From e3844f27833b24328387a357b40100b38223daa7 Mon Sep 17 00:00:00 2001 From: Dev Ashish Saradhana <41122199+Deva309@users.noreply.github.com> Date: Thu, 19 Sep 2024 06:18:32 +0530 Subject: [PATCH 01/13] [MWPW-157924] - Added functionality to disable Active Element Detection (#2892) Added functionality to disable Active Element Detection --- libs/blocks/global-navigation/global-navigation.js | 11 +++++++++-- .../global-navigation/utilities/utilities.js | 14 ++++++++++++-- .../global-navigation/global-navigation.test.js | 9 +++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/libs/blocks/global-navigation/global-navigation.js b/libs/blocks/global-navigation/global-navigation.js index bd21c226ae..f4c602bf86 100644 --- a/libs/blocks/global-navigation/global-navigation.js +++ b/libs/blocks/global-navigation/global-navigation.js @@ -36,6 +36,8 @@ import { addMepHighlightAndTargetId, isDarkMode, darkIcons, + setDisableAEDState, + getDisableAEDState, } from './utilities/utilities.js'; import { replaceKey, replaceKeyArray } from '../../features/placeholders.js'; @@ -837,8 +839,9 @@ class Gnav { if (!hasActiveLink()) { const sections = this.elements.mainNav.querySelectorAll('.feds-navItem--section'); + const disableAED = getDisableAEDState(); - if (sections.length === 1) { + if (!disableAED && sections.length === 1) { sections[0].classList.add(selectors.activeNavItem.slice(1)); setActiveLink(true); } @@ -1024,7 +1027,11 @@ const getSource = async () => { export default async function init(block) { try { const { mep } = getConfig(); - const url = await getSource(); + const sourceUrl = await getSource(); + const [url, hash = ''] = sourceUrl.split('#'); + if (hash === '_noActiveItem') { + setDisableAEDState(); + } const content = await fetchAndProcessPlainHtml({ url }); if (!content) return null; const gnav = new Gnav({ diff --git a/libs/blocks/global-navigation/utilities/utilities.js b/libs/blocks/global-navigation/utilities/utilities.js index 3c1e9b7ee6..5a663dd70c 100644 --- a/libs/blocks/global-navigation/utilities/utilities.js +++ b/libs/blocks/global-navigation/utilities/utilities.js @@ -133,7 +133,7 @@ export function getAnalyticsValue(str, index) { export function getExperienceName() { const experiencePath = getMetadata('gnav-source'); - const explicitExperience = experiencePath?.split('/').pop(); + const explicitExperience = experiencePath?.split('#')[0]?.split('/').pop(); if (explicitExperience?.length && explicitExperience !== 'gnav') return explicitExperience; @@ -257,6 +257,15 @@ export function setActiveDropdown(elem) { }); } +// Disable AED(Active Element Detection) +export const [setDisableAEDState, getDisableAEDState] = (() => { + let disableAED = false; + return [ + () => { disableAED = true; }, + () => disableAED, + ]; +})(); + export const [hasActiveLink, setActiveLink, getActiveLink] = (() => { let activeLinkFound; @@ -264,7 +273,8 @@ export const [hasActiveLink, setActiveLink, getActiveLink] = (() => { () => activeLinkFound, (val) => { activeLinkFound = !!val; }, (area) => { - if (hasActiveLink() || !(area instanceof HTMLElement)) return null; + const disableAED = getDisableAEDState(); + if (disableAED || hasActiveLink() || !(area instanceof HTMLElement)) return null; const { origin, pathname } = window.location; const url = `${origin}${pathname}`; const activeLink = [ diff --git a/test/blocks/global-navigation/global-navigation.test.js b/test/blocks/global-navigation/global-navigation.test.js index b260ee3f21..bcc2e4b675 100644 --- a/test/blocks/global-navigation/global-navigation.test.js +++ b/test/blocks/global-navigation/global-navigation.test.js @@ -557,6 +557,15 @@ describe('global navigation', () => { fetchStub.calledOnceWith('http://localhost:2000/gnav.plain.html'), ).to.be.true; }); + + it('disable AED(Active Element Detetction) if gnav-souce used with hash "#_noActiveItem" modifier', async () => { + const gnavMeta = toFragment``; + document.head.append(gnavMeta); + document.body.replaceChildren(toFragment``); + await initGnav(document.body.querySelector('header')); + const isActiveElement = !!document.querySelector('.global-navigation .feds-navItem--active'); + expect(isActiveElement).to.be.false; + }); }); describe('Dynamic nav', () => { From c80cf18bd5d74883ecfcf6c2cd3789cad92c25ec Mon Sep 17 00:00:00 2001 From: Mariia Lukianets Date: Thu, 19 Sep 2024 02:48:38 +0200 Subject: [PATCH 02/13] MWPW-158464: Switch Odin endpoint (#2894) * init plans cards doc * switch to QA bucket * add plans html * add test payload * upd path * card * test hlxignore * test * remove test files * remove edge payload * add marquee * add spacing --- .hlxignore | 1 + libs/deps/mas/mas.js | 8 +- libs/deps/mas/merch-datasource.js | 2 +- libs/features/mas/docs/plans.html | 64 +++ libs/features/mas/mocks/aem.js | 4 +- .../cf/fragments/search/authorPayload.json | 537 ++++++++++++++++++ .../sites/cf/fragments/search/default.json | 356 ------------ .../web-components/src/merch-datasource.js | 15 +- .../test/merch-datasource.test.html.js | 3 +- 9 files changed, 620 insertions(+), 370 deletions(-) create mode 100644 libs/features/mas/docs/plans.html create mode 100644 libs/features/mas/mocks/sites/cf/fragments/search/authorPayload.json delete mode 100644 libs/features/mas/mocks/sites/cf/fragments/search/default.json diff --git a/.hlxignore b/.hlxignore index 0fdf90bee2..213dabe3a5 100644 --- a/.hlxignore +++ b/.hlxignore @@ -9,3 +9,4 @@ LICENSE web-test-runner.config.mjs codecov.yaml libs/features/mas/* +!libs/features/mas/docs diff --git a/libs/deps/mas/mas.js b/libs/deps/mas/mas.js index 4e5c80f3a9..cdd84a9c58 100644 --- a/libs/deps/mas/mas.js +++ b/libs/deps/mas/mas.js @@ -1,10 +1,10 @@ -var bo=Object.defineProperty;var _o=e=>{throw TypeError(e)};var Ms=(e,t,r)=>t in e?bo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Us=(e,t)=>{for(var r in t)bo(e,r,{get:t[r],enumerable:!0})};var O=(e,t,r)=>Ms(e,typeof t!="symbol"?t+"":t,r),wo=(e,t,r)=>t.has(e)||_o("Cannot "+r);var R=(e,t,r)=>(wo(e,t,"read from private field"),r?r.call(e):t.get(e)),Q=(e,t,r)=>t.has(e)?_o("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),K=(e,t,r,n)=>(wo(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var lt;(function(e){e.STAGE="STAGE",e.PRODUCTION="PRODUCTION",e.LOCAL="LOCAL"})(lt||(lt={}));var Mr;(function(e){e.STAGE="STAGE",e.PRODUCTION="PROD",e.LOCAL="LOCAL"})(Mr||(Mr={}));var ht;(function(e){e.DRAFT="DRAFT",e.PUBLISHED="PUBLISHED"})(ht||(ht={}));var Ae;(function(e){e.V2="UCv2",e.V3="UCv3"})(Ae||(Ae={}));var Y;(function(e){e.CHECKOUT="checkout",e.CHECKOUT_EMAIL="checkout/email",e.SEGMENTATION="segmentation",e.BUNDLE="bundle",e.COMMITMENT="commitment",e.RECOMMENDATION="recommendation",e.EMAIL="email",e.PAYMENT="payment",e.CHANGE_PLAN_TEAM_PLANS="change-plan/team-upgrade/plans",e.CHANGE_PLAN_TEAM_PAYMENT="change-plan/team-upgrade/payment"})(Y||(Y={}));var Ur=function(e){var t;return(t=Ds.get(e))!==null&&t!==void 0?t:e},Ds=new Map([["countrySpecific","cs"],["quantity","q"],["authCode","code"],["checkoutPromoCode","apc"],["rurl","rUrl"],["curl","cUrl"],["ctxrturl","ctxRtUrl"],["country","co"],["language","lang"],["clientId","cli"],["context","ctx"],["productArrangementCode","pa"],["offerType","ot"],["marketSegment","ms"]]);var Ao=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},So=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(c){s={error:c}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i};function je(e,t,r){var n,o;try{for(var i=Ao(Object.entries(e)),s=i.next();!s.done;s=i.next()){var c=So(s.value,2),a=c[0],h=c[1],l=Ur(a);h!=null&&r.has(l)&&t.set(l,h)}}catch(d){n={error:d}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}}function Ft(e){switch(e){case lt.PRODUCTION:return"https://commerce.adobe.com";default:return"https://commerce-stg.adobe.com"}}function Ht(e,t){var r,n;for(var o in e){var i=e[o];try{for(var s=(r=void 0,Ao(Object.entries(i))),c=s.next();!c.done;c=s.next()){var a=So(c.value,2),h=a[0],l=a[1];if(l!=null){var d=Ur(h);t.set("items["+o+"]["+d+"]",l)}}}catch(u){r={error:u}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}}}var Fs=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function To(e){Vs(e);var t=e.env,r=e.items,n=e.workflowStep,o=Fs(e,["env","items","workflowStep"]),i=new URL(Ft(t));return i.pathname=n+"/",Ht(r,i.searchParams),je(o,i.searchParams,zs),i.toString()}var zs=new Set(["cli","co","lang","ctx","cUrl","mv","nglwfdata","otac","promoid","rUrl","sdid","spint","trackingid","code","campaignid","appctxid"]),Gs=["env","workflowStep","clientId","country","items"];function Vs(e){var t,r;try{for(var n=Hs(Gs),o=n.next();!o.done;o=n.next()){var i=o.value;if(!e[i])throw new Error('Argument "checkoutData" is not valid, missing: '+i)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!0}var js=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ws="p_draft_landscape",qs="/store/";function Fr(e){Xs(e);var t=e.env,r=e.items,n=e.workflowStep,o=e.ms,i=e.marketSegment,s=e.ot,c=e.offerType,a=e.pa,h=e.productArrangementCode,l=e.landscape,d=js(e,["env","items","workflowStep","ms","marketSegment","ot","offerType","pa","productArrangementCode","landscape"]),u={marketSegment:i??o,offerType:c??s,productArrangementCode:h??a},m=new URL(Ft(t));return m.pathname=""+qs+n,n!==Y.SEGMENTATION&&n!==Y.CHANGE_PLAN_TEAM_PLANS&&Ht(r,m.searchParams),n===Y.SEGMENTATION&&je(u,m.searchParams,Dr),je(d,m.searchParams,Dr),l===ht.DRAFT&&je({af:Ws},m.searchParams,Dr),m.toString()}var Dr=new Set(["af","ai","apc","appctxid","cli","co","csm","ctx","ctxRtUrl","DCWATC","dp","fr","gsp","ijt","lang","lo","mal","ms","mv","mv2","nglwfdata","ot","otac","pa","pcid","promoid","q","rf","sc","scl","sdid","sid","spint","svar","th","thm","trackingid","usid","workflowid","context.guid","so.ca","so.su","so.tr","so.va"]),Ys=["env","workflowStep","clientId","country"];function Xs(e){var t,r;try{for(var n=Bs(Ys),o=n.next();!o.done;o=n.next()){var i=o.value;if(!e[i])throw new Error('Argument "checkoutData" is not valid, missing: '+i)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}if(e.workflowStep!==Y.SEGMENTATION&&e.workflowStep!==Y.CHANGE_PLAN_TEAM_PLANS&&!e.items)throw new Error('Argument "checkoutData" is not valid, missing: items');return!0}function Hr(e,t){switch(e){case Ae.V2:return To(t);case Ae.V3:return Fr(t);default:return console.warn("Unsupported CheckoutType, will use UCv3 as default. Given type: "+e),Fr(t)}}var zr;(function(e){e.BASE="BASE",e.TRIAL="TRIAL",e.PROMOTION="PROMOTION"})(zr||(zr={}));var k;(function(e){e.MONTH="MONTH",e.YEAR="YEAR",e.TWO_YEARS="TWO_YEARS",e.THREE_YEARS="THREE_YEARS",e.PERPETUAL="PERPETUAL",e.TERM_LICENSE="TERM_LICENSE",e.ACCESS_PASS="ACCESS_PASS",e.THREE_MONTHS="THREE_MONTHS",e.SIX_MONTHS="SIX_MONTHS"})(k||(k={}));var L;(function(e){e.ANNUAL="ANNUAL",e.MONTHLY="MONTHLY",e.TWO_YEARS="TWO_YEARS",e.THREE_YEARS="THREE_YEARS",e.P1D="P1D",e.P1Y="P1Y",e.P3Y="P3Y",e.P10Y="P10Y",e.P15Y="P15Y",e.P3D="P3D",e.P7D="P7D",e.P30D="P30D",e.HALF_YEARLY="HALF_YEARLY",e.QUARTERLY="QUARTERLY"})(L||(L={}));var Gr;(function(e){e.INDIVIDUAL="INDIVIDUAL",e.TEAM="TEAM",e.ENTERPRISE="ENTERPRISE"})(Gr||(Gr={}));var Vr;(function(e){e.COM="COM",e.EDU="EDU",e.GOV="GOV"})(Vr||(Vr={}));var jr;(function(e){e.DIRECT="DIRECT",e.INDIRECT="INDIRECT"})(jr||(jr={}));var Br;(function(e){e.ENTERPRISE_PRODUCT="ENTERPRISE_PRODUCT",e.ETLA="ETLA",e.RETAIL="RETAIL",e.VIP="VIP",e.VIPMP="VIPMP",e.FREE="FREE"})(Br||(Br={}));var Po="tacocat.js";var zt=(e,t)=>String(e??"").toLowerCase()==String(t??"").toLowerCase(),Co=e=>`${e??""}`.replace(/[&<>'"]/g,t=>({"&":"&","<":"<",">":">","'":"'",'"':"""})[t]??t)??"";function N(e,t={},{metadata:r=!0,search:n=!0,storage:o=!0}={}){let i;if(n&&i==null){let s=new URLSearchParams(window.location.search),c=Be(n)?n:e;i=s.get(c)}if(o&&i==null){let s=Be(o)?o:e;i=window.sessionStorage.getItem(s)??window.localStorage.getItem(s)}if(r&&i==null){let s=Zs(Be(r)?r:e);i=document.documentElement.querySelector(`meta[name="${s}"]`)?.content}return i??t[e]}var We=()=>{};var $o=e=>typeof e=="boolean",me=e=>typeof e=="function",Gt=e=>typeof e=="number",Oo=e=>e!=null&&typeof e=="object";var Be=e=>typeof e=="string",Wr=e=>Be(e)&&e,qe=e=>Gt(e)&&Number.isFinite(e)&&e>0;function Ye(e,t=r=>r==null||r===""){return e!=null&&Object.entries(e).forEach(([r,n])=>{t(n)&&delete e[r]}),e}function w(e,t){if($o(e))return e;let r=String(e);return r==="1"||r==="true"?!0:r==="0"||r==="false"?!1:t}function pe(e,t,r){let n=Object.values(t);return n.find(o=>zt(o,e))??r??n[0]}function Zs(e=""){return String(e).replace(/(\p{Lowercase_Letter})(\p{Uppercase_Letter})/gu,(t,r,n)=>`${r}-${n}`).replace(/\W+/gu,"-").toLowerCase()}function Xe(e,t=1){return Gt(e)||(e=Number.parseInt(e,10)),!Number.isNaN(e)&&e>0&&Number.isFinite(e)?e:t}var Js=Date.now(),qr=()=>`(+${Date.now()-Js}ms)`,Vt=new Set,Qs=w(N("tacocat.debug",{},{metadata:!1}),typeof process<"u"&&process.env?.DEBUG);function Lo(e){let t=`[${Po}/${e}]`,r=(s,c,...a)=>s?!0:(o(c,...a),!1),n=Qs?(s,...c)=>{console.debug(`${t} ${s}`,...c,qr())}:()=>{},o=(s,...c)=>{let a=`${t} ${s}`;Vt.forEach(([h])=>h(a,...c))};return{assert:r,debug:n,error:o,warn:(s,...c)=>{let a=`${t} ${s}`;Vt.forEach(([,h])=>h(a,...c))}}}function Ks(e,t){let r=[e,t];return Vt.add(r),()=>{Vt.delete(r)}}Ks((e,...t)=>{console.error(e,...t,qr())},(e,...t)=>{console.warn(e,...t,qr())});var ea="no promo",No="promo-tag",ta="yellow",ra="neutral",na=(e,t,r)=>{let n=i=>i||ea,o=r?` (was "${n(t)}")`:"";return`${n(e)}${o}`},oa="cancel-context",dt=(e,t)=>{let r=e===oa,n=!r&&e?.length>0,o=(n||r)&&(t&&t!=e||!t&&!r),i=o&&n||!o&&!!t,s=i?e||t:void 0;return{effectivePromoCode:s,overridenPromoCode:e,className:i?No:`${No} no-promo`,text:na(s,t,o),variant:i?ta:ra,isOverriden:o}};var Yr="ABM",Xr="PUF",Zr="M2M",Jr="PERPETUAL",Qr="P3Y",ia="TAX_INCLUSIVE_DETAILS",sa="TAX_EXCLUSIVE",Ro={ABM:Yr,PUF:Xr,M2M:Zr,PERPETUAL:Jr,P3Y:Qr},Ol={[Yr]:{commitment:k.YEAR,term:L.MONTHLY},[Xr]:{commitment:k.YEAR,term:L.ANNUAL},[Zr]:{commitment:k.MONTH,term:L.MONTHLY},[Jr]:{commitment:k.PERPETUAL,term:void 0},[Qr]:{commitment:k.THREE_MONTHS,term:L.P3Y}},Io="Value is not an offer",Kr=e=>{if(typeof e!="object")return Io;let{commitment:t,term:r}=e,n=aa(t,r);return{...e,planType:n}};var aa=(e,t)=>{switch(e){case void 0:return Io;case"":return"";case k.YEAR:return t===L.MONTHLY?Yr:t===L.ANNUAL?Xr:"";case k.MONTH:return t===L.MONTHLY?Zr:"";case k.PERPETUAL:return Jr;case k.TERM_LICENSE:return t===L.P3Y?Qr:"";default:return""}};function en(e){let{priceDetails:t}=e,{price:r,priceWithoutDiscount:n,priceWithoutTax:o,priceWithoutDiscountAndTax:i,taxDisplay:s}=t;if(s!==ia)return e;let c={...e,priceDetails:{...t,price:o??r,priceWithoutDiscount:i??n,taxDisplay:sa}};return c.offerType==="TRIAL"&&c.priceDetails.price===0&&(c.priceDetails.price=c.priceDetails.priceWithoutDiscount),c}var tn=function(e,t){return tn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])},tn(e,t)};function ut(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");tn(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var E=function(){return E=Object.assign||function(t){for(var r,n=1,o=arguments.length;n0}),r=[],n=0,o=t;n1)throw new RangeError("integer-width stems only accept a single optional option");o.options[0].replace(ha,function(c,a,h,l,d,u){if(a)t.minimumIntegerDigits=h.length;else{if(l&&d)throw new Error("We currently do not support maximum integer digits");if(u)throw new Error("We currently do not support exact integer digits")}return""});continue}if(jo.test(o.stem)){t.minimumIntegerDigits=o.stem.length;continue}if(Fo.test(o.stem)){if(o.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");o.stem.replace(Fo,function(c,a,h,l,d,u){return h==="*"?t.minimumFractionDigits=a.length:l&&l[0]==="#"?t.maximumFractionDigits=l.length:d&&u?(t.minimumFractionDigits=d.length,t.maximumFractionDigits=d.length+u.length):(t.minimumFractionDigits=a.length,t.maximumFractionDigits=a.length),""}),o.options.length&&(t=E(E({},t),Ho(o.options[0])));continue}if(Vo.test(o.stem)){t=E(E({},t),Ho(o.stem));continue}var i=Bo(o.stem);i&&(t=E(E({},t),i));var s=da(o.stem);s&&(t=E(E({},t),s))}return t}var on,ua=new RegExp("^"+nn.source+"*"),ma=new RegExp(nn.source+"*$");function y(e,t){return{start:e,end:t}}var pa=!!String.prototype.startsWith,fa=!!String.fromCodePoint,ga=!!Object.fromEntries,xa=!!String.prototype.codePointAt,va=!!String.prototype.trimStart,ya=!!String.prototype.trimEnd,Ea=!!Number.isSafeInteger,ba=Ea?Number.isSafeInteger:function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991},an=!0;try{qo=Jo("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu"),an=((on=qo.exec("a"))===null||on===void 0?void 0:on[0])==="a"}catch{an=!1}var qo,Yo=pa?function(t,r,n){return t.startsWith(r,n)}:function(t,r,n){return t.slice(n,n+r.length)===r},cn=fa?String.fromCodePoint:function(){for(var t=[],r=0;ri;){if(s=t[i++],s>1114111)throw RangeError(s+" is not a valid code point");n+=s<65536?String.fromCharCode(s):String.fromCharCode(((s-=65536)>>10)+55296,s%1024+56320)}return n},Xo=ga?Object.fromEntries:function(t){for(var r={},n=0,o=t;n=n)){var o=t.charCodeAt(r),i;return o<55296||o>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?o:(o-55296<<10)+(i-56320)+65536}},_a=va?function(t){return t.trimStart()}:function(t){return t.replace(ua,"")},wa=ya?function(t){return t.trimEnd()}:function(t){return t.replace(ma,"")};function Jo(e,t){return new RegExp(e,t)}var ln;an?(sn=Jo("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu"),ln=function(t,r){var n;sn.lastIndex=r;var o=sn.exec(t);return(n=o[1])!==null&&n!==void 0?n:""}):ln=function(t,r){for(var n=[];;){var o=Zo(t,r);if(o===void 0||Ko(o)||Ta(o))break;n.push(o),r+=o>=65536?2:1}return cn.apply(void 0,n)};var sn,Qo=function(){function e(t,r){r===void 0&&(r={}),this.message=t,this.position={offset:0,line:1,column:1},this.ignoreTag=!!r.ignoreTag,this.requiresOtherClause=!!r.requiresOtherClause,this.shouldParseSkeletons=!!r.shouldParseSkeletons}return e.prototype.parse=function(){if(this.offset()!==0)throw Error("parser can only be used once");return this.parseMessage(0,"",!1)},e.prototype.parseMessage=function(t,r,n){for(var o=[];!this.isEOF();){var i=this.char();if(i===123){var s=this.parseArgument(t,n);if(s.err)return s;o.push(s.val)}else{if(i===125&&t>0)break;if(i===35&&(r==="plural"||r==="selectordinal")){var c=this.clonePosition();this.bump(),o.push({type:T.pound,location:y(c,this.clonePosition())})}else if(i===60&&!this.ignoreTag&&this.peek()===47){if(n)break;return this.error(v.UNMATCHED_CLOSING_TAG,y(this.clonePosition(),this.clonePosition()))}else if(i===60&&!this.ignoreTag&&hn(this.peek()||0)){var s=this.parseTag(t,r);if(s.err)return s;o.push(s.val)}else{var s=this.parseLiteral(t,r);if(s.err)return s;o.push(s.val)}}}return{val:o,err:null}},e.prototype.parseTag=function(t,r){var n=this.clonePosition();this.bump();var o=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return{val:{type:T.literal,value:"<"+o+"/>",location:y(n,this.clonePosition())},err:null};if(this.bumpIf(">")){var i=this.parseMessage(t+1,r,!0);if(i.err)return i;var s=i.val,c=this.clonePosition();if(this.bumpIf("")?{val:{type:T.tag,value:o,children:s,location:y(n,this.clonePosition())},err:null}:this.error(v.INVALID_TAG,y(c,this.clonePosition())))}else return this.error(v.UNCLOSED_TAG,y(n,this.clonePosition()))}else return this.error(v.INVALID_TAG,y(n,this.clonePosition()))},e.prototype.parseTagName=function(){var t=this.offset();for(this.bump();!this.isEOF()&&Sa(this.char());)this.bump();return this.message.slice(t,this.offset())},e.prototype.parseLiteral=function(t,r){for(var n=this.clonePosition(),o="";;){var i=this.tryParseQuote(r);if(i){o+=i;continue}var s=this.tryParseUnquoted(t,r);if(s){o+=s;continue}var c=this.tryParseLeftAngleBracket();if(c){o+=c;continue}break}var a=y(n,this.clonePosition());return{val:{type:T.literal,value:o,location:a},err:null}},e.prototype.tryParseLeftAngleBracket=function(){return!this.isEOF()&&this.char()===60&&(this.ignoreTag||!Aa(this.peek()||0))?(this.bump(),"<"):null},e.prototype.tryParseQuote=function(t){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if(t==="plural"||t==="selectordinal")break;return null;default:return null}this.bump();var r=[this.char()];for(this.bump();!this.isEOF();){var n=this.char();if(n===39)if(this.peek()===39)r.push(39),this.bump();else{this.bump();break}else r.push(n);this.bump()}return cn.apply(void 0,r)},e.prototype.tryParseUnquoted=function(t,r){if(this.isEOF())return null;var n=this.char();return n===60||n===123||n===35&&(r==="plural"||r==="selectordinal")||n===125&&t>0?null:(this.bump(),cn(n))},e.prototype.parseArgument=function(t,r){var n=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(v.EXPECT_ARGUMENT_CLOSING_BRACE,y(n,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(v.EMPTY_ARGUMENT,y(n,this.clonePosition()));var o=this.parseIdentifierIfPossible().value;if(!o)return this.error(v.MALFORMED_ARGUMENT,y(n,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(v.EXPECT_ARGUMENT_CLOSING_BRACE,y(n,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:T.argument,value:o,location:y(n,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(v.EXPECT_ARGUMENT_CLOSING_BRACE,y(n,this.clonePosition())):this.parseArgumentOptions(t,r,o,n);default:return this.error(v.MALFORMED_ARGUMENT,y(n,this.clonePosition()))}},e.prototype.parseIdentifierIfPossible=function(){var t=this.clonePosition(),r=this.offset(),n=ln(this.message,r),o=r+n.length;this.bumpTo(o);var i=this.clonePosition(),s=y(t,i);return{value:n,location:s}},e.prototype.parseArgumentOptions=function(t,r,n,o){var i,s=this.clonePosition(),c=this.parseIdentifierIfPossible().value,a=this.clonePosition();switch(c){case"":return this.error(v.EXPECT_ARGUMENT_TYPE,y(s,a));case"number":case"date":case"time":{this.bumpSpace();var h=null;if(this.bumpIf(",")){this.bumpSpace();var l=this.clonePosition(),d=this.parseSimpleArgStyleIfPossible();if(d.err)return d;var u=wa(d.val);if(u.length===0)return this.error(v.EXPECT_ARGUMENT_STYLE,y(this.clonePosition(),this.clonePosition()));var m=y(l,this.clonePosition());h={style:u,styleLocation:m}}var f=this.tryParseArgumentClose(o);if(f.err)return f;var g=y(o,this.clonePosition());if(h&&Yo(h?.style,"::",0)){var _=_a(h.style.slice(2));if(c==="number"){var d=this.parseNumberSkeletonFromString(_,h.styleLocation);return d.err?d:{val:{type:T.number,value:n,location:g,style:d.val},err:null}}else{if(_.length===0)return this.error(v.EXPECT_DATE_TIME_SKELETON,g);var u={type:Se.dateTime,pattern:_,location:h.styleLocation,parsedOptions:this.shouldParseSkeletons?Uo(_):{}},P=c==="date"?T.date:T.time;return{val:{type:P,value:n,location:g,style:u},err:null}}}return{val:{type:c==="number"?T.number:c==="date"?T.date:T.time,value:n,location:g,style:(i=h?.style)!==null&&i!==void 0?i:null},err:null}}case"plural":case"selectordinal":case"select":{var C=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(v.EXPECT_SELECT_ARGUMENT_OPTIONS,y(C,E({},C)));this.bumpSpace();var A=this.parseIdentifierIfPossible(),I=0;if(c!=="select"&&A.value==="offset"){if(!this.bumpIf(":"))return this.error(v.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,y(this.clonePosition(),this.clonePosition()));this.bumpSpace();var d=this.tryParseDecimalInteger(v.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,v.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);if(d.err)return d;this.bumpSpace(),A=this.parseIdentifierIfPossible(),I=d.val}var S=this.tryParsePluralOrSelectOptions(t,c,r,A);if(S.err)return S;var f=this.tryParseArgumentClose(o);if(f.err)return f;var $=y(o,this.clonePosition());return c==="select"?{val:{type:T.select,value:n,options:Xo(S.val),location:$},err:null}:{val:{type:T.plural,value:n,options:Xo(S.val),offset:I,pluralType:c==="plural"?"cardinal":"ordinal",location:$},err:null}}default:return this.error(v.INVALID_ARGUMENT_TYPE,y(s,a))}},e.prototype.tryParseArgumentClose=function(t){return this.isEOF()||this.char()!==125?this.error(v.EXPECT_ARGUMENT_CLOSING_BRACE,y(t,this.clonePosition())):(this.bump(),{val:!0,err:null})},e.prototype.parseSimpleArgStyleIfPossible=function(){for(var t=0,r=this.clonePosition();!this.isEOF();){var n=this.char();switch(n){case 39:{this.bump();var o=this.clonePosition();if(!this.bumpUntil("'"))return this.error(v.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE,y(o,this.clonePosition()));this.bump();break}case 123:{t+=1,this.bump();break}case 125:{if(t>0)t-=1;else return{val:this.message.slice(r.offset,this.offset()),err:null};break}default:this.bump();break}}return{val:this.message.slice(r.offset,this.offset()),err:null}},e.prototype.parseNumberSkeletonFromString=function(t,r){var n=[];try{n=Go(t)}catch{return this.error(v.INVALID_NUMBER_SKELETON,r)}return{val:{type:Se.number,tokens:n,location:r,parsedOptions:this.shouldParseSkeletons?Wo(n):{}},err:null}},e.prototype.tryParsePluralOrSelectOptions=function(t,r,n,o){for(var i,s=!1,c=[],a=new Set,h=o.value,l=o.location;;){if(h.length===0){var d=this.clonePosition();if(r!=="select"&&this.bumpIf("=")){var u=this.tryParseDecimalInteger(v.EXPECT_PLURAL_ARGUMENT_SELECTOR,v.INVALID_PLURAL_ARGUMENT_SELECTOR);if(u.err)return u;l=y(d,this.clonePosition()),h=this.message.slice(d.offset,this.offset())}else break}if(a.has(h))return this.error(r==="select"?v.DUPLICATE_SELECT_ARGUMENT_SELECTOR:v.DUPLICATE_PLURAL_ARGUMENT_SELECTOR,l);h==="other"&&(s=!0),this.bumpSpace();var m=this.clonePosition();if(!this.bumpIf("{"))return this.error(r==="select"?v.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT:v.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT,y(this.clonePosition(),this.clonePosition()));var f=this.parseMessage(t+1,r,n);if(f.err)return f;var g=this.tryParseArgumentClose(m);if(g.err)return g;c.push([h,{value:f.val,location:y(m,this.clonePosition())}]),a.add(h),this.bumpSpace(),i=this.parseIdentifierIfPossible(),h=i.value,l=i.location}return c.length===0?this.error(r==="select"?v.EXPECT_SELECT_ARGUMENT_SELECTOR:v.EXPECT_PLURAL_ARGUMENT_SELECTOR,y(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!s?this.error(v.MISSING_OTHER_CLAUSE,y(this.clonePosition(),this.clonePosition())):{val:c,err:null}},e.prototype.tryParseDecimalInteger=function(t,r){var n=1,o=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(n=-1);for(var i=!1,s=0;!this.isEOF();){var c=this.char();if(c>=48&&c<=57)i=!0,s=s*10+(c-48),this.bump();else break}var a=y(o,this.clonePosition());return i?(s*=n,ba(s)?{val:s,err:null}:this.error(r,a)):this.error(t,a)},e.prototype.offset=function(){return this.position.offset},e.prototype.isEOF=function(){return this.offset()===this.message.length},e.prototype.clonePosition=function(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}},e.prototype.char=function(){var t=this.position.offset;if(t>=this.message.length)throw Error("out of bound");var r=Zo(this.message,t);if(r===void 0)throw Error("Offset "+t+" is at invalid UTF-16 code unit boundary");return r},e.prototype.error=function(t,r){return{val:null,err:{kind:t,message:this.message,location:r}}},e.prototype.bump=function(){if(!this.isEOF()){var t=this.char();t===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=t<65536?1:2)}},e.prototype.bumpIf=function(t){if(Yo(this.message,t,this.offset())){for(var r=0;r=0?(this.bumpTo(n),!0):(this.bumpTo(this.message.length),!1)},e.prototype.bumpTo=function(t){if(this.offset()>t)throw Error("targetOffset "+t+" must be greater than or equal to the current offset "+this.offset());for(t=Math.min(t,this.message.length);;){var r=this.offset();if(r===t)break;if(r>t)throw Error("targetOffset "+t+" is at invalid UTF-16 code unit boundary");if(this.bump(),this.isEOF())break}},e.prototype.bumpSpace=function(){for(;!this.isEOF()&&Ko(this.char());)this.bump()},e.prototype.peek=function(){if(this.isEOF())return null;var t=this.char(),r=this.offset(),n=this.message.charCodeAt(r+(t>=65536?2:1));return n??null},e}();function hn(e){return e>=97&&e<=122||e>=65&&e<=90}function Aa(e){return hn(e)||e===47}function Sa(e){return e===45||e===46||e>=48&&e<=57||e===95||e>=97&&e<=122||e>=65&&e<=90||e==183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function Ko(e){return e>=9&&e<=13||e===32||e===133||e>=8206&&e<=8207||e===8232||e===8233}function Ta(e){return e>=33&&e<=35||e===36||e>=37&&e<=39||e===40||e===41||e===42||e===43||e===44||e===45||e>=46&&e<=47||e>=58&&e<=59||e>=60&&e<=62||e>=63&&e<=64||e===91||e===92||e===93||e===94||e===96||e===123||e===124||e===125||e===126||e===161||e>=162&&e<=165||e===166||e===167||e===169||e===171||e===172||e===174||e===176||e===177||e===182||e===187||e===191||e===215||e===247||e>=8208&&e<=8213||e>=8214&&e<=8215||e===8216||e===8217||e===8218||e>=8219&&e<=8220||e===8221||e===8222||e===8223||e>=8224&&e<=8231||e>=8240&&e<=8248||e===8249||e===8250||e>=8251&&e<=8254||e>=8257&&e<=8259||e===8260||e===8261||e===8262||e>=8263&&e<=8273||e===8274||e===8275||e>=8277&&e<=8286||e>=8592&&e<=8596||e>=8597&&e<=8601||e>=8602&&e<=8603||e>=8604&&e<=8607||e===8608||e>=8609&&e<=8610||e===8611||e>=8612&&e<=8613||e===8614||e>=8615&&e<=8621||e===8622||e>=8623&&e<=8653||e>=8654&&e<=8655||e>=8656&&e<=8657||e===8658||e===8659||e===8660||e>=8661&&e<=8691||e>=8692&&e<=8959||e>=8960&&e<=8967||e===8968||e===8969||e===8970||e===8971||e>=8972&&e<=8991||e>=8992&&e<=8993||e>=8994&&e<=9e3||e===9001||e===9002||e>=9003&&e<=9083||e===9084||e>=9085&&e<=9114||e>=9115&&e<=9139||e>=9140&&e<=9179||e>=9180&&e<=9185||e>=9186&&e<=9254||e>=9255&&e<=9279||e>=9280&&e<=9290||e>=9291&&e<=9311||e>=9472&&e<=9654||e===9655||e>=9656&&e<=9664||e===9665||e>=9666&&e<=9719||e>=9720&&e<=9727||e>=9728&&e<=9838||e===9839||e>=9840&&e<=10087||e===10088||e===10089||e===10090||e===10091||e===10092||e===10093||e===10094||e===10095||e===10096||e===10097||e===10098||e===10099||e===10100||e===10101||e>=10132&&e<=10175||e>=10176&&e<=10180||e===10181||e===10182||e>=10183&&e<=10213||e===10214||e===10215||e===10216||e===10217||e===10218||e===10219||e===10220||e===10221||e===10222||e===10223||e>=10224&&e<=10239||e>=10240&&e<=10495||e>=10496&&e<=10626||e===10627||e===10628||e===10629||e===10630||e===10631||e===10632||e===10633||e===10634||e===10635||e===10636||e===10637||e===10638||e===10639||e===10640||e===10641||e===10642||e===10643||e===10644||e===10645||e===10646||e===10647||e===10648||e>=10649&&e<=10711||e===10712||e===10713||e===10714||e===10715||e>=10716&&e<=10747||e===10748||e===10749||e>=10750&&e<=11007||e>=11008&&e<=11055||e>=11056&&e<=11076||e>=11077&&e<=11078||e>=11079&&e<=11084||e>=11085&&e<=11123||e>=11124&&e<=11125||e>=11126&&e<=11157||e===11158||e>=11159&&e<=11263||e>=11776&&e<=11777||e===11778||e===11779||e===11780||e===11781||e>=11782&&e<=11784||e===11785||e===11786||e===11787||e===11788||e===11789||e>=11790&&e<=11798||e===11799||e>=11800&&e<=11801||e===11802||e===11803||e===11804||e===11805||e>=11806&&e<=11807||e===11808||e===11809||e===11810||e===11811||e===11812||e===11813||e===11814||e===11815||e===11816||e===11817||e>=11818&&e<=11822||e===11823||e>=11824&&e<=11833||e>=11834&&e<=11835||e>=11836&&e<=11839||e===11840||e===11841||e===11842||e>=11843&&e<=11855||e>=11856&&e<=11857||e===11858||e>=11859&&e<=11903||e>=12289&&e<=12291||e===12296||e===12297||e===12298||e===12299||e===12300||e===12301||e===12302||e===12303||e===12304||e===12305||e>=12306&&e<=12307||e===12308||e===12309||e===12310||e===12311||e===12312||e===12313||e===12314||e===12315||e===12316||e===12317||e>=12318&&e<=12319||e===12320||e===12336||e===64830||e===64831||e>=65093&&e<=65094}function dn(e){e.forEach(function(t){if(delete t.location,Yt(t)||Xt(t))for(var r in t.options)delete t.options[r].location,dn(t.options[r].value);else Bt(t)&&Jt(t.style)||(Wt(t)||qt(t))&&mt(t.style)?delete t.style.location:Zt(t)&&dn(t.children)})}function ei(e,t){t===void 0&&(t={}),t=E({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var r=new Qo(e,t).parse();if(r.err){var n=SyntaxError(v[r.err.kind]);throw n.location=r.err.location,n.originalMessage=r.err.message,n}return t?.captureLocation||dn(r.val),r.val}function pt(e,t){var r=t&&t.cache?t.cache:Na,n=t&&t.serializer?t.serializer:La,o=t&&t.strategy?t.strategy:Ca;return o(e,{cache:r,serializer:n})}function Pa(e){return e==null||typeof e=="number"||typeof e=="boolean"}function ti(e,t,r,n){var o=Pa(n)?n:r(n),i=t.get(o);return typeof i>"u"&&(i=e.call(this,n),t.set(o,i)),i}function ri(e,t,r){var n=Array.prototype.slice.call(arguments,3),o=r(n),i=t.get(o);return typeof i>"u"&&(i=e.apply(this,n),t.set(o,i)),i}function un(e,t,r,n,o){return r.bind(t,e,n,o)}function Ca(e,t){var r=e.length===1?ti:ri;return un(e,this,r,t.cache.create(),t.serializer)}function $a(e,t){return un(e,this,ri,t.cache.create(),t.serializer)}function Oa(e,t){return un(e,this,ti,t.cache.create(),t.serializer)}var La=function(){return JSON.stringify(arguments)};function mn(){this.cache=Object.create(null)}mn.prototype.get=function(e){return this.cache[e]};mn.prototype.set=function(e,t){this.cache[e]=t};var Na={create:function(){return new mn}},Qt={variadic:$a,monadic:Oa};var Te;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(Te||(Te={}));var ft=function(e){ut(t,e);function t(r,n,o){var i=e.call(this,r)||this;return i.code=n,i.originalMessage=o,i}return t.prototype.toString=function(){return"[formatjs Error: "+this.code+"] "+this.message},t}(Error);var pn=function(e){ut(t,e);function t(r,n,o,i){return e.call(this,'Invalid values for "'+r+'": "'+n+'". Options are "'+Object.keys(o).join('", "')+'"',Te.INVALID_VALUE,i)||this}return t}(ft);var ni=function(e){ut(t,e);function t(r,n,o){return e.call(this,'Value for "'+r+'" must be of type '+n,Te.INVALID_VALUE,o)||this}return t}(ft);var oi=function(e){ut(t,e);function t(r,n){return e.call(this,'The intl string context variable "'+r+'" was not provided to the string "'+n+'"',Te.MISSING_VALUE,n)||this}return t}(ft);var D;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(D||(D={}));function Ra(e){return e.length<2?e:e.reduce(function(t,r){var n=t[t.length-1];return!n||n.type!==D.literal||r.type!==D.literal?t.push(r):n.value+=r.value,t},[])}function Ia(e){return typeof e=="function"}function gt(e,t,r,n,o,i,s){if(e.length===1&&rn(e[0]))return[{type:D.literal,value:e[0].value}];for(var c=[],a=0,h=e;a{throw TypeError(e)};var Ms=(e,t,r)=>t in e?bo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Us=(e,t)=>{for(var r in t)bo(e,r,{get:t[r],enumerable:!0})};var O=(e,t,r)=>Ms(e,typeof t!="symbol"?t+"":t,r),wo=(e,t,r)=>t.has(e)||_o("Cannot "+r);var R=(e,t,r)=>(wo(e,t,"read from private field"),r?r.call(e):t.get(e)),Q=(e,t,r)=>t.has(e)?_o("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),K=(e,t,r,n)=>(wo(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var lt;(function(e){e.STAGE="STAGE",e.PRODUCTION="PRODUCTION",e.LOCAL="LOCAL"})(lt||(lt={}));var Mr;(function(e){e.STAGE="STAGE",e.PRODUCTION="PROD",e.LOCAL="LOCAL"})(Mr||(Mr={}));var ht;(function(e){e.DRAFT="DRAFT",e.PUBLISHED="PUBLISHED"})(ht||(ht={}));var Ae;(function(e){e.V2="UCv2",e.V3="UCv3"})(Ae||(Ae={}));var Y;(function(e){e.CHECKOUT="checkout",e.CHECKOUT_EMAIL="checkout/email",e.SEGMENTATION="segmentation",e.BUNDLE="bundle",e.COMMITMENT="commitment",e.RECOMMENDATION="recommendation",e.EMAIL="email",e.PAYMENT="payment",e.CHANGE_PLAN_TEAM_PLANS="change-plan/team-upgrade/plans",e.CHANGE_PLAN_TEAM_PAYMENT="change-plan/team-upgrade/payment"})(Y||(Y={}));var Ur=function(e){var t;return(t=Ds.get(e))!==null&&t!==void 0?t:e},Ds=new Map([["countrySpecific","cs"],["quantity","q"],["authCode","code"],["checkoutPromoCode","apc"],["rurl","rUrl"],["curl","cUrl"],["ctxrturl","ctxRtUrl"],["country","co"],["language","lang"],["clientId","cli"],["context","ctx"],["productArrangementCode","pa"],["offerType","ot"],["marketSegment","ms"]]);var Ao=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},So=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(c){s={error:c}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i};function je(e,t,r){var n,o;try{for(var i=Ao(Object.entries(e)),s=i.next();!s.done;s=i.next()){var c=So(s.value,2),a=c[0],h=c[1],l=Ur(a);h!=null&&r.has(l)&&t.set(l,h)}}catch(d){n={error:d}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}}function Ft(e){switch(e){case lt.PRODUCTION:return"https://commerce.adobe.com";default:return"https://commerce-stg.adobe.com"}}function Ht(e,t){var r,n;for(var o in e){var i=e[o];try{for(var s=(r=void 0,Ao(Object.entries(i))),c=s.next();!c.done;c=s.next()){var a=So(c.value,2),h=a[0],l=a[1];if(l!=null){var d=Ur(h);t.set("items["+o+"]["+d+"]",l)}}}catch(u){r={error:u}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}}}var Fs=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function To(e){Vs(e);var t=e.env,r=e.items,n=e.workflowStep,o=Fs(e,["env","items","workflowStep"]),i=new URL(Ft(t));return i.pathname=n+"/",Ht(r,i.searchParams),je(o,i.searchParams,zs),i.toString()}var zs=new Set(["cli","co","lang","ctx","cUrl","mv","nglwfdata","otac","promoid","rUrl","sdid","spint","trackingid","code","campaignid","appctxid"]),Gs=["env","workflowStep","clientId","country","items"];function Vs(e){var t,r;try{for(var n=Hs(Gs),o=n.next();!o.done;o=n.next()){var i=o.value;if(!e[i])throw new Error('Argument "checkoutData" is not valid, missing: '+i)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!0}var js=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ws="p_draft_landscape",qs="/store/";function Fr(e){Xs(e);var t=e.env,r=e.items,n=e.workflowStep,o=e.ms,i=e.marketSegment,s=e.ot,c=e.offerType,a=e.pa,h=e.productArrangementCode,l=e.landscape,d=js(e,["env","items","workflowStep","ms","marketSegment","ot","offerType","pa","productArrangementCode","landscape"]),u={marketSegment:i??o,offerType:c??s,productArrangementCode:h??a},m=new URL(Ft(t));return m.pathname=""+qs+n,n!==Y.SEGMENTATION&&n!==Y.CHANGE_PLAN_TEAM_PLANS&&Ht(r,m.searchParams),n===Y.SEGMENTATION&&je(u,m.searchParams,Dr),je(d,m.searchParams,Dr),l===ht.DRAFT&&je({af:Ws},m.searchParams,Dr),m.toString()}var Dr=new Set(["af","ai","apc","appctxid","cli","co","csm","ctx","ctxRtUrl","DCWATC","dp","fr","gsp","ijt","lang","lo","mal","ms","mv","mv2","nglwfdata","ot","otac","pa","pcid","promoid","q","rf","sc","scl","sdid","sid","spint","svar","th","thm","trackingid","usid","workflowid","context.guid","so.ca","so.su","so.tr","so.va"]),Ys=["env","workflowStep","clientId","country"];function Xs(e){var t,r;try{for(var n=Bs(Ys),o=n.next();!o.done;o=n.next()){var i=o.value;if(!e[i])throw new Error('Argument "checkoutData" is not valid, missing: '+i)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}if(e.workflowStep!==Y.SEGMENTATION&&e.workflowStep!==Y.CHANGE_PLAN_TEAM_PLANS&&!e.items)throw new Error('Argument "checkoutData" is not valid, missing: items');return!0}function Hr(e,t){switch(e){case Ae.V2:return To(t);case Ae.V3:return Fr(t);default:return console.warn("Unsupported CheckoutType, will use UCv3 as default. Given type: "+e),Fr(t)}}var zr;(function(e){e.BASE="BASE",e.TRIAL="TRIAL",e.PROMOTION="PROMOTION"})(zr||(zr={}));var k;(function(e){e.MONTH="MONTH",e.YEAR="YEAR",e.TWO_YEARS="TWO_YEARS",e.THREE_YEARS="THREE_YEARS",e.PERPETUAL="PERPETUAL",e.TERM_LICENSE="TERM_LICENSE",e.ACCESS_PASS="ACCESS_PASS",e.THREE_MONTHS="THREE_MONTHS",e.SIX_MONTHS="SIX_MONTHS"})(k||(k={}));var L;(function(e){e.ANNUAL="ANNUAL",e.MONTHLY="MONTHLY",e.TWO_YEARS="TWO_YEARS",e.THREE_YEARS="THREE_YEARS",e.P1D="P1D",e.P1Y="P1Y",e.P3Y="P3Y",e.P10Y="P10Y",e.P15Y="P15Y",e.P3D="P3D",e.P7D="P7D",e.P30D="P30D",e.HALF_YEARLY="HALF_YEARLY",e.QUARTERLY="QUARTERLY"})(L||(L={}));var Gr;(function(e){e.INDIVIDUAL="INDIVIDUAL",e.TEAM="TEAM",e.ENTERPRISE="ENTERPRISE"})(Gr||(Gr={}));var Vr;(function(e){e.COM="COM",e.EDU="EDU",e.GOV="GOV"})(Vr||(Vr={}));var jr;(function(e){e.DIRECT="DIRECT",e.INDIRECT="INDIRECT"})(jr||(jr={}));var Br;(function(e){e.ENTERPRISE_PRODUCT="ENTERPRISE_PRODUCT",e.ETLA="ETLA",e.RETAIL="RETAIL",e.VIP="VIP",e.VIPMP="VIPMP",e.FREE="FREE"})(Br||(Br={}));var Po="tacocat.js";var zt=(e,t)=>String(e??"").toLowerCase()==String(t??"").toLowerCase(),Co=e=>`${e??""}`.replace(/[&<>'"]/g,t=>({"&":"&","<":"<",">":">","'":"'",'"':"""})[t]??t)??"";function N(e,t={},{metadata:r=!0,search:n=!0,storage:o=!0}={}){let i;if(n&&i==null){let s=new URLSearchParams(window.location.search),c=Be(n)?n:e;i=s.get(c)}if(o&&i==null){let s=Be(o)?o:e;i=window.sessionStorage.getItem(s)??window.localStorage.getItem(s)}if(r&&i==null){let s=Zs(Be(r)?r:e);i=document.documentElement.querySelector(`meta[name="${s}"]`)?.content}return i??t[e]}var We=()=>{};var $o=e=>typeof e=="boolean",me=e=>typeof e=="function",Gt=e=>typeof e=="number",Oo=e=>e!=null&&typeof e=="object";var Be=e=>typeof e=="string",Wr=e=>Be(e)&&e,qe=e=>Gt(e)&&Number.isFinite(e)&&e>0;function Ye(e,t=r=>r==null||r===""){return e!=null&&Object.entries(e).forEach(([r,n])=>{t(n)&&delete e[r]}),e}function w(e,t){if($o(e))return e;let r=String(e);return r==="1"||r==="true"?!0:r==="0"||r==="false"?!1:t}function pe(e,t,r){let n=Object.values(t);return n.find(o=>zt(o,e))??r??n[0]}function Zs(e=""){return String(e).replace(/(\p{Lowercase_Letter})(\p{Uppercase_Letter})/gu,(t,r,n)=>`${r}-${n}`).replace(/\W+/gu,"-").toLowerCase()}function Xe(e,t=1){return Gt(e)||(e=Number.parseInt(e,10)),!Number.isNaN(e)&&e>0&&Number.isFinite(e)?e:t}var Js=Date.now(),qr=()=>`(+${Date.now()-Js}ms)`,Vt=new Set,Qs=w(N("tacocat.debug",{},{metadata:!1}),typeof process<"u"&&process.env?.DEBUG);function Lo(e){let t=`[${Po}/${e}]`,r=(s,c,...a)=>s?!0:(o(c,...a),!1),n=Qs?(s,...c)=>{console.debug(`${t} ${s}`,...c,qr())}:()=>{},o=(s,...c)=>{let a=`${t} ${s}`;Vt.forEach(([h])=>h(a,...c))};return{assert:r,debug:n,error:o,warn:(s,...c)=>{let a=`${t} ${s}`;Vt.forEach(([,h])=>h(a,...c))}}}function Ks(e,t){let r=[e,t];return Vt.add(r),()=>{Vt.delete(r)}}Ks((e,...t)=>{console.error(e,...t,qr())},(e,...t)=>{console.warn(e,...t,qr())});var ea="no promo",No="promo-tag",ta="yellow",ra="neutral",na=(e,t,r)=>{let n=i=>i||ea,o=r?` (was "${n(t)}")`:"";return`${n(e)}${o}`},oa="cancel-context",dt=(e,t)=>{let r=e===oa,n=!r&&e?.length>0,o=(n||r)&&(t&&t!=e||!t&&!r),i=o&&n||!o&&!!t,s=i?e||t:void 0;return{effectivePromoCode:s,overridenPromoCode:e,className:i?No:`${No} no-promo`,text:na(s,t,o),variant:i?ta:ra,isOverriden:o}};var Yr="ABM",Xr="PUF",Zr="M2M",Jr="PERPETUAL",Qr="P3Y",ia="TAX_INCLUSIVE_DETAILS",sa="TAX_EXCLUSIVE",Ro={ABM:Yr,PUF:Xr,M2M:Zr,PERPETUAL:Jr,P3Y:Qr},Ll={[Yr]:{commitment:k.YEAR,term:L.MONTHLY},[Xr]:{commitment:k.YEAR,term:L.ANNUAL},[Zr]:{commitment:k.MONTH,term:L.MONTHLY},[Jr]:{commitment:k.PERPETUAL,term:void 0},[Qr]:{commitment:k.THREE_MONTHS,term:L.P3Y}},Io="Value is not an offer",Kr=e=>{if(typeof e!="object")return Io;let{commitment:t,term:r}=e,n=aa(t,r);return{...e,planType:n}};var aa=(e,t)=>{switch(e){case void 0:return Io;case"":return"";case k.YEAR:return t===L.MONTHLY?Yr:t===L.ANNUAL?Xr:"";case k.MONTH:return t===L.MONTHLY?Zr:"";case k.PERPETUAL:return Jr;case k.TERM_LICENSE:return t===L.P3Y?Qr:"";default:return""}};function en(e){let{priceDetails:t}=e,{price:r,priceWithoutDiscount:n,priceWithoutTax:o,priceWithoutDiscountAndTax:i,taxDisplay:s}=t;if(s!==ia)return e;let c={...e,priceDetails:{...t,price:o??r,priceWithoutDiscount:i??n,taxDisplay:sa}};return c.offerType==="TRIAL"&&c.priceDetails.price===0&&(c.priceDetails.price=c.priceDetails.priceWithoutDiscount),c}var tn=function(e,t){return tn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])},tn(e,t)};function ut(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");tn(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var E=function(){return E=Object.assign||function(t){for(var r,n=1,o=arguments.length;n0}),r=[],n=0,o=t;n1)throw new RangeError("integer-width stems only accept a single optional option");o.options[0].replace(ha,function(c,a,h,l,d,u){if(a)t.minimumIntegerDigits=h.length;else{if(l&&d)throw new Error("We currently do not support maximum integer digits");if(u)throw new Error("We currently do not support exact integer digits")}return""});continue}if(jo.test(o.stem)){t.minimumIntegerDigits=o.stem.length;continue}if(Fo.test(o.stem)){if(o.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");o.stem.replace(Fo,function(c,a,h,l,d,u){return h==="*"?t.minimumFractionDigits=a.length:l&&l[0]==="#"?t.maximumFractionDigits=l.length:d&&u?(t.minimumFractionDigits=d.length,t.maximumFractionDigits=d.length+u.length):(t.minimumFractionDigits=a.length,t.maximumFractionDigits=a.length),""}),o.options.length&&(t=E(E({},t),Ho(o.options[0])));continue}if(Vo.test(o.stem)){t=E(E({},t),Ho(o.stem));continue}var i=Bo(o.stem);i&&(t=E(E({},t),i));var s=da(o.stem);s&&(t=E(E({},t),s))}return t}var on,ua=new RegExp("^"+nn.source+"*"),ma=new RegExp(nn.source+"*$");function y(e,t){return{start:e,end:t}}var pa=!!String.prototype.startsWith,fa=!!String.fromCodePoint,ga=!!Object.fromEntries,xa=!!String.prototype.codePointAt,va=!!String.prototype.trimStart,ya=!!String.prototype.trimEnd,Ea=!!Number.isSafeInteger,ba=Ea?Number.isSafeInteger:function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991},an=!0;try{qo=Jo("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu"),an=((on=qo.exec("a"))===null||on===void 0?void 0:on[0])==="a"}catch{an=!1}var qo,Yo=pa?function(t,r,n){return t.startsWith(r,n)}:function(t,r,n){return t.slice(n,n+r.length)===r},cn=fa?String.fromCodePoint:function(){for(var t=[],r=0;ri;){if(s=t[i++],s>1114111)throw RangeError(s+" is not a valid code point");n+=s<65536?String.fromCharCode(s):String.fromCharCode(((s-=65536)>>10)+55296,s%1024+56320)}return n},Xo=ga?Object.fromEntries:function(t){for(var r={},n=0,o=t;n=n)){var o=t.charCodeAt(r),i;return o<55296||o>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?o:(o-55296<<10)+(i-56320)+65536}},_a=va?function(t){return t.trimStart()}:function(t){return t.replace(ua,"")},wa=ya?function(t){return t.trimEnd()}:function(t){return t.replace(ma,"")};function Jo(e,t){return new RegExp(e,t)}var ln;an?(sn=Jo("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu"),ln=function(t,r){var n;sn.lastIndex=r;var o=sn.exec(t);return(n=o[1])!==null&&n!==void 0?n:""}):ln=function(t,r){for(var n=[];;){var o=Zo(t,r);if(o===void 0||Ko(o)||Ta(o))break;n.push(o),r+=o>=65536?2:1}return cn.apply(void 0,n)};var sn,Qo=function(){function e(t,r){r===void 0&&(r={}),this.message=t,this.position={offset:0,line:1,column:1},this.ignoreTag=!!r.ignoreTag,this.requiresOtherClause=!!r.requiresOtherClause,this.shouldParseSkeletons=!!r.shouldParseSkeletons}return e.prototype.parse=function(){if(this.offset()!==0)throw Error("parser can only be used once");return this.parseMessage(0,"",!1)},e.prototype.parseMessage=function(t,r,n){for(var o=[];!this.isEOF();){var i=this.char();if(i===123){var s=this.parseArgument(t,n);if(s.err)return s;o.push(s.val)}else{if(i===125&&t>0)break;if(i===35&&(r==="plural"||r==="selectordinal")){var c=this.clonePosition();this.bump(),o.push({type:T.pound,location:y(c,this.clonePosition())})}else if(i===60&&!this.ignoreTag&&this.peek()===47){if(n)break;return this.error(v.UNMATCHED_CLOSING_TAG,y(this.clonePosition(),this.clonePosition()))}else if(i===60&&!this.ignoreTag&&hn(this.peek()||0)){var s=this.parseTag(t,r);if(s.err)return s;o.push(s.val)}else{var s=this.parseLiteral(t,r);if(s.err)return s;o.push(s.val)}}}return{val:o,err:null}},e.prototype.parseTag=function(t,r){var n=this.clonePosition();this.bump();var o=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return{val:{type:T.literal,value:"<"+o+"/>",location:y(n,this.clonePosition())},err:null};if(this.bumpIf(">")){var i=this.parseMessage(t+1,r,!0);if(i.err)return i;var s=i.val,c=this.clonePosition();if(this.bumpIf("")?{val:{type:T.tag,value:o,children:s,location:y(n,this.clonePosition())},err:null}:this.error(v.INVALID_TAG,y(c,this.clonePosition())))}else return this.error(v.UNCLOSED_TAG,y(n,this.clonePosition()))}else return this.error(v.INVALID_TAG,y(n,this.clonePosition()))},e.prototype.parseTagName=function(){var t=this.offset();for(this.bump();!this.isEOF()&&Sa(this.char());)this.bump();return this.message.slice(t,this.offset())},e.prototype.parseLiteral=function(t,r){for(var n=this.clonePosition(),o="";;){var i=this.tryParseQuote(r);if(i){o+=i;continue}var s=this.tryParseUnquoted(t,r);if(s){o+=s;continue}var c=this.tryParseLeftAngleBracket();if(c){o+=c;continue}break}var a=y(n,this.clonePosition());return{val:{type:T.literal,value:o,location:a},err:null}},e.prototype.tryParseLeftAngleBracket=function(){return!this.isEOF()&&this.char()===60&&(this.ignoreTag||!Aa(this.peek()||0))?(this.bump(),"<"):null},e.prototype.tryParseQuote=function(t){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if(t==="plural"||t==="selectordinal")break;return null;default:return null}this.bump();var r=[this.char()];for(this.bump();!this.isEOF();){var n=this.char();if(n===39)if(this.peek()===39)r.push(39),this.bump();else{this.bump();break}else r.push(n);this.bump()}return cn.apply(void 0,r)},e.prototype.tryParseUnquoted=function(t,r){if(this.isEOF())return null;var n=this.char();return n===60||n===123||n===35&&(r==="plural"||r==="selectordinal")||n===125&&t>0?null:(this.bump(),cn(n))},e.prototype.parseArgument=function(t,r){var n=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(v.EXPECT_ARGUMENT_CLOSING_BRACE,y(n,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(v.EMPTY_ARGUMENT,y(n,this.clonePosition()));var o=this.parseIdentifierIfPossible().value;if(!o)return this.error(v.MALFORMED_ARGUMENT,y(n,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(v.EXPECT_ARGUMENT_CLOSING_BRACE,y(n,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:T.argument,value:o,location:y(n,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(v.EXPECT_ARGUMENT_CLOSING_BRACE,y(n,this.clonePosition())):this.parseArgumentOptions(t,r,o,n);default:return this.error(v.MALFORMED_ARGUMENT,y(n,this.clonePosition()))}},e.prototype.parseIdentifierIfPossible=function(){var t=this.clonePosition(),r=this.offset(),n=ln(this.message,r),o=r+n.length;this.bumpTo(o);var i=this.clonePosition(),s=y(t,i);return{value:n,location:s}},e.prototype.parseArgumentOptions=function(t,r,n,o){var i,s=this.clonePosition(),c=this.parseIdentifierIfPossible().value,a=this.clonePosition();switch(c){case"":return this.error(v.EXPECT_ARGUMENT_TYPE,y(s,a));case"number":case"date":case"time":{this.bumpSpace();var h=null;if(this.bumpIf(",")){this.bumpSpace();var l=this.clonePosition(),d=this.parseSimpleArgStyleIfPossible();if(d.err)return d;var u=wa(d.val);if(u.length===0)return this.error(v.EXPECT_ARGUMENT_STYLE,y(this.clonePosition(),this.clonePosition()));var m=y(l,this.clonePosition());h={style:u,styleLocation:m}}var f=this.tryParseArgumentClose(o);if(f.err)return f;var g=y(o,this.clonePosition());if(h&&Yo(h?.style,"::",0)){var _=_a(h.style.slice(2));if(c==="number"){var d=this.parseNumberSkeletonFromString(_,h.styleLocation);return d.err?d:{val:{type:T.number,value:n,location:g,style:d.val},err:null}}else{if(_.length===0)return this.error(v.EXPECT_DATE_TIME_SKELETON,g);var u={type:Se.dateTime,pattern:_,location:h.styleLocation,parsedOptions:this.shouldParseSkeletons?Uo(_):{}},P=c==="date"?T.date:T.time;return{val:{type:P,value:n,location:g,style:u},err:null}}}return{val:{type:c==="number"?T.number:c==="date"?T.date:T.time,value:n,location:g,style:(i=h?.style)!==null&&i!==void 0?i:null},err:null}}case"plural":case"selectordinal":case"select":{var C=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(v.EXPECT_SELECT_ARGUMENT_OPTIONS,y(C,E({},C)));this.bumpSpace();var A=this.parseIdentifierIfPossible(),I=0;if(c!=="select"&&A.value==="offset"){if(!this.bumpIf(":"))return this.error(v.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,y(this.clonePosition(),this.clonePosition()));this.bumpSpace();var d=this.tryParseDecimalInteger(v.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,v.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);if(d.err)return d;this.bumpSpace(),A=this.parseIdentifierIfPossible(),I=d.val}var S=this.tryParsePluralOrSelectOptions(t,c,r,A);if(S.err)return S;var f=this.tryParseArgumentClose(o);if(f.err)return f;var $=y(o,this.clonePosition());return c==="select"?{val:{type:T.select,value:n,options:Xo(S.val),location:$},err:null}:{val:{type:T.plural,value:n,options:Xo(S.val),offset:I,pluralType:c==="plural"?"cardinal":"ordinal",location:$},err:null}}default:return this.error(v.INVALID_ARGUMENT_TYPE,y(s,a))}},e.prototype.tryParseArgumentClose=function(t){return this.isEOF()||this.char()!==125?this.error(v.EXPECT_ARGUMENT_CLOSING_BRACE,y(t,this.clonePosition())):(this.bump(),{val:!0,err:null})},e.prototype.parseSimpleArgStyleIfPossible=function(){for(var t=0,r=this.clonePosition();!this.isEOF();){var n=this.char();switch(n){case 39:{this.bump();var o=this.clonePosition();if(!this.bumpUntil("'"))return this.error(v.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE,y(o,this.clonePosition()));this.bump();break}case 123:{t+=1,this.bump();break}case 125:{if(t>0)t-=1;else return{val:this.message.slice(r.offset,this.offset()),err:null};break}default:this.bump();break}}return{val:this.message.slice(r.offset,this.offset()),err:null}},e.prototype.parseNumberSkeletonFromString=function(t,r){var n=[];try{n=Go(t)}catch{return this.error(v.INVALID_NUMBER_SKELETON,r)}return{val:{type:Se.number,tokens:n,location:r,parsedOptions:this.shouldParseSkeletons?Wo(n):{}},err:null}},e.prototype.tryParsePluralOrSelectOptions=function(t,r,n,o){for(var i,s=!1,c=[],a=new Set,h=o.value,l=o.location;;){if(h.length===0){var d=this.clonePosition();if(r!=="select"&&this.bumpIf("=")){var u=this.tryParseDecimalInteger(v.EXPECT_PLURAL_ARGUMENT_SELECTOR,v.INVALID_PLURAL_ARGUMENT_SELECTOR);if(u.err)return u;l=y(d,this.clonePosition()),h=this.message.slice(d.offset,this.offset())}else break}if(a.has(h))return this.error(r==="select"?v.DUPLICATE_SELECT_ARGUMENT_SELECTOR:v.DUPLICATE_PLURAL_ARGUMENT_SELECTOR,l);h==="other"&&(s=!0),this.bumpSpace();var m=this.clonePosition();if(!this.bumpIf("{"))return this.error(r==="select"?v.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT:v.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT,y(this.clonePosition(),this.clonePosition()));var f=this.parseMessage(t+1,r,n);if(f.err)return f;var g=this.tryParseArgumentClose(m);if(g.err)return g;c.push([h,{value:f.val,location:y(m,this.clonePosition())}]),a.add(h),this.bumpSpace(),i=this.parseIdentifierIfPossible(),h=i.value,l=i.location}return c.length===0?this.error(r==="select"?v.EXPECT_SELECT_ARGUMENT_SELECTOR:v.EXPECT_PLURAL_ARGUMENT_SELECTOR,y(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!s?this.error(v.MISSING_OTHER_CLAUSE,y(this.clonePosition(),this.clonePosition())):{val:c,err:null}},e.prototype.tryParseDecimalInteger=function(t,r){var n=1,o=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(n=-1);for(var i=!1,s=0;!this.isEOF();){var c=this.char();if(c>=48&&c<=57)i=!0,s=s*10+(c-48),this.bump();else break}var a=y(o,this.clonePosition());return i?(s*=n,ba(s)?{val:s,err:null}:this.error(r,a)):this.error(t,a)},e.prototype.offset=function(){return this.position.offset},e.prototype.isEOF=function(){return this.offset()===this.message.length},e.prototype.clonePosition=function(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}},e.prototype.char=function(){var t=this.position.offset;if(t>=this.message.length)throw Error("out of bound");var r=Zo(this.message,t);if(r===void 0)throw Error("Offset "+t+" is at invalid UTF-16 code unit boundary");return r},e.prototype.error=function(t,r){return{val:null,err:{kind:t,message:this.message,location:r}}},e.prototype.bump=function(){if(!this.isEOF()){var t=this.char();t===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=t<65536?1:2)}},e.prototype.bumpIf=function(t){if(Yo(this.message,t,this.offset())){for(var r=0;r=0?(this.bumpTo(n),!0):(this.bumpTo(this.message.length),!1)},e.prototype.bumpTo=function(t){if(this.offset()>t)throw Error("targetOffset "+t+" must be greater than or equal to the current offset "+this.offset());for(t=Math.min(t,this.message.length);;){var r=this.offset();if(r===t)break;if(r>t)throw Error("targetOffset "+t+" is at invalid UTF-16 code unit boundary");if(this.bump(),this.isEOF())break}},e.prototype.bumpSpace=function(){for(;!this.isEOF()&&Ko(this.char());)this.bump()},e.prototype.peek=function(){if(this.isEOF())return null;var t=this.char(),r=this.offset(),n=this.message.charCodeAt(r+(t>=65536?2:1));return n??null},e}();function hn(e){return e>=97&&e<=122||e>=65&&e<=90}function Aa(e){return hn(e)||e===47}function Sa(e){return e===45||e===46||e>=48&&e<=57||e===95||e>=97&&e<=122||e>=65&&e<=90||e==183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function Ko(e){return e>=9&&e<=13||e===32||e===133||e>=8206&&e<=8207||e===8232||e===8233}function Ta(e){return e>=33&&e<=35||e===36||e>=37&&e<=39||e===40||e===41||e===42||e===43||e===44||e===45||e>=46&&e<=47||e>=58&&e<=59||e>=60&&e<=62||e>=63&&e<=64||e===91||e===92||e===93||e===94||e===96||e===123||e===124||e===125||e===126||e===161||e>=162&&e<=165||e===166||e===167||e===169||e===171||e===172||e===174||e===176||e===177||e===182||e===187||e===191||e===215||e===247||e>=8208&&e<=8213||e>=8214&&e<=8215||e===8216||e===8217||e===8218||e>=8219&&e<=8220||e===8221||e===8222||e===8223||e>=8224&&e<=8231||e>=8240&&e<=8248||e===8249||e===8250||e>=8251&&e<=8254||e>=8257&&e<=8259||e===8260||e===8261||e===8262||e>=8263&&e<=8273||e===8274||e===8275||e>=8277&&e<=8286||e>=8592&&e<=8596||e>=8597&&e<=8601||e>=8602&&e<=8603||e>=8604&&e<=8607||e===8608||e>=8609&&e<=8610||e===8611||e>=8612&&e<=8613||e===8614||e>=8615&&e<=8621||e===8622||e>=8623&&e<=8653||e>=8654&&e<=8655||e>=8656&&e<=8657||e===8658||e===8659||e===8660||e>=8661&&e<=8691||e>=8692&&e<=8959||e>=8960&&e<=8967||e===8968||e===8969||e===8970||e===8971||e>=8972&&e<=8991||e>=8992&&e<=8993||e>=8994&&e<=9e3||e===9001||e===9002||e>=9003&&e<=9083||e===9084||e>=9085&&e<=9114||e>=9115&&e<=9139||e>=9140&&e<=9179||e>=9180&&e<=9185||e>=9186&&e<=9254||e>=9255&&e<=9279||e>=9280&&e<=9290||e>=9291&&e<=9311||e>=9472&&e<=9654||e===9655||e>=9656&&e<=9664||e===9665||e>=9666&&e<=9719||e>=9720&&e<=9727||e>=9728&&e<=9838||e===9839||e>=9840&&e<=10087||e===10088||e===10089||e===10090||e===10091||e===10092||e===10093||e===10094||e===10095||e===10096||e===10097||e===10098||e===10099||e===10100||e===10101||e>=10132&&e<=10175||e>=10176&&e<=10180||e===10181||e===10182||e>=10183&&e<=10213||e===10214||e===10215||e===10216||e===10217||e===10218||e===10219||e===10220||e===10221||e===10222||e===10223||e>=10224&&e<=10239||e>=10240&&e<=10495||e>=10496&&e<=10626||e===10627||e===10628||e===10629||e===10630||e===10631||e===10632||e===10633||e===10634||e===10635||e===10636||e===10637||e===10638||e===10639||e===10640||e===10641||e===10642||e===10643||e===10644||e===10645||e===10646||e===10647||e===10648||e>=10649&&e<=10711||e===10712||e===10713||e===10714||e===10715||e>=10716&&e<=10747||e===10748||e===10749||e>=10750&&e<=11007||e>=11008&&e<=11055||e>=11056&&e<=11076||e>=11077&&e<=11078||e>=11079&&e<=11084||e>=11085&&e<=11123||e>=11124&&e<=11125||e>=11126&&e<=11157||e===11158||e>=11159&&e<=11263||e>=11776&&e<=11777||e===11778||e===11779||e===11780||e===11781||e>=11782&&e<=11784||e===11785||e===11786||e===11787||e===11788||e===11789||e>=11790&&e<=11798||e===11799||e>=11800&&e<=11801||e===11802||e===11803||e===11804||e===11805||e>=11806&&e<=11807||e===11808||e===11809||e===11810||e===11811||e===11812||e===11813||e===11814||e===11815||e===11816||e===11817||e>=11818&&e<=11822||e===11823||e>=11824&&e<=11833||e>=11834&&e<=11835||e>=11836&&e<=11839||e===11840||e===11841||e===11842||e>=11843&&e<=11855||e>=11856&&e<=11857||e===11858||e>=11859&&e<=11903||e>=12289&&e<=12291||e===12296||e===12297||e===12298||e===12299||e===12300||e===12301||e===12302||e===12303||e===12304||e===12305||e>=12306&&e<=12307||e===12308||e===12309||e===12310||e===12311||e===12312||e===12313||e===12314||e===12315||e===12316||e===12317||e>=12318&&e<=12319||e===12320||e===12336||e===64830||e===64831||e>=65093&&e<=65094}function dn(e){e.forEach(function(t){if(delete t.location,Yt(t)||Xt(t))for(var r in t.options)delete t.options[r].location,dn(t.options[r].value);else Bt(t)&&Jt(t.style)||(Wt(t)||qt(t))&&mt(t.style)?delete t.style.location:Zt(t)&&dn(t.children)})}function ei(e,t){t===void 0&&(t={}),t=E({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var r=new Qo(e,t).parse();if(r.err){var n=SyntaxError(v[r.err.kind]);throw n.location=r.err.location,n.originalMessage=r.err.message,n}return t?.captureLocation||dn(r.val),r.val}function pt(e,t){var r=t&&t.cache?t.cache:Na,n=t&&t.serializer?t.serializer:La,o=t&&t.strategy?t.strategy:Ca;return o(e,{cache:r,serializer:n})}function Pa(e){return e==null||typeof e=="number"||typeof e=="boolean"}function ti(e,t,r,n){var o=Pa(n)?n:r(n),i=t.get(o);return typeof i>"u"&&(i=e.call(this,n),t.set(o,i)),i}function ri(e,t,r){var n=Array.prototype.slice.call(arguments,3),o=r(n),i=t.get(o);return typeof i>"u"&&(i=e.apply(this,n),t.set(o,i)),i}function un(e,t,r,n,o){return r.bind(t,e,n,o)}function Ca(e,t){var r=e.length===1?ti:ri;return un(e,this,r,t.cache.create(),t.serializer)}function $a(e,t){return un(e,this,ri,t.cache.create(),t.serializer)}function Oa(e,t){return un(e,this,ti,t.cache.create(),t.serializer)}var La=function(){return JSON.stringify(arguments)};function mn(){this.cache=Object.create(null)}mn.prototype.get=function(e){return this.cache[e]};mn.prototype.set=function(e,t){this.cache[e]=t};var Na={create:function(){return new mn}},Qt={variadic:$a,monadic:Oa};var Te;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(Te||(Te={}));var ft=function(e){ut(t,e);function t(r,n,o){var i=e.call(this,r)||this;return i.code=n,i.originalMessage=o,i}return t.prototype.toString=function(){return"[formatjs Error: "+this.code+"] "+this.message},t}(Error);var pn=function(e){ut(t,e);function t(r,n,o,i){return e.call(this,'Invalid values for "'+r+'": "'+n+'". Options are "'+Object.keys(o).join('", "')+'"',Te.INVALID_VALUE,i)||this}return t}(ft);var ni=function(e){ut(t,e);function t(r,n,o){return e.call(this,'Value for "'+r+'" must be of type '+n,Te.INVALID_VALUE,o)||this}return t}(ft);var oi=function(e){ut(t,e);function t(r,n){return e.call(this,'The intl string context variable "'+r+'" was not provided to the string "'+n+'"',Te.MISSING_VALUE,n)||this}return t}(ft);var D;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(D||(D={}));function Ra(e){return e.length<2?e:e.reduce(function(t,r){var n=t[t.length-1];return!n||n.type!==D.literal||r.type!==D.literal?t.push(r):n.value+=r.value,t},[])}function Ia(e){return typeof e=="function"}function gt(e,t,r,n,o,i,s){if(e.length===1&&rn(e[0]))return[{type:D.literal,value:e[0].value}];for(var c=[],a=0,h=e;a0?e.substring(0,n):"";let o=ai(e.split("").reverse().join("")),i=r-o,s=e.substring(i,i+1),c=i+(s==="."||s===","?1:0);t.suffix=o>0?e.substring(c,r):"",t.mask=e.substring(n,c),t.maskHasNegativeSign=t.mask.charAt(0)==="-",t.maskHasPositiveSign=t.mask.charAt(0)==="+";let a=t.mask.match(Fa);return t.decimal=a&&a[a.length-1]||".",t.separator=a&&a[1]&&a[0]||",",a=t.mask.split(t.decimal),t.integer=a[0],t.fraction=a[1],t}function za(e,t,r){let n=!1,o={value:e};e<0&&(n=!0,o.value=-o.value),o.sign=n?"-":"",o.value=Number(o.value).toFixed(t.fraction&&t.fraction.length),o.value=Number(o.value).toString();let i=t.fraction&&t.fraction.lastIndexOf("0"),[s="0",c=""]=o.value.split(".");return(!c||c&&c.length<=i)&&(c=i<0?"":(+("0."+c)).toFixed(i+1).replace("0.","")),o.integer=s,o.fraction=c,Ga(o,t),(o.result==="0"||o.result==="")&&(n=!1,o.sign=""),!n&&t.maskHasPositiveSign?o.sign="+":n&&t.maskHasPositiveSign?o.sign="-":n&&(o.sign=r&&r.enforceMaskSign&&!t.maskHasNegativeSign?"":"-"),o}function Ga(e,t){e.result="";let r=t.integer.split(t.separator),n=r.join(""),o=n&&n.indexOf("0");if(o>-1)for(;e.integer.lengthMath.round(e*20)/20},gn=(e,t)=>({accept:e,round:t}),qa=[gn(({divisor:e,price:t})=>t%e==0,({divisor:e,price:t})=>t/e),gn(({usePrecision:e})=>e,({divisor:e,price:t})=>Math.ceil(Math.floor(t*1e4/e)/100)/100),gn(()=>!0,({divisor:e,price:t})=>Math.ceil(Math.floor(t*100/e)/100))],xn={[k.YEAR]:{[L.MONTHLY]:xt.MONTH,[L.ANNUAL]:xt.YEAR},[k.MONTH]:{[L.MONTHLY]:xt.MONTH}},Ya=(e,t)=>e.indexOf(`'${t}'`)===0,Xa=(e,t=!0)=>{let r=e.replace(/'.*?'/,"").trim(),n=pi(r);return!!n?t||(r=r.replace(/[,\.]0+/,n)):r=r.replace(/\s?(#.*0)(?!\s)?/,"$&"+Ja(e)),r},Za=e=>{let t=Qa(e),r=Ya(e,t),n=e.replace(/'.*?'/,""),o=di.test(n)||ui.test(n);return{currencySymbol:t,isCurrencyFirst:r,hasCurrencySpace:o}},mi=e=>e.replace(di,hi).replace(ui,hi),Ja=e=>e.match(/#(.?)#/)?.[1]===li?ja:li,Qa=e=>e.match(/'(.*?)'/)?.[1]??"",pi=e=>e.match(/0(.?)0/)?.[1]??"";function Kt({formatString:e,price:t,usePrecision:r,isIndianPrice:n=!1},o,i=s=>s){let{currencySymbol:s,isCurrencyFirst:c,hasCurrencySpace:a}=Za(e),h=r?pi(e):"",l=Xa(e,r),d=r?2:0,u=i(t,{currencySymbol:s}),m=n?u.toLocaleString("hi-IN",{minimumFractionDigits:d,maximumFractionDigits:d}):ci(l,u),f=r?m.lastIndexOf(h):m.length,g=m.substring(0,f),_=m.substring(f+1);return{accessiblePrice:e.replace(/'.*?'/,"SYMBOL").replace(/#.*0/,m).replace(/SYMBOL/,s),currencySymbol:s,decimals:_,decimalsDelimiter:h,hasCurrencySpace:a,integer:g,isCurrencyFirst:c,recurrenceTerm:o}}var fi=e=>{let{commitment:t,term:r,usePrecision:n}=e,o=Ba[r]??1;return Kt(e,o>1?xt.MONTH:xn[t]?.[r],(i,{currencySymbol:s})=>{let c={divisor:o,price:i,usePrecision:n},{round:a}=qa.find(({accept:l})=>l(c));if(!a)throw new Error(`Missing rounding rule for: ${JSON.stringify(c)}`);return(Wa[s]??(l=>l))(a(c))})},gi=({commitment:e,term:t,...r})=>Kt(r,xn[e]?.[t]),xi=e=>{let{commitment:t,term:r}=e;return t===k.YEAR&&r===L.MONTHLY?Kt(e,xt.YEAR,n=>n*12):Kt(e,xn[t]?.[r])};var Ka={recurrenceLabel:"{recurrenceTerm, select, MONTH {/mo} YEAR {/yr} other {}}",recurrenceAriaLabel:"{recurrenceTerm, select, MONTH {per month} YEAR {per year} other {}}",perUnitLabel:"{perUnit, select, LICENSE {per license} other {}}",perUnitAriaLabel:"{perUnit, select, LICENSE {per license} other {}}",freeLabel:"Free",freeAriaLabel:"Free",taxExclusiveLabel:"{taxTerm, select, GST {excl. GST} VAT {excl. VAT} TAX {excl. tax} IVA {excl. IVA} SST {excl. SST} KDV {excl. KDV} other {}}",taxInclusiveLabel:"{taxTerm, select, GST {incl. GST} VAT {incl. VAT} TAX {incl. tax} IVA {incl. IVA} SST {incl. SST} KDV {incl. KDV} other {}}",alternativePriceAriaLabel:"Alternatively at {alternativePrice}",strikethroughAriaLabel:"Regularly at {strikethroughPrice}"},ec=Lo("ConsonantTemplates/price"),tc=/<.+?>/g,W={container:"price",containerOptical:"price-optical",containerStrikethrough:"price-strikethrough",containerAnnual:"price-annual",disabled:"disabled",currencySpace:"price-currency-space",currencySymbol:"price-currency-symbol",decimals:"price-decimals",decimalsDelimiter:"price-decimals-delimiter",integer:"price-integer",recurrence:"price-recurrence",taxInclusivity:"price-tax-inclusivity",unitType:"price-unit-type"},Pe={perUnitLabel:"perUnitLabel",perUnitAriaLabel:"perUnitAriaLabel",recurrenceLabel:"recurrenceLabel",recurrenceAriaLabel:"recurrenceAriaLabel",taxExclusiveLabel:"taxExclusiveLabel",taxInclusiveLabel:"taxInclusiveLabel",strikethroughAriaLabel:"strikethroughAriaLabel"},rc="TAX_EXCLUSIVE",nc=e=>Oo(e)?Object.entries(e).filter(([,t])=>Be(t)||Gt(t)||t===!0).reduce((t,[r,n])=>t+` ${r}${n===!0?"":'="'+Co(n)+'"'}`,""):"",ee=(e,t,r,n=!1)=>`${n?mi(t):t??""}`;function oc(e,{accessibleLabel:t,currencySymbol:r,decimals:n,decimalsDelimiter:o,hasCurrencySpace:i,integer:s,isCurrencyFirst:c,recurrenceLabel:a,perUnitLabel:h,taxInclusivityLabel:l},d={}){let u=ee(W.currencySymbol,r),m=ee(W.currencySpace,i?" ":""),f="";return c&&(f+=u+m),f+=ee(W.integer,s),f+=ee(W.decimalsDelimiter,o),f+=ee(W.decimals,n),c||(f+=m+u),f+=ee(W.recurrence,a,null,!0),f+=ee(W.unitType,h,null,!0),f+=ee(W.taxInclusivity,l,!0),ee(e,f,{...d,"aria-label":t})}var Ce=({displayOptical:e=!1,displayStrikethrough:t=!1,displayAnnual:r=!1}={})=>({country:n,displayFormatted:o=!0,displayRecurrence:i=!0,displayPerUnit:s=!1,displayTax:c=!1,language:a,literals:h={}}={},{commitment:l,formatString:d,price:u,priceWithoutDiscount:m,taxDisplay:f,taxTerm:g,term:_,usePrecision:P}={},C={})=>{Object.entries({country:n,formatString:d,language:a,price:u}).forEach(([ae,Ir])=>{if(Ir==null)throw new Error(`Argument "${ae}" is missing`)});let A={...Ka,...h},I=`${a.toLowerCase()}-${n.toUpperCase()}`;function S(ae,Ir){let kr=A[ae];if(kr==null)return"";try{return new si(kr.replace(tc,""),I).format(Ir)}catch{return ec.error("Failed to format literal:",kr),""}}let $=t&&m?m:u,z=e?fi:gi;r&&(z=xi);let{accessiblePrice:X,recurrenceTerm:ie,...ue}=z({commitment:l,formatString:d,term:_,price:e?u:$,usePrecision:P,isIndianPrice:n==="IN"}),Z=X,_e="";if(w(i)&&ie){let ae=S(Pe.recurrenceAriaLabel,{recurrenceTerm:ie});ae&&(Z+=" "+ae),_e=S(Pe.recurrenceLabel,{recurrenceTerm:ie})}let we="";if(w(s)){we=S(Pe.perUnitLabel,{perUnit:"LICENSE"});let ae=S(Pe.perUnitAriaLabel,{perUnit:"LICENSE"});ae&&(Z+=" "+ae)}let se="";w(c)&&g&&(se=S(f===rc?Pe.taxExclusiveLabel:Pe.taxInclusiveLabel,{taxTerm:g}),se&&(Z+=" "+se)),t&&(Z=S(Pe.strikethroughAriaLabel,{strikethroughPrice:Z}));let J=W.container;if(e&&(J+=" "+W.containerOptical),t&&(J+=" "+W.containerStrikethrough),r&&(J+=" "+W.containerAnnual),w(o))return oc(J,{...ue,accessibleLabel:Z,recurrenceLabel:_e,perUnitLabel:we,taxInclusivityLabel:se},C);let{currencySymbol:Ge,decimals:Ut,decimalsDelimiter:Dt,hasCurrencySpace:ct,integer:Rr,isCurrencyFirst:Is}=ue,Ve=[Rr,Dt,Ut];Is?(Ve.unshift(ct?"\xA0":""),Ve.unshift(Ge)):(Ve.push(ct?"\xA0":""),Ve.push(Ge)),Ve.push(_e,we,se);let ks=Ve.join("");return ee(J,ks,C)},vi=()=>(e,t,r)=>{let o=(e.displayOldPrice===void 0||w(e.displayOldPrice))&&t.priceWithoutDiscount&&t.priceWithoutDiscount!=t.price;return`${Ce()(e,t,r)}${o?" "+Ce({displayStrikethrough:!0})(e,t,r):""}`};var vn=Ce(),yn=vi(),En=Ce({displayOptical:!0}),bn=Ce({displayStrikethrough:!0}),_n=Ce({displayAnnual:!0});var ic=(e,t)=>{if(!(!qe(e)||!qe(t)))return Math.floor((t-e)/t*100)},yi=()=>(e,t,r)=>{let{price:n,priceWithoutDiscount:o}=t,i=ic(n,o);return i===void 0?'':`${i}%`};var wn=yi();var{freeze:vt}=Object,ce=vt({...Ae}),le=vt({...Y}),$e={STAGE:"STAGE",PRODUCTION:"PRODUCTION",LOCAL:"LOCAL"},Ei=vt({...k}),bi=vt({...Ro}),_i=vt({...L});var Ln={};Us(Ln,{CLASS_NAME_FAILED:()=>er,CLASS_NAME_PENDING:()=>tr,CLASS_NAME_RESOLVED:()=>rr,ERROR_MESSAGE_BAD_REQUEST:()=>nr,ERROR_MESSAGE_MISSING_LITERALS_URL:()=>Sn,ERROR_MESSAGE_OFFER_NOT_FOUND:()=>An,EVENT_TYPE_ERROR:()=>sc,EVENT_TYPE_FAILED:()=>or,EVENT_TYPE_PENDING:()=>ir,EVENT_TYPE_READY:()=>Ze,EVENT_TYPE_RESOLVED:()=>sr,LOG_NAMESPACE:()=>Tn,Landscape:()=>Je,PARAM_AOS_API_KEY:()=>ac,PARAM_ENV:()=>Pn,PARAM_LANDSCAPE:()=>Cn,PARAM_WCS_API_KEY:()=>cc,STATE_FAILED:()=>te,STATE_PENDING:()=>re,STATE_RESOLVED:()=>ne,TAG_NAME_SERVICE:()=>fe,WCS_PROD_URL:()=>$n,WCS_STAGE_URL:()=>On});var er="placeholder-failed",tr="placeholder-pending",rr="placeholder-resolved",nr="Bad WCS request",An="Commerce offer not found",Sn="Literals URL not provided",sc="wcms:commerce:error",or="wcms:placeholder:failed",ir="wcms:placeholder:pending",Ze="wcms:commerce:ready",sr="wcms:placeholder:resolved",Tn="wcms/commerce",Pn="commerce.env",Cn="commerce.landscape",ac="commerce.aosKey",cc="commerce.wcsKey",$n="https://www.adobe.com/web_commerce_artifact",On="https://www.stage.adobe.com/web_commerce_artifact_stage",te="failed",re="pending",ne="resolved",fe="wcms-commerce",Je={DRAFT:"DRAFT",PUBLISHED:"PUBLISHED"};var Nn={clientId:"merch-at-scale",delimiter:"\xB6",ignoredProperties:["analytics","literals"],serializableTypes:["Array","Object"],sampleRate:30,tags:"consumer=milo/commerce"},wi=new Set,lc=e=>e instanceof Error||typeof e.originatingRequest=="string";function Ai(e){if(e==null)return;let t=typeof e;if(t==="function"){let{name:r}=e;return r?`${t} ${r}`:t}if(t==="object"){if(e instanceof Error)return e.message;if(typeof e.originatingRequest=="string"){let{message:n,originatingRequest:o,status:i}=e;return[n,i,o].filter(s=>s).join(" ")}let r=e[Symbol.toStringTag]??Object.getPrototypeOf(e).constructor.name;if(!Nn.serializableTypes.includes(r))return r}return e}function hc(e,t){if(!Nn.ignoredProperties.includes(e))return Ai(t)}var Rn={append(e){let{delimiter:t,sampleRate:r,tags:n,clientId:o}=Nn,{message:i,params:s}=e,c=[],a=i,h=[];s.forEach(u=>{u!=null&&(lc(u)?c:h).push(u)}),c.length&&(a+=" ",a+=c.map(Ai).join(" "));let{pathname:l,search:d}=window.location;a+=`${t}page=`,a+=l+d,h.length&&(a+=`${t}facts=`,a+=JSON.stringify(h,hc)),wi.has(a)||(wi.add(a),window.lana?.log(a,{sampleRate:r,tags:n,clientId:o}))}};var b=Object.freeze({checkoutClientId:"adobe_com",checkoutWorkflow:ce.V3,checkoutWorkflowStep:le.EMAIL,country:"US",displayOldPrice:!0,displayPerUnit:!1,displayRecurrence:!0,displayTax:!1,env:$e.PRODUCTION,forceTaxExclusive:!1,language:"en",entitlement:!1,extraOptions:{},modal:!1,promotionCode:"",quantity:1,wcsApiKey:"wcms-commerce-ims-ro-user-milo",wcsBufferDelay:1,wcsURL:"https://www.adobe.com/web_commerce_artifact",landscape:Je.PUBLISHED,wcsBufferLimit:1});function Si(e,{once:t=!1}={}){let r=null;function n(){let o=document.querySelector(fe);o!==r&&(r=o,o&&e(o))}return document.addEventListener(Ze,n,{once:t}),ge(n),()=>document.removeEventListener(Ze,n)}function yt(e,{country:t,forceTaxExclusive:r,perpetual:n}){let o;if(e.length<2)o=e;else{let i=t==="GB"||n?"EN":"MULT",[s,c]=e;o=[s.language===i?s:c]}return r&&(o=o.map(en)),o}var ge=e=>window.setTimeout(e);function Qe(e,t=1){if(e==null)return[t];let r=(Array.isArray(e)?e:String(e).split(",")).map(Xe).filter(qe);return r.length||(r=[t]),r}function ar(e){return e==null?[]:(Array.isArray(e)?e:String(e).split(",")).filter(Wr)}function G(){return window.customElements.get(fe)?.instance}var dc="en_US",p={ar:"AR_es",be_en:"BE_en",be_fr:"BE_fr",be_nl:"BE_nl",br:"BR_pt",ca:"CA_en",ch_de:"CH_de",ch_fr:"CH_fr",ch_it:"CH_it",cl:"CL_es",co:"CO_es",la:"DO_es",mx:"MX_es",pe:"PE_es",africa:"MU_en",dk:"DK_da",de:"DE_de",ee:"EE_et",eg_ar:"EG_ar",eg_en:"EG_en",es:"ES_es",fr:"FR_fr",gr_el:"GR_el",gr_en:"GR_en",ie:"IE_en",il_he:"IL_iw",it:"IT_it",lv:"LV_lv",lt:"LT_lt",lu_de:"LU_de",lu_en:"LU_en",lu_fr:"LU_fr",my_en:"MY_en",my_ms:"MY_ms",hu:"HU_hu",mt:"MT_en",mena_en:"DZ_en",mena_ar:"DZ_ar",nl:"NL_nl",no:"NO_nb",pl:"PL_pl",pt:"PT_pt",ro:"RO_ro",si:"SI_sl",sk:"SK_sk",fi:"FI_fi",se:"SE_sv",tr:"TR_tr",uk:"GB_en",at:"AT_de",cz:"CZ_cs",bg:"BG_bg",ru:"RU_ru",ua:"UA_uk",au:"AU_en",in_en:"IN_en",in_hi:"IN_hi",id_en:"ID_en",id_id:"ID_in",nz:"NZ_en",sa_ar:"SA_ar",sa_en:"SA_en",sg:"SG_en",cn:"CN_zh-Hans",tw:"TW_zh-Hant",hk_zh:"HK_zh-hant",jp:"JP_ja",kr:"KR_ko",za:"ZA_en",ng:"NG_en",cr:"CR_es",ec:"EC_es",pr:"US_es",gt:"GT_es",cis_en:"AZ_en",cis_ru:"AZ_ru",sea:"SG_en",th_en:"TH_en",th_th:"TH_th"},cr=Object.freeze({LOCAL:"local",PROD:"prod",STAGE:"stage"});function uc({locale:e={}}={}){if(!e.prefix)return{country:b.country,language:b.language,locale:dc};let t=e.prefix.replace("/","")??"",[r=b.country,n=b.language]=(p[t]??t).split("_",2);return r=r.toUpperCase(),n=n.toLowerCase(),{country:r,language:n,locale:`${n}_${r}`}}function Ti(e={}){let{commerce:t={},locale:r=void 0}=e,n=$e.PRODUCTION,o=$n,i=["local","stage"].includes(e.env?.name),s=N(Pn,t,{metadata:!1})?.toLowerCase()==="stage";i&&s&&(n=$e.STAGE,o=On);let c=N("checkoutClientId",t)??b.checkoutClientId,a=pe(N("checkoutWorkflow",t),ce,b.checkoutWorkflow),h=le.CHECKOUT;a===ce.V3&&(h=pe(N("checkoutWorkflowStep",t),le,b.checkoutWorkflowStep));let l=w(N("displayOldPrice",t),b.displayOldPrice),d=w(N("displayPerUnit",t),b.displayPerUnit),u=w(N("displayRecurrence",t),b.displayRecurrence),m=w(N("displayTax",t),b.displayTax),f=w(N("entitlement",t),b.entitlement),g=w(N("modal",t),b.modal),_=w(N("forceTaxExclusive",t),b.forceTaxExclusive),P=N("promotionCode",t)??b.promotionCode,C=Qe(N("quantity",t)),A=N("wcsApiKey",t)??b.wcsApiKey,I=e.env?.name===cr.PROD?Je.PUBLISHED:pe(N(Cn,t),Je,b.landscape),S=Xe(N("wcsBufferDelay",t),b.wcsBufferDelay),$=Xe(N("wcsBufferLimit",t),b.wcsBufferLimit);return{...uc({locale:r}),displayOldPrice:l,checkoutClientId:c,checkoutWorkflow:a,checkoutWorkflowStep:h,displayPerUnit:d,displayRecurrence:u,displayTax:m,entitlement:f,extraOptions:b.extraOptions,modal:g,env:n,forceTaxExclusive:_,priceLiteralsURL:t.priceLiteralsURL,priceLiteralsPromise:t.priceLiteralsPromise,promotionCode:P,quantity:C,wcsApiKey:A,wcsBufferDelay:S,wcsBufferLimit:$,wcsURL:o,landscape:I}}var Ci="debug",mc="error",pc="info",fc="warn",gc=Date.now(),In=new Set,kn=new Set,Pi=new Map,Et=Object.freeze({DEBUG:Ci,ERROR:mc,INFO:pc,WARN:fc}),$i={append({level:e,message:t,params:r,timestamp:n,source:o}){console[e](`${n}ms [${o}] %c${t}`,"font-weight: bold;",...r)}},Oi={filter:({level:e})=>e!==Ci},xc={filter:()=>!1};function vc(e,t,r,n,o){return{level:e,message:t,namespace:r,get params(){if(n.length===1){let[i]=n;me(i)&&(n=i(),Array.isArray(n)||(n=[n]))}return n},source:o,timestamp:Date.now()-gc}}function yc(e){[...kn].every(t=>t(e))&&In.forEach(t=>t(e))}function Li(e){let t=(Pi.get(e)??0)+1;Pi.set(e,t);let r=`${e} #${t}`,n=i=>(s,...c)=>yc(vc(i,s,e,c,r)),o=Object.seal({id:r,namespace:e,module(i){return Li(`${o.namespace}/${i}`)},debug:n(Et.DEBUG),error:n(Et.ERROR),info:n(Et.INFO),warn:n(Et.WARN)});return o}function lr(...e){e.forEach(t=>{let{append:r,filter:n}=t;me(n)?kn.add(n):me(r)&&In.add(r)})}function Ec(e={}){let{name:t}=e,r=w(N("commerce.debug",{search:!0,storage:!0}),t===cr.LOCAL);return lr(r?$i:Oi),t===cr.PROD&&lr(Rn),F}function bc(){In.clear(),kn.clear()}var F={...Li(Tn),Level:Et,Plugins:{consoleAppender:$i,debugFilter:Oi,quietFilter:xc,lanaAppender:Rn},init:Ec,reset:bc,use:lr};var _c={CLASS_NAME_FAILED:er,CLASS_NAME_PENDING:tr,CLASS_NAME_RESOLVED:rr,EVENT_TYPE_FAILED:or,EVENT_TYPE_PENDING:ir,EVENT_TYPE_RESOLVED:sr,STATE_FAILED:te,STATE_PENDING:re,STATE_RESOLVED:ne},wc={[te]:er,[re]:tr,[ne]:rr},Ac={[te]:or,[re]:ir,[ne]:sr},ur=new WeakMap;function V(e){if(!ur.has(e)){let t=F.module(e.constructor.is);ur.set(e,{changes:new Map,connected:!1,dispose:We,error:void 0,log:t,options:void 0,promises:[],state:re,timer:null,value:void 0,version:0})}return ur.get(e)}function hr(e){let t=V(e),{error:r,promises:n,state:o}=t;(o===ne||o===te)&&(t.promises=[],o===ne?n.forEach(({resolve:i})=>i(e)):o===te&&n.forEach(({reject:i})=>i(r))),e.dispatchEvent(new CustomEvent(Ac[o],{bubbles:!0}))}function dr(e){let t=ur.get(e);[te,re,ne].forEach(r=>{e.classList.toggle(wc[r],r===t.state)})}var Sc={get error(){return V(this).error},get log(){return V(this).log},get options(){return V(this).options},get state(){return V(this).state},get value(){return V(this).value},attributeChangedCallback(e,t,r){V(this).changes.set(e,r),this.requestUpdate()},connectedCallback(){V(this).dispose=Si(()=>this.requestUpdate(!0))},disconnectedCallback(){let e=V(this);e.connected&&(e.connected=!1,e.log.debug("Disconnected:",{element:this})),e.dispose(),e.dispose=We},onceSettled(){let{error:e,promises:t,state:r}=V(this);return ne===r?Promise.resolve(this):te===r?Promise.reject(e):new Promise((n,o)=>{t.push({resolve:n,reject:o})})},toggleResolved(e,t,r){let n=V(this);return e!==n.version?!1:(r!==void 0&&(n.options=r),n.state=ne,n.value=t,dr(this),this.log.debug("Resolved:",{element:this,value:t}),ge(()=>hr(this)),!0)},toggleFailed(e,t,r){let n=V(this);return e!==n.version?!1:(r!==void 0&&(n.options=r),n.error=t,n.state=te,dr(this),n.log.error("Failed:",{element:this,error:t}),ge(()=>hr(this)),!0)},togglePending(e){let t=V(this);return t.version++,e&&(t.options=e),t.state=re,dr(this),ge(()=>hr(this)),t.version},requestUpdate(e=!1){if(!this.isConnected||!G())return;let t=V(this);if(t.timer)return;let{error:r,options:n,state:o,value:i,version:s}=t;t.state=re,t.timer=ge(async()=>{t.timer=null;let c=null;if(t.changes.size&&(c=Object.fromEntries(t.changes.entries()),t.changes.clear()),t.connected?t.log.debug("Updated:",{element:this,changes:c}):(t.connected=!0,t.log.debug("Connected:",{element:this,changes:c})),c||e)try{await this.render?.()===!1&&t.state===re&&t.version===s&&(t.state=o,t.error=r,t.value=i,dr(this),hr(this))}catch(a){this.toggleFailed(t.version,a,n)}})}};function Ni(e={}){return Object.entries(e).forEach(([t,r])=>{(r==null||r===""||r?.length===0)&&delete e[t]}),e}function mr(e,t={}){let{tag:r,is:n}=e,o=document.createElement(r,{is:n});return o.setAttribute("is",n),Object.assign(o.dataset,Ni(t)),o}function pr(e){let{tag:t,is:r,prototype:n}=e,o=window.customElements.get(r);return o||(Object.defineProperties(n,Object.getOwnPropertyDescriptors(Sc)),o=Object.defineProperties(e,Object.getOwnPropertyDescriptors(_c)),window.customElements.define(r,o,{extends:t})),o}function fr(e,t=document.body){return Array.from(t?.querySelectorAll(`${e.tag}[is="${e.is}"]`)??[])}function gr(e,t={}){return e instanceof HTMLElement?(Object.assign(e.dataset,Ni(t)),e):null}var Tc="download",Pc="upgrade",Oe,Ke=class Ke extends HTMLAnchorElement{constructor(){super();Q(this,Oe);this.addEventListener("click",this.clickHandler)}static get observedAttributes(){return["data-checkout-workflow","data-checkout-workflow-step","data-extra-options","data-ims-country","data-perpetual","data-promotion-code","data-quantity","data-template","data-wcs-osi","data-entitlement","data-upgrade","data-modal"]}static createCheckoutLink(r={},n=""){let o=G();if(!o)return null;let{checkoutMarketSegment:i,checkoutWorkflow:s,checkoutWorkflowStep:c,entitlement:a,upgrade:h,modal:l,perpetual:d,promotionCode:u,quantity:m,wcsOsi:f,extraOptions:g}=o.collectCheckoutOptions(r),_=mr(Ke,{checkoutMarketSegment:i,checkoutWorkflow:s,checkoutWorkflowStep:c,entitlement:a,upgrade:h,modal:l,perpetual:d,promotionCode:u,quantity:m,wcsOsi:f,extraOptions:g});return n&&(_.innerHTML=`${n}`),_}static getCheckoutLinks(r){return fr(Ke,r)}get isCheckoutLink(){return!0}get placeholder(){return this}clickHandler(r){var n;(n=R(this,Oe))==null||n.call(this,r)}async render(r={}){if(!this.isConnected)return!1;let n=G();if(!n)return!1;this.dataset.imsCountry||n.imsCountryPromise.then(l=>{l&&(this.dataset.imsCountry=l)},We);let o=n.collectCheckoutOptions(r,this.placeholder);if(!o.wcsOsi.length)return!1;let i;try{i=JSON.parse(o.extraOptions??"{}")}catch(l){this.placeholder.log.error("cannot parse exta checkout options",l)}let s=this.placeholder.togglePending(o);this.href="";let c=n.resolveOfferSelectors(o),a=await Promise.all(c);a=a.map(l=>yt(l,o));let h=await n.buildCheckoutAction(a.flat(),{...i,...o});return this.renderOffers(a.flat(),o,{},h,s)}renderOffers(r,n,o={},i=void 0,s=void 0){if(!this.isConnected)return!1;let c=G();if(!c)return!1;if(n={...JSON.parse(this.placeholder.dataset.extraOptions??"null"),...n,...o},s??(s=this.placeholder.togglePending(n)),R(this,Oe)&&K(this,Oe,void 0),i){this.classList.remove(Tc,Pc),this.placeholder.toggleResolved(s,r,n);let{url:h,text:l,className:d,handler:u}=i;return h&&(this.href=h),l&&(this.firstElementChild.innerHTML=l),d&&this.classList.add(...d.split(" ")),u&&(this.setAttribute("href","#"),K(this,Oe,u.bind(this))),!0}else if(r.length){if(this.placeholder.toggleResolved(s,r,n)){let h=c.buildCheckoutURL(r,n);return this.setAttribute("href",h),!0}}else{let h=new Error(`Not provided: ${n?.wcsOsi??"-"}`);if(this.placeholder.toggleFailed(s,h,n))return this.setAttribute("href","#"),!0}return!1}updateOptions(r={}){let n=G();if(!n)return!1;let{checkoutMarketSegment:o,checkoutWorkflow:i,checkoutWorkflowStep:s,entitlement:c,upgrade:a,modal:h,perpetual:l,promotionCode:d,quantity:u,wcsOsi:m}=n.collectCheckoutOptions(r);return gr(this,{checkoutMarketSegment:o,checkoutWorkflow:i,checkoutWorkflowStep:s,entitlement:c,upgrade:a,modal:h,perpetual:l,promotionCode:d,quantity:u,wcsOsi:m}),!0}};Oe=new WeakMap,O(Ke,"is","checkout-link"),O(Ke,"tag","a");var Mn=Ke,Un=pr(Mn);var Ri=[p.uk,p.au,p.fr,p.at,p.be_en,p.be_fr,p.be_nl,p.bg,p.ch_de,p.ch_fr,p.ch_it,p.cz,p.de,p.dk,p.ee,p.eg_ar,p.eg_en,p.es,p.fi,p.fr,p.gr_el,p.gr_en,p.hu,p.ie,p.it,p.lu_de,p.lu_en,p.lu_fr,p.nl,p.no,p.pl,p.pt,p.ro,p.se,p.si,p.sk,p.tr,p.ua,p.id_en,p.id_id,p.in_en,p.in_hi,p.jp,p.my_en,p.my_ms,p.nz,p.th_en,p.th_th],Cc={INDIVIDUAL_COM:[p.za,p.lt,p.lv,p.ng,p.sa_ar,p.sa_en,p.za,p.sg,p.kr],TEAM_COM:[p.za,p.lt,p.lv,p.ng,p.za,p.co,p.kr],INDIVIDUAL_EDU:[p.lt,p.lv,p.sa_en,p.sea],TEAM_EDU:[p.sea,p.kr]},et=class et extends HTMLSpanElement{static get observedAttributes(){return["data-display-old-price","data-display-per-unit","data-display-recurrence","data-display-tax","data-perpetual","data-promotion-code","data-tax-exclusive","data-template","data-wcs-osi"]}static createInlinePrice(t){let r=G();if(!r)return null;let{displayOldPrice:n,displayPerUnit:o,displayRecurrence:i,displayTax:s,forceTaxExclusive:c,perpetual:a,promotionCode:h,quantity:l,template:d,wcsOsi:u}=r.collectPriceOptions(t);return mr(et,{displayOldPrice:n,displayPerUnit:o,displayRecurrence:i,displayTax:s,forceTaxExclusive:c,perpetual:a,promotionCode:h,quantity:l,template:d,wcsOsi:u})}static getInlinePrices(t){return fr(et,t)}get isInlinePrice(){return!0}get placeholder(){return this}resolveDisplayTaxForGeoAndSegment(t,r,n,o){let i=`${t}_${r}`;if(Ri.includes(t)||Ri.includes(i))return!0;let s=Cc[`${n}_${o}`];return s?!!(s.includes(t)||s.includes(i)):!1}async resolveDisplayTax(t,r){let[n]=await t.resolveOfferSelectors(r),o=yt(await n,r);if(o?.length){let{country:i,language:s}=r,c=o[0],[a=""]=c.marketSegments;return this.resolveDisplayTaxForGeoAndSegment(i,s,c.customerSegment,a)}}async render(t={}){if(!this.isConnected)return!1;let r=G();if(!r)return!1;let n=r.collectPriceOptions(t,this.placeholder);if(!n.wcsOsi.length)return!1;let o=this.placeholder.togglePending(n);this.innerHTML="";let[i]=r.resolveOfferSelectors(n);return this.renderOffers(yt(await i,n),n,o)}renderOffers(t,r={},n=void 0){if(!this.isConnected)return;let o=G();if(!o)return!1;let i=o.collectPriceOptions({...this.dataset,...r});if(n??(n=this.placeholder.togglePending(i)),t.length){if(this.placeholder.toggleResolved(n,t,i))return this.innerHTML=o.buildPriceHTML(t,i),!0}else{let s=new Error(`Not provided: ${i?.wcsOsi??"-"}`);if(this.placeholder.toggleFailed(n,s,i))return this.innerHTML="",!0}return!1}updateOptions(t){let r=G();if(!r)return!1;let{displayOldPrice:n,displayPerUnit:o,displayRecurrence:i,displayTax:s,forceTaxExclusive:c,perpetual:a,promotionCode:h,quantity:l,template:d,wcsOsi:u}=r.collectPriceOptions(t);return gr(this,{displayOldPrice:n,displayPerUnit:o,displayRecurrence:i,displayTax:s,forceTaxExclusive:c,perpetual:a,promotionCode:h,quantity:l,template:d,wcsOsi:u}),!0}};O(et,"is","inline-price"),O(et,"tag","span");var Dn=et,Fn=pr(Dn);function Ii({providers:e,settings:t},r){let n=F.module("checkout");function o(h,l){let{checkoutClientId:d,checkoutWorkflow:u,checkoutWorkflowStep:m,country:f,language:g,promotionCode:_,quantity:P}=t,{checkoutMarketSegment:C,checkoutWorkflow:A=u,checkoutWorkflowStep:I=m,imsCountry:S,country:$=S??f,language:z=g,quantity:X=P,entitlement:ie,upgrade:ue,modal:Z,perpetual:_e,promotionCode:we=_,wcsOsi:se,extraOptions:J,...Ge}=Object.assign({},l?.dataset??{},h??{}),Ut=pe(A,ce,b.checkoutWorkflow),Dt=le.CHECKOUT;Ut===ce.V3&&(Dt=pe(I,le,b.checkoutWorkflowStep));let ct=Ye({...Ge,extraOptions:J,checkoutClientId:d,checkoutMarketSegment:C,country:$,quantity:Qe(X,b.quantity),checkoutWorkflow:Ut,checkoutWorkflowStep:Dt,language:z,entitlement:w(ie),upgrade:w(ue),modal:w(Z),perpetual:w(_e),promotionCode:dt(we).effectivePromoCode,wcsOsi:ar(se)});if(l)for(let Rr of e.checkout)Rr(l,ct);return ct}async function i(h,l){let d=G(),u=await r.getCheckoutAction?.(h,l,d.imsSignedInPromise);return u||null}function s(h,l){if(!Array.isArray(h)||!h.length||!l)return"";let{env:d,landscape:u}=t,{checkoutClientId:m,checkoutMarketSegment:f,checkoutWorkflow:g,checkoutWorkflowStep:_,country:P,promotionCode:C,quantity:A,...I}=o(l),S=window.frameElement?"if":"fp",$={checkoutPromoCode:C,clientId:m,context:S,country:P,env:d,items:[],marketSegment:f,workflowStep:_,landscape:u,...I};if(h.length===1){let[{offerId:z,offerType:X,productArrangementCode:ie}]=h,{marketSegments:[ue]}=h[0];Object.assign($,{marketSegment:ue,offerType:X,productArrangementCode:ie}),$.items.push(A[0]===1?{id:z}:{id:z,quantity:A[0]})}else $.items.push(...h.map(({offerId:z},X)=>({id:z,quantity:A[X]??b.quantity})));return Hr(g,$)}let{createCheckoutLink:c,getCheckoutLinks:a}=Un;return{CheckoutLink:Un,CheckoutWorkflow:ce,CheckoutWorkflowStep:le,buildCheckoutAction:i,buildCheckoutURL:s,collectCheckoutOptions:o,createCheckoutLink:c,getCheckoutLinks:a}}function $c({interval:e=200,maxAttempts:t=25}={}){let r=F.module("ims");return new Promise(n=>{r.debug("Waing for IMS to be ready");let o=0;function i(){window.adobeIMS?.initialized?n():++o>t?(r.debug("Timeout"),n()):setTimeout(i,e)}i()})}function Oc(e){return e.then(()=>window.adobeIMS?.isSignedInUser()??!1)}function Lc(e){let t=F.module("ims");return e.then(r=>r?window.adobeIMS.getProfile().then(({countryCode:n})=>(t.debug("Got user country:",n),n),n=>{t.error("Unable to get user country:",n)}):null)}function ki({}){let e=$c(),t=Oc(e),r=Lc(t);return{imsReadyPromise:e,imsSignedInPromise:t,imsCountryPromise:r}}function Nc(e){if(!e.priceLiteralsURL)throw new Error(Sn);return new Promise(t=>{window.fetch(e.priceLiteralsURL).then(r=>{r.json().then(({data:n})=>{t(n)})})})}async function Mi(e){let r=await(e.priceLiteralsPromise||Nc(e));if(Array.isArray(r)){let n=i=>r.find(s=>zt(s.lang,i)),o=n(e.language)??n(b.language);if(o)return Object.freeze(o)}return{}}function Ui({literals:e,providers:t,settings:r}){function n(c,a){let{country:h,displayOldPrice:l,displayPerUnit:d,displayRecurrence:u,displayTax:m,forceTaxExclusive:f,language:g,promotionCode:_,quantity:P}=r,{displayOldPrice:C=l,displayPerUnit:A=d,displayRecurrence:I=u,displayTax:S=m,forceTaxExclusive:$=f,country:z=h,language:X=g,perpetual:ie,promotionCode:ue=_,quantity:Z=P,template:_e,wcsOsi:we,...se}=Object.assign({},a?.dataset??{},c??{}),J=Ye({...se,country:z,displayOldPrice:w(C),displayPerUnit:w(A),displayRecurrence:w(I),displayTax:w(S),forceTaxExclusive:w($),language:X,perpetual:w(ie),promotionCode:dt(ue).effectivePromoCode,quantity:Qe(Z,b.quantity),template:_e,wcsOsi:ar(we)});if(a)for(let Ge of t.price)Ge(a,J);return J}function o(c,a){if(!Array.isArray(c)||!c.length||!a)return"";let{template:h}=a,l;switch(h){case"discount":l=wn;break;case"strikethrough":l=bn;break;case"optical":l=En;break;case"annual":l=_n;break;default:l=a.promotionCode?yn:vn}let d=n(a);d.literals=Object.assign({},e.price,Ye(a.literals??{}));let[u]=c;return u={...u,...u.priceDetails},l(d,u)}let{createInlinePrice:i,getInlinePrices:s}=Fn;return{InlinePrice:Fn,buildPriceHTML:o,collectPriceOptions:n,createInlinePrice:i,getInlinePrices:s}}function Di({settings:e}){let t=F.module("wcs"),{env:r,wcsApiKey:n}=e,o=new Map,i=new Map,s;async function c(l,d,u=!0){let m=An;t.debug("Fetching:",l);try{l.offerSelectorIds=l.offerSelectorIds.sort();let f=new URL(e.wcsURL);f.searchParams.set("offer_selector_ids",l.offerSelectorIds.join(",")),f.searchParams.set("country",l.country),f.searchParams.set("locale",l.locale),f.searchParams.set("landscape",r===$e.STAGE?"ALL":e.landscape),f.searchParams.set("api_key",n),l.language&&f.searchParams.set("language",l.language),l.promotionCode&&f.searchParams.set("promotion_code",l.promotionCode),l.currency&&f.searchParams.set("currency",l.currency);let g=await fetch(f.toString(),{credentials:"omit"});if(g.ok){let _=await g.json();t.debug("Fetched:",l,_);let P=_.resolvedOffers??[];P=P.map(Kr),d.forEach(({resolve:C},A)=>{let I=P.filter(({offerSelectorIds:S})=>S.includes(A)).flat();I.length&&(d.delete(A),C(I))})}else g.status===404&&l.offerSelectorIds.length>1?(t.debug("Multi-osi 404, fallback to fetch-by-one strategy"),await Promise.allSettled(l.offerSelectorIds.map(_=>c({...l,offerSelectorIds:[_]},d,!1)))):(m=nr,t.error(m,l))}catch(f){m=nr,t.error(m,l,f)}u&&d.size&&(t.debug("Missing:",{offerSelectorIds:[...d.keys()]}),d.forEach(f=>{f.reject(new Error(m))}))}function a(){clearTimeout(s);let l=[...i.values()];i.clear(),l.forEach(({options:d,promises:u})=>c(d,u))}function h({country:l,language:d,perpetual:u=!1,promotionCode:m="",wcsOsi:f=[]}){let g=`${d}_${l}`;l!=="GB"&&(d=u?"EN":"MULT");let _=[l,d,m].filter(P=>P).join("-").toLowerCase();return f.map(P=>{let C=`${P}-${_}`;if(!o.has(C)){let A=new Promise((I,S)=>{let $=i.get(_);if(!$){let z={country:l,locale:g,offerSelectorIds:[]};l!=="GB"&&(z.language=d),$={options:z,promises:new Map},i.set(_,$)}m&&($.options.promotionCode=m),$.options.offerSelectorIds.push(P),$.promises.set(P,{resolve:I,reject:S}),$.options.offerSelectorIds.length>=e.wcsBufferLimit?a():(t.debug("Queued:",$.options),s||(s=setTimeout(a,e.wcsBufferDelay)))});o.set(C,A)}return o.get(C)})}return{WcsCommitment:Ei,WcsPlanType:bi,WcsTerm:_i,resolveOfferSelectors:h}}var j=class extends HTMLElement{get isWcmsCommerce(){return!0}};O(j,"instance"),O(j,"promise",null);window.customElements.define(fe,j);async function Rc(e,t){let r=F.init(e.env).module("service");r.debug("Activating:",e);let n={price:{}},o=Object.freeze(Ti(e));try{n.price=await Mi(o)}catch(a){r.warn("Price literals were not fetched:",a)}let i={checkout:new Set,price:new Set},s=document.createElement(fe),c={literals:n,providers:i,settings:o};return j.instance=Object.defineProperties(s,Object.getOwnPropertyDescriptors({...Ii(c,t),...ki(c),...Ui(c),...Di(c),...Ln,Log:F,get defaults(){return b},get literals(){return n},get log(){return F},get providers(){return{checkout(a){return i.checkout.add(a),()=>i.checkout.delete(a)},price(a){return i.price.add(a),()=>i.price.delete(a)}}},get settings(){return o}})),r.debug("Activated:",{literals:n,settings:o,element:s}),document.head.append(s),ge(()=>{let a=new CustomEvent(Ze,{bubbles:!0,cancelable:!1,detail:j.instance});j.instance.dispatchEvent(a)}),j.instance}function Fi(){document.head.querySelector(fe)?.remove(),j.promise=null,F.reset()}function bt(e,t){let r=me(e)?e():null,n=me(t)?t():{};return r&&(n.force&&Fi(),Rc(r,n).then(o=>{bt.resolve(o)})),j.promise??(j.promise=new Promise(o=>{bt.resolve=o})),j.promise}var xr=window,yr=xr.ShadowRoot&&(xr.ShadyCSS===void 0||xr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,zi=Symbol(),Hi=new WeakMap,vr=class{constructor(t,r,n){if(this._$cssResult$=!0,n!==zi)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=r}get styleSheet(){let t=this.o,r=this.t;if(yr&&t===void 0){let n=r!==void 0&&r.length===1;n&&(t=Hi.get(r)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&Hi.set(r,t))}return t}toString(){return this.cssText}},Gi=e=>new vr(typeof e=="string"?e:e+"",void 0,zi);var Hn=(e,t)=>{yr?e.adoptedStyleSheets=t.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet):t.forEach(r=>{let n=document.createElement("style"),o=xr.litNonce;o!==void 0&&n.setAttribute("nonce",o),n.textContent=r.cssText,e.appendChild(n)})},Er=yr?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let r="";for(let n of t.cssRules)r+=n.cssText;return Gi(r)})(e):e;var zn,br=window,Vi=br.trustedTypes,Ic=Vi?Vi.emptyScript:"",ji=br.reactiveElementPolyfillSupport,Vn={toAttribute(e,t){switch(t){case Boolean:e=e?Ic:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=e!==null;break;case Number:r=e===null?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch{r=null}}return r}},Bi=(e,t)=>t!==e&&(t==t||e==e),Gn={attribute:!0,type:String,converter:Vn,reflect:!1,hasChanged:Bi},jn="finalized",Le=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var r;this.finalize(),((r=this.h)!==null&&r!==void 0?r:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((r,n)=>{let o=this._$Ep(n,r);o!==void 0&&(this._$Ev.set(o,n),t.push(o))}),t}static createProperty(t,r=Gn){if(r.state&&(r.attribute=!1),this.finalize(),this.elementProperties.set(t,r),!r.noAccessor&&!this.prototype.hasOwnProperty(t)){let n=typeof t=="symbol"?Symbol():"__"+t,o=this.getPropertyDescriptor(t,n,r);o!==void 0&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,r,n){return{get(){return this[r]},set(o){let i=this[t];this[r]=o,this.requestUpdate(t,i,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Gn}static finalize(){if(this.hasOwnProperty(jn))return!1;this[jn]=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let r=this.properties,n=[...Object.getOwnPropertyNames(r),...Object.getOwnPropertySymbols(r)];for(let o of n)this.createProperty(o,r[o])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let r=[];if(Array.isArray(t)){let n=new Set(t.flat(1/0).reverse());for(let o of n)r.unshift(Er(o))}else t!==void 0&&r.push(Er(t));return r}static _$Ep(t,r){let n=r.attribute;return n===!1?void 0:typeof n=="string"?n:typeof t=="string"?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise(r=>this.enableUpdating=r),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(r=>r(this))}addController(t){var r,n;((r=this._$ES)!==null&&r!==void 0?r:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)===null||n===void 0||n.call(t))}removeController(t){var r;(r=this._$ES)===null||r===void 0||r.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,r)=>{this.hasOwnProperty(r)&&(this._$Ei.set(r,this[r]),delete this[r])})}createRenderRoot(){var t;let r=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return Hn(r,this.constructor.elementStyles),r}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(r=>{var n;return(n=r.hostConnected)===null||n===void 0?void 0:n.call(r)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(r=>{var n;return(n=r.hostDisconnected)===null||n===void 0?void 0:n.call(r)})}attributeChangedCallback(t,r,n){this._$AK(t,n)}_$EO(t,r,n=Gn){var o;let i=this.constructor._$Ep(t,n);if(i!==void 0&&n.reflect===!0){let s=(((o=n.converter)===null||o===void 0?void 0:o.toAttribute)!==void 0?n.converter:Vn).toAttribute(r,n.type);this._$El=t,s==null?this.removeAttribute(i):this.setAttribute(i,s),this._$El=null}}_$AK(t,r){var n;let o=this.constructor,i=o._$Ev.get(t);if(i!==void 0&&this._$El!==i){let s=o.getPropertyOptions(i),c=typeof s.converter=="function"?{fromAttribute:s.converter}:((n=s.converter)===null||n===void 0?void 0:n.fromAttribute)!==void 0?s.converter:Vn;this._$El=i,this[i]=c.fromAttribute(r,s.type),this._$El=null}}requestUpdate(t,r,n){let o=!0;t!==void 0&&(((n=n||this.constructor.getPropertyOptions(t)).hasChanged||Bi)(this[t],r)?(this._$AL.has(t)||this._$AL.set(t,r),n.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,n))):o=!1),!this.isUpdatePending&&o&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(r){Promise.reject(r)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((o,i)=>this[i]=o),this._$Ei=void 0);let r=!1,n=this._$AL;try{r=this.shouldUpdate(n),r?(this.willUpdate(n),(t=this._$ES)===null||t===void 0||t.forEach(o=>{var i;return(i=o.hostUpdate)===null||i===void 0?void 0:i.call(o)}),this.update(n)):this._$Ek()}catch(o){throw r=!1,this._$Ek(),o}r&&this._$AE(n)}willUpdate(t){}_$AE(t){var r;(r=this._$ES)===null||r===void 0||r.forEach(n=>{var o;return(o=n.hostUpdated)===null||o===void 0?void 0:o.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((r,n)=>this._$EO(n,this[n],r)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};Le[jn]=!0,Le.elementProperties=new Map,Le.elementStyles=[],Le.shadowRootOptions={mode:"open"},ji?.({ReactiveElement:Le}),((zn=br.reactiveElementVersions)!==null&&zn!==void 0?zn:br.reactiveElementVersions=[]).push("1.6.3");var Bn,_r=window,tt=_r.trustedTypes,Wi=tt?tt.createPolicy("lit-html",{createHTML:e=>e}):void 0,qn="$lit$",xe=`lit$${(Math.random()+"").slice(9)}$`,Ki="?"+xe,kc=`<${Ki}>`,Ie=document,wr=()=>Ie.createComment(""),wt=e=>e===null||typeof e!="object"&&typeof e!="function",es=Array.isArray,Mc=e=>es(e)||typeof e?.[Symbol.iterator]=="function",Wn=`[ \f\r]`,_t=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,qi=/-->/g,Yi=/>/g,Ne=RegExp(`>|${Wn}(?:([^\\s"'>=/]+)(${Wn}*=${Wn}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),Xi=/'/g,Zi=/"/g,ts=/^(?:script|style|textarea|title)$/i,rs=e=>(t,...r)=>({_$litType$:e,strings:t,values:r}),nu=rs(1),ou=rs(2),At=Symbol.for("lit-noChange"),M=Symbol.for("lit-nothing"),Ji=new WeakMap,Re=Ie.createTreeWalker(Ie,129,null,!1);function ns(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Wi!==void 0?Wi.createHTML(t):t}var Uc=(e,t)=>{let r=e.length-1,n=[],o,i=t===2?"":"",s=_t;for(let c=0;c"?(s=o??_t,d=-1):l[1]===void 0?d=-2:(d=s.lastIndex-l[2].length,h=l[1],s=l[3]===void 0?Ne:l[3]==='"'?Zi:Xi):s===Zi||s===Xi?s=Ne:s===qi||s===Yi?s=_t:(s=Ne,o=void 0);let m=s===Ne&&e[c+1].startsWith("/>")?" ":"";i+=s===_t?a+kc:d>=0?(n.push(h),a.slice(0,d)+qn+a.slice(d)+xe+m):a+xe+(d===-2?(n.push(void 0),c):m)}return[ns(e,i+(e[r]||"")+(t===2?"":"")),n]},St=class e{constructor({strings:t,_$litType$:r},n){let o;this.parts=[];let i=0,s=0,c=t.length-1,a=this.parts,[h,l]=Uc(t,r);if(this.el=e.createElement(h,n),Re.currentNode=this.el.content,r===2){let d=this.el.content,u=d.firstChild;u.remove(),d.append(...u.childNodes)}for(;(o=Re.nextNode())!==null&&a.length0){o.textContent=tt?tt.emptyScript:"";for(let m=0;m2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=M}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,r=this,n,o){let i=this.strings,s=!1;if(i===void 0)t=rt(this,t,r,0),s=!wt(t)||t!==this._$AH&&t!==At,s&&(this._$AH=t);else{let c=t,a,h;for(t=i[0],a=0;anew Tt(typeof e=="string"?e:e+"",void 0,Kn),ke=(e,...t)=>{let r=e.length===1?e[0]:t.reduce((n,o,i)=>n+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+e[i+1],e[0]);return new Tt(r,e,Kn)},eo=(e,t)=>{Tr?e.adoptedStyleSheets=t.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet):t.forEach(r=>{let n=document.createElement("style"),o=Sr.litNonce;o!==void 0&&n.setAttribute("nonce",o),n.textContent=r.cssText,e.appendChild(n)})},Pr=Tr?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let r="";for(let n of t.cssRules)r+=n.cssText;return ve(r)})(e):e;var to,Cr=window,is=Cr.trustedTypes,Fc=is?is.emptyScript:"",ss=Cr.reactiveElementPolyfillSupport,no={toAttribute(e,t){switch(t){case Boolean:e=e?Fc:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=e!==null;break;case Number:r=e===null?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch{r=null}}return r}},as=(e,t)=>t!==e&&(t==t||e==e),ro={attribute:!0,type:String,converter:no,reflect:!1,hasChanged:as},oo="finalized",he=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var r;this.finalize(),((r=this.h)!==null&&r!==void 0?r:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((r,n)=>{let o=this._$Ep(n,r);o!==void 0&&(this._$Ev.set(o,n),t.push(o))}),t}static createProperty(t,r=ro){if(r.state&&(r.attribute=!1),this.finalize(),this.elementProperties.set(t,r),!r.noAccessor&&!this.prototype.hasOwnProperty(t)){let n=typeof t=="symbol"?Symbol():"__"+t,o=this.getPropertyDescriptor(t,n,r);o!==void 0&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,r,n){return{get(){return this[r]},set(o){let i=this[t];this[r]=o,this.requestUpdate(t,i,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||ro}static finalize(){if(this.hasOwnProperty(oo))return!1;this[oo]=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let r=this.properties,n=[...Object.getOwnPropertyNames(r),...Object.getOwnPropertySymbols(r)];for(let o of n)this.createProperty(o,r[o])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let r=[];if(Array.isArray(t)){let n=new Set(t.flat(1/0).reverse());for(let o of n)r.unshift(Pr(o))}else t!==void 0&&r.push(Pr(t));return r}static _$Ep(t,r){let n=r.attribute;return n===!1?void 0:typeof n=="string"?n:typeof t=="string"?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise(r=>this.enableUpdating=r),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(r=>r(this))}addController(t){var r,n;((r=this._$ES)!==null&&r!==void 0?r:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)===null||n===void 0||n.call(t))}removeController(t){var r;(r=this._$ES)===null||r===void 0||r.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,r)=>{this.hasOwnProperty(r)&&(this._$Ei.set(r,this[r]),delete this[r])})}createRenderRoot(){var t;let r=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return eo(r,this.constructor.elementStyles),r}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(r=>{var n;return(n=r.hostConnected)===null||n===void 0?void 0:n.call(r)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(r=>{var n;return(n=r.hostDisconnected)===null||n===void 0?void 0:n.call(r)})}attributeChangedCallback(t,r,n){this._$AK(t,n)}_$EO(t,r,n=ro){var o;let i=this.constructor._$Ep(t,n);if(i!==void 0&&n.reflect===!0){let s=(((o=n.converter)===null||o===void 0?void 0:o.toAttribute)!==void 0?n.converter:no).toAttribute(r,n.type);this._$El=t,s==null?this.removeAttribute(i):this.setAttribute(i,s),this._$El=null}}_$AK(t,r){var n;let o=this.constructor,i=o._$Ev.get(t);if(i!==void 0&&this._$El!==i){let s=o.getPropertyOptions(i),c=typeof s.converter=="function"?{fromAttribute:s.converter}:((n=s.converter)===null||n===void 0?void 0:n.fromAttribute)!==void 0?s.converter:no;this._$El=i,this[i]=c.fromAttribute(r,s.type),this._$El=null}}requestUpdate(t,r,n){let o=!0;t!==void 0&&(((n=n||this.constructor.getPropertyOptions(t)).hasChanged||as)(this[t],r)?(this._$AL.has(t)||this._$AL.set(t,r),n.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,n))):o=!1),!this.isUpdatePending&&o&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(r){Promise.reject(r)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((o,i)=>this[i]=o),this._$Ei=void 0);let r=!1,n=this._$AL;try{r=this.shouldUpdate(n),r?(this.willUpdate(n),(t=this._$ES)===null||t===void 0||t.forEach(o=>{var i;return(i=o.hostUpdate)===null||i===void 0?void 0:i.call(o)}),this.update(n)):this._$Ek()}catch(o){throw r=!1,this._$Ek(),o}r&&this._$AE(n)}willUpdate(t){}_$AE(t){var r;(r=this._$ES)===null||r===void 0||r.forEach(n=>{var o;return(o=n.hostUpdated)===null||o===void 0?void 0:o.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((r,n)=>this._$EO(n,this[n],r)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};he[oo]=!0,he.elementProperties=new Map,he.elementStyles=[],he.shadowRootOptions={mode:"open"},ss?.({ReactiveElement:he}),((to=Cr.reactiveElementVersions)!==null&&to!==void 0?to:Cr.reactiveElementVersions=[]).push("1.6.3");var io,$r=window,ot=$r.trustedTypes,cs=ot?ot.createPolicy("lit-html",{createHTML:e=>e}):void 0,ao="$lit$",ye=`lit$${(Math.random()+"").slice(9)}$`,fs="?"+ye,Hc=`<${fs}>`,De=document,Ct=()=>De.createComment(""),$t=e=>e===null||typeof e!="object"&&typeof e!="function",gs=Array.isArray,zc=e=>gs(e)||typeof e?.[Symbol.iterator]=="function",so=`[ +\f\r"'\`<>=]|("|')|))|$)`,"g"),Xi=/'/g,Zi=/"/g,ts=/^(?:script|style|textarea|title)$/i,rs=e=>(t,...r)=>({_$litType$:e,strings:t,values:r}),ou=rs(1),iu=rs(2),At=Symbol.for("lit-noChange"),M=Symbol.for("lit-nothing"),Ji=new WeakMap,Re=Ie.createTreeWalker(Ie,129,null,!1);function ns(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Wi!==void 0?Wi.createHTML(t):t}var Uc=(e,t)=>{let r=e.length-1,n=[],o,i=t===2?"":"",s=_t;for(let c=0;c"?(s=o??_t,d=-1):l[1]===void 0?d=-2:(d=s.lastIndex-l[2].length,h=l[1],s=l[3]===void 0?Ne:l[3]==='"'?Zi:Xi):s===Zi||s===Xi?s=Ne:s===qi||s===Yi?s=_t:(s=Ne,o=void 0);let m=s===Ne&&e[c+1].startsWith("/>")?" ":"";i+=s===_t?a+kc:d>=0?(n.push(h),a.slice(0,d)+qn+a.slice(d)+xe+m):a+xe+(d===-2?(n.push(void 0),c):m)}return[ns(e,i+(e[r]||"")+(t===2?"":"")),n]},St=class e{constructor({strings:t,_$litType$:r},n){let o;this.parts=[];let i=0,s=0,c=t.length-1,a=this.parts,[h,l]=Uc(t,r);if(this.el=e.createElement(h,n),Re.currentNode=this.el.content,r===2){let d=this.el.content,u=d.firstChild;u.remove(),d.append(...u.childNodes)}for(;(o=Re.nextNode())!==null&&a.length0){o.textContent=tt?tt.emptyScript:"";for(let m=0;m2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=M}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,r=this,n,o){let i=this.strings,s=!1;if(i===void 0)t=rt(this,t,r,0),s=!wt(t)||t!==this._$AH&&t!==At,s&&(this._$AH=t);else{let c=t,a,h;for(t=i[0],a=0;anew Tt(typeof e=="string"?e:e+"",void 0,Kn),ke=(e,...t)=>{let r=e.length===1?e[0]:t.reduce((n,o,i)=>n+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+e[i+1],e[0]);return new Tt(r,e,Kn)},eo=(e,t)=>{Tr?e.adoptedStyleSheets=t.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet):t.forEach(r=>{let n=document.createElement("style"),o=Sr.litNonce;o!==void 0&&n.setAttribute("nonce",o),n.textContent=r.cssText,e.appendChild(n)})},Pr=Tr?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let r="";for(let n of t.cssRules)r+=n.cssText;return ve(r)})(e):e;var to,Cr=window,is=Cr.trustedTypes,Fc=is?is.emptyScript:"",ss=Cr.reactiveElementPolyfillSupport,no={toAttribute(e,t){switch(t){case Boolean:e=e?Fc:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=e!==null;break;case Number:r=e===null?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch{r=null}}return r}},as=(e,t)=>t!==e&&(t==t||e==e),ro={attribute:!0,type:String,converter:no,reflect:!1,hasChanged:as},oo="finalized",he=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var r;this.finalize(),((r=this.h)!==null&&r!==void 0?r:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((r,n)=>{let o=this._$Ep(n,r);o!==void 0&&(this._$Ev.set(o,n),t.push(o))}),t}static createProperty(t,r=ro){if(r.state&&(r.attribute=!1),this.finalize(),this.elementProperties.set(t,r),!r.noAccessor&&!this.prototype.hasOwnProperty(t)){let n=typeof t=="symbol"?Symbol():"__"+t,o=this.getPropertyDescriptor(t,n,r);o!==void 0&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,r,n){return{get(){return this[r]},set(o){let i=this[t];this[r]=o,this.requestUpdate(t,i,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||ro}static finalize(){if(this.hasOwnProperty(oo))return!1;this[oo]=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let r=this.properties,n=[...Object.getOwnPropertyNames(r),...Object.getOwnPropertySymbols(r)];for(let o of n)this.createProperty(o,r[o])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let r=[];if(Array.isArray(t)){let n=new Set(t.flat(1/0).reverse());for(let o of n)r.unshift(Pr(o))}else t!==void 0&&r.push(Pr(t));return r}static _$Ep(t,r){let n=r.attribute;return n===!1?void 0:typeof n=="string"?n:typeof t=="string"?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise(r=>this.enableUpdating=r),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(r=>r(this))}addController(t){var r,n;((r=this._$ES)!==null&&r!==void 0?r:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)===null||n===void 0||n.call(t))}removeController(t){var r;(r=this._$ES)===null||r===void 0||r.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,r)=>{this.hasOwnProperty(r)&&(this._$Ei.set(r,this[r]),delete this[r])})}createRenderRoot(){var t;let r=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return eo(r,this.constructor.elementStyles),r}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(r=>{var n;return(n=r.hostConnected)===null||n===void 0?void 0:n.call(r)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(r=>{var n;return(n=r.hostDisconnected)===null||n===void 0?void 0:n.call(r)})}attributeChangedCallback(t,r,n){this._$AK(t,n)}_$EO(t,r,n=ro){var o;let i=this.constructor._$Ep(t,n);if(i!==void 0&&n.reflect===!0){let s=(((o=n.converter)===null||o===void 0?void 0:o.toAttribute)!==void 0?n.converter:no).toAttribute(r,n.type);this._$El=t,s==null?this.removeAttribute(i):this.setAttribute(i,s),this._$El=null}}_$AK(t,r){var n;let o=this.constructor,i=o._$Ev.get(t);if(i!==void 0&&this._$El!==i){let s=o.getPropertyOptions(i),c=typeof s.converter=="function"?{fromAttribute:s.converter}:((n=s.converter)===null||n===void 0?void 0:n.fromAttribute)!==void 0?s.converter:no;this._$El=i,this[i]=c.fromAttribute(r,s.type),this._$El=null}}requestUpdate(t,r,n){let o=!0;t!==void 0&&(((n=n||this.constructor.getPropertyOptions(t)).hasChanged||as)(this[t],r)?(this._$AL.has(t)||this._$AL.set(t,r),n.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,n))):o=!1),!this.isUpdatePending&&o&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(r){Promise.reject(r)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((o,i)=>this[i]=o),this._$Ei=void 0);let r=!1,n=this._$AL;try{r=this.shouldUpdate(n),r?(this.willUpdate(n),(t=this._$ES)===null||t===void 0||t.forEach(o=>{var i;return(i=o.hostUpdate)===null||i===void 0?void 0:i.call(o)}),this.update(n)):this._$Ek()}catch(o){throw r=!1,this._$Ek(),o}r&&this._$AE(n)}willUpdate(t){}_$AE(t){var r;(r=this._$ES)===null||r===void 0||r.forEach(n=>{var o;return(o=n.hostUpdated)===null||o===void 0?void 0:o.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((r,n)=>this._$EO(n,this[n],r)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};he[oo]=!0,he.elementProperties=new Map,he.elementStyles=[],he.shadowRootOptions={mode:"open"},ss?.({ReactiveElement:he}),((to=Cr.reactiveElementVersions)!==null&&to!==void 0?to:Cr.reactiveElementVersions=[]).push("1.6.3");var io,$r=window,ot=$r.trustedTypes,cs=ot?ot.createPolicy("lit-html",{createHTML:e=>e}):void 0,ao="$lit$",ye=`lit$${(Math.random()+"").slice(9)}$`,fs="?"+ye,Hc=`<${fs}>`,De=document,Ct=()=>De.createComment(""),$t=e=>e===null||typeof e!="object"&&typeof e!="function",gs=Array.isArray,zc=e=>gs(e)||typeof e?.[Symbol.iterator]=="function",so=`[ \f\r]`,Pt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ls=/-->/g,hs=/>/g,Me=RegExp(`>|${so}(?:([^\\s"'>=/]+)(${so}*=${so}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),ds=/'/g,us=/"/g,xs=/^(?:script|style|textarea|title)$/i,vs=e=>(t,...r)=>({_$litType$:e,strings:t,values:r}),x=vs(1),hu=vs(2),Fe=Symbol.for("lit-noChange"),U=Symbol.for("lit-nothing"),ms=new WeakMap,Ue=De.createTreeWalker(De,129,null,!1);function ys(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return cs!==void 0?cs.createHTML(t):t}var Gc=(e,t)=>{let r=e.length-1,n=[],o,i=t===2?"":"",s=Pt;for(let c=0;c"?(s=o??Pt,d=-1):l[1]===void 0?d=-2:(d=s.lastIndex-l[2].length,h=l[1],s=l[3]===void 0?Me:l[3]==='"'?us:ds):s===us||s===ds?s=Me:s===ls||s===hs?s=Pt:(s=Me,o=void 0);let m=s===Me&&e[c+1].startsWith("/>")?" ":"";i+=s===Pt?a+Hc:d>=0?(n.push(h),a.slice(0,d)+ao+a.slice(d)+ye+m):a+ye+(d===-2?(n.push(void 0),c):m)}return[ys(e,i+(e[r]||"")+(t===2?"":"")),n]},Ot=class e{constructor({strings:t,_$litType$:r},n){let o;this.parts=[];let i=0,s=0,c=t.length-1,a=this.parts,[h,l]=Gc(t,r);if(this.el=e.createElement(h,n),Ue.currentNode=this.el.content,r===2){let d=this.el.content,u=d.firstChild;u.remove(),d.append(...u.childNodes)}for(;(o=Ue.nextNode())!==null&&a.length0){o.textContent=ot?ot.emptyScript:"";for(let m=0;m2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=U}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,r=this,n,o){let i=this.strings,s=!1;if(i===void 0)t=it(this,t,r,0),s=!$t(t)||t!==this._$AH&&t!==Fe,s&&(this._$AH=t);else{let c=t,a,h;for(t=i[0],a=0;a{var n,o;let i=(n=r?.renderBefore)!==null&&n!==void 0?n:t,s=i._$litPart$;if(s===void 0){let c=(o=r?.renderBefore)!==null&&o!==void 0?o:null;i._$litPart$=s=new Lt(t.insertBefore(Ct(),c),c,void 0,r??{})}return s._$AI(e),s};var po,fo;var oe=class extends he{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,r;let n=super.createRenderRoot();return(t=(r=this.renderOptions).renderBefore)!==null&&t!==void 0||(r.renderBefore=n.firstChild),n}update(t){let r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Es(r,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!1)}render(){return Fe}};oe.finalized=!0,oe._$litElement$=!0,(po=globalThis.litElementHydrateSupport)===null||po===void 0||po.call(globalThis,{LitElement:oe});var bs=globalThis.litElementPolyfillSupport;bs?.({LitElement:oe});((fo=globalThis.litElementVersions)!==null&&fo!==void 0?fo:globalThis.litElementVersions=[]).push("3.3.3");var Nt="(max-width: 767px)",Rt="(max-width: 1199px)",B="(min-width: 768px)",H="(min-width: 1200px)",q="(min-width: 1600px)";var _s=ke` +\f\r"'\`<>=]|("|')|))|$)`,"g"),ds=/'/g,us=/"/g,xs=/^(?:script|style|textarea|title)$/i,vs=e=>(t,...r)=>({_$litType$:e,strings:t,values:r}),x=vs(1),du=vs(2),Fe=Symbol.for("lit-noChange"),U=Symbol.for("lit-nothing"),ms=new WeakMap,Ue=De.createTreeWalker(De,129,null,!1);function ys(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return cs!==void 0?cs.createHTML(t):t}var Gc=(e,t)=>{let r=e.length-1,n=[],o,i=t===2?"":"",s=Pt;for(let c=0;c"?(s=o??Pt,d=-1):l[1]===void 0?d=-2:(d=s.lastIndex-l[2].length,h=l[1],s=l[3]===void 0?Me:l[3]==='"'?us:ds):s===us||s===ds?s=Me:s===ls||s===hs?s=Pt:(s=Me,o=void 0);let m=s===Me&&e[c+1].startsWith("/>")?" ":"";i+=s===Pt?a+Hc:d>=0?(n.push(h),a.slice(0,d)+ao+a.slice(d)+ye+m):a+ye+(d===-2?(n.push(void 0),c):m)}return[ys(e,i+(e[r]||"")+(t===2?"":"")),n]},Ot=class e{constructor({strings:t,_$litType$:r},n){let o;this.parts=[];let i=0,s=0,c=t.length-1,a=this.parts,[h,l]=Gc(t,r);if(this.el=e.createElement(h,n),Ue.currentNode=this.el.content,r===2){let d=this.el.content,u=d.firstChild;u.remove(),d.append(...u.childNodes)}for(;(o=Ue.nextNode())!==null&&a.length0){o.textContent=ot?ot.emptyScript:"";for(let m=0;m2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=U}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,r=this,n,o){let i=this.strings,s=!1;if(i===void 0)t=it(this,t,r,0),s=!$t(t)||t!==this._$AH&&t!==Fe,s&&(this._$AH=t);else{let c=t,a,h;for(t=i[0],a=0;a{var n,o;let i=(n=r?.renderBefore)!==null&&n!==void 0?n:t,s=i._$litPart$;if(s===void 0){let c=(o=r?.renderBefore)!==null&&o!==void 0?o:null;i._$litPart$=s=new Lt(t.insertBefore(Ct(),c),c,void 0,r??{})}return s._$AI(e),s};var po,fo;var oe=class extends he{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,r;let n=super.createRenderRoot();return(t=(r=this.renderOptions).renderBefore)!==null&&t!==void 0||(r.renderBefore=n.firstChild),n}update(t){let r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Es(r,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!1)}render(){return Fe}};oe.finalized=!0,oe._$litElement$=!0,(po=globalThis.litElementHydrateSupport)===null||po===void 0||po.call(globalThis,{LitElement:oe});var bs=globalThis.litElementPolyfillSupport;bs?.({LitElement:oe});((fo=globalThis.litElementVersions)!==null&&fo!==void 0?fo:globalThis.litElementVersions=[]).push("3.3.3");var Nt="(max-width: 767px)",Rt="(max-width: 1199px)",B="(min-width: 768px)",H="(min-width: 1200px)",q="(min-width: 1600px)";var _s=ke` :host { position: relative; display: flex; @@ -1664,7 +1664,7 @@ body.merch-modal { width: var(--img-width); height: var(--img-height); } - `);customElements.define("merch-icon",at);var He="Network error",kt,Lr=class{constructor(t){Q(this,kt);O(this,"sites",{cf:{fragments:{search:this.searchFragment.bind(this),getByPath:this.getFragmentByPath.bind(this),getById:this.getFragmentById.bind(this),save:this.saveFragment.bind(this),copy:this.copyFragmentClassic.bind(this),publish:this.publishFragment.bind(this),delete:this.deleteFragment.bind(this)}}});K(this,kt,/^author-/.test(t));let r=`https://${t}.adobeaemcloud.com`,n=`${r}/adobe/sites`;this.cfFragmentsUrl=`${n}/cf/fragments`,this.cfSearchUrl=`${this.cfFragmentsUrl}/search`,this.cfPublishUrl=`${this.cfFragmentsUrl}/publish`,this.wcmcommandUrl=`${r}/bin/wcmcommand`,this.csrfTokenUrl=`${r}/libs/granite/csrf/token.json`,this.headers={Authorization:`Bearer ${sessionStorage.getItem("masAccessToken")??window.adobeid?.authorize?.()}`,pragma:"no-cache","cache-control":"no-cache"}}async getCsrfToken(){let t=await fetch(this.csrfTokenUrl,{headers:this.headers}).catch(n=>{throw new Error(`${He}: ${n.message}`)});if(!t.ok)throw new Error(`Failed to get CSRF token: ${t.status} ${t.statusText}`);let{token:r}=await t.json();return r}async searchFragment({path:t,query:r,variant:n}){let o={};t&&(o.path=t),r&&(o.fullText={text:encodeURIComponent(r),queryMode:"EXACT_WORDS"});let i=new URLSearchParams({query:JSON.stringify({filter:o})}).toString(),s=await fetch(`${this.cfSearchUrl}?${i}`,{headers:this.headers}).catch(h=>{throw new Error(`${He}: ${h.message}`)});if(!s.ok)throw new Error(`Search failed: ${s.status} ${s.statusText}`);let a=(await s.json()).items;return n&&(a=a.filter(h=>{let[l]=h.fields.find(d=>d.name==="variant")?.values;return l===n})),a}async getFragmentByPath(t){let r=R(this,kt)?this.headers:{},n=await fetch(`${this.cfFragmentsUrl}?path=${t}`,{headers:r}).catch(i=>{throw new Error(`${He}: ${i.message}`)});if(!n.ok)throw new Error(`Failed to get fragment: ${n.status} ${n.statusText}`);let{items:o}=await n.json();if(!o||o.length===0)throw new Error("Fragment not found");return o[0]}async getFragment(t){let r=t.headers.get("Etag"),n=await t.json();return n.etag=r,n}async getFragmentById(t){let r=await fetch(`${this.cfFragmentsUrl}/${t}`,{headers:this.headers});if(!r.ok)throw new Error(`Failed to get fragment: ${r.status} ${r.statusText}`);return await this.getFragment(r)}async saveFragment(t){let{title:r,fields:n}=t,o=await fetch(`${this.cfFragmentsUrl}/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json","If-Match":t.etag,...this.headers},body:JSON.stringify({title:r,fields:n})}).catch(i=>{throw new Error(`${He}: ${i.message}`)});if(!o.ok)throw new Error(`Failed to save fragment: ${o.status} ${o.statusText}`);return await this.getFragment(o)}async copyFragmentClassic(t){let r=await this.getCsrfToken(),n=t.path.split("/").slice(0,-1).join("/"),o=new FormData;o.append("cmd","copyPage"),o.append("srcPath",t.path),o.append("destParentPath",n),o.append("shallow","false"),o.append("_charset_","UTF-8");let i=await fetch(this.wcmcommandUrl,{method:"POST",headers:{...this.headers,"csrf-token":r},body:o}).catch(u=>{throw new Error(`${He}: ${u.message}`)});if(!i.ok)throw new Error(`Failed to copy fragment: ${i.status} ${i.statusText}`);let s=await i.text(),l=new DOMParser().parseFromString(s,"text/html").getElementById("Message")?.textContent.trim();if(!l)throw new Error("Failed to extract new path from copy response");await Ts();let d=await this.getFragmentByPath(l);return d&&(d=await this.getFragmentById(d.id)),d}async publishFragment(t){let r=await fetch(this.cfPublishUrl,{method:"POST",headers:{"Content-Type":"application/json","If-Match":t.etag,...this.headers},body:JSON.stringify({paths:[t.path],filterReferencesByStatus:["DRAFT","UNPUBLISHED"],workflowModelId:"/var/workflow/models/scheduled_activation_with_references"})}).catch(n=>{throw new Error(`${He}: ${n.message}`)});if(!r.ok)throw new Error(`Failed to publish fragment: ${r.status} ${r.statusText}`);return await r.json()}async deleteFragment(t){let r=await fetch(`${this.cfFragmentsUrl}/${t.id}`,{method:"DELETE",headers:{"Content-Type":"application/json","If-Match":t.etag,...this.headers}}).catch(n=>{throw new Error(`${He}: ${n.message}`)});if(!r.ok)throw new Error(`Failed to delete fragment: ${r.status} ${r.statusText}`);return r}};kt=new WeakMap;var Wc="aem-bucket",Nr={CATALOG:"catalog",AH:"ah",CCD_ACTION:"ccd-action",SPECIAL_OFFERS:"special-offers"},qc={[Nr.CATALOG]:{title:{tag:"h3",slot:"heading-xs"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xs"},ctas:{size:"l"}},[Nr.AH]:{title:{tag:"h3",slot:"heading-xxs"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xxs"},ctas:{size:"s"}},[Nr.CCD_ACTION]:{title:{tag:"h3",slot:"heading-xs"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xs"},ctas:{size:"l"}},[Nr.SPECIAL_OFFERS]:{name:{tag:"h4",slot:"detail-m"},title:{tag:"h4",slot:"detail-m"},backgroundImage:{tag:"div",slot:"bg-image"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xs"},ctas:{size:"l"}}};async function Yc(e,t,r,n){let o=e.fields.reduce((c,{name:a,multiple:h,values:l})=>(c[a]=h?l:l[0],c),{id:e.id});o.model=o.model;let{variant:i="catalog"}=o;r.setAttribute("variant",i);let s=qc[i]??"catalog";if(o.icon?.forEach(c=>{let a=Ee("merch-icon",{slot:"icons",src:c,alt:"",href:"",size:"l"});t(a)}),o.title&&s.title&&t(Ee(s.title.tag,{slot:s.title.slot},o.title)),o.backgroundImage&&s.backgroundImage&&t(Ee(s.backgroundImage.tag,{slot:s.backgroundImage.slot},``)),o.prices&&s.prices){let c=o.prices,a=Ee(s.prices.tag,{slot:s.prices.slot},c);t(a)}if(o.description&&s.description){let c=Ee(s.description.tag,{slot:s.description.slot},o.description);t(c)}if(o.ctas){let c=Ee("div",{slot:"footer"},o.ctas),a=[];[...c.querySelectorAll("a")].forEach(h=>{let l=h.parentElement.tagName==="STRONG";if(n)h.classList.add("con-button"),l&&h.classList.add("blue"),a.push(h);else{let m=Ee("sp-button",{treatment:l?"fill":"outline",variant:l?"accent":"primary"},h);m.addEventListener("click",f=>{f.stopPropagation(),h.click()}),a.push(m)}}),c.innerHTML="",c.append(...a),t(c)}}var be,yo=class{constructor(){Q(this,be,new Map)}clear(){R(this,be).clear()}add(...t){t.forEach(r=>{let{path:n}=r;n&&R(this,be).set(n,r)})}has(t){return R(this,be).has(t)}get(t){return R(this,be).get(t)}remove(t){R(this,be).delete(t)}};be=new WeakMap;var vo=new yo,Mt,ze,Eo=class extends HTMLElement{constructor(){super(...arguments);Q(this,Mt);O(this,"cache",vo);O(this,"refs",[]);O(this,"path");O(this,"consonant",!1);Q(this,ze)}static get observedAttributes(){return["source","path","consonant"]}attributeChangedCallback(r,n,o){this[r]=o}connectedCallback(){this.consonant=this.hasAttribute("consonant"),this.clearRefs();let r=this.getAttribute(Wc)??"publish-p22655-e59341";K(this,Mt,new Lr(r)),this.refresh(!1)}clearRefs(){this.refs.forEach(r=>{r.remove()})}async refresh(r=!0){this.path&&(R(this,ze)&&!await Promise.race([R(this,ze),Promise.resolve(!1)])||(this.clearRefs(),this.refs=[],r&&this.cache.remove(this.path),K(this,ze,this.fetchData().then(()=>!0))))}async fetchData(){let r=vo.get(this.path);if(r||(r=await R(this,Mt).sites.cf.fragments.getByPath(this.path),vo.add(r)),r){Yc(r,o=>{this.parentElement.appendChild(o),this.refs.push(o)},this.parentElement,this.consonant);return}}get updateComplete(){return R(this,ze)??Promise.reject(new Error("datasource is not correctly configured"))}};Mt=new WeakMap,ze=new WeakMap;customElements.define("merch-datasource",Eo);var{searchParams:Ns}=new URL(import.meta.url),Xc=Ns.get("locale")??"US_en",Rs=Ns.get("env")==="stage",Zc=Rs?"stage":"prod",Jc=Rs?"STAGE":"PROD",Qc=fetch("https://www.adobe.com/federal/commerce/price-literals.json").then(e=>e.json().then(({data:t})=>t)),Kc=()=>({env:{name:Zc},commerce:{"commerce.env":Jc,priceLiteralsPromise:Qc},locale:{prefix:Xc}}),el=bt(Kc),Qu=el;export{Qu as default}; + `);customElements.define("merch-icon",at);var He="Network error",kt,Lr=class{constructor(t){Q(this,kt);O(this,"sites",{cf:{fragments:{search:this.searchFragment.bind(this),getByPath:this.getFragmentByPath.bind(this),getById:this.getFragmentById.bind(this),save:this.saveFragment.bind(this),copy:this.copyFragmentClassic.bind(this),publish:this.publishFragment.bind(this),delete:this.deleteFragment.bind(this)}}});K(this,kt,/^author-/.test(t));let r=`https://${t}.adobeaemcloud.com`,n=`${r}/adobe/sites`;this.cfFragmentsUrl=`${n}/cf/fragments`,this.cfSearchUrl=`${this.cfFragmentsUrl}/search`,this.cfPublishUrl=`${this.cfFragmentsUrl}/publish`,this.wcmcommandUrl=`${r}/bin/wcmcommand`,this.csrfTokenUrl=`${r}/libs/granite/csrf/token.json`,this.headers={Authorization:`Bearer ${sessionStorage.getItem("masAccessToken")??window.adobeid?.authorize?.()}`,pragma:"no-cache","cache-control":"no-cache"}}async getCsrfToken(){let t=await fetch(this.csrfTokenUrl,{headers:this.headers}).catch(n=>{throw new Error(`${He}: ${n.message}`)});if(!t.ok)throw new Error(`Failed to get CSRF token: ${t.status} ${t.statusText}`);let{token:r}=await t.json();return r}async searchFragment({path:t,query:r,variant:n}){let o={};t&&(o.path=t),r&&(o.fullText={text:encodeURIComponent(r),queryMode:"EXACT_WORDS"});let i=new URLSearchParams({query:JSON.stringify({filter:o})}).toString(),s=await fetch(`${this.cfSearchUrl}?${i}`,{headers:this.headers}).catch(h=>{throw new Error(`${He}: ${h.message}`)});if(!s.ok)throw new Error(`Search failed: ${s.status} ${s.statusText}`);let a=(await s.json()).items;return n&&(a=a.filter(h=>{let[l]=h.fields.find(d=>d.name==="variant")?.values;return l===n})),a}async getFragmentByPath(t){let r=R(this,kt)?this.headers:{},n=await fetch(`${this.cfFragmentsUrl}?path=${t}`,{headers:r}).catch(i=>{throw new Error(`${He}: ${i.message}`)});if(!n.ok)throw new Error(`Failed to get fragment: ${n.status} ${n.statusText}`);let{items:o}=await n.json();if(!o||o.length===0)throw new Error("Fragment not found");return o[0]}async getFragment(t){let r=t.headers.get("Etag"),n=await t.json();return n.etag=r,n}async getFragmentById(t){let r=await fetch(`${this.cfFragmentsUrl}/${t}`,{headers:this.headers});if(!r.ok)throw new Error(`Failed to get fragment: ${r.status} ${r.statusText}`);return await this.getFragment(r)}async saveFragment(t){let{title:r,fields:n}=t,o=await fetch(`${this.cfFragmentsUrl}/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json","If-Match":t.etag,...this.headers},body:JSON.stringify({title:r,fields:n})}).catch(i=>{throw new Error(`${He}: ${i.message}`)});if(!o.ok)throw new Error(`Failed to save fragment: ${o.status} ${o.statusText}`);return await this.getFragment(o)}async copyFragmentClassic(t){let r=await this.getCsrfToken(),n=t.path.split("/").slice(0,-1).join("/"),o=new FormData;o.append("cmd","copyPage"),o.append("srcPath",t.path),o.append("destParentPath",n),o.append("shallow","false"),o.append("_charset_","UTF-8");let i=await fetch(this.wcmcommandUrl,{method:"POST",headers:{...this.headers,"csrf-token":r},body:o}).catch(u=>{throw new Error(`${He}: ${u.message}`)});if(!i.ok)throw new Error(`Failed to copy fragment: ${i.status} ${i.statusText}`);let s=await i.text(),l=new DOMParser().parseFromString(s,"text/html").getElementById("Message")?.textContent.trim();if(!l)throw new Error("Failed to extract new path from copy response");await Ts();let d=await this.getFragmentByPath(l);return d&&(d=await this.getFragmentById(d.id)),d}async publishFragment(t){let r=await fetch(this.cfPublishUrl,{method:"POST",headers:{"Content-Type":"application/json","If-Match":t.etag,...this.headers},body:JSON.stringify({paths:[t.path],filterReferencesByStatus:["DRAFT","UNPUBLISHED"],workflowModelId:"/var/workflow/models/scheduled_activation_with_references"})}).catch(n=>{throw new Error(`${He}: ${n.message}`)});if(!r.ok)throw new Error(`Failed to publish fragment: ${r.status} ${r.statusText}`);return await r.json()}async deleteFragment(t){let r=await fetch(`${this.cfFragmentsUrl}/${t.id}`,{method:"DELETE",headers:{"Content-Type":"application/json","If-Match":t.etag,...this.headers}}).catch(n=>{throw new Error(`${He}: ${n.message}`)});if(!r.ok)throw new Error(`Failed to delete fragment: ${r.status} ${r.statusText}`);return r}};kt=new WeakMap;var Wc="aem-bucket",qc="publish-p22655-e155390",Nr={CATALOG:"catalog",AH:"ah",CCD_ACTION:"ccd-action",SPECIAL_OFFERS:"special-offers"},Yc={[Nr.CATALOG]:{title:{tag:"h3",slot:"heading-xs"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xs"},ctas:{size:"l"}},[Nr.AH]:{title:{tag:"h3",slot:"heading-xxs"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xxs"},ctas:{size:"s"}},[Nr.CCD_ACTION]:{title:{tag:"h3",slot:"heading-xs"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xs"},ctas:{size:"l"}},[Nr.SPECIAL_OFFERS]:{name:{tag:"h4",slot:"detail-m"},title:{tag:"h4",slot:"detail-m"},backgroundImage:{tag:"div",slot:"bg-image"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xs"},ctas:{size:"l"}}};async function Xc(e,t,r,n){let o=e.fields.reduce((c,{name:a,multiple:h,values:l})=>(c[a]=h?l:l[0],c),{id:e.id});o.model=o.model;let{variant:i="catalog"}=o;r.setAttribute("variant",i);let s=Yc[i]??"catalog";if(o.mnemonicIcon?.forEach((c,a)=>{let h=o.mnemonicLink?.length>a?o.mnemonicLink[a]:"",l=o.mnemonicAlt?.length>a?o.mnemonicAlt[a]:"",d=Ee("merch-icon",{slot:"icons",src:c,alt:l,href:h,size:"l"});t(d)}),o.cardTitle&&s.title&&t(Ee(s.title.tag,{slot:s.title.slot},o.cardTitle)),o.backgroundImage&&s.backgroundImage&&t(Ee(s.backgroundImage.tag,{slot:s.backgroundImage.slot},``)),o.prices&&s.prices){let c=o.prices,a=Ee(s.prices.tag,{slot:s.prices.slot},c);t(a)}if(o.description&&s.description){let c=Ee(s.description.tag,{slot:s.description.slot},o.description);t(c)}if(o.ctas){let c=Ee("div",{slot:"footer"},o.ctas),a=[];[...c.querySelectorAll("a")].forEach(h=>{let l=h.parentElement.tagName==="STRONG";if(n)h.classList.add("con-button"),l&&h.classList.add("blue"),a.push(h);else{let m=Ee("sp-button",{treatment:l?"fill":"outline",variant:l?"accent":"primary"},h);m.addEventListener("click",f=>{f.stopPropagation(),h.click()}),a.push(m)}}),c.innerHTML="",c.append(...a),t(c)}}var be,yo=class{constructor(){Q(this,be,new Map)}clear(){R(this,be).clear()}add(...t){t.forEach(r=>{let{path:n}=r;n&&R(this,be).set(n,r)})}has(t){return R(this,be).has(t)}get(t){return R(this,be).get(t)}remove(t){R(this,be).delete(t)}};be=new WeakMap;var vo=new yo,Mt,ze,Eo=class extends HTMLElement{constructor(){super(...arguments);Q(this,Mt);O(this,"cache",vo);O(this,"refs",[]);O(this,"path");O(this,"consonant",!1);Q(this,ze)}static get observedAttributes(){return["source","path","consonant"]}attributeChangedCallback(r,n,o){this[r]=o}connectedCallback(){this.consonant=this.hasAttribute("consonant"),this.clearRefs();let r=this.getAttribute(Wc)??qc;K(this,Mt,new Lr(r)),this.refresh(!1)}clearRefs(){this.refs.forEach(r=>{r.remove()})}async refresh(r=!0){this.path&&(R(this,ze)&&!await Promise.race([R(this,ze),Promise.resolve(!1)])||(this.clearRefs(),this.refs=[],r&&this.cache.remove(this.path),K(this,ze,this.fetchData().then(()=>!0))))}async fetchData(){let r=vo.get(this.path);if(r||(r=await R(this,Mt).sites.cf.fragments.getByPath(this.path),vo.add(r)),r){Xc(r,o=>{this.parentElement.appendChild(o),this.refs.push(o)},this.parentElement,this.consonant);return}}get updateComplete(){return R(this,ze)??Promise.reject(new Error("datasource is not correctly configured"))}};Mt=new WeakMap,ze=new WeakMap;customElements.define("merch-datasource",Eo);var{searchParams:Ns}=new URL(import.meta.url),Zc=Ns.get("locale")??"US_en",Rs=Ns.get("env")==="stage",Jc=Rs?"stage":"prod",Qc=Rs?"STAGE":"PROD",Kc=fetch("https://www.adobe.com/federal/commerce/price-literals.json").then(e=>e.json().then(({data:t})=>t)),el=()=>({env:{name:Jc},commerce:{"commerce.env":Qc,priceLiteralsPromise:Kc},locale:{prefix:Zc}}),tl=bt(el),Ku=tl;export{Ku as default}; /*! Bundled license information: @lit/reactive-element/css-tag.js: diff --git a/libs/deps/mas/merch-datasource.js b/libs/deps/mas/merch-datasource.js index 16536a0faa..e7f0bf1ce3 100644 --- a/libs/deps/mas/merch-datasource.js +++ b/libs/deps/mas/merch-datasource.js @@ -1 +1 @@ -function d(l,t={},e){let s=document.createElement(l);e instanceof HTMLElement?s.appendChild(e):s.innerHTML=e;for(let[a,o]of Object.entries(t))s.setAttribute(a,o);return s}function T(l=1e3){return new Promise(t=>setTimeout(t,l))}var m="Network error",f=class{#t;constructor(t){this.#t=/^author-/.test(t);let e=`https://${t}.adobeaemcloud.com`,s=`${e}/adobe/sites`;this.cfFragmentsUrl=`${s}/cf/fragments`,this.cfSearchUrl=`${this.cfFragmentsUrl}/search`,this.cfPublishUrl=`${this.cfFragmentsUrl}/publish`,this.wcmcommandUrl=`${e}/bin/wcmcommand`,this.csrfTokenUrl=`${e}/libs/granite/csrf/token.json`,this.headers={Authorization:`Bearer ${sessionStorage.getItem("masAccessToken")??window.adobeid?.authorize?.()}`,pragma:"no-cache","cache-control":"no-cache"}}async getCsrfToken(){let t=await fetch(this.csrfTokenUrl,{headers:this.headers}).catch(s=>{throw new Error(`${m}: ${s.message}`)});if(!t.ok)throw new Error(`Failed to get CSRF token: ${t.status} ${t.statusText}`);let{token:e}=await t.json();return e}async searchFragment({path:t,query:e,variant:s}){let a={};t&&(a.path=t),e&&(a.fullText={text:encodeURIComponent(e),queryMode:"EXACT_WORDS"});let o=new URLSearchParams({query:JSON.stringify({filter:a})}).toString(),r=await fetch(`${this.cfSearchUrl}?${o}`,{headers:this.headers}).catch(c=>{throw new Error(`${m}: ${c.message}`)});if(!r.ok)throw new Error(`Search failed: ${r.status} ${r.statusText}`);let i=(await r.json()).items;return s&&(i=i.filter(c=>{let[h]=c.fields.find(g=>g.name==="variant")?.values;return h===s})),i}async getFragmentByPath(t){let e=this.#t?this.headers:{},s=await fetch(`${this.cfFragmentsUrl}?path=${t}`,{headers:e}).catch(o=>{throw new Error(`${m}: ${o.message}`)});if(!s.ok)throw new Error(`Failed to get fragment: ${s.status} ${s.statusText}`);let{items:a}=await s.json();if(!a||a.length===0)throw new Error("Fragment not found");return a[0]}async getFragment(t){let e=t.headers.get("Etag"),s=await t.json();return s.etag=e,s}async getFragmentById(t){let e=await fetch(`${this.cfFragmentsUrl}/${t}`,{headers:this.headers});if(!e.ok)throw new Error(`Failed to get fragment: ${e.status} ${e.statusText}`);return await this.getFragment(e)}async saveFragment(t){let{title:e,fields:s}=t,a=await fetch(`${this.cfFragmentsUrl}/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json","If-Match":t.etag,...this.headers},body:JSON.stringify({title:e,fields:s})}).catch(o=>{throw new Error(`${m}: ${o.message}`)});if(!a.ok)throw new Error(`Failed to save fragment: ${a.status} ${a.statusText}`);return await this.getFragment(a)}async copyFragmentClassic(t){let e=await this.getCsrfToken(),s=t.path.split("/").slice(0,-1).join("/"),a=new FormData;a.append("cmd","copyPage"),a.append("srcPath",t.path),a.append("destParentPath",s),a.append("shallow","false"),a.append("_charset_","UTF-8");let o=await fetch(this.wcmcommandUrl,{method:"POST",headers:{...this.headers,"csrf-token":e},body:a}).catch(y=>{throw new Error(`${m}: ${y.message}`)});if(!o.ok)throw new Error(`Failed to copy fragment: ${o.status} ${o.statusText}`);let r=await o.text(),h=new DOMParser().parseFromString(r,"text/html").getElementById("Message")?.textContent.trim();if(!h)throw new Error("Failed to extract new path from copy response");await T();let g=await this.getFragmentByPath(h);return g&&(g=await this.getFragmentById(g.id)),g}async publishFragment(t){let e=await fetch(this.cfPublishUrl,{method:"POST",headers:{"Content-Type":"application/json","If-Match":t.etag,...this.headers},body:JSON.stringify({paths:[t.path],filterReferencesByStatus:["DRAFT","UNPUBLISHED"],workflowModelId:"/var/workflow/models/scheduled_activation_with_references"})}).catch(s=>{throw new Error(`${m}: ${s.message}`)});if(!e.ok)throw new Error(`Failed to publish fragment: ${e.status} ${e.statusText}`);return await e.json()}async deleteFragment(t){let e=await fetch(`${this.cfFragmentsUrl}/${t.id}`,{method:"DELETE",headers:{"Content-Type":"application/json","If-Match":t.etag,...this.headers}}).catch(s=>{throw new Error(`${m}: ${s.message}`)});if(!e.ok)throw new Error(`Failed to delete fragment: ${e.status} ${e.statusText}`);return e}sites={cf:{fragments:{search:this.searchFragment.bind(this),getByPath:this.getFragmentByPath.bind(this),getById:this.getFragmentById.bind(this),save:this.saveFragment.bind(this),copy:this.copyFragmentClassic.bind(this),publish:this.publishFragment.bind(this),delete:this.deleteFragment.bind(this)}}}};var x="aem-bucket",p={CATALOG:"catalog",AH:"ah",CCD_ACTION:"ccd-action",SPECIAL_OFFERS:"special-offers"},F={[p.CATALOG]:{title:{tag:"h3",slot:"heading-xs"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xs"},ctas:{size:"l"}},[p.AH]:{title:{tag:"h3",slot:"heading-xxs"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xxs"},ctas:{size:"s"}},[p.CCD_ACTION]:{title:{tag:"h3",slot:"heading-xs"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xs"},ctas:{size:"l"}},[p.SPECIAL_OFFERS]:{name:{tag:"h4",slot:"detail-m"},title:{tag:"h4",slot:"detail-m"},backgroundImage:{tag:"div",slot:"bg-image"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xs"},ctas:{size:"l"}}};async function k(l,t,e,s){let a=l.fields.reduce((n,{name:i,multiple:c,values:h})=>(n[i]=c?h:h[0],n),{id:l.id});a.model=a.model;let{variant:o="catalog"}=a;e.setAttribute("variant",o);let r=F[o]??"catalog";if(a.icon?.forEach(n=>{let i=d("merch-icon",{slot:"icons",src:n,alt:"",href:"",size:"l"});t(i)}),a.title&&r.title&&t(d(r.title.tag,{slot:r.title.slot},a.title)),a.backgroundImage&&r.backgroundImage&&t(d(r.backgroundImage.tag,{slot:r.backgroundImage.slot},``)),a.prices&&r.prices){let n=a.prices,i=d(r.prices.tag,{slot:r.prices.slot},n);t(i)}if(a.description&&r.description){let n=d(r.description.tag,{slot:r.description.slot},a.description);t(n)}if(a.ctas){let n=d("div",{slot:"footer"},a.ctas),i=[];[...n.querySelectorAll("a")].forEach(c=>{let h=c.parentElement.tagName==="STRONG";if(s)c.classList.add("con-button"),h&&c.classList.add("blue"),i.push(c);else{let $=d("sp-button",{treatment:h?"fill":"outline",variant:h?"accent":"primary"},c);$.addEventListener("click",E=>{E.stopPropagation(),c.click()}),i.push($)}}),n.innerHTML="",n.append(...i),t(n)}}var w=class{#t=new Map;clear(){this.#t.clear()}add(...t){t.forEach(e=>{let{path:s}=e;s&&this.#t.set(s,e)})}has(t){return this.#t.has(t)}get(t){return this.#t.get(t)}remove(t){this.#t.delete(t)}},u=new w,b=class extends HTMLElement{#t;cache=u;refs=[];path;consonant=!1;#e;static get observedAttributes(){return["source","path","consonant"]}attributeChangedCallback(t,e,s){this[t]=s}connectedCallback(){this.consonant=this.hasAttribute("consonant"),this.clearRefs();let t=this.getAttribute(x)??"publish-p22655-e59341";this.#t=new f(t),this.refresh(!1)}clearRefs(){this.refs.forEach(t=>{t.remove()})}async refresh(t=!0){this.path&&(this.#e&&!await Promise.race([this.#e,Promise.resolve(!1)])||(this.clearRefs(),this.refs=[],t&&this.cache.remove(this.path),this.#e=this.fetchData().then(()=>!0)))}async fetchData(){let t=u.get(this.path);if(t||(t=await this.#t.sites.cf.fragments.getByPath(this.path),u.add(t)),t){k(t,s=>{this.parentElement.appendChild(s),this.refs.push(s)},this.parentElement,this.consonant);return}}get updateComplete(){return this.#e??Promise.reject(new Error("datasource is not correctly configured"))}};customElements.define("merch-datasource",b);export{b as MerchDataSource}; +function m(l,t={},e){let a=document.createElement(l);e instanceof HTMLElement?a.appendChild(e):a.innerHTML=e;for(let[s,o]of Object.entries(t))a.setAttribute(s,o);return a}function $(l=1e3){return new Promise(t=>setTimeout(t,l))}var g="Network error",f=class{#t;constructor(t){this.#t=/^author-/.test(t);let e=`https://${t}.adobeaemcloud.com`,a=`${e}/adobe/sites`;this.cfFragmentsUrl=`${a}/cf/fragments`,this.cfSearchUrl=`${this.cfFragmentsUrl}/search`,this.cfPublishUrl=`${this.cfFragmentsUrl}/publish`,this.wcmcommandUrl=`${e}/bin/wcmcommand`,this.csrfTokenUrl=`${e}/libs/granite/csrf/token.json`,this.headers={Authorization:`Bearer ${sessionStorage.getItem("masAccessToken")??window.adobeid?.authorize?.()}`,pragma:"no-cache","cache-control":"no-cache"}}async getCsrfToken(){let t=await fetch(this.csrfTokenUrl,{headers:this.headers}).catch(a=>{throw new Error(`${g}: ${a.message}`)});if(!t.ok)throw new Error(`Failed to get CSRF token: ${t.status} ${t.statusText}`);let{token:e}=await t.json();return e}async searchFragment({path:t,query:e,variant:a}){let s={};t&&(s.path=t),e&&(s.fullText={text:encodeURIComponent(e),queryMode:"EXACT_WORDS"});let o=new URLSearchParams({query:JSON.stringify({filter:s})}).toString(),r=await fetch(`${this.cfSearchUrl}?${o}`,{headers:this.headers}).catch(c=>{throw new Error(`${g}: ${c.message}`)});if(!r.ok)throw new Error(`Search failed: ${r.status} ${r.statusText}`);let n=(await r.json()).items;return a&&(n=n.filter(c=>{let[h]=c.fields.find(d=>d.name==="variant")?.values;return h===a})),n}async getFragmentByPath(t){let e=this.#t?this.headers:{},a=await fetch(`${this.cfFragmentsUrl}?path=${t}`,{headers:e}).catch(o=>{throw new Error(`${g}: ${o.message}`)});if(!a.ok)throw new Error(`Failed to get fragment: ${a.status} ${a.statusText}`);let{items:s}=await a.json();if(!s||s.length===0)throw new Error("Fragment not found");return s[0]}async getFragment(t){let e=t.headers.get("Etag"),a=await t.json();return a.etag=e,a}async getFragmentById(t){let e=await fetch(`${this.cfFragmentsUrl}/${t}`,{headers:this.headers});if(!e.ok)throw new Error(`Failed to get fragment: ${e.status} ${e.statusText}`);return await this.getFragment(e)}async saveFragment(t){let{title:e,fields:a}=t,s=await fetch(`${this.cfFragmentsUrl}/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json","If-Match":t.etag,...this.headers},body:JSON.stringify({title:e,fields:a})}).catch(o=>{throw new Error(`${g}: ${o.message}`)});if(!s.ok)throw new Error(`Failed to save fragment: ${s.status} ${s.statusText}`);return await this.getFragment(s)}async copyFragmentClassic(t){let e=await this.getCsrfToken(),a=t.path.split("/").slice(0,-1).join("/"),s=new FormData;s.append("cmd","copyPage"),s.append("srcPath",t.path),s.append("destParentPath",a),s.append("shallow","false"),s.append("_charset_","UTF-8");let o=await fetch(this.wcmcommandUrl,{method:"POST",headers:{...this.headers,"csrf-token":e},body:s}).catch(y=>{throw new Error(`${g}: ${y.message}`)});if(!o.ok)throw new Error(`Failed to copy fragment: ${o.status} ${o.statusText}`);let r=await o.text(),h=new DOMParser().parseFromString(r,"text/html").getElementById("Message")?.textContent.trim();if(!h)throw new Error("Failed to extract new path from copy response");await $();let d=await this.getFragmentByPath(h);return d&&(d=await this.getFragmentById(d.id)),d}async publishFragment(t){let e=await fetch(this.cfPublishUrl,{method:"POST",headers:{"Content-Type":"application/json","If-Match":t.etag,...this.headers},body:JSON.stringify({paths:[t.path],filterReferencesByStatus:["DRAFT","UNPUBLISHED"],workflowModelId:"/var/workflow/models/scheduled_activation_with_references"})}).catch(a=>{throw new Error(`${g}: ${a.message}`)});if(!e.ok)throw new Error(`Failed to publish fragment: ${e.status} ${e.statusText}`);return await e.json()}async deleteFragment(t){let e=await fetch(`${this.cfFragmentsUrl}/${t.id}`,{method:"DELETE",headers:{"Content-Type":"application/json","If-Match":t.etag,...this.headers}}).catch(a=>{throw new Error(`${g}: ${a.message}`)});if(!e.ok)throw new Error(`Failed to delete fragment: ${e.status} ${e.statusText}`);return e}sites={cf:{fragments:{search:this.searchFragment.bind(this),getByPath:this.getFragmentByPath.bind(this),getById:this.getFragmentById.bind(this),save:this.saveFragment.bind(this),copy:this.copyFragmentClassic.bind(this),publish:this.publishFragment.bind(this),delete:this.deleteFragment.bind(this)}}}};var x="aem-bucket",F="publish-p22655-e155390",p={CATALOG:"catalog",AH:"ah",CCD_ACTION:"ccd-action",SPECIAL_OFFERS:"special-offers"},k={[p.CATALOG]:{title:{tag:"h3",slot:"heading-xs"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xs"},ctas:{size:"l"}},[p.AH]:{title:{tag:"h3",slot:"heading-xxs"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xxs"},ctas:{size:"s"}},[p.CCD_ACTION]:{title:{tag:"h3",slot:"heading-xs"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xs"},ctas:{size:"l"}},[p.SPECIAL_OFFERS]:{name:{tag:"h4",slot:"detail-m"},title:{tag:"h4",slot:"detail-m"},backgroundImage:{tag:"div",slot:"bg-image"},prices:{tag:"h3",slot:"heading-xs"},description:{tag:"div",slot:"body-xs"},ctas:{size:"l"}}};async function C(l,t,e,a){let s=l.fields.reduce((i,{name:n,multiple:c,values:h})=>(i[n]=c?h:h[0],i),{id:l.id});s.model=s.model;let{variant:o="catalog"}=s;e.setAttribute("variant",o);let r=k[o]??"catalog";if(s.mnemonicIcon?.forEach((i,n)=>{let c=s.mnemonicLink?.length>n?s.mnemonicLink[n]:"",h=s.mnemonicAlt?.length>n?s.mnemonicAlt[n]:"",d=m("merch-icon",{slot:"icons",src:i,alt:h,href:c,size:"l"});t(d)}),s.cardTitle&&r.title&&t(m(r.title.tag,{slot:r.title.slot},s.cardTitle)),s.backgroundImage&&r.backgroundImage&&t(m(r.backgroundImage.tag,{slot:r.backgroundImage.slot},``)),s.prices&&r.prices){let i=s.prices,n=m(r.prices.tag,{slot:r.prices.slot},i);t(n)}if(s.description&&r.description){let i=m(r.description.tag,{slot:r.description.slot},s.description);t(i)}if(s.ctas){let i=m("div",{slot:"footer"},s.ctas),n=[];[...i.querySelectorAll("a")].forEach(c=>{let h=c.parentElement.tagName==="STRONG";if(a)c.classList.add("con-button"),h&&c.classList.add("blue"),n.push(c);else{let T=m("sp-button",{treatment:h?"fill":"outline",variant:h?"accent":"primary"},c);T.addEventListener("click",E=>{E.stopPropagation(),c.click()}),n.push(T)}}),i.innerHTML="",i.append(...n),t(i)}}var w=class{#t=new Map;clear(){this.#t.clear()}add(...t){t.forEach(e=>{let{path:a}=e;a&&this.#t.set(a,e)})}has(t){return this.#t.has(t)}get(t){return this.#t.get(t)}remove(t){this.#t.delete(t)}},u=new w,b=class extends HTMLElement{#t;cache=u;refs=[];path;consonant=!1;#e;static get observedAttributes(){return["source","path","consonant"]}attributeChangedCallback(t,e,a){this[t]=a}connectedCallback(){this.consonant=this.hasAttribute("consonant"),this.clearRefs();let t=this.getAttribute(x)??F;this.#t=new f(t),this.refresh(!1)}clearRefs(){this.refs.forEach(t=>{t.remove()})}async refresh(t=!0){this.path&&(this.#e&&!await Promise.race([this.#e,Promise.resolve(!1)])||(this.clearRefs(),this.refs=[],t&&this.cache.remove(this.path),this.#e=this.fetchData().then(()=>!0)))}async fetchData(){let t=u.get(this.path);if(t||(t=await this.#t.sites.cf.fragments.getByPath(this.path),u.add(t)),t){C(t,a=>{this.parentElement.appendChild(a),this.refs.push(a)},this.parentElement,this.consonant);return}}get updateComplete(){return this.#e??Promise.reject(new Error("datasource is not correctly configured"))}};customElements.define("merch-datasource",b);export{b as MerchDataSource}; diff --git a/libs/features/mas/docs/plans.html b/libs/features/mas/docs/plans.html new file mode 100644 index 0000000000..38eccc0830 --- /dev/null +++ b/libs/features/mas/docs/plans.html @@ -0,0 +1,64 @@ + + + + + Plans merch cards + + + + + + + + + +
+
+
+
+
+
M@S2 Components
+
+
+ + +
+
+
+

<<Merch cards>>

+
+
+
+
+
+ +
+
+
+ + diff --git a/libs/features/mas/mocks/aem.js b/libs/features/mas/mocks/aem.js index c83e228b23..3d6d5a9226 100644 --- a/libs/features/mas/mocks/aem.js +++ b/libs/features/mas/mocks/aem.js @@ -3,12 +3,12 @@ export async function withAem(originalFetch) { if (/cf\/fragments\/search/.test(pathname)) { // TODO add conditional use case. return originalFetch( - '/test/mocks/sites/cf/fragments/search/default.json', + '/test/mocks/sites/cf/fragments/search/authorPayload.json', ); } else if (/cf\/fragments/.test(pathname) && searchParams.has('path')) { const path = searchParams.get('path'); const item = await originalFetch( - '/test/mocks/sites/cf/fragments/search/default.json', + '/test/mocks/sites/cf/fragments/search/authorPayload.json', ) .then((res) => res.json()) .then(({ items }) => items.find((item) => item.path === path)); diff --git a/libs/features/mas/mocks/sites/cf/fragments/search/authorPayload.json b/libs/features/mas/mocks/sites/cf/fragments/search/authorPayload.json new file mode 100644 index 0000000000..bd9114104f --- /dev/null +++ b/libs/features/mas/mocks/sites/cf/fragments/search/authorPayload.json @@ -0,0 +1,537 @@ +{ + "items": [ + { + "path": "/content/dam/sandbox/mas/creative-cloud", + "title": "Creative Cloud All Apps", + "description": "", + "id": "f4aafcef-d410-4092-9f77-a72b9234c224", + "created": { + "at": "2024-09-11T07:36:46.63Z", + "by": "johndoe@adobe.com", + "fullName": "John Doe" + }, + "modified": { + "at": "2024-09-11T08:41:22.433Z", + "by": "johndoe@adobe.com", + "fullName": "John Doe" + }, + "published": { + "at": "2024-09-11T08:27:19.117Z", + "by": "johndoe@adobe.com", + "fullName": "John Doe" + }, + "status": "MODIFIED", + "fields": [ + { + "name": "mnemonicIcon", + "type": "text", + "multiple": true, + "locked": false, + "values": [ + "/test/mocks/img/creative-cloud.svg" + ] + }, + { + "name": "mnemonicAlt", + "type": "text", + "multiple": true, + "locked": false, + "values": [ + "Creative Cloud Product Icon" + ] + }, + { + "name": "mnemonicLink", + "type": "text", + "multiple": true, + "locked": false, + "values": [ + "https://www.adobe.com/creativecloud/all-apps.html" + ] + }, + { + "name": "badge", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [] + }, + { + "name": "cardTitle", + "type": "text", + "multiple": false, + "locked": false, + "values": [ + "Creative Cloud All Apps" + ] + }, + { + "name": "cardTitleLink", + "type": "text", + "multiple": false, + "locked": false, + "values": [ + "https://www.adobe.com/creativecloud/all-apps.html" + ] + }, + { + "name": "prices", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [ + "" + ] + }, + { + "name": "shortDescription", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [] + }, + { + "name": "description", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [ + "

Get 25 apps and games plus fonts, storage, templates, and tutorials for less than the price of Acrobat Pro, Photoshop, and Premiere Pro sold separately. (Substance 3D apps not included.)

" + ] + }, + { + "name": "ctas", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [ + "Buy nowFree trial" + ] + }, + { + "name": "variant", + "type": "text", + "multiple": false, + "locked": false, + "values": [ + "ccd-action" + ] + }, + { + "name": "parent", + "type": "content-fragment", + "multiple": false, + "locked": false, + "values": [] + }, + { + "name": "product", + "type": "content-reference", + "multiple": false, + "locked": false, + "values": [] + }, + { + "name": "stockOffer", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [] + }, + { + "name": "secure", + "type": "boolean", + "multiple": false, + "locked": false, + "values": [false] + }, + { + "name": "promoCode", + "type": "text", + "multiple": false, + "locked": false, + "values": [] + } + ], + "variations": [], + "tags": [], + "references": [], + "model": { + "id": "L2NvbmYvbWFzL3NldHRpbmdzL2RhbS9jZm0vbW9kZWxzL2NhcmQ", + "path": "/conf/mas/settings/dam/cfm/models/card", + "name": "Card", + "title": "Card", + "description": "universal m@s card model" + }, + "validationStatus": [], + "fieldTags": [], + "etag": "\"18d6aa75a4d2d0d594ee363257f808f4\"" + }, + { + "path": "/content/dam/sandbox/mas/photoshop", + "title": "Photoshop", + "description": "", + "id": "d52dcff2-9dea-439e-a7a4-a53099ec9315", + "created": { + "at": "2024-05-08T12:05:04.785Z", + "by": "johndoe@adobe.com", + "fullName": "John Doe" + }, + "modified": { + "at": "2024-06-13T11:10:20.455Z", + "by": "johndoe@adobe.com", + "fullName": "John Doe" + }, + "published": { + "at": "2024-06-13T11:11:01.224Z", + "by": "johndoe@adobe.com", + "fullName": "John Doe" + }, + "status": "PUBLISHED", + "fields": [ + { + "name": "mnemonicIcon", + "type": "text", + "multiple": true, + "locked": false, + "values": [ + "/test/mocks/img/photoshop.svg" + ] + }, + { + "name": "mnemonicAlt", + "type": "text", + "multiple": true, + "locked": false, + "values": [ + "Photoshop Icon" + ] + }, + { + "name": "mnemonicLink", + "type": "text", + "multiple": true, + "locked": false, + "values": [ + "https://www.adobe.com/products/photoshop.html" + ] + }, + { + "name": "badge", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [] + }, + { + "name": "cardTitle", + "type": "text", + "multiple": false, + "locked": false, + "values": [ + "Photoshop" + ] + }, + { + "name": "cardTitleLink", + "type": "text", + "multiple": false, + "locked": false, + "values": [ + "https://www.adobe.com/products/photoshop.html" + ] + }, + { + "name": "prices", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [ + "" + ] + }, + { + "name": "shortDescription", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [] + }, + { + "name": "description", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [ + "

Edit, composite, and create beautiful images, graphics, and art on desktop and iPad.

" + ] + }, + { + "name": "ctas", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [ + "Buy nowFree trial" + ] + }, + { + "name": "variant", + "type": "text", + "multiple": false, + "locked": false, + "values": [ + "ccd-action" + ] + }, + { + "name": "parent", + "type": "content-fragment", + "multiple": false, + "locked": false, + "values": [] + }, + { + "name": "product", + "type": "content-reference", + "multiple": false, + "locked": false, + "values": [] + }, + { + "name": "stockOffer", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [] + }, + { + "name": "secure", + "type": "boolean", + "multiple": false, + "locked": false, + "values": [false] + }, + { + "name": "promoCode", + "type": "text", + "multiple": false, + "locked": false, + "values": [] + } + ], + "variations": [], + "tags": [], + "references": [], + "model": { + "id": "L2NvbmYvc2FuZGJveC9zZXR0aW5ncy9kYW0vY2ZtL21vZGVscy9tZXJjaC1jYXJk", + "path": "/conf/sandbox/settings/dam/cfm/models/merch-card", + "name": "Merch Card", + "title": "Merch Card", + "description": "content for adobe.com merch-card web component." + }, + "validationStatus": [], + "fieldTags": [], + "etag": "\"343f00d61244effce6e55c31cc90d4f9\"" + }, + { + "path": "/content/dam/sandbox/mas/special-offers-students-and-teachers", + "title": "Special Offers Students and Teachers", + "description": "", + "id": "64382bf2-6308-4245-85c6-ea43e0edb287", + "created": { + "at": "2024-08-15T21:48:42.597Z", + "by": "johndoe@adobe.com", + "fullName": "John Doe" + }, + "modified": { + "at": "2024-08-27T11:58:39.08Z", + "by": "johndoe@adobe.com", + "fullName": "John Doe" + }, + "published": { + "at": "2024-08-26T09:22:58.047Z", + "by": "johndoe@adobe.com", + "fullName": "John Doe" + }, + "status": "MODIFIED", + "fields": [ + { + "name": "mnemonicIcon", + "type": "text", + "multiple": true, + "locked": false, + "values": [ + ] + }, + { + "name": "mnemonicAlt", + "type": "text", + "multiple": true, + "locked": false, + "values": [ + ] + }, + { + "name": "mnemonicLink", + "type": "text", + "multiple": true, + "locked": false, + "values": [ + ] + }, + { + "name": "badge", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [] + }, + { + "name": "backgroundImage", + "type": "text", + "multiple": false, + "locked": false, + "values": [ + "/test/img/special-offers-img2.png" + ] + }, + { + "name": "cardTitle", + "type": "text", + "multiple": false, + "locked": false, + "values": [ + "Save over 30% on Creative Cloud All Apps." + ] + }, + { + "name": "cardTitleLink", + "type": "text", + "multiple": false, + "locked": false, + "values": [ + "https://www.adobe.com/products/special-offers.html" + ] + }, + { + "name": "prices", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [ + "" + ] + }, + { + "name": "shortDescription", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [] + }, + { + "name": "description", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [ + "

Join us for the creative event of the year Oct 14-16. Register by August 31 and save US$200 on a full conference pass.

See terms

" + ] + }, + { + "name": "ctas", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [ + "

Buy now

" + ] + }, + { + "name": "variant", + "type": "text", + "multiple": false, + "locked": false, + "values": [ + "special-offers" + ] + }, + { + "name": "parent", + "type": "content-fragment", + "multiple": false, + "locked": false, + "values": [] + }, + { + "name": "product", + "type": "content-reference", + "multiple": false, + "locked": false, + "values": [] + }, + { + "name": "stockOffer", + "type": "long-text", + "multiple": false, + "locked": false, + "mimeType": "text/html", + "values": [] + }, + { + "name": "secure", + "type": "boolean", + "multiple": false, + "locked": false, + "values": [false] + }, + { + "name": "promoCode", + "type": "text", + "multiple": false, + "locked": false, + "values": [] + } + ], + "variations": [], + "tags": [], + "references": [], + "model": { + "id": "L2NvbmYvc2FuZGJveC9zZXR0aW5ncy9kYW0vY2ZtL21vZGVscy9tZXJjaC1jYXJk", + "path": "/conf/sandbox/settings/dam/cfm/models/merch-card", + "name": "Merch Card", + "title": "Merch Card", + "description": "content for adobe.com merch-card web component." + }, + "validationStatus": [ + { + "property": "fields.description.values[0].", + "message": "has unsafe html content" + }, + { + "property": "fields.ctas.values[0].", + "message": "has unsafe html content" + } + ], + "fieldTags": [] + } + ] +} diff --git a/libs/features/mas/mocks/sites/cf/fragments/search/default.json b/libs/features/mas/mocks/sites/cf/fragments/search/default.json deleted file mode 100644 index cf638313f1..0000000000 --- a/libs/features/mas/mocks/sites/cf/fragments/search/default.json +++ /dev/null @@ -1,356 +0,0 @@ -{ - "items": [ - { - "path": "/content/dam/sandbox/mas/creative-cloud", - "title": "Creative Cloud All Apps", - "description": "", - "id": "be9aa9c6-b8e9-4058-aa6b-f0125647479a", - "created": { - "at": "2024-05-08T12:05:03.588Z", - "by": "johndoe@adobe.com", - "fullName": "John Doe" - }, - "modified": { - "at": "2024-06-13T11:10:53.174Z", - "by": "johndoe@adobe.com", - "fullName": "John Doe" - }, - "published": { - "at": "2024-06-13T11:11:01.224Z", - "by": "johndoe@adobe.com", - "fullName": "John Doe" - }, - "status": "PUBLISHED", - "fields": [ - { - "name": "type", - "type": "enumeration", - "multiple": false, - "values": ["ccd-action"] - }, - { - "name": "icon", - "type": "text", - "multiple": true, - "values": ["/test/mocks/img/creative-cloud.svg"] - }, - { - "name": "name", - "type": "text", - "multiple": false, - "values": ["creative-cloud"] - }, - { - "name": "title", - "type": "text", - "multiple": false, - "values": ["Creative Cloud All Apps"] - }, - { - "name": "link", - "type": "text", - "multiple": false, - "values": [] - }, - { - "name": "prices", - "type": "long-text", - "multiple": false, - "mimeType": "text/html", - "values": [ - "" - ] - }, - { - "name": "description", - "type": "long-text", - "multiple": false, - "mimeType": "text/html", - "values": [ - "

Get 25 apps and games plus fonts, storage, templates, and tutorials for less than the price of Acrobat Pro, Photoshop, and Premiere Pro sold separately. (Substance 3D apps not included.)

" - ] - }, - { - "name": "secure", - "type": "boolean", - "multiple": false, - "values": [true] - }, - { - "name": "stock", - "type": "boolean", - "multiple": false, - "values": [true] - }, - { - "name": "ctas", - "type": "long-text", - "multiple": false, - "mimeType": "text/html", - "values": [ - "Buy nowFree trial" - ] - } - ], - "variations": [], - "tags": [], - "references": [], - "model": { - "id": "L2NvbmYvc2FuZGJveC9zZXR0aW5ncy9kYW0vY2ZtL21vZGVscy9tZXJjaC1jYXJk", - "path": "/conf/sandbox/settings/dam/cfm/models/merch-card", - "name": "Merch Card", - "title": "Merch Card", - "description": "content for adobe.com merch-card web component." - }, - "validationStatus": [], - "fieldTags": [], - "etag": "\"2028f561fa1f216104ee23d9ee4a141e\"" - }, - { - "path": "/content/dam/sandbox/mas/photoshop", - "title": "Photoshop", - "description": "", - "id": "d52dcff2-9dea-439e-a7a4-a53099ec9315", - "created": { - "at": "2024-05-08T12:05:04.785Z", - "by": "johndoe@adobe.com", - "fullName": "John Doe" - }, - "modified": { - "at": "2024-06-13T11:10:20.455Z", - "by": "johndoe@adobe.com", - "fullName": "John Doe" - }, - "published": { - "at": "2024-06-13T11:11:01.224Z", - "by": "johndoe@adobe.com", - "fullName": "John Doe" - }, - "status": "PUBLISHED", - "fields": [ - { - "name": "type", - "type": "enumeration", - "multiple": false, - "values": ["ccd-action"] - }, - { - "name": "icon", - "type": "text", - "multiple": true, - "values": ["/test/mocks/img/photoshop.svg"] - }, - { - "name": "name", - "type": "text", - "multiple": false, - "values": ["photoshop"] - }, - { - "name": "title", - "type": "text", - "multiple": false, - "values": ["Photoshop"] - }, - { - "name": "link", - "type": "text", - "multiple": false, - "values": [] - }, - { - "name": "prices", - "type": "long-text", - "multiple": false, - "mimeType": "text/html", - "values": [ - "" - ] - }, - { - "name": "description", - "type": "long-text", - "multiple": false, - "mimeType": "text/html", - "values": [ - "

Edit, composite, and create beautiful images, graphics, and art on desktop and iPad.

" - ] - }, - { - "name": "secure", - "type": "boolean", - "multiple": false, - "values": [true] - }, - { - "name": "stock", - "type": "boolean", - "multiple": false, - "values": [true] - }, - { - "name": "ctas", - "type": "long-text", - "multiple": false, - "mimeType": "text/html", - "values": [ - "Buy nowFree trial" - ] - } - ], - "variations": [], - "tags": [], - "references": [], - "model": { - "id": "L2NvbmYvc2FuZGJveC9zZXR0aW5ncy9kYW0vY2ZtL21vZGVscy9tZXJjaC1jYXJk", - "path": "/conf/sandbox/settings/dam/cfm/models/merch-card", - "name": "Merch Card", - "title": "Merch Card", - "description": "content for adobe.com merch-card web component." - }, - "validationStatus": [], - "fieldTags": [], - "etag": "\"343f00d61244effce6e55c31cc90d4f9\"" - }, - { - "path": "/content/dam/sandbox/mas/special-offers-students-and-teachers", - "title": "Special Offers Students and Teachers", - "description": "", - "id": "64382bf2-6308-4245-85c6-ea43e0edb287", - "created": { - "at": "2024-08-15T21:48:42.597Z", - "by": "johndoe@adobe.com", - "fullName": "John Doe" - }, - "modified": { - "at": "2024-08-27T11:58:39.08Z", - "by": "johndoe@adobe.com", - "fullName": "John Doe" - }, - "published": { - "at": "2024-08-26T09:22:58.047Z", - "by": "johndoe@adobe.com", - "fullName": "John Doe" - }, - "status": "MODIFIED", - "fields": [ - { - "name": "variant", - "type": "enumeration", - "multiple": false, - "locked": false, - "values": ["special-offers"] - }, - { - "name": "icon", - "type": "text", - "multiple": true, - "locked": false, - "values": [] - }, - { - "name": "name", - "type": "text", - "multiple": false, - "locked": false, - "values": ["Special Offers Students and Teachers"] - }, - { - "name": "title", - "type": "text", - "multiple": false, - "locked": false, - "values": ["Individuals"] - }, - { - "name": "link", - "type": "text", - "multiple": false, - "locked": false, - "values": [] - }, - { - "name": "backgroundImage", - "type": "text", - "multiple": false, - "locked": false, - "values": [ - "/test/img/special-offers-img2.png" - ] - }, - { - "name": "prices", - "type": "long-text", - "multiple": false, - "locked": false, - "mimeType": "text/html", - "values": [ - "

Save over 30% on Creative Cloud All Apps.

" - ] - }, - { - "name": "description", - "type": "long-text", - "multiple": false, - "locked": false, - "mimeType": "text/html", - "values": [ - "

Join us for the creative event of the year Oct 14-16. Register by August 31 and save US$200 on a full conference pass.

See terms

" - ] - }, - { - "name": "secure", - "type": "boolean", - "multiple": false, - "locked": false, - "values": [false] - }, - { - "name": "stock", - "type": "boolean", - "multiple": false, - "locked": false, - "values": [false] - }, - { - "name": "ctas", - "type": "long-text", - "multiple": false, - "locked": false, - "mimeType": "text/html", - "values": [ - "

Buy now

" - ] - }, - { - "name": "xlg", - "type": "text", - "multiple": false, - "locked": false, - "values": ["photoshop-lapsed"] - } - ], - "variations": [], - "tags": [], - "references": [], - "model": { - "id": "L2NvbmYvc2FuZGJveC9zZXR0aW5ncy9kYW0vY2ZtL21vZGVscy9tZXJjaC1jYXJk", - "path": "/conf/sandbox/settings/dam/cfm/models/merch-card", - "name": "Merch Card", - "title": "Merch Card", - "description": "content for adobe.com merch-card web component." - }, - "validationStatus": [ - { - "property": "fields.description.values[0].", - "message": "has unsafe html content" - }, - { - "property": "fields.ctas.values[0].", - "message": "has unsafe html content" - } - ], - "fieldTags": [] - } - ] -} diff --git a/libs/features/mas/web-components/src/merch-datasource.js b/libs/features/mas/web-components/src/merch-datasource.js index c0ea3fd8f9..9c4b6b17f0 100644 --- a/libs/features/mas/web-components/src/merch-datasource.js +++ b/libs/features/mas/web-components/src/merch-datasource.js @@ -2,6 +2,7 @@ import { AEM } from './aem.js'; import { createTag } from './utils.js'; const ATTR_AEM_BUCKET = 'aem-bucket'; +const AEM_BUCKET = 'publish-p22655-e155390'; const VARIANTS = { CATALOG: 'catalog', @@ -52,23 +53,25 @@ async function parseMerchCard(fragmentData, appendFn, merchCard, consonant) { const { variant = 'catalog' } = item; merchCard.setAttribute('variant', variant); const cardMapping = cardContent[variant] ?? 'catalog'; - item.icon?.forEach((icon) => { + item.mnemonicIcon?.forEach((icon, idx) => { + const href = item.mnemonicLink?.length > idx ? item.mnemonicLink[idx] : ''; + const alt = item.mnemonicAlt?.length > idx ? item.mnemonicAlt[idx] : ''; const merchIcon = createTag('merch-icon', { slot: 'icons', src: icon, - alt: '', - href: '', + alt, + href, size: 'l', }); appendFn(merchIcon); }); - if (item.title && cardMapping.title) { + if (item.cardTitle && cardMapping.title) { appendFn( createTag( cardMapping.title.tag, { slot: cardMapping.title.slot }, - item.title, + item.cardTitle, ), ); } @@ -210,7 +213,7 @@ export class MerchDataSource extends HTMLElement { this.consonant = this.hasAttribute('consonant'); this.clearRefs(); const bucket = - this.getAttribute(ATTR_AEM_BUCKET) ?? 'publish-p22655-e59341'; + this.getAttribute(ATTR_AEM_BUCKET) ?? AEM_BUCKET; this.#aem = new AEM(bucket); this.refresh(false); } diff --git a/libs/features/mas/web-components/test/merch-datasource.test.html.js b/libs/features/mas/web-components/test/merch-datasource.test.html.js index 70ba7f4ee4..b4ba7c3d74 100644 --- a/libs/features/mas/web-components/test/merch-datasource.test.html.js +++ b/libs/features/mas/web-components/test/merch-datasource.test.html.js @@ -13,7 +13,7 @@ const expect = chai.expect; runTests(async () => { const [cc, photoshop] = await fetch( - 'mocks/sites/cf/fragments/search/default.json', + 'mocks/sites/cf/fragments/search/authorPayload.json', ) .then((res) => res.json()) .then(({ items }) => items); @@ -44,6 +44,7 @@ runTests(async () => { const [ccCard, photoshopCard] = getTemplateContent('cards'); document.querySelector('main').append(ccCard, photoshopCard); expect(aemMock.count).to.equal(0); + const card = document.querySelector('main merch-card:has(> merch-datasource[path="/content/dam/sandbox/mas/creative-cloud"])'); }); it('re-renders a card after clearing the cache', async () => { From 549c71f6e650496b20d14fa5748ee4d1f7307272 Mon Sep 17 00:00:00 2001 From: Ryan Clayton Date: Thu, 19 Sep 2024 02:14:22 -0600 Subject: [PATCH 03/13] MWPW-154059 - Milo templates library (#2855) * MWPW-154059 - Milo templates library * Allows template-metadata block to output metadata block in template * Fixes inital listing order * Adds search ability to templates Resolves: MWPW-154059 * Updating unit tests * Addressing eslint issue * Address PR feedback --------- Co-authored-by: Ryan Clayton --- libs/blocks/library-config/library-config.css | 6 ++- libs/blocks/library-config/library-config.js | 45 ++++++++++++---- libs/blocks/library-config/library-utils.js | 22 +++++++- libs/blocks/library-config/lists/blocks.js | 14 ++--- libs/blocks/library-config/lists/templates.js | 51 +++++++++++++++++-- .../library-metadata/library-metadata.css | 1 + .../library-config/library-config.test.js | 25 ++++----- 7 files changed, 123 insertions(+), 41 deletions(-) diff --git a/libs/blocks/library-config/library-config.css b/libs/blocks/library-config/library-config.css index 1f7b6df019..121f79c95a 100644 --- a/libs/blocks/library-config/library-config.css +++ b/libs/blocks/library-config/library-config.css @@ -205,7 +205,8 @@ input.sk-library-search-input:focus { * Fixes block list getting cut off with search * Margin height equal to search bar height */ -.sk-library ul.con-blocks-list.inset { +.sk-library ul.con-blocks-list.inset, +.sk-library ul.con-templates-list.inset { margin-bottom: 39px; } @@ -242,7 +243,8 @@ input.sk-library-search-input:focus { font-weight: 700; } -.sk-library .block-group.is-hidden { +.sk-library .block-group.is-hidden, +.con-templates-list .template.is-hidden { display: none; } diff --git a/libs/blocks/library-config/library-config.js b/libs/blocks/library-config/library-config.js index c7bc4f2026..394ec5a9b7 100644 --- a/libs/blocks/library-config/library-config.js +++ b/libs/blocks/library-config/library-config.js @@ -2,14 +2,14 @@ import { createTag } from '../../utils/utils.js'; const LIBRARY_PATH = '/docs/library/library.json'; -async function loadBlocks(content, list, query) { +async function loadBlocks({ content, list, query, type }) { const { default: blocks } = await import('./lists/blocks.js'); - blocks(content, list, query); + blocks(content, list, query, type); } -async function loadTemplates(content, list) { +async function loadTemplates({ content, list, query, type }) { const { default: templates } = await import('./lists/templates.js'); - templates(content, list); + templates(content, list, query, type); } async function loadPlaceholders(content, list) { @@ -32,7 +32,7 @@ async function loadPersonalization(content, list) { personalization(content, list); } -function addSearch(content, list) { +function addSearch({ content, list, type }) { const skLibrary = list.closest('.sk-library'); const header = skLibrary.querySelector('.sk-library-header'); let search = skLibrary.querySelector('.sk-library-search'); @@ -40,6 +40,7 @@ function addSearch(content, list) { search = createTag('div', { class: 'sk-library-search' }); const searchInput = createTag('input', { class: 'sk-library-search-input', placeholder: 'Search...' }); const clear = createTag('div', { class: 'sk-library-search-clear is-hidden' }); + searchInput.addEventListener('input', (e) => { const query = e.target.value; if (query === '') { @@ -47,12 +48,31 @@ function addSearch(content, list) { } else { clear.classList.remove('is-hidden'); } - loadBlocks(content, list, query); + + switch (type) { + case 'blocks': + loadBlocks({ content, list, query, type }); + break; + case 'templates': + loadTemplates({ content, list, query, type }); + break; + default: + } }); clear.addEventListener('click', (e) => { e.target.classList.add('is-hidden'); e.target.closest('.sk-library-search').querySelector('.sk-library-search-input').value = ''; - loadBlocks(content, list); + const query = e.target.value; + + switch (type) { + case 'blocks': + loadBlocks({ content, list, query, type }); + break; + case 'templates': + loadTemplates({ content, list, query, type }); + break; + default: + } }); search.append(searchInput); search.append(clear); @@ -67,11 +87,12 @@ async function loadList(type, content, list) { const query = list.closest('.sk-library').querySelector('.sk-library-search-input')?.value; switch (type) { case 'blocks': - addSearch(content, list); - loadBlocks(content, list, query); + addSearch({ content, list, type }); + loadBlocks({ content, list, query, type }); break; case 'templates': - loadTemplates(content, list); + addSearch({ content, list, type }); + loadTemplates({ content, list, query, type }); break; case 'placeholders': loadPlaceholders(content, list); @@ -198,6 +219,10 @@ function createHeader() { el.classList.remove('inset'); }); skLibrary.classList.remove('allow-back'); + + // Remove library search if it's been added + const search = skLibrary.querySelector('.sk-library-search'); + if (search) search.remove(); }); return header; } diff --git a/libs/blocks/library-config/library-utils.js b/libs/blocks/library-config/library-utils.js index 0143b851d4..b8048c09d9 100644 --- a/libs/blocks/library-config/library-utils.js +++ b/libs/blocks/library-config/library-utils.js @@ -1,4 +1,24 @@ -/* global ClipboardItem */ +import { getSearchTags } from './lists/blocks.js'; +import { getTemplateSearchTags } from './lists/templates.js'; + +/* search utility */ +export function isMatching(container, query, type, titleText) { + let tagsString; + + switch (type) { + case 'blocks': + tagsString = getSearchTags(container); + break; + case 'templates': + tagsString = getTemplateSearchTags(container, titleText); + break; + default: + } + if (!query || !tagsString) return false; + const searchTokens = query.split(' '); + return searchTokens.every((token) => tagsString.toLowerCase().includes(token.toLowerCase())); +} + export default function createCopy(blob) { const data = [new ClipboardItem({ [blob.type]: blob })]; navigator.clipboard.write(data); diff --git a/libs/blocks/library-config/lists/blocks.js b/libs/blocks/library-config/lists/blocks.js index f5f59352f1..69de637170 100644 --- a/libs/blocks/library-config/lists/blocks.js +++ b/libs/blocks/library-config/lists/blocks.js @@ -1,5 +1,5 @@ import { createTag } from '../../../utils/utils.js'; -import createCopy from '../library-utils.js'; +import createCopy, { isMatching } from '../library-utils.js'; import { getMetadata } from '../../section-metadata/section-metadata.js'; const LIBRARY_METADATA = 'library-metadata'; @@ -132,13 +132,6 @@ export function getSearchTags(container) { return containerName; } -export function isMatching(container, query) { - const tagsString = getSearchTags(container); - if (!query || !tagsString) return false; - const searchTokens = query.split(' '); - return searchTokens.every((token) => tagsString.toLowerCase().includes(token.toLowerCase())); -} - function getBlockType(subSection, withinContainer) { if (subSection.className === LIBRARY_CONTAINER_START) return CONTAINER_START_BLOCK; if (subSection.className === LIBRARY_CONTAINER_END) return CONTAINER_END_BLOCK; @@ -247,7 +240,7 @@ export function getContainers(doc) { return containers; } -export default async function loadBlocks(blocks, list, query) { +export default async function loadBlocks(blocks, list, query, type) { list.textContent = ''; blocks.forEach(async (block) => { const titleText = createTag('p', { class: 'item-title' }, block.name); @@ -277,7 +270,6 @@ export default async function loadBlocks(blocks, list, query) { const html = await resp.text(); const parser = new DOMParser(); const doc = parser.parseFromString(html, 'text/html'); - const containers = getContainers(doc); let matchingContainerFound = false; @@ -298,7 +290,7 @@ export default async function loadBlocks(blocks, list, query) { item.append(name, copy); if (query) { - if (isMatching(container, query)) { + if (isMatching(container, query, type)) { matchingContainerFound = true; } else { item.classList.add('is-hidden'); diff --git a/libs/blocks/library-config/lists/templates.js b/libs/blocks/library-config/lists/templates.js index 736f79c35c..f917a2c5a4 100644 --- a/libs/blocks/library-config/lists/templates.js +++ b/libs/blocks/library-config/lists/templates.js @@ -1,5 +1,6 @@ import { createTag } from '../../../utils/utils.js'; -import createCopy from '../library-utils.js'; +import createCopy, { isMatching } from '../library-utils.js'; +import { getMetadata } from '../../section-metadata/section-metadata.js'; import { getTable, decorateImages, handleLinks } from './blocks.js'; function createSpace() { @@ -7,6 +8,16 @@ function createSpace() { return createTag('p', null, br); } +export function getTemplateSearchTags(template, titleText) { + const templateName = titleText.textContent; + + if (template.searchtags?.text) { + const terms = template.searchtags?.text.trim().toLowerCase(); + return `${terms} ${templateName}`; + } + return templateName; +} + function formatDom(aemDom, path) { // Decorate Links handleLinks(aemDom, path); @@ -16,11 +27,27 @@ function formatDom(aemDom, path) { // Decorate Blocks const divs = aemDom.querySelectorAll('main > div > div'); + const template = {}; + divs.forEach((div) => { + // If there is library-metadata, extract searchTags. Remove library-metadata. + if (div.classList.contains('library-metadata')) { + const libraryMetadata = getMetadata(div); + template.searchtags = libraryMetadata.searchtags; + div.remove(); + return; + } // Give table some space div.insertAdjacentElement('afterend', createSpace()); const table = getTable(div, true); + const th = table.querySelector('th'); + + // Converts to a metadata block so it can be copied/pasted. + if (th.textContent === 'template-metadata') { + th.textContent = 'metadata'; + } + div.parentElement.replaceChild(table, div); }); @@ -38,7 +65,8 @@ function formatDom(aemDom, path) { }); const flattedDom = createTag('div'); flattedDom.append(...formattedSections); - return flattedDom; + template.flattedDom = flattedDom; + return template; } async function formatTemplate(path) { @@ -50,13 +78,14 @@ async function formatTemplate(path) { return formatDom(dom, path); } -export default async function loadTemplates(templates, list) { +export default async function loadTemplates(templates, list, query, type) { + list.textContent = ''; + templates.forEach(async (template) => { const titleText = createTag('p', { class: 'item-title' }, template.name); const title = createTag('li', { class: 'template' }, titleText); const previewButton = createTag('button', { class: 'preview-group' }, 'Preview'); const copy = createTag('button', { class: 'copy' }); - const formatted = await formatTemplate(template.path); list.append(title); title.append(previewButton, copy); @@ -66,10 +95,22 @@ export default async function loadTemplates(templates, list) { window.open(template.path, '_templatepreview'); }); + // Returns an object with flattedDom and searchtags. + const formatted = await formatTemplate(template.path); + if (query) { + if (isMatching(formatted, query, type, titleText)) { + title.classList.remove('is-hidden'); + } else { + title.classList.add('is-hidden'); + } + } else { + title.classList.remove('is-hidden'); + } + copy.addEventListener('click', (e) => { e.target.classList.add('copied'); setTimeout(() => { e.target.classList.remove('copied'); }, 3000); - const blob = new Blob([formatted.outerHTML], { type: 'text/html' }); + const blob = new Blob([formatted.flattedDom.outerHTML], { type: 'text/html' }); createCopy(blob); }); }); diff --git a/libs/blocks/library-metadata/library-metadata.css b/libs/blocks/library-metadata/library-metadata.css index ce00217e59..4a9c2589b2 100644 --- a/libs/blocks/library-metadata/library-metadata.css +++ b/libs/blocks/library-metadata/library-metadata.css @@ -18,6 +18,7 @@ .library-meta-row { background-color: #EFEFEF; + color: initial; display: grid; grid-template-columns: 1fr 1fr; margin-top: 4px; diff --git a/test/blocks/library-config/library-config.test.js b/test/blocks/library-config/library-config.test.js index 3478cfc4d7..4de9ad2ebf 100644 --- a/test/blocks/library-config/library-config.test.js +++ b/test/blocks/library-config/library-config.test.js @@ -1,7 +1,8 @@ import { readFile } from '@web/test-runner-commands'; import { expect } from '@esm-bundle/chai'; -const { getContainers, getSearchTags, isMatching, getHtml } = await import('../../../libs/blocks/library-config/lists/blocks.js'); +const { getContainers, getSearchTags, getHtml } = await import('../../../libs/blocks/library-config/lists/blocks.js'); +const { isMatching } = await import('../../../libs/blocks/library-config/library-utils.js'); const BLOCK_PAGE_URL = 'https://main--milo--adobecom.hlx.page/path/to/block/page'; function verifyContainer(container, elementsLength, hasLibraryMetadata) { @@ -35,8 +36,8 @@ describe('Library Config: text', () => { const searchTags = getSearchTags(containers[0]); expect(searchTags).to.equal('tb-2up-gr10 tb-3up-gr12 text'); // verify isMatching() - expect(isMatching(containers[0], 'tb-2up-gr10')).to.be.true; - expect(isMatching(containers[0], 'non-existing')).to.be.false; + expect(isMatching(containers[0], 'tb-2up-gr10', 'blocks')).to.be.true; + expect(isMatching(containers[0], 'non-existing', 'blocks')).to.be.false; }); }); @@ -62,8 +63,8 @@ describe('Library Config: chart', () => { const searchTags = getSearchTags(containers[0]); expect(searchTags).to.equal('chart-0 chart (area, green, border)'); // verify isMatching() - expect(isMatching(containers[0], 'chart-0')).to.be.true; - expect(isMatching(containers[0], 'non-existing')).to.be.false; + expect(isMatching(containers[0], 'chart-0', 'blocks')).to.be.true; + expect(isMatching(containers[0], 'non-existing', 'blocks')).to.be.false; }); }); @@ -89,8 +90,8 @@ describe('Library Config: marquee', () => { const searchTags = getSearchTags(containers[0]); expect(searchTags).to.equal('mq-std-md-lt mq-std-md-rt mq-std-md-lt-vid marquee-dark marquee'); // verify isMatching() - expect(isMatching(containers[0], 'mq-std-md-lt')).to.be.true; - expect(isMatching(containers[0], 'non-existing')).to.be.false; + expect(isMatching(containers[0], 'mq-std-md-lt', 'blocks')).to.be.true; + expect(isMatching(containers[0], 'non-existing', 'blocks')).to.be.false; }); }); @@ -168,10 +169,10 @@ describe('Library Config: containers', () => { it('isMatching', async () => { document.body.innerHTML = mixedHtml; const containers = getContainers(document); - expect(isMatching(containers[0], 'tag1')).to.be.false; - expect(isMatching(containers[1], 'tag1')).to.be.true; - expect(isMatching(containers[2], 'tag2')).to.be.true; - expect(isMatching(containers[3], 'tag3')).to.be.true; - expect(isMatching(containers[4], 'tag4')).to.be.true; + expect(isMatching(containers[0], 'tag1', 'blocks')).to.be.false; + expect(isMatching(containers[1], 'tag1', 'blocks')).to.be.true; + expect(isMatching(containers[2], 'tag2', 'blocks')).to.be.true; + expect(isMatching(containers[3], 'tag3', 'blocks')).to.be.true; + expect(isMatching(containers[4], 'tag4', 'blocks')).to.be.true; }); }); From 740348ca5831b06ba9e8fc3b30256a2aeac01c64 Mon Sep 17 00:00:00 2001 From: Robert Bogos <146744221+robert-bogos@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:59:14 +0300 Subject: [PATCH 04/13] [MWPW-158756] Enhance stage links conversion for cross-domain localization (#2913) * support cross-domain localization on stage links conversion * Update libs/utils/utils.js Co-authored-by: Rares Munteanu * hotfix --------- Co-authored-by: Rares Munteanu --- libs/utils/utils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 07fee41492..7f1a434d83 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -659,8 +659,7 @@ export function decorateLinks(el) { decorateImageLinks(el); const anchors = el.getElementsByTagName('a'); const { hostname } = window.location; - convertStageLinks({ anchors, config, hostname }); - return [...anchors].reduce((rdx, a) => { + const links = [...anchors].reduce((rdx, a) => { appendHtmlToLink(a); a.href = localizeLink(a.href); decorateSVG(a); @@ -695,6 +694,8 @@ export function decorateLinks(el) { } return rdx; }, []); + convertStageLinks({ anchors, config, hostname }); + return links; } function decorateContent(el) { From 647f799155a3a3f6b9b3787783b2c0e2dd6a78d8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:15:42 +0000 Subject: [PATCH 05/13] [AUTOMATED-PR] Update imslib.min.js dependency (#2872) 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 ab5505bf74..ee4e1f813e 100644 --- a/libs/deps/imslib.min.js +++ b/libs/deps/imslib.min.js @@ -1,4 +1,4 @@ -// Built 2024-08-14T01:18:38.920Z - Last Modified 2024-08-13T11:31:26.000Z +// Built 2024-09-12T01:22:29.208Z - Last Modified 2024-09-11T13:09:14.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.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}())}(); +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.45.0-8-gd14e654"}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 k(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}function y(e,t){if(null==e)return t;if(e===t)return e;if(!k(e))return e;var r=Object.assign({},e);return k(t)&&Object.keys(t).forEach((function(o){var n,i;k(t[o])?o in e?r[o]=y(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 y(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 y(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=y(h.state||{},l));var f=b.createRedirectUrl(s,a,h,"authorize",p),v=n.locale||c||"",g=e.response_type,k=void 0===g?h.response_type||"":g;return r(r({},h),{client_id:a,scope:p,locale:v,response_type:k,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),A=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}(),E=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 A(this.status,this.response)):r(new A(this.status,this.response))},o.onerror=function(){var e=new A(this.status,this.response);return r(e)},o.ontimeout=function(){var e=new A(0,"timeout");return r(e)},o.onabort=function(){var e=new A(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(E.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}()),J=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 E.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 E.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=B.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}()),K=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),J.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 J.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 J.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 J.post(i,r({client_id:t,access_token:o},n),s)},e.prototype.checkStatus=function(){var e=m.baseUrlServices+"/ims/check/v1/status";return J.get(e)},e.prototype.checkToken=function(e,t,n){var i=e.client_id,s=e.scope,a=t.arkoseSessionToken,c=o(t,["arkoseSessionToken"]),u=r({},w.mergeExternalParameters(c,this.apiParameters,"check_token")),l=r(r({},u),{client_id:i,scope:s});return a&&(l.arkose_session_token=a),n&&(l.user_id=n),this.callCheckToken(v.uriEncodeData(l),i,"/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 J.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 J.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 J.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),J.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),J.post(i,s,a)},e.prototype.jumpTokenToDevice=function(e,t,o,n){void 0===t&&(t={});var i=r({},w.mergeExternalParameters(t,this.apiParameters,"jumptoken_to_device"));!i.user_id&&n&&(i.user_id=n);var s=m.baseUrlServices+"/ims/jumptoken/v2?client_id="+o+"&jslVersion="+m.jslibver,a=v.uriEncodeData(r(r({},i),e)),c=this.formEncoded();return this.addClientIdInHeader(o,c),J.post(s,a,c)},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 J.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),J.post(m.checkTokenEndpoint.url+"/ims"+r,e,o).catch((function(t){if(!m.checkTokenEndpoint.shouldFallbackToAdobe(t))throw t;return J.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",e.ARKOSE_ERROR="arkose_error"}(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,k=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=k}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;rge.lastUserInteraction&&(ge.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,k=r.gse;p.info("token",i),d.from_ims&&v.setHash(d.old_hash||""),o.profileService.removeProfileIfOtherUser(u);var y={token:i,expire:a,sid:c,impersonatorId:h,isImpersonatedSession:f,pbaSatisfiedPolicies:g,isGuestToken:m,gse:k};return r.isReauth()?t.triggerOnReauthAccessToken(y):o.tokenReceived(y),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 K(c),this.csrfService=new f(u,this.instanceKey),this.serviceRequest={clientId:u,scope:l,imsApis:this.imsApis},this.tokenService=new fe(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),ge.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=r.enableGuestBotDetection,l=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,enableGuestBotDetection:u});break;default:e=this.tokenService.getTokenAndProfile}return e().then(this.processTokenResponse,this.processError.apply(this)).then((function(e){l=e})).finally((function(){p.info("onReady initialization"),window.addEventListener("getImsLibInstance",(function(){t.triggerOnImsInstance(t)}),!1),s&&v.setHash(te.removeAccessToken()),o.triggerOnReady(l?l.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){void 0===t&&(t={});var r=this.tokenService.getTokenFieldsFromStorage(),o=r?r.user_id:null;return this.imsApis.jumpTokenToDevice(e,t,this.adobeIdData.client_id,o)},e}(),ke=new(function(){function e(){this.createIMSLib=function(e,t){void 0===e&&(e=null),void 0===t&&(t="adobeIMS");var r=new me(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(){ke.initAdobeIms()}return e.prototype.initialize=function(){return!0},e}())}(); From adf2a9c611908a2c0b23d08c114c1a67632660b5 Mon Sep 17 00:00:00 2001 From: Santoshkumar Nateekar Date: Thu, 19 Sep 2024 09:12:23 -0700 Subject: [PATCH 06/13] [MWPW-158021] Update Milo README with Nala commands details (#2909) * update readme with nala commands * update few command sentences * horizontal line * update horizontal line * update heading * update nala wiki link --------- Co-authored-by: Santoshkumar Sharanappa Nateekar --- README.md | 43 ++++++++++++++++++++++++++++++++++++++++++ nala/utils/nala.run.js | 14 +++++++------- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b8cbb78ba3..e5639acff0 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ https://feat-branch--project--owner.hlx.page/?milolibs=local (feature code, stag ``` ## Testing +### Unit Testing ```sh npm run test ``` @@ -69,3 +70,45 @@ npm run test:watch ### Coverage `npm run test:watch` can give misleading coverage reports. Use `npm run test` for accurate coverage reporting. +### Nala E2E UI Testing +----- + +#### 1. Running Nala Tests +Nala tests are run using the `npm run nala [options]` command: + +```sh +npm run nala [options] +``` +```sh +# env: [local | libs | branch | stage | etc ] default: local + +# options: + - browser= # Browser to use (default: chrome) + - device= # Device (default: desktop) + - test=<.test.js> # Specific test file to run (runs all tests in the file) + - -g, --g=<@tag> # Tag to filter tests by annotations ex: @test1 @accordion @marquee + - mode= # Mode (default: headless) + - config= # Configuration file (default: Playwright default) + - project= # Project configuration (default: milo-live-chromium) + - milolibs= # Milolibs?= + +``` +#### 2. Nala Help Command: +To view examples of how to use Nala commands with various options, you can run +```sh +npm run nala help +``` + +#### ⚠️ Important Note +- **Debug and UI Mode Caution**: When using `debug` or `ui` mode, it is recommended to run only a single test using annotations (e.g., `@test1`). Running multiple tests in these modes (e.g., `npm run nala local mode=debug` or `mode=ui`) will launch a separate browser or debugger window for each test, which can quickly become resource-intensive and challenging to manage. + +- **Tip**: To effectively watch or debug, focus on one test at a time to avoid opening excessive browser instances or debugger windows. + +#### 3. Nala Documentation +For detailed guides and documentation on Nala, please visit the [Nala GitHub Wiki](https://github.com/adobecom/milo/wiki/Nala#nala-introduction). + + + + + + diff --git a/nala/utils/nala.run.js b/nala/utils/nala.run.js index 11d1354006..bcda6d9ebc 100644 --- a/nala/utils/nala.run.js +++ b/nala/utils/nala.run.js @@ -13,13 +13,12 @@ function displayHelp() { \x1b[1m2] Options:\x1b[0m - \x1b[33m* browser=\x1b[0m Browser to use (default: chrome) - \x1b[33m* device=\x1b[0m Device (default: desktop) - \x1b[33m* test=<.test.js>\x1b[0m Test file to run (default: all tests) - \x1b[33m* tag=<@tag>\x1b[0m Tags to filter tests by annotations ex: @test1 @accordion @marquee - \x1b[33m* -g, --g=<@tag>\x1b[0m Tags to filter tests by annotations ex: @test1 @accordion @marquee + \x1b[33m* browser=\x1b[0m Browser to run the test in + \x1b[33m* device=\x1b[0m Device type to run the test on + \x1b[33m* test=<.test.js>\x1b[0m Specific test file to run (runs all tests in the file) + \x1b[33m* -g, --g=<@tag>\x1b[0m Annotation Tag to filter and run tests by annotation (e.g., @test1, @accordion, @marquee) \x1b[33m* mode=\x1b[0m Mode (default: headless) - \x1b[33m* config=\x1b[0m Configuration file (default: Playwright default) + \x1b[33m* config=\x1b[0m Custom configuration file to use (default: Playwright's default) \x1b[33m* project=\x1b[0m Project configuration (default: milo-live-chromium) \x1b[33m* milolibs=\x1b[0m Milo library environment (default: none) @@ -31,7 +30,8 @@ function displayHelp() { | npm run nala local @accordion | Runs only accordion annotated/tagged tests on local environment on chrome browser | | npm run nala local @accordion browser=firefox | Runs only accordion annotated/tagged tests on local environment on firefox browser | | npm run nala local mode=ui | Runs all nala tests on local environment in UI mode on chrome browser | - | npm run nala local tags=@tag1,@tag2 | Runs tests annotated with @tag1 and @tag2 on local environment on chrome browser | + | npm run nala local -g=@accordion | Runs tests annotated with tag i.e @accordion on local env on chrome browser | + | npm run nala local -g=@accordion browser=firefox | Runs tests annotated with tag i.e @accordion on local env on Firefox browser | \x1b[1mDebugging:\x1b[0m ----------- From c3c9bcc51cd0e0a580b8d729549c16392c0569e4 Mon Sep 17 00:00:00 2001 From: Nicolas Peltier <1032754+npeltier@users.noreply.github.com> Date: Thu, 19 Sep 2024 19:15:31 +0200 Subject: [PATCH 07/13] MWPW-158777 returning proper response in case of error (#2916) --- libs/martech/martech.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/libs/martech/martech.js b/libs/martech/martech.js index 01492cadfe..f7f6d73a11 100644 --- a/libs/martech/martech.js +++ b/libs/martech/martech.js @@ -121,26 +121,23 @@ export const getTargetPersonalization = async () => { window.lana.log(`target response time: ${responseTime}`, { tags: 'martech', errorType: 'i' }); }, { once: true }); - let manifests = []; - let propositions = []; + let targetManifests = []; + let targetPropositions = []; const response = await waitForEventOrTimeout(ALLOY_SEND_EVENT, timeout); if (response.error) { window.lana.log('target response time: ad blocker', { tags: 'martech', errorType: 'i' }); - return []; + return { targetManifests, targetPropositions }; } if (response.timeout) { waitForEventOrTimeout(ALLOY_SEND_EVENT, 5100 - timeout) .then(() => sendTargetResponseAnalytics(true, responseStart, timeout)); } else { sendTargetResponseAnalytics(false, responseStart, timeout); - manifests = handleAlloyResponse(response.result); - propositions = response.result?.propositions || []; + targetManifests = handleAlloyResponse(response.result); + targetPropositions = response.result?.propositions || []; } - return { - targetManifests: manifests, - targetPropositions: propositions, - }; + return { targetManifests, targetPropositions }; }; const setupEntitlementCallback = () => { From 1791eb84811268736613f09e47c971d0d6e59627 Mon Sep 17 00:00:00 2001 From: Vivian A Goodrich <101133187+vgoodric@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:10:48 -0600 Subject: [PATCH 08/13] MWPW-158674 [MEP] Support nested placholders in MEP placeholders (#2908) * MWPW-158674 [MEP] Support nested placholders in MEP placeholders * unit test * move match functionality to reusable function * add default value for info in getManifestConfig declaration * MWPW-158142 [MEP] check for MEP placeholders as fragmentless content is inserted (#2919) * Initial checkin. Working state. * Code refactor. * Unit test initial checkin. * Refactor into reusable function. * Removed old code. * Linting. * update unit test to call create content --------- Co-authored-by: vgoodric --------- Co-authored-by: Dave Linhart <132396886+AdobeLinhart@users.noreply.github.com> --- .../personalization/personalization.js | 30 ++++++++++++++++-- .../parseNestedPlaceholders.test.js | 31 +++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 test/features/personalization/parseNestedPlaceholders.test.js diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index dc0ae2c1fb..66fd2fbd69 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -148,6 +148,17 @@ const createFrag = (el, action, content, manifestId, targetManifestId) => { return frag; }; +export function replacePlaceholders(value, placeholders) { + let val = value; + const matches = val.match(/{{(.*?)}}/g); + if (!matches) return val; + matches.forEach((match) => { + const key = match.replace(/{{|}}/g, '').trim(); + if (placeholders[key]) val = val.replace(match, placeholders[key]); + }); + return val; +} + export const createContent = (el, content, manifestId, targetManifestId, action, modifiers) => { if (action === 'replace') { addIds(el, manifestId, targetManifestId); @@ -158,11 +169,16 @@ export const createContent = (el, content, manifestId, targetManifestId, action, return el; } if (getSelectorType(content) !== 'fragment') { + const config = getConfig(); + const newContent = replacePlaceholders(content, config.placeholders); + if (action === 'replace') { - el.innerHTML = content; + el.innerHTML = newContent; + return el; } - const container = createTag('div', {}, content); + + const container = createTag('div', {}, newContent); addIds(container, manifestId, targetManifestId); return container; } @@ -727,7 +743,7 @@ export const addMepAnalytics = (config, header) => { } }); }; -export async function getManifestConfig(info, variantOverride = false) { +export async function getManifestConfig(info = {}, variantOverride = false) { const { name, manifestData, @@ -926,6 +942,13 @@ export function handleFragmentCommand(command, a) { return false; } +export function parseNestedPlaceholders({ placeholders }) { + if (!placeholders) return; + Object.entries(placeholders).forEach(([key, value]) => { + placeholders[key] = replacePlaceholders(value, placeholders); + }); +} + export async function applyPers(manifests, postLCP = false) { if (!manifests?.length) return; let experiments = manifests; @@ -935,6 +958,7 @@ export async function applyPers(manifests, postLCP = false) { } experiments = cleanAndSortManifestList(experiments); + parseNestedPlaceholders(config); let results = []; diff --git a/test/features/personalization/parseNestedPlaceholders.test.js b/test/features/personalization/parseNestedPlaceholders.test.js new file mode 100644 index 0000000000..43a5d05071 --- /dev/null +++ b/test/features/personalization/parseNestedPlaceholders.test.js @@ -0,0 +1,31 @@ +import { expect } from '@esm-bundle/chai'; +import { parseNestedPlaceholders, createContent } from '../../../libs/features/personalization/personalization.js'; +import { getConfig } from '../../../libs/utils/utils.js'; + +const config = getConfig(); +config.placeholders = { + 'promo-product-name': 'CC All Apps', + 'promo-header': 'Buy now and save {{promo-discount}}% off {{promo-product-name}}.', + 'promo-discount': '50', + 'promo-description': 'For just {{promo-price}}, get 20+...', + 'promo-price': 'US$49.99', +}; +describe('test different values for parseNestedPlaceholders', () => { + it('should update placeholders', () => { + parseNestedPlaceholders(config); + expect(config.placeholders['promo-header']).to.equal('Buy now and save 50% off CC All Apps.'); + expect(config.placeholders['promo-description']).to.equal('For just US$49.99, get 20+...'); + }); +}); +describe('test createContent', () => { + const el = document.createElement('div'); + it('append action', () => { + const newContent = createContent(el, '{{promo-discount}}', false, false, 'append', []); + expect(newContent.innerHTML).to.equal('50'); + }); + it('replace action', () => { + el.innerHTML = 'Hello World'; + const newContent = createContent(el, '{{promo-discount}}', false, false, 'replace', []); + expect(newContent.innerHTML).to.equal('50'); + }); +}); From 7d7eb6363db36ad11f8dfbc84caa34fc45788f30 Mon Sep 17 00:00:00 2001 From: Sean Archibeque Date: Mon, 23 Sep 2024 02:14:25 -0600 Subject: [PATCH 09/13] MWPW-154980 - Milo advanced page publishing part 2 (#2885) * sidekick publish button state * bulk publish publish config errors * dial in functionality add custom messages and denylist * publish permission in bulk pub testing * test permissions and utils coverage * remove extra variable assignment * add no signin message * put back timout for init sidekick pub button decoration * fix edge case where sk event isnt fired on refresh * fix unit tests * put back var assignment * dial in user can publish funtion * move publish utility to tools dir * fix disabled false on button * preflight publishing disabling * watch for sidekick logins * remove css formatting updates --- .../components/bulk-publisher.js | 17 +++-- libs/blocks/bulk-publish-v2/services.js | 25 +++++++ libs/blocks/preflight/panels/general.js | 60 ++++++++++++----- libs/blocks/preflight/preflight.css | 56 +++++++++++++++- libs/tools/utils/publish.js | 32 +++++++++ libs/utils/sidekick-decorate.js | 65 ++++++++++++++++--- .../bulk-publish-v2/bulk-publish-v2.test.js | 33 ++++++---- .../bulk-publish-v2/mocks/authentication.js | 2 +- test/blocks/bulk-publish-v2/mocks/fetch.js | 3 +- .../mocks/response/permissions.json | 26 ++++++++ tools/utils/utils.js | 17 ++++- 11 files changed, 289 insertions(+), 47 deletions(-) create mode 100644 libs/tools/utils/publish.js create mode 100644 test/blocks/bulk-publish-v2/mocks/response/permissions.json diff --git a/libs/blocks/bulk-publish-v2/components/bulk-publisher.js b/libs/blocks/bulk-publish-v2/components/bulk-publisher.js index c0c88ae5db..712f663fa0 100644 --- a/libs/blocks/bulk-publish-v2/components/bulk-publisher.js +++ b/libs/blocks/bulk-publish-v2/components/bulk-publisher.js @@ -1,7 +1,7 @@ import './job-process.js'; import { LitElement, html } from '../../../deps/lit-all.min.js'; import { getSheet } from '../../../../tools/utils/utils.js'; -import { authenticate, startJob } from '../services.js'; +import { authenticate, getPublishable, startJob } from '../services.js'; import { getConfig } from '../../../utils/utils.js'; import { delay, @@ -95,7 +95,8 @@ class BulkPublish2 extends LitElement { this.validateUrls(); } - setJobErrors(errors) { + setJobErrors(jobErrors, authErrors) { + const errors = [...jobErrors, ...authErrors]; const urls = []; errors.forEach((error) => { const matched = this.urls.filter((url) => { @@ -323,7 +324,8 @@ class BulkPublish2 extends LitElement { class="panel-title" @click=${handleToggle}> - Job Results + ${this.jobs.length ? html`${this.jobs.length}` : ''} + Job Result${this.jobs.length > 1 ? 's' : ''}
{ + /* c8 ignore next 4 */ const loader = this.renderRoot.querySelector('.load-indicator'); const message = this.renderRoot.querySelector('.message'); loader?.classList.add('hide'); @@ -427,6 +431,7 @@ class BulkPublish2 extends LitElement { const canUse = Object.values(this.user.permissions).filter((perms) => perms.canUse); if (canUse.length) return html``; message = 'Current user is not authorized to use Bulk Publishing Tool'; + /* c8 ignore next 3 */ } else { message = 'Please sign in to AEM sidekick to continue'; } diff --git a/libs/blocks/bulk-publish-v2/services.js b/libs/blocks/bulk-publish-v2/services.js index 2889aa5660..76af892bf2 100644 --- a/libs/blocks/bulk-publish-v2/services.js +++ b/libs/blocks/bulk-publish-v2/services.js @@ -1,3 +1,4 @@ +import userCanPublishPage from '../../tools/utils/publish.js'; import { PROCESS_TYPES, getErrorText, @@ -246,8 +247,32 @@ const updateRetry = async ({ queue, urls, process }) => { return newQueue; }; +// publish authentication service +const getPublishable = async ({ urls, process, user }) => { + let publishable = { authorized: [], unauthorized: [] }; + if (!isLive(process)) { + publishable.authorized = urls; + } else { + const { permissions, profile } = user; + const live = { permissions: ['read'] }; + if (permissions?.publish?.canUse) { + live.permissions.push('write'); + } + publishable = await urls.reduce(async (init, url) => { + const result = await init; + const detail = { webPath: new URL(url).pathname, live, profile }; + const { canPublish, message } = await userCanPublishPage(detail); + if (canPublish) result.authorized.push(url); + else result.unauthorized.push({ href: url, message }); + return result; + }, Promise.resolve(publishable)); + } + return publishable; +}; + export { authenticate, + getPublishable, pollJobStatus, startJob, updateRetry, diff --git a/libs/blocks/preflight/panels/general.js b/libs/blocks/preflight/panels/general.js index 53d8fcda3c..70c22b5553 100644 --- a/libs/blocks/preflight/panels/general.js +++ b/libs/blocks/preflight/panels/general.js @@ -1,4 +1,5 @@ import { html, signal, useEffect } from '../../../deps/htm-preact.js'; +import userCanPublishPage from '../../../tools/utils/publish.js'; const NOT_FOUND = { preview: { lastModified: 'Not found' }, live: { lastModified: 'Not found' } }; @@ -16,19 +17,19 @@ async function getStatus(url) { const resp = await fetch(adminUrl); if (!resp.ok) return {}; const json = await resp.json(); + const publish = await userCanPublishPage(json, false); const preview = json.preview.lastModified || 'Never'; const live = json.live.lastModified || 'Never'; const edit = json.edit.url; - return { url, edit, preview, live }; + return { url, edit, preview, live, publish }; } -function getStatuses() { - Object.keys(content.value).forEach((key) => { - content.value[key].items.forEach((item, idx) => { - getStatus(item.url).then((status) => { - content.value[key].items[idx] = status; - content.value = { ...content.value }; - }); +async function getStatuses() { + Object.keys(content.value).forEach(async (key) => { + content.value[key].items.forEach(async (item, idx) => { + const status = await getStatus(item.url); + content.value[key].items[idx] = status; + content.value = { ...content.value }; }); }); } @@ -68,12 +69,17 @@ async function setContent() { }; getStatuses(); + const sk = document.querySelector('helix-sidekick'); + sk?.addEventListener('statusfetched', async () => { + getStatuses(); + }); } async function handleAction(action) { Object.keys(content.value).map(async (key) => { content.value[key].items.forEach(async (item, idx) => { - if (!item.checked) return; + const checkPublish = action === 'live' ? (item.publish && !item.publish.canPublish) : false; + if (!item.checked || checkPublish) return; content.value[key].items[idx].action = action; content.value = { ...content.value }; const adminUrl = getAdminUrl(item.url, action); @@ -128,7 +134,19 @@ function prettyPath(url) { return url.hash ? `${url.pathname} (${url.hash})` : url.pathname; } +function usePublishProps(item) { + let disablePublish; + if (item.publish && !item.publish.canPublish) { + disablePublish = html`${item.publish.message}`; + } + return { + publishText: html`${item.action === 'live' ? 'Publishing' : prettyDate(item.live)}`, + disablePublish, + }; +} + function Item({ name, item, idx }) { + const { publishText, disablePublish } = usePublishProps(item); const isChecked = item.checked ? ' is-checked' : ''; const isFetching = item.edit ? '' : ' is-fetching'; if (!item.url) return undefined; @@ -139,7 +157,9 @@ function Item({ name, item, idx }) {

${prettyPath(item.url)}

${item.edit && html`EDIT`}

${item.action === 'preview' ? 'Previewing' : prettyDate(item.preview)}

-

${item.action === 'live' ? 'Publishing' : prettyDate(item.live)}

+

+ ${isChecked && disablePublish ? html`${disablePublish}` : publishText} +

`; } @@ -167,12 +187,18 @@ function ContentGroup({ name, group }) { export default function General() { useEffect(() => { setContent(); }, []); - const checked = Object.keys(content.value) - .find((key) => content.value[key].items.find((item) => item.checked)); + const allChecked = Object.values(content.value) + .flatMap((item) => item.items).filter((item) => item.checked); + + const checked = !!allChecked.length; + const publishable = allChecked + .filter((item) => item.checked && !!item.publish?.canPublish).length; const hasPage = content.value.page; const selectStyle = checked ? 'Select none' : 'Select all'; + const tooltip = allChecked.length !== publishable && 'Puplishing disabled pages will be ignored'; + return html`
${Object.keys(content.value).map((key) => html`<${ContentGroup} name=${key} group=${content.value[key]} />`)} @@ -188,9 +214,13 @@ export default function General() {
-
- -
+ ${!!publishable && html` +
+ +
+ `} `}
`; diff --git a/libs/blocks/preflight/preflight.css b/libs/blocks/preflight/preflight.css index 40210aa579..394b09519b 100644 --- a/libs/blocks/preflight/preflight.css +++ b/libs/blocks/preflight/preflight.css @@ -200,6 +200,10 @@ p.preflight-date-wrapper { margin: 0; } +p.preflight-date-wrapper .disabled-publish { + font-size: 0.8em; +} + .preflight-group-row p { margin: 0; line-height: 1; @@ -238,6 +242,9 @@ span.preflight-time { } .preflight-action { + display: flex; + align-items: center; + cursor: pointer; background: var(--action-color); color: #FFF; font-weight: 700; @@ -251,6 +258,51 @@ span.preflight-time { clip-path: polygon(0% 0%, var(--notch-size) 0%, calc(100% - var(--notch-size)) 0%, 100% var(--notch-size), 100% calc(100% - var(--notch-size)), 100% 100%, 0% 100%, 0% 100%); } +.tooltip { + position: relative; +} + +.tooltip::before { + content: attr(data-tooltip); + position: absolute; + right: 74%; + transform: translateX(50%); + bottom: 130%; + margin-top: 15px; + width: max-content; + max-width: 157px; + padding: 10px; + border-radius: 4px; + background: white; + color: var(--action-color); + text-align: center; + font-size: 14px; + font-weight: 400; + opacity: 0; + transition: opacity 0.3s, visibility 0.3s; + visibility: hidden; + line-height: 19px; +} + +.tooltip::after { + content: ''; + bottom: 103%; + right: 69%; + position: absolute; + margin: 12px 1px 0; + border: 5px solid white; + border-color: white transparent transparent; + opacity: 0; + transition: 200ms; + visibility: hidden; +} + +.tooltip:hover::before, +.tooltip:hover::after { + opacity: 1; + visibility: visible; + z-index: 9; +} /* SEO */ .seo-columns { @@ -346,7 +398,7 @@ span.preflight-time { .dialog-modal#preflight .problem-links table td a { color: #fff; display: inline-block; - overflow-x: scroll; + overflow-x: scroll; position: absolute; top: 50%; left: 0; @@ -566,4 +618,4 @@ img[data-alt-check]::after { .dialog-modal#preflight table td h3 { font-size: 16px; -} +} \ No newline at end of file diff --git a/libs/tools/utils/publish.js b/libs/tools/utils/publish.js new file mode 100644 index 0000000000..49acf0928d --- /dev/null +++ b/libs/tools/utils/publish.js @@ -0,0 +1,32 @@ +import { getCustomConfig } from '../../../tools/utils/utils.js'; + +const userCanPublishPage = async (detail, isBulk = true) => { + if (!detail) return false; + const { live, profile, webPath } = detail; + let canPublish = isBulk ? live?.permissions?.includes('write') : true; + let message = 'Publishing is currently disabled for this page'; + const config = await getCustomConfig('/.milo/publish-permissions-config.json'); + const item = config?.urls?.data?.find(({ url }) => ( + url.endsWith('**') ? webPath.includes(url.slice(0, -2)) : url === webPath + )); + if (item) { + canPublish = false; + if (item.message) message = item.message; + const group = config[item.group]; + if (group && profile?.email) { + let isDeny; + const user = group.data?.find(({ allow, deny }) => { + if (deny) { + /* c8 ignore next 3 */ + isDeny = true; + return deny === profile.email; + } + return allow === profile.email; + }); + canPublish = isDeny ? !user : !!user; + } + } + return { canPublish, message }; +}; + +export default userCanPublishPage; diff --git a/libs/utils/sidekick-decorate.js b/libs/utils/sidekick-decorate.js index ec125ef650..89a87911ae 100644 --- a/libs/utils/sidekick-decorate.js +++ b/libs/utils/sidekick-decorate.js @@ -1,4 +1,26 @@ +import userCanPublishPage from '../tools/utils/publish.js'; + +const PUBLISH_BTN = '.publish.plugin button'; +const PROFILE = '.profile-email'; +const CONFIRM_MESSAGE = 'Are you sure? This will publish to production.'; + export default function stylePublish(sk) { + const setupPublishBtn = async (page, btn) => { + const { canPublish, message } = await userCanPublishPage(page, false); + if (canPublish) { + btn.removeAttribute('disabled'); + } else { + btn.setAttribute('disabled', true); + } + const messageText = btn.querySelector('span'); + const text = canPublish ? CONFIRM_MESSAGE : message; + if (messageText) { + messageText.innerText = text; + } else { + btn.insertAdjacentHTML('beforeend', `${text}`); + } + }; + const style = new CSSStyleSheet(); style.replaceSync(` :host { @@ -10,19 +32,21 @@ export default function stylePublish(sk) { order: 100; } .publish.plugin button { + position: relative; + } + .publish.plugin button:not([disabled=true]) { background: var(--bg-color); border-color: #b46157; color: var(--text-color); - position: relative; } - .publish.plugin button:hover { + .publish.plugin button:not([disabled=true]):hover { background-color: var(--hlx-sk-button-hover-bg); border-color: unset; color: var(--hlx-sk-button-hover-color); } .publish.plugin button > span { display: none; - background: var(--bg-color); + background: #666; border-radius: 4px; line-height: 1.2rem; padding: 8px 12px; @@ -33,6 +57,9 @@ export default function stylePublish(sk) { width: 150px; white-space: pre-wrap; } + .publish.plugin button:not([disabled=true]) > span { + background: var(--bg-color); + } .publish.plugin button:hover > span { display: block; color: var(--text-color); @@ -41,19 +68,39 @@ export default function stylePublish(sk) { content: ''; border-left: 6px solid transparent; border-right: 6px solid transparent; - border-bottom: 6px solid var(--bg-color); + border-bottom: 6px solid #666; position: absolute; text-align: center; top: -6px; left: 50%; transform: translateX(-50%); } + .publish.plugin button:not([disabled=true]) > span:before { + border-bottom: 6px solid var(--bg-color); + } `); + sk.shadowRoot.adoptedStyleSheets = [style]; - setTimeout(() => { - const btn = sk.shadowRoot.querySelector('.publish.plugin button'); - btn?.insertAdjacentHTML('beforeend', ` - Are you sure? This will publish to production. - `); + + sk.addEventListener('statusfetched', async (event) => { + const page = event?.detail?.data; + const btn = event?.target?.shadowRoot?.querySelector(PUBLISH_BTN); + if (page && btn) { + setupPublishBtn(page, btn); + } + }); + + setTimeout(async () => { + const btn = sk.shadowRoot.querySelector(PUBLISH_BTN); + btn?.setAttribute('disabled', true); + const message = btn?.querySelector('span'); + if (btn && !message) { + const page = { + webPath: window.location.pathname, + // added for edge case where the statusfetched event isnt fired on refresh + profile: { email: sk.shadowRoot.querySelector(PROFILE)?.innerText }, + }; + setupPublishBtn(page, btn); + } }, 500); } diff --git a/test/blocks/bulk-publish-v2/bulk-publish-v2.test.js b/test/blocks/bulk-publish-v2/bulk-publish-v2.test.js index 3b634681d2..7cd56109b4 100644 --- a/test/blocks/bulk-publish-v2/bulk-publish-v2.test.js +++ b/test/blocks/bulk-publish-v2/bulk-publish-v2.test.js @@ -114,6 +114,16 @@ describe('Bulk Publish Tool', () => { await mouseEvent(rootEl.querySelector('.fix-btn')); }); + it('can trigger cannot publish config', async () => { + await clock.runAllAsync(); + await setProcess(rootEl, 'publish'); + await setTextArea(rootEl, 'https://error--milo--adobecom.hlx.page/not/a/valid/path'); + await mouseEvent(rootEl.querySelector('#RunProcess')); + const errors = rootEl.querySelector('.errors'); + expect(errors.querySelector('strong').innerText).to.equal('Publishing disabled until the test is over'); + await mouseEvent(rootEl.querySelector('.fix-btn')); + }); + it('can validate milo urls and enable form', async () => { await clock.runAllAsync(); await setProcess(rootEl, 'publish'); @@ -132,6 +142,17 @@ describe('Bulk Publish Tool', () => { await mouseEvent(rootEl.querySelector('.switch.half')); }); + it('can toggle job timing flyout', async () => { + await clock.runAllAsync(); + const doneJobProcess = rootEl.querySelector('job-process'); + const jobInfo = doneJobProcess?.shadowRoot.querySelector('job-info'); + const timerDetail = jobInfo?.shadowRoot.querySelector('.timer'); + await mouseEvent(timerDetail); + await clock.runAllAsync(); + await mouseEvent(timerDetail); + expect(timerDetail.classList.contains('show-times')).to.be.false; + }); + it('can submit valid bulk preview job', async () => { await clock.runAllAsync(); await setProcess(rootEl, 'preview'); @@ -174,17 +195,6 @@ describe('Bulk Publish Tool', () => { expect(rootEl.querySelectorAll('job-process')).to.have.lengthOf(4); }); - it('can toggle job timing flyout', async () => { - await clock.runAllAsync(); - const doneJobProcess = rootEl.querySelector('job-process'); - const jobInfo = doneJobProcess?.shadowRoot.querySelector('job-info'); - const timerDetail = jobInfo?.shadowRoot.querySelector('.timer'); - await mouseEvent(timerDetail); - await clock.runAllAsync(); - await mouseEvent(timerDetail); - expect(timerDetail.classList.contains('show-times')).to.be.false; - }); - it('can toggle view mode', async () => { await mouseEvent(rootEl.querySelector('.switch.full')); await clock.runAllAsync(); @@ -218,7 +228,6 @@ describe('Bulk Publish Tool', () => { it('can clear bulk jobs', async () => { await clock.runAllAsync(); await mouseEvent(rootEl.querySelector('.clear-jobs')); - await clock.runAllAsync(); expect(rootEl.querySelectorAll('job-process')).to.have.lengthOf(0); }); }); diff --git a/test/blocks/bulk-publish-v2/mocks/authentication.js b/test/blocks/bulk-publish-v2/mocks/authentication.js index 22d01045ad..ca826fa82d 100644 --- a/test/blocks/bulk-publish-v2/mocks/authentication.js +++ b/test/blocks/bulk-publish-v2/mocks/authentication.js @@ -23,7 +23,7 @@ class MockAuth extends HTMLElement { bubbles: true, detail: { data: { - profile: { name: 'Unit Test' }, + profile: { name: 'Unit Test', email: 'tester@adobe.com' }, preview: { permissions }, live: { permissions }, }, diff --git a/test/blocks/bulk-publish-v2/mocks/fetch.js b/test/blocks/bulk-publish-v2/mocks/fetch.js index 8ab62d86d3..48d7637f54 100644 --- a/test/blocks/bulk-publish-v2/mocks/fetch.js +++ b/test/blocks/bulk-publish-v2/mocks/fetch.js @@ -11,6 +11,7 @@ const requests = { delstatus: 'https://admin.hlx.page/job/adobecom/milo/main/preview-remove/job-2024-01-24t23-16-20-377z/details', retry: 'https://admin.hlx.page/preview/adobecom/milo/main/tools/bulk-publish-v2-test', index: 'https://admin.hlx.page/index/adobecom/milo/main/tools/bulk-publish-v2-test', + permissions: '/.milo/publish-permissions-config.json', }; const getMocks = async () => { @@ -25,7 +26,7 @@ const getMocks = async () => { export async function mockFetch() { const mocks = await getMocks(); stub(window, 'fetch').callsFake((...args) => { - const headers = args[1].body ?? null; + const headers = args[1]?.body ?? null; const body = headers ? JSON.parse(headers) : false; const [resource] = args; const response = mocks.find((mock) => (body.delete ? mock.request === 'delete' : mock.url === resource)); diff --git a/test/blocks/bulk-publish-v2/mocks/response/permissions.json b/test/blocks/bulk-publish-v2/mocks/response/permissions.json new file mode 100644 index 0000000000..37fe5eaec9 --- /dev/null +++ b/test/blocks/bulk-publish-v2/mocks/response/permissions.json @@ -0,0 +1,26 @@ +{ + "urls": { + "total": 4, + "offset": 0, + "limit": 4, + "data": [ + { + "url": "/not/a/valid/path", + "group": "gwp-test", + "message": "Publishing disabled until the test is over" + } + ] + }, + "gwp-test": { + "total": 2, + "offset": 0, + "limit": 2, + "data": [ + { "allow": "testuser@adobe.com" }, + { "allow": "testuser1@adobe.com" } + ] + }, + ":version": 3, + ":names": ["urls", "gwp-US", "no-publish", "gwp-FR"], + ":type": "multi-sheet" +} diff --git a/tools/utils/utils.js b/tools/utils/utils.js index 29d68397d8..327604793d 100644 --- a/tools/utils/utils.js +++ b/tools/utils/utils.js @@ -1,6 +1,7 @@ const IMS_CLIENT_ID = 'milo_ims'; const IMS_PROD_URL = 'https://auth.services.adobe.com/imslib/imslib.min.js'; const STYLE_SHEETS = {}; +const CONFIGS = {}; const getImsToken = async (loadScript) => { window.adobeid = { @@ -25,4 +26,18 @@ const getSheet = async (url) => { return sheet; }; -export { getImsToken, getSheet }; +const getCustomConfig = async (path) => { + /* c8 ignore next 3 */ + if (CONFIGS[path] !== undefined) { + return CONFIGS[path]; + } + let config = null; + const resp = await fetch(path); + if (resp.ok) { + config = await resp.json(); + } + CONFIGS[path] = config; + return CONFIGS[path]; +}; + +export { getImsToken, getSheet, getCustomConfig }; From c5e352f8753677d63b427042d53b4df3fc626cdd Mon Sep 17 00:00:00 2001 From: Rahul Gupta Date: Mon, 23 Sep 2024 17:49:57 +0530 Subject: [PATCH 10/13] [MWPW-153363] Countdown Timer implementation based on page metadata (#2928) * CDT Approach based on metadata * Add unit tests for CDT * self code review * removed comments * Add support for CDT in media block * Code Coverage fix * code coverage * code coverage * Handling Review Comments * Review comments * add unit test for code coverage * added cdt feature tests * increase code coverage * NIT for one line coverage * review comments for parallel load * code coverage * Fix UTC * Support instant query param * Fix code coverage --- libs/blocks/hero-marquee/hero-marquee.js | 6 ++ libs/blocks/marquee/marquee.js | 12 ++- libs/blocks/media/media.js | 15 ++- libs/features/cdt/cdt.css | 86 +++++++++++++++ libs/features/cdt/cdt.js | 121 ++++++++++++++++++++++ libs/utils/decorate.js | 16 ++- test/blocks/hero-marquee/mocks/body.html | 2 +- test/blocks/marquee/mocks/body.html | 2 +- test/blocks/media/media.test.js | 11 +- test/blocks/media/mocks/body.html | 2 +- test/blocks/media/mocks/placeholders.json | 24 +++++ test/features/cdt/cdt.test.js | 62 +++++++++++ test/features/cdt/mocks/body.html | 1 + 13 files changed, 351 insertions(+), 9 deletions(-) create mode 100644 libs/features/cdt/cdt.css create mode 100644 libs/features/cdt/cdt.js create mode 100644 test/blocks/media/mocks/placeholders.json create mode 100644 test/features/cdt/cdt.test.js create mode 100644 test/features/cdt/mocks/body.html diff --git a/libs/blocks/hero-marquee/hero-marquee.js b/libs/blocks/hero-marquee/hero-marquee.js index 91a0499e68..e464c7d3c2 100644 --- a/libs/blocks/hero-marquee/hero-marquee.js +++ b/libs/blocks/hero-marquee/hero-marquee.js @@ -5,6 +5,7 @@ import { decorateTextOverrides, decorateButtons, handleObjectFit, + loadCDT, } from '../../utils/decorate.js'; import { createTag, loadStyle, getConfig } from '../../utils/utils.js'; @@ -259,5 +260,10 @@ export default async function init(el) { } }); decorateTextOverrides(el, ['-heading', '-body', '-detail'], mainCopy); + + if (el.classList.contains('countdown-timer')) { + promiseArr.push(loadCDT(copy, el.classList)); + } + await Promise.all(promiseArr); } diff --git a/libs/blocks/marquee/marquee.js b/libs/blocks/marquee/marquee.js index 39f52449c6..d3e06edf4e 100644 --- a/libs/blocks/marquee/marquee.js +++ b/libs/blocks/marquee/marquee.js @@ -2,7 +2,7 @@ * Marquee - v6.0 */ -import { decorateButtons, getBlockSize, decorateBlockBg } from '../../utils/decorate.js'; +import { decorateButtons, getBlockSize, decorateBlockBg, loadCDT } from '../../utils/decorate.js'; import { createTag, getConfig, loadStyle } from '../../utils/utils.js'; // [headingSize, bodySize, detailSize] @@ -133,7 +133,15 @@ export default async function init(el) { if (iconArea?.childElementCount > 1) decorateMultipleIconArea(iconArea); extendButtonsClass(text); if (el.classList.contains('split')) decorateSplit(el, foreground, media); + + const promiseArr = []; if (el.classList.contains('mnemonic-list') && foreground) { - await loadMnemonicList(foreground); + promiseArr.push(loadMnemonicList(foreground)); + } + + if (el.classList.contains('countdown-timer')) { + promiseArr.push(loadCDT(text, el.classList)); } + + await Promise.all(promiseArr); } diff --git a/libs/blocks/media/media.js b/libs/blocks/media/media.js index 2fcc018576..1dbcb9e0b1 100644 --- a/libs/blocks/media/media.js +++ b/libs/blocks/media/media.js @@ -1,6 +1,13 @@ /* media - consonant v6 */ -import { decorateBlockBg, decorateBlockText, getBlockSize, decorateTextOverrides, applyHoverPlay } from '../../utils/decorate.js'; +import { + decorateBlockBg, + decorateBlockText, + getBlockSize, + decorateTextOverrides, + applyHoverPlay, + loadCDT, +} from '../../utils/decorate.js'; import { createTag, loadStyle, getConfig } from '../../utils/utils.js'; const blockTypeSizes = { @@ -33,7 +40,7 @@ function decorateQr(el) { qrImage.classList.add('qr-code-img'); } -export default function init(el) { +export default async function init(el) { if (el.className.includes('rounded-corners')) { const { miloLibs, codeRoot } = getConfig(); const base = miloLibs || codeRoot; @@ -105,4 +112,8 @@ export default function init(el) { const mediaRowReversed = el.querySelector(':scope > .foreground > .media-row > div').classList.contains('text'); if (mediaRowReversed) el.classList.add('media-reverse-mobile'); decorateTextOverrides(el); + + if (el.classList.contains('countdown-timer')) { + await loadCDT(container, el.classList); + } } diff --git a/libs/features/cdt/cdt.css b/libs/features/cdt/cdt.css new file mode 100644 index 0000000000..c67183c43a --- /dev/null +++ b/libs/features/cdt/cdt.css @@ -0,0 +1,86 @@ +.horizontal, +.vertical { + display: flex; + padding: 20px 0; +} + +.vertical { + flex-direction: column; +} + +.center { + align-items: center; + justify-content: center; +} + +.timer-label { + font-size: var(--type-body-s-size); + font-weight: 700; + height: 27px; +} + +.light .timer-label { + color: #000; +} + +.dark .timer-label { + color: #FFF; +} + +.horizontal .timer-label { + margin: 0 2px 27px; +} + +.timer-block { + display: flex; +} + +.horizontal .timer-block { + margin-left: 10px; +} + +.timer-fragment { + display: flex; + flex-direction: column; + align-items: center; +} + +.timer-box { + padding: 0 9px; + width: 10px; + border-radius: 5px; + font-size: var(--type-body-m-size); + font-weight: 700; + text-align: center; +} + +.light .timer-box { + background-color: #222; + color: #FFF; +} + +.dark .timer-box { + background-color: #EBEBEB; + color: #1D1D1D; +} + +.timer-unit-container { + display: flex; + column-gap: 2px; + align-items: center; +} + +.timer-unit-label { + width: 100%; + font-size: var(--type-body-xs-size); + font-weight: 400; + text-align: start; +} + +.light .timer-unit-label { + color: #464646; +} + +.dark .timer-unit-label { + color: #D1D1D1; +} diff --git a/libs/features/cdt/cdt.js b/libs/features/cdt/cdt.js new file mode 100644 index 0000000000..8afb6b5116 --- /dev/null +++ b/libs/features/cdt/cdt.js @@ -0,0 +1,121 @@ +import { getMetadata, getConfig, createTag } from '../../utils/utils.js'; +import { replaceKey } from '../placeholders.js'; + +function loadCountdownTimer( + container, + cdtLabel, + cdtDays, + cdtHours, + cdtMins, + timeRangesEpoch, +) { + let isVisible = false; + let interval; + + function appendTimerBox(parent, value, label) { + const fragment = createTag('div', { class: 'timer-fragment' }, null, { parent }); + const unitContainer = createTag('div', { class: 'timer-unit-container' }, null, { parent: fragment }); + createTag('div', { class: 'timer-unit-label' }, label, { parent: fragment }); + + createTag('div', { class: 'timer-box' }, Math.floor(value / 10).toString(), { parent: unitContainer }); + createTag('div', { class: 'timer-box' }, (value % 10).toString(), { parent: unitContainer }); + } + + function appendSeparator(parent) { + createTag('div', { class: 'timer-separator' }, ':', { parent }); + } + + function appendTimerBlock(parent, daysLeft, hoursLeft, minutesLeft) { + const timerBlock = createTag('div', { class: 'timer-block' }, null, { parent }); + appendTimerBox(timerBlock, daysLeft, cdtDays); + appendSeparator(timerBlock); + appendTimerBox(timerBlock, hoursLeft, cdtHours); + appendSeparator(timerBlock); + appendTimerBox(timerBlock, minutesLeft, cdtMins); + } + + function appendTimerLabel(parent, label) { + createTag('div', { class: 'timer-label' }, label, { parent }); + } + + function removeCountdown() { + container.replaceChildren(); + } + + function render(daysLeft, hoursLeft, minutesLeft) { + if (!isVisible) return; + + removeCountdown(); + + appendTimerLabel(container, cdtLabel); + appendTimerBlock(container, daysLeft, hoursLeft, minutesLeft); + } + + function updateCountdown() { + const instant = new URL(window.location.href)?.searchParams?.get('instant'); + const currentTime = instant ? new Date(instant) : Date.now(); + + for (let i = 0; i < timeRangesEpoch.length; i += 2) { + const startTime = timeRangesEpoch[i]; + const endTime = timeRangesEpoch[i + 1]; + + if (currentTime >= startTime && currentTime <= endTime) { + isVisible = true; + const diffTime = endTime - currentTime; + const daysLeft = Math.floor(diffTime / (1000 * 60 * 60 * 24)); + const hoursLeft = Math.floor((diffTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); + const minutesLeft = Math.floor((diffTime % (1000 * 60 * 60)) / (1000 * 60)); + render(daysLeft, hoursLeft, minutesLeft); + return; + } + } + + isVisible = false; + clearInterval(interval); + removeCountdown(); + } + + function startCountdown() { + const oneMinuteinMs = 60000; + updateCountdown(); + interval = setInterval(updateCountdown, oneMinuteinMs); + } + + startCountdown(); +} + +function isMobile() { + return window.matchMedia('(max-width: 767px)').matches; +} + +export default async function initCDT(el, classList) { + const placeholders = ['cdt-ends-in', 'cdt-days', 'cdt-hours', 'cdt-mins']; + const [cdtLabel, cdtDays, cdtHours, cdtMins] = await Promise.all( + placeholders.map((placeholder) => replaceKey(placeholder, getConfig())), + ); + + const cdtMetadata = getMetadata('countdown-timer'); + if (cdtMetadata === null) { + throw new Error('Metadata for countdown-timer is not available'); + } + + const cdtRange = cdtMetadata.split(','); + if (cdtRange.length % 2 !== 0) { + throw new Error('Invalid countdown timer range'); + } + + const timeRangesEpoch = cdtRange.map((time) => { + const parsedTime = Date.parse(time?.trim()); + return Number.isNaN(parsedTime) ? null : parsedTime; + }); + if (timeRangesEpoch.includes(null)) { + throw new Error('Invalid format for countdown timer range'); + } + + const cdtDiv = createTag('div', { class: 'countdown-timer' }, null, { parent: el }); + cdtDiv.classList.add(isMobile() ? 'vertical' : 'horizontal'); + cdtDiv.classList.add(classList.contains('dark') ? 'dark' : 'light'); + if (classList.contains('center')) cdtDiv.classList.add('center'); + + loadCountdownTimer(cdtDiv, cdtLabel, cdtDays, cdtHours, cdtMins, timeRangesEpoch); +} diff --git a/libs/utils/decorate.js b/libs/utils/decorate.js index 556670c79f..c577622b95 100644 --- a/libs/utils/decorate.js +++ b/libs/utils/decorate.js @@ -1,4 +1,6 @@ -import { createTag } from './utils.js'; +import { createTag, loadStyle, getConfig } from './utils.js'; + +const { miloLibs, codeRoot } = getConfig(); export function decorateButtons(el, size) { const buttons = el.querySelectorAll('em a, strong a, p > a strong'); @@ -309,3 +311,15 @@ export function decorateMultiViewport(el) { } return foreground; } + +export async function loadCDT(el, classList) { + try { + await Promise.all([ + loadStyle(`${miloLibs || codeRoot}/features/cdt/cdt.css`), + import('../features/cdt/cdt.js') + .then(({ default: initCDT }) => initCDT(el, classList)), + ]); + } catch (error) { + window.lana?.log(`Failed to load countdown timer module: ${error}`, { tags: 'countdown-timer' }); + } +} diff --git a/test/blocks/hero-marquee/mocks/body.html b/test/blocks/hero-marquee/mocks/body.html index 72166c8f81..2031f3cd68 100644 --- a/test/blocks/hero-marquee/mocks/body.html +++ b/test/blocks/hero-marquee/mocks/body.html @@ -106,7 +106,7 @@

2-Row Cell - text right

-
+
#ffffff
diff --git a/test/blocks/marquee/mocks/body.html b/test/blocks/marquee/mocks/body.html index 2d1d583423..5d6cda9e8a 100644 --- a/test/blocks/marquee/mocks/body.html +++ b/test/blocks/marquee/mocks/body.html @@ -184,7 +184,7 @@

Marquee inline

Marquee (split)

small

-
+
#000000
diff --git a/test/blocks/media/media.test.js b/test/blocks/media/media.test.js index 2a5ff0eaba..1da03b80dd 100644 --- a/test/blocks/media/media.test.js +++ b/test/blocks/media/media.test.js @@ -1,7 +1,13 @@ import { readFile, setViewport } from '@web/test-runner-commands'; import { expect } from '@esm-bundle/chai'; +import { setConfig, getConfig } from '../../../libs/utils/utils.js'; -document.head.innerHTML = ""; +const locales = { '': { ietf: 'en-US', tk: 'hah7vzn.css' } }; +const conf = { locales, miloLibs: 'http://localhost:2000/libs' }; +setConfig(conf); +getConfig().locale.contentRoot = '/test/blocks/media/mocks'; + +document.head.innerHTML = ''; document.body.innerHTML = await readFile({ path: './mocks/body.html' }); const { default: init } = await import('../../../libs/blocks/media/media.js'); describe('media', () => { @@ -132,5 +138,8 @@ describe('media', () => { const detail = medias[8].querySelector('.detail-l'); expect(detail).to.exist; }); + it('has a cdt', () => { + expect(medias[8].querySelectorAll('.timer-label')).to.have.lengthOf(1); + }); }); }); diff --git a/test/blocks/media/mocks/body.html b/test/blocks/media/mocks/body.html index 662303a823..78445c8a28 100644 --- a/test/blocks/media/mocks/body.html +++ b/test/blocks/media/mocks/body.html @@ -170,7 +170,7 @@

Heading XS 18/22 Media (merch

-
+
diff --git a/test/blocks/media/mocks/placeholders.json b/test/blocks/media/mocks/placeholders.json new file mode 100644 index 0000000000..3c7e61d0af --- /dev/null +++ b/test/blocks/media/mocks/placeholders.json @@ -0,0 +1,24 @@ +{ + "total": 21, + "offset": 0, + "limit": 21, + "data": [ + { + "key": "cdt-ends-in", + "value": "ENDS IN" + }, + { + "key": "cdt-days", + "value": "days" + }, + { + "key": "cdt-hours", + "value": "hours" + }, + { + "key": "cdt-mins", + "value": "mins" + } + ], + ":type": "sheet" +} diff --git a/test/features/cdt/cdt.test.js b/test/features/cdt/cdt.test.js new file mode 100644 index 0000000000..cbe87c91cf --- /dev/null +++ b/test/features/cdt/cdt.test.js @@ -0,0 +1,62 @@ +import { readFile } from '@web/test-runner-commands'; +import { expect } from '@esm-bundle/chai'; +import { loadCDT } from '../../../libs/utils/decorate.js'; +import { setConfig } from '../../../libs/utils/utils.js'; + +const locales = { '': { ietf: 'en-US', tk: 'hah7vzn.css' } }; +const conf = { locales }; +setConfig(conf); + +document.body.innerHTML = await readFile({ path: './mocks/body.html' }); +describe('CDT test error case no metadata', () => { + it('check for countdown-timer meta data', async () => { + const container = document.getElementById('cdt-container'); + await loadCDT(container, container.classList); + expect(container.querySelectorAll('.timer-label')).to.have.lengthOf(0); + }); +}); + +describe('CDT test error case invalid date', () => { + before(() => { + document.head.innerHTML = ''; + }); + it('check for countdown-timer meta data', async () => { + const container = document.getElementById('cdt-container'); + await loadCDT(container, container.classList); + expect(container.querySelectorAll('.timer-label')).to.have.lengthOf(0); + }); +}); + +describe('CDT test success case', () => { + before(() => { + document.head.innerHTML = ''; + }); + it('check for countdown-timer meta data', async () => { + const container = document.getElementById('cdt-container'); + await loadCDT(container, container.classList); + expect(container.querySelectorAll('.timer-label')).to.have.lengthOf(1); + container.innerHTML = ''; + }); +}); + +describe('CDT test error case invalid cdt metdata format', () => { + before(() => { + document.head.innerHTML = ''; + }); + it('check for countdown-timer meta data', async () => { + const container = document.getElementById('cdt-container'); + await loadCDT(container, container.classList); + expect(container.querySelectorAll('.timer-label')).to.have.lengthOf(0); + }); +}); + +describe('CDT test start is equal to end date', () => { + before(() => { + document.head.innerHTML = ''; + }); + it('check for countdown-timer meta data', async () => { + const container = document.getElementById('cdt-container'); + await loadCDT(container, container.classList); + expect(container.querySelectorAll('.timer-label')).to.have.lengthOf(0); + }); +}); diff --git a/test/features/cdt/mocks/body.html b/test/features/cdt/mocks/body.html new file mode 100644 index 0000000000..e46f3f6262 --- /dev/null +++ b/test/features/cdt/mocks/body.html @@ -0,0 +1 @@ +
From 59436649dbd9224cf2f53a2a354afc106f74772c Mon Sep 17 00:00:00 2001 From: Mark Perry <124626043+markpadbe@users.noreply.github.com> Date: Mon, 23 Sep 2024 09:12:12 -0700 Subject: [PATCH 11/13] MWPW-158077 rollout new Timeline block (#2926) * Move files out of mep folder * Update to match grid-width-10 * Remove from mep folder and add unit tests * Add mock to test --- .../timeline/timeline.css | 25 +++--- .../timeline/timeline.js | 2 +- libs/utils/utils.js | 1 + test/blocks/timeline/mocks/body.html | 23 ++++++ test/blocks/timeline/mocks/switchcolors.html | 25 ++++++ test/blocks/timeline/timeline.test.js | 77 +++++++++++++++++++ 6 files changed, 140 insertions(+), 13 deletions(-) rename libs/{mep/mwpw-143159 => blocks}/timeline/timeline.css (85%) rename libs/{mep/mwpw-143159 => blocks}/timeline/timeline.js (98%) create mode 100644 test/blocks/timeline/mocks/body.html create mode 100644 test/blocks/timeline/mocks/switchcolors.html create mode 100644 test/blocks/timeline/timeline.test.js diff --git a/libs/mep/mwpw-143159/timeline/timeline.css b/libs/blocks/timeline/timeline.css similarity index 85% rename from libs/mep/mwpw-143159/timeline/timeline.css rename to libs/blocks/timeline/timeline.css index 18f1de7c6d..ebf0842787 100644 --- a/libs/mep/mwpw-143159/timeline/timeline.css +++ b/libs/blocks/timeline/timeline.css @@ -1,10 +1,12 @@ .timeline { box-sizing: border-box; - padding: 0 0 var(--spacing-xl) 0; - width: var(--grid-container-width); - max-width: 968px; + padding: 0 var(--grid-margins-width) var(--spacing-xl) var(--grid-margins-width); + width: 100%; margin: 0 auto; } +.dialog-modal .timeline { + padding: 0 var(--spacing-xl) var(--spacing-xl) var(--spacing-xl); +} .timeline .row { display: grid; @@ -123,20 +125,19 @@ } @media screen and (min-width: 600px) { - .timeline { - width: 100%; - padding: 0 var(--grid-margins-width) var(--spacing-xl) var(--grid-margins-width); - } - .dialog-modal .timeline { padding: 0 var(--spacing-xl) var(--spacing-xl) var(--spacing-xl); } } -@media screen and (min-width: 1200px) { +@media screen and (min-width:1120px) { .timeline { - padding: 0 0 var(--spacing-xxl) 0; - width: 968px; - max-width: 100%; + padding-left: calc((100vw - 1000px) / 2); + padding-right: calc((100vw - 1000px) / 2); + } + + .dialog-modal .timeline { + padding: 0 var(--spacing-xl) var(--spacing-xl) var(--spacing-xl); } } + diff --git a/libs/mep/mwpw-143159/timeline/timeline.js b/libs/blocks/timeline/timeline.js similarity index 98% rename from libs/mep/mwpw-143159/timeline/timeline.js rename to libs/blocks/timeline/timeline.js index 8322c09592..ba2ea4aacf 100644 --- a/libs/mep/mwpw-143159/timeline/timeline.js +++ b/libs/blocks/timeline/timeline.js @@ -1,4 +1,4 @@ -import { createTag } from '../../../utils/utils.js'; +import { createTag } from '../../utils/utils.js'; function isColor(str) { const hexRegex = /^#(?:[0-9a-fA-F]{3}){1,2}$/; diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 7f1a434d83..9b5160da0c 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -75,6 +75,7 @@ const MILO_BLOCKS = [ 'tabs', 'table-of-contents', 'text', + 'timeline', 'walls-io', 'table', 'table-metadata', diff --git a/test/blocks/timeline/mocks/body.html b/test/blocks/timeline/mocks/body.html new file mode 100644 index 0000000000..52ecb8cebf --- /dev/null +++ b/test/blocks/timeline/mocks/body.html @@ -0,0 +1,23 @@ +
+
+
+

linear-gradient(to right, #E63888 0, #E9749A 100%)

+

Day 1

+

If you start your free trial today | 7-day free trial

+
+
+
+
+

#FFCE2E

+

Day 8

+

Your subscription starts and billing begins | 14-day full refund period

+
+
+
+
+

Day 21

+

Full refund period ends

+
+
+
+
diff --git a/test/blocks/timeline/mocks/switchcolors.html b/test/blocks/timeline/mocks/switchcolors.html new file mode 100644 index 0000000000..13e81224b7 --- /dev/null +++ b/test/blocks/timeline/mocks/switchcolors.html @@ -0,0 +1,25 @@ + +
+
+
+

#FFCE2E

+

Day 1

+

If you start your free trial today | 7-day free trial

+
+
+
+
+

linear-gradient(to right, #E63888 0, #E9749A 100%)

+

Day 8

+

Your subscription starts and billing begins | 14-day full refund period

+
+
+
+
+

Day 21

+

Full refund period ends

+
+
+
+
+ diff --git a/test/blocks/timeline/timeline.test.js b/test/blocks/timeline/timeline.test.js new file mode 100644 index 0000000000..204f3719a6 --- /dev/null +++ b/test/blocks/timeline/timeline.test.js @@ -0,0 +1,77 @@ +import { readFile } from '@web/test-runner-commands'; +import { expect } from '@esm-bundle/chai'; +import { setConfig } from '../../../libs/utils/utils.js'; + +const config = { codeRoot: '/libs' }; +setConfig(config); + +const { default: init } = await import('../../../libs/blocks/timeline/timeline.js'); + +describe('Timeline', () => { + beforeEach(async () => { + document.body.innerHTML = await readFile({ path: './mocks/body.html' }); + }); + + afterEach(() => { + document.body.innerHTML = ''; + }); + + it('has 3 headers', async () => { + const timelineEl = document.querySelector('.timeline'); + init(timelineEl); + const headers = timelineEl.querySelectorAll('.timeline h3'); + expect(headers[0].textContent).to.equal('Day 1'); + expect(headers[1].textContent).to.equal('Day 8'); + expect(headers[2].textContent).to.equal('Day 21'); + }); + it('has 3 descriptions', async () => { + const timelineEl = document.querySelector('.timeline'); + init(timelineEl); + const descriptions = timelineEl.querySelectorAll('.timeline h3 + p'); + + expect(descriptions[0].textContent).to.equal('If you start your free trial today'); + expect(descriptions[1].textContent).to.equal('Your subscription starts and billing begins'); + expect(descriptions[2].textContent).to.equal('Full refund period ends'); + }); + it('has a payment period and a refund period section ', async () => { + const timelineEl = document.querySelector('.timeline'); + init(timelineEl); + const trialPeriod = timelineEl.querySelector('.row .left .period'); + const refundPeriod = timelineEl.querySelector('.row .right .period'); + + expect(trialPeriod.textContent).to.equal('7-day free trial'); + expect(refundPeriod.textContent).to.equal('14-day full refund period'); + expect(trialPeriod.style.background.includes('to right')).to.true; + }); + it('it sets bar background colors based on colors in free trial and refund period section', async () => { + const timelineEl = document.querySelector('.timeline'); + init(timelineEl); + const bars = timelineEl.querySelectorAll('.bar'); + + expect(bars[0].style.backgroundColor).to.equal('rgb(230, 56, 136)'); + expect(bars[1].style.backgroundColor).to.equal('rgb(233, 116, 154)'); + expect(bars[2].style.backgroundColor).to.equal('rgb(255, 206, 46)'); + }); + it('updates background linear gradient for rtl', async () => { + const timelineEl = document.querySelector('.timeline'); + timelineEl.parentElement.setAttribute('dir', 'rtl'); + init(timelineEl); + const trialPeriod = timelineEl.querySelector('.row .left .period'); + expect(trialPeriod.style.background.includes('to left')).to.be.true; + }); + describe('Timeline', () => { + beforeEach(async () => { + document.body.innerHTML = await readFile({ path: './mocks/switchcolors.html' }); + }); + afterEach(() => { + document.body.innerHTML = ''; + }); + it('handles linear-gradient for either side', async () => { + const timelineEl = document.querySelector('.timeline'); + init(timelineEl); + const refundPeriod = timelineEl.querySelector('.row .right .period'); + expect(refundPeriod.textContent).to.equal('14-day full refund period'); + expect(refundPeriod.style.background.includes('to left')).to.true; + }); + }); +}); From 31186310164d35672516b29e32de8a938865071e Mon Sep 17 00:00:00 2001 From: Okan Sahin <39759830+mokimo@users.noreply.github.com> Date: Mon, 23 Sep 2024 18:16:00 +0200 Subject: [PATCH 12/13] Auto label nala PRs as zero impact (#2936) --- .github/workflows/label-zero-impact.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/label-zero-impact.js b/.github/workflows/label-zero-impact.js index 6d16dc8a7f..505a21ce8d 100644 --- a/.github/workflows/label-zero-impact.js +++ b/.github/workflows/label-zero-impact.js @@ -5,15 +5,17 @@ const zeroImpactDirs = [ '.vscode', '.test', '.browserslistrc', - 'libs/mep', + '.gitignore', '.eslintrc.js', 'CODEOWNERS', 'web-test-runner.config.mjs', 'LICENSE', 'codecov.yaml', - '.gitignore', 'package.json', 'package-lock.json', + 'test', + 'libs/mep', + 'nala' ]; const zeroImpactLabel = 'zero-impact'; From b60004514348a00bbf0aa131cf5f93231321ca6b Mon Sep 17 00:00:00 2001 From: Santoshkumar Nateekar Date: Mon, 23 Sep 2024 17:50:38 -0700 Subject: [PATCH 13/13] [MWPW-158872 : NALA] Update Nala GitHub Action runs to correctly handle bot-generated PR details. (#2930) * update the globalset for nala run * fix eslint errors * remove comma from console message * fix eslint comma-dangle rule --------- Co-authored-by: Santoshkumar Sharanappa Nateekar --- nala/utils/global.setup.js | 58 +++++++++++++++++++++++++++----------- nala/utils/pr.run.sh | 39 +++++++++++++++++++------ 2 files changed, 72 insertions(+), 25 deletions(-) diff --git a/nala/utils/global.setup.js b/nala/utils/global.setup.js index e453973589..93a0839ae6 100644 --- a/nala/utils/global.setup.js +++ b/nala/utils/global.setup.js @@ -7,13 +7,17 @@ const MAIN_BRANCH_LIVE_URL = 'https://main--milo--adobecom.hlx.live'; const STAGE_BRANCH_URL = 'https://milo.stage.adobe.com'; async function getGitHubPRBranchLiveUrl() { - // get the pr number + // get the pr number and branch name const prReference = process.env.GITHUB_REF; - const prNumber = prReference.split('/')[2]; + const prHeadReference = process.env.GITHUB_HEAD_REF; - // get the pr branch name - const branch = process.env.GITHUB_HEAD_REF; - const prBranch = branch.replace(/\//g, '-'); + const prNumber = prReference.startsWith('refs/pull/') + ? prReference.split('/')[2] + : null; + + const prBranch = prHeadReference + ? prHeadReference.replace(/\//g, '-') + : prReference.split('/')[2].replace(/\//g, '-'); // get the org and repo const repository = process.env.GITHUB_REPOSITORY; @@ -22,8 +26,8 @@ async function getGitHubPRBranchLiveUrl() { const toRepoName = repoParts[1]; // Get the org and repo from the environment variables - const prFromOrg = process.env.prOrg; - const prFromRepoName = process.env.prRepo; + const prFromOrg = process.env.prOrg || toRepoOrg; + const prFromRepoName = process.env.prRepo || toRepoName; const prBranchLiveUrl = `https://${prBranch}--${prFromRepoName}--${prFromOrg}.hlx.live`; @@ -31,14 +35,15 @@ async function getGitHubPRBranchLiveUrl() { if (await isBranchURLValid(prBranchLiveUrl)) { process.env.PR_BRANCH_LIVE_URL = prBranchLiveUrl; } + console.info('GH Ref : ', prReference); + console.info('GH Head Ref : ', prHeadReference); console.info('PR Repository : ', repository); console.info('PR TO ORG : ', toRepoOrg); console.info('PR TO REPO : ', toRepoName); console.info('PR From ORG : ', prFromOrg); console.info('PR From REPO : ', prFromRepoName); - console.info('PR Branch : ', branch); console.info('PR Branch(U) : ', prBranch); - console.info('PR Number : ', prNumber); + console.info('PR Number : ', prNumber || 'Auto-PR'); console.info('PR From Branch live url : ', prBranchLiveUrl); } catch (err) { console.error(`Error => Error in setting PR Branch test URL : ${prBranchLiveUrl}`); @@ -60,8 +65,12 @@ async function getGitHubMiloLibsBranchLiveUrl() { console.info('PR Branch live url : ', prBranchLiveUrl); console.info('Milo Libs : ', miloLibs); } catch (err) { - console.error(`Error => Error in setting PR Branch test URL : ${prBranchLiveUrl}`); - console.info(`Note: PR branch test url ${prBranchLiveUrl} is not valid, Exiting test execution.`); + console.error( + `Error => Error in setting PR Branch test URL : ${prBranchLiveUrl}`, + ); + console.info( + `Note: PR branch test url ${prBranchLiveUrl} is not valid, Exiting test execution.`, + ); process.exit(1); } } @@ -75,8 +84,13 @@ async function getCircleCIBranchLiveUrl() { } console.info('Stage Branch Live URL : ', stageBranchLiveUrl); } catch (err) { - console.error('Error => Error in setting Stage Branch test URL : ', stageBranchLiveUrl); - console.info('Note: Stage branch test url is not valid, Exiting test execution.'); + console.error( + 'Error => Error in setting Stage Branch test URL : ', + stageBranchLiveUrl, + ); + console.info( + 'Note: Stage branch test url is not valid, Exiting test execution.', + ); process.exit(1); } } @@ -87,12 +101,18 @@ async function getLocalBranchLiveUrl() { const localGitRootDir = execSync('git rev-parse --show-toplevel', { encoding: 'utf-8' }).trim(); if (localGitRootDir) { - const gitRemoteOriginUrl = execSync('git config --get remote.origin.url', { cwd: localGitRootDir, encoding: 'utf-8' }).trim(); + const gitRemoteOriginUrl = execSync( + 'git config --get remote.origin.url', + { cwd: localGitRootDir, encoding: 'utf-8' }, + ).trim(); const match = gitRemoteOriginUrl.match(/github\.com\/(.*?)\/(.*?)\.git/); if (match) { const [localOrg, localRepo] = match.slice(1, 3); - const localBranch = execSync('git rev-parse --abbrev-ref HEAD', { cwd: localGitRootDir, encoding: 'utf-8' }).trim(); + const localBranch = execSync('git rev-parse --abbrev-ref HEAD', { + cwd: localGitRootDir, + encoding: 'utf-8', + }).trim(); localTestLiveUrl = process.env.LOCAL_TEST_LIVE_URL || MAIN_BRANCH_LIVE_URL; if (await isBranchURLValid(localTestLiveUrl)) { console.info('Git ORG : ', localOrg); @@ -103,8 +123,12 @@ async function getLocalBranchLiveUrl() { } } } catch (error) { - console.error(`Error => Error in setting local test URL : ${localTestLiveUrl}\n`); - console.info('Note: Local or branch test url is not valid, Exiting test execution.\n'); + console.error( + `Error => Error in setting local test URL : ${localTestLiveUrl}\n`, + ); + console.info( + 'Note: Local or branch test url is not valid, Exiting test execution.\n', + ); process.exit(1); } } diff --git a/nala/utils/pr.run.sh b/nala/utils/pr.run.sh index 0d72a8d66a..a9d70c091b 100755 --- a/nala/utils/pr.run.sh +++ b/nala/utils/pr.run.sh @@ -4,22 +4,43 @@ TAGS="" REPORTER="" EXCLUDE_TAGS="--grep-invert nopr" EXIT_STATUS=0 -PR_NUMBER=$(echo "$GITHUB_REF" | awk -F'/' '{print $3}') -echo "PR Number: $PR_NUMBER" -# Extract feature branch name from GITHUB_HEAD_REF -FEATURE_BRANCH="$GITHUB_HEAD_REF" +echo "GITHUB_REF: $GITHUB_REF" +echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF" + +if [[ "$GITHUB_REF" == refs/pull/* ]]; then + # extract PR number and branch name + PR_NUMBER=$(echo "$GITHUB_REF" | awk -F'/' '{print $3}') + FEATURE_BRANCH="$GITHUB_HEAD_REF" +elif [[ "$GITHUB_REF" == refs/heads/* ]]; then + # extract branch name from GITHUB_REF + FEATURE_BRANCH=$(echo "$GITHUB_REF" | awk -F'/' '{print $3}') +else + echo "Unknown reference format" +fi + # Replace "/" characters in the feature branch name with "-" FEATURE_BRANCH=$(echo "$FEATURE_BRANCH" | sed 's/\//-/g') + +echo "PR Number: ${PR_NUMBER:-"N/A"}" echo "Feature Branch Name: $FEATURE_BRANCH" +repository=${GITHUB_REPOSITORY} +repoParts=(${repository//\// }) +toRepoOrg=${repoParts[0]} +toRepoName=${repoParts[1]} + +prRepo=${prRepo:-$toRepoName} +prOrg=${prOrg:-$toRepoOrg} + PR_BRANCH_LIVE_URL_GH="https://$FEATURE_BRANCH--$prRepo--$prOrg.hlx.live" + # set pr branch url as env export PR_BRANCH_LIVE_URL_GH export PR_NUMBER echo "PR Branch live URL: $PR_BRANCH_LIVE_URL_GH" -echo "*******************************" + # Convert GitHub Tag(@) labels that can be grepped for label in ${labels}; do @@ -37,9 +58,11 @@ done REPORTER=$reporter [[ ! -z "$REPORTER" ]] && REPORTER="--reporter $REPORTER" -echo "*** Running Nala on $FEATURE_BRANCH ***" -echo "Tags : $TAGS" -echo "npx playwright test ${TAGS} ${EXCLUDE_TAGS} ${REPORTER}" +echo "Running Nala on branch: $FEATURE_BRANCH " +echo "Tags : ${TAGS:-"No @tags or annotations on this PR"}" +echo "Run Command : npx playwright test ${TAGS} ${EXCLUDE_TAGS} ${REPORTER}" +echo -e "\n" +echo "*******************************" # Navigate to the GitHub Action path and install dependencies cd "$GITHUB_ACTION_PATH" || exit