"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = exports.crawl = void 0;
const cheerio_1 = require("cheerio");
const lib_1 = require("../lib");
const crawl = (word) => {
    return (0, lib_1.request)({
        protocol: 'https',
        hostname: 'sjp.pl',
        path: `/${encodeURIComponent(word)}`,
    });
};
exports.crawl = crawl;
const parse = (html) => {
    const $ = (0, cheerio_1.load)(html);
    const $header = $($('h1')[0]);
    const $isAllowed = $header.next();
    const $definitions = $header.next().next().next().next();
    return {
        definitions: $definitions.text().trim().split(/\d+\./),
        exists: $isAllowed.text().trim().indexOf('dopuszczalne w grach') >= 0,
    };
};
exports.parse = parse;
