UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

1 lines 24.7 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[92769],{78648:function(t,e,s){s.d(e,{A:function(){return it}});var i=s(86518);s(16280),s(44114),s(26910),s(18111),s(22489),s(7588),s(61701),s(33110),s(45367),s(92731),s(84864),s(57465),s(27495),s(17642),s(58004),s(33853),s(45876),s(32475),s(15024),s(31698),s(25440),s(42762),s(62953);const n=["getFn"];function r(t){return Array.isArray?Array.isArray(t):"[object Array]"===g(t)}function c(t){return null==t?"":function(t){if("string"==typeof t)return t;if("bigint"==typeof t)return t.toString();const e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(t)}function o(t){return"string"==typeof t}function u(t){return"number"==typeof t}function h(t){return!0===t||!1===t||function(t){return a(t)&&null!==t}(t)&&"[object Boolean]"==g(t)}function a(t){return"object"==typeof t}function l(t){return null!=t}function d(t){return!t.trim().length}function g(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const f=Object.prototype.hasOwnProperty;class p{get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(t=>{const s=A(t);this._keys.push(s),this._keyMap[s.id]=s,e+=s.weight}),this._keys.forEach(t=>{t.weight/=e})}}function A(t){let e=null,s=null,i=null,n=1,c=null;if(o(t)||r(t))i=t,e=m(t),s=C(t);else{if(!f.call(t,"name"))throw new Error((t=>`Missing ${t} property in key`)("name"));const r=t.name;if(i=r,f.call(t,"weight")&&(n=t.weight,n<=0))throw new Error((t=>`Property 'weight' in key '${t}' must be a positive integer`)(r));e=m(r),s=C(r),c=t.getFn}return{path:e,id:s,weight:n,src:i,getFn:c}}function m(t){return r(t)?t:t.split(".")}function C(t){return r(t)?t.join("."):t}const M={useExtendedSearch:!1,useTokenSearch:!1,getFn:function(t,e){const s=[];let i=!1;const n=(t,e,a,d)=>{if(l(t))if(e[a]){const g=t[e[a]];if(!l(g))return;if(a===e.length-1&&(o(g)||u(g)||h(g)||"bigint"==typeof g))s.push(void 0!==d?{v:c(g),i:d}:c(g));else if(r(g)){i=!0;for(let t=0,s=g.length;t<s;t+=1)n(g[t],e,a+1,t)}else e.length&&n(g,e,a+1,d)}else s.push(void 0!==d?{v:t,i:d}:t)};return n(t,o(e)?e.split("."):e,0),i?s:s[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},y=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign({},{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1}),{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1}),{location:0,threshold:.6,distance:100}),M)),x=/[^ ]+/g;class F{setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((t,e)=>{this._keysMap[t.id]=e})}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,o(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();o(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,s=this.size();e<s;e+=1)this.records[e].i-=1}removeAll(t){for(let e=t.length-1;e>=0;e-=1)this.records.splice(t[e],1);for(let e=0,s=this.records.length;e<s;e+=1)this.records[e].i=e}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!l(t)||d(t))return;const s={v:t,i:e,n:this.norm.get(t)};this.records.push(s)}_addObject(t,e){const s={i:e,$:{}};this.keys.forEach((e,i)=>{const n=e.getFn?e.getFn(t):this.getFn(t,e.path);if(l(n))if(r(n)){const t=[];for(let e=0,s=n.length;e<s;e+=1){const s=n[e];if(l(s))if(o(s)){if(!d(s)){const i={v:s,i:e,n:this.norm.get(s)};t.push(i)}}else if(l(s.v)){const e=o(s.v)?s.v:c(s.v);if(!d(e)){const i={v:e,i:s.i,n:this.norm.get(e)};t.push(i)}}}s.$[i]=t}else if(o(n)&&!d(n)){const t={v:n,n:this.norm.get(n)};s.$[i]=t}}),this.records.push(s)}toJSON(){return{keys:this.keys.map(t=>{let{getFn:e}=t;return(0,i.A)(t,n)}),records:this.records}}constructor({getFn:t=y.getFn,fieldNormWeight:e=y.fieldNormWeight}={}){this.norm=function(t=1,e=3){const s=new Map,i=Math.pow(10,e);return{get(e){const n=e.match(x).length;if(s.has(n))return s.get(n);const r=1/Math.pow(n,.5*t),c=parseFloat(Math.round(r*i)/i);return s.set(n,c),c},clear(){s.clear()}}}(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}}function D(t,e,{getFn:s=y.getFn,fieldNormWeight:i=y.fieldNormWeight}={}){const n=new F({getFn:s,fieldNormWeight:i});return n.setKeys(t.map(A)),n.setSources(e),n.create(),n}const E=32;function v(t,e,s,{location:i=y.location,distance:n=y.distance,threshold:r=y.threshold,findAllMatches:c=y.findAllMatches,minMatchCharLength:o=y.minMatchCharLength,includeMatches:u=y.includeMatches,ignoreLocation:h=y.ignoreLocation}={}){if(e.length>E)throw new Error(`Pattern length exceeds max of ${E}.`);const a=e.length,l=t.length,d=Math.max(0,Math.min(i,l));let g=r,f=d;const p=(t,e)=>{const s=t/a;if(h)return s;const i=Math.abs(d-e);return n?s+i/n:i?1:s},A=o>1||u,m=A?Array(l):[];let C;for(;(C=t.indexOf(e,f))>-1;){const t=p(0,C);if(g=Math.min(t,g),f=C+a,A){let t=0;for(;t<a;)m[C+t]=1,t+=1}}f=-1;let M=[],x=1,F=a+l;const D=1<<a-1;for(let y=0;y<a;y+=1){let e=0,i=F;for(;e<i;){p(y,d+i)<=g?e=i:F=i,i=Math.floor((F-e)/2+e)}F=i;let n=Math.max(1,d-i+1);const r=c?l:Math.min(d+i,l)+a,o=Array(r+2);o[r+1]=(1<<y)-1;for(let c=r;c>=n;c-=1){const e=c-1,i=s[t[e]];if(A&&(m[e]=+!!i),o[c]=(o[c+1]<<1|1)&i,y&&(o[c]|=(M[c+1]|M[c])<<1|1|M[c+1]),o[c]&D&&(x=p(y,e),x<=g)){if(g=x,f=e,f<=d)break;n=Math.max(1,2*d-f)}}if(p(y+1,d)>g)break;M=o}const v={isMatch:f>=0,score:Math.max(.001,x)};if(A){const t=function(t=[],e=y.minMatchCharLength){const s=[];let i=-1,n=-1,r=0;for(let c=t.length;r<c;r+=1){const c=t[r];c&&-1===i?i=r:c||-1===i||(n=r-1,n-i+1>=e&&s.push([i,n]),i=-1)}return t[r-1]&&r-i>=e&&s.push([i,r-1]),s}(m,o);t.length?u&&(v.indices=t):v.isMatch=!1}return v}function _(t){const e={};for(let s=0,i=t.length;s<i;s+=1){const n=t.charAt(s);e[n]=(e[n]||0)|1<<i-s-1}return e}function B(t){if(t.length<=1)return t;t.sort((t,e)=>t[0]-e[0]||t[1]-e[1]);const e=[t[0]];for(let s=1,i=t.length;s<i;s+=1){const i=e[e.length-1],n=t[s];n[0]<=i[1]+1?i[1]=Math.max(i[1],n[1]):e.push(n)}return e}const k={"ł":"l","Ł":"L","đ":"d","Đ":"D","ø":"o","Ø":"O","ħ":"h","Ħ":"H","ŧ":"t","Ŧ":"T","ı":"i","ß":"ss"},I=new RegExp("["+Object.keys(k).join("")+"]","g"),S=String.prototype.normalize?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(I,t=>k[t]):t=>t;class b{searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:s,includeMatches:i}=this.options;if(t=e?t:t.toLowerCase(),t=s?S(t):t,this.pattern===t){const e={isMatch:!0,score:0};return i&&(e.indices=[[0,t.length-1]]),e}const{location:n,distance:r,threshold:c,findAllMatches:o,minMatchCharLength:u,ignoreLocation:h}=this.options,a=[];let l=0,d=!1;this.chunks.forEach(({pattern:e,alphabet:s,startIndex:g})=>{const{isMatch:f,score:p,indices:A}=v(t,e,s,{location:n+g,distance:r,threshold:c,findAllMatches:o,minMatchCharLength:u,includeMatches:i,ignoreLocation:h});f&&(d=!0),l+=p,f&&A&&a.push(...A)});const g={isMatch:d,score:d?l/this.chunks.length:1};return d&&i&&(g.indices=B(a)),g}constructor(t,{location:e=y.location,threshold:s=y.threshold,distance:i=y.distance,includeMatches:n=y.includeMatches,findAllMatches:r=y.findAllMatches,minMatchCharLength:c=y.minMatchCharLength,isCaseSensitive:o=y.isCaseSensitive,ignoreDiacritics:u=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){if(this.options={location:e,threshold:s,distance:i,includeMatches:n,findAllMatches:r,minMatchCharLength:c,isCaseSensitive:o,ignoreDiacritics:u,ignoreLocation:h},t=o?t:t.toLowerCase(),t=u?S(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const a=(t,e)=>{this.chunks.push({pattern:t,alphabet:_(t),startIndex:e})},l=this.pattern.length;if(l>E){let t=0;const e=l%E,s=l-e;for(;t<s;)a(this.pattern.substr(t,E),t),t+=E;if(e){const t=l-E;a(this.pattern.substr(t),t)}}else a(this.pattern,0)}}class w{static isMultiMatch(t){return L(t,this.multiRegex)}static isSingleMatch(t){return L(t,this.singleRegex)}search(t){return{isMatch:!1,score:1}}constructor(t){this.pattern=t}}function L(t,e){const s=t.match(e);return s?s[1]:null}class $ extends w{static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}constructor(t,{location:e=y.location,threshold:s=y.threshold,distance:i=y.distance,includeMatches:n=y.includeMatches,findAllMatches:r=y.findAllMatches,minMatchCharLength:c=y.minMatchCharLength,isCaseSensitive:o=y.isCaseSensitive,ignoreDiacritics:u=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){super(t),this._bitapSearch=new b(t,{location:e,threshold:s,distance:i,includeMatches:n,findAllMatches:r,minMatchCharLength:c,isCaseSensitive:o,ignoreDiacritics:u,ignoreLocation:h})}}class N extends w{static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e,s=0;const i=[],n=this.pattern.length;for(;(e=t.indexOf(this.pattern,s))>-1;)s=e+n,i.push([e,s-1]);const r=!!i.length;return{isMatch:r,score:r?0:1,indices:i}}constructor(t){super(t)}}const O=[class extends w{static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}constructor(t){super(t)}},N,class extends w{static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}constructor(t){super(t)}},class extends w{static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}constructor(t){super(t)}},class extends w{static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}constructor(t){super(t)}},class extends w{static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}constructor(t){super(t)}},class extends w{static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const e=-1===t.indexOf(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}constructor(t){super(t)}},$],j=O.length;const R=new Set([$.type,N.type]);class W{static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:s,isCaseSensitive:i,ignoreDiacritics:n}=this.options;t=i?t:t.toLowerCase(),t=n?S(t):t;let r=0;const c=[];let o=0,u=!1;for(let h=0,a=e.length;h<a;h+=1){const i=e[h];c.length=0,r=0,u=!1;for(let e=0,n=i.length;e<n;e+=1){const n=i[e],{isMatch:h,indices:a,score:l}=n.search(t);if(!h){o=0,r=0,c.length=0,u=!1;break}{r+=1,o+=l;const t=n.constructor.type;t.startsWith("inverse")&&(u=!0),s&&(R.has(t)?c.push(...a):c.push(a))}}if(r){const t={isMatch:!0,score:o/r};return u&&(t.hasInverse=!0),s&&(t.indices=B(c)),t}}return{isMatch:!1,score:1}}constructor(t,{isCaseSensitive:e=y.isCaseSensitive,ignoreDiacritics:s=y.ignoreDiacritics,includeMatches:i=y.includeMatches,minMatchCharLength:n=y.minMatchCharLength,ignoreLocation:r=y.ignoreLocation,findAllMatches:c=y.findAllMatches,location:o=y.location,threshold:u=y.threshold,distance:h=y.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:s,includeMatches:i,minMatchCharLength:n,findAllMatches:c,ignoreLocation:r,location:o,threshold:u,distance:h},t=e?t:t.toLowerCase(),t=s?S(t):t,this.pattern=t,this.query=function(t,e={}){return t.replace(/\\\|/g,"\0").split("|").map(t=>{const s=function(t){const e=[],s=t.length;let i=0;for(;i<s;){for(;i<s&&" "===t[i];)i++;if(i>=s)break;let n=i;for(;n<s&&" "!==t[n]&&'"'!==t[n];)n++;if(n<s&&'"'===t[n]){for(n++;n<s;){if('"'===t[n]){const e=n+1;if(e>=s||" "===t[e]){n++;break}if("$"===t[e]&&(e+1>=s||" "===t[e+1])){n+=2;break}}n++}e.push(t.substring(i,n)),i=n}else{for(;n<s&&" "!==t[n];)n++;e.push(t.substring(i,n)),i=n}}return e}(t.replace(/\u0000/g,"|").trim()).filter(t=>t&&!!t.trim()),i=[];for(let n=0,r=s.length;n<r;n+=1){const t=s[n];let r=!1,c=-1;for(;!r&&++c<j;){const s=O[c],n=s.isMultiMatch(t);n&&(i.push(new s(n,e)),r=!0)}if(!r)for(c=-1;++c<j;){const s=O[c],n=s.isSingleMatch(t);if(n){i.push(new s(n,e));break}}}return i})}(this.pattern,this.options)}}const z=[];function K(...t){z.push(...t)}function T(t,e){for(let s=0,i=z.length;s<i;s+=1){const i=z[s];if(i.condition(t,e))return new i(t,e)}return new b(t,e)}const P="$and",Q="$or",q="$path",J="$val",U=t=>!(!t[P]&&!t[Q]),V=t=>({[P]:Object.keys(t).map(e=>({[e]:t[e]}))});function H(t,e,{auto:s=!0}={}){const i=t=>{if(o(t)){const i={keyId:null,pattern:t};return s&&(i.searcher=T(t,e)),i}const n=Object.keys(t),c=(t=>!!t[q])(t);if(!c&&n.length>1&&!U(t))return i(V(t));if((t=>!r(t)&&a(t)&&!U(t))(t)){const i=c?t[q]:n[0],r=c?t[J]:t[i];if(!o(r))throw new Error((t=>`Invalid value for key ${t}`)(i));const u={keyId:C(i),pattern:r};return s&&(u.searcher=T(r,e)),u}const u={children:[],operator:n[0]};return n.forEach(e=>{const s=t[e];r(s)&&s.forEach(t=>{u.children.push(i(t))})}),u};return U(t)||(t=V(t)),i(t)}function G(t,{ignoreFieldNorm:e=y.ignoreFieldNorm}){let s=1;return t.forEach(({key:t,norm:i,score:n})=>{const r=t?t.weight:null;s*=Math.pow(0===n&&r?Number.EPSILON:n,(r||1)*(e?1:i))}),s}class X{get size(){return this.heap.length}shouldInsert(t){return this.size<this.limit||t<this.heap[0].score}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):t.score<this.heap[0].score&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(t){return this.heap.sort(t)}_bubbleUp(t){const e=this.heap;for(;t>0;){const s=t-1>>1;if(e[t].score<=e[s].score)break;const i=e[t];e[t]=e[s],e[s]=i,t=s}}_sinkDown(t){const e=this.heap,s=e.length;let i=t;do{const n=2*(t=i)+1,r=2*t+2;if(n<s&&e[n].score>e[i].score&&(i=n),r<s&&e[r].score>e[i].score&&(i=r),i!==t){const s=e[t];e[t]=e[i],e[i]=s}}while(i!==t)}constructor(t){this.limit=t,this.heap=[]}}function Y(t,e){const s=t.matches;e.matches=[],l(s)&&s.forEach(t=>{if(!l(t.indices)||!t.indices.length)return;const{indices:s,value:i}=t,n={indices:s,value:i};t.key&&(n.key=t.key.src),t.idx>-1&&(n.refIndex=t.idx),e.matches.push(n)})}function Z(t,e){e.score=t.score}const tt=/\b\w+\b/g;function et({isCaseSensitive:t=!1,ignoreDiacritics:e=!1}={}){return{tokenize(s){return t||(s=s.toLowerCase()),e&&(s=S(s)),s.match(tt)||[]}}}function st(t,e){for(const[s,i]of t.terms){const n=i.filter(t=>t.docIdx!==e),r=i.length-n.length;r>0&&(t.fieldCount-=r,t.df.set(s,(t.df.get(s)||0)-r),0===n.length?(t.terms.delete(s),t.df.delete(s)):t.terms.set(s,n))}}class it{_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=T(t,this._invertedIndex?Object.assign(Object.assign({},this.options),{},{_invertedIndex:this._invertedIndex}):this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof F))throw new Error("Incorrect 'index' type");if(this._myIndex=e||D(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const t=et({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});this._invertedIndex=function(t,e,s){const i=new Map,n=new Map;let r=0;function c(t,e,c,o){const u=s.tokenize(t);if(!u.length)return;r++;const h=new Map;for(const s of u)h.set(s,(h.get(s)||0)+1);for(const[s,r]of h){const t={docIdx:e,keyIdx:c,subIdx:o,tf:r};let u=i.get(s);u||(u=[],i.set(s,u)),u.push(t),n.set(s,(n.get(s)||0)+1)}}for(const u of t){const{i:t,v:s,$:i}=u;if(void 0===s){if(i)for(let n=0;n<e;n++){const e=i[n];if(e)if(Array.isArray(e))for(const s of e){var o;c(s.v,t,n,null!==(o=s.i)&&void 0!==o?o:-1)}else c(e.v,t,n,-1)}}else c(s,t,-1,-1)}return{terms:i,fieldCount:r,df:n}}(this._myIndex.records,this._myIndex.keys.length,t)}}add(t){if(l(t)&&(this._docs.push(t),this._myIndex.add(t),this._invertedIndex)){const t=this._myIndex.records[this._myIndex.records.length-1],e=et({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});!function(t,e,s,i){const{i:n,v:r,$:c}=e;function o(e,s,r){const c=i.tokenize(e);if(!c.length)return;t.fieldCount++;const o=new Map;for(const t of c)o.set(t,(o.get(t)||0)+1);for(const[i,u]of o){const e={docIdx:n,keyIdx:s,subIdx:r,tf:u};let c=t.terms.get(i);c||(c=[],t.terms.set(i,c)),c.push(e),t.df.set(i,(t.df.get(i)||0)+1)}}if(void 0===r){if(c)for(let h=0;h<s;h++){const t=c[h];if(t)if(Array.isArray(t))for(const e of t){var u;o(e.v,h,null!==(u=e.i)&&void 0!==u?u:-1)}else o(t.v,h,-1)}}else o(r,-1,-1)}(this._invertedIndex,t,this._myIndex.keys.length,e)}}remove(t=()=>!1){const e=[],s=[];for(let i=0,n=this._docs.length;i<n;i+=1)t(this._docs[i],i)&&(e.push(this._docs[i]),s.push(i));if(s.length){if(this._invertedIndex)for(const t of s)st(this._invertedIndex,t);for(let t=s.length-1;t>=0;t-=1)this._docs.splice(s[t],1);this._myIndex.removeAll(s)}return e}removeAt(t){this._invertedIndex&&st(this._invertedIndex,t);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),e}getIndex(){return this._myIndex}search(t,e){const{limit:s=-1}=e||{},{includeMatches:i,includeScore:n,shouldSort:r,sortFn:c,ignoreFieldNorm:h}=this.options;if(o(t)&&!t.trim()){let t=this._docs.map((t,e)=>({item:t,refIndex:e}));return u(s)&&s>-1&&(t=t.slice(0,s)),t}let a;if(u(s)&&s>0&&o(t)){const e=new X(s);o(this._docs[0])?this._searchStringList(t,{heap:e,ignoreFieldNorm:h}):this._searchObjectList(t,{heap:e,ignoreFieldNorm:h}),a=e.extractSorted(c)}else a=o(t)?o(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),function(t,{ignoreFieldNorm:e=y.ignoreFieldNorm}){t.forEach(t=>{t.score=G(t.matches,{ignoreFieldNorm:e})})}(a,{ignoreFieldNorm:h}),r&&a.sort(c),u(s)&&s>-1&&(a=a.slice(0,s));return function(t,e,{includeMatches:s=y.includeMatches,includeScore:i=y.includeScore}={}){const n=[];return s&&n.push(Y),i&&n.push(Z),t.map(t=>{const{idx:s}=t,i={item:e[s],refIndex:s};return n.length&&n.forEach(e=>{e(t,i)}),i})}(a,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(t,{heap:e,ignoreFieldNorm:s}={}){const i=this._getSearcher(t),{records:n}=this._myIndex,r=e?null:[];return n.forEach(({v:t,i:n,n:c})=>{if(!l(t))return;const{isMatch:o,score:u,indices:h}=i.searchIn(t);if(o){const i={item:t,idx:n,matches:[{score:u,value:t,norm:c,indices:h}]};e?(i.score=G(i.matches,{ignoreFieldNorm:s}),e.shouldInsert(i.score)&&e.insert(i)):r.push(i)}}),r}_searchLogical(t){const e=H(t,this.options),s=(t,e,i)=>{if(!("children"in t)){const{keyId:s,searcher:n}=t;let r;return null===s?(r=[],this._myIndex.keys.forEach((t,s)=>{r.push(...this._findMatches({key:t,value:e[s],searcher:n}))})):r=this._findMatches({key:this._keyStore.get(s),value:this._myIndex.getValueForItemAtKeyId(e,s),searcher:n}),r&&r.length?[{idx:i,item:e,matches:r}]:[]}const{children:n,operator:r}=t,c=[];for(let o=0,u=n.length;o<u;o+=1){const t=n[o],u=s(t,e,i);if(u.length)c.push(...u);else if(r===P)return[]}return c},i=this._myIndex.records,n=new Map,r=[];return i.forEach(({$:t,i:i})=>{if(l(t)){const c=s(e,t,i);c.length&&(n.has(i)||(n.set(i,{idx:i,item:t,matches:[]}),r.push(n.get(i))),c.forEach(({matches:t})=>{n.get(i).matches.push(...t)}))}}),r}_searchObjectList(t,{heap:e,ignoreFieldNorm:s}={}){const i=this._getSearcher(t),{keys:n,records:r}=this._myIndex,c=e?null:[];return r.forEach(({$:t,i:r})=>{if(!l(t))return;const o=[];let u=!1,h=!1;if(n.forEach((e,s)=>{const n=this._findMatches({key:e,value:t[s],searcher:i});n.length?(o.push(...n),n[0].hasInverse&&(h=!0)):u=!0}),(!h||!u)&&o.length){const i={idx:r,item:t,matches:o};e?(i.score=G(i.matches,{ignoreFieldNorm:s}),e.shouldInsert(i.score)&&e.insert(i)):c.push(i)}}),c}_findMatches({key:t,value:e,searcher:s}){if(!l(e))return[];const i=[];if(r(e))e.forEach(({v:e,i:n,n:r})=>{if(!l(e))return;const{isMatch:c,score:o,indices:u,hasInverse:h}=s.searchIn(e);c&&i.push({score:o,key:t,value:e,idx:n,norm:r,indices:u,hasInverse:h})});else{const{v:n,n:r}=e,{isMatch:c,score:o,indices:u,hasInverse:h}=s.searchIn(n);c&&i.push({score:o,key:t,value:n,norm:r,indices:u,hasInverse:h})}return i}constructor(t,e,s){this.options=Object.assign(Object.assign({},y),e),this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new p(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,s),this._lastQuery=null,this._lastSearcher=null}}class nt{static condition(t,e){return e.useTokenSearch}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let s=0,i=0,n=0;for(let o=0;o<this.termSearchers.length;o++){const r=this.termSearchers[o].searchIn(t),c=this.idfWeights[o];i+=c,r.isMatch&&(n++,s+=c*(1-r.score),r.indices&&e.push(...r.indices))}if(0===n)return{isMatch:!1,score:1};const r=i>0?1-s/i:0,c={isMatch:!0,score:Math.max(.001,r)};return this.options.includeMatches&&e.length&&(c.indices=B(e)),c}constructor(t,e){this.options=e,this.analyzer=et({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics});const s=this.analyzer.tokenize(t),i=e._invertedIndex,{df:n,fieldCount:r}=i;this.termSearchers=[],this.idfWeights=[];for(const c of s){this.termSearchers.push(new b(c,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const t=n.get(c)||0,s=Math.log(1+(r-t+.5)/(t+.5));this.idfWeights.push(s)}}}it.version="7.3.0",it.createIndex=D,it.parseIndex=function(t,{getFn:e=y.getFn,fieldNormWeight:s=y.fieldNormWeight}={}){const{keys:i,records:n}=t,r=new F({getFn:e,fieldNormWeight:s});return r.setKeys(i),r.setIndexRecords(n),r},it.config=y,it.match=function(t,e,s){return T(t,Object.assign(Object.assign({},y),s)).searchIn(e)},it.parseQuery=H,K(W),K(nt),it.use=function(...t){t.forEach(t=>K(t))}}}]);