text: /**
   * rapidJS: Automatic serving, all-implicit-routing, pluggable fullstack scoped
   *          function modules, un-opinionated templating. 
   * 
   * Copyright (c) Thassilo Martin Schiepanski
   */
  "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.render=exports.defaultLang=exports.localeMatchRegex=void 0;const fs_1=require("fs"),path_1=require("path"),config_server_1=__importDefault(require("../../config/config.server")),bindings_1=require("../../interface/bindings"),languages_json_1=__importDefault(require("./languages.json")),countries_json_1=__importDefault(require("./countries.json")),checkLocaleCoding=(e,n,o)=>{if(!n.includes(e))throw new SyntaxError(`Invalid code '${o}' given in locale configuration (Not an ISO-2-digit compliant ${o} code)`)},normalizedLocale=config_server_1.default.locale.map(e=>{if("string"==typeof e||e instanceof String)return checkLocaleCoding(String(e),languages_json_1.default,"language"),e;checkLocaleCoding(e.language,languages_json_1.default,"language");const n=e.countries||[];return n.forEach(e=>(checkLocaleCoding(e,countries_json_1.default,"country"),e)),(0<n.length?`${e.language}-(${n.join("|")})|`:"")+e.language}).join("|");function render(e,n){if(!(n.locale||{}).language||0==bindings_1.localeEngine.length)return e;const o=[];var r=n.locale.language+".json",a=(0,path_1.join)(config_server_1.default.directory.lang,r);(0,fs_1.existsSync)(a)&&o.push(a),n.isCompound&&(r=(0,path_1.join)(config_server_1.default.directory.web,n.pathname,r),console.log(r),(0,fs_1.existsSync)(r)&&o.push(r));let t={};return o.forEach(e=>{t=Object.assign(t,require(e))}),e=bindings_1.localeEngine.apply(e,[n.locale,t])}exports.localeMatchRegex=0<normalizedLocale.length?new RegExp(`^/(${normalizedLocale})/`):void 0,exports.defaultLang=0<config_server_1.default.locale.length?"string"==typeof config_server_1.default.locale[0]||config_server_1.default.locale[0]instanceof String?String(config_server_1.default.locale[0]):config_server_1.default.locale[0].language:void 0,exports.render=render;