UNPKG

105 kBSource Map (JSON)View Raw
1{"version":3,"sources":["webpack://cqSpaPageModelManager/webpack/universalModuleDefinition","webpack://cqSpaPageModelManager/webpack/bootstrap","webpack://cqSpaPageModelManager/./src/InternalConstants.js","webpack://cqSpaPageModelManager/./src/PathUtils.js","webpack://cqSpaPageModelManager/./src/Constants.js","webpack://cqSpaPageModelManager/external \"clone\"","webpack://cqSpaPageModelManager/./src/MetaProperty.js","webpack://cqSpaPageModelManager/./src/EditorClient.js","webpack://cqSpaPageModelManager/./src/ModelStore.js","webpack://cqSpaPageModelManager/./src/ModelManager.js","webpack://cqSpaPageModelManager/./src/EventType.js","webpack://cqSpaPageModelManager/./src/ModelClient.js","webpack://cqSpaPageModelManager/./node_modules/path-browserify/index.js","webpack://cqSpaPageModelManager/external \"url\"","webpack://cqSpaPageModelManager/./index.js","webpack://cqSpaPageModelManager/./src/ModelRouter.js","webpack://cqSpaPageModelManager/./node_modules/process/browser.js"],"names":["root","factory","exports","module","define","amd","self","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","InternalConstants","DEFAULT_SLING_MODEL_SELECTOR","DEFAULT_MODEL_JSON_EXTENSION","CONTEXT_PATH_REGEXP","JCR_CONTENT_PATTERN","Constants","JCR_CONTENT","PathUtils","window","e","location","getCurrentPathname","matches","exec","lastIndex","path","rootPath","localPath","internalize","sanitize","url","contextPath","getContextPath","startsWith","endsWith","replace","propertyName","isBrowser","meta","document","head","querySelector","content","convertToModelUrl","metaModelUrl","getMetaPropertyValue","MetaProperty","PAGE_MODEL_ROOT_URL","getCurrentPageModelUrl","sanitizedPath","parse","pathname","selectorIndex","indexOf","substr","normalizePath","extension","length","extensionPath","match","queue","selector","index","slice","undefined","eventName","options","dispatchEvent","CustomEvent","paths","normalize","filter","join","splashIndex","lastIndexOf","substring","RegExp","test","targetPath","targetPathChildren","makeRelative","split","rootPathChildren","delimitators","forEach","delimitator","newPaths","delim","makeAbsolute","concat","lastPath","splice","pagePath","dataPath","splitPaths","itemPath","strings","str","returnStr","TYPE_PROP","ITEMS_PROP","ITEMS_ORDER_PROP","PATH_PROP","CHILDREN_PROP","HIERARCHY_TYPE_PROP","require","PAGE_MODEL_ROUTE_FILTERS","PAGE_MODEL_ROUTER","triggerPageModelLoaded","model","dispatchGlobalCustomEvent","EventType","PAGE_MODEL_LOADED","detail","clone","EditorClient","ModelManager","_modelManager","_windowListener","event","msg","_updateModel","console","error","addEventListener","PAGE_MODEL_UPDATE","cmd","siblingName","insertBefore","data","modelStore","setData","_notifyListeners","removeData","getParentNodePath","getNodeName","_modelStore","insertData","log","_data","removeEventListener","ModelStore","initialize","_pageContentDelimiter","_rootPath","parent","parentPath","answer","items","pathKey","childItem","subPath","subpath","pageDelimiter","_getStartStrings","childParentPath","trimStrings","_findItemData","newData","itemKey","getData","localData","immutable","dataPaths","splitPageContentPaths","pageData","_getPageData","result","isItem","itemName","push","warn","adaptPagePath","isRouteExcluded","route","routeFilters","getRouteFilters","modelClient","Promise","resolve","reject","addSelector","addExtension","externalize","config","initialModel","destroy","_modelClient","_listenersMap","_fetchPromises","_initPromise","metaPropertyModelUrl","currentPathname","rootModelURL","ModelClient","_editorClient","_checkDependencies","then","rootModelPath","_fetchData","rootModel","modelRootPath","childPath","promise","fetch","_toModelPath","obj","forceReload","item","_storeData","listenersForPath","listener","callback","adaptedPath","PAGE_MODEL_INIT","PAGE_MODEL_ROUTE_CHANGED","apiHost","_apiHost","modelPath","err","Error","credentials","response","status","json","normalizeArray","parts","allowAboveRoot","up","last","unshift","xs","f","res","resolvedPath","resolvedAbsolute","arguments","process","cwd","TypeError","charAt","isAbsolute","trailingSlash","Array","relative","from","to","trim","arr","start","end","fromParts","toParts","Math","min","samePartsLength","outputParts","sep","delimiter","dirname","code","charCodeAt","hasRoot","matchedSlash","basename","ext","extname","startDot","startPart","preDotState","len","ROUTER_MODES","DISABLED","CONTENT_PATH","getModelPath","localUrl","endPosition","queryPosition","isModelRouterEnabled","modelRouterMetaType","dispatchRouteChanged","ModelManagerSerice","routeModel","pushState","history","replaceState","state","title","apply","cachedSetTimeout","cachedClearTimeout","defaultSetTimout","defaultClearTimeout","runTimeout","fun","setTimeout","clearTimeout","currentQueue","draining","queueIndex","cleanUpNextTick","drainQueue","timeout","run","marker","runClearTimeout","Item","array","noop","nextTick","args","browser","env","argv","version","versions","on","addListener","once","off","removeListener","removeAllListeners","emit","prependListener","prependOnceListener","listeners","binding","chdir","dir","umask"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAA+B,sBAAID,IAEnCD,EAA4B,sBAAIC,IARlC,CASmB,oBAATK,KAAuBA,KAAOC,MAAM,WAC9C,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUR,QAGnC,IAAIC,EAASK,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHV,QAAS,IAUV,OANAW,EAAQH,GAAUI,KAAKX,EAAOD,QAASC,EAAQA,EAAOD,QAASO,GAG/DN,EAAOS,GAAI,EAGJT,EAAOD,QA0Df,OArDAO,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASf,EAASgB,EAAMC,GAC3CV,EAAoBW,EAAElB,EAASgB,IAClCG,OAAOC,eAAepB,EAASgB,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAASvB,GACX,oBAAXwB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAepB,EAASwB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAepB,EAAS,aAAc,CA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,SAAU,EAClB1E,EAAQ2E,IAAM,GACd3E,EAAQ4E,KAAO,GACf5E,EAAQ6E,QAAU,GAClB7E,EAAQ8E,SAAW,GAInB9E,EAAQ+E,GAAKR,EACbvE,EAAQgF,YAAcT,EACtBvE,EAAQiF,KAAOV,EACfvE,EAAQkF,IAAMX,EACdvE,EAAQmF,eAAiBZ,EACzBvE,EAAQoF,mBAAqBb,EAC7BvE,EAAQqF,KAAOd,EACfvE,EAAQsF,gBAAkBf,EAC1BvE,EAAQuF,oBAAsBhB,EAE9BvE,EAAQwF,UAAY,SAAUpV,GAAQ,MAAO,IAE7C4P,EAAQyF,QAAU,SAAUrV,GACxB,MAAM,IAAI2O,MAAM,qCAGpBiB,EAAQC,IAAM,WAAc,MAAO,KACnCD,EAAQ0F,MAAQ,SAAUC,GACtB,MAAM,IAAI5G,MAAM,mCAEpBiB,EAAQ4F,MAAQ,WAAa,OAAO","file":"cq-spa-page-model-manager.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"cqSpaPageModelManager\"] = factory();\n\telse\n\t\troot[\"cqSpaPageModelManager\"] = factory();\n})(typeof self !== 'undefined' ? self : this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 9);\n","/*\n * ADOBE CONFIDENTIAL\n *\n * Copyright 2018 Adobe Systems Incorporated\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe Systems Incorporated and its suppliers,\n * if any. The intellectual and technical concepts contained\n * herein are proprietary to Adobe Systems Incorporated and its\n * suppliers and may be covered by U.S. and Foreign Patents,\n * patents in process, and are protected by trade secret or copyright law.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe Systems Incorporated.\n */\n\nconst DEFAULT_SLING_MODEL_SELECTOR = 'model';\n\nconst InternalConstants = {\n\n DEFAULT_SLING_MODEL_SELECTOR: DEFAULT_SLING_MODEL_SELECTOR,\n\n DEFAULT_MODEL_JSON_EXTENSION: '.' + DEFAULT_SLING_MODEL_SELECTOR + '.json'\n};\n\nexport default InternalConstants;","/*\n * ADOBE CONFIDENTIAL\n *\n * Copyright 2018 Adobe Systems Incorporated\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe Systems Incorporated and its suppliers,\n * if any. The intellectual and technical concepts contained\n * herein are proprietary to Adobe Systems Incorporated and its\n * suppliers and may be covered by U.S. and Foreign Patents,\n * patents in process, and are protected by trade secret or copyright law.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe Systems Incorporated.\n */\nimport Constants from \"./Constants\";\nimport InternalConstants from \"./InternalConstants\";\nimport MetaProperty from \"./MetaProperty\";\nimport { normalize as normalizePath } from \"path\";\nimport url from \"url\";\n\n/**\n * Regexp used to extract the context path of a location.\n * The context path is extracted by assuming that the location starts with the context path followed by one of the following node names\n */\nconst CONTEXT_PATH_REGEXP = /^(.*)?(?:\\/(?:content|conf|apps|libs|etc)\\/.*)/g;\n\nconst JCR_CONTENT_PATTERN = '(.+)/' + Constants.JCR_CONTENT +'/(.+)';\n\n/**\n * Helper functions related to path manipulation.\n *\n * @namespace PathUtils\n */\nexport class PathUtils {\n\n /**\n * Returns if the code executes in the browser context or not by checking for the\n * existance of the window object\n *\n * @returns {Boolean} the result of the check of the existance of the window object\n */\n static isBrowser() {\n try {\n return typeof window !== 'undefined';\n }catch(e){\n return false;\n }\n }\n\n /**\n * Returns the context path of the given location.\n * If no location is provided, it fallbacks to the current location.\n * @param {String} [location] - Location to be used to detect the context path from.\n * @returns {String}\n */\n static getContextPath(location) {\n location = location || this.getCurrentPathname();\n if (!location) {\n return \"\";\n }\n\n let matches = CONTEXT_PATH_REGEXP.exec(location);\n CONTEXT_PATH_REGEXP.lastIndex = 0;\n if (matches && matches[1]) {\n return matches[1];\n } else {\n return \"\";\n }\n }\n\n /**\n * Adapts the provided path to a valid model path.\n * Returns an empty string if the given path is equal to the root model path.\n * This function is a utility tool that converts a provided root model path into an internal specific empty path\n *\n * @param {string} [path] - raw model path\n * @return {string} the valid model path\n *\n * @private\n */\n static adaptPagePath(path, rootPath) {\n if (!path) {\n return '';\n }\n\n if (!rootPath) {\n return path;\n }\n\n const localPath = PathUtils.internalize(path);\n const localRootModelPath = PathUtils.sanitize(rootPath);\n\n return localPath === localRootModelPath ? '' : localPath;\n }\n\n /**\n * Returns the given URL externalized by adding the optional context path\n *\n * @param {string} url - URL to externalize\n * @returns {string}\n */\n static externalize(url) {\n const contextPath = this.getContextPath();\n\n if (!contextPath || url.startsWith(contextPath)) {\n return url;\n }\n\n return contextPath + url;\n }\n\n /**\n * Returns the given URL internalized by removing the optional context path\n *\n * @param {string} url - URL to internalize\n * @returns {string}\n */\n static internalize(url) {\n if (!url) {\n return url;\n }\n\n const contextPath = this.getContextPath();\n\n // Does the path starts with a node\n if (url.startsWith(contextPath.endsWith('/') ? contextPath : contextPath + '/')) {\n return url.replace(contextPath, \"\");\n } else {\n return url;\n }\n }\n\n /**\n * Returns the value of the meta property with the given key\n *\n * @param {string} propertyName - name of the meta property\n * @return {string|undefined}\n */\n static getMetaPropertyValue(propertyName) {\n if (this.isBrowser()) {\n const meta = document.head.querySelector('meta[property=\"' + propertyName + '\"]');\n return meta && meta.content;\n }\n }\n\n /**\n * Returns a model path for the given URL\n *\n * @param {string} url - Raw URL for which to get a model URL\n * @return {string|undefined}\n */\n static convertToModelUrl(url) {\n return url && url.replace && url.replace(/\\.htm(l)?$/, InternalConstants.DEFAULT_MODEL_JSON_EXTENSION);\n }\n\n /**\n * Returns the model URL as contained in the current page URL\n *\n * @return {string}\n */\n static getCurrentPageModelUrl() {\n // extract the model from the pathname\n return this.convertToModelUrl(this.getCurrentPathname());\n }\n\n /**\n * Returns the URL of the page model to initialize the page model manager with.\n * It is either derived from a meta tag property called 'cq:pagemodel_root_url' or from the given location.\n * If no location is provided, it derives it from the current location.\n *\n * @param {String} [url] - path or URL to be used to derive the page model URL from\n * @returns {String}\n */\n static getModelUrl(url) {\n // Model path extracted from the given url\n if (url && url.replace) {\n return this.convertToModelUrl(url);\n }\n\n // model path from the meta property\n const metaModelUrl = this.getMetaPropertyValue(MetaProperty.PAGE_MODEL_ROOT_URL);\n\n if (metaModelUrl) {\n return metaModelUrl;\n }\n\n // Model URL extracted from the current page URL\n return this.getCurrentPageModelUrl();\n }\n\n /**\n * Returns the given path after sanitizing it.\n * This function should be called on page paths before storing them in the page model,\n * to make sure only properly formatted paths (e.g., \"/content/mypage\") are stored.\n * @param {string} path - Path of the page to be sanitized.\n * @return {string|undefined}\n */\n static sanitize(path) {\n if (!path) {\n return;\n }\n\n // Parse URL, then remove protocol and domain (if they exist).\n // Important: URLs starting with \"//some/path\" will resolve to\n // \"http://some/path\" or \"https://some/path\" (note that the first\n // substring will be used as the hostname)\n let sanitizedPath = url.parse(path, false, true).pathname;\n\n // Remove context path (if it exists)\n sanitizedPath = this.internalize(sanitizedPath);\n\n // Remove selectors (if they exist)\n let selectorIndex = sanitizedPath.indexOf(\".\");\n if (selectorIndex > -1) {\n sanitizedPath = sanitizedPath.substr(0, selectorIndex);\n }\n\n // Normalize path (replace multiple consecutive slashes with a single\n // one). It's important that the final sanitized URL does not start with\n // \"//\" as this might lead to resources from other sites being loaded\n sanitizedPath = normalizePath(sanitizedPath);\n\n return sanitizedPath;\n }\n\n /**\n * Returns the given path extended with the given extension.\n * @param {String} path - Path to be extended.\n * @param {String} extension - Extension to be added.\n * @returns {String}\n */\n static addExtension(path, extension) {\n if (!extension || extension.length < 1) {\n return path;\n }\n\n if (!extension.startsWith(\".\")) {\n extension = \".\" + extension;\n }\n\n if (!path || path.length < 1 || path.indexOf(extension) > -1) {\n return path;\n }\n\n let extensionPath = path;\n\n // Groups\n // 1. the resource\n // 2. the selectors and the extension\n // 3. the suffix\n // 4. the parameters\n let match = /^((?:[/a-zA-Z0-9:_-]*)+)(?:\\.?)([a-zA-Z0-9._-]*)(?:\\/?)([a-zA-Z0-9/._-]*)(?:\\??)([a-zA-Z0-9=&]*)$/g.exec(\n path\n );\n let queue = \"\";\n\n if (match && match.length > 2) {\n // suffix\n queue = match[3] ? \"/\" + match[3] : \"\";\n // parameters\n queue += match[4] ? \"?\" + match[4] : \"\";\n\n extensionPath =\n match[1] +\n \".\" +\n match[2].replace(/\\.htm(l)?/, extension) +\n queue;\n }\n\n return extensionPath.indexOf(extension) > -1\n ? extensionPath\n : extensionPath + extension + queue;\n }\n\n /**\n * Returns the given path extended with the given selector.\n * @param {String} path - Path to be extended.\n * @param {String} selector - Selector to be added.\n * @returns {String}\n */\n static addSelector(path, selector) {\n if (!selector || selector.length < 1) {\n return path;\n }\n\n if (!selector.startsWith(\".\")) {\n selector = \".\" + selector;\n }\n\n if (!path || path.length < 1 || path.indexOf(selector) > -1) {\n return path;\n }\n\n let index = path.indexOf(\".\") || path.length;\n\n if (index < 0) {\n return path + selector;\n }\n\n return path.slice(0, index) + selector + path.slice(index, path.length);\n }\n\n /**\n * Returns the current location as a string.\n * @returns {String}\n */\n static getCurrentPathname() {\n return this.isBrowser() ? window.location.pathname : undefined;\n }\n\n /**\n * Dispatches a custom event on the window object, when in the browser context\n *\n * @param {String} eventName - the name of the custom event\n * @param {Object} options - the custom event options\n */\n static dispatchGlobalCustomEvent(eventName, options) {\n if (this.isBrowser()) {\n window.dispatchEvent(new CustomEvent(eventName, options));\n }\n }\n\n /**\n * Joins given path segments into a string using /\n *\n * @param paths\n * @returns {string}\n */\n static join (paths) {\n return paths ? this.normalize(paths.filter((path) => path).join('/')) : \"\";\n }\n\n /**\n * Normalizes given path by replacing repeated / with a single one\n *\n * @param {string} path\n * @returns {string}\n */\n static normalize(path) {\n if (!path) return \"\";\n return path ? path.replace(/(\\/+)/g, '/') : \"\";\n }\n\n /**\n * Returns path that starts with /\n *\n * @param {string} path\n * @returns {*}\n */\n static makeAbsolute(path) {\n if (!path || (typeof path !== \"string\")) return \"\";\n return path.startsWith('/') ? path : \"/\" + path;\n }\n\n /**\n * Returns path without the leading /\n *\n * @param path\n * @returns {*}\n */\n static makeRelative(path) {\n if (!path || (typeof path !== \"string\")) return \"\";\n return path.startsWith('/') ? path.slice(1) : path;\n }\n\n /**\n * Returns path to the direct parent\n *\n * @param path\n * @returns {*|boolean|string}\n */\n static getParentNodePath(path) {\n const splashIndex = path.lastIndexOf('/') + 1;\n return path && typeof path === 'string' && splashIndex > 0 && splashIndex < path.length && path.substring(0, splashIndex - 1);\n }\n\n /**\n * Checks if given path is an JCR path\n *\n * @param path\n * @returns {boolean}\n */\n static isItem(path) {\n return new RegExp(JCR_CONTENT_PATTERN).test(path);\n }\n\n /**\n * Returns the name of the last node of the given path\n * @param path\n * @returns {*|boolean|string}\n */\n static getNodeName(path) {\n const splashIndex = path.lastIndexOf('/') + 1;\n return path && typeof path === 'string' && splashIndex < path.length && path.substring(splashIndex, path.length);\n }\n\n /**\n * Returns the subpath of the targetPath relative to the rootPath,\n * or the targetPath if the rootPath is not a root of the targetPath.\n *\n * @param targetPath\n * @param rootPath\n * @returns {*}\n */\n static subpath(targetPath, rootPath) {\n if (!targetPath) {\n return \"\";\n }\n\n let targetPathChildren = PathUtils.makeRelative(targetPath).split('/');\n let rootPathChildren = PathUtils.makeRelative(rootPath).split('/');\n\n if (targetPathChildren.length < rootPathChildren.length) {\n return targetPath;\n }\n\n let index;\n for(index = 0; index < rootPathChildren.length; ++index) {\n if (targetPathChildren[index] !== rootPathChildren[index]) {\n break;\n }\n }\n\n if (index === rootPathChildren.length) {\n return targetPathChildren.slice(index).join(\"/\");\n } else {\n return targetPath;\n }\n }\n\n /**\n * Returns an array of segments of the path, split by the custom set of delimitators passed as an array.\n *\n * @param {string} path\n * @param {array} delimitators\n * @returns {*}\n */\n static splitByDelimitators(path, delimitators) {\n let paths = [path];\n delimitators.forEach((delimitator) => {\n let newPaths = [];\n let delim = PathUtils.normalize(PathUtils.makeAbsolute(delimitator) + \"/\");\n paths.forEach((path) => {\n newPaths = newPaths.concat(path.split(delim));\n if (path.endsWith(delimitator)) {\n let lastPath = newPaths.splice(newPaths.length-1, 1)[0];\n if (lastPath !== delimitator) {\n newPaths = newPaths.concat(lastPath.split(PathUtils.makeAbsolute(delimitator)));\n }\n }\n newPaths = newPaths.filter((path) => path);\n });\n paths = newPaths;\n });\n return paths;\n }\n\n /**\n * Returns an JCR path based on pagePath and dataPath\n *\n * @param pagePath path to the page\n * @param dataPath path to the item on the page\n * @returns {string}\n */\n static _getJCRPath(pagePath, dataPath) {\n return pagePath + '/' + Constants.JCR_CONTENT + '/' + dataPath;\n }\n\n /**\n * Returns object containing pagePath (path to a page) and, if exists, itemPath (path to the item on that page)\n * from the passed path\n *\n * @param {string} path\n * @returns {{pagePath}}\n */\n static splitPageContentPaths(path) {\n if (!path && typeof path !== 'string') {\n return;\n }\n\n const splitPaths = path.split('/' + Constants.JCR_CONTENT + '/');\n\n let split = {\n pagePath: splitPaths[0]\n };\n\n if (splitPaths.length > 1) {\n split.itemPath = splitPaths[1];\n }\n\n return split;\n }\n\n /**\n * Returns path that is no longer prefixed nor suffixed by the set of strings passed as an array\n *\n * @param path\n * @param {array} strings\n * @returns {*}\n */\n static trimStrings(path, strings) {\n strings.forEach((str) => {\n while(path.startsWith(str)) {\n path = PathUtils.makeRelative(path.slice(str.length));\n }\n\n while(path.endsWith(str)) {\n path = path.slice(0, path.length - str.length);\n if (path.endsWith('/')) {\n path = path.slice(0, path.length - 1);\n }\n }\n });\n return path;\n }\n\n static _getStartStrings(path, strings) {\n let returnStr = \"\";\n strings.forEach((str) => {\n while(path.startsWith(str)) {\n path = PathUtils.makeRelative(path.slice(str.length));\n returnStr = returnStr + \"/\" + str;\n }\n });\n return PathUtils.makeRelative(returnStr);\n }\n}\n","/*\n * ADOBE CONFIDENTIAL\n *\n * Copyright 2018 Adobe Systems Incorporated\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe Systems Incorporated and its suppliers,\n * if any. The intellectual and technical concepts contained\n * herein are proprietary to Adobe Systems Incorporated and its\n * suppliers and may be covered by U.S. and Foreign Patents,\n * patents in process, and are protected by trade secret or copyright law.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe Systems Incorporated.\n */\n\n/**\n * Useful variables for interacting with CQ/AEM components\n *\n * @namespace Constants\n */\nconst Constants = {\n\n /**\n * Type of the item\n *\n * @type {string}\n */\n TYPE_PROP: ':type',\n\n /**\n * List of child items of an item\n *\n * @type {string}\n */\n ITEMS_PROP: ':items',\n\n /**\n * Order in which the items should be listed\n *\n * @type {string}\n */\n ITEMS_ORDER_PROP: ':itemsOrder',\n\n /**\n * Path of an item\n *\n * @type {string}\n */\n PATH_PROP: ':path',\n\n /**\n * Children of a hierarchical item\n *\n * @type {string}\n */\n CHILDREN_PROP: ':children',\n\n /**\n * Hierarchical type of the item\n */\n HIERARCHY_TYPE_PROP: ':hierarchyType',\n\n /**\n * JCR CONTENT Node\n */\n JCR_CONTENT: \"jcr:content\"\n};\n\nexport default Constants;\n","module.exports = require(\"clone\");","/*\n * ADOBE CONFIDENTIAL\n *\n * Copyright 2018 Adobe Systems Incorporated\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe Systems Incorporated and its suppliers,\n * if any. The intellectual and technical concepts contained\n * herein are proprietary to Adobe Systems Incorporated and its\n * suppliers and may be covered by U.S. and Foreign Patents,\n * patents in process, and are protected by trade secret or copyright law.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe Systems Incorporated.\n */\n\n/**\n * Names of the meta properties associated with the PageModelProvider and ModelRouter\n *\n * @type {{PAGE_MODEL_ROOT_URL: string, PAGE_MODEL_ROUTE_FILTERS: string, PAGE_MODEL_ROUTER: string}}\n */\nconst MetaProperty = {\n\n PAGE_MODEL_ROOT_URL: 'cq:pagemodel_root_url',\n\n PAGE_MODEL_ROUTE_FILTERS: 'cq:pagemodel_route_filters',\n\n PAGE_MODEL_ROUTER: 'cq:pagemodel_router'\n\n};\n\nexport default MetaProperty;","/*\n * ADOBE CONFIDENTIAL\n *\n * Copyright 2018 Adobe Systems Incorporated\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe Systems Incorporated and its suppliers,\n * if any. The intellectual and technical concepts contained\n * herein are proprietary to Adobe Systems Incorporated and its\n * suppliers and may be covered by U.S. and Foreign Patents,\n * patents in process, and are protected by trade secret or copyright law.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe Systems Incorporated.\n */\nimport { PathUtils } from \"./PathUtils\";\nimport clone from 'clone';\nimport EventType from \"./EventType\";\n\n/**\n * Broadcast an event to indicate the page model has been loaded\n *\n * @param {{}} model - model item to be added to the broadcast payload\n * @fires cq-pagemodel-loaded\n */\nexport function triggerPageModelLoaded(model) {\n // Deep copy to protect the internal state of the page mode\n PathUtils.dispatchGlobalCustomEvent(EventType.PAGE_MODEL_LOADED, {\n detail: {\n model: clone(model)\n }\n });\n}\n\n/**\n * The EditorClient is responsible for the interactions with the Page Editor.\n */\nexport class EditorClient {\n\n constructor(ModelManager) {\n this._modelManager = ModelManager;\n\n this._windowListener = (event) => {\n if (!event || !event.detail || !event.detail.msg) {\n console.error('EditorService.js', 'No message passed to cq-pagemodel-update', event);\n return;\n }\n\n this._updateModel(event.detail.msg);\n };\n\n if (PathUtils.isBrowser()) {\n window.addEventListener(EventType.PAGE_MODEL_UPDATE, this._windowListener);\n }\n }\n\n /**\n * Updates the page model with the given data\n *\n * @param {Object} msg - Object containing the data to update the page model\n * @property {String} msg.dataPath - Relative data path in the PageModel which needs to be updated\n * @property {String} msg.pagePath - Absolute page path corresponding to the page in the PageModel which needs to be updated\n * @param {String} msg.cmd - Command Action requested via Editable on the content Node\n * @param {Object} msg.data - Data that needs to be updated in the PageModel at {path}\n *\n * @fires cq-pagemodel-loaded\n *\n * @private\n */\n _updateModel(msg) {\n if (!msg || !msg.cmd || !msg.path) {\n console.error('PageModelManager.js', 'Not enough data received to update the page model');\n return;\n }\n // Path in the PageModel which needs to be updated\n let path = msg.path;\n // Command Action requested via Editable on the content Node\n let cmd = msg.cmd;\n // Data that needs to be updated in the page model at the given path\n let data = clone(msg.data);\n\n let siblingName;\n let itemPath;\n let insertBefore;\n\n switch(cmd) {\n case 'replace':\n this._modelManager.modelStore.setData(path, data);\n this._modelManager._notifyListeners(path);\n break;\n\n case 'delete':\n this._modelManager.modelStore.removeData(path);\n this._modelManager._notifyListeners(PathUtils.getParentNodePath(path));\n break;\n\n case 'insertBefore':\n insertBefore = true;\n // No break as we want both insert command to be treated the same way\n // eslint-disable-next-line no-fallthrough\n case 'insertAfter':\n // The logic relative to the item path and sibling between the editor and the ModelManager is reversed\n // Adapting the command to the ModelManager API\n siblingName = PathUtils.getNodeName(path);\n itemPath = PathUtils.getParentNodePath(path) + \"/\" + data.key;\n this._modelManager._modelStore.insertData(itemPath, data.value, siblingName, insertBefore);\n this._modelManager._notifyListeners(PathUtils.getParentNodePath(path));\n\n break;\n\n default:\n // \"replaceContent\" command not supported\n // \"moveBefore\", \"moveAfter\" commands not supported.\n // As instead, we are replacing source and destination parents because they can contain data about the item we want to relocate\n console.log('EditorClient', 'unsupported command:', cmd);\n }\n\n triggerPageModelLoaded(this._modelManager.modelStore._data);\n }\n\n /**\n * @private\n */\n destroy() {\n this._modelManager = null;\n delete this._modelManager;\n\n if (PathUtils.isBrowser()) {\n window.removeEventListener(EventType.PAGE_MODEL_UPDATE, this._windowListener);\n }\n }\n}","/*\n * ADOBE CONFIDENTIAL\n *\n * Copyright 2018 Adobe Systems Incorporated\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe Systems Incorporated and its suppliers,\n * if any. The intellectual and technical concepts contained\n * herein are proprietary to Adobe Systems Incorporated and its\n * suppliers and may be covered by U.S. and Foreign Patents,\n * patents in process, and are protected by trade secret or copyright law.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe Systems Incorporated.\n */\nimport clone from 'clone';\nimport Constants from \"./Constants\";\nimport { PathUtils } from \"./PathUtils\";\n\n/**\n * The ModelStore is in charge of providing access to the data model. It provides the CRUD operations over the model.\n * To protect the integrity of the data it initially returns immutable data. If needed, you can request a mutable object.\n */\nexport class ModelStore {\n\n /**\n * Item wrapper containing information about the item parent\n *\n * @typedef {Object} ItemWrapper\n * @property {string} [key] - Name of the item\n * @property {{}} [data] - Item data\n * @property {{}} [parent] - Parent item\n * @property {string} [parentPath] - Path of the parent item\n */\n\n /**\n * @param {string} [rootPath] - Root path of the model\n * @param {{}} [data] - Initial model\n */\n constructor(rootPath, data) {\n this.initialize(rootPath, data);\n this._pageContentDelimiter = [Constants.JCR_CONTENT];\n }\n\n /**\n * Initializes the the ModelManager\n *\n * @param {string} rootPath - Root path of the model\n * @param {{}} data - Initial model\n */\n initialize(rootPath, data) {\n if (data) {\n this._data = data;\n }\n\n this._rootPath = rootPath;\n }\n\n /**\n * Returns the current root path\n *\n * @return {string}\n */\n get rootPath() {\n return this._rootPath;\n }\n\n /**\n *\n * @param {string} pagePath - Path of the page\n *\n * @return {{}|undefined} - Data of the page\n * @private\n */\n _getPageData(pagePath) {\n if (!this._data) {\n return;\n }\n\n if ('' === pagePath || pagePath === this._data[Constants.PATH_PROP] || pagePath === this.rootPath) {\n return this._data;\n }\n\n return this._data[Constants.CHILDREN_PROP] && this._data[Constants.CHILDREN_PROP][pagePath];\n }\n\n /**\n * Retrieves the item and eventually returns the data wrapped with the parent information\n *\n * @param {string} path - Path of the item\n * @param {{}} [data=_data] - Data to be explored\n * @param {{}} [parent] - Parent data\n * @param {string} [parentPath=''] - Path of the parent data\n * @return {ItemWrapper}\n * @private\n */\n _findItemData(path, data = this._data, parent = undefined, parentPath = '') {\n let answer = {\n parent: parent,\n parentPath: parentPath\n };\n\n let items = data[Constants.ITEMS_PROP];\n\n if (!items) {\n return answer;\n }\n\n for (let pathKey in items) {\n if (!Object.prototype.hasOwnProperty.call(items, pathKey)) {\n continue;\n }\n\n let childItem = items[pathKey];\n\n // Direct child. We reached the leaf\n if (pathKey === path) {\n answer.data = items[pathKey];\n answer.key = pathKey;\n return answer;\n } else {\n // Continue traversing\n let subPath = PathUtils.subpath(path, pathKey);\n let pageDelimiter = PathUtils._getStartStrings(subPath, this._pageContentDelimiter);\n let childParentPath = PathUtils.join([parentPath, pathKey, pageDelimiter]);\n subPath = PathUtils.trimStrings(subPath, this._pageContentDelimiter);\n\n if (subPath !== path) {\n childItem = this._findItemData(subPath, childItem, childItem, childParentPath);\n\n if (childItem) {\n return childItem;\n }\n }\n }\n }\n\n return answer;\n }\n\n /**\n * Replaces the data in the given location\n *\n * @param {string} path - Path of the data\n * @param {{}} newData - New data to be set\n */\n setData(path, newData) {\n let itemKey = PathUtils.getNodeName(path);\n let data = this.getData(PathUtils.getParentNodePath(path), false);\n\n if (data && data[Constants.ITEMS_PROP]) {\n let localData = clone(newData);\n data[Constants.ITEMS_PROP][itemKey] = localData.value;\n }\n }\n\n /**\n * Returns the data for the given path. If no path is provided, it returns the whole data\n *\n * @param {string} [path] - Path to the data\n * @param {boolean} [immutable=true] - Should the returned data be a clone\n * @return {*}\n */\n getData(path, immutable = true) {\n if (!path && typeof path !== 'string') {\n return immutable ? clone(this._data) : this._data;\n }\n\n // Request for the root path\n // Returns the full data\n if (path === this._rootPath || path === this._rootPath + '/' + Constants.JCR_CONTENT) {\n return immutable? clone(this._data) : this._data;\n }\n\n const dataPaths = PathUtils.splitPageContentPaths(path);\n\n let pageData = this._getPageData(dataPaths.pagePath);\n\n // If there is no page\n // or if we are getting the data of a page\n // return the page data\n if (!pageData || !dataPaths.itemPath) {\n return immutable? clone(pageData) : pageData;\n }\n\n let result = this._findItemData(dataPaths.itemPath, pageData);\n\n if (result) {\n return immutable ? clone(result.data) : result.data;\n }\n }\n\n /**\n * Insert the provided data at the location of the given path. If no sibling name is provided the data is added at the end of the list\n *\n * @param {string} path - Path to the data\n * @param {{}} data - Data to be inserted\n * @param {string} [siblingName] - Name of the item before or after which to add the data\n * @param {boolean} [insertBefore=false] - Should the data be inserted before the sibling\n */\n insertData(path, data, siblingName, insertBefore = false) {\n data = clone(data);\n // We need to find the parent\n if (!path) {\n console.warn(\"No path provided for data:\", data);\n return;\n }\n\n const isItem = PathUtils.isItem(path);\n\n if (!isItem && this._data[Constants.CHILDREN_PROP]) {\n // Page data\n this._data[Constants.CHILDREN_PROP][path] = data;\n return;\n }\n\n // Item data\n const dataPaths = PathUtils.splitPageContentPaths(path);\n let pageData = this._getPageData(dataPaths.pagePath);\n let result = this._findItemData(dataPaths.itemPath, pageData);\n let parent = result.parent || pageData || this._data;\n let itemName = PathUtils.getNodeName(dataPaths.itemPath);\n\n if (parent && Object.prototype.hasOwnProperty.call(parent, Constants.ITEMS_PROP)) {\n parent[Constants.ITEMS_PROP][itemName] = data;\n\n if (Object.prototype.hasOwnProperty.call(parent, Constants.ITEMS_ORDER_PROP)) {\n let index = parent[Constants.ITEMS_ORDER_PROP].indexOf(siblingName);\n\n if (index > -1) {\n parent[Constants.ITEMS_ORDER_PROP].splice(insertBefore ? index : index + 1, 0, itemName);\n } else {\n parent[Constants.ITEMS_ORDER_PROP].push(itemName);\n }\n }\n }\n }\n\n /**\n * Removes the data located at the provided location\n *\n * @param {string} path - Path of the data\n * @return {string|undefined} - Path to the parent item initially containing the removed data\n */\n removeData(path) {\n if (!path) {\n return;\n }\n\n const isItem = PathUtils.isItem(path);\n\n if (!isItem && this._data[Constants.CHILDREN_PROP]) {\n // Page data\n delete this._data[Constants.CHILDREN_PROP][path];\n return;\n }\n\n // Item data\n const dataPaths = PathUtils.splitPageContentPaths(path);\n let pageData = this._getPageData(dataPaths.pagePath);\n let result = this._findItemData(dataPaths.itemPath, pageData);\n\n if (result.data) {\n if (result && result.parent && Object.prototype.hasOwnProperty.call(result.parent, Constants.ITEMS_PROP)) {\n let { parent } = result;\n let itemName = PathUtils.getNodeName(dataPaths.itemPath);\n\n delete parent[Constants.ITEMS_PROP][itemName];\n delete result.data;\n delete result.parent;\n\n if (Object.prototype.hasOwnProperty.call(parent, Constants.ITEMS_ORDER_PROP)) {\n let index = parent[Constants.ITEMS_ORDER_PROP].indexOf(itemName);\n parent[Constants.ITEMS_ORDER_PROP].splice(index, 1);\n }\n\n return result.parentPath;\n }\n } else {\n console.warn(`Item for path ${path} was not found! Nothing to remove then.`);\n }\n }\n\n /**\n * @private\n */\n destroy() {\n this._data = null;\n this._rootPath = null;\n this._pageContentDelimiter = null;\n\n delete this._data;\n delete this._rootPath;\n delete this._pageContentDelimiter;\n }\n}\n","/*\n * ADOBE CONFIDENTIAL\n *\n * Copyright 2018 Adobe Systems Incorporated\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe Systems Incorporated and its suppliers,\n * if any. The intellectual and technical concepts contained\n * herein are proprietary to Adobe Systems Incorporated and its\n * suppliers and may be covered by U.S. and Foreign Patents,\n * patents in process, and are protected by trade secret or copyright law.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe Systems Incorporated.\n */\nimport { PathUtils } from \"./PathUtils\";\nimport Constants from \"./Constants\";\nimport MetaProperty from \"./MetaProperty\";\nimport { EditorClient, triggerPageModelLoaded } from \"./EditorClient\";\nimport { ModelClient } from \"./ModelClient\";\nimport { ModelStore } from \"./ModelStore\";\n\n/**\n * Does the provided model object contains an entry for the given child path\n *\n * @param {{}} model - model to be evaluated\n * @param {string} childPath - path of the child\n * @return {*}\n *\n * @private\n */\nfunction hasChildOfPath(model, childPath) {\n return !!(model && childPath && model[Constants.CHILDREN_PROP] && model[Constants.CHILDREN_PROP][PathUtils.sanitize(childPath)]);\n}\n\n/**\n * Does the provided page path correspond to the model root path\n *\n * @param {string} pagePath - path of the page model\n * @param {string} modelRootPath - current model root path\n * @return {boolean}\n *\n * @private\n */\nfunction isPageURLRoot(pagePath, modelRootPath) {\n return !pagePath || !modelRootPath || PathUtils.sanitize(pagePath) === PathUtils.sanitize(modelRootPath);\n}\n\n/**\n * Adapts the provided path to a valid model path.\n * Returns an empty string if the given path is equal to the root model path.\n * This function is a utility tool that converts a provided root model path into an internal specific empty path\n *\n * @param {string} [path] - raw model path\n * @return {string} the valid model path\n *\n * @private\n */\nfunction adaptPagePath(path) {\n if (!path) {\n return '';\n }\n\n const localPath = PathUtils.internalize(path);\n\n if (!this.modelStore || !this.modelStore.rootPath) {\n return localPath;\n }\n\n const localRootModelPath = PathUtils.sanitize(this.modelStore.rootPath);\n\n return localPath === localRootModelPath ? '' : localPath;\n}\n\n/**\n * Returns the list of provided route filters\n *\n * @returns {string[]}\n *\n * @private\n */\nexport function getRouteFilters() {\n let routeFilters = PathUtils.getMetaPropertyValue(MetaProperty.PAGE_MODEL_ROUTE_FILTERS);\n return routeFilters ? routeFilters.split(',') : [];\n}\n\n/**\n * Should the route be excluded\n *\n * @param route\n * @returns {boolean}\n *\n * @private\n */\nexport function isRouteExcluded(route) {\n const routeFilters = getRouteFilters();\n\n for (let i = 0, length = routeFilters.length; i < length; i++) {\n if (new RegExp(routeFilters[i]).test(route)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * The ModelManager gathers all the components implicated in managing the model data\n */\nclass ModelManager {\n\n /**\n * Configuration object for the getData function\n *\n * @typedef {{}} GetDataConfig\n * @property {string} path - Path of the data model\n * @property {boolean} forceReload - Should the data model be reloaded\n */\n\n /**\n * Configuration object for the Initialization function\n *\n * @typedef {{}} InitializationConfig\n * @property {string} [path] - Path of the data model\n * @property {{}} [model] - Model structure to initialize the page model manager with\n * @property {ModelClient} [modelClient] - Model client\n */\n\n get modelClient() {\n return this._modelClient;\n }\n\n get modelStore() {\n return this._modelStore;\n }\n\n /**\n * Verifies the integrity of the provided dependencies\n *\n * @return {Promise}\n * @private\n */\n _checkDependencies() {\n if (!this.modelClient) {\n return Promise.reject(\"No ModelClient registered\");\n }\n\n if (!this.modelStore) {\n return Promise.reject(\"No ModelManager registered\");\n }\n\n return Promise.resolve();\n }\n\n /**\n * Transforms the given path into a model URL\n *\n * @param path\n * @return {*}\n * @private\n */\n _toModelPath(path) {\n let url = PathUtils.addSelector(path, 'model');\n url = PathUtils.addExtension(url, 'json');\n url = PathUtils.externalize(url);\n\n return PathUtils.makeAbsolute(url);\n }\n\n /**\n * Initializes the ModelManager using the given path to resolve a data model.\n * If no path is provided, fallbacks are applied in the following order:\n *\n * - meta property: cq:pagemodel_root_url\n * - current pathname of the browser\n *\n * Once the initial model is loaded and if the data model doesn't contain the path of the current pathname, the library attempts to fetch a fragment of model.\n *\n * @param {string|InitializationConfig} [config] - URL to the data model or configuration object\n * @fires cq-pagemodel-loaded\n * @return {Promise}\n */\n initialize(config) {\n this.destroy();\n let path;\n let initialModel;\n\n if (!config || typeof config === 'string') {\n path = config;\n } else if (config) {\n path = config.path;\n this._modelClient = config.modelClient;\n initialModel = config.model;\n }\n\n this._listenersMap = {};\n this._fetchPromises = {};\n this._initPromise = null;\n\n const metaPropertyModelUrl = PathUtils.internalize(PathUtils.getMetaPropertyValue(MetaProperty.PAGE_MODEL_ROOT_URL));\n const currentPathname = PathUtils.sanitize(PathUtils.getCurrentPathname());\n // Fetch the app root model\n // 1. consider the provided page path\n // 2. consider the meta property value\n // 3. fallback to the model path contained in the URL\n const rootModelURL = path || metaPropertyModelUrl || currentPathname;\n\n if (!rootModelURL) {\n console.error('ModelManager.js', 'Cannot initialize without an URL to fetch the root model');\n }\n\n if (!this._modelClient) {\n this._modelClient = new ModelClient();\n }\n\n this._editorClient = new EditorClient(this);\n this._modelStore = new ModelStore(rootModelURL, initialModel);\n\n this._initPromise = this._checkDependencies().then(() => {\n const rootModelPath = PathUtils.sanitize(rootModelURL);\n let data = this.modelStore.getData(rootModelPath);\n\n if (data) {\n triggerPageModelLoaded(data);\n return data;\n } else {\n return this._fetchData(rootModelURL).then((rootModel) => {\n this.modelStore.initialize(rootModelPath, rootModel);\n // Append the child page if the page model doesn't correspond to the URL of the root model\n // and if the model root path doesn't already contain the child model (asynchronous page load)\n if (!isRouteExcluded(currentPathname) &&\n !isPageURLRoot(currentPathname, metaPropertyModelUrl) &&\n !hasChildOfPath(rootModel, currentPathname)) {\n return this._fetchData(currentPathname).then((model) => {\n this.modelStore.insertData(PathUtils.sanitize(currentPathname), model);\n let data = this.modelStore.getData();\n triggerPageModelLoaded(data);\n return data;\n });\n } else {\n let data = this.modelStore.getData();\n triggerPageModelLoaded(data);\n return data;\n }\n });\n }\n });\n\n return this._initPromise;\n }\n\n /**\n * Fetches a model for the given path\n * Consider wrapping this\n *\n * @param {string} path - Model path\n * @return {Promise}\n * @private\n */\n _fetchData(path) {\n if (Object.prototype.hasOwnProperty.call(this._fetchPromises, path)) {\n return this._fetchPromises[path];\n }\n\n let promise = this.modelClient.fetch(this._toModelPath(path));\n\n this._fetchPromises[path] = promise;\n\n promise.then((obj) => {\n delete this._fetchPromises[path];\n return obj;\n }).catch((error) => {\n delete this._fetchPromises[path];\n return error;\n });\n\n return promise;\n }\n\n _storeData(path, data) {\n const isItem = PathUtils.isItem(path);\n\n this.modelStore.insertData(path, data);\n\n // If the path correspond to an item notify either the parent item\n // Otherwise notify the app root\n this._notifyListeners(path);\n\n if (!isItem) {\n // As we are expecting a page, we notify the root\n this._notifyListeners('');\n }\n\n return data;\n }\n\n /**\n * Returns the path of the data model root\n *\n * @return {string}\n */\n get rootPath() {\n return this.modelStore.rootPath;\n }\n\n /**\n * Returns the model for the given configuration\n * @param {string|GetDataConfig} [config] - Either the path of the data model or a configuration object. If no parameter is provided the complete model is returned\n * @return {Promise}\n */\n getData(config) {\n let path;\n let forceReload = false;\n\n if (typeof config === 'string') {\n path = config;\n } else if (config) {\n path = config.path;\n forceReload = config.forceReload;\n }\n\n let initPromise = this._initPromise || Promise.resolve();\n\n return initPromise.then(() => this._checkDependencies())\n .then(() => {\n if (!forceReload) {\n let item = this.modelStore.getData(path);\n\n if (item) {\n return Promise.resolve(item);\n }\n }\n\n // We are not having any items\n // We want to reload the item\n return this._fetchData(path).then((data) => this._storeData(path, data));\n });\n }\n\n /**\n * Notifies the listeners for a given path\n *\n * @param {string} path - Path of the data model\n * @private\n */\n _notifyListeners(path) {\n path = PathUtils.adaptPagePath.call(this, path);\n let listenersForPath = this._listenersMap[path];\n\n if (!listenersForPath) {\n return;\n }\n\n if (listenersForPath.length) {\n listenersForPath.forEach((listener) => {\n try {\n listener();\n } catch (e) {\n console.error('Error in listener ' + listenersForPath + ' at path ' + path + ' : ' + e);\n }\n });\n }\n }\n\n\n /**\n * Add the given callback as a listener for changes at the given path.\n *\n * @param {String} [path] Absolute path of the resource (e.g., \"/content/mypage\"). If not provided, the root page path is used.\n * @param {String} [callback] Function to be executed listening to changes at given path\n */\n addListener(path, callback) {\n if (!path && typeof path !== 'string') {\n return;\n }\n\n let adaptedPath = adaptPagePath.call(this, path);\n\n this._listenersMap[adaptedPath] = this._listenersMap[path] || [];\n this._listenersMap[adaptedPath].push(callback);\n }\n\n /**\n * Remove the callback listener from the given path path.\n *\n * @param {String} [path] Absolute path of the resource (e.g., \"/content/mypage\"). If not provided, the root page path is used.\n * @param {String} [callback] Listener function to be removed.\n */\n removeListener(path, callback) {\n if (!path) {\n return;\n }\n let adaptedPath = adaptPagePath.call(this, path);\n\n let listenersForPath = this._listenersMap[adaptedPath];\n if (listenersForPath) {\n let index = listenersForPath.indexOf(callback);\n if (index !== -1) {\n listenersForPath.splice(index, 1);\n }\n }\n }\n\n /**\n * @private\n */\n destroy() {\n this._fetchPromises = null;\n delete this._fetchPromises;\n this._listenersMap = null;\n delete this._listenersMap;\n\n if (this.modelClient && this.modelClient.destroy) {\n this.modelClient.destroy();\n }\n\n if (this.modelStore && this.modelStore.destroy) {\n this.modelStore.destroy();\n }\n\n if (this._editorClient && this._editorClient.destroy) {\n this._editorClient.destroy();\n }\n }\n}\n\nexport default new ModelManager();\n","/*\n * ADOBE CONFIDENTIAL\n *\n * Copyright 2018 Adobe Systems Incorporated\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe Systems Incorporated and its suppliers,\n * if any. The intellectual and technical concepts contained\n * herein are proprietary to Adobe Systems Incorporated and its\n * suppliers and may be covered by U.S. and Foreign Patents,\n * patents in process, and are protected by trade secret or copyright law.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe Systems Incorporated.\n */\n\n/**\n * Type of events triggered or listened by the PageModelManager and ModelRouter\n *\n * @type {{PAGE_MODEL_INIT: string, PAGE_MODEL_LOADED: string, PAGE_MODEL_UPDATE: string, PAGE_MODEL_ROUTE_CHANGED: string}}\n */\nconst EventType = {\n\n /**\n * Event which indicates that the PageModelManager has been initialized\n */\n PAGE_MODEL_INIT: 'cq-pagemodel-init',\n\n /**\n * Event which indicates that the PageModelManager has loaded new content\n */\n PAGE_MODEL_LOADED: 'cq-pagemodel-loaded',\n\n /**\n * Event that indicates a request to update the page model\n */\n PAGE_MODEL_UPDATE: 'cq-pagemodel-update',\n\n /**\n * Event which indicates that ModelRouter has identified that model route has changed\n */\n PAGE_MODEL_ROUTE_CHANGED: 'cq-pagemodel-route-changed'\n};\n\nexport default EventType;","/*\n * ADOBE CONFIDENTIAL\n *\n * Copyright 2018 Adobe Systems Incorporated\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe Systems Incorporated and its suppliers,\n * if any. The intellectual and technical concepts contained\n * herein are proprietary to Adobe Systems Incorporated and its\n * suppliers and may be covered by U.S. and Foreign Patents,\n * patents in process, and are protected by trade secret or copyright law.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe Systems Incorporated.\n */\n\nexport class ModelClient {\n\n /**\n * @constructor\n * @param {string} [apiHost] - Http host of the API\n */\n constructor(apiHost) {\n this._apiHost = apiHost || '';\n this._fetchPromises = {};\n }\n\n /**\n * Fetches a model using the given a resource path\n *\n * @param {string} modelPath - Absolute path to the model.\n * @return {*}\n */\n fetch(modelPath) {\n if (!modelPath) {\n let err = 'Fetching model rejected for path: ' + modelPath;\n return Promise.reject(new Error(err));\n }\n\n // Either the API host has been provided or we make an absolute request relative to the current host\n let url = `${this._apiHost}${modelPath}`;\n \n // Assure that the default credentials value ('same-origin') is set for browsers which do not set it\n // or which are setting the old default value ('omit')\n return fetch(url, {credentials: 'same-origin'}).then(function(response) {\n if (response.status >= 200 && response.status < 300) {\n return response.json();\n }\n\n throw { response: response };\n }).catch((error) => {\n return Promise.reject(error);\n });\n }\n\n /**\n * Destroys the internal references to avoid memory leaks\n */\n destroy() {\n this._apiHost = null;\n this._fetchPromises = null;\n }\n}","// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,\n// backported and transplited with Babel, with backwards-compat fixes\n\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length - 1; i >= 0; i--) {\n var last = parts[i];\n if (last === '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\n var resolvedPath = '',\n resolvedAbsolute = false;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0) ? arguments[i] : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string') {\n throw new TypeError('Arguments to path.resolve must be strings');\n } else if (!path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\n var isAbsolute = exports.isAbsolute(path),\n trailingSlash = substr(path, -1) === '/';\n\n // Normalize the path\n path = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n\n return (isAbsolute ? '/' : '') + path;\n};\n\n// posix version\nexports.isAbsolute = function(path) {\n return path.charAt(0) === '/';\n};\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n if (typeof p !== 'string') {\n throw new TypeError('Arguments to path.join must be strings');\n }\n return p;\n }).join('/'));\n};\n\n\n// path.relative(from, to)\n// posix version\nexports.relative = function(from, to) {\n from = exports.resolve(from).substr(1);\n to = exports.resolve(to).substr(1);\n\n function trim(arr) {\n var start = 0;\n for (; start < arr.length; start++) {\n if (arr[start] !== '') break;\n }\n\n var end = arr.length - 1;\n for (; end >= 0; end--) {\n if (arr[end] !== '') break;\n }\n\n if (start > end) return [];\n return arr.slice(start, end - start + 1);\n }\n\n var fromParts = trim(from.split('/'));\n var toParts = trim(to.split('/'));\n\n var length = Math.min(fromParts.length, toParts.length);\n var samePartsLength = length;\n for (var i = 0; i < length; i++) {\n if (fromParts[i] !== toParts[i]) {\n samePartsLength = i;\n break;\n }\n }\n\n var outputParts = [];\n for (var i = samePartsLength; i < fromParts.length; i++) {\n outputParts.push('..');\n }\n\n outputParts = outputParts.concat(toParts.slice(samePartsLength));\n\n return outputParts.join('/');\n};\n\nexports.sep = '/';\nexports.delimiter = ':';\n\nexports.dirname = function (path) {\n if (typeof path !== 'string') path = path + '';\n if (path.length === 0) return '.';\n var code = path.charCodeAt(0);\n var hasRoot = code === 47 /*/*/;\n var end = -1;\n var matchedSlash = true;\n for (var i = path.length - 1; i >= 1; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n if (!matchedSlash) {\n end = i;\n break;\n }\n } else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n\n if (end === -1) return hasRoot ? '/' : '.';\n if (hasRoot && end === 1) {\n // return '//';\n // Backwards-compat fix:\n return '/';\n }\n return path.slice(0, end);\n};\n\nfunction basename(path) {\n if (typeof path !== 'string') path = path + '';\n\n var start = 0;\n var end = -1;\n var matchedSlash = true;\n var i;\n\n for (i = path.length - 1; i >= 0; --i) {\n if (path.charCodeAt(i) === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n\n if (end === -1) return '';\n return path.slice(start, end);\n}\n\n// Uses a mixed approach for backwards-compatibility, as ext behavior changed\n// in new Node.js versions, so only basename() above is backported here\nexports.basename = function (path, ext) {\n var f = basename(path);\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\nexports.extname = function (path) {\n if (typeof path !== 'string') path = path + '';\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n for (var i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n return '';\n }\n return path.slice(startDot, end);\n};\n\nfunction filter (xs, f) {\n if (xs.filter) return xs.filter(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (f(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// String.prototype.substr - negative index don't work in IE8\nvar substr = 'ab'.substr(-1) === 'b'\n ? function (str, start, len) { return str.substr(start, len) }\n : function (str, start, len) {\n if (start < 0) start = str.length + start;\n return str.substr(start, len);\n }\n;\n","module.exports = require(\"url\");","/*\n * ADOBE CONFIDENTIAL\n *\n * Copyright 2018 Adobe Systems Incorporated\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe Systems Incorporated and its suppliers,\n * if any. The intellectual and technical concepts contained\n * herein are proprietary to Adobe Systems Incorporated and its\n * suppliers and may be covered by U.S. and Foreign Patents,\n * patents in process, and are protected by trade secret or copyright law.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe Systems Incorporated.\n */\n\nrequire('./src/ModelRouter');\n\nexport { default as ModelManager } from \"./src/ModelManager\";\nexport * from \"./src/ModelClient\";\nexport * from \"./src/PathUtils\";\nexport { default as Constants } from \"./src/Constants\";","/*\n * ADOBE CONFIDENTIAL\n *\n * Copyright 2018 Adobe Systems Incorporated\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe Systems Incorporated and its suppliers,\n * if any. The intellectual and technical concepts contained\n * herein are proprietary to Adobe Systems Incorporated and its\n * suppliers and may be covered by U.S. and Foreign Patents,\n * patents in process, and are protected by trade secret or copyright law.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe Systems Incorporated.\n */\nimport EventType from './EventType';\nimport { PathUtils } from \"./PathUtils\";\nimport MetaProperty from \"./MetaProperty\";\nimport ModelManagerSerice from \"./ModelManager\";\nimport { isRouteExcluded } from \"./ModelManager\";\n\n/**\n * Triggered by the ModelRouter when the route has changed.\n *\n * @event cq-pagemodel-route-changed\n * @type {Object}\n * @property {Object} detail\n * @property {Object} detail.model - The page model object corresponding to the new route\n */\n\n/**\n * <p>The ModelRouter listens for HTML5 History API <i>popstate</i> events and calls {@link PageModelManager#getData()} with the model path it extracted from the URL.</p>\n *\n * <h2>Configuration</h2>\n *\n * <p>The Model Router can be configured using meta properties located in the head section of the document.</p>\n *\n * <h3>Meta properties</h3>\n * <ul>\n * <li>cq:page_model_router - default=undefined, options=disable</li>\n * <li>cq:page_model_route_filters - default=undefined, options=RegExp<></li>\n * </ul>\n *\n * <h3>Defaults</h3>\n * <ul>\n * <li>The ModelRouter is enabled and uses the <i>History</i> API to extract the model path from the current content path</li>\n * </ul>\n *\n * <h3>Examples and Usages</h3>\n *\n * <h4>Disables the page model router</h4>\n * <pre>\n * <code>e.g. &lt;meta property=\"cq:page_model_router\" content=\"disable\"\\&gt;</code>\n * </pre>\n *\n * <h4>Filters paths from the model routing with the given patterns</h4>\n * <pre>\n * <code>e.g. &lt;meta property=\"cq:page_model_route_filters\" content=\"route/not/found,^(.*)(?:exclude/path)(.*)\"\\&gt;</code>\n * </pre>\n *\n * @module ModelRouter\n */\n\n/**\n * Modes in which the Model Router operates\n *\n * @type {{DISABLED: string, CONTENT_PATH: string}}\n */\nexport const ROUTER_MODES = {\n\n /**\n * Flag that indicates that the model router should be disabled\n *\n * @type {string}\n */\n DISABLED: 'disabled',\n\n /**\n * Flag that indicates that the model router should extract the model path from the content path section of the URL\n *\n * @type {string}\n */\n CONTENT_PATH: 'path'\n};\n\n/**\n * Returns the model path. If no URL is provided the current window URL is used\n *\n * @param {string} [url] - url from which to extract the model path\n *\n * @return {string}\n */\nexport function getModelPath(url) {\n let localUrl;\n\n localUrl = url || window.location.pathname;\n\n // The default value model path comes as the the content path\n let endPosition = localUrl.indexOf('.');\n\n if (endPosition < 0) {\n\n //If the path is missing extension and has query params instead eg. http://zyx/abc?test=test\n let queryPosition = localUrl.indexOf('?');\n if (queryPosition < 0)\n endPosition = localUrl.length;\n else\n endPosition = queryPosition;\n }\n\n return localUrl.substr(0, endPosition);\n}\n\n/**\n * Is the model router enabled. Enabled by default\n * @returns {boolean}\n *\n * @private\n */\nexport function isModelRouterEnabled() {\n if (!PathUtils.isBrowser()) {\n return false;\n }\n const modelRouterMetaType = PathUtils.getMetaPropertyValue(MetaProperty.PAGE_MODEL_ROUTER);\n // Enable the the page model routing by default\n return !modelRouterMetaType || ROUTER_MODES.DISABLED !== modelRouterMetaType;\n}\n\n/**\n * Fetches the model from the PageModelManager and then dispatches it\n *\n * @fires cq-pagemodel-route-changed\n *\n * @param {string} [path] - path of the model to be dispatched\n *\n * @private\n */\nexport function dispatchRouteChanged(path) {\n // Triggering the page model manager to load a new child page model\n // No need to use a cache as the PageModelManager already does it\n ModelManagerSerice.getData({path: path}).then(function (model) {\n PathUtils.dispatchGlobalCustomEvent(EventType.PAGE_MODEL_ROUTE_CHANGED, {\n detail: {\n model: model\n }\n });\n });\n}\n\n/**\n * Triggers the PageModelManager to fetch data based on the current route\n *\n * @fires cq-pagemodel-route-changed - with the root page model object\n *\n * @param {string} [url] - url from which to extract the model path\n *\n * @private\n */\nexport function routeModel(url) {\n if (!isModelRouterEnabled()) {\n return;\n }\n\n const path = getModelPath(url);\n\n\n // don't fetch the model\n // for the root path\n // or when the route is excluded\n if (!path || '/' === path || isRouteExcluded(path)) {\n return;\n }\n\n dispatchRouteChanged(path);\n}\n\n// Activate the model router\nif (isModelRouterEnabled()) {\n // Encapsulate the history.pushState and history.replaceState functions to prefetch the page model for the current route\n const pushState = window.history.pushState;\n const replaceState = window.history.replaceState;\n\n window.history.pushState = function(state, title, url) {\n routeModel(url);\n\n return pushState.apply(history, arguments);\n };\n\n window.history.replaceState = function(state, title, url) {\n routeModel(url);\n\n return replaceState.apply(history, arguments);\n };\n}\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n"],"sourceRoot":""}
\No newline at end of file