(self.webpackChunkbeancount_web=self.webpackChunkbeancount_web||[]).push([[756],{5756:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>x});var a=n(1516),r=n(1896),o=n(6668),i=n(1961),c=n(2942),s=n(6694),l=n(9492),u=n(5069),d=n(9284),m=n(4760),f=n(2475),h=n(2069),p=n(712);const v={required:"${label} \u4e0d\u80fd\u4e3a\u7a7a\uff01"};class y extends d.Component{constructor(){super(...arguments),this.formRef=d.createRef(),this.state={loading:!1,checkStatus:"loading",showForm:!1,config:{}},this.checkReq=()=>{this.setState({loading:!0}),(0,m.hd)("/api/check",{method:"POST"}).then((e=>{this.setState({checkStatus:"ok"})})).catch((()=>{this.setState({checkStatus:"error"})})).finally((()=>{this.setState({loading:!1})}))},this.handleNextStep=()=>{this.setState({loading:!0}),(0,m.hd)("/api/config",{method:"GET"}).then((e=>{this.setState({config:e,showForm:!0})})).finally((()=>{this.setState({loading:!1})}))},this.handleReCheck=()=>{this.checkReq()},this.handleSubmitServerConfig=e=>{this.setState({loading:!0}),(0,m.hd)("/api/config",{method:"POST",body:e}).then((()=>{this.props.history.replace("/ledger")})).finally((()=>{this.setState({loading:!1})}))}}componentDidMount(){this.checkReq()}render(){return"error"===this.state.checkStatus?(0,p.jsxs)("div",{children:[(0,p.jsx)(a.A,{message:"\u68c0\u6d4b\u5931\u8d25",description:"\u4f9d\u8d56\u672a\u5b89\u88c5\uff0c\u8bf7\u5148\u5b89\u88c5 beancount",type:"error",showIcon:!0}),(0,p.jsx)("div",{style:{marginTop:"1rem"},children:(0,p.jsx)(r.A,{block:!0,type:"danger",loading:this.state.loading,onClick:this.handleReCheck,children:"\u91cd\u65b0\u68c0\u6d4b"})}),(0,p.jsx)("div",{style:{marginTop:"1rem"},children:(0,p.jsx)("a",{href:"https://www.yuque.com/chuyi-ble7p/beancount-ns/sqwwqa#RwqnF",target:"_blank",children:"\u600e\u4e48\u5b89\u88c5 beancount ?"})})]}):"ok"===this.state.checkStatus?this.state.showForm?(0,p.jsx)("div",{children:(0,p.jsxs)(o.A,{name:"init-form",className:"page-form",size:"middle",layout:"vertical",style:{textAlign:"left"},ref:this.formRef,onFinish:this.handleSubmitServerConfig,validateMessages:v,children:[(0,p.jsx)(o.A.Item,{label:(0,p.jsxs)(d.Fragment,{children:[(0,p.jsx)("span",{children:"\u8d26\u672c\u5b58\u50a8\u4f4d\u7f6e"}),"\xa0",(0,p.jsx)(i.A,{title:"\u5982\u679c\u662fdocker\u5bb9\u5668\u90e8\u7f72\uff0c\u6b64\u5904\u9ed8\u8ba4\u4e3a\uff1a/data/beancount",children:(0,p.jsx)(u.A,{})})]}),name:"dataPath",initialValue:this.state.config.dataPath,rules:[{required:!0}],children:(0,p.jsx)(c.A,{placeholder:"\u8d26\u672c\u5b58\u50a8\u4f4d\u7f6e"})}),(0,p.jsx)(o.A.Item,{label:"\u8d26\u672c\u5f00\u59cb\u65e5\u671f",name:"startDate",initialValue:this.state.config.startDate,rules:[{required:!0}],children:(0,p.jsx)(c.A,{type:"date",placeholder:"\u8d26\u672c\u5f00\u59cb\u65e5\u671f"})}),(0,p.jsx)(o.A.Item,{label:"\u5e01\u79cd",name:"operatingCurrency",initialValue:this.state.config.operatingCurrency,rules:[{required:!0}],children:(0,p.jsx)(c.A,{placeholder:"\u5e01\u79cd"})}),(0,p.jsx)(o.A.Item,{label:"\u5e73\u8861\u8d26\u6237\u540d\u79f0\u8bbe\u7f6e",name:"openingBalances",initialValue:this.state.config.openingBalances,rules:[{required:!0}],children:(0,p.jsx)(c.A,{placeholder:"\u5e73\u8861\u8d26\u6237\u540d\u79f0\u8bbe\u7f6e"})}),(0,p.jsx)(o.A.Item,{label:"\u4fee\u6539\u6e90\u6587\u4ef6\u65f6\u662f\u5426\u5907\u4efd\u6570\u636e",name:"isBak",valuePropName:"checked",initialValue:this.state.config.isBak,children:(0,p.jsx)(s.A,{})}),(0,p.jsx)(o.A.Item,{label:(0,p.jsxs)(d.Fragment,{children:[(0,p.jsx)("span",{children:"\u5bc6\u94a5"}),"\xa0",(0,p.jsx)(i.A,{title:"\u53ef\u4ee5\u5728\u542f\u52a8\u65e5\u5fd7\u4e2d\u67e5\u770b",children:(0,p.jsx)(u.A,{})})]}),name:"secret",rules:[{required:!0}],children:(0,p.jsx)(c.A.Password,{placeholder:"\u5bc6\u94a5"})}),(0,p.jsx)(o.A.Item,{children:(0,p.jsx)(r.A,{block:!0,type:"primary",htmlType:"submit",loading:this.state.loading,className:"submit-button",children:"\u786e\u8ba4"})})]})}):(0,p.jsxs)("div",{children:[(0,p.jsx)(a.A,{message:"\u68c0\u6d4b\u901a\u8fc7",description:"beancount\u5df2\u5b89\u88c5\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\u6765\u5b8c\u6210\u521d\u59cb\u914d\u7f6e",type:"success",showIcon:!0}),(0,p.jsx)("div",{style:{marginTop:"1rem"}}),(0,p.jsx)(r.A,{type:"primary",block:!0,onClick:this.handleNextStep,children:"\u4e0b\u4e00\u6b65"})]}):(0,p.jsx)(l.A,{tip:"Loading...",children:(0,p.jsx)(a.A,{message:"\u68c0\u6d4b\u4e2d",description:"\u6b63\u5728\u68c0\u6d4b beancount \u662f\u5426\u5df2\u5b89\u88c5",type:"info",showIcon:!0})})}}y.contextType=f.A;const x=(0,h.A)(y)},2069:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var a=n(9284),r=n(712);const o=e=>class extends a.Component{constructor(){super(...arguments),this.defaultCommodity={currency:"CNY",symbol:"\uffe5"},this.currentCommodity=window.localStorage.getItem("ledgerCurrency")}render(){return(0,r.jsx)(e,{...this.props,commodity:this.currentCommodity?JSON.parse(this.currentCommodity):this.defaultCommodity})}}},4923:(e,t,n)=>{"use strict";function a(e){return Object.keys(e).reduce((function(t,n){return!n.startsWith("data-")&&!n.startsWith("aria-")&&"role"!==n||n.startsWith("data-__")||(t[n]=e[n]),t}),{})}n.d(t,{A:()=>a})},1516:(e,t,n)=>{"use strict";n.d(t,{A:()=>M});var a=n(8168),r=n(5544),o=n(4467),i=n(9335),c=n(5185),s=n(5252),l=n(8943),u=n(5691),d=n(8994),m=n(8380),f=n(9708),h=n(8713),p=n(4480),v=n.n(p),y=n(7285),x=n(9284),g=n(3135),A=n(4923),b=n(7458),C=n(3029),N=n(2901),j=n(6822),k=n(2176),w=n(3954),E=n(5501);const O=function(e){function t(){var e,n,a,r;return(0,C.A)(this,t),n=this,a=t,r=arguments,a=(0,w.A)(a),(e=(0,j.A)(n,(0,k.A)()?Reflect.construct(a,r||[],(0,w.A)(n).constructor):a.apply(n,r))).state={error:void 0,info:{componentStack:""}},e}return(0,E.A)(t,e),(0,N.A)(t,[{key:"componentDidCatch",value:function(e,t){this.setState({error:e,info:t})}},{key:"render",value:function(){var e=this.props,t=e.message,n=e.description,a=e.children,r=this.state,o=r.error,i=r.info,c=i&&i.componentStack?i.componentStack:null,s="undefined"===typeof t?(o||"").toString():t,l="undefined"===typeof n?c:n;return o?x.createElement(M,{type:"error",message:s,description:x.createElement("pre",null,l)}):a}}]),t}(x.Component);var S=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r{"use strict";n.d(t,{A:()=>g});var a=n(8168),r=n(4467),o=n(5544),i=n(4480),c=n.n(i),s=n(3781),l=n.n(s),u=n(37),d=n(9284),m=n(3135),f=n(7458),h=n(993),p=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r{"use strict";n.d(t,{A:()=>b});var a=n(8168),r=n(4467),o=n(5547),i=n(4480),c=n.n(i),s=n(5544),l=n(45),u=n(9284),d=n(4413),m=n(6184),f=u.forwardRef((function(e,t){var n,a=e.prefixCls,o=void 0===a?"rc-switch":a,i=e.className,f=e.checked,h=e.defaultChecked,p=e.disabled,v=e.loadingIcon,y=e.checkedChildren,x=e.unCheckedChildren,g=e.onClick,A=e.onChange,b=e.onKeyDown,C=(0,l.A)(e,["prefixCls","className","checked","defaultChecked","disabled","loadingIcon","checkedChildren","unCheckedChildren","onClick","onChange","onKeyDown"]),N=(0,d.A)(!1,{value:f,defaultValue:h}),j=(0,s.A)(N,2),k=j[0],w=j[1];function E(e,t){var n=k;return p||(w(n=e),null===A||void 0===A||A(n,t)),n}var O=c()(o,i,(n={},(0,r.A)(n,"".concat(o,"-checked"),k),(0,r.A)(n,"".concat(o,"-disabled"),p),n));return u.createElement("button",Object.assign({},C,{type:"button",role:"switch","aria-checked":k,disabled:p,className:O,ref:t,onKeyDown:function(e){e.which===m.A.LEFT?E(!1,e):e.which===m.A.RIGHT&&E(!0,e),null===b||void 0===b||b(e)},onClick:function(e){var t=E(!k,e);null===g||void 0===g||g(t,e)}}),v,u.createElement("span",{className:"".concat(o,"-inner")},k?y:x))}));f.displayName="Switch";const h=f;var p=n(3135),v=n(1151),y=n(9416),x=n(8394),g=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r{var a=n(3712),r=/^\s+/;e.exports=function(e){return e?e.slice(0,a(e)+1).replace(r,""):e}},3712:e=>{var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},3781:(e,t,n)=>{var a=n(8469),r=n(5236),o=n(150),i=Math.max,c=Math.min;e.exports=function(e,t,n){var s,l,u,d,m,f,h=0,p=!1,v=!1,y=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function x(t){var n=s,a=l;return s=l=void 0,h=t,d=e.apply(a,n)}function g(e){var n=e-f;return void 0===f||n>=t||n<0||v&&e-h>=u}function A(){var e=r();if(g(e))return b(e);m=setTimeout(A,function(e){var n=t-(e-f);return v?c(n,u-(e-h)):n}(e))}function b(e){return m=void 0,y&&s?x(e):(s=l=void 0,d)}function C(){var e=r(),n=g(e);if(s=arguments,l=this,f=e,n){if(void 0===m)return function(e){return h=e,m=setTimeout(A,t),p?x(e):d}(f);if(v)return clearTimeout(m),m=setTimeout(A,t),x(f)}return void 0===m&&(m=setTimeout(A,t)),d}return t=o(t)||0,a(n)&&(p=!!n.leading,u=(v="maxWait"in n)?i(o(n.maxWait)||0,t):u,y="trailing"in n?!!n.trailing:y),C.cancel=function(){void 0!==m&&clearTimeout(m),h=0,s=f=l=m=void 0},C.flush=function(){return void 0===m?d:b(r())},C}},8469:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},5236:(e,t,n)=>{var a=n(4133);e.exports=function(){return a.Date.now()}},150:(e,t,n)=>{var a=n(5464),r=n(8469),o=n(242),i=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(o(e))return NaN;if(r(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=r(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=a(e);var n=c.test(e);return n||s.test(e)?l(e.slice(2),n?2:8):i.test(e)?NaN:+e}}}]);