const html = require('choo/html'); const assets = require('../../common/assets'); const notFound = require('./notFound'); const downloadPassword = require('./downloadPassword'); const { bytes } = require('../utils'); const fxPromo = require('./fxPromo'); function getFileFromDOM() { const el = document.getElementById('dl-file'); if (!el) { return null; } return { nonce: el.getAttribute('data-nonce'), pwd: !!+el.getAttribute('data-requires-password') }; } module.exports = function(state, emit) { state.fileInfo = state.fileInfo || getFileFromDOM(); if (!state.fileInfo) { return notFound(state, emit); } state.fileInfo.id = state.params.id; state.fileInfo.key = state.params.key; const fileInfo = state.fileInfo; const size = fileInfo.size ? state.translate('downloadFileSize', { size: bytes(fileInfo.size) }) : ''; let action = html`