12 lines
64 KiB
JavaScript
12 lines
64 KiB
JavaScript
/*!
|
|
* Tiny Advanced Typography plugin
|
|
*
|
|
* Copyright (c) 2023 Ephox Corporation DBA Tiny Technologies, Inc.
|
|
* Licensed under the Tiny commercial license. See https://www.tiny.cloud/legal/
|
|
*
|
|
* Version: 1.1.2-44
|
|
*/
|
|
|
|
!function(){"use strict";const e=e=>parseInt(e,10),t=(e,t)=>{const n=e-t;return 0===n?0:n>0?1:-1},n=(e,t,n)=>({major:e,minor:t,patch:n}),r=t=>{const r=/([0-9]+)\.([0-9]+)\.([0-9]+)(?:(\-.+)?)/.exec(t);return r?n(e(r[1]),e(r[2]),e(r[3])):n(0,0,0)},a=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(n=r=e,(a=String).prototype.isPrototypeOf(n)||(null===(o=r.constructor)||void 0===o?void 0:o.name)===a.name)?"string":t;var n,r,a,o})(t)===e,o=a("string"),i=a("array"),s=(null,e=>null===e);const u=e=>!(e=>null==e)(e),c=e=>"function"==typeof e,l=e=>()=>e;function p(e,...t){return(...n)=>{const r=t.concat(n);return e.apply(null,r)}}const g=l(!1);class h{constructor(e,t){this.tag=e,this.value=t}static some(e){return new h(!0,e)}static none(){return h.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?h.some(e(this.value)):h.none()}bind(e){return this.tag?e(this.value):h.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:h.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return u(e)?h.some(e):h.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}h.singletonNone=new h(!1);const f=Array.prototype.indexOf,d=(e,t)=>((e,t)=>f.call(e,t))(e,t)>-1,m=(e,t)=>{for(let n=0,r=e.length;n<r;n++)if(t(e[n],n))return!0;return!1},v=(e,t)=>{const n=e.length,r=new Array(n);for(let a=0;a<n;a++){const n=e[a];r[a]=t(n,a)}return r},y=(e,t)=>{for(let n=0,r=e.length;n<r;n++)t(e[n],n)},b=(e,t)=>{const n=[];for(let r=0,a=e.length;r<a;r++){const a=e[r];t(a,r)&&n.push(a)}return n},$=Object.keys,x=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},R=x;"undefined"!=typeof window?window:Function("return this;")();const E=e=>t=>(e=>e.dom.nodeType)(t)===e,w=E(3),q=E(9),k=E(11),A=(e,t)=>{const n=e.dom;if(1!==n.nodeType)return!1;{const e=n;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},S=(e,t)=>e.dom===t.dom,T=c(Element.prototype.attachShadow)&&c(Node.prototype.getRootNode)?e=>R(e.dom.getRootNode()):e=>q(e)?e:R(e.dom.ownerDocument),B=e=>R(e.dom.host),L=e=>{const t=w(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const n=t.ownerDocument;return(e=>{const t=T(e);return k(n=t)&&u(n.dom.host)?h.some(t):h.none();var n})(R(t)).fold((()=>n.body.contains(t)),(r=L,a=B,e=>r(a(e))));var r,a},C=(e,t,n)=>((e,n,r)=>{let a=e.dom;const o=c(r)?r:g;for(;a.parentNode;){a=a.parentNode;const e=R(a);if(A(e,t))return h.some(e);if(o(e))break}return h.none()})(e,0,n),D=(e,t,n)=>((e,t,n,r,a)=>e(n,r)?h.some(n):c(a)&&a(n)?h.none():t(n,r,a))(((e,t)=>A(e,t)),C,e,t,n),I=e=>e.dom.contentEditable,N=(e,t)=>{let n=[];return y(v(e.dom.childNodes,R),(e=>{t(e)&&(n=n.concat([e])),n=n.concat(N(e,t))})),n},O=((e,t)=>{const n=t=>e(t)?h.from(t.dom.nodeValue):h.none();return{get:t=>{if(!e(t))throw new Error("Can only get text value of a text node");return n(t).getOr("")},getOption:n,set:(t,n)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=n}}})(w),z=e=>O.get(e),M=(e,t)=>O.set(e,t),P=e=>e.dom.textContent,j=e=>t=>t.options.get(e),U=e=>t=>h.from(t.options.get(e)),_={et:"Estonian",eo:"Esperanto","en-US":"English (US)","en-GB":"English (UK)",bg:"Bulgarian",be:"Belarusian",ca:"Catalan",cs:"Czech",ga:"Irish",da:"Danish",nl:"Dutch",fi:"Finnish",de:"German",el:"Greek",hu:"Hungarian",it:"Italian",lv:"Latvian",no:"Norwegian",pl:"Polish",ro:"Romanian",ru:"Russian",sk:"Slovak",sl:"Slovenian",sr:"Servian",es:"Spanish",sv:"Swedish",tr:"Turkish",uk:"Ukraninan"},F=$(_),Q="en-US",H=e=>e in _,G=e=>i(e)?{value:e.filter((e=>o(e)&&H(e))),valid:!0}:{valid:!1,message:"Must be an array of strings."},W=U("typography_rules"),V=j("typography_langs"),X=U("typography_ignore"),K=j("typography_default_lang"),Y="tinymce-typography-lang",Z=e=>{const t=h.from(tinymce.util.LocalStorage.getItem(Y)).getOr(K(e));return((e,t)=>!!H(t)&&V(e).includes(t))(e,t)?t:Q},J=(e,t)=>{const n=R(e.getBody()),r=e=>S(e,n),a=D(t,"[lang]",r).filter((o=r,e=>!o(e))).bind((e=>{return t=e,"lang",h.from(((e,t)=>{const n=e.dom.getAttribute(t);return null===n?void 0:n})(t,"lang"));var t})).getOr(Z(e));var o;return H(a)?a:Q};
|
|
/*! typograf | © 2023 Denis Seleznev | MIT License | https://github.com/typograf/typograf */
|
|
var ee=function(){return ee=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},ee.apply(this,arguments)};function te(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}var ne=[["iexcl",161],["cent",162],["pound",163],["curren",164],["yen",165],["brvbar",166],["sect",167],["uml",168],["copy",169],["ordf",170],["laquo",171],["not",172],["reg",174],["macr",175],["deg",176],["plusmn",177],["sup2",178],["sup3",179],["acute",180],["micro",181],["para",182],["middot",183],["cedil",184],["sup1",185],["ordm",186],["raquo",187],["frac14",188],["frac12",189],["frac34",190],["iquest",191],["Agrave",192],["Aacute",193],["Acirc",194],["Atilde",195],["Auml",196],["Aring",197],["AElig",198],["Ccedil",199],["Egrave",200],["Eacute",201],["Ecirc",202],["Euml",203],["Igrave",204],["Iacute",205],["Icirc",206],["Iuml",207],["ETH",208],["Ntilde",209],["Ograve",210],["Oacute",211],["Ocirc",212],["Otilde",213],["Ouml",214],["times",215],["Oslash",216],["Ugrave",217],["Uacute",218],["Ucirc",219],["Uuml",220],["Yacute",221],["THORN",222],["szlig",223],["agrave",224],["aacute",225],["acirc",226],["atilde",227],["auml",228],["aring",229],["aelig",230],["ccedil",231],["egrave",232],["eacute",233],["ecirc",234],["euml",235],["igrave",236],["iacute",237],["icirc",238],["iuml",239],["eth",240],["ntilde",241],["ograve",242],["oacute",243],["ocirc",244],["otilde",245],["ouml",246],["divide",247],["oslash",248],["ugrave",249],["uacute",250],["ucirc",251],["uuml",252],["yacute",253],["thorn",254],["yuml",255],["fnof",402],["Alpha",913],["Beta",914],["Gamma",915],["Delta",916],["Epsilon",917],["Zeta",918],["Eta",919],["Theta",920],["Iota",921],["Kappa",922],["Lambda",923],["Mu",924],["Nu",925],["Xi",926],["Omicron",927],["Pi",928],["Rho",929],["Sigma",931],["Tau",932],["Upsilon",933],["Phi",934],["Chi",935],["Psi",936],["Omega",937],["alpha",945],["beta",946],["gamma",947],["delta",948],["epsilon",949],["zeta",950],["eta",951],["theta",952],["iota",953],["kappa",954],["lambda",955],["mu",956],["nu",957],["xi",958],["omicron",959],["pi",960],["rho",961],["sigmaf",962],["sigma",963],["tau",964],["upsilon",965],["phi",966],["chi",967],["psi",968],["omega",969],["thetasym",977],["upsih",978],["piv",982],["bull",8226],["hellip",8230],["prime",8242],["Prime",8243],["oline",8254],["frasl",8260],["weierp",8472],["image",8465],["real",8476],["trade",8482],["alefsym",8501],["larr",8592],["uarr",8593],["rarr",8594],["darr",8595],["harr",8596],["crarr",8629],["lArr",8656],["uArr",8657],["rArr",8658],["dArr",8659],["hArr",8660],["forall",8704],["part",8706],["exist",8707],["empty",8709],["nabla",8711],["isin",8712],["notin",8713],["ni",8715],["prod",8719],["sum",8721],["minus",8722],["lowast",8727],["radic",8730],["prop",8733],["infin",8734],["ang",8736],["and",8743],["or",8744],["cap",8745],["cup",8746],["int",8747],["there4",8756],["sim",8764],["cong",8773],["asymp",8776],["ne",8800],["equiv",8801],["le",8804],["ge",8805],["sub",8834],["sup",8835],["nsub",8836],["sube",8838],["supe",8839],["oplus",8853],["otimes",8855],["perp",8869],["sdot",8901],["lceil",8968],["rceil",8969],["lfloor",8970],["rfloor",8971],["lang",9001],["rang",9002],["spades",9824],["clubs",9827],["hearts",9829],["diams",9830],["loz",9674],["OElig",338],["oelig",339],["Scaron",352],["scaron",353],["Yuml",376],["circ",710],["tilde",732],["ndash",8211],["mdash",8212],["lsquo",8216],["rsquo",8217],["sbquo",8218],["ldquo",8220],["rdquo",8221],["bdquo",8222],["dagger",8224],["Dagger",8225],["permil",8240],["lsaquo",8249],["rsaquo",8250],["euro",8364],["NestedGreaterGreater",8811],["NestedLessLess",8810]],re=[["nbsp",160],["thinsp",8201],["ensp",8194],["emsp",8195],["shy",173],["zwnj",8204],["zwj",8205],["lrm",8206],["rlm",8207]],ae=function(){function e(){var e=this;this.entities=this.prepareEntities(te(te([],ne,!0),re,!0)),this.entitiesByName={},this.entitiesByNameEntity={},this.entitiesByDigitEntity={},this.entitiesByUtf={},this.entities.forEach((function(t){e.entitiesByName[t.name]=t,e.entitiesByNameEntity[t.nameEntity]=t,e.entitiesByDigitEntity[t.digitEntity]=t,e.entitiesByUtf[t.utf]=t})),this.invisibleEntities=this.prepareEntities(re)}return e.prototype.toUtf=function(e){var t=this;-1!==e.text.search(/&#/)&&(e.text=this.decHexToUtf(e.text)),-1!==e.text.search(/&[a-z]/i)&&(e.text=e.text.replace(/&[a-z\d]{2,31};/gi,(function(e){var n=t.entitiesByNameEntity[e];return n?n.utf:e})))},e.prototype.decHexToUtf=function(e){return e.replace(/&#(\d{1,6});/gi,(function(e,t){return String.fromCharCode(parseInt(t,10))})).replace(/&#x([\da-f]{1,6});/gi,(function(e,t){return String.fromCharCode(parseInt(t,16))}))},e.prototype.restore=function(e){var t=e.prefs.htmlEntity,n=t.type,r=this.entities;if("name"===n||"digit"===n){(t.onlyInvisible||t.list)&&(r=[],t.onlyInvisible&&(r=r.concat(this.invisibleEntities)),t.list&&(r=r.concat(this.prepareListParam(t.list))));var a="name"===n?"nameEntity":"digitEntity";e.text=this.restoreEntitiesByIndex(e.text,a,r)}},e.prototype.getByUtf=function(e,t){var n;switch(t){case"digit":n=this.entitiesByDigitEntity[e];break;case"name":n=this.entitiesByNameEntity[e];break;default:n=e}return n},e.prototype.prepareEntities=function(e){var t=[];return e.forEach((function(e){var n=e[0],r=e[1],a=String.fromCharCode(r);t.push({name:n,nameEntity:"&"+n+";",digitEntity:"&#"+r+";",utf:a,reName:new RegExp("&"+n+";","g"),reUtf:new RegExp(a,"g")})})),t},e.prototype.prepareListParam=function(e){var t=this,n=[];return e.forEach((function(e){var r=t.entitiesByName[e];r&&n.push(r)})),n},e.prototype.restoreEntitiesByIndex=function(e,t,n){return n.forEach((function(n){e=e.replace(n.reUtf,n[t])})),e},e}(),oe=new ae,ie=[];function se(e){var t=(e||"").split("/")[0];t&&"common"!==t&&!ce(t)&&(ie.push(t),ie.sort())}function ue(){return ie}function ce(e){return"common"===e||-1!==ie.indexOf(e)}function le(e,t){var n=e||t;return n?Array.isArray(n)?n:[n]:[]}function pe(e){if(!e.length)throw Error('Not defined the property "locale".');e.forEach((function(e){if(!ce(e))throw Error('"'.concat(e,'" is not supported locale.'))}))}var ge={};function he(e){return ge[e]}function fe(e){Object.keys(e).forEach((function(t){se(t),ge[t]=e[t]}))}var de=["a","abbr","acronym","b","bdo","big","br","button","cite","code","dfn","em","i","img","input","kbd","label","map","object","q","samp","script","select","small","span","strong","sub","sup","textarea","time","tt","var"],me=new RegExp("(https?|file|ftp)://([a-zA-Z0-9/+-=%&:_.~?]+[a-zA-Z0-9#+]*)","g"),ve="\\d+([.,]\\d+)?",ye=/\d/;function be(e){return e.search(ye)>-1}var $e="\uf000",xe="\uf001",Re=function(){function e(){this.groups=["own","html","url"],this.hidden={},this.counter=0;var e=[["\x3c!--","--\x3e"],["<!ENTITY",">"],["<!DOCTYPE",">"],["<\\?xml","\\?>"],["<!\\[CDATA\\[","\\]\\]>"]];["code","kbd","object","pre","samp","script","style","var"].forEach((function(t){e.push(["<".concat(t,"(\\s[^>]*?)?>"),"</".concat(t,">")])})),this.tags={own:[],html:e.map(this.prepareRegExp),url:[me]}}return e.prototype.add=function(e){this.tags.own.push(this.prepareRegExp(e))},e.prototype.show=function(e,t){for(var n=new RegExp("\uf000tf\\d+\uf000","g"),r=new RegExp("\uf000tf\\d"),a=function(n){return e.safeTags.hidden[t][n]||n},o=0,i=this.tags[t].length;o<i&&(e.text=e.text.replace(n,a),-1!==e.text.search(r));o++);},e.prototype.hide=function(e,t){var n=this;e.safeTags.hidden[t]={};var r=this.pasteLabel.bind(this,e,t);this.tags[t].forEach((function(t){e.text=e.text.replace(n.prepareRegExp(t),r)}))},e.prototype.hideHTMLTags=function(e){if(e.isHTML){var t=this.pasteLabel.bind(this,e,"html");e.text=e.text.replace(/<\/?[a-z][^]*?>/gi,t).replace(/<\/?[a-z][^]*?>/gi,t).replace(/&[gl]t;/gi,t)}},e.prototype.getPrevLabel=function(e,t){for(var n=t-1;n>=0;n--)if(e[n]===$e)return e.slice(n,t+1);return""},e.prototype.getNextLabel=function(e,t){for(var n=t+1;n<e.length;n++)if(e[n]===$e)return e.slice(t,n+1);return""},e.prototype.getTagByLabel=function(e,t){var n=null;return this.groups.some((function(r){var a=e.safeTags.hidden[r][t];return void 0!==a&&(n={group:r,value:a}),n})),n},e.prototype.getTagInfo=function(e){if(!e)return null;var t={group:e.group};switch(e.group){case"html":t.name=e.value.split(/[<\s>]/)[1],t.isInline=de.indexOf(t.name)>-1,t.isClosing=e.value.search(/^<\//)>-1;break;case"url":t.isInline=!0;break;case"own":t.isInline=!1}return t},e.prototype.pasteLabel=function(e,t,n){var r=e.safeTags,a="\uf000tf"+r.counter+$e;return r.hidden[t][a]=n,r.counter++,a},e.prototype.prepareRegExp=function(e){if(e instanceof RegExp)return e;var t=e[0],n=e[1],r=e[2];return new RegExp(t+(void 0===r?"[^]*?":r)+n,"gi")},e.prototype.getPrevTagInfo=function(e,t,n){var r=this.getPrevLabel(t,n-1);if(r){var a=this.getTagByLabel(e,r);if(a)return this.getTagInfo(a)}return null},e.prototype.getNextTagInfo=function(e,t,n){var r=this.getNextLabel(t,n+1);if(r){var a=this.getTagByLabel(e,r);if(a)return this.getTagInfo(a)}return null},e}();function Ee(e,t){for(var n="";1==(1&t)&&(n+=e),0!=(t>>>=1);)e+=e;return n}function we(e){return e.replace(/\u00A0/g," ")}function qe(e,t){for(var n=0;n<t.length;n++)e=e.replace(t[n][0],t[n][1]);return e}function ke(e){return-1!==e.search(/(<\/?[a-z]|<!|&[lg]t;)/i)}function Ae(e){return"object"==typeof e?JSON.parse(JSON.stringify(e)):e}var Se={symbols:110,number:150,space:210,dash:310,punctuation:410,nbsp:510,money:710,date:810,other:910,optalign:1010,typo:1110,html:1210},Te=0,Be="default",Le=[],Ce=[];function De(){var e=te([],Le,!0);return function(e){e.sort((function(e,t){return e.index>t.index?1:-1}))}(e),e}function Ie(){return te([],Ce,!0)}function Ne(e){if("number"==typeof e.index)return e.index;var t=e.name.split("/")[1],n=Se[t];return void 0===n&&(n=Te),"string"==typeof e.index?n+parseInt(e.index,10):n}function Oe(e){var t=e.name.split("/"),n=t[0],r=t[1],a=t[2];return{name:e.name,shortName:a,handler:e.handler,queue:e.queue||Be,enabled:!0!==e.disabled,locale:n,group:r,index:Ne(e),settings:e.settings,live:e.live,htmlAttrs:e.htmlAttrs}}function ze(e){return{type:(null==e?void 0:e.type)||"default",list:null==e?void 0:e.list,onlyInvisible:Boolean(null==e?void 0:e.onlyInvisible)}}function Me(e){return e||"LF"}var Pe=function(){function e(e){var t=this;this.rules=[],this.innerRules=[],this.rulesByQueues={},this.innerRulesByQueues={},this.separatePartsTags=["title","p","h[1-6]","select","legend"],this.prefs=function(e){return{locale:le(e.locale),lineEnding:Me(e.lineEnding),live:Boolean(e.live),ruleFilter:e.ruleFilter,enableRule:e.enableRule,disableRule:e.disableRule,processingSeparateParts:e.processingSeparateParts,htmlEntity:ze(e.htmlEntity)}}(e),pe(this.prefs.locale),this.safeTags=new Re,this.settings={},this.enabledRules={},this.innerRulesByQueues={},this.innerRules=Ie(),this.innerRules.forEach((function(e){t.innerRulesByQueues[e.queue]=t.innerRulesByQueues[e.queue]||[],t.innerRulesByQueues[e.queue].push(e)})),this.rulesByQueues={},this.rules=De(),this.rules.forEach((function(e){t.prepareRuleSettings(e),t.rulesByQueues[e.queue]=t.rulesByQueues[e.queue]||[],t.rulesByQueues[e.queue].push(e)})),this.prefs.disableRule&&this.disableRule(this.prefs.disableRule),this.prefs.enableRule&&this.enableRule(this.prefs.enableRule)}return e.addRule=function(e){!function(e){var t=Oe(e);se(t.locale),Le.push(t)}(e)},e.addRules=function(e){var t=this;e.forEach((function(e){t.addRule(e)}))},e.addInnerRule=function(e){!function(e){Ce.push(Oe(e))}(e)},e.addInnerRules=function(e){var t=this;e.forEach((function(e){t.addInnerRule(e)}))},e.getRule=function(e){var t=null;return De().some((function(n){return n.name===e&&(t=n,!0)})),t},e.getRules=function(){return De()},e.getInnerRules=function(){return Ie()},e.getLocales=function(){return ue()},e.addLocale=function(e){se(e)},e.hasLocale=function(e){return ce(e)},e.setData=function(e){fe(e)},e.getData=function(e){return he(e)},e.prototype.execute=function(e,t){if(!(e=""+e))return"";var n=function(e,t){var n=ee({},e);return t?("locale"in t&&(n.locale=le(t.locale)),"htmlEntity"in t&&(n.htmlEntity=ze(t.htmlEntity)),"lineEnding"in t&&(n.lineEnding=Me(t.lineEnding)),"processingSeparateParts"in t&&(n.processingSeparateParts=t.processingSeparateParts),"ruleFilter"in t&&(n.ruleFilter=t.ruleFilter),n):n}(this.prefs,t);pe(n.locale);var r=this.prepareContext(e,n);return this.process(r)},e.prototype.getSetting=function(e,t){return this.settings[e]&&this.settings[e][t]},e.prototype.setSetting=function(e,t,n){this.settings[e]=this.settings[e]||{},this.settings[e][t]=n},e.prototype.isEnabledRule=function(e){return!1!==this.enabledRules[e]},e.prototype.isDisabledRule=function(e){return!this.enabledRules[e]},e.prototype.enableRule=function(e){return this.enable(e,!0)},e.prototype.disableRule=function(e){return this.enable(e,!1)},e.prototype.addSafeTag=function(e,t,n){var r=e instanceof RegExp?e:[e,t,n];this.safeTags.add(r)},e.prototype.prepareContext=function(e,t){return{text:e,isHTML:ke(e),prefs:t,getData:function(e){return"char"===e?t.locale.map((function(t){return he(t+"/"+e)})).join(""):he(t.locale[0]+"/"+e)},safeTags:this.safeTags}},e.prototype.splitBySeparateParts=function(e){if(!e.isHTML||!1===e.prefs.processingSeparateParts)return[e.text];var t=[],n=new RegExp("<("+this.separatePartsTags.join("|")+")(\\s[^>]*?)?>[^]*?</\\1>","gi"),r=0;return e.text.replace(n,(function(n,a,o,i){return r!==i&&t.push((r?xe:"")+e.text.slice(r,i)+xe),t.push(n),r=i+n.length,n})),t.push(r?xe+e.text.slice(r,e.text.length):e.text),t},e.prototype.process=function(e){var t=this;e.text=e.text.replace(/\r\n?/g,"\n"),this.executeRules(e,"start"),this.safeTags.hide(e,"own"),this.executeRules(e,"hide-safe-tags-own"),this.safeTags.hide(e,"html"),this.executeRules(e,"hide-safe-tags-html");var n,r,a=e.isHTML,o=new RegExp(xe,"g");return e.text=this.splitBySeparateParts(e).map((function(n){return e.text=n,e.isHTML=ke(n),t.safeTags.hideHTMLTags(e),t.safeTags.hide(e,"url"),t.executeRules(e,"hide-safe-tags-url"),t.executeRules(e,"hide-safe-tags"),oe.toUtf(e),e.prefs.live&&(e.text=we(e.text)),t.executeRules(e,"utf"),t.executeRules(e),oe.restore(e),t.executeRules(e,"html-entities"),t.safeTags.show(e,"url"),t.executeRules(e,"show-safe-tags-url"),e.text.replace(o,"")})).join(""),e.isHTML=a,this.safeTags.show(e,"html"),this.executeRules(e,"show-safe-tags-html"),this.safeTags.show(e,"own"),this.executeRules(e,"show-safe-tags-own"),this.executeRules(e,"end"),n=e.text,"CRLF"===(r=e.prefs.lineEnding)?n.replace(/\n/g,"\r\n"):"CR"===r?n.replace(/\n/g,"\r"):n},e.prototype.executeRules=function(e,t){var n=this;void 0===t&&(t=Be);var r=this.rulesByQueues[t],a=this.innerRulesByQueues[t];a&&a.forEach((function(t){n.ruleIterator(e,t)})),r&&r.forEach((function(t){n.ruleIterator(e,t)}))},e.prototype.ruleIterator=function(e,t){if(!(!0===e.prefs.live&&!1===t.live||!1===e.prefs.live&&!0===t.live)&&("common"===t.locale||t.locale===e.prefs.locale[0])&&this.isEnabledRule(t.name)){if(e.prefs.ruleFilter&&!e.prefs.ruleFilter(t))return;this.onBeforeRule&&this.onBeforeRule(t.name,e),e.text=t.handler.call(this,e.text,this.settings[t.name],e),this.onAfterRule&&this.onAfterRule(t.name,e)}},e.prototype.prepareRuleSettings=function(e){this.settings[e.name]=Ae(e.settings),this.enabledRules[e.name]=e.enabled},e.prototype.enable=function(e,t){var n=this;Array.isArray(e)?e.forEach((function(e){n.enableByMask(e,t)})):this.enableByMask(e,t)},e.prototype.enableByMask=function(e,t){var n=this;if(e)if(-1!==e.search(/\*/)){var r=new RegExp(e.replace(/\//g,"\\/").replace(/\*/g,".*"));this.rules.forEach((function(e){var a=e.name;r.test(a)&&(n.enabledRules[a]=t)}))}else this.enabledRules[e]=t},e.groups=[],e.titles={},e.version="7.1.0",e}();[{"common/char":"a-z","common/dash":"--?|\u2012|\u2013|\u2014","common/quote":'\xab\u2039\xbb\u203a\u201e\u201c\u201f\u201d"'},{"be/char":"\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0439\u043a\u043b\u043c\u043d\u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u044b\u044c\u044d\u044e\u044f\u0451\u0456\u045e\u0491","be/quote":{left:"\xab\u201c",right:"\xbb\u201d"}},{"bg/char":"\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043a\u043b\u043c\u043d\u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044a\u044c\u044e\u044f","bg/quote":{left:"\u201e\u2019",right:"\u201c\u2019"}},{"ca/char":"abcdefghijlmnopqrstuvxyz\xe0\xe7\xe8\xe9\xed\xef\xf2\xf3\xfa\xfc","ca/quote":{left:"\xab\u201c",right:"\xbb\u201d"}},{"cs/char":"a-z\xe1\xe9\xed\xf3\xfa\xfd\u010d\u010f\u011b\u0148\u0159\u0161\u0165\u016f\u017e","cs/quote":{left:"\u201e\u201a",right:"\u201c\u2018"}},{"da/char":"a-z\xe5\xe6\xf8","da/quote":{left:"\xbb\u203a",right:"\xab\u2039"}},{"de/char":"a-z\xdf\xe4\xf6\xfc","de/quote":{left:"\u201e\u201a",right:"\u201c\u2018"}},{"el/char":"\u0390\u03ac\u03ad\u03ae\u03af\u03b0\u03b1\u03b2\u03b3\u03b4\u03b5\u03b6\u03b7\u03b8\u03b9\u03ba\u03bb\u03bc\u03bd\u03be\u03bf\u03c0\u03c1\u03c2\u03c3\u03c4\u03c5\u03c6\u03c7\u03c8\u03c9\u03ca\u03cb\u03cc\u03cd\u03ce\u03f2\u1f71\u1f73\u1f75\u1f77\u1f79\u1f7b\u1f7d","el/quote":{left:"\xab\u201c",right:"\xbb\u201d"}},{"en-GB/char":"a-z","en-GB/quote":{left:"\u2018\u201c",right:"\u2019\u201d"}},{"en-US/char":"a-z","en-US/quote":{left:"\u201c\u2018",right:"\u201d\u2019"}},{"eo/char":"abcdefghijklmnoprstuvz\u0109\u011d\u0125\u0135\u015d\u016d","eo/quote":{left:"\u201c\u2018",right:"\u201d\u2019"}},{"es/char":"a-z\xe1\xe9\xed\xf1\xf3\xfa\xfc","es/quote":{left:"\xab\u201c",right:"\xbb\u201d"}},{"et/char":"abdefghijklmnoprstuvz\xe4\xf5\xf6\xfc\u0161\u017e","et/quote":{left:"\u201e\xab",right:"\u201c\xbb"}},{"fi/char":"abcdefghijklmnopqrstuvy\xf6\xe4\xe5","fi/quote":{left:"\u201d\u2019",right:"\u201d\u2019"}},{"fr/char":"a-z\xe0\xe2\xe7\xe8\xe9\xea\xeb\xee\xef\xf4\xfb\xfc\u0153\xe6","fr/quote":{left:"\xab\u2039",right:"\xbb\u203a",spacing:!0}},{"ga/char":"abcdefghilmnoprstuvwxyz\xe1\xe9\xed\xf3\xfa","ga/quote":{left:"\u201c\u2018",right:"\u201d\u2019"}},{"hu/char":"a-z\xe1\xe4\xe9\xed\xf3\xf6\xfa\xfc\u0151\u0171","hu/quote":{left:"\u201e\xbb",right:"\u201d\xab"}},{"it/char":"a-z\xe0\xe9\xe8\xec\xf2\xf9","it/quote":{left:"\xab\u201c",right:"\xbb\u201d"}},{"lv/char":"abcdefghijklmnopqrstuvxz\xe6\u0153","lv/quote":{left:"\xab\u201e",right:"\xbb\u201c"}},{"nl/char":"a-z\xe4\xe7\xe8\xe9\xea\xeb\xee\xef\xf1\xf6\xfb\xfc","nl/quote":{left:"\u2018\u201c",right:"\u2019\u201d"}},{"no/char":"a-z\xe5\xe6\xe8\xe9\xea\xf2\xf3\xf4\xf8","no/quote":{left:"\xab\u2019",right:"\xbb\u2019"}},{"pl/char":"abcdefghijklmnoprstuvwxyz\xf3\u0105\u0107\u0119\u0142\u0144\u015b\u017a\u017c","pl/quote":{left:"\u201e\xab",right:"\u201d\xbb"}},{"ro/char":"abcdefghijklmnoprstuvxz\xee\u0103\u0219\u021b","ro/quote":{left:"\u201e\xab",right:"\u201d\xbb"}},{"ru/char":"\u0430-\u044f\u0451","ru/dashBefore":"(^| |\\n)","ru/dashAfter":"(?=[\xa0 ,.?:!]|$)","ru/dashAfterDe":"(?=[,.?:!]|[\xa0 ][^\u0410-\u042f\u0401]|$)","ru/l":"\u0430-\u044f\u0451a-z","ru/L":"\u0410-\u042f\u0401A-Z","ru/month":"\u044f\u043d\u0432\u0430\u0440\u044c|\u0444\u0435\u0432\u0440\u0430\u043b\u044c|\u043c\u0430\u0440\u0442|\u0430\u043f\u0440\u0435\u043b\u044c|\u043c\u0430\u0439|\u0438\u044e\u043d\u044c|\u0438\u044e\u043b\u044c|\u0430\u0432\u0433\u0443\u0441\u0442|\u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044c|\u043e\u043a\u0442\u044f\u0431\u0440\u044c|\u043d\u043e\u044f\u0431\u0440\u044c|\u0434\u0435\u043a\u0430\u0431\u0440\u044c","ru/monthGenCase":"\u044f\u043d\u0432\u0430\u0440\u044f|\u0444\u0435\u0432\u0440\u0430\u043b\u044f|\u043c\u0430\u0440\u0442\u0430|\u0430\u043f\u0440\u0435\u043b\u044f|\u043c\u0430\u044f|\u0438\u044e\u043d\u044f|\u0438\u044e\u043b\u044f|\u0430\u0432\u0433\u0443\u0441\u0442\u0430|\u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f|\u043e\u043a\u0442\u044f\u0431\u0440\u044f|\u043d\u043e\u044f\u0431\u0440\u044f|\u0434\u0435\u043a\u0430\u0431\u0440\u044f","ru/monthPreCase":"\u044f\u043d\u0432\u0430\u0440\u0435|\u0444\u0435\u0432\u0440\u0430\u043b\u0435|\u043c\u0430\u0440\u0442\u0435|\u0430\u043f\u0440\u0435\u043b\u0435|\u043c\u0430\u0435|\u0438\u044e\u043d\u0435|\u0438\u044e\u043b\u0435|\u0430\u0432\u0433\u0443\u0441\u0442\u0435|\u0441\u0435\u043d\u0442\u044f\u0431\u0440\u0435|\u043e\u043a\u0442\u044f\u0431\u0440\u0435|\u043d\u043e\u044f\u0431\u0440\u0435|\u0434\u0435\u043a\u0430\u0431\u0440\u0435","ru/quote":{left:"\xab\u201e\u201a",right:"\xbb\u201c\u2018",removeDuplicateQuotes:!0},"ru/shortMonth":"\u044f\u043d\u0432|\u0444\u0435\u0432|\u043c\u0430\u0440|\u0430\u043f\u0440|\u043c\u0430[\u0435\u0439\u044f]|\u0438\u044e\u043d|\u0438\u044e\u043b|\u0430\u0432\u0433|\u0441\u0435\u043d|\u043e\u043a\u0442|\u043d\u043e\u044f|\u0434\u0435\u043a","ru/weekday":"\u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a|\u0432\u0442\u043e\u0440\u043d\u0438\u043a|\u0441\u0440\u0435\u0434\u0430|\u0447\u0435\u0442\u0432\u0435\u0440\u0433|\u043f\u044f\u0442\u043d\u0438\u0446\u0430|\u0441\u0443\u0431\u0431\u043e\u0442\u0430|\u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435"},{"sk/char":"abcdefghijklmnoprstuvwxyz\xe1\xe4\xe9\xed\xf3\xf4\xfa\xfd\u010d\u010f\u013e\u0148\u0155\u0161\u0165\u017e","sk/quote":{left:"\u201e\u201a",right:"\u201c\u2018"}},{"sl/char":"a-z\u010d\u0161\u017e","sl/quote":{left:"\u201e\u201a",right:"\u201c\u2018"}},{"sr/char":"abcdefghijklmnoprstuvz\u0107\u010d\u0111\u0161\u017e","sr/quote":{left:"\u201e\u2019",right:"\u201d\u2019"}},{"sv/char":"a-z\xe4\xe5\xe9\xf6","sv/quote":{left:"\u201d\u2019",right:"\u201d\u2019"}},{"tr/char":"abcdefghijklmnoprstuvyz\xe2\xe7\xee\xf6\xfb\xfc\u011f\u0131\u015f","tr/quote":{left:"\u201c\u2018",right:"\u201d\u2019"}},{"uk/char":"\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043a\u043b\u043c\u043d\u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044c\u044e\u044f\u0454\u0456\u0457\u0491","uk/quote":{left:"\xab\u201e",right:"\xbb\u201c"}}].forEach((function(e){return fe(e)}));var je={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},Ue={name:"common/html/escape",index:"+100",queue:"end",handler:function(e){return e.replace(/[&<>"'/]/g,(function(e){return je[e]}))},disabled:!0},_e=new RegExp("<("+["address","article","aside","blockquote","canvas","dd","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","li","main","nav","noscript","ol","output","p","pre","section","table","tfoot","ul","video"].join("|")+")[>\\s]"),Fe={name:"common/html/p",index:"+5",queue:"end",handler:function(e){var t=e.split("\n\n");return t.forEach((function(e,t,n){e.trim()&&(_e.test(e)||(n[t]=e.replace(/^(\s*)/,"$1<p>").replace(/(\s*)$/,"</p>$1")))})),t.join("\n\n")},disabled:!0,htmlAttrs:!1},Qe={name:"common/html/processingAttrs",queue:"hide-safe-tags-own",handler:function(e,t,n){var r=this,a=new RegExp("(^|\\s)("+t.attrs.join("|")+")=(\"[^\"]*?\"|'[^']*?')","gi"),o=Ae(n.prefs);return o.ruleFilter=function(e){return!1!==e.htmlAttrs},e.replace(/(<[-\w]+\s)([^>]+?)(?=>)/g,(function(e,t,n){return t+n.replace(a,(function(e,t,n,a){var i=a[0],s=a[a.length-1],u=a.slice(1,-1);return t+n+"="+i+r.execute(u,o)+s}))}))},settings:{attrs:["title","placeholder"]},disabled:!0,htmlAttrs:!1},He={name:"common/html/url",queue:"end",handler:function(e,t,n){return n.isHTML?e:e.replace(me,(function(e,t,n){n=n.replace(/([^/]+\/?)(\?|#)$/,"$1").replace(/^([^/]+)\/$/,"$1"),"http"===t?n=n.replace(/^([^/]+)(:80)([^\d]|\/|$)/,"$1$3"):"https"===t&&(n=n.replace(/^([^/]+)(:443)([^\d]|\/|$)/,"$1$3"));var r=n,a=t+"://"+n,o='<a href="'+a+'">';return"http"===t||"https"===t?(r=r.replace(/^www\./,""),o+("http"===t?r:t+"://"+r)+"</a>"):o+a+"</a>"}))},disabled:!0,htmlAttrs:!1};Pe.addRules([{name:"common/html/e-mail",queue:"end",handler:function(e,t,n){return n.isHTML?e:e.replace(/(^|[\s;(])([\w\-.]{2,64})@([\w\-.]{2,64})\.([a-z]{2,64})([)\s.,!?]|$)/gi,'$1<a href="mailto:$2@$3.$4">$2@$3.$4</a>$5')},disabled:!0,htmlAttrs:!1},Ue,{name:"common/html/nbr",index:"+10",queue:"end",handler:function(e){return e.replace(/([^\n>])\n(?=[^\n])/g,"$1<br/>\n")},disabled:!0,htmlAttrs:!1},Fe,Qe,{name:"common/html/quot",queue:"hide-safe-tags",handler:function(e){return e.replace(/"/g,'"')}},{name:"common/html/stripTags",index:"+99",queue:"end",handler:function(e){return e.replace(/<[^>]+>/g,"")},disabled:!0},He]);var Ge={name:"common/nbsp/afterNumber",handler:function(e,t,n){var r="(^|\\s)(\\d{1,5}) (["+n.getData("char")+"]+)";return e.replace(new RegExp(r,"gi"),"$1$2\xa0$3")},disabled:!0},We={name:"common/nbsp/afterShortWord",handler:function(e,t,n){var r=t.lengthShortWord,a=he("common/quote"),o=n.getData("char"),i="$1$2\xa0",s=new RegExp("(^|[ \xa0(\uf000"+a+"])(["+o+"]{1,"+r+"}) ","gim");return e.replace(s,i).replace(s,i)},settings:{lengthShortWord:2}},Ve={name:"common/nbsp/beforeShortLastNumber",handler:function(e,t,n){var r=n.getData("quote"),a=n.getData("char"),o=a.toUpperCase(),i=new RegExp("(["+a+o+"]) (?=\\d{1,"+t.lengthLastNumber+"}[-+\u2212%'\""+r.right+")]?([.!?\u2026]( ["+o+"]|$)|$))","gm");return e.replace(i,"$1\xa0")},live:!1,settings:{lengthLastNumber:2}},Xe={name:"common/nbsp/beforeShortLastWord",handler:function(e,t,n){var r=n.getData("char"),a=r.toUpperCase(),o=new RegExp("(["+r+"\\d]) (["+r+a+"]{1,"+t.lengthLastWord+"}[.!?\u2026])( ["+a+"]|$)","g");return e.replace(o,"$1\xa0$2$3")},settings:{lengthLastWord:3}};function Ke(e,t,n,r){return t+n.replace(/([^\u00A0])\u00A0([^\u00A0])/g,"$1 $2")+r}var Ye={name:"common/nbsp/nowrap",queue:"end",handler:function(e){return e.replace(/(<nowrap>)(.*?)(<\/nowrap>)/g,Ke).replace(/(<nobr>)(.*?)(<\/nobr>)/g,Ke)}},Ze={name:"common/nbsp/replaceNbsp",queue:"utf",live:!1,handler:we,disabled:!0};Pe.addRules([Ge,{name:"common/nbsp/afterParagraphMark",handler:function(e){return e.replace(/\xb6 ?(?=\d)/g,"\xb6\xa0")}},{name:"common/nbsp/afterSectionMark",handler:function(e,t,n){var r=n.prefs.locale[0];return e.replace(/\xa7[ \u00A0\u2009]?(?=\d|I|V|X)/g,"ru"===r?"\xa7\u202f":"\xa7\xa0")}},We,Ve,Xe,{name:"common/nbsp/dpi",handler:function(e){return e.replace(/(\d) ?(lpi|dpi)(?!\w)/,"$1\xa0$2")}},Ye,Ze]);var Je={name:"common/number/digitGrouping",index:"310",disabled:!0,handler:function(e,t){return e.replace(new RegExp("(^ ?|\\D |".concat($e,")(\\d{1,3}([ \xa0\u202f\u2009]\\d{3})+)(?! ?[\\d-])"),"gm"),(function(e,n,r){return n+r.replace(/\s/g,t.space)})).replace(/(\d{5,}([.,]\d+)?)/g,(function(e,n){var r=n.match(/[.,]/),a=r?n.split(r):[n],o=a[0],i=a[1];return o=o.replace(/(\d)(?=(\d{3})+([^\d]|$))/g,"$1"+t.space),r?o+r+i:o}))},settings:{space:"\u202f"}},et={name:"common/number/mathSigns",handler:function(e){return qe(e,[[/!=/g,"\u2260"],[/<=/g,"\u2264"],[/(^|[^=])>=/g,"$1\u2265"],[/<=>/g,"\u21d4"],[/<</g,"\u226a"],[/>>/g,"\u226b"],[/~=/g,"\u2245"],[/(^|[^+])\+-/g,"$1\xb1"]])}};Pe.addRules([Je,{name:"common/number/fraction",handler:function(e){return e.replace(/(^|\D)1\/2(\D|$)/g,"$1\xbd$2").replace(/(^|\D)1\/4(\D|$)/g,"$1\xbc$2").replace(/(^|\D)3\/4(\D|$)/g,"$1\xbe$2")}},et,{name:"common/number/times",handler:function(e){return e.replace(/(\d)[ \u00A0]?[x\u0445][ \u00A0]?(\d)/g,"$1\xd7$2")}}]);var tt={name:"common/other/repeatWord",handler:function(e,t,n){var r=he("common/quote"),a=n.getData("char"),o="[;:,.?! \n"+r+"]",i=new RegExp("("+o+"|^)(["+a+"]{"+t.min+",}) \\2("+o+"|$)","gi");return e.replace(i,"$1$2$3")},settings:{min:2},disabled:!0};Pe.addRules([{name:"common/other/delBOM",queue:"start",index:-1,handler:function(e){return 65279===e.charCodeAt(0)?e.slice(1):e}},tt]);var nt={name:"common/punctuation/apostrophe",handler:function(e,t,n){var r="(["+n.getData("char")+"])",a=new RegExp(r+"'"+r,"gi");return e.replace(a,"$1\u2019$2")}},rt=function(){function e(){this.bufferQuotes={left:"\uf005\uf006\uf007",right:"\uf008\uf009\uf0a0"},this.beforeLeft=" \n\t\xa0[(",this.afterRight=" \n\t\xa0!?.:;#*,\u2026)\\]"}return e.prototype.process=function(e){var t=e.context.text;if(!this.count(t).total)return t;var n=e.settings,r=e.settings.left[0]===e.settings.right[0];return r&&(e.settings=Ae(e.settings),e.settings.left=this.bufferQuotes.left.slice(0,e.settings.left.length),e.settings.right=this.bufferQuotes.right.slice(0,e.settings.right.length)),e.settings.spacing&&(t=this.removeSpacing(t,e.settings)),t=this.set(t,e),e.settings.spacing&&(t=this.setSpacing(t,e.settings)),e.settings.removeDuplicateQuotes&&(t=this.removeDuplicates(t,e.settings)),r&&(t=this.returnOriginalQuotes(t,n,e.settings),e.settings=n),t},e.prototype.returnOriginalQuotes=function(e,t,n){for(var r={},a=0;a<n.left.length;a++)r[n.left[a]]=t.left[a],r[n.right[a]]=t.right[a];return e.replace(new RegExp("["+n.left+n.right+"]","g"),(function(e){return r[e]}))},e.prototype.count=function(e){var t={total:0};return e.replace(new RegExp("["+he("common/quote")+"]","g"),(function(e){return t[e]||(t[e]=0),t[e]++,t.total++,e})),t},e.prototype.removeDuplicates=function(e,t){var n=t.left[0],r=t.left[1]||n,a=t.right[0];return n!==r?e:e.replace(new RegExp(n+n,"g"),n).replace(new RegExp(a+a,"g"),a)},e.prototype.removeSpacing=function(e,t){for(var n=0,r=t.left.length;n<r;n++){var a=t.left[n],o=t.right[n];e=e.replace(new RegExp(a+"([ \u202f\xa0])","g"),a).replace(new RegExp("([ \u202f\xa0])"+o,"g"),o)}return e},e.prototype.setSpacing=function(e,t){for(var n=0,r=t.left.length;n<r;n++){var a=t.left[n],o=t.right[n];e=e.replace(new RegExp(a+"([^\u202f])","g"),a+"\u202f$1").replace(new RegExp("([^\u202f])"+o,"g"),"$1\u202f"+o)}return e},e.prototype.set=function(e,t){var n=he("common/quote"),r=t.settings.left[0],a=t.settings.left[1]||r,o=t.settings.right[0],i=new RegExp("(^|["+this.beforeLeft+"])(["+n+"]+)(?=[^\\s\uf000])","gim"),s=new RegExp("([^\\s\uf000])(["+n+"]+)(?=["+this.afterRight+"]|$)","gim");return e=e.replace(i,(function(e,t,n){return t+Ee(r,n.length)})).replace(s,(function(e,t,n){return t+Ee(o,n.length)})),e=this.setAboveTags(e,t),r!==a&&(e=this.setInner(e,t.settings)),e},e.prototype.setAboveTags=function(e,t){var n=this,r=he("common/quote"),a=t.settings.left[0],o=t.settings.right[0];return e.replace(new RegExp("(^|.)(["+r+"])(.|$)","gm"),(function(r,i,s,u,c){if(i!==$e&&u!==$e)return r;if(i===$e&&u===$e)return'"'===s?i+n.getAboveTwoTags(e,c+1,t)+u:r;if(i===$e){var l=n.afterRight.indexOf(u)>-1,p=t.safeTags.getPrevTagInfo(t.context,e,c-1);return l&&p&&"html"===p.group?i+(p.isClosing?o:a)+u:i+(!u||l?o:a)+u}var g=n.beforeLeft.indexOf(i)>-1,h=t.safeTags.getNextTagInfo(t.context,e,c+1);return g&&h&&"html"===h.group?i+(h.isClosing?o:a)+u:i+(!i||g?a:o)+u}))},e.prototype.getAboveTwoTags=function(e,t,n){var r=n.safeTags.getPrevTagInfo(n.context,e,t),a=n.safeTags.getNextTagInfo(n.context,e,t);if(r&&"html"===r.group){if(!r.isClosing)return n.settings.left[0];if(a&&a.isClosing&&r.isClosing)return n.settings.right[0]}return e[t]},e.prototype.setInner=function(e,t){for(var n=t.left[0],r=t.right[0],a=this.getMaxLevel(e,n,r,t.left.length),o=0,i="",s=0,u=e.length;s<u;s++){var c=e[s];c===n?(i+=t.left[o>a-1?a-1:o],++o>a&&(o=a)):c===r?(--o<0&&(o=0),i+=t.right[o]):('"'===c&&(o=0),i+=c)}return i},e.prototype.getMaxLevel=function(e,t,n,r){var a=this.count(e);return a[t]===a[n]?r:Math.min(r,2)},e}(),at=new rt,ot={};ue().forEach((function(e){ot[e]=Ae(he(e+"/quote"))}));var it={name:"common/punctuation/quote",handler:function(e,t,n){var r=t[n.prefs.locale[0]];return r?at.process({context:n,settings:r,safeTags:this.safeTags}):e},settings:ot},st={name:"common/punctuation/quoteLink",queue:"show-safe-tags-html",index:"+5",handler:function(e,t,n){var r=this.getSetting("common/punctuation/quote",n.prefs.locale[0]),a=oe.getByUtf(r.left[0]),o=oe.getByUtf(r.right[0]),i=oe.getByUtf(r.left[1]),s=oe.getByUtf(r.right[1]);i=i?"|"+i:"",s=s?"|"+s:"";var u=new RegExp("(<[aA]\\s[^>]*?>)("+a+i+")([^]*?)("+o+s+")(</[aA]>)","g");return e.replace(u,"$2$1$3$5$4")}};Pe.addRules([nt,{name:"common/punctuation/delDoublePunctuation",handler:function(e){return e.replace(/(^|[^,]),,(?!,)/g,"$1,").replace(/(^|[^:])::(?!:)/g,"$1:").replace(/(^|[^!?.])\.\.(?!\.)/g,"$1.").replace(/(^|[^;]);;(?!;)/g,"$1;").replace(/(^|[^?])\?\?(?!\?)/g,"$1?")}},{name:"common/punctuation/hellip",handler:function(e,t,n){return"ru"===n.prefs.locale[0]?e.replace(/(^|[^.])\.{3,4}(?=[^.]|$)/g,"$1\u2026"):e.replace(/(^|[^.])\.{3}(\.?)(?=[^.]|$)/g,"$1\u2026$2")}},it,st]);var ut={name:"common/space/beforeBracket",handler:function(e,t,n){var r=n.getData("char"),a=new RegExp("(["+r+".!?,;\u2026)])\\(","gi");return e.replace(a,"$1 (")}},ct={name:"common/space/delRepeatN",index:"-1",handler:function(e,t){var n=t.maxConsecutiveLineBreaks,r=new RegExp("\n{".concat(n+1,",}"),"g"),a=Ee("\n",n);return e.replace(r,a)},settings:{maxConsecutiveLineBreaks:2}},lt={name:"common/space/trimLeft",index:"-4",handler:String.prototype.trimLeft?function(e){return e.trimLeft()}:function(e){return e.replace(/^[\s\uFEFF\xA0]+/g,"")}},pt={name:"common/space/trimRight",index:"-3",live:!1,handler:String.prototype.trimRight?function(e){return e.trimRight()}:function(e){return e.replace(/[\s\uFEFF\xA0]+$/g,"")}},gt=new RegExp('(\\D):([^)",:.?\\s\\/\\\\\uf000])',"g"),ht={name:"common/space/afterColon",handler:function(e){return e.replace(gt,"$1: $2")}},ft={name:"common/space/afterComma",handler:function(e,t,n){var r=n.getData("quote"),a="string"==typeof r?r:r.right;return e.replace(new RegExp('(.),([^)",:.?\\s\\/\\\\\uf000'+a+"])","g"),(function(e,t,n){return be(t)&&be(n)?e:t+", "+n}))}},dt=new RegExp("\\?([^).\u2026!;?\\s[\\])\uf000"+he("common/quote")+"])","g"),mt={name:"common/space/afterQuestionMark",handler:function(e){return e.replace(dt,"? $1")}},vt=new RegExp("!([^).\u2026!;?\\s[\\])\uf000"+he("common/quote")+"])","g"),yt={name:"common/space/afterExclamationMark",handler:function(e){return e.replace(vt,"! $1")}},bt=new RegExp(";([^).\u2026!;?\\s[\\])\uf000"+he("common/quote")+"])","g"),$t={name:"common/space/afterSemicolon",handler:function(e){return e.replace(bt,"; $1")}};Pe.addRules([ht,ft,mt,yt,$t,ut,{name:"common/space/bracket",handler:function(e){return e.replace(/(\() +/g,"(").replace(/ +\)/g,")")}},{name:"common/space/delBeforeDot",handler:function(e){return e.replace(/(^|[^!?:;,.\u2026]) (\.|\.\.\.)(\s|$)/g,"$1$2$3")}},{name:"common/space/delBeforePercent",handler:function(e){return e.replace(/(\d)( |\u00A0)(%|\u2030|\u2031)/g,"$1$3")}},{name:"common/space/delBeforePunctuation",handler:function(e){return e.replace(/(^|[^!?:;,.\u2026]) ([!?:;,])(?!\))/g,"$1$2")}},{name:"common/space/delBetweenExclamationMarks",handler:function(e){return e.replace(/([!?]) (?=[!?])/g,"$1")}},{name:"common/space/delLeadingBlanks",handler:function(e){return e.replace(/^[ \t]+/gm,"")},disabled:!0},ct,{name:"common/space/delRepeatSpace",index:"-1",handler:function(e){return e.replace(/([^\n \t])[ \t]{2,}(?![\n \t])/g,"$1 ")}},{name:"common/space/delTrailingBlanks",index:"-3",handler:function(e){return e.replace(/[ \t]+\n/g,"\n")}},{name:"common/space/insertFinalNewline",queue:"end",handler:function(e){return"\n"===e[e.length-1]?e:e+"\n"},live:!1,disabled:!0},{name:"common/space/replaceTab",index:"-5",handler:function(e){return e.replace(/\t/g," ")}},{name:"common/space/squareBracket",handler:function(e){return e.replace(/(\[) +/g,"[").replace(/ +\]/g,"]")}},lt,pt]);var xt={name:"common/symbols/arrow",handler:function(e){return qe(e,[[/(^|[^-])->(?!>)/g,"$1\u2192"],[/(^|[^<])<-(?!-)/g,"$1\u2190"]])}},Rt={name:"common/symbols/cf",handler:function(e){var t=new RegExp('(^|[\\s(\\[+\u2248\xb1\u2212\u2014\u2013\\-])(\\d+(?:[.,]\\d+)?)[ \xa0\u2009]?(C|F)([\\W\\s.,:!?")\\]]|$)',"mg");return e.replace(t,"$1$2\u2009\xb0$3$4")}},Et={name:"common/symbols/copy",handler:function(e){return qe(e,[[/\(r\)/gi,"\xae"],[/(copyright )?\((c|\u0441)\)/gi,"\xa9"],[/\(tm\)/gi,"\u2122"]])}};Pe.addRules([xt,Rt,Et]);var wt={name:"en-US/dash/main",index:"-5",handler:function(e){var t=he("common/dash"),n="[ ".concat("\xa0","]"),r="[ ".concat("\xa0","\n]"),a=new RegExp("".concat(n,"(").concat(t,")(").concat(r,")"),"g");return e.replace(a,"".concat("\xa0").concat("\u2014","$2"))}};Pe.addRules([wt]);var qt={name:"ru/dash/centuries",handler:function(e,t){var n="("+he("common/dash")+")",r=new RegExp("(X|I|V)[ |\xa0]?"+n+"[ |\xa0]?(X|I|V)","g");return e.replace(r,"$1"+t.dash+"$3")},settings:{dash:"\u2013"}},kt={name:"ru/dash/daysMonth",handler:function(e,t){var n=new RegExp("(^|\\s)([123]?\\d)("+he("common/dash")+")([123]?\\d)[ \xa0]("+he("ru/monthGenCase")+")","g");return e.replace(n,"$1$2"+t.dash+"$4\xa0$5")},settings:{dash:"\u2013"}},At={name:"ru/dash/de",handler:function(e){var t=new RegExp("([a-\u044f\u0451]+) \u0434\u0435"+he("ru/dashAfterDe"),"g");return e.replace(t,"$1-\u0434\u0435")},disabled:!0},St={name:"ru/dash/decade",handler:function(e,t){var n=new RegExp("(^|\\s)(\\d{3}|\\d)0("+he("common/dash")+")(\\d{3}|\\d)0(-\u0435[ \xa0])(?=\u0433\\.?[ \xa0]?\u0433|\u0433\u043e\u0434)","g");return e.replace(n,"$1$20"+t.dash+"$40$5")},settings:{dash:"\u2013"}},Tt={name:"ru/dash/directSpeech",handler:function(e){var t=he("common/dash"),n=new RegExp('(["\xbb\u2018\u201c,])[ |\xa0]?('.concat(t,")[ |\xa0]"),"g"),r=new RegExp("(^|".concat($e,")(").concat(t,")( |\xa0)"),"gm"),a=new RegExp("([.\u2026?!])[ \xa0](".concat(t,")[ \xa0]"),"g");return e.replace(n,"$1\xa0\u2014 ").replace(r,"$1\u2014\xa0").replace(a,"$1 \u2014\xa0")}},Bt={name:"ru/dash/izpod",handler:function(e){var t=new RegExp(he("ru/dashBefore")+"(\u0418|\u0438)\u0437 \u043f\u043e\u0434"+he("ru/dashAfter"),"g");return e.replace(t,"$1$2\u0437-\u043f\u043e\u0434")}},Lt={name:"ru/dash/izza",handler:function(e){var t=new RegExp(he("ru/dashBefore")+"(\u0418|\u0438)\u0437 \u0437\u0430"+he("ru/dashAfter"),"g");return e.replace(t,"$1$2\u0437-\u0437\u0430")}},Ct={name:"ru/dash/ka",handler:function(e){var t=new RegExp("([a-\u044f\u0451]+) \u043a\u0430(\u0441\u044c)?"+he("ru/dashAfter"),"g");return e.replace(t,"$1-\u043a\u0430$2")}},Dt={name:"ru/dash/koe",handler:function(e){var t=new RegExp(he("ru/dashBefore")+"([\u041a\u043a]\u043e[\u0435\u0439])\\s([\u0430-\u044f\u0451]{3,})"+he("ru/dashAfter"),"g");return e.replace(t,"$1$2-$3")}},It={name:"ru/dash/main",index:"-5",handler:function(e){var t=he("common/dash"),n=new RegExp("([ \xa0])("+t+")([ \xa0\\n])","g");return e.replace(n,"\xa0\u2014$3")}},Nt={name:"ru/dash/month",handler:function(e,t){var n="("+he("ru/month")+")",r="("+he("ru/monthPreCase")+")",a=he("common/dash"),o=new RegExp(n+" ?("+a+") ?"+n,"gi"),i=new RegExp(r+" ?("+a+") ?"+r,"gi"),s="$1"+t.dash+"$3";return e.replace(o,s).replace(i,s)},settings:{dash:"\u2013"}},Ot={name:"ru/dash/surname",handler:function(e){var t=new RegExp("([\u0410-\u042f\u0401][\u0430-\u044f\u0451]+)\\s-([\u0430-\u044f\u0451]{1,3})(?![^\u0430-\u044f\u0451]|$)","g");return e.replace(t,"$1\xa0\u2014$2")}},zt={name:"ru/dash/taki",handler:function(e){var t=new RegExp("(\u0432\u0435\u0440\u043d\u043e|\u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e|\u043e\u043f\u044f\u0442\u044c|\u043f\u0440\u044f\u043c\u043e|\u0442\u0430\u043a|\u0432\u0441[\u0435\u0451]|\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e|\u043d\u0435\u0443\u0436\u0435\u043b\u0438)\\s(\u0442\u0430\u043a\u0438)"+he("ru/dashAfter"),"g");return e.replace(t,"$1-$2")}},Mt={name:"ru/dash/time",handler:function(e,t){var n=new RegExp(he("ru/dashBefore")+"(\\d?\\d:[0-5]\\d)"+he("common/dash")+"(\\d?\\d:[0-5]\\d)"+he("ru/dashAfter"),"g");return e.replace(n,"$1$2"+t.dash+"$3")},settings:{dash:"\u2013"}},Pt={name:"ru/dash/to",handler:function(e){var t=new RegExp("(^|[^\u0410-\u042f\u0401\u0430-\u044f\u0451\\w])([\u041e\u043e]\u0442\u043a\u0443\u0434\u0430|[\u041a\u043a]\u0443\u0434\u0430|[\u0413\u0433]\u0434\u0435|[\u041a\u043a]\u043e\u0433\u0434\u0430|[\u0417\u0437]\u0430\u0447\u0435\u043c|[\u041f\u043f]\u043e\u0447\u0435\u043c\u0443|[\u041a\u043a]\u0430\u043a|[\u041a\u043a]\u0430\u043a\u043e[\u0435\u0439\u043c]|[\u041a\u043a]\u0430\u043a\u0430\u044f|[\u041a\u043a]\u0430\u043a\u0438[\u0435\u043c\u0445]|[\u041a\u043a]\u0430\u043a\u0438\u043c\u0438|[\u041a\u043a]\u0430\u043a\u0443\u044e|[\u0427\u0447]\u0442\u043e|[\u0427\u0447]\u0435\u0433\u043e|[\u0427\u0447]\u0435[\u0439\u043c]|[\u0427\u0447]\u044c\u0438\u043c?|[\u041a\u043a]\u0442\u043e|[\u041a\u043a]\u043e\u0433\u043e|[\u041a\u043a]\u043e\u043c\u0443|[\u041a\u043a]\u0435\u043c)( | -|- )(\u0442\u043e|\u043b\u0438\u0431\u043e|\u043d\u0438\u0431\u0443\u0434\u044c)"+he("ru/dashAfter"),"g");return e.replace(t,(function(e,t,n,r,a){var o=n+r+a;return"\u043a\u0430\u043a \u0442\u043e"===o||"\u041a\u0430\u043a \u0442\u043e"===o?e:t+n+"-"+a}))}},jt={name:"ru/dash/kakto",handler:function(e){var t=new RegExp("(^|[^\u0410-\u042f\u0401\u0430-\u044f\u0451\\w])([\u041a\u043a]\u0430\u043a) \u0442\u043e"+he("ru/dashAfter"),"g");return e.replace(t,"$1$2-\u0442\u043e")}},Ut={name:"ru/dash/weekday",handler:function(e,t){var n="("+he("ru/weekday")+")",r=new RegExp(n+" ?("+he("common/dash")+") ?"+n,"gi");return e.replace(r,"$1"+t.dash+"$3")},settings:{dash:"\u2013"}},_t={name:"ru/dash/years",handler:function(e,t){var n=he("common/dash"),r=new RegExp("(\\D|^)(\\d{4})[ \xa0]?("+n+")[ \xa0]?(\\d{4})(?=[ \xa0]?\u0433)","g");return e.replace(r,(function(e,n,r,a,o){return parseInt(r,10)<parseInt(o,10)?n+r+t.dash+o:e}))},settings:{dash:"\u2013"}};Pe.addRules([qt,kt,At,St,Tt,Bt,Lt,Ct,Dt,It,Nt,Ot,zt,Mt,Pt,jt,Ut,_t]);var Ft="(-|\\.|\\/)",Qt="(-|\\/)",Ht=new RegExp("(^|\\D)(\\d{4})"+Ft+"(\\d{2})"+Ft+"(\\d{2})(\\D|$)","gi"),Gt=new RegExp("(^|\\D)(\\d{2})"+Qt+"(\\d{2})"+Qt+"(\\d{4})(\\D|$)","gi"),Wt={name:"ru/date/fromISO",handler:function(e){return e.replace(Ht,"$1$6.$4.$2$7").replace(Gt,"$1$4.$2.$6$7")}},Vt={name:"ru/date/weekday",handler:function(e){var t=he("ru/monthGenCase"),n=he("ru/weekday"),r=new RegExp("(\\d)( |\xa0)("+t+"),( |\xa0)("+n+")","gi");return e.replace(r,(function(e,t,n,r,a,o){return t+n+r.toLowerCase()+","+a+o.toLowerCase()}))}};Pe.addRules([Wt,Vt]);var Xt={name:"ru/money/currency",handler:function(e){var t="([$\u20ac\xa5\u04b0\xa3\u20a4\u20bd])",n="[ \xa0\u2009\u202f]",r=new RegExp("(^|[\\D]{2})"+t+" ?("+ve+"("+n+"\\d{3})*)("+n+"?(\u0442\u044b\u0441\\.|\u043c\u043b\u043d|\u043c\u043b\u0440\u0434|\u0442\u0440\u043b\u043d))?","gm"),a=new RegExp("(^|[\\D])("+ve+") ?"+t,"gm");return e.replace(r,(function(e,t,n,r,a,o,i,s){return t+r+(s?"\xa0"+s:"")+"\xa0"+n})).replace(a,"$1$2\xa0$4")},disabled:!0},Kt={name:"ru/money/ruble",handler:function(e){var t="$1\xa0\u20bd",n="(\\d+)( |\xa0)?(\u0440|\u0440\u0443\u0431)\\.",r=new RegExp("^"+n+"$","g"),a=new RegExp(n+"(?=[!?,:;])","g"),o=new RegExp(n+"(?=\\s+[A-\u042f\u0401])","g");return e.replace(r,t).replace(a,t).replace(o,t+".")},disabled:!0};function Yt(e,t,n,r){return"\u0434\u0434"===n&&"\u043c\u043c"===r||["\u0440\u0444","\u0440\u0443","\u0440\u0443\u0441","\u043e\u0440\u0433","\u0443\u043a\u0440","\u0431\u0433","\u0441\u0440\u0431"].indexOf(r)>-1?e:t+n+".\xa0"+r+"."}Pe.addRules([Xt,Kt]);var Zt={name:"ru/nbsp/abbr",handler:function(e){var t=new RegExp("(^|\\s|".concat($e,")([\u0430-\u044f\u0451]{1,3})\\. ?([\u0430-\u044f\u0451]{1,3})\\."),"g");return e.replace(t,Yt).replace(t,Yt)}},Jt={name:"ru/nbsp/beforeParticle",index:"+5",handler:function(e){var t="(\u043b\u0438|\u043b\u044c|\u0436\u0435|\u0436|\u0431\u044b|\u0431)",n=new RegExp("([\u0410-\u042f\u0401\u0430-\u044f\u0451]) "+t+'(?=[,;:?!"\u2018\u201c\xbb])',"g"),r=new RegExp("([\u0410-\u042f\u0401\u0430-\u044f\u0451])[ \xa0]"+t+"[ \xa0]","g");return e.replace(n,"$1\xa0$2").replace(r,"$1\xa0$2 ")}},en={name:"ru/nbsp/centuries",handler:function(e){var t=he("common/dash"),n="(^|\\s)([VIX]+)",r='(?=[,;:?!"\u2018\u201c\xbb]|$)',a=new RegExp(n+"[ \xa0]?\u0432\\.?"+r,"gm"),o=new RegExp(n+"("+t+")([VIX]+)[ \xa0]?\u0432\\.?([ \xa0]?\u0432\\.?)?"+r,"gm");return e.replace(a,"$1$2\xa0\u0432.").replace(o,"$1$2$3$4\xa0\u0432\u0432.")}},tn={name:"ru/nbsp/dayMonth",handler:function(e){var t=new RegExp("(\\d{1,2}) ("+he("ru/shortMonth")+")","gi");return e.replace(t,"$1\xa0$2")}},nn={name:"ru/nbsp/initials",handler:function(e){var t="\xa0\u202f ",n=he("ru/quote"),r=new RegExp("(^|["+t+n.left+'\uf000"])([\u0410-\u042f\u0401])\\.['+t+"]?([\u0410-\u042f\u0401])\\.["+t+"]?([\u0410-\u042f\u0401][\u0430-\u044f\u0451]+)","gm");return e.replace(r,"$1$2.\xa0$3.\xa0$4")}},rn={2:"\xb2","\xb2":"\xb2",3:"\xb3","\xb3":"\xb3","":""},an={name:"ru/nbsp/m",index:"+5",handler:function(e){var t=new RegExp("(^|[\\s,.\\(\uf000])(\\d+)[ \xa0]?(\u043c\u043c?|\u0441\u043c|\u043a\u043c|\u0434\u043c|\u0433\u043c|mm?|km|cm|dm)([23\xb2\xb3])?([\\s\\).!?,;\uf000]|$)","gm");return e.replace(t,(function(e,t,n,r,a,o){return t+n+"\xa0"+r+rn[a||""]+("\xa0"===o?" ":o)}))}},on={name:"ru/nbsp/page",handler:function(e){var t=new RegExp("(^|[)\\s\uf000])(\u0441\u0442\u0440|\u0433\u043b|\u0440\u0438\u0441|\u0438\u043b\u043b?|\u0441\u0442|\u043f|c)\\. *(\\d+)([\\s.,?!;:]|$)","gim");return e.replace(t,"$1$2.\xa0$3$4")}},sn={name:"ru/nbsp/ps",handler:function(e){var t=new RegExp("(^|\\s|".concat($e,")[p\u0437]\\.[ \xa0]?([p\u0437]\\.[ \xa0]?)?[s\u044b]\\.:? "),"gim");return e.replace(t,(function(e,t,n){return t+(n?"P.\xa0P.\xa0S. ":"P.\xa0S. ")}))}},un={name:"ru/nbsp/see",handler:function(e){var t=new RegExp("(^|\\s|".concat($e,"|\\()(\u0441\u043c|\u0438\u043c)\\.[ \xa0]?([\u0430-\u044f\u04510-9a-z]+)([\\s.,?!]|$)"),"gi");return e.replace(t,(function(e,t,n,r,a){return("\xa0"===t?" ":t)+n+".\xa0"+r+a}))}},cn={name:"ru/nbsp/years",index:"+5",handler:function(e){var t=he("common/dash"),n=new RegExp("(^|\\D)(\\d{4})("+t+')(\\d{4})[ \xa0]?\u0433\\.?([ \xa0]?\u0433\\.)?(?=[,;:?!"\u2018\u201c\xbb\\s]|$)',"gm");return e.replace(n,"$1$2$3$4\xa0\u0433\u0433.")}};Pe.addRules([Zt,{name:"ru/nbsp/addr",handler:function(e){return e.replace(/(\s|^)(\u0434\u043e\u043c|\u0434\.|\u043a\u0432\.|\u043f\u043e\u0434\.|\u043f-\u0434) *(\d+)/gi,"$1$2\xa0$3").replace(/(\s|^)(\u043c\u043a\u0440-\u043d|\u043c\u043a-\u043d|\u043c\u043a\u0440\.|\u043c\u043a\u0440\u043d)\s/gi,"$1$2\xa0").replace(/(\s|^)(\u044d\u0442\.) *(-?\d+)/gi,"$1$2\xa0$3").replace(/(\s|^)(\d+) +\u044d\u0442\u0430\u0436([^\u0430-\u044f\u0451]|$)/gi,"$1$2\xa0\u044d\u0442\u0430\u0436$3").replace(/(\s|^)\u043b\u0438\u0442\u0435\u0440\s([\u0410-\u042f]|$)/gi,"$1\u043b\u0438\u0442\u0435\u0440\xa0$2").replace(/(\s|^)(\u043e\u0431\u043b|\u043a\u0440|\u0441\u0442|\u043f\u043e\u0441|\u0441|\u0434|\u0443\u043b|\u043f\u0435\u0440|\u043f\u0440|\u043f\u0440-\u0442|\u043f\u0440\u043e\u0441\u043f|\u043f\u043b|\u0431\u0443\u043b|\u0431-\u0440|\u043d\u0430\u0431|\u0448|\u0442\u0443\u043f|\u043e\u0444|\u043a\u043e\u043c\u043d?|\u0443\u0447|\u0432\u043b|\u0432\u043b\u0430\u0434|\u0441\u0442\u0440|\u043a\u043e\u0440)\. *([\u0430-\u044f\u0451a-z\d]+)/gi,"$1$2.\xa0$3").replace(/(\D[ \u00A0]|^)\u0433\. ?([\u0410-\u042f\u0401])/gm,"$1\u0433.\xa0$2")}},{name:"ru/nbsp/afterNumberSign",handler:function(e){return e.replace(/\u2116[ \u00A0\u2009]?(\d|\u043f\/\u043f)/g,"\u2116\u202f$1")}},Jt,en,tn,nn,an,{name:"ru/nbsp/mln",handler:function(e){return e.replace(/(\d) ?(\u0442\u044b\u0441|\u043c\u043b\u043d|\u043c\u043b\u0440\u0434|\u0442\u0440\u043b\u043d)(\.|\s|$)/gi,"$1\xa0$2$3")}},{name:"ru/nbsp/ooo",handler:function(e){return e.replace(/(^|[^a-\u044f\u0451A-\u042f\u0401])(\u041e\u041e\u041e|\u041e\u0410\u041e|\u0417\u0410\u041e|\u041d\u0418\u0418|\u041f\u0411\u041e\u042e\u041b) /g,"$1$2\xa0")}},on,sn,{name:"ru/nbsp/rubleKopek",handler:function(e){return e.replace(/(\d) ?(?=(\u0440\u0443\u0431|\u043a\u043e\u043f)\.)/g,"$1\xa0")}},un,{name:"ru/nbsp/year",handler:function(e){return e.replace(/(^|\D)(\d{4}) ?\u0433([ ,;.\n]|$)/g,"$1$2\xa0\u0433$3")}},cn]);var ln={name:"ru/number/ordinals",handler:function(e,t,n){var r=n.getData("char"),a=new RegExp("(\\d[%\u2030]?)-(\u044b\u0439|\u043e\u0439|\u0430\u044f|\u043e\u0435|\u044b\u0435|\u044b\u043c|\u043e\u043c|\u044b\u0445|\u043e\u0433\u043e|\u043e\u043c\u0443|\u044b\u043c\u0438)(?!["+r+"])","g");return e.replace(a,(function(e,t,n){return t+"-"+{\u043e\u0439:"\u0439",\u044b\u0439:"\u0439",\u0430\u044f:"\u044f",\u043e\u0435:"\u0435",\u044b\u0435:"\u0435",\u044b\u043c:"\u043c",\u043e\u043c:"\u043c",\u044b\u0445:"\u0445",\u043e\u0433\u043e:"\u0433\u043e",\u043e\u043c\u0443:"\u043c\u0443",\u044b\u043c\u0438:"\u043c\u0438"}[n]}))}};function pn(e,t){var n=new RegExp('<span class="('+t.join("|")+')">([^]*?)</span>',"g");return e.replace(n,"$2")}function gn(e,t){return e.replace(/<title>[^]*?<\/title>/i,(function(e){return pn(e,t)}))}Pe.addRules([{name:"ru/number/comma",handler:function(e){return e.replace(/(^|\s)(\d+)\.(\d+[\u00A0\u2009\u202F ]*?[%\u2030\xb0\xd7x])/gim,"$1$2,$3")}},ln]);var hn=["typograf-oa-lbracket","typograf-oa-n-lbracket","typograf-oa-sp-lbracket"],fn="ru/optalign/bracket",dn={name:fn,handler:function(e){return e.replace(/( |\u00A0)\(/g,'<span class="typograf-oa-sp-lbracket">$1</span><span class="typograf-oa-lbracket">(</span>').replace(/^\(/gm,'<span class="typograf-oa-n-lbracket">(</span>')},disabled:!0,htmlAttrs:!1},mn={name:fn,queue:"start",handler:function(e){return pn(e,hn)},htmlAttrs:!1},vn={name:fn,queue:"end",handler:function(e){return gn(e,hn)},htmlAttrs:!1},yn=["typograf-oa-comma","typograf-oa-comma-sp"],bn="ru/optalign/comma",$n={name:bn,handler:function(e,t,n){var r=n.getData("char"),a=new RegExp("(["+r+"\\d\u0301]+), ","gi");return e.replace(a,'$1<span class="typograf-oa-comma">,</span><span class="typograf-oa-comma-sp"> </span>')},disabled:!0,htmlAttrs:!1},xn={name:bn,queue:"start",handler:function(e){return pn(e,yn)},htmlAttrs:!1},Rn={name:bn,queue:"end",handler:function(e){return gn(e,yn)},htmlAttrs:!1},En=["typograf-oa-lquote","typograf-oa-n-lquote","typograf-oa-sp-lquote"],wn="ru/optalign/quote",qn={name:wn,handler:function(e){var t=this.getSetting("common/punctuation/quote","ru"),n="(["+t.left[0]+(t.left[1]||"")+"])",r=new RegExp("(^|\n\n|\uf000)("+n+")","g"),a=new RegExp("([^\n\uf000])([ \xa0\n])("+n+")","gi");return e.replace(r,'$1<span class="typograf-oa-n-lquote">$2</span>').replace(a,'$1<span class="typograf-oa-sp-lquote">$2</span><span class="typograf-oa-lquote">$3</span>')},disabled:!0,htmlAttrs:!1},kn={name:wn,queue:"start",handler:function(e){return pn(e,En)},htmlAttrs:!1},An={name:wn,queue:"end",handler:function(e){return gn(e,En)},htmlAttrs:!1};Pe.addRules([dn,$n,qn]),Pe.addInnerRules([mn,vn,xn,Rn,kn,An]);var Sn=[];function Tn(e){var t,n,r=e[0],a="";if(e.length<8)return Bn(e);if(e.length>10)if("+"===r){if("7"!==e[1])return e;t=!0,e=e.substr(2)}else"8"===r&&(n=!0,e=e.substr(1));for(var o=8;o>=2;o--){var i=+e.substr(0,o);if(Sn.indexOf(i)>-1){a=e.substr(0,o),e=e.substr(o);break}}return a||(a=e.substr(0,5),e=e.substr(5)),(t?"+7\xa0":"")+(n?"8\xa0":"")+function(e){var t=+e,n=e.length,r=[e],a=!1;if(n>3)switch(n){case 4:r=[e.substr(0,2),e.substr(2,2)];break;case 5:r=[e.substr(0,3),e.substr(3,3)];break;case 6:r=[e.substr(0,2),e.substr(2,2),e.substr(4,2)]}else a=t>900&&t<=999||495===t||499===t;var o=r.join("-");return a?o:"("+o+")"}(a)+"\xa0"+Bn(e)}function Bn(e){var t="";return e.length%2&&(t=e[0],t+=e.length<=5?"-":"",e=e.substr(1,e.length-1)),t+e.split(/(?=(?:\d\d)+$)/).join("-")}function Ln(e){return e.replace(/[^\d+]/g,"")}[4162,416332,8512,851111,4722,4725,391379,8442,4732,4152,4154451,4154459,4154455,41544513,8142,8332,8612,8622,3525,812,8342,8152,3812,4862,3422,342633,8112,9142,8452,3432,3434,3435,4812,8432,8439,3822,4872,3412,3511,3512,3022,4112,4852,4855,3852,3854,8182,818,90,3472,4741,4764,4832,4922,8172,8202,8722,4932,493,3952,3951,3953,411533,4842,3842,3843,8212,4942,"39131-39179","39190-39199",391,4712,4742,8362,495,499,4966,4964,4967,498,8312,8313,3832,383612,3532,8412,4232,423370,423630,8632,8642,8482,4242,8672,8652,4752,4822,482502,4826300,3452,8422,4212,3466,3462,8712,8352,"901-934","936-939","950-953",958,"960-969","977-989","991-997",999].forEach((function(e){if("string"==typeof e)for(var t=e.split("-"),n=+t[0];n<=+t[1];n++)Sn.push(n);else Sn.push(e)}));var Cn={name:"ru/other/phone-number",live:!1,handler:function(e){var t=new RegExp("(^|,| |\uf000)(\\+7[\\d\\(\\) \xa0-]{10,18})(?=,|;|\uf000|$)","gm");return e.replace(t,(function(e,t,n){var r=Ln(n);return 12===r.length?t+Tn(r):e})).replace(/(^|[^\u0430-\u044f\u0451])([\u260e\u260f\u2706\ud83d\udce0\ud83d\udcde\ud83d\udcf1]|\u0442\.|\u0442\u0435\u043b\.|\u0444\.|\u043c\u043e\u0431\.|\u0444\u0430\u043a\u0441|\u0441\u043e\u0442\u043e\u0432\u044b\u0439|\u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0439|\u0442\u0435\u043b\u0435\u0444\u043e\u043d)(:?\s*?)([+\d(][\d \u00A0\-()]{3,}\d)/gi,(function(e,t,n,r,a){var o=Ln(a);return o.length>=5?t+n+r+Tn(o):e}))}};Pe.addRules([{name:"ru/other/accent",handler:function(e){return e.replace(/([\u0430-\u044f\u0451])([\u0410\u0415\u0401\u0418\u041e\u0423\u042b\u042d\u042e\u042f])([^\u0410-\u042f\u0401\w]|$)/g,(function(e,t,n,r){return t+n.toLowerCase()+"\u0301"+r}))},disabled:!0},Cn]);var Dn={name:"ru/punctuation/ano",handler:function(e){var t=new RegExp("([^\xab\u201e[(!?,:;\\-\u2012\u2013\u2014\\s\uf000])(\\s+)(\u0430|\u043d\u043e)(?= |\xa0|\\n)","g");return e.replace(t,"$1,$2$3")}},In={name:"ru/punctuation/exclamationQuestion",index:"+5",handler:function(e){var t=new RegExp("(^|[^!])!\\?([^?]|$)","g");return e.replace(t,"$1?!$2")}};Pe.addRules([Dn,{name:"ru/punctuation/exclamation",handler:function(e){return e.replace(/(^|[^!])!{2}($|[^!])/gm,"$1!$2").replace(/(^|[^!])!{4}($|[^!])/gm,"$1!!!$2")},live:!1},In,{name:"ru/punctuation/hellipQuestion",handler:function(e){return e.replace(/(^|[^.])(\.\.\.|\u2026),/g,"$1\u2026").replace(/(!|\?)(\.\.\.|\u2026)(?=[^.]|$)/g,"$1..")}}]);var Nn={name:"ru/space/year",handler:function(e,t,n){var r=n.getData("char"),a=new RegExp("(^| |\xa0)(\\d{3,4})(\u0433\u043e\u0434([\u0430\u0443\u0435]|\u043e\u043c)?)([^"+r+"]|$)","g");return e.replace(a,"$1$2 $3$5")}};Pe.addRules([{name:"ru/space/afterHellip",handler:function(e){return e.replace(/([\u0430-\u044f\u0451])(\.\.\.|\u2026)([\u0410-\u042f\u0401])/g,"$1$2 $3").replace(/([?!]\.\.)([\u0430-\u044f\u0451a-z])/gi,"$1 $2")}},Nn]),Pe.addRules([{name:"ru/symbols/NN",handler:function(e){return e.replace(/\u2116\u2116/g,"\u2116")}}]);var On={A:"\u0410",a:"\u0430",B:"\u0412",E:"\u0415",e:"\u0435",K:"\u041a",M:"\u041c",H:"\u041d",O:"\u041e",o:"\u043e",P:"\u0420",p:"\u0440",C:"\u0421",c:"\u0441",T:"\u0422",y:"\u0443",X:"\u0425",x:"\u0445"},zn=Object.keys(On).join(""),Mn={name:"ru/typo/switchingKeyboardLayout",handler:function(e){var t=new RegExp("(["+zn+"]{1,3})(?=[\u0410-\u042f\u0401\u0430-\u044f\u0451]+?)","g");return e.replace(t,(function(e,t){for(var n="",r=0;r<t.length;r++)n+=On[t[r]];return n}))}};Pe.addRules([Mn]),Pe.setData("fr/quote",{left:"\xab\u2039",right:"\xbb\u203a",spacing:!1});const Pn=["common/punctuation/quote","en-US/dash/main","common/nbsp/afterParagraphMark","common/nbsp/afterShortWord","common/nbsp/beforeShortLastNumber","common/nbsp/beforeShortLastWord","common/nbsp/dpi","common/punctuation/apostrophe"],jn=(e,t,n)=>{const r=new Pe({locale:n});return r.disableRule("*"),r.enableRule(b(W(e).getOr(Pn),p(d,Pn))),r.execute(t)},Un=["common/space/delBeforePunctuation","common/space/afterComma","common/space/afterColon","common/space/delBetweenExclamationMarks","common/space/afterExclamationMark","common/space/afterQuestionMark","common/space/afterSemicolon","common/space/beforeBracket","common/space/bracket","common/space/delBeforeDot","common/space/delBeforePercent","common/space/squareBracket","common/number/mathSigns","common/number/times","common/number/fraction","common/symbols/arrow","common/symbols/cf","common/symbols/copy","common/punctuation/delDoublePunctuation","common/punctuation/hellip","common/nbsp/afterSectionMark"],_n=(e,t,n)=>{const r=new Pe({locale:n});return r.disableRule("*"),r.enableRule(b(W(e).getOr(Un),p(d,Un))),r.execute(t)},Fn=(e,t)=>N(t,(t=>"false"!==e.dom.getContentEditableParent(t.dom)&&w(t)&&!("\ufeff"===t.dom.data))),Qn=(e,t)=>!m(X(e).getOr([]),(e=>((e,t,n)=>C(e,t,void 0).isSome())(t,e))),Hn=(e,t)=>{y(Fn(e,t),(t=>{Qn(e,t)&&M(t,_n(e,z(t),J(e,t)))}))},Gn=(e,t)=>{e.notificationManager.open({text:t,type:"success",timeout:3e3})},Wn=e=>{let t=e.getBody();const n=((e,t)=>{const n=c(t)?t:g;let r=e.dom;const a=[];for(;null!==r.parentNode&&void 0!==r.parentNode;){const e=r.parentNode,t=R(e);if(a.push(t),!0===n(t))break;r=e}return a})(R(e.selection.getNode()));for(const r of n){if(!e.dom.isEditable(r.dom))break;t=r.dom}y(e.dom.select(((e,t)=>{const n=[],r=c(t)?e=>m(n,(n=>t(n,e))):e=>d(n,e);for(let t=0,a=e.length;t<a;t++){const a=e[t];r(a)||n.push(a)}return n})(v($(e.schema.getBlockElements()),(e=>e.toLowerCase()))).join(","),t),(t=>{const n=R(t);((e,t=!1)=>{return L(e)?e.dom.isContentEditable:(n=e,D(n,"[contenteditable]")).fold(l(t),(e=>"true"===I(e)));var n})(n)&&(Hn(e,n),((e,t)=>{const n=h.from(P(t)).getOr("");let r=0;y(Fn(e,t),(t=>{const{length:a}=z(t);Qn(e,t)&&M(t,jn(e,n,J(e,t)).slice(r,r+a)),r+=a}))})(e,n))})),Gn(e,"Document typography has been enhanced")},Vn=e=>{const t=e.selection.getRng();((e,t)=>{const{startOffset:n,endOffset:r}=t,a=R(t.startContainer),o=R(t.endContainer);let i=!1;y(e.selection.getSelectedBlocks(),(t=>{const s=R(t),u=h.from(P(s)).getOr("");let c=0;y(Fn(e,s),(t=>{const s=z(t),{length:l}=s,p=jn(e,u,J(e,t)),g=c,h=c+l;c+=l,Qn(e,t)&&(S(t,a)&&S(t,o)?M(t,s.slice(0,n)+p.slice(g,h).slice(n,r)+s.slice(r,l)):S(t,a)?(i=!0,M(t,s.slice(0,n)+p.slice(g,h).slice(n,l))):S(t,o)?(i=!1,M(t,p.slice(g,h).slice(0,r)+s.slice(r,l))):i&&M(t,p.slice(g,h)))}))}))})(e,t),((e,t)=>{const{startContainer:n,endContainer:r,startOffset:a,endOffset:o}=t,i=(s=R(n),u=a,c=R(r),{start:s,soffset:u,finish:c,foffset:o});var s,u,c;tinymce.dom.RangeUtils(e.dom).walk(t,(n=>{y(0===n.length?[t.commonAncestorContainer]:n,(t=>((e,t,n)=>{if(!Qn(n,e))return;if(!S(e,t.start)&&!S(e,t.finish))return void Hn(n,e);const r=J(n,e);if(S(e,t.start)&&w(e)){const a=z(e);M(e,a.slice(0,t.soffset)+_n(n,a.slice(t.soffset,a.length),r))}if(S(e,t.finish)&&w(e)){const a=z(e);M(e,_n(n,a.slice(0,t.foffset),r)+a.slice(t.foffset,a.length))}})(R(t),i,e)))}))})(e,t),Gn(e,"The selected content typography has been enhanced")},Xn=(e,t)=>{const n=e.dom.isEditable(e.selection.getNode());t.setEnabled(n&&!e.dom.isEmpty(e.getBody()))},Kn=e=>t=>{Xn(e,t);const n=((e,t)=>{let n=null;const r=()=>{s(n)||(clearTimeout(n),n=null)};return{cancel:r,throttle:(...t)=>{r(),n=setTimeout((()=>{n=null,e.apply(null,t)}),50)}}})((()=>Xn(e,t)));return e.on("SelectionChange AfterSetSelectionRange",n.throttle),e.on("remove",n.cancel),()=>{n.cancel(),e.off("SelectionChange AfterSetSelectionRange",n.throttle),e.off("remove",n.cancel)}};tinymce.PluginManager.requireLangPack("typography","ar,bg_BG,ca,cs,da,de,el,es,eu,fa,fi,fr_FR,he_IL,hi,hr,hu_HU,id,it,ja,kk,ko_KR,ms,nb_NO,nl,pl,pt_BR,pt_PT,ro,ru,sk,sl_SI,sv_SE,th_TH,tr,uk,vi,zh_CN,zh_TW"),tinymce.PluginManager.add("typography",(e=>{((e,n)=>!!e&&-1===((e,n)=>{const r=t(e.major,n.major);if(0!==r)return r;const a=t(e.minor,n.minor);if(0!==a)return a;const o=t(e.patch,n.patch);return 0!==o?o:0})((e=>r((e=>[e.majorVersion,e.minorVersion].join(".").split(".").slice(0,3).join("."))(e)))(e),r(n)))(tinymce,"6.0.0")?console.error("The typography plugin requires at least version 6.0.0 of TinyMCE."):((e=>{e.addCommand("mceTypography",(()=>(e=>{e.dom.isEditable(e.selection.getNode())&&e.undoManager.transact((()=>{const t=e.selection.getBookmark(2);e.selection.isCollapsed()?Wn(e):Vn(e),e.focus(),e.selection.moveToBookmark(t)}))})(e)))})(e),(e=>{const t=e.options.register;t("typography_rules",{processor:"string[]"}),t("typography_langs",{processor:G,default:F}),t("typography_ignore",{processor:"string[]",default:[]}),t("typography_default_lang",{processor:"string",default:Q})})(e),(e=>{const t=V(e),n=t=>{t.isEnabled()&&e.execCommand("mceTypography")};if(t.length<=1)e.ui.registry.addButton("typography",{icon:"typography",tooltip:"Typography",onAction:n,onSetup:Kn(e)}),e.ui.registry.addMenuItem("typography",{icon:"typography",text:"Typography",onAction:n,onSetup:Kn(e)});else{const r=t=>t===Z(e),a=t=>{(e=>{tinymce.util.LocalStorage.setItem(Y,e)})(t),e.execCommand("mceTypography")};e.ui.registry.addSplitButton("typography",{icon:"typography",tooltip:"Typography",onAction:n,select:r,onSetup:Kn(e),onItemAction:(e,t)=>a(t),fetch:e=>e(v(t,(e=>({value:e,type:"choiceitem",text:_[e]}))))}),e.ui.registry.addNestedMenuItem("typography",{icon:"typography",text:"Typography",onSetup:Kn(e),getSubmenuItems:()=>[{type:"menuitem",text:"Enhance",onAction:n},{type:"nestedmenuitem",text:"Language",getSubmenuItems:()=>v(t,(e=>({active:r(e),type:"togglemenuitem",text:_[e],onAction:()=>a(e)})))}]})}})(e))}))}(); |