@apolitical/sdk 11.0.5 → 11.0.6

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