@ryzeup/richtexteditor 1.0.32 â 1.0.33
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 +119 -119
- package/dist/index.js +2 -2
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(D,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],t):(D=typeof globalThis!="undefined"?globalThis:D||self,t(D.RichTextEditor={},D.React,D.ReactDOM))})(this,(function(D,t,$){"use strict";var an=Object.defineProperty,on=Object.defineProperties;var sn=Object.getOwnPropertyDescriptors;var Xe=Object.getOwnPropertySymbols;var cn=Object.prototype.hasOwnProperty,dn=Object.prototype.propertyIsEnumerable;var Ke=(D,t,$)=>t in D?an(D,t,{enumerable:!0,configurable:!0,writable:!0,value:$}):D[t]=$,ne=(D,t)=>{for(var $ in t||(t={}))cn.call(t,$)&&Ke(D,$,t[$]);if(Xe)for(var $ of Xe(t))dn.call(t,$)&&Ke(D,$,t[$]);return D},re=(D,t)=>on(D,sn(t));function Ye(a){const u=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const h in a)if(h!=="default"){const m=Object.getOwnPropertyDescriptor(a,h);Object.defineProperty(u,h,m.get?m:{enumerable:!0,get:()=>a[h]})}}return u.default=a,Object.freeze(u)}const Re=Ye(t);window.React=Re;var ge={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},pe=t.createContext&&t.createContext(ge),Qe=["attr","size","title"];function Ge(a,u){if(a==null)return{};var h=Je(a,u),m,v;if(Object.getOwnPropertySymbols){var L=Object.getOwnPropertySymbols(a);for(v=0;v<L.length;v++)m=L[v],!(u.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(a,m)&&(h[m]=a[m])}return h}function Je(a,u){if(a==null)return{};var h={};for(var m in a)if(Object.prototype.hasOwnProperty.call(a,m)){if(u.indexOf(m)>=0)continue;h[m]=a[m]}return h}function le(){return le=Object.assign?Object.assign.bind():function(a){for(var u=1;u<arguments.length;u++){var h=arguments[u];for(var m in h)Object.prototype.hasOwnProperty.call(h,m)&&(a[m]=h[m])}return a},le.apply(this,arguments)}function ve(a,u){var h=Object.keys(a);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(a);u&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(a,v).enumerable})),h.push.apply(h,m)}return h}function ae(a){for(var u=1;u<arguments.length;u++){var h=arguments[u]!=null?arguments[u]:{};u%2?ve(Object(h),!0).forEach(function(m){et(a,m,h[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(h)):ve(Object(h)).forEach(function(m){Object.defineProperty(a,m,Object.getOwnPropertyDescriptor(h,m))})}return a}function et(a,u,h){return u=tt(u),u in a?Object.defineProperty(a,u,{value:h,enumerable:!0,configurable:!0,writable:!0}):a[u]=h,a}function tt(a){var u=nt(a,"string");return typeof u=="symbol"?u:u+""}function nt(a,u){if(typeof a!="object"||!a)return a;var h=a[Symbol.toPrimitive];if(h!==void 0){var m=h.call(a,u);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(u==="string"?String:Number)(a)}function Ee(a){return a&&a.map((u,h)=>t.createElement(u.tag,ae({key:h},u.attr),Ee(u.child)))}function A(a){return u=>t.createElement(rt,le({attr:ae({},a.attr)},u),Ee(a.child))}function rt(a){var u=h=>{var{attr:m,size:v,title:L}=a,_=Ge(a,Qe),O=v||h.size||"1em",E;return h.className&&(E=h.className),a.className&&(E=(E?E+" ":"")+a.className),t.createElement("svg",le({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},h.attr,m,_,{className:E,style:ae(ae({color:a.color||h.color},h.style),a.style),height:O,width:O,xmlns:"http://www.w3.org/2000/svg"}),L&&t.createElement("title",null,L),a.children)};return pe!==void 0?t.createElement(pe.Consumer,null,h=>u(h)):u(ge)}function lt(a){return A({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 at(a){return A({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 ot(a){return A({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 it(a){return A({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 st(a){return A({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 ct(a){return A({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 dt(a){return A({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 ut(a){return A({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 mt(a){return A({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 ht(a){return A({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 ft(a){return A({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 gt(a){return A({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 pt(a){return A({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 A({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 Et(a){return A({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 yt(a){return A({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 A({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 bt(a){return A({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 Ct=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],ye=({exec:a,saveSelection:u,handleFileChange:h,handleFontSizeChange:m,handleFontFamilyChange:v,insertEmoji:L,handleLink:_,removeFormatting:O,visibleActions:E,className:N,style:M})=>{var V,Y;const x=t.useRef(null),W=t.useRef(null),b=t.useRef(null),[k,F]=t.useState(!1),[I,P]=t.useState({x:0,y:0});t.useEffect(()=>{const g=y=>{!y.target.closest(".rte-emoji-popup")&&!y.target.closest("button[title='Emoji']")&&F(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const q=g=>{var X;g.preventDefault();const y=g.currentTarget.dataset.command;if(y)switch(y){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertStaticUnorderedList":case"insertOrderedList":case"insertStaticOrderedList":case"removeFormat":a(y);break;case"insertImage":{(X=x.current)==null||X.click();break}default:console.warn("Unknown command:",y)}},K=g=>{a("foreColor",g.target.value)},Z=g=>{a("backColor",g.target.value)},[S,H]=t.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}),B=t.useRef(null),j=t.useRef(null);return t.useEffect(()=>{const g=()=>{const y=window.getSelection();if(!y||!y.anchorNode)return;let X=y.anchorNode.nodeType===Node.ELEMENT_NODE?y.anchorNode:y.anchorNode.parentElement;if(!X)return;const G=window.getComputedStyle(X),ie=G.fontFamily.replace(/['"]/g,"").split(",")[0],de=parseInt(G.fontSize,10);if(B.current){const J=Array.from(B.current.options).some(se=>se.value===ie);B.current.value=J?ie:""}j.current&&(j.current.value=String(de))};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),t.useEffect(()=>{const g=()=>{H({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)},[]),t.createElement("div",{className:`rte-toolbar ${N||""}`,style:M},E.bold&&t.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:q,className:S.bold?"rte-active":""},t.createElement(ct,null)),E.italic&&t.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:q,className:S.italic?"rte-active":""},t.createElement(ut,null)),E.underline&&t.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:q,className:S.underline?"rte-active":""},t.createElement(gt,null)),E.unorderedList&&t.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:q,title:"UnorderedList",className:S.unorderedList?"rte-active":""},t.createElement(vt,null)),E.staticUnorderedList&&t.createElement("button",{"data-command":"insertStaticUnorderedList",onMouseDown:q,title:"StaticUnorderedList",className:S.unorderedList?"rte-active":""},t.createElement(ht,null)),E.orderedList&&t.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:q,className:S.orderedList?"rte-active":"",style:{fontSize:"medium"}},t.createElement(pt,null)),E.staticOrderedList&&t.createElement("button",{"data-command":"insertStaticOrderedList",title:"StaticOrderedList",onMouseDown:q,className:S.orderedList?"rte-active":""},t.createElement(it,null)),E.link&&t.createElement("button",{"data-command":"createLink",title:"Link",onClick:_,className:S.link?"rte-active":""},t.createElement(mt,null)),E.removeFormat&&t.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),u(),O()},className:S.removeFormat?"rte-active":""},t.createElement(bt,null)),E.image&&t.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:q,className:S.image?"rte-active":""},t.createElement(ot,null)),t.createElement("input",{type:"file",accept:"image/*",ref:x,style:{display:"none"},onChange:h}),E.emoji&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),u();const y=g.currentTarget.getBoundingClientRect();P({x:y.left,y:y.bottom+8}),F(X=>!X)},className:S.emoji?"rte-active":""},t.createElement(ft,null)),k&&$.createPortal(t.createElement("div",{className:"rte-emoji-popup",style:{top:I.y,left:I.x}},Ct.map((g,y)=>t.createElement("span",{key:y,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:X=>{X.preventDefault(),L(g),F(!1)}},g))),document.body)),E.color&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Text Color",onMouseDown:g=>{var y;g.preventDefault(),u(),(y=W.current)==null||y.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((V=W.current)==null?void 0:V.value)||"#000",fontSize:"18px"},className:S.color?"rte-active":""},t.createElement(wt,null)),t.createElement("input",{ref:W,type:"color",defaultValue:"#000000",onChange:g=>{var y;K(g),((y=g.target.parentElement)==null?void 0:y.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Highlight",onMouseDown:g=>{var y;g.preventDefault(),u(),(y=b.current)==null||y.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((Y=b.current)==null?void 0:Y.value)||"#000",fontSize:"18px"},className:S.highlight?"rte-active":""},t.createElement(dt,null)),t.createElement("input",{ref:b,type:"color",onChange:g=>{var y;Z(g),((y=g.target.parentElement)==null?void 0:y.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&t.createElement(t.Fragment,null,t.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyLeft"),className:S.alignLeft?"rte-active":""},t.createElement(st,null)),t.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyCenter"),className:S.alignCenter?"rte-active":""},t.createElement(lt,null)),t.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyRight"),className:S.alignRight?"rte-active":""},t.createElement(at,null))),E.table&&t.createElement("button",{title:"Insert Dynamic Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertTable"),className:S.table?"rte-active":"",style:{fontSize:"medium"}},t.createElement(Et,null)),E.table&&t.createElement("button",{title:"Insert Static Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertStaticTable"),className:S.table?"rte-active":"",style:{fontSize:"medium"}},t.createElement(yt,null)),E.fontFamily&&t.createElement("select",{ref:B,className:"rte-dropdown",defaultValue:"",onMouseDown:()=>u(),onChange:v},t.createElement("option",{value:"",disabled:!0},"Font Family"),t.createElement("option",{value:"Arial"},"Arial"),t.createElement("option",{value:"Georgia"},"Georgia"),t.createElement("option",{value:"Times New Roman"},"Times New Roman"),t.createElement("option",{value:"Courier New"},"Courier New"),t.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&t.createElement("select",{ref:j,className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>u(),onChange:m},t.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(g,y)=>10+y).map(g=>t.createElement("option",{key:g,value:g},g,"px"))))},Lt=({show:a,position:u,filtered:h,insertMention:m,onClose:v,query:L})=>{const _=t.useRef(null),[O,E]=t.useState(0);return t.useEffect(()=>{a&&E(0)},[a]),t.useEffect(()=>{const N=M=>{_.current&&!_.current.contains(M.target)&&v()};return a&&document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[a,v]),t.useEffect(()=>{if(!a)return;const N=M=>{if(!(!a||h.length===0)&&(M.key==="ArrowDown"&&(M.preventDefault(),E(x=>Math.min(x+1,h.length-1))),M.key==="ArrowUp"&&(M.preventDefault(),E(x=>Math.max(x-1,0))),M.key==="Enter")){M.preventDefault();const x=h[O];x&&m(x)}};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[a,h,O]),t.useEffect(()=>{if(!_.current)return;const M=_.current.querySelectorAll("li")[O];M&&M.scrollIntoView({block:"nearest",behavior:"smooth"})},[O]),a?t.createElement("ul",{ref:_,className:"rte-popup",style:{top:u.y,left:u.x}},h.length>0?h.map(({name:N,value:M},x)=>{const W=N.toLowerCase(),b=L.toLowerCase(),k=W.indexOf(b);let F=N;if(k!==-1&&L.length>0){const I=k+L.length;F=N.substring(0,k)+`<span class="rte-highlight">${N.substring(k,I)}</span>`+N.substring(I)}return t.createElement("li",{key:M,onMouseDown:I=>{I.preventDefault(),m({name:N,value:M})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:x===O?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:F},onMouseEnter:()=>E(x)})}):t.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ce(a){return A({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 oe(a){return A({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 St=({visible:a,x:u,y:h,onAction:m,onClose:v})=>{if(!a)return null;const L={top:h,left:u};return t.createElement("div",{style:L,className:"rte-table-menu",onMouseLeave:v},t.createElement("button",{onClick:()=>m("insertRowAbove")},t.createElement(oe,null)," Insert row above"),t.createElement("button",{onClick:()=>m("insertRowBelow")},t.createElement(oe,null)," Insert row below"),t.createElement("button",{onClick:()=>m("insertColLeft")},t.createElement(oe,null)," Insert col left"),t.createElement("button",{onClick:()=>m("insertColRight")},t.createElement(oe,null)," Insert col right"),t.createElement("button",{onClick:()=>m("deleteRow")},t.createElement(ce,null)," Delete row"),t.createElement("button",{onClick:()=>m("deleteCol")},t.createElement(ce,null)," Delete column"),t.createElement("button",{onClick:()=>m("deleteTable")},t.createElement(ce,null)," Delete table"))};function we(a){return A({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M885.9 490.3c3.6-12 5.4-24.4 5.4-37 0-28.3-9.3-55.5-26.1-77.7 3.6-12 5.4-24.4 5.4-37 0-28.3-9.3-55.5-26.1-77.7 3.6-12 5.4-24.4 5.4-37 0-51.6-30.7-98.1-78.3-118.4a66.1 66.1 0 0 0-26.5-5.4H144c-17.7 0-32 14.3-32 32v364c0 17.7 14.3 32 32 32h129.3l85.8 310.8C372.9 889 418.9 924 470.9 924c29.7 0 57.4-11.8 77.9-33.4 20.5-21.5 31-49.7 29.5-79.4l-6-122.9h239.9c12.1 0 23.9-3.2 34.3-9.3 40.4-23.5 65.5-66.1 65.5-111 0-28.3-9.3-55.5-26.1-77.7zM184 456V172h81v284h-81zm627.2 160.4H496.8l9.6 198.4c.6 11.9-4.7 23.1-14.6 30.5-6.1 4.5-13.6 6.8-21.1 6.7a44.28 44.28 0 0 1-42.2-32.3L329 459.2V172h415.4a56.85 56.85 0 0 1 33.6 51.8c0 9.7-2.3 18.9-6.9 27.3l-13.9 25.4 21.9 19a56.76 56.76 0 0 1 19.6 43c0 9.7-2.3 18.9-6.9 27.3l-13.9 25.4 21.9 19a56.76 56.76 0 0 1 19.6 43c0 9.7-2.3 18.9-6.9 27.3l-14 25.5 21.9 19a56.76 56.76 0 0 1 19.6 43c0 19.1-11 37.5-28.8 48.4z"},child:[]}]})(a)}function be(a){return A({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M885.9 533.7c16.8-22.2 26.1-49.4 26.1-77.7 0-44.9-25.1-87.4-65.5-111.1a67.67 67.67 0 0 0-34.3-9.3H572.4l6-122.9c1.4-29.7-9.1-57.9-29.5-79.4A106.62 106.62 0 0 0 471 99.9c-52 0-98 35-111.8 85.1l-85.9 311H144c-17.7 0-32 14.3-32 32v364c0 17.7 14.3 32 32 32h601.3c9.2 0 18.2-1.8 26.5-5.4 47.6-20.3 78.3-66.8 78.3-118.4 0-12.6-1.8-25-5.4-37 16.8-22.2 26.1-49.4 26.1-77.7 0-12.6-1.8-25-5.4-37 16.8-22.2 26.1-49.4 26.1-77.7-.2-12.6-2-25.1-5.6-37.1zM184 852V568h81v284h-81zm636.4-353l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 16.5-7.2 32.2-19.6 43l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 16.5-7.2 32.2-19.6 43l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 22.4-13.2 42.6-33.6 51.8H329V564.8l99.5-360.5a44.1 44.1 0 0 1 42.2-32.3c7.6 0 15.1 2.2 21.1 6.7 9.9 7.4 15.2 18.6 14.6 30.5l-9.6 198.4h314.4C829 418.5 840 436.9 840 456c0 16.5-7.2 32.1-19.6 43z"},child:[]}]})(a)}const Ce=({html:a,className:u,style:h,attributes:m,setAttributes:v})=>{const[L,_]=t.useState("web"),O={web:{label:"Web",width:"100%",height:"100%"},galaxyS23:{label:"Galaxy S23",width:360,height:780},iphoneSE:{label:"iPhone SE (3rd Gen)",width:375,height:667},iphoneX:{label:"iPhone X / XS",width:375,height:812},pixel7a:{label:"Pixel 7a",width:390,height:844},iphone12:{label:"iPhone 12 / 13 / 14",width:390,height:844},iphone14:{label:"iPhone 14 Pro",width:393,height:852},pixel7:{label:"Pixel 7",width:412,height:915},iphone11:{label:"iPhone 11",width:414,height:896},iphone14ProMax:{label:"iPhone 14 Pro Max",width:430,height:932},pixel8Pro:{label:"Pixel 8 Pro",width:448,height:998},galaxyS24Ultra:{label:"Galaxy S24 Ultra",width:480,height:1040}},E=b=>{const k=b.target;if(k.tagName==="A"){b.preventDefault();const F=k.href;F&&window.open(F,"_blank","noopener,noreferrer")}},N=b=>b==="rgb(0, 0, 0)"||b==="rgba(0, 0, 0, 1)"||b==="#000"||b==="#000000"||b==="black",M=b=>{const k=document.createElement("div");k.innerHTML=b;const F=document.createTreeWalker(k,NodeFilter.SHOW_TEXT,null),I=[];for(;F.nextNode();){const P=F.currentNode;P.nodeValue&&/{{\s*[\s\S]*?\s*}}/.test(P.nodeValue)&&I.push(P)}return I.forEach(P=>{var j;const q=P.nodeValue||"",K=P.parentElement;if(!K)return;let Z=K,S=!1;for(;Z;){if(Z.tagName==="FONT"&&Z.getAttribute("color")){S=!0;break}const V=(j=Z.style)==null?void 0:j.color;if(V&&!N(V)){S=!0;break}const Y=window.getComputedStyle(Z);if(Y.color&&!N(Y.color)){S=!0;break}Z=Z.parentElement}const H=document.createDocumentFragment();let B=0;q.replace(/{{\s*([\s\S]*?)\s*}}/g,(V,Y,g)=>{if(g>B&&H.appendChild(document.createTextNode(q.slice(B,g))),S)H.appendChild(document.createTextNode(V));else{const y=document.createElement("span");y.style.color="blue",y.textContent=V,H.appendChild(y)}return B=g+V.length,V}),B<q.length&&H.appendChild(document.createTextNode(q.slice(B))),K.replaceChild(H,P)}),k.innerHTML=k.innerHTML.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""),k.innerHTML},x=()=>new Date().toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),W=()=>new Date().toLocaleString("en-US",{month:"short",day:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0});return t.createElement("div",{className:`rte-preview ${u||""}`,style:re(ne({},h),{position:"relative"}),onClick:E},t.createElement("div",{className:"rte-preview-device-picker"},t.createElement("select",{value:L,onChange:b=>_(b.target.value)},Object.entries(O).map(([b,k])=>t.createElement("option",{key:b,value:b},k.label)))),L==="web"&&t.createElement("div",{className:"rte-preview-web-wrapper"},t.createElement("div",{className:"rte-preview-card"},t.createElement("div",{className:"rte-preview-content",dangerouslySetInnerHTML:{__html:M(a)}}),t.createElement("div",{className:"rte-preview-meta"},"Data updated as on Dec 14, 2025"),t.createElement("div",{className:"rte-preview-footer"},t.createElement("div",{className:"rte-preview-actions"},t.createElement(be,{className:"rte-preview-like"}),t.createElement(we,{className:"rte-preview-like"})),t.createElement("div",{className:"rte-preview-time"},"Dec 26, 2025 5:57 PM")))),L!=="web"&&t.createElement("div",{className:"rte-preview-mobile-overlay"},t.createElement("div",{className:"rte-preview-mobile-frame",style:{width:O[L].width,height:O[L].height}},t.createElement("div",{className:"rte-preview-mobile-header"},t.createElement("div",{className:"rte-preview-logo"},"A"),t.createElement("div",{className:"rte-preview-bell"},"đ",t.createElement("span",{className:"rte-preview-badge"},"99+"))),t.createElement("div",{className:"rte-preview-tabs-wrapper"},t.createElement("div",{className:"rte-preview-tabs"},t.createElement("div",{className:"rte-preview-tab rte-preview-tab-active"},"My Alerts"),t.createElement("div",{className:"rte-preview-tab"},"Reportees Alerts"))),t.createElement("div",{className:"rte-preview-mobile-body"},t.createElement("div",{className:"rte-preview-card"},t.createElement("div",{className:"rte-preview-content",dangerouslySetInnerHTML:{__html:M(a)}}),t.createElement("div",{className:"rte-preview-meta"},"Data updated as on ",x()),t.createElement("div",{className:"rte-preview-footer"},t.createElement("div",{className:"rte-preview-actions"},t.createElement(be,{className:"rte-preview-like"}),t.createElement(we,{className:"rte-preview-like"})),t.createElement("div",{className:"rte-preview-time"},W())))))),t.createElement("div",null,t.createElement("h3",{style:{marginBottom:10}},"Enter Attribute Values"),t.createElement("div",{className:"rte-attr-list"},Object.keys(m).map(b=>t.createElement("div",{key:b,className:"rte-attr-row"},t.createElement("div",{className:"rte-attr-name"},`{{${b}}}`),t.createElement("span",null," : "),t.createElement("input",{className:"rte-attr-input",value:m[b]||"",onChange:k=>{const F=k.target.value;v(I=>re(ne({},I),{[b]:F}))},placeholder:"Enter value"}))))))},xt=({visible:a,linkData:u,onClose:h,onInsert:m})=>{const[v,L]=t.useState(""),[_,O]=t.useState(""),[E,N]=t.useState(""),[M,x]=t.useState("_self");if(t.useEffect(()=>{a?(L(u.url||""),O(u.text||""),N(u.title||""),x(u.target||"_self")):(L(""),O(""),N(""),x("_self"))},[a,u]),!a)return null;const W=()=>{m({url:v,text:_,title:E,target:M})};return t.createElement(t.Fragment,null,t.createElement("div",{className:"rte-link-modal-overlay",onClick:h}),t.createElement("div",{className:"rte-link-modal"},t.createElement("h4",{className:"rte-link-modal__title"},v?"Edit Link":"Insert Link"),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:v,onChange:b=>L(b.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:_,onChange:b=>O(b.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:b=>N(b.target.value)}),t.createElement("select",{className:"rte-link-modal__select",value:M,onChange:b=>x(b.target.value)},t.createElement("option",{value:"_self"},"Same tab"),t.createElement("option",{value:"_blank"},"New tab")),t.createElement("div",{className:"rte-link-modal__actions"},t.createElement("button",{className:"rte-link-modal__btn",onClick:h},"Cancel"),t.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:W},"OK"))))};function Le(a){const u=new Map;return a.forEach(h=>{u.set(h.name,h.value)}),Array.from(u.entries()).map(([h,m])=>({name:h,value:m}))}const Nt=({atSuggestions:a=[],showOutput:u=!1,showPreview:h=!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:v={},styles:L={},handleGetHtml:_=()=>{},onChange:O=()=>{},value:E,onMentionSelect:N=()=>{},handleAddAttributes:M=()=>{}})=>{var Pe,_e,je,Fe,Ie,qe,Be,Ve,Ue,$e,We,Ze;const x=t.useRef(null),[W,b]=t.useState(E!=null&&E.length?E:" "),[k,F]=t.useState(""),[I,P]=t.useState(!1),[q,K]=t.useState({x:0,y:0}),[Z,S]=t.useState([]),H=t.useRef(null),B=t.useRef(null),[j,V]=t.useState({visible:!1,x:0,y:0}),[Y,g]=t.useState(!1),y=t.useRef(null),[X,G]=t.useState({url:"",text:"",title:"",target:"_self"}),ie={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:(Pe=m.unorderedList)!=null?Pe:!0,orderedList:(_e=m.orderedList)!=null?_e:!0,staticUnorderedList:(je=m.staticUnorderedList)!=null?je:!0,staticOrderedList:(Fe=m.staticOrderedList)!=null?Fe:!0,align:!0,link:(Ie=m.link)!=null?Ie:!1,image:(qe=m.image)!=null?qe:!1,emoji:(Be=m.emoji)!=null?Be:!1,table:(Ve=m.table)!=null?Ve:!1,color:(Ue=m.color)!=null?Ue:!1,fontFamily:($e=m.fontFamily)!=null?$e:!1,fontSize:(We=m.fontSize)!=null?We:!1,highlight:(Ze=m.fontSize)!=null?Ze:!1},[de,J]=t.useState(""),[se,ue]=t.useState([]),[Se,xe]=t.useState({}),U=()=>x.current,T=()=>{const e=Mt(),n=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let r=e;n||(r=`<div style="font-size: 12px;">${e}</div>`),r=r.replace(/<(ul|ol)([^>]*)>[\s\S]*?<\/\1>/g,(o,w,f)=>{if(/list-type=["']static["']/.test(f)||o.includes("data-hidden-array-start")||o.includes("data-hidden-array-end"))return o;const d=`<${w}${f}>`,s='<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>',p='<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span>',C=`</${w}>`,z=o.replace(new RegExp(`^${d}`),"").replace(new RegExp(`${C}$`),"");return`${d}${s}${z}${p}${C}`}),F(r),_==null||_(r);const l=Xt(e);O(l);const c=Pt(),i=Le(c);JSON.stringify(i)!==JSON.stringify(se)&&(ue(i),N(i),tn(i))},Mt=()=>{const e=U();if(!e)return W;const n=e.cloneNode(!0);n.querySelectorAll("table div").forEach(l=>l.remove()),n.querySelectorAll("table").forEach(l=>{l.removeAttribute("data-has-resize-handle")}),n.querySelectorAll(".rte-table-selected , .rte-cell-highlight").forEach(l=>l.classList.remove(".rte-table-selected , .rte-cell-highlight"));let r=n.innerHTML;return r=Tt(r),r},Tt=e=>{const n=document.createElement("div");return n.innerHTML=e,n.querySelectorAll("tbody").forEach(r=>{r.getAttribute("table-type")==="static"||(r.innerHTML=`{{#arrayData}}${r.innerHTML}{{/arrayData}}`)}),n.innerHTML},R=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=document.getElementById("rte-editor-body");if(!n)return;const r=e.getRangeAt(0);n.contains(r.startContainer)&&(H.current=r.cloneRange())},Q=()=>{const e=window.getSelection();!e||!H.current||(e.removeAllRanges(),e.addRange(H.current))},Ne=(e,n)=>{const r=window.getSelection();r&&r.rangeCount>0&&(H.current=r.getRangeAt(0)),Q(),document.execCommand(e,!1,n),T()};t.useEffect(()=>{const e=U();if(!e||!E)return;const n=At(E);e.innerHTML=n,T()},[]);const At=e=>e.replace(/(<table[\s\S]*?>[\s\S]*?<\/table>)/g,n=>n.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""));t.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),t.useEffect(()=>{M&&M(e=>{Ht(e)})},[]),t.useEffect(()=>{const e=U();if(!e)return;e.querySelectorAll("table").forEach(r=>{r.hasAttribute("data-has-resize-handle")||(fe(r),r.querySelectorAll("th, td").forEach(c=>ee(c)))})},[]),t.useEffect(()=>{const e=()=>{requestAnimationFrame(()=>{ln()})};return document.addEventListener("selectionchange",e),()=>{document.removeEventListener("selectionchange",e)}},[]),t.useEffect(()=>{const e=x.current;if(!e)return;const n=()=>{e.querySelectorAll("table.rte-table-selected").forEach(l=>{l.dataset.__rteSelected="true",l.classList.remove("rte-table-selected")})},r=()=>{e.querySelectorAll("table[data-__rte-selected]").forEach(l=>{l.classList.add("rte-table-selected"),l.removeAttribute("data-__rte-selected")})};return e.addEventListener("copy",n),document.addEventListener("mouseup",r),()=>{e.removeEventListener("copy",n),document.removeEventListener("mouseup",r)}},[]);const Me=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},Te=(e,n)=>{var d;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.getRangeAt(0),c=Me(l.startContainer);let i,o;const w=n==="insertStaticUnorderedList"||n==="insertStaticOrderedList";if(c){let s=c.querySelector(e);s||(s=document.createElement(e),s.style.margin="0",s.style.paddingLeft="20px",c.appendChild(s)),o=s,i=document.createElement("li"),i.textContent="â",o.appendChild(i)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const s=U();if(o=s==null?void 0:s.querySelector(`${e}:last-child`),!o)return;w&&o.setAttribute("list-type","static"),i=o.querySelector("li:last-child")}const f=document.createRange();f.setStart(i,0),f.collapse(!0),r.removeAllRanges(),r.addRange(f),(d=U())==null||d.focus(),T()},me=(e,n)=>{e==="insertOrderedList"||e==="insertStaticOrderedList"?Te("ol",e):e==="insertUnorderedList"||e==="insertStaticUnorderedList"?Te("ul",e):e.startsWith("justify")?Kt(e):Ne(e,n),e==="insertTable"&&ke(),e==="insertStaticTable"&&ke("insertStaticTable")},kt=e=>{const n=document.createElement("span");n.textContent="â",e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const r=n.getBoundingClientRect();n.remove(),K({x:r.left,y:r.bottom+window.scrollY}),S(a||[]),P(!0),B.current=e.cloneRange()},zt=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.anchorNode;let r=e.anchorOffset;if(!n)return null;let l=n;for(l.nodeType!==Node.TEXT_NODE&&(l.childNodes&&l.childNodes[r]?l=l.childNodes[r]:l=n.previousSibling);l;){if(l.nodeType===Node.TEXT_NODE){const c=l.textContent||"",i=l===n?r:c.length,o=c.lastIndexOf("@",i-1);if(o!==-1){const w=document.createRange();return w.setStart(l,o),w.setEnd(l,i),w}}l=l.previousSibling}return null},Dt=e=>{var i;const n=window.getSelection();if(!n)return;const r=zt();r?(n.removeAllRanges(),n.addRange(r)):B.current&&(n.removeAllRanges(),n.addRange(B.current));const l=document.createElement("span");l.textContent=`{{${e.name}}}`,l.style.display="inline",l.setAttribute("data-mention",e.value||e.name||""),l.title=`{{${e.name}}}`;try{const o=n.rangeCount?n.getRangeAt(0):null;if(o)o.deleteContents(),o.insertNode(l);else{const d=document.createRange(),s=U();d.selectNodeContents(s),d.collapse(!1),d.insertNode(l)}const w=document.createTextNode("â");l.after(w);const f=document.createRange();f.setStartAfter(w),f.collapse(!0),n.removeAllRanges(),n.addRange(f)}catch(o){console.error("insertMention error:",o)}let c=Le([...se,e]);ue(c),N(c),P(!1),(i=U())==null||i.focus(),T()},Ot=e=>{const n=U();if(!n)return;let r=null;H.current&&n.contains(H.current.startContainer)?r=H.current.cloneRange():(r=document.createRange(),r.selectNodeContents(n),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),c.title=`{{${e.name}}}`,r.insertNode(c);const i=document.createTextNode(" ");c.after(i);const o=document.createRange();o.setStartAfter(i),o.collapse(!0),l.removeAllRanges(),l.addRange(o),H.current=o.cloneRange(),n.focus()},Ht=e=>{e.forEach(n=>Ot(n)),ue(n=>{const r=[...n,...e],l=Array.from(new Map(r.map(c=>[c.name,c])).values());return N(l),l}),T()},Pt=()=>{const e=U();if(!e)return[];const n=e.querySelectorAll("span[data-mention]"),r=[];return n.forEach(l=>{const c=l.getAttribute("data-mention")||"",o=(l.textContent||"").match(/{{(.+?)}}/);o&&r.push({name:o[1],value:c})}),r},_t=e=>{var r,l,c;const n=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(n)&&(e.preventDefault(),me(n==="b"?"bold":n==="i"?"italic":n==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const i=window.getSelection(),o=i!=null&&i.anchorNode?Me(i.anchorNode):null;if(!o)return;if(((r=o.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const f=o.parentElement,d=f==null?void 0:f.closest("li");if(d){f==null||f.removeChild(o);const s=document.createElement("p");s.innerHTML="<br />",(l=d.parentElement)==null||l.insertBefore(s,d.nextSibling);const p=document.createRange();p.setStart(s,0),p.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(p)}else{const s=o.closest("ul, ol");if(s){const p=document.createElement("p");p.innerHTML="<br />",(c=s.parentElement)==null||c.insertBefore(p,s.nextSibling),s.removeChild(o);const C=document.createRange();C.setStart(p,0),C.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(C)}}T()}}if(n==="backspace"||n==="delete"){const i=window.getSelection();if(!i||i.rangeCount===0)return;const o=i.getRangeAt(0);if(o.cloneContents().querySelector("table"))return;if(o.cloneContents().querySelectorAll(".rte-resize-handle").length>0){e.preventDefault(),e.stopPropagation();return}}},jt=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.anchorNode;if(he(l))return;setTimeout(()=>{kt(r.getRangeAt(0)),J(""),S(a),P(!0)},0);return}if(I){setTimeout(()=>Ae(),0);return}},he=e=>{if(!e)return!1;let n=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;n;){if(n.tagName==="TH")return!0;n=n.parentElement}return!1},Ae=()=>{T();const e=window.getSelection();if(!e||!e.anchorNode)return;if(he(e.anchorNode)){P(!1);return}let n=e.anchorNode.textContent||"";n=n.replace(/\u00A0/g," ");const r=n.match(/@([^\n]*)$/);if(!r){P(!1);return}const l=r[1].trim().toLowerCase();J(l);const c=a.filter(i=>i.name.toLowerCase().includes(l));c.length>0?(S(c),P(!0)):P(!1)},Ft=e=>{var l;const n=(l=e.target.files)==null?void 0:l[0];if(!n)return;const r=new FileReader;r.onload=c=>{var C;const i=(C=c.target)==null?void 0:C.result;Q();const o=window.getSelection();let w=o&&o.rangeCount?o.getRangeAt(0):null;const f=document.createElement("img");f.src=i,f.alt=n.name||"image",f.className="rte-inserted-image",f.contentEditable="true";const d=U();if(!w||!d){d==null||d.appendChild(f);const z=document.createTextNode(" ");d==null||d.appendChild(z);const te=document.createRange();te.setStartAfter(z),te.collapse(!0),o==null||o.removeAllRanges(),o==null||o.addRange(te),d==null||d.focus(),T(),e.target.value="";return}w.deleteContents(),w.insertNode(f);const s=document.createTextNode(" ");f.after(s);const p=document.createRange();p.setStartAfter(s),p.collapse(!0),o.removeAllRanges(),o.addRange(p),d.focus(),T(),e.target.value=""},r.readAsDataURL(n)},It=e=>{var c;Q();const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const r=n.getRangeAt(0),l=document.createTextNode(e);r.insertNode(l),r.setStartAfter(l),r.collapse(!0),n.removeAllRanges(),n.addRange(r),(c=U())==null||c.focus(),T()},ke=e=>{var s;Jt(),Q();const n=document.createElement("table");n.style.borderCollapse="collapse",n.style.width="310px",n.style.border="1px solid #ccc",n.style.margin="8px 0",n.style.position="relative",n.style.textAlign="center",v.table&&n.classList.add(v.table);const r=document.createElement("thead");v.thead&&r.classList.add(v.thead);const l=document.createElement("tbody");v.tbody&&l.classList.add(v.tbody),e==="insertStaticTable"&&l.setAttribute("table-type","static");const c=document.createElement("tr");v.tr&&c.classList.add(v.tr);const i=document.createElement("tr");v.tr&&i.classList.add(v.tr);for(let p=0;p<2;p++){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",v.th&&C.classList.add(v.th);const z=document.createElement("td");z.textContent="",z.style.border="1px solid #999",z.style.padding="4px",z.style.position="relative",z.style.backgroundColor="#fff",z.style.minHeight="20px",z.style.height="20px",z.style.whiteSpace="normal",z.style.wordBreak="break-word",z.style.overflowWrap="anywhere",z.style.lineHeight="20px",z.style.minWidth="20px",v.td&&z.classList.add(v.td),ee(C),ee(z),c.appendChild(C),i.appendChild(z)}r.appendChild(c),l.appendChild(i),n.appendChild(r),n.appendChild(l),fe(n);const o=window.getSelection();if(!(o!=null&&o.rangeCount))return;const w=o.getRangeAt(0);w.collapse(!1),w.insertNode(n);const f=document.createElement("p");f.innerHTML="<br/>",n.after(f);const d=document.createRange();d.setStart(f,0),d.collapse(!0),o.removeAllRanges(),o.addRange(d),(s=U())==null||s.focus(),T()},fe=e=>{if(e.dataset.hasResizeHandle==="true")return;const n=document.createElement("div");Object.assign(n.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"}),n.contentEditable="false",n.dataset.hasResizeHandle="true",n.classList.add("rte-resize-handle"),n.addEventListener("mousedown",r=>{r.preventDefault(),r.clientX,r.clientY;const l=e.getBoundingClientRect();l.width,l.height;const c=o=>{const w=Math.max(100,o.clientX-l.left),f=Math.max(20,o.clientY-l.top);e.style.width=`${w}px`,e.style.height=`${f}px`,T()},i=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",i),T()};document.addEventListener("mousemove",c),document.addEventListener("mouseup",i)}),e.appendChild(n)},ee=e=>{const n=document.createElement("div"),r=document.createElement("div");Object.assign(n.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"}),n.contentEditable="false",n.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"),qt(e,n,r),e.appendChild(n),e.appendChild(r)},qt=(e,n,r)=>{let l=0,c=0,i=0,o=0;n.addEventListener("mousedown",s=>{s.preventDefault(),l=s.clientX,i=e.offsetWidth,document.addEventListener("mousemove",w),document.addEventListener("mouseup",d)}),r.addEventListener("mousedown",s=>{s.preventDefault(),c=s.clientY,o=e.offsetHeight,document.addEventListener("mousemove",f),document.addEventListener("mouseup",d)});const w=s=>{const p=i+(s.clientX-l);e.style.width=`${Math.max(30,p)}px`,T()},f=s=>{const p=o+(s.clientY-c);e.style.height=`${Math.max(20,p)}px`,T()},d=()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",d),T()}},Bt=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"),V({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},ze=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))};function De(){const e=x.current;e&&e.querySelectorAll("table.rte-table-selected").forEach(n=>n.classList.remove("rte-table-selected"))}const Vt=e=>{var i,o,w;if(!j.cell)return;const n=j.cell.closest("table"),r=j.cell.cellIndex,l=j.cell.parentElement.rowIndex,c=f=>{const d=f.tagName.toLowerCase(),s=document.createElement(d);return s.textContent="",s.style.cssText=f.style.cssText,ee(s),s};switch(e){case"insertRowAbove":{const f=n.rows[l],d=n.insertRow(l);Array.from(f.cells).forEach(s=>{d.appendChild(c(s))});break}case"insertRowBelow":{const f=n.rows[l],d=n.insertRow(l+1);Array.from(f.cells).forEach(s=>{d.appendChild(c(s))});break}case"insertColLeft":{Array.from(n.rows).forEach(f=>{const d=f.cells[r];f.insertBefore(c(d),d)});break}case"insertColRight":{Array.from(n.rows).forEach(f=>{const d=f.cells[r];f.insertBefore(c(d),d.nextSibling)});break}case"deleteRow":n.rows.length>1&&n.deleteRow(l);break;case"deleteCol":Array.from(n.rows).forEach(f=>{f.cells[r]&&f.deleteCell(r)});break;case"deleteTable":{const f=(i=j.cell)==null?void 0:i.closest("table");if(!f)break;f.remove();const d=document.createElement("p");d.innerHTML="<br />",(w=(o=j.cell)==null?void 0:o.parentElement)==null||w.after(d);break}}requestAnimationFrame(()=>T()),V(re(ne({},j),{visible:!1})),ze(),De()},Ut=()=>{R(),y.current=H.current,G({url:"",text:"",title:"",target:"_self"}),g(!0)},$t=e=>{const n=window.getSelection();if(!n||!y.current)return;n.removeAllRanges(),n.addRange(y.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=n.getRangeAt(0);c.deleteContents(),c.insertNode(l);const i=document.createTextNode(" ");l.after(i);const o=document.createRange();o.setStartAfter(i),o.collapse(!0),n.removeAllRanges(),n.addRange(o),g(!1),T()},Wt=e=>{const n=e.target;if(n.tagName==="A"){const r=n;if(e.ctrlKey||e.metaKey){window.open(r.href,"_blank","noopener,noreferrer");return}e.preventDefault();const l=document.createRange();l.selectNode(r),y.current=l,G({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),g(!0)}},Zt=()=>{const e=U();if(!e)return;const n=window.getSelection();if((!n||n.rangeCount===0)&&H.current){const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(H.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const l=r.getRangeAt(0);Q(),document.execCommand("removeFormat",!1);const c=l.cloneContents(),i=document.createElement("div");i.appendChild(c);const o=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT,null),w=[];for(;o.nextNode();){const s=o.currentNode,p=s.tagName.toUpperCase(),C=s.getAttribute&&s.getAttribute("data-mention")!==null;p!=="A"&&!C&&w.push(s)}for(let s=w.length-1;s>=0;s--){const p=w[s],C=p.parentNode;if(C){for(;p.firstChild;)C.insertBefore(p.firstChild,p);C.removeChild(p)}}i.querySelectorAll("[style]").forEach(s=>s.removeAttribute("style")),l.deleteContents();const f=document.createDocumentFragment();for(;i.firstChild;)f.appendChild(i.firstChild);l.insertNode(f);const d=document.createRange();d.setStartAfter(l.endContainer.nodeType===Node.TEXT_NODE?l.endContainer:l.startContainer),d.collapse(!0),r.removeAllRanges(),r.addRange(d),e.normalize(),T()},Xt=e=>{var l;let n=e;n=n.replace(/{{#arrayData\d*}}/g,""),n=n.replace(/{{\/arrayData\d*}}/g,"");const r=document.createElement("div");return r.innerHTML=n,r.querySelectorAll("br").forEach(c=>{c.replaceWith(`
|
|
1
|
+
(function(D,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],t):(D=typeof globalThis!="undefined"?globalThis:D||self,t(D.RichTextEditor={},D.React,D.ReactDOM))})(this,(function(D,t,$){"use strict";var an=Object.defineProperty,on=Object.defineProperties;var sn=Object.getOwnPropertyDescriptors;var Xe=Object.getOwnPropertySymbols;var cn=Object.prototype.hasOwnProperty,dn=Object.prototype.propertyIsEnumerable;var Ke=(D,t,$)=>t in D?an(D,t,{enumerable:!0,configurable:!0,writable:!0,value:$}):D[t]=$,ne=(D,t)=>{for(var $ in t||(t={}))cn.call(t,$)&&Ke(D,$,t[$]);if(Xe)for(var $ of Xe(t))dn.call(t,$)&&Ke(D,$,t[$]);return D},re=(D,t)=>on(D,sn(t));function Ye(a){const u=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const h in a)if(h!=="default"){const m=Object.getOwnPropertyDescriptor(a,h);Object.defineProperty(u,h,m.get?m:{enumerable:!0,get:()=>a[h]})}}return u.default=a,Object.freeze(u)}const Re=Ye(t);window.React=Re;var ge={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},pe=t.createContext&&t.createContext(ge),Qe=["attr","size","title"];function Ge(a,u){if(a==null)return{};var h=Je(a,u),m,v;if(Object.getOwnPropertySymbols){var S=Object.getOwnPropertySymbols(a);for(v=0;v<S.length;v++)m=S[v],!(u.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(a,m)&&(h[m]=a[m])}return h}function Je(a,u){if(a==null)return{};var h={};for(var m in a)if(Object.prototype.hasOwnProperty.call(a,m)){if(u.indexOf(m)>=0)continue;h[m]=a[m]}return h}function le(){return le=Object.assign?Object.assign.bind():function(a){for(var u=1;u<arguments.length;u++){var h=arguments[u];for(var m in h)Object.prototype.hasOwnProperty.call(h,m)&&(a[m]=h[m])}return a},le.apply(this,arguments)}function ve(a,u){var h=Object.keys(a);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(a);u&&(m=m.filter(function(v){return Object.getOwnPropertyDescriptor(a,v).enumerable})),h.push.apply(h,m)}return h}function ae(a){for(var u=1;u<arguments.length;u++){var h=arguments[u]!=null?arguments[u]:{};u%2?ve(Object(h),!0).forEach(function(m){et(a,m,h[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(h)):ve(Object(h)).forEach(function(m){Object.defineProperty(a,m,Object.getOwnPropertyDescriptor(h,m))})}return a}function et(a,u,h){return u=tt(u),u in a?Object.defineProperty(a,u,{value:h,enumerable:!0,configurable:!0,writable:!0}):a[u]=h,a}function tt(a){var u=nt(a,"string");return typeof u=="symbol"?u:u+""}function nt(a,u){if(typeof a!="object"||!a)return a;var h=a[Symbol.toPrimitive];if(h!==void 0){var m=h.call(a,u);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(u==="string"?String:Number)(a)}function Ee(a){return a&&a.map((u,h)=>t.createElement(u.tag,ae({key:h},u.attr),Ee(u.child)))}function A(a){return u=>t.createElement(rt,le({attr:ae({},a.attr)},u),Ee(a.child))}function rt(a){var u=h=>{var{attr:m,size:v,title:S}=a,_=Ge(a,Qe),H=v||h.size||"1em",E;return h.className&&(E=h.className),a.className&&(E=(E?E+" ":"")+a.className),t.createElement("svg",le({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},h.attr,m,_,{className:E,style:ae(ae({color:a.color||h.color},h.style),a.style),height:H,width:H,xmlns:"http://www.w3.org/2000/svg"}),S&&t.createElement("title",null,S),a.children)};return pe!==void 0?t.createElement(pe.Consumer,null,h=>u(h)):u(ge)}function lt(a){return A({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 at(a){return A({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 ot(a){return A({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 it(a){return A({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 st(a){return A({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 ct(a){return A({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 dt(a){return A({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 ut(a){return A({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 mt(a){return A({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 ht(a){return A({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 ft(a){return A({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 gt(a){return A({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 pt(a){return A({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 A({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 Et(a){return A({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 yt(a){return A({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 A({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 bt(a){return A({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 Ct=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],ye=({exec:a,saveSelection:u,handleFileChange:h,handleFontSizeChange:m,handleFontFamilyChange:v,insertEmoji:S,handleLink:_,removeFormatting:H,visibleActions:E,className:N,style:M})=>{var V,Y;const x=t.useRef(null),W=t.useRef(null),C=t.useRef(null),[k,F]=t.useState(!1),[I,P]=t.useState({x:0,y:0});t.useEffect(()=>{const g=y=>{!y.target.closest(".rte-emoji-popup")&&!y.target.closest("button[title='Emoji']")&&F(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const q=g=>{var X;g.preventDefault();const y=g.currentTarget.dataset.command;if(y)switch(y){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertStaticUnorderedList":case"insertOrderedList":case"insertStaticOrderedList":case"removeFormat":a(y);break;case"insertImage":{(X=x.current)==null||X.click();break}default:console.warn("Unknown command:",y)}},K=g=>{a("foreColor",g.target.value)},Z=g=>{a("backColor",g.target.value)},[L,O]=t.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}),B=t.useRef(null),j=t.useRef(null);return t.useEffect(()=>{const g=()=>{const y=window.getSelection();if(!y||!y.anchorNode)return;let X=y.anchorNode.nodeType===Node.ELEMENT_NODE?y.anchorNode:y.anchorNode.parentElement;if(!X)return;const G=window.getComputedStyle(X),ie=G.fontFamily.replace(/['"]/g,"").split(",")[0],de=parseInt(G.fontSize,10);if(B.current){const J=Array.from(B.current.options).some(se=>se.value===ie);B.current.value=J?ie:""}j.current&&(j.current.value=String(de))};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),t.useEffect(()=>{const g=()=>{O({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)},[]),t.createElement("div",{className:`rte-toolbar ${N||""}`,style:M},E.bold&&t.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:q,className:L.bold?"rte-active":""},t.createElement(ct,null)),E.italic&&t.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:q,className:L.italic?"rte-active":""},t.createElement(ut,null)),E.underline&&t.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:q,className:L.underline?"rte-active":""},t.createElement(gt,null)),E.unorderedList&&t.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:q,title:"UnorderedList",className:L.unorderedList?"rte-active":""},t.createElement(vt,null)),E.staticUnorderedList&&t.createElement("button",{"data-command":"insertStaticUnorderedList",onMouseDown:q,title:"StaticUnorderedList",className:L.unorderedList?"rte-active":""},t.createElement(ht,null)),E.orderedList&&t.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:q,className:L.orderedList?"rte-active":"",style:{fontSize:"medium"}},t.createElement(pt,null)),E.staticOrderedList&&t.createElement("button",{"data-command":"insertStaticOrderedList",title:"StaticOrderedList",onMouseDown:q,className:L.orderedList?"rte-active":""},t.createElement(it,null)),E.link&&t.createElement("button",{"data-command":"createLink",title:"Link",onClick:_,className:L.link?"rte-active":""},t.createElement(mt,null)),E.removeFormat&&t.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),u(),H()},className:L.removeFormat?"rte-active":""},t.createElement(bt,null)),E.image&&t.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:q,className:L.image?"rte-active":""},t.createElement(ot,null)),t.createElement("input",{type:"file",accept:"image/*",ref:x,style:{display:"none"},onChange:h}),E.emoji&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),u();const y=g.currentTarget.getBoundingClientRect();P({x:y.left,y:y.bottom+8}),F(X=>!X)},className:L.emoji?"rte-active":""},t.createElement(ft,null)),k&&$.createPortal(t.createElement("div",{className:"rte-emoji-popup",style:{top:I.y,left:I.x}},Ct.map((g,y)=>t.createElement("span",{key:y,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:X=>{X.preventDefault(),S(g),F(!1)}},g))),document.body)),E.color&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Text Color",onMouseDown:g=>{var y;g.preventDefault(),u(),(y=W.current)==null||y.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((V=W.current)==null?void 0:V.value)||"#000",fontSize:"18px"},className:L.color?"rte-active":""},t.createElement(wt,null)),t.createElement("input",{ref:W,type:"color",defaultValue:"#000000",onChange:g=>{var y;K(g),((y=g.target.parentElement)==null?void 0:y.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Highlight",onMouseDown:g=>{var y;g.preventDefault(),u(),(y=C.current)==null||y.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((Y=C.current)==null?void 0:Y.value)||"#000",fontSize:"18px"},className:L.highlight?"rte-active":""},t.createElement(dt,null)),t.createElement("input",{ref:C,type:"color",onChange:g=>{var y;Z(g),((y=g.target.parentElement)==null?void 0:y.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&t.createElement(t.Fragment,null,t.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyLeft"),className:L.alignLeft?"rte-active":""},t.createElement(st,null)),t.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyCenter"),className:L.alignCenter?"rte-active":""},t.createElement(lt,null)),t.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyRight"),className:L.alignRight?"rte-active":""},t.createElement(at,null))),E.table&&t.createElement("button",{title:"Insert Dynamic Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertTable"),className:L.table?"rte-active":"",style:{fontSize:"medium"}},t.createElement(Et,null)),E.table&&t.createElement("button",{title:"Insert Static Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertStaticTable"),className:L.table?"rte-active":"",style:{fontSize:"medium"}},t.createElement(yt,null)),E.fontFamily&&t.createElement("select",{ref:B,className:"rte-dropdown",defaultValue:"",onMouseDown:()=>u(),onChange:v},t.createElement("option",{value:"",disabled:!0},"Font Family"),t.createElement("option",{value:"Arial"},"Arial"),t.createElement("option",{value:"Georgia"},"Georgia"),t.createElement("option",{value:"Times New Roman"},"Times New Roman"),t.createElement("option",{value:"Courier New"},"Courier New"),t.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&t.createElement("select",{ref:j,className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>u(),onChange:m},t.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(g,y)=>10+y).map(g=>t.createElement("option",{key:g,value:g},g,"px"))))},St=({show:a,position:u,filtered:h,insertMention:m,onClose:v,query:S})=>{const _=t.useRef(null),[H,E]=t.useState(0);return t.useEffect(()=>{a&&E(0)},[a]),t.useEffect(()=>{const N=M=>{_.current&&!_.current.contains(M.target)&&v()};return a&&document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[a,v]),t.useEffect(()=>{if(!a)return;const N=M=>{if(!(!a||h.length===0)&&(M.key==="ArrowDown"&&(M.preventDefault(),E(x=>Math.min(x+1,h.length-1))),M.key==="ArrowUp"&&(M.preventDefault(),E(x=>Math.max(x-1,0))),M.key==="Enter")){M.preventDefault();const x=h[H];x&&m(x)}};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[a,h,H]),t.useEffect(()=>{if(!_.current)return;const M=_.current.querySelectorAll("li")[H];M&&M.scrollIntoView({block:"nearest",behavior:"smooth"})},[H]),a?t.createElement("ul",{ref:_,className:"rte-popup",style:{top:u.y,left:u.x}},h.length>0?h.map(({name:N,value:M},x)=>{const W=N.toLowerCase(),C=S.toLowerCase(),k=W.indexOf(C);let F=N;if(k!==-1&&S.length>0){const I=k+S.length;F=N.substring(0,k)+`<span class="rte-highlight">${N.substring(k,I)}</span>`+N.substring(I)}return t.createElement("li",{key:M,onMouseDown:I=>{I.preventDefault(),m({name:N,value:M})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:x===H?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:F},onMouseEnter:()=>E(x)})}):t.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ce(a){return A({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 oe(a){return A({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 Lt=({visible:a,x:u,y:h,onAction:m,onClose:v})=>{if(!a)return null;const S={top:h,left:u};return t.createElement("div",{style:S,className:"rte-table-menu",onMouseLeave:v},t.createElement("button",{onClick:()=>m("insertRowAbove")},t.createElement(oe,null)," Insert row above"),t.createElement("button",{onClick:()=>m("insertRowBelow")},t.createElement(oe,null)," Insert row below"),t.createElement("button",{onClick:()=>m("insertColLeft")},t.createElement(oe,null)," Insert col left"),t.createElement("button",{onClick:()=>m("insertColRight")},t.createElement(oe,null)," Insert col right"),t.createElement("button",{onClick:()=>m("deleteRow")},t.createElement(ce,null)," Delete row"),t.createElement("button",{onClick:()=>m("deleteCol")},t.createElement(ce,null)," Delete column"),t.createElement("button",{onClick:()=>m("deleteTable")},t.createElement(ce,null)," Delete table"))};function we(a){return A({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M885.9 490.3c3.6-12 5.4-24.4 5.4-37 0-28.3-9.3-55.5-26.1-77.7 3.6-12 5.4-24.4 5.4-37 0-28.3-9.3-55.5-26.1-77.7 3.6-12 5.4-24.4 5.4-37 0-51.6-30.7-98.1-78.3-118.4a66.1 66.1 0 0 0-26.5-5.4H144c-17.7 0-32 14.3-32 32v364c0 17.7 14.3 32 32 32h129.3l85.8 310.8C372.9 889 418.9 924 470.9 924c29.7 0 57.4-11.8 77.9-33.4 20.5-21.5 31-49.7 29.5-79.4l-6-122.9h239.9c12.1 0 23.9-3.2 34.3-9.3 40.4-23.5 65.5-66.1 65.5-111 0-28.3-9.3-55.5-26.1-77.7zM184 456V172h81v284h-81zm627.2 160.4H496.8l9.6 198.4c.6 11.9-4.7 23.1-14.6 30.5-6.1 4.5-13.6 6.8-21.1 6.7a44.28 44.28 0 0 1-42.2-32.3L329 459.2V172h415.4a56.85 56.85 0 0 1 33.6 51.8c0 9.7-2.3 18.9-6.9 27.3l-13.9 25.4 21.9 19a56.76 56.76 0 0 1 19.6 43c0 9.7-2.3 18.9-6.9 27.3l-13.9 25.4 21.9 19a56.76 56.76 0 0 1 19.6 43c0 9.7-2.3 18.9-6.9 27.3l-14 25.5 21.9 19a56.76 56.76 0 0 1 19.6 43c0 19.1-11 37.5-28.8 48.4z"},child:[]}]})(a)}function be(a){return A({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M885.9 533.7c16.8-22.2 26.1-49.4 26.1-77.7 0-44.9-25.1-87.4-65.5-111.1a67.67 67.67 0 0 0-34.3-9.3H572.4l6-122.9c1.4-29.7-9.1-57.9-29.5-79.4A106.62 106.62 0 0 0 471 99.9c-52 0-98 35-111.8 85.1l-85.9 311H144c-17.7 0-32 14.3-32 32v364c0 17.7 14.3 32 32 32h601.3c9.2 0 18.2-1.8 26.5-5.4 47.6-20.3 78.3-66.8 78.3-118.4 0-12.6-1.8-25-5.4-37 16.8-22.2 26.1-49.4 26.1-77.7 0-12.6-1.8-25-5.4-37 16.8-22.2 26.1-49.4 26.1-77.7-.2-12.6-2-25.1-5.6-37.1zM184 852V568h81v284h-81zm636.4-353l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 16.5-7.2 32.2-19.6 43l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 16.5-7.2 32.2-19.6 43l-21.9 19 13.9 25.4a56.2 56.2 0 0 1 6.9 27.3c0 22.4-13.2 42.6-33.6 51.8H329V564.8l99.5-360.5a44.1 44.1 0 0 1 42.2-32.3c7.6 0 15.1 2.2 21.1 6.7 9.9 7.4 15.2 18.6 14.6 30.5l-9.6 198.4h314.4C829 418.5 840 436.9 840 456c0 16.5-7.2 32.1-19.6 43z"},child:[]}]})(a)}const Ce=({html:a,className:u,style:h,attributes:m,setAttributes:v})=>{const[S,_]=t.useState("web"),H={web:{label:"Web",width:"100%",height:"100%"},galaxyS23:{label:"Galaxy S23",width:360,height:780},iphoneSE:{label:"iPhone SE (3rd Gen)",width:375,height:667},iphoneX:{label:"iPhone X / XS",width:375,height:812},pixel7a:{label:"Pixel 7a",width:390,height:844},iphone12:{label:"iPhone 12 / 13 / 14",width:390,height:844},iphone14:{label:"iPhone 14 Pro",width:393,height:852},pixel7:{label:"Pixel 7",width:412,height:915},iphone11:{label:"iPhone 11",width:414,height:896},iphone14ProMax:{label:"iPhone 14 Pro Max",width:430,height:932},pixel8Pro:{label:"Pixel 8 Pro",width:448,height:998},galaxyS24Ultra:{label:"Galaxy S24 Ultra",width:480,height:1040}},E=C=>{const k=C.target;if(k.tagName==="A"){C.preventDefault();const F=k.href;F&&window.open(F,"_blank","noopener,noreferrer")}},N=C=>C==="rgb(0, 0, 0)"||C==="rgba(0, 0, 0, 1)"||C==="#000"||C==="#000000"||C==="black",M=C=>{const k=document.createElement("div");k.innerHTML=C;const F=document.createTreeWalker(k,NodeFilter.SHOW_TEXT,null),I=[];for(;F.nextNode();){const P=F.currentNode;P.nodeValue&&/{{\s*[\s\S]*?\s*}}/.test(P.nodeValue)&&I.push(P)}return I.forEach(P=>{var j;const q=P.nodeValue||"",K=P.parentElement;if(!K)return;let Z=K,L=!1;for(;Z;){if(Z.tagName==="FONT"&&Z.getAttribute("color")){L=!0;break}const V=(j=Z.style)==null?void 0:j.color;if(V&&!N(V)){L=!0;break}const Y=window.getComputedStyle(Z);if(Y.color&&!N(Y.color)){L=!0;break}Z=Z.parentElement}const O=document.createDocumentFragment();let B=0;q.replace(/{{\s*([\s\S]*?)\s*}}/g,(V,Y,g)=>{if(g>B&&O.appendChild(document.createTextNode(q.slice(B,g))),L)O.appendChild(document.createTextNode(V));else{const y=document.createElement("span");y.style.color="blue",y.textContent=V,O.appendChild(y)}return B=g+V.length,V}),B<q.length&&O.appendChild(document.createTextNode(q.slice(B))),K.replaceChild(O,P)}),k.innerHTML=k.innerHTML.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""),k.innerHTML},x=()=>new Date().toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),W=()=>new Date().toLocaleString("en-US",{month:"short",day:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0});return t.createElement("div",{className:`rte-preview ${u||""}`,style:re(ne({},h),{position:"relative"}),onClick:E},t.createElement("div",{className:"rte-preview-device-picker"},t.createElement("select",{value:S,onChange:C=>_(C.target.value)},Object.entries(H).map(([C,k])=>t.createElement("option",{key:C,value:C},k.label)))),S==="web"&&t.createElement("div",{className:"rte-preview-web-wrapper"},t.createElement("div",{className:"rte-preview-card"},t.createElement("div",{className:"rte-preview-content",dangerouslySetInnerHTML:{__html:M(a)}}),t.createElement("div",{className:"rte-preview-meta"},"Data updated as on Dec 14, 2025"),t.createElement("div",{className:"rte-preview-footer"},t.createElement("div",{className:"rte-preview-actions"},t.createElement(be,{className:"rte-preview-like"}),t.createElement(we,{className:"rte-preview-like"})),t.createElement("div",{className:"rte-preview-time"},"Dec 26, 2025 5:57 PM")))),S!=="web"&&t.createElement("div",{className:"rte-preview-mobile-overlay"},t.createElement("div",{className:"rte-preview-mobile-frame",style:{width:H[S].width,height:H[S].height}},t.createElement("div",{className:"rte-preview-mobile-header"},t.createElement("div",{className:"rte-preview-logo"},"A"),t.createElement("div",{className:"rte-preview-bell"},"đ",t.createElement("span",{className:"rte-preview-badge"},"99+"))),t.createElement("div",{className:"rte-preview-tabs-wrapper"},t.createElement("div",{className:"rte-preview-tabs"},t.createElement("div",{className:"rte-preview-tab rte-preview-tab-active"},"My Alerts"),t.createElement("div",{className:"rte-preview-tab"},"Reportees Alerts"))),t.createElement("div",{className:"rte-preview-mobile-body"},t.createElement("div",{className:"rte-preview-card"},t.createElement("div",{className:"rte-preview-content",dangerouslySetInnerHTML:{__html:M(a)}}),t.createElement("div",{className:"rte-preview-meta"},"Data updated as on ",x()),t.createElement("div",{className:"rte-preview-footer"},t.createElement("div",{className:"rte-preview-actions"},t.createElement(be,{className:"rte-preview-like"}),t.createElement(we,{className:"rte-preview-like"})),t.createElement("div",{className:"rte-preview-time"},W())))))),t.createElement("div",null,t.createElement("h3",{style:{marginBottom:10}},"Enter Attribute Values"),t.createElement("div",{className:"rte-attr-list"},Object.keys(m).map(C=>t.createElement("div",{key:C,className:"rte-attr-row"},t.createElement("div",{className:"rte-attr-name"},`{{${C}}}`),t.createElement("span",null," : "),t.createElement("input",{className:"rte-attr-input",value:m[C]||"",onChange:k=>{const F=k.target.value;v(I=>re(ne({},I),{[C]:F}))},placeholder:"Enter value"}))))))},xt=({visible:a,linkData:u,onClose:h,onInsert:m})=>{const[v,S]=t.useState(""),[_,H]=t.useState(""),[E,N]=t.useState(""),[M,x]=t.useState("_self");if(t.useEffect(()=>{a?(S(u.url||""),H(u.text||""),N(u.title||""),x(u.target||"_self")):(S(""),H(""),N(""),x("_self"))},[a,u]),!a)return null;const W=()=>{m({url:v,text:_,title:E,target:M})};return t.createElement(t.Fragment,null,t.createElement("div",{className:"rte-link-modal-overlay",onClick:h}),t.createElement("div",{className:"rte-link-modal"},t.createElement("h4",{className:"rte-link-modal__title"},v?"Edit Link":"Insert Link"),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:v,onChange:C=>S(C.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:_,onChange:C=>H(C.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:C=>N(C.target.value)}),t.createElement("select",{className:"rte-link-modal__select",value:M,onChange:C=>x(C.target.value)},t.createElement("option",{value:"_self"},"Same tab"),t.createElement("option",{value:"_blank"},"New tab")),t.createElement("div",{className:"rte-link-modal__actions"},t.createElement("button",{className:"rte-link-modal__btn",onClick:h},"Cancel"),t.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:W},"OK"))))};function Se(a){const u=new Map;return a.forEach(h=>{u.set(h.name,h.value)}),Array.from(u.entries()).map(([h,m])=>({name:h,value:m}))}const Nt=({atSuggestions:a=[],showOutput:u=!1,showPreview:h=!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:v={},styles:S={},handleGetHtml:_=()=>{},onChange:H=()=>{},value:E,onMentionSelect:N=()=>{},handleAddAttributes:M=()=>{}})=>{var Pe,_e,je,Fe,Ie,qe,Be,Ve,Ue,$e,We,Ze;const x=t.useRef(null),[W,C]=t.useState(E!=null&&E.length?E:" "),[k,F]=t.useState(""),[I,P]=t.useState(!1),[q,K]=t.useState({x:0,y:0}),[Z,L]=t.useState([]),O=t.useRef(null),B=t.useRef(null),[j,V]=t.useState({visible:!1,x:0,y:0}),[Y,g]=t.useState(!1),y=t.useRef(null),[X,G]=t.useState({url:"",text:"",title:"",target:"_self"}),ie={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:(Pe=m.unorderedList)!=null?Pe:!0,orderedList:(_e=m.orderedList)!=null?_e:!0,staticUnorderedList:(je=m.staticUnorderedList)!=null?je:!0,staticOrderedList:(Fe=m.staticOrderedList)!=null?Fe:!0,align:!0,link:(Ie=m.link)!=null?Ie:!1,image:(qe=m.image)!=null?qe:!1,emoji:(Be=m.emoji)!=null?Be:!1,table:(Ve=m.table)!=null?Ve:!1,color:(Ue=m.color)!=null?Ue:!1,fontFamily:($e=m.fontFamily)!=null?$e:!1,fontSize:(We=m.fontSize)!=null?We:!1,highlight:(Ze=m.fontSize)!=null?Ze:!1},[de,J]=t.useState(""),[se,ue]=t.useState([]),[Le,xe]=t.useState({}),U=()=>x.current,T=()=>{const e=Mt(),n=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let r=e;n||(r=`<div style="font-size: 12px;">${e}</div>`),r=r.replace(/<(ul|ol)([^>]*)>[\s\S]*?<\/\1>/g,(o,w,f)=>{if(/list-type=["']static["']/.test(f)||o.includes("data-hidden-array-start")||o.includes("data-hidden-array-end"))return o;const d=`<${w}${f}>`,s='<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>',p='<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span>',b=`</${w}>`,z=o.replace(new RegExp(`^${d}`),"").replace(new RegExp(`${b}$`),"");return`${d}${s}${z}${p}${b}`}),F(r),_==null||_(r);const l=Xt(e);H(l);const c=Pt(),i=Se(c);JSON.stringify(i)!==JSON.stringify(se)&&(ue(i),N(i),tn(i))},Mt=()=>{const e=U();if(!e)return W;const n=e.cloneNode(!0);n.querySelectorAll("table div").forEach(l=>l.remove()),n.querySelectorAll("table").forEach(l=>{l.removeAttribute("data-has-resize-handle")}),n.querySelectorAll(".rte-table-selected , .rte-cell-highlight").forEach(l=>l.classList.remove(".rte-table-selected , .rte-cell-highlight"));let r=n.innerHTML;return r=Tt(r),r},Tt=e=>{const n=document.createElement("div");return n.innerHTML=e,n.querySelectorAll("tbody").forEach(r=>{r.getAttribute("table-type")==="static"||(r.innerHTML=`{{#arrayData}}${r.innerHTML}{{/arrayData}}`)}),n.innerHTML},R=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=document.getElementById("rte-editor-body");if(!n)return;const r=e.getRangeAt(0);n.contains(r.startContainer)&&(O.current=r.cloneRange())},Q=()=>{const e=window.getSelection();!e||!O.current||(e.removeAllRanges(),e.addRange(O.current))},Ne=(e,n)=>{const r=window.getSelection();r&&r.rangeCount>0&&(O.current=r.getRangeAt(0)),Q(),document.execCommand(e,!1,n),T()};t.useEffect(()=>{const e=U();if(!e||!E)return;const n=At(E);e.innerHTML=n,T()},[]);const At=e=>e.replace(/(<table[\s\S]*?>[\s\S]*?<\/table>)/g,n=>n.replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,""));t.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),t.useEffect(()=>{M&&M(e=>{Ot(e)})},[]),t.useEffect(()=>{const e=U();if(!e)return;e.querySelectorAll("table").forEach(r=>{r.hasAttribute("data-has-resize-handle")||(fe(r),r.querySelectorAll("th, td").forEach(c=>ee(c)))})},[]),t.useEffect(()=>{const e=()=>{requestAnimationFrame(()=>{ln()})};return document.addEventListener("selectionchange",e),()=>{document.removeEventListener("selectionchange",e)}},[]),t.useEffect(()=>{const e=x.current;if(!e)return;const n=()=>{e.querySelectorAll("table.rte-table-selected").forEach(l=>{l.dataset.__rteSelected="true",l.classList.remove("rte-table-selected")})},r=()=>{e.querySelectorAll("table[data-__rte-selected]").forEach(l=>{l.classList.add("rte-table-selected"),l.removeAttribute("data-__rte-selected")})};return e.addEventListener("copy",n),document.addEventListener("mouseup",r),()=>{e.removeEventListener("copy",n),document.removeEventListener("mouseup",r)}},[]);const Me=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},Te=(e,n)=>{var d;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.getRangeAt(0),c=Me(l.startContainer);let i,o;const w=n==="insertStaticUnorderedList"||n==="insertStaticOrderedList";if(c){let s=c.querySelector(e);s||(s=document.createElement(e),s.style.margin="0",s.style.paddingLeft="20px",c.appendChild(s)),o=s,i=document.createElement("li"),i.textContent="â",o.appendChild(i)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const s=U();if(o=s==null?void 0:s.querySelector(`${e}:last-child`),!o)return;w&&o.setAttribute("list-type","static"),i=o.querySelector("li:last-child")}const f=document.createRange();f.setStart(i,0),f.collapse(!0),r.removeAllRanges(),r.addRange(f),(d=U())==null||d.focus(),T()},me=(e,n)=>{e==="insertOrderedList"||e==="insertStaticOrderedList"?Te("ol",e):e==="insertUnorderedList"||e==="insertStaticUnorderedList"?Te("ul",e):e.startsWith("justify")?Kt(e):Ne(e,n),e==="insertTable"&&ke(),e==="insertStaticTable"&&ke("insertStaticTable")},kt=e=>{const n=document.createElement("span");n.textContent="â",e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const r=n.getBoundingClientRect();n.remove(),K({x:r.left,y:r.bottom+window.scrollY}),L(a||[]),P(!0),B.current=e.cloneRange()},zt=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.anchorNode;let r=e.anchorOffset;if(!n)return null;let l=n;for(l.nodeType!==Node.TEXT_NODE&&(l.childNodes&&l.childNodes[r]?l=l.childNodes[r]:l=n.previousSibling);l;){if(l.nodeType===Node.TEXT_NODE){const c=l.textContent||"",i=l===n?r:c.length,o=c.lastIndexOf("@",i-1);if(o!==-1){const w=document.createRange();return w.setStart(l,o),w.setEnd(l,i),w}}l=l.previousSibling}return null},Dt=e=>{var i;const n=window.getSelection();if(!n)return;const r=zt();r?(n.removeAllRanges(),n.addRange(r)):B.current&&(n.removeAllRanges(),n.addRange(B.current));const l=document.createElement("span");l.textContent=`{{${e.name}}}`,l.style.display="inline",l.setAttribute("data-mention",e.value||e.name||""),l.title=`{{${e.name}}}`;try{const o=n.rangeCount?n.getRangeAt(0):null;if(o)o.deleteContents(),o.insertNode(l);else{const d=document.createRange(),s=U();d.selectNodeContents(s),d.collapse(!1),d.insertNode(l)}const w=document.createTextNode("â");l.after(w);const f=document.createRange();f.setStartAfter(w),f.collapse(!0),n.removeAllRanges(),n.addRange(f)}catch(o){console.error("insertMention error:",o)}let c=Se([...se,e]);ue(c),N(c),P(!1),(i=U())==null||i.focus(),T()},Ht=e=>{const n=U();if(!n)return;let r=null;O.current&&n.contains(O.current.startContainer)?r=O.current.cloneRange():(r=document.createRange(),r.selectNodeContents(n),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),c.title=`{{${e.name}}}`,r.insertNode(c);const i=document.createTextNode(" ");c.after(i);const o=document.createRange();o.setStartAfter(i),o.collapse(!0),l.removeAllRanges(),l.addRange(o),O.current=o.cloneRange(),n.focus()},Ot=e=>{e.forEach(n=>Ht(n)),ue(n=>{const r=[...n,...e],l=Array.from(new Map(r.map(c=>[c.name,c])).values());return N(l),l}),T()},Pt=()=>{const e=U();if(!e)return[];const n=e.querySelectorAll("span[data-mention]"),r=[];return n.forEach(l=>{const c=l.getAttribute("data-mention")||"",o=(l.textContent||"").match(/{{(.+?)}}/);o&&r.push({name:o[1],value:c})}),r},_t=e=>{var r,l,c;const n=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(n)&&(e.preventDefault(),me(n==="b"?"bold":n==="i"?"italic":n==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const i=window.getSelection(),o=i!=null&&i.anchorNode?Me(i.anchorNode):null;if(!o)return;if(((r=o.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const f=o.parentElement,d=f==null?void 0:f.closest("li");if(d){f==null||f.removeChild(o);const s=document.createElement("p");s.innerHTML="<br />",(l=d.parentElement)==null||l.insertBefore(s,d.nextSibling);const p=document.createRange();p.setStart(s,0),p.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(p)}else{const s=o.closest("ul, ol");if(s){const p=document.createElement("p");p.innerHTML="<br />",(c=s.parentElement)==null||c.insertBefore(p,s.nextSibling),s.removeChild(o);const b=document.createRange();b.setStart(p,0),b.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(b)}}T()}}if(n==="backspace"||n==="delete"){const i=window.getSelection();if(!i||i.rangeCount===0)return;const o=i.getRangeAt(0);if(o.cloneContents().querySelector("table"))return;if(o.cloneContents().querySelectorAll(".rte-resize-handle").length>0){e.preventDefault(),e.stopPropagation();return}}},jt=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.anchorNode;if(he(l))return;setTimeout(()=>{kt(r.getRangeAt(0)),J(""),L(a),P(!0)},0);return}if(I){setTimeout(()=>Ae(),0);return}},he=e=>{if(!e)return!1;let n=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;n;){if(n.tagName==="TH")return!0;n=n.parentElement}return!1},Ae=()=>{T();const e=window.getSelection();if(!e||!e.anchorNode)return;if(he(e.anchorNode)){P(!1);return}let n=e.anchorNode.textContent||"";n=n.replace(/\u00A0/g," ");const r=n.match(/@([^\n]*)$/);if(!r){P(!1);return}const l=r[1].trim().toLowerCase();J(l);const c=a.filter(i=>i.name.toLowerCase().includes(l));c.length>0?(L(c),P(!0)):P(!1)},Ft=e=>{var l;const n=(l=e.target.files)==null?void 0:l[0];if(!n)return;const r=new FileReader;r.onload=c=>{var b;const i=(b=c.target)==null?void 0:b.result;Q();const o=window.getSelection();let w=o&&o.rangeCount?o.getRangeAt(0):null;const f=document.createElement("img");f.src=i,f.alt=n.name||"image",f.className="rte-inserted-image",f.contentEditable="true";const d=U();if(!w||!d){d==null||d.appendChild(f);const z=document.createTextNode(" ");d==null||d.appendChild(z);const te=document.createRange();te.setStartAfter(z),te.collapse(!0),o==null||o.removeAllRanges(),o==null||o.addRange(te),d==null||d.focus(),T(),e.target.value="";return}w.deleteContents(),w.insertNode(f);const s=document.createTextNode(" ");f.after(s);const p=document.createRange();p.setStartAfter(s),p.collapse(!0),o.removeAllRanges(),o.addRange(p),d.focus(),T(),e.target.value=""},r.readAsDataURL(n)},It=e=>{var c;Q();const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const r=n.getRangeAt(0),l=document.createTextNode(e);r.insertNode(l),r.setStartAfter(l),r.collapse(!0),n.removeAllRanges(),n.addRange(r),(c=U())==null||c.focus(),T()},ke=e=>{var s;Jt(),Q();const n=document.createElement("table");n.style.borderCollapse="collapse",n.style.width="310px",n.style.border="1px solid #ccc",n.style.margin="8px 0",n.style.position="relative",n.style.textAlign="center",v.table&&n.classList.add(v.table);const r=document.createElement("thead");v.thead&&r.classList.add(v.thead);const l=document.createElement("tbody");v.tbody&&l.classList.add(v.tbody),e==="insertStaticTable"&&l.setAttribute("table-type","static");const c=document.createElement("tr");v.tr&&c.classList.add(v.tr);const i=document.createElement("tr");v.tr&&i.classList.add(v.tr);for(let p=0;p<2;p++){const b=document.createElement("th");b.textContent="",b.style.border="1px solid #999",b.style.padding="4px",b.style.position="relative",b.style.backgroundColor="lightgray",b.style.height="20px",b.style.whiteSpace="normal",b.style.wordBreak="break-word",b.style.overflowWrap="anywhere",b.style.lineHeight="20px",b.style.minWidth="20px",v.th&&b.classList.add(v.th);const z=document.createElement("td");z.textContent="",z.style.border="1px solid #999",z.style.padding="4px",z.style.position="relative",z.style.backgroundColor="#fff",z.style.minHeight="20px",z.style.height="20px",z.style.whiteSpace="normal",z.style.wordBreak="break-word",z.style.overflowWrap="anywhere",z.style.lineHeight="20px",z.style.minWidth="20px",v.td&&z.classList.add(v.td),ee(b),ee(z),c.appendChild(b),i.appendChild(z)}r.appendChild(c),l.appendChild(i),n.appendChild(r),n.appendChild(l),fe(n);const o=window.getSelection();if(!(o!=null&&o.rangeCount))return;const w=o.getRangeAt(0);w.collapse(!1),w.insertNode(n);const f=document.createElement("p");f.innerHTML="<br/>",n.after(f);const d=document.createRange();d.setStart(f,0),d.collapse(!0),o.removeAllRanges(),o.addRange(d),(s=U())==null||s.focus(),T()},fe=e=>{if(e.dataset.hasResizeHandle==="true")return;const n=document.createElement("div");Object.assign(n.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"}),n.contentEditable="false",n.dataset.hasResizeHandle="true",n.classList.add("rte-resize-handle"),n.addEventListener("mousedown",r=>{r.preventDefault(),r.clientX,r.clientY;const l=e.getBoundingClientRect();l.width,l.height;const c=o=>{const w=Math.max(100,o.clientX-l.left),f=Math.max(20,o.clientY-l.top);e.style.width=`${w}px`,e.style.height=`${f}px`,T()},i=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",i),T()};document.addEventListener("mousemove",c),document.addEventListener("mouseup",i)}),e.appendChild(n)},ee=e=>{const n=document.createElement("div"),r=document.createElement("div");Object.assign(n.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"}),n.contentEditable="false",n.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"),qt(e,n,r),e.appendChild(n),e.appendChild(r)},qt=(e,n,r)=>{let l=0,c=0,i=0,o=0;n.addEventListener("mousedown",s=>{s.preventDefault(),l=s.clientX,i=e.offsetWidth,document.addEventListener("mousemove",w),document.addEventListener("mouseup",d)}),r.addEventListener("mousedown",s=>{s.preventDefault(),c=s.clientY,o=e.offsetHeight,document.addEventListener("mousemove",f),document.addEventListener("mouseup",d)});const w=s=>{const p=i+(s.clientX-l);e.style.width=`${Math.max(30,p)}px`,T()},f=s=>{const p=o+(s.clientY-c);e.style.height=`${Math.max(20,p)}px`,T()},d=()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",d),T()}},Bt=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"),V({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},ze=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))};function De(){const e=x.current;e&&e.querySelectorAll("table.rte-table-selected").forEach(n=>n.classList.remove("rte-table-selected"))}const Vt=e=>{var i,o,w;if(!j.cell)return;const n=j.cell.closest("table"),r=j.cell.cellIndex,l=j.cell.parentElement.rowIndex,c=f=>{const d=f.tagName.toLowerCase(),s=document.createElement(d);return s.textContent="",s.style.cssText=f.style.cssText,ee(s),s};switch(e){case"insertRowAbove":{const f=n.rows[l],d=n.insertRow(l);Array.from(f.cells).forEach(s=>{d.appendChild(c(s))});break}case"insertRowBelow":{const f=n.rows[l],d=n.insertRow(l+1);Array.from(f.cells).forEach(s=>{d.appendChild(c(s))});break}case"insertColLeft":{Array.from(n.rows).forEach(f=>{const d=f.cells[r];f.insertBefore(c(d),d)});break}case"insertColRight":{Array.from(n.rows).forEach(f=>{const d=f.cells[r];f.insertBefore(c(d),d.nextSibling)});break}case"deleteRow":n.rows.length>1&&n.deleteRow(l);break;case"deleteCol":Array.from(n.rows).forEach(f=>{f.cells[r]&&f.deleteCell(r)});break;case"deleteTable":{const f=(i=j.cell)==null?void 0:i.closest("table");if(!f)break;f.remove();const d=document.createElement("p");d.innerHTML="<br />",(w=(o=j.cell)==null?void 0:o.parentElement)==null||w.after(d);break}}requestAnimationFrame(()=>T()),V(re(ne({},j),{visible:!1})),ze(),De()},Ut=()=>{R(),y.current=O.current,G({url:"",text:"",title:"",target:"_self"}),g(!0)},$t=e=>{const n=window.getSelection();if(!n||!y.current)return;n.removeAllRanges(),n.addRange(y.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=n.getRangeAt(0);c.deleteContents(),c.insertNode(l);const i=document.createTextNode(" ");l.after(i);const o=document.createRange();o.setStartAfter(i),o.collapse(!0),n.removeAllRanges(),n.addRange(o),g(!1),T()},Wt=e=>{const n=e.target;if(n.tagName==="A"){const r=n;if(e.ctrlKey||e.metaKey){window.open(r.href,"_blank","noopener,noreferrer");return}e.preventDefault();const l=document.createRange();l.selectNode(r),y.current=l,G({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),g(!0)}},Zt=()=>{const e=U();if(!e)return;const n=window.getSelection();if((!n||n.rangeCount===0)&&O.current){const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(O.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const l=r.getRangeAt(0);Q(),document.execCommand("removeFormat",!1);const c=l.cloneContents(),i=document.createElement("div");i.appendChild(c);const o=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT,null),w=[];for(;o.nextNode();){const s=o.currentNode,p=s.tagName.toUpperCase(),b=s.getAttribute&&s.getAttribute("data-mention")!==null;p!=="A"&&!b&&w.push(s)}for(let s=w.length-1;s>=0;s--){const p=w[s],b=p.parentNode;if(b){for(;p.firstChild;)b.insertBefore(p.firstChild,p);b.removeChild(p)}}i.querySelectorAll("[style]").forEach(s=>s.removeAttribute("style")),l.deleteContents();const f=document.createDocumentFragment();for(;i.firstChild;)f.appendChild(i.firstChild);l.insertNode(f);const d=document.createRange();d.setStartAfter(l.endContainer.nodeType===Node.TEXT_NODE?l.endContainer:l.startContainer),d.collapse(!0),r.removeAllRanges(),r.addRange(d),e.normalize(),T()},Xt=e=>{var l;let n=e;n=n.replace(/{{#arrayData\d*}}/g,""),n=n.replace(/{{\/arrayData\d*}}/g,"");const r=document.createElement("div");return r.innerHTML=n,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
|
|
6
|
+
`).trim())||""};function He(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const n=e.getRangeAt(0);if(n.collapsed){let i=n.startContainer,o=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement;const w=o==null?void 0:o.closest("td, th");return w?[w]:[]}const r=n.commonAncestorContainer,l=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;return Array.from(l.querySelectorAll("td, th")).filter(i=>{const o=document.createRange();return o.selectNodeContents(i),n.compareBoundaryPoints(Range.END_TO_START,o)<0&&n.compareBoundaryPoints(Range.START_TO_END,o)>0})}function Kt(e){const n=He();if(n.length===0){Ne(e);return}let r="left";e==="justifyCenter"&&(r="center"),e==="justifyRight"&&(r="right"),n.forEach(l=>{l.style.textAlign=r}),T()}const Yt=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return!1;let n=e.anchorNode.nodeType===Node.ELEMENT_NODE?e.anchorNode:e.anchorNode.parentElement;for(;n;){if(n.tagName==="TABLE")return!0;n=n.parentElement}return!1},Rt=e=>{if(Yt()){e.preventDefault();const d=e.clipboardData.getData("text/plain");if(!d)return;const s=window.getSelection();if(!s||!s.rangeCount)return;const p=s.getRangeAt(0);p.deleteContents();const b=d.split(/\r?\n/);b.forEach((z,te)=>{p.insertNode(document.createTextNode(z)),te<b.length-1&&p.insertNode(document.createElement("br"))}),p.collapse(!1),s.removeAllRanges(),s.addRange(p),T();return}const n=e.clipboardData.getData("text/html")||"";if(!n)return;const r=document.createElement("div");if(r.innerHTML=n,r.querySelector("img")){e.preventDefault();return}e.preventDefault();const l=document.createElement("div");l.innerHTML=n;const c=d=>{d.hasAttribute("data-has-resize-handle")||(d.style.borderCollapse="collapse",d.style.width="100%",d.style.border="1px solid #ccc",d.style.margin="8px 0",d.style.position="relative",d.style.textAlign="center",d.querySelectorAll("th").forEach(s=>{const p=s;p.style.border="1px solid #999",p.style.padding="4px",p.style.position="relative",p.style.backgroundColor="lightgray",p.style.height="20px",p.style.whiteSpace="normal",p.style.wordBreak="break-word",p.style.overflowWrap="anywhere",p.style.lineHeight="20px",p.style.minWidth="20px"}),d.querySelectorAll("td").forEach(s=>{const p=s;p.style.border="1px solid #999",p.style.padding="4px",p.style.position="relative",p.style.backgroundColor="#fff",p.style.height="20px",p.style.minHeight="20px",p.style.whiteSpace="normal",p.style.wordBreak="break-word",p.style.overflowWrap="anywhere",p.style.lineHeight="20px",p.style.minWidth="20px"}))};l.querySelectorAll("table").forEach(d=>c(d));const i=window.getSelection();if(!i||!i.rangeCount)return;const o=i.getRangeAt(0);o.deleteContents();const w=document.createDocumentFragment();for(;l.firstChild;)w.appendChild(l.firstChild);o.insertNode(w),o.collapse(!1),i.removeAllRanges(),i.addRange(o);const f=x.current;f&&(f.querySelectorAll("table").forEach(d=>{const s=d;s.hasAttribute("data-has-resize-handle")||(fe(s),s.querySelectorAll("th, td").forEach(p=>{const b=p;b.dataset.hasResizeHandles||ee(b)}))}),T())},Qt=e=>{Q();const n=window.getSelection();if(!n||!n.rangeCount)return;const r=He();if(r.length>0){r.forEach(o=>{o.style.fontSize=`${e}px`,o.style.lineHeight="1.2"}),T();return}const l=n.getRangeAt(0);if(l.collapsed)return;const c=document.createElement("span");c.style.fontSize=`${e}px`,c.appendChild(l.extractContents()),l.insertNode(c);const i=document.createRange();i.setStartAfter(c),i.collapse(!0),n.removeAllRanges(),n.addRange(i),T()},Gt=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return null;const n=e.anchorNode;if(he(n)||n.nodeType!==Node.TEXT_NODE)return null;const r=n.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 o=document.createRange();return o.setStart(n,c),o.setEnd(n,l),{range:o,query:i}},Oe=()=>{const e=Gt();if(!e)return;const{range:n,query:r}=e,l=document.createElement("span");l.textContent="â",n.insertNode(l);const c=l.getBoundingClientRect();l.remove(),K({x:c.left,y:c.bottom+window.scrollY}),J(r.toLowerCase());const i=a.filter(o=>o.name.toLowerCase().includes(r.toLowerCase()));L(i),P(!0),B.current=n.cloneRange()};function Jt(){const e=x.current;if(!e)return;const n=window.getSelection();if(!n||n.rangeCount>0&&e.contains(n.anchorNode))return;const r=document.createRange();r.selectNodeContents(e),r.collapse(!1),n.removeAllRanges(),n.addRange(r),O.current=r.cloneRange()}const en=e=>{const n=e.target;if(!n||!(n.textContent||"").match(/{{([\s\S]+?)}}/)||!x.current)return;let i=n.firstChild;if((!i||i.nodeType!==Node.TEXT_NODE)&&(i=n.childNodes[0]),!i||i.nodeType!==Node.TEXT_NODE)return;const o=i.textContent||"",w=o.indexOf("{{"),f=o.indexOf("}}");if(w===-1||f===-1)return;const d=window.getSelection();if(!d)return;const s=document.createRange();s.setStart(i,w),s.setEnd(i,f+2),d.removeAllRanges(),d.addRange(s)},tn=e=>{xe(n=>{const r={};return e.forEach(l=>{var c;r[l.name]=(c=n[l.name])!=null?c:""}),r})},nn=()=>{let e=k;return Object.entries(Le).forEach(([n,r])=>{if(r.trim()){const l=new RegExp(`{{\\s*${n}\\s*}}`,"g");e=e.replace(l,r)}}),e};function rn(e){const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0),l=document.createRange();return l.selectNode(e),r.compareBoundaryPoints(Range.START_TO_START,l)<=0&&r.compareBoundaryPoints(Range.END_TO_END,l)>=0}function ln(){const e=x.current;if(!e)return;e.querySelectorAll("table").forEach(r=>{rn(r)?r.classList.add("rte-table-selected"):r.classList.remove("rte-table-selected")})}return t.createElement("div",{className:`rte-wrapper ${(v==null?void 0:v.wrapper)||""}`,style:S.wrapper},t.createElement("div",{style:{flex:1}},t.createElement(ye,{exec:me,saveSelection:R,handleFileChange:Ft,handleFontSizeChange:e=>Qt(e.target.value),handleFontFamilyChange:e=>me("fontName",e.target.value),insertEmoji:It,handleLink:Ut,removeFormatting:Zt,visibleActions:ie,className:v.toolbar,style:S.toolbar}),t.createElement("div",{ref:x,id:"rte-editor-body",className:`rte-editor ${(v==null?void 0:v.editor)||""}`,style:S.editor,contentEditable:!0,suppressContentEditableWarning:!0,onPaste:Rt,onKeyUp:()=>{R(),Oe()},onMouseUp:R,onInput:()=>{Ae(),R()},onKeyDown:_t,onBeforeInput:jt,onContextMenu:Bt,onClick:e=>{Wt(e),R(),Oe()},onDoubleClick:en}),t.createElement(St,{show:I,position:q,filtered:Z,insertMention:Dt,onClose:()=>P(!1),query:de}),u&&t.createElement("div",{className:`rte-output ${(v==null?void 0:v.output)||""}`,style:S.output},t.createElement("h4",null,"Output HTML:"),t.createElement("p",null,k)),t.createElement(Lt,{visible:j.visible,x:j.x,y:j.y,onAction:Vt,onClose:()=>{V(re(ne({},j),{visible:!1})),ze(),De()}}),t.createElement(xt,{visible:Y,linkData:X,onClose:()=>g(!1),onInsert:$t})),h?t.createElement(Ce,{className:v.preview,style:S.preview,html:nn(),attributes:Le,setAttributes:xe}):null)};D.RichTextEditor=Nt,D.RtePreview=Ce,D.RteToolbar=ye,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}));
|