From 01da50f8cf4a1795c1410bca6b9fbce36e79e832 Mon Sep 17 00:00:00 2001 From: Ruchika Sinha <69535463+Ruchika4@users.noreply.github.com> Date: Wed, 14 Aug 2024 01:19:32 -0700 Subject: [PATCH 1/8] [MWPW-154970] allow authoring hash value delay=0 for promo modals (#2706) allow authoring delay=0 for modals --- libs/blocks/modal/modal.js | 4 ++-- test/blocks/modals/modals.test.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/blocks/modal/modal.js b/libs/blocks/modal/modal.js index 60a4e6d2ff..2ab382868a 100644 --- a/libs/blocks/modal/modal.js +++ b/libs/blocks/modal/modal.js @@ -222,7 +222,7 @@ export function getHashParams(hashStr) { params.hash = part; } else { const [key, val] = part.split('='); - if (key === 'delay' && parseInt(val, 10) > 0) { + if (key === 'delay') { params.delay = parseInt(val, 10) * 1000; } } @@ -232,7 +232,7 @@ export function getHashParams(hashStr) { export function delayedModal(el) { const { hash, delay } = getHashParams(el?.dataset.modalHash); - if (!delay || !hash) return false; + if (delay === undefined || !hash) return false; isDelayedModal = true; const modalOpenEvent = new Event(`${hash}:modalOpen`); const pagesModalWasShownOn = window.sessionStorage.getItem(`shown:${hash}`); diff --git a/test/blocks/modals/modals.test.js b/test/blocks/modals/modals.test.js index d4cb3abaa1..7cfd66704e 100644 --- a/test/blocks/modals/modals.test.js +++ b/test/blocks/modals/modals.test.js @@ -196,7 +196,10 @@ describe('Modals', () => { it('validates and returns proper hash parameters', () => { expect(getHashParams()).to.deep.equal({}); - expect(getHashParams('#delayed-modal:delay=0')).to.deep.equal({ hash: '#delayed-modal' }); + expect(getHashParams('#delayed-modal:delay=0')).to.deep.equal({ + delay: 0, + hash: '#delayed-modal', + }); expect(getHashParams('#delayed-modal:delay=1')).to.deep.equal({ delay: 1000, hash: '#delayed-modal', From 3c9774cc9a687cf20be86a5d2fe0a79cb708945a Mon Sep 17 00:00:00 2001 From: Suhani Jain <110388864+suhjainadobe@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:49:39 +0530 Subject: [PATCH 2/8] MWPW-153810 media image is seen loaded twice in product page urls in desktop (#2715) * Update utils.js * Update utils.js * Update utils.js * Update utils.js * Update utils.js * Update utils.js * Update body.html * Update utils.test.js --- libs/utils/utils.js | 26 +++++++++++++++++++++++--- test/utils/mocks/body.html | 2 +- test/utils/utils.test.js | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 2970289cea..fbbfb37cb4 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -730,10 +730,30 @@ async function decorateIcons(area, config) { async function decoratePlaceholders(area, config) { const el = area.querySelector('main') || area; const regex = /{{(.*?)}}|%7B%7B(.*?)%7D%7D/g; - const found = regex.test(el.innerHTML); - if (!found) return; + const walker = document.createTreeWalker( + el, + NodeFilter.SHOW_TEXT, + { + acceptNode(node) { + const a = regex.test(node.nodeValue) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT; + regex.lastIndex = 0; + return a; + }, + }, + ); + const nodes = []; + let node = walker.nextNode(); + while (node !== null) { + nodes.push(node); + node = walker.nextNode(); + } + if (!nodes.length) return; const { replaceText } = await import('../features/placeholders.js'); - el.innerHTML = await replaceText(el.innerHTML, config, regex); + const replaceNodes = nodes.map(async (textNode) => { + textNode.nodeValue = await replaceText(textNode.nodeValue, config, regex); + textNode.nodeValue = textNode.nodeValue.replace(/ /g, '\u00A0'); + }); + await Promise.all(replaceNodes); } async function loadFooter() { diff --git a/test/utils/mocks/body.html b/test/utils/mocks/body.html index 6e636675b1..44d2a43192 100644 --- a/test/utils/mocks/body.html +++ b/test/utils/mocks/body.html @@ -47,6 +47,6 @@

I'm not a blockhead.

-

{{nothing-to-see-here}}

+

{{ inkl. MwSt.}}

diff --git a/test/utils/utils.test.js b/test/utils/utils.test.js index d02c008716..f9c497baa8 100644 --- a/test/utils/utils.test.js +++ b/test/utils/utils.test.js @@ -191,7 +191,7 @@ describe('Utils', () => { it('Decorates placeholder', () => { const paragraphs = [...document.querySelectorAll('p')]; const lastPara = paragraphs.pop(); - expect(lastPara.textContent).to.equal('nothing to see here'); + expect(lastPara.textContent).to.equal(' inkl. MwSt.'); }); it('Decorates meta helix url', () => { From 8e03d6ec41b03f86ec835e01ea0611201de0df70 Mon Sep 17 00:00:00 2001 From: Vivian A Goodrich <101133187+vgoodric@users.noreply.github.com> Date: Wed, 14 Aug 2024 02:19:46 -0600 Subject: [PATCH 3/8] MWPW-146031 [MEP] Existing Personalization Tag UPDATE: Photoshop-any (#2735) update id's --- libs/features/personalization/entitlements.js | 2 +- libs/features/personalization/stage-entitlements.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/features/personalization/entitlements.js b/libs/features/personalization/entitlements.js index fef5fc1402..8bec487190 100644 --- a/libs/features/personalization/entitlements.js +++ b/libs/features/personalization/entitlements.js @@ -1,7 +1,7 @@ import { getConfig } from '../../utils/utils.js'; const ENTITLEMENT_MAP = { - '51b1f617-2e43-4e91-a98a-3b7716ecba8f': 'photoshop-any', + '31943c06-06de-4f5f-8689-18973c13207a': 'photoshop-any', '8ba78b22-90fb-4b97-a1c4-f8c03a45cbc2': 'indesign-any', '8d3c8ac2-2937-486b-b6ff-37f02271b09b': 'illustrator-any', 'fd30e9c7-9ae9-44db-8e70-5c652a5bb1d2': 'cc-all-apps-any', diff --git a/libs/features/personalization/stage-entitlements.js b/libs/features/personalization/stage-entitlements.js index ac8515fb8e..77ae919c5e 100644 --- a/libs/features/personalization/stage-entitlements.js +++ b/libs/features/personalization/stage-entitlements.js @@ -1,5 +1,5 @@ const STAGE_ENTITLEMENTS = { - '5a5fd14e-f4ca-49d2-9f87-835df5477e3c': 'photoshop-any', + '22ec76d1-b715-4ec5-8f36-b0db7c8b725a': 'photoshop-any', '09bc4ba3-ebed-4d05-812d-a1fb1a7e82ae': 'indesign-any', '25ede755-7181-4be2-801e-19f157c005ae': 'illustrator-any', 'bf632803-4412-463d-83c5-757dda3224ee': 'cc-all-apps-any', From d0f2a3785f90f9233b6193d46879e699d58a5767 Mon Sep 17 00:00:00 2001 From: Vivian A Goodrich <101133187+vgoodric@users.noreply.github.com> Date: Wed, 14 Aug 2024 02:19:53 -0600 Subject: [PATCH 4/8] MWPW-156624 [MILO][MEP] Add locale prefix as an option for placeholder feature (#2736) * mepgeofolder * Update libs/features/personalization/preview.js Co-authored-by: Mark Perry <124626043+markpadbe@users.noreply.github.com> * MWPW-156545 [MILO][MEP] Info in MEP button panel is incorrect (#2729) * stash * add override existance to if check --------- Co-authored-by: Mark Perry <124626043+markpadbe@users.noreply.github.com> --- .../personalization/personalization.js | 19 ++++++++++++------- libs/features/personalization/preview.js | 10 +++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index 4a092127b4..4586cc158b 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -442,11 +442,11 @@ export function handleCommands(commands, rootEl = document, forceInline = false) }); } -const getVariantInfo = (line, variantNames, variants, manifestPath, manifestOverrideName) => { +const getVariantInfo = (line, variantNames, variants, manifestPath, fTargetId) => { const config = getConfig(); let manifestId = getFileName(manifestPath); let targetId = manifestId.replace('.json', ''); - if (manifestOverrideName) targetId = manifestOverrideName; + if (fTargetId) targetId = fTargetId; if (!config.mep?.preview) manifestId = false; const action = line.action?.toLowerCase().replace('content', '').replace('fragment', ''); const { selector } = line; @@ -508,7 +508,7 @@ const getVariantInfo = (line, variantNames, variants, manifestPath, manifestOver }); }; -export function parseManifestVariants(data, manifestPath, manifestOverrideName) { +export function parseManifestVariants(data, manifestPath, targetId) { if (!data?.length) return null; const manifestConfig = {}; @@ -524,7 +524,7 @@ export function parseManifestVariants(data, manifestPath, manifestOverrideName) }); experiences.forEach((line) => { - getVariantInfo(line, variantNames, variants, manifestPath, manifestOverrideName); + getVariantInfo(line, variantNames, variants, manifestPath, targetId); }); manifestConfig.variants = variants; @@ -545,6 +545,7 @@ function parsePlaceholders(placeholders, config, selectedVariantName = '') { if (!placeholders?.length || selectedVariantName === 'default') return config; const valueNames = [ selectedVariantName.toLowerCase(), + config.mep?.geoPrefix, config.locale.region.toLowerCase(), config.locale.ietf.toLowerCase(), ...config.locale.ietf.toLowerCase().split('-'), @@ -684,8 +685,9 @@ export async function getManifestConfig(info, variantOverride = false) { acc[item.key] = item.value; return acc; }, {}); - const manifestOverrideName = name || infoObj?.['manifest-override-name']?.toLowerCase(); - const manifestConfig = parseManifestVariants(persData, manifestPath, manifestOverrideName); + const manifestOverrideName = infoObj?.['manifest-override-name']?.toLowerCase(); + const targetId = name || manifestOverrideName; + const manifestConfig = parseManifestVariants(persData, manifestPath, targetId); if (!manifestConfig) { /* c8 ignore next 3 */ @@ -697,8 +699,10 @@ export async function getManifestConfig(info, variantOverride = false) { 'manifest-execution-order': ['First', 'Normal', 'Last'], }; if (infoTab) { - manifestConfig.manifestOverrideName = manifestOverrideName; manifestConfig.manifestType = infoObj?.['manifest-type']?.toLowerCase(); + if (manifestOverrideName && manifestConfig.manifestType === TRACKED_MANIFEST_TYPE) { + manifestConfig.manifestOverrideName = manifestOverrideName; + } const executionOrder = { 'manifest-type': 1, 'manifest-execution-order': 1, @@ -955,6 +959,7 @@ export async function init(enablements = {}) { highlight: (mepHighlight !== undefined && mepHighlight !== 'false'), targetEnabled: target, experiments: [], + geoPrefix: config.locale?.prefix.split('/')[1]?.toLowerCase() || 'en-us', }; manifests = manifests.concat(await combineMepSources(pzn, promo, mepParam)); manifests?.forEach((manifest) => { diff --git a/libs/features/personalization/preview.js b/libs/features/personalization/preview.js index d98050622b..f88c0d4889 100644 --- a/libs/features/personalization/preview.js +++ b/libs/features/personalization/preview.js @@ -143,6 +143,7 @@ function createPreviewPill(manifests) { manifestUrl, manifestOverrideName, } = manifest; + const editUrl = manifestUrl || manifestPath; let radio = ''; variantNames.forEach((variant) => { const checked = { @@ -180,18 +181,18 @@ function createPreviewPill(manifests) {

On: ${manifest.event.start?.toLocaleString()} - instant

Off: ${manifest.event.end?.toLocaleString()}

` : ''; let analyticsTitle = ''; - if (manifestType === TRACKED_MANIFEST_TYPE) { + if (manifestType !== TRACKED_MANIFEST_TYPE) { analyticsTitle = 'N/A for this manifest type'; } else if (manifestOverrideName) { analyticsTitle = manifestOverrideName; } else { analyticsTitle = manifestFileName.replace('.json', '').slice(0, 20); } - manifestList += `
+ manifestList += `
${targetTitle} - + ${scheduled} @@ -228,8 +229,7 @@ function createPreviewPill(manifests) {
Page Info:
Target integration feature is ${targetOnText}
Personalization feature is ${personalizationOnText}
-
Page's Region is ${config.locale.region}
-
Page's Locale is ${config.locale.ietf}
+
Page's Prefix/Region/Locale are ${config.mep.geoPrefix} / ${config.locale.region} / ${config.locale.ietf}
From fea81804d531a19bc05e294eba7a0daccf2d0b4f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:31:16 +0000 Subject: [PATCH 5/8] [AUTOMATED-PR] Update imslib.min.js dependency (#2740) Update self hosted dependency Co-authored-by: GitHub Action --- libs/deps/imslib.min.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/deps/imslib.min.js b/libs/deps/imslib.min.js index 6a22727819..ab5505bf74 100644 --- a/libs/deps/imslib.min.js +++ b/libs/deps/imslib.min.js @@ -1,4 +1,4 @@ -// Built 2024-07-31T01:04:03.854Z - Last Modified 2024-07-30T10:51:53.000Z +// Built 2024-08-14T01:18:38.920Z - Last Modified 2024-08-13T11:31:26.000Z var roll=function(){ /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. @@ -14,4 +14,4 @@ var roll=function(){ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};function t(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}var r=function(){return(r=Object.assign||function(e){for(var t,r=1,o=arguments.length;r0&&n[n.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]0)&&!(o=i.next()).done;)s.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return s}function a(){for(var e=[],t=0;t=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(Object.keys(a)),u=c.next();!u.done;u=c.next()){var l=u.value;if(r===l||r.endsWith("."+l))return new e(!0,a[l],n)}}catch(e){i={error:e}}finally{try{u&&!u.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}}return new e(!1,n)},e.prototype.shouldFallbackToAdobe=function(e){return!!this.proxied&&("feature_disabled"===e.error&&"cdsc"===e.error_description)},e.THIRD_PARTY_DOMAINS_PROD={"behance.net":"https://sso.behance.net"},e.THIRD_PARTY_DOMAINS_STAGE={"s2stagehance.com":"https://sso.s2stagehance.com"},e}(),m=new(function(){function e(){this.baseUrlAdobe="",this.baseUrlServices="",this.checkTokenEndpoint=new g,this.jslibver="v2-v0.43.0-3-gc3eb4d3"}return e.prototype.loadEnvironment=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r="");var o=e===l.STAGE;o?(this.baseUrlAdobe="https://ims-na1-stg1.adobelogin.com",this.baseUrlServices="https://adobeid-na1-stg1.services.adobe.com"):(this.baseUrlAdobe="https://ims-na1.adobelogin.com",this.baseUrlServices="https://adobeid-na1.services.adobe.com"),this.checkTokenEndpoint=g.computeEndpoint(t,r,o,this.baseUrlServices)},e}());function y(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}function k(e,t){if(null==e)return t;if(e===t)return e;if(!y(e))return e;var r=Object.assign({},e);return y(t)&&Object.keys(t).forEach((function(o){var n,i;y(t[o])?o in e?r[o]=k(e[o],t[o]):Object.assign(r,((n={})[o]=t[o],n)):Object.assign(r,((i={})[o]=t[o],i))})),r}var w=new(function(){function e(){this.getCustomApiParameters=function(e,t){return e[t]||{}}}return e.prototype.mergeExternalParameters=function(e,t,r){return k(this.getCustomApiParameters(t,r),e)},e.prototype.toJson=function(e){try{return"string"!=typeof e?e:JSON.parse(e)}catch(e){return null}},e}()),b=function(){function e(){}return e.getInitialRedirectUri=function(e,t){var r=e.redirect_uri||t||window.location.href,o="function"==typeof r?r():r,n=o.indexOf("from_ims");return-1===n?o:("#"===o[n-1]&&n--,o.substr(0,n))},e.createDefaultRedirectUrl=function(e,t,r,o){var n=this.getInitialRedirectUri(r,e),i=this.createOldHash(n);return i.indexOf("?")>0?i+"&client_id="+t+"&api="+o:i+"?client_id="+t+"&api="+o},e.createRedirectUrl=function(e,t,r,o,n){void 0===n&&(n="");var i=this.createDefaultRedirectUrl(e,t,r,o);(n=n||r.scope||"")&&(i=i+"&scope="+n);var s=r.reauth||"";return s&&(i=i+"&reauth="+s),i},e.createOldHash=function(e){var t=e.indexOf("#");return t<0?e+"#old_hash=&from_ims=true":e.substring(0,t)+"#old_hash="+e.substring(t+1)+"&from_ims=true"},e.mergeApiParamsWithExternalParams=function(e,t,r){return k(w.getCustomApiParameters(e,r),t)},e}(),S=function(){var e=this;this.composeRedirectUrl=function(e){var t=e.apiParameters,o=e.externalParameters,n=void 0===o?{}:o,i=e.adobeIdRedirectUri,s=void 0===i?"":i,a=e.clientId,c=e.locale,u=e.state,l=void 0===u?{}:u,d=e.scope,p=void 0===d?n.scope||t.scope||"":d,h=b.mergeApiParamsWithExternalParams(t,n,"authorize");l&&(h.state=k(h.state||{},l));var f=b.createRedirectUrl(s,a,h,"authorize",p),v=n.locale||c||"",g=e.response_type,y=void 0===g?h.response_type||"":g;return r(r({},h),{client_id:a,scope:p,locale:v,response_type:y,jslVersion:m.jslibver,redirect_uri:f})},this.createRedirectUrl=function(t){var r=e.composeRedirectUrl(t),o=v.uriEncodeData(r);return m.baseUrlAdobe+"/ims/authorize/v1?"+o}},T=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.signIn=function(e){var r=t.createRedirectUrl(e);v.setHrefUrl(r)},t.authorizeToken=function(e,r){var o=t.composeRedirectUrl(r);e&&(o.user_assertion=e,o.user_assertion_type="urn:ietf:params:oauth:client-assertion-type:jwt-bearer"),t.createAuthorizeForm(o).submit()},t}return t(r,e),r.prototype.createAuthorizeForm=function(e){var t=m.baseUrlAdobe+"/ims/authorize/v1",r=document.createElement("form");r.style.display="none",r.setAttribute("method","post"),r.setAttribute("action",t);var o=null,n=null,i="";for(var s in e){if("object"==typeof(n=e[s])){if(0===Object.keys(n).length)continue;i=JSON.stringify(n)}else i=n;""!==i&&(o=this.createFormElement("input","text",s,i),r.appendChild(o))}return document.getElementsByTagName("body")[0].appendChild(r),r},r.prototype.createFormElement=function(e,t,r,o){var n=document.createElement(e);return n.setAttribute("type",t),n.setAttribute("name",r),n.setAttribute("value",o),n},r}(S),I=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/,_=["https://auth.services.adobe.com","https://auth-stg1.services.adobe.com","https://localhost.corp.adobe.com:9000"],P=new function(){var e=this;this.windowObjectReference=null,this.previousUrl="",this.openSignInWindow=function(t,r,o,n){e.onProcessLocation=n,e.allowOrigin=o.allowOrigin,e.timerId&&clearInterval(e.timerId),window.removeEventListener("message",e.receiveMessage),window.addEventListener("message",e.receiveMessage),e.broadcastChannel&&e.broadcastChannel.close(),e.broadcastChannel=new BroadcastChannel("imslib"),e.broadcastChannel.onmessage=e.receiveMessage;var i="popup=yes, width="+o.width+", height="+o.height+", top="+o.top+", left="+o.left;!e.windowObjectReference||e.windowObjectReference&&e.windowObjectReference.closed?e.windowObjectReference=window.open(t,o.title,i):e.previousUrl!==t?(e.windowObjectReference=window.open(t,o.title,i),e.windowObjectReference&&e.windowObjectReference.focus()):e.windowObjectReference.focus(),e.previousUrl=t},this.receiveMessage=function(t){if(a(_,[e.allowOrigin]).includes(t.origin)){try{if(!I.test(t.data))return void console.warn("refused to receive message containing unknown data format",t.data)}catch(e){return void console.error(e)}e.broadcastChannel&&e.broadcastChannel.close(),e.onProcessLocation&&e.onProcessLocation(t.data)}else console.warn("refused to receive message from origin not whitelisted",t.origin)}},R=function(e){function o(t,o){var n=e.call(this)||this;return n.signIn=function(e){e.state=r(r({},e.state),{imslibmodal:!0});var t=e.state.nonce,o=n.createRedirectUrl(e);P.openSignInWindow(o,t,n.popupSettings,n.onPopupMessage)},n.onPopupMessage=t,n.popupSettings=o,n}return t(o,e),o}(S),E=function(){function e(e,t){this.status=0,this.data="",this.status=e,this.data=this.toJson(t)}return e.prototype.toJson=function(e){try{return"string"!=typeof e?e:JSON.parse(e)}catch(t){return e}},e}(),A=new(function(){function e(){}return e.prototype.http=function(e){return new Promise((function(t,r){var o=new(0,window.XMLHttpRequest);"boolean"==typeof e.withCredentials?o.withCredentials=e.withCredentials:o.withCredentials=!0,"number"==typeof e.timeout&&(o.timeout=e.timeout),o.open(e.method,e.url,!0);var n;o.onload=function(){return this.status>=200&&this.status<300?t(new E(this.status,this.response)):r(new E(this.status,this.response))},o.onerror=function(){var e=new E(this.status,this.response);return r(e)},o.ontimeout=function(){var e=new E(0,"timeout");return r(e)},o.onabort=function(){var e=new E(0,"aborted");return r(e)},(n=e.headers)&&Object.keys(n).forEach((function(e){o.setRequestHeader(e,n[e])})),o.send(e.data)}))},e.prototype.post=function(e,t,r,o,n){return void 0===r&&(r={}),this.http({headers:r,method:"POST",url:e,data:t,withCredentials:o,timeout:n})},e.prototype.get=function(e,t,r,o){return void 0===t&&(t={}),this.http({headers:t,method:"GET",url:e,withCredentials:r,timeout:o})},e}()),O=function(){this.probe=function(e,t,r){if(void 0===r&&(r=2e3),!e||0===e.length)return Promise.resolve([]);for(var o={"Content-Type":"application/json","Cache-Control":"no-cache, no-store, must-revalidate",Pragma:"no-cache",Expires:0,"X-IMS-CLIENTID":t},n="/ims/cdsc_probe?"+v.uriEncodeData({client_id:t}),i=[],s=[],a=function(t){var a=e[t]+n;s.push(A.post(a,{},o,!1,r).then((function(e){return 200==e.status&&i.push(t)})).catch((function(){})))},c=0;c=0?new G("ride_pba_idle_session","",!0):null;var n=this.addRedirectUriToJump(r,o);return new G(r,n)},e.prototype.addRedirectUriToJump=function(e,t){if(!t||"string"!=typeof t)return"";var r=t;this.adobeIdThinData||(this.adobeIdThinData=new H);var o=this.adobeIdThinData.computeRideRedirectUri(e);if(!o||0===o.length)return r;try{var n=new URL(r);return n.searchParams.append("redirect_uri",o),n.toString()}catch(e){return r}},e.prototype.isUnauthorizedException=function(e){var t=e.status;return 401===(void 0===t?0:t)},e}()),K=new(function(){function e(){this.triggerOnError=null}return e.prototype.post=function(e,t,r){var o=this;void 0===r&&(r={});var n=z.getCachedApiResponse(e,t);if(n){var i=n.status,s=n.data;return 200===i?Promise.resolve(s):Promise.reject(s)}return A.post(e,t,r).then((function(r){return o.storeApiResponse(e,JSON.stringify(t),r)})).catch((function(r){return o.verifyError(e,JSON.stringify(t),r)}))},e.prototype.get=function(e,t){var r=this;void 0===t&&(t={});var o=z.getCachedApiResponse(e);if(o){var n=o.status,i=o.data;return 200===n?Promise.resolve(i):Promise.reject(i)}return A.get(e,t).then((function(t){return r.storeApiResponse(e,"",t)})).catch((function(t){return r.verifyError(e,"",t)}))},e.prototype.verifyError=function(e,t,r){this.storeApiResponse(e,t,r);var o=J.verify(r,e);return Promise.reject(o||r.data)},e.prototype.storeApiResponse=function(e,t,r){return void 0===t&&(t=""),z.storeApiResponse(e,t,r),Promise.resolve(r.data)},e}()),B=function(){function e(e){void 0===e&&(e={}),this.CONTENT_FORM_ENCODED="application/x-www-form-urlencoded;charset=utf-8",this.apiParameters=e}return e.prototype.validateToken=function(e){var t=e.token,o=e.client_id,n=e.type,i=v.uriEncodeData(r(r({},w.getCustomApiParameters(this.apiParameters,"validate_token")),{type:n||"access_token",client_id:o,token:t})),s=m.baseUrlAdobe+"/ims/validate_token/v1?jslVersion="+m.jslibver,a=this.formEncoded();return this.addClientIdInHeader(o,a),K.post(s,i,a)},e.prototype.getProfile=function(e){var t=e.token,o=e.client_id,n=r({},w.getCustomApiParameters(this.apiParameters,"profile")),i=this.createAuthorizationHeader(t);this.addClientIdInHeader(o,i);var s=v.uriEncodeData(r({client_id:o},n)),a=m.baseUrlAdobe+"/ims/profile/v1?"+s+"&jslVersion="+m.jslibver;return K.get(a,i)},e.prototype.getUserInfo=function(e){var t=e.token,o=e.client_id,n=r({},w.getCustomApiParameters(this.apiParameters,"userinfo")),i=this.createAuthorizationHeader(t);this.addClientIdInHeader(o,i);var s=v.uriEncodeData(r({client_id:o},n)),a=m.baseUrlAdobe+"/ims/userinfo/v1?"+s+"&jslVersion="+m.jslibver;return K.get(a,i)},e.prototype.logoutToken=function(e){var t=e.client_id,o=e.token,n=r({},w.getCustomApiParameters(this.apiParameters,"logout_token")),i=m.baseUrlServices+"/ims/logout/v1?jslVersion="+m.jslibver,s=this.addClientIdInHeader(t);return K.post(i,r({client_id:t,access_token:o},n),s)},e.prototype.checkStatus=function(){var e=m.baseUrlServices+"/ims/check/v1/status";return K.get(e)},e.prototype.checkToken=function(e,t,o){var n=e.client_id,i=e.scope,s=r({},w.mergeExternalParameters(t,this.apiParameters,"check_token")),a=r(r({},s),{client_id:n,scope:i});return o&&(a.user_id=o),this.callCheckToken(v.uriEncodeData(a),n,"/check/v6/token?jslVersion="+m.jslibver)},e.prototype.switchProfile=function(e,t,o){void 0===o&&(o="");var n=e.client_id,i=e.scope,s=void 0===i?"":i,a=r({},w.mergeExternalParameters(t,this.apiParameters,"check_token")),c=v.uriEncodeData(r(r({},a),{client_id:n,scope:s,user_id:o}));return this.callCheckToken(c,n,"/check/v6/token?jslVersion="+m.jslibver)},e.prototype.listSocialProviders=function(e){var t=e.client_id,o=r({},w.getCustomApiParameters(this.apiParameters,"providers")),n=v.uriEncodeData(r({client_id:t},o)),i=m.baseUrlServices+"/ims/social/v2/providers?"+n+"&jslVersion="+m.jslibver,s=this.addClientIdInHeader(t);return K.get(i,s)},e.prototype.exchangeIjt=function(e,t){var o=e.client_id,n=r({},w.getCustomApiParameters(this.apiParameters,"ijt")),i=m.baseUrlServices+"/ims/jump/implicit/"+t,s=v.uriEncodeData(r({client_id:o},n)),a=i+"?"+s+"&jslVersion="+m.jslibver;a.length>2048&&(delete n.redirect_uri,a=i+"?"+(s=v.uriEncodeData(n)));var c=this.addClientIdInHeader(o);return K.get(a,c)},e.prototype.avatarUrl=function(e){return m.baseUrlAdobe+"/ims/avatar/download/"+e},e.prototype.getReleaseFlags=function(e){var t=e.token,o=e.client_id,n=r({},w.getCustomApiParameters(this.apiParameters,"fg_value")),i=this.createAuthorizationHeader(t);this.addClientIdInHeader(o,i);var s=v.uriEncodeData(r({client_id:o},n)),a=m.baseUrlAdobe+"/ims/fg/value/v1?"+s+"&jslVersion="+m.jslibver;return K.get(a,i)},e.prototype.getTransitoryAuthorizationCode=function(e,t,o){void 0===t&&(t={});var n=r({},w.mergeExternalParameters(t,this.apiParameters,"check_token")),i=v.uriEncodeData(r(r({},n),e));return this.callCheckToken(i,o,"/check/v6/token?client_id="+o+"&jslVersion="+m.jslibver)},e.prototype.getTokenFromCode=function(e,t){void 0===t&&(t={});var o=r({},w.mergeExternalParameters(t,this.apiParameters,"token"));o.grant_type="authorization_code",delete e.other;var n=m.baseUrlServices+"/ims/token/v3?jslVersion="+m.jslibver,i=v.uriEncodeData(r(r({},o),e)),s=this.formEncoded();return this.addClientIdInHeader(e.client_id,s),K.post(n,i,s)},e.prototype.jumpToken=function(e,t,o){void 0===t&&(t={});var n=r({},w.mergeExternalParameters(t,this.apiParameters,"jumptoken")),i=m.baseUrlServices+"/ims/jumptoken/v1?client_id="+o+"&jslVersion="+m.jslibver,s=v.uriEncodeData(r(r({},n),e)),a=this.formEncoded();return this.addClientIdInHeader(o,a),K.post(i,s,a)},e.prototype.socialHeadlessSignIn=function(e,t){void 0===t&&(t={});var o=r({},w.mergeExternalParameters(t,this.apiParameters,"jumptoken")),n=m.baseUrlServices+"/ims/social/v2/native?jslVersion="+m.jslibver,i=v.uriEncodeData(r(r(r({},o),e),{response_type:"implicit_jump"}));return K.post(n,i,this.formEncoded())},e.prototype.createAuthorizationHeader=function(e){var t={};return e&&(t[d]="Bearer "+e),t},e.prototype.formEncoded=function(e){return void 0===e&&(e={}),e["content-type"]=this.CONTENT_FORM_ENCODED,e},e.prototype.addClientIdInHeader=function(e,t){return void 0===t&&(t={}),t.client_id=e,t},e.prototype.callCheckToken=function(e,t,r){var o=this.formEncoded();return this.addClientIdInHeader(t,o),K.post(m.checkTokenEndpoint.url+"/ims"+r,e,o).catch((function(t){if(!m.checkTokenEndpoint.shouldFallbackToAdobe(t))throw t;return K.post(m.checkTokenEndpoint.fallbackUrl+"/ims"+r,e,o)}))},e}();!function(e){e.INITIALIZE_ERROR="initialize_error",e.HTTP="http",e.FRAGMENT="fragment",e.CSRF="csrf",e.NOT_ALLOWED="not_allowed",e.PROFILE_EXCEPTION="profile_exception",e.TOKEN_EXPIRED="token_expired",e.SOCIAL_PROVIDERS="SOCIAL_PROVIDERS",e.RIDE_EXCEPTION="ride_exception"}(N||(N={}));var W=function(e){this.message=null,this.errorType=N.PROFILE_EXCEPTION,this.message=e},Y=/\s|,/g;function X(e){return e.split(Y).sort().join(",")}var Z,Q=function(){function e(e){this.profileServiceRequest=e,this.storage=h.getStorageByName(c.SessionStorage)}return e.prototype.getProfile=function(e){var t=this,r=this.profileServiceRequest,o=r.clientId,n=r.imsApis,i=this.getProfileFromStorage();return i?Promise.resolve(i):n.getProfile({client_id:o,token:e}).then((function(e){if(!e)throw new W("NO profile response");if(0===Object.keys(e).length)throw new W("NO profile value");return t.saveProfileToStorage(e),Promise.resolve(e)})).catch((function(e){return e instanceof q?Promise.reject(e):(t.removeProfile(),Promise.reject(e))}))},e.prototype.getProfileStorageKey=function(){var e=this.profileServiceRequest;return"adobeid_ims_profile/"+e.clientId+"/"+!1+"/"+X(e.scope)},e.prototype.getProfileFromStorage=function(){var e=this.getProfileStorageKey(),t=this.storage.getItem(e);return t&&JSON.parse(t)},e.prototype.saveProfileToStorage=function(e){var t=this.getProfileStorageKey();this.storage.setItem(t,JSON.stringify(e))},e.prototype.removeProfile=function(){var e=this.getProfileStorageKey();this.storage.removeItem(e)},e.prototype.removeProfileIfOtherUser=function(e){if(e){var t=this.getProfileFromStorage();t&&t.userId!==e&&this.removeProfile()}},e}();!function(e){e.GUEST="guest"}(Z||(Z={}));var $,ee=function(){function e(e,t){var r=this;this.REAUTH_SCOPE="reauthenticated",this.valid=!1,this.isReauth=function(){return r.scope.indexOf(r.REAUTH_SCOPE)>=0},this.client_id="",this.scope="",this.expire=new Date,this.user_id="",this.tokenValue="",this.sid="",this.state=null,this.fromFragment=!1,this.impersonatorId="",this.isImpersonatedSession=!1;var o=e.valid,n=e.tokenValue,i=e.access_token,s=e.state,a=e.other,c=n||i,u=this.parseJwt(c);if(!u)throw new Error("token cannot be decoded "+c);this.state=w.toJson(s);var l=u.client_id,d=u.user_id,p=u.scope,h=u.sid,f=u.imp_id,v=u.imp_sid,g=u.pba,m=u.atp,y=u.gse;this.atp=m,this.client_id=l,this.expire=t,this.user_id=d,this.scope=p,this.valid=o,this.tokenValue=c,this.sid=h,this.other=a,this.impersonatorId=f||"",this.isImpersonatedSession=!!v,this.pbaSatisfiedPolicies=g&&g.split(",")||[],this.isGuestToken=this.atp===Z.GUEST,this.gse=y}return e.prototype.parseJwt=function(e){if(!e)return null;try{return JSON.parse(atob(e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")))}catch(t){return p.error("error on decoding token ",e,t),null}},e.prototype.validate=function(e,t){var r,o,n,i=this.valid,s=this.client_id,a=this.scope,c=this.expire;return c0&&(r=new Array(o+1).join(e)+r),r}("0",5,e.toString(2))},le=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("Data is not a string");var r=e.toLowerCase().split("");!function(e){if(e.length%8!=0)throw new Error("Data length is not a multiple of 8");e.forEach((function(e){if(!(e in ce))throw new Error("Unknown encoded character "+e)}));var t=!1;e.forEach((function(e){if("="!==e&&t)throw new Error("Found padding char in the middle of the string");"="===e&&(t=!0)}))}(r);var o=function(e){for(var t=e.length-1,r=0;"="===e[t];)++r,--t;return r}(r),n=[];r.forEach((function(e){n.push(ue(ce[e]))}));var i=n.join("");return o>0&&(i=i.slice(0,-5*o)),i.length%8!=0&&(i=i.slice(0,i.length%8*-1)),t?function(e){var t="";if(e.length%8!=0)throw new Error("Length must be a multiple of 8");for(var r=0,o=e.length;rfe.lastUserInteraction&&(fe.lastUserInteraction=n)}return o.tokenService.refreshToken(e).then((function(e){return o.onTokenProfileReceived(e)})).catch((function(e){if(p.error("refresh token error",e),e instanceof q)return Promise.reject(e);var t=o.verifyRideErrorExceptionStrict(e);return t||(o.profileService.removeProfile(),o.onTokenExpired(),Promise.reject(e))}))},this.switchProfile=function(e,t){return void 0===t&&(t={}),e?o.tokenService.switchProfile(e,t).then((function(e){return o.onTokenProfileReceived(e)})).catch((function(e){return o.verifyRideErrorException(e)})):Promise.reject(new Error("Please provide the user id for switchProfile"))},this.executeErrorCallback=function(e){if(p.info("initialize exception ended",e),!e||e.type!==$.LOGOUT){var t=o.adobeIdData.onError;t&&t(N.HTTP,"Initialization error")}},this.triggerOnImsInstance=function(e){var t=document.createEvent("CustomEvent"),r={clientId:o.adobeIdData.client_id,instance:e};t.initCustomEvent("onImsLibInstance",!1,!1,r),window.dispatchEvent(t)},this.processInitializeException=function(e){return void 0===e&&(e={}),p.warn("initialize",e),o.restoreHash(),Promise.reject(e)},this.verifyModalSignInEvent=function(e){return e instanceof ae?o.notifyParentAboutModalSignIn(e):Promise.reject(e)},this.verifyTokenExpiredException=function(e){return e instanceof ie?(o.adobeIdData.handlers.triggerOnAccessTokenHasExpired(),Promise.resolve()):Promise.reject(e)},this.verifyRideErrorException=function(e){return n(o,void 0,Promise,(function(){return i(this,(function(t){switch(t.label){case 0:return e instanceof G?this.adobeIdData.overrideErrorHandler&&!this.adobeIdData.overrideErrorHandler(e)?[2,Promise.reject(e)]:e.isPbaExpiredIdleSessionWorkaround?[4,this.signIn()]:[3,2]:[3,4];case 1:return t.sent(),[3,4];case 2:return e.jump?[4,v.replaceUrlAndWait(e.jump,1e4)]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2,Promise.reject(e)]}}))}))},this.verifyRideErrorExceptionStrict=function(e){return e instanceof G?o.verifyRideErrorException(e):null},this.verifyCsrfException=function(e){var t=e.type;return t&&t===N.CSRF&&o.signOut(),Promise.reject(e)},this.processTokenResponse=function(e){var t=o.adobeIdData.handlers,r=e.tokenFields,n=e.profile,i=r.tokenValue,s=r.state,a=r.expire,c=r.sid,u=r.user_id,l=r.other,d=void 0===l?{}:l,h=r.impersonatorId,f=r.isImpersonatedSession,g=r.pbaSatisfiedPolicies,m=r.isGuestToken,y=r.gse;p.info("token",i),d.from_ims&&v.setHash(d.old_hash||""),o.profileService.removeProfileIfOtherUser(u);var k={token:i,expire:a,sid:c,impersonatorId:h,isImpersonatedSession:f,pbaSatisfiedPolicies:g,isGuestToken:m,gse:y};return r.isReauth()?t.triggerOnReauthAccessToken(k):o.tokenReceived(k),n&&o.profileService.saveProfileToStorage(n),Promise.resolve(s)},this.exchangeIjt=function(e){var t=o.adobeIdData.ijt;return e||t?o.tokenService.exchangeIjt(e||t).then((function(e){return e.profile?o.profileService.saveProfileToStorage(e.profile):o.profileService.removeProfile(),Promise.resolve(e)})):Promise.reject(new Error("please set the adobeid.ijt value"))},this.adobeIdData=new L(e),t&&(this.instanceKey=t);var s=this.adobeIdData,a=s.api_parameters,c=void 0===a?{}:a,u=s.client_id,l=s.scope,d=s.useLocalStorage,h=s.autoValidateToken,g=s.modalMode,m=s.modalSettings;this.imsApis=new B(c),this.csrfService=new f(u,this.instanceKey),this.serviceRequest={clientId:u,scope:l,imsApis:this.imsApis},this.tokenService=new pe(r(r({},this.serviceRequest),{useLocalStorage:d,autoValidateToken:h}),this.csrfService),this.profileService=new Q(this.serviceRequest),this.signInservice=g?new R(this.onPopupMessage,m):new T}return Object.defineProperty(e.prototype,"version",{get:function(){return m.jslibver},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"adobeid",{get:function(){return r({},this.adobeIdData)},enumerable:!0,configurable:!0}),e.prototype.enableLogging=function(){p.enableLogging()},e.prototype.disableLogging=function(){p.disableLogging()},e.prototype.checkInitialized=function(){this.initialized},e.prototype.signUp=function(e,t){var r=this;void 0===e&&(e={}),this.checkInitialized();var o=this.adobeIdData,n=this.csrfService;if(!o)throw new Error("no adobeId on reAuthenticate");var i=n.initialize();return o.createSignUpRedirectRequest(e,t,i).then((function(e){r.signInservice.signIn(e)}))},e.prototype.isSignedInUser=function(){var e=this.getAccessToken();return(!e||!e.isGuestToken)&&!(!e&&!this.getReauthAccessToken())},e.prototype.getProfile=function(){var e=this,t=this.profileService.getProfileFromStorage();if(t)return Promise.resolve(t);var r=this.getAccessToken()||this.getReauthAccessToken();if(!r){var o="please login before getting the profile";return Promise.reject(new W(o))}if(r.isGuestToken){o="guest account does not have a profile";return Promise.reject(new W(o))}return this.profileService.getProfile(r.token).then((function(e){return Promise.resolve(e)})).catch((function(t){return p.error("get profile exception ",t),t instanceof q?e.refreshToken().then((function(e){return Promise.resolve(e.profile)})):Promise.reject(new W(t.message||t))}))},e.prototype.avatarUrl=function(e){return this.imsApis.avatarUrl(e)},e.prototype.getReleaseFlags=function(e){return void 0===e&&(e=!1),e?this.tokenService.getDecodedReleaseFlags():this.tokenService.getReleaseFlags()},e.prototype.getAccessToken=function(){return this.getTokenFromStorage(!1)},e.prototype.getReauthAccessToken=function(){return this.getTokenFromStorage(!0)},e.prototype.getTokenFromStorage=function(e){var t=this.tokenService.getTokenFieldsFromStorage(e);return t?{token:t.tokenValue,expire:t.expire,sid:t.sid,impersonatorId:t.impersonatorId,isImpersonatedSession:t.isImpersonatedSession,pbaSatisfiedPolicies:t.pbaSatisfiedPolicies,isGuestToken:t.isGuestToken,gse:t.gse}:null},e.prototype.listSocialProviders=function(){var e=this;return new Promise((function(t,r){var o=e.adobeIdData.client_id;e.imsApis.listSocialProviders({client_id:o}).then((function(e){t(e)})).catch((function(e){r(e)}))}))},e.prototype.tokenReceived=function(e){this.adobeIdData.handlers.triggerOnAccessToken(e),fe.startAutoRefreshFlow({expire:e.expire,refreshTokenMethod:this.refreshToken})},e.prototype.onTokenProfileReceived=function(e){var t=e.tokenInfo,r=e.profile;return p.info("token",t),this.tokenReceived(t),this.profileService.saveProfileToStorage(r),Promise.resolve(e)},e.prototype.validateToken=function(){var e=this;return this.tokenService.validateToken().then((function(){return Promise.resolve(!0)})).catch((function(t){return p.warn("validate token exception",t),t instanceof q?Promise.reject(!1):(e.profileService.removeProfile(),Promise.reject(!1))}))},e.prototype.onTokenExpired=function(){var e=this.adobeIdData.handlers;this.tokenService.purge(),e.triggerOnAccessTokenHasExpired()},e.prototype.setStandAloneToken=function(e){return this.tokenService.setStandAloneToken(e)},e.prototype.initialize=function(){var e,t=this,r=this.adobeIdData,o=r.handlers,n=r.standalone,i=r.ijt,s=r.alwaysRemoveTokenFromUrl,a=r.enableGuestAccounts,c=r.enableGuestTokenForceRefresh,u=null;switch(n&&this.setStandAloneToken(n),!0){case!!i:e=this.exchangeIjt;break;case a:e=this.tokenService.getGuestToken.bind(this.tokenService,{},{enableGuestAccounts:a,enableGuestTokenForceRefresh:c});break;default:e=this.tokenService.getTokenAndProfile}return e().then(this.processTokenResponse,this.processError.apply(this)).then((function(e){u=e})).finally((function(){p.info("onReady initialization"),window.addEventListener("getImsLibInstance",(function(){t.triggerOnImsInstance(t)}),!1),s&&v.setHash(te.removeAccessToken()),o.triggerOnReady(u?u.context:null),t.triggerOnImsInstance(t),t.initialized=!0}))},e.prototype.processError=function(){var e=this;return function(t){return e.verifyModalSignInEvent(t).catch(e.processInitializeException).catch(e.verifyTokenExpiredException).catch(e.verifyRideErrorException).catch(e.verifyCsrfException).catch(e.executeErrorCallback)}},e.prototype.notifyParentAboutModalSignIn=function(e){var t=window.location.href.replace("imslibmodal","wasmodal");if(window.opener)window.opener.postMessage(t,window.location.origin),window.close();else{var r=new BroadcastChannel("imslib");r.postMessage(t),r.close(),window.close()}return Promise.reject("popup")},e.prototype.restoreHash=function(){var e=te.fragmentToObject();e&&e.from_ims&&v.setHash(e.old_hash||"")},e.prototype.getTransitoryAuthorizationCode=function(e,t){return void 0===t&&(t={}),(e=e||{}).response_type=e.response_type||"code",e.target_client_id=e.target_client_id||this.adobeIdData.client_id,e.target_scope=e.target_scope||this.adobeIdData.scope,this.imsApis.getTransitoryAuthorizationCode(e,t,this.adobeIdData.client_id)},e.prototype.jumpToken=function(e,t){return void 0===t&&(t={}),e.target_client_id=e.target_client_id||this.adobeIdData.client_id,e.target_scope=e.target_scope||this.adobeIdData.scope,this.imsApis.jumpToken(e,t,this.adobeIdData.client_id)},e.prototype.getVerifierByKey=function(e){return(new M).getVerifierByKey(e)},e.prototype.socialHeadlessSignIn=function(e,t){return void 0===t&&(t={}),n(this,void 0,Promise,(function(){var r=this;return i(this,(function(o){return[2,this.imsApis.socialHeadlessSignIn(e,t).then((function(e){return r.exchangeIjt(e.token)})).catch((function(t){return"ride_AdobeID_social"===t.error&&r.signIn({idp_flow:"social.native",provider_id:e.provider_id,idp_token:e.idp_token}),Promise.reject(t)}))]}))}))},e.prototype.getAccountType=function(){var e=this.getAccessToken();if(!e)throw new Error("please login before getting the account type");if(e.isGuestToken)return oe.GUEST;var t=this.profileService.getProfileFromStorage();if(!t)throw new Error("you need to first get the profile before getting the account type");return t.account_type},e.prototype.getSessionExpiration=function(){var e=this.getAccessToken();if(!e)throw new Error("please obtain a token before getting the session expiration");return e.gse},e}(),ge=new(function(){function e(){this.createIMSLib=function(e,t){void 0===e&&(e=null),void 0===t&&(t="adobeIMS");var r=new ve(e,t);return window[t]=r,r}}return e.prototype.initAdobeIms=function(){window.adobeImsFactory={createIMSLib:this.createIMSLib};var e=window.adobeIMS||null;if(!e){var t=window.adobeid;if(!t||!t.client_id)return;(e=this.createIMSLib(t,"adobeIMS")).initialize()}},e}());return new(function(){function e(){ge.initAdobeIms()}return e.prototype.initialize=function(){return!0},e}())}(); +var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};function t(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}var r=function(){return(r=Object.assign||function(e){for(var t,r=1,o=arguments.length;r0&&n[n.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]0)&&!(o=i.next()).done;)s.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return s}function a(){for(var e=[],t=0;t=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(Object.keys(a)),u=c.next();!u.done;u=c.next()){var l=u.value;if(r===l||r.endsWith("."+l))return new e(!0,a[l],n)}}catch(e){i={error:e}}finally{try{u&&!u.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}}return new e(!1,n)},e.prototype.shouldFallbackToAdobe=function(e){return!!this.proxied&&("feature_disabled"===e.error&&"cdsc"===e.error_description)},e.THIRD_PARTY_DOMAINS_PROD={"behance.net":"https://sso.behance.net"},e.THIRD_PARTY_DOMAINS_STAGE={"s2stagehance.com":"https://sso.s2stagehance.com"},e}(),m=new(function(){function e(){this.baseUrlAdobe="",this.baseUrlServices="",this.checkTokenEndpoint=new g,this.jslibver="v2-v0.44.0-4-g6b36690"}return e.prototype.loadEnvironment=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r="");var o=e===l.STAGE;o?(this.baseUrlAdobe="https://ims-na1-stg1.adobelogin.com",this.baseUrlServices="https://adobeid-na1-stg1.services.adobe.com"):(this.baseUrlAdobe="https://ims-na1.adobelogin.com",this.baseUrlServices="https://adobeid-na1.services.adobe.com"),this.checkTokenEndpoint=g.computeEndpoint(t,r,o,this.baseUrlServices)},e}());function y(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}function k(e,t){if(null==e)return t;if(e===t)return e;if(!y(e))return e;var r=Object.assign({},e);return y(t)&&Object.keys(t).forEach((function(o){var n,i;y(t[o])?o in e?r[o]=k(e[o],t[o]):Object.assign(r,((n={})[o]=t[o],n)):Object.assign(r,((i={})[o]=t[o],i))})),r}var w=new(function(){function e(){this.getCustomApiParameters=function(e,t){return e[t]||{}}}return e.prototype.mergeExternalParameters=function(e,t,r){return k(this.getCustomApiParameters(t,r),e)},e.prototype.toJson=function(e){try{return"string"!=typeof e?e:JSON.parse(e)}catch(e){return null}},e}()),b=function(){function e(){}return e.getInitialRedirectUri=function(e,t){var r=e.redirect_uri||t||window.location.href,o="function"==typeof r?r():r,n=o.indexOf("from_ims");return-1===n?o:("#"===o[n-1]&&n--,o.substr(0,n))},e.createDefaultRedirectUrl=function(e,t,r,o){var n=this.getInitialRedirectUri(r,e),i=this.createOldHash(n);return i.indexOf("?")>0?i+"&client_id="+t+"&api="+o:i+"?client_id="+t+"&api="+o},e.createRedirectUrl=function(e,t,r,o,n){void 0===n&&(n="");var i=this.createDefaultRedirectUrl(e,t,r,o);(n=n||r.scope||"")&&(i=i+"&scope="+n);var s=r.reauth||"";return s&&(i=i+"&reauth="+s),i},e.createOldHash=function(e){var t=e.indexOf("#");return t<0?e+"#old_hash=&from_ims=true":e.substring(0,t)+"#old_hash="+e.substring(t+1)+"&from_ims=true"},e.mergeApiParamsWithExternalParams=function(e,t,r){return k(w.getCustomApiParameters(e,r),t)},e}(),S=function(){var e=this;this.composeRedirectUrl=function(e){var t=e.apiParameters,o=e.externalParameters,n=void 0===o?{}:o,i=e.adobeIdRedirectUri,s=void 0===i?"":i,a=e.clientId,c=e.locale,u=e.state,l=void 0===u?{}:u,d=e.scope,p=void 0===d?n.scope||t.scope||"":d,h=b.mergeApiParamsWithExternalParams(t,n,"authorize");l&&(h.state=k(h.state||{},l));var f=b.createRedirectUrl(s,a,h,"authorize",p),v=n.locale||c||"",g=e.response_type,y=void 0===g?h.response_type||"":g;return r(r({},h),{client_id:a,scope:p,locale:v,response_type:y,jslVersion:m.jslibver,redirect_uri:f})},this.createRedirectUrl=function(t){var r=e.composeRedirectUrl(t),o=v.uriEncodeData(r);return m.baseUrlAdobe+"/ims/authorize/v1?"+o}},T=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.signIn=function(e){var r=t.createRedirectUrl(e);v.setHrefUrl(r)},t.authorizeToken=function(e,r){var o=t.composeRedirectUrl(r);e&&(o.user_assertion=e,o.user_assertion_type="urn:ietf:params:oauth:client-assertion-type:jwt-bearer"),t.createAuthorizeForm(o).submit()},t}return t(r,e),r.prototype.createAuthorizeForm=function(e){var t=m.baseUrlAdobe+"/ims/authorize/v1",r=document.createElement("form");r.style.display="none",r.setAttribute("method","post"),r.setAttribute("action",t);var o=null,n=null,i="";for(var s in e){if("object"==typeof(n=e[s])){if(0===Object.keys(n).length)continue;i=JSON.stringify(n)}else i=n;""!==i&&(o=this.createFormElement("input","text",s,i),r.appendChild(o))}return document.getElementsByTagName("body")[0].appendChild(r),r},r.prototype.createFormElement=function(e,t,r,o){var n=document.createElement(e);return n.setAttribute("type",t),n.setAttribute("name",r),n.setAttribute("value",o),n},r}(S),I=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/,_=["https://auth.services.adobe.com","https://auth-stg1.services.adobe.com","https://localhost.corp.adobe.com:9000"],P=new function(){var e=this;this.windowObjectReference=null,this.previousUrl="",this.openSignInWindow=function(t,r,o,n){e.onProcessLocation=n,e.allowOrigin=o.allowOrigin,e.timerId&&clearInterval(e.timerId),window.removeEventListener("message",e.receiveMessage),window.addEventListener("message",e.receiveMessage),e.broadcastChannel&&e.broadcastChannel.close(),e.broadcastChannel=new BroadcastChannel("imslib"),e.broadcastChannel.onmessage=e.receiveMessage;var i="popup=yes, width="+o.width+", height="+o.height+", top="+o.top+", left="+o.left;!e.windowObjectReference||e.windowObjectReference&&e.windowObjectReference.closed?e.windowObjectReference=window.open(t,o.title,i):e.previousUrl!==t?(e.windowObjectReference=window.open(t,o.title,i),e.windowObjectReference&&e.windowObjectReference.focus()):e.windowObjectReference.focus(),e.previousUrl=t},this.receiveMessage=function(t){if(a(_,[e.allowOrigin]).includes(t.origin)){try{if(!I.test(t.data))return void console.warn("refused to receive message containing unknown data format",t.data)}catch(e){return void console.error(e)}e.broadcastChannel&&e.broadcastChannel.close(),e.onProcessLocation&&e.onProcessLocation(t.data)}else console.warn("refused to receive message from origin not whitelisted",t.origin)}},R=function(e){function o(t,o){var n=e.call(this)||this;return n.signIn=function(e){e.state=r(r({},e.state),{imslibmodal:!0});var t=e.state.nonce,o=n.createRedirectUrl(e);P.openSignInWindow(o,t,n.popupSettings,n.onPopupMessage)},n.onPopupMessage=t,n.popupSettings=o,n}return t(o,e),o}(S),E=function(){function e(e,t){this.status=0,this.data="",this.status=e,this.data=this.toJson(t)}return e.prototype.toJson=function(e){try{return"string"!=typeof e?e:JSON.parse(e)}catch(t){return e}},e}(),A=new(function(){function e(){}return e.prototype.http=function(e){return new Promise((function(t,r){var o=new(0,window.XMLHttpRequest);"boolean"==typeof e.withCredentials?o.withCredentials=e.withCredentials:o.withCredentials=!0,"number"==typeof e.timeout&&(o.timeout=e.timeout),o.open(e.method,e.url,!0);var n;o.onload=function(){return this.status>=200&&this.status<300?t(new E(this.status,this.response)):r(new E(this.status,this.response))},o.onerror=function(){var e=new E(this.status,this.response);return r(e)},o.ontimeout=function(){var e=new E(0,"timeout");return r(e)},o.onabort=function(){var e=new E(0,"aborted");return r(e)},(n=e.headers)&&Object.keys(n).forEach((function(e){o.setRequestHeader(e,n[e])})),o.send(e.data)}))},e.prototype.post=function(e,t,r,o,n){return void 0===r&&(r={}),this.http({headers:r,method:"POST",url:e,data:t,withCredentials:o,timeout:n})},e.prototype.get=function(e,t,r,o){return void 0===t&&(t={}),this.http({headers:t,method:"GET",url:e,withCredentials:r,timeout:o})},e}()),O=function(){this.probe=function(e,t,r){if(void 0===r&&(r=2e3),!e||0===e.length)return Promise.resolve([]);for(var o={"Content-Type":"application/json","Cache-Control":"no-cache, no-store, must-revalidate",Pragma:"no-cache",Expires:0,"X-IMS-CLIENTID":t},n="/ims/cdsc_probe?"+v.uriEncodeData({client_id:t}),i=[],s=[],a=function(t){var a=e[t]+n;s.push(A.post(a,{},o,!1,r).then((function(e){return 200==e.status&&i.push(t)})).catch((function(){})))},c=0;c=0?new G("ride_pba_idle_session","",!0):null;var n=this.addRedirectUriToJump(r,o);return new G(r,n)},e.prototype.addRedirectUriToJump=function(e,t){if(!t||"string"!=typeof t)return"";var r=t;this.adobeIdThinData||(this.adobeIdThinData=new M);var o=this.adobeIdThinData.computeRideRedirectUri(e);if(!o||0===o.length)return r;try{var n=new URL(r);return n.searchParams.append("redirect_uri",o),n.toString()}catch(e){return r}},e.prototype.isUnauthorizedException=function(e){var t=e.status;return 401===(void 0===t?0:t)},e}()),K=new(function(){function e(){this.triggerOnError=null}return e.prototype.post=function(e,t,r){var o=this;void 0===r&&(r={});var n=z.getCachedApiResponse(e,t);if(n){var i=n.status,s=n.data;return 200===i?Promise.resolve(s):Promise.reject(s)}return A.post(e,t,r).then((function(r){return o.storeApiResponse(e,JSON.stringify(t),r)})).catch((function(r){return o.verifyError(e,JSON.stringify(t),r)}))},e.prototype.get=function(e,t){var r=this;void 0===t&&(t={});var o=z.getCachedApiResponse(e);if(o){var n=o.status,i=o.data;return 200===n?Promise.resolve(i):Promise.reject(i)}return A.get(e,t).then((function(t){return r.storeApiResponse(e,"",t)})).catch((function(t){return r.verifyError(e,"",t)}))},e.prototype.verifyError=function(e,t,r){this.storeApiResponse(e,t,r);var o=J.verify(r,e);return Promise.reject(o||r.data)},e.prototype.storeApiResponse=function(e,t,r){return void 0===t&&(t=""),z.storeApiResponse(e,t,r),Promise.resolve(r.data)},e}()),B=function(){function e(e){void 0===e&&(e={}),this.CONTENT_FORM_ENCODED="application/x-www-form-urlencoded;charset=utf-8",this.apiParameters=e}return e.prototype.validateToken=function(e){var t=e.token,o=e.client_id,n=e.type,i=v.uriEncodeData(r(r({},w.getCustomApiParameters(this.apiParameters,"validate_token")),{type:n||"access_token",client_id:o,token:t})),s=m.baseUrlAdobe+"/ims/validate_token/v1?jslVersion="+m.jslibver,a=this.formEncoded();return this.addClientIdInHeader(o,a),K.post(s,i,a)},e.prototype.getProfile=function(e){var t=e.token,o=e.client_id,n=r({},w.getCustomApiParameters(this.apiParameters,"profile")),i=this.createAuthorizationHeader(t);this.addClientIdInHeader(o,i);var s=v.uriEncodeData(r({client_id:o},n)),a=m.baseUrlAdobe+"/ims/profile/v1?"+s+"&jslVersion="+m.jslibver;return K.get(a,i)},e.prototype.getUserInfo=function(e){var t=e.token,o=e.client_id,n=r({},w.getCustomApiParameters(this.apiParameters,"userinfo")),i=this.createAuthorizationHeader(t);this.addClientIdInHeader(o,i);var s=v.uriEncodeData(r({client_id:o},n)),a=m.baseUrlAdobe+"/ims/userinfo/v1?"+s+"&jslVersion="+m.jslibver;return K.get(a,i)},e.prototype.logoutToken=function(e){var t=e.client_id,o=e.token,n=r({},w.getCustomApiParameters(this.apiParameters,"logout_token")),i=m.baseUrlServices+"/ims/logout/v1?jslVersion="+m.jslibver,s=this.addClientIdInHeader(t);return K.post(i,r({client_id:t,access_token:o},n),s)},e.prototype.checkStatus=function(){var e=m.baseUrlServices+"/ims/check/v1/status";return K.get(e)},e.prototype.checkToken=function(e,t,o){var n=e.client_id,i=e.scope,s=r({},w.mergeExternalParameters(t,this.apiParameters,"check_token")),a=r(r({},s),{client_id:n,scope:i});return o&&(a.user_id=o),this.callCheckToken(v.uriEncodeData(a),n,"/check/v6/token?jslVersion="+m.jslibver)},e.prototype.switchProfile=function(e,t,o){void 0===o&&(o="");var n=e.client_id,i=e.scope,s=void 0===i?"":i,a=r({},w.mergeExternalParameters(t,this.apiParameters,"check_token")),c=v.uriEncodeData(r(r({},a),{client_id:n,scope:s,user_id:o}));return this.callCheckToken(c,n,"/check/v6/token?jslVersion="+m.jslibver)},e.prototype.listSocialProviders=function(e){var t=e.client_id,o=r({},w.getCustomApiParameters(this.apiParameters,"providers")),n=v.uriEncodeData(r({client_id:t},o)),i=m.baseUrlServices+"/ims/social/v2/providers?"+n+"&jslVersion="+m.jslibver,s=this.addClientIdInHeader(t);return K.get(i,s)},e.prototype.exchangeIjt=function(e,t){var o=e.client_id,n=r({},w.getCustomApiParameters(this.apiParameters,"ijt")),i=m.baseUrlServices+"/ims/jump/implicit/"+t,s=v.uriEncodeData(r({client_id:o},n)),a=i+"?"+s+"&jslVersion="+m.jslibver;a.length>2048&&(delete n.redirect_uri,a=i+"?"+(s=v.uriEncodeData(n)));var c=this.addClientIdInHeader(o);return K.get(a,c)},e.prototype.avatarUrl=function(e){return m.baseUrlAdobe+"/ims/avatar/download/"+e},e.prototype.getReleaseFlags=function(e){var t=e.token,o=e.client_id,n=r({},w.getCustomApiParameters(this.apiParameters,"fg_value")),i=this.createAuthorizationHeader(t);this.addClientIdInHeader(o,i);var s=v.uriEncodeData(r({client_id:o},n)),a=m.baseUrlAdobe+"/ims/fg/value/v1?"+s+"&jslVersion="+m.jslibver;return K.get(a,i)},e.prototype.getTransitoryAuthorizationCode=function(e,t,o){void 0===t&&(t={});var n=r({},w.mergeExternalParameters(t,this.apiParameters,"check_token")),i=v.uriEncodeData(r(r({},n),e));return this.callCheckToken(i,o,"/check/v6/token?client_id="+o+"&jslVersion="+m.jslibver)},e.prototype.getTokenFromCode=function(e,t){void 0===t&&(t={});var o=r({},w.mergeExternalParameters(t,this.apiParameters,"token"));o.grant_type="authorization_code",delete e.other;var n=m.baseUrlServices+"/ims/token/v3?jslVersion="+m.jslibver,i=v.uriEncodeData(r(r({},o),e)),s=this.formEncoded();return this.addClientIdInHeader(e.client_id,s),K.post(n,i,s)},e.prototype.jumpToken=function(e,t,o){void 0===t&&(t={});var n=r({},w.mergeExternalParameters(t,this.apiParameters,"jumptoken")),i=m.baseUrlServices+"/ims/jumptoken/v1?client_id="+o+"&jslVersion="+m.jslibver,s=v.uriEncodeData(r(r({},n),e)),a=this.formEncoded();return this.addClientIdInHeader(o,a),K.post(i,s,a)},e.prototype.jumpTokenToDevice=function(e,t,o){void 0===t&&(t={});var n=r({},w.mergeExternalParameters(t,this.apiParameters,"jumptoken_to_device")),i=m.baseUrlServices+"/ims/jumptoken/v2?client_id="+o+"&jslVersion="+m.jslibver,s=v.uriEncodeData(r(r({},n),e)),a=this.formEncoded();return this.addClientIdInHeader(o,a),K.post(i,s,a)},e.prototype.socialHeadlessSignIn=function(e,t){void 0===t&&(t={});var o=r({},w.mergeExternalParameters(t,this.apiParameters,"jumptoken")),n=m.baseUrlServices+"/ims/social/v2/native?jslVersion="+m.jslibver,i=v.uriEncodeData(r(r(r({},o),e),{response_type:"implicit_jump"}));return K.post(n,i,this.formEncoded())},e.prototype.createAuthorizationHeader=function(e){var t={};return e&&(t[d]="Bearer "+e),t},e.prototype.formEncoded=function(e){return void 0===e&&(e={}),e["content-type"]=this.CONTENT_FORM_ENCODED,e},e.prototype.addClientIdInHeader=function(e,t){return void 0===t&&(t={}),t.client_id=e,t},e.prototype.callCheckToken=function(e,t,r){var o=this.formEncoded();return this.addClientIdInHeader(t,o),K.post(m.checkTokenEndpoint.url+"/ims"+r,e,o).catch((function(t){if(!m.checkTokenEndpoint.shouldFallbackToAdobe(t))throw t;return K.post(m.checkTokenEndpoint.fallbackUrl+"/ims"+r,e,o)}))},e}();!function(e){e.INITIALIZE_ERROR="initialize_error",e.HTTP="http",e.FRAGMENT="fragment",e.CSRF="csrf",e.NOT_ALLOWED="not_allowed",e.PROFILE_EXCEPTION="profile_exception",e.TOKEN_EXPIRED="token_expired",e.SOCIAL_PROVIDERS="SOCIAL_PROVIDERS",e.RIDE_EXCEPTION="ride_exception"}(N||(N={}));var W=function(e){this.message=null,this.errorType=N.PROFILE_EXCEPTION,this.message=e},Y=/\s|,/g;function X(e){return e.split(Y).sort().join(",")}var Z,Q=function(){function e(e){this.profileServiceRequest=e,this.storage=h.getStorageByName(c.SessionStorage)}return e.prototype.getProfile=function(e){var t=this,r=this.profileServiceRequest,o=r.clientId,n=r.imsApis,i=this.getProfileFromStorage();return i?Promise.resolve(i):n.getProfile({client_id:o,token:e}).then((function(e){if(!e)throw new W("NO profile response");if(0===Object.keys(e).length)throw new W("NO profile value");return t.saveProfileToStorage(e),Promise.resolve(e)})).catch((function(e){return e instanceof q?Promise.reject(e):(t.removeProfile(),Promise.reject(e))}))},e.prototype.getProfileStorageKey=function(){var e=this.profileServiceRequest;return"adobeid_ims_profile/"+e.clientId+"/"+!1+"/"+X(e.scope)},e.prototype.getProfileFromStorage=function(){var e=this.getProfileStorageKey(),t=this.storage.getItem(e);return t&&JSON.parse(t)},e.prototype.saveProfileToStorage=function(e){var t=this.getProfileStorageKey();this.storage.setItem(t,JSON.stringify(e))},e.prototype.removeProfile=function(){var e=this.getProfileStorageKey();this.storage.removeItem(e)},e.prototype.removeProfileIfOtherUser=function(e){if(e){var t=this.getProfileFromStorage();t&&t.userId!==e&&this.removeProfile()}},e}();!function(e){e.GUEST="guest"}(Z||(Z={}));var $,ee=function(){function e(e,t){var r=this;this.REAUTH_SCOPE="reauthenticated",this.valid=!1,this.isReauth=function(){return r.scope.indexOf(r.REAUTH_SCOPE)>=0},this.client_id="",this.scope="",this.expire=new Date,this.user_id="",this.tokenValue="",this.sid="",this.state=null,this.fromFragment=!1,this.impersonatorId="",this.isImpersonatedSession=!1;var o=e.valid,n=e.tokenValue,i=e.access_token,s=e.state,a=e.other,c=n||i,u=this.parseJwt(c);if(!u)throw new Error("token cannot be decoded "+c);this.state=w.toJson(s);var l=u.client_id,d=u.user_id,p=u.scope,h=u.sid,f=u.imp_id,v=u.imp_sid,g=u.pba,m=u.atp,y=u.gse;this.atp=m,this.client_id=l,this.expire=t,this.user_id=d,this.scope=p,this.valid=o,this.tokenValue=c,this.sid=h,this.other=a,this.impersonatorId=f||"",this.isImpersonatedSession=!!v,this.pbaSatisfiedPolicies=g&&g.split(",")||[],this.isGuestToken=this.atp===Z.GUEST,this.gse=y}return e.prototype.parseJwt=function(e){if(!e)return null;try{return JSON.parse(atob(e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")))}catch(t){return p.error("error on decoding token ",e,t),null}},e.prototype.validate=function(e,t){var r,o,n,i=this.valid,s=this.client_id,a=this.scope,c=this.expire;return c0&&(r=new Array(o+1).join(e)+r),r}("0",5,e.toString(2))},le=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("Data is not a string");var r=e.toLowerCase().split("");!function(e){if(e.length%8!=0)throw new Error("Data length is not a multiple of 8");e.forEach((function(e){if(!(e in ce))throw new Error("Unknown encoded character "+e)}));var t=!1;e.forEach((function(e){if("="!==e&&t)throw new Error("Found padding char in the middle of the string");"="===e&&(t=!0)}))}(r);var o=function(e){for(var t=e.length-1,r=0;"="===e[t];)++r,--t;return r}(r),n=[];r.forEach((function(e){n.push(ue(ce[e]))}));var i=n.join("");return o>0&&(i=i.slice(0,-5*o)),i.length%8!=0&&(i=i.slice(0,i.length%8*-1)),t?function(e){var t="";if(e.length%8!=0)throw new Error("Length must be a multiple of 8");for(var r=0,o=e.length;rfe.lastUserInteraction&&(fe.lastUserInteraction=n)}return o.tokenService.refreshToken(e).then((function(e){return o.onTokenProfileReceived(e)})).catch((function(e){if(p.error("refresh token error",e),e instanceof q)return Promise.reject(e);var t=o.verifyRideErrorExceptionStrict(e);return t||(o.profileService.removeProfile(),o.onTokenExpired(),Promise.reject(e))}))},this.switchProfile=function(e,t){return void 0===t&&(t={}),e?o.tokenService.switchProfile(e,t).then((function(e){return o.onTokenProfileReceived(e)})).catch((function(e){return o.verifyRideErrorException(e)})):Promise.reject(new Error("Please provide the user id for switchProfile"))},this.executeErrorCallback=function(e){if(p.info("initialize exception ended",e),!e||e.type!==$.LOGOUT){var t=o.adobeIdData.onError;t&&t(N.HTTP,"Initialization error")}},this.triggerOnImsInstance=function(e){var t=document.createEvent("CustomEvent"),r={clientId:o.adobeIdData.client_id,instance:e};t.initCustomEvent("onImsLibInstance",!1,!1,r),window.dispatchEvent(t)},this.processInitializeException=function(e){return void 0===e&&(e={}),p.warn("initialize",e),o.restoreHash(),Promise.reject(e)},this.verifyModalSignInEvent=function(e){return e instanceof ae?o.notifyParentAboutModalSignIn(e):Promise.reject(e)},this.verifyTokenExpiredException=function(e){return e instanceof ie?(o.adobeIdData.handlers.triggerOnAccessTokenHasExpired(),Promise.resolve()):Promise.reject(e)},this.verifyRideErrorException=function(e){return n(o,void 0,Promise,(function(){return i(this,(function(t){switch(t.label){case 0:return e instanceof G?this.adobeIdData.overrideErrorHandler&&!this.adobeIdData.overrideErrorHandler(e)?[2,Promise.reject(e)]:e.isPbaExpiredIdleSessionWorkaround?[4,this.signIn()]:[3,2]:[3,4];case 1:return t.sent(),[3,4];case 2:return e.jump?[4,v.replaceUrlAndWait(e.jump,1e4)]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2,Promise.reject(e)]}}))}))},this.verifyRideErrorExceptionStrict=function(e){return e instanceof G?o.verifyRideErrorException(e):null},this.verifyCsrfException=function(e){var t=e.type;return t&&t===N.CSRF&&o.signOut(),Promise.reject(e)},this.processTokenResponse=function(e){var t=o.adobeIdData.handlers,r=e.tokenFields,n=e.profile,i=r.tokenValue,s=r.state,a=r.expire,c=r.sid,u=r.user_id,l=r.other,d=void 0===l?{}:l,h=r.impersonatorId,f=r.isImpersonatedSession,g=r.pbaSatisfiedPolicies,m=r.isGuestToken,y=r.gse;p.info("token",i),d.from_ims&&v.setHash(d.old_hash||""),o.profileService.removeProfileIfOtherUser(u);var k={token:i,expire:a,sid:c,impersonatorId:h,isImpersonatedSession:f,pbaSatisfiedPolicies:g,isGuestToken:m,gse:y};return r.isReauth()?t.triggerOnReauthAccessToken(k):o.tokenReceived(k),n&&o.profileService.saveProfileToStorage(n),Promise.resolve(s)},this.exchangeIjt=function(e){var t=o.adobeIdData.ijt;return e||t?o.tokenService.exchangeIjt(e||t).then((function(e){return e.profile?o.profileService.saveProfileToStorage(e.profile):o.profileService.removeProfile(),Promise.resolve(e)})):Promise.reject(new Error("please set the adobeid.ijt value"))},this.adobeIdData=new L(e),t&&(this.instanceKey=t);var s=this.adobeIdData,a=s.api_parameters,c=void 0===a?{}:a,u=s.client_id,l=s.scope,d=s.useLocalStorage,h=s.autoValidateToken,g=s.modalMode,m=s.modalSettings;this.imsApis=new B(c),this.csrfService=new f(u,this.instanceKey),this.serviceRequest={clientId:u,scope:l,imsApis:this.imsApis},this.tokenService=new pe(r(r({},this.serviceRequest),{useLocalStorage:d,autoValidateToken:h}),this.csrfService),this.profileService=new Q(this.serviceRequest),this.signInservice=g?new R(this.onPopupMessage,m):new T}return Object.defineProperty(e.prototype,"version",{get:function(){return m.jslibver},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"adobeid",{get:function(){return r({},this.adobeIdData)},enumerable:!0,configurable:!0}),e.prototype.enableLogging=function(){p.enableLogging()},e.prototype.disableLogging=function(){p.disableLogging()},e.prototype.checkInitialized=function(){this.initialized},e.prototype.signUp=function(e,t){var r=this;void 0===e&&(e={}),this.checkInitialized();var o=this.adobeIdData,n=this.csrfService;if(!o)throw new Error("no adobeId on reAuthenticate");var i=n.initialize();return o.createSignUpRedirectRequest(e,t,i).then((function(e){r.signInservice.signIn(e)}))},e.prototype.isSignedInUser=function(){var e=this.getAccessToken();return(!e||!e.isGuestToken)&&!(!e&&!this.getReauthAccessToken())},e.prototype.getProfile=function(){var e=this,t=this.profileService.getProfileFromStorage();if(t)return Promise.resolve(t);var r=this.getAccessToken()||this.getReauthAccessToken();if(!r){var o="please login before getting the profile";return Promise.reject(new W(o))}if(r.isGuestToken){o="guest account does not have a profile";return Promise.reject(new W(o))}return this.profileService.getProfile(r.token).then((function(e){return Promise.resolve(e)})).catch((function(t){return p.error("get profile exception ",t),t instanceof q?e.refreshToken().then((function(e){return Promise.resolve(e.profile)})):Promise.reject(new W(t.message||t))}))},e.prototype.avatarUrl=function(e){return this.imsApis.avatarUrl(e)},e.prototype.getReleaseFlags=function(e){return void 0===e&&(e=!1),e?this.tokenService.getDecodedReleaseFlags():this.tokenService.getReleaseFlags()},e.prototype.getAccessToken=function(){return this.getTokenFromStorage(!1)},e.prototype.getReauthAccessToken=function(){return this.getTokenFromStorage(!0)},e.prototype.getTokenFromStorage=function(e){var t=this.tokenService.getTokenFieldsFromStorage(e);return t?{token:t.tokenValue,expire:t.expire,sid:t.sid,impersonatorId:t.impersonatorId,isImpersonatedSession:t.isImpersonatedSession,pbaSatisfiedPolicies:t.pbaSatisfiedPolicies,isGuestToken:t.isGuestToken,gse:t.gse}:null},e.prototype.listSocialProviders=function(){var e=this;return new Promise((function(t,r){var o=e.adobeIdData.client_id;e.imsApis.listSocialProviders({client_id:o}).then((function(e){t(e)})).catch((function(e){r(e)}))}))},e.prototype.tokenReceived=function(e){this.adobeIdData.handlers.triggerOnAccessToken(e),fe.startAutoRefreshFlow({expire:e.expire,refreshTokenMethod:this.refreshToken})},e.prototype.onTokenProfileReceived=function(e){var t=e.tokenInfo,r=e.profile;return p.info("token",t),this.tokenReceived(t),this.profileService.saveProfileToStorage(r),Promise.resolve(e)},e.prototype.validateToken=function(){var e=this;return this.tokenService.validateToken().then((function(){return Promise.resolve(!0)})).catch((function(t){return p.warn("validate token exception",t),t instanceof q?Promise.reject(!1):(e.profileService.removeProfile(),Promise.reject(!1))}))},e.prototype.onTokenExpired=function(){var e=this.adobeIdData.handlers;this.tokenService.purge(),e.triggerOnAccessTokenHasExpired()},e.prototype.setStandAloneToken=function(e){return this.tokenService.setStandAloneToken(e)},e.prototype.initialize=function(){var e,t=this,r=this.adobeIdData,o=r.handlers,n=r.standalone,i=r.ijt,s=r.alwaysRemoveTokenFromUrl,a=r.enableGuestAccounts,c=r.enableGuestTokenForceRefresh,u=null;switch(n&&this.setStandAloneToken(n),!0){case!!i:e=this.exchangeIjt;break;case a:e=this.tokenService.getGuestToken.bind(this.tokenService,{},{enableGuestAccounts:a,enableGuestTokenForceRefresh:c});break;default:e=this.tokenService.getTokenAndProfile}return e().then(this.processTokenResponse,this.processError.apply(this)).then((function(e){u=e})).finally((function(){p.info("onReady initialization"),window.addEventListener("getImsLibInstance",(function(){t.triggerOnImsInstance(t)}),!1),s&&v.setHash(te.removeAccessToken()),o.triggerOnReady(u?u.context:null),t.triggerOnImsInstance(t),t.initialized=!0}))},e.prototype.processError=function(){var e=this;return function(t){return e.verifyModalSignInEvent(t).catch(e.processInitializeException).catch(e.verifyTokenExpiredException).catch(e.verifyRideErrorException).catch(e.verifyCsrfException).catch(e.executeErrorCallback)}},e.prototype.notifyParentAboutModalSignIn=function(e){var t=window.location.href.replace("imslibmodal","wasmodal");if(window.opener)window.opener.postMessage(t,window.location.origin),window.close();else{var r=new BroadcastChannel("imslib");r.postMessage(t),r.close(),window.close()}return Promise.reject("popup")},e.prototype.restoreHash=function(){var e=te.fragmentToObject();e&&e.from_ims&&v.setHash(e.old_hash||"")},e.prototype.getTransitoryAuthorizationCode=function(e,t){return void 0===t&&(t={}),(e=e||{}).response_type=e.response_type||"code",e.target_client_id=e.target_client_id||this.adobeIdData.client_id,e.target_scope=e.target_scope||this.adobeIdData.scope,this.imsApis.getTransitoryAuthorizationCode(e,t,this.adobeIdData.client_id)},e.prototype.jumpToken=function(e,t){return void 0===t&&(t={}),e.target_client_id=e.target_client_id||this.adobeIdData.client_id,e.target_scope=e.target_scope||this.adobeIdData.scope,this.imsApis.jumpToken(e,t,this.adobeIdData.client_id)},e.prototype.getVerifierByKey=function(e){return(new H).getVerifierByKey(e)},e.prototype.socialHeadlessSignIn=function(e,t){return void 0===t&&(t={}),n(this,void 0,Promise,(function(){var r=this;return i(this,(function(o){return[2,this.imsApis.socialHeadlessSignIn(e,t).then((function(e){return r.exchangeIjt(e.token)})).catch((function(t){return"ride_AdobeID_social"===t.error&&r.signIn({idp_flow:"social.native",provider_id:e.provider_id,idp_token:e.idp_token}),Promise.reject(t)}))]}))}))},e.prototype.getAccountType=function(){var e=this.getAccessToken();if(!e)throw new Error("please login before getting the account type");if(e.isGuestToken)return oe.GUEST;var t=this.profileService.getProfileFromStorage();if(!t)throw new Error("you need to first get the profile before getting the account type");return t.account_type},e.prototype.getSessionExpiration=function(){var e=this.getAccessToken();if(!e)throw new Error("please obtain a token before getting the session expiration");return e.gse},e.prototype.jumpTokenToDevice=function(e,t){return void 0===t&&(t={}),this.imsApis.jumpTokenToDevice(e,t,this.adobeIdData.client_id)},e}(),ge=new(function(){function e(){this.createIMSLib=function(e,t){void 0===e&&(e=null),void 0===t&&(t="adobeIMS");var r=new ve(e,t);return window[t]=r,r}}return e.prototype.initAdobeIms=function(){window.adobeImsFactory={createIMSLib:this.createIMSLib};var e=window.adobeIMS||null;if(!e){var t=window.adobeid;if(!t||!t.client_id)return;(e=this.createIMSLib(t,"adobeIMS")).initialize()}},e}());return new(function(){function e(){ge.initAdobeIms()}return e.prototype.initialize=function(){return!0},e}())}(); From e9fa6999fba638b4ff1847a063655a5687d6d88a Mon Sep 17 00:00:00 2001 From: Okan Sahin <39759830+mokimo@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:46:43 +0200 Subject: [PATCH 6/8] MWPW-155412: Fix video CLS netting +10 lighthouse points (#2724) * fix cls by adding the videoEl without a source * adapt the video hover and in view port play * Remove no-lazy and return earlier * Fix linting issue * Consolidate duplicated logic * Move functions into the init function * Move root margin and use optional chaining * Only query for the videoEl once --- libs/blocks/adobetv/adobetv.js | 35 +++++------------- libs/blocks/video/video.js | 41 ++++++--------------- libs/utils/decorate.js | 24 +++++++++++-- test/blocks/adobetv/adobetv.test.js | 11 ------ test/blocks/adobetv/mocks/body.html | 2 +- test/blocks/marquee/marquee.test.js | 21 ++++++++--- test/blocks/video/mocks/body.html | 2 +- test/blocks/video/video.test.js | 56 +++++++++++------------------ 8 files changed, 80 insertions(+), 112 deletions(-) diff --git a/libs/blocks/adobetv/adobetv.js b/libs/blocks/adobetv/adobetv.js index 31cfc7a368..5a13b37cfd 100644 --- a/libs/blocks/adobetv/adobetv.js +++ b/libs/blocks/adobetv/adobetv.js @@ -1,22 +1,16 @@ -import { createIntersectionObserver } from '../../utils/utils.js'; -import { applyHoverPlay, getVideoAttrs } from '../../utils/decorate.js'; +import { turnAnchorIntoVideo } from '../../utils/decorate.js'; -const ROOT_MARGIN = 1000; - -const loadAdobeTv = (a) => { +export default function init(a) { + a.classList.add('hide-video'); const bgBlocks = ['aside', 'marquee', 'hero-marquee']; if (a.href.includes('.mp4') && bgBlocks.some((b) => a.closest(`.${b}`))) { a.classList.add('hide'); - const { href, hash, dataset } = a; - const attrs = getVideoAttrs(hash || 'autoplay', dataset); - const video = ``; if (!a.parentNode) return; - a.insertAdjacentHTML('afterend', video); - const videoElem = document.body.querySelector(`source[src="${href}"]`)?.parentElement; - applyHoverPlay(videoElem); - a.remove(); + turnAnchorIntoVideo({ + hash: a.hash || 'autoplay', + src: a.href, + anchorTag: a, + }); } else { const embed = `