UNPKG

contentstack

Version:
122 lines (114 loc) 418 kB
module.exports = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./src/core/contentstack.js"); /******/ }) /************************************************************************/ /******/ ({ /***/ "./config.js": /*!*******************!*\ !*** ./config.js ***! \*******************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nvar config = {\n protocol: \"https\",\n host: \"cdn.contentstack.io\",\n port: 443,\n version: \"v3\",\n urls: {\n sync: \"/stacks/sync\",\n content_types: \"/content_types/\",\n entries: \"/entries/\",\n assets: \"/assets/\",\n environments: \"/environments/\"\n }\n};\n\nexports.default = config;\n\n//# sourceURL=webpack://Contentstack/./config.js?"); /***/ }), /***/ "./node_modules/@contentstack/utils/dist/index.es.js": /*!***********************************************************!*\ !*** ./node_modules/@contentstack/utils/dist/index.es.js ***! \***********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nvar nodeHtmlParser = __webpack_require__(/*! node-html-parser */ \"./node_modules/node-html-parser/dist/esm/index.js\");\n\nfunction createMetadata(attribute) {\n return {\n text: attribute['#text'],\n itemUid: attribute[\"data-sys-entry-uid\"] || attribute[\"data-sys-asset-uid\"],\n itemType: attribute.type,\n styleType: attribute[\"sys-style-type\"],\n attributes: attribute,\n contentTypeUid: attribute[\"data-sys-content-type-uid\"]\n };\n}\nfunction nodeToMetadata(attribute, textNode) {\n return {\n text: textNode.text,\n itemUid: attribute[\"entry-uid\"] || attribute[\"asset-uid\"],\n itemType: attribute.type,\n styleType: attribute[\"display-type\"],\n attributes: attribute,\n contentTypeUid: attribute[\"content-type-uid\"]\n };\n}\nfunction attributeToString(attributes) {\n var result = '';\n var _loop_1 = function _loop_1(key) {\n if (Object.prototype.hasOwnProperty.call(attributes, key)) {\n var element = attributes[key];\n if (element instanceof Array) {\n var elementString_1 = '';\n var isFirst_1 = true;\n element.forEach(function (value) {\n if (isFirst_1) {\n elementString_1 += \"\" + value;\n isFirst_1 = false;\n } else {\n elementString_1 += \", \" + value;\n }\n });\n element = elementString_1;\n } else if ((typeof element === 'undefined' ? 'undefined' : _typeof(element)) === 'object') {\n var elementString = '';\n for (var elementKey in element) {\n if (Object.prototype.hasOwnProperty.call(element, elementKey)) {\n var value = element[elementKey];\n elementString += elementKey + \":\" + value + \"; \";\n }\n }\n element = elementString;\n }\n result += \" \" + key + \"=\\\"\" + element + \"\\\"\";\n }\n };\n for (var key in attributes) {\n _loop_1(key);\n }\n return result;\n}\n\nvar StyleType;\n(function (StyleType) {\n StyleType[\"BLOCK\"] = \"block\";\n StyleType[\"INLINE\"] = \"inline\";\n StyleType[\"LINK\"] = \"link\";\n StyleType[\"DISPLAY\"] = \"display\";\n StyleType[\"DOWNLOAD\"] = \"download\";\n})(StyleType || (StyleType = {}));\nvar StyleType$1 = StyleType;\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\n/* global Reflect, Promise */\n\nvar _extendStatics = function extendStatics(d, b) {\n _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {\n d.__proto__ = b;\n } || function (d, b) {\n for (var p in b) {\n if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];\n }\n };\n return _extendStatics(d, b);\n};\n\nfunction __extends(d, b) {\n _extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nvar _assign = function __assign() {\n _assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) {\n if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n }\n return t;\n };\n return _assign.apply(this, arguments);\n};\n\nfunction elementToJson(element) {\n var obj = _assign({}, element.rawAttributes);\n element.childNodes.forEach(function (chileNode) {\n var node = chileNode;\n obj = _assign(_assign({}, obj), parseElement(node));\n });\n return obj;\n}\nfunction parseElement(node) {\n var obj = {};\n if (node.nodeType === 3) {\n obj['#text'] = node.text;\n } else if (node.nodeType === 1) {\n obj[node.tagName.toLowerCase()] = elementToJson(node);\n }\n return obj;\n}\n\nvar frameflag = 'documentfragmentcontainer';\nString.prototype.forEachEmbeddedItem = function (callbackfn) {\n var str = \"<\" + frameflag + \">\" + this.toString() + \"</\" + frameflag + \">\";\n var root = nodeHtmlParser.parse(str);\n var embeddedEntries = root.querySelectorAll(\".embedded-entry\");\n embeddedEntries.forEach(function (element) {\n callbackfn(element.outerHTML, createMetadata(elementToJson(element)));\n });\n var embeddedAsset = root.querySelectorAll(\".embedded-asset\");\n embeddedAsset.forEach(function (element) {\n callbackfn(element.outerHTML, createMetadata(elementToJson(element)));\n });\n};\n\nvar _a;\nvar defaultOptions = (_a = {}, _a[StyleType$1.BLOCK] = function (item) {\n return \"<div><p>\" + (item.title || item.uid) + \"</p><p>Content type: <span>\" + item._content_type_uid + \"</span></p></div>\";\n}, _a[StyleType$1.INLINE] = function (item) {\n return \"<span>\" + (item.title || item.uid) + \"</span>\";\n}, _a[StyleType$1.LINK] = function (item, metadata) {\n return \"<a href=\\\"\" + item.url + \"\\\">\" + (metadata.text || item.title || item.uid) + \"</a>\";\n}, _a[StyleType$1.DISPLAY] = function (item, metadata) {\n return \"<img src=\\\"\" + item.url + \"\\\" alt=\\\"\" + (metadata.attributes.alt || item.title || item.filename || item.uid) + \"\\\" />\";\n}, _a[StyleType$1.DOWNLOAD] = function (item, metadata) {\n return \"<a href=\\\"\" + item.url + \"\\\">\" + (metadata.text || item.title || item.uid) + \"</a>\";\n}, _a);\n\n// This function will find Embedded object present in string\nfunction findEmbeddedEntry(uid, contentTypeUid, embeddeditems) {\n if (embeddeditems === void 0) {\n embeddeditems = [];\n }\n return embeddeditems.filter(function (entry) {\n if (entry.uid === uid && entry._content_type_uid === contentTypeUid) {\n return entry;\n }\n });\n}\nfunction findEmbeddedAsset(uid, embeddedAssets) {\n if (embeddedAssets === void 0) {\n embeddedAssets = [];\n }\n return embeddedAssets.filter(function (asset) {\n if (asset.uid === uid) {\n return asset;\n }\n });\n}\nfunction findEmbeddedItems(object, entry) {\n if (object && object !== undefined && entry && entry !== undefined) {\n if (entry._embedded_items !== undefined) {\n var entryEmbedable = entry;\n if (object.itemType === 'entry') {\n return findEmbeddedEntry(object.itemUid, object.contentTypeUid, Object.values(entryEmbedable._embedded_items || []).reduce(function (accumulator, value) {\n return accumulator.concat(value);\n }, []));\n } else {\n return findEmbeddedAsset(object.itemUid, Object.values(entryEmbedable._embedded_items || []).reduce(function (accumulator, value) {\n return accumulator.concat(value);\n }, []));\n }\n }\n }\n return [];\n}\nfunction findRenderString(item, metadata, renderOptions) {\n if (!item && item === undefined || !metadata && metadata === undefined) {\n return '';\n }\n if (renderOptions && renderOptions[metadata.styleType] !== undefined) {\n var renderFunction = renderOptions[metadata.styleType];\n if (metadata.attributes['data-sys-content-type-uid'] !== undefined && typeof renderFunction !== 'function' && renderFunction[metadata.attributes['data-sys-content-type-uid']] !== undefined) {\n return renderFunction[metadata.attributes['data-sys-content-type-uid']](item, metadata);\n } else if (metadata.attributes['data-sys-content-type-uid'] !== undefined && typeof renderFunction !== 'function' && renderFunction.$default !== undefined) {\n return renderFunction.$default(item, metadata);\n } else if (metadata.contentTypeUid !== undefined && typeof renderFunction !== 'function' && renderFunction[metadata.contentTypeUid] !== undefined) {\n return renderFunction[metadata.contentTypeUid](item, metadata);\n } else if (metadata.contentTypeUid !== undefined && typeof renderFunction !== 'function' && renderFunction.$default !== undefined) {\n return renderFunction.$default(item, metadata);\n } else if (typeof renderFunction === 'function') {\n return renderFunction(item, metadata);\n }\n }\n var defaultRenderFunction = defaultOptions[metadata.styleType];\n return defaultRenderFunction(item, metadata);\n}\n\nfunction findRenderContent(keyPaths, entry, render) {\n getContent(keyPaths.split(\".\"), entry, render);\n}\nfunction getContent(keys, object, render) {\n if (keys) {\n var key = keys[0];\n if (keys.length === 1 && object[key]) {\n object[key] = render(object[key]);\n } else if (keys.length > 0) {\n if (object[key]) {\n var newKeys = keys.slice(1);\n if (Array.isArray(object[key])) {\n // tslint:disable-next-line: prefer-for-of\n for (var _i = 0, _a = object[key]; _i < _a.length; _i++) {\n var objKey = _a[_i];\n getContent(newKeys, objKey, render);\n }\n } else if (_typeof(object[key]) === 'object') {\n getContent(newKeys, object[key], render);\n }\n }\n }\n }\n}\n\n/**\r\n *\r\n * @param {EntryEmbedable| EntryEmbedable[]} entry - Objects that contains RTE with embedded objects\r\n * @param {string[]} paths - Key paths for RTE contents in Entry object\r\n * @param {RenderOption?} renderOption - Optional render options to render content\r\n */\nfunction render(option) {\n function findContent(path, entry) {\n findRenderContent(path, entry, function (content) {\n return renderContent(content, { entry: entry, renderOption: option.renderOption });\n });\n }\n function findAndRender(entry) {\n if (!option.paths || option.paths.length === 0) {\n Object.keys(_assign({}, entry._embedded_items)).forEach(function (path) {\n findContent(path, entry);\n });\n } else {\n option.paths.forEach(function (path) {\n findContent(path, entry);\n });\n }\n }\n if (option.entry instanceof Array) {\n option.entry.forEach(function (entry) {\n findAndRender(entry);\n });\n } else {\n findAndRender(option.entry);\n }\n}\n/**\r\n *\r\n * @param {string | string[]} content - RTE content to render\r\n * @param {EntryEmbedable} options.entry - Entry object containing embedded objects\r\n * @param {RenderOption?} options.renderOption - Optional render options to render content\r\n */\nfunction renderContent(content, option) {\n // return blank if content not present\n if (!content || content === undefined) {\n return '';\n }\n // render content of type string\n if (typeof content === 'string') {\n var contentToReplace_1 = content;\n content.forEachEmbeddedItem(function (embededObjectTag, object) {\n contentToReplace_1 = findAndReplaceEmbeddedItem(contentToReplace_1, embededObjectTag, object, option);\n });\n return contentToReplace_1;\n }\n // render content of type array of string\n var resultContent = [];\n content.forEach(function (element) {\n resultContent.push(renderContent(element, option));\n });\n return resultContent;\n}\nfunction findAndReplaceEmbeddedItem(content, embededObjectTag, metadata, option) {\n var embeddedObjects = findEmbeddedItems(metadata, option.entry);\n var renderString = findRenderString(embeddedObjects[0], metadata, option.renderOption);\n return content.replace(embededObjectTag, renderString);\n}\n\nvar NodeType;\n(function (NodeType) {\n NodeType[\"DOCUMENT\"] = \"doc\";\n NodeType[\"PARAGRAPH\"] = \"p\";\n NodeType[\"LINK\"] = \"a\";\n NodeType[\"IMAGE\"] = \"img\";\n NodeType[\"EMBED\"] = \"embed\";\n NodeType[\"HEADING_1\"] = \"h1\";\n NodeType[\"HEADING_2\"] = \"h2\";\n NodeType[\"HEADING_3\"] = \"h3\";\n NodeType[\"HEADING_4\"] = \"h4\";\n NodeType[\"HEADING_5\"] = \"h5\";\n NodeType[\"HEADING_6\"] = \"h6\";\n NodeType[\"ORDER_LIST\"] = \"ol\";\n NodeType[\"UNORDER_LIST\"] = \"ul\";\n NodeType[\"LIST_ITEM\"] = \"li\";\n NodeType[\"HR\"] = \"hr\";\n NodeType[\"TABLE\"] = \"table\";\n NodeType[\"TABLE_HEADER\"] = \"thead\";\n NodeType[\"TABLE_BODY\"] = \"tbody\";\n NodeType[\"TABLE_FOOTER\"] = \"tfoot\";\n NodeType[\"TABLE_ROW\"] = \"tr\";\n NodeType[\"TABLE_HEAD\"] = \"th\";\n NodeType[\"TABLE_DATA\"] = \"td\";\n NodeType[\"BLOCK_QUOTE\"] = \"blockquote\";\n NodeType[\"CODE\"] = \"code\";\n NodeType[\"TEXT\"] = \"text\";\n NodeType[\"REFERENCE\"] = \"reference\";\n})(NodeType || (NodeType = {}));\nvar NodeType$1 = NodeType;\n\nvar MarkType;\n(function (MarkType) {\n MarkType[\"BOLD\"] = \"bold\";\n MarkType[\"ITALIC\"] = \"italic\";\n MarkType[\"UNDERLINE\"] = \"underline\";\n MarkType[\"STRIKE_THROUGH\"] = \"strikethrough\";\n MarkType[\"INLINE_CODE\"] = \"inlineCode\";\n MarkType[\"SUBSCRIPT\"] = \"subscript\";\n MarkType[\"SUPERSCRIPT\"] = \"superscript\";\n})(MarkType || (MarkType = {}));\nvar MarkType$1 = MarkType;\n\nvar Node = /** @class */function () {\n function Node() {}\n return Node;\n}();\n\nvar Document = /** @class */function (_super) {\n __extends(Document, _super);\n function Document() {\n var _this = _super.call(this) || this;\n _this.type = NodeType$1.DOCUMENT;\n return _this;\n }\n return Document;\n}(Node);\n\nvar TextNode = /** @class */function (_super) {\n __extends(TextNode, _super);\n function TextNode(text) {\n var _this = _super.call(this) || this;\n _this.text = text;\n return _this;\n }\n return TextNode;\n}(Node);\n\nvar _a$1;\nvar defaultNodeOption = (_a$1 = {}, _a$1[NodeType$1.DOCUMENT] = function (node) {\n return \"\";\n}, _a$1[NodeType$1.PARAGRAPH] = function (node, next) {\n return \"<p>\" + next(node.children) + \"</p>\";\n}, _a$1[NodeType$1.LINK] = function (node, next) {\n return \"<a href=\\\"\" + node.attrs.href + \"\\\">\" + next(node.children) + \"</a>\";\n}, _a$1[NodeType$1.IMAGE] = function (node, next) {\n return \"<img src=\\\"\" + node.attrs.src + \"\\\" />\" + next(node.children);\n}, _a$1[NodeType$1.EMBED] = function (node, next) {\n return \"<iframe src=\\\"\" + node.attrs.src + \"\\\">\" + next(node.children) + \"</iframe>\";\n}, _a$1[NodeType$1.HEADING_1] = function (node, next) {\n return \"<h1>\" + next(node.children) + \"</h1>\";\n}, _a$1[NodeType$1.HEADING_2] = function (node, next) {\n return \"<h2>\" + next(node.children) + \"</h2>\";\n}, _a$1[NodeType$1.HEADING_3] = function (node, next) {\n return \"<h3>\" + next(node.children) + \"</h3>\";\n}, _a$1[NodeType$1.HEADING_4] = function (node, next) {\n return \"<h4>\" + next(node.children) + \"</h4>\";\n}, _a$1[NodeType$1.HEADING_5] = function (node, next) {\n return \"<h5>\" + next(node.children) + \"</h5>\";\n}, _a$1[NodeType$1.HEADING_6] = function (node, next) {\n return \"<h6>\" + next(node.children) + \"</h6>\";\n}, _a$1[NodeType$1.ORDER_LIST] = function (node, next) {\n return \"<ol>\" + next(node.children) + \"</ol>\";\n}, _a$1[NodeType$1.UNORDER_LIST] = function (node, next) {\n return \"<ul>\" + next(node.children) + \"</ul>\";\n}, _a$1[NodeType$1.LIST_ITEM] = function (node, next) {\n return \"<li>\" + next(node.children) + \"</li>\";\n}, _a$1[NodeType$1.HR] = function (node, next) {\n return \"<hr>\";\n}, _a$1[NodeType$1.TABLE] = function (node, next) {\n return \"<table>\" + next(node.children) + \"</table>\";\n}, _a$1[NodeType$1.TABLE_HEADER] = function (node, next) {\n return \"<thead>\" + next(node.children) + \"</thead>\";\n}, _a$1[NodeType$1.TABLE_BODY] = function (node, next) {\n return \"<tbody>\" + next(node.children) + \"</tbody>\";\n}, _a$1[NodeType$1.TABLE_FOOTER] = function (node, next) {\n return \"<tfoot>\" + next(node.children) + \"</tfoot>\";\n}, _a$1[NodeType$1.TABLE_ROW] = function (node, next) {\n return \"<tr>\" + next(node.children) + \"</tr>\";\n}, _a$1[NodeType$1.TABLE_HEAD] = function (node, next) {\n return \"<th>\" + next(node.children) + \"</th>\";\n}, _a$1[NodeType$1.TABLE_DATA] = function (node, next) {\n return \"<td>\" + next(node.children) + \"</td>\";\n}, _a$1[NodeType$1.BLOCK_QUOTE] = function (node, next) {\n return \"<blockquote>\" + next(node.children) + \"</blockquote>\";\n}, _a$1[NodeType$1.CODE] = function (node, next) {\n return \"<code>\" + next(node.children) + \"</code>\";\n}, _a$1['reference'] = function (node, next) {\n return \"\";\n}, _a$1[MarkType$1.BOLD] = function (text) {\n return \"<strong>\" + text + \"</strong>\";\n}, _a$1[MarkType$1.ITALIC] = function (text) {\n return \"<em>\" + text + \"</em>\";\n}, _a$1[MarkType$1.UNDERLINE] = function (text) {\n return \"<u>\" + text + \"</u>\";\n}, _a$1[MarkType$1.STRIKE_THROUGH] = function (text) {\n return \"<strike>\" + text + \"</strike>\";\n}, _a$1[MarkType$1.INLINE_CODE] = function (text) {\n return \"<span>\" + text + \"</span>\";\n}, _a$1[MarkType$1.SUBSCRIPT] = function (text) {\n return \"<sub>\" + text + \"</sub>\";\n}, _a$1[MarkType$1.SUPERSCRIPT] = function (text) {\n return \"<sup>\" + text + \"</sup>\";\n}, _a$1);\n\nfunction jsonToHTML(option) {\n if (option.entry instanceof Array) {\n enumerateEntries({\n entry: option.entry,\n paths: option.paths,\n renderOption: option.renderOption\n });\n } else {\n enumerateKeys({\n entry: option.entry,\n paths: option.paths,\n renderOption: option.renderOption\n });\n }\n}\nfunction enumerateEntries(option) {\n for (var _i = 0, _a = option.entry; _i < _a.length; _i++) {\n var entry = _a[_i];\n jsonToHTML({ entry: entry, paths: option.paths, renderOption: option.renderOption });\n }\n}\nfunction enumerateKeys(option) {\n for (var _i = 0, _a = option.paths; _i < _a.length; _i++) {\n var key = _a[_i];\n findRenderContent(key, option.entry, function (content) {\n return enumerateContents(content, option.entry, option.renderOption);\n });\n }\n}\nfunction enumerateContents(content, entry, renderOption) {\n if (!(content instanceof Array) && content.type !== 'doc') {\n return content;\n }\n if (content instanceof Array) {\n var result_1 = [];\n content.forEach(function (doc) {\n result_1.push(enumerateContents(doc, entry, renderOption));\n });\n return result_1;\n }\n var commonRenderOption = _assign(_assign({}, defaultNodeOption), renderOption);\n return nodeChildrenToHTML(content.children, commonRenderOption, entry);\n}\nfunction textNodeToHTML(node, renderOption) {\n var text = node.text;\n if (node.superscript) {\n text = renderOption[MarkType$1.SUPERSCRIPT](text);\n }\n if (node.subscript) {\n text = renderOption[MarkType$1.SUBSCRIPT](text);\n }\n if (node.inlineCode) {\n text = renderOption[MarkType$1.INLINE_CODE](text);\n }\n if (node.strikethrough) {\n text = renderOption[MarkType$1.STRIKE_THROUGH](text);\n }\n if (node.underline) {\n text = renderOption[MarkType$1.UNDERLINE](text);\n }\n if (node.italic) {\n text = renderOption[MarkType$1.ITALIC](text);\n }\n if (node.bold) {\n text = renderOption[MarkType$1.BOLD](text);\n }\n return text;\n}\nfunction referenceToHTML(node, renderOption, entry) {\n if (!entry) {\n return '';\n }\n var metadata = nodeToMetadata(node.attrs, node.children && node.children.length > 0 ? node.children[0] : {});\n var item = findEmbeddedItems(metadata, entry)[0];\n return findRenderString(item, metadata, renderOption);\n}\nfunction nodeChildrenToHTML(nodes, renderOption, entry) {\n return nodes.map(function (node) {\n return nodeToHTML(node, renderOption, entry);\n }).join('');\n}\nfunction nodeToHTML(node, renderOption, entry) {\n if (!node.type) {\n return textNodeToHTML(node, renderOption);\n } else if (node.type === 'reference') {\n return referenceToHTML(node, renderOption, entry);\n } else {\n var next = function next(nodes) {\n return nodeChildrenToHTML(nodes, renderOption, entry);\n };\n return renderOption[node.type](node, next);\n }\n}\n\nexports.Document = Document;\nexports.MarkType = MarkType$1;\nexports.Node = Node;\nexports.NodeType = NodeType$1;\nexports.StyleType = StyleType$1;\nexports.TextNode = TextNode;\nexports.attributeToString = attributeToString;\nexports.jsonToHTML = jsonToHTML;\nexports.render = render;\nexports.renderContent = renderContent;\n//# sourceMappingURL=index.es.js.map\n\n//# sourceURL=webpack://Contentstack/./node_modules/@contentstack/utils/dist/index.es.js?"); /***/ }), /***/ "./node_modules/es6-promise/dist/es6-promise.js": /*!******************************************************!*\ !*** ./node_modules/es6-promise/dist/es6-promise.js ***! \******************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var require;\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\n/*!\n * @overview es6-promise - a tiny implementation of Promises/A+.\n * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)\n * @license Licensed under MIT license\n * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE\n * @version 4.1.1\n */\n\n(function (global, factory) {\n ( false ? undefined : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : true ? !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :\n\t\t\t\t__WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : undefined;\n})(undefined, function () {\n 'use strict';\n\n function objectOrFunction(x) {\n var type = typeof x === 'undefined' ? 'undefined' : _typeof(x);\n return x !== null && (type === 'object' || type === 'function');\n }\n\n function isFunction(x) {\n return typeof x === 'function';\n }\n\n var _isArray = undefined;\n if (Array.isArray) {\n _isArray = Array.isArray;\n } else {\n _isArray = function _isArray(x) {\n return Object.prototype.toString.call(x) === '[object Array]';\n };\n }\n\n var isArray = _isArray;\n\n var len = 0;\n var vertxNext = undefined;\n var customSchedulerFn = undefined;\n\n var asap = function asap(callback, arg) {\n queue[len] = callback;\n queue[len + 1] = arg;\n len += 2;\n if (len === 2) {\n // If len is 2, that means that we need to schedule an async flush.\n // If additional callbacks are queued before the queue is flushed, they\n // will be processed by this flush that we are scheduling.\n if (customSchedulerFn) {\n customSchedulerFn(flush);\n } else {\n scheduleFlush();\n }\n }\n };\n\n function setScheduler(scheduleFn) {\n customSchedulerFn = scheduleFn;\n }\n\n function setAsap(asapFn) {\n asap = asapFn;\n }\n\n var browserWindow = typeof window !== 'undefined' ? window : undefined;\n var browserGlobal = browserWindow || {};\n var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;\n var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';\n\n // test for web worker but not in IE10\n var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';\n\n // node\n function useNextTick() {\n // node version 0.10.x displays a deprecation warning when nextTick is used recursively\n // see https://github.com/cujojs/when/issues/410 for details\n return function () {\n return process.nextTick(flush);\n };\n }\n\n // vertx\n function useVertxTimer() {\n if (typeof vertxNext !== 'undefined') {\n return function () {\n vertxNext(flush);\n };\n }\n\n return useSetTimeout();\n }\n\n function useMutationObserver() {\n var iterations = 0;\n var observer = new BrowserMutationObserver(flush);\n var node = document.createTextNode('');\n observer.observe(node, { characterData: true });\n\n return function () {\n node.data = iterations = ++iterations % 2;\n };\n }\n\n // web worker\n function useMessageChannel() {\n var channel = new MessageChannel();\n channel.port1.onmessage = flush;\n return function () {\n return channel.port2.postMessage(0);\n };\n }\n\n function useSetTimeout() {\n // Store setTimeout reference so es6-promise will be unaffected by\n // other code modifying setTimeout (like sinon.useFakeTimers())\n var globalSetTimeout = setTimeout;\n return function () {\n return globalSetTimeout(flush, 1);\n };\n }\n\n var queue = new Array(1000);\n function flush() {\n for (var i = 0; i < len; i += 2) {\n var callback = queue[i];\n var arg = queue[i + 1];\n\n callback(arg);\n\n queue[i] = undefined;\n queue[i + 1] = undefined;\n }\n\n len = 0;\n }\n\n function attemptVertx() {\n try {\n var r = require;\n var vertx = __webpack_require__(!(function webpackMissingModule() { var e = new Error(\"Cannot find module 'vertx'\"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));\n vertxNext = vertx.runOnLoop || vertx.runOnContext;\n return useVertxTimer();\n } catch (e) {\n return useSetTimeout();\n }\n }\n\n var scheduleFlush = undefined;\n // Decide what async method to use to triggering processing of queued callbacks:\n if (isNode) {\n scheduleFlush = useNextTick();\n } else if (BrowserMutationObserver) {\n scheduleFlush = useMutationObserver();\n } else if (isWorker) {\n scheduleFlush = useMessageChannel();\n } else if (browserWindow === undefined && \"function\" === 'function') {\n scheduleFlush = attemptVertx();\n } else {\n scheduleFlush = useSetTimeout();\n }\n\n function then(onFulfillment, onRejection) {\n var _arguments = arguments;\n\n var parent = this;\n\n var child = new this.constructor(noop);\n\n if (child[PROMISE_ID] === undefined) {\n makePromise(child);\n }\n\n var _state = parent._state;\n\n if (_state) {\n (function () {\n var callback = _arguments[_state - 1];\n asap(function () {\n return invokeCallback(_state, child, callback, parent._result);\n });\n })();\n } else {\n subscribe(parent, child, onFulfillment, onRejection);\n }\n\n return child;\n }\n\n /**\n `Promise.resolve` returns a promise that will become resolved with the\n passed `value`. It is shorthand for the following:\n \n ```javascript\n let promise = new Promise(function(resolve, reject){\n resolve(1);\n });\n \n promise.then(function(value){\n // value === 1\n });\n ```\n \n Instead of writing the above, your code now simply becomes the following:\n \n ```javascript\n let promise = Promise.resolve(1);\n \n promise.then(function(value){\n // value === 1\n });\n ```\n \n @method resolve\n @static\n @param {Any} value value that the returned promise will be resolved with\n Useful for tooling.\n @return {Promise} a promise that will become fulfilled with the given\n `value`\n */\n function resolve$1(object) {\n /*jshint validthis:true */\n var Constructor = this;\n\n if (object && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && object.constructor === Constructor) {\n return object;\n }\n\n var promise = new Constructor(noop);\n resolve(promise, object);\n return promise;\n }\n\n var PROMISE_ID = Math.random().toString(36).substring(16);\n\n function noop() {}\n\n var PENDING = void 0;\n var FULFILLED = 1;\n var REJECTED = 2;\n\n var GET_THEN_ERROR = new ErrorObject();\n\n function selfFulfillment() {\n return new TypeError(\"You cannot resolve a promise with itself\");\n }\n\n function cannotReturnOwn() {\n return new TypeError('A promises callback cannot return that same promise.');\n }\n\n function getThen(promise) {\n try {\n return promise.then;\n } catch (error) {\n GET_THEN_ERROR.error = error;\n return GET_THEN_ERROR;\n }\n }\n\n function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {\n try {\n then$$1.call(value, fulfillmentHandler, rejectionHandler);\n } catch (e) {\n return e;\n }\n }\n\n function handleForeignThenable(promise, thenable, then$$1) {\n asap(function (promise) {\n var sealed = false;\n var error = tryThen(then$$1, thenable, function (value) {\n if (sealed) {\n return;\n }\n sealed = true;\n if (thenable !== value) {\n resolve(promise, value);\n } else {\n fulfill(promise, value);\n }\n }, function (reason) {\n if (sealed) {\n return;\n }\n sealed = true;\n\n reject(promise, reason);\n }, 'Settle: ' + (promise._label || ' unknown promise'));\n\n if (!sealed && error) {\n sealed = true;\n reject(promise, error);\n }\n }, promise);\n }\n\n function handleOwnThenable(promise, thenable) {\n if (thenable._state === FULFILLED) {\n fulfill(promise, thenable._result);\n } else if (thenable._state === REJECTED) {\n reject(promise, thenable._result);\n } else {\n subscribe(thenable, undefined, function (value) {\n return resolve(promise, value);\n }, function (reason) {\n return reject(promise, reason);\n });\n }\n }\n\n function handleMaybeThenable(promise, maybeThenable, then$$1) {\n if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) {\n handleOwnThenable(promise, maybeThenable);\n } else {\n if (then$$1 === GET_THEN_ERROR) {\n reject(promise, GET_THEN_ERROR.error);\n GET_THEN_ERROR.error = null;\n } else if (then$$1 === undefined) {\n fulfill(promise, maybeThenable);\n } else if (isFunction(then$$1)) {\n handleForeignThenable(promise, maybeThenable, then$$1);\n } else {\n fulfill(promise, maybeThenable);\n }\n }\n }\n\n function resolve(promise, value) {\n if (promise === value) {\n reject(promise, selfFulfillment());\n } else if (objectOrFunction(value)) {\n handleMaybeThenable(promise, value, getThen(value));\n } else {\n fulfill(promise, value);\n }\n }\n\n function publishRejection(promise) {\n if (promise._onerror) {\n promise._onerror(promise._result);\n }\n\n publish(promise);\n }\n\n function fulfill(promise, value) {\n if (promise._state !== PENDING) {\n return;\n }\n\n promise._result = value;\n promise._state = FULFILLED;\n\n if (promise._subscribers.length !== 0) {\n asap(publish, promise);\n }\n }\n\n function reject(promise, reason) {\n if (promise._state !== PENDING) {\n return;\n }\n promise._state = REJECTED;\n promise._result = reason;\n\n asap(publishRejection, promise);\n }\n\n function subscribe(parent, child, onFulfillment, onRejection) {\n var _subscribers = parent._subscribers;\n var length = _subscribers.length;\n\n parent._onerror = null;\n\n _subscribers[length] = child;\n _subscribers[length + FULFILLED] = onFulfillment;\n _subscribers[length + REJECTED] = onRejection;\n\n if (length === 0 && parent._state) {\n asap(publish, parent);\n }\n }\n\n function publish(promise) {\n var subscribers = promise._subscribers;\n var settled = promise._state;\n\n if (subscribers.length === 0) {\n return;\n }\n\n var child = undefined,\n callback = undefined,\n detail = promise._result;\n\n for (var i = 0; i < subscribers.length; i += 3) {\n child = subscribers[i];\n callback = subscribers[i + settled];\n\n if (child) {\n invokeCallback(settled, child, callback, detail);\n } else {\n callback(detail);\n }\n }\n\n promise._subscribers.length = 0;\n }\n\n function ErrorObject() {\n this.error = null;\n }\n\n var TRY_CATCH_ERROR = new ErrorObject();\n\n function tryCatch(callback, detail) {\n try {\n return callback(detail);\n } catch (e) {\n TRY_CATCH_ERROR.error = e;\n return TRY_CATCH_ERROR;\n }\n }\n\n function invokeCallback(settled, promise, callback, detail) {\n var hasCallback = isFunction(callback),\n value = undefined,\n error = undefined,\n succeeded = undefined,\n failed = undefined;\n\n if (hasCallback) {\n value = tryCatch(callback, detail);\n\n if (value === TRY_CATCH_ERROR) {\n failed = true;\n error = value.error;\n value.error = null;\n } else {\n succeeded = true;\n }\n\n if (promise === value) {\n reject(promise, cannotReturnOwn());\n return;\n }\n } else {\n value = detail;\n succeeded = true;\n }\n\n if (promise._state !== PENDING) {\n // noop\n } else if (hasCallback && succeeded) {\n resolve(promise, value);\n } else if (failed) {\n reject(promise, error);\n } else if (settled === FULFILLED) {\n fulfill(promise, value);\n } else if (settled === REJECTED) {\n reject(promise, value);\n }\n }\n\n function initializePromise(promise, resolver) {\n try {\n resolver(function resolvePromise(value) {\n resolve(promise, value);\n }, function rejectPromise(reason) {\n reject(promise, reason);\n });\n } catch (e) {\n reject(promise, e);\n }\n }\n\n var id = 0;\n function nextId() {\n return id++;\n }\n\n function makePromise(promise) {\n promise[PROMISE_ID] = id++;\n promise._state = undefined;\n promise._result = undefined;\n promise._subscribers = [];\n }\n\n function Enumerator$1(Constructor, input) {\n this._instanceConstructor = Constructor;\n this.promise = new Constructor(noop);\n\n if (!this.promise[PROMISE_ID]) {\n makePromise(this.promise);\n }\n\n if (isArray(input)) {\n this.length = input.length;\n this._remaining = input.length;\n\n this._result = new Array(this.length);\n\n if (this.length === 0) {\n fulfill(this.promise, this._result);\n } else {\n this.length = this.length || 0;\n this._enumerate(input);\n if (this._remaining === 0) {\n fulfill(this.promise, this._result);\n }\n }\n } else {\n reject(this.promise, validationError());\n }\n }\n\n function validationError() {\n return new Error('Array Methods must be provided an Array');\n }\n\n Enumerator$1.prototype._enumerate = function (input) {\n for (var i = 0; this._state === PENDING && i < input.length; i++) {\n this._eachEntry(input[i], i);\n }\n };\n\n Enumerator$1.prototype._eachEntry = function (entry, i) {\n var c = this._instanceConstructor;\n var resolve$$1 = c.resolve;\n\n if (resolve$$1 === resolve$1) {\n var _then = getThen(entry);\n\n if (_then === then && entry._state !== PENDING) {\n this._settledAt(entry._state, i, entry._result);\n } else if (typeof _then !== 'function') {\n this._remaining--;\n this._result[i] = entry;\n } else if (c === Promise$2) {\n var promise = new c(noop);\n handleMaybeThenable(promise, entry, _then);\n this._willSettleAt(promise, i);\n } else {\n this._willSettleAt(new c(function (resolve$$1) {\n return resolve$$1(entry);\n }), i);\n }\n } else {\n this._willSettleAt(resolve$$1(entry), i);\n }\n };\n\n Enumerator$1.prototype._settledAt = function (state, i, value) {\n var promise = this.promise;\n\n if (promise._state === PENDING) {\n this._remaining--;\n\n if (state === REJECTED) {\n reject(promise, value);\n } else {\n this._result[i] = value;\n }\n }\n\n if (this._remaining === 0) {\n fulfill(promise, this._result);\n }\n };\n\n Enumerator$1.prototype._willSettleAt = function (promise, i) {\n var enumerator = this;\n\n subscribe(promise, undefined, function (value) {\n return enumerator._settledAt(FULFILLED, i, value);\n }, function (reason) {\n return enumerator._settledAt(REJECTED, i, reason);\n });\n };\n\n /**\n `Promise.all` accepts an array of promises, and returns a new promise which\n is fulfilled with an array of fulfillment values for the passed promises, or\n rejected with the reason of the first passed promise to be rejected. It casts all\n elements of the passed iterable to promises as it runs this algorithm.\n \n Example:\n \n ```javascript\n let promise1 = resolve(1);\n let promise2 = resolve(2);\n let promise3 = resolve(3);\n let promises = [ promise1, promise2, promise3 ];\n \n Promise.all(promises).then(function(array){\n // The array here would be [ 1, 2, 3 ];\n });\n ```\n \n If any of the `promises` given to `all` are rejected, the first promise\n that is rejected will be given as an argument to the returned promises's\n rejection handler. For example:\n \n Example:\n \n ```javascript\n let promise1 = resolve(1);\n let promise2 = reject(new Error(\"2\"));\n let promise3 = reject(new Error(\"3\"));\n let promises = [ promise1, promise2, promise3 ];\n \n Promise.all(promises).then(function(array){\n // Code here never runs because there are rejected promises!\n }, function(error) {\n // error.message === \"2\"\n });\n ```\n \n @method all\n @static\n @param {Array} entries array of promises\n @param {String} label optional string for labeling the promise.\n Useful for tooling.\n @return {Promise} promise that is fulfilled when all `promises` have been\n fulfilled, or rejected if any of them become rejected.\n @static\n */\n function all$1(entries) {\n return new Enumerator$1(this, entries).promise;\n }\n\n /**\n `Promise.race` returns a new promise which is settled in the same way as the\n first passed promise to settle.\n \n Example:\n \n ```javascript\n let promise1 = new Promise(function(resolve, reject){\n setTimeout(function(){\n resolve('promise 1');\n }, 200);\n });\n \n let promise2 = new Promise(function(resolve, reject){\n setTimeout(function(){\n resolve('promise 2');\n }, 100);\n });\n \n Promise.race([promise1, promise2]).then(function(result){\n // result === 'promise 2' because it was resolved before promise1\n // was resolved.\n });\n ```\n \n `Promise.race` is deterministic in that only the state of the first\n settled promise matters. For example, even if other promises given to the\n `promises` array argument are resolved, but the first settled promise has\n become rejected before the other promises became fulfilled, the returned\n promise will become rejected:\n \n ```javascript\n let promise1 = new Promise(function(resolve, reject){\n setTimeout(function(){\n resolve('promise 1');\n }, 200);\n });\n \n let promise2 = new Promise(function(resolve, reject){\n setTimeout(function(){\n reject(new Error('promise 2'));\n }, 100);\n });\n \n Promise.race([promise1, promise2]).then(function(result){\n // Code here never runs\n }, function(reason){\n // reason.message === 'promise 2' because promise 2 became rejected before\n // promise 1 became fulfilled\n });\n ```\n \n An example real-world use case is implementing timeouts:\n \n ```javascript\n Promise.race([ajax('foo.json'), timeout(5000)])\n ```\n \n @method race\n @static\n @param {Array} promises array of promises to observe\n Useful for tooling.\n @return {Promise} a promise which settles in the same way as the first passed\n promise to settle.\n */\n function race$1(entries) {\n /*jshint validthis:true */\n var Constructor = this;\n\n if (!isArray(entries)) {\n return new Constructor(function (_, reject) {\n return reject(new TypeError('You must pass an array to race.'));\n });\n } else {\n return new Constructor(function (resolve, reject) {\n var length = entries.length;\n for (var i = 0; i < length; i++) {\n Constructor.resolve(entries[i]).then(resolve, reject);\n }\n });\n }\n }\n\n /**\n `Promise.reject` returns a promise rejected with the passed `reason`.\n It is shorthand for the following:\n \n ```javascript\n let promise = new Promise(function(resolve, reject){\n reject(new Error('WHOOPS'));\n });\n \n promise.then(function(value){\n // Code here doesn't run because the promise is rejected!\n }, function(reason){\n // reason.message === 'WHOOPS'\n });\n ```\n \n Instead of writing the above, your code now simply becomes the following:\n \n ```javascript\n let promise = Promise.reject(new Error('WHOOPS'));\n \n promise.then(function(value){\n // Code here doesn't run because the promise is rejected!\n }, function(reason){\n // reason.message === 'WHOOPS'\n });\n ```\n \n @method reject\n @static\n @param {Any} reason value that the returned promise will be rejected with.\n Useful for tooling.\n @return {Promise} a promise rejected with the given `reason`.\n */\n function reject$1(reason) {\n /*jshint validthis:true */\n var Constructor = this;\n var promise = new Constructor(noop);\n reject(promise, reason);\n return promise;\n }\n\n function needsResolver() {\n throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');\n }\n\n function needsNew() {\n throw new TypeError(\"Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.\");\n }\n\n /**\n Promise objects represent the eventual result of an asynchronous operation. The\n primary way of interacting with a promise is through its `then` method, which\n registers callbacks to receive either a promise's eventual value or the reason\n why the promise cannot be fulfilled.\n \n Terminology\n -----------\n \n - `promise` is an object or function with a `then` method whose behavior conforms to this specification.\n - `thenable` is an object or function that defines a `then` method.\n - `value`