UNPKG

osm-community-index

Version:

An index of community resources for OpenStreetMap

561 lines (555 loc) 14.5 kB
(() => { var __create = Object.create; var __getProtoOf = Object.getPrototypeOf; var __defProp = Object.defineProperty; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; function __accessProp(key) { return this[key]; } var __toESMCache_node; var __toESMCache_esm; var __toESM = (mod, isNodeMode, target) => { var canCache = mod != null && typeof mod === "object"; if (canCache) { var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap; var cached = cache.get(mod); if (cached) return cached; } target = mod != null ? __create(__getProtoOf(mod)) : {}; const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target; for (let key of __getOwnPropNames(mod)) if (!__hasOwnProp.call(to, key)) __defProp(to, key, { get: __accessProp.bind(mod, key), enumerable: true }); if (canCache) cache.set(mod, to); return to; }; var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports); var __returnValue = (v) => v; function __exportSetter(name, newValue) { this[name] = __returnValue.bind(null, newValue); } var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true, configurable: true, set: __exportSetter.bind(all, name) }); }; // node_modules/diacritics/index.js var require_diacritics = __commonJS((exports) => { exports.remove = removeDiacritics; var replacementList = [ { base: " ", chars: " " }, { base: "0", chars: "߀" }, { base: "A", chars: "ⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ" }, { base: "AA", chars: "Ꜳ" }, { base: "AE", chars: "ÆǼǢ" }, { base: "AO", chars: "Ꜵ" }, { base: "AU", chars: "Ꜷ" }, { base: "AV", chars: "ꜸꜺ" }, { base: "AY", chars: "Ꜽ" }, { base: "B", chars: "ⒷBḂḄḆɃƁ" }, { base: "C", chars: "ⒸCꜾḈĆCĈĊČÇƇȻ" }, { base: "D", chars: "ⒹDḊĎḌḐḒḎĐƊƉᴅꝹ" }, { base: "Dh", chars: "Ð" }, { base: "DZ", chars: "DZDŽ" }, { base: "Dz", chars: "DzDž" }, { base: "E", chars: "ɛⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎᴇ" }, { base: "F", chars: "ꝼⒻFḞƑꝻ" }, { base: "G", chars: "ⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾɢ" }, { base: "H", chars: "ⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ" }, { base: "I", chars: "ⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ" }, { base: "J", chars: "ⒿJĴɈȷ" }, { base: "K", chars: "ⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ" }, { base: "L", chars: "ⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ" }, { base: "LJ", chars: "LJ" }, { base: "Lj", chars: "Lj" }, { base: "M", chars: "ⓂMḾṀṂⱮƜϻ" }, { base: "N", chars: "ꞤȠⓃNǸŃÑṄŇṆŅṊṈƝꞐᴎ" }, { base: "NJ", chars: "NJ" }, { base: "Nj", chars: "Nj" }, { base: "O", chars: "ⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ" }, { base: "OE", chars: "Œ" }, { base: "OI", chars: "Ƣ" }, { base: "OO", chars: "Ꝏ" }, { base: "OU", chars: "Ȣ" }, { base: "P", chars: "ⓅPṔṖƤⱣꝐꝒꝔ" }, { base: "Q", chars: "ⓆQꝖꝘɊ" }, { base: "R", chars: "ⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ" }, { base: "S", chars: "ⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ" }, { base: "T", chars: "ⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ" }, { base: "Th", chars: "Þ" }, { base: "TZ", chars: "Ꜩ" }, { base: "U", chars: "ⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ" }, { base: "V", chars: "ⓋVṼṾƲꝞɅ" }, { base: "VY", chars: "Ꝡ" }, { base: "W", chars: "ⓌWẀẂŴẆẄẈⱲ" }, { base: "X", chars: "ⓍXẊẌ" }, { base: "Y", chars: "ⓎYỲÝŶỸȲẎŸỶỴƳɎỾ" }, { base: "Z", chars: "ⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ" }, { base: "a", chars: "ⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑ" }, { base: "aa", chars: "ꜳ" }, { base: "ae", chars: "æǽǣ" }, { base: "ao", chars: "ꜵ" }, { base: "au", chars: "ꜷ" }, { base: "av", chars: "ꜹꜻ" }, { base: "ay", chars: "ꜽ" }, { base: "b", chars: "ⓑbḃḅḇƀƃɓƂ" }, { base: "c", chars: "cⓒćĉċčçḉƈȼꜿↄ" }, { base: "d", chars: "ⓓdḋďḍḑḓḏđƌɖɗƋᏧԁꞪ" }, { base: "dh", chars: "ð" }, { base: "dz", chars: "dzdž" }, { base: "e", chars: "ⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇǝ" }, { base: "f", chars: "ⓕfḟƒ" }, { base: "ff", chars: "ff" }, { base: "fi", chars: "fi" }, { base: "fl", chars: "fl" }, { base: "ffi", chars: "ffi" }, { base: "ffl", chars: "ffl" }, { base: "g", chars: "ⓖgǵĝḡğġǧģǥɠꞡꝿᵹ" }, { base: "h", chars: "ⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ" }, { base: "hv", chars: "ƕ" }, { base: "i", chars: "ⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı" }, { base: "j", chars: "ⓙjĵǰɉ" }, { base: "k", chars: "ⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ" }, { base: "l", chars: "ⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇɭ" }, { base: "lj", chars: "lj" }, { base: "m", chars: "ⓜmḿṁṃɱɯ" }, { base: "n", chars: "ⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥлԉ" }, { base: "nj", chars: "nj" }, { base: "o", chars: "ⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿꝋꝍɵɔᴑ" }, { base: "oe", chars: "œ" }, { base: "oi", chars: "ƣ" }, { base: "oo", chars: "ꝏ" }, { base: "ou", chars: "ȣ" }, { base: "p", chars: "ⓟpṕṗƥᵽꝑꝓꝕρ" }, { base: "q", chars: "ⓠqɋꝗꝙ" }, { base: "r", chars: "ⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ" }, { base: "s", chars: "ⓢsśṥŝṡšṧṣṩșşȿꞩꞅẛʂ" }, { base: "ss", chars: "ß" }, { base: "t", chars: "ⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ" }, { base: "th", chars: "þ" }, { base: "tz", chars: "ꜩ" }, { base: "u", chars: "ⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ" }, { base: "v", chars: "ⓥvṽṿʋꝟʌ" }, { base: "vy", chars: "ꝡ" }, { base: "w", chars: "ⓦwẁẃŵẇẅẘẉⱳ" }, { base: "x", chars: "ⓧxẋẍ" }, { base: "y", chars: "ⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ" }, { base: "z", chars: "ⓩzźẑżžẓẕƶȥɀⱬꝣ" } ]; var diacriticsMap = {}; for (i = 0;i < replacementList.length; i += 1) { chars = replacementList[i].chars; for (j = 0;j < chars.length; j += 1) { diacriticsMap[chars[j]] = replacementList[i].base; } } var chars; var j; var i; function removeDiacritics(str) { return str.replace(/[^\u0000-\u007e]/g, function(c) { return diacriticsMap[c] || c; }); } exports.replacementList = replacementList; exports.diacriticsMap = diacriticsMap; }); // src/oci.ts var exports_oci = {}; __export(exports_oci, { simplify: () => simplify, resolveStrings: () => resolveStrings }); // lib/simplify.ts var import_diacritics = __toESM(require_diacritics(), 1); function simplify(str) { if (typeof str !== "string") return ""; return import_diacritics.default.remove(str.replace(/&/g, "and").replace(/(İ|i̇)/ig, "i").replace(/[\s\-=_!"#%'*{},.\/:;?\(\)\[\]@\\$\^*+<>«»~`’\u00a1\u00a7\u00b6\u00b7\u00bf\u037e\u0387\u055a-\u055f\u0589\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0830-\u083e\u085e\u0964\u0965\u0970\u0af0\u0df4\u0e4f\u0e5a\u0e5b\u0f04-\u0f12\u0f14\u0f85\u0fd0-\u0fd4\u0fd9\u0fda\u104a-\u104f\u10fb\u1360-\u1368\u166d\u166e\u16eb-\u16ed\u1735\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u1805\u1807-\u180a\u1944\u1945\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-\u1b60\u1bfc-\u1bff\u1c3b-\u1c3f\u1c7e\u1c7f\u1cc0-\u1cc7\u1cd3\u2000-\u206f\u2cf9-\u2cfc\u2cfe\u2cff\u2d70\u2e00-\u2e7f\u3001-\u3003\u303d\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uaaf0\uaaf1\uabeb\ufe10-\ufe16\ufe19\ufe30\ufe45\ufe46\ufe49-\ufe4c\ufe50-\ufe52\ufe54-\ufe57\ufe5f-\ufe61\ufe68\ufe6a\ufe6b\ufeff\uff01-\uff03\uff05-\uff07\uff0a\uff0c\uff0e\uff0f\uff1a\uff1b\uff1f\uff20\uff3c\uff61\uff64\uff65]+/g, "").toLowerCase()); } // lib/resolve_strings.ts function resolveStrings(item, defaults, localizerFn) { const itemStrings = Object.assign({}, item.strings); const defaultStrings = Object.assign({}, defaults[item.type]); const anyToken = new RegExp(/(\{\w+\})/, "gi"); if (localizerFn) { if (itemStrings.community) { const communityID = simplify(itemStrings.community); itemStrings.community = localizerFn(`_communities.${communityID}`); } for (const prop of ["name", "description", "extendedDescription"]) { if (defaultStrings[prop]) defaultStrings[prop] = localizerFn(`_defaults.${item.type}.${prop}`); if (itemStrings[prop]) itemStrings[prop] = localizerFn(`${item.id}.${prop}`); } } const replacements = { account: item.account, community: itemStrings.community, signupUrl: itemStrings.signupUrl, url: itemStrings.url }; if (!replacements.signupUrl) { replacements.signupUrl = resolve(itemStrings.signupUrl || defaultStrings.signupUrl); } if (!replacements.url) { replacements.url = resolve(itemStrings.url || defaultStrings.url); } const resolved = { name: resolve(itemStrings.name || defaultStrings.name), url: resolve(itemStrings.url || defaultStrings.url), signupUrl: resolve(itemStrings.signupUrl || defaultStrings.signupUrl), description: resolve(itemStrings.description || defaultStrings.description), extendedDescription: resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription) }; resolved.nameHTML = linkify(resolved.url, resolved.name); resolved.urlHTML = linkify(resolved.url); resolved.signupUrlHTML = linkify(resolved.signupUrl); resolved.descriptionHTML = resolve(itemStrings.description || defaultStrings.description, true); resolved.extendedDescriptionHTML = resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription, true); return resolved; function resolve(s, addLinks) { if (!s) return; let result = s; for (const key in replacements) { const token = `{${key}}`; const regex = new RegExp(token, "g"); if (regex.test(result)) { let replacement = replacements[key]; if (!replacement) { throw new Error(`Cannot resolve token: ${token}`); } else { if (addLinks && (key === "signupUrl" || key === "url")) { replacement = linkify(replacement) ?? replacement; } result = result.replace(regex, replacement); } } } const leftovers = result.match(anyToken); if (leftovers) { throw new Error(`Cannot resolve tokens: ${leftovers}`); } if (addLinks && resolved.url && item.type === "reddit") { result = result.replace(/(\/r\/\w+\/*)/i, (match) => linkify(resolved.url, match)); } return result; } function linkify(url, text) { if (!url) return; text = text || url; return `<a target="_blank" href="${url}">${text}</a>`; } } // src/index.ts globalThis.oci = exports_oci; })(); //# debugId=8AAF21033890956F64756E2164756E21 //# sourceMappingURL=oci.iife.js.map