From a9f02090f789a9680772f1606f84c722617610df Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Wed, 17 Jul 2024 14:38:04 -0400 Subject: [PATCH] Fixes USFM download --- .../assets/js-dcs/usfm-alignment-remover.js | 9524 ++++++++++++++++- templates/repo/branch/list.tmpl | 8 + templates/repo/dcs_metadata.tmpl | 4 +- templates/repo/home.tmpl | 14 +- templates/repo/release/list.tmpl | 10 +- templates/repo/tag/list.tmpl | 10 + 6 files changed, 9511 insertions(+), 59 deletions(-) diff --git a/public/assets/js-dcs/usfm-alignment-remover.js b/public/assets/js-dcs/usfm-alignment-remover.js index d1315a5ee3..1d07e32fa8 100644 --- a/public/assets/js-dcs/usfm-alignment-remover.js +++ b/public/assets/js-dcs/usfm-alignment-remover.js @@ -1,55 +1,9479 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function e(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=e(s);fetch(s.href,i)}})();function un(n,t){return function(){return n.apply(t,arguments)}}const{toString:us}=Object.prototype,{getPrototypeOf:fr}=Object,Le=(n=>t=>{const e=us.call(t);return n[e]||(n[e]=e.slice(8,-1).toLowerCase())})(Object.create(null)),Pt=n=>(n=n.toLowerCase(),t=>Le(t)===n),Ue=n=>t=>typeof t===n,{isArray:oe}=Array,pe=Ue("undefined");function ls(n){return n!==null&&!pe(n)&&n.constructor!==null&&!pe(n.constructor)&&Rt(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const ln=Pt("ArrayBuffer");function fs(n){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(n):t=n&&n.buffer&&ln(n.buffer),t}const cs=Ue("string"),Rt=Ue("function"),fn=Ue("number"),Me=n=>n!==null&&typeof n=="object",ds=n=>n===!0||n===!1,Ce=n=>{if(Le(n)!=="object")return!1;const t=fr(n);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)},hs=Pt("Date"),ps=Pt("File"),gs=Pt("Blob"),ms=Pt("FileList"),ys=n=>Me(n)&&Rt(n.pipe),vs=n=>{let t;return n&&(typeof FormData=="function"&&n instanceof FormData||Rt(n.append)&&((t=Le(n))==="formdata"||t==="object"&&Rt(n.toString)&&n.toString()==="[object FormData]"))},_s=Pt("URLSearchParams"),[bs,ws,Ss,xs]=["ReadableStream","Request","Response","Headers"].map(Pt),Ts=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ge(n,t,{allOwnKeys:e=!1}={}){if(n===null||typeof n>"u")return;let r,s;if(typeof n!="object"&&(n=[n]),oe(n))for(r=0,s=n.length;r0;)if(s=e[r],t===s.toLowerCase())return s;return null}const dn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,hn=n=>!pe(n)&&n!==dn;function er(){const{caseless:n}=hn(this)&&this||{},t={},e=(r,s)=>{const i=n&&cn(t,s)||s;Ce(t[i])&&Ce(r)?t[i]=er(t[i],r):Ce(r)?t[i]=er({},r):oe(r)?t[i]=r.slice():t[i]=r};for(let r=0,s=arguments.length;r(ge(t,(s,i)=>{e&&Rt(s)?n[i]=un(s,e):n[i]=s},{allOwnKeys:r}),n),Cs=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),As=(n,t,e,r)=>{n.prototype=Object.create(t.prototype,r),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:t.prototype}),e&&Object.assign(n.prototype,e)},ks=(n,t,e,r)=>{let s,i,a;const o={};if(t=t||{},n==null)return t;do{for(s=Object.getOwnPropertyNames(n),i=s.length;i-- >0;)a=s[i],(!r||r(a,n,t))&&!o[a]&&(t[a]=n[a],o[a]=!0);n=e!==!1&&fr(n)}while(n&&(!e||e(n,t))&&n!==Object.prototype);return t},Rs=(n,t,e)=>{n=String(n),(e===void 0||e>n.length)&&(e=n.length),e-=t.length;const r=n.indexOf(t,e);return r!==-1&&r===e},Os=n=>{if(!n)return null;if(oe(n))return n;let t=n.length;if(!fn(t))return null;const e=new Array(t);for(;t-- >0;)e[t]=n[t];return e},zs=(n=>t=>n&&t instanceof n)(typeof Uint8Array<"u"&&fr(Uint8Array)),Is=(n,t)=>{const r=(n&&n[Symbol.iterator]).call(n);let s;for(;(s=r.next())&&!s.done;){const i=s.value;t.call(n,i[0],i[1])}},Fs=(n,t)=>{let e;const r=[];for(;(e=n.exec(t))!==null;)r.push(e);return r},Ps=Pt("HTMLFormElement"),Bs=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,r,s){return r.toUpperCase()+s}),Fr=(({hasOwnProperty:n})=>(t,e)=>n.call(t,e))(Object.prototype),Ns=Pt("RegExp"),pn=(n,t)=>{const e=Object.getOwnPropertyDescriptors(n),r={};ge(e,(s,i)=>{let a;(a=t(s,i,n))!==!1&&(r[i]=a||s)}),Object.defineProperties(n,r)},Ds=n=>{pn(n,(t,e)=>{if(Rt(n)&&["arguments","caller","callee"].indexOf(e)!==-1)return!1;const r=n[e];if(Rt(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+e+"'")})}})},Ls=(n,t)=>{const e={},r=s=>{s.forEach(i=>{e[i]=!0})};return oe(n)?r(n):r(String(n).split(t)),e},Us=()=>{},Ms=(n,t)=>n!=null&&Number.isFinite(n=+n)?n:t,Xe="abcdefghijklmnopqrstuvwxyz",Pr="0123456789",gn={DIGIT:Pr,ALPHA:Xe,ALPHA_DIGIT:Xe+Xe.toUpperCase()+Pr},qs=(n=16,t=gn.ALPHA_DIGIT)=>{let e="";const{length:r}=t;for(;n--;)e+=t[Math.random()*r|0];return e};function Ws(n){return!!(n&&Rt(n.append)&&n[Symbol.toStringTag]==="FormData"&&n[Symbol.iterator])}const Hs=n=>{const t=new Array(10),e=(r,s)=>{if(Me(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const i=oe(r)?[]:{};return ge(r,(a,o)=>{const l=e(a,s+1);!pe(l)&&(i[o]=l)}),t[s]=void 0,i}}return r};return e(n,0)},Vs=Pt("AsyncFunction"),Zs=n=>n&&(Me(n)||Rt(n))&&Rt(n.then)&&Rt(n.catch),N={isArray:oe,isArrayBuffer:ln,isBuffer:ls,isFormData:vs,isArrayBufferView:fs,isString:cs,isNumber:fn,isBoolean:ds,isObject:Me,isPlainObject:Ce,isReadableStream:bs,isRequest:ws,isResponse:Ss,isHeaders:xs,isUndefined:pe,isDate:hs,isFile:ps,isBlob:gs,isRegExp:Ns,isFunction:Rt,isStream:ys,isURLSearchParams:_s,isTypedArray:zs,isFileList:ms,forEach:ge,merge:er,extend:Es,trim:Ts,stripBOM:Cs,inherits:As,toFlatObject:ks,kindOf:Le,kindOfTest:Pt,endsWith:Rs,toArray:Os,forEachEntry:Is,matchAll:Fs,isHTMLForm:Ps,hasOwnProperty:Fr,hasOwnProp:Fr,reduceDescriptors:pn,freezeMethods:Ds,toObjectSet:Ls,toCamelCase:Bs,noop:Us,toFiniteNumber:Ms,findKey:cn,global:dn,isContextDefined:hn,ALPHABET:gn,generateString:qs,isSpecCompliantForm:Ws,toJSONObject:Hs,isAsyncFn:Vs,isThenable:Zs};function at(n,t,e,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",t&&(this.code=t),e&&(this.config=e),r&&(this.request=r),s&&(this.response=s)}N.inherits(at,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:N.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const mn=at.prototype,yn={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{yn[n]={value:n}});Object.defineProperties(at,yn);Object.defineProperty(mn,"isAxiosError",{value:!0});at.from=(n,t,e,r,s,i)=>{const a=Object.create(mn);return N.toFlatObject(n,a,function(l){return l!==Error.prototype},o=>o!=="isAxiosError"),at.call(a,n.message,t,e,r,s),a.cause=n,a.name=n.name,i&&Object.assign(a,i),a};const js=null;function rr(n){return N.isPlainObject(n)||N.isArray(n)}function vn(n){return N.endsWith(n,"[]")?n.slice(0,-2):n}function Br(n,t,e){return n?n.concat(t).map(function(s,i){return s=vn(s),!e&&i?"["+s+"]":s}).join(e?".":""):t}function Gs(n){return N.isArray(n)&&!n.some(rr)}const $s=N.toFlatObject(N,{},null,function(t){return/^is[A-Z]/.test(t)});function qe(n,t,e){if(!N.isObject(n))throw new TypeError("target must be an object");t=t||new FormData,e=N.toFlatObject(e,{metaTokens:!0,dots:!1,indexes:!1},!1,function(d,v){return!N.isUndefined(v[d])});const r=e.metaTokens,s=e.visitor||g,i=e.dots,a=e.indexes,l=(e.Blob||typeof Blob<"u"&&Blob)&&N.isSpecCompliantForm(t);if(!N.isFunction(s))throw new TypeError("visitor must be a function");function c(y){if(y===null)return"";if(N.isDate(y))return y.toISOString();if(!l&&N.isBlob(y))throw new at("Blob is not supported. Use a Buffer instead.");return N.isArrayBuffer(y)||N.isTypedArray(y)?l&&typeof Blob=="function"?new Blob([y]):Buffer.from(y):y}function g(y,d,v){let m=y;if(y&&!v&&typeof y=="object"){if(N.endsWith(d,"{}"))d=r?d:d.slice(0,-2),y=JSON.stringify(y);else if(N.isArray(y)&&Gs(y)||(N.isFileList(y)||N.endsWith(d,"[]"))&&(m=N.toArray(y)))return d=vn(d),m.forEach(function(T,k){!(N.isUndefined(T)||T===null)&&t.append(a===!0?Br([d],k,i):a===null?d:d+"[]",c(T))}),!1}return rr(y)?!0:(t.append(Br(v,d,i),c(y)),!1)}const f=[],w=Object.assign($s,{defaultVisitor:g,convertValue:c,isVisitable:rr});function p(y,d){if(!N.isUndefined(y)){if(f.indexOf(y)!==-1)throw Error("Circular reference detected in "+d.join("."));f.push(y),N.forEach(y,function(m,S){(!(N.isUndefined(m)||m===null)&&s.call(t,m,N.isString(S)?S.trim():S,d,w))===!0&&p(m,d?d.concat(S):[S])}),f.pop()}}if(!N.isObject(n))throw new TypeError("data must be an object");return p(n),t}function Nr(n){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function cr(n,t){this._pairs=[],n&&qe(n,this,t)}const _n=cr.prototype;_n.append=function(t,e){this._pairs.push([t,e])};_n.toString=function(t){const e=t?function(r){return t.call(this,r,Nr)}:Nr;return this._pairs.map(function(s){return e(s[0])+"="+e(s[1])},"").join("&")};function Js(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function bn(n,t,e){if(!t)return n;const r=e&&e.encode||Js,s=e&&e.serialize;let i;if(s?i=s(t,e):i=N.isURLSearchParams(t)?t.toString():new cr(t,e).toString(r),i){const a=n.indexOf("#");a!==-1&&(n=n.slice(0,a)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class Dr{constructor(){this.handlers=[]}use(t,e,r){return this.handlers.push({fulfilled:t,rejected:e,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){N.forEach(this.handlers,function(r){r!==null&&t(r)})}}const wn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ks=typeof URLSearchParams<"u"?URLSearchParams:cr,Xs=typeof FormData<"u"?FormData:null,Ys=typeof Blob<"u"?Blob:null,Qs={isBrowser:!0,classes:{URLSearchParams:Ks,FormData:Xs,Blob:Ys},protocols:["http","https","file","blob","url","data"]},dr=typeof window<"u"&&typeof document<"u",ta=(n=>dr&&["ReactNative","NativeScript","NS"].indexOf(n)<0)(typeof navigator<"u"&&navigator.product),ea=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ra=dr&&window.location.href||"http://localhost",na=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:dr,hasStandardBrowserEnv:ta,hasStandardBrowserWebWorkerEnv:ea,origin:ra},Symbol.toStringTag,{value:"Module"})),Ft={...na,...Qs};function ia(n,t){return qe(n,new Ft.classes.URLSearchParams,Object.assign({visitor:function(e,r,s,i){return Ft.isNode&&N.isBuffer(e)?(this.append(r,e.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function sa(n){return N.matchAll(/\w+|\[(\w*)]/g,n).map(t=>t[0]==="[]"?"":t[1]||t[0])}function aa(n){const t={},e=Object.keys(n);let r;const s=e.length;let i;for(r=0;r=e.length;return a=!a&&N.isArray(s)?s.length:a,l?(N.hasOwnProp(s,a)?s[a]=[s[a],r]:s[a]=r,!o):((!s[a]||!N.isObject(s[a]))&&(s[a]=[]),t(e,r,s[a],i)&&N.isArray(s[a])&&(s[a]=aa(s[a])),!o)}if(N.isFormData(n)&&N.isFunction(n.entries)){const e={};return N.forEachEntry(n,(r,s)=>{t(sa(r),s,e,0)}),e}return null}function oa(n,t,e){if(N.isString(n))try{return(t||JSON.parse)(n),N.trim(n)}catch(r){if(r.name!=="SyntaxError")throw r}return(e||JSON.stringify)(n)}const me={transitional:wn,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const r=e.getContentType()||"",s=r.indexOf("application/json")>-1,i=N.isObject(t);if(i&&N.isHTMLForm(t)&&(t=new FormData(t)),N.isFormData(t))return s?JSON.stringify(Sn(t)):t;if(N.isArrayBuffer(t)||N.isBuffer(t)||N.isStream(t)||N.isFile(t)||N.isBlob(t)||N.isReadableStream(t))return t;if(N.isArrayBufferView(t))return t.buffer;if(N.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return ia(t,this.formSerializer).toString();if((o=N.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return qe(o?{"files[]":t}:t,l&&new l,this.formSerializer)}}return i||s?(e.setContentType("application/json",!1),oa(t)):t}],transformResponse:[function(t){const e=this.transitional||me.transitional,r=e&&e.forcedJSONParsing,s=this.responseType==="json";if(N.isResponse(t)||N.isReadableStream(t))return t;if(t&&N.isString(t)&&(r&&!this.responseType||s)){const a=!(e&&e.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(o){if(a)throw o.name==="SyntaxError"?at.from(o,at.ERR_BAD_RESPONSE,this,null,this.response):o}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ft.classes.FormData,Blob:Ft.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};N.forEach(["delete","get","head","post","put","patch"],n=>{me.headers[n]={}});const ua=N.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),la=n=>{const t={};let e,r,s;return n&&n.split(` -`).forEach(function(a){s=a.indexOf(":"),e=a.substring(0,s).trim().toLowerCase(),r=a.substring(s+1).trim(),!(!e||t[e]&&ua[e])&&(e==="set-cookie"?t[e]?t[e].push(r):t[e]=[r]:t[e]=t[e]?t[e]+", "+r:r)}),t},Lr=Symbol("internals");function de(n){return n&&String(n).trim().toLowerCase()}function Ae(n){return n===!1||n==null?n:N.isArray(n)?n.map(Ae):String(n)}function fa(n){const t=Object.create(null),e=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=e.exec(n);)t[r[1]]=r[2];return t}const ca=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function Ye(n,t,e,r,s){if(N.isFunction(r))return r.call(this,t,e);if(s&&(t=e),!!N.isString(t)){if(N.isString(r))return t.indexOf(r)!==-1;if(N.isRegExp(r))return r.test(t)}}function da(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,r)=>e.toUpperCase()+r)}function ha(n,t){const e=N.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(n,r+e,{value:function(s,i,a){return this[r].call(this,t,s,i,a)},configurable:!0})})}class xt{constructor(t){t&&this.set(t)}set(t,e,r){const s=this;function i(o,l,c){const g=de(l);if(!g)throw new Error("header name must be a non-empty string");const f=N.findKey(s,g);(!f||s[f]===void 0||c===!0||c===void 0&&s[f]!==!1)&&(s[f||l]=Ae(o))}const a=(o,l)=>N.forEach(o,(c,g)=>i(c,g,l));if(N.isPlainObject(t)||t instanceof this.constructor)a(t,e);else if(N.isString(t)&&(t=t.trim())&&!ca(t))a(la(t),e);else if(N.isHeaders(t))for(const[o,l]of t.entries())i(l,o,r);else t!=null&&i(e,t,r);return this}get(t,e){if(t=de(t),t){const r=N.findKey(this,t);if(r){const s=this[r];if(!e)return s;if(e===!0)return fa(s);if(N.isFunction(e))return e.call(this,s,r);if(N.isRegExp(e))return e.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=de(t),t){const r=N.findKey(this,t);return!!(r&&this[r]!==void 0&&(!e||Ye(this,this[r],r,e)))}return!1}delete(t,e){const r=this;let s=!1;function i(a){if(a=de(a),a){const o=N.findKey(r,a);o&&(!e||Ye(r,r[o],o,e))&&(delete r[o],s=!0)}}return N.isArray(t)?t.forEach(i):i(t),s}clear(t){const e=Object.keys(this);let r=e.length,s=!1;for(;r--;){const i=e[r];(!t||Ye(this,this[i],i,t,!0))&&(delete this[i],s=!0)}return s}normalize(t){const e=this,r={};return N.forEach(this,(s,i)=>{const a=N.findKey(r,i);if(a){e[a]=Ae(s),delete e[i];return}const o=t?da(i):String(i).trim();o!==i&&delete e[i],e[o]=Ae(s),r[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return N.forEach(this,(r,s)=>{r!=null&&r!==!1&&(e[s]=t&&N.isArray(r)?r.join(", "):r)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,e])=>t+": "+e).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const r=new this(t);return e.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[Lr]=this[Lr]={accessors:{}}).accessors,s=this.prototype;function i(a){const o=de(a);r[o]||(ha(s,a),r[o]=!0)}return N.isArray(t)?t.forEach(i):i(t),this}}xt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);N.reduceDescriptors(xt.prototype,({value:n},t)=>{let e=t[0].toUpperCase()+t.slice(1);return{get:()=>n,set(r){this[e]=r}}});N.freezeMethods(xt);function Qe(n,t){const e=this||me,r=t||e,s=xt.from(r.headers);let i=r.data;return N.forEach(n,function(o){i=o.call(e,i,s.normalize(),t?t.status:void 0)}),s.normalize(),i}function xn(n){return!!(n&&n.__CANCEL__)}function ue(n,t,e){at.call(this,n??"canceled",at.ERR_CANCELED,t,e),this.name="CanceledError"}N.inherits(ue,at,{__CANCEL__:!0});function Tn(n,t,e){const r=e.config.validateStatus;!e.status||!r||r(e.status)?n(e):t(new at("Request failed with status code "+e.status,[at.ERR_BAD_REQUEST,at.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e))}function pa(n){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return t&&t[1]||""}function ga(n,t){n=n||10;const e=new Array(n),r=new Array(n);let s=0,i=0,a;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),g=r[i];a||(a=c),e[s]=l,r[s]=c;let f=i,w=0;for(;f!==s;)w+=e[f++],f=f%n;if(s=(s+1)%n,s===i&&(i=(i+1)%n),c-ar)return s&&(clearTimeout(s),s=null),e=o,n.apply(null,arguments);s||(s=setTimeout(()=>(s=null,e=Date.now(),n.apply(null,arguments)),r-(o-e)))}}const Fe=(n,t,e=3)=>{let r=0;const s=ga(50,250);return ma(i=>{const a=i.loaded,o=i.lengthComputable?i.total:void 0,l=a-r,c=s(l),g=a<=o;r=a;const f={loaded:a,total:o,progress:o?a/o:void 0,bytes:l,rate:c||void 0,estimated:c&&o&&g?(o-a)/c:void 0,event:i,lengthComputable:o!=null};f[t?"download":"upload"]=!0,n(f)},e)},ya=Ft.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),e=document.createElement("a");let r;function s(i){let a=i;return t&&(e.setAttribute("href",a),a=e.href),e.setAttribute("href",a),{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",host:e.host,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):"",hostname:e.hostname,port:e.port,pathname:e.pathname.charAt(0)==="/"?e.pathname:"/"+e.pathname}}return r=s(window.location.href),function(a){const o=N.isString(a)?s(a):a;return o.protocol===r.protocol&&o.host===r.host}}():function(){return function(){return!0}}(),va=Ft.hasStandardBrowserEnv?{write(n,t,e,r,s,i){const a=[n+"="+encodeURIComponent(t)];N.isNumber(e)&&a.push("expires="+new Date(e).toGMTString()),N.isString(r)&&a.push("path="+r),N.isString(s)&&a.push("domain="+s),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read(n){const t=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function _a(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function ba(n,t){return t?n.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):n}function En(n,t){return n&&!_a(t)?ba(n,t):t}const Ur=n=>n instanceof xt?{...n}:n;function Xt(n,t){t=t||{};const e={};function r(c,g,f){return N.isPlainObject(c)&&N.isPlainObject(g)?N.merge.call({caseless:f},c,g):N.isPlainObject(g)?N.merge({},g):N.isArray(g)?g.slice():g}function s(c,g,f){if(N.isUndefined(g)){if(!N.isUndefined(c))return r(void 0,c,f)}else return r(c,g,f)}function i(c,g){if(!N.isUndefined(g))return r(void 0,g)}function a(c,g){if(N.isUndefined(g)){if(!N.isUndefined(c))return r(void 0,c)}else return r(void 0,g)}function o(c,g,f){if(f in t)return r(c,g);if(f in n)return r(void 0,c)}const l={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(c,g)=>s(Ur(c),Ur(g),!0)};return N.forEach(Object.keys(Object.assign({},n,t)),function(g){const f=l[g]||s,w=f(n[g],t[g],g);N.isUndefined(w)&&f!==o||(e[g]=w)}),e}const Cn=n=>{const t=Xt({},n);let{data:e,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:i,headers:a,auth:o}=t;t.headers=a=xt.from(a),t.url=bn(En(t.baseURL,t.url),n.params,n.paramsSerializer),o&&a.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):"")));let l;if(N.isFormData(e)){if(Ft.hasStandardBrowserEnv||Ft.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((l=a.getContentType())!==!1){const[c,...g]=l?l.split(";").map(f=>f.trim()).filter(Boolean):[];a.setContentType([c||"multipart/form-data",...g].join("; "))}}if(Ft.hasStandardBrowserEnv&&(r&&N.isFunction(r)&&(r=r(t)),r||r!==!1&&ya(t.url))){const c=s&&i&&va.read(i);c&&a.set(s,c)}return t},wa=typeof XMLHttpRequest<"u",Sa=wa&&function(n){return new Promise(function(e,r){const s=Cn(n);let i=s.data;const a=xt.from(s.headers).normalize();let{responseType:o}=s,l;function c(){s.cancelToken&&s.cancelToken.unsubscribe(l),s.signal&&s.signal.removeEventListener("abort",l)}let g=new XMLHttpRequest;g.open(s.method.toUpperCase(),s.url,!0),g.timeout=s.timeout;function f(){if(!g)return;const p=xt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),d={data:!o||o==="text"||o==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:p,config:n,request:g};Tn(function(m){e(m),c()},function(m){r(m),c()},d),g=null}"onloadend"in g?g.onloadend=f:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(f)},g.onabort=function(){g&&(r(new at("Request aborted",at.ECONNABORTED,s,g)),g=null)},g.onerror=function(){r(new at("Network Error",at.ERR_NETWORK,s,g)),g=null},g.ontimeout=function(){let y=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const d=s.transitional||wn;s.timeoutErrorMessage&&(y=s.timeoutErrorMessage),r(new at(y,d.clarifyTimeoutError?at.ETIMEDOUT:at.ECONNABORTED,s,g)),g=null},i===void 0&&a.setContentType(null),"setRequestHeader"in g&&N.forEach(a.toJSON(),function(y,d){g.setRequestHeader(d,y)}),N.isUndefined(s.withCredentials)||(g.withCredentials=!!s.withCredentials),o&&o!=="json"&&(g.responseType=s.responseType),typeof s.onDownloadProgress=="function"&&g.addEventListener("progress",Fe(s.onDownloadProgress,!0)),typeof s.onUploadProgress=="function"&&g.upload&&g.upload.addEventListener("progress",Fe(s.onUploadProgress)),(s.cancelToken||s.signal)&&(l=p=>{g&&(r(!p||p.type?new ue(null,n,g):p),g.abort(),g=null)},s.cancelToken&&s.cancelToken.subscribe(l),s.signal&&(s.signal.aborted?l():s.signal.addEventListener("abort",l)));const w=pa(s.url);if(w&&Ft.protocols.indexOf(w)===-1){r(new at("Unsupported protocol "+w+":",at.ERR_BAD_REQUEST,n));return}g.send(i||null)})},xa=(n,t)=>{let e=new AbortController,r;const s=function(l){if(!r){r=!0,a();const c=l instanceof Error?l:this.reason;e.abort(c instanceof at?c:new ue(c instanceof Error?c.message:c))}};let i=t&&setTimeout(()=>{s(new at(`timeout ${t} of ms exceeded`,at.ETIMEDOUT))},t);const a=()=>{n&&(i&&clearTimeout(i),i=null,n.forEach(l=>{l&&(l.removeEventListener?l.removeEventListener("abort",s):l.unsubscribe(s))}),n=null)};n.forEach(l=>l&&l.addEventListener&&l.addEventListener("abort",s));const{signal:o}=e;return o.unsubscribe=a,[o,()=>{i&&clearTimeout(i),i=null}]},Ta=function*(n,t){let e=n.byteLength;if(!t||e{const i=Ea(n,t,s);let a=0;return new ReadableStream({type:"bytes",async pull(o){const{done:l,value:c}=await i.next();if(l){o.close(),r();return}let g=c.byteLength;e&&e(a+=g),o.enqueue(new Uint8Array(c))},cancel(o){return r(o),i.return()}},{highWaterMark:2})},qr=(n,t)=>{const e=n!=null;return r=>setTimeout(()=>t({lengthComputable:e,total:n,loaded:r}))},We=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",An=We&&typeof ReadableStream=="function",nr=We&&(typeof TextEncoder=="function"?(n=>t=>n.encode(t))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),Ca=An&&(()=>{let n=!1;const t=new Request(Ft.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!t})(),Wr=64*1024,ir=An&&!!(()=>{try{return N.isReadableStream(new Response("").body)}catch{}})(),Pe={stream:ir&&(n=>n.body)};We&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Pe[t]&&(Pe[t]=N.isFunction(n[t])?e=>e[t]():(e,r)=>{throw new at(`Response type '${t}' is not supported`,at.ERR_NOT_SUPPORT,r)})})})(new Response);const Aa=async n=>{if(n==null)return 0;if(N.isBlob(n))return n.size;if(N.isSpecCompliantForm(n))return(await new Request(n).arrayBuffer()).byteLength;if(N.isArrayBufferView(n))return n.byteLength;if(N.isURLSearchParams(n)&&(n=n+""),N.isString(n))return(await nr(n)).byteLength},ka=async(n,t)=>{const e=N.toFiniteNumber(n.getContentLength());return e??Aa(t)},Ra=We&&(async n=>{let{url:t,method:e,data:r,signal:s,cancelToken:i,timeout:a,onDownloadProgress:o,onUploadProgress:l,responseType:c,headers:g,withCredentials:f="same-origin",fetchOptions:w}=Cn(n);c=c?(c+"").toLowerCase():"text";let[p,y]=s||i||a?xa([s,i],a):[],d,v;const m=()=>{!d&&setTimeout(()=>{p&&p.unsubscribe()}),d=!0};let S;try{if(l&&Ca&&e!=="get"&&e!=="head"&&(S=await ka(g,r))!==0){let D=new Request(t,{method:"POST",body:r,duplex:"half"}),B;N.isFormData(r)&&(B=D.headers.get("content-type"))&&g.setContentType(B),D.body&&(r=Mr(D.body,Wr,qr(S,Fe(l)),null,nr))}N.isString(f)||(f=f?"cors":"omit"),v=new Request(t,{...w,signal:p,method:e.toUpperCase(),headers:g.normalize().toJSON(),body:r,duplex:"half",withCredentials:f});let T=await fetch(v);const k=ir&&(c==="stream"||c==="response");if(ir&&(o||k)){const D={};["status","statusText","headers"].forEach(H=>{D[H]=T[H]});const B=N.toFiniteNumber(T.headers.get("content-length"));T=new Response(Mr(T.body,Wr,o&&qr(B,Fe(o,!0)),k&&m,nr),D)}c=c||"text";let A=await Pe[N.findKey(Pe,c)||"text"](T,n);return!k&&m(),y&&y(),await new Promise((D,B)=>{Tn(D,B,{data:A,headers:xt.from(T.headers),status:T.status,statusText:T.statusText,config:n,request:v})})}catch(T){throw m(),T&&T.name==="TypeError"&&/fetch/i.test(T.message)?Object.assign(new at("Network Error",at.ERR_NETWORK,n,v),{cause:T.cause||T}):at.from(T,T&&T.code,n,v)}}),sr={http:js,xhr:Sa,fetch:Ra};N.forEach(sr,(n,t)=>{if(n){try{Object.defineProperty(n,"name",{value:t})}catch{}Object.defineProperty(n,"adapterName",{value:t})}});const Hr=n=>`- ${n}`,Oa=n=>N.isFunction(n)||n===null||n===!1,kn={getAdapter:n=>{n=N.isArray(n)?n:[n];const{length:t}=n;let e,r;const s={};for(let i=0;i`adapter ${o} `+(l===!1?"is not supported by the environment":"is not available in the build"));let a=t?i.length>1?`since : -`+i.map(Hr).join(` -`):" "+Hr(i[0]):"as no adapter specified";throw new at("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return r},adapters:sr};function tr(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new ue(null,n)}function Vr(n){return tr(n),n.headers=xt.from(n.headers),n.data=Qe.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),kn.getAdapter(n.adapter||me.adapter)(n).then(function(r){return tr(n),r.data=Qe.call(n,n.transformResponse,r),r.headers=xt.from(r.headers),r},function(r){return xn(r)||(tr(n),r&&r.response&&(r.response.data=Qe.call(n,n.transformResponse,r.response),r.response.headers=xt.from(r.response.headers))),Promise.reject(r)})}const Rn="1.7.2",hr={};["object","boolean","number","function","string","symbol"].forEach((n,t)=>{hr[n]=function(r){return typeof r===n||"a"+(t<1?"n ":" ")+n}});const Zr={};hr.transitional=function(t,e,r){function s(i,a){return"[Axios v"+Rn+"] Transitional option '"+i+"'"+a+(r?". "+r:"")}return(i,a,o)=>{if(t===!1)throw new at(s(a," has been removed"+(e?" in "+e:"")),at.ERR_DEPRECATED);return e&&!Zr[a]&&(Zr[a]=!0,console.warn(s(a," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(i,a,o):!0}};function za(n,t,e){if(typeof n!="object")throw new at("options must be an object",at.ERR_BAD_OPTION_VALUE);const r=Object.keys(n);let s=r.length;for(;s-- >0;){const i=r[s],a=t[i];if(a){const o=n[i],l=o===void 0||a(o,i,n);if(l!==!0)throw new at("option "+i+" must be "+l,at.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new at("Unknown option "+i,at.ERR_BAD_OPTION)}}const ar={assertOptions:za,validators:hr},Ut=ar.validators;class Kt{constructor(t){this.defaults=t,this.interceptors={request:new Dr,response:new Dr}}async request(t,e){try{return await this._request(t,e)}catch(r){if(r instanceof Error){let s;Error.captureStackTrace?Error.captureStackTrace(s={}):s=new Error;const i=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=` -`+i):r.stack=i}catch{}}throw r}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=Xt(this.defaults,e);const{transitional:r,paramsSerializer:s,headers:i}=e;r!==void 0&&ar.assertOptions(r,{silentJSONParsing:Ut.transitional(Ut.boolean),forcedJSONParsing:Ut.transitional(Ut.boolean),clarifyTimeoutError:Ut.transitional(Ut.boolean)},!1),s!=null&&(N.isFunction(s)?e.paramsSerializer={serialize:s}:ar.assertOptions(s,{encode:Ut.function,serialize:Ut.function},!0)),e.method=(e.method||this.defaults.method||"get").toLowerCase();let a=i&&N.merge(i.common,i[e.method]);i&&N.forEach(["delete","get","head","post","put","patch","common"],y=>{delete i[y]}),e.headers=xt.concat(a,i);const o=[];let l=!0;this.interceptors.request.forEach(function(d){typeof d.runWhen=="function"&&d.runWhen(e)===!1||(l=l&&d.synchronous,o.unshift(d.fulfilled,d.rejected))});const c=[];this.interceptors.response.forEach(function(d){c.push(d.fulfilled,d.rejected)});let g,f=0,w;if(!l){const y=[Vr.bind(this),void 0];for(y.unshift.apply(y,o),y.push.apply(y,c),w=y.length,g=Promise.resolve(e);f{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const a=new Promise(o=>{r.subscribe(o),i=o}).then(s);return a.cancel=function(){r.unsubscribe(i)},a},t(function(i,a,o){r.reason||(r.reason=new ue(i,a,o),e(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}static source(){let t;return{token:new pr(function(s){t=s}),cancel:t}}}function Ia(n){return function(e){return n.apply(null,e)}}function Fa(n){return N.isObject(n)&&n.isAxiosError===!0}const or={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(or).forEach(([n,t])=>{or[t]=n});function On(n){const t=new Kt(n),e=un(Kt.prototype.request,t);return N.extend(e,Kt.prototype,t,{allOwnKeys:!0}),N.extend(e,t,null,{allOwnKeys:!0}),e.create=function(s){return On(Xt(n,s))},e}const yt=On(me);yt.Axios=Kt;yt.CanceledError=ue;yt.CancelToken=pr;yt.isCancel=xn;yt.VERSION=Rn;yt.toFormData=qe;yt.AxiosError=at;yt.Cancel=yt.CanceledError;yt.all=function(t){return Promise.all(t)};yt.spread=Ia;yt.isAxiosError=Fa;yt.mergeConfig=Xt;yt.AxiosHeaders=xt;yt.formToJSON=n=>Sn(N.isHTMLForm(n)?new FormData(n):n);yt.getAdapter=kn.getAdapter;yt.HttpStatusCode=or;yt.default=yt;var Mt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zn(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function xe(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var In={exports:{}};/*! +true&&(function polyfill() { + const relList = document.createElement("link").relList; + if (relList && relList.supports && relList.supports("modulepreload")) { + return; + } + for (const link of document.querySelectorAll('link[rel="modulepreload"]')) { + processPreload(link); + } + new MutationObserver((mutations) => { + for (const mutation of mutations) { + if (mutation.type !== "childList") { + continue; + } + for (const node of mutation.addedNodes) { + if (node.tagName === "LINK" && node.rel === "modulepreload") + processPreload(node); + } + } + }).observe(document, { childList: true, subtree: true }); + function getFetchOpts(link) { + const fetchOpts = {}; + if (link.integrity) fetchOpts.integrity = link.integrity; + if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy; + if (link.crossOrigin === "use-credentials") + fetchOpts.credentials = "include"; + else if (link.crossOrigin === "anonymous") fetchOpts.credentials = "omit"; + else fetchOpts.credentials = "same-origin"; + return fetchOpts; + } + function processPreload(link) { + if (link.ep) + return; + link.ep = true; + const fetchOpts = getFetchOpts(link); + fetch(link.href, fetchOpts); + } +}()); + +function bind(fn, thisArg) { + return function wrap() { + return fn.apply(thisArg, arguments); + }; +} + +// utils is a library of generic helper functions non-specific to axios + +const {toString} = Object.prototype; +const {getPrototypeOf} = Object; + +const kindOf = (cache => thing => { + const str = toString.call(thing); + return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase()); +})(Object.create(null)); + +const kindOfTest = (type) => { + type = type.toLowerCase(); + return (thing) => kindOf(thing) === type +}; + +const typeOfTest = type => thing => typeof thing === type; + +/** + * Determine if a value is an Array + * + * @param {Object} val The value to test + * + * @returns {boolean} True if value is an Array, otherwise false + */ +const {isArray} = Array; + +/** + * Determine if a value is undefined + * + * @param {*} val The value to test + * + * @returns {boolean} True if the value is undefined, otherwise false + */ +const isUndefined = typeOfTest('undefined'); + +/** + * Determine if a value is a Buffer + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is a Buffer, otherwise false + */ +function isBuffer(val) { + return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) + && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val); +} + +/** + * Determine if a value is an ArrayBuffer + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is an ArrayBuffer, otherwise false + */ +const isArrayBuffer = kindOfTest('ArrayBuffer'); + + +/** + * Determine if a value is a view on an ArrayBuffer + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false + */ +function isArrayBufferView(val) { + let result; + if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { + result = ArrayBuffer.isView(val); + } else { + result = (val) && (val.buffer) && (isArrayBuffer(val.buffer)); + } + return result; +} + +/** + * Determine if a value is a String + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is a String, otherwise false + */ +const isString = typeOfTest('string'); + +/** + * Determine if a value is a Function + * + * @param {*} val The value to test + * @returns {boolean} True if value is a Function, otherwise false + */ +const isFunction = typeOfTest('function'); + +/** + * Determine if a value is a Number + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is a Number, otherwise false + */ +const isNumber = typeOfTest('number'); + +/** + * Determine if a value is an Object + * + * @param {*} thing The value to test + * + * @returns {boolean} True if value is an Object, otherwise false + */ +const isObject = (thing) => thing !== null && typeof thing === 'object'; + +/** + * Determine if a value is a Boolean + * + * @param {*} thing The value to test + * @returns {boolean} True if value is a Boolean, otherwise false + */ +const isBoolean = thing => thing === true || thing === false; + +/** + * Determine if a value is a plain Object + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is a plain Object, otherwise false + */ +const isPlainObject = (val) => { + if (kindOf(val) !== 'object') { + return false; + } + + const prototype = getPrototypeOf(val); + return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val); +}; + +/** + * Determine if a value is a Date + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is a Date, otherwise false + */ +const isDate = kindOfTest('Date'); + +/** + * Determine if a value is a File + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is a File, otherwise false + */ +const isFile = kindOfTest('File'); + +/** + * Determine if a value is a Blob + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is a Blob, otherwise false + */ +const isBlob = kindOfTest('Blob'); + +/** + * Determine if a value is a FileList + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is a File, otherwise false + */ +const isFileList = kindOfTest('FileList'); + +/** + * Determine if a value is a Stream + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is a Stream, otherwise false + */ +const isStream = (val) => isObject(val) && isFunction(val.pipe); + +/** + * Determine if a value is a FormData + * + * @param {*} thing The value to test + * + * @returns {boolean} True if value is an FormData, otherwise false + */ +const isFormData = (thing) => { + let kind; + return thing && ( + (typeof FormData === 'function' && thing instanceof FormData) || ( + isFunction(thing.append) && ( + (kind = kindOf(thing)) === 'formdata' || + // detect form-data instance + (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]') + ) + ) + ) +}; + +/** + * Determine if a value is a URLSearchParams object + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is a URLSearchParams object, otherwise false + */ +const isURLSearchParams = kindOfTest('URLSearchParams'); + +const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest); + +/** + * Trim excess whitespace off the beginning and end of a string + * + * @param {String} str The String to trim + * + * @returns {String} The String freed of excess whitespace + */ +const trim = (str) => str.trim ? + str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); + +/** + * Iterate over an Array or an Object invoking a function for each item. + * + * If `obj` is an Array callback will be called passing + * the value, index, and complete array for each item. + * + * If 'obj' is an Object callback will be called passing + * the value, key, and complete object for each property. + * + * @param {Object|Array} obj The object to iterate + * @param {Function} fn The callback to invoke for each item + * + * @param {Boolean} [allOwnKeys = false] + * @returns {any} + */ +function forEach(obj, fn, {allOwnKeys = false} = {}) { + // Don't bother if no value provided + if (obj === null || typeof obj === 'undefined') { + return; + } + + let i; + let l; + + // Force an array if not already something iterable + if (typeof obj !== 'object') { + /*eslint no-param-reassign:0*/ + obj = [obj]; + } + + if (isArray(obj)) { + // Iterate over array values + for (i = 0, l = obj.length; i < l; i++) { + fn.call(null, obj[i], i, obj); + } + } else { + // Iterate over object keys + const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj); + const len = keys.length; + let key; + + for (i = 0; i < len; i++) { + key = keys[i]; + fn.call(null, obj[key], key, obj); + } + } +} + +function findKey(obj, key) { + key = key.toLowerCase(); + const keys = Object.keys(obj); + let i = keys.length; + let _key; + while (i-- > 0) { + _key = keys[i]; + if (key === _key.toLowerCase()) { + return _key; + } + } + return null; +} + +const _global = (() => { + /*eslint no-undef:0*/ + if (typeof globalThis !== "undefined") return globalThis; + return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global) +})(); + +const isContextDefined = (context) => !isUndefined(context) && context !== _global; + +/** + * Accepts varargs expecting each argument to be an object, then + * immutably merges the properties of each object and returns result. + * + * When multiple objects contain the same key the later object in + * the arguments list will take precedence. + * + * Example: + * + * ```js + * var result = merge({foo: 123}, {foo: 456}); + * console.log(result.foo); // outputs 456 + * ``` + * + * @param {Object} obj1 Object to merge + * + * @returns {Object} Result of all merge properties + */ +function merge(/* obj1, obj2, obj3, ... */) { + const {caseless} = isContextDefined(this) && this || {}; + const result = {}; + const assignValue = (val, key) => { + const targetKey = caseless && findKey(result, key) || key; + if (isPlainObject(result[targetKey]) && isPlainObject(val)) { + result[targetKey] = merge(result[targetKey], val); + } else if (isPlainObject(val)) { + result[targetKey] = merge({}, val); + } else if (isArray(val)) { + result[targetKey] = val.slice(); + } else { + result[targetKey] = val; + } + }; + + for (let i = 0, l = arguments.length; i < l; i++) { + arguments[i] && forEach(arguments[i], assignValue); + } + return result; +} + +/** + * Extends object a by mutably adding to it the properties of object b. + * + * @param {Object} a The object to be extended + * @param {Object} b The object to copy properties from + * @param {Object} thisArg The object to bind function to + * + * @param {Boolean} [allOwnKeys] + * @returns {Object} The resulting value of object a + */ +const extend = (a, b, thisArg, {allOwnKeys}= {}) => { + forEach(b, (val, key) => { + if (thisArg && isFunction(val)) { + a[key] = bind(val, thisArg); + } else { + a[key] = val; + } + }, {allOwnKeys}); + return a; +}; + +/** + * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) + * + * @param {string} content with BOM + * + * @returns {string} content value without BOM + */ +const stripBOM = (content) => { + if (content.charCodeAt(0) === 0xFEFF) { + content = content.slice(1); + } + return content; +}; + +/** + * Inherit the prototype methods from one constructor into another + * @param {function} constructor + * @param {function} superConstructor + * @param {object} [props] + * @param {object} [descriptors] + * + * @returns {void} + */ +const inherits = (constructor, superConstructor, props, descriptors) => { + constructor.prototype = Object.create(superConstructor.prototype, descriptors); + constructor.prototype.constructor = constructor; + Object.defineProperty(constructor, 'super', { + value: superConstructor.prototype + }); + props && Object.assign(constructor.prototype, props); +}; + +/** + * Resolve object with deep prototype chain to a flat object + * @param {Object} sourceObj source object + * @param {Object} [destObj] + * @param {Function|Boolean} [filter] + * @param {Function} [propFilter] + * + * @returns {Object} + */ +const toFlatObject = (sourceObj, destObj, filter, propFilter) => { + let props; + let i; + let prop; + const merged = {}; + + destObj = destObj || {}; + // eslint-disable-next-line no-eq-null,eqeqeq + if (sourceObj == null) return destObj; + + do { + props = Object.getOwnPropertyNames(sourceObj); + i = props.length; + while (i-- > 0) { + prop = props[i]; + if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) { + destObj[prop] = sourceObj[prop]; + merged[prop] = true; + } + } + sourceObj = filter !== false && getPrototypeOf(sourceObj); + } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype); + + return destObj; +}; + +/** + * Determines whether a string ends with the characters of a specified string + * + * @param {String} str + * @param {String} searchString + * @param {Number} [position= 0] + * + * @returns {boolean} + */ +const endsWith = (str, searchString, position) => { + str = String(str); + if (position === undefined || position > str.length) { + position = str.length; + } + position -= searchString.length; + const lastIndex = str.indexOf(searchString, position); + return lastIndex !== -1 && lastIndex === position; +}; + + +/** + * Returns new array from array like object or null if failed + * + * @param {*} [thing] + * + * @returns {?Array} + */ +const toArray = (thing) => { + if (!thing) return null; + if (isArray(thing)) return thing; + let i = thing.length; + if (!isNumber(i)) return null; + const arr = new Array(i); + while (i-- > 0) { + arr[i] = thing[i]; + } + return arr; +}; + +/** + * Checking if the Uint8Array exists and if it does, it returns a function that checks if the + * thing passed in is an instance of Uint8Array + * + * @param {TypedArray} + * + * @returns {Array} + */ +// eslint-disable-next-line func-names +const isTypedArray = (TypedArray => { + // eslint-disable-next-line func-names + return thing => { + return TypedArray && thing instanceof TypedArray; + }; +})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array)); + +/** + * For each entry in the object, call the function with the key and value. + * + * @param {Object} obj - The object to iterate over. + * @param {Function} fn - The function to call for each entry. + * + * @returns {void} + */ +const forEachEntry = (obj, fn) => { + const generator = obj && obj[Symbol.iterator]; + + const iterator = generator.call(obj); + + let result; + + while ((result = iterator.next()) && !result.done) { + const pair = result.value; + fn.call(obj, pair[0], pair[1]); + } +}; + +/** + * It takes a regular expression and a string, and returns an array of all the matches + * + * @param {string} regExp - The regular expression to match against. + * @param {string} str - The string to search. + * + * @returns {Array} + */ +const matchAll = (regExp, str) => { + let matches; + const arr = []; + + while ((matches = regExp.exec(str)) !== null) { + arr.push(matches); + } + + return arr; +}; + +/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */ +const isHTMLForm = kindOfTest('HTMLFormElement'); + +const toCamelCase = str => { + return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, + function replacer(m, p1, p2) { + return p1.toUpperCase() + p2; + } + ); +}; + +/* Creating a function that will check if an object has a property. */ +const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype); + +/** + * Determine if a value is a RegExp object + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is a RegExp object, otherwise false + */ +const isRegExp = kindOfTest('RegExp'); + +const reduceDescriptors = (obj, reducer) => { + const descriptors = Object.getOwnPropertyDescriptors(obj); + const reducedDescriptors = {}; + + forEach(descriptors, (descriptor, name) => { + let ret; + if ((ret = reducer(descriptor, name, obj)) !== false) { + reducedDescriptors[name] = ret || descriptor; + } + }); + + Object.defineProperties(obj, reducedDescriptors); +}; + +/** + * Makes all methods read-only + * @param {Object} obj + */ + +const freezeMethods = (obj) => { + reduceDescriptors(obj, (descriptor, name) => { + // skip restricted props in strict mode + if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) { + return false; + } + + const value = obj[name]; + + if (!isFunction(value)) return; + + descriptor.enumerable = false; + + if ('writable' in descriptor) { + descriptor.writable = false; + return; + } + + if (!descriptor.set) { + descriptor.set = () => { + throw Error('Can not rewrite read-only method \'' + name + '\''); + }; + } + }); +}; + +const toObjectSet = (arrayOrString, delimiter) => { + const obj = {}; + + const define = (arr) => { + arr.forEach(value => { + obj[value] = true; + }); + }; + + isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter)); + + return obj; +}; + +const noop = () => {}; + +const toFiniteNumber = (value, defaultValue) => { + return value != null && Number.isFinite(value = +value) ? value : defaultValue; +}; + +const ALPHA = 'abcdefghijklmnopqrstuvwxyz'; + +const DIGIT = '0123456789'; + +const ALPHABET = { + DIGIT, + ALPHA, + ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT +}; + +const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => { + let str = ''; + const {length} = alphabet; + while (size--) { + str += alphabet[Math.random() * length|0]; + } + + return str; +}; + +/** + * If the thing is a FormData object, return true, otherwise return false. + * + * @param {unknown} thing - The thing to check. + * + * @returns {boolean} + */ +function isSpecCompliantForm(thing) { + return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]); +} + +const toJSONObject = (obj) => { + const stack = new Array(10); + + const visit = (source, i) => { + + if (isObject(source)) { + if (stack.indexOf(source) >= 0) { + return; + } + + if(!('toJSON' in source)) { + stack[i] = source; + const target = isArray(source) ? [] : {}; + + forEach(source, (value, key) => { + const reducedValue = visit(value, i + 1); + !isUndefined(reducedValue) && (target[key] = reducedValue); + }); + + stack[i] = undefined; + + return target; + } + } + + return source; + }; + + return visit(obj, 0); +}; + +const isAsyncFn = kindOfTest('AsyncFunction'); + +const isThenable = (thing) => + thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch); + +const utils$1 = { + isArray, + isArrayBuffer, + isBuffer, + isFormData, + isArrayBufferView, + isString, + isNumber, + isBoolean, + isObject, + isPlainObject, + isReadableStream, + isRequest, + isResponse, + isHeaders, + isUndefined, + isDate, + isFile, + isBlob, + isRegExp, + isFunction, + isStream, + isURLSearchParams, + isTypedArray, + isFileList, + forEach, + merge, + extend, + trim, + stripBOM, + inherits, + toFlatObject, + kindOf, + kindOfTest, + endsWith, + toArray, + forEachEntry, + matchAll, + isHTMLForm, + hasOwnProperty, + hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection + reduceDescriptors, + freezeMethods, + toObjectSet, + toCamelCase, + noop, + toFiniteNumber, + findKey, + global: _global, + isContextDefined, + ALPHABET, + generateString, + isSpecCompliantForm, + toJSONObject, + isAsyncFn, + isThenable +}; + +/** + * Create an Error with the specified message, config, error code, request and response. + * + * @param {string} message The error message. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [config] The config. + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * + * @returns {Error} The created error. + */ +function AxiosError(message, code, config, request, response) { + Error.call(this); + + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor); + } else { + this.stack = (new Error()).stack; + } + + this.message = message; + this.name = 'AxiosError'; + code && (this.code = code); + config && (this.config = config); + request && (this.request = request); + response && (this.response = response); +} + +utils$1.inherits(AxiosError, Error, { + toJSON: function toJSON() { + return { + // Standard + message: this.message, + name: this.name, + // Microsoft + description: this.description, + number: this.number, + // Mozilla + fileName: this.fileName, + lineNumber: this.lineNumber, + columnNumber: this.columnNumber, + stack: this.stack, + // Axios + config: utils$1.toJSONObject(this.config), + code: this.code, + status: this.response && this.response.status ? this.response.status : null + }; + } +}); + +const prototype$1 = AxiosError.prototype; +const descriptors = {}; + +[ + 'ERR_BAD_OPTION_VALUE', + 'ERR_BAD_OPTION', + 'ECONNABORTED', + 'ETIMEDOUT', + 'ERR_NETWORK', + 'ERR_FR_TOO_MANY_REDIRECTS', + 'ERR_DEPRECATED', + 'ERR_BAD_RESPONSE', + 'ERR_BAD_REQUEST', + 'ERR_CANCELED', + 'ERR_NOT_SUPPORT', + 'ERR_INVALID_URL' +// eslint-disable-next-line func-names +].forEach(code => { + descriptors[code] = {value: code}; +}); + +Object.defineProperties(AxiosError, descriptors); +Object.defineProperty(prototype$1, 'isAxiosError', {value: true}); + +// eslint-disable-next-line func-names +AxiosError.from = (error, code, config, request, response, customProps) => { + const axiosError = Object.create(prototype$1); + + utils$1.toFlatObject(error, axiosError, function filter(obj) { + return obj !== Error.prototype; + }, prop => { + return prop !== 'isAxiosError'; + }); + + AxiosError.call(axiosError, error.message, code, config, request, response); + + axiosError.cause = error; + + axiosError.name = error.name; + + customProps && Object.assign(axiosError, customProps); + + return axiosError; +}; + +// eslint-disable-next-line strict +const httpAdapter = null; + +/** + * Determines if the given thing is a array or js object. + * + * @param {string} thing - The object or array to be visited. + * + * @returns {boolean} + */ +function isVisitable(thing) { + return utils$1.isPlainObject(thing) || utils$1.isArray(thing); +} + +/** + * It removes the brackets from the end of a string + * + * @param {string} key - The key of the parameter. + * + * @returns {string} the key without the brackets. + */ +function removeBrackets(key) { + return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key; +} + +/** + * It takes a path, a key, and a boolean, and returns a string + * + * @param {string} path - The path to the current key. + * @param {string} key - The key of the current object being iterated over. + * @param {string} dots - If true, the key will be rendered with dots instead of brackets. + * + * @returns {string} The path to the current key. + */ +function renderKey(path, key, dots) { + if (!path) return key; + return path.concat(key).map(function each(token, i) { + // eslint-disable-next-line no-param-reassign + token = removeBrackets(token); + return !dots && i ? '[' + token + ']' : token; + }).join(dots ? '.' : ''); +} + +/** + * If the array is an array and none of its elements are visitable, then it's a flat array. + * + * @param {Array} arr - The array to check + * + * @returns {boolean} + */ +function isFlatArray(arr) { + return utils$1.isArray(arr) && !arr.some(isVisitable); +} + +const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) { + return /^is[A-Z]/.test(prop); +}); + +/** + * Convert a data object to FormData + * + * @param {Object} obj + * @param {?Object} [formData] + * @param {?Object} [options] + * @param {Function} [options.visitor] + * @param {Boolean} [options.metaTokens = true] + * @param {Boolean} [options.dots = false] + * @param {?Boolean} [options.indexes = false] + * + * @returns {Object} + **/ + +/** + * It converts an object into a FormData object + * + * @param {Object} obj - The object to convert to form data. + * @param {string} formData - The FormData object to append to. + * @param {Object} options + * + * @returns + */ +function toFormData(obj, formData, options) { + if (!utils$1.isObject(obj)) { + throw new TypeError('target must be an object'); + } + + // eslint-disable-next-line no-param-reassign + formData = formData || new (FormData)(); + + // eslint-disable-next-line no-param-reassign + options = utils$1.toFlatObject(options, { + metaTokens: true, + dots: false, + indexes: false + }, false, function defined(option, source) { + // eslint-disable-next-line no-eq-null,eqeqeq + return !utils$1.isUndefined(source[option]); + }); + + const metaTokens = options.metaTokens; + // eslint-disable-next-line no-use-before-define + const visitor = options.visitor || defaultVisitor; + const dots = options.dots; + const indexes = options.indexes; + const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob; + const useBlob = _Blob && utils$1.isSpecCompliantForm(formData); + + if (!utils$1.isFunction(visitor)) { + throw new TypeError('visitor must be a function'); + } + + function convertValue(value) { + if (value === null) return ''; + + if (utils$1.isDate(value)) { + return value.toISOString(); + } + + if (!useBlob && utils$1.isBlob(value)) { + throw new AxiosError('Blob is not supported. Use a Buffer instead.'); + } + + if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) { + return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value); + } + + return value; + } + + /** + * Default visitor. + * + * @param {*} value + * @param {String|Number} key + * @param {Array} path + * @this {FormData} + * + * @returns {boolean} return true to visit the each prop of the value recursively + */ + function defaultVisitor(value, key, path) { + let arr = value; + + if (value && !path && typeof value === 'object') { + if (utils$1.endsWith(key, '{}')) { + // eslint-disable-next-line no-param-reassign + key = metaTokens ? key : key.slice(0, -2); + // eslint-disable-next-line no-param-reassign + value = JSON.stringify(value); + } else if ( + (utils$1.isArray(value) && isFlatArray(value)) || + ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)) + )) { + // eslint-disable-next-line no-param-reassign + key = removeBrackets(key); + + arr.forEach(function each(el, index) { + !(utils$1.isUndefined(el) || el === null) && formData.append( + // eslint-disable-next-line no-nested-ternary + indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'), + convertValue(el) + ); + }); + return false; + } + } + + if (isVisitable(value)) { + return true; + } + + formData.append(renderKey(path, key, dots), convertValue(value)); + + return false; + } + + const stack = []; + + const exposedHelpers = Object.assign(predicates, { + defaultVisitor, + convertValue, + isVisitable + }); + + function build(value, path) { + if (utils$1.isUndefined(value)) return; + + if (stack.indexOf(value) !== -1) { + throw Error('Circular reference detected in ' + path.join('.')); + } + + stack.push(value); + + utils$1.forEach(value, function each(el, key) { + const result = !(utils$1.isUndefined(el) || el === null) && visitor.call( + formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers + ); + + if (result === true) { + build(el, path ? path.concat(key) : [key]); + } + }); + + stack.pop(); + } + + if (!utils$1.isObject(obj)) { + throw new TypeError('data must be an object'); + } + + build(obj); + + return formData; +} + +/** + * It encodes a string by replacing all characters that are not in the unreserved set with + * their percent-encoded equivalents + * + * @param {string} str - The string to encode. + * + * @returns {string} The encoded string. + */ +function encode$1(str) { + const charMap = { + '!': '%21', + "'": '%27', + '(': '%28', + ')': '%29', + '~': '%7E', + '%20': '+', + '%00': '\x00' + }; + return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) { + return charMap[match]; + }); +} + +/** + * It takes a params object and converts it to a FormData object + * + * @param {Object} params - The parameters to be converted to a FormData object. + * @param {Object} options - The options object passed to the Axios constructor. + * + * @returns {void} + */ +function AxiosURLSearchParams(params, options) { + this._pairs = []; + + params && toFormData(params, this, options); +} + +const prototype = AxiosURLSearchParams.prototype; + +prototype.append = function append(name, value) { + this._pairs.push([name, value]); +}; + +prototype.toString = function toString(encoder) { + const _encode = encoder ? function(value) { + return encoder.call(this, value, encode$1); + } : encode$1; + + return this._pairs.map(function each(pair) { + return _encode(pair[0]) + '=' + _encode(pair[1]); + }, '').join('&'); +}; + +/** + * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their + * URI encoded counterparts + * + * @param {string} val The value to be encoded. + * + * @returns {string} The encoded value. + */ +function encode(val) { + return encodeURIComponent(val). + replace(/%3A/gi, ':'). + replace(/%24/g, '$'). + replace(/%2C/gi, ','). + replace(/%20/g, '+'). + replace(/%5B/gi, '['). + replace(/%5D/gi, ']'); +} + +/** + * Build a URL by appending params to the end + * + * @param {string} url The base of the url (e.g., http://www.google.com) + * @param {object} [params] The params to be appended + * @param {?object} options + * + * @returns {string} The formatted url + */ +function buildURL(url, params, options) { + /*eslint no-param-reassign:0*/ + if (!params) { + return url; + } + + const _encode = options && options.encode || encode; + + const serializeFn = options && options.serialize; + + let serializedParams; + + if (serializeFn) { + serializedParams = serializeFn(params, options); + } else { + serializedParams = utils$1.isURLSearchParams(params) ? + params.toString() : + new AxiosURLSearchParams(params, options).toString(_encode); + } + + if (serializedParams) { + const hashmarkIndex = url.indexOf("#"); + + if (hashmarkIndex !== -1) { + url = url.slice(0, hashmarkIndex); + } + url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; + } + + return url; +} + +class InterceptorManager { + constructor() { + this.handlers = []; + } + + /** + * Add a new interceptor to the stack + * + * @param {Function} fulfilled The function to handle `then` for a `Promise` + * @param {Function} rejected The function to handle `reject` for a `Promise` + * + * @return {Number} An ID used to remove interceptor later + */ + use(fulfilled, rejected, options) { + this.handlers.push({ + fulfilled, + rejected, + synchronous: options ? options.synchronous : false, + runWhen: options ? options.runWhen : null + }); + return this.handlers.length - 1; + } + + /** + * Remove an interceptor from the stack + * + * @param {Number} id The ID that was returned by `use` + * + * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise + */ + eject(id) { + if (this.handlers[id]) { + this.handlers[id] = null; + } + } + + /** + * Clear all interceptors from the stack + * + * @returns {void} + */ + clear() { + if (this.handlers) { + this.handlers = []; + } + } + + /** + * Iterate over all the registered interceptors + * + * This method is particularly useful for skipping over any + * interceptors that may have become `null` calling `eject`. + * + * @param {Function} fn The function to call for each interceptor + * + * @returns {void} + */ + forEach(fn) { + utils$1.forEach(this.handlers, function forEachHandler(h) { + if (h !== null) { + fn(h); + } + }); + } +} + +const transitionalDefaults = { + silentJSONParsing: true, + forcedJSONParsing: true, + clarifyTimeoutError: false +}; + +const URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams; + +const FormData$1 = typeof FormData !== 'undefined' ? FormData : null; + +const Blob$1 = typeof Blob !== 'undefined' ? Blob : null; + +const platform$1 = { + isBrowser: true, + classes: { + URLSearchParams: URLSearchParams$1, + FormData: FormData$1, + Blob: Blob$1 + }, + protocols: ['http', 'https', 'file', 'blob', 'url', 'data'] +}; + +const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined'; + +/** + * Determine if we're running in a standard browser environment + * + * This allows axios to run in a web worker, and react-native. + * Both environments support XMLHttpRequest, but not fully standard globals. + * + * web workers: + * typeof window -> undefined + * typeof document -> undefined + * + * react-native: + * navigator.product -> 'ReactNative' + * nativescript + * navigator.product -> 'NativeScript' or 'NS' + * + * @returns {boolean} + */ +const hasStandardBrowserEnv = ( + (product) => { + return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0 + })(typeof navigator !== 'undefined' && navigator.product); + +/** + * Determine if we're running in a standard browser webWorker environment + * + * Although the `isStandardBrowserEnv` method indicates that + * `allows axios to run in a web worker`, the WebWorker will still be + * filtered out due to its judgment standard + * `typeof window !== 'undefined' && typeof document !== 'undefined'`. + * This leads to a problem when axios post `FormData` in webWorker + */ +const hasStandardBrowserWebWorkerEnv = (() => { + return ( + typeof WorkerGlobalScope !== 'undefined' && + // eslint-disable-next-line no-undef + self instanceof WorkerGlobalScope && + typeof self.importScripts === 'function' + ); +})(); + +const origin = hasBrowserEnv && window.location.href || 'http://localhost'; + +const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({ + __proto__: null, + hasBrowserEnv, + hasStandardBrowserEnv, + hasStandardBrowserWebWorkerEnv, + origin +}, Symbol.toStringTag, { value: 'Module' })); + +const platform = { + ...utils, + ...platform$1 +}; + +function toURLEncodedForm(data, options) { + return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({ + visitor: function(value, key, path, helpers) { + if (platform.isNode && utils$1.isBuffer(value)) { + this.append(key, value.toString('base64')); + return false; + } + + return helpers.defaultVisitor.apply(this, arguments); + } + }, options)); +} + +/** + * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z'] + * + * @param {string} name - The name of the property to get. + * + * @returns An array of strings. + */ +function parsePropPath(name) { + // foo[x][y][z] + // foo.x.y.z + // foo-x-y-z + // foo x y z + return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => { + return match[0] === '[]' ? '' : match[1] || match[0]; + }); +} + +/** + * Convert an array to an object. + * + * @param {Array} arr - The array to convert to an object. + * + * @returns An object with the same keys and values as the array. + */ +function arrayToObject(arr) { + const obj = {}; + const keys = Object.keys(arr); + let i; + const len = keys.length; + let key; + for (i = 0; i < len; i++) { + key = keys[i]; + obj[key] = arr[key]; + } + return obj; +} + +/** + * It takes a FormData object and returns a JavaScript object + * + * @param {string} formData The FormData object to convert to JSON. + * + * @returns {Object | null} The converted object. + */ +function formDataToJSON(formData) { + function buildPath(path, value, target, index) { + let name = path[index++]; + + if (name === '__proto__') return true; + + const isNumericKey = Number.isFinite(+name); + const isLast = index >= path.length; + name = !name && utils$1.isArray(target) ? target.length : name; + + if (isLast) { + if (utils$1.hasOwnProp(target, name)) { + target[name] = [target[name], value]; + } else { + target[name] = value; + } + + return !isNumericKey; + } + + if (!target[name] || !utils$1.isObject(target[name])) { + target[name] = []; + } + + const result = buildPath(path, value, target[name], index); + + if (result && utils$1.isArray(target[name])) { + target[name] = arrayToObject(target[name]); + } + + return !isNumericKey; + } + + if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) { + const obj = {}; + + utils$1.forEachEntry(formData, (name, value) => { + buildPath(parsePropPath(name), value, obj, 0); + }); + + return obj; + } + + return null; +} + +/** + * It takes a string, tries to parse it, and if it fails, it returns the stringified version + * of the input + * + * @param {any} rawValue - The value to be stringified. + * @param {Function} parser - A function that parses a string into a JavaScript object. + * @param {Function} encoder - A function that takes a value and returns a string. + * + * @returns {string} A stringified version of the rawValue. + */ +function stringifySafely(rawValue, parser, encoder) { + if (utils$1.isString(rawValue)) { + try { + (parser || JSON.parse)(rawValue); + return utils$1.trim(rawValue); + } catch (e) { + if (e.name !== 'SyntaxError') { + throw e; + } + } + } + + return (encoder || JSON.stringify)(rawValue); +} + +const defaults = { + + transitional: transitionalDefaults, + + adapter: ['xhr', 'http', 'fetch'], + + transformRequest: [function transformRequest(data, headers) { + const contentType = headers.getContentType() || ''; + const hasJSONContentType = contentType.indexOf('application/json') > -1; + const isObjectPayload = utils$1.isObject(data); + + if (isObjectPayload && utils$1.isHTMLForm(data)) { + data = new FormData(data); + } + + const isFormData = utils$1.isFormData(data); + + if (isFormData) { + return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data; + } + + if (utils$1.isArrayBuffer(data) || + utils$1.isBuffer(data) || + utils$1.isStream(data) || + utils$1.isFile(data) || + utils$1.isBlob(data) || + utils$1.isReadableStream(data) + ) { + return data; + } + if (utils$1.isArrayBufferView(data)) { + return data.buffer; + } + if (utils$1.isURLSearchParams(data)) { + headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false); + return data.toString(); + } + + let isFileList; + + if (isObjectPayload) { + if (contentType.indexOf('application/x-www-form-urlencoded') > -1) { + return toURLEncodedForm(data, this.formSerializer).toString(); + } + + if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) { + const _FormData = this.env && this.env.FormData; + + return toFormData( + isFileList ? {'files[]': data} : data, + _FormData && new _FormData(), + this.formSerializer + ); + } + } + + if (isObjectPayload || hasJSONContentType ) { + headers.setContentType('application/json', false); + return stringifySafely(data); + } + + return data; + }], + + transformResponse: [function transformResponse(data) { + const transitional = this.transitional || defaults.transitional; + const forcedJSONParsing = transitional && transitional.forcedJSONParsing; + const JSONRequested = this.responseType === 'json'; + + if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) { + return data; + } + + if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) { + const silentJSONParsing = transitional && transitional.silentJSONParsing; + const strictJSONParsing = !silentJSONParsing && JSONRequested; + + try { + return JSON.parse(data); + } catch (e) { + if (strictJSONParsing) { + if (e.name === 'SyntaxError') { + throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response); + } + throw e; + } + } + } + + return data; + }], + + /** + * A timeout in milliseconds to abort a request. If set to 0 (default) a + * timeout is not created. + */ + timeout: 0, + + xsrfCookieName: 'XSRF-TOKEN', + xsrfHeaderName: 'X-XSRF-TOKEN', + + maxContentLength: -1, + maxBodyLength: -1, + + env: { + FormData: platform.classes.FormData, + Blob: platform.classes.Blob + }, + + validateStatus: function validateStatus(status) { + return status >= 200 && status < 300; + }, + + headers: { + common: { + 'Accept': 'application/json, text/plain, */*', + 'Content-Type': undefined + } + } +}; + +utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => { + defaults.headers[method] = {}; +}); + +// RawAxiosHeaders whose duplicates are ignored by node +// c.f. https://nodejs.org/api/http.html#http_message_headers +const ignoreDuplicateOf = utils$1.toObjectSet([ + 'age', 'authorization', 'content-length', 'content-type', 'etag', + 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', + 'last-modified', 'location', 'max-forwards', 'proxy-authorization', + 'referer', 'retry-after', 'user-agent' +]); + +/** + * Parse headers into an object + * + * ``` + * Date: Wed, 27 Aug 2014 08:58:49 GMT + * Content-Type: application/json + * Connection: keep-alive + * Transfer-Encoding: chunked + * ``` + * + * @param {String} rawHeaders Headers needing to be parsed + * + * @returns {Object} Headers parsed into an object + */ +const parseHeaders = rawHeaders => { + const parsed = {}; + let key; + let val; + let i; + + rawHeaders && rawHeaders.split('\n').forEach(function parser(line) { + i = line.indexOf(':'); + key = line.substring(0, i).trim().toLowerCase(); + val = line.substring(i + 1).trim(); + + if (!key || (parsed[key] && ignoreDuplicateOf[key])) { + return; + } + + if (key === 'set-cookie') { + if (parsed[key]) { + parsed[key].push(val); + } else { + parsed[key] = [val]; + } + } else { + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; + } + }); + + return parsed; +}; + +const $internals = Symbol('internals'); + +function normalizeHeader(header) { + return header && String(header).trim().toLowerCase(); +} + +function normalizeValue(value) { + if (value === false || value == null) { + return value; + } + + return utils$1.isArray(value) ? value.map(normalizeValue) : String(value); +} + +function parseTokens(str) { + const tokens = Object.create(null); + const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g; + let match; + + while ((match = tokensRE.exec(str))) { + tokens[match[1]] = match[2]; + } + + return tokens; +} + +const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim()); + +function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) { + if (utils$1.isFunction(filter)) { + return filter.call(this, value, header); + } + + if (isHeaderNameFilter) { + value = header; + } + + if (!utils$1.isString(value)) return; + + if (utils$1.isString(filter)) { + return value.indexOf(filter) !== -1; + } + + if (utils$1.isRegExp(filter)) { + return filter.test(value); + } +} + +function formatHeader(header) { + return header.trim() + .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => { + return char.toUpperCase() + str; + }); +} + +function buildAccessors(obj, header) { + const accessorName = utils$1.toCamelCase(' ' + header); + + ['get', 'set', 'has'].forEach(methodName => { + Object.defineProperty(obj, methodName + accessorName, { + value: function(arg1, arg2, arg3) { + return this[methodName].call(this, header, arg1, arg2, arg3); + }, + configurable: true + }); + }); +} + +class AxiosHeaders { + constructor(headers) { + headers && this.set(headers); + } + + set(header, valueOrRewrite, rewrite) { + const self = this; + + function setHeader(_value, _header, _rewrite) { + const lHeader = normalizeHeader(_header); + + if (!lHeader) { + throw new Error('header name must be a non-empty string'); + } + + const key = utils$1.findKey(self, lHeader); + + if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) { + self[key || _header] = normalizeValue(_value); + } + } + + const setHeaders = (headers, _rewrite) => + utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite)); + + if (utils$1.isPlainObject(header) || header instanceof this.constructor) { + setHeaders(header, valueOrRewrite); + } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) { + setHeaders(parseHeaders(header), valueOrRewrite); + } else if (utils$1.isHeaders(header)) { + for (const [key, value] of header.entries()) { + setHeader(value, key, rewrite); + } + } else { + header != null && setHeader(valueOrRewrite, header, rewrite); + } + + return this; + } + + get(header, parser) { + header = normalizeHeader(header); + + if (header) { + const key = utils$1.findKey(this, header); + + if (key) { + const value = this[key]; + + if (!parser) { + return value; + } + + if (parser === true) { + return parseTokens(value); + } + + if (utils$1.isFunction(parser)) { + return parser.call(this, value, key); + } + + if (utils$1.isRegExp(parser)) { + return parser.exec(value); + } + + throw new TypeError('parser must be boolean|regexp|function'); + } + } + } + + has(header, matcher) { + header = normalizeHeader(header); + + if (header) { + const key = utils$1.findKey(this, header); + + return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher))); + } + + return false; + } + + delete(header, matcher) { + const self = this; + let deleted = false; + + function deleteHeader(_header) { + _header = normalizeHeader(_header); + + if (_header) { + const key = utils$1.findKey(self, _header); + + if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) { + delete self[key]; + + deleted = true; + } + } + } + + if (utils$1.isArray(header)) { + header.forEach(deleteHeader); + } else { + deleteHeader(header); + } + + return deleted; + } + + clear(matcher) { + const keys = Object.keys(this); + let i = keys.length; + let deleted = false; + + while (i--) { + const key = keys[i]; + if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) { + delete this[key]; + deleted = true; + } + } + + return deleted; + } + + normalize(format) { + const self = this; + const headers = {}; + + utils$1.forEach(this, (value, header) => { + const key = utils$1.findKey(headers, header); + + if (key) { + self[key] = normalizeValue(value); + delete self[header]; + return; + } + + const normalized = format ? formatHeader(header) : String(header).trim(); + + if (normalized !== header) { + delete self[header]; + } + + self[normalized] = normalizeValue(value); + + headers[normalized] = true; + }); + + return this; + } + + concat(...targets) { + return this.constructor.concat(this, ...targets); + } + + toJSON(asStrings) { + const obj = Object.create(null); + + utils$1.forEach(this, (value, header) => { + value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value); + }); + + return obj; + } + + [Symbol.iterator]() { + return Object.entries(this.toJSON())[Symbol.iterator](); + } + + toString() { + return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n'); + } + + get [Symbol.toStringTag]() { + return 'AxiosHeaders'; + } + + static from(thing) { + return thing instanceof this ? thing : new this(thing); + } + + static concat(first, ...targets) { + const computed = new this(first); + + targets.forEach((target) => computed.set(target)); + + return computed; + } + + static accessor(header) { + const internals = this[$internals] = (this[$internals] = { + accessors: {} + }); + + const accessors = internals.accessors; + const prototype = this.prototype; + + function defineAccessor(_header) { + const lHeader = normalizeHeader(_header); + + if (!accessors[lHeader]) { + buildAccessors(prototype, _header); + accessors[lHeader] = true; + } + } + + utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header); + + return this; + } +} + +AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']); + +// reserved names hotfix +utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => { + let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set` + return { + get: () => value, + set(headerValue) { + this[mapped] = headerValue; + } + } +}); + +utils$1.freezeMethods(AxiosHeaders); + +/** + * Transform the data for a request or a response + * + * @param {Array|Function} fns A single function or Array of functions + * @param {?Object} response The response object + * + * @returns {*} The resulting transformed data + */ +function transformData(fns, response) { + const config = this || defaults; + const context = response || config; + const headers = AxiosHeaders.from(context.headers); + let data = context.data; + + utils$1.forEach(fns, function transform(fn) { + data = fn.call(config, data, headers.normalize(), response ? response.status : undefined); + }); + + headers.normalize(); + + return data; +} + +function isCancel(value) { + return !!(value && value.__CANCEL__); +} + +/** + * A `CanceledError` is an object that is thrown when an operation is canceled. + * + * @param {string=} message The message. + * @param {Object=} config The config. + * @param {Object=} request The request. + * + * @returns {CanceledError} The created error. + */ +function CanceledError(message, config, request) { + // eslint-disable-next-line no-eq-null,eqeqeq + AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request); + this.name = 'CanceledError'; +} + +utils$1.inherits(CanceledError, AxiosError, { + __CANCEL__: true +}); + +/** + * Resolve or reject a Promise based on response status. + * + * @param {Function} resolve A function that resolves the promise. + * @param {Function} reject A function that rejects the promise. + * @param {object} response The response. + * + * @returns {object} The response. + */ +function settle(resolve, reject, response) { + const validateStatus = response.config.validateStatus; + if (!response.status || !validateStatus || validateStatus(response.status)) { + resolve(response); + } else { + reject(new AxiosError( + 'Request failed with status code ' + response.status, + [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], + response.config, + response.request, + response + )); + } +} + +function parseProtocol(url) { + const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url); + return match && match[1] || ''; +} + +/** + * Calculate data maxRate + * @param {Number} [samplesCount= 10] + * @param {Number} [min= 1000] + * @returns {Function} + */ +function speedometer(samplesCount, min) { + samplesCount = samplesCount || 10; + const bytes = new Array(samplesCount); + const timestamps = new Array(samplesCount); + let head = 0; + let tail = 0; + let firstSampleTS; + + min = min !== undefined ? min : 1000; + + return function push(chunkLength) { + const now = Date.now(); + + const startedAt = timestamps[tail]; + + if (!firstSampleTS) { + firstSampleTS = now; + } + + bytes[head] = chunkLength; + timestamps[head] = now; + + let i = tail; + let bytesCount = 0; + + while (i !== head) { + bytesCount += bytes[i++]; + i = i % samplesCount; + } + + head = (head + 1) % samplesCount; + + if (head === tail) { + tail = (tail + 1) % samplesCount; + } + + if (now - firstSampleTS < min) { + return; + } + + const passed = startedAt && now - startedAt; + + return passed ? Math.round(bytesCount * 1000 / passed) : undefined; + }; +} + +/** + * Throttle decorator + * @param {Function} fn + * @param {Number} freq + * @return {Function} + */ +function throttle(fn, freq) { + let timestamp = 0; + const threshold = 1000 / freq; + let timer = null; + return function throttled() { + const force = this === true; + + const now = Date.now(); + if (force || now - timestamp > threshold) { + if (timer) { + clearTimeout(timer); + timer = null; + } + timestamp = now; + return fn.apply(null, arguments); + } + if (!timer) { + timer = setTimeout(() => { + timer = null; + timestamp = Date.now(); + return fn.apply(null, arguments); + }, threshold - (now - timestamp)); + } + }; +} + +const progressEventReducer = (listener, isDownloadStream, freq = 3) => { + let bytesNotified = 0; + const _speedometer = speedometer(50, 250); + + return throttle(e => { + const loaded = e.loaded; + const total = e.lengthComputable ? e.total : undefined; + const progressBytes = loaded - bytesNotified; + const rate = _speedometer(progressBytes); + const inRange = loaded <= total; + + bytesNotified = loaded; + + const data = { + loaded, + total, + progress: total ? (loaded / total) : undefined, + bytes: progressBytes, + rate: rate ? rate : undefined, + estimated: rate && total && inRange ? (total - loaded) / rate : undefined, + event: e, + lengthComputable: total != null + }; + + data[isDownloadStream ? 'download' : 'upload'] = true; + + listener(data); + }, freq); +}; + +const isURLSameOrigin = platform.hasStandardBrowserEnv ? + +// Standard browser envs have full support of the APIs needed to test +// whether the request URL is of the same origin as current location. + (function standardBrowserEnv() { + const msie = /(msie|trident)/i.test(navigator.userAgent); + const urlParsingNode = document.createElement('a'); + let originURL; + + /** + * Parse a URL to discover its components + * + * @param {String} url The URL to be parsed + * @returns {Object} + */ + function resolveURL(url) { + let href = url; + + if (msie) { + // IE needs attribute set twice to normalize properties + urlParsingNode.setAttribute('href', href); + href = urlParsingNode.href; + } + + urlParsingNode.setAttribute('href', href); + + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils + return { + href: urlParsingNode.href, + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', + host: urlParsingNode.host, + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', + hostname: urlParsingNode.hostname, + port: urlParsingNode.port, + pathname: (urlParsingNode.pathname.charAt(0) === '/') ? + urlParsingNode.pathname : + '/' + urlParsingNode.pathname + }; + } + + originURL = resolveURL(window.location.href); + + /** + * Determine if a URL shares the same origin as the current location + * + * @param {String} requestURL The URL to test + * @returns {boolean} True if URL shares the same origin, otherwise false + */ + return function isURLSameOrigin(requestURL) { + const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL; + return (parsed.protocol === originURL.protocol && + parsed.host === originURL.host); + }; + })() : + + // Non standard browser envs (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return function isURLSameOrigin() { + return true; + }; + })(); + +const cookies = platform.hasStandardBrowserEnv ? + + // Standard browser envs support document.cookie + { + write(name, value, expires, path, domain, secure) { + const cookie = [name + '=' + encodeURIComponent(value)]; + + utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString()); + + utils$1.isString(path) && cookie.push('path=' + path); + + utils$1.isString(domain) && cookie.push('domain=' + domain); + + secure === true && cookie.push('secure'); + + document.cookie = cookie.join('; '); + }, + + read(name) { + const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); + return (match ? decodeURIComponent(match[3]) : null); + }, + + remove(name) { + this.write(name, '', Date.now() - 86400000); + } + } + + : + + // Non-standard browser env (web workers, react-native) lack needed support. + { + write() {}, + read() { + return null; + }, + remove() {} + }; + +/** + * Determines whether the specified URL is absolute + * + * @param {string} url The URL to test + * + * @returns {boolean} True if the specified URL is absolute, otherwise false + */ +function isAbsoluteURL(url) { + // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). + // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed + // by any combination of letters, digits, plus, period, or hyphen. + return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url); +} + +/** + * Creates a new URL by combining the specified URLs + * + * @param {string} baseURL The base URL + * @param {string} relativeURL The relative URL + * + * @returns {string} The combined URL + */ +function combineURLs(baseURL, relativeURL) { + return relativeURL + ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') + : baseURL; +} + +/** + * Creates a new URL by combining the baseURL with the requestedURL, + * only when the requestedURL is not already an absolute URL. + * If the requestURL is absolute, this function returns the requestedURL untouched. + * + * @param {string} baseURL The base URL + * @param {string} requestedURL Absolute or relative URL to combine + * + * @returns {string} The combined full path + */ +function buildFullPath(baseURL, requestedURL) { + if (baseURL && !isAbsoluteURL(requestedURL)) { + return combineURLs(baseURL, requestedURL); + } + return requestedURL; +} + +const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing; + +/** + * Config-specific merge-function which creates a new config-object + * by merging two configuration objects together. + * + * @param {Object} config1 + * @param {Object} config2 + * + * @returns {Object} New object resulting from merging config2 to config1 + */ +function mergeConfig(config1, config2) { + // eslint-disable-next-line no-param-reassign + config2 = config2 || {}; + const config = {}; + + function getMergedValue(target, source, caseless) { + if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) { + return utils$1.merge.call({caseless}, target, source); + } else if (utils$1.isPlainObject(source)) { + return utils$1.merge({}, source); + } else if (utils$1.isArray(source)) { + return source.slice(); + } + return source; + } + + // eslint-disable-next-line consistent-return + function mergeDeepProperties(a, b, caseless) { + if (!utils$1.isUndefined(b)) { + return getMergedValue(a, b, caseless); + } else if (!utils$1.isUndefined(a)) { + return getMergedValue(undefined, a, caseless); + } + } + + // eslint-disable-next-line consistent-return + function valueFromConfig2(a, b) { + if (!utils$1.isUndefined(b)) { + return getMergedValue(undefined, b); + } + } + + // eslint-disable-next-line consistent-return + function defaultToConfig2(a, b) { + if (!utils$1.isUndefined(b)) { + return getMergedValue(undefined, b); + } else if (!utils$1.isUndefined(a)) { + return getMergedValue(undefined, a); + } + } + + // eslint-disable-next-line consistent-return + function mergeDirectKeys(a, b, prop) { + if (prop in config2) { + return getMergedValue(a, b); + } else if (prop in config1) { + return getMergedValue(undefined, a); + } + } + + const mergeMap = { + url: valueFromConfig2, + method: valueFromConfig2, + data: valueFromConfig2, + baseURL: defaultToConfig2, + transformRequest: defaultToConfig2, + transformResponse: defaultToConfig2, + paramsSerializer: defaultToConfig2, + timeout: defaultToConfig2, + timeoutMessage: defaultToConfig2, + withCredentials: defaultToConfig2, + withXSRFToken: defaultToConfig2, + adapter: defaultToConfig2, + responseType: defaultToConfig2, + xsrfCookieName: defaultToConfig2, + xsrfHeaderName: defaultToConfig2, + onUploadProgress: defaultToConfig2, + onDownloadProgress: defaultToConfig2, + decompress: defaultToConfig2, + maxContentLength: defaultToConfig2, + maxBodyLength: defaultToConfig2, + beforeRedirect: defaultToConfig2, + transport: defaultToConfig2, + httpAgent: defaultToConfig2, + httpsAgent: defaultToConfig2, + cancelToken: defaultToConfig2, + socketPath: defaultToConfig2, + responseEncoding: defaultToConfig2, + validateStatus: mergeDirectKeys, + headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true) + }; + + utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) { + const merge = mergeMap[prop] || mergeDeepProperties; + const configValue = merge(config1[prop], config2[prop], prop); + (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); + }); + + return config; +} + +const resolveConfig = (config) => { + const newConfig = mergeConfig({}, config); + + let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig; + + newConfig.headers = headers = AxiosHeaders.from(headers); + + newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer); + + // HTTP basic authentication + if (auth) { + headers.set('Authorization', 'Basic ' + + btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : '')) + ); + } + + let contentType; + + if (utils$1.isFormData(data)) { + if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) { + headers.setContentType(undefined); // Let the browser set it + } else if ((contentType = headers.getContentType()) !== false) { + // fix semicolon duplication issue for ReactNative FormData implementation + const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : []; + headers.setContentType([type || 'multipart/form-data', ...tokens].join('; ')); + } + } + + // Add xsrf header + // This is only done if running in a standard browser environment. + // Specifically not if we're in a web worker, or react-native. + + if (platform.hasStandardBrowserEnv) { + withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig)); + + if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) { + // Add xsrf header + const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName); + + if (xsrfValue) { + headers.set(xsrfHeaderName, xsrfValue); + } + } + } + + return newConfig; +}; + +const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined'; + +const xhrAdapter = isXHRAdapterSupported && function (config) { + return new Promise(function dispatchXhrRequest(resolve, reject) { + const _config = resolveConfig(config); + let requestData = _config.data; + const requestHeaders = AxiosHeaders.from(_config.headers).normalize(); + let {responseType} = _config; + let onCanceled; + function done() { + if (_config.cancelToken) { + _config.cancelToken.unsubscribe(onCanceled); + } + + if (_config.signal) { + _config.signal.removeEventListener('abort', onCanceled); + } + } + + let request = new XMLHttpRequest(); + + request.open(_config.method.toUpperCase(), _config.url, true); + + // Set the request timeout in MS + request.timeout = _config.timeout; + + function onloadend() { + if (!request) { + return; + } + // Prepare the response + const responseHeaders = AxiosHeaders.from( + 'getAllResponseHeaders' in request && request.getAllResponseHeaders() + ); + const responseData = !responseType || responseType === 'text' || responseType === 'json' ? + request.responseText : request.response; + const response = { + data: responseData, + status: request.status, + statusText: request.statusText, + headers: responseHeaders, + config, + request + }; + + settle(function _resolve(value) { + resolve(value); + done(); + }, function _reject(err) { + reject(err); + done(); + }, response); + + // Clean up request + request = null; + } + + if ('onloadend' in request) { + // Use onloadend if available + request.onloadend = onloadend; + } else { + // Listen for ready state to emulate onloadend + request.onreadystatechange = function handleLoad() { + if (!request || request.readyState !== 4) { + return; + } + + // The request errored out and we didn't get a response, this will be + // handled by onerror instead + // With one exception: request that using file: protocol, most browsers + // will return status as 0 even though it's a successful request + if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { + return; + } + // readystate handler is calling before onerror or ontimeout handlers, + // so we should call onloadend on the next 'tick' + setTimeout(onloadend); + }; + } + + // Handle browser request cancellation (as opposed to a manual cancellation) + request.onabort = function handleAbort() { + if (!request) { + return; + } + + reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, _config, request)); + + // Clean up request + request = null; + }; + + // Handle low level network errors + request.onerror = function handleError() { + // Real errors are hidden from us by the browser + // onerror should only fire if it's a network error + reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, _config, request)); + + // Clean up request + request = null; + }; + + // Handle timeout + request.ontimeout = function handleTimeout() { + let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded'; + const transitional = _config.transitional || transitionalDefaults; + if (_config.timeoutErrorMessage) { + timeoutErrorMessage = _config.timeoutErrorMessage; + } + reject(new AxiosError( + timeoutErrorMessage, + transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, + _config, + request)); + + // Clean up request + request = null; + }; + + // Remove Content-Type if data is undefined + requestData === undefined && requestHeaders.setContentType(null); + + // Add headers to the request + if ('setRequestHeader' in request) { + utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) { + request.setRequestHeader(key, val); + }); + } + + // Add withCredentials to request if needed + if (!utils$1.isUndefined(_config.withCredentials)) { + request.withCredentials = !!_config.withCredentials; + } + + // Add responseType to request if needed + if (responseType && responseType !== 'json') { + request.responseType = _config.responseType; + } + + // Handle progress if needed + if (typeof _config.onDownloadProgress === 'function') { + request.addEventListener('progress', progressEventReducer(_config.onDownloadProgress, true)); + } + + // Not all browsers support upload events + if (typeof _config.onUploadProgress === 'function' && request.upload) { + request.upload.addEventListener('progress', progressEventReducer(_config.onUploadProgress)); + } + + if (_config.cancelToken || _config.signal) { + // Handle cancellation + // eslint-disable-next-line func-names + onCanceled = cancel => { + if (!request) { + return; + } + reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel); + request.abort(); + request = null; + }; + + _config.cancelToken && _config.cancelToken.subscribe(onCanceled); + if (_config.signal) { + _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled); + } + } + + const protocol = parseProtocol(_config.url); + + if (protocol && platform.protocols.indexOf(protocol) === -1) { + reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config)); + return; + } + + + // Send the request + request.send(requestData || null); + }); +}; + +const composeSignals = (signals, timeout) => { + let controller = new AbortController(); + + let aborted; + + const onabort = function (cancel) { + if (!aborted) { + aborted = true; + unsubscribe(); + const err = cancel instanceof Error ? cancel : this.reason; + controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err)); + } + }; + + let timer = timeout && setTimeout(() => { + onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT)); + }, timeout); + + const unsubscribe = () => { + if (signals) { + timer && clearTimeout(timer); + timer = null; + signals.forEach(signal => { + signal && + (signal.removeEventListener ? signal.removeEventListener('abort', onabort) : signal.unsubscribe(onabort)); + }); + signals = null; + } + }; + + signals.forEach((signal) => signal && signal.addEventListener && signal.addEventListener('abort', onabort)); + + const {signal} = controller; + + signal.unsubscribe = unsubscribe; + + return [signal, () => { + timer && clearTimeout(timer); + timer = null; + }]; +}; + +const streamChunk = function* (chunk, chunkSize) { + let len = chunk.byteLength; + + if (!chunkSize || len < chunkSize) { + yield chunk; + return; + } + + let pos = 0; + let end; + + while (pos < len) { + end = pos + chunkSize; + yield chunk.slice(pos, end); + pos = end; + } +}; + +const readBytes = async function* (iterable, chunkSize, encode) { + for await (const chunk of iterable) { + yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize); + } +}; + +const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => { + const iterator = readBytes(stream, chunkSize, encode); + + let bytes = 0; + + return new ReadableStream({ + type: 'bytes', + + async pull(controller) { + const {done, value} = await iterator.next(); + + if (done) { + controller.close(); + onFinish(); + return; + } + + let len = value.byteLength; + onProgress && onProgress(bytes += len); + controller.enqueue(new Uint8Array(value)); + }, + cancel(reason) { + onFinish(reason); + return iterator.return(); + } + }, { + highWaterMark: 2 + }) +}; + +const fetchProgressDecorator = (total, fn) => { + const lengthComputable = total != null; + return (loaded) => setTimeout(() => fn({ + lengthComputable, + total, + loaded + })); +}; + +const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function'; +const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function'; + +// used only inside the fetch adapter +const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? + ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : + async (str) => new Uint8Array(await new Response(str).arrayBuffer()) +); + +const supportsRequestStream = isReadableStreamSupported && (() => { + let duplexAccessed = false; + + const hasContentType = new Request(platform.origin, { + body: new ReadableStream(), + method: 'POST', + get duplex() { + duplexAccessed = true; + return 'half'; + }, + }).headers.has('Content-Type'); + + return duplexAccessed && !hasContentType; +})(); + +const DEFAULT_CHUNK_SIZE = 64 * 1024; + +const supportsResponseStream = isReadableStreamSupported && !!(()=> { + try { + return utils$1.isReadableStream(new Response('').body); + } catch(err) { + // return undefined + } +})(); + +const resolvers = { + stream: supportsResponseStream && ((res) => res.body) +}; + +isFetchSupported && (((res) => { + ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => { + !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() : + (_, config) => { + throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config); + }); + }); +})(new Response)); + +const getBodyLength = async (body) => { + if (body == null) { + return 0; + } + + if(utils$1.isBlob(body)) { + return body.size; + } + + if(utils$1.isSpecCompliantForm(body)) { + return (await new Request(body).arrayBuffer()).byteLength; + } + + if(utils$1.isArrayBufferView(body)) { + return body.byteLength; + } + + if(utils$1.isURLSearchParams(body)) { + body = body + ''; + } + + if(utils$1.isString(body)) { + return (await encodeText(body)).byteLength; + } +}; + +const resolveBodyLength = async (headers, body) => { + const length = utils$1.toFiniteNumber(headers.getContentLength()); + + return length == null ? getBodyLength(body) : length; +}; + +const fetchAdapter = isFetchSupported && (async (config) => { + let { + url, + method, + data, + signal, + cancelToken, + timeout, + onDownloadProgress, + onUploadProgress, + responseType, + headers, + withCredentials = 'same-origin', + fetchOptions + } = resolveConfig(config); + + responseType = responseType ? (responseType + '').toLowerCase() : 'text'; + + let [composedSignal, stopTimeout] = (signal || cancelToken || timeout) ? + composeSignals([signal, cancelToken], timeout) : []; + + let finished, request; + + const onFinish = () => { + !finished && setTimeout(() => { + composedSignal && composedSignal.unsubscribe(); + }); + + finished = true; + }; + + let requestContentLength; + + try { + if ( + onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' && + (requestContentLength = await resolveBodyLength(headers, data)) !== 0 + ) { + let _request = new Request(url, { + method: 'POST', + body: data, + duplex: "half" + }); + + let contentTypeHeader; + + if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) { + headers.setContentType(contentTypeHeader); + } + + if (_request.body) { + data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator( + requestContentLength, + progressEventReducer(onUploadProgress) + ), null, encodeText); + } + } + + if (!utils$1.isString(withCredentials)) { + withCredentials = withCredentials ? 'cors' : 'omit'; + } + + request = new Request(url, { + ...fetchOptions, + signal: composedSignal, + method: method.toUpperCase(), + headers: headers.normalize().toJSON(), + body: data, + duplex: "half", + withCredentials + }); + + let response = await fetch(request); + + const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response'); + + if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) { + const options = {}; + + ['status', 'statusText', 'headers'].forEach(prop => { + options[prop] = response[prop]; + }); + + const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length')); + + response = new Response( + trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator( + responseContentLength, + progressEventReducer(onDownloadProgress, true) + ), isStreamResponse && onFinish, encodeText), + options + ); + } + + responseType = responseType || 'text'; + + let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config); + + !isStreamResponse && onFinish(); + + stopTimeout && stopTimeout(); + + return await new Promise((resolve, reject) => { + settle(resolve, reject, { + data: responseData, + headers: AxiosHeaders.from(response.headers), + status: response.status, + statusText: response.statusText, + config, + request + }); + }) + } catch (err) { + onFinish(); + + if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) { + throw Object.assign( + new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request), + { + cause: err.cause || err + } + ) + } + + throw AxiosError.from(err, err && err.code, config, request); + } +}); + +const knownAdapters = { + http: httpAdapter, + xhr: xhrAdapter, + fetch: fetchAdapter +}; + +utils$1.forEach(knownAdapters, (fn, value) => { + if (fn) { + try { + Object.defineProperty(fn, 'name', {value}); + } catch (e) { + // eslint-disable-next-line no-empty + } + Object.defineProperty(fn, 'adapterName', {value}); + } +}); + +const renderReason = (reason) => `- ${reason}`; + +const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false; + +const adapters = { + getAdapter: (adapters) => { + adapters = utils$1.isArray(adapters) ? adapters : [adapters]; + + const {length} = adapters; + let nameOrAdapter; + let adapter; + + const rejectedReasons = {}; + + for (let i = 0; i < length; i++) { + nameOrAdapter = adapters[i]; + let id; + + adapter = nameOrAdapter; + + if (!isResolvedHandle(nameOrAdapter)) { + adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()]; + + if (adapter === undefined) { + throw new AxiosError(`Unknown adapter '${id}'`); + } + } + + if (adapter) { + break; + } + + rejectedReasons[id || '#' + i] = adapter; + } + + if (!adapter) { + + const reasons = Object.entries(rejectedReasons) + .map(([id, state]) => `adapter ${id} ` + + (state === false ? 'is not supported by the environment' : 'is not available in the build') + ); + + let s = length ? + (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) : + 'as no adapter specified'; + + throw new AxiosError( + `There is no suitable adapter to dispatch the request ` + s, + 'ERR_NOT_SUPPORT' + ); + } + + return adapter; + }, + adapters: knownAdapters +}; + +/** + * Throws a `CanceledError` if cancellation has been requested. + * + * @param {Object} config The config that is to be used for the request + * + * @returns {void} + */ +function throwIfCancellationRequested(config) { + if (config.cancelToken) { + config.cancelToken.throwIfRequested(); + } + + if (config.signal && config.signal.aborted) { + throw new CanceledError(null, config); + } +} + +/** + * Dispatch a request to the server using the configured adapter. + * + * @param {object} config The config that is to be used for the request + * + * @returns {Promise} The Promise to be fulfilled + */ +function dispatchRequest(config) { + throwIfCancellationRequested(config); + + config.headers = AxiosHeaders.from(config.headers); + + // Transform request data + config.data = transformData.call( + config, + config.transformRequest + ); + + if (['post', 'put', 'patch'].indexOf(config.method) !== -1) { + config.headers.setContentType('application/x-www-form-urlencoded', false); + } + + const adapter = adapters.getAdapter(config.adapter || defaults.adapter); + + return adapter(config).then(function onAdapterResolution(response) { + throwIfCancellationRequested(config); + + // Transform response data + response.data = transformData.call( + config, + config.transformResponse, + response + ); + + response.headers = AxiosHeaders.from(response.headers); + + return response; + }, function onAdapterRejection(reason) { + if (!isCancel(reason)) { + throwIfCancellationRequested(config); + + // Transform response data + if (reason && reason.response) { + reason.response.data = transformData.call( + config, + config.transformResponse, + reason.response + ); + reason.response.headers = AxiosHeaders.from(reason.response.headers); + } + } + + return Promise.reject(reason); + }); +} + +const VERSION = "1.7.2"; + +const validators$1 = {}; + +// eslint-disable-next-line func-names +['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => { + validators$1[type] = function validator(thing) { + return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type; + }; +}); + +const deprecatedWarnings = {}; + +/** + * Transitional option validator + * + * @param {function|boolean?} validator - set to false if the transitional option has been removed + * @param {string?} version - deprecated version / removed since version + * @param {string?} message - some message with additional info + * + * @returns {function} + */ +validators$1.transitional = function transitional(validator, version, message) { + function formatMessage(opt, desc) { + return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : ''); + } + + // eslint-disable-next-line func-names + return (value, opt, opts) => { + if (validator === false) { + throw new AxiosError( + formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), + AxiosError.ERR_DEPRECATED + ); + } + + if (version && !deprecatedWarnings[opt]) { + deprecatedWarnings[opt] = true; + // eslint-disable-next-line no-console + console.warn( + formatMessage( + opt, + ' has been deprecated since v' + version + ' and will be removed in the near future' + ) + ); + } + + return validator ? validator(value, opt, opts) : true; + }; +}; + +/** + * Assert object's properties type + * + * @param {object} options + * @param {object} schema + * @param {boolean?} allowUnknown + * + * @returns {object} + */ + +function assertOptions(options, schema, allowUnknown) { + if (typeof options !== 'object') { + throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE); + } + const keys = Object.keys(options); + let i = keys.length; + while (i-- > 0) { + const opt = keys[i]; + const validator = schema[opt]; + if (validator) { + const value = options[opt]; + const result = value === undefined || validator(value, opt, options); + if (result !== true) { + throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE); + } + continue; + } + if (allowUnknown !== true) { + throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION); + } + } +} + +const validator = { + assertOptions, + validators: validators$1 +}; + +const validators = validator.validators; + +/** + * Create a new instance of Axios + * + * @param {Object} instanceConfig The default config for the instance + * + * @return {Axios} A new instance of Axios + */ +class Axios { + constructor(instanceConfig) { + this.defaults = instanceConfig; + this.interceptors = { + request: new InterceptorManager(), + response: new InterceptorManager() + }; + } + + /** + * Dispatch a request + * + * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults) + * @param {?Object} config + * + * @returns {Promise} The Promise to be fulfilled + */ + async request(configOrUrl, config) { + try { + return await this._request(configOrUrl, config); + } catch (err) { + if (err instanceof Error) { + let dummy; + + Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error()); + + // slice off the Error: ... line + const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : ''; + try { + if (!err.stack) { + err.stack = stack; + // match without the 2 top stack lines + } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) { + err.stack += '\n' + stack; + } + } catch (e) { + // ignore the case where "stack" is an un-writable property + } + } + + throw err; + } + } + + _request(configOrUrl, config) { + /*eslint no-param-reassign:0*/ + // Allow for axios('example/url'[, config]) a la fetch API + if (typeof configOrUrl === 'string') { + config = config || {}; + config.url = configOrUrl; + } else { + config = configOrUrl || {}; + } + + config = mergeConfig(this.defaults, config); + + const {transitional, paramsSerializer, headers} = config; + + if (transitional !== undefined) { + validator.assertOptions(transitional, { + silentJSONParsing: validators.transitional(validators.boolean), + forcedJSONParsing: validators.transitional(validators.boolean), + clarifyTimeoutError: validators.transitional(validators.boolean) + }, false); + } + + if (paramsSerializer != null) { + if (utils$1.isFunction(paramsSerializer)) { + config.paramsSerializer = { + serialize: paramsSerializer + }; + } else { + validator.assertOptions(paramsSerializer, { + encode: validators.function, + serialize: validators.function + }, true); + } + } + + // Set config.method + config.method = (config.method || this.defaults.method || 'get').toLowerCase(); + + // Flatten headers + let contextHeaders = headers && utils$1.merge( + headers.common, + headers[config.method] + ); + + headers && utils$1.forEach( + ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], + (method) => { + delete headers[method]; + } + ); + + config.headers = AxiosHeaders.concat(contextHeaders, headers); + + // filter out skipped interceptors + const requestInterceptorChain = []; + let synchronousRequestInterceptors = true; + this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { + if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) { + return; + } + + synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; + + requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); + }); + + const responseInterceptorChain = []; + this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { + responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); + }); + + let promise; + let i = 0; + let len; + + if (!synchronousRequestInterceptors) { + const chain = [dispatchRequest.bind(this), undefined]; + chain.unshift.apply(chain, requestInterceptorChain); + chain.push.apply(chain, responseInterceptorChain); + len = chain.length; + + promise = Promise.resolve(config); + + while (i < len) { + promise = promise.then(chain[i++], chain[i++]); + } + + return promise; + } + + len = requestInterceptorChain.length; + + let newConfig = config; + + i = 0; + + while (i < len) { + const onFulfilled = requestInterceptorChain[i++]; + const onRejected = requestInterceptorChain[i++]; + try { + newConfig = onFulfilled(newConfig); + } catch (error) { + onRejected.call(this, error); + break; + } + } + + try { + promise = dispatchRequest.call(this, newConfig); + } catch (error) { + return Promise.reject(error); + } + + i = 0; + len = responseInterceptorChain.length; + + while (i < len) { + promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]); + } + + return promise; + } + + getUri(config) { + config = mergeConfig(this.defaults, config); + const fullPath = buildFullPath(config.baseURL, config.url); + return buildURL(fullPath, config.params, config.paramsSerializer); + } +} + +// Provide aliases for supported request methods +utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, config) { + return this.request(mergeConfig(config || {}, { + method, + url, + data: (config || {}).data + })); + }; +}); + +utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + /*eslint func-names:0*/ + + function generateHTTPMethod(isForm) { + return function httpMethod(url, data, config) { + return this.request(mergeConfig(config || {}, { + method, + headers: isForm ? { + 'Content-Type': 'multipart/form-data' + } : {}, + url, + data + })); + }; + } + + Axios.prototype[method] = generateHTTPMethod(); + + Axios.prototype[method + 'Form'] = generateHTTPMethod(true); +}); + +/** + * A `CancelToken` is an object that can be used to request cancellation of an operation. + * + * @param {Function} executor The executor function. + * + * @returns {CancelToken} + */ +class CancelToken { + constructor(executor) { + if (typeof executor !== 'function') { + throw new TypeError('executor must be a function.'); + } + + let resolvePromise; + + this.promise = new Promise(function promiseExecutor(resolve) { + resolvePromise = resolve; + }); + + const token = this; + + // eslint-disable-next-line func-names + this.promise.then(cancel => { + if (!token._listeners) return; + + let i = token._listeners.length; + + while (i-- > 0) { + token._listeners[i](cancel); + } + token._listeners = null; + }); + + // eslint-disable-next-line func-names + this.promise.then = onfulfilled => { + let _resolve; + // eslint-disable-next-line func-names + const promise = new Promise(resolve => { + token.subscribe(resolve); + _resolve = resolve; + }).then(onfulfilled); + + promise.cancel = function reject() { + token.unsubscribe(_resolve); + }; + + return promise; + }; + + executor(function cancel(message, config, request) { + if (token.reason) { + // Cancellation has already been requested + return; + } + + token.reason = new CanceledError(message, config, request); + resolvePromise(token.reason); + }); + } + + /** + * Throws a `CanceledError` if cancellation has been requested. + */ + throwIfRequested() { + if (this.reason) { + throw this.reason; + } + } + + /** + * Subscribe to the cancel signal + */ + + subscribe(listener) { + if (this.reason) { + listener(this.reason); + return; + } + + if (this._listeners) { + this._listeners.push(listener); + } else { + this._listeners = [listener]; + } + } + + /** + * Unsubscribe from the cancel signal + */ + + unsubscribe(listener) { + if (!this._listeners) { + return; + } + const index = this._listeners.indexOf(listener); + if (index !== -1) { + this._listeners.splice(index, 1); + } + } + + /** + * Returns an object that contains a new `CancelToken` and a function that, when called, + * cancels the `CancelToken`. + */ + static source() { + let cancel; + const token = new CancelToken(function executor(c) { + cancel = c; + }); + return { + token, + cancel + }; + } +} + +/** + * Syntactic sugar for invoking a function and expanding an array for arguments. + * + * Common use case would be to use `Function.prototype.apply`. + * + * ```js + * function f(x, y, z) {} + * var args = [1, 2, 3]; + * f.apply(null, args); + * ``` + * + * With `spread` this example can be re-written. + * + * ```js + * spread(function(x, y, z) {})([1, 2, 3]); + * ``` + * + * @param {Function} callback + * + * @returns {Function} + */ +function spread(callback) { + return function wrap(arr) { + return callback.apply(null, arr); + }; +} + +/** + * Determines whether the payload is an error thrown by Axios + * + * @param {*} payload The value to test + * + * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false + */ +function isAxiosError(payload) { + return utils$1.isObject(payload) && (payload.isAxiosError === true); +} + +const HttpStatusCode = { + Continue: 100, + SwitchingProtocols: 101, + Processing: 102, + EarlyHints: 103, + Ok: 200, + Created: 201, + Accepted: 202, + NonAuthoritativeInformation: 203, + NoContent: 204, + ResetContent: 205, + PartialContent: 206, + MultiStatus: 207, + AlreadyReported: 208, + ImUsed: 226, + MultipleChoices: 300, + MovedPermanently: 301, + Found: 302, + SeeOther: 303, + NotModified: 304, + UseProxy: 305, + Unused: 306, + TemporaryRedirect: 307, + PermanentRedirect: 308, + BadRequest: 400, + Unauthorized: 401, + PaymentRequired: 402, + Forbidden: 403, + NotFound: 404, + MethodNotAllowed: 405, + NotAcceptable: 406, + ProxyAuthenticationRequired: 407, + RequestTimeout: 408, + Conflict: 409, + Gone: 410, + LengthRequired: 411, + PreconditionFailed: 412, + PayloadTooLarge: 413, + UriTooLong: 414, + UnsupportedMediaType: 415, + RangeNotSatisfiable: 416, + ExpectationFailed: 417, + ImATeapot: 418, + MisdirectedRequest: 421, + UnprocessableEntity: 422, + Locked: 423, + FailedDependency: 424, + TooEarly: 425, + UpgradeRequired: 426, + PreconditionRequired: 428, + TooManyRequests: 429, + RequestHeaderFieldsTooLarge: 431, + UnavailableForLegalReasons: 451, + InternalServerError: 500, + NotImplemented: 501, + BadGateway: 502, + ServiceUnavailable: 503, + GatewayTimeout: 504, + HttpVersionNotSupported: 505, + VariantAlsoNegotiates: 506, + InsufficientStorage: 507, + LoopDetected: 508, + NotExtended: 510, + NetworkAuthenticationRequired: 511, +}; + +Object.entries(HttpStatusCode).forEach(([key, value]) => { + HttpStatusCode[value] = key; +}); + +/** + * Create an instance of Axios + * + * @param {Object} defaultConfig The default config for the instance + * + * @returns {Axios} A new instance of Axios + */ +function createInstance(defaultConfig) { + const context = new Axios(defaultConfig); + const instance = bind(Axios.prototype.request, context); + + // Copy axios.prototype to instance + utils$1.extend(instance, Axios.prototype, context, {allOwnKeys: true}); + + // Copy context to instance + utils$1.extend(instance, context, null, {allOwnKeys: true}); + + // Factory for creating new instances + instance.create = function create(instanceConfig) { + return createInstance(mergeConfig(defaultConfig, instanceConfig)); + }; + + return instance; +} + +// Create the default instance to be exported +const axios = createInstance(defaults); + +// Expose Axios class to allow class inheritance +axios.Axios = Axios; + +// Expose Cancel & CancelToken +axios.CanceledError = CanceledError; +axios.CancelToken = CancelToken; +axios.isCancel = isCancel; +axios.VERSION = VERSION; +axios.toFormData = toFormData; + +// Expose AxiosError class +axios.AxiosError = AxiosError; + +// alias for CanceledError for backward compatibility +axios.Cancel = axios.CanceledError; + +// Expose all/spread +axios.all = function all(promises) { + return Promise.all(promises); +}; + +axios.spread = spread; + +// Expose isAxiosError +axios.isAxiosError = isAxiosError; + +// Expose mergeConfig +axios.mergeConfig = mergeConfig; + +axios.AxiosHeaders = AxiosHeaders; + +axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing); + +axios.getAdapter = adapters.getAdapter; + +axios.HttpStatusCode = HttpStatusCode; + +axios.default = axios; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function commonjsRequire(path) { + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +} + +var jszip_min = {exports: {}}; + +/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files -(c) 2009-2016 Stuart Knightley -Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. +(c) 2009-2016 Stuart Knightley +Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. + +JSZip uses the library pako released under the MIT license : +https://github.com/nodeca/pako/blob/main/LICENSE +*/ + +(function (module, exports) { + !function(e){module.exports=e();}(function(){return function s(a,o,h){function u(r,e){if(!o[r]){if(!a[r]){var t="function"==typeof commonjsRequire&&commonjsRequire;if(!e&&t)return t(r,!0);if(l)return l(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var i=o[r]={exports:{}};a[r][0].call(i.exports,function(e){var t=a[r][1][e];return u(t||e)},i,i.exports,s,a,o,h);}return o[r].exports}for(var l="function"==typeof commonjsRequire&&commonjsRequire,e=0;e>2,s=(3&t)<<4|r>>4,a=1>6:64,o=2>4,r=(15&i)<<4|(s=p.indexOf(e.charAt(o++)))>>2,n=(3&s)<<6|(a=p.indexOf(e.charAt(o++))),l[h++]=t,64!==s&&(l[h++]=r),64!==a&&(l[h++]=n);return l};},{"./support":30,"./utils":32}],2:[function(e,t,r){var n=e("./external"),i=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),a=e("./stream/DataLengthProbe");function o(e,t,r,n,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=n,this.compressedContent=i;}o.prototype={getContentWorker:function(){var e=new i(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new i(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(e,t,r){return e.pipe(new s).pipe(new a("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new a("compressedSize")).withStreamInfo("compression",t)},t.exports=o;},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,r){var n=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},r.DEFLATE=e("./flate");},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,r){var n=e("./utils");var o=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e;}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==n.getTypeOf(e)?function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a>>8^i[255&(e^t[a])];return -1^e}(0|t,e,e.length,0):function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a>>8^i[255&(e^t.charCodeAt(a))];return -1^e}(0|t,e,e.length,0):0};},{"./utils":32}],5:[function(e,t,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null;},{}],6:[function(e,t,r){var n=null;n="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:n};},{lie:37}],7:[function(e,t,r){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),s=e("./utils"),a=e("./stream/GenericWorker"),o=n?"uint8array":"array";function h(e,t){a.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={};}r.magic="\b\0",s.inherits(h,a),h.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(o,e.data),!1);},h.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0);},h.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null;},h.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta});};},r.compressWorker=function(e){return new h("Deflate",e)},r.uncompressWorker=function(){return new h("Inflate",{})};},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,r){function A(e,t){var r,n="";for(r=0;r>>=8;return n}function n(e,t,r,n,i,s){var a,o,h=e.file,u=e.compression,l=s!==O.utf8encode,f=I.transformTo("string",s(h.name)),c=I.transformTo("string",O.utf8encode(h.name)),d=h.comment,p=I.transformTo("string",s(d)),m=I.transformTo("string",O.utf8encode(d)),_=c.length!==h.name.length,g=m.length!==d.length,b="",v="",y="",w=h.dir,k=h.date,x={crc32:0,compressedSize:0,uncompressedSize:0};t&&!r||(x.crc32=e.crc32,x.compressedSize=e.compressedSize,x.uncompressedSize=e.uncompressedSize);var S=0;t&&(S|=8),l||!_&&!g||(S|=2048);var z=0,C=0;w&&(z|=16),"UNIX"===i?(C=798,z|=function(e,t){var r=e;return e||(r=t?16893:33204),(65535&r)<<16}(h.unixPermissions,w)):(C=20,z|=function(e){return 63&(e||0)}(h.dosPermissions)),a=k.getUTCHours(),a<<=6,a|=k.getUTCMinutes(),a<<=5,a|=k.getUTCSeconds()/2,o=k.getUTCFullYear()-1980,o<<=4,o|=k.getUTCMonth()+1,o<<=5,o|=k.getUTCDate(),_&&(v=A(1,1)+A(B(f),4)+c,b+="up"+A(v.length,2)+v),g&&(y=A(1,1)+A(B(p),4)+m,b+="uc"+A(y.length,2)+y);var E="";return E+="\n\0",E+=A(S,2),E+=u.magic,E+=A(a,2),E+=A(o,2),E+=A(x.crc32,4),E+=A(x.compressedSize,4),E+=A(x.uncompressedSize,4),E+=A(f.length,2),E+=A(b.length,2),{fileRecord:R.LOCAL_FILE_HEADER+E+f+b,dirRecord:R.CENTRAL_FILE_HEADER+A(C,2)+E+A(p.length,2)+"\0\0\0\0"+A(z,4)+A(n,4)+f+b+p}}var I=e("../utils"),i=e("../stream/GenericWorker"),O=e("../utf8"),B=e("../crc32"),R=e("../signature");function s(e,t,r,n){i.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[];}I.inherits(s,i),s.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,i.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-n-1))/r:100}}));},s.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var r=n(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}});}else this.accumulate=!0;},s.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,r=n(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),t)this.push({data:function(e){return R.DATA_DESCRIPTOR+A(e.crc32,4)+A(e.compressedSize,4)+A(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null;},s.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return n.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i;},{"../utils":32}],19:[function(e,t,r){var n=e("./Uint8ArrayReader");function i(e){n.call(this,e);}e("../utils").inherits(i,n),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i;},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,r){var n=e("./DataReader");function i(e){n.call(this,e);}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i;},{"../utils":32,"./DataReader":18}],21:[function(e,t,r){var n=e("./ArrayReader");function i(e){n.call(this,e);}e("../utils").inherits(i,n),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i;},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,r){var n=e("../utils"),i=e("../support"),s=e("./ArrayReader"),a=e("./StringReader"),o=e("./NodeBufferReader"),h=e("./Uint8ArrayReader");t.exports=function(e){var t=n.getTypeOf(e);return n.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new o(e):i.uint8array?new h(n.transformTo("uint8array",e)):new s(n.transformTo("array",e)):new a(e)};},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b";},{}],24:[function(e,t,r){var n=e("./GenericWorker"),i=e("../utils");function s(e){n.call(this,"ConvertWorker to "+e),this.destType=e;}i.inherits(s,n),s.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta});},t.exports=s;},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,r){var n=e("./GenericWorker"),i=e("../crc32");function s(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0);}e("../utils").inherits(s,n),s.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e);},t.exports=s;},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,r){var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0);}n.inherits(s,i),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length;}i.prototype.processChunk.call(this,e);},t.exports=s;},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,r){var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=n.getTypeOf(e),t.isPaused||t._tickAndRepeat();},function(e){t.error(e);});}n.inherits(s,i),s.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null;},s.prototype.resume=function(){return !!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0));},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return !1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t);}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s;},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,r){function n(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null;}n.prototype={push:function(e){this.emit("data",e);},end:function(){if(this.isFinished)return !1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0;}catch(e){this.emit("error",e);}return !0},error:function(e){return !this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[];},emit:function(e,t){if(this._listeners[e])for(var r=0;r "+e:e}},t.exports=n;},{}],29:[function(e,t,r){var h=e("../utils"),i=e("./ConvertWorker"),s=e("./GenericWorker"),u=e("../base64"),n=e("../support"),a=e("../external"),o=null;if(n.nodestream)try{o=e("../nodejs/NodejsStreamOutputAdapter");}catch(e){}function l(e,o){return new a.Promise(function(t,r){var n=[],i=e._internalType,s=e._outputType,a=e._mimeType;e.on("data",function(e,t){n.push(e),o&&o(t);}).on("error",function(e){n=[],r(e);}).on("end",function(){try{var e=function(e,t,r){switch(e){case"blob":return h.newBlob(h.transformTo("arraybuffer",t),r);case"base64":return u.encode(t);default:return h.transformTo(e,t)}}(s,function(e,t){var r,n=0,i=null,s=0;for(r=0;r>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t}(e)},s.utf8decode=function(e){return h.nodebuffer?o.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,r,n,i,s=e.length,a=new Array(2*s);for(t=r=0;t>10&1023,a[r++]=56320|1023&n);}return a.length!==r&&(a.subarray?a=a.subarray(0,r):a.length=r),o.applyFromCharCode(a)}(e=o.transformTo(h.uint8array?"uint8array":"array",e))},o.inherits(a,n),a.prototype.processChunk=function(e){var t=o.transformTo(h.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(h.uint8array){var r=t;(t=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),t.set(r,this.leftOver.length);}else t=this.leftOver.concat(t);this.leftOver=null;}var n=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}(t),i=t;n!==t.length&&(h.uint8array?(i=t.subarray(0,n),this.leftOver=t.subarray(n,t.length)):(i=t.slice(0,n),this.leftOver=t.slice(n,t.length))),this.push({data:s.utf8decode(i),meta:e.meta});},a.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null);},s.Utf8DecodeWorker=a,o.inherits(l,n),l.prototype.processChunk=function(e){this.push({data:s.utf8encode(e.data),meta:e.meta});},s.Utf8EncodeWorker=l;},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,a){var o=e("./support"),h=e("./base64"),r=e("./nodejsUtils"),u=e("./external");function n(e){return e}function l(e,t){for(var r=0;r>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0);},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=n(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4));}},readExtraFields:function(e){var t,r,n,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t},r.buf2binstring=function(e){return l(e,e.length)},r.binstring2buf=function(e){for(var t=new h.Buf8(e.length),r=0,n=t.length;r>10&1023,o[n++]=56320|1023&i);}return l(o,n)},r.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t};},{"./common":41}],43:[function(e,t,r){t.exports=function(e,t,r,n){for(var i=65535&e|0,s=e>>>16&65535|0,a=0;0!==r;){for(r-=a=2e3>>1:e>>>1;t[r]=e;}return t}();t.exports=function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a>>8^i[255&(e^t[a])];return -1^e};},{}],46:[function(e,t,r){var h,c=e("../utils/common"),u=e("./trees"),d=e("./adler32"),p=e("./crc32"),n=e("./messages"),l=0,f=4,m=0,_=-2,g=-1,b=4,i=2,v=8,y=9,s=286,a=30,o=19,w=2*s+1,k=15,x=3,S=258,z=S+x+1,C=42,E=113,A=1,I=2,O=3,B=4;function R(e,t){return e.msg=n[t],t}function T(e){return (e<<1)-(4e.avail_out&&(r=e.avail_out),0!==r&&(c.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0));}function N(e,t){u._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,F(e.strm);}function U(e,t){e.pending_buf[e.pending++]=t;}function P(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t;}function L(e,t){var r,n,i=e.max_chain_length,s=e.strstart,a=e.prev_length,o=e.nice_match,h=e.strstart>e.w_size-z?e.strstart-(e.w_size-z):0,u=e.window,l=e.w_mask,f=e.prev,c=e.strstart+S,d=u[s+a-1],p=u[s+a];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(u[(r=t)+a]===p&&u[r+a-1]===d&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&sh&&0!=--i);return a<=e.lookahead?a:e.lookahead}function j(e){var t,r,n,i,s,a,o,h,u,l,f=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=f+(f-z)){for(c.arraySet(e.window,e.window,f,f,0),e.match_start-=f,e.strstart-=f,e.block_start-=f,t=r=e.hash_size;n=e.head[--t],e.head[t]=f<=n?n-f:0,--r;);for(t=r=f;n=e.prev[--t],e.prev[t]=f<=n?n-f:0,--r;);i+=f;}if(0===e.strm.avail_in)break;if(a=e.strm,o=e.window,h=e.strstart+e.lookahead,u=i,l=void 0,l=a.avail_in,u=x)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<=x&&(e.ins_h=(e.ins_h<=x)if(n=u._tr_tally(e,e.strstart-e.match_start,e.match_length-x),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=x){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=x&&(e.ins_h=(e.ins_h<=x&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-x,n=u._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-x),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(j(e),0===e.lookahead&&t===l)return A;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,N(e,!1),0===e.strm.avail_out))return A;if(e.strstart-e.block_start>=e.w_size-z&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):(e.strstart>e.block_start&&(N(e,!1),e.strm.avail_out),A)}),new M(4,4,8,4,Z),new M(4,5,16,8,Z),new M(4,6,32,32,Z),new M(4,4,16,16,W),new M(8,16,32,32,W),new M(8,16,128,128,W),new M(8,32,128,256,W),new M(32,128,258,1024,W),new M(32,258,258,4096,W)],r.deflateInit=function(e,t){return Y(e,t,v,15,8,0)},r.deflateInit2=Y,r.deflateReset=K,r.deflateResetKeep=G,r.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?_:(e.state.gzhead=t,m):_},r.deflate=function(e,t){var r,n,i,s;if(!e||!e.state||5>8&255),U(n,n.gzhead.time>>16&255),U(n,n.gzhead.time>>24&255),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(U(n,255&n.gzhead.extra.length),U(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=p(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(U(n,0),U(n,0),U(n,0),U(n,0),U(n,0),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,3),n.status=E);else {var a=v+(n.w_bits-8<<4)<<8;a|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=E,P(n,a),0!==n.strstart&&(P(n,e.adler>>>16),P(n,65535&e.adler)),e.adler=1;}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending!==n.pending_buf_size));)U(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73);}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindexi&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.gzindex=0,n.status=91);}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindexi&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.status=103);}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&F(e),n.pending+2<=n.pending_buf_size&&(U(n,255&e.adler),U(n,e.adler>>8&255),e.adler=0,n.status=E)):n.status=E),0!==n.pending){if(F(e),0===e.avail_out)return n.last_flush=-1,m}else if(0===e.avail_in&&T(t)<=T(r)&&t!==f)return R(e,-5);if(666===n.status&&0!==e.avail_in)return R(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==l&&666!==n.status){var o=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(j(e),0===e.lookahead)){if(t===l)return A;break}if(e.match_length=0,r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):3===n.strategy?function(e,t){for(var r,n,i,s,a=e.window;;){if(e.lookahead<=S){if(j(e),e.lookahead<=S&&t===l)return A;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=x&&0e.lookahead&&(e.match_length=e.lookahead);}if(e.match_length>=x?(r=u._tr_tally(e,1,e.match_length-x),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):h[n.level].func(n,t);if(o!==O&&o!==B||(n.status=666),o===A||o===O)return 0===e.avail_out&&(n.last_flush=-1),m;if(o===I&&(1===t?u._tr_align(n):5!==t&&(u._tr_stored_block(n,0,0,!1),3===t&&(D(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),F(e),0===e.avail_out))return n.last_flush=-1,m}return t!==f?m:n.wrap<=0?1:(2===n.wrap?(U(n,255&e.adler),U(n,e.adler>>8&255),U(n,e.adler>>16&255),U(n,e.adler>>24&255),U(n,255&e.total_in),U(n,e.total_in>>8&255),U(n,e.total_in>>16&255),U(n,e.total_in>>24&255)):(P(n,e.adler>>>16),P(n,65535&e.adler)),F(e),0=r.w_size&&(0===s&&(D(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new c.Buf8(r.w_size),c.arraySet(u,t,l-r.w_size,r.w_size,0),t=u,l=r.w_size),a=e.avail_in,o=e.next_in,h=e.input,e.avail_in=l,e.next_in=0,e.input=t,j(r);r.lookahead>=x;){for(n=r.strstart,i=r.lookahead-(x-1);r.ins_h=(r.ins_h<>>=y=v>>>24,p-=y,0===(y=v>>>16&255))C[s++]=65535&v;else {if(!(16&y)){if(0==(64&y)){v=m[(65535&v)+(d&(1<>>=y,p-=y),p<15&&(d+=z[n++]<>>=y=v>>>24,p-=y,!(16&(y=v>>>16&255))){if(0==(64&y)){v=_[(65535&v)+(d&(1<>>=y,p-=y,(y=s-a)>3,d&=(1<<(p-=w<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function s(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new I.Buf16(320),this.work=new I.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0;}function a(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=P,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new I.Buf32(n),t.distcode=t.distdyn=new I.Buf32(i),t.sane=1,t.back=-1,N):U}function o(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,a(e)):U}function h(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=s.wsize?(I.arraySet(s.window,t,r-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(n<(i=s.wsize-s.wnext)&&(i=n),I.arraySet(s.window,t,r-n,i,s.wnext),(n-=i)?(I.arraySet(s.window,t,r-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,r.check=B(r.check,E,2,0),l=u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=30;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=30;break}if(l-=4,k=8+(15&(u>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=3;case 3:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<>>8&255,E[2]=u>>>16&255,E[3]=u>>>24&255,r.check=B(r.check,E,4,0)),l=u=0,r.mode=4;case 4:for(;l<16;){if(0===o)break e;o--,u+=n[s++]<>8),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===o)break e;o--,u+=n[s++]<>>8&255,r.check=B(r.check,E,2,0)),l=u=0;}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(o<(d=r.length)&&(d=o),d&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),I.arraySet(r.head.extra,n,s,d,k)),512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break e;for(d=0;k=n[s+d++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k)),k&&d>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===o)break e;o--,u+=n[s++]<>>=1)){case 0:r.mode=14;break;case 1:if(j(r),r.mode=20,6!==t)break;u>>>=2,l-=2;break e;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30;}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,u+=n[s++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&u,l=u=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(o>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,286>>=3,l-=3;}for(;r.have<19;)r.lens[A[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},x=T(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=_,l-=_,r.lens[r.have++]=b;else {if(16===b){for(z=_+2;l>>=_,l-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}k=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2;}else if(17===b){for(z=_+3;l>>=_)),u>>>=3,l-=3;}else {for(z=_+7;l>>=_)),u>>>=7,l-=7;}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;d--;)r.lens[r.have++]=k;}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},x=T(D,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},x=T(F,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,x){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(6<=o&&258<=h){e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,R(e,c),a=e.next_out,i=e.output,h=e.avail_out,s=e.next_in,n=e.input,o=e.avail_in,u=r.hold,l=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(C=r.lencode[u&(1<>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=v,l-=v,r.back+=v;}if(u>>>=_,l-=_,r.back+=_,r.length=b,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(z=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra;}r.was=r.length,r.mode=23;case 23:for(;g=(C=r.distcode[u&(1<>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=v,l-=v,r.back+=v;}if(u>>>=_,l-=_,r.back+=_,64&g){e.msg="invalid distance code",r.mode=30;break}r.offset=b,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(z=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra;}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===h)break e;if(d=c-h,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}p=d>r.wnext?(d-=r.wnext,r.wsize-d):r.wnext-d,d>r.length&&(d=r.length),m=r.window;}else m=i,p=a-r.offset,d=r.length;for(hd?(m=R[T+a[v]],A[I+a[v]]):(m=96,0),h=1<>S)+(u-=h)]=p<<24|m<<16|_|0,0!==u;);for(h=1<>=1;if(0!==h?(E&=h-1,E+=h):E=0,v++,0==--O[b]){if(b===w)break;b=t[r+a[v]];}if(k>>7)]}function U(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255;}function P(e,t,r){e.bi_valid>d-r?(e.bi_buf|=t<>d-e.bi_valid,e.bi_valid+=r-d):(e.bi_buf|=t<>>=1,r<<=1,0<--t;);return r>>>1}function Z(e,t,r){var n,i,s=new Array(g+1),a=0;for(n=1;n<=g;n++)s[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var o=e[2*i+1];0!==o&&(e[2*i]=j(s[o]++,o));}}function W(e){var t;for(t=0;t>1;1<=r;r--)G(e,s,r);for(i=h;r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],G(e,s,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,s[2*i]=s[2*r]+s[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,s[2*r+1]=s[2*n+1]=i,e.heap[1]=i++,G(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,s,a,o,h=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,f=t.stat_desc.has_stree,c=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,m=0;for(s=0;s<=g;s++)e.bl_count[s]=0;for(h[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<_;r++)p<(s=h[2*h[2*(n=e.heap[r])+1]+1]+1)&&(s=p,m++),h[2*n+1]=s,u>=7;n>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return o;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return h;for(t=32;t>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==t?J(e,t,r,n):4===e.strategy||s===i?(P(e,2+(n?1:0),3),K(e,z,C)):(P(e,4+(n?1:0),3),function(e,t,r,n){var i;for(P(e,t-257,5),P(e,r-1,5),P(e,n-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(A[r]+u+1)]++,e.dyn_dtree[2*N(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){P(e,2,3),L(e,m,z),function(e){16===e.bi_valid?(U(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8);}(e);};},{"../utils/common":41}],53:[function(e,t,r){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0;};},{}],54:[function(e,t,r){(function(e){!function(r,n){if(!r.setImmediate){var i,s,t,a,o=1,h={},u=!1,l=r.document,e=Object.getPrototypeOf&&Object.getPrototypeOf(r);e=e&&e.setTimeout?e:r,i="[object process]"==={}.toString.call(r.process)?function(e){process.nextTick(function(){c(e);});}:function(){if(r.postMessage&&!r.importScripts){var e=!0,t=r.onmessage;return r.onmessage=function(){e=!1;},r.postMessage("","*"),r.onmessage=t,e}}()?(a="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",d,!1):r.attachEvent("onmessage",d),function(e){r.postMessage(a+e,"*");}):r.MessageChannel?((t=new MessageChannel).port1.onmessage=function(e){c(e.data);},function(e){t.port2.postMessage(e);}):l&&"onreadystatechange"in l.createElement("script")?(s=l.documentElement,function(e){var t=l.createElement("script");t.onreadystatechange=function(){c(e),t.onreadystatechange=null,s.removeChild(t),t=null;},s.appendChild(t);}):function(e){setTimeout(c,0,e);},e.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r= string.length) { + nextChar = "\n"; // save new line + } else { + var _char = string[endPos]; + + if (_char === ' ') { + nextChar = _char; // save space + } + } + + if (nextChar) { + match.nextChar = nextChar; + } + + matches.push(match); + } + } + + return matches; +}; +/** + * @description - Parses the marker that opens and describes content + * @param {String} markerOpen - the string that contains the marker '\v 1', '\p', ... + * @return {Object} - the object of tag and number if it exists +*/ + + +var parseMarkerOpen = function parseMarkerOpen(markerOpen) { + var object = {}; + + if (markerOpen) { + var regex = /(\+?\w+)\s*(\d*)/g; + var matches = getMatches(markerOpen, regex, true); + object = { + tag: matches[0][1], + number: matches[0][2] + }; + } + + return object; +}; +/** + * @description - trim a leading space + * @param {String} text - text to trim + * @return {String} trimmed string + */ + + +var removeLeadingSpace = function removeLeadingSpace(text) { + if (text && text.length > 1 && text[0] === " ") { + text = text.substr(1); + } + + return text; +}; +/** + * @description - Parses the word marker into word object + * @param {object} state - holds parsing state information + * @param {String} wordContent - the string to find the data/attributes + * @param {null|Array} removePrefixOfX - array of attributes we want to remove the 'x-` prefix + * @return {Object} - object of the word attributes +*/ + + +var parseWord = function parseWord(state, wordContent) { + var removePrefixOfX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + var object = {}; + var wordParts = (wordContent || "").split('|'); + var word = removeLeadingSpace(wordParts[0]); + var attributeContent = wordParts[1]; + object = { + text: word, + tag: 'w', + type: 'word' + }; + + if (state.params["content-source"]) { + object["content-source"] = state.params["content-source"]; + } + + if (attributeContent) { + var regex = /([x-]*)([\w-]+)=['"](.*?)['"]/g; + var matches = getMatches(attributeContent, regex, true); + + for (var i = 0, len = matches.length; i < len; i++) { + var match = matches[i]; + var key = match[2]; + var xPrefix = match[1]; + + if (xPrefix) { + if (removePrefixOfX !== null && !removePrefixOfX.includes(key)) { + // if this is not one of our attributes, leave the `x-` prefix + key = xPrefix + key; + } + } + + if (key === "strongs" || key === "x-strong") { + // fix invalid strong keys + key = "strong"; + } + + if (state.params.map && state.params.map[key]) { + // see if we should convert this key + key = state.params.map[key]; + } + + var value = match[3]; + + if (state.params.convertToInt && state.params.convertToInt.includes(key)) { + value = parseInt(value, 10); + } + + object[key] = value; + } + + if (!matches.length) { + object[attributeContent] = ""; // place holder for attribute with no value + } + } + + return object; +}; +/** + * @description - make a marker object that contains the text + * @param {string} text - text to embed in object + * @return {{content: *}} new text marker + */ + + +var makeTextMarker = function makeTextMarker(text) { + return { + content: text + }; +}; +/** + * @description create marker object from text + * @param {String} text - text to put in marker + * @return {object} new marker + */ + + +var createMarkerFromText = function createMarkerFromText(text) { + return { + open: text, + tag: text + }; +}; +/** + * @description - Parses the line and determines what content is in it + * @param {String} line - the string to find the markers and content + * @param {Boolean} lastLine - true if last line of file + * @return {Array} - array of objects that describe open/close and content +*/ + + +var parseLine = function parseLine(line, lastLine) { + var array = []; + + if (line.trim() === '') { + if (!lastLine) { + var object = makeTextMarker(line + '\n'); + array.push(object); + } + + return array; + } + + var regex = /([^\\]+)?\\(\+?\w+\s*\d*)(?!\w)\s*([^\\]+)?(\\\w\*)?/g; + var matches = getMatches(line, regex, lastLine); + + if (matches.length && matches[0].index > 0) { + // check for leading text + var _object = makeTextMarker(line.substr(0, matches[0].index - 1)); + + array.push(_object); + } + + var lastObject = null; + + if (regex.exec(line)) { + // normal formatting with marker followed by content + for (var i = 0, len = matches.length; i < len; i++) { + var match = matches[i]; + var orphan = match[1]; + + if (orphan) { + var _object3 = { + content: orphan + }; + array.push(_object3); + match[0] = match[0].substr(orphan.length); // trim out orphan text + + match.index += orphan.length; + } + + var open = match[2] ? match[2].trim() : undefined; + var content = match[3] || undefined; + var close = match[4] ? match[4].trim() : undefined; + var marker = parseMarkerOpen(open); + var _object2 = { + open: open, + tag: marker.tag, + number: marker.number, + content: content + }; + var whiteSpaceInOpen = open !== match[2]; + + if (whiteSpaceInOpen && !marker.number) { + var shouldMatch = '\\' + open + (content ? ' ' + content : ""); + + if (removeLeadingSpace(match[0]) !== shouldMatch) { + // look for dropped inside white space + var endMatch = match.index + match[0].length; + var lineLength = line.length; + var runToEnd = endMatch >= lineLength; + var startPos = open.length + 2; + var endPos = match[0].indexOf(match[3], startPos); + + if (endPos < 0) { + if (!runToEnd) { + if (match[0] === '\\' + match[2]) { + _object2.nextChar = ' '; + } + } else { + endPos = startPos; + startPos--; + } + } + + var prefix = endPos >= 0 && match[0].substring(startPos, endPos); + + if (prefix) { + _object2.content = prefix + (content || ""); + } + } + } + + if (marker.number && !USFM$1.markerSupportsNumbers(marker.tag)) { + // this tag doesn't have number, move to content + delete _object2.number; + var newContent = void 0; + var tagPos = match[0].indexOf(marker.tag); + + if (tagPos >= 0) { + newContent = match[0].substr(tagPos + marker.tag.length + 1); + } else { + newContent = marker.number + ' ' + (content || ""); + } + + _object2.content = newContent; + } + + if (close) { + if (_object2.content) { + var pos = _object2.content.lastIndexOf(close); + + if (pos >= 0) { + _object2.content = _object2.content.substring(0, pos); + } + } + + array.push(_object2); + var closeTag = close.substr(1); + _object2 = createMarkerFromText(closeTag); + } + + if (match.nextChar) { + _object2.nextChar = match.nextChar; + } + + array.push(_object2); + lastObject = _object2; + } // check for leftover text at end of line + + + if (matches.length) { + var lastMatch = matches[matches.length - 1]; + + var _endPos = lastMatch.index + lastMatch[0].length; + + if (_endPos < line.length) { + var orphanText = line.substr(_endPos) + (lastLine ? '' : '\n'); + + if (lastObject && lastObject.nextChar && lastObject.nextChar === ' ') { + orphanText = orphanText.substr(1); // remove first space since already handled + } + + var _object4 = makeTextMarker(orphanText); + + array.push(_object4); + } + } + } else { + // doesn't have a marker but may have content + // this is considered an orphaned line + var _object5 = makeTextMarker(line + (lastLine ? '' : '\n')); + + array.push(_object5); + } + + return array; +}; +/** + * get top phrase if doing phrase (milestone) + * @param {object} state - holds parsing state information + * @return {object} location to add to phrase or null + */ + + +var getLastPhrase = function getLastPhrase(state) { + if (state.phrase && state.phrase.length > 0) { + return state.phrase[state.phrase.length - 1]; + } + + return null; +}; +/** + * @description - get location for chapter/verse, if location doesn't exist, create it. + * @param {object} state - holds parsing state information + * @return {array} location to place verse content + */ + + +var getSaveToLocation = function getSaveToLocation(state) { + var saveTo = state.headers; + var phrase = getLastPhrase(state); + + if (phrase !== null) { + saveTo = phrase; + } else if (state.params.chunk) { + if (state.currentVerse) { + if (!state.verses[state.currentVerse]) { + state.verses[state.currentVerse] = []; + } + + saveTo = state.verses[state.currentVerse]; + } + } else if (state.currentChapter) { + if (!state.currentVerse) { + state.currentVerse = 'front'; + } + + if (!state.chapters[state.currentChapter][state.currentVerse]) { + state.chapters[state.currentChapter][state.currentVerse] = []; + } + + saveTo = state.chapters[state.currentChapter][state.currentVerse]; + } + + return saveTo; +}; +/** + * @description - create a USFM object from marker + * @param {object} marker - object that contains usfm marker + * @param {boolean} noNext - if true, then ignore nextChar + * @return {{tag: *}} USFM object + */ + + +var createUsfmObject = function createUsfmObject(marker) { + var noNext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + if (typeof marker === 'string') { + return { + type: "text", + text: marker + }; + } + + var output = marker; + var tag = marker.tag; + var content = marker.content || marker.text; + var tagProps = USFM$1.USFM_PROPERTIES[tag]; + var type = USFM$1.propType(tagProps); + var isText = true; + + if (tag) { + isText = USFM$1.propDisplayable(tagProps); + + if (type === 'milestone' && tag.indexOf('-s') < 0) { + // verify that it actually is a milestone + type = ''; + } + + if (type) { + output.type = type; + } + } else { + // default to text type + output.type = "text"; + } + + if (marker.number) { + if (!USFM$1.markerSupportsNumbers(tag)) { + // handle rare case that parser places part of content as number + var newContent = marker.number; + + if (content) { + newContent += ' ' + content; + } + + content = newContent; + delete output.number; + } + } else { + delete output.number; + } + + if (noNext) { + delete output.nextChar; + } else if (marker.nextChar) { + if (content) { + content += marker.nextChar; + delete output.nextChar; + } + } + + delete output.content; + delete output.text; + + if (content) { + output[isText ? 'text' : 'content'] = content; + } + + delete output.open; + delete output.close; + return output; +}; +/** + * @description push usfm object to array, and concat strings of last array item is also string + * @param {object} state - holds parsing state information + * @param {array} saveTo - location to place verse content + * @param {object|string} usfmObject - object that contains usfm marker, or could be raw text + */ + + +usfmToJson.createUsfmObject = createUsfmObject; + +var pushObject = function pushObject(state, saveTo, usfmObject) { + if (!Array.isArray(saveTo)) { + var phrase = getLastPhrase(state); + + if (phrase === null) { + var isNestedMarker = state.nested.length > 0; + + if (isNestedMarker) { + // if this marker is nested in another marker, then we need to add to content as string + var last = state.nested.length - 1; + var contentKey = USFM$1.markerContentDisplayable(usfmObject.tag) ? 'text' : 'content'; + var lastObject = state.nested[last]; + var output = lastObject[contentKey]; + + if (typeof usfmObject === "string") { + output += usfmObject; + } else { + output += '\\' + usfmObject.tag; + var content = usfmObject.text || usfmObject.content; + + if (content) { + if (content[0] !== ' ') { + output += ' '; + } + + output += content; + } + } + + lastObject[contentKey] = output; + return; + } + } else { + saveTo = phrase; + } + } + + if (typeof usfmObject === "string") { + // if raw text, convert to object + if (usfmObject === '') { + // skip empty strings + return; + } + + usfmObject = createUsfmObject(usfmObject); + } + + saveTo = Array.isArray(saveTo) ? saveTo : getSaveToLocation(state); + + if (saveTo.length && usfmObject.type === "text") { + // see if we can append to previous string + var lastPos = saveTo.length - 1; + var _lastObject = saveTo[lastPos]; + + if (_lastObject.type === "text") { + _lastObject.text += usfmObject.text; + return; + } + } + + saveTo.push(usfmObject); +}; +/** + * @description test if last character was newline (or return) char + * @param {String} line - line to test + * @return {boolean} true if newline + */ + + +usfmToJson.pushObject = pushObject; + +var isLastCharNewLine$1 = function isLastCharNewLine(line) { + var lastChar = line ? line.substr(line.length - 1) : ''; + var index = ['\n', '\r'].indexOf(lastChar); + return index >= 0; +}; +/** + * @description test if next to last character is quote + * @param {String} line - line to test + * @return {boolean} true if newline + */ + + +var isNextToLastCharQuote = function isNextToLastCharQuote(line) { + var nextToLastChar = line && line.length >= 2 ? line.substr(line.length - 2, 1) : ''; + var index = ["'", '"', '“'].indexOf(nextToLastChar); + return index >= 0; +}; + +var isAlignmentMarker = function isAlignmentMarker(lastObject) { + return lastObject && lastObject.tag && ["k", "w", "zaln"].includes(lastObject.tag); +}; +/** + * @description - see if two similar alignment markers crammed together + * @param {object} lastObject - previous object + * @param {String} currentTag - usfm tag of current marker. + * @return {Boolean} - true if two similar markers crammed together + */ + + +var crammedMarkers = function crammedMarkers(lastObject, currentTag) { + var crammed = lastObject && isAlignmentMarker(lastObject) && lastObject.tag === currentTag; + return crammed; +}; +/** + * get last element of an array or null + * @param {Array} array + * @return {null|object} + */ + + +var getLast = function getLast(array) { + if (Array.isArray(array) && array.length) { + var lastItem = array[array.length - 1]; + return lastItem; + } + + return null; +}; +/** + * @description - remove previous new line from text + * @param {object} state - holds parsing state information + * @param {String} currentTag - usfm tag of current marker. + * @param {Boolean} endTag - if true then this is an end marker + */ + + +var removeLastNewLine = function removeLastNewLine(state) { + var currentTag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + var endTag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + var saveTo = getSaveToLocation(state); + var replaceWithSpace = false; + var lastObject = getLast(saveTo); + + if (lastObject) { + if (lastObject.nextChar === '\n') { + if (!state.newAlignFormat) { + delete lastObject.nextChar; + + if (crammedMarkers(lastObject, currentTag)) { + replaceWithSpace = true; + } + } + } else if (lastObject.text) { + var text = lastObject.text; + + if (isLastCharNewLine$1(text)) { + if (text.length === 1) { + saveTo.pop(); + lastObject = getLast(saveTo); + } else { + lastObject.text = text.substr(0, text.length - 1); + + if (!state.newAlignFormat && lastObject.text === ' ' && USFM$1.markerDisplayable(lastObject.tag)) { + lastObject.nextChar = lastObject.text; + delete lastObject.text; + } + } + + replaceWithSpace = state.newAlignFormat || !endTag && crammedMarkers(lastObject, currentTag); + } + } + } + + if (replaceWithSpace) { + pushObject(state, null, ' '); + } +}; +/** + * @description - remove previous new line from text + * @param {object} state - holds parsing state information + */ + + +var handleWordWhiteSpace = function handleWordWhiteSpace(state) { + var saveTo = getSaveToLocation(state); + + if (saveTo && saveTo.length) { + var lastObject = saveTo[saveTo.length - 1]; + + if (lastObject.nextChar === '\n') { + if (!state.newAlignFormat) { + lastObject.nextChar = ' '; + } + } else if (lastObject.text) { + var text = lastObject.text; + + if (isLastCharNewLine$1(text)) { + var startOfLine = saveTo.length === 1 && lastObject.text.length === 1; + var removeNewLine = startOfLine || isNextToLastCharQuote(text); + + if (state.newAlignFormat) { + if (lastObject.type === "text") { + lastObject.text = text.substr(0, text.length - 1) + ' '; + } + } else if (removeNewLine) { + if (text.length === 1) { + saveTo.pop(); + } else { + lastObject.text = text.substr(0, text.length - 1); + } + } else { + // replace newline with space + lastObject.text = text.substr(0, text.length - 1) + ' '; + } + } + } + } +}; +/** + * @description normalize the numbers in string by removing leading '0' + * @param {string} text - number string to normalize + * @return {string} normalized number string + */ + + +var stripLeadingZeros = function stripLeadingZeros(text) { + while (text.length > 1 && text[0] === '0') { + text = text.substr(1); + } + + return text; +}; +/** + * check if object is an end marker + * @param {object} marker - object to check + * @return {{endMarker: (null|string), spannedUsfm: (boolean)}} return new values + */ + + +var checkForEndMarker = function checkForEndMarker(marker) { + var spannedUsfm = false; + var endMarker = null; + var content = marker.content || ""; + var initialTag = marker.tag; + var baseTag = marker.tag; + + if (baseTag.substr(baseTag.length - 1) === "*") { + baseTag = baseTag.substr(0, baseTag.length - 1); + endMarker = marker.tag; + } else if (content.substr(0, 1) === '-') { + var nextChar = content.substr(1, 1); + + if (nextChar === 's' || nextChar === 'e') { + var trim = 2; + marker.tag += content.substr(0, 2); + endMarker = nextChar === 'e' ? marker.tag : null; + baseTag += '-s'; + content = content.substr(trim); + marker.content = content; + } + } else if (content.substr(0, 1) === '*') { + var _trim = 1; + var space = ''; + + if (content.substr(_trim, 1) === ' ') { + _trim++; + space = ' '; + } + + marker.tag += content.substr(0, 1); + endMarker = marker.tag; + content = content.substr(_trim); + + if (content) { + content += marker.nextChar || ''; + delete marker.nextChar; + } + + if (space) { + if (content) { + marker.endMarkerChar = space; + } else { + marker.nextChar = space; + } + } + + marker.content = content; + } + + if (endMarker) { + spannedUsfm = true; + } else { + var tagProps = USFM$1.USFM_PROPERTIES[baseTag]; + + if (USFM$1.propStandalone(tagProps)) { + endMarker = marker.tag; + spannedUsfm = true; + } else { + var termination = USFM$1.propTermination(tagProps); + + if (termination) { + spannedUsfm = true; + + if (initialTag + termination === marker.tag) { + endMarker = marker.tag; + } + } + } + } + + return { + endMarker: endMarker, + spannedUsfm: spannedUsfm + }; +}; +/** + * checks if we are currently within a phrase and if it is non-displayable + * @param {object} state - holds parsing state information + * @return {boolean} true if phrase parent is non-displayable (e.g. a footnote) + */ + + +var isNonDisplayablePhraseParent = function isNonDisplayablePhraseParent(state) { + var phraseParent = getPhraseParent(state); + + if (phraseParent) { + if (!USFM$1.markerContentDisplayable(phraseParent.tag)) { + return true; + } + } + + return false; +}; +/** + * @description - save the usfm object to specified place and handle nested data + * @param {object} state - holds parsing state information + * @param {object} marker - object that contains usfm marker + */ + + +var saveUsfmObject = function saveUsfmObject(state, marker) { + var phraseParent = getPhraseParent(state); + + if (phraseParent) { + if (!USFM$1.markerContentDisplayable(phraseParent.tag)) { + var objectText = typeof marker === 'string' ? marker : markerToText(marker); + phraseParent.content = (phraseParent.content || "") + objectText; + } else if (phraseParent.attrib && !phraseParent.usfm3Milestone && typeof marker === 'string') { + phraseParent.attrib += marker; + } else { + var saveTo = getLastPhrase(state); + var usfmObject_ = createUsfmObject(marker); + saveTo.push(usfmObject_); + } + } else if (state.nested.length > 0) { + // is nested object + pushObject(state, null, marker); + } else { + // not nested + var _saveTo = getSaveToLocation(state); + + _saveTo.push(marker); + } +}; +/** + * keeps nesting count if of same type + * @param {object} state - holds parsing state information + * @param {object} phraseParent - object adding to + * @param {string} tag - tag for verseObject + * @return {boolean} true if match + */ + + +var incrementPhraseNesting = function incrementPhraseNesting(state, phraseParent, tag) { + if (phraseParent && phraseParent.tag === tag) { + if (!phraseParent.nesting) { + phraseParent.nesting = 0; + } + + phraseParent.nesting++; + return true; + } + + return false; +}; +/** + * keeps nesting count if of same type + * @param {object} state - holds parsing state information + * @param {object} phraseParent - object adding to + * @param {string} endTag - tag for verseObject + * @return {{matchesParent: (boolean), count: (number)}} return new values + */ + + +var decrementPhraseNesting = function decrementPhraseNesting(state, phraseParent, endTag) { + var matchesParent = false; + var parts = endTag.split(' '); + var endTagBase = parts[0] + (parts.length > 1 ? '\\*' : ''); // remove attributes + + var count = -1; + + if (phraseParent) { + var terminations = USFM$1.markerTermination(phraseParent.tag); + + if (!terminations) { + terminations = []; + } + + if (terminations && !Array.isArray(terminations)) { + terminations = [terminations]; + } + + var termination = null; + + for (var i = 0, len = terminations.length; i < len; i++) { + termination = terminations[i]; + + if (termination) { + matchesParent = termination === endTagBase || phraseParent.tag + termination === endTagBase || phraseParent.tag.substr(0, phraseParent.tag.length - 2) + termination + '\\*' === endTagBase; + + if (matchesParent) { + break; + } + } + } + + if (!matchesParent && USFM$1.SPECIAL_END_TAGS[endTagBase] === phraseParent.tag) { + matchesParent = true; + } + + if (matchesParent) { + count = phraseParent.nesting || 0; + + if (count) { + phraseParent.nesting = --count; + } + + if (!count) { + delete phraseParent.nesting; + } + + delete phraseParent.usfm3Milestone; + } + } + + return { + matchesParent: matchesParent, + count: count + }; +}; +/** + * get the last item that was saved + * @param {object} state - holds parsing state information + * @return {Object} last item + */ + + +var getLastItem = function getLastItem(state) { + var last = getSaveToLocation(state); + + if (last && last.length) { + last = last[last.length - 1]; + } + + return last; +}; + +var getToEndOfAttributes = function getToEndOfAttributes(content, pos, index, markers) { + var endPos = content.indexOf('*', pos); + + while (endPos < 0) { + // if attributes overflow to next line + var nextLine = index + 1; + + if (nextLine >= markers.length) { + break; + } + + var nextMarker = markers[nextLine]; + + if (!nextMarker.tag && nextMarker.content) { + endPos = nextMarker.content.indexOf('*'); + + if (endPos === 0) { + // attributes are ended + break; + } else if (endPos < 0) { + content += nextMarker.content; + index = nextLine; + endPos = content.indexOf('*', pos); + } else { + var nextContent = nextMarker.content.substr(endPos); + + if (nextMarker.content[endPos - 1] === '\\') { + endPos--; + } + + if (endPos > 0) { + content += nextMarker.content.substr(0, endPos); + nextMarker.content = nextContent; + } + + break; + } + } else { + break; + } + } + + return { + content: content, + index: index + }; +}; +/** + * mark the beginning of a spanned usfm + * @param {object} state - holds parsing state information + * @param {object} marker - verseObject to save + * @param {string} tag - tag for verseObject + * @param {number} index - current position in markers + * @param {array} markers - parsed markers we are iterating through + * @return {number} new index + */ + + +var startSpan = function startSpan(state, marker, tag, index, markers) { + marker.tag = tag; + var phraseParent = getPhraseParent(state); + var tagProps = USFM$1.USFM_PROPERTIES[tag]; + var displayable = USFM$1.propDisplayable(tagProps); + + if (USFM$1.propUsfm3Milestone(tagProps)) { + marker.usfm3Milestone = true; + } + + if (USFM$1.propAttributes(tagProps)) { + var contentKey = USFM$1.propDisplayable(tagProps) ? 'text' : 'content'; + var content = marker[contentKey]; + + if (content) { + var pos = content.indexOf('|'); + + if (pos >= 0) { + var __ret = getToEndOfAttributes(content, pos, index, markers); + + content = __ret.content; + index = __ret.index; + var foundContent = content.substr(0, pos).trim(); + + if (!foundContent) { + pos = 0; + } + + marker.attrib = content.substr(pos); + content = content.substr(0, pos); + } + + if (content) { + marker[contentKey] = content; + } + } + + if (!content) { + delete marker[contentKey]; + } + } + + if (phraseParent) { + if (!USFM$1.markerContentDisplayable(phraseParent.tag)) { + phraseParent.content = (phraseParent.content || "") + markerToText(marker); + incrementPhraseNesting(state, phraseParent, tag); + return index; + } + } + + if (displayable) { + // we need to nest + pushObject(state, null, marker); + + if (state.phrase === null) { + state.phrase = []; // create new phrase stack + + state.phraseParent = marker; + } + + state.phrase.push([]); // push new empty list onto phrase stack + + marker.children = getLastPhrase(state); // point to top of phrase stack + } else { + saveUsfmObject(state, marker); + + if (state.phrase === null) { + state.phraseParent = getLastItem(state); + } + + incrementPhraseNesting(state, marker, tag); + } + + return index; +}; +/** + * get parent of current phrase + * @param {object} state - holds parsing state information + * @return {Object} parent + */ + + +var getPhraseParent = function getPhraseParent(state) { + var parent = null; + + if (state.phrase !== null && state.phrase.length > 1) { + parent = state.phrase[state.phrase.length - 2]; + } + + if (parent) { + if (parent.length > 0) { + parent = parent[parent.length - 1]; // get last in array + } else { + parent = null; + } + } + + if (!parent) { + parent = state.phraseParent; + } + + return parent; +}; +/** + * pop and return last phrase + * @param {object} state - holds parsing state information + * @return {object} last phrase + */ + + +var popPhrase = function popPhrase(state) { + var last = null; + + if (state.phrase && state.phrase.length > 0) { + state.phrase.pop(); // remove last phrases + + if (state.phrase.length <= 0) { + state.phrase = null; // stop adding to phrases + + last = state.phraseParent; + state.phraseParent = null; + } else { + last = getPhraseParent(state); + } + } else { + state.phraseParent = null; + } + + return last; +}; +/** + * end a spanned usfm + * @param {object} state - holds parsing state information + * @param {number} index - current position in markers + * @param {array} markers - parsed markers we are iterating through + * @param {string} endMarker - end marker for phrase + * @param {boolean} header - if true then saving to header + * @return {number} new index + */ + + +var endSpan = function endSpan(state, index, markers, endMarker) { + var header = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; + var current = markers[index]; + var content = current.content; + var phraseParent = getPhraseParent(state); + var phraseParentProps = phraseParent && USFM$1.USFM_PROPERTIES[phraseParent.tag] || null; + var parentContentDisplayable = USFM$1.propDisplayable(phraseParentProps); + + if (endMarker && USFM$1.propUsfm3Milestone(phraseParentProps)) { + endMarker += "\\*"; + } + + if (!phraseParent || parentContentDisplayable) { + popPhrase(state); + + if (phraseParent && endMarker) { + if (phraseParent.children !== undefined && !phraseParent.children.length) { + delete phraseParent.children; // remove unneeded empty children + } + + while (phraseParent) { + var tagBase = phraseParent.tag.split('-')[0]; + + if (tagBase + '*' === endMarker || tagBase + '-e\\*' === endMarker) { + // if this is the parent end + phraseParent.endTag = endMarker; + break; + } else { + phraseParent.endTag = ""; + phraseParent = getPhraseParent(state); // pop next + + popPhrase(state); + } + } + } + } + + var checkNext = USFM$1.markerStandalone(current.tag); + var trimLength = 0; + + if (content) { + var next = content[0]; + + if (['\\', '-', '*'].includes(next)) { + if (next === "*") { + // check if content is part of milestone end + trimLength = 1; + } else if (content.substr(0, 2) === "\\*") { + // check if content is part of milestone end + trimLength = 2; + } else if (content.substr(0, 4) === "-e\\*") { + // check if content marker is part of milestone end + trimLength = 4; + } else if (content.substr(0, 3) === "-e*") { + // check if content marker is part of milestone end + trimLength = 3; + } else if (content === "-e") { + // check if content + next marker is part of milestone end + trimLength = 2; + checkNext = true; + } + + if (trimLength) { + if (content.substr(trimLength, 1) === '\n') { + trimLength++; + } + + content = content.substr(trimLength); // remove phrase end marker + } + } + } + + if (content && USFM$1.markerHasEndAttributes(current.tag)) { + if (phraseParent) { + var parts = (phraseParent.endTag || "").split('\\*'); + endMarker = parts[0] + content + (parts.length > 1 ? '\\*' : ''); + phraseParent.endTag = endMarker; + current.content = content = ""; + } else { + current.attrib = content; + current.content = content = ""; + } + } + + var terminator = null; + + if (checkNext || !content && !current.nextChar && endMarker) { + trimLength = 0; + + if (index + 1 < markers.length) { + var nextItem = markers[index + 1]; + + if (!nextItem.tag) { + var nextContent = nextItem.content || ''; + + if (nextContent.substr(0, 1) === "*") { + // check if content is part of milestone end + trimLength = 1; + } else if (nextContent.substr(0, 2) === "\\*") { + // check if content is part of milestone end + trimLength = 2; + } + + terminator = nextContent.substr(0, trimLength); + + if (current.attrib) { + if (terminator.substr(0, 1) === '\\') { + terminator = terminator.substr(1); + } + + current.endTag = terminator; + } else { + if (!endMarker.includes(terminator)) { + endMarker += terminator; + } + + current.tag = endMarker; + } + + var nextChar = nextContent.substr(trimLength, 1); + + if (nextChar === ' ' || nextChar === '\n') { + if (!phraseParent) { + trimLength++; + current.nextChar = nextChar; + } + } + + if (trimLength) { + content = ''; + nextContent = nextContent.substr(trimLength); + nextItem.content = nextContent; + } + + if (!nextContent) { + index++; + } + } + } + } + + if (current && current.nextChar) { + if (content) { + content += current.nextChar; + delete current.nextChar; + } + } + + if (phraseParent) { + var endMarker_ = "\\" + endMarker; + + var _decrementPhraseNesti = decrementPhraseNesting(state, phraseParent, endMarker), + matchesParent = _decrementPhraseNesti.matchesParent, + count = _decrementPhraseNesti.count; + + var finishPhrase = matchesParent && count <= 0; + + if (!parentContentDisplayable) { + var _nextChar = current && current.nextChar || ''; + + if (content && _nextChar) { + content += _nextChar; + _nextChar = ''; + } + + _nextChar += current && current.endMarkerChar || ''; + + if (!finishPhrase) { + phraseParent.content = (phraseParent.content || "") + endMarker_ + _nextChar; + } else { + phraseParent.endTag = endMarker; + + if (_nextChar) { + phraseParent.nextChar = _nextChar; + } + + popPhrase(state); + } + } else if (finishPhrase) { + // parent displayable and this finishes + phraseParent.endTag = endMarker; + + var _nextChar2 = current && (current.nextChar || current.endMarkerChar); + + if (_nextChar2) { + if (parentContentDisplayable) { + content = _nextChar2 + (content || ""); + } else { + phraseParent.nextChar = _nextChar2; + } + } + } + } else { + // no parent, so will save end marker + content = current; + } + + if (content || !phraseParent) { + saveUsfmObject(state, createUsfmObject(content, header)); + } + + return index; +}; +/** + * @description - adds usfm object to current verse and handles nested USFM objects + * @param {object} state - holds parsing state information + * @param {object} marker - object that contains usfm marker + */ + + +var addToCurrentVerse = function addToCurrentVerse(state, marker) { + var tag = marker.tag; + + if (!tag) { + pushObject(state, null, createUsfmObject(marker)); + return; + } + + saveUsfmObject(state, createUsfmObject(marker)); +}; +/** + * makes sure that phrases are terminated before we begin a new verse or chapter + * @param {object} state - holds parsing state information + */ + + +var terminatePhrases = function terminatePhrases(state) { + var phraseParent = getPhraseParent(state); + + while (phraseParent) { + phraseParent.endTag = ''; + delete phraseParent.nesting; + delete phraseParent.usfm3Milestone; + phraseParent = popPhrase(state); + } +}; +/** + * @description - process marker as a verse + * @param {object} state - holds parsing state information + * @param {object} marker - marker object containing content + */ + + +var parseAsVerse = function parseAsVerse(state, marker) { + state.inHeader = false; + terminatePhrases(state); + state.nested = []; + marker.content = marker.content || ""; + + if (marker.nextChar === "\n") { + marker.content += marker.nextChar; + } + + state.currentVerse = stripLeadingZeros(marker.number); // check for verse span + + var spanMatch = VERSE_SPAN_REGEX.exec(marker.content); + + if (spanMatch) { + state.currentVerse += spanMatch[0][0] + stripLeadingZeros(spanMatch[0].substr(1).trim()); + marker.content = marker.content.substr(spanMatch[0].length); + } + + if (state.params.chunk && !state.onSameChapter) { + if (state.verses[state.currentVerse]) { + state.onSameChapter = true; + } else { + state.verses[state.currentVerse] = []; + pushObject(state, null, marker.content); + } + } else if (state.chapters[state.currentChapter] && !state.onSameChapter) { + // if the current chapter exists, not on same chapter, and there is content to store + if (state.chapters[state.currentChapter][state.currentVerse]) { + // If the verse already exists, then we are flagging as 'on the same chapter' + state.onSameChapter = true; + } else { + pushObject(state, null, marker.content); + } + } +}; +/** + * @description - process marker as text + * @param {object} state - holds parsing state information + * @param {object} marker - marker object containing content + */ + + +var processAsText = function processAsText(state, marker) { + if (state.currentChapter > 0 && marker.content) { + if (getPhraseParent(state)) { + saveUsfmObject(state, marker.content); + } else { + addToCurrentVerse(state, marker.content); + } + } else if (state.currentChapter === 0 && !state.currentVerse) { + // if we haven't seen chapter yet, its a header + pushObject(state, state.headers, createUsfmObject(marker)); + } + + if (state.params.chunk && state.currentVerse > 0 && marker.content) { + if (!state.verses[state.currentVerse]) { + state.verses[state.currentVerse] = []; + } + + if (getPhraseParent(state)) { + saveUsfmObject(state, marker.content); + } else { + pushObject(state, state.verses[state.currentVerse], marker.content); + } + } +}; + +var addTextField = function addTextField(text) { + var results = ""; + + if (text) { + results = ' ' + text; + } + + return results; +}; +/** + * @description - convert marker to text + * @param {object} marker - object to convert to text + * @param {boolean} noSpaceAfterTag - if true then don't add space after tag + * @return {string} text representation of marker + */ + + +var markerToText = function markerToText(marker) { + var noSpaceAfterTag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + if (!marker.tag) { + return marker.text || marker.content; + } + + var text = '\\' + marker.tag; + + if (marker.number) { + text += " " + marker.number; + } + + var content = marker.content || marker.text; + + if (noSpaceAfterTag) { + text += content; + } else { + text += addTextField(content); + } + + if (marker.attrib) { + var dashPos = marker.tag.indexOf('-'); + var suffix = dashPos > 0 ? marker.tag.substr(dashPos + 1, 1) : ''; + var spannedTag = ['s', 'e'].includes(suffix); + + if (!content && (!suffix || !spannedTag)) { + text += ' '; + } + + text += marker.attrib; + + if (spannedTag) { + text += '\\'; + } + } + + if (marker.nextChar) { + text += marker.nextChar; + } + + return text; +}; +/** + * @description - process marker as a chapter + * @param {object} state - holds parsing state information + * @param {object} marker - marker object containing content + */ + + +var processAsChapter = function processAsChapter(state, marker) { + state.inHeader = false; + terminatePhrases(state); + state.nested = []; + state.currentChapter = stripLeadingZeros(marker.number); + state.chapters[state.currentChapter] = {}; // resetting 'on same chapter' flag + + state.onSameChapter = false; + state.currentVerse = 0; +}; +/** + * @description - see if verse number in content + * @param {object} marker - marker object containing content + */ + + +var extractNumberFromContent = function extractNumberFromContent(marker) { + var numberMatch = NUMBER.exec(marker.content); + + if (numberMatch) { + marker.number = numberMatch[0]; + marker.content = marker.content.substr(numberMatch.length); + } +}; + +var getVerseObjectsForChapter = function getVerseObjectsForChapter(currentChapter) { + var outputChapter = {}; + + for (var _i = 0, _Object$keys = Object.keys(currentChapter); _i < _Object$keys.length; _i++) { + var verseNum = _Object$keys[_i]; + var verseObjects = currentChapter[verseNum]; + outputChapter[verseNum] = { + verseObjects: verseObjects + }; + } + + return outputChapter; +}; + +var getVerseObjectsForBook = function getVerseObjectsForBook(usfmJSON, state) { + usfmJSON.chapters = {}; + + for (var _i2 = 0, _Object$keys2 = Object.keys(state.chapters); _i2 < _Object$keys2.length; _i2++) { + var chapterNum = _Object$keys2[_i2]; + var currentChapter = state.chapters[chapterNum]; + usfmJSON.chapters[chapterNum] = getVerseObjectsForChapter(currentChapter); + } +}; +/** + * add marker to header + * @param {object} state - holds parsing state information + * @param {object} marker - marker object containing content + */ + + +var addHeaderMarker = function addHeaderMarker(state, marker) { + var nextChar = marker.nextChar; // save nextChar + + var usfmObject = createUsfmObject(marker, true); + + if (nextChar !== undefined) { + usfmObject.nextChar = nextChar; // add back in + } + + var lastHeader = state.headers.length ? state.headers[state.headers.length - 1] : null; + var lastNext = lastHeader ? lastHeader.nextChar : null; + var appendToLast = lastHeader && lastNext !== '\n'; + + if (appendToLast) { + var markerContent = marker.content || marker.text || ''; + var noSpaceAfterTag = markerContent.substr(0, 1) === '*'; // special handling for end tags + + var key = lastHeader.text ? 'text' : 'content'; + var content = (lastHeader[key] || '') + (lastHeader.next || '') + markerToText(marker, noSpaceAfterTag); + delete lastHeader.next; + + if (content.substr(-1) === '\n') { + lastHeader.nextChar = '\n'; + content = content.substr(0, content.length - 1); // trim off + } + + lastHeader[key] = content; + } else { + if (usfmObject.text && !usfmObject.nextChar && usfmObject.text.substr(-1) === '\n') { + usfmObject.nextChar = '\n'; + usfmObject.text = usfmObject.text.substr(0, usfmObject.text.length - 1); // trim off + } + + state.headers.push(usfmObject); + } +}; +/** + * processes the marker checking for spans + * @param {object} state - holds parsing state information + * @param {object} marker - marker object containing content + * @param {Number} i - current index in markers + * @param {Array} markers - array of parsed markers + * @return {Number} new index in markers + */ + + +var processMarkerForSpans = function processMarkerForSpans(state, marker, i, markers) { + var _checkForEndMarker = checkForEndMarker(marker), + endMarker = _checkForEndMarker.endMarker, + spannedUsfm = _checkForEndMarker.spannedUsfm; + + if (!endMarker && USFM$1.markerHasSpecialEndTag(marker.tag)) { + // check for one-off end markers + var startMarker = USFM$1.markerHasSpecialEndTag(marker.tag); + endMarker = marker.tag; + marker.tag = startMarker; + spannedUsfm = true; + } + + if (endMarker) { + // check for end marker + if (spannedUsfm) { + i = endSpan(state, i, markers, endMarker, state.inHeader); + } + } else if (spannedUsfm) { + i = startSpan(state, createUsfmObject(marker), marker.tag, i, markers); + } else { + addToCurrentVerse(state, marker); + } + + return i; +}; +/** + * clean of trailing newlines in headers since it is implicit + * @param {object} state - holds parsing state information + */ + + +var cleanupHeaderNewLines = function cleanupHeaderNewLines(state) { + for (var i = 0; i < state.headers.length; i++) { + var header = state.headers[i]; + + if (header.type === 'text') { + header.text += header.nextChar || ''; + + while (i + 1 < state.headers.length) { + var headerNext = i + 1 < state.headers.length ? state.headers[i + 1] : {}; + + if (headerNext.type === 'text') { + header.text += headerNext.text + (headerNext.nextChar || ''); + state.headers.splice(i + 1, 1); + } else { + break; + } + } + + if (header.text.substr(-1) === '\n') { + header.text = header.text.substr(0, header.text.length - 1); + } + } + + if (header && header.nextChar === '\n') { + delete header.nextChar; + } + } +}; +/** + * process this as a general marker + * @param {object} state - holds parsing state information + * @param {Object} marker - current marker + * @param {Number} index - current marker index + * @param {Array} markers - array of all markers + * @return {Number} updated index + */ + + +var processMarker = function processMarker(state, marker, index, markers) { + if (state.currentChapter === 0 && !state.currentVerse) { + // if we haven't seen chapter or verse yet, its a header + state.inHeader = true; + addHeaderMarker(state, marker); + } else if (state.currentChapter || state.params.chunk && state.currentVerse) { + index = processMarkerForSpans(state, marker, index, markers); + } + + return index; +}; +/** + * find the Alignment Format level in content + * @param {String} usfm - the raw usfm string + * @param {object} state - holds parsing state information + */ + + +var getAlignmentFormat = function getAlignmentFormat(usfm, state) { + var newAlignFormat = false; + var alignmentRegex = /\\zaln-s([^\\]*)(\\[\\*]?)?/; + var match = alignmentRegex.exec(usfm); + + if (!match) { + // if no alignment markers, check for tWords markers + var tWordsRegex = /\\k-s([^\\]*)(\\[\\*]?)?/; + match = tWordsRegex.exec(usfm); + } + + if (match && match[2]) { + newAlignFormat = match[2] === "\\*"; + } + + state.newAlignFormat = newAlignFormat; +}; +/** + * check if first character is BOM, and if so then remove it + * @param {string} text + * @return {string} + */ + + +usfmToJson.getAlignmentFormat = getAlignmentFormat; + +function removeBOM(text) { + var firstChar = text[0]; + var BOM = "\uFEFF"; + var BOM2 = "\uFFFE"; + + if (firstChar === BOM || firstChar === BOM2) { + text = text.substr(1); + } + + return text; +} +/** + * @description - Parses the usfm string and returns an object + * @param {String} usfm - the raw usfm string + * @param {Object} params - extra params to use for chunk parsing. Properties: + * chunk {boolean} - if true then output is just a small piece of book + * content-source {String} - content source attribute to add to word imports + * convertToInt {Array} - attributes to convert to integer + * @return {Object} - json object that holds the parsed usfm data, headers and chapters +*/ + + +var usfmToJSON = function usfmToJSON(usfm) { + var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + usfm = removeBOM(usfm); + var lines = usfm.split(/\r?\n/); // get all the lines + + var usfmJSON = {}; + var markers = []; + var lastLine = lines.length - 1; + + for (var l = 0; l < lines.length; l++) { + var parsedLine = parseLine(lines[l], l >= lastLine); + markers.push.apply(markers, parsedLine); // fast concat + } + + var state = { + currentChapter: 0, + currentVerse: 0, + chapters: {}, + verses: {}, + headers: [], + nested: [], + phrase: null, + phraseParent: null, + onSameChapter: false, + inHeader: true, + newAlignFormat: false, + params: params + }; + getAlignmentFormat(usfm, state); + + for (var i = 0; i < markers.length; i++) { + var marker = markers[i]; + + switch (marker.tag) { + case 'c': + { + // chapter + if (!marker.number && marker.content) { + // if no number, try to find in content + extractNumberFromContent(marker); + } + + if (marker.number) { + processAsChapter(state, marker); + } else { + // no chapter number, add as text + marker.content = markerToText(marker); + processAsText(state, marker); + } + + break; + } + + case 'v': + { + // verse + if (!marker.number && marker.content) { + // if no number, try to find in content + extractNumberFromContent(marker); + } + + if (marker.number) { + parseAsVerse(state, marker); + } else { + // no verse number, add as text + marker.content = markerToText(marker); + processAsText(state, marker); + } + + break; + } + + case 'k': + case 'zaln': + { + // phrase + if (state.inHeader) { + addHeaderMarker(state, marker); + } else { + var phrase = parseWord(state, marker.content); // very similar to word marker, so start with this and modify + + phrase.type = "milestone"; + var milestone = phrase.text.trim(); + + if (milestone === '-s') { + // milestone start + removeLastNewLine(state, marker.tag); + delete phrase.text; + i = startSpan(state, phrase, marker.tag, i, markers); + } else if (milestone === '-e') { + // milestone end + removeLastNewLine(state, marker.tag, true); + i = endSpan(state, i, markers, marker.tag + "-e\\*"); + } else { + i = processMarkerForSpans(state, marker, i, markers); // process as regular marker + } + } + + break; + } + + case 'w': + { + // word + if (state.inHeader) { + addHeaderMarker(state, marker); + } else { + handleWordWhiteSpace(state); + var wordObject = parseWord(state, marker.content, USFM$1.wordSpecialAttributes); + + if (isNonDisplayablePhraseParent(state)) { + saveUsfmObject(state, marker); + } else { + pushObject(state, null, wordObject); + + if (marker.nextChar) { + pushObject(state, null, marker.nextChar); + } + } + } + + break; + } + + case 'w*': + { + if (state.inHeader) { + addHeaderMarker(state, marker); + } else { + if (isNonDisplayablePhraseParent(state)) { + saveUsfmObject(state, marker); + } else if (marker.nextChar && marker.nextChar !== ' ') { + pushObject(state, null, marker.nextChar); + } else if (marker.nextChar) { + // next char is space + var nextMarker = markers[i + 1]; + + if (nextMarker && !nextMarker.tag && nextMarker.content && nextMarker.content[0] !== ' ') { + // see if space is not part of following text block + pushObject(state, null, marker.nextChar); + } + } + } + + break; + } + + case undefined: + { + // likely orphaned text for the preceding verse marker + if (marker) { + if (state.inHeader) { + addHeaderMarker(state, marker); + } else if (marker.content && marker.content.substr(0, 2) === "\\*") { + // is part of usfm3 milestone marker + marker.content = marker.content.substr(2); + } else if (marker.content && marker.content.substr(0, 1) === "*") { + var phraseParent = getPhraseParent(state); + + if (phraseParent && (phraseParent.usfm3Milestone || isAlignmentMarker(phraseParent))) { + // is part of usfm3 milestone marker + marker.content = marker.content.substr(1); + } + } + + if (marker.content) { + processAsText(state, marker); + } + } + + break; + } + + default: + { + var tag0 = marker.tag ? marker.tag.substr(0, 1) : ""; + + if (tag0 === 'v' || tag0 === 'c') { + // check for mangled verses and chapters + var number = marker.tag.substr(1); + var isInt = /^\+?\d+$/.test(number); + + if (isInt) { + // separate number from tag + marker.tag = tag0; + + if (marker.number) { + marker.content = marker.number + (marker.content ? " " + marker.content : ""); + } + + marker.number = number; + + if (tag0 === 'v') { + parseAsVerse(state, marker); + marker = null; + } else if (tag0 === 'c') { + processAsChapter(state, marker); + marker = null; + } + } else if (marker.tag.length === 1) { + // convert line to text + marker.content = markerToText(marker); + processAsText(state, marker); + marker = null; + } + } + + if (marker) { + // if not yet processed + i = processMarker(state, marker, i, markers); + } + } + } + } + + terminatePhrases(state); + cleanupHeaderNewLines(state); + usfmJSON.headers = state.headers; + getVerseObjectsForBook(usfmJSON, state); + + if (Object.keys(state.verses).length > 0) { + usfmJSON.verses = getVerseObjectsForChapter(state.verses); + } + + return usfmJSON; +}; + +usfmToJson.usfmToJSON = usfmToJSON; + +var jsonToUsfm = {}; + +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +Object.defineProperty(jsonToUsfm, "__esModule", { + value: true +}); +jsonToUsfm.jsonToUSFM = void 0; + +var USFM = _interopRequireWildcard(USFM$2); + +var _usfmToJson$1 = usfmToJson; + +function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } + +function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +var params_ = {}; +var wordMap_ = {}; +var wordIgnore_ = []; +var milestoneMap_ = {}; +var milestoneIgnore_ = []; +/** + * @description checks if we need to add a newline if next object is not text or newline + * @param {Object} nextObject - next object to be output + * @return {String} either newline or empty string + */ + +var needsNewLine = function needsNewLine(nextObject) { + var retVal = ''; + + if (nextObject && nextObject.tag === 'zaln') { + retVal = '\n'; // prevent cramming of alignments together + } + + return retVal; +}; +/** + * @description test if last character was newline (or return) char + * @param {String} line - line to test + * @return {boolean} true if newline + */ + + +var isLastCharNewLine = function isLastCharNewLine(line) { + var lastChar = line ? line.substr(line.length - 1) : ''; + return lastChar === '\n'; +}; +/** + * @description Takes in word json and outputs it as USFM. + * @param {Object} wordObject - word in JSON + * @param {Object} nextObject - next object to be output + * @return {String} - word in USFM + */ + + +var generateWord = function generateWord(wordObject, nextObject) { + var keys = Object.keys(wordObject); + var attributes = []; + var word = wordObject.text; + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i]; + + if (!wordIgnore_.includes(key)) { + var value = wordObject[key]; + + if (wordMap_[key]) { + // see if we should convert this key + key = wordMap_[key]; + } + + var prefix = ''; + + if (USFM.wordSpecialAttributes.includes(key)) { + prefix = 'x-'; + } + + var attribute = prefix + key; + + if (value) { + // add value only if set + attribute += '="' + value + '"'; + } + + attributes.push(attribute); + } + } + + var attrOut = attributes.join(' '); + + if (attrOut) { + attrOut = '|' + attrOut.trimLeft(); + } + + var line = '\\w ' + word + attrOut + '\\w*'; + return line; +}; +/** + * @description Takes in word json and outputs it as USFM. + * @param {Object} phraseObject - word in JSON + * @param {Object} nextObject - next object to be output + * @return {String} - word in USFM + */ + + +var generatePhrase = function generatePhrase(phraseObject, nextObject) { + var tag = phraseObject.tag || 'zaln'; + var markerTermination = ''; + + if (typeof phraseObject.endTag === 'string') { + markerTermination = phraseObject.endTag; // new format takes precidence + + delete phraseObject.endTag; + } else { + markerTermination = tag + '-e\\*'; // fall back to old generation method + } + + var content = ''; + var milestoneType = phraseObject.type === 'milestone'; + + if (milestoneType) { + var keys = Object.keys(phraseObject); + var attributes = []; + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i]; + + if (!milestoneIgnore_.includes(key)) { + var value = phraseObject[key]; + + if (milestoneMap_[key]) { + // see if we should convert this key + key = milestoneMap_[key]; + } + + var prefix = 'x-'; + var attribute = prefix + key + '="' + value + '"'; + attributes.push(attribute); + } + } + + content = '-s |' + attributes.join(' ').trimLeft() + '\\*'; + } else { + var isUsfm3Milestone = USFM.markerIsMilestone(tag); + + if (isUsfm3Milestone) { + if (phraseObject.attrib) { + content = phraseObject.attrib; + } + + content += "\\*"; + } + + if (phraseObject.text) { + content += ' ' + phraseObject.text; + } + + if (phraseObject.content) { + content += ' ' + phraseObject.content; + } + } + + var line = '\\' + tag + content; + /* eslint-disable no-use-before-define */ + + line = objectToString(phraseObject.children, line); + /* eslint-enable no-use-before-define */ + + if (markerTermination) { + line += '\\' + markerTermination + (phraseObject.nextChar || needsNewLine(nextObject)); + } + + return line; +}; +/** + * @description convert usfm marker to string + * @param {object} usfmObject - usfm object to output + * @param {object} nextObject - usfm object that will come next + * @param {Boolean} noSpaceAfterTag - if true then do not put space after tag + * @param {Boolean} noTermination - if true then do not add missing termination + * @return {String} Text equivalent of marker. + */ + + +var usfmMarkerToString = function usfmMarkerToString(usfmObject) { + var nextObject = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + var noSpaceAfterTag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + var noTermination = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + var output = ""; + var content = usfmObject.text || usfmObject.content || ""; + var markerTermination = usfmObject.endTag; // new format takes precidence + + if (typeof markerTermination !== 'string' && USFM.markerTermination(usfmObject.tag) && !noTermination) { + markerTermination = usfmObject.tag + '*'; // fall back to old generation method + } + + if (usfmObject.tag) { + output = '\\' + usfmObject.tag; + + if (usfmObject.number) { + output += ' ' + usfmObject.number; + } + + var firstChar = content.substr(0, 1); + + if (noSpaceAfterTag) ; else if (usfmObject.attrib) { + if (content) { + output += ' ' + content; + } + + if (usfmObject.tag.substr(-2) === '\\*') { + // we need to apply attibute before \* + output = output.substr(0, output.length - 2) + usfmObject.attrib + output.substr(-2); + } else { + output += usfmObject.attrib; + } + + content = ''; + } else if (!markerTermination) { + if (firstChar !== '' && firstChar !== '\n' && content !== ' \n') { + // make sure some whitespace + output += ' '; + } else if (nextObject && usfmObject.tag && !content && // make sure some whitespace + !usfmObject.nextChar && !['w', 'k', 'zaln'].includes(nextObject.tag)) { + output += ' '; + } + } else if (firstChar !== ' ') { + // if marker termination, make sure we have space + output += ' '; + } + } + + if (content) { + output += content; + } + + if (markerTermination) { + output += '\\' + markerTermination; + } + + if (usfmObject.nextChar) { + output += usfmObject.nextChar; + } + + return output; +}; +/** + * determines if we are currently on a displayable line + * @param {String} output - previous output + * @return {boolean} + */ + + +var isOnDisplayableLine = function isOnDisplayableLine(output) { + var isDisplayableLine = false; + var pos = output.lastIndexOf('\\'); + + if (pos >= 0) { + var endSegment = output.substr(pos + 1); + var parts = endSegment.split(' '); + + if (parts.length === 2 && parts[1] === '') { + isDisplayableLine = USFM.markerDisplayable(parts[0]); + } + } + + return isDisplayableLine; +}; +/** + * @description adds word to the line and makes sure it has appropriate spacing + * @param {String} text - to add + * @param {String} output - string to add to + * @return {String} updated output + */ + + +var addPhrase = function addPhrase(text, output) { + var prefixNewLine = false; + output = output || ""; + + if (text) { + prefixNewLine = false; + var lastChar = output ? output.substr(output.length - 1) : ''; + + if (params_.forcedNewLines) { + if (lastChar === ' ') { + if (!isOnDisplayableLine(output)) { + output = output.substr(0, output.length - 1); // trim space + + prefixNewLine = true; + } + } + } + + if (prefixNewLine) { + text = '\n' + text; + } + + output += text; + } + + return output; +}; +/** + * check if text contains a paragraph marker. Imprecise check just to save time before doing more extensive checking. + * @param {string} text + * @return {boolean} + */ + + +function hasParagraph(text) { + var hasParagraph_ = false; + + if (text.includes('\\')) { + // check if USFM markers in text + var paragraphStarts = ['\\p', '\\m', '\\c', '\\n', '\\b']; + + for (var _i = 0, _paragraphStarts = paragraphStarts; _i < _paragraphStarts.length; _i++) { + var mark = _paragraphStarts[_i]; + + // check for paragraph markers + if (text.includes(mark)) { + hasParagraph_ = true; + break; + } + } + } + + return hasParagraph_; +} +/** + * @description converts object to string and appends to line + * @param {string|array|object} object - marker to print + * @param {string} output - marker to print + * @param {String|array|object} nextObject - optional object that is next entry. Used to determine if we need to + * add a space between current marker and following text + * @return {String} Text equivalent of marker appended to output. + */ + + +var objectToString = function objectToString(object, output) { + var nextObject = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + + if (!object || !Object.keys(object).length) { + return output; // do not add to output + } + + output = output || ""; + + if (object.verseObjects) { + // support new verse object format + object = object.verseObjects; + } + + if (Array.isArray(object)) { + var _nextObject; + + for (var i = 0, len = object.length; i < len; i++) { + var objectN = _nextObject ? _nextObject : object[i]; + _nextObject = i + 1 < object.length ? object[i + 1] : null; + output = objectToString(objectN, output, _nextObject); + } + + return output; + } + + if (object.type === 'text') { + var text = object.text || ''; + + if (hasParagraph(text)) { + // TODO: convert to JSON and back for clean up + var verseObjects = (0, _usfmToJson$1.usfmToJSON)('\\v 1 ' + text, { + chunk: true + }); + var newText = jsonToUSFM(verseObjects).substr(5); // convert back to text and string out verse marker + + if (newText !== text) { + console.log("text updated to ".concat(newText)); + text = newText; + } + } + + return output + text; + } + + if (object.type === 'word') { + // usfm word marker + return addPhrase(generateWord(object), output); + } + + if (object.type === 'milestone' && object.endTag !== object.tag + '*') { + // milestone type (phrase) + return addPhrase(generatePhrase(object, nextObject), output); + } else if (object.children && object.children.length) { + return output + generatePhrase(object, nextObject); + } + + if (object.type === 'paragraph') { + var checkAhead = false; // if true need to check next object for leading text + // paragraphs have no whitespace before a newline + + if (object.text) { + if (object.text.endsWith('\n')) { + var _text = object.text.substr(0, object.text.length - 1); + + object.text = "".concat(_text.trimRight(), "\n"); + } else if (object.text.trim() === '') { + object.text = ''; + + if (object.nextChar === ' ') { + checkAhead = true; + } + } + } else if (object.nextChar === ' ') { + checkAhead = true; + } + + if (checkAhead) { + // if next is text object, trim leading spaces + if (nextObject) { + if (nextObject.type === 'text') { + var _text2 = (nextObject.text || '').trimLeft(); + + if (_text2) { + nextObject.text = _text2; + } else { + // remove text object that is empty + delete nextObject.text; + delete nextObject.type; + nextObject = null; + delete object.nextChar; + } + } + } else if (object.nextChar === ' ') { + // if end of verse, remove space after paragraph + delete object.nextChar; + } + } + } + + if (object.tag) { + // any other USFM marker tag + return output + usfmMarkerToString(object, nextObject); + } + + return output; +}; +/** + * @description Takes in verse json and outputs it as a USFM line array. + * @param {String} verseNumber - number to use for the verse + * @param {Array|Object} verseObjects - verse in JSON + * @return {String} - verse in USFM + */ + + +var generateVerse = function generateVerse(verseNumber, verseObjects) { + var verseText = objectToString(verseObjects); + var object = { + tag: 'v', + number: verseNumber, + text: verseText + }; + return usfmMarkerToString(object); +}; +/** + * @description adds verse to lines array, makes sure there is a newline before verse + * @param {Array} lines - array to add to + * @param {String} verse - line to add + * @return {Array} updated lines array + */ + + +var addVerse = function addVerse(lines, verse) { + if (params_.forcedNewLines && lines && lines.length) { + var lastLine = lines[lines.length - 1]; + + if (!isLastCharNewLine(lastLine)) { + // need to add newline + var quoted = lastLine.indexOf('\n\\q') >= 0; + + if (!quoted) { + // don't add newline before verse if quoted + verse = '\n' + verse; + } + } + } + + lines = lines.concat(verse); + return lines; +}; +/** + * @description adds chapter to lines array, makes sure there is a newline before chapters + * @param {Array} lines - array to add to + * @param {Array} chapter - chapter lines to add + * @return {Array} updated lines array + */ + + +var addChapter = function addChapter(lines, chapter) { + if (lines && lines.length) { + var lastLine = lines[lines.length - 1]; + + if (!isLastCharNewLine(lastLine)) { + // need to add newline + if (chapter && chapter.length) { + chapter[0] = '\n' + chapter[0]; // add newline to start of chapter + } + } + } + + lines = lines.concat(chapter); + return lines; +}; +/** + * get sorted list of verses. `front` will be first, the rest sorted alphabetically + * @param {Array} verses - to sort + * @return {string[]} sorted verses + */ + + +var sortVerses = function sortVerses(verses) { + var sortedVerses = verses.sort(function (a, b) { + var delta = parseInt(a, 10) - parseInt(b, 10); + + if (delta === 0) { + // handle verse spans, unspanned verse first + delta = a > b ? 1 : -1; + } + + return delta; + }); + return sortedVerses; +}; +/** + * get the last line and last character of that line + * @param {Array} lines + * @return {{lastLine: string, lastChar: string, position: number}} results + */ + + +function getLastLine(lines) { + var position = lines.length - 1; + var lastLine = lines.length ? lines[position] : ""; + var lastChar = lastLine ? lastLine.substr(lastLine.length - 1) : ""; + return { + lastLine: lastLine, + lastChar: lastChar, + position: position + }; +} +/** + * gets the last character of the last line and make sure it is a newline + * @param {Array} lines + */ + + +function makeSureEndsWithNewLine(lines) { + var _getLastLine = getLastLine(lines), + lastChar = _getLastLine.lastChar, + position = _getLastLine.position; + + if (lastChar && lastChar !== '\n') { + // make sure newline at end + lines[position] += '\n'; + } +} +/** + * make sure paragraphs without text start a new line + * @param {array} verseObjects + * @param {array} lines + */ + + +function makeSureParagraphsAtEndHaveLineFeeds(verseObjects, lines) { + if (verseObjects) { + if (verseObjects.length > 0) { + var lastPos = verseObjects.length - 1; // skip over empty objects + + while (lastPos > 0 && !Object.keys(verseObjects[lastPos]).length) { + lastPos--; + } + + var lastObject = verseObjects[lastPos]; + + if (lastObject && lastObject.type === 'paragraph' && !(lastObject.text && lastObject.text.trim())) { + makeSureEndsWithNewLine(lines); + } else if (lastObject.children) { + makeSureParagraphsAtEndHaveLineFeeds(lastObject.children, lines); + } + } + } +} +/** + * @description Takes in chapter json and outputs it as a USFM line array. + * @param {String} chapterNumber - number to use for the chapter + * @param {Object} chapterObject - chapter in JSON + * @return {Array} - chapter in USFM lines/string + */ + + +var generateChapterLines = function generateChapterLines(chapterNumber, chapterObject) { + var lines = []; + lines.push('\\c ' + chapterNumber + '\n'); + + if (chapterObject.front) { + // handle front matter first + var verseText = objectToString(chapterObject.front); + lines = lines.concat(verseText); + var frontVerseObjects = chapterObject.front; + makeSureParagraphsAtEndHaveLineFeeds(frontVerseObjects.verseObjects, lines); + delete chapterObject.front; + } + + var verseNumbers = sortVerses(Object.keys(chapterObject)); + var verseLen = verseNumbers.length; + + for (var i = 0; i < verseLen; i++) { + var verseNumber = verseNumbers[i]; // check if verse is inside previous line (such as \q) + + var _getLastLine2 = getLastLine(lines), + lastLine = _getLastLine2.lastLine, + lastChar = _getLastLine2.lastChar, + position = _getLastLine2.position; + + if (lastChar && lastChar !== '\n' && lastChar !== ' ') { + // do we need white space + lines[position] = lastLine + ' '; + } + + var verseObjects = chapterObject[verseNumber]; + var verseLine = generateVerse(verseNumber, verseObjects); + lines = addVerse(lines, verseLine); + makeSureParagraphsAtEndHaveLineFeeds(verseObjects.verseObjects, lines); + } + + return lines; +}; +/** + * @description convert object to text and add to array. Objects are terminated with newline + * @param {array} output - array where text is appended + * @param {Object} usfmObject - USFM object to convert to string + */ + + +var outputHeaderObject = function outputHeaderObject(output, usfmObject) { + var noSpace = false; + + if (usfmObject.content) { + var firstChar = usfmObject.content.substr(0, 1); + noSpace = ['-', '*'].includes(firstChar) || usfmObject.content.substr(0, 2) === '\\*'; + } + + var text = usfmMarkerToString(usfmObject, null, noSpace, true); + + if (usfmObject.type === 'text' && typeof usfmObject.text === 'string') { + text += '\n'; + } else if (usfmObject.tag) { + text += '\n'; + } + + output.push(text); +}; +/** + * @description Goes through parameters and populates ignore lists and parameter maps + * for words and milestones + */ + + +var processParams = function processParams() { + wordMap_ = params_.map ? params_.map : {}; + wordMap_.strongs = 'strong'; + wordIgnore_ = ['text', 'tag', 'type']; + + if (params_.ignore) { + wordIgnore_ = wordIgnore_.concat(params_.ignore); + } -JSZip uses the library pako released under the MIT license : -https://github.com/nodeca/pako/blob/main/LICENSE -*/(function(n,t){(function(e){n.exports=e()})(function(){return function e(r,s,i){function a(c,g){if(!s[c]){if(!r[c]){var f=typeof xe=="function"&&xe;if(!g&&f)return f(c,!0);if(o)return o(c,!0);var w=new Error("Cannot find module '"+c+"'");throw w.code="MODULE_NOT_FOUND",w}var p=s[c]={exports:{}};r[c][0].call(p.exports,function(y){var d=r[c][1][y];return a(d||y)},p,p.exports,e,r,s,i)}return s[c].exports}for(var o=typeof xe=="function"&&xe,l=0;l>2,p=(3&c)<<4|g>>4,y=1>6:64,d=2>4,g=(15&w)<<4|(p=o.indexOf(l.charAt(d++)))>>2,f=(3&p)<<6|(y=o.indexOf(l.charAt(d++))),S[v++]=c,p!==64&&(S[v++]=g),y!==64&&(S[v++]=f);return S}},{"./support":30,"./utils":32}],2:[function(e,r,s){var i=e("./external"),a=e("./stream/DataWorker"),o=e("./stream/Crc32Probe"),l=e("./stream/DataLengthProbe");function c(g,f,w,p,y){this.compressedSize=g,this.uncompressedSize=f,this.crc32=w,this.compression=p,this.compressedContent=y}c.prototype={getContentWorker:function(){var g=new a(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),f=this;return g.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),g},getCompressedWorker:function(){return new a(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(g,f,w){return g.pipe(new o).pipe(new l("uncompressedSize")).pipe(f.compressWorker(w)).pipe(new l("compressedSize")).withStreamInfo("compression",f)},r.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,r,s){var i=e("./stream/GenericWorker");s.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},s.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,r,s){var i=e("./utils"),a=function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var g=0;g<8;g++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l}();r.exports=function(o,l){return o!==void 0&&o.length?i.getTypeOf(o)!=="string"?function(c,g,f,w){var p=a,y=w+f;c^=-1;for(var d=w;d>>8^p[255&(c^g[d])];return-1^c}(0|l,o,o.length,0):function(c,g,f,w){var p=a,y=w+f;c^=-1;for(var d=w;d>>8^p[255&(c^g.charCodeAt(d))];return-1^c}(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(e,r,s){s.base64=!1,s.binary=!1,s.dir=!1,s.createFolders=!0,s.date=null,s.compression=null,s.compressionOptions=null,s.comment=null,s.unixPermissions=null,s.dosPermissions=null},{}],6:[function(e,r,s){var i=null;i=typeof Promise<"u"?Promise:e("lie"),r.exports={Promise:i}},{lie:37}],7:[function(e,r,s){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=e("pako"),o=e("./utils"),l=e("./stream/GenericWorker"),c=i?"uint8array":"array";function g(f,w){l.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=w,this.meta={}}s.magic="\b\0",o.inherits(g,l),g.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(c,f.data),!1)},g.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},g.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},g.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(w){f.push({data:w,meta:f.meta})}},s.compressWorker=function(f){return new g("Deflate",f)},s.uncompressWorker=function(){return new g("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,r,s){function i(p,y){var d,v="";for(d=0;d>>=8;return v}function a(p,y,d,v,m,S){var T,k,A=p.file,D=p.compression,B=S!==c.utf8encode,H=o.transformTo("string",S(A.name)),I=o.transformTo("string",c.utf8encode(A.name)),j=A.comment,rt=o.transformTo("string",S(j)),E=o.transformTo("string",c.utf8encode(j)),L=I.length!==A.name.length,h=E.length!==j.length,M="",it="",Z="",st=A.dir,G=A.date,Y={crc32:0,compressedSize:0,uncompressedSize:0};y&&!d||(Y.crc32=p.crc32,Y.compressedSize=p.compressedSize,Y.uncompressedSize=p.uncompressedSize);var F=0;y&&(F|=8),B||!L&&!h||(F|=2048);var z=0,tt=0;st&&(z|=16),m==="UNIX"?(tt=798,z|=function(K,pt){var vt=K;return K||(vt=pt?16893:33204),(65535&vt)<<16}(A.unixPermissions,st)):(tt=20,z|=function(K){return 63&(K||0)}(A.dosPermissions)),T=G.getUTCHours(),T<<=6,T|=G.getUTCMinutes(),T<<=5,T|=G.getUTCSeconds()/2,k=G.getUTCFullYear()-1980,k<<=4,k|=G.getUTCMonth()+1,k<<=5,k|=G.getUTCDate(),L&&(it=i(1,1)+i(g(H),4)+I,M+="up"+i(it.length,2)+it),h&&(Z=i(1,1)+i(g(rt),4)+E,M+="uc"+i(Z.length,2)+Z);var Q="";return Q+=` -\0`,Q+=i(F,2),Q+=D.magic,Q+=i(T,2),Q+=i(k,2),Q+=i(Y.crc32,4),Q+=i(Y.compressedSize,4),Q+=i(Y.uncompressedSize,4),Q+=i(H.length,2),Q+=i(M.length,2),{fileRecord:f.LOCAL_FILE_HEADER+Q+H+M,dirRecord:f.CENTRAL_FILE_HEADER+i(tt,2)+Q+i(rt.length,2)+"\0\0\0\0"+i(z,4)+i(v,4)+H+M+rt}}var o=e("../utils"),l=e("../stream/GenericWorker"),c=e("../utf8"),g=e("../crc32"),f=e("../signature");function w(p,y,d,v){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=y,this.zipPlatform=d,this.encodeFileName=v,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(w,l),w.prototype.push=function(p){var y=p.meta.percent||0,d=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,l.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:d?(y+100*(d-v-1))/d:100}}))},w.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var y=this.streamFiles&&!p.file.dir;if(y){var d=a(p,y,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:d.fileRecord,meta:{percent:0}})}else this.accumulate=!0},w.prototype.closedSource=function(p){this.accumulate=!1;var y=this.streamFiles&&!p.file.dir,d=a(p,y,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(d.dirRecord),y)this.push({data:function(v){return f.DATA_DESCRIPTOR+i(v.crc32,4)+i(v.compressedSize,4)+i(v.uncompressedSize,4)}(p),meta:{percent:100}});else for(this.push({data:d.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},w.prototype.flush=function(){for(var p=this.bytesWritten,y=0;y=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=o,c},readString:function(o){return i.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},r.exports=a},{"../utils":32}],19:[function(e,r,s){var i=e("./Uint8ArrayReader");function a(o){i.call(this,o)}e("../utils").inherits(a,i),a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,r,s){var i=e("./DataReader");function a(o){i.call(this,o)}e("../utils").inherits(a,i),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=a},{"../utils":32,"./DataReader":18}],21:[function(e,r,s){var i=e("./ArrayReader");function a(o){i.call(this,o)}e("../utils").inherits(a,i),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(e,r,s){var i=e("../utils"),a=e("../support"),o=e("./ArrayReader"),l=e("./StringReader"),c=e("./NodeBufferReader"),g=e("./Uint8ArrayReader");r.exports=function(f){var w=i.getTypeOf(f);return i.checkSupport(w),w!=="string"||a.uint8array?w==="nodebuffer"?new c(f):a.uint8array?new g(i.transformTo("uint8array",f)):new o(i.transformTo("array",f)):new l(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,r,s){s.LOCAL_FILE_HEADER="PK",s.CENTRAL_FILE_HEADER="PK",s.CENTRAL_DIRECTORY_END="PK",s.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",s.ZIP64_CENTRAL_DIRECTORY_END="PK",s.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,r,s){var i=e("./GenericWorker"),a=e("../utils");function o(l){i.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,i),o.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},r.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,r,s){var i=e("./GenericWorker"),a=e("../crc32");function o(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,i),o.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,r,s){var i=e("../utils"),a=e("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}i.inherits(o,a),o.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}a.prototype.processChunk.call(this,l)},r.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,r,s){var i=e("../utils"),a=e("./GenericWorker");function o(l){a.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(g){c.dataIsReady=!0,c.data=g,c.max=g&&g.length||0,c.type=i.getTypeOf(g),c.isPaused||c._tickAndRepeat()},function(g){c.error(g)})}i.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,r,s){function i(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var l=0;l "+a:a}},r.exports=i},{}],29:[function(e,r,s){var i=e("../utils"),a=e("./ConvertWorker"),o=e("./GenericWorker"),l=e("../base64"),c=e("../support"),g=e("../external"),f=null;if(c.nodestream)try{f=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function w(y,d){return new g.Promise(function(v,m){var S=[],T=y._internalType,k=y._outputType,A=y._mimeType;y.on("data",function(D,B){S.push(D),d&&d(B)}).on("error",function(D){S=[],m(D)}).on("end",function(){try{var D=function(B,H,I){switch(B){case"blob":return i.newBlob(i.transformTo("arraybuffer",H),I);case"base64":return l.encode(H);default:return i.transformTo(B,H)}}(k,function(B,H){var I,j=0,rt=null,E=0;for(I=0;I"u")s.blob=!1;else{var i=new ArrayBuffer(0);try{s.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(i),s.blob=a.getBlob("application/zip").size===0}catch{s.blob=!1}}}try{s.nodestream=!!e("readable-stream").Readable}catch{s.nodestream=!1}},{"readable-stream":16}],31:[function(e,r,s){for(var i=e("./utils"),a=e("./support"),o=e("./nodejsUtils"),l=e("./stream/GenericWorker"),c=new Array(256),g=0;g<256;g++)c[g]=252<=g?6:248<=g?5:240<=g?4:224<=g?3:192<=g?2:1;c[254]=c[254]=1;function f(){l.call(this,"utf-8 decode"),this.leftOver=null}function w(){l.call(this,"utf-8 encode")}s.utf8encode=function(p){return a.nodebuffer?o.newBufferFrom(p,"utf-8"):function(y){var d,v,m,S,T,k=y.length,A=0;for(S=0;S>>6:(v<65536?d[T++]=224|v>>>12:(d[T++]=240|v>>>18,d[T++]=128|v>>>12&63),d[T++]=128|v>>>6&63),d[T++]=128|63&v);return d}(p)},s.utf8decode=function(p){return a.nodebuffer?i.transformTo("nodebuffer",p).toString("utf-8"):function(y){var d,v,m,S,T=y.length,k=new Array(2*T);for(d=v=0;d>10&1023,k[v++]=56320|1023&m)}return k.length!==v&&(k.subarray?k=k.subarray(0,v):k.length=v),i.applyFromCharCode(k)}(p=i.transformTo(a.uint8array?"uint8array":"array",p))},i.inherits(f,l),f.prototype.processChunk=function(p){var y=i.transformTo(a.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var d=y;(y=new Uint8Array(d.length+this.leftOver.length)).set(this.leftOver,0),y.set(d,this.leftOver.length)}else y=this.leftOver.concat(y);this.leftOver=null}var v=function(S,T){var k;for((T=T||S.length)>S.length&&(T=S.length),k=T-1;0<=k&&(192&S[k])==128;)k--;return k<0||k===0?T:k+c[S[k]]>T?k:T}(y),m=y;v!==y.length&&(a.uint8array?(m=y.subarray(0,v),this.leftOver=y.subarray(v,y.length)):(m=y.slice(0,v),this.leftOver=y.slice(v,y.length))),this.push({data:s.utf8decode(m),meta:p.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=f,i.inherits(w,l),w.prototype.processChunk=function(p){this.push({data:s.utf8encode(p.data),meta:p.meta})},s.Utf8EncodeWorker=w},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,r,s){var i=e("./support"),a=e("./base64"),o=e("./nodejsUtils"),l=e("./external");function c(d){return d}function g(d,v){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=i(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var y,d,v,m=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4>>6:(p<65536?w[v++]=224|p>>>12:(w[v++]=240|p>>>18,w[v++]=128|p>>>12&63),w[v++]=128|p>>>6&63),w[v++]=128|63&p);return w},s.buf2binstring=function(f){return g(f,f.length)},s.binstring2buf=function(f){for(var w=new i.Buf8(f.length),p=0,y=w.length;p>10&1023,S[y++]=56320|1023&d)}return g(S,y)},s.utf8border=function(f,w){var p;for((w=w||f.length)>f.length&&(w=f.length),p=w-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?w:p+l[f[p]]>w?p:w}},{"./common":41}],43:[function(e,r,s){r.exports=function(i,a,o,l){for(var c=65535&i|0,g=i>>>16&65535|0,f=0;o!==0;){for(o-=f=2e3>>1:a>>>1;o[l]=a}return o}();r.exports=function(a,o,l,c){var g=i,f=c+l;a^=-1;for(var w=c;w>>8^g[255&(a^o[w])];return-1^a}},{}],46:[function(e,r,s){var i,a=e("../utils/common"),o=e("./trees"),l=e("./adler32"),c=e("./crc32"),g=e("./messages"),f=0,w=4,p=0,y=-2,d=-1,v=4,m=2,S=8,T=9,k=286,A=30,D=19,B=2*k+1,H=15,I=3,j=258,rt=j+I+1,E=42,L=113,h=1,M=2,it=3,Z=4;function st(u,U){return u.msg=g[U],U}function G(u){return(u<<1)-(4u.avail_out&&(P=u.avail_out),P!==0&&(a.arraySet(u.output,U.pending_buf,U.pending_out,P,u.next_out),u.next_out+=P,U.pending_out+=P,u.total_out+=P,u.avail_out-=P,U.pending-=P,U.pending===0&&(U.pending_out=0))}function z(u,U){o._tr_flush_block(u,0<=u.block_start?u.block_start:-1,u.strstart-u.block_start,U),u.block_start=u.strstart,F(u.strm)}function tt(u,U){u.pending_buf[u.pending++]=U}function Q(u,U){u.pending_buf[u.pending++]=U>>>8&255,u.pending_buf[u.pending++]=255&U}function K(u,U){var P,x,b=u.max_chain_length,C=u.strstart,W=u.prev_length,V=u.nice_match,R=u.strstart>u.w_size-rt?u.strstart-(u.w_size-rt):0,$=u.window,X=u.w_mask,J=u.prev,nt=u.strstart+j,ct=$[C+W-1],ut=$[C+W];u.prev_length>=u.good_match&&(b>>=2),V>u.lookahead&&(V=u.lookahead);do if($[(P=U)+W]===ut&&$[P+W-1]===ct&&$[P]===$[C]&&$[++P]===$[C+1]){C+=2,P++;do;while($[++C]===$[++P]&&$[++C]===$[++P]&&$[++C]===$[++P]&&$[++C]===$[++P]&&$[++C]===$[++P]&&$[++C]===$[++P]&&$[++C]===$[++P]&&$[++C]===$[++P]&&CR&&--b!=0);return W<=u.lookahead?W:u.lookahead}function pt(u){var U,P,x,b,C,W,V,R,$,X,J=u.w_size;do{if(b=u.window_size-u.lookahead-u.strstart,u.strstart>=J+(J-rt)){for(a.arraySet(u.window,u.window,J,J,0),u.match_start-=J,u.strstart-=J,u.block_start-=J,U=P=u.hash_size;x=u.head[--U],u.head[U]=J<=x?x-J:0,--P;);for(U=P=J;x=u.prev[--U],u.prev[U]=J<=x?x-J:0,--P;);b+=J}if(u.strm.avail_in===0)break;if(W=u.strm,V=u.window,R=u.strstart+u.lookahead,$=b,X=void 0,X=W.avail_in,$=I)for(C=u.strstart-u.insert,u.ins_h=u.window[C],u.ins_h=(u.ins_h<=I&&(u.ins_h=(u.ins_h<=I)if(x=o._tr_tally(u,u.strstart-u.match_start,u.match_length-I),u.lookahead-=u.match_length,u.match_length<=u.max_lazy_match&&u.lookahead>=I){for(u.match_length--;u.strstart++,u.ins_h=(u.ins_h<=I&&(u.ins_h=(u.ins_h<=I&&u.match_length<=u.prev_length){for(b=u.strstart+u.lookahead-I,x=o._tr_tally(u,u.strstart-1-u.prev_match,u.prev_length-I),u.lookahead-=u.prev_length-1,u.prev_length-=2;++u.strstart<=b&&(u.ins_h=(u.ins_h<u.pending_buf_size-5&&(P=u.pending_buf_size-5);;){if(u.lookahead<=1){if(pt(u),u.lookahead===0&&U===f)return h;if(u.lookahead===0)break}u.strstart+=u.lookahead,u.lookahead=0;var x=u.block_start+P;if((u.strstart===0||u.strstart>=x)&&(u.lookahead=u.strstart-x,u.strstart=x,z(u,!1),u.strm.avail_out===0)||u.strstart-u.block_start>=u.w_size-rt&&(z(u,!1),u.strm.avail_out===0))return h}return u.insert=0,U===w?(z(u,!0),u.strm.avail_out===0?it:Z):(u.strstart>u.block_start&&(z(u,!1),u.strm.avail_out),h)}),new ft(4,4,8,4,vt),new ft(4,5,16,8,vt),new ft(4,6,32,32,vt),new ft(4,4,16,16,lt),new ft(8,16,32,32,lt),new ft(8,16,128,128,lt),new ft(8,32,128,256,lt),new ft(32,128,258,1024,lt),new ft(32,258,258,4096,lt)],s.deflateInit=function(u,U){return Tt(u,U,S,15,8,0)},s.deflateInit2=Tt,s.deflateReset=Ct,s.deflateResetKeep=ht,s.deflateSetHeader=function(u,U){return u&&u.state?u.state.wrap!==2?y:(u.state.gzhead=U,p):y},s.deflate=function(u,U){var P,x,b,C;if(!u||!u.state||5>8&255),tt(x,x.gzhead.time>>16&255),tt(x,x.gzhead.time>>24&255),tt(x,x.level===9?2:2<=x.strategy||x.level<2?4:0),tt(x,255&x.gzhead.os),x.gzhead.extra&&x.gzhead.extra.length&&(tt(x,255&x.gzhead.extra.length),tt(x,x.gzhead.extra.length>>8&255)),x.gzhead.hcrc&&(u.adler=c(u.adler,x.pending_buf,x.pending,0)),x.gzindex=0,x.status=69):(tt(x,0),tt(x,0),tt(x,0),tt(x,0),tt(x,0),tt(x,x.level===9?2:2<=x.strategy||x.level<2?4:0),tt(x,3),x.status=L);else{var W=S+(x.w_bits-8<<4)<<8;W|=(2<=x.strategy||x.level<2?0:x.level<6?1:x.level===6?2:3)<<6,x.strstart!==0&&(W|=32),W+=31-W%31,x.status=L,Q(x,W),x.strstart!==0&&(Q(x,u.adler>>>16),Q(x,65535&u.adler)),u.adler=1}if(x.status===69)if(x.gzhead.extra){for(b=x.pending;x.gzindex<(65535&x.gzhead.extra.length)&&(x.pending!==x.pending_buf_size||(x.gzhead.hcrc&&x.pending>b&&(u.adler=c(u.adler,x.pending_buf,x.pending-b,b)),F(u),b=x.pending,x.pending!==x.pending_buf_size));)tt(x,255&x.gzhead.extra[x.gzindex]),x.gzindex++;x.gzhead.hcrc&&x.pending>b&&(u.adler=c(u.adler,x.pending_buf,x.pending-b,b)),x.gzindex===x.gzhead.extra.length&&(x.gzindex=0,x.status=73)}else x.status=73;if(x.status===73)if(x.gzhead.name){b=x.pending;do{if(x.pending===x.pending_buf_size&&(x.gzhead.hcrc&&x.pending>b&&(u.adler=c(u.adler,x.pending_buf,x.pending-b,b)),F(u),b=x.pending,x.pending===x.pending_buf_size)){C=1;break}C=x.gzindexb&&(u.adler=c(u.adler,x.pending_buf,x.pending-b,b)),C===0&&(x.gzindex=0,x.status=91)}else x.status=91;if(x.status===91)if(x.gzhead.comment){b=x.pending;do{if(x.pending===x.pending_buf_size&&(x.gzhead.hcrc&&x.pending>b&&(u.adler=c(u.adler,x.pending_buf,x.pending-b,b)),F(u),b=x.pending,x.pending===x.pending_buf_size)){C=1;break}C=x.gzindexb&&(u.adler=c(u.adler,x.pending_buf,x.pending-b,b)),C===0&&(x.status=103)}else x.status=103;if(x.status===103&&(x.gzhead.hcrc?(x.pending+2>x.pending_buf_size&&F(u),x.pending+2<=x.pending_buf_size&&(tt(x,255&u.adler),tt(x,u.adler>>8&255),u.adler=0,x.status=L)):x.status=L),x.pending!==0){if(F(u),u.avail_out===0)return x.last_flush=-1,p}else if(u.avail_in===0&&G(U)<=G(P)&&U!==w)return st(u,-5);if(x.status===666&&u.avail_in!==0)return st(u,-5);if(u.avail_in!==0||x.lookahead!==0||U!==f&&x.status!==666){var V=x.strategy===2?function(R,$){for(var X;;){if(R.lookahead===0&&(pt(R),R.lookahead===0)){if($===f)return h;break}if(R.match_length=0,X=o._tr_tally(R,0,R.window[R.strstart]),R.lookahead--,R.strstart++,X&&(z(R,!1),R.strm.avail_out===0))return h}return R.insert=0,$===w?(z(R,!0),R.strm.avail_out===0?it:Z):R.last_lit&&(z(R,!1),R.strm.avail_out===0)?h:M}(x,U):x.strategy===3?function(R,$){for(var X,J,nt,ct,ut=R.window;;){if(R.lookahead<=j){if(pt(R),R.lookahead<=j&&$===f)return h;if(R.lookahead===0)break}if(R.match_length=0,R.lookahead>=I&&0R.lookahead&&(R.match_length=R.lookahead)}if(R.match_length>=I?(X=o._tr_tally(R,1,R.match_length-I),R.lookahead-=R.match_length,R.strstart+=R.match_length,R.match_length=0):(X=o._tr_tally(R,0,R.window[R.strstart]),R.lookahead--,R.strstart++),X&&(z(R,!1),R.strm.avail_out===0))return h}return R.insert=0,$===w?(z(R,!0),R.strm.avail_out===0?it:Z):R.last_lit&&(z(R,!1),R.strm.avail_out===0)?h:M}(x,U):i[x.level].func(x,U);if(V!==it&&V!==Z||(x.status=666),V===h||V===it)return u.avail_out===0&&(x.last_flush=-1),p;if(V===M&&(U===1?o._tr_align(x):U!==5&&(o._tr_stored_block(x,0,0,!1),U===3&&(Y(x.head),x.lookahead===0&&(x.strstart=0,x.block_start=0,x.insert=0))),F(u),u.avail_out===0))return x.last_flush=-1,p}return U!==w?p:x.wrap<=0?1:(x.wrap===2?(tt(x,255&u.adler),tt(x,u.adler>>8&255),tt(x,u.adler>>16&255),tt(x,u.adler>>24&255),tt(x,255&u.total_in),tt(x,u.total_in>>8&255),tt(x,u.total_in>>16&255),tt(x,u.total_in>>24&255)):(Q(x,u.adler>>>16),Q(x,65535&u.adler)),F(u),0=P.w_size&&(C===0&&(Y(P.head),P.strstart=0,P.block_start=0,P.insert=0),$=new a.Buf8(P.w_size),a.arraySet($,U,X-P.w_size,P.w_size,0),U=$,X=P.w_size),W=u.avail_in,V=u.next_in,R=u.input,u.avail_in=X,u.next_in=0,u.input=U,pt(P);P.lookahead>=I;){for(x=P.strstart,b=P.lookahead-(I-1);P.ins_h=(P.ins_h<>>=I=H>>>24,T-=I,(I=H>>>16&255)===0)M[g++]=65535&H;else{if(!(16&I)){if(!(64&I)){H=k[(65535&H)+(S&(1<>>=I,T-=I),T<15&&(S+=h[l++]<>>=I=H>>>24,T-=I,!(16&(I=H>>>16&255))){if(!(64&I)){H=A[(65535&H)+(S&(1<>>=I,T-=I,(I=g-f)>3,S&=(1<<(T-=j<<3))-1,i.next_in=l,i.next_out=g,i.avail_in=l>>24&255)+(E>>>8&65280)+((65280&E)<<8)+((255&E)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function T(E){var L;return E&&E.state?(L=E.state,E.total_in=E.total_out=L.total=0,E.msg="",L.wrap&&(E.adler=1&L.wrap),L.mode=y,L.last=0,L.havedict=0,L.dmax=32768,L.head=null,L.hold=0,L.bits=0,L.lencode=L.lendyn=new i.Buf32(d),L.distcode=L.distdyn=new i.Buf32(v),L.sane=1,L.back=-1,w):p}function k(E){var L;return E&&E.state?((L=E.state).wsize=0,L.whave=0,L.wnext=0,T(E)):p}function A(E,L){var h,M;return E&&E.state?(M=E.state,L<0?(h=0,L=-L):(h=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15=Z.wsize?(i.arraySet(Z.window,L,h-Z.wsize,Z.wsize,0),Z.wnext=0,Z.whave=Z.wsize):(M<(it=Z.wsize-Z.wnext)&&(it=M),i.arraySet(Z.window,L,h-M,it,Z.wnext),(M-=it)?(i.arraySet(Z.window,L,h-M,M,0),Z.wnext=M,Z.whave=Z.wsize):(Z.wnext+=it,Z.wnext===Z.wsize&&(Z.wnext=0),Z.whave>>8&255,h.check=o(h.check,C,2,0),z=F=0,h.mode=2;break}if(h.flags=0,h.head&&(h.head.done=!1),!(1&h.wrap)||(((255&F)<<8)+(F>>8))%31){E.msg="incorrect header check",h.mode=30;break}if((15&F)!=8){E.msg="unknown compression method",h.mode=30;break}if(z-=4,u=8+(15&(F>>>=4)),h.wbits===0)h.wbits=u;else if(u>h.wbits){E.msg="invalid window size",h.mode=30;break}h.dmax=1<>8&1),512&h.flags&&(C[0]=255&F,C[1]=F>>>8&255,h.check=o(h.check,C,2,0)),z=F=0,h.mode=3;case 3:for(;z<32;){if(G===0)break t;G--,F+=M[Z++]<>>8&255,C[2]=F>>>16&255,C[3]=F>>>24&255,h.check=o(h.check,C,4,0)),z=F=0,h.mode=4;case 4:for(;z<16;){if(G===0)break t;G--,F+=M[Z++]<>8),512&h.flags&&(C[0]=255&F,C[1]=F>>>8&255,h.check=o(h.check,C,2,0)),z=F=0,h.mode=5;case 5:if(1024&h.flags){for(;z<16;){if(G===0)break t;G--,F+=M[Z++]<>>8&255,h.check=o(h.check,C,2,0)),z=F=0}else h.head&&(h.head.extra=null);h.mode=6;case 6:if(1024&h.flags&&(G<(K=h.length)&&(K=G),K&&(h.head&&(u=h.head.extra_len-h.length,h.head.extra||(h.head.extra=new Array(h.head.extra_len)),i.arraySet(h.head.extra,M,Z,K,u)),512&h.flags&&(h.check=o(h.check,M,K,Z)),G-=K,Z+=K,h.length-=K),h.length))break t;h.length=0,h.mode=7;case 7:if(2048&h.flags){if(G===0)break t;for(K=0;u=M[Z+K++],h.head&&u&&h.length<65536&&(h.head.name+=String.fromCharCode(u)),u&&K>9&1,h.head.done=!0),E.adler=h.check=0,h.mode=12;break;case 10:for(;z<32;){if(G===0)break t;G--,F+=M[Z++]<>>=7&z,z-=7&z,h.mode=27;break}for(;z<3;){if(G===0)break t;G--,F+=M[Z++]<>>=1)){case 0:h.mode=14;break;case 1:if(j(h),h.mode=20,L!==6)break;F>>>=2,z-=2;break t;case 2:h.mode=17;break;case 3:E.msg="invalid block type",h.mode=30}F>>>=2,z-=2;break;case 14:for(F>>>=7&z,z-=7&z;z<32;){if(G===0)break t;G--,F+=M[Z++]<>>16^65535)){E.msg="invalid stored block lengths",h.mode=30;break}if(h.length=65535&F,z=F=0,h.mode=15,L===6)break t;case 15:h.mode=16;case 16:if(K=h.length){if(G>>=5,z-=5,h.ndist=1+(31&F),F>>>=5,z-=5,h.ncode=4+(15&F),F>>>=4,z-=4,286>>=3,z-=3}for(;h.have<19;)h.lens[W[h.have++]]=0;if(h.lencode=h.lendyn,h.lenbits=7,P={bits:h.lenbits},U=c(0,h.lens,0,19,h.lencode,0,h.work,P),h.lenbits=P.bits,U){E.msg="invalid code lengths set",h.mode=30;break}h.have=0,h.mode=19;case 19:for(;h.have>>16&255,mt=65535&b,!((lt=b>>>24)<=z);){if(G===0)break t;G--,F+=M[Z++]<>>=lt,z-=lt,h.lens[h.have++]=mt;else{if(mt===16){for(x=lt+2;z>>=lt,z-=lt,h.have===0){E.msg="invalid bit length repeat",h.mode=30;break}u=h.lens[h.have-1],K=3+(3&F),F>>>=2,z-=2}else if(mt===17){for(x=lt+3;z>>=lt)),F>>>=3,z-=3}else{for(x=lt+7;z>>=lt)),F>>>=7,z-=7}if(h.have+K>h.nlen+h.ndist){E.msg="invalid bit length repeat",h.mode=30;break}for(;K--;)h.lens[h.have++]=u}}if(h.mode===30)break;if(h.lens[256]===0){E.msg="invalid code -- missing end-of-block",h.mode=30;break}if(h.lenbits=9,P={bits:h.lenbits},U=c(g,h.lens,0,h.nlen,h.lencode,0,h.work,P),h.lenbits=P.bits,U){E.msg="invalid literal/lengths set",h.mode=30;break}if(h.distbits=6,h.distcode=h.distdyn,P={bits:h.distbits},U=c(f,h.lens,h.nlen,h.ndist,h.distcode,0,h.work,P),h.distbits=P.bits,U){E.msg="invalid distances set",h.mode=30;break}if(h.mode=20,L===6)break t;case 20:h.mode=21;case 21:if(6<=G&&258<=Y){E.next_out=st,E.avail_out=Y,E.next_in=Z,E.avail_in=G,h.hold=F,h.bits=z,l(E,Q),st=E.next_out,it=E.output,Y=E.avail_out,Z=E.next_in,M=E.input,G=E.avail_in,F=h.hold,z=h.bits,h.mode===12&&(h.back=-1);break}for(h.back=0;ft=(b=h.lencode[F&(1<>>16&255,mt=65535&b,!((lt=b>>>24)<=z);){if(G===0)break t;G--,F+=M[Z++]<>ht)])>>>16&255,mt=65535&b,!(ht+(lt=b>>>24)<=z);){if(G===0)break t;G--,F+=M[Z++]<>>=ht,z-=ht,h.back+=ht}if(F>>>=lt,z-=lt,h.back+=lt,h.length=mt,ft===0){h.mode=26;break}if(32&ft){h.back=-1,h.mode=12;break}if(64&ft){E.msg="invalid literal/length code",h.mode=30;break}h.extra=15&ft,h.mode=22;case 22:if(h.extra){for(x=h.extra;z>>=h.extra,z-=h.extra,h.back+=h.extra}h.was=h.length,h.mode=23;case 23:for(;ft=(b=h.distcode[F&(1<>>16&255,mt=65535&b,!((lt=b>>>24)<=z);){if(G===0)break t;G--,F+=M[Z++]<>ht)])>>>16&255,mt=65535&b,!(ht+(lt=b>>>24)<=z);){if(G===0)break t;G--,F+=M[Z++]<>>=ht,z-=ht,h.back+=ht}if(F>>>=lt,z-=lt,h.back+=lt,64&ft){E.msg="invalid distance code",h.mode=30;break}h.offset=mt,h.extra=15&ft,h.mode=24;case 24:if(h.extra){for(x=h.extra;z>>=h.extra,z-=h.extra,h.back+=h.extra}if(h.offset>h.dmax){E.msg="invalid distance too far back",h.mode=30;break}h.mode=25;case 25:if(Y===0)break t;if(K=Q-Y,h.offset>K){if((K=h.offset-K)>h.whave&&h.sane){E.msg="invalid distance too far back",h.mode=30;break}pt=K>h.wnext?(K-=h.wnext,h.wsize-K):h.wnext-K,K>h.length&&(K=h.length),vt=h.window}else vt=it,pt=st-h.offset,K=h.length;for(YB?(I=pt[vt+v[L]],z[tt+v[L]]):(I=96,0),S=1<>st)+(T-=S)]=H<<24|I<<16|j|0,T!==0;);for(S=1<>=1;if(S!==0?(F&=S-1,F+=S):F=0,L++,--Q[E]==0){if(E===M)break;E=f[w+v[L]]}if(it>>7)]}function tt(b,C){b.pending_buf[b.pending++]=255&C,b.pending_buf[b.pending++]=C>>>8&255}function Q(b,C,W){b.bi_valid>m-W?(b.bi_buf|=C<>m-b.bi_valid,b.bi_valid+=W-m):(b.bi_buf|=C<>>=1,W<<=1,0<--C;);return W>>>1}function vt(b,C,W){var V,R,$=new Array(v+1),X=0;for(V=1;V<=v;V++)$[V]=X=X+W[V-1]<<1;for(R=0;R<=C;R++){var J=b[2*R+1];J!==0&&(b[2*R]=pt($[J]++,J))}}function lt(b){var C;for(C=0;C>1;1<=W;W--)ht(b,$,W);for(R=nt;W=b.heap[1],b.heap[1]=b.heap[b.heap_len--],ht(b,$,1),V=b.heap[1],b.heap[--b.heap_max]=W,b.heap[--b.heap_max]=V,$[2*R]=$[2*W]+$[2*V],b.depth[R]=(b.depth[W]>=b.depth[V]?b.depth[W]:b.depth[V])+1,$[2*W+1]=$[2*V+1]=R,b.heap[1]=R++,ht(b,$,1),2<=b.heap_len;);b.heap[--b.heap_max]=b.heap[1],function(ut,bt){var Ht,At,Vt,gt,Zt,le,Ot=bt.dyn_tree,Qt=bt.max_code,jt=bt.stat_desc.static_tree,fe=bt.stat_desc.has_stree,ce=bt.stat_desc.extra_bits,te=bt.stat_desc.extra_base,zt=bt.stat_desc.max_length,ee=0;for(gt=0;gt<=v;gt++)ut.bl_count[gt]=0;for(Ot[2*ut.heap[ut.heap_max]+1]=0,Ht=ut.heap_max+1;Ht>=7;R>>=1)if(1&ct&&J.dyn_ltree[2*nt]!==0)return a;if(J.dyn_ltree[18]!==0||J.dyn_ltree[20]!==0||J.dyn_ltree[26]!==0)return o;for(nt=32;nt>>3,($=b.static_len+3+7>>>3)<=R&&(R=$)):R=$=W+5,W+4<=R&&C!==-1?x(b,C,W,V):b.strategy===4||$===R?(Q(b,2+(V?1:0),3),Ct(b,rt,E)):(Q(b,4+(V?1:0),3),function(J,nt,ct,ut){var bt;for(Q(J,nt-257,5),Q(J,ct-1,5),Q(J,ut-4,4),bt=0;bt>>8&255,b.pending_buf[b.d_buf+2*b.last_lit+1]=255&C,b.pending_buf[b.l_buf+b.last_lit]=255&W,b.last_lit++,C===0?b.dyn_ltree[2*W]++:(b.matches++,C--,b.dyn_ltree[2*(h[W]+f+1)]++,b.dyn_dtree[2*z(C)]++),b.last_lit===b.lit_bufsize-1},s._tr_align=function(b){Q(b,2,3),K(b,T,rt),function(C){C.bi_valid===16?(tt(C,C.bi_buf),C.bi_buf=0,C.bi_valid=0):8<=C.bi_valid&&(C.pending_buf[C.pending++]=255&C.bi_buf,C.bi_buf>>=8,C.bi_valid-=8)}(b)}},{"../utils/common":41}],53:[function(e,r,s){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,r,s){(function(i){(function(a,o){if(!a.setImmediate){var l,c,g,f,w=1,p={},y=!1,d=a.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(a);v=v&&v.setTimeout?v:a,l={}.toString.call(a.process)==="[object process]"?function(k){process.nextTick(function(){S(k)})}:function(){if(a.postMessage&&!a.importScripts){var k=!0,A=a.onmessage;return a.onmessage=function(){k=!1},a.postMessage("","*"),a.onmessage=A,k}}()?(f="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",T,!1):a.attachEvent("onmessage",T),function(k){a.postMessage(f+k,"*")}):a.MessageChannel?((g=new MessageChannel).port1.onmessage=function(k){S(k.data)},function(k){g.port2.postMessage(k)}):d&&"onreadystatechange"in d.createElement("script")?(c=d.documentElement,function(k){var A=d.createElement("script");A.onreadystatechange=function(){S(k),A.onreadystatechange=null,c.removeChild(A),A=null},c.appendChild(A)}):function(k){setTimeout(S,0,k)},v.setImmediate=function(k){typeof k!="function"&&(k=new Function(""+k));for(var A=new Array(arguments.length-1),D=0;D"u"?i===void 0?this:i:self)}).call(this,typeof Mt<"u"?Mt:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(In);var Pa=In.exports;const jr=zn(Pa);var ye={},kt={},ot={};Object.defineProperty(ot,"__esModule",{value:!0});ot.wordSpecialAttributes=ot.propUsfm3Milestone=ot.markerHasSpecialEndTag=ot.markerIsMilestone=ot.markerSupportsNumbers=ot.markerContentDisplayable=ot.markerDisplayable=ot.propDisplayable=ot.markerStandalone=ot.propStandalone=ot.markerHasEndAttributes=ot.propAttributes=ot.markerTermination=ot.propTermination=ot.markerType=ot.propType=ot.USFM_PROPERTIES=ot.SPECIAL_END_TAGS=ot.MARKERS_WITH_NUMBERS=void 0;var Fn={c:!0,v:!0};ot.MARKERS_WITH_NUMBERS=Fn;var Pn={esbe:"esb","qt-e":"qt-s","qt1-e":"qt1-s","qt2-e":"qt2-s","qt3-e":"qt3-s","qt4-e":"qt4-s","qt5-e":"qt5-s"};ot.SPECIAL_END_TAGS=Pn;var Wt={"+add":{endTag:"*",display:!0},"+bd":{endTag:"*",display:!0},"+bdit":{endTag:"*",display:!0},"+bk":{endTag:"*",display:!0},"+dc":{endTag:"*",display:!0},"+em":{endTag:"*",display:!0},"+it":{endTag:"*",display:!0},"+k":{endTag:"*",display:!0},"+lit":{display:!0},"+nd":{endTag:"*",display:!0},"+no":{endTag:"*",display:!0},"+ord":{endTag:"*",display:!0},"+pn":{endTag:"*",display:!0},"+png":{endTag:"*",display:!0},"+qt":{type:"quote",endTag:"*",display:!0},"+sc":{endTag:"*",display:!0},"+sig":{endTag:"*",display:!0},"+sls":{endTag:"*",display:!0},"+sup":{endTag:"*",display:!0},"+tl":{endTag:"*",display:!0},"+wj":{endTag:"*",display:!0},add:{endTag:"*",display:!0},b:{type:"paragraph",display:!0},bd:{endTag:"*",display:!0},bdit:{endTag:"*",display:!0},bk:{endTag:"*",display:!0},ca:{endTag:"*"},cat:{endTag:"*"},cls:{type:"paragraph",display:!0},d:{display:!0},dc:{endTag:"*",display:!0},ef:{endTag:"*"},em:{endTag:"*",display:!0},esb:{endTag:"esbe"},ex:{endTag:"*"},f:{type:"footnote",endTag:"*"},fa:{endTag:"*"},fdc:{endTag:"*"},fe:{endTag:"*"},fig:{endTag:"*",attrib:!0},fm:{endTag:"*"},fqa:{endTag:"*"},fv:{endTag:"*"},ior:{endTag:"*"},iqt:{endTag:"*"},it:{endTag:"*",display:!0},jmp:{endTag:"*",attrib:!0,display:!0},k:{endTag:["-e","*"],type:"milestone",display:!0,attrib:!0},lf:{display:!0},lh:{display:!0},li:{endTag:"*",display:!0},lik:{endTag:"*",display:!0},lim:{display:!0},lim1:{display:!0},lim2:{display:!0},lim3:{display:!0},lim4:{display:!0},lim5:{display:!0},lit:{display:!0},litl:{endTag:"*",display:!0},liv:{endTag:"*",display:!0},liv1:{endTag:"*",display:!0},liv2:{endTag:"*",display:!0},liv3:{endTag:"*",display:!0},liv4:{endTag:"*",display:!0},liv5:{endTag:"*",display:!0},m:{type:"paragraph",display:!0},mi:{type:"paragraph",display:!0},nb:{type:"paragraph",display:!0},nd:{endTag:"*",display:!0},ndx:{endTag:"*"},no:{endTag:"*",display:!0},ord:{endTag:"*",display:!0},p:{type:"paragraph",display:!0},pb:{type:"paragraph",display:!0},pc:{type:"paragraph",display:!0},ph:{type:"paragraph",display:!0},ph1:{type:"paragraph",display:!0},ph2:{type:"paragraph",display:!0},ph3:{type:"paragraph",display:!0},ph4:{type:"paragraph",display:!0},ph5:{type:"paragraph",display:!0},pi:{type:"paragraph",display:!0},pi1:{type:"paragraph",display:!0},pi2:{type:"paragraph",display:!0},pi3:{type:"paragraph",display:!0},pi4:{type:"paragraph",display:!0},pi5:{type:"paragraph",display:!0},pm:{type:"paragraph",display:!0},pmc:{type:"paragraph",display:!0},pmo:{type:"paragraph",display:!0},pmr:{type:"paragraph",display:!0},pn:{endTag:"*",display:!0},png:{endTag:"*",display:!0},po:{type:"paragraph",display:!0},pr:{type:"paragraph",display:!0},pro:{endTag:"*"},q:{type:"quote",display:!0},q1:{type:"quote",display:!0},q2:{type:"quote",display:!0},q3:{type:"quote",display:!0},q4:{type:"quote",display:!0},qa:{type:"quote",display:!0},qac:{type:"quote",endTag:"*",display:!0},qc:{type:"quote",display:!0},qm:{type:"quote",display:!0},qr:{type:"quote",display:!0},qs:{type:"quote",endTag:"*",display:!0},qt:{type:"quote",endTag:"*",display:!0,milestone:!0,attrib:!0},qt1:{type:"quote",endTag:"*",display:!0,milestone:!0,attrib:!0},qt2:{type:"quote",endTag:"*",display:!0,milestone:!0,attrib:!0},qt3:{type:"quote",endTag:"*",display:!0,milestone:!0,attrib:!0},qt4:{type:"quote",endTag:"*",display:!0,milestone:!0,attrib:!0},qt5:{type:"quote",endTag:"*",display:!0,milestone:!0,attrib:!0},"qt-e":{endAttrib:!0},"qt1-e":{endAttrib:!0},"qt2-e":{endAttrib:!0},"qt3-e":{endAttrib:!0},"qt4-e":{endAttrib:!0},"qt5-e":{endAttrib:!0},"qt-s":{type:"quote",endTag:"-e",display:!0,milestone:!0,usfm3Milestone:!0,attrib:!0},"qt1-s":{type:"quote",endTag:"-e",display:!0,milestone:!0,usfm3Milestone:!0,attrib:!0},"qt2-s":{type:"quote",endTag:"-e",display:!0,milestone:!0,usfm3Milestone:!0,attrib:!0},"qt3-s":{type:"quote",endTag:"-e",display:!0,milestone:!0,usfm3Milestone:!0,attrib:!0},"qt4-s":{type:"quote",endTag:"-e",display:!0,milestone:!0,usfm3Milestone:!0,attrib:!0},"qt5-s":{type:"quote",endTag:"-e",display:!0,milestone:!0,usfm3Milestone:!0,attrib:!0},rb:{endTag:"*",display:!0,attrib:!0},rq:{endTag:"*"},rt:{endTag:"*"},s:{type:"section"},s1:{type:"section"},s2:{type:"section"},s3:{type:"section"},s4:{type:"section"},s5:{type:"section"},sc:{endTag:"*",display:!0},sig:{endTag:"*",display:!0},sis:{endTag:"*"},sls:{endTag:"*",display:!0},sp:{display:!0},sup:{endTag:"*",display:!0},tl:{endTag:"*",display:!0},ts:{milestone:!0,display:!1,standalone:!0},"ts-e":{milestone:!0,display:!1,endAttrib:!0,standalone:!0},"ts-s":{milestone:!0,display:!1,endAttrib:!0,standalone:!0},v:{display:!0},va:{endTag:"*"},vp:{endTag:"*"},w:{endTag:"*",display:!0,attrib:!0},wa:{endTag:"*",display:!0},wg:{endTag:"*",display:!0},wh:{endTag:"*",display:!0},wj:{endTag:"*",display:!0},x:{endTag:"*"},xdc:{endTag:"*"},xnt:{endTag:"*"},xop:{endTag:"*"},xot:{endTag:"*"},xt:{endTag:"*",attrib:!0},zaln:{endTag:"-e",type:"milestone",display:!0,attrib:!0}};ot.USFM_PROPERTIES=Wt;var Bn=function(t){return t&&t.type};ot.propType=Bn;var Ba=function(t){var e=t&&Wt[t];return Bn(e)};ot.markerType=Ba;var Nn=function(t){return t&&t.endTag};ot.propTermination=Nn;var Na=function(t){var e=Wt[t];return Nn(e)};ot.markerTermination=Na;var Da=function(t){return t&&t.attrib};ot.propAttributes=Da;var La=function(t){var e=Wt[t];return e&&e.endAttrib};ot.markerHasEndAttributes=La;var Dn=function(t){return t&&t.standalone};ot.propStandalone=Dn;var Ua=function(t){var e=Wt[t];return Dn(e)};ot.markerStandalone=Ua;var gr=function(t){return t&&t.display};ot.propDisplayable=gr;var Ma=function(t){var e=t&&Wt[t];return gr(e)};ot.markerDisplayable=Ma;var qa=function(t){var e=Wt[t];return gr(e)};ot.markerContentDisplayable=qa;var Wa=function(t){return Fn[t]};ot.markerSupportsNumbers=Wa;var Ha=function(t){var e=Wt[t];return e&&e.milestone};ot.markerIsMilestone=Ha;var Va=function(t){return Pn[t]};ot.markerHasSpecialEndTag=Va;var Za=function(t){return t&&t.usfm3Milestone};ot.propUsfm3Milestone=Za;var ja=["morph","occurrence","occurrences","tw"];ot.wordSpecialAttributes=ja;function ke(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ke=function(e){return typeof e}:ke=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ke(n)}Object.defineProperty(kt,"__esModule",{value:!0});kt.usfmToJSON=kt.getAlignmentFormat=kt.pushObject=kt.createUsfmObject=void 0;var dt=Ga(ot);function Ln(n){if(typeof WeakMap!="function")return null;var t=new WeakMap,e=new WeakMap;return(Ln=function(s){return s?e:t})(n)}function Ga(n,t){if(n&&n.__esModule)return n;if(n===null||ke(n)!=="object"&&typeof n!="function")return{default:n};var e=Ln(t);if(e&&e.has(n))return e.get(n);var r={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in n)if(i!=="default"&&Object.prototype.hasOwnProperty.call(n,i)){var a=s?Object.getOwnPropertyDescriptor(n,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=n[i]}return r.default=n,e&&e.set(n,r),r}var $a=/(^-\d+\s)/,Ja=/(\d+)/,mr=function(t,e,r){var s=[],i;if(t.match(e))for(;i=e.exec(t);){var a=null,o=i.index+i[0].length;if(!r&&o>=t.length)a=` -`;else{var l=t[o];l===" "&&(a=l)}a&&(i.nextChar=a),s.push(i)}return s},Ka=function(t){var e={};if(t){var r=/(\+?\w+)\s*(\d*)/g,s=mr(t,r,!0);e={tag:s[0][1],number:s[0][2]}}return e},Un=function(t){return t&&t.length>1&&t[0]===" "&&(t=t.substr(1)),t},Gr=function(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,s={},i=(e||"").split("|"),a=Un(i[0]),o=i[1];if(s={text:a,tag:"w",type:"word"},t.params["content-source"]&&(s["content-source"]=t.params["content-source"]),o){for(var l=/([x-]*)([\w-]+)=['"](.*?)['"]/g,c=mr(o,l,!0),g=0,f=c.length;g0){var o=Te(t.substr(0,a[0].index-1));r.push(o)}var l=null;if(i.exec(t)){for(var c=0,g=a.length;c=D,H=y.length+2,I=f[0].indexOf(f[3],H);I<0&&(B?(I=H,H--):f[0]==="\\"+f[2]&&(S.nextChar=" "));var j=I>=0&&f[0].substring(H,I);j&&(S.content=j+(d||""))}}if(m.number&&!dt.markerSupportsNumbers(m.tag)){delete S.number;var rt=void 0,E=f[0].indexOf(m.tag);E>=0?rt=f[0].substr(E+m.tag.length+1):rt=m.number+" "+(d||""),S.content=rt}if(v){if(S.content){var L=S.content.lastIndexOf(v);L>=0&&(S.content=S.content.substring(0,L))}r.push(S);var h=v.substr(1);S=Xa(h)}f.nextChar&&(S.nextChar=f.nextChar),r.push(S),l=S}if(a.length){var M=a[a.length-1],it=M.index+M[0].length;if(it0?t.phrase[t.phrase.length-1]:null},ve=function(t){var e=t.headers,r=He(t);return r!==null?e=r:t.params.chunk?t.currentVerse&&(t.verses[t.currentVerse]||(t.verses[t.currentVerse]=[]),e=t.verses[t.currentVerse]):t.currentChapter&&(t.currentVerse||(t.currentVerse="front"),t.chapters[t.currentChapter][t.currentVerse]||(t.chapters[t.currentChapter][t.currentVerse]=[]),e=t.chapters[t.currentChapter][t.currentVerse]),e},Lt=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(typeof t=="string")return{type:"text",text:t};var r=t,s=t.tag,i=t.content||t.text,a=dt.USFM_PROPERTIES[s],o=dt.propType(a),l=!0;if(s?(l=dt.propDisplayable(a),o==="milestone"&&s.indexOf("-s")<0&&(o=""),o&&(r.type=o)):r.type="text",t.number){if(!dt.markerSupportsNumbers(s)){var c=t.number;i&&(c+=" "+i),i=c,delete r.number}}else delete r.number;return e?delete r.nextChar:t.nextChar&&i&&(i+=t.nextChar,delete r.nextChar),delete r.content,delete r.text,i&&(r[l?"text":"content"]=i),delete r.open,delete r.close,r};kt.createUsfmObject=Lt;var Et=function(t,e,r){if(!Array.isArray(e)){var s=He(t);if(s===null){var i=t.nested.length>0;if(i){var a=t.nested.length-1,o=dt.markerContentDisplayable(r.tag)?"text":"content",l=t.nested[a],c=l[o];if(typeof r=="string")c+=r;else{c+="\\"+r.tag;var g=r.text||r.content;g&&(g[0]!==" "&&(c+=" "),c+=g)}l[o]=c;return}}else e=s}if(typeof r=="string"){if(r==="")return;r=Lt(r)}if(e=Array.isArray(e)?e:ve(t),e.length&&r.type==="text"){var f=e.length-1,w=e[f];if(w.type==="text"){w.text+=r.text;return}}e.push(r)};kt.pushObject=Et;var Mn=function(t){var e=t?t.substr(t.length-1):"",r=[` -`,"\r"].indexOf(e);return r>=0},Qa=function(t){var e=t&&t.length>=2?t.substr(t.length-2,1):"",r=["'",'"',"“"].indexOf(e);return r>=0},qn=function(t){return t&&t.tag&&["k","w","zaln"].includes(t.tag)},$r=function(t,e){var r=t&&qn(t)&&t.tag===e;return r},Jr=function(t){if(Array.isArray(t)&&t.length){var e=t[t.length-1];return e}return null},Kr=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,s=ve(t),i=!1,a=Jr(s);if(a){if(a.nextChar===` -`)t.newAlignFormat||(delete a.nextChar,$r(a,e)&&(i=!0));else if(a.text){var o=a.text;Mn(o)&&(o.length===1?(s.pop(),a=Jr(s)):(a.text=o.substr(0,o.length-1),!t.newAlignFormat&&a.text===" "&&dt.markerDisplayable(a.tag)&&(a.nextChar=a.text,delete a.text)),i=t.newAlignFormat||!r&&$r(a,e))}}i&&Et(t,null," ")},to=function(t){var e=ve(t);if(e&&e.length){var r=e[e.length-1];if(r.nextChar===` -`)t.newAlignFormat||(r.nextChar=" ");else if(r.text){var s=r.text;if(Mn(s)){var i=e.length===1&&r.text.length===1,a=i||Qa(s);t.newAlignFormat?r.type==="text"&&(r.text=s.substr(0,s.length-1)+" "):a?s.length===1?e.pop():r.text=s.substr(0,s.length-1):r.text=s.substr(0,s.length-1)+" "}}}},ur=function(t){for(;t.length>1&&t[0]==="0";)t=t.substr(1);return t},eo=function(t){var e=!1,r=null,s=t.content||"",i=t.tag,a=t.tag;if(a.substr(a.length-1)==="*")a=a.substr(0,a.length-1),r=t.tag;else if(s.substr(0,1)==="-"){var o=s.substr(1,1);if(o==="s"||o==="e"){var l=2;t.tag+=s.substr(0,2),r=o==="e"?t.tag:null,a+="-s",s=s.substr(l),t.content=s}}else if(s.substr(0,1)==="*"){var c=1,g="";s.substr(c,1)===" "&&(c++,g=" "),t.tag+=s.substr(0,1),r=t.tag,s=s.substr(c),s&&(s+=t.nextChar||"",delete t.nextChar),g&&(s?t.endMarkerChar=g:t.nextChar=g),t.content=s}if(r)e=!0;else{var f=dt.USFM_PROPERTIES[a];if(dt.propStandalone(f))r=t.tag,e=!0;else{var w=dt.propTermination(f);w&&(e=!0,i+w===t.tag&&(r=t.tag))}}return{endMarker:r,spannedUsfm:e}},Xr=function(t){var e=Bt(t);return!!(e&&!dt.markerContentDisplayable(e.tag))},Yt=function(t,e){var r=Bt(t);if(r)if(dt.markerContentDisplayable(r.tag))if(r.attrib&&!r.usfm3Milestone&&typeof e=="string")r.attrib+=e;else{var i=He(t),a=Lt(e);i.push(a)}else{var s=typeof e=="string"?e:ae(e);r.content=(r.content||"")+s}else if(t.nested.length>0)Et(t,null,e);else{var o=ve(t);o.push(e)}},Yr=function(t,e,r){return e&&e.tag===r?(e.nesting||(e.nesting=0),e.nesting++,!0):!1},ro=function(t,e,r){var s=!1,i=r.split(" "),a=i[0]+(i.length>1?"\\*":""),o=-1;if(e){var l=dt.markerTermination(e.tag);l||(l=[]),l&&!Array.isArray(l)&&(l=[l]);for(var c=null,g=0,f=l.length;g=s.length)break;var o=s[a];if(!o.tag&&o.content){if(i=o.content.indexOf("*"),i===0)break;if(i<0)t+=o.content,r=a,i=t.indexOf("*",e);else{var l=o.content.substr(i);o.content[i-1]==="\\"&&i--,i>0&&(t+=o.content.substr(0,i),o.content=l);break}}else break}return{content:t,index:r}},Wn=function(t,e,r,s,i){e.tag=r;var a=Bt(t),o=dt.USFM_PROPERTIES[r],l=dt.propDisplayable(o);if(dt.propUsfm3Milestone(o)&&(e.usfm3Milestone=!0),dt.propAttributes(o)){var c=dt.propDisplayable(o)?"text":"content",g=e[c];if(g){var f=g.indexOf("|");if(f>=0){var w=io(g,f,s,i);g=w.content,s=w.index;var p=g.substr(0,f).trim();p||(f=0),e.attrib=g.substr(f),g=g.substr(0,f)}g&&(e[c]=g)}g||delete e[c]}return a&&!dt.markerContentDisplayable(a.tag)?(a.content=(a.content||"")+ae(e),Yr(t,a,r),s):(l?(Et(t,null,e),t.phrase===null&&(t.phrase=[],t.phraseParent=e),t.phrase.push([]),e.children=He(t)):(Yt(t,e),t.phrase===null&&(t.phraseParent=no(t)),Yr(t,e,r)),s)},Bt=function(t){var e=null;return t.phrase!==null&&t.phrase.length>1&&(e=t.phrase[t.phrase.length-2]),e&&(e.length>0?e=e[e.length-1]:e=null),e||(e=t.phraseParent),e},Re=function(t){var e=null;return t.phrase&&t.phrase.length>0?(t.phrase.pop(),t.phrase.length<=0?(t.phrase=null,e=t.phraseParent,t.phraseParent=null):e=Bt(t)):t.phraseParent=null,e},Hn=function(t,e,r,s){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1,a=r[e],o=a.content,l=Bt(t),c=l&&dt.USFM_PROPERTIES[l.tag]||null,g=dt.propDisplayable(c);if(s&&dt.propUsfm3Milestone(c)&&(s+="\\*"),(!l||g)&&(Re(t),l&&s))for(l.children!==void 0&&!l.children.length&&delete l.children;l;){var f=l.tag.split("-")[0];if(f+"*"===s||f+"-e\\*"===s){l.endTag=s;break}else l.endTag="",l=Bt(t),Re(t)}var w=dt.markerStandalone(a.tag),p=0;if(o){var y=o[0];["\\","-","*"].includes(y)&&(y==="*"?p=1:o.substr(0,2)==="\\*"?p=2:o.substr(0,4)==="-e\\*"?p=4:o.substr(0,3)==="-e*"?p=3:o==="-e"&&(p=2,w=!0),p&&(o.substr(p,1)===` -`&&p++,o=o.substr(p)))}if(o&&dt.markerHasEndAttributes(a.tag))if(l){var d=(l.endTag||"").split("\\*");s=d[0]+o+(d.length>1?"\\*":""),l.endTag=s,a.content=o=""}else a.attrib=o,a.content=o="";var v=null;if((w||!o&&!a.nextChar&&s)&&(p=0,e+10&&e.content?Bt(t)?Yt(t,e.content):Vn(t,e.content):t.currentChapter===0&&!t.currentVerse&&Et(t,t.headers,Lt(e)),t.params.chunk&&t.currentVerse>0&&e.content&&(t.verses[t.currentVerse]||(t.verses[t.currentVerse]=[]),Bt(t)?Yt(t,e.content):Et(t,t.verses[t.currentVerse],e.content))},so=function(t){var e="";return t&&(e=" "+t),e},ae=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t.tag)return t.text||t.content;var r="\\"+t.tag;t.number&&(r+=" "+t.number);var s=t.content||t.text;if(e?r+=s:r+=so(s),t.attrib){var i=t.tag.indexOf("-"),a=i>0?t.tag.substr(i+1,1):"",o=["s","e"].includes(a);!s&&(!a||!o)&&(r+=" "),r+=t.attrib,o&&(r+="\\")}return t.nextChar&&(r+=t.nextChar),r},tn=function(t,e){t.inHeader=!1,yr(t),t.nested=[],t.currentChapter=ur(e.number),t.chapters[t.currentChapter]={},t.onSameChapter=!1,t.currentVerse=0},en=function(t){var e=Ja.exec(t.content);e&&(t.number=e[0],t.content=t.content.substr(e.length))},Zn=function(t){for(var e={},r=0,s=Object.keys(t);r1&&arguments[1]!==void 0?arguments[1]:{};t=lo(t);for(var r=t.split(/\r?\n/),s={},i=[],a=r.length-1,o=0;o=a);i.push.apply(i,l)}var c={currentChapter:0,currentVerse:0,chapters:{},verses:{},headers:[],nested:[],phrase:null,phraseParent:null,onSameChapter:!1,inHeader:!0,newAlignFormat:!1,params:e};Gn(t,c);for(var g=0;g0&&(s.verses=Zn(c.verses)),s};kt.usfmToJSON=fo;var Ve={};function Oe(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Oe=function(e){return typeof e}:Oe=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Oe(n)}Object.defineProperty(Ve,"__esModule",{value:!0});Ve.jsonToUSFM=void 0;var Ze=ho(ot),co=kt;function $n(n){if(typeof WeakMap!="function")return null;var t=new WeakMap,e=new WeakMap;return($n=function(s){return s?e:t})(n)}function ho(n,t){if(n&&n.__esModule)return n;if(n===null||Oe(n)!=="object"&&typeof n!="function")return{default:n};var e=$n(t);if(e&&e.has(n))return e.get(n);var r={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in n)if(i!=="default"&&Object.prototype.hasOwnProperty.call(n,i)){var a=s?Object.getOwnPropertyDescriptor(n,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=n[i]}return r.default=n,e&&e.set(n,r),r}function po(n,t){var e=typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(!e){if(Array.isArray(n)||(e=go(n))||t){e&&(n=e);var r=0,s=function(){};return{s,n:function(){return r>=n.length?{done:!0}:{done:!1,value:n[r++]}},e:function(c){throw c},f:s}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,a=!1,o;return{s:function(){e=e.call(n)},n:function(){var c=e.next();return i=c.done,c},e:function(c){a=!0,o=c},f:function(){try{!i&&e.return!=null&&e.return()}finally{if(a)throw o}}}}function go(n,t){if(n){if(typeof n=="string")return rn(n,t);var e=Object.prototype.toString.call(n).slice(8,-1);if(e==="Object"&&n.constructor&&(e=n.constructor.name),e==="Map"||e==="Set")return Array.from(n);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return rn(n,t)}}function rn(n,t){(t==null||t>n.length)&&(t=n.length);for(var e=0,r=new Array(t);e1&&arguments[1]!==void 0?arguments[1]:null,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,i="",a=t.text||t.content||"",o=t.endTag;if(typeof o!="string"&&Ze.markerTermination(t.tag)&&!s&&(o=t.tag+"*"),t.tag){i="\\"+t.tag,t.number&&(i+=" "+t.number);var l=a.substr(0,1);r||(t.attrib?(a&&(i+=" "+a),t.tag.substr(-2)==="\\*"?i=i.substr(0,i.length-2)+t.attrib+i.substr(-2):i+=t.attrib,a=""):o?l!==" "&&(i+=" "):(l!==""&&l!==` -`&&a!==` -`||e&&t.tag&&!a&&!t.nextChar&&!["w","k","zaln"].includes(e.tag))&&(i+=" "))}return a&&(i+=a),o&&(i+="\\"+o),t.nextChar&&(i+=t.nextChar),i},vo=function(t){var e=!1,r=t.lastIndexOf("\\");if(r>=0){var s=t.substr(r+1),i=s.split(" ");i.length===2&&i[1]===""&&(e=Ze.markerDisplayable(i[0]))}return e},sn=function(t,e){var r=!1;if(e=e||"",t){r=!1;var s=e?e.substr(e.length-1):"";It.forcedNewLines&&s===" "&&(vo(e)||(e=e.substr(0,e.length-1),r=!0)),r&&(t=` -`+t),e+=t}return e};function _o(n){var t=!1;if(n.includes("\\"))for(var e=["\\p","\\m","\\c","\\n","\\b"],r=0,s=e;r2&&arguments[2]!==void 0?arguments[2]:null;if(!t||!Object.keys(t).length)return e;if(e=e||"",t.verseObjects&&(t=t.verseObjects),Array.isArray(t)){for(var s,i=0,a=t.length;i=0;s||(e=` -`+e)}}return t=t.concat(e),t},bo=function(t,e){if(t&&t.length){var r=t[t.length-1];Jn(r)||e&&e.length&&(e[0]=` -`+e[0])}return t=t.concat(e),t},Yn=function(t){var e=t.sort(function(r,s){var i=parseInt(r,10)-parseInt(s,10);return i===0&&(i=r>s?1:-1),i});return e};function Qn(n){var t=n.length-1,e=n.length?n[t]:"",r=e?e.substr(e.length-1):"";return{lastLine:e,lastChar:r,position:t}}function wo(n){var t=Qn(n),e=t.lastChar,r=t.position;e&&e!==` -`&&(n[r]+=` -`)}function lr(n,t){if(n&&n.length>0){for(var e=n.length-1;e>0&&!Object.keys(n[e]).length;)e--;var r=n[e];r&&r.type==="paragraph"&&!(r.text&&r.text.trim())?wo(t):r.children&&lr(r.children,t)}}var So=function(t,e){var r=[];if(r.push("\\c "+t+` -`),e.front){var s=_r(e.front);r=r.concat(s);var i=e.front;lr(i.verseObjects,r),delete e.front}for(var a=Yn(Object.keys(e)),o=a.length,l=0;l-1}function bi(_,O){var q=this.__data__,et=_e(q,_);return et<0?q.push([_,O]):q[et][1]=O,this}Nt.prototype.clear=mi,Nt.prototype.delete=yi,Nt.prototype.get=vi,Nt.prototype.has=_i,Nt.prototype.set=bi;function re(_){var O=-1,q=_?_.length:0;for(this.clear();++O-1&&_%1==0&&_-1&&_%1==0&&_<=s}function we(_){var O=typeof _;return!!_&&(O=="object"||O=="function")}function ss(_){return!!_&&typeof _=="object"}function Je(_){return Ar(_)?zi(_):Di(_)}function as(){return[]}function os(){return!1}n.exports=ts})(De,De.exports);var ei=De.exports;const Eo=zn(ei);Object.defineProperty(qt,"__esModule",{value:!0});qt.mergeVerseData=qt.convertStringToVerseObjects=qt.removeMarker=void 0;var Co=ko(ei),Ao=kt;function ko(n){return n&&n.__esModule?n:{default:n}}var Ro=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",e=t;if(t){var r=ri(t);r&&(e=ii(r))}return e};qt.removeMarker=Ro;var ri=function(t){var e=(0,Ao.usfmToJSON)("\\v 1 "+t,{chunk:!0}),r=e&&e.verses&&e.verses[1]&&e.verses[1].verseObjects;return r};qt.convertStringToVerseObjects=ri;var Oo=function n(t,e,r){switch(t.type){case"word":e+=r+t.text,r=" ";break;case"milestone":e+=r+ni(t),r=" ";break;default:if(t.text){e+=t.text;var s=e.substr(-1);s!==","&&s!=="."&&s!=="?"&&s!==";"&&(r="")}if(t.children)for(var i=t.children.length,a=0;a{let t=n.text||"",e="";const r=n.children?n.children.length:0;for(let s=0;s{let e="";if(n.type==="word"?e=t+n.text:n.type==="milestone"&&(e=t+si(n)),e)n={type:"text",text:e},t=" ";else{if(t=" ",n.nextChar)t="";else if(n.text){const r=n.text.substr(-1);[",",".","?",";"].includes(r)||(t="")}if(n.children){const r=Eo(n);let s="";const i=n.children.length;for(let a=0;a1){let s=r[1];return s.substr(0,1)===" "&&(s=s.substr(1)),s}return""}function Fo(n){const t=n?.verseObjects||n;if(t){let e="";const r=[],s=t.length;for(let i=0;i(n=Fo(n),Io(n)),on=n=>{let t="";return"front"in n&&(t+=an(n.front)),Object.keys(n).forEach(e=>{if(e==="front")return;const r=n[e];t+=`\\v ${e} `+an(r)}),t},Po=n=>{const t=ye.toJSON(n);let e="";return t.headers.forEach(r=>{r.type=="text"?e+=`${r.text} -`:r.tag&&r.content&&(r.content!=="\\*"&&(r.content=` ${r.content}`),e+=`\\${r.tag}${r.content} -`)}),"front"in t.chapters&&(e+=on(t.chapters.front)),Object.keys(t.chapters).forEach(r=>{r!=="front"&&(e+=` -\\c ${r} -`+on(t.chapters[r]))}),e};function Bo(n,t,e,r){if(!n||!t||!e)console.log("owner, repo and ref must be provided"),r&&(r.textContent="owner, repo and ref must be provided");else{const s=`/${n}/${t}/archive/${e}.zip`;yt.get(s,{responseType:"blob"}).then(i=>jr.loadAsync(i.data)).then(i=>{const a=new jr,o=[];let l=0;const c=i.filter(g=>g.endsWith(".usfm")).length;if(!c)throw r.textContent="No USFM files found in the given repo",new Error("No USFM files found");return i.forEach((g,f)=>{if(g.endsWith(".usfm")){const w=f.async("string").then(p=>{console.log(`Processing ${n}/`+g);const y=Po(p);a.file(g,y),l++,r&&(r.textContent=`Processing ${l} of ${c}...`)});o.push(w)}}),Promise.all(o).then(()=>a)}).then(i=>i.generateAsync({type:"blob"})).then(i=>{const a=URL.createObjectURL(i),o=document.createElement("a");o.href=a,o.download=`${n}--${t}--${e}--unaligned-usfm.zip`,document.body.appendChild(o),o.click(),document.body.removeChild(o),r&&(r.textContent="")}).catch(i=>console.error("Error processing USFM files:",i))}}window.downloadUnalignedUSFM=Bo; + milestoneMap_ = params_.mileStoneMap ? params_.mileStoneMap : {}; + milestoneMap_.strongs = 'strong'; + milestoneIgnore_ = ['children', 'tag', 'type']; + + if (params_.mileStoneIgnore) { + milestoneIgnore_ = milestoneIgnore_.concat(params_.mileStoneIgnore); + } +}; +/** + * @description Takes in scripture json and outputs it as a USFM string. + * @param {Object} json - Scripture in JSON + * @param {Object} params - optional parameters like attributes to ignore. Properties: + * chunk {boolean} - if true then output is just a small piece of book + * ignore (Array} - list of attributes to ignore on word objects + * map {Object} - dictionary of attribute names to map to new name on word objects + * mileStoneIgnore (Array} - list of attributes to ignore on milestone objects + * mileStoneMap {Object} - dictionary of attribute names to map to new name on milestone objects + * forcedNewLines (boolean} - if true then we add newlines before alignment tags, verses, words + * @return {String} - Scripture in USFM + */ + + +var jsonToUSFM = function jsonToUSFM(json, params) { + params_ = params || {}; // save current parameters + + processParams(); + var output = []; + + if (json.headers) { + var _iterator = _createForOfIteratorHelper(json.headers), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var header = _step.value; + outputHeaderObject(output, header); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + } + + if (json.chapters) { + var chapterNumbers = Object.keys(json.chapters); + var chapterLen = chapterNumbers.length; + + for (var i = 0; i < chapterLen; i++) { + var chapterNumber = chapterNumbers[i]; + var chapterObject = json.chapters[chapterNumber]; + var chapterLines = generateChapterLines(chapterNumber, chapterObject); + output = addChapter(output, chapterLines); + } + } + + if (json.verses) { + var verseNumbers = sortVerses(Object.keys(json.verses)); + var verseLen = verseNumbers.length; + + for (var _i2 = 0; _i2 < verseLen; _i2++) { + var verseNumber = verseNumbers[_i2]; + var verseObjects = json.verses[verseNumber]; + var verse = generateVerse(verseNumber, verseObjects); + output = addVerse(output, verse); + } + } + + return output.join(''); +}; + +jsonToUsfm.jsonToUSFM = jsonToUSFM; + +var filter = {}; + +var lodash_clonedeep = {exports: {}}; + +/** + * lodash (Custom Build) + * Build: `lodash modularize exports="npm" -o ./` + * Copyright jQuery Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + */ +lodash_clonedeep.exports; + +(function (module, exports) { + /** Used as the size to enable large array optimizations. */ + var LARGE_ARRAY_SIZE = 200; + + /** Used to stand-in for `undefined` hash values. */ + var HASH_UNDEFINED = '__lodash_hash_undefined__'; + + /** Used as references for various `Number` constants. */ + var MAX_SAFE_INTEGER = 9007199254740991; + + /** `Object#toString` result references. */ + var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + mapTag = '[object Map]', + numberTag = '[object Number]', + objectTag = '[object Object]', + promiseTag = '[object Promise]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + symbolTag = '[object Symbol]', + weakMapTag = '[object WeakMap]'; + + var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + + /** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ + var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; + + /** Used to match `RegExp` flags from their coerced string values. */ + var reFlags = /\w*$/; + + /** Used to detect host constructors (Safari). */ + var reIsHostCtor = /^\[object .+?Constructor\]$/; + + /** Used to detect unsigned integer values. */ + var reIsUint = /^(?:0|[1-9]\d*)$/; + + /** Used to identify `toStringTag` values supported by `_.clone`. */ + var cloneableTags = {}; + cloneableTags[argsTag] = cloneableTags[arrayTag] = + cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = + cloneableTags[boolTag] = cloneableTags[dateTag] = + cloneableTags[float32Tag] = cloneableTags[float64Tag] = + cloneableTags[int8Tag] = cloneableTags[int16Tag] = + cloneableTags[int32Tag] = cloneableTags[mapTag] = + cloneableTags[numberTag] = cloneableTags[objectTag] = + cloneableTags[regexpTag] = cloneableTags[setTag] = + cloneableTags[stringTag] = cloneableTags[symbolTag] = + cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = + cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; + cloneableTags[errorTag] = cloneableTags[funcTag] = + cloneableTags[weakMapTag] = false; + + /** Detect free variable `global` from Node.js. */ + var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; + + /** Detect free variable `self`. */ + var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + + /** Used as a reference to the global object. */ + var root = freeGlobal || freeSelf || Function('return this')(); + + /** Detect free variable `exports`. */ + var freeExports = exports && !exports.nodeType && exports; + + /** Detect free variable `module`. */ + var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module; + + /** Detect the popular CommonJS extension `module.exports`. */ + var moduleExports = freeModule && freeModule.exports === freeExports; + + /** + * Adds the key-value `pair` to `map`. + * + * @private + * @param {Object} map The map to modify. + * @param {Array} pair The key-value pair to add. + * @returns {Object} Returns `map`. + */ + function addMapEntry(map, pair) { + // Don't return `map.set` because it's not chainable in IE 11. + map.set(pair[0], pair[1]); + return map; + } + + /** + * Adds `value` to `set`. + * + * @private + * @param {Object} set The set to modify. + * @param {*} value The value to add. + * @returns {Object} Returns `set`. + */ + function addSetEntry(set, value) { + // Don't return `set.add` because it's not chainable in IE 11. + set.add(value); + return set; + } + + /** + * A specialized version of `_.forEach` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ + function arrayEach(array, iteratee) { + var index = -1, + length = array ? array.length : 0; + + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; + } + + /** + * Appends the elements of `values` to `array`. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to append. + * @returns {Array} Returns `array`. + */ + function arrayPush(array, values) { + var index = -1, + length = values.length, + offset = array.length; + + while (++index < length) { + array[offset + index] = values[index]; + } + return array; + } + + /** + * A specialized version of `_.reduce` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ + function arrayReduce(array, iteratee, accumulator, initAccum) { + var index = -1, + length = array ? array.length : 0; + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; + } + + /** + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. + * + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. + */ + function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); + + while (++index < n) { + result[index] = iteratee(index); + } + return result; + } + + /** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ + function getValue(object, key) { + return object == null ? undefined : object[key]; + } + + /** + * Checks if `value` is a host object in IE < 9. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a host object, else `false`. + */ + function isHostObject(value) { + // Many host objects are `Object` objects that can coerce to strings + // despite having improperly defined `toString` methods. + var result = false; + if (value != null && typeof value.toString != 'function') { + try { + result = !!(value + ''); + } catch (e) {} + } + return result; + } + + /** + * Converts `map` to its key-value pairs. + * + * @private + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. + */ + function mapToArray(map) { + var index = -1, + result = Array(map.size); + + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; + } + + /** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ + function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; + } + + /** + * Converts `set` to an array of its values. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. + */ + function setToArray(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = value; + }); + return result; + } + + /** Used for built-in method references. */ + var arrayProto = Array.prototype, + funcProto = Function.prototype, + objectProto = Object.prototype; + + /** Used to detect overreaching core-js shims. */ + var coreJsData = root['__core-js_shared__']; + + /** Used to detect methods masquerading as native. */ + var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; + }()); + + /** Used to resolve the decompiled source of functions. */ + var funcToString = funcProto.toString; + + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; + + /** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ + var objectToString = objectProto.toString; + + /** Used to detect if a method is native. */ + var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' + ); + + /** Built-in value references. */ + var Buffer = moduleExports ? root.Buffer : undefined, + Symbol = root.Symbol, + Uint8Array = root.Uint8Array, + getPrototype = overArg(Object.getPrototypeOf, Object), + objectCreate = Object.create, + propertyIsEnumerable = objectProto.propertyIsEnumerable, + splice = arrayProto.splice; + + /* Built-in method references for those with the same name as other `lodash` methods. */ + var nativeGetSymbols = Object.getOwnPropertySymbols, + nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, + nativeKeys = overArg(Object.keys, Object); + + /* Built-in method references that are verified to be native. */ + var DataView = getNative(root, 'DataView'), + Map = getNative(root, 'Map'), + Promise = getNative(root, 'Promise'), + Set = getNative(root, 'Set'), + WeakMap = getNative(root, 'WeakMap'), + nativeCreate = getNative(Object, 'create'); + + /** Used to detect maps, sets, and weakmaps. */ + var dataViewCtorString = toSource(DataView), + mapCtorString = toSource(Map), + promiseCtorString = toSource(Promise), + setCtorString = toSource(Set), + weakMapCtorString = toSource(WeakMap); + + /** Used to convert symbols to primitives and strings. */ + var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; + + /** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function Hash(entries) { + var index = -1, + length = entries ? entries.length : 0; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + + /** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ + function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + } + + /** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function hashDelete(key) { + return this.has(key) && delete this.__data__[key]; + } + + /** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? undefined : result; + } + return hasOwnProperty.call(data, key) ? data[key] : undefined; + } + + /** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function hashHas(key) { + var data = this.__data__; + return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key); + } + + /** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ + function hashSet(key, value) { + var data = this.__data__; + data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; + } + + // Add methods to `Hash`. + Hash.prototype.clear = hashClear; + Hash.prototype['delete'] = hashDelete; + Hash.prototype.get = hashGet; + Hash.prototype.has = hashHas; + Hash.prototype.set = hashSet; + + /** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function ListCache(entries) { + var index = -1, + length = entries ? entries.length : 0; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + + /** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ + function listCacheClear() { + this.__data__ = []; + } + + /** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + return true; + } + + /** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; + } + + /** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; + } + + /** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ + function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; + } + + // Add methods to `ListCache`. + ListCache.prototype.clear = listCacheClear; + ListCache.prototype['delete'] = listCacheDelete; + ListCache.prototype.get = listCacheGet; + ListCache.prototype.has = listCacheHas; + ListCache.prototype.set = listCacheSet; + + /** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function MapCache(entries) { + var index = -1, + length = entries ? entries.length : 0; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + + /** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ + function mapCacheClear() { + this.__data__ = { + 'hash': new Hash, + 'map': new (Map || ListCache), + 'string': new Hash + }; + } + + /** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function mapCacheDelete(key) { + return getMapData(this, key)['delete'](key); + } + + /** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function mapCacheGet(key) { + return getMapData(this, key).get(key); + } + + /** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function mapCacheHas(key) { + return getMapData(this, key).has(key); + } + + /** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ + function mapCacheSet(key, value) { + getMapData(this, key).set(key, value); + return this; + } + + // Add methods to `MapCache`. + MapCache.prototype.clear = mapCacheClear; + MapCache.prototype['delete'] = mapCacheDelete; + MapCache.prototype.get = mapCacheGet; + MapCache.prototype.has = mapCacheHas; + MapCache.prototype.set = mapCacheSet; + + /** + * Creates a stack cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function Stack(entries) { + this.__data__ = new ListCache(entries); + } + + /** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ + function stackClear() { + this.__data__ = new ListCache; + } + + /** + * Removes `key` and its value from the stack. + * + * @private + * @name delete + * @memberOf Stack + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function stackDelete(key) { + return this.__data__['delete'](key); + } + + /** + * Gets the stack value for `key`. + * + * @private + * @name get + * @memberOf Stack + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function stackGet(key) { + return this.__data__.get(key); + } + + /** + * Checks if a stack value for `key` exists. + * + * @private + * @name has + * @memberOf Stack + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function stackHas(key) { + return this.__data__.has(key); + } + + /** + * Sets the stack `key` to `value`. + * + * @private + * @name set + * @memberOf Stack + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the stack cache instance. + */ + function stackSet(key, value) { + var cache = this.__data__; + if (cache instanceof ListCache) { + var pairs = cache.__data__; + if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { + pairs.push([key, value]); + return this; + } + cache = this.__data__ = new MapCache(pairs); + } + cache.set(key, value); + return this; + } + + // Add methods to `Stack`. + Stack.prototype.clear = stackClear; + Stack.prototype['delete'] = stackDelete; + Stack.prototype.get = stackGet; + Stack.prototype.has = stackHas; + Stack.prototype.set = stackSet; + + /** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ + function arrayLikeKeys(value, inherited) { + // Safari 8.1 makes `arguments.callee` enumerable in strict mode. + // Safari 9 makes `arguments.length` enumerable in strict mode. + var result = (isArray(value) || isArguments(value)) + ? baseTimes(value.length, String) + : []; + + var length = result.length, + skipIndexes = !!length; + + for (var key in value) { + if ((hasOwnProperty.call(value, key)) && + !(skipIndexes && (key == 'length' || isIndex(key, length)))) { + result.push(key); + } + } + return result; + } + + /** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ + function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || + (value === undefined && !(key in object))) { + object[key] = value; + } + } + + /** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; + } + + /** + * The base implementation of `_.assign` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ + function baseAssign(object, source) { + return object && copyObject(source, keys(source), object); + } + + /** + * The base implementation of `_.clone` and `_.cloneDeep` which tracks + * traversed objects. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @param {boolean} [isFull] Specify a clone including symbols. + * @param {Function} [customizer] The function to customize cloning. + * @param {string} [key] The key of `value`. + * @param {Object} [object] The parent object of `value`. + * @param {Object} [stack] Tracks traversed objects and their clone counterparts. + * @returns {*} Returns the cloned value. + */ + function baseClone(value, isDeep, isFull, customizer, key, object, stack) { + var result; + if (customizer) { + result = object ? customizer(value, key, object, stack) : customizer(value); + } + if (result !== undefined) { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return copyArray(value, result); + } + } else { + var tag = getTag(value), + isFunc = tag == funcTag || tag == genTag; + + if (isBuffer(value)) { + return cloneBuffer(value, isDeep); + } + if (tag == objectTag || tag == argsTag || (isFunc && !object)) { + if (isHostObject(value)) { + return object ? value : {}; + } + result = initCloneObject(isFunc ? {} : value); + if (!isDeep) { + return copySymbols(value, baseAssign(result, value)); + } + } else { + if (!cloneableTags[tag]) { + return object ? value : {}; + } + result = initCloneByTag(value, tag, baseClone, isDeep); + } + } + // Check for circular references and return its corresponding clone. + stack || (stack = new Stack); + var stacked = stack.get(value); + if (stacked) { + return stacked; + } + stack.set(value, result); + + if (!isArr) { + var props = isFull ? getAllKeys(value) : keys(value); + } + arrayEach(props || value, function(subValue, key) { + if (props) { + key = subValue; + subValue = value[key]; + } + // Recursively populate clone (susceptible to call stack limits). + assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack)); + }); + return result; + } + + /** + * The base implementation of `_.create` without support for assigning + * properties to the created object. + * + * @private + * @param {Object} prototype The object to inherit from. + * @returns {Object} Returns the new object. + */ + function baseCreate(proto) { + return isObject(proto) ? objectCreate(proto) : {}; + } + + /** + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. + */ + function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); + } + + /** + * The base implementation of `getTag`. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ + function baseGetTag(value) { + return objectToString.call(value); + } + + /** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ + function baseIsNative(value) { + if (!isObject(value) || isMasked(value)) { + return false; + } + var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); + } + + /** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; + } + + /** + * Creates a clone of `buffer`. + * + * @private + * @param {Buffer} buffer The buffer to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Buffer} Returns the cloned buffer. + */ + function cloneBuffer(buffer, isDeep) { + if (isDeep) { + return buffer.slice(); + } + var result = new buffer.constructor(buffer.length); + buffer.copy(result); + return result; + } + + /** + * Creates a clone of `arrayBuffer`. + * + * @private + * @param {ArrayBuffer} arrayBuffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. + */ + function cloneArrayBuffer(arrayBuffer) { + var result = new arrayBuffer.constructor(arrayBuffer.byteLength); + new Uint8Array(result).set(new Uint8Array(arrayBuffer)); + return result; + } + + /** + * Creates a clone of `dataView`. + * + * @private + * @param {Object} dataView The data view to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned data view. + */ + function cloneDataView(dataView, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; + return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); + } + + /** + * Creates a clone of `map`. + * + * @private + * @param {Object} map The map to clone. + * @param {Function} cloneFunc The function to clone values. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned map. + */ + function cloneMap(map, isDeep, cloneFunc) { + var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map); + return arrayReduce(array, addMapEntry, new map.constructor); + } + + /** + * Creates a clone of `regexp`. + * + * @private + * @param {Object} regexp The regexp to clone. + * @returns {Object} Returns the cloned regexp. + */ + function cloneRegExp(regexp) { + var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); + result.lastIndex = regexp.lastIndex; + return result; + } + + /** + * Creates a clone of `set`. + * + * @private + * @param {Object} set The set to clone. + * @param {Function} cloneFunc The function to clone values. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned set. + */ + function cloneSet(set, isDeep, cloneFunc) { + var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set); + return arrayReduce(array, addSetEntry, new set.constructor); + } + + /** + * Creates a clone of the `symbol` object. + * + * @private + * @param {Object} symbol The symbol object to clone. + * @returns {Object} Returns the cloned symbol object. + */ + function cloneSymbol(symbol) { + return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; + } + + /** + * Creates a clone of `typedArray`. + * + * @private + * @param {Object} typedArray The typed array to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned typed array. + */ + function cloneTypedArray(typedArray, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; + return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); + } + + /** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ + function copyArray(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; + } + + /** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property identifiers to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. + */ + function copyObject(source, props, object, customizer) { + object || (object = {}); + + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index]; + + var newValue = undefined; + + assignValue(object, key, newValue === undefined ? source[key] : newValue); + } + return object; + } + + /** + * Copies own symbol properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ + function copySymbols(source, object) { + return copyObject(source, getSymbols(source), object); + } + + /** + * Creates an array of own enumerable property names and symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ + function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); + } + + /** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ + function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; + } + + /** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ + function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; + } + + /** + * Creates an array of the own enumerable symbol properties of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ + var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray; + + /** + * Gets the `toStringTag` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ + var getTag = baseGetTag; + + // Fallback for data views, maps, sets, and weak maps in IE 11, + // for data views in Edge < 14, and promises in Node.js. + if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || + (Map && getTag(new Map) != mapTag) || + (Promise && getTag(Promise.resolve()) != promiseTag) || + (Set && getTag(new Set) != setTag) || + (WeakMap && getTag(new WeakMap) != weakMapTag)) { + getTag = function(value) { + var result = objectToString.call(value), + Ctor = result == objectTag ? value.constructor : undefined, + ctorString = Ctor ? toSource(Ctor) : undefined; + + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: return dataViewTag; + case mapCtorString: return mapTag; + case promiseCtorString: return promiseTag; + case setCtorString: return setTag; + case weakMapCtorString: return weakMapTag; + } + } + return result; + }; + } + + /** + * Initializes an array clone. + * + * @private + * @param {Array} array The array to clone. + * @returns {Array} Returns the initialized clone. + */ + function initCloneArray(array) { + var length = array.length, + result = array.constructor(length); + + // Add properties assigned by `RegExp#exec`. + if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { + result.index = array.index; + result.input = array.input; + } + return result; + } + + /** + * Initializes an object clone. + * + * @private + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. + */ + function initCloneObject(object) { + return (typeof object.constructor == 'function' && !isPrototype(object)) + ? baseCreate(getPrototype(object)) + : {}; + } + + /** + * Initializes an object clone based on its `toStringTag`. + * + * **Note:** This function only supports cloning values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to clone. + * @param {string} tag The `toStringTag` of the object to clone. + * @param {Function} cloneFunc The function to clone values. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the initialized clone. + */ + function initCloneByTag(object, tag, cloneFunc, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag: + return cloneArrayBuffer(object); + + case boolTag: + case dateTag: + return new Ctor(+object); + + case dataViewTag: + return cloneDataView(object, isDeep); + + case float32Tag: case float64Tag: + case int8Tag: case int16Tag: case int32Tag: + case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: + return cloneTypedArray(object, isDeep); + + case mapTag: + return cloneMap(object, isDeep, cloneFunc); + + case numberTag: + case stringTag: + return new Ctor(object); + + case regexpTag: + return cloneRegExp(object); + + case setTag: + return cloneSet(object, isDeep, cloneFunc); + + case symbolTag: + return cloneSymbol(object); + } + } + + /** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ + function isIndex(value, length) { + length = length == null ? MAX_SAFE_INTEGER : length; + return !!length && + (typeof value == 'number' || reIsUint.test(value)) && + (value > -1 && value % 1 == 0 && value < length); + } + + /** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ + function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); + } + + /** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ + function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); + } + + /** + * Checks if `value` is likely a prototype object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + */ + function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; + + return value === proto; + } + + /** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to process. + * @returns {string} Returns the source code. + */ + function toSource(func) { + if (func != null) { + try { + return funcToString.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; + } + + /** + * This method is like `_.clone` except that it recursively clones `value`. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Lang + * @param {*} value The value to recursively clone. + * @returns {*} Returns the deep cloned value. + * @see _.clone + * @example + * + * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * + * var deep = _.cloneDeep(objects); + * console.log(deep[0] === objects[0]); + * // => false + */ + function cloneDeep(value) { + return baseClone(value, true, true); + } + + /** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ + function eq(value, other) { + return value === other || (value !== value && other !== other); + } + + /** + * Checks if `value` is likely an `arguments` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ + function isArguments(value) { + // Safari 8.1 makes `arguments.callee` enumerable in strict mode. + return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && + (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); + } + + /** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ + var isArray = Array.isArray; + + /** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ + function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); + } + + /** + * This method is like `_.isArrayLike` except that it also checks if `value` + * is an object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. + * @example + * + * _.isArrayLikeObject([1, 2, 3]); + * // => true + * + * _.isArrayLikeObject(document.body.children); + * // => true + * + * _.isArrayLikeObject('abc'); + * // => false + * + * _.isArrayLikeObject(_.noop); + * // => false + */ + function isArrayLikeObject(value) { + return isObjectLike(value) && isArrayLike(value); + } + + /** + * Checks if `value` is a buffer. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. + * @example + * + * _.isBuffer(new Buffer(2)); + * // => true + * + * _.isBuffer(new Uint8Array(2)); + * // => false + */ + var isBuffer = nativeIsBuffer || stubFalse; + + /** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ + function isFunction(value) { + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 8-9 which returns 'object' for typed array and other constructors. + var tag = isObject(value) ? objectToString.call(value) : ''; + return tag == funcTag || tag == genTag; + } + + /** + * Checks if `value` is a valid array-like length. + * + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ + function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + } + + /** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ + function isObject(value) { + var type = typeof value; + return !!value && (type == 'object' || type == 'function'); + } + + /** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ + function isObjectLike(value) { + return !!value && typeof value == 'object'; + } + + /** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ + function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); + } + + /** + * This method returns a new empty array. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {Array} Returns the new empty array. + * @example + * + * var arrays = _.times(2, _.stubArray); + * + * console.log(arrays); + * // => [[], []] + * + * console.log(arrays[0] === arrays[1]); + * // => false + */ + function stubArray() { + return []; + } + + /** + * This method returns `false`. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {boolean} Returns `false`. + * @example + * + * _.times(2, _.stubFalse); + * // => [false, false] + */ + function stubFalse() { + return false; + } + + module.exports = cloneDeep; +} (lodash_clonedeep, lodash_clonedeep.exports)); + +var lodash_clonedeepExports = lodash_clonedeep.exports; +const cloneDeep = /*@__PURE__*/getDefaultExportFromCjs(lodash_clonedeepExports); + +Object.defineProperty(filter, "__esModule", { + value: true +}); +filter.mergeVerseData = filter.convertStringToVerseObjects = filter.removeMarker = void 0; + +var _lodash = _interopRequireDefault(lodash_clonedeepExports); + +var _usfmToJson = usfmToJson; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + +/* eslint-disable no-use-before-define,brace-style */ + +/* Method to filter specified usfm marker from a string + * @param {string} string - The string to remove specfic marker from + * @return {string} + */ +var removeMarker = function removeMarker() { + var string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + var output = string; // default results + + if (string) { + var verseObjects = convertStringToVerseObjects(string); + + if (verseObjects) { + output = mergeVerseData(verseObjects); // get displayed text from verseObjects + } + } + + return output; +}; +/** + * takes the text of a verse and converts to verseObjects + * @param {String} text - verse text to convert + * @return {Object|*} verseObjects for verseText + */ + + +filter.removeMarker = removeMarker; + +var convertStringToVerseObjects = function convertStringToVerseObjects(text) { + // first parse to verse objects + var jsonData = (0, _usfmToJson.usfmToJSON)('\\v 1 ' + text, { + chunk: true + }); + var verseObjects = jsonData && jsonData.verses && jsonData.verses["1"] && jsonData.verses["1"].verseObjects; + return verseObjects; +}; +/** + * parse a single child + * @param {Object} child + * @param {String} text + * @param {String} wordSpacing + * @return {{wordSpacing: string, text: string}} + */ + + +filter.convertStringToVerseObjects = convertStringToVerseObjects; + +var parseChild = function parseChild(child, text, wordSpacing) { + switch (child.type) { + case 'word': + text += wordSpacing + child.text; + wordSpacing = ' '; + break; + + case 'milestone': + text += wordSpacing + parseMilestone$1(child); + wordSpacing = ' '; + break; + + default: + if (child.text) { + text += child.text; + var lastChar = text.substr(-1); + + if (lastChar !== "," && lastChar !== '.' && lastChar !== '?' && lastChar !== ';') { + // legacy support, make sure padding before word + wordSpacing = ''; + } + } + + if (child.children) { + var length = child.children.length; + + for (var i = 0; i < length; i++) { + var childChild = child.children[i]; + + var __ret = parseChild(childChild, text, wordSpacing); + + text = __ret.text; + wordSpacing = __ret.wordSpacing; + } + } + + break; + } + + return { + text: text, + wordSpacing: wordSpacing + }; +}; +/** + * dive down into milestone to extract words and text + * @param {Object} verseObject - milestone to parse + * @return {string} text content of milestone + */ + + +var parseMilestone$1 = function parseMilestone(verseObject) { + var text = verseObject.text || ""; + var wordSpacing = ''; + var length = verseObject.children.length; + + for (var i = 0; i < length; i++) { + var child = verseObject.children[i]; + + var __ret = parseChild(child, text, wordSpacing); + + text = __ret.text; + wordSpacing = __ret.wordSpacing; + + if (child.nextChar) { + text += child.nextChar; + } + } + + if (verseObject.nextChar) { + text += verseObject.nextChar; + } + + return text; +}; +/** + * get text from word and milestone markers + * @param {Object} verseObject - to parse + * @param {String} wordSpacing - spacing to use before next word + * @return {*} new verseObject and word spacing + */ + + +var replaceWordsAndMilestones$1 = function replaceWordsAndMilestones(verseObject, wordSpacing) { + var text = ''; + + if (verseObject.type === 'word') { + text = wordSpacing + verseObject.text; + } else if (verseObject.children) { + text = wordSpacing + parseMilestone$1(verseObject); + } + + if (text) { + // replace with text object + verseObject = { + type: "text", + text: text + }; + wordSpacing = ' '; + } else { + wordSpacing = ' '; + + if (verseObject.nextChar) { + wordSpacing = ''; // no need for spacing before next word if this item has it + } else if (verseObject.text) { + var lastChar = verseObject.text.substr(-1); + + if (![',', '.', '?', ';'].includes(lastChar)) { + // legacy support, make sure padding before next word if punctuation + wordSpacing = ''; + } + } + + if (verseObject.children) { + // handle nested + var verseObject_ = (0, _lodash["default"])(verseObject); + var wordSpacing_ = ''; + var length = verseObject.children.length; + + for (var i = 0; i < length; i++) { + var flattened = replaceWordsAndMilestones(verseObject.children[i], wordSpacing_); + wordSpacing_ = flattened.wordSpacing; + verseObject_.children[i] = flattened.verseObject; + } + + verseObject = verseObject_; + } + } + + return { + verseObject: verseObject, + wordSpacing: wordSpacing + }; +}; +/** + * @description merge verse data into a string + * @param {Object|Array} verseData - verse objects to be merged + * @param {array} filter - Optional filter to get a specific type of word object type. + * @return {String} - the merged verse object string + */ + + +var mergeVerseData = function mergeVerseData(verseData) { + if (verseData.verseObjects) { + verseData = verseData.verseObjects; + } + + var flattenedData = []; + + if (Array.isArray(verseData)) { + var wordSpacing = ''; + var _length = verseData.length; + + for (var i = 0; i < _length; i++) { + var verseObject = verseData[i]; + var flattened = replaceWordsAndMilestones$1(verseObject, wordSpacing); + wordSpacing = flattened.wordSpacing; + flattenedData.push(flattened.verseObject); + } + + verseData = { + // use flattened data + verseObjects: flattenedData + }; + } + + var verseText = ""; + var length = flattenedData.length; + + for (var _i = 0; _i < length; _i++) { + var verseObj = flattenedData[_i]; + + if (verseObj.text) { + if (verseObj.tag) { + var lastChar = verseText && verseText[verseText.length - 1]; + + if (!['', ' ', '\n'].includes(lastChar)) { + verseText += ' '; + } + } + + verseText += verseObj.text; + } + + if (verseObj.nextChar) { + verseText += verseObj.nextChar; + } + } + + return verseText; +}; + +filter.mergeVerseData = mergeVerseData; + +lib.toJSON = usfmToJson.usfmToJSON; +lib.toUSFM = jsonToUsfm.jsonToUSFM; +lib.removeMarker = filter.removeMarker; + +/* eslint-disable no-async-promise-executor, no-throw-literal */ + +/** + * dive down into milestone to extract words and text + * @param {Object} verseObject - milestone to parse + * @return {string} text content of milestone + */ +const parseMilestone = verseObject => { + let text = verseObject.text || ''; + let wordSpacing = ''; + const length = verseObject.children ? verseObject.children.length : 0; + + for (let i = 0; i < length; i++) { + let child = verseObject.children[i]; + + switch (child.type) { + case 'word': + text += wordSpacing + child.text; + wordSpacing = ' '; + break; + + case 'milestone': + text += wordSpacing + parseMilestone(child); + wordSpacing = ' '; + break; + + default: + if (child.text) { + text += child.text; + const lastChar = text.substr(-1); + + if ((lastChar !== ',') && (lastChar !== '.') && (lastChar !== '?') && (lastChar !== ';')) { // legacy support, make sure padding before word + wordSpacing = ''; + } + } + break; + } + } + return text; +}; + +/** + * get text from word and milestone markers + * @param {Object} verseObject - to parse + * @param {String} wordSpacing - spacing to use before next word + * @return {*} new verseObject and word spacing + */ +const replaceWordsAndMilestones = (verseObject, wordSpacing) => { + let text = ''; + + if (verseObject.type === 'word') { + text = wordSpacing + verseObject.text; + } else if (verseObject.type === 'milestone') { + text = wordSpacing + parseMilestone(verseObject); + } + + if (text) { // replace with text object + verseObject = { + type: 'text', + text, + }; + wordSpacing = ' '; + } else { + wordSpacing = ' '; + + if (verseObject.nextChar) { + wordSpacing = ''; // no need for spacing before next word if this item has it + } else if (verseObject.text) { + const lastChar = verseObject.text.substr(-1); + + if (![',', '.', '?', ';'].includes(lastChar)) { // legacy support, make sure padding before next word if punctuation + wordSpacing = ''; + } + } + + if (verseObject.children) { // handle nested + const verseObject_ = cloneDeep(verseObject); + let wordSpacing_ = ''; + const length = verseObject.children.length; + + for (let i = 0; i < length; i++) { + const flattened = + replaceWordsAndMilestones(verseObject.children[i], wordSpacing_); + wordSpacing_ = flattened.wordSpacing; + verseObject_.children[i] = flattened.verseObject; + } + verseObject = verseObject_; + } + } + return { verseObject, wordSpacing }; +}; + +/** + * converts verse from verse objects to USFM string + * @param verseData + * @return {string} + */ +function convertVerseDataToUSFM(verseData) { + const outputData = { + 'chapters': {}, + 'headers': [], + 'verses': { '1': verseData }, + }; + const USFM = lib.toUSFM(outputData, { chunk: true, forcedNewLines: true }); + const split = USFM.split('\\v 1'); + + if (split.length > 1) { + let content = split[1]; + + if (content.substr(0, 1) === ' ') { // remove space separator + content = content.substr(1); + } + return content; + } + return ''; // error on JSON to USFM +} + +/** + * @description remove milestones and word markers + * @param {Object|Array} verseData + * @return {Object} + */ +function removeMilestonesAndWordMarkers(verseData) { + const verseObjects = verseData?.verseObjects || verseData; + if (verseObjects) { + let wordSpacing = ''; + const flattenedData = []; + const length = verseObjects.length; + + for (let i = 0; i < length; i++) { + const verseObject = verseObjects[i]; + const flattened = replaceWordsAndMilestones(verseObject, wordSpacing); + wordSpacing = flattened.wordSpacing; + flattenedData.push(flattened.verseObject); + } + verseData = { // use flattened data + verseObjects: flattenedData, + }; + } + return verseData; +} + +/** + * @description convert verse from verse objects to USFM string, removing milestones and word markers + * @param {Object|Array} verseData + * @return {String} + */ +const getUsfmForVerseContent = (verseData) => { + verseData = removeMilestonesAndWordMarkers(verseData); + return convertVerseDataToUSFM(verseData); +}; + +const flattenChapterData = (chapterData) => { + let usfmStr = ''; + + if ("front" in chapterData) { + usfmStr += getUsfmForVerseContent(chapterData["front"]); + } + Object.keys(chapterData).forEach((verseNum) => { + if (verseNum === "front") { + return; + } + const verseData = chapterData[verseNum]; + usfmStr += `\\v ${verseNum} ` + getUsfmForVerseContent(verseData); + }); + + return usfmStr; +}; + +const removeAlignments = (usfmContent) => { + const usfmJSON = lib.toJSON(usfmContent); + let usfmStr = ''; + + usfmJSON.headers.forEach(header => { + if (header.type == "text") { + usfmStr += `${header.text}\n`; + } else if (header.tag && header.content) { + if (header.content !== "\\*") { + header.content = ` ${header.content}`; + } + usfmStr += `\\${header.tag}${header.content}\n`; + } + }); + + if ("front" in usfmJSON.chapters) { + usfmStr += flattenChapterData(usfmJSON.chapters["front"]); + } + Object.keys(usfmJSON.chapters).forEach(chapterNum => { + if (chapterNum === "front") { + return; + } + usfmStr += `\n\\c ${chapterNum}\n` + flattenChapterData(usfmJSON.chapters[chapterNum]); + }); + + return usfmStr; +}; + +function downloadUnalignedUSFM(owner, repo, ref, statusElement) { + if (!owner || !repo || !ref) { + console.log('owner, repo and ref must be provided'); + if (statusElement) { + statusElement.textContent = 'owner, repo and ref must be provided'; + } + } else { + const dcsZipUrl = `/${owner}/${repo}/archive/${ref}.zip`; + + // Step 2: Fetch Zip File from DCS + axios + .get(dcsZipUrl, { responseType: 'blob' }) + .then((response) => JSZip.loadAsync(response.data)) // Step 3: Load Zip File with JSZip + .then((zip) => { + const newZip = new JSZip(); + const filePromises = []; + let count = 0; + const total = zip.filter((path) => path.endsWith('.usfm')).length; + if (!total) { + statusElement.textContent = 'No USFM files found in the given repo'; + throw new Error('No USFM files found'); + } + + zip.forEach((relativePath, file) => { + if (relativePath.endsWith('.usfm')) { + // Step 4: Process `.usfm` Files + const filePromise = file.async('string').then((content) => { + console.log(`Processing ${owner}/` + relativePath); + const unalignedUsfm = removeAlignments(content); + newZip.file(relativePath, unalignedUsfm); + count++; + if (statusElement) { + statusElement.textContent = `Processing ${count} of ${total} USFM files...`; + } + }); + filePromises.push(filePromise); + } + }); + return Promise.all(filePromises).then(() => newZip); + }) + .then((newZip) => newZip.generateAsync({ type: 'blob' })) // Step 5: Generate Modified Zip File + .then((blob) => { + const downloadUrl = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = downloadUrl; + a.download = `${repo}-${ref}-unaligned_usfm.zip`; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + if (statusElement) { + statusElement.textContent = ''; + } + }) + .catch((error) => console.error('Error processing USFM files:', error)); + } +} + +window.downloadUnalignedUSFM = downloadUnalignedUSFM; diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl index cbc23dce0e..0500b4c8a9 100644 --- a/templates/repo/branch/list.tmpl +++ b/templates/repo/branch/list.tmpl @@ -1,4 +1,9 @@ {{template "base/head" .}} + +{{if and .RepoDM (eq .RepoDM.Subject "Aligned Bible")}} + +{{end}} +
{{template "repo/header" .}}
@@ -172,6 +177,9 @@
{{end}} diff --git a/templates/repo/dcs_metadata.tmpl b/templates/repo/dcs_metadata.tmpl index 57e811567f..8f403822df 100644 --- a/templates/repo/dcs_metadata.tmpl +++ b/templates/repo/dcs_metadata.tmpl @@ -73,8 +73,8 @@ Validation Errors (JSON) {{end}} - - Preview + + Preview / PDF {{if or $.Permission.IsAdmin $.IsOrganizationOwner $.PageIsAdmin $.PageIsUserSettings}}