From 4a0ec163c521f8e2a00d3262ca9418dc40b3e7e4 Mon Sep 17 00:00:00 2001 From: pofider Date: Fri, 15 Nov 2019 13:02:28 +0100 Subject: [PATCH] include dist --- .gitignore | 1 - dist/lib/app.js | 159 + dist/lib/app.js.map | 1 + dist/lib/docs.js | 117 + dist/lib/docs.js.map | 1 + dist/lib/payments/actions/checkout.js | 7 + dist/lib/payments/actions/checkout.js.map | 1 + dist/lib/payments/actions/dispatcher.js | 16 + dist/lib/payments/actions/dispatcher.js.map | 1 + .../payments/actions/findOrCreateCustomer.js | 20 + .../actions/findOrCreateCustomer.js.map | 1 + dist/lib/payments/braintree.js | 46 + dist/lib/payments/braintree.js.map | 1 + dist/lib/payments/braintreeHook.js | 107 + dist/lib/payments/braintreeHook.js.map | 1 + dist/lib/payments/cancelSubscription.js | 24 + dist/lib/payments/cancelSubscription.js.map | 1 + dist/lib/payments/checkout.js | 111 + dist/lib/payments/checkout.js.map | 1 + dist/lib/payments/customer.js | 74 + dist/lib/payments/customer.js.map | 1 + dist/lib/payments/emails.js | 147 + dist/lib/payments/emails.js.map | 1 + dist/lib/payments/gumroadNotification.js | 20 + dist/lib/payments/gumroadNotification.js.map | 1 + dist/lib/payments/invoiceCounter.js | 18 + dist/lib/payments/invoiceCounter.js.map | 1 + dist/lib/payments/notifyGumroad.js | 20 + dist/lib/payments/notifyGumroad.js.map | 1 + dist/lib/payments/notifyLicensingServer.js | 18 + .../lib/payments/notifyLicensingServer.js.map | 1 + dist/lib/payments/payments.js | 104 + dist/lib/payments/payments.js.map | 1 + dist/lib/payments/renderInvoice.js | 42 + dist/lib/payments/renderInvoice.js.map | 1 + dist/lib/payments/sendCustomerLink.js | 19 + dist/lib/payments/sendCustomerLink.js.map | 1 + dist/lib/payments/services.js | 3 + dist/lib/payments/services.js.map | 1 + dist/lib/payments/updatePaymentMethod.js | 38 + dist/lib/payments/updatePaymentMethod.js.map | 1 + dist/lib/payments/validateVat.js | 30 + dist/lib/payments/validateVat.js.map | 1 + dist/lib/payments/vatValidate.js | 30 + dist/lib/payments/vatValidate.js.map | 1 + dist/lib/posts.js | 73 + dist/lib/posts.js.map | 1 + dist/lib/router.js | 169 + dist/lib/router.js.map | 1 + dist/lib/utils/logger.js | 29 + dist/lib/utils/logger.js.map | 1 + dist/lib/utils/mailer.js | 37 + dist/lib/utils/mailer.js.map | 1 + dist/lib/utils/utils.js | 7 + dist/lib/utils/utils.js.map | 1 + dist/public/app.54325477.js | 617 + dist/public/app.54325477.js.map | 1 + dist/public/app.bb735868.js | 44683 ++++++++++++++++ dist/public/app.bb735868.js.map | 1 + dist/public/app.html | 1 + dist/public/checkout.69dcbd03.css | 8 + dist/public/checkout.69dcbd03.css.map | 1 + dist/public/checkout.69dcbd03.js | 396 + dist/public/checkout.69dcbd03.js.map | 1 + dist/public/checkout.808e9e20.css | 2 + dist/public/checkout.808e9e20.css.map | 1 + package.json | 2 +- 67 files changed, 47225 insertions(+), 2 deletions(-) create mode 100644 dist/lib/app.js create mode 100644 dist/lib/app.js.map create mode 100644 dist/lib/docs.js create mode 100644 dist/lib/docs.js.map create mode 100644 dist/lib/payments/actions/checkout.js create mode 100644 dist/lib/payments/actions/checkout.js.map create mode 100644 dist/lib/payments/actions/dispatcher.js create mode 100644 dist/lib/payments/actions/dispatcher.js.map create mode 100644 dist/lib/payments/actions/findOrCreateCustomer.js create mode 100644 dist/lib/payments/actions/findOrCreateCustomer.js.map create mode 100644 dist/lib/payments/braintree.js create mode 100644 dist/lib/payments/braintree.js.map create mode 100644 dist/lib/payments/braintreeHook.js create mode 100644 dist/lib/payments/braintreeHook.js.map create mode 100644 dist/lib/payments/cancelSubscription.js create mode 100644 dist/lib/payments/cancelSubscription.js.map create mode 100644 dist/lib/payments/checkout.js create mode 100644 dist/lib/payments/checkout.js.map create mode 100644 dist/lib/payments/customer.js create mode 100644 dist/lib/payments/customer.js.map create mode 100644 dist/lib/payments/emails.js create mode 100644 dist/lib/payments/emails.js.map create mode 100644 dist/lib/payments/gumroadNotification.js create mode 100644 dist/lib/payments/gumroadNotification.js.map create mode 100644 dist/lib/payments/invoiceCounter.js create mode 100644 dist/lib/payments/invoiceCounter.js.map create mode 100644 dist/lib/payments/notifyGumroad.js create mode 100644 dist/lib/payments/notifyGumroad.js.map create mode 100644 dist/lib/payments/notifyLicensingServer.js create mode 100644 dist/lib/payments/notifyLicensingServer.js.map create mode 100644 dist/lib/payments/payments.js create mode 100644 dist/lib/payments/payments.js.map create mode 100644 dist/lib/payments/renderInvoice.js create mode 100644 dist/lib/payments/renderInvoice.js.map create mode 100644 dist/lib/payments/sendCustomerLink.js create mode 100644 dist/lib/payments/sendCustomerLink.js.map create mode 100644 dist/lib/payments/services.js create mode 100644 dist/lib/payments/services.js.map create mode 100644 dist/lib/payments/updatePaymentMethod.js create mode 100644 dist/lib/payments/updatePaymentMethod.js.map create mode 100644 dist/lib/payments/validateVat.js create mode 100644 dist/lib/payments/validateVat.js.map create mode 100644 dist/lib/payments/vatValidate.js create mode 100644 dist/lib/payments/vatValidate.js.map create mode 100644 dist/lib/posts.js create mode 100644 dist/lib/posts.js.map create mode 100644 dist/lib/router.js create mode 100644 dist/lib/router.js.map create mode 100644 dist/lib/utils/logger.js create mode 100644 dist/lib/utils/logger.js.map create mode 100644 dist/lib/utils/mailer.js create mode 100644 dist/lib/utils/mailer.js.map create mode 100644 dist/lib/utils/utils.js create mode 100644 dist/lib/utils/utils.js.map create mode 100644 dist/public/app.54325477.js create mode 100644 dist/public/app.54325477.js.map create mode 100644 dist/public/app.bb735868.js create mode 100644 dist/public/app.bb735868.js.map create mode 100644 dist/public/app.html create mode 100644 dist/public/checkout.69dcbd03.css create mode 100644 dist/public/checkout.69dcbd03.css.map create mode 100644 dist/public/checkout.69dcbd03.js create mode 100644 dist/public/checkout.69dcbd03.js.map create mode 100644 dist/public/checkout.808e9e20.css create mode 100644 dist/public/checkout.808e9e20.css.map diff --git a/.gitignore b/.gitignore index 05acfc60..1fa102e8 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,6 @@ key.txt views/learn/docs/*.* .env .cache -dist test/body.txt test/signature.txt \ No newline at end of file diff --git a/dist/lib/app.js b/dist/lib/app.js new file mode 100644 index 00000000..5100bd48 --- /dev/null +++ b/dist/lib/app.js @@ -0,0 +1,159 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +require('dotenv').config(); +const express_1 = __importDefault(require("express")); +const express3_handlebars_1 = __importDefault(require("express3-handlebars")); +const router_1 = __importDefault(require("./router")); +const docs = __importStar(require("./docs")); +const docs_1 = __importDefault(require("../../views/learn/docs")); +const multer_1 = __importDefault(require("multer")); +const body_parser_1 = __importDefault(require("body-parser")); +const reap2_1 = __importDefault(require("reap2")); +const path = __importStar(require("path")); +const logger = __importStar(require("./utils/logger")); +const mongodb_1 = require("mongodb"); +const payments_1 = __importDefault(require("./payments/payments")); +const posts_1 = __importDefault(require("./posts")); +const express_rate_limit_1 = __importDefault(require("express-rate-limit")); +const app = express_1.default(); +logger.init(); +let connectionString = 'mongodb://'; +if (process.env.mongodb_username) { + connectionString += process.env.mongodb_username + ':' + process.env.mongodb_password + '@'; +} +connectionString += process.env.mongodb_address || 'localhost:27017'; +connectionString += '/' + process.env.mongodb_authdb; +const client = new mongodb_1.MongoClient(connectionString, { + useNewUrlParser: true, + useUnifiedTopology: true +}); +let db; +client.connect(err => { + if (err) { + console.error(err); + process.exit(); + } + console.log('Connected successfully to mongodb server'); + db = client.db('website'); + const payments = new payments_1.default(db); + const router = router_1.default(payments, db); + var reaper = new reap2_1.default({ threshold: 300000 }); + reaper.watch(path.join(__dirname, '../../', 'public', 'temp')); + setInterval(() => { + reaper.start((err, files) => { + if (err) { + console.error('Failed to delete temp file: ' + err); + } + }); + }, 10000).unref(); + var hbs = express3_handlebars_1.default.create({ + defaultLayout: 'main', + extname: '.html', + helpers: { + fixCoding: function (content) { + if (content.charAt(0) === '\uFEFF') { + content = content.substr(1); + } + return content; + }, + toShortDate: function (date) { + return require('moment')(date).format('MM-DD-YYYY'); + }, + toLongDate: function (date) { + return require('moment')(date).format('MM-DD-YYYY HH:mm'); + } + } + }); + app.engine('.html', hbs.engine); + // app.disable('view cache'); + app.set('view engine', '.html'); + app.use(express_1.default.static('public/')); + app.use(express_1.default.static('dist/public')); + app.use(multer_1.default({ dest: 'public/temp' })); + app.post('/gumroad', body_parser_1.default.urlencoded({ extended: true, limit: '2mb' }), (req, res) => res.send('Ok')); + app.post('/temp', function (req, res) { + function findFirstFile() { + for (var f in req.files) { + if (req.files[f]) { + return req.files[f]; + } + } + } + return res.send(require('path').basename(findFirstFile().path)); + }); + app.get('/', function (req, res) { + res.render('home', { + home: true, + title: 'js' + 'report - javascript based reporting platform', + description: 'jsreport is an open source reporting platform where reports are designed using popular javascript templating engines.' + }); + }); + app.get('/learn/dotnet', docs.dotnet); + app.get('/learn/nodejs', docs.nodejs); + app.get('/learn/templating-engines', docs.engines); + app.get('/learn/recipes', docs.recipes); + app.get('/learn/extensions', docs.extensions); + app.get('/learn/:doc', docs.doc); + app.get('/learn', docs.learn); + app.get('/examples/certificates', function (req, res) { + return res.render('examples/certificates'); + }); + app.get('/online', router.online); + app.get('/playground', router.playground); + app.get('/on-prem', router.onprem); + app.get('/about', router.about); + app.get('/downloads', router.downloads); + app.get('/embedding', router.embedding); + app.get('/buy', router.buyOnPrem); + app.get('/buy/on-prem', router.buyOnPrem); + app.get('/buy/support', router.buySupport); + app.get('/buy/online', router.buyOnline); + app.get('/buy/thank-you', router.buyThankYou); + app.get('/showcases', router.showcases); + app.post('/contact-email', body_parser_1.default.urlencoded({ extended: true, limit: '2mb' }), router.contactEmail); + posts_1.default(app).then(function (poet) { + app.get('/sitemap*', function (req, res) { + var postCount = poet.helpers.getPostCount(); + var posts = poet.helpers.getPosts(0, postCount); + res.setHeader('Content-Type', 'application/xml'); + res.render('sitemap', { + posts: posts, + layout: false, + docs: Object.keys(docs_1.default) + }); + }); + app.get('*', function (req, res) { + res.status(404).render('404'); + }); + app.listen(process.env.PORT || 3000); + }).catch(logger.error); + const limiter = express_rate_limit_1.default({ + windowMs: 10000, + max: 20 + }); + app.get('/payments/customer/:customerId/invoice/:invoiceId', limiter, router.invoice); + app.get('/payments/*', limiter, router.payments); + app.post('/api/checkout', [limiter, body_parser_1.default.json()], router.checkoutSubmit); + app.post('/api/validate-vat', [limiter, body_parser_1.default.json()], router.validateVat); + app.post('/api/customer-link', [limiter, body_parser_1.default.json()], router.customerLink); + app.get('/api/braintree-token', limiter, router.braintreeToken); + app.get('/api/customer/:id', limiter, router.customerApi); + app.delete('/api/customer/:customerId/subscription/:productId', limiter, router.cancelSubscription); + app.put('/api/customer/:customerId/subscription/:productId', [limiter, body_parser_1.default.json()], router.updatePaymentMethod); + app.post('/api/braintree/hook', [limiter, body_parser_1.default.urlencoded()], router.braintreeHook); + app.use((err, req, res, next) => { + logger.error('Error when processing ' + req.path + '; ' + err.stack); + res.status(500).send({ error: err.message }); + }); +}); +//# sourceMappingURL=app.js.map \ No newline at end of file diff --git a/dist/lib/app.js.map b/dist/lib/app.js.map new file mode 100644 index 00000000..8b7e596d --- /dev/null +++ b/dist/lib/app.js.map @@ -0,0 +1 @@ +{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/lib/app.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAA;AAC1B,sDAA6B;AAC7B,8EAAwC;AACxC,sDAA6B;AAC7B,6CAA8B;AAC9B,kEAA8C;AAC9C,oDAA2B;AAC3B,8DAAoC;AACpC,kDAA0B;AAC1B,2CAA4B;AAC5B,uDAAwC;AACxC,qCAAqC;AACrC,mEAA0C;AA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C,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/lib/docs.js b/dist/lib/docs.js new file mode 100644 index 00000000..dfbd4fb7 --- /dev/null +++ b/dist/lib/docs.js @@ -0,0 +1,117 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const docs = __importStar(require("../../views/learn/docs.js")); +const fs = __importStar(require("fs")); +const path = __importStar(require("path")); +const marked_1 = __importDefault(require("marked")); +const prismjs_1 = __importDefault(require("prismjs")); +const prism_languages_1 = __importDefault(require("prism-languages")); +let cache = {}; +function highlight(code, lang, callback) { + try { + return callback(null, prismjs_1.default.highlight(code, prism_languages_1.default[lang])); + } + catch (err) { + callback(err); + } +} +function extensions(req, res) { + res.render('learn/extensions', { learn: true }); +} +exports.extensions = extensions; +; +function dotnet(req, res) { + res.render('learn/dotnet', { learn: true }); +} +exports.dotnet = dotnet; +; +function recipes(req, res) { + res.render('learn/recipes', { learn: true }); +} +exports.recipes = recipes; +; +function nodejs(req, res) { + res.render('learn/nodejs', { learn: true }); +} +exports.nodejs = nodejs; +; +function engines(req, res) { + res.render('learn/engines', { learn: true }); +} +exports.engines = engines; +; +function learn(req, res) { + res.render('learn/learn', { learn: true, title: "Learn jsreport" }); +} +exports.learn = learn; +; +function doc(req, res) { + var filePath = path.join(__dirname, '../../', "views", "learn", "docs", req.params.doc + ".md"); + if (!fs.existsSync(filePath) || !docs[req.params.doc]) { + return res.status(404).render("404"); + } + if (cache[req.params.doc]) { + return res.render('learn/doc', cache[req.params.doc]); + } + fs.readFile(filePath, 'UTF-8', function (err, content) { + if (content.charAt(0) === '\uFEFF') + content = content.substr(1); + var renderer = new marked_1.default.Renderer(); + var toc = []; + var renderer = (function () { + var renderer = new marked_1.default.Renderer(); + renderer.heading = function (text, level, raw) { + var anchor = this.options.headerPrefix + raw.toLowerCase().replace(/[^\w]+/g, '-'); + toc.push({ + anchor: anchor, + level: level, + text: text + }); + return '' + + text + + '\n'; + }; + return renderer; + })(); + marked_1.default(content, { renderer: renderer, highlight: highlight }, function (err, html) { + var tocHTML = ''; + if (toc.length > 3 && req.params.doc !== 'faq' && req.params.doc !== 'online-faq') { + tocHTML = '
'; + tocHTML += '

table of contents

'; + tocHTML += '
'; + toc.forEach(function (entry) { + tocHTML += '
' + entry.text + '
\n'; + }); + tocHTML += '
\n'; + } + cache[req.params.doc] = { + title: docs[req.params.doc], + content: tocHTML + html, + url: "https://jsreport.net" + req.url, + id: req.params.doc, + learn: true, + linkDocCss: true + }; + res.render('learn/doc', cache[req.params.doc]); + }); + }); +} +exports.doc = doc; +; +//# sourceMappingURL=docs.js.map \ No newline at end of file diff --git a/dist/lib/docs.js.map b/dist/lib/docs.js.map new file mode 100644 index 00000000..c87c56f8 --- /dev/null +++ b/dist/lib/docs.js.map @@ -0,0 +1 @@ +{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/lib/docs.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gEAAiD;AACjD,uCAAwB;AACxB,2CAA4B;AAC5B,oDAA2B;AAC3B,sDAA2B;AAC3B,sEAAuC;AACvC,IAAI,KAAK,GAAG,EAAE,CAAC;AAEf,SAAS,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ;IACnC,IAAI;QACA,OAAO,QAAQ,CAAC,IAAI,EAAE,iBAAK,CAAC,SAAS,CAAC,IAAI,EAAE,yBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjE;IAAC,OAAO,GAAG,EAAE;QACV,QAAQ,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,CAAC,CAAC,CAAC;AACP,CAAC;AAhED,kBAgEC;AAAA,CAAC"} \ No newline at end of file diff --git a/dist/lib/payments/actions/checkout.js b/dist/lib/payments/actions/checkout.js new file mode 100644 index 00000000..95a50050 --- /dev/null +++ b/dist/lib/payments/actions/checkout.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const findOrCreateCustomer_1 = require("./findOrCreateCustomer"); +exports.CheckoutAction = async (context, checkoutRequest) => { + const cutomer = await context.dispatcher.dispatch(findOrCreateCustomer_1.findOrCreateCustomer, context, checkoutRequest.email); +}; +//# sourceMappingURL=checkout.js.map \ No newline at end of file diff --git a/dist/lib/payments/actions/checkout.js.map b/dist/lib/payments/actions/checkout.js.map new file mode 100644 index 00000000..c2ac1f27 --- /dev/null +++ b/dist/lib/payments/actions/checkout.js.map @@ -0,0 +1 @@ +{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../../../src/lib/payments/actions/checkout.ts"],"names":[],"mappings":";;AAEA,iEAA8D;AAIjD,QAAA,cAAc,GAAG,KAAK,EAAE,OAAwB,EAAE,eAAgC,EAAE,EAAE;IAC/F,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,2CAAoB,EAAE,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC,CAAA;AAE3G,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/lib/payments/actions/dispatcher.js b/dist/lib/payments/actions/dispatcher.js new file mode 100644 index 00000000..2a8d7737 --- /dev/null +++ b/dist/lib/payments/actions/dispatcher.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +class DispatchContext { + constructor(services, dispatcher) { + this.services = services; + this.dispatcher = dispatcher; + } +} +exports.DispatchContext = DispatchContext; +class Dispatcher { + dispatch(fn, context, ...args) { + return fn(context, ...args); + } +} +exports.Dispatcher = Dispatcher; +//# sourceMappingURL=dispatcher.js.map \ No newline at end of file diff --git a/dist/lib/payments/actions/dispatcher.js.map b/dist/lib/payments/actions/dispatcher.js.map new file mode 100644 index 00000000..e554f439 --- /dev/null +++ b/dist/lib/payments/actions/dispatcher.js.map @@ -0,0 +1 @@ +{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../../../src/lib/payments/actions/dispatcher.ts"],"names":[],"mappings":";;AAEA,MAAa,eAAe;IAIxB,YAAY,QAAkB,EAAE,UAAsB;QAClD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAChC,CAAC;CACJ;AARD,0CAQC;AAED,MAAa,UAAU;IACnB,QAAQ,CAAC,EAA8C,EAAE,OAAwB,EAAE,GAAG,IAAI;QACtF,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;IAC/B,CAAC;CACJ;AAJD,gCAIC"} \ No newline at end of file diff --git a/dist/lib/payments/actions/findOrCreateCustomer.js b/dist/lib/payments/actions/findOrCreateCustomer.js new file mode 100644 index 00000000..92c60cba --- /dev/null +++ b/dist/lib/payments/actions/findOrCreateCustomer.js @@ -0,0 +1,20 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const nanoid_1 = __importDefault(require("nanoid")); +exports.findOrCreateCustomer = async (context, email) => { + let customer = await context.services.db.collection('customers').findOne({ email }); + if (customer) { + return customer; + } + customer = { + email, + uuid: nanoid_1.default(16), + creationDate: new Date() + }; + await this.db.collection('customers').insertOne(customer); + return customer; +}; +//# sourceMappingURL=findOrCreateCustomer.js.map \ No newline at end of file diff --git a/dist/lib/payments/actions/findOrCreateCustomer.js.map b/dist/lib/payments/actions/findOrCreateCustomer.js.map new file mode 100644 index 00000000..a3ca4561 --- /dev/null +++ b/dist/lib/payments/actions/findOrCreateCustomer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"findOrCreateCustomer.js","sourceRoot":"","sources":["../../../../src/lib/payments/actions/findOrCreateCustomer.ts"],"names":[],"mappings":";;;;;AAAA,oDAA2B;AAId,QAAA,oBAAoB,GAAG,KAAK,EAAE,OAAwB,EAAE,KAAa,EAAE,EAAE;IAClF,IAAI,QAAQ,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IAEnF,IAAI,QAAQ,EAAE;QACV,OAAiB,QAAQ,CAAA;KAC5B;IAED,QAAQ,GAAG;QACP,KAAK;QACL,IAAI,EAAE,gBAAM,CAAC,EAAE,CAAC;QAChB,YAAY,EAAE,IAAI,IAAI,EAAE;KAC3B,CAAA;IAED,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IAEzD,OAAiB,QAAQ,CAAA;AAC7B,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/lib/payments/braintree.js b/dist/lib/payments/braintree.js new file mode 100644 index 00000000..b0831ab9 --- /dev/null +++ b/dist/lib/payments/braintree.js @@ -0,0 +1,46 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const braintree = __importStar(require("braintree")); +class Braintree { + constructor() { + this._gateway = new braintree.BraintreeGateway({ + environment: braintree.Environment.Sandbox, + merchantId: process.env.BRAINTREE_MERCHANT_ID, + publicKey: process.env.BRAINTREE_PUBLIC_KEY, + privateKey: process.env.BRAINTREE_PRIVATE_KEY + }); + } + generateToken() { + return this._gateway.clientToken.generate({}).then(r => r.clientToken); + } + createCustomer(obj) { + return this._gateway.customer.create(obj); + } + createPaymentMethod(obj) { + return this._gateway.paymentMethod.create(obj); + } + createSubscription(obj) { + return this._gateway.subscription.create(obj); + } + createSale(obj) { + return this._gateway.transaction.sale(obj); + } + updateSubscription(id, obj) { + return this._gateway.subscription.update(id, obj); + } + cancelSubscription(obj) { + return this._gateway.subscription.cancel(obj); + } + parseWebHook(signature, obj) { + return this._gateway.webhookNotification.parse(signature, obj); + } +} +exports.default = Braintree; +//# sourceMappingURL=braintree.js.map \ No newline at end of file diff --git a/dist/lib/payments/braintree.js.map b/dist/lib/payments/braintree.js.map new file mode 100644 index 00000000..eb8f74db --- /dev/null +++ b/dist/lib/payments/braintree.js.map @@ -0,0 +1 @@ +{"version":3,"file":"braintree.js","sourceRoot":"","sources":["../../../src/lib/payments/braintree.ts"],"names":[],"mappings":";;;;;;;;;AAAA,qDAAsC;AAEtC,MAAqB,SAAS;IAG5B;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,SAAS,CAAC,gBAAgB,CAAC;YAC7C,WAAW,EAAE,SAAS,CAAC,WAAW,CAAC,OAAO;YAC1C,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;YAC7C,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB;YAC3C,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;SAC9C,CAAC,CAAA;IACJ,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;IACxE,CAAC;IAED,cAAc,CAAC,GAAG;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC3C,CAAC;IAED,mBAAmB,CAAC,GAAyC;QAC3D,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAChD,CAAC;IAED,kBAAkB,CAAC,GAAG;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC/C,CAAC;IAED,UAAU,CAAC,GAAG;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC5C,CAAC;IAED,kBAAkB,CAAC,EAAU,EAAE,GAAkC;QAC/D,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;IACnD,CAAC;IAED,kBAAkB,CAAC,GAAG;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC/C,CAAC;IAED,YAAY,CAAC,SAAS,EAAE,GAAG;QACzB,OAAa,IAAI,CAAC,QAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;IACvE,CAAC;CACF;AA3CD,4BA2CC"} \ No newline at end of file diff --git a/dist/lib/payments/braintreeHook.js b/dist/lib/payments/braintreeHook.js new file mode 100644 index 00000000..09eb43ba --- /dev/null +++ b/dist/lib/payments/braintreeHook.js @@ -0,0 +1,107 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const logger = __importStar(require("../utils/logger")); +const utils_1 = require("../utils/utils"); +const emails_1 = require("./emails"); +function braintreeHook(services) { + async function processSubscriptionChargeNotif(subscription) { + logger.info('Search for customer with subscription id ' + subscription.id); + const customer = await services.customerRepository.findBySubscription(subscription.id); + if (!customer) { + throw Error('Unable to find customer with subscription'); + } + logger.info('Processing subscription successful charge notification for customer ' + customer.email); + const product = customer.products.find(p => p.braintree.subscription && p.braintree.subscription.id === subscription.id); + product.braintree.subscription = subscription; + const sale = await services.customerRepository.createSale(product.accountingData); + await services.renderInvoice(sale); + product.sales.push(sale); + await services.customerRepository.update(customer); + await services.notifyLicensingServer(customer, product, sale); + await services.sendEmail({ + to: customer.email, + content: utils_1.interpolate(emails_1.Emails.recurring.customer.content, { customer, product, sale }), + subject: utils_1.interpolate(emails_1.Emails.recurring.customer.subject, { customer, product, sale }), + }); + await services.sendEmail({ + to: 'jan.blaha@jsreport.net', + content: utils_1.interpolate(emails_1.Emails.recurring.us.content, { customer, product, sale }), + subject: utils_1.interpolate(emails_1.Emails.recurring.us.subject, { customer, product, sale }), + }); + } + async function processSubscriptionFailedChargeNotif(subscription) { + logger.info('Search for customer with subscription id ' + subscription.id); + const customer = await services.customerRepository.findBySubscription(subscription.id); + if (!customer) { + throw Error('Unable to find customer with subscription'); + } + logger.info('Processing subscription failed charge notification for customer ' + customer.email); + const product = customer.products.find(p => p.braintree.subscription && p.braintree.subscription.id === subscription.id); + product.braintree.subscription = subscription; + await services.customerRepository.update(customer); + await services.sendEmail({ + to: customer.email, + content: utils_1.interpolate(emails_1.Emails.recurringFail.customer.content, { customer, product }), + subject: utils_1.interpolate(emails_1.Emails.recurringFail.customer.subject, { customer, product }), + }); + await services.sendEmail({ + to: 'jan.blaha@jsreport.net', + content: utils_1.interpolate(emails_1.Emails.recurringFail.us.content, { customer, product }), + subject: utils_1.interpolate(emails_1.Emails.recurringFail.us.subject, { customer, product }), + }); + } + async function processSubscriptionCanceledNotif(subscription) { + logger.info('Search for customer with subscription id ' + subscription.id); + const customer = await services.customerRepository.findBySubscription(subscription.id); + if (!customer) { + throw Error('Unable to find customer with subscription'); + } + logger.info('Processing subscription canceled notification for customer ' + customer.email); + const product = customer.products.find(p => p.braintree.subscription && p.braintree.subscription.id === subscription.id); + if (product.braintree.subscription.status !== 'Active') { + logger.info('Subscription already canceled, skipping'); + return; + } + product.braintree.subscription = subscription; + await services.customerRepository.update(customer); + await services.sendEmail({ + to: customer.email, + content: utils_1.interpolate(emails_1.Emails.recurringCancel.customer.content, { customer, product }), + subject: utils_1.interpolate(emails_1.Emails.recurringCancel.customer.subject, { customer, product }), + }); + await services.sendEmail({ + to: 'jan.blaha@jsreport.net', + content: utils_1.interpolate(emails_1.Emails.recurringCancel.us.content, { customer, product }), + subject: utils_1.interpolate(emails_1.Emails.recurringCancel.us.subject, { customer, product }), + }); + } + return async function (signature, body) { + const webhookNotification = await services.braintree.parseWebHook(signature, body); + logger.info('processing braintree hook of kind ' + webhookNotification.kind); + try { + switch (webhookNotification.kind) { + case 'subscription_charged_successfully': + return processSubscriptionChargeNotif(webhookNotification.subscription); + case 'subscription_charged_unsuccessfully': + return processSubscriptionFailedChargeNotif(webhookNotification.subscription); + case 'subscription_canceled': + return processSubscriptionCanceledNotif(webhookNotification.subscription); + default: + logger.info('skip processing ' + webhookNotification.kind); + } + } + catch (e) { + logger.error('Critical error when processing braintree hook', e); + throw e; + } + }; +} +exports.braintreeHook = braintreeHook; +//# sourceMappingURL=braintreeHook.js.map \ No newline at end of file diff --git a/dist/lib/payments/braintreeHook.js.map b/dist/lib/payments/braintreeHook.js.map new file mode 100644 index 00000000..8bc53f5a --- /dev/null +++ b/dist/lib/payments/braintreeHook.js.map @@ -0,0 +1 @@ +{"version":3,"file":"braintreeHook.js","sourceRoot":"","sources":["../../../src/lib/payments/braintreeHook.ts"],"names":[],"mappings":";;;;;;;;;AAAA,wDAAyC;AAEzC,0CAA4C;AAC5C,qCAAiC;AAGjC,SAAgB,aAAa,CAAC,QAAkB;IAC5C,KAAK,UAAU,8BAA8B,CAAC,YAAY;QACtD,MAAM,CAAC,IAAI,CAAC,2CAA2C,GAAG,YAAY,CAAC,EAAE,CAAC,CAAA;QAC1E,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA;QAEtF,IAAI,CAAC,QAAQ,EAAE;YACX,MAAM,KAAK,CAAC,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,EAAE;YACR,MAAM,CAAC,KAAK,CAAC,+CAA+C,EAAE,CAAC,CAAC,CAAA;YAChE,MAAM,CAAC,CAAA;SACV;IACL,CAAC,CAAA;AACL,CAAC;AAlHD,sCAkHC"} \ No newline at end of file diff --git a/dist/lib/payments/cancelSubscription.js b/dist/lib/payments/cancelSubscription.js new file mode 100644 index 00000000..e05d4abf --- /dev/null +++ b/dist/lib/payments/cancelSubscription.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const emails_1 = require("./emails"); +const utils_1 = require("../utils/utils"); +exports.cancelSubscription = (services) => async (customerId, productId) => { + const customer = await services.customerRepository.find(customerId); + const product = customer.products.find(p => p.id === productId); + await services.braintree.cancelSubscription(product.braintree.subscription.id); + product.braintree.subscription.status = 'Canceled'; + Object.assign(customer.products.find(p => p.id === productId), product); + await services.customerRepository.update(customer); + const mail = product.isSupport ? emails_1.Emails.cancel.support : emails_1.Emails.cancel.enterprise; + await services.sendEmail({ + to: customer.email, + content: utils_1.interpolate(mail.customer.content, { customer, product }), + subject: utils_1.interpolate(mail.customer.subject, { customer, product }), + }); + await services.sendEmail({ + to: 'jan.blaha@jsreport.net', + content: utils_1.interpolate(mail.us.content, { customer, product }), + subject: utils_1.interpolate(mail.us.subject, { customer, product }), + }); +}; +//# sourceMappingURL=cancelSubscription.js.map \ No newline at end of file diff --git a/dist/lib/payments/cancelSubscription.js.map b/dist/lib/payments/cancelSubscription.js.map new file mode 100644 index 00000000..5b9aefd5 --- /dev/null +++ b/dist/lib/payments/cancelSubscription.js.map @@ -0,0 +1 @@ +{"version":3,"file":"cancelSubscription.js","sourceRoot":"","sources":["../../../src/lib/payments/cancelSubscription.ts"],"names":[],"mappings":";;AACA,qCAAiC;AACjC,0CAA4C;AAE/B,QAAA,kBAAkB,GAAG,CAAC,QAAkB,EAAE,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE;IACtF,MAAM,QAAQ,GAAG,MAA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,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;KAC/D,CAAC,CAAA;AACN,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/lib/payments/checkout.js b/dist/lib/payments/checkout.js new file mode 100644 index 00000000..9d463f76 --- /dev/null +++ b/dist/lib/payments/checkout.js @@ -0,0 +1,111 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const logger = __importStar(require("../utils/logger")); +const v4_1 = __importDefault(require("uuid/v4")); +const nanoid_1 = __importDefault(require("nanoid")); +const emails_1 = require("./emails"); +const utils_1 = require("../utils/utils"); +const uuid = () => v4_1.default().toUpperCase(); +// the mock less solution is likely to fire just some events from the checkout script +// like { action: 'sendEmail', data: { subject: '...' }} +exports.checkout = (services) => async (checkoutData) => { + logger.info('Processing checkout ' + JSON.stringify(checkoutData)); + const customer = await services.customerRepository.findOrCreate(checkoutData.email); + let productBraintree = {}; + if (checkoutData.product.isSubscription) { + if (customer.braintree == null) { + const customerRes = await services.braintree.createCustomer({ + company: checkoutData.name, + email: checkoutData.email + }); + if (customerRes.success === false) { + throw new Error('Unable to create customer: ' + customerRes.message); + } + customer.braintree = { customerId: customerRes.customer.id }; + } + const pmr = await services.braintree.createPaymentMethod({ + customerId: customer.braintree.customerId, + paymentMethodNonce: checkoutData.nonce, + options: { + verifyCard: true + } + }); + if (pmr.success === false) { + throw new Error('Unable to register payment method: ' + pmr.message); + } + const sr = await services.braintree.createSubscription({ + paymentMethodToken: pmr.paymentMethod.token, + planId: checkoutData.product.code + (checkoutData.vatRate !== 0 ? 'VAT' : ''), + merchantAccountId: 'jsreportusd' + }); + if (sr.success === false) { + throw new Error('Unable to create subscription ' + sr.message); + } + productBraintree.paymentMethod = pmr.paymentMethod; + productBraintree.subscription = sr.subscription; + } + else { + await services.braintree.createSale({ + amount: checkoutData.amount, + paymentMethodNonce: checkoutData.nonce, + options: { + submitForSettlement: true + } + }); + } + const accountingData = { + address: checkoutData.address, + amount: checkoutData.amount, + country: checkoutData.country, + currency: checkoutData.currency, + isEU: checkoutData.isEU, + name: checkoutData.name, + price: checkoutData.price, + vatAmount: checkoutData.vatAmount, + vatNumber: checkoutData.vatNumber, + vatRate: checkoutData.vatRate, + item: checkoutData.product.name + }; + const product = { + code: checkoutData.product.code, + permalink: checkoutData.product.permalink, + isSubscription: checkoutData.product.isSubscription, + name: checkoutData.product.name, + isSupport: checkoutData.product.isSupport, + id: nanoid_1.default(4), + sales: [], + braintree: productBraintree, + accountingData, + licenseKey: checkoutData.product.isSupport ? null : uuid() + }; + const sale = await services.customerRepository.createSale(accountingData); + await services.renderInvoice(sale); + product.sales.push(sale); + await services.notifyLicensingServer(customer, product, product.sales[0]); + customer.products = customer.products || []; + customer.products.push(product); + await services.customerRepository.update(customer); + const mail = product.isSupport ? emails_1.Emails.checkout.support : emails_1.Emails.checkout.enterprise; + await services.sendEmail({ + to: customer.email, + content: utils_1.interpolate(mail.customer.content, { customer, product, sale: product.sales[0] }), + subject: utils_1.interpolate(mail.customer.subject, { customer, product, sale: product.sales[0] }), + }); + await services.sendEmail({ + to: 'jan.blaha@jsreport.net', + content: utils_1.interpolate(mail.us.content, { customer, product }), + subject: utils_1.interpolate(mail.us.subject, { customer, product }), + }); + return customer; +}; +//# sourceMappingURL=checkout.js.map \ No newline at end of file diff --git a/dist/lib/payments/checkout.js.map b/dist/lib/payments/checkout.js.map new file mode 100644 index 00000000..ae9aa8c9 --- /dev/null +++ b/dist/lib/payments/checkout.js.map @@ -0,0 +1 @@ +{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../../src/lib/payments/checkout.ts"],"names":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,CAAC,CAAC,eAAM,CAAC,QAAQ,CAAC,UAAU,CAAA;IAErF,MAAM,QAAQ,CAAC,SAAS,CAAC;QACrB,EAAE,EAAE,QAAQ,CAAC,KAAK;QAClB,OAAO,EAAE,mBAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1F,OAAO,EAAE,mBAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7F,CAAC,CAAA;IAEF,MAAM,QAAQ,CAAC,SAAS,CAAC;QACrB,EAAE,EAAE,wBAAwB;QAC5B,OAAO,EAAE,mBAAW,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;QAC5D,OAAO,EAAE,mBAAW,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;KAC/D,CAAC,CAAA;IAEF,OAAO,QAAQ,CAAA;AACnB,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/lib/payments/customer.js b/dist/lib/payments/customer.js new file mode 100644 index 00000000..b9e68a0e --- /dev/null +++ b/dist/lib/payments/customer.js @@ -0,0 +1,74 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const nanoid_1 = __importDefault(require("nanoid")); +class CustomerRepository { + constructor(db) { + this.db = db; + } + async find(customerId) { + const customer = await this.db.collection('customers').findOne({ uuid: customerId }); + if (!customer) { + throw new Error('Customer not found'); + } + return customer; + } + async findByEmail(email) { + const customer = await this.db.collection('customers').findOne({ email }); + if (!customer) { + throw new Error('Customer not found'); + } + return customer; + } + async findOrCreate(email) { + let customer = await this.db.collection('customers').findOne({ email }); + if (customer) { + return customer; + } + customer = { + email, + uuid: nanoid_1.default(16), + creationDate: new Date() + }; + await this.db.collection('customers').insertOne(customer); + return customer; + } + async update(customer) { + return this.db.collection('customers').updateOne({ _id: customer._id }, { $set: { ...customer } }); + } + async findSale(customerId, saleId) { + const customer = await this.find(customerId); + const sale = Array.prototype.concat(...customer.products.map(p => p.sales)).find(s => s.id === saleId); + if (!sale) { + throw new Error(`Invoice ${saleId} not found`); + } + return sale; + } + async findBySubscription(subscriptionId) { + const customer = await this.db.collection('customers').findOne({ products: { $elemMatch: { 'braintree.subscription.id': subscriptionId } } }); + return customer; + } + async createSale(data) { + await this.db.collection('invoiceCounter').updateOne({}, { + $inc: { + nextId: 1 + } + }); + let counter = await this.db.collection('invoiceCounter').findOne({}); + if (counter == null) { + counter = { nextId: 1 }; + } + const id = `${new Date().getFullYear()}-${counter.nextId}B`; + const sale = { + accountingData: data, + id: id, + blobName: `${id}.pdf`, + purchaseDate: new Date() + }; + return sale; + } +} +exports.CustomerRepository = CustomerRepository; +//# sourceMappingURL=customer.js.map \ No newline at end of file diff --git a/dist/lib/payments/customer.js.map b/dist/lib/payments/customer.js.map new file mode 100644 index 00000000..12eb90c4 --- /dev/null +++ b/dist/lib/payments/customer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"customer.js","sourceRoot":"","sources":["../../../src/lib/payments/customer.ts"],"names":[],"mappings":";;;;;AACA,oDAA2B;AAyD3B,MAAa,kBAAkB;IAG3B,YAAY,EAAM;QACd,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;IAChB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,UAAU;QACjB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;QACpF,IAAI,C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ACN,QAAQ,EAAE,GAAG,EAAE,MAAM;YACrB,YAAY,EAAE,IAAI,IAAI,EAAE;SAC3B,CAAA;QAED,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAxFD,gDAwFC"} \ No newline at end of file diff --git a/dist/lib/payments/emails.js b/dist/lib/payments/emails.js new file mode 100644 index 00000000..8dd56bb1 --- /dev/null +++ b/dist/lib/payments/emails.js @@ -0,0 +1,147 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Emails = { + checkout: { + enterprise: { + us: { + subject: 'New sale ${product.name}', + content: '${customer.email}' + }, + customer: { + subject: 'You bought ${product.name}', + content: `Hi,
+thank you for purchasing \${product.name}.
+
+Your license key is:
+\${product.licenseKey}
+
+Please see how you can apply the license key here:
+https://jsreport.net/learn/faq#how-to-apply-license-key
+
+The invoice can be downloaded from your customer portal
+https://jsreport.net/payments/customer/\${customer.uuid}
+
+Please download and read the end user license agreement:
+http://jsreport.net/terms-of-use-commercial.txt
+
+Thank you
+jsreport team +` + } + }, + support: { + us: { + subject: 'New sale ${product.name}', + content: '${customer.email}' + }, + customer: { + subject: 'You bought ${product.name}', + content: `Hi,
+thank for purchasing the jsreport support.
+
+Please register to the support portal https://support.jsreport.net and follow the instructions.
+
+You can also use email support@jsreport.net for support questions and incidents.
+However, the support portal is the preferred way to contact us.
+Please always mention your're support subscriber in case you decide to use the email.
+
+The invoice can be downloaded from your customer portal
+https://jsreport.net/payments/customer/\${customer.uuid}
+
+Thank you
+jsreport team +` + } + } + }, + cancel: { + enterprise: { + us: { + subject: '${product.name} canceled', + content: '${customer.email}' + }, + customer: { + subject: '${product.name} canceled', + content: `Hi,
+your \${product.name} has been canceled.
+You can continue using the license key until the end of the period.
+Since then the license key becomes invalid and server instances using it won't start.
+
+jsreport team +` + } + }, + support: { + us: { + subject: '${product.name} canceled', + content: '${customer.email}' + }, + customer: { + subject: '${product.name} canceled', + content: `Hi,
+your \${product.name} has been canceled.
+
+jsreport team +` + } + } + }, + recurring: { + us: { + subject: '${product.name} successful recurring charge', + content: '\${customer.email}' + }, + customer: { + subject: '${product.name} renewal successful', + content: `Hi,
+your \${product.name} was successfuly renewed.
+
+The invoice can be downloaded from your customer portal
+https://jsreport.net/payments/customer/\${customer.uuid}
+
+Thank you for using jsreport
+jsreport team` + } + }, + recurringFail: { + us: { + subject: '${product.name} renewal charge unsuccessful', + content: '${customer.email}' + }, + customer: { + subject: '${product.name} renewal charge unsuccessful', + content: `Hi,
+we weren't able to charge your bank card for \${product.name} renewal.
+
+Please verify your bank credentials.
+https://jsreport.net/payments/customer/\${customer.uuid}/product/\${product.id}
+
+We will automatically try to charge the card again in the three days before the subscription gets canceled.
+
+jsreport team` + } + }, + recurringCancel: { + us: { + subject: '${product.name} canceled because of failed payments', + content: `\${customer.email} ` + }, + customer: { + subject: '${product.name} canceled because of failed payments', + content: `Hi,
+\${product.name} was canceled because of multiple failed payments.
+
+jsreport team` + } + }, + customerLink: { + subject: 'jsreport customer dashboard link', + content: `Hi,
+you requested link to your jsreport customer dashboard. Here it is

+https://jsreport.net/payments/customer/\${customer.uuid}
+
+jsreport team + ` + } +}; +//# sourceMappingURL=emails.js.map \ No newline at end of file diff --git a/dist/lib/payments/emails.js.map b/dist/lib/payments/emails.js.map new file mode 100644 index 00000000..d991a7ff --- /dev/null +++ b/dist/lib/payments/emails.js.map @@ -0,0 +1 @@ +{"version":3,"file":"emails.js","sourceRoot":"","sources":["../../../src/lib/payments/emails.ts"],"names":[],"mappings":";;AAAa,QAAA,MAAM,GAAG;IAClB,QAAQ,EAAE;QACN,UAAU,EAAE;YACR,EAAE,EAAE;gBACA,OAAO,EAAE,0BAA0B;gBACnC,OAAO,EAAE,mBAAmB;aAC/B;YACD,QAAQ,EAAE;gBACN,OAAO,EAAE,4BAA4B;gBACrC,OAAO,EAAE;;;;;;;;;;;;;;;;;CAiBxB;aAAa;SACL;QACD,OAAO,EAAE;YACL,EAAE,EAAE;gBACA,OAAO,EAAE,0BAA0B;gBACnC,OAAO,EAAE,mBAAmB;aAC/B;YACD,QAAQ,EAAE;gBACN,OAAO,EAAE,4BAA4B;gBACrC,OAAO,EAAE;;;;;;;;;;;;;;CAcxB;aACY;SACJ;KACJ;IACD,MAAM,EAAE;QACJ,UAAU,EAAE;YACR,EAAE,EAAE;gBACA,OAAO,EAAE,0BAA0B;gBACnC,OAAO,EAAE,mBAAmB;aAC/B;YACD,QAAQ,EAAE;gBACN,OAAO,EAAE,0BAA0B;gBACnC,OAAO,EAAE;;;;;;CAMxB;aACY;SACJ;QACD,OAAO,EAAE;YACL,EAAE,EAAE;gBACA,OAAO,EAAE,0BAA0B;gBACnC,OAAO,EAAE,mBAAmB;aAC/B;YACD,QAAQ,EAAE;gBACN,OAAO,EAAE,0BAA0B;gBACnC,OAAO,EAAE;;;;CAIxB;aACY;SACJ;KACJ;IACD,SAAS,EAAE;QACP,EAAE,EAAE;YACA,OAAO,EAAE,6CAA6C;YACtD,OAAO,EAAE,oBAAoB;SAChC;QACD,QAAQ,EAAE;YACN,OAAO,EAAE,oCAAoC;YAC7C,OAAO,EAAE;;;;;;;cAOP;SACL;KACJ;IACD,aAAa,EAAE;QACX,EAAE,EAAE;YACA,OAAO,EAAE,6CAA6C;YACtD,OAAO,EAAE,mBAAmB;SAC/B;QACD,QAAQ,EAAE;YACN,OAAO,EAAE,6CAA6C;YACtD,OAAO,EAAE;;;;;;;;cAQP;SACL;KACJ;IACD,eAAe,EAAE;QACb,EAAE,EAAE;YACA,OAAO,EAAE,qDAAqD;YAC9D,OAAO,EAAE,qBAAqB;SACjC;QACD,QAAQ,EAAE;YACN,OAAO,EAAE,qDAAqD;YAC9D,OAAO,EAAE;;;cAGP;SACL;KACJ;IACD,YAAY,EAAE;QACV,OAAO,EAAE,kCAAkC;QAC3C,OAAO,EAAE;;;;;SAKR;KACJ;CACJ,CAAA"} \ No newline at end of file diff --git a/dist/lib/payments/gumroadNotification.js b/dist/lib/payments/gumroadNotification.js new file mode 100644 index 00000000..85fe5a9e --- /dev/null +++ b/dist/lib/payments/gumroadNotification.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function default_1(axios) { + return function (paymentInfo) { + return axios.post('https://jsreportonline.net/gumroad-hook', { + email: paymentInfo.email, + purchaseDate: paymentInfo.purchaseDate, + customer: paymentInfo.customer, + price: paymentInfo.amount, + currency: paymentInfo.currency, + invoiceId: paymentInfo.invoiceId, + license_key: paymentInfo.license_key, + braintree: true, + product_name: paymentInfo.product.name, + permalink: paymentInfo.product.permalink + }); + }; +} +exports.default = default_1; +//# sourceMappingURL=gumroadNotification.js.map \ No newline at end of file diff --git a/dist/lib/payments/gumroadNotification.js.map b/dist/lib/payments/gumroadNotification.js.map new file mode 100644 index 00000000..bee9bdd9 --- /dev/null +++ b/dist/lib/payments/gumroadNotification.js.map @@ -0,0 +1 @@ +{"version":3,"file":"gumroadNotification.js","sourceRoot":"","sources":["../../../src/lib/payments/gumroadNotification.ts"],"names":[],"mappings":";;AAAA,mBAAyB,KAAK;IAC1B,OAAO,UAAU,WAAW;QACxB,OAAO,KAAK,CAAC,IAAI,CAAC,yCAAyC,EAAE;YACzD,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,YAAY,EAAE,WAAW,CAAC,YAAY;YACtC,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,KAAK,EAAE,WAAW,CAAC,MAAM;YACzB,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,SAAS,EAAE,WAAW,CAAC,SAAS;YAChC,WAAW,EAAE,WAAW,CAAC,WAAW;YACpC,SAAS,EAAE,IAAI;YACf,YAAY,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI;YACtC,SAAS,EAAE,WAAW,CAAC,OAAO,CAAC,SAAS;SAC3C,CAAC,CAAA;IACN,CAAC,CAAA;AACL,CAAC;AAfD,4BAeC"} \ No newline at end of file diff --git a/dist/lib/payments/invoiceCounter.js b/dist/lib/payments/invoiceCounter.js new file mode 100644 index 00000000..6310cb50 --- /dev/null +++ b/dist/lib/payments/invoiceCounter.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function default_1(db) { + return async function () { + await db.collection('invoiceCounter').updateOne({}, { + $inc: { + nextId: 1 + } + }); + let counter = await db.collection('invoiceCounter').findOne({}); + if (counter == null) { + counter = { nextId: 1 }; + } + return `${new Date().getFullYear()}-${counter.nextId}B`; + }; +} +exports.default = default_1; +//# sourceMappingURL=invoiceCounter.js.map \ No newline at end of file diff --git a/dist/lib/payments/invoiceCounter.js.map b/dist/lib/payments/invoiceCounter.js.map new file mode 100644 index 00000000..bd04bc52 --- /dev/null +++ b/dist/lib/payments/invoiceCounter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"invoiceCounter.js","sourceRoot":"","sources":["../../../src/lib/payments/invoiceCounter.ts"],"names":[],"mappings":";;AAEA,mBAAyB,EAAM;IAC3B,OAAO,KAAK;QACR,MAAM,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,SAAS,CAC3C,EAAE,EACF;YACI,IAAI,EAAE;gBACF,MAAM,EAAE,CAAC;aACZ;SACJ,CACJ,CAAA;QACD,IAAI,OAAO,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAC/D,IAAI,OAAO,IAAI,IAAI,EAAE;YACjB,OAAO,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAA;SAC1B;QAED,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAA;IAC3D,CAAC,CAAA;AACL,CAAC;AAjBD,4BAiBC"} \ No newline at end of file diff --git a/dist/lib/payments/notifyGumroad.js b/dist/lib/payments/notifyGumroad.js new file mode 100644 index 00000000..15dd1ce7 --- /dev/null +++ b/dist/lib/payments/notifyGumroad.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function default_1(axios) { + return function (paymentInfo) { + return axios.post('https://jsreportonline.net/gumroad-hook', { + email: paymentInfo.email, + purchaseDate: paymentInfo.purchaseDate, + customer: paymentInfo.customer, + price: paymentInfo.amount, + currency: paymentInfo.currency, + invoiceId: paymentInfo.invoiceId, + license_key: paymentInfo.license_key, + braintree: true, + product_name: paymentInfo.product.name, + permalink: paymentInfo.product.permalink + }); + }; +} +exports.default = default_1; +//# sourceMappingURL=notifyGumroad.js.map \ No newline at end of file diff --git a/dist/lib/payments/notifyGumroad.js.map b/dist/lib/payments/notifyGumroad.js.map new file mode 100644 index 00000000..48f9b726 --- /dev/null +++ b/dist/lib/payments/notifyGumroad.js.map @@ -0,0 +1 @@ +{"version":3,"file":"notifyGumroad.js","sourceRoot":"","sources":["../../../src/lib/payments/notifyGumroad.ts"],"names":[],"mappings":";;AAAA,mBAAyB,KAAK;IAC1B,OAAO,UAAU,WAAW;QACxB,OAAO,KAAK,CAAC,IAAI,CAAC,yCAAyC,EAAE;YACzD,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,YAAY,EAAE,WAAW,CAAC,YAAY;YACtC,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,KAAK,EAAE,WAAW,CAAC,MAAM;YACzB,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,SAAS,EAAE,WAAW,CAAC,SAAS;YAChC,WAAW,EAAE,WAAW,CAAC,WAAW;YACpC,SAAS,EAAE,IAAI;YACf,YAAY,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI;YACtC,SAAS,EAAE,WAAW,CAAC,OAAO,CAAC,SAAS;SAC3C,CAAC,CAAA;IACN,CAAC,CAAA;AACL,CAAC;AAfD,4BAeC"} \ No newline at end of file diff --git a/dist/lib/payments/notifyLicensingServer.js b/dist/lib/payments/notifyLicensingServer.js new file mode 100644 index 00000000..277693b2 --- /dev/null +++ b/dist/lib/payments/notifyLicensingServer.js @@ -0,0 +1,18 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const axios_1 = __importDefault(require("axios")); +exports.notifyLicensingServer = function (customer, product, sale) { + return Promise.resolve(); + return axios_1.default.post('https://jsreportonline.net/gumroad-hook', { + email: customer.email, + purchaseDate: new Date(), + license_key: product.licenseKey, + braintree: true, + product_name: product.name, + permalink: product.permalink + }); +}; +//# sourceMappingURL=notifyLicensingServer.js.map \ No newline at end of file diff --git a/dist/lib/payments/notifyLicensingServer.js.map b/dist/lib/payments/notifyLicensingServer.js.map new file mode 100644 index 00000000..502eadcb --- /dev/null +++ b/dist/lib/payments/notifyLicensingServer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"notifyLicensingServer.js","sourceRoot":"","sources":["../../../src/lib/payments/notifyLicensingServer.ts"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AAIZ,QAAA,qBAAqB,GAAG,UAAU,QAAkB,EAAE,OAAgB,EAAE,IAAU;IAC3F,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IAExB,OAAO,eAAK,CAAC,IAAI,CAAC,yCAAyC,EAAE;QACzD,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,YAAY,EAAE,IAAI,IAAI,EAAE;QACxB,WAAW,EAAE,OAAO,CAAC,UAAU;QAC/B,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,OAAO,CAAC,IAAI;QAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;KAC/B,CAAC,CAAA;AACN,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/lib/payments/payments.js b/dist/lib/payments/payments.js new file mode 100644 index 00000000..35f7ba13 --- /dev/null +++ b/dist/lib/payments/payments.js @@ -0,0 +1,104 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const logger = __importStar(require("../utils/logger")); +const mailer_1 = require("../utils/mailer"); +const braintree_1 = __importDefault(require("./braintree")); +const customer_1 = require("./customer"); +const validateVat_1 = __importDefault(require("./validateVat")); +const checkout_1 = require("./checkout"); +const notifyLicensingServer_1 = require("./notifyLicensingServer"); +const updatePaymentMethod_1 = require("./updatePaymentMethod"); +const cancelSubscription_1 = require("./cancelSubscription"); +const braintreeHook_1 = require("./braintreeHook"); +const renderInvoice_1 = require("./renderInvoice"); +const sendCustomerLink_1 = require("./sendCustomerLink"); +const braintree = new braintree_1.default(); +class Payments { + constructor(db) { + this.db = db; + this.customerRepository = new customer_1.CustomerRepository(db); + this.services = { + customerRepository: this.customerRepository, + braintree, + sendEmail: mailer_1.sendEmail, + notifyLicensingServer: notifyLicensingServer_1.notifyLicensingServer, + renderInvoice: renderInvoice_1.renderInvoice + }; + } + generateToken() { + return braintree.generateToken(); + } + async validateVat(vatNumber = '') { + return validateVat_1.default(vatNumber); + } + async checkout(checkoutData) { + return checkout_1.checkout(this.services)(checkoutData); + } + async updatePaymentMethod(customerId, productId, pm) { + return updatePaymentMethod_1.updatePaymentMethod(this.services)(customerId, productId, pm); + } + async customer(id) { + return this.customerRepository.find(id); + } + async invoice(customerId, saleId) { + logger.info('Downloading invoice ' + saleId); + const sale = await this.customerRepository.findSale(customerId, saleId); + return renderInvoice_1.readInvoice(sale.blobName); + } + async cancelSubscription(customerId, productId) { + logger.info('Canceling subscription customerId:' + customerId + ' productId:' + productId); + return cancelSubscription_1.cancelSubscription(this.services)(customerId, productId); + } + braintreeHook(signature, body) { + logger.info('Parsing braintree hook'); + return braintreeHook_1.braintreeHook(this.services)(signature, body); + } + customerLink(email) { + logger.info('Request customer link ' + email); + return sendCustomerLink_1.sendCustomerLink(this.services)(email); + } +} +exports.default = Payments; +/* + +export default (braintree: Braintree, jsreportClient, db: Db, axios) => { + const customerRepository = new CustomerRepository(db) + const createInvoice = CreateInvoice(jsreportClient, db) + const notifyGumroad = NotifyGumroad(axios) + + + + /* + const path = require('path') + const signature = decodeURIComponent( + require('fs') + .readFileSync(path.join(__dirname, 'signature.txt')) + .toString() + ) + const body = decodeURIComponent( + require('fs') + .readFileSync(path.join(__dirname, 'body.txt')) + .toString() + ) + gateway.webhookNotification.parse(signature, body, function (err, webhookNotification) { + console.log('[Webhook Received ' + webhookNotification.timestamp + '] | Kind: ' + webhookNotification.kind) + + // Example values for webhook notification properties + console.log(webhookNotification.kind) // "subscriptionWentPastDue" + console.log(webhookNotification.timestamp) // Sun Jan 1 00:00:00 UTC 2012 + }) + + } +} +*/ +//# sourceMappingURL=payments.js.map \ No newline at end of file diff --git a/dist/lib/payments/payments.js.map b/dist/lib/payments/payments.js.map new file mode 100644 index 00000000..5c0d0a2c --- /dev/null +++ b/dist/lib/payments/payments.js.map @@ -0,0 +1 @@ +{"version":3,"file":"payments.js","sourceRoot":"","sources":["../../../src/lib/payments/payments.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAyC;AACzC,4CAA2C;AAE3C,4DAAmC;AACnC,yCAA+C;AAC/C,gEAAuC;AACvC,yCAAsD;AACtD,mEAA+D;AAC/D,+DAA2D;AAC3D,6DAAyD;AACzD,mDAA+C;AAE/C,mDAA4D;AAC5D,yDAAqD;AAErD,MAAM,SAAS,GAAG,IAAI,mBAAS,EAAE,CAAA;AAEjC,MAAqB,QAAQ;IAK3B,YAAY,EAAM;QAChB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,kBAAkB,GAAG,IAAI,6BAAkB,CAAC,EAAE,CAAC,CAAA;QAEpD,IAAI,CAAC,QAAQ,GAAG;YACd,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,SAAS;YACT,SAAS,EAAT,kBAAS;YACT,qBAAqB,EAArB,6CAAqB;Y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AA;QACrC,OAAO,6BAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;IACtD,CAAC;IAED,YAAY,CAAC,KAAK;QAChB,MAAM,CAAC,IAAI,CAAC,wBAAwB,GAAG,KAAK,CAAC,CAAA;QAC7C,OAAO,mCAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAA;IAC/C,CAAC;CACF;AA1DD,2BA0DC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BE"} \ No newline at end of file diff --git a/dist/lib/payments/renderInvoice.js b/dist/lib/payments/renderInvoice.js new file mode 100644 index 00000000..706d8051 --- /dev/null +++ b/dist/lib/payments/renderInvoice.js @@ -0,0 +1,42 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const logger = __importStar(require("../utils/logger")); +const azure = __importStar(require("azure-storage")); +const jsreport_client_1 = __importDefault(require("jsreport-client")); +const bluebird_1 = __importDefault(require("bluebird")); +const stream_1 = __importDefault(require("stream")); +const jsreportClient = jsreport_client_1.default(process.env.JO_URL, process.env.JO_USER, process.env.JO_PASSWORD); +const blobServiceAsync = bluebird_1.default.promisifyAll(azure.createBlobService()); +exports.renderInvoice = async (data) => { + logger.info('request invoice generation in jo'); + const renderResult = await jsreportClient.render({ + template: { + name: '/payments/invoice' + }, + data + }); + const buffer = await renderResult.body(); + return blobServiceAsync.createBlockBlobFromTextAsync('invoices', data.id + '.pdf', buffer); +}; +exports.readInvoice = async (blobName) => { + const data = []; + const writingStream = new stream_1.default.Writable({ + write: (chunk, encoding, next) => { + data.push(chunk); + next(); + } + }); + await blobServiceAsync.getBlobToStreamAsync('invoices', blobName, writingStream); + return Buffer.concat(data); +}; +//# sourceMappingURL=renderInvoice.js.map \ No newline at end of file diff --git a/dist/lib/payments/renderInvoice.js.map b/dist/lib/payments/renderInvoice.js.map new file mode 100644 index 00000000..74160a8c --- /dev/null +++ b/dist/lib/payments/renderInvoice.js.map @@ -0,0 +1 @@ +{"version":3,"file":"renderInvoice.js","sourceRoot":"","sources":["../../../src/lib/payments/renderInvoice.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAyC;AACzC,qDAAsC;AACtC,sEAA4C;AAC5C,wDAA8B;AAC9B,oDAA2B;AAE3B,MAAM,cAAc,GAAG,yBAAc,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AACvG,MAAM,gBAAgB,GAAG,kBAAO,CAAC,YAAY,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAA;AAG3D,QAAA,aAAa,GAAG,KAAK,EAAE,IAAI,EAAE,EAAE;IACxC,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAA;IAC/C,MAAM,YAAY,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC;QAC7C,QAAQ,EAAE;YACN,IAAI,EAAE,mBAAmB;SAC5B;QACD,IAAI;KACP,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,CAAA;IACxC,OAAO,gBAAgB,CAAC,4BAA4B,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,CAAC,CAAA;AAC9F,CAAC,CAAA;AAEY,QAAA,WAAW,GAAG,KAAK,EAAE,QAAgB,EAAE,EAAE;IAClD,MAAM,IAAI,GAAG,EAAE,CAAA;IACf,MAAM,aAAa,GAAG,IAAI,gBAAM,CAAC,QAAQ,CAAC;QACtC,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;YAC7B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAChB,IAAI,EAAE,CAAA;QACV,CAAC;KACJ,CAAC,CAAA;IAEF,MAAM,gBAAgB,CAAC,oBAAoB,CAAC,UAAU,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAA;IAChF,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAC9B,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/lib/payments/sendCustomerLink.js b/dist/lib/payments/sendCustomerLink.js new file mode 100644 index 00000000..618d1b33 --- /dev/null +++ b/dist/lib/payments/sendCustomerLink.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const emails_1 = require("./emails"); +const utils_1 = require("../utils/utils"); +exports.sendCustomerLink = (services) => async (email) => { + let customer; + try { + customer = await services.customerRepository.findByEmail(email); + } + catch (e) { + return; + } + services.sendEmail({ + to: customer.email, + subject: emails_1.Emails.customerLink.subject, + content: utils_1.interpolate(emails_1.Emails.customerLink.content, { customer }) + }); +}; +//# sourceMappingURL=sendCustomerLink.js.map \ No newline at end of file diff --git a/dist/lib/payments/sendCustomerLink.js.map b/dist/lib/payments/sendCustomerLink.js.map new file mode 100644 index 00000000..9be1fd17 --- /dev/null +++ b/dist/lib/payments/sendCustomerLink.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sendCustomerLink.js","sourceRoot":"","sources":["../../../src/lib/payments/sendCustomerLink.ts"],"names":[],"mappings":";;AACA,qCAAkC;AAClC,0CAA6C;AAEhC,QAAA,gBAAgB,GAAG,CAAC,QAAkB,EAAE,EAAE,CAAC,KAAK,EAAE,KAAa,EAAE,EAAE;IAC5E,IAAI,QAAQ,CAAA;IACZ,IAAI;QACA,QAAQ,GAAG,MAAM,QAAQ,CAAC,kBAAkB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;KAClE;IAAC,OAAO,CAAC,EAAE;QACR,OAAM;KACT;IAED,QAAQ,CAAC,SAAS,CAAC;QACf,EAAE,EAAE,QAAQ,CAAC,KAAK;QAClB,OAAO,EAAE,eAAM,CAAC,YAAY,CAAC,OAAO;QACpC,OAAO,EAAE,mBAAW,CAAC,eAAM,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC;KAClE,CAAC,CAAA;AACN,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/lib/payments/services.js b/dist/lib/payments/services.js new file mode 100644 index 00000000..d0202b74 --- /dev/null +++ b/dist/lib/payments/services.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=services.js.map \ No newline at end of file diff --git a/dist/lib/payments/services.js.map b/dist/lib/payments/services.js.map new file mode 100644 index 00000000..18b20785 --- /dev/null +++ b/dist/lib/payments/services.js.map @@ -0,0 +1 @@ +{"version":3,"file":"services.js","sourceRoot":"","sources":["../../../src/lib/payments/services.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lib/payments/updatePaymentMethod.js b/dist/lib/payments/updatePaymentMethod.js new file mode 100644 index 00000000..ef4c1ef8 --- /dev/null +++ b/dist/lib/payments/updatePaymentMethod.js @@ -0,0 +1,38 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const logger = __importStar(require("../utils/logger")); +exports.updatePaymentMethod = (services) => async (customerId, productId, nonce) => { + logger.info(`updating patyment method for customer: ${customerId}, productId: ${productId}`); + const customer = await services.customerRepository.find(customerId); + const product = customer.products.find(p => p.id === productId); + const pmr = await services.braintree.createPaymentMethod({ + customerId: customer.braintree.customerId, + paymentMethodNonce: nonce, + options: { + verifyCard: true + } + }); + if (pmr.success === false) { + throw new Error('Unable to register payment method: ' + pmr.message); + } + const sres = await services.braintree.updateSubscription(product.braintree.subscription.id, { + paymentMethodToken: pmr.paymentMethod.token, + id: product.braintree.subscription.id, + merchantAccountId: product.braintree.subscription.merchantAccountId, + planId: product.braintree.subscription.planId + }); + if (sres.success === false) { + throw new Error('Unable to udpdate payment ' + sres.message); + } + product.braintree.paymentMethod = pmr.paymentMethod; + Object.assign(customer.products.find(p => p.id === productId), product); + await services.customerRepository.update(customer); +}; +//# sourceMappingURL=updatePaymentMethod.js.map \ No newline at end of file diff --git a/dist/lib/payments/updatePaymentMethod.js.map b/dist/lib/payments/updatePaymentMethod.js.map new file mode 100644 index 00000000..34556036 --- /dev/null +++ b/dist/lib/payments/updatePaymentMethod.js.map @@ -0,0 +1 @@ +{"version":3,"file":"updatePaymentMethod.js","sourceRoot":"","sources":["../../../src/lib/payments/updatePaymentMethod.ts"],"names":[],"mappings":";;;;;;;;;AAAA,wDAAyC;AAG5B,QAAA,mBAAmB,GAAG,CAAC,QAAkB,EAAE,EAAE,CAAC,KAAK,EAAE,UAAkB,EAAE,SAAiB,EAAE,KAAa,EAAE,EAAE;IACtH,MAAM,CAAC,IAAI,CAAC,0CAA0C,UAAU,gBAAgB,SAAS,EAAE,CAAC,CAAA;IAC5F,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACnE,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAA;IAE/D,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,mBAAmB,CAAC;QACrD,UAAU,EAAE,QAAQ,CAAC,SAAS,CAAC,UAAU;QACzC,kBAAkB,EAAE,KAAK;QACzB,OAAO,EAAE;YACL,UAAU,EAAE,IAAI;SACnB;KACJ,CAAC,CAAA;IAEF,IAAI,GAAG,CAAC,OAAO,KAAK,KAAK,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,GAAG,CAAC,OAAO,CAAC,CAAA;KACvE;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,kBAAkB,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE;QACxF,kBAAkB,EAAE,GAAG,CAAC,aAAa,CAAC,KAAK;QAC3C,EAAE,EAAE,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE;QACrC,iBAAiB,EAAE,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,iBAAiB;QACnE,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM;KAChD,CAAC,CAAA;IAEF,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,IAAI,CAAC,OAAO,CAAC,CAAA;KAC/D;IAED,OAAO,CAAC,SAAS,CAAC,aAAa,GAAG,GAAG,CAAC,aAAa,CAAA;IAEnD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,EAAE,OAAO,CAAC,CAAA;IACvE,MAAM,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACtD,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/lib/payments/validateVat.js b/dist/lib/payments/validateVat.js new file mode 100644 index 00000000..567df4de --- /dev/null +++ b/dist/lib/payments/validateVat.js @@ -0,0 +1,30 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const logger = __importStar(require("../utils/logger")); +const util_1 = require("util"); +const validate_vat_1 = __importDefault(require("validate-vat")); +const validateVatUtil = util_1.promisify(validate_vat_1.default); +async function default_1(vatNumber = '') { + logger.debug('validating vat ' + vatNumber); + const r = await validateVatUtil(vatNumber.slice(0, 2), vatNumber.substring(2)); + if (r.valid !== true) { + throw new Error('Invalid VAT'); + } + return { + country: r.countryCode, + name: r.name, + address: r.address + }; +} +exports.default = default_1; +//# sourceMappingURL=validateVat.js.map \ No newline at end of file diff --git a/dist/lib/payments/validateVat.js.map b/dist/lib/payments/validateVat.js.map new file mode 100644 index 00000000..870fb428 --- /dev/null +++ b/dist/lib/payments/validateVat.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validateVat.js","sourceRoot":"","sources":["../../../src/lib/payments/validateVat.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAyC;AACzC,+BAAgC;AAChC,gEAAsC;AACtC,MAAM,eAAe,GAAG,gBAAS,CAAC,sBAAW,CAAC,CAAA;AAE/B,KAAK,oBAAW,SAAS,GAAG,EAAE;IACzC,MAAM,CAAC,KAAK,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAA;IAC3C,MAAM,CAAC,GAAG,MAAM,eAAe,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IAE9E,IAAI,CAAC,CAAC,KAAK,KAAK,IAAI,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;KACjC;IAED,OAAO;QACH,OAAO,EAAE,CAAC,CAAC,WAAW;QACtB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,OAAO,EAAE,CAAC,CAAC,OAAO;KACrB,CAAA;AACL,CAAC;AAbD,4BAaC"} \ No newline at end of file diff --git a/dist/lib/payments/vatValidate.js b/dist/lib/payments/vatValidate.js new file mode 100644 index 00000000..353c6d85 --- /dev/null +++ b/dist/lib/payments/vatValidate.js @@ -0,0 +1,30 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const logger = __importStar(require("../utils/logger")); +const util_1 = require("util"); +const validate_vat_1 = __importDefault(require("validate-vat")); +const validateVatUtil = util_1.promisify(validate_vat_1.default); +async function default_1(vatNumber = '') { + logger.debug('validating vat ' + vatNumber); + const r = await validateVatUtil(vatNumber.slice(0, 2), vatNumber.substring(2)); + if (r.valid !== true) { + throw new Error('Invalid VAT'); + } + return { + country: r.countryCode, + name: r.name, + address: r.address + }; +} +exports.default = default_1; +//# sourceMappingURL=vatValidate.js.map \ No newline at end of file diff --git a/dist/lib/payments/vatValidate.js.map b/dist/lib/payments/vatValidate.js.map new file mode 100644 index 00000000..ef63fcad --- /dev/null +++ b/dist/lib/payments/vatValidate.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vatValidate.js","sourceRoot":"","sources":["../../../src/lib/payments/vatValidate.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAyC;AACzC,+BAAgC;AAChC,gEAAsC;AACtC,MAAM,eAAe,GAAG,gBAAS,CAAC,sBAAW,CAAC,CAAA;AAE/B,KAAK,oBAAW,SAAS,GAAG,EAAE;IACzC,MAAM,CAAC,KAAK,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAA;IAC3C,MAAM,CAAC,GAAG,MAAM,eAAe,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IAE9E,IAAI,CAAC,CAAC,KAAK,KAAK,IAAI,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;KACjC;IAED,OAAO;QACH,OAAO,EAAE,CAAC,CAAC,WAAW;QACtB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,OAAO,EAAE,CAAC,CAAC,OAAO;KACrB,CAAA;AACL,CAAC;AAbD,4BAaC"} \ No newline at end of file diff --git a/dist/lib/posts.js b/dist/lib/posts.js new file mode 100644 index 00000000..91696f69 --- /dev/null +++ b/dist/lib/posts.js @@ -0,0 +1,73 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const Prism = __importStar(require("prismjs")); +const languages = __importStar(require("prism-languages")); +const poet_1 = __importDefault(require("poet")); +const marked_1 = __importDefault(require("marked")); +async function default_1(app) { + var poet = poet_1.default(app, { + postsPerPage: 300 + }); + var cache = {}; + marked_1.default.setOptions({ + highlight: function (code, lang, callback) { + try { + return callback(null, Prism.highlight(code, languages[lang])); + } + catch (err) { + callback(err); + } + } + }); + poet.addTemplate({ + ext: 'md', + fn: function (s, cb) { + marked_1.default(s, function (err, content) { + if (err) + return cb(err); + cb(null, content); + }); + } + }); + poet.addRoute('/blog/:post', function (req, res, next) { + var post = poet.helpers.getPost(req.params.post); + if (post) { + if (cache[req.params.slug]) { + return res.render('post', cache[req.params.post]); + } + cache[req.params.post] = { + post: post, + linkDocCss: true, + url: "https://jsreport.net" + post.url, + id: req.params.slug, + blog: true, + lastPosts: poet.helpers.getPosts(0, 3), + title: post.title + }; + res.render('post', cache[req.params.post]); + } + else { + res.send(404); + } + }); + poet.addRoute('/blog', function (req, res) { + res.render('page', { + posts: poet.helpers.getPosts(0, 300), + blog: true, + title: "Blog about jsreport" + }); + }); + return poet.init(); +} +exports.default = default_1; +//# sourceMappingURL=posts.js.map \ No newline at end of file diff --git a/dist/lib/posts.js.map b/dist/lib/posts.js.map new file mode 100644 index 00000000..883a1ae1 --- /dev/null +++ b/dist/lib/posts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"posts.js","sourceRoot":"","sources":["../../src/lib/posts.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAgC;AAChC,2DAA4C;AAC5C,gDAAuB;AACvB,oDAA2B;AAEZ,KAAK,oBAAW,GAAG;IAE9B,IAAI,IAAI,GAAG,cAAI,CAAC,GAAG,EAAE;QACjB,YAAY,EAAE,GAAG;KACpB,CAAC,CAAC;IAEH,IAAI,KAAK,GAAG,EAAE,CAAC;IAEf,gBAAM,CAAC,UAAU,CAAC;QACd,SAAS,EAAE,UAAU,IAAI,EAAE,IAAI,EAAE,QAAQ;YACrC,IAAI;gBACA,OAAO,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACjE;YAAC,OAAO,GAAG,EAAE;gBACV,QAAQ,CAAC,GAAG,CAAC,CAAA;aAChB;QACL,CAAC;KACJ,CAAC,CAAC;IAEH,IAAI,CAAC,WAAW,CAAC;QACb,GAAG,EAAE,IAAI;QACT,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE;YACf,gBAAM,CAAC,CAAC,EAAE,UAAU,GAAG,EAAE,OAAO;gBAC5B,IAAI,GAAG;oBAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;gBACxB,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACtB,CAAC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,UAAU,GAAG,EAAE,GAAG,EAAE,IAAI;Q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/lib/router.js b/dist/lib/router.js new file mode 100644 index 00000000..2b7a4574 --- /dev/null +++ b/dist/lib/router.js @@ -0,0 +1,169 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function default_1(payments, db) { + return { + onprem(req, res) { + return res.render('onprem', { + onprem: true, + title: 'jsreport - report server', + description: 'Download jsreport on-prem version to your server in your company and use it without any limitations.' + }); + }, + playground(req, res) { + return res.render('playground', { + playground: true, + title: 'Try free jsreport online playground', + description: 'Try free jsreport online fiddling tool. Share your reports with others. Embed report generation into your website.' + }); + }, + buyOnPrem(req, res) { + return res.render('buy', { + buy: true, + buyOnPrem: true, + title: 'jsreport - buy', + description: 'Buy jsreport license' + }); + }, + buySupport(req, res) { + return res.render('buy', { + buy: true, + buySupport: true, + title: 'jsreport - buy', + description: 'Buy jsreport support' + }); + }, + buyOnline(req, res) { + return res.render('buy', { + buy: true, + buyOnline: true, + title: 'jsreport - buy', + description: 'Buy jsreport online credits' + }); + }, + buyThankYou(req, res) { + return res.render('thank-you', { + buy: true, + title: 'jsreport - buy', + description: 'Thank you' + }); + }, + online(req, res) { + return res.render('online', { + online: true, + title: 'jsreportonline - pdf reports as a service', + description: 'Do not install anything. Just register to cloud based jsreportonline service and start creating reports now.' + }); + }, + onlinePricing(req, res) { + return res.render('online-pricing', { + online: true, + title: 'jsreportonline - pdf reports as a service', + description: 'Do not install anything. Just register to cloud based jsreportonline service and start creating reports now.' + }); + }, + about(req, res) { + return res.render('about', { about: true, title: 'About jsreport' }); + }, + downloads(req, res) { + return res.redirect('/on-prem'); + }, + embedding(req, res) { + return res.render('embedding', { + playground: true, + title: 'Embed jsreport to any page' + }); + }, + showcases(req, res) { + return res.render('showcases', { + title: 'jsreport - showcases', + description: 'jsreport showcases' + }); + }, + contactEmail(req, res) { + return db + .collection('contacts') + .insertOne({ + date: new Date(), + email: req.body.contactEmail, + enabledNewsletter: req.body.enabledNewsletter === 'true', + type: req.body.type + }) + .then(() => { + // expire in 30seconds + res.cookie('jsreport-contact-email-set', 'true', { + maxAge: 30 * 60 * 1000 + }); + res.send('ok'); + }) + .catch(e => { + console.error(e); + res.send('error ' + e); + }); + }, + payments(req, res) { + return res.render('../dist/public/app.html', { + title: 'jsreport customers' + }); + }, + checkoutSubmit(req, res, next) { + return payments + .checkout(req.body) + .then(r => res.send(r)) + .catch(next); + }, + braintreeToken(req, res, next) { + return payments + .generateToken() + .then(r => res.send(r)) + .catch(next); + }, + validateVat(req, res) { + return payments + .validateVat(req.body.vatNumber) + .then(r => res.send(r)) + .catch(r => res.send({ valid: false })); + }, + customerApi(req, res, next) { + return payments + .customer(req.params.id) + .then(r => res.send(r)) + .catch(next); + }, + invoice(req, res, next) { + return payments + .invoice(req.params.customerId, req.params.invoiceId) + .then(buf => { + res.setHeader('Content-Type', 'application/pdf'); + res.setHeader('Content-Disposition', `inline; filename=${req.params.invoiceId}.pdf`); + res.send(buf); + }) + .catch(next); + }, + cancelSubscription(req, res, next) { + return payments + .cancelSubscription(req.params.customerId, req.params.productId) + .then(() => res.send({ result: 'ok' })) + .catch(next); + }, + updatePaymentMethod(req, res, next) { + return payments + .updatePaymentMethod(req.params.customerId, req.params.productId, req.body.nonce) + .then(() => res.send({ result: 'ok' })) + .catch(next); + }, + braintreeHook(req, res, next) { + return payments + .braintreeHook(req.body.bt_signature, req.body.bt_payload) + .then(() => res.send('ok')) + .catch(next); + }, + customerLink(req, res, next) { + return payments + .customerLink(req.body.email) + .then(() => res.send('ok')) + .catch(next); + } + }; +} +exports.default = default_1; +//# sourceMappingURL=router.js.map \ No newline at end of file diff --git a/dist/lib/router.js.map b/dist/lib/router.js.map new file mode 100644 index 00000000..283b12d0 --- /dev/null +++ b/dist/lib/router.js.map @@ -0,0 +1 @@ +{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/lib/router.ts"],"names":[],"mappings":";;AAEA,mBAAyB,QAAQ,EAAE,EAAE;IACnC,OAAO;QACL,MAAM,CAAC,GAAG,EAAE,GAAG;YACb,OAAO,GAA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G,EAAE,GAAG,EAAE,IAAI;YAChC,OAAO,QAAQ;iBACZ,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;iBAChF,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;iBACtC,KAAK,CAAC,IAAI,CAAC,CAAA;QAChB,CAAC;QAED,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI;YAC1B,OAAO,QAAQ;iBACZ,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;iBACzD,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAChB,CAAC;QAED,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI;YACzB,OAAO,QAAQ;iBACZ,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;iBAC5B,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC;AA1LD,4BA0LC"} \ No newline at end of file diff --git a/dist/lib/utils/logger.js b/dist/lib/utils/logger.js new file mode 100644 index 00000000..a52d1229 --- /dev/null +++ b/dist/lib/utils/logger.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const winston = require('winston'); +require('winston-loggly'); +let _logger; +exports.init = ({ loggly = null } = {}) => { + _logger = winston.createLogger({ + level: 'debug', + format: winston.format.simple() + }); + _logger.add(new winston.transports.Console(), { + level: 'debug' + }); + if (loggly) { + _logger.add(new winston.transports.Loggly(), { + level: loggly.level, + token: loggly.token, + subdomain: loggly.subdomain, + json: true, + tags: ['website'] + }); + } +}; +exports.info = (...args) => _logger.info.apply(_logger, args); +exports.debug = (...args) => _logger.debug.apply(_logger, args); +exports.error = (...args) => _logger.error.apply(_logger, args); +exports.warn = (...args) => _logger.warn.apply(_logger, args); +exports.log = (...args) => _logger.log.apply(_logger, args); +//# sourceMappingURL=logger.js.map \ No newline at end of file diff --git a/dist/lib/utils/logger.js.map b/dist/lib/utils/logger.js.map new file mode 100644 index 00000000..c961c787 --- /dev/null +++ b/dist/lib/utils/logger.js.map @@ -0,0 +1 @@ +{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/lib/utils/logger.ts"],"names":[],"mappings":";;AAAA,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAClC,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAGzB,IAAI,OAAO,CAAA;AAEA,QAAA,IAAI,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE;IAC3C,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC;QAC7B,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;KAChC,CAAC,CAAA;IAEF,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE;QAC5C,KAAK,EAAE,OAAO;KACf,CAAC,CAAA;IAEF,IAAI,MAAM,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE;YAC3C,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,CAAC,SAAS,CAAC;SAClB,CAAC,CAAA;KACH;AACH,CAAC,CAAA;AAGU,QAAA,IAAI,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACrD,QAAA,KAAK,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACvD,QAAA,KAAK,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACvD,QAAA,IAAI,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACrD,QAAA,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/lib/utils/mailer.js b/dist/lib/utils/mailer.js new file mode 100644 index 00000000..25e89855 --- /dev/null +++ b/dist/lib/utils/mailer.js @@ -0,0 +1,37 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const sendgrid_1 = __importDefault(require("sendgrid")); +const logger = __importStar(require("./logger.js")); +const helper = sendgrid_1.default.mail; +exports.sendEmail = (Mail) => { + const sg = sendgrid_1.default(process.env.SENDGRID); + logger.info(`Sending email (${Mail.subject}) to ${Mail.to}`); + const fromEmail = new helper.Email('support@jsreport.net'); + const toEmail = new helper.Email(Mail.to); + const contentEmail = new helper.Content('text/html', Mail.content); + const mail = new helper.Mail(fromEmail, Mail.subject, toEmail, contentEmail); + const request = sg.emptyRequest({ + method: 'POST', + path: '/v3/mail/send', + body: mail.toJSON() + }); + return sg.API(request, (err, response) => { + if (err) { + logger.error('Error while sending mail:', err); + } + else { + logger.info('sent succesfully'); + } + }); +}; +//# sourceMappingURL=mailer.js.map \ No newline at end of file diff --git a/dist/lib/utils/mailer.js.map b/dist/lib/utils/mailer.js.map new file mode 100644 index 00000000..017e658a --- /dev/null +++ b/dist/lib/utils/mailer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"mailer.js","sourceRoot":"","sources":["../../../src/lib/utils/mailer.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,wDAA+B;AAC/B,oDAAqC;AACrC,MAAM,MAAM,GAAG,kBAAQ,CAAC,IAAI,CAAA;AAQf,QAAA,SAAS,GAAG,CAAC,IAAI,EAAE,EAAE;IAChC,MAAM,EAAE,GAAG,kBAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAEzC,MAAM,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,OAAO,QAAQ,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;IAE5D,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAA;IAC1D,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACzC,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IAClE,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAA;IAE5E,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC;QAC9B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;KACpB,CAAC,CAAA;IAEF,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE;QACvC,IAAI,GAAG,EAAE;YACP,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAA;SAC/C;aAAM;YACL,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;SAChC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/lib/utils/utils.js b/dist/lib/utils/utils.js new file mode 100644 index 00000000..6e18b341 --- /dev/null +++ b/dist/lib/utils/utils.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const vm = require('vm'); +exports.interpolate = (tmpl, vars) => { + return vm.runInNewContext('`' + tmpl + '`', vars); +}; +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/dist/lib/utils/utils.js.map b/dist/lib/utils/utils.js.map new file mode 100644 index 00000000..e561ffa9 --- /dev/null +++ b/dist/lib/utils/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/utils/utils.ts"],"names":[],"mappings":";;AAAA,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAEX,QAAA,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;IACtC,OAAO,EAAE,CAAC,eAAe,CAAC,GAAG,GAAG,IAAI,GAAG,GAAG,EAAE,IAAI,CAAC,CAAA;AACrD,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/public/app.54325477.js b/dist/public/app.54325477.js new file mode 100644 index 00000000..c496733d --- /dev/null +++ b/dist/public/app.54325477.js @@ -0,0 +1,617 @@ +parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;cA.length&&A.push(e)}function q(e,t,o,u){var l=typeof e;"undefined"!==l&&"boolean"!==l||(e=null);var f=!1;if(null===e)f=!0;else switch(l){case"string":case"number":f=!0;break;case"object":switch(e.$$typeof){case r:case n:f=!0}}if(f)return o(u,e,""===t?"."+F(e,0):t),1;if(f=0,t=""===t?".":t+":",Array.isArray(e))for(var c=0;c=h},o=function(){},exports.unstable_forceFrameRate=function(e){0>e||125(d=t<_?_:t)&&(d=8.33)),_=t}y=e,h=e+d,F.postMessage(null)}};e=function(e){b=e,v||(v=!0,p(function(e){P(e)}))},n=function(e,n){m=c(function(){e(exports.unstable_now())},n)},t=function(){f(m),m=-1}}var M=null,C=null,A=null,L=3,R=!1,j=!1,q=!1;function D(e,n){var t=e.next;if(t===e)M=null;else{e===M&&(M=t);var r=e.previous;r.next=t,t.previous=r}e.next=e.previous=null,t=e.callback,r=L;var o=A;L=e.priorityLevel,A=e;try{var i=e.expirationTime<=n;switch(L){case 1:var l=t(i);break;case 2:case 3:case 4:l=t(i);break;case 5:l=t(i)}}catch(u){throw u}finally{L=r,A=o}if("function"==typeof l)if(n=e.expirationTime,e.callback=l,null===M)M=e.next=e.previous=e;else{l=null,i=M;do{if(n<=i.expirationTime){l=i;break}i=i.next}while(i!==M);null===l?l=M:l===M&&(M=e),(n=l.previous).next=l.previous=e,e.next=l,e.previous=n}}function E(e){if(null!==C&&C.startTime<=e)do{var n=C,t=n.next;if(n===t)C=null;else{C=t;var r=n.previous;r.next=t,t.previous=r}n.next=n.previous=null,O(n,n.expirationTime)}while(null!==C&&C.startTime<=e)}function I(t){q=!1,E(t),j||(null!==M?(j=!0,e(N)):null!==C&&n(I,C.startTime-t))}function N(e,o){j=!1,q&&(q=!1,t()),E(o),R=!0;try{if(e){if(null!==M)do{D(M,o),E(o=exports.unstable_now())}while(null!==M&&!r())}else for(;null!==M&&M.expirationTime<=o;)D(M,o),E(o=exports.unstable_now());return null!==M||(null!==C&&n(I,C.startTime-o),!1)}finally{R=!1}}function B(e){switch(e){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1e4;default:return 5e3}}function O(e,n){if(null===M)M=e.next=e.previous=e;else{var t=null,r=M;do{if(nl){if(i=u,null===C)C=r.next=r.previous=r;else{o=null;var a=C;do{if(ithis.eventPool.length&&this.eventPool.push(e)}function se(e){e.eventPool=[],e.getPooled=ue,e.release=ce}t(oe.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=ie)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=ie)},persist:function(){this.isPersistent=ie},isPersistent:ae,destructor:function(){var e,t=this.constructor.Interface;for(e in t)this[e]=null;this.nativeEvent=this._targetInst=this.dispatchConfig=null,this.isPropagationStopped=this.isDefaultPrevented=ae,this._dispatchInstances=this._dispatchListeners=null}}),oe.Interface={type:null,target:null,currentTarget:function(){return null},eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null},oe.extend=function(e){function n(){}function r(){return l.apply(this,arguments)}var l=this;n.prototype=l.prototype;var i=new n;return t(i,r.prototype),r.prototype=i,r.prototype.constructor=r,r.Interface=t({},l.Interface,e),r.extend=l.extend,se(r),r},se(oe);var fe=oe.extend({data:null}),de=oe.extend({data:null}),pe=[9,13,27,32],he=H&&"CompositionEvent"in window,me=null;H&&"documentMode"in document&&(me=document.documentMode);var ge=H&&"TextEvent"in window&&!me,ve=H&&(!he||me&&8=me),ye=String.fromCharCode(32),be={beforeInput:{phasedRegistrationNames:{bubbled:"onBeforeInput",captured:"onBeforeInputCapture"},dependencies:["compositionend","keypress","textInput","paste"]},compositionEnd:{phasedRegistrationNames:{bubbled:"onCompositionEnd",captured:"onCompositionEndCapture"},dependencies:"blur compositionend keydown keypress keyup mousedown".split(" ")},compositionStart:{phasedRegistrationNames:{bubbled:"onCompositionStart",captured:"onCompositionStartCapture"},dependencies:"blur compositionstart keydown keypress keyup mousedown".split(" ")},compositionUpdate:{phasedRegistrationNames:{bubbled:"onCompositionUpdate",captured:"onCompositionUpdateCapture"},dependencies:"blur compositionupdate keydown keypress keyup mousedown".split(" ")}},we=!1;function ke(e,t){switch(e){case"keyup":return-1!==pe.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"blur":return!0;default:return!1}}function Ee(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var xe=!1;function Te(e,t){switch(e){case"compositionend":return Ee(t);case"keypress":return 32!==t.which?null:(we=!0,ye);case"textInput":return(e=t.data)===ye&&we?null:e;default:return null}}function Ce(e,t){if(xe)return"compositionend"===e||!he&&ke(e,t)?(e=le(),re=ne=te=null,xe=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1t}return!1}function wt(e,t,n,r,l,i){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i}var kt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){kt[e]=new wt(e,0,!1,e,null,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];kt[t]=new wt(t,1,!1,e[1],null,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){kt[e]=new wt(e,2,!1,e.toLowerCase(),null,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){kt[e]=new wt(e,2,!1,e,null,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){kt[e]=new wt(e,3,!1,e.toLowerCase(),null,!1)}),["checked","multiple","muted","selected"].forEach(function(e){kt[e]=new wt(e,3,!0,e,null,!1)}),["capture","download"].forEach(function(e){kt[e]=new wt(e,4,!1,e,null,!1)}),["cols","rows","size","span"].forEach(function(e){kt[e]=new wt(e,6,!1,e,null,!1)}),["rowSpan","start"].forEach(function(e){kt[e]=new wt(e,5,!1,e.toLowerCase(),null,!1)});var Et=/[\-:]([a-z])/g;function xt(e){return e[1].toUpperCase()}function Tt(e,t,n,r){var l=kt.hasOwnProperty(t)?kt[t]:null;(null!==l?0===l.type:!r&&(2On.length&&On.push(e)}}}var Qn=new("function"==typeof WeakMap?WeakMap:Map);function Kn(e){var t=Qn.get(e);return void 0===t&&(t=new Set,Qn.set(e,t)),t}function $n(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function qn(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Yn(e,t){var n,r=qn(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=qn(r)}}function Xn(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?Xn(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function Gn(){for(var e=window,t=$n();t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(r){n=!1}if(!n)break;t=$n((e=t.contentWindow).document)}return t}function Zn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var Jn=H&&"documentMode"in document&&11>=document.documentMode,er={select:{phasedRegistrationNames:{bubbled:"onSelect",captured:"onSelectCapture"},dependencies:"blur contextmenu dragend focus keydown keyup mousedown mouseup selectionchange".split(" ")}},tr=null,nr=null,rr=null,lr=!1;function ir(e,t){var n=t.window===t?t.document:9===t.nodeType?t:t.ownerDocument;return lr||null==tr||tr!==$n(n)?null:("selectionStart"in(n=tr)&&Zn(n)?n={start:n.selectionStart,end:n.selectionEnd}:n={anchorNode:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset},rr&&un(rr,n)?null:(rr=n,(e=oe.getPooled(er.select,nr,e,t)).type="select",e.target=tr,j(e),e))}var ar={eventTypes:er,extractEvents:function(e,t,n,r){var l,i=r.window===r?r.document:9===r.nodeType?r:r.ownerDocument;if(!(l=!i)){e:{i=Kn(i),l=f.onSelect;for(var a=0;a=t.length))throw r(Error(93));t=t[0]}n=t}null==n&&(n="")}e._wrapperState={initialValue:Ct(n)}}function dr(e,t){var n=Ct(t.value),r=Ct(t.defaultValue);null!=n&&((n=""+n)!==e.value&&(e.value=n),null==t.defaultValue&&e.defaultValue!==n&&(e.defaultValue=n)),null!=r&&(e.defaultValue=""+r)}function pr(e){var t=e.textContent;t===e._wrapperState.initialValue&&(e.value=t)}N.injectEventPluginOrder("ResponderEventPlugin SimpleEventPlugin EnterLeaveEventPlugin ChangeEventPlugin SelectEventPlugin BeforeInputEventPlugin".split(" ")),w=O,k=I,E=D,N.injectEventPluginsByName({SimpleEventPlugin:In,EnterLeaveEventPlugin:ln,ChangeEventPlugin:Kt,SelectEventPlugin:ar,BeforeInputEventPlugin:Se});var hr={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg"};function mr(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function gr(e,t){return null==e||"http://www.w3.org/1999/xhtml"===e?mr(t):"http://www.w3.org/2000/svg"===e&&"foreignObject"===t?"http://www.w3.org/1999/xhtml":e}var vr=void 0,yr=function(e){return"undefined"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(t,n,r,l){MSApp.execUnsafeLocalFunction(function(){return e(t,n)})}:e}(function(e,t){if(e.namespaceURI!==hr.svg||"innerHTML"in e)e.innerHTML=t;else{for((vr=vr||document.createElement("div")).innerHTML=""+t+"",t=vr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function br(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var wr={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},kr=["Webkit","ms","Moz","O"];function Er(e,t,n){return null==t||"boolean"==typeof t||""===t?"":n||"number"!=typeof t||0===t||wr.hasOwnProperty(e)&&wr[e]?(""+t).trim():t+"px"}function xr(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=0===n.indexOf("--"),l=Er(n,t[n],r);"float"===n&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}Object.keys(wr).forEach(function(e){kr.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),wr[t]=wr[e]})});var Tr=t({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Cr(e,t){if(t){if(Tr[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw r(Error(137),e,"");if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw r(Error(60));if(!("object"==typeof t.dangerouslySetInnerHTML&&"__html"in t.dangerouslySetInnerHTML))throw r(Error(61))}if(null!=t.style&&"object"!=typeof t.style)throw r(Error(62),"")}}function Sr(e,t){if(-1===e.indexOf("-"))return"string"==typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}function _r(e,t){var n=Kn(e=9===e.nodeType||11===e.nodeType?e:e.ownerDocument);t=f[t];for(var r=0;rOr||(e.current=Dr[Or],Dr[Or]=null,Or--)}function Ar(e,t){Dr[++Or]=e.current,e.current=t}var Wr={},Vr={current:Wr},Br={current:!1},jr=Wr;function Hr(e,t){var n=e.type.contextTypes;if(!n)return Wr;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l,i={};for(l in n)i[l]=t[l];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Qr(e){return null!=(e=e.childContextTypes)}function Kr(e){Lr(Br,e),Lr(Vr,e)}function $r(e){Lr(Br,e),Lr(Vr,e)}function qr(e,t,n){if(Vr.current!==Wr)throw r(Error(168));Ar(Vr,t,e),Ar(Br,n,e)}function Yr(e,n,l){var i=e.stateNode;if(e=n.childContextTypes,"function"!=typeof i.getChildContext)return l;for(var a in i=i.getChildContext())if(!(a in e))throw r(Error(108),ft(n)||"Unknown",a);return t({},l,i)}function Xr(e){var t=e.stateNode;return t=t&&t.__reactInternalMemoizedMergedChildContext||Wr,jr=Vr.current,Ar(Vr,t,e),Ar(Br,Br.current,e),!0}function Gr(e,t,n){var l=e.stateNode;if(!l)throw r(Error(169));n?(t=Yr(e,t,jr),l.__reactInternalMemoizedMergedChildContext=t,Lr(Br,e),Lr(Vr,e),Ar(Vr,t,e)):Lr(Br,e),Ar(Br,n,e)}var Zr=n.unstable_runWithPriority,Jr=n.unstable_scheduleCallback,el=n.unstable_cancelCallback,tl=n.unstable_shouldYield,nl=n.unstable_requestPaint,rl=n.unstable_now,ll=n.unstable_getCurrentPriorityLevel,il=n.unstable_ImmediatePriority,al=n.unstable_UserBlockingPriority,ol=n.unstable_NormalPriority,ul=n.unstable_LowPriority,cl=n.unstable_IdlePriority,sl={},fl=void 0!==nl?nl:function(){},dl=null,pl=null,hl=!1,ml=rl(),gl=1e4>ml?rl:function(){return rl()-ml};function vl(){switch(ll()){case il:return 99;case al:return 98;case ol:return 97;case ul:return 96;case cl:return 95;default:throw r(Error(332))}}function yl(e){switch(e){case 99:return il;case 98:return al;case 97:return ol;case 96:return ul;case 95:return cl;default:throw r(Error(332))}}function bl(e,t){return e=yl(e),Zr(e,t)}function wl(e,t,n){return e=yl(e),Jr(e,t,n)}function kl(e){return null===dl?(dl=[e],pl=Jr(il,xl)):dl.push(e),sl}function El(){null!==pl&&el(pl),xl()}function xl(){if(!hl&&null!==dl){hl=!0;var e=0;try{var t=dl;bl(99,function(){for(;e=(e=10*(1073741821-t)-10*(1073741821-e))?99:250>=e?98:5250>=e?97:95}function Cl(e,n){if(e&&e.defaultProps)for(var r in n=t({},n),e=e.defaultProps)void 0===n[r]&&(n[r]=e[r]);return n}function Sl(e){var t=e._result;switch(e._status){case 1:return t;case 2:case 0:throw t;default:switch(e._status=0,(t=(t=e._ctor)()).then(function(t){0===e._status&&(t=t.default,e._status=1,e._result=t)},function(t){0===e._status&&(e._status=2,e._result=t)}),e._status){case 1:return e._result;case 2:throw e._result}throw e._result=t,t}}var _l={current:null},Pl=null,Nl=null,zl=null;function Ml(){zl=Nl=Pl=null}function Ul(e,t){var n=e.type._context;Ar(_l,n._currentValue,e),n._currentValue=t}function Rl(e){var t=_l.current;Lr(_l,e),e.type._context._currentValue=t}function Fl(e,t){for(;null!==e;){var n=e.alternate;if(e.childExpirationTime=t&&(ya=!0),e.firstContext=null)}function Dl(e,t){if(zl!==e&&!1!==t&&0!==t)if("number"==typeof t&&1073741823!==t||(zl=e,t=1073741823),t={context:e,observedBits:t,next:null},null===Nl){if(null===Pl)throw r(Error(308));Nl=t,Pl.dependencies={expirationTime:0,firstContext:t,responders:null}}else Nl=Nl.next=t;return e._currentValue}var Ol=!1;function Ll(e){return{baseState:e,firstUpdate:null,lastUpdate:null,firstCapturedUpdate:null,lastCapturedUpdate:null,firstEffect:null,lastEffect:null,firstCapturedEffect:null,lastCapturedEffect:null}}function Al(e){return{baseState:e.baseState,firstUpdate:e.firstUpdate,lastUpdate:e.lastUpdate,firstCapturedUpdate:null,lastCapturedUpdate:null,firstEffect:null,lastEffect:null,firstCapturedEffect:null,lastCapturedEffect:null}}function Wl(e,t){return{expirationTime:e,suspenseConfig:t,tag:0,payload:null,callback:null,next:null,nextEffect:null}}function Vl(e,t){null===e.lastUpdate?e.firstUpdate=e.lastUpdate=t:(e.lastUpdate.next=t,e.lastUpdate=t)}function Bl(e,t){var n=e.alternate;if(null===n){var r=e.updateQueue,l=null;null===r&&(r=e.updateQueue=Ll(e.memoizedState))}else r=e.updateQueue,l=n.updateQueue,null===r?null===l?(r=e.updateQueue=Ll(e.memoizedState),l=n.updateQueue=Ll(n.memoizedState)):r=e.updateQueue=Al(l):null===l&&(l=n.updateQueue=Al(r));null===l||r===l?Vl(r,t):null===r.lastUpdate||null===l.lastUpdate?(Vl(r,t),Vl(l,t)):(Vl(r,t),l.lastUpdate=t)}function jl(e,t){var n=e.updateQueue;null===(n=null===n?e.updateQueue=Ll(e.memoizedState):Hl(e,n)).lastCapturedUpdate?n.firstCapturedUpdate=n.lastCapturedUpdate=t:(n.lastCapturedUpdate.next=t,n.lastCapturedUpdate=t)}function Hl(e,t){var n=e.alternate;return null!==n&&t===n.updateQueue&&(t=e.updateQueue=Al(t)),t}function Ql(e,n,r,l,i,a){switch(r.tag){case 1:return"function"==typeof(e=r.payload)?e.call(a,l,i):e;case 3:e.effectTag=-2049&e.effectTag|64;case 0:if(null==(i="function"==typeof(e=r.payload)?e.call(a,l,i):e))break;return t({},l,i);case 2:Ol=!0}return l}function Kl(e,t,n,r,l){Ol=!1;for(var i=(t=Hl(e,t)).baseState,a=null,o=0,u=t.firstUpdate,c=i;null!==u;){var s=u.expirationTime;sm?(g=f,f=null):g=f.sibling;var v=p(r,f,o[m],u);if(null===v){null===f&&(f=g);break}e&&f&&null===v.alternate&&t(r,f),i=a(v,i,m),null===s?c=v:s.sibling=v,s=v,f=g}if(m===o.length)return n(r,f),c;if(null===f){for(;mg?(v=m,m=null):v=m.sibling;var b=p(i,m,y.value,c);if(null===b){null===m&&(m=v);break}e&&m&&null===b.alternate&&t(i,m),o=a(b,o,g),null===f?s=b:f.sibling=b,f=b,m=v}if(y.done)return n(i,m),s;if(null===m){for(;!y.done;g++,y=u.next())null!==(y=d(i,y.value,c))&&(o=a(y,o,g),null===f?s=y:f.sibling=y,f=y);return s}for(m=l(i,m);!y.done;g++,y=u.next())null!==(y=h(m,i,g,y.value,c))&&(e&&null!==y.alternate&&m.delete(null===y.key?g:y.key),o=a(y,o,g),null===f?s=y:f.sibling=y,f=y);return e&&m.forEach(function(e){return t(i,e)}),s}return function(e,l,a,u){var c="object"==typeof a&&null!==a&&a.type===Ze&&null===a.key;c&&(a=a.props.children);var s="object"==typeof a&&null!==a;if(s)switch(a.$$typeof){case Xe:e:{for(s=a.key,c=l;null!==c;){if(c.key===s){if(7===c.tag?a.type===Ze:c.elementType===a.type){n(e,c.sibling),(l=i(c,a.type===Ze?a.props.children:a.props,u)).ref=li(e,c,a),l.return=e,e=l;break e}n(e,c);break}t(e,c),c=c.sibling}a.type===Ze?((l=wu(a.props.children,e.mode,u,a.key)).return=e,e=l):((u=bu(a.type,a.key,a.props,null,e.mode,u)).ref=li(e,l,a),u.return=e,e=u)}return o(e);case Ge:e:{for(c=a.key;null!==l;){if(l.key===c){if(4===l.tag&&l.stateNode.containerInfo===a.containerInfo&&l.stateNode.implementation===a.implementation){n(e,l.sibling),(l=i(l,a.children||[],u)).return=e,e=l;break e}n(e,l);break}t(e,l),l=l.sibling}(l=Eu(a,e.mode,u)).return=e,e=l}return o(e)}if("string"==typeof a||"number"==typeof a)return a=""+a,null!==l&&6===l.tag?(n(e,l.sibling),(l=i(l,a,u)).return=e,e=l):(n(e,l),(l=ku(a,e.mode,u)).return=e,e=l),o(e);if(ri(a))return m(e,l,a,u);if(st(a))return g(e,l,a,u);if(s&&ii(e,a),void 0===a&&!c)switch(e.tag){case 1:case 0:throw e=e.type,r(Error(152),e.displayName||e.name||"Component")}return n(e,l)}}var oi=ai(!0),ui=ai(!1),ci={},si={current:ci},fi={current:ci},di={current:ci};function pi(e){if(e===ci)throw r(Error(174));return e}function hi(e,t){Ar(di,t,e),Ar(fi,e,e),Ar(si,ci,e);var n=t.nodeType;switch(n){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:gr(null,"");break;default:t=gr(t=(n=8===n?t.parentNode:t).namespaceURI||null,n=n.tagName)}Lr(si,e),Ar(si,t,e)}function mi(e){Lr(si,e),Lr(fi,e),Lr(di,e)}function gi(e){pi(di.current);var t=pi(si.current),n=gr(t,e.type);t!==n&&(Ar(fi,e,e),Ar(si,n,e))}function vi(e){fi.current===e&&(Lr(si,e),Lr(fi,e))}var yi=1,bi=1,wi=2,ki={current:0};function Ei(e){for(var t=e;null!==t;){if(13===t.tag){if(null!==t.memoizedState)return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!=(64&t.effectTag))return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var xi=0,Ti=2,Ci=4,Si=8,_i=16,Pi=32,Ni=64,zi=128,Mi=$e.ReactCurrentDispatcher,Ui=0,Ri=null,Fi=null,Ii=null,Di=null,Oi=null,Li=null,Ai=0,Wi=null,Vi=0,Bi=!1,ji=null,Hi=0;function Qi(){throw r(Error(321))}function Ki(e,t){if(null===t)return!1;for(var n=0;nAi&&(Ai=f)):(Jo(f,c.suspenseConfig),a=c.eagerReducer===e?c.eagerState:e(a,c.action)),o=c,c=c.next}while(null!==c&&c!==l);s||(u=o,i=a),an(a,t.memoizedState)||(ya=!0),t.memoizedState=a,t.baseUpdate=u,t.baseState=i,n.lastRenderedState=a}return[t.memoizedState,n.dispatch]}function Ji(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},null===Wi?(Wi={lastEffect:null}).lastEffect=e.next=e:null===(t=Wi.lastEffect)?Wi.lastEffect=e.next=e:(n=t.next,t.next=e,e.next=n,Wi.lastEffect=e),e}function ea(e,t,n,r){var l=Yi();Vi|=e,l.memoizedState=Ji(t,n,void 0,void 0===r?null:r)}function ta(e,t,n,r){var l=Xi();r=void 0===r?null:r;var i=void 0;if(null!==Fi){var a=Fi.memoizedState;if(i=a.destroy,null!==r&&Ki(r,a.deps))return void Ji(xi,n,i,r)}Vi|=e,l.memoizedState=Ji(t,n,i,r)}function na(e,t){return"function"==typeof t?(e=e(),t(e),function(){t(null)}):null!=t?(e=e(),t.current=e,function(){t.current=null}):void 0}function ra(){}function la(e,t,n){if(!(25>Hi))throw r(Error(301));var l=e.alternate;if(e===Ri||null!==l&&l===Ri)if(Bi=!0,e={expirationTime:Ui,suspenseConfig:null,action:n,eagerReducer:null,eagerState:null,next:null},null===ji&&(ji=new Map),void 0===(n=ji.get(t)))ji.set(t,e);else{for(t=n;null!==t.next;)t=t.next;t.next=e}else{var i=Lo(),a=Yl.suspense;a={expirationTime:i=Ao(i,e,a),suspenseConfig:a,action:n,eagerReducer:null,eagerState:null,next:null};var o=t.last;if(null===o)a.next=a;else{var u=o.next;null!==u&&(a.next=u),o.next=a}if(t.last=a,0===e.expirationTime&&(null===l||0===l.expirationTime)&&null!==(l=t.lastRenderedReducer))try{var c=t.lastRenderedState,s=l(c,n);if(a.eagerReducer=l,a.eagerState=s,an(s,c))return}catch(f){}Vo(e,i)}}var ia={readContext:Dl,useCallback:Qi,useContext:Qi,useEffect:Qi,useImperativeHandle:Qi,useLayoutEffect:Qi,useMemo:Qi,useReducer:Qi,useRef:Qi,useState:Qi,useDebugValue:Qi,useResponder:Qi},aa={readContext:Dl,useCallback:function(e,t){return Yi().memoizedState=[e,void 0===t?null:t],e},useContext:Dl,useEffect:function(e,t){return ea(516,zi|Ni,e,t)},useImperativeHandle:function(e,t,n){return n=null!=n?n.concat([e]):null,ea(4,Ci|Pi,na.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ea(4,Ci|Pi,e,t)},useMemo:function(e,t){var n=Yi();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Yi();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e=(e=r.queue={last:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:t}).dispatch=la.bind(null,Ri,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},Yi().memoizedState=e},useState:function(e){var t=Yi();return"function"==typeof e&&(e=e()),t.memoizedState=t.baseState=e,e=(e=t.queue={last:null,dispatch:null,lastRenderedReducer:Gi,lastRenderedState:e}).dispatch=la.bind(null,Ri,e),[t.memoizedState,e]},useDebugValue:ra,useResponder:cn},oa={readContext:Dl,useCallback:function(e,t){var n=Xi();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&Ki(t,r[1])?r[0]:(n.memoizedState=[e,t],e)},useContext:Dl,useEffect:function(e,t){return ta(516,zi|Ni,e,t)},useImperativeHandle:function(e,t,n){return n=null!=n?n.concat([e]):null,ta(4,Ci|Pi,na.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ta(4,Ci|Pi,e,t)},useMemo:function(e,t){var n=Xi();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&Ki(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)},useReducer:Zi,useRef:function(){return Xi().memoizedState},useState:function(e){return Zi(Gi,e)},useDebugValue:ra,useResponder:cn},ua=null,ca=null,sa=!1;function fa(e,t){var n=mu(5,null,null,0);n.elementType="DELETED",n.type="DELETED",n.stateNode=t,n.return=e,n.effectTag=8,null!==e.lastEffect?(e.lastEffect.nextEffect=n,e.lastEffect=n):e.firstEffect=e.lastEffect=n}function da(e,t){switch(e.tag){case 5:var n=e.type;return null!==(t=1!==t.nodeType||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,!0);case 6:return null!==(t=""===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,!0);case 13:default:return!1}}function pa(e){if(sa){var t=ca;if(t){var n=t;if(!da(e,t)){if(!(t=Ir(n.nextSibling))||!da(e,t))return e.effectTag|=2,sa=!1,void(ua=e);fa(ua,n)}ua=e,ca=Ir(t.firstChild)}else e.effectTag|=2,sa=!1,ua=e}}function ha(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&18!==e.tag;)e=e.return;ua=e}function ma(e){if(e!==ua)return!1;if(!sa)return ha(e),sa=!0,!1;var t=e.type;if(5!==e.tag||"head"!==t&&"body"!==t&&!Ur(t,e.memoizedProps))for(t=ca;t;)fa(e,t),t=Ir(t.nextSibling);return ha(e),ca=ua?Ir(e.stateNode.nextSibling):null,!0}function ga(){ca=ua=null,sa=!1}var va=$e.ReactCurrentOwner,ya=!1;function ba(e,t,n,r){t.child=null===e?ui(t,null,n,r):oi(t,e.child,n,r)}function wa(e,t,n,r,l){n=n.render;var i=t.ref;return Il(t,l),r=$i(e,t,n,r,i,l),null===e||ya?(t.effectTag|=1,ba(e,t,r,l),t.child):(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=l&&(e.expirationTime=0),Ua(e,t,l))}function ka(e,t,n,r,l,i){if(null===e){var a=n.type;return"function"!=typeof a||gu(a)||void 0!==a.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=bu(n.type,null,r,null,t.mode,i)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=a,Ea(e,t,a,r,l,i))}return a=e.child,lt)&&Fo.set(e,t))}}function Bo(e,t){e.expirationTimel.firstPendingTime&&(l.firstPendingTime=t),0===(e=l.lastPendingTime)||t=t)&&(wl(97,function(){return n._onComplete(),null}),!0)}function $o(){if(null!==Fo){var e=Fo;Fo=null,e.forEach(function(e,t){kl(Zo.bind(null,t,e))}),El()}}function qo(e,t){var n=mo;mo|=1;try{return e(t)}finally{(mo=n)===io&&El()}}function Yo(e,t,n,r){var l=mo;mo|=4;try{return bl(98,e.bind(null,t,n,r))}finally{(mo=l)===io&&El()}}function Xo(e,t){var n=mo;mo&=-2,mo|=ao;try{return e(t)}finally{(mo=n)===io&&El()}}function Go(e,t){e.finishedWork=null,e.finishedExpirationTime=0;var n=e.timeoutHandle;if(-1!==n&&(e.timeoutHandle=-1,Fr(n)),null!==vo)for(n=vo.return;null!==n;){var r=n;switch(r.tag){case 1:var l=r.type.childContextTypes;null!=l&&Kr(r);break;case 3:mi(r),$r(r);break;case 5:vi(r);break;case 4:mi(r);break;case 13:case 19:Lr(ki,r);break;case 10:Rl(r)}n=n.return}go=e,vo=yu(e.current,null,t),yo=t,bo=co,ko=wo=1073741823,Eo=null,xo=!1}function Zo(e,t,n){if((mo&(oo|uo))!==io)throw r(Error(327));if(e.firstPendingTime component higher in the tree to provide a loading indicator or placeholder to display."+dt(c))}bo!==ho&&(bo=so),s=Wa(s,c),c=u;do{switch(c.tag){case 3:c.effectTag|=2048,c.expirationTime=f,jl(c,f=eo(c,s,f));break e;case 1:if(d=s,o=c.type,u=c.stateNode,0==(64&c.effectTag)&&("function"==typeof o.getDerivedStateFromError||null!==u&&"function"==typeof u.componentDidCatch&&(null===No||!No.has(u)))){c.effectTag|=2048,c.expirationTime=f,jl(c,f=to(c,d,f));break e}}c=c.return}while(null!==c)}vo=tu(a)}if(mo=l,Ml(),ro.current=i,null!==vo)return Zo.bind(null,e,t)}if(e.finishedWork=e.current.alternate,e.finishedExpirationTime=t,Ko(e,t))return null;switch(go=null,bo){case co:throw r(Error(328));case so:return(l=e.lastPendingTime)(n=(l=gl())-n)&&(n=0),(t=10*(1073741821-t)-l)<(n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*no(n/1960))-n)&&(n=t)),10=(t=0|(i=Eo).busyMinDurationMs)?t=0:(n=0|i.busyDelayMs,t=(l=gl()-(10*(1073741821-l)-(0|i.timeoutMs||5e3)))<=n?0:n+t-l),10<\/script>",d=f.removeChild(f.firstChild)):"string"==typeof l.is?d=d.createElement(f,{is:l.is}):(d=d.createElement(f),"select"===f&&(f=d,l.multiple?f.multiple=!0:l.size&&(f.size=l.size))):d=d.createElementNS(u,f),(f=d)[U]=c,f[R]=l,Fa(l=f,n,!1,!1),c=l;var p=i,h=Sr(o,a);switch(o){case"iframe":case"object":case"embed":Wn("load",c),i=a;break;case"video":case"audio":for(i=0;ia.tailExpiration&&1l&&(l=o),(c=a.childExpirationTime)>l&&(l=c),a=a.sibling;i.childExpirationTime=l}if(null!==n)return n;null!==e&&0==(1024&e.effectTag)&&(null===e.firstEffect&&(e.firstEffect=vo.firstEffect),null!==vo.lastEffect&&(null!==e.lastEffect&&(e.lastEffect.nextEffect=vo.firstEffect),e.lastEffect=vo.lastEffect),1i?a:i,e.firstPendingTime=i,iw&&(k=w,w=P,P=k),k=Yn(C,P),E=Yn(C,w),k&&E&&(1!==_.rangeCount||_.anchorNode!==k.node||_.anchorOffset!==k.offset||_.focusNode!==E.node||_.focusOffset!==E.offset)&&((S=S.createRange()).setStart(k.node,k.offset),_.removeAllRanges(),P>w?(_.addRange(S),_.extend(E.node,E.offset)):(S.setEnd(E.node,E.offset),_.addRange(S))))),S=[];for(_=C;_=_.parentNode;)1===_.nodeType&&S.push({element:_,left:_.scrollLeft,top:_.scrollTop});for("function"==typeof C.focus&&C.focus(),C=0;C=n?Na(e,t,n):(Ar(ki,ki.current&yi,t),null!==(t=Ua(e,t,n))?t.sibling:null);Ar(ki,ki.current&yi,t);break;case 19:if(l=t.childExpirationTime>=n,0!=(64&e.effectTag)){if(l)return Ma(e,t,n);t.effectTag|=64}if(null!==(i=t.memoizedState)&&(i.rendering=null,i.tail=null),Ar(ki,ki.current,t),!l)return null}return Ua(e,t,n)}}else ya=!1;switch(t.expirationTime=0,t.tag){case 2:if(l=t.type,null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,i=Hr(t,Vr.current),Il(t,n),i=$i(null,t,l,e,i,n),t.effectTag|=1,"object"==typeof i&&null!==i&&"function"==typeof i.render&&void 0===i.$$typeof){if(t.tag=1,qi(),Qr(l)){var a=!0;Xr(t)}else a=!1;t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null;var o=l.getDerivedStateFromProps;"function"==typeof o&&Gl(t,l,o,e),i.updater=Zl,t.stateNode=i,i._reactInternalFiber=t,ni(t,l,e,n),t=Sa(null,t,l,!0,a,n)}else t.tag=0,ba(null,t,i,n),t=t.child;return t;case 16:switch(i=t.elementType,null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,i=Sl(i),t.type=i,a=t.tag=vu(i),e=Cl(i,e),a){case 0:t=Ta(null,t,i,e,n);break;case 1:t=Ca(null,t,i,e,n);break;case 11:t=wa(null,t,i,e,n);break;case 14:t=ka(null,t,i,Cl(i.type,e),l,n);break;default:throw r(Error(306),i,"")}return t;case 0:return l=t.type,i=t.pendingProps,Ta(e,t,l,i=t.elementType===l?i:Cl(l,i),n);case 1:return l=t.type,i=t.pendingProps,Ca(e,t,l,i=t.elementType===l?i:Cl(l,i),n);case 3:if(_a(t),null===(l=t.updateQueue))throw r(Error(282));return i=null!==(i=t.memoizedState)?i.element:null,Kl(t,l,t.pendingProps,null,n),(l=t.memoizedState.element)===i?(ga(),t=Ua(e,t,n)):(i=t.stateNode,(i=(null===e||null===e.child)&&i.hydrate)&&(ca=Ir(t.stateNode.containerInfo.firstChild),ua=t,i=sa=!0),i?(t.effectTag|=2,t.child=ui(t,null,l,n)):(ba(e,t,l,n),ga()),t=t.child),t;case 5:return gi(t),null===e&&pa(t),l=t.type,i=t.pendingProps,a=null!==e?e.memoizedProps:null,o=i.children,Ur(l,i)?o=null:null!==a&&Ur(l,a)&&(t.effectTag|=16),xa(e,t),4&t.mode&&1!==n&&i.hidden?(t.expirationTime=t.childExpirationTime=1,t=null):(ba(e,t,o,n),t=t.child),t;case 6:return null===e&&pa(t),null;case 13:return Na(e,t,n);case 4:return hi(t,t.stateNode.containerInfo),l=t.pendingProps,null===e?t.child=oi(t,null,l,n):ba(e,t,l,n),t.child;case 11:return l=t.type,i=t.pendingProps,wa(e,t,l,i=t.elementType===l?i:Cl(l,i),n);case 7:return ba(e,t,t.pendingProps,n),t.child;case 8:case 12:return ba(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(l=t.type._context,i=t.pendingProps,o=t.memoizedProps,Ul(t,a=i.value),null!==o){var u=o.value;if(0===(a=an(u,a)?0:0|("function"==typeof l._calculateChangedBits?l._calculateChangedBits(u,a):1073741823))){if(o.children===i.children&&!Br.current){t=Ua(e,t,n);break e}}else for(null!==(u=t.child)&&(u.return=t);null!==u;){var c=u.dependencies;if(null!==c){o=u.child;for(var s=c.firstContext;null!==s;){if(s.context===l&&0!=(s.observedBits&a)){1===u.tag&&((s=Wl(n,null)).tag=2,Bl(u,s)),u.expirationTime=t;)n=r,r=r._next;e._next=r,null!==n&&(n._next=e)}return e},Re=qo,Fe=Yo,Ie=Qo,De=function(e,t){var n=mo;mo|=2;try{return e(t)}finally{(mo=n)===io&&El()}};var Ou={createPortal:Du,findDOMNode:function(e){if(null==e)e=null;else if(1!==e.nodeType){var t=e._reactInternalFiber;if(void 0===t){if("function"==typeof e.render)throw r(Error(188));throw r(Error(268),Object.keys(e))}e=null===(e=pn(t))?null:e.stateNode}return e},hydrate:function(e,t,n){if(!Ru(t))throw r(Error(200));return Iu(null,e,t,!0,n)},render:function(e,t,n){if(!Ru(t))throw r(Error(200));return Iu(null,e,t,!1,n)},unstable_renderSubtreeIntoContainer:function(e,t,n,l){if(!Ru(n))throw r(Error(200));if(null==e||void 0===e._reactInternalFiber)throw r(Error(38));return Iu(e,t,n,!1,l)},unmountComponentAtNode:function(e){if(!Ru(e))throw r(Error(40));return!!e._reactRootContainer&&(Xo(function(){Iu(null,null,e,!1,function(){e._reactRootContainer=null})}),!0)},unstable_createPortal:function(){return Du.apply(void 0,arguments)},unstable_batchedUpdates:qo,unstable_interactiveUpdates:function(e,t,n,r){return Qo(),Yo(e,t,n,r)},unstable_discreteUpdates:Yo,unstable_flushDiscreteUpdates:Qo,flushSync:function(e,t){if((mo&(oo|uo))!==io)throw r(Error(187));var n=mo;mo|=1;try{return bl(99,e.bind(null,t))}finally{mo=n,El()}},unstable_createRoot:Lu,unstable_createSyncRoot:Au,unstable_flushControlled:function(e){var t=mo;mo|=1;try{bl(99,e)}finally{(mo=t)===io&&El()}},__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{Events:[I,D,O,N.injectEventPluginsByName,c,j,function(e){C(e,B)},Me,Ue,Hn,P,lu,{current:!1}]}};function Lu(e,t){if(!Ru(e))throw r(Error(299),"unstable_createRoot");return new Uu(e,null!=t&&!0===t.hydrate)}function Au(e,t){if(!Ru(e))throw r(Error(299),"unstable_createRoot");return new Mu(e,1,null!=t&&!0===t.hydrate)}!function(e){var n=e.findFiberByHostInstance;pu(t({},e,{overrideHookState:null,overrideProps:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:$e.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=pn(e))?null:e.stateNode},findFiberByHostInstance:function(e){return n?n(e):null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null}))}({findFiberByHostInstance:F,bundleType:0,version:"16.9.0",rendererPackageName:"react-dom"});var Wu={default:Ou},Vu=Wu&&Ou||Wu;module.exports=Vu.default||Vu; +},{"react":"SAdv","object-assign":"0tLx","scheduler":"JlZK"}],"CSY6":[function(require,module,exports) { +"use strict";function _(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE){0;try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(_)}catch(O){console.error(O)}}}_(),module.exports=require("./cjs/react-dom.production.min.js"); +},{"./cjs/react-dom.production.min.js":"5i0G"}],"B7HP":[function(require,module,exports) { +"use strict";function t(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t; +},{}],"3pS0":[function(require,module,exports) { +function o(o,t){o.prototype=Object.create(t.prototype),o.prototype.constructor=o,o.__proto__=t}module.exports=o; +},{}],"7PB2":[function(require,module,exports) { +"use strict";var _="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";module.exports=_; +},{}],"632c":[function(require,module,exports) { +"use strict";var e=require("./lib/ReactPropTypesSecret");function r(){}function t(){}t.resetWarningCache=r,module.exports=function(){function n(r,t,n,o,a,p){if(p!==e){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function o(){return n}n.isRequired=n;var a={array:n,bool:n,func:n,number:n,object:n,string:n,symbol:n,any:n,arrayOf:o,element:n,elementType:n,instanceOf:o,node:n,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:t,resetWarningCache:r};return a.PropTypes=a,a}; +},{"./lib/ReactPropTypesSecret":"7PB2"}],"yu5W":[function(require,module,exports) { +var r,e;module.exports=require("./factoryWithThrowingShims")(); +},{"./factoryWithThrowingShims":"632c"}],"29ln":[function(require,module,exports) { +var global = arguments[3]; +var u=arguments[3],_="__global_unique_id__";module.exports=function(){return u[_]=(u[_]||0)+1}; +},{}],"Gdxp":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=!0;function r(r,t){if(!e){if(r)return;var o="Warning: "+t;"undefined"!=typeof console&&console.warn(o);try{throw Error(o)}catch(n){}}}var t=r;exports.default=t; +},{}],"7nu8":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=u(require("react")),e=i(require("@babel/runtime/helpers/inheritsLoose")),r=i(require("prop-types")),n=i(require("gud")),o=i(require("tiny-warning"));function i(t){return t&&t.__esModule?t:{default:t}}function u(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var n=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(t,r):{};n.get||n.set?Object.defineProperty(e,r,n):e[r]=t[r]}return e.default=t,e}var s=1073741823;function c(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}function a(t){var e=[];return{on:function(t){e.push(t)},off:function(t){e=e.filter(function(e){return e!==t})},get:function(){return t},set:function(r,n){t=r,e.forEach(function(e){return e(t,n)})}}}function p(t){return Array.isArray(t)?t[0]:t}function f(o,i){var u,f,l="__create-react-context-"+(0,n.default)()+"__",v=function(t){function r(){var e;return(e=t.apply(this,arguments)||this).emitter=a(e.props.value),e}(0,e.default)(r,t);var n=r.prototype;return n.getChildContext=function(){var t;return(t={})[l]=this.emitter,t},n.componentWillReceiveProps=function(t){if(this.props.value!==t.value){var e,r=this.props.value,n=t.value;c(r,n)?e=0:(e="function"==typeof i?i(r,n):s,0!==(e|=0)&&this.emitter.set(t.value,e))}},n.render=function(){return this.props.children},r}(t.Component);v.childContextTypes=((u={})[l]=r.default.object.isRequired,u);var d=function(t){function r(){var e;return(e=t.apply(this,arguments)||this).state={value:e.getValue()},e.onUpdate=function(t,r){0!=((0|e.observedBits)&r)&&e.setState({value:e.getValue()})},e}(0,e.default)(r,t);var n=r.prototype;return n.componentWillReceiveProps=function(t){var e=t.observedBits;this.observedBits=null==e?s:e},n.componentDidMount=function(){this.context[l]&&this.context[l].on(this.onUpdate);var t=this.props.observedBits;this.observedBits=null==t?s:t},n.componentWillUnmount=function(){this.context[l]&&this.context[l].off(this.onUpdate)},n.getValue=function(){return this.context[l]?this.context[l].get():o},n.render=function(){return p(this.props.children)(this.state.value)},r}(t.Component);return d.contextTypes=((f={})[l]=r.default.object,f),{Provider:v,Consumer:d}}var l=t.default.createContext||f,v=l;exports.default=v; +},{"react":"SAdv","@babel/runtime/helpers/inheritsLoose":"3pS0","prop-types":"yu5W","gud":"29ln","tiny-warning":"Gdxp"}],"eFhb":[function(require,module,exports) { +"use strict";function e(){return exports.default=e=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:"",o=r&&r.split("/")||[],i=n&&n.split("/")||[],f=r&&t(r),l=n&&t(n),u=f||l;if(r&&t(r)?i=o:o.length&&(i.pop(),i=i.concat(o)),!i.length)return"/";var a=void 0;if(i.length){var s=i[i.length-1];a="."===s||".."===s||""===s}else a=!1;for(var v=0,h=i.length;h>=0;h--){var p=i[h];"."===p?e(i,h):".."===p?(e(i,h),v++):v&&(e(i,h),v--)}if(!u)for(;v--;v)i.unshift("..");!u||""===i[0]||i[0]&&t(i[0])||i.unshift("");var c=i.join("/");return a&&"/"!==c.substr(-1)&&(c+="/"),c}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var n=r;exports.default=n; +},{}],"bzK/":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function r(t,n){if(t===n)return!0;if(null==t||null==n)return!1;if(Array.isArray(t))return Array.isArray(n)&&t.length===n.length&&t.every(function(e,t){return r(e,n[t])});var o=void 0===t?"undefined":e(t);if(o!==(void 0===n?"undefined":e(n)))return!1;if("object"===o){var u=t.valueOf(),f=n.valueOf();if(u!==t||f!==n)return r(u,f);var i=Object.keys(t),y=Object.keys(n);return i.length===y.length&&i.every(function(e){return r(t[e],n[e])})}return!1}var t=r;exports.default=t; +},{}],"XpeU":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=!0,r="Invariant failed";function t(t,o){if(!t)throw e?new Error(r):new Error(r+": "+(o||""))}var o=t;exports.default=o; +},{}],"s9Ic":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createBrowserHistory=b,exports.createHashHistory=U,exports.createMemoryHistory=R,exports.createLocation=l,exports.locationsAreEqual=v,exports.parsePath=h,exports.createPath=d;var n=r(require("@babel/runtime/helpers/esm/extends")),t=r(require("resolve-pathname")),e=r(require("value-equal")),o=r(require("tiny-warning")),i=r(require("tiny-invariant"));function r(n){return n&&n.__esModule?n:{default:n}}function a(n){return"/"===n.charAt(0)?n:"/"+n}function c(n){return"/"===n.charAt(0)?n.substr(1):n}function u(n,t){return new RegExp("^"+t+"(\\/|\\?|#|$)","i").test(n)}function s(n,t){return u(n,t)?n.substr(t.length):n}function f(n){return"/"===n.charAt(n.length-1)?n.slice(0,-1):n}function h(n){var t=n||"/",e="",o="",i=t.indexOf("#");-1!==i&&(o=t.substr(i),t=t.substr(0,i));var r=t.indexOf("?");return-1!==r&&(e=t.substr(r),t=t.substr(0,r)),{pathname:t,search:"?"===e?"":e,hash:"#"===o?"":o}}function d(n){var t=n.pathname,e=n.search,o=n.hash,i=t||"/";return e&&"?"!==e&&(i+="?"===e.charAt(0)?e:"?"+e),o&&"#"!==o&&(i+="#"===o.charAt(0)?o:"#"+o),i}function l(e,o,i,r){var a;"string"==typeof e?(a=h(e)).state=o:(void 0===(a=(0,n.default)({},e)).pathname&&(a.pathname=""),a.search?"?"!==a.search.charAt(0)&&(a.search="?"+a.search):a.search="",a.hash?"#"!==a.hash.charAt(0)&&(a.hash="#"+a.hash):a.hash="",void 0!==o&&void 0===a.state&&(a.state=o));try{a.pathname=decodeURI(a.pathname)}catch(c){throw c instanceof URIError?new URIError('Pathname "'+a.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):c}return i&&(a.key=i),r?a.pathname?"/"!==a.pathname.charAt(0)&&(a.pathname=(0,t.default)(a.pathname,r.pathname)):a.pathname=r.pathname:a.pathname||(a.pathname="/"),a}function v(n,t){return n.pathname===t.pathname&&n.search===t.search&&n.hash===t.hash&&n.key===t.key&&(0,e.default)(n.state,t.state)}function p(){var n=null;var t=[];return{setPrompt:function(t){return n=t,function(){n===t&&(n=null)}},confirmTransitionTo:function(t,e,o,i){if(null!=n){var r="function"==typeof n?n(t,e):n;"string"==typeof r?"function"==typeof o?o(r,i):i(!0):i(!1!==r)}else i(!0)},appendListener:function(n){var e=!0;function o(){e&&n.apply(void 0,arguments)}return t.push(o),function(){e=!1,t=t.filter(function(n){return n!==o})}},notifyListeners:function(){for(var n=arguments.length,e=new Array(n),o=0;o=0?t:0)+"#"+n)}function U(t){void 0===t&&(t={}),w||(0,i.default)(!1);var e=window.history,o=(P(),t),r=o.getUserConfirmation,c=void 0===r?m:r,u=o.hashType,h=void 0===u?"slash":u,g=t.basename?f(a(t.basename)):"",y=L[h],x=y.encodePath,O=y.decodePath;function k(){var n=O(T());return g&&(n=s(n,g)),l(n)}var E=p();function b(t){(0,n.default)(W,t),W.length=e.length,E.notifyListeners(W.location,W.action)}var U=!1,C=null;function R(){var n=T(),t=x(n);if(n!==t)S(t);else{var e=k(),o=W.location;if(!U&&v(o,e))return;if(C===d(e))return;C=null,function(n){if(U)U=!1,b();else{E.confirmTransitionTo(n,"POP",c,function(t){t?b({action:"POP",location:n}):function(n){var t=W.location,e=B.lastIndexOf(d(t));-1===e&&(e=0);var o=B.lastIndexOf(d(n));-1===o&&(o=0);var i=e-o;i&&(U=!0,F(i))}(n)})}}(e)}}var M=T(),q=x(M);M!==q&&S(q);var I=k(),B=[d(I)];function F(n){e.go(n)}var _=0;function j(n){1===(_+=n)&&1===n?window.addEventListener(A,R):0===_&&window.removeEventListener(A,R)}var G=!1;var W={length:e.length,action:"POP",location:I,createHref:function(n){return"#"+x(g+d(n))},push:function(n,t){var e=l(n,void 0,void 0,W.location);E.confirmTransitionTo(e,"PUSH",c,function(n){if(n){var t=d(e),o=x(g+t);if(T()!==o){C=t,H(o);var i=B.lastIndexOf(d(W.location)),r=B.slice(0,-1===i?0:i+1);r.push(t),B=r,b({action:"PUSH",location:e})}else b()}})},replace:function(n,t){var e=l(n,void 0,void 0,W.location);E.confirmTransitionTo(e,"REPLACE",c,function(n){if(n){var t=d(e),o=x(g+t);T()!==o&&(C=t,S(o));var i=B.indexOf(d(W.location));-1!==i&&(B[i]=t),b({action:"REPLACE",location:e})}})},go:F,goBack:function(){F(-1)},goForward:function(){F(1)},block:function(n){void 0===n&&(n=!1);var t=E.setPrompt(n);return G||(j(1),G=!0),function(){return G&&(G=!1,j(-1)),t()}},listen:function(n){var t=E.appendListener(n);return j(1),function(){j(-1),t()}}};return W}function C(n,t,e){return Math.min(Math.max(n,t),e)}function R(t){void 0===t&&(t={});var e=t,o=e.getUserConfirmation,i=e.initialEntries,r=void 0===i?["/"]:i,a=e.initialIndex,c=void 0===a?0:a,u=e.keyLength,s=void 0===u?6:u,f=p();function h(t){(0,n.default)(P,t),P.length=P.entries.length,f.notifyListeners(P.location,P.action)}function v(){return Math.random().toString(36).substr(2,s)}var w=C(c,0,r.length-1),m=r.map(function(n){return l(n,void 0,"string"==typeof n?v():n.key||v())}),g=d;function y(n){var t=C(P.index+n,0,P.entries.length-1),e=P.entries[t];f.confirmTransitionTo(e,"POP",o,function(n){n?h({action:"POP",location:e,index:t}):h()})}var P={length:m.length,action:"POP",location:m[w],index:w,entries:m,createHref:g,push:function(n,t){var e=l(n,t,v(),P.location);f.confirmTransitionTo(e,"PUSH",o,function(n){if(n){var t=P.index+1,o=P.entries.slice(0);o.length>t?o.splice(t,o.length-t,e):o.push(e),h({action:"PUSH",location:e,index:t,entries:o})}})},replace:function(n,t){var e=l(n,t,v(),P.location);f.confirmTransitionTo(e,"REPLACE",o,function(n){n&&(P.entries[P.index]=e,h({action:"REPLACE",location:e}))})},go:y,goBack:function(){y(-1)},goForward:function(){y(1)},canGo:function(n){var t=P.index+n;return t>=0&&t=0||(u[r]=e[r]);return u}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e; +},{}],"Ingc":[function(require,module,exports) { +"use strict";var e=require("react-is"),t={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},r={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},o={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},p={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},a={};function y(r){return e.isMemo(r)?p:a[r.$$typeof]||t}a[e.ForwardRef]=o;var s=Object.defineProperty,n=Object.getOwnPropertyNames,c=Object.getOwnPropertySymbols,i=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,l=Object.prototype;function d(e,t,o){if("string"!=typeof t){if(l){var p=f(t);p&&p!==l&&d(e,p,o)}var a=n(t);c&&(a=a.concat(c(t)));for(var m=y(e),u=y(t),g=0;g0?r:o)(t)}; +},{}],"mVdD":[function(require,module,exports) { +var e=require("./_to-integer"),r=Math.max,t=Math.min;module.exports=function(n,a){return(n=e(n))<0?r(n+a,0):t(n,a)}; +},{"./_to-integer":"rqGZ"}],"rKjT":[function(require,module,exports) { +var e=require("./_to-integer"),r=Math.min;module.exports=function(t){return t>0?r(e(t),9007199254740991):0}; +},{"./_to-integer":"rqGZ"}],"dUOO":[function(require,module,exports) { +"use strict";var e=require("./_to-object"),t=require("./_to-absolute-index"),i=require("./_to-length");module.exports=[].copyWithin||function(r,o){var n=e(this),u=i(n.length),h=t(r,u),l=t(o,u),d=arguments.length>2?arguments[2]:void 0,s=Math.min((void 0===d?u:t(d,u))-l,u-h),a=1;for(l0;)l in n?n[h]=n[l]:delete n[h],h+=a,l+=a;return n}; +},{"./_to-object":"loGD","./_to-absolute-index":"mVdD","./_to-length":"rKjT"}],"hdTv":[function(require,module,exports) { +var e=require("./_shared")("wks"),r=require("./_uid"),o=require("./_global").Symbol,u="function"==typeof o,i=module.exports=function(i){return e[i]||(e[i]=u&&o[i]||(u?o:r)("Symbol."+i))};i.store=e; +},{"./_shared":"dbww","./_uid":"yoHo","./_global":"h3Gt"}],"OFDF":[function(require,module,exports) { +var e=require("./_wks")("unscopables"),r=Array.prototype;null==r[e]&&require("./_hide")(r,e,{}),module.exports=function(o){r[e][o]=!0}; +},{"./_wks":"hdTv","./_hide":"rIu9"}],"s95x":[function(require,module,exports) { +var r=require("./_export");r(r.P,"Array",{copyWithin:require("./_array-copy-within")}),require("./_add-to-unscopables")("copyWithin"); +},{"./_export":"L1Pz","./_array-copy-within":"dUOO","./_add-to-unscopables":"OFDF"}],"avvw":[function(require,module,exports) { +"use strict";var e=require("./_to-object"),t=require("./_to-absolute-index"),r=require("./_to-length");module.exports=function(o){for(var i=e(this),u=r(i.length),n=arguments.length,d=t(n>1?arguments[1]:void 0,u),l=n>2?arguments[2]:void 0,s=void 0===l?u:t(l,u);s>d;)i[d++]=o;return i}; +},{"./_to-object":"loGD","./_to-absolute-index":"mVdD","./_to-length":"rKjT"}],"JMur":[function(require,module,exports) { +var r=require("./_export");r(r.P,"Array",{fill:require("./_array-fill")}),require("./_add-to-unscopables")("fill"); +},{"./_export":"L1Pz","./_array-fill":"avvw","./_add-to-unscopables":"OFDF"}],"6fDU":[function(require,module,exports) { +var r={}.toString;module.exports=function(t){return r.call(t).slice(8,-1)}; +},{}],"SGIP":[function(require,module,exports) { +var e=require("./_cof");module.exports=Object("z").propertyIsEnumerable(0)?Object:function(r){return"String"==e(r)?r.split(""):Object(r)}; +},{"./_cof":"6fDU"}],"2HaH":[function(require,module,exports) { +var r=require("./_cof");module.exports=Array.isArray||function(e){return"Array"==r(e)}; +},{"./_cof":"6fDU"}],"FPEW":[function(require,module,exports) { +var r=require("./_is-object"),e=require("./_is-array"),o=require("./_wks")("species");module.exports=function(i){var t;return e(i)&&("function"!=typeof(t=i.constructor)||t!==Array&&!e(t.prototype)||(t=void 0),r(t)&&null===(t=t[o])&&(t=void 0)),void 0===t?Array:t}; +},{"./_is-object":"Hb36","./_is-array":"2HaH","./_wks":"hdTv"}],"zgnn":[function(require,module,exports) { +var r=require("./_array-species-constructor");module.exports=function(e,n){return new(r(e))(n)}; +},{"./_array-species-constructor":"FPEW"}],"R7oH":[function(require,module,exports) { +var e=require("./_ctx"),r=require("./_iobject"),t=require("./_to-object"),i=require("./_to-length"),u=require("./_array-species-create");module.exports=function(n,c){var s=1==n,a=2==n,o=3==n,f=4==n,l=6==n,q=5==n||l,_=c||u;return function(u,c,h){for(var v,p,b=t(u),d=r(b),g=e(c,h,3),j=i(d.length),x=0,m=s?_(u,j):a?_(u,0):void 0;j>x;x++)if((q||x in d)&&(p=g(v=d[x],x,b),n))if(s)m[x]=p;else if(p)switch(n){case 3:return!0;case 5:return v;case 6:return x;case 2:m.push(v)}else if(f)return!1;return l?-1:o||f?f:m}}; +},{"./_ctx":"x6Uu","./_iobject":"SGIP","./_to-object":"loGD","./_to-length":"rKjT","./_array-species-create":"zgnn"}],"DVgS":[function(require,module,exports) { +"use strict";var r=require("./_export"),e=require("./_array-methods")(5),i="find",n=!0;i in[]&&Array(1)[i](function(){n=!1}),r(r.P+r.F*n,"Array",{find:function(r){return e(this,r,arguments.length>1?arguments[1]:void 0)}}),require("./_add-to-unscopables")(i); +},{"./_export":"L1Pz","./_array-methods":"R7oH","./_add-to-unscopables":"OFDF"}],"sQB3":[function(require,module,exports) { +"use strict";var r=require("./_export"),e=require("./_array-methods")(6),n="findIndex",i=!0;n in[]&&Array(1)[n](function(){i=!1}),r(r.P+r.F*i,"Array",{findIndex:function(r){return e(this,r,arguments.length>1?arguments[1]:void 0)}}),require("./_add-to-unscopables")(n); +},{"./_export":"L1Pz","./_array-methods":"R7oH","./_add-to-unscopables":"OFDF"}],"ZUj+":[function(require,module,exports) { +var r=require("./_an-object");module.exports=function(t,e,o,a){try{return a?e(r(o)[0],o[1]):e(o)}catch(n){var c=t.return;throw void 0!==c&&r(c.call(t)),n}}; +},{"./_an-object":"gBlm"}],"M4Qf":[function(require,module,exports) { +module.exports={}; +},{}],"P7X6":[function(require,module,exports) { +var r=require("./_iterators"),e=require("./_wks")("iterator"),t=Array.prototype;module.exports=function(o){return void 0!==o&&(r.Array===o||t[e]===o)}; +},{"./_iterators":"M4Qf","./_wks":"hdTv"}],"SlOi":[function(require,module,exports) { +"use strict";var e=require("./_object-dp"),r=require("./_property-desc");module.exports=function(t,i,o){i in t?e.f(t,i,r(0,o)):t[i]=o}; +},{"./_object-dp":"hYd+","./_property-desc":"BqL0"}],"dcYf":[function(require,module,exports) { +var e=require("./_cof"),t=require("./_wks")("toStringTag"),n="Arguments"==e(function(){return arguments}()),r=function(e,t){try{return e[t]}catch(n){}};module.exports=function(u){var o,c,i;return void 0===u?"Undefined":null===u?"Null":"string"==typeof(c=r(o=Object(u),t))?c:n?e(o):"Object"==(i=e(o))&&"function"==typeof o.callee?"Arguments":i}; +},{"./_cof":"6fDU","./_wks":"hdTv"}],"28ek":[function(require,module,exports) { +var r=require("./_classof"),e=require("./_wks")("iterator"),t=require("./_iterators");module.exports=require("./_core").getIteratorMethod=function(o){if(null!=o)return o[e]||o["@@iterator"]||t[r(o)]}; +},{"./_classof":"dcYf","./_wks":"hdTv","./_iterators":"M4Qf","./_core":"HIea"}],"wLNg":[function(require,module,exports) { +var r=require("./_wks")("iterator"),t=!1;try{var n=[7][r]();n.return=function(){t=!0},Array.from(n,function(){throw 2})}catch(e){}module.exports=function(n,u){if(!u&&!t)return!1;var o=!1;try{var c=[7],a=c[r]();a.next=function(){return{done:o=!0}},c[r]=function(){return a},n(c)}catch(e){}return o}; +},{"./_wks":"hdTv"}],"uV/T":[function(require,module,exports) { +"use strict";var e=require("./_ctx"),r=require("./_export"),t=require("./_to-object"),i=require("./_iter-call"),o=require("./_is-array-iter"),u=require("./_to-length"),n=require("./_create-property"),a=require("./core.get-iterator-method");r(r.S+r.F*!require("./_iter-detect")(function(e){Array.from(e)}),"Array",{from:function(r){var l,c,f,q,_=t(r),h="function"==typeof this?this:Array,v=arguments.length,y=v>1?arguments[1]:void 0,d=void 0!==y,s=0,g=a(_);if(d&&(y=e(y,v>2?arguments[2]:void 0,2)),null==g||h==Array&&o(g))for(c=new h(l=u(_.length));l>s;s++)n(c,s,d?y(_[s],s):_[s]);else for(q=g.call(_),c=new h;!(f=q.next()).done;s++)n(c,s,d?i(q,y,[f.value,s],!0):f.value);return c.length=s,c}}); +},{"./_ctx":"x6Uu","./_export":"L1Pz","./_to-object":"loGD","./_iter-call":"ZUj+","./_is-array-iter":"P7X6","./_to-length":"rKjT","./_create-property":"SlOi","./core.get-iterator-method":"28ek","./_iter-detect":"wLNg"}],"h4Pq":[function(require,module,exports) { +var e=require("./_iobject"),r=require("./_defined");module.exports=function(i){return e(r(i))}; +},{"./_iobject":"SGIP","./_defined":"iw5+"}],"qnvW":[function(require,module,exports) { +var e=require("./_to-iobject"),r=require("./_to-length"),t=require("./_to-absolute-index");module.exports=function(n){return function(i,o,u){var f,l=e(i),a=r(l.length),c=t(u,a);if(n&&o!=o){for(;a>c;)if((f=l[c++])!=f)return!0}else for(;a>c;c++)if((n||c in l)&&l[c]===o)return n||c||0;return!n&&-1}}; +},{"./_to-iobject":"h4Pq","./_to-length":"rKjT","./_to-absolute-index":"mVdD"}],"XhQx":[function(require,module,exports) { +"use strict";var r=require("./_export"),e=require("./_array-includes")(!0);r(r.P,"Array",{includes:function(r){return e(this,r,arguments.length>1?arguments[1]:void 0)}}),require("./_add-to-unscopables")("includes"); +},{"./_export":"L1Pz","./_array-includes":"qnvW","./_add-to-unscopables":"OFDF"}],"yfm4":[function(require,module,exports) { +module.exports=function(e,n){return{value:n,done:!!e}}; +},{}],"HO+o":[function(require,module,exports) { +var e=require("./_shared")("keys"),r=require("./_uid");module.exports=function(u){return e[u]||(e[u]=r(u))}; +},{"./_shared":"dbww","./_uid":"yoHo"}],"/1XJ":[function(require,module,exports) { +var r=require("./_has"),e=require("./_to-iobject"),u=require("./_array-includes")(!1),i=require("./_shared-key")("IE_PROTO");module.exports=function(o,a){var n,s=e(o),t=0,h=[];for(n in s)n!=i&&r(s,n)&&h.push(n);for(;a.length>t;)r(s,n=a[t++])&&(~u(h,n)||h.push(n));return h}; +},{"./_has":"ROQC","./_to-iobject":"h4Pq","./_array-includes":"qnvW","./_shared-key":"HO+o"}],"/EVN":[function(require,module,exports) { +module.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","); +},{}],"nr8P":[function(require,module,exports) { +var e=require("./_object-keys-internal"),r=require("./_enum-bug-keys");module.exports=Object.keys||function(u){return e(u,r)}; +},{"./_object-keys-internal":"/1XJ","./_enum-bug-keys":"/EVN"}],"+17n":[function(require,module,exports) { +var e=require("./_object-dp"),r=require("./_an-object"),t=require("./_object-keys");module.exports=require("./_descriptors")?Object.defineProperties:function(o,i){r(o);for(var u,c=t(i),n=c.length,s=0;n>s;)e.f(o,u=c[s++],i[u]);return o}; +},{"./_object-dp":"hYd+","./_an-object":"gBlm","./_object-keys":"nr8P","./_descriptors":"+1KZ"}],"20Vv":[function(require,module,exports) { +var e=require("./_global").document;module.exports=e&&e.documentElement; +},{"./_global":"h3Gt"}],"z2NO":[function(require,module,exports) { +var e=require("./_an-object"),r=require("./_object-dps"),t=require("./_enum-bug-keys"),n=require("./_shared-key")("IE_PROTO"),o=function(){},i="prototype",u=function(){var e,r=require("./_dom-create")("iframe"),n=t.length;for(r.style.display="none",require("./_html").appendChild(r),r.src="javascript:",(e=r.contentWindow.document).open(),e.write("
\ No newline at end of file diff --git a/dist/public/checkout.69dcbd03.css b/dist/public/checkout.69dcbd03.css new file mode 100644 index 00000000..727e0fab --- /dev/null +++ b/dist/public/checkout.69dcbd03.css @@ -0,0 +1,8 @@ +@keyframes spin { + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } +} + +/*# sourceMappingURL=/checkout.69dcbd03.css.map */ \ No newline at end of file diff --git a/dist/public/checkout.69dcbd03.css.map b/dist/public/checkout.69dcbd03.css.map new file mode 100644 index 00000000..e2c75448 --- /dev/null +++ b/dist/public/checkout.69dcbd03.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["checkout.css"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA","file":"checkout.69dcbd03.css","sourceRoot":"..\\..\\src\\public\\payments","sourcesContent":["@keyframes spin {\r\n 100% { \r\n -webkit-transform: rotate(360deg);\r\n transform: rotate(360deg);\r\n }\r\n}"]} \ No newline at end of file diff --git a/dist/public/checkout.69dcbd03.js b/dist/public/checkout.69dcbd03.js new file mode 100644 index 00000000..464d90cc --- /dev/null +++ b/dist/public/checkout.69dcbd03.js @@ -0,0 +1,396 @@ +// modules are defined as an array +// [ module function, map of requires ] +// +// map of requires is short require name -> numeric require +// +// anything defined in a previous bundle is accessed via the +// orig method which is the require for previous bundles +parcelRequire = (function (modules, cache, entry, globalName) { + // Save the require from previous bundle to this closure if any + var previousRequire = typeof parcelRequire === 'function' && parcelRequire; + var nodeRequire = typeof require === 'function' && require; + + function newRequire(name, jumped) { + if (!cache[name]) { + if (!modules[name]) { + // if we cannot find the module within our internal map or + // cache jump to the current global require ie. the last bundle + // that was added to the page. + var currentRequire = typeof parcelRequire === 'function' && parcelRequire; + if (!jumped && currentRequire) { + return currentRequire(name, true); + } + + // If there are other bundles on this page the require from the + // previous one is saved to 'previousRequire'. Repeat this as + // many times as there are bundles until the module is found or + // we exhaust the require chain. + if (previousRequire) { + return previousRequire(name, true); + } + + // Try the node require function if it exists. + if (nodeRequire && typeof name === 'string') { + return nodeRequire(name); + } + + var err = new Error('Cannot find module \'' + name + '\''); + err.code = 'MODULE_NOT_FOUND'; + throw err; + } + + localRequire.resolve = resolve; + localRequire.cache = {}; + + var module = cache[name] = new newRequire.Module(name); + + modules[name][0].call(module.exports, localRequire, module, module.exports, this); + } + + return cache[name].exports; + + function localRequire(x){ + return newRequire(localRequire.resolve(x)); + } + + function resolve(x){ + return modules[name][1][x] || x; + } + } + + function Module(moduleName) { + this.id = moduleName; + this.bundle = newRequire; + this.exports = {}; + } + + newRequire.isParcelRequire = true; + newRequire.Module = Module; + newRequire.modules = modules; + newRequire.cache = cache; + newRequire.parent = previousRequire; + newRequire.register = function (id, exports) { + modules[id] = [function (require, module) { + module.exports = exports; + }, {}]; + }; + + var error; + for (var i = 0; i < entry.length; i++) { + try { + newRequire(entry[i]); + } catch (e) { + // Save first error but execute all entries + if (!error) { + error = e; + } + } + } + + if (entry.length) { + // Expose entry point to Node, AMD or browser globals + // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js + var mainExports = newRequire(entry[entry.length - 1]); + + // CommonJS + if (typeof exports === "object" && typeof module !== "undefined") { + module.exports = mainExports; + + // RequireJS + } else if (typeof define === "function" && define.amd) { + define(function () { + return mainExports; + }); + + //