string-remove-widows 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.0.2](https://github.com/codsen/codsen/compare/string-remove-widows@4.0.1...string-remove-widows@4.0.2) (2022-12-06)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package string-remove-widows
|
|
9
|
+
|
|
6
10
|
## 4.0.0 (2022-12-01)
|
|
7
11
|
|
|
8
12
|
### BREAKING CHANGES
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name string-remove-widows
|
|
3
|
+
* @fileoverview Helps to prevent widow words in a text
|
|
4
|
+
* @version 4.0.2
|
|
5
|
+
* @author Roy Revelt, Codsen Ltd
|
|
6
|
+
* @license MIT
|
|
7
|
+
* {@link https://codsen.com/os/string-remove-widows/}
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import{matchRightIncl as ee}from"string-match-left-right";import{left as N,right as D}from"string-left-right";import{Ranges as te}from"ranges-push";import{rApply as K}from"ranges-apply";var R="4.0.2";var h="\xA0",E=" ",S="\\00A0",w="\\u00A0",j="\u2013",M="–",J="\\2013",U="\\u2013",k="\u2014",I="—",B="\\2014",_="\\u2014",C=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],q=[{heads:"{{",tails:"}}"}],P=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],G=["abbr","address","area","article","aside","audio","base","bdi","bdo","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","param","picture","pre","progress","rb","rp","rt","rtc","ruby","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul","var","video","wbr","xml"];var $e=R,ne={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};function ce(t,f){let Z=Date.now();if(typeof t!="string")throw t===void 0?new Error("string-remove-widows: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`string-remove-widows: [THROW_ID_02] the first input argument must be string! It was given as "${typeof t}", equal to:
|
|
11
|
+
${JSON.stringify(t,null,4)}`);if(f&&typeof f!="object")throw new Error(`string-remove-widows: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof f}, equal to ${JSON.stringify(f,null,4)}`);let b=Array.isArray,L=t.length,a=new te({mergeType:2}),Y=["."],z=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,Q=/^[0-9][A-Z]{2}/,V=.06,$,A=0,g=0,W=0,y,T,d,c,r,u,s,p,n={...ne,...f},m={removeWidows:!1,convertEntities:!1};if(!n.ignore||!b(n.ignore)&&typeof n.ignore!="string")n.ignore=[];else if(typeof n.ignore=="string"&&(n.ignore=[n.ignore]),n.ignore.includes("all"))n.ignore=n.ignore.concat(C.concat(P));else if(n.ignore.some(e=>typeof e=="string")){let e=[];n.ignore=n.ignore.filter(i=>typeof i=="string"&&i.length?(["nunjucks","jinja","liquid"].includes(i.trim().toLowerCase())?e=e.concat(C):["hugo"].includes(i.trim().toLowerCase())?e=e.concat(q):["hexo"].includes(i.trim().toLowerCase())&&(e=e.concat(P)),!1):typeof i=="object"),e.length&&(n.ignore=n.ignore.concat(e))}let O;n.reportProgressFunc&&(O=Math.floor(n.reportProgressFuncTo-(n.reportProgressFuncTo-n.reportProgressFuncFrom)*V-n.reportProgressFuncFrom));function v(e,i){let o=h;n.removeWidowPreventionMeasures?o=" ":n.convertEntities&&(o=E,typeof n.targetLanguage=="string"&&(n.targetLanguage.trim().toLowerCase()==="css"?o=S:n.targetLanguage.trim().toLowerCase()==="js"&&(o=w))),t.slice(e,i)!==o&&a.push(e,i,o)}function x(){g=0,W=0,y=void 0,T=void 0,d=void 0,c=void 0,r=void 0,u=void 0}x();for(let e=0;e<=L;e++){if(!s&&b(n.ignore)&&n.ignore.length&&n.ignore.some((o,l)=>{if(b(o.heads)&&o.heads.some(H=>t.startsWith(H,e))||typeof o.heads=="string"&&t.startsWith(o.heads,e))return g+=1,s=n.ignore[l].tails,!0}),!s&&p&&p===e&&(g+=1,p=void 0),typeof n.reportProgressFunc=="function"&&($=n.reportProgressFuncFrom+Math.floor(e/L*(O||1)),$!==A&&(A=$,n.reportProgressFunc($))),!s&&e&&t[e]&&t[e].trim()&&(!t[e-1]||t[e-1]&&!t[e-1].trim())&&(c=e),!s&&t[e]&&t[e].trim()&&(W+=1),!s&&n.hyphens&&(`-${k}${j}`.includes(t[e])||t.startsWith(M,e)||t.startsWith(J,e)||t.startsWith(U,e)||t.startsWith(I,e)||t.startsWith(B,e)||t.startsWith(_,e))&&t[e+1]&&(!t[e+1].trim()||t[e]==="&")&&t[e-1]&&!t[e-1].trim()&&t[N(t,e)]&&(v(N(t,e)+1,e),m.removeWidows=!0),!s&&(t.startsWith(" ",e)||t.startsWith(" ",e))&&(r=e,u=e+6,t[e+6]&&t[e+6].trim()&&(p=e+6),n.convertEntities?(n.targetLanguage==="css"||n.targetLanguage==="js")&&(a.push(e,e+6,n.targetLanguage==="css"?S:w),m.convertEntities=!0):(a.push(e,e+6,h),m.convertEntities=!0)),!s&&t[e+4]&&t[e]==="\\"&&t[e+1]==="0"&&t[e+2]==="0"&&t[e+3].toUpperCase()==="A"&&t[e+4]==="0"&&(r=e,u=e+5,t[e+5]&&t[e+5].trim()&&(p=e+5),n.convertEntities?(n.targetLanguage==="html"||n.targetLanguage==="js")&&(a.push(e,e+5,n.targetLanguage==="html"?E:w),m.convertEntities=!0):(a.push(e,e+5,h),m.convertEntities=!0)),!s&&t[e]==="\\"&&t[e+1]&&t[e+1].toLowerCase()==="u"&&t[e+2]==="0"&&t[e+3]==="0"&&t[e+4]&&t[e+4].toUpperCase()==="A"&&t[e+5]==="0"&&(r=e,u=e+6,t[e+6]&&t[e+6].trim()&&(p=e+6),n.convertEntities?(n.targetLanguage==="html"||n.targetLanguage==="css")&&a.push(e,e+6,n.targetLanguage==="html"?E:S):a.push(e,e+6,h)),!s&&t[e]===h&&(r=e,u=e+1,n.convertEntities&&a.push(e,e+1,n.targetLanguage==="css"?S:n.targetLanguage==="js"?w:E)),!s&&t[e]&&t[e].trim()&&(!t[e-1]||!t[e-1].trim())&&(g+=1),!s&&(!t[e]||`\r
|
|
12
|
+
`.includes(t[e])||(t[e]===`
|
|
13
|
+
`||t[e]==="\r"||t[e]==="\r"&&t[e+1]===`
|
|
14
|
+
`)&&N(t,e)&&Y.includes(t[N(t,e)]))){if((!n.minWordCount||g>=n.minWordCount)&&(!n.minCharCount||W>=n.minCharCount)){let o,l;d!==void 0&&c!==void 0&&r!==void 0&&u!==void 0?d>r?(o=d,l=c):(o=r,l=u):d!==void 0&&c!==void 0?(o=d,l=c):r!==void 0&&u!==void 0&&(o=r,l=u),!(o&&l)&&y&&T&&(o=y,l=T),o&&l&&(v(o,l),m.removeWidows=!0)}x()}n.UKPostcodes&&t[e]&&!t[e].trim()&&t[e-1]&&t[e-1].trim()&&z.test(t.slice(0,e))&&t[D(t,e)]&&Q.test(t.slice(D(t,e)))&&(v(e,D(t,e)),m.removeWidows=!0),!s&&t[e]&&!t[e].trim()&&t[e-1]&&t[e-1].trim()&&(d===void 0||t[d-1]&&t[d-1].trim())&&!"/>".includes(t[D(t,e)])&&!t.slice(0,e).trim().endsWith("br")&&!t.slice(0,e).trim().endsWith("hr")&&!(t.slice(0,e).endsWith("<")&&G.some(o=>t.startsWith(o,D(t,e))))&&(y=d,T=c,d=e,c=void 0,(r!==void 0||u!==void 0)&&(r=void 0,u=void 0));let i;s&&(typeof s=="string"&&(!s.length||t.startsWith(s,e))?s=void 0:b(s)&&(!s.length||s.some(o=>{if(t.startsWith(o,e))return i=o,!0}))&&(s=void 0,e+=i.length,b(n.ignore)&&n.ignore.length&&t[e+1]&&n.ignore.some(o=>ee(t,e,o.tails,{trimBeforeMatching:!0,cb:(l,H,F)=>(F&&(e=F-1,t[e+1]&&t[e+1].trim()&&(g+=1)),!0)})))),t[e]&&`\r
|
|
15
|
+
`.includes(t[e])&&(g=0,W=0),b(n.tagRanges)&&n.tagRanges.length&&n.tagRanges.some(o=>{if(e>=o[0]&&e<=o[1]&&o[1]-1>e)return e=o[1]-1,!0})}return K(t,a.current()).split("").forEach((e,i)=>{}),{res:K(t,a.current(),n.reportProgressFunc?e=>{$=Math.floor((n.reportProgressFuncTo-n.reportProgressFuncFrom)*(1-V)+e/100*(n.reportProgressFuncTo-n.reportProgressFuncFrom)*V),$!==A&&(A=$,n.reportProgressFunc($))}:void 0),ranges:a.current(),log:{timeTakenInMilliseconds:Date.now()-Z},whatWasDone:m}}export{ne as defaults,ce as removeWidows,$e as version};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name string-remove-widows
|
|
3
|
+
* @fileoverview Helps to prevent widow words in a text
|
|
4
|
+
* @version 4.0.2
|
|
5
|
+
* @author Roy Revelt, Codsen Ltd
|
|
6
|
+
* @license MIT
|
|
7
|
+
* {@link https://codsen.com/os/string-remove-widows/}
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";var stringRemoveWidows=(()=>{var tr=Object.create;var k=Object.defineProperty;var rr=Object.getOwnPropertyDescriptor;var nr=Object.getOwnPropertyNames,je=Object.getOwnPropertySymbols,or=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty,sr=Object.prototype.propertyIsEnumerable;var ge=(e,t,r)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,A=(e,t)=>{for(var r in t||(t={}))Le.call(t,r)&&ge(e,r,t[r]);if(je)for(var r of je(t))sr.call(t,r)&&ge(e,r,t[r]);return e};var He=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ir=(e,t)=>{for(var r in t)k(e,r,{get:t[r],enumerable:!0})},Fe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of nr(t))!Le.call(e,l)&&l!==r&&k(e,l,{get:()=>t[l],enumerable:!(n=rr(t,l))||n.enumerable});return e};var Ve=(e,t,r)=>(r=e!=null?tr(or(e)):{},Fe(t||!e||!e.__esModule?k(r,"default",{value:e,enumerable:!0}):r,e)),ar=e=>Fe(k({},"__esModule",{value:!0}),e);var fe=(e,t,r)=>(ge(e,typeof t!="symbol"?t+"":t,r),r);var Ke=He((ho,Ge)=>{var gr="[object Object]";function fr(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function dr(e,t){return function(r){return e(t(r))}}var hr=Function.prototype,ke=Object.prototype,qe=hr.toString,pr=ke.hasOwnProperty,mr=qe.call(Object),$r=ke.toString,br=dr(Object.getPrototypeOf,Object);function yr(e){return!!e&&typeof e=="object"}function wr(e){if(!yr(e)||$r.call(e)!=gr||fr(e))return!1;var t=br(e);if(t===null)return!0;var r=pr.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&qe.call(r)==mr}Ge.exports=wr});var jt=He((q,H)=>{var Er=200,it="__lodash_hash_undefined__",at=9007199254740991,we="[object Arguments]",Tr="[object Array]",lt="[object Boolean]",ut="[object Date]",Ar="[object Error]",Ee="[object Function]",ct="[object GeneratorFunction]",te="[object Map]",gt="[object Number]",Te="[object Object]",Ze="[object Promise]",ft="[object RegExp]",re="[object Set]",dt="[object String]",ht="[object Symbol]",he="[object WeakMap]",pt="[object ArrayBuffer]",ne="[object DataView]",mt="[object Float32Array]",$t="[object Float64Array]",bt="[object Int8Array]",yt="[object Int16Array]",wt="[object Int32Array]",Et="[object Uint8Array]",Tt="[object Uint8ClampedArray]",At="[object Uint16Array]",vt="[object Uint32Array]",vr=/[\\^$.*+?()[\]{}|]/g,Sr=/\w*$/,_r=/^\[object .+?Constructor\]$/,Or=/^(?:0|[1-9]\d*)$/,T={};T[we]=T[Tr]=T[pt]=T[ne]=T[lt]=T[ut]=T[mt]=T[$t]=T[bt]=T[yt]=T[wt]=T[te]=T[gt]=T[Te]=T[ft]=T[re]=T[dt]=T[ht]=T[Et]=T[Tt]=T[At]=T[vt]=!0;T[Ar]=T[Ee]=T[he]=!1;var Nr=typeof global=="object"&&global&&global.Object===Object&&global,Cr=typeof self=="object"&&self&&self.Object===Object&&self,W=Nr||Cr||Function("return this")(),St=typeof q=="object"&&q&&!q.nodeType&&q,Ye=St&&typeof H=="object"&&H&&!H.nodeType&&H,Wr=Ye&&Ye.exports===St;function Dr(e,t){return e.set(t[0],t[1]),e}function Rr(e,t){return e.add(t),e}function Ir(e,t){for(var r=-1,n=e?e.length:0;++r<n&&t(e[r],r,e)!==!1;);return e}function Mr(e,t){for(var r=-1,n=t.length,l=e.length;++r<n;)e[l+r]=t[r];return e}function _t(e,t,r,n){var l=-1,o=e?e.length:0;for(n&&o&&(r=e[++l]);++l<o;)r=t(r,e[l],l,e);return r}function xr(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}function jr(e,t){return e==null?void 0:e[t]}function Ot(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function Xe(e){var t=-1,r=Array(e.size);return e.forEach(function(n,l){r[++t]=[l,n]}),r}function Ae(e,t){return function(r){return e(t(r))}}function ze(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var Lr=Array.prototype,Hr=Function.prototype,oe=Object.prototype,de=W["__core-js_shared__"],Qe=function(){var e=/[^.]+$/.exec(de&&de.keys&&de.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Nt=Hr.toString,R=oe.hasOwnProperty,se=oe.toString,Fr=RegExp("^"+Nt.call(R).replace(vr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),et=Wr?W.Buffer:void 0,tt=W.Symbol,rt=W.Uint8Array,Vr=Ae(Object.getPrototypeOf,Object),Pr=Object.create,Jr=oe.propertyIsEnumerable,Br=Lr.splice,nt=Object.getOwnPropertySymbols,Ur=et?et.isBuffer:void 0,kr=Ae(Object.keys,Object),pe=P(W,"DataView"),G=P(W,"Map"),me=P(W,"Promise"),$e=P(W,"Set"),be=P(W,"WeakMap"),K=P(Object,"create"),qr=L(pe),Gr=L(G),Kr=L(me),Zr=L($e),Yr=L(be),ot=tt?tt.prototype:void 0,st=ot?ot.valueOf:void 0;function j(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Xr(){this.__data__=K?K(null):{}}function zr(e){return this.has(e)&&delete this.__data__[e]}function Qr(e){var t=this.__data__;if(K){var r=t[e];return r===it?void 0:r}return R.call(t,e)?t[e]:void 0}function en(e){var t=this.__data__;return K?t[e]!==void 0:R.call(t,e)}function tn(e,t){var r=this.__data__;return r[e]=K&&t===void 0?it:t,this}j.prototype.clear=Xr;j.prototype.delete=zr;j.prototype.get=Qr;j.prototype.has=en;j.prototype.set=tn;function D(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function rn(){this.__data__=[]}function nn(e){var t=this.__data__,r=ie(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():Br.call(t,r,1),!0}function on(e){var t=this.__data__,r=ie(t,e);return r<0?void 0:t[r][1]}function sn(e){return ie(this.__data__,e)>-1}function an(e,t){var r=this.__data__,n=ie(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}D.prototype.clear=rn;D.prototype.delete=nn;D.prototype.get=on;D.prototype.has=sn;D.prototype.set=an;function F(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function ln(){this.__data__={hash:new j,map:new(G||D),string:new j}}function un(e){return ae(this,e).delete(e)}function cn(e){return ae(this,e).get(e)}function gn(e){return ae(this,e).has(e)}function fn(e,t){return ae(this,e).set(e,t),this}F.prototype.clear=ln;F.prototype.delete=un;F.prototype.get=cn;F.prototype.has=gn;F.prototype.set=fn;function V(e){this.__data__=new D(e)}function dn(){this.__data__=new D}function hn(e){return this.__data__.delete(e)}function pn(e){return this.__data__.get(e)}function mn(e){return this.__data__.has(e)}function $n(e,t){var r=this.__data__;if(r instanceof D){var n=r.__data__;if(!G||n.length<Er-1)return n.push([e,t]),this;r=this.__data__=new F(n)}return r.set(e,t),this}V.prototype.clear=dn;V.prototype.delete=hn;V.prototype.get=pn;V.prototype.has=mn;V.prototype.set=$n;function bn(e,t){var r=Se(e)||Jn(e)?xr(e.length,String):[],n=r.length,l=!!n;for(var o in e)(t||R.call(e,o))&&!(l&&(o=="length"||Hn(o,n)))&&r.push(o);return r}function Ct(e,t,r){var n=e[t];(!(R.call(e,t)&&It(n,r))||r===void 0&&!(t in e))&&(e[t]=r)}function ie(e,t){for(var r=e.length;r--;)if(It(e[r][0],t))return r;return-1}function yn(e,t){return e&&Wt(t,_e(t),e)}function ye(e,t,r,n,l,o,u){var a;if(n&&(a=o?n(e,l,o,u):n(e)),a!==void 0)return a;if(!le(e))return e;var g=Se(e);if(g){if(a=xn(e),!t)return Rn(e,a)}else{var i=x(e),h=i==Ee||i==ct;if(Un(e))return Sn(e,t);if(i==Te||i==we||h&&!o){if(Ot(e))return o?e:{};if(a=jn(h?{}:e),!t)return In(e,yn(a,e))}else{if(!T[i])return o?e:{};a=Ln(e,i,ye,t)}}u||(u=new V);var $=u.get(e);if($)return $;if(u.set(e,a),!g)var p=r?Mn(e):_e(e);return Ir(p||e,function(f,d){p&&(d=f,f=e[d]),Ct(a,d,ye(f,t,r,n,d,e,u))}),a}function wn(e){return le(e)?Pr(e):{}}function En(e,t,r){var n=t(e);return Se(e)?n:Mr(n,r(e))}function Tn(e){return se.call(e)}function An(e){if(!le(e)||Vn(e))return!1;var t=xt(e)||Ot(e)?Fr:_r;return t.test(L(e))}function vn(e){if(!Rt(e))return kr(e);var t=[];for(var r in Object(e))R.call(e,r)&&r!="constructor"&&t.push(r);return t}function Sn(e,t){if(t)return e.slice();var r=new e.constructor(e.length);return e.copy(r),r}function ve(e){var t=new e.constructor(e.byteLength);return new rt(t).set(new rt(e)),t}function _n(e,t){var r=t?ve(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}function On(e,t,r){var n=t?r(Xe(e),!0):Xe(e);return _t(n,Dr,new e.constructor)}function Nn(e){var t=new e.constructor(e.source,Sr.exec(e));return t.lastIndex=e.lastIndex,t}function Cn(e,t,r){var n=t?r(ze(e),!0):ze(e);return _t(n,Rr,new e.constructor)}function Wn(e){return st?Object(st.call(e)):{}}function Dn(e,t){var r=t?ve(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Rn(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}function Wt(e,t,r,n){r||(r={});for(var l=-1,o=t.length;++l<o;){var u=t[l],a=n?n(r[u],e[u],u,r,e):void 0;Ct(r,u,a===void 0?e[u]:a)}return r}function In(e,t){return Wt(e,Dt(e),t)}function Mn(e){return En(e,_e,Dt)}function ae(e,t){var r=e.__data__;return Fn(t)?r[typeof t=="string"?"string":"hash"]:r.map}function P(e,t){var r=jr(e,t);return An(r)?r:void 0}var Dt=nt?Ae(nt,Object):Gn,x=Tn;(pe&&x(new pe(new ArrayBuffer(1)))!=ne||G&&x(new G)!=te||me&&x(me.resolve())!=Ze||$e&&x(new $e)!=re||be&&x(new be)!=he)&&(x=function(e){var t=se.call(e),r=t==Te?e.constructor:void 0,n=r?L(r):void 0;if(n)switch(n){case qr:return ne;case Gr:return te;case Kr:return Ze;case Zr:return re;case Yr:return he}return t});function xn(e){var t=e.length,r=e.constructor(t);return t&&typeof e[0]=="string"&&R.call(e,"index")&&(r.index=e.index,r.input=e.input),r}function jn(e){return typeof e.constructor=="function"&&!Rt(e)?wn(Vr(e)):{}}function Ln(e,t,r,n){var l=e.constructor;switch(t){case pt:return ve(e);case lt:case ut:return new l(+e);case ne:return _n(e,n);case mt:case $t:case bt:case yt:case wt:case Et:case Tt:case At:case vt:return Dn(e,n);case te:return On(e,n,r);case gt:case dt:return new l(e);case ft:return Nn(e);case re:return Cn(e,n,r);case ht:return Wn(e)}}function Hn(e,t){return t=t==null?at:t,!!t&&(typeof e=="number"||Or.test(e))&&e>-1&&e%1==0&&e<t}function Fn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Vn(e){return!!Qe&&Qe in e}function Rt(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||oe;return e===r}function L(e){if(e!=null){try{return Nt.call(e)}catch(t){}try{return e+""}catch(t){}}return""}function Pn(e){return ye(e,!0,!0)}function It(e,t){return e===t||e!==e&&t!==t}function Jn(e){return Bn(e)&&R.call(e,"callee")&&(!Jr.call(e,"callee")||se.call(e)==we)}var Se=Array.isArray;function Mt(e){return e!=null&&kn(e.length)&&!xt(e)}function Bn(e){return qn(e)&&Mt(e)}var Un=Ur||Kn;function xt(e){var t=le(e)?se.call(e):"";return t==Ee||t==ct}function kn(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=at}function le(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function qn(e){return!!e&&typeof e=="object"}function _e(e){return Mt(e)?bn(e):vn(e)}function Gn(){return[]}function Kn(){return!1}H.exports=Pn});var ao={};ir(ao,{defaults:()=>er,removeWidows:()=>io,version:()=>so});function Pe(e){return typeof e!="string"?e:e.length?[e]:[]}function Je(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ee(e){return typeof e=="string"}var Be={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},lr=e=>e+1;function ur(e,t,r,n,l=!1,o=lr){let u=typeof r=="function"?r():r;if(+t<0&&l&&u==="EOL")return u;let a=A(A({},Be),n);if(t>=e.length&&!l)return!1;let g=l?1:r.length,i=0,h=!1,$=!1,p=!1,f=a.maxMismatches,d=t,S=!1,y=!1,v=!1;function w(){return i===1&&f<a.maxMismatches-1}for(;e[d];){let b=o(d);if(a.trimBeforeMatching&&e[d].trim()===""){if(!e[b]&&l&&r==="EOL")return!0;d=o(d);continue}if(a&&!a.i&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.includes(e[d])||(a==null?void 0:a.i)&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.map(_=>_.toLowerCase()).includes(e[d].toLowerCase())){if(l&&r==="EOL"&&!e[b])return!0;d=o(d);continue}let E=b>d?r[r.length-g]:r[g-1];if(!a.i&&e[d]===E||a.i&&e[d].toLowerCase()===E.toLowerCase()){if(S||(S=!0),p||(p=!0),g===r.length){if(y=!0,f!==a.maxMismatches)return!1}else g===1&&(v=!0);if(g-=1,i++,w())return!1;if(!g)return i!==r.length||f===a.maxMismatches||!h?d:!1}else if(!h&&!i&&(h=!0),a.maxMismatches&&f&&d){f-=1;for(let _=0;_<=f;_++){let c=b>d?r[r.length-g+1+_]:r[g-2-_],N=e[o(d)];if(c&&(!a.i&&e[d]===c||a.i&&e[d].toLowerCase()===c.toLowerCase())&&(!a.firstMustMatch||g!==r.length)){if(i++,w())return!1;g-=2,S=!0;break}else if(N&&c&&(!a.i&&N===c||a.i&&N.toLowerCase()===c.toLowerCase())&&(!a.firstMustMatch||g!==r.length)){if(!i&&!a.hungry)return!1;g-=1,S=!0;break}else if(c===void 0&&f>=0&&S&&(!a.firstMustMatch||y)&&(!a.lastMustMatch||v))return d}S||($=d)}else return d===0&&g===1&&!a.lastMustMatch&&p?0:!1;if($!==!1&&$!==d&&($=!1),g<1)return d;d=o(d)}if(g>0)return l&&u==="EOL"?!0:a&&a.maxMismatches>=g&&p?$||0:!1}function cr(e,t,r,n,l){var h,$;if(Je(l)&&Object.prototype.hasOwnProperty.call(l,"trimBeforeMatching")&&l&&typeof l.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${e}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(l.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let o=A(A({},Be),l);if(typeof o.trimCharsBeforeMatching=="string"&&(o.trimCharsBeforeMatching=Pe(o.trimCharsBeforeMatching)),o.trimCharsBeforeMatching=o.trimCharsBeforeMatching.map(p=>ee(p)?p:String(p)),!ee(t)||!t.length)return!1;if(!Number.isInteger(r)||r<0)throw new Error(`string-match-left-right/${e}(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ${typeof r}, equal to:
|
|
11
|
+
${JSON.stringify(r,null,4)}`);let u,a;if(ee(n))u=[n];else if(Array.isArray(n))u=n;else if(!n)u=n;else if(typeof n=="function")u=[],u.push(n);else throw new Error(`string-match-left-right/${e}(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's ${typeof n}, equal to:
|
|
12
|
+
${JSON.stringify(n,null,4)}`);if(l&&!Je(l))throw new Error(`string-match-left-right/${e}(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type "${typeof l}", and equal to:
|
|
13
|
+
${JSON.stringify(l,null,4)}`);let g=0,i="";if((o==null?void 0:o.trimCharsBeforeMatching)&&o.trimCharsBeforeMatching.some((p,f)=>p.length>1?(g=f,i=p,!0):!1))throw new Error(`string-match-left-right/${e}(): [THROW_ID_07] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ${g} is longer than 1 character, ${i.length} (equals to ${i}). Please split it into separate characters and put into array as separate elements.`);if(!u||!Array.isArray(u)||Array.isArray(u)&&!u.length||Array.isArray(u)&&u.length===1&&ee(u[0])&&!u[0].trim()){if(typeof o.cb=="function"){let f,d=r;if((e==="matchLeftIncl"||e==="matchRight")&&(d+=1),e[5]==="L")for(let w=d;w--;){let b=t[w];if((!o.trimBeforeMatching||o.trimBeforeMatching&&b!==void 0&&b.trim())&&(!((h=o.trimCharsBeforeMatching)!=null&&h.length)||b!==void 0&&!o.trimCharsBeforeMatching.includes(b))){f=w;break}}else if(e.startsWith("matchRight"))for(let w=d;w<t.length;w++){let b=t[w];if((!o.trimBeforeMatching||o.trimBeforeMatching&&b.trim())&&(!(($=o.trimCharsBeforeMatching)!=null&&$.length)||!o.trimCharsBeforeMatching.includes(b))){f=w;break}}if(f===void 0)return!1;let S=t[f],y=f+1,v="";return y&&y>0&&(v=t.slice(0,y)),e[5]==="L"||f&&f>0&&(v=t.slice(f)),o.cb(S,v,f)}let p="";throw l||(p=" More so, the whole options object, the fourth input argument, is missing!"),new Error(`string-match-left-right/${e}(): [THROW_ID_08] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!${p}`)}for(let p=0,f=u.length;p<f;p++){a=typeof u[p]=="function";let d=u[p],S,y,v="",w=r;e==="matchRight"?w+=1:e==="matchLeft"&&(w-=1);let b=ur(t,w,d,o,a,E=>e[5]==="L"?E-1:E+1);if(b&&a&&typeof d=="function"&&d()==="EOL")return d()&&(o.cb?o.cb(S,v,y):!0)?d():!1;if(Number.isInteger(b)&&(y=e.startsWith("matchLeft")?b-1:b+1,e[5]==="L"?v=t.slice(0,b):v=t.slice(y)),y<0&&(y=void 0),t[y]&&(S=t[y]),Number.isInteger(b)&&(o.cb?o.cb(S,v,y):!0))return d}return!1}function Ue(e,t,r,n){return cr("matchRightIncl",e,t,r,n)}var Zn=Ve(Ke(),1),Yn=Ve(jt(),1);var J="\xA0";function Xn({str:e,idx:t=0,stopAtNewlines:r=!1,stopAtRawNbsp:n=!1}){if(typeof e!="string"||!e.length||((!t||typeof t!="number")&&(t=0),!e[t+1]))return null;if(e[t+1]&&(e[t+1].trim()||r&&`
|
|
14
|
+
\r`.includes(e[t+1])||n&&e[t+1]===J))return t+1;if(e[t+2]&&(e[t+2].trim()||r&&`
|
|
15
|
+
\r`.includes(e[t+2])||n&&e[t+2]===J))return t+2;for(let l=t+1,o=e.length;l<o;l++)if(e[l].trim()||r&&`
|
|
16
|
+
\r`.includes(e[l])||n&&e[l]===J)return l;return null}function B(e,t=0){return Xn({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function zn({str:e,idx:t,stopAtNewlines:r,stopAtRawNbsp:n}){if(typeof e!="string"||!e.length||((!t||typeof t!="number")&&(t=0),t<1))return null;if(e[~-t]&&(e[~-t].trim()||r&&`
|
|
17
|
+
\r`.includes(e[~-t])||n&&e[~-t]===J))return~-t;if(e[t-2]&&(e[t-2].trim()||r&&`
|
|
18
|
+
\r`.includes(e[t-2])||n&&e[t-2]===J))return t-2;for(let l=t;l--;)if(e[l]&&(e[l].trim()||r&&`
|
|
19
|
+
\r`.includes(e[l])||n&&e[l]===J))return l;return null}function Z(e,t=0){return zn({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function ue(e,t=1){let r="\xA0";function n(o){return Array.from(o).reverse().join("")}function l(o,u,a){let g=a?`
|
|
20
|
+
`:"\r",i=a?"\r":`
|
|
21
|
+
`;if(!o)return o;let h=0,$=0,p="";for(let f=0,d=o.length;f<d;f++)(o[f]===g||o[f]===i&&o[f-1]!==g)&&$++,`\r
|
|
22
|
+
`.includes(o[f])||o[f]===r?(h=0,o[f]===r?p+=o[f]:o[f]===g?$<=u&&(p+=o[f],o[f+1]===i&&(p+=o[f+1],f++)):o[f]===i&&(o==null?void 0:o[f-1])!==g&&$<=u&&(p+=o[f])):(h++,!o[f+1]&&!$&&(p+=" "));return p}if(typeof e=="string"&&e.length){let o=1;typeof+t=="number"&&Number.isInteger(+t)&&+t>=0&&(o=+t);let u="",a="";if(!e.trim())u=e;else if(!e[0].trim()){for(let g=0,i=e.length;g<i;g++)if(e[g].trim()){u=e.slice(0,g);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===r)){for(let g=e.length;g--;)if(e[g].trim()){a=e.slice(g+1);break}}return`${l(u,o,!1)}${e.trim()}${n(l(n(a),o,!0))}`}return e}var Qn={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function Lt(e,t){if(!Array.isArray(e)||!e.length)return e;let r=A(A({},Qn),t),n,l;if(r.strictlyTwoElementsInRangeArrays&&!e.every((a,g)=>!Array.isArray(a)||a.length!==2?(n=g,l=a.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) has not two but ${l} elements!`);if(!e.every((a,g)=>!Array.isArray(a)||!Number.isInteger(a[0])||a[0]<0||!Number.isInteger(a[1])||a[1]<0?(n=g,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) does not consist of only natural numbers!`);let o=e.length**2,u=0;return Array.from(e).sort((a,g)=>(r.progressFn&&(u+=1,r.progressFn(Math.floor(u*100/o))),a[0]===g[0]?a[1]<g[1]?-1:a[1]>g[1]?1:0:a[0]<g[0]?-1:1))}var Ht={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function eo(e,t){function r(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}if(!Array.isArray(e)||!e.length)return null;let n;if(t)if(r(t)){if(n=A(A({},Ht),t),n.progressFn&&r(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&typeof n.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] resolvedOpts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(![1,2,"1","2"].includes(n.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] resolvedOpts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if(typeof n.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] resolvedOpts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
|
|
23
|
+
${JSON.stringify(t,null,4)} (type ${typeof t})`);else n=A({},Ht);let l=e.filter(i=>Array.isArray(i)).map(i=>[...i]).filter(i=>i[2]!==void 0||i[0]!==i[1]),o,u,a;n.progressFn?o=Lt(l,{progressFn:i=>{a=Math.floor(i/5),a!==u&&(u=a,n.progressFn(a))}}):o=Lt(l);let g=o.length-1;for(let i=g;i>0;i--)n.progressFn&&(a=Math.floor((1-i/g)*78)+21,a!==u&&a>u&&(u=a,n.progressFn(a))),(o[i][0]<=o[i-1][0]||!n.joinRangesThatTouchEdges&&o[i][0]<o[i-1][1]||n.joinRangesThatTouchEdges&&o[i][0]<=o[i-1][1])&&(o[i-1][0]=Math.min(o[i][0],o[i-1][0]),o[i-1][1]=Math.max(o[i][1],o[i-1][1]),o[i][2]!==void 0&&(o[i-1][0]>=o[i][0]||o[i-1][1]<=o[i][1])&&o[i-1][2]!==null&&(o[i][2]===null&&o[i-1][2]!==null?o[i-1][2]=null:o[i-1][2]!=null?+n.mergeType==2&&o[i-1][0]===o[i][0]?o[i-1][2]=o[i][2]:o[i-1][2]+=o[i][2]:o[i-1][2]=o[i][2]),o.splice(i,1),i=o.length);return o.length?o:null}function I(e){return e!=null}function M(e){return Number.isInteger(e)&&e>=0}function Y(e){return typeof e=="string"}var to={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},Ft=class{constructor(e){fe(this,"ranges");fe(this,"opts");let t=A(A({},to),e);if(t.mergeType&&t.mergeType!==1&&t.mergeType!==2)if(Y(t.mergeType)&&t.mergeType.trim()==="1")t.mergeType=1;else if(Y(t.mergeType)&&t.mergeType.trim()==="2")t.mergeType=2;else throw new Error(`ranges-push: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof t.mergeType}", equal to ${JSON.stringify(t.mergeType,null,4)}`);this.opts=t,this.ranges=[]}add(e,t,r){var o;if(e==null&&t==null)return;if(I(e)&&!I(t)){if(Array.isArray(e)){if(e.length){if(e.some(u=>Array.isArray(u))){e.forEach(u=>{Array.isArray(u)&&this.add(...u)});return}e.length&&M(+e[0])&&M(+e[1])&&this.add(...e)}return}throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set (${JSON.stringify(e,null,0)}) but second-one, "to" is not (${JSON.stringify(t,null,0)})`)}else if(!I(e)&&I(t))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(t,null,0)}) but first-one, "from" is not (${JSON.stringify(e,null,0)})`);let n=+e,l=+t;if(M(r)&&(r=String(r)),M(n)&&M(l)){if(I(r)&&!Y(r)&&!M(r))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof r}, equal to:
|
|
24
|
+
${JSON.stringify(r,null,4)}`);if(I(this.ranges)&&Array.isArray(this.last())&&n===this.last()[1]){if(this.last()[1]=l,this.last()[2],this.last()[2]!==null&&I(r)){let u=this.last()[2]&&this.last()[2].length&&(!((o=this.opts)!=null&&o.mergeType)||this.opts.mergeType===1)?`${this.last()[2]}${r}`:r;this.opts.limitToBeAddedWhitespace&&(u=ue(u,this.opts.limitLinebreaksCount)),Y(u)&&!u.length||(this.last()[2]=u)}}else{this.ranges||(this.ranges=[]);let u=r!==void 0&&!(Y(r)&&!r.length)?[n,l,r&&this.opts.limitToBeAddedWhitespace?ue(r,this.opts.limitLinebreaksCount):r]:[n,l];this.ranges.push(u)}}else throw M(n)&&n>=0?new TypeError(`ranges-push/Ranges/add(): [THROW_ID_10] "to" value, the second input argument, must be a natural number or zero! Currently it's of a type "${typeof l}" equal to: ${JSON.stringify(l,null,4)}`):new TypeError(`ranges-push/Ranges/add(): [THROW_ID_09] "from" value, the first input argument, must be a natural number or zero! Currently it's of a type "${typeof n}" equal to: ${JSON.stringify(n,null,4)}`)}push(e,t,r){this.add(e,t,r)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=eo(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>I(e[2])?[e[0],e[1],ue(e[2],this.opts.limitLinebreaksCount)]:e):this.ranges):null}wipe(){this.ranges=[]}replace(e){if(Array.isArray(e)&&e.length)if(Array.isArray(e[0])&&M(e[0][0]))this.ranges=Array.from(e);else throw new Error(`ranges-push/Ranges/replace(): [THROW_ID_11] Single range was given but we expected array of arrays! The first element, ${JSON.stringify(e[0],null,4)} should be an array and its first element should be an integer, a string index.`);else this.ranges=[]}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}};var ro={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function Oe(e,t){if(!Array.isArray(e)||!e.length)return e;let r=A(A({},ro),t),n,l;if(r.strictlyTwoElementsInRangeArrays&&!e.every((a,g)=>!Array.isArray(a)||a.length!==2?(n=g,l=a.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) has not two but ${l} elements!`);if(!e.every((a,g)=>!Array.isArray(a)||!Number.isInteger(a[0])||a[0]<0||!Number.isInteger(a[1])||a[1]<0?(n=g,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${n}th range (${JSON.stringify(e[n],null,4)}) does not consist of only natural numbers!`);let o=e.length**2,u=0;return Array.from(e).sort((a,g)=>(r.progressFn&&(u+=1,r.progressFn(Math.floor(u*100/o))),a[0]===g[0]?a[1]<g[1]?-1:a[1]>g[1]?1:0:a[0]<g[0]?-1:1))}var Vt={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Pt(e,t){function r(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}if(!Array.isArray(e)||!e.length)return null;let n;if(t)if(r(t)){if(n=A(A({},Vt),t),n.progressFn&&r(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&typeof n.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(![1,2,"1","2"].includes(n.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if(typeof n.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
|
|
25
|
+
${JSON.stringify(t,null,4)} (type ${typeof t})`);else n=A({},Vt);let l=e.filter(i=>Array.isArray(i)).map(i=>[...i]).filter(i=>i[2]!==void 0||i[0]!==i[1]),o,u,a;n.progressFn?o=Oe(l,{progressFn:i=>{a=Math.floor(i/5),a!==u&&(u=a,n.progressFn(a))}}):o=Oe(l);let g=o.length-1;for(let i=g;i>0;i--)n.progressFn&&(a=Math.floor((1-i/g)*78)+21,a!==u&&a>u&&(u=a,n.progressFn(a))),(o[i][0]<=o[i-1][0]||!n.joinRangesThatTouchEdges&&o[i][0]<o[i-1][1]||n.joinRangesThatTouchEdges&&o[i][0]<=o[i-1][1])&&(o[i-1][0]=Math.min(o[i][0],o[i-1][0]),o[i-1][1]=Math.max(o[i][1],o[i-1][1]),o[i][2]!==void 0&&(o[i-1][0]>=o[i][0]||o[i-1][1]<=o[i][1])&&o[i-1][2]!==null&&(o[i][2]===null&&o[i-1][2]!==null?o[i-1][2]=null:o[i-1][2]!=null?+n.mergeType==2&&o[i-1][0]===o[i][0]?o[i-1][2]=o[i][2]:o[i-1][2]+=o[i][2]:o[i-1][2]=o[i][2]),o.splice(i,1),i=o.length);return o.length?o:null}var no=!0,Ne="Invariant failed";function Jt(e,t){if(!e){if(no)throw new Error(Ne);var r=typeof t=="function"?t():t,n=r?"".concat(Ne,": ").concat(r):Ne;throw new Error(n)}}function Ce(e,t,r){let n=0,l=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof e!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(t&&!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(r&&typeof r!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!t||!t.filter(h=>h).length)return e;let o;Array.isArray(t)&&Number.isInteger(t[0])&&Number.isInteger(t[1])?o=[Array.from(t)]:o=Array.from(t);let u=o.length,a=0;o.filter(h=>h).forEach((h,$)=>{if(r&&(n=Math.floor(a/u*10),n!==l&&(l=n,r(n))),!Array.isArray(h))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${$}th element not an array: ${JSON.stringify(h,null,4)}, which is ${typeof h}`);if(!Number.isInteger(h[0])){if(!Number.isInteger(+h[0])||+h[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${$}th element, array ${JSON.stringify(h,null,0)}. Its first element is not an integer, string index, but ${typeof h[0]}, equal to: ${JSON.stringify(h[0],null,4)}.`);o[$][0]=+o[$][0]}if(!Number.isInteger(h[1])){if(!Number.isInteger(+h[1])||+h[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${$}th element, array ${JSON.stringify(h,null,0)}. Its second element is not an integer, string index, but ${typeof h[1]}, equal to: ${JSON.stringify(h[1],null,4)}.`);o[$][1]=+o[$][1]}a+=1});let g=Pt(o,{progressFn:h=>{r&&(n=10+Math.floor(h/10),n!==l&&(l=n,r(n)))}});Jt(g);let i=g.length;if(i>0){let h=e.slice(g[i-1][1]);e=g.reduce(($,p,f,d)=>{r&&(n=20+Math.floor(f/i*80),n!==l&&(l=n,r(n)));let S=f===0?0:d[f-1][1],y=d[f][0];return`${$}${e.slice(S,y)}${d[f][2]||""}`},""),e+=h}return e}var Bt="4.0.2";var U="\xA0",X=" ",z="\\00A0",Q="\\u00A0",Ut="\u2013",kt="–",qt="\\2013",Gt="\\u2013",Kt="\u2014",Zt="—",Yt="\\2014",Xt="\\u2014",We=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],zt=[{heads:"{{",tails:"}}"}],De=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],Qt=["abbr","address","area","article","aside","audio","base","bdi","bdo","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","param","picture","pre","progress","rb","rp","rt","rtc","ruby","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul","var","video","wbr","xml"];var so=Bt,er={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};function io(e,t){let r=Date.now();if(typeof e!="string")throw e===void 0?new Error("string-remove-widows: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`string-remove-widows: [THROW_ID_02] the first input argument must be string! It was given as "${typeof e}", equal to:
|
|
26
|
+
${JSON.stringify(e,null,4)}`);if(t&&typeof t!="object")throw new Error(`string-remove-widows: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof t}, equal to ${JSON.stringify(t,null,4)}`);let n=Array.isArray,l=e.length,o=new Ft({mergeType:2}),u=["."],a=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,g=/^[0-9][A-Z]{2}/,i=.06,h,$=0,p=0,f=0,d,S,y,v,w,b,E,_,c=A(A({},er),t),N={removeWidows:!1,convertEntities:!1};if(!c.ignore||!n(c.ignore)&&typeof c.ignore!="string")c.ignore=[];else if(typeof c.ignore=="string"&&(c.ignore=[c.ignore]),c.ignore.includes("all"))c.ignore=c.ignore.concat(We.concat(De));else if(c.ignore.some(s=>typeof s=="string")){let s=[];c.ignore=c.ignore.filter(O=>typeof O=="string"&&O.length?(["nunjucks","jinja","liquid"].includes(O.trim().toLowerCase())?s=s.concat(We):["hugo"].includes(O.trim().toLowerCase())?s=s.concat(zt):["hexo"].includes(O.trim().toLowerCase())&&(s=s.concat(De)),!1):typeof O=="object"),s.length&&(c.ignore=c.ignore.concat(s))}let Re;c.reportProgressFunc&&(Re=Math.floor(c.reportProgressFuncTo-(c.reportProgressFuncTo-c.reportProgressFuncFrom)*i-c.reportProgressFuncFrom));function ce(s,O){let m=U;c.removeWidowPreventionMeasures?m=" ":c.convertEntities&&(m=X,typeof c.targetLanguage=="string"&&(c.targetLanguage.trim().toLowerCase()==="css"?m=z:c.targetLanguage.trim().toLowerCase()==="js"&&(m=Q))),e.slice(s,O)!==m&&o.push(s,O,m)}function Ie(){p=0,f=0,d=void 0,S=void 0,y=void 0,v=void 0,w=void 0,b=void 0}Ie();for(let s=0;s<=l;s++){if(!E&&n(c.ignore)&&c.ignore.length&&c.ignore.some((m,C)=>{if(n(m.heads)&&m.heads.some(Me=>e.startsWith(Me,s))||typeof m.heads=="string"&&e.startsWith(m.heads,s))return p+=1,E=c.ignore[C].tails,!0}),!E&&_&&_===s&&(p+=1,_=void 0),typeof c.reportProgressFunc=="function"&&(h=c.reportProgressFuncFrom+Math.floor(s/l*(Re||1)),h!==$&&($=h,c.reportProgressFunc(h))),!E&&s&&e[s]&&e[s].trim()&&(!e[s-1]||e[s-1]&&!e[s-1].trim())&&(v=s),!E&&e[s]&&e[s].trim()&&(f+=1),!E&&c.hyphens&&(`-${Kt}${Ut}`.includes(e[s])||e.startsWith(kt,s)||e.startsWith(qt,s)||e.startsWith(Gt,s)||e.startsWith(Zt,s)||e.startsWith(Yt,s)||e.startsWith(Xt,s))&&e[s+1]&&(!e[s+1].trim()||e[s]==="&")&&e[s-1]&&!e[s-1].trim()&&e[Z(e,s)]&&(ce(Z(e,s)+1,s),N.removeWidows=!0),!E&&(e.startsWith(" ",s)||e.startsWith(" ",s))&&(w=s,b=s+6,e[s+6]&&e[s+6].trim()&&(_=s+6),c.convertEntities?(c.targetLanguage==="css"||c.targetLanguage==="js")&&(o.push(s,s+6,c.targetLanguage==="css"?z:Q),N.convertEntities=!0):(o.push(s,s+6,U),N.convertEntities=!0)),!E&&e[s+4]&&e[s]==="\\"&&e[s+1]==="0"&&e[s+2]==="0"&&e[s+3].toUpperCase()==="A"&&e[s+4]==="0"&&(w=s,b=s+5,e[s+5]&&e[s+5].trim()&&(_=s+5),c.convertEntities?(c.targetLanguage==="html"||c.targetLanguage==="js")&&(o.push(s,s+5,c.targetLanguage==="html"?X:Q),N.convertEntities=!0):(o.push(s,s+5,U),N.convertEntities=!0)),!E&&e[s]==="\\"&&e[s+1]&&e[s+1].toLowerCase()==="u"&&e[s+2]==="0"&&e[s+3]==="0"&&e[s+4]&&e[s+4].toUpperCase()==="A"&&e[s+5]==="0"&&(w=s,b=s+6,e[s+6]&&e[s+6].trim()&&(_=s+6),c.convertEntities?(c.targetLanguage==="html"||c.targetLanguage==="css")&&o.push(s,s+6,c.targetLanguage==="html"?X:z):o.push(s,s+6,U)),!E&&e[s]===U&&(w=s,b=s+1,c.convertEntities&&o.push(s,s+1,c.targetLanguage==="css"?z:c.targetLanguage==="js"?Q:X)),!E&&e[s]&&e[s].trim()&&(!e[s-1]||!e[s-1].trim())&&(p+=1),!E&&(!e[s]||`\r
|
|
27
|
+
`.includes(e[s])||(e[s]===`
|
|
28
|
+
`||e[s]==="\r"||e[s]==="\r"&&e[s+1]===`
|
|
29
|
+
`)&&Z(e,s)&&u.includes(e[Z(e,s)]))){if((!c.minWordCount||p>=c.minWordCount)&&(!c.minCharCount||f>=c.minCharCount)){let m,C;y!==void 0&&v!==void 0&&w!==void 0&&b!==void 0?y>w?(m=y,C=v):(m=w,C=b):y!==void 0&&v!==void 0?(m=y,C=v):w!==void 0&&b!==void 0&&(m=w,C=b),!(m&&C)&&d&&S&&(m=d,C=S),m&&C&&(ce(m,C),N.removeWidows=!0)}Ie()}c.UKPostcodes&&e[s]&&!e[s].trim()&&e[s-1]&&e[s-1].trim()&&a.test(e.slice(0,s))&&e[B(e,s)]&&g.test(e.slice(B(e,s)))&&(ce(s,B(e,s)),N.removeWidows=!0),!E&&e[s]&&!e[s].trim()&&e[s-1]&&e[s-1].trim()&&(y===void 0||e[y-1]&&e[y-1].trim())&&!"/>".includes(e[B(e,s)])&&!e.slice(0,s).trim().endsWith("br")&&!e.slice(0,s).trim().endsWith("hr")&&!(e.slice(0,s).endsWith("<")&&Qt.some(m=>e.startsWith(m,B(e,s))))&&(d=y,S=v,y=s,v=void 0,(w!==void 0||b!==void 0)&&(w=void 0,b=void 0));let O;E&&(typeof E=="string"&&(!E.length||e.startsWith(E,s))?E=void 0:n(E)&&(!E.length||E.some(m=>{if(e.startsWith(m,s))return O=m,!0}))&&(E=void 0,s+=O.length,n(c.ignore)&&c.ignore.length&&e[s+1]&&c.ignore.some(m=>Ue(e,s,m.tails,{trimBeforeMatching:!0,cb:(C,Me,xe)=>(xe&&(s=xe-1,e[s+1]&&e[s+1].trim()&&(p+=1)),!0)})))),e[s]&&`\r
|
|
30
|
+
`.includes(e[s])&&(p=0,f=0),n(c.tagRanges)&&c.tagRanges.length&&c.tagRanges.some(m=>{if(s>=m[0]&&s<=m[1]&&m[1]-1>s)return s=m[1]-1,!0})}return Ce(e,o.current()).split("").forEach((s,O)=>{}),{res:Ce(e,o.current(),c.reportProgressFunc?s=>{h=Math.floor((c.reportProgressFuncTo-c.reportProgressFuncFrom)*(1-i)+s/100*(c.reportProgressFuncTo-c.reportProgressFuncFrom)*i),h!==$&&($=h,c.reportProgressFunc(h))}:void 0),ranges:o.current(),log:{timeTakenInMilliseconds:Date.now()-r},whatWasDone:N}}return ar(ao);})();
|
|
31
|
+
/**
|
|
32
|
+
* @name arrayiffy-if-string
|
|
33
|
+
* @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
|
|
34
|
+
* @version 5.0.2
|
|
35
|
+
* @author Roy Revelt, Codsen Ltd
|
|
36
|
+
* @license MIT
|
|
37
|
+
* {@link https://codsen.com/os/arrayiffy-if-string/}
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* @name ranges-apply
|
|
41
|
+
* @fileoverview Take an array of string index ranges, delete/replace the string according to them
|
|
42
|
+
* @version 7.0.2
|
|
43
|
+
* @author Roy Revelt, Codsen Ltd
|
|
44
|
+
* @license MIT
|
|
45
|
+
* {@link https://codsen.com/os/ranges-apply/}
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* @name ranges-merge
|
|
49
|
+
* @fileoverview Merge and sort string index ranges
|
|
50
|
+
* @version 9.0.2
|
|
51
|
+
* @author Roy Revelt, Codsen Ltd
|
|
52
|
+
* @license MIT
|
|
53
|
+
* {@link https://codsen.com/os/ranges-merge/}
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* @name ranges-push
|
|
57
|
+
* @fileoverview Gather string index ranges
|
|
58
|
+
* @version 7.0.2
|
|
59
|
+
* @author Roy Revelt, Codsen Ltd
|
|
60
|
+
* @license MIT
|
|
61
|
+
* {@link https://codsen.com/os/ranges-push/}
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* @name ranges-sort
|
|
65
|
+
* @fileoverview Sort string index ranges
|
|
66
|
+
* @version 6.0.2
|
|
67
|
+
* @author Roy Revelt, Codsen Ltd
|
|
68
|
+
* @license MIT
|
|
69
|
+
* {@link https://codsen.com/os/ranges-sort/}
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* @name string-collapse-leading-whitespace
|
|
73
|
+
* @fileoverview Collapse the leading and trailing whitespace of a string
|
|
74
|
+
* @version 7.0.2
|
|
75
|
+
* @author Roy Revelt, Codsen Ltd
|
|
76
|
+
* @license MIT
|
|
77
|
+
* {@link https://codsen.com/os/string-collapse-leading-whitespace/}
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* @name string-left-right
|
|
81
|
+
* @fileoverview Looks up the first non-whitespace character to the left/right of a given index
|
|
82
|
+
* @version 6.0.2
|
|
83
|
+
* @author Roy Revelt, Codsen Ltd
|
|
84
|
+
* @license MIT
|
|
85
|
+
* {@link https://codsen.com/os/string-left-right/}
|
|
86
|
+
*/
|
|
87
|
+
/**
|
|
88
|
+
* @name string-match-left-right
|
|
89
|
+
* @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
|
|
90
|
+
* @version 9.0.2
|
|
91
|
+
* @author Roy Revelt, Codsen Ltd
|
|
92
|
+
* @license MIT
|
|
93
|
+
* {@link https://codsen.com/os/string-match-left-right/}
|
|
94
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-remove-widows",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Helps to prevent widow words in a text",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"against",
|
|
@@ -75,12 +75,12 @@
|
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"ranges-apply": "^7.0.
|
|
79
|
-
"ranges-push": "^7.0.
|
|
80
|
-
"string-left-right": "^6.0.
|
|
81
|
-
"string-match-left-right": "^9.0.
|
|
78
|
+
"ranges-apply": "^7.0.2",
|
|
79
|
+
"ranges-push": "^7.0.2",
|
|
80
|
+
"string-left-right": "^6.0.2",
|
|
81
|
+
"string-match-left-right": "^9.0.2"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"string-strip-html": "^13.0.
|
|
84
|
+
"string-strip-html": "^13.0.2"
|
|
85
85
|
}
|
|
86
86
|
}
|