'use strict';

const __chunk_1 = require('./chunk-91f43df3.js');

function getMap(id) {
    return document.querySelector((id) ? `gl-map#${id}` : 'gl-map');
}
function getThumbnail(item) {
    if (item.image)
        return (__chunk_1.h("ion-thumbnail", { slot: "start" },
            __chunk_1.h("img", { src: item.image })));
}
function toArray(value, sep = ',') {
    if (!value)
        return [];
    if (Array.isArray(value))
        return value;
    return value.split(sep);
}
// Based on: https://davidwalsh.name/get-absolute-url
const getAbsoluteUrl = (function () {
    let a;
    return function (url) {
        if (!a)
            a = document.createElement('a');
        a.href = url;
        return a.href;
    };
})();
async function fetchPdf(url, filename, docDef) {
    let res = await fetch(url + filename, {
        method: 'POST',
        mode: 'cors',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(docDef)
    });
    let blob = await res.blob();
    if (window.navigator.msSaveOrOpenBlob) {
        window.navigator.msSaveOrOpenBlob(blob, `${filename}.pdf`);
    }
    else {
        window.open(window.URL.createObjectURL(blob));
    }
}

exports.fetchPdf = fetchPdf;
exports.getAbsoluteUrl = getAbsoluteUrl;
exports.getMap = getMap;
exports.getThumbnail = getThumbnail;
exports.toArray = toArray;
