import{r as e}from"./rolldown-runtime.WmLfqUcM.js";var t=e({plugin_exports:()=>n});(function(){var e=hugerte.util.Tools.resolve(`hugerte.PluginManager`);let t=(e=>t=>e===t)(null),n=e=>e,r=(e,t)=>{let n=e.length,r=Array(n);for(let i=0;i<n;i++){let n=e[i];r[i]=t(n,i)}return r},i={aletter:`[A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-׳ؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆༀཀ-ཇཉ-ཬྈ-ྌႠ-Ⴥა-ჺჼᄀ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᨀ-ᨖᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᯀ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⒶ-ⓩⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⴀ-ⴥⴰ-ⵥⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〻〼ㄅ-ㄭㄱ-ㆎㆠ-ㆺꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐꞑꞠ-ꞩꟺ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻﬀ-ﬆﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼＡ-Ｚａ-ｚﾠ-ﾾￂ-ￇￊ-ￏￒ-ￗￚ-ￜ]`,midnumlet:`[-'\\.‘’․﹒＇．]`,midletter:`[:··״‧︓﹕：]`,midnum:`[±+*/,;;։،؍٬߸⁄︐︔﹐﹔，；]`,numeric:`[0-9٠-٩٫۰-۹߀-߉०-९০-৯੦-੯૦-૯୦-୯௦-௯౦-౯೦-೯൦-൯๐-๙໐-໙༠-༩၀-၉႐-႙០-៩᠐-᠙᥆-᥏᧐-᧙᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙꘠-꘩꣐-꣙꤀-꤉꧐-꧙꩐-꩙꯰-꯹]`,cr:`\\r`,lf:`\\n`,newline:`[\v\f\u2028\u2029]`,extend:`[̀-ͯ҃-҉֑-ׇֽֿׁׂׅׄؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ܑۭܰ-݊ަ-ް߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ऀ-ःऺ-़ा-ॏ॑-ॗॢॣঁ-ঃ়া-ৄেৈো-্ৗৢৣਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑੰੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣஂா-ூெ-ைொ-்ௗఁ-ఃా-ౄె-ైొ-్ౕౖౢౣಂಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣംഃാ-ൄെ-ൈൊ-്ൗൢൣංඃ්ා-ුූෘ-ෟෲෳัิ-ฺ็-๎ັິ-ູົຼ່-ໍ༹༘༙༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏႚ-ႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳា-៓៝᠋-᠍ᢩᤠ-ᤫᤰ-᤻ᦰ-ᧀᧈᧉᨗ-ᨛᩕ-ᩞ᩠-᩿᩼ᬀ-ᬄ᬴-᭄᭫-᭳ᮀ-ᮂᮡ-᯦᮪-᯳ᰤ-᰷᳐-᳔᳒-᳨᳭ᳲ᷀-ᷦ᷼-᷿‌‍⃐-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꙯-꙲꙼꙽꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-꣄꣠-꣱ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀ꨩ-ꨶꩃꩌꩍꩻꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꯣ-ꯪ꯬꯭ﬞ︀-️︠-︦ﾞﾟ]`,format:`[­؀-؃۝܏឴឵‎‏‪-‮⁠-⁤⁪-⁯﻿￹-￻]`,katakana:`[〱-〵゛゜゠-ヺー-ヿㇰ-ㇿ㋐-㋾㌀-㍗ｦ-ﾝ]`,extendnumlet:`[=_‿⁀⁔︳︴﹍-﹏＿∀-⋿<>]`,punctuation:"[~№|!-*+-\\/:;?@\\[-`{}¡«·»¿;·՚-՟։֊־׀׃׆׳״؉؊،؍؛؞؟٪-٭۔܀-܍߷-߹࠰-࠾࡞।॥॰෴๏๚๛༄-༒༺-༽྅࿐-࿔࿙࿚၊-၏჻፡-፨᐀᙭᙮᚛᚜᛫-᛭᜵᜶។-៖៘-៚᠀-᠊᥄᥅᨞᨟᪠-᪦᪨-᪭᭚-᭠᯼-᯿᰻-᰿᱾᱿᳓‐-‧‰-⁃⁅-⁑⁓-⁞⁽⁾₍₎〈〉❨-❵⟅⟆⟦-⟯⦃-⦘⧘-⧛⧼⧽⳹-⳼⳾⳿⵰⸀-⸮⸰⸱、-〃〈-】〔-〟〰〽゠・꓾꓿꘍-꘏꙳꙾꛲-꛷꡴-꡷꣎꣏꣸-꣺꤮꤯꥟꧁-꧍꧞꧟꩜-꩟꫞꫟꯫﴾﴿︐-︙︰-﹒﹔-﹡﹣﹨﹪﹫！-＃％-＊，-／：；？＠［-］＿｛｝｟-･]"},a={ALETTER:0,MIDNUMLET:1,MIDLETTER:2,MIDNUM:3,NUMERIC:4,CR:5,LF:6,NEWLINE:7,EXTEND:8,FORMAT:9,KATAKANA:10,EXTENDNUMLET:11,AT:12,OTHER:13},o=[new RegExp(i.aletter),new RegExp(i.midnumlet),new RegExp(i.midletter),new RegExp(i.midnum),new RegExp(i.numeric),new RegExp(i.cr),new RegExp(i.lf),new RegExp(i.newline),new RegExp(i.extend),new RegExp(i.format),new RegExp(i.katakana),new RegExp(i.extendnumlet),RegExp(`@`)],s=RegExp(`^`+i.punctuation+`$`),c=/^\s+$/,l=o,u=a.OTHER,d=e=>{let t=u,n=l.length;for(let r=0;r<n;++r){let n=l[r];if(n&&n.test(e)){t=r;break}}return t},f=e=>{let t={};return n=>{if(t[n])return t[n];{let r=e(n);return t[n]=r,r}}},p=e=>r(e,f(d)),m=(e,t)=>{let n=e[t],r=e[t+1];if(t<0||t>e.length-1&&t!==0||n===a.ALETTER&&r===a.ALETTER)return!1;let i=e[t+2];if(n===a.ALETTER&&(r===a.MIDLETTER||r===a.MIDNUMLET||r===a.AT)&&i===a.ALETTER)return!1;let o=e[t-1];return(n===a.MIDLETTER||n===a.MIDNUMLET||r===a.AT)&&r===a.ALETTER&&o===a.ALETTER||(n===a.NUMERIC||n===a.ALETTER)&&(r===a.NUMERIC||r===a.ALETTER)||(n===a.MIDNUM||n===a.MIDNUMLET)&&r===a.NUMERIC&&o===a.NUMERIC||n===a.NUMERIC&&(r===a.MIDNUM||r===a.MIDNUMLET)&&i===a.NUMERIC||(n===a.EXTEND||n===a.FORMAT)&&(r===a.ALETTER||r===a.NUMERIC||r===a.KATAKANA||r===a.EXTEND||r===a.FORMAT)||(r===a.EXTEND||r===a.FORMAT&&(i===a.ALETTER||i===a.NUMERIC||i===a.KATAKANA||i===a.EXTEND||i===a.FORMAT))&&(n===a.ALETTER||n===a.NUMERIC||n===a.KATAKANA||n===a.EXTEND||n===a.FORMAT)||n===a.CR&&r===a.LF?!1:n===a.NEWLINE||n===a.CR||n===a.LF||r===a.NEWLINE||r===a.CR||r===a.LF?!0:!(n===a.KATAKANA&&r===a.KATAKANA||r===a.EXTENDNUMLET&&(n===a.ALETTER||n===a.NUMERIC||n===a.KATAKANA||n===a.EXTENDNUMLET)||n===a.EXTENDNUMLET&&(r===a.ALETTER||r===a.NUMERIC||r===a.KATAKANA)||n===a.AT)},h=c,g=s,_=e=>e===`http`||e===`https`,v=(e,t)=>{let n;for(n=t;n<e.length&&!h.test(e[n]);n++);return n},y=(e,t)=>{let n=v(e,t+1);return e.slice(t+1,n).join(``).substr(0,3)===`://`?n:t},b=(e,t,n,r)=>{let i=[],a=[],o=[];for(let s=0;s<n.length;++s)if(o.push(e[s]),m(n,s)){let n=t[s];if((r.includeWhitespace||!h.test(n))&&(r.includePunctuation||!g.test(n))){let n=s-o.length+1,r=s+1;if(_(t.slice(n,r).join(``))){let n=y(t,s),i=e.slice(r,n);Array.prototype.push.apply(o,i),s=n}i.push(o),a.push({start:n,end:r})}o=[]}return{words:i,indices:a}},x=()=>({includeWhitespace:!1,includePunctuation:!1}),S=(e,t,n)=>{n={...x(),...n};let i=r(e,t);return b(e,i,p(i),n)},C=(e,t,n)=>S(e,t,n).words,w=e=>e.replace(/\uFEFF/g,``);var T=hugerte.util.Tools.resolve(`hugerte.dom.TreeWalker`);let E=(e,t)=>{let n=t.getBlockElements(),r=t.getVoidElements(),i=e=>n[e.nodeName]||r[e.nodeName],a=[],o=``,s=new T(e,e),c;for(;c=s.next();)c.nodeType===3?o+=w(c.data):i(c)&&o.length&&(a.push(o),o=``);return o.length&&a.push(o),a},D=e=>e.replace(/\u200B/g,``),O=e=>e.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,`_`).length,k=(e,t)=>C(D(E(e,t).join(`
`)).split(``),n).length,A=(e,t)=>O(E(e,t).join(``)),j=(e,t)=>O(E(e,t).join(``).replace(/\s/g,``)),M=(e,t)=>()=>t(e.getBody(),e.schema),N=(e,t)=>()=>t(e.selection.getRng().cloneContents(),e.schema),P=e=>M(e,k),F=e=>({body:{getWordCount:P(e),getCharacterCount:M(e,A),getCharacterCountWithoutSpaces:M(e,j)},selection:{getWordCount:N(e,k),getCharacterCount:N(e,A),getCharacterCountWithoutSpaces:N(e,j)},getCount:P(e)}),I=(e,t)=>{e.windowManager.open({title:`Word Count`,body:{type:`panel`,items:[{type:`table`,header:[`Count`,`Document`,`Selection`],cells:[[`Words`,String(t.body.getWordCount()),String(t.selection.getWordCount())],[`Characters (no spaces)`,String(t.body.getCharacterCountWithoutSpaces()),String(t.selection.getCharacterCountWithoutSpaces())],[`Characters`,String(t.body.getCharacterCount()),String(t.selection.getCharacterCount())]]}]},buttons:[{type:`cancel`,name:`close`,text:`Close`,primary:!0}]})},L=(e,t)=>{e.addCommand(`mceWordCount`,()=>I(e,t))},R=(e,n)=>{let r=null;return{cancel:()=>{t(r)||(clearTimeout(r),r=null)},throttle:(...i)=>{t(r)&&(r=setTimeout(()=>{r=null,e.apply(null,i)},n))}}};var z=hugerte.util.Tools.resolve(`hugerte.util.Delay`);let B=(e,t)=>{e.dispatch(`wordCountUpdate`,{wordCount:{words:t.body.getWordCount(),characters:t.body.getCharacterCount(),charactersWithoutSpaces:t.body.getCharacterCountWithoutSpaces()}})},V=(e,t)=>{B(e,t)},H=(e,t,n)=>{let r=R(()=>V(e,t),n);e.on(`init`,()=>{V(e,t),z.setEditorTimeout(e,()=>{e.on(`SetContent BeforeAddUndo Undo Redo ViewUpdate keyup`,r.throttle)},0),e.on(`remove`,r.cancel)})},U=e=>{let t=()=>e.execCommand(`mceWordCount`);e.ui.registry.addButton(`wordcount`,{tooltip:`Word count`,icon:`character-count`,onAction:t}),e.ui.registry.addMenuItem(`wordcount`,{text:`Word count`,icon:`character-count`,onAction:t})};((t=300)=>{e.add(`wordcount`,e=>{let n=F(e);return L(e,n),U(e),H(e,n,t),n})})()})();var n={};export{t};