{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./cartridges/org_newbalance/cartridge/client/default/js/arTryOn.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","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","targetOrigin","window","arTryOnURL","targetURL","arTryOnPath","arTryOnConfig","isReady","setStyleAR","uri","$","show","document","getElementById","contentWindow","postMessage","type","accessoryDescriptionUrl","find","spinner","stop","initVyking","config","arTryonIframe","tryCount","onmessage","event","configparam","data","arTryOnKey","cameraWidth","cameraHeight","autoPlay","attr","expiryTime","getTime","Date","fetch","method","cache","selectedStyle","arTryOnEnabledStyles","complete","startVyking","navUserAgent","deviceType","navigator","userAgent","match","location","configURI","arModal","hide","start","encodeURI","then","response","ok","Error","status","arrayBuffer","on","URL","searchParams","click"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SA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AAM,cAAgBJ,EAAaI,MAAM,sBAAwBJ,EAAaI,MAAM,cAClU,SAEA,UAkIhB9C,OAAO+C,UAAY,WACnB,IAjBgBC,EAiBZC,EAAUzC,EAAE,mBAChB,GAAmB,YAAfmC,EACAM,EAAQjC,KAAK,oBAAoBP,OACjCwC,EAAQjC,KAAK,mBAAmBkC,YAKhC,GAHAD,EAAQjC,KAAK,mBAAmBP,OAChCwC,EAAQjC,KAAK,oBAAoBkC,OACjCD,EAAQjC,KAAK,kBAAkBC,UAAUkC,QACpC9C,EAEE,CACH,IAAIiC,EAAgB9B,EAAE,6BAA6BuB,KAAK,kBACxD,GAAI/B,OAAOuC,qBAAqBD,GAE5BhC,EADeN,OAAOuC,qBAAqBD,SA9BvCU,EA0BG5C,EAzBnB+B,MAAMiB,UAAUJ,IAAYK,MAAK,SAAUC,GACvC,IAAKA,EAASC,GACV,MAAM,IAAIC,MAAJ,4CAA+CR,EAA/C,qBAAqEM,EAASG,SAExFH,EAASI,cAAcL,MAAK,SAAUjC,GAClCD,EAAWC,SA+BvBZ,GAAE,WACEA,EAAE,mBAAmBmD,GAAG,iBAAiB,WACrClB,OAGJjC,EAAE,mBAAmBmD,GAAG,iBAAiB,WAhJzCjD,SAASC,eAAe,yBAAyBC,cAAcC,YAAY,CACvEC,KAAM,+BACPf,MAoJa,YAFF,IAAI6D,IAAI5D,OAAO+C,UAAWc,aACnBjF,IAAI,OAErB4B,EAAE,gBAAgBsD","file":"arTryOn.js","sourcesContent":[" \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 = \"./cartridges/org_newbalance/cartridge/client/default/js/arTryOn.js\");\n","'use strict';\n\nvar targetOrigin = window.arTryOnURL;\nvar targetURL = window.arTryOnPath;\nvar arTryOnConfig = window.arTryOnConfig;\nvar isReady = false;\n\n/**\n * Get device type of user agent\n * @return {string} userAgent - Desktop or Mobile useragent type\n */\nfunction getDeviceType() {\n var navUserAgent = navigator.userAgent;\n var userAgent = '';\n if (navUserAgent.match(/Phone/i) || navUserAgent.match(/DROID/i) || navUserAgent.match(/Android/i) || navUserAgent.match(/webOS/i) || navUserAgent.match(/iPhone/i) || navUserAgent.match(/iPod/i) || navUserAgent.match(/BlackBerry/) || navUserAgent.match(/Windows Phone/i) || navUserAgent.match(/ZuneWP7/i) || navUserAgent.match(/IEMobile/i)) {\n userAgent = 'Mobile';\n } else if (navUserAgent.match(/Tablet/i) || navUserAgent.match(/iPad/i) || navUserAgent.match(/Kindle/i) || navUserAgent.match(/Playbook/i) || navUserAgent.match(/Nexus/i) || navUserAgent.match(/Xoom/i) || navUserAgent.match(/SM-N900T/i) || navUserAgent.match(/GT-N7100/i) || navUserAgent.match(/SAMSUNG-SGH-I717/i) || navUserAgent.match(/SM-T330NU/i)) {\n userAgent = 'Tablet';\n } else {\n userAgent = 'Desktop';\n }\n return userAgent;\n}\n\nconst playAR = function () {\n document.getElementById('vyking-sneaker-window').contentWindow.postMessage({\n type: 'VYKING_SNEAKER_WINDOW_PLAY'\n }, targetOrigin);\n};\n\nconst pauseAR = function () {\n document.getElementById('vyking-sneaker-window').contentWindow.postMessage({\n type: 'VYKING_SNEAKER_WINDOW_PAUSE'\n }, targetOrigin);\n};\n\n/**\n * Set the style on the Vyking Iframe\n * @param {string} uri - URL to Style config\n */\nfunction setStyleAR(uri) {\n $('.arLoader').show();\n document.getElementById('vyking-sneaker-window').contentWindow.postMessage({\n type: 'VYKING_SNEAKER_WINDOW_REPLACE_ACCESSORIES',\n accessoryDescriptionUrl: uri\n }, targetOrigin);\n playAR();\n $('#ar-tryon-modal').find('.modal-content').spinner().stop();\n}\n\n/**\n * Init Vyking iframe\n * @param {Object} config - config object\n */\nfunction initVyking(config) {\n var arTryonIframe = $('#vyking-sneaker-window');\n var tryCount = 0;\n\n const postConfig = (configparam) => {\n // console.log(`postconfig ${clientWidth}x${clientHeight}`);\n\n let cameraWidthAR = 360;\n let cameraHeightAR = 640;\n arTryonIframe[0].contentWindow.postMessage({\n type: 'VYKING_SNEAKER_WINDOW_CONFIG',\n config: configparam,\n key: window.arTryOnKey,\n cameraWidth: cameraWidthAR,\n cameraHeight: cameraHeightAR,\n autoPlay: false\n }, targetOrigin);\n\n arTryonIframe.attr('width', cameraWidthAR);\n arTryonIframe.attr('height', cameraHeightAR);\n\n tryCount += 1;\n };\n\n window.onmessage = event => {\n const {\n data\n } = event;\n\n if (data.type === 'VYKING_SNEAKER_WINDOW_WAITING_FOR_CONFIG') {\n if (tryCount < 20) {\n postConfig(config);\n }\n }\n\n if (data.type === 'VYKING_SNEAKER_WINDOW_EXPIRY_TIME') {\n // console.info(`Licence expiry date: ${data.expiryTime.toString()}`);\n // If close to licencse expiry reload th configuration file isReady for next time\n if (data.expiryTime.getTime() - new Date().getTime() < 1 * 24 * 60 * 60 * 1000) {\n // console.log(`Expired on ${data.expiryTime.toString()}`);\n fetch(arTryOnConfig, {\n method: 'GET',\n cache: 'reload'\n });\n }\n }\n\n if (data.type === 'VYKING_SNEAKER_WINDOW_READY') {\n isReady = true;\n var selectedStyle = $('.style-attribute.selected').attr('data-attrvalue');\n if (window.arTryOnEnabledStyles[selectedStyle]) {\n var styleURI = window.arTryOnEnabledStyles[selectedStyle];\n setStyleAR(styleURI);\n }\n }\n\n if (data.type === 'VYKING_SNEAKER_WINDOW_REPLACE_ACCESSORIES') {\n if (data.complete === 1) {\n $('#ar-tryon-modal').find('.modal-content').spinner().stop();\n }\n }\n\n if (data.type === 'VYKING_SNEAKER_WINDOW_BUSY_ERROR') {\n $('#ar-tryon-modal').find('.modal-content').spinner().stop();\n }\n\n if (data.type === 'VYKING_SNEAKER_WINDOW_ERROR') {\n $('#ar-tryon-modal').find('.modal-content').spinner().stop();\n // console.log(`${data.requestType} ${data.value}`);\n }\n };\n\n arTryonIframe.attr('src', targetURL);\n}\n\n/**\n * Load Vyking Config file\n * @param {string} configURI - URL to config file\n */\nfunction loadConfig(configURI) {\n fetch(encodeURI(configURI)).then(function (response) {\n if (!response.ok) {\n throw new Error(`Failed to load configuration from ${configURI}. Status: ${response.status}`);\n }\n response.arrayBuffer().then(function (config) {\n initVyking(config);\n });\n });\n}\n\n/**\n * Load config and initVyking is mobile view.\n */\nfunction startVyking() {\n var deviceType = getDeviceType();\n window.location += '#arModal';\n var arModal = $('#ar-tryon-modal');\n if (deviceType === 'Desktop') {\n arModal.find('.artryon-desktop').show();\n arModal.find('.artryon-mobile').hide();\n } else {\n arModal.find('.artryon-mobile').show();\n arModal.find('.artryon-desktop').hide();\n arModal.find('.modal-content').spinner().start();\n if (!isReady) {\n loadConfig(arTryOnConfig);\n } else {\n var selectedStyle = $('.style-attribute.selected').attr('data-attrvalue');\n if (window.arTryOnEnabledStyles[selectedStyle]) {\n var styleURI = window.arTryOnEnabledStyles[selectedStyle];\n setStyleAR(styleURI);\n }\n }\n }\n}\n\n$(function () {\n $('#ar-tryon-modal').on('show.bs.modal', function () {\n startVyking();\n });\n\n $('#ar-tryon-modal').on('hide.bs.modal', function () {\n pauseAR();\n });\n\n var params = (new URL(window.location)).searchParams;\n var arParam = params.get('AR');\n if (arParam === 'arTryOn') {\n $('#arTryOn-btn').click();\n }\n});\n"],"sourceRoot":""}