UNPKG

bible-ref-parse

Version:

Identifies and parses Bible references (like John 3:16) in over 40 languages.

1 lines 146 kB
(function(){var s,a,e,t,x={}.hasOwnProperty;s=function(){class s{constructor(){var a,e,t;for(a in this.options={},e=s.prototype.options)x.call(e,a)&&(t=e[a],this.options[a]=t);this.versification_system(this.options.versification_system)}parse(s){return this.reset(),this.s=s,s=this.replace_control_characters(s),[s,this.passage.books]=this.match_books(s),[this.entities]=this.match_passages(s),this}parse_with_context(s,a){var e;return this.reset(),[a,this.passage.books]=this.match_books(this.replace_control_characters(a)),[e,a]=this.match_passages(a),this.reset(),this.s=s,s=this.replace_control_characters(s),[s,this.passage.books]=this.match_books(s),this.passage.books.push({value:"",parsed:[],start_index:0,type:"context",context:a}),s=""+(this.passage.books.length-1)+"/9"+s,[this.entities]=this.match_passages(s),this}reset(){return this.s="",this.entities=[],this.passage?(this.passage.books=[],this.passage.indices={}):(this.passage=new a,this.passage.options=this.options,this.passage.translations=this.translations)}set_options(s){var a,e;for(a in s)x.call(s,a)&&(e=s[a],"include_apocrypha"===a||"versification_system"===a||"case_sensitive"===a?this[a](e):this.options[a]=e);return this}include_apocrypha(s){var a,t,r,n,i;if(null==s||!0!==s&&!1!==s)return this;for(n in this.options.include_apocrypha=s,this.regexps.books=this.regexps.get_books(s,this.options.case_sensitive),r=this.translations)x.call(r,n)&&"aliases"!==n&&"alternates"!==n&&(null==(a=this.translations[n]).chapters&&(a.chapters={}),null==(t=this.translations[n].chapters).Ps&&(t.Ps=e.shallow_clone_array(this.translations.default.chapters.Ps)),!0===s?(i=null!=this.translations[n].chapters.Ps151?this.translations[n].chapters.Ps151[0]:this.translations.default.chapters.Ps151[0],this.translations[n].chapters.Ps[150]=i):151===this.translations[n].chapters.Ps.length&&this.translations[n].chapters.Ps.pop());return this}versification_system(s){var a,t,r,n,i,o,l;if(null==s||null==this.translations[s])return this;if(null!=this.translations.alternates.default)if("default"===s)for(n in null!=this.translations.alternates.default.order&&(this.translations.default.order=e.shallow_clone(this.translations.alternates.default.order)),o=this.translations.alternates.default.chapters)x.call(o,n)&&(i=o[n],this.translations.default.chapters[n]=e.shallow_clone_array(i));else this.versification_system("default");if(null==(a=this.translations.alternates).default&&(a.default={order:null,chapters:{}}),"default"!==s&&null!=this.translations[s].order&&(null==(t=this.translations.alternates.default).order&&(t.order=e.shallow_clone(this.translations.default.order)),this.translations.default.order=e.shallow_clone(this.translations[s].order)),"default"!==s&&null!=this.translations[s].chapters)for(n in l=this.translations[s].chapters)x.call(l,n)&&(i=l[n],null==(r=this.translations.alternates.default.chapters)[n]&&(r[n]=e.shallow_clone_array(this.translations.default.chapters[n])),this.translations.default.chapters[n]=e.shallow_clone_array(i));return this.options.versification_system=s,this.include_apocrypha(this.options.include_apocrypha),this}case_sensitive(s){return null==s||"none"!==s&&"books"!==s||s===this.options.case_sensitive||(this.options.case_sensitive=s,this.regexps.books=this.regexps.get_books(this.options.include_apocrypha,s)),this}translation_info(s="default"){var a,t,r,n,i,o,l,u;for(a in null!=s&&null!=(null!=(o=this.translations.aliases[s])?o.alias:void 0)&&(s=this.translations.aliases[s].alias),null!=s&&null!=this.translations[s]||(s="default"),s!==(n=this.options.versification_system)&&this.versification_system(s),i={alias:s,books:[],chapters:{},order:e.shallow_clone(this.translations.default.order)},l=this.translations.default.chapters)x.call(l,a)&&(t=l[a],i.chapters[a]=e.shallow_clone_array(t));for(a in u=i.order)x.call(u,a)&&(r=u[a],i.books[r-1]=a);return s!==n&&this.versification_system(n),i}replace_control_characters(s){return s=s.replace(this.regexps.control," "),"replace"===this.options.non_latin_digits_strategy&&(s=(s=(s=(s=(s=(s=(s=(s=(s=(s=s.replace(/[٠۰߀०০੦૦୦0౦೦൦๐໐༠၀႐០᠐᥆᧐᪀᪐᭐᮰᱀᱐꘠꣐꤀꧐꩐꯰0]/g,"0")).replace(/[١۱߁१১੧૧୧௧౧೧൧๑໑༡၁႑១᠑᥇᧑᪁᪑᭑᮱᱁᱑꘡꣑꤁꧑꩑꯱1]/g,"1")).replace(/[٢۲߂२২੨૨୨௨౨೨൨๒໒༢၂႒២᠒᥈᧒᪂᪒᭒᮲᱂᱒꘢꣒꤂꧒꩒꯲2]/g,"2")).replace(/[٣۳߃३৩੩૩୩௩౩೩൩๓໓༣၃႓៣᠓᥉᧓᪃᪓᭓᮳᱃᱓꘣꣓꤃꧓꩓꯳3]/g,"3")).replace(/[٤۴߄४৪੪૪୪௪౪೪൪๔໔༤၄႔៤᠔᥊᧔᪄᪔᭔᮴᱄᱔꘤꣔꤄꧔꩔꯴4]/g,"4")).replace(/[٥۵߅५৫੫૫୫௫౫೫൫๕໕༥၅႕៥᠕᥋᧕᪅᪕᭕᮵᱅᱕꘥꣕꤅꧕꩕꯵5]/g,"5")).replace(/[٦۶߆६৬੬૬୬௬౬೬൬๖໖༦၆႖៦᠖᥌᧖᪆᪖᭖᮶᱆᱖꘦꣖꤆꧖꩖꯶6]/g,"6")).replace(/[٧۷߇७৭੭૭୭௭౭೭൭๗໗༧၇႗៧᠗᥍᧗᪇᪗᭗᮷᱇᱗꘧꣗꤇꧗꩗꯷7]/g,"7")).replace(/[٨۸߈८৮੮૮୮௮౮೮൮๘໘༨၈႘៨᠘᥎᧘᪈᪘᭘᮸᱈᱘꘨꣘꤈꧘꩘꯸8]/g,"8")).replace(/[٩۹߉९৯੯૯୯௯౯೯൯๙໙༩၉႙៩᠙᥏᧙᪉᪙᭙᮹᱉᱙꘩꣙꤉꧙꩙꯹9]/g,"9")),s}match_books(s){var a,e,t,x,r,n;for(e=[],x=0,r=(n=this.regexps.books).length;x<r&&(a=n[x],t=!1,s=s.replace(a.regexp,(function(s,x,r){var n;return t=!0,e.push({value:r,parsed:a.osis,type:"book"}),n=null!=a.extra?`/${a.extra}`:"",`${x}${e.length-1}${n}`})),!0!==t||!/^[\s\x1f\d:.,;\-\u2013\u2014]+$/.test(s));x++);return[s=s.replace(this.regexps.translations,(function(s){return e.push({value:s,parsed:s.toLowerCase(),type:"translation"}),`${e.length-1}`})),this.get_book_indices(e,s)]}get_book_indices(s,a){var e,t,x;for(e=0,x=/([\x1f\x1e])(\d+)(?:\/\d+)?\1/g;t=x.exec(a);)s[t[2]].start_index=t.index+e,e+=s[t[2]].value.length-t[0].length;return s}match_passages(s){var a,e,x,r,n,i,o,l,u,p,c,h;for(x=[],p={};n=this.regexps.escaped_passage.exec(s);)[r,l,e]=n,o=l.length,n.index+=r.length-o,/\s[2-9]\d\d\s*$|\s\d{4,}\s*$/.test(l)&&(l=l.replace(/\s+\d+\s*$/,"")),/[\d\x1f\x1e)]$/.test(l)||(l=this.replace_match_end(l)),"delete"===this.options.captive_end_digits_strategy&&(i=n.index+l.length,s.length>i&&/^\w/.test(s.substr(i,1))&&(l=l.replace(/[\s*]+\d+$/,"")),l=l.replace(/(\x1e[)\]]?)[\s*]*\d+$/,"$1")),h=""===(l=l.replace(/[A-Z]+/g,(function(s){return s.toLowerCase()}))).substr(0,1)?0:l.split("")[0].length,u={value:t.parse(l,{punctuation_strategy:this.options.punctuation_strategy}),type:"base",start_index:this.passage.books[e].start_index-h,match:l},"full"===this.options.book_alone_strategy&&"include"===this.options.book_range_strategy&&"b"===u.value[0].type&&(1===u.value.length||u.value.length>1&&"translation_sequence"===u.value[1].type)&&0===h&&(1===this.passage.books[e].parsed.length||this.passage.books[e].parsed.length>1&&"translation"===this.passage.books[e].parsed[1].type)&&/^[234]/.test(this.passage.books[e].parsed[0])&&this.create_book_range(s,u,e),[a,p]=this.passage.handle_obj(u),x=x.concat(a),(c=this.adjust_regexp_end(a,o,l.length))>0&&(this.regexps.escaped_passage.lastIndex-=c);return[x,p]}adjust_regexp_end(s,a,e){var t;return t=0,s.length>0?t=a-s[s.length-1].indices[1]-1:a!==e&&(t=a-e),t}replace_match_end(s){var a,e;for(e=s.length;a=this.regexps.match_end_split.exec(s);)e=a.index+a[0].length;return e<s.length&&(s=s.substr(0,e)),s}create_book_range(a,e,t){var x,r,n,i,o,l,u;for(x=[s.prototype.regexps.first,s.prototype.regexps.second,s.prototype.regexps.third],r=n=1,u=i=parseInt(this.passage.books[t].parsed[0].substr(0,1),10);1<=u?n<u:n>u;r=1<=u?++n:--n)if(l=r===i-1?s.prototype.regexps.range_and:s.prototype.regexps.range_only,null!=(o=a.match(RegExp(`(?:^|\\W)(${x[r-1]}\\s*${l}\\s*)\\x1f${t}\\x1f`,"i"))))return this.add_book_range_object(e,o,r);return!1}add_book_range_object(s,a,e){var t,x,r,n,i,o;if(r=a[1].length,s.value[0]={type:"b_range_pre",value:[{type:"b_pre",value:e.toString(),indices:[a.index,a.index+r]},s.value[0]],indices:[0,s.value[0].indices[1]+r]},s.value[0].value[1].indices[0]+=r,s.value[0].value[1].indices[1]+=r,s.start_index-=r,s.match=a[1]+s.match,1!==s.value.length){for(o=[],t=x=1,n=s.value.length;1<=n?x<n:x>n;t=1<=n?++x:--x)null!=s.value[t].value&&(null!=(null!=(i=s.value[t].value[0])?i.indices:void 0)&&(s.value[t].value[0].indices[0]+=r,s.value[t].value[0].indices[1]+=r),s.value[t].indices[0]+=r,o.push(s.value[t].indices[1]+=r));return o}}osis(){var s,a,e,t,x;for(t=[],s=0,a=(x=this.parsed_entities()).length;s<a;s++)(e=x[s]).osis.length>0&&t.push(e.osis);return t.join(",")}osis_and_translations(){var s,a,e,t,x;for(t=[],s=0,a=(x=this.parsed_entities()).length;s<a;s++)(e=x[s]).osis.length>0&&t.push([e.osis,e.translations.join(",")]);return t}osis_and_indices(){var s,a,e,t,x;for(t=[],s=0,a=(x=this.parsed_entities()).length;s<a;s++)(e=x[s]).osis.length>0&&t.push({osis:e.osis,translations:e.translations,indices:e.indices});return t}parsed_entities(){var s,a,e,t,x,r,n,i,o,l,u,p,c,h,g,_,d,f,v,b,y,k,m,A;for(h=[],a=t=0,_=this.entities.length;0<=_?t<_:t>_;a=0<=_?++t:--t)if((s=this.entities[a]).type&&"translation_sequence"===s.type&&h.length>0&&a===h[h.length-1].entity_id+1&&(h[h.length-1].indices[1]=s.absolute_indices[1]),null!=s.passages&&!("b"===s.type&&"ignore"===this.options.book_alone_strategy||"b_range"===s.type&&"ignore"===this.options.book_range_strategy||"context"===s.type)){if(A=[],k=null,null!=s.passages[0].translations)for(x=0,n=(d=s.passages[0].translations).length;x<n;x++)m=(null!=(f=(y=d[x]).osis)?f.length:void 0)>0?y.osis:"",null==k&&(k=y.alias),A.push(m);else A=[""],k="default";for(c=[],e=l=0,v=o=s.passages.length;0<=v?l<v:l>v;e=0<=v?++l:--l)null==(g=s.passages[e]).type&&(g.type=s.type),!1===g.valid.valid&&("ignore"===this.options.invalid_sequence_strategy&&"sequence"===s.type&&this.snap_sequence("ignore",s,c,e,o),"ignore"===this.options.invalid_passage_strategy)||("b"!==g.type&&"b_range"!==g.type||"ignore"!==this.options.book_sequence_strategy||"sequence"!==s.type?("b_range_start"!==g.type&&"range_end_b"!==g.type||"ignore"!==this.options.book_range_strategy||this.snap_range(s,e),null==g.absolute_indices&&(g.absolute_indices=s.absolute_indices),c.push({osis:g.valid.valid?this.to_osis(g.start,g.end,k):"",type:g.type,indices:g.absolute_indices,translations:A,start:g.start,end:g.end,enclosed_indices:g.enclosed_absolute_indices,entity_id:a,entities:[g]})):this.snap_sequence("book",s,c,e,o));if(0!==c.length)if(c.length>1&&"combine"===this.options.consecutive_combination_strategy&&(c=this.combine_consecutive_passages(c,k)),"separate"===this.options.sequence_combination_strategy)h=h.concat(c);else{for(b=[],null!=c[r=c.length-1].enclosed_indices&&c[r].enclosed_indices[1]>=0&&(s.absolute_indices[1]=c[r].enclosed_indices[1]),u=0,i=c.length;u<i;u++)(p=c[u]).osis.length>0&&b.push(p.osis);h.push({osis:b.join(","),indices:s.absolute_indices,translations:A,entity_id:a,entities:c})}}return h}to_osis(s,a,e){var t,x;return null==a.c&&null==a.v&&s.b===a.b&&null==s.c&&null==s.v&&"first_chapter"===this.options.book_alone_strategy&&(a.c=1),t={start:"",end:""},null==s.c&&(s.c=1),null==s.v&&(s.v=1),null==a.c&&(this.options.passage_existence_strategy.indexOf("c")>=0||null!=this.passage.translations[e].chapters[a.b]&&1===this.passage.translations[e].chapters[a.b].length?a.c=this.passage.translations[e].chapters[a.b].length:a.c=999),null==a.v&&(null!=this.passage.translations[e].chapters[a.b][a.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0?a.v=this.passage.translations[e].chapters[a.b][a.c-1]:a.v=999),this.options.include_apocrypha&&"b"===this.options.ps151_strategy&&(151===s.c&&"Ps"===s.b||151===a.c&&"Ps"===a.b)&&this.fix_ps151(s,a,e),"b"===this.options.osis_compaction_strategy&&1===s.c&&1===s.v&&(999===a.c&&999===a.v||a.c===this.passage.translations[e].chapters[a.b].length&&this.options.passage_existence_strategy.indexOf("c")>=0&&(999===a.v||a.v===this.passage.translations[e].chapters[a.b][a.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0))?(t.start=s.b,t.end=a.b):this.options.osis_compaction_strategy.length<=2&&1===s.v&&(999===a.v||a.v===this.passage.translations[e].chapters[a.b][a.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0)?(t.start=s.b+"."+s.c.toString(),t.end=a.b+"."+a.c.toString()):(t.start=s.b+"."+s.c.toString()+"."+s.v.toString(),t.end=a.b+"."+a.c.toString()+"."+a.v.toString()),x=t.start===t.end?t.start:t.start+"-"+t.end,null!=s.extra&&(x=s.extra+","+x),null!=a.extra&&(x+=","+a.extra),x}fix_ps151(s,a,e){var t;return"default"!==e&&null==(null!=(t=this.translations[e])?t.chapters.Ps151:void 0)&&this.passage.promote_book_to_translation("Ps151",e),151===s.c&&"Ps"===s.b?151===a.c&&"Ps"===a.b?(s.b="Ps151",s.c=1,a.b="Ps151",a.c=1):(s.extra=this.to_osis({b:"Ps151",c:1,v:s.v},{b:"Ps151",c:1,v:this.passage.translations[e].chapters.Ps151[0]},e),s.b="Prov",s.c=1,s.v=1):(a.extra=this.to_osis({b:"Ps151",c:1,v:1},{b:"Ps151",c:1,v:a.v},e),a.c=150,a.v=this.passage.translations[e].chapters.Ps[149])}combine_consecutive_passages(s,a){var e,t,x,r,n,i,o,l,u,p,c;for(l=[],u={},e=-1,t=!1,x=n=0,c=i=s.length-1;0<=c?n<=c:n>=c;x=0<=c?++n:--n)(o=s[x]).osis.length>0?(p=l.length-1,r=!1,o.enclosed_indices[0]!==e&&(e=o.enclosed_indices[0]),e>=0&&(x===i||s[x+1].enclosed_indices[0]!==o.enclosed_indices[0])&&(r=!0,t=!0),this.is_verse_consecutive(u,o.start,a)?(l[p].end=o.end,l[p].is_enclosed_last=r,l[p].indices[1]=o.indices[1],l[p].enclosed_indices[1]=o.enclosed_indices[1],l[p].osis=this.to_osis(l[p].start,o.end,a)):l.push(o),u={b:o.end.b,c:o.end.c,v:o.end.v}):(l.push(o),u={});return t&&this.snap_enclosed_indices(l),l}snap_enclosed_indices(s){var a,e,t;for(a=0,e=s.length;a<e;a++)null!=(t=s[a]).is_enclosed_last&&(t.enclosed_indices[0]<0&&t.is_enclosed_last&&(t.indices[1]=t.enclosed_indices[1]),delete t.is_enclosed_last);return s}is_verse_consecutive(s,a,e){var t;if(null==s.b)return!1;if(t=null!=this.passage.translations[e].order?this.passage.translations[e].order:this.passage.translations.default.order,s.b===a.b){if(s.c===a.c){if(s.v===a.v-1)return!0}else if(1===a.v&&s.c===a.c-1&&s.v===this.passage.translations[e].chapters[s.b][s.c-1])return!0}else if(1===a.c&&1===a.v&&t[s.b]===t[a.b]-1&&s.c===this.passage.translations[e].chapters[s.b].length&&s.v===this.passage.translations[e].chapters[s.b][s.c-1])return!0;return!1}snap_range(s,a){var e,t,r,n,i,o,l,u;for(t in"b_range_start"===s.type||"sequence"===s.type&&"b_range_start"===s.passages[a].type?(e=1,i="end",u="b_range_start"):(e=0,i="start",u="range_end_b"),o="end"===i?"start":"end",n=s.passages[a][o])x.call(n,t)&&(s.passages[a][o][t]=s.passages[a][i][t]);return"sequence"===s.type?(a>=s.value.length&&(a=s.value.length-1),null!=(r=this.passage.pluck(u,s.value[a]))&&(l=this.snap_range(r,0),0===a?s.absolute_indices[0]=l.absolute_indices[0]:s.absolute_indices[1]=l.absolute_indices[1])):(s.original_type=s.type,s.type=s.value[e].type,s.absolute_indices=[s.value[e].absolute_indices[0],s.value[e].absolute_indices[1]]),s}snap_sequence(s,a,e,t,x){var r;return(r=a.passages[t]).absolute_indices[0]===a.absolute_indices[0]&&t<x-1&&this.get_snap_sequence_i(a.passages,t,x)!==t?(a.absolute_indices[0]=a.passages[t+1].absolute_indices[0],this.remove_absolute_indices(a.passages,t+1)):r.absolute_indices[1]===a.absolute_indices[1]&&t>0?a.absolute_indices[1]=e.length>0?e[e.length-1].indices[1]:a.passages[t-1].absolute_indices[1]:"book"===s&&t<x-1&&!this.starts_with_book(a.passages[t+1])&&(a.passages[t+1].absolute_indices[0]=r.absolute_indices[0]),a}get_snap_sequence_i(s,a,e){var t,x,r,n;for(t=x=r=a+1,n=e;r<=n?x<n:x>n;t=r<=n?++x:--x){if(this.starts_with_book(s[t]))return t;if(s[t].valid.valid)return a}return a}starts_with_book(s){return"b"===s.type.substr(0,1)||("range"===s.type||"ff"===s.type)&&"b"===s.start.type.substr(0,1)}remove_absolute_indices(s,a){var e,t,x,r,n,i;if(s[a].enclosed_absolute_indices[0]<0)return!1;for([i,e]=s[a].enclosed_absolute_indices,t=0,x=(n=s.slice(a)).length;t<x&&((r=n[t]).enclosed_absolute_indices[0]===i&&r.enclosed_absolute_indices[1]===e);t++)r.enclosed_absolute_indices=[-1,-1];return!0}}return s.prototype.s="",s.prototype.entities=[],s.prototype.passage=null,s.prototype.regexps={},s.prototype.options={consecutive_combination_strategy:"combine",osis_compaction_strategy:"b",book_sequence_strategy:"ignore",invalid_sequence_strategy:"ignore",sequence_combination_strategy:"combine",punctuation_strategy:"us",invalid_passage_strategy:"ignore",non_latin_digits_strategy:"ignore",passage_existence_strategy:"bcv",zero_chapter_strategy:"error",zero_verse_strategy:"error",single_chapter_1_strategy:"chapter",book_alone_strategy:"ignore",book_range_strategy:"ignore",captive_end_digits_strategy:"delete",end_range_digits_strategy:"verse",include_apocrypha:!1,ps151_strategy:"c",versification_system:"default",case_sensitive:"none"},s}.call(this),this.bcv_parser=s,a=function(){class s{handle_array(s,a=[],e={}){var t,x,r;for(t=0,x=s.length;t<x;t++)if(null!=(r=s[t])){if("stop"===r.type)break;[a,e]=this.handle_obj(r,a,e)}return[a,e]}handle_obj(s,a,e){return null!=s.type&&null!=this[s.type]?this[s.type](s,a,e):[a,e]}b(s,a,t){var x,r,n,i,o,l,u;for(s.start_context=e.shallow_clone(t),s.passages=[],x=[],n=0,i=(l=this.books[s.value].parsed).length;n<i;n++)o={start:{b:r=l[n]},end:{b:r},valid:u=this.validate_ref(s.start_context.translations,{b:r})},0===s.passages.length&&u.valid?s.passages.push(o):x.push(o);return 0===s.passages.length&&s.passages.push(x.shift()),x.length>0&&(s.passages[0].alternates=x),null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),a.push(s),t={b:s.passages[0].start.b},null!=s.start_context.translations&&(t.translations=s.start_context.translations),[a,t]}b_range(s,a,e){return this.range(s,a,e)}b_range_pre(s,a,t){var x,r,n;return s.start_context=e.shallow_clone(t),s.passages=[],x=this.pluck("b",s.value),[[r],t]=this.b(x,[],t),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),n={b:s.value[0].value+r.passages[0].start.b.substr(1),type:"b"},s.passages=[{start:n,end:r.passages[0].end,valid:r.passages[0].valid}],null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),a.push(s),[a,t]}b_range_start(s,a,e){return this.range(s,a,e)}base(s,a,e){return this.indices=this.calculate_indices(s.match,s.start_index),this.handle_array(s.value,a,e)}bc(s,a,t){var x,r,n,i,o,l,u,p,c;for(s.start_context=e.shallow_clone(t),s.passages=[],this.reset_context(t,["b","c","v"]),n=this.pluck("c",s.value).value,x=[],o=0,l=(p=this.books[this.pluck("b",s.value).value].parsed).length;o<l;o++)i="c",u={start:{b:r=p[o]},end:{b:r},valid:c=this.validate_ref(s.start_context.translations,{b:r,c:n})},(c.messages.start_chapter_not_exist_in_single_chapter_book||c.messages.start_chapter_1)&&(u.valid=this.validate_ref(s.start_context.translations,{b:r,v:n}),c.messages.start_chapter_not_exist_in_single_chapter_book&&(u.valid.messages.start_chapter_not_exist_in_single_chapter_book=1),u.start.c=1,u.end.c=1,i="v"),u.start[i]=n,[u.start.c,u.start.v]=this.fix_start_zeroes(u.valid,u.start.c,u.start.v),null==u.start.v&&delete u.start.v,u.end[i]=u.start[i],0===s.passages.length&&u.valid.valid?s.passages.push(u):x.push(u);return 0===s.passages.length&&s.passages.push(x.shift()),x.length>0&&(s.passages[0].alternates=x),null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),this.set_context_from_object(t,["b","c","v"],s.passages[0].start),a.push(s),[a,t]}bc_title(s,a,t){var x,r,n,i,o;if(s.start_context=e.shallow_clone(t),[[x],t]=this.bc(this.pluck("bc",s.value),[],t),"Ps"!==x.passages[0].start.b.substr(0,2)&&null!=x.passages[0].alternates)for(r=n=0,i=x.passages[0].alternates.length;0<=i?n<i:n>i;r=0<=i?++n:--n)if("Ps"===x.passages[0].alternates[r].start.b.substr(0,2)){x.passages[0]=x.passages[0].alternates[r];break}return"Ps"!==x.passages[0].start.b.substr(0,2)?(a.push(x),[a,t]):(this.books[this.pluck("b",x.value).value].parsed=["Ps"],null==(o=this.pluck("title",s.value))&&(o=this.pluck("v",s.value)),s.value[1]={type:"v",value:[{type:"integer",value:1,indices:o.indices}],indices:o.indices},s.type="bcv",this.bcv(s,a,s.start_context))}bcv(s,a,t){var x,r,n,i,o,l,u,p,c,h;for(s.start_context=e.shallow_clone(t),s.passages=[],this.reset_context(t,["b","c","v"]),n=this.pluck("bc",s.value),i=this.pluck("c",n.value).value,c=this.pluck("v",s.value).value,x=[],o=0,l=(p=this.books[this.pluck("b",n.value).value].parsed).length;o<l;o++)r=p[o],h=this.validate_ref(s.start_context.translations,{b:r,c:i,v:c}),[i,c]=this.fix_start_zeroes(h,i,c),u={start:{b:r,c:i,v:c},end:{b:r,c:i,v:c},valid:h},0===s.passages.length&&h.valid?s.passages.push(u):x.push(u);return 0===s.passages.length&&s.passages.push(x.shift()),x.length>0&&(s.passages[0].alternates=x),null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),this.set_context_from_object(t,["b","c","v"],s.passages[0].start),a.push(s),[a,t]}bv(s,a,t){var x,r,n;return s.start_context=e.shallow_clone(t),[x,n]=s.value,r={indices:s.indices,value:[{type:"bc",value:[x,{type:"c",value:[{type:"integer",value:1}]}]},n]},[[r],t]=this.bcv(r,[],t),s.passages=r.passages,null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),a.push(s),[a,t]}c(s,a,t){var x,r;return s.start_context=e.shallow_clone(t),x="integer"===s.type?s.value:this.pluck("integer",s.value).value,!(r=this.validate_ref(s.start_context.translations,{b:t.b,c:x})).valid&&r.messages.start_chapter_not_exist_in_single_chapter_book?this.v(s,a,t):([x]=this.fix_start_zeroes(r,x),s.passages=[{start:{b:t.b,c:x},end:{b:t.b,c:x},valid:r}],null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),a.push(s),t.c=x,this.reset_context(t,["v"]),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),[a,t])}c_psalm(s,a,e){var t;return s.type="bc",t=parseInt(this.books[s.value].value.match(/^\d+/)[0],10),s.value=[{type:"b",value:s.value,indices:s.indices},{type:"c",value:[{type:"integer",value:t,indices:s.indices}],indices:s.indices}],this.bc(s,a,e)}c_title(s,a,t){var x;return s.start_context=e.shallow_clone(t),"Ps"!==t.b?this.c(s.value[0],a,t):(x=this.pluck("title",s.value),s.value[1]={type:"v",value:[{type:"integer",value:1,indices:x.indices}],indices:x.indices},s.type="cv",this.cv(s,a,s.start_context))}cv(s,a,t){var x,r,n;return s.start_context=e.shallow_clone(t),x=this.pluck("c",s.value).value,r=this.pluck("v",s.value).value,n=this.validate_ref(s.start_context.translations,{b:t.b,c:x,v:r}),[x,r]=this.fix_start_zeroes(n,x,r),s.passages=[{start:{b:t.b,c:x,v:r},end:{b:t.b,c:x,v:r},valid:n}],null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),a.push(s),t.c=x,t.v=r,null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),[a,t]}cb_range(s,a,e){var t,x,r;return s.type="range",[t,r,x]=s.value,s.value=[{type:"bc",value:[t,r],indices:s.indices},x],x.indices[1]=s.indices[1],this.range(s,a,e)}context(s,a,t){var r,n;for(r in s.start_context=e.shallow_clone(t),s.passages=[],n=this.books[s.value].context)x.call(n,r)&&(t[r]=this.books[s.value].context[r]);return a.push(s),[a,t]}cv_psalm(s,a,t){var x,r,n;return s.start_context=e.shallow_clone(t),s.type="bcv",[r,n]=s.value,[[x]]=this.c_psalm(r,[],s.start_context),s.value=[x,n],this.bcv(s,a,t)}ff(s,a,t){return s.start_context=e.shallow_clone(t),s.value.push({type:"integer",indices:s.indices,value:999}),[[s],t]=this.range(s,[],s.start_context),s.value[0].indices=s.value[1].indices,s.value[0].absolute_indices=s.value[1].absolute_indices,s.value.pop(),null!=s.passages[0].valid.messages.end_verse_not_exist&&delete s.passages[0].valid.messages.end_verse_not_exist,null!=s.passages[0].valid.messages.end_chapter_not_exist&&delete s.passages[0].valid.messages.end_chapter_not_exist,null!=s.passages[0].end.original_c&&delete s.passages[0].end.original_c,a.push(s),[a,t]}integer_title(s,a,t){return s.start_context=e.shallow_clone(t),"Ps"!==t.b?this.integer(s.value[0],a,t):(s.value[0]={type:"c",value:[s.value[0]],indices:[s.value[0].indices[0],s.value[0].indices[1]]},s.value[1].type="v",s.value[1].original_type="title",s.value[1].value=[{type:"integer",value:1,indices:s.value[1].value.indices}],s.type="cv",this.cv(s,a,s.start_context))}integer(s,a,e){return null!=e.v?this.v(s,a,e):this.c(s,a,e)}next_v(s,a,t){var x,r;return s.start_context=e.shallow_clone(t),null==(x=this.pluck_last_recursively("integer",s.value))&&(x={value:1}),s.value.push({type:"integer",indices:s.indices,value:x.value+1}),[[r],t]=this.range(s,[],s.start_context),null!=r.passages[0].valid.messages.end_verse_not_exist&&null==r.passages[0].valid.messages.start_verse_not_exist&&null==r.passages[0].valid.messages.start_chapter_not_exist&&null!=t.c&&(s.value.pop(),s.value.push({type:"cv",indices:s.indices,value:[{type:"c",value:[{type:"integer",value:t.c+1,indices:s.indices}],indices:s.indices},{type:"v",value:[{type:"integer",value:1,indices:s.indices}],indices:s.indices}]}),[[r],t]=this.range(s,[],s.start_context)),r.value[0].indices=r.value[1].indices,r.value[0].absolute_indices=r.value[1].absolute_indices,r.value.pop(),null!=r.passages[0].valid.messages.end_verse_not_exist&&delete r.passages[0].valid.messages.end_verse_not_exist,null!=r.passages[0].valid.messages.end_chapter_not_exist&&delete r.passages[0].valid.messages.end_chapter_not_exist,null!=r.passages[0].end.original_c&&delete r.passages[0].end.original_c,a.push(r),[a,t]}sequence(s,a,t){var x,r,n,i,o,l,u,p,c;for(s.start_context=e.shallow_clone(t),s.passages=[],x=0,n=(u=s.value).length;x<n;x++)for(o=u[x],[[l],t]=this.handle_array(o,[],t),r=0,i=(p=l.passages).length;r<i;r++)null==(c=p[r]).type&&(c.type=l.type),null==c.absolute_indices&&(c.absolute_indices=l.absolute_indices),null!=l.start_context.translations&&(c.translations=l.start_context.translations),c.enclosed_absolute_indices="sequence_post_enclosed"===l.type?l.absolute_indices:[-1,-1],s.passages.push(c);return null==s.absolute_indices&&(s.passages.length>0&&"sequence"===s.type?s.absolute_indices=[s.passages[0].absolute_indices[0],s.passages[s.passages.length-1].absolute_indices[1]]:s.absolute_indices=this.get_absolute_indices(s.indices)),a.push(s),[a,t]}sequence_post_enclosed(s,a,e){return this.sequence(s,a,e)}v(s,a,t){var x,r,n,i;return n="integer"===s.type?s.value:this.pluck("integer",s.value).value,s.start_context=e.shallow_clone(t),x=null!=t.c?t.c:1,i=this.validate_ref(s.start_context.translations,{b:t.b,c:x,v:n}),[r,n]=this.fix_start_zeroes(i,0,n),s.passages=[{start:{b:t.b,c:x,v:n},end:{b:t.b,c:x,v:n},valid:i}],null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),a.push(s),t.v=n,[a,t]}range(s,a,t){var x,r,n,i,o,l,u,p,c,h,g;return s.start_context=e.shallow_clone(t),[c,x]=s.value,[[c],t]=this.handle_obj(c,[],t),"v"!==x.type||("bc"!==c.type||(null!=(n=c.passages)&&null!=(i=n[0])&&null!=(o=i.valid)&&null!=(l=o.messages)?l.start_chapter_not_exist_in_single_chapter_book:void 0))&&"c"!==c.type||"verse"!==this.options.end_range_digits_strategy?([[x],t]=this.handle_obj(x,[],t),s.value=[c,x],s.indices=[c.indices[0],x.indices[1]],delete s.absolute_indices,h={b:c.passages[0].start.b,c:c.passages[0].start.c,v:c.passages[0].start.v,type:c.type},r={b:x.passages[0].end.b,c:x.passages[0].end.c,v:x.passages[0].end.v,type:x.type},x.passages[0].valid.messages.start_chapter_is_zero&&(r.c=0),x.passages[0].valid.messages.start_verse_is_zero&&(r.v=0),(g=this.validate_ref(s.start_context.translations,h,r)).valid?([u,p]=this.range_handle_valid(g,s,c,h,x,r,a),u?p:(null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),s.passages=[{start:h,end:r,valid:g}],null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),"b"===h.type?"b"===r.type?s.type="b_range":s.type="b_range_start":"b"===r.type&&(s.type="range_end_b"),a.push(s),[a,t])):this.range_handle_invalid(g,s,c,h,x,r,a)):(s.value[0]=c,this.range_change_integer_end(s,a))}range_change_end(s,a,e){var t,x,r;return[r,t]=s.value,"integer"===t.type?(t.original_value=t.value,t.value=e):"v"===t.type?((x=this.pluck("integer",t.value)).original_value=x.value,x.value=e):"cv"===t.type&&((x=this.pluck("c",t.value)).original_value=x.value,x.value=e),this.handle_obj(s,a,s.start_context)}range_change_integer_end(s,a){var e,t;return[t,e]=s.value,null==s.original_type&&(s.original_type=s.type),null==s.original_value&&(s.original_value=[t,e]),s.type="integer"===t.type?"cv":t.type+"v","integer"===t.type&&(s.value[0]={type:"c",value:[t],indices:t.indices}),"integer"===e.type&&(s.value[1]={type:"v",value:[e],indices:e.indices}),this.handle_obj(s,a,s.start_context)}range_check_new_end(s,a,e,t){var x,r,n;return x=0,n=null,t.messages.end_chapter_before_start?n="c":t.messages.end_verse_before_start&&(n="v"),null!=n&&(x=this.range_get_new_end_value(a,e,t,n)),x>0&&((r={b:e.b,c:e.c,v:e.v})[n]=x,this.validate_ref(s,r).valid||(x=0)),x}range_end_b(s,a,e){return this.range(s,a,e)}range_get_new_end_value(s,a,e,t){var x;return x=0,"c"===t&&e.messages.end_chapter_is_zero||"v"===t&&e.messages.end_verse_is_zero||(s[t]>=10&&a[t]<10&&s[t]-10*Math.floor(s[t]/10)<a[t]?x=a[t]+10*Math.floor(s[t]/10):s[t]>=100&&a[t]<100&&s[t]-100<a[t]&&(x=a[t]+100)),x}range_handle_invalid(s,a,e,t,x,r,n){var i,o;return(!1===s.valid&&(s.messages.end_chapter_before_start||s.messages.end_verse_before_start)&&("integer"===x.type||"v"===x.type)||!1===s.valid&&s.messages.end_chapter_before_start&&"cv"===x.type)&&(i=this.range_check_new_end(a.start_context.translations,t,r,s))>0?this.range_change_end(a,n,i):"verse"!==this.options.end_range_digits_strategy||null!=t.v||"integer"!==x.type&&"v"!==x.type||(o="v"===x.type?this.pluck("integer",x.value):x.value,!this.validate_ref(a.start_context.translations,{b:t.b,c:t.c,v:o}).valid)?(null==a.original_type&&(a.original_type=a.type),a.type="sequence",[a.original_value,a.value]=[[e,x],[[e],[x]]],this.sequence(a,n,a.start_context)):this.range_change_integer_end(a,n)}range_handle_valid(s,a,e,t,x,r,n){var i;return s.messages.end_chapter_not_exist&&"verse"===this.options.end_range_digits_strategy&&null==t.v&&("integer"===x.type||"v"===x.type)&&this.options.passage_existence_strategy.indexOf("v")>=0&&(i="v"===x.type?this.pluck("integer",x.value):x.value,this.validate_ref(a.start_context.translations,{b:t.b,c:t.c,v:i}).valid)?[!0,this.range_change_integer_end(a,n)]:(this.range_validate(s,t,r,a),[!1,null])}range_validate(s,a,e,t){return s.messages.end_chapter_not_exist||s.messages.end_chapter_not_exist_in_single_chapter_book?(e.original_c=e.c,e.c=s.messages.end_chapter_not_exist?s.messages.end_chapter_not_exist:s.messages.end_chapter_not_exist_in_single_chapter_book,null!=e.v&&(e.v=this.validate_ref(t.start_context.translations,{b:e.b,c:e.c,v:999}).messages.end_verse_not_exist,delete s.messages.end_verse_is_zero)):s.messages.end_verse_not_exist&&(e.original_v=e.v,e.v=s.messages.end_verse_not_exist),s.messages.end_verse_is_zero&&"allow"!==this.options.zero_verse_strategy&&(e.v=s.messages.end_verse_is_zero),s.messages.end_chapter_is_zero&&(e.c=s.messages.end_chapter_is_zero),[a.c,a.v]=this.fix_start_zeroes(s,a.c,a.v),!0}translation_sequence(s,a,t){var x,r,n,i,o,l,u,p;for(s.start_context=e.shallow_clone(t),(u=[]).push({translation:this.books[s.value[0].value].parsed}),x=0,n=(o=s.value[1]).length;x<n;x++)p=o[x],null!=(p=this.books[this.pluck("translation",p).value].parsed)&&u.push({translation:p});for(r=0,i=u.length;r<i;r++)l=u[r],null!=this.translations.aliases[l.translation]?(l.alias=this.translations.aliases[l.translation].alias,l.osis=this.translations.aliases[l.translation].osis||l.translation.toUpperCase()):(l.alias="default",l.osis=l.translation.toUpperCase());return a.length>0&&(t=this.translation_sequence_apply(a,u)),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),a.push(s),this.reset_context(t,["translations"]),[a,t]}translation_sequence_apply(s,a){var t,x,r,n,i,o;for(o=0,x=r=i=s.length-1;i<=0?r<=0:r>=0;x=i<=0?++r:--r)if(null!=s[x].original_type&&(s[x].type=s[x].original_type),null!=s[x].original_value&&(s[x].value=s[x].original_value),"translation_sequence"===s[x].type){o=x+1;break}return o<s.length?(s[o].start_context.translations=a,[n,t]=this.handle_array(s.slice(o),[],s[o].start_context)):t=e.shallow_clone(s[s.length-1].start_context),t}pluck(s,a){var e,t,x;for(e=0,t=a.length;e<t;e++)if(null!=(x=a[e])&&null!=x.type&&x.type===s)return"c"===s||"v"===s?this.pluck("integer",x.value):x;return null}pluck_last_recursively(s,a){var e,t,x;for(e=a.length-1;e>=0;e+=-1)if(null!=(t=a[e])&&null!=t.type){if(t.type===s)return this.pluck(s,[t]);if(null!=(x=this.pluck_last_recursively(s,t.value)))return x}return null}set_context_from_object(s,a,e){var t,x,r,n;for(r=[],t=0,x=a.length;t<x;t++)null!=e[n=a[t]]&&r.push(s[n]=e[n]);return r}reset_context(s,a){var e,t,x,r;for(x=[],e=0,t=a.length;e<t;e++)r=a[e],x.push(delete s[r]);return x}fix_start_zeroes(s,a,e){return s.messages.start_chapter_is_zero&&"upgrade"===this.options.zero_chapter_strategy&&(a=s.messages.start_chapter_is_zero),s.messages.start_verse_is_zero&&"upgrade"===this.options.zero_verse_strategy&&(e=s.messages.start_verse_is_zero),[a,e]}calculate_indices(s,a){var e,t,x,r,n,i,o,l,u,p,c,h,g,_,d,f;for(d="book",x=[],p=0,a=parseInt(a,10),g=[s],r=0,i=(_=["",""]).length;r<i;r++){for(e=_[r],f=[],n=0,o=g.length;n<o;n++)c=g[n],f=f.concat(c.split(e));g=f}for(u=0,l=g.length;u<l;u++)d="book"===d?"rest":"book",0!==(h=(c=g[u]).length)&&("book"===d?(c=c.replace(/\/\d+$/,""),t=p+h,x.length>0&&x[x.length-1].index===a?x[x.length-1].end=t:x.push({start:p,end:t,index:a}),p+=h+2,a=this.books[c].start_index+this.books[c].value.length-p,x.push({start:t+1,end:t+1,index:a})):(t=p+h-1,x.length>0&&x[x.length-1].index===a?x[x.length-1].end=t:x.push({start:p,end:t,index:a}),p+=h));return x}get_absolute_indices([s,a]){var e,t,x,r,n,i;for(i=null,e=null,x=0,r=(n=this.indices).length;x<r;x++)if(t=n[x],null===i&&t.start<=s&&s<=t.end&&(i=s+t.index),t.start<=a&&a<=t.end){e=a+t.index+1;break}return[i,e]}validate_ref(s,a,e){var t,x,r,n,i,o;for(null!=s&&s.length>0||(s=[{translation:"default",osis:"",alias:"default"}]),o=!1,r={},t=0,x=s.length;t<x;t++)null==(i=s[t]).alias&&(i.alias="default"),null!=i.alias?(null==this.translations.aliases[i.alias]&&(i.alias="default",null==r.translation_unknown&&(r.translation_unknown=[]),r.translation_unknown.push(i)),[n]=this.validate_start_ref(i.alias,a,r),e&&([n]=this.validate_end_ref(i.alias,a,e,n,r)),!0===n&&(o=!0)):(null==r.translation_invalid&&(r.translation_invalid=[]),r.translation_invalid.push(i));return{valid:o,messages:r}}validate_start_ref(s,a,e){var t,x,r,n;if(n=!0,"default"!==s&&null==(null!=(t=this.translations[s])?t.chapters[a.b]:void 0)&&this.promote_book_to_translation(a.b,s),r=null!=(null!=(x=this.translations[s])?x.order:void 0)?s:"default",null!=a.v&&(a.v=parseInt(a.v,10)),null!=this.translations[r].order[a.b]){if(null==a.c&&(a.c=1),a.c=parseInt(a.c,10),isNaN(a.c))return n=!1,e.start_chapter_not_numeric=!0,[n,e];0===a.c&&(e.start_chapter_is_zero=1,"error"===this.options.zero_chapter_strategy?n=!1:a.c=1),null!=a.v&&0===a.v&&(e.start_verse_is_zero=1,"error"===this.options.zero_verse_strategy?n=!1:"upgrade"===this.options.zero_verse_strategy&&(a.v=1)),a.c>0&&null!=this.translations[s].chapters[a.b][a.c-1]?null!=a.v?isNaN(a.v)?(n=!1,e.start_verse_not_numeric=!0):a.v>this.translations[s].chapters[a.b][a.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0&&(n=!1,e.start_verse_not_exist=this.translations[s].chapters[a.b][a.c-1]):1===a.c&&"verse"===this.options.single_chapter_1_strategy&&1===this.translations[s].chapters[a.b].length&&(e.start_chapter_1=1):1!==a.c&&1===this.translations[s].chapters[a.b].length?(n=!1,e.start_chapter_not_exist_in_single_chapter_book=1):a.c>0&&this.options.passage_existence_strategy.indexOf("c")>=0&&(n=!1,e.start_chapter_not_exist=this.translations[s].chapters[a.b].length)}else null==a.b?(n=!1,e.start_book_not_defined=!0):(this.options.passage_existence_strategy.indexOf("b")>=0&&(n=!1),e.start_book_not_exist=!0);return[n,e]}validate_end_ref(s,a,e,t,x){var r,n;return n=null!=(null!=(r=this.translations[s])?r.order:void 0)?s:"default",null!=e.c&&(e.c=parseInt(e.c,10),isNaN(e.c)?(t=!1,x.end_chapter_not_numeric=!0):0===e.c&&(x.end_chapter_is_zero=1,"error"===this.options.zero_chapter_strategy?t=!1:e.c=1)),null!=e.v&&(e.v=parseInt(e.v,10),isNaN(e.v)?(t=!1,x.end_verse_not_numeric=!0):0===e.v&&(x.end_verse_is_zero=1,"error"===this.options.zero_verse_strategy?t=!1:"upgrade"===this.options.zero_verse_strategy&&(e.v=1))),null!=this.translations[n].order[e.b]?(null==e.c&&1===this.translations[s].chapters[e.b].length&&(e.c=1),null!=this.translations[n].order[a.b]&&this.translations[n].order[a.b]>this.translations[n].order[e.b]&&(this.options.passage_existence_strategy.indexOf("b")>=0&&(t=!1),x.end_book_before_start=!0),a.b!==e.b||null==e.c||isNaN(e.c)||(null==a.c&&(a.c=1),!isNaN(parseInt(a.c,10))&&a.c>e.c?(t=!1,x.end_chapter_before_start=!0):a.c!==e.c||null==e.v||isNaN(e.v)||(null==a.v&&(a.v=1),!isNaN(parseInt(a.v,10))&&a.v>e.v&&(t=!1,x.end_verse_before_start=!0))),null==e.c||isNaN(e.c)||null==this.translations[s].chapters[e.b][e.c-1]&&(1===this.translations[s].chapters[e.b].length?x.end_chapter_not_exist_in_single_chapter_book=1:e.c>0&&this.options.passage_existence_strategy.indexOf("c")>=0&&(x.end_chapter_not_exist=this.translations[s].chapters[e.b].length)),null==e.v||isNaN(e.v)||(null==e.c&&(e.c=this.translations[s].chapters[e.b].length),e.v>this.translations[s].chapters[e.b][e.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0&&(x.end_verse_not_exist=this.translations[s].chapters[e.b][e.c-1]))):(t=!1,x.end_book_not_exist=!0),[t,x]}promote_book_to_translation(s,a){var t,x;if(null==(t=this.translations)[a]&&(t[a]={}),null==(x=this.translations[a]).chapters&&(x.chapters={}),null==this.translations[a].chapters[s])return this.translations[a].chapters[s]=e.shallow_clone_array(this.translations.default.chapters[s])}}return s.prototype.books=[],s.prototype.indices={},s.prototype.options={},s.prototype.translations={},s}.call(this),e={shallow_clone:function(s){var a,e,t;if(null==s)return s;for(a in e={},s)x.call(s,a)&&(t=s[a],e[a]=t);return e},shallow_clone_array:function(s){var a,e,t,x;if(null==s)return s;for(t=[],a=e=0,x=s.length;0<=x?e<=x:e>=x;a=0<=x?++e:--e)void 0!==s[a]&&(t[a]=s[a]);return t}},s.prototype.regexps.translations=/(?:(?:ERV))\b/gi,s.prototype.translations={aliases:{default:{osis:"",alias:"default"}},alternates:{},default:{order:{Gen:1,Exod:2,Lev:3,Num:4,Deut:5,Josh:6,Judg:7,Ruth:8,"1Sam":9,"2Sam":10,"1Kgs":11,"2Kgs":12,"1Chr":13,"2Chr":14,Ezra:15,Neh:16,Esth:17,Job:18,Ps:19,Prov:20,Eccl:21,Song:22,Isa:23,Jer:24,Lam:25,Ezek:26,Dan:27,Hos:28,Joel:29,Amos:30,Obad:31,Jonah:32,Mic:33,Nah:34,Hab:35,Zeph:36,Hag:37,Zech:38,Mal:39,Matt:40,Mark:41,Luke:42,John:43,Acts:44,Rom:45,"1Cor":46,"2Cor":47,Gal:48,Eph:49,Phil:50,Col:51,"1Thess":52,"2Thess":53,"1Tim":54,"2Tim":55,Titus:56,Phlm:57,Heb:58,Jas:59,"1Pet":60,"2Pet":61,"1John":62,"2John":63,"3John":64,Jude:65,Rev:66,Tob:67,Jdt:68,GkEsth:69,Wis:70,Sir:71,Bar:72,PrAzar:73,Sus:74,Bel:75,SgThree:76,EpJer:77,"1Macc":78,"2Macc":79,"3Macc":80,"4Macc":81,"1Esd":82,"2Esd":83,PrMan:84},chapters:{Gen:[31,25,24,26,32,22,24,22,29,32,32,20,18,24,21,16,27,33,38,18,34,24,20,67,34,35,46,22,35,43,55,32,20,31,29,43,36,30,23,23,57,38,34,34,28,34,31,22,33,26],Exod:[22,25,22,31,23,30,25,32,35,29,10,51,22,31,27,36,16,27,25,26,36,31,33,18,40,37,21,43,46,38,18,35,23,35,35,38,29,31,43,38],Lev:[17,16,17,35,19,30,38,36,24,20,47,8,59,57,33,34,16,30,37,27,24,33,44,23,55,46,34],Num:[54,34,51,49,31,27,89,26,23,36,35,16,33,45,41,50,13,32,22,29,35,41,30,25,18,65,23,31,40,16,54,42,56,29,34,13],Deut:[46,37,29,49,33,25,26,20,29,22,32,32,18,29,23,22,20,22,21,20,23,30,25,22,19,19,26,68,29,20,30,52,29,12],Josh:[18,24,17,24,15,27,26,35,27,43,23,24,33,15,63,10,18,28,51,9,45,34,16,33],Judg:[36,23,31,24,31,40,25,35,57,18,40,15,25,20,20,31,13,31,30,48,25],Ruth:[22,23,18,22],"1Sam":[28,36,21,22,12,21,17,22,27,27,15,25,23,52,35,23,58,30,24,42,15,23,29,22,44,25,12,25,11,31,13],"2Sam":[27,32,39,12,25,23,29,18,13,19,27,31,39,33,37,23,29,33,43,26,22,51,39,25],"1Kgs":[53,46,28,34,18,38,51,66,28,29,43,33,34,31,34,34,24,46,21,43,29,53],"2Kgs":[18,25,27,44,27,33,20,29,37,36,21,21,25,29,38,20,41,37,37,21,26,20,37,20,30],"1Chr":[54,55,24,43,26,81,40,40,44,14,47,40,14,17,29,43,27,17,19,8,30,19,32,31,31,32,34,21,30],"2Chr":[17,18,17,22,14,42,22,18,31,19,23,16,22,15,19,14,19,34,11,37,20,12,21,27,28,23,9,27,36,27,21,33,25,33,27,23],Ezra:[11,70,13,24,17,22,28,36,15,44],Neh:[11,20,32,23,19,19,73,18,38,39,36,47,31],Esth:[22,23,15,17,14,14,10,17,32,3],Job:[22,13,26,21,27,30,21,22,35,22,20,25,28,22,35,22,16,21,29,29,34,30,17,25,6,14,23,28,25,31,40,22,33,37,16,33,24,41,30,24,34,17],Ps:[6,12,8,8,12,10,17,9,20,18,7,8,6,7,5,11,15,50,14,9,13,31,6,10,22,12,14,9,11,12,24,11,22,22,28,12,40,22,13,17,13,11,5,26,17,11,9,14,20,23,19,9,6,7,23,13,11,11,17,12,8,12,11,10,13,20,7,35,36,5,24,20,28,23,10,12,20,72,13,19,16,8,18,12,13,17,7,18,52,17,16,15,5,23,11,13,12,9,9,5,8,28,22,35,45,48,43,13,31,7,10,10,9,8,18,19,2,29,176,7,8,9,4,8,5,6,5,6,8,8,3,18,3,3,21,26,9,8,24,13,10,7,12,15,21,10,20,14,9,6],Prov:[33,22,35,27,23,35,27,36,18,32,31,28,25,35,33,33,28,24,29,30,31,29,35,34,28,28,27,28,27,33,31],Eccl:[18,26,22,16,20,12,29,17,18,20,10,14],Song:[17,17,11,16,16,13,13,14],Isa:[31,22,26,6,30,13,25,22,21,34,16,6,22,32,9,14,14,7,25,6,17,25,18,23,12,21,13,29,24,33,9,20,24,17,10,22,38,22,8,31,29,25,28,28,25,13,15,22,26,11,23,15,12,17,13,12,21,14,21,22,11,12,19,12,25,24],Jer:[19,37,25,31,31,30,34,22,26,25,23,17,27,22,21,21,27,23,15,18,14,30,40,10,38,24,22,17,32,24,40,44,26,22,19,32,21,28,18,16,18,22,13,30,5,28,7,47,39,46,64,34],Lam:[22,22,66,22,22],Ezek:[28,10,27,17,17,14,27,18,11,22,25,28,23,23,8,63,24,32,14,49,32,31,49,27,17,21,36,26,21,26,18,32,33,31,15,38,28,23,29,49,26,20,27,31,25,24,23,35],Dan:[21,49,30,37,31,28,28,27,27,21,45,13],Hos:[11,23,5,19,15,11,16,14,17,15,12,14,16,9],Joel:[20,32,21],Amos:[15,16,15,13,27,14,17,14,15],Obad:[21],Jonah:[17,10,10,11],Mic:[16,13,12,13,15,16,20],Nah:[15,13,19],Hab:[17,20,19],Zeph:[18,15,20],Hag:[15,23],Zech:[21,13,10,14,11,15,14,23,17,12,17,14,9,21],Mal:[14,17,18,6],Matt:[25,23,17,25,48,34,29,34,38,42,30,50,58,36,39,28,27,35,30,34,46,46,39,51,46,75,66,20],Mark:[45,28,35,41,43,56,37,38,50,52,33,44,37,72,47,20],Luke:[80,52,38,44,39,49,50,56,62,42,54,59,35,35,32,31,37,43,48,47,38,71,56,53],John:[51,25,36,54,47,71,53,59,41,42,57,50,38,31,27,33,26,40,42,31,25],Acts:[26,47,26,37,42,15,60,40,43,48,30,25,52,28,41,40,34,28,41,38,40,30,35,27,27,32,44,31],Rom:[32,29,31,25,21,23,25,39,33,21,36,21,14,23,33,27],"1Cor":[31,16,23,21,13,20,40,13,27,33,34,31,13,40,58,24],"2Cor":[24,17,18,18,21,18,16,24,15,18,33,21,14],Gal:[24,21,29,31,26,18],Eph:[23,22,21,32,33,24],Phil:[30,30,21,23],Col:[29,23,25,18],"1Thess":[10,20,13,18,28],"2Thess":[12,17,18],"1Tim":[20,15,16,16,25,21],"2Tim":[18,26,17,22],Titus:[16,15,15],Phlm:[25],Heb:[14,18,19,16,14,20,28,13,28,39,40,29,25],Jas:[27,26,18,17,20],"1Pet":[25,25,22,19,14],"2Pet":[21,22,18],"1John":[10,29,24,21,21],"2John":[13],"3John":[15],Jude:[25],Rev:[20,29,22,11,14,17,17,13,21,11,19,17,18,20,8,21,18,24,21,15,27,21],Tob:[22,14,17,21,22,18,16,21,6,13,18,22,17,15],Jdt:[16,28,10,15,24,21,32,36,14,23,23,20,20,19,14,25],GkEsth:[22,23,15,17,14,14,10,17,32,13,12,6,18,19,16,24],Wis:[16,24,19,20,23,25,30,21,18,21,26,27,19,31,19,29,21,25,22],Sir:[30,18,31,31,15,37,36,19,18,31,34,18,26,27,20,30,32,33,30,31,28,27,27,34,26,29,30,26,28,25,31,24,33,31,26,31,31,34,35,30,22,25,33,23,26,20,25,25,16,29,30],Bar:[22,35,37,37,9],PrAzar:[68],Sus:[64],Bel:[42],SgThree:[39],EpJer:[73],"1Macc":[64,70,60,61,68,63,50,32,73,89,74,53,53,49,41,24],"2Macc":[36,32,40,50,27,31,42,36,29,38,38,45,26,46,39],"3Macc":[29,33,30,21,51,41,23],"4Macc":[35,24,21,26,38,35,23,29,32,21,27,19,27,20,32,25,24,24],"1Esd":[58,30,24,63,73,34,15,96,55],"2Esd":[40,48,36,52,56,59,70,63,47,59,46,51,58,48,63,78],PrMan:[15],Ps151:[7]}},vulgate:{chapters:{Gen:[31,25,24,26,32,22,24,22,29,32,32,20,18,24,21,16,27,33,38,18,34,24,20,67,34,35,46,22,35,43,55,32,20,31,29,43,36,30,23,23,57,38,34,34,28,34,31,22,32,25],Exod:[22,25,22,31,23,30,25,32,35,29,10,51,22,31,27,36,16,27,25,26,36,31,33,18,40,37,21,43,46,38,18,35,23,35,35,38,29,31,43,36],Lev:[17,16,17,35,19,30,38,36,24,20,47,8,59,57,33,34,16,30,37,27,24,33,44,23,55,45,34],Num:[54,34,51,49,31,27,89,26,23,36,34,15,34,45,41,50,13,32,22,30,35,41,30,25,18,65,23,31,39,17,54,42,56,29,34,13],Josh:[18,24,17,25,16,27,26,35,27,44,23,24,33,15,63,10,18,28,51,9,43,34,16,33],Judg:[36,23,31,24,32,40,25,35,57,18,40,15,25,20,20,31,13,31,30,48,24],"1Sam":[28,36,21,22,12,21,17,22,27,27,15,25,23,52,35,23,58,30,24,43,15,23,28,23,44,25,12,25,11,31,13],"1Kgs":[53,46,28,34,18,38,51,66,28,29,43,33,34,31,34,34,24,46,21,43,29,54],"1Chr":[54,55,24,43,26,81,40,40,44,14,46,40,14,17,29,43,27,17,19,7,30,19,32,31,31,32,34,21,30],Neh:[11,20,31,23,19,19,73,18,38,39,36,46,31],Job:[22,13,26,21,27,30,21,22,35,22,20,25,28,22,35,23,16,21,29,29,34,30,17,25,6,14,23,28,25,31,40,22,33,37,16,33,24,41,35,28,25,16],Ps:[6,13,9,10,13,11,18,10,39,8,9,6,7,5,10,15,51,15,10,14,32,6,10,22,12,14,9,11,13,25,11,22,23,28,13,40,23,14,18,14,12,5,26,18,12,10,15,21,23,21,11,7,9,24,13,12,12,18,14,9,13,12,11,14,20,8,36,37,6,24,20,28,23,11,13,21,72,13,20,17,8,19,13,14,17,7,19,53,17,16,16,5,23,11,13,12,9,9,5,8,29,22,35,45,48,43,14,31,7,10,10,9,26,9,10,2,29,176,7,8,9,4,8,5,6,5,6,8,8,3,18,3,3,21,26,9,8,24,14,10,8,12,15,21,10,11,9,14,9,6],Eccl:[18,26,22,17,19,11,30,17,18,20,10,14],Song:[16,17,11,16,17,12,13,14],Jer:[19,37,25,31,31,30,34,22,26,25,23,17,27,22,21,21,27,23,15,18,14,30,40,10,38,24,22,17,32,24,40,44,26,22,19,32,20,28,18,16,18,22,13,30,5,28,7,47,39,46,64,34],Ezek:[28,9,27,17,17,14,27,18,11,22,25,28,23,23,8,63,24,32,14,49,32,31,49,27,17,21,36,26,21,26,18,32,33,31,15,38,28,23,29,49,26,20,27,31,25,24,23,35],Dan:[21,49,100,34,31,28,28,27,27,21,45,13,65,42],Hos:[11,24,5,19,15,11,16,14,17,15,12,14,15,10],Amos:[15,16,15,13,27,15,17,14,14],Jonah:[16,11,10,11],Mic:[16,13,12,13,14,16,20],Hag:[14,24],Matt:[25,23,17,25,48,34,29,34,38,42,30,50,58,36,39,28,26,35,30,34,46,46,39,51,46,75,66,20],Mark:[45,28,35,40,43,56,37,39,49,52,33,44,37,72,47,20],John:[51,25,36,54,47,72,53,59,41,42,57,50,38,31,27,33,26,40,42,31,25],Acts:[26,47,26,37,42,15,59,40,43,48,30,25,52,27,41,40,34,28,40,38,40,30,35,27,27,32,44,31],"2Cor":[24,17,18,18,21,18,16,24,15,18,33,21,13],Rev:[20,29,22,11,14,17,17,13,21,11,19,18,18,20,8,21,18,24,21,15,27,21],Tob:[25,23,25,23,28,22,20,24,12,13,21,22,23,17],Jdt:[12,18,15,17,29,21,25,34,19,20,21,20,31,18,15,31],Wis:[16,25,19,20,24,27,30,21,19,21,27,27,19,31,19,29,20,25,20],Sir:[40,23,34,36,18,37,40,22,25,34,36,19,32,27,22,31,31,33,28,33,31,33,38,47,36,28,33,30,35,27,42,28,33,31,26,28,34,39,41,32,28,26,37,27,31,23,31,28,19,31,38,13],Bar:[22,35,38,37,9,72],"1Macc":[67,70,60,61,68,63,50,32,73,89,74,54,54,49,41,24],"2Macc":[36,33,40,50,27,31,42,36,29,38,38,46,26,46,40]}},ceb:{chapters:{"2Cor":[24,17,18,18,21,18,16,24,15,18,33,21,13],Rev:[20,29,22,11,14,17,17,13,21,11,19,18,18,20,8,21,18,24,21,15,27,21],Tob:[22,14,17,21,22,18,16,21,6,13,18,22,18,15],PrAzar:[67],EpJer:[72],"1Esd":[55,26,24,63,71,33,15,92,55]}},kjv:{chapters:{"3John":[14]}},nab:{order:{Gen:1,Exod:2,Lev:3,Num:4,Deut:5,Josh:6,Judg:7,Ruth:8,"1Sam":9,"2Sam":10,"1Kgs":11,"2Kgs":12,"1Chr":13,"2Chr":14,PrMan:15,Ezra:16,Neh:17,"1Esd":18,"2Esd":19,Tob:20,Jdt:21,Esth:22,GkEsth:23,"1Macc":24,"2Macc":25,"3Macc":26,"4Macc":27,Job:28,Ps:29,Prov:30,Eccl:31,Song:32,Wis:33,Sir:34,Isa:35,Jer:36,Lam:37,Bar:38,EpJer:39,Ezek:40,Dan:41,PrAzar:42,Sus:43,Bel:44,SgThree:45,Hos:46,Joel:47,Amos:48,Obad:49,Jonah:50,Mic:51,Nah:52,Hab:53,Zeph:54,Hag:55,Zech:56,Mal:57,Matt:58,Mark:59,Luke:60,John:61,Acts:62,Rom:63,"1Cor":64,"2Cor":65,Gal:66,Eph:67,Phil:68,Col:69,"1Thess":70,"2Thess":71,"1Tim":72,"2Tim":73,Titus:74,Phlm:75,Heb:76,Jas:77,"1Pet":78,"2Pet":79,"1John":80,"2John":81,"3John":82,Jude:83,Rev:84},chapters:{Gen:[31,25,24,26,32,22,24,22,29,32,32,20,18,24,21,16,27,33,38,18,34,24,20,67,34,35,46,22,35,43,54,33,20,31,29,43,36,30,23,23,57,38,34,34,28,34,31,22,33,26],Exod:[22,25,22,31,23,30,29,28,35,29,10,51,22,31,27,36,16,27,25,26,37,30,33,18,40,37,21,43,46,38,18,35,23,35,35,38,29,31,43,38],Lev:[17,16,17,35,26,23,38,36,24,20,47,8,59,57,33,34,16,30,37,27,24,33,44,23,55,46,34],Num:[54,34,51,49,31,27,89,26,23,36,35,16,33,45,41,35,28,32,22,29,35,41,30,25,19,65,23,31,39,17,54,42,56,29,34,13],Deut:[46,37,29,49,33,25,26,20,29,22,32,31,19,29,23,22,20,22,21,20,23,29,26,22,19,19,26,69,28,20,30,52,29,12],"1Sam":[28,36,21,22,12,21,17,22,27,27,15,25,23,52,35,23,58,30,24,42,16,23,28,23,44,25,12,25,11,31,13],"2Sam":[27,32,39,12,25,23,29,18,13,19,27,31,39,33,37,23,29,32,44,26,22,51,39,25],"1Kgs":[53,46,28,20,32,38,51,66,28,29,43,33,34,31,34,34,24,46,21,43,29,54],"2Kgs":[18,25,27,44,27,33,20,29,37,36,20,22,25,29,38,20,41,37,37,21,26,20,37,20,30],"1Chr":[54,55,24,43,41,66,40,40,44,14,47,41,14,17,29,43,27,17,19,8,30,19,32,31,31,32,34,21,30],"2Chr":[18,17,17,22,14,42,22,18,31,19,23,16,23,14,19,14,19,34,11,37,20,12,21,27,28,23,9,27,36,27,21,33,25,33,27,23],Neh:[11,20,38,17,19,19,72,18,37,40,36,47,31],Job:[22,13,26,21,27,30,21,22,35,22,20,25,28,22,35,22,16,21,29,29,34,30,17,25,6,14,23,28,25,31,40,22,33,37,16,33,24,41,30,32,26,17],Ps:[6,11,9,9,13,11,18,10,21,18,7,9,6,7,5,11,15,51,15,10,14,32,6,10,22,12,14,9,11,13,25,11,22,23,28,13,40,23,14,18,14,12,5,27,18,12,10,15,21,23,21,11,7,9,24,14,12,12,18,14,9,13,12,11,14,20,8,36,37,6,24,20,28,23,11,13,21,72,13,20,17,8,19,13,14,17,7,19,53,17,16,16,5,23,11,13,12,9,9,5,8,29,22,35,45,48,43,14,31,7,10,10,9,8,18,19,2,29,176,7,8,9,4,8,5,6,5,6,8,8,3,18,3,3,21,26,9,8,24,14,10,8,12,15,21,10,20,14,9,6],Eccl:[18,26,22,17,19,12,29,17,18,20,10,14],Song:[17,17,11,16,16,12,14,14],Isa:[31,22,26,6,30,13,25,23,20,34,16,6,22,32,9,14,14,7,25,6,17,25,18,23,12,21,13,29,24,33,9,20,24,17,10,22,38,22,8,31,29,25,28,28,25,13,15,22,26,11,23,15,12,17,13,12,21,14,21,22,11,12,19,11,25,24],Jer:[19,37,25,31,31,30,34,23,25,25,23,17,27,22,21,21,27,23,15,18,14,30,40,10,38,24,22,17,32,24,40,44,26,22,19,32,21,28,18,16,18,22,13,30,5,28,7,47,39,46,64,34],Ezek:[28,10,27,17,17,14,27,18,11,22