@zh-keyboard/vue
Version:
基于Vue的中文虚拟键盘组件
3 lines • 153 kB
JavaScript
(function(de,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],o):(de=typeof globalThis<"u"?globalThis:de||self,o(de.ZhKeyboardVue={},de.Vue))})(this,function(de,o){"use strict";var Kh=Object.defineProperty;var zh=(de,o,Ce)=>o in de?Kh(de,o,{enumerable:!0,configurable:!0,writable:!0,value:Ce}):de[o]=Ce;var le=(de,o,Ce)=>zh(de,typeof o!="symbol"?o+"":o,Ce);function Ce(b){return o.getCurrentScope()?(o.onScopeDispose(b),!0):!1}const Lr=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Fr=b=>b!=null,$r=Object.prototype.toString,Hr=b=>$r.call(b)==="[object Object]",Ur=()=>{};function lt(b){return Array.isArray(b)?b:[b]}function Wr(b){return o.getCurrentInstance()}function Yr(b,E=!0,B){Wr()?o.onMounted(b,B):E?b():o.nextTick(b)}function Xr(b,E,B){return o.watch(b,E,{...B,immediate:!0})}const Je=Lr?window:void 0;function Se(b){var E;const B=o.toValue(b);return(E=B==null?void 0:B.$el)!=null?E:B}function St(...b){const E=[],B=()=>{E.forEach(z=>z()),E.length=0},k=(z,I,$,q)=>(z.addEventListener(I,$,q),()=>z.removeEventListener(I,$,q)),D=o.computed(()=>{const z=lt(o.toValue(b[0])).filter(I=>I!=null);return z.every(I=>typeof I!="string")?z:void 0}),S=Xr(()=>{var z,I;return[(I=(z=D.value)==null?void 0:z.map($=>Se($)))!=null?I:[Je].filter($=>$!=null),lt(o.toValue(D.value?b[1]:b[0])),lt(o.unref(D.value?b[2]:b[1])),o.toValue(D.value?b[3]:b[2])]},([z,I,$,q])=>{if(B(),!(z!=null&&z.length)||!(I!=null&&I.length)||!($!=null&&$.length))return;const V=Hr(q)?{...q}:q;E.push(...z.flatMap(F=>I.flatMap(ee=>$.map(U=>k(F,ee,U,V)))))},{flush:"post"}),C=()=>{S(),B()};return Ce(B),C}function Gr(){const b=o.shallowRef(!1),E=o.getCurrentInstance();return E&&o.onMounted(()=>{b.value=!0},E),b}function Gn(b){const E=Gr();return o.computed(()=>(E.value,!!b()))}function Qr(b,E,B={}){const{window:k=Je,...D}=B;let S;const C=Gn(()=>k&&"MutationObserver"in k),z=()=>{S&&(S.disconnect(),S=void 0)},I=o.computed(()=>{const F=o.toValue(b),ee=lt(F).map(Se).filter(Fr);return new Set(ee)}),$=o.watch(()=>I.value,F=>{z(),C.value&&F.size&&(S=new MutationObserver(E),F.forEach(ee=>S.observe(ee,D)))},{immediate:!0,flush:"post"}),q=()=>S==null?void 0:S.takeRecords(),V=()=>{$(),z()};return Ce(V),{isSupported:C,stop:V,takeRecords:q}}function Zr(b,E,B={}){const{window:k=Je,document:D=k==null?void 0:k.document,flush:S="sync"}=B;if(!k||!D)return Ur;let C;const z=q=>{C==null||C(),C=q},I=o.watchEffect(()=>{const q=Se(b);if(q){const{stop:V}=Qr(D,F=>{F.map(U=>[...U.removedNodes]).flat().some(U=>U===q||U.contains(q))&&E(F)},{window:k,childList:!0,subtree:!0});z(V)}},{flush:S}),$=()=>{I(),z()};return Ce($),$}function Jr(b={}){var E;const{window:B=Je,deep:k=!0,triggerOnRemoval:D=!1}=b,S=(E=b.document)!=null?E:B==null?void 0:B.document,C=()=>{var $;let q=S==null?void 0:S.activeElement;if(k)for(;q!=null&&q.shadowRoot;)q=($=q==null?void 0:q.shadowRoot)==null?void 0:$.activeElement;return q},z=o.shallowRef(),I=()=>{z.value=C()};if(B){const $={capture:!0,passive:!0};St(B,"blur",q=>{q.relatedTarget===null&&I()},$),St(B,"focus",I,$)}return D&&Zr(z,I,{document:S}),I(),z}function ea(b,E,B={}){const{window:k=Je,...D}=B;let S;const C=Gn(()=>k&&"ResizeObserver"in k),z=()=>{S&&(S.disconnect(),S=void 0)},I=o.computed(()=>{const V=o.toValue(b);return Array.isArray(V)?V.map(F=>Se(F)):[Se(V)]}),$=o.watch(I,V=>{if(z(),C.value&&k){S=new ResizeObserver(E);for(const F of V)F&&S.observe(F,D)}},{immediate:!0,flush:"post"}),q=()=>{z(),$()};return Ce(q),{isSupported:C,stop:q}}function Qn(b,E={width:0,height:0},B={}){const{window:k=Je,box:D="content-box"}=B,S=o.computed(()=>{var V,F;return(F=(V=Se(b))==null?void 0:V.namespaceURI)==null?void 0:F.includes("svg")}),C=o.shallowRef(E.width),z=o.shallowRef(E.height),{stop:I}=ea(b,([V])=>{const F=D==="border-box"?V.borderBoxSize:D==="content-box"?V.contentBoxSize:V.devicePixelContentBoxSize;if(k&&S.value){const ee=Se(b);if(ee){const U=ee.getBoundingClientRect();C.value=U.width,z.value=U.height}}else if(F){const ee=lt(F);C.value=ee.reduce((U,{inlineSize:H})=>U+H,0),z.value=ee.reduce((U,{blockSize:H})=>U+H,0)}else C.value=V.contentRect.width,z.value=V.contentRect.height},B);Yr(()=>{const V=Se(b);V&&(C.value="offsetWidth"in V?V.offsetWidth:E.width,z.value="offsetHeight"in V?V.offsetHeight:E.height)});const $=o.watch(()=>Se(b),V=>{C.value=V?E.width:0,z.value=V?E.height:0});function q(){I(),$()}return{width:C,height:z,stop:q}}var ta=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function na(b){return b&&b.__esModule&&Object.prototype.hasOwnProperty.call(b,"default")?b.default:b}var Bt={exports:{}},ra=Bt.exports,Zn;function aa(){return Zn||(Zn=1,function(b,E){(function(B,k){b.exports=k()})(ra,function(){var B=function(e,t){return(B=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(n[a]=r[a])})(e,t)},k=function(){return(k=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};function D(e,t,n){for(var r,a=0,i=t.length;a<i;a++)!r&&a in t||((r=r||Array.prototype.slice.call(t,0,a))[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}var S=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:ta,C=Object.keys,z=Array.isArray;function I(e,t){return typeof t!="object"||C(t).forEach(function(n){e[n]=t[n]}),e}typeof Promise>"u"||S.Promise||(S.Promise=Promise);var $=Object.getPrototypeOf,q={}.hasOwnProperty;function V(e,t){return q.call(e,t)}function F(e,t){typeof t=="function"&&(t=t($(e))),(typeof Reflect>"u"?C:Reflect.ownKeys)(t).forEach(function(n){U(e,n,t[n])})}var ee=Object.defineProperty;function U(e,t,n,r){ee(e,t,I(n&&V(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function H(e){return{from:function(t){return e.prototype=Object.create(t.prototype),U(e.prototype,"constructor",e),{extend:F.bind(null,e.prototype)}}}}var fe=Object.getOwnPropertyDescriptor,Re=[].slice;function _e(e,t,n){return Re.call(e,t,n)}function Ve(e,t){return t(e)}function he(e){if(!e)throw new Error("Assertion Failed")}function ne(e){S.setImmediate?setImmediate(e):setTimeout(e,0)}function X(e,t){if(typeof t=="string"&&V(e,t))return e[t];if(!t)return e;if(typeof t!="string"){for(var n=[],r=0,a=t.length;r<a;++r){var i=X(e,t[r]);n.push(i)}return n}var s=t.indexOf(".");if(s!==-1){var u=e[t.substr(0,s)];return u==null?void 0:X(u,t.substr(s+1))}}function te(e,t,n){if(e&&t!==void 0&&!("isFrozen"in Object&&Object.isFrozen(e)))if(typeof t!="string"&&"length"in t){he(typeof n!="string"&&"length"in n);for(var r=0,a=t.length;r<a;++r)te(e,t[r],n[r])}else{var i,s,u=t.indexOf(".");u!==-1?(i=t.substr(0,u),(s=t.substr(u+1))===""?n===void 0?z(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=n:te(u=!(u=e[i])||!V(e,i)?e[i]={}:u,s,n)):n===void 0?z(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function Be(e){var t,n={};for(t in e)V(e,t)&&(n[t]=e[t]);return n}var un=[].concat;function cn(e){return un.apply([],e)}var Fe="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(cn([8,16,32,64].map(function(e){return["Int","Uint","Float"].map(function(t){return t+e+"Array"})}))).filter(function(e){return S[e]}),or=new Set(Fe.map(function(e){return S[e]})),ft=null;function qe(e){return ft=new WeakMap,e=function t(n){if(!n||typeof n!="object")return n;var r=ft.get(n);if(r)return r;if(z(n)){r=[],ft.set(n,r);for(var a=0,i=n.length;a<i;++a)r.push(t(n[a]))}else if(or.has(n.constructor))r=n;else{var s,u=$(n);for(s in r=u===Object.prototype?{}:Object.create(u),ft.set(n,r),n)V(n,s)&&(r[s]=t(n[s]))}return r}(e),ft=null,e}var Qd={}.toString;function ln(e){return Qd.call(e).slice(8,-1)}var fn=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Zd=typeof fn=="symbol"?function(e){var t;return e!=null&&(t=e[fn])&&t.apply(e)}:function(){return null};function Me(e,t){return t=e.indexOf(t),0<=t&&e.splice(t,1),0<=t}var et={};function Oe(e){var t,n,r,a;if(arguments.length===1){if(z(e))return e.slice();if(this===et&&typeof e=="string")return[e];if(a=Zd(e)){for(n=[];!(r=a.next()).done;)n.push(r.value);return n}if(e==null)return[e];if(typeof(t=e.length)!="number")return[e];for(n=new Array(t);t--;)n[t]=e[t];return n}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var dn=typeof Symbol<"u"?function(e){return e[Symbol.toStringTag]==="AsyncFunction"}:function(){return!1},pt=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],we=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(pt),Jd={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function tt(e,t){this.name=e,this.message=t}function sr(e,t){return e+". Errors: "+Object.keys(t).map(function(n){return t[n].toString()}).filter(function(n,r,a){return a.indexOf(n)===r}).join(`
`)}function Dt(e,t,n,r){this.failures=t,this.failedKeys=r,this.successCount=n,this.message=sr(e,t)}function nt(e,t){this.name="BulkError",this.failures=Object.keys(t).map(function(n){return t[n]}),this.failuresByPos=t,this.message=sr(e,this.failures)}H(tt).from(Error).extend({toString:function(){return this.name+": "+this.message}}),H(Dt).from(tt),H(nt).from(tt);var hn=we.reduce(function(e,t){return e[t]=t+"Error",e},{}),eh=tt,L=we.reduce(function(e,t){var n=t+"Error";function r(a,i){this.name=n,a?typeof a=="string"?(this.message="".concat(a).concat(i?`
`+i:""),this.inner=i||null):typeof a=="object"&&(this.message="".concat(a.name," ").concat(a.message),this.inner=a):(this.message=Jd[t]||n,this.inner=null)}return H(r).from(eh),e[t]=r,e},{});L.Syntax=SyntaxError,L.Type=TypeError,L.Range=RangeError;var ur=pt.reduce(function(e,t){return e[t+"Error"]=L[t],e},{}),Kt=we.reduce(function(e,t){return["Syntax","Type","Range"].indexOf(t)===-1&&(e[t+"Error"]=L[t]),e},{});function re(){}function dt(e){return e}function th(e,t){return e==null||e===dt?t:function(n){return t(e(n))}}function Le(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function nh(e,t){return e===re?t:function(){var n=e.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?Le(r,this.onsuccess):r),a&&(this.onerror=this.onerror?Le(a,this.onerror):a),i!==void 0?i:n}}function rh(e,t){return e===re?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?Le(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Le(r,this.onerror):r)}}function ah(e,t){return e===re?t:function(n){var r=e.apply(this,arguments);I(n,r);var a=this.onsuccess,i=this.onerror;return this.onsuccess=null,this.onerror=null,n=t.apply(this,arguments),a&&(this.onsuccess=this.onsuccess?Le(a,this.onsuccess):a),i&&(this.onerror=this.onerror?Le(i,this.onerror):i),r===void 0?n===void 0?void 0:n:I(r,n)}}function ih(e,t){return e===re?t:function(){return t.apply(this,arguments)!==!1&&e.apply(this,arguments)}}function pn(e,t){return e===re?t:function(){var n=e.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,a=arguments.length,i=new Array(a);a--;)i[a]=arguments[a];return n.then(function(){return t.apply(r,i)})}return t.apply(this,arguments)}}Kt.ModifyError=Dt,Kt.DexieError=tt,Kt.BulkError=nt;var ke=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function cr(e){ke=e}var ht={},lr=100,Fe=typeof Promise>"u"?[]:function(){var e=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[e,$(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,$(t),e]}(),pt=Fe[0],we=Fe[1],Fe=Fe[2],we=we&&we.then,$e=pt&&pt.constructor,vn=!!Fe,vt=function(e,t){yt.push([e,t]),zt&&(queueMicrotask(sh),zt=!1)},yn=!0,zt=!0,He=[],Tt=[],mn=dt,Ke={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:re,pgp:!1,env:{},finalize:re},M=Ke,yt=[],Ue=0,At=[];function N(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=M;if(typeof e!="function"){if(e!==ht)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&bn(this,this._value))}this._state=null,this._value=null,++t.ref,function n(r,a){try{a(function(i){if(r._state===null){if(i===r)throw new TypeError("A promise cannot be resolved with itself.");var s=r._lib&&rt();i&&typeof i.then=="function"?n(r,function(u,l){i instanceof N?i._then(u,l):i.then(u,l)}):(r._state=!0,r._value=i,dr(r)),s&&at()}},bn.bind(null,r))}catch(i){bn(r,i)}}(this,e)}var gn={get:function(){var e=M,t=Rt;function n(r,a){var i=this,s=!e.global&&(e!==M||t!==Rt),u=s&&!Te(),l=new N(function(d,v){wn(i,new fr(pr(r,e,s,u),pr(a,e,s,u),d,v,e))});return this._consoleTask&&(l._consoleTask=this._consoleTask),l}return n.prototype=ht,n},set:function(e){U(this,"then",e&&e.prototype===ht?gn:{get:function(){return e},set:gn.set})}};function fr(e,t,n,r,a){this.onFulfilled=typeof e=="function"?e:null,this.onRejected=typeof t=="function"?t:null,this.resolve=n,this.reject=r,this.psd=a}function bn(e,t){var n,r;Tt.push(t),e._state===null&&(n=e._lib&&rt(),t=mn(t),e._state=!1,e._value=t,r=e,He.some(function(a){return a._value===r._value})||He.push(r),dr(e),n&&at())}function dr(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)wn(e,t[n]);var a=e._PSD;--a.ref||a.finalize(),Ue===0&&(++Ue,vt(function(){--Ue==0&&_n()},[]))}function wn(e,t){if(e._state!==null){var n=e._state?t.onFulfilled:t.onRejected;if(n===null)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++Ue,vt(oh,[n,e,t])}else e._listeners.push(t)}function oh(e,t,n){try{var r,a=t._value;!t._state&&Tt.length&&(Tt=[]),r=ke&&t._consoleTask?t._consoleTask.run(function(){return e(a)}):e(a),t._state||Tt.indexOf(a)!==-1||function(i){for(var s=He.length;s;)if(He[--s]._value===i._value)return He.splice(s,1)}(t),n.resolve(r)}catch(i){n.reject(i)}finally{--Ue==0&&_n(),--n.psd.ref||n.psd.finalize()}}function sh(){We(Ke,function(){rt()&&at()})}function rt(){var e=yn;return zt=yn=!1,e}function at(){var e,t,n;do for(;0<yt.length;)for(e=yt,yt=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}while(0<yt.length);zt=yn=!0}function _n(){var e=He;He=[],e.forEach(function(r){r._PSD.onunhandled.call(null,r._value,r)});for(var t=At.slice(0),n=t.length;n;)t[--n]()}function jt(e){return new N(ht,!1,e)}function ie(e,t){var n=M;return function(){var r=rt(),a=M;try{return Ae(n,!0),e.apply(this,arguments)}catch(i){t&&t(i)}finally{Ae(a,!1),r&&at()}}}F(N.prototype,{then:gn,_then:function(e,t){wn(this,new fr(null,null,e,t,M))},catch:function(e){if(arguments.length===1)return this.then(null,e);var t=e,n=arguments[1];return typeof t=="function"?this.then(null,function(r){return(r instanceof t?n:jt)(r)}):this.then(null,function(r){return(r&&r.name===t?n:jt)(r)})},finally:function(e){return this.then(function(t){return N.resolve(e()).then(function(){return t})},function(t){return N.resolve(e()).then(function(){return jt(t)})})},timeout:function(e,t){var n=this;return e<1/0?new N(function(r,a){var i=setTimeout(function(){return a(new L.Timeout(t))},e);n.then(r,a).finally(clearTimeout.bind(null,i))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&U(N.prototype,Symbol.toStringTag,"Dexie.Promise"),Ke.env=hr(),F(N,{all:function(){var e=Oe.apply(null,arguments).map(Vt);return new N(function(t,n){e.length===0&&t([]);var r=e.length;e.forEach(function(a,i){return N.resolve(a).then(function(s){e[i]=s,--r||t(e)},n)})})},resolve:function(e){return e instanceof N?e:e&&typeof e.then=="function"?new N(function(t,n){e.then(t,n)}):new N(ht,!0,e)},reject:jt,race:function(){var e=Oe.apply(null,arguments).map(Vt);return new N(function(t,n){e.map(function(r){return N.resolve(r).then(t,n)})})},PSD:{get:function(){return M},set:function(e){return M=e}},totalEchoes:{get:function(){return Rt}},newPSD:ze,usePSD:We,scheduler:{get:function(){return vt},set:function(e){vt=e}},rejectionMapper:{get:function(){return mn},set:function(e){mn=e}},follow:function(e,t){return new N(function(n,r){return ze(function(a,i){var s=M;s.unhandleds=[],s.onunhandled=i,s.finalize=Le(function(){var u,l=this;u=function(){l.unhandleds.length===0?a():i(l.unhandleds[0])},At.push(function d(){u(),At.splice(At.indexOf(d),1)}),++Ue,vt(function(){--Ue==0&&_n()},[])},s.finalize),e()},t,n,r)})}}),$e&&($e.allSettled&&U(N,"allSettled",function(){var e=Oe.apply(null,arguments).map(Vt);return new N(function(t){e.length===0&&t([]);var n=e.length,r=new Array(n);e.forEach(function(a,i){return N.resolve(a).then(function(s){return r[i]={status:"fulfilled",value:s}},function(s){return r[i]={status:"rejected",reason:s}}).then(function(){return--n||t(r)})})})}),$e.any&&typeof AggregateError<"u"&&U(N,"any",function(){var e=Oe.apply(null,arguments).map(Vt);return new N(function(t,n){e.length===0&&n(new AggregateError([]));var r=e.length,a=new Array(r);e.forEach(function(i,s){return N.resolve(i).then(function(u){return t(u)},function(u){a[s]=u,--r||n(new AggregateError(a))})})})}),$e.withResolvers&&(N.withResolvers=$e.withResolvers));var ue={awaits:0,echoes:0,id:0},uh=0,It=[],Nt=0,Rt=0,ch=0;function ze(e,t,n,r){var a=M,i=Object.create(a);return i.parent=a,i.ref=0,i.global=!1,i.id=++ch,Ke.env,i.env=vn?{Promise:N,PromiseProp:{value:N,configurable:!0,writable:!0},all:N.all,race:N.race,allSettled:N.allSettled,any:N.any,resolve:N.resolve,reject:N.reject}:{},t&&I(i,t),++a.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()},r=We(i,e,n,r),i.ref===0&&i.finalize(),r}function it(){return ue.id||(ue.id=++uh),++ue.awaits,ue.echoes+=lr,ue.id}function Te(){return!!ue.awaits&&(--ue.awaits==0&&(ue.id=0),ue.echoes=ue.awaits*lr,!0)}function Vt(e){return ue.echoes&&e&&e.constructor===$e?(it(),e.then(function(t){return Te(),t},function(t){return Te(),oe(t)})):e}function lh(){var e=It[It.length-1];It.pop(),Ae(e,!1)}function Ae(e,t){var n,r=M;(t?!ue.echoes||Nt++&&e===M:!Nt||--Nt&&e===M)||queueMicrotask(t?(function(a){++Rt,ue.echoes&&--ue.echoes!=0||(ue.echoes=ue.awaits=ue.id=0),It.push(M),Ae(a,!0)}).bind(null,e):lh),e!==M&&(M=e,r===Ke&&(Ke.env=hr()),vn&&(n=Ke.env.Promise,t=e.env,(r.global||e.global)&&(Object.defineProperty(S,"Promise",t.PromiseProp),n.all=t.all,n.race=t.race,n.resolve=t.resolve,n.reject=t.reject,t.allSettled&&(n.allSettled=t.allSettled),t.any&&(n.any=t.any))))}function hr(){var e=S.Promise;return vn?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(S,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function We(e,t,n,r,a){var i=M;try{return Ae(e,!0),t(n,r,a)}finally{Ae(i,!1)}}function pr(e,t,n,r){return typeof e!="function"?e:function(){var a=M;n&&it(),Ae(t,!0);try{return e.apply(this,arguments)}finally{Ae(a,!1),r&&queueMicrotask(Te)}}}function kn(e){Promise===$e&&ue.echoes===0?Nt===0?e():enqueueNativeMicroTask(e):setTimeout(e,0)}(""+we).indexOf("[native code]")===-1&&(it=Te=re);var oe=N.reject,Ye="",Pe="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",vr="String expected.",ot=[],qt="__dbnames",xn="readonly",En="readwrite";function Xe(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var yr={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Mt(e){return typeof e!="string"||/\./.test(e)?function(t){return t}:function(t){return t[e]===void 0&&e in t&&delete(t=qe(t))[e],t}}function mr(){throw L.Type()}function Z(e,t){try{var n=gr(e),r=gr(t);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t<e?1:e<t?-1:0;case"binary":return function(a,i){for(var s=a.length,u=i.length,l=s<u?s:u,d=0;d<l;++d)if(a[d]!==i[d])return a[d]<i[d]?-1:1;return s===u?0:s<u?-1:1}(br(e),br(t));case"Array":return function(a,i){for(var s=a.length,u=i.length,l=s<u?s:u,d=0;d<l;++d){var v=Z(a[d],i[d]);if(v!==0)return v}return s===u?0:s<u?-1:1}(e,t)}}catch{}return NaN}function gr(e){var t=typeof e;return t!="object"?t:ArrayBuffer.isView(e)?"binary":(e=ln(e),e==="ArrayBuffer"?"binary":e)}function br(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var wr=(ae.prototype._trans=function(e,t,n){var r=this._tx||M.trans,a=this.name,i=ke&&typeof console<"u"&&console.createTask&&console.createTask("Dexie: ".concat(e==="readonly"?"read":"write"," ").concat(this.name));function s(d,v,c){if(!c.schema[a])throw new L.NotFound("Table "+a+" not part of transaction");return t(c.idbtrans,c)}var u=rt();try{var l=r&&r.db._novip===this.db._novip?r===M.trans?r._promise(e,s,n):ze(function(){return r._promise(e,s,n)},{trans:r,transless:M.transless||M}):function d(v,c,m,f){if(v.idbdb&&(v._state.openComplete||M.letThrough||v._vip)){var p=v._createTransaction(c,m,v._dbSchema);try{p.create(),v._state.PR1398_maxLoop=3}catch(y){return y.name===hn.InvalidState&&v.isOpen()&&0<--v._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),v.close({disableAutoOpen:!1}),v.open().then(function(){return d(v,c,m,f)})):oe(y)}return p._promise(c,function(y,h){return ze(function(){return M.trans=p,f(y,h,p)})}).then(function(y){if(c==="readwrite")try{p.idbtrans.commit()}catch{}return c==="readonly"?y:p._completion.then(function(){return y})})}if(v._state.openComplete)return oe(new L.DatabaseClosed(v._state.dbOpenError));if(!v._state.isBeingOpened){if(!v._state.autoOpen)return oe(new L.DatabaseClosed);v.open().catch(re)}return v._state.dbReadyPromise.then(function(){return d(v,c,m,f)})}(this.db,e,[this.name],s);return i&&(l._consoleTask=i,l=l.catch(function(d){return console.trace(d),oe(d)})),l}finally{u&&at()}},ae.prototype.get=function(e,t){var n=this;return e&&e.constructor===Object?this.where(e).first(t):e==null?oe(new L.Type("Invalid argument to Table.get()")):this._trans("readonly",function(r){return n.core.get({trans:r,key:e}).then(function(a){return n.hook.reading.fire(a)})}).then(t)},ae.prototype.where=function(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(z(e))return new this.db.WhereClause(this,"[".concat(e.join("+"),"]"));var t=C(e);if(t.length===1)return this.where(t[0]).equals(e[t[0]]);var n=this.schema.indexes.concat(this.schema.primKey).filter(function(u){if(u.compound&&t.every(function(d){return 0<=u.keyPath.indexOf(d)})){for(var l=0;l<t.length;++l)if(t.indexOf(u.keyPath[l])===-1)return!1;return!0}return!1}).sort(function(u,l){return u.keyPath.length-l.keyPath.length})[0];if(n&&this.db._maxKey!==Ye){var i=n.keyPath.slice(0,t.length);return this.where(i).equals(i.map(function(l){return e[l]}))}!n&&ke&&console.warn("The query ".concat(JSON.stringify(e)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(t.join("+"),"]"));var r=this.schema.idxByName;function a(u,l){return Z(u,l)===0}var s=t.reduce(function(c,l){var d=c[0],v=c[1],c=r[l],m=e[l];return[d||c,d||!c?Xe(v,c&&c.multi?function(f){return f=X(f,l),z(f)&&f.some(function(p){return a(m,p)})}:function(f){return a(m,X(f,l))}):v]},[null,null]),i=s[0],s=s[1];return i?this.where(i.name).equals(e[i.keyPath]).filter(s):n?this.filter(s):this.where(t).equals("")},ae.prototype.filter=function(e){return this.toCollection().and(e)},ae.prototype.count=function(e){return this.toCollection().count(e)},ae.prototype.offset=function(e){return this.toCollection().offset(e)},ae.prototype.limit=function(e){return this.toCollection().limit(e)},ae.prototype.each=function(e){return this.toCollection().each(e)},ae.prototype.toArray=function(e){return this.toCollection().toArray(e)},ae.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},ae.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,z(e)?"[".concat(e.join("+"),"]"):e))},ae.prototype.reverse=function(){return this.toCollection().reverse()},ae.prototype.mapToClass=function(e){var t,n=this.db,r=this.name;function a(){return t!==null&&t.apply(this,arguments)||this}(this.schema.mappedClass=e).prototype instanceof mr&&(function(l,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");function v(){this.constructor=l}B(l,d),l.prototype=d===null?Object.create(d):(v.prototype=d.prototype,new v)}(a,t=e),Object.defineProperty(a.prototype,"db",{get:function(){return n},enumerable:!1,configurable:!0}),a.prototype.table=function(){return r},e=a);for(var i=new Set,s=e.prototype;s;s=$(s))Object.getOwnPropertyNames(s).forEach(function(l){return i.add(l)});function u(l){if(!l)return l;var d,v=Object.create(e.prototype);for(d in l)if(!i.has(d))try{v[d]=l[d]}catch{}return v}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=u,this.hook("reading",u),e},ae.prototype.defineClass=function(){return this.mapToClass(function(e){I(this,e)})},ae.prototype.add=function(e,t){var n=this,r=this.schema.primKey,a=r.auto,i=r.keyPath,s=e;return i&&a&&(s=Mt(i)(e)),this._trans("readwrite",function(u){return n.core.mutate({trans:u,type:"add",keys:t!=null?[t]:null,values:[s]})}).then(function(u){return u.numFailures?N.reject(u.failures[0]):u.lastResult}).then(function(u){if(i)try{te(e,i,u)}catch{}return u})},ae.prototype.update=function(e,t){return typeof e!="object"||z(e)?this.where(":id").equals(e).modify(t):(e=X(e,this.schema.primKey.keyPath),e===void 0?oe(new L.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t))},ae.prototype.put=function(e,t){var n=this,r=this.schema.primKey,a=r.auto,i=r.keyPath,s=e;return i&&a&&(s=Mt(i)(e)),this._trans("readwrite",function(u){return n.core.mutate({trans:u,type:"put",values:[s],keys:t!=null?[t]:null})}).then(function(u){return u.numFailures?N.reject(u.failures[0]):u.lastResult}).then(function(u){if(i)try{te(e,i,u)}catch{}return u})},ae.prototype.delete=function(e){var t=this;return this._trans("readwrite",function(n){return t.core.mutate({trans:n,type:"delete",keys:[e]})}).then(function(n){return n.numFailures?N.reject(n.failures[0]):void 0})},ae.prototype.clear=function(){var e=this;return this._trans("readwrite",function(t){return e.core.mutate({trans:t,type:"deleteRange",range:yr})}).then(function(t){return t.numFailures?N.reject(t.failures[0]):void 0})},ae.prototype.bulkGet=function(e){var t=this;return this._trans("readonly",function(n){return t.core.getMany({keys:e,trans:n}).then(function(r){return r.map(function(a){return t.hook.reading.fire(a)})})})},ae.prototype.bulkAdd=function(e,t,n){var r=this,a=Array.isArray(t)?t:void 0,i=(n=n||(a?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(s){var d=r.schema.primKey,u=d.auto,d=d.keyPath;if(d&&a)throw new L.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==e.length)throw new L.InvalidArgument("Arguments objects and keys must have the same length");var l=e.length,d=d&&u?e.map(Mt(d)):e;return r.core.mutate({trans:s,type:"add",keys:a,values:d,wantResults:i}).then(function(p){var c=p.numFailures,m=p.results,f=p.lastResult,p=p.failures;if(c===0)return i?m:f;throw new nt("".concat(r.name,".bulkAdd(): ").concat(c," of ").concat(l," operations failed"),p)})})},ae.prototype.bulkPut=function(e,t,n){var r=this,a=Array.isArray(t)?t:void 0,i=(n=n||(a?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(s){var d=r.schema.primKey,u=d.auto,d=d.keyPath;if(d&&a)throw new L.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==e.length)throw new L.InvalidArgument("Arguments objects and keys must have the same length");var l=e.length,d=d&&u?e.map(Mt(d)):e;return r.core.mutate({trans:s,type:"put",keys:a,values:d,wantResults:i}).then(function(p){var c=p.numFailures,m=p.results,f=p.lastResult,p=p.failures;if(c===0)return i?m:f;throw new nt("".concat(r.name,".bulkPut(): ").concat(c," of ").concat(l," operations failed"),p)})})},ae.prototype.bulkUpdate=function(e){var t=this,n=this.core,r=e.map(function(s){return s.key}),a=e.map(function(s){return s.changes}),i=[];return this._trans("readwrite",function(s){return n.getMany({trans:s,keys:r,cache:"clone"}).then(function(u){var l=[],d=[];e.forEach(function(c,m){var f=c.key,p=c.changes,y=u[m];if(y){for(var h=0,g=Object.keys(p);h<g.length;h++){var w=g[h],_=p[w];if(w===t.schema.primKey.keyPath){if(Z(_,f)!==0)throw new L.Constraint("Cannot update primary key in bulkUpdate()")}else te(y,w,_)}i.push(m),l.push(f),d.push(y)}});var v=l.length;return n.mutate({trans:s,type:"put",keys:l,values:d,updates:{keys:r,changeSpecs:a}}).then(function(c){var m=c.numFailures,f=c.failures;if(m===0)return v;for(var p=0,y=Object.keys(f);p<y.length;p++){var h,g=y[p],w=i[Number(g)];w!=null&&(h=f[g],delete f[g],f[w]=h)}throw new nt("".concat(t.name,".bulkUpdate(): ").concat(m," of ").concat(v," operations failed"),f)})})})},ae.prototype.bulkDelete=function(e){var t=this,n=e.length;return this._trans("readwrite",function(r){return t.core.mutate({trans:r,type:"delete",keys:e})}).then(function(s){var a=s.numFailures,i=s.lastResult,s=s.failures;if(a===0)return i;throw new nt("".concat(t.name,".bulkDelete(): ").concat(a," of ").concat(n," operations failed"),s)})},ae);function ae(){}function mt(e){function t(s,u){if(u){for(var l=arguments.length,d=new Array(l-1);--l;)d[l-1]=arguments[l];return n[s].subscribe.apply(null,d),e}if(typeof s=="string")return n[s]}var n={};t.addEventType=i;for(var r=1,a=arguments.length;r<a;++r)i(arguments[r]);return t;function i(s,u,l){if(typeof s!="object"){var d;u=u||ih;var v={subscribers:[],fire:l=l||re,subscribe:function(c){v.subscribers.indexOf(c)===-1&&(v.subscribers.push(c),v.fire=u(v.fire,c))},unsubscribe:function(c){v.subscribers=v.subscribers.filter(function(m){return m!==c}),v.fire=v.subscribers.reduce(u,l)}};return n[s]=t[s]=v}C(d=s).forEach(function(c){var m=d[c];if(z(m))i(c,d[c][0],d[c][1]);else{if(m!=="asap")throw new L.InvalidArgument("Invalid event config");var f=i(c,dt,function(){for(var p=arguments.length,y=new Array(p);p--;)y[p]=arguments[p];f.subscribers.forEach(function(h){ne(function(){h.apply(null,y)})})})}})}}function gt(e,t){return H(t).from({prototype:e}),t}function st(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Cn(e,t){e.filter=Xe(e.filter,t)}function Sn(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return Xe(r(),t())}:t,e.justLimit=n&&!r}function Lt(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new L.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function _r(e,t,n){var r=Lt(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:e.dir==="prev",unique:!!e.unique,query:{index:r,range:e.range}})}function Ft(e,t,n,r){var a=e.replayFilter?Xe(e.filter,e.replayFilter()):e.filter;if(e.or){var i={},s=function(u,l,d){var v,c;a&&!a(l,d,function(m){return l.stop(m)},function(m){return l.fail(m)})||((c=""+(v=l.primaryKey))=="[object ArrayBuffer]"&&(c=""+new Uint8Array(v)),V(i,c)||(i[c]=!0,t(u,l,d)))};return Promise.all([e.or._iterate(s,n),kr(_r(e,r,n),e.algorithm,s,!e.keysOnly&&e.valueMapper)])}return kr(_r(e,r,n),Xe(e.algorithm,a),t,!e.keysOnly&&e.valueMapper)}function kr(e,t,n,r){var a=ie(r?function(i,s,u){return n(r(i),s,u)}:n);return e.then(function(i){if(i)return i.start(function(){var s=function(){return i.continue()};t&&!t(i,function(u){return s=u},function(u){i.stop(u),s=re},function(u){i.fail(u),s=re})||a(i.value,i,function(u){return s=u}),s()})})}var bt=(xr.prototype.execute=function(e){var t=this["@@propmod"];if(t.add!==void 0){var n=t.add;if(z(n))return D(D([],z(e)?e:[],!0),n).sort();if(typeof n=="number")return(Number(e)||0)+n;if(typeof n=="bigint")try{return BigInt(e)+n}catch{return BigInt(0)+n}throw new TypeError("Invalid term ".concat(n))}if(t.remove!==void 0){var r=t.remove;if(z(r))return z(e)?e.filter(function(a){return!r.includes(a)}).sort():[];if(typeof r=="number")return Number(e)-r;if(typeof r=="bigint")try{return BigInt(e)-r}catch{return BigInt(0)-r}throw new TypeError("Invalid subtrahend ".concat(r))}return n=(n=t.replacePrefix)===null||n===void 0?void 0:n[0],n&&typeof e=="string"&&e.startsWith(n)?t.replacePrefix[1]+e.substring(n.length):e},xr);function xr(e){this["@@propmod"]=e}var fh=(J.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,oe.bind(null,n.error)):n.table._trans("readonly",e).then(t)},J.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,oe.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},J.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=Xe(t.algorithm,e)},J.prototype._iterate=function(e,t){return Ft(this._ctx,e,t,this._ctx.table.core)},J.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&I(n,e),t._ctx=n,t},J.prototype.raw=function(){return this._ctx.valueMapper=null,this},J.prototype.each=function(e){var t=this._ctx;return this._read(function(n){return Ft(t,e,n,t.table.core)})},J.prototype.count=function(e){var t=this;return this._read(function(n){var r=t._ctx,a=r.table.core;if(st(r,!0))return a.count({trans:n,query:{index:Lt(r,a.schema),range:r.range}}).then(function(s){return Math.min(s,r.limit)});var i=0;return Ft(r,function(){return++i,!1},n,a).then(function(){return i})}).then(e)},J.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),r=n[0],a=n.length-1;function i(l,d){return d?i(l[n[d]],d-1):l[r]}var s=this._ctx.dir==="next"?1:-1;function u(l,d){return Z(i(l,a),i(d,a))*s}return this.toArray(function(l){return l.sort(u)}).then(t)},J.prototype.toArray=function(e){var t=this;return this._read(function(n){var r=t._ctx;if(r.dir==="next"&&st(r,!0)&&0<r.limit){var a=r.valueMapper,i=Lt(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:i,range:r.range}}).then(function(u){return u=u.result,a?u.map(a):u})}var s=[];return Ft(r,function(u){return s.push(u)},n,r.table.core).then(function(){return s})},e)},J.prototype.offset=function(e){var t=this._ctx;return e<=0||(t.offset+=e,st(t)?Sn(t,function(){var n=e;return function(r,a){return n===0||(n===1?--n:a(function(){r.advance(n),n=0}),!1)}}):Sn(t,function(){var n=e;return function(){return--n<0}})),this},J.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Sn(this._ctx,function(){var t=e;return function(n,r,a){return--t<=0&&r(a),0<=t}},!0),this},J.prototype.until=function(e,t){return Cn(this._ctx,function(n,r,a){return!e(n.value)||(r(a),t)}),this},J.prototype.first=function(e){return this.limit(1).toArray(function(t){return t[0]}).then(e)},J.prototype.last=function(e){return this.reverse().first(e)},J.prototype.filter=function(e){var t;return Cn(this._ctx,function(n){return e(n.value)}),(t=this._ctx).isMatch=Xe(t.isMatch,e),this},J.prototype.and=function(e){return this.filter(e)},J.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},J.prototype.reverse=function(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},J.prototype.desc=function(){return this.reverse()},J.prototype.eachKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(n,r){e(r.key,r)})},J.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},J.prototype.eachPrimaryKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(n,r){e(r.primaryKey,r)})},J.prototype.keys=function(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each(function(r,a){n.push(a.key)}).then(function(){return n}).then(e)},J.prototype.primaryKeys=function(e){var t=this._ctx;if(t.dir==="next"&&st(t,!0)&&0<t.limit)return this._read(function(r){var a=Lt(t,t.table.core.schema);return t.table.core.query({trans:r,values:!1,limit:t.limit,query:{index:a,range:t.range}})}).then(function(r){return r.result}).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(r,a){n.push(a.primaryKey)}).then(function(){return n}).then(e)},J.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},J.prototype.firstKey=function(e){return this.limit(1).keys(function(t){return t[0]}).then(e)},J.prototype.lastKey=function(e){return this.reverse().firstKey(e)},J.prototype.distinct=function(){var e=this._ctx,e=e.index&&e.table.schema.idxByName[e.index];if(!e||!e.multi)return this;var t={};return Cn(this._ctx,function(a){var r=a.primaryKey.toString(),a=V(t,r);return t[r]=!0,!a}),this},J.prototype.modify=function(e){var t=this,n=this._ctx;return this._write(function(r){var a,i,s;s=typeof e=="function"?e:(a=C(e),i=a.length,function(h){for(var g=!1,w=0;w<i;++w){var _=a[w],x=e[_],O=X(h,_);x instanceof bt?(te(h,_,x.execute(O)),g=!0):O!==x&&(te(h,_,x),g=!0)}return g});var u=n.table.core,c=u.schema.primaryKey,l=c.outbound,d=c.extractKey,v=200,c=t.db._options.modifyChunkSize;c&&(v=typeof c=="object"?c[u.name]||c["*"]||200:c);function m(h,_){var w=_.failures,_=_.numFailures;p+=h-_;for(var x=0,O=C(w);x<O.length;x++){var A=O[x];f.push(w[A])}}var f=[],p=0,y=[];return t.clone().primaryKeys().then(function(h){function g(_){var x=Math.min(v,h.length-_);return u.getMany({trans:r,keys:h.slice(_,_+x),cache:"immutable"}).then(function(O){for(var A=[],P=[],K=l?[]:null,j=[],T=0;T<x;++T){var R=O[T],Y={value:qe(R),primKey:h[_+T]};s.call(Y,Y.value,Y)!==!1&&(Y.value==null?j.push(h[_+T]):l||Z(d(R),d(Y.value))===0?(P.push(Y.value),l&&K.push(h[_+T])):(j.push(h[_+T]),A.push(Y.value)))}return Promise.resolve(0<A.length&&u.mutate({trans:r,type:"add",values:A}).then(function(G){for(var Q in G.failures)j.splice(parseInt(Q),1);m(A.length,G)})).then(function(){return(0<P.length||w&&typeof e=="object")&&u.mutate({trans:r,type:"put",keys:K,values:P,criteria:w,changeSpec:typeof e!="function"&&e,isAdditionalChunk:0<_}).then(function(G){return m(P.length,G)})}).then(function(){return(0<j.length||w&&e===Bn)&&u.mutate({trans:r,type:"delete",keys:j,criteria:w,isAdditionalChunk:0<_}).then(function(G){return m(j.length,G)})}).then(function(){return h.length>_+x&&g(_+v)})})}var w=st(n)&&n.limit===1/0&&(typeof e!="function"||e===Bn)&&{index:n.index,range:n.range};return g(0).then(function(){if(0<f.length)throw new Dt("Error modifying one or more objects",f,p,y);return h.length})})})},J.prototype.delete=function(){var e=this._ctx,t=e.range;return st(e)&&(e.isPrimKey||t.type===3)?this._write(function(n){var r=e.table.core.schema.primaryKey,a=t;return e.table.core.count({trans:n,query:{index:r,range:a}}).then(function(i){return e.table.core.mutate({trans:n,type:"deleteRange",range:a}).then(function(s){var u=s.failures;if(s.lastResult,s.results,s=s.numFailures,s)throw new Dt("Could not delete some values",Object.keys(u).map(function(l){return u[l]}),i-s);return i-s})})}):this.modify(Bn)},J);function J(){}var Bn=function(e,t){return t.value=null};function dh(e,t){return e<t?-1:e===t?0:1}function hh(e,t){return t<e?-1:e===t?0:1}function ge(e,t,n){return e=e instanceof Cr?new e.Collection(e):e,e._ctx.error=new(n||TypeError)(t),e}function ut(e){return new e.Collection(e,function(){return Er("")}).limit(0)}function $t(e,t,n,r){var a,i,s,u,l,d,v,c=n.length;if(!n.every(function(p){return typeof p=="string"}))return ge(e,vr);function m(p){a=p==="next"?function(h){return h.toUpperCase()}:function(h){return h.toLowerCase()},i=p==="next"?function(h){return h.toLowerCase()}:function(h){return h.toUpperCase()},s=p==="next"?dh:hh;var y=n.map(function(h){return{lower:i(h),upper:a(h)}}).sort(function(h,g){return s(h.lower,g.lower)});u=y.map(function(h){return h.upper}),l=y.map(function(h){return h.lower}),v=(d=p)==="next"?"":r}m("next"),e=new e.Collection(e,function(){return je(u[0],l[c-1]+r)}),e._ondirectionchange=function(p){m(p)};var f=0;return e._addAlgorithm(function(p,y,h){var g=p.key;if(typeof g!="string")return!1;var w=i(g);if(t(w,l,f))return!0;for(var _=null,x=f;x<c;++x){var O=function(A,P,K,j,T,R){for(var Y=Math.min(A.length,j.length),G=-1,Q=0;Q<Y;++Q){var be=P[Q];if(be!==j[Q])return T(A[Q],K[Q])<0?A.substr(0,Q)+K[Q]+K.substr(Q+1):T(A[Q],j[Q])<0?A.substr(0,Q)+j[Q]+K.substr(Q+1):0<=G?A.substr(0,G)+P[G]+K.substr(G+1):null;T(A[Q],be)<0&&(G=Q)}return Y<j.length&&R==="next"?A+K.substr(A.length):Y<A.length&&R==="prev"?A.substr(0,K.length):G<0?null:A.substr(0,G)+j[G]+K.substr(G+1)}(g,w,u[x],l[x],s,d);O===null&&_===null?f=x+1:(_===null||0<s(_,O))&&(_=O)}return y(_!==null?function(){p.continue(_+v)}:h),!1}),e}function je(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Er(e){return{type:1,lower:e,upper:e}}var Cr=(Object.defineProperty(ce.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),ce.prototype.between=function(e,t,n,r){n=n!==!1,r=r===!0;try{return 0<this._cmp(e,t)||this._cmp(e,t)===0&&(n||r)&&(!n||!r)?ut(this):new this.Collection(this,function(){return je(e,t,!n,!r)})}catch{return ge(this,Pe)}},ce.prototype.equals=function(e){return e==null?ge(this,Pe):new this.Collection(this,function(){return Er(e)})},ce.prototype.above=function(e){return e==null?ge(this,Pe):new this.Collection(this,function(){return je(e,void 0,!0)})},ce.prototype.aboveOrEqual=function(e){return e==null?ge(this,Pe):new this.Collection(this,function(){return je(e,void 0,!1)})},ce.prototype.below=function(e){return e==null?ge(this,Pe):new this.Collection(this,function(){return je(void 0,e,!1,!0)})},ce.prototype.belowOrEqual=function(e){return e==null?ge(this,Pe):new this.Collection(this,function(){return je(void 0,e)})},ce.prototype.startsWith=function(e){return typeof e!="string"?ge(this,vr):this.between(e,e+Ye,!0,!0)},ce.prototype.startsWithIgnoreCase=function(e){return e===""?this.startsWith(e):$t(this,function(t,n){return t.indexOf(n[0])===0},[e],Ye)},ce.prototype.equalsIgnoreCase=function(e){return $t(this,function(t,n){return t===n[0]},[e],"")},ce.prototype.anyOfIgnoreCase=function(){var e=Oe.apply(et,arguments);return e.length===0?ut(this):$t(this,function(t,n){return n.indexOf(t)!==-1},e,"")},ce.prototype.startsWithAnyOfIgnoreCase=function(){var e=Oe.apply(et,arguments);return e.length===0?ut(this):$t(this,function(t,n){return n.some(function(r){return t.indexOf(r)===0})},e,Ye)},ce.prototype.anyOf=function(){var e=this,t=Oe.apply(et,arguments),n=this._cmp;try{t.sort(n)}catch{return ge(this,Pe)}if(t.length===0)return ut(this);var r=new this.Collection(this,function(){return je(t[0],t[t.length-1])});r._ondirectionchange=function(i){n=i==="next"?e._ascending:e._descending,t.sort(n)};var a=0;return r._addAlgorithm(function(i,s,u){for(var l=i.key;0<n(l,t[a]);)if(++a===t.length)return s(u),!1;return n(l,t[a])===0||(s(function(){i.continue(t[a])}),!1)}),r},ce.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},ce.prototype.noneOf=function(){var e=Oe.apply(et,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return ge(this,Pe)}var t=e.reduce(function(n,r){return n?n.concat([[n[n.length-1][1],r]]):[[-1/0,r]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},ce.prototype.inAnyRange=function(g,t){var n=this,r=this._cmp,a=this._ascending,i=this._descending,s=this._min,u=this._max;if(g.length===0)return ut(this);if(!g.every(function(w){return w[0]!==void 0&&w[1]!==void 0&&a(w[0],w[1])<=0}))return ge(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",L.InvalidArgument);var l=!t||t.includeLowers!==!1,d=t&&t.includeUppers===!0,v,c=a;function m(w,_){return c(w[0],_[0])}try{(v=g.reduce(function(w,_){for(var x=0,O=w.length;x<O;++x){var A=w[x];if(r(_[0],A[1])<0&&0<r(_[1],A[0])){A[0]=s(A[0],_[0]),A[1]=u(A[1],_[1]);break}}return x===O&&w.push(_),w},[])).sort(m)}catch{return ge(this,Pe)}var f=0,p=d?function(w){return 0<a(w,v[f][1])}:function(w){return 0<=a(w,v[f][1])},y=l?function(w){return 0<i(w,v[f][0])}:function(w){return 0<=i(w,v[f][0])},h=p,g=new this.Collection(this,function(){return je(v[0][0],v[v.length-1][1],!l,!d)});return g._ondirectionchange=function(w){c=w==="next"?(h=p,a):(h=y,i),v.sort(m)},g._addAlgorithm(function(w,_,x){for(var O,A=w.key;h(A);)if(++f===v.length)return _(x),!1;return!p(O=A)&&!y(O)||(n._cmp(A,v[f][1])===0||n._cmp(A,v[f][0])===0||_(function(){c===a?w.continue(v[f][0]):w.continue(v[f][1])}),!1)}),g},ce.prototype.startsWithAnyOf=function(){var e=Oe.apply(et,arguments);return e.every(function(t){return typeof t=="string"})?e.length===0?ut(this):this.inAnyRange(e.map(function(t){return[t,t+Ye]})):ge(this,"startsWithAnyOf() only works with strings")},ce);function ce(){}function xe(e){return ie(function(t){return wt(t),e(t.target.error),!1})}function wt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var _t="storagemutated",On="x-storagemutated-1",Ie=mt(null,_t),ph=(Ee.prototype._lock=function(){return he(!M.global),++this._reculock,this._reculock!==1||M.global||(M.lockOwnerFor=this),this},Ee.prototype._unlock=function(){if(he(!M.global),--this._reculock==0)for(M.global||(M.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{We(e[1],e[0])}catch{}}return this},Ee.prototype._locked=function(){return this._reculock&&M.lockOwnerFor!==this},Ee.prototype.create=function(e){var t=this;if(!this.mode)return this;var n=this.db.idbdb,r=this.db._state.dbOpenError;if(he(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new L.DatabaseClosed(r);case"MissingAPIError":throw new L.MissingAPI(r.message,r);default:throw new L.OpenFailed(r)}if(!this.active)throw new L.TransactionInactive;return he(this._completion._state===null),(e=this.idbtrans=e||(this.db.core||n).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=ie(function(a){wt(a),t._reject(e.error)}),e.onabort=ie(function(a){wt(a),t.active&&t._reject(new L.Abort(e.error)),t.active=!1,t.on("abort").fire(a)}),e.oncomplete=ie(function(){t.active=!1,t._resolve(),"mutatedParts"in e&&Ie.storagemutated.fire(e.mutatedParts)}),this},Ee.prototype._promise=function(e,t,n){var r=this;if(e==="readwrite"&&this.mode!=="readwrite")return oe(new L.ReadOnly("Transaction is readonly"));if(!this.active)return oe(new L.TransactionInactive);if(this._locked())return new N(function(i,s){r._blockedFuncs.push([function(){r._promise(e,t,n).then(i,s)},M])});if(n)return ze(function(){var i=new N(function(s,u){r._lock();var l=t(s,u,r);l&&l.then&&l.then(s,u)});return i.finally(function(){return r._unlock()}),i._lib=!0,i});var a=new N(function(i,s){var u=t(i,s,r);u&&u.then&&u.then(i,s)});return a._lib=!0,a},Ee.prototype._root=function(){return this.parent?this.parent._root():this},Ee.prototype.waitFor=function(e){var t,n=this._root(),r=N.resolve(e);n._waitingFor?n._waitingFor=n._waitingFor.then(function(){return r}):(n._waitingFor=r,n._waitingQueue=[],t=n.idbtrans.objectStore(n.storeNames[0]),function i(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(t.get(-1/0).onsuccess=i)}());var a=n._waitingFor;return new N(function(i,s){r.then(function(u){return n._waitingQueue.push(ie(i.bind(null,u)))},function(u){return n._waitingQueue.push(ie(s.bind(null,u)))}).finally(function(){n._waitingFor===a&&(n._waitingFor=null)})})},Ee.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new L.Abort))},Ee.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(V(t,e))return t[e];var n=this.schema[e];if(!n)throw new L.NotFound("Table "+e+" not part of transaction");return n=new this.db.Table(e,n,this),n.core=this.db.core.table(e),t[e]=n},Ee);function Ee(){}function Pn(e,t,n,r,a,i,s){return{name:e,keyPath:t,unique:n,multi:r,auto:a,compound:i,src:(n&&!s?"&":"")+(r?"*":"")+(a?"++":"")+Sr(t)}}function Sr(e){return typeof e=="string"?e:e?"["+[].join.call(e,"+")+"]":""}function Dn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(r=function(a){return[a.name,a]},n.reduce(function(a,i,s){return s=r(i,s),s&&(a[s[0]]=s[1]),a},{}))};var r}var kt=function(e){try{return e.only([[]]),kt=function(){return[[]]},[[]]}catch{return kt=function(){return Ye},Ye}};function Kn(e){return e==null?function(){}:typeof e=="string"?(t=e).split(".").length===1?function(n){return n[t]}:function(n){return X(n,t)}:function(n){return X(n,e)};var t}function Br(e){return[].slice.call(e)}var vh=0;function xt(e){return e==null?":id":typeof e=="string"?e:"[".concat(e.join("+"),"]")}function yh(e,t,l){function r(h){if(h.type===3)return null;if(h.type===4)throw new Error("Cannot convert never type to IDBKeyRange");var f=h.lower,p=h.upper,y=h.lowerOpen,h=h.upperOpen;return f===void 0?p===void 0?null:t.upperBou