@guardian/support-dotcom-components 7.0.1 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/server/api/bannerRouter.d.ts +2 -1
- package/dist/server/api/bannerRouter.d.ts.map +1 -1
- package/dist/server/api/epicRouter.d.ts +2 -1
- package/dist/server/api/epicRouter.d.ts.map +1 -1
- package/dist/server/factories/epicVariant.d.ts +68 -2
- package/dist/server/factories/epicVariant.d.ts.map +1 -1
- package/dist/server/factories/index.d.ts +68 -2
- package/dist/server/factories/index.d.ts.map +1 -1
- package/dist/server/lib/choiceCards/choiceCards.d.ts +6 -0
- package/dist/server/lib/choiceCards/choiceCards.d.ts.map +1 -0
- package/dist/server/lib/choiceCards/defaultChoiceCardSettings.d.ts +7 -0
- package/dist/server/lib/choiceCards/defaultChoiceCardSettings.d.ts.map +1 -0
- package/dist/server/productCatalog.d.ts +14 -0
- package/dist/server/productCatalog.d.ts.map +1 -0
- package/dist/server/tests/banners/channelBannerTests.d.ts.map +1 -1
- package/dist/shared/lib/geolocation.d.ts +4 -3
- package/dist/shared/lib/geolocation.d.ts.map +1 -1
- package/dist/shared/types/abTests/banner.d.ts +1308 -0
- package/dist/shared/types/abTests/banner.d.ts.map +1 -1
- package/dist/shared/types/abTests/epic.d.ts +734 -14
- package/dist/shared/types/abTests/epic.d.ts.map +1 -1
- package/dist/shared/types/abTests/gutter.d.ts +14 -14
- package/dist/shared/types/props/banner.d.ts +598 -7
- package/dist/shared/types/props/banner.d.ts.map +1 -1
- package/dist/shared/types/props/choiceCards.d.ts +625 -0
- package/dist/shared/types/props/choiceCards.d.ts.map +1 -0
- package/dist/shared/types/props/design.d.ts +4 -4
- package/dist/shared/types/props/epic.d.ts +1332 -24
- package/dist/shared/types/props/epic.d.ts.map +1 -1
- package/dist/shared/types/props/gutter.d.ts +10 -10
- package/dist/shared/types/props/shared.d.ts +6 -6
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";const n="gu.history.weeklyArticleCount",t="gu.history.articleCountsThisWeek",a=e=>{const n=e.getDay()||7;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()-(n-1))/864e5},i=e=>e.get(n)||void 0,o=new Set(["environment/climate-change","environment/climate-crisis","environment/environment","science/science","politics/politics","us-news/us-politics","australia-news/australian-politics","world/world","world/europe-news","world/russia","books/books","culture/culture","world/coronavirus-outbreak","world/race","inequality/inequality","technology/technology","business/business","tone/recipes","sport/sport","football/football","sport/olympic-games","sport/olympic-games-2024","tracking/commissioningdesk/uk-investigations"]),r=(e,n={})=>(e.forEach((e=>{o.has(e)&&(n[e]=(n[e]??0)+1)})),n),s=(e,i,o)=>{const s=((e,n)=>{const i=a(new Date),o=e.get(t);if(o&&o.week===i){const a=o.articles[n]||0;return e.set(t,{week:i,articles:{...o.articles,[n]:a+1}}),a>0}return e.set(t,{week:i,articles:{[n]:1}}),!1})(e,i);if(!s){const t=a(new Date),i=e.get(n)||[],s=i[0];if(s?.week&&s.week===t)s.count+=1,s.tags=r(o,s.tags),e.set(n,i);else{i.unshift({week:t,count:1,tags:r(o,{})});const a=t-365,s=i.filter((e=>e.week>=a));e.set(n,s)}}},l=["GBPCountries","UnitedStates","AUDCountries","EURCountries","International","NZDCountries","Canada"],u=e.enum(l),c=e.object({targetedCountryGroups:e.array(u),targetedCountryCodes:e.array(e.string()).optional()}).optional(),d={GBPCountries:{name:"United Kingdom",currency:"GBP",countries:["GB","FK","GI","GG","IM","JE","SH"],supportRegionId:"UK"},UnitedStates:{name:"United States",currency:"USD",countries:["US"],supportRegionId:"US"},AUDCountries:{name:"Australia",currency:"AUD",countries:["AU","KI","NR","NF","TV"],supportRegionId:"AU"},EURCountries:{name:"Europe",currency:"EUR",countries:["AD","AL","AT","BA","BE","BG","BL","CH","CY","CZ","DE","DK","EE","ES","FI","FO","FR","GF","GL","GP","GR","HR","HU","IE","IT","LI","LT","LU","LV","MC","ME","MF","IS","MQ","MT","NL","NO","PF","PL","PM","PT","RE","RO","RS","SE","SI","SJ","SK","SM","TF","TR","WF","YT","VA","AX","AZ","AM","GE","BY","MD","UA","MK"],supportRegionId:"EU"},International:{name:"International",currency:"USD",countries:["AE","AF","AG","AI","AO","AQ","AR","AS","AW","BB","BD","BF","BH","BI","BJ","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BZ","CC","CD","CF","CG","CI","CL","CM","CN","CO","CR","CU","CV","CW","CX","DJ","DM","DO","DZ","EC","EG","EH","ER","ET","FJ","FM","GA","GD","GH","GM","GN","GQ","GS","GT","GU","GW","GY","HK","HM","HN","HT","ID","IL","IN","IO","IQ","IR","JM","JO","JP","KE","KG","KH","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LK","LR","LS","LY","MA","MG","MH","ML","MM","MN","MO","MP","MR","MS","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NG","NI","NP","NU","OM","PA","PE","PG","PH","PK","PN","PR","PS","PW","PY","QA","RU","RW","SA","SB","SC","SD","SG","SL","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TG","TH","TJ","TK","TL","TM","TN","TO","TT","TW","TZ","UG","UM","UY","UZ","VC","VE","VG","VI","VN","VU","WS","YE","ZA","ZM","ZW"],supportRegionId:"INT"},NZDCountries:{name:"New Zealand",currency:"NZD",countries:["NZ","CK"],supportRegionId:"NZ"},Canada:{name:"Canada",currency:"CAD",countries:["CA"],supportRegionId:"CA"}},g={AD:"Andorra",AE:"the UAE",AF:"Afghanistan",AG:"Antigua and Barbuda",AI:"Anguilla",AL:"Albania",AM:"Armenia",AO:"Angola",AR:"Argentina",AS:"the US",AT:"Austria",AU:"Australia",AW:"Aruba",AX:"Åland Islands",AZ:"Azerbaijan",BA:"Bosnia and Herzegovina",BB:"Barbados",BD:"Bangladesh",BE:"Belgium",BF:"Burkina Faso",BG:"Bulgaria",BH:"Bahrain",BI:"Burundi",BJ:"Benin",BL:"Saint Barthélemy",BM:"Bermuda",BN:"Brunei Darussalam",BO:"Bolivia",BQ:"Bonaire, Sint Eustatius and Saba",BR:"Brazil",BS:"the Bahamas",BT:"Bhutan",BV:"Bouvet Island",BW:"Botswana",BY:"Belarus",BZ:"Belize",CA:"Canada",CD:"the Democratic Republic of the Congo",CF:"the Central Africa Republic",CG:"the Congo",CH:"Switzerland",CI:"Côte d'Ivoire",CK:"the Cook Islands",CL:"Chile",CM:"Cameroon",CN:"China",CO:"Colombia",CR:"Costa Rica",CU:"Cuba",CV:"Cabo Verde",CW:"Curaçao",CX:"Christmas Island",CY:"Cyprus",CZ:"the Czech Republic",DE:"Germany",DJ:"Djibouti",DK:"Denmark",DM:"Dominica",DO:"the Dominican Republic",DZ:"Algeria",EC:"Ecuador",EE:"Estonia",EG:"Egypt",EH:"the Western Sahara",ER:"Eritrea",ES:"Spain",ET:"Ethiopia",FI:"Finland",FJ:"Fiji",FK:"the UK",FO:"the UK",FR:"France",GA:"Gabon",GB:"the UK",GD:"Grenada",GE:"Georgia",GF:"French Guiana",GG:"Guernsey",GH:"Ghana",GI:"Gibraltar",GL:"Greenland",GM:"the Gambia",GN:"Guinea",GP:"Guadeloupe",GQ:"Equatorial Guinea",GR:"Greece",GT:"Guatemala",GU:"Guam",GW:"Guinea-Bissau",GY:"Guyana",HK:"Hong Kong",HN:"Honduras",HR:"Croatia",HT:"Haiti",HU:"Hungary",ID:"Indonesia",IE:"Ireland",IM:"the Isle of Man",IN:"India",IQ:"Iraq",IR:"Iran",IS:"Iceland",IT:"Italy",JE:"Jersey",JM:"Jamaica",JO:"Jordan",JP:"Japan",KE:"Kenya",KG:"Kyrgyzstan",KH:"Cambodia",KI:"Kiribati",KN:"Saint Kitts and Nevis",KP:"Korea",KR:"Korea",KW:"Kuwait",KY:"the Cayman Ialnds",KZ:"Kazakhstan",LB:"Lebanon",LC:"Saint Lucia",LI:"Liechtenstein",LK:"Sri Lanka",LR:"Liberia",LS:"Lesotho",LT:"Lithuania",LU:"Luxembourg",LV:"Latvia",LY:"Libya",MA:"Morocco",MC:"Monaco",MD:"Moldova",ME:"Montenegro",MG:"Madagascar",MK:"the Republic of North Macedonia",ML:"Mali",MM:"Myanmar",MN:"Mongolia",MO:"Macao",MQ:"Martinique",MR:"Mauritania",MS:"Montserrat",MT:"Malta",MU:"Mauritius",MV:"Maldives",MW:"Malawi",MX:"Mexico",MY:"Malaysia",MZ:"Mozambique",NA:"Namibia",NC:"New Caledonia",NE:"Niger",NF:"Norfolk Island",NG:"Nigeria",NI:"Nicaragua",NL:"the Netherlands",NO:"Norway",NP:"Nepal",NR:"Nauru",NU:"Niue",NZ:"New Zealand",OM:"Oman",PA:"Panama",PE:"Peru",PF:"French Polynesia",PG:"Papua New Guinea",PH:"the Philippines",PK:"Pakistan",PL:"Poland",PM:"Saint Pierre and Miquelon",PN:"Pitcairn",PR:"Puerto Rico",PT:"Portugal",PW:"Palau",PY:"Paraguay",QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russia",RW:"Rwanda",SA:"Saudi Arabia",SB:"Solomon Islands",SC:"Seychelles",SD:"Sudan",SE:"Sweden",SG:"Singapore",SH:"Saint Helena",SI:"Slovenia",SJ:"Svalbard and Jan Mayen",SK:"Slovakia",SL:"Sierra Leone",SM:"San Marino",SN:"Senegal",SO:"Somalia",SR:"Suriname",SS:"South Sudan",ST:"Sao Tome and Principe",SV:"El Salvador",SY:"Syrian Arab Republic",SZ:"Eswatini",TD:"Chad",TG:"Togo",TH:"Thailand",TJ:"Tajikistan",TK:"Tokelau",TL:"Timor-Leste",TM:"Turkmenistan",TN:"Tunisia",TO:"Tonga",TR:"Turkey",TT:"Trinidad and Tobago",TV:"Tuvalu",TW:"Taiwan",TZ:"Tanzania ",UG:"Uganda",US:"the US",UY:"Uruguay",UZ:"Uzbekistan",VC:"Saint Vincent and the Grenadines",VE:"Venezuela",VG:"the Virgin Islands",VI:"the Virgin Islands",VN:"Vietnam",VU:"Vanuatu",WF:"Wallis and Futuna",WS:"Samoa",YE:"Yemen",YT:"Mayotte",ZA:"South Africa",ZM:"Zambia",ZW:"Zimbabwe"},m={GBPCountries:"£",UnitedStates:"$",AUDCountries:"$",Canada:"CA$",EURCountries:"€",NZDCountries:"NZ$",International:"$"},p=e=>Object.keys(d).find((n=>d[n].countries.includes(e??"")))||"International",b=(e,n=[],t=[])=>0===n.length&&0===t.length||!!e&&(!!n.includes(p(e.toUpperCase()))||t.includes(e.toUpperCase())),C=e=>{if(e){const n=p(e);return m[n]}return"£"},S=e=>{if(e)return g[e]},h=e=>e.includes("subscribe/weekly/checkout"),y=(e,n)=>{if(n){const t=(e=>d[p(e)].supportRegionId)(n);if(t&&!h(e))return e.replace(/(support\.theguardian\.com)\/(contribute-in-epic|contribute|subscribe|checkout)/,((e,n,a)=>`${n}/${t.toLowerCase()}/${a}`))}return e},A=(e,n,t,a)=>{if(a){const i=a[p(t)];if(i){return`${C(t)}${i[e][n].price}`}}},I={CURRENCY_SYMBOL:({countryCode:e})=>C(e),COUNTRY_NAME:({countryCode:e})=>S(e),PRICE_DIGISUB_MONTHLY:({countryCode:e,prices:n})=>A("Digisub","Monthly",e,n),PRICE_DIGISUB_ANNUAL:({countryCode:e,prices:n})=>A("Digisub","Annual",e,n),PRICE_GUARDIANWEEKLY_MONTHLY:({countryCode:e,prices:n})=>A("GuardianWeekly","Monthly",e,n),PRICE_GUARDIANWEEKLY_ANNUAL:({countryCode:e,prices:n})=>A("GuardianWeekly","Annual",e,n),DAY_OF_THE_WEEK:()=>((e=new Date)=>e.toLocaleString("en-GB",{weekday:"long"}))(),DATE:()=>((e=new Date)=>e.toLocaleString("en-GB",{day:"numeric",month:"long",year:"numeric"}))()},T=(e,n,t)=>e?e.replace(N,(e=>{const a=e.substring(2,e.length-2),i=I[a];if(i){const e=i({countryCode:n,prices:t});if(e)return e}return e})):"",N=/%%.*?%%/g,M=e=>{const n=e.match(N)?.filter((e=>"%%ARTICLE_COUNT%%"!==e));return!!n&&n.length>0},E="gu.contributions.views",G=e=>e.get(E)||void 0,U=e=>{const n=localStorage.getItem(E),t=n?JSON.parse(n).value:[];t.push({date:(new Date).getTime(),testId:e});const a={value:t.slice(-50)};localStorage.setItem(E,JSON.stringify(a))},B=e=>{const n=(e=>{const n=new Date(e,10,1).getDay();return new Date(e,10,22+(11-n)%7)})(e);return n.setDate(n.getDate()+5),n},R=(e=new Date)=>{const n=(e=>{const n=e.getDate()<20?1:2;return e.setMonth(e.getMonth()+n),e})(e),t=(n.getMonth()+1).toString().padStart(2,"0"),a=n.toLocaleString("default",{month:"long"}),i=n.getFullYear();return{reminderCta:`Remind me in ${a}`,reminderPeriod:`${i}-${t}-01`,reminderLabel:`${a} ${i}`}},L=new Date("2023-12-31"),P=e=>e>=(e=>new Date(e.getFullYear(),9,20))(e)&&e<B(e.getFullYear()),D=(e,n=new Date)=>{return"US"===e&&P(n)?{reminderCta:"Remind me on Giving Tuesday",reminderPeriod:`${t=n.getFullYear()}-${(B(t).getMonth()+1).toString().padStart(0,"2")}-01`,reminderLabel:"on Giving Tuesday",reminderOption:`giving-tuesday-${t}`}:"US"===e&&(e=>e>=B(e.getFullYear())&&e<L)(n)?(e=>({reminderCta:"Remind me on New Years Eve",reminderPeriod:`${e}-12-01`,reminderLabel:"on New Years Eve",reminderOption:`new-years-eve-${e}`}))(n.getFullYear()):R(n);var t},w=e.object({text:e.string(),baseUrl:e.string()});let O=function(e){return e.Custom="CustomSecondaryCta",e.ContributionsReminder="ContributionsReminderSecondaryCta",e}({});e.nativeEnum(O);const k=e.object({type:e.literal(O.Custom),cta:w}),f=e.object({type:e.literal(O.ContributionsReminder)}),K=e.discriminatedUnion("type",[k,f]),F=e.object({countLabel:e.string(),goalCopy:e.string().optional()}),j=e.object({total:e.number(),goal:e.number()}),v=e.enum(["US","AU","global"]),H=e.object({currencySymbol:e.string(),copy:F,name:v,tickerData:j.optional()}),Y=e.object({for52Weeks:e.number(),forTargetedWeeks:e.number()}),V=e.enum(["for52Weeks","forTargetedWeeks"]),W=e.object({type:e.literal("above"),copy:e.string().optional(),countType:V.optional()}),Z=e.enum(["CONTRIBUTION","MEMBERSHIP_SUPPORTER","DIGITAL_SUBSCRIPTION","PRINT_SUBSCRIPTION"]),$=e.enum(["ACQUISITIONS_EPIC","ACQUISITIONS_ENGAGEMENT_BANNER","ACQUISITIONS_SUBSCRIPTIONS_BANNER","ACQUISITIONS_HEADER","ACQUISITIONS_OTHER"]),x=e.object({abTestName:e.string(),abTestVariant:e.string(),campaignCode:e.string(),componentType:$,products:e.array(Z).nullish(),labels:e.array(e.string()).nullish(),ophanPageId:e.string(),platformId:e.string(),referrerUrl:e.string()}),_=e.object({mainUrl:e.string(),mobileUrl:e.string().optional(),tabletUrl:e.string().optional(),desktopUrl:e.string().optional(),leftColUrl:e.string().optional(),wideUrl:e.string().optional(),altText:e.string()}),J=e.object({name:e.string(),description:e.string().optional(),headshot:_.optional()}),Q=/^[0-9A-F]{2}$/,z=e.string().refine((e=>Q.test(e)),(e=>({message:`"${e}" is not a valid hex value`}))),q=e.object({r:z,g:z,b:z,kind:e.literal("hex")}),X=e.object({mobileUrl:e.string(),tabletUrl:e.string(),desktopUrl:e.string(),altText:e.string(),kind:e.literal("Image")}),ee=e.object({buttonColour:q.nullish(),buttonTextColour:q.nullish(),buttonBorderColour:q.nullish(),buttonSelectColour:q.nullish(),buttonSelectTextColour:q.nullish(),buttonSelectBorderColour:q.nullish(),kind:e.literal("ChoiceCards")}),ne=e.discriminatedUnion("kind",[X,ee]),te=e.object({visual:ne.nullish(),colours:e.object({basic:e.object({background:q,bodyText:q})})}),ae=e=>`#${e.r}${e.g}${e.b}`,ie=e.object({maxViewsCount:e.number(),maxViewsDays:e.number(),minDaysBetweenViews:e.number()}),oe=e.object({reminderCta:e.string(),reminderLabel:e.string(),reminderPeriod:e.string()}),re=e.enum(["ONE_OFF","MONTHLY","ANNUAL"]),se=e.object({testName:e.string(),variantName:e.string(),defaultContributionType:re,displayContributionType:re.array(),amountsCardData:e.object({ONE_OFF:e.object({amounts:e.array(e.number()),defaultAmount:e.number(),hideChooseYourAmount:e.boolean().optional()}),MONTHLY:e.object({amounts:e.array(e.number()),defaultAmount:e.number(),hideChooseYourAmount:e.boolean().optional()}),ANNUAL:e.object({amounts:e.array(e.number()),defaultAmount:e.number(),hideChooseYourAmount:e.boolean().optional()})})}),le=e.object({newsletterId:e.string(),successDescription:e.string()}),ue=e.object({name:e.string(),heading:e.string().optional(),paragraphs:e.array(e.string()),highlightedText:e.string().optional(),tickerSettings:H.optional(),cta:w.optional(),secondaryCta:K.optional(),newsletterSignup:le.optional(),image:_.optional(),showReminderFields:oe.optional(),separateArticleCount:W.optional(),maxViews:ie.optional(),showSignInLink:e.boolean().optional(),bylineWithImage:J.optional(),showChoiceCards:e.boolean().optional(),choiceCardAmounts:se.optional(),defaultChoiceCardFrequency:re.optional()}),ce=e.object({variant:ue,tracking:x,countryCode:e.string().nullish(),articleCounts:Y,onReminderOpen:e.any().nullish(),fetchEmail:e.any().nullish(),submitComponentEvent:e.any().nullish(),openCmp:e.any().nullish(),hasConsentForArticleCount:e.boolean().nullish(),stage:e.string().nullish()}),de=e.enum(["contributions","subscriptions","signIn","abandonedBasket"]),ge=e.object({heading:e.string().optional(),messageText:e.string().optional(),paragraphs:e.array(e.string()).optional(),mobileMessageText:e.string().optional(),highlightedText:e.string().optional(),cta:w.optional(),secondaryCta:K.optional()}),me=e.object({tracking:x,bannerChannel:de,content:ge.nullish(),mobileContent:ge.nullish(),countryCode:e.string().nullish(),isSupporter:e.boolean().nullish(),tickerSettings:H.nullish(),submitComponentEvent:e.any(),articleCounts:Y,hasOptedOutOfArticleCount:e.boolean().nullish(),fetchEmail:e.any().nullish(),separateArticleCount:e.boolean().nullish(),design:te.nullish()}),pe=e.object({heading:e.string(),subheading:e.string(),primaryCta:w.optional(),secondaryCta:w.optional(),benefits:e.array(e.string()).optional()}),be=e.object({content:pe,tracking:x,mobileContent:pe.optional(),countryCode:e.string().optional(),submitComponentEvent:e.any(),numArticles:e.number().optional()}),Ce=e.object({image:_,bodyCopy:e.array(e.string()),cta:w.optional()});e.object({content:Ce,tracking:x,countryCode:e.string().optional(),submitComponentEvent:e.any()});const Se=e.enum(["Contribution","SupporterPlus","GuardianWeekly","Paper"]),he=e.enum(["new","guest","current"]),ye=e.enum(["Epic","EpicAMP","EpicAppleNews","EpicLiveblog","Banner1","Banner2","Header","GutterLiveblog"]),Ae=e.enum(["Live","Draft","Archived"]),Ie=e.enum(["Mobile","Desktop","All","iOS","Android"]),Te=e.enum(["SignedIn","SignedOut","All"]),Ne=e.enum(["HasConsented","HasNotConsented","All"]),Me=e.object({name:e.literal("ABTest")}),Ee=e.object({name:e.literal("EpsilonGreedyBandit"),epsilon:e.number(),sampleCount:e.number().optional()}),Ge=e.object({name:e.literal("Roulette"),sampleCount:e.number().optional()}),Ue=e.intersection(e.discriminatedUnion("name",[Me,Ee,Ge]),e.object({testName:e.string().optional()})),Be=e.object({channel:ye,name:e.string(),status:Ae,priority:e.number(),controlProportionSettings:e.object({proportion:e.number(),offset:e.number()}).optional(),deviceType:Ie.optional(),signedInStatus:Te.optional(),consentStatus:Ne.optional(),methodologies:Ue.array().optional()}),Re=e.enum(["AllExistingSupporters","AllNonSupporters","Everyone","PostAskPauseSingleContributors"]),Le=e.object({minViews:e.number(),maxViews:e.number().optional(),periodInWeeks:e.number(),tagIds:e.array(e.string()).optional()});e.object({userType:e.array(he),product:e.array(Se)}),e.object({tagIds:e.array(e.string()),sectionIds:e.array(e.string()),excludedTagIds:e.array(e.string()),excludedSectionIds:e.array(e.string())});const Pe=e.object({maxViewsCount:e.number(),maxViewsDays:e.number(),minDaysBetweenViews:e.number()}),De=["ONE_OFF","MONTHLY","ANNUAL"];Be.extend({name:e.string(),status:Ae,locations:e.array(u).optional(),regionTargeting:c.optional(),tagIds:e.array(e.string()),sections:e.array(e.string()),excludedTagIds:e.array(e.string()),excludedSections:e.array(e.string()),alwaysAsk:e.boolean(),maxViews:Pe.optional(),userCohort:Re,hasCountryName:e.boolean(),highPriority:e.boolean(),useLocalViewLog:e.boolean(),articlesViewedSettings:Le.optional(),priority:e.number(),variants:ue.array()});const we=e.object({amount:e.union([e.number(),e.literal("other")]),billingPeriod:e.union([e.literal("ONE_OFF"),e.literal("MONTHLY"),e.literal("ANNUAL")]),product:e.union([e.literal("Contribution"),e.literal("SupporterPlus"),e.literal("PremiumTier"),e.literal("DailyEdition"),e.literal("GuardianWeekly"),e.literal("Paper"),e.literal("PaperAndDigital")]),region:e.union([e.literal("uk"),e.literal("us"),e.literal("au"),e.literal("eu"),e.literal("int"),e.literal("nz"),e.literal("ca")])}),Oe=(e,n,t)=>{const a=(e=>{if(URLSearchParams){const n=new URLSearchParams(window.location.search).get(`force-${e}`);if(n)return n}return null})(e);return fetch(`${n}/${e}${a?`?force=${a}`:""}`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then((n=>{if(!n.ok)throw Error(n.statusText||`Supporter Revenue ${e} | Api call returned HTTP status ${n.status}`);return n})).then((e=>e.json()))},ke=(e,n)=>Oe("epic",e,n),fe=(e,n)=>Oe("liveblog-epic",e,n),Ke=(e,n)=>Oe("banner",e,n),Fe=(e,n)=>Oe("gutter-liveblog",e,n),je=(e,n)=>Oe("header",e,n);export{l as CountryGroupId,O as SecondaryCtaType,we as abandonedBasketSchema,y as addRegionIdToSupportUrl,me as bannerSchema,R as buildReminderFields,M as containsNonArticleCountPlaceholder,De as contributionTabFrequencies,p as countryCodeToCountryGroupId,u as countryGroupIdSchema,ce as epicPropsSchema,Ke as getBanner,S as getCountryName,ke as getEpic,G as getEpicViewLog,Fe as getGutterLiveblog,je as getHeader,fe as getLiveblogEpic,C as getLocalCurrencySymbol,D as getReminderFields,i as getWeeklyArticleHistory,be as headerPropsSchema,ae as hexColourToString,b as inTargetedCountry,s as incrementWeeklyArticleCount,h as isGWCheckoutUrl,U as logEpicView,T as replaceNonArticleCountPlaceholders,c as targetedRegionsSchema};
|
|
1
|
+
import{z as e}from"zod";const n="gu.history.weeklyArticleCount",t="gu.history.articleCountsThisWeek",a=e=>{const n=e.getDay()||7;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()-(n-1))/864e5},i=e=>e.get(n)||void 0,o=new Set(["environment/climate-change","environment/climate-crisis","environment/environment","science/science","politics/politics","us-news/us-politics","australia-news/australian-politics","world/world","world/europe-news","world/russia","books/books","culture/culture","world/coronavirus-outbreak","world/race","inequality/inequality","technology/technology","business/business","tone/recipes","sport/sport","football/football","sport/olympic-games","sport/olympic-games-2024","tracking/commissioningdesk/uk-investigations"]),r=(e,n={})=>(e.forEach((e=>{o.has(e)&&(n[e]=(n[e]??0)+1)})),n),s=(e,i,o)=>{const s=((e,n)=>{const i=a(new Date),o=e.get(t);if(o&&o.week===i){const a=o.articles[n]||0;return e.set(t,{week:i,articles:{...o.articles,[n]:a+1}}),a>0}return e.set(t,{week:i,articles:{[n]:1}}),!1})(e,i);if(!s){const t=a(new Date),i=e.get(n)||[],s=i[0];if(s?.week&&s.week===t)s.count+=1,s.tags=r(o,s.tags),e.set(n,i);else{i.unshift({week:t,count:1,tags:r(o,{})});const a=t-365,s=i.filter((e=>e.week>=a));e.set(n,s)}}},l=["GBPCountries","UnitedStates","AUDCountries","EURCountries","International","NZDCountries","Canada"],u=e.enum(l),c=e.object({targetedCountryGroups:e.array(u),targetedCountryCodes:e.array(e.string()).optional()}).optional(),d={GBPCountries:{name:"United Kingdom",currency:"GBP",countries:["GB","FK","GI","GG","IM","JE","SH"],supportRegionId:"UK"},UnitedStates:{name:"United States",currency:"USD",countries:["US"],supportRegionId:"US"},AUDCountries:{name:"Australia",currency:"AUD",countries:["AU","KI","NR","NF","TV"],supportRegionId:"AU"},EURCountries:{name:"Europe",currency:"EUR",countries:["AD","AL","AT","BA","BE","BG","BL","CH","CY","CZ","DE","DK","EE","ES","FI","FO","FR","GF","GL","GP","GR","HR","HU","IE","IT","LI","LT","LU","LV","MC","ME","MF","IS","MQ","MT","NL","NO","PF","PL","PM","PT","RE","RO","RS","SE","SI","SJ","SK","SM","TF","TR","WF","YT","VA","AX","AZ","AM","GE","BY","MD","UA","MK"],supportRegionId:"EU"},International:{name:"International",currency:"USD",countries:["AE","AF","AG","AI","AO","AQ","AR","AS","AW","BB","BD","BF","BH","BI","BJ","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BZ","CC","CD","CF","CG","CI","CL","CM","CN","CO","CR","CU","CV","CW","CX","DJ","DM","DO","DZ","EC","EG","EH","ER","ET","FJ","FM","GA","GD","GH","GM","GN","GQ","GS","GT","GU","GW","GY","HK","HM","HN","HT","ID","IL","IN","IO","IQ","IR","JM","JO","JP","KE","KG","KH","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LK","LR","LS","LY","MA","MG","MH","ML","MM","MN","MO","MP","MR","MS","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NG","NI","NP","NU","OM","PA","PE","PG","PH","PK","PN","PR","PS","PW","PY","QA","RU","RW","SA","SB","SC","SD","SG","SL","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TG","TH","TJ","TK","TL","TM","TN","TO","TT","TW","TZ","UG","UM","UY","UZ","VC","VE","VG","VI","VN","VU","WS","YE","ZA","ZM","ZW"],supportRegionId:"INT"},NZDCountries:{name:"New Zealand",currency:"NZD",countries:["NZ","CK"],supportRegionId:"NZ"},Canada:{name:"Canada",currency:"CAD",countries:["CA"],supportRegionId:"CA"}},g={AD:"Andorra",AE:"the UAE",AF:"Afghanistan",AG:"Antigua and Barbuda",AI:"Anguilla",AL:"Albania",AM:"Armenia",AO:"Angola",AR:"Argentina",AS:"the US",AT:"Austria",AU:"Australia",AW:"Aruba",AX:"Åland Islands",AZ:"Azerbaijan",BA:"Bosnia and Herzegovina",BB:"Barbados",BD:"Bangladesh",BE:"Belgium",BF:"Burkina Faso",BG:"Bulgaria",BH:"Bahrain",BI:"Burundi",BJ:"Benin",BL:"Saint Barthélemy",BM:"Bermuda",BN:"Brunei Darussalam",BO:"Bolivia",BQ:"Bonaire, Sint Eustatius and Saba",BR:"Brazil",BS:"the Bahamas",BT:"Bhutan",BV:"Bouvet Island",BW:"Botswana",BY:"Belarus",BZ:"Belize",CA:"Canada",CD:"the Democratic Republic of the Congo",CF:"the Central Africa Republic",CG:"the Congo",CH:"Switzerland",CI:"Côte d'Ivoire",CK:"the Cook Islands",CL:"Chile",CM:"Cameroon",CN:"China",CO:"Colombia",CR:"Costa Rica",CU:"Cuba",CV:"Cabo Verde",CW:"Curaçao",CX:"Christmas Island",CY:"Cyprus",CZ:"the Czech Republic",DE:"Germany",DJ:"Djibouti",DK:"Denmark",DM:"Dominica",DO:"the Dominican Republic",DZ:"Algeria",EC:"Ecuador",EE:"Estonia",EG:"Egypt",EH:"the Western Sahara",ER:"Eritrea",ES:"Spain",ET:"Ethiopia",FI:"Finland",FJ:"Fiji",FK:"the UK",FO:"the UK",FR:"France",GA:"Gabon",GB:"the UK",GD:"Grenada",GE:"Georgia",GF:"French Guiana",GG:"Guernsey",GH:"Ghana",GI:"Gibraltar",GL:"Greenland",GM:"the Gambia",GN:"Guinea",GP:"Guadeloupe",GQ:"Equatorial Guinea",GR:"Greece",GT:"Guatemala",GU:"Guam",GW:"Guinea-Bissau",GY:"Guyana",HK:"Hong Kong",HN:"Honduras",HR:"Croatia",HT:"Haiti",HU:"Hungary",ID:"Indonesia",IE:"Ireland",IM:"the Isle of Man",IN:"India",IQ:"Iraq",IR:"Iran",IS:"Iceland",IT:"Italy",JE:"Jersey",JM:"Jamaica",JO:"Jordan",JP:"Japan",KE:"Kenya",KG:"Kyrgyzstan",KH:"Cambodia",KI:"Kiribati",KN:"Saint Kitts and Nevis",KP:"Korea",KR:"Korea",KW:"Kuwait",KY:"the Cayman Ialnds",KZ:"Kazakhstan",LB:"Lebanon",LC:"Saint Lucia",LI:"Liechtenstein",LK:"Sri Lanka",LR:"Liberia",LS:"Lesotho",LT:"Lithuania",LU:"Luxembourg",LV:"Latvia",LY:"Libya",MA:"Morocco",MC:"Monaco",MD:"Moldova",ME:"Montenegro",MG:"Madagascar",MK:"the Republic of North Macedonia",ML:"Mali",MM:"Myanmar",MN:"Mongolia",MO:"Macao",MQ:"Martinique",MR:"Mauritania",MS:"Montserrat",MT:"Malta",MU:"Mauritius",MV:"Maldives",MW:"Malawi",MX:"Mexico",MY:"Malaysia",MZ:"Mozambique",NA:"Namibia",NC:"New Caledonia",NE:"Niger",NF:"Norfolk Island",NG:"Nigeria",NI:"Nicaragua",NL:"the Netherlands",NO:"Norway",NP:"Nepal",NR:"Nauru",NU:"Niue",NZ:"New Zealand",OM:"Oman",PA:"Panama",PE:"Peru",PF:"French Polynesia",PG:"Papua New Guinea",PH:"the Philippines",PK:"Pakistan",PL:"Poland",PM:"Saint Pierre and Miquelon",PN:"Pitcairn",PR:"Puerto Rico",PT:"Portugal",PW:"Palau",PY:"Paraguay",QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russia",RW:"Rwanda",SA:"Saudi Arabia",SB:"Solomon Islands",SC:"Seychelles",SD:"Sudan",SE:"Sweden",SG:"Singapore",SH:"Saint Helena",SI:"Slovenia",SJ:"Svalbard and Jan Mayen",SK:"Slovakia",SL:"Sierra Leone",SM:"San Marino",SN:"Senegal",SO:"Somalia",SR:"Suriname",SS:"South Sudan",ST:"Sao Tome and Principe",SV:"El Salvador",SY:"Syrian Arab Republic",SZ:"Eswatini",TD:"Chad",TG:"Togo",TH:"Thailand",TJ:"Tajikistan",TK:"Tokelau",TL:"Timor-Leste",TM:"Turkmenistan",TN:"Tunisia",TO:"Tonga",TR:"Turkey",TT:"Trinidad and Tobago",TV:"Tuvalu",TW:"Taiwan",TZ:"Tanzania ",UG:"Uganda",US:"the US",UY:"Uruguay",UZ:"Uzbekistan",VC:"Saint Vincent and the Grenadines",VE:"Venezuela",VG:"the Virgin Islands",VI:"the Virgin Islands",VN:"Vietnam",VU:"Vanuatu",WF:"Wallis and Futuna",WS:"Samoa",YE:"Yemen",YT:"Mayotte",ZA:"South Africa",ZM:"Zambia",ZW:"Zimbabwe"},p={GBPCountries:"£",UnitedStates:"$",AUDCountries:"$",Canada:"CA$",EURCountries:"€",NZDCountries:"NZ$",International:"$"},m={GBP:"£",USD:"$",AUD:"$",EUR:"€",NZD:"NZ$",CAD:"CA$"},b=e=>Object.keys(d).find((n=>d[n].countries.includes(e??"")))||"International",C=(e,n=[],t=[])=>0===n.length&&0===t.length||!!e&&(!!n.includes(b(e.toUpperCase()))||t.includes(e.toUpperCase())),S=e=>{if(e){const n=b(e);return p[n]}return"£"},h=e=>{if(e)return g[e]},y=e=>e.includes("subscribe/weekly/checkout"),A=(e,n)=>{if(n){const t=(e=>d[b(e)].supportRegionId)(n);if(t&&!y(e))return e.replace(/(support\.theguardian\.com)\/(contribute-in-epic|contribute|subscribe|checkout)/,((e,n,a)=>`${n}/${t.toLowerCase()}/${a}`))}return e},T=(e,n,t,a)=>{if(a){const i=a[b(t)];if(i){return`${S(t)}${i[e][n].price}`}}},I={CURRENCY_SYMBOL:({countryCode:e})=>S(e),COUNTRY_NAME:({countryCode:e})=>h(e),PRICE_DIGISUB_MONTHLY:({countryCode:e,prices:n})=>T("Digisub","Monthly",e,n),PRICE_DIGISUB_ANNUAL:({countryCode:e,prices:n})=>T("Digisub","Annual",e,n),PRICE_GUARDIANWEEKLY_MONTHLY:({countryCode:e,prices:n})=>T("GuardianWeekly","Monthly",e,n),PRICE_GUARDIANWEEKLY_ANNUAL:({countryCode:e,prices:n})=>T("GuardianWeekly","Annual",e,n),DAY_OF_THE_WEEK:()=>((e=new Date)=>e.toLocaleString("en-GB",{weekday:"long"}))(),DATE:()=>((e=new Date)=>e.toLocaleString("en-GB",{day:"numeric",month:"long",year:"numeric"}))()},N=(e,n,t)=>e?e.replace(M,(e=>{const a=e.substring(2,e.length-2),i=I[a];if(i){const e=i({countryCode:n,prices:t});if(e)return e}return e})):"",M=/%%.*?%%/g,E=e=>{const n=e.match(M)?.filter((e=>"%%ARTICLE_COUNT%%"!==e));return!!n&&n.length>0},G="gu.contributions.views",U=e=>e.get(G)||void 0,B=e=>{const n=localStorage.getItem(G),t=n?JSON.parse(n).value:[];t.push({date:(new Date).getTime(),testId:e});const a={value:t.slice(-50)};localStorage.setItem(G,JSON.stringify(a))},R=e=>{const n=(e=>{const n=new Date(e,10,1).getDay();return new Date(e,10,22+(11-n)%7)})(e);return n.setDate(n.getDate()+5),n},P=(e=new Date)=>{const n=(e=>{const n=e.getDate()<20?1:2;return e.setMonth(e.getMonth()+n),e})(e),t=(n.getMonth()+1).toString().padStart(2,"0"),a=n.toLocaleString("default",{month:"long"}),i=n.getFullYear();return{reminderCta:`Remind me in ${a}`,reminderPeriod:`${i}-${t}-01`,reminderLabel:`${a} ${i}`}},D=new Date("2023-12-31"),L=e=>e>=(e=>new Date(e.getFullYear(),9,20))(e)&&e<R(e.getFullYear()),w=(e,n=new Date)=>{return"US"===e&&L(n)?{reminderCta:"Remind me on Giving Tuesday",reminderPeriod:`${t=n.getFullYear()}-${(R(t).getMonth()+1).toString().padStart(0,"2")}-01`,reminderLabel:"on Giving Tuesday",reminderOption:`giving-tuesday-${t}`}:"US"===e&&(e=>e>=R(e.getFullYear())&&e<D)(n)?(e=>({reminderCta:"Remind me on New Years Eve",reminderPeriod:`${e}-12-01`,reminderLabel:"on New Years Eve",reminderOption:`new-years-eve-${e}`}))(n.getFullYear()):P(n);var t},O=e.object({text:e.string(),baseUrl:e.string()});let k=function(e){return e.Custom="CustomSecondaryCta",e.ContributionsReminder="ContributionsReminderSecondaryCta",e}({});e.nativeEnum(k);const f=e.object({type:e.literal(k.Custom),cta:O}),j=e.object({type:e.literal(k.ContributionsReminder)}),K=e.discriminatedUnion("type",[f,j]),F=e.object({countLabel:e.string(),goalCopy:e.string().optional()}),v=e.object({total:e.number(),goal:e.number()}),H=e.enum(["US","AU","global"]),Y=e.object({currencySymbol:e.string(),copy:F,name:H,tickerData:v.optional()}),V=e.object({for52Weeks:e.number(),forTargetedWeeks:e.number()}),W=e.enum(["for52Weeks","forTargetedWeeks"]),Z=e.object({type:e.literal("above"),copy:e.string().optional(),countType:W.optional()}),$=e.enum(["CONTRIBUTION","MEMBERSHIP_SUPPORTER","DIGITAL_SUBSCRIPTION","PRINT_SUBSCRIPTION"]),x=e.enum(["ACQUISITIONS_EPIC","ACQUISITIONS_ENGAGEMENT_BANNER","ACQUISITIONS_SUBSCRIPTIONS_BANNER","ACQUISITIONS_HEADER","ACQUISITIONS_OTHER"]),_=e.object({abTestName:e.string(),abTestVariant:e.string(),campaignCode:e.string(),componentType:x,products:e.array($).nullish(),labels:e.array(e.string()).nullish(),ophanPageId:e.string(),platformId:e.string(),referrerUrl:e.string()}),J=e.object({mainUrl:e.string(),mobileUrl:e.string().optional(),tabletUrl:e.string().optional(),desktopUrl:e.string().optional(),leftColUrl:e.string().optional(),wideUrl:e.string().optional(),altText:e.string()}),Q=e.object({name:e.string(),description:e.string().optional(),headshot:J.optional()}),z=/^[0-9A-F]{2}$/,q=e.string().refine((e=>z.test(e)),(e=>({message:`"${e}" is not a valid hex value`}))),X=e.object({r:q,g:q,b:q,kind:e.literal("hex")}),ee=e.object({mobileUrl:e.string(),tabletUrl:e.string(),desktopUrl:e.string(),altText:e.string(),kind:e.literal("Image")}),ne=e.object({buttonColour:X.nullish(),buttonTextColour:X.nullish(),buttonBorderColour:X.nullish(),buttonSelectColour:X.nullish(),buttonSelectTextColour:X.nullish(),buttonSelectBorderColour:X.nullish(),kind:e.literal("ChoiceCards")}),te=e.discriminatedUnion("kind",[ee,ne]),ae=e.object({visual:te.nullish(),colours:e.object({basic:e.object({background:X,bodyText:X})})}),ie=e=>`#${e.r}${e.g}${e.b}`,oe=e.object({copy:e.string()}),re=e.union([e.literal("Monthly"),e.literal("Annual")]),se=e.discriminatedUnion("supportTier",[e.object({supportTier:e.literal("Contribution"),ratePlan:re}),e.object({supportTier:e.literal("SupporterPlus"),ratePlan:re}),e.object({supportTier:e.literal("OneOff")})]),le=e.object({copy:e.string(),textColour:X.nullish(),backgroundColour:X.nullish()}),ue=e.object({product:se,label:e.string(),isDefault:e.boolean(),benefitsLabel:e.string().nullish(),benefits:e.array(oe),pill:le.nullish()}),ce=e.object({choiceCards:e.array(ue),mobileChoiceCards:e.array(ue).nullish()}),de=e.object({maxViewsCount:e.number(),maxViewsDays:e.number(),minDaysBetweenViews:e.number()}),ge=e.object({reminderCta:e.string(),reminderLabel:e.string(),reminderPeriod:e.string()}),pe=e.enum(["ONE_OFF","MONTHLY","ANNUAL"]),me=e.object({testName:e.string(),variantName:e.string(),defaultContributionType:pe,displayContributionType:pe.array(),amountsCardData:e.object({ONE_OFF:e.object({amounts:e.array(e.number()),defaultAmount:e.number(),hideChooseYourAmount:e.boolean().optional()}),MONTHLY:e.object({amounts:e.array(e.number()),defaultAmount:e.number(),hideChooseYourAmount:e.boolean().optional()}),ANNUAL:e.object({amounts:e.array(e.number()),defaultAmount:e.number(),hideChooseYourAmount:e.boolean().optional()})})}),be=e.object({newsletterId:e.string(),successDescription:e.string()}),Ce=e.object({name:e.string(),heading:e.string().optional(),paragraphs:e.array(e.string()),highlightedText:e.string().optional(),tickerSettings:Y.optional(),cta:O.optional(),secondaryCta:K.optional(),newsletterSignup:be.optional(),image:J.optional(),showReminderFields:ge.optional(),separateArticleCount:Z.optional(),maxViews:de.optional(),showSignInLink:e.boolean().optional(),bylineWithImage:Q.optional(),showChoiceCards:e.boolean().optional(),choiceCardsSettings:ce.nullish(),choiceCardAmounts:me.optional(),defaultChoiceCardFrequency:pe.optional()}),Se=e.object({variant:Ce,tracking:_,countryCode:e.string().nullish(),articleCounts:V,onReminderOpen:e.any().nullish(),fetchEmail:e.any().nullish(),submitComponentEvent:e.any().nullish(),openCmp:e.any().nullish(),hasConsentForArticleCount:e.boolean().nullish(),stage:e.string().nullish()}),he=e.enum(["contributions","subscriptions","signIn","abandonedBasket"]),ye=e.object({heading:e.string().optional(),messageText:e.string().optional(),paragraphs:e.array(e.string()).optional(),mobileMessageText:e.string().optional(),highlightedText:e.string().optional(),cta:O.optional(),secondaryCta:K.optional()}),Ae=e.object({tracking:_,bannerChannel:he,content:ye.nullish(),mobileContent:ye.nullish(),countryCode:e.string().nullish(),isSupporter:e.boolean().nullish(),tickerSettings:Y.nullish(),submitComponentEvent:e.any(),articleCounts:V,hasOptedOutOfArticleCount:e.boolean().nullish(),fetchEmail:e.any().nullish(),separateArticleCount:e.boolean().nullish(),design:ae.nullish(),choiceCardsSettings:ce.nullish()}),Te=e.object({heading:e.string(),subheading:e.string(),primaryCta:O.optional(),secondaryCta:O.optional(),benefits:e.array(e.string()).optional()}),Ie=e.object({content:Te,tracking:_,mobileContent:Te.optional(),countryCode:e.string().optional(),submitComponentEvent:e.any(),numArticles:e.number().optional()}),Ne=e.object({image:J,bodyCopy:e.array(e.string()),cta:O.optional()});e.object({content:Ne,tracking:_,countryCode:e.string().optional(),submitComponentEvent:e.any()});const Me=e.enum(["Contribution","SupporterPlus","GuardianWeekly","Paper"]),Ee=e.enum(["new","guest","current"]),Ge=e.enum(["Epic","EpicAMP","EpicAppleNews","EpicLiveblog","Banner1","Banner2","Header","GutterLiveblog"]),Ue=e.enum(["Live","Draft","Archived"]),Be=e.enum(["Mobile","Desktop","All","iOS","Android"]),Re=e.enum(["SignedIn","SignedOut","All"]),Pe=e.enum(["HasConsented","HasNotConsented","All"]),De=e.object({name:e.literal("ABTest")}),Le=e.object({name:e.literal("EpsilonGreedyBandit"),epsilon:e.number(),sampleCount:e.number().optional()}),we=e.object({name:e.literal("Roulette"),sampleCount:e.number().optional()}),Oe=e.intersection(e.discriminatedUnion("name",[De,Le,we]),e.object({testName:e.string().optional()})),ke=e.object({channel:Ge,name:e.string(),status:Ue,priority:e.number(),controlProportionSettings:e.object({proportion:e.number(),offset:e.number()}).optional(),deviceType:Be.optional(),signedInStatus:Re.optional(),consentStatus:Pe.optional(),methodologies:Oe.array().optional()}),fe=e.enum(["AllExistingSupporters","AllNonSupporters","Everyone","PostAskPauseSingleContributors"]),je=e.object({minViews:e.number(),maxViews:e.number().optional(),periodInWeeks:e.number(),tagIds:e.array(e.string()).optional()});e.object({userType:e.array(Ee),product:e.array(Me)}),e.object({tagIds:e.array(e.string()),sectionIds:e.array(e.string()),excludedTagIds:e.array(e.string()),excludedSectionIds:e.array(e.string())});const Ke=e.object({maxViewsCount:e.number(),maxViewsDays:e.number(),minDaysBetweenViews:e.number()}),Fe=["ONE_OFF","MONTHLY","ANNUAL"];ke.extend({name:e.string(),status:Ue,locations:e.array(u).optional(),regionTargeting:c.optional(),tagIds:e.array(e.string()),sections:e.array(e.string()),excludedTagIds:e.array(e.string()),excludedSections:e.array(e.string()),alwaysAsk:e.boolean(),maxViews:Ke.optional(),userCohort:fe,hasCountryName:e.boolean(),highPriority:e.boolean(),useLocalViewLog:e.boolean(),articlesViewedSettings:je.optional(),priority:e.number(),variants:Ce.array()});const ve=e.object({amount:e.union([e.number(),e.literal("other")]),billingPeriod:e.union([e.literal("ONE_OFF"),e.literal("MONTHLY"),e.literal("ANNUAL")]),product:e.union([e.literal("Contribution"),e.literal("SupporterPlus"),e.literal("PremiumTier"),e.literal("DailyEdition"),e.literal("GuardianWeekly"),e.literal("Paper"),e.literal("PaperAndDigital")]),region:e.union([e.literal("uk"),e.literal("us"),e.literal("au"),e.literal("eu"),e.literal("int"),e.literal("nz"),e.literal("ca")])}),He=(e,n,t)=>{const a=(e=>{if(URLSearchParams){const n=new URLSearchParams(window.location.search).get(`force-${e}`);if(n)return n}return null})(e);return fetch(`${n}/${e}${a?`?force=${a}`:""}`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then((n=>{if(!n.ok)throw Error(n.statusText||`Supporter Revenue ${e} | Api call returned HTTP status ${n.status}`);return n})).then((e=>e.json()))},Ye=(e,n)=>He("epic",e,n),Ve=(e,n)=>He("liveblog-epic",e,n),We=(e,n)=>He("banner",e,n),Ze=(e,n)=>He("gutter-liveblog",e,n),$e=(e,n)=>He("header",e,n);export{l as CountryGroupId,k as SecondaryCtaType,ve as abandonedBasketSchema,A as addRegionIdToSupportUrl,Ae as bannerSchema,P as buildReminderFields,E as containsNonArticleCountPlaceholder,Fe as contributionTabFrequencies,b as countryCodeToCountryGroupId,u as countryGroupIdSchema,d as countryGroups,Se as epicPropsSchema,We as getBanner,h as getCountryName,Ye as getEpic,U as getEpicViewLog,Ze as getGutterLiveblog,$e as getHeader,Ve as getLiveblogEpic,S as getLocalCurrencySymbol,w as getReminderFields,i as getWeeklyArticleHistory,Ie as headerPropsSchema,ie as hexColourToString,C as inTargetedCountry,s as incrementWeeklyArticleCount,y as isGWCheckoutUrl,m as isoCurrencyToCurrencySymbol,B as logEpicView,N as replaceNonArticleCountPlaceholders,c as targetedRegionsSchema};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("zod");const t="gu.history.weeklyArticleCount",n="gu.history.articleCountsThisWeek",a=e=>{const t=e.getDay()||7;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()-(t-1))/864e5},o=new Set(["environment/climate-change","environment/climate-crisis","environment/environment","science/science","politics/politics","us-news/us-politics","australia-news/australian-politics","world/world","world/europe-news","world/russia","books/books","culture/culture","world/coronavirus-outbreak","world/race","inequality/inequality","technology/technology","business/business","tone/recipes","sport/sport","football/football","sport/olympic-games","sport/olympic-games-2024","tracking/commissioningdesk/uk-investigations"]),r=(e,t={})=>(e.forEach((e=>{o.has(e)&&(t[e]=(t[e]??0)+1)})),t),i=["GBPCountries","UnitedStates","AUDCountries","EURCountries","International","NZDCountries","Canada"],s=e.z.enum(i),l=e.z.object({targetedCountryGroups:e.z.array(s),targetedCountryCodes:e.z.array(e.z.string()).optional()}).optional(),u={GBPCountries:{name:"United Kingdom",currency:"GBP",countries:["GB","FK","GI","GG","IM","JE","SH"],supportRegionId:"UK"},UnitedStates:{name:"United States",currency:"USD",countries:["US"],supportRegionId:"US"},AUDCountries:{name:"Australia",currency:"AUD",countries:["AU","KI","NR","NF","TV"],supportRegionId:"AU"},EURCountries:{name:"Europe",currency:"EUR",countries:["AD","AL","AT","BA","BE","BG","BL","CH","CY","CZ","DE","DK","EE","ES","FI","FO","FR","GF","GL","GP","GR","HR","HU","IE","IT","LI","LT","LU","LV","MC","ME","MF","IS","MQ","MT","NL","NO","PF","PL","PM","PT","RE","RO","RS","SE","SI","SJ","SK","SM","TF","TR","WF","YT","VA","AX","AZ","AM","GE","BY","MD","UA","MK"],supportRegionId:"EU"},International:{name:"International",currency:"USD",countries:["AE","AF","AG","AI","AO","AQ","AR","AS","AW","BB","BD","BF","BH","BI","BJ","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BZ","CC","CD","CF","CG","CI","CL","CM","CN","CO","CR","CU","CV","CW","CX","DJ","DM","DO","DZ","EC","EG","EH","ER","ET","FJ","FM","GA","GD","GH","GM","GN","GQ","GS","GT","GU","GW","GY","HK","HM","HN","HT","ID","IL","IN","IO","IQ","IR","JM","JO","JP","KE","KG","KH","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LK","LR","LS","LY","MA","MG","MH","ML","MM","MN","MO","MP","MR","MS","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NG","NI","NP","NU","OM","PA","PE","PG","PH","PK","PN","PR","PS","PW","PY","QA","RU","RW","SA","SB","SC","SD","SG","SL","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TG","TH","TJ","TK","TL","TM","TN","TO","TT","TW","TZ","UG","UM","UY","UZ","VC","VE","VG","VI","VN","VU","WS","YE","ZA","ZM","ZW"],supportRegionId:"INT"},NZDCountries:{name:"New Zealand",currency:"NZD",countries:["NZ","CK"],supportRegionId:"NZ"},Canada:{name:"Canada",currency:"CAD",countries:["CA"],supportRegionId:"CA"}},c={AD:"Andorra",AE:"the UAE",AF:"Afghanistan",AG:"Antigua and Barbuda",AI:"Anguilla",AL:"Albania",AM:"Armenia",AO:"Angola",AR:"Argentina",AS:"the US",AT:"Austria",AU:"Australia",AW:"Aruba",AX:"Åland Islands",AZ:"Azerbaijan",BA:"Bosnia and Herzegovina",BB:"Barbados",BD:"Bangladesh",BE:"Belgium",BF:"Burkina Faso",BG:"Bulgaria",BH:"Bahrain",BI:"Burundi",BJ:"Benin",BL:"Saint Barthélemy",BM:"Bermuda",BN:"Brunei Darussalam",BO:"Bolivia",BQ:"Bonaire, Sint Eustatius and Saba",BR:"Brazil",BS:"the Bahamas",BT:"Bhutan",BV:"Bouvet Island",BW:"Botswana",BY:"Belarus",BZ:"Belize",CA:"Canada",CD:"the Democratic Republic of the Congo",CF:"the Central Africa Republic",CG:"the Congo",CH:"Switzerland",CI:"Côte d'Ivoire",CK:"the Cook Islands",CL:"Chile",CM:"Cameroon",CN:"China",CO:"Colombia",CR:"Costa Rica",CU:"Cuba",CV:"Cabo Verde",CW:"Curaçao",CX:"Christmas Island",CY:"Cyprus",CZ:"the Czech Republic",DE:"Germany",DJ:"Djibouti",DK:"Denmark",DM:"Dominica",DO:"the Dominican Republic",DZ:"Algeria",EC:"Ecuador",EE:"Estonia",EG:"Egypt",EH:"the Western Sahara",ER:"Eritrea",ES:"Spain",ET:"Ethiopia",FI:"Finland",FJ:"Fiji",FK:"the UK",FO:"the UK",FR:"France",GA:"Gabon",GB:"the UK",GD:"Grenada",GE:"Georgia",GF:"French Guiana",GG:"Guernsey",GH:"Ghana",GI:"Gibraltar",GL:"Greenland",GM:"the Gambia",GN:"Guinea",GP:"Guadeloupe",GQ:"Equatorial Guinea",GR:"Greece",GT:"Guatemala",GU:"Guam",GW:"Guinea-Bissau",GY:"Guyana",HK:"Hong Kong",HN:"Honduras",HR:"Croatia",HT:"Haiti",HU:"Hungary",ID:"Indonesia",IE:"Ireland",IM:"the Isle of Man",IN:"India",IQ:"Iraq",IR:"Iran",IS:"Iceland",IT:"Italy",JE:"Jersey",JM:"Jamaica",JO:"Jordan",JP:"Japan",KE:"Kenya",KG:"Kyrgyzstan",KH:"Cambodia",KI:"Kiribati",KN:"Saint Kitts and Nevis",KP:"Korea",KR:"Korea",KW:"Kuwait",KY:"the Cayman Ialnds",KZ:"Kazakhstan",LB:"Lebanon",LC:"Saint Lucia",LI:"Liechtenstein",LK:"Sri Lanka",LR:"Liberia",LS:"Lesotho",LT:"Lithuania",LU:"Luxembourg",LV:"Latvia",LY:"Libya",MA:"Morocco",MC:"Monaco",MD:"Moldova",ME:"Montenegro",MG:"Madagascar",MK:"the Republic of North Macedonia",ML:"Mali",MM:"Myanmar",MN:"Mongolia",MO:"Macao",MQ:"Martinique",MR:"Mauritania",MS:"Montserrat",MT:"Malta",MU:"Mauritius",MV:"Maldives",MW:"Malawi",MX:"Mexico",MY:"Malaysia",MZ:"Mozambique",NA:"Namibia",NC:"New Caledonia",NE:"Niger",NF:"Norfolk Island",NG:"Nigeria",NI:"Nicaragua",NL:"the Netherlands",NO:"Norway",NP:"Nepal",NR:"Nauru",NU:"Niue",NZ:"New Zealand",OM:"Oman",PA:"Panama",PE:"Peru",PF:"French Polynesia",PG:"Papua New Guinea",PH:"the Philippines",PK:"Pakistan",PL:"Poland",PM:"Saint Pierre and Miquelon",PN:"Pitcairn",PR:"Puerto Rico",PT:"Portugal",PW:"Palau",PY:"Paraguay",QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russia",RW:"Rwanda",SA:"Saudi Arabia",SB:"Solomon Islands",SC:"Seychelles",SD:"Sudan",SE:"Sweden",SG:"Singapore",SH:"Saint Helena",SI:"Slovenia",SJ:"Svalbard and Jan Mayen",SK:"Slovakia",SL:"Sierra Leone",SM:"San Marino",SN:"Senegal",SO:"Somalia",SR:"Suriname",SS:"South Sudan",ST:"Sao Tome and Principe",SV:"El Salvador",SY:"Syrian Arab Republic",SZ:"Eswatini",TD:"Chad",TG:"Togo",TH:"Thailand",TJ:"Tajikistan",TK:"Tokelau",TL:"Timor-Leste",TM:"Turkmenistan",TN:"Tunisia",TO:"Tonga",TR:"Turkey",TT:"Trinidad and Tobago",TV:"Tuvalu",TW:"Taiwan",TZ:"Tanzania ",UG:"Uganda",US:"the US",UY:"Uruguay",UZ:"Uzbekistan",VC:"Saint Vincent and the Grenadines",VE:"Venezuela",VG:"the Virgin Islands",VI:"the Virgin Islands",VN:"Vietnam",VU:"Vanuatu",WF:"Wallis and Futuna",WS:"Samoa",YE:"Yemen",YT:"Mayotte",ZA:"South Africa",ZM:"Zambia",ZW:"Zimbabwe"},d={GBPCountries:"£",UnitedStates:"$",AUDCountries:"$",Canada:"CA$",EURCountries:"€",NZDCountries:"NZ$",International:"$"},g=e=>Object.keys(u).find((t=>u[t].countries.includes(e??"")))||"International",p=e=>{if(e){const t=g(e);return d[t]}return"£"},z=e=>{if(e)return c[e]},m=e=>e.includes("subscribe/weekly/checkout"),C=(e,t,n,a)=>{if(a){const o=a[g(n)];if(o){return`${p(n)}${o[e][t].price}`}}},b={CURRENCY_SYMBOL:({countryCode:e})=>p(e),COUNTRY_NAME:({countryCode:e})=>z(e),PRICE_DIGISUB_MONTHLY:({countryCode:e,prices:t})=>C("Digisub","Monthly",e,t),PRICE_DIGISUB_ANNUAL:({countryCode:e,prices:t})=>C("Digisub","Annual",e,t),PRICE_GUARDIANWEEKLY_MONTHLY:({countryCode:e,prices:t})=>C("GuardianWeekly","Monthly",e,t),PRICE_GUARDIANWEEKLY_ANNUAL:({countryCode:e,prices:t})=>C("GuardianWeekly","Annual",e,t),DAY_OF_THE_WEEK:()=>((e=new Date)=>e.toLocaleString("en-GB",{weekday:"long"}))(),DATE:()=>((e=new Date)=>e.toLocaleString("en-GB",{day:"numeric",month:"long",year:"numeric"}))()},S=/%%.*?%%/g,h="gu.contributions.views",y=e=>{const t=(e=>{const t=new Date(e,10,1).getDay();return new Date(e,10,22+(11-t)%7)})(e);return t.setDate(t.getDate()+5),t},A=(e=new Date)=>{const t=(e=>{const t=e.getDate()<20?1:2;return e.setMonth(e.getMonth()+t),e})(e),n=(t.getMonth()+1).toString().padStart(2,"0"),a=t.toLocaleString("default",{month:"long"}),o=t.getFullYear();return{reminderCta:`Remind me in ${a}`,reminderPeriod:`${o}-${n}-01`,reminderLabel:`${a} ${o}`}},T=new Date("2023-12-31"),I=e=>e>=(e=>new Date(e.getFullYear(),9,20))(e)&&e<y(e.getFullYear()),N=e.z.object({text:e.z.string(),baseUrl:e.z.string()});let M=function(e){return e.Custom="CustomSecondaryCta",e.ContributionsReminder="ContributionsReminderSecondaryCta",e}({});e.z.nativeEnum(M);const E=e.z.object({type:e.z.literal(M.Custom),cta:N}),G=e.z.object({type:e.z.literal(M.ContributionsReminder)}),U=e.z.discriminatedUnion("type",[E,G]),R=e.z.object({countLabel:e.z.string(),goalCopy:e.z.string().optional()}),B=e.z.object({total:e.z.number(),goal:e.z.number()}),P=e.z.enum(["US","AU","global"]),L=e.z.object({currencySymbol:e.z.string(),copy:R,name:P,tickerData:B.optional()}),D=e.z.object({for52Weeks:e.z.number(),forTargetedWeeks:e.z.number()}),w=e.z.enum(["for52Weeks","forTargetedWeeks"]),O=e.z.object({type:e.z.literal("above"),copy:e.z.string().optional(),countType:w.optional()}),k=e.z.enum(["CONTRIBUTION","MEMBERSHIP_SUPPORTER","DIGITAL_SUBSCRIPTION","PRINT_SUBSCRIPTION"]),x=e.z.enum(["ACQUISITIONS_EPIC","ACQUISITIONS_ENGAGEMENT_BANNER","ACQUISITIONS_SUBSCRIPTIONS_BANNER","ACQUISITIONS_HEADER","ACQUISITIONS_OTHER"]),F=e.z.object({abTestName:e.z.string(),abTestVariant:e.z.string(),campaignCode:e.z.string(),componentType:x,products:e.z.array(k).nullish(),labels:e.z.array(e.z.string()).nullish(),ophanPageId:e.z.string(),platformId:e.z.string(),referrerUrl:e.z.string()}),f=e.z.object({mainUrl:e.z.string(),mobileUrl:e.z.string().optional(),tabletUrl:e.z.string().optional(),desktopUrl:e.z.string().optional(),leftColUrl:e.z.string().optional(),wideUrl:e.z.string().optional(),altText:e.z.string()}),v=e.z.object({name:e.z.string(),description:e.z.string().optional(),headshot:f.optional()}),K=/^[0-9A-F]{2}$/,j=e.z.string().refine((e=>K.test(e)),(e=>({message:`"${e}" is not a valid hex value`}))),H=e.z.object({r:j,g:j,b:j,kind:e.z.literal("hex")}),V=e.z.object({mobileUrl:e.z.string(),tabletUrl:e.z.string(),desktopUrl:e.z.string(),altText:e.z.string(),kind:e.z.literal("Image")}),Y=e.z.object({buttonColour:H.nullish(),buttonTextColour:H.nullish(),buttonBorderColour:H.nullish(),buttonSelectColour:H.nullish(),buttonSelectTextColour:H.nullish(),buttonSelectBorderColour:H.nullish(),kind:e.z.literal("ChoiceCards")}),W=e.z.discriminatedUnion("kind",[V,Y]),Z=e.z.object({visual:W.nullish(),colours:e.z.object({basic:e.z.object({background:H,bodyText:H})})}),$=e.z.object({maxViewsCount:e.z.number(),maxViewsDays:e.z.number(),minDaysBetweenViews:e.z.number()}),_=e.z.object({reminderCta:e.z.string(),reminderLabel:e.z.string(),reminderPeriod:e.z.string()}),J=e.z.enum(["ONE_OFF","MONTHLY","ANNUAL"]),Q=e.z.object({testName:e.z.string(),variantName:e.z.string(),defaultContributionType:J,displayContributionType:J.array(),amountsCardData:e.z.object({ONE_OFF:e.z.object({amounts:e.z.array(e.z.number()),defaultAmount:e.z.number(),hideChooseYourAmount:e.z.boolean().optional()}),MONTHLY:e.z.object({amounts:e.z.array(e.z.number()),defaultAmount:e.z.number(),hideChooseYourAmount:e.z.boolean().optional()}),ANNUAL:e.z.object({amounts:e.z.array(e.z.number()),defaultAmount:e.z.number(),hideChooseYourAmount:e.z.boolean().optional()})})}),q=e.z.object({newsletterId:e.z.string(),successDescription:e.z.string()}),X=e.z.object({name:e.z.string(),heading:e.z.string().optional(),paragraphs:e.z.array(e.z.string()),highlightedText:e.z.string().optional(),tickerSettings:L.optional(),cta:N.optional(),secondaryCta:U.optional(),newsletterSignup:q.optional(),image:f.optional(),showReminderFields:_.optional(),separateArticleCount:O.optional(),maxViews:$.optional(),showSignInLink:e.z.boolean().optional(),bylineWithImage:v.optional(),showChoiceCards:e.z.boolean().optional(),choiceCardAmounts:Q.optional(),defaultChoiceCardFrequency:J.optional()}),ee=e.z.object({variant:X,tracking:F,countryCode:e.z.string().nullish(),articleCounts:D,onReminderOpen:e.z.any().nullish(),fetchEmail:e.z.any().nullish(),submitComponentEvent:e.z.any().nullish(),openCmp:e.z.any().nullish(),hasConsentForArticleCount:e.z.boolean().nullish(),stage:e.z.string().nullish()}),te=e.z.enum(["contributions","subscriptions","signIn","abandonedBasket"]),ne=e.z.object({heading:e.z.string().optional(),messageText:e.z.string().optional(),paragraphs:e.z.array(e.z.string()).optional(),mobileMessageText:e.z.string().optional(),highlightedText:e.z.string().optional(),cta:N.optional(),secondaryCta:U.optional()}),ae=e.z.object({tracking:F,bannerChannel:te,content:ne.nullish(),mobileContent:ne.nullish(),countryCode:e.z.string().nullish(),isSupporter:e.z.boolean().nullish(),tickerSettings:L.nullish(),submitComponentEvent:e.z.any(),articleCounts:D,hasOptedOutOfArticleCount:e.z.boolean().nullish(),fetchEmail:e.z.any().nullish(),separateArticleCount:e.z.boolean().nullish(),design:Z.nullish()}),oe=e.z.object({heading:e.z.string(),subheading:e.z.string(),primaryCta:N.optional(),secondaryCta:N.optional(),benefits:e.z.array(e.z.string()).optional()}),re=e.z.object({content:oe,tracking:F,mobileContent:oe.optional(),countryCode:e.z.string().optional(),submitComponentEvent:e.z.any(),numArticles:e.z.number().optional()}),ie=e.z.object({image:f,bodyCopy:e.z.array(e.z.string()),cta:N.optional()});e.z.object({content:ie,tracking:F,countryCode:e.z.string().optional(),submitComponentEvent:e.z.any()});const se=e.z.enum(["Contribution","SupporterPlus","GuardianWeekly","Paper"]),le=e.z.enum(["new","guest","current"]),ue=e.z.enum(["Epic","EpicAMP","EpicAppleNews","EpicLiveblog","Banner1","Banner2","Header","GutterLiveblog"]),ce=e.z.enum(["Live","Draft","Archived"]),de=e.z.enum(["Mobile","Desktop","All","iOS","Android"]),ge=e.z.enum(["SignedIn","SignedOut","All"]),pe=e.z.enum(["HasConsented","HasNotConsented","All"]),ze=e.z.object({name:e.z.literal("ABTest")}),me=e.z.object({name:e.z.literal("EpsilonGreedyBandit"),epsilon:e.z.number(),sampleCount:e.z.number().optional()}),Ce=e.z.object({name:e.z.literal("Roulette"),sampleCount:e.z.number().optional()}),be=e.z.intersection(e.z.discriminatedUnion("name",[ze,me,Ce]),e.z.object({testName:e.z.string().optional()})),Se=e.z.object({channel:ue,name:e.z.string(),status:ce,priority:e.z.number(),controlProportionSettings:e.z.object({proportion:e.z.number(),offset:e.z.number()}).optional(),deviceType:de.optional(),signedInStatus:ge.optional(),consentStatus:pe.optional(),methodologies:be.array().optional()}),he=e.z.enum(["AllExistingSupporters","AllNonSupporters","Everyone","PostAskPauseSingleContributors"]),ye=e.z.object({minViews:e.z.number(),maxViews:e.z.number().optional(),periodInWeeks:e.z.number(),tagIds:e.z.array(e.z.string()).optional()});e.z.object({userType:e.z.array(le),product:e.z.array(se)}),e.z.object({tagIds:e.z.array(e.z.string()),sectionIds:e.z.array(e.z.string()),excludedTagIds:e.z.array(e.z.string()),excludedSectionIds:e.z.array(e.z.string())});const Ae=e.z.object({maxViewsCount:e.z.number(),maxViewsDays:e.z.number(),minDaysBetweenViews:e.z.number()});Se.extend({name:e.z.string(),status:ce,locations:e.z.array(s).optional(),regionTargeting:l.optional(),tagIds:e.z.array(e.z.string()),sections:e.z.array(e.z.string()),excludedTagIds:e.z.array(e.z.string()),excludedSections:e.z.array(e.z.string()),alwaysAsk:e.z.boolean(),maxViews:Ae.optional(),userCohort:he,hasCountryName:e.z.boolean(),highPriority:e.z.boolean(),useLocalViewLog:e.z.boolean(),articlesViewedSettings:ye.optional(),priority:e.z.number(),variants:X.array()});const Te=e.z.object({amount:e.z.union([e.z.number(),e.z.literal("other")]),billingPeriod:e.z.union([e.z.literal("ONE_OFF"),e.z.literal("MONTHLY"),e.z.literal("ANNUAL")]),product:e.z.union([e.z.literal("Contribution"),e.z.literal("SupporterPlus"),e.z.literal("PremiumTier"),e.z.literal("DailyEdition"),e.z.literal("GuardianWeekly"),e.z.literal("Paper"),e.z.literal("PaperAndDigital")]),region:e.z.union([e.z.literal("uk"),e.z.literal("us"),e.z.literal("au"),e.z.literal("eu"),e.z.literal("int"),e.z.literal("nz"),e.z.literal("ca")])}),Ie=(e,t,n)=>{const a=(e=>{if(URLSearchParams){const t=new URLSearchParams(window.location.search).get(`force-${e}`);if(t)return t}return null})(e);return fetch(`${t}/${e}${a?`?force=${a}`:""}`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).then((t=>{if(!t.ok)throw Error(t.statusText||`Supporter Revenue ${e} | Api call returned HTTP status ${t.status}`);return t})).then((e=>e.json()))};exports.CountryGroupId=i,exports.SecondaryCtaType=M,exports.abandonedBasketSchema=Te,exports.addRegionIdToSupportUrl=(e,t)=>{if(t){const n=(e=>u[g(e)].supportRegionId)(t);if(n&&!m(e))return e.replace(/(support\.theguardian\.com)\/(contribute-in-epic|contribute|subscribe|checkout)/,((e,t,a)=>`${t}/${n.toLowerCase()}/${a}`))}return e},exports.bannerSchema=ae,exports.buildReminderFields=A,exports.containsNonArticleCountPlaceholder=e=>{const t=e.match(S)?.filter((e=>"%%ARTICLE_COUNT%%"!==e));return!!t&&t.length>0},exports.contributionTabFrequencies=["ONE_OFF","MONTHLY","ANNUAL"],exports.countryCodeToCountryGroupId=g,exports.countryGroupIdSchema=s,exports.epicPropsSchema=ee,exports.getBanner=(e,t)=>Ie("banner",e,t),exports.getCountryName=z,exports.getEpic=(e,t)=>Ie("epic",e,t),exports.getEpicViewLog=e=>e.get(h)||void 0,exports.getGutterLiveblog=(e,t)=>Ie("gutter-liveblog",e,t),exports.getHeader=(e,t)=>Ie("header",e,t),exports.getLiveblogEpic=(e,t)=>Ie("liveblog-epic",e,t),exports.getLocalCurrencySymbol=p,exports.getReminderFields=(e,t=new Date)=>{return"US"===e&&I(t)?{reminderCta:"Remind me on Giving Tuesday",reminderPeriod:`${n=t.getFullYear()}-${(y(n).getMonth()+1).toString().padStart(0,"2")}-01`,reminderLabel:"on Giving Tuesday",reminderOption:`giving-tuesday-${n}`}:"US"===e&&(e=>e>=y(e.getFullYear())&&e<T)(t)?(e=>({reminderCta:"Remind me on New Years Eve",reminderPeriod:`${e}-12-01`,reminderLabel:"on New Years Eve",reminderOption:`new-years-eve-${e}`}))(t.getFullYear()):A(t);var n},exports.getWeeklyArticleHistory=e=>e.get(t)||void 0,exports.headerPropsSchema=re,exports.hexColourToString=e=>`#${e.r}${e.g}${e.b}`,exports.inTargetedCountry=(e,t=[],n=[])=>0===t.length&&0===n.length||!!e&&(!!t.includes(g(e.toUpperCase()))||n.includes(e.toUpperCase())),exports.incrementWeeklyArticleCount=(e,o,i)=>{const s=((e,t)=>{const o=a(new Date),r=e.get(n);if(r&&r.week===o){const a=r.articles[t]||0;return e.set(n,{week:o,articles:{...r.articles,[t]:a+1}}),a>0}return e.set(n,{week:o,articles:{[t]:1}}),!1})(e,o);if(!s){const n=a(new Date),o=e.get(t)||[],s=o[0];if(s?.week&&s.week===n)s.count+=1,s.tags=r(i,s.tags),e.set(t,o);else{o.unshift({week:n,count:1,tags:r(i,{})});const a=n-365,s=o.filter((e=>e.week>=a));e.set(t,s)}}},exports.isGWCheckoutUrl=m,exports.logEpicView=e=>{const t=localStorage.getItem(h),n=t?JSON.parse(t).value:[];n.push({date:(new Date).getTime(),testId:e});const a={value:n.slice(-50)};localStorage.setItem(h,JSON.stringify(a))},exports.replaceNonArticleCountPlaceholders=(e,t,n)=>e?e.replace(S,(e=>{const a=e.substring(2,e.length-2),o=b[a];if(o){const e=o({countryCode:t,prices:n});if(e)return e}return e})):"",exports.targetedRegionsSchema=l;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("zod");const t="gu.history.weeklyArticleCount",n="gu.history.articleCountsThisWeek",a=e=>{const t=e.getDay()||7;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()-(t-1))/864e5},o=new Set(["environment/climate-change","environment/climate-crisis","environment/environment","science/science","politics/politics","us-news/us-politics","australia-news/australian-politics","world/world","world/europe-news","world/russia","books/books","culture/culture","world/coronavirus-outbreak","world/race","inequality/inequality","technology/technology","business/business","tone/recipes","sport/sport","football/football","sport/olympic-games","sport/olympic-games-2024","tracking/commissioningdesk/uk-investigations"]),r=(e,t={})=>(e.forEach((e=>{o.has(e)&&(t[e]=(t[e]??0)+1)})),t),i=["GBPCountries","UnitedStates","AUDCountries","EURCountries","International","NZDCountries","Canada"],s=e.z.enum(i),l=e.z.object({targetedCountryGroups:e.z.array(s),targetedCountryCodes:e.z.array(e.z.string()).optional()}).optional(),u={GBPCountries:{name:"United Kingdom",currency:"GBP",countries:["GB","FK","GI","GG","IM","JE","SH"],supportRegionId:"UK"},UnitedStates:{name:"United States",currency:"USD",countries:["US"],supportRegionId:"US"},AUDCountries:{name:"Australia",currency:"AUD",countries:["AU","KI","NR","NF","TV"],supportRegionId:"AU"},EURCountries:{name:"Europe",currency:"EUR",countries:["AD","AL","AT","BA","BE","BG","BL","CH","CY","CZ","DE","DK","EE","ES","FI","FO","FR","GF","GL","GP","GR","HR","HU","IE","IT","LI","LT","LU","LV","MC","ME","MF","IS","MQ","MT","NL","NO","PF","PL","PM","PT","RE","RO","RS","SE","SI","SJ","SK","SM","TF","TR","WF","YT","VA","AX","AZ","AM","GE","BY","MD","UA","MK"],supportRegionId:"EU"},International:{name:"International",currency:"USD",countries:["AE","AF","AG","AI","AO","AQ","AR","AS","AW","BB","BD","BF","BH","BI","BJ","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BZ","CC","CD","CF","CG","CI","CL","CM","CN","CO","CR","CU","CV","CW","CX","DJ","DM","DO","DZ","EC","EG","EH","ER","ET","FJ","FM","GA","GD","GH","GM","GN","GQ","GS","GT","GU","GW","GY","HK","HM","HN","HT","ID","IL","IN","IO","IQ","IR","JM","JO","JP","KE","KG","KH","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LK","LR","LS","LY","MA","MG","MH","ML","MM","MN","MO","MP","MR","MS","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NG","NI","NP","NU","OM","PA","PE","PG","PH","PK","PN","PR","PS","PW","PY","QA","RU","RW","SA","SB","SC","SD","SG","SL","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TG","TH","TJ","TK","TL","TM","TN","TO","TT","TW","TZ","UG","UM","UY","UZ","VC","VE","VG","VI","VN","VU","WS","YE","ZA","ZM","ZW"],supportRegionId:"INT"},NZDCountries:{name:"New Zealand",currency:"NZD",countries:["NZ","CK"],supportRegionId:"NZ"},Canada:{name:"Canada",currency:"CAD",countries:["CA"],supportRegionId:"CA"}},c={AD:"Andorra",AE:"the UAE",AF:"Afghanistan",AG:"Antigua and Barbuda",AI:"Anguilla",AL:"Albania",AM:"Armenia",AO:"Angola",AR:"Argentina",AS:"the US",AT:"Austria",AU:"Australia",AW:"Aruba",AX:"Åland Islands",AZ:"Azerbaijan",BA:"Bosnia and Herzegovina",BB:"Barbados",BD:"Bangladesh",BE:"Belgium",BF:"Burkina Faso",BG:"Bulgaria",BH:"Bahrain",BI:"Burundi",BJ:"Benin",BL:"Saint Barthélemy",BM:"Bermuda",BN:"Brunei Darussalam",BO:"Bolivia",BQ:"Bonaire, Sint Eustatius and Saba",BR:"Brazil",BS:"the Bahamas",BT:"Bhutan",BV:"Bouvet Island",BW:"Botswana",BY:"Belarus",BZ:"Belize",CA:"Canada",CD:"the Democratic Republic of the Congo",CF:"the Central Africa Republic",CG:"the Congo",CH:"Switzerland",CI:"Côte d'Ivoire",CK:"the Cook Islands",CL:"Chile",CM:"Cameroon",CN:"China",CO:"Colombia",CR:"Costa Rica",CU:"Cuba",CV:"Cabo Verde",CW:"Curaçao",CX:"Christmas Island",CY:"Cyprus",CZ:"the Czech Republic",DE:"Germany",DJ:"Djibouti",DK:"Denmark",DM:"Dominica",DO:"the Dominican Republic",DZ:"Algeria",EC:"Ecuador",EE:"Estonia",EG:"Egypt",EH:"the Western Sahara",ER:"Eritrea",ES:"Spain",ET:"Ethiopia",FI:"Finland",FJ:"Fiji",FK:"the UK",FO:"the UK",FR:"France",GA:"Gabon",GB:"the UK",GD:"Grenada",GE:"Georgia",GF:"French Guiana",GG:"Guernsey",GH:"Ghana",GI:"Gibraltar",GL:"Greenland",GM:"the Gambia",GN:"Guinea",GP:"Guadeloupe",GQ:"Equatorial Guinea",GR:"Greece",GT:"Guatemala",GU:"Guam",GW:"Guinea-Bissau",GY:"Guyana",HK:"Hong Kong",HN:"Honduras",HR:"Croatia",HT:"Haiti",HU:"Hungary",ID:"Indonesia",IE:"Ireland",IM:"the Isle of Man",IN:"India",IQ:"Iraq",IR:"Iran",IS:"Iceland",IT:"Italy",JE:"Jersey",JM:"Jamaica",JO:"Jordan",JP:"Japan",KE:"Kenya",KG:"Kyrgyzstan",KH:"Cambodia",KI:"Kiribati",KN:"Saint Kitts and Nevis",KP:"Korea",KR:"Korea",KW:"Kuwait",KY:"the Cayman Ialnds",KZ:"Kazakhstan",LB:"Lebanon",LC:"Saint Lucia",LI:"Liechtenstein",LK:"Sri Lanka",LR:"Liberia",LS:"Lesotho",LT:"Lithuania",LU:"Luxembourg",LV:"Latvia",LY:"Libya",MA:"Morocco",MC:"Monaco",MD:"Moldova",ME:"Montenegro",MG:"Madagascar",MK:"the Republic of North Macedonia",ML:"Mali",MM:"Myanmar",MN:"Mongolia",MO:"Macao",MQ:"Martinique",MR:"Mauritania",MS:"Montserrat",MT:"Malta",MU:"Mauritius",MV:"Maldives",MW:"Malawi",MX:"Mexico",MY:"Malaysia",MZ:"Mozambique",NA:"Namibia",NC:"New Caledonia",NE:"Niger",NF:"Norfolk Island",NG:"Nigeria",NI:"Nicaragua",NL:"the Netherlands",NO:"Norway",NP:"Nepal",NR:"Nauru",NU:"Niue",NZ:"New Zealand",OM:"Oman",PA:"Panama",PE:"Peru",PF:"French Polynesia",PG:"Papua New Guinea",PH:"the Philippines",PK:"Pakistan",PL:"Poland",PM:"Saint Pierre and Miquelon",PN:"Pitcairn",PR:"Puerto Rico",PT:"Portugal",PW:"Palau",PY:"Paraguay",QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russia",RW:"Rwanda",SA:"Saudi Arabia",SB:"Solomon Islands",SC:"Seychelles",SD:"Sudan",SE:"Sweden",SG:"Singapore",SH:"Saint Helena",SI:"Slovenia",SJ:"Svalbard and Jan Mayen",SK:"Slovakia",SL:"Sierra Leone",SM:"San Marino",SN:"Senegal",SO:"Somalia",SR:"Suriname",SS:"South Sudan",ST:"Sao Tome and Principe",SV:"El Salvador",SY:"Syrian Arab Republic",SZ:"Eswatini",TD:"Chad",TG:"Togo",TH:"Thailand",TJ:"Tajikistan",TK:"Tokelau",TL:"Timor-Leste",TM:"Turkmenistan",TN:"Tunisia",TO:"Tonga",TR:"Turkey",TT:"Trinidad and Tobago",TV:"Tuvalu",TW:"Taiwan",TZ:"Tanzania ",UG:"Uganda",US:"the US",UY:"Uruguay",UZ:"Uzbekistan",VC:"Saint Vincent and the Grenadines",VE:"Venezuela",VG:"the Virgin Islands",VI:"the Virgin Islands",VN:"Vietnam",VU:"Vanuatu",WF:"Wallis and Futuna",WS:"Samoa",YE:"Yemen",YT:"Mayotte",ZA:"South Africa",ZM:"Zambia",ZW:"Zimbabwe"},d={GBPCountries:"£",UnitedStates:"$",AUDCountries:"$",Canada:"CA$",EURCountries:"€",NZDCountries:"NZ$",International:"$"},p=e=>Object.keys(u).find((t=>u[t].countries.includes(e??"")))||"International",z=e=>{if(e){const t=p(e);return d[t]}return"£"},g=e=>{if(e)return c[e]},m=e=>e.includes("subscribe/weekly/checkout"),b=(e,t,n,a)=>{if(a){const o=a[p(n)];if(o){return`${z(n)}${o[e][t].price}`}}},C={CURRENCY_SYMBOL:({countryCode:e})=>z(e),COUNTRY_NAME:({countryCode:e})=>g(e),PRICE_DIGISUB_MONTHLY:({countryCode:e,prices:t})=>b("Digisub","Monthly",e,t),PRICE_DIGISUB_ANNUAL:({countryCode:e,prices:t})=>b("Digisub","Annual",e,t),PRICE_GUARDIANWEEKLY_MONTHLY:({countryCode:e,prices:t})=>b("GuardianWeekly","Monthly",e,t),PRICE_GUARDIANWEEKLY_ANNUAL:({countryCode:e,prices:t})=>b("GuardianWeekly","Annual",e,t),DAY_OF_THE_WEEK:()=>((e=new Date)=>e.toLocaleString("en-GB",{weekday:"long"}))(),DATE:()=>((e=new Date)=>e.toLocaleString("en-GB",{day:"numeric",month:"long",year:"numeric"}))()},S=/%%.*?%%/g,h="gu.contributions.views",y=e=>{const t=(e=>{const t=new Date(e,10,1).getDay();return new Date(e,10,22+(11-t)%7)})(e);return t.setDate(t.getDate()+5),t},A=(e=new Date)=>{const t=(e=>{const t=e.getDate()<20?1:2;return e.setMonth(e.getMonth()+t),e})(e),n=(t.getMonth()+1).toString().padStart(2,"0"),a=t.toLocaleString("default",{month:"long"}),o=t.getFullYear();return{reminderCta:`Remind me in ${a}`,reminderPeriod:`${o}-${n}-01`,reminderLabel:`${a} ${o}`}},T=new Date("2023-12-31"),I=e=>e>=(e=>new Date(e.getFullYear(),9,20))(e)&&e<y(e.getFullYear()),N=e.z.object({text:e.z.string(),baseUrl:e.z.string()});let M=function(e){return e.Custom="CustomSecondaryCta",e.ContributionsReminder="ContributionsReminderSecondaryCta",e}({});e.z.nativeEnum(M);const E=e.z.object({type:e.z.literal(M.Custom),cta:N}),G=e.z.object({type:e.z.literal(M.ContributionsReminder)}),U=e.z.discriminatedUnion("type",[E,G]),R=e.z.object({countLabel:e.z.string(),goalCopy:e.z.string().optional()}),B=e.z.object({total:e.z.number(),goal:e.z.number()}),P=e.z.enum(["US","AU","global"]),L=e.z.object({currencySymbol:e.z.string(),copy:R,name:P,tickerData:B.optional()}),D=e.z.object({for52Weeks:e.z.number(),forTargetedWeeks:e.z.number()}),w=e.z.enum(["for52Weeks","forTargetedWeeks"]),O=e.z.object({type:e.z.literal("above"),copy:e.z.string().optional(),countType:w.optional()}),k=e.z.enum(["CONTRIBUTION","MEMBERSHIP_SUPPORTER","DIGITAL_SUBSCRIPTION","PRINT_SUBSCRIPTION"]),x=e.z.enum(["ACQUISITIONS_EPIC","ACQUISITIONS_ENGAGEMENT_BANNER","ACQUISITIONS_SUBSCRIPTIONS_BANNER","ACQUISITIONS_HEADER","ACQUISITIONS_OTHER"]),f=e.z.object({abTestName:e.z.string(),abTestVariant:e.z.string(),campaignCode:e.z.string(),componentType:x,products:e.z.array(k).nullish(),labels:e.z.array(e.z.string()).nullish(),ophanPageId:e.z.string(),platformId:e.z.string(),referrerUrl:e.z.string()}),j=e.z.object({mainUrl:e.z.string(),mobileUrl:e.z.string().optional(),tabletUrl:e.z.string().optional(),desktopUrl:e.z.string().optional(),leftColUrl:e.z.string().optional(),wideUrl:e.z.string().optional(),altText:e.z.string()}),F=e.z.object({name:e.z.string(),description:e.z.string().optional(),headshot:j.optional()}),v=/^[0-9A-F]{2}$/,K=e.z.string().refine((e=>v.test(e)),(e=>({message:`"${e}" is not a valid hex value`}))),H=e.z.object({r:K,g:K,b:K,kind:e.z.literal("hex")}),V=e.z.object({mobileUrl:e.z.string(),tabletUrl:e.z.string(),desktopUrl:e.z.string(),altText:e.z.string(),kind:e.z.literal("Image")}),Y=e.z.object({buttonColour:H.nullish(),buttonTextColour:H.nullish(),buttonBorderColour:H.nullish(),buttonSelectColour:H.nullish(),buttonSelectTextColour:H.nullish(),buttonSelectBorderColour:H.nullish(),kind:e.z.literal("ChoiceCards")}),W=e.z.discriminatedUnion("kind",[V,Y]),Z=e.z.object({visual:W.nullish(),colours:e.z.object({basic:e.z.object({background:H,bodyText:H})})}),$=e.z.object({copy:e.z.string()}),_=e.z.union([e.z.literal("Monthly"),e.z.literal("Annual")]),J=e.z.discriminatedUnion("supportTier",[e.z.object({supportTier:e.z.literal("Contribution"),ratePlan:_}),e.z.object({supportTier:e.z.literal("SupporterPlus"),ratePlan:_}),e.z.object({supportTier:e.z.literal("OneOff")})]),Q=e.z.object({copy:e.z.string(),textColour:H.nullish(),backgroundColour:H.nullish()}),q=e.z.object({product:J,label:e.z.string(),isDefault:e.z.boolean(),benefitsLabel:e.z.string().nullish(),benefits:e.z.array($),pill:Q.nullish()}),X=e.z.object({choiceCards:e.z.array(q),mobileChoiceCards:e.z.array(q).nullish()}),ee=e.z.object({maxViewsCount:e.z.number(),maxViewsDays:e.z.number(),minDaysBetweenViews:e.z.number()}),te=e.z.object({reminderCta:e.z.string(),reminderLabel:e.z.string(),reminderPeriod:e.z.string()}),ne=e.z.enum(["ONE_OFF","MONTHLY","ANNUAL"]),ae=e.z.object({testName:e.z.string(),variantName:e.z.string(),defaultContributionType:ne,displayContributionType:ne.array(),amountsCardData:e.z.object({ONE_OFF:e.z.object({amounts:e.z.array(e.z.number()),defaultAmount:e.z.number(),hideChooseYourAmount:e.z.boolean().optional()}),MONTHLY:e.z.object({amounts:e.z.array(e.z.number()),defaultAmount:e.z.number(),hideChooseYourAmount:e.z.boolean().optional()}),ANNUAL:e.z.object({amounts:e.z.array(e.z.number()),defaultAmount:e.z.number(),hideChooseYourAmount:e.z.boolean().optional()})})}),oe=e.z.object({newsletterId:e.z.string(),successDescription:e.z.string()}),re=e.z.object({name:e.z.string(),heading:e.z.string().optional(),paragraphs:e.z.array(e.z.string()),highlightedText:e.z.string().optional(),tickerSettings:L.optional(),cta:N.optional(),secondaryCta:U.optional(),newsletterSignup:oe.optional(),image:j.optional(),showReminderFields:te.optional(),separateArticleCount:O.optional(),maxViews:ee.optional(),showSignInLink:e.z.boolean().optional(),bylineWithImage:F.optional(),showChoiceCards:e.z.boolean().optional(),choiceCardsSettings:X.nullish(),choiceCardAmounts:ae.optional(),defaultChoiceCardFrequency:ne.optional()}),ie=e.z.object({variant:re,tracking:f,countryCode:e.z.string().nullish(),articleCounts:D,onReminderOpen:e.z.any().nullish(),fetchEmail:e.z.any().nullish(),submitComponentEvent:e.z.any().nullish(),openCmp:e.z.any().nullish(),hasConsentForArticleCount:e.z.boolean().nullish(),stage:e.z.string().nullish()}),se=e.z.enum(["contributions","subscriptions","signIn","abandonedBasket"]),le=e.z.object({heading:e.z.string().optional(),messageText:e.z.string().optional(),paragraphs:e.z.array(e.z.string()).optional(),mobileMessageText:e.z.string().optional(),highlightedText:e.z.string().optional(),cta:N.optional(),secondaryCta:U.optional()}),ue=e.z.object({tracking:f,bannerChannel:se,content:le.nullish(),mobileContent:le.nullish(),countryCode:e.z.string().nullish(),isSupporter:e.z.boolean().nullish(),tickerSettings:L.nullish(),submitComponentEvent:e.z.any(),articleCounts:D,hasOptedOutOfArticleCount:e.z.boolean().nullish(),fetchEmail:e.z.any().nullish(),separateArticleCount:e.z.boolean().nullish(),design:Z.nullish(),choiceCardsSettings:X.nullish()}),ce=e.z.object({heading:e.z.string(),subheading:e.z.string(),primaryCta:N.optional(),secondaryCta:N.optional(),benefits:e.z.array(e.z.string()).optional()}),de=e.z.object({content:ce,tracking:f,mobileContent:ce.optional(),countryCode:e.z.string().optional(),submitComponentEvent:e.z.any(),numArticles:e.z.number().optional()}),pe=e.z.object({image:j,bodyCopy:e.z.array(e.z.string()),cta:N.optional()});e.z.object({content:pe,tracking:f,countryCode:e.z.string().optional(),submitComponentEvent:e.z.any()});const ze=e.z.enum(["Contribution","SupporterPlus","GuardianWeekly","Paper"]),ge=e.z.enum(["new","guest","current"]),me=e.z.enum(["Epic","EpicAMP","EpicAppleNews","EpicLiveblog","Banner1","Banner2","Header","GutterLiveblog"]),be=e.z.enum(["Live","Draft","Archived"]),Ce=e.z.enum(["Mobile","Desktop","All","iOS","Android"]),Se=e.z.enum(["SignedIn","SignedOut","All"]),he=e.z.enum(["HasConsented","HasNotConsented","All"]),ye=e.z.object({name:e.z.literal("ABTest")}),Ae=e.z.object({name:e.z.literal("EpsilonGreedyBandit"),epsilon:e.z.number(),sampleCount:e.z.number().optional()}),Te=e.z.object({name:e.z.literal("Roulette"),sampleCount:e.z.number().optional()}),Ie=e.z.intersection(e.z.discriminatedUnion("name",[ye,Ae,Te]),e.z.object({testName:e.z.string().optional()})),Ne=e.z.object({channel:me,name:e.z.string(),status:be,priority:e.z.number(),controlProportionSettings:e.z.object({proportion:e.z.number(),offset:e.z.number()}).optional(),deviceType:Ce.optional(),signedInStatus:Se.optional(),consentStatus:he.optional(),methodologies:Ie.array().optional()}),Me=e.z.enum(["AllExistingSupporters","AllNonSupporters","Everyone","PostAskPauseSingleContributors"]),Ee=e.z.object({minViews:e.z.number(),maxViews:e.z.number().optional(),periodInWeeks:e.z.number(),tagIds:e.z.array(e.z.string()).optional()});e.z.object({userType:e.z.array(ge),product:e.z.array(ze)}),e.z.object({tagIds:e.z.array(e.z.string()),sectionIds:e.z.array(e.z.string()),excludedTagIds:e.z.array(e.z.string()),excludedSectionIds:e.z.array(e.z.string())});const Ge=e.z.object({maxViewsCount:e.z.number(),maxViewsDays:e.z.number(),minDaysBetweenViews:e.z.number()});Ne.extend({name:e.z.string(),status:be,locations:e.z.array(s).optional(),regionTargeting:l.optional(),tagIds:e.z.array(e.z.string()),sections:e.z.array(e.z.string()),excludedTagIds:e.z.array(e.z.string()),excludedSections:e.z.array(e.z.string()),alwaysAsk:e.z.boolean(),maxViews:Ge.optional(),userCohort:Me,hasCountryName:e.z.boolean(),highPriority:e.z.boolean(),useLocalViewLog:e.z.boolean(),articlesViewedSettings:Ee.optional(),priority:e.z.number(),variants:re.array()});const Ue=e.z.object({amount:e.z.union([e.z.number(),e.z.literal("other")]),billingPeriod:e.z.union([e.z.literal("ONE_OFF"),e.z.literal("MONTHLY"),e.z.literal("ANNUAL")]),product:e.z.union([e.z.literal("Contribution"),e.z.literal("SupporterPlus"),e.z.literal("PremiumTier"),e.z.literal("DailyEdition"),e.z.literal("GuardianWeekly"),e.z.literal("Paper"),e.z.literal("PaperAndDigital")]),region:e.z.union([e.z.literal("uk"),e.z.literal("us"),e.z.literal("au"),e.z.literal("eu"),e.z.literal("int"),e.z.literal("nz"),e.z.literal("ca")])}),Re=(e,t,n)=>{const a=(e=>{if(URLSearchParams){const t=new URLSearchParams(window.location.search).get(`force-${e}`);if(t)return t}return null})(e);return fetch(`${t}/${e}${a?`?force=${a}`:""}`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).then((t=>{if(!t.ok)throw Error(t.statusText||`Supporter Revenue ${e} | Api call returned HTTP status ${t.status}`);return t})).then((e=>e.json()))};exports.CountryGroupId=i,exports.SecondaryCtaType=M,exports.abandonedBasketSchema=Ue,exports.addRegionIdToSupportUrl=(e,t)=>{if(t){const n=(e=>u[p(e)].supportRegionId)(t);if(n&&!m(e))return e.replace(/(support\.theguardian\.com)\/(contribute-in-epic|contribute|subscribe|checkout)/,((e,t,a)=>`${t}/${n.toLowerCase()}/${a}`))}return e},exports.bannerSchema=ue,exports.buildReminderFields=A,exports.containsNonArticleCountPlaceholder=e=>{const t=e.match(S)?.filter((e=>"%%ARTICLE_COUNT%%"!==e));return!!t&&t.length>0},exports.contributionTabFrequencies=["ONE_OFF","MONTHLY","ANNUAL"],exports.countryCodeToCountryGroupId=p,exports.countryGroupIdSchema=s,exports.countryGroups=u,exports.epicPropsSchema=ie,exports.getBanner=(e,t)=>Re("banner",e,t),exports.getCountryName=g,exports.getEpic=(e,t)=>Re("epic",e,t),exports.getEpicViewLog=e=>e.get(h)||void 0,exports.getGutterLiveblog=(e,t)=>Re("gutter-liveblog",e,t),exports.getHeader=(e,t)=>Re("header",e,t),exports.getLiveblogEpic=(e,t)=>Re("liveblog-epic",e,t),exports.getLocalCurrencySymbol=z,exports.getReminderFields=(e,t=new Date)=>{return"US"===e&&I(t)?{reminderCta:"Remind me on Giving Tuesday",reminderPeriod:`${n=t.getFullYear()}-${(y(n).getMonth()+1).toString().padStart(0,"2")}-01`,reminderLabel:"on Giving Tuesday",reminderOption:`giving-tuesday-${n}`}:"US"===e&&(e=>e>=y(e.getFullYear())&&e<T)(t)?(e=>({reminderCta:"Remind me on New Years Eve",reminderPeriod:`${e}-12-01`,reminderLabel:"on New Years Eve",reminderOption:`new-years-eve-${e}`}))(t.getFullYear()):A(t);var n},exports.getWeeklyArticleHistory=e=>e.get(t)||void 0,exports.headerPropsSchema=de,exports.hexColourToString=e=>`#${e.r}${e.g}${e.b}`,exports.inTargetedCountry=(e,t=[],n=[])=>0===t.length&&0===n.length||!!e&&(!!t.includes(p(e.toUpperCase()))||n.includes(e.toUpperCase())),exports.incrementWeeklyArticleCount=(e,o,i)=>{const s=((e,t)=>{const o=a(new Date),r=e.get(n);if(r&&r.week===o){const a=r.articles[t]||0;return e.set(n,{week:o,articles:{...r.articles,[t]:a+1}}),a>0}return e.set(n,{week:o,articles:{[t]:1}}),!1})(e,o);if(!s){const n=a(new Date),o=e.get(t)||[],s=o[0];if(s?.week&&s.week===n)s.count+=1,s.tags=r(i,s.tags),e.set(t,o);else{o.unshift({week:n,count:1,tags:r(i,{})});const a=n-365,s=o.filter((e=>e.week>=a));e.set(t,s)}}},exports.isGWCheckoutUrl=m,exports.isoCurrencyToCurrencySymbol={GBP:"£",USD:"$",AUD:"$",EUR:"€",NZD:"NZ$",CAD:"CA$"},exports.logEpicView=e=>{const t=localStorage.getItem(h),n=t?JSON.parse(t).value:[];n.push({date:(new Date).getTime(),testId:e});const a={value:n.slice(-50)};localStorage.setItem(h,JSON.stringify(a))},exports.replaceNonArticleCountPlaceholders=(e,t,n)=>e?e.replace(S,(e=>{const a=e.substring(2,e.length-2),o=C[a];if(o){const e=o({countryCode:t,prices:n});if(e)return e}return e})):"",exports.targetedRegionsSchema=l;
|
|
@@ -2,8 +2,9 @@ import { Router } from 'express';
|
|
|
2
2
|
import type { AmountsTests, BannerDesignFromTool, BannerTest, Prices } from '../../shared/types';
|
|
3
3
|
import type { ChannelSwitches } from '../channelSwitches';
|
|
4
4
|
import type { TickerDataProvider } from '../lib/fetchTickerData';
|
|
5
|
+
import type { ProductCatalog } from '../productCatalog';
|
|
5
6
|
import type { BanditData } from '../selection/banditData';
|
|
6
7
|
import type { BannerDeployTimesProvider } from '../tests/banners/bannerDeployTimes';
|
|
7
8
|
import type { ValueProvider } from '../utils/valueReloader';
|
|
8
|
-
export declare const buildBannerRouter: (channelSwitches: ValueProvider<ChannelSwitches>, tickerData: TickerDataProvider, productPrices: ValueProvider<Prices | undefined>, bannerTests: ValueProvider<BannerTest[]>, bannerDeployTimes: BannerDeployTimesProvider, choiceCardAmounts: ValueProvider<AmountsTests>, bannerDesigns: ValueProvider<BannerDesignFromTool[]>, banditData: ValueProvider<BanditData[]>) => Router;
|
|
9
|
+
export declare const buildBannerRouter: (channelSwitches: ValueProvider<ChannelSwitches>, tickerData: TickerDataProvider, productPrices: ValueProvider<Prices | undefined>, bannerTests: ValueProvider<BannerTest[]>, bannerDeployTimes: BannerDeployTimesProvider, choiceCardAmounts: ValueProvider<AmountsTests>, bannerDesigns: ValueProvider<BannerDesignFromTool[]>, banditData: ValueProvider<BanditData[]>, productCatalog: ValueProvider<ProductCatalog>) => Router;
|
|
9
10
|
//# sourceMappingURL=bannerRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bannerRouter.d.ts","sourceRoot":"","sources":["../../../src/server/api/bannerRouter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,KAAK,EACR,YAAY,EACZ,oBAAoB,EAGpB,UAAU,EACV,MAAM,EAGT,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"bannerRouter.d.ts","sourceRoot":"","sources":["../../../src/server/api/bannerRouter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,KAAK,EACR,YAAY,EACZ,oBAAoB,EAGpB,UAAU,EACV,MAAM,EAGT,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAI1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAKjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAIpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAa5D,eAAO,MAAM,iBAAiB,oBACT,aAAa,CAAC,eAAe,CAAC,cACnC,kBAAkB,iBACf,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC,eACnC,aAAa,CAAC,UAAU,EAAE,CAAC,qBACrB,yBAAyB,qBACzB,aAAa,CAAC,YAAY,CAAC,iBAC/B,aAAa,CAAC,oBAAoB,EAAE,CAAC,cACxC,aAAa,CAAC,UAAU,EAAE,CAAC,kBACvB,aAAa,CAAC,cAAc,CAAC,KAC9C,MA0IF,CAAC"}
|
|
@@ -3,7 +3,8 @@ import type { AmountsTests, EpicTest } from '../../shared/types';
|
|
|
3
3
|
import type { ChannelSwitches } from '../channelSwitches';
|
|
4
4
|
import type { TickerDataProvider } from '../lib/fetchTickerData';
|
|
5
5
|
import type { SuperModeArticle } from '../lib/superMode';
|
|
6
|
+
import type { ProductCatalog } from '../productCatalog';
|
|
6
7
|
import type { BanditData } from '../selection/banditData';
|
|
7
8
|
import type { ValueProvider } from '../utils/valueReloader';
|
|
8
|
-
export declare const buildEpicRouter: (channelSwitches: ValueProvider<ChannelSwitches>, superModeArticles: ValueProvider<SuperModeArticle[]>, articleEpicTests: ValueProvider<EpicTest[]>, liveblogEpicTests: ValueProvider<EpicTest[]>, choiceCardAmounts: ValueProvider<AmountsTests>, tickerData: TickerDataProvider, banditData: ValueProvider<BanditData[]>) => Router;
|
|
9
|
+
export declare const buildEpicRouter: (channelSwitches: ValueProvider<ChannelSwitches>, superModeArticles: ValueProvider<SuperModeArticle[]>, articleEpicTests: ValueProvider<EpicTest[]>, liveblogEpicTests: ValueProvider<EpicTest[]>, choiceCardAmounts: ValueProvider<AmountsTests>, tickerData: TickerDataProvider, banditData: ValueProvider<BanditData[]>, productCatalog: ValueProvider<ProductCatalog>) => Router;
|
|
9
10
|
//# sourceMappingURL=epicRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epicRouter.d.ts","sourceRoot":"","sources":["../../../src/server/api/epicRouter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,KAAK,EACR,YAAY,EAGZ,QAAQ,EAMX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"epicRouter.d.ts","sourceRoot":"","sources":["../../../src/server/api/epicRouter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,KAAK,EACR,YAAY,EAGZ,QAAQ,EAMX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAI1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAIjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAI1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAiB5D,eAAO,MAAM,eAAe,oBACP,aAAa,CAAC,eAAe,CAAC,qBAC5B,aAAa,CAAC,gBAAgB,EAAE,CAAC,oBAClC,aAAa,CAAC,QAAQ,EAAE,CAAC,qBACxB,aAAa,CAAC,QAAQ,EAAE,CAAC,qBACzB,aAAa,CAAC,YAAY,CAAC,cAClC,kBAAkB,cAClB,aAAa,CAAC,UAAU,EAAE,CAAC,kBACvB,aAAa,CAAC,cAAc,CAAC,KAC9C,MAiMF,CAAC"}
|
|
@@ -34,8 +34,8 @@ declare const _default: Factory<{
|
|
|
34
34
|
successDescription: string;
|
|
35
35
|
} | undefined;
|
|
36
36
|
image?: {
|
|
37
|
-
mainUrl: string;
|
|
38
37
|
altText: string;
|
|
38
|
+
mainUrl: string;
|
|
39
39
|
mobileUrl?: string | undefined;
|
|
40
40
|
tabletUrl?: string | undefined;
|
|
41
41
|
desktopUrl?: string | undefined;
|
|
@@ -62,8 +62,8 @@ declare const _default: Factory<{
|
|
|
62
62
|
name: string;
|
|
63
63
|
description?: string | undefined;
|
|
64
64
|
headshot?: {
|
|
65
|
-
mainUrl: string;
|
|
66
65
|
altText: string;
|
|
66
|
+
mainUrl: string;
|
|
67
67
|
mobileUrl?: string | undefined;
|
|
68
68
|
tabletUrl?: string | undefined;
|
|
69
69
|
desktopUrl?: string | undefined;
|
|
@@ -72,6 +72,72 @@ declare const _default: Factory<{
|
|
|
72
72
|
} | undefined;
|
|
73
73
|
} | undefined;
|
|
74
74
|
showChoiceCards?: boolean | undefined;
|
|
75
|
+
choiceCardsSettings?: {
|
|
76
|
+
choiceCards: {
|
|
77
|
+
product: {
|
|
78
|
+
supportTier: "Contribution";
|
|
79
|
+
ratePlan: "Monthly" | "Annual";
|
|
80
|
+
} | {
|
|
81
|
+
supportTier: "SupporterPlus";
|
|
82
|
+
ratePlan: "Monthly" | "Annual";
|
|
83
|
+
} | {
|
|
84
|
+
supportTier: "OneOff";
|
|
85
|
+
};
|
|
86
|
+
label: string;
|
|
87
|
+
isDefault: boolean;
|
|
88
|
+
benefits: {
|
|
89
|
+
copy: string;
|
|
90
|
+
}[];
|
|
91
|
+
benefitsLabel?: string | null | undefined;
|
|
92
|
+
pill?: {
|
|
93
|
+
copy: string;
|
|
94
|
+
textColour?: {
|
|
95
|
+
r: string;
|
|
96
|
+
b: string;
|
|
97
|
+
g: string;
|
|
98
|
+
kind: "hex";
|
|
99
|
+
} | null | undefined;
|
|
100
|
+
backgroundColour?: {
|
|
101
|
+
r: string;
|
|
102
|
+
b: string;
|
|
103
|
+
g: string;
|
|
104
|
+
kind: "hex";
|
|
105
|
+
} | null | undefined;
|
|
106
|
+
} | null | undefined;
|
|
107
|
+
}[];
|
|
108
|
+
mobileChoiceCards?: {
|
|
109
|
+
product: {
|
|
110
|
+
supportTier: "Contribution";
|
|
111
|
+
ratePlan: "Monthly" | "Annual";
|
|
112
|
+
} | {
|
|
113
|
+
supportTier: "SupporterPlus";
|
|
114
|
+
ratePlan: "Monthly" | "Annual";
|
|
115
|
+
} | {
|
|
116
|
+
supportTier: "OneOff";
|
|
117
|
+
};
|
|
118
|
+
label: string;
|
|
119
|
+
isDefault: boolean;
|
|
120
|
+
benefits: {
|
|
121
|
+
copy: string;
|
|
122
|
+
}[];
|
|
123
|
+
benefitsLabel?: string | null | undefined;
|
|
124
|
+
pill?: {
|
|
125
|
+
copy: string;
|
|
126
|
+
textColour?: {
|
|
127
|
+
r: string;
|
|
128
|
+
b: string;
|
|
129
|
+
g: string;
|
|
130
|
+
kind: "hex";
|
|
131
|
+
} | null | undefined;
|
|
132
|
+
backgroundColour?: {
|
|
133
|
+
r: string;
|
|
134
|
+
b: string;
|
|
135
|
+
g: string;
|
|
136
|
+
kind: "hex";
|
|
137
|
+
} | null | undefined;
|
|
138
|
+
} | null | undefined;
|
|
139
|
+
}[] | null | undefined;
|
|
140
|
+
} | null | undefined;
|
|
75
141
|
choiceCardAmounts?: {
|
|
76
142
|
testName: string;
|
|
77
143
|
variantName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epicVariant.d.ts","sourceRoot":"","sources":["../../../src/server/factories/epicVariant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC
|
|
1
|
+
{"version":3,"file":"epicVariant.d.ts","sourceRoot":"","sources":["../../../src/server/factories/epicVariant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGlC,wBAoBI"}
|
|
@@ -36,8 +36,8 @@ export declare const factories: {
|
|
|
36
36
|
successDescription: string;
|
|
37
37
|
} | undefined;
|
|
38
38
|
image?: {
|
|
39
|
-
mainUrl: string;
|
|
40
39
|
altText: string;
|
|
40
|
+
mainUrl: string;
|
|
41
41
|
mobileUrl?: string | undefined;
|
|
42
42
|
tabletUrl?: string | undefined;
|
|
43
43
|
desktopUrl?: string | undefined;
|
|
@@ -64,8 +64,8 @@ export declare const factories: {
|
|
|
64
64
|
name: string;
|
|
65
65
|
description?: string | undefined;
|
|
66
66
|
headshot?: {
|
|
67
|
-
mainUrl: string;
|
|
68
67
|
altText: string;
|
|
68
|
+
mainUrl: string;
|
|
69
69
|
mobileUrl?: string | undefined;
|
|
70
70
|
tabletUrl?: string | undefined;
|
|
71
71
|
desktopUrl?: string | undefined;
|
|
@@ -74,6 +74,72 @@ export declare const factories: {
|
|
|
74
74
|
} | undefined;
|
|
75
75
|
} | undefined;
|
|
76
76
|
showChoiceCards?: boolean | undefined;
|
|
77
|
+
choiceCardsSettings?: {
|
|
78
|
+
choiceCards: {
|
|
79
|
+
product: {
|
|
80
|
+
supportTier: "Contribution";
|
|
81
|
+
ratePlan: "Monthly" | "Annual";
|
|
82
|
+
} | {
|
|
83
|
+
supportTier: "SupporterPlus";
|
|
84
|
+
ratePlan: "Monthly" | "Annual";
|
|
85
|
+
} | {
|
|
86
|
+
supportTier: "OneOff";
|
|
87
|
+
};
|
|
88
|
+
label: string;
|
|
89
|
+
isDefault: boolean;
|
|
90
|
+
benefits: {
|
|
91
|
+
copy: string;
|
|
92
|
+
}[];
|
|
93
|
+
benefitsLabel?: string | null | undefined;
|
|
94
|
+
pill?: {
|
|
95
|
+
copy: string;
|
|
96
|
+
textColour?: {
|
|
97
|
+
r: string;
|
|
98
|
+
b: string;
|
|
99
|
+
g: string;
|
|
100
|
+
kind: "hex";
|
|
101
|
+
} | null | undefined;
|
|
102
|
+
backgroundColour?: {
|
|
103
|
+
r: string;
|
|
104
|
+
b: string;
|
|
105
|
+
g: string;
|
|
106
|
+
kind: "hex";
|
|
107
|
+
} | null | undefined;
|
|
108
|
+
} | null | undefined;
|
|
109
|
+
}[];
|
|
110
|
+
mobileChoiceCards?: {
|
|
111
|
+
product: {
|
|
112
|
+
supportTier: "Contribution";
|
|
113
|
+
ratePlan: "Monthly" | "Annual";
|
|
114
|
+
} | {
|
|
115
|
+
supportTier: "SupporterPlus";
|
|
116
|
+
ratePlan: "Monthly" | "Annual";
|
|
117
|
+
} | {
|
|
118
|
+
supportTier: "OneOff";
|
|
119
|
+
};
|
|
120
|
+
label: string;
|
|
121
|
+
isDefault: boolean;
|
|
122
|
+
benefits: {
|
|
123
|
+
copy: string;
|
|
124
|
+
}[];
|
|
125
|
+
benefitsLabel?: string | null | undefined;
|
|
126
|
+
pill?: {
|
|
127
|
+
copy: string;
|
|
128
|
+
textColour?: {
|
|
129
|
+
r: string;
|
|
130
|
+
b: string;
|
|
131
|
+
g: string;
|
|
132
|
+
kind: "hex";
|
|
133
|
+
} | null | undefined;
|
|
134
|
+
backgroundColour?: {
|
|
135
|
+
r: string;
|
|
136
|
+
b: string;
|
|
137
|
+
g: string;
|
|
138
|
+
kind: "hex";
|
|
139
|
+
} | null | undefined;
|
|
140
|
+
} | null | undefined;
|
|
141
|
+
}[] | null | undefined;
|
|
142
|
+
} | null | undefined;
|
|
77
143
|
choiceCardAmounts?: {
|
|
78
144
|
testName: string;
|
|
79
145
|
variantName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/factories/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/factories/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMpB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CountryGroupId } from '../../../shared/lib';
|
|
2
|
+
import type { Channel } from '../../../shared/types';
|
|
3
|
+
import type { ChoiceCardsSettings } from '../../../shared/types/props/choiceCards';
|
|
4
|
+
import type { ProductCatalog } from '../../productCatalog';
|
|
5
|
+
export declare const getChoiceCardsSettings: (countryGroupId: CountryGroupId, channel: Channel, productCatalog: ProductCatalog, variantChoiceCardSettings?: ChoiceCardsSettings) => ChoiceCardsSettings | undefined;
|
|
6
|
+
//# sourceMappingURL=choiceCards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choiceCards.d.ts","sourceRoot":"","sources":["../../../../src/server/lib/choiceCards/choiceCards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,qBAAqB,CAAC;AAEvE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAER,mBAAmB,EAEtB,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAkD3D,eAAO,MAAM,sBAAsB,mBACf,cAAc,WACrB,OAAO,kBACA,cAAc,8BACF,mBAAmB,KAChD,mBAAmB,GAAG,SA4BxB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CountryGroupId } from '../../../shared/lib';
|
|
2
|
+
import type { ChoiceCardsSettings } from '../../../shared/types/props/choiceCards';
|
|
3
|
+
declare const currencySymbolTemplate = "%%CURRENCY_SYMBOL%%";
|
|
4
|
+
declare const defaultEpicChoiceCardsSettings: (countryGroupId: CountryGroupId) => ChoiceCardsSettings;
|
|
5
|
+
declare const defaultBannerChoiceCardsSettings: (countryGroupId: CountryGroupId) => ChoiceCardsSettings;
|
|
6
|
+
export { currencySymbolTemplate, defaultEpicChoiceCardsSettings, defaultBannerChoiceCardsSettings };
|
|
7
|
+
//# sourceMappingURL=defaultChoiceCardSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultChoiceCardSettings.d.ts","sourceRoot":"","sources":["../../../../src/server/lib/choiceCards/defaultChoiceCardSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAc,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE/F,QAAA,MAAM,sBAAsB,wBAAwB,CAAC;AA4FrD,QAAA,MAAM,8BAA8B,mBAAoB,cAAc,KAAG,mBAGvE,CAAC;AAEH,QAAA,MAAM,gCAAgC,mBAAoB,cAAc,KAAG,mBAGzE,CAAC;AAEH,OAAO,EAAE,sBAAsB,EAAE,8BAA8B,EAAE,gCAAgC,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IsoCurrency } from '../shared/lib';
|
|
2
|
+
import type { ValueReloader } from './utils/valueReloader';
|
|
3
|
+
type RatePlan = 'Monthly' | 'Annual';
|
|
4
|
+
interface ProductRatePlan {
|
|
5
|
+
pricing: Record<IsoCurrency, number>;
|
|
6
|
+
}
|
|
7
|
+
interface Product {
|
|
8
|
+
ratePlans: Record<RatePlan, ProductRatePlan>;
|
|
9
|
+
}
|
|
10
|
+
type ProductName = 'Contribution' | 'SupporterPlus';
|
|
11
|
+
export type ProductCatalog = Record<ProductName, Product>;
|
|
12
|
+
declare const buildProductCatalogReloader: () => Promise<ValueReloader<ProductCatalog>>;
|
|
13
|
+
export { buildProductCatalogReloader };
|
|
14
|
+
//# sourceMappingURL=productCatalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productCatalog.d.ts","sourceRoot":"","sources":["../../src/server/productCatalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,KAAK,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;AAErC,UAAU,eAAe;IACrB,OAAO,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;CACxC;AAED,UAAU,OAAO;IACb,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;CAChD;AAED,KAAK,WAAW,GAAG,cAAc,GAAG,eAAe,CAAC;AAEpD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAe1D,QAAA,MAAM,2BAA2B,QAAO,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CACnC,CAAC;AAE3C,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channelBannerTests.d.ts","sourceRoot":"","sources":["../../../../src/server/tests/banners/channelBannerTests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EACR,aAAa,EACb,oBAAoB,EAGpB,mBAAmB,EACnB,aAAa,EAEb,kBAAkB,EACrB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"channelBannerTests.d.ts","sourceRoot":"","sources":["../../../../src/server/tests/banners/channelBannerTests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EACR,aAAa,EACb,oBAAoB,EAGpB,mBAAmB,EACnB,aAAa,EAEb,kBAAkB,EACrB,MAAM,uBAAuB,CAAC;AAK/B,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAKlF,CAAC;AAEF,eAAO,MAAM,mBAAmB,YACnB,aAAa,WACb,oBAAoB,EAAE,KAChC,kBAAkB,GAAG,SAMvB,CAAC;AAwBF,eAAO,MAAM,gCAAgC,qBAAkD,CAAC;AAChG,eAAO,MAAM,gCAAgC,qBAAkD,CAAC"}
|
|
@@ -13,16 +13,17 @@ export declare const targetedRegionsSchema: z.ZodOptional<z.ZodObject<{
|
|
|
13
13
|
targetedCountryCodes?: string[] | undefined;
|
|
14
14
|
}>>;
|
|
15
15
|
export type SupportRegionId = 'UK' | 'US' | 'AU' | 'EU' | 'INT' | 'NZ' | 'CA';
|
|
16
|
-
type IsoCurrency = 'GBP' | 'USD' | 'AUD' | 'EUR' | 'NZD' | 'CAD';
|
|
17
|
-
type CountryGroup = {
|
|
16
|
+
export type IsoCurrency = 'GBP' | 'USD' | 'AUD' | 'EUR' | 'NZD' | 'CAD';
|
|
17
|
+
export type CountryGroup = {
|
|
18
18
|
name: string;
|
|
19
19
|
currency: IsoCurrency;
|
|
20
20
|
countries: string[];
|
|
21
21
|
supportRegionId: SupportRegionId;
|
|
22
22
|
};
|
|
23
23
|
type CountryGroups = Record<CountryGroupId, CountryGroup>;
|
|
24
|
-
declare const countryGroups: CountryGroups;
|
|
24
|
+
export declare const countryGroups: CountryGroups;
|
|
25
25
|
export type Region = keyof typeof countryGroups;
|
|
26
|
+
export declare const isoCurrencyToCurrencySymbol: Record<IsoCurrency, string>;
|
|
26
27
|
export declare const countryCodeToCountryGroupId: (countryCode?: string) => CountryGroupId;
|
|
27
28
|
export declare const inTargetedCountry: (countryCodeFromPayload?: string, countryGroups?: CountryGroupId[], countryCodes?: string[]) => boolean;
|
|
28
29
|
export declare const getLocalCurrencySymbol: (geolocation?: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geolocation.d.ts","sourceRoot":"","sources":["../../../src/shared/lib/geolocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc,sHAQjB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,eAAO,MAAM,oBAAoB,wHAAyB,CAAC;AAE3D,eAAO,MAAM,qBAAqB;;;;;;;;;GAKnB,CAAC;AAGhB,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9E,
|
|
1
|
+
{"version":3,"file":"geolocation.d.ts","sourceRoot":"","sources":["../../../src/shared/lib/geolocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc,sHAQjB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,eAAO,MAAM,oBAAoB,wHAAyB,CAAC;AAE3D,eAAO,MAAM,qBAAqB;;;;;;;;;GAKnB,CAAC;AAGhB,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9E,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAExE,MAAM,MAAM,YAAY,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,WAAW,CAAC;IACtB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,eAAe,EAAE,eAAe,CAAC;CACpC,CAAC;AAEF,KAAK,aAAa,GAAG,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;AAE1D,eAAO,MAAM,aAAa,EAAE,aAsR3B,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,OAAO,aAAa,CAAC;AAsPhD,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAOnE,CAAC;AAEF,eAAO,MAAM,2BAA2B,iBAAkB,MAAM,KAAG,cAOlE,CAAC;AAEF,eAAO,MAAM,iBAAiB,4BACD,MAAM,kBAChB,cAAc,EAAE,iBACjB,MAAM,EAAE,KACvB,OAiBF,CAAC;AAQF,eAAO,MAAM,sBAAsB,iBAAkB,MAAM,KAAG,MAO7D,CAAC;AAEF,eAAO,MAAM,cAAc,iBAAkB,MAAM,KAAG,MAAM,GAAG,SAM9D,CAAC;AAKF,eAAO,MAAM,eAAe,YAAa,MAAM,KAAG,OACD,CAAC;AAElD,eAAO,MAAM,uBAAuB,gBAAiB,MAAM,gBAAgB,MAAM,KAAG,MAYnF,CAAC"}
|