diff --git a/README.md b/README.md index 92a1c40..29a36cd 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,14 @@ https://forevermatt.github.io/svelte-budget/ when creating a new transaction and when editing an existing transaction) - [x] Enable seeing a category's transactions - [ ] Update Category view to show both budgeted and remaining amounts -- [ ] Add "next" buttons to allow progressing through record-an-expense using +- [x] Add "next" buttons to allow progressing through record-an-expense using a mouse - [x] Autofocus the appropriate input (where applicable) on arrival at each page - [ ] Allow adding a comment/note on each transaction +- [ ] Handle page reloads in the middle of the add-expense process (which + loses the timestamp, for example) +- [ ] Add a data-breadcrumb trail as they enter data for a new transaction - [ ] ... ## Data Structure @@ -41,4 +44,4 @@ https://github.com/forevermatt/budget-data specification. ### Icons The list of icons available in the library I'm using can be found here: -https://fontawesome.com/icons?d=gallery +https://fontawesome.com/icons?d=gallery&s=solid&m=free diff --git a/assets/bundle.js b/assets/bundle.js index 1f1570b..58779e9 100644 --- a/assets/bundle.js +++ b/assets/bundle.js @@ -1 +1 @@ -var app=function(){"use strict";function t(){}function n(t,n){for(const e in n)t[e]=n[e];return t}function e(t){return t()}function r(){return Object.create(null)}function o(t){t.forEach(e)}function s(t){return"function"==typeof t}function c(t,n){return t!=t?n==n:t!==n||t&&"object"==typeof t||"function"==typeof t}function u(n,...e){if(null==n)return t;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function a(t){let n;return u(t,t=>n=t)(),n}function i(t,n,e){t.$$.on_destroy.push(u(n,e))}function l(t,n,e,r){if(t){const o=f(t,n,e,r);return t[0](o)}}function f(t,e,r,o){return t[1]&&o?n(r.ctx.slice(),t[1](o(e))):r.ctx}function $(t,n,e,r,o,s,c){const u=function(t,n,e,r){if(t[2]&&r){const o=t[2](r(e));if(void 0===n.dirty)return o;if("object"==typeof o){const t=[],e=Math.max(n.dirty.length,o.length);for(let r=0;rt.removeEventListener(n,e,r)}function C(t){return function(n){return n.preventDefault(),t.call(this,n)}}function A(t,n,e){null==e?t.removeAttribute(n):t.getAttribute(n)!==e&&t.setAttribute(n,e)}function _(t,n){n=""+n,t.wholeText!==n&&(t.data=n)}function N(t,n){t.value=null==n?"":n}function O(t,n,e,r){t.style.setProperty(n,e,r?"important":"")}function j(t,n,e){t.classList[e?"add":"remove"](n)}let S;function L(t){S=t}function M(){if(!S)throw new Error("Function called outside component initialization");return S}function D(t){M().$$.on_mount.push(t)}function T(){const t=M();return(n,e)=>{const r=t.$$.callbacks[n];if(r){const o=function(t,n){const e=document.createEvent("CustomEvent");return e.initCustomEvent(t,!1,!1,n),e}(n,e);r.slice().forEach(n=>{n.call(t,o)})}}}function H(t,n){const e=t.$$.callbacks[n.type];e&&e.slice().forEach(t=>t(n))}const V=[],z=[],P=[],R=[],I=Promise.resolve();let B=!1;function F(){B||(B=!0,I.then(W))}function q(){return F(),I}function U(t){P.push(t)}let Y=!1;const J=new Set;function W(){if(!Y){Y=!0;do{for(let t=0;t{K.delete(t),r&&(e&&t.d(1),r())}),t.o(n)}}function et(t,n){t.d(1),n.delete(t.key)}function rt(t,n,e,r,o,s,c,u,a,i,l,f){let $=t.length,d=s.length,p=$;const m={};for(;p--;)m[t[p].key]=p;const g=[],h=new Map,y=new Map;for(p=d;p--;){const t=f(o,s,p),u=e(t);let a=c.get(u);a?r&&a.p(t,n):(a=i(u,t),a.c()),h.set(u,g[p]=a),u in m&&y.set(u,Math.abs(p-m[u]))}const b=new Set,w=new Set;function x(t){tt(t,1),t.m(u,l),c.set(t.key,t),l=t.first,d--}for(;$&&d;){const n=g[d-1],e=t[$-1],r=n.key,o=e.key;n===e?(l=n.first,$--,d--):h.has(o)?!c.has(r)||b.has(r)?x(n):w.has(o)?$--:y.get(r)>y.get(o)?(w.add(r),x(n)):(b.add(o),$--):(a(e,c),$--)}for(;$--;){const n=t[$];h.has(n.key)||a(n,c)}for(;d;)x(g[d-1]);return g}function ot(t){t&&t.c()}function st(t,n,r){const{fragment:c,on_mount:u,on_destroy:a,after_update:i}=t.$$;c&&c.m(n,r),U(()=>{const n=u.map(e).filter(s);a?a.push(...n):o(n),t.$$.on_mount=[]}),i.forEach(U)}function ct(t,n){const e=t.$$;null!==e.fragment&&(o(e.on_destroy),e.fragment&&e.fragment.d(n),e.on_destroy=e.fragment=null,e.ctx=[])}function ut(n,e,s,c,u,a,i=[-1]){const l=S;L(n);const f=e.props||{},$=n.$$={fragment:null,ctx:null,props:a,update:t,not_equal:u,bound:r(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(l?l.$$.context:[]),callbacks:r(),dirty:i,skip_bound:!1};let d=!1;if($.ctx=s?s(n,f,(t,e,...r)=>{const o=r.length?r[0]:e;return $.ctx&&u($.ctx[t],$.ctx[t]=o)&&(!$.skip_bound&&$.bound[t]&&$.bound[t](o),d&&function(t,n){-1===t.$$.dirty[0]&&(V.push(t),F(),t.$$.dirty.fill(0)),t.$$.dirty[n/31|0]|=1<{const t=e.indexOf(n);-1!==t&&e.splice(t,1)}}$set(t){var n;this.$$set&&(n=t,0!==Object.keys(n).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const it=(t,n)=>{n.update(n=>[t,...n])},lt=Array.isArray,ft=t=>{const n=$t(t);return lt(n)?n:[]},$t=t=>{const n=localStorage.getItem(t);return JSON.parse(n)},dt=(t,n)=>{localStorage.setItem(t,JSON.stringify(n))},pt=[];function mt(t,n){return{subscribe:gt(t,n).subscribe}}function gt(n,e=t){let r;const o=[];function s(t){if(c(n,t)&&(n=t,r)){const t=!pt.length;for(let t=0;t{const t=o.indexOf(a);-1!==t&&o.splice(t,1),0===o.length&&(r(),r=null)}}}}function ht(n,e,r){const c=!Array.isArray(n),a=c?[n]:n,i=e.length<2;return mt(r,n=>{let r=!1;const l=[];let f=0,$=t;const d=()=>{if(f)return;$();const r=e(c?l[0]:l,n);i?n(r):$=s(r)?r:t},p=a.map((t,n)=>u(t,t=>{l[n]=t,f&=~(1<{f|=1<Et.set("");function At(t){let n,e,r,o,s,c;return{c(){n=b("div"),e=b("button"),e.innerHTML='',r=v(),o=x(t[0]),A(e,"type","button"),A(e,"class","close"),A(e,"aria-label","Close"),A(n,"class","alert alert-danger keep-line-breaks svelte-1anyckn"),A(n,"role","alert")},m(t,u){g(t,n,u),m(n,e),m(n,r),m(n,o),s||(c=E(e,"click",Ct),s=!0)},p(t,n){1&n&&_(o,t[0])},d(t){t&&h(n),s=!1,c()}}}function _t(n){let e,r=n[0]&&At(n);return{c(){r&&r.c(),e=k()},m(t,n){r&&r.m(t,n),g(t,e,n)},p(t,[n]){t[0]?r?r.p(t,n):(r=At(t),r.c(),r.m(e.parentNode,e)):r&&(r.d(1),r=null)},i:t,o:t,d(t){r&&r.d(t),t&&h(e)}}}function Nt(t,n,e){let r;return i(t,Et,t=>e(0,r=t)),[r]}window.onunhandledrejection=t=>{let n=t.reason;Et.set(n.message)};class Ot extends at{constructor(t){super(),ut(this,t,Nt,_t,c,{})}}const jt=gt([]),St=()=>dt("accounts",a(jt)),Lt=gt([]),Mt=(t,n)=>n.find(n=>n.uuid===t)||{},Dt=()=>dt("categories",a(Lt)),Tt=(t,n)=>{((t,n,e,r)=>{r.update(r=>{const o=r.find(e=>e[t]===n),s=Object.assign({},o,e);let c=!1;for(let e=0;enew Date(t).toLocaleDateString(),Vt=t=>{let n=new Date(t);const e=n.getFullYear(),r=n.getMonth()+1,o=n.getDate();return`${e}-${String(r).padStart(2,"0")}-${String(o).padStart(2,"0")}`},zt=(t,n)=>{var e=n.getFullYear(),r=n.getMonth(),o=new Date(e,r-t),s=o.getFullYear(),c=o.getMonth()+1;return s+"-"+String("0"+c).slice(-2)},Pt=gt({}),Rt=t=>a(Pt)[t]||{},It=t=>Rt(t).budgeted||0,Bt=()=>{Pt.set((t=>{const n=$t(t);return null!==n?n:{}})("budget"))},Ft=(t,n)=>{a(Pt);(t=>a(Pt).hasOwnProperty(t))(t)?Yt(t,n):((t,n)=>{Ut(t,{budgeted:n,remaining:n,refilled:zt(0,new Date)})})(t,n)},qt=(t,n)=>{const e=Rt(t).remaining||0;Ut(t,{remaining:e-n})},Ut=(t,n)=>{((t,n,e)=>{e.update(e=>(e.hasOwnProperty(t)?e[t]=Object.assign(e[t],n):e[t]=n,e))})(t,n,Pt),dt("budget",a(Pt))},Yt=(t,n)=>{let e=a(Pt)[t],r=e.budgeted,o=e.remaining;Ut(t,{budgeted:n,remaining:o+(n-r)})},Jt=gt([]),Wt=gt({}),Gt=t=>{const n=Object.assign({},t);Wt.set(n)},Kt=t=>a(Jt).filter(n=>(n.categoryAmounts||{}).hasOwnProperty(t)),Qt=()=>dt("transactions",a(Jt)),Xt=t=>{const n=a(Wt),e=Object.assign({},n,t);Wt.set(e)};function Zt(t){let n,e,r;var o=t[0];return o&&(n=new o({}),n.$on("routeEvent",t[5])),{c(){n&&ot(n.$$.fragment),e=k()},m(t,o){n&&st(n,t,o),g(t,e,o),r=!0},p(t,r){if(o!==(o=t[0])){if(n){X();const t=n;nt(t.$$.fragment,1,0,()=>{ct(t,1)}),Z()}o?(n=new o({}),n.$on("routeEvent",t[5]),ot(n.$$.fragment),tt(n.$$.fragment,1),st(n,e.parentNode,e)):n=null}},i(t){r||(n&&tt(n.$$.fragment,t),r=!0)},o(t){n&&nt(n.$$.fragment,t),r=!1},d(t){t&&h(e),n&&ct(n,t)}}}function tn(t){let n,e,r;var o=t[0];function s(t){return{props:{params:t[1]}}}return o&&(n=new o(s(t)),n.$on("routeEvent",t[4])),{c(){n&&ot(n.$$.fragment),e=k()},m(t,o){n&&st(n,t,o),g(t,e,o),r=!0},p(t,r){const c={};if(2&r&&(c.params=t[1]),o!==(o=t[0])){if(n){X();const t=n;nt(t.$$.fragment,1,0,()=>{ct(t,1)}),Z()}o?(n=new o(s(t)),n.$on("routeEvent",t[4]),ot(n.$$.fragment),tt(n.$$.fragment,1),st(n,e.parentNode,e)):n=null}else o&&n.$set(c)},i(t){r||(n&&tt(n.$$.fragment,t),r=!0)},o(t){n&&nt(n.$$.fragment,t),r=!1},d(t){t&&h(e),n&&ct(n,t)}}}function nn(t){let n,e,r,o;const s=[tn,Zt],c=[];function u(t,n){return t[1]?0:1}return n=u(t),e=c[n]=s[n](t),{c(){e.c(),r=k()},m(t,e){c[n].m(t,e),g(t,r,e),o=!0},p(t,[o]){let a=n;n=u(t),n===a?c[n].p(t,o):(X(),nt(c[a],1,1,()=>{c[a]=null}),Z(),e=c[n],e||(e=c[n]=s[n](t),e.c()),tt(e,1),e.m(r.parentNode,r))},i(t){o||(tt(e),o=!0)},o(t){nt(e),o=!1},d(t){c[n].d(t),t&&h(r)}}}function en(){const t=window.location.href.indexOf("#/");let n=t>-1?window.location.href.substr(t+1):"/";const e=n.indexOf("?");let r="";return e>-1&&(r=n.substr(e+1),n=n.substr(0,e)),{location:n,querystring:r}}const rn=mt(null,(function(t){t(en());const n=()=>{t(en())};return window.addEventListener("hashchange",n,!1),function(){window.removeEventListener("hashchange",n,!1)}}));ht(rn,t=>t.location),ht(rn,t=>t.querystring);function on(t){if(!t||t.length<1||"/"!=t.charAt(0)&&0!==t.indexOf("#/"))throw Error("Invalid parameter location");return q().then(()=>{window.location.hash=("#"==t.charAt(0)?"":"#")+t})}function sn(n,e,r){let o,s=t;i(n,rn,t=>r(6,o=t)),n.$$.on_destroy.push(()=>s());let{routes:c={}}=e,{prefix:u=""}=e;class a{constructor(t,n){if(!n||"function"!=typeof n&&("object"!=typeof n||!0!==n._sveltesparouter))throw Error("Invalid component object");if(!t||"string"==typeof t&&(t.length<1||"/"!=t.charAt(0)&&"*"!=t.charAt(0))||"object"==typeof t&&!(t instanceof RegExp))throw Error('Invalid value for "path" argument');const{pattern:e,keys:r}=function(t,n){if(t instanceof RegExp)return{keys:!1,pattern:t};var e,r,o,s,c=[],u="",a=t.split("/");for(a[0]||a.shift();o=a.shift();)"*"===(e=o[0])?(c.push("wild"),u+="/(.*)"):":"===e?(r=o.indexOf("?",1),s=o.indexOf(".",1),c.push(o.substring(1,~r?r:~s?s:o.length)),u+=~r&&!~s?"(?:/([^/]+?))?":"/([^/]+?)",~s&&(u+=(~r?"?":"")+"\\"+o.substring(s))):u+="/"+o;return{keys:c,pattern:new RegExp("^"+u+(n?"(?=$|/)":"/?$"),"i")}}(t);this.path=t,"object"==typeof n&&!0===n._sveltesparouter?(this.component=n.route,this.conditions=n.conditions||[],this.userData=n.userData):(this.component=n,this.conditions=[],this.userData=void 0),this._pattern=e,this._keys=r}match(t){u&&t.startsWith(u)&&(t=t.substr(u.length)||"/");const n=this._pattern.exec(t);if(null===n)return null;if(!1===this._keys)return n;const e={};let r=0;for(;r{l.push(new a(n,t))}):Object.keys(c).forEach(t=>{l.push(new a(t,c[t]))});let f=null,$=null;const d=T(),p=(t,n)=>{q().then(()=>{d(t,n)})};return n.$$set=t=>{"routes"in t&&r(2,c=t.routes),"prefix"in t&&r(3,u=t.prefix)},n.$$.update=()=>{if(65&n.$$.dirty){r(0,f=null);let t=0;for(;!f&&t{"autofocusElement"in t&&e(0,s=t.autofocusElement),"$$scope"in t&&e(1,o=t.$$scope)},t.$$.update=()=>{1&t.$$.dirty&&s.focus&&s.focus()},[s,o,r,function(n){H(t,n)}]}class ln extends at{constructor(t){super(),ut(this,t,an,un,c,{autofocusElement:0})}}function fn(t){let n,e,r;return{c(){n=b("input"),A(n,"class","form-control"),A(n,"placeholder","New account name")},m(o,s){g(o,n,s),N(n,t[0]),t[4](n),e||(r=E(n,"input",t[3]),e=!0)},p(t,e){1&e&&n.value!==t[0]&&N(n,t[0])},d(o){o&&h(n),t[4](null),e=!1,r()}}}function $n(t){let n,e,r,o;return r=new ln({props:{autofocusElement:t[1],$$slots:{default:[fn]},$$scope:{ctx:t}}}),r.$on("submit",t[2]),{c(){n=b("h2"),n.textContent="New Account",e=v(),ot(r.$$.fragment)},m(t,s){g(t,n,s),g(t,e,s),st(r,t,s),o=!0},p(t,[n]){const e={};2&n&&(e.autofocusElement=t[1]),35&n&&(e.$$scope={dirty:n,ctx:t}),r.$set(e)},i(t){o||(tt(r.$$.fragment,t),o=!0)},o(t){nt(r.$$.fragment,t),o=!1},d(t){t&&h(n),t&&h(e),ct(r,t)}}}function dn(t,n,e){let r="",o={};return[r,o,function(){(t=>{const n={uuid:kt(),name:t};it(n,jt),St()})(r),on("/accounts")},function(){r=this.value,e(0,r)},function(t){z[t?"unshift":"push"](()=>{o=t,e(1,o)})}]}function pn(n){let e,r,o;return{c(){e=w("svg"),r=w("path"),A(r,"fill","currentColor"),A(r,"d",n[0]),A(e,"aria-hidden","true"),A(e,"class",o=p(n[1])+" svelte-1d15yci"),A(e,"role","img"),A(e,"xmlns","http://www.w3.org/2000/svg"),A(e,"viewBox",n[2])},m(t,n){g(t,e,n),m(e,r)},p(t,[n]){1&n&&A(r,"d",t[0]),2&n&&o!==(o=p(t[1])+" svelte-1d15yci")&&A(e,"class",o),4&n&&A(e,"viewBox",t[2])},i:t,o:t,d(t){t&&h(e)}}}function mn(t,e,r){let{icon:o}=e,s=[],c="",u="";return t.$$set=t=>{r(4,e=n(n({},e),d(t))),"icon"in t&&r(3,o=t.icon)},t.$$.update=()=>{8&t.$$.dirty&&r(2,u="0 0 "+o.icon[0]+" "+o.icon[1]),r(1,c="fa-svelte "+(e.class?e.class:"")),8&t.$$.dirty&&r(0,s=o.icon[4])},e=d(e),[s,c,u,o]}class gn extends at{constructor(t){super(),ut(this,t,mn,pn,c,{icon:3})}}function hn(t){let n,e,r;return n=new gn({props:{icon:t[0]}}),{c(){ot(n.$$.fragment),e=v()},m(t,o){st(n,t,o),g(t,e,o),r=!0},p(t,e){const r={};1&e&&(r.icon=t[0]),n.$set(r)},i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){nt(n.$$.fragment,t),r=!1},d(t){ct(n,t),t&&h(e)}}}function yn(t){let n,e,r,o,s,c,u,a,i,l,f,$,d=t[0]&&hn(t);return{c(){n=b("a"),e=b("span"),d&&d.c(),r=b("br"),o=v(),s=b("br"),c=v(),u=x(t[1]),A(e,"class","button-circle svelte-2b5sup"),A(n,"id",a="button-"+t[1]),A(n,"class","btn svelte-2b5sup"),A(n,"href",i=t[3]||"javascript:void(0)"),A(n,"role","button"),j(n,"float-left",t[2])},m(a,i){g(a,n,i),m(n,e),d&&d.m(e,null),m(e,r),m(e,o),m(n,s),m(n,c),m(n,u),l=!0,f||($=E(n,"click",t[4]),f=!0)},p(t,[o]){t[0]?d?(d.p(t,o),1&o&&tt(d,1)):(d=hn(t),d.c(),tt(d,1),d.m(e,r)):d&&(X(),nt(d,1,1,()=>{d=null}),Z()),(!l||2&o)&&_(u,t[1]),(!l||2&o&&a!==(a="button-"+t[1]))&&A(n,"id",a),(!l||8&o&&i!==(i=t[3]||"javascript:void(0)"))&&A(n,"href",i),4&o&&j(n,"float-left",t[2])},i(t){l||(tt(d),l=!0)},o(t){nt(d),l=!1},d(t){t&&h(n),d&&d.d(),f=!1,$()}}}function bn(t,n,e){let{icon:r}=n,{name:o}=n,{left:s=!1}=n,{url:c=""}=n;return t.$$set=t=>{"icon"in t&&e(0,r=t.icon),"name"in t&&e(1,o=t.name),"left"in t&&e(2,s=t.left),"url"in t&&e(3,c=t.url)},[r,o,s,c,function(n){H(t,n)}]}class wn extends at{constructor(t){super(),ut(this,t,bn,yn,c,{icon:0,name:1,left:2,url:3})}}function xn(t){let n,e,r,o,s,c;const u=t[1].default,a=l(u,t,t[0],null);return{c(){n=b("div"),e=v(),r=b("div"),a&&a.c(),o=v(),s=b("div"),A(n,"id","button-row-spacer"),A(n,"class","svelte-17rvsyv"),A(s,"class","clearfix"),A(r,"id","button-row"),A(r,"class","svelte-17rvsyv")},m(t,u){g(t,n,u),g(t,e,u),g(t,r,u),a&&a.m(r,null),m(r,o),m(r,s),c=!0},p(t,[n]){a&&a.p&&1&n&&$(a,u,t,t[0],n,null,null)},i(t){c||(tt(a,t),c=!0)},o(t){nt(a,t),c=!1},d(t){t&&h(n),t&&h(e),t&&h(r),a&&a.d(t)}}}function vn(t,n,e){let{$$slots:r={},$$scope:o}=n;return t.$$set=t=>{"$$scope"in t&&e(0,o=t.$$scope)},[o,r]}class kn extends at{constructor(t){super(),ut(this,t,vn,xn,c,{})}}var En={prefix:"fas",iconName:"home",icon:[576,512,[],"f015","M280.37 148.26L96 300.11V464a16 16 0 0 0 16 16l112.06-.29a16 16 0 0 0 15.92-16V368a16 16 0 0 1 16-16h64a16 16 0 0 1 16 16v95.64a16 16 0 0 0 16 16.05L464 480a16 16 0 0 0 16-16V300L295.67 148.26a12.19 12.19 0 0 0-15.3 0zM571.6 251.47L488 182.56V44.05a12 12 0 0 0-12-12h-56a12 12 0 0 0-12 12v72.61L318.47 43a48 48 0 0 0-61 0L4.34 251.47a12 12 0 0 0-1.6 16.9l25.5 31A12 12 0 0 0 45.15 301l235.22-193.74a12.19 12.19 0 0 1 15.3 0L530.9 301a12 12 0 0 0 16.9-1.6l25.5-31a12 12 0 0 0-1.7-16.93z"]},Cn={prefix:"fas",iconName:"list-ul",icon:[512,512,[],"f0ca","M48 48a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm448 16H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"]},An={prefix:"fas",iconName:"minus",icon:[448,512,[],"f068","M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"]};function _n(t,n,e){const r=t.slice();return r[1]=n[e],r}function Nn(t){let n,e,r=t[1].name+"";return{c(){n=b("li"),e=x(r)},m(t,r){g(t,n,r),m(n,e)},p(t,n){1&n&&r!==(r=t[1].name+"")&&_(e,r)},d(t){t&&h(n)}}}function On(n){let e,r;return e=new wn({props:{icon:En,name:"budget",url:"#/budget",left:!0}}),{c(){ot(e.$$.fragment)},m(t,n){st(e,t,n),r=!0},p:t,i(t){r||(tt(e.$$.fragment,t),r=!0)},o(t){nt(e.$$.fragment,t),r=!1},d(t){ct(e,t)}}}function jn(t){let n,e,r,o,s,c,u,a,i=t[0],l=[];for(let n=0;nAdd new account',c=v(),ot(u.$$.fragment)},m(t,i){g(t,n,i),g(t,e,i),g(t,r,i);for(let t=0;te(0,r=t)),[r]}const Ln=t=>Hn(t)?"danger":"",Mn=t=>Tn(t,2),Dn=t=>Tn(t,0),Tn=(t,n)=>(null==t&&(t=0),(Number(t)/100).toFixed(n)),Hn=t=>t&&t<0;function Vn(n){let e,r,o,s;return{c(){e=b("div"),r=b("div"),A(r,"class",o="category-graph-line "+n[2](n[1],n[0])+" svelte-6b2uyp"),O(r,"width",n[3](n[1],n[0])+"%"),A(e,"class",s="category-graph "+Ln(n[1])+" svelte-6b2uyp")},m(t,n){g(t,e,n),m(e,r)},p(t,[n]){3&n&&o!==(o="category-graph-line "+t[2](t[1],t[0])+" svelte-6b2uyp")&&A(r,"class",o),3&n&&O(r,"width",t[3](t[1],t[0])+"%"),2&n&&s!==(s="category-graph "+Ln(t[1])+" svelte-6b2uyp")&&A(e,"class",s)},i:t,o:t,d(t){t&&h(e)}}}function zn(t,n,e){let{budgeted:r}=n,{remaining:o}=n;return t.$$set=t=>{"budgeted"in t&&e(0,r=t.budgeted),"remaining"in t&&e(1,o=t.remaining)},[r,o,(t,n)=>null==t?"":t<0?"danger":tt<0?0:0===n?t>0?100:0:t/n*100]}class Pn extends at{constructor(t){super(),ut(this,t,zn,Vn,c,{budgeted:0,remaining:1})}}function Rn(t,n,e){const r=t.slice();return r[3]=n[e].budgeted,r[4]=n[e].remaining,r[5]=n[e].name,r[6]=n[e].uuid,r}function In(t){let n,e,r,o,s,c,u,a,i,l,f,$,d,p,y,w,k,E,C,N,O,j=t[5]+"",S=Mn(t[4])+"",L=Dn(t[3])+"";return a=new Pn({props:{budgeted:t[3],remaining:t[4]}}),{c(){n=b("tr"),e=b("td"),r=b("a"),o=x(j),c=v(),u=b("td"),ot(a.$$.fragment),i=v(),l=b("td"),f=b("div"),$=b("sup"),$.textContent="$",d=x(S),y=v(),w=b("div"),k=b("span"),E=x("/ "),C=x(L),N=v(),A(r,"href",s="#/category/"+t[6]),A(r,"class","btn btn-outline-secondary"),A(e,"class","category-name width-10 svelte-1g8xb6x"),A(u,"class","width-80 svelte-1g8xb6x"),A($,"class","svelte-1g8xb6x"),A(f,"class",p="category-available "+Ln(t[4])+" svelte-1g8xb6x"),A(w,"class","category-budgeted svelte-1g8xb6x"),A(l,"class","category-amount width-10 svelte-1g8xb6x")},m(t,s){g(t,n,s),m(n,e),m(e,r),m(r,o),m(n,c),m(n,u),st(a,u,null),m(n,i),m(n,l),m(l,f),m(f,$),m(f,d),m(l,y),m(l,w),m(w,k),m(k,E),m(k,C),m(n,N),O=!0},p(t,n){(!O||1&n)&&j!==(j=t[5]+"")&&_(o,j),(!O||1&n&&s!==(s="#/category/"+t[6]))&&A(r,"href",s);const e={};1&n&&(e.budgeted=t[3]),1&n&&(e.remaining=t[4]),a.$set(e),(!O||1&n)&&S!==(S=Mn(t[4])+"")&&_(d,S),(!O||1&n&&p!==(p="category-available "+Ln(t[4])+" svelte-1g8xb6x"))&&A(f,"class",p),(!O||1&n)&&L!==(L=Dn(t[3])+"")&&_(C,L)},i(t){O||(tt(a.$$.fragment,t),O=!0)},o(t){nt(a.$$.fragment,t),O=!1},d(t){t&&h(n),ct(a)}}}function Bn(t){let n,e,r,o=t[0],s=[];for(let n=0;nnt(s[t],1,1,()=>{s[t]=null});return{c(){n=b("table"),e=b("tbody");for(let t=0;te(1,r=t)),i(t,Lt,t=>e(2,o=t)),t.$$.update=()=>{6&t.$$.dirty&&e(0,s=((t,n)=>{let e=[];for(var r in t)if(t.hasOwnProperty(r)){let o=Mt(r,n);e.push({budgeted:t[r].budgeted,remaining:t[r].remaining,name:o.name,uuid:o.uuid})}return e.sort((t,n)=>(t.name||"").localeCompare(n.name||""))})(r,o))},[s]}class qn extends at{constructor(t){super(),ut(this,t,Fn,Bn,c,{})}}function Un(n){let e,r,o,s;return e=new wn({props:{icon:Cn,name:"accounts",url:"#/accounts",left:!0}}),o=new wn({props:{icon:An,name:"expense",url:"#/expense/new"}}),{c(){ot(e.$$.fragment),r=v(),ot(o.$$.fragment)},m(t,n){st(e,t,n),g(t,r,n),st(o,t,n),s=!0},p:t,i(t){s||(tt(e.$$.fragment,t),tt(o.$$.fragment,t),s=!0)},o(t){nt(e.$$.fragment,t),nt(o.$$.fragment,t),s=!1},d(t){ct(e,t),t&&h(r),ct(o,t)}}}function Yn(t){let n,e,r,o,s,c,u,a;return r=new qn({}),u=new kn({props:{$$slots:{default:[Un]},$$scope:{ctx:t}}}),{c(){n=b("h2"),n.textContent="Budget",e=v(),ot(r.$$.fragment),o=v(),s=b("p"),s.innerHTML='Add new category',c=v(),ot(u.$$.fragment)},m(t,i){g(t,n,i),g(t,e,i),st(r,t,i),g(t,o,i),g(t,s,i),g(t,c,i),st(u,t,i),a=!0},p(t,[n]){const e={};1&n&&(e.$$scope={dirty:n,ctx:t}),u.$set(e)},i(t){a||(tt(r.$$.fragment,t),tt(u.$$.fragment,t),a=!0)},o(t){nt(r.$$.fragment,t),nt(u.$$.fragment,t),a=!1},d(t){t&&h(n),t&&h(e),ct(r,t),t&&h(o),t&&h(s),t&&h(c),ct(u,t)}}}function Jn(n){let e,r,s,c,u,a,i;return{c(){e=b("form"),r=b("div"),s=b("div"),s.innerHTML='$',c=v(),u=b("input"),A(s,"class","input-group-prepend"),A(u,"type","tel"),A(u,"aria-describedby","amount-input-currency-symbol"),A(u,"aria-label","Amount"),A(u,"class","text-right form-control"),A(r,"class","input-group input-group-lg"),e.noValidate=!0},m(t,o){g(t,e,o),m(e,r),m(r,s),m(r,c),m(r,u),n[4](u),a||(i=[E(u,"keydown",n[1]),E(e,"submit",C(n[2]))],a=!0)},p:t,i:t,o:t,d(t){t&&h(e),n[4](null),a=!1,o(i)}}}function Wn(t,n,e){let{amount:r=0}=n;const o=T();let s,c=[],u=null;function a(t){for(var n="",r=0;r{var t;c=(t=r)?String(t).split("").filter((function(t){return"0123456789".indexOf(t)>=0})):[],a(c),i(Number(c.join(""))),s.focus()}),t.$$set=t=>{"amount"in t&&e(3,r=t.amount)},[s,function(t){var n=t.which;(t=>t>=32&&t<112||t>=123&&t<127||t>=186)(n)&&t.preventDefault();var e=(t=>t>=48&&t<58?String(t-48):t>=96&&t<106?String(t-96):"")(n);e?c.push(e):(t=>8===t)(n)&&(t.preventDefault(),c.pop()),a(c),i(Number(c.join("")))},function(t){o("next",u)},r,function(t){z[t?"unshift":"push"](()=>{s=t,e(0,s)})}]}class Gn extends at{constructor(t){super(),ut(this,t,Wn,Jn,c,{amount:3})}}function Kn(t){let n,e,r,o,s,c,u=t[0].name+"";return s=new Gn({props:{amount:t[1]}}),s.$on("next",t[2]),{c(){n=b("h2"),e=x("Amount for "),r=x(u),o=v(),ot(s.$$.fragment)},m(t,u){g(t,n,u),m(n,e),m(n,r),g(t,o,u),st(s,t,u),c=!0},p(t,[n]){(!c||1&n)&&u!==(u=t[0].name+"")&&_(r,u);const e={};2&n&&(e.amount=t[1]),s.$set(e)},i(t){c||(tt(s.$$.fragment,t),c=!0)},o(t){nt(s.$$.fragment,t),c=!1},d(t){t&&h(n),t&&h(o),ct(s,t)}}}function Qn(t,n,e){let r;i(t,Lt,t=>e(5,r=t));let o,s,c,{params:u}=n;return t.$$set=t=>{"params"in t&&e(3,u=t.params)},t.$$.update=()=>{8&t.$$.dirty&&e(4,o=u.uuid),48&t.$$.dirty&&e(0,s=r.find(t=>t.uuid===o)||{}),16&t.$$.dirty&&e(1,c=It(o)||0)},[s,c,function(t){let n=t.detail;Ft(o,n),on("/budget")},u]}function Xn(n){let e,r,s,c,u,a;return{c(){e=b("form"),r=b("h2"),r.innerHTML='',s=v(),c=b("input"),A(c,"class","form-control"),A(c,"placeholder","New category name"),A(c,"id","new-category-name")},m(t,o){g(t,e,o),m(e,r),m(e,s),m(e,c),N(c,n[0]),n[4](c),u||(a=[E(c,"input",n[3]),E(e,"submit",C(n[2]))],u=!0)},p(t,[n]){1&n&&c.value!==t[0]&&N(c,t[0])},i:t,o:t,d(t){t&&h(e),n[4](null),u=!1,o(a)}}}function Zn(t,n,e){let r="",o={};return D(()=>{o.focus()}),[r,o,function(){on(`/category/${(t=>{const n=a(Lt).find(n=>n.name===t);if(n)return n;{const n={uuid:kt(),name:t};return it(n,Lt),Dt(),n}})(r).uuid}/amount`)},function(){r=this.value,e(0,r)},function(t){z[t?"unshift":"push"](()=>{o=t,e(1,o)})}]}function te(t,n,e){const r=t.slice();return r[1]=n[e].amountTotal,r[2]=n[e].timestamp,r[3]=n[e].who,r}function ne(t){let n;return{c(){n=b("i"),n.textContent="No matching transactions found."},m(t,e){g(t,n,e)},d(t){t&&h(n)}}}function ee(t){let n,e,r,o,s,c,u,a,i,l,f,$=Ht(t[2])+"",d=t[3]+"",p=Mn(t[1])+"";return{c(){n=b("div"),e=b("div"),r=x($),o=v(),s=b("div"),c=x(d),u=v(),a=b("div"),i=b("sup"),i.textContent="$",l=x(p),f=v(),A(e,"class","col-2 text-center"),A(s,"class","col-7"),A(a,"class","col-3 text-right"),A(n,"class","row")},m(t,$){g(t,n,$),m(n,e),m(e,r),m(n,o),m(n,s),m(s,c),m(n,u),m(n,a),m(a,i),m(a,l),m(n,f)},p(t,n){1&n&&$!==($=Ht(t[2])+"")&&_(r,$),1&n&&d!==(d=t[3]+"")&&_(c,d),1&n&&p!==(p=Mn(t[1])+"")&&_(l,p)},d(t){t&&h(n)}}}function re(n){let e,r=n[0],o=[];for(let t=0;t{"transactions"in t&&e(0,r=t.transactions)},[r]}class se extends at{constructor(t){super(),ut(this,t,oe,re,c,{transactions:0})}}function ce(n){let e,r;return e=new wn({props:{icon:En,name:"budget",url:"#/budget",left:!0}}),{c(){ot(e.$$.fragment)},m(t,n){st(e,t,n),r=!0},p:t,i(t){r||(tt(e.$$.fragment,t),r=!0)},o(t){nt(e.$$.fragment,t),r=!1},d(t){ct(e,t)}}}function ue(t){let n,e,r,o,s,c,u,a,i,l,f,$,d,p,y,w,k,C,N,O=t[1].name+"",j=Mn(It(t[0]))+"";return p=new se({props:{transactions:t[2]}}),w=new kn({props:{$$slots:{default:[ce]},$$scope:{ctx:t}}}),{c(){n=b("h2"),e=b("b"),r=x(O),o=x(":"),s=v(),c=b("a"),u=b("sup"),u.textContent="$",a=v(),i=x(j),f=v(),$=b("hr"),d=v(),ot(p.$$.fragment),y=v(),ot(w.$$.fragment),A(e,"class","editable svelte-1uc4ts5"),A(e,"title","(Click to rename)"),A(c,"class","btn btn-default"),A(c,"href",l="#/category/"+t[0]+"/amount"),A($,"class","small")},m(l,h){g(l,n,h),m(n,e),m(e,r),m(e,o),m(n,s),m(n,c),m(c,u),m(c,a),m(c,i),g(l,f,h),g(l,$,h),g(l,d,h),st(p,l,h),g(l,y,h),st(w,l,h),k=!0,C||(N=E(e,"click",t[3]),C=!0)},p(t,[n]){(!k||2&n)&&O!==(O=t[1].name+"")&&_(r,O),(!k||1&n)&&j!==(j=Mn(It(t[0]))+"")&&_(i,j),(!k||1&n&&l!==(l="#/category/"+t[0]+"/amount"))&&A(c,"href",l);const e={};4&n&&(e.transactions=t[2]),p.$set(e);const o={};64&n&&(o.$$scope={dirty:n,ctx:t}),w.$set(o)},i(t){k||(tt(p.$$.fragment,t),tt(w.$$.fragment,t),k=!0)},o(t){nt(p.$$.fragment,t),nt(w.$$.fragment,t),k=!1},d(t){t&&h(n),t&&h(f),t&&h($),t&&h(d),ct(p,t),t&&h(y),ct(w,t),C=!1,N()}}}function ae(t,n,e){let r;i(t,Lt,t=>e(5,r=t));let{params:o={}}=n;let s,c,u;return t.$$set=t=>{"params"in t&&e(4,o=t.params)},t.$$.update=()=>{16&t.$$.dirty&&e(0,s=o.uuid||""),33&t.$$.dirty&&e(1,c=r.find(t=>t.uuid===s)||{}),1&t.$$.dirty&&e(2,u=Kt(s))},[s,c,u,()=>{let t=prompt("Edit category name:",c.name);null!=t&&Tt(s,{name:t})},o]}function ie(t,n,e){const r=t.slice();return r[3]=n[e],r}function le(t,n){let e,r,o,s,c,u,a=n[3].name+"";function i(...t){return n[2](n[3],...t)}return{key:t,first:null,c(){e=b("p"),r=b("button"),o=x(a),s=v(),A(r,"class","btn btn-outline-secondary"),this.first=e},m(t,n){g(t,e,n),m(e,r),m(r,o),m(e,s),c||(u=E(r,"click",i),c=!0)},p(t,e){n=t,1&e&&a!==(a=n[3].name+"")&&_(o,a)},d(t){t&&h(e),c=!1,u()}}}function fe(n){let e,r=[],o=new Map,s=n[0];const c=t=>t[3].uuid;for(let t=0;t{"accounts"in t&&e(0,r=t.accounts)},[r,o,t=>o("select",t.uuid)]}class de extends at{constructor(t){super(),ut(this,t,$e,fe,c,{accounts:0})}}function pe(n){let e,r;return e=new wn({props:{icon:En,name:"budget",url:"#/budget",left:!0}}),{c(){ot(e.$$.fragment)},m(t,n){st(e,t,n),r=!0},p:t,i(t){r||(tt(e.$$.fragment,t),r=!0)},o(t){nt(e.$$.fragment,t),r=!1},d(t){ct(e,t)}}}function me(t){let n,e,r,o,s,c;return r=new de({props:{accounts:t[0]}}),r.$on("select",t[1]),s=new kn({props:{$$slots:{default:[pe]},$$scope:{ctx:t}}}),{c(){n=b("h2"),n.textContent="Paid using",e=v(),ot(r.$$.fragment),o=v(),ot(s.$$.fragment)},m(t,u){g(t,n,u),g(t,e,u),st(r,t,u),g(t,o,u),st(s,t,u),c=!0},p(t,[n]){const e={};1&n&&(e.accounts=t[0]),r.$set(e);const o={};4&n&&(o.$$scope={dirty:n,ctx:t}),s.$set(o)},i(t){c||(tt(r.$$.fragment,t),tt(s.$$.fragment,t),c=!0)},o(t){nt(r.$$.fragment,t),nt(s.$$.fragment,t),c=!1},d(t){t&&h(n),t&&h(e),ct(r,t),t&&h(o),ct(s,t)}}}function ge(t,n,e){let r;return i(t,jt,t=>e(0,r=t)),[r,function(t){let n=t.detail;Xt({accountUuid:n}),on("/expense/amount/")}]}function he(n){let e,r;return e=new wn({props:{icon:En,name:"budget",url:"#/budget",left:!0}}),{c(){ot(e.$$.fragment)},m(t,n){st(e,t,n),r=!0},p:t,i(t){r||(tt(e.$$.fragment,t),r=!0)},o(t){nt(e.$$.fragment,t),r=!1},d(t){ct(e,t)}}}function ye(t){let n,e,r,o,s,c,u,a,i=t[0].who+"";return s=new Gn({}),s.$on("next",t[1]),u=new kn({props:{$$slots:{default:[he]},$$scope:{ctx:t}}}),{c(){n=b("h2"),e=x("Amount paid to "),r=x(i),o=v(),ot(s.$$.fragment),c=v(),ot(u.$$.fragment)},m(t,i){g(t,n,i),m(n,e),m(n,r),g(t,o,i),st(s,t,i),g(t,c,i),st(u,t,i),a=!0},p(t,[n]){(!a||1&n)&&i!==(i=t[0].who+"")&&_(r,i);const e={};8&n&&(e.$$scope={dirty:n,ctx:t}),u.$set(e)},i(t){a||(tt(s.$$.fragment,t),tt(u.$$.fragment,t),a=!0)},o(t){nt(s.$$.fragment,t),nt(u.$$.fragment,t),a=!1},d(t){t&&h(n),t&&h(o),ct(s,t),t&&h(c),ct(u,t)}}}function be(t,n,e){let r,o;return i(t,Wt,t=>e(2,r=t)),t.$$.update=()=>{4&t.$$.dirty&&e(0,o=r)},[o,function(t){let n=t.detail;Xt({amountTotal:n}),on("/expense/category/")}]}function we(t,n,e){const r=t.slice();return r[4]=n[e],r}function xe(t,n){let e,r,o,s,c,u,a=n[4].name+"";function i(...t){return n[2](n[4],...t)}return{key:t,first:null,c(){e=b("p"),r=b("button"),o=x(a),s=v(),A(r,"class","btn btn-outline-secondary"),this.first=e},m(t,n){g(t,e,n),m(e,r),m(r,o),m(e,s),c||(u=E(r,"click",i),c=!0)},p(t,e){n=t,1&e&&a!==(a=n[4].name+"")&&_(o,a)},d(t){t&&h(e),c=!1,u()}}}function ve(n){let e,r=[],o=new Map,s=n[0];const c=t=>t[4].uuid;for(let t=0;t{"categories"in t&&e(0,r=t.categories)},[r,o,t=>o("select",t.uuid)]}class Ee extends at{constructor(t){super(),ut(this,t,ke,ve,c,{categories:0})}}function Ce(n){let e,r;return e=new wn({props:{icon:En,name:"budget",url:"#/budget",left:!0}}),{c(){ot(e.$$.fragment)},m(t,n){st(e,t,n),r=!0},p:t,i(t){r||(tt(e.$$.fragment,t),r=!0)},o(t){nt(e.$$.fragment,t),r=!1},d(t){ct(e,t)}}}function Ae(t){let n,e,r,o,s,c;return r=new Ee({props:{categories:t[0]}}),r.$on("select",t[1]),s=new kn({props:{$$slots:{default:[Ce]},$$scope:{ctx:t}}}),{c(){n=b("h2"),n.textContent="Category",e=v(),ot(r.$$.fragment),o=v(),ot(s.$$.fragment)},m(t,u){g(t,n,u),g(t,e,u),st(r,t,u),g(t,o,u),st(s,t,u),c=!0},p(t,[n]){const e={};1&n&&(e.categories=t[0]),r.$set(e);const o={};8&n&&(o.$$scope={dirty:n,ctx:t}),s.$set(o)},i(t){c||(tt(r.$$.fragment,t),tt(s.$$.fragment,t),c=!0)},o(t){nt(r.$$.fragment,t),nt(s.$$.fragment,t),c=!1},d(t){t&&h(n),t&&h(e),ct(r,t),t&&h(o),ct(s,t)}}}function _e(t,n,e){let r,o;return i(t,Wt,t=>e(2,r=t)),i(t,Lt,t=>e(0,o=t)),[o,function(t){let n={};n[t.detail]=r.amountTotal,Xt({categoryAmounts:n}),on("/expense/review/")}]}function Ne(t){const n=Date.now();return Gt({timestamp:n}),on("/expense/who/"),[]}function Oe(n){let e,r,o,s,c=Mn(n[1])+"";return{c(){e=b("span"),r=x(n[0]),o=x(": $ "),s=x(c),A(e,"class","badge badge-info")},m(t,n){g(t,e,n),m(e,r),m(e,o),m(e,s)},p(t,[n]){1&n&&_(r,t[0]),2&n&&c!==(c=Mn(t[1])+"")&&_(s,c)},i:t,o:t,d(t){t&&h(e)}}}function je(t,n,e){let{name:r=""}=n,{amount:o=0}=n;return t.$$set=t=>{"name"in t&&e(0,r=t.name),"amount"in t&&e(1,o=t.amount)},[r,o]}class Se extends at{constructor(t){super(),ut(this,t,je,Oe,c,{name:0,amount:1})}}function Le(t,n,e){const r=t.slice();return r[4]=n[e],r}function Me(t){let n,e;return n=new Se({props:{name:Mt(t[4],t[2]).name,amount:t[0][t[4]]}}),{c(){ot(n.$$.fragment)},m(t,r){st(n,t,r),e=!0},p(t,e){const r={};6&e&&(r.name=Mt(t[4],t[2]).name),3&e&&(r.amount=t[0][t[4]]),n.$set(r)},i(t){e||(tt(n.$$.fragment,t),e=!0)},o(t){nt(n.$$.fragment,t),e=!1},d(t){ct(n,t)}}}function De(t){let n,e,r=t[1],o=[];for(let n=0;nnt(o[t],1,1,()=>{o[t]=null});return{c(){for(let t=0;te(2,r=t));let o,s,{transaction:c={}}=n;return t.$$set=t=>{"transaction"in t&&e(3,c=t.transaction)},t.$$.update=()=>{8&t.$$.dirty&&e(0,o=c.categoryAmounts||{}),1&t.$$.dirty&&e(1,s=Object.keys(o))},[o,s,r,c]}class He extends at{constructor(t){super(),ut(this,t,Te,De,c,{transaction:3})}}function Ve(n){let e,r;return e=new wn({props:{icon:En,name:"done"}}),e.$on("click",n[3]),{c(){ot(e.$$.fragment)},m(t,n){st(e,t,n),r=!0},p:t,i(t){r||(tt(e.$$.fragment,t),r=!0)},o(t){nt(e.$$.fragment,t),r=!1},d(t){ct(e,t)}}}function ze(t){let n,e,r,o,s,c,u,a,i,l,f,$,d,p,y,w,k,C,N,O,j,S,L,M,D,T,H,V,z,P,R,I=t[0].who+"",B=Mn(t[2])+"";return p=new He({props:{transaction:t[0]}}),V=new kn({props:{$$slots:{default:[Ve]},$$scope:{ctx:t}}}),{c(){n=b("div"),e=b("div"),r=b("h2"),r.textContent="Review Expense",o=v(),s=b("p"),c=b("a"),u=x(I),a=v(),i=b("a"),l=x("$"),f=x(B),$=v(),d=b("p"),ot(p.$$.fragment),y=v(),w=b("p"),k=b("b"),k.textContent="Account:",C=v(),N=b("a"),O=x(t[1]),j=v(),S=b("p"),L=b("b"),L.textContent="Date:",M=v(),D=b("input"),H=v(),ot(V.$$.fragment),A(c,"class","btn btn-outline-secondary"),A(c,"href","#/expense/who/"),A(i,"class","btn btn-outline-secondary float-right"),A(i,"href","#/expense/amount/"),A(N,"class","btn btn-outline-secondary float-right"),A(N,"href","#/expense/account/"),A(D,"type","date"),A(D,"class","float-right"),D.value=T=Vt(t[0].timestamp),A(e,"class","col-12 col-sm-8 offset-sm-2 col-md-6 offset-md-3"),A(n,"class","row")},m(h,b){g(h,n,b),m(n,e),m(e,r),m(e,o),m(e,s),m(s,c),m(c,u),m(s,a),m(s,i),m(i,l),m(i,f),m(e,$),m(e,d),st(p,d,null),m(e,y),m(e,w),m(w,k),m(w,C),m(w,N),m(N,O),m(e,j),m(e,S),m(S,L),m(S,M),m(S,D),g(h,H,b),st(V,h,b),z=!0,P||(R=E(D,"change",t[4]),P=!0)},p(t,[n]){(!z||1&n)&&I!==(I=t[0].who+"")&&_(u,I),(!z||4&n)&&B!==(B=Mn(t[2])+"")&&_(f,B);const e={};1&n&&(e.transaction=t[0]),p.$set(e),(!z||2&n)&&_(O,t[1]),(!z||1&n&&T!==(T=Vt(t[0].timestamp)))&&(D.value=T);const r={};512&n&&(r.$$scope={dirty:n,ctx:t}),V.$set(r)},i(t){z||(tt(p.$$.fragment,t),tt(V.$$.fragment,t),z=!0)},o(t){nt(p.$$.fragment,t),nt(V.$$.fragment,t),z=!1},d(t){t&&h(n),ct(p),t&&h(H),ct(V,t),P=!1,R()}}}function Pe(t,n,e){let r,o;i(t,Wt,t=>e(5,r=t)),i(t,jt,t=>e(7,o=t));let s,c,u,l;return t.$$.update=()=>{var n;32&t.$$.dirty&&e(0,s=r),129&t.$$.dirty&&e(6,(n=s.accountUuid,c=o.find(t=>t.uuid===n)||{})),64&t.$$.dirty&&e(1,u=c.name||""),1&t.$$.dirty&&e(2,l=s.amountTotal||0)},[s,u,l,function(){(()=>{const t=a(Wt);t.uuid=kt(),it(t,Jt),Qt();const n=t.categoryAmounts||{};for(const t in n){const e=n[t]||0;qt(t,e)}Gt({})})(),on("/budget")},t=>{let n=t.target.value,e=new Date(n+" 12:00:00");Xt({timestamp:e.getTime()})}]}function Re(t){let n,e,r,o,s,c,u;return{c(){n=b("h2"),e=b("label"),r=x(t[1]),o=v(),s=b("input"),A(e,"for","who"),A(s,"type","text"),A(s,"class","form-control"),A(s,"id","who")},m(a,i){g(a,n,i),m(n,e),m(e,r),g(a,o,i),g(a,s,i),N(s,t[0]),t[5](s),c||(u=E(s,"input",t[4]),c=!0)},p(t,n){2&n&&_(r,t[1]),1&n&&s.value!==t[0]&&N(s,t[0])},d(e){e&&h(n),e&&h(o),e&&h(s),t[5](null),c=!1,u()}}}function Ie(t){let n,e;return n=new ln({props:{autofocusElement:t[2],$$slots:{default:[Re]},$$scope:{ctx:t}}}),n.$on("submit",t[3]),{c(){ot(n.$$.fragment)},m(t,r){st(n,t,r),e=!0},p(t,[e]){const r={};4&e&&(r.autofocusElement=t[2]),135&e&&(r.$$scope={dirty:e,ctx:t}),n.$set(r)},i(t){e||(tt(n.$$.fragment,t),e=!0)},o(t){nt(n.$$.fragment,t),e=!1},d(t){ct(n,t)}}}function Be(t,n,e){let{title:r}=n,{who:o=""}=n;const s=T();let c={};return t.$$set=t=>{"title"in t&&e(1,r=t.title),"who"in t&&e(0,o=t.who)},[o,r,c,()=>{s("select",o)},function(){o=this.value,e(0,o)},function(t){z[t?"unshift":"push"](()=>{c=t,e(2,c)})}]}class Fe extends at{constructor(t){super(),ut(this,t,Be,Ie,c,{title:1,who:0})}}function qe(n){let e,r;return e=new wn({props:{icon:En,name:"budget",url:"#/budget",left:!0}}),{c(){ot(e.$$.fragment)},m(t,n){st(e,t,n),r=!0},p:t,i(t){r||(tt(e.$$.fragment,t),r=!0)},o(t){nt(e.$$.fragment,t),r=!1},d(t){ct(e,t)}}}function Ue(t){let n,e,r,o;return n=new Fe({props:{title:"Paid to:"}}),n.$on("select",t[0]),r=new kn({props:{$$slots:{default:[qe]},$$scope:{ctx:t}}}),{c(){ot(n.$$.fragment),e=v(),ot(r.$$.fragment)},m(t,s){st(n,t,s),g(t,e,s),st(r,t,s),o=!0},p(t,[n]){const e={};2&n&&(e.$$scope={dirty:n,ctx:t}),r.$set(e)},i(t){o||(tt(n.$$.fragment,t),tt(r.$$.fragment,t),o=!0)},o(t){nt(n.$$.fragment,t),nt(r.$$.fragment,t),o=!1},d(t){ct(n,t),t&&h(e),ct(r,t)}}}function Ye(t){return[t=>{const n=t.detail;Xt({who:n}),on("/expense/account/")}]}function Je(t){return function(t){if(!t||t.length<1||"/"!=t.charAt(0)&&0!==t.indexOf("#/"))throw Error("Invalid parameter location");q().then(()=>{const n=("#"==t.charAt(0)?"":"#")+t;try{window.history.replaceState(void 0,void 0,n)}catch(t){console.warn("Caught exception while replacing the current page. If you're running this in the Svelte REPL, please note that the `replace` method might not work in this environment.")}window.dispatchEvent(new Event("hashchange"))})}("/budget"),[]}function We(n){let e,r,o,s,c;return{c(){e=b("h2"),e.textContent="Hmm...",r=v(),o=b("p"),o.textContent="We can't seem to find that page.",s=v(),c=b("p"),c.innerHTML='Try going back to the Home screen. Perhaps there's a link\n from there to where you were trying to go.'},m(t,n){g(t,e,n),g(t,r,n),g(t,o,n),g(t,s,n),g(t,c,n)},p:t,i:t,o:t,d(t){t&&h(e),t&&h(r),t&&h(o),t&&h(s),t&&h(c)}}}const Ge={"/":class extends at{constructor(t){super(),ut(this,t,Je,null,c,{})}},"/account/new":class extends at{constructor(t){super(),ut(this,t,dn,$n,c,{})}},"/accounts":class extends at{constructor(t){super(),ut(this,t,Sn,jn,c,{})}},"/budget":class extends at{constructor(t){super(),ut(this,t,null,Yn,c,{})}},"/category/new":class extends at{constructor(t){super(),ut(this,t,Zn,Xn,c,{})}},"/category/:uuid":class extends at{constructor(t){super(),ut(this,t,ae,ue,c,{params:4})}},"/category/:uuid/amount":class extends at{constructor(t){super(),ut(this,t,Qn,Kn,c,{params:3})}},"/expense/account/":class extends at{constructor(t){super(),ut(this,t,ge,me,c,{})}},"/expense/amount/":class extends at{constructor(t){super(),ut(this,t,be,ye,c,{})}},"/expense/category/":class extends at{constructor(t){super(),ut(this,t,_e,Ae,c,{})}},"/expense/new":class extends at{constructor(t){super(),ut(this,t,Ne,null,c,{})}},"/expense/review/":class extends at{constructor(t){super(),ut(this,t,Pe,ze,c,{})}},"/expense/who/":class extends at{constructor(t){super(),ut(this,t,Ye,Ue,c,{})}},"*":class extends at{constructor(t){super(),ut(this,t,null,We,c,{})}}};function Ke(n){let e,r,o,s,c;return r=new Ot({}),s=new cn({props:{routes:Ge}}),{c(){e=b("div"),ot(r.$$.fragment),o=v(),ot(s.$$.fragment),A(e,"class","container-xl my-3")},m(t,n){g(t,e,n),st(r,e,null),m(e,o),st(s,e,null),c=!0},p:t,i(t){c||(tt(r.$$.fragment,t),tt(s.$$.fragment,t),c=!0)},o(t){nt(r.$$.fragment,t),nt(s.$$.fragment,t),c=!1},d(t){t&&h(e),ct(r),ct(s)}}}function Qe(t){return D(async()=>{jt.set(ft("accounts")),Lt.set(ft("categories")),Bt(),Jt.set(ft("transactions"))}),[]}return new class extends at{constructor(t){super(),ut(this,t,Qe,Ke,c,{})}}({target:document.body})}(); +var app=function(){"use strict";function t(){}function n(t,n){for(const e in n)t[e]=n[e];return t}function e(t){return t()}function r(){return Object.create(null)}function o(t){t.forEach(e)}function c(t){return"function"==typeof t}function s(t,n){return t!=t?n==n:t!==n||t&&"object"==typeof t||"function"==typeof t}function u(n,...e){if(null==n)return t;const r=n.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function a(t){let n;return u(t,t=>n=t)(),n}function i(t,n,e){t.$$.on_destroy.push(u(n,e))}function l(t,n,e,r){if(t){const o=f(t,n,e,r);return t[0](o)}}function f(t,e,r,o){return t[1]&&o?n(r.ctx.slice(),t[1](o(e))):r.ctx}function $(t,n,e,r,o,c,s){const u=function(t,n,e,r){if(t[2]&&r){const o=t[2](r(e));if(void 0===n.dirty)return o;if("object"==typeof o){const t=[],e=Math.max(n.dirty.length,o.length);for(let r=0;rt.removeEventListener(n,e,r)}function A(t){return function(n){return n.preventDefault(),t.call(this,n)}}function C(t,n,e){null==e?t.removeAttribute(n):t.getAttribute(n)!==e&&t.setAttribute(n,e)}function L(t,n){n=""+n,t.wholeText!==n&&(t.data=n)}function N(t,n){t.value=null==n?"":n}function _(t,n,e,r){t.style.setProperty(n,e,r?"important":"")}function M(t,n,e){t.classList[e?"add":"remove"](n)}let O;function j(t){O=t}function S(){if(!O)throw new Error("Function called outside component initialization");return O}function D(t){S().$$.on_mount.push(t)}function T(){const t=S();return(n,e)=>{const r=t.$$.callbacks[n];if(r){const o=function(t,n){const e=document.createEvent("CustomEvent");return e.initCustomEvent(t,!1,!1,n),e}(n,e);r.slice().forEach(n=>{n.call(t,o)})}}}function z(t,n){const e=t.$$.callbacks[n.type];e&&e.slice().forEach(t=>t(n))}const H=[],V=[],P=[],R=[],I=Promise.resolve();let B=!1;function F(){B||(B=!0,I.then(G))}function q(){return F(),I}function U(t){P.push(t)}function Y(t){R.push(t)}let J=!1;const W=new Set;function G(){if(!J){J=!0;do{for(let t=0;t{Q.delete(t),r&&(e&&t.d(1),r())}),t.o(n)}}function rt(t,n){t.d(1),n.delete(t.key)}function ot(t,n,e,r,o,c,s,u,a,i,l,f){let $=t.length,p=c.length,d=$;const m={};for(;d--;)m[t[d].key]=d;const g=[],h=new Map,y=new Map;for(d=p;d--;){const t=f(o,c,d),u=e(t);let a=s.get(u);a?r&&a.p(t,n):(a=i(u,t),a.c()),h.set(u,g[d]=a),u in m&&y.set(u,Math.abs(d-m[u]))}const b=new Set,w=new Set;function x(t){nt(t,1),t.m(u,l),s.set(t.key,t),l=t.first,p--}for(;$&&p;){const n=g[p-1],e=t[$-1],r=n.key,o=e.key;n===e?(l=n.first,$--,p--):h.has(o)?!s.has(r)||b.has(r)?x(n):w.has(o)?$--:y.get(r)>y.get(o)?(w.add(r),x(n)):(b.add(o),$--):(a(e,s),$--)}for(;$--;){const n=t[$];h.has(n.key)||a(n,s)}for(;p;)x(g[p-1]);return g}function ct(t,n,e){const r=t.$$.props[n];void 0!==r&&(t.$$.bound[r]=e,e(t.$$.ctx[r]))}function st(t){t&&t.c()}function ut(t,n,r){const{fragment:s,on_mount:u,on_destroy:a,after_update:i}=t.$$;s&&s.m(n,r),U(()=>{const n=u.map(e).filter(c);a?a.push(...n):o(n),t.$$.on_mount=[]}),i.forEach(U)}function at(t,n){const e=t.$$;null!==e.fragment&&(o(e.on_destroy),e.fragment&&e.fragment.d(n),e.on_destroy=e.fragment=null,e.ctx=[])}function it(n,e,c,s,u,a,i=[-1]){const l=O;j(n);const f=e.props||{},$=n.$$={fragment:null,ctx:null,props:a,update:t,not_equal:u,bound:r(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(l?l.$$.context:[]),callbacks:r(),dirty:i,skip_bound:!1};let p=!1;if($.ctx=c?c(n,f,(t,e,...r)=>{const o=r.length?r[0]:e;return $.ctx&&u($.ctx[t],$.ctx[t]=o)&&(!$.skip_bound&&$.bound[t]&&$.bound[t](o),p&&function(t,n){-1===t.$$.dirty[0]&&(H.push(t),F(),t.$$.dirty.fill(0)),t.$$.dirty[n/31|0]|=1<{const t=e.indexOf(n);-1!==t&&e.splice(t,1)}}$set(t){var n;this.$$set&&(n=t,0!==Object.keys(n).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const ft=(t,n)=>{n.update(n=>[t,...n])},$t=Array.isArray,pt=t=>{const n=dt(t);return $t(n)?n:[]},dt=t=>{const n=localStorage.getItem(t);return JSON.parse(n)},mt=(t,n)=>{localStorage.setItem(t,JSON.stringify(n))},gt=[];function ht(t,n){return{subscribe:yt(t,n).subscribe}}function yt(n,e=t){let r;const o=[];function c(t){if(s(n,t)&&(n=t,r)){const t=!gt.length;for(let t=0;t{const t=o.indexOf(a);-1!==t&&o.splice(t,1),0===o.length&&(r(),r=null)}}}}function bt(n,e,r){const s=!Array.isArray(n),a=s?[n]:n,i=e.length<2;return ht(r,n=>{let r=!1;const l=[];let f=0,$=t;const p=()=>{if(f)return;$();const r=e(s?l[0]:l,n);i?n(r):$=c(r)?r:t},d=a.map((t,n)=>u(t,t=>{l[n]=t,f&=~(1<{f|=1<Ct.set("");function Nt(t){let n,e,r,o,c,s;return{c(){n=b("div"),e=b("button"),e.innerHTML='',r=v(),o=x(t[0]),C(e,"type","button"),C(e,"class","close"),C(e,"aria-label","Close"),C(n,"class","alert alert-danger keep-line-breaks svelte-1anyckn"),C(n,"role","alert")},m(t,u){g(t,n,u),m(n,e),m(n,r),m(n,o),c||(s=E(e,"click",Lt),c=!0)},p(t,n){1&n&&L(o,t[0])},d(t){t&&h(n),c=!1,s()}}}function _t(n){let e,r=n[0]&&Nt(n);return{c(){r&&r.c(),e=k()},m(t,n){r&&r.m(t,n),g(t,e,n)},p(t,[n]){t[0]?r?r.p(t,n):(r=Nt(t),r.c(),r.m(e.parentNode,e)):r&&(r.d(1),r=null)},i:t,o:t,d(t){r&&r.d(t),t&&h(e)}}}function Mt(t,n,e){let r;return i(t,Ct,t=>e(0,r=t)),[r]}window.onunhandledrejection=t=>{let n=t.reason;Ct.set(n.message)};class Ot extends lt{constructor(t){super(),it(this,t,Mt,_t,s,{})}}const jt=yt([]),St=()=>mt("accounts",a(jt)),Dt=yt([]),Tt=(t,n)=>n.find(n=>n.uuid===t)||{},zt=()=>mt("categories",a(Dt)),Ht=(t,n)=>{((t,n,e,r)=>{r.update(r=>{const o=r.find(e=>e[t]===n),c=Object.assign({},o,e);let s=!1;for(let e=0;enew Date(t).toLocaleDateString(),Pt=t=>{if(t){let n=new Date(t);const e=n.getFullYear(),r=n.getMonth()+1,o=n.getDate();return`${e}-${String(r).padStart(2,"0")}-${String(o).padStart(2,"0")}`}return""},Rt=(t,n)=>{var e=n.getFullYear(),r=n.getMonth(),o=new Date(e,r-t),c=o.getFullYear(),s=o.getMonth()+1;return c+"-"+String("0"+s).slice(-2)},It=yt({}),Bt=t=>a(It)[t]||{},Ft=t=>Bt(t).budgeted||0,qt=()=>{It.set((t=>{const n=dt(t);return null!==n?n:{}})("budget"))},Ut=(t,n)=>{a(It);(t=>a(It).hasOwnProperty(t))(t)?Wt(t,n):((t,n)=>{Jt(t,{budgeted:n,remaining:n,refilled:Rt(0,new Date)})})(t,n)},Yt=(t,n)=>{const e=Bt(t).remaining||0;Jt(t,{remaining:e-n})},Jt=(t,n)=>{((t,n,e)=>{e.update(e=>(e.hasOwnProperty(t)?e[t]=Object.assign(e[t],n):e[t]=n,e))})(t,n,It),mt("budget",a(It))},Wt=(t,n)=>{let e=a(It)[t],r=e.budgeted,o=e.remaining;Jt(t,{budgeted:n,remaining:o+(n-r)})},Gt=yt([]),Kt=yt({}),Qt=t=>{const n=Object.assign({},t);Kt.set(n)},Xt=t=>a(Gt).filter(n=>(n.categoryAmounts||{}).hasOwnProperty(t)),Zt=()=>mt("transactions",a(Gt)),tn=t=>{const n=a(Kt),e=Object.assign({},n,t);Kt.set(e)};function nn(t){let n,e,r;var o=t[0];return o&&(n=new o({}),n.$on("routeEvent",t[5])),{c(){n&&st(n.$$.fragment),e=k()},m(t,o){n&&ut(n,t,o),g(t,e,o),r=!0},p(t,r){if(o!==(o=t[0])){if(n){Z();const t=n;et(t.$$.fragment,1,0,()=>{at(t,1)}),tt()}o?(n=new o({}),n.$on("routeEvent",t[5]),st(n.$$.fragment),nt(n.$$.fragment,1),ut(n,e.parentNode,e)):n=null}},i(t){r||(n&&nt(n.$$.fragment,t),r=!0)},o(t){n&&et(n.$$.fragment,t),r=!1},d(t){t&&h(e),n&&at(n,t)}}}function en(t){let n,e,r;var o=t[0];function c(t){return{props:{params:t[1]}}}return o&&(n=new o(c(t)),n.$on("routeEvent",t[4])),{c(){n&&st(n.$$.fragment),e=k()},m(t,o){n&&ut(n,t,o),g(t,e,o),r=!0},p(t,r){const s={};if(2&r&&(s.params=t[1]),o!==(o=t[0])){if(n){Z();const t=n;et(t.$$.fragment,1,0,()=>{at(t,1)}),tt()}o?(n=new o(c(t)),n.$on("routeEvent",t[4]),st(n.$$.fragment),nt(n.$$.fragment,1),ut(n,e.parentNode,e)):n=null}else o&&n.$set(s)},i(t){r||(n&&nt(n.$$.fragment,t),r=!0)},o(t){n&&et(n.$$.fragment,t),r=!1},d(t){t&&h(e),n&&at(n,t)}}}function rn(t){let n,e,r,o;const c=[en,nn],s=[];function u(t,n){return t[1]?0:1}return n=u(t),e=s[n]=c[n](t),{c(){e.c(),r=k()},m(t,e){s[n].m(t,e),g(t,r,e),o=!0},p(t,[o]){let a=n;n=u(t),n===a?s[n].p(t,o):(Z(),et(s[a],1,1,()=>{s[a]=null}),tt(),e=s[n],e||(e=s[n]=c[n](t),e.c()),nt(e,1),e.m(r.parentNode,r))},i(t){o||(nt(e),o=!0)},o(t){et(e),o=!1},d(t){s[n].d(t),t&&h(r)}}}function on(){const t=window.location.href.indexOf("#/");let n=t>-1?window.location.href.substr(t+1):"/";const e=n.indexOf("?");let r="";return e>-1&&(r=n.substr(e+1),n=n.substr(0,e)),{location:n,querystring:r}}const cn=ht(null,(function(t){t(on());const n=()=>{t(on())};return window.addEventListener("hashchange",n,!1),function(){window.removeEventListener("hashchange",n,!1)}}));bt(cn,t=>t.location),bt(cn,t=>t.querystring);function sn(t){if(!t||t.length<1||"/"!=t.charAt(0)&&0!==t.indexOf("#/"))throw Error("Invalid parameter location");return q().then(()=>{window.location.hash=("#"==t.charAt(0)?"":"#")+t})}function un(n,e,r){let o,c=t;i(n,cn,t=>r(6,o=t)),n.$$.on_destroy.push(()=>c());let{routes:s={}}=e,{prefix:u=""}=e;class a{constructor(t,n){if(!n||"function"!=typeof n&&("object"!=typeof n||!0!==n._sveltesparouter))throw Error("Invalid component object");if(!t||"string"==typeof t&&(t.length<1||"/"!=t.charAt(0)&&"*"!=t.charAt(0))||"object"==typeof t&&!(t instanceof RegExp))throw Error('Invalid value for "path" argument');const{pattern:e,keys:r}=function(t,n){if(t instanceof RegExp)return{keys:!1,pattern:t};var e,r,o,c,s=[],u="",a=t.split("/");for(a[0]||a.shift();o=a.shift();)"*"===(e=o[0])?(s.push("wild"),u+="/(.*)"):":"===e?(r=o.indexOf("?",1),c=o.indexOf(".",1),s.push(o.substring(1,~r?r:~c?c:o.length)),u+=~r&&!~c?"(?:/([^/]+?))?":"/([^/]+?)",~c&&(u+=(~r?"?":"")+"\\"+o.substring(c))):u+="/"+o;return{keys:s,pattern:new RegExp("^"+u+(n?"(?=$|/)":"/?$"),"i")}}(t);this.path=t,"object"==typeof n&&!0===n._sveltesparouter?(this.component=n.route,this.conditions=n.conditions||[],this.userData=n.userData):(this.component=n,this.conditions=[],this.userData=void 0),this._pattern=e,this._keys=r}match(t){u&&t.startsWith(u)&&(t=t.substr(u.length)||"/");const n=this._pattern.exec(t);if(null===n)return null;if(!1===this._keys)return n;const e={};let r=0;for(;r{l.push(new a(n,t))}):Object.keys(s).forEach(t=>{l.push(new a(t,s[t]))});let f=null,$=null;const p=T(),d=(t,n)=>{q().then(()=>{p(t,n)})};return n.$$set=t=>{"routes"in t&&r(2,s=t.routes),"prefix"in t&&r(3,u=t.prefix)},n.$$.update=()=>{if(65&n.$$.dirty){r(0,f=null);let t=0;for(;!f&&t{"autofocusElement"in t&&e(0,c=t.autofocusElement),"$$scope"in t&&e(1,o=t.$$scope)},t.$$.update=()=>{1&t.$$.dirty&&c.focus&&c.focus()},[c,o,r,function(n){z(t,n)}]}class $n extends lt{constructor(t){super(),it(this,t,fn,ln,s,{autofocusElement:0})}}function pn(t){let n,e,r;return{c(){n=b("input"),C(n,"class","form-control"),C(n,"placeholder","New account name")},m(o,c){g(o,n,c),N(n,t[0]),t[4](n),e||(r=E(n,"input",t[3]),e=!0)},p(t,e){1&e&&n.value!==t[0]&&N(n,t[0])},d(o){o&&h(n),t[4](null),e=!1,r()}}}function dn(t){let n,e,r,o;return r=new $n({props:{autofocusElement:t[1],$$slots:{default:[pn]},$$scope:{ctx:t}}}),r.$on("submit",t[2]),{c(){n=b("h2"),n.textContent="New Account",e=v(),st(r.$$.fragment)},m(t,c){g(t,n,c),g(t,e,c),ut(r,t,c),o=!0},p(t,[n]){const e={};2&n&&(e.autofocusElement=t[1]),35&n&&(e.$$scope={dirty:n,ctx:t}),r.$set(e)},i(t){o||(nt(r.$$.fragment,t),o=!0)},o(t){et(r.$$.fragment,t),o=!1},d(t){t&&h(n),t&&h(e),at(r,t)}}}function mn(t,n,e){let r="",o={};return[r,o,function(){(t=>{const n={uuid:At(),name:t};ft(n,jt),St()})(r),sn("/accounts")},function(){r=this.value,e(0,r)},function(t){V[t?"unshift":"push"](()=>{o=t,e(1,o)})}]}function gn(n){let e,r,o;return{c(){e=w("svg"),r=w("path"),C(r,"fill","currentColor"),C(r,"d",n[0]),C(e,"aria-hidden","true"),C(e,"class",o=d(n[1])+" svelte-1d15yci"),C(e,"role","img"),C(e,"xmlns","http://www.w3.org/2000/svg"),C(e,"viewBox",n[2])},m(t,n){g(t,e,n),m(e,r)},p(t,[n]){1&n&&C(r,"d",t[0]),2&n&&o!==(o=d(t[1])+" svelte-1d15yci")&&C(e,"class",o),4&n&&C(e,"viewBox",t[2])},i:t,o:t,d(t){t&&h(e)}}}function hn(t,e,r){let{icon:o}=e,c=[],s="",u="";return t.$$set=t=>{r(4,e=n(n({},e),p(t))),"icon"in t&&r(3,o=t.icon)},t.$$.update=()=>{8&t.$$.dirty&&r(2,u="0 0 "+o.icon[0]+" "+o.icon[1]),r(1,s="fa-svelte "+(e.class?e.class:"")),8&t.$$.dirty&&r(0,c=o.icon[4])},e=p(e),[c,s,u,o]}class yn extends lt{constructor(t){super(),it(this,t,hn,gn,s,{icon:3})}}function bn(t){let n,e,r;return n=new yn({props:{icon:t[0]}}),{c(){st(n.$$.fragment),e=v()},m(t,o){ut(n,t,o),g(t,e,o),r=!0},p(t,e){const r={};1&e&&(r.icon=t[0]),n.$set(r)},i(t){r||(nt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){at(n,t),t&&h(e)}}}function wn(t){let n,e,r,o,c,s,u,a,i,l,f,$,p=t[0]&&bn(t);return{c(){n=b("a"),e=b("span"),p&&p.c(),r=b("br"),o=v(),c=b("br"),s=v(),u=x(t[1]),C(e,"class","button-circle svelte-2b5sup"),C(n,"id",a="button-"+t[1]),C(n,"class","btn svelte-2b5sup"),C(n,"href",i=t[3]||"javascript:void(0)"),C(n,"role","button"),M(n,"float-left",t[2])},m(a,i){g(a,n,i),m(n,e),p&&p.m(e,null),m(e,r),m(e,o),m(n,c),m(n,s),m(n,u),l=!0,f||($=E(n,"click",t[4]),f=!0)},p(t,[o]){t[0]?p?(p.p(t,o),1&o&&nt(p,1)):(p=bn(t),p.c(),nt(p,1),p.m(e,r)):p&&(Z(),et(p,1,1,()=>{p=null}),tt()),(!l||2&o)&&L(u,t[1]),(!l||2&o&&a!==(a="button-"+t[1]))&&C(n,"id",a),(!l||8&o&&i!==(i=t[3]||"javascript:void(0)"))&&C(n,"href",i),4&o&&M(n,"float-left",t[2])},i(t){l||(nt(p),l=!0)},o(t){et(p),l=!1},d(t){t&&h(n),p&&p.d(),f=!1,$()}}}function xn(t,n,e){let{icon:r}=n,{name:o}=n,{left:c=!1}=n,{url:s=""}=n;return t.$$set=t=>{"icon"in t&&e(0,r=t.icon),"name"in t&&e(1,o=t.name),"left"in t&&e(2,c=t.left),"url"in t&&e(3,s=t.url)},[r,o,c,s,function(n){z(t,n)}]}class vn extends lt{constructor(t){super(),it(this,t,xn,wn,s,{icon:0,name:1,left:2,url:3})}}function kn(t){let n,e,r,o,c,s;const u=t[1].default,a=l(u,t,t[0],null);return{c(){n=b("div"),e=v(),r=b("div"),a&&a.c(),o=v(),c=b("div"),C(n,"id","button-row-spacer"),C(n,"class","svelte-17rvsyv"),C(c,"class","clearfix"),C(r,"id","button-row"),C(r,"class","svelte-17rvsyv")},m(t,u){g(t,n,u),g(t,e,u),g(t,r,u),a&&a.m(r,null),m(r,o),m(r,c),s=!0},p(t,[n]){a&&a.p&&1&n&&$(a,u,t,t[0],n,null,null)},i(t){s||(nt(a,t),s=!0)},o(t){et(a,t),s=!1},d(t){t&&h(n),t&&h(e),t&&h(r),a&&a.d(t)}}}function En(t,n,e){let{$$slots:r={},$$scope:o}=n;return t.$$set=t=>{"$$scope"in t&&e(0,o=t.$$scope)},[o,r]}class An extends lt{constructor(t){super(),it(this,t,En,kn,s,{})}}var Cn={prefix:"fas",iconName:"arrow-right",icon:[448,512,[],"f061","M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"]},Ln={prefix:"fas",iconName:"check",icon:[512,512,[],"f00c","M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"]},Nn={prefix:"fas",iconName:"home",icon:[576,512,[],"f015","M280.37 148.26L96 300.11V464a16 16 0 0 0 16 16l112.06-.29a16 16 0 0 0 15.92-16V368a16 16 0 0 1 16-16h64a16 16 0 0 1 16 16v95.64a16 16 0 0 0 16 16.05L464 480a16 16 0 0 0 16-16V300L295.67 148.26a12.19 12.19 0 0 0-15.3 0zM571.6 251.47L488 182.56V44.05a12 12 0 0 0-12-12h-56a12 12 0 0 0-12 12v72.61L318.47 43a48 48 0 0 0-61 0L4.34 251.47a12 12 0 0 0-1.6 16.9l25.5 31A12 12 0 0 0 45.15 301l235.22-193.74a12.19 12.19 0 0 1 15.3 0L530.9 301a12 12 0 0 0 16.9-1.6l25.5-31a12 12 0 0 0-1.7-16.93z"]},_n={prefix:"fas",iconName:"list-ul",icon:[512,512,[],"f0ca","M48 48a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm448 16H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"]},Mn={prefix:"fas",iconName:"minus",icon:[448,512,[],"f068","M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"]},On={prefix:"fas",iconName:"times",icon:[352,512,[],"f00d","M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"]};function jn(t,n,e){const r=t.slice();return r[1]=n[e],r}function Sn(t){let n,e,r=t[1].name+"";return{c(){n=b("li"),e=x(r)},m(t,r){g(t,n,r),m(n,e)},p(t,n){1&n&&r!==(r=t[1].name+"")&&L(e,r)},d(t){t&&h(n)}}}function Dn(n){let e,r;return e=new vn({props:{icon:Nn,name:"budget",url:"#/budget",left:!0}}),{c(){st(e.$$.fragment)},m(t,n){ut(e,t,n),r=!0},p:t,i(t){r||(nt(e.$$.fragment,t),r=!0)},o(t){et(e.$$.fragment,t),r=!1},d(t){at(e,t)}}}function Tn(t){let n,e,r,o,c,s,u,a,i=t[0],l=[];for(let n=0;nAdd new account',s=v(),st(u.$$.fragment)},m(t,i){g(t,n,i),g(t,e,i),g(t,r,i);for(let t=0;te(0,r=t)),[r]}const Hn=t=>In(t)?"danger":"",Vn=t=>Rn(t,2),Pn=t=>Rn(t,0),Rn=(t,n)=>(null==t&&(t=0),(Number(t)/100).toFixed(n)),In=t=>t&&t<0;function Bn(n){let e,r,o,c;return{c(){e=b("div"),r=b("div"),C(r,"class",o="category-graph-line "+n[2](n[1],n[0])+" svelte-6b2uyp"),_(r,"width",n[3](n[1],n[0])+"%"),C(e,"class",c="category-graph "+Hn(n[1])+" svelte-6b2uyp")},m(t,n){g(t,e,n),m(e,r)},p(t,[n]){3&n&&o!==(o="category-graph-line "+t[2](t[1],t[0])+" svelte-6b2uyp")&&C(r,"class",o),3&n&&_(r,"width",t[3](t[1],t[0])+"%"),2&n&&c!==(c="category-graph "+Hn(t[1])+" svelte-6b2uyp")&&C(e,"class",c)},i:t,o:t,d(t){t&&h(e)}}}function Fn(t,n,e){let{budgeted:r}=n,{remaining:o}=n;return t.$$set=t=>{"budgeted"in t&&e(0,r=t.budgeted),"remaining"in t&&e(1,o=t.remaining)},[r,o,(t,n)=>null==t?"":t<0?"danger":tt<0?0:0===n?t>0?100:0:t/n*100]}class qn extends lt{constructor(t){super(),it(this,t,Fn,Bn,s,{budgeted:0,remaining:1})}}function Un(t,n,e){const r=t.slice();return r[3]=n[e].budgeted,r[4]=n[e].remaining,r[5]=n[e].name,r[6]=n[e].uuid,r}function Yn(t){let n,e,r,o,c,s,u,a,i,l,f,$,p,d,y,w,k,E,A,N,_,M=t[5]+"",O=Vn(t[4])+"",j=Pn(t[3])+"";return a=new qn({props:{budgeted:t[3],remaining:t[4]}}),{c(){n=b("tr"),e=b("td"),r=b("a"),o=x(M),s=v(),u=b("td"),st(a.$$.fragment),i=v(),l=b("td"),f=b("div"),$=b("sup"),$.textContent="$",p=x(O),y=v(),w=b("div"),k=b("span"),E=x("/ "),A=x(j),N=v(),C(r,"href",c="#/category/"+t[6]),C(r,"class","btn btn-outline-secondary"),C(e,"class","category-name width-10 svelte-1g8xb6x"),C(u,"class","width-80 svelte-1g8xb6x"),C($,"class","svelte-1g8xb6x"),C(f,"class",d="category-available "+Hn(t[4])+" svelte-1g8xb6x"),C(w,"class","category-budgeted svelte-1g8xb6x"),C(l,"class","category-amount width-10 svelte-1g8xb6x")},m(t,c){g(t,n,c),m(n,e),m(e,r),m(r,o),m(n,s),m(n,u),ut(a,u,null),m(n,i),m(n,l),m(l,f),m(f,$),m(f,p),m(l,y),m(l,w),m(w,k),m(k,E),m(k,A),m(n,N),_=!0},p(t,n){(!_||1&n)&&M!==(M=t[5]+"")&&L(o,M),(!_||1&n&&c!==(c="#/category/"+t[6]))&&C(r,"href",c);const e={};1&n&&(e.budgeted=t[3]),1&n&&(e.remaining=t[4]),a.$set(e),(!_||1&n)&&O!==(O=Vn(t[4])+"")&&L(p,O),(!_||1&n&&d!==(d="category-available "+Hn(t[4])+" svelte-1g8xb6x"))&&C(f,"class",d),(!_||1&n)&&j!==(j=Pn(t[3])+"")&&L(A,j)},i(t){_||(nt(a.$$.fragment,t),_=!0)},o(t){et(a.$$.fragment,t),_=!1},d(t){t&&h(n),at(a)}}}function Jn(t){let n,e,r,o=t[0],c=[];for(let n=0;net(c[t],1,1,()=>{c[t]=null});return{c(){n=b("table"),e=b("tbody");for(let t=0;te(1,r=t)),i(t,Dt,t=>e(2,o=t)),t.$$.update=()=>{6&t.$$.dirty&&e(0,c=((t,n)=>{let e=[];for(var r in t)if(t.hasOwnProperty(r)){let o=Tt(r,n);e.push({budgeted:t[r].budgeted,remaining:t[r].remaining,name:o.name,uuid:o.uuid})}return e.sort((t,n)=>(t.name||"").localeCompare(n.name||""))})(r,o))},[c]}class Gn extends lt{constructor(t){super(),it(this,t,Wn,Jn,s,{})}}function Kn(n){let e,r,o,c;return e=new vn({props:{icon:_n,name:"accounts",url:"#/accounts",left:!0}}),o=new vn({props:{icon:Mn,name:"expense",url:"#/expense/new"}}),{c(){st(e.$$.fragment),r=v(),st(o.$$.fragment)},m(t,n){ut(e,t,n),g(t,r,n),ut(o,t,n),c=!0},p:t,i(t){c||(nt(e.$$.fragment,t),nt(o.$$.fragment,t),c=!0)},o(t){et(e.$$.fragment,t),et(o.$$.fragment,t),c=!1},d(t){at(e,t),t&&h(r),at(o,t)}}}function Qn(t){let n,e,r,o,c,s,u,a;return r=new Gn({}),u=new An({props:{$$slots:{default:[Kn]},$$scope:{ctx:t}}}),{c(){n=b("h2"),n.textContent="Budget",e=v(),st(r.$$.fragment),o=v(),c=b("p"),c.innerHTML='Add new category',s=v(),st(u.$$.fragment)},m(t,i){g(t,n,i),g(t,e,i),ut(r,t,i),g(t,o,i),g(t,c,i),g(t,s,i),ut(u,t,i),a=!0},p(t,[n]){const e={};1&n&&(e.$$scope={dirty:n,ctx:t}),u.$set(e)},i(t){a||(nt(r.$$.fragment,t),nt(u.$$.fragment,t),a=!0)},o(t){et(r.$$.fragment,t),et(u.$$.fragment,t),a=!1},d(t){t&&h(n),t&&h(e),at(r,t),t&&h(o),t&&h(c),t&&h(s),at(u,t)}}}function Xn(n){let e,r,c,s,u,a,i;return{c(){e=b("form"),r=b("div"),c=b("div"),c.innerHTML='$',s=v(),u=b("input"),C(c,"class","input-group-prepend"),C(u,"type","tel"),C(u,"aria-describedby","amount-input-currency-symbol"),C(u,"aria-label","Amount"),C(u,"class","text-right form-control"),C(r,"class","input-group input-group-lg"),e.noValidate=!0},m(t,o){g(t,e,o),m(e,r),m(r,c),m(r,s),m(r,u),n[5](u),a||(i=[E(u,"keydown",n[1]),E(e,"submit",A(n[2]))],a=!0)},p:t,i:t,o:t,d(t){t&&h(e),n[5](null),a=!1,o(i)}}}function Zn(t,n,e){let{amount:r=0}=n,{resultingAmount:o=0}=n;const c=T();let s,u=[];D(()=>{a(r),s.focus()});const a=t=>{var n;u=(n=t)?String(n).split("").filter((function(t){return"0123456789".indexOf(t)>=0})):[],i(u),l(Number(u.join("")))};function i(t){for(var n="",r=0;r{"amount"in t&&e(4,r=t.amount),"resultingAmount"in t&&e(3,o=t.resultingAmount)},t.$$.update=()=>{16&t.$$.dirty&&a(r)},[s,function(t){var n=t.which;(t=>t>=32&&t<112||t>=123&&t<127||t>=186)(n)&&t.preventDefault();var e=(t=>t>=48&&t<58?String(t-48):t>=96&&t<106?String(t-96):"")(n);e?u.push(e):(t=>8===t)(n)&&(t.preventDefault(),u.pop()),i(u),l(Number(u.join("")))},function(t){c("next",o)},o,r,function(t){V[t?"unshift":"push"](()=>{s=t,e(0,s)})}]}class te extends lt{constructor(t){super(),it(this,t,Zn,Xn,s,{amount:4,resultingAmount:3})}}function ne(n){let e,r,o,c;return e=new vn({props:{icon:Ln,name:"save"}}),e.$on("click",n[3]),o=new vn({props:{icon:On,name:"cancel",url:"#/budget",left:!0}}),{c(){st(e.$$.fragment),r=v(),st(o.$$.fragment)},m(t,n){ut(e,t,n),g(t,r,n),ut(o,t,n),c=!0},p:t,i(t){c||(nt(e.$$.fragment,t),nt(o.$$.fragment,t),c=!0)},o(t){et(e.$$.fragment,t),et(o.$$.fragment,t),c=!1},d(t){at(e,t),t&&h(r),at(o,t)}}}function ee(t){let n,e,r,o,c,s,u,a,i,l=t[1].name+"";function f(n){t[5].call(null,n)}let $={amount:t[2]};return void 0!==t[0]&&($.resultingAmount=t[0]),c=new te({props:$}),V.push(()=>ct(c,"resultingAmount",f)),c.$on("next",t[3]),a=new An({props:{$$slots:{default:[ne]},$$scope:{ctx:t}}}),{c(){n=b("h2"),e=x("Monthly amount for "),r=x(l),o=v(),st(c.$$.fragment),u=v(),st(a.$$.fragment)},m(t,s){g(t,n,s),m(n,e),m(n,r),g(t,o,s),ut(c,t,s),g(t,u,s),ut(a,t,s),i=!0},p(t,[n]){(!i||2&n)&&l!==(l=t[1].name+"")&&L(r,l);const e={};4&n&&(e.amount=t[2]),!s&&1&n&&(s=!0,e.resultingAmount=t[0],Y(()=>s=!1)),c.$set(e);const o={};256&n&&(o.$$scope={dirty:n,ctx:t}),a.$set(o)},i(t){i||(nt(c.$$.fragment,t),nt(a.$$.fragment,t),i=!0)},o(t){et(c.$$.fragment,t),et(a.$$.fragment,t),i=!1},d(t){t&&h(n),t&&h(o),at(c,t),t&&h(u),at(a,t)}}}function re(t,n,e){let r;i(t,Dt,t=>e(7,r=t));let{params:o}=n,c=0;let s,u,a;return t.$$set=t=>{"params"in t&&e(4,o=t.params)},t.$$.update=()=>{16&t.$$.dirty&&e(6,s=o.uuid),192&t.$$.dirty&&e(1,u=r.find(t=>t.uuid===s)||{}),66&t.$$.dirty&&e(2,a=u&&Ft(s)||0)},[c,u,a,()=>{Ut(s,c),sn("/budget")},o,function(t){c=t,e(0,c)}]}function oe(n){let e,r,c,s,u,a;return{c(){e=b("form"),r=b("h2"),r.innerHTML='',c=v(),s=b("input"),C(s,"class","form-control"),C(s,"placeholder","New category name"),C(s,"id","new-category-name")},m(t,o){g(t,e,o),m(e,r),m(e,c),m(e,s),N(s,n[0]),n[4](s),u||(a=[E(s,"input",n[3]),E(e,"submit",A(n[2]))],u=!0)},p(t,[n]){1&n&&s.value!==t[0]&&N(s,t[0])},i:t,o:t,d(t){t&&h(e),n[4](null),u=!1,o(a)}}}function ce(t,n,e){let r="",o={};return D(()=>{o.focus()}),[r,o,function(){sn(`/category/${(t=>{const n=a(Dt).find(n=>n.name===t);if(n)return n;{const n={uuid:At(),name:t};return ft(n,Dt),zt(),n}})(r).uuid}/amount`)},function(){r=this.value,e(0,r)},function(t){V[t?"unshift":"push"](()=>{o=t,e(1,o)})}]}function se(t,n,e){const r=t.slice();return r[1]=n[e].amountTotal,r[2]=n[e].timestamp,r[3]=n[e].who,r}function ue(t){let n;return{c(){n=b("i"),n.textContent="No matching transactions found."},m(t,e){g(t,n,e)},d(t){t&&h(n)}}}function ae(t){let n,e,r,o,c,s,u,a,i,l,f,$=Vt(t[2])+"",p=t[3]+"",d=Vn(t[1])+"";return{c(){n=b("div"),e=b("div"),r=x($),o=v(),c=b("div"),s=x(p),u=v(),a=b("div"),i=b("sup"),i.textContent="$",l=x(d),f=v(),C(e,"class","col-2 text-center"),C(c,"class","col-7"),C(a,"class","col-3 text-right"),C(n,"class","row")},m(t,$){g(t,n,$),m(n,e),m(e,r),m(n,o),m(n,c),m(c,s),m(n,u),m(n,a),m(a,i),m(a,l),m(n,f)},p(t,n){1&n&&$!==($=Vt(t[2])+"")&&L(r,$),1&n&&p!==(p=t[3]+"")&&L(s,p),1&n&&d!==(d=Vn(t[1])+"")&&L(l,d)},d(t){t&&h(n)}}}function ie(n){let e,r=n[0],o=[];for(let t=0;t{"transactions"in t&&e(0,r=t.transactions)},[r]}class fe extends lt{constructor(t){super(),it(this,t,le,ie,s,{transactions:0})}}function $e(n){let e,r;return e=new vn({props:{icon:Nn,name:"budget",url:"#/budget",left:!0}}),{c(){st(e.$$.fragment)},m(t,n){ut(e,t,n),r=!0},p:t,i(t){r||(nt(e.$$.fragment,t),r=!0)},o(t){et(e.$$.fragment,t),r=!1},d(t){at(e,t)}}}function pe(t){let n,e,r,o,c,s,u,a,i,l,f,$,p,d,y,w,k,A,N,_=t[1].name+"",M=Vn(Ft(t[0]))+"";return d=new fe({props:{transactions:t[2]}}),w=new An({props:{$$slots:{default:[$e]},$$scope:{ctx:t}}}),{c(){n=b("h2"),e=b("b"),r=x(_),o=x(":"),c=v(),s=b("a"),u=b("sup"),u.textContent="$",a=v(),i=x(M),f=v(),$=b("hr"),p=v(),st(d.$$.fragment),y=v(),st(w.$$.fragment),C(e,"class","editable svelte-1uc4ts5"),C(e,"title","(Click to rename)"),C(s,"class","btn btn-default"),C(s,"href",l="#/category/"+t[0]+"/amount"),C($,"class","small")},m(l,h){g(l,n,h),m(n,e),m(e,r),m(e,o),m(n,c),m(n,s),m(s,u),m(s,a),m(s,i),g(l,f,h),g(l,$,h),g(l,p,h),ut(d,l,h),g(l,y,h),ut(w,l,h),k=!0,A||(N=E(e,"click",t[3]),A=!0)},p(t,[n]){(!k||2&n)&&_!==(_=t[1].name+"")&&L(r,_),(!k||1&n)&&M!==(M=Vn(Ft(t[0]))+"")&&L(i,M),(!k||1&n&&l!==(l="#/category/"+t[0]+"/amount"))&&C(s,"href",l);const e={};4&n&&(e.transactions=t[2]),d.$set(e);const o={};64&n&&(o.$$scope={dirty:n,ctx:t}),w.$set(o)},i(t){k||(nt(d.$$.fragment,t),nt(w.$$.fragment,t),k=!0)},o(t){et(d.$$.fragment,t),et(w.$$.fragment,t),k=!1},d(t){t&&h(n),t&&h(f),t&&h($),t&&h(p),at(d,t),t&&h(y),at(w,t),A=!1,N()}}}function de(t,n,e){let r;i(t,Dt,t=>e(5,r=t));let{params:o={}}=n;let c,s,u;return t.$$set=t=>{"params"in t&&e(4,o=t.params)},t.$$.update=()=>{16&t.$$.dirty&&e(0,c=o.uuid||""),33&t.$$.dirty&&e(1,s=r.find(t=>t.uuid===c)||{}),1&t.$$.dirty&&e(2,u=Xt(c))},[c,s,u,()=>{let t=prompt("Edit category name:",s.name);null!=t&&Ht(c,{name:t})},o]}function me(t,n,e){const r=t.slice();return r[3]=n[e],r}function ge(t,n){let e,r,o,c,s,u,a=n[3].name+"";function i(...t){return n[2](n[3],...t)}return{key:t,first:null,c(){e=b("p"),r=b("button"),o=x(a),c=v(),C(r,"class","btn btn-outline-secondary"),this.first=e},m(t,n){g(t,e,n),m(e,r),m(r,o),m(e,c),s||(u=E(r,"click",i),s=!0)},p(t,e){n=t,1&e&&a!==(a=n[3].name+"")&&L(o,a)},d(t){t&&h(e),s=!1,u()}}}function he(n){let e,r=[],o=new Map,c=n[0];const s=t=>t[3].uuid;for(let t=0;t{"accounts"in t&&e(0,r=t.accounts)},[r,o,t=>o("select",t.uuid)]}class be extends lt{constructor(t){super(),it(this,t,ye,he,s,{accounts:0})}}function we(n){let e,r;return e=new vn({props:{icon:Nn,name:"budget",url:"#/budget",left:!0}}),{c(){st(e.$$.fragment)},m(t,n){ut(e,t,n),r=!0},p:t,i(t){r||(nt(e.$$.fragment,t),r=!0)},o(t){et(e.$$.fragment,t),r=!1},d(t){at(e,t)}}}function xe(t){let n,e,r,o,c,s;return r=new be({props:{accounts:t[0]}}),r.$on("select",t[1]),c=new An({props:{$$slots:{default:[we]},$$scope:{ctx:t}}}),{c(){n=b("h2"),n.textContent="Paid using",e=v(),st(r.$$.fragment),o=v(),st(c.$$.fragment)},m(t,u){g(t,n,u),g(t,e,u),ut(r,t,u),g(t,o,u),ut(c,t,u),s=!0},p(t,[n]){const e={};1&n&&(e.accounts=t[0]),r.$set(e);const o={};4&n&&(o.$$scope={dirty:n,ctx:t}),c.$set(o)},i(t){s||(nt(r.$$.fragment,t),nt(c.$$.fragment,t),s=!0)},o(t){et(r.$$.fragment,t),et(c.$$.fragment,t),s=!1},d(t){t&&h(n),t&&h(e),at(r,t),t&&h(o),at(c,t)}}}function ve(t,n,e){let r;return i(t,jt,t=>e(0,r=t)),[r,function(t){let n=t.detail;tn({accountUuid:n}),sn("/expense/amount/")}]}function ke(n){let e,r,o,c;return e=new vn({props:{icon:Cn,name:"next"}}),e.$on("click",n[2]),o=new vn({props:{icon:Nn,name:"budget",url:"#/budget",left:!0}}),{c(){st(e.$$.fragment),r=v(),st(o.$$.fragment)},m(t,n){ut(e,t,n),g(t,r,n),ut(o,t,n),c=!0},p:t,i(t){c||(nt(e.$$.fragment,t),nt(o.$$.fragment,t),c=!0)},o(t){et(e.$$.fragment,t),et(o.$$.fragment,t),c=!1},d(t){at(e,t),t&&h(r),at(o,t)}}}function Ee(t){let n,e,r,o,c,s,u,a,i,l=t[1].who+"";function f(n){t[3].call(null,n)}let $={};return void 0!==t[0]&&($.resultingAmount=t[0]),c=new te({props:$}),V.push(()=>ct(c,"resultingAmount",f)),c.$on("next",t[2]),a=new An({props:{$$slots:{default:[ke]},$$scope:{ctx:t}}}),{c(){n=b("h2"),e=x("Amount paid to "),r=x(l),o=v(),st(c.$$.fragment),u=v(),st(a.$$.fragment)},m(t,s){g(t,n,s),m(n,e),m(n,r),g(t,o,s),ut(c,t,s),g(t,u,s),ut(a,t,s),i=!0},p(t,[n]){(!i||2&n)&&l!==(l=t[1].who+"")&&L(r,l);const e={};!s&&1&n&&(s=!0,e.resultingAmount=t[0],Y(()=>s=!1)),c.$set(e);const o={};32&n&&(o.$$scope={dirty:n,ctx:t}),a.$set(o)},i(t){i||(nt(c.$$.fragment,t),nt(a.$$.fragment,t),i=!0)},o(t){et(c.$$.fragment,t),et(a.$$.fragment,t),i=!1},d(t){t&&h(n),t&&h(o),at(c,t),t&&h(u),at(a,t)}}}function Ae(t,n,e){let r;i(t,Kt,t=>e(4,r=t));let o=0;let c;return t.$$.update=()=>{16&t.$$.dirty&&e(1,c=r)},[o,c,()=>{tn({amountTotal:o}),sn("/expense/category/")},function(t){o=t,e(0,o)}]}function Ce(t,n,e){const r=t.slice();return r[4]=n[e],r}function Le(t,n){let e,r,o,c,s,u,a=n[4].name+"";function i(...t){return n[2](n[4],...t)}return{key:t,first:null,c(){e=b("p"),r=b("button"),o=x(a),c=v(),C(r,"class","btn btn-outline-secondary"),this.first=e},m(t,n){g(t,e,n),m(e,r),m(r,o),m(e,c),s||(u=E(r,"click",i),s=!0)},p(t,e){n=t,1&e&&a!==(a=n[4].name+"")&&L(o,a)},d(t){t&&h(e),s=!1,u()}}}function Ne(n){let e,r=[],o=new Map,c=n[0];const s=t=>t[4].uuid;for(let t=0;t{"categories"in t&&e(0,r=t.categories)},[r,o,t=>o("select",t.uuid)]}class Me extends lt{constructor(t){super(),it(this,t,_e,Ne,s,{categories:0})}}function Oe(n){let e,r;return e=new vn({props:{icon:Nn,name:"budget",url:"#/budget",left:!0}}),{c(){st(e.$$.fragment)},m(t,n){ut(e,t,n),r=!0},p:t,i(t){r||(nt(e.$$.fragment,t),r=!0)},o(t){et(e.$$.fragment,t),r=!1},d(t){at(e,t)}}}function je(t){let n,e,r,o,c,s;return r=new Me({props:{categories:t[0]}}),r.$on("select",t[1]),c=new An({props:{$$slots:{default:[Oe]},$$scope:{ctx:t}}}),{c(){n=b("h2"),n.textContent="Category",e=v(),st(r.$$.fragment),o=v(),st(c.$$.fragment)},m(t,u){g(t,n,u),g(t,e,u),ut(r,t,u),g(t,o,u),ut(c,t,u),s=!0},p(t,[n]){const e={};1&n&&(e.categories=t[0]),r.$set(e);const o={};8&n&&(o.$$scope={dirty:n,ctx:t}),c.$set(o)},i(t){s||(nt(r.$$.fragment,t),nt(c.$$.fragment,t),s=!0)},o(t){et(r.$$.fragment,t),et(c.$$.fragment,t),s=!1},d(t){t&&h(n),t&&h(e),at(r,t),t&&h(o),at(c,t)}}}function Se(t,n,e){let r,o;return i(t,Kt,t=>e(2,r=t)),i(t,Dt,t=>e(0,o=t)),[o,function(t){let n={};n[t.detail]=r.amountTotal,tn({categoryAmounts:n}),sn("/expense/review/")}]}function De(t){const n=Date.now();return Qt({timestamp:n}),sn("/expense/who/"),[]}function Te(n){let e,r,o,c,s=Vn(n[1])+"";return{c(){e=b("span"),r=x(n[0]),o=x(": $ "),c=x(s),C(e,"class","badge badge-info")},m(t,n){g(t,e,n),m(e,r),m(e,o),m(e,c)},p(t,[n]){1&n&&L(r,t[0]),2&n&&s!==(s=Vn(t[1])+"")&&L(c,s)},i:t,o:t,d(t){t&&h(e)}}}function ze(t,n,e){let{name:r=""}=n,{amount:o=0}=n;return t.$$set=t=>{"name"in t&&e(0,r=t.name),"amount"in t&&e(1,o=t.amount)},[r,o]}class He extends lt{constructor(t){super(),it(this,t,ze,Te,s,{name:0,amount:1})}}function Ve(t,n,e){const r=t.slice();return r[4]=n[e],r}function Pe(t){let n,e;return n=new He({props:{name:Tt(t[4],t[2]).name,amount:t[0][t[4]]}}),{c(){st(n.$$.fragment)},m(t,r){ut(n,t,r),e=!0},p(t,e){const r={};6&e&&(r.name=Tt(t[4],t[2]).name),3&e&&(r.amount=t[0][t[4]]),n.$set(r)},i(t){e||(nt(n.$$.fragment,t),e=!0)},o(t){et(n.$$.fragment,t),e=!1},d(t){at(n,t)}}}function Re(t){let n,e,r=t[1],o=[];for(let n=0;net(o[t],1,1,()=>{o[t]=null});return{c(){for(let t=0;te(2,r=t));let o,c,{transaction:s={}}=n;return t.$$set=t=>{"transaction"in t&&e(3,s=t.transaction)},t.$$.update=()=>{8&t.$$.dirty&&e(0,o=s.categoryAmounts||{}),1&t.$$.dirty&&e(1,c=Object.keys(o))},[o,c,r,s]}class Be extends lt{constructor(t){super(),it(this,t,Ie,Re,s,{transaction:3})}}function Fe(n){let e,r;return e=new vn({props:{icon:Nn,name:"done"}}),e.$on("click",n[3]),{c(){st(e.$$.fragment)},m(t,n){ut(e,t,n),r=!0},p:t,i(t){r||(nt(e.$$.fragment,t),r=!0)},o(t){et(e.$$.fragment,t),r=!1},d(t){at(e,t)}}}function qe(t){let n,e,r,o,c,s,u,a,i,l,f,$,p,d,y,w,k,A,N,_,M,O,j,S,D,T,z,H,V,P,R,I=t[0].who+"",B=Vn(t[2])+"";return d=new Be({props:{transaction:t[0]}}),H=new An({props:{$$slots:{default:[Fe]},$$scope:{ctx:t}}}),{c(){n=b("div"),e=b("div"),r=b("h2"),r.textContent="Review Expense",o=v(),c=b("p"),s=b("a"),u=x(I),a=v(),i=b("a"),l=x("$"),f=x(B),$=v(),p=b("p"),st(d.$$.fragment),y=v(),w=b("p"),k=b("b"),k.textContent="Account:",A=v(),N=b("a"),_=x(t[1]),M=v(),O=b("p"),j=b("b"),j.textContent="Date:",S=v(),D=b("input"),z=v(),st(H.$$.fragment),C(s,"class","btn btn-outline-secondary"),C(s,"href","#/expense/who/"),C(i,"class","btn btn-outline-secondary float-right"),C(i,"href","#/expense/amount/"),C(N,"class","btn btn-outline-secondary float-right"),C(N,"href","#/expense/account/"),C(D,"type","date"),C(D,"class","float-right"),D.value=T=Pt(t[0].timestamp),C(e,"class","col-12 col-sm-8 offset-sm-2 col-md-6 offset-md-3"),C(n,"class","row")},m(h,b){g(h,n,b),m(n,e),m(e,r),m(e,o),m(e,c),m(c,s),m(s,u),m(c,a),m(c,i),m(i,l),m(i,f),m(e,$),m(e,p),ut(d,p,null),m(e,y),m(e,w),m(w,k),m(w,A),m(w,N),m(N,_),m(e,M),m(e,O),m(O,j),m(O,S),m(O,D),g(h,z,b),ut(H,h,b),V=!0,P||(R=E(D,"change",t[4]),P=!0)},p(t,[n]){(!V||1&n)&&I!==(I=t[0].who+"")&&L(u,I),(!V||4&n)&&B!==(B=Vn(t[2])+"")&&L(f,B);const e={};1&n&&(e.transaction=t[0]),d.$set(e),(!V||2&n)&&L(_,t[1]),(!V||1&n&&T!==(T=Pt(t[0].timestamp)))&&(D.value=T);const r={};512&n&&(r.$$scope={dirty:n,ctx:t}),H.$set(r)},i(t){V||(nt(d.$$.fragment,t),nt(H.$$.fragment,t),V=!0)},o(t){et(d.$$.fragment,t),et(H.$$.fragment,t),V=!1},d(t){t&&h(n),at(d),t&&h(z),at(H,t),P=!1,R()}}}function Ue(t,n,e){let r,o;i(t,Kt,t=>e(5,r=t)),i(t,jt,t=>e(7,o=t));let c,s,u,l;return t.$$.update=()=>{var n;32&t.$$.dirty&&e(0,c=r),129&t.$$.dirty&&e(6,(n=c.accountUuid,s=o.find(t=>t.uuid===n)||{})),64&t.$$.dirty&&e(1,u=s.name||""),1&t.$$.dirty&&e(2,l=c.amountTotal||0)},[c,u,l,function(){(()=>{const t=a(Kt);t.uuid=At(),ft(t,Gt),Zt();const n=t.categoryAmounts||{};for(const t in n){const e=n[t]||0;Yt(t,e)}Qt({})})(),sn("/budget")},t=>{let n=t.target.value,e=new Date(n+" 12:00:00");tn({timestamp:e.getTime()})}]}function Ye(t){let n,e,r,o,c,s,u;return{c(){n=b("h2"),e=b("label"),r=x(t[1]),o=v(),c=b("input"),C(e,"for","who"),C(c,"type","text"),C(c,"class","form-control"),C(c,"id","who")},m(a,i){g(a,n,i),m(n,e),m(e,r),g(a,o,i),g(a,c,i),N(c,t[0]),t[5](c),s||(u=E(c,"input",t[4]),s=!0)},p(t,n){2&n&&L(r,t[1]),1&n&&c.value!==t[0]&&N(c,t[0])},d(e){e&&h(n),e&&h(o),e&&h(c),t[5](null),s=!1,u()}}}function Je(t){let n,e;return n=new $n({props:{autofocusElement:t[2],$$slots:{default:[Ye]},$$scope:{ctx:t}}}),n.$on("submit",t[3]),{c(){st(n.$$.fragment)},m(t,r){ut(n,t,r),e=!0},p(t,[e]){const r={};4&e&&(r.autofocusElement=t[2]),135&e&&(r.$$scope={dirty:e,ctx:t}),n.$set(r)},i(t){e||(nt(n.$$.fragment,t),e=!0)},o(t){et(n.$$.fragment,t),e=!1},d(t){at(n,t)}}}function We(t,n,e){let{title:r}=n,{who:o=""}=n;const c=T();let s={};return t.$$set=t=>{"title"in t&&e(1,r=t.title),"who"in t&&e(0,o=t.who)},[o,r,s,()=>{c("select",o)},function(){o=this.value,e(0,o)},function(t){V[t?"unshift":"push"](()=>{s=t,e(2,s)})}]}class Ge extends lt{constructor(t){super(),it(this,t,We,Je,s,{title:1,who:0})}}function Ke(n){let e,r,o,c;return e=new vn({props:{icon:Cn,name:"next"}}),e.$on("click",n[1]),o=new vn({props:{icon:Nn,name:"budget",url:"#/budget",left:!0}}),{c(){st(e.$$.fragment),r=v(),st(o.$$.fragment)},m(t,n){ut(e,t,n),g(t,r,n),ut(o,t,n),c=!0},p:t,i(t){c||(nt(e.$$.fragment,t),nt(o.$$.fragment,t),c=!0)},o(t){et(e.$$.fragment,t),et(o.$$.fragment,t),c=!1},d(t){at(e,t),t&&h(r),at(o,t)}}}function Qe(t){let n,e,r,o,c;function s(n){t[2].call(null,n)}let u={title:"Paid to:"};return void 0!==t[0]&&(u.who=t[0]),n=new Ge({props:u}),V.push(()=>ct(n,"who",s)),n.$on("select",t[1]),o=new An({props:{$$slots:{default:[Ke]},$$scope:{ctx:t}}}),{c(){st(n.$$.fragment),r=v(),st(o.$$.fragment)},m(t,e){ut(n,t,e),g(t,r,e),ut(o,t,e),c=!0},p(t,[r]){const c={};!e&&1&r&&(e=!0,c.who=t[0],Y(()=>e=!1)),n.$set(c);const s={};8&r&&(s.$$scope={dirty:r,ctx:t}),o.$set(s)},i(t){c||(nt(n.$$.fragment,t),nt(o.$$.fragment,t),c=!0)},o(t){et(n.$$.fragment,t),et(o.$$.fragment,t),c=!1},d(t){at(n,t),t&&h(r),at(o,t)}}}function Xe(t,n,e){let r="";return[r,()=>{tn({who:r}),sn("/expense/account/")},function(t){r=t,e(0,r)}]}function Ze(t){return function(t){if(!t||t.length<1||"/"!=t.charAt(0)&&0!==t.indexOf("#/"))throw Error("Invalid parameter location");q().then(()=>{const n=("#"==t.charAt(0)?"":"#")+t;try{window.history.replaceState(void 0,void 0,n)}catch(t){console.warn("Caught exception while replacing the current page. If you're running this in the Svelte REPL, please note that the `replace` method might not work in this environment.")}window.dispatchEvent(new Event("hashchange"))})}("/budget"),[]}function tr(n){let e,r,o,c,s;return{c(){e=b("h2"),e.textContent="Hmm...",r=v(),o=b("p"),o.textContent="We can't seem to find that page.",c=v(),s=b("p"),s.innerHTML='Try going back to the Home screen. Perhaps there's a link\n from there to where you were trying to go.'},m(t,n){g(t,e,n),g(t,r,n),g(t,o,n),g(t,c,n),g(t,s,n)},p:t,i:t,o:t,d(t){t&&h(e),t&&h(r),t&&h(o),t&&h(c),t&&h(s)}}}const nr={"/":class extends lt{constructor(t){super(),it(this,t,Ze,null,s,{})}},"/account/new":class extends lt{constructor(t){super(),it(this,t,mn,dn,s,{})}},"/accounts":class extends lt{constructor(t){super(),it(this,t,zn,Tn,s,{})}},"/budget":class extends lt{constructor(t){super(),it(this,t,null,Qn,s,{})}},"/category/new":class extends lt{constructor(t){super(),it(this,t,ce,oe,s,{})}},"/category/:uuid":class extends lt{constructor(t){super(),it(this,t,de,pe,s,{params:4})}},"/category/:uuid/amount":class extends lt{constructor(t){super(),it(this,t,re,ee,s,{params:4})}},"/expense/account/":class extends lt{constructor(t){super(),it(this,t,ve,xe,s,{})}},"/expense/amount/":class extends lt{constructor(t){super(),it(this,t,Ae,Ee,s,{})}},"/expense/category/":class extends lt{constructor(t){super(),it(this,t,Se,je,s,{})}},"/expense/new":class extends lt{constructor(t){super(),it(this,t,De,null,s,{})}},"/expense/review/":class extends lt{constructor(t){super(),it(this,t,Ue,qe,s,{})}},"/expense/who/":class extends lt{constructor(t){super(),it(this,t,Xe,Qe,s,{})}},"*":class extends lt{constructor(t){super(),it(this,t,null,tr,s,{})}}};function er(n){let e,r,o,c,s;return r=new Ot({}),c=new an({props:{routes:nr}}),{c(){e=b("div"),st(r.$$.fragment),o=v(),st(c.$$.fragment),C(e,"class","container-xl my-3")},m(t,n){g(t,e,n),ut(r,e,null),m(e,o),ut(c,e,null),s=!0},p:t,i(t){s||(nt(r.$$.fragment,t),nt(c.$$.fragment,t),s=!0)},o(t){et(r.$$.fragment,t),et(c.$$.fragment,t),s=!1},d(t){t&&h(e),at(r),at(c)}}}function rr(t){return D(async()=>{jt.set(pt("accounts")),Dt.set(pt("categories")),qt(),Gt.set(pt("transactions"))}),[]}return new class extends lt{constructor(t){super(),it(this,t,rr,er,s,{})}}({target:document.body})}(); diff --git a/src/components/AmountInput.svelte b/src/components/AmountInput.svelte index 7571fd6..b7b4ef8 100644 --- a/src/components/AmountInput.svelte +++ b/src/components/AmountInput.svelte @@ -3,19 +3,25 @@ import { getNumericCharFrom, isBackspace, isPrintable } from '../helpers/charact import { createEventDispatcher, onMount } from 'svelte'; export let amount = 0 +export let resultingAmount = 0 const dispatch = createEventDispatcher(); let inputField let numeralsEntered = [] -let resultingAmount = null + +$: recordAndShowAmount(amount) onMount(() => { + recordAndShowAmount(amount) + inputField.focus(); +}) + +const recordAndShowAmount = amount => { numeralsEntered = getNumeralsFromAmount(amount) showNumerals(numeralsEntered) recordAmount(Number(numeralsEntered.join(''))) - inputField.focus(); -}) +} function getNumeralsFromAmount(value) { if ( ! value) { @@ -47,7 +53,9 @@ function showNumerals(numerals) { text = '0' + text; } - inputField.value = text; + if (inputField) { + inputField.value = text; + } } function recordAmount(amount) { diff --git a/src/components/Button.svelte b/src/components/Button.svelte index d7b8229..34d0624 100644 --- a/src/components/Button.svelte +++ b/src/components/Button.svelte @@ -1,7 +1,7 @@ -

Amount for {category.name}

+

Monthly amount for {category.name}

+ + - + +