{"version":3,"sources":["jsdelivr-header.js","/npm/dynamic-html-pdf@1.0.4/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACQA,IAAI,WAAa,QAAQ,cACrB,IAAM,QAAQ,YAGlB,OAAO,QAAQ,eAAiB,CAAC,EAAe,KAC5C,WAAW,eAAe,EAAe,EAAS,EAGtD,OAAO,QAAQ,OAAS,CAAC,EAAU,IAExB,IAAI,SAAQ,CAAC,EAAS,KAEpB,GAAa,EAAS,UAAa,EAAS,SAC7C,EAAO,IAAI,MAAM,uCAGC,WAAlB,EAAS,MAAsB,EAAS,MACxC,EAAO,IAAI,MAAM,8GAGrB,IAAI,EAAO,WAAW,QAAQ,EAAS,SAA5B,CAAsC,EAAS,SACtD,EAAa,IAAI,OAAO,EAAM,GACZ,WAAlB,EAAS,KAGT,EAAW,UAAS,CAAC,EAAK,KACjB,EAGD,EAAO,GAFP,EAAQ,EAEG,IAKnB,EAAW,OAAO,EAAS,MAAM,CAAC,EAAK,KAC9B,EAGD,EAAO,GAFP,EAAQ,EAEG,GAEvB","file":"/npm/dynamic-html-pdf@1.0.4/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/dynamic-html-pdf@1.0.4/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * dynamic-handlebar-pdf\n *\n *\n * Copyright (c) 2017 Navjot Dhanawat\n * Licensed under the MIT license.\n */\n\n/**\n * Dynamic handlebars pdf is used to create pdf from handlebar templates.\n * @param  {document, options}\n * @return {callback}\n */\n\nvar Handlebars = require('handlebars'),\n    pdf = require('html-pdf');\n\n// Handlebar helper support\nmodule.exports.registerHelper = (conditionName, callback) => {\n    Handlebars.registerHelper(conditionName, callback);\n};\n\nmodule.exports.create = (document, options) => {\n    // Compile handlebar template\n    return new Promise((resolve, reject) => {\n\n        if (!document || !document.template || !document.context) {\n            reject(new Error(\"Some, or all, options are missing.\"));\n        }\n\n        if (document.type !== 'buffer' && !document.path) {\n            reject(new Error(\"Please provide path parameter to save file or if you want buffer as output give parameter type = 'buffer'\"));\n        }\n\n        var html = Handlebars.compile(document.template)(document.context);\n        var pdfPromise = pdf.create(html, options);\n        if (document.type === 'buffer') {\n            // Create PDF from html template generated by handlebars\n            //Output will be buffer\n            pdfPromise.toBuffer((err, buff) => {\n                if (!err)\n                    resolve(buff);\n                else\n                    reject(err);\n            });\n        } else {\n            // Create PDF from html template generated by handlebars\n            // Output will be PDF file\n            pdfPromise.toFile(document.path, (err, res) => {\n                if (!err)\n                    resolve(res);\n                else\n                    reject(err);\n            });\n        }\n    });\n};\n"]}