compromise
Version:
modest natural language processing
2 lines • 89.8 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).nlp=e()}(this,function(){"use strict";var t={methods:{one:{},two:{},three:{},four:{}},model:{one:{},two:{},three:{}},compute:{},hooks:[]};const e={compute:function(t){const{world:e}=this,n=e.compute;return"string"==typeof t&&n.hasOwnProperty(t)?n[t](this):(t=>"[object Array]"===Object.prototype.toString.call(t))(t)?t.forEach(o=>{e.compute.hasOwnProperty(o)?n[o](this):console.warn("no compute:",t)}):"function"==typeof t?t(this):console.warn("no compute:",t),this}};var n={forEach:function(t){return this.fullPointer.forEach((e,n)=>{const o=this.update([e]);t(o,n)}),this},map:function(t,e){const n=this.fullPointer.map((e,n)=>{const o=this.update([e]),r=t(o,n);return void 0===r?this.none():r});if(0===n.length)return e||this.update([]);if(void 0!==n[0]){if("string"==typeof n[0])return n;if("object"==typeof n[0]&&(null===n[0]||!n[0].isView))return n}let o=[];return n.forEach(t=>{o=o.concat(t.fullPointer)}),this.toView(o)},filter:function(t){let e=this.fullPointer;e=e.filter((e,n)=>{const o=this.update([e]);return t(o,n)});return this.update(e)},find:function(t){const e=this.fullPointer.find((e,n)=>{const o=this.update([e]);return t(o,n)});return this.update([e])},some:function(t){return this.fullPointer.some((e,n)=>{const o=this.update([e]);return t(o,n)})},random:function(t=1){let e=this.fullPointer,n=Math.floor(Math.random()*e.length);return n+t>this.length&&(n=this.length-t,n=n<0?0:n),e=e.slice(n,n+t),this.update(e)}};const o={termList:function(){return this.methods.one.termList(this.docs)},terms:function(t){const e=this.match(".");return"number"==typeof t?e.eq(t):e},groups:function(t){if(t||0===t)return this.update(this._groups[t]||[]);const e={};return Object.keys(this._groups).forEach(t=>{e[t]=this.update(this._groups[t])}),e},eq:function(t){let e=this.pointer;return e||(e=this.docs.map((t,e)=>[e])),e[t]?this.update([e[t]]):this.none()},first:function(){return this.eq(0)},last:function(){const t=this.fullPointer.length-1;return this.eq(t)},firstTerms:function(){return this.match("^.")},lastTerms:function(){return this.match(".$")},slice:function(t,e){let n=this.pointer||this.docs.map((t,e)=>[e]);return n=n.slice(t,e),this.update(n)},all:function(){return this.update().toView()},fullSentences:function(){const t=this.fullPointer.map(t=>[t[0]]);return this.update(t).toView()},none:function(){return this.update([])},isDoc:function(t){if(!t||!t.isView)return!1;const e=this.fullPointer,n=t.fullPointer;return!e.length!==n.length&&e.every((t,e)=>!!n[e]&&(t[0]===n[e][0]&&t[1]===n[e][1]&&t[2]===n[e][2]))},wordCount:function(){return this.docs.reduce((t,e)=>(t+=e.filter(t=>""!==t.text).length,t),0)},isFull:function(){const t=this.pointer;if(!t)return!0;if(0===t.length||0!==t[0][0])return!1;let e=0,n=0;return this.document.forEach(t=>e+=t.length),this.docs.forEach(t=>n+=t.length),e===n},getNth:function(t){return"number"==typeof t?this.eq(t):"string"==typeof t?this.if(t):this}};o.group=o.groups,o.fullSentence=o.fullSentences,o.sentence=o.fullSentences,o.lastTerm=o.lastTerms,o.firstTerm=o.firstTerms;const r=Object.assign({},o,e,n);r.get=r.eq;class View{constructor(e,n,o={}){[["document",e],["world",t],["_groups",o],["_cache",null],["viewType","View"]].forEach(t=>{Object.defineProperty(this,t[0],{value:t[1],writable:!0})}),this.ptrs=n}get docs(){let e=this.document;return this.ptrs&&(e=t.methods.one.getDoc(this.ptrs,this.document)),e}get pointer(){return this.ptrs}get methods(){return this.world.methods}get model(){return this.world.model}get hooks(){return this.world.hooks}get isView(){return!0}get found(){return this.docs.length>0}get length(){return this.docs.length}get fullPointer(){const{docs:t,ptrs:e,document:n}=this,o=e||t.map((t,e)=>[e]);return o.map(t=>{let[e,o,r,s,i]=t;return o=o||0,r=r||(n[e]||[]).length,n[e]&&n[e][o]&&(s=s||n[e][o].id,n[e][r-1]&&(i=i||n[e][r-1].id)),[e,o,r,s,i]})}update(t){const e=new View(this.document,t);if(this._cache&&t&&t.length>0){const n=[];t.forEach((t,e)=>{const[o,r,s]=t;(1===t.length||0===r&&this.document[o].length===s)&&(n[e]=this._cache[o])}),n.length>0&&(e._cache=n)}return e.world=this.world,e}toView(t){return new View(this.document,t||this.pointer)}fromText(t){const{methods:e}=this,n=e.one.tokenize.fromString(t,this.world),o=new View(n);return o.world=this.world,o.compute(["normal","freeze","lexicon"]),this.world.compute.preTagger&&o.compute("preTagger"),o.compute("unfreeze"),o}clone(){let t=this.document.slice(0);t=t.map(t=>t.map(t=>((t=Object.assign({},t)).tags=new Set(t.tags),t)));const e=this.update(this.pointer);return e.document=t,e._cache=this._cache,e}}Object.assign(View.prototype,r);const s=function(t){return t&&"object"==typeof t&&!Array.isArray(t)},i=t=>"__proto__"===t||"constructor"===t||"prototype"===t;function c(t,e){if(s(e))for(const n in e)i(n)||(s(e[n])?(t[n]||Object.assign(t,{[n]:{}}),c(t[n],e[n])):Object.assign(t,{[n]:e[n]}));return t}const u=function(t,e,n,o){if(r=t,"[object Array]"===Object.prototype.toString.call(r))return void t.forEach(t=>u(t,e,n,o));var r;const{methods:s,model:a,compute:l,hooks:h}=e;t.methods&&function(t,e){for(const n in e)i(n)||(t[n]=t[n]||{},Object.assign(t[n],e[n]))}(s,t.methods),t.model&&c(a,t.model),t.irregulars&&function(t,e){const n=t.two.models||{};Object.keys(e).forEach(t=>{e[t].pastTense&&(n.toPast&&(n.toPast.ex[t]=e[t].pastTense),n.fromPast&&(n.fromPast.ex[e[t].pastTense]=t)),e[t].presentTense&&(n.toPresent&&(n.toPresent.ex[t]=e[t].presentTense),n.fromPresent&&(n.fromPresent.ex[e[t].presentTense]=t)),e[t].gerund&&(n.toGerund&&(n.toGerund.ex[t]=e[t].gerund),n.fromGerund&&(n.fromGerund.ex[e[t].gerund]=t)),e[t].comparative&&(n.toComparative&&(n.toComparative.ex[t]=e[t].comparative),n.fromComparative&&(n.fromComparative.ex[e[t].comparative]=t)),e[t].superlative&&(n.toSuperlative&&(n.toSuperlative.ex[t]=e[t].superlative),n.fromSuperlative&&(n.fromSuperlative.ex[e[t].superlative]=t))})}(a,t.irregulars),t.compute&&Object.assign(l,t.compute),h&&(e.hooks=h.concat(t.hooks||[])),t.api&&t.api(n),t.lib&&Object.keys(t.lib).forEach(e=>o[e]=t.lib[e]),t.tags&&o.addTags(t.tags),t.words&&o.addWords(t.words),t.frozen&&o.addWords(t.frozen,!0),t.mutate&&t.mutate(e,o)},a=function(t){return"[object Array]"===Object.prototype.toString.call(t)},l=function(t,e,n){const{methods:o}=n,r=new e([]);if(r.world=n,"number"==typeof t&&(t=String(t)),!t)return r;if("string"==typeof t){return new e(o.one.tokenize.fromString(t,n))}if(s=t,"[object Object]"===Object.prototype.toString.call(s)&&t.isView)return new e(t.document,t.ptrs);var s;if(a(t)){if(a(t[0])){const n=t.map(t=>t.map(t=>({text:t,normal:t,pre:"",post:" ",tags:new Set})));return new e(n)}const n=t.map(t=>t.terms.map(t=>(a(t.tags)&&(t.tags=new Set(t.tags)),t)));return new e(n)}return r},h=Object.assign({},t),f=function(t,e){e&&f.addWords(e);const n=l(t,View,h);return t&&n.compute(h.hooks),n};Object.defineProperty(f,"_world",{value:h,writable:!0}),f.tokenize=function(t,e){const{compute:n}=this._world;e&&f.addWords(e);const o=l(t,View,h);return n.contractions&&o.compute(["alias","normal","machine","contractions"]),o},f.plugin=function(t){return u(t,this._world,View,this),this},f.extend=f.plugin,f.world=function(){return this._world},f.model=function(){return this._world.model},f.methods=function(){return this._world.methods},f.hooks=function(){return this._world.hooks},f.verbose=function(t){const e="undefined"!=typeof process&&process.env?process.env:self.env||{};return e.DEBUG_TAGS="tagger"===t||!0===t||"",e.DEBUG_MATCH="match"===t||!0===t||"",e.DEBUG_CHUNKS="chunker"===t||!0===t||"",this},f.version="14.17.0";var p={one:{cacheDoc:function(t){const e=t.map(t=>{const e=new Set;return t.forEach(t=>{""!==t.normal&&e.add(t.normal),t.switch&&e.add(`%${t.switch}%`),t.implicit&&e.add(t.implicit),t.machine&&e.add(t.machine),t.root&&e.add(t.root),t.alias&&t.alias.forEach(t=>e.add(t));const n=Array.from(t.tags);for(let t=0;t<n.length;t+=1)e.add("#"+n[t])}),e});return e}}};const d={cache:function(){return this._cache=this.methods.one.cacheDoc(this.document),this},uncache:function(){return this._cache=null,this}};var m={api:function(t){Object.assign(t.prototype,d)},compute:{cache:function(t){t._cache=t.methods.one.cacheDoc(t.document)}},methods:p};const w=t=>/^\p{Lu}[\p{Ll}'’]/u.test(t)||/^\p{Lu}$/u.test(t),y=(t,e,n)=>{if(n.forEach(t=>t.dirty=!0),t){const o=[e,0].concat(n);Array.prototype.splice.apply(t,o)}return t},b=function(t){const e=t[t.length-1];!e||/ $/.test(e.post)||/[-–—]/.test(e.post)||(e.post+=" ")},v=(t,e,n)=>{const o=/[-.?!,;:)–—'"]/g,r=t[e-1];if(!r)return;const s=r.post;if(o.test(s)){const t=s.match(o).join(""),e=n[n.length-1];e.post=t+e.post,r.post=r.post.replace(o,"")}},x=function(t,e,n,o){const[r,s,i]=e;0===s||i===o[r].length?b(n):(b(n),b([t[e[1]]])),function(t,e,n){const o=t[e];if(0!==e||!w(o.text))return;n[0].text=n[0].text.replace(/^\p{Ll}/u,t=>t.toUpperCase());const r=t[e];r.tags.has("ProperNoun")||r.tags.has("Acronym")||w(r.text)&&r.text.length>1&&(r.text=(s=r.text,s.replace(/^\p{Lu}/u,t=>t.toLowerCase())));var s}(t,s,n),y(t,s,n)};let j=0;const E=t=>(t=t.length<3?"0"+t:t).length<3?"0"+t:t,O=function(t){let[e,n]=t.index||[0,0];j+=1,j=j>46655?0:j,e=e>46655?0:e,n=n>1294?0:n;let o=E(j.toString(36));o+=E(e.toString(36));let r=n.toString(36);r=r.length<2?"0"+r:r,o+=r;return o+=parseInt(36*Math.random(),10).toString(36),t.normal+"|"+o.toUpperCase()},k=function(t){if(t.has("@hasContraction")&&"function"==typeof t.contractions){t.grow("@hasContraction").contractions().expand()}},P=t=>"[object Array]"===Object.prototype.toString.call(t),_=function(t,e,n){const{document:o,world:r}=e;e.uncache();const s=e.fullPointer,i=e.fullPointer;e.forEach((c,u)=>{const a=c.fullPointer[0],[l]=a,h=o[l];let f=function(t,e){const{methods:n}=e;return"string"==typeof t?n.one.tokenize.fromString(t,e)[0]:"object"==typeof t&&t.isView?t.clone().docs[0]||[]:P(t)?P(t[0])?t[0]:t:[]}(t,r);0!==f.length&&(f=function(t){return t.map(t=>(t.id=O(t),t))}(f),n?(k(e.update([a]).firstTerm()),x(h,a,f,o)):(k(e.update([a]).lastTerm()),function(t,e,n,o){const[r,,s]=e,i=(o[r]||[]).length;s<i?(v(t,s,n),b(n)):i===s&&(b(t),v(t,s,n),o[r+1]&&(n[n.length-1].post+=" ")),y(t,e[2],n),e[4]=n[n.length-1].id}(h,a,f,o)),o[l]&&o[l][a[1]]&&(a[3]=o[l][a[1]].id),i[u]=a,a[2]+=f.length,s[u]=a)});const c=e.toView(s);return e.ptrs=i,c.compute(["id","index","freeze","lexicon"]),c.world.compute.preTagger&&c.compute("preTagger"),c.compute("unfreeze"),c},S={insertAfter:function(t){return _(t,this,!1)},insertBefore:function(t){return _(t,this,!0)}};S.append=S.insertAfter,S.prepend=S.insertBefore,S.insert=S.insertAfter;const $=/\$[0-9a-z]+/g,z={},A=t=>t.replace(/^\p{Ll}/u,t=>t.toUpperCase()),C=t=>t.replace(/^\p{Lu}/u,t=>t.toLowerCase());z.replaceWith=function(t,e={}){let n=this.fullPointer;!0===e&&(e={tags:!0,case:!0,possessives:!0});const o=this;if(this.uncache(),"function"==typeof t)return function(t,e,n){return t.forEach(t=>{const o=e(t);t.replaceWith(o,n)}),t}(o,t,e);const r=o.docs[0];if(!r)return o;const s=e.possessives&&r[r.length-1].tags.has("Possessive"),i=e.case&&(c=r[0].text,/^\p{Lu}[\p{Ll}'’]/u.test(c)||/^\p{Lu}$/u.test(c));var c;t=function(t,e){if("string"!=typeof t)return t;const n=e.groups();return t=t.replace($,t=>{const e=t.replace(/\$/,"");return n.hasOwnProperty(e)?n[e].text():t}),t}(t,o);const u=this.update(n);n=n.map(t=>t.slice(0,3));let a=(u.docs[0]||[]).map(t=>Array.from(t.tags));const l=u.docs[0][0].pre,h=u.docs[0][u.docs[0].length-1].post;if("string"==typeof t&&(t=this.fromText(t).compute("id")),o.insertAfter(t),u.has("@hasContraction")&&o.contractions){o.grow("@hasContraction+").contractions().expand()}if(o.delete(u),s){const t=o.docs[0],e=t[t.length-1];e.tags.has("Possessive")||(e.text+="'s",e.normal+="'s",e.tags.add("Possessive"))}if(l&&o.docs[0]&&(o.docs[0][0].pre=l),h&&o.docs[0]){const t=o.docs[0][o.docs[0].length-1];t.post.trim()||(t.post=h)}const f=o.toView(n).compute(["index","freeze","lexicon"]);if(f.world.compute.preTagger&&f.compute("preTagger"),f.compute("unfreeze"),e.tags&&(a=a.slice(0,t.wordCount()),f.terms().forEach((t,e)=>{t.tagSafe(a[e])})),!f.docs[0]||!f.docs[0][0])return f;if(e.case){const t=i?A:C;f.docs[0][0].text=t(f.docs[0][0].text)}return f},z.replace=function(t,e,n){if(t&&!e)return this.replaceWith(t,n);const o=this.match(t);return o.found?(this.soften(),o.replaceWith(e,n)):this};const T={remove:function(t){const{indexN:e}=this.methods.one.pointer;this.uncache();let n=this.all(),o=this;t&&(n=this,o=this.match(t));const r=!n.ptrs;if(o.has("@hasContraction")&&o.contractions){o.grow("@hasContraction").contractions().expand()}let s=n.fullPointer;const i=o.fullPointer.reverse(),c=function(t,e){e.forEach(e=>{const[n,o,r]=e,s=r-o;t[n]&&(r===t[n].length&&r>1&&function(t,e){const n=t.length-1,o=t[n],r=t[n-e];r&&o&&(r.post+=o.post,r.post=r.post.replace(/ +([.?!,;:])/,"$1"),r.post=r.post.replace(/[,;:]+([.?!])/,"$1"))}(t[n],s),t[n].splice(o,s))});for(let e=t.length-1;e>=0;e-=1)if(0===t[e].length&&(t.splice(e,1),e===t.length&&t[e-1])){const n=t[e-1],o=n[n.length-1];o&&(o.post=o.post.trimEnd())}return t}(this.document,i);if(s=function(t,e){return t=t.map(t=>{const[n]=t;return e[n]?(e[n].forEach(e=>{const n=e[2]-e[1];t[1]<=e[1]&&t[2]>=e[2]&&(t[2]-=n)}),t):t}),t.forEach((e,n)=>{if(0===e[1]&&0==e[2])for(let e=n+1;e<t.length;e+=1)t[e][0]-=1,t[e][0]<0&&(t[e][0]=0)}),t=(t=t.filter(t=>t[2]-t[1]>0)).map(t=>(t[3]=null,t[4]=null,t))}(s,e(i)),n.ptrs=s,n.document=c,n.compute("index"),r&&(n.ptrs=void 0),!t)return this.ptrs=[],n.none();return n.toView(s)}};T.delete=T.remove;const F={pre:function(t,e){return void 0===t&&this.found?this.docs[0][0].pre:(this.docs.forEach(n=>{const o=n[0];!0===e?o.pre+=t:o.pre=t}),this)},post:function(t,e){if(void 0===t){const t=this.docs[this.docs.length-1];return t[t.length-1].post}return this.docs.forEach(n=>{const o=n[n.length-1];!0===e?o.post+=t:o.post=t}),this},trim:function(){if(!this.found)return this;const t=this.docs,e=t[0][0];e.pre=e.pre.trimStart();const n=t[t.length-1],o=n[n.length-1];return o.post=o.post.trimEnd(),this},hyphenate:function(){return this.docs.forEach(t=>{t.forEach((e,n)=>{0!==n&&(e.pre=""),t[n+1]&&(e.post="-")})}),this},dehyphenate:function(){const t=/[-–—]/;return this.docs.forEach(e=>{e.forEach(e=>{t.test(e.post)&&(e.post=" ")})}),this},toQuotations:function(t,e){return t=t||'"',e=e||'"',this.docs.forEach(n=>{n[0].pre=t+n[0].pre;const o=n[n.length-1];o.post=e+o.post}),this},toParentheses:function(t,e){return t=t||"(",e=e||")",this.docs.forEach(n=>{n[0].pre=t+n[0].pre;const o=n[n.length-1];o.post=e+o.post}),this}};F.deHyphenate=F.dehyphenate,F.toQuotation=F.toQuotations;var L={alpha:(t,e)=>t.normal<e.normal?-1:t.normal>e.normal?1:0,length:(t,e)=>{const n=t.normal.trim().length,o=e.normal.trim().length;return n<o?1:n>o?-1:0},wordCount:(t,e)=>t.words<e.words?1:t.words>e.words?-1:0,sequential:(t,e)=>t[0]<e[0]?1:t[0]>e[0]?-1:t[1]>e[1]?1:-1,byFreq:function(t){const e={};return t.forEach(t=>{e[t.normal]=e[t.normal]||0,e[t.normal]+=1}),t.sort((t,n)=>{const o=e[t.normal],r=e[n.normal];return o<r?1:o>r?-1:0}),t}};const N=new Set(["index","sequence","seq","sequential","chron","chronological"]),V=new Set(["freq","frequency","topk","repeats"]),q=new Set(["alpha","alphabetical"]);var D={unique:function(){const t=new Set;return this.filter(e=>{const n=e.text("machine");return!t.has(n)&&(t.add(n),!0)})},reverse:function(){let t=this.pointer||this.docs.map((t,e)=>[e]);return t=[].concat(t),t=t.reverse(),this._cache&&(this._cache=this._cache.reverse()),this.update(t)},sort:function(t){const{docs:e,pointer:n}=this;if(this.uncache(),"function"==typeof t)return function(t,e){let n=t.fullPointer;return n=n.sort((n,o)=>(n=t.update([n]),o=t.update([o]),e(n,o))),t.ptrs=n,t}(this,t);t=t||"alpha";const o=n||e.map((t,e)=>[e]);let r=e.map((t,e)=>({index:e,words:t.length,normal:t.map(t=>t.machine||t.normal||"").join(" "),pointer:o[e]}));return N.has(t)&&(t="sequential"),q.has(t)&&(t="alpha"),V.has(t)?(r=L.byFreq(r),this.update(r.map(t=>t.pointer))):"function"==typeof L[t]?(r=r.sort(L[t]),this.update(r.map(t=>t.pointer))):this}};const G=function(t,e){if(t.length>0){const e=t[t.length-1],n=e[e.length-1];!1===/ /.test(n.post)&&(n.post+=" ")}return t=t.concat(e)};var B={concat:function(t){if("string"==typeof t){const e=this.fromText(t);if(this.found&&this.ptrs){const t=this.fullPointer,n=t[t.length-1][0];this.document.splice(n,0,...e.document)}else this.document=this.document.concat(e.document);return this.all().compute("index")}if("object"==typeof t&&t.isView)return function(t,e){if(t.document===e.document){const n=t.fullPointer.concat(e.fullPointer);return t.toView(n).compute("index")}return e.fullPointer.forEach(e=>{e[0]+=t.document.length}),t.document=G(t.document,e.docs),t.all()}(this,t);if(e=t,"[object Array]"===Object.prototype.toString.call(e)){const e=G(this.document,t);return this.document=e,this.all()}var e;return this}};var M={harden:function(){return this.ptrs=this.fullPointer,this},soften:function(){let t=this.ptrs;return!t||t.length<1||(t=t.map(t=>t.slice(0,3)),this.ptrs=t),this}};const U=Object.assign({},{toLowerCase:function(){return this.termList().forEach(t=>{t.text=t.text.toLowerCase()}),this},toUpperCase:function(){return this.termList().forEach(t=>{t.text=t.text.toUpperCase()}),this},toTitleCase:function(){return this.termList().forEach(t=>{t.text=t.text.replace(/^ *[a-z\u00C0-\u00FF]/,t=>t.toUpperCase())}),this},toCamelCase:function(){return this.docs.forEach(t=>{t.forEach((e,n)=>{0!==n&&(e.text=e.text.replace(/^ *[a-z\u00C0-\u00FF]/,t=>t.toUpperCase())),n!==t.length-1&&(e.post="")})}),this}},S,z,T,F,D,B,M),W={id:function(t){const e=t.docs;for(let t=0;t<e.length;t+=1)for(let n=0;n<e[t].length;n+=1){const o=e[t][n];o.id=o.id||O(o)}}};var I={api:function(t){Object.assign(t.prototype,U)},compute:W};const R=!0;var H={one:{contractions:[{word:"@",out:["at"]},{word:"arent",out:["are","not"]},{word:"alot",out:["a","lot"]},{word:"brb",out:["be","right","back"]},{word:"cannot",out:["can","not"]},{word:"dun",out:["do","not"]},{word:"can't",out:["can","not"]},{word:"shan't",out:["should","not"]},{word:"won't",out:["will","not"]},{word:"that's",out:["that","is"]},{word:"what's",out:["what","is"]},{word:"let's",out:["let","us"]},{word:"dunno",out:["do","not","know"]},{word:"gonna",out:["going","to"]},{word:"gotta",out:["have","got","to"]},{word:"gimme",out:["give","me"]},{word:"outta",out:["out","of"]},{word:"tryna",out:["trying","to"]},{word:"gtg",out:["got","to","go"]},{word:"im",out:["i","am"]},{word:"imma",out:["I","will"]},{word:"imo",out:["in","my","opinion"]},{word:"irl",out:["in","real","life"]},{word:"ive",out:["i","have"]},{word:"rn",out:["right","now"]},{word:"tbh",out:["to","be","honest"]},{word:"wanna",out:["want","to"]},{word:"c'mere",out:["come","here"]},{word:"c'mon",out:["come","on"]},{word:"shoulda",out:["should","have"]},{word:"coulda",out:["coulda","have"]},{word:"woulda",out:["woulda","have"]},{word:"musta",out:["must","have"]},{word:"tis",out:["it","is"]},{word:"twas",out:["it","was"]},{word:"y'know",out:["you","know"]},{word:"ne'er",out:["never"]},{word:"o'er",out:["over"]},{after:"ll",out:["will"]},{after:"ve",out:["have"]},{after:"re",out:["are"]},{after:"m",out:["am"]},{before:"c",out:["ce"]},{before:"m",out:["me"]},{before:"n",out:["ne"]},{before:"qu",out:["que"]},{before:"s",out:["se"]},{before:"t",out:["tu"]},{word:"shouldnt",out:["should","not"]},{word:"couldnt",out:["could","not"]},{word:"wouldnt",out:["would","not"]},{word:"hasnt",out:["has","not"]},{word:"wasnt",out:["was","not"]},{word:"isnt",out:["is","not"]},{word:"cant",out:["can","not"]},{word:"dont",out:["do","not"]},{word:"wont",out:["will","not"]},{word:"howd",out:["how","did"]},{word:"whatd",out:["what","did"]},{word:"whend",out:["when","did"]},{word:"whered",out:["where","did"]}],numberSuffixes:{st:R,nd:R,rd:R,th:R,am:R,pm:R,max:R,"°":R,s:R,e:R,er:R,"ère":R,"ème":R}}};const Q=function(t,e,n){const[o,r]=e;n&&0!==n.length&&(n=n.map((t,e)=>(t.implicit=t.text,t.machine=t.text,t.pre="",t.post="",t.text="",t.normal="",t.index=[o,r+e],t)),n[0]&&(n[0].pre=t[o][r].pre,n[n.length-1].post=t[o][r].post,n[0].text=t[o][r].text,n[0].normal=t[o][r].normal),t[o].splice(r,1,...n))},Z=/'/,K=new Set(["what","how","when","where","why"]),J=new Set(["be","go","start","think","need"]),X=new Set(["been","gone"]),Y=/'/,tt=/(e|é|aison|sion|tion)$/,et=/(age|isme|acle|ege|oire)$/;var nt=(t,e)=>["je",t[e].normal.split(Y)[1]],ot=(t,e)=>{const n=t[e].normal.split(Y)[1];return n&&n.endsWith("e")?["la",n]:["le",n]},rt=(t,e)=>{const n=t[e].normal.split(Y)[1];return n&&tt.test(n)&&!et.test(n)?["du",n]:n&&n.endsWith("s")?["des",n]:["de",n]};const st=/^([0-9.]{1,4}[a-z]{0,2}) ?[-–—] ?([0-9]{1,4}[a-z]{0,2})$/i,it=/^([0-9]{1,2}(:[0-9][0-9])?(am|pm)?) ?[-–—] ?([0-9]{1,2}(:[0-9][0-9])?(am|pm)?)$/i,ct=/^[0-9]{3}-[0-9]{4}$/,ut=function(t,e){const n=t[e];let o=n.text.match(st);return null!==o?!0===n.tags.has("PhoneNumber")||ct.test(n.text)?null:[o[1],"to",o[2]]:(o=n.text.match(it),null!==o?[o[1],"to",o[4]]:null)},at=/^([+-]?[0-9][.,0-9]*)([a-z°²³µ/]+)$/,lt=function(t,e,n){const o=n.model.one.numberSuffixes||{},r=t[e].text.match(at);if(null!==r){const t=r[2].toLowerCase().trim();return o.hasOwnProperty(t)?null:[r[1],t]}return null},ht=/'/,ft=/^[0-9][^-–—]*[-–—].*?[0-9]/,pt=function(t,e,n,o){const r=e.update();r.document=[t];let s=n+o;n>0&&(n-=1),t[s]&&(s+=1),r.ptrs=[[0,n,s]]},dt={t:(t,e)=>function(t,e){return"ain't"===t[e].normal||"aint"===t[e].normal?null:[t[e].normal.replace(/n't/,""),"not"]}(t,e),d:(t,e)=>function(t,e){const n=t[e].normal.split(Z)[0];if(K.has(n))return[n,"did"];if(t[e+1]){if(X.has(t[e+1].normal))return[n,"had"];if(J.has(t[e+1].normal))return[n,"would"]}return null}(t,e)},mt={j:(t,e)=>nt(t,e),l:(t,e)=>ot(t,e),d:(t,e)=>rt(t,e)},gt=function(t,e,n,o){for(let r=0;r<t.length;r+=1){const s=t[r];if(s.word===e.normal)return s.out;if(null!==o&&o===s.after)return[n].concat(s.out);if(null!==n&&n===s.before&&o&&o.length>2)return s.out.concat(o)}return null},wt=function(t,e){const n=e.fromText(t.join(" "));return n.compute(["id","alias"]),n.docs[0]},yt=function(t,e){for(let n=e+1;n<5&&t[n];n+=1)if("been"===t[n].normal)return["there","has"];return["there","is"]};var bt={contractions:t=>{const{world:e,document:n}=t,{model:o,methods:r}=e,s=o.one.contractions||[];n.forEach((o,i)=>{for(let c=o.length-1;c>=0;c-=1){let u=null,a=null;if(!0===ht.test(o[c].normal)){const t=o[c].normal.split(ht);u=t[0],a=t[1]}let l=gt(s,o[c],u,a);!l&&dt.hasOwnProperty(a)&&(l=dt[a](o,c,e)),!l&&mt.hasOwnProperty(u)&&(l=mt[u](o,c)),"there"===u&&"s"===a&&(l=yt(o,c)),l?(l=wt(l,t),Q(n,[i,c],l),pt(n[i],t,c,l.length)):ft.test(o[c].normal)?(l=ut(o,c),l&&(l=wt(l,t),Q(n,[i,c],l),r.one.setTag(l,"NumberRange",e),l[2]&&l[2].tags.has("Time")&&r.one.setTag([l[0]],"Time",e,null,"time-range"),pt(n[i],t,c,l.length))):(l=lt(o,c,e),l&&(l=wt(l,t),Q(n,[i,c],l),r.one.setTag([l[1]],"Unit",e,null,"contraction-unit")))}})}};const vt={model:H,compute:bt,hooks:["contractions"]},xt=function(t){const e=t.world,{model:n,methods:o}=t.world,r=o.one.setTag,{frozenLex:s}=n.one,i=n.one._multiCache||{};t.docs.forEach(t=>{for(let n=0;n<t.length;n+=1){const o=t[n],c=o.machine||o.normal;if(void 0!==i[c]&&t[n+1]){for(let o=n+i[c]-1;o>n;o-=1){const i=t.slice(n,o+1),c=i.map(t=>t.machine||t.normal).join(" ");!0!==s.hasOwnProperty(c)||(r(i,s[c],e,!1,"1-frozen-multi-lexicon"),i.forEach(t=>t.frozen=!0))}}void 0!==s[c]&&s.hasOwnProperty(c)&&(r([o],s[c],e,!1,"1-freeze-lexicon"),o.frozen=!0)}})};const jt=t=>"[34m"+t+"[0m",Et=t=>"[3m[2m"+t+"[0m",Ot=function(t){t.docs.forEach(t=>{console.log(jt("\n ┌─────────")),t.forEach(t=>{let e=` ${Et("│")} `;const n=t.implicit||t.text||"-";!0===t.frozen?e+=`${jt(n)} ❄️`:e+=Et(n),console.log(e)})})};var kt={compute:{frozen:xt,freeze:xt,unfreeze:function(t){return t.docs.forEach(t=>{t.forEach(t=>{delete t.frozen})}),t}},mutate:t=>{const e=t.methods.one;e.termMethods.isFrozen=t=>!0===t.frozen,e.debug.freeze=Ot,e.debug.frozen=Ot},api:function(t){t.prototype.freeze=function(){return this.docs.forEach(t=>{t.forEach(t=>{t.frozen=!0})}),this},t.prototype.unfreeze=function(){this.compute("unfreeze")},t.prototype.isFrozen=function(){return this.match("@isFrozen+")}},hooks:["freeze"]};const Pt=function(t,e,n){const{model:o,methods:r}=n,s=r.one.setTag,i=o.one._multiCache||{},{lexicon:c}=o.one||{},u=t[e],a=u.machine||u.normal;if(void 0!==i[a]&&t[e+1]){for(let o=e+i[a]-1;o>e;o-=1){const r=t.slice(e,o+1);if(r.length<=1)return!1;const i=r.map(t=>t.machine||t.normal).join(" ");if(!0===c.hasOwnProperty(i)){const t=c[i];return s(r,t,n,!1,"1-multi-lexicon"),!t||2!==t.length||"PhrasalVerb"!==t[0]&&"PhrasalVerb"!==t[1]||s([r[1]],"Particle",n,!1,"1-phrasal-particle"),!0}}return!1}return null},_t=/^(under|over|mis|re|un|dis|semi|pre|post)-?/,St=new Set(["Verb","Infinitive","PastTense","Gerund","PresentTense","Adjective","Participle"]),$t=function(t,e,n){const{model:o,methods:r}=n,s=r.one.setTag,{lexicon:i}=o.one,c=t[e],u=c.machine||c.normal;if(void 0!==i[u]&&i.hasOwnProperty(u))return s([c],i[u],n,!1,"1-lexicon"),!0;if(c.alias){const t=c.alias.find(t=>i.hasOwnProperty(t));if(t)return s([c],i[t],n,!1,"1-lexicon-alias"),!0}if(!0===_t.test(u)){const t=u.replace(_t,"");if(i.hasOwnProperty(t)&&t.length>3&&St.has(i[t]))return s([c],i[t],n,!1,"1-lexicon-prefix"),!0}return null};var zt={lexicon:function(t){const e=t.world;t.docs.forEach(t=>{for(let n=0;n<t.length;n+=1)if(0===t[n].tags.size){let o=null;o=o||Pt(t,n,e),o=o||$t(t,n,e)}})}};var At={one:{expandLexicon:function(t){const e={},n={};return Object.keys(t).forEach(o=>{const r=t[o],s=(o=(o=o.toLowerCase().trim()).replace(/'s\b/,"")).split(/ /);s.length>1&&(void 0===n[s[0]]||s.length>n[s[0]])&&(n[s[0]]=s.length),e[o]=e[o]||r}),delete e[""],delete e.null,delete e[" "],{lex:e,_multi:n}}}};var Ct={addWords:function(t,e=!1){const n=this.world(),{methods:o,model:r}=n;if(!t)return;if(Object.keys(t).forEach(e=>{"string"==typeof t[e]&&t[e].startsWith("#")&&(t[e]=t[e].replace(/^#/,""))}),!0===e){const{lex:e,_multi:s}=o.one.expandLexicon(t,n);return Object.assign(r.one._multiCache,s),void Object.assign(r.one.frozenLex,e)}if(o.two.expandLexicon){const{lex:e,_multi:s}=o.two.expandLexicon(t,n);Object.assign(r.one.lexicon,e),Object.assign(r.one._multiCache,s)}const{lex:s,_multi:i}=o.one.expandLexicon(t,n);Object.assign(r.one.lexicon,s),Object.assign(r.one._multiCache,i)}};var Tt={model:{one:{lexicon:{},_multiCache:{},frozenLex:{}}},methods:At,compute:zt,lib:Ct,hooks:["lexicon"]};const Ft=function(t,e){const n=[{}],o=[null],r=[0],s=[];let i=0;t.forEach(function(t){let r=0;const s=function(t,e){const{methods:n,model:o}=e,r=n.one.tokenize.splitTerms(t,o).map(t=>n.one.tokenize.splitWhitespace(t,o));return r.map(t=>t.text.toLowerCase())}(t,e);for(let t=0;t<s.length;t++){const e=s[t];n[r]&&n[r].hasOwnProperty(e)?r=n[r][e]:(i++,n[r][e]=i,n[i]={},r=i,o[i]=null)}o[r]=[s.length]});for(const t in n[0])i=n[0][t],r[i]=0,s.push(i);for(;s.length;){const t=s.shift(),e=Object.keys(n[t]);for(let c=0;c<e.length;c+=1){const u=e[c],a=n[t][u];for(s.push(a),i=r[t];i>0&&!n[i].hasOwnProperty(u);)i=r[i];if(n.hasOwnProperty(i)){const t=n[i][u];r[a]=t,o[t]&&(o[a]=o[a]||[],o[a]=o[a].concat(o[t]))}else r[a]=0}}return{goNext:n,endAs:o,failTo:r}},Lt=function(t,e,n){let o=0;const r=[];for(let s=0;s<t.length;s++){const i=t[s][n.form]||t[s].normal;for(;o>0&&(void 0===e.goNext[o]||!e.goNext[o].hasOwnProperty(i));)o=e.failTo[o]||0;if(e.goNext[o].hasOwnProperty(i)&&(o=e.goNext[o][i],e.endAs[o])){const n=e.endAs[o];for(let e=0;e<n.length;e++){const o=n[e],i=t[s-o+1],[c,u]=i.index;r.push([c,u,u+o,i.id])}}}return r},Nt=function(t,e){for(let n=0;n<t.length;n+=1)if(!0===e.has(t[n]))return!1;return!0};const Vt=(t,e)=>{for(let n=t.length-1;n>=0;n-=1)if(t[n]!==e)return t=t.slice(0,n+1);return t},qt={buildTrie:function(t){return function(t){return t.goNext=t.goNext.map(t=>{if(0!==Object.keys(t).length)return t}),t.goNext=Vt(t.goNext,void 0),t.failTo=Vt(t.failTo,0),t.endAs=Vt(t.endAs,null),t}(Ft(t,this.world()))}};qt.compile=qt.buildTrie;var Dt={api:function(t){t.prototype.lookup=function(t,e={}){if(!t)return this.none();"string"==typeof t&&(t=[t]);var n;let o=function(t,e,n){let o=[];n.form=n.form||"normal";const r=t.docs;if(!e.goNext||!e.goNext[0])return console.error("Compromise invalid lookup trie"),t.none();const s=Object.keys(e.goNext[0]);for(let i=0;i<r.length;i++){if(t._cache&&t._cache[i]&&!0===Nt(s,t._cache[i]))continue;const c=r[i],u=Lt(c,e,n);u.length>0&&(o=o.concat(u))}return t.update(o)}(this,(n=t,"[object Object]"===Object.prototype.toString.call(n)?t:Ft(t,this.world)),e);return o=o.settle(),o}},lib:qt};const Gt=function(t,e){return e?(t.forEach(t=>{const n=t[0];e[n]&&(t[0]=e[n][0],t[1]+=e[n][1],t[2]+=e[n][1])}),t):t},Bt=function(t,e){let{ptrs:n}=t;const{byGroup:o}=t;return n=Gt(n,e),Object.keys(o).forEach(t=>{o[t]=Gt(o[t],e)}),{ptrs:n,byGroup:o}},Mt=function(t,e,n){const o=n.methods.one;return"number"==typeof t&&(t=String(t)),"string"==typeof t&&(t=o.killUnicode(t,n),t=o.parseMatch(t,e,n)),t},Ut=t=>"[object Object]"===Object.prototype.toString.call(t),Wt=t=>t&&Ut(t)&&!0===t.isView,It=t=>t&&Ut(t)&&!0===t.isNet;var Rt={matchOne:function(t,e,n){const o=this.methods.one;if(Wt(t))return this.intersection(t).eq(0);if(It(t))return this.sweep(t,{tagger:!1,matchOne:!0}).view;const r={regs:t=Mt(t,n,this.world),group:e,justOne:!0},s=o.match(this.docs,r,this._cache),{ptrs:i,byGroup:c}=Bt(s,this.fullPointer),u=this.toView(i);return u._groups=c,u},match:function(t,e,n){const o=this.methods.one;if(Wt(t))return this.intersection(t);if(It(t))return this.sweep(t,{tagger:!1}).view.settle();const r={regs:t=Mt(t,n,this.world),group:e},s=o.match(this.docs,r,this._cache),{ptrs:i,byGroup:c}=Bt(s,this.fullPointer),u=this.toView(i);return u._groups=c,u},has:function(t,e,n){const o=this.methods.one;if(Wt(t)){return this.intersection(t).fullPointer.length>0}if(It(t))return this.sweep(t,{tagger:!1}).view.found;const r={regs:t=Mt(t,n,this.world),group:e,justOne:!0};return o.match(this.docs,r,this._cache).ptrs.length>0},if:function(t,e,n){const o=this.methods.one;if(Wt(t))return this.filter(e=>e.intersection(t).found);if(It(t)){const e=this.sweep(t,{tagger:!1}).view.settle();return this.if(e)}const r={regs:t=Mt(t,n,this.world),group:e,justOne:!0};let s=this.fullPointer;const i=this._cache||[];s=s.filter((t,e)=>{const n=this.update([t]);return o.match(n.docs,r,i[e]).ptrs.length>0});const c=this.update(s);return this._cache&&(c._cache=s.map(t=>i[t[0]])),c},ifNo:function(t,e,n){const{methods:o}=this,r=o.one;if(Wt(t))return this.filter(e=>!e.intersection(t).found);if(It(t)){const e=this.sweep(t,{tagger:!1}).view.settle();return this.ifNo(e)}t=Mt(t,n,this.world);const s=this._cache||[],i=this.filter((n,o)=>{const i={regs:t,group:e,justOne:!0};return 0===r.match(n.docs,i,s[o]).ptrs.length});return this._cache&&(i._cache=i.ptrs.map(t=>s[t[0]])),i}};var Ht={before:function(t,e,n){const{indexN:o}=this.methods.one.pointer,r=[],s=o(this.fullPointer);Object.keys(s).forEach(t=>{const e=s[t].sort((t,e)=>t[1]>e[1]?1:-1)[0];e[1]>0&&r.push([e[0],0,e[1]])});const i=this.toView(r);return t?i.match(t,e,n):i},after:function(t,e,n){const{indexN:o}=this.methods.one.pointer,r=[],s=o(this.fullPointer),i=this.document;Object.keys(s).forEach(t=>{const e=s[t].sort((t,e)=>t[1]>e[1]?-1:1)[0],[n,,o]=e;o<i[n].length&&r.push([n,o,i[n].length])});const c=this.toView(r);return t?c.match(t,e,n):c},growLeft:function(t,e,n){"string"==typeof t&&(t=this.world.methods.one.parseMatch(t,n,this.world)),t[t.length-1].end=!0;const o=this.fullPointer;return this.forEach((n,r)=>{const s=n.before(t,e);if(s.found){const t=s.terms();o[r][1]-=t.length,o[r][3]=t.docs[0][0].id}}),this.update(o)},growRight:function(t,e,n){"string"==typeof t&&(t=this.world.methods.one.parseMatch(t,n,this.world)),t[0].start=!0;const o=this.fullPointer;return this.forEach((n,r)=>{const s=n.after(t,e);if(s.found){const t=s.terms();o[r][2]+=t.length,o[r][4]=null}}),this.update(o)},grow:function(t,e,n){return this.growRight(t,e,n).growLeft(t,e,n)}};const Qt=function(t,e){return[t[0],t[1],e[2]]},Zt=(t,e,n)=>{return"string"==typeof t||(o=t,"[object Array]"===Object.prototype.toString.call(o))?e.match(t,n):t||e.none();var o},Kt=function(t,e){const[n,o,r]=t;return e.document[n]&&e.document[n][o]&&(t[3]=t[3]||e.document[n][o].id,e.document[n][r-1]&&(t[4]=t[4]||e.document[n][r-1].id)),t},Jt={splitOn:function(t,e){const{splitAll:n}=this.methods.one.pointer,o=Zt(t,this,e).fullPointer,r=n(this.fullPointer,o);let s=[];return r.forEach(t=>{s.push(t.passthrough),s.push(t.before),s.push(t.match),s.push(t.after)}),s=s.filter(t=>t),s=s.map(t=>Kt(t,this)),this.update(s)},splitBefore:function(t,e){const{splitAll:n}=this.methods.one.pointer,o=Zt(t,this,e).fullPointer,r=n(this.fullPointer,o);for(let t=0;t<r.length;t+=1)!r[t].after&&r[t+1]&&r[t+1].before&&r[t].match&&r[t].match[0]===r[t+1].before[0]&&(r[t].after=r[t+1].before,delete r[t+1].before);let s=[];return r.forEach(t=>{s.push(t.passthrough),s.push(t.before),t.match&&t.after?s.push(Qt(t.match,t.after)):s.push(t.match)}),s=s.filter(t=>t),s=s.map(t=>Kt(t,this)),this.update(s)},splitAfter:function(t,e){const{splitAll:n}=this.methods.one.pointer,o=Zt(t,this,e).fullPointer,r=n(this.fullPointer,o);let s=[];return r.forEach(t=>{s.push(t.passthrough),t.before&&t.match?s.push(Qt(t.before,t.match)):(s.push(t.before),s.push(t.match)),s.push(t.after)}),s=s.filter(t=>t),s=s.map(t=>Kt(t,this)),this.update(s)}};Jt.split=Jt.splitAfter;const Xt=function(t,e){return!(!t||!e)&&(t[0]===e[0]&&t[2]===e[1])},Yt=function(t,e,n){const o=t.world,r=o.methods.one.parseMatch;n=n||"^.";const s=r(e=e||".$",{},o),i=r(n,{},o);s[s.length-1].end=!0,i[0].start=!0;const c=t.fullPointer,u=[c[0]];for(let e=1;e<c.length;e+=1){const n=u[u.length-1],o=c[e],r=t.update([n]),a=t.update([o]);Xt(n,o)&&r.has(s)&&a.has(i)?u[u.length-1]=[n[0],n[1],o[2],n[3],o[4]]:u.push(o)}return t.update(u)},te={joinIf:function(t,e){return Yt(this,t,e)},join:function(){return Yt(this)}},ee=Object.assign({},Rt,Ht,Jt,te);ee.lookBehind=ee.before,ee.lookBefore=ee.before,ee.lookAhead=ee.after,ee.lookAfter=ee.after,ee.notIf=ee.ifNo;const ne=/(?:^|\s)([![^]*(?:<[^<]*>)?\/.*?[^\\/]\/[?\]+*$~]*)(?:\s|$)/,oe=/([!~[^]*(?:<[^<]*>)?\([^)]+[^\\)]\)[?\]+*$~]*)(?:\s|$)/,re=/ /g,se=t=>/^[![^]*(<[^<]*>)?\//.test(t)&&/\/[?\]+*$~]*$/.test(t),ie=function(t){return t=(t=t.map(t=>t.trim())).filter(t=>t)},ce=/\{([0-9]+)?(, *[0-9]*)?\}/,ue=/&&/,ae=new RegExp(/^<\s*(\S+)\s*>/),le=t=>t.charAt(0).toUpperCase()+t.substring(1),he=t=>t.charAt(t.length-1),fe=t=>t.charAt(0),pe=t=>t.substring(1),de=t=>t.substring(0,t.length-1),me=function(t){return t=pe(t),t=de(t)},ge=function(t,e){const n={};for(let o=0;o<2;o+=1){if("$"===he(t)&&(n.end=!0,t=de(t)),"^"===fe(t)&&(n.start=!0,t=pe(t)),"?"===he(t)&&(n.optional=!0,t=de(t)),("["===fe(t)||"]"===he(t))&&(n.group=null,"["===fe(t)&&(n.groupStart=!0),"]"===he(t)&&(n.groupEnd=!0),t=(t=t.replace(/^\[/,"")).replace(/\]$/,""),"<"===fe(t))){const e=ae.exec(t);e.length>=2&&(n.group=e[1],t=t.replace(e[0],""))}if("+"===he(t)&&(n.greedy=!0,t=de(t)),"*"!==t&&"*"===he(t)&&"\\*"!==t&&(n.greedy=!0,t=de(t)),"!"===fe(t)&&(n.negative=!0,t=pe(t)),"~"===fe(t)&&"~"===he(t)&&t.length>2&&(t=me(t),n.fuzzy=!0,n.min=e.fuzzy||.85,!1===/\(/.test(t)))return n.word=t,n;if("/"===fe(t)&&"/"===he(t))return t=me(t),e.caseSensitive&&(n.use="text"),n.regex=new RegExp(t),n;if(!0===ce.test(t)&&(t=t.replace(ce,(t,e,o)=>(void 0===o?(n.min=Number(e),n.max=Number(e)):(o=o.replace(/, */,""),void 0===e?(n.min=0,n.max=Number(o)):(n.min=Number(e),n.max=Number(o||999))),n.greedy=!0,n.min||(n.optional=!0),""))),"("===fe(t)&&")"===he(t)){ue.test(t)?(n.choices=t.split(ue),n.operator="and"):(n.choices=t.split("|"),n.operator="or"),n.choices[0]=pe(n.choices[0]);const o=n.choices.length-1;n.choices[o]=de(n.choices[o]),n.choices=n.choices.map(t=>t.trim()),n.choices=n.choices.filter(t=>t),n.choices=n.choices.map(t=>t.split(/ /g).map(t=>ge(t,e))),t=""}if("{"===fe(t)&&"}"===he(t)){if(t=me(t),n.root=t,/\//.test(t)){const t=n.root.split(/\//);n.root=t[0],n.pos=t[1],"adj"===n.pos&&(n.pos="Adjective"),n.pos=n.pos.charAt(0).toUpperCase()+n.pos.substr(1).toLowerCase(),void 0!==t[2]&&(n.sense=t[2])}return n}if("<"===fe(t)&&">"===he(t))return t=me(t),n.chunk=le(t),n.greedy=!0,n;if("%"===fe(t)&&"%"===he(t))return t=me(t),n.switch=t,n}return"#"===fe(t)?(n.tag=pe(t),n.tag=le(n.tag),n):"@"===fe(t)?(n.method=pe(t),n):"."===t?(n.anything=!0,n):"*"===t?(n.anything=!0,n.greedy=!0,n.optional=!0,n):(t&&(t=(t=t.replace("\\*","*")).replace("\\.","."),e.caseSensitive?n.use="text":t=t.toLowerCase(),n.word=t),n)},we=/[a-z0-9][-–—][a-z]/i,ye=function(t,e){const{all:n}=e.methods.two.transform.verb||{},o=t.root;return n?n(o,e.model):[]},be=function(t,e){const{all:n}=e.methods.two.transform.noun||{};return n?n(t.root,e.model):[t.root]},ve=function(t,e){const{all:n}=e.methods.two.transform.adjective||{};return n?n(t.root,e.model):[t.root]},xe=function(t){return t=function(t){let e=0,n=null;for(let o=0;o<t.length;o++){const r=t[o];!0===r.groupStart&&(n=r.group,null===n&&(n=String(e),e+=1)),null!==n&&(r.group=n),!0===r.groupEnd&&(n=null)}return t}(t),t=function(t){return t.map(t=>(t.fuzzy&&t.choices&&t.choices.forEach(e=>{1===e.length&&e[0].word&&(e[0].fuzzy=!0,e[0].min=t.min)}),t))}(t=t.map(t=>{if(void 0!==t.choices){if("or"!==t.operator)return t;if(!0===t.fuzzy)return t;!0===t.choices.every(t=>{if(1!==t.length)return!1;const e=t[0];return!0!==e.fuzzy&&!e.start&&!e.end&&void 0!==e.word&&!0!==e.negative&&!0!==e.optional&&!0!==e.method})&&(t.fastOr=new Set,t.choices.forEach(e=>{t.fastOr.add(e[0].word)}),delete t.choices)}return t})),t},je=function(t,e){for(const n of e)if(t.has(n))return!0;return!1},Ee=function(t,e){for(let n=0;n<t.length;n+=1){const o=t[n];if(!0!==o.optional&&!0!==o.negative&&!0!==o.fuzzy){if(void 0!==o.word&&!1===e.has(o.word))return!0;if(void 0!==o.tag&&!1===e.has("#"+o.tag))return!0;if(void 0!==o.fastOr&&!1===je(o.fastOr,e))return!0}}return!1},Oe=function(t,e,n=3){if(t===e)return 1;if(t.length<n||e.length<n)return 0;const o=function(t,e){const n=t.length,o=e.length;if(0===n)return o;if(0===o)return n;const r=(o>n?o:n)+1;if(Math.abs(n-o)>(r||100))return r||100;const s=[];for(let t=0;t<r;t++)s[t]=[t],s[t].length=r;for(let t=0;t<r;t++)s[0][t]=t;let i,c,u,a,l,h;for(let r=1;r<=n;++r)for(c=t[r-1],i=1;i<=o;++i){if(r===i&&s[r][i]>4)return n;u=e[i-1],a=c===u?0:1,l=s[r-1][i]+1,(h=s[r][i-1]+1)<l&&(l=h),(h=s[r-1][i-1]+a)<l&&(l=h);const o=r>1&&i>1&&c===e[i-2]&&t[r-2]===u&&(h=s[r-2][i-2]+a)<l;s[r][i]=o?h:l}return s[n][o]}(t,e),r=Math.max(t.length,e.length);return 1-(0===r?0:o/r)},ke=/([\u0022\uFF02\u0027\u201C\u2018\u201F\u201B\u201E\u2E42\u201A\u00AB\u2039\u2035\u2036\u2037\u301D\u0060\u301F])/,Pe=/([\u0022\uFF02\u0027\u201D\u2019\u00BB\u203A\u2032\u2033\u2034\u301E\u00B4])/,_e=/^[-–—]$/,Se=/ [-–—]{1,3} /,$e=(t,e)=>-1!==t.post.indexOf(e),ze={hasQuote:t=>ke.test(t.pre)||Pe.test(t.post),hasComma:t=>$e(t,","),hasPeriod:t=>!0===$e(t,".")&&!1===$e(t,"..."),hasExclamation:t=>$e(t,"!"),hasQuestionMark:t=>$e(t,"?")||$e(t,"¿"),hasEllipses:t=>$e(t,"..")||$e(t,"…"),hasSemicolon:t=>$e(t,";"),hasColon:t=>$e(t,":"),hasSlash:t=>/\//.test(t.text),hasHyphen:t=>_e.test(t.post)||_e.test(t.pre),hasDash:t=>Se.test(t.post)||Se.test(t.pre),hasContraction:t=>Boolean(t.implicit),isAcronym:t=>t.tags.has("Acronym"),isKnown:t=>t.tags.size>0,isTitleCase:t=>/^\p{Lu}[a-z'\u00C0-\u00FF]/u.test(t.text),isUpperCase:t=>/^\p{Lu}+$/u.test(t.text)};ze.hasQuotation=ze.hasQuote;let Ae=function(){};Ae=function(t,e,n,o){const r=function(t,e,n,o){if(!0===e.anything)return!0;if(!0===e.start&&0!==n)return!1;if(!0===e.end&&n!==o-1)return!1;if(void 0!==e.id&&e.id===t.id)return!0;if(void 0!==e.word){if(e.use)return e.word===t[e.use];if(null!==t.machine&&t.machine===e.word)return!0;if(!0===e.fuzzy){if(e.word===t.root)return!0;if(Oe(e.word,t.normal)>=e.min)return!0}return!(!t.alias||!t.alias.some(t=>t===e.word))||e.word===t.text||e.word===t.normal}if(void 0!==e.tag)return!0===t.tags.has(e.tag);if(void 0!==e.method)return"function"==typeof ze[e.method]&&!0===ze[e.method](t);if(void 0!==e.pre)return t.pre&&t.pre.includes(e.pre);if(void 0!==e.post)return t.post&&t.post.includes(e.post);if(void 0!==e.regex){let n=t.normal;return e.use&&(n=t[e.use]),e.regex.test(n)}if(void 0!==e.chunk)return t.chunk===e.chunk;if(void 0!==e.switch)return t.switch===e.switch;if(void 0!==e.machine)return t.normal===e.machine||t.machine===e.machine||t.root===e.machine;if(void 0!==e.sense)return t.sense===e.sense;if(void 0!==e.fastOr){if(e.pos&&!t.tags.has(e.pos))return null;const n=t.root||t.implicit||t.machine||t.normal;return e.fastOr.has(n)||e.fastOr.has(t.text)}return void 0!==e.choices&&("and"===e.operator?e.choices.every(e=>Ae(t,e,n,o)):e.choices.some(e=>Ae(t,e,n,o)))}(t,e,n,o);return!0===e.negative?!r:r};const Ce=function(t,e){if(!0===t.end&&!0===t.greedy&&e.start_i+e.t<e.phrase_length-1){const n=Object.assign({},t,{end:!1});if(!0===Ae(e.terms[e.t],n,e.start_i+e.t,e.phrase_length))return!0}return!1},Te=function(t,e){return t.groups[t.inGroup]||(t.groups[t.inGroup]={start:e,length:0}),t.groups[t.inGroup]},Fe=function(t){const{regs:e}=t,n=e[t.r],o=function(t,e){let n=t.t;if(!e)return t.terms.length;for(;n<t.terms.length;n+=1)if(!0===Ae(t.terms[n],e,t.start_i+n,t.phrase_length))return n;return null}(t,e[t.r+1]);if(null===o||0===o)return null;if(void 0!==n.min&&o-t.t<n.min)return null;if(void 0!==n.max&&o-t.t>n.max)return t.t=t.t+n.max,!0;if(!0===t.hasGroup){Te(t,t.t).length+=o-t.t}return t.t=o,!0},Le=function(t){return"[object Array]"===Object.prototype.toString.call(t)},Ne=function(t,e,n){let o=0;for(let r=0;r<e.length;r+=1){const s=e[r],i=t.t+n+o;if(void 0===t.terms[i])return 0;if(!0!==Ae(t.terms[i],s,t.start_i+i,t.phrase_length))return 0;if(o+=1,!0===s.greedy){const e=Object.assign({},s,{start:!1,end:!1});for(let n=i+1;n<t.terms.length&&!0===Ae(t.terms[n],e,t.start_i+n,t.phrase_length);n+=1)o+=1}}return o},Ve=function(t,e){const n=t.regs[t.r];for(let o=0;o<n.choices.length;o+=1){const r=n.choices[o];if(!Le(r))return 0;const s=Ne(t,r,e);if(s>0)return s}return 0},qe=function(t){const{regs:e}=t,n=e[t.r],o=function(t){const e=t.regs[t.r];let n=Ve(t,0);if(0===n)return 0;if(!0===e.greedy){let e=Ve(t,n);for(;e>0;)n+=e,e=Ve(t,n)}return n}(t);if(o){if(!0===n.negative)return null;if(!0===t.hasGroup){Te(t,t.t).length+=o}if(!0===n.end){const e=t.phrase_length;if(t.t+t.start_i+o!==e)return null}return t.t+=o,!0}return!0===n.negative?(n.optional||(t.t+=1),!0):!!n.optional||null},De=function(t){const{regs:e}=t,n=e[t.r],o=function(t){let e=0;return!0===t.regs[t.r].choices.every(n=>{const o=n.every((e,n)=>{const o=t.t+n;return void 0!==t.terms[o]&&Ae(t.terms[o],e,t.start_i+o,t.phrase_length)});return!0===o&&n.length>e&&(e=n.length),o})&&e}(t);if(o){if(!0===n.negative)return null;if(!0===t.hasGroup){Te(t,t.t).length+=o}if(!0===n.end){const e=t.phrase_length;if(t.t+t.start_i+o!==e)return null}return t.t+=o,!0}return!0===n.negative?(n.optional||(t.t+=1),!0):!!n.optional||null},Ge=function(t){const{regs:e}=t,n=e[t.r],o=Object.assign({},n);o.negative=!1;if(Ae(t.terms[t.t],o,t.start_i+t.t,t.phrase_length))return!1;if(n.optional){const n=e[t.r+1];if(n){if(Ae(t.terms[t.t],n,t.start_i+t.t,t.phrase_length))t.r+=1;else if(n.optional&&e[t.r+2]){Ae(t.terms[t.t],e[t.r+2],t.start_i+t.t,t.phrase_length)&&(t.r+=2)}}}return n.greedy?function(t,e,n){let o=0;for(let r=t.t;r<t.terms.length;r+=1){let s=Ae(t.terms[r],e,t.start_i+r,t.phrase_length);if(s)break;if(n&&(s=Ae(t.terms[r],n,t.start_i+r,t.phrase_length),s))break;if(o+=1,void 0!==e.max&&o===e.max)break}return!(0===o||e.min&&e.min>o||(t.t+=o,0))}(t,o,e[t.r+1]):(t.t+=1,!0)},Be=function(t){const{regs:e,phrase_length:n}=t,o=e[t.r];return t.t=function(t,e){const n=Object.assign({},t.regs[t.r],{start:!1,end:!1}),o=t.t;for(;t.t<t.terms.length;t.t+=1){const r=t.t-o+1;if(e&&Ae(t.terms[t.t],e,t.start_i+t.t,t.phrase_length)&&(void 0===n.min||r>=n.min))return t.t;if(void 0!==n.max&&r===n.max)return t.t;if(!1===Ae(t.terms[t.t],n,t.start_i+t.t,t.phrase_length))return void 0!==n.min&&r<n.min?null:t.t}return void 0!==n.min&&t.t-o+1<n.min?null:t.t}(t,e[t.r+1]),null===t.t?null:!0!==o.end||t.start_i+t.t===n||null},Me=function(t){const{regs:e}=t,n=e[t.r],o=t.terms[t.t],r=t.t;if(n.optional&&e[t.r+1]&&n.negative)return!0;if(n.optional&&e[t.r+1]&&function(t){const{regs:e}=t,n=e[t.r],o=t.terms[t.t],r=Ae(o,e[t.r+1],t.start_i+t.t,t.phrase_length);if(n.negative||r){const n=t.terms[t.t+1];n&&Ae(n,e[t.r+1],t.start_i+t.t+1,t.phrase_length)||(t.r+=1)}}(t),o.implicit&&t.terms[t.t+1]&&function(t){const e=t.terms[t.t],n=t.regs[t.r];if(e.implicit&&t.terms[t.t+1]){if(!t.terms[t.t+1].implicit)return;n.word===e.normal&&(t.t+=1),"hasContraction"===n.method&&(t.t+=1)}}(t),t.t+=1,!0===n.end&&t.t!==t.terms.length&&!0!==n.greedy)return null;if(!0===n.greedy){if(!Be(t))return null}return!0===t.hasGroup&&function(t,e){const n=t.regs[t.r],o=Te(t,e);t.t>1&&n.greedy?o.length+=t.t-e:o.length++}(t,r),!0},Ue=function(t,e,n,o){if(0===t.length||0===e.length)return null;const r={t:0,terms:t,r:0,regs:e,groups:{},start_i:n,phrase_length:o,inGroup:null};for(;r.r<e.length;r.r+=1){const t=e[r.r];if(r.hasGroup=Boolean(t.group),!0===r.hasGroup?r.inGroup=t.group:r.inGroup=null,!r.terms[r.t]){if(!1===e.slice(r.r).some(t=>!t.optional))break;return null}if(!0===t.anything&&!0===t.greedy){if(!Fe(r))return null;continue}if(void 0!==t.choices&&"or"===t.operator){if(!qe(r))return null;continue}if(void 0!==t.choices&&"and"===t.operator){if(!De(r))return null;continue}if(!0===t.anything){if(t.negative&&t.anything)return null;if(!Me(r))return null;continue}if(!0===Ce(t,r)){if(!Me(r))return null;continue}if(t.negative){if(!Ge(r))return null;continue}if(!0===Ae(r.terms[r.t],t,r.start_i+r.t,r.phrase_length)){if(!Me(r))return null;continue}if(!0!==t.optional)return null}const s=[null,n,r.t+n];if(s[1]===s[2])return null;const i={};return Object.keys(r.groups).forEach(t=>{const e=r.groups[t],o=n+e.start;i[t]=[null,o,o+e.length]}),{pointer:s,groups:i}},We=function(t,e){return t.pointer[0]=e,Object.keys(t.groups).forEach(n=>{t.groups[n][0]=e}),t},Ie=function(t,e,n){let o=Ue(t,e,0,t.length);return o?(o=We(o,n),o):null},Re={one:{termMethods:ze,parseMatch:function(t,e,n){if(null==t||""===t)return[];e=e||{},"number"==typeof t&&(t=String(t));let o=function(t){const e=t.split(ne);let n=[];e.forEach(t=>{se(t)?n.push(t):n=n.concat(t.split(oe))}),n=ie(n);let o=[];return n.forEach(t=>{(t=>/^[![^]*(<[^<]*>)?\(/.test(t)&&/\)[?\]+*$~]*$/.test(t))(t)||se(t)?o.push(t):o=o.concat(t.split(re))}),o=ie(o),o}(t);return o=o.map(t=>ge(t,e)),o=function(t,e){const n=e.model.one.prefixes;for(let e=t.length-1;e>=0;e-=1){const o=t[e];if(o.word&&we.test(o.word)){let r=o.word.split(/[-–—]/g);if(n.hasOwnProperty(r[0]))continue;r=r.filter(t=>t).reverse(),t.splice(e,1),r.forEach(n=>{const r=Object.assign({},o);r.word=n,t.splice(e,0,r)})}}return t}(o,n),o=function(t,e){return t.map(t=>{if(t.root)if(e.methods.two&&e.methods.two.transform){let n=[];t.pos?"Verb"===t.pos?n=n.concat(ye(t,e)):"Noun"===t.pos?n=n.concat(be(t,e)):"Adjective"===t.pos&&(n=n.concat(ve(t,e))):(n=n.concat(ye(t,e)),n=n.concat(be(t,e)),n=n.concat(ve(t,e))),n=n.filter(t=>t),n.length>0&&(t.operator="or",t.fastOr=new Set(n))}else t.machine=t.root,delete t.id,delete t.root;return t})}(o,n),o=xe(o),o},match:function(t,e,n){n=n||[];const{regs:o,group:r,justOne:s}=e;let i=[];if(!o||0===o.length)return{ptrs:[],byGroup:{}};const c=o.filter(t=>!0!==t.optional&&!0!==t.negative).length;t:for(let e=0;e<t.length;e+=1){const r=t[e];if(!n[e]||!Ee(o,n[e])){if(!0===o[0].start){const t=Ie(r,o,e);t&&i.push(t);continue}for(let t=0;t<r.length;t+=1){const n=r.slice(t);if(n.length<c)break;let u=Ue(n,o,t,r.length);if(u){if(u=We(u,e),i.push(u),!0===s)break t;const n=u.pointer[2];Math.abs(n-1)>t&&(t=Math.abs(n-1))}}}}return!0===o[o.length-1].end&&(i=i.filter(e=>{const n=e.pointer[0];return t[n].length===e.pointer[2]})),e.notIf&&(i=function(t,e,n){return t=t.filter(t=>{const[o,r,s]=t.pointer,i=n[o].slice(r,s);for(let t=0;t<i.length;t+=1){const n=i.slice(t);if(null!==Ue(n,e,t,i.length))return!1}return!0}),t}(i,e.notIf,t)),i=function(t,e){const n=[],o={};return 0===t.length||("number"==typeof e&&(e=String(e)),e?t.forEach(t=>{t.groups[e]&&n.push(t.groups[e])}):t.forEach(t=>{n.push(t.pointer),Object.keys(t.groups).forEach(e=>{o[e]=o[e]||[],o[e].push(t.groups[e])})})),{ptrs:n,byGroup:o}}(i,r),i.ptrs.forEach(e=>{const[n,o,r]=e;e[3]=t[n][o].id,e[4]=t[n][r-1].id}),i}}};var He={api:function(t){Object.assign(t.prototype,ee)},methods:Re,lib:{parseMatch:function(t,e){const n=this.world(),o=n.methods.one.killUnicode;return o&&(t=o(t,n)),n.methods.one.parseMatch(t,e,n)}}};const Qe=/^\../,Ze=/^#./,Ke=function(t,e){const n={},o={};return Object.keys(e).forEach(r=>{let s=e[r];const i=function(t){let e="",n="</span>";return t=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Qe.test(t)?e=`<span class="${t.replace(/^\./,"")}"`:Ze.test(t)?e=`<span id="${t.replace(/^#/,"")}"`:(e=`<${t}`,n=`</${t}>`),e+=">",{start:e,end:n}}(r);"string"==typeof s&&(s=t.match(s)),s.docs.forEach(t=>{if(t.every(t=>t.implicit))return;const e=t[0].id;n[e]=n[e]||[],n[e].push(i.start);const r=t[t.length-1].id;o[r]=o[r]||[],o[r].push(i.end)})}),{starts:n,ends:o}};var Je={html:function(t){const{starts:e,ends:n}=Ke(this,t);let o="";return this.docs.forEach(t=>{for(let r=0;r<t.length;r+=1){const s=t[r];e.hasOwnProperty(s.id)&&(o+=e[s.id].join("")),o+=s.pre||"",o+=s.text||"",n.hasOwnProperty(s.id)&&(o+=n[s.id].join("")),o+=s.post||""}}),o}};const Xe=/[,:;)\]*.?~!\u0022\uFF02\u201D\u2019\u00BB\u203A\u2032\u2033\u2034\u301E\u00B4—-]+$/,Ye=/^[(['"*~\uFF02\u201C\u2018\u201F\u201B\u201E\u2E42\u201A\u00AB\u2039\u2035\u2036\u2037\u301D\u0060\u301F]+/,tn=/[,:;)('"\u201D\]]/,en=/^[-–—]$/,nn=/ /,on=function(t,e,n=!0){let o="";return t.forEach(t=>{let n=t.pre||"",r=t.post||"";"some"===e.punctuation&&(n=n.replace(Ye,""),en.test(r)&&(r=" "),r=r.replace(tn,""),r=r.replace(/\?!+/,"?"),r=r.replace(/!+/,"!"),r=r.replace(/\?+/,"?"),r=r.replace(/\.{2,}/,""),t.tags.has("Abbreviation")&&(r=r.replace(/\./,""))),"some"===e.whitespace&&(n=n.replace(/\s/,""),r=r.replace(/\s+/," ")),e.keepPunct||(n=n.replace(Ye,""),r="-"===r?" ":r.replace(Xe,""));let s=t[e.form||"text"]||t.normal||"";"implicit"===e.form&&(s=t.implicit||t.text),"root"===e.form&&t.implicit&&(s=t.root||t.implicit||t.normal),"machine"!==e.form&&"implicit"!==e.form&&"root"!==e.form||!t.implicit||r&&nn.test(r)||(r+=" "),o+=n+s+r}),!1===n&&(o=o.trim()),!0===e.lowerCase&&(o=o.toLowerCase()),o},rn={text:{form:"text"},normal:{whitespace:"some",punctuation:"some",case:"some",unicode:"some",form:"normal"},machine:{keepSpace:!1,whitespace:"some",punctuation:"some",case:"none",unicode:"some",form:"machine"},root:{keepSpace:!1,whitespace:"some",punctuation:"some",case:"some",unicode:"some",form:"root"},implicit:{form:"implicit"}};rn.clean=rn.normal,rn.reduced=rn.root;const sn=[];let cn=0;for(;cn<64;)sn[cn]=0|4294967296*Math.sin(++cn%Math.PI);const un=function(t){let e,n,o,r=decodeURI(encodeURI(t))+"",s=r.length;const i=[e=1732584193,n=4023233417,~e,~n],c=[];for(t=--s/4+2|15,c[--t]=8*s;~s;)c[s>>2]|=r.charCodeAt(s)<<8*s--;for(cn=r=0;cn<t;cn+=16){for(s=i;r<64;s=[o=s[3],e+((o=s[0]+[e&n|~e&o,o&e|~o&n,e^n^o,n^(e|~o)][s=r>>4]+sn[r]+~~c[cn|15&[r,5*r+1,3*r+5,7*r][s]])<<(s=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*s+r++%4])|o>>>-s),e,n])e=0|s[1],n=s[2];for(r=4;r;)i[--r]+=s[r]}for(t="";r<32;)t+=(i[r>>3]>>4*(1^r++)&15).toString(16);return t},an={text:!0,terms:!0},ln={case:"none",unicode:"some",form:"machine",punctuation:"some"},hn=function(t,e){return Object.assign({},t,e)},fn={text:t=>on(t,{keepPunct:!0},!1),normal:t=>on(t,hn(rn.normal,{keepPunct:!0}),!1),implicit:t=>on(t,hn(rn.implicit,{keepPunct:!0}),!1),machine:t=>on(t,ln,!1),root:t=>on(t,hn(ln,{form:"root"}),!1),hash:t=>un(on(t,{keepPunct:!0},!1)),offset:t=>{const e=fn.text(t).length;return{index:t[0].offset.index,start:t[0].offset.start,length:e}},terms:t=>t.map(t=>{const e=Object.assign({},t);return e.tags=Array.from(t.tags),e}),confidence:(t,e,n)=>e.eq(n).confidence(),syllables:(t,e,n)=>e.eq(n).syllables(),sentence:(t,e,n)=>e.eq(n).fullSentence().text(),dirty:t=>t.some(t=>!0===t.dirty)};fn.sentences=fn.sentence,fn.clean=fn.normal,fn.reduced=fn.root;const pn={json:function(t){const e=(n=this,"string"==typeof(o=(o=t)||{})&&(o={}),(o=Object.assign({},an,o)).offset&&n.compute("offset"),n.docs.map((t,e)=>{const r={};return Object.keys(o).forEach(s=>{o[s]&&fn[s]&&(r[s]=fn[s](t,n,e))}),r}));var n,o;return"number"==typeof t?e[t]:e}};pn.data=pn.json;const dn=function(t){const e=t.pre||"",n=t.post||"";return e+t.text+n},mn=function(t,e){const n=function(t,e){const n={};return Object.keys(e).forEach(o=>{t.match(o).fullPointer.forEach(t=>{n[t[3]]={fn:e[o],end:t[2]}})}),n}(t,e);let o="";return t.docs.forEach((e,r)=>{for(let s=0;s<e.length;s+=1){const i=e[s];if(n.hasOwnProperty(i.id)){const{fn:c,end:u}=n[i.id],a=t.update([[r,s,u]]);o+=e[s].pre||"",o+=c(a),s=u-1,o+=e[s].post||""}else o+=dn(i)}}),o},gn=new Set(["Hyphenated","Prefix","SlashedTerm"]),wn=function(t,e){const n=e[t];if(!n||!n.parents||0===n.parents.length)return t;for(let t=0;t<n.parents.length;t+=1){const o=n.parents[t];if(e[o]&&(!e[o].parents||0===e[o].parents.length))return o}return n.parents[n.parents.length-1]},yn=function(t,e){const n=e.model.one.tagSet,o=function(t){const e={};for(const n in t){const o=t[n];o.alias&&(e[n]=o.alias)}return e}(n);return t.docs.map(t=>{const e=t.reduce((t,e)=>t+e.pre+e.text+e.post,"").trim(),r=t.map(t=>{let e=function(t,e){const n=Array.from(t.tags||[]);if(0===n.length)return"-";const o=n.find(t=>!gn.has(wn(t,e)))||n[0];return wn(o,e)}(t,n);return o[e]||e}).join(",");return`${e} {${r}}`}).join("\n")},bn={debug:function(t){const e=this.methods.one.debug||{};return t&&e.hasOwnProperty(t)?(e[t](this),this):"undefined"!=typeof window&&window.document?(e.clientSide(this),this):(e.tags(this),this)},out:function(t){if(e=t,"[object Object]"===Object.prototype.toString.call(e))return mn(this,t);var e;if("text"===t)return this.text();if("normal"===t)return this.text("normal");if("root"===t)return this.text("root");if("machine"===t||"reduced"===t)return this.text("machine");if("hash"===t||"md5"===t)return un(this.text());if("spec"===t)return yn(this,this.world);if("json"===t)return this.json();if("offset"===t||"offsets"===t)return this.compute("offset"),this.json({offset:!0});if("array"===t){const t=this.docs.map(t=>t.reduce((t,e)=>t+e.pre+e.text+e.post,"").trim());return t.filter(t=>t)}if("freq"===t||"frequency"===t||"topk"===t)return function(t){const e={};t.forEach(t=>{e[t]=e[t]||0,e[t]+=1});const n=Object.keys(e).map(t=>({normal:t,count:e[t]}));return n.sort((t,e)=>t.count>e.count?-1:0)}(this.json({normal:!0}).map(t=>t.normal));if("terms"===t){let t=[];return this.docs.forEach(e=>{let n=e.map(t=>t.text);n=n.filter(t=>t),t=t.concat(n)}),t}return"tags"===t?this.docs.map(t=>t.reduce((t,e)=>(t[e.implicit||e.normal]=Array.from(e.tags),t),{})):"debug"===t?this.debug():this.text()},wrap:function(t){return mn(this,t)}};var vn={text:function(t){let e={};var n;if(t&&"string"==typeof t&&rn.hasOwnProperty(t)?e=Object.assign({},rn[t]):t&&(n=t,"[object Object]"===Object.prototype.toString.call(n))&&(e=Object.assign({},t)),void 0!==e.keepSpace||this.isFull()||(e.keepSpace=!1),void 0===e.keepEndPunct&&this.pointer){const t=this.pointer[0];t&&t[1]?e.keepEndPunct=!1:e.keepEndPunct=!0}return void 0===e.keepPunct&&(e.keepPunct=!0),void 0===e.keepSpace&&(e.keepSpace=!0),function(t,e){let n="";if(!t||!t[0]||!t[0][0])return n;for(let o=0;o<t.length;o+=1)n+=on(t[o],e,!0);if(e.keepSpace||(n=n.trim()),!1===e.keepEndPunct){t[0][0].tags.has("Emoticon")||(n=n.replace(Ye,""));const e=t[t.length-1];e[e.length-1].tags.has("Emoticon")||(n=n.replace(Xe,"")),n.endsWith("'")&&!n.endsWith("s'")&&(n=n.replace(/'/,""))}return!0===e.cleanWhitespace&&(n=n.trim()),n}(this.docs,e)}};const xn=Object.assign({},bn,vn,pn,Je),jn="[0m",En={green:t=>"[32m"+t+jn,red:t=>"[31m"+t+jn,blue:t=>"[34m"+t+jn,magenta:t=>"[35m"+t+jn,cyan:t=>"[36m"+t+jn,yellow:t=>"[33m"+t+jn,black:t=>"[30m"+t+jn,dim:t=>"[2m"+t+jn,i:t=>"[3m"+t+jn},On={tags:function(t){const{docs:e,model:n}=t;0===e.length&&console.log(En.blue("\n ──────")),e.forEach(e=>{console.log(En.blue("\n ┌─────────")),e.forEach(e=>{const o=[...e.tags||[]];let r=e.text||"-";e.sense&&(r=`{${e.normal}/${e.sense}}`),e.implicit&&(r="["+e.implicit+"]"),r=En.yellow(r);let s="'"+r+"'";if(e.reference){const n=t.update([e.reference]).text("normal");s+=` - ${En.dim(En.i("["+n+"]"))}`}s=s.padEnd(18);const i=En.blue(" │ ")+En.i(s)+" - "+function(t,e){return e.one.tagSet&&(t=t.map(t=>{if(!e.one.tagSet.hasOwnProperty(t))return t;const n=e.one.tagSet[t].color||"blue";return En[n](t)})),t.join(", ")}(o,n);console.log(i)})}),console.log("\n")},clientSide:function(t){console.log("%c -=-=- ","background-color:#6699cc;"),t.forEach(t=>{console.groupCollapsed(t.text());const e=t.docs[0].map(t=>{let e=t.text||"-";t.implicit&&(e="["+t.implicit+"]");return{text:e,tags:"["+Array.from(t.tags).join(", ")+"]"}});console.table(e,["text","tags"]),console.groupEnd()})},chunks:function(t){const{docs:e}=t;console.log(""),e.forEach(t=>{const e=[];t.forEach(t=>{"Noun"===t.chunk?e.push(En.blue(t.implicit||t.normal)):"Verb"===t.chunk?e.push(En.green(t.implicit||t.normal)):"Adjective"===t.chunk?e.push(En.yellow(t.implicit||t.normal)):"Pivot"===t.chunk?e.push(En.red(t.implicit||t.normal)):e.push(t.implicit||t.normal)}),console.log(e.join(" "),"\n")}),console.log("\n")},highlight:function(t){if(!t.found)return;const e={};t.fullPointer.forEach(t=>{e[t[0]]=e[t[0]]||[],e[t[0]].push(t)}),Object.keys(e).forEach(n=>{let o=t.update([[Number(n)]]).text();t.update(e[n]).json({offset:!0}).forEach((t,e)=>{o=function(t,e,n){const o=((t,e,n)=>{const o=9*n,r=e.start+o,s=r+e.length;return[t.substring(0,r),t.substring(r,s),t.substring(s,t.length)]})(t,e,n);return`${o[0]}${En.blue(o[1])}${o[2]}`}(o,t.offset,e)}),console.log(o)}),console.log("\n")}},kn=/\{(?=[^{]*$)/,Pn=/\}[ \t]*#.*$/,_n=function(t=""){let[e,n]=t.split(kn);if(void 0===n)return{text:e,tags:[]};n=n.replace(Pn,"}"),n=n.split(",").map(t=>t.trim());let o=n[n.length-1];return n[n.length-1]=o.replace(/\}$/,""),n=n.map(t=>t.split("|").map(t=>t.trim())),n=n.filter(t=>t.some(t=>""!==t)),{text:e,tags:n}},Sn=function(t){return t.map(t=>t.join("|")).join(",")};var $n={lib:{fromSpec:function(t){return this(t.split("\n").filter(t=>t.trim()).map(t=>_n(t).text).join("\n"))},testSpec:function(t,e=!0,n=!1){let o=this.world(),r={},s=o.model.one.tagSet;Object.keys(s).forEach(t=>{s[t].alias&&(r[s[t].alias]=t)});let i=t.split("\n").filter(t=>t.trim()).map(t=>{let{text:o,tags:s}=_n(t),i=this(o),c=function(t,e){return t.map(t=>(t=t.map(t=>"#"+(e[t]||t))).length>1?`(${t.join(" && ")})`:t[0]).join(" ")}(s,r),u=i.has(c);if(!1!==e){let t=u?"✅":"❌";console.log(`${t} ${o} {${Sn(s)}}`)}if(!1===u&&!0===n)throw new Error(`❌ ${o} {${Sn(s)}}`);return u?null:o}).filter(Boolean).join("\n");return this(i)}},api:function(t){Object.assign(t.prototype,xn)},methods:{one:{hash:un,debug:On}}};const zn=function(t,e){if(t[0]!==e[0])return!1;const[,n,o]=t,[,r,s]=e;return n<=r&&o>r||r<=n&&s>n},An=function(t){const e={};return t.forEach(t=>{e[t[0]]=e[t[0]]||[],e[t[0]].push(t)}),e},Cn=function(t,e){const n=An(e),o=[];return t.forEach(t=>{const[e]=t;let r=n[e]||[];if(r=r.filter(e=>function(t,e){return t[1]<=e[1]&&e[2]<=t[2]}(t,e)),0===r.length)return void o.push({passthrough:t});r=r.sort((t,e)=>t[1]-e[1]);let s=t;r.forEach((t,e)=>{const n=function(t,e){const[n,o]=t,r=e[1],s=e[2],i={};if(o<r){const e=r<t[2]?r:t[2];i.before=[n,o,e]}return i.match=e,t[2]>s&&(i.after=[n,s,t[2]]),i}(s,t);r[e+1]?(o.push({before:n.before,match:n.match}),n.after&&(s=n.after)):o.push(n)})}),o};var Tn={one:{termList:function(t){const e=[];for(let n=0;n<t.length;n+=1)for(let o=0;o<t[n].length;o+=1)e.push(t[n][o]);return e},getDoc:function(t,e){let n=[];return t.forEach((o,r)=>{if(!o)return;let[s,i,c,u,a]=o,l=e[s]||[];if(void 0===i&&(i=0),void 0===c&&(c=l.length),!u||l[i]&&l[i].id===u)l=l.slice(i,c);else{const n=function(t,e,n){for(let o=0;o<20;o+=1){if(e[n-o]){const r=e[n-o].findIndex(e=>e.id===t);if(-1!==r)return[n-o,r]}if(e[n+o]){const r=e[n+o].findIndex(e=>e.id===t);if(-1!==r)return[n+o,r]}}return null}(u,e,s);if(null!==n){const o=c-i;l=e[n[0]].slice(n[1],n[1]+o);const s=l[0]?l[0].id:null;t[r]=[n[0],n[1],n[1]+o,s]}}0!==l.length&&i!==c&&(a&&l[l.length-1].id!==a&&(l=function(t,e){const[n,o,,,r]=t,s=e[n],i=s.findIndex(t=>t.id===r);return-1===i?(t[2]=e[n].length,t[4]=s.length?s[s.length-1].id:null):t[2]=i,e[n].slice(o,t[2]+1)}(o,e)),n.push(l))}),n=n.filter(t=>t.length>0),n},pointer:{indexN:An,splitAll:Cn}}};const Fn=function(t,e){const n=t.concat(e),o=An(n);let r=[];return n.forEach(t=>{const[e]=t;if(1===o[e].length)return void r.push(t);const n=o[e].filter(e=>zn(t,e));n.push(t);const s=function(t){let e=t[0][1],n=t[0][2];return t.forEach(t=>{t[1]<e&&(e=t[1]),t[2]>n&&(n=t[2])}),[t[0][0],e,n]}(n);r.push(s)}),r=function(t){const e={};for(let n=0;n<t.length;n+=1)e[t[n].join(",")]=t[n];return Object.values(e)}(r),r},Ln=function(t,e){const n=[];return Cn(t,e).forEach(t=>{t.passthrough&&n.push(t.passthrough),t.before&&n.push(t.before),t.after&&n.push(t.after)}),n},Nn=(t,e)=>{return"string"==typeof t||(n=t,"[object Array]"===Object.prototype.toString.call(n))?e.match(t):t||e.none();var n},Vn=function(t,e){return t.map(t=>{const[n,o]=t;return e[n]&&e[n][o]&&(t[3]=e[n][o].id),t})},qn={union:function(t){t=Nn(t,this);let e=Fn(this.fullPointer,t.fullPointer);return e=Vn(e,this.document),this.toView(e)}};qn.and=qn.union,qn.intersection=function(t){t=Nn(t,this);let e=function(t,e){const n=An(e),o=[];return t.forEach(t=>{let e=n[t[0]]||[];e=e.filter(e=>zn(t,e)),0!==e.length&&e.forEach(e=>{const n=function(t,e){const n=t[1]<e[1]?e[1]:t[1],o=t[2]>e[2]?e[2]:t[2];return n<o?[t[0],n,o]:null}(t,e);n&&o.push(n)})}),o}(this.fullPointer,t.fullPointer);return e=Vn(e,this.document),this.toView(e)},qn.not=function(t){t=Nn(t,this);let e=Ln(this.fullPointer,t.fullPointer);return e=Vn(e,this.document),this.toView(e)},qn.difference=qn.not,qn.complement=function(){const t=this.all();let e=Ln(t.fullPointer,this.fullPointer);return e=Vn(e,this.document),this.toView(e)},qn.settle=function(){let t=this.fullPointer;return t.forEach(e=>{t=Fn(t,[e])}),t=Vn(t,this.document),this.update(t)};var Dn={methods:Tn,api:function(t){Object.assign(t.prototype,qn)}};const Gn=function(t){return!0===t.optional||!0===t.negative?null:t.tag?"#"+t.tag:t.word?t.word:t.switch?`%${t.switch}%`:null},Bn=function(t,e){const n=e.methods.one.parseMatch;return t.forEach(t=>{t.regs=n(t.match,{},e),"string"==typeof t.ifNo&&(t.ifNo=[t.ifNo]),t.notIf&&(t.notIf=n(t.notIf,{},e)),t.needs=function(t){const e=[];return t.forEach(t=>{e.push(Gn(t)),"and"===t.operator&&t.choices&&t.choices.forEach(t=>{t.forEach(t=>{e.push(Gn(t))})})}),e.filter(t=>t)}(t.regs);const{wants:o,count:r}=function(t){const e=[];let n=0;return t.forEach(t=>{"or"!==t.operator||t.optional||t.negative||(t.fastOr&&Array.from(t.fastOr).forEach(t=>{e.push(t)}),t.choices&&t.choices.forEach(t=>{t.forEach(t=>{const n=Gn(t);n&&e.push(n)})}),n+=1)}),{wants:e,count:n}}(t.regs);t.wants=o,t.minWant=r,t.minWords=t.regs.filter(t=>!t.optional).length}),t};var Mn={buildNet:function(t,e){t=Bn(t,e);const n={};t.forEach(t=>{t.needs.forEach(e=>{n[e]=Array.isArray(n[e])?n[e]:[],n[e].push(t)}),t.wants.forEach(e=>{n[e]=Array.isArray(n[e])?n[e]:[],n[e].push(t)})}),Object.keys(n).forEach(t=>{const e={};n[t]=n[t].filter(t=>"boolean"!=typeof e[t.match]&&(e[t.match]=!0,!0))});const o=t.filter(t=>0===t.needs.length&&0===t.wants.length);return{hooks:n,always:o}},bulkMatch:function(t,e,n,o={}){const r=n.one.cacheDoc(t);let s=function(t,e){return t.map((n,o)=>{let r=[];Object.keys(e).forEach(n=>{t[o].has(n)&&(r=r.concat(e[n]))});const s={};return r=r.filter(t=>"boolean"!=typeof s[t.match]&&(s[t.match]=!0,!0)),r})}(r,e.hooks);s=function(t,e){return t.map((t,n)=>{const o=e[n];return(t=(t=t.filter(t=>t.needs.every(t=>o.has(t)))).filter(t=>void 0===t.ifNo||!0!==t.ifNo.some(t=>o.has(t)))).filter(t=>0===t.wants.length||t.wants.filter(t=>o.has(t)).length>=t.minWant)})}(s,r),e.always.length>0&&(s=s.map(t=>t.concat(e.always))),s=function(t,e){return t.map((t,n)=>{const o=e[n].length;return t=t.filter(t=>o>=t.minWords),t})}(s,t);const i=function(t,e,n,o,r){const s=[];for(let n=0;n<t.length;n+=1)for(let i=0;i<t[n].length;i+=1){const c=t[n][i],u=o.one.match([e[n]],c);if(u.ptrs.length>0&&(u.ptrs.forEach(t=>{t[0]=n;const e=Object.assign({},c,{pointer:t});void 0!==c.unTag&&(e.unTag=c.unTag),s.push(e)}),!0===r.matchOne))return[s[0]]}return s}(s,t,0,n,o);return i},bulkTagger:function(t,e,n){const{model:o,methods:r}=n,{getDoc:s,setTag:i,unTag:c}=r.one,u=r.two.looksPlural;if(0===t.length)return t;return("undefined"!=typeof process&&process.env?process.env:self.env||{}).DEBUG_TAGS&&console.log(`\n\n [32m→ ${t.length} post-tagger:[0m`),t.map(t=>{if(!t.tag&&!t.chunk&&!t.unTag)return;const r=t.reason||t.match,a=s([t.pointer],e)[0];if(!0===t.safe){if(!1===function(t,e,n){const o=n.one.tagSet;if(!o.hasOwnProperty(e))return!0;const r=o[e].not||[];for(let e=0;e<t.length;e+=1){const n=t[e];for(let t=0;t<r.length;t+=1)if(!0===n.tags.has(r[t]))return!1}return!0}(a,t.tag,o))return;if("-"===a[a.length-1].post)return}if(void 0!==t.tag){if(i(a,t.tag,n,t.safe,`[post] '${r}'`),"Noun"===t.tag&&u){const e=a[a.length-1];u(e.text)?i([e],"Plural",n,t.safe,"quick-plural"):i([e],"Singular",n,t.safe,"quick-singular")}!0===t.freeze&&a.forEach(t=>t.frozen=!0)}void 0!==t.unTag&&c(a,t.unTag,n,t.safe,r),t.chunk&&a.forEach(e=>e.chunk=t.chunk)})}},Un={lib:{buildNet:function(t){const e=this.methods().one.buildNet(t,this.world());return e.isNet=!0,e}},api:function(t){t.prototype.sweep=function(t,e={}){const{world:n,docs:o}=this,{methods:r}=n;let s=r.one.bulkMatch(o,t,this.methods,e);!1!==e.tagger&&r.one.bulkTagger(s,o,this.world),s=s.map(t=>{const e=t.pointer,n=o[e[0]][e[1]],r=e[2]-e[1];return n.index&&(t.pointer=[n.index[0],n.index[1],e[1]+r]),t});const i=s.map(t=>t.pointer);return s=s.map(t=>(t.view=this.update([t.pointer]),delete t.regs,delete t.needs,delete t.pointer,delete t._expanded,t)),{view:this.update(i),found:s}}},methods:{one:Mn}};const Wn=/ /,In=function(t,e){"Noun"===e&&(t.chunk=e),"Verb"===e&&(t.chunk=e)},Rn=function(t,e,n,o){if(!0===t.tags.has(e))return null;if("."===e)return null;!0===t.frozen&&(o=!0);const r=n[e];if(r){if(r.not&&r.not.length>0)for(let e=0;e<r.not.length;e+=1){if(!0===o&&t.tags.has(r.not[e]))return null;t.tags.delete(r.not[e])}if(r.parents&&r.parents.length>0)for(let e=0;e<r.parents.length;e+=1)t.tags.add(r.parents[e]),In(t,r.parents[e])}return t.tags.add(e),t.dirty=!0,In(t,e),!0},Hn=function(t,e,n={},o,r){const s=n.model.one.tagSet||{};if(!e)return;const i="undefined"!=typeof process&&process.env?process.env:self.env||{};var c;if(i&&i.DEBUG_TAGS&&((t,e,n="")=>{const o=t.map(t=>t.text||"["+t.implicit+"]").join(" ");var r;"string"!=typeof e&&e.length>2&&(e=e.slice(0,2).join(", #")+" +"),e="string"!=typeof e?e.join(", #"):e,console.log(` ${(r=o,"[33m[3m"+r+"[0m").padEnd(24)} [32m→[0m #${e.padEnd(22)} ${(t=>"[3m"+t+"[0m")(n)}`)})(t,e,r),!0!=(c=e,"[object Array]"===Object.prototype.toString.call(c)))if("string"==typeof e)if(e=e.trim(),Wn.test(e))!function(t,e,n,o){const r=e.split(Wn);t.forEach((t,e)=>{let s=r[e];s&&(s=s.replace(/^#/,""),Rn(t,s,n,o))})}(t,e,s,o);else{e=e.replace(/^#/,"");for(let n=0;n<t.length;n+=1)Rn(t[n],e,s,o)}else console.warn(`compromise: Invalid tag '${e}'`);else e.forEach(e=>Hn(t,e,n,o))},Qn=function(t){return t.children=t.children||[],t._cache=t._cache||{},t.props=t.props||{},t._cache.parents=t._cache.parents||[],t._cache.children=t._cache.children||[],t},Zn=/^ *(#|\/\/)/,Kn=function(t){let e=t.trim().split(/->/),n=[];e.forEach(t=>{n=n.concat(function(t){if(!(t=t.trim()))return null;if(/^\[/.test(t)&&/\]$/.test(t)){let e=(t=(t=t.replace(/^\[/,"")).replace(/\]$/,"")).split(/,/);return e=e.map(t=>t.trim()).filter(t=>t),e=e.map(t=>Qn({id:t})),e}return[Qn({id:t})]}(t))}),n=n.filter(t=>t);let o=n[0];for(let t=1;t<n.length;t+=1)o.children.push(n[t]),o=n[t];return n[0]},Jn=(t,e)=>{let n=[],o=[t];for(;o.length>0;){let t=o.pop();n.push(t),t.children&&t.children.forEach(n=>{e&&e(t,n),o.push(n)})}return n},Xn=t=>"[object Array]"===Object.prototype.toString.call(t),Yn=t=>(t=t||"").trim(),to=function(t=[]){return"string"==typeof t?function(t){let e=t.split(/\r?\n/),n=[];e.forEach(t=>{if(!t.trim()||Zn.test(t))return;let e=(t=>{const e=/^( {2}|\t)/;let n=0;for(;e.test(t);)t=t.replace(e,""),n+=1;return n})(t);n.push({indent:e,node:Kn(t)})});let o=function(t){let e={children:[]};return t.forEach((n,o)=>{0===n.indent?e.children=e.children.concat(n.node):t[o-1]&&function(t,e){let n=t[e].indent;for(;e>=0;e-=1)if(t[e].indent<n)return t[e];return t[0]}(t,o).node.children.push(n.node)}),e}(n);return o=Qn(o),o}(t):Xn(t)?function(t){let e={};t.forEach(t=>{e[t.id]=t});let n=Qn({});return t.forEach(t=>{if((t=Qn(t)).parent)if(e.hasOwnProperty(t.parent)){let n=e[t.parent];delete t.parent,n.children.push(t)}else console.warn(`[Grad] - missing node '${t.parent}'`);else n.children.push(t)}),n}(t):(Jn(e=t).forEach(Qn),e);var e},eo=function(t,e){let n="-> ";e&&(n=(t=>"[2m"+t+"[0m")("→ "));let o="";return Jn(t).forEach((t,r)=>{let s=t.id||"";if(e&&(s=(t=>"[31m"+t+"[0m")(s)),0===r&&!t.id)return;let i=t._cache.parents.length;o+=" ".repeat(i)+n+s+"\n"}),o},no=function(t){let e=Jn(t);e.forEach(t=>{delete(t=Object.assign({},t)).children});let n=e[0];return n&&!n.id&&0===Object.keys(n.props).length&&e.shift(),e},oo={text:eo,txt:eo,array:no,flat:no},ro=function(t,e){return"nested"===e||"json"===e?t:"debug"===e?(console.log(eo(t,!0)),null):oo.hasOwnProperty(e)?oo[e](t):t},so=t=>{Jn(t,(t,e)=>{t.id&&(t._cache.parents=t._cache.parents||[],e._cache.parents=t._cache.parents.concat([t.id]))})},io=/\//;class g{constructor(t={}){Object.defineProperty(this,"json",{enumerable:!1,value:t,writable:!0})}get children(){return this.json.children}get id(){return this.json.id}get found(){return this.json.id||this.json.children.length>0}props(t={}){let e=this.json.props||{};return"string"==typeof t&&(e[t]=!0),this.json.props=Object.assign(e,t),this}get(t){if(t=Yn(t),!io.test(t)){let e=this.json.children.find(e=>e.id===t);return new g(e)}let e=((t,e)=>{let n=(t=>"string"!=typeof t?t:(t=t.replace(/^\//,"")).split(/\//))(e=e||"");for(let e=0;e<n.length;e+=1){let o=t.children.find(t=>t.id===n[e]);if(!o)return null;t=o}return t})(this.json,t)||Qn({});return new g(e)}add(t,e={}){if(Xn(t))return t.forEach(t=>this.add(Yn(t),e)),this;t=Yn(t);let n=Qn({id:t,props:e});return this.json.children.push(n),new g(n)}remove(t){return t=Yn(t),this.json.children=this.json.children.filter(e=>e.id!==t),this}nodes(){return Jn(this.json).map(t=>(delete(t=Object.assign({},t)).children,t))}cache(){return(t=>{let e=Jn(t,(t,e)=>{t.id&&(t._cache.parents=t._cache.parents||[],t._cache.children=t._cache.children||[],e._cache.parents=t._cache.parents.concat([t.id]))}),n={};e.forEach(t=>{t.id&&(n[t.id]=t)}),e.forEach(t=>{t._cache.parents.forEach(e=>{n.hasOwnProperty(e)&&n[e]._cache.children.push(t.id)})}),t._cache.children=Object.keys(n)})(this.json),this}list(){return Jn(this.json)}fillDown(){var t;return t=this.json,Jn(t,(t,e)=>{e.props=((t,e)=>(Object.keys(e).forEach(n=>{if(e[n]instanceof Set){let o=t[n]||new Set;t[n]=new Set([...o,...e[n]])}else if((t=>t&&"object"==typeof t&&!Array.isArray(t))(e[n])){let o=t[n]||{};t[n]=Object.assign({},e[n],o)}else Xn(e[n])?t[n]=e[n].concat(t[n]||[]):void 0===t[n]&&(t[n]=e[n])}),t))(e.props,t.props)}),this}depth(){so(this.json);let t=Jn(this.json),e=t.length>1?1:0;return t.forEach(t=>{if(0===t._cache.parents.length)return;let n=t._cache.parents.length+1;n>e&&(e=n)}),e}out(t){return so(this.json),ro(this.json,t)}debug(){return so(this.json),ro(this.json,"debug"),this}}const co=function(t){let e=to(t);return new g(e)};co.prototype.plugin=function(t){t(this)};const uo={Noun:"blue",Verb:"green",Negative:"green",Date:"red",Value:"red",Adjective:"magenta",Preposition:"cyan",Conjunction:"cyan",Determiner:"cyan",Hyphenated:"cyan",Adverb:"cyan"},ao=function(t){if(uo.hasOwnProperty(t.id))return uo[t.id];if(uo.hasOwnProperty(t.is))return uo[t.is];const e=t._cache.parents.find(t=>uo[t]);return uo[e]},lo=function(t){return t?"string"==typeof t?[t]:t:[]},ho=function(t,e){return t=function(t,e){return Object.keys(t).forEach(n=>{t[n].isA&&(t[n].is=t[n].isA),t[n].notA&&(t[n].not=t[n].notA),t[n].is&&"string"==typeof t[n].is&&(e.hasOwnProperty(t[n].is)||t.hasOwnProperty(t[n].is)||(t[t[n].is]={})),t[n].not&&"string"==typeof t[n].not&&!t.hasOwnProperty(t[n].not)&&(e.hasOwnProperty(t[n].not)||t.hasOwnProperty(t[n].not)||(t[t[n].not]={}))}),t}(t,e),Object.keys(t).forEach(e=>{t[e].children=lo(t[e].children),t[e].not=lo(t[e].not)}),Object.keys(t).forEach(e=>{(t[e].not||[]).forEach(n=>{t[n]&&t[n].not&&t[n].not.push(e)})}),t};var fo={one:{setTag:Hn,unTag:function(t,e,n){e=e.trim().replace(/^#/,"");for(let o=0;o<t.length;o+=1){const r=t[o];if(!0===r.frozen)continue;if("*"===e){r.tags.clear();continue}const s=n[e];if(s&&s.children.length>0)for(let t=0;t<s.children.length;t+=1)r.tags.delete(s.children[t]);r.tags.delete(e)}},addTags:function(t,e){Object.keys(e).length>0&&(t=function(t){return Object.keys(t).forEach(e=>{t[e]=Object.assign({},t[e]),t[e].novel=!0}),t}(t)),t=ho(t,e);const n=function(t){const e=Object.keys(t).map(e=>{const n=t[e],o={not:new Set(n.not),also:n.also,is:n.is,novel:n.novel};return{id:e,parent:n.is,props:o,children:[],alias:n.alias}});return co(e).cache().fillDown().out("array")}(Object.assign({},e,t)),o=function(t){const e={};return t.forEach(t=>{const{not:n,also:o,is:r,novel:s}=t.props;let i=t._cache.parents;o&&(i=i.concat(o)),e[t.id]={is:r,not:n,novel:s,also:o,parents:i,children:t._cache.children,color:ao(t),alias:t.alias}}),Object.keys(e).forEach(t=>{const n=new Set(e[t].not);e[t].not.forEach(t=>{e[t]&&e[t].children.forEach(t=>n.add(t))}),e[t].not=Array.from(n)}),e}(n);return o},canBe:function(t,e,n){if(!n.hasOwnProperty(e))return!0;const o=n[e].not||[];for(let e=0;e<o.length;e+=1)if(t.tags.has(o[e]))return!1;return!0}}};const po=function(t){return"[object Array]"===Object.prototype.toString.call(t)},mo={tag:function(t,e="",n){if(!this.found||!t)return this;const o=this.termList();if(0===o.length)return this;const{methods:r,verbose:s,world:i}=this;return!0===s&&console.log(" + ",t,e||""),po(t)?t.forEach(t=>r.one.setTag(o,t,i,n,e)):r.one.setTag(o,t,i,n,e),this.uncache(),this},tagSafe:function(t,e=""){return this.tag(t,e,!0)},unTag:function(t,e){if(!this.found||!t)return this;const n=this.termList();if(0===n.length)return this;const{methods:o,verbose:r,model:s}=this;!0===r&&console.log(" - ",t,e||"");const i=s.one.tagSet;return po(t)?t.forEach(t=>o.one.unTag(n,t,i)):o.one.unTag(n,t,i),this.uncache(),this},canBe:function(t){t=t.replace(/^#/,"");const e=this.model.one.tagSet,n=this.methods.one.canBe,o=[];this.document.forEach((r,s)=>{r.forEach((r,i)=>{n(r,t,e)||o.push([s,i,i+1])})});const r=this.update(o);return this.difference(r)}};var go={addTags:function(t){const{model:e,methods:n}=this.world(),o=e.one.tagSet,r=(0,n.one.addTags)(t,o);return e.one.tagSet=r,this}};const wo=new Set(["Auxiliary","Possessive"]);var yo={model:{one:{tagSet:{}}},compute:{tagRank:function(t){const{document:e,world:n}=t,o=n.model.one.tagSet;e.forEach(t=>{t.forEach(t=>{const e=Array.from(t.tags);t.tagRank=function(t,e){return t=t.sort((t,n)=>{if(wo.has(t)||!e.hasOwnProperty(n))return 1;if(wo.has(n)||!e.hasOwnProperty(t))return-1;let o=e[t].children||[];const r=o.length;return o=e[n].children||[],r-o.length}),t}(e,o)})})}},methods:fo,api:function(t){Object.assign(t.prototype,mo)},lib:go};const bo=/([.!?\u203D\u2E18\u203C\u2047-\u2049\u0964\u0965\u061F\u06D4\u0589\u1362\u1367\u104B\u17D4\u3002]+\s)/g,vo=/^[.!?\u203D\u2E18\u203C\u2047-\u2049\u0964\u0965\u061F\u06D4\u0589\u1362\u1367\u104B\u17D4\u3002]+\s$/,xo=/((?:\r?\n|\r)+)/,jo=/[\u3002\uFF01\uFF1F\uFF61]/,Eo="\\u3002\\uFF01\\uFF1F\\uFF61",Oo=".!?\\u203D\\u2E18\\u203C\\u2047-\\u2049।॥؟۔։።፧။។"+Eo,ko="\\u300D\\u300F\\uFF09\\u3011\\u3015\\u300B\\u3009\\u201D",Po=new RegExp(`([${Oo}]+\\s|[${Eo}]+(?![${ko}${Eo}])|[${Eo}]+[${ko}]+(?=[\\s\\u300C\\u300E\\uFF08\\u3010\\u3014\\u300A\\u3008\\u201C]|$))`,"g"),_o=new RegExp(`^(?:[${Oo}]+\\s|[${Eo}]+[${ko}]*)$`),So=/[\p{L}\p{N}\p{So}]/u,$o=/\S/,zo=function(t){return Boolean(t.match(/\n$/))},Ao={'"':'"',""":""","“":"”","‟":"”","„":"”","⹂":"”","‚":"’","«":"»","‹":"›","‵":"′","‶":"″","‷":"‴","〝":"〞","〟":"〞","「":"」","『":"』"},Co=RegExp("["+Object.keys(Ao).join("")+"]","g"),To=RegExp("["+Object.values(Ao).join("")+"]","g"),Fo=function(t){if(!t)return!1;const e=t.match(To);return null!==e&&1===e.length},Lo=/[(\uFF08]/g,No=/[)\uFF09]/g,Vo=/\S/,qo=/^\s+/,Do=function(t,e){const n=t.split(/[-–—]/);if(n.length<=1)return!1;const{prefixes:o,suffixes:r}=e.one;if(1===n[0].length&&/[a-z]/i.test(n[0]))return!1;if(o.hasOwnProperty(n[0]))return!1;if(n[1]=n[1].trim().replace(/[.?!]$/,""),r.hasOwnProperty(n[1]))return!1;if(!0===/^([a-z\u00C0-\u00FF`"'/]+)[-–—]([a-z0-9\u00C0-\u00FF].*)/i.test(t))return!0;return!0===/^[('"]?([0-9]{1,4})[-–—]([a-z\u00C0-\u00FF`"'/-]+[)'"]?$)/i.test(t)},Go=function(t){const e=[],n=t.split(/[-–—]/);let o="-";const r=t.match(/[-–—]/);r&&r[0]&&(o=r);for(let t=0;t<n.length;t++)t===n.length-1?e.push(n[t]):e.push(n[t]+o);return e},Bo=/\p{L} ?\/ ?\p{L}+$/u,Mo=/\S/,Uo=/^[!?.]+$/,Wo=/(\S+)/;let Io=[".","?","!",":",";","-","–","—","--","...","(",")","[","]",'"',"'","`","«","»","*","•"];Io=Io.reduce((t,e)=>(t[e]=!0,t),{});const Ro=/\p{Letter}/u,Ho=/[\p{Number}\p{Currency_Symbol}]/u,Qo=/^[a-z]\.([a-z]\.)+/i,Zo=/[sn]['’]$/,Ko=/^[(+\-]?\d+(th|st|nd|rd)?[)+\-]?$/,Jo=/([A-Z]\.)+[A-Z]?,?$/,Xo=/^[A-Z]\.,?$/,Yo=/[A-Z]{2,}('s|,)?$/,tr=/([a-z]\.)+[a-z]\.?$/,er=function(t){return function(t){return!0===Jo.test(t)||!0===tr.test(t)||!0===Xo.test(t)||!0===Yo.test(t)}(t)&&(t=t.replace(/\./g,"")),t},nr=function(t,e){const n=e.methods.one.killUnicode;let o=t.text||"";o=function(t){const e=t=(t=(t=t||"").toLowerCase()).trim();return t=(t=(t=t.replace(/[,;.!?]+$/,"")).replace(/\u2026/g,"...")).replace(/\u2013/g,"-"),!1===/^[:;]/.test(t)&&(t=(t=(t=t.replace(/\.{3,}$/g,"")).replace(/[",.!:;?)]+$/g,"")).replace(/^['"(]+/g,"")),""===(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"")).trim())&&(t=e),t.replace(/([0-9]),([0-9])/g,"$1$2")}(o),o=n(o,e),o=er(o),t.normal=o},or=/[ .][A-Z]\.? *$/i,rr=/(?:\u2026|\.{2,}) *$/,sr=/\p{L}/u,ir=/\. *$/,cr=/^[A-Z]\. $/;var ur={one:{killUnicode:function(t,e){const n=e.model.one.unicode||{},o=(t=t||"").split("");return o.forEach((t,e)=>{n[t]&&(o[e]=n[t])}),o.join("")},tokenize:{splitSentences:function(t,e){if(t=t||"",!(t=String(t))||"string"!=typeof t||!1===Vo.test(t))return[];const n=function(t){const e=[],n=jo.test(t),o=n?Po:bo,r=n?_o:vo,s=t.split(xo);for(let t=0;t<s.length;t++){const n=s[t].split(o);for(let t=0;t<n.length;t++)n[t+1]&&!0===r.test(n[t+1])&&(n[t]+=n[t+1],n[t+1]=""),""!==n[t]&&e.push(n[t])}return e}(t);let o=function(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n];if(void 0!==o&&""!==o){if(!1===$o.test(o)||!1===So.test(o)){if(e[e.length-1]){e[e.length-1]+=o;continue}if(t[n+1]){t[n+1]=o+t[n+1];continue}}e.push(o)}}return e}(n);if(o=function(t,e){const n=e.methods.one.tokenize.isSentence,o=e.model.one.abbreviations||new Set,r=[];for(let e=0;e<t.length;e++){const s=t[e];!t[e+1]||n(s,o)||zo(s)?s&&s.length>0&&(r.push(s),t[e]=""):t[e+1]=s+(t[e+1]||"")}return r}(o,e),o=function(t){const e=[];for(let n=0;n<t.length;n+=1){const o=t[n],r=o.match(Co);if(null!==r&&1===r.length){const s=o.match(To);if(null!==s&&s[0]!==r[0]){e.push(o);continue}if(Fo(t[n+1])&&t[n+1].length<280){t[n]+=t[n+1],e.push(t[n]),t[n+1]="",n+=1;continue}if(Fo(t[n+2])){const o=t[n+1]+t[n+2];if(o.length<280){t[n]+=o,e.push(t[n]),t[n+1]="",t[n+2]="",n+=2;continue}}}e.push(t[n])}return e}(o),o=function(t){const e=[];for(let n=0;n<t.length;n+=1){const o=t[n].match(Lo);null!==o&&1===o.length&&t[n+1]&&t[n+1].length<250&&null!==t[n+1].match(No)&&1===o.length&&!Lo.test(t[n+1])?(t[n]+=t[n+1],e.push(t[n]),t[n+1]="",n+=1):e.push(t[n])}return e}(o),0===o.length)return[t];for(let t=1;t<o.length;t+=1){const e=o[t].match(qo);null!==e&&(o[t-1]+=e[0],o[t]=o[t].replace(qo,""))}return o},isSentence:function(t,e){if(!1===sr.test(t))return!1;if(!0===or.test(t))return!1;if(3===t.length&&cr.test(t))return!1;if(!0===rr.test(t))return!1;const n=t.replace(/[.!?\u203D\u2E18\u203C\u2047-\u2049] *$/,"").split(" "),o=n[n.length-1].toLowerCase();return!0!==e.hasOwnProperty(o)||!0!==ir.test(t)},splitTerms:function(t,e){let n=[],o=[];if("number"==typeof(t=t||"")&&(t=String(t)),function(t){return"[object Array]"===Object.prototype.toString.call(t)}(t))return t;const r=t.split(Wo);for(let t=0;t<r.length;t++)!0!==Do(r[t],e)?o.push(r[t]):o=o.concat(Go(r[t]));let s="";for(let t=0;t<o.length;t++){const e=o[t];!0===Mo.test(e)&&!1===Io.hasOwnProperty(e)&&!1===Uo.test(e)?(n.length>0?(n[n.length-1]+=s,n.push(e)):n.push(s+e),s=""):s+=e}return s&&(0===n.length&&(n[0]=""),n[n.length-1]+=s),n=function(t){for(let e=1;e<t.length-1;e++)Bo.test(t[e])&&(t[e-1]+=t[e]+t[e+1],t[e]=null,t[e+1]=null);return t}(n),n=function(t){const e=/^[0-9]{1,4}(:[0-9][0-9])?([a-z]{1,2})? ?[-–—] ?$/,n=/^[0-9]{1,4}([a-z]{1,2})? ?$/;for(let o=0;o<t.length-1;o+=1)t[o+1]&&e.test(t[o])&&n.test(t[o+1])&&(t[o]=t[o]+t[o+1],t[o+1]=null);return t}(n),n=n.filter(t=>t),n},splitWhitespace:(t,e)=>{const{str:n,pre:o,post:r}=function(t,e){const{prePunctuation:n,postPunctuation:o,emoticons:r}=e.one;let s=t,i="",c="";const u=Array.from(t);if(r.hasOwnProperty(t.trim()))return{str:t.trim(),pre:i,post:" "};let a=u.length;for(let e=0;e<a;e+=1){const e=u[0];if(!0!==n[e]){if(("+"===e||"-"===e||"("===e)&&Ko.test(t.trim()))break;if("'"===e&&3===e.length&&Ho.test(u[1]))break;if(Ro.test(e)||Ho.test(e))break;i+=u.shift()}}a=u.length;for(let e=0;e<a;e+=1){const e=u[u.length-1];if(!0!==o[e]){if(Ro.test(e)||Ho.test(e))break;if(!("."===e&&!0===Qo.test(s)||"'"===e&&!0===Zo.test(s))){if(("+"===e||")"===e)&&Ko.test(t.trim()))break;c=u.pop()+c}}}return""===(t=u.join(""))&&(s=s.replace(/ *$/,t=>(c=t||"","")),t=s,i=""),{str:t,pre:i,post:c}}(t,e);return{text:n,pre:o,post:r,tags:new Set}},fromString:function(t,e){const{methods:n,model:o}=e,{splitSentences:r,splitTerms:s,splitWhitespace:i}=n.one.tokenize;return t=r(t=t||"",e).map(t=>{let n=s(t,o);return n=n.map(t=>i(t,o)),n.forEach(t=>{nr(t,e)}),n}),t}}}};const ar={},lr={};[[["approx","apt","bc","cyn","eg","esp","est","etc","ex","exp","prob","pron","gal","min","pseud","fig","jd","lat","lng","vol","fm","def","misc","plz","ea","ps","sec","pt","pref","pl","pp","qt","fr","sq","nee","ss","tel","temp","vet","ver","fem","masc","eng","adj","vb","rb","inf","situ","vivo","vitro","wr"]],[["dl","ml","gal","qt","pt","tbl","tsp","tbsp","km","dm","cm","mm","mi","td","hr","hrs","kg","hg","dg","cg","mg","µg","lb","oz","sq ft","hz","mps","mph","kmph","kb","mb","tb","lx","lm","fl oz","yb"],"Unit"],[["ad","al","arc","ba","bl","ca","cca","col","corp","ft","fy","ie","lit","ma","md","pd","tce"],"Noun"],[["adj","adm","adv","asst","atty","bldg","brig","capt","cmdr","comdr","cpl","det","dr","esq","gen","gov","hon","jr","llb","lt","maj","messrs","mlle","mme","mr","mrs","ms","mstr","phd","prof","pvt","rep","reps","res","rev","sen","sens","sfc","sgt","sir","sr","supt","surg"],"Honorific"],[["jan","feb","mar","apr","jun","jul","aug","sep","sept","oct","nov","dec"],"Month"],[["dept","univ","assn","bros","inc","ltd","co"],"Organization"],[["rd","st","dist","mt","ave","blvd","cl","cres","hwy","ariz","cal","calif","colo","conn","fla","fl","ga","ida","ia","kan","kans","minn","neb","nebr","okla","penna","penn","pa","dak","tenn","tex","ut","vt","va","wis","wisc","wy","wyo","usafa","alta","ont","que","sask"],"Place"]].forEach(t=>{t[0].forEach(e=>{ar[e]=!0,lr[e]="Abbreviation",void 0!==t[1]&&(lr[e]=[lr[e],t[1]])})});var hr=["anti","bi","co","contra","de","extra","infra","inter","intra","macro","micro","mis","mono","multi","peri","pre","pro","proto","pseudo","re","sub","supra","trans","tri","un","out","ex"].reduce((t,e)=>(t[e]=!0,t),{});const fr={"!":"¡","?":"¿Ɂ",'"':'“”"❝❞',"'":"‘‛❛❜’","-":"—–",a:"ªÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻȀȁȂȃȦȧȺΆΑΔΛάαλАаѦѧӐӑӒӓƛæ",b:"ßþƀƁƂƃƄƅɃΒβϐϦБВЪЬвъьѢѣҌҍ",c:"¢©ÇçĆćĈĉĊċČčƆƇƈȻȼͻͼϲϹϽϾСсєҀҁҪҫ",d:"ÐĎďĐđƉƊȡƋƌ",e:"ÈÉÊËèéêëĒēĔĕĖėĘęĚěƐȄȅȆȇȨȩɆɇΈΕΞΣέεξϵЀЁЕеѐёҼҽҾҿӖӗễ",f:"ƑƒϜϝӺӻҒғſ",g:"ĜĝĞğĠġĢģƓǤǥǦǧǴǵ",h:"ĤĥĦħƕǶȞȟΉΗЂЊЋНнђћҢңҤҥҺһӉӊ",I:"ÌÍÎÏ",i:"ìíîïĨĩĪīĬĭĮįİıƖƗȈȉȊȋΊΐΪίιϊІЇіїi̇",j:"ĴĵǰȷɈɉϳЈј",k:"ĶķĸƘƙǨǩΚκЌЖКжкќҚқҜҝҞҟҠҡ",l:"ĹĺĻļĽľĿŀŁłƚƪǀǏǐȴȽΙӀӏ",m:"ΜϺϻМмӍӎ",n:"ÑñŃńŅņŇňʼnŊŋƝƞǸǹȠȵΝΠήηϞЍИЙЛПийлпѝҊҋӅӆӢӣӤӥπ",o:"ÒÓÔÕÖØðòóôõöøŌōŎŏŐőƟƠơǑǒǪǫǬǭǾǿȌȍȎȏȪȫȬȭȮȯȰȱΌΘΟθοσόϕϘϙϬϴОФоѲѳӦӧӨөӪӫ",p:"ƤΡρϷϸϼРрҎҏÞ",q:"Ɋɋ",r:"ŔŕŖŗŘřƦȐȑȒȓɌɍЃГЯгяѓҐґ",s:"ŚśŜŝŞşŠšƧƨȘșȿЅѕ",t:"ŢţŤťŦŧƫƬƭƮȚțȶȾΓΤτϮТт",u:"ÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưƱƲǓǔǕǖǗǘǙǚǛǜȔȕȖȗɄΰυϋύ",v:"νѴѵѶѷ",w:"ŴŵƜωώϖϢϣШЩшщѡѿ",x:"×ΧχϗϰХхҲҳӼӽӾӿ",y:"ÝýÿŶŷŸƳƴȲȳɎɏΎΥΫγψϒϓϔЎУучўѰѱҮүҰұӮӯӰӱӲӳ",z:"ŹźŻżŽžƵƶȤȥɀΖ"},pr={};Object.keys(fr).forEach(function(t){fr[t].split("").forEach(function(e){pr[e]=t})});for(let t=33;t<=126;t+=1)pr[String.fromCharCode(t+65248)]=String.fromCharCode(t);const dr=/\//,mr=/[a-z]\.[a-z]/i,gr=/[0-9]/,wr=function(t,e){const n=t.normal||t.text||t.machine,o=e.model.one.aliases;if(o.hasOwnProperty(n)&&(t.alias=t.alias||[],t.alias.push(o[n])),dr.test(n)&&!mr.test(n)&&!gr.test(n)){const e=n.split(dr);e.length<=3&&e.forEach(e=>{""!==(e=e.trim())&&(t.alias=t.alias||[],t.alias.push(e))})}return t},yr=/^\p{Letter}+-\p{Letter}+$/u,br=function(t){let e=t.implicit||t.normal||t.text;e=e.replace(/['’]s$/,""),e=e.replace(/s['’]$/,"s"),e=e.replace(/([aeiou][ktrp])in'$/,"$1ing"),yr.test(e)&&(e=e.replace(/-/g,"")),e=e.replace(/^[#@]/,""),e!==t.normal&&(t.machine=e)},vr=function(t,e){const n=t.docs;for(let o=0;o<n.length;o+=1)for(let r=0;r<n[o].length;r+=1)e(n[o][r],t.world)},xr={alias:t=>vr(t,wr),machine:t=>vr(t,br),normal:t=>vr(t,nr),freq:function(t){const e=t.docs,n={};for(let t=0;t<e.length;t+=1)for(let o=0;o<e[t].length;o+=1){const r=e[t][o],s=r.machine||r.normal;n[s]=n[s]||0,n[s]+=1}for(let t=0;t<e.length;t+=1)for(let o=0;o<e[t].length;o+=1){const r=e[t][o],s=r.machine||r.normal;r.freq=n[s]}},offset:function(t){let e=0,n=0;const o=t.document;for(let t=0;t<o.length;t+=1)for(let r=0;r<o[t].length;r+=1){const s=o[t][r];s.offset={index:n,start:e+s.pre.length,length:s.text.length},e+=s.pre.length+s.text.length+s.post.length,n+=1}},index:function(t){const e=t.document;for(let t=0;t<e.length;t+=1)for(let n=0;n<e[t].length;n+=1)e[t][n].index=[t,n]},wordCount:function(t){let e=0;const n=t.docs;for(let t=0;t<n.length;t+=1)for(let o=0;o<n[t].length;o+=1)""!==n[t][o].normal&&(e+=1,n[t][o].wordCount=e)}};var jr={compute:xr,methods:ur,model:{one:{aliases:{"&":"and","@":"at","%":"percent",plz:"please",bein:"being"},abbreviations:ar,prefixes:hr,suffixes:{like:!0,ish:!0,less:!0,able:!0,elect:!0,type:!0,designate:!0},prePunctuation:{"#":!0,"@":!0,_:!0,"°":!0,"":!0,"":!0,"":!0,"\ufeff":!0},postPunctuation:{"%":!0,_:!0,"°":!0,"":!0,"":!0,"":!0,"\ufeff":!0},lexicon:lr,unicode:pr,emoticons:{"<3":!0,"</3":!0,"<\\3":!0,":^P":!0,":^p":!0,":^O":!0,":^3":!0}}},hooks:["alias","machine","index","id"]};var Er={typeahead:function(t){const e=t.model.one.typeahead,n=t.docs;if(0===n.length||0===Object.keys(e).length)return;const o=n[n.length-1]||[],r=o[o.length-1];if(!r.post&&e.hasOwnProperty(r.normal)){const n=e[r.normal];r.implicit=n,r.machine=n,r.typeahead=!0,t.compute.preTagger&&t.last().unTag("*").compute(["lexicon","preTagger"])}}};const Or=function(){const t=this.docs;if(0===t.length)return this;const e=t[t.length-1]||[],n=e[e.length-1];return!0===n.typeahead&&n.machine&&(n.text=n.machine,n.normal=n.machine),this},kr={safe:!0,min:3};var Pr={typeahead:function(t=[],e={}){const n=this.model();var o;e=Object.assign({},kr,e),o=t,"[object Object]"===Object.prototype.toString.call(o)&&(Object.assign(n.one.lexicon,t),t=Object.keys(t));const r=function(t,e,n){let o={};const r=[],s=n.prefixes||{};return t.forEach(t=>{let i=(t=t.toLowerCase().trim()).length;e.max&&i>e.max&&(i=e.max);for(let c=e.min;c<i;c+=1){const i=t.substring(0,c);e.safe&&n.model.one.lexicon.hasOwnProperty(i)||(!0!==s.hasOwnProperty(i)&&!0!==o.hasOwnProperty(i)?o[i]=t:r.push(i))}}),o=Object.assign({},s,o),r.forEach(t=>{delete o[t]}),o}(t,e,this.world());return Object.keys(r).forEach(t=>{n.one.typeahead.hasOwnProperty(t)?delete n.one.typeahead[t]:n.one.typeahead[t]=r[t]}),this}};var _r={model:{one:{typeahead:{}}},api:function(t){t.prototype.autoFill=Or},lib:Pr,compute:Er,hooks:["typeahead"]};return f.extend(I),f.extend($n),f.extend(He),f.extend(Dn),f.extend(yo),f.plugin(vt),f.extend(jr),f.extend(kt),f.plugin(m),f.extend(Dt),f.extend(_r),f.extend(Tt),f.extend(Un),f});