@apolitical/sdk 10.3.4 → 10.3.5-ac.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.
Files changed (2) hide show
  1. package/build/index.js +1 -1
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/gtm"),require("axios"),require("http-status-codes"),require("socket.io-client"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/content","@apolitical/error-reporting","@apolitical/gtm","axios","http-status-codes","socket.io-client","buffer"],e):"object"==typeof exports?exports.ApoliticalSDK=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/gtm"),require("axios"),require("http-status-codes"),require("socket.io-client"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/content"],t["@apolitical/error-reporting"],t["@apolitical/gtm"],t.axios,t["http-status-codes"],t["socket.io-client"],t.buffer)}(this,(function(t,e,r,a,n,s,i){return function(){"use strict";var o={809:function(e){e.exports=t},30:function(t){t.exports=e},36:function(t){t.exports=r},300:function(t){t.exports=a},408:function(t){t.exports=i},25:function(t){t.exports=n},130:function(t){t.exports=s}},c={};function l(t){var e=c[t];if(void 0!==e)return e.exports;var r=c[t]={exports:{}};return o[t](r,r.exports,l),r.exports}l.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return l.d(e,{a:e}),e},l.d=function(t,e){for(var r in e)l.o(e,r)&&!l.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},l.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},l.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var u={};return function(){l.r(u),l.d(u,{assets:function(){return R},auth:function(){return _},badges:function(){return zr},buildAnswer:function(){return ka},buildCardCtaClickHandler:function(){return xa},buildCarouselCard:function(){return Ba},buildQuestion:function(){return fa},carouselCards:function(){return ea},contentInteraction:function(){return rt},decodeBase64:function(){return Ya},default:function(){return ja},editorialPages:function(){return ia},getEntries:function(){return e.getEntries},getEntry:function(){return e.getEntry},management:function(){return wt},mgmt:function(){return Rt},payments:function(){return Ut},people:function(){return Ke},peopleEngagement:function(){return er},qaQuestions:function(){return pa},reportError:function(){return r.reportError},search:function(){return Sr},socials:function(){return Yr},useMaps:function(){return Ta}});var t={};l.r(t),l.d(t,{read:function(){return ur},remove:function(){return Er}});var e=l(809),r=l(30),a=l(36),n={APOLITICAL:{WEBSITES:{LIVE:"https://apolitical.co",LOCALHOST:"localhost",STAGING:/https:\/\/([\w|\d|-]+)\.apolitical\.co/i,STAGING_SPLITTER:"-"},ENVIRONMENTS:{PRODUCTION:"live",LOCAL:"local"}},APIS:{ASSETS_API:{BASE_URL:"/api/assets-api",ENDPOINTS:{USERS:"/users",CERTIFICATES:"/certificates",PROFILE_IMAGES:"/profile-images"}},AUTH_API:{BASE_URL:"/api/auth-api",ENDPOINTS:{USER_PASSWORD:"/password",USERS:"/users"}},CONTENT_INTERACTION_API:{BASE_URL:"/api/content-interaction-api",ENDPOINTS:{QUESTIONS:"/questions",ANSWERS:"/answers",REPLIES:"/replies",LIKES:"/likes"}},MANAGEMENT_API:{BASE_URL:"/api/management-api",ENDPOINTS:{ACCOUNTS:"/accounts",EVENT_REGISTRATIONS:"/event-registrations",LOGINS:"/logins",LOGIN_PASSWORDLESS:"/passwordless",BULK_ENROLMENTS:"/bulk-enrolments",PROFILE:"/users/me/profile"}},MGMT_API:{BASE_URL:"/api/mgmt-api",ENDPOINTS:{REFERRALS:"/referrals",BULK_REFERRALS:"/bulk-referrals",BULK_ENROLMENTS:"/bulk-enrolments"}},PAYMENTS_API:{BASE_URL:"/api/payments-api",BASE_URL_V2:"/api/payments-api/v2",ENDPOINTS:{PRODUCTS:"/products"}},PEOPLE_API:{BASE_URL:"/api/people-api",BASE_URL_V2:"/api/people-api/v2",ENDPOINTS:{BULK_ENROLMENTS:"/bulk-enrolments",COMMUNITIES:"/communities",REGISTRATIONS:"/registrations",USERS:"/users",USER_ANSWERS:"/answers",USER_COURSES:"/courses",USER_EVENTS:"/events",USER_LIKES:"/likes",USER_LESSONS:"/lessons",USER_PRODUCTS:"/products",USER_RATINGS:"/ratings",USER_REFERRALS:"/referrals",USER_SUBSCRIPTIONS:"/subscriptions"}},PEOPLE_ENGAGEMENT_API:{BASE_URL:"/api/people-engagement-api",ENDPOINTS:{ENQUIRY_EMAILS:"/enquiry-emails",USERS:"/users",USER_PROPERTIES:"/properties"}},SEARCH_API:{BASE_URL:"/api/search-api",ENDPOINTS:{SEARCH:"/search",CHATBOTH:{COURSES:"/chatbot/me/courses"}}},SOCIALS_API:{BASE_URL:"/api/socials-api",ENDPOINTS:{COMMUNITIES:"/communities"},PATHS:{ACTIVITIES:"activities",REACTIONS:"reactions"}}},CONTENTFUL:{ARTICLES:{TYPE:"solutionArticle"},BADGES:{TYPE:"badge",INCLUDE:0,LIMIT:1e3,SELECT:"fields.name,fields.slug,fields.description,fields.icon,fields.colour",SKIP:0},CAROUSELS:{CARD_TYPES:{communityPage:{INCLUDE:1,SELECT:"fields.bannerSection,fields.slug,fields.title"},customCard:{INCLUDE:1,SELECT:"fields.icon,fields.label,fields.image,fields.primaryText,fields.secondaryText,fields.authorName,fields.authorImage,fields.link,fields.openInNewTab"},solutionArticle:{INCLUDE:1,SELECT:"fields.authorIds,fields.authorTag,fields.image,fields.publishedDate,fields.readingTime,fields.slug,fields.title"},microcourse:{INCLUDE:2,SELECT:"fields.banner,fields.freeCourse,fields.partnershipDetails,fields.slug,fields.title,fields.courseType"},event:{INCLUDE:1,SELECT:"fields.bannerImage,fields.defaultStartDate,fields.slug,fields.speakers,fields.title,fields.isEventOngoing"},listPage:{INCLUDE:1,SELECT:"fields.hero,fields.slug,fields.title"},qaQuestion:{INCLUDE:0,SELECT:"fields.answers,fields.authorId,fields.slug,fields.title,sys.createdAt,fields.projectNames"},learningHub:{INCLUDE:1,SELECT:"fields.bannerSection,fields.customLabel,fields.slug,fields.title"}}},COMMUNITY:{TYPE:"communityPage"},COURSES:{TYPE:"microcourse"},CUSTOM_CARD:{TYPE:"customCard"},EDITORIAL_PAGES:{INCLUDE:1,SELECT:"fields.carousels,fields.slug,fields.showCarouselCta,fields.header,fields.subHeader",TYPE:"editorialPage"},EVENTS:{TYPE:"event"},LISTS:{TYPE:"listPage"},QUESTIONS:{TYPE:"qaQuestion",INCLUDE:1,LIMIT:10,ORDER:"-sys.createdAt",SELECT:"sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.authorId,fields.answers,fields.isEdited,fields.projectNames",SKIP:0},ANSWERS:{TYPE:"qaAnswer"},REPLIES:{TYPE:"reply"},LEARNING_HUB:{TYPE:"learningHub"}},GOOGLE:{MAPS:{LIBRARIES:{PLACES:"places",GEOCODING:"geocoding"},VERSION:"weekly"}},HUBSPOT:{ENVIRONMENTS_MAPPING:{local:"SANDBOX",beta:"SANDBOX",rc:"SANDBOX",live:"LIVE"},EMAIL_IDS:{SANDBOX:{internalEmailId:49099078634,externalEmailId:55196526554},LIVE:{internalEmailId:55233583049,externalEmailId:55231159239}}},USERS:{MYSELF:"me"},STATUS_CODES:{INVALID_TOKEN:498},ERROR_MESSAGES:{INVALID_TOKEN:"Invalid token error: Logging user out..."}};const{HUBSPOT:{ENVIRONMENTS_MAPPING:s,EMAIL_IDS:i}}=n;let o={emailIds:{}};const c=()=>o,{APOLITICAL:{WEBSITES:{LIVE:E,LOCALHOST:S,STAGING:d,STAGING_SPLITTER:p},ENVIRONMENTS:{PRODUCTION:I,LOCAL:h}}}=n;var g=l(300),w=l.n(g);const y=async t=>{try{const{message:e,response:a,request:n}=t;let s=e;return a?s+=` - The request was made and the server responded with ${JSON.stringify({status:a.status,data:a.data})}`:n&&(s+=" - The request was made but no response was received"),console.warn(s),await(0,r.reportError)(new Error(s)),s}catch(t){return console.warn(`Cannot handle error: ${t.message}`),t.message}},{APIS:{ASSETS_API:{BASE_URL:m,ENDPOINTS:{USERS:A,CERTIFICATES:T}}}}=n;var f={create:async(t,e)=>{let r=[];try{const{data:a}=await w().post(`${m}${A}/${t}${T}`,e);a&&(r=a)}catch(t){await y(t)}return r}};const{APIS:{ASSETS_API:{BASE_URL:N,ENDPOINTS:{USERS:$,PROFILE_IMAGES:P}}}}=n;var R={certificates:f,profileImages:{create:async({userId:t,fileObject:e})=>{let r=[];try{if(!t)throw new Error("userSlug not found!");const a=new FormData;a.append("file",e);const{data:n}=await w().post(`${N}${$}/${t}${P}`,a);n&&(r=n)}catch(t){await y(t)}return r}}};const{APIS:{AUTH_API:{BASE_URL:O,ENDPOINTS:{USER_PASSWORD:L,USERS:C}}},USERS:{MYSELF:U}}=n;var _={userPassword:{update:async t=>{let e=null;try{e=await w().put(`${O}${C}/${U}${L}`,t)}catch(t){e={message:(((t||{}).response||{}).data||{}).message},await y(t)}return e}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:v,ENDPOINTS:{ANSWERS:b,QUESTIONS:D,LIKES:M}}}}=n,B=`${v}${D}`;var k={create:async({questionSlug:t},e)=>{try{await w().post(`${B}/${encodeURIComponent(t)}${b}`,e)}catch(t){const e=await y(t);throw new Error(e)}},remove:async({questionSlug:t,answerSlug:e})=>{try{await w().delete(`${B}/${encodeURIComponent(t)}${b}/${encodeURIComponent(e)}`)}catch(t){const e=await y(t);throw new Error(e)}},update:async({questionSlug:t,answerSlug:e},r)=>{try{return await w().put(`${B}/${encodeURIComponent(t)}${b}/${encodeURIComponent(e)}`,r)}catch(t){const e=await y(t);throw new Error(e)}},like:async({questionSlug:t,answerSlug:e},r)=>{try{return await w().post(`${B}/${encodeURIComponent(t)}${b}/${encodeURIComponent(e)}${M}`,r)}catch(t){const e=await y(t);throw new Error(e)}},unlike:async({questionSlug:t,answerSlug:e})=>{try{return await w().delete(`${B}/${encodeURIComponent(t)}${b}/${encodeURIComponent(e)}${M}`)}catch(t){const e=await y(t);throw new Error(e)}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:G,ENDPOINTS:{QUESTIONS:q}}}}=n,x=`${G}${q}`;var V={create:async t=>{try{return await w().post(x,t)}catch(t){const e=await y(t);throw new Error(e)}},remove:async({questionSlug:t})=>{try{await w().delete(`${x}/${encodeURIComponent(t)}`)}catch(t){const e=await y(t);throw new Error(e)}},update:async({questionSlug:t},e)=>{try{return await w().put(`${x}/${encodeURIComponent(t)}`,e)}catch(t){const e=await y(t);throw new Error(e)}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:Y,ENDPOINTS:{REPLIES:j,ANSWERS:F,QUESTIONS:K,LIKES:H}}}}=n,Q=`${Y}${K}`,W=({questionSlug:t,answerSlug:e,replySlug:r},a=!1)=>{let n=`${Q}/${encodeURIComponent(t)}${F}/${encodeURIComponent(e)}${j}`;return r&&(n=`${n}/${encodeURIComponent(r)}`,a&&(n=`${n}${H}`)),n};var J={create:async({questionSlug:t,answerSlug:e},r)=>{try{return await w().post(W({questionSlug:t,answerSlug:e}),r)}catch(t){const e=await y(t);throw new Error(e)}},update:async({questionSlug:t,answerSlug:e,replySlug:r},a)=>{try{return await w().put(W({questionSlug:t,answerSlug:e,replySlug:r}),a)}catch(t){const e=await y(t);throw new Error(e)}},remove:async({questionSlug:t,answerSlug:e,replySlug:r})=>{try{await w().delete(W({questionSlug:t,answerSlug:e,replySlug:r}))}catch(t){const e=await y(t);throw new Error(e)}},like:async({questionSlug:t,answerSlug:e,replySlug:r,payload:a})=>{try{await w().post(W({questionSlug:t,answerSlug:e,replySlug:r},!0),a)}catch(t){const e=await y(t);throw new Error(e)}},unlike:async({questionSlug:t,answerSlug:e,replySlug:r})=>{try{await w().delete(W({questionSlug:t,answerSlug:e,replySlug:r},!0))}catch(t){const e=await y(t);throw new Error(e)}},getReplyUrl:W};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:z,ENDPOINTS:{QUESTIONS:X,ANSWERS:Z,LIKES:tt}}}}=n,et=`${z}${X}`;var rt={answers:k,questions:V,replies:J,likes:{create:async({questionSlug:t,answerSlug:e})=>{try{return await w().post(`${et}/${encodeURIComponent(t)}${Z}/${encodeURIComponent(e)}${tt}`)}catch(t){const e=await y(t);throw new Error(e)}},remove:async({questionSlug:t,answerSlug:e})=>{try{return await w().delete(`${et}/${encodeURIComponent(t)}${Z}/${encodeURIComponent(e)}${tt}`)}catch(t){const e=await y(t);throw new Error(e)}}}};const{APIS:{MANAGEMENT_API:{BASE_URL:at,ENDPOINTS:{ACCOUNTS:nt}}}}=n;var st={create:async t=>{try{await w().post(`${at}${nt}`,t)}catch(t){throw await y(t),t}},read:async t=>{let e=null;try{({data:e}=await w().get(`${at}${nt}/${encodeURIComponent(t)}`))}catch(t){await y(t)}return e},update:async(t,e)=>{try{await w().put(`${at}${nt}/${encodeURIComponent(t)}`,e)}catch(t){throw await y(t),t}}};const{APIS:{MANAGEMENT_API:{BASE_URL:it,ENDPOINTS:{EVENT_REGISTRATIONS:ot}}}}=n;var ct={create:async t=>{try{await w().post(`${it}${ot}`,t)}catch(t){const e=await y(t);throw new Error(e)}}};const{APIS:{MANAGEMENT_API:{BASE_URL:lt,ENDPOINTS:{LOGINS:ut,LOGIN_PASSWORDLESS:Et}}}}=n,St=`${lt}${ut}`;var dt={update:async t=>{try{await w().put(`${St}/${encodeURIComponent(t)}${Et}`)}catch(t){throw await y(t),t}}};const{APIS:{MANAGEMENT_API:{BASE_URL:pt}}}=n;var It={create:async t=>{try{await w().post(`${pt}/users/${t.id}/products`,t)}catch(t){const e=await y(t);throw new Error(e)}}};const{APIS:{MANAGEMENT_API:{BASE_URL:ht,ENDPOINTS:{PROFILE:gt}}}}=n;var wt={accounts:st,eventRegistrations:ct,passwordless:dt,userProducts:It,profile:{update:async t=>{try{const e=["name","jobTitle","organization","location","biography","image"];if(!Object.keys(t).some((t=>e.includes(t))))throw new Error("Profile data should include at least one of 'name', 'jobTitle', 'organization', 'location', 'biography', 'image'");await w().put(`${ht}${gt}`,t)}catch(t){const e=await y(t);throw new Error(`An error occurred while trying to update the user's profile in the management api: ${e}`)}}}};const{APIS:{MGMT_API:{BASE_URL:yt,ENDPOINTS:{REFERRALS:mt}}}}=n;var At={create:async t=>{try{await w().post(`${yt}${mt}`,t)}catch(t){throw await y(t),t}}};const{APIS:{MGMT_API:{BASE_URL:Tt,ENDPOINTS:{BULK_REFERRALS:ft}}}}=n;var Nt={create:async t=>{try{await w().post(`${Tt}${ft}`,t)}catch(t){throw await y(t),t}}};const{APIS:{MGMT_API:{BASE_URL:$t,ENDPOINTS:{BULK_ENROLMENTS:Pt}}}}=n;var Rt={referrals:At,bulkReferrals:Nt,bulkEnrolments:{create:async t=>{try{await w().post(`${$t}${Pt}`,t)}catch(t){throw await y(t),t}}}};const{APIS:{PAYMENTS_API:{BASE_URL_V2:Ot,ENDPOINTS:{PRODUCTS:Lt}}}}=n,Ct=`${Ot}${Lt}`;var Ut={products:{list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Ct,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:_t,ENDPOINTS:{BULK_ENROLMENTS:vt}}}}=n;var bt={list:async t=>{let e=[];try{const{data:r}=await w().get(`${_t}${vt}`,{params:t});r&&r.length&&(e=r)}catch(t){await y(t)}return e}},Dt=l(25);const{OK:Mt,MULTIPLE_CHOICES:Bt,NOT_FOUND:kt,FORBIDDEN:Gt}=Dt.StatusCodes,qt=t=>t>=Mt&&t<Bt||t===Gt||t===kt,{APIS:{PEOPLE_API:{BASE_URL_V2:xt,ENDPOINTS:{USERS:Vt}}},STATUS_CODES:{INVALID_TOKEN:Yt},ERROR_MESSAGES:{INVALID_TOKEN:jt}}=n,Ft=async t=>{let e=null;try{const{data:r}=await w().get(`${xt}${Vt}/${encodeURIComponent(t)}`,{validateStatus:qt});r&&r.id&&(e=r)}catch(t){if(t?.response?.status===Yt)throw new Error(jt);await y(t)}return e},Kt=async t=>{let e=[];try{if(t&&t.length<2)throw new Error("users list method requires at least two ids");const r=t.map((t=>`ids=${encodeURIComponent(t)}`)).join("&"),a=await w().get(`${xt}${Vt}?${r}`,{validateStatus:qt});a&&a.length&&(e=a)}catch(t){await y(t)}return e};var Ht={read:Ft,update:async(t,e)=>{let r=!1;try{const{data:a}=await w().put(`${xt}${Vt}/${encodeURIComponent(t)}`,e);r=!(!a||!a.id)}catch(t){await y(t)}return r},list:Kt};const{APIS:{PEOPLE_API:{BASE_URL_V2:Qt,ENDPOINTS:{USERS:Wt,USER_LIKES:Jt}}},USERS:{MYSELF:zt}}=n,Xt=`${Qt}${Wt}/${zt}${Jt}`,Zt=async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Xt,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e};var te={list:Zt};var ee={authors:{readQuestionAuthors:async(t,e,r)=>{try{if(t.author=await Ft(t.authorId),t.answers&&t.answers.length&&!r.ignoreAnswersAuthors){t.answers.sort(((t,e)=>new Date(e.updatedAt)-new Date(t.updatedAt))),t.totalAnswers=t.answers.length;let a=t.answers;if(r.limit&&r.pageNumber){const e=r.limit*(r.pageNumber-1);a=t.answers.slice(e,e+r.limit)}for(let t of a){t.author=t.authorId&&await Ft(t.authorId)||{};const[r]=e?await Zt({contentType:n.CONTENTFUL.ANSWERS.TYPE,contentSlug:t.slug}):[null];t.userLiked=!!r}t.answers=a}else t.answers||(t.answers=[]);return t}catch(t){throw await y(t),new Error(`Cannot read authors for question: ${t.message}`)}},readAuthors:async(t=[])=>{let e=[];try{if(!1===Array.isArray(t))throw new Error("authorIds is not an array!");if(t&&1===t.length){const r=await Ft(t[0]);r&&e.push(r)}else if(t&&t.length>1){const r=await Kt(t);r&&r.length>0&&(e=r)}}catch(t){throw await y(t),new Error(`Cannot read authors: ${t.message}`)}return e}}};const{APIS:{PEOPLE_API:{BASE_URL:re,ENDPOINTS:{REGISTRATIONS:ae}}}}=n;var ne={list:async t=>{let e=[];try{const{data:r}=await w().get(`${re}${ae}`,{params:t});r&&r.length&&(e=r)}catch(t){await y(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:se,ENDPOINTS:{COMMUNITIES:ie,USERS:oe}}}}=n,ce=`${se}${oe}`;function le(t){const e=t["content-range"].split(" ")[1].split("/"),[r,a,n]=[...e[0].split("-"),e[1]].map((t=>parseInt(t,10)||0));return{start:r,end:a,total:n}}var ue={list:async(t="me",e={})=>{let r={items:[],start:0,end:0,total:0},a=e?{params:e}:{params:{}};try{const{data:e,headers:n}=await w().get(`${ce}/${t}${ie}`,{...a,headers:{"Cache-Control":"no-cache",Pragma:"no-cache",Expires:0}});return e?.length>0&&(r={data:e,pagination:le(n)}),r}catch(t){await y(t)}return r}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Ee,ENDPOINTS:{USERS:Se,USER_COURSES:de}}},USERS:{MYSELF:pe}}=n,Ie=`${Ee}${Se}/${pe}${de}`;var he={create:async t=>{try{await w().post(Ie,t)}catch(t){await y(t)}},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Ie,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e},update:async(t,e)=>{try{await w().put(`${Ie}/${t}`,e)}catch(t){await y(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:ge,ENDPOINTS:{USERS:we,USER_EVENTS:ye}}},USERS:{MYSELF:me}}=n,Ae=`${ge}${we}/${me}${ye}`;var Te={list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Ae,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:fe,ENDPOINTS:{USERS:Ne,USER_LESSONS:$e}}},USERS:{MYSELF:Pe}}=n,Re=`${fe}${Ne}/${Pe}${$e}`;var Oe={create:async t=>{let e=null;try{e=await w().post(Re,t)}catch(t){await y(t)}return e},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Re,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Le,ENDPOINTS:{USERS:Ce,USER_PRODUCTS:Ue}}},USERS:{MYSELF:_e}}=n,ve=`${Le}${Ce}/${_e}${Ue}`;var be={create:async t=>{let e=null;try{e=await w().post(ve,t)}catch(t){await y(t)}return e},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(ve,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e},update:async(t,e)=>{try{await w().put(`${ve}/${t}`,e)}catch(t){await y(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:De,ENDPOINTS:{USERS:Me,USER_RATINGS:Be}}},USERS:{MYSELF:ke}}=n,Ge=`${De}${Me}/${ke}${Be}`;var qe={create:async t=>{let e=null;try{const{data:r}=await w().post(Ge,t);r?.id&&(e=r)}catch(t){await y(t)}return e},update:async(t,e)=>{try{await w().put(`${Ge}/${t}`,e)}catch(t){await y(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:xe,ENDPOINTS:{USERS:Ve,USER_REFERRALS:Ye}}},USERS:{MYSELF:je}}=n,Fe=`${xe}${Ve}/${je}${Ye}`;var Ke={bulkEnrolments:bt,handlers:ee,registrations:ne,users:Ht,userCommunities:ue,userCourses:he,userEvents:Te,userLessons:Oe,userLikes:te,userProducts:be,userRatings:qe,userReferrals:{list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Fe,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:He,ENDPOINTS:{ENQUIRY_EMAILS:Qe}}}}=n;var We={create:async t=>{let e=null;try{const{data:r}=await w().post(`${He}${Qe}`,t);r&&(e=r)}catch(t){await y(t)}return e}},Je={forms:{sendEnquiryEmails:async t=>{let e=null;try{const{emailIds:r}=c();e=await er.emails.create({...r,...t})}catch(t){await y(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:ze,ENDPOINTS:{USERS:Xe,USER_PROPERTIES:Ze}}},USERS:{MYSELF:tr}}=n;var er={emails:We,handlers:Je,userProperties:{update:async(t,e)=>{try{await w().put(`${ze}${Xe}/${tr}${Ze}/${t}`,e)}catch(t){await y(t)}}}},rr=l(130);const{APIS:{SEARCH_API:{BASE_URL:ar,ENDPOINTS:{SEARCH:nr}}}}=n,sr=`${ar}${nr}`;var ir={ask:async t=>{try{let e=null;const{data:r}=await w().get(sr,{params:{question:t}});return r?.answer&&r?.references&&r?.version&&(e=r),e}catch(t){const e=await y(t);throw new Error(e)}},stream:(t,e,r)=>{const a=(0,rr.io)(void 0,{path:"/api/search-api/web-sockets"});function n(){a.emit("search",{question:t})}function s(t){r(t),i(),a.disconnect()}function i(){a.off("connect",n),a.off("update",e),a.off("result",s)}return a.on("connect",n),a.on("update",e),a.on("result",s),i}};const{APIS:{SEARCH_API:{BASE_URL:or,ENDPOINTS:{CHATBOTH:{COURSES:cr}}}}}=n,lr=`${or}${cr}`;async function ur(t,e){try{let r=null;const{data:a}=await w().get(`${lr}/${t}`,{params:{text:e}});return a&&(r=a),r}catch(t){await y(t)}}async function Er(t){try{let e=null;const{data:r}=await w().delete(`${lr}/${t}`);return r&&(e=r),e}catch(t){await y(t)}}var Sr={...ir,chatbot:{courses:t}};const{APIS:{SOCIALS_API:{BASE_URL:dr,ENDPOINTS:{COMMUNITIES:pr},PATHS:{ACTIVITIES:Ir}}}}=n,hr=`${dr}${pr}`;var gr={read:async(t,e)=>{let r=null;try{const{data:a}=await w().get(`${hr}/${encodeURIComponent(t)}/${Ir}/${e}`);a&&(r=a)}catch(t){await y(t)}return r},list:async(t,e={})=>{let r=null;try{const{data:a}=await w().get(`${hr}/${encodeURIComponent(t)}/${Ir}`,{params:e});a&&(r=a)}catch(t){await y(t)}return r},create:async(t,e)=>{let r=null;try{const{data:a}=await w().post(`${hr}/${encodeURIComponent(t)}/${Ir}`,e);(a?.content||a?.title)&&(r=a)}catch(t){await y(t)}return r},update:async(t,e,r)=>{let a=null;try{const{data:n}=await w().put(`${hr}/${encodeURIComponent(t)}/${Ir}/${e}`,r);(n?.content||n?.title)&&(a=n)}catch(t){await y(t)}return a},remove:async(t,e)=>{let r=null;try{const{data:a}=await w().delete(`${hr}/${encodeURIComponent(t)}/${Ir}/${e}`);r=a}catch(t){await y(t)}return r}};const{APIS:{SOCIALS_API:{BASE_URL:wr,ENDPOINTS:{COMMUNITIES:yr}}}}=n,mr=`${wr}${yr}`;var Ar={read:async t=>{let e=null;try{const{data:r}=await w().get(`${mr}/${encodeURIComponent(t)}`);r?.title&&(e=r)}catch(t){await y(t)}return e},join:async(t,e)=>{let r=null;try{const{data:a}=await w().post(`${mr}/${encodeURIComponent(t)}/members`,e);r=a}catch(t){await y(t)}return r},leave:async t=>{let e=null;try{const{data:r}=await w().delete(`${mr}/${encodeURIComponent(t)}/members/me`);e=r}catch(t){await y(t)}return e}};const{APIS:{SOCIALS_API:{BASE_URL:Tr,ENDPOINTS:{COMMUNITIES:fr},PATHS:{ACTIVITIES:Nr,REACTIONS:$r}}}}=n,Pr=`${Tr}${fr}`;var Rr={create:async({slug:t,activityId:e,reactionId:r})=>{let a=null;const n={kind:"like"};let s=`${Pr}/${encodeURIComponent(t)}`;s=e?`${s}/${Nr}/${e}/${$r}`:`${s}/${$r}/${r}/${$r}`;try{const{data:t}=await w().post(s,n);a=t}catch(t){await y(t)}return a},remove:async({slug:t,reactionId:e})=>{let r=null;try{const{data:a}=await w().delete(`${Pr}/${encodeURIComponent(t)}/${$r}/${e}`);r=a}catch(t){await y(t)}return r}};const{APIS:{SOCIALS_API:{BASE_URL:Or,ENDPOINTS:{COMMUNITIES:Lr}}}}=n,Cr=`${Or}${Lr}`;var Ur={list:async(t,e)=>{let r={data:[],pagination:{start:0,end:0,total:0}},a=e?{params:e}:{params:{}};try{const{data:e}=await w().get(`${Cr}/${encodeURIComponent(t)}/members`,{...a,headers:{"Cache-Control":"no-cache",Pragma:"no-cache",Expires:0}});e?.data?.length>0&&(r=e)}catch(t){await y(t)}return r},read:async(t,e="me")=>{let r=null;try{r=(await w().get(`${Cr}/${encodeURIComponent(t)}/members/${e}`,{headers:{"Cache-Control":"no-cache",Pragma:"no-cache",Expires:0}})).data}catch(t){await y(t)}return r}};const{APIS:{SOCIALS_API:{BASE_URL:_r,ENDPOINTS:{COMMUNITIES:vr},PATHS:{ACTIVITIES:br,REACTIONS:Dr}}}}=n,Mr=`${_r}${vr}`;var Br={create:async({slug:t,activityId:e})=>{let r=null;const a={kind:"pin"};let n=`${Mr}/${encodeURIComponent(t)}`;n=`${n}/${br}/${e}/${Dr}`;try{const{data:t}=await w().post(n,a);r=t}catch(t){await y(t)}return r},remove:async({slug:t,reactionId:e})=>{let r=null;try{const{data:a}=await w().delete(`${Mr}/${encodeURIComponent(t)}/${Dr}/${e}`);r=a}catch(t){await y(t)}return r}};const{APIS:{SOCIALS_API:{BASE_URL:kr,ENDPOINTS:{COMMUNITIES:Gr},PATHS:{ACTIVITIES:qr,REACTIONS:xr}}}}=n,Vr=`${kr}${Gr}`;var Yr={activities:gr,communities:Ar,members:Ur,likes:Rr,pins:Br,reactions:{create:async(t,e,r,a)=>{let n=null,s=`${Vr}/${encodeURIComponent(t)}`;s=e?`${s}/${qr}/${e}/${xr}`:`${s}/${xr}/${r}/${xr}`;try{const{data:t}=await w().post(s,a);n=t}catch(t){await y(t)}return n},list:async(t,{activityId:e,reactionId:r},a={})=>{let n=null,s=`${Vr}/${encodeURIComponent(t)}`;s=e?`${s}/${qr}/${e}/${xr}`:`${s}/${xr}/${r}/${xr}`;try{const{data:t}=await w().get(s,{params:a});t&&(n=t)}catch(t){await y(t)}return n},remove:async(t,e)=>{let r=null;try{const{data:a}=await w().delete(`${Vr}/${encodeURIComponent(t)}/${xr}/${e}`);r=a}catch(t){await y(t)}return r},update:async(t,e,r,a)=>{let n=null,s=`${Vr}/${encodeURIComponent(t)}`;s=e?`${s}/${qr}/${e}`:`${s}/${xr}/${r}`;try{const{data:t}=await w().put(s,a);n=t}catch(t){await y(t)}return n}}};const{CONTENTFUL:jr}=n,{TYPE:Fr,ORDER:Kr,SELECT:Hr,SKIP:Qr,LIMIT:Wr,INCLUDE:Jr}=jr.BADGES;var zr={list:async()=>{try{return await(0,e.getEntries)({content_type:Fr,include:Jr,limit:Wr,order:Kr,select:Hr,skip:Qr})}catch(t){throw await y(t),new Error(`Cannot list badges: ${t.message}`)}}};const{CONTENTFUL:Xr}=n,{CARD_TYPES:Zr}=Xr.CAROUSELS,ta={read:async(t,r)=>{try{if(!r||!r.sys||!r.sys.id)throw new Error("Invalid link to card");if(!t||!Zr[t])throw new Error("Unsupported card content type");const{INCLUDE:a,SELECT:n}=Zr[t];return await(0,e.getEntry)({content_type:t,"sys.id":r.sys.id,include:a,select:n},{assetDetails:!0})}catch(t){throw await y(t),new Error(`Cannot read carousel card: ${t.message}`)}}};var ea=ta;const{CONTENTFUL:ra}=n,{INCLUDE:aa,SELECT:na,TYPE:sa}=ra.EDITORIAL_PAGES;var ia={read:async t=>{try{return await(0,e.getEntry)({content_type:sa,"fields.slug":t,include:aa,select:na})}catch(t){throw await y(t),new Error(`Cannot read editorial page: ${t.message}`)}}};const{CONTENTFUL:oa}=n,{TYPE:ca,ORDER:la,SELECT:ua,SKIP:Ea,LIMIT:Sa,INCLUDE:da}=oa.QUESTIONS;var pa={read:async t=>{try{return await(0,e.getEntry)({content_type:ca,"fields.slug":t,include:2,select:ua})}catch(t){throw await y(t),new Error(`Cannot read question: ${t.message}`)}},list:async(t={})=>{try{return await(0,e.getEntries)({content_type:ca,include:da,limit:Sa,order:la,select:ua,skip:Ea,...t})}catch(t){throw await y(t),new Error(`Cannot list questions: ${t.message}`)}}};var Ia=function t(e,r){if(e===r)return!0;if(e&&r&&"object"==typeof e&&"object"==typeof r){if(e.constructor!==r.constructor)return!1;var a,n,s;if(Array.isArray(e)){if((a=e.length)!=r.length)return!1;for(n=a;0!=n--;)if(!t(e[n],r[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if((a=(s=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(n=a;0!=n--;)if(!Object.prototype.hasOwnProperty.call(r,s[n]))return!1;for(n=a;0!=n--;){var i=s[n];if(!t(e[i],r[i]))return!1}return!0}return e!=e&&r!=r};const ha="__googleMapsScriptId";var ga;!function(t){t[t.INITIALIZED=0]="INITIALIZED",t[t.LOADING=1]="LOADING",t[t.SUCCESS=2]="SUCCESS",t[t.FAILURE=3]="FAILURE"}(ga||(ga={}));class wa{constructor({apiKey:t,authReferrerPolicy:e,channel:r,client:a,id:n=ha,language:s,libraries:i=[],mapIds:o,nonce:c,region:l,retries:u=3,url:E="https://maps.googleapis.com/maps/api/js",version:S}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=t,this.authReferrerPolicy=e,this.channel=r,this.client=a,this.id=n||ha,this.language=s,this.libraries=i,this.mapIds=o,this.nonce=c,this.region=l,this.retries=u,this.url=E,this.version=S,wa.instance){if(!Ia(this.options,wa.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(wa.instance.options)}`);return wa.instance}wa.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?ga.FAILURE:this.done?ga.SUCCESS:this.loading?ga.LOADING:ga.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let t=this.url;return t+="?callback=__googleMapsCallback",this.apiKey&&(t+=`&key=${this.apiKey}`),this.channel&&(t+=`&channel=${this.channel}`),this.client&&(t+=`&client=${this.client}`),this.libraries.length>0&&(t+=`&libraries=${this.libraries.join(",")}`),this.language&&(t+=`&language=${this.language}`),this.region&&(t+=`&region=${this.region}`),this.version&&(t+=`&v=${this.version}`),this.mapIds&&(t+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(t+=`&auth_referrer_policy=${this.authReferrerPolicy}`),t}deleteScript(){const t=document.getElementById(this.id);t&&t.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise(((t,e)=>{this.loadCallback((r=>{r?e(r.error):t(window.google)}))}))}importLibrary(t){return this.execute(),google.maps.importLibrary(t)}loadCallback(t){this.callbacks.push(t),this.execute()}setScript(){var t,e;if(document.getElementById(this.id))return void this.callback();const r={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(r).forEach((t=>!r[t]&&delete r[t])),(null===(e=null===(t=null===window||void 0===window?void 0:window.google)||void 0===t?void 0:t.maps)||void 0===e?void 0:e.importLibrary)||(t=>{let e,r,a,n="The Google Maps JavaScript API",s="google",i="importLibrary",o="__ib__",c=document,l=window;l=l[s]||(l[s]={});const u=l.maps||(l.maps={}),E=new Set,S=new URLSearchParams,d=()=>e||(e=new Promise(((i,l)=>{return d=this,p=void 0,h=function*(){var d;for(a in yield r=c.createElement("script"),r.id=this.id,S.set("libraries",[...E]+""),t)S.set(a.replace(/[A-Z]/g,(t=>"_"+t[0].toLowerCase())),t[a]);S.set("callback",s+".maps."+o),r.src=this.url+"?"+S,u[o]=i,r.onerror=()=>e=l(Error(n+" could not load.")),r.nonce=this.nonce||(null===(d=c.querySelector("script[nonce]"))||void 0===d?void 0:d.nonce)||"",c.head.append(r)},new((I=void 0)||(I=Promise))((function(t,e){function r(t){try{n(h.next(t))}catch(t){e(t)}}function a(t){try{n(h.throw(t))}catch(t){e(t)}}function n(e){var n;e.done?t(e.value):(n=e.value,n instanceof I?n:new I((function(t){t(n)}))).then(r,a)}n((h=h.apply(d,p||[])).next())}));var d,p,I,h})));u[i]?console.warn(n+" only loads once. Ignoring:",t):u[i]=(t,...e)=>E.add(t)&&d().then((()=>u[i](t,...e)))})(r);const a=this.libraries.map((t=>this.importLibrary(t)));a.length||a.push(this.importLibrary("core")),Promise.all(a).then((()=>this.callback()),(t=>{const e=new ErrorEvent("error",{error:t});this.loadErrorCallback(e)}))}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(t){if(this.errors.push(t),this.errors.length<=this.retries){const t=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${t} ms.`),setTimeout((()=>{this.deleteScript(),this.setScript()}),t)}else this.onerrorEvent=t,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach((t=>{t(this.onerrorEvent)})),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version)return console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),void this.callback();this.loading||(this.loading=!0,this.setScript())}}}const{GOOGLE:{MAPS:{LIBRARIES:{GEOCODING:ya,PLACES:ma},VERSION:Aa}}}=n;var Ta=function(t={}){let e=[];const r=c(),a=new wa({apiKey:r?.googleMaps?.apiKey,version:Aa});return{buildLocation:async function(t){try{const r=e.find((e=>e.description===t));if(!r)throw new Error("Place not found");const{place_id:n,description:s}=r,{Geocoder:i}=await a.importLibrary(ya),o=new i;return new Promise((t=>{o.geocode({placeId:n},((e=[],r)=>{if("OK"===r){const r=e[0].address_components.find((t=>t.types.includes("country"))),a=r?r.short_name:null;t({id:n,en:s,code:a})}else t({id:n,en:s,code:null})})).catch((()=>t({id:n,en:s,code:null})))}))}catch(t){return await y(t),null}},isValidPlace:function(t){return e.some((e=>e.description===t))},predictPlaces:async function(r){try{const{AutocompleteService:n}=await a.importLibrary(ma),s=new n;return new Promise((a=>{s.getPlacePredictions({...t,input:r,types:["(cities)"]},((t=[],r)=>{"OK"===r?(e=t,a(t)):a([])})).catch((()=>a([])))}))}catch(t){return await y(t),[]}}}},fa=async(t,e,r={ignoreAnswersAuthors:!1})=>{try{let a={};return a=await pa.read(t),a=await Ke.handlers.authors.readQuestionAuthors(a,e,r),a}catch(t){throw await y(t),new Error(`Cannot build question: ${t.message}`)}};const{ARTICLES:{TYPE:Na},COURSES:{TYPE:$a},CUSTOM_CARD:{TYPE:Pa},COMMUNITY:{TYPE:Ra},EVENTS:{TYPE:Oa},LISTS:{TYPE:La},QUESTIONS:{TYPE:Ca},LEARNING_HUB:{TYPE:Ua}}=n.CONTENTFUL,_a={ClosedHidden:"closed-hidden",ClosedVisible:"closed-visible",OpenHidden:"open-hidden",OpenVisible:"open-visible"},va=t=>t&&t.url?(Object.assign(t,{aspect:"responsiveCard",query:"q=90&fit=fill"}),t):null,ba=t=>t&&t.url?`${t.url}?w=100&h=100&fit=thumb&f=center`:null,Da=t=>t.toLowerCase().split(" ")[0],Ma={[Na]:async t=>{const{authorIds:e,authorTag:r,image:a,publishedDate:n,readingTime:s,slug:i,title:o}=t,c=await Ke.handlers.authors.readAuthors(e),l=c&&c.length?c:r?[Da(r)]:null;return{banner:va(a),contributors:l,publishedDate:n,readingTime:s,slug:i,title:o}},[Ra]:async t=>{const{title:e,slug:r,bannerSection:a,privacy:n,createdAt:s}=t,i=[_a.ClosedVisible,_a.ClosedHidden].includes(n),o=[_a.OpenVisible,_a.ClosedVisible].includes(n);return{banner:a?.image?va(a.image):null,slug:r,title:e,privacy:n,isPrivate:i,isVisible:o,createdAt:s}},[$a]:async(t,e)=>{const{banner:r,freeCourse:a,partnershipDetails:n,slug:s,title:i,registered:o,courseType:c}=t,l={banner:va(r),slug:s,title:i,pill:a?"free":"premium",registered:!!o,courseType:c};if(n){const{partners:t}=n;if(t)if(t.length>1){let e=[];for(let r=0;r<t.length;r++)e.push(t[r].title);l.partner=e}else l.partner=[t[0].title]}if(void 0===o&&e){const[t]=await Ke.userProducts.list({courseSlug:s,isEnrolled:!0,scope:"active"});l.registered=!!t}return l},[Pa]:t=>{const{authorName:e,authorImage:r,icon:a,image:n,label:s,link:i,primaryText:o}=t;return{...t,banner:n?va(n):null,customIcon:a?a.toLowerCase():null,customLabel:s,contributors:e?[{name:e,image:r?{thumbnail:ba(r)}:null}]:null,slug:i,text:o}},[Oa]:async(t,e)=>{const{bannerImage:r,defaultStartDate:a,isEventOngoing:n,slug:s,speakers:i,title:o,registered:c}=t,l=new Date(a),u=!!l&&l<new Date;if(i&&i.length)for(const t of i)t.image=ba(t.image);const E={banner:va(r),dateHasPassed:u,title:o,slug:s,isOngoingEvent:n,contributors:i,startDate:l,registered:!!c};if(void 0===c&&e){const[t]=await Ke.userEvents.list({eventSlug:s});E.registered=!!t}return E},[La]:async t=>{const{hero:e,slug:r,title:a}=t;return{banner:va(e),slug:r,title:a}},[Ca]:async t=>{const{answers:e,authorId:r,createdAt:a,slug:n,title:s}=t;let i=null;if(r){const t=await Ke.users.read(r);t&&(i=t)}return{answers:e&&e.length?e.length:0,contributors:i?[i]:[],createdAt:a,slug:n,title:s}},[Ua]:t=>{const{bannerSection:e,customLabel:r,slug:a,title:n}=t;return{banner:va(e.image),slug:a,title:n,customLabel:r}},people:t=>{const{id:e,name:r,jobTitle:a,location:n,image:s,customLink:i}=t;return{profile:s,slug:i?.link||e,title:r,text:a,secondaryText:n,customLinkText:i?.text}}};var Ba=async({contentType:t,...e}={},r)=>{try{if(!Ma[t])throw new Error("Content type not supported");if("function"!=typeof Ma[t])throw new Error("No builder function for content type");return"people"!==t&&e.sys&&e.sys.type&&"Link"===e.sys.type&&(e=await ea.read(t,e)),{contentType:t,...await Ma[t](e,r)}}catch(t){throw await y(t),new Error(`Cannot build carousel card: ${t.message}`)}},ka=async(t,e,r={})=>{try{if(!t.replies||0===t.replies.length)return t.replies=[],t;t.replies.sort(((t,e)=>new Date(t.createdAt)-new Date(e.createdAt))),t.totalReplies=t.totalReplies||t.replies.length;let a=t.replies;if(r.limit&&r.pageNumber){const e=r.limit*(r.pageNumber-1);a=t.replies.slice(e,e+r.limit)}for(const r of a){if(r.authorId===t.authorId){r.author=t.author,r.userLiked=!1;continue}r.author=r.authorId&&await Ft(r.authorId)||{};const[a]=e?await Zt({contentType:n.CONTENTFUL.REPLIES.TYPE,contentSlug:r.slug}):[null];r.userLiked=!!a}return t.replies=a,t}catch(t){throw await y(t),new Error(`Cannot build replies for answer: ${t.message}`)}};const Ga="success",qa="error";var xa=t=>async e=>{const{contentType:r}=e;switch(r){case"event":try{return await wt.eventRegistrations.create({eventSlug:e.slug,expectation:null,userEmail:t.email,startsAt:new Date(e.startDate).toISOString()}),Ga}catch(t){return reportError(new Error(`Error registering for event: ${JSON.stringify(t)}`)),qa}case"microcourse":try{return await wt.userProducts.create({id:t.id,courseSlug:e.slug,email:t.email,courseType:e.courseType}),Ga}catch(t){return reportError(new Error(`Error registering for microcourse: ${JSON.stringify(t)}`)),qa}case"communityPage":try{return await Yr.communities.join(e.slug,{...t.image.thumbnail&&{thumbnail:t.image.thumbnail},...t.jobTitle&&{jobTitle:t.jobTitle},...t.location&&{location:{...t.location}},...t.organization&&{organization:t.organization}}),Ga}catch(t){return reportError(new Error(`Error joining community: ${JSON.stringify(t)}`)),qa}default:return qa}},Va=l(408);const Ya=t=>t&&Va.Buffer.from(t,"base64").toString("ascii");function ja({contentContext:t=null,errorsContext:n=null,googleMapsContext:c=null,gtmContext:l=null,origin:u}){try{const g=(t=>{let e=null;t?e=t:"undefined"!=typeof window&&(e=window.origin||window.location.origin),e||new Error("Cannot select environment: Website not defined");let r=null;const a=e.match(d);return a?r=a[1].split(p)[0]:e===E?r=I:e.includes(S)&&(r=h),r||new Error(`Cannot select environment: No rule for website ${e}`),r})(u);return t&&(0,e.setContext)(Object.assign({},t,{environment:g})),n&&(0,r.setContext)(Object.assign({},n,{environment:g})),c&&(({apiKey:t})=>{o.googleMaps={apiKey:t}})(Object.assign({},c,{environment:g})),l&&((0,a.setContext)(Object.assign({},l,{environment:g})),(0,a.setupGTM)()),(({environment:t})=>{const e=(t=>{if(!t)throw new Error("Cannot map environment: Environment not defined");if(!s[t])throw new Error(`Cannot map environment: No mapping found for environment ${t}`);return s[t]})(t);o.emailIds=i[e]})(Object.assign({},{environment:g})),g}catch(t){console.warn(`Cannot load SDK: ${t.message}`)}}}(),u}()}));
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/gtm"),require("axios"),require("http-status-codes"),require("socket.io-client"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/content","@apolitical/error-reporting","@apolitical/gtm","axios","http-status-codes","socket.io-client","buffer"],e):"object"==typeof exports?exports.ApoliticalSDK=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/gtm"),require("axios"),require("http-status-codes"),require("socket.io-client"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/content"],t["@apolitical/error-reporting"],t["@apolitical/gtm"],t.axios,t["http-status-codes"],t["socket.io-client"],t.buffer)}(this,(function(t,e,r,a,n,s,i){return function(){"use strict";var o={809:function(e){e.exports=t},30:function(t){t.exports=e},36:function(t){t.exports=r},300:function(t){t.exports=a},408:function(t){t.exports=i},25:function(t){t.exports=n},130:function(t){t.exports=s}},c={};function l(t){var e=c[t];if(void 0!==e)return e.exports;var r=c[t]={exports:{}};return o[t](r,r.exports,l),r.exports}l.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return l.d(e,{a:e}),e},l.d=function(t,e){for(var r in e)l.o(e,r)&&!l.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},l.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},l.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var u={};return function(){l.r(u),l.d(u,{assets:function(){return R},auth:function(){return _},badges:function(){return zr},buildAnswer:function(){return ka},buildCardCtaClickHandler:function(){return xa},buildCarouselCard:function(){return Ba},buildQuestion:function(){return fa},carouselCards:function(){return ea},contentInteraction:function(){return rt},decodeBase64:function(){return Ya},default:function(){return ja},editorialPages:function(){return ia},getEntries:function(){return e.getEntries},getEntry:function(){return e.getEntry},management:function(){return wt},mgmt:function(){return Rt},payments:function(){return Ut},people:function(){return Ke},peopleEngagement:function(){return er},qaQuestions:function(){return pa},reportError:function(){return r.reportError},search:function(){return Sr},socials:function(){return Yr},useMaps:function(){return Ta}});var t={};l.r(t),l.d(t,{read:function(){return ur},remove:function(){return Er}});var e=l(809),r=l(30),a=l(36),n={APOLITICAL:{WEBSITES:{LIVE:"https://apolitical.co",LOCALHOST:"localhost",STAGING:/https:\/\/([\w|\d|-]+)\.apolitical\.co/i,STAGING_SPLITTER:"-"},ENVIRONMENTS:{PRODUCTION:"live",LOCAL:"local"}},APIS:{ASSETS_API:{BASE_URL:"/api/assets-api",ENDPOINTS:{USERS:"/users",CERTIFICATES:"/certificates",PROFILE_IMAGES:"/profile-images"}},AUTH_API:{BASE_URL:"/api/auth-api",ENDPOINTS:{USER_PASSWORD:"/password",USERS:"/users"}},CONTENT_INTERACTION_API:{BASE_URL:"/api/content-interaction-api",ENDPOINTS:{QUESTIONS:"/questions",ANSWERS:"/answers",REPLIES:"/replies",LIKES:"/likes"}},MANAGEMENT_API:{BASE_URL:"/api/management-api",ENDPOINTS:{ACCOUNTS:"/accounts",EVENT_REGISTRATIONS:"/event-registrations",LOGINS:"/logins",LOGIN_PASSWORDLESS:"/passwordless",BULK_ENROLMENTS:"/bulk-enrolments",PROFILE:"/users/me/profile"}},MGMT_API:{BASE_URL:"/api/mgmt-api",ENDPOINTS:{REFERRALS:"/referrals",BULK_REFERRALS:"/bulk-referrals",BULK_ENROLMENTS:"/bulk-enrolments"}},PAYMENTS_API:{BASE_URL:"/api/payments-api",BASE_URL_V2:"/api/payments-api/v2",ENDPOINTS:{PRODUCTS:"/products"}},PEOPLE_API:{BASE_URL:"/api/people-api",BASE_URL_V2:"/api/people-api/v2",ENDPOINTS:{BULK_ENROLMENTS:"/bulk-enrolments",COMMUNITIES:"/communities",REGISTRATIONS:"/registrations",USERS:"/users",USER_ANSWERS:"/answers",USER_COURSES:"/courses",USER_EVENTS:"/events",USER_LIKES:"/likes",USER_LESSONS:"/lessons",USER_PRODUCTS:"/products",USER_RATINGS:"/ratings",USER_REFERRALS:"/referrals",USER_SUBSCRIPTIONS:"/subscriptions"}},PEOPLE_ENGAGEMENT_API:{BASE_URL:"/api/people-engagement-api",ENDPOINTS:{ENQUIRY_EMAILS:"/enquiry-emails",USERS:"/users",USER_PROPERTIES:"/properties"}},SEARCH_API:{BASE_URL:"/api/search-api",ENDPOINTS:{SEARCH:"/search",CHATBOTH:{COURSES:"/chatbot/me/courses"}}},SOCIALS_API:{BASE_URL:"/api/socials-api",ENDPOINTS:{COMMUNITIES:"/communities"},PATHS:{ACTIVITIES:"activities",REACTIONS:"reactions"}}},CONTENTFUL:{ARTICLES:{TYPE:"solutionArticle"},BADGES:{TYPE:"badge",INCLUDE:0,LIMIT:1e3,SELECT:"fields.name,fields.slug,fields.description,fields.icon,fields.colour",SKIP:0},CAROUSELS:{CARD_TYPES:{communityPage:{INCLUDE:1,SELECT:"fields.bannerSection,fields.slug,fields.title"},customCard:{INCLUDE:1,SELECT:"fields.icon,fields.label,fields.image,fields.primaryText,fields.secondaryText,fields.authorName,fields.authorImage,fields.link,fields.openInNewTab"},solutionArticle:{INCLUDE:1,SELECT:"fields.authorIds,fields.authorTag,fields.image,fields.publishedDate,fields.readingTime,fields.slug,fields.title"},microcourse:{INCLUDE:2,SELECT:"fields.banner,fields.freeCourse,fields.partnershipDetails,fields.slug,fields.title,fields.courseType"},event:{INCLUDE:1,SELECT:"fields.bannerImage,fields.defaultStartDate,fields.slug,fields.speakers,fields.title,fields.isEventOngoing"},listPage:{INCLUDE:1,SELECT:"fields.hero,fields.slug,fields.title"},qaQuestion:{INCLUDE:0,SELECT:"fields.answers,fields.authorId,fields.slug,fields.title,sys.createdAt,fields.projectNames"},learningHub:{INCLUDE:1,SELECT:"fields.bannerSection,fields.customLabel,fields.slug,fields.title"}}},COMMUNITY:{TYPE:"communityPage"},COURSES:{TYPE:"microcourse"},CUSTOM_CARD:{TYPE:"customCard"},EDITORIAL_PAGES:{INCLUDE:1,SELECT:"fields.carousels,fields.slug,fields.showCarouselCta,fields.header,fields.subHeader",TYPE:"editorialPage"},EVENTS:{TYPE:"event"},LISTS:{TYPE:"listPage"},QUESTIONS:{TYPE:"qaQuestion",INCLUDE:1,LIMIT:10,ORDER:"-sys.createdAt",SELECT:"sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.authorId,fields.answers,fields.isEdited,fields.projectNames",SKIP:0},ANSWERS:{TYPE:"qaAnswer"},REPLIES:{TYPE:"reply"},LEARNING_HUB:{TYPE:"learningHub"}},GOOGLE:{MAPS:{LIBRARIES:{PLACES:"places",GEOCODING:"geocoding"},VERSION:"weekly"}},HUBSPOT:{ENVIRONMENTS_MAPPING:{local:"SANDBOX",beta:"SANDBOX",rc:"SANDBOX",live:"LIVE"},EMAIL_IDS:{SANDBOX:{internalEmailId:49099078634,externalEmailId:55196526554},LIVE:{internalEmailId:55233583049,externalEmailId:55231159239}}},USERS:{MYSELF:"me"},STATUS_CODES:{INVALID_TOKEN:498},ERROR_MESSAGES:{INVALID_TOKEN:"Invalid token error: Logging user out..."}};const{HUBSPOT:{ENVIRONMENTS_MAPPING:s,EMAIL_IDS:i}}=n;let o={emailIds:{}};const c=()=>o,{APOLITICAL:{WEBSITES:{LIVE:E,LOCALHOST:S,STAGING:d,STAGING_SPLITTER:p},ENVIRONMENTS:{PRODUCTION:I,LOCAL:h}}}=n;var g=l(300),w=l.n(g);const y=async t=>{try{const{message:e,response:a,request:n}=t;let s=e;return a?s+=` - The request was made and the server responded with ${JSON.stringify({status:a.status,data:a.data})}`:n&&(s+=" - The request was made but no response was received"),console.warn(s),await(0,r.reportError)(new Error(s)),s}catch(t){return console.warn(`Cannot handle error: ${t.message}`),t.message}},{APIS:{ASSETS_API:{BASE_URL:m,ENDPOINTS:{USERS:A,CERTIFICATES:T}}}}=n;var f={create:async(t,e)=>{let r=[];try{const{data:a}=await w().post(`${m}${A}/${t}${T}`,e);a&&(r=a)}catch(t){await y(t)}return r}};const{APIS:{ASSETS_API:{BASE_URL:N,ENDPOINTS:{USERS:$,PROFILE_IMAGES:P}}}}=n;var R={certificates:f,profileImages:{create:async({userId:t,fileObject:e})=>{let r=[];try{if(!t)throw new Error("userSlug not found!");const a=new FormData;a.append("file",e);const{data:n}=await w().post(`${N}${$}/${t}${P}`,a);n&&(r=n)}catch(t){await y(t)}return r}}};const{APIS:{AUTH_API:{BASE_URL:O,ENDPOINTS:{USER_PASSWORD:L,USERS:C}}},USERS:{MYSELF:U}}=n;var _={userPassword:{update:async t=>{let e=null;try{e=await w().put(`${O}${C}/${U}${L}`,t)}catch(t){e={message:(((t||{}).response||{}).data||{}).message},await y(t)}return e}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:v,ENDPOINTS:{ANSWERS:b,QUESTIONS:D,LIKES:M}}}}=n,B=`${v}${D}`;var k={create:async({questionSlug:t},e)=>{try{await w().post(`${B}/${encodeURIComponent(t)}${b}`,e)}catch(t){const e=await y(t);throw new Error(e)}},remove:async({questionSlug:t,answerSlug:e})=>{try{await w().delete(`${B}/${encodeURIComponent(t)}${b}/${encodeURIComponent(e)}`)}catch(t){const e=await y(t);throw new Error(e)}},update:async({questionSlug:t,answerSlug:e},r)=>{try{return await w().put(`${B}/${encodeURIComponent(t)}${b}/${encodeURIComponent(e)}`,r)}catch(t){const e=await y(t);throw new Error(e)}},like:async({questionSlug:t,answerSlug:e},r)=>{try{return await w().post(`${B}/${encodeURIComponent(t)}${b}/${encodeURIComponent(e)}${M}`,r)}catch(t){const e=await y(t);throw new Error(e)}},unlike:async({questionSlug:t,answerSlug:e})=>{try{return await w().delete(`${B}/${encodeURIComponent(t)}${b}/${encodeURIComponent(e)}${M}`)}catch(t){const e=await y(t);throw new Error(e)}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:G,ENDPOINTS:{QUESTIONS:q}}}}=n,x=`${G}${q}`;var V={create:async t=>{try{return await w().post(x,t)}catch(t){const e=await y(t);throw new Error(e)}},remove:async({questionSlug:t})=>{try{await w().delete(`${x}/${encodeURIComponent(t)}`)}catch(t){const e=await y(t);throw new Error(e)}},update:async({questionSlug:t},e)=>{try{return await w().put(`${x}/${encodeURIComponent(t)}`,e)}catch(t){const e=await y(t);throw new Error(e)}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:Y,ENDPOINTS:{REPLIES:j,ANSWERS:F,QUESTIONS:K,LIKES:H}}}}=n,Q=`${Y}${K}`,W=({questionSlug:t,answerSlug:e,replySlug:r},a=!1)=>{let n=`${Q}/${encodeURIComponent(t)}${F}/${encodeURIComponent(e)}${j}`;return r&&(n=`${n}/${encodeURIComponent(r)}`,a&&(n=`${n}${H}`)),n};var J={create:async({questionSlug:t,answerSlug:e},r)=>{try{return await w().post(W({questionSlug:t,answerSlug:e}),r)}catch(t){const e=await y(t);throw new Error(e)}},update:async({questionSlug:t,answerSlug:e,replySlug:r},a)=>{try{return await w().put(W({questionSlug:t,answerSlug:e,replySlug:r}),a)}catch(t){const e=await y(t);throw new Error(e)}},remove:async({questionSlug:t,answerSlug:e,replySlug:r})=>{try{await w().delete(W({questionSlug:t,answerSlug:e,replySlug:r}))}catch(t){const e=await y(t);throw new Error(e)}},like:async({questionSlug:t,answerSlug:e,replySlug:r,payload:a})=>{try{await w().post(W({questionSlug:t,answerSlug:e,replySlug:r},!0),a)}catch(t){const e=await y(t);throw new Error(e)}},unlike:async({questionSlug:t,answerSlug:e,replySlug:r})=>{try{await w().delete(W({questionSlug:t,answerSlug:e,replySlug:r},!0))}catch(t){const e=await y(t);throw new Error(e)}},getReplyUrl:W};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:z,ENDPOINTS:{QUESTIONS:X,ANSWERS:Z,LIKES:tt}}}}=n,et=`${z}${X}`;var rt={answers:k,questions:V,replies:J,likes:{create:async({questionSlug:t,answerSlug:e})=>{try{return await w().post(`${et}/${encodeURIComponent(t)}${Z}/${encodeURIComponent(e)}${tt}`)}catch(t){const e=await y(t);throw new Error(e)}},remove:async({questionSlug:t,answerSlug:e})=>{try{return await w().delete(`${et}/${encodeURIComponent(t)}${Z}/${encodeURIComponent(e)}${tt}`)}catch(t){const e=await y(t);throw new Error(e)}}}};const{APIS:{MANAGEMENT_API:{BASE_URL:at,ENDPOINTS:{ACCOUNTS:nt}}}}=n;var st={create:async t=>{try{await w().post(`${at}${nt}`,t)}catch(t){throw await y(t),t}},read:async t=>{let e=null;try{({data:e}=await w().get(`${at}${nt}/${encodeURIComponent(t)}`))}catch(t){await y(t)}return e},update:async(t,e)=>{try{await w().put(`${at}${nt}/${encodeURIComponent(t)}`,e)}catch(t){throw await y(t),t}}};const{APIS:{MANAGEMENT_API:{BASE_URL:it,ENDPOINTS:{EVENT_REGISTRATIONS:ot}}}}=n;var ct={create:async t=>{try{await w().post(`${it}${ot}`,t)}catch(t){const e=await y(t);throw new Error(e)}}};const{APIS:{MANAGEMENT_API:{BASE_URL:lt,ENDPOINTS:{LOGINS:ut,LOGIN_PASSWORDLESS:Et}}}}=n,St=`${lt}${ut}`;var dt={update:async t=>{try{await w().put(`${St}/${encodeURIComponent(t)}${Et}`)}catch(t){throw await y(t),t}}};const{APIS:{MANAGEMENT_API:{BASE_URL:pt}}}=n;var It={create:async t=>{try{await w().post(`${pt}/users/${t.id}/products`,t)}catch(t){const e=await y(t);throw new Error(e)}}};const{APIS:{MANAGEMENT_API:{BASE_URL:ht,ENDPOINTS:{PROFILE:gt}}}}=n;var wt={accounts:st,eventRegistrations:ct,passwordless:dt,userProducts:It,profile:{update:async t=>{try{const e=["name","jobTitle","organization","location","biography","image"];if(!Object.keys(t).some((t=>e.includes(t))))throw new Error("Profile data should include at least one of 'name', 'jobTitle', 'organization', 'location', 'biography', 'image'");await w().put(`${ht}${gt}`,t)}catch(t){const e=await y(t);throw new Error(`An error occurred while trying to update the user's profile in the management api: ${e}`)}}}};const{APIS:{MGMT_API:{BASE_URL:yt,ENDPOINTS:{REFERRALS:mt}}}}=n;var At={create:async t=>{try{await w().post(`${yt}${mt}`,t)}catch(t){throw await y(t),t}}};const{APIS:{MGMT_API:{BASE_URL:Tt,ENDPOINTS:{BULK_REFERRALS:ft}}}}=n;var Nt={create:async t=>{try{await w().post(`${Tt}${ft}`,t)}catch(t){throw await y(t),t}}};const{APIS:{MGMT_API:{BASE_URL:$t,ENDPOINTS:{BULK_ENROLMENTS:Pt}}}}=n;var Rt={referrals:At,bulkReferrals:Nt,bulkEnrolments:{create:async t=>{try{await w().post(`${$t}${Pt}`,t)}catch(t){throw await y(t),t}}}};const{APIS:{PAYMENTS_API:{BASE_URL_V2:Ot,ENDPOINTS:{PRODUCTS:Lt}}}}=n,Ct=`${Ot}${Lt}`;var Ut={products:{list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Ct,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:_t,ENDPOINTS:{BULK_ENROLMENTS:vt}}}}=n;var bt={list:async t=>{let e=[];try{const{data:r}=await w().get(`${_t}${vt}`,{params:t});r&&r.length&&(e=r)}catch(t){await y(t)}return e}},Dt=l(25);const{OK:Mt,MULTIPLE_CHOICES:Bt,NOT_FOUND:kt,FORBIDDEN:Gt}=Dt.StatusCodes,qt=t=>t>=Mt&&t<Bt||t===Gt||t===kt,{APIS:{PEOPLE_API:{BASE_URL_V2:xt,ENDPOINTS:{USERS:Vt}}},STATUS_CODES:{INVALID_TOKEN:Yt},ERROR_MESSAGES:{INVALID_TOKEN:jt}}=n,Ft=async t=>{let e=null;try{const{data:r}=await w().get(`${xt}${Vt}/${encodeURIComponent(t)}`,{validateStatus:qt});r&&r.id&&(e=r)}catch(t){if(t?.response?.status===Yt)throw new Error(jt);await y(t)}return e},Kt=async t=>{let e=[];try{if(t&&t.length<2)throw new Error("users list method requires at least two ids");const r=t.map((t=>`ids=${encodeURIComponent(t)}`)).join("&"),a=await w().get(`${xt}${Vt}?${r}`,{validateStatus:qt});a&&a.length&&(e=a)}catch(t){await y(t)}return e};var Ht={read:Ft,update:async(t,e)=>{let r=!1;try{const{data:a}=await w().put(`${xt}${Vt}/${encodeURIComponent(t)}`,e);r=!(!a||!a.id)}catch(t){await y(t)}return r},list:Kt};const{APIS:{PEOPLE_API:{BASE_URL_V2:Qt,ENDPOINTS:{USERS:Wt,USER_LIKES:Jt}}},USERS:{MYSELF:zt}}=n,Xt=`${Qt}${Wt}/${zt}${Jt}`,Zt=async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Xt,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e};var te={list:Zt};var ee={authors:{readQuestionAuthors:async(t,e,r)=>{try{if(t.author=await Ft(t.authorId),t.answers&&t.answers.length&&!r.ignoreAnswersAuthors){t.answers.sort(((t,e)=>new Date(e.updatedAt)-new Date(t.updatedAt))),t.totalAnswers=t.answers.length;let a=t.answers;if(r.limit&&r.pageNumber){const e=r.limit*(r.pageNumber-1);a=t.answers.slice(e,e+r.limit)}for(let t of a){t.author=t.authorId&&await Ft(t.authorId)||{};const[r]=e?await Zt({contentType:n.CONTENTFUL.ANSWERS.TYPE,contentSlug:t.slug}):[null];t.userLiked=!!r}t.answers=a}else t.answers||(t.answers=[]);return t}catch(t){throw await y(t),new Error(`Cannot read authors for question: ${t.message}`)}},readAuthors:async(t=[])=>{let e=[];try{if(!1===Array.isArray(t))throw new Error("authorIds is not an array!");if(t&&1===t.length){const r=await Ft(t[0]);r&&e.push(r)}else if(t&&t.length>1){const r=await Kt(t);r&&r.length>0&&(e=r)}}catch(t){throw await y(t),new Error(`Cannot read authors: ${t.message}`)}return e}}};const{APIS:{PEOPLE_API:{BASE_URL:re,ENDPOINTS:{REGISTRATIONS:ae}}}}=n;var ne={list:async t=>{let e=[];try{const{data:r}=await w().get(`${re}${ae}`,{params:t});r&&r.length&&(e=r)}catch(t){await y(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:se,ENDPOINTS:{COMMUNITIES:ie,USERS:oe}}}}=n,ce=`${se}${oe}`;function le(t){const e=t["content-range"].split(" ")[1].split("/"),[r,a,n]=[...e[0].split("-"),e[1]].map((t=>parseInt(t,10)||0));return{start:r,end:a,total:n}}var ue={list:async(t="me",e={})=>{let r={items:[],start:0,end:0,total:0},a=e?{params:e}:{params:{}};try{const{data:e,headers:n}=await w().get(`${ce}/${t}${ie}`,{...a,headers:{"Cache-Control":"no-cache",Pragma:"no-cache",Expires:0}});return e?.length>0&&(r={data:e,pagination:le(n)}),r}catch(t){await y(t)}return r}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Ee,ENDPOINTS:{USERS:Se,USER_COURSES:de}}},USERS:{MYSELF:pe}}=n,Ie=`${Ee}${Se}/${pe}${de}`;var he={create:async t=>{try{await w().post(Ie,t)}catch(t){await y(t)}},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Ie,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e},update:async(t,e)=>{try{await w().put(`${Ie}/${t}`,e)}catch(t){await y(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:ge,ENDPOINTS:{USERS:we,USER_EVENTS:ye}}},USERS:{MYSELF:me}}=n,Ae=`${ge}${we}/${me}${ye}`;var Te={list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Ae,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:fe,ENDPOINTS:{USERS:Ne,USER_LESSONS:$e}}},USERS:{MYSELF:Pe}}=n,Re=`${fe}${Ne}/${Pe}${$e}`;var Oe={create:async t=>{let e=null;try{e=await w().post(Re,t)}catch(t){await y(t)}return e},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Re,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Le,ENDPOINTS:{USERS:Ce,USER_PRODUCTS:Ue}}},USERS:{MYSELF:_e}}=n,ve=`${Le}${Ce}/${_e}${Ue}`;var be={create:async t=>{let e=null;try{e=await w().post(ve,t)}catch(t){await y(t)}return e},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(ve,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e},update:async(t,e)=>{try{await w().put(`${ve}/${t}`,e)}catch(t){await y(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:De,ENDPOINTS:{USERS:Me,USER_RATINGS:Be}}},USERS:{MYSELF:ke}}=n,Ge=`${De}${Me}/${ke}${Be}`;var qe={create:async t=>{let e=null;try{const{data:r}=await w().post(Ge,t);r?.id&&(e=r)}catch(t){await y(t)}return e},update:async(t,e)=>{try{await w().put(`${Ge}/${t}`,e)}catch(t){await y(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:xe,ENDPOINTS:{USERS:Ve,USER_REFERRALS:Ye}}},USERS:{MYSELF:je}}=n,Fe=`${xe}${Ve}/${je}${Ye}`;var Ke={bulkEnrolments:bt,handlers:ee,registrations:ne,users:Ht,userCommunities:ue,userCourses:he,userEvents:Te,userLessons:Oe,userLikes:te,userProducts:be,userRatings:qe,userReferrals:{list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Fe,r);t&&t.length&&(e=t)}catch(t){await y(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:He,ENDPOINTS:{ENQUIRY_EMAILS:Qe}}}}=n;var We={create:async t=>{let e=null;try{const{data:r}=await w().post(`${He}${Qe}`,t);r&&(e=r)}catch(t){await y(t)}return e}},Je={forms:{sendEnquiryEmails:async t=>{let e=null;try{const{emailIds:r}=c();e=await er.emails.create({...r,...t})}catch(t){await y(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:ze,ENDPOINTS:{USERS:Xe,USER_PROPERTIES:Ze}}},USERS:{MYSELF:tr}}=n;var er={emails:We,handlers:Je,userProperties:{update:async(t,e)=>{try{await w().put(`${ze}${Xe}/${tr}${Ze}/${t}`,e)}catch(t){await y(t)}}}},rr=l(130);const{APIS:{SEARCH_API:{BASE_URL:ar,ENDPOINTS:{SEARCH:nr}}}}=n,sr=`${ar}${nr}`;var ir={ask:async t=>{try{let e=null;const{data:r}=await w().get(sr,{params:{question:t}});return r?.answer&&r?.references&&r?.version&&(e=r),e}catch(t){const e=await y(t);throw new Error(e)}},stream:(t,e,r)=>{const a=(0,rr.io)(void 0,{path:"/api/search-api/web-sockets"});function n(){a.emit("search",{question:t})}function s(t){r(t),i(),a.disconnect()}function i(){a.off("connect",n),a.off("update",e),a.off("result",s)}return a.on("connect",n),a.on("update",e),a.on("result",s),i}};const{APIS:{SEARCH_API:{BASE_URL:or,ENDPOINTS:{CHATBOTH:{COURSES:cr}}}}}=n,lr=`${or}${cr}`;async function ur(t,e){try{let r=null;const{data:a}=await w().get(`${lr}/${t}`,{params:{text:e}});return a&&(r=a),r}catch(t){await y(t)}}async function Er(t){try{let e=null;const{data:r}=await w().delete(`${lr}/${t}`);return r&&(e=r),e}catch(t){await y(t)}}var Sr={...ir,chatbot:{courses:t}};const{APIS:{SOCIALS_API:{BASE_URL:dr,ENDPOINTS:{COMMUNITIES:pr},PATHS:{ACTIVITIES:Ir}}}}=n,hr=`${dr}${pr}`;var gr={read:async(t,e)=>{let r=null;try{const{data:a}=await w().get(`${hr}/${encodeURIComponent(t)}/${Ir}/${e}`);a&&(r=a)}catch(t){await y(t)}return r},list:async(t,e={})=>{let r=null;try{const{data:a}=await w().get(`${hr}/${encodeURIComponent(t)}/${Ir}`,{params:e});a&&(r=a)}catch(t){await y(t)}return r},create:async(t,e)=>{let r=null;try{const{data:a}=await w().post(`${hr}/${encodeURIComponent(t)}/${Ir}`,e);(a?.content||a?.title)&&(r=a)}catch(t){await y(t)}return r},update:async(t,e,r)=>{let a=null;try{const{data:n}=await w().put(`${hr}/${encodeURIComponent(t)}/${Ir}/${e}`,r);(n?.content||n?.title)&&(a=n)}catch(t){await y(t)}return a},remove:async(t,e)=>{let r=null;try{const{data:a}=await w().delete(`${hr}/${encodeURIComponent(t)}/${Ir}/${e}`);r=a}catch(t){await y(t)}return r}};const{APIS:{SOCIALS_API:{BASE_URL:wr,ENDPOINTS:{COMMUNITIES:yr}}}}=n,mr=`${wr}${yr}`;var Ar={read:async t=>{let e=null;try{const{data:r}=await w().get(`${mr}/${encodeURIComponent(t)}`);r?.title&&(e=r)}catch(t){await y(t)}return e},join:async(t,e)=>{let r=null;try{const{data:a}=await w().post(`${mr}/${encodeURIComponent(t)}/members`,e);r=a}catch(t){await y(t)}return r},leave:async t=>{let e=null;try{const{data:r}=await w().delete(`${mr}/${encodeURIComponent(t)}/members/me`);e=r}catch(t){await y(t)}return e}};const{APIS:{SOCIALS_API:{BASE_URL:Tr,ENDPOINTS:{COMMUNITIES:fr},PATHS:{ACTIVITIES:Nr,REACTIONS:$r}}}}=n,Pr=`${Tr}${fr}`;var Rr={create:async({slug:t,activityId:e,reactionId:r})=>{let a=null;const n={kind:"like"};let s=`${Pr}/${encodeURIComponent(t)}`;s=e?`${s}/${Nr}/${e}/${$r}`:`${s}/${$r}/${r}/${$r}`;try{const{data:t}=await w().post(s,n);a=t}catch(t){await y(t)}return a},remove:async({slug:t,reactionId:e})=>{let r=null;try{const{data:a}=await w().delete(`${Pr}/${encodeURIComponent(t)}/${$r}/${e}`);r=a}catch(t){await y(t)}return r}};const{APIS:{SOCIALS_API:{BASE_URL:Or,ENDPOINTS:{COMMUNITIES:Lr}}}}=n,Cr=`${Or}${Lr}`;var Ur={list:async(t,e)=>{let r={data:[],pagination:{start:0,end:0,total:0}},a=e?{params:e}:{params:{}};try{const{data:e}=await w().get(`${Cr}/${encodeURIComponent(t)}/members`,{...a,headers:{"Cache-Control":"no-cache",Pragma:"no-cache",Expires:0}});e?.data?.length>0&&(r=e)}catch(t){await y(t)}return r},read:async(t,e="me")=>{let r=null;try{r=(await w().get(`${Cr}/${encodeURIComponent(t)}/members/${e}`,{headers:{"Cache-Control":"no-cache",Pragma:"no-cache",Expires:0}})).data}catch(t){await y(t)}return r}};const{APIS:{SOCIALS_API:{BASE_URL:_r,ENDPOINTS:{COMMUNITIES:vr},PATHS:{ACTIVITIES:br,REACTIONS:Dr}}}}=n,Mr=`${_r}${vr}`;var Br={create:async({slug:t,activityId:e})=>{let r=null;const a={kind:"pin"};let n=`${Mr}/${encodeURIComponent(t)}`;n=`${n}/${br}/${e}/${Dr}`;try{const{data:t}=await w().post(n,a);r=t}catch(t){await y(t)}return r},remove:async({slug:t,reactionId:e})=>{let r=null;try{const{data:a}=await w().delete(`${Mr}/${encodeURIComponent(t)}/${Dr}/${e}`);r=a}catch(t){await y(t)}return r}};const{APIS:{SOCIALS_API:{BASE_URL:kr,ENDPOINTS:{COMMUNITIES:Gr},PATHS:{ACTIVITIES:qr,REACTIONS:xr}}}}=n,Vr=`${kr}${Gr}`;var Yr={activities:gr,communities:Ar,members:Ur,likes:Rr,pins:Br,reactions:{create:async(t,e,r,a)=>{let n=null,s=`${Vr}/${encodeURIComponent(t)}`;s=e?`${s}/${qr}/${e}/${xr}`:`${s}/${xr}/${r}/${xr}`;try{const{data:t}=await w().post(s,a);n=t}catch(t){await y(t)}return n},list:async(t,{activityId:e,reactionId:r},a={})=>{let n=null,s=`${Vr}/${encodeURIComponent(t)}`;s=e?`${s}/${qr}/${e}/${xr}`:`${s}/${xr}/${r}/${xr}`;try{const{data:t}=await w().get(s,{params:a});t&&(n=t)}catch(t){await y(t)}return n},remove:async(t,e)=>{let r=null;try{const{data:a}=await w().delete(`${Vr}/${encodeURIComponent(t)}/${xr}/${e}`);r=a}catch(t){await y(t)}return r},update:async(t,e,r,a)=>{let n=null,s=`${Vr}/${encodeURIComponent(t)}`;s=e?`${s}/${qr}/${e}`:`${s}/${xr}/${r}`;try{const{data:t}=await w().put(s,a);n=t}catch(t){await y(t)}return n}}};const{CONTENTFUL:jr}=n,{TYPE:Fr,ORDER:Kr,SELECT:Hr,SKIP:Qr,LIMIT:Wr,INCLUDE:Jr}=jr.BADGES;var zr={list:async()=>{try{return await(0,e.getEntries)({content_type:Fr,include:Jr,limit:Wr,order:Kr,select:Hr,skip:Qr})}catch(t){return await y(t),[]}}};const{CONTENTFUL:Xr}=n,{CARD_TYPES:Zr}=Xr.CAROUSELS,ta={read:async(t,r)=>{try{if(!r||!r.sys||!r.sys.id)throw new Error("Invalid link to card");if(!t||!Zr[t])throw new Error("Unsupported card content type");const{INCLUDE:a,SELECT:n}=Zr[t];return await(0,e.getEntry)({content_type:t,"sys.id":r.sys.id,include:a,select:n},{assetDetails:!0})}catch(t){throw await y(t),new Error(`Cannot read carousel card: ${t.message}`)}}};var ea=ta;const{CONTENTFUL:ra}=n,{INCLUDE:aa,SELECT:na,TYPE:sa}=ra.EDITORIAL_PAGES;var ia={read:async t=>{try{return await(0,e.getEntry)({content_type:sa,"fields.slug":t,include:aa,select:na})}catch(t){throw await y(t),new Error(`Cannot read editorial page: ${t.message}`)}}};const{CONTENTFUL:oa}=n,{TYPE:ca,ORDER:la,SELECT:ua,SKIP:Ea,LIMIT:Sa,INCLUDE:da}=oa.QUESTIONS;var pa={read:async t=>{try{return await(0,e.getEntry)({content_type:ca,"fields.slug":t,include:2,select:ua})}catch(t){throw await y(t),new Error(`Cannot read question: ${t.message}`)}},list:async(t={})=>{try{return await(0,e.getEntries)({content_type:ca,include:da,limit:Sa,order:la,select:ua,skip:Ea,...t})}catch(t){throw await y(t),new Error(`Cannot list questions: ${t.message}`)}}};var Ia=function t(e,r){if(e===r)return!0;if(e&&r&&"object"==typeof e&&"object"==typeof r){if(e.constructor!==r.constructor)return!1;var a,n,s;if(Array.isArray(e)){if((a=e.length)!=r.length)return!1;for(n=a;0!=n--;)if(!t(e[n],r[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if((a=(s=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(n=a;0!=n--;)if(!Object.prototype.hasOwnProperty.call(r,s[n]))return!1;for(n=a;0!=n--;){var i=s[n];if(!t(e[i],r[i]))return!1}return!0}return e!=e&&r!=r};const ha="__googleMapsScriptId";var ga;!function(t){t[t.INITIALIZED=0]="INITIALIZED",t[t.LOADING=1]="LOADING",t[t.SUCCESS=2]="SUCCESS",t[t.FAILURE=3]="FAILURE"}(ga||(ga={}));class wa{constructor({apiKey:t,authReferrerPolicy:e,channel:r,client:a,id:n=ha,language:s,libraries:i=[],mapIds:o,nonce:c,region:l,retries:u=3,url:E="https://maps.googleapis.com/maps/api/js",version:S}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=t,this.authReferrerPolicy=e,this.channel=r,this.client=a,this.id=n||ha,this.language=s,this.libraries=i,this.mapIds=o,this.nonce=c,this.region=l,this.retries=u,this.url=E,this.version=S,wa.instance){if(!Ia(this.options,wa.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(wa.instance.options)}`);return wa.instance}wa.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?ga.FAILURE:this.done?ga.SUCCESS:this.loading?ga.LOADING:ga.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let t=this.url;return t+="?callback=__googleMapsCallback",this.apiKey&&(t+=`&key=${this.apiKey}`),this.channel&&(t+=`&channel=${this.channel}`),this.client&&(t+=`&client=${this.client}`),this.libraries.length>0&&(t+=`&libraries=${this.libraries.join(",")}`),this.language&&(t+=`&language=${this.language}`),this.region&&(t+=`&region=${this.region}`),this.version&&(t+=`&v=${this.version}`),this.mapIds&&(t+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(t+=`&auth_referrer_policy=${this.authReferrerPolicy}`),t}deleteScript(){const t=document.getElementById(this.id);t&&t.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise(((t,e)=>{this.loadCallback((r=>{r?e(r.error):t(window.google)}))}))}importLibrary(t){return this.execute(),google.maps.importLibrary(t)}loadCallback(t){this.callbacks.push(t),this.execute()}setScript(){var t,e;if(document.getElementById(this.id))return void this.callback();const r={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(r).forEach((t=>!r[t]&&delete r[t])),(null===(e=null===(t=null===window||void 0===window?void 0:window.google)||void 0===t?void 0:t.maps)||void 0===e?void 0:e.importLibrary)||(t=>{let e,r,a,n="The Google Maps JavaScript API",s="google",i="importLibrary",o="__ib__",c=document,l=window;l=l[s]||(l[s]={});const u=l.maps||(l.maps={}),E=new Set,S=new URLSearchParams,d=()=>e||(e=new Promise(((i,l)=>{return d=this,p=void 0,h=function*(){var d;for(a in yield r=c.createElement("script"),r.id=this.id,S.set("libraries",[...E]+""),t)S.set(a.replace(/[A-Z]/g,(t=>"_"+t[0].toLowerCase())),t[a]);S.set("callback",s+".maps."+o),r.src=this.url+"?"+S,u[o]=i,r.onerror=()=>e=l(Error(n+" could not load.")),r.nonce=this.nonce||(null===(d=c.querySelector("script[nonce]"))||void 0===d?void 0:d.nonce)||"",c.head.append(r)},new((I=void 0)||(I=Promise))((function(t,e){function r(t){try{n(h.next(t))}catch(t){e(t)}}function a(t){try{n(h.throw(t))}catch(t){e(t)}}function n(e){var n;e.done?t(e.value):(n=e.value,n instanceof I?n:new I((function(t){t(n)}))).then(r,a)}n((h=h.apply(d,p||[])).next())}));var d,p,I,h})));u[i]?console.warn(n+" only loads once. Ignoring:",t):u[i]=(t,...e)=>E.add(t)&&d().then((()=>u[i](t,...e)))})(r);const a=this.libraries.map((t=>this.importLibrary(t)));a.length||a.push(this.importLibrary("core")),Promise.all(a).then((()=>this.callback()),(t=>{const e=new ErrorEvent("error",{error:t});this.loadErrorCallback(e)}))}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(t){if(this.errors.push(t),this.errors.length<=this.retries){const t=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${t} ms.`),setTimeout((()=>{this.deleteScript(),this.setScript()}),t)}else this.onerrorEvent=t,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach((t=>{t(this.onerrorEvent)})),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version)return console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),void this.callback();this.loading||(this.loading=!0,this.setScript())}}}const{GOOGLE:{MAPS:{LIBRARIES:{GEOCODING:ya,PLACES:ma},VERSION:Aa}}}=n;var Ta=function(t={}){let e=[];const r=c(),a=new wa({apiKey:r?.googleMaps?.apiKey,version:Aa});return{buildLocation:async function(t){try{const r=e.find((e=>e.description===t));if(!r)throw new Error("Place not found");const{place_id:n,description:s}=r,{Geocoder:i}=await a.importLibrary(ya),o=new i;return new Promise((t=>{o.geocode({placeId:n},((e=[],r)=>{if("OK"===r){const r=e[0].address_components.find((t=>t.types.includes("country"))),a=r?r.short_name:null;t({id:n,en:s,code:a})}else t({id:n,en:s,code:null})})).catch((()=>t({id:n,en:s,code:null})))}))}catch(t){return await y(t),null}},isValidPlace:function(t){return e.some((e=>e.description===t))},predictPlaces:async function(r){try{const{AutocompleteService:n}=await a.importLibrary(ma),s=new n;return new Promise((a=>{s.getPlacePredictions({...t,input:r,types:["(cities)"]},((t=[],r)=>{"OK"===r?(e=t,a(t)):a([])})).catch((()=>a([])))}))}catch(t){return await y(t),[]}}}},fa=async(t,e,r={ignoreAnswersAuthors:!1})=>{try{let a={};return a=await pa.read(t),a=await Ke.handlers.authors.readQuestionAuthors(a,e,r),a}catch(t){throw await y(t),new Error(`Cannot build question: ${t.message}`)}};const{ARTICLES:{TYPE:Na},COURSES:{TYPE:$a},CUSTOM_CARD:{TYPE:Pa},COMMUNITY:{TYPE:Ra},EVENTS:{TYPE:Oa},LISTS:{TYPE:La},QUESTIONS:{TYPE:Ca},LEARNING_HUB:{TYPE:Ua}}=n.CONTENTFUL,_a={ClosedHidden:"closed-hidden",ClosedVisible:"closed-visible",OpenHidden:"open-hidden",OpenVisible:"open-visible"},va=t=>t&&t.url?(Object.assign(t,{aspect:"responsiveCard",query:"q=90&fit=fill"}),t):null,ba=t=>t&&t.url?`${t.url}?w=100&h=100&fit=thumb&f=center`:null,Da=t=>t.toLowerCase().split(" ")[0],Ma={[Na]:async t=>{const{authorIds:e,authorTag:r,image:a,publishedDate:n,readingTime:s,slug:i,title:o}=t,c=await Ke.handlers.authors.readAuthors(e),l=c&&c.length?c:r?[Da(r)]:null;return{banner:va(a),contributors:l,publishedDate:n,readingTime:s,slug:i,title:o}},[Ra]:async t=>{const{title:e,slug:r,bannerSection:a,privacy:n,createdAt:s}=t,i=[_a.ClosedVisible,_a.ClosedHidden].includes(n),o=[_a.OpenVisible,_a.ClosedVisible].includes(n);return{banner:a?.image?va(a.image):null,slug:r,title:e,privacy:n,isPrivate:i,isVisible:o,createdAt:s}},[$a]:async(t,e)=>{const{banner:r,freeCourse:a,partnershipDetails:n,slug:s,title:i,registered:o,courseType:c}=t,l={banner:va(r),slug:s,title:i,pill:a?"free":"premium",registered:!!o,courseType:c};if(n){const{partners:t}=n;if(t)if(t.length>1){let e=[];for(let r=0;r<t.length;r++)e.push(t[r].title);l.partner=e}else l.partner=[t[0].title]}if(void 0===o&&e){const[t]=await Ke.userProducts.list({courseSlug:s,isEnrolled:!0,scope:"active"});l.registered=!!t}return l},[Pa]:t=>{const{authorName:e,authorImage:r,icon:a,image:n,label:s,link:i,primaryText:o}=t;return{...t,banner:n?va(n):null,customIcon:a?a.toLowerCase():null,customLabel:s,contributors:e?[{name:e,image:r?{thumbnail:ba(r)}:null}]:null,slug:i,text:o}},[Oa]:async(t,e)=>{const{bannerImage:r,defaultStartDate:a,isEventOngoing:n,slug:s,speakers:i,title:o,registered:c}=t,l=new Date(a),u=!!l&&l<new Date;if(i&&i.length)for(const t of i)t.image=ba(t.image);const E={banner:va(r),dateHasPassed:u,title:o,slug:s,isOngoingEvent:n,contributors:i,startDate:l,registered:!!c};if(void 0===c&&e){const[t]=await Ke.userEvents.list({eventSlug:s});E.registered=!!t}return E},[La]:async t=>{const{hero:e,slug:r,title:a}=t;return{banner:va(e),slug:r,title:a}},[Ca]:async t=>{const{answers:e,authorId:r,createdAt:a,slug:n,title:s}=t;let i=null;if(r){const t=await Ke.users.read(r);t&&(i=t)}return{answers:e&&e.length?e.length:0,contributors:i?[i]:[],createdAt:a,slug:n,title:s}},[Ua]:t=>{const{bannerSection:e,customLabel:r,slug:a,title:n}=t;return{banner:va(e.image),slug:a,title:n,customLabel:r}},people:t=>{const{id:e,name:r,jobTitle:a,location:n,image:s,customLink:i}=t;return{profile:s,slug:i?.link||e,title:r,text:a,secondaryText:n,customLinkText:i?.text}}};var Ba=async({contentType:t,...e}={},r)=>{try{if(!Ma[t])throw new Error("Content type not supported");if("function"!=typeof Ma[t])throw new Error("No builder function for content type");return"people"!==t&&e.sys&&e.sys.type&&"Link"===e.sys.type&&(e=await ea.read(t,e)),{contentType:t,...await Ma[t](e,r)}}catch(t){throw await y(t),new Error(`Cannot build carousel card: ${t.message}`)}},ka=async(t,e,r={})=>{try{if(!t.replies||0===t.replies.length)return t.replies=[],t;t.replies.sort(((t,e)=>new Date(t.createdAt)-new Date(e.createdAt))),t.totalReplies=t.totalReplies||t.replies.length;let a=t.replies;if(r.limit&&r.pageNumber){const e=r.limit*(r.pageNumber-1);a=t.replies.slice(e,e+r.limit)}for(const r of a){if(r.authorId===t.authorId){r.author=t.author,r.userLiked=!1;continue}r.author=r.authorId&&await Ft(r.authorId)||{};const[a]=e?await Zt({contentType:n.CONTENTFUL.REPLIES.TYPE,contentSlug:r.slug}):[null];r.userLiked=!!a}return t.replies=a,t}catch(t){throw await y(t),new Error(`Cannot build replies for answer: ${t.message}`)}};const Ga="success",qa="error";var xa=t=>async e=>{const{contentType:r}=e;switch(r){case"event":try{return await wt.eventRegistrations.create({eventSlug:e.slug,expectation:null,userEmail:t.email,startsAt:new Date(e.startDate).toISOString()}),Ga}catch(t){return reportError(new Error(`Error registering for event: ${JSON.stringify(t)}`)),qa}case"microcourse":try{return await wt.userProducts.create({id:t.id,courseSlug:e.slug,email:t.email,courseType:e.courseType}),Ga}catch(t){return reportError(new Error(`Error registering for microcourse: ${JSON.stringify(t)}`)),qa}case"communityPage":try{return await Yr.communities.join(e.slug,{...t.image.thumbnail&&{thumbnail:t.image.thumbnail},...t.jobTitle&&{jobTitle:t.jobTitle},...t.location&&{location:{...t.location}},...t.organization&&{organization:t.organization}}),Ga}catch(t){return reportError(new Error(`Error joining community: ${JSON.stringify(t)}`)),qa}default:return qa}},Va=l(408);const Ya=t=>t&&Va.Buffer.from(t,"base64").toString("ascii");function ja({contentContext:t=null,errorsContext:n=null,googleMapsContext:c=null,gtmContext:l=null,origin:u}){try{const g=(t=>{let e=null;t?e=t:"undefined"!=typeof window&&(e=window.origin||window.location.origin),e||new Error("Cannot select environment: Website not defined");let r=null;const a=e.match(d);return a?r=a[1].split(p)[0]:e===E?r=I:e.includes(S)&&(r=h),r||new Error(`Cannot select environment: No rule for website ${e}`),r})(u);return t&&(0,e.setContext)(Object.assign({},t,{environment:g})),n&&(0,r.setContext)(Object.assign({},n,{environment:g})),c&&(({apiKey:t})=>{o.googleMaps={apiKey:t}})(Object.assign({},c,{environment:g})),l&&((0,a.setContext)(Object.assign({},l,{environment:g})),(0,a.setupGTM)()),(({environment:t})=>{const e=(t=>{if(!t)throw new Error("Cannot map environment: Environment not defined");if(!s[t])throw new Error(`Cannot map environment: No mapping found for environment ${t}`);return s[t]})(t);o.emailIds=i[e]})(Object.assign({},{environment:g})),g}catch(t){console.warn(`Cannot load SDK: ${t.message}`)}}}(),u}()}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apolitical/sdk",
3
- "version": "10.3.4",
3
+ "version": "10.3.5-ac.0",
4
4
  "description": "Browser library to interact with Apolitical's APIs",
5
5
  "author": "Apolitical Group Limited <engineering@apolitical.co>",
6
6
  "license": "MIT",