@guardian/support-dotcom-components 7.6.0 → 7.6.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/dotcom/requests.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/dotcom/requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,aAAa,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,EACX,aAAa,EACb,WAAW,EACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE,MAAM,WAAW,UAAU,CAAC,KAAK;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB,CAAC,KAAK;IACrC,IAAI,CAAC,EAAE;QACH,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,EAAE,YAAY,CAAC;KACtB,CAAC;CACL;AAqCD,eAAO,MAAM,OAAO,YACP,MAAM,WACN,WAAW,KACrB,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAA4C,CAAC;AAErF,eAAO,MAAM,eAAe,YACf,MAAM,WACN,WAAW,KACrB,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAqD,CAAC;AAE9F,eAAO,MAAM,SAAS,YACT,MAAM,WACN,aAAa,KACvB,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAA8C,CAAC;AAEzF,eAAO,MAAM,iBAAiB,YACjB,MAAM,WACN,aAAa,KACvB,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAuD,CAAC;AAElG,eAAO,MAAM,SAAS,YACT,MAAM,WACN,aAAa,KACvB,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAA8C,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";import{URLSearchParams as n}from"url";const t="gu.history.weeklyArticleCount",a="gu.history.articleCountsThisWeek",i=e=>{const n=e.getDay()||7;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()-(n-1))/864e5},o=e=>e.get(t)||void 0,r=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"]),s=(e,n={})=>(e.forEach((e=>{r.has(e)&&(n[e]=(n[e]??0)+1)})),n),l=(e,n,o)=>{const r=((e,n)=>{const t=i(new Date),o=e.get(a);if(o&&o.week===t){const i=o.articles[n]||0;return e.set(a,{week:t,articles:{...o.articles,[n]:i+1}}),i>0}return e.set(a,{week:t,articles:{[n]:1}}),!1})(e,n);if(!r){const n=i(new Date),a=e.get(t)||[],r=a[0];if(r?.week&&r.week===n)r.count+=1,r.tags=s(o,r.tags),e.set(t,a);else{a.unshift({week:n,count:1,tags:s(o,{})});const i=n-365,r=a.filter((e=>e.week>=i));e.set(t,r)}}},u=["GBPCountries","UnitedStates","AUDCountries","EURCountries","International","NZDCountries","Canada"],c=e.enum(u),d=e.object({targetedCountryGroups:e.array(c),targetedCountryCodes:e.array(e.string()).optional()}).optional(),g={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"}},p={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:"$"},b={GBP:"£",USD:"$",AUD:"$",EUR:"€",NZD:"NZ$",CAD:"CA$"},C=e=>Object.keys(g).find((n=>g[n].countries.includes(e??"")))||"International",h=(e,n=[],t=[])=>0===n.length&&0===t.length||!!e&&(!!n.includes(C(e.toUpperCase()))||t.includes(e.toUpperCase())),S=e=>{if(e){const n=C(e);return m[n]}return"£"},y=e=>{if(e)return p[e]},A=e=>e.includes("subscribe/weekly/checkout"),T=(e,n)=>{if(n){const t=(e=>g[C(e)].supportRegionId)(n);if(t&&!A(e))return e.replace(/(support\.theguardian\.com)\/(contribute-in-epic|contribute|subscribe|checkout)/,((e,n,a)=>`${n}/${t.toLowerCase()}/${a}`))}return e},I=(e,n,t,a)=>{if(a){const i=a[C(t)];if(i){return`${S(t)}${i[e][n].price}`}}},N={CURRENCY_SYMBOL:({countryCode:e})=>S(e),COUNTRY_NAME:({countryCode:e})=>y(e),PRICE_DIGISUB_MONTHLY:({countryCode:e,prices:n})=>I("Digisub","Monthly",e,n),PRICE_DIGISUB_ANNUAL:({countryCode:e,prices:n})=>I("Digisub","Annual",e,n),PRICE_GUARDIANWEEKLY_MONTHLY:({countryCode:e,prices:n})=>I("GuardianWeekly","Monthly",e,n),PRICE_GUARDIANWEEKLY_ANNUAL:({countryCode:e,prices:n})=>I("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"}))()},M=(e,n,t)=>e?e.replace(E,(e=>{const a=e.substring(2,e.length-2),i=N[a];if(i){const e=i({countryCode:n,prices:t});if(e)return e}return e})):"",E=/%%.*?%%/g,G=e=>{const n=e.match(E)?.filter((e=>"%%ARTICLE_COUNT%%"!==e));return!!n&&n.length>0},U="gu.contributions.views",B=e=>e.get(U)||void 0,R=e=>{const n=localStorage.getItem(U),t=n?JSON.parse(n).value:[];t.push({date:(new Date).getTime(),testId:e});const a={value:t.slice(-50)};localStorage.setItem(U,JSON.stringify(a))},D=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}`}},L=new Date("2023-12-31"),w=e=>e>=(e=>new Date(e.getFullYear(),9,20))(e)&&e<D(e.getFullYear()),O=(e,n=new Date)=>{return"US"===e&&w(n)?{reminderCta:"Remind me on Giving Tuesday",reminderPeriod:`${t=n.getFullYear()}-${(D(t).getMonth()+1).toString().padStart(0,"2")}-01`,reminderLabel:"on Giving Tuesday",reminderOption:`giving-tuesday-${t}`}:"US"===e&&(e=>e>=D(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()):P(n);var t},k=e.object({text:e.string(),baseUrl:e.string()});let f=function(e){return e.Custom="CustomSecondaryCta",e.ContributionsReminder="ContributionsReminderSecondaryCta",e}({});e.nativeEnum(f);const j=e.object({type:e.literal(f.Custom),cta:k}),K=e.object({type:e.literal(f.ContributionsReminder)}),F=e.discriminatedUnion("type",[j,K]),v=e.object({countLabel:e.string(),goalCopy:e.string().optional()}),H=e.object({total:e.number(),goal:e.number()}),Y=e.enum(["US","AU","global"]),V=e.object({currencySymbol:e.string(),copy:v,name:Y,tickerData:H.optional()}),W=e.object({for52Weeks:e.number(),forTargetedWeeks:e.number()}),Z=e.enum(["for52Weeks","forTargetedWeeks"]),$=e.object({type:e.literal("above"),copy:e.string().optional(),countType:Z.optional()}),x=e.enum(["CONTRIBUTION","MEMBERSHIP_SUPPORTER","DIGITAL_SUBSCRIPTION","PRINT_SUBSCRIPTION"]),_=e.enum(["ACQUISITIONS_EPIC","ACQUISITIONS_ENGAGEMENT_BANNER","ACQUISITIONS_SUBSCRIPTIONS_BANNER","ACQUISITIONS_HEADER","ACQUISITIONS_OTHER"]),J=e.object({abTestName:e.string(),abTestVariant:e.string(),campaignCode:e.string(),componentType:_,products:e.array(x).nullish(),labels:e.array(e.string()).nullish(),ophanPageId:e.string(),platformId:e.string(),referrerUrl:e.string()}),Q=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()}),z=e.object({name:e.string(),description:e.string().optional(),headshot:Q.optional()}),q=/^[0-9A-F]{2}$/,X=e.string().refine((e=>q.test(e)),(e=>({message:`"${e}" is not a valid hex value`}))),ee=e.object({r:X,g:X,b:X,kind:e.literal("hex")}),ne=e.object({mobileUrl:e.string(),tabletUrl:e.string(),desktopUrl:e.string(),altText:e.string(),kind:e.literal("Image")}),te=e.object({buttonColour:ee.nullish(),buttonTextColour:ee.nullish(),buttonBorderColour:ee.nullish(),buttonSelectColour:ee.nullish(),buttonSelectTextColour:ee.nullish(),buttonSelectBorderColour:ee.nullish(),kind:e.literal("ChoiceCards")}),ae=e.discriminatedUnion("kind",[ne,te]),ie=e.object({visual:ae.nullish(),colours:e.object({basic:e.object({background:ee,bodyText:ee})})}),oe=e=>`#${e.r}${e.g}${e.b}`,re=e.object({copy:e.string()}),se=e.union([e.literal("Monthly"),e.literal("Annual")]),le=e.discriminatedUnion("supportTier",[e.object({supportTier:e.literal("Contribution"),ratePlan:se}),e.object({supportTier:e.literal("SupporterPlus"),ratePlan:se}),e.object({supportTier:e.literal("OneOff")})]),ue=e.object({copy:e.string(),textColour:ee.nullish(),backgroundColour:ee.nullish()}),ce=e.object({product:le,label:e.string(),isDefault:e.boolean(),benefitsLabel:e.string().nullish(),benefits:e.array(re),pill:ue.nullish(),destinationUrl:e.string().nullish()}),de=e.object({choiceCards:e.array(ce),mobileChoiceCards:e.array(ce).nullish()}),ge=e.object({maxViewsCount:e.number(),maxViewsDays:e.number(),minDaysBetweenViews:e.number()}),pe=e.object({reminderCta:e.string(),reminderLabel:e.string(),reminderPeriod:e.string()}),me=e.enum(["ONE_OFF","MONTHLY","ANNUAL"]),be=e.object({testName:e.string(),variantName:e.string(),defaultContributionType:me,displayContributionType:me.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()})})}),Ce=e.object({newsletterId:e.string(),successDescription:e.string()}),he=e.object({name:e.string(),heading:e.string().optional(),paragraphs:e.array(e.string()),highlightedText:e.string().optional(),tickerSettings:V.optional(),cta:k.optional(),secondaryCta:F.optional(),newsletterSignup:Ce.optional(),image:Q.optional(),showReminderFields:pe.optional(),separateArticleCount:$.optional(),promoCodes:e.array(e.string()).nullish(),maxViews:ge.optional(),showSignInLink:e.boolean().optional(),bylineWithImage:z.optional(),showChoiceCards:e.boolean().optional(),choiceCardsSettings:de.nullish(),choiceCardAmounts:be.optional(),defaultChoiceCardFrequency:me.optional()}),Se=e.object({variant:he,tracking:J,countryCode:e.string().nullish(),articleCounts:W,onReminderOpen:e.any().nullish(),fetchEmail:e.any().nullish(),submitComponentEvent:e.any().nullish(),openCmp:e.any().nullish(),hasConsentForArticleCount:e.boolean().nullish(),stage:e.string().nullish()}),ye=e.enum(["contributions","subscriptions","signIn","abandonedBasket"]),Ae=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:k.optional(),secondaryCta:F.optional()}),Te=e.object({tracking:J,bannerChannel:ye,content:Ae.nullish(),mobileContent:Ae.nullish(),countryCode:e.string().nullish(),isSupporter:e.boolean().nullish(),tickerSettings:V.nullish(),submitComponentEvent:e.any(),articleCounts:W,hasOptedOutOfArticleCount:e.boolean().nullish(),fetchEmail:e.any().nullish(),separateArticleCount:e.boolean().nullish(),design:ie.nullish(),choiceCardsSettings:de.nullish(),promoCodes:e.array(e.string()).nullish()}),Ie=e.object({heading:e.string(),subheading:e.string(),primaryCta:k.optional(),secondaryCta:k.optional(),benefits:e.array(e.string()).optional()}),Ne=e.object({content:Ie,tracking:J,mobileContent:Ie.optional(),countryCode:e.string().optional(),submitComponentEvent:e.any(),numArticles:e.number().optional(),promoCodes:e.array(e.string()).nullish()}),Me=e.object({image:Q,bodyCopy:e.array(e.string()),cta:k.optional()});e.object({content:Me,tracking:J,countryCode:e.string().optional(),submitComponentEvent:e.any(),promoCodes:e.array(e.string()).nullish()});const Ee=e.enum(["Contribution","SupporterPlus","GuardianWeekly","Paper"]),Ge=e.enum(["new","guest","current"]),Ue=e.enum(["Epic","EpicAMP","EpicAppleNews","EpicLiveblog","Banner1","Banner2","Header","GutterLiveblog"]),Be=e.enum(["Live","Draft","Archived"]),Re=e.enum(["Mobile","Desktop","All","iOS","Android"]),De=e.enum(["SignedIn","SignedOut","All"]),Pe=e.enum(["HasConsented","HasNotConsented","All"]),Le=e.object({name:e.literal("ABTest")}),we=e.object({name:e.literal("EpsilonGreedyBandit"),epsilon:e.number(),sampleCount:e.number().optional()}),Oe=e.object({name:e.literal("Roulette"),sampleCount:e.number().optional()}),ke=e.intersection(e.discriminatedUnion("name",[Le,we,Oe]),e.object({testName:e.string().optional()})),fe=e.object({channel:Ue,name:e.string(),status:Be,priority:e.number(),controlProportionSettings:e.object({proportion:e.number(),offset:e.number()}).optional(),deviceType:Re.optional(),signedInStatus:De.optional(),consentStatus:Pe.optional(),methodologies:ke.array().optional()}),je=e.enum(["AllExistingSupporters","AllNonSupporters","Everyone","PostAskPauseSingleContributors"]),Ke=e.object({minViews:e.number(),maxViews:e.number().optional(),periodInWeeks:e.number(),tagIds:e.array(e.string()).optional()});e.object({userType:e.array(Ge),product:e.array(Ee)}),e.object({tagIds:e.array(e.string()),sectionIds:e.array(e.string()),excludedTagIds:e.array(e.string()),excludedSectionIds:e.array(e.string())});const Fe=e.object({maxViewsCount:e.number(),maxViewsDays:e.number(),minDaysBetweenViews:e.number()}),ve=["ONE_OFF","MONTHLY","ANNUAL"];fe.extend({name:e.string(),status:Be,locations:e.array(c).optional(),regionTargeting:d.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:Fe.optional(),userCohort:je,hasCountryName:e.boolean(),highPriority:e.boolean(),useLocalViewLog:e.boolean(),articlesViewedSettings:Ke.optional(),priority:e.number(),variants:he.array()});const He=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")])}),Ye=(e,t,a)=>{const i=(e=>new n(window.location.search).get(`force-${e}`))(e);return fetch(`${t}/${e}${i?`?force=${i}`:""}`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}).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()))},Ve=(e,n)=>Ye("epic",e,n),We=(e,n)=>Ye("liveblog-epic",e,n),Ze=(e,n)=>Ye("banner",e,n),$e=(e,n)=>Ye("gutter-liveblog",e,n),xe=(e,n)=>Ye("header",e,n);export{u as CountryGroupId,f as SecondaryCtaType,He as abandonedBasketSchema,T as addRegionIdToSupportUrl,Te as bannerSchema,P as buildReminderFields,G as containsNonArticleCountPlaceholder,ve as contributionTabFrequencies,C as countryCodeToCountryGroupId,c as countryGroupIdSchema,g as countryGroups,Se as epicPropsSchema,Ze as getBanner,y as getCountryName,Ve as getEpic,B as getEpicViewLog,$e as getGutterLiveblog,xe as getHeader,We as getLiveblogEpic,S as getLocalCurrencySymbol,O as getReminderFields,o as getWeeklyArticleHistory,Ne as headerPropsSchema,oe as hexColourToString,h as inTargetedCountry,l as incrementWeeklyArticleCount,A as isGWCheckoutUrl,b as isoCurrencyToCurrencySymbol,R as logEpicView,M as replaceNonArticleCountPlaceholders,d 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())),h=e=>{if(e){const n=b(e);return p[n]}return"£"},S=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`${h(t)}${i[e][n].price}`}}},I={CURRENCY_SYMBOL:({countryCode:e})=>h(e),COUNTRY_NAME:({countryCode:e})=>S(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},D=(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}`}},P=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<P)(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()):D(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(),destinationUrl:e.string().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(),promoCodes:e.array(e.string()).nullish(),maxViews:de.optional(),showSignInLink:e.boolean().optional(),bylineWithImage:Q.optional(),showChoiceCards:e.boolean().optional(),choiceCardsSettings:ce.nullish(),choiceCardAmounts:me.optional(),defaultChoiceCardFrequency:pe.optional()}),he=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()}),Se=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:Se,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(),promoCodes:e.array(e.string()).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(),promoCodes:e.array(e.string()).nullish()}),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(),promoCodes:e.array(e.string()).nullish()});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"]),De=e.enum(["HasConsented","HasNotConsented","All"]),Pe=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",[Pe,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:De.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=>new URLSearchParams(window.location.search).get(`force-${e}`))(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,D as buildReminderFields,E as containsNonArticleCountPlaceholder,Fe as contributionTabFrequencies,b as countryCodeToCountryGroupId,u as countryGroupIdSchema,d as countryGroups,he as epicPropsSchema,We as getBanner,S as getCountryName,Ye as getEpic,U as getEpicViewLog,Ze as getGutterLiveblog,$e as getHeader,Ve as getLiveblogEpic,h 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"),t=require("url");const n="gu.history.weeklyArticleCount",a="gu.history.articleCountsThisWeek",o=e=>{const t=e.getDay()||7;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()-(t-1))/864e5},r=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"]),i=(e,t={})=>(e.forEach((e=>{r.has(e)&&(t[e]=(t[e]??0)+1)})),t),s=["GBPCountries","UnitedStates","AUDCountries","EURCountries","International","NZDCountries","Canada"],l=e.z.enum(s),u=e.z.object({targetedCountryGroups:e.z.array(l),targetedCountryCodes:e.z.array(e.z.string()).optional()}).optional(),c={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"}},d={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"},z={GBPCountries:"£",UnitedStates:"$",AUDCountries:"$",Canada:"CA$",EURCountries:"€",NZDCountries:"NZ$",International:"$"},p=e=>Object.keys(c).find((t=>c[t].countries.includes(e??"")))||"International",g=e=>{if(e){const t=p(e);return z[t]}return"£"},m=e=>{if(e)return d[e]},C=e=>e.includes("subscribe/weekly/checkout"),b=(e,t,n,a)=>{if(a){const o=a[p(n)];if(o){return`${g(n)}${o[e][t].price}`}}},h={CURRENCY_SYMBOL:({countryCode:e})=>g(e),COUNTRY_NAME:({countryCode:e})=>m(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,y="gu.contributions.views",A=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},T=(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}`}},I=new Date("2023-12-31"),N=e=>e>=(e=>new Date(e.getFullYear(),9,20))(e)&&e<A(e.getFullYear()),M=e.z.object({text:e.z.string(),baseUrl:e.z.string()});let E=function(e){return e.Custom="CustomSecondaryCta",e.ContributionsReminder="ContributionsReminderSecondaryCta",e}({});e.z.nativeEnum(E);const G=e.z.object({type:e.z.literal(E.Custom),cta:M}),U=e.z.object({type:e.z.literal(E.ContributionsReminder)}),B=e.z.discriminatedUnion("type",[G,U]),R=e.z.object({countLabel:e.z.string(),goalCopy:e.z.string().optional()}),P=e.z.object({total:e.z.number(),goal:e.z.number()}),L=e.z.enum(["US","AU","global"]),D=e.z.object({currencySymbol:e.z.string(),copy:R,name:L,tickerData:P.optional()}),w=e.z.object({for52Weeks:e.z.number(),forTargetedWeeks:e.z.number()}),O=e.z.enum(["for52Weeks","forTargetedWeeks"]),k=e.z.object({type:e.z.literal("above"),copy:e.z.string().optional(),countType:O.optional()}),x=e.z.enum(["CONTRIBUTION","MEMBERSHIP_SUPPORTER","DIGITAL_SUBSCRIPTION","PRINT_SUBSCRIPTION"]),j=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:j,products:e.z.array(x).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}$/,H=e.z.string().refine((e=>K.test(e)),(e=>({message:`"${e}" is not a valid hex value`}))),V=e.z.object({r:H,g:H,b:H,kind:e.z.literal("hex")}),Y=e.z.object({mobileUrl:e.z.string(),tabletUrl:e.z.string(),desktopUrl:e.z.string(),altText:e.z.string(),kind:e.z.literal("Image")}),W=e.z.object({buttonColour:V.nullish(),buttonTextColour:V.nullish(),buttonBorderColour:V.nullish(),buttonSelectColour:V.nullish(),buttonSelectTextColour:V.nullish(),buttonSelectBorderColour:V.nullish(),kind:e.z.literal("ChoiceCards")}),Z=e.z.discriminatedUnion("kind",[Y,W]),$=e.z.object({visual:Z.nullish(),colours:e.z.object({basic:e.z.object({background:V,bodyText:V})})}),_=e.z.object({copy:e.z.string()}),J=e.z.union([e.z.literal("Monthly"),e.z.literal("Annual")]),Q=e.z.discriminatedUnion("supportTier",[e.z.object({supportTier:e.z.literal("Contribution"),ratePlan:J}),e.z.object({supportTier:e.z.literal("SupporterPlus"),ratePlan:J}),e.z.object({supportTier:e.z.literal("OneOff")})]),q=e.z.object({copy:e.z.string(),textColour:V.nullish(),backgroundColour:V.nullish()}),X=e.z.object({product:Q,label:e.z.string(),isDefault:e.z.boolean(),benefitsLabel:e.z.string().nullish(),benefits:e.z.array(_),pill:q.nullish(),destinationUrl:e.z.string().nullish()}),ee=e.z.object({choiceCards:e.z.array(X),mobileChoiceCards:e.z.array(X).nullish()}),te=e.z.object({maxViewsCount:e.z.number(),maxViewsDays:e.z.number(),minDaysBetweenViews:e.z.number()}),ne=e.z.object({reminderCta:e.z.string(),reminderLabel:e.z.string(),reminderPeriod:e.z.string()}),ae=e.z.enum(["ONE_OFF","MONTHLY","ANNUAL"]),oe=e.z.object({testName:e.z.string(),variantName:e.z.string(),defaultContributionType:ae,displayContributionType:ae.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()})})}),re=e.z.object({newsletterId:e.z.string(),successDescription:e.z.string()}),ie=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:D.optional(),cta:M.optional(),secondaryCta:B.optional(),newsletterSignup:re.optional(),image:F.optional(),showReminderFields:ne.optional(),separateArticleCount:k.optional(),promoCodes:e.z.array(e.z.string()).nullish(),maxViews:te.optional(),showSignInLink:e.z.boolean().optional(),bylineWithImage:v.optional(),showChoiceCards:e.z.boolean().optional(),choiceCardsSettings:ee.nullish(),choiceCardAmounts:oe.optional(),defaultChoiceCardFrequency:ae.optional()}),se=e.z.object({variant:ie,tracking:f,countryCode:e.z.string().nullish(),articleCounts:w,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()}),le=e.z.enum(["contributions","subscriptions","signIn","abandonedBasket"]),ue=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:M.optional(),secondaryCta:B.optional()}),ce=e.z.object({tracking:f,bannerChannel:le,content:ue.nullish(),mobileContent:ue.nullish(),countryCode:e.z.string().nullish(),isSupporter:e.z.boolean().nullish(),tickerSettings:D.nullish(),submitComponentEvent:e.z.any(),articleCounts:w,hasOptedOutOfArticleCount:e.z.boolean().nullish(),fetchEmail:e.z.any().nullish(),separateArticleCount:e.z.boolean().nullish(),design:$.nullish(),choiceCardsSettings:ee.nullish(),promoCodes:e.z.array(e.z.string()).nullish()}),de=e.z.object({heading:e.z.string(),subheading:e.z.string(),primaryCta:M.optional(),secondaryCta:M.optional(),benefits:e.z.array(e.z.string()).optional()}),ze=e.z.object({content:de,tracking:f,mobileContent:de.optional(),countryCode:e.z.string().optional(),submitComponentEvent:e.z.any(),numArticles:e.z.number().optional(),promoCodes:e.z.array(e.z.string()).nullish()}),pe=e.z.object({image:F,bodyCopy:e.z.array(e.z.string()),cta:M.optional()});e.z.object({content:pe,tracking:f,countryCode:e.z.string().optional(),submitComponentEvent:e.z.any(),promoCodes:e.z.array(e.z.string()).nullish()});const ge=e.z.enum(["Contribution","SupporterPlus","GuardianWeekly","Paper"]),me=e.z.enum(["new","guest","current"]),Ce=e.z.enum(["Epic","EpicAMP","EpicAppleNews","EpicLiveblog","Banner1","Banner2","Header","GutterLiveblog"]),be=e.z.enum(["Live","Draft","Archived"]),he=e.z.enum(["Mobile","Desktop","All","iOS","Android"]),Se=e.z.enum(["SignedIn","SignedOut","All"]),ye=e.z.enum(["HasConsented","HasNotConsented","All"]),Ae=e.z.object({name:e.z.literal("ABTest")}),Te=e.z.object({name:e.z.literal("EpsilonGreedyBandit"),epsilon:e.z.number(),sampleCount:e.z.number().optional()}),Ie=e.z.object({name:e.z.literal("Roulette"),sampleCount:e.z.number().optional()}),Ne=e.z.intersection(e.z.discriminatedUnion("name",[Ae,Te,Ie]),e.z.object({testName:e.z.string().optional()})),Me=e.z.object({channel:Ce,name:e.z.string(),status:be,priority:e.z.number(),controlProportionSettings:e.z.object({proportion:e.z.number(),offset:e.z.number()}).optional(),deviceType:he.optional(),signedInStatus:Se.optional(),consentStatus:ye.optional(),methodologies:Ne.array().optional()}),Ee=e.z.enum(["AllExistingSupporters","AllNonSupporters","Everyone","PostAskPauseSingleContributors"]),Ge=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(me),product:e.z.array(ge)}),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 Ue=e.z.object({maxViewsCount:e.z.number(),maxViewsDays:e.z.number(),minDaysBetweenViews:e.z.number()});Me.extend({name:e.z.string(),status:be,locations:e.z.array(l).optional(),regionTargeting:u.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:Ue.optional(),userCohort:Ee,hasCountryName:e.z.boolean(),highPriority:e.z.boolean(),useLocalViewLog:e.z.boolean(),articlesViewedSettings:Ge.optional(),priority:e.z.number(),variants:ie.array()});const Be=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=>new t.URLSearchParams(window.location.search).get(`force-${e}`),Pe=(e,t,n)=>{const a=Re(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=s,exports.SecondaryCtaType=E,exports.abandonedBasketSchema=Be,exports.addRegionIdToSupportUrl=(e,t)=>{if(t){const n=(e=>c[p(e)].supportRegionId)(t);if(n&&!C(e))return e.replace(/(support\.theguardian\.com)\/(contribute-in-epic|contribute|subscribe|checkout)/,((e,t,a)=>`${t}/${n.toLowerCase()}/${a}`))}return e},exports.bannerSchema=ce,exports.buildReminderFields=T,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=l,exports.countryGroups=c,exports.epicPropsSchema=se,exports.getBanner=(e,t)=>Pe("banner",e,t),exports.getCountryName=m,exports.getEpic=(e,t)=>Pe("epic",e,t),exports.getEpicViewLog=e=>e.get(y)||void 0,exports.getGutterLiveblog=(e,t)=>Pe("gutter-liveblog",e,t),exports.getHeader=(e,t)=>Pe("header",e,t),exports.getLiveblogEpic=(e,t)=>Pe("liveblog-epic",e,t),exports.getLocalCurrencySymbol=g,exports.getReminderFields=(e,t=new Date)=>{return"US"===e&&N(t)?{reminderCta:"Remind me on Giving Tuesday",reminderPeriod:`${n=t.getFullYear()}-${(A(n).getMonth()+1).toString().padStart(0,"2")}-01`,reminderLabel:"on Giving Tuesday",reminderOption:`giving-tuesday-${n}`}:"US"===e&&(e=>e>=A(e.getFullYear())&&e<I)(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()):T(t);var n},exports.getWeeklyArticleHistory=e=>e.get(n)||void 0,exports.headerPropsSchema=ze,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,t,r)=>{const s=((e,t)=>{const n=o(new Date),r=e.get(a);if(r&&r.week===n){const o=r.articles[t]||0;return e.set(a,{week:n,articles:{...r.articles,[t]:o+1}}),o>0}return e.set(a,{week:n,articles:{[t]:1}}),!1})(e,t);if(!s){const t=o(new Date),a=e.get(n)||[],s=a[0];if(s?.week&&s.week===t)s.count+=1,s.tags=i(r,s.tags),e.set(n,a);else{a.unshift({week:t,count:1,tags:i(r,{})});const o=t-365,s=a.filter((e=>e.week>=o));e.set(n,s)}}},exports.isGWCheckoutUrl=C,exports.isoCurrencyToCurrencySymbol={GBP:"£",USD:"$",AUD:"$",EUR:"€",NZD:"NZ$",CAD:"CA$"},exports.logEpicView=e=>{const t=localStorage.getItem(y),n=t?JSON.parse(t).value:[];n.push({date:(new Date).getTime(),testId:e});const a={value:n.slice(-50)};localStorage.setItem(y,JSON.stringify(a))},exports.replaceNonArticleCountPlaceholders=(e,t,n)=>e?e.replace(S,(e=>{const a=e.substring(2,e.length-2),o=h[a];if(o){const e=o({countryCode:t,prices:n});if(e)return e}return e})):"",exports.targetedRegionsSchema=u;
|
|
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:"$"},z=e=>Object.keys(u).find((t=>u[t].countries.includes(e??"")))||"International",p=e=>{if(e){const t=z(e);return d[t]}return"£"},g=e=>{if(e)return c[e]},m=e=>e.includes("subscribe/weekly/checkout"),C=(e,t,n,a)=>{if(a){const o=a[z(n)];if(o){return`${p(n)}${o[e][t].price}`}}},b={CURRENCY_SYMBOL:({countryCode:e})=>p(e),COUNTRY_NAME:({countryCode:e})=>g(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"}))()},h=/%%.*?%%/g,S="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]),B=e.z.object({countLabel:e.z.string(),goalCopy:e.z.string().optional()}),R=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:B,name:P,tickerData:R.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"]),j=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()}),F=e.z.object({name:e.z.string(),description:e.z.string().optional(),headshot:f.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(),destinationUrl:e.z.string().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:f.optional(),showReminderFields:te.optional(),separateArticleCount:O.optional(),promoCodes:e.z.array(e.z.string()).nullish(),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:j,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:j,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(),promoCodes:e.z.array(e.z.string()).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:j,mobileContent:ce.optional(),countryCode:e.z.string().optional(),submitComponentEvent:e.z.any(),numArticles:e.z.number().optional(),promoCodes:e.z.array(e.z.string()).nullish()}),ze=e.z.object({image:f,bodyCopy:e.z.array(e.z.string()),cta:N.optional()});e.z.object({content:ze,tracking:j,countryCode:e.z.string().optional(),submitComponentEvent:e.z.any(),promoCodes:e.z.array(e.z.string()).nullish()});const pe=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"]),Ce=e.z.enum(["Live","Draft","Archived"]),be=e.z.enum(["Mobile","Desktop","All","iOS","Android"]),he=e.z.enum(["SignedIn","SignedOut","All"]),Se=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:Ce,priority:e.z.number(),controlProportionSettings:e.z.object({proportion:e.z.number(),offset:e.z.number()}).optional(),deviceType:be.optional(),signedInStatus:he.optional(),consentStatus:Se.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(pe)}),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: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: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")])}),Be=(e,t,n)=>{const a=(e=>new URLSearchParams(window.location.search).get(`force-${e}`))(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[z(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(h)?.filter((e=>"%%ARTICLE_COUNT%%"!==e));return!!t&&t.length>0},exports.contributionTabFrequencies=["ONE_OFF","MONTHLY","ANNUAL"],exports.countryCodeToCountryGroupId=z,exports.countryGroupIdSchema=s,exports.countryGroups=u,exports.epicPropsSchema=ie,exports.getBanner=(e,t)=>Be("banner",e,t),exports.getCountryName=g,exports.getEpic=(e,t)=>Be("epic",e,t),exports.getEpicViewLog=e=>e.get(S)??void 0,exports.getGutterLiveblog=(e,t)=>Be("gutter-liveblog",e,t),exports.getHeader=(e,t)=>Be("header",e,t),exports.getLiveblogEpic=(e,t)=>Be("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=de,exports.hexColourToString=e=>`#${e.r}${e.g}${e.b}`,exports.inTargetedCountry=(e,t=[],n=[])=>0===t.length&&0===n.length||!!e&&(!!t.includes(z(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(S),n=t?JSON.parse(t).value:[];n.push({date:(new Date).getTime(),testId:e});const a={value:n.slice(-50)};localStorage.setItem(S,JSON.stringify(a))},exports.replaceNonArticleCountPlaceholders=(e,t,n)=>e?e.replace(h,(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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewLog.d.ts","sourceRoot":"","sources":["../../../src/shared/lib/viewLog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAU9D,UAAU,QAAQ;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB;AACD,MAAM,MAAM,WAAW,GAAG,QAAQ,EAAE,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,cAAc,iBAAkB,YAAY,KAAG,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"viewLog.d.ts","sourceRoot":"","sources":["../../../src/shared/lib/viewLog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAU9D,UAAU,QAAQ;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB;AACD,MAAM,MAAM,WAAW,GAAG,QAAQ,EAAE,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,cAAc,iBAAkB,YAAY,KAAG,WAAW,GAAG,SAMzE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,WAAY,MAAM,KAAG,IAc5C,CAAC"}
|
package/package.json
CHANGED