string-remove-widows 4.2.0 → 4.2.1
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-remove-widows
|
|
3
3
|
* @fileoverview Helps to prevent widow words in a text
|
|
4
|
-
* @version 4.2.
|
|
4
|
+
* @version 4.2.1
|
|
5
5
|
* @author Roy Revelt
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-remove-widows/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import{formatDiagnosticValue as q,isPlainObject as X,rawMDash as ee,rawNbsp as w,rawNDash as te}from"codsen-utils";import{rApply as G}from"ranges-apply";import{Ranges as oe}from"ranges-push";import{left as N,right as D}from"string-left-right";import{matchRightIncl as ne}from"string-match-left-right";var F="4.2.
|
|
10
|
+
import{formatDiagnosticValue as q,isPlainObject as X,rawMDash as ee,rawNbsp as w,rawNDash as te}from"codsen-utils";import{rApply as G}from"ranges-apply";import{Ranges as oe}from"ranges-push";import{left as N,right as D}from"string-left-right";import{matchRightIncl as ne}from"string-match-left-right";var F="4.2.1";var f=" ",E="\\00A0",S="\\u00A0",R="–",M="\\2013",k="\\u2013",U="—",J="\\2014",I="\\u2014",C=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],B=[{heads:"{{",tails:"}}"}],P=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],_=["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 ge=F,se={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};function be(t,h){let K=Date.now();if(typeof t!="string")throw t===void 0?new Error("string-remove-widows/removeWidows(): [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`string-remove-widows/removeWidows(): [THROW_ID_02] the first input argument must be string! It was given as "${typeof t}", equal to:
|
|
11
11
|
${q(t,4)}`);if(h&&!X(h))throw new Error(`string-remove-widows/removeWidows(): [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof h}, equal to ${q(h,4)}`);let b=Array.isArray,L=t.length,a=new oe({mergeType:2}),Z=["."],Y=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,z=/^[0-9][A-Z]{2}/,v=.06,$,W=0,g=0,A=0,y,T,l,c,r,d,s,p,o={...se,...h},m={removeWidows:!1,convertEntities:!1};if(!o.ignore||!b(o.ignore)&&typeof o.ignore!="string")o.ignore=[];else if(typeof o.ignore=="string"&&(o.ignore=[o.ignore]),o.ignore.includes("all"))o.ignore=o.ignore.concat(C.concat(P));else if(o.ignore.some(e=>typeof e=="string")){let e=[];o.ignore=o.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(B):["hexo"].includes(i.trim().toLowerCase())&&(e=e.concat(P)),!1):typeof i=="object"),e.length&&(o.ignore=o.ignore.concat(e))}let x;o.reportProgressFunc&&(x=Math.floor(o.reportProgressFuncTo-(o.reportProgressFuncTo-o.reportProgressFuncFrom)*v-o.reportProgressFuncFrom));function V(e,i){let n=w;o.removeWidowPreventionMeasures?n=" ":o.convertEntities&&(n=f,typeof o.targetLanguage=="string"&&(o.targetLanguage.trim().toLowerCase()==="css"?n=E:o.targetLanguage.trim().toLowerCase()==="js"&&(n=S))),t.slice(e,i)!==n&&a.push(e,i,n)}function O(){g=0,A=0,y=void 0,T=void 0,l=void 0,c=void 0,r=void 0,d=void 0}O();for(let e=0;e<=L;e++){if(!s&&b(o.ignore)&&o.ignore.length&&o.ignore.some((n,u)=>b(n.heads)&&n.heads.some(j=>t.startsWith(j,e))||typeof n.heads=="string"&&t.startsWith(n.heads,e)?(g+=1,s=o.ignore[u].tails,!0):!1),!s&&p&&p===e&&(g+=1,p=void 0),typeof o.reportProgressFunc=="function"&&($=o.reportProgressFuncFrom+Math.floor(e/L*(x||1)),$!==W&&(W=$,o.reportProgressFunc($))),!s&&e&&t[e]?.trim()&&(!t[e-1]||t[e-1]&&!t[e-1].trim())&&(c=e),!s&&t[e]?.trim()&&(A+=1),!s&&o.hyphens&&(`-${ee}${te}`.includes(t[e])||t.startsWith(R,e)||t.startsWith(M,e)||t.startsWith(k,e)||t.startsWith(U,e)||t.startsWith(J,e)||t.startsWith(I,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,d=e+6,t[e+6]?.trim()&&(p=e+6),o.convertEntities?(o.targetLanguage==="css"||o.targetLanguage==="js")&&(a.push(e,e+6,o.targetLanguage==="css"?E:S),m.convertEntities=!0):(a.push(e,e+6,w),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,d=e+5,t[e+5]?.trim()&&(p=e+5),o.convertEntities?(o.targetLanguage==="html"||o.targetLanguage==="js")&&(a.push(e,e+5,o.targetLanguage==="html"?f:S),m.convertEntities=!0):(a.push(e,e+5,w),m.convertEntities=!0)),!s&&t[e]==="\\"&&t[e+1]?.toLowerCase()==="u"&&t[e+2]==="0"&&t[e+3]==="0"&&t[e+4]?.toUpperCase()==="A"&&t[e+5]==="0"&&(r=e,d=e+6,t[e+6]?.trim()&&(p=e+6),o.convertEntities?(o.targetLanguage==="html"||o.targetLanguage==="css")&&a.push(e,e+6,o.targetLanguage==="html"?f:E):a.push(e,e+6,w)),!s&&t[e]===w&&(r=e,d=e+1,o.convertEntities&&a.push(e,e+1,o.targetLanguage==="css"?E:o.targetLanguage==="js"?S:f)),!s&&t[e]?.trim()&&!t[e-1]?.trim()&&(g+=1),!s&&(!t[e]||`\r
|
|
12
12
|
`.includes(t[e])||(t[e]===`
|
|
13
13
|
`||t[e]==="\r"||t[e]==="\r"&&t[e+1]===`
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-remove-widows
|
|
3
3
|
* @fileoverview Helps to prevent widow words in a text
|
|
4
|
-
* @version 4.2.
|
|
4
|
+
* @version 4.2.1
|
|
5
5
|
* @author Roy Revelt
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-remove-widows/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
"use strict";var stringRemoveWidows=(()=>{var U=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols;var $e=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable;var K=(e,t,n)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,W=(e,t)=>{for(var n in t||(t={}))$e.call(t,n)&&K(e,n,t[n]);if(me)for(var n of me(t))He.call(t,n)&&K(e,n,t[n]);return e};var Pe=(e,t)=>{for(var n in t)U(e,n,{get:t[n],enumerable:!0})},Be=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ke(t))!$e.call(e,u)&&u!==n&&U(e,u,{get:()=>t[u],enumerable:!(s=Fe(t,u))||s.enumerable});return e};var Ue=e=>Be(U({},"__esModule",{value:!0}),e);var F=(e,t,n)=>K(e,typeof t!="symbol"?t+"":t,n);var ut={};Pe(ut,{defaults:()=>_e,removeWidows:()=>lt,version:()=>at});function qe(){let e=[],t=0,n=!1;return{append(s){return n?!1:t+s.length>1999?(e.push("\u2026"),t+=1,n=!0,!1):(e.push(s),t+=s.length,!0)},result(){return e.join("")},stopped(){return n}}}function Je(e){return"\\u".concat(e.toString(16).padStart(4,"0"))}function q(e,t){if(e.append('"')){for(let n=0;n<t.length&&!e.stopped();n+=1){let s=t.charCodeAt(n);s===34?e.append('\\"'):s===92?e.append("\\\\"):s===8?e.append("\\b"):s===9?e.append("\\t"):s===10?e.append("\\n"):s===12?e.append("\\f"):s===13?e.append("\\r"):s<32||s===8232||s===8233||s>=55296&&s<=57343?e.append(Je(s)):e.append(t[n])}e.append('"')}}function Ge(e){return e.get&&e.set?"[Getter/Setter]":e.get?"[Getter]":e.set?"[Setter]":"[Accessor]"}function ye(e,t){e.append("Symbol(");let n=String(t);n.length>8&&q(e,n.slice(7,-1)),e.append(")")}function be(e,t){typeof t=="symbol"?ye(e,t):q(e,String(t))}function $(e,t=0){let n=qe(),s=t===4?4:0,u=new WeakSet,r=0;function g(a){s&&n.append(" ".repeat(a*s))}function l(a,p){a&&n.append(","),s&&(n.append("\n"),g(p+1))}function c(a,p,w){s&&p&&(n.append("\n"),g(w)),n.append(a)}function i(a,p){Object.prototype.hasOwnProperty.call(a,"value")?h(a.value,p):n.append(Ge(a))}function m(a,p){let w;try{w=Reflect.getOwnPropertyDescriptor(a,"length")}catch(b){n.append("[Uninspectable]");return}let y=w==null?void 0:w.value;if(!Number.isSafeInteger(y)||y<0){n.append("[Uninspectable]");return}n.append("[");let A=!1;for(let b=0;b<y&&!n.stopped();b+=1){if(l(A,p),A=!0,r>=50){n.append("[MaxEntries]");break}r+=1;let d;try{d=Reflect.getOwnPropertyDescriptor(a,String(b))}catch(S){n.append("[Uninspectable]");continue}d!=null&&d.enumerable?i(d,p+1):n.append("[Empty]")}c("]",A,p)}function v(a,p){let w;try{w=Reflect.ownKeys(a)}catch(A){n.append("[Uninspectable]");return}n.append("{");let y=!1;for(let A of w){if(n.stopped())break;if(r>=50){l(y,p),y=!0,q(n,"\u2026"),n.append(s?": ":":"),n.append("[MaxEntries]");break}r+=1;let b;try{b=Reflect.getOwnPropertyDescriptor(a,A)}catch(d){l(y,p),y=!0,be(n,A),n.append(s?": ":":"),n.append("[Uninspectable]");continue}b!=null&&b.enumerable&&(l(y,p),y=!0,be(n,A),n.append(s?": ":":"),i(b,p+1))}c("}",y,p)}function T(a,p){if(u.has(a)){n.append("[Circular]");return}if(p>=5){n.append("[MaxDepth]");return}let w;try{w=Array.isArray(a)}catch(y){n.append("[Uninspectable]");return}u.add(a);try{w?m(a,p):v(a,p)}finally{u.delete(a)}}function h(a,p){a===null?n.append("null"):typeof a=="string"?q(n,a):typeof a=="number"?n.append(Object.is(a,-0)?"-0":String(a)):typeof a=="boolean"?n.append(a?"true":"false"):typeof a>"u"?n.append("undefined"):typeof a=="bigint"?n.append("".concat(a,"n")):typeof a=="symbol"?ye(n,a):typeof a=="function"?n.append("[Function]"):T(a,p)}try{return h(e,0),n.result()}catch(a){return"[Uninspectable]"}}var we="\u2013",Ae="\u2014",L="\xA0";var gt=new Set([..."\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4","$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]),ze=Object.prototype.hasOwnProperty;function N(e){if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function R(e){return typeof e=="string"}function Ee(e){return Number.isFinite(e)}function M(e){return Number.isSafeInteger(e)&&e>=0}function I(e){return e!=null}function ve(e,t){return N(e)&&R(t)&&ze.call(e,t)}var Ke={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function V(e,t){if(!Array.isArray(e)||!e.length)return e;let n=W(W({},Ke),t),s,u;if(n.strictlyTwoElementsInRangeArrays&&!e.every((l,c)=>!Array.isArray(l)||l.length!==2?(s=c,u=l.length,!1):!0))throw new TypeError("ranges-sort/rSort(): [THROW_ID_01] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ".concat(s,"th range (").concat($(e[s],4),") has not two but ").concat(u," elements!"));if(!e.every((l,c)=>!Array.isArray(l)||!Number.isInteger(l[0])||l[0]<0||!Number.isInteger(l[1])||l[1]<0?(s=c,!1):!0))throw new TypeError("ranges-sort/rSort(): [THROW_ID_02] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ".concat(s,"th range (").concat($(e[s],4),") does not consist of only natural numbers!"));let r=e.length**2,g=0;return Array.from(e).sort((l,c)=>(n.progressFn&&(g+=1,n.progressFn(Math.floor(g*100/r))),l[0]===c[0]?l[1]<c[1]?-1:l[1]>c[1]?1:0:l[0]<c[0]?-1:1))}var Qe={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Q(e,t){function n(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}if(!Array.isArray(e)||!e.length)return null;if(t&&!n(t))throw new TypeError("ranges-merge/rMerge(): [THROW_ID_01] the second input argument must be a plain object. It was given as:\n".concat($(t,4)," (type ").concat(typeof t,")"));let s=W(W({},Qe),t);if(s.progressFn&&n(s.progressFn)&&!Object.keys(s.progressFn).length)s.progressFn=null;else if(s.progressFn&&typeof s.progressFn!="function")throw new TypeError('ranges-merge/rMerge(): [THROW_ID_02] opts.progressFn must be a function! It was given of a type: "'.concat(typeof s.progressFn,'", equal to ').concat($(s.progressFn,4)));if(![1,2,"1","2"].includes(s.mergeType))throw new TypeError('ranges-merge/rMerge(): [THROW_ID_03] opts.mergeType was customised to a wrong thing! It was given of a type: "'.concat(typeof s.mergeType,'", equal to ').concat($(s.mergeType,4)));if(typeof s.joinRangesThatTouchEdges!="boolean")throw new TypeError('ranges-merge/rMerge(): [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "'.concat(typeof s.joinRangesThatTouchEdges,'", equal to ').concat($(s.joinRangesThatTouchEdges,4)));let u=e.filter(i=>Array.isArray(i)).map(i=>[...i]).filter(i=>i[2]!==void 0||i[0]!==i[1]),r,g,l;s.progressFn?r=V(u,{progressFn:i=>{l=Math.floor(i/5),l!==g&&(g=l,s.progressFn(l))}}):r=V(u);let c=r.length-1;for(let i=c;i>0;i--)s.progressFn&&(l=Math.floor((1-i/c)*78)+21,l!==g&&l>g&&(g=l,s.progressFn(l))),(r[i][0]<=r[i-1][0]||!s.joinRangesThatTouchEdges&&r[i][0]<r[i-1][1]||s.joinRangesThatTouchEdges&&r[i][0]<=r[i-1][1])&&(r[i-1][0]=Math.min(r[i][0],r[i-1][0]),r[i-1][1]=Math.max(r[i][1],r[i-1][1]),r[i][2]!==void 0&&(r[i-1][0]>=r[i][0]||r[i-1][1]<=r[i][1])&&r[i-1][2]!==null&&(r[i][2]===null&&r[i-1][2]!==null?r[i-1][2]=null:r[i-1][2]!=null?+s.mergeType==2&&r[i-1][0]===r[i][0]?r[i-1][2]=r[i][2]:r[i-1][2]+=r[i][2]:r[i-1][2]=r[i][2]),r.splice(i,1),i=r.length);return r.length?r:null}function J(e){if(typeof e=="number")return Number.isInteger(e)&&e>=0;if(typeof e!="string"||!e.trim())return!1;let t=Number(e);return Number.isInteger(t)&&t>=0}function Z(e,t,n){let s=0,u=0;if(e===void 0&&t===void 0&&n===void 0)throw new Error("ranges-apply/rApply(): [THROW_ID_01] inputs missing!");if(typeof e!="string")throw new TypeError("ranges-apply/rApply(): [THROW_ID_02] first input argument must be a string! Currently it's: ".concat(typeof e,", equal to: ").concat($(e,4)));if(t!=null&&!Array.isArray(t))throw new TypeError("ranges-apply/rApply(): [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ".concat(typeof t,", equal to: ").concat($(t,4)));if(n&&typeof n!="function")throw new TypeError("ranges-apply/rApply(): [THROW_ID_04] the third input argument must be a function (or falsy)! Currently it's: ".concat(typeof n,", equal to: ").concat($(n,4)));if(!(t!=null&&t.some(Boolean)))return e;let r;Array.isArray(t)&&!Array.isArray(t[0])&&J(t[0])&&J(t[1])?r=[Array.from(t)]:r=Array.from(t);let g=r.length,l=0;r.forEach((m,v)=>{if(m){if(n&&(s=Math.floor(l/g*10),s!==u&&(u=s,n(s))),!Array.isArray(m))throw new TypeError("ranges-apply/rApply(): [THROW_ID_05] ranges array, second input arg., has ".concat(v,"th element not an array: ").concat($(m,4),", which is ").concat(typeof m));if(!J(m[0]))throw new TypeError("ranges-apply/rApply(): [THROW_ID_06] ranges array, second input arg. has ".concat(v,"th element, array ").concat($(m),". Its first element is not a non-negative integer or string index, but ").concat(typeof m[0],", equal to: ").concat($(m[0],4),"."));if(typeof m[0]=="string"&&(r[v]=[...m],r[v][0]=Number(m[0])),!J(m[1]))throw new TypeError("ranges-apply/rApply(): [THROW_ID_07] ranges array, second input arg. has ".concat(v,"th element, array ").concat($(m),". Its second element is not a non-negative integer or string index, but ").concat(typeof m[1],", equal to: ").concat($(m[1],4),"."));typeof m[1]=="string"&&(r[v]===m&&(r[v]=[...m]),r[v][1]=Number(m[1])),l+=1}});let c=n?Q(r,{progressFn:m=>{s=10+Math.floor(m/10),s!==u&&(u=s,n(s))}}):Q(r),i=(c==null?void 0:c.length)||0;if(c&&i>0){let m=e.slice(c[i-1][1]);e=c.reduce((v,T,h,a)=>{n&&(s=20+Math.floor(h/i*80),s!==u&&(u=s,n(s)));let p=h===0?0:a[h-1][1],w=a[h][0];return"".concat(v).concat(e.slice(p,w)).concat(a[h][2]||"")},""),e+=m}return e}function G(e,t=1){let n="\xA0";function s(r){return Array.from(r).reverse().join("")}function u(r,g,l){let c=l?"\n":"\r",i=l?"\r":"\n";if(!r)return r;let m=0,v=0,T="";for(let h=0,a=r.length;h<a;h++)(r[h]===c||r[h]===i&&r[h-1]!==c)&&v++,"\r\n".includes(r[h])||r[h]===n?(m=0,r[h]===n?T+=r[h]:r[h]===c?v<=g&&(T+=r[h],r[h+1]===i&&(T+=r[h+1],h++)):r[h]===i&&(r==null?void 0:r[h-1])!==c&&v<=g&&(T+=r[h])):(m++,!r[h+1]&&!v&&(T+=" "));return T}if(typeof e=="string"&&e.length){let r=1;typeof+t=="number"&&Number.isInteger(+t)&&+t>=0&&(r=+t);let g="",l="";if(!e.trim())g=e;else if(!e[0].trim()){for(let c=0,i=e.length;c<i;c++)if(e[c].trim()){g=e.slice(0,c);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===n)){for(let c=e.length;c--;)if(e[c].trim()){l=e.slice(c+1);break}}return"".concat(u(g,r,!1)).concat(e.trim()).concat(s(u(s(l),r,!0)))}return e}var Ze={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Ye(e,t){function n(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}if(!Array.isArray(e)||!e.length)return null;if(t&&!n(t))throw new TypeError("ranges-push/rMerge(): [THROW_ID_10] the second input argument must be a plain object. It was given as:\n".concat($(t,4)," (type ").concat(typeof t,")"));let s=W(W({},Ze),t);if(s.progressFn&&n(s.progressFn)&&!Object.keys(s.progressFn).length)s.progressFn=null;else if(s.progressFn&&typeof s.progressFn!="function")throw new TypeError('ranges-push/rMerge(): [THROW_ID_11] resolvedOpts.progressFn must be a function! It was given of a type: "'.concat(typeof s.progressFn,'", equal to ').concat($(s.progressFn,4)));if(![1,2,"1","2"].includes(s.mergeType))throw new TypeError('ranges-push/rMerge(): [THROW_ID_12] resolvedOpts.mergeType was customised to a wrong thing! It was given of a type: "'.concat(typeof s.mergeType,'", equal to ').concat($(s.mergeType,4)));if(typeof s.joinRangesThatTouchEdges!="boolean")throw new TypeError('ranges-push/rMerge(): [THROW_ID_13] resolvedOpts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "'.concat(typeof s.joinRangesThatTouchEdges,'", equal to ').concat($(s.joinRangesThatTouchEdges,4)));let u=e.filter(i=>Array.isArray(i)).map(i=>[...i]).filter(i=>i[2]!==void 0||i[0]!==i[1]),r,g,l;s.progressFn?r=V(u,{progressFn:i=>{l=Math.floor(i/5),l!==g&&(g=l,s.progressFn!=null&&s.progressFn(l))}}):r=V(u);let c=r.length-1;for(let i=c;i>0;i--)s.progressFn&&(l=Math.floor((1-i/c)*78)+21,l!==g&&l>g&&(g=l,s.progressFn(l))),(r[i][0]<=r[i-1][0]||!s.joinRangesThatTouchEdges&&r[i][0]<r[i-1][1]||s.joinRangesThatTouchEdges&&r[i][0]<=r[i-1][1])&&(r[i-1][0]=Math.min(r[i][0],r[i-1][0]),r[i-1][1]=Math.max(r[i][1],r[i-1][1]),r[i][2]!==void 0&&(r[i-1][0]>=r[i][0]||r[i-1][1]<=r[i][1])&&r[i-1][2]!==null&&(r[i][2]===null&&r[i-1][2]!==null?r[i-1][2]=null:r[i-1][2]!=null?+s.mergeType==2&&r[i-1][0]===r[i][0]?r[i-1][2]=r[i][2]:r[i-1][2]+=r[i][2]:r[i-1][2]=r[i][2]),r.splice(i,1),i=r.length);return r.length?r:null}var Xe={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1};function Te(e){return e[2]===void 0&&e[0]===e[1]}function et(e){let t=-1;for(let n=0,s=e.length;n<s;n++){let u=e[n];if(Array.isArray(u)){if(u[0]<t)return!1;t=u[0]}}return!0}var We=class{constructor(e){F(this,"ranges");F(this,"opts");F(this,"sorted");if(e!=null&&!N(e))throw new TypeError("ranges-push/Ranges/constructor(): [THROW_ID_01] The options argument must be a plain object. It was given as ".concat($(e,4)," (type ").concat(typeof e,")."));let t=W(W({},Xe),e);if(t.mergeType&&t.mergeType!==1&&t.mergeType!==2)if(R(t.mergeType)&&t.mergeType.trim()==="1")t.mergeType=1;else if(R(t.mergeType)&&t.mergeType.trim()==="2")t.mergeType=2;else throw new Error('ranges-push/Ranges/constructor(): [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "'.concat(typeof t.mergeType,'", equal to ').concat($(t.mergeType,4)));this.opts=t,this.ranges=[],this.sorted=!0}add(e,t,n){var r;if(e==null&&t==null)return;if(I(e)&&!I(t)){if(Array.isArray(e)){if(e.length){if(e.some(g=>Array.isArray(g))){e.forEach(g=>{Array.isArray(g)&&this.add(...g)});return}e.length&&M(+e[0])&&M(+e[1])&&this.add(...e)}return}throw new TypeError('ranges-push/Ranges/add(): [THROW_ID_03] the first input argument, "from" is set ('.concat($(e),') but second-one, "to" is not (').concat($(t),")"))}else if(!I(e)&&I(t))throw new TypeError('ranges-push/Ranges/add(): [THROW_ID_04] the second input argument, "to" is set ('.concat($(t),') but first-one, "from" is not (').concat($(e),")"));let s=+e,u=+t;if(M(s)&&M(u)){if(I(n)&&!R(n)&&!Ee(n))throw new TypeError("ranges-push/Ranges/add(): [THROW_ID_05] The third argument, the value to add, was given not as string but ".concat(typeof n,", equal to:\n").concat($(n,4)));if(I(this.ranges)&&Array.isArray(this.last())&&s===this.last()[1]){if(this.last()[1]=u,this.last()[2],this.last()[2]!==null&&I(n)){let g=this.last()[2]&&this.last()[2].length&&(!((r=this.opts)!=null&&r.mergeType)||this.opts.mergeType===1)?"".concat(this.last()[2]).concat(n):n;this.opts.limitToBeAddedWhitespace&&(g=G(g,this.opts.limitLinebreaksCount)),R(g)&&!g.length||(this.last()[2]=g)}}else{this.ranges||(this.ranges=[]);let g=this.last();g&&s<g[0]&&(this.sorted=!1);let l=n!==void 0&&!(R(n)&&!n.length)?[s,u,n&&this.opts.limitToBeAddedWhitespace?G(n,this.opts.limitLinebreaksCount):n]:[s,u];this.ranges.push(l)}}else throw M(s)?new TypeError('ranges-push/Ranges/add(): [THROW_ID_07] "to" value, the second input argument, must be a natural number or zero! Currently it\'s of a type "'.concat(typeof t,'" equal to: ').concat($(t,4))):new TypeError('ranges-push/Ranges/add(): [THROW_ID_06] "from" value, the first input argument, must be a natural number or zero! Currently it\'s of a type "'.concat(typeof e,'" equal to: ').concat($(e,4)))}push(e,t,n){this.add(e,t,n)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=Ye(this.ranges,{mergeType:this.opts.mergeType}),this.sorted=!0,this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>I(e[2])?[e[0],e[1],G(e[2],this.opts.limitLinebreaksCount)]:e):this.ranges):null}firstCovers(e){if(!M(e))throw new TypeError("ranges-push/Ranges/firstCovers(): [THROW_ID_08] the input argument must be a natural number or zero! It was given as ".concat($(e,4)," (type ").concat(typeof e,")"));if(!Array.isArray(this.ranges)||!this.ranges.length)return!1;let t=null;if(this.sorted){for(let s=0,u=this.ranges.length;s<u;s++){let r=this.ranges[s];if(!(!Array.isArray(r)||Te(r))){if(t===null){if(r[0]!==0)return!1;t=r[1]}else{if(r[0]>t)break;r[1]>t&&(t=r[1])}if(t>=e)return!0}}return t!==null&&t>=e}let n=!0;for(;n;){n=!1;for(let s=0,u=this.ranges.length;s<u;s++){let r=this.ranges[s];if(!(!Array.isArray(r)||Te(r))){if(r[0]<0)return!1;(t===null?r[0]===0:r[0]<=t&&r[1]>t)&&(t=r[1],n=!0)}}}return t!==null&&t>=e}wipe(){this.ranges=[],this.sorted=!0}replace(e){if(Array.isArray(e)&&e.length)if(Array.isArray(e[0])&&M(e[0][0]))this.ranges=Array.from(e),this.sorted=et(this.ranges);else throw new Error("ranges-push/Ranges/replace(): [THROW_ID_09] Single range was given but we expected array of arrays! The first element, ".concat($(e[0],4)," should be an array and its first element should be an integer, a string index."));else this.ranges=[],this.sorted=!0}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}};var j="\xA0";function tt({str:e,idx:t=0,stopAtNewlines:n=!1,stopAtRawNbsp:s=!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()||n&&"\n\r".includes(e[t+1])||s&&e[t+1]===j))return t+1;if(e[t+2]&&(e[t+2].trim()||n&&"\n\r".includes(e[t+2])||s&&e[t+2]===j))return t+2;for(let u=t+1,r=e.length;u<r;u++)if(e[u].trim()||n&&"\n\r".includes(e[u])||s&&e[u]===j)return u;return null}function _(e,t=0){return tt({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function rt({str:e,idx:t,stopAtNewlines:n,stopAtRawNbsp:s}){if(typeof e!="string"||!e.length||((!t||typeof t!="number")&&(t=0),t<1))return null;if(e[~-t]&&(e[~-t].trim()||n&&"\n\r".includes(e[~-t])||s&&e[~-t]===j))return~-t;if(e[t-2]&&(e[t-2].trim()||n&&"\n\r".includes(e[t-2])||s&&e[t-2]===j))return t-2;for(let u=t;u--;)if(e[u]&&(e[u].trim()||n&&"\n\r".includes(e[u])||s&&e[u]===j))return u;return null}function k(e,t=0){return rt({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function De(e){return typeof e!="string"?e:e.length?[e]:[]}var Se={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},nt=e=>e+1;function st(e,t,n,s,u=!1,r=nt){var b;let g=typeof n=="function"?n():n;if(+t<0&&u&&g==="EOL")return g;let l=W(W({},Se),s);if(t>=e.length&&!u)return!1;let c=u?1:n.length,i=0,m=!1,v=!1,T=!1,h=l.maxMismatches,a=t,p=!1,w=!1,y=!1;function A(){return i===1&&h<l.maxMismatches-1}for(;e[a];){let d=r(a);if(l.trimBeforeMatching&&e[a].trim()===""){if(!e[d]&&u&&n==="EOL")return!0;a=r(a);continue}if(l&&!l.i&&((b=l==null?void 0:l.trimCharsBeforeMatching)!=null&&b.includes(e[a]))||l!=null&&l.i&&l.trimCharsBeforeMatching&&l.trimCharsBeforeMatching.map(f=>f.toLowerCase()).includes(e[a].toLowerCase())){if(u&&n==="EOL"&&!e[d])return!0;a=r(a);continue}let S=d>a?n[n.length-c]:n[c-1];if(!l.i&&e[a]===S||l.i&&S!==void 0&&e[a].toLowerCase()===S.toLowerCase()){if(p||(p=!0),T||(T=!0),c===n.length){if(w=!0,h!==l.maxMismatches)return!1}else c===1&&(y=!0);if(c-=1,i++,A())return!1;if(!c)return i!==n.length||h===l.maxMismatches||!m?a:!1}else if(!m&&!i&&(m=!0),l.maxMismatches&&h&&a){h-=1;for(let f=0;f<=h;f++){let D=d>a?n[n.length-c+1+f]:n[c-2-f],x=e[r(a)];if(D&&(!l.i&&e[a]===D||l.i&&e[a].toLowerCase()===D.toLowerCase())&&(!l.firstMustMatch||c!==n.length)){if(i++,A())return!1;c-=2,p=!0;break}else if(x&&D&&(!l.i&&x===D||l.i&&x.toLowerCase()===D.toLowerCase())&&(!l.firstMustMatch||c!==n.length)){if(!i&&!l.hungry)return!1;c-=1,p=!0;break}else if(D===void 0&&h>=0&&p&&(!l.firstMustMatch||w)&&(!l.lastMustMatch||y))return a}p||(v=a)}else return a===0&&c===1&&!l.lastMustMatch&&T?0:!1;if(v!==!1&&v!==a&&(v=!1),c<1)return a;a=r(a)}if(c>0)return u&&g==="EOL"?!0:l&&l.maxMismatches>=c&&T?v||0:!1}function ot(e,t,n,s,u){var m,v,T;if(N(u)&&ve(u,"trimBeforeMatching")&&u&&typeof u.trimBeforeMatching!="boolean")throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_01] opts.trimBeforeMatching should be boolean!").concat(Array.isArray(u.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""));let r=W(W({},Se),u);if(typeof r.trimCharsBeforeMatching=="string"&&(r.trimCharsBeforeMatching=De(r.trimCharsBeforeMatching)),r.trimCharsBeforeMatching=r.trimCharsBeforeMatching.map(h=>R(h)?h:String(h)),!R(t)||!t.length)return!1;if(!Number.isInteger(n)||n<0)throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_02] the second argument should be a natural number. Currently it's of a type: ").concat(typeof n,", equal to:\n").concat($(n,4)));let g,l;if(R(s))g=[s];else if(Array.isArray(s))g=s;else if(!s)g=s;else if(typeof s=="function")g=[],g.push(s);else throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_03] the third argument, whatToMatch, is neither string nor array of strings! It's ").concat(typeof s,", equal to:\n").concat($(s,4)));if(u&&!N(u))throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_04] the fourth argument, options object, should be a plain object. Currently it's of a type \"").concat(typeof u,'", and equal to:\n').concat($(u,4)));let c=0,i="";if((m=r==null?void 0:r.trimCharsBeforeMatching)!=null&&m.some((h,a)=>h.length>1?(c=a,i=h,!0):!1))throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_05] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ").concat(c," is longer than 1 character, ").concat(i.length," (equals to ").concat(i,"). Please split it into separate characters and put into array as separate elements."));if(!g||!Array.isArray(g)||Array.isArray(g)&&!g.length||Array.isArray(g)&&g.length===1&&R(g[0])&&!g[0].trim()){if(typeof r.cb=="function"){let a,p=n;if((e==="matchLeftIncl"||e==="matchRight")&&(p+=1),e[5]==="L")for(let b=p;b--;){let d=t[b];if((!r.trimBeforeMatching||r.trimBeforeMatching&&(d!=null&&d.trim()))&&(!((v=r.trimCharsBeforeMatching)!=null&&v.length)||d!==void 0&&!r.trimCharsBeforeMatching.includes(d))){a=b;break}}else if(e.startsWith("matchRight"))for(let b=p;b<t.length;b++){let d=t[b];if((!r.trimBeforeMatching||r.trimBeforeMatching&&d.trim())&&(!((T=r.trimCharsBeforeMatching)!=null&&T.length)||!r.trimCharsBeforeMatching.includes(d))){a=b;break}}if(a===void 0)return!1;let w=t[a],y=a+1,A="";return y&&y>0&&(A=t.slice(0,y)),e[5]==="L"||a&&a>0&&(A=t.slice(a)),r.cb(w,A,a)}let h="";throw u||(h=" More so, the whole options object, the fourth input argument, is missing!"),new Error("string-match-left-right/".concat(e,'(): [THROW_ID_06] 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!').concat(h))}for(let h=0,a=g.length;h<a;h++){l=typeof g[h]=="function";let p=g[h],w,y,A="",b=n;e==="matchRight"?b+=1:e==="matchLeft"&&(b-=1);let d=st(t,b,p,r,l,S=>e[5]==="L"?S-1:S+1);if(d&&l&&typeof p=="function"&&p()==="EOL")return p()&&(!r.cb||r.cb(w,A,y))?p():!1;if(Number.isInteger(d)&&(y=e.startsWith("matchLeft")?d-1:d+1,e[5]==="L"?A=t.slice(0,d):A=t.slice(y)),y<0&&(y=void 0),t[y]&&(w=t[y]),Number.isInteger(d)&&(!r.cb||r.cb(w,A,y)))return p}return!1}function Ce(e,t,n,s){return ot("matchRightIncl",e,t,n,s)}var Re="4.2.0";var H=" ",P="\\00A0",B="\\u00A0",Oe="–",Ne="\\2013",Me="\\u2013",Ie="—",xe="\\2014",Le="\\u2014",Y=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],Ve=[{heads:"{{",tails:"}}"}],X=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],je=["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 at=Re,_e={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};function lt(e,t){var te,re,ne,se,oe,ie,ae,le,ue,fe,ge,ce;let n=Date.now();if(typeof e!="string")throw e===void 0?new Error("string-remove-widows/removeWidows(): [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error('string-remove-widows/removeWidows(): [THROW_ID_02] the first input argument must be string! It was given as "'.concat(typeof e,'", equal to:\n').concat($(e,4)));if(t&&!N(t))throw new Error("string-remove-widows/removeWidows(): [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ".concat(typeof t,", equal to ").concat($(t,4)));let s=Array.isArray,u=e.length,r=new We({mergeType:2}),g=["."],l=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,c=/^[0-9][A-Z]{2}/,i=.06,m,v=0,T=0,h=0,a,p,w,y,A,b,d,S,f=W(W({},_e),t),D={removeWidows:!1,convertEntities:!1};if(!f.ignore||!s(f.ignore)&&typeof f.ignore!="string")f.ignore=[];else if(typeof f.ignore=="string"&&(f.ignore=[f.ignore]),f.ignore.includes("all"))f.ignore=f.ignore.concat(Y.concat(X));else if(f.ignore.some(o=>typeof o=="string")){let o=[];f.ignore=f.ignore.filter(C=>typeof C=="string"&&C.length?(["nunjucks","jinja","liquid"].includes(C.trim().toLowerCase())?o=o.concat(Y):["hugo"].includes(C.trim().toLowerCase())?o=o.concat(Ve):["hexo"].includes(C.trim().toLowerCase())&&(o=o.concat(X)),!1):typeof C=="object"),o.length&&(f.ignore=f.ignore.concat(o))}let x;f.reportProgressFunc&&(x=Math.floor(f.reportProgressFuncTo-(f.reportProgressFuncTo-f.reportProgressFuncFrom)*i-f.reportProgressFuncFrom));function z(o,C){let E=L;f.removeWidowPreventionMeasures?E=" ":f.convertEntities&&(E=H,typeof f.targetLanguage=="string"&&(f.targetLanguage.trim().toLowerCase()==="css"?E=P:f.targetLanguage.trim().toLowerCase()==="js"&&(E=B))),e.slice(o,C)!==E&&r.push(o,C,E)}function ee(){T=0,h=0,a=void 0,p=void 0,w=void 0,y=void 0,A=void 0,b=void 0}ee();for(let o=0;o<=u;o++){if(!d&&s(f.ignore)&&f.ignore.length&&f.ignore.some((E,O)=>s(E.heads)&&E.heads.some(he=>e.startsWith(he,o))||typeof E.heads=="string"&&e.startsWith(E.heads,o)?(T+=1,d=f.ignore[O].tails,!0):!1),!d&&S&&S===o&&(T+=1,S=void 0),typeof f.reportProgressFunc=="function"&&(m=f.reportProgressFuncFrom+Math.floor(o/u*(x||1)),m!==v&&(v=m,f.reportProgressFunc(m))),!d&&o&&((te=e[o])!=null&&te.trim())&&(!e[o-1]||e[o-1]&&!e[o-1].trim())&&(y=o),!d&&((re=e[o])!=null&&re.trim())&&(h+=1),!d&&f.hyphens&&("-".concat(Ae).concat(we).includes(e[o])||e.startsWith(Oe,o)||e.startsWith(Ne,o)||e.startsWith(Me,o)||e.startsWith(Ie,o)||e.startsWith(xe,o)||e.startsWith(Le,o))&&e[o+1]&&(!e[o+1].trim()||e[o]==="&")&&e[o-1]&&!e[o-1].trim()&&e[k(e,o)]&&(z(k(e,o)+1,o),D.removeWidows=!0),!d&&(e.startsWith(" ",o)||e.startsWith(" ",o))&&(A=o,b=o+6,(ne=e[o+6])!=null&&ne.trim()&&(S=o+6),f.convertEntities?(f.targetLanguage==="css"||f.targetLanguage==="js")&&(r.push(o,o+6,f.targetLanguage==="css"?P:B),D.convertEntities=!0):(r.push(o,o+6,L),D.convertEntities=!0)),!d&&e[o+4]&&e[o]==="\\"&&e[o+1]==="0"&&e[o+2]==="0"&&e[o+3].toUpperCase()==="A"&&e[o+4]==="0"&&(A=o,b=o+5,(se=e[o+5])!=null&&se.trim()&&(S=o+5),f.convertEntities?(f.targetLanguage==="html"||f.targetLanguage==="js")&&(r.push(o,o+5,f.targetLanguage==="html"?H:B),D.convertEntities=!0):(r.push(o,o+5,L),D.convertEntities=!0)),!d&&e[o]==="\\"&&((oe=e[o+1])==null?void 0:oe.toLowerCase())==="u"&&e[o+2]==="0"&&e[o+3]==="0"&&((ie=e[o+4])==null?void 0:ie.toUpperCase())==="A"&&e[o+5]==="0"&&(A=o,b=o+6,(ae=e[o+6])!=null&&ae.trim()&&(S=o+6),f.convertEntities?(f.targetLanguage==="html"||f.targetLanguage==="css")&&r.push(o,o+6,f.targetLanguage==="html"?H:P):r.push(o,o+6,L)),!d&&e[o]===L&&(A=o,b=o+1,f.convertEntities&&r.push(o,o+1,f.targetLanguage==="css"?P:f.targetLanguage==="js"?B:H)),!d&&((le=e[o])!=null&&le.trim())&&!((ue=e[o-1])!=null&&ue.trim())&&(T+=1),!d&&(!e[o]||"\r\n".includes(e[o])||(e[o]==="\n"||e[o]==="\r"||e[o]==="\r"&&e[o+1]==="\n")&&k(e,o)&&g.includes(e[k(e,o)]))){if((!f.minWordCount||T>=f.minWordCount)&&(!f.minCharCount||h>=f.minCharCount)){let E,O;w!==void 0&&y!==void 0&&A!==void 0&&b!==void 0?w>A?(E=w,O=y):(E=A,O=b):w!==void 0&&y!==void 0?(E=w,O=y):A!==void 0&&b!==void 0&&(E=A,O=b),!(E&&O)&&a&&p&&(E=a,O=p),E&&O&&(z(E,O),D.removeWidows=!0)}ee()}f.UKPostcodes&&e[o]&&!e[o].trim()&&((fe=e[o-1])!=null&&fe.trim())&&l.test(e.slice(0,o))&&e[_(e,o)]&&c.test(e.slice(_(e,o)))&&(z(o,_(e,o)),D.removeWidows=!0),!d&&e[o]&&!e[o].trim()&&((ge=e[o-1])!=null&&ge.trim())&&(w===void 0||(ce=e[w-1])!=null&&ce.trim())&&!"/>".includes(e[_(e,o)])&&!e.slice(0,o).trim().endsWith("br")&&!e.slice(0,o).trim().endsWith("hr")&&!(e.slice(0,o).endsWith("<")&&je.some(E=>e.startsWith(E,_(e,o))))&&(a=w,p=y,w=o,y=void 0,(A!==void 0||b!==void 0)&&(A=void 0,b=void 0));let C;d&&(typeof d=="string"&&(!d.length||e.startsWith(d,o))?d=void 0:s(d)&&(!d.length||d.some(E=>e.startsWith(E,o)?(C=E,!0):!1))&&(d=void 0,o+=C.length,s(f.ignore)&&f.ignore.length&&e[o+1]&&f.ignore.some(E=>Ce(e,o,E.tails,{trimBeforeMatching:!0,cb:(O,he,de)=>{var pe;return de&&(o=de-1,(pe=e[o+1])!=null&&pe.trim()&&(T+=1)),!0}})))),e[o]&&"\r\n".includes(e[o])&&(T=0,h=0),s(f.tagRanges)&&f.tagRanges.length&&f.tagRanges.some(E=>o>=E[0]&&o<=E[1]&&E[1]-1>o?(o=E[1]-1,!0):!1)}return Z(e,r.current()).split("").forEach((o,C)=>{}),{res:Z(e,r.current(),f.reportProgressFunc?o=>{m=Math.floor((f.reportProgressFuncTo-f.reportProgressFuncFrom)*(1-i)+o/100*(f.reportProgressFuncTo-f.reportProgressFuncFrom)*i),m!==v&&(v=m,f.reportProgressFunc(m))}:void 0),ranges:r.current(),log:{timeTakenInMilliseconds:Date.now()-n},whatWasDone:D}}return Ue(ut);})();
|
|
10
|
+
"use strict";var stringRemoveWidows=(()=>{var U=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols;var $e=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable;var K=(e,t,n)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,W=(e,t)=>{for(var n in t||(t={}))$e.call(t,n)&&K(e,n,t[n]);if(me)for(var n of me(t))He.call(t,n)&&K(e,n,t[n]);return e};var Pe=(e,t)=>{for(var n in t)U(e,n,{get:t[n],enumerable:!0})},Be=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ke(t))!$e.call(e,u)&&u!==n&&U(e,u,{get:()=>t[u],enumerable:!(s=Fe(t,u))||s.enumerable});return e};var Ue=e=>Be(U({},"__esModule",{value:!0}),e);var F=(e,t,n)=>K(e,typeof t!="symbol"?t+"":t,n);var ut={};Pe(ut,{defaults:()=>_e,removeWidows:()=>lt,version:()=>at});function qe(){let e=[],t=0,n=!1;return{append(s){return n?!1:t+s.length>1999?(e.push("\u2026"),t+=1,n=!0,!1):(e.push(s),t+=s.length,!0)},result(){return e.join("")},stopped(){return n}}}function Je(e){return"\\u".concat(e.toString(16).padStart(4,"0"))}function q(e,t){if(e.append('"')){for(let n=0;n<t.length&&!e.stopped();n+=1){let s=t.charCodeAt(n);s===34?e.append('\\"'):s===92?e.append("\\\\"):s===8?e.append("\\b"):s===9?e.append("\\t"):s===10?e.append("\\n"):s===12?e.append("\\f"):s===13?e.append("\\r"):s<32||s===8232||s===8233||s>=55296&&s<=57343?e.append(Je(s)):e.append(t[n])}e.append('"')}}function Ge(e){return e.get&&e.set?"[Getter/Setter]":e.get?"[Getter]":e.set?"[Setter]":"[Accessor]"}function ye(e,t){e.append("Symbol(");let n=String(t);n.length>8&&q(e,n.slice(7,-1)),e.append(")")}function be(e,t){typeof t=="symbol"?ye(e,t):q(e,String(t))}function $(e,t=0){let n=qe(),s=t===4?4:0,u=new WeakSet,r=0;function g(a){s&&n.append(" ".repeat(a*s))}function l(a,p){a&&n.append(","),s&&(n.append("\n"),g(p+1))}function c(a,p,w){s&&p&&(n.append("\n"),g(w)),n.append(a)}function i(a,p){Object.prototype.hasOwnProperty.call(a,"value")?h(a.value,p):n.append(Ge(a))}function m(a,p){let w;try{w=Reflect.getOwnPropertyDescriptor(a,"length")}catch(b){n.append("[Uninspectable]");return}let y=w==null?void 0:w.value;if(!Number.isSafeInteger(y)||y<0){n.append("[Uninspectable]");return}n.append("[");let A=!1;for(let b=0;b<y&&!n.stopped();b+=1){if(l(A,p),A=!0,r>=50){n.append("[MaxEntries]");break}r+=1;let d;try{d=Reflect.getOwnPropertyDescriptor(a,String(b))}catch(S){n.append("[Uninspectable]");continue}d!=null&&d.enumerable?i(d,p+1):n.append("[Empty]")}c("]",A,p)}function v(a,p){let w;try{w=Reflect.ownKeys(a)}catch(A){n.append("[Uninspectable]");return}n.append("{");let y=!1;for(let A of w){if(n.stopped())break;if(r>=50){l(y,p),y=!0,q(n,"\u2026"),n.append(s?": ":":"),n.append("[MaxEntries]");break}r+=1;let b;try{b=Reflect.getOwnPropertyDescriptor(a,A)}catch(d){l(y,p),y=!0,be(n,A),n.append(s?": ":":"),n.append("[Uninspectable]");continue}b!=null&&b.enumerable&&(l(y,p),y=!0,be(n,A),n.append(s?": ":":"),i(b,p+1))}c("}",y,p)}function T(a,p){if(u.has(a)){n.append("[Circular]");return}if(p>=5){n.append("[MaxDepth]");return}let w;try{w=Array.isArray(a)}catch(y){n.append("[Uninspectable]");return}u.add(a);try{w?m(a,p):v(a,p)}finally{u.delete(a)}}function h(a,p){a===null?n.append("null"):typeof a=="string"?q(n,a):typeof a=="number"?n.append(Object.is(a,-0)?"-0":String(a)):typeof a=="boolean"?n.append(a?"true":"false"):typeof a>"u"?n.append("undefined"):typeof a=="bigint"?n.append("".concat(a,"n")):typeof a=="symbol"?ye(n,a):typeof a=="function"?n.append("[Function]"):T(a,p)}try{return h(e,0),n.result()}catch(a){return"[Uninspectable]"}}var we="\u2013",Ae="\u2014",L="\xA0";var gt=new Set([..."\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4","$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]),ze=Object.prototype.hasOwnProperty;function N(e){if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function R(e){return typeof e=="string"}function Ee(e){return Number.isFinite(e)}function M(e){return Number.isSafeInteger(e)&&e>=0}function I(e){return e!=null}function ve(e,t){return N(e)&&R(t)&&ze.call(e,t)}var Ke={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function V(e,t){if(!Array.isArray(e)||!e.length)return e;let n=W(W({},Ke),t),s,u;if(n.strictlyTwoElementsInRangeArrays&&!e.every((l,c)=>!Array.isArray(l)||l.length!==2?(s=c,u=l.length,!1):!0))throw new TypeError("ranges-sort/rSort(): [THROW_ID_01] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ".concat(s,"th range (").concat($(e[s],4),") has not two but ").concat(u," elements!"));if(!e.every((l,c)=>!Array.isArray(l)||!Number.isInteger(l[0])||l[0]<0||!Number.isInteger(l[1])||l[1]<0?(s=c,!1):!0))throw new TypeError("ranges-sort/rSort(): [THROW_ID_02] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ".concat(s,"th range (").concat($(e[s],4),") does not consist of only natural numbers!"));let r=e.length**2,g=0;return Array.from(e).sort((l,c)=>(n.progressFn&&(g+=1,n.progressFn(Math.floor(g*100/r))),l[0]===c[0]?l[1]<c[1]?-1:l[1]>c[1]?1:0:l[0]<c[0]?-1:1))}var Qe={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Q(e,t){function n(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}if(!Array.isArray(e)||!e.length)return null;if(t&&!n(t))throw new TypeError("ranges-merge/rMerge(): [THROW_ID_01] the second input argument must be a plain object. It was given as:\n".concat($(t,4)," (type ").concat(typeof t,")"));let s=W(W({},Qe),t);if(s.progressFn&&n(s.progressFn)&&!Object.keys(s.progressFn).length)s.progressFn=null;else if(s.progressFn&&typeof s.progressFn!="function")throw new TypeError('ranges-merge/rMerge(): [THROW_ID_02] opts.progressFn must be a function! It was given of a type: "'.concat(typeof s.progressFn,'", equal to ').concat($(s.progressFn,4)));if(![1,2,"1","2"].includes(s.mergeType))throw new TypeError('ranges-merge/rMerge(): [THROW_ID_03] opts.mergeType was customised to a wrong thing! It was given of a type: "'.concat(typeof s.mergeType,'", equal to ').concat($(s.mergeType,4)));if(typeof s.joinRangesThatTouchEdges!="boolean")throw new TypeError('ranges-merge/rMerge(): [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "'.concat(typeof s.joinRangesThatTouchEdges,'", equal to ').concat($(s.joinRangesThatTouchEdges,4)));let u=e.filter(i=>Array.isArray(i)).map(i=>[...i]).filter(i=>i[2]!==void 0||i[0]!==i[1]),r,g,l;s.progressFn?r=V(u,{progressFn:i=>{l=Math.floor(i/5),l!==g&&(g=l,s.progressFn(l))}}):r=V(u);let c=r.length-1;for(let i=c;i>0;i--)s.progressFn&&(l=Math.floor((1-i/c)*78)+21,l!==g&&l>g&&(g=l,s.progressFn(l))),(r[i][0]<=r[i-1][0]||!s.joinRangesThatTouchEdges&&r[i][0]<r[i-1][1]||s.joinRangesThatTouchEdges&&r[i][0]<=r[i-1][1])&&(r[i-1][0]=Math.min(r[i][0],r[i-1][0]),r[i-1][1]=Math.max(r[i][1],r[i-1][1]),r[i][2]!==void 0&&(r[i-1][0]>=r[i][0]||r[i-1][1]<=r[i][1])&&r[i-1][2]!==null&&(r[i][2]===null&&r[i-1][2]!==null?r[i-1][2]=null:r[i-1][2]!=null?+s.mergeType==2&&r[i-1][0]===r[i][0]?r[i-1][2]=r[i][2]:r[i-1][2]+=r[i][2]:r[i-1][2]=r[i][2]),r.splice(i,1),i=r.length);return r.length?r:null}function J(e){if(typeof e=="number")return Number.isInteger(e)&&e>=0;if(typeof e!="string"||!e.trim())return!1;let t=Number(e);return Number.isInteger(t)&&t>=0}function Z(e,t,n){let s=0,u=0;if(e===void 0&&t===void 0&&n===void 0)throw new Error("ranges-apply/rApply(): [THROW_ID_01] inputs missing!");if(typeof e!="string")throw new TypeError("ranges-apply/rApply(): [THROW_ID_02] first input argument must be a string! Currently it's: ".concat(typeof e,", equal to: ").concat($(e,4)));if(t!=null&&!Array.isArray(t))throw new TypeError("ranges-apply/rApply(): [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ".concat(typeof t,", equal to: ").concat($(t,4)));if(n&&typeof n!="function")throw new TypeError("ranges-apply/rApply(): [THROW_ID_04] the third input argument must be a function (or falsy)! Currently it's: ".concat(typeof n,", equal to: ").concat($(n,4)));if(!(t!=null&&t.some(Boolean)))return e;let r;Array.isArray(t)&&!Array.isArray(t[0])&&J(t[0])&&J(t[1])?r=[Array.from(t)]:r=Array.from(t);let g=r.length,l=0;r.forEach((m,v)=>{if(m){if(n&&(s=Math.floor(l/g*10),s!==u&&(u=s,n(s))),!Array.isArray(m))throw new TypeError("ranges-apply/rApply(): [THROW_ID_05] ranges array, second input arg., has ".concat(v,"th element not an array: ").concat($(m,4),", which is ").concat(typeof m));if(!J(m[0]))throw new TypeError("ranges-apply/rApply(): [THROW_ID_06] ranges array, second input arg. has ".concat(v,"th element, array ").concat($(m),". Its first element is not a non-negative integer or string index, but ").concat(typeof m[0],", equal to: ").concat($(m[0],4),"."));if(typeof m[0]=="string"&&(r[v]=[...m],r[v][0]=Number(m[0])),!J(m[1]))throw new TypeError("ranges-apply/rApply(): [THROW_ID_07] ranges array, second input arg. has ".concat(v,"th element, array ").concat($(m),". Its second element is not a non-negative integer or string index, but ").concat(typeof m[1],", equal to: ").concat($(m[1],4),"."));typeof m[1]=="string"&&(r[v]===m&&(r[v]=[...m]),r[v][1]=Number(m[1])),l+=1}});let c=n?Q(r,{progressFn:m=>{s=10+Math.floor(m/10),s!==u&&(u=s,n(s))}}):Q(r),i=(c==null?void 0:c.length)||0;if(c&&i>0){let m=e.slice(c[i-1][1]);e=c.reduce((v,T,h,a)=>{n&&(s=20+Math.floor(h/i*80),s!==u&&(u=s,n(s)));let p=h===0?0:a[h-1][1],w=a[h][0];return"".concat(v).concat(e.slice(p,w)).concat(a[h][2]||"")},""),e+=m}return e}function G(e,t=1){let n="\xA0";function s(r){return Array.from(r).reverse().join("")}function u(r,g,l){let c=l?"\n":"\r",i=l?"\r":"\n";if(!r)return r;let m=0,v=0,T="";for(let h=0,a=r.length;h<a;h++)(r[h]===c||r[h]===i&&r[h-1]!==c)&&v++,"\r\n".includes(r[h])||r[h]===n?(m=0,r[h]===n?T+=r[h]:r[h]===c?v<=g&&(T+=r[h],r[h+1]===i&&(T+=r[h+1],h++)):r[h]===i&&(r==null?void 0:r[h-1])!==c&&v<=g&&(T+=r[h])):(m++,!r[h+1]&&!v&&(T+=" "));return T}if(typeof e=="string"&&e.length){let r=1;typeof+t=="number"&&Number.isInteger(+t)&&+t>=0&&(r=+t);let g="",l="";if(!e.trim())g=e;else if(!e[0].trim()){for(let c=0,i=e.length;c<i;c++)if(e[c].trim()){g=e.slice(0,c);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===n)){for(let c=e.length;c--;)if(e[c].trim()){l=e.slice(c+1);break}}return"".concat(u(g,r,!1)).concat(e.trim()).concat(s(u(s(l),r,!0)))}return e}var Ze={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Ye(e,t){function n(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}if(!Array.isArray(e)||!e.length)return null;if(t&&!n(t))throw new TypeError("ranges-push/rMerge(): [THROW_ID_10] the second input argument must be a plain object. It was given as:\n".concat($(t,4)," (type ").concat(typeof t,")"));let s=W(W({},Ze),t);if(s.progressFn&&n(s.progressFn)&&!Object.keys(s.progressFn).length)s.progressFn=null;else if(s.progressFn&&typeof s.progressFn!="function")throw new TypeError('ranges-push/rMerge(): [THROW_ID_11] resolvedOpts.progressFn must be a function! It was given of a type: "'.concat(typeof s.progressFn,'", equal to ').concat($(s.progressFn,4)));if(![1,2,"1","2"].includes(s.mergeType))throw new TypeError('ranges-push/rMerge(): [THROW_ID_12] resolvedOpts.mergeType was customised to a wrong thing! It was given of a type: "'.concat(typeof s.mergeType,'", equal to ').concat($(s.mergeType,4)));if(typeof s.joinRangesThatTouchEdges!="boolean")throw new TypeError('ranges-push/rMerge(): [THROW_ID_13] resolvedOpts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "'.concat(typeof s.joinRangesThatTouchEdges,'", equal to ').concat($(s.joinRangesThatTouchEdges,4)));let u=e.filter(i=>Array.isArray(i)).map(i=>[...i]).filter(i=>i[2]!==void 0||i[0]!==i[1]),r,g,l;s.progressFn?r=V(u,{progressFn:i=>{l=Math.floor(i/5),l!==g&&(g=l,s.progressFn!=null&&s.progressFn(l))}}):r=V(u);let c=r.length-1;for(let i=c;i>0;i--)s.progressFn&&(l=Math.floor((1-i/c)*78)+21,l!==g&&l>g&&(g=l,s.progressFn(l))),(r[i][0]<=r[i-1][0]||!s.joinRangesThatTouchEdges&&r[i][0]<r[i-1][1]||s.joinRangesThatTouchEdges&&r[i][0]<=r[i-1][1])&&(r[i-1][0]=Math.min(r[i][0],r[i-1][0]),r[i-1][1]=Math.max(r[i][1],r[i-1][1]),r[i][2]!==void 0&&(r[i-1][0]>=r[i][0]||r[i-1][1]<=r[i][1])&&r[i-1][2]!==null&&(r[i][2]===null&&r[i-1][2]!==null?r[i-1][2]=null:r[i-1][2]!=null?+s.mergeType==2&&r[i-1][0]===r[i][0]?r[i-1][2]=r[i][2]:r[i-1][2]+=r[i][2]:r[i-1][2]=r[i][2]),r.splice(i,1),i=r.length);return r.length?r:null}var Xe={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1};function Te(e){return e[2]===void 0&&e[0]===e[1]}function et(e){let t=-1;for(let n=0,s=e.length;n<s;n++){let u=e[n];if(Array.isArray(u)){if(u[0]<t)return!1;t=u[0]}}return!0}var We=class{constructor(e){F(this,"ranges");F(this,"opts");F(this,"sorted");if(e!=null&&!N(e))throw new TypeError("ranges-push/Ranges/constructor(): [THROW_ID_01] The options argument must be a plain object. It was given as ".concat($(e,4)," (type ").concat(typeof e,")."));let t=W(W({},Xe),e);if(t.mergeType&&t.mergeType!==1&&t.mergeType!==2)if(R(t.mergeType)&&t.mergeType.trim()==="1")t.mergeType=1;else if(R(t.mergeType)&&t.mergeType.trim()==="2")t.mergeType=2;else throw new Error('ranges-push/Ranges/constructor(): [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "'.concat(typeof t.mergeType,'", equal to ').concat($(t.mergeType,4)));this.opts=t,this.ranges=[],this.sorted=!0}add(e,t,n){var r;if(e==null&&t==null)return;if(I(e)&&!I(t)){if(Array.isArray(e)){if(e.length){if(e.some(g=>Array.isArray(g))){e.forEach(g=>{Array.isArray(g)&&this.add(...g)});return}e.length&&M(+e[0])&&M(+e[1])&&this.add(...e)}return}throw new TypeError('ranges-push/Ranges/add(): [THROW_ID_03] the first input argument, "from" is set ('.concat($(e),') but second-one, "to" is not (').concat($(t),")"))}else if(!I(e)&&I(t))throw new TypeError('ranges-push/Ranges/add(): [THROW_ID_04] the second input argument, "to" is set ('.concat($(t),') but first-one, "from" is not (').concat($(e),")"));let s=+e,u=+t;if(M(s)&&M(u)){if(I(n)&&!R(n)&&!Ee(n))throw new TypeError("ranges-push/Ranges/add(): [THROW_ID_05] The third argument, the value to add, was given not as string but ".concat(typeof n,", equal to:\n").concat($(n,4)));if(I(this.ranges)&&Array.isArray(this.last())&&s===this.last()[1]){if(this.last()[1]=u,this.last()[2],this.last()[2]!==null&&I(n)){let g=this.last()[2]&&this.last()[2].length&&(!((r=this.opts)!=null&&r.mergeType)||this.opts.mergeType===1)?"".concat(this.last()[2]).concat(n):n;this.opts.limitToBeAddedWhitespace&&(g=G(g,this.opts.limitLinebreaksCount)),R(g)&&!g.length||(this.last()[2]=g)}}else{this.ranges||(this.ranges=[]);let g=this.last();g&&s<g[0]&&(this.sorted=!1);let l=n!==void 0&&!(R(n)&&!n.length)?[s,u,n&&this.opts.limitToBeAddedWhitespace?G(n,this.opts.limitLinebreaksCount):n]:[s,u];this.ranges.push(l)}}else throw M(s)?new TypeError('ranges-push/Ranges/add(): [THROW_ID_07] "to" value, the second input argument, must be a natural number or zero! Currently it\'s of a type "'.concat(typeof t,'" equal to: ').concat($(t,4))):new TypeError('ranges-push/Ranges/add(): [THROW_ID_06] "from" value, the first input argument, must be a natural number or zero! Currently it\'s of a type "'.concat(typeof e,'" equal to: ').concat($(e,4)))}push(e,t,n){this.add(e,t,n)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=Ye(this.ranges,{mergeType:this.opts.mergeType}),this.sorted=!0,this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>I(e[2])?[e[0],e[1],G(e[2],this.opts.limitLinebreaksCount)]:e):this.ranges):null}firstCovers(e){if(!M(e))throw new TypeError("ranges-push/Ranges/firstCovers(): [THROW_ID_08] the input argument must be a natural number or zero! It was given as ".concat($(e,4)," (type ").concat(typeof e,")"));if(!Array.isArray(this.ranges)||!this.ranges.length)return!1;let t=null;if(this.sorted){for(let s=0,u=this.ranges.length;s<u;s++){let r=this.ranges[s];if(!(!Array.isArray(r)||Te(r))){if(t===null){if(r[0]!==0)return!1;t=r[1]}else{if(r[0]>t)break;r[1]>t&&(t=r[1])}if(t>=e)return!0}}return t!==null&&t>=e}let n=!0;for(;n;){n=!1;for(let s=0,u=this.ranges.length;s<u;s++){let r=this.ranges[s];if(!(!Array.isArray(r)||Te(r))){if(r[0]<0)return!1;(t===null?r[0]===0:r[0]<=t&&r[1]>t)&&(t=r[1],n=!0)}}}return t!==null&&t>=e}wipe(){this.ranges=[],this.sorted=!0}replace(e){if(Array.isArray(e)&&e.length)if(Array.isArray(e[0])&&M(e[0][0]))this.ranges=Array.from(e),this.sorted=et(this.ranges);else throw new Error("ranges-push/Ranges/replace(): [THROW_ID_09] Single range was given but we expected array of arrays! The first element, ".concat($(e[0],4)," should be an array and its first element should be an integer, a string index."));else this.ranges=[],this.sorted=!0}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}};var j="\xA0";function tt({str:e,idx:t=0,stopAtNewlines:n=!1,stopAtRawNbsp:s=!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()||n&&"\n\r".includes(e[t+1])||s&&e[t+1]===j))return t+1;if(e[t+2]&&(e[t+2].trim()||n&&"\n\r".includes(e[t+2])||s&&e[t+2]===j))return t+2;for(let u=t+1,r=e.length;u<r;u++)if(e[u].trim()||n&&"\n\r".includes(e[u])||s&&e[u]===j)return u;return null}function _(e,t=0){return tt({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function rt({str:e,idx:t,stopAtNewlines:n,stopAtRawNbsp:s}){if(typeof e!="string"||!e.length||((!t||typeof t!="number")&&(t=0),t<1))return null;if(e[~-t]&&(e[~-t].trim()||n&&"\n\r".includes(e[~-t])||s&&e[~-t]===j))return~-t;if(e[t-2]&&(e[t-2].trim()||n&&"\n\r".includes(e[t-2])||s&&e[t-2]===j))return t-2;for(let u=t;u--;)if(e[u]&&(e[u].trim()||n&&"\n\r".includes(e[u])||s&&e[u]===j))return u;return null}function k(e,t=0){return rt({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function De(e){return typeof e!="string"?e:e.length?[e]:[]}var Se={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},nt=e=>e+1;function st(e,t,n,s,u=!1,r=nt){var b;let g=typeof n=="function"?n():n;if(+t<0&&u&&g==="EOL")return g;let l=W(W({},Se),s);if(t>=e.length&&!u)return!1;let c=u?1:n.length,i=0,m=!1,v=!1,T=!1,h=l.maxMismatches,a=t,p=!1,w=!1,y=!1;function A(){return i===1&&h<l.maxMismatches-1}for(;e[a];){let d=r(a);if(l.trimBeforeMatching&&e[a].trim()===""){if(!e[d]&&u&&n==="EOL")return!0;a=r(a);continue}if(l&&!l.i&&((b=l==null?void 0:l.trimCharsBeforeMatching)!=null&&b.includes(e[a]))||l!=null&&l.i&&l.trimCharsBeforeMatching&&l.trimCharsBeforeMatching.map(f=>f.toLowerCase()).includes(e[a].toLowerCase())){if(u&&n==="EOL"&&!e[d])return!0;a=r(a);continue}let S=d>a?n[n.length-c]:n[c-1];if(!l.i&&e[a]===S||l.i&&S!==void 0&&e[a].toLowerCase()===S.toLowerCase()){if(p||(p=!0),T||(T=!0),c===n.length){if(w=!0,h!==l.maxMismatches)return!1}else c===1&&(y=!0);if(c-=1,i++,A())return!1;if(!c)return i!==n.length||h===l.maxMismatches||!m?a:!1}else if(!m&&!i&&(m=!0),l.maxMismatches&&h&&a){h-=1;for(let f=0;f<=h;f++){let D=d>a?n[n.length-c+1+f]:n[c-2-f],x=e[r(a)];if(D&&(!l.i&&e[a]===D||l.i&&e[a].toLowerCase()===D.toLowerCase())&&(!l.firstMustMatch||c!==n.length)){if(i++,A())return!1;c-=2,p=!0;break}else if(x&&D&&(!l.i&&x===D||l.i&&x.toLowerCase()===D.toLowerCase())&&(!l.firstMustMatch||c!==n.length)){if(!i&&!l.hungry)return!1;c-=1,p=!0;break}else if(D===void 0&&h>=0&&p&&(!l.firstMustMatch||w)&&(!l.lastMustMatch||y))return a}p||(v=a)}else return a===0&&c===1&&!l.lastMustMatch&&T?0:!1;if(v!==!1&&v!==a&&(v=!1),c<1)return a;a=r(a)}if(c>0)return u&&g==="EOL"?!0:l&&l.maxMismatches>=c&&T?v||0:!1}function ot(e,t,n,s,u){var m,v,T;if(N(u)&&ve(u,"trimBeforeMatching")&&u&&typeof u.trimBeforeMatching!="boolean")throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_01] opts.trimBeforeMatching should be boolean!").concat(Array.isArray(u.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""));let r=W(W({},Se),u);if(typeof r.trimCharsBeforeMatching=="string"&&(r.trimCharsBeforeMatching=De(r.trimCharsBeforeMatching)),r.trimCharsBeforeMatching=r.trimCharsBeforeMatching.map(h=>R(h)?h:String(h)),!R(t)||!t.length)return!1;if(!Number.isInteger(n)||n<0)throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_02] the second argument should be a natural number. Currently it's of a type: ").concat(typeof n,", equal to:\n").concat($(n,4)));let g,l;if(R(s))g=[s];else if(Array.isArray(s))g=s;else if(!s)g=s;else if(typeof s=="function")g=[],g.push(s);else throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_03] the third argument, whatToMatch, is neither string nor array of strings! It's ").concat(typeof s,", equal to:\n").concat($(s,4)));if(u&&!N(u))throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_04] the fourth argument, options object, should be a plain object. Currently it's of a type \"").concat(typeof u,'", and equal to:\n').concat($(u,4)));let c=0,i="";if((m=r==null?void 0:r.trimCharsBeforeMatching)!=null&&m.some((h,a)=>h.length>1?(c=a,i=h,!0):!1))throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_05] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ").concat(c," is longer than 1 character, ").concat(i.length," (equals to ").concat(i,"). Please split it into separate characters and put into array as separate elements."));if(!g||!Array.isArray(g)||Array.isArray(g)&&!g.length||Array.isArray(g)&&g.length===1&&R(g[0])&&!g[0].trim()){if(typeof r.cb=="function"){let a,p=n;if((e==="matchLeftIncl"||e==="matchRight")&&(p+=1),e[5]==="L")for(let b=p;b--;){let d=t[b];if((!r.trimBeforeMatching||r.trimBeforeMatching&&(d!=null&&d.trim()))&&(!((v=r.trimCharsBeforeMatching)!=null&&v.length)||d!==void 0&&!r.trimCharsBeforeMatching.includes(d))){a=b;break}}else if(e.startsWith("matchRight"))for(let b=p;b<t.length;b++){let d=t[b];if((!r.trimBeforeMatching||r.trimBeforeMatching&&d.trim())&&(!((T=r.trimCharsBeforeMatching)!=null&&T.length)||!r.trimCharsBeforeMatching.includes(d))){a=b;break}}if(a===void 0)return!1;let w=t[a],y=a+1,A="";return y&&y>0&&(A=t.slice(0,y)),e[5]==="L"||a&&a>0&&(A=t.slice(a)),r.cb(w,A,a)}let h="";throw u||(h=" More so, the whole options object, the fourth input argument, is missing!"),new Error("string-match-left-right/".concat(e,'(): [THROW_ID_06] 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!').concat(h))}for(let h=0,a=g.length;h<a;h++){l=typeof g[h]=="function";let p=g[h],w,y,A="",b=n;e==="matchRight"?b+=1:e==="matchLeft"&&(b-=1);let d=st(t,b,p,r,l,S=>e[5]==="L"?S-1:S+1);if(d&&l&&typeof p=="function"&&p()==="EOL")return p()&&(!r.cb||r.cb(w,A,y))?p():!1;if(Number.isInteger(d)&&(y=e.startsWith("matchLeft")?d-1:d+1,e[5]==="L"?A=t.slice(0,d):A=t.slice(y)),y<0&&(y=void 0),t[y]&&(w=t[y]),Number.isInteger(d)&&(!r.cb||r.cb(w,A,y)))return p}return!1}function Ce(e,t,n,s){return ot("matchRightIncl",e,t,n,s)}var Re="4.2.1";var H=" ",P="\\00A0",B="\\u00A0",Oe="–",Ne="\\2013",Me="\\u2013",Ie="—",xe="\\2014",Le="\\u2014",Y=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],Ve=[{heads:"{{",tails:"}}"}],X=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],je=["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 at=Re,_e={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};function lt(e,t){var te,re,ne,se,oe,ie,ae,le,ue,fe,ge,ce;let n=Date.now();if(typeof e!="string")throw e===void 0?new Error("string-remove-widows/removeWidows(): [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error('string-remove-widows/removeWidows(): [THROW_ID_02] the first input argument must be string! It was given as "'.concat(typeof e,'", equal to:\n').concat($(e,4)));if(t&&!N(t))throw new Error("string-remove-widows/removeWidows(): [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ".concat(typeof t,", equal to ").concat($(t,4)));let s=Array.isArray,u=e.length,r=new We({mergeType:2}),g=["."],l=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,c=/^[0-9][A-Z]{2}/,i=.06,m,v=0,T=0,h=0,a,p,w,y,A,b,d,S,f=W(W({},_e),t),D={removeWidows:!1,convertEntities:!1};if(!f.ignore||!s(f.ignore)&&typeof f.ignore!="string")f.ignore=[];else if(typeof f.ignore=="string"&&(f.ignore=[f.ignore]),f.ignore.includes("all"))f.ignore=f.ignore.concat(Y.concat(X));else if(f.ignore.some(o=>typeof o=="string")){let o=[];f.ignore=f.ignore.filter(C=>typeof C=="string"&&C.length?(["nunjucks","jinja","liquid"].includes(C.trim().toLowerCase())?o=o.concat(Y):["hugo"].includes(C.trim().toLowerCase())?o=o.concat(Ve):["hexo"].includes(C.trim().toLowerCase())&&(o=o.concat(X)),!1):typeof C=="object"),o.length&&(f.ignore=f.ignore.concat(o))}let x;f.reportProgressFunc&&(x=Math.floor(f.reportProgressFuncTo-(f.reportProgressFuncTo-f.reportProgressFuncFrom)*i-f.reportProgressFuncFrom));function z(o,C){let E=L;f.removeWidowPreventionMeasures?E=" ":f.convertEntities&&(E=H,typeof f.targetLanguage=="string"&&(f.targetLanguage.trim().toLowerCase()==="css"?E=P:f.targetLanguage.trim().toLowerCase()==="js"&&(E=B))),e.slice(o,C)!==E&&r.push(o,C,E)}function ee(){T=0,h=0,a=void 0,p=void 0,w=void 0,y=void 0,A=void 0,b=void 0}ee();for(let o=0;o<=u;o++){if(!d&&s(f.ignore)&&f.ignore.length&&f.ignore.some((E,O)=>s(E.heads)&&E.heads.some(he=>e.startsWith(he,o))||typeof E.heads=="string"&&e.startsWith(E.heads,o)?(T+=1,d=f.ignore[O].tails,!0):!1),!d&&S&&S===o&&(T+=1,S=void 0),typeof f.reportProgressFunc=="function"&&(m=f.reportProgressFuncFrom+Math.floor(o/u*(x||1)),m!==v&&(v=m,f.reportProgressFunc(m))),!d&&o&&((te=e[o])!=null&&te.trim())&&(!e[o-1]||e[o-1]&&!e[o-1].trim())&&(y=o),!d&&((re=e[o])!=null&&re.trim())&&(h+=1),!d&&f.hyphens&&("-".concat(Ae).concat(we).includes(e[o])||e.startsWith(Oe,o)||e.startsWith(Ne,o)||e.startsWith(Me,o)||e.startsWith(Ie,o)||e.startsWith(xe,o)||e.startsWith(Le,o))&&e[o+1]&&(!e[o+1].trim()||e[o]==="&")&&e[o-1]&&!e[o-1].trim()&&e[k(e,o)]&&(z(k(e,o)+1,o),D.removeWidows=!0),!d&&(e.startsWith(" ",o)||e.startsWith(" ",o))&&(A=o,b=o+6,(ne=e[o+6])!=null&&ne.trim()&&(S=o+6),f.convertEntities?(f.targetLanguage==="css"||f.targetLanguage==="js")&&(r.push(o,o+6,f.targetLanguage==="css"?P:B),D.convertEntities=!0):(r.push(o,o+6,L),D.convertEntities=!0)),!d&&e[o+4]&&e[o]==="\\"&&e[o+1]==="0"&&e[o+2]==="0"&&e[o+3].toUpperCase()==="A"&&e[o+4]==="0"&&(A=o,b=o+5,(se=e[o+5])!=null&&se.trim()&&(S=o+5),f.convertEntities?(f.targetLanguage==="html"||f.targetLanguage==="js")&&(r.push(o,o+5,f.targetLanguage==="html"?H:B),D.convertEntities=!0):(r.push(o,o+5,L),D.convertEntities=!0)),!d&&e[o]==="\\"&&((oe=e[o+1])==null?void 0:oe.toLowerCase())==="u"&&e[o+2]==="0"&&e[o+3]==="0"&&((ie=e[o+4])==null?void 0:ie.toUpperCase())==="A"&&e[o+5]==="0"&&(A=o,b=o+6,(ae=e[o+6])!=null&&ae.trim()&&(S=o+6),f.convertEntities?(f.targetLanguage==="html"||f.targetLanguage==="css")&&r.push(o,o+6,f.targetLanguage==="html"?H:P):r.push(o,o+6,L)),!d&&e[o]===L&&(A=o,b=o+1,f.convertEntities&&r.push(o,o+1,f.targetLanguage==="css"?P:f.targetLanguage==="js"?B:H)),!d&&((le=e[o])!=null&&le.trim())&&!((ue=e[o-1])!=null&&ue.trim())&&(T+=1),!d&&(!e[o]||"\r\n".includes(e[o])||(e[o]==="\n"||e[o]==="\r"||e[o]==="\r"&&e[o+1]==="\n")&&k(e,o)&&g.includes(e[k(e,o)]))){if((!f.minWordCount||T>=f.minWordCount)&&(!f.minCharCount||h>=f.minCharCount)){let E,O;w!==void 0&&y!==void 0&&A!==void 0&&b!==void 0?w>A?(E=w,O=y):(E=A,O=b):w!==void 0&&y!==void 0?(E=w,O=y):A!==void 0&&b!==void 0&&(E=A,O=b),!(E&&O)&&a&&p&&(E=a,O=p),E&&O&&(z(E,O),D.removeWidows=!0)}ee()}f.UKPostcodes&&e[o]&&!e[o].trim()&&((fe=e[o-1])!=null&&fe.trim())&&l.test(e.slice(0,o))&&e[_(e,o)]&&c.test(e.slice(_(e,o)))&&(z(o,_(e,o)),D.removeWidows=!0),!d&&e[o]&&!e[o].trim()&&((ge=e[o-1])!=null&&ge.trim())&&(w===void 0||(ce=e[w-1])!=null&&ce.trim())&&!"/>".includes(e[_(e,o)])&&!e.slice(0,o).trim().endsWith("br")&&!e.slice(0,o).trim().endsWith("hr")&&!(e.slice(0,o).endsWith("<")&&je.some(E=>e.startsWith(E,_(e,o))))&&(a=w,p=y,w=o,y=void 0,(A!==void 0||b!==void 0)&&(A=void 0,b=void 0));let C;d&&(typeof d=="string"&&(!d.length||e.startsWith(d,o))?d=void 0:s(d)&&(!d.length||d.some(E=>e.startsWith(E,o)?(C=E,!0):!1))&&(d=void 0,o+=C.length,s(f.ignore)&&f.ignore.length&&e[o+1]&&f.ignore.some(E=>Ce(e,o,E.tails,{trimBeforeMatching:!0,cb:(O,he,de)=>{var pe;return de&&(o=de-1,(pe=e[o+1])!=null&&pe.trim()&&(T+=1)),!0}})))),e[o]&&"\r\n".includes(e[o])&&(T=0,h=0),s(f.tagRanges)&&f.tagRanges.length&&f.tagRanges.some(E=>o>=E[0]&&o<=E[1]&&E[1]-1>o?(o=E[1]-1,!0):!1)}return Z(e,r.current()).split("").forEach((o,C)=>{}),{res:Z(e,r.current(),f.reportProgressFunc?o=>{m=Math.floor((f.reportProgressFuncTo-f.reportProgressFuncFrom)*(1-i)+o/100*(f.reportProgressFuncTo-f.reportProgressFuncFrom)*i),m!==v&&(v=m,f.reportProgressFunc(m))}:void 0),ranges:r.current(),log:{timeTakenInMilliseconds:Date.now()-n},whatWasDone:D}}return Ue(ut);})();
|
|
11
11
|
/**
|
|
12
12
|
* @name codsen-utils
|
|
13
13
|
* @fileoverview Various utility functions
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
/**
|
|
28
28
|
* @name ranges-merge
|
|
29
29
|
* @fileoverview Merge and sort string index ranges
|
|
30
|
-
* @version 9.2.
|
|
30
|
+
* @version 9.2.1
|
|
31
31
|
* @author Roy Revelt
|
|
32
32
|
* @license MIT
|
|
33
33
|
* {@link https://codsen.com/os/ranges-merge/}
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
/**
|
|
36
36
|
* @name ranges-apply
|
|
37
37
|
* @fileoverview Take an array of string index ranges, delete/replace the string according to them
|
|
38
|
-
* @version 7.2.
|
|
38
|
+
* @version 7.2.1
|
|
39
39
|
* @author Roy Revelt
|
|
40
40
|
* @license MIT
|
|
41
41
|
* {@link https://codsen.com/os/ranges-apply/}
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
/**
|
|
68
68
|
* @name arrayiffy-if-string
|
|
69
69
|
* @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
|
|
70
|
-
* @version 5.2.
|
|
70
|
+
* @version 5.2.1
|
|
71
71
|
* @author Roy Revelt
|
|
72
72
|
* @license MIT
|
|
73
73
|
* {@link https://codsen.com/os/arrayiffy-if-string/}
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
/**
|
|
76
76
|
* @name string-match-left-right
|
|
77
77
|
* @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
|
|
78
|
-
* @version 9.2.
|
|
78
|
+
* @version 9.2.1
|
|
79
79
|
* @author Roy Revelt
|
|
80
80
|
* @license MIT
|
|
81
81
|
* {@link https://codsen.com/os/string-match-left-right/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-remove-widows",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "Helps to prevent widow words in a text",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"against",
|
|
@@ -72,13 +72,13 @@
|
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"codsen-utils": "^1.8.0",
|
|
75
|
-
"ranges-apply": "^7.2.
|
|
75
|
+
"ranges-apply": "^7.2.1",
|
|
76
76
|
"ranges-push": "^7.2.0",
|
|
77
77
|
"string-left-right": "^6.2.0",
|
|
78
|
-
"string-match-left-right": "^9.2.
|
|
78
|
+
"string-match-left-right": "^9.2.1"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"string-strip-html": "^13.6.
|
|
81
|
+
"string-strip-html": "^13.6.1"
|
|
82
82
|
},
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": ">=18.20.8"
|