{"version":3,"file":"popoutHelper-Dp_Rlapf.js","sources":["../../../node_modules/date-fns/esm/addMilliseconds/index.js","../../../app/javascript/widget/helpers/urlParamsHelper.js","../../../app/javascript/widget/helpers/popoutHelper.js"],"sourcesContent":["import toInteger from \"../_lib/toInteger/index.js\";\nimport toDate from \"../toDate/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name addMilliseconds\n * @category Millisecond Helpers\n * @summary Add the specified number of milliseconds to the given date.\n *\n * @description\n * Add the specified number of milliseconds to the given date.\n *\n * ### v2.0.0 breaking changes:\n *\n * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the milliseconds added\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Add 750 milliseconds to 10 July 2014 12:45:30.000:\n * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)\n * //=> Thu Jul 10 2014 12:45:30.750\n */\n\nexport default function addMilliseconds(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var timestamp = toDate(dirtyDate).getTime();\n var amount = toInteger(dirtyAmount);\n return new Date(timestamp + amount);\n}","export const buildSearchParamsWithLocale = search => {\n // [TODO] for now this works, but we will need to find a way to get the locale from the root component\n const locale = window.WOOT_WIDGET.$root.$i18n.locale;\n const params = new URLSearchParams(search);\n params.append('locale', locale);\n\n return `?${params}`;\n};\n\nexport const getLocale = (search = '') => {\n return new URLSearchParams(search).get('locale');\n};\n\nexport const buildPopoutURL = ({\n origin,\n conversationCookie,\n websiteToken,\n locale,\n}) => {\n const popoutUrl = new URL('/widget', origin);\n popoutUrl.searchParams.append('cw_conversation', conversationCookie);\n popoutUrl.searchParams.append('website_token', websiteToken);\n popoutUrl.searchParams.append('locale', locale);\n\n return popoutUrl.toString();\n};\n","import { buildPopoutURL } from './urlParamsHelper';\n\nexport const popoutChatWindow = (\n origin,\n websiteToken,\n locale,\n conversationCookie\n) => {\n try {\n const windowUrl = buildPopoutURL({\n origin,\n websiteToken,\n locale,\n conversationCookie,\n });\n const popoutWindow = window.open(\n windowUrl,\n `webwidget_session_${websiteToken}`,\n 'resizable=off,width=400,height=600'\n );\n popoutWindow.focus();\n } catch (err) {\n // eslint-disable-next-line no-console\n console.log(err);\n }\n};\n"],"names":["addMilliseconds","dirtyDate","dirtyAmount","requiredArgs","timestamp","toDate","amount","toInteger","buildSearchParamsWithLocale","search","locale","params","getLocale","buildPopoutURL","origin","conversationCookie","websiteToken","popoutUrl","popoutChatWindow","windowUrl","err"],"mappings":"sDA0Be,SAASA,EAAgBC,EAAWC,EAAa,CAC9DC,EAAa,EAAG,SAAS,EACzB,IAAIC,EAAYC,EAAOJ,CAAS,EAAE,QAAO,EACrCK,EAASC,EAAUL,CAAW,EAClC,OAAO,IAAI,KAAKE,EAAYE,CAAM,CACpC,CC/BY,MAACE,EAA8BC,GAAU,CAEnD,MAAMC,EAAS,OAAO,YAAY,MAAM,MAAM,OACxCC,EAAS,IAAI,gBAAgBF,CAAM,EACzC,OAAAE,EAAO,OAAO,SAAUD,CAAM,EAEvB,IAAIC,CAAM,EACnB,EAEaC,EAAY,CAACH,EAAS,KAC1B,IAAI,gBAAgBA,CAAM,EAAE,IAAI,QAAQ,EAGpCI,EAAiB,CAAC,CAC7B,OAAAC,EACA,mBAAAC,EACA,aAAAC,EACA,OAAAN,CACF,IAAM,CACJ,MAAMO,EAAY,IAAI,IAAI,UAAWH,CAAM,EAC3C,OAAAG,EAAU,aAAa,OAAO,kBAAmBF,CAAkB,EACnEE,EAAU,aAAa,OAAO,gBAAiBD,CAAY,EAC3DC,EAAU,aAAa,OAAO,SAAUP,CAAM,EAEvCO,EAAU,UACnB,ECvBaC,EAAmB,CAC9BJ,EACAE,EACAN,EACAK,IACG,CACH,GAAI,CACF,MAAMI,EAAYN,EAAe,CAC/B,OAAAC,EACA,aAAAE,EACA,OAAAN,EACA,mBAAAK,CACN,CAAK,EACoB,OAAO,KAC1BI,EACA,qBAAqBH,CAAY,GACjC,oCACN,EACiB,MAAK,CACnB,OAAQI,EAAK,CAEZ,QAAQ,IAAIA,CAAG,CAChB,CACH","x_google_ignoreList":[0]}