{"version":3,"sources":["webpack://ViewerUtils/../mathworks/devel/bat/Bwiaui_artifacts/build/scm/mw-postmessagechannel/release/src/main/PostMessageChannel.js","webpack://ViewerUtils/./internal/ui/src/js/ErrorUtils.js","webpack://ViewerUtils/./internal/ui/src/js/FetchUtils.js","webpack://ViewerUtils/./internal/ui/src/js/ViewerEventHandlers.js","webpack://ViewerUtils/./internal/ui/src/js/index.js","webpack://ViewerUtils/webpack/bootstrap","webpack://ViewerUtils/webpack/runtime/compat get default export","webpack://ViewerUtils/webpack/runtime/define property getters","webpack://ViewerUtils/webpack/runtime/hasOwnProperty shorthand","webpack://ViewerUtils/webpack/runtime/make namespace object","webpack://ViewerUtils/webpack/startup"],"names":["Message","this","type","tag","JSON","data","typeAndBody","targetWindowOrigin","message","event","hasListener","localWindow","location","listeners","e","hideSpinner","document","querySelector","style","visibility","showErrorPage","display","innerHTML","showTimeoutPage","_fetchArtifact","async","contextRoot","url","filename","mwtypeMsg","timeout","controller","AbortController","setTimeout","abort","poll","method","mode","signal","headers","credentials","body","stringify","options","response","fetch","status","json","mwtype","faultId","Error","name","fetchData","fetchModelArtifactURL","isMatlabLink","href","toLowerCase","match","constructor","embedParam","channel","PostMessageChannel","window","connect","parent","hyperLinkCallback","bind","copyActionCallback","addEventListener","contentLoadedCallback","eventData","documentHeight","elapsedRetries","elementForHeightCalculation","offsetHeight","waitForParentIFrame","setInterval","parentIFrame","size","clearInterval","tryToResizeParentIframe","embedParm","isAllowedProtocol","send","isInProduct","open","matlabCommand","alert","Handler","require","fetchUtils","errorUtils","module","exports","__webpack_module_cache__","__webpack_require__","moduleId","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","__webpack_exports__"],"mappings":"2YAIM,kBACF,IAEMA,EAHa,WAIf,gBAAyB,UACrBC,KAAA,OACAA,KAAA,OANW,4CAwBX,OAAOA,KAAKC,MAAQD,KAApB,OAxBW,kCA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G/B,SAASC,EAAoBC,GAE5B,GAAGF,EAAyBE,GAC3B,OAAOF,EAAyBE,GAAUH,QAG3C,IAAID,EAASE,EAAyBE,GAAY,CAGjDH,QAAS,IAOV,OAHAI,EAAoBD,GAAUJ,EAAQA,EAAOC,QAASE,GAG/CH,EAAOC,QCnBfE,EAAoBG,EAAI,SAASN,GAChC,IAAIO,EAASP,GAAUA,EAAOQ,WAC7B,WAAa,OAAOR,EAAgB,SACpC,WAAa,OAAOA,GAErB,OADAG,EAAoBM,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,GCLRJ,EAAoBM,EAAI,SAASR,EAASU,GACzC,IAAI,IAAIC,KAAOD,EACXR,EAAoBU,EAAEF,EAAYC,KAAST,EAAoBU,EAAEZ,EAASW,IAC5EE,OAAOC,eAAed,EAASW,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3ET,EAAoBU,EAAI,SAASK,EAAKC,GAAQ,OAAOL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,ICC/FhB,EAAoBoB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CX,OAAOC,eAAed,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DZ,OAAOC,eAAed,EAAS,aAAc,CAAEyB,OAAO,KCFvD,IAAIC,EAAsBxB,EAAoB,M","file":"viewerutils.min.js","sourcesContent":["/**\n * @Copyright 2020 The MathWorks, Inc.\n */\n\ndefine([], function () {\n const DEFAULT_TAG = '__mwpmc__';\n\n class Message {\n constructor (type, body) {\n this.type = type;\n this.body = body;\n }\n\n static serialize (tag, type, body) {\n return tag + JSON.stringify([type, body]);\n }\n\n static deserialize (tag, data) {\n if (!data || !data.includes(tag)) {\n return new Message(); // not for us, ignore\n }\n\n const typeAndBody = JSON.parse(data.replace(tag, ''));\n\n return new Message(typeAndBody[0], typeAndBody[1]);\n }\n\n isValid () {\n return this.type && this.body;\n }\n\n setEvent (event) {\n this.event = event;\n }\n }\n\n /**\n * Lightweight cross-window communication over the postMessage API. Allows multiple window\n * objects to communicate (for example, a document containing an iframe can communicate\n * with the document in the iframe).\n */\n class PostMessageChannel {\n constructor (localWindow, tag, targetWindowOrigin) {\n this.localWindow = localWindow;\n this.tag = tag || DEFAULT_TAG;\n this.targetWindowOrigin = targetWindowOrigin || '*';\n\n this.listeners = {};\n\n this.addPostMessageListener();\n }\n\n onMessage (event) {\n const message = Message.deserialize(this.tag, event.data);\n\n if (message.isValid() && this.hasListener(message.type)) {\n message.setEvent(event);\n this.listeners[message.type].call(this, message);\n }\n }\n\n /**\n * Clears the channel's event listeners. Also removes channel-related listeners from\n * the local window object.\n */\n disconnect () {\n this.targetWindow = null;\n this.listeners = {};\n this.localWindow.removeEventListener('message', this.onMessage);\n }\n\n /**\n * Waits for another channel to send a connect message. On receiving this message,\n * the message sender is set as the channel's target.\n */\n listen () {\n this.on('__connect', message => {\n this.setTargetWindow(message.event.source);\n });\n }\n\n /**\n * Sends a connect message to another window, and sets that window as the channel's target.\n */\n connect (targetWindow) {\n this.setTargetWindow(targetWindow);\n\n this.send('__connect', this.localWindow.location.origin);\n this.send('connect', this.localWindow.location.origin);\n }\n\n /**\n * Adds a callback for a specified message type. Within the callback :this: is bound\n * to the channel object.\n */\n on (type, listener) {\n this.listeners[type] = listener;\n }\n\n hasListener (type) {\n return !!this.listeners[type];\n }\n\n /**\n * Sends a message to the channel's target window.\n */\n send (type, body) {\n this.targetWindow.postMessage(\n Message.serialize(this.tag, type, body),\n this.targetWindowOrigin);\n }\n\n addPostMessageListener () {\n this.localWindow.addEventListener('message', e => this.onMessage(e));\n }\n\n setTargetWindow (targetWindow) {\n this.targetWindow = targetWindow;\n }\n }\n\n return PostMessageChannel;\n});\n","const showErrorPage = function () {\n document.querySelector('.dialog').style.display = 'block';\n document.querySelector('.dialog').querySelector('h1').innerHTML = 'We are sorry, but something went wrong.';\n hideSpinner();\n};\nconst showTimeoutPage = function () {\n document.querySelector('.dialog').style.display = 'block';\n document.querySelector('.dialog').querySelector('h1').innerHTML = 'Request is taking too long. Please try again later.';\n hideSpinner();\n};\n\nconst hideSpinner = function () {\n document.querySelector('.loader').style.visibility = 'hidden';\n document.querySelector('.loading_large_file').style.visibility = 'hidden';\n};\n\nexport default { showErrorPage, showTimeoutPage };\n","const fetchData = async function (contextRoot, url, filename, timeout = 45000) {\n return _fetchArtifact(contextRoot, url, filename, 'renderer/GetData', timeout)\n};\n\nconst fetchModelArtifactURL = async function (contextRoot, url, filename, timeout = 45000) {\n return _fetchArtifact(contextRoot, url, filename, 'renderer/GetModelArtifactURL', timeout)\n};\n\nconst _fetchArtifact = async function (contextRoot, url, filename, mwtypeMsg, timeout) {\n // eslint-disable-next-line no-undef\n const controller = new AbortController();\n setTimeout(() => controller.abort(), timeout);\n const headers = {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n };\n\n const data = {\n 'mwtype': mwtypeMsg,\n 'url': url,\n 'filename': filename\n };\n return poll(`${contextRoot}data/v1/api`, {\n method: 'POST',\n mode: 'cors',\n signal: controller.signal,\n headers,\n credentials: 'include',\n body: JSON.stringify(data)\n });\n}\n\nconst poll = async (url, options) => {\n try {\n // eslint-disable-next-line no-undef\n let response = await fetch(url, options);\n // in case of a browser time (504) out or a status not found (204) from server, poll again\n if (response.status === 204 || response.status === 504) {\n await poll(url, options);\n }\n let message = await response.json();\n if (message.mwtype === 'core/Fault') {\n if (message.faultId[0] === 'TimeoutFault') {\n throw new Error('TimeoutError');\n } else {\n throw new Error('ServerError');\n }\n }\n return message;\n } catch (e) {\n if (e.name === 'AbortError') {\n throw new Error('TimeoutError');\n }\n throw e;\n }\n};\n\nexport default { fetchData, fetchModelArtifactURL };\n","import PostMessageChannel from 'mw-postmessagechannel/PostMessageChannel';\n\nlet ViewerEventHandlers = (() => {\n // private methods\n const isMatlabLink = (href) => href && href.toLowerCase().match(/^matlab:/) !== null;\n const isAllowedProtocol = (href) => href && href.toLowerCase().match(/^(matlab|http|https):/) !== null;\n const isEmbedded = (embedParm) => embedParm === 'product' || embedParm === 'web';\n const isInProduct = (embedParm) => embedParm === 'product';\n\n return class {\n constructor (embedParam) {\n this.embedParam = embedParam;\n this.channel = new PostMessageChannel(window, '__linkclk__');\n this.channel.connect(window.parent);\n\n // Bind hyperlinkCallback to ViewerUtils class. This is needed\n // since when the Viewer widget executes the callback, the context\n // is set to the widget and not the class.\n this.hyperLinkCallback = this.hyperLinkCallback.bind(this);\n this.copyActionCallback = this.copyActionCallback.bind(this);\n document.addEventListener('copy', this.copyActionCallback);\n }\n\n contentLoadedCallback (eventData) {\n const tryToResizeParentIframe = (eventData) => {\n const maxRetries = 5;\n let elapsedRetries = 0;\n let documentHeight;\n if (eventData) {\n documentHeight = eventData.documentHeight;\n } else {\n const elementForHeightCalculation = document.querySelector('.dijitContentPane');\n documentHeight = elementForHeightCalculation.offsetHeight;\n }\n\n const waitForParentIFrame = setInterval(function () {\n elapsedRetries = elapsedRetries + 1;\n\n if ('parentIFrame' in window) {\n window.parentIFrame.size(documentHeight);\n\n clearInterval(waitForParentIFrame);\n }\n if (elapsedRetries === maxRetries) {\n clearInterval(waitForParentIFrame);\n }\n }, 50);\n };\n\n setTimeout(function () {\n document.querySelector('.loader').style.visibility = 'hidden';\n\n tryToResizeParentIframe(eventData);\n }, 0);\n }\n\n hyperLinkCallback (href) {\n // Check if link protocol is allowed before proceeding.\n if (!isAllowedProtocol(href)) {\n return;\n }\n\n if (isEmbedded(this.embedParam)) {\n if (isMatlabLink(href)) {\n this.channel.send('openMatlabLink', { 'url': href });\n } else {\n if (isInProduct(this.embedParam)) {\n this.channel.send('openExternalLink', { 'url': href });\n } else {\n window.open(href, '_blank');\n }\n }\n } else {\n if (isMatlabLink(href)) {\n const match = href.match(/matlab:(.*)/i);\n let matlabCommand = null;\n if (match) {\n matlabCommand = match[1];\n }\n // eslint-disable-next-line no-undef\n alert('You clicked on a MATLAB command\\n' + matlabCommand);\n } else {\n document.location = href;\n }\n }\n }\n\n // the copy action callback function that sends copy event from Viewer app to parent app (AOE or FEX)\n copyActionCallback () {\n this.channel.send('copyAction', {});\n }\n };\n})();\n\nexport default ViewerEventHandlers;\n","// Webpack does not allow importing in ES6 and exporting in CJS.\n// See https://www.seancdavis.com/blog/export-es6-class-globally-webpack/\nconst Handler = require('./ViewerEventHandlers').default;\nconst fetchUtils = require('./FetchUtils').default;\nconst errorUtils = require('./ErrorUtils').default;\nrequire('../css/index.css');\nmodule.exports = { Handler, ...fetchUtils, ...errorUtils };\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = function(module) {\n\tvar getter = module && module.__esModule ?\n\t\tfunction() { return module['default']; } :\n\t\tfunction() { return module; };\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(7827);\n"],"sourceRoot":""}