var backend=function(e){self.webpackChunkbackend=function(t,n){for(var i in n)e[i]=n[i];for(;t.length;)r[t.pop()]=1};var t={},r={main:1};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.e=function(e){var t=[];return t.push(Promise.resolve().then((function(){r[e]||importScripts(n.p+""+e+".kcab.worker.b16816d5632f095a8a84.js")}))),Promise.all(t)},n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/kcab/",n(n.s=285)}([function(e,t,r){"use strict";function n(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new Date(e.getTime()):"number"==typeof e||"[object Number]"===t?new Date(e):("string"!=typeof e&&"[object String]"!==t||"undefined"==typeof console||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as arguments. Please use `parseISO` to parse strings. See: https://git.io/fpAk2"),console.warn((new Error).stack)),new Date(NaN))}r.d(t,"a",(function(){return n}))},function(e,t,r){"use strict";r.r(t),r.d(t,"toDateRepr",(function(){return l.h})),r.d(t,"fromDateRepr",(function(){return l.d})),r.d(t,"getDatabasePath",(function(){return E})),r.d(t,"openDatabase",(function(){return S})),r.d(t,"reopenDatabase",(function(){return O})),r.d(t,"closeDatabase",(function(){return T})),r.d(t,"setDatabase",(function(){return A})),r.d(t,"getDatabase",(function(){return M})),r.d(t,"loadClock",(function(){return D})),r.d(t,"runQuery",(function(){return I})),r.d(t,"execQuery",(function(){return j})),r.d(t,"cache",(function(){return N})),r.d(t,"transaction",(function(){return k})),r.d(t,"asyncTransaction",(function(){return C})),r.d(t,"all",(function(){return L})),r.d(t,"first",(function(){return x})),r.d(t,"firstSync",(function(){return P})),r.d(t,"run",(function(){return B})),r.d(t,"select",(function(){return U})),r.d(t,"update",(function(){return F})),r.d(t,"insertWithUUID",(function(){return W})),r.d(t,"insert",(function(){return H})),r.d(t,"delete_",(function(){return z})),r.d(t,"selectWithSchema",(function(){return q})),r.d(t,"selectFirstWithSchema",(function(){return V})),r.d(t,"insertWithSchema",(function(){return G})),r.d(t,"updateWithSchema",(function(){return Y})),r.d(t,"getCategories",(function(){return $})),r.d(t,"getCategoriesGrouped",(function(){return K})),r.d(t,"insertCategoryGroup",(function(){return Z})),r.d(t,"updateCategoryGroup",(function(){return X})),r.d(t,"moveCategoryGroup",(function(){return J})),r.d(t,"deleteCategoryGroup",(function(){return Q})),r.d(t,"insertCategory",(function(){return ee})),r.d(t,"updateCategory",(function(){return te})),r.d(t,"moveCategory",(function(){return re})),r.d(t,"deleteCategory",(function(){return ne})),r.d(t,"getPayee",(function(){return ie})),r.d(t,"insertPayee",(function(){return oe})),r.d(t,"deletePayee",(function(){return ae})),r.d(t,"deleteTransferPayee",(function(){return se})),r.d(t,"updatePayee",(function(){return ue})),r.d(t,"mergePayees",(function(){return ce})),r.d(t,"getPayees",(function(){return le})),r.d(t,"getOrphanedPayees",(function(){return fe})),r.d(t,"getPayeeByName",(function(){return de})),r.d(t,"insertPayeeRule",(function(){return he})),r.d(t,"deletePayeeRule",(function(){return pe})),r.d(t,"updatePayeeRule",(function(){return ge})),r.d(t,"getPayeeRules",(function(){return me})),r.d(t,"getAccounts",(function(){return ye})),r.d(t,"insertAccount",(function(){return be})),r.d(t,"updateAccount",(function(){return _e})),r.d(t,"deleteAccount",(function(){return we})),r.d(t,"moveAccount",(function(){return ve})),r.d(t,"getTransaction",(function(){return Ee})),r.d(t,"getTransactionsByDate",(function(){return Se})),r.d(t,"getTransactions",(function(){return Oe})),r.d(t,"insertTransaction",(function(){return Te})),r.d(t,"updateTransaction",(function(){return Ae})),r.d(t,"deleteTransaction",(function(){return Me}));var n=r(171),i=r.n(n),o=r(15),a=r(4),s=r.n(a),u=r(7),c=r(33),l=r(17),f=r(12),d=r(13),h=r(67);function p(e,t){const r=e[t-1],n=e[t];return r?n?(r.sort_order+n.sort_order)/2:r.sort_order+16384:n.sort_order/2}function g(e,t){const r=e.findIndex(e=>e.id===t),n=e[r],i=e[r-1];let o=[];if(t&&-1!==r){if(n.sort_order-(i?i.sort_order:0)<=2){let t=r,n=16384+(0|e[t].sort_order);for(;t0?e[e.length-1].sort_order+16384:16384,{updates:o,sort_order:t}}}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t"id"!==e);if(null==t.id)throw new Error("update: id is required");await Object(u.j)(r.map(r=>({dataset:e,row:t.id,column:r,value:t[r],timestamp:d.default.send()})))}async function W(e,t){return t.id||(t=y(y({},t),{},{id:_.v4Sync()})),await H(e,t),t.id}async function H(e,t){let r=Object.keys(t).filter(e=>"id"!==e);if(null==t.id)throw new Error("insert: id is required");await Object(u.j)(r.map(r=>({dataset:e,row:t.id,column:r,value:t[r],timestamp:d.default.send()})))}async function z(e,t){await Object(u.j)([{dataset:e,row:t,column:"tombstone",value:1,timestamp:d.default.send()}])}async function q(e,t,r){return(await I(t,r,!0)).map(t=>Object(h.c)(c.a,c.b,e,t)).filter(Boolean)}async function V(e,t,r){let n=await q(e,t,r);return n.length>0?n[0]:null}function G(e,t){return t.id||(t=y(y({},t),{},{id:_.v4Sync()})),W(e,Object(h.a)(c.a,c.b,e,t))}function Y(e,t){return F(e,Object(h.b)(c.a,c.b,e,t))}async function $(){return L("\n SELECT c.* FROM categories c\n LEFT JOIN category_groups cg ON c.cat_group = cg.id\n WHERE c.tombstone = 0\n ORDER BY cg.sort_order, cg.id, c.sort_order, c.id\n ")}async function K(){const e=await L("SELECT * FROM category_groups WHERE tombstone = 0 ORDER BY is_income, sort_order, id"),t=await L("\n SELECT * FROM categories WHERE tombstone = 0\n ORDER BY sort_order, id\n ");return e.map(e=>y(y({},e),{},{categories:t.filter(t=>t.cat_group===e.id)}))}async function Z(e){const t=await x("\n SELECT sort_order FROM category_groups WHERE tombstone = 0 ORDER BY sort_order DESC, id DESC LIMIT 1\n "),r=(t?t.sort_order:0)+16384;return W("category_groups",e=y(y({},l.b.validate(e)),{},{sort_order:r}))}function X(e){return F("category_groups",e=l.b.validate(e,{update:!0}))}async function J(e,t){const r=g(await L("SELECT id, sort_order FROM category_groups WHERE tombstone = 0 ORDER BY sort_order, id"),t),n=r.updates,i=r.sort_order;for(let e of n)await F("category_groups",e);await F("category_groups",{id:e,sort_order:i})}async function Q(e,t){const r=await L("SELECT * FROM categories WHERE cat_group = ?",[e.id]);await Promise.all(r.map(e=>ne(e,t))),await z("category_groups",e.id)}async function ee(e,{atEnd:t}={}){let r,n;return await Object(u.c)(async()=>{if(t){const e=await x("\n SELECT sort_order FROM categories WHERE tombstone = 0 ORDER BY sort_order DESC, id DESC LIMIT 1\n ");r=(e?e.sort_order:0)+16384}else{const t=await L("SELECT id, sort_order FROM categories WHERE cat_group = ? AND tombstone = 0 ORDER BY sort_order, id",[e.cat_group]),n=g(t,t.length>0?t[0].id:null),i=n.updates,o=n.sort_order;for(let e of i)await F("categories",e);r=o}e=y(y({},l.c.validate(e)),{},{sort_order:r});const i=await W("categories",e);await H("category_mapping",{id:i,transferId:i}),n=i}),n}function te(e){return F("categories",e=l.c.validate(e,{update:!0}))}async function re(e,t,r){if(!t)throw new Error("moveCategory: groupId is required");const n=g(await L("SELECT id, sort_order FROM categories WHERE cat_group = ? AND tombstone = 0 ORDER BY sort_order, id",[t]),r),i=n.updates,o=n.sort_order;for(let e of i)await F("categories",e);await F("categories",{id:e,sort_order:o,cat_group:t})}async function ne(e,t){if(t){const r=await L("SELECT * FROM category_mapping WHERE transferId = ?",[e.id]);for(let e of r)await F("category_mapping",{id:e.id,transferId:t});await F("category_mapping",{id:e.id,transferId:t})}return z("categories",e.id)}async function ie(e){return x("SELECT * FROM payees WHERE id = ?",[e])}async function oe(e){let t;return e=l.e.validate(e),await Object(u.c)(async()=>{t=await W("payees",e),await H("payee_mapping",{id:t,targetId:t})}),t}async function ae(e){if((await x("SELECT * FROM payees WHERE id = ?",[e.id])).transfer_acct)return;let t=await L("SELECT * FROM payee_rules WHERE payee_id = ?",[e.id]);return await Promise.all(t.map(e=>pe({id:e.id}))),z("payees",e.id)}async function se(e){return z("payees",e.id)}function ue(e){return F("payees",e=l.e.validate(e,{update:!0}))}async function ce(e,t){let r=Object(f.i)(await L("SELECT * FROM payees"));null==r[e].transfer_acct&&(t=t.filter(e=>null==r[e].transfer_acct),await Object(u.c)(async()=>(await Promise.all(t.map(async t=>{let r=await L("SELECT id FROM payee_mapping WHERE targetId = ?",[t]);await Promise.all(r.map(t=>F("payee_mapping",{id:t.id,targetId:e})))})),Promise.all(t.map(t=>Promise.all([F("payee_mapping",{id:t,targetId:e}),z("payees",t)]))))))}function le(){return L("\n SELECT p.*, COALESCE(a.name, p.name) AS name FROM payees p\n LEFT JOIN accounts a ON (p.transfer_acct = a.id AND a.tombstone = 0)\n WHERE p.tombstone = 0 AND (p.transfer_acct IS NULL OR a.id IS NOT NULL)\n ORDER BY p.transfer_acct IS NULL DESC, p.name COLLATE NOCASE\n ")}async function fe(){return(await L("\n SELECT p.id FROM payees p\n LEFT JOIN payee_mapping pm ON pm.id = p.id\n LEFT JOIN v_transactions_internal_alive t ON t.payee = pm.targetId\n WHERE p.tombstone = 0 AND p.transfer_acct IS NULL AND t.id IS NULL\n ")).map(e=>e.id)}async function de(e){return x("SELECT * FROM payees WHERE LOWER(name) = ? AND tombstone = 0",[e.toLowerCase()])}function he(e){return W("payee_rules",e=l.f.validate(e))}function pe(e){return z("payee_rules",e.id)}function ge(e){return F("payee_rules",e=l.e.validate(e,{update:!0}))}function me(e){return L("SELECT pr.* FROM payee_rules pr\n LEFT JOIN payee_mapping pm ON pm.id = pr.payee_id\n WHERE pm.targetId = ? AND pr.tombstone = 0",[e])}function ye(){return L("SELECT a.*, b.name as bankName, b.id as bankId FROM accounts a\n LEFT JOIN banks b ON a.bank = b.id\n WHERE a.tombstone = 0\n ORDER BY sort_order, name")}async function be(e){void 0===e.type&&(e=y(y({},e),{},{type:"checking"}));let t=g(await L("SELECT * FROM accounts WHERE offbudget = ? ORDER BY sort_order, name",[null!=e.offbudget?e.offbudget:0])).sort_order;return W("accounts",e=l.a.validate(y(y({},e),{},{sort_order:t})))}function _e(e){return F("accounts",e=l.a.validate(e,{update:!0}))}function we(e){return z("accounts",e.id)}async function ve(e,t){let r,n=await x("SELECT * FROM accounts WHERE id = ?",[e]);r=n.closed?await L("SELECT id, sort_order FROM accounts WHERE closed = 1 ORDER BY sort_order, name"):await L("SELECT id, sort_order FROM accounts WHERE tombstone = 0 AND offbudget = ? ORDER BY sort_order, name",[n.offbudget]);const i=g(r,t),o=i.updates,a=i.sort_order;await Object(u.c)(()=>{for(let e of o)F("accounts",e);F("accounts",{id:e,sort_order:a})})}async function Ee(e){return(await q("transactions","SELECT * FROM v_transactions WHERE id = ?",[e]))[0]}async function Se(e,t,r,n={}){throw new Error("`getTransactionsByDate` is deprecated")}async function Oe(e,t){if(void 0!==t)throw new Error("`getTransactions` was given a second argument, it now only takes a single argument `accountId`");return q("transactions","SELECT * FROM v_transactions WHERE account = ?",[e])}function Te(e){return G("transactions",e)}function Ae(e){return Y("transactions",e)}async function Me(e){return z("transactions",e.id)}},function(e,t,r){"use strict";(function(e){r.d(t,"l",(function(){return m})),r.d(t,"s",(function(){return y})),r.d(t,"k",(function(){return b})),r.d(t,"f",(function(){return _})),r.d(t,"e",(function(){return w})),r.d(t,"d",(function(){return v})),r.d(t,"m",(function(){return E})),r.d(t,"b",(function(){return S})),r.d(t,"r",(function(){return O})),r.d(t,"a",(function(){return T})),r.d(t,"q",(function(){return A})),r.d(t,"j",(function(){return M})),r.d(t,"i",(function(){return D})),r.d(t,"c",(function(){return I})),r.d(t,"n",(function(){return R})),r.d(t,"o",(function(){return N})),r.d(t,"h",(function(){return k})),r.d(t,"p",(function(){return C})),r.d(t,"g",(function(){return L}));var n=r(34),i=r(57),o=r(132),a=r(47),s=r(133),u=r(107),c=r(168),l=r(65),f=r(82),d=r(78);function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return p(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);rnew RegExp(e.replace(/d+/g,"\\d{1,2}").replace(/M+/g,"\\d{1,2}").replace(/y+/g,"\\d{4}"))),Object(d.a)(e=>e.replace(/y+/g,"").replace(/[^\w]$/,"").replace(/^[^\w]/,"")),Object(d.a)(e=>{let t=e.replace(/y+/g,"").replace(/[^\w]$/,"").replace(/^[^\w]/,"").replace(/d+/g,"\\d{1,2}").replace(/M+/g,"\\d{1,2}");return new RegExp("^"+t+"$")}),Object(d.a)(e=>e.replace(/d+/g,"").replace(/[^\w]$/,"").replace(/^[^\w]/,"").replace(/\/\//,"/").replace(/\.\./,".").replace(/--/,"-")),Object(d.a)(e=>{let t=e.replace(/d+/g,"").replace(/[^\w]$/,"").replace(/^[^\w]/,"").replace(/\/\//,"/").replace(/M+/g,"\\d{1,2}").replace(/y+/g,"\\d{2,4}");return new RegExp("^"+t+"$")}),Object(d.a)(e=>e.replace(/y+/g,"yy")),Object(d.a)(e=>{let t=e.replace(/[^\w]$/,"").replace(/^[^\w]/,"").replace(/d+/g,"\\d{1,2}").replace(/M+/g,"\\d{1,2}").replace(/y+/g,"\\d{2}");return new RegExp("^"+t+"$")})}).call(this,r(23))},function(e,t,r){"use strict";function n(e){if(null===e||!0===e||!1===e)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}r.d(t,"a",(function(){return n}))},function(e,t,r){(function(t){let n=r(397).SQLiteFS,i=r(398).default,o=r(52),a=r(15)._getModule,s=r(179),u=r(399),c=r(400),l=null,f=null;function d(e){return e.replace(/^\//,"").replace(/\//g,"-")}function h(e){try{l.stat(e)}catch(e){return!1}return!0}function p(e){let t=e.split("/").filter(e=>""!==e),r="";for(let e of t)r+="/"+e,h(r)||l.mkdir(r)}function g(e){return e.startsWith("/documents")&&(e.endsWith(".sqlite")?h(e)||l.symlink("/blocked/"+d(e),e):l.writeFile(e,"!$@) this should never read !$@)")),e}async function m(e,t){if(e.startsWith("/documents")&&!e.endsWith(".sqlite")){if(!h(e))throw new Error("File does not exist: "+e);let r=s.getStore(await s.getDatabase(),"files").store,n=await s.get(r,e);if(null==n)throw new Error("File does not exist: "+e);return"utf8"===t.encoding&&ArrayBuffer.isView(n.contents)?String.fromCharCode.apply(null,new Uint16Array(n.contents.buffer)):n.contents}return l.readFile(y(e),t)}function y(e){try{return l.lookupPath(e,{follow:!1}).node.link?l.readlink(e):e}catch(t){return e}}async function b(e,t){if(t instanceof ArrayBuffer?t=new Uint8Array(t):ArrayBuffer.isView(t)&&(t=new Uint8Array(t.buffer)),g(e),e.startsWith("/documents")){let r=e.endsWith(".sqlite"),n=s.getStore(await s.getDatabase(),"files").store;r?(await s.set(n,{filepath:e,contents:""}),await Promise.resolve(),l.writeFile(y(e),t)):await s.set(n,{filepath:e,contents:t})}else l.writeFile(y(e),t)}async function _(){let e=(await(await fetch("/data-file-index.txt")).text()).split("\n").map(e=>e.trim()).filter(e=>""!==e);await O("/migrations"),await O("/demo-budget"),await Promise.all(e.map(async e=>{var t;b("/"+e,await(t="/data/"+e,fetch(t).then(e=>e.arrayBuffer())))}))}async function w(){let e=s.getStore(await s.getDatabase(),"files").store.getAllKeys(),t=await new Promise((t,r)=>{e.onsuccess=e=>t(e.target.result),e.onerror=e=>r(e)});for(let e of t)p(v(e)),g(e)}function v(e){return e.split("/").slice(0,-1).join("/")}async function E(e){return l.readdir(e).filter(e=>"."!==e&&".."!==e)}async function S(e){return h(e)}async function O(e){l.mkdir(e)}async function T(e){return async function(e){if(e.startsWith("/documents")){let t=e.endsWith(".sqlite"),r=s.getStore(await s.getDatabase(),"files").store;if(await s.del(r,e),t){let t=y(e);h(t)&&l.unlink(t)}}l.unlink(e)}(e)}async function A(e){l.rmdir(e)}e.exports={pathToId:d,populateFileHeirarchy:w,init:async function(){let e=a();if(l=e.FS,l.mkdir("/uploads"),l.mkdir("/documents"),l.mkdir("/blocked"),!t.__TESTING__){let t=new i(()=>{o.send("fallback-write-error")});f=new n(l,t),e.register_for_idb(f),l.mount(f,{},"/blocked"),await _()}await w()},shutdown:function(){f.backend.shutdown()},bundledDatabasePath:"/default-db.sqlite",migrationsPath:"/migrations",demoBudgetPath:"/demo-budget",getDataDir:u.getDataDir,getDocumentDir:u.getDocumentDir,getBudgetDir:u.getBudgetDir,_setDocumentDir:u._setDocumentDir,join:c,basename:v,listDir:E,exists:S,mkdir:O,size:async function(e){return l.stat(y(e)).size},copyFile:async function(e,t){return b(t,await m(e))},readFile:async function(e,t="utf8"){return m(e,{encoding:t})},writeFile:async function(e,t){return b(e,t)},removeFile:T,removeDir:A,removeDirRecursively:async function e(t){if(await S(t)){for(let r of await E(t)){let n=c(t,r),i=l.stat(n,!0);l.isDir(i.mode)?await e(n):await T(n)}await A(t)}},getModifiedTime:async function(e){throw new Error("getModifiedTime not supported on the web (only used for backups)")}}}).call(this,r(23))},function(e,t,r){"use strict";(function(e){r.d(t,"b",(function(){return h})),r.d(t,"e",(function(){return m})),r.d(t,"i",(function(){return y})),r.d(t,"g",(function(){return b})),r.d(t,"f",(function(){return _})),r.d(t,"c",(function(){return w})),r.d(t,"d",(function(){return v})),r.d(t,"h",(function(){return E})),r.d(t,"a",(function(){return S})),r.d(t,"j",(function(){return O}));var n=r(172),i=r(8),o=r(24),a=r(15),s=r(2),u=r(43);const c=r(49).resolveName;let l,f,d;function h(){return l}async function p(e,t){await a.transaction(e,()=>{t.forEach(t=>{const r=l._getNode(t);null==r.sql&&a.runQuery(e,"INSERT OR REPLACE INTO kvcache (key, value) VALUES (?, ?)",[t,JSON.stringify(r.value)])})})}function g(e,t,{clean:r}){if(r){let r=1e7*Math.random();a.runQuery(t,"INSERT OR REPLACE INTO kvcache_key (id, key) VALUES (1, ?)",[r]),e&&a.runQuery(e,"INSERT OR REPLACE INTO kvcache_key (id, key) VALUES (1, ?)",[r])}else a.runQuery(t,"DELETE FROM kvcache_key")}async function m(t,r){let i,s,c=!e.__TESTING__,h=t.getDatabase();if(u.a.isDesktop&&c){let e=t.getDatabasePath().replace(/db\.sqlite$/,"cache.sqlite");d=i=a.openDatabase(e),a.execQuery(i,"\n CREATE TABLE IF NOT EXISTS kvcache (key TEXT PRIMARY KEY, value TEXT);\n CREATE TABLE IF NOT EXISTS kvcache_key (id INTEGER PRIMARY KEY, key REAL)\n ")}else i=h;if(s=c?new n.a(p.bind(null,i),g.bind(null,h,i)):new n.a,Object(o.captureBreadcrumb)({message:"loading spreaadsheet",category:"server"}),l=s,f=r,r&&s.addEventListener("change",r),c&&!function(e,t){let r=a.runQuery(t,"SELECT key FROM kvcache_key WHERE id = 1",[],!0),n=0===r.length?null:r[0].key;if(null==n)return!0;if(e){let t=a.runQuery(e,"SELECT key FROM kvcache_key WHERE id = 1",[],!0);if(0===t.length||t[0].key!==n)return!0}return r=a.runQuery(t,"SELECT * FROM kvcache LIMIT 1",[],!0),0===r.length}(h,i)){let e=await a.runQuery(i,"SELECT * FROM kvcache",[],!0);console.log(`Loaded spreadsheet from cache (${e.length} items)`);for(let t of e){let e=JSON.parse(t.value);s.load(t.key,e)}}else console.log("Loading fresh spreadsheet"),await _(t);return Object(o.captureBreadcrumb)({message:"loaded spreaadsheet",category:"server"}),s}function y(){l&&(l.unload(),l=null),d&&(a.closeDatabase(d),d=null)}async function b(e){if(l)return y(),m(e,f)}async function _(e){let t=l,r=(i.b()||{}).budgetType,n="report"===r?"reflect_budgets":"zero_budgets",o=await e.all(`\n SELECT * FROM ${n} b\n LEFT JOIN categories c ON c.id = b.category\n WHERE c.tombstone = 0\n `);t.startTransaction();for(let e of o)if(e.month&&e.category){let r="budget"+e.month;t.set(`${r}!budget-${e.category}`,e.amount),t.set(`${r}!carryover-${e.category}`,1===e.carryover)}if("report"!==r){let r=await e.all("SELECT * FROM zero_budget_months");for(let e of r){let r=Object(s.p)(e.id);t.set(r+"!buffered",e.buffered)}}t.endTransaction()}function w(e,t){return l._getNode(c(e,t))}function v(e,t){return l.getValue(c(e,t))}function E(){l&&l.startTransaction()}function S(){l&&l.endTransaction()}function O(){return new Promise(e=>{l?l.onFinish(e):e()})}}).call(this,r(23))},function(e,t,r){"use strict";r.r(t),function(e){r.d(t,"mutator",(function(){return h})),r.d(t,"isMutating",(function(){return p})),r.d(t,"runHandler",(function(){return m})),r.d(t,"enableGlobalMutations",(function(){return y})),r.d(t,"disableGlobalMutations",(function(){return b})),r.d(t,"runMutator",(function(){return _})),r.d(t,"withMutatorContext",(function(){return w})),r.d(t,"getMutatorContext",(function(){return v}));var n=r(91),i=r(24);function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;tsetTimeout(t,e))}async function m(e,t,{undoTag:r,name:n}={}){if(d.push(n),d.length>5&&(d=d.slice(-5)),l.has(e))return _(()=>e(t),{undoTag:r});"close-budget"===n&&await async function(){for(await g(200);u.size>0;)await Promise.all([...u.values()]),await g(100)}();let i=e(t);return u.add(i),i.then(()=>{u.delete(i)}),i}function y(){e.__TESTING__&&(f=!0)}function b(){e.__TESTING__&&(f=!1)}const _=Object(n.sequential)(async(e,t={})=>(c=t,e().finally(()=>{c=null})));function w(e,t){if(null==c&&!f)return Object(i.captureBreadcrumb)("Recent methods: "+d.join(", ")),Object(i.captureException)(new Error("withMutatorContext: mutator not running")),t();let r=c;return c=a(a({},c),e),t().finally(()=>{c=r})}function v(){return null==c?(Object(i.captureBreadcrumb)({category:"server",message:"Recent methods: "+d.join(", ")}),{}):null==c&&f?{}:c}}.call(this,r(23))},function(e,t,r){"use strict";(function(e){r.d(t,"k",(function(){return N})),r.d(t,"a",(function(){return U})),r.d(t,"b",(function(){return F})),r.d(t,"c",(function(){return V})),r.d(t,"j",(function(){return G})),r.d(t,"l",(function(){return $})),r.d(t,"d",(function(){return K})),r.d(t,"f",(function(){return J})),r.d(t,"e",(function(){return Q}));var n=r(91),i=(r(289),r(8)),o=r(28),a=r(9),s=r.n(a),u=r(24),c=r(69),l=r(30),f=r(1),d=r(5),h=r(61),p=r(14),g=r(6),m=r(12),y=r(13),b=r(75),_=r(173),w=r(20),v=r(125),E=r(240);r.d(t,"g",(function(){return E.a}));var S=r(241);function O(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function T(e){for(var t=1;ta+" = ?").join(" OR ");try{let e=await f.runQuery(i,o,!0);r=r.concat(e)}catch(e){throw new I("invalid-schema")}}return r}function x(e){if(null===e)return"0:";if("number"==typeof e)return"N:"+e;if("string"==typeof e)return"S:"+e;throw new Error("Unserializable value type: "+JSON.stringify(e))}function P(e){switch(e[0]){case"0":return null;case"N":return parseFloat(e.slice(2));case"S":return e.slice(2)}throw new Error("Invalid type key for value: "+e)}let B=[];function U(e){return B.push(e),()=>{B=B.filter(t=>t!==e)}}const F=Object(n.sequential)(async e=>{if(k("import"))return function(e){f.transaction(()=>{for(let t=0;t= ?"),[i,o,a,s],!0);0===u.length?t.push(n):u[0].timestamp!==s&&t.push(T(T({},n),{},{old:!0}))}return t}(e)),e=[...e].sort((e,t)=>{let r=e.timestamp?e.timestamp.toString():"",n=t.timestamp?t.timestamp.toString():"";return rn?1:0});let t={};async function r(){let e=new Map;for(let r of Object.keys(t)){const n=await L(r,t[r]);for(let t=0;t{"prefs"!==e.dataset&&(null==t[e.dataset]&&(t[e.dataset]=[]),t[e.dataset].push(e.row))});let n,a,s={},u=await r();p.a(e,u),k("enabled")&&(n=Object(y.getClock)(),a=n.merkle),d.b()&&d.b().startCacheBarrier(),f.transaction(()=>{let t=new Set;for(let r=0;r0&&(i.d(s,{avoidSync:!0}),s.budgetType&&Object(h.c)(s.budgetType),j.send("prefs-updated"));let c=await r();d.b()&&(d.h(),Object(h.d)(u,c),d.b().triggerDatabaseChanges(u,c),d.a(),d.b().endCacheBarrier()),B.forEach(e=>e(u,c));let l=X(e.filter(e=>!e.old));return o.a.events.emit("sync",{type:"applied",tables:l,data:c,prevData:u}),e});function W(e){return e.forEach(e=>{y.default.recv(e.timestamp)}),Object(g.runMutator)(()=>F(e))}async function H(t){try{await F(t)}catch(e){throw e instanceof I&&("invalid-schema"===e.reason?o.a.events.emit("sync",{type:"error",subtype:"apply-failure"}):o.a.events.emit("sync",{type:"error"})),e}await function(){if(K(),k("enabled")&&!k("offline")){if(e.__TESTING__)return Q().then(e=>{if(e.error)throw e.error;return e});Z=setTimeout(Q,1e3)}}()}let z=!1,q=[];async function V(e){if(z)return void await e();z=!0;let t=[];try{await e()}finally{z=!1,t=q,q=[]}t.length>0&&await H(t)}async function G(e){if(!z)return H(e);q=q.concat(e)}function Y(e){return f.runQuery("SELECT timestamp, dataset, row, column, value FROM messages_crdt WHERE timestamp > ?",[e],!0)}async function $(e,t){let r=await Y(t);return await W(e.map(e=>T(T({},e),{},{value:P(e.value),timestamp:y.default.parse(e.timestamp)}))),r}function K(){Z&&(clearTimeout(Z),Z=null)}let Z=null;function X(e){return e.reduce((e,t)=>{let r="schedules_next_date"===t.dataset?"schedules":t.dataset;return e.includes(r)||e.push(r),e},[])}async function J(){(await Q()).error||await d.j()}const Q=Object(n.once)((async function(){let e;o.a.events.emit("sync",{type:"start"});try{e=await async function e(t,r,n){let o=i.b()||{},a=o.cloudFileId,u=o.groupId,d=o.lastSyncedTimestamp;if(K(),k("disabled")||k("offline"))return[];let h=Object(y.getClock)().timestamp.toString(),p=t||d||new y.default(Date.now()-3e5,0,"0").toString(),g=Y(p),m=await s.a.getItem("user-token");c.a.info("Syncing since",p,g.length,"(attempt: "+r+")");let E=await _.b(u,a,p,g),S=await Object(l.postBinary)(Object(w.a)().SYNC_SERVER+"/sync",E,{"X-ACTUAL-TOKEN":m});if(!i.b()||i.b().groupId!==u)return[];let O=await _.a(S);c.a.info("Got messages from server",O.messages.length);let A=Object(y.getClock)().timestamp.toString()!==h,M=[];O.messages.length>0&&(M=await W(O.messages.map(e=>T(T({},e),{},{value:P(e.value),timestamp:y.default.parse(e.timestamp)}))));let D=b.diff(O.merkle,Object(y.getClock)().merkle);O.messages;if(null!==D){if(r>=10&&D===n||r>=100){c.a.info("SENT -------"),c.a.info(JSON.stringify(g)),c.a.info("RECEIVED -------"),c.a.info(JSON.stringify(O.messages));let e=Object(v.b)();if(console.log(r,"messages:",g.length,g.length>0?g[0]:null,"res.messages:",O.messages.length,O.messages.length>0?O.messages[0]:null,"clientId",Object(y.getClock)().timestamp.node(),"groupId",u,"diffTime:",D,D===n,"local clock:",Object(y.getClock)().timestamp.toString(),Object(y.getClock)().merkle.hash,"rebuilt hash:",e.numMessages,e.trie.hash,"server hash:",O.merkle.hash,"localTimeChanged:",A),e.trie.hash===O.merkle.hash){let e=await f.all("SELECT * FROM messages_clock");1!==e.length&&console.log("Bad number of clocks:",e.length);let t=Object(y.deserializeClock)(e[0]).merkle.hash;console.log("Merkle hash in db:",t)}throw new I("out-of-sync")}M=M.concat(await e(new y.default(D,0,"0").toString(),A?0:r+1,D))}else await i.d({lastSyncedTimestamp:Object(y.getClock)().timestamp.toString()});return M}(null,0,null)}catch(e){return console.log(e),e instanceof I?"out-of-sync"===e.reason?(Object(u.captureException)(e),o.a.events.emit("sync",{type:"error",subtype:"out-of-sync"})):"invalid-schema"===e.reason?o.a.events.emit("sync",{type:"error",subtype:"invalid-schema"}):"decrypt-failure"===e.reason||"encrypt-failure"===e.reason?o.a.events.emit("sync",{type:"error",subtype:e.reason,meta:e.meta}):"beta-version"===e.reason?o.a.events.emit("sync",{type:"error",subtype:e.reason}):o.a.events.emit("sync",{type:"error"}):e instanceof D?(console.log(e),"unauthorized"===e.reason?(o.a.events.emit("sync",{type:"unauthorized"}),s.a.setItem("readOnly","true")):"network-failure"===e.reason?o.a.events.emit("sync",{type:"error",subtype:"network"}):o.a.events.emit("sync",{type:"error",subtype:e.reason})):(Object(u.captureException)(e),o.a.events.emit("sync",{type:"error"})),{error:{message:e.message,reason:e.reason,meta:e.meta}}}let t=X(e);return o.a.events.emit("sync",{type:"success",tables:t,syncDisabled:k("disabled")}),{messages:e}}))}).call(this,r(23))},function(e,t,r){"use strict";(function(e){r.d(t,"c",(function(){return s})),r.d(t,"d",(function(){return u})),r.d(t,"e",(function(){return c})),r.d(t,"b",(function(){return l})),r.d(t,"a",(function(){return f}));var n=r(7),i=r(13);const o=r(4);let a=null;async function s(t){if(e.__TESTING__&&!t)return a={dummyTestPrefs:!0},a;const r=o.join(o.getBudgetDir(t),"metadata.json");try{a=JSON.parse(await o.readFile(r))}catch(e){a={id:t,budgetName:t}}return a.id=t,a}async function u(e,{avoidSync:t=!1}={}){if(Object.assign(a,e),!t){let t=Object.keys(e).map(t=>"budgetType"===t||"budgetName"===t?{dataset:"prefs",row:t,column:"value",value:e[t],timestamp:i.default.send()}:null).filter(e=>e);t.length>0&&await Object(n.j)(t)}if(!a.dummyTestPrefs){let e=o.join(o.getBudgetDir(a.id),"metadata.json");await o.writeFile(e,JSON.stringify(a))}}function c(){a=null}function l(){return a}function f(e,t){return{id:e,budgetName:t,"notifications.schedules":!0,"notifications.repair-splits":!0}}}).call(this,r(23))},function(e,t,r){let n=r(179),i=n.getDatabase,o=n.closeDatabase;function a(e){e.commit&&e.commit()}e.exports={init:function(){},shutdown:function(){o()},getItem:async function(e){let t=(await i()).transaction(["asyncStorage"],"readonly"),r=t.objectStore("asyncStorage");return new Promise((n,i)=>{let o=r.get(e);o.onerror=e=>i(e),o.onsuccess=e=>n(e.target.result),a(t)})},setItem:async function(e,t){let r=(await i()).transaction(["asyncStorage"],"readwrite"),n=r.objectStore("asyncStorage");new Promise((i,o)=>{let s=n.put(t,e);s.onerror=e=>o(e),s.onsuccess=e=>i(),a(r)})},removeItem:async function(e){let t=(await i()).transaction(["asyncStorage"],"readwrite"),r=t.objectStore("asyncStorage");return new Promise((n,i)=>{let o=r.delete(e);o.onerror=e=>i(e),o.onsuccess=e=>n(),a(t)})},multiGet:async function(e){let t=(await i()).transaction(["asyncStorage"],"readonly"),r=t.objectStore("asyncStorage"),n=Promise.all(e.map(e=>new Promise((t,n)=>{let i=r.get(e);i.onerror=e=>n(e),i.onsuccess=r=>t([e,r.target.result])})));return a(t),n},multiSet:async function(e){let t=(await i()).transaction(["asyncStorage"],"readwrite"),r=t.objectStore("asyncStorage"),n=Promise.all(e.map(([e,t])=>new Promise((n,i)=>{let o=r.put(t,e);o.onerror=e=>i(e),o.onsuccess=e=>n()})));return a(t),n},multiRemove:async function(e){let t=(await i()).transaction(["asyncStorage"],"readwrite"),r=t.objectStore("asyncStorage"),n=Promise.all(e.map(e=>new Promise((t,n)=>{let i=r.delete(e);i.onerror=e=>n(e),i.onsuccess=e=>t()})));return a(t),n}}},function(e,t,r){"use strict";(function(e){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ var n=r(286),i=r(287),o=r(178);function a(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,t){if(a()=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function p(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return F(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(e).length;default:if(n)return F(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return A(this,t,r);case"ascii":return M(this,t,r);case"latin1":case"binary":return D(this,t,r);case"base64":return T(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function m(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function y(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var l=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var f=!0,d=0;di&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function T(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function A(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=f}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},u.prototype.compare=function(e,t,r,n,i){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),s=Math.min(o,a),c=this.slice(n,i),l=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return _(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":return v(this,e,t,r);case"latin1":case"binary":return E(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function M(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function N(e,t,r,n,i,o){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function k(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function C(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function L(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(e,t,r,n,o){return o||L(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function P(e,t,r,n,o){return o||L(e,0,r,8),i.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},u.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},u.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||N(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||N(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||N(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):k(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||N(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):k(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||N(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):C(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||N(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):C(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);N(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);N(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||N(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||N(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):k(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||N(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):k(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||N(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):C(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||N(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):C(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return x(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return x(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return P(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return P(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function W(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(B,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function H(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(23))},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},function(e,t,r){"use strict";r.d(t,"l",(function(){return c})),r.d(t,"f",(function(){return l})),r.d(t,"j",(function(){return f})),r.d(t,"b",(function(){return d})),r.d(t,"n",(function(){return h})),r.d(t,"h",(function(){return p})),r.d(t,"d",(function(){return m})),r.d(t,"i",(function(){return y})),r.d(t,"o",(function(){return b})),r.d(t,"g",(function(){return _})),r.d(t,"e",(function(){return w})),r.d(t,"c",(function(){return E})),r.d(t,"p",(function(){return S})),r.d(t,"a",(function(){return O})),r.d(t,"k",(function(){return T})),r.d(t,"m",(function(){return A}));const n=["id"];function i(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t{t.push(e)}),e.updated&&e.updated.forEach(e=>{let r=e.id,o=i(e,n);const s=t.findIndex(e=>e.id===r);t[s]=a(a({},t[s]),o)}),e.deleted&&e.deleted.forEach(e=>{const r=t.findIndex(t=>e.id===t.id);-1!==r&&t.splice(r,1)}),t}function h(e,t){let r=new Map;for(let n=0;n!n.has(e.id)).map(e=>({id:e.id}));return t.forEach(e=>{let t=r.get(e.id);if(t){const r=l(t,e);r&&o.push(r)}else i.push(e)}),{added:i,updated:o,deleted:a}}function y(e){let t={};for(let r=0;ru.format(e,{locale:t,format:"%v"})},regex:r}}("1,000.33")},function(e,t,r){"use strict";r.r(t),r.d(t,"setClock",(function(){return s})),r.d(t,"getClock",(function(){return u})),r.d(t,"makeClock",(function(){return c})),r.d(t,"serializeClock",(function(){return l})),r.d(t,"deserializeClock",(function(){return f})),r.d(t,"makeClientId",(function(){return d})),r.d(t,"default",(function(){return p})),r.d(t,"MutableTimestamp",(function(){return g}));var n=r(273),i=r.n(n);const o=r(42);let a=null;function s(e){a=e}function u(){return a}function c(e,t={}){return{timestamp:g.from(e),merkle:t}}function l(e){return JSON.stringify({timestamp:e.timestamp.toString(),merkle:e.merkle})}function f(e){let t;try{t=JSON.parse(e)}catch(e){t={timestamp:"1970-01-01T00:00:00.000Z-0000-"+d(),merkle:{}}}return{timestamp:g.from(p.parse(t.timestamp)),merkle:t.merkle}}function d(){return o.v4Sync().replace(/-/g,"").slice(-16)}var h={maxDrift:3e5};class p{constructor(e,t,r){this._state={millis:e,counter:t,node:r}}valueOf(){return this.toString()}toString(){return[new Date(this.millis()).toISOString(),("0000"+this.counter().toString(16).toUpperCase()).slice(-4),("0000000000000000"+this.node()).slice(-16)].join("-")}millis(){return this._state.millis}counter(){return this._state.counter}node(){return this._state.node}hash(){return i.a.v3(this.toString())}}class g extends p{setMillis(e){this._state.millis=e}setCounter(e){this._state.counter=e}setNode(e){this._state.node=e}}g.from=e=>new g(e.millis(),e.counter(),e.node()),p.init=function(e={}){e.maxDrift&&(h.maxDrift=e.maxDrift),s(c(new p(0,0,e.node?("0000000000000000"+e.node).toString().slice(-16):"")))},p.send=function(){if(!a)return null;var e=Date.now(),t=a.timestamp.millis(),r=a.timestamp.counter(),n=Math.max(t,e),i=t===n?r+1:0;if(n-e>h.maxDrift)throw new p.ClockDriftError(n,e,h.maxDrift);if(i>65535)throw new p.OverflowError;return a.timestamp.setMillis(n),a.timestamp.setCounter(i),new p(a.timestamp.millis(),a.timestamp.counter(),a.timestamp.node())},p.recv=function(e){if(!a)return null;var t=Date.now(),r=e.millis(),n=e.counter();if(r-t>h.maxDrift)throw new p.ClockDriftError;var i=a.timestamp.millis(),o=a.timestamp.counter(),s=Math.max(Math.max(i,t),r),u=s===i&&s===r?Math.max(o,n)+1:s===i?o+1:s===r?n+1:0;if(s-t>h.maxDrift)throw new p.ClockDriftError;if(u>65535)throw new p.OverflowError;return a.timestamp.setMillis(s),a.timestamp.setCounter(u),new p(a.timestamp.millis(),a.timestamp.counter(),a.timestamp.node())},p.parse=function(e){if("string"==typeof e){var t=e.split("-");if(t&&5===t.length){var r=Date.parse(t.slice(0,3).join("-")).valueOf(),n=parseInt(t[3],16),i=t[4];if(!isNaN(r)&&!isNaN(n))return new p(r,n,i)}}return null};var m=p.parse("1970-01-01T00:00:00.000Z-0000-0000000000000000");p.zero=function(){return m};var y=p.parse("9999-12-31T23:59:59.999Z-FFFF-FFFFFFFFFFFFFFFF");p.max=function(){return y},p.since=e=>e+"-0000-0000000000000000",p.DuplicateNodeError=class extends Error{constructor(e){super(),this.type="DuplicateNodeError",this.message="duplicate node identifier "+e}},p.ClockDriftError=class extends Error{constructor(...e){super(),this.type="ClockDriftError",this.message=["maximum clock drift exceeded"].concat(e).join(" ")}},p.OverflowError=class extends Error{constructor(){super(),this.type="OverflowError",this.message="timestamp counter overflow"}}},function(e,t,r){"use strict";r.d(t,"a",(function(){return g})),r.d(t,"b",(function(){return m})),r.d(t,"f",(function(){return y})),r.d(t,"e",(function(){return b})),r.d(t,"d",(function(){return w})),r.d(t,"c",(function(){return v}));var n=r(7),i=r(12),o=r(13),a=r(6);function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0){!function(){h=h.slice(0,p+1);let e=h.filter(e=>"marker"===e.type);if(e.length>20){let t=e.slice(-20),r=h.indexOf(t[0]);h=h.slice(r),p=h.length-1}}();let n=r.undoTag;h.push({type:"messages",messages:e,oldData:t,undoTag:n}),p++}}function m(){h=[{type:"marker"}],p=0}function y(e,t){let r=Object(a.getMutatorContext)();if(r.undoDisabled||r.undoListening)return e();h=h.slice(0,p+1);let n={type:"marker",meta:t};return"marker"===h[h.length-1].type?h[h.length-1]=n:(h.push(n),p++),Object(a.withMutatorContext)({undoListening:!0,undoTag:r.undoTag},e)}function b(e){return(...t)=>y(()=>e(...t))}async function _(e,t,r){await Object(a.withMutatorContext)({undoListening:!1},()=>Object(n.j)(e.map(e=>l(l({},e),{},{timestamp:o.default.send()}))));const i=e.reduce((e,t)=>(e.includes(t.dataset)||e.push(t.dataset),e),[]);d.send("undo-event",{messages:e,tables:i,meta:t,undoTag:r})}async function w(){let e=p;for(p=Math.max(p-1,0);p>0&&"marker"!==h[p].type;)p--;let t=h[p].meta,r=Math.max(p,0),n=h.slice(r,e+1).filter(e=>"messages"===e.type);if(n.length>0){let e=n.reduce((e,t)=>e.concat(t.messages.map(e=>function(e,t){let r=Object(i.g)(t,[e.dataset,e.row]);if(r){let t=e.column;return"spreadsheet_cells"===e.dataset&&(t="cachedValue"),l(l({},e),{},{value:r[t]})}if("spreadsheet_cells"===e.dataset)return"expr"===e.column?l(l({},e),{},{value:null}):e;if("category_mapping"!==e.dataset&&"payee_mapping"!==e.dataset)return"zero_budget_months"===e.dataset||"zero_budgets"===e.dataset||"reflect_budgets"===e.dataset?["buffered","amount","carryover"].includes(e.column)?l(l({},e),{},{value:0}):null:"notes"===e.dataset?l(l({},e),{},{value:null}):l(l({},e),{},{column:"tombstone",value:1});return null}(e,t.oldData)).filter(e=>e)),[]).reverse();await _(e,t,n[0].undoTag)}}async function v(){let e="marker"===h[p].type?h[p].meta:null,t=p;for(p=Math.min(p+1,h.length-1);p"messages"===e.type);if(n.length>0){let t=n.reduce((e,t)=>e.concat(t.messages).concat(function(e,t){let r=new Set;return e.forEach(e=>{Object(i.g)(t,[e.dataset,e.row])||["zero_budget_months","zero_budgets","reflect_budgets","notes","category_mapping","payee_mapping"].includes(e.dataset)||r.add(e.dataset+"."+e.row)}),[...r].map(e=>{let t=s(e.split("."),2);return{dataset:t[0],row:t[1],column:"tombstone",value:0,timestamp:o.default.send()}})}(t.messages,t.oldData)),[]);await _(t,e,n[n.length-1].undoTag)}}},function(e,t,r){"use strict";r.r(t),r.d(t,"init",(function(){return a})),r.d(t,"_getModule",(function(){return s})),r.d(t,"prepare",(function(){return u})),r.d(t,"runQuery",(function(){return c})),r.d(t,"execQuery",(function(){return l})),r.d(t,"transaction",(function(){return d})),r.d(t,"asyncTransaction",(function(){return h})),r.d(t,"openDatabase",(function(){return p})),r.d(t,"closeDatabase",(function(){return g})),r.d(t,"exportDatabase",(function(){return m}));var n=r(272),i=r.n(n);let o=null;async function a(){return new Promise((e,t)=>{i()({locateFile:e=>"/"+e}).then(t=>{o=t,e()},e=>{t(e)})})}function s(){if(null==o)throw new Error("_getModule: sql.js must be initialized first");return o}function u(e,t){return e.prepare(t)}function c(e,t,r=[],n){r&&function(e,t){t.forEach(t=>{if("string"!=typeof t&&"number"!=typeof t&&null!==t)throw new Error("Invalid field type "+t+" for sql "+e)})}(t,r);let i="string"==typeof t?e.prepare(t):t;if(n)try{i.bind(r);let e=[];for(;i.step();)e.push(i.getAsObject());return"string"==typeof t?i.free():i.reset(),e}catch(e){throw console.log(t),e}else try{return i.run(r),{changes:e.getRowsModified()}}catch(e){throw e}}function l(e,t){e.exec(t)}let f=0;function d(e,t){let r,n,i;f>0?(r="SAVEPOINT __actual_sp",n="RELEASE __actual_sp",i="ROLLBACK TO __actual_sp"):(r="BEGIN",n="COMMIT",i="ROLLBACK"),l(e,r),f++;try{const r=t();return l(e,n),r}catch(t){throw l(e,i),"ROLLBACK"!==i&&l(e,n),t}finally{f--}}async function h(e,t){0===f&&e.exec("BEGIN TRANSACTION"),f++;try{await t()}finally{f--,0===f&&e.exec("COMMIT")}}async function p(e){if(e){if("string"!=typeof e)return new o.Database(e);let t=e;if(":memory:"!==t){if("undefined"==typeof SharedArrayBuffer){let e=o.FS.open(o.FS.readlink(t),"a+");await e.node.contents.readIfFallback(),o.FS.close(e)}let e=new o.Database(t.includes("/blocked")?t:o.FS.readlink(t),{filename:!0});return e.exec("\n PRAGMA journal_mode=MEMORY;\n PRAGMA cache_size=-10000;\n "),e}}return new o.Database}function g(e){e.close()}function m(e){return e.export()}},function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var n=r(10),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,t),t.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";r.d(t,"g",(function(){return c})),r.d(t,"h",(function(){return l})),r.d(t,"d",(function(){return f})),r.d(t,"a",(function(){return d})),r.d(t,"c",(function(){return h})),r.d(t,"b",(function(){return p})),r.d(t,"e",(function(){return g})),r.d(t,"f",(function(){return m})),r.d(t,"i",(function(){return y}));const n=["sort_order"],i=["sort_order"];function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function c(e,t,r,n){r.forEach(r=>{if(n){if(t.hasOwnProperty(r)&&null==t[r])throw new Error(`${e} is missing field ${r}`)}else if(!t.hasOwnProperty(r)||null==t[r])throw new Error(`${e} is missing field ${r}`)})}function l(e){if("string"!=typeof e)throw new Error("toDateRepr not passed a string: "+e);return parseInt(e.replace(/-/g,""))}function f(e){if("number"!=typeof e)throw new Error("fromDateRepr not passed a number: "+e);const t=e.toString();return t.slice(0,4)+"-"+t.slice(4,6)+"-"+t.slice(6)}const d={validateAccountType(e){const t=e.type;if("checking"!==t&&"savings"!==t&&"investment"!==t&&"credit"!==t&&"mortgage"!==t&&"debt"!==t&&"other"!==t)throw new Error("Invalid account type: "+t)},validate:(e,{update:t}={})=>(t&&null==e.type||d.validateAccountType(e),c("account",e,t?["name","type","offbudget","closed"]:["name","type"],t),e)},h={validate(e,{update:t}={}){c("category",e,t?["name","is_income","cat_group"]:["name","cat_group"],t);e.sort_order;return u(e,n)}},p={validate(e,{update:t}={}){c("categoryGroup",e,t?["name","is_income"]:["name"],t);e.sort_order;return u(e,i)}},g={validate:(e,{update:t}={})=>(c("payee",e,["name"],t),e)},m={validateType(e){const t=e.type;if("equals"!==t&&"contains"!==t)throw new Error("Invalid rule type: "+t)},validate:(e,{update:t}={})=>(t&&!("type"in e)||m.validateType(e),c("payee_rules",e,["payee_id","type"],t),e)},y={validate(e,{update:t}={}){if(c("transaction",e,["date","acct"],t),"date"in e&&(null==e.date.match(/^\d{4}-\d{2}-\d{2}$/)||e.date<"2000-01-01"))throw new Error("Invalid transaction date: "+e.date);return e},toJS(e){if(!("location"in e))throw new Error("A full transaction is required to be passed to `toJS`. Instead got: "+JSON.stringify(e));let t=a({},e);return t.error=e.error?JSON.parse(e.error):null,t.isParent=1===e.isParent,t.isChild=1===e.isChild,t.starting_balance_flag=1===e.starting_balance_flag,t.cleared=1===e.cleared,t.pending=1===e.pending,t.date=t.date&&f(t.date),t},fromJS(e){let t=a({},e);return"error"in t&&(t.error=e.error?JSON.stringify(e.error):null),"isParent"in t&&(t.isParent=e.isParent?1:0),"isChild"in t&&(t.isChild=e.isChild?1:0),"cleared"in t&&(t.cleared=e.cleared?1:0),"pending"in t&&(t.pending=e.pending?1:0),"starting_balance_flag"in t&&(t.starting_balance_flag=e.starting_balance_flag?1:0),"date"in t&&(t.date=l(e.date)),t}}},function(e,t,r){"use strict";r.r(t),r.d(t,"PostError",(function(){return n})),r.d(t,"HTTPError",(function(){return i})),r.d(t,"SyncError",(function(){return o})),r.d(t,"TransactionError",(function(){return a})),r.d(t,"RuleError",(function(){return s})),r.d(t,"APIError",(function(){return u})),r.d(t,"FileDownloadError",(function(){return c})),r.d(t,"FileUploadError",(function(){return l})),r.d(t,"isCodeError",(function(){return f}));class n extends Error{constructor(e,t){super("PostError: "+e),this.type="PostError",this.reason=e,this.meta=t}}class i extends Error{constructor(e,t){super(`HTTPError: unsuccessful status code (${e}): ${t}`),this.statusCode=e,this.responseBody=t}}class o extends Error{constructor(e,t){super("SyncError: "+e),this.reason=e,this.meta=t}}class a extends Error{constructor(e){super(e)}}class s extends Error{constructor(e,t){super("RuleError: "+t),this.type=e}}function u(e,t){return{type:"APIError",message:e,meta:t}}function c(e,t){return{type:"FileDownloadError",reason:e,meta:t}}function l(e,t){return{type:"FileUploadError",reason:e,meta:t}}function f(e){return e instanceof ReferenceError||e instanceof SyntaxError}},function(e,t){var r,n,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var u,c=[],l=!1,f=-1;function d(){l&&u&&(l=!1,u.length?c=u.concat(c):f=-1,c.length&&h())}function h(){if(!l){var e=s(d);l=!0;for(var t=c.length;t;){for(u=c,c=[];++f1)for(var r=1;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r[e[1],e[0]])));var O;function T(e){return m(m({},e),{},{field:S[e.field]||e.field})}function A(e){return m(m({},e),{},{field:E[e.field]||e.field})}const M={validate(e,{update:t}={}){if(Object(l.g)("rules",e,["conditions","actions"],t),(!t||"stage"in e)&&"pre"!==e.stage&&"post"!==e.stage&&null!==e.stage)throw new Error("Invalid rule stage: "+e.stage);return e},toJS(e){function t(e){let t;try{t="string"==typeof e?JSON.parse(e):e}catch(e){throw new u.RuleError("internal","Cannot parse rule json")}if(!Array.isArray(t))throw new u.RuleError("internal","Rule json must be an array");return t}let r=m({},e);return r.conditions=r.conditions?t(r.conditions).map(e=>T(e)):[],r.actions=r.actions?t(r.actions).map(e=>T(e)):[],r},fromJS(e){let t=m({},e);if("conditions"in t){let e=t.conditions.map(e=>A(e));t.conditions=JSON.stringify(e)}if("actions"in t){let e=t.actions.map(e=>A(e));t.actions=JSON.stringify(e)}return t}};function D(e){let t;try{t=new i.c(m(m({},M.toJS(e)),{},{fieldTypes:c.a}))}catch(e){if(console.warn("Invalid rule",e),e instanceof u.RuleError)return null;throw e}return Object(i.f)(t,Object(o.a)()),t}async function I(){b=new Map,w=new i.d({field:"imported_payee",method:"firstchar"}),v=new i.d({field:"payee"});let e=await n.all("\n SELECT * FROM rules\n WHERE conditions IS NOT NULL AND actions IS NOT NULL AND tombstone = 0\n ");for(let t=0;t{"rules"===t&&e.forEach(e=>{let t=b.get(e.id);if(1===e.tombstone){let t=b.get(e.id);t&&(b.delete(t.getId()),w.remove(t),v.remove(t))}else{let r=D(e);r&&(t&&(w.remove(t),v.remove(t)),b.set(e.id,r),w.index(r),v.index(r))}})}),[...t.keys()].find(e=>-1!==e.indexOf("mapping"))&&j().forEach(e=>{Object(i.f)(e,Object(o.a)())})}function L(e){let t=m({},e),r=Object(i.g)(Object(f.e)(w.getApplicableRules(e),v.getApplicableRules(e)));for(let e=0;e{if(e instanceof i.b)return e;try{return new i.b(e.op,e.field,e.value,e.options,c.a)}catch(e){return r.push(e.type||"internal"),console.log("conditionsToAQL: invalid condition: "+e.message),null}}).filter(Boolean)).map(e=>{let r=e.type,n=e.field,i=e.op,o=e.value,s=e.options,u=e=>"number"===r?e.value:e,l=(e,t,n)=>{if("number"===r){if(s){if(s.outflow)return{$and:[{amount:{$lt:0}},{[e]:{$transform:"$neg",[t]:n}}]};if(s.inflow)return{$and:[{amount:{$gt:0}},{[e]:{[t]:n}}]}}return{amount:{[t]:n}}}return"string"===r?{[e]:{$transform:"$lower",[t]:n}}:"date"===r?{[e]:{[t]:n.date}}:{[e]:{[t]:n}}};switch(i){case"isapprox":case"is":if("date"===r){if("recur"===o.type){return{$or:o.schedule.occurrences({take:t}).toArray().map(e=>Object(a.f)(e.date)).map(e=>"isapprox"===i?{$and:[{date:{$gte:Object(a.q)(e,2)}},{date:{$lte:Object(a.a)(e,2)}}]}:{date:e})}}o.date;if("isapprox"===i){let e=Object(a.l)(o.date),t=Object(a.a)(e,2);return{$and:[{date:{$gte:Object(a.q)(e,2)}},{date:{$lte:t}}]}}switch(o.type){case"date":return{date:o.date};case"month":return{$and:[{date:{$gte:o.date+"-00"}},{date:{$lte:o.date+"-99"}}]};case"year":return{$and:[{date:{$gte:o.date+"-00-00"}},{date:{$lte:o.date+"-99-99"}}]}}}else if("number"===r){let e=o.value;if("isapprox"===i){let t=Object(c.b)(e);return{$and:[l(n,"$gte",e-t),l(n,"$lte",e+t)]}}return l(n,"$eq",e)}return l(n,"$eq",o);case"isbetween":let e=h(Object(c.c)(o.num1,o.num2),2),s=e[0],f=e[1];return{[n]:[{$gte:s},{$lte:f}]};case"contains":return l("id"===r?n+".name":n,"$like","%"+o+"%");case"oneOf":let d=o;return 0===d.length?{id:null}:{$or:d.map(e=>l(n,"$eq",e))};case"gt":return l(n,"$gt",u(o));case"gte":return l(n,"$gte",u(o));case"lt":return l(n,"$lt",u(o));case"lte":return l(n,"$lte",u(o));case"true":return l(n,"$eq",!0);case"false":return l(n,"$eq",!1);default:throw new Error("Unhandled operator: "+i)}}),errors:r}}function P(e,t,r){let n=t.map(e=>{if(e instanceof i.a)return e;try{return new i.a(e.op,e.field,e.value,e.options,c.a)}catch(e){return console.log("Action error",e),null}}).filter(Boolean);if(n.length!==t.length)return null;let o=e.map(e=>{let t={id:e};for(let e of n)e.exec(t);return t});return r["transactions-batch-update"]({updated:o})}function B(e){let t=new Set;return Object(i.e)(j(),"payee",(r,n)=>{n===e&&t.add(r)}),Object(i.g)([...t])}function*U(e,t,r,{condValue:n,actionValue:i}){let o=j();for(let a=0;a""!==e)))],i=m(m({},r),{},{conditions:[m(m({},t),{},{value:n})]});return await N(i),r.id}return R(new i.c({stage:"pre",conditions:[{op:"oneOf",field:"imported_payee",value:e}],actions:[{op:"set",field:"payee",value:t}],fieldTypes:c.a}).serialize())}function W(e){let t=new Map;e.forEach(e=>{e.category&&t.set(e.category,(t.get(e.category)||0)+1)});let r=e.reduce((e,r)=>{let n=t.get(r.category);return!e||n>e.score?{score:n,category:r.category}:e},null);return r.score>=3?r.category:null}async function H(e){if(0===e.length)return;let t=new Set(e.map(e=>e.payee)),r=new Set(e.map(e=>e.id)),o=null;for(let t=0;t= ? AND date <= ? AND is_parent = 0 AND a.closed = 0",[Object(l.h)(o),Object(l.h)(Object(a.a)(Object(a.d)(),180))]),d=Object(f.n)(u,"payee"),p=new Map;for(let e of t)if(e){let t=(d.get(e)||[]).slice(0,5);if(t.find(e=>r.has(e.id))){let r=W(t);r&&p.set(e,r)}}await Object(s.c)(async()=>{for(let t of p.entries()){var e=h(t,2);let r=e[0],n=e[1],o=[...U(null,"payee","category",{condValue:r})];if(o.length>0)for(let e of o){let t=e.actions[0];t.value!==n&&await N(m(m({},e),{},{actions:[m(m({},t),{},{value:n})]}))}else{let e=new i.c({stage:null,conditions:[{op:"is",field:"payee",value:r}],actions:[{op:"set",field:"category",value:n}],fieldTypes:c.a});await R(e.serialize())}}})}async function z(){let e=await n.all("SELECT p.*, c.id as category FROM payees p\n LEFT JOIN category_mapping cm ON cm.id = p.category\n LEFT JOIN categories c ON (c.id = cm.transferId AND c.tombstone = 0)\n WHERE p.tombstone = 0 AND transfer_acct IS NULL"),t=await n.all("SELECT pr.*, pm.targetId as payee_id FROM payee_rules pr\n LEFT JOIN payee_mapping pm ON pm.id = pr.payee_id\n WHERE pr.tombstone = 0"),r=new Map;for(let t=0;t{let t=r.get(e.payee_id);return!("equals"!==e.type&&null!=e.type||t&&e.value.toLowerCase()===t.name.toLowerCase())}),s=n.filter(e=>"contains"===e.type),u=[{op:"set",field:"payee",value:t}];i.length>0&&o.push({stage:null,conditions:[{op:"oneOf",field:"imported_payee",value:i.map(e=>e.value)}],actions:u}),s.length>0&&(o=o.concat(s.map(e=>({stage:null,conditions:[{op:"contains",field:"imported_payee",value:e.value}],actions:u}))))}let u=e.filter(e=>e.category).reduce((e,t)=>{let r=e.get(t.category)||new Set;return r.add(t.id),e.set(t.category,r),e},new Map);for(let e of u){var c=h(e,2);let t=c[0],r=c[1];o.push({stage:null,conditions:[{op:"oneOf",field:"payee",value:[...r]}],actions:[{op:"set",field:"category",value:t}]})}let l=Object(s.k)("disabled");await Object(s.c)(async()=>{for(let e of o)await R({stage:e.stage,conditions:e.conditions,actions:e.actions});await n.runQuery("DELETE FROM payee_rules",[])}),Object(s.k)(l)}},function(e,t,r){"use strict";function n(e,t){for(var r=e<0?"-":"",n=Math.abs(e).toString();n.length!t.has(Object.keys(e)[0]))}))}select(e=[]){Array.isArray(e)||(e=[e]);let t=new a(i(i({},this.state),{},{selectExpressions:e}));return t.state.calculation=!1,t}calculate(e){let t=this.select({result:e});return t.state.calculation=!0,t}groupBy(e){return Array.isArray(e)||(e=[e]),new a(i(i({},this.state),{},{groupExpressions:[...this.state.groupExpressions,...e]}))}orderBy(e){return Array.isArray(e)||(e=[e]),new a(i(i({},this.state),{},{orderExpressions:[...this.state.orderExpressions,...e]}))}limit(e){return new a(i(i({},this.state),{},{limit:e}))}offset(e){return new a(i(i({},this.state),{},{offset:e}))}raw(){return new a(i(i({},this.state),{},{rawMode:!0}))}withDead(){return new a(i(i({},this.state),{},{withDead:!0}))}withoutValidatedRefs(){return new a(i(i({},this.state),{},{validateRefs:!1}))}options(e){return new a(i(i({},this.state),{},{tableOptions:e}))}serialize(){return this.state}}function s(e){return new a({table:e})}},function(e,t,r){"use strict";r.d(t,"a",(function(){return m})),r.d(t,"b",(function(){return y}));var n=r(33),i=r(1),o=r(108),a=(r(12),r(58)),s=r(67);async function u(e,t,r,n,o){let u=Object(a.b)(e,t,r),c=await i.all(u,n);return function(e,t){for(let r=0;r{n[e]=Object(s.e)(n[e],t.get(e))})}}(c,o),c}async function c(e,t,r,{params:n={},executors:i={}}={}){let o,a=r.namedParameters.map(e=>{let t=e.paramName;if(void 0===n[t])throw new Error(`Parameter ${t} not provided to query`);return Object(s.d)(n[t],e.paramType)});if(o=i[r.implicitTableName]?await i[r.implicitTableName](r,e,t,a,r.outputTypes):await u(e,r,t,a,r.outputTypes),e.calculation)if(o.length>0){let e=o[0];o=e[Object.keys(e)[0]]||0}else o=null;return o}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function f(e){for(var t=1;te.matched.split(","))))}let g=Object(o.b)(l.map(e=>e.group_id),`IFNULL(${r.from}.parent_id, ${r.from}.id)`),m=`\n SELECT ${r.select}, parent_id AS _parent_id FROM ${r.from}\n ${r.joins}\n WHERE ${g} ${d}\n ${r.orderBy}\n `,y=(Date.now(),(await i.all(m)).reduce((e,t)=>{let r=t._parent_id;if(delete t._parent_id,null==r)e.parents.push(t);else{let n=e.children.get(r)||[];n.push(t),e.children.set(r,n)}return e},{parents:[],children:new Map})),b=y.parents,_=y.children;return function(e,t,r=(e=>e)){return e.reduce((e,n)=>{let i=t.get(n.id)||[];return e.push(f(f({},r(n)),{},{subtransactions:i.map(r)})),e},[])}(b,_,e=>(Object.keys(e).forEach(t=>{e[t]=Object(s.e)(e[t],c.get(t))}),p&&!p.has(e.id)&&(e._unmatched=!0),e))}(0,t,r,n,0,c):void 0}},g=r(25);function m(e,t,r,n){return c(e,t,r,{params:n,executors:p})}function y(e,t){return e instanceof g.a&&(e=e.serialize()),async function(e,t,r,n){let i=Object(a.a)(r,e,t),o=i.sqlPieces,s=i.state;return{data:await c(r,o,s,n),dependencies:s.dependencies}}(n.a,n.b,e,{params:t,executors:p})}},function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));function n(e){var t=new Date(e.getTime()),r=t.getTimezoneOffset();return t.setSeconds(0,0),6e4*r+t.getTime()%6e4}},function(e,t,r){"use strict";var n=r(56);const i=r(52),o=Object(n.a)();o.events.on("sync",e=>{i.send("sync-event",e)}),t.a=o},function(e,t,r){"use strict";r.d(t,"b",(function(){return w})),r.d(t,"a",(function(){return E})),r.d(t,"c",(function(){return S})),r.d(t,"d",(function(){return O})),r.d(t,"g",(function(){return M})),r.d(t,"f",(function(){return D})),r.d(t,"e",(function(){return I}));var n=r(18),i=r(66),o=r(109),a=r(133),s=r(47),u=r(2),c=r(12),l=r(38),f=r(41),d=r(93);function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function p(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r"oneOf"===e?(b(Array.isArray(t),"no-empty-array",`oneOf must have an array value (field: ${r})`),t):t},string:{ops:["is","contains","oneOf"],nullable:!1,parse:(e,t,r)=>"oneOf"===e?(b(Array.isArray(t),"no-empty-array",`oneOf must have an array value (field: ${r}): ${JSON.stringify(t)}`),t.filter(Boolean).map(e=>e.toLowerCase())):("contains"===e&&b("string"==typeof t&&t.length>0,"no-empty-string",`contains must have non-empty string (field: ${r})`),t.toLowerCase())},number:{ops:["is","isapprox","isbetween","gt","gte","lt","lte"],nullable:!1,parse(e,t,r){let n="number"==typeof t?{type:"literal",value:t}:function(e){let t=e.num1,r=e.num2;return"number"!=typeof t||"number"!=typeof r?null:{type:"between",num1:t,num2:r}}(t);return b(null!=n,"not-number",`Value must be a number or between amount: ${JSON.stringify(t)} (field: ${r})`),"isbetween"===e?b("between"===n.type,"number-format",`Invalid between value for "${e}" (field: ${r})`):b("literal"===n.type,"number-format",`Invalid number value for "${e}" (field: ${r})`),n}},boolean:{ops:["is"],nullable:!1,parse:(e,t,r)=>(b("boolean"==typeof t,"not-boolean",`Value must be a boolean: ${t} (field: ${r})`),t)}};class w{constructor(e,t,r,n,i){let o=i.get(t);b(o,"internal","Invalid condition field: "+t);let a=_[o];b(a,"internal",`Invalid condition type: ${o} (field: ${t})`),b(a.ops.includes(e),"internal",`Invalid condition operator: ${e} (type: ${o}, field: ${t})`),!0!==a.nullable&&b(null!=r,"no-null","Field cannot be empty: "+t),"string"===o&&!0!==a.nullable&&b(""!==r,"no-null","Field cannot be empty: "+t),this.rawValue=r,this.unparsedValue=r,this.op=e,this.field=t,this.value=a.parse?a.parse(e,r,t):r,this.options=n,this.type=o}eval(e){let t=e[this.field];if(void 0===t)return!1;"string"==typeof t&&(t=t.toLowerCase());let r=this.type;if("number"===r&&this.options)if(this.options.outflow){if(t>0)return!1;t=-t}else if(this.options.inflow&&t<0)return!1;let n=e=>"number"===r?e.value:e;switch(this.op){case"isapprox":case"is":if("date"===r){if(null==t)return!1;if("recur"===this.value.type){let e=this.value.schedule;if("isapprox"===this.op){let r=Object(u.l)(t);return e.occursBetween(a.a(r,2),s.a(r,2))}return e.occursOn({date:Object(u.l)(t)})}{let e=this.value.date;if("isapprox"===this.op){let r=Object(u.l)(e),n=Object(u.a)(r,2);return t>=Object(u.q)(r,2)&&t<=n}switch(this.value.type){case"date":return t===e;case"month":return Object(u.k)(t)===e;case"year":return Object(u.s)(t)===e}}}else if("number"===r){let e=this.value.value;if("isapprox"===this.op){let r=Object(l.b)(e);return t>=e-r&&t<=e+r}return t===e}return t===this.value;case"isbetween":{let e=m(Object(l.c)(this.value.num1,this.value.num2),2),r=e[0],n=e[1];return t>=r&&t<=n}case"contains":return null!==t&&-1!==t.indexOf(this.value);case"oneOf":return null!==t&&-1!==this.value.indexOf(t);case"gt":return null!==t&&("date"===r?Object(u.i)(t,this.value.date):t>n(this.value));case"gte":return null!==t&&("date"===r?t===this.value.date||Object(u.i)(t,this.value.date):t>=n(this.value));case"lt":return null!==t&&("date"===r?Object(u.j)(t,this.value.date):tnew w(e.op,e.field,e.value,e.options,i)),this.actions=n.map(e=>new E(e.op,e.field,e.value,e.options,i))}evalConditions(e){return 0!==this.conditions.length&&this.conditions.every(t=>t.eval(e))}execActions(e){let t={};return this.actions.forEach(e=>e.exec(t)),t}exec(e){return this.evalConditions(e)?this.execActions(e):null}apply(e){let t=this.exec(e);return Object.assign({},e,t)}getId(){return this.id}serialize(){return{id:this.id,stage:this.stage,conditions:this.conditions.map(e=>e.serialize()),actions:this.actions.map(e=>e.serialize())}}}class O{constructor({field:e,method:t}){this.field=e,this.method=t,this.rules=new Map}getIndex(e){return this.rules.has(e)||this.rules.set(e,new Set),this.rules.get(e)}getIndexForValue(e){return this.getIndex(this.getKey(e)||"*")}getKey(e){return"string"==typeof e&&""!==e?"firstchar"===this.method?e[0].toLowerCase():e.toLowerCase():null}getIndexes(e){let t=e.conditions.find(e=>e.field===this.field),r=[];return!t||"oneOf"!==t.op&&"is"!==t.op?r.push(this.getIndex("*")):"oneOf"===t.op?t.value.forEach(e=>r.push(this.getIndexForValue(e))):r.push(this.getIndexForValue(t.value)),r}index(e){this.getIndexes(e).forEach(t=>{t.add(e)})}remove(e){this.getIndexes(e).forEach(t=>{t.delete(e)})}getApplicableRules(e){let t;if(this.field in e){let r=this.getKey(e[this.field]);r&&(t=this.rules.get(r))}return Object(c.e)(t||new Set,this.rules.get("*")||new Set)}}const T={is:10,oneOf:9,isapprox:5,isbetween:5,gt:1,gte:1,lt:1,lte:1,contains:0};function A(e){let t=new Map;return e.forEach(e=>{t.set(e,function(e){let t=e.conditions.reduce((e,t)=>null==T[t.op]?(console.log("Found invalid operation while ranking: "+t.op),0):e+T[t.op],0);return e.conditions.every(e=>"is"===e.op||"isapprox"===e.op||"oneOf"===e.op)?2*t:t}(e))}),[...e].sort((e,r)=>{let n=t.get(e),i=t.get(r);if(ni)return 1;{let t=e.getId(),n=r.getId();return tn?1:0}})}function M(e){let t=[],r=[],n=[];for(let i of e)switch(i.stage){case"pre":t.push(i);break;case"post":n.push(i);break;default:r.push(i)}return t=A(t),r=A(r),n=A(n),t.concat(r).concat(n)}function D(e,t){for(let r=0;rt.get(e)||e),n.unparsedValue=[...n.value]}}for(let r=0;re.text())}}.call(this,r(10).Buffer)},function(e,t,r){"use strict";var n=r(76);let i=r(410),o={};class a{constructor({id:e,value:t}){this.id=e||i.v4Sync()}async createFromPassword({password:e,salt:t}){this.value=await n.a({secret:e,salt:t})}async createFromBase64(e){this.value=await n.d(e)}getId(){return this.id}getValue(){return this.value}serialize(){return{id:this.id,base64:this.value.base64}}}function s(e){if(null==e||null==o[e])throw new Error("missing-key");return o[e]}t.a={decrypt:function(e,t){return n.b(s(t.keyId),e,t)},encrypt:function(e,t){return n.c(s(t),e)},randomBytes:function(e){return n.e(e)},createKey:async function({id:e,password:t,salt:r}){let n=new a({id:e});return await n.createFromPassword({password:t,salt:r}),n},loadKey:async function(e){let t;e instanceof a?t=e:(t=new a({id:e.id}),await t.createFromBase64(e.base64)),o[t.getId()]=t},getKey:s,hasKey:function(e){return e in o},unloadKey:function(e){delete o[e.getId()]},unloadAllKeys:function(){o={}}}},function(e,t,r){"use strict";r.d(t,"c",(function(){return p})),r.d(t,"i",(function(){return g})),r.d(t,"j",(function(){return m})),r.d(t,"a",(function(){return b})),r.d(t,"l",(function(){return _})),r.d(t,"g",(function(){return w})),r.d(t,"h",(function(){return v})),r.d(t,"e",(function(){return E})),r.d(t,"d",(function(){return S})),r.d(t,"f",(function(){return O})),r.d(t,"b",(function(){return T})),r.d(t,"m",(function(){return A})),r.d(t,"n",(function(){return M})),r.d(t,"k",(function(){return D}));var n=r(2),i=r(1),o=r(7),a=(r(12),r(8)),s=r(5);async function u(e,t){const r=await s.c(e,t);return"number"==typeof r.value?r.value:0}function c(){return"report"===(a.b()||{}).budgetType?"reflect_budgets":"zero_budgets"}function l(){return"report"===a.b().budgetType}function f(e){return parseInt(e.replace("-",""))}function d(e,t){return i.all(`\n SELECT b.*, c.is_income FROM v_categories c\n LEFT JOIN ${e} b ON b.category = c.id\n WHERE c.tombstone = 0 AND b.month = ?\n `,[t])}function h(e){let t=s.b().meta().createdMonths,r=null;for(let e of t)(null==r||e>r)&&(r=e);return n.o(e,r)}function p({category:e,month:t}){let r=c(),n=i.firstSync(`SELECT * FROM ${r} WHERE month = ? AND category = ?`,[f(t),e]);return n&&n.amount||0}function g({category:e,month:t,amount:r}){"number"!=typeof r&&(r=0);const n=c();let o=i.firstSync(`SELECT id FROM ${n} WHERE month = ? AND category = ?`,[f(t),e]);return o?i.update(n,{id:o.id,amount:r}):i.insert(n,{id:`${f(t)}-${e}`,month:f(t),category:e,amount:r})}function m(e,t){let r=i.firstSync("SELECT id FROM zero_budget_months WHERE id = ?",[e]);return r?i.update("zero_budget_months",{id:r.id,buffered:t}):i.insert("zero_budget_months",{id:e,buffered:t})}function y(e,t,r,n){let o=i.firstSync(`SELECT id FROM ${e} WHERE month = ? AND category = ?`,[r,t]);return o?i.update(e,{id:o.id,carryover:n?1:0}):i.insert(e,{id:`${r}-${t}`,month:r,category:t,carryover:n?1:0})}async function b({month:e}){let t=f(n.m(e)),r=c(),i=await d(r,t);await Object(o.c)(()=>{i.forEach(t=>{(1!==t.is_income||l())&&g({category:t.category,month:e,amount:t.amount})})})}async function _({month:e}){let t=await i.all("SELECT * FROM v_categories WHERE tombstone = 0");await Object(o.c)(()=>{t.forEach(t=>{(1!==t.is_income||l())&&g({category:t.id,month:e,amount:0})})})}async function w({month:e}){let t=await i.all("SELECT * FROM v_categories WHERE tombstone = 0"),r=n.m(e),a=n.m(r),s=n.m(a);await Object(o.c)(async()=>{for(let i of t){if(1===i.is_income&&!l())continue;const t=(await u(n.p(r),"sum-amount-"+i.id)+await u(n.p(a),"sum-amount-"+i.id)+await u(n.p(s),"sum-amount-"+i.id))/3|0;g({category:i.id,month:e,amount:-t})}})}async function v({startMonth:e}){if(!l())throw new Error("setAllFuture only applies to report budget type");let t=c(),r=await d(t,f(e)),i=h(n.b(e,1));Object(o.c)(()=>{for(let e of i)r.forEach(t=>{(1!==t.is_income||l())&&g({category:t.category,month:e,amount:t.amount})})})}async function E({month:e,amount:t}){let r=await i.first("SELECT buffered FROM zero_budget_months WHERE id = ?",[e]),o=n.p(e),a=await u(o,"to-budget");if(a>0){let n=function(e,t,r){return t+(r=Math.min(Math.max(r,-t),Math.max(e,0)))}(a,r&&r.buffered||0,t);return await m(e,n),!0}return!1}async function S({startMonth:e,amount:t}){let r=h(e);await Object(o.c)(async()=>{for(let e of r)if(!await E({month:e,amount:t}))break})}async function O({month:e}){await m(e,0)}async function T({month:e,to:t,from:r}){let i=n.p(e),o=await u(i,"budget-"+t),a=await u(i,"leftover-"+t),s=await u(i,"to-be-budgeted"===r?"to-budget":"leftover-"+r);if(a>=0||s<=0)return;let c=Math.min(-a,s);if("to-be-budgeted"!==r){const t=await u(i,"budget-"+r);await g({category:r,month:e,amount:t-c})}await g({category:t,month:e,amount:o+c})}async function A({month:e,amount:t,category:r}){let i=n.p(e),o=await u(i,"to-budget");t=Math.max(Math.min(t,o),0);let a=await u(i,"budget-"+r);await g({category:r,month:e,amount:a+t})}async function M({month:e,amount:t,from:r,to:i}){const o=n.p(e),a=await u(o,"budget-"+r);if(await g({category:r,month:e,amount:a-t}),"to-be-budgeted"!==i){const r=await u(o,"budget-"+i);await g({category:i,month:e,amount:r+t})}}async function D({startMonth:e,category:t,flag:r}){let n=c(),i=h(e);await Object(o.c)(()=>{for(let e of i)y(n,t,f(e),r)})}},function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;tDate.now()}),cleared:a("boolean",{default:!0}),tombstone:a("boolean"),schedule:a("id",{ref:"schedules"})},payees:{id:a("id"),name:a("string",{required:!0}),transfer_acct:a("id",{ref:"accounts"}),tombstone:a("boolean")},accounts:{id:a("id"),name:a("string",{required:!0}),type:a("string"),offbudget:a("boolean"),closed:a("boolean"),sort_order:a("float"),tombstone:a("boolean")},categories:{id:a("id"),name:a("string"),is_income:a("boolean"),group:a("id",{ref:"category_groups"}),sort_order:a("float"),tombstone:a("boolean")},category_groups:{id:a("id"),name:a("string"),is_income:a("boolean"),sort_order:a("float"),tombstone:a("boolean")},schedules:{id:a("id"),rule:a("id",{ref:"rules",required:!0}),next_date:a("date"),completed:a("boolean"),posts_transaction:a("boolean"),tombstone:a("boolean"),_payee:a("id",{ref:"payees"}),_account:a("id",{ref:"accounts"}),_amount:a("json/fallback"),_amountOp:a("string"),_date:a("json/fallback"),_conditions:a("json"),_actions:a("json")},rules:{id:a("id"),stage:a("string"),conditions:a("json"),actions:a("json"),tombstone:a("boolean")},notes:{id:a("id"),note:a("string")}},u={tableViews(e,{isJoin:t,withDead:r,tableOptions:n={}}){switch(e){case"transactions":{if(t)return"v_transactions_internal_alive";let e=n.splits||"inline";return r||"inline"!==e&&"none"!==e?"v_transactions_internal":"v_transactions_internal_alive"}case"schedules":return"v_schedules";case"categories":return"v_categories";case"payees":return"v_payees"}return e},customizeQuery(e){let t=e.table;e.tableOptions;return i(i({},e),{},{orderExpressions:function(e){if(e.length>0)return e.concat(["id"]);switch(t){case"transactions":return[{date:"desc"},"starting_balance_flag",{sort_order:"desc"},"id"];case"payees":return[{$condition:{transfer_acct:null},$dir:"desc"},{$nocase:"$name"}];case"accounts":return["sort_order","name"];case"schedules":return[{$condition:{completed:!0}},"next_date"]}return[]}(e.orderExpressions)})},views:{payees:{v_payees:e=>`\n SELECT ${e({name:"COALESCE(__accounts.name, _.name)"})} FROM payees _\n LEFT JOIN accounts __accounts ON (_.transfer_acct = __accounts.id AND __accounts.tombstone = 0)\n -- We never want to show transfer payees that are pointing to deleted accounts.\n -- Either this isn't a transfer payee, if the account exists\n WHERE _.transfer_acct IS NULL OR __accounts.id IS NOT NULL\n `},categories:{fields:{group:"cat_group"},v_categories:e=>`SELECT ${e({group:"cat_group"})} FROM categories _`},schedules:{v_schedules:e=>`\n SELECT ${e({next_date:"\n CASE\n WHEN _nd.local_next_date_ts = _nd.base_next_date_ts THEN _nd.local_next_date\n ELSE _nd.base_next_date\n END\n ",_payee:"pm.targetId",_account:"json_extract(_rules.conditions, _paths.account || '.value')",_amount:"json_extract(_rules.conditions, _paths.amount || '.value')",_amountOp:"json_extract(_rules.conditions, _paths.amount || '.op')",_date:"json_extract(_rules.conditions, _paths.date || '.value')",_conditions:"_rules.conditions",_actions:"_rules.actions"})} FROM schedules _\n LEFT JOIN schedules_next_date _nd ON _nd.schedule_id = _.id\n LEFT JOIN schedules_json_paths _paths ON _paths.schedule_id = _.id\n LEFT JOIN rules _rules ON _rules.id = _.rule\n LEFT JOIN payee_mapping pm ON pm.id = json_extract(_rules.conditions, _paths.payee || '.value')\n `},transactions:{fields:{is_parent:"isParent",is_child:"isChild",account:"acct",imported_id:"financial_id",imported_payee:"imported_description",transfer_id:"transferred_id",payee:"description"},v_transactions_internal:e=>`\n SELECT ${e({payee:"pm.targetId",category:"CASE WHEN _.isParent = 1 THEN NULL ELSE cm.transferId END",amount:"IFNULL(_.amount, 0)",parent_id:"CASE WHEN _.isChild = 0 THEN NULL ELSE _.parent_id END"})} FROM transactions _\n LEFT JOIN category_mapping cm ON cm.id = _.category\n LEFT JOIN payee_mapping pm ON pm.id = _.description\n WHERE\n _.date IS NOT NULL AND\n _.acct IS NOT NULL AND\n (_.isChild = 0 OR _.parent_id IS NOT NULL)\n `,v_transactions_internal_alive:"\n SELECT _.* FROM v_transactions_internal _\n LEFT JOIN transactions t2 ON (_.is_child = 1 AND t2.id = _.parent_id)\n WHERE IFNULL(_.tombstone, 0) = 0 AND (_.is_child = 0 OR t2.tombstone = 0)\n ",v_transactions:(e,t)=>`\n SELECT ${t({payee:"p.id",category:"c.id",account:"a.id"})} FROM v_transactions_internal_alive _\n LEFT JOIN payees p ON (p.id = _.payee AND p.tombstone = 0)\n LEFT JOIN categories c ON (c.id = _.category AND c.tombstone = 0)\n LEFT JOIN accounts a ON (a.id = _.account AND a.tombstone = 0)\n ORDER BY _.date desc, _.starting_balance_flag, _.sort_order desc, _.id;\n `}}}},function(e,t,r){"use strict";r.d(t,"a",(function(){return k}));var n=r(3),i=r(27),o=r(0),a=r(66),s=r(59),u=r(62);var c=r(137),l=r(131),f=r(136),d=r(92),h=r(22),p="midnight",g="noon",m="morning",y="afternoon",b="evening",_="night";function w(e,t){var r=e>0?"-":"+",n=Math.abs(e),i=Math.floor(n/60),o=n%60;if(0===o)return r+String(i);var a=t||"";return r+String(i)+a+Object(h.a)(o,2)}function v(e,t){return e%60==0?(e>0?"-":"+")+Object(h.a)(Math.abs(e)/60,2):E(e,t)}function E(e,t){var r=t||"",n=e>0?"-":"+",i=Math.abs(e);return n+Object(h.a)(Math.floor(i/60),2)+r+Object(h.a)(i%60,2)}var S={G:function(e,t,r){var n=e.getUTCFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(e,t,r){if("yo"===t){var n=e.getUTCFullYear(),i=n>0?n:1-n;return r.ordinalNumber(i,{unit:"year"})}return u.a.y(e,t)},Y:function(e,t,r,n){var i=Object(d.a)(e,n),o=i>0?i:1-i;if("YY"===t){var a=o%100;return Object(h.a)(a,2)}return"Yo"===t?r.ordinalNumber(o,{unit:"year"}):Object(h.a)(o,t.length)},R:function(e,t){var r=Object(l.a)(e);return Object(h.a)(r,t.length)},u:function(e,t){var r=e.getUTCFullYear();return Object(h.a)(r,t.length)},Q:function(e,t,r){var n=Math.ceil((e.getUTCMonth()+1)/3);switch(t){case"Q":return String(n);case"QQ":return Object(h.a)(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,t,r){var n=Math.ceil((e.getUTCMonth()+1)/3);switch(t){case"q":return String(n);case"qq":return Object(h.a)(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,t,r){var n=e.getUTCMonth();switch(t){case"M":case"MM":return u.a.M(e,t);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(e,t,r){var n=e.getUTCMonth();switch(t){case"L":return String(n+1);case"LL":return Object(h.a)(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(e,t,r,n){var i=Object(f.a)(e,n);return"wo"===t?r.ordinalNumber(i,{unit:"week"}):Object(h.a)(i,t.length)},I:function(e,t,r){var n=Object(c.a)(e);return"Io"===t?r.ordinalNumber(n,{unit:"week"}):Object(h.a)(n,t.length)},d:function(e,t,r){return"do"===t?r.ordinalNumber(e.getUTCDate(),{unit:"date"}):u.a.d(e,t)},D:function(e,t,r){var n=function(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(o.a)(e),r=t.getTime();t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0);var n=t.getTime(),i=r-n;return Math.floor(i/864e5)+1}(e);return"Do"===t?r.ordinalNumber(n,{unit:"dayOfYear"}):Object(h.a)(n,t.length)},E:function(e,t,r){var n=e.getUTCDay();switch(t){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(e,t,r,n){var i=e.getUTCDay(),o=(i-n.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return Object(h.a)(o,2);case"eo":return r.ordinalNumber(o,{unit:"day"});case"eee":return r.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(i,{width:"short",context:"formatting"});case"eeee":default:return r.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,r,n){var i=e.getUTCDay(),o=(i-n.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return Object(h.a)(o,t.length);case"co":return r.ordinalNumber(o,{unit:"day"});case"ccc":return r.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(i,{width:"narrow",context:"standalone"});case"cccccc":return r.day(i,{width:"short",context:"standalone"});case"cccc":default:return r.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,r){var n=e.getUTCDay(),i=0===n?7:n;switch(t){case"i":return String(i);case"ii":return Object(h.a)(i,t.length);case"io":return r.ordinalNumber(i,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(e,t,r){var n=e.getUTCHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":case"aaa":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"aaaaa":return r.dayPeriod(n,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(n,{width:"wide",context:"formatting"})}},b:function(e,t,r){var n,i=e.getUTCHours();switch(n=12===i?g:0===i?p:i/12>=1?"pm":"am",t){case"b":case"bb":case"bbb":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"bbbbb":return r.dayPeriod(n,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(n,{width:"wide",context:"formatting"})}},B:function(e,t,r){var n,i=e.getUTCHours();switch(n=i>=17?b:i>=12?y:i>=4?m:_,t){case"B":case"BB":case"BBB":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(n,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(n,{width:"wide",context:"formatting"})}},h:function(e,t,r){if("ho"===t){var n=e.getUTCHours()%12;return 0===n&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return u.a.h(e,t)},H:function(e,t,r){return"Ho"===t?r.ordinalNumber(e.getUTCHours(),{unit:"hour"}):u.a.H(e,t)},K:function(e,t,r){var n=e.getUTCHours()%12;return"Ko"===t?r.ordinalNumber(n,{unit:"hour"}):Object(h.a)(n,t.length)},k:function(e,t,r){var n=e.getUTCHours();return 0===n&&(n=24),"ko"===t?r.ordinalNumber(n,{unit:"hour"}):Object(h.a)(n,t.length)},m:function(e,t,r){return"mo"===t?r.ordinalNumber(e.getUTCMinutes(),{unit:"minute"}):u.a.m(e,t)},s:function(e,t,r){return"so"===t?r.ordinalNumber(e.getUTCSeconds(),{unit:"second"}):u.a.s(e,t)},S:function(e,t){var r=t.length,n=e.getUTCMilliseconds(),i=Math.floor(n*Math.pow(10,r-3));return Object(h.a)(i,r)},X:function(e,t,r,n){var i=(n._originalDate||e).getTimezoneOffset();if(0===i)return"Z";switch(t){case"X":return v(i);case"XXXX":case"XX":return E(i);case"XXXXX":case"XXX":default:return E(i,":")}},x:function(e,t,r,n){var i=(n._originalDate||e).getTimezoneOffset();switch(t){case"x":return v(i);case"xxxx":case"xx":return E(i);case"xxxxx":case"xxx":default:return E(i,":")}},O:function(e,t,r,n){var i=(n._originalDate||e).getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+w(i,":");case"OOOO":default:return"GMT"+E(i,":")}},z:function(e,t,r,n){var i=(n._originalDate||e).getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+w(i,":");case"zzzz":default:return"GMT"+E(i,":")}},t:function(e,t,r,n){var i=n._originalDate||e,o=Math.floor(i.getTime()/1e3);return Object(h.a)(o,t.length)},T:function(e,t,r,n){var i=(n._originalDate||e).getTime();return Object(h.a)(i,t.length)}};function O(e,t){switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}}function T(e,t){switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}}var A={p:T,P:function(e,t){var r,n=e.match(/(P+)(p+)?/),i=n[1],o=n[2];if(!o)return O(e,t);switch(i){case"P":r=t.dateTime({width:"short"});break;case"PP":r=t.dateTime({width:"medium"});break;case"PPP":r=t.dateTime({width:"long"});break;case"PPPP":default:r=t.dateTime({width:"full"})}return r.replace("{{date}}",O(i,t)).replace("{{time}}",T(o,t))}},M=r(50),D=r(94),I=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,j=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,R=/^'(.*?)'?$/,N=/''/g;function k(e,t,r){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var u=String(t),c=r||{},l=c.locale||s.a,f=l.options&&l.options.firstWeekContainsDate,d=null==f?1:Object(n.a)(f),h=null==c.firstWeekContainsDate?d:Object(n.a)(c.firstWeekContainsDate);if(!(h>=1&&h<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=l.options&&l.options.weekStartsOn,g=null==p?0:Object(n.a)(p),m=null==c.weekStartsOn?g:Object(n.a)(c.weekStartsOn);if(!(m>=0&&m<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!l.localize)throw new RangeError("locale must contain localize property");if(!l.formatLong)throw new RangeError("locale must contain formatLong property");var y=Object(o.a)(e);if(!Object(a.a)(y))throw new RangeError("Invalid time value");var b=Object(i.a)(y),_=Object(M.a)(y,b),w={firstWeekContainsDate:h,weekStartsOn:m,locale:l,_originalDate:y},v=u.match(j).map((function(e){var t=e[0];return"p"===t||"P"===t?(0,A[t])(e,l.formatLong,w):e})).join("").match(I).map((function(e){if("''"===e)return"'";var t=e[0];if("'"===t)return C(e);var r=S[t];return r?(!c.awareOfUnicodeTokens&&Object(D.a)(e)&&Object(D.b)(e),r(_,e,l.localize,w)):e})).join("");return v}function C(e){return e.match(R)[1].replace(N,"'")}},function(e,t,r){(function(e){!function(e,t){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"==typeof e?e.exports=o:t.BN=o,o.BN=o,o.wordSize=26;try{a="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(347).Buffer}catch(e){}function s(e,t){var r=e.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function u(e,t,r){var n=s(e,r);return r-1>=t&&(n|=s(e,r-1)<<4),n}function c(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n=t;n-=2)i=u(e,t,n)<=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(n=(e.length-t)%2==0?t+1:t;n=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,f=67108863&u,d=Math.min(c,t.length-1),h=Math.max(0,c-e.length+1);h<=d;h++){var p=c-h|0;l+=(a=(i=0|e.words[p])*(o=0|t.words[h])+f)/67108864|0,f=67108863&a}r.words[c]=0|f,u=0|l}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?l[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var c=f[e],h=d[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modn(h).toString(e);r=(p=p.idivn(h)).isZero()?g+r:l[c-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,c=new e(o),l=this.clone();if(u){for(s=0;!l.isZero();s++)a=l.andln(255),l.iushrn(8),c[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,h=0|a[1],p=8191&h,g=h>>>13,m=0|a[2],y=8191&m,b=m>>>13,_=0|a[3],w=8191&_,v=_>>>13,E=0|a[4],S=8191&E,O=E>>>13,T=0|a[5],A=8191&T,M=T>>>13,D=0|a[6],I=8191&D,j=D>>>13,R=0|a[7],N=8191&R,k=R>>>13,C=0|a[8],L=8191&C,x=C>>>13,P=0|a[9],B=8191&P,U=P>>>13,F=0|s[0],W=8191&F,H=F>>>13,z=0|s[1],q=8191&z,V=z>>>13,G=0|s[2],Y=8191&G,$=G>>>13,K=0|s[3],Z=8191&K,X=K>>>13,J=0|s[4],Q=8191&J,ee=J>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,le=0|s[8],fe=8191&le,de=le>>>13,he=0|s[9],pe=8191&he,ge=he>>>13;r.negative=e.negative^t.negative,r.length=19;var me=(c+(n=Math.imul(f,W))|0)+((8191&(i=(i=Math.imul(f,H))+Math.imul(d,W)|0))<<13)|0;c=((o=Math.imul(d,H))+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(p,W),i=(i=Math.imul(p,H))+Math.imul(g,W)|0,o=Math.imul(g,H);var ye=(c+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,V)|0)+Math.imul(d,q)|0))<<13)|0;c=((o=o+Math.imul(d,V)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,W),i=(i=Math.imul(y,H))+Math.imul(b,W)|0,o=Math.imul(b,H),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(g,q)|0,o=o+Math.imul(g,V)|0;var be=(c+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(d,Y)|0))<<13)|0;c=((o=o+Math.imul(d,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(w,W),i=(i=Math.imul(w,H))+Math.imul(v,W)|0,o=Math.imul(v,H),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,V)|0)+Math.imul(b,q)|0,o=o+Math.imul(b,V)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,$)|0;var _e=(c+(n=n+Math.imul(f,Z)|0)|0)+((8191&(i=(i=i+Math.imul(f,X)|0)+Math.imul(d,Z)|0))<<13)|0;c=((o=o+Math.imul(d,X)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(S,W),i=(i=Math.imul(S,H))+Math.imul(O,W)|0,o=Math.imul(O,H),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(b,Y)|0,o=o+Math.imul(b,$)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,X)|0;var we=(c+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,ee)|0)+Math.imul(d,Q)|0))<<13)|0;c=((o=o+Math.imul(d,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(A,W),i=(i=Math.imul(A,H))+Math.imul(M,W)|0,o=Math.imul(M,H),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(O,q)|0,o=o+Math.imul(O,V)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,$)|0,n=n+Math.imul(y,Z)|0,i=(i=i+Math.imul(y,X)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,X)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,ee)|0;var ve=(c+(n=n+Math.imul(f,re)|0)|0)+((8191&(i=(i=i+Math.imul(f,ne)|0)+Math.imul(d,re)|0))<<13)|0;c=((o=o+Math.imul(d,ne)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(I,W),i=(i=Math.imul(I,H))+Math.imul(j,W)|0,o=Math.imul(j,H),n=n+Math.imul(A,q)|0,i=(i=i+Math.imul(A,V)|0)+Math.imul(M,q)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(S,Y)|0,i=(i=i+Math.imul(S,$)|0)+Math.imul(O,Y)|0,o=o+Math.imul(O,$)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,X)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ne)|0;var Ee=(c+(n=n+Math.imul(f,oe)|0)|0)+((8191&(i=(i=i+Math.imul(f,ae)|0)+Math.imul(d,oe)|0))<<13)|0;c=((o=o+Math.imul(d,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,W),i=(i=Math.imul(N,H))+Math.imul(k,W)|0,o=Math.imul(k,H),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,V)|0)+Math.imul(j,q)|0,o=o+Math.imul(j,V)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(M,Y)|0,o=o+Math.imul(M,$)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,X)|0)+Math.imul(O,Z)|0,o=o+Math.imul(O,X)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,ae)|0;var Se=(c+(n=n+Math.imul(f,ue)|0)|0)+((8191&(i=(i=i+Math.imul(f,ce)|0)+Math.imul(d,ue)|0))<<13)|0;c=((o=o+Math.imul(d,ce)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(L,W),i=(i=Math.imul(L,H))+Math.imul(x,W)|0,o=Math.imul(x,H),n=n+Math.imul(N,q)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,V)|0,n=n+Math.imul(I,Y)|0,i=(i=i+Math.imul(I,$)|0)+Math.imul(j,Y)|0,o=o+Math.imul(j,$)|0,n=n+Math.imul(A,Z)|0,i=(i=i+Math.imul(A,X)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(O,Q)|0,o=o+Math.imul(O,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(g,ue)|0,o=o+Math.imul(g,ce)|0;var Oe=(c+(n=n+Math.imul(f,fe)|0)|0)+((8191&(i=(i=i+Math.imul(f,de)|0)+Math.imul(d,fe)|0))<<13)|0;c=((o=o+Math.imul(d,de)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(B,W),i=(i=Math.imul(B,H))+Math.imul(U,W)|0,o=Math.imul(U,H),n=n+Math.imul(L,q)|0,i=(i=i+Math.imul(L,V)|0)+Math.imul(x,q)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(N,Y)|0,i=(i=i+Math.imul(N,$)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,$)|0,n=n+Math.imul(I,Z)|0,i=(i=i+Math.imul(I,X)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,X)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(O,re)|0,o=o+Math.imul(O,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(y,ue)|0,i=(i=i+Math.imul(y,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0,n=n+Math.imul(p,fe)|0,i=(i=i+Math.imul(p,de)|0)+Math.imul(g,fe)|0,o=o+Math.imul(g,de)|0;var Te=(c+(n=n+Math.imul(f,pe)|0)|0)+((8191&(i=(i=i+Math.imul(f,ge)|0)+Math.imul(d,pe)|0))<<13)|0;c=((o=o+Math.imul(d,ge)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,V))+Math.imul(U,q)|0,o=Math.imul(U,V),n=n+Math.imul(L,Y)|0,i=(i=i+Math.imul(L,$)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,$)|0,n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,X)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,ee)|0)+Math.imul(j,Q)|0,o=o+Math.imul(j,ee)|0,n=n+Math.imul(A,re)|0,i=(i=i+Math.imul(A,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(O,oe)|0,o=o+Math.imul(O,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(y,fe)|0,i=(i=i+Math.imul(y,de)|0)+Math.imul(b,fe)|0,o=o+Math.imul(b,de)|0;var Ae=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ge)|0)+Math.imul(g,pe)|0))<<13)|0;c=((o=o+Math.imul(g,ge)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,Y),i=(i=Math.imul(B,$))+Math.imul(U,Y)|0,o=Math.imul(U,$),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,X)|0,n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(I,re)|0,i=(i=i+Math.imul(I,ne)|0)+Math.imul(j,re)|0,o=o+Math.imul(j,ne)|0,n=n+Math.imul(A,oe)|0,i=(i=i+Math.imul(A,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(O,ue)|0,o=o+Math.imul(O,ce)|0,n=n+Math.imul(w,fe)|0,i=(i=i+Math.imul(w,de)|0)+Math.imul(v,fe)|0,o=o+Math.imul(v,de)|0;var Me=(c+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,ge)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,ge)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(B,Z),i=(i=Math.imul(B,X))+Math.imul(U,Z)|0,o=Math.imul(U,X),n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(I,oe)|0,i=(i=i+Math.imul(I,ae)|0)+Math.imul(j,oe)|0,o=o+Math.imul(j,ae)|0,n=n+Math.imul(A,ue)|0,i=(i=i+Math.imul(A,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(S,fe)|0,i=(i=i+Math.imul(S,de)|0)+Math.imul(O,fe)|0,o=o+Math.imul(O,de)|0;var De=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ge)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,ge)|0)+(i>>>13)|0)+(De>>>26)|0,De&=67108863,n=Math.imul(B,Q),i=(i=Math.imul(B,ee))+Math.imul(U,Q)|0,o=Math.imul(U,ee),n=n+Math.imul(L,re)|0,i=(i=i+Math.imul(L,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,n=n+Math.imul(I,ue)|0,i=(i=i+Math.imul(I,ce)|0)+Math.imul(j,ue)|0,o=o+Math.imul(j,ce)|0,n=n+Math.imul(A,fe)|0,i=(i=i+Math.imul(A,de)|0)+Math.imul(M,fe)|0,o=o+Math.imul(M,de)|0;var Ie=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ge)|0)+Math.imul(O,pe)|0))<<13)|0;c=((o=o+Math.imul(O,ge)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(B,re),i=(i=Math.imul(B,ne))+Math.imul(U,re)|0,o=Math.imul(U,ne),n=n+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,ce)|0,n=n+Math.imul(I,fe)|0,i=(i=i+Math.imul(I,de)|0)+Math.imul(j,fe)|0,o=o+Math.imul(j,de)|0;var je=(c+(n=n+Math.imul(A,pe)|0)|0)+((8191&(i=(i=i+Math.imul(A,ge)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,ge)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(B,oe),i=(i=Math.imul(B,ae))+Math.imul(U,oe)|0,o=Math.imul(U,ae),n=n+Math.imul(L,ue)|0,i=(i=i+Math.imul(L,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(N,fe)|0,i=(i=i+Math.imul(N,de)|0)+Math.imul(k,fe)|0,o=o+Math.imul(k,de)|0;var Re=(c+(n=n+Math.imul(I,pe)|0)|0)+((8191&(i=(i=i+Math.imul(I,ge)|0)+Math.imul(j,pe)|0))<<13)|0;c=((o=o+Math.imul(j,ge)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(B,ue),i=(i=Math.imul(B,ce))+Math.imul(U,ue)|0,o=Math.imul(U,ce),n=n+Math.imul(L,fe)|0,i=(i=i+Math.imul(L,de)|0)+Math.imul(x,fe)|0,o=o+Math.imul(x,de)|0;var Ne=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,ge)|0)+Math.imul(k,pe)|0))<<13)|0;c=((o=o+Math.imul(k,ge)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(B,fe),i=(i=Math.imul(B,de))+Math.imul(U,fe)|0,o=Math.imul(U,de);var ke=(c+(n=n+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,ge)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,ge)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863;var Ce=(c+(n=Math.imul(B,pe))|0)+((8191&(i=(i=Math.imul(B,ge))+Math.imul(U,pe)|0))<<13)|0;return c=((o=Math.imul(U,ge))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=me,u[1]=ye,u[2]=be,u[3]=_e,u[4]=we,u[5]=ve,u[6]=Ee,u[7]=Se,u[8]=Oe,u[9]=Te,u[10]=Ae,u[11]=Me,u[12]=De,u[13]=Ie,u[14]=je,u[15]=Re,u[16]=Ne,u[17]=ke,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function g(e,t,r){return(new m).mulp(e,t,r)}function m(e,t){this.x=e,this.y=t}Math.imul||(p=h),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?p(this,e,t):r<63?h(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):g(this,e,t)},m.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},m.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==l||c>=i);c--){var f=0|this.words[c];this.words[c]=l<<26-o|f>>>o,l=f&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;f--){var d=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(d=Math.min(d/a|0,67108863),n._ishlnsubmul(i,d,f);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);s&&(s.words[f]=d)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var l=r.clone(),f=t.clone();!t.isZero();){for(var d=0,h=1;0==(t.words[0]&h)&&d<26;++d,h<<=1);if(d>0)for(t.iushrn(d);d-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(l),a.isub(f)),i.iushrn(1),a.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(f)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,l=1;0==(t.words[0]&l)&&c<26;++c,l<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var f=0,d=1;0==(r.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(r.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new S(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function b(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function v(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function O(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},b.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(e,t){e.iushrn(this.n,0,t)},b.prototype.imulK=function(e){return e.imul(this.k)},i(_,b),_.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},_.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new _;else if("p224"===e)t=new w;else if("p192"===e)t=new v;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new E}return y[e]=t,t},S.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,c).cmp(u);)l.redIAdd(u);for(var f=this.pow(l,i),d=this.pow(e,i.addn(1).iushrn(1)),h=this.pow(e,i),p=a;0!==h.cmp(s);){for(var g=h,m=0;0!==g.cmp(s);m++)g=g.redSqr();n(m=0;n--){for(var c=t.words[n],l=u-1;l>=0;l--){var f=c>>l&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==a?(a<<=1,a|=f,(4===++s||0===n&&0===l)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new O(e)},i(O,S),O.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},O.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},O.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},O.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},O.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(97)(e))},function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(0);function i(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(n.a)(e),i=Object(n.a)(t),o=r.getTime()-i.getTime();return o<0?-1:o>0?1:o}},function(e,t,r){"use strict";(function(e){r.d(t,"a",(function(){return T})),r.d(t,"g",(function(){return A})),r.d(t,"c",(function(){return M})),r.d(t,"h",(function(){return D})),r.d(t,"e",(function(){return I})),r.d(t,"f",(function(){return j})),r.d(t,"d",(function(){return R})),r.d(t,"b",(function(){return N}));var n=r(4),i=r.n(n),o=r(9),a=r.n(o),s=r(130),u=r(2),c=r(15),l=r(8),f=r(20),d=r(6),h=r(18),p=r(31),g=r(30);function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return y(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return y(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r{throw new h.HTTPError(e.status,t)}):e}async function O(...e){let t=await Object(s.fetch)(...e);return t=await S(t),t.json()}async function T(){let e,t=await a.a.getItem("user-token"),r=l.b(),n=r.cloudFileId,i=r.encryptKeyId;try{e=await Object(g.post)(Object(f.a)().SYNC_SERVER+"/user-get-key",{token:t,fileId:n})}catch(e){return console.log(e),{error:{reason:"network"}}}return{valid:e.id==i&&(null==i||p.a.hasKey(i))}}async function A(e){let t=await a.a.getItem("user-token"),r=l.b().cloudFileId;try{await Object(g.post)(Object(f.a)().SYNC_SERVER+"/reset-user-file",{token:t,fileId:r})}catch(e){return e instanceof h.PostError?{error:{reason:"unauthorized"===e.reason?"unauthorized":"network"}}:{error:{reason:"internal"}}}if(e)try{await Object(g.post)(Object(f.a)().SYNC_SERVER+"/user-create-key",{token:t,fileId:r,keyId:e.key.getId(),keySalt:e.salt,testContent:e.testContent})}catch(e){return e instanceof h.PostError?{error:{reason:"network"}}:{error:{reason:"internal"}}}return{}}async function M(){let t=l.b(),r=t.id;if(!t.budgetName)return null;let n=i.a.getBudgetDir(r),o=new E;return await Object(d.runMutator)(async()=>{let t=await i.a.readFile(i.a.join(n,"db.sqlite"),"binary"),r=await c.openDatabase(t);c.execQuery(r,"\n DELETE FROM kvcache;\n DELETE FROM kvcache_key;\n ");let a=c.exportDatabase(r);c.closeDatabase(r);let s=JSON.parse(await i.a.readFile(i.a.join(n,"metadata.json")));s.resetClock=!0;let u=e.from(JSON.stringify(s),"utf8");o.addFile("db.sqlite",a),o.addFile("metadata.json",u)}),o.toBuffer()}async function D(){let e=await a.a.getItem("user-token");if(!e)throw Object(h.FileUploadError)("unauthorized");let t=await M();if(null==t)return;let r,n=l.b(),i=n.id,o=n.groupId,s=n.budgetName,c=n.cloudFileId,d=n.encryptKeyId,g=t,m=null;if(d){let e;try{e=await p.a.encrypt(t,d)}catch(e){throw Object(h.FileUploadError)("encrypt-failure",{isMissingKey:"missing-key"===e.message})}g=e.value,m=e.meta}c||(c=v.v4Sync());try{r=await O(Object(f.a)().SYNC_SERVER+"/upload-user-file",{method:"POST",headers:_(_({"Content-Length":g.length,"Content-Type":"application/encrypted-file","X-ACTUAL-TOKEN":e,"X-ACTUAL-FILE-ID":c,"X-ACTUAL-NAME":encodeURIComponent(s),"X-ACTUAL-FORMAT":2},m?{"X-ACTUAL-ENCRYPT-META":JSON.stringify(m)}:null),o?{"X-ACTUAL-GROUP-ID":o}:null),body:g})}catch(e){console.log("Upload failure",e);e instanceof h.PostError&&e.reason;if(e instanceof h.PostError)throw new h.FileUploadError("unauthorized"===e.reason?"unauthorized":e.reason||"network");throw Object(h.FileUploadError)("internal")}if("ok"!==r.status)throw Object(h.FileUploadError)("internal");l.b()&&l.b().id===i&&await l.d({lastUploaded:u.d(),cloudFileId:c,groupId:r.groupId})}async function I(){let e=l.b(),t=e.cloudFileId,r=e.groupId,n=e.lastUploaded,i=(e.id,n&&u.a(n,7)),o=u.d();n&&o{})}async function j(e){const t=m(await a.a.multiGet(["user-token"]),1),r=m(t[0],2)[1];await Object(g.post)(Object(f.a)().SYNC_SERVER+"/delete-user-file",{token:r,fileId:e})}async function R(){let e,t=await a.a.getItem("user-token");if(!t)return null;try{e=await O(Object(f.a)().SYNC_SERVER+"/list-user-files",{headers:{"X-ACTUAL-TOKEN":t}})}catch(e){return console.log("Error",e),null}return"error"===e.status?null:e.data.map(e=>_(_({},e),{},{hasKey:p.a.hasKey(e.encryptKeyId)}))}async function N(t,r){let n,o,c=await a.a.getItem("user-token");try{n=await Object(s.fetch)(Object(f.a)().SYNC_SERVER+"/download-user-file",{headers:{"X-ACTUAL-TOKEN":c,"X-ACTUAL-FILE-ID":t}}).then(S).then(t=>t.arrayBuffer?t.arrayBuffer().then(t=>e.from(t)):t.buffer())}catch(e){throw console.log("Download failure",e),Object(h.FileDownloadError)("download-failure")}try{o=await O(Object(f.a)().SYNC_SERVER+"/get-user-file-info",{headers:{"X-ACTUAL-TOKEN":c,"X-ACTUAL-FILE-ID":t}})}catch(e){throw Object(h.FileDownloadError)("internal",{fileId:t})}if("ok"!==o.status)throw Object(h.FileDownloadError)("internal",{fileId:t});let l=o.data;if(l.encryptMeta)try{n=await p.a.decrypt(n,l.encryptMeta)}catch(e){throw Object(h.FileDownloadError)("decrypt-failure",{isMissingKey:"missing-key"===e.message})}let d=new E(n),g=d.getEntries(),m=g.find(e=>e.entryName.includes("db.sqlite")),y=g.find(e=>e.entryName.includes("metadata.json"));if(!m||!y)throw Object(h.FileDownloadError)("invalid-zip-file");let b,w=d.readFile(m),v=d.readFile(y);try{b=JSON.parse(v.toString("utf8"))}catch(e){throw Object(h.FileDownloadError)("invalid-meta-file")}b=_(_({},b),{},{cloudFileId:l.fileId,groupId:l.groupId,lastUploaded:u.d(),encryptKeyId:l.encryptMeta?l.encryptMeta.keyId:null});let T=i.a.getBudgetDir(b.id);if(await i.a.exists(T)){if(!r)throw Object(h.FileDownloadError)("file-exists",{id:b.id});{let e=i.a.join(T,"db.sqlite"),t=i.a.join(T,"metadata.json");await i.a.exists(e)&&await i.a.removeFile(e),await i.a.exists(t)&&await i.a.removeFile(t)}}else await i.a.mkdir(T);return await i.a.writeFile(i.a.join(T,"db.sqlite"),w),await i.a.writeFile(i.a.join(T,"metadata.json"),JSON.stringify(b)),{id:b.id}}}).call(this,r(10).Buffer)},function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"c",(function(){return i})),r.d(t,"b",(function(){return o}));r(12);const n=new Map(Object.entries({imported_payee:"string",payee:"id",date:"date",notes:"string",amount:"number",amountInflow:"number",amountOutfow:"number",category:"id",account:"id",cleared:"boolean"}));function i(e,t){return e=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;te,fromExternal(e){let t={};return"id"in e&&(t.id=e.id),"account_id"in e&&(t.acct=e.account_id),"amount"in e&&(t.amount=e.amount),"payee_id"in e&&(t.description=e.payee_id),"imported_payee"in e&&(t.imported_description=e.imported_payee),"category_id"in e&&(t.category=e.category_id),"date"in e&&(t.date=e.date),"notes"in e&&(t.notes=e.notes),"imported_id"in e&&(t.financial_id=e.imported_id),"transfer_id"in e&&(t.transferred_id=e.transfer_id),"cleared"in e&&(t.cleared=e.cleared),t}});const l=u(u({},n.a),{},{toExternal:e=>({id:e.id,name:e.name,type:e.type,offbudget:!!e.offbudget,closed:!!e.closed}),fromExternal(e){let t=u({},e);return"offbudget"in e&&(t.offbudget=e.offbudget?1:0),"closed"in e&&(t.closed=e.closed?1:0),t}}),f=u(u({},n.c),{},{toExternal:e=>({id:e.id,name:e.name,is_income:!!e.is_income,group_id:e.cat_group}),fromExternal(e){e.group_id;let t=a(e,i);return"is_income"in e&&(t.is_income=e.is_income?1:0),"group_id"in e&&(t.cat_group=e.group_id),t}}),d=u(u({},n.b),{},{toExternal:e=>({id:e.id,name:e.name,is_income:!!e.is_income,categories:e.categories.map(f.toExternal)}),fromExternal(e){let t=u({},e);return"is_income"in e&&(t.is_income=e.is_income?1:0),"categories"in e&&(t.categories=e.categories.map(f.fromExternal)),t}}),h=u(u({},n.e),{},{toExternal:e=>({id:e.id,name:e.name,category:e.category,transfer_acct:e.transfer_acct}),fromExternal:e=>e}),p=u(u({},n.f),{},{toExternal(e){e.tombstone;return a(e,o)},fromExternal:e=>e})},function(e,t,r){"use strict";r.d(t,"b",(function(){return A})),r.d(t,"c",(function(){return N})),r.d(t,"a",(function(){return k})),r.d(t,"d",(function(){return C}));var n=r(275),i=r.n(n),o=r(1),a=r(12),s=r(77),u=r(2),c=(r(39),r(20)),l=r(7),f=r(6),d=r(135),h=(r(111),r(18),r(21)),p=r(68);const g=["subtransactions"],m=["payee_name","subtransactions"];function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;t=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}const v=r(64),E=r(30).post,S=(r(434),r(42));function O(e,t){let r=Object(s.c)(b(b({},e),{},{is_parent:!0,subtransactions:t.map((t,r)=>Object(s.b)(e,b(b({},t),{},{sort_order:0-r})))})),n=r.subtransactions;return[w(r,g),...n]}function T(e){switch(e.type){case"credit":case"loan":return-e.balances.current;default:return e.balances.current}}async function A(e,t,r){let n=(await E(Object(c.a)().PLAID_SERVER+"/accounts",{userId:e,key:t,item_id:r})).accounts;return n.forEach(e=>{e.balances.current=T(e)}),n}function M(e){return{imported_id:e.transaction_id,payee_name:e.name,imported_payee:e.name,amount:-Object(a.a)(e.amount),date:e.date}}async function D(e,t,r,n,i,o){let a=[],s=null,l=0,f=0;for(;;){const p=u.d(),g=await E(Object(c.a)().PLAID_SERVER+"/transactions",{userId:e,key:t,item_id:""+n,account_id:r,start_date:i,end_date:p,count:100,offset:l});if(g.error_code)throw d=g.error_type,h=g.error_code,{type:"BankSyncError",category:d,code:h};if(0===g.transactions.length)break;if(f+=g.transactions.length,a=a.concat(g.transactions.filter(e=>!e.pending)),s=T(g.accounts[0]),f===g.total_transactions||null!=o&&a.length>=o)break;l+=100}var d,h;return a=null!=o?a.slice(0,o):a,{transactions:a.map(M),accountBalance:s}}async function I(e,t,r){if(null==e.payee&&t){let e=r.get(t.toLowerCase());if(e=e||await o.getPayeeByName(t),null!=e)return e.id;{let e={id:S.v4Sync(),name:t};return r.set(t.toLowerCase(),e),e.id}}return e.payee}async function j(e,t,{rawPayeeName:r}={}){let n=new Map,o=[];for(let a of e){if(null==a.date)throw new Error("`date` is required when adding a transaction");let e=a,s=e.payee_name,u=e.subtransactions;if(a=w(e,m),s){let e=s.trim();s=""===e?null:r?e:i()(e)}a.imported_payee=a.imported_payee||s,a.imported_payee&&(a.imported_payee=a.imported_payee.trim()),a.account=t,a.payee=await I(a,s,n),o.push({payee_name:s,subtransactions:u?u.map(e=>b(b({},e),{},{account:t})):null,trans:a})}return{normalized:o,payeesToCreate:n}}async function R(e,t){let r=new Set(t.map(e=>e.payee));await Object(l.c)(async()=>{for(let t of e.values())r.has(t.id)&&await o.insertPayee(t)})}async function N(e,t){const r=new Set,n=[],i=[];let s=await j(t,e),c=s.normalized,l=s.payeesToCreate,f=[];for(let t of c){let n=t.payee_name,i=t.trans,a=t.subtransactions;i=Object(h.k)(i);let s=null,c=null;i.imported_id&&(s=await o.first("SELECT * FROM v_transactions WHERE imported_id = ? AND account = ?",[i.imported_id,e]),s&&r.add(s.id)),s||(c=await o.all("SELECT id, date, imported_id, payee, category, notes FROM v_transactions\n WHERE date >= ? AND date <= ? AND amount = ? AND account = ? AND is_child = 0",[o.toDateRepr(u.q(i.date,4)),o.toDateRepr(u.a(i.date,1)),i.amount||0,e])),f.push({payee_name:n,trans:i,subtransactions:a,match:s,fuzzyDataset:c})}let d=f.map(e=>{if(!e.match&&e.fuzzyDataset){let t=e.fuzzyDataset.find(t=>!r.has(t.id)&&e.trans.payee===t.payee);if(t)return r.add(t.id),b(b({},e),{},{match:t})}return e}).map(e=>{if(!e.match&&e.fuzzyDataset){let t=e.fuzzyDataset.find(e=>!r.has(e.id));if(t)return r.add(t.id),b(b({},e),{},{match:t})}return e});for(let e of d){e.payee_name;let t=e.trans,r=e.subtransactions,s=e.match;if(s){let e=b(b({},s),{},{cleared:1===s.cleared,date:o.fromDateRepr(s.date)});const r={date:t.date,imported_id:t.imported_id||null,payee:e.payee||t.payee||null,category:e.category||t.category||null,imported_payee:t.imported_payee||null,notes:e.notes||t.notes||null,cleared:null==t.cleared||t.cleared};Object(a.j)(e,r,Object.keys(r))&&n.push(b({id:e.id},r))}else{let e=b(b({},t),{},{id:S.v4Sync(),category:t.category||null,cleared:null==t.cleared||t.cleared});r&&r.length>0?i.push(...O(e,r)):i.push(e)}}return await R(l,[...i,...n]),await Object(p.a)({added:i,updated:n}),{added:i.map(e=>e.id),updated:n.map(e=>e.id)}}async function k(e,t,{runTransfers:r=!0}={}){const n=[];let i,a=await j(t,e,{rawPayeeName:!0}),s=a.normalized,u=a.payeesToCreate;for(let t of s){t.payee_name;let r=t.trans,i=t.subtransactions;r=Object(h.k)(r);let o=b(b({id:S.v4Sync()},r),{},{account:e,cleared:null==r.cleared||r.cleared});i&&i.length>0?n.push(...O(o,i)):n.push(o)}if(await R(u,n),r){let e=await Object(p.a)({added:n});i=e.added.map(e=>e.id)}else await Object(l.c)(async()=>{i=await Promise.all(n.map(async e=>o.insertTransaction(e)))});return i}async function C(e,t,r,n,i){const s=await o.first("SELECT * FROM v_transactions WHERE account = ? ORDER BY date DESC LIMIT 1",[r]);if(s){const c=await o.first("SELECT date FROM v_transactions WHERE account = ? ORDER BY date ASC LIMIT 1",[r]),l=o.fromDateRepr(c.date);let d=u.q(o.fromDateRepr(s.date),31);db(b({},e),{},{account:r})),Object(f.runMutator)(async()=>{const e=await N(r,p);return await async function(e,t){await o.runQuery("UPDATE accounts SET balance_current = ? WHERE id = ?",[Object(a.a)(t),e])}(r,g),e}))}{const a=await o.select("accounts",r),s=u.q(u.d(),0===a.offbudget?1:30),c=(await D(e,t,n,i,v.format(v.parseISO(s),"yyyy-MM-dd"))).transactions;let l=a.balance_current;const h=c.reduce((e,t)=>e-t.amount,l),p=c.length>0?c[c.length-1].date:u.d();let g=await Object(d.a)();return Object(f.runMutator)(async()=>{let e=await o.insertTransaction({account:r,amount:h,category:0===a.offbudget?g.category:null,payee:g.id,date:p,cleared:!0,starting_balance_flag:!0}),t=await N(r,c);return b(b({},t),{},{added:[e,...t.added]})})}}},function(e,t,r){"use strict";r.d(t,"d",(function(){return u})),r.d(t,"b",(function(){return c})),r.d(t,"e",(function(){return l})),r.d(t,"a",(function(){return f})),r.d(t,"c",(function(){return d}));var n=r(2),i=r(25);function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;ti&&e<=n.a(i,7)?"upcoming":e{let t=e._conditions.find(e=>"date"===e.field);return{$and:{schedule:e.id,date:{$gte:t&&"is"===t.op?e.next_date:n.q(e.next_date,2)}}}});return Object(i.b)("transactions").filter({$or:t}).orderBy({date:"desc"}).groupBy("schedule").select(["schedule","date"])}function l(e){let t={start:n.l(e.start),frequency:e.frequency.toUpperCase(),byHourOfDay:[12]};e.interval&&(t.interval=e.interval);let r=e=>e.slice(0,2).toUpperCase();switch(e.frequency){case"weekly":return[t];case"monthly":if(e.patterns&&e.patterns.length>0){let n=e.patterns.filter(e=>"day"===e.type),i=e.patterns.filter(e=>"day"!==e.type);return[n.length>0&&a(a({},t),{},{byDayOfMonth:n.map(e=>e.value)}),i.length>0&&a(a({},t),{},{byDayOfWeek:i.map(e=>[r(e.type),e.value])})].filter(Boolean)}return[t];case"yearly":return[t];default:throw new Error("Invalid recurring date config")}}function f(e){return{payee:e.find(e=>"is"===e.op&&"payee"===e.field)||e.find(e=>"is"===e.op&&"description"===e.field)||null,account:e.find(e=>"is"===e.op&&"account"===e.field)||e.find(e=>"is"===e.op&&"acct"===e.field)||null,amount:e.find(e=>("is"===e.op||"isapprox"===e.op||"isbetween"===e.op)&&"amount"===e.field)||null,date:e.find(e=>("is"===e.op||"isapprox"===e.op)&&"date"===e.field)||null}}function d(e){return e&&"number"!=typeof e?(e.num1+e.num2)/2|0:e}},function(e,t,r){const n=r(119);e.exports={v4:function(){return Promise.resolve(n.v4())},v4Sync:function(){return n.v4()}}},function(e,t,r){"use strict";t.a={isMobile:!1,isWeb:!0,isDesktop:!1}},function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=r,r.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},function(e,t,r){"use strict";var n=t,i=r(35),o=r(44),a=r(223);n.assert=o,n.toArray=a.toArray,n.zero2=a.zero2,n.toHex=a.toHex,n.encode=a.encode,n.getNAF=function(e,t,r){var n=new Array(Math.max(e.bitLength(),r)+1);n.fill(0);for(var i=1<(i>>1)-1?(i>>1)-u:u,o.isubn(s)):s=0,n[a]=s,o.iushrn(1)}return n},n.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var n,i=0,o=0;e.cmpn(-i)>0||t.cmpn(-o)>0;){var a,s,u=e.andln(3)+i&3,c=t.andln(3)+o&3;3===u&&(u=-1),3===c&&(c=-1),a=0==(1&u)?0:3!==(n=e.andln(7)+i&7)&&5!==n||2!==c?u:-u,r[0].push(a),s=0==(1&c)?0:3!==(n=t.andln(7)+o&7)&&5!==n||2!==u?c:-c,r[1].push(s),2*i===a+1&&(i=1-i),2*o===s+1&&(o=1-o),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(27),i=r(74);function o(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(i.a)(e),o=Object(i.a)(t),a=r.getTime()-Object(n.a)(r),s=o.getTime()-Object(n.a)(o);return Math.round((a-s)/864e5)}},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(3),i=r(0);function o(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(i.a)(e),o=Object(n.a)(t);return r.setDate(r.getDate()+o),r}},function(e,t,r){(function(e){function r(e,t){for(var r=0,n=e.length-1;n>=0;n--){var i=e[n];"."===i?e.splice(n,1):".."===i?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}function n(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;n=-1&&!i;o--){var a=o>=0?arguments[o]:e.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(t=a+"/"+t,i="/"===a.charAt(0))}return(i?"/":"")+(t=r(n(t.split("/"),(function(e){return!!e})),!i).join("/"))||"."},t.normalize=function(e){var o=t.isAbsolute(e),a="/"===i(e,-1);return(e=r(n(e.split("/"),(function(e){return!!e})),!o).join("/"))||o||(e="."),e&&a&&(e+="/"),(o?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(n(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},t.relative=function(e,r){function n(e){for(var t=0;t=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=t.resolve(e).substr(1),r=t.resolve(r).substr(1);for(var i=n(e.split("/")),o=n(r.split("/")),a=Math.min(i.length,o.length),s=a,u=0;u=1;--o)if(47===(t=e.charCodeAt(o))){if(!i){n=o;break}}else i=!1;return-1===n?r?"/":".":r&&1===n?"/":e.slice(0,n)},t.basename=function(e,t){var r=function(e){"string"!=typeof e&&(e+="");var t,r=0,n=-1,i=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!i){r=t+1;break}}else-1===n&&(i=!1,n=t+1);return-1===n?"":e.slice(r,n)}(e);return t&&r.substr(-1*t.length)===t&&(r=r.substr(0,r.length-t.length)),r},t.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,r=0,n=-1,i=!0,o=0,a=e.length-1;a>=0;--a){var s=e.charCodeAt(a);if(47!==s)-1===n&&(i=!1,n=a+1),46===s?-1===t?t=a:1!==o&&(o=1):-1!==t&&(o=-1);else if(!i){r=a+1;break}}return-1===t||-1===n||0===o||1===o&&t===n-1&&t===r+1?"":e.slice(t,n)};var i="b"==="ab".substr(-1)?function(e,t,r){return e.substr(t,r)}:function(e,t,r){return t<0&&(t=e.length+t),e.substr(t,r)}}).call(this,r(19))},function(e,t){function r(e,t){return e+"!"+t}e.exports={unresolveName:function(e){let t=e.indexOf("!");return-1!==t?{sheet:e.slice(0,t),name:e.slice(t+1)}:{sheet:null,name:e}},resolveName:r,resolveNamesAsObjects:function(e){const t={};return Object.keys(e).forEach(n=>{const i=e[n];Object.keys(i).forEach(e=>{const o=i[e];t[r(n,e)]=o})}),t},resolveNamesAsArrays:function(e){const t=[];return Object.keys(e).forEach(n=>{const i=e[n];i.forEach(e=>{i[e];t.push(r(n,e))})}),t}}},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(3),i=r(55);function o(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(n.a)(t);return Object(i.a)(e,-r)}},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(3),i=r(0);function o(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var r=t||{},o=r.locale,a=o&&o.options&&o.options.weekStartsOn,s=null==a?0:Object(n.a)(a),u=null==r.weekStartsOn?s:Object(n.a)(r.weekStartsOn);if(!(u>=0&&u<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var c=Object(i.a)(e),l=c.getUTCDay(),f=(l{let n=r.data,s="string"==typeof n?JSON.parse(n):n;if(s.type&&("init"===s.type||s.type.startsWith("__")))return;let c=s.id,l=s.name,f=s.args,d=s.undoTag,h=s.catchErrors;t[l]?i(t[l],f,{undoTag:d,name:l}).then(r=>{h&&(r={data:r,error:null}),e.postMessage({type:"reply",id:c,result:r,mutated:o(t[l]),undoTag:d})},t=>{let r=function(e){return e.type&&"APIError"===e.type?e:{type:"InternalError",message:e.message}}(t);l.startsWith("api/")?e.postMessage({type:"reply",id:c,error:r}):h?e.postMessage({type:"reply",id:c,result:{error:r,data:null}}):e.postMessage({type:"error",id:c}),"InternalError"===r.type&&a(t),h||u("server-error")}):(console.warn("Unknown method: "+l),e.postMessage({type:"reply",id:c,result:null,error:{type:"APIError",message:"Unknown method: "+l}}))},!1),e.postMessage({type:"connect"})},send:u,getNumClients:function(){return 1},tapIntoAPI:function(){}}},function(e,t,r){"use strict";var n=r(44),i=r(11);function o(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function a(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function u(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i>6|192,r[n++]=63&a|128):o(e,i)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++i)),r[n++]=a>>18|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128,r[n++]=63&a|128):(r[n++]=a>>12|224,r[n++]=a>>6&63|128,r[n++]=63&a|128)}else for(i=0;i>>0}return a},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},t.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},t.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,c=t;return u+=(c=c+n>>>0)>>0)>>0)>>0},t.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},t.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,c){var l=0,f=t;return l+=(f=f+n>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,c){return t+n+o+s+c>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},function(e,t,r){"use strict";var n=r(80),i=r(123),o=i(n("String.prototype.indexOf"));e.exports=function(e,t){var r=n(e,!!t);return"function"==typeof r&&o(e,".prototype.")>-1?i(r):r}},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(3),i=r(0);function o(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(i.a)(e).getTime(),o=Object(n.a)(t);return new Date(r+o)}},function(e,t,r){"use strict";r.d(t,"a",(function(){return u}));var n=r(129),i=r(24);function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return a(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r{this.method(e,r.handlers[e])}),r.services.forEach(e=>{this.service(e)});for(let e of r.events.all.entries()){var t=o(e,2);let r=t[0],n=t[1];for(let e of n)this.events.on(r,e)}}}startServices(){this.unlistenServices.length>0&&Object(i.captureException)(new Error("App: startServices called while services are already running")),this.unlistenServices=this.services.map(e=>e())}stopServices(){this.unlistenServices.forEach(e=>{e&&e()}),this.unlistenServices=[]}}function u(){return new s}},function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(3),i=r(0),o=r(90);function a(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(i.a)(e),a=Object(n.a)(t),s=r.getMonth()+a,u=new Date(0);u.setFullYear(r.getFullYear(),s,1),u.setHours(0,0,0,0);var c=Object(o.a)(u);return r.setMonth(s,Math.min(c,r.getDate())),r}},function(e,t,r){"use strict";r.d(t,"d",(function(){return y})),r.d(t,"c",(function(){return H})),r.d(t,"a",(function(){return z})),r.d(t,"b",(function(){return q}));const n=["$transform"],i=["$dir"];function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function c(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return l(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return l(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r{let n=r[e];if(null==n)throw new h(`Path error: ${e} table does not exist`);if(!n[t]||null==n[t].ref)throw new h(`Field not joinable on table ${e}: "${t}"`);return n[t].ref},a),u=i.slice(0,-1);if(1===u.length)o=u[0];else{let e=u.join("."),t=n.get(e);if(!t)throw new h("Path does not exist: "+e);o=t.tableId}return{tableName:s,tableId:d(s),joinField:i[i.length-1],joinTable:o}}function w(e,t){let r=t.split(".");return r=r.reduce((e,t)=>{let r=e.context+"."+t;return{context:r,path:[...e.path,r]}},{context:e.implicitTableName,path:[]}).path,r.forEach(t=>{e.paths.get(t)||e.paths.set(t,_(e,t))}),e.paths.get(r[r.length-1])}function v(e,t){if("string"!=typeof t)throw new h("Invalid field name, must be a string");let r,n=m(t),i=n.path,o=n.field;r=""===i?{tableName:e.implicitTableName,tableId:e.implicitTableId}:w(e,i);let a=function(e,t,r){if(null==e[t])throw new h(`Table "${t}" does not exist in the schema`);let n=e[t][r];if(null==n)throw new h(`Field "${r}" does not exist in table "${t}"`);return n}(e.schema,r.tableName,o);if(e.validateRefs&&a.ref&&"id"===a.type&&"id"!==o){let n=e.implicitTableName+"."+t,i=e.paths.get(n);i||(i=_(e,n),i.noMapping=!0,e.paths.set(n,i)),o="id",r=i}return b(r.tableId+"."+o,a.type)}function E(e){let t=e.match(/^(\d{4}-\d{2}-\d{2})$/);return t?b(p(t[1]),"date",{literal:!0}):null}function S(e){let t=e.match(/^(\d{4}-\d{2})$/);return t?b(p(t[1]),"date",{literal:!0}):null}function O(e,t){throw new h(`Bad ${t} format: ${e}`)}function T(e,t,r){if(t.type===r)return t;if("param"===t.type)return function(e,t){let r=e.paramType;if(r){let e={date:["string"],"date-month":["date"],"date-year":["date","date-month"],id:["string"],float:["integer"]};if(!(r===t||e[t]&&e[t].includes(r)))throw new Error(`Parameter "${name}" can't convert to ${t} (already inferred as ${r})`)}else e.paramType=t}(t,r),b(t.value,r);if("null"===t.type){if(!t.literal)throw new h("A non-literal null doesn't make sense");return"boolean"===r?b(0,"boolean",{literal:!0}):t}if("date"===r){if("string"===t.type){if(t.literal)return E(t.value)||O(t.value,"date");throw new h("Casting string fields to dates is not supported")}throw new h(`Can't cast ${t.type} to date`)}if("date-month"===r){let e;if("date"===t.type)e=t;else{if("string"!==t.type&&"any"!==t.type)throw new h(`Can't cast ${t.type} to date-month`);e=S(t.value)||E(t.value)||O(t.value,"date-month")}return e.literal?b(p(e.value.toString().slice(0,6)),"date-month",{literal:!0}):b(`CAST(SUBSTR(${e.value}, 1, 6) AS integer)`,"date-month")}if("date-year"===r){let e;if("date"===t.type||"date-month"===t.type)e=t;else{if("string"!==t.type)throw new h(`Can't cast ${t.type} to date-year`);e=function(e){let t=e.match(/^(\d{4})$/);return t?b(p(t[1]),"date",{literal:!0}):null}(t.value)||S(t.value)||E(t.value)||O(t.value,"date-year")}return e.literal?b(p(e.value.toString().slice(0,4)),"date-year",{literal:!0}):b(`CAST(SUBSTR(${e.value}, 1, 4) AS integer)`,"date-year")}if("id"===r){if("string"===t.type)return b(t.value,"id",{literal:t.literal})}else if("float"===r&&"integer"===t.type)return b(t.value,"float",{literal:t.literal});if("any"===t.type)return b(t.value,r,{literal:t.literal});throw new h(`Can't convert ${t.type} to ${r}`)}function A(e,t,r){let n=t;if(r&&(n=T(0,t,r)),n.literal){if("id"===n.type)return`'${n.value}'`;if("string"===n.type){return`'${n.value.replace(/'/g,"''")}'`}}return n.value}function M(e,t,r){return t.map((e,t)=>A(0,e,r?r[t]:null))}function D(e,t,r){if(null==r&&(r=t),null!=t&&e.lengthr)throw new h("Too many arguments")}function I(e,t){return(r,...n)=>{if(null==r||null==r.compileStack)throw new h("This function cannot track error data. It needs to accept the compiler state as the first argument.");r.compileStack.push({type:e,args:n});let i=t(r,...n);return r.compileStack.pop(),i}}function j(e){if("string"==typeof e)return e;if(void 0===e)return"undefined";let t=JSON.stringify(e);if(t.length>70){return JSON.stringify(e,null,2).split("\n").join("\n ")}return t}function R(e){if(void 0===e)throw new h("`undefined` is not a valid query value");if(null===e)return b("NULL","null",{literal:!0});if(e instanceof Date)return b(function(e){let t=e=>(e<10?"0":"")+e;return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())}(e),"date",{literal:!0});if("string"==typeof e)return b(e=e.replace(/\\\$/g,"$"),"string",{literal:!0});if("boolean"==typeof e)return b(e?1:0,"boolean",{literal:!0});if("number"==typeof e)return b(e,(0|e)===e?"integer":"float",{literal:!0});if(Array.isArray(e))return b(e,"array",{literal:!0});throw new h("Unsupported type of expression: "+JSON.stringify(e))}const N=I("expr",(e,t)=>{if("string"==typeof t){if("$"===t[0]){let r="$"===t?e.implicitField:t.slice(1);if(null==r||""===r)throw new h("Invalid field reference: "+t);return v(e,r)}if(":"===t[0]){let r={value:"?",type:"param",paramName:t.slice(1)};return e.namedParameters.push(r),r}}if(null!==t){if(Array.isArray(t))return R(t);if("object"==typeof t&&Object.keys(t).find(e=>"$"===e[0]))return k(e,t)}return R(t)});const k=I("function",(e,t)=>{let r=c(Object.keys(t),1)[0],n=t[r];if(Array.isArray(n)||(n=[n]),"$"!==r[0])throw new h(`Unknown property "${r}". Did you mean to call a function? Try prefixing it with $`);let i=n;switch("$condition"!==r&&(i=n.map(t=>N(e,t))),r){case"$sum":return D(i,1),b(`SUM(${c(M(0,i,["float"]),1)[0]})`,i[0].type);case"$sumOver":return b(`(SUM(${c(M(0,i,["float"]),1)[0]}) OVER (${e.orders?"ORDER BY "+F(e,e.orders):""} ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING))`,i[0].type);case"$count":return D(i,1),b(`COUNT(${c(M(0,i),1)[0]})`,"integer");case"$substr":{D(i,2,3);let e=c(M(0,i,["string","integer","integer"]),3);return b(`SUBSTR(${e[0]}, ${e[1]}, ${e[2]})`,"string")}case"$lower":return D(i,1),b(`LOWER(${c(M(0,i,["string"]),1)[0]})`,"string");case"$neg":D(i,1);c(M(0,i,["float"]),1)[0];return b(`(-${A(0,i[0])})`,i[0].type);case"$abs":D(i,1);c(M(0,i,["float"]),1)[0];return b(`ABS(${A(0,i[0])})`,i[0].type);case"$idiv":{D(i,2);let e=c(M(0,i,["integer","integer"]),2);e[0],e[1];return b(`(${A(0,i[0])} / ${A(0,i[1])})`,i[0].type)}case"$month":return D(i,1),T(0,i[0],"date-month");case"$year":return D(i,1),T(0,i[0],"date-year");case"$condition":return D(i,1),b(L(e,i[0]).join(" AND "),"boolean");case"$nocase":return D(i,1),b(c(M(0,i,["string"]),1)[0]+" COLLATE NOCASE",i[0].type);case"$literal":if(D(i,1),!i[0].literal)throw new h("Literal not passed to $literal");return i[0];default:throw new h("Unknown function: "+r)}}),C=I("op",(e,t,r)=>{let i,o=r.$transform,s=u(r,n),l=c(Object.keys(s),1)[0],f=N(e,r[l]);switch(i=o?k(a(a({},e),{},{implicitField:t}),"string"==typeof o?{[o]:"$"}:o):N(e,"$"+t),l){case"$gte":{let e=c(M(0,[i,f],[null,i.type]),2);return`${e[0]} >= ${e[1]}`}case"$lte":{let e=c(M(0,[i,f],[null,i.type]),2);return`${e[0]} <= ${e[1]}`}case"$gt":{let e=c(M(0,[i,f],[null,i.type]),2);return`${e[0]} > ${e[1]}`}case"$lt":{let e=c(M(0,[i,f],[null,i.type]),2);return`${e[0]} < ${e[1]}`}case"$eq":{if("null"===T(0,f,i.type).type)return A(0,i)+" IS NULL";let t=c(M(0,[i,f],[null,i.type]),2),r=t[0],n=t[1];if("param"===f.type){let t=e.namedParameters.map(e=>e===f||e===i?[e,a({},e)]:e);return e.namedParameters=[].concat.apply([],t),`CASE\n WHEN ${r} IS NULL THEN ${n} IS NULL\n ELSE ${r} = ${n}\n END`}return`${r} = ${n}`}case"$oneof":{let e=c(M(0,[i,f],[null,"array"]),2),t=e[0],r=e[1];return t+" IN ("+[...new Set(r)].map(e=>`'${e}'`).join(",")+")"}case"$like":{let e=c(M(0,[i,f],["string","string"]),2);return`${e[0]} LIKE ${e[1]}`}default:throw new h("Unknown operator: "+l)}});function L(e,t){return Array.isArray(t)||(t=Object.entries(t).map(e=>({[e[0]]:e[1]}))),t.filter(Boolean).reduce((t,r)=>{let n=Object.entries(r).map(([t,r])=>"$and"===t?r?x(e,r):null:"$or"===t?r?function(e,t){if(!t)return"0";let r=L(e,t);if(0===r.length)return"0";return"("+r.join("\n OR ")+")"}(e,r):null:"string"==typeof r||"number"==typeof r||"boolean"==typeof r||r instanceof Date||null==r?C(e,t,{$eq:r}):Array.isArray(r)?r.map(r=>C(e,t,r)).join(" AND "):C(e,t,r)).filter(Boolean);return[...t,...n]},[])}function x(e,t){if(!t)return"1";let r=L(e,t);return 0===r.length?"1":"("+r.join("\n AND ")+")"}const P=I("filter",(e,t)=>x(e,t));const B=I("select",(e,t,r,n)=>(r||t.includes("id")||t.includes("*")||(t=t.concat(["id"])),t.map(t=>{if("string"==typeof t){if(-1!==t.indexOf("*")){return function(e,t){let r,n;if("*"===t)n={tableName:e.implicitTableName,tableId:e.implicitTableId};else if(t.match(/\.\*$/)){let i=m(t);r=i.path,n=w(e,i.path)}let i=e.schema[n.tableName];if(null==i)throw new Error(`Table "${n.tableName}" does not exist`);return Object.keys(i).map(e=>r?`${r}.${e}`:e)}(e,t).map(t=>{let r=N(e,"$"+t);return e.outputTypes.set(t,r.type),r.value+" AS "+y(t)}).join(", ")}let r=N(e,"$"+t);return e.outputTypes.set(t,r.type),r.value+" AS "+y(t)}let r=c(Object.entries(t)[0],2),i=r[0],o=r[1];if("$"===i[0])throw e.compileStack.push({type:"value",value:t}),new h(`Invalid field "${i}", are you trying to select a function? You need to name the expression`);if("string"==typeof o){let t=N(e,"$"+o);return e.outputTypes.set(i,t.type),`${t.value} AS ${y(i)}`}let s=k(a(a({},e),{},{orders:n}),o);return e.outputTypes.set(i,s.type),s.value+" AS "+y(i)}).join(", "))),U=I("groupBy",(e,t)=>t.map(t=>"string"==typeof t?N(e,"$"+t).value:k(e,t).value).join(", ")),F=I("orderBy",(e,t)=>t.map(t=>{let r,n=null;if("string"==typeof t)r=N(e,"$"+t).value;else{let o=Object.entries(t),a=o[0];if(1===o.length&&"$"!==a[0][0])n=a[1],r=N(e,"$"+a[0]).value;else{let o=t.$dir,a=u(t,i);n=o,r=k(e,a).value}}if(null!=n){if("desc"!==n&&"asc"!==n)throw new h("Invalid order direction: "+n);return`${r} ${n}`}return r}).join(", "));let W=["$sum","$count"];function H(e){return e.groupExpressions.length>0||e.selectExpressions.find(e=>{if("string"!=typeof e){let t=c(Object.entries(e)[0],2);t[0];return function e(t){if("object"!=typeof t||Array.isArray(t))return!1;let r=c(Object.entries(t)[0],2),n=r[0],i=r[1];return Array.isArray(i)||(i=[i]),-1!==W.indexOf(n)||i.find(t=>e(t))}(t[1])}return!1})}function z(e,t,r={}){let n=e.withDead,i=e.validateRefs,o=void 0===i||i,s=e.tableOptions,u=e.rawMode,l=r.tableViews,d=void 0===l?{}:l,p=r.tableFilters,m=void 0===p?e=>[]:p,b=r.customizeQuery,_=void 0===b?e=>e:b,w=e=>{let t=m(e);for(let e of t){if(Array.isArray(e))throw new h("Invalid internal table filter: only object filters are supported");if(-1!==Object.keys(e)[0].indexOf("."))throw new h("Invalid internal table filter: field names cannot contain paths")}return t},v=(e,t)=>("function"==typeof d?d(e,{withDead:n,isJoin:t,tableOptions:s}):d[e])||e,E=e.table,S=_(e),O=S.filterExpressions,T=S.selectExpressions,A=S.groupExpressions,M=S.orderExpressions,D=S.limit,I=S.offset,R=(S.calculation,""),N="",k="",C="",L="",W={schema:t,implicitTableName:E,implicitTableId:v(E),paths:new Map,dependencies:[E],compileStack:[],outputTypes:new Map,validateRefs:o,namedParameters:[]};f=0;try{if(R=B(W,T,H(e),M),O.length>0){N="WHERE "+P(W,O)}else N="WHERE 1";if(!u){let e=w(E);e.length>0&&(N+=" AND "+x(W,e))}if(A.length>0){C="GROUP BY "+U(W,A)}if(M.length>0){L="ORDER BY "+F(W,M)}W.paths.size>0&&(k=function(e,t,r){let n=[];return e.paths.forEach((i,o)=>{let s=e.paths.get(o),u=s.tableName,c=s.tableId,l=s.joinField,f=s.joinTable,d=s.noMapping,h=`${c}.id = ${t(f)}.${y(l)}`,p=r(u);p.length>0&&(h+=" AND "+x(a(a({},e),{},{implicitTableName:u,implicitTableId:c}),p)),n.push(`LEFT JOIN ${d?u:t(u,!0)} ${c} ON ${g(e.schema,u,c,h)}`),-1===e.dependencies.indexOf(u)&&e.dependencies.push(u)}),n.join("\n")}(W,v,w))}catch(e){if(e instanceof h)throw function(e,t){if(0===t.length)return e;let r=t.slice(1).reverse().map(e=>{switch(e.type){case"expr":case"function":return j(e.args[0]);case"op":{let t=c(e.args,2);return j({[t[0]]:t[1]})}case"value":return j(e.value);default:return""}}).map(e=>"\n "+e).join("");const n=t[0].type,i=t[0].args[0];r+=`\n ${n}(${j(1===i.length?i[0]:i)})`;{const t=new h;return t.message=e.message+"\n\nExpression stack:"+r,t.stack=null,t}}(e,W.compileStack);throw e}return{sqlPieces:{select:R,from:v(E),joins:k,where:N,groupBy:C,orderBy:L,limit:D,offset:I},state:W}}function q(e,t,r){let n=r,i=e.withDead?n.where:g(t.schema,t.implicitTableName,t.implicitTableId,n.where);return`\n SELECT ${n.select} FROM ${n.from}\n ${n.joins}\n ${i}\n ${n.groupBy}\n ${n.orderBy}\n ${null!=n.limit?"LIMIT "+n.limit:""}\n ${null!=n.offset?"OFFSET "+n.offset:""}\n `}},function(e,t,r){"use strict";var n={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function i(e){return function(t){var r=t||{},n=r.width?String(r.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var o={date:i({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:i({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:i({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},a={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function s(e){return function(t,r){var n=r||{},i=n.width?String(n.width):e.defaultWidth;return("formatting"===(n.context?String(n.context):"standalone")&&e.formattingValues?e.formattingValues[i]||e.formattingValues[e.defaultFormattingWidth]:e.values[i]||e.values[e.defaultWidth])[e.argumentCallback?e.argumentCallback(t):t]}}function u(e){return function(t,r){var n=String(t),i=r||{},o=i.width,a=o&&e.matchPatterns[o]||e.matchPatterns[e.defaultMatchWidth],s=n.match(a);if(!s)return null;var u,c=s[0],l=o&&e.parsePatterns[o]||e.parsePatterns[e.defaultParseWidth];return u="[object Array]"===Object.prototype.toString.call(l)?l.findIndex((function(e){return e.test(n)})):function(e,t){for(var r in e)if(e.hasOwnProperty(r)&&t(e[r]))return r}(l,(function(e){return e.test(n)})),u=e.valueCallback?e.valueCallback(u):u,{value:u=i.valueCallback?i.valueCallback(u):u,rest:n.slice(c.length)}}}var c,l={formatDistance:function(e,t,r){var i;return r=r||{},i="string"==typeof n[e]?n[e]:1===t?n[e].one:n[e].other.replace("{{count}}",t),r.addSuffix?r.comparison>0?"in "+i:i+" ago":i},formatLong:o,formatRelative:function(e,t,r,n){return a[e]},localize:{ordinalNumber:function(e,t){var r=Number(e),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},era:s({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:s({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(e){return Number(e)-1}}),month:s({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:s({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:s({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(c={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}},function(e,t){var r=String(e),n=t||{},i=r.match(c.matchPattern);if(!i)return null;var o=i[0],a=r.match(c.parsePattern);if(!a)return null;var s=c.valueCallback?c.valueCallback(a[0]):a[0];return{value:s=n.valueCallback?n.valueCallback(s):s,rest:r.slice(o.length)}}),era:u({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:u({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:u({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:u({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:u({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}};t.a=l},function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(0);function i(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=1,r=Object(n.a)(e),i=r.getUTCDay(),o=(ie+Object(u.number)(t),0)}const l=r(49).resolveName;const f=r(49).resolveName;function d(e){let t=o.m(e[0]);return o.p(t,"rollover")}function h(e,t){if(t.length>0){let r=d(t);n.b().createStatic(r,"carryover-"+e.id,!1),n.b().createStatic(r,"leftover-"+e.id,0),n.b().createStatic(r,"leftover-pos-"+e.id,0)}}function p(e,t,r){let i=d(r);e.blankSheet!==i&&(n.b().clearSheet(e.blankSheet),function(e,t,r){n.b().createStatic(t,"is-blank",!0),n.b().createStatic(t,"to-budget",0),n.b().createStatic(t,"buffered",0),e.forEach(e=>h(e,r))}(t,i,r),e.blankSheet=i)}var g=r(32);function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return y(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return y(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r{let t=i.runQuery(`SELECT SUM(amount) as amount FROM v_transactions_internal_alive t\n LEFT JOIN accounts a ON a.id = t.account\n WHERE t.date >= ${o} AND t.date <= ${a}\n AND category = '${e.id}' AND a.offbudget = 0`,[],!0)[0];return(t?t.amount:0)||0}}),"rollover"===v()?function(e,t,r){e.is_income||(n.b().createStatic(t,"budget-"+e.id,0),null==n.b().getCellValue(t,"budget-"+e.id)&&n.b().set(f(t,"budget-"+e.id),0),n.b().createStatic(t,"carryover-"+e.id,!1),n.b().createDynamic(t,"leftover-"+e.id,{initialValue:0,dependencies:["budget-"+e.id,"sum-amount-"+e.id,`${r}!carryover-${e.id}`,`${r}!leftover-${e.id}`,`${r}!leftover-pos-${e.id}`],run:(e,t,r,n,i)=>Object(u.number)(e)+Object(u.number)(t)+(r?Object(u.number)(n):Object(u.number)(i))}),n.b().createDynamic(t,"leftover-pos-"+e.id,{initialValue:0,dependencies:["leftover-"+e.id],run:e=>e<0?0:e}))}(e,t,r):async function(e,t,r){n.b().createStatic(t,"budget-"+e.id,0),null==n.b().getCellValue(t,"budget-"+e.id)&&n.b().set(l(t,"budget-"+e.id),0),n.b().createDynamic(t,"leftover-"+e.id,{initialValue:0,dependencies:["budget-"+e.id,"sum-amount-"+e.id,`${r}!carryover-${e.id}`,`${r}!leftover-${e.id}`],run:(t,r,n,i)=>e.is_income?Object(u.number)(t)-Object(u.number)(r)+(n?Object(u.number)(i):0):Object(u.number)(t)+Object(u.number)(r)+(n?Object(u.number)(i):0)}),n.b().createDynamic(t,"spent-with-carryover-"+e.id,{initialValue:0,dependencies:["budget-"+e.id,"sum-amount-"+e.id,"carryover-"+e.id],refresh:!0,run:(e,t,r)=>r?Math.max(0,Object(u.number)(e)+Object(u.number)(t)):t}),n.b().createStatic(t,"carryover-"+e.id,!1)}(e,t,r)}function S(e,t){n.b().createDynamic(t,"group-sum-amount-"+e.id,{initialValue:0,dependencies:e.categories.map(e=>"sum-amount-"+e.id),run:c}),e.is_income&&"rollover"===v()||(n.b().createDynamic(t,"group-budget-"+e.id,{initialValue:0,dependencies:e.categories.map(e=>"budget-"+e.id),run:c}),n.b().createDynamic(t,"group-leftover-"+e.id,{initialValue:0,dependencies:e.categories.map(e=>"leftover-"+e.id),run:c}))}function O(e,t){if((t.has("date")||t.has("acct")||t.has("amount")||t.has("category")||t.has("tombstone")||t.has("isParent"))&&e.date&&e.category){let t=o.k(i.fromDateRepr(e.date)),r=o.p(t,v());n.b().recompute(Object(s.resolveName)(r,"sum-amount-"+e.category))}}function T(e,t,r){let a=v();if(1===r.tombstone&&t&&0===t.tombstone){let t=r.id;e.forEach(e=>{!function(e,t){n.b().removeDependencies(e,"total-budgeted",["group-budget-"+t]),n.b().removeDependencies(e,"total-spent",["group-sum-amount-"+t]),n.b().removeDependencies(e,"total-leftover",["group-leftover-"+t])}(o.p(e,a),t)})}else if(0===r.tombstone&&(!t||1===t.tombstone)){let t=r;t.is_income&&"rollover"===a||e.forEach(e=>{let r=o.p(e,a),s=i.runQuery("SELECT * FROM categories WHERE tombstone = 0 AND cat_group = ?",[t.id],!0);S(_(_({},t),{},{categories:s}),r),function(e,t){n.b().addDependencies(e,"total-budgeted",["group-budget-"+t]),n.b().addDependencies(e,"total-spent",["group-sum-amount-"+t]),n.b().addDependencies(e,"total-leftover",["group-leftover-"+t])}(r,t.id)})}}function A(e,t){let r=n.b().meta().createdMonths,u=void 0===r?new Set:r;n.h();try{t.forEach((t,r)=>{let c=e.get(r);t.forEach(e=>{let t=c&&c.get(e.id);if("zero_budget_months"===r)!function(e){let t=o.p(e.id);n.b().set(t+"!buffered",e.buffered)}(e);else if("zero_budgets"===r||"reflect_budgets"===r)!function(e){if(e.category){let t=o.p(e.month.toString());n.b().set(`${t}!budget-${e.category}`,e.amount||0),n.b().set(`${t}!carryover-${e.category}`,1===e.carryover)}}(e);else if("transactions"===r){let r=new Set(Object.keys(Object(a.f)(t||{},e)||{}));t&&O(t,r),O(e,r)}else"category_mapping"===r?function(e,t,r){e.forEach(e=>{let i=o.p(e,v());t&&n.b().recompute(Object(s.resolveName)(i,"sum-amount-"+t.transferId)),n.b().recompute(Object(s.resolveName)(i,"sum-amount-"+r.transferId))})}(u,t,e):"categories"===r?function(e,t,r){function i(e,t,r){n.b().addDependencies(e,"group-sum-amount-"+t,["sum-amount-"+r]),n.b().addDependencies(e,"group-budget-"+t,["budget-"+r]),n.b().addDependencies(e,"group-leftover-"+t,["leftover-"+r])}function a(e,t,r){n.b().removeDependencies(e,"group-sum-amount-"+t,["sum-amount-"+r]),n.b().removeDependencies(e,"group-budget-"+t,["budget-"+r]),n.b().removeDependencies(e,"group-leftover-"+t,["leftover-"+r])}let s=v();if(t&&0===t.tombstone&&1===r.tombstone){let t=r.id,n=r.cat_group;e.forEach(e=>{a(o.p(e),n,t)})}else if(0!==r.tombstone||t&&1!==t.tombstone){if(t&&t.cat_group!==r.cat_group){let n=r.id;e.forEach(e=>{let u=o.p(e,s);a(u,t.cat_group,n),i(u,r.cat_group,n)})}}else"rollover"===s&&h(r,e),e.forEach(e=>{let t=o.m(e),a=o.p(t,s),u=o.p(e,s),c=o.c(e),l=c.start,f=c.end;E(r,u,a,l,f);let d=r.id,h=r.cat_group;"rollover"===v()&&n.b().addDependencies(u,"last-month-overspent",[`${a}!leftover-${d}`,`${a}!carryover-${d}`]),i(u,h,d)})}(u,t,e):"category_groups"===r?T(u,t,e):"accounts"===r&&function(e,t,r){if(!t||t.offbudget!==r.offbudget){let t=i.runQuery("\n SELECT DISTINCT(category) as category FROM transactions\n WHERE acct = ?\n ",[r.id],!0);e.forEach(e=>{let r=o.p(e,v());t.forEach(e=>{n.b().recompute(Object(s.resolveName)(r,"sum-amount-"+e.category))})})}}(u,t,e)})})}finally{n.a()}}async function M(e,t){[...n.b().meta().createdMonths].map(r=>{let n=e.map(e=>g.c({month:r,category:e})).reduce((e,t)=>e+t,0),i=g.c({month:r,category:t});g.i({month:r,category:t,amount:n+i})})}async function D(e){const t=await i.getCategories(),r=await i.getCategoriesGrouped();n.h();let a=n.b().meta();a.createdMonths=a.createdMonths||new Set;let s=v();"rollover"===s&&p(a,t,e),e.forEach(e=>{if(!a.createdMonths.has(e)){let i=o.m(e),l=o.c(e),f=l.start,d=l.end,h=o.p(e,s),p=o.p(i,s);t.forEach(e=>{E(e,h,p,f,d)}),r.forEach(e=>{S(e,h)}),"rollover"===s?function(e,t,r,i){let o=e.filter(e=>e.is_income)[0],a=t.filter(e=>!e.is_income);var s;n.b().createStatic(i,"buffered",0),n.b().createDynamic(i,"from-last-month",{initialValue:0,dependencies:[r+"!to-budget",r+"!buffered"],run:(e,t)=>Object(u.number)(e)+Object(u.number)(t)}),n.b().createDynamic(i,"total-income",{initialValue:0,dependencies:["group-sum-amount-"+o.id],run:e=>e}),n.b().createDynamic(i,"available-funds",{initialValue:0,dependencies:["total-income","from-last-month"],run:(e,t)=>Object(u.number)(e)+Object(u.number)(t)}),n.b().createDynamic(i,"last-month-overspent",{initialValue:0,dependencies:(s=a.map(e=>[`${r}!leftover-${e.id}`,`${r}!carryover-${e.id}`]),Array.prototype.concat.apply([],s)),run:(...e)=>(e=function(e){let t=[];for(let r=0;rr?e:e+Math.min(0,Object(u.number)(t)),0)}),n.b().createDynamic(i,"total-budgeted",{initialValue:0,dependencies:e.filter(e=>!e.is_income).map(e=>"group-budget-"+e.id),run:(...e)=>-c(...e)}),n.b().createDynamic(i,"buffered",{initialValue:0}),n.b().createDynamic(i,"to-budget",{initialValue:0,dependencies:["available-funds","last-month-overspent","total-budgeted","buffered"],run:(e,t,r,n)=>Object(u.number)(e)+Object(u.number)(t)+Object(u.number)(r)-Object(u.number)(n)}),n.b().createDynamic(i,"total-spent",{initialValue:0,dependencies:e.filter(e=>!e.is_income).map(e=>"group-sum-amount-"+e.id),run:c}),n.b().createDynamic(i,"total-leftover",{initialValue:0,dependencies:e.filter(e=>!e.is_income).map(e=>"group-leftover-"+e.id),run:c})}(r,t,p,h):function(e,t,r){let i=e.filter(e=>e.is_income)[0],o=t.filter(e=>!e.is_income);n.b().createDynamic(r,"total-budgeted",{initialValue:0,dependencies:e.filter(e=>!e.is_income).map(e=>"group-budget-"+e.id),run:c}),n.b().createDynamic(r,"total-spent",{initialValue:0,refresh:!0,dependencies:o.map(e=>`${r}!spent-with-carryover-${e.id}`),run:c}),n.b().createDynamic(r,"total-income",{initialValue:0,dependencies:["group-sum-amount-"+i.id],run:e=>e}),n.b().createDynamic(r,"total-leftover",{initialValue:0,dependencies:["total-budgeted","total-spent"],run:c}),n.b().createDynamic(r,"total-budget-income",{initialValue:0,dependencies:["group-budget-"+i.id],run:e=>e}),n.b().createDynamic(r,"total-saved",{initialValue:0,dependencies:["total-budget-income","total-budgeted"],run:(e,t)=>e-t}),n.b().createDynamic(r,"real-saved",{initialValue:0,dependencies:["total-income","total-spent"],run:(e,t)=>e- -t})}(r,t,h),a.createdMonths.add(e)}}),n.b().setMeta(a),n.a(),await n.j()}async function I(){let e=await i.first("SELECT * FROM transactions WHERE isChild=0 AND date IS NOT NULL ORDER BY date ASC LIMIT 1"),t=e&&i.fromDateRepr(e.date),r=o.e(),a=function(e,t){return(e=o.h(e))>(t=o.h(t))&&(e=t),{start:e=o.r(e,3),end:t=o.b(t,12),range:o.o(e,t)}}(t||r,r),s=a.start,u=a.end,c=a.range,l=n.b().meta().createdMonths||new Set;return c.filter(e=>!l.has(e)).length>0&&await D(c),{start:s,end:u}}async function j(e){let t=n.b().meta();if(e===t.budgetType)return;t.budgetType=e,t.createdMonths=new Set;let r=n.b().getNodes();i.transaction(()=>{for(let e of r.keys()){let t=m(e.split("!"),2),r=t[0],i=t[1];r.match(/^budget\d+/)&&n.b().deleteCell(r,i)}}),n.b().startCacheBarrier(),n.f(i);let o=await I();return n.b().endCacheBarrier(),o}},function(e,t,r){"use strict";var n=r(22),i={y:function(e,t){var r=e.getUTCFullYear(),i=r>0?r:1-r;return Object(n.a)("yy"===t?i%100:i,t.length)},M:function(e,t){var r=e.getUTCMonth();return"M"===t?String(r+1):Object(n.a)(r+1,2)},d:function(e,t){return Object(n.a)(e.getUTCDate(),t.length)},a:function(e,t){var r=e.getUTCHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":case"aaa":return r.toUpperCase();case"aaaaa":return r[0];case"aaaa":default:return"am"===r?"a.m.":"p.m."}},h:function(e,t){return Object(n.a)(e.getUTCHours()%12||12,t.length)},H:function(e,t){return Object(n.a)(e.getUTCHours(),t.length)},m:function(e,t){return Object(n.a)(e.getUTCMinutes(),t.length)},s:function(e,t){return Object(n.a)(e.getUTCSeconds(),t.length)}};t.a=i},function(e,t,r){"use strict";var n,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};n=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}y(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&y(e,"error",t,r)}(e,i,{once:!0})}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var u=10;function c(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function f(e,t,r,n){var i,o,a,s;if(c(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),a=o[t]),void 0===a)a=o[t]=r,++e._eventsCount;else if("function"==typeof a?a=o[t]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=l(e))>0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=d.bind(n);return i.listener=r,n.wrapFn=i,i}function p(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,l=m(u,c);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},s.prototype.listenerCount=g,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,r){"use strict";r.r(t),r.d(t,"addDays",(function(){return n.a})),r.d(t,"addHours",(function(){return a})),r.d(t,"addISOWeekYears",(function(){return p})),r.d(t,"addMilliseconds",(function(){return o.a})),r.d(t,"addMinutes",(function(){return g})),r.d(t,"addMonths",(function(){return m.a})),r.d(t,"addQuarters",(function(){return y})),r.d(t,"addSeconds",(function(){return b})),r.d(t,"addWeeks",(function(){return _.a})),r.d(t,"addYears",(function(){return w.a})),r.d(t,"areIntervalsOverlapping",(function(){return v})),r.d(t,"closestIndexTo",(function(){return E})),r.d(t,"closestTo",(function(){return S})),r.d(t,"compareAsc",(function(){return O.a})),r.d(t,"compareDesc",(function(){return T})),r.d(t,"differenceInCalendarDays",(function(){return d.a})),r.d(t,"differenceInCalendarISOWeekYears",(function(){return A})),r.d(t,"differenceInCalendarISOWeeks",(function(){return D})),r.d(t,"differenceInCalendarMonths",(function(){return I})),r.d(t,"differenceInCalendarQuarters",(function(){return R})),r.d(t,"differenceInCalendarWeeks",(function(){return N})),r.d(t,"differenceInCalendarYears",(function(){return k})),r.d(t,"differenceInDays",(function(){return C.a})),r.d(t,"differenceInHours",(function(){return x})),r.d(t,"differenceInISOWeekYears",(function(){return B})),r.d(t,"differenceInMilliseconds",(function(){return L})),r.d(t,"differenceInMinutes",(function(){return U})),r.d(t,"differenceInMonths",(function(){return F})),r.d(t,"differenceInQuarters",(function(){return W})),r.d(t,"differenceInSeconds",(function(){return H})),r.d(t,"differenceInWeeks",(function(){return z})),r.d(t,"differenceInYears",(function(){return q})),r.d(t,"eachDayOfInterval",(function(){return V})),r.d(t,"eachWeekOfInterval",(function(){return G})),r.d(t,"eachWeekendOfInterval",(function(){return K})),r.d(t,"eachWeekendOfMonth",(function(){return J})),r.d(t,"eachWeekendOfYear",(function(){return te})),r.d(t,"endOfDay",(function(){return re})),r.d(t,"endOfDecade",(function(){return ne})),r.d(t,"endOfHour",(function(){return ie})),r.d(t,"endOfISOWeek",(function(){return ae})),r.d(t,"endOfISOWeekYear",(function(){return se})),r.d(t,"endOfMinute",(function(){return ue})),r.d(t,"endOfMonth",(function(){return X.a})),r.d(t,"endOfQuarter",(function(){return ce})),r.d(t,"endOfSecond",(function(){return le})),r.d(t,"endOfWeek",(function(){return oe})),r.d(t,"endOfYear",(function(){return ee})),r.d(t,"format",(function(){return fe.a})),r.d(t,"formatDistance",(function(){return ge})),r.d(t,"formatDistanceStrict",(function(){return me})),r.d(t,"formatRelative",(function(){return be})),r.d(t,"fromUnixTime",(function(){return _e})),r.d(t,"getDate",(function(){return we.a})),r.d(t,"getDay",(function(){return ve})),r.d(t,"getDayOfYear",(function(){return Ee})),r.d(t,"getDaysInMonth",(function(){return Se.a})),r.d(t,"getDaysInYear",(function(){return Te})),r.d(t,"getDecade",(function(){return Ae})),r.d(t,"getHours",(function(){return Me})),r.d(t,"getISODay",(function(){return De})),r.d(t,"getISOWeek",(function(){return Ie})),r.d(t,"getISOWeekYear",(function(){return l})),r.d(t,"getISOWeeksInYear",(function(){return je})),r.d(t,"getMilliseconds",(function(){return Re})),r.d(t,"getMinutes",(function(){return Ne})),r.d(t,"getMonth",(function(){return ke})),r.d(t,"getOverlappingDaysInIntervals",(function(){return Ce})),r.d(t,"getQuarter",(function(){return j})),r.d(t,"getSeconds",(function(){return Le})),r.d(t,"getTime",(function(){return xe})),r.d(t,"getUnixTime",(function(){return Pe})),r.d(t,"getWeek",(function(){return Fe})),r.d(t,"getWeekOfMonth",(function(){return We})),r.d(t,"getWeekYear",(function(){return Be})),r.d(t,"getWeeksInMonth",(function(){return ze})),r.d(t,"getYear",(function(){return qe})),r.d(t,"isAfter",(function(){return Ve.a})),r.d(t,"isBefore",(function(){return Ge.a})),r.d(t,"isDate",(function(){return Ye})),r.d(t,"isEqual",(function(){return $e})),r.d(t,"isFirstDayOfMonth",(function(){return Ke})),r.d(t,"isFriday",(function(){return Ze})),r.d(t,"isLastDayOfMonth",(function(){return Xe})),r.d(t,"isLeapYear",(function(){return Oe})),r.d(t,"isMonday",(function(){return Je})),r.d(t,"isSameDay",(function(){return et})),r.d(t,"isSameHour",(function(){return rt})),r.d(t,"isSameISOWeek",(function(){return it})),r.d(t,"isSameISOWeekYear",(function(){return ot})),r.d(t,"isSameMinute",(function(){return st})),r.d(t,"isSameMonth",(function(){return ut})),r.d(t,"isSameQuarter",(function(){return lt})),r.d(t,"isSameSecond",(function(){return dt})),r.d(t,"isSameWeek",(function(){return nt})),r.d(t,"isSameYear",(function(){return ht})),r.d(t,"isSaturday",(function(){return pt})),r.d(t,"isSunday",(function(){return Y})),r.d(t,"isThursday",(function(){return gt})),r.d(t,"isTuesday",(function(){return mt})),r.d(t,"isValid",(function(){return yt.a})),r.d(t,"isWednesday",(function(){return bt})),r.d(t,"isWeekend",(function(){return $})),r.d(t,"isWithinInterval",(function(){return _t})),r.d(t,"lastDayOfDecade",(function(){return wt})),r.d(t,"lastDayOfISOWeek",(function(){return Et})),r.d(t,"lastDayOfISOWeekYear",(function(){return St})),r.d(t,"lastDayOfMonth",(function(){return He})),r.d(t,"lastDayOfQuarter",(function(){return Ot})),r.d(t,"lastDayOfWeek",(function(){return vt})),r.d(t,"lastDayOfYear",(function(){return Tt})),r.d(t,"lightFormat",(function(){return jt})),r.d(t,"max",(function(){return Nt})),r.d(t,"min",(function(){return kt})),r.d(t,"parse",(function(){return Ar})),r.d(t,"parseISO",(function(){return Ir.a})),r.d(t,"roundToNearestMinutes",(function(){return jr})),r.d(t,"setDate",(function(){return Rr})),r.d(t,"setDay",(function(){return Nr})),r.d(t,"setDayOfYear",(function(){return kr})),r.d(t,"setHours",(function(){return Cr})),r.d(t,"setISODay",(function(){return Lr})),r.d(t,"setISOWeek",(function(){return xr})),r.d(t,"setISOWeekYear",(function(){return h})),r.d(t,"setMilliseconds",(function(){return Pr})),r.d(t,"setMinutes",(function(){return Br})),r.d(t,"setMonth",(function(){return Ur})),r.d(t,"setQuarter",(function(){return Fr})),r.d(t,"setSeconds",(function(){return Wr})),r.d(t,"setWeek",(function(){return Hr})),r.d(t,"setWeekYear",(function(){return zr})),r.d(t,"setYear",(function(){return qr})),r.d(t,"startOfDay",(function(){return Qe.a})),r.d(t,"startOfDecade",(function(){return Vr})),r.d(t,"startOfHour",(function(){return tt})),r.d(t,"startOfISOWeek",(function(){return c})),r.d(t,"startOfISOWeekYear",(function(){return f})),r.d(t,"startOfMinute",(function(){return at})),r.d(t,"startOfMonth",(function(){return Z.a})),r.d(t,"startOfQuarter",(function(){return ct})),r.d(t,"startOfSecond",(function(){return ft})),r.d(t,"startOfWeek",(function(){return u})),r.d(t,"startOfWeekYear",(function(){return Ue})),r.d(t,"startOfYear",(function(){return Q})),r.d(t,"subDays",(function(){return Gr.a})),r.d(t,"subHours",(function(){return Yr})),r.d(t,"subISOWeekYears",(function(){return P})),r.d(t,"subMilliseconds",(function(){return ye.a})),r.d(t,"subMinutes",(function(){return $r})),r.d(t,"subMonths",(function(){return Kr.a})),r.d(t,"subQuarters",(function(){return Zr})),r.d(t,"subSeconds",(function(){return Xr})),r.d(t,"subWeeks",(function(){return Jr.a})),r.d(t,"subYears",(function(){return Qr.a})),r.d(t,"toDate",(function(){return s.a}));var n=r(47),i=r(3),o=r(55);function a(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(i.a)(t);return Object(o.a)(e,36e5*r)}var s=r(0);function u(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var r=t||{},n=r.locale,o=n&&n.options&&n.options.weekStartsOn,a=null==o?0:Object(i.a)(o),u=null==r.weekStartsOn?a:Object(i.a)(r.weekStartsOn);if(!(u>=0&&u<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var c=Object(s.a)(e),l=c.getDay(),f=(l=i.getTime()?r+1:t.getTime()>=a.getTime()?r:r-1}function f(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=l(e),r=new Date(0);r.setFullYear(t,0,4),r.setHours(0,0,0,0);var n=c(r);return n}var d=r(46);function h(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=Object(i.a)(t),o=Object(d.a)(r,f(r)),a=new Date(0);return a.setFullYear(n,0,4),a.setHours(0,0,0,0),(r=f(a)).setDate(r.getDate()+o),r}function p(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(i.a)(t);return h(e,l(e)+r)}function g(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(i.a)(t);return Object(o.a)(e,6e4*r)}var m=r(57);function y(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(i.a)(t),n=3*r;return Object(m.a)(e,n)}function b(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(i.a)(t);return Object(o.a)(e,1e3*r)}var _=r(73),w=r(126);function v(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=e||{},n=t||{},i=Object(s.a)(r.start).getTime(),o=Object(s.a)(r.end).getTime(),a=Object(s.a)(n.start).getTime(),u=Object(s.a)(n.end).getTime();if(!(i<=o&&a<=u))throw new RangeError("Invalid interval");return i0?-1:i<0?1:i}function A(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");return l(e)-l(t)}var M=r(27);function D(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=c(e),n=c(t),i=r.getTime()-Object(M.a)(r),o=n.getTime()-Object(M.a)(n);return Math.round((i-o)/6048e5)}function I(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=Object(s.a)(t),i=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return 12*i+o}function j(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=Math.floor(t.getMonth()/3)+1;return r}function R(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=Object(s.a)(t),i=r.getFullYear()-n.getFullYear(),o=j(r)-j(n);return 4*i+o}function N(e,t,r){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var n=u(e,r),i=u(t,r),o=n.getTime()-Object(M.a)(n),a=i.getTime()-Object(M.a)(i);return Math.round((o-a)/6048e5)}function k(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=Object(s.a)(t);return r.getFullYear()-n.getFullYear()}var C=r(127);function L(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=Object(s.a)(t);return r.getTime()-n.getTime()}function x(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=L(e,t)/36e5;return r>0?Math.floor(r):Math.ceil(r)}function P(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(i.a)(t);return p(e,-r)}function B(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=Object(s.a)(t),i=Object(O.a)(r,n),o=Math.abs(A(r,n));r=P(r,i*o);var a=Object(O.a)(r,n)===-i,u=i*(o-a);return 0===u?0:u}function U(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=L(e,t)/6e4;return r>0?Math.floor(r):Math.ceil(r)}function F(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=Object(s.a)(t),i=Object(O.a)(r,n),o=Math.abs(I(r,n));r.setMonth(r.getMonth()-i*o);var a=Object(O.a)(r,n)===-i,u=i*(o-a);return 0===u?0:u}function W(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=F(e,t)/3;return r>0?Math.floor(r):Math.ceil(r)}function H(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=L(e,t)/1e3;return r>0?Math.floor(r):Math.ceil(r)}function z(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(C.a)(e,t)/7;return r>0?Math.floor(r):Math.ceil(r)}function q(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=Object(s.a)(t),i=Object(O.a)(r,n),o=Math.abs(k(r,n));r.setFullYear(r.getFullYear()-i*o);var a=Object(O.a)(r,n)===-i,u=i*(o-a);return 0===u?0:u}function V(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var r=e||{},n=Object(s.a)(r.start),i=Object(s.a)(r.end),o=i.getTime();if(!(n.getTime()<=o))throw new RangeError("Invalid interval");var a=[],u=n;u.setHours(0,0,0,0);var c=t&&"step"in t?Number(t.step):1;if(c<1||isNaN(c))throw new RangeError("`options.step` must be a number greater than 1");for(;u.getTime()<=o;)a.push(Object(s.a)(u)),u.setDate(u.getDate()+c),u.setHours(0,0,0,0);return a}function G(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var r=e||{},n=Object(s.a)(r.start),i=Object(s.a)(r.end),o=i.getTime();if(!(n.getTime()<=o))throw new RangeError("Invalid interval");var a=u(n,t),c=u(i,t);a.setHours(15),c.setHours(15),o=c.getTime();for(var l=[],f=a;f.getTime()<=o;)f.setHours(0),l.push(Object(s.a)(f)),(f=Object(_.a)(f,1)).setHours(15);return l}function Y(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return 0===Object(s.a)(e).getDay()}function $(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getDay();return 0===r||6===r}function K(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");for(var t=V(e),r=[],n=0;n++=0&&u<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var c=Object(s.a)(e),l=c.getDay(),f=6+(l0?(a=Object(s.a)(t),u=Object(s.a)(e)):(a=Object(s.a)(e),u=Object(s.a)(t));var l,f=H(u,a),d=(Object(M.a)(u)-Object(M.a)(a))/1e3,h=Math.round((f-d)/60);if(h<2)return n.includeSeconds?f<5?i.formatDistance("lessThanXSeconds",5,c):f<10?i.formatDistance("lessThanXSeconds",10,c):f<20?i.formatDistance("lessThanXSeconds",20,c):f<40?i.formatDistance("halfAMinute",null,c):f<60?i.formatDistance("lessThanXMinutes",1,c):i.formatDistance("xMinutes",1,c):0===h?i.formatDistance("lessThanXMinutes",1,c):i.formatDistance("xMinutes",h,c);if(h<45)return i.formatDistance("xMinutes",h,c);if(h<90)return i.formatDistance("aboutXHours",1,c);if(h<1440){var p=Math.round(h/60);return i.formatDistance("aboutXHours",p,c)}if(h<2520)return i.formatDistance("xDays",1,c);if(h<43200){var g=Math.round(h/1440);return i.formatDistance("xDays",g,c)}if(h<86400)return l=Math.round(h/43200),i.formatDistance("aboutXMonths",l,c);if((l=F(u,a))<12){var m=Math.round(h/43200);return i.formatDistance("xMonths",m,c)}var y=l%12,b=Math.floor(l/12);return y<3?i.formatDistance("aboutXYears",b,c):y<9?i.formatDistance("overXYears",b,c):i.formatDistance("almostXYears",b+1,c)}function me(e,t,r){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var n=r||{},i=n.locale||pe.a;if(!i.formatDistance)throw new RangeError("locale must contain localize.formatDistance property");var o=Object(O.a)(e,t);if(isNaN(o))throw new RangeError("Invalid time value");var a,u,c=he(n);c.addSuffix=Boolean(n.addSuffix),c.comparison=o,o>0?(a=Object(s.a)(t),u=Object(s.a)(e)):(a=Object(s.a)(e),u=Object(s.a)(t));var l,f=null==n.roundingMethod?"round":String(n.roundingMethod);if("floor"===f)l=Math.floor;else if("ceil"===f)l=Math.ceil;else{if("round"!==f)throw new RangeError("roundingMethod must be 'floor', 'ceil' or 'round'");l=Math.round}var d,h=H(u,a),p=(Object(M.a)(u)-Object(M.a)(a))/1e3,g=l((h-p)/60);if("second"===(d=null==n.unit?g<1?"second":g<60?"minute":g<1440?"hour":g<43200?"day":g<525600?"month":"year":String(n.unit)))return i.formatDistance("xSeconds",h,c);if("minute"===d)return i.formatDistance("xMinutes",g,c);if("hour"===d){var m=l(g/60);return i.formatDistance("xHours",m,c)}if("day"===d){var y=l(g/1440);return i.formatDistance("xDays",y,c)}if("month"===d){var b=l(g/43200);return i.formatDistance("xMonths",b,c)}if("year"===d){var _=l(g/525600);return i.formatDistance("xYears",_,c)}throw new RangeError("unit must be 'second', 'minute', 'hour', 'day', 'month' or 'year'")}var ye=r(50);function be(e,t,r){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var n=Object(s.a)(e),i=Object(s.a)(t),o=r||{},a=o.locale||pe.a;if(!a.localize)throw new RangeError("locale must contain localize property");if(!a.formatLong)throw new RangeError("locale must contain formatLong property");if(!a.formatRelative)throw new RangeError("locale must contain formatRelative property");var u,c=Object(d.a)(n,i);if(isNaN(c))throw new RangeError("Invalid time value");u=c<-6?"other":c<-1?"lastWeek":c<0?"yesterday":c<1?"today":c<2?"tomorrow":c<7?"nextWeek":"other";var l=Object(ye.a)(n,Object(M.a)(n)),f=Object(ye.a)(i,Object(M.a)(i)),h=a.formatRelative(u,l,f,o);return Object(fe.a)(n,h,o)}function _e(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(i.a)(e);return Object(s.a)(1e3*t)}var we=r(128);function ve(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getDay();return r}function Ee(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=Object(d.a)(t,Q(t)),n=r+1;return n}var Se=r(90);function Oe(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getFullYear();return r%400==0||r%4==0&&r%100!=0}function Te(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e);return isNaN(t)?NaN:Oe(t)?366:365}function Ae(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getFullYear(),n=10*Math.floor(r/10);return n}function Me(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getHours();return r}function De(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getDay();return 0===r&&(r=7),r}function Ie(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=c(t).getTime()-f(t).getTime();return Math.round(r/6048e5)+1}function je(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=f(e),r=f(Object(_.a)(t,60)),n=r.valueOf()-t.valueOf();return Math.round(n/6048e5)}function Re(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getMilliseconds();return r}function Ne(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getMinutes();return r}function ke(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getMonth();return r}function Ce(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=e||{},n=t||{},i=Object(s.a)(r.start).getTime(),o=Object(s.a)(r.end).getTime(),a=Object(s.a)(n.start).getTime(),u=Object(s.a)(n.end).getTime();if(!(i<=o&&a<=u))throw new RangeError("Invalid interval");var c=io?o:u,d=f-l;return Math.ceil(d/864e5)}function Le(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getSeconds();return r}function xe(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getTime();return r}function Pe(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return Math.floor(xe(e)/1e3)}function Be(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=r.getFullYear(),o=t||{},a=o.locale,c=a&&a.options&&a.options.firstWeekContainsDate,l=null==c?1:Object(i.a)(c),f=null==o.firstWeekContainsDate?l:Object(i.a)(o.firstWeekContainsDate);if(!(f>=1&&f<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var d=new Date(0);d.setFullYear(n+1,0,f),d.setHours(0,0,0,0);var h=u(d,t),p=new Date(0);p.setFullYear(n,0,f),p.setHours(0,0,0,0);var g=u(p,t);return r.getTime()>=h.getTime()?n+1:r.getTime()>=g.getTime()?n:n-1}function Ue(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var r=t||{},n=r.locale,o=n&&n.options&&n.options.firstWeekContainsDate,a=null==o?1:Object(i.a)(o),s=null==r.firstWeekContainsDate?a:Object(i.a)(r.firstWeekContainsDate),c=Be(e,t),l=new Date(0);l.setFullYear(c,0,s),l.setHours(0,0,0,0);var f=u(l,t);return f}function Fe(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=u(r,t).getTime()-Ue(r,t).getTime();return Math.round(n/6048e5)+1}function We(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var r=t||{},n=r.locale,o=n&&n.options&&n.options.weekStartsOn,a=null==o?0:Object(i.a)(o),s=null==r.weekStartsOn?a:Object(i.a)(r.weekStartsOn);if(!(s>=0&&s<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var u=ve(Object(Z.a)(e)),c=ve(e),l=uc?7-s:0;return Math.ceil((Object(we.a)(e)+f)/7)}function He(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(0,0,0,0),t}function ze(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return N(He(e),Object(Z.a)(e),t)+1}function qe(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getFullYear();return r}var Ve=r(168),Ge=r(107);function Ye(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e)}function $e(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=Object(s.a)(t);return r.getTime()===n.getTime()}function Ke(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return 1===Object(s.a)(e).getDate()}function Ze(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return 5===Object(s.a)(e).getDay()}function Xe(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e);return re(t).getTime()===Object(X.a)(t).getTime()}function Je(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return 1===Object(s.a)(e).getDay()}var Qe=r(74);function et(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(Qe.a)(e),n=Object(Qe.a)(t);return r.getTime()===n.getTime()}function tt(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e);return t.setMinutes(0,0,0),t}function rt(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=tt(e),n=tt(t);return r.getTime()===n.getTime()}function nt(e,t,r){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var n=u(e,r),i=u(t,r);return n.getTime()===i.getTime()}function it(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");return nt(e,t,{weekStartsOn:1})}function ot(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=f(e),n=f(t);return r.getTime()===n.getTime()}function at(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e);return t.setSeconds(0,0),t}function st(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=at(e),n=at(t);return r.getTime()===n.getTime()}function ut(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=Object(s.a)(t);return r.getFullYear()===n.getFullYear()&&r.getMonth()===n.getMonth()}function ct(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getMonth(),n=r-r%3;return t.setMonth(n,1),t.setHours(0,0,0,0),t}function lt(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=ct(e),n=ct(t);return r.getTime()===n.getTime()}function ft(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e);return t.setMilliseconds(0),t}function dt(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=ft(e),n=ft(t);return r.getTime()===n.getTime()}function ht(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=Object(s.a)(t);return r.getFullYear()===n.getFullYear()}function pt(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return 6===Object(s.a)(e).getDay()}function gt(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return 4===Object(s.a)(e).getDay()}function mt(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return 2===Object(s.a)(e).getDay()}var yt=r(66);function bt(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return 3===Object(s.a)(e).getDay()}function _t(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=t||{},n=Object(s.a)(e).getTime(),i=Object(s.a)(r.start).getTime(),o=Object(s.a)(r.end).getTime();if(!(i<=o))throw new RangeError("Invalid interval");return n>=i&&n<=o}function wt(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(s.a)(e),r=t.getFullYear(),n=9+10*Math.floor(r/10);return t.setFullYear(n+1,0,0),t.setHours(0,0,0,0),t}function vt(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var r=t||{},n=r.locale,o=n&&n.options&&n.options.weekStartsOn,a=null==o?0:Object(i.a)(o),u=null==r.weekStartsOn?a:Object(i.a)(r.weekStartsOn);if(!(u>=0&&u<=6))throw new RangeError("weekStartsOn must be between 0 and 6");var c=Object(s.a)(e),l=c.getDay(),f=6+(lr||isNaN(r))&&(t=r)})),t}var Ct=r(92);function Lt(e,t,r){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var n=r||{},o=n.locale,a=o&&o.options&&o.options.weekStartsOn,u=null==a?0:Object(i.a)(a),c=null==n.weekStartsOn?u:Object(i.a)(n.weekStartsOn);if(!(c>=0&&c<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var l=Object(s.a)(e),f=Object(i.a)(t),d=l.getUTCDay(),h=f%7,p=(h+7)%7,g=(p0,i=n?t:1-t;if(i<=50)r=e||100;else{var o=i+50;r=e+100*Math.floor(o/100)-(e>=o%100?100:0)}return n?r:1-r}var yr=[31,28,31,30,31,30,31,31,30,31,30,31],br=[31,29,31,30,31,30,31,31,30,31,30,31];function _r(e){return e%400==0||e%4==0&&e%100!=0}var wr={G:{priority:140,parse:function(e,t,r,n){switch(t){case"G":case"GG":case"GGG":return r.era(e,{width:"abbreviated"})||r.era(e,{width:"narrow"});case"GGGGG":return r.era(e,{width:"narrow"});case"GGGG":default:return r.era(e,{width:"wide"})||r.era(e,{width:"abbreviated"})||r.era(e,{width:"narrow"})}},set:function(e,t,r,n){return e.setUTCFullYear(1===r?10:-9,0,1),e.setUTCHours(0,0,0,0),e}},y:{priority:130,parse:function(e,t,r,n){var i=function(e){return{year:e,isTwoDigitYear:"yy"===t}};switch(t){case"y":return hr(4,e,i);case"yo":return r.ordinalNumber(e,{unit:"year",valueCallback:i});default:return hr(t.length,e,i)}},validate:function(e,t,r){return t.isTwoDigitYear||t.year>0},set:function(e,t,r,n){var i=Object(Ct.a)(e,n);if(r.isTwoDigitYear){var o=mr(r.year,i);return e.setUTCFullYear(o,0,1),e.setUTCHours(0,0,0,0),e}var a=i>0?r.year:1-r.year;return e.setUTCFullYear(a,0,1),e.setUTCHours(0,0,0,0),e}},Y:{priority:130,parse:function(e,t,r,n){var i=function(e){return{year:e,isTwoDigitYear:"YY"===t}};switch(t){case"Y":return hr(4,e,i);case"Yo":return r.ordinalNumber(e,{unit:"year",valueCallback:i});default:return hr(t.length,e,i)}},validate:function(e,t,r){return t.isTwoDigitYear||t.year>0},set:function(e,t,r,n){var i=e.getUTCFullYear();if(r.isTwoDigitYear){var o=mr(r.year,i);return e.setUTCFullYear(o,0,n.firstWeekContainsDate),e.setUTCHours(0,0,0,0),Object(Pt.a)(e,n)}var a=i>0?r.year:1-r.year;return e.setUTCFullYear(a,0,n.firstWeekContainsDate),e.setUTCHours(0,0,0,0),Object(Pt.a)(e,n)}},R:{priority:130,parse:function(e,t,r,n){return pr("R"===t?4:t.length,e)},set:function(e,t,r,n){var i=new Date(0);return i.setUTCFullYear(r,0,4),i.setUTCHours(0,0,0,0),Object(Ut.a)(i)}},u:{priority:130,parse:function(e,t,r,n){return pr("u"===t?4:t.length,e)},set:function(e,t,r,n){return e.setUTCFullYear(r,0,1),e.setUTCHours(0,0,0,0),e}},Q:{priority:120,parse:function(e,t,r,n){switch(t){case"Q":case"QQ":return hr(t.length,e);case"Qo":return r.ordinalNumber(e,{unit:"quarter"});case"QQQ":return r.quarter(e,{width:"abbreviated",context:"formatting"})||r.quarter(e,{width:"narrow",context:"formatting"});case"QQQQQ":return r.quarter(e,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(e,{width:"wide",context:"formatting"})||r.quarter(e,{width:"abbreviated",context:"formatting"})||r.quarter(e,{width:"narrow",context:"formatting"})}},validate:function(e,t,r){return t>=1&&t<=4},set:function(e,t,r,n){return e.setUTCMonth(3*(r-1),1),e.setUTCHours(0,0,0,0),e}},q:{priority:120,parse:function(e,t,r,n){switch(t){case"q":case"qq":return hr(t.length,e);case"qo":return r.ordinalNumber(e,{unit:"quarter"});case"qqq":return r.quarter(e,{width:"abbreviated",context:"standalone"})||r.quarter(e,{width:"narrow",context:"standalone"});case"qqqqq":return r.quarter(e,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(e,{width:"wide",context:"standalone"})||r.quarter(e,{width:"abbreviated",context:"standalone"})||r.quarter(e,{width:"narrow",context:"standalone"})}},validate:function(e,t,r){return t>=1&&t<=4},set:function(e,t,r,n){return e.setUTCMonth(3*(r-1),1),e.setUTCHours(0,0,0,0),e}},M:{priority:110,parse:function(e,t,r,n){var i=function(e){return e-1};switch(t){case"M":return lr(Ft,e,i);case"MM":return hr(2,e,i);case"Mo":return r.ordinalNumber(e,{unit:"month",valueCallback:i});case"MMM":return r.month(e,{width:"abbreviated",context:"formatting"})||r.month(e,{width:"narrow",context:"formatting"});case"MMMMM":return r.month(e,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(e,{width:"wide",context:"formatting"})||r.month(e,{width:"abbreviated",context:"formatting"})||r.month(e,{width:"narrow",context:"formatting"})}},validate:function(e,t,r){return t>=0&&t<=11},set:function(e,t,r,n){return e.setUTCMonth(r,1),e.setUTCHours(0,0,0,0),e}},L:{priority:110,parse:function(e,t,r,n){var i=function(e){return e-1};switch(t){case"L":return lr(Ft,e,i);case"LL":return hr(2,e,i);case"Lo":return r.ordinalNumber(e,{unit:"month",valueCallback:i});case"LLL":return r.month(e,{width:"abbreviated",context:"standalone"})||r.month(e,{width:"narrow",context:"standalone"});case"LLLLL":return r.month(e,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(e,{width:"wide",context:"standalone"})||r.month(e,{width:"abbreviated",context:"standalone"})||r.month(e,{width:"narrow",context:"standalone"})}},validate:function(e,t,r){return t>=0&&t<=11},set:function(e,t,r,n){return e.setUTCMonth(r,1),e.setUTCHours(0,0,0,0),e}},w:{priority:100,parse:function(e,t,r,n){switch(t){case"w":return lr(zt,e);case"wo":return r.ordinalNumber(e,{unit:"week"});default:return hr(t.length,e)}},validate:function(e,t,r){return t>=1&&t<=53},set:function(e,t,r,n){return Object(Pt.a)(function(e,t,r){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var n=Object(s.a)(e),o=Object(i.a)(t),a=Object(xt.a)(n,r)-o;return n.setUTCDate(n.getUTCDate()-7*a),n}(e,r,n),n)}},I:{priority:100,parse:function(e,t,r,n){switch(t){case"I":return lr(zt,e);case"Io":return r.ordinalNumber(e,{unit:"week"});default:return hr(t.length,e)}},validate:function(e,t,r){return t>=1&&t<=53},set:function(e,t,r,n){return Object(Ut.a)(function(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=Object(i.a)(t),o=Object(Bt.a)(r)-n;return r.setUTCDate(r.getUTCDate()-7*o),r}(e,r,n),n)}},d:{priority:90,parse:function(e,t,r,n){switch(t){case"d":return lr(Wt,e);case"do":return r.ordinalNumber(e,{unit:"date"});default:return hr(t.length,e)}},validate:function(e,t,r){var n=_r(e.getUTCFullYear()),i=e.getUTCMonth();return n?t>=1&&t<=br[i]:t>=1&&t<=yr[i]},set:function(e,t,r,n){return e.setUTCDate(r),e.setUTCHours(0,0,0,0),e}},D:{priority:90,parse:function(e,t,r,n){switch(t){case"D":case"DD":return lr(Ht,e);case"Do":return r.ordinalNumber(e,{unit:"date"});default:return hr(t.length,e)}},validate:function(e,t,r){return _r(e.getUTCFullYear())?t>=1&&t<=366:t>=1&&t<=365},set:function(e,t,r,n){return e.setUTCMonth(0,r),e.setUTCHours(0,0,0,0),e}},E:{priority:90,parse:function(e,t,r,n){switch(t){case"E":case"EE":case"EEE":return r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"EEEEE":return r.day(e,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"EEEE":default:return r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"})}},validate:function(e,t,r){return t>=0&&t<=6},set:function(e,t,r,n){return(e=Lt(e,r,n)).setUTCHours(0,0,0,0),e}},e:{priority:90,parse:function(e,t,r,n){var i=function(e){var t=7*Math.floor((e-1)/7);return(e+n.weekStartsOn+6)%7+t};switch(t){case"e":case"ee":return hr(t.length,e,i);case"eo":return r.ordinalNumber(e,{unit:"day",valueCallback:i});case"eee":return r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"eeeee":return r.day(e,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"eeee":default:return r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"})}},validate:function(e,t,r){return t>=0&&t<=6},set:function(e,t,r,n){return(e=Lt(e,r,n)).setUTCHours(0,0,0,0),e}},c:{priority:90,parse:function(e,t,r,n){var i=function(e){var t=7*Math.floor((e-1)/7);return(e+n.weekStartsOn+6)%7+t};switch(t){case"c":case"cc":return hr(t.length,e,i);case"co":return r.ordinalNumber(e,{unit:"day",valueCallback:i});case"ccc":return r.day(e,{width:"abbreviated",context:"standalone"})||r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"});case"ccccc":return r.day(e,{width:"narrow",context:"standalone"});case"cccccc":return r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"});case"cccc":default:return r.day(e,{width:"wide",context:"standalone"})||r.day(e,{width:"abbreviated",context:"standalone"})||r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"})}},validate:function(e,t,r){return t>=0&&t<=6},set:function(e,t,r,n){return(e=Lt(e,r,n)).setUTCHours(0,0,0,0),e}},i:{priority:90,parse:function(e,t,r,n){var i=function(e){return 0===e?7:e};switch(t){case"i":case"ii":return hr(t.length,e);case"io":return r.ordinalNumber(e,{unit:"day"});case"iii":return r.day(e,{width:"abbreviated",context:"formatting",valueCallback:i})||r.day(e,{width:"short",context:"formatting",valueCallback:i})||r.day(e,{width:"narrow",context:"formatting",valueCallback:i});case"iiiii":return r.day(e,{width:"narrow",context:"formatting",valueCallback:i});case"iiiiii":return r.day(e,{width:"short",context:"formatting",valueCallback:i})||r.day(e,{width:"narrow",context:"formatting",valueCallback:i});case"iiii":default:return r.day(e,{width:"wide",context:"formatting",valueCallback:i})||r.day(e,{width:"abbreviated",context:"formatting",valueCallback:i})||r.day(e,{width:"short",context:"formatting",valueCallback:i})||r.day(e,{width:"narrow",context:"formatting",valueCallback:i})}},validate:function(e,t,r){return t>=1&&t<=7},set:function(e,t,r,n){return(e=function(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(i.a)(t);r%7==0&&(r-=7);var n=1,o=Object(s.a)(e),a=o.getUTCDay(),u=r%7,c=(u+7)%7,l=(c=1&&t<=12},set:function(e,t,r,n){var i=e.getUTCHours()>=12;return i&&r<12?e.setUTCHours(r+12,0,0,0):i||12!==r?e.setUTCHours(r,0,0,0):e.setUTCHours(0,0,0,0),e}},H:{priority:70,parse:function(e,t,r,n){switch(t){case"H":return lr(qt,e);case"Ho":return r.ordinalNumber(e,{unit:"hour"});default:return hr(t.length,e)}},validate:function(e,t,r){return t>=0&&t<=23},set:function(e,t,r,n){return e.setUTCHours(r,0,0,0),e}},K:{priority:70,parse:function(e,t,r,n){switch(t){case"K":return lr(Gt,e);case"Ko":return r.ordinalNumber(e,{unit:"hour"});default:return hr(t.length,e)}},validate:function(e,t,r){return t>=0&&t<=11},set:function(e,t,r,n){return e.getUTCHours()>=12&&r<12?e.setUTCHours(r+12,0,0,0):e.setUTCHours(r,0,0,0),e}},k:{priority:70,parse:function(e,t,r,n){switch(t){case"k":return lr(Vt,e);case"ko":return r.ordinalNumber(e,{unit:"hour"});default:return hr(t.length,e)}},validate:function(e,t,r){return t>=1&&t<=24},set:function(e,t,r,n){var i=r<=24?r%24:r;return e.setUTCHours(i,0,0,0),e}},m:{priority:60,parse:function(e,t,r,n){switch(t){case"m":return lr($t,e);case"mo":return r.ordinalNumber(e,{unit:"minute"});default:return hr(t.length,e)}},validate:function(e,t,r){return t>=0&&t<=59},set:function(e,t,r,n){return e.setUTCMinutes(r,0,0),e}},s:{priority:50,parse:function(e,t,r,n){switch(t){case"s":return lr(Kt,e);case"so":return r.ordinalNumber(e,{unit:"second"});default:return hr(t.length,e)}},validate:function(e,t,r){return t>=0&&t<=59},set:function(e,t,r,n){return e.setUTCSeconds(r,0),e}},S:{priority:30,parse:function(e,t,r,n){return hr(t.length,e,(function(e){return Math.floor(e*Math.pow(10,3-t.length))}))},set:function(e,t,r,n){return e.setUTCMilliseconds(r),e}},X:{priority:10,parse:function(e,t,r,n){switch(t){case"X":return fr(or,e);case"XX":return fr(ar,e);case"XXXX":return fr(sr,e);case"XXXXX":return fr(cr,e);case"XXX":default:return fr(ur,e)}},set:function(e,t,r,n){return t.timestampIsSet?e:new Date(e.getTime()-r)}},x:{priority:10,parse:function(e,t,r,n){switch(t){case"x":return fr(or,e);case"xx":return fr(ar,e);case"xxxx":return fr(sr,e);case"xxxxx":return fr(cr,e);case"xxx":default:return fr(ur,e)}},set:function(e,t,r,n){return t.timestampIsSet?e:new Date(e.getTime()-r)}},t:{priority:40,parse:function(e,t,r,n){return dr(e)},set:function(e,t,r,n){return[new Date(1e3*r),{timestampIsSet:!0}]}},T:{priority:20,parse:function(e,t,r,n){return dr(e)},set:function(e,t,r,n){return[new Date(r),{timestampIsSet:!0}]}}},vr=r(94),Er=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Sr=/^'(.*?)'?$/,Or=/''/g,Tr=/\S/;function Ar(e,t,r,n){if(arguments.length<3)throw new TypeError("3 arguments required, but only "+arguments.length+" present");var o=String(e),a=String(t),u=n||{},c=u.locale||pe.a;if(!c.match)throw new RangeError("locale must contain match property");var l=c.options&&c.options.firstWeekContainsDate,f=null==l?1:Object(i.a)(l),d=null==u.firstWeekContainsDate?f:Object(i.a)(u.firstWeekContainsDate);if(!(d>=1&&d<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var h=c.options&&c.options.weekStartsOn,p=null==h?0:Object(i.a)(h),g=null==u.weekStartsOn?p:Object(i.a)(u.weekStartsOn);if(!(g>=0&&g<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(""===a)return""===o?Object(s.a)(r):new Date(NaN);var m,y={firstWeekContainsDate:d,weekStartsOn:g,locale:c},b=[{priority:10,set:Mr,index:0}],_=a.match(Er);for(m=0;m<_.length;m++){var w=_[m];!u.awareOfUnicodeTokens&&Object(vr.a)(w)&&Object(vr.b)(w);var v=w[0],E=wr[v];if(E){var S=E.parse(o,w,c.match,y);if(!S)return new Date(NaN);b.push({priority:E.priority,set:E.set,validate:E.validate,value:S.value,index:b.length}),o=S.rest}else{if("''"===w?w="'":"'"===v&&(w=Dr(w)),0!==o.indexOf(w))return new Date(NaN);o=o.slice(w.length)}}if(o.length>0&&Tr.test(o))return new Date(NaN);var O=b.map((function(e){return e.priority})).sort((function(e,t){return t-e})).filter((function(e,t,r){return r.indexOf(e)===t})).map((function(e){return b.filter((function(t){return t.priority===e})).reverse()})).map((function(e){return e[0]})),T=Object(s.a)(r);if(isNaN(T))return new Date(NaN);var A=Object(ye.a)(T,Object(M.a)(T)),D={};for(m=0;m30)throw new RangeError("`options.nearestTo` must be between 1 and 30");var n=Object(s.a)(e),o=n.getSeconds(),a=n.getMinutes()+o/60,u=Math.floor(a/r)*r,c=a%r,l=Math.round(c/r)*r;return new Date(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),u+l)}function Rr(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(s.a)(e),n=Object(i.a)(t);return r.setDate(n),r}function Nr(e,t,r){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var o=r||{},a=o.locale,u=a&&a.options&&a.options.weekStartsOn,c=null==u?0:Object(i.a)(u),l=null==o.weekStartsOn?c:Object(i.a)(o.weekStartsOn);if(!(l>=0&&l<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var f=Object(s.a)(e,o),d=Object(i.a)(t),h=f.getDay(),p=d%7,g=(p+7)%7,m=(ga[r]&&a[r].fields&&a[r].fields[e]||e;return Object.fromEntries(Object.keys(n).map(e=>{if("_"===e[0])return null;let t=o[e];if(null==t)throw new Error(`Field "${e}" does not exist on table ${r}: ${JSON.stringify(n)}`);if(u(e,t)&&null==n[e])throw new Error(`"${e}" is required for table "${r}": ${JSON.stringify(n)}`);return i&&null==n[e]?null:[s(e),c(n[e],t.type)]}).filter(Boolean))}function d(e,t,r,n){let i=a({},n),o=e[r];if(null==o)throw new Error(`Error inserting: table "${r}" does not exist`);return Object.keys(o).forEach(e=>{let t=o[e];if(null==i[e])if(void 0!==t.default)i[e]="function"==typeof t.default?t.default():t.default;else if(u(e,t))throw new Error(`"${e}" is required for table "${r}": ${JSON.stringify(i)}`)}),f(e,t,r,i,{skipNull:!0})}function h(e,t,r,n){let i=a({},n);if(null==e[r])throw new Error(`Error updating: table "${r}" does not exist`);return f(e,t,r,i)}function p(e,t,r,n){let i=e[r];if(null==i)throw new Error(`Table "${r}" does not exist`);let o=Object.keys(i),a={};for(let e=0;ei.selectWithSchema("transactions",e,t),e,e=>`id = '${e}'`,e=>"SELECT * FROM v_transactions_internal WHERE "+e)}async function l({added:e,deleted:t,updated:r,learnCategories:l=!1,detectOrphanPayees:f=!0}){let d=[],h=r?r.map(e=>e.id):[],p=t?await async function(e){let t=Object(o.b)(e,"parent_id"),r=await i.all("SELECT id FROM v_transactions_internal WHERE "+t),n=new Set(e);for(let e of r)n.add(e.id);return[...n]}(t.map(e=>e.id)):[],g=new Set,m=await i.all("SELECT * FROM accounts WHERE tombstone = 0");if(r){let e=r.filter(e=>e.payee).map(e=>e.id),t=await c(e);for(let e=0;e{e&&(d=await Promise.all(e.map(async e=>i.insertTransaction(e)))),t&&await Promise.all(p.map(async e=>{await i.deleteTransaction({id:e})})),r&&await Promise.all(r.map(async e=>{if(e.account){1===m.find(t=>t.id===e.account).offbudget&&(e.category=null)}await i.updateTransaction(e)}))});let y,b=await c(d),_=await c(h),w=await c(p),v=b;if(await Object(n.c)(async()=>{await Promise.all(b.map(e=>a.b(e))),y=(await Promise.all(_.map(e=>a.c(e)))).filter(Boolean),await Promise.all(w.map(e=>a.a(e)))}),l){let t=new Set([...e?e.filter(e=>e.category).map(e=>e.id):[],...r?r.filter(e=>e.category).map(e=>e.id):[]]);await s.l(b.concat(_).filter(e=>t.has(e.id)))}if(f&&r){let e=r.map(e=>e.payee).filter(Boolean);if(e.length>0){let t=new Set(await i.getOrphanedPayees()),r=[...g].filter(e=>t.has(e));r.length>0&&u.send("orphaned-payees",{orphanedIds:r,updatedPayeeIds:e})}}return{added:v,updated:y}}},function(e,t,r){"use strict";t.a={info:(...e)=>{console.log(...e)},warn:(...e)=>{console.warn(...e)}}},function(e,t,r){"use strict";var n=r(16).Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=l,this.end=f,t=3;break;default:return this.write=d,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function d(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}t.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,r){var n=r(16).Buffer,i=r(99).Transform,o=r(70).StringDecoder;function a(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(11)(a,i),a.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},a.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},a.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},a.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},e.exports=a},function(e,t,r){"use strict";var n=r(122);e.exports=function(){return n()&&!!Symbol.toStringTag}},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(3),i=r(47);function o(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(n.a)(t),o=7*r;return Object(i.a)(e,o)}},function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(0);function i(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(n.a)(e);return t.setHours(0,0,0,0),t}},function(e,t,r){"use strict";function n(e){return Object.keys(e).filter(e=>"hash"!==e)}function i(e){let t=e+"0".repeat(16-e.length);return 1e3*parseInt(t,3)*60}function o(e,t){let r=t.hash(),n=Number(t.millis()/1e3/60|0).toString(3);return function e(t,r,n){if(0===r.length)return t;const i=r[0],o=t[i]||{};return Object.assign({},t,{[i]:Object.assign({},o,e(o,r.slice(1),n),{hash:o.hash^n})})}(e=Object.assign({},e,{hash:e.hash^r}),n,r)}function a(e){let t={};for(let r of e)o(t,r);return t}function s(e,t){if(e.hash===t.hash)return null;let r=e,o=t,a="";for(;;){let e=[...new Set([...n(r),...n(o)]).values()];e.sort();let t=null;for(let n=0;ni[r]=u(e[r],t)),i}function c(e,t="",r=0){return" ".repeat(r)+(""!==t?`k: ${t} `:"")+`hash: ${e.hash||"(empty)"}\n`+n(e).map(t=>c(e[t],t,r+2)).join("")}r.r(t),r.d(t,"getKeys",(function(){return n})),r.d(t,"keyToTimestamp",(function(){return i})),r.d(t,"insert",(function(){return o})),r.d(t,"build",(function(){return a})),r.d(t,"diff",(function(){return s})),r.d(t,"prune",(function(){return u})),r.d(t,"debug",(function(){return c}))},function(e,t,r){"use strict";(function(e){r.d(t,"f",(function(){return i})),r.d(t,"e",(function(){return o})),r.d(t,"c",(function(){return a})),r.d(t,"b",(function(){return s})),r.d(t,"a",(function(){return u})),r.d(t,"d",(function(){return c}));function n(e){switch(e){case"aes-256-gcm":return"AES-GCM";default:throw new Error("unsupported crypto algorithm: "+e)}}async function i(e){let t=new TextEncoder("utf-8").encode(e).buffer,r=await crypto.subtle.digest("sha-256",t),n=Array.from(new Uint8Array(r)).map(e=>String.fromCharCode(e)).join("");return btoa(n)}function o(t){return e.from(crypto.getRandomValues(new Uint8Array(t)))}async function a(t,r){let i=crypto.getRandomValues(new Uint8Array(12)),o=await crypto.subtle.encrypt({name:n("aes-256-gcm"),iv:i,tagLength:128},t.getValue().raw,r);o=e.from(o);let a=o.slice(-16);return o=o.slice(0,-16),{value:o,meta:{keyId:t.getId(),algorithm:"aes-256-gcm",iv:e.from(i).toString("base64"),authTag:a.toString("base64")}}}async function s(t,r,i){let o=i.algorithm,a=i.iv,s=i.authTag,u=await crypto.subtle.decrypt({name:n(o),iv:e.from(a,"base64"),tagLength:128},t.getValue().raw,e.concat([r,e.from(s,"base64")]));return e.from(u)}async function u({secret:t,salt:r}){let n=e.from(t),i=e.from(r),o=await crypto.subtle.importKey("raw",n,{name:"PBKDF2"},!1,["deriveBits","deriveKey"]),a=await crypto.subtle.deriveKey({name:"PBKDF2",hash:"SHA-512",salt:i,iterations:1e4},o,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),s=await crypto.subtle.exportKey("raw",a);return{raw:a,base64:e.from(s).toString("base64")}}async function c(t){return{raw:await crypto.subtle.importKey("raw",e.from(t,"base64"),{name:"AES-GCM"},!1,["encrypt","decrypt"]),base64:t}}}).call(this,r(10).Buffer)},function(e,t,r){"use strict";r.d(t,"b",(function(){return d})),r.d(t,"c",(function(){return h})),r.d(t,"d",(function(){return p})),r.d(t,"e",(function(){return b})),r.d(t,"a",(function(){return _}));var n=r(12);const i=["subtransactions"];function o(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;te+l(t.amount),0);return s(s({},e),{},{error:t===l(e.amount)?null:f(t,e)})}function p(e){return e.reduce((e,t)=>{let r=t.subtransactions,n=o(t,i);r=r||[],e.push(n);for(let t=0;te.id===t),o=e[i],a=[...e];if(-1===i)throw new Error("Tried to edit unknown transaction id: "+t);if(o.is_parent||o.is_child){let t=function(e,t){for(;t>=0;){if(e[t].is_parent)return t;t--}return null}(e,i);if(null==t)return console.log("Cannot find parent index"),{diff:{deleted:[],updated:[]}};let o,s=function(e,t){let r=[e[t]],n=t+1;for(;n{if(e.is_parent){let r=e.id===t.id?t:e,n=e.subtransactions.map(n=>{let i=n;return e.id===t.id?i=s(s({},n),{},{payee:n.payee===e.payee?t.payee:n.payee}):n.id===t.id&&(i=t),d(r,i)});return h(s(s({},r),{},{subtransactions:n}))}return t})}function _(e,t){return y(e,t,e=>{if(e.is_parent){if(e.id===t)return null;if(1===e.subtransactions.length)return s(s({},e),{},{subtransactions:null,is_parent:!1,error:null});{let r=e.subtransactions.filter(e=>e.id!==t);return h(s(s({},e),{},{subtransactions:r}))}}return null})}},function(e,t,r){"use strict";var n=function(e,t){return e===t};t.a=function(e,t){var r;void 0===t&&(t=n);var i,o=[],a=!1,s=function(e,r){return t(e,o[r],r)};return function(){for(var t=arguments.length,n=new Array(t),u=0;u1&&"boolean"!=typeof t)throw new o('"allowMissing" argument must be a boolean');var r=O(e),i=r.length>0?r[0]:"",a=T("%"+i+"%",t),u=a.name,c=a.value,l=!1,f=a.alias;f&&(i=f[0],_(r,b([0,1],f)));for(var d=1,h=!0;d=r.length){var E=s(c,g);c=(h=!!E)&&"get"in E&&!("originalValue"in E.get)?E.get:c[g]}else h=y(c,g),c=c[g];h&&!l&&(p[u]=c)}}return c}},function(e,t,r){"use strict";var n=r(165),i="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),o=Object.prototype.toString,a=Array.prototype.concat,s=Object.defineProperty,u=s&&function(){var e={};try{for(var t in s(e,"x",{enumerable:!1,value:e}),e)return!1;return e.x===e}catch(e){return!1}}(),c=function(e,t,r,n){var i;(!(t in e)||"function"==typeof(i=n)&&"[object Function]"===o.call(i)&&n())&&(u?s(e,t,{configurable:!0,enumerable:!1,value:r,writable:!0}):e[t]=r)},l=function(e,t){var r=arguments.length>2?arguments[2]:{},o=n(t);i&&(o=a.call(o,Object.getOwnPropertySymbols(t)));for(var s=0;s4294967295)throw new RangeError("requested too many random bytes");var r=i.allocUnsafe(e);if(e>0)if(e>65536)for(var a=0;a2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,i,a,s;if("string"==typeof t&&(i="not ",t.substr(!a||a<0?0:+a,i.length)===i)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))s="The ".concat(e," ").concat(n," ").concat(o(t,"type"));else{var u=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";s='The "'.concat(e,'" ').concat(u," ").concat(n," ").concat(o(t,"type"))}return s+=". Received type ".concat(typeof r)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},function(e,t,r){"use strict";(function(t){var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=c;var i=r(192),o=r(196);r(11)(c,i);for(var a=n(o.prototype),s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=i},function(e,t,r){"use strict";var n={};function i(e,t,r){r||(r=Error);var i=function(e){var r,n;function i(r,n,i){return e.call(this,function(e,r,n){return"string"==typeof t?t:t(e,r,n)}(r,n,i))||this}return n=e,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=e,n[e]=i}function o(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,i,a,s;if("string"==typeof t&&(i="not ",t.substr(!a||a<0?0:+a,i.length)===i)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))s="The ".concat(e," ").concat(n," ").concat(o(t,"type"));else{var u=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";s='The "'.concat(e,'" ').concat(u," ").concat(n," ").concat(o(t,"type"))}return s+=". Received type ".concat(typeof r)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},function(e,t,r){"use strict";(function(t){var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=c;var i=r(217),o=r(221);r(11)(c,i);for(var a=n(o.prototype),s=0;s0){const e=t.queue.shift();n(e.args,e.resolve,e.reject)}else t.running=null}function n(n,i,o){t.running=e(...n),t.running.then(e=>{r(),i(e)},e=>{r(),o(e)})}return(...e)=>t.running?new Promise((r,n)=>{t.queue.push({resolve:r,reject:n,args:e})}):new Promise((t,r)=>n(e,t,r))}function i(e){let t=null;return(...r)=>t||(t=e(...r).finally(()=>{t=null}),t)}r.r(t),r.d(t,"sequential",(function(){return n})),r.d(t,"once",(function(){return i}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(3),i=r(0),o=r(51);function a(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var r=Object(i.a)(e,t),a=r.getUTCFullYear(),s=t||{},u=s.locale,c=u&&u.options&&u.options.firstWeekContainsDate,l=null==c?1:Object(n.a)(c),f=null==s.firstWeekContainsDate?l:Object(n.a)(s.firstWeekContainsDate);if(!(f>=1&&f<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var d=new Date(0);d.setUTCFullYear(a+1,0,f),d.setUTCHours(0,0,0,0);var h=Object(o.a)(d,t),p=new Date(0);p.setUTCFullYear(a,0,f),p.setUTCHours(0,0,0,0);var g=Object(o.a)(p,t);return r.getTime()>=h.getTime()?a+1:r.getTime()>=g.getTime()?a:a-1}},function(e,t,r){"use strict";r.d(t,"a",(function(){return Ce}));class n extends Error{}let i;class o{constructor(e,t){if(this.duration=t&&t.duration||0,this.generators=t&&t.generators&&t.generators.slice()||[],!Number.isInteger(this.duration)||this.duration<0)throw new n("duration must be a non-negative integer")}static set adapter(e){if(i)throw new Error(`"${i.name}" has already been configured.`);i=e}static get adapter(){if(!i)throw new Error("No date adapter has been configured. See rSchedule docs.");return i}static isDate(e){throw a("isDate()")}static fromDate(e,t){throw a("fromDate()")}static fromJSON(e){throw a("fromJSON()")}static fromDateTime(e){throw a("fromDateTime()")}toISOString(){return this.set("timezone","UTC").toDateTime().toISOString()}toDateTime(){return c.fromJSON(Object.assign(Object.assign({},this.toJSON()),{generators:this.generators}))}}function a(e){return new Error(`You must implement the "${e}" method for this DateAdapter class`)}var s;o.hasTimezoneSupport=!1,function(e){e.WEEKDAYS=["SU","MO","TU","WE","TH","FR","SA"],e.MILLISECONDS_IN_SECOND=1e3,e.MILLISECONDS_IN_MINUTE=60*e.MILLISECONDS_IN_SECOND,e.MILLISECONDS_IN_HOUR=60*e.MILLISECONDS_IN_MINUTE,e.MILLISECONDS_IN_DAY=24*e.MILLISECONDS_IN_HOUR,e.MILLISECONDS_IN_WEEK=7*e.MILLISECONDS_IN_DAY}(s||(s={}));class u extends Error{}class c{constructor(e,t,r,n){if(this.date=new Date(e),this.timezone=t||null,this.duration=r||0,this.generators=n&&n.slice()||[],!Number.isInteger(this.duration)||this.duration<0)throw new u("duration must be a non-negative integer");this.assertIsValid()}static fromJSON(e){const t=new Date(Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond));return new c(t,e.timezone,e.duration,e.generators)}static fromDateAdapter(e){return c.fromJSON(Object.assign(Object.assign({},e.toJSON()),{generators:e.generators}))}get end(){if(this.duration)return this._end||(this._end=this.add(this.duration,"millisecond")),this._end}isEqual(e){return!!e&&(l(this,e),this.valueOf()===e.valueOf())}isBefore(e){return l(this,e),this.valueOf()e.valueOf()}isAfterOrEqual(e){return l(this,e),this.valueOf()>=e.valueOf()}isOccurring(e){if(!this.duration)throw new Error("DateTime#isOccurring() is only applicable to DateTimes with durations");return l(this,e),e.isAfterOrEqual(this)&&e.isBeforeOrEqual(this.add(this.duration,"millisecond"))}add(e,t){switch(t){case"generator":{const t=this.generators.slice();return t.unshift(e),new c(this.date,this.timezone,this.duration,t)}case"year":return this.forkDateTime(v(this.date,e));case"month":return this.forkDateTime(E(this.date,e));case"week":return this.forkDateTime(S(this.date,e));case"day":return this.forkDateTime(O(this.date,e));case"hour":return this.forkDateTime(T(this.date,e));case"minute":return this.forkDateTime(A(this.date,e));case"second":return this.forkDateTime(M(this.date,e));case"millisecond":return this.forkDateTime(D(this.date,e));default:throw new Error("Invalid unit provided to `DateTime#add`")}}subtract(e,t){switch(t){case"year":return this.forkDateTime(function(e,t){return v(e,-t)}(this.date,e));case"month":return this.forkDateTime(function(e,t){return E(e,-t)}(this.date,e));case"week":return this.forkDateTime(function(e,t){return S(e,-t)}(this.date,e));case"day":return this.forkDateTime(I(this.date,e));case"hour":return this.forkDateTime(function(e,t){return T(e,-t)}(this.date,e));case"minute":return this.forkDateTime(function(e,t){return A(e,-t)}(this.date,e));case"second":return this.forkDateTime(function(e,t){return M(e,-t)}(this.date,e));case"millisecond":return this.forkDateTime(function(e,t){return D(e,-t)}(this.date,e));default:throw new Error("Invalid unit provided to `DateTime#subtract`")}}get(e){switch(e){case"year":return this.date.getUTCFullYear();case"month":return this.date.getUTCMonth()+1;case"yearday":return function(e){const t=new Date(Date.UTC(e.getUTCFullYear(),0,1)),r=e.valueOf()-t.valueOf();return 1+Math.floor(r/s.MILLISECONDS_IN_DAY)}(this.date);case"weekday":return s.WEEKDAYS[this.date.getUTCDay()];case"day":return this.date.getUTCDate();case"hour":return this.date.getUTCHours();case"minute":return this.date.getUTCMinutes();case"second":return this.date.getUTCSeconds();case"millisecond":return this.date.getUTCMilliseconds();default:throw new Error("Invalid unit provided to `DateTime#set`")}}set(e,t){if("duration"===e)return new c(this.date,this.timezone,t,this.generators);if("generators"===e)return new c(this.date,this.timezone,this.duration,t);let r=new Date(this.date);switch(e){case"year":r.setUTCFullYear(t);break;case"month":{const e=m(t,r.getUTCFullYear());r.getUTCDate()>e?(r.setUTCDate(1),r.setUTCMonth(t),r=I(r,1)):r.setUTCMonth(t-1);break}case"day":r.setUTCDate(t);break;case"hour":r.setUTCHours(t);break;case"minute":r.setUTCMinutes(t);break;case"second":r.setUTCSeconds(t);break;case"millisecond":r.setUTCMilliseconds(t);break;default:throw new Error("Invalid unit provided to `DateTime#set`")}return this.forkDateTime(r)}granularity(e,t={}){let r=this.forkDateTime(this.date);switch(e){case"year":r=r.set("month",1);case"month":r=r.set("day",1);break;case"week":r=function(e,t){const r=h(t).indexOf(e.get("weekday"));return e.subtract(r,"day")}(r,t.weekStart)}switch(e){case"year":case"month":case"week":case"day":r=r.set("hour",0);case"hour":r=r.set("minute",0);case"minute":r=r.set("second",0);case"second":r=r.set("millisecond",0);case"millisecond":return r;default:throw new Error("Invalid granularity provided to `DateTime#granularity`: "+e)}}endGranularity(e,t={}){let r=this.forkDateTime(this.date);switch(e){case"year":r=r.set("month",12);case"month":r=r.set("day",m(r.get("month"),r.get("year")));break;case"week":r=function(e,t){const r=h(t).indexOf(e.get("weekday"));return e.add(6-r,"day")}(r,t.weekStart)}switch(e){case"year":case"month":case"week":case"day":r=r.set("hour",23);case"hour":r=r.set("minute",59);case"minute":r=r.set("second",59);case"second":r=r.set("millisecond",999);case"millisecond":return r;default:throw new Error("Invalid granularity provided to `DateTime#granularity`: "+e)}}toISOString(){return this.date.toISOString()}toDateTime(){return this}toJSON(){const e={timezone:this.timezone,year:this.get("year"),month:this.get("month"),day:this.get("day"),hour:this.get("hour"),minute:this.get("minute"),second:this.get("second"),millisecond:this.get("millisecond")};return this.duration&&(e.duration=this.duration),e}valueOf(){return this.date.valueOf()}assertIsValid(){if(isNaN(this.valueOf()))throw new u("DateTime has invalid date.");return!0}forkDateTime(e){return new c(e,this.timezone,this.duration,this.generators)}}function l(e,t){if(e.timezone!==t.timezone)throw new u("Attempted to compare a datetime to another date in a different timezone: "+JSON.stringify(e)+" and "+JSON.stringify(t));return!0}function f(e,t){if(e.isAfter(t))return 1;if(e.isBefore(t))return-1;if(e.duration&&t.duration){if(e.duration>t.duration)return 1;if(e.duration[e.toISOString(),e])).values())}function h(e="SU"){const t=s.WEEKDAYS.slice();let r=t.indexOf(e);for(;0!==r;)p(t),r--;return t}function p(e,t="first"){return 0===e.length||("first"===t?e.push(e.shift()):e.unshift(e.pop())),e}function g(e,t){if(e===t)return 0;const r=s.WEEKDAYS.indexOf(e)-s.WEEKDAYS.indexOf(t);return r>0?7-r:Math.abs(r)}function m(e,t){return{1:31,2:y(t),3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}[e]}function y(e){return b(e)?29:28}function b(e){return e%400==0||e%4==0&&e%100!=0}function _(e){if(null===e||!0===e||!1===e)return NaN;const t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function w(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");const r=e.valueOf(),n=_(t);return new Date(r+n)}function v(e,t){return E(e,12*_(t))}function E(e,t){const r=_(t),n=(e=new Date(e)).getUTCMonth()+r,i=new Date(0);i.setUTCFullYear(e.getUTCFullYear(),n,1),i.setUTCHours(0,0,0,0);const o=m(i.getUTCMonth()+1,i.getUTCFullYear());return e.setUTCMonth(n,Math.min(o,e.getUTCDate())),e}function S(e,t){return O(e,7*_(t))}function O(e,t){return D(e,_(t)*s.MILLISECONDS_IN_DAY)}function T(e,t){return w(e,_(t)*s.MILLISECONDS_IN_HOUR)}function A(e,t){return w(e,_(t)*s.MILLISECONDS_IN_MINUTE)}function M(e,t){return w(e,_(t)*s.MILLISECONDS_IN_SECOND)}function D(e,t){const r=_(t),n=e.getTime();return new Date(n+r)}function I(e,t){return O(e,-t)}class j extends Error{}class R extends Error{}function N(e,t){return e>t?1:t>e?-1:0}function k(e){return JSON.parse(JSON.stringify(e))}function C(e,t){return e instanceof c?e.timezone!==t?o.adapter.fromDateTime(e).set("timezone",t).toDateTime():e:e instanceof o?e.set("timezone",t).toDateTime():o.adapter.fromDate(e).set("timezone",t).toDateTime()}function L(e,t){return e.timezone!==t?o.adapter.fromDateTime(e).set("timezone",t).toDateTime():e}class x extends Error{}function P(e,t){const r=function(e){let t,r;if(e.start instanceof c)t=e.start;else if(e.start instanceof o)t=e.start.toDateTime();else{if(!o.adapter.isDate(e.start))throw new x('"start" must be either a `DateAdapter` instance or an instance of the date a DateAdapter is wrapping (e.g. `StandardDateAdapter` wraps a `Date`)');t=o.adapter.fromDate(e.start).toDateTime()}if(e.end)if(e.end instanceof c)r=e.end;else if(e.end instanceof o)r=e.end.toDateTime();else{if(!o.adapter.isDate(e.end))throw new x('"end" must be either be `undefined`, a `DateAdapter` instance, or an instance of the date a DateAdapter is wrapping (e.g. `StandardDateAdapter` wraps a `Date`)');r=o.adapter.fromDate(e.end).toDateTime()}if(void 0!==e.duration){if(!Number.isInteger(e.duration))throw new x('"duration" expects a whole number');if(e.duration<=0)throw new x('"duration" must be greater than 0')}if(void 0!==e.count){if(!Number.isInteger(e.count))throw new x('"count" must be a whole number');if(e.count<0)throw new x('"count" must be greater than 0')}if(void 0!==e.end&&void 0!==e.count)throw new x('"end" and "count" cannot both be present');return{start:t,end:r,count:e.count,duration:e.duration}}(t),n=k(t);return e.forEach(e=>{e.normalizeOptions(n,r)}),Object.keys(r).forEach(e=>{void 0===r[e]&&delete r[e]}),r}function B(e){const t=k(e);return t.start=e.start,e.end&&(t.end=e.end),t}class U extends Error{}class F{constructor(e){this.date=e}}class W{constructor(e){this.date=e}}class H{constructor(e,t,r){this.options=t,this.args=r,this.rules=[],this.iterator=void 0===this.options.count?this.iterate():this.args.reverse?this.iterateWithReverseCount():this.iterateWithCount(),this.options=Object.assign(Object.assign({},k(t)),{start:t.start,end:t.end}),this.reverse=void 0===this.options.count&&r.reverse||!1;const n=this.normalizeDateTimeArgs(r),i=n.start,o=n.end;if(void 0!==t.count?this.start=t.start:i&&t.start?this.start=i.isAfterOrEqual(t.start)?i:t.start:this.start=i||t.start,o&&t.end?this.end=o.isBeforeOrEqual(t.end)?o:t.end:this.end=o||t.end,this.args.reverse&&void 0===t.count&&!this.end)throw new Error("When iterating in reverse, the rule must have an `end` or `count` property or you must provide an `end` argument.");this.isInfinite=!this.end&&void 0===this.options.count,this.hasDuration=!!this.options.duration,this.rules=Array.isArray(e)?e:e(this)}[Symbol.iterator](){return this.iterator}next(e){return this.iterator.next(e)}*iterateWithReverseCount(){let e;const t=Array.from(this.iterateWithCount()).reverse().slice();let r=t.shift();for(;r;)if(e&&e.skipToDate&&r.isAfter(e.skipToDate))r=t.shift();else{if(e=yield r,e&&e.skipToDate&&e.skipToDate.isAfterOrEqual(r))throw new Error("A provided `skipToDate` option must be greater than the last yielded date (or smaller, in the case of reverse iteration)");r=t.shift()}}*iterateWithCount(){if(0===this.options.count)return;const e=this.iterate(),t=this.args.start||this.start;let r,n=e.next().value,i=1;for(;n&&i<=this.options.count;)if(i++,n.isBefore(t))n=e.next().value;else if(r&&r.skipToDate&&n.isBefore(r.skipToDate))n=e.next().value;else{if(r=yield n,r&&r.skipToDate&&r.skipToDate.isBeforeOrEqual(n))throw new Error("A provided `skipToDate` option must be greater than the last yielded date (or smaller, in the case of reverse iteration)");n=e.next().value}}*iterate(){let e=this.start;this.reverse&&(e=this.end);let t=this.nextDate(e);for(;t;){const e=yield this.normalizeRunOutput(t);if(e&&e.skipToDate){if(this.reverse?e.skipToDate.isAfterOrEqual(t):e.skipToDate.isBeforeOrEqual(t))throw new Error("A provided `skipToDate` option must be greater than the last yielded date (or smaller, in the case of reverse iteration)");t=this.nextDate(e.skipToDate)}else t=this.nextDate(this.reverse?t.subtract(1,"millisecond"):t.add(1,"millisecond"))}}nextDate(e){let t=this.runRules(e.set("generators",[]));if(this.isDatePastEnd(t.date))return null;let r=0;for(;t instanceof W&&r<50;){if(t=this.runRules(t.date),this.isDatePastEnd(t.date))return null;r++}if(t instanceof W)throw new U(`Failed to find a matching occurrence in ${r} iterations. Last iterated date: "${t.date.toISOString()}"`);if(this.reverse?e.isBefore(t.date):e.isAfter(t.date))throw new U("An error occurred in a recurrence rule. If this happened using the rSchedule provided recurrence rules, you should open an issue in the rSchedule repo. The maintainer is going to want to know how to recreate the error.");return t.date}runRules(e){let t=new F(e);for(const e of this.rules){if(t instanceof W)return t;t=e.run(t.date)}return t}isDatePastEnd(e){return this.reverse?e.isBefore(this.start):this.end&&e.isAfter(this.end)}normalizeRunOutput(e){return this.hasDuration?e.set("duration",this.options.duration):e}normalizeDateTimeArgs(e){return{start:e.start&&L(e.start,this.options.start.timezone),end:e.end&&L(e.end,this.options.start.timezone)}}}class z{constructor(e={}){this.timezone=void 0!==e.timezone?e.timezone:null,this.maxDuration=e.maxDuration||0}get firstDate(){if(void 0!==this._firstDate)return this._firstDate;const e=this._run().next().value;return this._firstDate=e?this.dateAdapter.fromDateTime(e):null,this._firstDate}get lastDate(){if(void 0!==this._lastDate)return this._lastDate;if(this.isInfinite)return this._lastDate=null,null;const e=this._run({reverse:!0}).next().value;return this._lastDate=e?this.dateAdapter.fromDateTime(e):null,this._lastDate}pipe(...e){return e.reduce((e,t)=>t({base:e,timezone:this.timezone}),this)}occurrences(e={}){return new q(this,this.normalizeOccurrencesArgs(e))}collections(e={}){return new G(this,this.normalizeCollectionsArgs(e))}occursBetween(e,t,r={}){const n=this.normalizeDateInput(e),i=this.normalizeDateInput(t);if(this.hasDuration&&!r.excludeEnds){const e=this.getMaxDuration("occursBetween",r),t=this._run({start:n.subtract(e,"millisecond"),end:i,reverse:!0});for(const e of t)if(!e.end.isBefore(n))return!0;return!1}for(const e of this._run({start:n,end:i})){if(r.excludeEnds){if(e.isEqual(n))continue;if(e.isEqual(i))break}return!0}return!1}occursOn(e){const t=this.normalizeOccursOnArgs(e);if(t.weekday){if(this.isInfinite&&!t.before)throw new j("When calling `occursOn()` with a `weekday` argument and an occurrence object that has infinite occurrences, you must include a `before` argument as well.");const e=t.after&&(t.excludeEnds?t.after.add(1,"day"):t.after),r=t.before&&(t.excludeEnds?t.before.subtract(1,"day"):t.before),n=this._run({start:e,end:r});let i=n.next().value;if(!i)return!1;for(;i;){if(i.get("weekday")===t.weekday)return!0;i=n.next({skipToDate:i.add(g(i.get("weekday"),t.weekday),"day").granularity("day")}).value}return!1}if(!t.date)throw new j('"occursOn()" must be called with either a "date" or "weekday" argument');if(this.hasDuration){const e=this.getMaxDuration("occursOn",t),r=this._run({start:t.date.subtract(e,"millisecond"),end:t.date});for(const e of r)if(!e.end.isBefore(t.date))return!e.isAfter(t.date);return!1}for(const e of this._run({start:t.date,end:t.date}))return!!e;return!1}occursAfter(e,t={}){const r=this.normalizeDateInput(e);if(this.hasDuration&&!t.excludeStart){const e=this.getMaxDuration("occursAfter",t),n=this._run({start:r.subtract(e,"millisecond")});for(const e of n)if(!e.end.isBefore(r))return!0;return!1}for(const e of this._run({start:r}))if(!t.excludeStart||!e.isEqual(r))return!0;return!1}occursBefore(e,t={}){const r=this.normalizeDateInput(e);if(this.hasDuration&&t.excludeStart){for(const e of this._run({end:r,reverse:!0}))if(!e.end.isAfterOrEqual(r))return!0;return!1}for(const e of this._run({end:r,reverse:!0}))if(!t.excludeStart||!e.isEqual(r))return!0;return!1}get dateAdapter(){return o.adapter}normalizeOccurrencesArgs(e){return Object.assign(Object.assign({},e),{start:this.normalizeDateInput(e.start),end:this.normalizeDateInput(e.end)})}normalizeCollectionsArgs(e){if(void 0!==e.reverse)throw new j("`collections()` does not support the `reverse` option at this time.");return Object.assign(Object.assign({},e),{start:this.normalizeDateInput(e.start),end:this.normalizeDateInput(e.end)})}normalizeOccursOnArgs(e={}){return Object.assign(Object.assign({},e),{date:this.normalizeDateInput(e.date),after:this.normalizeDateInput(e.after),before:this.normalizeDateInput(e.before),excludeDates:e.excludeDates&&e.excludeDates.map(e=>this.normalizeDateInput(e))})}normalizeRunArgs(e){return Object.assign(Object.assign({},e),{start:this.normalizeDateInput(e.start),end:this.normalizeDateInput(e.end)})}normalizeDateInput(e){return e?C(e,this.timezone):void 0}normalizeDateInputToAdapter(e){if(e)return function(e){return e instanceof c?o.adapter.fromDateTime(e):e instanceof o?e:o.adapter.fromDate(e)}(e)}normalizeRunOutput(e){return L(e,this.timezone)}getMaxDuration(e,t){const r=t.maxDuration||this.maxDuration;if(!Number.isInteger(r))throw new j(`When an occurrence generator has a duration, a 'maxDuration' argument must be supplied to ${e}().`);return r}}class q{constructor(e,t){this.iterable=e,this.args=t,this[Symbol.iterator]=()=>this.occurrenceIterator(),this.iterator=e._run(t),this.isInfinite=e.isInfinite}next(e){return this.occurrenceIterator(e).next()}toArray(){if(this.args.end||this.args.take||!this.isInfinite)return Array.from(this.occurrenceIterator());throw new R("OccurrenceIterator#toArray() can only be called if the iterator is not infinite, or you provide and `end` argument, or you provide a `take` argument.")}*occurrenceIterator(e){let t=this.normalizeRunArgs(e),r=this.iterator.next(t).value;for(;r;){const e=yield this.normalizeDateOutput(r);t=this.normalizeRunArgs(e),r=this.iterator.next(t).value}}normalizeRunArgs(e){return{skipToDate:this.normalizeDateInput(e&&e.skipToDate)}}normalizeDateInput(e){return e?C(e,this.iterable.timezone):void 0}normalizeDateOutput(e){if(e)return e?o.adapter.fromDateTime(e):void 0}}class V{constructor(e=[],t,r,n){this.dates=e,this.granularity=t,this.periodStart=r,this.periodEnd=n}}class G{constructor(e,t){if(this.iterable=e,this.args=t,this.granularity="year",this[Symbol.iterator]=()=>this.iterator,t.granularity&&(this.granularity=t.granularity,"week"===this.granularity&&!t.weekStart))throw new Error('"week" granularity requires `weekStart` arg');if(t.weekStart&&(this.weekStart=t.weekStart),t.reverse)throw new Error("`OccurrenceGenerator#collections()` does not support iterating in reverse. Though `OccurrenceGenerator#occurrences()` does support iterating in reverse.");this.args=Object.assign(Object.assign({},t),{start:t.start||e._run().next().value,end:t.end&&this.getPeriod(t.end).end}),this.startDate=this.args.start&&this.normalizeDateOutput(this.getPeriod(this.args.start).start)||null,this.iterator=this.collectionIterator()}next(){return this.iterator.next()}toArray(){if(this.args.end||this.args.take||!this.iterable.isInfinite){const e=[];for(const t of this.collectionIterator())e.push(t);return e}throw new R("CollectionIterator#toArray() can only be called if the iterator is not infinite, or you provide and `end` argument, or you provide a `take` argument.")}normalizeDateOutput(e){if(e)return o.adapter.fromDateTime(e)}*collectionIterator(){if(!this.startDate)return;let e=this.occurrenceIterator(),t=e.next().value;if(!t)return;let r=this.getPeriod(this.args.start),n=[],i=0;for(;t&&(void 0===this.args.take||this.args.take>i);){for(;t&&t.isBeforeOrEqual(r.end);)n.push(t),t=e.next().value;if(yield new V(n.map(e=>this.normalizeDateOutput(e)),this.granularity,this.normalizeDateOutput(r.start),this.normalizeDateOutput(r.end)),!t)return;n=[],r=this.args.skipEmptyPeriods?this.getPeriod(t):this.getPeriod(this.incrementPeriod(r.period)),"month"===this.granularity&&this.weekStart&&(e=this.iterable._run({start:r.start,end:this.args.end}),t=e.next().value),i++}}getPeriod(e){let t,r,n;return"month"===this.granularity&&this.weekStart?(t=e.granularity("month").granularity("week",{weekStart:this.weekStart}),r=e.endGranularity("month").endGranularity("week",{weekStart:this.weekStart}),n=e.granularity("month")):(t=e.granularity(this.granularity,{weekStart:this.weekStart}),r=e.endGranularity(this.granularity,{weekStart:this.weekStart}),n=t),{start:t,end:r,period:n}}incrementPeriod(e){return e.add(1,this.granularity)}occurrenceIterator(){let e=this.args.start||this.iterable._run().next().value;return e?(e=this.getPeriod(e).start,this.iterable._run({start:e,end:this.args.end})):this.iterable._run(this.args)}}class Y extends z{constructor(e,t){super(t),this.streams=e,this.config=t,this.timezone=t.timezone,this.streams=e.map(e=>e instanceof Y?e:e.set("timezone",this.timezone)),this.isInfinite=this.calculateIsInfinite(),this.hasDuration=this.calculateHasDuration()}normalizeDateInput(e){if(e)return C(e,this.timezone)}normalizeRunOutput(e){return L(e,this.timezone)}}class ${constructor(e,t){this.runArgs=t,this.stream=e._run(this.runArgs),this.next()}next(e){const t=this.stream.next(e),r=t.done,n=t.value;return this.done="boolean"!=typeof r||r,this.value=n,{done:r,value:n}}}function K(e,t={},r={}){if(r.skipToDate&&0!==e.length){if(t.reverse?e.every(e=>e.value.isBeforeOrEqual(r.skipToDate)):e.every(e=>e.value.isAfterOrEqual(r.skipToDate)))throw new Error("A provided `skipToDate` option must be greater than the last yielded date (or smaller, in the case of reverse iteration)");for(const n of e)n.done||(t.reverse?n.value.isBeforeOrEqual(r.skipToDate):n.value.isAfterOrEqual(r.skipToDate))||n.next(r)}}function Z(e,t){return e.done&&t.done?0:e.done?1:t.done?-1:e.value.isAfter(t.value)?1:-1}function X(e,t){return e.done&&t.done?0:e.done?-1:t.done?1:e.value.isAfter(t.value)?-1:1}function J(e,t={},r={}){return K(e,t,r),e.sort(t.reverse?X:Z).filter(e=>!e.done).shift()}function Q(...e){return t=>new ee(e,t)}class ee extends Y{set(e,t){return new ee(this.streams.map(e=>e.set("timezone",t)),Object.assign(Object.assign({},this.config),{base:this.config.base&&this.config.base.set("timezone",t),timezone:t}))}*_run(e={}){const t=this.streams.map(t=>new $(t,e));if(this.config.base&&t.push(new $(this.config.base,e)),0===t.length)return;let r=J(t,e);for(;r&&!r.done;){const n=yield this.normalizeRunOutput(r.value);n&&n.skipToDate||r.next(),r=J(t,e,n)}}calculateIsInfinite(){return this.config.base&&this.config.base.isInfinite||this.streams.some(e=>e.isInfinite)}calculateHasDuration(){const e=this.streams.every(e=>e.hasDuration);return this.config.base?this.config.base.hasDuration&&e:e}}class te extends z{constructor(e={}){super(e),this.adapters=[],this.isInfinite=!1,this.maxDuration=0,this.datetimes=[],this.data=e.data,e.dates&&(this.adapters=e.dates.map(t=>{let r=this.normalizeDateInputToAdapter(t);return e.duration&&!r.duration&&(r=r.set("duration",e.duration)),r.set("timezone",this.timezone)}),this.datetimes=this.adapters.map(e=>e.toDateTime())),this.hasDuration=this.datetimes.every(e=>!!e.duration),this.hasDuration&&(this.maxDuration=this.adapters.reduce((e,t)=>t.duration>e?t.duration:e,0))}get length(){return this.adapters.length}get firstDate(){return this.adapters[0]||null}get lastDate(){return this.adapters[this.length-1]||null}occurrences(e={}){return new q(this,this.normalizeOccurrencesArgs(e))}collections(e={}){return new G(this,this.normalizeCollectionsArgs(e))}add(e){return new te({dates:[...this.adapters,e],timezone:this.timezone,data:this.data})}remove(e){const t=this.adapters.slice(),r=this.normalizeDateInputToAdapter(e),n=t.findIndex(e=>e.valueOf()===r.valueOf());return n>=0&&t.splice(n,1),new te({dates:t,timezone:this.timezone,data:this.data})}set(e,t,r={}){let n=this.timezone,i=this.adapters.slice();if("timezone"===e){if(t===this.timezone)return this;r.keepLocalTime&&(i=this.adapters.map(e=>{const r=e.toJSON();return r.timezone=t,this.dateAdapter.fromJSON(r)})),n=t}else if("dates"===e)i=t;else{if("duration"!==e)throw new j(`Unexpected prop argument "${e}". Accepted values are "timezone" or "dates"`);i=i.map(e=>e.set("duration",t||0))}return new te({dates:i,data:this.data,timezone:n})}filter(e){return new te({dates:this.adapters.filter(e),data:this.data,timezone:this.timezone})}*_run(e={}){let t=this.datetimes.sort(f);e.start&&(t=t.filter(t=>t.isAfterOrEqual(e.start))),e.end&&(t=t.filter(t=>t.isBeforeOrEqual(e.end))),e.reverse&&(t=t.slice().reverse()),e.take&&(t=t.slice(0,e.take));const r=t.slice();let n,i=r.shift();for(;i;)if(n&&n.skipToDate&&(e.reverse?n.skipToDate.isBefore(i):n.skipToDate.isAfter(i)))i=r.shift();else{if(i=i.add(this,"generator"),n=yield this.normalizeRunOutput(i),n&&n.skipToDate&&(e.reverse?n.skipToDate.isAfterOrEqual(i):n.skipToDate.isBeforeOrEqual(i)))throw new Error("A provided `skipToDate` option must be greater than the last yielded date (or smaller, in the case of reverse iteration)");i=r.shift()}}}class re extends Error{}let ne;class ie{constructor(e,t){if(this.duration=t&&t.duration||0,this.generators=t&&t.generators&&t.generators.slice()||[],!Number.isInteger(this.duration)||this.duration<0)throw new re("duration must be a non-negative integer")}static set adapter(e){if(ne)throw new Error(`"${ne.name}" has already been configured.`);ne=e}static get adapter(){if(!ne)throw new Error("No date adapter has been configured. See rSchedule docs.");return ne}static isDate(e){throw oe("isDate()")}static fromDate(e,t){throw oe("fromDate()")}static fromJSON(e){throw oe("fromJSON()")}static fromDateTime(e){throw oe("fromDateTime()")}toISOString(){return this.set("timezone","UTC").toDateTime().toISOString()}toDateTime(){return ue.fromJSON(Object.assign(Object.assign({},this.toJSON()),{generators:this.generators}))}}function oe(e){return new Error(`You must implement the "${e}" method for this DateAdapter class`)}var ae;ie.hasTimezoneSupport=!1,function(e){e.WEEKDAYS=["SU","MO","TU","WE","TH","FR","SA"],e.MILLISECONDS_IN_SECOND=1e3,e.MILLISECONDS_IN_MINUTE=60*e.MILLISECONDS_IN_SECOND,e.MILLISECONDS_IN_HOUR=60*e.MILLISECONDS_IN_MINUTE,e.MILLISECONDS_IN_DAY=24*e.MILLISECONDS_IN_HOUR,e.MILLISECONDS_IN_WEEK=7*e.MILLISECONDS_IN_DAY}(ae||(ae={}));class se extends Error{}class ue{constructor(e,t,r,n){if(this.date=new Date(e),this.timezone=t||null,this.duration=r||0,this.generators=n&&n.slice()||[],!Number.isInteger(this.duration)||this.duration<0)throw new se("duration must be a non-negative integer");this.assertIsValid()}static fromJSON(e){const t=new Date(Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond));return new ue(t,e.timezone,e.duration,e.generators)}static fromDateAdapter(e){return ue.fromJSON(Object.assign(Object.assign({},e.toJSON()),{generators:e.generators}))}get end(){if(this.duration)return this._end||(this._end=this.add(this.duration,"millisecond")),this._end}isEqual(e){return!!e&&(ce(this,e),this.valueOf()===e.valueOf())}isBefore(e){return ce(this,e),this.valueOf()e.valueOf()}isAfterOrEqual(e){return ce(this,e),this.valueOf()>=e.valueOf()}isOccurring(e){if(!this.duration)throw new Error("DateTime#isOccurring() is only applicable to DateTimes with durations");return ce(this,e),e.isAfterOrEqual(this)&&e.isBeforeOrEqual(this.add(this.duration,"millisecond"))}add(e,t){switch(t){case"generator":{const t=this.generators.slice();return t.unshift(e),new ue(this.date,this.timezone,this.duration,t)}case"year":return this.forkDateTime(me(this.date,e));case"month":return this.forkDateTime(ye(this.date,e));case"week":return this.forkDateTime(be(this.date,e));case"day":return this.forkDateTime(_e(this.date,e));case"hour":return this.forkDateTime(we(this.date,e));case"minute":return this.forkDateTime(ve(this.date,e));case"second":return this.forkDateTime(Ee(this.date,e));case"millisecond":return this.forkDateTime(Se(this.date,e));default:throw new Error("Invalid unit provided to `DateTime#add`")}}subtract(e,t){switch(t){case"year":return this.forkDateTime(function(e,t){return me(e,-t)}(this.date,e));case"month":return this.forkDateTime(function(e,t){return ye(e,-t)}(this.date,e));case"week":return this.forkDateTime(function(e,t){return be(e,-t)}(this.date,e));case"day":return this.forkDateTime(Oe(this.date,e));case"hour":return this.forkDateTime(function(e,t){return we(e,-t)}(this.date,e));case"minute":return this.forkDateTime(function(e,t){return ve(e,-t)}(this.date,e));case"second":return this.forkDateTime(function(e,t){return Ee(e,-t)}(this.date,e));case"millisecond":return this.forkDateTime(function(e,t){return Se(e,-t)}(this.date,e));default:throw new Error("Invalid unit provided to `DateTime#subtract`")}}get(e){switch(e){case"year":return this.date.getUTCFullYear();case"month":return this.date.getUTCMonth()+1;case"yearday":return function(e){const t=new Date(Date.UTC(e.getUTCFullYear(),0,1)),r=e.valueOf()-t.valueOf();return 1+Math.floor(r/ae.MILLISECONDS_IN_DAY)}(this.date);case"weekday":return ae.WEEKDAYS[this.date.getUTCDay()];case"day":return this.date.getUTCDate();case"hour":return this.date.getUTCHours();case"minute":return this.date.getUTCMinutes();case"second":return this.date.getUTCSeconds();case"millisecond":return this.date.getUTCMilliseconds();default:throw new Error("Invalid unit provided to `DateTime#set`")}}set(e,t){if("duration"===e)return new ue(this.date,this.timezone,t,this.generators);if("generators"===e)return new ue(this.date,this.timezone,this.duration,t);let r=new Date(this.date);switch(e){case"year":r.setUTCFullYear(t);break;case"month":{const e=de(t,r.getUTCFullYear());r.getUTCDate()>e?(r.setUTCDate(1),r.setUTCMonth(t),r=Oe(r,1)):r.setUTCMonth(t-1);break}case"day":r.setUTCDate(t);break;case"hour":r.setUTCHours(t);break;case"minute":r.setUTCMinutes(t);break;case"second":r.setUTCSeconds(t);break;case"millisecond":r.setUTCMilliseconds(t);break;default:throw new Error("Invalid unit provided to `DateTime#set`")}return this.forkDateTime(r)}granularity(e,t={}){let r=this.forkDateTime(this.date);switch(e){case"year":r=r.set("month",1);case"month":r=r.set("day",1);break;case"week":r=function(e,t){const r=le(t).indexOf(e.get("weekday"));return e.subtract(r,"day")}(r,t.weekStart)}switch(e){case"year":case"month":case"week":case"day":r=r.set("hour",0);case"hour":r=r.set("minute",0);case"minute":r=r.set("second",0);case"second":r=r.set("millisecond",0);case"millisecond":return r;default:throw new Error("Invalid granularity provided to `DateTime#granularity`: "+e)}}endGranularity(e,t={}){let r=this.forkDateTime(this.date);switch(e){case"year":r=r.set("month",12);case"month":r=r.set("day",de(r.get("month"),r.get("year")));break;case"week":r=function(e,t){const r=le(t).indexOf(e.get("weekday"));return e.add(6-r,"day")}(r,t.weekStart)}switch(e){case"year":case"month":case"week":case"day":r=r.set("hour",23);case"hour":r=r.set("minute",59);case"minute":r=r.set("second",59);case"second":r=r.set("millisecond",999);case"millisecond":return r;default:throw new Error("Invalid granularity provided to `DateTime#granularity`: "+e)}}toISOString(){return this.date.toISOString()}toDateTime(){return this}toJSON(){const e={timezone:this.timezone,year:this.get("year"),month:this.get("month"),day:this.get("day"),hour:this.get("hour"),minute:this.get("minute"),second:this.get("second"),millisecond:this.get("millisecond")};return this.duration&&(e.duration=this.duration),e}valueOf(){return this.date.valueOf()}assertIsValid(){if(isNaN(this.valueOf()))throw new se("DateTime has invalid date.");return!0}forkDateTime(e){return new ue(e,this.timezone,this.duration,this.generators)}}function ce(e,t){if(e.timezone!==t.timezone)throw new se("Attempted to compare a datetime to another date in a different timezone: "+JSON.stringify(e)+" and "+JSON.stringify(t));return!0}function le(e="SU"){const t=ae.WEEKDAYS.slice();let r=t.indexOf(e);for(;0!==r;)fe(t),r--;return t}function fe(e,t="first"){return 0===e.length||("first"===t?e.push(e.shift()):e.unshift(e.pop())),e}function de(e,t){return{1:31,2:he(t),3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}[e]}function he(e){return function(e){return e%400==0||e%4==0&&e%100!=0}(e)?29:28}function pe(e){if(null===e||!0===e||!1===e)return NaN;const t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function ge(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");const r=e.valueOf(),n=pe(t);return new Date(r+n)}function me(e,t){return ye(e,12*pe(t))}function ye(e,t){const r=pe(t),n=(e=new Date(e)).getUTCMonth()+r,i=new Date(0);i.setUTCFullYear(e.getUTCFullYear(),n,1),i.setUTCHours(0,0,0,0);const o=de(i.getUTCMonth()+1,i.getUTCFullYear());return e.setUTCMonth(n,Math.min(o,e.getUTCDate())),e}function be(e,t){return _e(e,7*pe(t))}function _e(e,t){return Se(e,pe(t)*ae.MILLISECONDS_IN_DAY)}function we(e,t){return ge(e,pe(t)*ae.MILLISECONDS_IN_HOUR)}function ve(e,t){return ge(e,pe(t)*ae.MILLISECONDS_IN_MINUTE)}function Ee(e,t){return ge(e,pe(t)*ae.MILLISECONDS_IN_SECOND)}function Se(e,t){const r=pe(t),n=e.getTime();return new Date(n+r)}function Oe(e,t){return _e(e,-t)}function Te(e,t){return e.timezone!==t?ie.adapter.fromDateTime(e).set("timezone",t).toDateTime():e}class Ae extends z{constructor(e,t,r={}){super(r),this.recurrenceRules=e,this.options=B(t),this.normOptions=P(this.recurrenceRules,this.options),this.timezone=void 0!==r.timezone?r.timezone:this.normOptions.start.timezone,this.data=r.data,this.hasDuration=!!t.duration,this.hasDuration&&(this.duration=t.duration),this.isInfinite=void 0===this.normOptions.end&&void 0===this.normOptions.count}occurrences(e={}){return new q(this,this.normalizeOccurrencesArgs(e))}collections(e={}){return new G(this,this.normalizeCollectionsArgs(e))}*_run(e={}){const t=this.normalizeRunArgs(e),r=new H((n=this.recurrenceRules,e=>n.reduce((t,r)=>{const n=r.get(e);return n&&t.push(n),t},[])),this.normOptions,t);var n;let i=r.next().value,o=0;for(;i&&(void 0===t.take||oi);){n=n.add(this,"generator");const e=yield this.normalizeRunOutput(n);n=r.next(e).value,i++}}}function Ie(...e){return t=>new je(e,t)}class je extends Y{set(e,t){return new je(this.streams.map(e=>e.set("timezone",t)),Object.assign(Object.assign({},this.config),{base:this.config.base&&this.config.base.set("timezone",t),timezone:t}))}*_run(e={}){if(!this.config.base)return;const t=new $(this.config.base,e),r=new $(new ee(this.streams,{timezone:this.config.timezone}),e);for(Re(t,r,e);!t.done;){const n=yield this.normalizeRunOutput(t.value);n&&n.skipToDate||t.next(),Re(t,r,e,n)}}calculateIsInfinite(){return!(!this.config.base||!this.config.base.isInfinite)}calculateHasDuration(){return!(!this.config.base||!this.config.base.hasDuration)}}function Re(e,t,r={},n={}){for(K([e,t],r,n),Ne(e,t,r);!e.done&&!t.done&&e.value.isEqual(t.value);)e.next(),Ne(e,t,r)}function Ne(e,t,r={}){if(r.reverse)for(;!t.done&&!e.done&&t.value.isAfter(e.value);)t.next();else for(;!t.done&&!e.done&&t.value.isBefore(e.value);)t.next()}class ke extends Y{set(e,t){return new ke([],Object.assign(Object.assign({},this.config),{base:this.config.base&&this.config.base.set("timezone",t),timezone:t}))}*_run(e={}){if(!this.config.base)return;const t=new $(this.config.base,e);for(;!t.done;){const e=yield this.normalizeRunOutput(t.value),r=t.value;for(t.next(e);(!e||!e.skipToDate)&&!t.done&&t.value.isEqual(r);)t.next()}}calculateIsInfinite(){return!(!this.config.base||!this.config.base.isInfinite)}calculateHasDuration(){return!(!this.config.base||!this.config.base.hasDuration)}}class Ce extends De{constructor(e={}){super(e),this.rrules=[],this.exrules=[];for(const t of["rrules","exrules"]){const r=e[t];r&&(this[t]=r.map(e=>e instanceof Me?e.set("timezone",this.timezone):new Me(e,{timezone:this.timezone})))}for(const t of["rdates","exdates"]){const r=e[t];this[t]=r?r instanceof te?r.set("timezone",this.timezone):new te({dates:r,timezone:this.timezone}):new te({timezone:this.timezone})}this.hasDuration=this.rrules.every(e=>e.hasDuration)&&this.exrules.every(e=>e.hasDuration)&&this.rdates.hasDuration&&this.exdates.hasDuration,this.isInfinite=this.rrules.some(e=>e.isInfinite),this.occurrenceStream=[Q(...this.rrules),Ie(...this.exrules),Q(this.rdates),Ie(this.exdates),e=>new ke([],e)].reduce((e,t)=>t({base:e,timezone:this.timezone}),void 0)}add(e,t){const r=this.rrules.slice(),n=this.exrules.slice();let i=this.rdates,o=this.exdates;switch(e){case"rrule":r.push(t);break;case"exrule":n.push(t);break;case"rdate":i=this.rdates.add(t);break;case"exdate":o=this.exdates.add(t)}return new Ce({timezone:this.timezone,data:this.data,rrules:r,exrules:n,rdates:i,exdates:o})}remove(e,t){let r=this.rrules,n=this.exrules,i=this.rdates,o=this.exdates;switch(e){case"rrule":r=r.filter(e=>e!==t);break;case"exrule":n=n.filter(e=>e!==t);break;case"rdate":i=this.rdates.remove(t);break;case"exdate":o=this.exdates.remove(t)}return new Ce({timezone:this.timezone,data:this.data,rrules:r,exrules:n,rdates:i,exdates:o})}set(e,t,r={}){let n=this.timezone,i=this.rrules,o=this.exrules,a=this.rdates,s=this.exdates;switch(e){case"timezone":if(t===this.timezone&&!r.keepLocalTime)return this;r.keepLocalTime&&(i=i.map(e=>e.set("timezone",t,r)),o=o.map(e=>e.set("timezone",t,r)),a=a.set("timezone",t,r),s=s.set("timezone",t,r)),n=t;break;case"rrules":i=t;break;case"exrules":o=t;break;case"rdates":a=t;break;case"exdates":s=t}return new Ce({timezone:n,data:this.data,rrules:i,exrules:o,rdates:a,exdates:s})}}Error;Error;class Le{constructor(e){this.processor=e,this.start=e.start,this.end=e.end,this.options=e.options}}class xe extends Le{constructor(e,t){super(e),this.initDate=t,this.intervalUnit=function(e){switch(e){case"YEARLY":return"year";case"MONTHLY":return"month";case"WEEKLY":return"week";case"DAILY":return"day";case"HOURLY":return"hour";case"MINUTELY":return"minute";case"SECONDLY":return"second";case"MILLISECONDLY":return"millisecond";default:throw new Error("unknown freq passed to freqToGranularity()")}}(this.options.frequency),this.firstIntervalStartDate=this.normalizedStartDate(this.options.start),this.intervalStartDate=this.firstIntervalStartDate,this.intervalEndDate=this.normalizedEndDate(this.firstIntervalStartDate),this.skipToInterval(this.initDate)}run(e){return this.validateDate(new F(e))}validateDate(e){const t=e.date;return e instanceof F&&this.dateIsWithinInterval(t)?e:(this.skipToInterval(t),new W(this.dateIsWithinInterval(t)?t:this.setToCurrentInterval()))}setToCurrentInterval(){return this.intervalStartDate}normalizedStartDate(e){return"WEEKLY"===this.options.frequency?e.granularity("week",{weekStart:this.options.weekStart}):e.granularity(this.intervalUnit)}normalizedEndDate(e){switch(this.options.frequency){case"YEARLY":return e.add(1,"year");case"MONTHLY":return e.add(1,"month");case"WEEKLY":return e.add(1,"week");case"DAILY":return e.add(1,"day");case"HOURLY":return e.add(1,"hour");case"MINUTELY":return e.add(1,"minute");case"SECONDLY":return e.add(1,"second");case"MILLISECONDLY":return e.add(1,"millisecond");default:throw new Error("Unknown frequency "+this.options.frequency)}}skipToInterval(e){const t=this.intervalDifference(e);this.intervalStartDate=this.firstIntervalStartDate.add(t,this.intervalUnit),this.intervalEndDate=this.normalizedEndDate(this.intervalStartDate)}dateIsWithinInterval(e){return this.intervalStartDate.isBeforeOrEqual(e)&&this.intervalEndDate.isAfter(e)}intervalDifference(e){return Pe({first:this.firstIntervalStartDate,second:e,unit:this.intervalUnit,interval:this.options.interval,weekStart:this.options.weekStart,direction:"after"})}}function Pe({first:e,second:t,unit:r,interval:n,weekStart:i,direction:o}){let a=(()=>{let n,o;switch(r){case"year":return o=12*(t.get("year")-e.get("year")),o=o+t.get("month")-e.get("month"),Math.floor(o/12);case"month":return o=12*(t.get("year")-e.get("year")),o=o+t.get("month")-e.get("month"),o;case"week":e=e.granularity("week",{weekStart:i}),n=s.MILLISECONDS_IN_WEEK;break;case"day":n=s.MILLISECONDS_IN_DAY;break;case"hour":n=s.MILLISECONDS_IN_HOUR;break;case"minute":n=s.MILLISECONDS_IN_MINUTE;break;case"second":n=s.MILLISECONDS_IN_SECOND;break;case"millisecond":n=1;break;default:throw new Error("Unexpected `unit` value")}const a=t.valueOf()-e.valueOf();return Math.floor(a/n)})();return a=("after"===o?Math.ceil:Math.floor)(a/n)*n,a}class Be extends xe{setToCurrentInterval(){return this.intervalEndDate.subtract(1,"millisecond")}intervalDifference(e){return Pe({first:this.firstIntervalStartDate,second:e,unit:this.intervalUnit,interval:this.options.interval,weekStart:this.options.weekStart,direction:"before"})}}const Ue=["MILLISECONDLY","SECONDLY","MINUTELY","HOURLY","DAILY","WEEKLY","MONTHLY","YEARLY"],Fe={name:"FrequencyRule",get:e=>void 0!==e.options.byMillisecondOfSecond||"MILLISECONDLY"!==e.options.frequency?null:e.reverse?new Be(e,e.end):new xe(e,e.start),normalizeOptions:(e,t)=>{if(!Ue.includes(e.frequency))throw new x('"frequency" must be one of '+JSON.stringify(Ue));if(void 0!==e.interval){if(!Number.isInteger(e.interval))throw new x('"interval" expects a whole number');if(e.interval<1)throw new x('"interval" cannot be less than 1')}if(void 0!==e.weekStart&&!s.WEEKDAYS.includes(e.weekStart))throw new x('"weekStart" must be one of '+JSON.stringify(s.WEEKDAYS));t.frequency=e.frequency,t.interval=e.interval||1,t.weekStart=e.weekStart||"MO"},deps:()=>[Fe]};function We(e){return Array.isArray(e)&&e.length>0}const He=new WeakMap;class ze extends Le{constructor(e){super(e),He.has(this.processor)||He.set(this.processor,new xe(e,e.start)),this.frequency=He.get(this.processor)}validateDate(e){return this.frequency.validateDate(e)}}class qe extends Le{constructor(e){super(e),He.has(this.processor)||He.set(this.processor,new Be(e,e.end)),this.frequency=He.get(this.processor)}validateDate(e){return this.frequency.validateDate(e)}}class Ve extends qe{run(e){const t=e.get(this.granularity);for(const r of this.option)if(!(tr))return t===r?this.validateDate(new F(e)):this.validateDate(new W(e.granularity(this.baseGranularity).set(this.granularity,r)));return this.validateDate(new W(e.granularity(this.baseGranularity).add(1,this.baseGranularity).set(this.granularity,this.option[0])))}}class $e extends Ye{constructor(){super(...arguments),this.baseGranularity="second",this.granularity="millisecond",this.option=this.options.byMillisecondOfSecond}}const Ke={name:"ByMillisecondOfSecond",get:e=>void 0===e.options.byMillisecondOfSecond?null:e.reverse?new Ge(e):new $e(e),normalizeOptions:(e,t)=>{if(void 0!==e.byMillisecondOfSecond){if(!We(e.byMillisecondOfSecond))throw new x('"byMillisecondOfSecond" expects a non-empty array');if(e.byMillisecondOfSecond.some(e=>e<0||e>999))throw new x('"byMillisecondOfSecond" values must be >= 0 && <= 999');t.byMillisecondOfSecond=e.byMillisecondOfSecond,t.byMillisecondOfSecond.sort(N)}else"MILLISECONDLY"!==e.frequency&&(t.byMillisecondOfSecond=[t.start.get("millisecond")])},deps:()=>[Fe,Ke]};class Ze extends Ve{constructor(){super(...arguments),this.baseGranularity="minute",this.granularity="second",this.option=this.options.bySecondOfMinute.slice().reverse()}}class Xe extends Ye{constructor(){super(...arguments),this.baseGranularity="minute",this.granularity="second",this.option=this.options.bySecondOfMinute}}const Je={name:"BySecondOfMinute",get:e=>void 0===e.options.bySecondOfMinute?null:e.reverse?new Ze(e):new Xe(e),normalizeOptions:(e,t)=>{if(void 0!==e.bySecondOfMinute){if(!We(e.bySecondOfMinute))throw new x('"bySecondOfMinute" expects a non-empty array');if(e.bySecondOfMinute.some(e=>e<0||e>60))throw new x('"bySecondOfMinute" values must be >= 0 && <= 60');t.bySecondOfMinute=e.bySecondOfMinute,t.bySecondOfMinute.sort(N)}else["SECONDLY","MILLISECONDLY"].includes(e.frequency)||(t.bySecondOfMinute=[t.start.get("second")])},deps:()=>[Fe,Je,Ke]};class Qe extends Ve{constructor(){super(...arguments),this.baseGranularity="hour",this.granularity="minute",this.option=this.options.byMinuteOfHour.slice().reverse()}}class et extends Ye{constructor(){super(...arguments),this.baseGranularity="hour",this.granularity="minute",this.option=this.options.byMinuteOfHour}}const tt={name:"ByMinuteOfHour",get:e=>void 0===e.options.byMinuteOfHour?null:e.reverse?new Qe(e):new et(e),normalizeOptions:(e,t)=>{if(void 0!==e.byMinuteOfHour){if(!We(e.byMinuteOfHour))throw new x('"byMinuteOfHour" expects a non-empty array');if(e.byMinuteOfHour.some(e=>e<0||e>59))throw new x('"byMinuteOfHour" values must be >= 0 && <= 59');t.byMinuteOfHour=e.byMinuteOfHour,t.byMinuteOfHour.sort(N)}else["MINUTELY","SECONDLY","MILLISECONDLY"].includes(e.frequency)||(t.byMinuteOfHour=[t.start.get("minute")])},deps:()=>[Fe,tt,Je,Ke]};class rt extends Ve{constructor(){super(...arguments),this.baseGranularity="day",this.granularity="hour",this.option=this.options.byHourOfDay.slice().reverse()}}class nt extends Ye{constructor(){super(...arguments),this.baseGranularity="day",this.granularity="hour",this.option=this.options.byHourOfDay}}const it={name:"ByHourOfDay",get:e=>void 0===e.options.byHourOfDay?null:e.reverse?new rt(e):new nt(e),normalizeOptions:(e,t)=>{if(void 0!==e.byHourOfDay){if(!We(e.byHourOfDay))throw new x('"byHourOfDay" expects a non-empty array');if(e.byHourOfDay.some(e=>e<0||e>23))throw new x('"byHourOfDay" values must be >= 0 && <= 23');t.byHourOfDay=e.byHourOfDay,t.byHourOfDay.sort(N)}else["YEARLY","MONTHLY","WEEKLY","DAILY"].includes(e.frequency)&&(t.byHourOfDay=[t.start.get("hour")])},deps:()=>[Fe,it,tt,Je,Ke]};function ot(e,t){return e.add(g(e.get("weekday"),t),"day")}function at(e,t,r){let n=e.set("day",1);return r<0&&(n=n.add(1,"month")),n=ot(n,t),r<0?n.add(r,"week"):n.add(r-1,"week")}class st extends ze{run(e){const t=ut(e,this.options.byDayOfMonth,this.options.byDayOfWeek),r=e.get("day");for(const n of t)if(!(r>n))return r===n?this.validateDate(new F(e)):this.validateDate(new W(e.granularity("month").set("day",n)));let n,i=e,o=0;for(;!n&&o<30;)i=i.granularity("month").add(1,"month"),n=ut(i,this.options.byDayOfMonth,this.options.byDayOfWeek)[0],o++;if(o>=13)throw new U("byDayOfMonth Infinite while loop");return this.validateDate(new W(i.set("day",n)))}}function ut(e,t,r){const n=e.endGranularity("month").get("day");let i=t.filter(e=>n>=Math.abs(e)).map(e=>e>0?e:n+e+1);if(r){const t=e.granularity("month"),n=[];r.forEach(r=>{if("string"==typeof r)return void n.push(...i.filter(e=>t.set("day",e).get("weekday")===r));const o=at(e,...r).get("day");i.includes(o)&&n.push(o)}),i=Array.from(new Set(n))}return i.sort((e,t)=>e>t?1:e=13)throw new U("byDayOfMonth Infinite while loop");return this.validateDate(new W(i.set("day",n)))}}const lt={name:"ByDayOfMonth",get:e=>void 0===e.options.byDayOfMonth?null:e.reverse?new ct(e):new st(e),normalizeOptions:(e,t)=>{if(void 0!==e.byDayOfMonth){if("WEEKLY"===e.frequency)throw new x('when "frequency" is "WEEKLY", "byDayOfMonth" cannot be present');if(!We(e.byDayOfMonth))throw new x('"byDayOfMonth" expects a non-empty array');if(e.byDayOfMonth.some(e=>0===e||e<-31||e>31))throw new x('"byDayOfMonth" values must be `num !== 0 && num <= 31 && num >= -31`');t.byDayOfMonth=e.byDayOfMonth.slice()}else We(e.byDayOfWeek)||We(e.byDayOfYear)||!["YEARLY","MONTHLY"].includes(e.frequency)||(t.byDayOfMonth=[t.start.get("day")])},deps:()=>[Fe,lt,it,tt,Je,Ke]};function ft(e,t,r){let n=e.set("month",1).set("day",1);return r<0&&(n=n.add(1,"year")),n=ot(n,t),r<0?n.add(r,"week"):n.add(r-1,"week")}function dt(e,t){const r=g(e.get("weekday"),t);return e.subtract(0===r?0:7-r,"day")}class ht extends qe{run(e){return"YEARLY"===this.options.frequency?void 0===this.options.byMonthOfYear?this.expandYearly(e):this.expandMonthly(e):"MONTHLY"===this.options.frequency?this.expandMonthly(e):this.expand(e)}expandYearly(e){let t=pt(e,this.options.byDayOfWeek)[0],r=0,n=e;for(;!t&&r<28;)r++,n=n.granularity("year").subtract(1,"millisecond"),t=pt(n,this.options.byDayOfWeek)[0];if(!t)throw new U("The byDayOfWeek rule appears to contain an impossible combination");return this.result(e,t)}expandMonthly(e){let t=gt(e,this.options.byDayOfWeek)[0],r=0,n=e;for(;!t&&r<50;)r++,n=n.granularity("month").subtract(1,"millisecond"),t=gt(n,this.options.byDayOfWeek)[0];if(!t)throw new U("The byDayOfWeek rule appears to contain an impossible combination");return this.result(e,t)}expand(e){const t=this.options.byDayOfWeek.map(t=>dt(e,t)).sort(f).pop();return this.result(e,t)}result(e,t){return t.isEqual(e)?this.validateDate(new F(e)):this.validateDate(new W(t.endGranularity("day")))}}function pt(e,t){return d([...t.filter(e=>Array.isArray(e)).map(t=>ft(e,...t)),...t.filter(e=>"string"==typeof e).map(t=>dt(e,t)).filter(t=>t.get("year")===e.get("year"))]).filter(t=>t.isBeforeOrEqual(e)).sort(f).reverse()}function gt(e,t){return d([...t.filter(e=>Array.isArray(e)).map(t=>at(e,...t)),...t.filter(e=>"string"==typeof e).map(t=>dt(e,t)).filter(t=>t.get("year")===e.get("year")&&t.get("month")===e.get("month"))]).filter(t=>t.isBeforeOrEqual(e)).sort(f).reverse()}class mt extends ze{run(e){return"YEARLY"===this.options.frequency?void 0===this.options.byMonthOfYear?this.expandYearly(e):this.expandMonthly(e):"MONTHLY"===this.options.frequency?this.expandMonthly(e):this.expand(e)}expandYearly(e){let t=yt(e,this.options.byDayOfWeek)[0],r=0,n=e;for(;!t&&r<28;)r++,n=n.granularity("year").add(1,"year"),t=yt(n,this.options.byDayOfWeek)[0];if(!t)throw new U("The byDayOfWeek rule appears to contain an impossible combination");return this.result(e,t)}expandMonthly(e){let t=bt(e,this.options.byDayOfWeek)[0],r=0,n=e;for(;!t&&r<50;)r++,n=n.granularity("month").add(1,"month"),t=bt(n,this.options.byDayOfWeek)[0];if(!t)throw new U("The byDayOfWeek rule appears to contain an impossible combination");return this.result(e,t)}expand(e){const t=this.options.byDayOfWeek.map(t=>ot(e,t)).sort(f)[0];return this.result(e,t)}result(e,t){return t.isEqual(e)?this.validateDate(new F(e)):this.validateDate(new W(t.granularity("day")))}}function yt(e,t){return d([...t.filter(e=>Array.isArray(e)).map(t=>ft(e,...t)),...t.filter(e=>"string"==typeof e).map(t=>ot(e,t)).filter(t=>t.get("year")===e.get("year"))]).filter(t=>t.isAfterOrEqual(e)).sort(f)}function bt(e,t){return d([...t.filter(e=>Array.isArray(e)).map(t=>at(e,...t)),...t.filter(e=>"string"==typeof e).map(t=>ot(e,t)).filter(t=>t.get("year")===e.get("year")&&t.get("month")===e.get("month"))]).filter(t=>t.isAfterOrEqual(e)).sort(f)}const _t={name:"ByDayOfWeek",get:e=>void 0===e.options.byDayOfWeek?null:e.reverse?new ht(e):new mt(e),normalizeOptions:(e,t)=>{if(void 0!==e.byDayOfWeek){if(!We(e.byDayOfWeek))throw new x('"byDayOfWeek" expects a non-empty array');const r=e.byDayOfWeek.find(e=>Array.isArray(e)?!s.WEEKDAYS.includes(e[0]):!s.WEEKDAYS.includes(e));if(r)throw new x(`"byDayOfWeek" expects weedays in the form ${JSON.stringify(s.WEEKDAYS)} but "${r}" was provided`);if(!["YEARLY","MONTHLY"].includes(e.frequency)&&e.byDayOfWeek.some(e=>Array.isArray(e)))throw new x('"byDayOfWeek" can only include a numeric value (i.e. `[string, number]`) when the "frequency" is either "MONTHLY" or "YEARLY"');if("MONTHLY"===e.frequency&&e.byDayOfWeek.some(e=>Array.isArray(e)&&(e[1]<-31||0===e[1]||e[1]>31)))throw new x('when "frequency" is "MONTHLY", each "byDayOfWeek" can optionally only have a numeric value >= -31 and <= 31 and !== 0');if("YEARLY"===e.frequency&&e.byDayOfWeek.some(e=>Array.isArray(e)&&(e[1]<-366||0===e[1]||e[1]>366)))throw new x('when "frequency" is "YEARLY", each "byDayOfWeek" can optionally only have a numeric value >= -366 and <= 366 and !== 0');t.byDayOfWeek=e.byDayOfWeek}else We(e.byDayOfMonth)||"WEEKLY"!==e.frequency||(t.byDayOfWeek=[t.start.get("weekday")])},deps:()=>[Fe,_t,it,tt,Je,Ke]};class wt extends qe{constructor(){super(...arguments),this.option=this.processor.options.byMonthOfYear.slice().reverse()}run(e){const t=e.get("month");for(const r of this.option)if(!(tr))return t===r?this.validateDate(new F(e)):this.validateDate(new W(e.granularity("year").set("month",r)));return this.validateDate(new W(e.granularity("year").add(1,"year").set("month",this.options.byMonthOfYear[0])))}}const Et={name:"ByMonthOfYear",get:e=>void 0===e.options.byMonthOfYear?null:e.reverse?new wt(e):new vt(e),normalizeOptions:(e,t)=>{if(void 0!==e.byMonthOfYear){if(!We(e.byMonthOfYear))throw new x('"byMonthOfYear" expects a non-empty array');if(e.byMonthOfYear.some(e=>e<1||e>12))throw new x('"byMonthOfYear" values must be `num >= 1 && num >= 12`');t.byMonthOfYear=e.byMonthOfYear.slice(),t.byMonthOfYear.sort(N)}else We(e.byDayOfMonth)||We(e.byDayOfWeek)||We(e.byDayOfYear)||"YEARLY"!==e.frequency||(t.byMonthOfYear=[t.start.get("month")])},deps:()=>[Fe,Et,lt,it,tt,Je,Ke]},St=[Fe,Et,lt,_t,it,tt,Je,Ke];class Ot extends o{constructor(e,t={}){if(super(void 0,t),!["UTC",null,void 0].includes(t.timezone))throw new n(`StandardDateAdapter only supports "UTC" and local time zones but "${t.timezone}" was provided.`);this._date=new Date(e),this.timezone=void 0!==t.timezone?t.timezone:null,this.assertIsValid()}static isDate(e){return"[object Date]"===Object.prototype.toString.call(e)}static fromDate(e,t){return new Ot(e,t)}static fromJSON(e){const t=[e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond];switch(e.timezone){case"UTC":return new Ot(new Date(Date.UTC(...t)),{timezone:"UTC",duration:e.duration});case null:return new Ot(new Date(...t),{timezone:null,duration:e.duration});default:throw new n(`The \`StandardDateAdapter\` only supports datetimes in UTC or LOCAL (null) time. You provided a JSON object with timezone "${e.timezone}".`)}}static fromDateTime(e){const t=Ot.fromJSON(e.toJSON());return t.generators.push(...e.generators),t}get date(){return new Date(this._date)}get end(){if(this.duration)return this._end||(this._end=Ot.fromDateTime(this.toDateTime().add(this.duration,"millisecond")).date),this._end}set(e,t){if("timezone"===e)return this.timezone===t?this:new Ot(this._date,{timezone:t,duration:this.duration,generators:this.generators});if("duration"===e)return this.duration===t?this:new Ot(this._date,{timezone:this.timezone,duration:t,generators:this.generators});throw new j(`Unknown prop "${e}" for StandardDateAdapter#set()`)}valueOf(){return this._date.valueOf()}toJSON(){let e;return e="UTC"===this.timezone?{timezone:this.timezone,year:this._date.getUTCFullYear(),month:this._date.getUTCMonth()+1,day:this._date.getUTCDate(),hour:this._date.getUTCHours(),minute:this._date.getUTCMinutes(),second:this._date.getUTCSeconds(),millisecond:this._date.getUTCMilliseconds()}:{timezone:this.timezone,year:this._date.getFullYear(),month:this._date.getMonth()+1,day:this._date.getDate(),hour:this._date.getHours(),minute:this._date.getMinutes(),second:this._date.getSeconds(),millisecond:this._date.getMilliseconds()},this.duration&&(e.duration=this.duration),e}assertIsValid(){if(!Ot.isDate(this._date)||isNaN(this._date.valueOf()))throw new n("StandardDateAdapter has invalid date.");if(![null,"UTC"].includes(this.timezone))throw new n(`StandardDateAdapter only supports local (null) and UTC timezones but "${this.timezone}" was specified.`);if(this.duration&&this.duration<=0)throw new n("If provided, duration must be greater than 0.");return!0}}Ot.hasTimezoneSupport=!1,o.adapter=Ot,Me.recurrenceRules=St;class Tt extends Error{}class At extends Error{}function Mt(e,t,r){r.data&&(!0===r.data?t.data=e.data:t.data=r.data(e),void 0===t.data&&delete t.data)}function Dt(e,t){z.JSON_FN_MAP.set(e,t)}z.JSON_FN_MAP=new Map,z.prototype.toJSON=function(e){throw new At(`To support smaller bundles, ${this.constructor.name}#toJSON() must be manually added. See "@rschedule/json-tools" in the rSchedule docs.`)},z.fromJSON=function(e,t){if("object"!=typeof e||null===e)throw new Tt(`Invalid json "${e}"`);const r=z.JSON_FN_MAP.get(e.type);if(!r)throw new Tt(`Unknown rSchedule object type "${e.type}". Have you added a json serializer for "${e.type}"? See "@rschedule/json-tools" in the rSchedule docs.`);return r(e,t)},te.prototype.toJSON=function(e={}){const t={type:"Dates",dates:this.adapters.map(e=>e.toJSON())};return e.nested||(t.timezone=this.timezone),Mt(this,t,e),t},te.fromJSON=function(e,t={}){if("Dates"!==e.type)throw new Tt("Invalid Dates JSON");return new te({dates:e.dates.map(e=>o.adapter.fromJSON(e)),data:"function"==typeof t.data?t.data(e):e.data,timezone:t.timezone||e.timezone})},Dt("Dates",te.fromJSON),Me.prototype.toJSON=function(e={}){const t={type:"Rule",config:Object.assign(Object.assign({},k(this.options)),{start:this.normalizeDateInput(this.options.start).toJSON()})};return this.options.end&&(t.config.end=this.normalizeDateInput(this.options.end).toJSON()),e.nested||(t.timezone=this.timezone),Mt(this,t,e),t},Me.fromJSON=function(e,t={}){const r=Object.assign(Object.assign({},e.config),{start:o.adapter.fromJSON(e.config.start),end:e.config.end&&o.adapter.fromJSON(e.config.end)});return new Me(r,{data:"function"==typeof t.data?t.data(e):e.data,timezone:t.timezone||e.timezone})},Dt("Rule",Me.fromJSON),Ce.prototype.toJSON=function(e={}){const t={type:"Schedule",rrules:this.rrules.map(t=>t.toJSON(Object.assign(Object.assign({},e),{nested:!0}))),exrules:this.exrules.map(t=>t.toJSON(Object.assign(Object.assign({},e),{nested:!0}))),rdates:this.rdates.toJSON(Object.assign(Object.assign({},e),{nested:!0})),exdates:this.exdates.toJSON(Object.assign(Object.assign({},e),{nested:!0}))};return e.nested||(t.timezone=this.timezone),Mt(this,t,e),t},Ce.fromJSON=function(e,t={}){if("Schedule"!==e.type)throw new Tt("Invalid Schedule JSON");return new Ce({rrules:e.rrules.map(r=>Me.fromJSON(r,Object.assign({timezone:e.timezone},t))),exrules:e.exrules.map(r=>Me.fromJSON(r,Object.assign({timezone:e.timezone},t))),rdates:te.fromJSON(e.rdates,Object.assign({timezone:e.timezone},t)),exdates:te.fromJSON(e.exdates,Object.assign({timezone:e.timezone},t)),data:"function"==typeof t.data?t.data(e):e.data,timezone:t.timezone||e.timezone})},Dt("Schedule",Ce.fromJSON)},function(e,t,r){"use strict";r.d(t,"a",(function(){return i})),r.d(t,"b",(function(){return o}));var n=["D","DD","YY","YYYY"];function i(e){return-1!==n.indexOf(e)}function o(e){throw new RangeError("`options.awareOfUnicodeTokens` must be set to `true` to use `"+e+"` token; see: https://git.io/fxCyr")}},function(e,t,r){"use strict";r.d(t,"a",(function(){return y})),r.d(t,"c",(function(){return b})),r.d(t,"b",(function(){return _})),r.d(t,"d",(function(){return w})),r.d(t,"e",(function(){return v}));var n=r(4),i=r.n(n),o=r(2),a=r(15),s=r(8),u=r(37);function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;te.match(/\.sqlite$/)));const o=await Promise.all(n.map(async e=>{const t=await i.a.getModifiedTime(i.a.join(r,e));return{id:e,date:new Date(t)}}));return o.sort((e,t)=>e.datet.date?-1:0),o}async function y(e){let t=await m(e),r=await async function(e){const t=i.a.getBudgetDir(e);return await i.a.exists(i.a.join(t,"db.latest.sqlite"))?{id:"db.latest.sqlite",date:null,isLatest:!0}:null}(e);return r&&t.unshift(r),t=t.map(e=>l(l({},e),{},{date:e.date?p.format(e.date,"yyyy-MM-dd h:mm"):null})),t}async function b(e){const t=i.a.getBudgetDir(e);await i.a.exists(i.a.join(t,"db.latest.sqlite"))&&await i.a.removeFile(i.a.join(i.a.getBudgetDir(e),"db.latest.sqlite"));let r=h.v4Sync()+".sqlite",n=i.a.join(t,"backups",r);await i.a.exists(i.a.join(t,"backups"))||await i.a.mkdir(i.a.join(t,"backups")),await i.a.copyFile(i.a.join(t,"db.sqlite"),n);const s=a.openDatabase(n);await a.runQuery(s,"DELETE FROM messages_crdt"),await a.runQuery(s,"DELETE FROM messages_clock"),a.closeDatabase(s);const u=await async function(e){const t=e.reduce((e,t)=>{const r=p.format(t.date,"yyyy-MM-dd");return e[r]=e[r]||[],e[r].push(t),e},{}),r=[];for(let e of Object.keys(t)){const n=t[e],i=e===o.d();for(let e of n.slice(i?3:1))r.push(e.id)}const n=e.filter(e=>!r.includes(e.id));return r.concat(n.slice(10).map(e=>e.id))}(await m(e));for(let e of u)await i.a.removeFile(i.a.join(t,"backups",e));d.send("backups-updated",await y(e))}async function _(e,t){const r=i.a.getBudgetDir(e);if(await i.a.exists(i.a.join(r,"db.latest.sqlite"))||(await i.a.copyFile(i.a.join(r,"db.sqlite"),i.a.join(r,"db.latest.sqlite")),await i.a.copyFile(i.a.join(r,"metadata.json"),i.a.join(r,"metadata.latest.json")),v(),w(e),await s.c(e)),"db.latest.sqlite"===t){console.log("Reverting backup"),await i.a.copyFile(i.a.join(r,"db.latest.sqlite"),i.a.join(r,"db.sqlite")),await i.a.copyFile(i.a.join(r,"metadata.latest.json"),i.a.join(r,"metadata.json")),await i.a.removeFile(i.a.join(r,"db.latest.sqlite")),await i.a.removeFile(i.a.join(r,"metadata.latest.json"));try{await u.h()}catch(e){}s.e()}else{console.log("Loading backup",t),await s.c(e),await s.d({groupId:null,lastSyncedTimestamp:null,lastUploaded:null});try{await u.h()}catch(e){}s.e(),await i.a.copyFile(i.a.join(r,"backups",t),i.a.join(r,"db.sqlite"))}}function w(e){g&&clearInterval(g),g=setInterval(async()=>{console.log("Making backup"),await b(e)},9e5)}function v(){clearInterval(g),g=null}},function(e,t,r){"use strict";r.d(t,"b",(function(){return h})),r.d(t,"a",(function(){return m})),r.d(t,"c",(function(){return w}));var n=r(9),i=r.n(n),o=r(76);function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r{y?b.push([e,[u,...t]]):e(u,...t)}}const w=_((e,t,r)=>{}),v=_((e,t)=>{})},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.constants={O_RDONLY:0,O_WRONLY:1,O_RDWR:2,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,O_CREAT:64,O_EXCL:128,O_NOCTTY:256,O_TRUNC:512,O_APPEND:1024,O_DIRECTORY:65536,O_NOATIME:262144,O_NOFOLLOW:131072,O_SYNC:1052672,O_DIRECT:16384,O_NONBLOCK:2048,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1,F_OK:0,R_OK:4,W_OK:2,X_OK:1,UV_FS_SYMLINK_DIR:1,UV_FS_SYMLINK_JUNCTION:2,UV_FS_COPYFILE_EXCL:1,UV_FS_COPYFILE_FICLONE:2,UV_FS_COPYFILE_FICLONE_FORCE:4,COPYFILE_EXCL:1,COPYFILE_FICLONE:2,COPYFILE_FICLONE_FORCE:4}},function(e,t,r){e.exports=i;var n=r(63).EventEmitter;function i(){n.call(this)}r(11)(i,n),i.Readable=r(142),i.Writable=r(303),i.Duplex=r(304),i.Transform=r(305),i.PassThrough=r(306),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(l(),0===n.listenerCount(this,"error"))throw e}function l(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",l),r.removeListener("close",l),e.removeListener("close",l)}return r.on("error",c),e.on("error",c),r.on("end",l),r.on("close",l),e.on("close",l),e.emit("pipe",r),e}},function(e,t,r){function n(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===n(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===n(e)},t.isObject=function(e){return"object"==typeof e&&null!==e},t.isDate=function(e){return"[object Date]"===n(e)},t.isError=function(e){return"[object Error]"===n(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof e},t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=r(10).Buffer.isBuffer},function(e,t,r){"use strict";var n=r(11),i=r(146),o=r(148),a=r(149),s=r(71);function u(e){s.call(this,"digest"),this._hash=e}n(u,s),u.prototype._update=function(e){this._hash.update(e)},u.prototype._final=function(){return this._hash.digest()},e.exports=function(e){return"md5"===(e=e.toLowerCase())?new i:"rmd160"===e||"ripemd160"===e?new o:new u(a(e))}},function(e,t,r){(function(t){e.exports=function(e,r){for(var n=Math.min(e.length,r.length),i=new t(n),o=0;o=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o!a.has(e));if(u.length>0){let t=n("("+u.map(e=>r(e)).join(" OR ")+")"),s=await e(t,i,!0);a=new Set([...a,...u]),o=o.concat(s)}}return o}function i(e,t){return t+" IN ("+[...new Set(e)].map(e=>`'${e}'`).join(",")+")"}r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return i}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(3),i=r(27),o={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},a=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,s=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,u=/^([+-])(\d{2})(?::?(\d{2}))?$/;function c(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var r=t||{},o=null==r.additionalDigits?2:Object(n.a)(r.additionalDigits);if(2!==o&&1!==o&&0!==o)throw new RangeError("additionalDigits must be 0, 1 or 2");if("string"!=typeof e&&"[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);var a=l(e),s=f(a.date,o),u=d(s.restDateString,s.year);if(isNaN(u)||!u)return new Date(NaN);var c,h=u.getTime(),g=0;if(a.time&&(g=p(a.time),isNaN(g)))return new Date(NaN);if(a.timezone){if(c=m(a.timezone),isNaN(c))return new Date(NaN)}else{var y=h+g,b=new Date(y);c=Object(i.a)(b);var _=new Date(y);_.setDate(b.getDate()+1);var w=Object(i.a)(_)-c;w>0&&(c+=w)}return new Date(h+g+c)}function l(e){var t,r={},n=e.split(o.dateTimeDelimiter);if(/:/.test(n[0])?(r.date=null,t=n[0]):(r.date=n[0],t=n[1],o.timeZoneDelimiter.test(r.date)&&(r.date=e.split(o.timeZoneDelimiter)[0],t=e.substr(r.date.length,e.length))),t){var i=o.timezone.exec(t);i?(r.time=t.replace(i[1],""),r.timezone=i[1]):r.time=t}return r}function f(e,t){var r=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),n=e.match(r);if(!n)return{year:null};var i=n[1]&&parseInt(n[1]),o=n[2]&&parseInt(n[2]);return{year:null==o?i:100*o,restDateString:e.slice((n[1]||n[2]).length)}}function d(e,t){if(null===t)return null;var r=e.match(a);if(!r)return null;var n=!!r[4],i=h(r[1]),o=h(r[2])-1,s=h(r[3]),u=h(r[4])-1,c=h(r[5])-1;if(n)return function(e,t,r){return!(t<0||t>52||r<0||r>6)}(0,u,c)?function(e,t,r){var n=new Date(0);n.setUTCFullYear(e,0,4);var i=n.getUTCDay()||7,o=7*(t||0)+(r||0)+1-i;return n.setUTCDate(n.getUTCDate()+o),n}(t,u,c):new Date(NaN);var l=new Date(0);return function(e,t,r){return!(t<0||t>11||r<1||r>(y[t]||(b(e)?29:28)))}(t,o,s)&&function(e,t){return!(t<1||t>(b(e)?366:365))}(t,i)?(l.setUTCFullYear(t,o,Math.max(i,s)),l):new Date(NaN)}function h(e){return e?parseInt(e):1}function p(e){var t=e.match(s);if(!t)return null;var r=g(t[1]),n=g(t[2]),i=g(t[3]);return function(e,t,r){return!(r<0||r>=60||t<0||t>=60||e<0||e>=25)}(r,n,i)?r%24*36e5+6e4*n+1e3*i:NaN}function g(e){return e&&parseFloat(e.replace(",","."))||0}function m(e){if("Z"===e)return 0;var t=e.match(u);if(!t)return 0;var r="+"===t[1]?-1:1,n=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return function(e,t){return!(t<0||t>59)}(0,i)?r*(36e5*n+6e4*i):NaN}var y=[31,null,31,30,31,30,31,31,30,31,30,31];function b(e){return e%400==0||e%4==0&&e%100}},function(e,t,r){"use strict";r.d(t,"b",(function(){return s})),r.d(t,"a",(function(){return c}));var n=r(1),i=r(7);let o,a;async function s(){let e=(await n.all("SELECT * FROM category_mapping")).map(e=>[e.id,e.transferId]),t=(await n.all("SELECT * FROM payee_mapping")).map(e=>[e.id,e.targetId]);o=new Map(e.concat(t)),a&&a(),a=Object(i.a)(u)}function u(e,t){t.forEach((e,t)=>{if(-1!==t.indexOf("mapping")){let r="category_mapping"===t?"transferId":"targetId";e.forEach(e=>{o.set(e.id,e[r])})}})}function c(){return o}},function(e,t,r){"use strict";r.d(t,"b",(function(){return f})),r.d(t,"a",(function(){return d})),r.d(t,"c",(function(){return h}));var n=r(1);function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}async function a(e){if(e.payee){let t=await n.first("SELECT id, transfer_acct FROM v_payees WHERE id = ?",[e.payee]),r=t.transfer_acct;t.id;return r}return null}async function s(e,t){return(await n.first("SELECT offbudget FROM accounts WHERE id = ?",[e.account])).offbudget===(await n.first("SELECT offbudget FROM accounts WHERE id = ?",[t])).offbudget&&(await n.updateTransaction({id:e.id,category:null}),!0)}async function u(e,t){let r=(await n.first("SELECT id FROM payees WHERE transfer_acct = ?",[e.account])).id;if(e.parent_id){let t=await n.first("\n SELECT p.id, p.transfer_acct FROM v_transactions t\n LEFT JOIN payees p ON p.id = t.payee\n WHERE t.id = ?\n ",[e.parent_id]);if(t.transfer_acct)return t.id!==e.payee?(await n.updateTransaction({id:e.id,payee:null}),{id:e.id,payee:null}):null}const a=await n.insertTransaction({account:t,amount:-e.amount,payee:r,date:e.date,transfer_id:e.id,notes:e.notes||null,cleared:!1});await n.updateTransaction({id:e.id,transfer_id:a});const u=await s(e,t);return function(e){for(var t=1;t=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(r)?n.showHidden=r:r&&t._extend(n,r),b(n.showHidden)&&(n.showHidden=!1),b(n.depth)&&(n.depth=2),b(n.colors)&&(n.colors=!1),b(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),l(n,e,n.depth)}function u(e,t){var r=s.styles[t];return r?"["+s.colors[r][0]+"m"+e+"["+s.colors[r][1]+"m":e}function c(e,t){return e}function l(e,r,n){if(e.customInspect&&r&&S(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,e);return y(i)||(i=l(e,i,n)),i}var o=function(e,t){if(b(t))return e.stylize("undefined","undefined");if(y(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(m(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(g(t))return e.stylize("null","null")}(e,r);if(o)return o;var a=Object.keys(r),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(r)),E(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return f(r);if(0===a.length){if(S(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(_(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(v(r))return e.stylize(Date.prototype.toString.call(r),"date");if(E(r))return f(r)}var c,w="",O=!1,T=["{","}"];(h(r)&&(O=!0,T=["[","]"]),S(r))&&(w=" [Function"+(r.name?": "+r.name:"")+"]");return _(r)&&(w=" "+RegExp.prototype.toString.call(r)),v(r)&&(w=" "+Date.prototype.toUTCString.call(r)),E(r)&&(w=" "+f(r)),0!==a.length||O&&0!=r.length?n<0?_(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),c=O?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,w,T)):T[0]+w+T[1]}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function d(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),D(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=g(r)?l(e,u.value,null):l(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),b(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function h(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function y(e){return"string"==typeof e}function b(e){return void 0===e}function _(e){return w(e)&&"[object RegExp]"===O(e)}function w(e){return"object"==typeof e&&null!==e}function v(e){return w(e)&&"[object Date]"===O(e)}function E(e){return w(e)&&("[object Error]"===O(e)||e instanceof Error)}function S(e){return"function"==typeof e}function O(e){return Object.prototype.toString.call(e)}function T(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(r){if(b(o)&&(o=e.env.NODE_DEBUG||""),r=r.toUpperCase(),!a[r])if(new RegExp("\\b"+r+"\\b","i").test(o)){var n=e.pid;a[r]=function(){var e=t.format.apply(t,arguments);console.error("%s %d: %s",r,n,e)}}else a[r]=function(){};return a[r]},t.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=h,t.isBoolean=p,t.isNull=g,t.isNullOrUndefined=function(e){return null==e},t.isNumber=m,t.isString=y,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=b,t.isRegExp=_,t.isObject=w,t.isDate=v,t.isError=E,t.isFunction=S,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=r(293);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(){var e=new Date,t=[T(e.getHours()),T(e.getMinutes()),T(e.getSeconds())].join(":");return[e.getDate(),A[e.getMonth()],t].join(" ")}function D(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",M(),t.format.apply(t,arguments))},t.inherits=r(294),t._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};var I="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function j(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(I&&e[I]){var t;if("function"!=typeof(t=e[I]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,I,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,n=new Promise((function(e,n){t=e,r=n})),i=[],o=0;o=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},r(297),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(23))},function(e,t,r){"use strict";(function(t){void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,a,s=arguments.length;switch(s){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick((function(){e.call(null,r)}));case 3:return t.nextTick((function(){e.call(null,r,n)}));case 4:return t.nextTick((function(){e.call(null,r,n,i)}));default:for(o=new Array(s-1),a=0;a>>24]^l[p>>>16&255]^f[g>>>8&255]^d[255&m]^t[y++],a=c[p>>>24]^l[g>>>16&255]^f[m>>>8&255]^d[255&h]^t[y++],s=c[g>>>24]^l[m>>>16&255]^f[h>>>8&255]^d[255&p]^t[y++],u=c[m>>>24]^l[h>>>16&255]^f[p>>>8&255]^d[255&g]^t[y++],h=o,p=a,g=s,m=u;return o=(n[h>>>24]<<24|n[p>>>16&255]<<16|n[g>>>8&255]<<8|n[255&m])^t[y++],a=(n[p>>>24]<<24|n[g>>>16&255]<<16|n[m>>>8&255]<<8|n[255&h])^t[y++],s=(n[g>>>24]<<24|n[m>>>16&255]<<16|n[h>>>8&255]<<8|n[255&p])^t[y++],u=(n[m>>>24]<<24|n[h>>>16&255]<<16|n[p>>>8&255]<<8|n[255&g])^t[y++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],u=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var c=s^s<<1^s<<2^s<<3^s<<4;c=c>>>8^255&c^99,r[a]=c,n[c]=a;var l=e[a],f=e[l],d=e[f],h=257*e[c]^16843008*c;i[0][a]=h<<24|h>>>8,i[1][a]=h<<16|h>>>16,i[2][a]=h<<8|h>>>24,i[3][a]=h,h=16843009*d^65537*f^257*l^16843008*a,o[0][c]=h<<24|h>>>8,o[1][c]=h<<16|h>>>16,o[2][c]=h<<8|h>>>24,o[3][c]=h,0===a?a=s=1:(a=l^e[e[e[d^l]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=i(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a],a^=s[o/t|0]<<24):t>6&&o%t==4&&(a=u.SBOX[a>>>24]<<24|u.SBOX[a>>>16&255]<<16|u.SBOX[a>>>8&255]<<8|u.SBOX[255&a]),i[o]=i[o-t]^a}for(var c=[],l=0;l>>24]]^u.INV_SUB_MIX[1][u.SBOX[d>>>16&255]]^u.INV_SUB_MIX[2][u.SBOX[d>>>8&255]]^u.INV_SUB_MIX[3][u.SBOX[255&d]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(e){return a(e=i(e),this._keySchedule,u.SUB_MIX,u.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=a(e,this._invKeySchedule,u.INV_SUB_MIX,u.INV_SBOX,this._nRounds),o=n.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o},c.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},e.exports.AES=c},function(e,t,r){var n=r(16).Buffer,i=r(146);e.exports=function(e,t,r,o){if(n.isBuffer(e)||(e=n.from(e,"binary")),t&&(n.isBuffer(t)||(t=n.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var a=r/8,s=n.alloc(a),u=n.alloc(o||0),c=n.alloc(0);a>0||o>0;){var l=new i;l.update(c),l.update(e),t&&l.update(t),c=l.digest();var f=0;if(a>0){var d=s.length-a;f=Math.min(a,c.length),c.copy(s,d,0,f),a-=f}if(f0){var h=u.length-o,p=Math.min(o,c.length-f);c.copy(u,h,f,f+p),o-=p}}return c.fill(0),{key:s,iv:u}}},function(e,t,r){"use strict";var n=r(35),i=r(45),o=i.getNAF,a=i.getJSF,s=i.assert;function u(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){s(e.precomputed);var r=e._getDoubles(),n=o(t,1,this._bitLength),i=(1<=a;l--)u=(u<<1)+n[l];c.push(u)}for(var f=this.jpoint(null,null,null),d=this.jpoint(null,null,null),h=i;h>0;h--){for(a=0;a=0;c--){for(var l=0;c>=0&&0===a[c];c--)l++;if(c>=0&&l++,u=u.dblp(l),c<0)break;var f=a[c];s(0!==f),u="affine"===e.type?f>0?u.mixedAdd(i[f-1>>1]):u.mixedAdd(i[-f-1>>1].neg()):f>0?u.add(i[f-1>>1]):u.add(i[-f-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){var s,u,c,l=this._wnafT1,f=this._wnafT2,d=this._wnafT3,h=0;for(s=0;s=1;s-=2){var g=s-1,m=s;if(1===l[g]&&1===l[m]){var y=[t[g],null,null,t[m]];0===t[g].y.cmp(t[m].y)?(y[1]=t[g].add(t[m]),y[2]=t[g].toJ().mixedAdd(t[m].neg())):0===t[g].y.cmp(t[m].y.redNeg())?(y[1]=t[g].toJ().mixedAdd(t[m]),y[2]=t[g].add(t[m].neg())):(y[1]=t[g].toJ().mixedAdd(t[m]),y[2]=t[g].toJ().mixedAdd(t[m].neg()));var b=[-3,-1,-5,-7,0,7,5,1,3],_=a(r[g],r[m]);for(h=Math.max(_[0].length,h),d[g]=new Array(h),d[m]=new Array(h),u=0;u=0;s--){for(var O=0;s>=0;){var T=!0;for(u=0;u=0&&O++,E=E.dblp(O),s<0)break;for(u=0;u0?c=f[u][A-1>>1]:A<0&&(c=f[u][-A-1>>1].neg()),E="affine"===c.type?E.mixedAdd(c):E.add(c))}}for(s=0;s=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=u?a=new RangeError(c):t=n.concat(i,o),i=[],e.close(),r(a,t)}e.on("error",(function(t){e.removeListener("end",s),e.removeListener("readable",a),r(t)})),e.on("end",s),e.end(t),a()}function b(e,t){if("string"==typeof t&&(t=n.from(t)),!n.isBuffer(t))throw new TypeError("Not a string or buffer");var r=e._finishFlushFlag;return e._processChunk(t,r)}function _(e){if(!(this instanceof _))return new _(e);M.call(this,e,o.DEFLATE)}function w(e){if(!(this instanceof w))return new w(e);M.call(this,e,o.INFLATE)}function v(e){if(!(this instanceof v))return new v(e);M.call(this,e,o.GZIP)}function E(e){if(!(this instanceof E))return new E(e);M.call(this,e,o.GUNZIP)}function S(e){if(!(this instanceof S))return new S(e);M.call(this,e,o.DEFLATERAW)}function O(e){if(!(this instanceof O))return new O(e);M.call(this,e,o.INFLATERAW)}function T(e){if(!(this instanceof T))return new T(e);M.call(this,e,o.UNZIP)}function A(e){return e===o.Z_NO_FLUSH||e===o.Z_PARTIAL_FLUSH||e===o.Z_SYNC_FLUSH||e===o.Z_FULL_FLUSH||e===o.Z_FINISH||e===o.Z_BLOCK}function M(e,r){var a=this;if(this._opts=e=e||{},this._chunkSize=e.chunkSize||t.Z_DEFAULT_CHUNK,i.call(this,e),e.flush&&!A(e.flush))throw new Error("Invalid flush flag: "+e.flush);if(e.finishFlush&&!A(e.finishFlush))throw new Error("Invalid flush flag: "+e.finishFlush);if(this._flushFlag=e.flush||o.Z_NO_FLUSH,this._finishFlushFlag=void 0!==e.finishFlush?e.finishFlush:o.Z_FINISH,e.chunkSize&&(e.chunkSizet.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBitst.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.levelt.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevelt.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=t.Z_FILTERED&&e.strategy!=t.Z_HUFFMAN_ONLY&&e.strategy!=t.Z_RLE&&e.strategy!=t.Z_FIXED&&e.strategy!=t.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!n.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._handle=new o.Zlib(r);var s=this;this._hadError=!1,this._handle.onerror=function(e,r){D(s),s._hadError=!0;var n=new Error(e);n.errno=r,n.code=t.codes[r],s.emit("error",n)};var u=t.Z_DEFAULT_COMPRESSION;"number"==typeof e.level&&(u=e.level);var c=t.Z_DEFAULT_STRATEGY;"number"==typeof e.strategy&&(c=e.strategy),this._handle.init(e.windowBits||t.Z_DEFAULT_WINDOWBITS,u,e.memLevel||t.Z_DEFAULT_MEMLEVEL,c,e.dictionary),this._buffer=n.allocUnsafe(this._chunkSize),this._offset=0,this._level=u,this._strategy=c,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!a._handle},configurable:!0,enumerable:!0})}function D(t,r){r&&e.nextTick(r),t._handle&&(t._handle.close(),t._handle=null)}function I(e){e.emit("close")}Object.defineProperty(t,"codes",{enumerable:!0,value:Object.freeze(h),writable:!1}),t.Deflate=_,t.Inflate=w,t.Gzip=v,t.Gunzip=E,t.DeflateRaw=S,t.InflateRaw=O,t.Unzip=T,t.createDeflate=function(e){return new _(e)},t.createInflate=function(e){return new w(e)},t.createDeflateRaw=function(e){return new S(e)},t.createInflateRaw=function(e){return new O(e)},t.createGzip=function(e){return new v(e)},t.createGunzip=function(e){return new E(e)},t.createUnzip=function(e){return new T(e)},t.deflate=function(e,t,r){return"function"==typeof t&&(r=t,t={}),y(new _(t),e,r)},t.deflateSync=function(e,t){return b(new _(t),e)},t.gzip=function(e,t,r){return"function"==typeof t&&(r=t,t={}),y(new v(t),e,r)},t.gzipSync=function(e,t){return b(new v(t),e)},t.deflateRaw=function(e,t,r){return"function"==typeof t&&(r=t,t={}),y(new S(t),e,r)},t.deflateRawSync=function(e,t){return b(new S(t),e)},t.unzip=function(e,t,r){return"function"==typeof t&&(r=t,t={}),y(new T(t),e,r)},t.unzipSync=function(e,t){return b(new T(t),e)},t.inflate=function(e,t,r){return"function"==typeof t&&(r=t,t={}),y(new w(t),e,r)},t.inflateSync=function(e,t){return b(new w(t),e)},t.gunzip=function(e,t,r){return"function"==typeof t&&(r=t,t={}),y(new E(t),e,r)},t.gunzipSync=function(e,t){return b(new E(t),e)},t.inflateRaw=function(e,t,r){return"function"==typeof t&&(r=t,t={}),y(new O(t),e,r)},t.inflateRawSync=function(e,t){return b(new O(t),e)},a.inherits(M,i),M.prototype.params=function(r,n,i){if(rt.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+r);if(n!=t.Z_FILTERED&&n!=t.Z_HUFFMAN_ONLY&&n!=t.Z_RLE&&n!=t.Z_FIXED&&n!=t.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+n);if(this._level!==r||this._strategy!==n){var a=this;this.flush(o.Z_SYNC_FLUSH,(function(){s(a._handle,"zlib binding closed"),a._handle.params(r,n),a._hadError||(a._level=r,a._strategy=n,i&&i())}))}else e.nextTick(i)},M.prototype.reset=function(){return s(this._handle,"zlib binding closed"),this._handle.reset()},M.prototype._flush=function(e){this._transform(n.alloc(0),"",e)},M.prototype.flush=function(t,r){var i=this,a=this._writableState;("function"==typeof t||void 0===t&&!r)&&(r=t,t=o.Z_FULL_FLUSH),a.ended?r&&e.nextTick(r):a.ending?r&&this.once("end",r):a.needDrain?r&&this.once("drain",(function(){return i.flush(t,r)})):(this._flushFlag=t,this.write(n.alloc(0),"",r))},M.prototype.close=function(t){D(this,t),e.nextTick(I,this)},M.prototype._transform=function(e,t,r){var i,a=this._writableState,s=(a.ending||a.ended)&&(!e||a.length===e.length);return null===e||n.isBuffer(e)?this._handle?(s?i=this._finishFlushFlag:(i=this._flushFlag,e.length>=a.length&&(this._flushFlag=this._opts.flush||o.Z_NO_FLUSH)),void this._processChunk(e,i,r)):r(new Error("zlib binding closed")):r(new Error("invalid input"))},M.prototype._processChunk=function(e,t,r){var i=e&&e.length,o=this._chunkSize-this._offset,a=0,l=this,f="function"==typeof r;if(!f){var d,h=[],p=0;this.on("error",(function(e){d=e})),s(this._handle,"zlib binding closed");do{var g=this._handle.writeSync(t,e,a,i,this._buffer,this._offset,o)}while(!this._hadError&&b(g[0],g[1]));if(this._hadError)throw d;if(p>=u)throw D(this),new RangeError(c);var m=n.concat(h,p);return D(this),m}s(this._handle,"zlib binding closed");var y=this._handle.write(t,e,a,i,this._buffer,this._offset,o);function b(u,c){if(this&&(this.buffer=null,this.callback=null),!l._hadError){var d=o-c;if(s(d>=0,"have should not go down"),d>0){var g=l._buffer.slice(l._offset,l._offset+d);l._offset+=d,f?l.push(g):(h.push(g),p+=g.length)}if((0===c||l._offset>=l._chunkSize)&&(o=l._chunkSize,l._offset=0,l._buffer=n.allocUnsafe(l._chunkSize)),0===c){if(a+=i-u,i=u,!f)return!0;var m=l._handle.write(t,e,a,i,l._buffer,l._offset,l._chunkSize);return m.callback=b,void(m.buffer=e)}if(!f)return!1;r()}}y.buffer=e,y.callback=b},a.inherits(_,M),a.inherits(w,M),a.inherits(v,M),a.inherits(E,M),a.inherits(S,M),a.inherits(O,M),a.inherits(T,M)}).call(this,r(19))},function(e,t,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var n in r)i(r,n)&&(e[n]=r[n])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var o={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o>>0,1)},emit:function(t,r){(e.get(t)||[]).slice().map((function(e){e(r)})),(e.get("*")||[]).slice().map((function(e){e(t,r)}))}}}},function(e,t){e.exports={fetch:self.fetch,fetchBinary:()=>{throw new Error("fetchBinary not implemented")}}},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(0),i=r(60);function o(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(n.a)(e),r=t.getUTCFullYear(),o=new Date(0);o.setUTCFullYear(r+1,0,4),o.setUTCHours(0,0,0,0);var a=Object(i.a)(o),s=new Date(0);s.setUTCFullYear(r,0,4),s.setUTCHours(0,0,0,0);var u=Object(i.a)(s);return t.getTime()>=a.getTime()?r+1:t.getTime()>=u.getTime()?r:r-1}},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(3),i=r(57);function o(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(n.a)(t);return Object(i.a)(e,-r)}},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(3),i=r(47);function o(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(n.a)(t);return Object(i.a)(e,-r)}},function(e,t,r){"use strict";function n(e,t){switch(e){case"brokerage":case"investment":return"investment";case"credit":return"credit";case"loan":return"debt";case"other":return"other";case"depository":default:switch(t){case"money market":case"savings":return"savings";case"cd":return"cd";default:return"checking"}}}r.d(t,"a",(function(){return n}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(1);async function i(){let e=await n.first("\n SELECT * FROM categories\n WHERE is_income = 1 AND\n LOWER(name) = 'starting balances' AND\n tombstone = 0\n ");return null===e&&(e=await n.first("SELECT * FROM categories WHERE is_income = 1 AND tombstone = 0")),{id:await async function(e){let t=await n.first("SELECT id FROM payees WHERE LOWER(name) = ? AND tombstone = 0",[e.toLowerCase()]);return t?t.id:n.insertPayee({name:e})}("Starting Balance"),category:e?e.id:null}}},function(e,t,r){"use strict";r.d(t,"a",(function(){return u}));var n=r(0),i=r(51),o=r(3),a=r(92);function s(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var r=t||{},n=r.locale,s=n&&n.options&&n.options.firstWeekContainsDate,u=null==s?1:Object(o.a)(s),c=null==r.firstWeekContainsDate?u:Object(o.a)(r.firstWeekContainsDate),l=Object(a.a)(e,t),f=new Date(0);f.setUTCFullYear(l,0,c),f.setUTCHours(0,0,0,0);var d=Object(i.a)(f,t);return d}function u(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var r=Object(n.a)(e),o=Object(i.a)(r,t).getTime()-s(r,t).getTime();return Math.round(o/6048e5)+1}},function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(0),i=r(60),o=r(131);function a(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(o.a)(e),r=new Date(0);r.setUTCFullYear(t,0,4),r.setUTCHours(0,0,0,0);var n=Object(i.a)(r);return n}function s(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object(n.a)(e),r=Object(i.a)(t).getTime()-a(t).getTime();return Math.round(r/6048e5)+1}},function(e,t,r){"use strict";r.d(t,"b",(function(){return g})),r.d(t,"a",(function(){return m}));var n=r(9),i=r.n(n),o=r(1),a=r(20),s=r(40),u=r(134),c=r(12),l=r(30),f=r(6);function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);ro.insertWithUUID("banks",{id:u,bank_id:e.institution_id,name:e.name})),u}async function m(e,t,r=[]){let n=d(await i.a.multiGet(["user-id","user-key"]),2),a=d(n[0],2)[1],l=d(n[1],2)[1],h=await s.b(a,l,e);return h=h.filter(e=>t.includes(e.account_id)),Promise.all(h.map(async t=>{let n=await Object(f.runMutator)(async()=>{let n=await o.insertAccount({account_id:t.account_id,name:t.name,official_name:t.official_name,type:Object(u.a)(t.type),balance_current:Object(c.a)(t.balances.current),mask:t.mask,bank:e,offbudget:r.includes(t.account_id)?1:0});return await o.insertPayee({name:"",transfer_acct:n}),n});return await s.d(a,l,n,t.account_id,e),n}))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(98),i=r(292),o=n.constants.S_IFMT,a=n.constants.S_IFDIR,s=n.constants.S_IFREG,u=n.constants.S_IFBLK,c=n.constants.S_IFCHR,l=n.constants.S_IFLNK,f=n.constants.S_IFIFO,d=n.constants.S_IFSOCK,h=function(){function e(){}return e.build=function(t,r){void 0===r&&(r=!1);var n=new e,o=t.uid,a=t.gid,s=t.atime,u=t.mtime,c=t.ctime,l=r?i.default:function(e){return e};n.uid=l(o),n.gid=l(a),n.rdev=l(0),n.blksize=l(4096),n.ino=l(t.ino),n.size=l(t.getSize()),n.blocks=l(1),n.atime=s,n.mtime=u,n.ctime=c,n.birthtime=c,n.atimeMs=l(s.getTime()),n.mtimeMs=l(u.getTime());var f=l(c.getTime());return n.ctimeMs=f,n.birthtimeMs=f,n.dev=l(0),n.mode=l(t.mode),n.nlink=l(t.nlink),n},e.prototype._checkModeProperty=function(e){return(Number(this.mode)&o)===e},e.prototype.isDirectory=function(){return this._checkModeProperty(a)},e.prototype.isFile=function(){return this._checkModeProperty(s)},e.prototype.isBlockDevice=function(){return this._checkModeProperty(u)},e.prototype.isCharacterDevice=function(){return this._checkModeProperty(c)},e.prototype.isSymbolicLink=function(){return this._checkModeProperty(l)},e.prototype.isFIFO=function(){return this._checkModeProperty(f)},e.prototype.isSocket=function(){return this._checkModeProperty(d)},e}();t.Stats=h,t.default=h},function(e,t,r){"use strict";var n=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t * @license MIT */function i(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i=0;c--)if(l[c]!==f[c])return!1;for(c=l.length-1;c>=0;c--)if(s=l[c],!_(e[s],t[s],r,n))return!1;return!0}(e,t,r,n))}return r?e===t:e==t}function w(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function v(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function E(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&y(i,r,"Missing expected exception"+n);var o="string"==typeof n,s=!e&&i&&!r;if((!e&&a.isError(i)&&o&&v(i,r)||s)&&y(i,r,"Got unwanted exception"+n),e&&i&&r&&!v(i,r)||!e&&i)throw i}d.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=function(e){return g(m(e.actual),128)+" "+e.operator+" "+g(m(e.expected),128)}(this),this.generatedMessage=!0);var t=e.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=p(t),o=n.indexOf("\n"+i);if(o>=0){var a=n.indexOf("\n",o+1);n=n.substring(a+1)}this.stack=n}}},a.inherits(d.AssertionError,Error),d.fail=y,d.ok=b,d.equal=function(e,t,r){e!=t&&y(e,t,r,"==",d.equal)},d.notEqual=function(e,t,r){e==t&&y(e,t,r,"!=",d.notEqual)},d.deepEqual=function(e,t,r){_(e,t,!1)||y(e,t,r,"deepEqual",d.deepEqual)},d.deepStrictEqual=function(e,t,r){_(e,t,!0)||y(e,t,r,"deepStrictEqual",d.deepStrictEqual)},d.notDeepEqual=function(e,t,r){_(e,t,!1)&&y(e,t,r,"notDeepEqual",d.notDeepEqual)},d.notDeepStrictEqual=function e(t,r,n){_(t,r,!0)&&y(t,r,n,"notDeepStrictEqual",e)},d.strictEqual=function(e,t,r){e!==t&&y(e,t,r,"===",d.strictEqual)},d.notStrictEqual=function(e,t,r){e===t&&y(e,t,r,"!==",d.notStrictEqual)},d.throws=function(e,t,r){E(!0,e,t,r)},d.doesNotThrow=function(e,t,r){E(!1,e,t,r)},d.ifError=function(e){if(e)throw e},d.strict=n((function e(t,r){t||y(t,!0,r,"==",e)}),d,{equal:d.strictEqual,deepEqual:d.deepStrictEqual,notEqual:d.notStrictEqual,notDeepEqual:d.notDeepStrictEqual}),d.strict.strict=d.strict;var S=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(this,r(23))},function(e,t,r){(t=e.exports=r(186)).Stream=t,t.Readable=t,t.Writable=r(144),t.Duplex=r(79),t.Transform=r(189),t.PassThrough=r(302)},function(e,t,r){var n=r(10),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function a(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,t),t.Buffer=a),o(i,a),a.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";(function(t,n,i){var o=r(114);function a(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;e.entry=null;for(;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=b;var s,u=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?n:o.nextTick;b.WritableState=y;var c=Object.create(r(100));c.inherits=r(11);var l={deprecate:r(145)},f=r(187),d=r(143).Buffer,h=i.Uint8Array||function(){};var p,g=r(188);function m(){}function y(e,t){s=s||r(79),e=e||{};var n=t instanceof s;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,c=e.writableHighWaterMark,l=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(c||0===c)?c:l,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var f=!1===e.decodeStrings;this.decodeStrings=!f,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(o.nextTick(i,n),o.nextTick(O,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),O(e,t))}(e,r,n,t,i);else{var a=E(r);a||r.corked||r.bufferProcessing||!r.bufferedRequest||v(e,r),n?u(w,e,r,a,i):w(e,r,a,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new a(this)}function b(e){if(s=s||r(79),!(p.call(b,this)||this instanceof s))return new b(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),f.call(this)}function _(e,t,r,n,i,o,a){t.writelen=n,t.writecb=a,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function w(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),O(e,t)}function v(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,_(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new a(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,f=r.callback;if(_(e,t,!1,t.objectMode?1:c.length,c,l,f),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function E(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function S(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),O(e,t)}))}function O(e,t){var r=E(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(S,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}c.inherits(b,f),y.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(y.prototype,"buffer",{get:l.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(b,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||this===b&&(e&&e._writableState instanceof y)}})):p=function(e){return e instanceof this},b.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},b.prototype.write=function(e,t,r){var n,i=this._writableState,a=!1,s=!i.objectMode&&(n=e,d.isBuffer(n)||n instanceof h);return s&&!d.isBuffer(e)&&(e=function(e){return d.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=m),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),o.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,a=!1;return null===r?a=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),o.nextTick(n,a),i=!1),i}(this,i,e,r))&&(i.pendingcb++,a=function(e,t,r,n,i,o){if(!r){var a=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=d.from(t,r));return t}(t,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=t.objectMode?1:n.length;t.length+=s;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(b.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),b.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},b.prototype._writev=null,b.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,O(e,t),r&&(t.finished?o.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(b.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),b.prototype.destroy=g.destroy,b.prototype._undestroy=g.undestroy,b.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,r(19),r(113).setImmediate,r(23))},function(e,t,r){(function(t){function r(e){try{if(!t.localStorage)return!1}catch(e){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,r(23))},function(e,t,r){"use strict";var n=r(11),i=r(191),o=r(16).Buffer,a=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function u(e,t){return e<>>32-t}function c(e,t,r,n,i,o,a){return u(e+(t&r|~t&n)+i+o|0,a)+t|0}function l(e,t,r,n,i,o,a){return u(e+(t&n|r&~n)+i+o|0,a)+t|0}function f(e,t,r,n,i,o,a){return u(e+(t^r^n)+i+o|0,a)+t|0}function d(e,t,r,n,i,o,a){return u(e+(r^(t|~n))+i+o|0,a)+t|0}n(s,i),s.prototype._update=function(){for(var e=a,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,o=this._d;r=c(r,n,i,o,e[0],3614090360,7),o=c(o,r,n,i,e[1],3905402710,12),i=c(i,o,r,n,e[2],606105819,17),n=c(n,i,o,r,e[3],3250441966,22),r=c(r,n,i,o,e[4],4118548399,7),o=c(o,r,n,i,e[5],1200080426,12),i=c(i,o,r,n,e[6],2821735955,17),n=c(n,i,o,r,e[7],4249261313,22),r=c(r,n,i,o,e[8],1770035416,7),o=c(o,r,n,i,e[9],2336552879,12),i=c(i,o,r,n,e[10],4294925233,17),n=c(n,i,o,r,e[11],2304563134,22),r=c(r,n,i,o,e[12],1804603682,7),o=c(o,r,n,i,e[13],4254626195,12),i=c(i,o,r,n,e[14],2792965006,17),r=l(r,n=c(n,i,o,r,e[15],1236535329,22),i,o,e[1],4129170786,5),o=l(o,r,n,i,e[6],3225465664,9),i=l(i,o,r,n,e[11],643717713,14),n=l(n,i,o,r,e[0],3921069994,20),r=l(r,n,i,o,e[5],3593408605,5),o=l(o,r,n,i,e[10],38016083,9),i=l(i,o,r,n,e[15],3634488961,14),n=l(n,i,o,r,e[4],3889429448,20),r=l(r,n,i,o,e[9],568446438,5),o=l(o,r,n,i,e[14],3275163606,9),i=l(i,o,r,n,e[3],4107603335,14),n=l(n,i,o,r,e[8],1163531501,20),r=l(r,n,i,o,e[13],2850285829,5),o=l(o,r,n,i,e[2],4243563512,9),i=l(i,o,r,n,e[7],1735328473,14),r=f(r,n=l(n,i,o,r,e[12],2368359562,20),i,o,e[5],4294588738,4),o=f(o,r,n,i,e[8],2272392833,11),i=f(i,o,r,n,e[11],1839030562,16),n=f(n,i,o,r,e[14],4259657740,23),r=f(r,n,i,o,e[1],2763975236,4),o=f(o,r,n,i,e[4],1272893353,11),i=f(i,o,r,n,e[7],4139469664,16),n=f(n,i,o,r,e[10],3200236656,23),r=f(r,n,i,o,e[13],681279174,4),o=f(o,r,n,i,e[0],3936430074,11),i=f(i,o,r,n,e[3],3572445317,16),n=f(n,i,o,r,e[6],76029189,23),r=f(r,n,i,o,e[9],3654602809,4),o=f(o,r,n,i,e[12],3873151461,11),i=f(i,o,r,n,e[15],530742520,16),r=d(r,n=f(n,i,o,r,e[2],3299628645,23),i,o,e[0],4096336452,6),o=d(o,r,n,i,e[7],1126891415,10),i=d(i,o,r,n,e[14],2878612391,15),n=d(n,i,o,r,e[5],4237533241,21),r=d(r,n,i,o,e[12],1700485571,6),o=d(o,r,n,i,e[3],2399980690,10),i=d(i,o,r,n,e[10],4293915773,15),n=d(n,i,o,r,e[1],2240044497,21),r=d(r,n,i,o,e[8],1873313359,6),o=d(o,r,n,i,e[15],4264355552,10),i=d(i,o,r,n,e[6],2734768916,15),n=d(n,i,o,r,e[13],1309151649,21),r=d(r,n,i,o,e[4],4149444226,6),o=d(o,r,n,i,e[11],3174756917,10),i=d(i,o,r,n,e[2],718787259,15),n=d(n,i,o,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=o.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},e.exports=s},function(e,t,r){"use strict";var n=r(85).codes.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),o=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i>>32-t}function g(e,t,r,n,i,o,a,s){return p(e+(t^r^n)+o+a|0,s)+i|0}function m(e,t,r,n,i,o,a,s){return p(e+(t&r|~t&n)+o+a|0,s)+i|0}function y(e,t,r,n,i,o,a,s){return p(e+((t|~r)^n)+o+a|0,s)+i|0}function b(e,t,r,n,i,o,a,s){return p(e+(t&n|r&~n)+o+a|0,s)+i|0}function _(e,t,r,n,i,o,a,s){return p(e+(t^(r|~n))+o+a|0,s)+i|0}i(h,o),h.prototype._update=function(){for(var e=a,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,h=0|this._e,w=0|this._a,v=0|this._b,E=0|this._c,S=0|this._d,O=0|this._e,T=0;T<80;T+=1){var A,M;T<16?(A=g(r,n,i,o,h,e[s[T]],f[0],c[T]),M=_(w,v,E,S,O,e[u[T]],d[0],l[T])):T<32?(A=m(r,n,i,o,h,e[s[T]],f[1],c[T]),M=b(w,v,E,S,O,e[u[T]],d[1],l[T])):T<48?(A=y(r,n,i,o,h,e[s[T]],f[2],c[T]),M=y(w,v,E,S,O,e[u[T]],d[2],l[T])):T<64?(A=b(r,n,i,o,h,e[s[T]],f[3],c[T]),M=m(w,v,E,S,O,e[u[T]],d[3],l[T])):(A=_(r,n,i,o,h,e[s[T]],f[4],c[T]),M=g(w,v,E,S,O,e[u[T]],d[4],l[T])),r=h,h=o,o=p(i,10),i=n,n=A,w=O,O=S,S=p(E,10),E=v,v=M}var D=this._b+i+S|0;this._b=this._c+o+O|0,this._c=this._d+h+w|0,this._d=this._e+r+v|0,this._e=this._a+n+E|0,this._a=D},h.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=n.alloc?n.alloc(20):new n(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},e.exports=h},function(e,t,r){(t=e.exports=function(e){e=e.toLowerCase();var r=t[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r}).sha=r(324),t.sha1=r(325),t.sha224=r(326),t.sha256=r(198),t.sha384=r(327),t.sha512=r(199)},function(e,t,r){"use strict";var n=r(44);function i(e){this.options=e,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0}e.exports=i,i.prototype._init=function(){},i.prototype.update=function(e){return 0===e.length?[]:"decrypt"===this.type?this._updateDecrypt(e):this._updateEncrypt(e)},i.prototype._buffer=function(e,t){for(var r=Math.min(this.buffer.length-this.bufferOff,e.length-t),n=0;n0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t=0||!t.umod(e.prime1)||!t.umod(e.prime2));return t}function a(e,r){var i=function(e){var t=o(e);return{blinder:t.toRed(n.mont(e.modulus)).redPow(new n(e.publicExponent)).fromRed(),unblinder:t.invm(e.modulus)}}(r),a=r.modulus.byteLength(),s=new n(e).mul(i.blinder).umod(r.modulus),u=s.toRed(n.mont(r.prime1)),c=s.toRed(n.mont(r.prime2)),l=r.coefficient,f=r.prime1,d=r.prime2,h=u.redPow(r.exponent1).fromRed(),p=c.redPow(r.exponent2).fromRed(),g=h.isub(p).imul(l).umod(f).imul(d);return p.iadd(g).imul(i.unblinder).umod(r.modulus).toArrayLike(t,"be",a)}a.getr=o,e.exports=a}).call(this,r(10).Buffer)},function(e,t,r){"use strict";var n=t;n.version=r(363).version,n.utils=r(45),n.rand=r(153),n.curve=r(224),n.curves=r(157),n.ec=r(374),n.eddsa=r(378)},function(e,t,r){"use strict";var n,i=t,o=r(158),a=r(224),s=r(45).assert;function u(e){"short"===e.type?this.curve=new a.short(e):"edwards"===e.type?this.curve=new a.edwards(e):this.curve=new a.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=r(373)}catch(e){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},function(e,t,r){var n=t;n.utils=r(53),n.common=r(103),n.sha=r(367),n.ripemd=r(371),n.hmac=r(372),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},function(e,t,r){"use strict";(function(t){var n,i=r(10),o=i.Buffer,a={};for(n in i)i.hasOwnProperty(n)&&"SlowBuffer"!==n&&"Buffer"!==n&&(a[n]=i[n]);var s=a.Buffer={};for(n in o)o.hasOwnProperty(n)&&"allocUnsafe"!==n&&"allocUnsafeSlow"!==n&&(s[n]=o[n]);if(a.Buffer.prototype=o.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(e,t,r){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return o(e,t,r)}),s.alloc||(s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var n=o(e);return t&&0!==t.length?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n}),!a.kStringMaxLength)try{a.kStringMaxLength=t.binding("buffer").kStringMaxLength}catch(e){}a.constants||(a.constants={MAX_LENGTH:a.kMaxLength},a.kStringMaxLength&&(a.constants.MAX_STRING_LENGTH=a.kStringMaxLength)),e.exports=a}).call(this,r(19))},function(e,t,r){"use strict";const n=r(161).Reporter,i=r(104).EncoderBuffer,o=r(104).DecoderBuffer,a=r(44),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function c(e,t,r){const n={};this._baseState=n,n.name=r,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}e.exports=c;const l=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){const e=this._baseState,t={};l.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},c.prototype._wrap=function(){const e=this._baseState;u.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},c.prototype._init=function(e){const t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),a.equal(t.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(e){const t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);const n=e[r];t[n]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){c.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),s.forEach((function(e){c.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}})),c.prototype.use=function(e){a(e);const t=this._baseState;return a(null===t.use),t.use=e,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(e){const t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},c.prototype.explicit=function(e){const t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},c.prototype.implicit=function(e){const t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},c.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},c.prototype.key=function(e){const t=this._baseState;return a(null===t.key),t.key=e,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(e){const t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},c.prototype.contains=function(e){const t=this._baseState;return a(null===t.use),t.contains=e,this},c.prototype._decode=function(e,t){const r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));let n,i=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){let n=null;if(null!==r.explicit?n=r.explicit:null!==r.implicit?n=r.implicit:null!==r.tag&&(n=r.tag),null!==n||r.any){if(a=this._peekTag(e,n,r.any),e.isError(a))return a}else{const n=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(n)}}if(r.obj&&a&&(n=e.enterObject()),a){if(null!==r.explicit){const t=this._decodeTag(e,r.explicit);if(e.isError(t))return t;e=t}const n=e.offset;if(null===r.use&&null===r.choice){let t;r.any&&(t=e.save());const n=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(n))return n;r.any?i=e.raw(t):e=n}if(t&&t.track&&null!==r.tag&&t.track(e.path(),n,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),r.any||(i=null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach((function(r){r._decode(e,t)})),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){const n=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(n,t)}}return r.obj&&a&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,i),i},c.prototype._decodeGeneric=function(e,t,r){const n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},c.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(e,t){const r=this._baseState;let n=null,i=!1;return Object.keys(r.choice).some((function(o){const a=e.save(),s=r.choice[o];try{const r=s._decode(e,t);if(e.isError(r))return!1;n={type:o,value:r},i=!0}catch(t){return e.restore(a),!1}return!0}),this),i?n:e.error("Choice not matched")},c.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},c.prototype._encode=function(e,t,r){const n=this._baseState;if(null!==n.default&&n.default===e)return;const i=this._encodeValue(e,t,r);return void 0===i||this._skipDefault(i,t,r)?void 0:i},c.prototype._encodeValue=function(e,t,r){const i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);let o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}let a=null,s=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)a=this._getUse(i.contains,r)._encode(e,t),s=!0;else if(i.children)a=i.children.map((function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");const n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");const i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i}),this).filter((function(e){return e})),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");const r=this.clone();r._baseState.implicit=null,a=this._createEncoderBuffer(e.map((function(r){const n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)}),r))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(a=this._encodePrimitive(i.tag,e),s=!0);if(!i.any&&null===i.choice){const e=null!==i.implicit?i.implicit:i.tag,r=null===i.implicit?"universal":"context";null===e?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(e,s,r,a))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(e,t){const r=this._baseState,n=r.choice[e.type];return n||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},c.prototype._encodePrimitive=function(e,t){const r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},c.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},c.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)}},function(e,t,r){"use strict";const n=r(11);function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}t.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){let t;const r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},function(e,t,r){"use strict";function n(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t}t.tagClass={0:"universal",1:"application",2:"context",3:"private"},t.tagClassByName=n(t.tagClass),t.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},t.tagByName=n(t.tag)},function(e,t,r){var n=r(411),i=n,o=globalThis;i.exportSymbol("proto.EncryptedData",null,o),i.exportSymbol("proto.Message",null,o),i.exportSymbol("proto.MessageEnvelope",null,o),i.exportSymbol("proto.SyncRequest",null,o),i.exportSymbol("proto.SyncResponse",null,o),proto.EncryptedData=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.EncryptedData,n.Message),i.DEBUG&&!COMPILED&&(proto.EncryptedData.displayName="proto.EncryptedData"),proto.Message=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.Message,n.Message),i.DEBUG&&!COMPILED&&(proto.Message.displayName="proto.Message"),proto.MessageEnvelope=function(e){n.Message.initialize(this,e,0,-1,null,null)},i.inherits(proto.MessageEnvelope,n.Message),i.DEBUG&&!COMPILED&&(proto.MessageEnvelope.displayName="proto.MessageEnvelope"),proto.SyncRequest=function(e){n.Message.initialize(this,e,0,-1,proto.SyncRequest.repeatedFields_,null)},i.inherits(proto.SyncRequest,n.Message),i.DEBUG&&!COMPILED&&(proto.SyncRequest.displayName="proto.SyncRequest"),proto.SyncResponse=function(e){n.Message.initialize(this,e,0,-1,proto.SyncResponse.repeatedFields_,null)},i.inherits(proto.SyncResponse,n.Message),i.DEBUG&&!COMPILED&&(proto.SyncResponse.displayName="proto.SyncResponse"),n.Message.GENERATE_TO_OBJECT&&(proto.EncryptedData.prototype.toObject=function(e){return proto.EncryptedData.toObject(e,this)},proto.EncryptedData.toObject=function(e,t){var r={iv:t.getIv_asB64(),authtag:t.getAuthtag_asB64(),data:t.getData_asB64()};return e&&(r.$jspbMessageInstance=t),r}),proto.EncryptedData.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.EncryptedData;return proto.EncryptedData.deserializeBinaryFromReader(r,t)},proto.EncryptedData.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readBytes();e.setIv(r);break;case 2:r=t.readBytes();e.setAuthtag(r);break;case 3:r=t.readBytes();e.setData(r);break;default:t.skipField()}}return e},proto.EncryptedData.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.EncryptedData.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.EncryptedData.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getIv_asU8()).length>0&&t.writeBytes(1,r),(r=e.getAuthtag_asU8()).length>0&&t.writeBytes(2,r),(r=e.getData_asU8()).length>0&&t.writeBytes(3,r)},proto.EncryptedData.prototype.getIv=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.EncryptedData.prototype.getIv_asB64=function(){return n.Message.bytesAsB64(this.getIv())},proto.EncryptedData.prototype.getIv_asU8=function(){return n.Message.bytesAsU8(this.getIv())},proto.EncryptedData.prototype.setIv=function(e){return n.Message.setProto3BytesField(this,1,e)},proto.EncryptedData.prototype.getAuthtag=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.EncryptedData.prototype.getAuthtag_asB64=function(){return n.Message.bytesAsB64(this.getAuthtag())},proto.EncryptedData.prototype.getAuthtag_asU8=function(){return n.Message.bytesAsU8(this.getAuthtag())},proto.EncryptedData.prototype.setAuthtag=function(e){return n.Message.setProto3BytesField(this,2,e)},proto.EncryptedData.prototype.getData=function(){return n.Message.getFieldWithDefault(this,3,"")},proto.EncryptedData.prototype.getData_asB64=function(){return n.Message.bytesAsB64(this.getData())},proto.EncryptedData.prototype.getData_asU8=function(){return n.Message.bytesAsU8(this.getData())},proto.EncryptedData.prototype.setData=function(e){return n.Message.setProto3BytesField(this,3,e)},n.Message.GENERATE_TO_OBJECT&&(proto.Message.prototype.toObject=function(e){return proto.Message.toObject(e,this)},proto.Message.toObject=function(e,t){var r={dataset:n.Message.getFieldWithDefault(t,1,""),row:n.Message.getFieldWithDefault(t,2,""),column:n.Message.getFieldWithDefault(t,3,""),value:n.Message.getFieldWithDefault(t,4,"")};return e&&(r.$jspbMessageInstance=t),r}),proto.Message.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.Message;return proto.Message.deserializeBinaryFromReader(r,t)},proto.Message.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readString();e.setDataset(r);break;case 2:r=t.readString();e.setRow(r);break;case 3:r=t.readString();e.setColumn(r);break;case 4:r=t.readString();e.setValue(r);break;default:t.skipField()}}return e},proto.Message.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.Message.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.Message.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getDataset()).length>0&&t.writeString(1,r),(r=e.getRow()).length>0&&t.writeString(2,r),(r=e.getColumn()).length>0&&t.writeString(3,r),(r=e.getValue()).length>0&&t.writeString(4,r)},proto.Message.prototype.getDataset=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.Message.prototype.setDataset=function(e){return n.Message.setProto3StringField(this,1,e)},proto.Message.prototype.getRow=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.Message.prototype.setRow=function(e){return n.Message.setProto3StringField(this,2,e)},proto.Message.prototype.getColumn=function(){return n.Message.getFieldWithDefault(this,3,"")},proto.Message.prototype.setColumn=function(e){return n.Message.setProto3StringField(this,3,e)},proto.Message.prototype.getValue=function(){return n.Message.getFieldWithDefault(this,4,"")},proto.Message.prototype.setValue=function(e){return n.Message.setProto3StringField(this,4,e)},n.Message.GENERATE_TO_OBJECT&&(proto.MessageEnvelope.prototype.toObject=function(e){return proto.MessageEnvelope.toObject(e,this)},proto.MessageEnvelope.toObject=function(e,t){var r={timestamp:n.Message.getFieldWithDefault(t,1,""),isencrypted:n.Message.getBooleanFieldWithDefault(t,2,!1),content:t.getContent_asB64()};return e&&(r.$jspbMessageInstance=t),r}),proto.MessageEnvelope.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.MessageEnvelope;return proto.MessageEnvelope.deserializeBinaryFromReader(r,t)},proto.MessageEnvelope.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=t.readString();e.setTimestamp(r);break;case 2:r=t.readBool();e.setIsencrypted(r);break;case 3:r=t.readBytes();e.setContent(r);break;default:t.skipField()}}return e},proto.MessageEnvelope.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.MessageEnvelope.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.MessageEnvelope.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getTimestamp()).length>0&&t.writeString(1,r),(r=e.getIsencrypted())&&t.writeBool(2,r),(r=e.getContent_asU8()).length>0&&t.writeBytes(3,r)},proto.MessageEnvelope.prototype.getTimestamp=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.MessageEnvelope.prototype.setTimestamp=function(e){return n.Message.setProto3StringField(this,1,e)},proto.MessageEnvelope.prototype.getIsencrypted=function(){return n.Message.getBooleanFieldWithDefault(this,2,!1)},proto.MessageEnvelope.prototype.setIsencrypted=function(e){return n.Message.setProto3BooleanField(this,2,e)},proto.MessageEnvelope.prototype.getContent=function(){return n.Message.getFieldWithDefault(this,3,"")},proto.MessageEnvelope.prototype.getContent_asB64=function(){return n.Message.bytesAsB64(this.getContent())},proto.MessageEnvelope.prototype.getContent_asU8=function(){return n.Message.bytesAsU8(this.getContent())},proto.MessageEnvelope.prototype.setContent=function(e){return n.Message.setProto3BytesField(this,3,e)},proto.SyncRequest.repeatedFields_=[1],n.Message.GENERATE_TO_OBJECT&&(proto.SyncRequest.prototype.toObject=function(e){return proto.SyncRequest.toObject(e,this)},proto.SyncRequest.toObject=function(e,t){var r={messagesList:n.Message.toObjectList(t.getMessagesList(),proto.MessageEnvelope.toObject,e),fileid:n.Message.getFieldWithDefault(t,2,""),groupid:n.Message.getFieldWithDefault(t,3,""),keyid:n.Message.getFieldWithDefault(t,5,""),since:n.Message.getFieldWithDefault(t,6,"")};return e&&(r.$jspbMessageInstance=t),r}),proto.SyncRequest.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.SyncRequest;return proto.SyncRequest.deserializeBinaryFromReader(r,t)},proto.SyncRequest.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=new proto.MessageEnvelope;t.readMessage(r,proto.MessageEnvelope.deserializeBinaryFromReader),e.addMessages(r);break;case 2:r=t.readString();e.setFileid(r);break;case 3:r=t.readString();e.setGroupid(r);break;case 5:r=t.readString();e.setKeyid(r);break;case 6:r=t.readString();e.setSince(r);break;default:t.skipField()}}return e},proto.SyncRequest.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.SyncRequest.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.SyncRequest.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getMessagesList()).length>0&&t.writeRepeatedMessage(1,r,proto.MessageEnvelope.serializeBinaryToWriter),(r=e.getFileid()).length>0&&t.writeString(2,r),(r=e.getGroupid()).length>0&&t.writeString(3,r),(r=e.getKeyid()).length>0&&t.writeString(5,r),(r=e.getSince()).length>0&&t.writeString(6,r)},proto.SyncRequest.prototype.getMessagesList=function(){return n.Message.getRepeatedWrapperField(this,proto.MessageEnvelope,1)},proto.SyncRequest.prototype.setMessagesList=function(e){return n.Message.setRepeatedWrapperField(this,1,e)},proto.SyncRequest.prototype.addMessages=function(e,t){return n.Message.addToRepeatedWrapperField(this,1,e,proto.MessageEnvelope,t)},proto.SyncRequest.prototype.clearMessagesList=function(){return this.setMessagesList([])},proto.SyncRequest.prototype.getFileid=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.SyncRequest.prototype.setFileid=function(e){return n.Message.setProto3StringField(this,2,e)},proto.SyncRequest.prototype.getGroupid=function(){return n.Message.getFieldWithDefault(this,3,"")},proto.SyncRequest.prototype.setGroupid=function(e){return n.Message.setProto3StringField(this,3,e)},proto.SyncRequest.prototype.getKeyid=function(){return n.Message.getFieldWithDefault(this,5,"")},proto.SyncRequest.prototype.setKeyid=function(e){return n.Message.setProto3StringField(this,5,e)},proto.SyncRequest.prototype.getSince=function(){return n.Message.getFieldWithDefault(this,6,"")},proto.SyncRequest.prototype.setSince=function(e){return n.Message.setProto3StringField(this,6,e)},proto.SyncResponse.repeatedFields_=[1],n.Message.GENERATE_TO_OBJECT&&(proto.SyncResponse.prototype.toObject=function(e){return proto.SyncResponse.toObject(e,this)},proto.SyncResponse.toObject=function(e,t){var r={messagesList:n.Message.toObjectList(t.getMessagesList(),proto.MessageEnvelope.toObject,e),merkle:n.Message.getFieldWithDefault(t,2,"")};return e&&(r.$jspbMessageInstance=t),r}),proto.SyncResponse.deserializeBinary=function(e){var t=new n.BinaryReader(e),r=new proto.SyncResponse;return proto.SyncResponse.deserializeBinaryFromReader(r,t)},proto.SyncResponse.deserializeBinaryFromReader=function(e,t){for(;t.nextField()&&!t.isEndGroup();){switch(t.getFieldNumber()){case 1:var r=new proto.MessageEnvelope;t.readMessage(r,proto.MessageEnvelope.deserializeBinaryFromReader),e.addMessages(r);break;case 2:r=t.readString();e.setMerkle(r);break;default:t.skipField()}}return e},proto.SyncResponse.prototype.serializeBinary=function(){var e=new n.BinaryWriter;return proto.SyncResponse.serializeBinaryToWriter(this,e),e.getResultBuffer()},proto.SyncResponse.serializeBinaryToWriter=function(e,t){var r=void 0;(r=e.getMessagesList()).length>0&&t.writeRepeatedMessage(1,r,proto.MessageEnvelope.serializeBinaryToWriter),(r=e.getMerkle()).length>0&&t.writeString(2,r)},proto.SyncResponse.prototype.getMessagesList=function(){return n.Message.getRepeatedWrapperField(this,proto.MessageEnvelope,1)},proto.SyncResponse.prototype.setMessagesList=function(e){return n.Message.setRepeatedWrapperField(this,1,e)},proto.SyncResponse.prototype.addMessages=function(e,t){return n.Message.addToRepeatedWrapperField(this,1,e,proto.MessageEnvelope,t)},proto.SyncResponse.prototype.clearMessagesList=function(){return this.setMessagesList([])},proto.SyncResponse.prototype.getMerkle=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.SyncResponse.prototype.setMerkle=function(e){return n.Message.setProto3StringField(this,2,e)},i.object.extend(t,proto)},function(e,t,r){(function(e){t.require=function(){var t=r(83);if(e.versions.electron)try{originalFs=r(!function(){var e=new Error("Cannot find module 'original-fs'");throw e.code="MODULE_NOT_FOUND",e}()),Object.keys(originalFs).length>0&&(t=originalFs)}catch(e){}return t}}).call(this,r(19))},function(e,t,r){"use strict";var n=Array.prototype.slice,i=r(253),o=Object.keys,a=o?function(e){return o(e)}:r(441),s=Object.keys;a.shim=function(){Object.keys?function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2)||(Object.keys=function(e){return i(e)?s(n.call(e)):s(e)}):Object.keys=a;return Object.keys||a},e.exports=a},function(e,t,r){"use strict";var n="undefined"!=typeof Symbol&&Symbol,i=r(122);e.exports=function(){return"function"==typeof n&&("function"==typeof Symbol&&("symbol"==typeof n("foo")&&("symbol"==typeof Symbol("bar")&&i())))}},function(e,t,r){"use strict";var n=r(442);e.exports=Function.prototype.bind||n},function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(0);function i(e,t){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=Object(n.a)(e),i=Object(n.a)(t);return r.getTime()>i.getTime()}},function(e,t){e.exports={send:void 0}},function(e,t,r){"use strict";r.d(t,"a",(function(){return A}));var n=r(274),i=r.n(n),o=r(4),a=r.n(o),s=r(15);function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r{n.map(t=>{let n=t.name.match(/^(budget-report|budget)(\d+)!budget-(.+)$/);if(null==n)return void console.log("Warning: invalid budget month name",t.name);let i=n[1],o=n[2].slice(0,4)+"-"+n[2].slice(4),a=parseInt(n[2]),s=n[3],u=parseInt(r(t));isNaN(u)&&(u=0);let c=t.name.split("!")[0],l=e.runQuery("SELECT * FROM spreadsheet_cells WHERE name = ?",[`${c}!carryover-${s}`],!0),f="budget-report"===i?"reflect_budgets":"zero_budgets";e.runQuery(`INSERT INTO ${f} (id, month, category, amount, carryover) VALUES (?, ?, ?, ?, ?)`,[`${o}-${s}`,a,s,u,l.length>0&&"true"===r(l[0])?1:0])})});let i=e.runQuery("SELECT * FROM spreadsheet_cells WHERE name LIKE 'budget%!buffered'",[],!0);e.transaction(()=>{i.map(t=>{let n=t.name.match(/^budget(\d+)!buffered$/);if(n){let i=n[1].slice(0,4)+"-"+n[1].slice(4),o=parseInt(r(t));isNaN(o)&&(o=0),e.runQuery("INSERT INTO zero_budget_months (id, buffered) VALUES (?, ?)",[i,o])}})});let o=e.runQuery("SELECT * FROM spreadsheet_cells WHERE name LIKE 'notes!%'",[],!0);e.transaction(()=>{o.forEach(t=>{let n=(e=>{try{let t=JSON.parse(e);return t&&""!==t?t:null}catch(e){return null}})(r(t));if(n){let r=u(t.name.split("!"),2)[1];e.runQuery("INSERT INTO notes (id, note) VALUES (?, ?)",[r,n])}})}),e.execQuery("\n DROP TABLE spreadsheet_cells;\n ANALYZE;\n VACUUM;\n ")}};function h(e){return parseInt(e.match(/^(\d)+/)[0])}async function p(e,t,r){const n=await a.a.readFile(a.a.join(r,t));t.match(/\.js$/)?await async function(e,t){const r={runQuery:(t,r,n)=>s.runQuery(e,t,r,n),execQuery:t=>s.execQuery(e,t),transaction:t=>s.transaction(e,t)};if(null==d[t])throw new Error("Could not find JS migration code to run for "+t);return(0,d[t])(r,()=>l.v4Sync())}(e,h(t)):await async function(e,t){try{await s.execQuery(e,t)}catch(e){throw console.log("Error applying sql:",t),e}}(e,n),await s.runQuery(e,"INSERT INTO __migrations__ (id) VALUES (?)",[h(t)])}async function g(e){let t=await async function(e){return(await s.runQuery(e,"SELECT * FROM __migrations__ ORDER BY id ASC",[],!0)).map(e=>e.id)}(e),r=await async function(e){return(await a.a.listDir(e)).filter(e=>e.match(/(\.sql|\.js)$/)).sort((e,t)=>{const r=h(e),n=h(t);return rn?1:0})}(f);!function(e,t){for(let r=0;r=t.length||e[r]!==h(t[r]))throw new Error("out-of-sync-migrations")}(t,r);const n=function(e,t){return t.filter(t=>{const r=h(t);return-1===e.indexOf(r)})}(t,r);for(let t of n)await p(e,t,f);return n}var m=r(1),y=r(33),b=r(58);const _=["fields"];function w(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function v(e){for(var t=1;t=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function O(e){return Object.keys(e).map(t=>{let r=e[t],n=r!==t;return r.match(/[ .]/)||(r="_."+r),n?`${r} AS ${Object(b.d)(t)}`:""+r}).join(", ")}async function T(){let e=(await m.first("SELECT value FROM __meta__ WHERE key = ?",["view-hash"])||{}).value,t=function(e,t){let r=t.views,n=[];return Object.keys(r).forEach(t=>{let i=r[t],o=i.fields,a=void 0===o?{}:o,s=S(i,_),u=Object.fromEntries(Object.keys(e[t]).map(e=>[e,e])),c=v(v({},u),a);Object.keys(s).forEach(e=>{let t,r=e=>O(v(v({},u),e)),i=e=>O(v(v({},c),e));t="function"==typeof s[e]?s[e](i,r):s[e],t=t.trim().replace(/;$/,""),n.push(`\n DROP VIEW IF EXISTS ${e};\n CREATE VIEW ${e} AS ${t};\n `)})}),n.join("\n")}(y.a,y.b),r=i()(t);e!==r&&(await m.execQuery(t),await m.runQuery("INSERT OR REPLACE INTO __meta__ (key, value) VALUES (?, ?)",["view-hash",r]))}async function A(){await async function(){await g(m.getDatabase())}(),await T()}},function(e,t,r){"use strict";const n=r(290),i=Symbol("max"),o=Symbol("length"),a=Symbol("lengthCalculator"),s=Symbol("allowStale"),u=Symbol("maxAge"),c=Symbol("dispose"),l=Symbol("noDisposeOnSet"),f=Symbol("lruList"),d=Symbol("cache"),h=Symbol("updateAgeOnGet"),p=()=>1;const g=(e,t,r)=>{const n=e[d].get(t);if(n){const t=n.value;if(m(e,t)){if(b(e,n),!e[s])return}else r&&(e[h]&&(n.value.now=Date.now()),e[f].unshiftNode(n));return t.value}},m=(e,t)=>{if(!t||!t.maxAge&&!e[u])return!1;const r=Date.now()-t.now;return t.maxAge?r>t.maxAge:e[u]&&r>e[u]},y=e=>{if(e[o]>e[i])for(let t=e[f].tail;e[o]>e[i]&&null!==t;){const r=t.prev;b(e,t),t=r}},b=(e,t)=>{if(t){const r=t.value;e[c]&&e[c](r.key,r.value),e[o]-=r.length,e[d].delete(r.key),e[f].removeNode(t)}};class _{constructor(e,t,r,n,i){this.key=e,this.value=t,this.length=r,this.now=n,this.maxAge=i||0}}const w=(e,t,r,n)=>{let i=r.value;m(e,i)&&(b(e,r),e[s]||(i=void 0)),i&&t.call(n,i.value,i.key,e)};e.exports=class{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[i]=e.max||1/0;const t=e.length||p;if(this[a]="function"!=typeof t?p:t,this[s]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[u]=e.maxAge||0,this[c]=e.dispose,this[l]=e.noDisposeOnSet||!1,this[h]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[i]=e||1/0,y(this)}get max(){return this[i]}set allowStale(e){this[s]=!!e}get allowStale(){return this[s]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[u]=e,y(this)}get maxAge(){return this[u]}set lengthCalculator(e){"function"!=typeof e&&(e=p),e!==this[a]&&(this[a]=e,this[o]=0,this[f].forEach(e=>{e.length=this[a](e.value,e.key),this[o]+=e.length})),y(this)}get lengthCalculator(){return this[a]}get length(){return this[o]}get itemCount(){return this[f].length}rforEach(e,t){t=t||this;for(let r=this[f].tail;null!==r;){const n=r.prev;w(this,e,r,t),r=n}}forEach(e,t){t=t||this;for(let r=this[f].head;null!==r;){const n=r.next;w(this,e,r,t),r=n}}keys(){return this[f].toArray().map(e=>e.key)}values(){return this[f].toArray().map(e=>e.value)}reset(){this[c]&&this[f]&&this[f].length&&this[f].forEach(e=>this[c](e.key,e.value)),this[d]=new Map,this[f]=new n,this[o]=0}dump(){return this[f].map(e=>!m(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[f]}set(e,t,r){if((r=r||this[u])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const n=r?Date.now():0,s=this[a](t,e);if(this[d].has(e)){if(s>this[i])return b(this,this[d].get(e)),!1;const a=this[d].get(e).value;return this[c]&&(this[l]||this[c](e,a.value)),a.now=n,a.maxAge=r,a.value=t,this[o]+=s-a.length,a.length=s,this.get(e),y(this),!0}const h=new _(e,t,s,n,r);return h.length>this[i]?(this[c]&&this[c](e,t),!1):(this[o]+=h.length,this[f].unshift(h),this[d].set(e,this[f].head),y(this),!0)}has(e){if(!this[d].has(e))return!1;const t=this[d].get(e).value;return!m(this,t)}get(e){return g(this,e,!0)}peek(e){return g(this,e,!1)}pop(){const e=this[f].tail;return e?(b(this,e),e.value):null}del(e){b(this,this[d].get(e))}load(e){this.reset();const t=Date.now();for(let r=e.length-1;r>=0;r--){const n=e[r],i=n.e||0;if(0===i)this.set(n.k,n.v);else{const e=i-t;e>0&&this.set(n.k,n.v,e)}}}prune(){this[d].forEach((e,t)=>g(this,t,!1))}}},function(e,t,r){"use strict";r.d(t,"a",(function(){return h}));var n=r(129),i=r(33),o=r(58),a=r(26);function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r{this.running||this.runComputations()})}runComputations(e=0){for(this.running=!0;ethis.getNode(e).value);r=t._run(...e),r instanceof Promise&&console.warn("dynamic cell returned a promise! this is discouraged because errors are not handled properly")}else{if(!t.sql){e++;continue}r=Object(a.a)(t.query,t.sql.sqlPieces,t.sql.state)}}catch(e){return console.log("Error while evaluating "+n+":",e),this.running=!1,void(this.computeQueue=[])}if(r instanceof Promise)return void r.then(r=>{t.value=r,this.runComputations(e+1)},r=>{console.warn(`Failed running ${t.name}!`,r),this.runComputations(e+1)});t.value=r,e++}e===this.computeQueue.length&&(this.events.emit("change",{names:this.computeQueue}),this.saveCache&&this.saveCache(this.computeQueue),this.markCacheSafe(),this.running=!1,this.computeQueue=[])}markCacheSafe(){this.cacheBarrier||this.setCacheStatus&&this.setCacheStatus({clean:!0})}markCacheDirty(){this.setCacheStatus&&this.setCacheStatus({clean:!1})}startCacheBarrier(){this.cacheBarrier=!0,this.markCacheDirty()}endCacheBarrier(){this.cacheBarrier=!1,this.running||this.computeQueue.length>0||this.markCacheSafe()}addEventListener(e,t){return this.events.on(e,t),()=>this.events.off(e,t)}onFinish(e){if(0!==this.transactionDepth)throw new Error("onFinish called while inside a spreadsheet transaction. This is not allowed as it will lead to race conditions");if(!this.running&&0===this.computeQueue.length)return e([]),()=>{};let t=this.addEventListener("change",(...r)=>(t(),e(...r)));return t}unload(){this.events.all.clear()}getValue(e){return this.getNode(e).value}getExpr(e){return this.getNode(e).expr}getCellValue(e,t){return this.getNode(d(e,t)).value}getCellExpr(e,t){return this.getNode(d(e,t)).expr}getCellValueLoose(e,t){let r=d(e,t);return this.nodes.has(r)?this.getNode(r).value:null}bootup(e){this.onFinish(()=>{e()})}load(e,t){const r=this._getNode(e);r.expr=t,r.value=t}create(e,t){return this.transaction(()=>{const r=this._getNode(e);r.expr=t,r.value=t,this._markDirty(e)})}set(e,t){this.create(e,t)}recompute(e){this.transaction(()=>{this.dirtyCells.push(e)})}recomputeAll(){this.transaction(()=>{this.dirtyCells=[...this.nodes.keys()]})}createQuery(e,t,r){let n=d(e,t),a=this._getNode(n);if(a.query!==r){a.query=r;let e=Object(o.a)(a.query,i.a,i.b),t=e.sqlPieces,s=e.state;a.sql={sqlPieces:t,state:s},this.transaction(()=>{this._markDirty(n)})}}createStatic(e,t,r){let n=d(e,t);this.nodes.has(n)||this.create(n,r)}createDynamic(e,t,{dependencies:r=[],run:n,initialValue:i,refresh:o}){let a=d(e,t),s=this._getNode(a);s.dynamic||(s.dynamic=!0,s._run=n,r=r.map(t=>{let r;return r=f(t).sheet?t:d(e,t),r}),s._dependencies=r,this.graph.removeIncomingEdges(a),r.forEach(e=>{this.graph.addEdge(e,a)}),(null==s.value||o)&&this.transaction(()=>{s.value=i,this._markDirty(a)}))}clearSheet(e){for(let r of this.nodes.entries()){var t=s(r,2);let n=t[0];t[1].sheet===e&&this.nodes.delete(n)}}voidCell(e,t,r=null){let n=this.getNode(d(e,t));n._run=null,n.dynamic=!1,n.value=r}deleteCell(e,t){this.voidCell(e,t),this.nodes.delete(d(e,t))}addDependencies(e,t,r){let n=d(e,t);r=r.map(t=>f(t).sheet?t:d(e,t));let i=this.getNode(n),o=r.filter(e=>-1===(i._dependencies||[]).indexOf(e));o.length>0&&(i._dependencies=(i._dependencies||[]).concat(o),o.forEach(e=>{this.graph.addEdge(e,n)}),this.recompute(n))}removeDependencies(e,t,r){let n=d(e,t);r=r.map(t=>f(t).sheet?t:d(e,t));let i=this.getNode(n);i._dependencies=(i._dependencies||[]).filter(e=>-1===r.indexOf(e)),r.forEach(e=>{this.graph.removeEdge(e,n)}),this.recompute(n)}_markDirty(e){this.dirtyCells.push(e)}triggerDatabaseChanges(e,t){let r=new Set([...e.keys(),...t.keys()]);this.startTransaction(),this.nodes.forEach(e=>{e.sql&&e.sql.state.dependencies.some(e=>r.has(e))&&this._markDirty(e.name)}),this.endTransaction()}}},function(e,t,r){"use strict";(function(e){r.d(t,"b",(function(){return u})),r.d(t,"a",(function(){return c}));var n=r(31),i=r(8);let o=r(18).SyncError,a=r(163);function s(t){return e.isBuffer(t)?t:e.from(t)}async function u(t,r,s,u){let c=i.b().encryptKeyId,l=new a.SyncRequest;for(let t=0;te.name===r);)r="My Finances "+t,t++;return r}async function s(e){let t=e.replace(/( |[^A-Za-z0-9])/g,"-")+"-"+o.v4Sync().slice(0,7),r=0,n=i.a.getBudgetDir(t);for(;await i.a.exists(n);)r++,n=i.a.getBudgetDir(t+r.toString());return r>0&&(t+=r.toString()),t}},function(e,t,r){"use strict";r.d(t,"b",(function(){return s})),r.d(t,"a",(function(){return u}));r(83);var n=r(176),i=r.n(n),o=r(26),a=r(12);async function s(e,t,r,n){const o=t.reduce((e,{id:t,name:r})=>(e[t]=r,e),{}),s=r.reduce((e,{name:t,categories:r})=>(r.forEach(r=>e[r.id]=`${t}: ${r.name}`),e),{}),u=n.reduce((e,{id:t,name:r})=>(e[t]=r,e),{}),c=e.map(({account:e,date:t,payee:r,notes:n,category:i,amount:c})=>({Account:o[e],Date:t,Payee:u[r],Notes:n,Category:s[i],Amount:null==c?0:Object(a.k)(c)}));return i()(c,{header:!0})}async function u(e){let t=(await Object(o.b)(e.select([{Id:"id"},{Account:"account.name"},{Date:"date"},{Payee:"payee.name"},{ParentId:"parent_id"},{IsParent:"is_parent"},{Notes:"notes"},{Category:"category.name"},{Amount:"amount"}]).options({splits:"all"}))).data,r=new Map;for(let e of t)e.IsParent&&r.set(e.Id,e.Payee);let n=t.filter(e=>!e.IsParent).map(e=>({Account:e.Account,Date:e.Date,Payee:e.ParentId?r.get(e.ParentId):e.Payee,Notes:e.Notes,Category:e.Category,Amount:null==e.Amount?0:Object(a.k)(e.Amount)}));return i()(n,{header:!0})}},function(e,t,r){(function(t){const n=r(437),i=r(70).StringDecoder;e.exports=function(e,r={}){const o=[];if(t.isBuffer(e)){e=(new i).write(e)}function a(e){e&&o.push(e.toString())}let s=new n.Stringifier(r);s.on("data",a);for(let t of e)s.write(t);return s.end(),s.off("data",a),o.join("")}}).call(this,r(10).Buffer)},function(e,t,r){"use strict";var n=r(165),i=r(254),o=r(444),a=r(446),s=r(447),u=r(449),c=r(450),l=r(451),f=r(80),d=r(54),h=r(457),p=r(460),g=r(462),m=r(465),y=r(467),b=d("Date.prototype.getTime"),_=Object.getPrototypeOf,w=d("Object.prototype.toString"),v=f("%Set%",!0),E=d("Map.prototype.has",!0),S=d("Map.prototype.get",!0),O=d("Map.prototype.size",!0),T=d("Set.prototype.add",!0),A=d("Set.prototype.delete",!0),M=d("Set.prototype.has",!0),D=d("Set.prototype.size",!0);function I(e,t,r,n){for(var i,o=p(e);(i=o.next())&&!i.done;)if(C(t,i.value,r,n))return A(e,i.value),!0;return!1}function j(e){return void 0===e?null:"object"!=typeof e?"symbol"!=typeof e&&("string"!=typeof e&&"number"!=typeof e||+e==+e):void 0}function R(e,t,r,n,i,o){var a=j(r);if(null!=a)return a;var s=S(t,a),u=y({},i,{strict:!1});return!(void 0===s&&!E(t,a)||!C(n,s,u,o))&&(!E(e,a)&&C(n,s,u,o))}function N(e,t,r){var n=j(r);return null!=n?n:M(t,n)&&!M(e,n)}function k(e,t,r,n,i,o){for(var a,s,u=p(e);(a=u.next())&&!a.done;)if(C(r,s=a.value,i,o)&&C(n,S(t,s),i,o))return A(e,s),!0;return!1}function C(e,t,r,f){var d=r||{};if(d.strict?o(e,t):e===t)return!0;if(l(e)!==l(t))return!1;if(!e||!t||"object"!=typeof e&&"object"!=typeof t)return d.strict?o(e,t):e==t;var g,A=f.has(e),j=f.has(t);if(A&&j){if(f.get(e)===f.get(t))return!0}else g={};return A||f.set(e,g),j||f.set(t,g),function(e,t,r,o){var l,f;if(typeof e!=typeof t)return!1;if(null==e||null==t)return!1;if(w(e)!==w(t))return!1;if(i(e)!==i(t))return!1;var d=u(e),g=u(t);if(d!==g)return!1;var A=e instanceof Error,j=t instanceof Error;if(A!==j)return!1;if((A||j)&&(e.name!==t.name||e.message!==t.message))return!1;var x=a(e),P=a(t);if(x!==P)return!1;if((x||P)&&(e.source!==t.source||s(e)!==s(t)))return!1;var B=c(e),U=c(t);if(B!==U)return!1;if((B||U)&&b(e)!==b(t))return!1;if(r.strict&&_&&_(e)!==_(t))return!1;if(m(e)!==m(t))return!1;var F=L(e),W=L(t);if(F!==W)return!1;if(F||W){if(e.length!==t.length)return!1;for(l=0;l=0;l--)if(H[l]!=z[l])return!1;for(l=H.length-1;l>=0;l--)if(f=H[l],!C(e[f],t[f],r,o))return!1;var q=h(e),V=h(t);if(q!==V)return!1;if("Set"===q||"Set"===V)return function(e,t,r,n){if(D(e)!==D(t))return!1;var i,o,a,s=p(e),u=p(t);for(;(i=s.next())&&!i.done;)if(i.value&&"object"==typeof i.value)a||(a=new v),T(a,i.value);else if(!M(t,i.value)){if(r.strict)return!1;if(!N(e,t,i.value))return!1;a||(a=new v),T(a,i.value)}if(a){for(;(o=u.next())&&!o.done;)if(o.value&&"object"==typeof o.value){if(!I(a,o.value,r.strict,n))return!1}else if(!r.strict&&!M(e,o.value)&&!I(a,o.value,r.strict,n))return!1;return 0===D(a)}return!0}(e,t,r,o);if("Map"===q)return function(e,t,r,n){if(O(e)!==O(t))return!1;var i,o,a,s,u,c,l=p(e),f=p(t);for(;(i=l.next())&&!i.done;)if(s=i.value[0],u=i.value[1],s&&"object"==typeof s)a||(a=new v),T(a,s);else if(void 0===(c=S(t,s))&&!E(t,s)||!C(u,c,r,n)){if(r.strict)return!1;if(!R(e,t,s,u,r,n))return!1;a||(a=new v),T(a,s)}if(a){for(;(o=f.next())&&!o.done;)if(s=o.value[0],c=o.value[1],s&&"object"==typeof s){if(!k(a,e,s,c,r,n))return!1}else if(!(r.strict||e.has(s)&&C(S(e,s),c,r,n)||k(a,e,s,c,y({},r,{strict:!1}),n)))return!1;return 0===D(a)}return!0}(e,t,r,o);return!0}(e,t,d,f)}function L(e){return!(!e||"object"!=typeof e||"number"!=typeof e.length)&&("function"==typeof e.copy&&"function"==typeof e.slice&&(!(e.length>0&&"number"!=typeof e[0])&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))))}e.exports=function(e,t,r){return C(e,t,r,g())}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){let n=i();function i(){return new Promise((e,t)=>{let r=indexedDB.open("actual",9);r.onupgradeneeded=function(e){let t=e.target.result;t.objectStoreNames.contains("filesystem")&&t.deleteObjectStore("filesystem",{keyPath:"filepath"}),t.objectStoreNames.contains("messages")&&t.deleteObjectStore("messages",{keyPath:"filepath"}),t.objectStoreNames.contains("asyncStorage")||t.createObjectStore("asyncStorage"),t.objectStoreNames.contains("files")||t.createObjectStore("files",{keyPath:"filepath"})},r.onblocked=e=>console.log("blocked",e),r.onerror=e=>{console.log("openRequest error"),t(new Error("indexeddb-failure: Could not open IndexedDB"))},r.onsuccess=function(t){let r=t.target.result;r.onversionchange=()=>{r.close()},r.onerror=function(e){if(console.log("Database error: "+(e.target&&e.target.error)),e.target&&e.target.error){if("QuotaExceededError"===e.target.error.name)throw new Error("indexeddb-quota-error")}},e(r)}})}e.exports={getDatabase:function(){return n},openDatabase:function(){return null==n&&(n=i()),n},closeDatabase:function(){if(n){n.then(e=>{e.close()});n=null}},getStore:function(e,t){let r=e.transaction([t],"readwrite");return{trans:r,store:r.objectStore(t)}},get:async function(e,t,r=(e=>e)){return new Promise((n,i)=>{let o=e.get(t);o.onsuccess=e=>{n(r(o.result))},o.onerror=e=>i(e)})},set:async function(e,t){return new Promise((r,n)=>{let i=e.put(t);i.onsuccess=e=>r(),i.onerror=e=>n(e)})},del:async function(e,t){return new Promise((r,n)=>{let i=e.delete(t);i.onsuccess=e=>r(),i.onerror=e=>n(e)})}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(98),i=r(181),o=n.constants.S_IFMT,a=n.constants.S_IFDIR,s=n.constants.S_IFREG,u=n.constants.S_IFBLK,c=n.constants.S_IFCHR,l=n.constants.S_IFLNK,f=n.constants.S_IFIFO,d=n.constants.S_IFSOCK,h=function(){function e(){this.name="",this.mode=0}return e.build=function(t,r){var n=new e,o=t.getNode().mode;return n.name=i.strToEncoding(t.getName(),r),n.mode=o,n},e.prototype._checkModeProperty=function(e){return(this.mode&o)===e},e.prototype.isDirectory=function(){return this._checkModeProperty(a)},e.prototype.isFile=function(){return this._checkModeProperty(s)},e.prototype.isBlockDevice=function(){return this._checkModeProperty(u)},e.prototype.isCharacterDevice=function(){return this._checkModeProperty(c)},e.prototype.isSymbolicLink=function(){return this._checkModeProperty(l)},e.prototype.isFIFO=function(){return this._checkModeProperty(f)},e.prototype.isSocket=function(){return this._checkModeProperty(d)},e}();t.Dirent=h,t.default=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(140),i=r(182);t.ENCODING_UTF8="utf8",t.assertEncoding=function(e){if(e&&!n.Buffer.isEncoding(e))throw new i.TypeError("ERR_INVALID_OPT_VALUE_ENCODING",e)},t.strToEncoding=function(e,r){return r&&r!==t.ENCODING_UTF8?"buffer"===r?new n.Buffer(e):new n.Buffer(e).toString(r):e}},function(e,t,r){"use strict";(function(e){var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(141),a=r(112),s="undefined"==typeof Symbol?"_kCode":Symbol("code"),u={};function c(e){return function(e){function t(t){for(var r=[],n=1;n0,"At least one expected value needs to be specified"),e=e.map((function(e){return String(e)})),r>2?"one of "+t+" "+e.slice(0,r-1).join(", ")+", or "+e[r-1]:2===r?"one of "+t+" "+e[0]+" or "+e[1]:"of "+t+" "+e[0]}return"of "+t+" "+String(e)}t.AssertionError=l,t.message=f,t.E=d,t.Error=c(e.Error),t.TypeError=c(e.TypeError),t.RangeError=c(e.RangeError),d("ERR_ARG_NOT_ITERABLE","%s must be iterable"),d("ERR_ASSERTION","%s"),d("ERR_BUFFER_OUT_OF_BOUNDS",(function(e,t){return t?"Attempt to write outside buffer bounds":'"'+e+'" is outside of buffer bounds'})),d("ERR_CHILD_CLOSED_BEFORE_REPLY","Child closed before reply received"),d("ERR_CONSOLE_WRITABLE_STREAM","Console expects a writable stream instance for %s"),d("ERR_CPU_USAGE","Unable to obtain cpu usage %s"),d("ERR_DNS_SET_SERVERS_FAILED",(function(e,t){return'c-ares failed to set servers: "'+e+'" ['+t+"]"})),d("ERR_FALSY_VALUE_REJECTION","Promise was rejected with falsy value"),d("ERR_ENCODING_NOT_SUPPORTED",(function(e){return'The "'+e+'" encoding is not supported'})),d("ERR_ENCODING_INVALID_ENCODED_DATA",(function(e){return"The encoded data was not valid for encoding "+e})),d("ERR_HTTP_HEADERS_SENT","Cannot render headers after they are sent to the client"),d("ERR_HTTP_INVALID_STATUS_CODE","Invalid status code: %s"),d("ERR_HTTP_TRAILER_INVALID","Trailers are invalid with this transfer encoding"),d("ERR_INDEX_OUT_OF_RANGE","Index out of range"),d("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,i;o(e,"name is required"),t.includes("not ")?(n="must not be",t=t.split("not ")[1]):n="must be";if(Array.isArray(e)){var a=e.map((function(e){return'"'+e+'"'})).join(", ");i="The "+a+" arguments "+n+" "+h(t,"type")}else if(e.includes(" argument"))i="The "+e+" "+n+" "+h(t,"type");else{var s=e.includes(".")?"property":"argument";i='The "'+e+'" '+s+" "+n+" "+h(t,"type")}arguments.length>=3&&(i+=". Received type "+(null!==r?typeof r:"null"));return i})),d("ERR_INVALID_ARRAY_LENGTH",(function(e,t,r){return o.strictEqual(typeof r,"number"),'The array "'+e+'" (length '+r+") must be of length "+t+"."})),d("ERR_INVALID_BUFFER_SIZE","Buffer size must be a multiple of %s"),d("ERR_INVALID_CALLBACK","Callback must be a function"),d("ERR_INVALID_CHAR","Invalid character in %s"),d("ERR_INVALID_CURSOR_POS","Cannot set cursor row without setting its column"),d("ERR_INVALID_FD",'"fd" must be a positive integer: %s'),d("ERR_INVALID_FILE_URL_HOST",'File URL host must be "localhost" or empty on %s'),d("ERR_INVALID_FILE_URL_PATH","File URL path %s"),d("ERR_INVALID_HANDLE_TYPE","This handle type cannot be sent"),d("ERR_INVALID_IP_ADDRESS","Invalid IP address: %s"),d("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+String(t)+'" is invalid for option "'+e+'"'})),d("ERR_INVALID_OPT_VALUE_ENCODING",(function(e){return'The value "'+String(e)+'" is invalid for option "encoding"'})),d("ERR_INVALID_REPL_EVAL_CONFIG",'Cannot specify both "breakEvalOnSigint" and "eval" for REPL'),d("ERR_INVALID_SYNC_FORK_INPUT","Asynchronous forks do not support Buffer, Uint8Array or string input: %s"),d("ERR_INVALID_THIS",'Value of "this" must be of type %s'),d("ERR_INVALID_TUPLE","%s must be an iterable %s tuple"),d("ERR_INVALID_URL","Invalid URL: %s"),d("ERR_INVALID_URL_SCHEME",(function(e){return"The URL must be "+h(e,"scheme")})),d("ERR_IPC_CHANNEL_CLOSED","Channel closed"),d("ERR_IPC_DISCONNECTED","IPC channel is already disconnected"),d("ERR_IPC_ONE_PIPE","Child process can have only one IPC pipe"),d("ERR_IPC_SYNC_FORK","IPC cannot be used with synchronous forks"),d("ERR_MISSING_ARGS",(function(){for(var e=[],t=0;t0,"At least one arg needs to be specified");var r="The ",n=e.length;switch(e=e.map((function(e){return'"'+e+'"'})),n){case 1:r+=e[0]+" argument";break;case 2:r+=e[0]+" and "+e[1]+" arguments";break;default:r+=e.slice(0,n-1).join(", "),r+=", and "+e[n-1]+" arguments"}return r+" must be specified"})),d("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),d("ERR_NAPI_CONS_FUNCTION","Constructor must be a function"),d("ERR_NAPI_CONS_PROTOTYPE_OBJECT","Constructor.prototype must be an object"),d("ERR_NO_CRYPTO","Node.js is not compiled with OpenSSL crypto support"),d("ERR_NO_LONGER_SUPPORTED","%s is no longer supported"),d("ERR_PARSE_HISTORY_DATA","Could not parse history data in %s"),d("ERR_SOCKET_ALREADY_BOUND","Socket is already bound"),d("ERR_SOCKET_BAD_PORT","Port should be > 0 and < 65536"),d("ERR_SOCKET_BAD_TYPE","Bad socket type specified. Valid types are: udp4, udp6"),d("ERR_SOCKET_CANNOT_SEND","Unable to send data"),d("ERR_SOCKET_CLOSED","Socket is closed"),d("ERR_SOCKET_DGRAM_NOT_RUNNING","Not running"),d("ERR_STDERR_CLOSE","process.stderr cannot be closed"),d("ERR_STDOUT_CLOSE","process.stdout cannot be closed"),d("ERR_STREAM_WRAP","Stream has StringDecoder set or is in objectMode"),d("ERR_TLS_CERT_ALTNAME_INVALID","Hostname/IP does not match certificate's altnames: %s"),d("ERR_TLS_DH_PARAM_SIZE",(function(e){return"DH parameter size "+e+" is less than 2048"})),d("ERR_TLS_HANDSHAKE_TIMEOUT","TLS handshake timeout"),d("ERR_TLS_RENEGOTIATION_FAILED","Failed to renegotiate"),d("ERR_TLS_REQUIRED_SERVER_NAME",'"servername" is required parameter for Server.addContext'),d("ERR_TLS_SESSION_ATTACK","TSL session renegotiation attack detected"),d("ERR_TRANSFORM_ALREADY_TRANSFORMING","Calling transform done when still transforming"),d("ERR_TRANSFORM_WITH_LENGTH_0","Calling transform done when writableState.length != 0"),d("ERR_UNKNOWN_ENCODING","Unknown encoding: %s"),d("ERR_UNKNOWN_SIGNAL","Unknown signal: %s"),d("ERR_UNKNOWN_STDIN_TYPE","Unknown stdin file type"),d("ERR_UNKNOWN_STREAM_TYPE","Unknown stream file type"),d("ERR_V8BREAKITERATOR","Full ICU data not installed. See https://github.com/nodejs/node/wiki/Intl")}).call(this,r(23))},function(e,t,r){"use strict"; /* object-assign (c) Sindre Sorhus @license MIT */var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;function a(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,s,u=a(e),c=1;c0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):v(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?v(e,a,t,!1):T(e,a)):v(e,a,t,!1))):n||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function S(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(O,e):O(e))}function O(e){h("emit readable"),e.emit("readable"),I(e)}function T(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(A,e,t))}function A(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=c.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),0===(e-=a)){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function R(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(N,t,e))}function N(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function k(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?R(this):S(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&R(this),null;var n,i=t.needReadable;return h("need readable",i),(0===t.length||t.length-e0?j(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&R(this)),null!==n&&this.emit("data",n),n},_.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},_.prototype.pipe=function(e,t){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?l:_;function c(t,n){h("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,h("cleanup"),e.removeListener("close",y),e.removeListener("finish",b),e.removeListener("drain",f),e.removeListener("error",m),e.removeListener("unpipe",c),r.removeListener("end",l),r.removeListener("end",_),r.removeListener("data",g),d=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||f())}function l(){h("onend"),e.end()}o.endEmitted?i.nextTick(u):r.once("end",u),e.on("unpipe",c);var f=function(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,I(e))}}(r);e.on("drain",f);var d=!1;var p=!1;function g(t){h("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==k(o.pipes,e))&&!d&&(h("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,p=!0),r.pause())}function m(t){h("onerror",t),_(),e.removeListener("error",m),0===s(e,"error")&&e.emit("error",t)}function y(){e.removeListener("finish",b),_()}function b(){h("onfinish"),e.removeListener("close",y),_()}function _(){h("unpipe"),r.unpipe(e)}return r.on("data",g),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",m),e.once("close",y),e.once("finish",b),e.emit("pipe",r),o.flowing||(h("pipe resume"),r.resume()),e},_.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o=this._blockSize;){for(var o=this._blockOffset;o0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=o},function(e,t,r){"use strict";(function(t,n){var i;e.exports=T,T.ReadableState=O;r(63).EventEmitter;var o=function(e,t){return e.listeners(t).length},a=r(193),s=r(10).Buffer,u=t.Uint8Array||function(){};var c,l=r(317);c=l&&l.debuglog?l.debuglog("stream"):function(){};var f,d,h,p=r(318),g=r(194),m=r(195).getHighWaterMark,y=r(85).codes,b=y.ERR_INVALID_ARG_TYPE,_=y.ERR_STREAM_PUSH_AFTER_EOF,w=y.ERR_METHOD_NOT_IMPLEMENTED,v=y.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(11)(T,a);var E=g.errorOrDestroy,S=["error","close","destroy","pause","resume"];function O(e,t,n){i=i||r(86),e=e||{},"boolean"!=typeof n&&(n=t instanceof i),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=m(this,e,"readableHighWaterMark",n),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(f||(f=r(70).StringDecoder),this.decoder=new f(e.encoding),this.encoding=e.encoding)}function T(e){if(i=i||r(86),!(this instanceof T))return new T(e);var t=this instanceof i;this._readableState=new O(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),a.call(this)}function A(e,t,r,n,i){c("readableAddChunk",t);var o,a=e._readableState;if(null===t)a.reading=!1,function(e,t){if(c("onEofChunk"),t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?I(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,j(e)))}(e,a);else if(i||(o=function(e,t){var r;n=t,s.isBuffer(n)||n instanceof u||"string"==typeof t||void 0===t||e.objectMode||(r=new b("chunk",["string","Buffer","Uint8Array"],t));var n;return r}(a,t)),o)E(e,o);else if(a.objectMode||t&&t.length>0)if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===s.prototype||(t=function(e){return s.from(e)}(t)),n)a.endEmitted?E(e,new v):M(e,a,t,!0);else if(a.ended)E(e,new _);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?M(e,a,t,!1):R(e,a)):M(e,a,t,!1)}else n||(a.reading=!1,R(e,a));return!a.ended&&(a.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=1073741824?e=1073741824:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function I(e){var t=e._readableState;c("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(c("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(j,e))}function j(e){var t=e._readableState;c("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,x(e)}function R(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(N,e,t))}function N(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function C(e){c("readable nexttick read 0"),e.read(0)}function L(e,t){c("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),x(e),t.flowing&&!t.reading&&e.read(0)}function x(e){var t=e._readableState;for(c("flow",t.flowing);t.flowing&&null!==e.read(););}function P(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function B(e){var t=e._readableState;c("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(U,t,e))}function U(e,t){if(c("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function F(e,t){for(var r=0,n=e.length;r=t.highWaterMark:t.length>0)||t.ended))return c("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?B(this):I(this),null;if(0===(e=D(e,t))&&t.ended)return 0===t.length&&B(this),null;var n,i=t.needReadable;return c("need readable",i),(0===t.length||t.length-e0?P(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&B(this)),null!==n&&this.emit("data",n),n},T.prototype._read=function(e){E(this,new w("_read()"))},T.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,c("pipe count=%d opts=%j",i.pipesCount,t);var a=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?u:m;function s(t,n){c("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,c("cleanup"),e.removeListener("close",p),e.removeListener("finish",g),e.removeListener("drain",l),e.removeListener("error",h),e.removeListener("unpipe",s),r.removeListener("end",u),r.removeListener("end",m),r.removeListener("data",d),f=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function u(){c("onend"),e.end()}i.endEmitted?n.nextTick(a):r.once("end",a),e.on("unpipe",s);var l=function(e){return function(){var t=e._readableState;c("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,x(e))}}(r);e.on("drain",l);var f=!1;function d(t){c("ondata");var n=e.write(t);c("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==F(i.pipes,e))&&!f&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function h(t){c("onerror",t),m(),e.removeListener("error",h),0===o(e,"error")&&E(e,t)}function p(){e.removeListener("finish",g),m()}function g(){c("onfinish"),e.removeListener("close",p),m()}function m(){c("unpipe"),r.unpipe(e)}return r.on("data",d),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",h),e.once("close",p),e.once("finish",g),e.emit("pipe",r),i.flowing||(c("pipe resume"),r.resume()),e},T.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?I(this):i.reading||n.nextTick(C,this))),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(e,t){var r=a.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(k,this),r},T.prototype.removeAllListeners=function(e){var t=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(k,this),t},T.prototype.resume=function(){var e=this._readableState;return e.flowing||(c("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(L,e,t))}(this,e)),e.paused=!1,this},T.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",(function(){if(c("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){(c("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(t.push(i)||(n=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o-1))throw new v(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(e,t,r){r(new g("_write()"))},T.prototype._writev=null,T.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,r){t.ending=!0,R(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),T.prototype.destroy=f.destroy,T.prototype._undestroy=f.undestroy,T.prototype._destroy=function(e,t){t(e)}}).call(this,r(23),r(19))},function(e,t,r){"use strict";e.exports=l;var n=r(85).codes,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(86);function c(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function d(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function h(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,p=0|this._f,g=0|this._g,m=0|this._h,y=0;y<16;++y)r[y]=e.readInt32BE(4*y);for(;y<64;++y)r[y]=0|(((t=r[y-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[y-7]+h(r[y-15])+r[y-16];for(var b=0;b<64;++b){var _=m+d(u)+c(u,p,g)+a[b]+r[b]|0,w=f(n)+l(n,i,o)|0;m=g,g=p,p=u,u=s+_|0,s=o,o=i,i=n,n=_+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0,this._f=p+this._f|0,this._g=g+this._g|0,this._h=m+this._h|0},u.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},e.exports=u},function(e,t,r){var n=r(11),i=r(87),o=r(16).Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function l(e,t,r){return e&t|r&(e|t)}function f(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function d(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function h(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function g(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function m(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function y(e,t){return e>>>0>>0?1:0}n(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,s=0|this._eh,u=0|this._fh,b=0|this._gh,_=0|this._hh,w=0|this._al,v=0|this._bl,E=0|this._cl,S=0|this._dl,O=0|this._el,T=0|this._fl,A=0|this._gl,M=0|this._hl,D=0;D<32;D+=2)t[D]=e.readInt32BE(4*D),t[D+1]=e.readInt32BE(4*D+4);for(;D<160;D+=2){var I=t[D-30],j=t[D-30+1],R=h(I,j),N=p(j,I),k=g(I=t[D-4],j=t[D-4+1]),C=m(j,I),L=t[D-14],x=t[D-14+1],P=t[D-32],B=t[D-32+1],U=N+x|0,F=R+L+y(U,N)|0;F=(F=F+k+y(U=U+C|0,C)|0)+P+y(U=U+B|0,B)|0,t[D]=F,t[D+1]=U}for(var W=0;W<160;W+=2){F=t[W],U=t[W+1];var H=l(r,n,i),z=l(w,v,E),q=f(r,w),V=f(w,r),G=d(s,O),Y=d(O,s),$=a[W],K=a[W+1],Z=c(s,u,b),X=c(O,T,A),J=M+Y|0,Q=_+G+y(J,M)|0;Q=(Q=(Q=Q+Z+y(J=J+X|0,X)|0)+$+y(J=J+K|0,K)|0)+F+y(J=J+U|0,U)|0;var ee=V+z|0,te=q+H+y(ee,V)|0;_=b,M=A,b=u,A=T,u=s,T=O,s=o+Q+y(O=S+J|0,S)|0,o=i,S=E,i=n,E=v,n=r,v=w,r=Q+te+y(w=J+ee|0,J)|0}this._al=this._al+w|0,this._bl=this._bl+v|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+O|0,this._fl=this._fl+T|0,this._gl=this._gl+A|0,this._hl=this._hl+M|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+n+y(this._bl,v)|0,this._ch=this._ch+i+y(this._cl,E)|0,this._dh=this._dh+o+y(this._dl,S)|0,this._eh=this._eh+s+y(this._el,O)|0,this._fh=this._fh+u+y(this._fl,T)|0,this._gh=this._gh+b+y(this._gl,A)|0,this._hh=this._hh+_+y(this._hl,M)|0},u.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},e.exports=u},function(e,t,r){"use strict";var n=r(11),i=r(328),o=r(71),a=r(16).Buffer,s=r(201),u=r(148),c=r(149),l=a.alloc(128);function f(e,t){o.call(this,"digest"),"string"==typeof t&&(t=a.from(t));var r="sha512"===e||"sha384"===e?128:64;(this._alg=e,this._key=t,t.length>r)?t=("rmd160"===e?new u:c(e)).update(t).digest():t.lengthr||t!=t)throw new TypeError("Bad key length")}},function(e,t,r){(function(t,r){var n;if(t.process&&t.process.browser)n="utf-8";else if(t.process&&t.process.version){n=parseInt(r.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary"}else n="utf-8";e.exports=n}).call(this,r(23),r(19))},function(e,t,r){var n=r(201),i=r(148),o=r(149),a=r(16).Buffer,s=r(204),u=r(205),c=r(207),l=a.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function d(e,t,r){var s=function(e){function t(t){return o(e).update(t).digest()}return"rmd160"===e||"ripemd160"===e?function(e){return(new i).update(e).digest()}:"md5"===e?n:t}(e),u="sha512"===e||"sha384"===e?128:64;t.length>u?t=s(t):t.length>>0},t.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},t.ip=function(e,t,r,n){for(var i=0,o=0,a=6;a>=0;a-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>>s+a&1}for(a=6;a>=0;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[n+0]=i>>>0,r[n+1]=o>>>0},t.rip=function(e,t,r,n){for(var i=0,o=0,a=0;a<4;a++)for(var s=24;s>=0;s-=8)i<<=1,i|=t>>>s+a&1,i<<=1,i|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;s>=0;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},t.pc1=function(e,t,r,n){for(var i=0,o=0,a=7;a>=5;a--){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+a&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},t.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];t.pc2=function(e,t,r,i){for(var o=0,a=0,s=n.length>>>1,u=0;u>>n[u]&1;for(u=s;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=a>>>0},t.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];t.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];t.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},t.padSplit=function(e,t,r){for(var n=e.toString(2);n.length>>1];r=o.r28shl(r,s),i=o.r28shl(i,s),o.pc2(r,i,e.keys,a)}},u.prototype._update=function(e,t,r,n){var i=this._desState,a=o.readUInt32BE(e,t),s=o.readUInt32BE(e,t+4);o.ip(a,s,i.tmp,0),a=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,a,s,i.tmp,0):this._decrypt(i,a,s,i.tmp,0),a=i.tmp[0],s=i.tmp[1],o.writeUInt32BE(r,a,n),o.writeUInt32BE(r,s,n+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,a=d}o.rip(s,a,n,i)},u.prototype._decrypt=function(e,t,r,n,i){for(var a=r,s=t,u=e.keys.length-2;u>=0;u-=2){var c=e.keys[u],l=e.keys[u+1];o.expand(a,e.tmp,0),c^=e.tmp[0],l^=e.tmp[1];var f=o.substitute(c,l),d=a;a=(s^o.permute(f))>>>0,s=d}o.rip(a,s,n,i)}},function(e,t,r){var n=r(102),i=r(16).Buffer,o=r(211);function a(e){var t=e._cipher.encryptBlockRaw(e._prev);return o(e._prev),t}t.encrypt=function(e,t){var r=Math.ceil(t.length/16),o=e._cache.length;e._cache=i.concat([e._cache,i.allocUnsafe(16*r)]);for(var s=0;se;)r.ishrn(1);if(r.isEven()&&r.iadd(s),r.testn(1)||r.iadd(u),t.cmp(u)){if(!t.cmp(c))for(;r.mod(l).cmp(f);)r.iadd(h)}else for(;r.mod(o).cmp(d);)r.iadd(h);if(m(p=r.shrn(1))&&m(r)&&y(p)&&y(r)&&a.test(p)&&a.test(r))return r}}},function(e,t,r){var n=r(35),i=r(153);function o(e){this.rand=e||new i.Rand}e.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(e)>=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),a=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),u=0;!s.testn(u);u++);for(var c=e.shrn(u),l=s.toRed(o);t>0;t--){var f=this._randrange(new n(2),s);r&&r(f);var d=f.toRed(o).redPow(c);if(0!==d.cmp(a)&&0!==d.cmp(l)){for(var h=1;h0;t--){var l=this._randrange(new n(2),a),f=e.gcd(l);if(0!==f.cmpn(1))return f;var d=l.toRed(i).redPow(u);if(0!==d.cmp(o)&&0!==d.cmp(c)){for(var h=1;h0)if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===s.prototype||(t=function(e){return s.from(e)}(t)),n)a.endEmitted?E(e,new v):M(e,a,t,!0);else if(a.ended)E(e,new _);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?M(e,a,t,!1):R(e,a)):M(e,a,t,!1)}else n||(a.reading=!1,R(e,a));return!a.ended&&(a.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=1073741824?e=1073741824:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function I(e){var t=e._readableState;c("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(c("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(j,e))}function j(e){var t=e._readableState;c("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,x(e)}function R(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(N,e,t))}function N(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function C(e){c("readable nexttick read 0"),e.read(0)}function L(e,t){c("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),x(e),t.flowing&&!t.reading&&e.read(0)}function x(e){var t=e._readableState;for(c("flow",t.flowing);t.flowing&&null!==e.read(););}function P(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function B(e){var t=e._readableState;c("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(U,t,e))}function U(e,t){if(c("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function F(e,t){for(var r=0,n=e.length;r=t.highWaterMark:t.length>0)||t.ended))return c("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?B(this):I(this),null;if(0===(e=D(e,t))&&t.ended)return 0===t.length&&B(this),null;var n,i=t.needReadable;return c("need readable",i),(0===t.length||t.length-e0?P(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&B(this)),null!==n&&this.emit("data",n),n},T.prototype._read=function(e){E(this,new w("_read()"))},T.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,c("pipe count=%d opts=%j",i.pipesCount,t);var a=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?u:m;function s(t,n){c("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,c("cleanup"),e.removeListener("close",p),e.removeListener("finish",g),e.removeListener("drain",l),e.removeListener("error",h),e.removeListener("unpipe",s),r.removeListener("end",u),r.removeListener("end",m),r.removeListener("data",d),f=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function u(){c("onend"),e.end()}i.endEmitted?n.nextTick(a):r.once("end",a),e.on("unpipe",s);var l=function(e){return function(){var t=e._readableState;c("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,x(e))}}(r);e.on("drain",l);var f=!1;function d(t){c("ondata");var n=e.write(t);c("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==F(i.pipes,e))&&!f&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function h(t){c("onerror",t),m(),e.removeListener("error",h),0===o(e,"error")&&E(e,t)}function p(){e.removeListener("finish",g),m()}function g(){c("onfinish"),e.removeListener("close",p),m()}function m(){c("unpipe"),r.unpipe(e)}return r.on("data",d),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",h),e.once("close",p),e.once("finish",g),e.emit("pipe",r),i.flowing||(c("pipe resume"),r.resume()),e},T.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?I(this):i.reading||n.nextTick(C,this))),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(e,t){var r=a.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(k,this),r},T.prototype.removeAllListeners=function(e){var t=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(k,this),t},T.prototype.resume=function(){var e=this._readableState;return e.flowing||(c("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(L,e,t))}(this,e)),e.paused=!1,this},T.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",(function(){if(c("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){(c("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(t.push(i)||(n=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o-1))throw new v(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(e,t,r){r(new g("_write()"))},T.prototype._writev=null,T.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,r){t.ending=!0,R(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),T.prototype.destroy=f.destroy,T.prototype._undestroy=f.undestroy,T.prototype._destroy=function(e,t){t(e)}}).call(this,r(23),r(19))},function(e,t,r){"use strict";e.exports=l;var n=r(88).codes,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(89);function c(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length>8,a=255&i;o?r.push(o,a):r.push(a)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},function(e,t,r){"use strict";var n=t;n.base=r(117),n.short=r(364),n.mont=r(365),n.edwards=r(366)},function(e,t,r){"use strict";var n=r(53).rotr32;function i(e,t,r){return e&t^~e&r}function o(e,t,r){return e&t^e&r^t&r}function a(e,t,r){return e^t^r}t.ft_1=function(e,t,r,n){return 0===e?i(t,r,n):1===e||3===e?a(t,r,n):2===e?o(t,r,n):void 0},t.ch32=i,t.maj32=o,t.p32=a,t.s0_256=function(e){return n(e,2)^n(e,13)^n(e,22)},t.s1_256=function(e){return n(e,6)^n(e,11)^n(e,25)},t.g0_256=function(e){return n(e,7)^n(e,18)^e>>>3},t.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},function(e,t,r){"use strict";var n=r(53),i=r(103),o=r(225),a=r(44),s=n.sum32,u=n.sum32_4,c=n.sum32_5,l=o.ch32,f=o.maj32,d=o.s0_256,h=o.s1_256,p=o.g0_256,g=o.g1_256,m=i.BlockHash,y=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function b(){if(!(this instanceof b))return new b;m.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=y,this.W=new Array(64)}n.inherits(b,m),e.exports=b,b.blockSize=512,b.outSize=256,b.hmacStrength=192,b.padLength=64,b.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+e)}function u(e,t,r){var n=s(e,r);return r-1>=t&&(n|=s(e,r-1)<<4),n}function c(e,t,r,i){for(var o=0,a=0,s=Math.min(e.length,r),u=t;u=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&a0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},o.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n=t;n-=2)i=u(e,t,n)<=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(n=(e.length-t)%2==0?t+1:t;n=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;this._strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(e){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}var d=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?d[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var c=h[e],l=p[e];r="";var f=this.clone();for(f.negative=0;!f.isZero();){var g=f.modrn(l).toString(e);r=(f=f.idivn(l)).isZero()?g+r:d[c-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16,2)},a&&(o.prototype.toBuffer=function(e,t){return this.toArrayLike(a,e,t)}),o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function g(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,f=67108863&u,d=Math.min(c,t.length-1),h=Math.max(0,c-e.length+1);h<=d;h++){var p=c-h|0;l+=(a=(i=0|e.words[p])*(o=0|t.words[h])+f)/67108864|0,f=67108863&a}r.words[c]=0|f,u=0|l}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0");var a=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this["_toArrayLike"+("le"===t?"LE":"BE")](a,i),a},o.prototype._toArrayLikeLE=function(e,t){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r=0&&(e[r--]=a>>8&255),r>=0&&(e[r--]=a>>16&255),6===o?(r>=0&&(e[r--]=a>>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r>=0)for(e[r--]=n;r>=0;)e[r--]=0},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,h=0|a[1],p=8191&h,g=h>>>13,m=0|a[2],y=8191&m,b=m>>>13,_=0|a[3],w=8191&_,v=_>>>13,E=0|a[4],S=8191&E,O=E>>>13,T=0|a[5],A=8191&T,M=T>>>13,D=0|a[6],I=8191&D,j=D>>>13,R=0|a[7],N=8191&R,k=R>>>13,C=0|a[8],L=8191&C,x=C>>>13,P=0|a[9],B=8191&P,U=P>>>13,F=0|s[0],W=8191&F,H=F>>>13,z=0|s[1],q=8191&z,V=z>>>13,G=0|s[2],Y=8191&G,$=G>>>13,K=0|s[3],Z=8191&K,X=K>>>13,J=0|s[4],Q=8191&J,ee=J>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,le=0|s[8],fe=8191&le,de=le>>>13,he=0|s[9],pe=8191&he,ge=he>>>13;r.negative=e.negative^t.negative,r.length=19;var me=(c+(n=Math.imul(f,W))|0)+((8191&(i=(i=Math.imul(f,H))+Math.imul(d,W)|0))<<13)|0;c=((o=Math.imul(d,H))+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(p,W),i=(i=Math.imul(p,H))+Math.imul(g,W)|0,o=Math.imul(g,H);var ye=(c+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,V)|0)+Math.imul(d,q)|0))<<13)|0;c=((o=o+Math.imul(d,V)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,W),i=(i=Math.imul(y,H))+Math.imul(b,W)|0,o=Math.imul(b,H),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(g,q)|0,o=o+Math.imul(g,V)|0;var be=(c+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(d,Y)|0))<<13)|0;c=((o=o+Math.imul(d,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(w,W),i=(i=Math.imul(w,H))+Math.imul(v,W)|0,o=Math.imul(v,H),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,V)|0)+Math.imul(b,q)|0,o=o+Math.imul(b,V)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,$)|0;var _e=(c+(n=n+Math.imul(f,Z)|0)|0)+((8191&(i=(i=i+Math.imul(f,X)|0)+Math.imul(d,Z)|0))<<13)|0;c=((o=o+Math.imul(d,X)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(S,W),i=(i=Math.imul(S,H))+Math.imul(O,W)|0,o=Math.imul(O,H),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(b,Y)|0,o=o+Math.imul(b,$)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,X)|0;var we=(c+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,ee)|0)+Math.imul(d,Q)|0))<<13)|0;c=((o=o+Math.imul(d,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(A,W),i=(i=Math.imul(A,H))+Math.imul(M,W)|0,o=Math.imul(M,H),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(O,q)|0,o=o+Math.imul(O,V)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,$)|0,n=n+Math.imul(y,Z)|0,i=(i=i+Math.imul(y,X)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,X)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,ee)|0;var ve=(c+(n=n+Math.imul(f,re)|0)|0)+((8191&(i=(i=i+Math.imul(f,ne)|0)+Math.imul(d,re)|0))<<13)|0;c=((o=o+Math.imul(d,ne)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(I,W),i=(i=Math.imul(I,H))+Math.imul(j,W)|0,o=Math.imul(j,H),n=n+Math.imul(A,q)|0,i=(i=i+Math.imul(A,V)|0)+Math.imul(M,q)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(S,Y)|0,i=(i=i+Math.imul(S,$)|0)+Math.imul(O,Y)|0,o=o+Math.imul(O,$)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,X)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ne)|0;var Ee=(c+(n=n+Math.imul(f,oe)|0)|0)+((8191&(i=(i=i+Math.imul(f,ae)|0)+Math.imul(d,oe)|0))<<13)|0;c=((o=o+Math.imul(d,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,W),i=(i=Math.imul(N,H))+Math.imul(k,W)|0,o=Math.imul(k,H),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,V)|0)+Math.imul(j,q)|0,o=o+Math.imul(j,V)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(M,Y)|0,o=o+Math.imul(M,$)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,X)|0)+Math.imul(O,Z)|0,o=o+Math.imul(O,X)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,ae)|0;var Se=(c+(n=n+Math.imul(f,ue)|0)|0)+((8191&(i=(i=i+Math.imul(f,ce)|0)+Math.imul(d,ue)|0))<<13)|0;c=((o=o+Math.imul(d,ce)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(L,W),i=(i=Math.imul(L,H))+Math.imul(x,W)|0,o=Math.imul(x,H),n=n+Math.imul(N,q)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,V)|0,n=n+Math.imul(I,Y)|0,i=(i=i+Math.imul(I,$)|0)+Math.imul(j,Y)|0,o=o+Math.imul(j,$)|0,n=n+Math.imul(A,Z)|0,i=(i=i+Math.imul(A,X)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(O,Q)|0,o=o+Math.imul(O,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(g,ue)|0,o=o+Math.imul(g,ce)|0;var Oe=(c+(n=n+Math.imul(f,fe)|0)|0)+((8191&(i=(i=i+Math.imul(f,de)|0)+Math.imul(d,fe)|0))<<13)|0;c=((o=o+Math.imul(d,de)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(B,W),i=(i=Math.imul(B,H))+Math.imul(U,W)|0,o=Math.imul(U,H),n=n+Math.imul(L,q)|0,i=(i=i+Math.imul(L,V)|0)+Math.imul(x,q)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(N,Y)|0,i=(i=i+Math.imul(N,$)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,$)|0,n=n+Math.imul(I,Z)|0,i=(i=i+Math.imul(I,X)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,X)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(O,re)|0,o=o+Math.imul(O,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(y,ue)|0,i=(i=i+Math.imul(y,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0,n=n+Math.imul(p,fe)|0,i=(i=i+Math.imul(p,de)|0)+Math.imul(g,fe)|0,o=o+Math.imul(g,de)|0;var Te=(c+(n=n+Math.imul(f,pe)|0)|0)+((8191&(i=(i=i+Math.imul(f,ge)|0)+Math.imul(d,pe)|0))<<13)|0;c=((o=o+Math.imul(d,ge)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,V))+Math.imul(U,q)|0,o=Math.imul(U,V),n=n+Math.imul(L,Y)|0,i=(i=i+Math.imul(L,$)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,$)|0,n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,X)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,ee)|0)+Math.imul(j,Q)|0,o=o+Math.imul(j,ee)|0,n=n+Math.imul(A,re)|0,i=(i=i+Math.imul(A,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(O,oe)|0,o=o+Math.imul(O,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(y,fe)|0,i=(i=i+Math.imul(y,de)|0)+Math.imul(b,fe)|0,o=o+Math.imul(b,de)|0;var Ae=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ge)|0)+Math.imul(g,pe)|0))<<13)|0;c=((o=o+Math.imul(g,ge)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,Y),i=(i=Math.imul(B,$))+Math.imul(U,Y)|0,o=Math.imul(U,$),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,X)|0,n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(I,re)|0,i=(i=i+Math.imul(I,ne)|0)+Math.imul(j,re)|0,o=o+Math.imul(j,ne)|0,n=n+Math.imul(A,oe)|0,i=(i=i+Math.imul(A,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(O,ue)|0,o=o+Math.imul(O,ce)|0,n=n+Math.imul(w,fe)|0,i=(i=i+Math.imul(w,de)|0)+Math.imul(v,fe)|0,o=o+Math.imul(v,de)|0;var Me=(c+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,ge)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,ge)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(B,Z),i=(i=Math.imul(B,X))+Math.imul(U,Z)|0,o=Math.imul(U,X),n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(I,oe)|0,i=(i=i+Math.imul(I,ae)|0)+Math.imul(j,oe)|0,o=o+Math.imul(j,ae)|0,n=n+Math.imul(A,ue)|0,i=(i=i+Math.imul(A,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(S,fe)|0,i=(i=i+Math.imul(S,de)|0)+Math.imul(O,fe)|0,o=o+Math.imul(O,de)|0;var De=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ge)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,ge)|0)+(i>>>13)|0)+(De>>>26)|0,De&=67108863,n=Math.imul(B,Q),i=(i=Math.imul(B,ee))+Math.imul(U,Q)|0,o=Math.imul(U,ee),n=n+Math.imul(L,re)|0,i=(i=i+Math.imul(L,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,n=n+Math.imul(I,ue)|0,i=(i=i+Math.imul(I,ce)|0)+Math.imul(j,ue)|0,o=o+Math.imul(j,ce)|0,n=n+Math.imul(A,fe)|0,i=(i=i+Math.imul(A,de)|0)+Math.imul(M,fe)|0,o=o+Math.imul(M,de)|0;var Ie=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ge)|0)+Math.imul(O,pe)|0))<<13)|0;c=((o=o+Math.imul(O,ge)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(B,re),i=(i=Math.imul(B,ne))+Math.imul(U,re)|0,o=Math.imul(U,ne),n=n+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,ce)|0,n=n+Math.imul(I,fe)|0,i=(i=i+Math.imul(I,de)|0)+Math.imul(j,fe)|0,o=o+Math.imul(j,de)|0;var je=(c+(n=n+Math.imul(A,pe)|0)|0)+((8191&(i=(i=i+Math.imul(A,ge)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,ge)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(B,oe),i=(i=Math.imul(B,ae))+Math.imul(U,oe)|0,o=Math.imul(U,ae),n=n+Math.imul(L,ue)|0,i=(i=i+Math.imul(L,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(N,fe)|0,i=(i=i+Math.imul(N,de)|0)+Math.imul(k,fe)|0,o=o+Math.imul(k,de)|0;var Re=(c+(n=n+Math.imul(I,pe)|0)|0)+((8191&(i=(i=i+Math.imul(I,ge)|0)+Math.imul(j,pe)|0))<<13)|0;c=((o=o+Math.imul(j,ge)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(B,ue),i=(i=Math.imul(B,ce))+Math.imul(U,ue)|0,o=Math.imul(U,ce),n=n+Math.imul(L,fe)|0,i=(i=i+Math.imul(L,de)|0)+Math.imul(x,fe)|0,o=o+Math.imul(x,de)|0;var Ne=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,ge)|0)+Math.imul(k,pe)|0))<<13)|0;c=((o=o+Math.imul(k,ge)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(B,fe),i=(i=Math.imul(B,de))+Math.imul(U,fe)|0,o=Math.imul(U,de);var ke=(c+(n=n+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,ge)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,ge)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863;var Ce=(c+(n=Math.imul(B,pe))|0)+((8191&(i=(i=Math.imul(B,ge))+Math.imul(U,pe)|0))<<13)|0;return c=((o=Math.imul(U,ge))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=me,u[1]=ye,u[2]=be,u[3]=_e,u[4]=we,u[5]=ve,u[6]=Ee,u[7]=Se,u[8]=Oe,u[9]=Te,u[10]=Ae,u[11]=Me,u[12]=De,u[13]=Ie,u[14]=je,u[15]=Re,u[16]=Ne,u[17]=ke,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function y(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function b(e,t,r){return y(e,t,r)}function _(e,t){this.x=e,this.y=t}Math.imul||(m=g),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?m(this,e,t):r<63?g(this,e,t):r<1024?y(this,e,t):b(this,e,t)},_.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},_.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,r+=o/67108864|0,r+=a>>>26,this.words[i]=67108863&a}return 0!==r&&(this.words[i]=r,this.length++),t?this.ineg():this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i&1}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==l||c>=i);c--){var f=0|this.words[c];this.words[c]=l<<26-o|f>>>o,l=f&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this._strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;f--){var d=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(d=Math.min(d/a|0,67108863),n._ishlnsubmul(i,d,f);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);s&&(s.words[f]=d)}return s&&s._strip(),n._strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modrn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%e;return t?-i:i},o.prototype.modn=function(e){return this.modrn(e)},o.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/e|0,r=o%e}return this._strip(),t?this.ineg():this},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var l=r.clone(),f=t.clone();!t.isZero();){for(var d=0,h=1;0==(t.words[0]&h)&&d<26;++d,h<<=1);if(d>0)for(t.iushrn(d);d-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(l),a.isub(f)),i.iushrn(1),a.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(f)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,l=1;0==(t.words[0]&l)&&c<26;++c,l<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var f=0,d=1;0==(r.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(r.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var w={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function E(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function S(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function O(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function T(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function M(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},i(E,v),E.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},E.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(w[e])return w[e];var t;if("k256"===e)t=new E;else if("p224"===e)t=new S;else if("p192"===e)t=new O;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new T}return w[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(l(e,e.umod(this.m)._forceRed(this)),e)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,c).cmp(u);)l.redIAdd(u);for(var f=this.pow(l,i),d=this.pow(e,i.addn(1).iushrn(1)),h=this.pow(e,i),p=a;0!==h.cmp(s);){for(var g=h,m=0;0!==g.cmp(s);m++)g=g.redSqr();n(m=0;n--){for(var c=t.words[n],l=u-1;l>=0;l--){var f=c>>l&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==a?(a<<=1,a|=f,(4===++s||0===n&&0===l)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new M(e)},i(M,A),M.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},M.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},M.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},M.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},M.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(97)(e))},function(e,t,r){"use strict";const n=t;n.bignum=r(35),n.define=r(383).define,n.base=r(386),n.constants=r(387),n.decoders=r(232),n.encoders=r(230)},function(e,t,r){"use strict";const n=t;n.der=r(231),n.pem=r(384)},function(e,t,r){"use strict";const n=r(11),i=r(159).Buffer,o=r(160),a=r(162);function s(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new u,this.tree._init(e.body)}function u(e){o.call(this,"der",e)}function c(e){return e<10?"0"+e:e}e.exports=s,s.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},n(u,o),u.prototype._encodeComposite=function(e,t,r,n){const o=function(e,t,r,n){let i;"seqof"===e?e="seq":"setof"===e&&(e="set");if(a.tagByName.hasOwnProperty(e))i=a.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return n.error("Unknown tag: "+e);i=e}if(i>=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=a.tagClassByName[r||"universal"]<<6,i}(e,t,r,this.reporter);if(n.length<128){const e=i.alloc(2);return e[0]=o,e[1]=n.length,this._createEncoderBuffer([e,n])}let s=1;for(let e=n.length;e>=256;e>>=8)s++;const u=i.alloc(2+s);u[0]=o,u[1]=128|s;for(let e=1+s,t=n.length;t>0;e--,t>>=8)u[e]=255&t;return this._createEncoderBuffer([u,n])},u.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=i.alloc(2*e.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let n=0;for(let t=0;t=128;r>>=7)n++}const o=i.alloc(n);let a=o.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(o[a--]=127&r;(r>>=7)>0;)o[a--]=128|127&r}return this._createEncoderBuffer(o)},u.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[c(n.getUTCFullYear()),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[c(n.getUTCFullYear()%100),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},u.prototype._encodeNull=function(){return this._createEncoderBuffer("")},u.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){const t=e.toArray();!e.sign&&128&t[0]&&t.unshift(0),e=i.from(t)}if(i.isBuffer(e)){let t=e.length;0===e.length&&t++;const r=i.alloc(t);return e.copy(r),0===e.length&&(r[0]=0),this._createEncoderBuffer(r)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let r=1;for(let t=e;t>=256;t>>=8)r++;const n=new Array(r);for(let t=n.length-1;t>=0;t--)n[t]=255&e,e>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(i.from(n))},u.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},u.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},u.prototype._skipDefault=function(e,t,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function f(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(let t=0;t>>((3&t)<<3)&255;return i}}},function(e,t){for(var r=[],n=0;n<256;++n)r[n]=(n+256).toString(16).substr(1);e.exports=function(e,t){var n=t||0,i=r;return[i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]]].join("")}},function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(31);let i=r(163);async function o(){return(await n.a.randomBytes(12)).toString()}async function a(e){let t=new i.Message;t.setDataset(await o()),t.setRow(await o()),t.setColumn(await o()),t.setValue(await o());let r=t.serializeBinary();return await n.a.encrypt(r,e)}},function(e,t,r){"use strict";r.d(t,"a",(function(){return f}));var n=r(37),i=r(1),o=r(8),a=r(9),s=r.n(a),u=r(24),c=r(6);const l=r(52);async function f(e){if(!e){let e=await n.a(),t=e.valid,r=e.error;if(r)return{error:r};if(!t)return{error:{reason:"file-has-new-key"}}}let t=(await n.g(e)).error;if(t)return{error:t};if(await Object(c.runMutator)(async()=>{await i.execQuery("\n DELETE FROM messages_crdt;\n DELETE FROM messages_clock;\n DELETE FROM transactions WHERE tombstone = 1;\n DELETE FROM accounts WHERE tombstone = 1;\n DELETE FROM payees WHERE tombstone = 1;\n DELETE FROM categories WHERE tombstone = 1;\n DELETE FROM category_groups WHERE tombstone = 1;\n DELETE FROM schedules WHERE tombstone = 1;\n DELETE FROM rules WHERE tombstone = 1;\n ANALYZE;\n VACUUM;\n "),await i.loadClock()}),await o.d({groupId:null,lastSyncedTimestamp:null,lastUploaded:null}),e){let t=e.key,r=o.b().cloudFileId,n=JSON.parse(await s.a.getItem("encrypt-keys")||"{}");n[r]=t.serialize(),await s.a.setItem("encrypt-keys",JSON.stringify(n)),await o.d({encryptKeyId:t.getId()})}try{await n.h()}catch(e){return e.reason?{error:e}:(Object(u.captureException)(e),{error:{reason:"upload-failure"}})}finally{l.send("prefs-updated")}return{}}},function(e,t){e.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,FLG_ENC:0,FLG_COMP1:1,FLG_COMP2:2,FLG_DESC:4,FLG_ENH:8,FLG_STR:16,FLG_LNG:1024,FLG_MSK:4096,FILE:0,BUFFER:1,NONE:2,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}},function(e,t){e.exports={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed",FILE_IN_THE_WAY:"There is a file in the way: %s",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:"File not found: %s",NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found"}},function(e,t,r){(function(t){var n=r(105),i=r(245),o=n.Constants,a=r(417);e.exports=function(e){var r=new i.EntryHeader,s=t.alloc(0),u=t.alloc(0),c=!1,l=null,f=t.alloc(0);function d(){return e&&t.isBuffer(e)?(r.loadDataHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize)):t.alloc(0)}function h(e){return 8==(8&r.flags)||n.crc32(e)===r.dataHeader.crc}function p(e,i,o){if(void 0===i&&"string"==typeof e&&(e,e=void 0),c)return e&&i&&i(t.alloc(0),n.Errors.DIRECTORY_CONTENT_ERROR),t.alloc(0);var u=d();if(0===u.length)return e&&i&&i(u,n.Errors.NO_DATA),u;var l=t.alloc(r.size);switch(r.method){case n.Constants.STORED:return u.copy(l),h(l)?(e&&i&&i(l),l):(e&&i&&i(l,n.Errors.BAD_CRC),n.Errors.BAD_CRC);case n.Constants.DEFLATED:var f=new a.Inflater(u);if(!e)return f.inflate(l).copy(l,0),h(l)||console.warn(n.Errors.BAD_CRC+" "+s.toString()),l;f.inflateAsync((function(e){e.copy(l,0),h(l)?i&&i(l):i&&i(l,n.Errors.BAD_CRC)}));break;default:return e&&i&&i(t.alloc(0),n.Errors.UNKNOWN_METHOD),n.Errors.UNKNOWN_METHOD}}function g(i,o){if((!l||!l.length)&&t.isBuffer(e))return i&&o&&o(d()),d();if(l.length&&!c){var s;switch(r.method){case n.Constants.STORED:return r.compressedSize=r.size,s=t.alloc(l.length),l.copy(s),i&&o&&o(s),s;default:case n.Constants.DEFLATED:var u=new a.Deflater(l);if(!i){var f=u.deflate();return r.compressedSize=f.length,f}u.deflateAsync((function(e){s=t.alloc(e.length),r.compressedSize=e.length,e.copy(s),o&&o(s)})),u=null}}else{if(!i||!o)return t.alloc(0);o(t.alloc(0))}}function m(e,t){return(e.readUInt32LE(t+4)<<4)+e.readUInt32LE(t)}function y(e){var t,n,i,a;e.length>=o.EF_ZIP64_SCOMP&&(t=m(e,o.EF_ZIP64_SUNCOMP),r.size===o.EF_ZIP64_OR_32&&(r.size=t)),e.length>=o.EF_ZIP64_RHO&&(n=m(e,o.EF_ZIP64_SCOMP),r.compressedSize===o.EF_ZIP64_OR_32&&(r.compressedSize=n)),e.length>=o.EF_ZIP64_DSN&&(i=m(e,o.EF_ZIP64_RHO),r.offset===o.EF_ZIP64_OR_32&&(r.offset=i)),e.length>=o.EF_ZIP64_DSN+4&&(a=e.readUInt32LE(o.EF_ZIP64_DSN),r.diskNumStart===o.EF_ZIP64_OR_16&&(r.diskNumStart=a))}return{get entryName(){return s.toString()},get rawEntryName(){return s},set entryName(e){var t=(s=n.toBuffer(e))[s.length-1];c=47===t||92===t,r.fileNameLength=s.length},get extra(){return f},set extra(e){f=e,r.extraLength=e.length,function(e){for(var t,r,n,i=0;i\n\t"data" : <'+(l&&l.length+" bytes buffer"||"null")+">\n}"}}}}).call(this,r(10).Buffer)},function(e,t,r){t.EntryHeader=r(415),t.MainHeader=r(416)},function(e,t,r){"use strict";e.exports=function(e,t,r,n){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16|0}},function(e,t,r){"use strict";var n=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();e.exports=function(e,t,r,i){var o=n,a=i+r;e^=-1;for(var s=i;s>>8^o[255&(e^t[s])];return-1^e}},function(e,t){var r={utf8:{stringToBytes:function(e){return r.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(r.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);rclass extends e{get token(){return this.mixpanel.token}get config(){return this.mixpanel.config}_set(e,t,r,n,{identifiers:i,set_once:o=!1}){let s={};"object"==typeof e?("object"==typeof t?(n=r,r=t):n=t,s=e):(s[e]=t,"function"!=typeof r&&r||(n=r));let u=a({$token:this.token},i);u[o?"$set_once":"$set"]=s,"ip"in s&&(u.$ip=s.ip,delete s.ip),s.$ignore_time&&(u.$ignore_time=s.$ignore_time,delete s.$ignore_time),u=c(u,r),this.config.debug&&(console.log(`Sending the following data to Mixpanel (${this.endpoint}):`),console.log(u)),this.mixpanel.send_request({method:"GET",endpoint:this.endpoint,data:u},n)}_delete_profile({identifiers:e,modifiers:t,callback:r}){let n=a({$delete:"",$token:this.token},e);"function"==typeof t&&(r=t),n=c(n,t),this.config.debug&&console.log("Deleting profile "+JSON.stringify(e)),this.mixpanel.send_request({method:"GET",endpoint:this.endpoint,data:n},r)}_remove({identifiers:e,data:t,modifiers:r,callback:i}){let o={};if("object"!=typeof t||Array.isArray(t))this.config.debug&&console.error("Invalid value passed to #remove - data must be an object with scalar values");else{for(const e of Object.entries(t)){var s=n(e,2);const t=s[0],r=s[1];if("string"!=typeof r&&"number"!=typeof r)return void(this.config.debug&&(console.error("Invalid argument passed to #remove - values must be scalar"),console.error("Passed "+t+":",r)));o[t]=r}0!==Object.keys(o).length&&("function"==typeof r&&(i=r),t=c(t=a({$remove:o,$token:this.token},e),r),this.config.debug&&(console.log(`Sending the following data to Mixpanel (${this.endpoint}):`),console.log(t)),this.mixpanel.send_request({method:"GET",endpoint:this.endpoint,data:t},i))}}_union({identifiers:e,data:t,modifiers:r,callback:i}){let o={};if("object"!=typeof t||Array.isArray(t))this.config.debug&&console.error("Invalid value passed to #union - data must be an object with scalar or array values");else{for(const e of Object.entries(t)){var s=n(e,2);const t=s[0],r=s[1];if(Array.isArray(r)){var u=r.filter((function(e){return"string"==typeof e||"number"==typeof e}));u.length>0&&(o[t]=u)}else"string"==typeof r||"number"==typeof r?o[t]=[r]:this.config.debug&&(console.error("Invalid argument passed to #union - values must be a scalar value or array"),console.error("Passed "+t+":",r))}0!==Object.keys(o).length&&("function"==typeof r&&(i=r),t=c(t=a({$union:o,$token:this.token},e),r),this.config.debug&&(console.log(`Sending the following data to Mixpanel (${this.endpoint}):`),console.log(t)),this.mixpanel.send_request({method:"GET",endpoint:this.endpoint,data:t},i))}}_unset({identifiers:e,prop:t,modifiers:r,callback:n}){let i=[];if(Array.isArray(t))i=t;else{if("string"!=typeof t)return void(this.config.debug&&(console.error("Invalid argument passed to #unset - must be a string or array"),console.error("Passed: "+t)));i=[t]}let o=a({$unset:i,$token:this.token},e);"function"==typeof r&&(n=r),o=c(o,r),this.config.debug&&(console.log(`Sending the following data to Mixpanel (${this.endpoint}):`),console.log(o)),this.mixpanel.send_request({method:"GET",endpoint:this.endpoint,data:o},n)}}},function(e,t,r){"use strict";var n=Object.prototype.toString;e.exports=function(e){var t=n.call(e),r="[object Arguments]"===t;return r||(r="[object Array]"!==t&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===n.call(e.callee)),r}},function(e,t,r){"use strict";var n=r(72)(),i=r(54)("Object.prototype.toString"),o=function(e){return!(n&&e&&"object"==typeof e&&Symbol.toStringTag in e)&&"[object Arguments]"===i(e)},a=function(e){return!!o(e)||null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Array]"!==i(e)&&"[object Function]"===i(e.callee)},s=function(){return o(arguments)}();o.isLegacyArguments=a,e.exports=s?o:a},function(e,t,r){"use strict";var n=function(e){return e!=e};e.exports=function(e,t){return 0===e&&0===t?1/e==1/t:e===t||!(!n(e)||!n(t))}},function(e,t,r){"use strict";var n=r(255);e.exports=function(){return"function"==typeof Object.is?Object.is:n}},function(e,t,r){"use strict";var n=Object,i=TypeError;e.exports=function(){if(null!=this&&this!==n(this))throw new i("RegExp.prototype.flags getter called on non-object");var e="";return this.hasIndices&&(e+="d"),this.global&&(e+="g"),this.ignoreCase&&(e+="i"),this.multiline&&(e+="m"),this.dotAll&&(e+="s"),this.unicode&&(e+="u"),this.sticky&&(e+="y"),e}},function(e,t,r){"use strict";var n=r(257),i=r(81).supportsDescriptors,o=Object.getOwnPropertyDescriptor;e.exports=function(){if(i&&"gim"===/a/gim.flags){var e=o(RegExp.prototype,"flags");if(e&&"function"==typeof e.get&&"boolean"==typeof/a/.dotAll)return e.get}return n}},function(e,t,r){"use strict";var n=String.prototype.valueOf,i=Object.prototype.toString,o=r(72)();e.exports=function(e){return"string"==typeof e||"object"==typeof e&&(o?function(e){try{return n.call(e),!0}catch(e){return!1}}(e):"[object String]"===i.call(e))}},function(e,t,r){"use strict";var n,i="function"==typeof Map&&Map.prototype?Map:null,o="function"==typeof Set&&Set.prototype?Set:null;i||(n=function(e){return!1});var a=i?Map.prototype.has:null,s=o?Set.prototype.has:null;n||a||(n=function(e){return!1}),e.exports=n||function(e){if(!e||"object"!=typeof e)return!1;try{if(a.call(e),s)try{s.call(e)}catch(e){return!0}return e instanceof i}catch(e){}return!1}},function(e,t,r){"use strict";var n,i="function"==typeof Map&&Map.prototype?Map:null,o="function"==typeof Set&&Set.prototype?Set:null;o||(n=function(e){return!1});var a=i?Map.prototype.has:null,s=o?Set.prototype.has:null;n||s||(n=function(e){return!1}),e.exports=n||function(e){if(!e||"object"!=typeof e)return!1;try{if(s.call(e),a)try{a.call(e)}catch(e){return!0}return e instanceof o}catch(e){}return!1}},function(e,t){var r=Object.prototype.hasOwnProperty,n=Object.prototype.toString;e.exports=function(e,t,i){if("[object Function]"!==n.call(t))throw new TypeError("iterator must be a function");var o=e.length;if(o===+o)for(var a=0;a0)return e}catch(e){}return r(83)}}).call(this,r(19))},function(e,t){e.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}},function(e,t,r){(function(t){var n=r(106),i=r(270),o=n.Constants,a=r(477);e.exports=function(e){var r=new i.EntryHeader,s=t.alloc(0),u=t.alloc(0),c=!1,l=null,f=t.alloc(0);function d(){return e&&t.isBuffer(e)?(r.loadDataHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize)):t.alloc(0)}function h(e){return 8==(8&r.flags)||n.crc32(e)===r.dataHeader.crc}function p(e,i,o){if(void 0===i&&"string"==typeof e&&(o=e,e=void 0),c)return e&&i&&i(t.alloc(0),n.Errors.DIRECTORY_CONTENT_ERROR),t.alloc(0);var u=d();if(0===u.length)return e&&i&&i(u),u;if(r.encripted){if("string"!=typeof o&&!t.isBuffer(o))throw new Error("ADM-ZIP: Incompatible password parameter");u=a.ZipCrypto.decrypt(u,r,o)}var l=t.alloc(r.size);switch(r.method){case n.Constants.STORED:if(u.copy(l),h(l))return e&&i&&i(l),l;throw e&&i&&i(l,n.Errors.BAD_CRC),new Error(n.Errors.BAD_CRC);case n.Constants.DEFLATED:var f=new a.Inflater(u);if(!e){if(f.inflate(l).copy(l,0),!h(l))throw new Error(n.Errors.BAD_CRC+" "+s.toString());return l}f.inflateAsync((function(e){e.copy(e,0),i&&(h(e)?i(e):i(e,n.Errors.BAD_CRC))}));break;default:throw e&&i&&i(t.alloc(0),n.Errors.UNKNOWN_METHOD),new Error(n.Errors.UNKNOWN_METHOD)}}function g(i,o){if((!l||!l.length)&&t.isBuffer(e))return i&&o&&o(d()),d();if(l.length&&!c){var s;switch(r.method){case n.Constants.STORED:return r.compressedSize=r.size,s=t.alloc(l.length),l.copy(s),i&&o&&o(s),s;default:case n.Constants.DEFLATED:var u=new a.Deflater(l);if(!i){var f=u.deflate();return r.compressedSize=f.length,f}u.deflateAsync((function(e){s=t.alloc(e.length),r.compressedSize=e.length,e.copy(s),o&&o(s)})),u=null}}else{if(!i||!o)return t.alloc(0);o(t.alloc(0))}}function m(e,t){return(e.readUInt32LE(t+4)<<4)+e.readUInt32LE(t)}function y(e){var t,n,i,a;e.length>=o.EF_ZIP64_SCOMP&&(t=m(e,o.EF_ZIP64_SUNCOMP),r.size===o.EF_ZIP64_OR_32&&(r.size=t)),e.length>=o.EF_ZIP64_RHO&&(n=m(e,o.EF_ZIP64_SCOMP),r.compressedSize===o.EF_ZIP64_OR_32&&(r.compressedSize=n)),e.length>=o.EF_ZIP64_DSN&&(i=m(e,o.EF_ZIP64_RHO),r.offset===o.EF_ZIP64_OR_32&&(r.offset=i)),e.length>=o.EF_ZIP64_DSN+4&&(a=e.readUInt32LE(o.EF_ZIP64_DSN),r.diskNumStart===o.EF_ZIP64_OR_16&&(r.diskNumStart=a))}return{get entryName(){return s.toString()},get rawEntryName(){return s},set entryName(e){var t=(s=n.toBuffer(e))[s.length-1];c=47===t||92===t,r.fileNameLength=s.length},get extra(){return f},set extra(e){f=e,r.extraLength=e.length,function(e){for(var t,r,n,i=0;i"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:t(e),data:t(l)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}}).call(this,r(10).Buffer)},function(e,t,r){t.EntryHeader=r(475),t.MainHeader=r(476)},function(e,t,r){const n=r(482),i=r(169);function o(e,t){return i.send(e,t)}e.exports={runImport:async function(e,t){await o("api/start-import",{budgetName:e});try{await t()}catch(e){throw await o("api/abort-import"),e}await o("api/finish-import")},runQuery:function(e){return o("api/query",{query:e.serialize()})},q:n,loadBudget:async function(e){return o("api/load-budget",{id:e})},batchBudgetUpdates:async function(e){await o("api/batch-budget-start");try{await e()}finally{await o("api/batch-budget-end")}},getBudgetMonths:function(){return o("api/budget-months")},getBudgetMonth:function(e){return o("api/budget-month",{month:e})},setBudgetAmount:function(e,t,r){return o("api/budget-set-amount",{month:e,categoryId:t,amount:r})},setBudgetCarryover:function(e,t,r){return o("api/budget-set-carryover",{month:e,categoryId:t,flag:r})},addTransactions:function(e,t){return o("api/transactions-add",{accountId:e,transactions:t})},importTransactions:function(e,t){return o("api/transactions-import",{accountId:e,transactions:t})},filterTransactions:function(e,t){return o("api/transactions-filter",{accountId:e,text:t})},getTransactions:function(e,t,r){return o("api/transactions-get",{accountId:e,startDate:t,endDate:r})},updateTransaction:function(e,t){return o("api/transaction-update",{id:e,fields:t})},deleteTransaction:function(e){return o("api/transaction-delete",{id:e})},getAccounts:function(){return o("api/accounts-get")},createAccount:function(e,t){return o("api/account-create",{account:e,initialBalance:t})},updateAccount:function(e,t){return o("api/account-update",{id:e,fields:t})},closeAccount:function(e,t,r){return o("api/account-close",{id:e,transferAccountId:t,transferCategoryId:r})},reopenAccount:function(e){return o("api/account-reopen",{id:e})},deleteAccount:function(e){return o("api/account-delete",{id:e})},getCategories:function(){return o("api/categories-get",{grouped:!1})},createCategoryGroup:function(e){return o("api/category-group-create",{group:e})},updateCategoryGroup:function(e,t){return o("api/category-group-update",{id:e,fields:t})},deleteCategoryGroup:function(e,t){return o("api/category-group-delete",{id:e,transferCategoryId:t})},createCategory:function(e){return o("api/category-create",{category:e})},updateCategory:function(e,t){return o("api/category-update",{id:e,fields:t})},deleteCategory:function(e,t){return o("api/category-delete",{id:e,transferCategoryId:t})},getPayees:function(){return o("api/payees-get")},createPayee:function(e){return o("api/payee-create",{payee:e})},updatePayee:function(e,t){return o("api/payee-update",{id:e,fields:t})},deletePayee:function(e){return o("api/payee-delete",{id:e})},getPayeeRules:function(e){return o("api/payee-rules-get",{payeeId:e})},createPayeeRule:function(e,t){return o("api/payee-rule-create",{payee_id:e,rule:t})},deletePayeeRule:function(e){return o("api/payee-rule-delete",{id:e})},updatePayeeRule:function(e,t){return o("api/payee-rule-update",{id:e,fields:t})}}},function(e,t,r){(function(e,t,n,i){var o=void 0,a=function(a){return o||(o=new Promise((function(o,s){var u,c=(u=void 0!==a?a:{}).onAbort;u.onAbort=function(e){s(new Error(e)),c&&c(e)},u.postRun=u.postRun||[],u.postRun.push((function(){o(u)})),e=void 0,u||(u=void 0!==u?u:{}),u.onRuntimeInitialized=function(){function e(e,t){this.Qa=e,this.db=t,this.Pa=1,this.wb=[]}function t(e,t){if(this.db=t,t=$(e)+1,this.hb=qe(t),null===this.hb)throw Error("Unable to allocate memory for the SQL string");Y(e,U,this.hb,t),this.sb=this.hb,this.eb=this.Mb=null}function r(e,{filename:t=!1}={}){!1===t?(this.filename="dbfile_"+(4294967295*Math.random()>>>0),this.Xc=!0,null!=e&&je.zb("/",this.filename,e,!0,!0)):this.filename=e,this.handleError(o(this.filename,n)),this.db=j(n,"i32"),ee(this.db),this.nb={},this.Xa={}}var n=Je(4),i=u.cwrap,o=i("sqlite3_open","number",["string","number"]),a=i("sqlite3_close_v2","number",["number"]),s=i("sqlite3_exec","number",["number","string","number","number","number"]),c=i("sqlite3_changes","number",["number"]),l=i("sqlite3_prepare_v2","number",["number","string","number","number","number"]),f=i("sqlite3_sql","string",["number"]),d=i("sqlite3_normalized_sql","string",["number"]),h=i("sqlite3_prepare_v2","number",["number","number","number","number","number"]),p=i("sqlite3_bind_text","number",["number","number","number","number","number"]),g=i("sqlite3_bind_blob","number",["number","number","number","number","number"]),m=i("sqlite3_bind_double","number",["number","number","number"]),y=i("sqlite3_bind_int","number",["number","number","number"]),b=i("sqlite3_bind_parameter_index","number",["number","string"]),_=i("sqlite3_step","number",["number"]),w=i("sqlite3_errmsg","string",["number"]),v=i("sqlite3_column_count","number",["number"]),E=i("sqlite3_data_count","number",["number"]),S=i("sqlite3_column_double","number",["number","number"]),O=i("sqlite3_column_text","string",["number","number"]),T=i("sqlite3_column_blob","number",["number","number"]),A=i("sqlite3_column_bytes","number",["number","number"]),R=i("sqlite3_column_type","number",["number","number"]),N=i("sqlite3_column_name","string",["number","number"]),k=i("sqlite3_reset","number",["number"]),C=i("sqlite3_clear_bindings","number",["number"]),L=i("sqlite3_finalize","number",["number"]),P=i("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),F=i("sqlite3_value_type","number",["number"]),W=i("sqlite3_value_bytes","number",["number"]),H=i("sqlite3_value_text","string",["number"]),z=i("sqlite3_value_blob","number",["number"]),q=i("sqlite3_value_double","number",["number"]),V=i("sqlite3_result_double","",["number","number"]),K=i("sqlite3_result_null","",["number"]),Z=i("sqlite3_result_text","",["number","string","number","number"]),X=i("sqlite3_result_blob","",["number","number","number","number"]),J=i("sqlite3_result_int","",["number","number"]),Q=i("sqlite3_result_error","",["number","string","number"]),ee=i("RegisterExtensionFunctions","number",["number"]);e.prototype.bind=function(e){if(!this.Qa)throw"Statement closed";return this.reset(),Array.isArray(e)?this.vc(e):null==e||"object"!=typeof e||this.wc(e)},e.prototype.step=function(){if(!this.Qa)throw"Statement closed";this.Pa=1;var e=_(this.Qa);switch(e){case 100:return!0;case 101:return!1;default:throw this.db.handleError(e)}},e.prototype.Pc=function(e){return null==e&&(e=this.Pa,this.Pa+=1),S(this.Qa,e)},e.prototype.Qc=function(e){return null==e&&(e=this.Pa,this.Pa+=1),O(this.Qa,e)},e.prototype.getBlob=function(e){null==e&&(e=this.Pa,this.Pa+=1);var t=A(this.Qa,e);e=T(this.Qa,e);for(var r=new Uint8Array(t),n=0;n{let t=D((function(t,r){return t=te.get(t),e.lock(t,r)?0:5}),"iii"),r=D((function(t,r){return t=te.get(t),e.unlock(t,r),0}),"iii"),n=D((function(e,t){e=G(e),te.set(t,e)}),"vii");u._register_for_idb(t,r,n)},u.cleanup_file=e=>{let t=[...te.entries()].find(t=>t[1]===e);te.delete(t[0])},u.reset_filesystem=()=>{je.root=null,je.lc()}};var l,f={};for(l in u)u.hasOwnProperty(l)&&(f[l]=u[l]);var d,h,p,g,m,y="./this.program",b="object"==typeof window,_="function"==typeof importScripts,w="object"==typeof t&&"object"==typeof t.versions&&"string"==typeof t.versions.node,v="";w?(v=_?r(48).dirname(v)+"/":n+"/",d=function(e,t){return g||(g=r(83)),m||(m=r(48)),e=m.normalize(e),g.readFileSync(e,t?null:"utf8")},p=function(e){return(e=d(e,!0)).buffer||(e=new Uint8Array(e)),k(e.buffer),e},h=function(e,t,n){g||(g=r(83)),m||(m=r(48)),e=m.normalize(e),g.readFile(e,(function(e,r){e?n(e):t(r.buffer)}))},1>0]=0;break;case"i16":F[e>>1]=0;break;case"i32":W[e>>2]=0;break;case"i64":ie=[0,(ne=0,1<=+Math.abs(ne)?0>>0:~~+Math.ceil((ne-+(~~ne>>>0))/4294967296)>>>0:0)],W[e>>2]=ie[0],W[e+4>>2]=ie[1];break;case"float":H[e>>2]=0;break;case"double":z[e>>3]=0;break;default:fe("invalid type for setValue: "+t)}}function j(e,t){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return B[e>>0];case"i16":return F[e>>1];case"i32":case"i64":return W[e>>2];case"float":return H[e>>2];case"double":return z[e>>3];default:fe("invalid type for getValue: "+t)}return null}"object"!=typeof WebAssembly&&fe("no native wasm support detected");var R,N=!1;function k(e,t){e||fe("Assertion failed: "+t)}function C(e){var t=u["_"+e];return k(t,"Cannot call unknown function "+e+", make sure it is exported"),t}function L(e,t,r,n){var i,o={string:function(e){var t=0;if(null!=e&&0!==e){var r=1+(e.length<<2);t=Je(r),Y(e,U,t,r)}return t},array:function(e){var t=Je(e.length);return B.set(e,t),t}},a=C(e),s=[];if(e=0,n)for(var u=0;u=n);)++r;if(16(i=224==(240&i)?(15&i)<<12|o<<6|a:(7&i)<<18|o<<12|a<<6|63&e[t++])?n+=String.fromCharCode(i):(i-=65536,n+=String.fromCharCode(55296|i>>10,56320|1023&i))}}else n+=String.fromCharCode(i)}return n}function G(e,t){return e?V(U,e,t):""}function Y(e,t,r,n){if(!(0=a)a=65536+((1023&a)<<10)|1023&e.charCodeAt(++o);if(127>=a){if(r>=n)break;t[r++]=a}else{if(2047>=a){if(r+1>=n)break;t[r++]=192|a>>6}else{if(65535>=a){if(r+2>=n)break;t[r++]=224|a>>12}else{if(r+3>=n)break;t[r++]=240|a>>18,t[r++]=128|a>>12&63}t[r++]=128|a>>6&63}t[r++]=128|63&a}}return t[r]=0,r-i}function $(e){for(var t=0,r=0;r=n&&(n=65536+((1023&n)<<10)|1023&e.charCodeAt(++r)),127>=n?++t:t=2047>=n?t+2:65535>=n?t+3:t+4}return t}function K(e){var t=$(e)+1,r=qe(t);return r&&Y(e,B,r,t),r}function Z(){var e=R.buffer;P=e,u.HEAP8=B=new Int8Array(e),u.HEAP16=F=new Int16Array(e),u.HEAP32=W=new Int32Array(e),u.HEAPU8=U=new Uint8Array(e),u.HEAPU16=new Uint16Array(e),u.HEAPU32=new Uint32Array(e),u.HEAPF32=H=new Float32Array(e),u.HEAPF64=z=new Float64Array(e)}var X,J=[],Q=[],ee=[];function te(){var e=u.preRun.shift();J.unshift(e)}var re,ne,ie,oe,ae=0,se=null,ue=null;function ce(){ae++,u.monitorRunDependencies&&u.monitorRunDependencies(ae)}function le(){if(ae--,u.monitorRunDependencies&&u.monitorRunDependencies(ae),0==ae&&(null!==se&&(clearInterval(se),se=null),ue)){var e=ue;ue=null,e()}}function fe(e){throw u.onAbort&&u.onAbort(e),S(e),N=!0,new WebAssembly.RuntimeError("abort("+e+"). Build with -s ASSERTIONS=1 for more info.")}function de(){return re.startsWith("data:application/octet-stream;base64,")}if(u.preloadedImages={},u.preloadedAudios={},re="sql-wasm.wasm",!de()){var he=re;re=u.locateFile?u.locateFile(he,v):v+he}function pe(){var e=re;try{if(e==re&&T)return new Uint8Array(T);if(p)return p(e);throw"both async and sync fetching of the wasm failed"}catch(e){fe(e)}}function ge(e){for(;0r?[]:e.slice(t,r-t+1)}e=ve(e).substr(1),t=ve(t).substr(1),e=r(e.split("/")),t=r(t.split("/"));for(var n=Math.min(e.length,t.length),i=n,o=0;o=t||(t=Math.max(t,r*(1048576>r?2:1.125)>>>0),0!=r&&(t=Math.max(t,256)),r=e.Na,e.Na=new Uint8Array(t),0=e.node.Ra)return 0;if(8<(e=Math.min(e.node.Ra-i,n))&&o.subarray)t.set(o.subarray(i,i+e),r);else for(n=0;nt)throw new je.ErrnoError(28);return t},allocate:function(e,t,r){Ie.Zb(e.node,t+r),e.node.Ra=Math.max(e.node.Ra,t+r)},mmap:function(e,t,r,n,i,o){if(0!==t)throw new je.ErrnoError(28);if(!je.isFile(e.node.mode))throw new je.ErrnoError(43);if(e=e.node.Na,2&o||e.buffer!==P){if((0>>0)%je.Ua.length},ec:function(e){var t=je.Gb(e.parent.id,e.name);e.cb=je.Ua[t],je.Ua[t]=e},fc:function(e){var t=je.Gb(e.parent.id,e.name);if(je.Ua[t]===e)je.Ua[t]=e.cb;else for(t=je.Ua[t];t;){if(t.cb===e){t.cb=e.cb;break}t=t.cb}},lookupNode:function(e,t){var r=je.Vc(e);if(r)throw new je.ErrnoError(r,e);for(r=je.Ua[je.Gb(e.id,t)];r;r=r.cb){var n=r.name;if(r.parent.id===e.id&&n===t)return r}return je.lookup(e,t)},createNode:function(e,t,r,n){return e=new je.FSNode(e,t,r,n),je.ec(e),e},Ab:function(e){je.fc(e)},isRoot:function(e){return e===e.parent},ab:function(e){return!!e.lb},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},fb:function(e){return 40960==(61440&e)},pb:function(e){return 8192==(61440&e)},Rc:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return 49152==(49152&e)},Mc:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Yc:function(e){var t=je.Mc[e];if(void 0===t)throw Error("Unknown file open mode: "+e);return t},$b:function(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},Za:function(e,t){return je.hc?0:!t.includes("r")||292&e.mode?t.includes("w")&&!(146&e.mode)||t.includes("x")&&!(73&e.mode)?2:0:2},Vc:function(e){var t=je.Za(e,"x");return t||(e.node_ops.lookup?0:2)},Lb:function(e,t){try{return je.lookupNode(e,t),20}catch(e){}return je.Za(e,"wx")},qb:function(e,t,r){try{var n=je.lookupNode(e,t)}catch(e){return e.Oa}if(e=je.Za(e,"wx"))return e;if(r){if(!je.isDir(n.mode))return 54;if(je.isRoot(n)||je.Ya(n)===je.cwd())return 10}else if(je.isDir(n.mode))return 31;return 0},Wc:function(e,t){return e?je.fb(e.mode)?32:je.isDir(e.mode)&&("r"!==je.$b(t)||512&t)?31:je.Za(e,je.$b(t)):44},oc:4096,$c:function(e,t){for(t=t||je.oc,e=e||0;e<=t;e++)if(!je.streams[e])return e;throw new je.ErrnoError(33)},$a:function(e){return je.streams[e]},Jc:function(e,t,r){je.ub||(je.ub=function(){},je.ub.prototype={object:{get:function(){return this.node},set:function(e){this.node=e}}});var n,i=new je.ub;for(n in e)i[n]=e[n];return e=i,t=je.$c(t,r),e.fd=t,je.streams[t]=e},Dc:function(e){je.streams[e]=null},Cc:{open:function(e){e.stream_ops=je.Oc(e.node.rdev).stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new je.ErrnoError(70)}},Kb:function(e){return e>>8},sd:function(e){return 255&e},bb:function(e,t){return e<<8|t},Qb:function(e,t){je.Xb[e]={stream_ops:t}},Oc:function(e){return je.Xb[e]},bc:function(e){var t=[];for(e=[e];e.length;){var r=e.pop();t.push(r),e.push.apply(e,r.mb)}return t},mc:function(e,t){function r(e){return je.tb--,t(e)}function n(e){if(e){if(!n.Kc)return n.Kc=!0,r(e)}else++o>=i.length&&r(null)}"function"==typeof e&&(t=e,e=!1),je.tb++,1t)throw new je.ErrnoError(28);if(!(e="string"==typeof e?je.lookupPath(e,{Ta:!0}).node:e).node_ops.setattr)throw new je.ErrnoError(63);if(je.isDir(e.mode))throw new je.ErrnoError(31);if(!je.isFile(e.mode))throw new je.ErrnoError(28);var r=je.Za(e,"w");if(r)throw new je.ErrnoError(r);e.node_ops.setattr(e,{size:t,timestamp:Date.now()})},Nc:function(e,t){if(!(e=je.$a(e)))throw new je.ErrnoError(8);if(0==(2097155&e.flags))throw new je.ErrnoError(28);je.truncate(e.node,t)},kd:function(e,t,r){(e=je.lookupPath(e,{Ta:!0}).node).node_ops.setattr(e,{timestamp:Math.max(t,r)})},open:function(e,t,r,n,i){if(""===e)throw new je.ErrnoError(44);if(r=64&(t="string"==typeof t?je.Yc(t):t)?4095&(void 0===r?438:r)|32768:0,"object"==typeof e)var o=e;else{e=ye(e);try{o=je.lookupPath(e,{Ta:!(131072&t)}).node}catch(e){}}var a=!1;if(64&t)if(o){if(128&t)throw new je.ErrnoError(20)}else o=je.mknod(e,r,0),a=!0;if(!o)throw new je.ErrnoError(44);if(je.pb(o.mode)&&(t&=-513),65536&t&&!je.isDir(o.mode))throw new je.ErrnoError(54);if(!a&&(r=je.Wc(o,t)))throw new je.ErrnoError(r);512&t&&je.truncate(o,0),t&=-131713,(n=je.Jc({node:o,path:je.Ya(o),flags:t,seekable:!0,position:0,stream_ops:o.stream_ops,jd:[],error:!1},n,i)).stream_ops.open&&n.stream_ops.open(n),!u.logReadFiles||1&t||(je.Ob||(je.Ob={}),e in je.Ob||(je.Ob[e]=1,S("FS.trackingDelegate error on read file: "+e)));try{je.Sa.onOpenFile&&(i=0,1!=(2097155&t)&&(i|=je.nc.kc.qc),0!=(2097155&t)&&(i|=je.nc.kc.rc),je.Sa.onOpenFile(e,i))}catch(t){S("FS.trackingDelegate['onOpenFile']('"+e+"', flags) threw an exception: "+t.message)}return n},close:function(e){if(je.kb(e))throw new je.ErrnoError(8);e.Fb&&(e.Fb=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{je.Dc(e.fd)}e.fd=null},kb:function(e){return null===e.fd},llseek:function(e,t,r){if(je.kb(e))throw new je.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new je.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new je.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.jd=[],e.position},read:function(e,t,r,n,i){if(0>n||0>i)throw new je.ErrnoError(28);if(je.kb(e))throw new je.ErrnoError(8);if(1==(2097155&e.flags))throw new je.ErrnoError(8);if(je.isDir(e.node.mode))throw new je.ErrnoError(31);if(!e.stream_ops.read)throw new je.ErrnoError(28);var o=void 0!==i;if(o){if(!e.seekable)throw new je.ErrnoError(70)}else i=e.position;return t=e.stream_ops.read(e,t,r,n,i),o||(e.position+=t),t},write:function(e,t,r,n,i,o){if(0>n||0>i)throw new je.ErrnoError(28);if(je.kb(e))throw new je.ErrnoError(8);if(0==(2097155&e.flags))throw new je.ErrnoError(8);if(je.isDir(e.node.mode))throw new je.ErrnoError(31);if(!e.stream_ops.write)throw new je.ErrnoError(28);e.seekable&&1024&e.flags&&je.llseek(e,0,2);var a=void 0!==i;if(a){if(!e.seekable)throw new je.ErrnoError(70)}else i=e.position;t=e.stream_ops.write(e,t,r,n,i,o),a||(e.position+=t);try{e.path&&je.Sa.onWriteToFile&&je.Sa.onWriteToFile(e.path)}catch(t){S("FS.trackingDelegate['onWriteToFile']('"+e.path+"') threw an exception: "+t.message)}return t},allocate:function(e,t,r){if(je.kb(e))throw new je.ErrnoError(8);if(0>t||0>=r)throw new je.ErrnoError(28);if(0==(2097155&e.flags))throw new je.ErrnoError(8);if(!je.isFile(e.node.mode)&&!je.isDir(e.node.mode))throw new je.ErrnoError(43);if(!e.stream_ops.allocate)throw new je.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:function(e,t,r,n,i,o){if(0!=(2&i)&&0==(2&o)&&2!=(2097155&e.flags))throw new je.ErrnoError(2);if(1==(2097155&e.flags))throw new je.ErrnoError(2);if(!e.stream_ops.mmap)throw new je.ErrnoError(43);return e.stream_ops.mmap(e,t,r,n,i,o)},msync:function(e,t,r,n,i){return e&&e.stream_ops.msync?e.stream_ops.msync(e,t,r,n,i):0},ud:function(){return 0},ic:function(e,t,r){if(!e.stream_ops.ic)throw new je.ErrnoError(59);return e.stream_ops.ic(e,t,r)},readFile:function(e,t){if((t=t||{}).flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw Error('Invalid encoding type "'+t.encoding+'"');var r,n=je.open(e,t.flags);e=je.stat(e).size;var i=new Uint8Array(e);return je.read(n,i,0,e,0),"utf8"===t.encoding?r=V(i,0):"binary"===t.encoding&&(r=i),je.close(n),r},writeFile:function(e,t,r){if((r=r||{}).flags=r.flags||577,e=je.open(e,r.flags,r.mode),"string"==typeof t){var n=new Uint8Array($(t)+1);t=Y(t,n,0,n.length),je.write(e,n,0,t,void 0,r.Bc)}else{if(!ArrayBuffer.isView(t))throw Error("Unsupported data type");je.write(e,t,0,t.byteLength,void 0,r.Bc)}je.close(e)},cwd:function(){return je.Wb},chdir:function(e){if(null===(e=je.lookupPath(e,{Ta:!0})).node)throw new je.ErrnoError(44);if(!je.isDir(e.node.mode))throw new je.ErrnoError(54);var t=je.Za(e.node,"x");if(t)throw new je.ErrnoError(t);je.Wb=e.path},Fc:function(){je.mkdir("/tmp"),je.mkdir("/home"),je.mkdir("/home/web_user")},Ec:function(){je.mkdir("/dev"),je.Qb(je.bb(1,3),{read:function(){return 0},write:function(e,t,r,n){return n}}),je.rb("/dev/null",je.bb(1,3)),Oe(je.bb(5,0),Ae),Oe(je.bb(6,0),Me),je.rb("/dev/tty",je.bb(5,0)),je.rb("/dev/tty1",je.bb(6,0));var e=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return function(){return crypto.getRandomValues(e),e[0]}}if(w)try{var t=r(190);return function(){return t.randomBytes(1)[0]}}catch(e){}return function(){fe("randomDevice")}}();je.Wa("/dev","random",e),je.Wa("/dev","urandom",e),je.mkdir("/dev/shm"),je.mkdir("/dev/shm/tmp")},Hc:function(){je.mkdir("/proc");var e=je.mkdir("/proc/self");je.mkdir("/proc/self/fd"),je.mount({mount:function(){var t=je.createNode(e,"fd",16895,73);return t.node_ops={lookup:function(e,t){var r=je.$a(+t);if(!r)throw new je.ErrnoError(8);return(e={parent:null,mount:{jc:"fake"},node_ops:{readlink:function(){return r.path}}}).parent=e}},t}},{},"/proc/self/fd")},Ic:function(){u.stdin?je.Wa("/dev","stdin",u.stdin):je.symlink("/dev/tty","/dev/stdin"),u.stdout?je.Wa("/dev","stdout",null,u.stdout):je.symlink("/dev/tty","/dev/stdout"),u.stderr?je.Wa("/dev","stderr",null,u.stderr):je.symlink("/dev/tty1","/dev/stderr"),je.open("/dev/stdin",0),je.open("/dev/stdout",1),je.open("/dev/stderr",1)},Yb:function(){je.ErrnoError||(je.ErrnoError=function(e,t){this.node=t,this.hd=function(e){this.Oa=e},this.hd(e),this.message="FS error"},je.ErrnoError.prototype=Error(),je.ErrnoError.prototype.constructor=je.ErrnoError,[44].forEach((function(e){je.Db[e]=new je.ErrnoError(e),je.Db[e].stack=""})))},lc:function(){je.Yb(),je.Ua=Array(4096),je.mount(Ie,{},"/"),je.Fc(),je.Ec(),je.Hc(),je.Lc={MEMFS:Ie}},jb:function(e,t,r){je.jb.Hb=!0,je.Yb(),u.stdin=e||u.stdin,u.stdout=t||u.stdout,u.stderr=r||u.stderr,je.Ic()},wd:function(){je.jb.Hb=!1;var e=u._fflush;for(e&&e(0),e=0;ethis.length-1||0>e)){var t=e%this.chunkSize;return this.dc(e/this.chunkSize|0)[t]}},o.prototype.pc=function(e){this.dc=e},o.prototype.Ub=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(200<=e.status&&300>e.status||304===e.status))throw Error("Couldn't load "+r+". Status: "+e.status);var t,n=Number(e.getResponseHeader("Content-length")),i=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t;e=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t;var o=1048576;i||(o=n);var a=this;a.pc((function(e){var t=e*o,i=(e+1)*o-1;if(i=Math.min(i,n-1),void 0===a.ob[e]){var s=a.ob;if(t>i)throw Error("invalid range ("+t+", "+i+") or no bytes requested!");if(i>n-1)throw Error("only "+n+" bytes available! programmer error!");var u=new XMLHttpRequest;if(u.open("GET",r,!1),n!==o&&u.setRequestHeader("Range","bytes="+t+"-"+i),"undefined"!=typeof Uint8Array&&(u.responseType="arraybuffer"),u.overrideMimeType&&u.overrideMimeType("text/plain; charset=x-user-defined"),u.send(null),!(200<=u.status&&300>u.status||304===u.status))throw Error("Couldn't load "+r+". Status: "+u.status);t=void 0!==u.response?new Uint8Array(u.response||[]):We(u.responseText||"",!0),s[e]=t}if(void 0===a.ob[e])throw Error("doXHR failed!");return a.ob[e]})),!e&&n||(o=n=1,o=n=this.dc(0).length,E("LazyFiles on gzip forces download of the whole file when length is accessed")),this.tc=n,this.sc=o,this.Jb=!0},"undefined"!=typeof XMLHttpRequest){if(!_)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var a=new o;Object.defineProperties(a,{length:{get:function(){return this.Jb||this.Ub(),this.tc}},chunkSize:{get:function(){return this.Jb||this.Ub(),this.sc}}}),a={Ib:!1,Na:a}}else a={Ib:!1,url:r};var s=je.Gc(e,t,a,n,i);a.Na?s.Na=a.Na:a.url&&(s.Na=null,s.url=a.url),Object.defineProperties(s,{Ra:{get:function(){return this.Na.length}}});var u={};return Object.keys(s.stream_ops).forEach((function(e){var t=s.stream_ops[e];u[e]=function(){return je.ac(s),t.apply(null,arguments)}})),u.read=function(e,t,r,n,i){if(je.ac(s),i>=(e=e.node.Na).length)return 0;if(n=Math.min(e.length-i,n),e.slice)for(var o=0;o>2]=n.dev,W[r+4>>2]=0,W[r+8>>2]=n.ino,W[r+12>>2]=n.mode,W[r+16>>2]=n.nlink,W[r+20>>2]=n.uid,W[r+24>>2]=n.gid,W[r+28>>2]=n.rdev,W[r+32>>2]=0,ie=[n.size>>>0,(ne=n.size,1<=+Math.abs(ne)?0>>0:~~+Math.ceil((ne-+(~~ne>>>0))/4294967296)>>>0:0)],W[r+40>>2]=ie[0],W[r+44>>2]=ie[1],W[r+48>>2]=4096,W[r+52>>2]=n.blocks,W[r+56>>2]=n.atime.getTime()/1e3|0,W[r+60>>2]=0,W[r+64>>2]=n.mtime.getTime()/1e3|0,W[r+68>>2]=0,W[r+72>>2]=n.ctime.getTime()/1e3|0,W[r+76>>2]=0,ie=[n.ino>>>0,(ne=n.ino,1<=+Math.abs(ne)?0>>0:~~+Math.ceil((ne-+(~~ne>>>0))/4294967296)>>>0:0)],W[r+80>>2]=ie[0],W[r+84>>2]=ie[1],0}var ke,Ce=void 0;function Le(){return W[(Ce+=4)-4>>2]}function xe(e){if(!(e=je.$a(e)))throw new je.ErrnoError(8);return e}ke=w?function(){var e=t.hrtime();return 1e3*e[0]+e[1]/1e6}:function(){return performance.now()};var Pe,Be={};function Ue(){if(!Pe){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:y||"./this.program"};for(e in Be)void 0===Be[e]?delete t[e]:t[e]=Be[e];var r=[];for(e in t)r.push(e+"="+t[e]);Pe=r}return Pe}function Fe(e,t,r,n){e||(e=this),this.parent=e,this.mount=e.mount,this.lb=null,this.id=je.Zc++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n}function We(e,t){var r=Array($(e)+1);return e=Y(e,r,0,r.length),t&&(r.length=e),r}Object.defineProperties(Fe.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},Sc:{get:function(){return je.isDir(this.mode)}},Ib:{get:function(){return je.pb(this.mode)}}}),je.FSNode=Fe,je.lc();var He={a:function(e,t,r,n){fe("Assertion failed: "+G(e)+", at: "+[t?G(t):"unknown filename",r,n?G(n):"unknown function"])},u:function(e,t){!function(){function e(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}if(!oe){oe=!0;var t=(new Date).getFullYear(),r=new Date(t,0,1),n=new Date(t,6,1);t=r.getTimezoneOffset();var i=n.getTimezoneOffset(),o=Math.max(t,i);W[Ke()>>2]=60*o,W[$e()>>2]=Number(t!=i),r=e(r),n=e(n),r=K(r),n=K(n),i>2]=r,W[Ye()+4>>2]=n):(W[Ye()>>2]=n,W[Ye()+4>>2]=r)}}(),e=new Date(1e3*W[e>>2]),W[t>>2]=e.getSeconds(),W[t+4>>2]=e.getMinutes(),W[t+8>>2]=e.getHours(),W[t+12>>2]=e.getDate(),W[t+16>>2]=e.getMonth(),W[t+20>>2]=e.getFullYear()-1900,W[t+24>>2]=e.getDay();var r=new Date(e.getFullYear(),0,1);W[t+28>>2]=(e.getTime()-r.getTime())/864e5|0,W[t+36>>2]=-60*e.getTimezoneOffset();var n=new Date(e.getFullYear(),6,1).getTimezoneOffset();return e=0|(n!=(r=r.getTimezoneOffset())&&e.getTimezoneOffset()==Math.min(r,n)),W[t+32>>2]=e,e=W[Ye()+(e?4:0)>>2],W[t+40>>2]=e,t},m:function(e,t){try{var r;if(e=G(e),-8&t)var n=-28;else(r=je.lookupPath(e,{Ta:!0}).node)?(e="",4&t&&(e+="r"),2&t&&(e+="w"),1&t&&(e+="x"),n=e&&je.Za(r,e)?-2:0):n=-44;return n}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},A:function(e,t){try{return e=G(e),je.chmod(e,t),0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},H:function(e,t,r){try{return e=G(e),je.chown(e,t,r),0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},B:function(e,t){try{return je.fchmod(e,t),0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},I:function(e,t,r){try{return je.fchown(e,t,r),0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},b:function(e,t,r){Ce=r;try{var n=xe(e);switch(t){case 0:var i=Le();return 0>i?-28:je.open(n.path,n.flags,0,i).fd;case 1:case 2:return 0;case 3:return n.flags;case 4:return i=Le(),n.flags|=i,0;case 12:return i=Le(),F[i+0>>1]=2,0;case 13:case 14:return 0;case 16:case 8:return-28;case 9:return W[ze()>>2]=28,-1;default:return-28}}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},E:function(e,t){try{var r=xe(e);return Ne(je.stat,r.path,t)}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},n:function(e,t,r){try{return je.Nc(e,r),0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},l:function(e,t){try{if(0===t)return-28;var r=je.cwd();return t<$(r)+1?-68:(Y(r,U,e,t),e)}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},G:function(){return 0},d:function(){return 42},z:function(e,t){try{return e=G(e),Ne(je.lstat,e,t)}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},C:function(e,t){try{return"/"===(e=ye(e=G(e)))[e.length-1]&&(e=e.substr(0,e.length-1)),je.mkdir(e,t,0),0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},y:function(e,t,r,n,i,o){try{e:{o<<=12;var a=!1;if(0!=(16&n)&&0!=e%65536)var s=-28;else{if(0!=(32&n)){var u=De(t);if(!u){s=-48;break e}a=!0}else{var c=je.$a(i);if(!c){s=-8;break e}var l=je.mmap(c,e,t,o,r,n);u=l.ed,a=l.vb}Re[u]={Uc:u,Tc:t,vb:a,fd:i,dd:r,flags:n,offset:o},s=u}}return s}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},x:function(e,t){try{var r=Re[e];if(0!==t&&r){if(t===r.Tc){var n=je.$a(r.fd);if(n&&2&r.dd){var i=r.flags,o=r.offset,a=U.slice(e,e+t);je.msync(n,a,o,t,i)}Re[e]=null,r.vb&&Ve(r.Uc)}var s=0}else s=-28;return s}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},w:function(e,t,r){Ce=r;try{var n=G(e),i=r?Le():0;return je.open(n,t,i).fd}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},J:function(e,t,r){try{if(e=G(e),0>=r)var n=-28;else{var i=je.readlink(e),o=Math.min(r,$(i)),a=B[t+o];Y(i,U,t,r+1),B[t+o]=a,n=o}return n}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},F:function(e){try{return e=G(e),je.rmdir(e),0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},e:function(e,t){try{return e=G(e),Ne(je.stat,e,t)}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},i:function(e){try{return e=G(e),je.unlink(e),0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),-e.Oa}},v:function(){return 2147483648},p:function(e,t,r){U.copyWithin(e,t,t+r)},c:function(e){var t=U.length;if(2147483648<(e>>>=0))return!1;for(var r=1;4>=r;r*=2){var n=t*(1+.2/r);n=Math.min(n,e+100663296),0<(n=Math.max(e,n))%65536&&(n+=65536-n%65536);e:{try{R.grow(Math.min(2147483648,n)-P.byteLength+65535>>>16),Z();var i=1;break e}catch(e){}i=void 0}if(i)return!0}return!1},t:function(e){for(var t=ke();ke()-t>2]=o,o=0;o>0]=n.charCodeAt(o);B[i>>0]=0,r+=n.length+1})),0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),e.Oa}},s:function(e,t){try{var r=Ue();W[e>>2]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),W[t>>2]=n,0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),e.Oa}},f:function(e){try{var t=xe(e);return je.close(t),0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),e.Oa}},q:function(e,t){try{var r=xe(e),n=r.tty?2:je.isDir(r.mode)?3:je.fb(r.mode)?7:4;return B[t>>0]=n,0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),e.Oa}},j:function(e,t,r,n){try{e:{for(var i=xe(e),o=e=0;o>2],s=je.read(i,B,W[t+8*o>>2],a,void 0);if(0>s){var u=-1;break e}if(e+=s,s>2]=u,0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),e.Oa}},o:function(e,t,r,n,i){try{var o=xe(e);return-9007199254740992>=(e=4294967296*r+(t>>>0))||9007199254740992<=e?-61:(je.llseek(o,e,n),ie=[o.position>>>0,(ne=o.position,1<=+Math.abs(ne)?0>>0:~~+Math.ceil((ne-+(~~ne>>>0))/4294967296)>>>0:0)],W[i>>2]=ie[0],W[i+4>>2]=ie[1],o.Fb&&0===e&&0===n&&(o.Fb=null),0)}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),e.Oa}},k:function(e){try{var t=xe(e);return t.stream_ops&&t.stream_ops.fsync?-t.stream_ops.fsync(t):0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),e.Oa}},g:function(e,t,r,n){try{e:{for(var i=xe(e),o=e=0;o>2],W[t+(8*o+4)>>2],void 0);if(0>a){var s=-1;break e}e+=a}s=e}return W[n>>2]=s,0}catch(e){return void 0!==je&&e instanceof je.ErrnoError||fe(e),e.Oa}},h:function(e){var t=Date.now();return W[e>>2]=t/1e3|0,W[e+4>>2]=t%1e3*1e3|0,0},K:function(e){var t=Date.now()/1e3|0;return e&&(W[e>>2]=t),t},D:function(e,t){if(t){var r=t+8;t=1e3*W[r>>2],t+=W[r+4>>2]/1e3}else t=Date.now();e=G(e);try{je.kd(e,t,t);var n=0}catch(e){if(!(e instanceof je.ErrnoError)){e:{if(!(n=Error()).stack){try{throw Error()}catch(e){n=e}if(!n.stack){n="(no stack trace available)";break e}}n=n.stack.toString()}throw u.extraStackTrace&&(n+="\n"+u.extraStackTrace()),e+" : "+(n=function(e){return e.replace(/\b_Z[\w\d_]+/g,(function(e){return e==e?e:e+" ["+e+"]"}))}(n))}n=e.Oa,W[ze()>>2]=n,n=-1}return n}};!function(){function e(e){u.asm=e.exports,R=u.asm.L,Z(),X=u.asm.Da,Q.unshift(u.asm.M),le()}function t(t){e(t.instance)}function r(e){return function(){if(!T&&(b||_)){if("function"==typeof fetch&&!re.startsWith("file://"))return fetch(re,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+re+"'";return e.arrayBuffer()})).catch((function(){return pe()}));if(h)return new Promise((function(e,t){h(re,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return pe()}))}().then((function(e){return WebAssembly.instantiate(e,n)})).then(e,(function(e){S("failed to asynchronously prepare wasm: "+e),fe(e)}))}var n={a:He};if(ce(),u.instantiateWasm)try{return u.instantiateWasm(n,e)}catch(e){return S("Module.instantiateWasm callback failed with error: "+e),!1}T||"function"!=typeof WebAssembly.instantiateStreaming||de()||re.startsWith("file://")||"function"!=typeof fetch?r(t):fetch(re,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,n).then(t,(function(e){return S("wasm streaming compile failed: "+e),S("falling back to ArrayBuffer instantiation"),r(t)}))}))}(),u.___wasm_call_ctors=function(){return(u.___wasm_call_ctors=u.asm.M).apply(null,arguments)},u._sqlite3_vfs_find=function(){return(u._sqlite3_vfs_find=u.asm.N).apply(null,arguments)},u._sqlite3_free=function(){return(u._sqlite3_free=u.asm.O).apply(null,arguments)};var ze=u.___errno_location=function(){return(ze=u.___errno_location=u.asm.P).apply(null,arguments)};u._sqlite3_finalize=function(){return(u._sqlite3_finalize=u.asm.Q).apply(null,arguments)},u._sqlite3_reset=function(){return(u._sqlite3_reset=u.asm.R).apply(null,arguments)},u._sqlite3_clear_bindings=function(){return(u._sqlite3_clear_bindings=u.asm.S).apply(null,arguments)},u._sqlite3_value_blob=function(){return(u._sqlite3_value_blob=u.asm.T).apply(null,arguments)},u._sqlite3_value_text=function(){return(u._sqlite3_value_text=u.asm.U).apply(null,arguments)},u._sqlite3_value_bytes=function(){return(u._sqlite3_value_bytes=u.asm.V).apply(null,arguments)},u._sqlite3_value_double=function(){return(u._sqlite3_value_double=u.asm.W).apply(null,arguments)},u._sqlite3_value_int=function(){return(u._sqlite3_value_int=u.asm.X).apply(null,arguments)},u._sqlite3_value_type=function(){return(u._sqlite3_value_type=u.asm.Y).apply(null,arguments)},u._sqlite3_result_blob=function(){return(u._sqlite3_result_blob=u.asm.Z).apply(null,arguments)},u._sqlite3_result_double=function(){return(u._sqlite3_result_double=u.asm._).apply(null,arguments)},u._sqlite3_result_error=function(){return(u._sqlite3_result_error=u.asm.$).apply(null,arguments)},u._sqlite3_result_int=function(){return(u._sqlite3_result_int=u.asm.aa).apply(null,arguments)},u._sqlite3_result_int64=function(){return(u._sqlite3_result_int64=u.asm.ba).apply(null,arguments)},u._sqlite3_result_null=function(){return(u._sqlite3_result_null=u.asm.ca).apply(null,arguments)},u._sqlite3_result_text=function(){return(u._sqlite3_result_text=u.asm.da).apply(null,arguments)},u._sqlite3_step=function(){return(u._sqlite3_step=u.asm.ea).apply(null,arguments)},u._sqlite3_column_count=function(){return(u._sqlite3_column_count=u.asm.fa).apply(null,arguments)},u._sqlite3_data_count=function(){return(u._sqlite3_data_count=u.asm.ga).apply(null,arguments)},u._sqlite3_column_blob=function(){return(u._sqlite3_column_blob=u.asm.ha).apply(null,arguments)},u._sqlite3_column_bytes=function(){return(u._sqlite3_column_bytes=u.asm.ia).apply(null,arguments)},u._sqlite3_column_double=function(){return(u._sqlite3_column_double=u.asm.ja).apply(null,arguments)},u._sqlite3_column_text=function(){return(u._sqlite3_column_text=u.asm.ka).apply(null,arguments)},u._sqlite3_column_type=function(){return(u._sqlite3_column_type=u.asm.la).apply(null,arguments)},u._sqlite3_column_name=function(){return(u._sqlite3_column_name=u.asm.ma).apply(null,arguments)},u._sqlite3_bind_blob=function(){return(u._sqlite3_bind_blob=u.asm.na).apply(null,arguments)},u._sqlite3_bind_double=function(){return(u._sqlite3_bind_double=u.asm.oa).apply(null,arguments)},u._sqlite3_bind_int=function(){return(u._sqlite3_bind_int=u.asm.pa).apply(null,arguments)},u._sqlite3_bind_text=function(){return(u._sqlite3_bind_text=u.asm.qa).apply(null,arguments)},u._sqlite3_bind_parameter_index=function(){return(u._sqlite3_bind_parameter_index=u.asm.ra).apply(null,arguments)},u._sqlite3_sql=function(){return(u._sqlite3_sql=u.asm.sa).apply(null,arguments)},u._sqlite3_normalized_sql=function(){return(u._sqlite3_normalized_sql=u.asm.ta).apply(null,arguments)},u._sqlite3_errmsg=function(){return(u._sqlite3_errmsg=u.asm.ua).apply(null,arguments)},u._sqlite3_exec=function(){return(u._sqlite3_exec=u.asm.va).apply(null,arguments)},u._sqlite3_prepare_v2=function(){return(u._sqlite3_prepare_v2=u.asm.wa).apply(null,arguments)},u._sqlite3_changes=function(){return(u._sqlite3_changes=u.asm.xa).apply(null,arguments)},u._sqlite3_close_v2=function(){return(u._sqlite3_close_v2=u.asm.ya).apply(null,arguments)},u._sqlite3_create_function_v2=function(){return(u._sqlite3_create_function_v2=u.asm.za).apply(null,arguments)},u._sqlite3_open=function(){return(u._sqlite3_open=u.asm.Aa).apply(null,arguments)};var qe=u._malloc=function(){return(qe=u._malloc=u.asm.Ba).apply(null,arguments)},Ve=u._free=function(){return(Ve=u._free=u.asm.Ca).apply(null,arguments)};u._RegisterExtensionFunctions=function(){return(u._RegisterExtensionFunctions=u.asm.Ea).apply(null,arguments)},u._register_for_idb=function(){return(u._register_for_idb=u.asm.Fa).apply(null,arguments)};var Ge,Ye=u.__get_tzname=function(){return(Ye=u.__get_tzname=u.asm.Ga).apply(null,arguments)},$e=u.__get_daylight=function(){return($e=u.__get_daylight=u.asm.Ha).apply(null,arguments)},Ke=u.__get_timezone=function(){return(Ke=u.__get_timezone=u.asm.Ia).apply(null,arguments)},Ze=u.stackSave=function(){return(Ze=u.stackSave=u.asm.Ja).apply(null,arguments)},Xe=u.stackRestore=function(){return(Xe=u.stackRestore=u.asm.Ka).apply(null,arguments)},Je=u.stackAlloc=function(){return(Je=u.stackAlloc=u.asm.La).apply(null,arguments)},Qe=u._memalign=function(){return(Qe=u._memalign=u.asm.Ma).apply(null,arguments)};function et(){function e(){if(!Ge&&(Ge=!0,u.calledRun=!0,!N)){if(u.noFSInit||je.jb.Hb||je.jb(),je.hc=!1,ge(Q),u.onRuntimeInitialized&&u.onRuntimeInitialized(),u.postRun)for("function"==typeof u.postRun&&(u.postRun=[u.postRun]);u.postRun.length;){var e=u.postRun.shift();ee.unshift(e)}ge(ee)}}if(!(0>>16)*a&65535)<<16)&4294967295)<<15|u>>>17))*s+(((u>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(u=0,r){case 3:u^=(255&e.charCodeAt(c+2))<<16;case 2:u^=(255&e.charCodeAt(c+1))<<8;case 1:i^=u=(65535&(u=(u=(65535&(u^=255&e.charCodeAt(c)))*a+(((u>>>16)*a&65535)<<16)&4294967295)<<15|u>>>17))*s+(((u>>>16)*s&65535)<<16)&4294967295}return i^=e.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}var r=t;r.v2=function(e,t){for(var r,n=e.length,i=t^n,o=0;n>=4;)r=1540483477*(65535&(r=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++o;switch(n){case 3:i^=(255&e.charCodeAt(o+2))<<16;case 2:i^=(255&e.charCodeAt(o+1))<<8;case 1:i=1540483477*(65535&(i^=255&e.charCodeAt(o)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0},r.v3=t,e.exports=r}()},function(e,t,r){var n,i,o,a,s;n=r(430),i=r(248).utf8,o=r(431),a=r(248).bin,(s=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?a.stringToBytes(e):i.stringToBytes(e):o(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var r=n.bytesToWords(e),u=8*e.length,c=1732584193,l=-271733879,f=-1732584194,d=271733878,h=0;h>>24)|4278255360&(r[h]<<24|r[h]>>>8);r[u>>>5]|=128<>>9<<4)]=u;var p=s._ff,g=s._gg,m=s._hh,y=s._ii;for(h=0;h>>0,l=l+_>>>0,f=f+w>>>0,d=d+v>>>0}return n.endian([c,l,f,d])})._ff=function(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+(i>>>0)+a;return(s<>>32-o)+t},s._gg=function(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+(i>>>0)+a;return(s<>>32-o)+t},s._hh=function(e,t,r,n,i,o,a){var s=e+(t^r^n)+(i>>>0)+a;return(s<>>32-o)+t},s._ii=function(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+(i>>>0)+a;return(s<>>32-o)+t},s._blocksize=16,s._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var r=n.wordsToBytes(s(e,t));return t&&t.asBytes?r:t&&t.asString?a.bytesToString(r):n.bytesToHex(r)}},function(e,t,r){const n=r(432),i=r(433);let o="[0-9A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶ-ͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԣԱ-Ֆՙա-ևא-תװ-ײء-يٮ-ٯٱ-ۓەۥ-ۦۮ-ۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴ-ߵߺऄ-हऽॐक़-ॡॱ-ॲॻ-ॿঅ-ঌএ-ঐও-নপ-রলশ-হঽৎড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલ-ળવ-હઽૐૠ-ૡଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଵ-ହଽଡ଼-ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘ-ౙౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠ-ೡഅ-ഌഎ-ഐഒ-നപ-ഹഽൠ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะา-ำเ-ๆກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ະາ-ຳຽເ-ໄໆໜ-ໝༀཀ-ཇཉ-ཬྈ-ྋက-ဪဿၐ-ၕၚ-ၝၡၥ-ၦၮ-ၰၵ-ႁႎႠ-Ⴥა-ჺჼᄀ-ᅙᅟ-ᆢᆨ-ᇹሀ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙶᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦩᧁ-ᧇᨀ-ᨖᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮ-ᮯᰀ-ᰣᱍ-ᱏᱚ-ᱽᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₔℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-Ɐⱱ-ⱽⲀ-ⳤⴀ-ⴥⴰ-ⵥⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆷㇰ-ㇿ㐀䶵一鿃ꀀ-ꒌꔀ-ꘌꘐ-ꘟꘪ-ꘫꙀ-ꙟꙢ-ꙮꙿ-ꚗꜗ-ꜟꜢ-ꞈꞋ-ꞌꟻ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꤊ-ꤥꤰ-ꥆꨀ-ꨨꩀ-ꩂꩄ-ꩋ가힣豈-鶴侮-頻並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]",a=new RegExp(`(?:(?:(\\s?(?:^|[.\\(\\)!?;:"-])\\s*)(${o}))|(${o}))(${o}*[’']*${o}*)`,"g");e.exports=(e,t={})=>{e=e.toLowerCase().replace(a,(e,t="",r,i,o)=>{const a=function(e){const t=e[0];return/\s/.test(t)?e.substr(1):/[()]/.test(t)?null:e}(e);if(!a)return e;if(!r){const e=i+o;if(n.has(e))return a}return t+(i||r).toUpperCase()+o});const r=t.special||[];return(e=>e.map(e=>[new RegExp(`\\b${e}\\b`,"gi"),e]))([...i,...r]).forEach(([t,r])=>{e=e.replace(t,r)}),e}},function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(7),i=r(13);function o(e,t){t.forEach((t,r)=>{if("transactions"===r){e.get(r);let o=[];t.forEach(e=>{if(1===e.isChild&&null==e.parent_id&&e.id.includes("/")){let t=e.id.split("/")[0];o.push({dataset:"transactions",row:e.id,column:"parent_id",value:t,timestamp:i.default.send()})}}),o.length>0&&Object(n.b)(o)}})}let a=null;function s(){a&&(a(),a=null),a=Object(n.a)(o)}},function(e,t,r){(function(t){const n=r(435);e.exports=function(e,r={}){"string"==typeof e&&(e=t.from(e));const i=r&&r.objname?{}:[],o=new n.Parser(r);o.push=function(e){null!==e&&(void 0===r.objname?i.push(e):i[e[0]]=e[1])};const a=o.__parse(e,!1);if(void 0!==a)throw a;const s=o.__parse(void 0,!0);if(void 0!==s)throw s;return i}}).call(this,r(10).Buffer)},function(e,t,r){"use strict";var n=r(40),i=r(39),o=r(77),a=r(1),s=r(5),u=r(8),c=r(2),l=(r(170),r(37)),f=r(7),d=r(12),h=r(13),p=r(6),g=r(26),m=r(25);function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;tObject(p.runMutator)(async()=>{let r=Object(h.getClock)().timestamp.toString(),n=await e(t),i=await a.all("SELECT DISTINCT dataset FROM messages_crdt WHERE timestamp > ?",[r]);return w.getNumClients()>1&&w.send("sync-event",{type:"success",tables:i.map(e=>e.dataset)}),n},{undoDisabled:!0})}let O={};async function T(e){if(!e.match(/^\d{4}-\d{2}$/))throw E("Invalid month format, use YYYY-MM: "+e);if(!v){let t=await O["get-budget-bounds"](),r=t.start,n=t.end;if(!c.n(r,n).includes(e))throw E("No budget exists for month: "+e)}}let A=null;O["api/batch-budget-start"]=async function(){if(A)throw E("Cannot start a batch process: batch already started");v?a.asyncTransaction(()=>new Promise((e,t)=>{A={resolve:e,reject:t}})):Object(f.c)(()=>new Promise((e,t)=>{A={resolve:e,reject:t}}))},O["api/batch-budget-end"]=async function(){if(!A)throw E("Cannot end a batch process: no batch started");A.resolve(),A=null},O["api/load-budget"]=async function({id:e}){if((u.b()||{}).id!==e){w.send("start-load");let t=(await O["load-budget"]({id:e})).error;if(t)throw w.send("show-budgets"),"out-of-sync-migrations"===t||"out-of-sync-data"===t?new Error("This budget cannot be loaded with this version of the app."):"budget-not-found"===t?new Error('Budget "'+e+'" not found. Check the id of your budget in the "Advanced" section of the settings page.'):new Error('We had an unknown problem opening "'+e+'".');w.send("finish-load")}},O["api/start-import"]=async function({budgetName:e}){await O["close-budget"](),await O["create-budget"]({budgetName:e,avoidUpload:!0}),await a.runQuery("DELETE FROM categories WHERE is_income = 0"),await a.runQuery("DELETE FROM category_groups WHERE is_income = 0"),Object(f.k)("import"),w.send("start-import"),v=!0},O["api/finish-import"]=async function(){s.b().markCacheDirty();let e=u.b().id;await O["close-budget"](),await O["load-budget"]({id:e}),await O["get-budget-bounds"](),await s.j(),await l.h().catch(e=>{}),w.send("finish-import"),v=!1},O["api/abort-import"]=async function(){if(v){let e=u.b().id;await O["close-budget"](),await O["delete-budget"]({id:e}),w.send("show-budgets")}v=!1},O["api/query"]=async function({query:e}){return Object(g.b)(e)},O["api/budget-months"]=async function(){let e=await O["get-budget-bounds"](),t=e.start,r=e.end;return c.n(t,r)},O["api/budget-month"]=async function({month:e}){await T(e);let t=await a.getCategoriesGrouped(),r=c.p(e);function n(e){let t=s.b().getCellValue(r,e);return""===t?0:t}return{month:e,incomeAvailable:n("available-funds"),lastMonthOverspent:n("last-month-overspent"),forNextMonth:n("buffered"),totalBudgeted:n("total-budgeted"),toBudget:n("to-budget"),fromLastMonth:n("from-last-month"),totalIncome:n("total-income"),totalSpent:n("total-spent"),totalBalance:n("total-leftover"),categoryGroups:t.map(e=>e.is_income?b(b({},i.b.toExternal(e)),{},{received:n("total-income"),categories:e.categories.map(e=>b(b({},i.c.toExternal(e)),{},{received:n("sum-amount-"+e.id)}))}):b(b({},i.b.toExternal(e)),{},{budgeted:n("group-budget-"+e.id),spent:n("group-sum-amount-"+e.id),balance:n("group-leftover-"+e.id),categories:e.categories.map(e=>b(b({},i.c.toExternal(e)),{},{budgeted:n("budget-"+e.id),spent:n("sum-amount-"+e.id),balance:n("leftover-"+e.id),carryover:n("carryover-"+e.id)}))}))}},O["api/budget-set-amount"]=S((async function({month:e,categoryId:t,amount:r}){return O["budget/budget-amount"]({month:e,category:t,amount:r})})),O["api/budget-set-carryover"]=S((async function({month:e,categoryId:t,flag:r}){return await T(e),await async function(e,t){if(null==t)throw E(e+": category id is required");let r=await a.first("SELECT is_income FROM categories WHERE id = ?",[t]);if(!r)throw E(`${e}: category "${t}" does not exist`);if(0!==r.is_income)throw E(`${e}: category "${t}" is not an expense category`)}("budget-set-carryover",t),O["budget/set-carryover"]({startMonth:e,category:t,flag:r})})),O["api/transactions-export"]=async function({transactions:e,categoryGroups:t,payees:r}){return O["transactions-export"]({transactions:e,categoryGroups:t,payees:r})},O["api/transactions-import"]=S((async function({accountId:e,transactions:t}){return O["transactions-import"]({accountId:e,transactions:t})})),O["api/transactions-add"]=S((async function({accountId:e,transactions:t}){return await Object(n.a)(e,t,{runTransfers:!1}),"ok"})),O["api/transactions-get"]=async function({accountId:e,startDate:t,endDate:r}){return(await Object(g.b)(Object(m.b)("transactions").filter({$and:[e&&{account:e},t&&{date:{$gte:t}},r&&{date:{$lte:r}}].filter(Boolean)}).select("*").options({splits:"grouped"}))).data},O["api/transactions-filter"]=async function({text:e,accountId:t}){throw new Error("`filterTransactions` is deprecated, use `runQuery` instead")},O["api/transaction-update"]=S((async function({id:e,fields:t}){let r=(await Object(g.b)(Object(m.b)("transactions").filter({id:e}).select("*").options({splits:"grouped"}))).data,n=Object(o.d)(r);if(0===n.length)return[];let i=Object(o.e)(n,t).diff;return O["transactions-batch-update"](i)})),O["api/transaction-delete"]=S((async function({id:e}){let t=(await Object(g.b)(Object(m.b)("transactions").filter({id:e}).select("*").options({splits:"grouped"}))).data,r=Object(o.d)(t);if(0===r.length)return[];let n=Object(o.a)(r,e).diff;return O["transactions-batch-update"](n)})),O["api/accounts-get"]=async function(){return(await a.getAccounts()).map(e=>i.a.toExternal(e))},O["api/account-create"]=S((async function({account:e,initialBalance:t=null}){return O["account-create"]({name:e.name,type:e.type,offBudget:e.offbudget,closed:e.closed,balance:null!=t?Object(d.k)(t):null})})),O["api/account-update"]=S((async function({id:e,fields:t}){return a.updateAccount(b({id:e},i.a.fromExternal(t)))})),O["api/account-close"]=S((async function({id:e,transferAccountId:t,transferCategoryId:r}){return O["account-close"]({id:e,transferAccountId:t,categoryId:r})})),O["api/account-reopen"]=S((async function({id:e}){return O["account-reopen"]({id:e})})),O["api/account-delete"]=S((async function({id:e}){return O["account-close"]({id:e,forced:!0})})),O["api/categories-get"]=async function({grouped:e}={}){let t=await O["get-categories"]();return e?t.grouped.map(i.b.toExternal):t.list.map(i.c.toExternal)},O["api/category-group-create"]=S((async function({group:e}){return O["category-group-create"]({name:e.name})})),O["api/category-group-update"]=S((async function({id:e,fields:t}){return O["category-group-update"](b({id:e},i.b.fromExternal(t)))})),O["api/category-group-delete"]=S((async function({id:e,transferCategoryId:t}){return O["category-group-delete"]({id:e,transferId:t})})),O["api/category-create"]=S((async function({category:e}){return O["category-create"]({name:e.name,groupId:e.group_id,isIncome:e.is_income})})),O["api/category-update"]=S((async function({id:e,fields:t}){return O["category-update"](b({id:e},i.c.fromExternal(t)))})),O["api/category-delete"]=S((async function({id:e,transferCategoryId:t}){return O["category-delete"]({id:e,transferId:t})})),O["api/payees-get"]=async function(){return(await O["payees-get"]()).map(i.d.toExternal)},O["api/payee-create"]=S((async function({payee:e}){return O["payee-create"]({name:e.name})})),O["api/payee-update"]=S((async function({id:e,fields:t}){return O["payees-batch-change"]({updated:[b({id:e},i.d.fromExternal(t))]})})),O["api/payee-delete"]=S((async function({id:e}){return O["payees-batch-change"]({deleted:[{id:e}]})})),O["api/payee-rules-get"]=async function({payeeId:e}){return(await O["payees-get-rules"]({id:e})).map(i.e.toExternal)},O["api/payee-rule-create"]=S((async function({payee_id:e,rule:t}){return O["payees-add-rule"]({payee_id:e,type:t.type,value:t.value||null})})),O["api/payee-rule-update"]=S((async function({id:e,fields:t}){return O["payees-update-rule"](b({id:e},i.e.fromExternal(t)))})),O["api/payee-rule-delete"]=S((async function({id:e}){return O["payees-delete-rule"]({id:e})})),t.a=function(e){return O=Object.assign({},e,O),O}},function(e,t,r){"use strict";r.d(t,"a",(function(){return D}));var n=r(2),i=r(5),o=r(61),a=r(1),s=r(8),u=r(32),c=r(26),l=r(7),f=r(6),d=r(40),h=r(25);function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function g(e){for(var t=1;t"Starting Balances"===e.name).id}function v(e,t){let r=e.find(e=>"Deposit"===e.name),n=e.filter(e=>"Deposit"!==e.name&&"Starting Balance"!==e.name),i=t.find(e=>0===e.is_income),o=t.find(e=>1===e.is_income),a=i.categories.filter(e=>-1!==["Food","Restaurants","Entertainment","Clothing","General","Gift","Medical"].indexOf(e.name));return{incomePayee:r,expensePayees:n.filter(e=>!e.bill),incomeGroup:o,expenseCategories:a,billCategories:t.find(e=>"Bills"===e.name).categories,billPayees:n.filter(e=>e.bill)}}async function E(e,t,r,i){let o=v(r,i),a=o.incomePayee,s=o.expensePayees,u=o.incomeGroup,c=o.expenseCategories,l=o.billCategories,f=o.billPayees,h=b(100,200),p=[];for(let e=0;e"Income"===e.name):y(c),o="Deposit"===r.name?b(5e4,7e4):b(0,Math.random()<.05?-8e3:-700);let l={amount:o,payee:r.id,account:t.id,date:n.q(n.d(),e/3|0),category:i.id};if(p.push(l),Math.random()<.2){let e=l.amount/3|0,t=()=>r===a?u.categories.find(e=>"Income"===e.name).id:y(c).id;l.subtransactions=[{amount:e,category:t()},{amount:e,category:t()},{amount:l.amount-2*e,category:t()}]}}let g=n.k(p[p.length-1].date),m=n.o(g,n.e()),_=n.d();for(let e of m){let r=n.a(e,"12");n.j(r,_)&&p.push({amount:-1e4,payee:f.find(e=>e.name.toLowerCase().includes("power")).id,account:t.id,date:r,category:l.find(e=>"Power"===e.name).id}),r=n.a(e,"18"),n.j(r,_)&&p.push({amount:-9e3,payee:f.find(e=>e.name.toLowerCase().includes("water")).id,account:t.id,date:r,category:l.find(e=>"Water"===e.name).id}),r=n.a(e,"2"),n.j(r,_)&&p.push({amount:-12e4,payee:f.find(e=>e.name.toLowerCase().includes("housy")).id,account:t.id,date:r,category:l.find(e=>"Mortgage"===e.name).id}),r=n.a(e,"20"),n.j(r,_)&&p.push({amount:-6e3,payee:f.find(e=>e.name.toLowerCase().includes("internet")).id,account:t.id,date:r,category:l.find(e=>"Internet"===e.name).id}),r=n.a(e,"23"),n.j(r,_)&&p.push({amount:-7500,payee:f.find(e=>e.name.toLowerCase().includes("t-mobile")).id,account:t.id,date:r,category:l.find(e=>"Cell"===e.name).id})}let E=null;return p.forEach(e=>{(null==E||e.date"Starting Balance"===e.name).id,account:t.id,date:E,category:w(u.categories),starting_balance_flag:!0}),Object(d.a)(t.id,p)}async function S(e,t,r,i){let o=v(r,i),a=o.incomePayee,s=o.expensePayees,u=o.incomeGroup,c=o.expenseCategories,l=b(20,40),f=[];for(let e=0;e"Income"===e.name):y(c);let o="Deposit"===r.name?b(5e4,7e4):b(0,-1e4);f.push({amount:o,payee:r.id,account:t.id,date:n.q(n.d(),2*e|0),category:i.id})}f.unshift({amount:b(9e4,12e4),payee:r.find(e=>"Starting Balance"===e.name).id,account:t.id,date:f[f.length-1].date,category:w(u.categories),starting_balance_flag:!0}),await e["transactions-batch-update"]({added:f,fastMode:!0})}async function O(e,t,r,i){let o=v(r,i),a=o.incomePayee,s=(o.expensePayees,o.incomeGroup),u=(o.expenseCategories,b(10,30)),c=[];for(let e=0;e"Income"===e.name),i=b(1e4,2e4);c.push({amount:i,payee:e.id,account:t.id,date:n.q(n.d(),b(10,360)),category:r.id})}c.unshift({amount:b(1e4,2e4),payee:r.find(e=>"Starting Balance"===e.name).id,account:t.id,date:_(c,"date").date,category:w(s.categories),starting_balance_flag:!0}),await e["transactions-batch-update"]({added:c,fastMode:!0})}async function T(e,t,r,i){let o=v(r,i),a=o.incomePayee,s=o.expensePayees,u=o.incomeGroup,c=o.expenseCategories,l=b(15,40),f=[];for(let e=0;e"Income"===e.name):y(c),o=r===a?b(1e4,8e4):b(-1e4,-2e3);f.push({amount:o,payee:r.id,account:t.id,date:n.q(n.d(),5*e|0),category:i.id})}f.unshift({amount:3e4,payee:r.find(e=>"Starting Balance"===e.name).id,account:t.id,date:f[f.length-1].date,category:w(u.categories),starting_balance_flag:!0}),await e["transactions-batch-update"]({added:f,fastMode:!0})}async function A(e,t,r,i){let o=v(r,i),a=o.incomePayee,s=(o.expensePayees,o.incomeGroup),u=(o.expenseCategories,b(7,10)),c=b(1e5,2e5),l=s.categories.find(e=>"Income"===e.name),f=[{amount:100*b(-3e3,-3500)*100,payee:r.find(e=>"Starting Balance"===e.name).id,account:t.id,date:n.r(n.d(),u)+"-02",category:w(s.categories),starting_balance_flag:!0}];for(let e=0;e"Income"===e.name),l=[{amount:100*b(3250,3700)*100,payee:r.find(e=>"Starting Balance"===e.name).id,account:t.id,date:n.r(n.d(),u)+"-02",category:w(s.categories),starting_balance_flag:!0}];for(let e=0;eObject(l.c)(async()=>{for(let r of t)r.id=await e["account-create"](r)}));let r=[{name:"Starting Balance"},{name:"Kroger"},{name:"Publix"},{name:"Home Depot"},{name:"Movies"},{name:"Online store"},{name:"Deposit"},{name:"Dominion Power",bill:!0},{name:"Extra Watery",bill:!0},{name:"Housy House",bill:!0},{name:"Fast Internet",bill:!0},{name:"T-mobile",bill:!0}];await Object(f.runMutator)(()=>Object(l.c)(async()=>{for(let t of r)t.id=await e["payee-create"]({name:t.name})}));let p=[{name:"Usual Expenses",categories:[{name:"Savings"},{name:"Medical"},{name:"Gift"},{name:"General"},{name:"Clothing"},{name:"Entertainment"},{name:"Restaurants"},{name:"Food"}]},{name:"Bills",categories:[{name:"Power"},{name:"Water"},{name:"Mortgage"},{name:"Internet"},{name:"Cell"}]},{name:"Income",is_income:!0,categories:[{name:"Income",is_income:!0},{name:"Misc",is_income:!0},{name:"Starting Balances",is_income:!0}]}];await Object(f.runMutator)(async()=>{for(let t of p){t.id=await e["category-group-create"]({name:t.name,isIncome:t.is_income?1:0});for(let r of t.categories)r.id=await e["category-create"](g(g({},r),{},{isIncome:r.is_income?1:0,groupId:t.id}))}});let m=(await Object(f.runHandler)(e["get-categories"])).grouped;Object(l.k)("import"),await Object(f.runMutator)(()=>Object(l.c)(async()=>{for(let n of t)switch(n.type){case"checking":"Bank of America"===n.name?await E(0,n,r,m):await S(e,n,r,m);break;case"investment":await O(e,n,r,m);break;case"savings":await T(e,n,r,m);break;case"mortgage":await A(e,n,r,m);break;case"other":"House Asset"===n.name?await M(e,n,r,m):await S(e,n,r,m)}})),Object(l.k)("import");let y=t.find(e=>e.name="Bank of America"),_=(await Object(c.b)(Object(h.b)("transactions").filter({account:y.id}).calculate({$sum:"$amount"}).serialize())).data;if(_<0){let t=(await Object(c.b)(Object(h.b)("transactions").filter({account:y.id,amount:{$gt:0}}).limit(1).select(["id","amount"]).serialize())).data[0];await Object(f.runHandler)(e["transaction-update"],g(g({},t),{},{amount:t.amount+-_+b(1e4,2e4)}))}Object(l.k)("disabled"),await s.d({isCached:!1}),await i.g(a),await o.a(),await i.j(),await async function(e,t,r){let o=e.find(e=>e.name="Bank of America"),s=(await a.first("SELECT * FROM v_transactions t LEFT JOIN accounts a ON t.account = a.id\n WHERE a.offbudget = 0 AND t.is_child = 0 ORDER BY date ASC LIMIT 1")).date,c=(await a.first("SELECT * FROM v_transactions t LEFT JOIN accounts a ON t.account = a.id\n WHERE a.id = ? AND a.offbudget = 0 AND t.is_child = 0 ORDER BY date ASC LIMIT 1",[o.id])).date,h=n.k(a.fromDateRepr(s)),p=n.e(),g=n.o(h,p);function m(e){for(let t of r){let r=t.categories.find(t=>t.name===e);if(r)return r}}function y(e,t,r){return u.i({month:e,category:t.id,amount:r})}function b(e,t){let r=i.d(n.p(e),"sum-amount-"+t.id);r<0&&y(e,t,-r)}await Object(f.runMutator)(()=>Object(l.c)(async()=>{for(let e of g)e>=n.k(a.fromDateRepr(c))?(y(e,m("Food"),4e4),y(e,m("Restaurants"),3e4),y(e,m("Entertainment"),1e4),y(e,m("Clothing"),3e3),y(e,m("General"),5e4),y(e,m("Gift"),7500),y(e,m("Medical"),1e4),y(e,m("Cell"),7500),y(e,m("Internet"),6e3),y(e,m("Mortgage"),12e4),y(e,m("Water"),9e3),y(e,m("Power"),1e4)):(b(e,m("Food")),b(e,m("Restaurants")),b(e,m("Entertainment")),b(e,m("Clothing")),b(e,m("General")),b(e,m("Gift")),b(e,m("Medical")),b(e,m("Cell")),b(e,m("Internet")),b(e,m("Mortgage")),b(e,m("Water")),b(e,m("Power")))})),await i.j(),await Object(f.runMutator)(()=>Object(l.c)(async()=>{let e=0;for(let t of g)if(t>=n.k(a.fromDateRepr(c))&&t<=n.e()){let r=n.p(t),o=i.d(r,"to-budget")-e;o-403e3>0?(y(t,m("Savings"),o-403e3),u.j(t,403e3),e+=o-403e3):o>0&&u.j(t,o)}})),await i.j();let _=n.p(n.e()),w=i.d(_,"to-budget");w<0&&await Object(d.a)(o.id,[{amount:-w,category:m("Income").id,date:n.e()+"-01"}]),await i.j()}(t,0,m)}},function(e,t,r){"use strict";var n=r(56),i=r(6),o=r(14),a=r(32);let s=Object(n.a)();s.method("budget/budget-amount",Object(i.mutator)(Object(o.e)(a.i))),s.method("budget/copy-previous-month",Object(i.mutator)(Object(o.e)(a.a))),s.method("budget/set-zero",Object(i.mutator)(Object(o.e)(a.l))),s.method("budget/set-3month-avg",Object(i.mutator)(Object(o.e)(a.g))),s.method("budget/set-all-future",Object(i.mutator)(Object(o.e)(a.h))),s.method("budget/hold-for-next-month",Object(i.mutator)(Object(o.e)(a.e))),s.method("budget/hold-for-future-months",Object(i.mutator)(Object(o.e)(a.d))),s.method("budget/reset-hold",Object(i.mutator)(Object(o.e)(a.f))),s.method("budget/cover-overspending",Object(i.mutator)(Object(o.e)(a.b))),s.method("budget/transfer-available",Object(i.mutator)(Object(o.e)(a.m))),s.method("budget/transfer-category",Object(i.mutator)(Object(o.e)(a.n))),s.method("budget/set-carryover",Object(i.mutator)(Object(o.e)(a.k))),t.a=s},function(e,t,r){"use strict";var n=r(56),i=r(1);let o=Object(n.a)();o.method("notes-save",async({id:e,note:t})=>{await i.update("notes",{id:e,note:t})}),t.a=o},function(e,t,r){"use strict";r(7);var n=r(6),i=r(56),o=r(1),a=r(68);let s=Object(i.a)();s.method("tools/fix-split-transactions",async()=>{let e=await o.all("\n SELECT t.*, p.payee AS parentPayee FROM v_transactions_internal t\n LEFT JOIN v_transactions_internal p ON t.parent_id = p.id\n WHERE t.is_child = 1 AND t.payee IS NULL AND p.payee IS NOT NULL\n ");await Object(n.runMutator)(async()=>{let t=e.map(e=>({id:e.id,payee:e.parentPayee}));await Object(a.a)({updated:t})});let t=await o.all("\n SELECT t.id, p.cleared FROM v_transactions_internal t\n LEFT JOIN v_transactions_internal p ON t.parent_id = p.id\n WHERE t.is_child = 1 AND t.cleared != p.cleared\n ");await Object(n.runMutator)(async()=>{let e=t.map(e=>({id:e.id,cleared:1===e.cleared}));await Object(a.a)({updated:e})});let r=await o.all("\n SELECT t.* FROM v_transactions_internal t\n LEFT JOIN v_transactions_internal p ON t.parent_id = p.id\n WHERE t.is_child = 1 AND t.tombstone = 0 AND (p.tombstone = 1 OR p.id IS NULL)\n ");return await Object(n.runMutator)(async()=>{let e=r.map(e=>({id:e.id,tombstone:1}));await Object(a.a)({updated:e})}),{numBlankPayees:e.length,numCleared:t.length,numDeleted:r.length}}),t.a=s},function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(4),i=r.n(n);var o=r(277),a=r.n(o),s=r(2),u=r(12);function c(e,t){let n=[],o=e.match(/\.[^.]*$/);if(o){switch(o[0].toLowerCase()){case".qif":return async function(e){let t,r=[],n=await i.a.readFile(e);try{t=function(e,t){var r=e.split("\n"),n=r.shift(),i=/!Type:([^$]*)$/.exec(n.trim()),o={},a=o.transactions=[],s={};if(t=t||{},!i||!i.length)throw new Error("File does not appear to be a valid qif file: "+n);o.type=i[1];for(var u={};n=r.shift();)if("^"!==(n=n.trim()))switch(n[0]){case"D":s.date=n.substring(1);break;case"T":s.amount=n.substring(1);break;case"N":s.number=n.substring(1);break;case"M":s.memo=n.substring(1);break;case"A":s.address=(s.address||[]).concat(n.substring(1));break;case"P":s.payee=n.substring(1).replace(/&/g,"&");break;case"L":var c=n.substring(1).split(":");s.category=c[0],void 0!==c[1]&&(s.subcategory=c[1]);break;case"C":s.clearedStatus=n.substring(1);break;case"S":var l=n.substring(1).split(":");u.category=l[0],void 0!==l[1]&&(u.subcategory=l[1]);break;case"E":u.description=n.substring(1);break;case"$":u.amount=parseFloat(n.substring(1)),s.division instanceof Array||(s.division=[]),s.division.push(u),u={};break;default:throw new Error("Unknown Detail Code: "+n[0])}else a.push(s),s={};return Object.keys(s).length&&a.push(s),o.dateFormat=t.dateFormat,o}(n)}catch(e){return r.push({message:"Failed parsing: doesn't look like a valid QIF file.",internal:e.stack}),{errors:r,transactions:[]}}return{errors:r,transactions:t.transactions.map(e=>({amount:null!=e.amount?Object(u.m)(e.amount):null,date:e.date,payee_name:e.payee,imported_payee:e.payee,notes:e.memo||null}))}}(e);case".csv":return async function(e,t={}){let r,n=[],o=await i.a.readFile(e);try{r=a()(o,{columns:!0,bom:!0,delimiter:t.delimiter||",",quote:'"',trim:!0,relax_column_count:!0})}catch(e){return n.push({message:"Failed parsing: "+e.message,internal:e.message}),{errors:n,transactions:[]}}return{errors:n,transactions:r}}(e,t);case".ofx":case".qfx":return async function(e){let t=await r.e("xfo").then(r.t.bind(null,488,7)),n=t.getOFXTransactions,o=t.initModule;await o();let a,u=[],c=await i.a.readFile(e);try{a=n(c)}catch(e){return u.push({message:"Failed importing file",internal:e.stack}),{errors:u}}return{errors:u,transactions:a.map(e=>({amount:e.amount,imported_id:e.fi_id,date:e.date?Object(s.f)(1e3*e.date):null,payee_name:e.name,imported_payee:e.name,notes:e.memo||null}))}}(e)}}return n.push({message:"Invalid file type",internal:""}),{errors:n}}},function(e,t,r){"use strict";var n=r(177),i=r.n(n),o=r(74),a=r(47),s=r(56),u=r(1),c=r(8),l=r(17),f=r(26),d=(r(58),r(33),r(2)),h=r(25),p=r(21),g=r(29),m=r(41),y=r(6),b=r(14),_=r(93),w=r(7),v=r(24),E=r(40),S=r(133),O=r(127),T=r(249),A=r(132),M=r(128),D=r(34),I=r(250),j=r(12),R=r(38);function N(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function k(e){for(var t=1;te.date)}async function P(e,t){return(await Object(f.b)(Object(h.b)("transactions").filter({account:t,schedule:null,"payee.transfer_acct":null,$and:[{date:{$gte:S.a(e,2)}},{date:{$lte:a.a(e,2)}}]}).select("*").options({splits:"none"}))).data}function B(e,t){return 1/(Math.abs(O.a(Object(d.l)(e),Object(d.l)(t)))+1)}function U(e,t,r=.5){let n=(e=[...e].reverse())[0],i=e.slice(1),o=[];for(let r of n.transactions){let a=Object(R.b)(r.amount),s=r.payee,u=(r.account,i.map(e=>{let t=e.transactions.find(e=>e.amount>=r.amount-a&&e.amount<=r.amount+a);return t=t&&t.payee===s?t:null,t?{trans:t,rank:B(e.date,t.date)}:null}));if(-1!==u.indexOf(null))continue;let c=u.reduce((e,t)=>e+t.rank,B(n.date,r.date)),l=u.reduce((e,t)=>e&&t.trans.amount===r.amount,!0);o.push({rank:c,amount:r.amount,account:r.account,payee:r.payee,date:t,exactDate:c===e.length,exactAmount:l})}return o}async function F(e,t,r,n,i){let o=[];for(let s=0;s!(M.a(e)>28)&&{start:e,frequency:"monthly"},t)}async function q(e,t){let r=await F(A.a(Object(d.l)(e),3),1,{frequency:"monthly",patterns:[{type:"day",value:-1}]},t,.75),n=await F(A.a(Object(d.l)(e),4),1,{frequency:"monthly",patterns:[{type:"day",value:-1}]},t,.75);return r.concat(n)}async function V(e,t){return F(T.a(Object(d.l)(e),8),14,e=>{let t=D.a(new Date,"iiii").slice(0,2).toUpperCase();return{start:e,frequency:"monthly",patterns:[{type:t,value:1},{type:t,value:3}]}},t)}async function G(e,t){return F(A.a(Object(d.l)(e),8),14,e=>{let t=D.a(new Date,"iiii").slice(0,2).toUpperCase();return{start:e,frequency:"monthly",patterns:[{type:t,value:2},{type:t,value:4}]}},t)}async function Y(e){let t=e._conditions,r=t.find(e=>"date"===e.field).value;for(;;){let e=r;switch(r=k({},e),r.frequency){case"weekly":r.start=Object(d.f)(T.a(Object(d.l)(r.start),r.interval||1));break;case"monthly":r.start=Object(d.f)(A.a(Object(d.l)(r.start),r.interval||1));break;case"yearly":r.start=Object(d.f)(I.a(Object(d.l)(r.start),r.interval||1));break;default:throw new Error("findStartDate: invalid frequency")}let n=t.map(e=>"date"===e.field?k(k({},e),{},{value:r}):e),i=Object(p.b)(n,{recurDateBounds:1}),o=i.filters;if(i.errors.length>0){r=null;break}if(0===(await Object(f.b)(Object(h.b)("transactions").filter({$and:o}).select("*"))).data.length){r=e;break}}return r?k(k({},e),{},{date:r,_conditions:t.map(e=>"date"===e.field?k(k({},e),{},{value:r}):e)}):e}const $=["type"];function K(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function Z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function X(e){for(var t=1;t0){let t=e[0].date;return Object(d.f)(t)}}return null}async function re(e){if(null==e)throw new Error("Schedule not attached to a rule");let t=(await Object(f.b)(Object(h.b)("schedules").filter({id:e}).calculate("rule"))).data;return Object(p.d)().find(e=>e.id===t)}async function ne({id:e,start:t,conditions:r,reset:n}){if(null==r){let t=await re(e);if(null==t)throw new Error("No rule found for schedule");r=t.serialize().conditions}let i=Object(m.a)(r).date,o=(await Object(f.b)(Object(h.b)("schedules").filter({id:e}).calculate("next_date"))).data;if(i){let r=te(i,t?t(o):new Date);if(r!==o){let t=await u.first("SELECT id, base_next_date_ts FROM schedules_next_date WHERE schedule_id = ?",[e]);await u.update("schedules_next_date",n?{id:t.id,base_next_date:Object(l.h)(r),base_next_date_ts:Date.now()}:{id:t.id,local_next_date:Object(l.h)(r),local_next_date_ts:t.base_next_date_ts})}}}async function ie({schedule:e,conditions:t,resetNextDate:r}){if(e.rule)throw new Error("You cannot change the rule of a schedule");let n;if(t){let r=Object(m.a)(t).date;if(r&&null==r.value)throw new Error("Date is required");n=await re(e.id),null==n&&(n=await async function(e){let t=(await Object(f.b)(Object(h.b)("schedules").filter({id:e}).calculate("rule"))).data;t&&await u.delete_("rules",t);let r=await Object(p.f)({stage:null,conditions:[{op:"isapprox",field:"date",value:Object(d.d)()},{op:"isapprox",field:"amount",value:0}],actions:[{op:"link-schedule",value:e}]});return await u.updateWithSchema("schedules",{id:e,rule:r}),Object(p.d)().find(e=>e.id===r)}(e.id))}await Object(w.c)(async()=>{if(t){let o=n.serialize().conditions,a=function(e,t){let r=Object(m.a)(e),n=Object(m.a)(t),i=function(e,t){let r=[];for(let n=0;n{let t=i.find(t=>e===t[0]);return t&&t[1]?t[1]:e}),a=i.filter(e=>null==e[0]&&null!=e[1]).map(e=>e[1]);return o.concat(a)}(o,t);await Object(p.n)({id:n.id,conditions:a});let s=e=>{e.type;return K(e,$)};!r&&i()(o.find(e=>"account"===e.field),o.find(e=>"account"===e.field))&&i()(s(o.find(e=>"date"===e.field)),s(a.find(e=>"date"===e.field)))||await ne({id:e.id,conditions:a,reset:!0})}else r&&await ne({id:e.id,reset:!0});await u.updateWithSchema("schedules",e)})}function oe(e){let t=e instanceof g.c?e.serialize():p.j.toJS(e),r=t.actions,n=t.conditions;if(r&&r.find(e=>"link-schedule"===e.op)){let e=r.find(e=>"link-schedule"===e.op).value;if(e){let t=Object(m.a)(n),r=n.findIndex(e=>e===t.payee),i=n.findIndex(e=>e===t.account),o=n.findIndex(e=>e===t.amount),a=n.findIndex(e=>e===t.date);u.runQuery("INSERT OR REPLACE INTO schedules_json_paths (schedule_id, payee, account, amount, date) VALUES (?, ?, ?, ?, ?)",[e,-1===r?null:`$[${r}]`,-1===i?null:`$[${i}]`,-1===o?null:`$[${o}]`,-1===a?null:`$[${a}]`])}}}function ae(e,t){let r=!1;t.forEach((e,t)=>{"rules"===t&&(r=!0,e.forEach(e=>{oe(e)}))})}async function se({id:e}){let t=(await Object(f.b)(Object(h.b)("schedules").filter({id:e}).select("*"))).data[0];if(null==t||null==t._account)return;let r={payee:t._payee,account:t._account,amount:Object(m.c)(t._amount),date:t.next_date,schedule:t.id,cleared:!1};r.account&&await Object(E.a)(r.account,[r])}async function ue(e){let t=(await Object(f.b)(Object(h.b)("schedules").filter({completed:!1,"_account.closed":!1}).select("*"))).data,r=(await Object(f.b)(Object(m.b)(t))).data,n=new Set(r.filter(Boolean).map(e=>e.schedule)),i=[],o=!1;for(let r of t){let t=Object(m.d)(r.next_date,r.completed,n.has(r.id));if("paid"===t){if(r._date)if(r._date.frequency)try{await ne({id:r.id})}catch(e){}else r._date0?Q.send("schedules-offline",{payees:i}):o&&Q.send("sync-event",{type:"success",tables:["transactions"],syncDisabled:"false"})}let ce=Object(s.a)();ce.method("schedule/create",Object(y.mutator)(Object(b.e)((async function({schedule:e,conditions:t=[]}={}){let r=e&&e.id||ee.v4Sync(),n=Object(m.a)(t).date;if(null==n)throw new Error("A date condition is required to create a schedule");if(null==n.value)throw new Error("Date is required");let i,o=te(n),a=o?Object(l.h)(o):null;i=await Object(p.f)({stage:null,conditions:t,actions:[{op:"link-schedule",value:r}]});let s=Date.now();return await u.insertWithUUID("schedules_next_date",{schedule_id:r,local_next_date:a,local_next_date_ts:s,base_next_date:a,base_next_date_ts:s}),await u.insertWithSchema("schedules",X(X({},e),{},{id:r,rule:i})),r})))),ce.method("schedule/update",Object(y.mutator)(Object(b.e)(ie))),ce.method("schedule/delete",Object(y.mutator)(Object(b.e)((async function({id:e}){let t=(await Object(f.b)(Object(h.b)("schedules").filter({id:e}).calculate("rule"))).data;await Object(w.c)(async()=>{await u.delete_("rules",t),await u.delete_("schedules",e)})})))),ce.method("schedule/skip-next-date",Object(y.mutator)(Object(b.e)((async function({id:e}){return ne({id:e,start:e=>a.a(Object(d.l)(e),1)})})))),ce.method("schedule/post-transaction",Object(y.mutator)(Object(b.e)(se))),ce.method("schedule/force-run-service",Object(y.mutator)(()=>ue(!0))),ce.method("schedule/get-possible-transactions",(function({schedule:e}){})),ce.method("schedule/discover",(function(){return async function(){let e=(await Object(f.b)(Object(h.b)("accounts").filter({closed:!1}).select("*"))).data,t=[];for(let r of e){let e=await u.first("SELECT * FROM v_transactions WHERE account = ? AND parent_id IS NULL ORDER BY date DESC LIMIT 1",[r.id]);if(e){let n=Object(l.d)(e.date);t=t.concat(await W(n,r.id),await H(n,r.id),await z(n,r.id),await q(n,r.id),await V(n,r.id),await G(n,r.id))}}let r=[...Object(j.h)(t,"payee").entries()].map(([e,t])=>{t.sort((e,t)=>t.rank-e.rank);let r=t[0];return{id:L.v4Sync(),account:r.account,payee:r.payee,date:r.date,amount:r.amount,_conditions:[{op:"is",field:"account",value:r.account},{op:"is",field:"payee",value:r.payee},{op:r.exactDate?"is":"isapprox",field:"date",value:r.date},{op:r.exactAmount?"is":"isapprox",field:"amount",value:r.amount}]}}),n=[];for(let e of r)n.push(await Y(e));return n}()})),ce.method("schedule/get-upcoming-dates",(async function({config:e,count:t}){let r=Object(m.e)(e);try{return new _.a({rrules:r}).occurrences({start:o.a(new Date),take:t}).toArray().map(e=>Object(d.f)(e.date))}catch(t){throw Object(v.captureBreadcrumb)(e),t}})),ce.service((function(){return u.transaction(()=>{Object(p.d)().forEach(e=>{oe(e)})}),Object(w.a)(ae)})),ce.events.on("sync",({type:e,subtype:t})=>{if(("success"===e||"error"===e||"unauthorized"===e)&&c.b()){c.b().lastScheduleRun!==Object(d.d)()&&(Object(y.runMutator)(()=>ue("success"===e)),c.d({lastScheduleRun:Object(d.d)()}))}});t.a=ce},function(e,t,r){"use strict";r.r(t),function(e,n,i){r.d(t,"handlers",(function(){return ye})),r.d(t,"initApp",(function(){return Ee})),r.d(t,"init",(function(){return Se})),r.d(t,"lib",(function(){return Oe}));r(288);var o=r(9),a=r.n(o),s=r(24),u=r(8),c=r(4),l=r.n(c),f=r(15),d=r(69),h=r(43),p=r(1),g=r(5),m=r(14),y=r(170),b=r(29),_=r(21),w=r(110),v=r(68),E=r(38),S=r(95),O=r(12),T=r(2),A=r(134),M=r(61),D=r(40),I=r(138),j=r(174),R=r(6),N=r(13),k=r(75),C=r(7),L=r(276),x=r(135),P=r(283),B=r(175),U=r(20),F=r(278),W=r(169),H=r.n(W),z=r(37),q=r(31),V=r(96),G=r(30),Y=r(18),$=r(279),K=r(26),Z=r(25),X=r(28),J=r(284),Q=r(280),ee=r(281),te=r(282);function re(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return ne(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ne(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ne(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r{let t=g.b()._getNode(e);return{name:t.name,value:t.value}});le.send("cells-changed",t)}let ye={};function be(e){function t(e,t){let r=e.map(e=>{try{t(e)}catch(e){if(e instanceof Y.RuleError)return console.warn("Invalid rule",e),e.type;throw e}return null});return r.some(Boolean)?r:null}let r=t(e.conditions,e=>new b.b(e.op,e.field,e.value,e.options,E.a)),n=t(e.actions,e=>new b.a(e.op,e.field,e.value,e.options,E.a));return r||n?{conditionErrors:r,actionErrors:n}:null}ye.undo=Object(R.mutator)((async function(){return Object(m.d)()})),ye.redo=Object(R.mutator)((function(){return Object(m.c)()})),ye["transactions-batch-update"]=Object(R.mutator)((async function({added:e,deleted:t,updated:r,learnCategories:n}){return Object(m.f)(async()=>(await Object(v.a)({added:e,updated:r,deleted:t,learnCategories:n})).updated)})),ye["transaction-add"]=Object(R.mutator)((async function(e){return await ye["transactions-batch-update"]({added:[e]}),{}})),ye["transaction-update"]=Object(R.mutator)((async function(e){return await ye["transactions-batch-update"]({updated:[e]}),{}})),ye["transaction-delete"]=Object(R.mutator)((async function(e){return await ye["transactions-batch-update"]({deleted:[e]}),{}})),ye["transactions-filter"]=async function({term:e,accountId:t,latestDate:r,count:n,notPaged:i,options:o={}}){return p.getTransactions(e,t,r,i?null:null==n?void 0:n,o)},ye["transactions-parse-file"]=async function({filepath:e,options:t}){return Object(P.a)(e,t)},ye["transactions-export"]=async function({transactions:e,accounts:t,categoryGroups:r,payees:n}){return Object(B.b)(e,t,r,n)},ye["transactions-export-query"]=async function({query:e}){return Object(B.a)(new Z.a(e))},ye["get-categories"]=async function(){return{grouped:await p.getCategoriesGrouped(),list:await p.getCategories()}},ye["get-earliest-transaction"]=async function(){return(await Object(K.b)(Object(Z.b)("transactions").options({splits:"none"}).orderBy({date:"asc"}).select("*").limit(1))).data[0]||null},ye["get-budget-bounds"]=async function(){return M.a()},ye["rollover-budget-month"]=async function({month:e}){let t=await p.getCategoriesGrouped(),r=T.p(e);function n(e){let t=g.d(r,e);return{value:""===t?0:t,name:de(r,e)}}let i=[n("available-funds"),n("last-month-overspent"),n("buffered"),n("total-budgeted"),n("to-budget"),n("from-last-month"),n("total-income"),n("total-spent"),n("total-leftover")];for(let e of t)if(e.is_income){i.push(n("total-income"));for(let t of e.categories)i.push(n("sum-amount-"+t.id))}else{i=i.concat([n("group-budget-"+e.id),n("group-sum-amount-"+e.id),n("group-leftover-"+e.id)]);for(let t of e.categories)i=i.concat([n("budget-"+t.id),n("sum-amount-"+t.id),n("leftover-"+t.id),n("carryover-"+t.id)])}return i},ye["report-budget-month"]=async function({month:e}){let t=await p.getCategoriesGrouped(),r=T.p(e);function n(e){let t=g.d(r,e);return{value:""===t?0:t,name:de(r,e)}}let i=[n("total-budgeted"),n("total-budget-income"),n("total-saved"),n("total-income"),n("total-spent"),n("real-saved"),n("total-leftover")];for(let e of t){i=i.concat([n("group-budget-"+e.id),n("group-sum-amount-"+e.id),n("group-leftover-"+e.id)]);for(let t of e.categories)i=i.concat([n("budget-"+t.id),n("sum-amount-"+t.id),n("leftover-"+t.id)]),e.is_income||i.push(n("carryover-"+t.id))}return i},ye["budget-set-type"]=async function({type:e}){if("rollover"!==e&&"report"!==e)throw new Error("Invalid budget type: "+e);if(e!==u.b().budgetType)return u.d({budgetType:e})},ye["category-create"]=Object(R.mutator)((async function({name:e,groupId:t,isIncome:r}){return Object(m.f)(async()=>{if(!t)throw Object(Y.APIError)("Creating a category: groupId is required");return p.insertCategory({name:e,cat_group:t,is_income:r?1:0})})})),ye["category-update"]=Object(R.mutator)((async function(e){return Object(m.f)(async()=>{try{await p.updateCategory(e)}catch(e){if(e.message.toLowerCase().includes("unique constraint"))return{error:{type:"category-exists"}};throw e}return{}})})),ye["category-move"]=Object(R.mutator)((async function({id:e,groupId:t,targetId:r}){return Object(m.f)(async()=>(await Object(C.c)(async()=>{await p.moveCategory(e,t,r)}),"ok"))})),ye["category-delete"]=Object(R.mutator)((async function({id:e,transferId:t}){return Object(m.f)(async()=>{let r={};return await Object(C.c)(async()=>{let n=await p.first("SELECT is_income FROM categories WHERE id = ?",[e]);if(!n)return void(r={error:"no-categories"});let i=t&&await p.first("SELECT is_income FROM categories WHERE id = ?",[t]);!n||t&&!i?r={error:"no-categories"}:t&&n.is_income!==i.is_income?r={error:"category-type"}:(0===n.is_income&&t&&await M.b([e],t),await p.deleteCategory({id:e},t))}),r})})),ye["category-group-create"]=Object(R.mutator)((async function({name:e,isIncome:t}){return Object(m.f)(async()=>p.insertCategoryGroup({name:e,is_income:t?1:0}))})),ye["category-group-update"]=Object(R.mutator)((async function(e){return Object(m.f)(async()=>p.updateCategoryGroup(e))})),ye["category-group-move"]=Object(R.mutator)((async function({id:e,targetId:t}){return Object(m.f)(async()=>(await Object(C.c)(async()=>{await p.moveCategoryGroup(e,t)}),"ok"))})),ye["category-group-delete"]=Object(R.mutator)((async function({id:e,transferId:t}){return Object(m.f)(async()=>{const r=await p.all("SELECT id FROM categories WHERE cat_group = ? AND tombstone = 0",[e]);return Object(C.c)(async()=>{t&&await M.b(r.map(e=>e.id),t),await p.deleteCategoryGroup({id:e},t)})})})),ye["must-category-transfer"]=async function({id:e}){return 0!==(await p.runQuery("SELECT count(t.id) as count FROM transactions t\n LEFT JOIN category_mapping cm ON cm.id = t.category\n WHERE cm.transferId = ? AND t.tombstone = 0",[e],!0))[0].count||[...g.b().meta().createdMonths].some(t=>{const r=T.p(t);return 0!==g.b().getCellValue(r,"budget-"+e)})},ye["payee-create"]=Object(R.mutator)((async function({name:e}){return Object(m.f)(async()=>p.insertPayee({name:e}))})),ye["payees-get"]=async function(){return p.getPayees()},ye["payees-get-rule-counts"]=async function(){let e={};_.d();return _.g(_.d(),"payee",(t,r)=>{null==e[r]&&(e[r]=0),e[r]++}),e},ye["payees-merge"]=Object(R.mutator)((async function({targetId:e,mergeIds:t}){return Object(m.f)(async()=>p.mergePayees(e,t),{targetId:e,mergeIds:t})})),ye["payees-batch-change"]=Object(R.mutator)((async function({added:e,deleted:t,updated:r}){return Object(m.f)(async()=>Object(C.c)(async()=>{t&&await Promise.all(t.map(e=>p.deletePayee(e))),e&&await Promise.all(e.map(e=>p.insertPayee(e))),r&&await Promise.all(r.map(e=>p.updatePayee(e)))}))})),ye["payees-check-orphaned"]=async function({ids:e}){let t=new Set(await p.getOrphanedPayees());return e.filter(e=>t.has(e))},ye["payees-get-rules"]=async function({id:e}){return _.e(e).map(e=>e.serialize())},ye["payees-delete-rule"]=Object(R.mutator)((async function({id:e,payee_id:t}){return Object(m.f)(async()=>await p.deletePayeeRule({id:e}),{payeeId:t})})),ye["payees-update-rule"]=Object(R.mutator)((async function(e){return Object(m.f)(async()=>await p.updatePayeeRule(e),{payeeId:e.payee_id})})),ye["payees-add-rule"]=Object(R.mutator)((async function(e){return Object(m.f)(async()=>{let t=await p.insertPayeeRule(e);return oe(oe({},e),{},{id:t})},{payeeId:e.payee_id})})),ye["rule-validate"]=async function(e){return{error:be(e)}},ye["rule-add"]=Object(R.mutator)((async function(e){let t=be(e);return t?{error:t}:{id:await _.f(e)}})),ye["rule-update"]=Object(R.mutator)((async function(e){let t=be(e);return t?{error:t}:(await _.n(e),{})})),ye["rule-delete"]=Object(R.mutator)((async function(e){return _.c(e)})),ye["rule-delete-all"]=Object(R.mutator)((async function(e){let t=!1;return await Object(C.c)(async()=>{for(let r of e){!1===await _.c({id:r})&&(t=!0)}}),{someDeletionsFailed:t}})),ye["rule-apply-actions"]=Object(R.mutator)((async function({transactionIds:e,actions:t}){return _.a(e,t,ye)})),ye["rule-add-payee-rename"]=Object(R.mutator)((async function({fromNames:e,to:t}){return _.m(e,t)})),ye["rules-get"]=async function(){return Object(b.g)(_.d()).map(e=>e.serialize())},ye["rule-get"]=async function({id:e}){let t=_.d().find(t=>t.id===e);return t?t.serialize():null},ye["rules-run"]=async function({transaction:e}){return _.k(e)},ye["rules-migrate"]=async function(){await _.i()},ye["make-filters-from-conditions"]=async function({conditions:e}){return _.b(e)},ye.getCell=async function({sheetName:e,name:t}){let r=["name","value"],n=g.b()._getNode(de(e,t));if(r){let e={};return r.forEach(t=>{e[t]="run"===t?n._run?n._run.toString():null:n[t]}),e}return n},ye.getCells=async function({names:e}){return e.map(e=>({value:g.b()._getNode(e).value}))},ye.getCellNamesInSheet=async function({sheetName:e}){let t=[];for(let r of g.b().getNodes().keys()){let n=he(r),i=n.sheet,o=n.name;i===e&&t.push(o)}return t},ye.debugCell=async function({sheetName:e,name:t}){let r=g.b().getNode(de(e,t));return oe(oe({},r),{},{_run:r._run&&r._run.toString()})},ye["create-query"]=async function({sheetName:e,name:t,query:r}){return g.b().createQuery(e,t,r),"ok"},ye.query=async function(e){if(null==e.table)throw new Error("query has no table, did you forgot to call `.serialize`?");return Object(K.b)(e)},ye["bank-delete"]=async function({id:e}){const t=await p.runQuery("SELECT * FROM accounts WHERE bank = ?",[e],!0);return await p.delete_("banks",e),await Promise.all(t.map(async e=>{await p.runQuery("DELETE FROM transactions WHERE acct = ?",[e.id]),await p.delete_("accounts",e.id)})),"ok"},ye["account-update"]=Object(R.mutator)((async function({id:e,name:t}){return Object(m.f)(async()=>(await p.update("accounts",{id:e,name:t}),{}))})),ye["accounts-get"]=async function(){return p.getAccounts()},ye["account-properties"]=async function({id:e}){return{balance:(await p.first("SELECT sum(amount) as balance FROM transactions WHERE acct = ? AND isParent = 0 AND tombstone = 0",[e])).balance||0,numTransactions:(await p.first("SELECT count(id) as count FROM transactions WHERE acct = ? AND tombstone = 0",[e])).count}},ye["accounts-link"]=async function({institution:e,publicToken:t,accountId:r,upgradingId:n}){let i=await I.b(e,t),o=re(await a.a.multiGet(["user-id","user-key"]),2),s=re(o[0],2)[1],u=re(o[1],2)[1],c=(await D.b(s,u,i)).find(e=>e.account_id===r);return await p.update("accounts",{id:n,account_id:c.account_id,official_name:c.official_name,type:Object(A.a)(c.type),balance_current:Object(O.a)(c.balances.current),balance_available:Object(O.a)(c.balances.available),balance_limit:Object(O.a)(c.balances.limit),mask:c.mask,bank:i}),await D.d(s,u,n,c.account_id,i),le.send("sync-event",{type:"success",tables:["transactions"]}),"ok"},ye["accounts-connect"]=async function({institution:e,publicToken:t,accountIds:r,offbudgetIds:n}){let i=await I.b(e,t);return await I.a(i,r,n)},ye["account-create"]=Object(R.mutator)((async function({name:e,type:t,balance:r,offBudget:n,closed:i}){return Object(m.f)(async()=>{const o=await p.insertAccount({name:e,type:t,offbudget:n?1:0,closed:i?1:0});if(await p.insertPayee({name:"",transfer_acct:o}),null!=r){let e=await Object(x.a)();await p.insertTransaction({account:o,amount:Object(O.a)(r),category:n?null:e.category,payee:e.id,date:T.d(),cleared:!0,starting_balance_flag:!0})}return o})})),ye["account-close"]=Object(R.mutator)((async function({id:e,transferAccountId:t,categoryId:r,forced:n}){return await ye["account-unlink"]({id:e}),Object(m.f)(async()=>{let i=await p.first("SELECT * FROM accounts WHERE id = ? AND tombstone = 0",[e]);if(!i||1===i.closed)return;const o=await ye["account-properties"]({id:e}),a=o.balance;if(0===o.numTransactions)await p.deleteAccount({id:e});else if(n){let t=await p.runQuery("SELECT id, transfer_id FROM v_transactions WHERE account = ?",[e],!0),r=(await p.first("SELECT id FROM payees WHERE transfer_acct = ?",[e])).id;await Object(C.c)(()=>{t.forEach(e=>{e.transfer_id&&p.updateTransaction({id:e.transfer_id,payee:null,transfer_id:null}),p.deleteTransaction({id:e.id})}),p.deleteAccount({id:e}),p.deleteTransferPayee({id:r})})}else{if(0!==a&&null==t)throw Object(Y.APIError)("balance is non-zero: transferAccountId is required");if(await p.update("accounts",{id:e,closed:1}),0!==a){let n=(await p.first("SELECT id FROM payees WHERE transfer_acct = ?",[t])).id;await ye["transaction-add"]({id:ce.v4Sync(),payee:n,amount:-a,account:e,date:T.d(),notes:"Closing account",category:r||null})}}})})),ye["account-reopen"]=Object(R.mutator)((async function({id:e}){return Object(m.f)(async()=>{await p.update("accounts",{id:e,closed:0})})})),ye["account-move"]=Object(R.mutator)((async function({id:e,targetId:t}){return Object(m.f)(async()=>{await p.moveAccount(e,t)})}));let _e=!1;async function we(e,t,{showUpdate:r}={}){let n;try{n=l.a.getBudgetDir(e)}catch(e){return Object(s.captureException)(new Error("`getBudgetDir` failed in `loadBudget`: "+e.message)),{error:"budget-not-found"}}if(Object(s.captureBreadcrumb)({message:"Loading budget "+n}),!await l.a.exists(n))return Object(s.captureException)(new Error("budget directory does not exist")),{error:"budget-not-found"};try{await u.c(e),await p.openDatabase(e)}catch(t){return Object(s.captureBreadcrumb)({message:"Error loading budget "+e}),Object(s.captureException)(t),await ye["close-budget"](),{error:"opening-budget"}}if(!u.b().userId){let e=re(await a.a.multiGet(["user-token"]),1),t=re(e[0],2)[1];u.d({userId:t})}let o=u.b(),c=o.budgetVersion;o.budgetId;try{await Object(y.a)(c,r)}catch(t){let r;return console.warn("Error updating",t),t.message.includes("out-of-sync-migrations")?r={error:"out-of-sync-migrations"}:t.message.includes("out-of-sync-data")?r={error:"out-of-sync-data"}:(Object(s.captureException)(t),d.a.info("Error updating budget "+e,t),console.log("Error updating budget",t),r={error:"loading-budget"}),await ye["close-budget"](),r}await p.loadClock(),u.b().resetClock&&(N.getClock().timestamp.setNode(N.makeClientId()),await p.runQuery("INSERT OR REPLACE INTO messages_clock (id, clock) VALUES (1, ?)",[N.serializeClock(N.getClock())]),await u.d({resetClock:!1})),h.a.isWeb||h.a.isMobile||i.__TESTING__||Object(S.d)(e);try{await g.e(p,me)}catch(e){return Object(s.captureException)(e),await ye["close-budget"](),{error:"opening-budget"}}return g.b().meta().budgetType=u.b().budgetType,await M.a(),await w.b(),await _.h(),await L.a(),await X.a.startServices(),Object(m.b)(),i.__TESTING__||("_demo-budget"===e?Object(C.k)("disabled"):"_test-budget"===e?await a.a.setItem("lastBudget",e):(Object(C.k)("enabled"),await a.a.setItem("lastBudget",e),h.a.isMobile||await z.e())),X.a.events.emit("load-budget",{id:e}),{}}function ve(){return h.a.isMobile?"/documents":l.a.join("/documents","Actual")}async function Ee(t,r,n){ge=t,await f.init(),await Promise.all([a.a.init(),l.a.init()]),await V.a(),await async function(){async function e(e){await l.a.exists(e)||await l.a.mkdir(e)}let t=await a.a.getItem("document-dir");if(t)try{await e(t)}catch(e){t=null}t||(t=ve()),await e(t),l.a._setDocumentDir(t)}();let o=await a.a.getItem("encrypt-keys");if(o)try{let e=JSON.parse(o);await Promise.all(Object.keys(e).map(t=>q.a.loadKey(e[t])))}catch(e){throw console.log("Error loading key",e),new Error("load-key-error")}if(r){await a.a.getItem("lastBudget")}const s=await a.a.getItem("server-url");if(s&&Object(U.b)(s),le.init(n,X.a.handlers),V.c("app:init",{platform:h.a.isMobile?"mobile":h.a.isWeb?"web":"desktop"}),!r&&!h.a.isMobile&&!h.a.isWeb){let t=await a.a.getItem("auto-update");e.send({type:"shouldAutoUpdate",flag:null==t||"true"===t})}r&&(i.$send=(e,t)=>Object(R.runHandler)(X.a.handlers[e],t),i.$query=K.b,i.$q=Z.b,i.$db=p,i.$setSyncingMode=C.k)}async function Se({budgetId:t,config:r}){let n,i;return ge=ACTUAL_APP_VERSION,r?(n=r.dataDir,i=r.serverURL):(n="/",i=e.env.ACTUAL_SERVER_URL),await f.init(),await Promise.all([a.a.init({persist:!1}),l.a.init()]),l.a._setDocumentDir(n||e.cwd()),i?Object(U.b)(i):(Object(U.b)(null),X.a.events.on("load-budget",()=>{Object(C.k)("offline")})),t&&await Object(R.runHandler)(ye["load-budget"],{id:t}),Oe}ye["poll-web-token"]=async function({token:e}){let t=re(await a.a.multiGet(["user-id","user-key"]),2),r=re(t[0],2)[1],n=re(t[1],2)[1],i=Date.now();return _e=!1,new Promise(t=>{!async function t(o){if(_e)return;if(Date.now()-i>=6e5)return void o("timeout");let a=await Object(G.post)(Object(U.a)().PLAID_SERVER+"/get-web-token-contents",{userId:r,key:n,token:e});a?a.error?o("unknown"):o(null,a):setTimeout(()=>t(o),3e3)}((e,r)=>{t(e?{error:e}:{data:r})})})},ye["poll-web-token-stop"]=async function(){return _e=!0,"ok"},ye["accounts-sync"]=async function({id:e}){let t=re(await a.a.multiGet(["user-id","user-key"]),2),r=re(t[0],2)[1],n=re(t[1],2)[1],i=await p.runQuery("SELECT a.*, b.id as bankId FROM accounts a\n LEFT JOIN banks b ON a.bank = b.id\n WHERE a.tombstone = 0 AND a.closed = 0",[],!0);e&&(i=i.filter(t=>t.id===e));let o=[],c=[],l=[],f=[];u.b().groupId;for(var d=0;d0||o.length>0)&&(f=f.concat(e.id))}catch(t){"BankSyncError"===t.type?o.push({type:"SyncError",accountId:e.id,message:'Failed syncing account "'+e.name+'".',category:t.category,code:t.code}):t instanceof Y.PostError&&"internal"!==t.reason?o.push({accountId:e.id,message:`Account "${e.name}" is not linked properly. Please link it again`}):(o.push({accountId:e.id,message:"There was an internal error. Please email help@actualbudget.com for support.",internal:t.stack}),t.message="Failed syncing account: "+t.message,Object(s.captureException)(t))}}return f.length>0&&le.send("sync-event",{type:"success",tables:["transactions"]}),{errors:o,newTransactions:c,matchedTransactions:l,updatedAccounts:f}},ye["transactions-import"]=Object(R.mutator)((function({accountId:e,transactions:t}){return Object(m.f)(async()=>{if("string"!=typeof e)throw Object(Y.APIError)("transactions-import: accountId must be an id");try{return await D.c(e,t)}catch(e){if(e instanceof Y.TransactionError)return{errors:[{message:e.message}],added:[],updated:[]};throw e}})})),ye["account-unlink"]=Object(R.mutator)((async function({id:e}){let t=(await p.first("SELECT bank FROM accounts WHERE id = ?",[e])).bank;if(!t)return"ok";if(await p.updateAccount({id:e,account_id:null,bank:null,balance_current:null,balance_available:null,balance_limit:null}),0===(await p.first("SELECT COUNT(*) as count FROM accounts WHERE bank = ?",[t])).count){let e=re(await a.a.multiGet(["user-id","user-key"]),2),r=re(e[0],2)[1],n=re(e[1],2)[1];await Object(G.post)(Object(U.a)().PLAID_SERVER+"/remove-access-token",{userId:r,key:n,item_id:t})}return"ok"})),ye["make-plaid-public-token"]=async function({bankId:e}){let t=re(await a.a.multiGet(["user-id","user-key"]),2),r=re(t[0],2)[1],n=re(t[1],2)[1],i=await Object(G.post)(Object(U.a)().PLAID_SERVER+"/make-public-token",{userId:r,key:n,item_id:""+e});return i.error_code?{error:"",code:i.error_code,type:i.error_type}:{linkToken:i.link_token}},ye["save-global-prefs"]=async function(t){return"maxMonths"in t&&await a.a.setItem("max-months",""+t.maxMonths),"trackUsage"in t&&(V.b(t.trackUsage),await a.a.setItem("track-usage",""+t.trackUsage)),"autoUpdate"in t&&(await a.a.setItem("auto-update",""+t.autoUpdate),e.send({type:"shouldAutoUpdate",flag:t.autoUpdate})),"documentDir"in t&&await l.a.exists(t.documentDir)&&await a.a.setItem("document-dir",t.documentDir),"floatingSidebar"in t&&await a.a.setItem("floating-sidebar",""+t.floatingSidebar),"ok"},ye["load-global-prefs"]=async function(){let e=re(await a.a.multiGet(["floating-sidebar","seen-tutorial","max-months","track-usage","auto-update","document-dir","encrypt-key"]),7),t=re(e[0],2)[1],r=re(e[1],2)[1],n=re(e[2],2)[1],i=re(e[3],2)[1],o=re(e[4],2)[1],s=re(e[5],2)[1],u=re(e[6],2)[1];return{floatingSidebar:"true"===t,seenTutorial:"true"===r,maxMonths:Object(O.p)(n||""),trackUsage:null==i||"true"===i,autoUpdate:null==o||"true"===o,documentDir:s||ve(),keyId:u&&JSON.parse(u).id}},ye["save-prefs"]=async function(e){let t=u.b().cloudFileId;if(e.budgetName&&t){let r=await a.a.getItem("user-token");await Object(G.post)(Object(U.a)().SYNC_SERVER+"/update-user-filename",{token:r,fileId:t,name:e.budgetName})}return await u.d(e),"ok"},ye["load-prefs"]=async function(){return u.b()},ye["sync-reset"]=async function(){return await Object(C.i)()},ye["sync-repair"]=async function(){await Object(C.h)()},ye["key-make"]=async function({password:e}){if(!u.b())throw new Error("user-set-key must be called with file loaded");u.b().cloudFileId;let t=q.a.randomBytes(32).toString("base64"),r=ce.v4Sync(),n=await q.a.createKey({id:r,password:e,salt:t});await q.a.loadKey(n);let i=await Object(C.g)(n.getId());return await Object(C.i)({key:n,salt:t,testContent:JSON.stringify(oe(oe({},i),{},{value:i.value.toString("base64")}))})},ye["key-test"]=async function({fileId:e,password:t}){let r,i=await a.a.getItem("user-token");null==e&&(e=u.b().cloudFileId);try{r=await Object(G.post)(Object(U.a)().SYNC_SERVER+"/user-get-key",{token:i,fileId:e})}catch(e){return console.log(e),{error:{reason:"network"}}}let o=r,s=o.id,c=o.salt,l=o.test;if(null==l)return{error:{reason:"old-key-style"}};l=JSON.parse(l);let f=await q.a.createKey({id:s,password:t,salt:c});q.a.loadKey(f);try{await q.a.decrypt(n.from(l.value,"base64"),l.meta)}catch(e){return console.log(e),q.a.unloadKey(f),{error:{reason:"decrypt-failure"}}}let d=JSON.parse(await a.a.getItem("encrypt-keys")||"{}");return d[e]=f.serialize(),await a.a.setItem("encrypt-keys",JSON.stringify(d)),u.b()&&await u.d({encryptKeyId:f.getId()}),{}},ye["should-pitch-subscribe"]=async function(){return"true"!==await a.a.getItem("seenSubscribe")},ye["has-pitched-subscribe"]=async function(){return await a.a.setItem("seenSubscribe","true"),"ok"},ye["subscribe-needs-bootstrap"]=async function({url:e}={}){let t;try{t=await Object(G.get)(Object(U.a)(e).SIGNUP_SERVER+"/needs-bootstrap")}catch(e){return{error:"network-failure"}}try{t=JSON.parse(t)}catch(e){return{error:"parse-failure"}}return"error"===t.status?{error:t.reason}:{bootstrapped:t.data.bootstrapped}},ye["subscribe-bootstrap"]=async function({password:e}){let t;try{t=await Object(G.post)(Object(U.a)().SIGNUP_SERVER+"/bootstrap",{password:e})}catch(e){return{error:e.reason||"network-failure"}}return t.token?(await a.a.setItem("user-token",t.token),{}):{error:"internal"}},ye["subscribe-set-user"]=async function({token:e}){await a.a.setItem("user-token",e)},ye["subscribe-get-user"]=async function(){let e=await a.a.getItem("user-token");if(e)try{let t=await Object(G.get)(Object(U.a)().SIGNUP_SERVER+"/validate",{headers:{"X-ACTUAL-TOKEN":e}});return t=JSON.parse(t),"error"===t.status?"unauthorized"===t.reason?null:{offline:!0}:{offline:!1}}catch(e){return console.log(e),{offline:!0}}return null},ye["subscribe-change-password"]=async function({password:e}){let t,r=await a.a.getItem("user-token");try{t=await Object(G.post)(Object(U.a)().SIGNUP_SERVER+"/change-password",{token:r,password:e})}catch(e){return{error:e.reason||"network-failure"}}return{}},ye["subscribe-sign-in"]=async function({password:e}){let t=await Object(G.post)(Object(U.a)().SIGNUP_SERVER+"/login",{password:e});return t.token?(await a.a.setItem("user-token",t.token),{}):{error:"invalid-password"}},ye["subscribe-sign-out"]=async function(){return q.a.unloadAllKeys(),await a.a.multiRemove(["user-token","encrypt-keys","lastBudget","readOnly"]),"ok"},ye["get-server-url"]=async function(){return Object(U.a)()&&Object(U.a)().BASE_SERVER},ye["set-server-url"]=async function({url:e}){let t=(await Object(R.runHandler)(ye["subscribe-needs-bootstrap"],{url:e})).error;return t?{error:t}:(a.a.setItem("server-url",e),Object(U.b)(e),{})},ye.sync=async function(){return Object(C.e)()},ye["get-version"]=async function(){return{version:ge}},ye["get-budgets"]=async function(){const e=await l.a.listDir(l.a.getDocumentDir());return(await Promise.all(e.map(async e=>{const t=l.a.join(l.a.getDocumentDir(),e,"metadata.json");if(await l.a.exists(t)){let r;try{r=JSON.parse(await l.a.readFile(t))}catch(e){return void console.log("Error parsing metadata:",e.stack)}if("_demo-budget"!==e)return{id:e,cloudFileId:r.cloudFileId,groupId:r.groupId,name:r.budgetName||"(no name)"}}return null}))).filter(e=>e)},ye["get-ynab4-files"]=async function(){return se.findBudgets()},ye["get-remote-files"]=async function(){return z.d()},ye["reset-budget-cache"]=Object(R.mutator)((async function(){await g.f(p),g.b().recomputeAll(),await g.j()})),ye["upload-budget"]=async function({id:e}={}){if(e){if(u.b())throw new Error("upload-budget: id given but prefs already loaded");await u.c(e)}try{await z.h()}catch(e){return console.log(e),"FileUploadError"===e.type?{error:e}:(Object(s.captureException)(e),{error:{reason:"internal"}})}finally{e&&u.e()}return{}},ye["download-budget"]=async function({fileId:e,replace:t}){let r;try{r=await z.b(e,t)}catch(e){if("FileDownloadError"===e.type){if("file-exists"===e.reason&&e.meta.id){await u.c(e.meta.id);let t=u.b().budgetName;u.e(),e.meta=oe(oe({},e.meta),{},{name:t})}return{error:e}}return Object(s.captureException)(e),{error:{reason:"internal"}}}let n=r.id;return r=await we(r.id,ge,{showUpdate:!0}),r.error?{error:{reason:r.error}}:(Object(C.k)("enabled"),await Object(C.f)(),await ye["close-budget"](),{id:n})},ye["load-budget"]=async function({id:e}){let t=u.b();if(t){if(t.id===e)return{};await ye["close-budget"]()}let r=await we(e,ge,{showUpdate:!0});return async function(){let t=async t=>{let r=l.a.join(l.a.getBudgetDir(e),t);try{return await l.a.size(r)}catch(e){return null}};try{let e=await t("db.sqlite"),r=await t("cache.sqlite");V.c("app:load-budget",{size:e,cacheSize:r})}catch(e){console.warn(e)}}(),r},ye["create-demo-budget"]=async function(){return await a.a.setItem("readOnly",""),ye["create-budget"]({budgetName:"Demo Budget",testMode:!0,testBudgetId:"_demo-budget"})},ye["close-budget"]=async function(){Object(s.captureBreadcrumb)({message:"Closing budget"}),await g.j(),g.i(),Object(C.d)(),await X.a.stopServices(),await p.closeDatabase();try{await a.a.setItem("lastBudget","")}catch(e){}return u.e(),Object(S.e)(),"ok"},ye["delete-budget"]=async function({id:e,cloudFileId:t}){if(t&&await z.f(t).catch(e=>{}),e){let t=l.a.getBudgetDir(e);await l.a.removeDirRecursively(t)}return"ok"},ye["create-budget"]=async function({budgetName:e,avoidUpload:t,testMode:r,testBudgetId:n}={}){let i;if(r)e=e||"Test Budget",i=n||"_test-budget",await l.a.exists(l.a.getBudgetDir(i))&&await l.a.removeDirRecursively(l.a.getBudgetDir(i));else{if(!e){let t=await ye["get-budgets"]();e=await Object(j.b)(t)}i=await Object(j.a)(e)}let o=l.a.getBudgetDir(i);await l.a.mkdir(o),await l.a.copyFile(l.a.bundledDatabasePath,l.a.join(o,"db.sqlite")),await l.a.writeFile(l.a.join(o,"metadata.json"),JSON.stringify(u.a(i,e)));let a=(await we(i,ge)).error;if(a)return console.log("Error creating budget: "+a),{error:a};if(!t&&!r)try{await z.h()}catch(e){}return r&&await Object($.a)(ye),{}},ye["set-tutorial-seen"]=async function(){return await a.a.setItem("seen-tutorial","true"),"ok"},ye["import-budget"]=async function({filepath:e,type:t}){try{if(!await l.a.exists(e))throw new Error("File not found at the provided path: "+e);let r=n.from(await l.a.readFile(e,"binary"));switch(t){case"ynab4":try{await se.importBuffer(e,r)}catch(e){let t=e.message.toLowerCase();if(t.includes("not a ynab4")||t.includes("could not find file"))return{error:"not-ynab4"}}break;case"ynab5":let t;try{t=JSON.parse(r.toString())}catch(e){return{error:"parse-error"}}try{await ue.importYNAB5(t)}catch(e){return{error:"not-ynab5"}}}}catch(e){return e.message="Error importing budget: "+e.message,Object(s.captureException)(e),{error:"internal-error"}}return{}},ye["export-budget"]=async function(){return await z.c()},ye["get-upgrade-notifications"]=async function(){let e=u.b().id;if("_test-budget"===e||"_demo-budget"===e)return[];let t=["schedules","repair-splits"],r=[];for(let e of t){let t="notifications."+e;null==u.b()[t]&&r.push(e)}return r},ye["seen-upgrade-notification"]=async function({type:e}){let t="notifications."+e;u.d({[t]:!0})},ye["upload-file-web"]=async function({filename:e,contents:t}){return h.a.isWeb?(await l.a.writeFile("/uploads/"+e,t),"ok"):null},ye["backups-get"]=async function({id:e}){return Object(S.a)(e)},ye["backup-load"]=async function({id:e,backupId:t}){await Object(S.b)(e,t)},ye["backup-make"]=async function({id:e}){await Object(S.c)(e)},ye["get-last-opened-backup"]=async function(){const e=await a.a.getItem("lastBudget");if(e&&""!==e){const t=l.a.getBudgetDir(e);if(await l.a.exists(t))return e}return null},ye["app-focused"]=async function(){u.b()&&u.b().id&&Object(C.e)()},ye.track=async function({name:e,props:t}){V.c(e,t)},ye=Object(F.a)(ye),H.a.send=(e,t)=>Object(R.runHandler)(X.a.handlers[e],t),X.a.handlers=ye,X.a.combine(J.a,Q.a,ee.a,te.a);const Oe={getDataDir:l.a.getDataDir,sendMessage:(e,t)=>le.send(e,t),send:async(e,t)=>await Object(R.runHandler)(X.a.handlers[e],t),on:(e,t)=>X.a.events.on(e,t),syncAndReceiveMessages:C.l,q:Z.b,db:p,merkle:k,timestamp:N,SyncProtoBuf:pe}}.call(this,r(19),r(10).Buffer,r(23))},function(e,t,r){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=c(e),a=n[0],s=n[1],u=new o(function(e,t,r){return 3*(t+r)/4-r}(0,a,s)),l=0,f=s>0?a-4:a;for(r=0;r>16&255,u[l++]=t>>8&255,u[l++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[l++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,r){for(var i,o,a=[],s=t;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ t.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,l=-7,f=r?i-1:0,d=r?-1:1,h=e[t+f];for(f+=d,o=h&(1<<-l)-1,h>>=-l,l+=s;l>0;o=256*o+e[t+f],f+=d,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=n;l>0;a=256*a+e[t+f],f+=d,l-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(h?-1:1);a+=Math.pow(2,n),o-=c}return(h?-1:1)*a*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var a,s,u,c=8*o-i-1,l=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+f>=1?d/u:d*Math.pow(2,1-f))*u>=2&&(a++,u/=2),a+f>=l?(s=0,a=l):a+f>=1?(s=(t*u-1)*Math.pow(2,i),a+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,i),a=0));i>=8;e[r+h]=255&s,h+=p,s/=256,i-=8);for(a=a<0;e[r+h]=255&a,h+=p,a/=256,c-=8);e[r+h-p]|=128*g}},function(e,t){},function(e,t,r){"use strict"},function(e,t,r){"use strict";function n(e){var t=this;if(t instanceof n||(t=new n),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var r=0,i=arguments.length;r1)r=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");n=this.head.next,r=this.head.value}for(var i=0;null!==n;i++)r=e(r,n.value,i),n=n.next;return r},n.prototype.reduceReverse=function(e,t){var r,n=this.tail;if(arguments.length>1)r=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");n=this.tail.prev,r=this.tail.value}for(var i=this.length-1;null!==n;i--)r=e(r,n.value,i),n=n.prev;return r},n.prototype.toArray=function(){for(var e=new Array(this.length),t=0,r=this.head;null!==r;t++)e[t]=r.value,r=r.next;return e},n.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,r=this.tail;null!==r;t++)e[t]=r.value,r=r.prev;return e},n.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new n;if(tthis.length&&(t=this.length);for(var i=0,o=this.head;null!==o&&ithis.length&&(t=this.length);for(var i=this.length,o=this.tail;null!==o&&i>t;i--)o=o.prev;for(;null!==o&&i>e;i--,o=o.prev)r.push(o.value);return r},n.prototype.splice=function(e,t){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var r=0,n=this.head;null!==n&&r>>0===e}function Ie(e){if(!De(e))throw TypeError(F)}function je(e){if("string"==typeof e&&+e==e)return+e;if(e instanceof Date)return e.getTime()/1e3;if(isFinite(e))return e<0?Date.now()/1e3:e;throw new Error("Cannot parse time: "+e)}function Re(e){if("number"!=typeof e)throw TypeError(z)}function Ne(e){if("number"!=typeof e)throw TypeError(q)}t.filenameToSteps=Ee,t.pathToSteps=Se,t.dataToStr=function(e,t){return void 0===t&&(t=_.ENCODING_UTF8),d.Buffer.isBuffer(e)?e.toString(t):e instanceof Uint8Array?d.bufferFrom(e).toString(t):String(e)},t.dataToBuffer=Oe,t.bufferToEncoding=Te,t.toUnixTimestamp=je;var ke=function(){function e(e){void 0===e&&(e={}),this.ino=0,this.inodes={},this.releasedInos=[],this.fds={},this.releasedFds=[],this.maxFiles=1e4,this.openFiles=0,this.promisesApi=E.default(this),this.statWatchers={},this.props=Object.assign({Node:c.Node,Link:c.Link,File:c.File},e);var t=this.createLink();t.setNode(this.createNode(!0));var r=this;this.StatWatcher=function(e){function t(){return e.call(this,r)||this}return i(t,e),t}(xe);var n=Pe;this.ReadStream=function(e){function t(){for(var t=[],n=0;n1){var o=a+i.slice(0,i.length-1).join(a);this.mkdirpBase(o,511)}this.writeFileSync(r,n)}else this.mkdirpBase(r,511)}},e.prototype.reset=function(){this.ino=0,this.inodes={},this.releasedInos=[],this.fds={},this.releasedFds=[],this.openFiles=0,this.root=this.createLink(),this.root.setNode(this.createNode(!0))},e.prototype.mountSync=function(e,t){this.fromJSON(t,e)},e.prototype.openLink=function(e,t,r){if(void 0===r&&(r=!0),this.openFiles>=this.maxFiles)throw G("EMFILE","open",e.getPath());var n=e;if(r&&(n=this.resolveSymlinks(e)),!n)throw G(V,"open",e.getPath());var i=n.getNode();if(i.isDirectory()){if((t&(O|A|T))!==O)throw G("EISDIR","open",e.getPath())}else if(t&N)throw G("ENOTDIR","open",e.getPath());if(!(t&T||i.canRead()))throw G("EACCES","open",e.getPath());var o=new this.props.File(e,i,t,this.newFdNumber());return this.fds[o.fd]=o,this.openFiles++,t&I&&o.truncate(),o},e.prototype.openFile=function(e,t,r,n){void 0===n&&(n=!0);var i=Ee(e),o=n?this.getResolvedLink(i):this.getLink(i);if(!o&&t&M){var s=this.getResolvedLink(i.slice(0,i.length-1));if(!s)throw G(V,"open",a+i.join(a));t&M&&"number"==typeof r&&(o=this.createLink(s,i[i.length-1],!1,r))}if(o)return this.openLink(o,t,n);throw G(V,"open",e)},e.prototype.openBase=function(e,t,r,n){void 0===n&&(n=!0);var i=this.openFile(e,t,r,n);if(!i)throw G(V,"open",e);return i.fd},e.prototype.openSync=function(e,t,r){void 0===r&&(r=438);var n=Me(r),i=be(e),o=Y(t);return this.openBase(i,o,n)},e.prototype.open=function(e,t,r,n){var i=r,o=n;"function"==typeof r&&(i=438,o=r);var a=Me(i=i||438),s=be(e),u=Y(t);this.wrapAsync(this.openBase,[s,u,a],o)},e.prototype.closeFile=function(e){this.fds[e.fd]&&(this.openFiles--,delete this.fds[e.fd],this.releasedFds.push(e.fd))},e.prototype.closeSync=function(e){Ie(e);var t=this.getFileByFdOrThrow(e,"close");this.closeFile(t)},e.prototype.close=function(e,t){Ie(e),this.wrapAsync(this.closeSync,[e],t)},e.prototype.openFileOrGetById=function(e,t,r){if("number"==typeof e){var n=this.fds[e];if(!n)throw G(V);return n}return this.openFile(be(e),t,r)},e.prototype.readBase=function(e,t,r,n,i){return this.getFileByFdOrThrow(e).read(t,Number(r),Number(n),i)},e.prototype.readSync=function(e,t,r,n,i){return Ie(e),this.readBase(e,t,r,n,i)},e.prototype.read=function(e,t,r,n,i,o){var a=this;if(Z(o),0===n)return p.default.nextTick((function(){o&&o(null,0,t)}));h.default((function(){try{var s=a.readBase(e,t,r,n,i);o(null,s,t)}catch(e){o(e)}}))},e.prototype.readFileBase=function(e,t,r){var n,i,o="number"==typeof e&&De(e);if(o)i=e;else{var a=Ee(be(e)),s=this.getResolvedLink(a);if(s)if(s.getNode().isDirectory())throw G("EISDIR","open",s.getPath());i=this.openSync(e,t)}try{n=Te(this.getFileByFdOrThrow(i).getBuffer(),r)}finally{o||this.closeSync(i)}return n},e.prototype.readFileSync=function(e,t){var r=te(t),n=Y(r.flag);return this.readFileBase(e,n,r.encoding)},e.prototype.readFile=function(e,t,r){var n=X(te)(t,r),i=n[0],o=n[1],a=Y(i.flag);this.wrapAsync(this.readFileBase,[e,a,i.encoding],o)},e.prototype.writeBase=function(e,t,r,n,i){return this.getFileByFdOrThrow(e,"write").write(t,r,n,i)},e.prototype.writeSync=function(e,t,r,n,i){var o,a,s,u;Ie(e);var c="string"!=typeof t;c?(a=0|(r||0),s=n,u=i):(u=r,o=n);var l=Oe(t,o);return c?void 0===s&&(s=l.length):(a=0,s=l.length),this.writeBase(e,l,a,s,u)},e.prototype.write=function(e,t,r,n,i,o){var a,s,u,c,l,f=this;Ie(e);var d=typeof t,p=typeof r,g=typeof n,m=typeof i;"string"!==d?"function"===p?l=r:"function"===g?(a=0|r,l=n):"function"===m?(a=0|r,s=n,l=i):(a=0|r,s=n,u=i,l=o):"function"===p?l=r:"function"===g?(u=r,l=n):"function"===m&&(u=r,c=n,l=i);var y=Oe(t,c);"string"!==d?void 0===s&&(s=y.length):(a=0,s=y.length);var b=Z(l);h.default((function(){try{var r=f.writeBase(e,y,a,s,u);b(null,r,"string"!==d?y:t)}catch(e){b(e)}}))},e.prototype.writeFileBase=function(e,t,r,n){var i,o="number"==typeof e;i=o?e:this.openBase(be(e),r,n);var a=0,s=t.length,u=r&j?void 0:0;try{for(;s>0;){var c=this.writeSync(i,t,a,s,u);a+=c,s-=c,void 0!==u&&(u+=c)}}finally{o||this.closeSync(i)}},e.prototype.writeFileSync=function(e,t,r){var n=ne(r),i=Y(n.flag),o=Me(n.mode),a=Oe(t,n.encoding);this.writeFileBase(e,a,i,o)},e.prototype.writeFile=function(e,t,r,n){var i=r,o=n;"function"==typeof r&&(i=re,o=r);var a=Z(o),s=ne(i),u=Y(s.flag),c=Me(s.mode),l=Oe(t,s.encoding);this.wrapAsync(this.writeFileBase,[e,l,u,c],a)},e.prototype.linkBase=function(e,t){var r=Ee(e),n=this.getLink(r);if(!n)throw G(V,"link",e,t);var i=Ee(t),o=this.getLinkParent(i);if(!o)throw G(V,"link",e,t);var a=i[i.length-1];if(o.getChild(a))throw G("EEXIST","link",e,t);var s=n.getNode();s.nlink++,o.createChild(a,s)},e.prototype.copyFileBase=function(e,t,r){var n=this.readFileSync(e);if(r&C&&this.existsSync(t))throw G("EEXIST","copyFile",e,t);if(r&L)throw G("ENOSYS","copyFile",e,t);this.writeFileBase(t,n,P.w,438)},e.prototype.copyFileSync=function(e,t,r){var n=be(e),i=be(t);return this.copyFileBase(n,i,0|(r||0))},e.prototype.copyFile=function(e,t,r,n){var i,o,a=be(e),s=be(t);"function"==typeof r?(i=0,o=r):(i=r,o=n),Z(o),this.wrapAsync(this.copyFileBase,[a,s,i],o)},e.prototype.linkSync=function(e,t){var r=be(e),n=be(t);this.linkBase(r,n)},e.prototype.link=function(e,t,r){var n=be(e),i=be(t);this.wrapAsync(this.linkBase,[n,i],r)},e.prototype.unlinkBase=function(e){var t=Ee(e),r=this.getLink(t);if(!r)throw G(V,"unlink",e);if(r.length)throw Error("Dir not empty...");this.deleteLink(r);var n=r.getNode();n.nlink--,n.nlink<=0&&this.deleteNode(n)},e.prototype.unlinkSync=function(e){var t=be(e);this.unlinkBase(t)},e.prototype.unlink=function(e,t){var r=be(e);this.wrapAsync(this.unlinkBase,[r],t)},e.prototype.symlinkBase=function(e,t){var r=Ee(t),n=this.getLinkParent(r);if(!n)throw G(V,"symlink",e,t);var i=r[r.length-1];if(n.getChild(i))throw G("EEXIST","symlink",e,t);var o=n.createChild(i);return o.getNode().makeSymlink(Ee(e)),o},e.prototype.symlinkSync=function(e,t,r){var n=be(e),i=be(t);this.symlinkBase(n,i)},e.prototype.symlink=function(e,t,r,n){var i=Z("function"==typeof r?r:n),o=be(e),a=be(t);this.wrapAsync(this.symlinkBase,[o,a],i)},e.prototype.realpathBase=function(e,t){var r=Ee(e),n=this.getResolvedLink(r);if(!n)throw G(V,"realpath",e);return _.strToEncoding(n.getPath(),t)},e.prototype.realpathSync=function(e,t){return this.realpathBase(be(e),se(t).encoding)},e.prototype.realpath=function(e,t,r){var n=ue(t,r),i=n[0],o=n[1],a=be(e);this.wrapAsync(this.realpathBase,[a,i.encoding],o)},e.prototype.lstatBase=function(e,t){void 0===t&&(t=!1);var r=this.getLink(Ee(e));if(!r)throw G(V,"lstat",e);return l.default.build(r.getNode(),t)},e.prototype.lstatSync=function(e,t){return this.lstatBase(be(e),me(t).bigint)},e.prototype.lstat=function(e,t,r){var n=ye(t,r),i=n[0],o=n[1];this.wrapAsync(this.lstatBase,[be(e),i.bigint],o)},e.prototype.statBase=function(e,t){void 0===t&&(t=!1);var r=this.getResolvedLink(Ee(e));if(!r)throw G(V,"stat",e);return l.default.build(r.getNode(),t)},e.prototype.statSync=function(e,t){return this.statBase(be(e),me(t).bigint)},e.prototype.stat=function(e,t,r){var n=ye(t,r),i=n[0],o=n[1];this.wrapAsync(this.statBase,[be(e),i.bigint],o)},e.prototype.fstatBase=function(e,t){void 0===t&&(t=!1);var r=this.getFileByFd(e);if(!r)throw G("EBADF","fstat");return l.default.build(r.node,t)},e.prototype.fstatSync=function(e,t){return this.fstatBase(e,me(t).bigint)},e.prototype.fstat=function(e,t,r){var n=ye(t,r),i=n[0],o=n[1];this.wrapAsync(this.fstatBase,[e,i.bigint],o)},e.prototype.renameBase=function(e,t){var r=this.getLink(Ee(e));if(!r)throw G(V,"rename",e,t);var n=Ee(t),i=this.getLinkParent(n);if(!i)throw G(V,"rename",e,t);var a=r.parent;a&&a.deleteChild(r);var s=n[n.length-1];r.steps=o(i.steps,[s]),i.setChild(r.getName(),r)},e.prototype.renameSync=function(e,t){var r=be(e),n=be(t);this.renameBase(r,n)},e.prototype.rename=function(e,t,r){var n=be(e),i=be(t);this.wrapAsync(this.renameBase,[n,i],r)},e.prototype.existsBase=function(e){return!!this.statBase(e)},e.prototype.existsSync=function(e){try{return this.existsBase(be(e))}catch(e){return!1}},e.prototype.exists=function(e,t){var r=this,n=be(e);if("function"!=typeof t)throw Error(H);h.default((function(){try{t(r.existsBase(n))}catch(e){t(!1)}}))},e.prototype.accessBase=function(e,t){this.getLinkOrThrow(e,"access")},e.prototype.accessSync=function(e,t){void 0===t&&(t=k);var r=be(e);t|=0,this.accessBase(r,t)},e.prototype.access=function(e,t,r){var n,i=k;"function"!=typeof t?(i=0|t,n=Z(r)):n=t;var o=be(e);this.wrapAsync(this.accessBase,[o,i],n)},e.prototype.appendFileSync=function(e,t,r){void 0===r&&(r=ie);var n=oe(r);n.flag&&!De(e)||(n.flag="a"),this.writeFileSync(e,t,n)},e.prototype.appendFile=function(e,t,r,n){var i=ae(r,n),o=i[0],a=i[1];o.flag&&!De(e)||(o.flag="a"),this.writeFile(e,t,o,a)},e.prototype.readdirBase=function(e,t){var r=Ee(e),n=this.getResolvedLink(r);if(!n)throw G(V,"readdir",e);if(!n.getNode().isDirectory())throw G("ENOTDIR","scandir",e);if(t.withFileTypes){var i=[];for(var o in n.children){var a=n.getChild(o);a&&i.push(f.default.build(a,t.encoding))}return B||"buffer"===t.encoding||i.sort((function(e,t){return e.namet.name?1:0})),i}var s=[];for(var u in n.children)s.push(_.strToEncoding(u,t.encoding));return B||"buffer"===t.encoding||s.sort(),s},e.prototype.readdirSync=function(e,t){var r=he(t),n=be(e);return this.readdirBase(n,r)},e.prototype.readdir=function(e,t,r){var n=pe(t,r),i=n[0],o=n[1],a=be(e);this.wrapAsync(this.readdirBase,[a,i],o)},e.prototype.readlinkBase=function(e,t){var r=this.getLinkOrThrow(e,"readlink").getNode();if(!r.isSymlink())throw G("EINVAL","readlink",e);var n=a+r.symlink.join(a);return _.strToEncoding(n,t)},e.prototype.readlinkSync=function(e,t){var r=Q(t),n=be(e);return this.readlinkBase(n,r.encoding)},e.prototype.readlink=function(e,t,r){var n=ee(t,r),i=n[0],o=n[1],a=be(e);this.wrapAsync(this.readlinkBase,[a,i.encoding],o)},e.prototype.fsyncBase=function(e){this.getFileByFdOrThrow(e,"fsync")},e.prototype.fsyncSync=function(e){this.fsyncBase(e)},e.prototype.fsync=function(e,t){this.wrapAsync(this.fsyncBase,[e],t)},e.prototype.fdatasyncBase=function(e){this.getFileByFdOrThrow(e,"fdatasync")},e.prototype.fdatasyncSync=function(e){this.fdatasyncBase(e)},e.prototype.fdatasync=function(e,t){this.wrapAsync(this.fdatasyncBase,[e],t)},e.prototype.ftruncateBase=function(e,t){this.getFileByFdOrThrow(e,"ftruncate").truncate(t)},e.prototype.ftruncateSync=function(e,t){this.ftruncateBase(e,t)},e.prototype.ftruncate=function(e,t,r){var n="number"==typeof t?t:0,i=Z("number"==typeof t?r:t);this.wrapAsync(this.ftruncateBase,[e,n],i)},e.prototype.truncateBase=function(e,t){var r=this.openSync(e,"r+");try{this.ftruncateSync(r,t)}finally{this.closeSync(r)}},e.prototype.truncateSync=function(e,t){if(De(e))return this.ftruncateSync(e,t);this.truncateBase(e,t)},e.prototype.truncate=function(e,t,r){var n="number"==typeof t?t:0,i=Z("number"==typeof t?r:t);if(De(e))return this.ftruncate(e,n,i);this.wrapAsync(this.truncateBase,[e,n],i)},e.prototype.futimesBase=function(e,t,r){var n=this.getFileByFdOrThrow(e,"futimes").node;n.atime=new Date(1e3*t),n.mtime=new Date(1e3*r)},e.prototype.futimesSync=function(e,t,r){this.futimesBase(e,je(t),je(r))},e.prototype.futimes=function(e,t,r,n){this.wrapAsync(this.futimesBase,[e,je(t),je(r)],n)},e.prototype.utimesBase=function(e,t,r){var n=this.openSync(e,"r+");try{this.futimesBase(n,t,r)}finally{this.closeSync(n)}},e.prototype.utimesSync=function(e,t,r){this.utimesBase(be(e),je(t),je(r))},e.prototype.utimes=function(e,t,r,n){this.wrapAsync(this.utimesBase,[be(e),je(t),je(r)],n)},e.prototype.mkdirBase=function(e,t){var r=Ee(e);if(!r.length)throw G("EISDIR","mkdir",e);var n=this.getLinkParentAsDirOrThrow(e,"mkdir"),i=r[r.length-1];if(n.getChild(i))throw G("EEXIST","mkdir",e);n.createChild(i,this.createNode(!0,t))},e.prototype.mkdirpBase=function(e,t){for(var r=Ee(e),n=this.root,i=0;i1)return this.mkdtempBase(e,t,r-1);throw Error("Could not create temp dir.")}throw n}},e.prototype.mkdtempSync=function(e,t){var r=Q(t).encoding;if(!e||"string"!=typeof e)throw new TypeError("filename prefix is required");return Ae(e),this.mkdtempBase(e,r)},e.prototype.mkdtemp=function(e,t,r){var n=ee(t,r),i=n[0].encoding,o=n[1];if(!e||"string"!=typeof e)throw new TypeError("filename prefix is required");Ae(e)&&this.wrapAsync(this.mkdtempBase,[e,i],o)},e.prototype.rmdirBase=function(e,t){var r=de(t),n=this.getLinkAsDirOrThrow(e,"rmdir");if(n.length&&!r.recursive)throw G("ENOTEMPTY","rmdir",e);this.deleteLink(n)},e.prototype.rmdirSync=function(e,t){this.rmdirBase(be(e),t)},e.prototype.rmdir=function(e,t,r){var n=de(t),i=Z("function"==typeof t?t:r);this.wrapAsync(this.rmdirBase,[be(e),n],i)},e.prototype.fchmodBase=function(e,t){this.getFileByFdOrThrow(e,"fchmod").chmod(t)},e.prototype.fchmodSync=function(e,t){this.fchmodBase(e,Me(t))},e.prototype.fchmod=function(e,t,r){this.wrapAsync(this.fchmodBase,[e,Me(t)],r)},e.prototype.chmodBase=function(e,t){var r=this.openSync(e,"r+");try{this.fchmodBase(r,t)}finally{this.closeSync(r)}},e.prototype.chmodSync=function(e,t){var r=Me(t),n=be(e);this.chmodBase(n,r)},e.prototype.chmod=function(e,t,r){var n=Me(t),i=be(e);this.wrapAsync(this.chmodBase,[i,n],r)},e.prototype.lchmodBase=function(e,t){var r=this.openBase(e,A,0,!1);try{this.fchmodBase(r,t)}finally{this.closeSync(r)}},e.prototype.lchmodSync=function(e,t){var r=Me(t),n=be(e);this.lchmodBase(n,r)},e.prototype.lchmod=function(e,t,r){var n=Me(t),i=be(e);this.wrapAsync(this.lchmodBase,[i,n],r)},e.prototype.fchownBase=function(e,t,r){this.getFileByFdOrThrow(e,"fchown").chown(t,r)},e.prototype.fchownSync=function(e,t,r){Re(t),Ne(r),this.fchownBase(e,t,r)},e.prototype.fchown=function(e,t,r,n){Re(t),Ne(r),this.wrapAsync(this.fchownBase,[e,t,r],n)},e.prototype.chownBase=function(e,t,r){this.getResolvedLinkOrThrow(e,"chown").getNode().chown(t,r)},e.prototype.chownSync=function(e,t,r){Re(t),Ne(r),this.chownBase(be(e),t,r)},e.prototype.chown=function(e,t,r,n){Re(t),Ne(r),this.wrapAsync(this.chownBase,[be(e),t,r],n)},e.prototype.lchownBase=function(e,t,r){this.getLinkOrThrow(e,"lchown").getNode().chown(t,r)},e.prototype.lchownSync=function(e,t,r){Re(t),Ne(r),this.lchownBase(be(e),t,r)},e.prototype.lchown=function(e,t,r,n){Re(t),Ne(r),this.wrapAsync(this.lchownBase,[be(e),t,r],n)},e.prototype.watchFile=function(e,t,r){var n=be(e),i=t,o=r;if("function"==typeof i&&(o=t,i=null),"function"!=typeof o)throw Error('"watchFile()" requires a listener function');var a=5007,s=!0;i&&"object"==typeof i&&("number"==typeof i.interval&&(a=i.interval),"boolean"==typeof i.persistent&&(s=i.persistent));var u=this.statWatchers[n];return u||((u=new this.StatWatcher).start(n,s,a),this.statWatchers[n]=u),u.addListener("change",o),u},e.prototype.unwatchFile=function(e,t){var r=be(e),n=this.statWatchers[r];n&&("function"==typeof t?n.removeListener("change",t):n.removeAllListeners("change"),0===n.listenerCount("change")&&(n.stop(),delete this.statWatchers[r]))},e.prototype.createReadStream=function(e,t){return new this.ReadStream(e,t)},e.prototype.createWriteStream=function(e,t){return new this.WriteStream(e,t)},e.prototype.watch=function(e,t,r){var n=be(e),i=t;"function"==typeof t&&(r=t,i=null);var o=Q(i),a=o.persistent,s=o.recursive,u=o.encoding;void 0===a&&(a=!0),void 0===s&&(s=!1);var c=new this.FSWatcher;return c.start(n,a,s,u),r&&c.addListener("change",r),c},e.fd=2147483647,e}();function Ce(e){e.emit("stop")}t.Volume=ke;var Le,xe=function(e){function t(t){var r=e.call(this)||this;return r.onInterval=function(){try{var e=r.vol.statSync(r.filename);r.hasChanged(e)&&(r.emit("change",e,r.prev),r.prev=e)}finally{r.loop()}},r.vol=t,r}return i(t,e),t.prototype.loop=function(){this.timeoutRef=this.setTimeout(this.onInterval,this.interval)},t.prototype.hasChanged=function(e){return e.mtimeMs>this.prev.mtimeMs||e.nlink!==this.prev.nlink},t.prototype.start=function(e,t,r){void 0===t&&(t=!0),void 0===r&&(r=5007),this.filename=be(e),this.setTimeout=t?setTimeout:g.default,this.interval=r,this.prev=this.vol.statSync(this.filename),this.loop()},t.prototype.stop=function(){clearTimeout(this.timeoutRef),p.default.nextTick(Ce,this)},t}(b.EventEmitter);function Pe(e,t,r){if(!(this instanceof Pe))return new Pe(e,t,r);if(this._vol=e,void 0===(r=Object.assign({},$(r,{}))).highWaterMark&&(r.highWaterMark=65536),m.Readable.call(this,r),this.path=be(t),this.fd=void 0===r.fd?null:r.fd,this.flags=void 0===r.flags?"r":r.flags,this.mode=void 0===r.mode?438:r.mode,this.start=r.start,this.end=r.end,this.autoClose=void 0===r.autoClose||r.autoClose,this.pos=void 0,this.bytesRead=0,void 0!==this.start){if("number"!=typeof this.start)throw new TypeError('"start" option must be a Number');if(void 0===this.end)this.end=1/0;else if("number"!=typeof this.end)throw new TypeError('"end" option must be a Number');if(this.start>this.end)throw new Error('"start" option must be <= "end" option');this.pos=this.start}"number"!=typeof this.fd&&this.open(),this.on("end",(function(){this.autoClose&&this.destroy&&this.destroy()}))}function Be(e){this.close()}function Ue(e,t,r){if(!(this instanceof Ue))return new Ue(e,t,r);if(this._vol=e,r=Object.assign({},$(r,{})),m.Writable.call(this,r),this.path=be(t),this.fd=void 0===r.fd?null:r.fd,this.flags=void 0===r.flags?"w":r.flags,this.mode=void 0===r.mode?438:r.mode,this.start=r.start,this.autoClose=void 0===r.autoClose||!!r.autoClose,this.pos=void 0,this.bytesWritten=0,void 0!==this.start){if("number"!=typeof this.start)throw new TypeError('"start" option must be a Number');if(this.start<0)throw new Error('"start" must be >= zero');this.pos=this.start}r.encoding&&this.setDefaultEncoding(r.encoding),"number"!=typeof this.fd&&this.open(),this.once("finish",(function(){this.autoClose&&this.close()}))}t.StatWatcher=xe,v.inherits(Pe,m.Readable),t.ReadStream=Pe,Pe.prototype.open=function(){var e=this;this._vol.open(this.path,this.flags,this.mode,(function(t,r){if(t)return e.autoClose&&e.destroy&&e.destroy(),void e.emit("error",t);e.fd=r,e.emit("open",r),e.read()}))},Pe.prototype._read=function(e){if("number"!=typeof this.fd)return this.once("open",(function(){this._read(e)}));if(!this.destroyed){var t;(!Le||Le.length-Le.used<128)&&(t=this._readableState.highWaterMark,(Le=d.bufferAllocUnsafe(t)).used=0);var r=Le,n=Math.min(Le.length-Le.used,e),i=Le.used;if(void 0!==this.pos&&(n=Math.min(this.end-this.pos+1,n)),n<=0)return this.push(null);var o=this;this._vol.read(this.fd,Le,Le.used,n,this.pos,(function(e,t){if(e)o.autoClose&&o.destroy&&o.destroy(),o.emit("error",e);else{var n=null;t>0&&(o.bytesRead+=t,n=r.slice(i,i+t)),o.push(n)}})),void 0!==this.pos&&(this.pos+=n),Le.used+=n}},Pe.prototype._destroy=function(e,t){this.close((function(r){t(e||r)}))},Pe.prototype.close=function(e){var t=this;if(e&&this.once("close",e),this.closed||"number"!=typeof this.fd)return"number"!=typeof this.fd?void this.once("open",Be):p.default.nextTick((function(){return t.emit("close")}));this.closed=!0,this._vol.close(this.fd,(function(e){e?t.emit("error",e):t.emit("close")})),this.fd=null},v.inherits(Ue,m.Writable),t.WriteStream=Ue,Ue.prototype.open=function(){this._vol.open(this.path,this.flags,this.mode,function(e,t){if(e)return this.autoClose&&this.destroy&&this.destroy(),void this.emit("error",e);this.fd=t,this.emit("open",t)}.bind(this))},Ue.prototype._write=function(e,t,r){if(!(e instanceof d.Buffer))return this.emit("error",new Error("Invalid data"));if("number"!=typeof this.fd)return this.once("open",(function(){this._write(e,t,r)}));var n=this;this._vol.write(this.fd,e,0,e.length,this.pos,(function(e,t){if(e)return n.autoClose&&n.destroy&&n.destroy(),r(e);n.bytesWritten+=t,r()})),void 0!==this.pos&&(this.pos+=e.length)},Ue.prototype._writev=function(e,t){if("number"!=typeof this.fd)return this.once("open",(function(){this._writev(e,t)}));for(var r=this,n=e.length,i=new Array(n),o=0,a=0;athis.buf.length){var i=a.bufferAllocUnsafe(n+r);this.buf.copy(i,0,0,this.buf.length),this.buf=i}return e.copy(this.buf,n,t,t+r),this.touch(),r},t.prototype.read=function(e,t,r,n){void 0===t&&(t=0),void 0===r&&(r=e.byteLength),void 0===n&&(n=0),this.buf||(this.buf=a.bufferAllocUnsafe(0));var i=r;return i>e.byteLength&&(i=e.byteLength),i+n>this.buf.length&&(i=this.buf.length-n),this.buf.copy(e,t,n,n+i),i},t.prototype.truncate=function(e){if(void 0===e&&(e=0),e)if(this.buf||(this.buf=a.bufferAllocUnsafe(0)),e<=this.buf.length)this.buf=this.buf.slice(0,e);else{var t=a.bufferAllocUnsafe(0);this.buf.copy(t),t.fill(0,e)}else this.buf=a.bufferAllocUnsafe(0);this.touch()},t.prototype.chmod=function(e){this.perm=e,this.mode=-512&this.mode|e,this.touch()},t.prototype.chown=function(e,t){this.uid=e,this.gid=t,this.touch()},t.prototype.touch=function(){this.mtime=new Date,this.emit("change",this)},t.prototype.canRead=function(e,t){return void 0===e&&(e=o.default.getuid()),void 0===t&&(t=o.default.getgid()),!!(4&this.perm)||(!!(t===this.gid&&32&this.perm)||!!(e===this.uid&&256&this.perm))},t.prototype.canWrite=function(e,t){return void 0===e&&(e=o.default.getuid()),void 0===t&&(t=o.default.getgid()),!!(2&this.perm)||(!!(t===this.gid&&16&this.perm)||!!(e===this.uid&&128&this.perm))},t.prototype.del=function(){this.emit("delete",this)},t.prototype.toJSON=function(){return{ino:this.ino,uid:this.uid,gid:this.gid,atime:this.atime.getTime(),mtime:this.mtime.getTime(),ctime:this.ctime.getTime(),perm:this.perm,mode:this.mode,nlink:this.nlink,symlink:this.symlink,data:this.getString()}},t}(u.EventEmitter);t.Node=g;var m=function(e){function r(t,r,n){var i=e.call(this)||this;return i.children={},i.steps=[],i.ino=0,i.length=0,i.vol=t,i.parent=r,i.steps=r?r.steps.concat([n]):[n],i}return i(r,e),r.prototype.setNode=function(e){this.node=e,this.ino=e.ino},r.prototype.getNode=function(){return this.node},r.prototype.createChild=function(e,t){void 0===t&&(t=this.vol.createNode());var n=new r(this.vol,this,e);return n.setNode(t),t.isDirectory(),this.setChild(e,n),n},r.prototype.setChild=function(e,t){return void 0===t&&(t=new r(this.vol,this,e)),this.children[e]=t,t.parent=this,this.length++,this.emit("child:add",t,this),t},r.prototype.deleteChild=function(e){delete this.children[e.getName()],this.length--,this.emit("child:delete",e,this)},r.prototype.getChild=function(e){if(Object.hasOwnProperty.call(this.children,e))return this.children[e]},r.prototype.getPath=function(){return this.steps.join(t.SEP)},r.prototype.getName=function(){return this.steps[this.steps.length-1]},r.prototype.walk=function(e,t,r){if(void 0===t&&(t=e.length),void 0===r&&(r=0),r>=e.length)return this;if(r>=t)return this;var n=e[r],i=this.getChild(n);return i?i.walk(e,t,r+1):null},r.prototype.toJSON=function(){return{steps:this.steps,ino:this.ino,children:Object.keys(this.children)}},r}(u.EventEmitter);t.Link=m;var y=function(){function e(e,t,r,n){this.position=0,this.link=e,this.node=t,this.flags=r,this.fd=n}return e.prototype.getString=function(e){return void 0===e&&(e="utf8"),this.node.getString()},e.prototype.setString=function(e){this.node.setString(e)},e.prototype.getBuffer=function(){return this.node.getBuffer()},e.prototype.setBuffer=function(e){this.node.setBuffer(e)},e.prototype.getSize=function(){return this.node.getSize()},e.prototype.truncate=function(e){this.node.truncate(e)},e.prototype.seekTo=function(e){this.position=e},e.prototype.stats=function(){return c.default.build(this.node)},e.prototype.write=function(e,t,r,n){void 0===t&&(t=0),void 0===r&&(r=e.length),"number"!=typeof n&&(n=this.position),this.flags&p&&(n=this.getSize());var i=this.node.write(e,t,r,n);return this.position=n+i,i},e.prototype.read=function(e,t,r,n){void 0===t&&(t=0),void 0===r&&(r=e.byteLength),"number"!=typeof n&&(n=this.position);var i=this.node.read(e,t,r,n);return this.position=n+i,i},e.prototype.chmod=function(e){this.node.chmod(e)},e.prototype.chown=function(e,t){this.node.chown(e,t)},e}();t.File=y},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,i,o,a,s,u=1,c={},l=!1,f=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick((function(){p(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){p(e.data)},n=function(e){o.port2.postMessage(e)}):f&&"onreadystatechange"in f.createElement("script")?(i=f.documentElement,n=function(e){var t=f.createElement("script");t.onreadystatechange=function(){p(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):n=function(e){setTimeout(p,0,e)}:(a="setImmediate$"+Math.random()+"$",s=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(a)&&p(+t.data.slice(a.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),n=function(t){e.postMessage(a+t,"*")}),d.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,o=n.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,r=o,i=s,t.copy(r,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,r){"use strict";e.exports=o;var n=r(189),i=Object.create(r(100));function o(e){if(!(this instanceof o))return new o(e);n.call(this,e)}i.inherits=r(11),i.inherits(o,n),o.prototype._transform=function(e,t,r){r(null,e)}},function(e,t,r){e.exports=r(144)},function(e,t,r){e.exports=r(79)},function(e,t,r){e.exports=r(142).Transform},function(e,t,r){e.exports=r(142).PassThrough},function(e,t,r){"use strict";var n=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(c),f=["%","/","?",";","#"].concat(l),d=["/","?","#"],h=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},m={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=r(311);function _(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o127?k+="x":k+=N[C];if(!k.match(h)){var x=j.slice(0,M),P=j.slice(M+1),B=N.match(p);B&&(x.push(B[1]),P.unshift(B[2])),P.length&&(_="/"+P.join(".")+_),this.hostname=x.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),I||(this.hostname=n.toASCII(this.hostname));var U=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+U,this.href+=this.host,I&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!g[E])for(M=0,R=l.length;M0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift());return r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var T=S.slice(-1)[0],A=(r.host||e.host||S.length>1)&&("."===T||".."===T)||""===T,M=0,D=S.length;D>=0;D--)"."===(T=S[D])?S.splice(D,1):".."===T?(S.splice(D,1),M++):M&&(S.splice(D,1),M--);if(!v&&!E)for(;M--;M)S.unshift("..");!v||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),A&&"/"!==S.join("/").substr(-1)&&S.push("");var I,j=""===S[0]||S[0]&&"/"===S[0].charAt(0);O&&(r.hostname=r.host=j?"":S.length?S.shift():"",(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift()));return(v=v||r.host&&S.length)&&!j&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,r){(function(e,n){var i;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(o){t&&t.nodeType,e&&e.nodeType;var a="object"==typeof n&&n;a.global!==a&&a.window!==a&&a.self;var s,u=2147483647,c=/^xn--/,l=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,d={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},h=Math.floor,p=String.fromCharCode;function g(e){throw new RangeError(d[e])}function m(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function y(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+m((e=e.replace(f,".")).split("."),t).join(".")}function b(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=p((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=p(e)})).join("")}function w(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function v(e,t,r){var n=0;for(e=r?h(e/700):e>>1,e+=h(e/t);e>455;n+=36)e=h(e/35);return h(n+36*e/(e+38))}function E(e){var t,r,n,i,o,a,s,c,l,f,d,p=[],m=e.length,y=0,b=128,w=72;for((r=e.lastIndexOf("-"))<0&&(r=0),n=0;n=128&&g("not-basic"),p.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=m&&g("invalid-input"),((c=(d=e.charCodeAt(i++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:36)>=36||c>h((u-y)/a))&&g("overflow"),y+=c*a,!(c<(l=s<=w?1:s>=w+26?26:s-w));s+=36)a>h(u/(f=36-l))&&g("overflow"),a*=f;w=v(y-o,t=p.length+1,0==o),h(y/t)>u-b&&g("overflow"),b+=h(y/t),y%=t,p.splice(y++,0,b)}return _(p)}function S(e){var t,r,n,i,o,a,s,c,l,f,d,m,y,_,E,S=[];for(m=(e=b(e)).length,t=128,r=0,o=72,a=0;a=t&&dh((u-r)/(y=n+1))&&g("overflow"),r+=(s-t)*y,t=s,a=0;au&&g("overflow"),d==t){for(c=r,l=36;!(c<(f=l<=o?1:l>=o+26?26:l-o));l+=36)E=c-f,_=36-f,S.push(p(w(f+E%_,0))),c=h(E/_);S.push(p(w(c,0))),o=v(r,y,n==i),r=0,++n}++r,++t}return S.join("")}s={version:"1.4.1",ucs2:{decode:b,encode:_},decode:E,encode:S,toASCII:function(e){return y(e,(function(e){return l.test(e)?"xn--"+S(e):e}))},toUnicode:function(e){return y(e,(function(e){return c.test(e)?E(e.slice(4).toLowerCase()):e}))}},void 0===(i=function(){return s}.call(t,r,t,e))||(e.exports=i)}()}).call(this,r(97)(e),r(23))},function(e,t,r){"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},function(e,t,r){"use strict";t.decode=t.parse=r(312),t.encode=t.stringify=r(313)},function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,r,o){t=t||"&",r=r||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var l=0;l=0?(f=g.substr(0,m),d=g.substr(m+1)):(f=g,d=""),h=decodeURIComponent(f),p=decodeURIComponent(d),n(a,h)?i(a[h])?a[h].push(p):a[h]=[a[h],p]:a[h]=p}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,r,s){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),(function(a){var s=encodeURIComponent(n(a))+r;return i(e[a])?o(e[a],(function(e){return s+encodeURIComponent(n(e))})).join(t):s+encodeURIComponent(n(e[a]))})).join(t):s?encodeURIComponent(n(s))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n0&&("/"===n||r&&"\\"===n)}function i(e,t){if("string"!=typeof e)throw new TypeError("expected a string");return e=e.replace(/[\\\/]+/g,"/"),!1!==t&&(e=function(e){var t=e.length-1;if(t<2)return e;for(;n(e,t);)t--;return e.substr(0,t+1)}(e)),e}function o(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return r?(e=i(e,t)).replace(/^([a-zA-Z]+:|\.\/)/,""):e}}).call(this,r(19))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.fsProps=["constants","F_OK","R_OK","W_OK","X_OK","Stats"],t.fsSyncMethods=["renameSync","ftruncateSync","truncateSync","chownSync","fchownSync","lchownSync","chmodSync","fchmodSync","lchmodSync","statSync","lstatSync","fstatSync","linkSync","symlinkSync","readlinkSync","realpathSync","unlinkSync","rmdirSync","mkdirSync","mkdirpSync","readdirSync","closeSync","openSync","utimesSync","futimesSync","fsyncSync","writeSync","readSync","readFileSync","writeFileSync","appendFileSync","existsSync","accessSync","fdatasyncSync","mkdtempSync","copyFileSync","createReadStream","createWriteStream"],t.fsAsyncMethods=["rename","ftruncate","truncate","chown","fchown","lchown","chmod","fchmod","lchmod","stat","lstat","fstat","link","symlink","readlink","realpath","unlink","rmdir","mkdir","mkdirp","readdir","close","open","utimes","futimes","fsync","write","read","readFile","writeFile","appendFile","exists","access","fdatasync","mkdtemp","copyFile","watchFile","unwatchFile","watch"]},function(e,t,r){(t=e.exports=r(192)).Stream=t,t.Readable=t,t.Writable=r(196),t.Duplex=r(86),t.Transform=r(197),t.PassThrough=r(322),t.finished=r(147),t.pipeline=r(323)},function(e,t){},function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){for(var r=0;r0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return a.alloc(0);for(var t,r,n,i=a.allocUnsafe(e>>>0),o=this.head,s=0;o;)t=o.data,r=i,n=s,a.prototype.copy.call(t,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var r;return ei.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0==(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=a.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:u,value:function(e,t){return s(this,function(e){for(var t=1;t0,(function(e){n||(n=e),e&&a.forEach(c),o||(a.forEach(c),i(n))}))}));return t.reduce(l)}},function(e,t,r){var n=r(11),i=r(87),o=r(16).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<30|e>>>2}function l(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,f=0;f<16;++f)r[f]=e.readInt32BE(4*f);for(;f<80;++f)r[f]=r[f-3]^r[f-8]^r[f-14]^r[f-16];for(var d=0;d<80;++d){var h=~~(d/20),p=0|((t=n)<<5|t>>>27)+l(h,i,o,s)+u+r[d]+a[h];u=s,s=o,o=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=u},function(e,t,r){var n=r(11),i=r(87),o=r(16).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function l(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,d=0;d<16;++d)r[d]=e.readInt32BE(4*d);for(;d<80;++d)r[d]=(t=r[d-3]^r[d-8]^r[d-14]^r[d-16])<<1|t>>>31;for(var h=0;h<80;++h){var p=~~(h/20),g=c(n)+f(p,i,o,s)+u+r[h]+a[p]|0;u=s,s=o,o=l(i),i=n,n=g}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=u},function(e,t,r){var n=r(11),i=r(198),o=r(87),a=r(16).Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},e.exports=u},function(e,t,r){var n=r(11),i=r(199),o=r(87),a=r(16).Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},e.exports=u},function(e,t,r){"use strict";var n=r(11),i=r(16).Buffer,o=r(71),a=i.alloc(128);function s(e,t){o.call(this,"digest"),"string"==typeof t&&(t=i.from(t)),this._alg=e,this._key=t,t.length>64?t=e(t):t.length<64&&(t=i.concat([t,a],64));for(var r=this._ipad=i.allocUnsafe(64),n=this._opad=i.allocUnsafe(64),s=0;s<64;s++)r[s]=54^t[s],n[s]=92^t[s];this._hash=[r]}n(s,o),s.prototype._update=function(e){this._hash.push(e)},s.prototype._final=function(){var e=this._alg(i.concat(this._hash));return this._alg(i.concat([this._opad,e]))},e.exports=s},function(e,t,r){e.exports=r(202)},function(e,t,r){(function(t){var n,i,o=r(16).Buffer,a=r(204),s=r(205),u=r(206),c=r(207),l=t.crypto&&t.crypto.subtle,f={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},d=[];function h(){return i||(i=t.process&&t.process.nextTick?t.process.nextTick:t.queueMicrotask?t.queueMicrotask:t.setImmediate?t.setImmediate:t.setTimeout)}function p(e,t,r,n,i){return l.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then((function(e){return l.deriveBits({name:"PBKDF2",salt:t,iterations:r,hash:{name:i}},e,n<<3)})).then((function(e){return o.from(e)}))}e.exports=function(e,r,i,g,m,y){"function"==typeof m&&(y=m,m=void 0);var b=f[(m=m||"sha1").toLowerCase()];if(b&&"function"==typeof t.Promise){if(a(i,g),e=c(e,s,"Password"),r=c(r,s,"Salt"),"function"!=typeof y)throw new Error("No callback provided to pbkdf2");!function(e,t){e.then((function(e){h()((function(){t(null,e)}))}),(function(e){h()((function(){t(e)}))}))}(function(e){if(t.process&&!t.process.browser)return Promise.resolve(!1);if(!l||!l.importKey||!l.deriveBits)return Promise.resolve(!1);if(void 0!==d[e])return d[e];var r=p(n=n||o.alloc(8),n,10,128,e).then((function(){return!0})).catch((function(){return!1}));return d[e]=r,r}(b).then((function(t){return t?p(e,r,i,g,b):u(e,r,i,g,m)})),y)}else h()((function(){var t;try{t=u(e,r,i,g,m)}catch(e){return y(e)}y(null,t)}))}}).call(this,r(23))},function(e,t,r){var n=r(332),i=r(151),o=r(152),a=r(345),s=r(116);function u(e,t,r){if(e=e.toLowerCase(),o[e])return i.createCipheriv(e,t,r);if(a[e])return new n({key:t,iv:r,mode:e});throw new TypeError("invalid suite type")}function c(e,t,r){if(e=e.toLowerCase(),o[e])return i.createDecipheriv(e,t,r);if(a[e])return new n({key:t,iv:r,mode:e,decrypt:!0});throw new TypeError("invalid suite type")}t.createCipher=t.Cipher=function(e,t){var r,n;if(e=e.toLowerCase(),o[e])r=o[e].key,n=o[e].iv;else{if(!a[e])throw new TypeError("invalid suite type");r=8*a[e].key,n=a[e].iv}var i=s(t,!1,r,n);return u(e,i.key,i.iv)},t.createCipheriv=t.Cipheriv=u,t.createDecipher=t.Decipher=function(e,t){var r,n;if(e=e.toLowerCase(),o[e])r=o[e].key,n=o[e].iv;else{if(!a[e])throw new TypeError("invalid suite type");r=8*a[e].key,n=a[e].iv}var i=s(t,!1,r,n);return c(e,i.key,i.iv)},t.createDecipheriv=t.Decipheriv=c,t.listCiphers=t.getCiphers=function(){return Object.keys(a).concat(i.getCiphers())}},function(e,t,r){var n=r(71),i=r(333),o=r(11),a=r(16).Buffer,s={"des-ede3-cbc":i.CBC.instantiate(i.EDE),"des-ede3":i.EDE,"des-ede-cbc":i.CBC.instantiate(i.EDE),"des-ede":i.EDE,"des-cbc":i.CBC.instantiate(i.DES),"des-ecb":i.DES};function u(e){n.call(this);var t,r=e.mode.toLowerCase(),i=s[r];t=e.decrypt?"decrypt":"encrypt";var o=e.key;a.isBuffer(o)||(o=a.from(o)),"des-ede"!==r&&"des-ede-cbc"!==r||(o=a.concat([o,o.slice(0,8)]));var u=e.iv;a.isBuffer(u)||(u=a.from(u)),this._des=i.create({key:o,iv:u,type:t})}s.des=s["des-cbc"],s.des3=s["des-ede3-cbc"],e.exports=u,o(u,n),u.prototype._update=function(e){return a.from(this._des.update(e))},u.prototype._final=function(){return a.from(this._des.final())}},function(e,t,r){"use strict";t.utils=r(208),t.Cipher=r(150),t.DES=r(209),t.CBC=r(334),t.EDE=r(335)},function(e,t,r){"use strict";var n=r(44),i=r(11),o={};function a(e){n.equal(e.length,8,"Invalid IV length"),this.iv=new Array(8);for(var t=0;t15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},d.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>a%8,e._prev=o(e._prev,r?n:i);return s}function o(e,t){var r=e.length,i=-1,o=n.allocUnsafe(e.length);for(e=n.concat([e,n.from([t])]);++i>7;return o}t.encrypt=function(e,t,r){for(var o=t.length,a=n.allocUnsafe(o),s=-1;++s>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=n.alloc(16,0),this.cache=n.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=o(i)},a.prototype.update=function(e){var t;for(this.cache=n.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(n.concat([this.cache,i],16)),this.ghash(o([0,e,0,t])),this.state},e.exports=a},function(e,t,r){var n=r(213),i=r(16).Buffer,o=r(152),a=r(214),s=r(71),u=r(115),c=r(116);function l(e,t,r){s.call(this),this._cache=new f,this._last=void 0,this._cipher=new u.AES(t),this._prev=i.from(r),this._mode=e,this._autopadding=!0}function f(){this.cache=i.allocUnsafe(0)}function d(e,t,r){var s=o[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof r&&(r=i.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);if("string"==typeof t&&(t=i.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);return"stream"===s.type?new a(s.module,t,r,!0):"auth"===s.type?new n(s.module,t,r,!0):new l(s.module,t,r)}r(11)(l,s),l.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get(this._autopadding);)r=this._mode.decrypt(this,t),n.push(r);return i.concat(n)},l.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return function(e){var t=e[15];if(t<1||t>16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},f.prototype.flush=function(){if(this.cache.length)return this.cache},t.createDecipher=function(e,t){var r=o[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(t,!1,r.key,r.iv);return d(e,n.key,n.iv)},t.createDecipheriv=d},function(e,t){t["des-ecb"]={key:8,iv:0},t["des-cbc"]=t.des={key:8,iv:8},t["des-ede3-cbc"]=t.des3={key:24,iv:8},t["des-ede3"]={key:24,iv:0},t["des-ede-cbc"]={key:16,iv:8},t["des-ede"]={key:16,iv:0}},function(e,t,r){(function(e){var n=r(215),i=r(349),o=r(350);var a={binary:!0,hex:!0,base64:!0};t.DiffieHellmanGroup=t.createDiffieHellmanGroup=t.getDiffieHellman=function(t){var r=new e(i[t].prime,"hex"),n=new e(i[t].gen,"hex");return new o(r,n)},t.createDiffieHellman=t.DiffieHellman=function t(r,i,s,u){return e.isBuffer(i)||void 0===a[i]?t(r,"binary",i,s):(i=i||"binary",u=u||"binary",s=s||new e([2]),e.isBuffer(s)||(s=new e(s,u)),"number"==typeof r?new o(n(r,s),s,!0):(e.isBuffer(r)||(r=new e(r,i)),new o(r,s,!0)))}}).call(this,r(10).Buffer)},function(e,t){},function(e,t){},function(e){e.exports=JSON.parse('{"modp1":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},"modp2":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},"modp5":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},"modp14":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},"modp15":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},"modp16":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},"modp17":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},"modp18":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}')},function(e,t,r){(function(t){var n=r(35),i=new(r(216)),o=new n(24),a=new n(11),s=new n(10),u=new n(3),c=new n(7),l=r(215),f=r(84);function d(e,r){return r=r||"utf8",t.isBuffer(e)||(e=new t(e,r)),this._pub=new n(e),this}function h(e,r){return r=r||"utf8",t.isBuffer(e)||(e=new t(e,r)),this._priv=new n(e),this}e.exports=g;var p={};function g(e,t,r){this.setGenerator(t),this.__prime=new n(e),this._prime=n.mont(this.__prime),this._primeLen=e.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,r?(this.setPublicKey=d,this.setPrivateKey=h):this._primeCode=8}function m(e,r){var n=new t(e.toArray());return r?n.toString(r):n}Object.defineProperty(g.prototype,"verifyError",{enumerable:!0,get:function(){return"number"!=typeof this._primeCode&&(this._primeCode=function(e,t){var r=t.toString("hex"),n=[r,e.toString(16)].join("_");if(n in p)return p[n];var f,d=0;if(e.isEven()||!l.simpleSieve||!l.fermatTest(e)||!i.test(e))return d+=1,d+="02"===r||"05"===r?8:4,p[n]=d,d;switch(i.test(e.shrn(1))||(d+=2),r){case"02":e.mod(o).cmp(a)&&(d+=8);break;case"05":(f=e.mod(s)).cmp(u)&&f.cmp(c)&&(d+=8);break;default:d+=4}return p[n]=d,d}(this.__prime,this.__gen)),this._primeCode}}),g.prototype.generateKeys=function(){return this._priv||(this._priv=new n(f(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},g.prototype.computeSecret=function(e){var r=(e=(e=new n(e)).toRed(this._prime)).redPow(this._priv).fromRed(),i=new t(r.toArray()),o=this.getPrime();if(i.length0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return a.alloc(0);for(var t,r,n,i=a.allocUnsafe(e>>>0),o=this.head,s=0;o;)t=o.data,r=i,n=s,a.prototype.copy.call(t,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var r;return ei.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0==(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=a.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:u,value:function(e,t){return s(this,function(e){for(var t=1;t0,(function(e){n||(n=e),e&&a.forEach(c),o||(a.forEach(c),i(n))}))}));return t.reduce(l)}},function(e,t,r){var n=r(16).Buffer,i=r(200),o=r(155),a=r(156).ec,s=r(228),u=r(118),c=r(234);function l(e,t,r,o){if((e=n.from(e.toArray())).length0&&r.ishrn(n),r}function d(e,t,r){var o,a;do{for(o=n.alloc(0);8*o.length=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+e)}function u(e,t,r){var n=s(e,r);return r-1>=t&&(n|=s(e,r-1)<<4),n}function c(e,t,r,i){for(var o=0,a=0,s=Math.min(e.length,r),u=t;u=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&a0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},o.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n=t;n-=2)i=u(e,t,n)<=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(n=(e.length-t)%2==0?t+1:t;n=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;this._strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(e){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}var d=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?d[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var c=h[e],l=p[e];r="";var f=this.clone();for(f.negative=0;!f.isZero();){var g=f.modrn(l).toString(e);r=(f=f.idivn(l)).isZero()?g+r:d[c-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16,2)},a&&(o.prototype.toBuffer=function(e,t){return this.toArrayLike(a,e,t)}),o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function g(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,f=67108863&u,d=Math.min(c,t.length-1),h=Math.max(0,c-e.length+1);h<=d;h++){var p=c-h|0;l+=(a=(i=0|e.words[p])*(o=0|t.words[h])+f)/67108864|0,f=67108863&a}r.words[c]=0|f,u=0|l}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0");var a=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this["_toArrayLike"+("le"===t?"LE":"BE")](a,i),a},o.prototype._toArrayLikeLE=function(e,t){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r=0&&(e[r--]=a>>8&255),r>=0&&(e[r--]=a>>16&255),6===o?(r>=0&&(e[r--]=a>>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r>=0)for(e[r--]=n;r>=0;)e[r--]=0},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,h=0|a[1],p=8191&h,g=h>>>13,m=0|a[2],y=8191&m,b=m>>>13,_=0|a[3],w=8191&_,v=_>>>13,E=0|a[4],S=8191&E,O=E>>>13,T=0|a[5],A=8191&T,M=T>>>13,D=0|a[6],I=8191&D,j=D>>>13,R=0|a[7],N=8191&R,k=R>>>13,C=0|a[8],L=8191&C,x=C>>>13,P=0|a[9],B=8191&P,U=P>>>13,F=0|s[0],W=8191&F,H=F>>>13,z=0|s[1],q=8191&z,V=z>>>13,G=0|s[2],Y=8191&G,$=G>>>13,K=0|s[3],Z=8191&K,X=K>>>13,J=0|s[4],Q=8191&J,ee=J>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,le=0|s[8],fe=8191&le,de=le>>>13,he=0|s[9],pe=8191&he,ge=he>>>13;r.negative=e.negative^t.negative,r.length=19;var me=(c+(n=Math.imul(f,W))|0)+((8191&(i=(i=Math.imul(f,H))+Math.imul(d,W)|0))<<13)|0;c=((o=Math.imul(d,H))+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(p,W),i=(i=Math.imul(p,H))+Math.imul(g,W)|0,o=Math.imul(g,H);var ye=(c+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,V)|0)+Math.imul(d,q)|0))<<13)|0;c=((o=o+Math.imul(d,V)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,W),i=(i=Math.imul(y,H))+Math.imul(b,W)|0,o=Math.imul(b,H),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(g,q)|0,o=o+Math.imul(g,V)|0;var be=(c+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(d,Y)|0))<<13)|0;c=((o=o+Math.imul(d,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(w,W),i=(i=Math.imul(w,H))+Math.imul(v,W)|0,o=Math.imul(v,H),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,V)|0)+Math.imul(b,q)|0,o=o+Math.imul(b,V)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,$)|0;var _e=(c+(n=n+Math.imul(f,Z)|0)|0)+((8191&(i=(i=i+Math.imul(f,X)|0)+Math.imul(d,Z)|0))<<13)|0;c=((o=o+Math.imul(d,X)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(S,W),i=(i=Math.imul(S,H))+Math.imul(O,W)|0,o=Math.imul(O,H),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(b,Y)|0,o=o+Math.imul(b,$)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,X)|0;var we=(c+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,ee)|0)+Math.imul(d,Q)|0))<<13)|0;c=((o=o+Math.imul(d,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(A,W),i=(i=Math.imul(A,H))+Math.imul(M,W)|0,o=Math.imul(M,H),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(O,q)|0,o=o+Math.imul(O,V)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,$)|0,n=n+Math.imul(y,Z)|0,i=(i=i+Math.imul(y,X)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,X)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,ee)|0;var ve=(c+(n=n+Math.imul(f,re)|0)|0)+((8191&(i=(i=i+Math.imul(f,ne)|0)+Math.imul(d,re)|0))<<13)|0;c=((o=o+Math.imul(d,ne)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(I,W),i=(i=Math.imul(I,H))+Math.imul(j,W)|0,o=Math.imul(j,H),n=n+Math.imul(A,q)|0,i=(i=i+Math.imul(A,V)|0)+Math.imul(M,q)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(S,Y)|0,i=(i=i+Math.imul(S,$)|0)+Math.imul(O,Y)|0,o=o+Math.imul(O,$)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,X)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ne)|0;var Ee=(c+(n=n+Math.imul(f,oe)|0)|0)+((8191&(i=(i=i+Math.imul(f,ae)|0)+Math.imul(d,oe)|0))<<13)|0;c=((o=o+Math.imul(d,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,W),i=(i=Math.imul(N,H))+Math.imul(k,W)|0,o=Math.imul(k,H),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,V)|0)+Math.imul(j,q)|0,o=o+Math.imul(j,V)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(M,Y)|0,o=o+Math.imul(M,$)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,X)|0)+Math.imul(O,Z)|0,o=o+Math.imul(O,X)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,ae)|0;var Se=(c+(n=n+Math.imul(f,ue)|0)|0)+((8191&(i=(i=i+Math.imul(f,ce)|0)+Math.imul(d,ue)|0))<<13)|0;c=((o=o+Math.imul(d,ce)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(L,W),i=(i=Math.imul(L,H))+Math.imul(x,W)|0,o=Math.imul(x,H),n=n+Math.imul(N,q)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,V)|0,n=n+Math.imul(I,Y)|0,i=(i=i+Math.imul(I,$)|0)+Math.imul(j,Y)|0,o=o+Math.imul(j,$)|0,n=n+Math.imul(A,Z)|0,i=(i=i+Math.imul(A,X)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(O,Q)|0,o=o+Math.imul(O,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(g,ue)|0,o=o+Math.imul(g,ce)|0;var Oe=(c+(n=n+Math.imul(f,fe)|0)|0)+((8191&(i=(i=i+Math.imul(f,de)|0)+Math.imul(d,fe)|0))<<13)|0;c=((o=o+Math.imul(d,de)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(B,W),i=(i=Math.imul(B,H))+Math.imul(U,W)|0,o=Math.imul(U,H),n=n+Math.imul(L,q)|0,i=(i=i+Math.imul(L,V)|0)+Math.imul(x,q)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(N,Y)|0,i=(i=i+Math.imul(N,$)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,$)|0,n=n+Math.imul(I,Z)|0,i=(i=i+Math.imul(I,X)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,X)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(O,re)|0,o=o+Math.imul(O,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(y,ue)|0,i=(i=i+Math.imul(y,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0,n=n+Math.imul(p,fe)|0,i=(i=i+Math.imul(p,de)|0)+Math.imul(g,fe)|0,o=o+Math.imul(g,de)|0;var Te=(c+(n=n+Math.imul(f,pe)|0)|0)+((8191&(i=(i=i+Math.imul(f,ge)|0)+Math.imul(d,pe)|0))<<13)|0;c=((o=o+Math.imul(d,ge)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,V))+Math.imul(U,q)|0,o=Math.imul(U,V),n=n+Math.imul(L,Y)|0,i=(i=i+Math.imul(L,$)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,$)|0,n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,X)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,ee)|0)+Math.imul(j,Q)|0,o=o+Math.imul(j,ee)|0,n=n+Math.imul(A,re)|0,i=(i=i+Math.imul(A,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(O,oe)|0,o=o+Math.imul(O,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(y,fe)|0,i=(i=i+Math.imul(y,de)|0)+Math.imul(b,fe)|0,o=o+Math.imul(b,de)|0;var Ae=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ge)|0)+Math.imul(g,pe)|0))<<13)|0;c=((o=o+Math.imul(g,ge)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(B,Y),i=(i=Math.imul(B,$))+Math.imul(U,Y)|0,o=Math.imul(U,$),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,X)|0,n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(I,re)|0,i=(i=i+Math.imul(I,ne)|0)+Math.imul(j,re)|0,o=o+Math.imul(j,ne)|0,n=n+Math.imul(A,oe)|0,i=(i=i+Math.imul(A,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(O,ue)|0,o=o+Math.imul(O,ce)|0,n=n+Math.imul(w,fe)|0,i=(i=i+Math.imul(w,de)|0)+Math.imul(v,fe)|0,o=o+Math.imul(v,de)|0;var Me=(c+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,ge)|0)+Math.imul(b,pe)|0))<<13)|0;c=((o=o+Math.imul(b,ge)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(B,Z),i=(i=Math.imul(B,X))+Math.imul(U,Z)|0,o=Math.imul(U,X),n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(I,oe)|0,i=(i=i+Math.imul(I,ae)|0)+Math.imul(j,oe)|0,o=o+Math.imul(j,ae)|0,n=n+Math.imul(A,ue)|0,i=(i=i+Math.imul(A,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(S,fe)|0,i=(i=i+Math.imul(S,de)|0)+Math.imul(O,fe)|0,o=o+Math.imul(O,de)|0;var De=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ge)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,ge)|0)+(i>>>13)|0)+(De>>>26)|0,De&=67108863,n=Math.imul(B,Q),i=(i=Math.imul(B,ee))+Math.imul(U,Q)|0,o=Math.imul(U,ee),n=n+Math.imul(L,re)|0,i=(i=i+Math.imul(L,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,n=n+Math.imul(I,ue)|0,i=(i=i+Math.imul(I,ce)|0)+Math.imul(j,ue)|0,o=o+Math.imul(j,ce)|0,n=n+Math.imul(A,fe)|0,i=(i=i+Math.imul(A,de)|0)+Math.imul(M,fe)|0,o=o+Math.imul(M,de)|0;var Ie=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ge)|0)+Math.imul(O,pe)|0))<<13)|0;c=((o=o+Math.imul(O,ge)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(B,re),i=(i=Math.imul(B,ne))+Math.imul(U,re)|0,o=Math.imul(U,ne),n=n+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,ae)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,ae)|0,n=n+Math.imul(N,ue)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,ce)|0,n=n+Math.imul(I,fe)|0,i=(i=i+Math.imul(I,de)|0)+Math.imul(j,fe)|0,o=o+Math.imul(j,de)|0;var je=(c+(n=n+Math.imul(A,pe)|0)|0)+((8191&(i=(i=i+Math.imul(A,ge)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,ge)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(B,oe),i=(i=Math.imul(B,ae))+Math.imul(U,oe)|0,o=Math.imul(U,ae),n=n+Math.imul(L,ue)|0,i=(i=i+Math.imul(L,ce)|0)+Math.imul(x,ue)|0,o=o+Math.imul(x,ce)|0,n=n+Math.imul(N,fe)|0,i=(i=i+Math.imul(N,de)|0)+Math.imul(k,fe)|0,o=o+Math.imul(k,de)|0;var Re=(c+(n=n+Math.imul(I,pe)|0)|0)+((8191&(i=(i=i+Math.imul(I,ge)|0)+Math.imul(j,pe)|0))<<13)|0;c=((o=o+Math.imul(j,ge)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(B,ue),i=(i=Math.imul(B,ce))+Math.imul(U,ue)|0,o=Math.imul(U,ce),n=n+Math.imul(L,fe)|0,i=(i=i+Math.imul(L,de)|0)+Math.imul(x,fe)|0,o=o+Math.imul(x,de)|0;var Ne=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,ge)|0)+Math.imul(k,pe)|0))<<13)|0;c=((o=o+Math.imul(k,ge)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(B,fe),i=(i=Math.imul(B,de))+Math.imul(U,fe)|0,o=Math.imul(U,de);var ke=(c+(n=n+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,ge)|0)+Math.imul(x,pe)|0))<<13)|0;c=((o=o+Math.imul(x,ge)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863;var Ce=(c+(n=Math.imul(B,pe))|0)+((8191&(i=(i=Math.imul(B,ge))+Math.imul(U,pe)|0))<<13)|0;return c=((o=Math.imul(U,ge))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=me,u[1]=ye,u[2]=be,u[3]=_e,u[4]=we,u[5]=ve,u[6]=Ee,u[7]=Se,u[8]=Oe,u[9]=Te,u[10]=Ae,u[11]=Me,u[12]=De,u[13]=Ie,u[14]=je,u[15]=Re,u[16]=Ne,u[17]=ke,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function y(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function b(e,t,r){return y(e,t,r)}function _(e,t){this.x=e,this.y=t}Math.imul||(m=g),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?m(this,e,t):r<63?g(this,e,t):r<1024?y(this,e,t):b(this,e,t)},_.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},_.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,r+=o/67108864|0,r+=a>>>26,this.words[i]=67108863&a}return 0!==r&&(this.words[i]=r,this.length++),t?this.ineg():this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i&1}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==l||c>=i);c--){var f=0|this.words[c];this.words[c]=l<<26-o|f>>>o,l=f&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this._strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;f--){var d=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(d=Math.min(d/a|0,67108863),n._ishlnsubmul(i,d,f);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);s&&(s.words[f]=d)}return s&&s._strip(),n._strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modrn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%e;return t?-i:i},o.prototype.modn=function(e){return this.modrn(e)},o.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/e|0,r=o%e}return this._strip(),t?this.ineg():this},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var l=r.clone(),f=t.clone();!t.isZero();){for(var d=0,h=1;0==(t.words[0]&h)&&d<26;++d,h<<=1);if(d>0)for(t.iushrn(d);d-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(l),a.isub(f)),i.iushrn(1),a.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(f)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,l=1;0==(t.words[0]&l)&&c<26;++c,l<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var f=0,d=1;0==(r.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(r.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var w={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function E(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function S(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function O(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function T(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function M(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},i(E,v),E.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},E.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(w[e])return w[e];var t;if("k256"===e)t=new E;else if("p224"===e)t=new S;else if("p192"===e)t=new O;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new T}return w[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(l(e,e.umod(this.m)._forceRed(this)),e)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,c).cmp(u);)l.redIAdd(u);for(var f=this.pow(l,i),d=this.pow(e,i.addn(1).iushrn(1)),h=this.pow(e,i),p=a;0!==h.cmp(s);){for(var g=h,m=0;0!==g.cmp(s);m++)g=g.redSqr();n(m=0;n--){for(var c=t.words[n],l=u-1;l>=0;l--){var f=c>>l&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==a?(a<<=1,a|=f,(4===++s||0===n&&0===l)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new M(e)},i(M,A),M.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},M.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},M.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},M.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},M.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(97)(e))},function(e,t){},function(e){e.exports=JSON.parse('{"name":"elliptic","version":"6.5.4","description":"EC cryptography","main":"lib/elliptic.js","files":["lib"],"scripts":{"lint":"eslint lib test","lint:fix":"npm run lint -- --fix","unit":"istanbul test _mocha --reporter=spec test/index.js","test":"npm run lint && npm run unit","version":"grunt dist && git add dist/"},"repository":{"type":"git","url":"git@github.com:indutny/elliptic"},"keywords":["EC","Elliptic","curve","Cryptography"],"author":"Fedor Indutny ","license":"MIT","bugs":{"url":"https://github.com/indutny/elliptic/issues"},"homepage":"https://github.com/indutny/elliptic","devDependencies":{"brfs":"^2.0.2","coveralls":"^3.1.0","eslint":"^7.6.0","grunt":"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1","istanbul":"^0.4.5","mocha":"^8.0.1"},"dependencies":{"bn.js":"^4.11.9","brorand":"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1","inherits":"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}')},function(e,t,r){"use strict";var n=r(45),i=r(35),o=r(11),a=r(117),s=n.assert;function u(e){a.call(this,"short",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function c(e,t,r,n){a.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(t,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function l(e,t,r,n){a.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(t,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,a),e.exports=u,u.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new i(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new i(e.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(t))?r=o[0]:(r=o[1],s(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map((function(e){return{a:new i(e.a,16),b:new i(e.b,16)}})):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:i.mont(e),r=new i(2).toRed(t).redInvm(),n=r.redNeg(),o=new i(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},u.prototype._getEndoBasis=function(e){for(var t,r,n,o,a,s,u,c,l,f=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=e,h=this.n.clone(),p=new i(1),g=new i(0),m=new i(0),y=new i(1),b=0;0!==d.cmpn(0);){var _=h.div(d);c=h.sub(_.mul(d)),l=m.sub(_.mul(p));var w=y.sub(_.mul(g));if(!n&&c.cmp(f)<0)t=u.neg(),r=p,n=c.neg(),o=l;else if(n&&2==++b)break;u=c,h=d,d=c,m=p,p=l,y=g,g=w}a=c.neg(),s=l;var v=n.sqr().add(o.sqr());return a.sqr().add(s.sqr()).cmp(v)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),o=o.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:o},{a:a,b:s}]},u.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(c).neg()}},u.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(t&&!o||!t&&o)&&(n=n.redNeg()),this.point(e,n)},u.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},c.prototype.isInfinity=function(){return this.inf},c.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},c.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},c.prototype.getX=function(){return this.x.fromRed()},c.prototype.getY=function(){return this.y.fromRed()},c.prototype.mul=function(e){return e=new i(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},c.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},c.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},c.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},c.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},c.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(l,a.BasePoint),u.prototype.jpoint=function(e,t,r){return new l(this,e,t,r)},l.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},l.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},l.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),l=c.redMul(s),f=n.redMul(c),d=u.redSqr().redIAdd(l).redISub(f).redISub(f),h=u.redMul(f.redISub(d)).redISub(o.redMul(l)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(d,h,p)},l.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),l=r.redMul(u),f=s.redSqr().redIAdd(c).redISub(l).redISub(l),d=s.redMul(l.redISub(f)).redISub(i.redMul(c)),h=this.z.redMul(a);return this.curve.jpoint(f,d,h)},l.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},l.prototype.inspect=function(){return this.isInfinity()?"":""},l.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,r){"use strict";var n=r(35),i=r(11),o=r(117),a=r(45);function s(e){o.call(this,"mont",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function u(e,t,r){o.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(t,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(s,o),e.exports=s,s.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},i(u,o.BasePoint),s.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},s.prototype.point=function(e,t){return new u(this,e,t)},s.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},u.prototype.precompute=function(){},u.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},u.fromJSON=function(e,t){return new u(e,t[0],t[1]||e.one)},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},u.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},u.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},u.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},u.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},u.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(e,t,r){"use strict";var n=r(45),i=r(35),o=r(11),a=r(117),s=n.assert;function u(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new i(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),s(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function c(e,t,r,n,o){a.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===n?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new i(t,16),this.y=new i(r,16),this.z=n?new i(n,16):this.curve.one,this.t=o&&new i(o,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}o(u,a),e.exports=u,u.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},u.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},u.prototype.jpoint=function(e,t,r,n){return this.point(e,t,r,n)},u.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=this.c2.redSub(this.a.redMul(r)),o=this.one.redSub(this.c2.redMul(this.d).redMul(r)),a=n.redMul(o.redInvm()),s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var u=s.fromRed().isOdd();return(t&&!u||!t&&u)&&(s=s.redNeg()),this.point(e,s)},u.prototype.pointFromY=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=r.redSub(this.c2),o=r.redMul(this.d).redMul(this.c2).redSub(this.a),a=n.redMul(o.redInvm());if(0===a.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return s.fromRed().isOdd()!==t&&(s=s.redNeg()),this.point(s,e)},u.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),r=e.y.redSqr(),n=t.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(r)));return 0===n.cmp(i)},o(c,a.BasePoint),u.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},u.prototype.point=function(e,t,r,n){return new c(this,e,t,r,n)},c.fromJSON=function(e,t){return new c(e,t[0],t[1],t[2])},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},c.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),c=o.redMul(s),l=i.redMul(s),f=a.redMul(o);return this.curve.point(u,c,f,l)},c.prototype._projDbl=function(){var e,t,r,n,i,o,a=this.x.redAdd(this.y).redSqr(),s=this.x.redSqr(),u=this.y.redSqr();if(this.curve.twisted){var c=(n=this.curve._mulA(s)).redAdd(u);this.zOne?(e=a.redSub(s).redSub(u).redMul(c.redSub(this.curve.two)),t=c.redMul(n.redSub(u)),r=c.redSqr().redSub(c).redSub(c)):(i=this.z.redSqr(),o=c.redSub(i).redISub(i),e=a.redSub(s).redISub(u).redMul(o),t=c.redMul(n.redSub(u)),r=c.redMul(o))}else n=s.redAdd(u),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),e=this.curve._mulC(a.redISub(n)).redMul(o),t=this.curve._mulC(n).redMul(s.redISub(u)),r=n.redMul(o);return this.curve.point(e,t,r)},c.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},c.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),c=o.redMul(a),l=s.redMul(u),f=o.redMul(u),d=a.redMul(s);return this.curve.point(c,l,d,f)},c.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),c=i.redAdd(s),l=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),f=n.redMul(u).redMul(l);return this.curve.twisted?(t=n.redMul(c).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(f,t,r)},c.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},c.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},c.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},c.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},c.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},c.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()},c.prototype.getY=function(){return this.normalize(),this.y.fromRed()},c.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},c.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},c.prototype.toP=c.prototype.normalize,c.prototype.mixedAdd=c.prototype.add},function(e,t,r){"use strict";t.sha1=r(368),t.sha224=r(369),t.sha256=r(226),t.sha384=r(370),t.sha512=r(227)},function(e,t,r){"use strict";var n=r(53),i=r(103),o=r(225),a=n.rotl32,s=n.sum32,u=n.sum32_5,c=o.ft_1,l=i.BlockHash,f=[1518500249,1859775393,2400959708,3395469782];function d(){if(!(this instanceof d))return new d;l.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(d,l),e.exports=d,d.blockSize=512,d.outSize=160,d.hmacStrength=80,d.padLength=64,d.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t0))return a.iaddn(1),this.keyFromPrivate(a)}},f.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},f.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),u=e.toArray("be",a),c=new i({hash:this.hash,entropy:s,nonce:u,pers:o.pers,persEnc:o.persEnc||"utf8"}),f=this.n.sub(new n(1)),d=0;;d++){var h=o.k?o.k(d):new n(c.generate(this.n.byteLength()));if(!((h=this._truncateToN(h,!0)).cmpn(1)<=0||h.cmp(f)>=0)){var p=this.g.mul(h);if(!p.isInfinity()){var g=p.getX(),m=g.umod(this.n);if(0!==m.cmpn(0)){var y=h.invm(this.n).mul(m.mul(t.getPrivate()).iadd(e));if(0!==(y=y.umod(this.n)).cmpn(0)){var b=(p.getY().isOdd()?1:0)|(0!==g.cmp(m)?2:0);return o.canonical&&y.cmp(this.nh)>0&&(y=this.n.sub(y),b^=1),new l({r:m,s:y,recoveryParam:b})}}}}}},f.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new l(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,u=a.invm(this.n),c=u.mul(e).umod(this.n),f=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(c,r.getPublic(),f)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(c,r.getPublic(),f)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},f.prototype.recoverPubKey=function(e,t,r,i){u((3&r)===r,"The recovery param is more than two bits"),t=new l(t,i);var o=this.n,a=new n(e),s=t.r,c=t.s,f=1&r,d=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");s=d?this.curve.pointFromX(s.add(this.curve.n),f):this.curve.pointFromX(s,f);var h=t.r.invm(o),p=o.sub(a).mul(h).umod(o),g=c.mul(h).umod(o);return this.g.mulAdd(p,s,g)},f.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new l(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},function(e,t,r){"use strict";var n=r(158),i=r(223),o=r(44);function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}e.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length"}},function(e,t,r){"use strict";var n=r(35),i=r(45),o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(){this.place=0}function u(e,t){var r=e[t.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,a=t.place;o>>=0;return!(i<=127)&&(t.place=a,i)}function c(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}e.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new s;if(48!==e[r.place++])return!1;var o=u(e,r);if(!1===o)return!1;if(o+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var a=u(e,r);if(!1===a)return!1;var c=e.slice(r.place,a+r.place);if(r.place+=a,2!==e[r.place++])return!1;var l=u(e,r);if(!1===l)return!1;if(e.length!==l+r.place)return!1;var f=e.slice(r.place,l+r.place);if(0===c[0]){if(!(128&c[1]))return!1;c=c.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new n(c),this.s=new n(f),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=c(t),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];l(n,t.length),(n=n.concat(t)).push(2),l(n,r.length);var o=n.concat(r),a=[48];return l(a,o.length),a=a.concat(o),i.encode(a,e)}},function(e,t,r){"use strict";var n=r(158),i=r(157),o=r(45),a=o.assert,s=o.parseBytes,u=r(379),c=r(380);function l(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof l))return new l(e);e=i[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}e.exports=l,l.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},l.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},l.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=t)throw new Error("invalid sig")}e.exports=function(e,t,r,c,l){var f=a(r);if("ec"===f.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var n=s[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var i=new o(n),a=r.data.subjectPrivateKey.data;return i.verify(t,e,a)}(e,t,f)}if("dsa"===f.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var n=r.data.p,o=r.data.q,s=r.data.g,c=r.data.pub_key,l=a.signature.decode(e,"der"),f=l.s,d=l.r;u(f,o),u(d,o);var h=i.mont(n),p=f.invm(o);return 0===s.toRed(h).redPow(new i(t).mul(p).mod(o)).fromRed().mul(c.toRed(h).redPow(d.mul(p).mod(o)).fromRed()).mod(n).mod(o).cmp(d)}(e,t,f)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=n.concat([l,t]);for(var d=f.modulus.byteLength(),h=[1],p=0;t.length+h.length+2r-d-2)throw new Error("message too long");var h=f.alloc(r-n-d-2),p=r-l-1,g=i(l),m=s(f.concat([c,h,f.alloc(1,1),t],p),a(g,p)),y=s(g,a(m,l));return new u(f.concat([f.alloc(1),y,m],r))}(p,t);else if(1===d)h=function(e,t,r){var n,o=t.length,a=e.modulus.byteLength();if(o>a-11)throw new Error("message too long");n=r?f.alloc(a-o-3,255):function(e){var t,r=f.allocUnsafe(e),n=0,o=i(2*e),a=0;for(;n=0)throw new Error("data too long for modulus")}return r?l(h,p):c(h,p)}},function(e,t,r){var n=r(118),i=r(235),o=r(236),a=r(35),s=r(155),u=r(101),c=r(237),l=r(16).Buffer;e.exports=function(e,t,r){var f;f=e.padding?e.padding:r?1:4;var d,h=n(e),p=h.modulus.byteLength();if(t.length>p||new a(t).cmp(h.modulus)>=0)throw new Error("decryption error");d=r?c(new a(t),h):s(t,h);var g=l.alloc(p-d.length);if(d=l.concat([g,d],p),4===f)return function(e,t){var r=e.modulus.byteLength(),n=u("sha1").update(l.alloc(0)).digest(),a=n.length;if(0!==t[0])throw new Error("decryption error");var s=t.slice(1,a+1),c=t.slice(a+1),f=o(s,i(c,a)),d=o(c,i(f,r-a-1));if(function(e,t){e=l.from(e),t=l.from(t);var r=0,n=e.length;e.length!==t.length&&(r++,n=Math.min(e.length,t.length));var i=-1;for(;++i=t.length){o++;break}var a=t.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,d,r);if(3===f)return d;throw new Error("unknown padding")}},function(e,t,r){"use strict";(function(e,n){function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=r(16),a=r(84),s=o.Buffer,u=o.kMaxLength,c=e.crypto||e.msCrypto,l=Math.pow(2,32)-1;function f(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>l||e<0)throw new TypeError("offset must be a uint32");if(e>u||e>t)throw new RangeError("offset out of range")}function d(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>l||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>u)throw new RangeError("buffer too small")}function h(e,t,r,i){if(n.browser){var o=e.buffer,s=new Uint8Array(o,t,r);return c.getRandomValues(s),i?void n.nextTick((function(){i(null,e)})):e}if(!i)return a(r).copy(e,t),e;a(r,(function(r,n){if(r)return i(r);n.copy(e,t),i(null,e)}))}c&&c.getRandomValues||!n.browser?(t.randomFill=function(t,r,n,i){if(!(s.isBuffer(t)||t instanceof e.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof r)i=r,r=0,n=t.length;else if("function"==typeof n)i=n,n=t.length-r;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return f(r,t.length),d(n,r,t.length),h(t,r,n,i)},t.randomFillSync=function(t,r,n){void 0===r&&(r=0);if(!(s.isBuffer(t)||t instanceof e.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(r,t.length),void 0===n&&(n=t.length-r);return d(n,r,t.length),h(t,r,n)}):(t.randomFill=i,t.randomFillSync=i)}).call(this,r(23),r(19))},function(e,t,r){"use strict";r.r(t),r.d(t,"SQLiteFS",(function(){return o}));const n=63,i=44;const o=class{constructor(e,t){this.FS=e,this.backend=t,this.node_ops={getattr:t=>{let r=e.isFile(t.mode)?t.contents.getattr():null,n={dev:1};return n.ino=t.id,n.mode=r?r.mode:t.mode,n.nlink=1,n.uid=0,n.gid=0,n.rdev=t.rdev,n.size=r?r.size:e.isDir(t.mode)?4096:0,n.atime=new Date(0),n.mtime=new Date(0),n.ctime=new Date(0),n.blksize=r?r.blockSize:4096,n.blocks=Math.ceil(n.size/n.blksize),n},setattr:(e,t)=>{this.FS.isFile(e.mode)?e.contents.setattr(t):(null!=t.mode&&(e.mode=t.mode),null!=t.size&&(e.size=t.size))},lookup:(e,t)=>{throw new this.FS.ErrnoError(i)},mknod:(e,t,r,n)=>{if(t.endsWith(".lock"))throw new Error("Locking via lockfiles is not supported");return this.createNode(e,t,r,n)},rename:(e,t,r)=>{throw new Error("rename not implemented")},unlink:(e,t)=>{this.FS.lookupNode(e,t).contents.delete(t)},readdir:e=>{throw new Error("readdir not implemented")},symlink:(e,t,r)=>{throw new Error("symlink not implemented")},readlink:e=>{throw new Error("symlink not implemented")}},this.stream_ops={open:e=>{this.FS.isFile(e.node.mode)&&e.node.contents.open()},close:e=>{this.FS.isFile(e.node.mode)&&e.node.contents.close()},read:(e,t,r,n,i)=>e.node.contents.read(t,r,n,i),write:(e,t,r,n,i)=>e.node.contents.write(t,r,n,i),llseek:(t,r,n)=>{var i=r;if(1===n?i+=t.position:2===n&&e.isFile(t.node.mode)&&(i+=t.node.contents.getattr().size),i<0)throw new this.FS.ErrnoError(28);return i},allocate:(e,t,r)=>{e.node.contents.setattr({size:t+r})},mmap:(e,t,r,n,i,o)=>{throw new Error("mmap not implemented")},msync:(e,t,r,n,i)=>{throw new Error("msync not implemented")},fsync:(e,t,r,n,i)=>{e.node.contents.fsync()}}}mount(){return this.createNode(null,"/",16895,0)}lock(e,t){let r=this.FS.lookupPath(e).node;return!r||!r.contents||r.contents.lock(t)}unlock(e,t){let r=this.FS.lookupPath(e).node;return!r||!r.contents||r.contents.unlock(t)}createNode(e,t,r,i){if(!this.FS.isDir(r)&&!this.FS.isFile(r))throw new this.FS.ErrnoError(n);var o=this.FS.createNode(e,t,r,i);return this.FS.isDir(o.mode)?(o.node_ops={mknod:this.node_ops.mknod,lookup:this.node_ops.lookup,unlink:this.node_ops.unlink,setattr:this.node_ops.setattr},o.stream_ops={},o.contents={}):this.FS.isFile(o.mode)&&(o.node_ops=this.node_ops,o.stream_ops=this.stream_ops,o.contents=this.backend.createFile(t)),e&&(e.contents[t]=o,e.timestamp=o.timestamp),o}}},function(e,t,r){"use strict";r.r(t),function(e){let r=1,n=2;function i(e){return(e[16]<<8)+e[17]}function o(e,t,r){return function(e,t,r){let n=[];for(let i=e;i<=t;i+=r)n.push(i);return n}(t-t%e,r-1-(r-1)%e,e)}function a(e,t,r,n){let i=o(t,r,n),a=0;return i.map(i=>{let o=0,s=t;r>i&&ri&&ni+t||n<=i)return null;let l=e.byteOffset+a,f=e.buffer.byteLength-l;if(f<=0)return null;let d=Math.min(u,f);return new Uint8Array(c).set(new Uint8Array(e.buffer,l,d),o),a+=d,{pos:i,data:c,offset:o,length:d}}).filter(Boolean)}class s{constructor(e,t,r=null){this.filename=e,this.buffer=new Map,this.ops=t,this.meta=r,this._metaDirty=!1,this.writeLock=!1,this.openHandles=0}bufferChunks(e){for(let t=0;t{let r=this.buffer.get(t);return r?e.chunks.push(r):e.missing.push(t),e},{chunks:[],missing:[]}),r=[];return t.missing.length>0&&(r=this.ops.readBlocks(t.missing,this.meta.blockSize)),t.chunks.concat(r)}read(e,t,r,n){let i=e.buffer;if(r<=0)return 0;if(n<0)return 0;if(n>=this.meta.size){let e=new Uint8Array(i,t);for(let t=0;to.pos&&(a=t-o.pos),ro.data.byteLength||s<0)continue;let u=s-a;i.set(new Uint8Array(o.data,a,u),o.pos-t+a)}return n}(this.load(c),s,u);if(i.byteLength-t(t.length!==this.meta.blockSize?e.partialWrites.push(t):e.fullWrites.push({pos:t.pos,data:t.data}),e),{fullWrites:[],partialWrites:[]}),u=s.partialWrites,c=s.fullWrites,l=[];u.length>0&&(l=this.load(u.map(e=>e.pos)));let f=c.concat(l.map(e=>{let t=u.find(t=>t.pos===e.pos);return new Uint8Array(e.data).set(new Uint8Array(t.data,t.offset,t.length),t.offset,t.length),e}));return this.bufferChunks(f),n+r>this.meta.size&&this.setattr({size:n+r}),r}async readIfFallback(){if(this.ops.readIfFallback){let e=await this.ops.readIfFallback();this.meta=e||{size:0}}}lock(e){return this._recordingLock||(this._recordingLock=!0),!!this.ops.lock(e)&&(e>=n&&(this.writeLock=!0),!0)}unlock(e){return 0===e&&(this._recordingLock=!1),this.writeLock&&(this.fsync(),this.writeLock=!1),this.ops.unlock(e)}fsync(){if(this.buffer.size>0){let e=this.buffer.get(0);if(e){let t=i(new Uint8Array(e.data));if(t!==this.meta.blockSize){let e=this.buffer;this.buffer=new Map;let r=[...e.values()],n=r.length*this.meta.blockSize,i=new ArrayBuffer(n),o=new Uint8Array(i);for(let e of r)o.set(new Uint8Array(e.data),e.pos);this.bufferChunks(a(o,t,0,n)),this.setattr({blockSize:t})}}this.ops.writeBlocks([...this.buffer.values()],this.meta.blockSize)}this._metaDirty&&(this.ops.writeMeta({size:this.meta.size}),this._metaDirty=!1),this.buffer=new Map}setattr(e){null==this.meta&&(this.meta={}),void 0!==e.mode&&(this.meta.mode=e.mode),void 0!==e.blockSize&&(this.meta.blockSize=e.blockSize),void 0!==e.size&&(this.meta.size=e.size,this._metaDirty=!0)}getattr(){return this.meta}}class u{constructor(e,{initialOffset:t=4,useAtomics:r=!0,stream:n=!0,debug:i,name:o}={}){this.buffer=e,this.atomicView=new Int32Array(e),this.offset=t,this.useAtomics=r,this.stream=n,this.debug=i,this.name=o}log(...e){this.debug&&console.log(`[reader: ${this.name}]`,...e)}waitWrite(e,t=null){if(this.useAtomics){for(this.log("waiting for "+e);0===Atomics.load(this.atomicView,0);){if(null!=t&&"timed-out"===Atomics.wait(this.atomicView,0,0,t))throw new Error("timeout");Atomics.wait(this.atomicView,0,0,500)}this.log("resumed for "+e)}else if(1!==this.atomicView[0])throw new Error("`waitWrite` expected array to be readable")}flip(){if(this.log("flip"),this.useAtomics){if(1!==Atomics.compareExchange(this.atomicView,0,1,0))throw new Error("Read data out of sync! This is disastrous");Atomics.notify(this.atomicView,0)}else this.atomicView[0]=0;this.offset=4}done(){this.waitWrite("done");let e=3735928559===new DataView(this.buffer,this.offset).getUint32(0);return e&&(this.log("done"),this.flip()),e}peek(e){this.peekOffset=this.offset;let t=e();return this.offset=this.peekOffset,this.peekOffset=null,t}string(e){this.waitWrite("string",e);let t=this._int32(),r=t/2,n=new DataView(this.buffer,this.offset,t),i=[];for(let e=0;e{console.warn(`Deleting ${this.filename} database failed`)},e.onsuccess=()=>{}}open(){let e=new SharedArrayBuffer(36864);this.writer=new c(e,{name:"args (backend)",debug:!1});let t=new SharedArrayBuffer(36864);var r,n;this.reader=new u(t,{name:"results",debug:!1}),r=this.reader,n=this.writer,self.postMessage({type:"__absurd:spawn-idb-worker",argBuffer:n.buffer,resultBuffer:r.buffer}),self.addEventListener("message",e=>{switch(e.data.type){case"__perf-deets:start-profile":n.string("profile-start"),n.finalize(),r.int32(),r.done();break;case"__perf-deets:stop-profile":n.string("profile-stop"),n.finalize(),r.int32(),r.done()}})}close(){this.invokeWorker("closeFile",{name:this.getStoreName()}),this.reader=null,this.writer=null,this.worker=null}readMeta(){return this.invokeWorker("readMeta",{name:this.getStoreName()})}writeMeta(e){return this.invokeWorker("writeMeta",{name:this.getStoreName(),meta:e})}readBlocks(e,t){return this.stats&&(this.stats.read+=e.length),this.invokeWorker("readBlocks",{name:this.getStoreName(),positions:e,blockSize:t})}writeBlocks(e,t){return this.stats&&(this.stats.writes+=e.length),this.invokeWorker("writeBlocks",{name:this.getStoreName(),writes:e,blockSize:t})}}function d(e,t){return Math.round(e/t)}class h{constructor(e){this._openDb=null,this.hasAlertedFailure=!1,this.onFallbackFailure=e}async getDb(){return this._openDb||(this._openDb=await async function(e){return new Promise((t,r)=>{let n=globalThis.indexedDB.open(e,2);n.onsuccess=e=>{let r=e.target.result;r.onversionchange=()=>{console.log("closing because version changed"),r.close()},r.onclose=()=>{},t(r)},n.onupgradeneeded=e=>{let t=e.target.result;t.objectStoreNames.contains("data")||t.createObjectStore("data")},n.onblocked=e=>console.log("blocked",e),n.onerror=n.onabort=e=>r(e.target.error)})}(this.dbName)),this._openDb}closeDb(){this._openDb&&(this._openDb.close(),this._openDb=null)}async readAll(){let e=await this.getDb(this.dbName),t=new Map,r=e.transaction(["data"],"readonly").objectStore("data");return new Promise((e,n)=>{let i=r.openCursor(IDBKeyRange.lowerBound(-1));i.onerror=n,i.onsuccess=r=>{let n=r.target.result;n?(t.set(n.key,n.value),n.continue()):e(t)}})}async write(e,t,r){let n=(await this.getDb(this.dbName)).transaction(["data"],"readwrite"),i=n.objectStore("data");await new Promise((o,a)=>{let s=i.get(0);s.onsuccess=u=>{if(r&&!function(e,t){if(null!=e&&null!=t){let r=new Uint8Array(e),n=new Uint8Array(t);for(let e=24;e<40;e++)if(r[e]!==n[e])return!1;return!0}return null==e&&null==t}(s.result,t))return this.onFallbackFailure&&!this.hasAlertedFailure&&(this.hasAlertedFailure=!0,this.onFallbackFailure()),void a(new Error("Fallback mode unable to write file changes"));for(let t of e)i.put(t.value,t.key);n.onsuccess=()=>o(),n.onerror=()=>a()},s.onerror=a})}}class p{constructor(e,t){this.filename=e,this.dbName=this.filename.replace(/\//g,"-"),this.cachedFirstBlock=null,this.writeQueue=null,this.blocks=new Map,this.lockType=0,this.transferBlockOwnership=!1,this.persistance=new h(t)}async readIfFallback(){return this.transferBlockOwnership=!0,this.blocks=await this.persistance.readAll(),this.readMeta()}lock(e){return this.cachedFirstBlock=this.blocks.get(0),this.lockType=e,!0}unlock(e){return this.lockType>r&&e===r&&this.flush(),this.lockType=e,!0}delete(){let e=globalThis.indexedDB.deleteDatabase(this.dbName);e.onerror=()=>{console.warn(`Deleting ${this.filename} database failed`)},e.onsuccess=()=>{}}open(){this.writeQueue=[],this.lockType=0}close(){this.flush(),this.transferBlockOwnership?this.transferBlockOwnership=!1:this.blocks=new Map,this.persistance.closeDb()}readMeta(){let e=this.blocks.get(-1);if(e){let t=this.blocks.get(0);return{size:e.size,blockSize:i(new Uint8Array(t))}}return null}writeMeta(e){this.blocks.set(-1,e),this.queueWrite(-1,e)}readBlocks(e,t){let r=[];for(let n of e)r.push({pos:n,data:this.blocks.get(d(n,t))});return r}writeBlocks(e,t){for(let r of e){let e=d(r.pos,t);this.blocks.set(e,r.data),this.queueWrite(e,r.data)}this.lockType<=r&&this.flush()}queueWrite(e,t){this.writeQueue.push({key:e,value:t})}flush(){this.writeQueue.length>0&&(this.persistance.write(this.writeQueue,this.cachedFirstBlock,this.lockType>r),this.writeQueue=[]),this.cachedFirstBlock=null}}t.default=class{constructor(e){this.onFallbackFailure=e}createFile(t){let r;r="undefined"!=typeof SharedArrayBuffer?new f(t):new p(t,this.onFallbackFailure);let n=new s(t,r);return e.env.PERF_BUILD&&(null==this._files&&(this._files=new Set),this._files.add(n)),n}startProfile(){for(let e of this._files)if(e.ops.writer){let t=e.ops.writer,r=e.ops.reader;t.string("profile-start"),t.finalize(),r.int32(),r.done()}}stopProfile(){for(let e of this._files)if(e.ops.writer){let t=e.ops.writer,r=e.ops.reader;t.string("profile-stop"),t.finalize(),r.int32(),r.done()}}}}.call(this,r(19))},function(e,t,r){(function(t,n){const i=r(83),o=r(48);let a,s=o.join(t,"..","..","..","..");n.match("bundle")&&(s=o.join(t,"..")),e.exports={init:()=>{},getDataDir:()=>"/",_setDocumentDir:e=>a=e,getDocumentDir:()=>{if(!a)throw new Error("Document directory is not set");return a},getBudgetDir:t=>{if(!t)throw new Error("getDocumentDir: id is falsy: "+t);if(t.match(/[^A-Za-z0-9\-_]/))throw new Error(`Invalid budget id "${t}". Check the id of your budget in the "Advanced" section of the settings page.`);return o.join(e.exports.getDocumentDir(),t)},bundledDatabasePath:o.join(s,"default-db.sqlite"),migrationsPath:o.join(s,"migrations"),demoBudgetPath:o.join(s,"demo-budget"),join:o.join,basename:e=>o.basename(e),listDir:e=>new Promise((t,r)=>{i.readdir(e,(e,n)=>{e?r(e):t(n)})}),exists:e=>new Promise(t=>{i.access(e,i.constants.F_OK,e=>t(!e))}),mkdir:e=>new Promise((t,r)=>{i.mkdir(e,e=>{e?r(e):t()})}),size:e=>new Promise((t,r)=>{i.stat(e,(e,n)=>{e?r(e):t(n.size)})}),copyFile:(e,t)=>new Promise((r,n)=>{const o=i.createReadStream(e),a=i.createWriteStream(t);o.on("error",n),a.on("error",n),a.on("open",()=>o.pipe(a)),a.once("close",r)}),readFile:(e,t="utf8")=>("binary"===t&&(t=null),new Promise((r,n)=>{i.readFile(e,t,(e,t)=>{e?n(e):r(t)})})),writeFile:(e,t)=>new Promise((function(r,n){i.writeFile(e,t,"utf8",(function(e,t){return e?n(e):r()}))})),removeFile:e=>new Promise((function(t,r){i.unlink(e,e=>e?r(e):t())})),removeDir:e=>new Promise((function(t,r){i.rmdir(e,e=>e?r(e):t())})),removeDirRecursively:async t=>{const r=e.exports;if(await r.exists(t)){for(let e of await r.listDir(t)){const n=r.join(t,e);i.statSync(n).isDirectory()?await r.removeDirRecursively(n):await r.removeFile(n)}await r.removeDir(t)}},getModifiedTime:e=>new Promise((function(t,r){i.stat(e,(e,n)=>{e?r(e):t(new Date(n.mtime))})}))}}).call(this,"/","/index.js")},function(e,t){e.exports=function(...e){if(0===e.length)return".";let t;for(var r=0;r0&&(void 0===t?t=n:t+="/"+n)}return void 0===t?".":function(e){if(0===e.length)return".";var t=47===e.charCodeAt(0),r=47===e.charCodeAt(e.length-1);return 0!==(e=function(e,t){for(var r,n="",i=0,o=-1,a=0,s=0;s<=e.length;++s){if(s2){var u=n.lastIndexOf("/");if(u!==n.length-1){-1===u?(n="",i=0):i=(n=n.slice(0,u)).length-1-n.lastIndexOf("/"),o=s,a=0;continue}}else if(2===n.length||1===n.length){n="",i=0,o=s,a=0;continue}t&&(n.length>0?n+="/..":n="..",i=2)}else n.length>0?n+="/"+e.slice(o+1,s):n=e.slice(o+1,s),i=s-o-1;o=s,a=0}else 46===r&&-1!==a?++a:a=-1}return n}(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e}(t)}},function(e,t,r){var n=r(402),i=r(183),o=r(403),a=r(405),s=r(406),u={symbol:"",thousandsSeparator:",",decimalSeparator:".",symbolOnLeft:!0,spaceBetweenAmountAndSymbol:!1,decimalDigits:2},c={},l=[{symbolOnLeft:!0,spaceBetweenAmountAndSymbol:!1,format:{pos:"%s%v",neg:"-%s%v",zero:"%s%v"}},{symbolOnLeft:!0,spaceBetweenAmountAndSymbol:!0,format:{pos:"%s %v",neg:"-%s %v",zero:"%s %v"}},{symbolOnLeft:!1,spaceBetweenAmountAndSymbol:!1,format:{pos:"%v%s",neg:"-%v%s",zero:"%v%s"}},{symbolOnLeft:!1,spaceBetweenAmountAndSymbol:!0,format:{pos:"%v %s",neg:"-%v %s",zero:"%v %s"}}];function f(e){return a[e]}function d(e){return void 0===e}e.exports={defaultCurrency:u,get currencies(){return Object.keys(a).map((function(e){return a[e]}))},findCurrency:f,format:function(e,t){var r=t.code||t.locale&&o.getCurrency(t.locale),a=/^([a-z]+)([_-]([a-z]+))?$/i.exec(t.locale)||[],h=a[1],p=a[3],g=i({},c,s[h]||{},s[h+"-"+p]||{}),m=i({},u,f(r),g),y=m.symbolOnLeft,b=m.spaceBetweenAmountAndSymbol,_=l.filter((function(e){return e.symbolOnLeft==y&&e.spaceBetweenAmountAndSymbol==b}))[0].format;return n.formatMoney(e,{symbol:d(t.symbol)?m.symbol:t.symbol,decimal:d(t.decimal)?m.decimalSeparator:t.decimal,thousand:d(t.thousand)?m.thousandsSeparator:t.thousand,precision:"number"==typeof t.precision?t.precision:m.decimalDigits,format:["string","object"].indexOf(typeof t.format)>-1?t.format:_})},unformat:function(e,t){var r=t.code||t.locale&&o.getCurrency(t.locale),a=s[t.locale]||c,l=i({},u,f(r),a),h=d(t.decimal)?l.decimalSeparator:t.decimal;return n.unformat(e,h)}}},function(e,t,r){ /*! * accounting.js v0.4.2 * Copyright 2014 Open Exchange Rates * * Freely distributable under the MIT license. * Portions of accounting.js are inspired or borrowed from underscore.js * * Full details and documentation: * http://openexchangerates.github.io/accounting.js/ */ !function(r,n){var i={version:"0.4.2",settings:{currency:{symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3},number:{precision:0,grouping:3,thousand:",",decimal:"."}}},o=Array.prototype.map,a=Array.isArray,s=Object.prototype.toString;function u(e){return!!(""===e||e&&e.charCodeAt&&e.substr)}function c(e){return a?a(e):"[object Array]"===s.call(e)}function l(e){return e&&"[object Object]"===s.call(e)}function f(e,t){var r;for(r in e=e||{},t=t||{})t.hasOwnProperty(r)&&null==e[r]&&(e[r]=t[r]);return e}function d(e,t,r){var n,i,a=[];if(!e)return a;if(o&&e.map===o)return e.map(t,r);for(n=0,i=e.length;n3?u.length%3:0;return s+(p?u.substr(0,p)+o.thousand:"")+u.substr(p).replace(/(\d{3})(?=\d)/g,"$1"+o.thousand)+(a?o.decimal+m(Math.abs(e),a).split(".")[1]:"")},b=i.formatMoney=function(e,t,r,n,o,a){if(c(e))return d(e,(function(e){return b(e,t,r,n,o,a)}));e=g(e);var s=f(l(t)?t:{symbol:t,precision:r,thousand:n,decimal:o,format:a},i.settings.currency),u=p(s.format);return(e>0?u.pos:e<0?u.neg:u.zero).replace("%s",s.symbol).replace("%v",y(Math.abs(e),h(s.precision),s.thousand,s.decimal))};i.formatColumn=function(e,t,r,n,o,a){if(!e||!c(e))return[];var s=f(l(t)?t:{symbol:t,precision:r,thousand:n,decimal:o,format:a},i.settings.currency),m=p(s.format),b=m.pos.indexOf("%s")0?m.pos:e<0?m.neg:m.zero).replace("%s",s.symbol).replace("%v",y(Math.abs(e),h(s.precision),s.thousand,s.decimal));return r.length>_&&(_=r.length),r}));return d(w,(function(e,t){return u(e)&&e.length<_?b?e.replace(s.symbol,s.symbol+new Array(_-e.length+1).join(" ")):new Array(_-e.length+1).join(" ")+e:e}))},e.exports&&(t=e.exports=i),t.accounting=i}()},function(e,t,r){var n=r(404);t.getCurrency=function(e){var t,r,i=(t=e,r=t.split("_"),2==r.length||2==(r=t.split("-")).length?r.pop():t).toUpperCase();return i in n?n[i]:null},t.getLocales=function(e){e=e.toUpperCase();var t=[];for(countryCode in n)n[countryCode]===e&&t.push(countryCode);return t}},function(e,t){e.exports={AD:"EUR",AE:"AED",AF:"AFN",AG:"XCD",AI:"XCD",AL:"ALL",AM:"AMD",AN:"ANG",AO:"AOA",AR:"ARS",AS:"USD",AT:"EUR",AU:"AUD",AW:"AWG",AX:"EUR",AZ:"AZN",BA:"BAM",BB:"BBD",BD:"BDT",BE:"EUR",BF:"XOF",BG:"BGN",BH:"BHD",BI:"BIF",BJ:"XOF",BL:"EUR",BM:"BMD",BN:"BND",BO:"BOB",BQ:"USD",BR:"BRL",BS:"BSD",BT:"BTN",BV:"NOK",BW:"BWP",BY:"BYR",BZ:"BZD",CA:"CAD",CC:"AUD",CD:"CDF",CF:"XAF",CG:"XAF",CH:"CHF",CI:"XOF",CK:"NZD",CL:"CLP",CM:"XAF",CN:"CNY",CO:"COP",CR:"CRC",CU:"CUP",CV:"CVE",CW:"ANG",CX:"AUD",CY:"EUR",CZ:"CZK",DE:"EUR",DJ:"DJF",DK:"DKK",DM:"XCD",DO:"DOP",DZ:"DZD",EC:"USD",EE:"EUR",EG:"EGP",EH:"MAD",ER:"ERN",ES:"EUR",ET:"ETB",FI:"EUR",FJ:"FJD",FK:"FKP",FM:"USD",FO:"DKK",FR:"EUR",GA:"XAF",GB:"GBP",GD:"XCD",GE:"GEL",GF:"EUR",GG:"GBP",GH:"GHS",GI:"GIP",GL:"DKK",GM:"GMD",GN:"GNF",GP:"EUR",GQ:"XAF",GR:"EUR",GS:"GBP",GT:"GTQ",GU:"USD",GW:"XOF",GY:"GYD",HK:"HKD",HM:"AUD",HN:"HNL",HR:"HRK",HT:"HTG",HU:"HUF",ID:"IDR",IE:"EUR",IL:"ILS",IM:"GBP",IN:"INR",IO:"USD",IQ:"IQD",IR:"IRR",IS:"ISK",IT:"EUR",JE:"GBP",JM:"JMD",JO:"JOD",JP:"JPY",KE:"KES",KG:"KGS",KH:"KHR",KI:"AUD",KM:"KMF",KN:"XCD",KP:"KPW",KR:"KRW",KW:"KWD",KY:"KYD",KZ:"KZT",LA:"LAK",LB:"LBP",LC:"XCD",LI:"CHF",LK:"LKR",LR:"LRD",LS:"LSL",LT:"LTL",LU:"EUR",LV:"LVL",LY:"LYD",MA:"MAD",MC:"EUR",MD:"MDL",ME:"EUR",MF:"EUR",MG:"MGA",MH:"USD",MK:"MKD",ML:"XOF",MM:"MMK",MN:"MNT",MO:"MOP",MP:"USD",MQ:"EUR",MR:"MRO",MS:"XCD",MT:"EUR",MU:"MUR",MV:"MVR",MW:"MWK",MX:"MXN",MY:"MYR",MZ:"MZN",NA:"NAD",NC:"XPF",NE:"XOF",NF:"AUD",NG:"NGN",NI:"NIO",NL:"EUR",NO:"NOK",NP:"NPR",NR:"AUD",NU:"NZD",NZ:"NZD",OM:"OMR",PA:"PAB",PE:"PEN",PF:"XPF",PG:"PGK",PH:"PHP",PK:"PKR",PL:"PLN",PM:"EUR",PN:"NZD",PR:"USD",PS:"ILS",PT:"EUR",PW:"USD",PY:"PYG",QA:"QAR",RE:"EUR",RO:"RON",RS:"RSD",RU:"RUB",RW:"RWF",SA:"SAR",SB:"SBD",SC:"SCR",SD:"SDG",SE:"SEK",SG:"SGD",SH:"SHP",SI:"EUR",SJ:"NOK",SK:"EUR",SL:"SLL",SM:"EUR",SN:"XOF",SO:"SOS",SR:"SRD",ST:"STD",SV:"SVC",SX:"ANG",SY:"SYP",SZ:"SZL",TC:"USD",TD:"XAF",TF:"EUR",TG:"XOF",TH:"THB",TJ:"TJS",TK:"NZD",TL:"USD",TM:"TMT",TN:"TND",TO:"TOP",TR:"TRY",TT:"TTD",TV:"AUD",TW:"TWD",TZ:"TZS",UA:"UAH",UG:"UGX",UM:"USD",US:"USD",UY:"UYU",UZ:"UZS",VA:"EUR",VC:"XCD",VE:"VEF",VG:"USD",VI:"USD",VN:"VND",VU:"VUV",WF:"XPF",WS:"WST",YE:"YER",YT:"EUR",ZA:"ZAR",ZM:"ZMK",ZW:"ZWL"}},function(e){e.exports=JSON.parse('{"AED":{"code":"AED","symbol":"د.إ.‏","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"AFN":{"code":"AFN","symbol":"؋","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"ALL":{"code":"ALL","symbol":"Lek","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"AMD":{"code":"AMD","symbol":"֏","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"ANG":{"code":"ANG","symbol":"ƒ","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"AOA":{"code":"AOA","symbol":"Kz","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"ARS":{"code":"ARS","symbol":"$","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"AUD":{"code":"AUD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"AWG":{"code":"AWG","symbol":"ƒ","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"AZN":{"code":"AZN","symbol":"₼","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"BAM":{"code":"BAM","symbol":"КМ","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"BBD":{"code":"BBD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"BDT":{"code":"BDT","symbol":"৳","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":0},"BGN":{"code":"BGN","symbol":"лв.","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"BHD":{"code":"BHD","symbol":"د.ب.‏","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":3},"BIF":{"code":"BIF","symbol":"FBu","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"BMD":{"code":"BMD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"BND":{"code":"BND","symbol":"$","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"BOB":{"code":"BOB","symbol":"Bs","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"BRL":{"code":"BRL","symbol":"R$","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"BSD":{"code":"BSD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"BTC":{"code":"BTC","symbol":"Ƀ","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":8},"BTN":{"code":"BTN","symbol":"Nu.","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":1},"BWP":{"code":"BWP","symbol":"P","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"BYR":{"code":"BYR","symbol":"р.","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"BZD":{"code":"BZD","symbol":"BZ$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"CAD":{"code":"CAD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"CDF":{"code":"CDF","symbol":"FC","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"CHF":{"code":"CHF","symbol":"CHF","thousandsSeparator":"\'","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"CLP":{"code":"CLP","symbol":"$","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"CNY":{"code":"CNY","symbol":"¥","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"COP":{"code":"COP","symbol":"$","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"CRC":{"code":"CRC","symbol":"₡","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"CUC":{"code":"CUC","symbol":"CUC","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"CUP":{"code":"CUP","symbol":"$MN","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"CVE":{"code":"CVE","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"CZK":{"code":"CZK","symbol":"Kč","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"DJF":{"code":"DJF","symbol":"Fdj","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"DKK":{"code":"DKK","symbol":"kr.","thousandsSeparator":"","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"DOP":{"code":"DOP","symbol":"RD$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"DZD":{"code":"DZD","symbol":"د.ج.‏","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"EGP":{"code":"EGP","symbol":"ج.م.‏","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"ERN":{"code":"ERN","symbol":"Nfk","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"ETB":{"code":"ETB","symbol":"ETB","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"EUR":{"code":"EUR","symbol":"€","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"FJD":{"code":"FJD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"FKP":{"code":"FKP","symbol":"£","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"GBP":{"code":"GBP","symbol":"£","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"GEL":{"code":"GEL","symbol":"Lari","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"GHS":{"code":"GHS","symbol":"₵","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"GIP":{"code":"GIP","symbol":"£","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"GMD":{"code":"GMD","symbol":"D","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"GNF":{"code":"GNF","symbol":"FG","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"GTQ":{"code":"GTQ","symbol":"Q","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"GYD":{"code":"GYD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"HKD":{"code":"HKD","symbol":"HK$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"HNL":{"code":"HNL","symbol":"L.","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"HRK":{"code":"HRK","symbol":"kn","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"HTG":{"code":"HTG","symbol":"G","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"HUF":{"code":"HUF","symbol":"Ft","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"IDR":{"code":"IDR","symbol":"Rp","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"ILS":{"code":"ILS","symbol":"₪","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"INR":{"code":"INR","symbol":"₹","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"IQD":{"code":"IQD","symbol":"د.ع.‏","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"IRR":{"code":"IRR","symbol":"﷼","thousandsSeparator":",","decimalSeparator":"/","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"ISK":{"code":"ISK","symbol":"kr.","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":0},"JMD":{"code":"JMD","symbol":"J$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"JOD":{"code":"JOD","symbol":"د.ا.‏","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":3},"JPY":{"code":"JPY","symbol":"¥","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"KES":{"code":"KES","symbol":"KSh","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"KGS":{"code":"KGS","symbol":"сом","thousandsSeparator":" ","decimalSeparator":"-","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"KHR":{"code":"KHR","symbol":"៛","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"KMF":{"code":"KMF","symbol":"CF","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"KPW":{"code":"KPW","symbol":"₩","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"KRW":{"code":"KRW","symbol":"₩","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"KWD":{"code":"KWD","symbol":"د.ك.‏","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":3},"KYD":{"code":"KYD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"KZT":{"code":"KZT","symbol":"₸","thousandsSeparator":" ","decimalSeparator":"-","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"LAK":{"code":"LAK","symbol":"₭","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"LBP":{"code":"LBP","symbol":"ل.ل.‏","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"LKR":{"code":"LKR","symbol":"₨","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":0},"LRD":{"code":"LRD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"LSL":{"code":"LSL","symbol":"M","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"LYD":{"code":"LYD","symbol":"د.ل.‏","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":3},"MAD":{"code":"MAD","symbol":"د.م.‏","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"MDL":{"code":"MDL","symbol":"lei","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"MGA":{"code":"MGA","symbol":"Ar","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"MKD":{"code":"MKD","symbol":"ден.","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"MMK":{"code":"MMK","symbol":"K","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"MNT":{"code":"MNT","symbol":"₮","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"MOP":{"code":"MOP","symbol":"MOP$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"MRO":{"code":"MRO","symbol":"UM","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"MTL":{"code":"MTL","symbol":"₤","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"MUR":{"code":"MUR","symbol":"₨","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"MVR":{"code":"MVR","symbol":"MVR","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":1},"MWK":{"code":"MWK","symbol":"MK","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"MXN":{"code":"MXN","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"MYR":{"code":"MYR","symbol":"RM","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"MZN":{"code":"MZN","symbol":"MT","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"NAD":{"code":"NAD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"NGN":{"code":"NGN","symbol":"₦","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"NIO":{"code":"NIO","symbol":"C$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"NOK":{"code":"NOK","symbol":"kr","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"NPR":{"code":"NPR","symbol":"₨","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"NZD":{"code":"NZD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"OMR":{"code":"OMR","symbol":"﷼","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":3},"PAB":{"code":"PAB","symbol":"B/.","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"PEN":{"code":"PEN","symbol":"S/.","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"PGK":{"code":"PGK","symbol":"K","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"PHP":{"code":"PHP","symbol":"₱","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"PKR":{"code":"PKR","symbol":"₨","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"PLN":{"code":"PLN","symbol":"zł","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"PYG":{"code":"PYG","symbol":"₲","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"QAR":{"code":"QAR","symbol":"﷼","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"RON":{"code":"RON","symbol":"lei","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"RSD":{"code":"RSD","symbol":"Дин.","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"RUB":{"code":"RUB","symbol":"₽","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"RWF":{"code":"RWF","symbol":"RWF","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"SAR":{"code":"SAR","symbol":"﷼","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"SBD":{"code":"SBD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"SCR":{"code":"SCR","symbol":"₨","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"SDD":{"code":"SDD","symbol":"LSd","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"SDG":{"code":"SDG","symbol":"£‏","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"SEK":{"code":"SEK","symbol":"kr","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"SGD":{"code":"SGD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"SHP":{"code":"SHP","symbol":"£","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"SLL":{"code":"SLL","symbol":"Le","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"SOS":{"code":"SOS","symbol":"S","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"SRD":{"code":"SRD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"STD":{"code":"STD","symbol":"Db","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"SVC":{"code":"SVC","symbol":"₡","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"SYP":{"code":"SYP","symbol":"£","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"SZL":{"code":"SZL","symbol":"E","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"THB":{"code":"THB","symbol":"฿","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"TJS":{"code":"TJS","symbol":"TJS","thousandsSeparator":" ","decimalSeparator":";","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"TMT":{"code":"TMT","symbol":"m","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"TND":{"code":"TND","symbol":"د.ت.‏","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":3},"TOP":{"code":"TOP","symbol":"T$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"TRY":{"code":"TRY","symbol":"₺","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"TTD":{"code":"TTD","symbol":"TT$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"TVD":{"code":"TVD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"TWD":{"code":"TWD","symbol":"NT$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"TZS":{"code":"TZS","symbol":"TSh","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"UAH":{"code":"UAH","symbol":"₴","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"UGX":{"code":"UGX","symbol":"USh","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"USD":{"code":"USD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"UYU":{"code":"UYU","symbol":"$U","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"UZS":{"code":"UZS","symbol":"сўм","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"VEB":{"code":"VEB","symbol":"Bs.","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"VEF":{"code":"VEF","symbol":"Bs. F.","thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"VND":{"code":"VND","symbol":"₫","thousandsSeparator":".","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":0},"VUV":{"code":"VUV","symbol":"VT","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":0},"WST":{"code":"WST","symbol":"WS$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"XAF":{"code":"XAF","symbol":"F","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"XCD":{"code":"XCD","symbol":"$","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"XBT":{"code":"XBT","symbol":"Ƀ","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"XOF":{"code":"XOF","symbol":"F","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"XPF":{"code":"XPF","symbol":"F","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"YER":{"code":"YER","symbol":"﷼","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"ZAR":{"code":"ZAR","symbol":"R","thousandsSeparator":" ","decimalSeparator":",","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"ZMW":{"code":"ZMW","symbol":"ZK","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"WON":{"code":"WON","symbol":"₩","thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2}}')},function(e){e.exports=JSON.parse('{"de":{"thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"el":{"symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"thousandsSeparator":".","decimalSeparator":",","decimalDigits":2},"en-US":{"thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"en-IE":{"symbolOnLeft":true,"thousandsSeparator":",","decimalSeparator":".","spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"zh-CN":{"thousandsSeparator":",","decimalSeparator":".","symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"decimalDigits":2},"es":{"thousandsSeparator":".","decimalSeparator":",","symbolOnLeft":false,"spaceBetweenAmountAndSymbol":true,"decimalDigits":2},"it":{"symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"thousandsSeparator":".","decimalSeparator":",","decimalDigits":2},"nl":{"symbolOnLeft":true,"spaceBetweenAmountAndSymbol":false,"thousandsSeparator":".","decimalSeparator":",","decimalDigits":2}}')},function(e,t,r){var n,i,o=r(238),a=r(239),s=0,u=0;e.exports=function(e,t,r){var c=t&&r||0,l=t||[],f=(e=e||{}).node||n,d=void 0!==e.clockseq?e.clockseq:i;if(null==f||null==d){var h=o();null==f&&(f=n=[1|h[0],h[1],h[2],h[3],h[4],h[5]]),null==d&&(d=i=16383&(h[6]<<8|h[7]))}var p=void 0!==e.msecs?e.msecs:(new Date).getTime(),g=void 0!==e.nsecs?e.nsecs:u+1,m=p-s+(g-u)/1e4;if(m<0&&void 0===e.clockseq&&(d=d+1&16383),(m<0||p>s)&&void 0===e.nsecs&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");s=p,u=g,i=d;var y=(1e4*(268435455&(p+=122192928e5))+g)%4294967296;l[c++]=y>>>24&255,l[c++]=y>>>16&255,l[c++]=y>>>8&255,l[c++]=255&y;var b=p/4294967296*1e4&268435455;l[c++]=b>>>8&255,l[c++]=255&b,l[c++]=b>>>24&15|16,l[c++]=b>>>16&255,l[c++]=d>>>8|128,l[c++]=255&d;for(var _=0;_<6;++_)l[c+_]=f[_];return t||a(l)}},function(e,t,r){var n=r(238),i=r(239);e.exports=function(e,t,r){var o=t&&r||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var a=(e=e||{}).random||(e.rng||n)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t)for(var s=0;s<16;++s)t[o+s]=a[s];return t||i(a)}},function(e,t){e.exports=function(e){var t={addNode:i,removeNode:function(e){o(e),r.delete(e),n.delete(e)},adjacent:a,adjacentIncoming:s,addEdge:function(e,r){return i(e),i(r),a(e).add(r),s(r).add(e),t},removeEdge:u,removeIncomingEdges:o,topologicalSort:function(e){const t=new Set,r=[];return e.forEach(e=>{t.has(e)||function e(t,r,n){r.add(t);let i=a(t).values(),o=i.next();for(;!o.done;)r.has(o.value)||e(o.value,r,n),o=i.next();n.unshift(t)}(e,t,r)}),r},generateDOT:function(){let e=[];return r.forEach((function(t,r){0!==t.length&&e.push(`${r} -> {${t.join(",")}}`)})),`\n digraph G {\n ${e.join("\n").replace(/!/g,"_")}\n }\n `},getEdges:function(){return{edges:r,incomingEdges:n}}},r=new Map,n=new Map;function i(e){return r.set(e,a(e)),n.set(e,s(e)),t}function o(e){const t=s(e);n.set(e,new Set);let r=t.values(),i=r.next();for(;!i.done;)u(i.value,e),i=r.next()}function a(e){return r.get(e)||new Set}function s(e){return n.get(e)||new Set}function u(e,i){return r.has(e)&&a(e).delete(i),n.has(i)&&s(i).delete(e),t}return t}},function(e,t,r){const n=r(119);e.exports={v4:function(){return Promise.resolve(n.v4())},v4Sync:function(){return n.v4()}}},function(module,exports,__webpack_require__){(function(global,Buffer){var $jscomp=$jscomp||{};$jscomp.scope={},$jscomp.findInternal=function(e,t,r){e instanceof String&&(e=String(e));for(var n=e.length,i=0;i=n}}),"es6","es3"),$jscomp.polyfill("Array.prototype.find",(function(e){return e||function(e,t){return $jscomp.findInternal(this,e,t).v}}),"es6","es3"),$jscomp.polyfill("String.prototype.startsWith",(function(e){return e||function(e,t){var r=$jscomp.checkStringArgs(this,e,"startsWith");e+="";var n=r.length,i=e.length;t=Math.max(0,Math.min(0|t,r.length));for(var o=0;o=i}}),"es6","es3"),$jscomp.polyfill("String.prototype.repeat",(function(e){return e||function(e){var t=$jscomp.checkStringArgs(this,null,"repeat");if(0>e||1342177279>>=1)&&(t+=t);return r}}),"es6","es3");var COMPILED=!0,goog=goog||{};goog.global=this||self,goog.isDef=function(e){return void 0!==e},goog.isString=function(e){return"string"==typeof e},goog.isBoolean=function(e){return"boolean"==typeof e},goog.isNumber=function(e){return"number"==typeof e},goog.exportPath_=function(e,t,r){e=e.split("."),r=r||goog.global,e[0]in r||void 0===r.execScript||r.execScript("var "+e[0]);for(var n;e.length&&(n=e.shift());)!e.length&&goog.isDef(t)?r[n]=t:r=r[n]&&r[n]!==Object.prototype[n]?r[n]:r[n]={}},goog.define=function(e,t){if(!COMPILED){var r=goog.global.CLOSURE_UNCOMPILED_DEFINES,n=goog.global.CLOSURE_DEFINES;r&&void 0===r.nodeType&&Object.prototype.hasOwnProperty.call(r,e)?t=r[e]:n&&void 0===n.nodeType&&Object.prototype.hasOwnProperty.call(n,e)&&(t=n[e])}return t},goog.FEATURESET_YEAR=2012,goog.DEBUG=!0,goog.LOCALE="en",goog.TRUSTED_SITE=!0,goog.STRICT_MODE_COMPATIBLE=!1,goog.DISALLOW_TEST_ONLY_CODE=COMPILED&&!goog.DEBUG,goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING=!1,goog.provide=function(e){if(goog.isInModuleLoader_())throw Error("goog.provide cannot be used within a module.");if(!COMPILED&&goog.isProvided_(e))throw Error('Namespace "'+e+'" already declared.');goog.constructNamespace_(e)},goog.constructNamespace_=function(e,t){if(!COMPILED){delete goog.implicitNamespaces_[e];for(var r=e;(r=r.substring(0,r.lastIndexOf(".")))&&!goog.getObjectByName(r);)goog.implicitNamespaces_[r]=!0}goog.exportPath_(e,t)},goog.getScriptNonce=function(e){return e&&e!=goog.global?goog.getScriptNonce_(e.document):(null===goog.cspNonce_&&(goog.cspNonce_=goog.getScriptNonce_(goog.global.document)),goog.cspNonce_)},goog.NONCE_PATTERN_=/^[\w+/_-]+[=]{0,2}$/,goog.cspNonce_=null,goog.getScriptNonce_=function(e){return(e=e.querySelector&&e.querySelector("script[nonce]"))&&(e=e.nonce||e.getAttribute("nonce"))&&goog.NONCE_PATTERN_.test(e)?e:""},goog.VALID_MODULE_RE_=/^[a-zA-Z_$][a-zA-Z0-9._$]*$/,goog.module=function(e){if(!goog.isString(e)||!e||-1==e.search(goog.VALID_MODULE_RE_))throw Error("Invalid module identifier");if(!goog.isInGoogModuleLoader_())throw Error("Module "+e+" has been loaded incorrectly. Note, modules cannot be loaded as normal scripts. They require some kind of pre-processing step. You're likely trying to load a module via a script tag or as a part of a concatenated bundle without rewriting the module. For more info see: https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide.");if(goog.moduleLoaderState_.moduleName)throw Error("goog.module may only be called once per module.");if(goog.moduleLoaderState_.moduleName=e,!COMPILED){if(goog.isProvided_(e))throw Error('Namespace "'+e+'" already declared.');delete goog.implicitNamespaces_[e]}},goog.module.get=function(e){return goog.module.getInternal_(e)},goog.module.getInternal_=function(e){if(!COMPILED){if(e in goog.loadedModules_)return goog.loadedModules_[e].exports;if(!goog.implicitNamespaces_[e])return null!=(e=goog.getObjectByName(e))?e:null}return null},goog.ModuleType={ES6:"es6",GOOG:"goog"},goog.moduleLoaderState_=null,goog.isInModuleLoader_=function(){return goog.isInGoogModuleLoader_()||goog.isInEs6ModuleLoader_()},goog.isInGoogModuleLoader_=function(){return!!goog.moduleLoaderState_&&goog.moduleLoaderState_.type==goog.ModuleType.GOOG},goog.isInEs6ModuleLoader_=function(){if(goog.moduleLoaderState_&&goog.moduleLoaderState_.type==goog.ModuleType.ES6)return!0;var e=goog.global.$jscomp;return!!e&&("function"==typeof e.getCurrentModulePath&&!!e.getCurrentModulePath())},goog.module.declareLegacyNamespace=function(){if(!COMPILED&&!goog.isInGoogModuleLoader_())throw Error("goog.module.declareLegacyNamespace must be called from within a goog.module");if(!COMPILED&&!goog.moduleLoaderState_.moduleName)throw Error("goog.module must be called prior to goog.module.declareLegacyNamespace.");goog.moduleLoaderState_.declareLegacyNamespace=!0},goog.declareModuleId=function(e){if(!COMPILED){if(!goog.isInEs6ModuleLoader_())throw Error("goog.declareModuleId may only be called from within an ES6 module");if(goog.moduleLoaderState_&&goog.moduleLoaderState_.moduleName)throw Error("goog.declareModuleId may only be called once per module.");if(e in goog.loadedModules_)throw Error('Module with namespace "'+e+'" already exists.')}if(goog.moduleLoaderState_)goog.moduleLoaderState_.moduleName=e;else{var t=goog.global.$jscomp;if(!t||"function"!=typeof t.getCurrentModulePath)throw Error('Module with namespace "'+e+'" has been loaded incorrectly.');t=t.require(t.getCurrentModulePath()),goog.loadedModules_[e]={exports:t,type:goog.ModuleType.ES6,moduleId:e}}},goog.setTestOnly=function(e){if(goog.DISALLOW_TEST_ONLY_CODE)throw e=e||"",Error("Importing test-only code into non-debug environment"+(e?": "+e:"."))},goog.forwardDeclare=function(e){},COMPILED||(goog.isProvided_=function(e){return e in goog.loadedModules_||!goog.implicitNamespaces_[e]&&goog.isDefAndNotNull(goog.getObjectByName(e))},goog.implicitNamespaces_={"goog.module":!0}),goog.getObjectByName=function(e,t){e=e.split("."),t=t||goog.global;for(var r=0;r>>0),goog.uidCounter_=0,goog.getHashCode=goog.getUid,goog.removeHashCode=goog.removeUid,goog.cloneObject=function(e){var t=goog.typeOf(e);if("object"==t||"array"==t){if("function"==typeof e.clone)return e.clone();for(var r in t="array"==t?[]:{},e)t[r]=goog.cloneObject(e[r]);return t}return e},goog.bindNative_=function(e,t,r){return e.call.apply(e.bind,arguments)},goog.bindJs_=function(e,t,r){if(!e)throw Error();if(2{"use strict";class X{constructor(){if(new.target!=String)throw 1;this.x=42}}let q=Reflect.construct(X,[],String);if(q.x!=42||!(q instanceof String))throw 1;for(const a of[2,3]){if(a==2)continue;function f(z={a}){let a=0;return z.a}{function f(){return 0;}}return f()==3}})()')})),a("es7",(function(){return b("2 ** 2 == 4")})),a("es8",(function(){return b("async () => 1, true")})),a("es9",(function(){return b("({...rest} = {}), true")})),a("es_next",(function(){return!1})),{target:c,map:d}},goog.Transpiler.prototype.needsTranspile=function(e,t){if("always"==goog.TRANSPILE)return!0;if("never"==goog.TRANSPILE)return!1;if(!this.requiresTranspilation_){var r=this.createRequiresTranspilation_();this.requiresTranspilation_=r.map,this.transpilationTarget_=this.transpilationTarget_||r.target}if(e in this.requiresTranspilation_)return!!this.requiresTranspilation_[e]||!(!goog.inHtmlDocument_()||"es6"!=t||"noModule"in goog.global.document.createElement("script"));throw Error("Unknown language mode: "+e)},goog.Transpiler.prototype.transpile=function(e,t){return goog.transpile_(e,t,this.transpilationTarget_)},goog.transpiler_=new goog.Transpiler,goog.protectScriptTag_=function(e){return e.replace(/<\/(SCRIPT)/gi,"\\x3c/$1")},goog.DebugLoader_=function(){this.dependencies_={},this.idToPath_={},this.written_={},this.loadingDeps_=[],this.depsToLoad_=[],this.paused_=!1,this.factory_=new goog.DependencyFactory(goog.transpiler_),this.deferredCallbacks_={},this.deferredQueue_=[]},goog.DebugLoader_.prototype.bootstrap=function(e,t){function r(){n&&(goog.global.setTimeout(n,0),n=null)}var n=t;if(e.length){t=[];for(var i=0;i<\/script>",t.write(goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createHTML(n):n)}else{var i=t.createElement("script");i.defer=goog.Dependency.defer_,i.async=!1,i.type="text/javascript",(n=goog.getScriptNonce())&&i.setAttribute("nonce",n),goog.DebugLoader_.IS_OLD_IE_?(e.pause(),i.onreadystatechange=function(){"loaded"!=i.readyState&&"complete"!=i.readyState||(e.loaded(),e.resume())}):i.onload=function(){i.onload=null,e.loaded()},i.src=goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createScriptURL(this.path):this.path,t.head.appendChild(i)}}else goog.logToConsole_("Cannot use default debug loader outside of HTML documents."),"deps.js"==this.relativePath?(goog.logToConsole_("Consider setting CLOSURE_IMPORT_SCRIPT before loading base.js, or setting CLOSURE_NO_DEPS to true."),e.loaded()):e.pause()},goog.Es6ModuleDependency=function(e,t,r,n,i){goog.Dependency.call(this,e,t,r,n,i)},goog.inherits(goog.Es6ModuleDependency,goog.Dependency),goog.Es6ModuleDependency.prototype.load=function(e){if(goog.global.CLOSURE_IMPORT_SCRIPT)goog.global.CLOSURE_IMPORT_SCRIPT(this.path)?e.loaded():e.pause();else if(goog.inHtmlDocument_()){var t=goog.global.document,r=this;if(goog.isDocumentLoading_()){var n=function(e,r){e=r?'