"use strict"; /** * @license * SPDX-License-Identifier: Apache-2.0 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.safeScriptWithArgs = exports.scriptFromJson = exports.concatScripts = exports.safeScript = void 0; require("../environment/dev"); var script_impl_1 = require("../internals/script_impl"); var string_literal_1 = require("../internals/string_literal"); /** * Creates a SafeScript object from a template literal (without any embedded * expressions). * * This function is a template literal tag function. It should be called with * a template literal that does not contain any expressions. For example, * safeScript`foo`; * * @param templateObj This contains the literal part of the template literal. */ function safeScript(templateObj) { if (process.env.NODE_ENV !== 'production') { (0, string_literal_1.assertIsTemplateObject)(templateObj, false, 'safeScript is a template literal tag function ' + 'that only accepts template literals without expressions. ' + 'For example, safeScript`foo`;'); } return (0, script_impl_1.createScript)(templateObj[0]); } exports.safeScript = safeScript; /** Creates a `SafeScript` value by concatenating multiple `SafeScript`s. */ function concatScripts(scripts) { return (0, script_impl_1.createScript)(scripts.map(script_impl_1.unwrapScript).join('')); } exports.concatScripts = concatScripts; /** * Converts a serializable value into JSON that is safe to interpolate into a * script context. In particular it escapes < characters so that a value of * "" doesn't break out of the context. * @param value The value to serialize. */ function scriptFromJson(value) { return (0, script_impl_1.createScript)(JSON.stringify(value).replace(/