1
0
mirror of https://github.com/ZSCNetSupportDept/website.git synced 2025-10-29 01:15:04 +08:00
Files
website/assets/js/4523.e8cf2983.js

2 lines
43 KiB
JavaScript

/*! For license information please see 4523.e8cf2983.js.LICENSE.txt */
(self.webpackChunkdeveloper_zsc=self.webpackChunkdeveloper_zsc||[]).push([[4523],{540:(e,t,r)=>{"use strict";const n=Symbol("Comlink.proxy"),i=Symbol("Comlink.endpoint"),s=Symbol("Comlink.releaseProxy"),o=Symbol("Comlink.finalizer"),a=Symbol("Comlink.thrown"),u=e=>"object"==typeof e&&null!==e||"function"==typeof e,l={canHandle:e=>u(e)&&e[n],serialize(e){const{port1:t,port2:r}=new MessageChannel;return h(e,t),[r,[r]]},deserialize:e=>(e.start(),function(e,t){const r=new Map;return e.addEventListener("message",(function(e){const{data:t}=e;if(!t||!t.id)return;const n=r.get(t.id);if(n)try{n(t)}finally{r.delete(t.id)}})),g(e,r,[],t)}(e))},c=new Map([["proxy",l],["throw",{canHandle:e=>u(e)&&a in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function h(e,t=globalThis,r=["*"]){t.addEventListener("message",(function i(s){if(!s||!s.data)return;if(!function(e,t){for(const r of e){if(t===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(t))return!0}return!1}(r,s.origin))return void console.warn(`Invalid origin '${s.origin}' for comlink proxy`);const{id:u,type:l,path:c}=Object.assign({path:[]},s.data),f=(s.data.argumentList||[]).map(b);let p;try{const t=c.slice(0,-1).reduce(((e,t)=>e[t]),e),r=c.reduce(((e,t)=>e[t]),e);switch(l){case"GET":p=r;break;case"SET":t[c.slice(-1)[0]]=b(s.data.value),p=!0;break;case"APPLY":p=r.apply(t,f);break;case"CONSTRUCT":p=function(e){return Object.assign(e,{[n]:!0})}(new r(...f));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;h(e,r),p=function(e,t){return x.set(e,t),e}(t,[t])}break;case"RELEASE":p=void 0;break;default:return}}catch(m){p={value:m,[a]:0}}Promise.resolve(p).catch((e=>({value:e,[a]:0}))).then((r=>{const[n,s]=w(r);t.postMessage(Object.assign(Object.assign({},n),{id:u}),s),"RELEASE"===l&&(t.removeEventListener("message",i),d(t),o in e&&"function"==typeof e[o]&&e[o]())})).catch((e=>{const[r,n]=w({value:new TypeError("Unserializable return value"),[a]:0});t.postMessage(Object.assign(Object.assign({},r),{id:u}),n)}))})),t.start&&t.start()}function d(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function f(e){if(e)throw new Error("Proxy has been released and is not useable")}function p(e){return k(e,new Map,{type:"RELEASE"}).then((()=>{d(e)}))}const m=new WeakMap,y="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(m.get(e)||0)-1;m.set(e,t),0===t&&p(e)}));function g(e,t,r=[],n=function(){}){let o=!1;const a=new Proxy(n,{get(n,i){if(f(o),i===s)return()=>{!function(e){y&&y.unregister(e)}(a),p(e),t.clear(),o=!0};if("then"===i){if(0===r.length)return{then:()=>a};const n=k(e,t,{type:"GET",path:r.map((e=>e.toString()))}).then(b);return n.then.bind(n)}return g(e,t,[...r,i])},set(n,i,s){f(o);const[a,u]=w(s);return k(e,t,{type:"SET",path:[...r,i].map((e=>e.toString())),value:a},u).then(b)},apply(n,s,a){f(o);const u=r[r.length-1];if(u===i)return k(e,t,{type:"ENDPOINT"}).then(b);if("bind"===u)return g(e,t,r.slice(0,-1));const[l,c]=v(a);return k(e,t,{type:"APPLY",path:r.map((e=>e.toString())),argumentList:l},c).then(b)},construct(n,i){f(o);const[s,a]=v(i);return k(e,t,{type:"CONSTRUCT",path:r.map((e=>e.toString())),argumentList:s},a).then(b)}});return function(e,t){const r=(m.get(t)||0)+1;m.set(t,r),y&&y.register(e,t,e)}(a,e),a}function v(e){const t=e.map(w);return[t.map((e=>e[0])),(r=t.map((e=>e[1])),Array.prototype.concat.apply([],r))];var r}const x=new WeakMap;function w(e){for(const[t,r]of c)if(r.canHandle(e)){const[n,i]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},i]}return[{type:"RAW",value:e},x.get(e)||[]]}function b(e){switch(e.type){case"HANDLER":return c.get(e.name).deserialize(e.value);case"RAW":return e.value}}function k(e,t,r,n){return new Promise((i=>{const s=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.set(s,i),e.start&&e.start(),e.postMessage(Object.assign({id:s},r),n)}))}var E=r(8291),Q=r.n(E),S=r(4809);const L=12;function T(e,t){const r=function(e,t){const r=e.map((e=>/\p{Unified_Ideograph}/u.test(e)?function(e,t){const r=[];return function e(n,i){let s=0,o=!1;for(const a of t)if(n.substr(0,a.length)===a){const t={missed:i.missed,term:i.term.concat({value:a})};n.length>a.length?e(n.substr(a.length),t):r.push(t),o=!0}else for(let t=a.length-1;t>s;t-=1){const u=a.substr(0,t);if(n.substr(0,t)===u){s=t;const a={missed:i.missed,term:i.term.concat({value:u,trailing:!0})};n.length>t?e(n.substr(t),a):r.push(a),o=!0;break}}o||(n.length>0?e(n.substr(1),{missed:i.missed+1,term:i.term}):i.term.length>0&&r.push(i))}(e,{missed:0,term:[]}),r.sort(((e,t)=>{const r=e.missed>0?1:0,n=t.missed>0?1:0;return r!==n?r-n:e.term.length-t.term.length})).map((e=>e.term))}(e,t):[{value:e}])).slice(0,L),n=r.filter((e=>e.length>1));let i=1,s=!1;for(const a of n)if(s)a.splice(1,a.length-1);else{a.length>6&&a.splice(6,a.length-6);const e=i*a.length;if(e>=L){if(e>L){const e=Math.floor(L/i);a.splice(e,a.length-e),i*=e}else i=e;i>6&&(s=!0)}else i=e}const o=[];return function e(t,n){if(t===r.length||n.length>=L)o.push(n.slice(0,L));else for(const i of r[t])e(t+1,n.concat(i))}(0,[]),o}(e,t);if(0===r.length)return[{tokens:e,term:e.map((e=>({value:e,presence:Q().Query.presence.REQUIRED,wildcard:Q().Query.wildcard.LEADING|Q().Query.wildcard.TRAILING})))}];for(const a of r)a[a.length-1].maybeTyping=!0;const n=[];for(const a of S.BH)if("en"===a)S.sx.includes(a)||n.unshift(Q().stopWordFilter);else{const e=Q()[a];e.stopWordFilter&&!S.sx.includes(a)&&n.unshift(e.stopWordFilter)}let i;if(n.length>0){const e=e=>n.reduce(((e,t)=>e.filter((e=>t(e.value)))),e);i=[];const t=[];for(const n of r){const r=e(n);i.push(r),r.length<n.length&&r.length>0&&t.push(r)}r.push(...t)}else i=r.slice();const s=[];for(const a of i)if(a.length>2)for(let e=a.length-1;e>=0;e-=1)s.push(a.slice(0,e).concat(a.slice(e+1)));const o=Math.max(0,S.Ho);return I(r,o).concat(I(s,o))}function P(e,t,r){return e.flatMap((e=>{const n={tokens:e.map((e=>e.value)),term:e.map((e=>{const n=r?e.trailing||e.maybeTyping:e.trailing,i=t>0&&e.value.length>t?t:void 0;return{value:e.value,presence:Q().Query.presence.REQUIRED,wildcard:n?Q().Query.wildcard.TRAILING:Q().Query.wildcard.NONE,editDistance:i}}))};return t&&n.term.every((e=>!e.editDistance))?[]:n}))}function I(e,t){return Array.from({length:t+1},((t,r)=>function(e,t){return P(e,t).concat(P(e.filter((e=>{const t=e[e.length-1];return!t.trailing&&t.maybeTyping})),t,!0))}(e,r))).flat()}var _;!function(e){e[e.Title=0]="Title",e[e.Heading=1]="Heading",e[e.Description=2]="Description",e[e.Keywords=3]="Keywords",e[e.Content=4]="Content"}(_||(_={}));const F=new Map;h(class{async fetchIndexes(e,t){await this.lowLevelFetchIndexes(e,t)}async lowLevelFetchIndexes(e,t){const r=`${e}${t}`;let n=F.get(r);return n||(n=async function(e,t){const r=`${e}${S.IH.replace("{dir}",t?`-${t.replace(/\//g,"-")}`:"")}`;if(new URL(r,location.origin).origin!==location.origin)throw new Error("Unexpected version url");const n=await(await fetch(r)).json(),i=n.map(((e,t)=>{let{documents:r,index:n}=e;return{type:t,documents:r,index:Q().Index.load(n)}})),s=n.reduce(((e,t)=>{for(const r of t.index.invertedIndex)/\p{Unified_Ideograph}/u.test(r[0][0])&&e.add(r[0]);return e}),new Set);return{wrappedIndexes:i,zhDictionary:Array.from(s)}}(e,t),F.set(r,n)),n}async search(e,t,r,n){const i=function(e,t){if(1===t.length&&["ja","jp","th"].includes(t[0]))return Q()[t[0]].tokenizer(e).map((e=>e.toString()));let r=/[^-\s]+/g;return t.includes("zh")&&(r=/\w+|\p{Unified_Ideograph}+/gu),e.toLowerCase().match(r)||[]}(r,S.BH);if(0===i.length)return[];const{wrappedIndexes:s,zhDictionary:o}=await this.lowLevelFetchIndexes(e,t),a=T(i,o),u=[];e:for(const{term:l,tokens:c}of a)for(const{documents:e,index:t,type:r}of s)if(u.push(...t.query((e=>{for(const t of l)e.term(t.value,{wildcard:t.wildcard,presence:t.presence,...t.editDistance?{editDistance:t.editDistance}:null})})).slice(0,n).filter((e=>!u.some((t=>t.document.i.toString()===e.ref)))).slice(0,n-u.length).map((t=>{const n=e.find((e=>e.i.toString()===t.ref));return{document:n,type:r,page:r!==_.Title&&s[0].documents.find((e=>e.i===n.p)),metadata:t.matchData.metadata,tokens:c,score:t.score}}))),u.length>=n)break e;return function(e){e.forEach(((e,t)=>{e.index=t})),e.sort(((t,r)=>{let n=t.type!==_.Heading&&t.type!==_.Content&&t.type!==_.Description||!t.page?t.index:e.findIndex((e=>e.document===t.page)),i=r.type!==_.Heading&&r.type!==_.Content&&r.type!==_.Description||!r.page?r.index:e.findIndex((e=>e.document===r.page));if(-1===n&&(n=t.index),-1===i&&(i=r.index),n===i){const e=(0===r.type?1:0)-(0===t.type?1:0);return 0===e?t.index-r.index:e}return n-i}))}(u),function(e){e.forEach(((t,r)=>{r>0&&t.page&&e.slice(0,r).some((e=>(e.type===_.Keywords?e.page:e.document)===t.page))&&(r<e.length-1&&e[r+1].page===t.page?t.isInterOfTree=!0:t.isLastOfTree=!0)}))}(u),u}})},3397:(e,t,r)=>{"use strict";function n(e){const t=new RegExp("^[^"+e+"]+","u"),r=new RegExp("[^"+e+"]+$","u");return function(e){return e.update((function(e){return e.replace(t,"").replace(r,"")}))}}function i(e,t){e.trimmerSupport.generateTrimmer=n,e.zh=function(){this.pipeline.reset(),this.pipeline.add(e.zh.trimmer,e.zh.stopWordFilter),t&&(this.tokenizer=t)},t&&(e.zh.tokenizer=t),e.zh.wordCharacters="\\u3400-\\u4DBF\\u4E00-\\u9FFC\\uFA0E\\uFA0F\\uFA11\\uFA13\\uFA14\\uFA1F\\uFA21\\uFA23\\uFA24\\uFA27-\\uFA29\\u{20000}-\\u{2A6DD}\\u{2A700}-\\u{2B734}\\u{2B740}-\\u{2B81D}\\u{2B820}-\\u{2CEA1}\\u{2CEB0}-\\u{2EBE0}\\u{30000}-\\u{3134A}",e.zh.trimmer=e.trimmerSupport.generateTrimmer(e.zh.wordCharacters),e.Pipeline.registerFunction(e.zh.trimmer,"trimmer-zh"),e.zh.stopWordFilter=e.generateStopWordFilter("\u7684 \u4e00 \u4e0d \u5728 \u4eba \u6709 \u662f \u4e3a \u4ee5 \u4e8e \u4e0a \u4ed6 \u800c \u540e \u4e4b \u6765 \u53ca \u4e86 \u56e0 \u4e0b \u53ef \u5230 \u7531 \u8fd9 \u4e0e \u4e5f \u6b64 \u4f46 \u5e76 \u4e2a \u5176 \u5df2 \u65e0 \u5c0f \u6211 \u4eec \u8d77 \u6700 \u518d \u4eca \u53bb \u597d \u53ea \u53c8 \u6216 \u5f88 \u4ea6 \u67d0 \u628a \u90a3 \u4f60 \u4e43 \u5b83 \u5427 \u88ab \u6bd4 \u522b \u8d81 \u5f53 \u4ece \u5230 \u5f97 \u6253 \u51e1 \u513f \u5c14 \u8be5 \u5404 \u7ed9 \u8ddf \u548c \u4f55 \u8fd8 \u5373 \u51e0 \u65e2 \u770b \u636e \u8ddd \u9760 \u5566 \u4e86 \u53e6 \u4e48 \u6bcf \u4eec \u561b \u62ff \u54ea \u90a3 \u60a8 \u51ed \u4e14 \u5374 \u8ba9 \u4ecd \u5565 \u5982 \u82e5 \u4f7f \u8c01 \u867d \u968f \u540c \u6240 \u5979 \u54c7 \u55e1 \u5f80 \u54ea \u4e9b \u5411 \u6cbf \u54df \u7528 \u4e8e \u54b1 \u5219 \u600e \u66fe \u81f3 \u81f4 \u7740 \u8bf8 \u81ea".split(" ")),e.Pipeline.registerFunction(e.zh.stopWordFilter,"stopWordFilter-zh")}r.d(t,{A:()=>i})},6106:function(e,t,r){var n,i;n=function(){return function(e){e.multiLanguage=function(){for(var t=Array.prototype.slice.call(arguments),r=t.join("-"),n="",i=[],s=[],o=0;o<t.length;++o)"en"==t[o]?(n+="\\w",i.unshift(e.stopWordFilter),i.push(e.stemmer),s.push(e.stemmer)):(n+=e[t[o]].wordCharacters,e[t[o]].stopWordFilter&&i.unshift(e[t[o]].stopWordFilter),e[t[o]].stemmer&&(i.push(e[t[o]].stemmer),s.push(e[t[o]].stemmer)));var a=e.trimmerSupport.generateTrimmer(n);return e.Pipeline.registerFunction(a,"lunr-multi-trimmer-"+r),i.unshift(a),function(){this.pipeline.reset(),this.pipeline.add.apply(this.pipeline,i),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add.apply(this.searchPipeline,s))}}}},void 0===(i="function"==typeof n?n.call(t,r,t,e):n)||(e.exports=i)},6121:function(e,t,r){var n,i;void 0===(i="function"==typeof(n=function(){return function(e){e.stemmerSupport={Among:function(e,t,r,n){if(this.toCharArray=function(e){for(var t=e.length,r=new Array(t),n=0;n<t;n++)r[n]=e.charCodeAt(n);return r},!e&&""!=e||!t&&0!=t||!r)throw"Bad Among initialisation: s:"+e+", substring_i: "+t+", result: "+r;this.s_size=e.length,this.s=this.toCharArray(e),this.substring_i=t,this.result=r,this.method=n},SnowballProgram:function(){var e;return{bra:0,ket:0,limit:0,cursor:0,limit_backward:0,setCurrent:function(t){e=t,this.cursor=0,this.limit=t.length,this.limit_backward=0,this.bra=this.cursor,this.ket=this.limit},getCurrent:function(){var t=e;return e=null,t},in_grouping:function(t,r,n){if(this.cursor<this.limit){var i=e.charCodeAt(this.cursor);if(i<=n&&i>=r&&t[(i-=r)>>3]&1<<(7&i))return this.cursor++,!0}return!1},in_grouping_b:function(t,r,n){if(this.cursor>this.limit_backward){var i=e.charCodeAt(this.cursor-1);if(i<=n&&i>=r&&t[(i-=r)>>3]&1<<(7&i))return this.cursor--,!0}return!1},out_grouping:function(t,r,n){if(this.cursor<this.limit){var i=e.charCodeAt(this.cursor);if(i>n||i<r)return this.cursor++,!0;if(!(t[(i-=r)>>3]&1<<(7&i)))return this.cursor++,!0}return!1},out_grouping_b:function(t,r,n){if(this.cursor>this.limit_backward){var i=e.charCodeAt(this.cursor-1);if(i>n||i<r)return this.cursor--,!0;if(!(t[(i-=r)>>3]&1<<(7&i)))return this.cursor--,!0}return!1},eq_s:function(t,r){if(this.limit-this.cursor<t)return!1;for(var n=0;n<t;n++)if(e.charCodeAt(this.cursor+n)!=r.charCodeAt(n))return!1;return this.cursor+=t,!0},eq_s_b:function(t,r){if(this.cursor-this.limit_backward<t)return!1;for(var n=0;n<t;n++)if(e.charCodeAt(this.cursor-t+n)!=r.charCodeAt(n))return!1;return this.cursor-=t,!0},find_among:function(t,r){for(var n=0,i=r,s=this.cursor,o=this.limit,a=0,u=0,l=!1;;){for(var c=n+(i-n>>1),h=0,d=a<u?a:u,f=t[c],p=d;p<f.s_size;p++){if(s+d==o){h=-1;break}if(h=e.charCodeAt(s+d)-f.s[p])break;d++}if(h<0?(i=c,u=d):(n=c,a=d),i-n<=1){if(n>0||i==n||l)break;l=!0}}for(;;){if(a>=(f=t[n]).s_size){if(this.cursor=s+f.s_size,!f.method)return f.result;var m=f.method();if(this.cursor=s+f.s_size,m)return f.result}if((n=f.substring_i)<0)return 0}},find_among_b:function(t,r){for(var n=0,i=r,s=this.cursor,o=this.limit_backward,a=0,u=0,l=!1;;){for(var c=n+(i-n>>1),h=0,d=a<u?a:u,f=(p=t[c]).s_size-1-d;f>=0;f--){if(s-d==o){h=-1;break}if(h=e.charCodeAt(s-1-d)-p.s[f])break;d++}if(h<0?(i=c,u=d):(n=c,a=d),i-n<=1){if(n>0||i==n||l)break;l=!0}}for(;;){var p;if(a>=(p=t[n]).s_size){if(this.cursor=s-p.s_size,!p.method)return p.result;var m=p.method();if(this.cursor=s-p.s_size,m)return p.result}if((n=p.substring_i)<0)return 0}},replace_s:function(t,r,n){var i=n.length-(r-t),s=e.substring(0,t),o=e.substring(r);return e=s+n+o,this.limit+=i,this.cursor>=r?this.cursor+=i:this.cursor>t&&(this.cursor=t),i},slice_check:function(){if(this.bra<0||this.bra>this.ket||this.ket>this.limit||this.limit>e.length)throw"faulty slice operation"},slice_from:function(e){this.slice_check(),this.replace_s(this.bra,this.ket,e)},slice_del:function(){this.slice_from("")},insert:function(e,t,r){var n=this.replace_s(e,t,r);e<=this.bra&&(this.bra+=n),e<=this.ket&&(this.ket+=n)},slice_to:function(){return this.slice_check(),e.substring(this.bra,this.ket)},eq_v_b:function(e){return this.eq_s_b(e.length,e)}}}},e.trimmerSupport={generateTrimmer:function(e){var t=new RegExp("^[^"+e+"]+"),r=new RegExp("[^"+e+"]+$");return function(e){return"function"==typeof e.update?e.update((function(e){return e.replace(t,"").replace(r,"")})):e.replace(t,"").replace(r,"")}}}}})?n.call(t,r,t,e):n)||(e.exports=i)},8291:(e,t,r)=>{var n,i;!function(){var s,o,a,u,l,c,h,d,f,p,m,y,g,v,x,w,b,k,E,Q,S,L,T,P,I,_,F,O,R,C,A=function(e){var t=new A.Builder;return t.pipeline.add(A.trimmer,A.stopWordFilter,A.stemmer),t.searchPipeline.add(A.stemmer),e.call(t,t),t.build()};A.version="2.3.9",A.utils={},A.utils.warn=(s=this,function(e){s.console&&console.warn&&console.warn(e)}),A.utils.asString=function(e){return null==e?"":e.toString()},A.utils.clone=function(e){if(null==e)return e;for(var t=Object.create(null),r=Object.keys(e),n=0;n<r.length;n++){var i=r[n],s=e[i];if(Array.isArray(s))t[i]=s.slice();else{if("string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s)throw new TypeError("clone is not deep and does not support nested objects");t[i]=s}}return t},A.FieldRef=function(e,t,r){this.docRef=e,this.fieldName=t,this._stringValue=r},A.FieldRef.joiner="/",A.FieldRef.fromString=function(e){var t=e.indexOf(A.FieldRef.joiner);if(-1===t)throw"malformed field ref string";var r=e.slice(0,t),n=e.slice(t+1);return new A.FieldRef(n,r,e)},A.FieldRef.prototype.toString=function(){return null==this._stringValue&&(this._stringValue=this.fieldName+A.FieldRef.joiner+this.docRef),this._stringValue},A.Set=function(e){if(this.elements=Object.create(null),e){this.length=e.length;for(var t=0;t<this.length;t++)this.elements[e[t]]=!0}else this.length=0},A.Set.complete={intersect:function(e){return e},union:function(){return this},contains:function(){return!0}},A.Set.empty={intersect:function(){return this},union:function(e){return e},contains:function(){return!1}},A.Set.prototype.contains=function(e){return!!this.elements[e]},A.Set.prototype.intersect=function(e){var t,r,n,i=[];if(e===A.Set.complete)return this;if(e===A.Set.empty)return e;this.length<e.length?(t=this,r=e):(t=e,r=this),n=Object.keys(t.elements);for(var s=0;s<n.length;s++){var o=n[s];o in r.elements&&i.push(o)}return new A.Set(i)},A.Set.prototype.union=function(e){return e===A.Set.complete?A.Set.complete:e===A.Set.empty?this:new A.Set(Object.keys(this.elements).concat(Object.keys(e.elements)))},A.idf=function(e,t){var r=0;for(var n in e)"_index"!=n&&(r+=Object.keys(e[n]).length);var i=(t-r+.5)/(r+.5);return Math.log(1+Math.abs(i))},A.Token=function(e,t){this.str=e||"",this.metadata=t||{}},A.Token.prototype.toString=function(){return this.str},A.Token.prototype.update=function(e){return this.str=e(this.str,this.metadata),this},A.Token.prototype.clone=function(e){return e=e||function(e){return e},new A.Token(e(this.str,this.metadata),this.metadata)},A.tokenizer=function(e,t){if(null==e||null==e)return[];if(Array.isArray(e))return e.map((function(e){return new A.Token(A.utils.asString(e).toLowerCase(),A.utils.clone(t))}));for(var r=e.toString().toLowerCase(),n=r.length,i=[],s=0,o=0;s<=n;s++){var a=s-o;if(r.charAt(s).match(A.tokenizer.separator)||s==n){if(a>0){var u=A.utils.clone(t)||{};u.position=[o,a],u.index=i.length,i.push(new A.Token(r.slice(o,s),u))}o=s+1}}return i},A.tokenizer.separator=/[\s\-]+/,A.Pipeline=function(){this._stack=[]},A.Pipeline.registeredFunctions=Object.create(null),A.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&A.utils.warn("Overwriting existing registered function: "+t),e.label=t,A.Pipeline.registeredFunctions[e.label]=e},A.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||A.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},A.Pipeline.load=function(e){var t=new A.Pipeline;return e.forEach((function(e){var r=A.Pipeline.registeredFunctions[e];if(!r)throw new Error("Cannot load unregistered function: "+e);t.add(r)})),t},A.Pipeline.prototype.add=function(){Array.prototype.slice.call(arguments).forEach((function(e){A.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)}),this)},A.Pipeline.prototype.after=function(e,t){A.Pipeline.warnIfFunctionNotRegistered(t);var r=this._stack.indexOf(e);if(-1==r)throw new Error("Cannot find existingFn");r+=1,this._stack.splice(r,0,t)},A.Pipeline.prototype.before=function(e,t){A.Pipeline.warnIfFunctionNotRegistered(t);var r=this._stack.indexOf(e);if(-1==r)throw new Error("Cannot find existingFn");this._stack.splice(r,0,t)},A.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);-1!=t&&this._stack.splice(t,1)},A.Pipeline.prototype.run=function(e){for(var t=this._stack.length,r=0;r<t;r++){for(var n=this._stack[r],i=[],s=0;s<e.length;s++){var o=n(e[s],s,e);if(null!=o&&""!==o)if(Array.isArray(o))for(var a=0;a<o.length;a++)i.push(o[a]);else i.push(o)}e=i}return e},A.Pipeline.prototype.runString=function(e,t){var r=new A.Token(e,t);return this.run([r]).map((function(e){return e.toString()}))},A.Pipeline.prototype.reset=function(){this._stack=[]},A.Pipeline.prototype.toJSON=function(){return this._stack.map((function(e){return A.Pipeline.warnIfFunctionNotRegistered(e),e.label}))},A.Vector=function(e){this._magnitude=0,this.elements=e||[]},A.Vector.prototype.positionForIndex=function(e){if(0==this.elements.length)return 0;for(var t=0,r=this.elements.length/2,n=r-t,i=Math.floor(n/2),s=this.elements[2*i];n>1&&(s<e&&(t=i),s>e&&(r=i),s!=e);)n=r-t,i=t+Math.floor(n/2),s=this.elements[2*i];return s==e||s>e?2*i:s<e?2*(i+1):void 0},A.Vector.prototype.insert=function(e,t){this.upsert(e,t,(function(){throw"duplicate index"}))},A.Vector.prototype.upsert=function(e,t,r){this._magnitude=0;var n=this.positionForIndex(e);this.elements[n]==e?this.elements[n+1]=r(this.elements[n+1],t):this.elements.splice(n,0,e,t)},A.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;for(var e=0,t=this.elements.length,r=1;r<t;r+=2){var n=this.elements[r];e+=n*n}return this._magnitude=Math.sqrt(e)},A.Vector.prototype.dot=function(e){for(var t=0,r=this.elements,n=e.elements,i=r.length,s=n.length,o=0,a=0,u=0,l=0;u<i&&l<s;)(o=r[u])<(a=n[l])?u+=2:o>a?l+=2:o==a&&(t+=r[u+1]*n[l+1],u+=2,l+=2);return t},A.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},A.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),t=1,r=0;t<this.elements.length;t+=2,r++)e[r]=this.elements[t];return e},A.Vector.prototype.toJSON=function(){return this.elements},A.stemmer=(o={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},a={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},h="^("+(l="[^aeiou][^aeiouy]*")+")?"+(c=(u="[aeiouy]")+"[aeiou]*")+l+"("+c+")?$",d="^("+l+")?"+c+l+c+l,f="^("+l+")?"+u,p=new RegExp("^("+l+")?"+c+l),m=new RegExp(d),y=new RegExp(h),g=new RegExp(f),v=/^(.+?)(ss|i)es$/,x=/^(.+?)([^s])s$/,w=/^(.+?)eed$/,b=/^(.+?)(ed|ing)$/,k=/.$/,E=/(at|bl|iz)$/,Q=new RegExp("([^aeiouylsz])\\1$"),S=new RegExp("^"+l+u+"[^aeiouwxy]$"),L=/^(.+?[^aeiou])y$/,T=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,P=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,I=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,_=/^(.+?)(s|t)(ion)$/,F=/^(.+?)e$/,O=/ll$/,R=new RegExp("^"+l+u+"[^aeiouwxy]$"),C=function(e){var t,r,n,i,s,u,l;if(e.length<3)return e;if("y"==(n=e.substr(0,1))&&(e=n.toUpperCase()+e.substr(1)),s=x,(i=v).test(e)?e=e.replace(i,"$1$2"):s.test(e)&&(e=e.replace(s,"$1$2")),s=b,(i=w).test(e)){var c=i.exec(e);(i=p).test(c[1])&&(i=k,e=e.replace(i,""))}else s.test(e)&&(t=(c=s.exec(e))[1],(s=g).test(t)&&(u=Q,l=S,(s=E).test(e=t)?e+="e":u.test(e)?(i=k,e=e.replace(i,"")):l.test(e)&&(e+="e")));return(i=L).test(e)&&(e=(t=(c=i.exec(e))[1])+"i"),(i=T).test(e)&&(t=(c=i.exec(e))[1],r=c[2],(i=p).test(t)&&(e=t+o[r])),(i=P).test(e)&&(t=(c=i.exec(e))[1],r=c[2],(i=p).test(t)&&(e=t+a[r])),s=_,(i=I).test(e)?(t=(c=i.exec(e))[1],(i=m).test(t)&&(e=t)):s.test(e)&&(t=(c=s.exec(e))[1]+c[2],(s=m).test(t)&&(e=t)),(i=F).test(e)&&(t=(c=i.exec(e))[1],s=y,u=R,((i=m).test(t)||s.test(t)&&!u.test(t))&&(e=t)),s=m,(i=O).test(e)&&s.test(e)&&(i=k,e=e.replace(i,"")),"y"==n&&(e=n.toLowerCase()+e.substr(1)),e},function(e){return e.update(C)}),A.Pipeline.registerFunction(A.stemmer,"stemmer"),A.generateStopWordFilter=function(e){var t=e.reduce((function(e,t){return e[t]=t,e}),{});return function(e){if(e&&t[e.toString()]!==e.toString())return e}},A.stopWordFilter=A.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),A.Pipeline.registerFunction(A.stopWordFilter,"stopWordFilter"),A.trimmer=function(e){return e.update((function(e){return e.replace(/^\W+/,"").replace(/\W+$/,"")}))},A.Pipeline.registerFunction(A.trimmer,"trimmer"),A.TokenSet=function(){this.final=!1,this.edges={},this.id=A.TokenSet._nextId,A.TokenSet._nextId+=1},A.TokenSet._nextId=1,A.TokenSet.fromArray=function(e){for(var t=new A.TokenSet.Builder,r=0,n=e.length;r<n;r++)t.insert(e[r]);return t.finish(),t.root},A.TokenSet.fromClause=function(e){return"editDistance"in e?A.TokenSet.fromFuzzyString(e.term,e.editDistance):A.TokenSet.fromString(e.term)},A.TokenSet.fromFuzzyString=function(e,t){for(var r=new A.TokenSet,n=[{node:r,editsRemaining:t,str:e}];n.length;){var i=n.pop();if(i.str.length>0){var s,o=i.str.charAt(0);o in i.node.edges?s=i.node.edges[o]:(s=new A.TokenSet,i.node.edges[o]=s),1==i.str.length&&(s.final=!0),n.push({node:s,editsRemaining:i.editsRemaining,str:i.str.slice(1)})}if(0!=i.editsRemaining){if("*"in i.node.edges)var a=i.node.edges["*"];else{a=new A.TokenSet;i.node.edges["*"]=a}if(0==i.str.length&&(a.final=!0),n.push({node:a,editsRemaining:i.editsRemaining-1,str:i.str}),i.str.length>1&&n.push({node:i.node,editsRemaining:i.editsRemaining-1,str:i.str.slice(1)}),1==i.str.length&&(i.node.final=!0),i.str.length>=1){if("*"in i.node.edges)var u=i.node.edges["*"];else{u=new A.TokenSet;i.node.edges["*"]=u}1==i.str.length&&(u.final=!0),n.push({node:u,editsRemaining:i.editsRemaining-1,str:i.str.slice(1)})}if(i.str.length>1){var l,c=i.str.charAt(0),h=i.str.charAt(1);h in i.node.edges?l=i.node.edges[h]:(l=new A.TokenSet,i.node.edges[h]=l),1==i.str.length&&(l.final=!0),n.push({node:l,editsRemaining:i.editsRemaining-1,str:c+i.str.slice(2)})}}}return r},A.TokenSet.fromString=function(e){for(var t=new A.TokenSet,r=t,n=0,i=e.length;n<i;n++){var s=e[n],o=n==i-1;if("*"==s)t.edges[s]=t,t.final=o;else{var a=new A.TokenSet;a.final=o,t.edges[s]=a,t=a}}return r},A.TokenSet.prototype.toArray=function(){for(var e=[],t=[{prefix:"",node:this}];t.length;){var r=t.pop(),n=Object.keys(r.node.edges),i=n.length;r.node.final&&(r.prefix.charAt(0),e.push(r.prefix));for(var s=0;s<i;s++){var o=n[s];t.push({prefix:r.prefix.concat(o),node:r.node.edges[o]})}}return e},A.TokenSet.prototype.toString=function(){if(this._str)return this._str;for(var e=this.final?"1":"0",t=Object.keys(this.edges).sort(),r=t.length,n=0;n<r;n++){var i=t[n];e=e+i+this.edges[i].id}return e},A.TokenSet.prototype.intersect=function(e){for(var t=new A.TokenSet,r=void 0,n=[{qNode:e,output:t,node:this}];n.length;){r=n.pop();for(var i=Object.keys(r.qNode.edges),s=i.length,o=Object.keys(r.node.edges),a=o.length,u=0;u<s;u++)for(var l=i[u],c=0;c<a;c++){var h=o[c];if(h==l||"*"==l){var d=r.node.edges[h],f=r.qNode.edges[l],p=d.final&&f.final,m=void 0;h in r.output.edges?(m=r.output.edges[h]).final=m.final||p:((m=new A.TokenSet).final=p,r.output.edges[h]=m),n.push({qNode:f,output:m,node:d})}}}return t},A.TokenSet.Builder=function(){this.previousWord="",this.root=new A.TokenSet,this.uncheckedNodes=[],this.minimizedNodes={}},A.TokenSet.Builder.prototype.insert=function(e){var t,r=0;if(e<this.previousWord)throw new Error("Out of order word insertion");for(var n=0;n<e.length&&n<this.previousWord.length&&e[n]==this.previousWord[n];n++)r++;this.minimize(r),t=0==this.uncheckedNodes.length?this.root:this.uncheckedNodes[this.uncheckedNodes.length-1].child;for(n=r;n<e.length;n++){var i=new A.TokenSet,s=e[n];t.edges[s]=i,this.uncheckedNodes.push({parent:t,char:s,child:i}),t=i}t.final=!0,this.previousWord=e},A.TokenSet.Builder.prototype.finish=function(){this.minimize(0)},A.TokenSet.Builder.prototype.minimize=function(e){for(var t=this.uncheckedNodes.length-1;t>=e;t--){var r=this.uncheckedNodes[t],n=r.child.toString();n in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[n]:(r.child._str=n,this.minimizedNodes[n]=r.child),this.uncheckedNodes.pop()}},A.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},A.Index.prototype.search=function(e){return this.query((function(t){new A.QueryParser(e,t).parse()}))},A.Index.prototype.query=function(e){for(var t=new A.Query(this.fields),r=Object.create(null),n=Object.create(null),i=Object.create(null),s=Object.create(null),o=Object.create(null),a=0;a<this.fields.length;a++)n[this.fields[a]]=new A.Vector;e.call(t,t);for(a=0;a<t.clauses.length;a++){var u=t.clauses[a],l=null,c=A.Set.empty;l=u.usePipeline?this.pipeline.runString(u.term,{fields:u.fields}):[u.term];for(var h=0;h<l.length;h++){var d=l[h];u.term=d;var f=A.TokenSet.fromClause(u),p=this.tokenSet.intersect(f).toArray();if(0===p.length&&u.presence===A.Query.presence.REQUIRED){for(var m=0;m<u.fields.length;m++){s[F=u.fields[m]]=A.Set.empty}break}for(var y=0;y<p.length;y++){var g=p[y],v=this.invertedIndex[g],x=v._index;for(m=0;m<u.fields.length;m++){var w=v[F=u.fields[m]],b=Object.keys(w),k=g+"/"+F,E=new A.Set(b);if(u.presence==A.Query.presence.REQUIRED&&(c=c.union(E),void 0===s[F]&&(s[F]=A.Set.complete)),u.presence!=A.Query.presence.PROHIBITED){if(n[F].upsert(x,u.boost,(function(e,t){return e+t})),!i[k]){for(var Q=0;Q<b.length;Q++){var S,L=b[Q],T=new A.FieldRef(L,F),P=w[L];void 0===(S=r[T])?r[T]=new A.MatchData(g,F,P):S.add(g,F,P)}i[k]=!0}}else void 0===o[F]&&(o[F]=A.Set.empty),o[F]=o[F].union(E)}}}if(u.presence===A.Query.presence.REQUIRED)for(m=0;m<u.fields.length;m++){s[F=u.fields[m]]=s[F].intersect(c)}}var I=A.Set.complete,_=A.Set.empty;for(a=0;a<this.fields.length;a++){var F;s[F=this.fields[a]]&&(I=I.intersect(s[F])),o[F]&&(_=_.union(o[F]))}var O=Object.keys(r),R=[],C=Object.create(null);if(t.isNegated()){O=Object.keys(this.fieldVectors);for(a=0;a<O.length;a++){T=O[a];var N=A.FieldRef.fromString(T);r[T]=new A.MatchData}}for(a=0;a<O.length;a++){var D=(N=A.FieldRef.fromString(O[a])).docRef;if(I.contains(D)&&!_.contains(D)){var j,z=this.fieldVectors[N],B=n[N.fieldName].similarity(z);if(void 0!==(j=C[D]))j.score+=B,j.matchData.combine(r[N]);else{var M={ref:D,score:B,matchData:r[N]};C[D]=M,R.push(M)}}}return R.sort((function(e,t){return t.score-e.score}))},A.Index.prototype.toJSON=function(){var e=Object.keys(this.invertedIndex).sort().map((function(e){return[e,this.invertedIndex[e]]}),this),t=Object.keys(this.fieldVectors).map((function(e){return[e,this.fieldVectors[e].toJSON()]}),this);return{version:A.version,fields:this.fields,fieldVectors:t,invertedIndex:e,pipeline:this.pipeline.toJSON()}},A.Index.load=function(e){var t={},r={},n=e.fieldVectors,i=Object.create(null),s=e.invertedIndex,o=new A.TokenSet.Builder,a=A.Pipeline.load(e.pipeline);e.version!=A.version&&A.utils.warn("Version mismatch when loading serialised index. Current version of lunr '"+A.version+"' does not match serialized index '"+e.version+"'");for(var u=0;u<n.length;u++){var l=(h=n[u])[0],c=h[1];r[l]=new A.Vector(c)}for(u=0;u<s.length;u++){var h,d=(h=s[u])[0],f=h[1];o.insert(d),i[d]=f}return o.finish(),t.fields=e.fields,t.fieldVectors=r,t.invertedIndex=i,t.tokenSet=o.root,t.pipeline=a,new A.Index(t)},A.Builder=function(){this._ref="id",this._fields=Object.create(null),this._documents=Object.create(null),this.invertedIndex=Object.create(null),this.fieldTermFrequencies={},this.fieldLengths={},this.tokenizer=A.tokenizer,this.pipeline=new A.Pipeline,this.searchPipeline=new A.Pipeline,this.documentCount=0,this._b=.75,this._k1=1.2,this.termIndex=0,this.metadataWhitelist=[]},A.Builder.prototype.ref=function(e){this._ref=e},A.Builder.prototype.field=function(e,t){if(/\//.test(e))throw new RangeError("Field '"+e+"' contains illegal character '/'");this._fields[e]=t||{}},A.Builder.prototype.b=function(e){this._b=e<0?0:e>1?1:e},A.Builder.prototype.k1=function(e){this._k1=e},A.Builder.prototype.add=function(e,t){var r=e[this._ref],n=Object.keys(this._fields);this._documents[r]=t||{},this.documentCount+=1;for(var i=0;i<n.length;i++){var s=n[i],o=this._fields[s].extractor,a=o?o(e):e[s],u=this.tokenizer(a,{fields:[s]}),l=this.pipeline.run(u),c=new A.FieldRef(r,s),h=Object.create(null);this.fieldTermFrequencies[c]=h,this.fieldLengths[c]=0,this.fieldLengths[c]+=l.length;for(var d=0;d<l.length;d++){var f=l[d];if(null==h[f]&&(h[f]=0),h[f]+=1,null==this.invertedIndex[f]){var p=Object.create(null);p._index=this.termIndex,this.termIndex+=1;for(var m=0;m<n.length;m++)p[n[m]]=Object.create(null);this.invertedIndex[f]=p}null==this.invertedIndex[f][s][r]&&(this.invertedIndex[f][s][r]=Object.create(null));for(var y=0;y<this.metadataWhitelist.length;y++){var g=this.metadataWhitelist[y],v=f.metadata[g];null==this.invertedIndex[f][s][r][g]&&(this.invertedIndex[f][s][r][g]=[]),this.invertedIndex[f][s][r][g].push(v)}}}},A.Builder.prototype.calculateAverageFieldLengths=function(){for(var e=Object.keys(this.fieldLengths),t=e.length,r={},n={},i=0;i<t;i++){var s=A.FieldRef.fromString(e[i]),o=s.fieldName;n[o]||(n[o]=0),n[o]+=1,r[o]||(r[o]=0),r[o]+=this.fieldLengths[s]}var a=Object.keys(this._fields);for(i=0;i<a.length;i++){var u=a[i];r[u]=r[u]/n[u]}this.averageFieldLength=r},A.Builder.prototype.createFieldVectors=function(){for(var e={},t=Object.keys(this.fieldTermFrequencies),r=t.length,n=Object.create(null),i=0;i<r;i++){for(var s=A.FieldRef.fromString(t[i]),o=s.fieldName,a=this.fieldLengths[s],u=new A.Vector,l=this.fieldTermFrequencies[s],c=Object.keys(l),h=c.length,d=this._fields[o].boost||1,f=this._documents[s.docRef].boost||1,p=0;p<h;p++){var m,y,g,v=c[p],x=l[v],w=this.invertedIndex[v]._index;void 0===n[v]?(m=A.idf(this.invertedIndex[v],this.documentCount),n[v]=m):m=n[v],y=m*((this._k1+1)*x)/(this._k1*(1-this._b+this._b*(a/this.averageFieldLength[o]))+x),y*=d,y*=f,g=Math.round(1e3*y)/1e3,u.insert(w,g)}e[s]=u}this.fieldVectors=e},A.Builder.prototype.createTokenSet=function(){this.tokenSet=A.TokenSet.fromArray(Object.keys(this.invertedIndex).sort())},A.Builder.prototype.build=function(){return this.calculateAverageFieldLengths(),this.createFieldVectors(),this.createTokenSet(),new A.Index({invertedIndex:this.invertedIndex,fieldVectors:this.fieldVectors,tokenSet:this.tokenSet,fields:Object.keys(this._fields),pipeline:this.searchPipeline})},A.Builder.prototype.use=function(e){var t=Array.prototype.slice.call(arguments,1);t.unshift(this),e.apply(this,t)},A.MatchData=function(e,t,r){for(var n=Object.create(null),i=Object.keys(r||{}),s=0;s<i.length;s++){var o=i[s];n[o]=r[o].slice()}this.metadata=Object.create(null),void 0!==e&&(this.metadata[e]=Object.create(null),this.metadata[e][t]=n)},A.MatchData.prototype.combine=function(e){for(var t=Object.keys(e.metadata),r=0;r<t.length;r++){var n=t[r],i=Object.keys(e.metadata[n]);null==this.metadata[n]&&(this.metadata[n]=Object.create(null));for(var s=0;s<i.length;s++){var o=i[s],a=Object.keys(e.metadata[n][o]);null==this.metadata[n][o]&&(this.metadata[n][o]=Object.create(null));for(var u=0;u<a.length;u++){var l=a[u];null==this.metadata[n][o][l]?this.metadata[n][o][l]=e.metadata[n][o][l]:this.metadata[n][o][l]=this.metadata[n][o][l].concat(e.metadata[n][o][l])}}}},A.MatchData.prototype.add=function(e,t,r){if(!(e in this.metadata))return this.metadata[e]=Object.create(null),void(this.metadata[e][t]=r);if(t in this.metadata[e])for(var n=Object.keys(r),i=0;i<n.length;i++){var s=n[i];s in this.metadata[e][t]?this.metadata[e][t][s]=this.metadata[e][t][s].concat(r[s]):this.metadata[e][t][s]=r[s]}else this.metadata[e][t]=r},A.Query=function(e){this.clauses=[],this.allFields=e},A.Query.wildcard=new String("*"),A.Query.wildcard.NONE=0,A.Query.wildcard.LEADING=1,A.Query.wildcard.TRAILING=2,A.Query.presence={OPTIONAL:1,REQUIRED:2,PROHIBITED:3},A.Query.prototype.clause=function(e){return"fields"in e||(e.fields=this.allFields),"boost"in e||(e.boost=1),"usePipeline"in e||(e.usePipeline=!0),"wildcard"in e||(e.wildcard=A.Query.wildcard.NONE),e.wildcard&A.Query.wildcard.LEADING&&e.term.charAt(0)!=A.Query.wildcard&&(e.term="*"+e.term),e.wildcard&A.Query.wildcard.TRAILING&&e.term.slice(-1)!=A.Query.wildcard&&(e.term=e.term+"*"),"presence"in e||(e.presence=A.Query.presence.OPTIONAL),this.clauses.push(e),this},A.Query.prototype.isNegated=function(){for(var e=0;e<this.clauses.length;e++)if(this.clauses[e].presence!=A.Query.presence.PROHIBITED)return!1;return!0},A.Query.prototype.term=function(e,t){if(Array.isArray(e))return e.forEach((function(e){this.term(e,A.utils.clone(t))}),this),this;var r=t||{};return r.term=e.toString(),this.clause(r),this},A.QueryParseError=function(e,t,r){this.name="QueryParseError",this.message=e,this.start=t,this.end=r},A.QueryParseError.prototype=new Error,A.QueryLexer=function(e){this.lexemes=[],this.str=e,this.length=e.length,this.pos=0,this.start=0,this.escapeCharPositions=[]},A.QueryLexer.prototype.run=function(){for(var e=A.QueryLexer.lexText;e;)e=e(this)},A.QueryLexer.prototype.sliceString=function(){for(var e=[],t=this.start,r=this.pos,n=0;n<this.escapeCharPositions.length;n++)r=this.escapeCharPositions[n],e.push(this.str.slice(t,r)),t=r+1;return e.push(this.str.slice(t,this.pos)),this.escapeCharPositions.length=0,e.join("")},A.QueryLexer.prototype.emit=function(e){this.lexemes.push({type:e,str:this.sliceString(),start:this.start,end:this.pos}),this.start=this.pos},A.QueryLexer.prototype.escapeCharacter=function(){this.escapeCharPositions.push(this.pos-1),this.pos+=1},A.QueryLexer.prototype.next=function(){if(this.pos>=this.length)return A.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},A.QueryLexer.prototype.width=function(){return this.pos-this.start},A.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},A.QueryLexer.prototype.backup=function(){this.pos-=1},A.QueryLexer.prototype.acceptDigitRun=function(){var e,t;do{t=(e=this.next()).charCodeAt(0)}while(t>47&&t<58);e!=A.QueryLexer.EOS&&this.backup()},A.QueryLexer.prototype.more=function(){return this.pos<this.length},A.QueryLexer.EOS="EOS",A.QueryLexer.FIELD="FIELD",A.QueryLexer.TERM="TERM",A.QueryLexer.EDIT_DISTANCE="EDIT_DISTANCE",A.QueryLexer.BOOST="BOOST",A.QueryLexer.PRESENCE="PRESENCE",A.QueryLexer.lexField=function(e){return e.backup(),e.emit(A.QueryLexer.FIELD),e.ignore(),A.QueryLexer.lexText},A.QueryLexer.lexTerm=function(e){if(e.width()>1&&(e.backup(),e.emit(A.QueryLexer.TERM)),e.ignore(),e.more())return A.QueryLexer.lexText},A.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(A.QueryLexer.EDIT_DISTANCE),A.QueryLexer.lexText},A.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(A.QueryLexer.BOOST),A.QueryLexer.lexText},A.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(A.QueryLexer.TERM)},A.QueryLexer.termSeparator=A.tokenizer.separator,A.QueryLexer.lexText=function(e){for(;;){var t=e.next();if(t==A.QueryLexer.EOS)return A.QueryLexer.lexEOS;if(92!=t.charCodeAt(0)){if(":"==t)return A.QueryLexer.lexField;if("~"==t)return e.backup(),e.width()>0&&e.emit(A.QueryLexer.TERM),A.QueryLexer.lexEditDistance;if("^"==t)return e.backup(),e.width()>0&&e.emit(A.QueryLexer.TERM),A.QueryLexer.lexBoost;if("+"==t&&1===e.width())return e.emit(A.QueryLexer.PRESENCE),A.QueryLexer.lexText;if("-"==t&&1===e.width())return e.emit(A.QueryLexer.PRESENCE),A.QueryLexer.lexText;if(t.match(A.QueryLexer.termSeparator))return A.QueryLexer.lexTerm}else e.escapeCharacter()}},A.QueryParser=function(e,t){this.lexer=new A.QueryLexer(e),this.query=t,this.currentClause={},this.lexemeIdx=0},A.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=A.QueryParser.parseClause;e;)e=e(this);return this.query},A.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},A.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},A.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},A.QueryParser.parseClause=function(e){var t=e.peekLexeme();if(null!=t)switch(t.type){case A.QueryLexer.PRESENCE:return A.QueryParser.parsePresence;case A.QueryLexer.FIELD:return A.QueryParser.parseField;case A.QueryLexer.TERM:return A.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+t.type;throw t.str.length>=1&&(r+=" with value '"+t.str+"'"),new A.QueryParseError(r,t.start,t.end)}},A.QueryParser.parsePresence=function(e){var t=e.consumeLexeme();if(null!=t){switch(t.str){case"-":e.currentClause.presence=A.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=A.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+t.str+"'";throw new A.QueryParseError(r,t.start,t.end)}var n=e.peekLexeme();if(null==n){r="expecting term or field, found nothing";throw new A.QueryParseError(r,t.start,t.end)}switch(n.type){case A.QueryLexer.FIELD:return A.QueryParser.parseField;case A.QueryLexer.TERM:return A.QueryParser.parseTerm;default:r="expecting term or field, found '"+n.type+"'";throw new A.QueryParseError(r,n.start,n.end)}}},A.QueryParser.parseField=function(e){var t=e.consumeLexeme();if(null!=t){if(-1==e.query.allFields.indexOf(t.str)){var r=e.query.allFields.map((function(e){return"'"+e+"'"})).join(", "),n="unrecognised field '"+t.str+"', possible fields: "+r;throw new A.QueryParseError(n,t.start,t.end)}e.currentClause.fields=[t.str];var i=e.peekLexeme();if(null==i){n="expecting term, found nothing";throw new A.QueryParseError(n,t.start,t.end)}if(i.type===A.QueryLexer.TERM)return A.QueryParser.parseTerm;n="expecting term, found '"+i.type+"'";throw new A.QueryParseError(n,i.start,i.end)}},A.QueryParser.parseTerm=function(e){var t=e.consumeLexeme();if(null!=t){e.currentClause.term=t.str.toLowerCase(),-1!=t.str.indexOf("*")&&(e.currentClause.usePipeline=!1);var r=e.peekLexeme();if(null!=r)switch(r.type){case A.QueryLexer.TERM:return e.nextClause(),A.QueryParser.parseTerm;case A.QueryLexer.FIELD:return e.nextClause(),A.QueryParser.parseField;case A.QueryLexer.EDIT_DISTANCE:return A.QueryParser.parseEditDistance;case A.QueryLexer.BOOST:return A.QueryParser.parseBoost;case A.QueryLexer.PRESENCE:return e.nextClause(),A.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+r.type+"'";throw new A.QueryParseError(n,r.start,r.end)}else e.nextClause()}},A.QueryParser.parseEditDistance=function(e){var t=e.consumeLexeme();if(null!=t){var r=parseInt(t.str,10);if(isNaN(r)){var n="edit distance must be numeric";throw new A.QueryParseError(n,t.start,t.end)}e.currentClause.editDistance=r;var i=e.peekLexeme();if(null!=i)switch(i.type){case A.QueryLexer.TERM:return e.nextClause(),A.QueryParser.parseTerm;case A.QueryLexer.FIELD:return e.nextClause(),A.QueryParser.parseField;case A.QueryLexer.EDIT_DISTANCE:return A.QueryParser.parseEditDistance;case A.QueryLexer.BOOST:return A.QueryParser.parseBoost;case A.QueryLexer.PRESENCE:return e.nextClause(),A.QueryParser.parsePresence;default:n="Unexpected lexeme type '"+i.type+"'";throw new A.QueryParseError(n,i.start,i.end)}else e.nextClause()}},A.QueryParser.parseBoost=function(e){var t=e.consumeLexeme();if(null!=t){var r=parseInt(t.str,10);if(isNaN(r)){var n="boost must be numeric";throw new A.QueryParseError(n,t.start,t.end)}e.currentClause.boost=r;var i=e.peekLexeme();if(null!=i)switch(i.type){case A.QueryLexer.TERM:return e.nextClause(),A.QueryParser.parseTerm;case A.QueryLexer.FIELD:return e.nextClause(),A.QueryParser.parseField;case A.QueryLexer.EDIT_DISTANCE:return A.QueryParser.parseEditDistance;case A.QueryLexer.BOOST:return A.QueryParser.parseBoost;case A.QueryLexer.PRESENCE:return e.nextClause(),A.QueryParser.parsePresence;default:n="Unexpected lexeme type '"+i.type+"'";throw new A.QueryParseError(n,i.start,i.end)}else e.nextClause()}},void 0===(i="function"==typeof(n=function(){return A})?n.call(t,r,t,e):n)||(e.exports=i)}()}}]);