@apolitical/component-library 4.5.8 → 4.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -3
- package/index.mjs +22 -4
- package/package.json +1 -1
- package/style.css +1 -1
package/index.js
CHANGED
|
@@ -28,7 +28,7 @@ Check the render method of \``+O+"`."}return""}}function yh(O){{if(O!==void 0){v
|
|
|
28
28
|
|
|
29
29
|
Check your code at `+se+":"+ce+"."}return""}}var No={};function Dh(O){{var se=Po();if(!se){var ce=typeof O=="string"?O:O.displayName||O.name;ce&&(se=`
|
|
30
30
|
|
|
31
|
-
Check the top-level render call using <`+ce+">.")}return se}}function Ro(O,se){{if(!O._store||O._store.validated||O.key!=null)return;O._store.validated=!0;var ce=Dh(se);if(No[ce])return;No[ce]=!0;var Ce="";O&&O._owner&&O._owner!==or.current&&(Ce=" It was passed a child from "+F(O._owner.type)+"."),jn(O),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ce,Ce),jn(null)}}function Mo(O,se){{if(typeof O!="object")return;if(ke(O))for(var ce=0;ce<O.length;ce++){var Ce=O[ce];oi(Ce)&&Ro(Ce,se)}else if(oi(O))O._store&&(O._store.validated=!0);else if(O){var Oe=D(O);if(typeof Oe=="function"&&Oe!==O.entries)for(var Le=Oe.call(O),je;!(je=Le.next()).done;)oi(je.value)&&Ro(je.value,se)}}}function Ch(O){{var se=O.type;if(se==null||typeof se=="string")return;var ce;if(typeof se=="function")ce=se.propTypes;else if(typeof se=="object"&&(se.$$typeof===l||se.$$typeof===h))ce=se.propTypes;else return;if(ce){var Ce=F(se);Te(ce,O.props,"prop",Ce,O)}else if(se.PropTypes!==void 0&&!si){si=!0;var Oe=F(se);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Oe||"Unknown")}typeof se.getDefaultProps=="function"&&!se.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xh(O){{for(var se=Object.keys(O.props),ce=0;ce<se.length;ce++){var Ce=se[ce];if(Ce!=="children"&&Ce!=="key"){jn(O),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ce),jn(null);break}}O.ref!==null&&(jn(O),E("Invalid attribute `ref` supplied to `React.Fragment`."),jn(null))}}function Io(O,se,ce,Ce,Oe,Le){{var je=I(O);if(!je){var Be="";(O===void 0||typeof O=="object"&&O!==null&&Object.keys(O).length===0)&&(Be+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var at=yh(Oe);at?Be+=at:Be+=Po();var Ze;O===null?Ze="null":ke(O)?Ze="array":O!==void 0&&O.$$typeof===t?(Ze="<"+(F(O.type)||"Unknown")+" />",Be=" Did you accidentally export a JSX literal instead of a component?"):Ze=typeof O,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Ze,Be)}var Ge=ii(O,se,ce,Oe,Le);if(Ge==null)return Ge;if(je){var yt=se.children;if(yt!==void 0)if(Ce)if(ke(yt)){for(var On=0;On<yt.length;On++)Mo(yt[On],O);Object.freeze&&Object.freeze(yt)}else E("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Mo(yt,O)}return O===r?xh(Ge):Ch(Ge),Ge}}function wh(O,se,ce){return Io(O,se,ce,!0)}function Eh(O,se,ce){return Io(O,se,ce,!1)}var kh=Eh,_h=wh;lr.Fragment=r,lr.jsx=kh,lr.jsxs=_h}()),lr}process.env.NODE_ENV==="production"?ss.exports=Ph():ss.exports=Nh();var d=ss.exports;const _c=()=>{const[e,t]=y.useState(window.location.pathname),n=()=>{const r=window.location.pathname;t(r)};return y.useEffect(()=>(window.addEventListener("popstate",n),()=>{window.removeEventListener("popstate",n)}),[]),e},Yn=(e,t)=>{const n=y.useRef(!1);y.useEffect(()=>{n.current?e():n.current=!0},t)};function Bc(e,t,n){var r=this,a=y.useRef(null),i=y.useRef(0),s=y.useRef(null),o=y.useRef([]),l=y.useRef(),u=y.useRef(),c=y.useRef(e),h=y.useRef(!0);c.current=e;var p=typeof window<"u",m=!t&&t!==0&&p;if(typeof e!="function")throw new TypeError("Expected a function");t=+t||0;var g=!!(n=n||{}).leading,f=!("trailing"in n)||!!n.trailing,D="maxWait"in n,v="debounceOnServer"in n&&!!n.debounceOnServer,E=D?Math.max(+n.maxWait||0,t):null;y.useEffect(function(){return h.current=!0,function(){h.current=!1}},[]);var B=y.useMemo(function(){var x=function(I){var z=o.current,w=l.current;return o.current=l.current=null,i.current=I,u.current=c.current.apply(w,z)},k=function(I,z){m&&cancelAnimationFrame(s.current),s.current=m?requestAnimationFrame(I):setTimeout(I,z)},T=function(I){if(!h.current)return!1;var z=I-a.current;return!a.current||z>=t||z<0||D&&I-i.current>=E},S=function(I){return s.current=null,f&&o.current?x(I):(o.current=l.current=null,u.current)},q=function I(){var z=Date.now();if(T(z))return S(z);if(h.current){var w=t-(z-a.current),F=D?Math.min(w,E-(z-i.current)):w;k(I,F)}},N=function(){if(p||v){var I=Date.now(),z=T(I);if(o.current=[].slice.call(arguments),l.current=r,a.current=I,z){if(!s.current&&h.current)return i.current=a.current,k(q,t),g?x(a.current):u.current;if(D)return k(q,t),x(a.current)}return s.current||k(q,t),u.current}};return N.cancel=function(){s.current&&(m?cancelAnimationFrame(s.current):clearTimeout(s.current)),i.current=0,o.current=a.current=l.current=s.current=null},N.isPending=function(){return!!s.current},N.flush=function(){return s.current?S(Date.now()):u.current},N},[g,D,t,E,f,m,p,v]);return B}function Fc(e,t,n){var r=n===void 0?{}:n,a=r.leading,i=r.trailing;return Bc(e,t,{maxWait:t,leading:a===void 0||a,trailing:i===void 0||i})}let ui;const tr=(e=!0,t=!1,n="window")=>{if(!e)return;const[r,a]=y.useState(0)||[!1,()=>{}],i=n==="window"?[]:[n];y.useEffect(()=>(o(),window.addEventListener("resize",u),window.addEventListener("hashchange",u),window.addEventListener("hiddenSectionVisible",l),()=>{clearTimeout(ui),u.flush(),window.removeEventListener("resize",u),window.removeEventListener("hashchange",u),window.removeEventListener("hiddenSectionVisible",l)}),i);const s=()=>{if(n)return n==="window"?window.innerWidth:n.offsetWidth},o=()=>{a(s())},l=({detail:c})=>{const{id:h}=c;n==="window"||!n.closest(`#${h}`)||s()===r||o()},u=Fc(()=>{s()!==r&&(t&&(clearTimeout(ui),document.body.classList.add("is-resizing"),ui=setTimeout(()=>{document.body.classList.remove("is-resizing")},550)),o())},500,{leading:!0});return r},Ac=({scrollPosition:e=0,offset:t={down:0,up:10},callbacks:{scrollDown:n=()=>{},scrollUp:r=()=>{}}})=>{if(!window)return;const[a,i]=y.useState({current:0,past:0})||[!1,()=>{}],[s,o]=y.useState({scrollDown:!1,scrollUp:!1})||[!1,()=>{}];y.useEffect(()=>(l(),window.addEventListener("scroll",u),()=>{u.flush(),window.removeEventListener("scroll",u)}),[]);const l=()=>{const c=window.scrollY,h=a.current,p=c-h,m=p>0?"down":"up";if(i({current:c,past:h}),m==="down"){c>=e+t.down&&!s.scrollDown&&(!s.scrollUp||p>t.up)&&(n(),o({scrollUp:!1,scrollDown:!0}));return}Math.abs(p)>=t.up&&!s.scrollUp&&(r(),o({scrollUp:!0,scrollDown:!1}))},u=Fc(()=>{l()},250);return a},$s=(e=[],t=!0)=>{e=Array.isArray(e)?e:[e];const n=y.useRef(!1);Yn(()=>{if(window&&window.location&&window.location.hash){if(n.current)return;const r=document.getElementById(window.location.hash.replace("#",""));r&&(r.scrollIntoView(t?{behavior:"smooth"}:null),n.current=!0)}},e)},Ls=(e=!1)=>{if(!e)return{showTooltip:!1,tooltipProps:{}};const[t,n]=y.useState(!1);return{showTooltip:t,tooltipProps:{onMouseOver:()=>n(!0),onMouseOut:()=>n(!1),onFocus:()=>n(!0),onBlur:()=>n(!1),tabIndex:0}}};const qo={},An=y.forwardRef(({id:e,styling:t={},isOpen:n=!1,isLoading:r=!1,children:a,className:i="",functions:s={},callbacks:o={},...l},u)=>{const c=ue.useIntl(),h=y.useRef(null),p=u||h,[m,g]=y.useState(n?"open":"hidden"),{extraPadding:f=!0,hasPointer:D=!1,hasForm:v=!1}=t,{onOpen:E=()=>{},onClose:B=()=>{}}=o;e||(e=Date.now().toString());const x=qo[e];y.useEffect(()=>{const q=p==null?void 0:p.current;if(q)return q.addEventListener("transitionend",k),q.addEventListener("keydown",T),()=>{q.removeEventListener("transitionend",k),q.removeEventListener("keydown",T)}},[]);const k=({propertyName:q})=>{q==="opacity"&&(x!==!1&&clearTimeout(x),g(N=>(N==="open"?E():N==="closed"&&B(),N==="opening"?"open":N==="closing"?"closed":N==="closed"?"hidden":N)))},T=q=>{q.key==="Escape"&&(q.stopPropagation(),q.preventDefault(),g("closing"))};Yn(()=>{x!==!1&&clearTimeout(x);let q="open";n?g("opening"):(g("closing"),q="hidden"),qo[e||""]=setTimeout(()=>{g(q)},300)},[n]);const S={...l};return s&&s.onBlur&&(S.onBlur=s.onBlur),d.jsx("aside",{ref:p,className:Y("tooltip text-medium",m,i,{loading:r,"extra-padding":f,"has-pointer":D,bottom:D==="bottom","has-form":v}),...S,children:d.jsx("div",{className:"content",hidden:m==="hidden",children:r?d.jsx("p",{children:c.formatMessage({id:"tooltip_loading"})}):typeof a=="string"?d.jsx("p",{children:a}):a})})}),Ir=(e,t)=>{Array.isArray(t)||(t=[t]);const n=bn(e);return t.forEach(({type:r,value:a})=>{Bh(n,r,a)}),n},Tc=e=>{const t=[];return e.forEach(n=>{const r=parseInt(n);isNaN(r)||t.push(r)}),t.sort((n,r)=>n-r)},Sc=(e,t,n)=>{let r=n.mobile;for(const a in t){const i=parseInt(String(t[a]));if(e>=i)r=n[i];else if(e<i)break}return r},jc=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),Oc=(e="")=>e.replace(/(?:^\w|[A-Z]|\b\w)/g,t=>t.toUpperCase()).replace(/[&\s]+/g,""),Pc=(e="")=>e.charAt(0).toUpperCase()+e.slice(1),Rh=(e="")=>e.replace(/(?:^\w|[A-Z]|\b\w)/g,t=>t.toUpperCase()),It="https://storage.googleapis.com/apolitical-assets/",$n={general:"hello@apolitical.co",support:"concierge@apolitical.co","data-protection":{default:"dpo@apolitical.co",eu:"dpo.agl@apolitical.foundation"}},gr={ARTICLE:"microcourseArticle",DISCUSSION:"microcourseDiscussion",QUIZ:"assessmentQuiz"},os="SU:",Nc="Invalid token error: Logging user out...",Mh="200,000+",Ih="160+",Br=/@{{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})}}/g,Rc=new RegExp("(?<=^|\\s)@([A-Za-z]+(?:[- ]?[A-Za-z]*)*)$");function Mc(e){return e?{"--icon":`url(${It}icons/${e}.svg)`}:{}}const pn={milliseconds:{inSecond:1e3,inMinute:6e4,inHour:36e5,inDay:864e5},year:{weeks:52,days:365}},Ic=(e,t="en")=>new Date(e).toLocaleString(t,{day:"numeric",month:"short"}),zs=(e,t="en")=>new Date(e).toLocaleString(t,{weekday:"long",day:"numeric",month:"short",year:"numeric"}),us=e=>{let t;const n=xa(),r=xa(new Date(e));try{t=n.getTime()-r.getTime()}catch{return""}const a=t/pn.milliseconds.inHour,i=Math.floor(t/pn.milliseconds.inDay);if(i<1)return a<1?{path:"now"}:{path:"hours",number:Math.floor(a)};if(i<7)return{path:"days",number:i};const s=Math.floor(i/7);return s<=pn.year.weeks?{path:"weeks",number:s}:{path:"years",number:Math.floor(i/pn.year.days)}},xa=e=>{const n=(e||new Date).toUTCString();return new Date(n)},$h=(e,t,n)=>{let r;const a=xa(),i=xa(new Date(e));try{r=a.getTime()-i.getTime()}catch{return!1}switch(n){case"seconds":return r/pn.milliseconds.inSecond<=t;case"minutes":return r/pn.milliseconds.inMinute<=t;case"hours":return r/pn.milliseconds.inHour<=t}return!1},Lh=(e,t)=>{const n=new Date(e);return Math.abs(new Date().getTime()-n.getTime())/(1e3*60*60*24)<t},zh=e=>new Promise(t=>setTimeout(t,e)),qh=()=>{let e=!1;return typeof window<"u"&&(e=!!(window&&window.location&&window.location.href&&window.location.href.includes("localhost"))),e},nr={apolitical:"Apolitical",dates_now:"now",dates_hours:"{number}h",dates_days:"{number}d",dates_weeks:"{number}w",dates_years:"{number}y",card_carousel_viewAll:"View all",card_label_communityPage:"Community",card_label_event:"Event",card_label_learningHub:"Programme",card_label_listPage:"List",card_label_microcourse:"Course",card_label_qaQuestion:"Q&A",card_label_solutionArticle:"Article",card_bootcamp:"Email boot camp",card_ended:"Ended",card_new:"New",card_registered:"Registered",card_partner:"{partner} and {number} more",card_contributors_event:"Multiple speakers",card_contributors_solutionArticle:"Multiple authors",card_answers:"{number, plural, =0 {0 answers} one {# answer} other {# answers}}",card_time_ago:"{time} ago",card_time_read:"{time} min read",card_watch:"Watch recording",card_member_type_owner:"Admin",card_member_type_member:"Member",card_member_count:"{count} members",card_cta_people:"View profile",card_cta_communityPage:"Join now",card_cta_event:"Register now",card_cta_microcourse:"Enrol now",card_cta_communityPage_loading:"Joining...",card_cta_event_loading:"Registering...",card_cta_microcourse_loading:"Enrolling...",card_cta_communityPage_done:"Joined",card_cta_event_done:"Registered",card_cta_microcourse_done:"Enrolled",carousel_pagination_previous:"Previous",carousel_pagination_next:"Next",carousel_pagination_page:"Page {number} of {total}",carousel_pagination_aria_live:"{direction} {count} cards available",activitySection_notFoundError:"Post not found",activitiesFeed_sorting_label:"Choose feed sorting method",activitiesFeed_rankingMethod_recent:"Recent",activitiesFeed_rankingMethod_popular:"Popular",activitiesFeed_rankingMethod_internalTesting:"Apolitical Testing",communityDetails_members:"Members",communityDetails_viewAll:"View all",communityDetails_invite:"Invite colleagues",community_joinToPost:"Join community to create a post.",joinCommunityButton:"Join community",joinCommunityButton_short:"Join",joinCommunityButton_joining:"Joining...",joinCommunityButton_member:"Member",joinCommunityButton_member_aria:"Leave community",joinCommunityButton_leave:"Leave",joinCommunityButton_leaving:"Leaving...",joinCommunityButton_closed_tooltip:"Please contact the admin of this closed community if you would like to join it.",joinCommunityButton_aria_live:"You are {action} this community",member_apolitical:"Apolitical",member_community:"Community post",membersList:"Members",membersList_admin:"Admin",courseStructure_section:"{number, plural, =0 {Start here} other {Section #}}",courseStructure_section_end:"End here",courseStructure_time_left:"left",courseStructure_time_completed:"Completed",courseProgression_done:"<percent>{number}%</percent> done",courseProgression_timeLeft:"left","lessonType_analyse-data":"Analyse data","lessonType_analyse-scenarios":"Analyse scenarios","lessonType_attend-webinar":"Attend webinar","lessonType_brainstorm-ideas":"Brainstorm ideas","lessonType_discuss-with-peers":"Discuss with peers","lessonType_discuss-with-team":"Discuss with team","lessonType_do-activity":"Do activity","lessonType_do-assessment":"Do assessment","lessonType_explore-casebook":"Explore casebook","lessonType_fill-out-workbook":"Fill out workbook","lessonType_fill-out-worksheet":"Fill out worksheet","lessonType_investigate-interview":"Investigate interview","lessonType_listen-to-audio":"Listen to audio","lessonType_listen-to-audiocast":"Listen to audiocast","lessonType_listen-to-podcast":"Listen to podcast","lessonType_read-article":"Read article","lessonType_read-article-by-expert":"Read article by expert","lessonType_read-article-by-public-servant":"Read article by public servant","lessonType_read-conclusion":"Read conclusion","lessonType_read-infographic":"Read infographic","lessonType_read-introduction":"Read introduction","lessonType_read-resource":"Read resource","lessonType_reflect-on-content":"Reflect on content","lessonType_share-experiences":"Share experiences","lessonType_take-quiz":"Take quiz","lessonType_use-toolkit":"Use toolkit","lessonType_watch-video":"Watch video","lessonType_watch-webinar":"Watch webinar",markCompleteButton:"Mark as complete",markCompleteButton_completed:"Lesson complete",discussion_action_answer:"answer",discussion_action_comment:"comment",discussion_action_post:"post",discussion_action_response:"response",discussion_action_reply:"reply",discussion_action_question:"question",discussion_edited:"Edited",discussion_delete_title:"Delete {action}",discussion_delete_text:"<p>Are you sure you want to delete your {action}?</p><p>This can't be undone.</p>",discussion_delete_cancel:"Cancel",discussion_delete_delete:"Delete",discussion_delete_error:"We are unable to delete your {action} at the moment. Please try again later or contact us if problem persists.",discussion_reply:"Reply",discussion_report_subject:"Report a post on Apolitical",discussion_report_body:`I'd like to report the {contentType} <{contentSlug}> at {contentUrl}.
|
|
31
|
+
Check the top-level render call using <`+ce+">.")}return se}}function Ro(O,se){{if(!O._store||O._store.validated||O.key!=null)return;O._store.validated=!0;var ce=Dh(se);if(No[ce])return;No[ce]=!0;var Ce="";O&&O._owner&&O._owner!==or.current&&(Ce=" It was passed a child from "+F(O._owner.type)+"."),jn(O),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ce,Ce),jn(null)}}function Mo(O,se){{if(typeof O!="object")return;if(ke(O))for(var ce=0;ce<O.length;ce++){var Ce=O[ce];oi(Ce)&&Ro(Ce,se)}else if(oi(O))O._store&&(O._store.validated=!0);else if(O){var Oe=D(O);if(typeof Oe=="function"&&Oe!==O.entries)for(var Le=Oe.call(O),je;!(je=Le.next()).done;)oi(je.value)&&Ro(je.value,se)}}}function Ch(O){{var se=O.type;if(se==null||typeof se=="string")return;var ce;if(typeof se=="function")ce=se.propTypes;else if(typeof se=="object"&&(se.$$typeof===l||se.$$typeof===h))ce=se.propTypes;else return;if(ce){var Ce=F(se);Te(ce,O.props,"prop",Ce,O)}else if(se.PropTypes!==void 0&&!si){si=!0;var Oe=F(se);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Oe||"Unknown")}typeof se.getDefaultProps=="function"&&!se.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xh(O){{for(var se=Object.keys(O.props),ce=0;ce<se.length;ce++){var Ce=se[ce];if(Ce!=="children"&&Ce!=="key"){jn(O),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ce),jn(null);break}}O.ref!==null&&(jn(O),E("Invalid attribute `ref` supplied to `React.Fragment`."),jn(null))}}function Io(O,se,ce,Ce,Oe,Le){{var je=I(O);if(!je){var Be="";(O===void 0||typeof O=="object"&&O!==null&&Object.keys(O).length===0)&&(Be+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var at=yh(Oe);at?Be+=at:Be+=Po();var Ze;O===null?Ze="null":ke(O)?Ze="array":O!==void 0&&O.$$typeof===t?(Ze="<"+(F(O.type)||"Unknown")+" />",Be=" Did you accidentally export a JSX literal instead of a component?"):Ze=typeof O,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Ze,Be)}var Ge=ii(O,se,ce,Oe,Le);if(Ge==null)return Ge;if(je){var yt=se.children;if(yt!==void 0)if(Ce)if(ke(yt)){for(var On=0;On<yt.length;On++)Mo(yt[On],O);Object.freeze&&Object.freeze(yt)}else E("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Mo(yt,O)}return O===r?xh(Ge):Ch(Ge),Ge}}function wh(O,se,ce){return Io(O,se,ce,!0)}function Eh(O,se,ce){return Io(O,se,ce,!1)}var kh=Eh,_h=wh;lr.Fragment=r,lr.jsx=kh,lr.jsxs=_h}()),lr}process.env.NODE_ENV==="production"?ss.exports=Ph():ss.exports=Nh();var d=ss.exports;const _c=()=>{const[e,t]=y.useState(window.location.pathname),n=()=>{const r=window.location.pathname;t(r)};return y.useEffect(()=>(window.addEventListener("popstate",n),()=>{window.removeEventListener("popstate",n)}),[]),e},Yn=(e,t)=>{const n=y.useRef(!1);y.useEffect(()=>{n.current?e():n.current=!0},t)};function Bc(e,t,n){var r=this,a=y.useRef(null),i=y.useRef(0),s=y.useRef(null),o=y.useRef([]),l=y.useRef(),u=y.useRef(),c=y.useRef(e),h=y.useRef(!0);c.current=e;var p=typeof window<"u",m=!t&&t!==0&&p;if(typeof e!="function")throw new TypeError("Expected a function");t=+t||0;var g=!!(n=n||{}).leading,f=!("trailing"in n)||!!n.trailing,D="maxWait"in n,v="debounceOnServer"in n&&!!n.debounceOnServer,E=D?Math.max(+n.maxWait||0,t):null;y.useEffect(function(){return h.current=!0,function(){h.current=!1}},[]);var B=y.useMemo(function(){var x=function(I){var z=o.current,w=l.current;return o.current=l.current=null,i.current=I,u.current=c.current.apply(w,z)},k=function(I,z){m&&cancelAnimationFrame(s.current),s.current=m?requestAnimationFrame(I):setTimeout(I,z)},T=function(I){if(!h.current)return!1;var z=I-a.current;return!a.current||z>=t||z<0||D&&I-i.current>=E},S=function(I){return s.current=null,f&&o.current?x(I):(o.current=l.current=null,u.current)},q=function I(){var z=Date.now();if(T(z))return S(z);if(h.current){var w=t-(z-a.current),F=D?Math.min(w,E-(z-i.current)):w;k(I,F)}},N=function(){if(p||v){var I=Date.now(),z=T(I);if(o.current=[].slice.call(arguments),l.current=r,a.current=I,z){if(!s.current&&h.current)return i.current=a.current,k(q,t),g?x(a.current):u.current;if(D)return k(q,t),x(a.current)}return s.current||k(q,t),u.current}};return N.cancel=function(){s.current&&(m?cancelAnimationFrame(s.current):clearTimeout(s.current)),i.current=0,o.current=a.current=l.current=s.current=null},N.isPending=function(){return!!s.current},N.flush=function(){return s.current?S(Date.now()):u.current},N},[g,D,t,E,f,m,p,v]);return B}function Fc(e,t,n){var r=n===void 0?{}:n,a=r.leading,i=r.trailing;return Bc(e,t,{maxWait:t,leading:a===void 0||a,trailing:i===void 0||i})}let ui;const tr=(e=!0,t=!1,n="window")=>{if(!e)return;const[r,a]=y.useState(0)||[!1,()=>{}],i=n==="window"?[]:[n];y.useEffect(()=>(o(),window.addEventListener("resize",u),window.addEventListener("hashchange",u),window.addEventListener("hiddenSectionVisible",l),()=>{clearTimeout(ui),u.flush(),window.removeEventListener("resize",u),window.removeEventListener("hashchange",u),window.removeEventListener("hiddenSectionVisible",l)}),i);const s=()=>{if(n)return n==="window"?window.innerWidth:n.offsetWidth},o=()=>{a(s())},l=({detail:c})=>{const{id:h}=c;n==="window"||!n.closest(`#${h}`)||s()===r||o()},u=Fc(()=>{s()!==r&&(t&&(clearTimeout(ui),document.body.classList.add("is-resizing"),ui=setTimeout(()=>{document.body.classList.remove("is-resizing")},550)),o())},500,{leading:!0});return r},Ac=({scrollPosition:e=0,offset:t={down:0,up:10},callbacks:{scrollDown:n=()=>{},scrollUp:r=()=>{}}})=>{if(!window)return;const[a,i]=y.useState({current:0,past:0})||[!1,()=>{}],[s,o]=y.useState({scrollDown:!1,scrollUp:!1})||[!1,()=>{}];y.useEffect(()=>(l(),window.addEventListener("scroll",u),()=>{u.flush(),window.removeEventListener("scroll",u)}),[]);const l=()=>{const c=window.scrollY,h=a.current,p=c-h,m=p>0?"down":"up";if(i({current:c,past:h}),m==="down"){c>=e+t.down&&!s.scrollDown&&(!s.scrollUp||p>t.up)&&(n(),o({scrollUp:!1,scrollDown:!0}));return}Math.abs(p)>=t.up&&!s.scrollUp&&(r(),o({scrollUp:!0,scrollDown:!1}))},u=Fc(()=>{l()},250);return a},$s=(e=[],t=!0)=>{e=Array.isArray(e)?e:[e];const n=y.useRef(!1);Yn(()=>{if(window&&window.location&&window.location.hash){if(n.current)return;const r=document.getElementById(window.location.hash.replace("#",""));r&&(r.scrollIntoView(t?{behavior:"smooth"}:null),n.current=!0)}},e)},Ls=(e=!1)=>{if(!e)return{showTooltip:!1,tooltipProps:{}};const[t,n]=y.useState(!1);return{showTooltip:t,tooltipProps:{onMouseOver:()=>n(!0),onMouseOut:()=>n(!1),onFocus:()=>n(!0),onBlur:()=>n(!1),tabIndex:0}}};const qo={},An=y.forwardRef(({id:e,styling:t={},isOpen:n=!1,isLoading:r=!1,children:a,className:i="",functions:s={},callbacks:o={},...l},u)=>{const c=ue.useIntl(),h=y.useRef(null),p=u||h,[m,g]=y.useState(n?"open":"hidden"),{extraPadding:f=!0,hasPointer:D=!1,hasForm:v=!1}=t,{onOpen:E=()=>{},onClose:B=()=>{}}=o;e||(e=Date.now().toString());const x=qo[e];y.useEffect(()=>{const q=p==null?void 0:p.current;if(q)return q.addEventListener("transitionend",k),q.addEventListener("keydown",T),()=>{q.removeEventListener("transitionend",k),q.removeEventListener("keydown",T)}},[]);const k=({propertyName:q})=>{q==="opacity"&&(x!==!1&&clearTimeout(x),g(N=>(N==="open"?E():N==="closed"&&B(),N==="opening"?"open":N==="closing"?"closed":N==="closed"?"hidden":N)))},T=q=>{q.key==="Escape"&&(q.stopPropagation(),q.preventDefault(),g("closing"))};Yn(()=>{x!==!1&&clearTimeout(x);let q="open";n?g("opening"):(g("closing"),q="hidden"),qo[e||""]=setTimeout(()=>{g(q)},300)},[n]);const S={...l};return s&&s.onBlur&&(S.onBlur=s.onBlur),d.jsx("aside",{ref:p,className:Y("tooltip text-medium",m,i,{loading:r,"extra-padding":f,"has-pointer":D,bottom:D==="bottom","has-form":v}),...S,children:d.jsx("div",{className:"content",hidden:m==="hidden",children:r?d.jsx("p",{children:c.formatMessage({id:"tooltip_loading"})}):typeof a=="string"?d.jsx("p",{children:a}):a})})}),Ir=(e,t)=>{Array.isArray(t)||(t=[t]);const n=bn(e);return t.forEach(({type:r,value:a})=>{Bh(n,r,a)}),n},Tc=e=>{const t=[];return e.forEach(n=>{const r=parseInt(n);isNaN(r)||t.push(r)}),t.sort((n,r)=>n-r)},Sc=(e,t,n)=>{let r=n.mobile;for(const a in t){const i=parseInt(String(t[a]));if(e>=i)r=n[i];else if(e<i)break}return r},jc=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),Oc=(e="")=>e.replace(/(?:^\w|[A-Z]|\b\w)/g,t=>t.toUpperCase()).replace(/[&\s]+/g,""),Pc=(e="")=>e.charAt(0).toUpperCase()+e.slice(1),Rh=(e="")=>e.replace(/(?:^\w|[A-Z]|\b\w)/g,t=>t.toUpperCase()),It="https://storage.googleapis.com/apolitical-assets/",$n={general:"hello@apolitical.co",support:"concierge@apolitical.co","data-protection":{default:"dpo@apolitical.co",eu:"dpo.agl@apolitical.foundation"}},gr={ARTICLE:"microcourseArticle",DISCUSSION:"microcourseDiscussion",QUIZ:"assessmentQuiz"},os="SU:",Nc="Invalid token error: Logging user out...",Mh="200,000+",Ih="160+",Br=/@{{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})}}/g,Rc=new RegExp("(?<=^|\\s)@([A-Za-z]+(?:[- ]?[A-Za-z]*)*)$");function Mc(e){return e?{"--icon":`url(${It}icons/${e}.svg)`}:{}}const pn={milliseconds:{inSecond:1e3,inMinute:6e4,inHour:36e5,inDay:864e5},year:{weeks:52,days:365}},Ic=(e,t="en")=>new Date(e).toLocaleString(t,{day:"numeric",month:"short"}),zs=(e,t="en")=>new Date(e).toLocaleString(t,{weekday:"long",day:"numeric",month:"short",year:"numeric"}),us=e=>{let t;const n=xa(),r=xa(new Date(e));try{t=n.getTime()-r.getTime()}catch{return""}const a=t/pn.milliseconds.inHour,i=Math.floor(t/pn.milliseconds.inDay);if(i<1)return a<1?{path:"now"}:{path:"hours",number:Math.floor(a)};if(i<7)return{path:"days",number:i};const s=Math.floor(i/7);return s<=pn.year.weeks?{path:"weeks",number:s}:{path:"years",number:Math.floor(i/pn.year.days)}},xa=e=>{const n=(e||new Date).toUTCString();return new Date(n)},$h=(e,t,n)=>{let r;const a=xa(),i=xa(new Date(e));try{r=a.getTime()-i.getTime()}catch{return!1}switch(n){case"seconds":return r/pn.milliseconds.inSecond<=t;case"minutes":return r/pn.milliseconds.inMinute<=t;case"hours":return r/pn.milliseconds.inHour<=t}return!1},Lh=(e,t)=>{const n=new Date(e);return Math.abs(new Date().getTime()-n.getTime())/(1e3*60*60*24)<t},zh=e=>new Promise(t=>setTimeout(t,e)),qh=()=>{let e=!1;return typeof window<"u"&&(e=!!(window&&window.location&&window.location.href&&window.location.href.includes("localhost"))),e},nr={apolitical:"Apolitical",dates_now:"now",dates_hours:"{number}h",dates_days:"{number}d",dates_weeks:"{number}w",dates_years:"{number}y",card_carousel_viewAll:"View all",card_label_communityPage:"Community",card_label_event:"Event",card_label_learningHub:"Programme",card_label_listPage:"List",card_label_microcourse:"Course",card_label_qaQuestion:"Q&A",card_label_solutionArticle:"Article",card_bootcamp:"Email boot camp",card_ended:"Ended",card_new:"New",card_registered:"Registered",card_partner:"{partner} and {number} more",card_contributors_event:"Multiple speakers",card_contributors_solutionArticle:"Multiple authors",card_answers:"{number, plural, =0 {0 answers} one {# answer} other {# answers}}",card_time_ago:"{time} ago",card_time_read:"{time} min read",card_watch:"Watch recording",card_member_type_owner:"Admin",card_member_type_member:"Member",card_member_count:"{count} members",card_cta_people:"View profile",card_cta_communityPage:"Join now",card_cta_event:"Register now",card_cta_microcourse:"Enrol now",card_cta_communityPage_loading:"Joining...",card_cta_event_loading:"Registering...",card_cta_microcourse_loading:"Enrolling...",card_cta_communityPage_done:"Joined",card_cta_event_done:"Registered",card_cta_microcourse_done:"Enrolled",carousel_pagination_previous:"Previous",carousel_pagination_next:"Next",carousel_pagination_page:"Page {number} of {total}",carousel_pagination_aria_live:"{direction} {count} cards available",activitySection_notFoundError:"Post not found",activitiesFeed_sorting_label:"Choose feed sorting method",activitiesFeed_rankingMethod_recent:"Recent",activitiesFeed_rankingMethod_popular:"Popular",activitiesFeed_rankingMethod_internalTesting:"Testing",communityDetails_members:"Members",communityDetails_viewAll:"View all",communityDetails_invite:"Invite colleagues",community_joinToPost:"Join community to create a post.",joinCommunityButton:"Join community",joinCommunityButton_short:"Join",joinCommunityButton_joining:"Joining...",joinCommunityButton_member:"Member",joinCommunityButton_member_aria:"Leave community",joinCommunityButton_leave:"Leave",joinCommunityButton_leaving:"Leaving...",joinCommunityButton_closed_tooltip:"Please contact the admin of this closed community if you would like to join it.",joinCommunityButton_aria_live:"You are {action} this community",member_apolitical:"Apolitical",member_community:"Community post",membersList:"Members",membersList_admin:"Admin",courseStructure_section:"{number, plural, =0 {Start here} other {Section #}}",courseStructure_section_end:"End here",courseStructure_time_left:"left",courseStructure_time_completed:"Completed",courseProgression_done:"<percent>{number}%</percent> done",courseProgression_timeLeft:"left","lessonType_analyse-data":"Analyse data","lessonType_analyse-scenarios":"Analyse scenarios","lessonType_attend-webinar":"Attend webinar","lessonType_brainstorm-ideas":"Brainstorm ideas","lessonType_discuss-with-peers":"Discuss with peers","lessonType_discuss-with-team":"Discuss with team","lessonType_do-activity":"Do activity","lessonType_do-assessment":"Do assessment","lessonType_explore-casebook":"Explore casebook","lessonType_fill-out-workbook":"Fill out workbook","lessonType_fill-out-worksheet":"Fill out worksheet","lessonType_investigate-interview":"Investigate interview","lessonType_listen-to-audio":"Listen to audio","lessonType_listen-to-audiocast":"Listen to audiocast","lessonType_listen-to-podcast":"Listen to podcast","lessonType_read-article":"Read article","lessonType_read-article-by-expert":"Read article by expert","lessonType_read-article-by-public-servant":"Read article by public servant","lessonType_read-conclusion":"Read conclusion","lessonType_read-infographic":"Read infographic","lessonType_read-introduction":"Read introduction","lessonType_read-resource":"Read resource","lessonType_reflect-on-content":"Reflect on content","lessonType_share-experiences":"Share experiences","lessonType_take-quiz":"Take quiz","lessonType_use-toolkit":"Use toolkit","lessonType_watch-video":"Watch video","lessonType_watch-webinar":"Watch webinar",markCompleteButton:"Mark as complete",markCompleteButton_completed:"Lesson complete",discussion_action_answer:"answer",discussion_action_comment:"comment",discussion_action_post:"post",discussion_action_response:"response",discussion_action_reply:"reply",discussion_action_question:"question",discussion_edited:"Edited",discussion_delete_title:"Delete {action}",discussion_delete_text:"<p>Are you sure you want to delete your {action}?</p><p>This can't be undone.</p>",discussion_delete_cancel:"Cancel",discussion_delete_delete:"Delete",discussion_delete_error:"We are unable to delete your {action} at the moment. Please try again later or contact us if problem persists.",discussion_reply:"Reply",discussion_report_subject:"Report a post on Apolitical",discussion_report_body:`I'd like to report the {contentType} <{contentSlug}> at {contentUrl}.
|
|
32
32
|
|
|
33
33
|
Please explain why you're reporting this post. Reasons could include: inappropriate language, harassment, spam, hate speech, false information, among others. Include as much detail as you feel comfortable.
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ Thank you for helping to protect the Apolitical community from abusive content.`
|
|
|
36
36
|
`);c(f.length<3?`${a.substring(0,400)}...`:f.slice(0,3).join(`
|
|
37
37
|
`))},[a]),y.useEffect(()=>{h==="ready-to-close"&&p("closing")},[h]);const m=({propertyName:f})=>{f==="max-height"&&p(D=>D==="opening"?"open":D==="closing"?"closed":D)};if(!a)return null;const g=["opening","open"].includes(h);return d.jsxs(Mt,{variant:"subtle",className:Y("hide-show-text-box",t),children:[d.jsxs("div",{ref:l,id:e,className:Y("content",h),children:[d.jsx(Rt,{options:{forceBlock:!0,...i},children:h==="closed"?u:a}),h!=="closed"&&s]}),d.jsx("p",{className:"cta",children:d.jsx(_e,{variant:"tertiary",icon:{icon:"navigation_arrow",position:"left",animate:!0},styling:{muted:!0},className:Y({"rotate-180":g}),onClick:()=>{p(g?"ready-to-close":"opening")},"aria-expanded":g,"aria-controls":e,children:g?r||o.formatMessage({id:"hideShowTextBox_hide"}):n||o.formatMessage({id:"hideShowTextBox_show"})})})]})};const am=({element:e="ul",layout:t="vertical",variant:n="default",items:r=[],styling:a={},className:i=""})=>{const{hasBorder:s=!1,zebraStriping:o=!1}=a;return y.createElement(e,{className:Y("icon-bulleted-list text-medium",n,i,{"has-border":s,"has-zebra-stripes":o,[t]:e!=="dl"}),children:r.map((l,u)=>{const c={wrapper:y.Fragment,forceInline:!0},h={"--icon":`url(${It}icons/${l.icon}.svg)`};return e==="dl"?d.jsxs(y.Fragment,{children:[d.jsx("dt",{style:h,children:d.jsx(Rt,{options:c,children:l.dt||""})},`dt-${u}`),d.jsx("dd",{children:typeof l.text=="string"?d.jsx(Rt,{options:c,children:l.text}):l.text},`dd-${u}`)]},`dl-${u}`):d.jsx("li",{style:h,children:typeof l.text=="string"?d.jsx(Rt,{options:c,children:l.text}):l.text},u)})})},nt=()=>y.Fragment,im=({children:e})=>d.jsx(Mt,{variant:"secondary",children:e}),sm=({children:e})=>typeof e=="object"&&Object.keys(e||{}).length===1?d.jsx("p",{className:"center",children:e}):d.jsx("div",{className:"center",children:e}),om=["span","strong","h1","h2","h3","h4","h5","h6","p"],um=({children:e})=>{const t=ue.useIntl();if(!e)return null;let n=t.formatMessage({id:"markdown_collapsibleSection_summary"});const r=[];for(const i of y.Children.toArray(e))if(!(!i||typeof i=="string"||typeof i=="number"))if(y.isValidElement(i)&&i.type==="summary"){if(i.props&&i.props.children){for(const s of y.Children.toArray(i.props.children))if(!(!s||typeof s=="string"||typeof s=="number")&&y.isValidElement(s)){const o=s.type;if(om.includes(o)){for(n=s.props.children;typeof n!="string"&&(Array.isArray(n)&&n[0].props&&n[0].props.children&&n[0].props.children[0]);)n=n[0].props.children[0];break}}}}else r.push(i);const a=n?n.toString():"";return d.jsx(Va,{label:a,className:["Sources","Resources"].includes(a)?"discrete-links":"",children:r.map(i=>i)})},lm=({children:e,...t})=>{if(t.class)switch(t.class){case"casestudy":return d.jsx(Mt,{variant:"secondary",children:e});case"general-textbox":case"highlight-box":return d.jsx(Mt,{variant:"primary",children:e});case"pink-textbox":return d.jsx(Mt,{variant:"tertiary",children:e});case"content":return typeof e=="object"&&Object.keys(e||{}).length===1?d.jsx("p",{children:e}):e;default:return d.jsx("div",{...t,children:e})}return d.jsx("div",{...t,children:e})},Ct=({children:e})=>d.jsx(d.Fragment,{children:e}),cm=e=>{const t=ue.useIntl(),n=Date.now().toString();let r="default";const a=e.src;return a.includes("youtube")||a.includes("vimeo")?r="video":a.includes("riddle")||a.includes("sli.do")?r="poll":a.includes("padlet")&&(r="padlet"),d.jsxs(d.Fragment,{children:[d.jsx(Ie,{element:"a",href:`#content-after-iframe-${n}`,onClick:i=>{var s;i.preventDefault(),i.stopPropagation(),(s=document.getElementById(`content-after-iframe-${n}`))==null||s.scrollIntoView({behavior:"smooth"})},children:t.formatMessage({id:`markdown_skip${r==="default"?"":`_${r}`}`})}),d.jsx("iframe",{...e,title:t.formatMessage({id:`markdown_iframe${r==="default"?"":`_${r}`}`})}),d.jsx("span",{id:`content-after-iframe-${n}`})]})},Yo=e=>{let t="";return e&&typeof e!="string"&&typeof e!="number"&&typeof e!="boolean"&&"type"in e&&(t=e.type),t},dm=({children:e,...t})=>{let n={...t};t.href&&(t.href.includes("http:")||t.href.includes("https:"))&&!t.target&&(n.target="_blank");let r=e,a=!1;for(const i of y.Children.toArray(e))if(!(!i||typeof i=="string"||typeof i=="number")&&y.isValidElement(i)){const s=i.type;if(["button","center","span","strong"].includes(s)&&i.props&&i.props.children&&i.props.children[0])for((s==="button"||Yo(i.props.children[0])==="button")&&(a=!0),r=i.props.children[0];r&&typeof r!="string"&&!(typeof r=="boolean"||typeof r=="number"||!y.isValidElement(r));)if(r.props&&r.props.children&&r.props.children[0])r=r.props.children[0],r&&Yo(r)==="button"&&(a=!0);else break}return a?(n={...n,className:"button primary medium"},d.jsx("p",{className:"center",children:d.jsx(_e,{variant:"primary",size:"medium",...n,children:r})})):d.jsx("a",{...n,children:r})},ds=({children:e,...t})=>d.jsx("span",{className:Y({url:t==null?void 0:t.href}),children:e});const fm={default:{a:dm,CollapsibleSection:Va,TextBox:Mt,CaseStudy:im,style:nt,details:um,div:lm,iframe:cm,center:sm},"text-only":{h1:nt,h2:nt,h3:nt,h4:nt,h5:nt,h6:nt,style:nt,details:nt,div:nt,TextBox:nt,CollapsibleSection:nt,CaseStudy:nt,blockquote:nt,iframe:nt,button:nt}},xn=({element:e="div",className:t="",options:n={},children:r,overrideType:a="default",styling:i={}})=>{if(!r)return null;const{highlightTitles:s=!1}=i;r=r.replace(/^<br\/?>/,"");const o={wrapper:y.Fragment,forceBlock:!0};let l=fm[a];return n.overrides&&(l={...l,...n.overrides}),y.createElement(e,{className:Y("markdown-text",t,{"highlight-titles":s}),children:d.jsx(Rt,{options:{...o,...n,overrides:l},children:r})})};const Kc=({maxWidth:e=!1,title:t,subtitle:n,children:r,className:a=""})=>{const i=e?{"--max-width":`${e/16}rem`}:{};return d.jsxs("section",{className:Y("page-heading",a),children:[d.jsxs("div",{className:Y("content",{"has-max-width":e}),style:i,children:[t&&t.text&&y.createElement(t.element||"h1",{className:"title"},t.text),n&&n.text&&y.createElement(n.element||"h2",{className:"text-medium"},n.text)]}),r]})};const gn=({size:e="medium",variant:t="default",className:n="",icon:r,tooltip:a="",children:i,...s})=>{const o={"--icon":`url(${It}icons/${r}.svg)`},{showTooltip:l,tooltipProps:u}=Ls(!!a),c=d.jsx("span",{...u,className:Y("pill",e,t,n,{"has-icon":r}),style:o,...s,children:i});return a?d.jsxs("span",{className:"pill-wrapper",children:[d.jsx(An,{isOpen:l,children:a}),c]}):c};const Fr=({element:e="p",children:t=null,className:n="",...r})=>y.createElement(e,{...r,className:Y("status-banner text-small",n),"aria-live":"assertive"},t);const hm=({styling:e={},progress:t=0,text:n=!1,className:r=""})=>{const a=ue.useIntl(),{showText:i=!1,layout:s="bar",size:o="default",color:l="default"}=e,u=t>75?100:t>50?75:t>25?50:t>5?25:0,c={"--progress":`${t}%`};return d.jsx("span",{className:Y(`progress-bar section-${u}`,s,r,{[o]:o!=="default",[l!=="default"?l:""]:l!=="default"}),style:c,children:y.createElement(i?"span":Ie,{className:i?"text":"",children:n||a.formatMessage({id:"progressBar"},{number:t})})})},qs=y.memo(hm);const ci="loadingBlock_",mm=({progress:e=0,steps:t=!1,className:n=""})=>{const r=ue.useIntl();t||(t={0:{text:r.formatMessage({id:`${ci}loading`})},75:{text:r.formatMessage({id:`${ci}almostDone`})},100:{text:r.formatMessage({id:`${ci}complete`})}});let a=null;const i=Object.keys(t);for(let o=0;o<i.length&&!(e<parseInt(i[o]));o++)a=i[o];const s=a&&t[a].icon?{"--icon":`url(${It}icons/${t[a].icon}.svg)`}:{};return d.jsxs(Mt,{className:Y("loading-block",n,{"has-icon":a&&t[a].icon}),variant:"subtle",style:s,children:[a&&d.jsx("span",{className:"step",children:t[a].text}),d.jsx(qs,{progress:e})]})},pm=y.memo(mm);const kt=({element:e="div",className:t="",...n})=>d.jsx(Wa,{element:e,className:Y("loading-placeholder",t),...n});const fs={header:["logo","link","link","search"],sidebar:["text","text","text","text","text"],"cards-section":["subtitle","cards"],heading:["title"],cards:["card","card","card","card"],carousel:["cards","controls"],"carousel-with-title":["title","cards","controls"],answers:["text","text","text"],"text-page":["title","text","text","text","text","subtitle","text","text","text","text","subtitle","text","text","text","text"],"form-with-answers":["question","subtitle","form","answers","answers","answers","answers","answers"],"general-website-page":["banner","text-page"],"overview-page":["header","sidebar","title","text","cards-section","cards-section","footer"],"course-navigation":["button","button"],"course-lesson-page":["breadcrumb","course-navigation","text-page"],"course-lesson-quiz":["text-page","quiz-box"]},Zc=(e,t)=>e in fs?d.jsx("div",{className:e,children:fs[e].map((n,r)=>Zc(n,r))},t):d.jsx(kt,{className:e},t),Ws=({layout:e="overview-page",...t})=>d.jsx("div",{className:Y("loading-state",e),...t,children:fs[e].map((n,r)=>Zc(n,r))}),Yc=e=>{const t=e&&e.toUpperCase().trim().split(" ");return Array.isArray(t)&&t.length>1&&t[0]!==""?t[1]===""?t[0][0]:t[0][0]+t[t.length-1][0]:e?e.substr(0,1):""},Ur=["#5AB6A3","#A2D7AF","#806056","#3962B3"],gm=e=>{const t=Math.ceil(26/Ur.length),n=Yc(e).toLowerCase();if(n==="")return Ur[0];const r=n.charCodeAt(0)-96;for(let a=0;a<Ur.length;a++)if(r<=t*(a+1))return Ur[a]};const Go=256,Yt=({className:e="",src:t="",name:n,alt:r,width:a=Go,height:i=Go,...s})=>{const[o,l]=y.useState(!1),u=y.useRef(null),c=r??n;y.useEffect(()=>{const p=u.current;if(!p)return;const m=p.getContext("2d");if(!m)return;const g=a,f=i;typeof window<"u"&&window.devicePixelRatio&&(p.width=g*window.devicePixelRatio,p.height=f*window.devicePixelRatio,m.scale(window.devicePixelRatio,window.devicePixelRatio)),m.fillStyle=gm(n),m.fillRect(0,0,g,f),m.font=`${g/3}px Arial`,m.textAlign="center",m.fillStyle="white",m.fillText(Yc(n),g/2,f/1.6)},[n]);let h=!1;return t&&t!==""&&!o&&(t.includes("http")||t.includes("//"))&&(h=!0),d.jsx("figure",{className:Y("profile-picture",e,{error:o}),...s,children:h?d.jsx("img",{src:t,alt:c,onError:()=>{l(!0)},width:a,height:i}):d.jsx("canvas",{ref:u})})},Ka=e=>e==="apolitical"?{image:`${It}logos/member_apolitical.svg`}:e==="community"||typeof e=="object"&&!e.name?{image:`${It}logos/member_community.svg`}:{name:e.name,role:e.jobTitle||"",organisation:e.organization||"",country:e.location&&e.location.country||"",url:`/profiles/${e.id}`,image:e.image&&e.image.thumbnail},vm=({role:e="",organisation:t="",country:n="",maximumCharacters:r=80})=>{const a=e!=="",i=t!=="",s=n!=="";if(!a&&!i&&!s)return"";const o=`${e}${a&&i?` — ${t}`:t}`;let l=`${o}${(a||i)&&s?`, ${n}`:n}`;return l.length>r&&(l=o),l.length>r&&(l=Zn(l,r)),l};const wn=({element:e="div",member:t="community",additionalContent:n=!1,styling:r={},functions:a={},gtmContext:i="member",gtmType:s="member-click",className:o="",alt:l=""})=>{const u=ue.useIntl(),{size:c="medium"}=r,h=Ka(t);h.name||(h.name=u.formatMessage({id:`member_${typeof t=="string"?t:"community"}`}));const{name:p,image:m}=h;let{url:g}=h;t.link!==void 0&&(t.link===!1?g=void 0:g=t.link);const f=vm(h),D=n&&n.createdAt?us(n.createdAt):!1,v=n&&n.createdAt?zs(n.createdAt):"";return y.createElement(e,{className:Y("member text-medium",c,o),...a,children:d.jsxs(Tn,{href:g,gtmType:s,gtmContext:i,onClick:E=>{E==null||E.stopPropagation()},children:[d.jsx(Yt,{name:p,src:m,alt:l}),d.jsxs("p",{className:"details",children:[d.jsxs("strong",{children:[p,n&&d.jsxs("span",{className:"additional-content",children:[n.createdAt&&D&&d.jsx("span",{className:"date",title:v,"aria-label":v,children:u.formatMessage({id:`dates_${D.path}`},{number:D.number})}),n.didEdit&&d.jsx("em",{children:u.formatMessage({id:"discussion_edited"})})]})]}),f&&d.jsx("small",{className:Y({"text-medium":c==="large"}),children:f})]})]})})};const Qo={small:24,medium:48},Hs=({element:e="div",contributors:{total:t,data:n}={total:void 0,data:[]},styling:{showText:r,size:a,showGap:i,showPlaceholders:s}={showText:!0,size:"medium",showGap:!0,showPlaceholders:!1},cutoff:o=2,multipleText:l,className:u="",...c})=>{const h=ue.useIntl();return!n||n.length===0?null:y.createElement(e,{...c,className:Y("contributors",u,a,{"has-gap":i}),children:d.jsxs(d.Fragment,{children:[d.jsx("ul",{children:n.map((p,m)=>{let g,f="";if(m<o){const{name:D="",image:v=""}=Ka(p);if(s)return d.jsx(kt,{element:"li",className:"contributor"},m);g=d.jsx(Yt,{name:D,src:v,width:Qo[a||"medium"],height:Qo[a||"medium"]})}else if(m===o){const D=(t||n.length)-o;g=d.jsxs("small",{className:Y({"large-number":D>99}),children:["+",Kh(D,0)]}),f="number-left"}return g?d.jsx("li",{className:Y("contributor",f),children:g},m):null})}),r&&d.jsx("span",{className:"label",children:typeof r=="string"?r:n.length===1?typeof n[0]=="string"?h.formatMessage({id:`member_${n[0]}`}):Zn(n[0].name||"",20):l||null})]})})},Gc=({showDevTools:e=!0,children:t})=>{const n=new Ye.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,staleTime:6e4}}});return d.jsxs(Ye.QueryClientProvider,{client:n,children:[t,e&&d.jsx(Fh.ReactQueryDevtools,{initialIsOpen:!1})]})};var Qc=y.createContext({client:da});function bm(e){var t=e.children,n=e.client,r=e.apiKey,a=e.options,i=y.useMemo(function(){return n&&r&&console.warn("[PostHog.js] You have provided both a client and an apiKey to PostHogProvider. The apiKey will be ignored in favour of the client."),n&&a&&console.warn("[PostHog.js] You have provided both a client and options to PostHogProvider. The options will be ignored in favour of the client."),n||(r&&(da.__loaded&&console.warn("[PostHog.js] was already loaded elsewhere. This may cause issues."),da.init(r,a)),da)},[n,r]);return y.createElement(Qc.Provider,{value:{client:i}},t)}var ym=function(){var e=y.useContext(Qc).client;return e};function Dm(e){var t=ym(),n=y.useState(),r=n[0],a=n[1];return y.useEffect(function(){return t.onFeatureFlags(function(){a(t.getFeatureFlagPayload(e))})},[t,e]),r}const Jc=({children:e,user:t})=>t.isLoading?null:process.env.REACT_APP_PUBLIC_POSTHOG_KEY?d.jsx(bm,{apiKey:atob(process.env.REACT_APP_PUBLIC_POSTHOG_KEY),options:{api_host:"/ph",autocapture:!1,disable_session_recording:!0,persistence_name:"flags",secure_cookie:!0,ui_host:"eu.posthog.com",bootstrap:{distinctID:t.id||"00000000-0000-0000-0000-000000000000",isIdentifiedID:!!t.id}},children:e}):d.jsx(d.Fragment,{children:e});var Us=(e=>(e.COMMUNITY_RANKING="community-ranking",e))(Us||{});const Xc=({children:e,locale:t,messages:n})=>{const r=t||"en",a={...Vh[r],...n||{}};return d.jsx(ue.IntlProvider,{locale:r,messages:a,children:e})},Vs=y.createContext({}),ha={en:"English",es:"Español",fr:"Français",pt:"Português"},Lt=y.createContext({isLoading:!0});function Za(){return y.useContext(Lt)}const ed=({children:e,user:t})=>d.jsx(Lt.Provider,{value:t,children:e}),Ks=y.createContext({registerOverlay:()=>{},unregisterOverlay:()=>{}}),td=()=>y.useContext(Ks),nd=({children:e})=>{const[t,n]=y.useState([]);y.useEffect(()=>{t.length>0?document.body.classList.add("has-overlay"):document.body.classList.remove("has-overlay")},[t]);const r=y.useCallback(i=>{n(s=>[...s,i])},[]),a=y.useCallback(i=>{n(s=>s.filter(o=>o!==i))},[]);return d.jsx(Ks.Provider,{value:{registerOverlay:r,unregisterOverlay:a},children:e})},Cm=({bootstrap:e,children:t,intl:n,showDevTools:r})=>{const[a,i]=y.useState({isLoading:!0}),s=(n==null?void 0:n.locale)||localStorage.getItem("language")||"en",[o,l]=y.useState(s),u=c=>{localStorage.setItem("language",c),l(c)};return y.useEffect(()=>{e().then(c=>{i({...c,isLoading:!1}),$c(5e3)}).catch(c=>{c.message===Nc&&window.location.pathname!=="/user-onboarding/logout"&&(window.location.href="/user-onboarding/logout"),i({isLoading:!1})})},[]),d.jsx(Vs.Provider,{value:{language:o,updateLanguage:u},children:d.jsx(Xc,{locale:o,messages:n==null?void 0:n.messages,children:d.jsx(Is.CookiesProvider,{children:d.jsx(ed,{user:a,children:d.jsx(nd,{children:d.jsx(Gc,{showDevTools:r,children:d.jsx(Jc,{user:a,children:t})})})})})})})};const cr="joinCommunityButton",Zs=({isMember:e=!1,isOpen:t=!1,isShort:n=!1,disabled:r=!1,functions:{join:a,leave:i}={join:()=>{},leave:()=>{}}})=>{const s=ue.useIntl(),o=y.useContext(Lt),l=o&&typeof o.id=="string",u=r||!l,[c,h]=y.useState(e),[p,m]=y.useState(e?"joined":"notJoined");y.useEffect(()=>{p==="joining"?m("joined"):p==="leaving"&&m("notJoined")},[c]);const g={},f={};return c&&p!=="leaving"&&(g["data-hover-text"]=s.formatMessage({id:`${cr}_leave`}),g["aria-label"]=s.formatMessage({id:`${cr}_member_aria`}),f["aria-hidden"]="true"),d.jsx(_e,{variant:c?"secondary":"primary",size:"medium",styling:{fullWidth:!0},icon:c&&p!=="leaving"?{icon:"tick",position:"left"}:!1,tooltip:!t&&!c?s.formatMessage({id:`${cr}_closed_tooltip`}):"",onClick:async D=>{if(u)return;D.currentTarget.blur(),m(c?"leaving":"joining");const v=new CustomEvent("ariaLive",{detail:{message:s.formatMessage({id:`${cr}_aria_live`},{action:c?"leaving":"joining"})}});document.dispatchEvent(v);const E=c?i:a;typeof E=="function"&&setTimeout(async()=>{await E()},500),h(!c)},className:Y("join-community-button",p,{active:p==="joining"}),disabled:u,"data-testid":"join-button",...g,children:d.jsx("span",{className:"text",...f,children:s.formatMessage({id:`${cr}${["joining","leaving"].includes(p)?`_${p}`:c?"_member":n?"_short":""}`})})})};const di="communityDetails_",xm=({className:e="",isMember:t=!1,isOpen:n=!1,slug:r,members:{number:a=0,data:i=[]}={number:0,data:[]},functions:{invite:s,...o}})=>{const l=ue.useIntl(),u=5,c=a||i.length,h=i.length?i:Array(u).fill({}),p=`/communities/${r}/members`===window.location.pathname,m=t||n,g=!n&&!t;return d.jsxs("div",{className:Y("community-details",e),children:[m&&d.jsxs("div",{className:"member-details",children:[d.jsxs("div",{className:"top",children:[d.jsxs("h4",{children:[l.formatMessage({id:`${di}members`}),d.jsx("span",{className:"count",children:c})]}),!p&&d.jsx("p",{className:"text-small",children:d.jsx("a",{href:`/communities/${r}/members`,children:l.formatMessage({id:`${di}viewAll`})})})]}),d.jsx(Hs,{contributors:{total:a,data:h},styling:{size:"medium",showGap:!0,showPlaceholders:c===0},cutoff:u})]}),d.jsx(Zs,{isMember:t,isOpen:n,disabled:g,functions:{...o}}),t&&d.jsx(_e,{variant:"primary",onClick:s,icon:{icon:"plus"},styling:{fullWidth:!0},children:l.formatMessage({id:`${di}invite`})})]})};const wm=({breadcrumbs:e,cutoff:t=20,className:n=""})=>{const r=ue.useIntl();return d.jsxs(d.Fragment,{children:[d.jsx(Ie,{element:"p",children:r.formatMessage({id:"breadcrumbs_label"})}),d.jsx("ul",{className:Y("breadcrumbs text-small",n),children:e.map(({text:a,href:i,current:s=!1},o)=>{const l={};return s&&(l["aria-current"]="location"),d.jsxs("li",{children:[s&&d.jsx(Ie,{element:"span",children:r.formatMessage({id:"breadcrumbs_currentPage"})}),d.jsx(Tn,{href:s?void 0:i,...l,children:Zn(a,t)})]},`${window.btoa(a)}_${o}`)})})]})};const Em=({options:e,allOption:t=!1,allowMultiple:n=!0,onChange:r=()=>{},className:a=""})=>{const i=ue.useIntl(),s=t?[{id:"all",text:typeof t!="boolean"&&t.text||i.formatMessage({id:"filters_all"})},...e]:e,[o,l]=y.useState(t?["all"]:[]),u=(c,h)=>{let p=[];o.includes(c)?p=o.filter(m=>m!==c):c==="all"?p=["all"]:n?p=[...o.filter(m=>m!=="all"),c]:p=[c],l(m=>(r&&typeof r=="function"&&r({current:p,previous:m}),p)),h&&typeof h=="function"&&h()};return d.jsx("ul",{className:Y("filters",a),children:s.map(({id:c,text:h,disabled:p=!1,callback:m=()=>{}})=>{let g={};return p&&(g={disabled:!0,"aria-label":i.formatMessage({id:"filters_disabled"},{name:h})}),d.jsx("li",{children:d.jsx("button",{className:Y(c,{selected:o.includes(c)}),onClick:f=>{f.preventDefault(),f.stopPropagation(),u(c,m)},...g,children:h})},c)})})},km=(e,t,n)=>{const r=String(e);if(!n||!n.length)return t?`/${r}/${t}`:`/${r}`;let a="",i=!1;return n.forEach(({url:s,position:o})=>{o==="before-lang"?(a+=`/${s}`,i=!0):(a.includes(`/${r}/`)||(a+=`/${r}`),a+=`/${s}`)}),a.includes(`/${r}/`)||(a+=`/${r}`),t&&(a+=`/${t}`),i?{url:a,urlForRouter:`/${a.split("/").slice(2).join("/")}`}:a};const Vr="languageSwitcher_",_m=({currentLanguage:e,isOriginalLanguage:t=!1,isHumanTranslation:n=!1,translations:r,onChange:a,urlParts:i,variant:s="default",label:o,className:l=""})=>{const u=ue.useIntl(),{updateLanguage:c=()=>{}}=y.useContext(Vs),[h,p]=y.useState(e);if(y.useEffect(()=>{e!==h&&p(e)},[e]),!r||!Object.values(r).some(D=>D&&D.post_name))return null;const g=Object.keys(r),f=h!==e;return d.jsxs("div",{className:Y("language-switcher text-small",s,l),children:[d.jsxs("nav",{children:[s!=="short"&&d.jsx("p",{children:o||u.formatMessage({id:`${Vr}label`})}),d.jsx("ul",{children:g.map(D=>{var B;if(!ha[D])return null;const v=(B=r[D])==null?void 0:B.post_name;let E={className:D};if(h===D)E["aria-label"]=u.formatMessage({id:`${Vr}selected`},{language:ha[D]});else{const x=km(D,v,i);E={...E,href:typeof x=="string"?x:x.url,onClick:k=>{p(D),c(D),typeof a<"u"&&(k.preventDefault(),k.stopPropagation(),a(D,typeof x=="string"?x:x.urlForRouter))}}}return d.jsx("li",{children:d.jsx(Tn,{...E,fallbackElement:"span",children:ha[D]})},D)})}),s!=="short"&&!f&&d.jsx("p",{children:u.formatMessage({id:`${Vr}translation_${t?"original":n?"human":"machine"}`})})]}),s!=="short"&&!f&&!t&&!n&&d.jsx("small",{children:u.formatMessage({id:`${Vr}disclaimer`},{email:$n.support,link:D=>{const v=`mailto:${D}`;return d.jsx("a",{href:v,children:D})}})})]})};const fi=ue.createIntl({locale:"en",messages:nr}),$r=({hasNextPage:e=!0,loadNextPage:t=()=>{},isLoading:n=!1,variant:r="secondary",size:a="medium",styling:i={muted:!1,fullWidth:!1},icon:s=!1,messages:o={button:fi.formatMessage({id:"loadMore_button"}),endOfFeed:fi.formatMessage({id:"loadMore_endOfFeed"}),error:fi.formatMessage({id:"loadMore_error"})},className:l="",gtmContext:u="LoadMore"})=>{const[c,h]=y.useState(""),p=async m=>{if(!n)try{await t(m)}catch(g){g instanceof Error?h(g.message):h("Unknown error")}};return!c&&!e&&!o.endOfFeed?null:d.jsx("footer",{className:Y("load-more",l),children:!c&&e?d.jsx(_e,{variant:r,size:a,styling:i,icon:s,onClick:p,"data-gtm-event-context":u,"data-gtm-event-type":"load-more-click",disabled:n,className:"gtm-trackable","data-testid":"load-more-button",children:o.button}):o.endOfFeed&&(!c||c!=null&&c.includes("Cannot read items"))?d.jsx("p",{children:o.endOfFeed}):c&&d.jsx("p",{className:"error",children:o.error})})};const Ys=({variant:e="default",version:t="default",className:n="",...r})=>d.jsx("p",{className:"logo-wrapper",children:d.jsx("a",{href:"/home/",className:Y("logo",e,t,n),...r,children:d.jsx(Ie,{children:d.jsx(ue.FormattedMessage,{id:"apolitical"})})})});let Kr=!1;const rd=({element:e="div",id:t="more-menu",options:n,className:r=""})=>{const a=ue.useIntl(),i=y.useRef(null),[s,o]=y.useState(!1),l=u=>{i.current&&u.target instanceof HTMLElement&&!i.current.contains(u.target)&&o(!1)};return y.useEffect(()=>(document.addEventListener("click",l,!0),()=>{document.removeEventListener("click",l,!0)})),y.createElement(e,{ref:i,className:Y("more-menu text-medium",r),children:d.jsxs(d.Fragment,{children:[d.jsx(_e,{variant:"tertiary",size:"medium",icon:{icon:"ellipsis"},onClick:()=>o(!s),"aria-haspopup":"true","aria-expanded":s,"aria-controls":t,screenreaderText:a.formatMessage({id:"moreMenu"}),className:"more-menu-button"}),d.jsx("ul",{id:t,hidden:!s,children:n.map(({href:u,onClick:c,text:h,icon:p,...m},g)=>{const f={...m,onClick:D=>{o(!1),typeof c=="function"&&c(D)},onFocus:()=>{Kr&&(clearTimeout(Kr),Kr=!1)},onBlur:()=>{Kr=setTimeout(()=>{o(!1)},100)}};return u&&(f.href=u),d.jsx("li",{className:"more-menu-list-item",children:d.jsx(_e,{variant:"tertiary",size:"medium",icon:p?{icon:p,position:"left"}:!1,...f,children:h})},`${window.btoa(h)}_${g}`)})})]})})},Bm=(e,t=!1)=>t?e.replaceAll("/","")===t:typeof window<"u"&&window.location&&window.location.pathname===e;const Fm=[{key:"homepage",href:"/home/"},{key:"events",href:"/events/"},{key:"microcourses",href:"/microcourses/"},{key:"articles",href:"/solution-articles/"},{key:"communities",href:"/communities/"}],ad=({activeLink:e})=>{const t=ue.useIntl(),n=y.useContext(Lt),r=n&&typeof n.id=="string";return d.jsxs("ul",{id:"navigation-menu",className:"text-medium",children:[Fm.map(({key:a,href:i})=>{const s=Bm(i,e),o={};return s&&(o["aria-current"]="page"),d.jsx("li",{className:Y(a,{active:s}),children:d.jsx("a",{href:i,"data-gtm-event-type":`${a}-click`,"data-gtm-event-context":"NavigationMenu",className:"gtm-trackable",...o,children:t.formatMessage({id:`navigationMenu_links_${a}`})})},a)}),r&&d.jsx("li",{className:"profile","data-testid":"profile-link",children:d.jsxs("a",{href:"/profiles/me","data-gtm-event-type":"profile-click","data-gtm-event-context":"NavigationMenu",className:"gtm-trackable",children:[d.jsx(Yt,{name:(n==null?void 0:n.name)||"",src:n!=null&&n.image?n.image.thumbnail:""}),d.jsx("span",{children:t.formatMessage({id:"navigationMenu_profile"})})]})})]})},dr=(e,t,n)=>`${e}?share=${t}${n?`&uuid=${n}`:""}`,Am=({title:e,link:t,referrer:n})=>[{key:"linkedin",icon:"social_linkedin",url:`https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(`${dr(t,"linkedin",n)}&src=linkedin`)}&title=${encodeURIComponent(e)}&source=Apolitical`},{key:"twitter",icon:"social_twitter",url:`https://twitter.com/share?ref_src=twsrc%5Etfw&url=${encodeURIComponent(`${dr(t,"twitter",n)}&src=twitter`)}&text=${encodeURIComponent(e)}&via=${encodeURIComponent("apoliticalco")}`},{key:"facebook",icon:"social_facebook",url:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(`${dr(t,"facebook",n)}`)}&t=${e}`},{key:"email",icon:"share_email",url:`mailto:?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`${e}
|
|
38
38
|
|
|
39
|
-
${dr(t,"mailto",n)}&src=email`)}`},{key:"clipboard-copy",icon:"share_copy-link",url:dr(t,"copy",n),shouldRender:()=>navigator&&navigator.clipboard&&navigator.clipboard.writeText,onClick:(r,a)=>(r.preventDefault(),r.stopPropagation(),navigator.clipboard.writeText(a))}];const Tm="shareLinks_",Sm=({title:e,link:t,referrer:n,gtmContext:r="ShareLinks",size:a="large",variant:i="default",className:s=""})=>{const o=ue.useIntl(),l=Am({title:e,link:t,referrer:n});return d.jsxs("aside",{className:Y("share-links",a,i,s),children:[d.jsx("p",{className:"text-small",children:o.formatMessage({id:"shareLinks_label"})}),d.jsx("ul",{children:l.map(({key:u,icon:c,url:h,shouldRender:p=!0,onClick:m})=>{if(typeof p=="function"&&!p())return null;const g={};return m&&(g.onClick=f=>m(f,h)),d.jsx("li",{children:d.jsx(_e,{size:a,variant:"tertiary",icon:{icon:c||u},href:h,target:"_blank",rel:"noopener noreferrer",className:"gtm-trackable","data-gtm-event-context":`${r}-SocialButtons`,"data-gtm-event-type":`${u}-click`,"data-testid":"link",screenreaderText:o.formatMessage({id:`${Tm}link_${u}`}),...g})},u)})})]})};const jm=({tabs:e,className:t="",preventLocationChange:n})=>{var p;const r=(m,g,f)=>(m||(m=`panel-${window.btoa(g)}-${f}`),m);let a=e.findIndex(m=>m.current===!0);if(a<0&&(a=0),window.location.hash){const m=window.location.hash.replace("#","");if(e.find(f=>f.id===m)){for(let f=0;f<e.length;f++)if(r(e[f].id,e[f].text,f)===m){a=f;break}}}const[i,s]=y.useState((p=e[a])!=null&&p.id?e[a].id:r(e[a].id,e[a].text,a)),[o,l]=y.useState(""),u=(m,g)=>{switch(m.key){case"ArrowLeft":case"ArrowRight":{m.preventDefault();let f=g;m.key==="ArrowLeft"?g>0?f=g-1:f=e.length-1:m.key==="ArrowRight"&&(g<e.length-1?f=g+1:f=0);const D=r(e[f].id,e[f].text,f),v=document.getElementById(`tab-${D}`);v==null||v.focus(),l(D);break}case"Enter":s(o),window.location.hash=`#${o}`;break}};y.useEffect(()=>{if(e[a].hasCarousel){const m=new CustomEvent("hiddenSectionVisible",{detail:{id:i}});window.dispatchEvent(m)}},[i]);const c=[],h=[];return e.forEach(({id:m,text:g,content:f,href:D,hasCarousel:v},E)=>{m=r(m,g,E);const B=i===m,x={};D||(x["aria-controls"]=m,x.onClick=k=>{k.preventDefault(),k.stopPropagation(),s(m),!n&&(window.location.hash=`#${m}`)},h.push(d.jsx("section",{id:m,hidden:!B,role:"tabpanel","aria-labelledby":`tab-${m}`,"aria-live":B?"assertive":"off",children:typeof f=="string"?d.jsx("p",{children:f}):f},`section-${m}`))),c.push(d.jsx("li",{"data-testid":"navigation-tab",children:d.jsx("a",{href:D||`#${m}`,id:`tab-${m}`,"aria-controls":m,className:Y({selected:B}),role:"tab",tabIndex:B?0:-1,"aria-selected":B,onKeyDown:k=>u(k,E),...x,children:g})},`tab-${m}`))}),d.jsxs("div",{className:Y("tabs-wrapper",t),children:[d.jsx("ul",{className:"tabs",role:"tablist",children:c}),d.jsx("div",{className:"tab-content",children:h})]})};const Om={"2-1":901,"1-3":769,"1-1":769},id=({layout:e="2-1",hideOnMobile:t=!1,hasCSSContainers:n=!1,className:r="",children:a})=>{const i=tr(!0);let s=a;return y.Children.count(a)===1&&(s=y.Children.toArray(a)[0],s.props&&(s=s.props.children)),d.jsx("section",{className:Y("columns",`layout-${e}`,r,{"has-containers":n}),children:y.Children.map(s,(o,l)=>t!==!1&&l===t&&i&&i<Om[e]?null:o)})};const Gs=({id:e="character-limit",limit:t,valueLength:n,...r})=>{const a=ue.useIntl(),i="form_fieldWrapper_characterLimit";if(t===0)return null;const s=t-n,o=Math.abs(n-t),l=n>=.99*t,u=n>=.9*t&&n<.99*t,c=n>t;return d.jsxs(d.Fragment,{children:[d.jsx("small",{id:e,className:Y("character-limit",{"near-limit":l,"approaching-limit":u}),"aria-live":"polite","aria-label":c?"":a.formatMessage({id:`${i}_aria_${s<0?"over":"default"}`},{remaining:s,over:o,limit:t}),children:c?a.formatMessage({id:`${i}_aria_${s<0?"over":"default"}`},{remaining:s,over:o,limit:t}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"hidden",children:a.formatMessage({id:i})}),n," / ",t]})}),d.jsx(Ie,{showOnFocus:!1,id:`${e}-info`,children:a.formatMessage({id:`${i}_info`},{limit:t})})]})},Ya=e=>(e==null?void 0:e.toString().length)||0,sd=(e,t=null)=>{const n={};return e===0||(n["data-character-limit"]=e,t&&(n.functions={onChange:r=>{Ya(r)>e&&(r=r==null?void 0:r.toString().slice(0,e)),t(r)}})),n};const Zr="emailHelperTextBox_",od=({id:e="email-helper-textbox",type:t,email:n,redirectPath:r,resendVerificationCode:a})=>{const i=ue.useIntl(),[s,o]=y.useState({path:`${Zr}default`,type:"default",link:{},mail:{},error:""}),[l,u]=y.useState(!1),c=y.useCallback(g=>{g.preventDefault(),g.stopPropagation();const f=D=>{o({path:`${Zr}error_verificationFailedToSend`,type:"error",link:{"data-gtm-event-context":"VerifyEmailBox","data-gtm-event-type":"SendEmailClick",className:"gtm-trackable",onClick:v=>c(v),href:"#","data-testid":"send-verify-email-click"},mail:{href:"mailto:concierge@apolitical.co",className:"gtm-trackable","data-gtm-event-context":"ErrorVerifyingBox","data-gtm-event-type":"email-concierge-click"},error:D})};if(typeof a!="function"){f(i.formatMessage({id:`${Zr}error_noFunction`}));return}u(!0),a(n).then(()=>{localStorage.setItem("email",n),window.location.href=r||"/signup/verify-email"}).catch(D=>{f(D.message)}).finally(()=>{u(!1)})},[n,r,a]);y.useEffect(()=>{let g=Zr,f="default",D={},v={};switch(t){case"gov":g+="autoApproved",f="success";break;case"nonGov":g+="unrecognisedEmail",f="error",D={href:"https://about.apolitical.co/who-can-join-the-community","data-gtm-event-context":"NonGovEmailHelperTextBox","data-gtm-event-type":"LearnMoreClick"};break;case"pending":g+="pendingApproval",f="error",v={href:"mailto:concierge@apolitical.co",className:"gtm-trackable","data-gtm-event-context":"EmailExistsBox","data-gtm-event-type":"email-concierge-click"};break;case"verify":g+="emailUnverified",f="error",D={href:"#","data-gtm-event-context":"VerifyEmailBox","data-gtm-event-type":"SendEmailClick",className:"gtm-trackable",onClick:E=>c(E),"data-testid":"send-verify-email-click"};break;case"exists":g+="emailAlreadyExists",f="error",D={href:"/user-onboarding/login","data-gtm-event-context":"EmailExistsBox","data-gtm-event-type":"login-click"},v={href:"mailto:concierge@apolitical.co",className:"gtm-trackable","data-gtm-event-context":"EmailExistsBox","data-gtm-event-type":"email-concierge-click"};break;default:g+="default",D={href:"https://about.apolitical.co/who-can-join-the-community","data-gtm-event-context":"DefaultEmailHelperTextBox","data-gtm-event-type":"LearnMoreClick"};break}o({...s,path:g,type:f,link:D,mail:v})},[t]);const h={};return["link","mail"].forEach(g=>{h[g]=Object.keys(s[g]).length?f=>d.jsx("a",{...s[g],children:f}):f=>f}),d.jsx(Uc,{id:e,type:s.type,heading:l?!1:i.formatMessage({id:`${s.path}_title`}),children:l?d.jsxs(d.Fragment,{children:[d.jsx(kt,{element:"span"}),d.jsx(kt,{element:"span"})]}):i.formatMessage({id:`${s.path}_text`},{...h,strong:g=>d.jsx("strong",{children:g}),em:g=>d.jsx("em",{children:g}),br:d.jsxs(d.Fragment,{children:[d.jsx("br",{}),d.jsx("br",{})]}),error:s.error})})},Ln=({className:e="",element:t="input",id:n,inputRef:r,functions:a={onChange:()=>{}},name:i=n,placeholder:s,type:o="text",value:l,autoFocus:u,...c})=>{const h=y.useRef(),p=r||h;return y.useEffect(()=>{var m;u&&((m=p.current)==null||m.focus())},[]),!(c!=null&&c.autoComplete)&&["email"].includes(o)&&(c.autoComplete="email"),y.createElement(t,{ref:p,...c,type:o,id:n,name:i,className:Y(e,t,{"has-scrollbar":o==="textarea"&&p.current&&p.current.clientHeight<p.current.scrollHeight}),value:l,placeholder:s,autoFocus:u,...a,onChange:m=>{const g=m.target;a.onChange(g.value)}})};const Pn={UP:"ArrowUp",DOWN:"ArrowDown",ENTER:"Enter"},Pm=500,Nm=({id:e,name:t=e,value:n,placeholder:r,functions:a={onChange:()=>{},onKeyInput:async()=>new Promise(()=>{})},...i})=>{const{onChange:s=()=>{},onKeyInput:o=async()=>{}}=a,[{input:l,displayInput:u,debouncedInput:c},h]=y.useState({input:n,displayInput:n,debouncedInput:n}),[{predictions:p,activePredictionIndex:m,isPredictionSelected:g},f]=y.useState({predictions:[],activePredictionIndex:-1,isPredictionSelected:!!n}),{formatMessage:D}=ue.useIntl();r||(r=D({id:"inputAutocomplete_placeholder"})),y.useEffect(()=>{const x=setTimeout(()=>{g||h(k=>({...k,debouncedInput:l}))},Pm);return()=>{clearTimeout(x)}},[l,g]),y.useEffect(()=>{c&&!g?(async()=>{try{const k=await o(c)||[];f(T=>({...T,predictions:k}))}catch(k){console.error("Error fetching predictions:",k),f(T=>({...T,predictions:[]}))}})():f(x=>({...x,predictions:[]}))},[c,g]),y.useEffect(()=>{m>=0&&p[m]&&h(x=>({...x,displayInput:p[m].description}))},[m,p]);const v=x=>{[Pn.DOWN,Pn.UP,Pn.ENTER].includes(x.key)&&(x.preventDefault(),x.key===Pn.DOWN&&m<p.length-1?f(k=>({...k,activePredictionIndex:m+1})):x.key===Pn.UP&&m>0?f(k=>({...k,activePredictionIndex:m-1})):x.key===Pn.ENTER&&m>-1&&(s(p[m].description),h(k=>({...k,input:p[m].description})),f(k=>({...k,predictions:[],isPredictionSelected:!0}))))},E=x=>{s(x.target.value),h(k=>({...k,input:x.target.value,displayInput:x.target.value})),f(k=>({...k,activePredictionIndex:-1,isPredictionSelected:!1}))},B=x=>{s(x.description),h(k=>({...k,input:x.description,displayInput:x.description})),f(k=>({...k,isPredictionSelected:!0,predictions:[]}))};return d.jsxs(d.Fragment,{children:[d.jsx("input",{type:"text",value:u,onChange:E,onKeyDown:v,placeholder:r,name:t,id:e,...i}),d.jsx("ul",{className:"predictions-list",children:p.map((x,k)=>d.jsx("li",{onClick:()=>B(x),onMouseEnter:()=>f(T=>({...T,activePredictionIndex:k})),className:Y("predictions-list-item",{active:k===m}),children:x.description},k))})]})};const ud=({className:e="",disabled:t,element:n="p",functions:r={onChange:()=>{}},id:a,inputRef:i,intlPath:s=!1,label:o,shownValue:l=!0,type:u="checkbox",value:c,...h})=>{const p=ue.useIntl(),{onChange:m,...g}=r,f=()=>{t||m(c?null:l)},D=d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:i,id:a,name:a,type:u,value:l,checked:c,onKeyDown:v=>{(v.key==="Enter"||v.code==="Space")&&(v.preventDefault(),v.stopPropagation(),f())},readOnly:!0,disabled:t}),d.jsx("span",{className:"pretty-checkbox","data-testid":"pretty-checkbox"}),d.jsx("label",{htmlFor:a,children:o||p.formatMessage({id:s?`${s}_${a}`:a})})]});return y.createElement(n,{onClick:v=>{const E=v.target;E.nodeName.toLowerCase()==="a"||E.parentNode&&E.parentNode.nodeName.toLowerCase()==="a"||(v.preventDefault(),v.stopPropagation(),f())},className:Y("checkbox-wrapper",e),...h,...g},D)};const Rm=y.memo(function({direction:t="down"}){return d.jsx(Wa,{className:Y("rotating-chevron",`direction-${t}`)})});const Mm=({className:e,options:t,initialValue:n,value:r,functions:a={onChange:()=>{},onMultiSelectSubmit:()=>{}},gtm:{context:i}={context:""},placeholder:s,multiSelect:o,multiSelectOptions:l,id:u})=>{const c=ue.useIntl(),[h,p]=y.useState(!1),m=r||n,g=Array.isArray(m)?[...m]:m?[m]:[],[f,D]=y.useState(g);let v;Array.isArray(f)&&f.length===1&&typeof f[0]=="string"?v=t&&f?t.find(S=>S.id===f[0]):t?t[0]:{id:"",label:""}:Array.isArray(f)&&f.length===1&&typeof f[0]!="string"?v=f[0]:v={id:"",label:""},y.useEffect(()=>{D(g)},[r,n]);const{onChange:E,onMultiSelectSubmit:B,...x}=a,k=S=>{if(o){let q=[];f!=null&&f.includes(S.id)?q=f.filter(N=>N!==S.id):q=[...f,S.id],D([...q]),E&&E([...q])}else D([S]),E&&E(S.id),p(!1)},T=S=>{if(S==="all"){const q=(t==null?void 0:t.map(N=>N.id))||[];D(q),E&&E(q)}else D([]),E&&E([])};return d.jsxs("div",{className:Y("dropdown-wrapper",e),children:[d.jsxs("button",{className:"input","aria-expanded":h,"aria-haspopup":"listbox","aria-controls":"dropdown-list",onClick:S=>{S.preventDefault(),S.stopPropagation(),p(!h)},"data-testid":"dropdown-selector",...x,children:[o?`${s} · ${f.length}`:v.label,d.jsx(Rm,{direction:h?"up":"down"})]}),d.jsx("select",{defaultValue:v.id,onChange:S=>{S.preventDefault(),S.stopPropagation();const q=t&&t.find(N=>N.id===S.target.value);k(q)},hidden:!h,...x,children:t==null?void 0:t.map(S=>d.jsx("option",{value:S.id,children:S.label},S.id))}),d.jsxs("div",{className:"menu-options input dropdown-menu",role:"menu",hidden:!h,children:[d.jsxs("div",{className:"dropdown-menu-list",children:[(l==null?void 0:l.topbar)&&d.jsxs("div",{className:"action-bar",children:[d.jsx("p",{children:`${f==null?void 0:f.length} selected`}),d.jsxs("ul",{children:[d.jsx("li",{children:d.jsx(_e,{variant:"tertiary",size:"small",onClick:()=>T("all"),className:"gtm-trackable",children:c.formatMessage({id:"dropdown_menu_multiselect_all"})})}),d.jsx("li",{children:d.jsx(_e,{variant:"tertiary",size:"small",onClick:()=>T("none"),className:"gtm-trackable",children:c.formatMessage({id:"dropdown_menu_multiselect_none"})})})]})]}),d.jsx("ul",{children:t==null?void 0:t.map(S=>{const q=S.id===v.id||(f==null?void 0:f.includes(S))||(f==null?void 0:f.includes(S.id));return d.jsx("li",{"data-testid":"dropdown-options",children:d.jsxs("button",{className:Y("gtm-trackable",{selected:q,"selected-single":q&&!o}),"data-gtm-event-type":`${S}-click`,"data-gtm-event-context":i,onClick:N=>{N.preventDefault(),N.stopPropagation(),k(S)},role:"menuitem","aria-current":q,"data-testid":q?"current-selection":"",children:[o&&d.jsx("span",{className:"pretty-checkbox","data-testid":"pretty-checkbox"}),d.jsx("span",{className:Y({"menu-option-label":o}),children:S.label})]})},S.id)})})]}),(l==null?void 0:l.submitSection)&&d.jsx("p",{className:"submit",children:d.jsx(_e,{variant:"secondary",onClick:()=>{B&&B(f),document.dispatchEvent(new CustomEvent("dropdownMultiSelectSubmit",{detail:{id:u||"dropdown-multi-select",value:f}})),p(!1)},children:c.formatMessage({id:"form_submit"})})})]})]})};const Im=({className:e="",functions:t={onChange:()=>{}},intlPath:n=!1,id:r,label:a,multiSelect:i=!1,name:s,options:o,required:l,type:u="checkboxes",value:c,...h})=>{const p=ue.useIntl(),m=i?c:[],g=c;return d.jsx("ul",{...h,className:Y("options-wrapper",e),"data-testid":`ul-${r}`,children:o==null?void 0:o.map(({id:f,label:D=!1,value:v=f,disabled:E=!1})=>{const B=`${r}_${f}`,x=()=>{if(E)return;let k;if(i){const T=m==null?void 0:m.indexOf(v);Array.isArray(m)&&T>=0?(k=m,k.splice(T,1)):(!m||m.length===0?k=[]:k=m,k.push(v))}else k=g===v?void 0:v;t.onChange(k)};return d.jsx(ud,{element:"li",id:B,type:u==="checkboxes"?"checkbox":"radio",shownValue:v,value:i?m==null?void 0:m.includes(v):g===v,functions:{...t,onChange:x},intlPath:n,label:D||p.formatMessage({id:n?`${n}_${f}`:f}),disabled:E},B)})})};const $m=({inputRef:e,type:t="password",gtm:{context:n}={context:void 0},autoComplete:r="on",...a})=>{const i=ue.useIntl(),s=y.useRef(),o=e||s,[l,u]=y.useState(!1),[c,h]=y.useState(t),p=()=>{var m;u(!l),h(l?"password":"text"),(m=o.current)==null||m.focus()};return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:Y("show-password gtm-trackable",{"password-visible":l}),"data-gtm-event-context":n,"data-gtm-event-type":`${l?"hide":"show"}-password-click`,onClick:p,"aria-label":i.formatMessage({id:`showpassword_aria_${l?"hide":"show"}`}),children:i.formatMessage({id:`showpassword_${l?"hide":"show"}`})}),d.jsx(Ln,{inputRef:o,type:c,autoComplete:r,...a})]})};const Nn={text:{component:Ln},email:{component:Ln},url:{component:Ln},textarea:{component:Ln,props:{element:"textarea",rows:4,cols:10}},checkbox:{component:ud},checkboxes:{component:Im,props:{multiSelect:!0}},select:{component:Mm},password:{component:$m},autocomplete:{component:Nm}},Lm=({id:e,intlPath:t=!1,className:n="",error:r,functions:a={onChange:()=>{}},limit:i=0,showRequiredLabels:s=!0,type:o,validation:l,value:u,submitOnEnter:c,...h})=>{const p=ue.useIntl(),m=l&&l.some(({condition:N})=>N==="required"),g=Ya(u),f=o&&Nn[o]&&Nn[o].component?Nn[o].component:Ln,D=o&&["checkboxes"].includes(o),v=r&&`error-${e}`,E=`character-limit-${e}`,B={};D?B.element="legend":B.htmlFor=e;let x={...h,id:e,name:e,className:r?"error":"",type:o,required:m,"aria-required":m,functions:bn(a),value:u};const k=N=>{x["aria-describedby"]?x["aria-describedby"]+=` ${N}`:x["aria-describedby"]=N};if(i>0){const N=sd(i,a.onChange);k(`${E}-info`),x={...x,...N},N.functions&&typeof N.functions=="object"&&(x.functions={...x.functions,...N.functions})}o&&Nn[o]&&Nn[o].props&&(x={...x,...Nn[o].props}),D&&(x.intlPath=`${t}_${e}`),r&&(x["aria-invalid"]=!0,x["aria-errormessage"]=v,k(v));const T=h.label||p.formatMessage({id:t?`${t}_${e}`:e}),S=({...N})=>r?y.createElement(N.as||"p",{id:v,className:"error text-small",...N},r):null;if(o&&["checkbox"].includes(o))return d.jsxs(d.Fragment,{children:[d.jsx(f,{...x,label:T,className:Y("field-wrapper",n)}),d.jsx(S,{as:"p"})]});const q=N=>y.createElement(N.element||"label",{...N,className:"checkboxes-label text-small","data-testid":`label-${e}`});return d.jsx(d.Fragment,{children:y.createElement(D?"fieldset":"div",{className:Y("field-wrapper text-medium",n)},d.jsxs(d.Fragment,{children:[y.createElement(D?"div":"p",{className:"field-label"},d.jsx(d.Fragment,{children:d.jsxs(q,{...B,children:[T,m&&s&&d.jsxs(d.Fragment,{children:[" ",d.jsxs("small",{children:["(",p.formatMessage({id:"form_fieldWrapper_required"}),")"]})]})]})})),y.createElement(D?"div":"p",{className:"field-component"},d.jsxs(d.Fragment,{children:[d.jsx(f,{...x}),d.jsx(Gs,{id:E,limit:i,valueLength:g})]})),d.jsx(S,{})]}))})},zm=(e,t)=>{const{type:n,payload:r}=t,a=e.errors?bn(e.errors):{},i=e.values?bn(e.values):{};switch(n){case"toggleSubmitting":return{...e,isSubmitting:!e.isSubmitting};case"updateValue":if(r!=null&&r.key&&a[r==null?void 0:r.key]&&delete a[r==null?void 0:r.key],r!=null&&r.key){if(["isSubmitting","formSubmitted","errors"].includes(r==null?void 0:r.key))return{...e,errors:a,[r==null?void 0:r.key]:r==null?void 0:r.value};i[r==null?void 0:r.key]=r==null?void 0:r.value}return{...e,errors:a,values:i};case"addError":return r!=null&&r.key&&!a[r==null?void 0:r.key]&&(a[r==null?void 0:r.key]=r==null?void 0:r.value),{...e,errors:a};case"removeError":return r!=null&&r.key&&a[r==null?void 0:r.key]&&delete a[r==null?void 0:r.key],{...e,errors:a};case"submitForm":{const{fields:s=[],dispatch:o=()=>{},onSuccess:l=()=>{},onFailure:u=()=>{},intl:c}=r,h=bn(Object.keys(a));for(const p of s)if(p.validation)for(let m=0;m<p.validation.length;m++){const{condition:g="required",error:f=!1}=p.validation[m];let D=!1;if(typeof g=="function"){const v=g(i);v&&(D=f||v)}else{const v=i[p.id];switch(g){case"required":(!v||typeof v=="string"&&v.trim().length===0)&&(D=f||(c==null?void 0:c.formatMessage({id:"form_error_required"})));break;case"no-numbers":{v&&!/^([^0-9]*)$/.test(v)&&(D=f||(c==null?void 0:c.formatMessage({id:"form_error_numbers"})));break}case"valid-email":{v&&!/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(v)&&(D=f||(c==null?void 0:c.formatMessage({id:"form_error_email"})));break}case"valid-url":{v&&!/^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/.test(v)&&(D=f||(c==null?void 0:c.formatMessage({id:"form_error_url"})));break}default:console.warn("WARNING! No field validation condition has been set")}}if(D){o({type:"addError",payload:{key:p.id,value:D}}),h.push(p.id);break}}return h.length===0?l(i):u(i,h),{...e,isSubmitting:!1}}case"formSubmitted":return{...e,isSubmitting:!1,formSubmitted:!0,errors:{}};case"formSubmittedAndReset":return{isSubmitting:!1,formSubmitted:!0,errors:{}};default:return e}};let hi=null;const ln=({element:e="form",fields:t,className:n="",id:r=t.length?`form__${t[0].id}`:"form",formRef:a,intlPath:i=!1,button:s={variant:"primary",size:"large",customOnSubmit:!1},secondaryActionButton:o={variant:"secondary",size:"large"},meta:l,children:u,gtm:c={context:"Form",event:"form-submit-click"},functions:{onSuccess:h=async()=>{},onCancel:p=()=>{},onCatch:m=()=>{},onFailure:g=()=>{}}={onSuccess:async()=>{},onCancel:()=>{},onCatch:()=>{},onFailure:()=>{}},...f})=>{const{customOnSubmit:D,hideButton:v,overwriteSubmittingText:E=!1,...B}=s,x=40,{shouldShowCancelButton:k=!1,shouldReset:T=!0,shouldHide:S=!0,showRequiredLabels:q=!0,showSuccessMessage:N=!1}=l||{},I=ue.useIntl(),z={};t.length&&t.forEach(A=>{const L=A.id||A.name;L&&(z[L]=A.value||"")});const[w,F]=y.useReducer(zm,{isSubmitting:!1,formSubmitted:!1,errors:{},values:z}),{errors:j,isSubmitting:M,formSubmitted:V,values:G}=w;y.useEffect(()=>{T&&V&&(hi=setTimeout(()=>{F({type:"updateValue",payload:{key:"formSubmitted",value:!1}})},3e3))},[V]),y.useEffect(()=>()=>{hi&&clearTimeout(hi)},[]),y.useEffect(()=>{const A=L=>{F({type:"updateValue",payload:{key:L.detail.id,value:L.detail.value}})};return document.addEventListener("dropdownMultiSelectSubmit",A),()=>{document.removeEventListener("dropdownMultiSelectSubmit",A)}},[]);const J=y.useRef(null),ae=a||J;if(!t.length)return null;let C=B.text;C||(C=s.children||I.formatMessage({id:"form_submit"})),delete B.text;const R=()=>{if(!M){if(F({type:"toggleSubmitting"}),s.disabled){typeof s.disabled=="object"&&s.disabled.isClickable&&F({type:"submitForm",payload:{fields:t,dispatch:F,intl:I}});return}F({type:"submitForm",payload:{fields:t,dispatch:F,onSuccess:async A=>{try{await h(A),F({type:T?"formSubmittedAndReset":"formSubmitted"})}catch(L){m(L),F({type:"updateValue",payload:{key:"isSubmitting",value:!1}})}},onFailure:(A,L)=>{g(A,L),F({type:"updateValue",payload:{key:"isSubmitting",value:!1}})},intl:I}})}},_=[{...B,icon:V?{icon:"tick",position:"left"}:!1,className:"gtm-trackable",onClick:A=>{var U;if(A.preventDefault(),A.stopPropagation(),M)return;let L=0;if((U=ae==null?void 0:ae.current)!=null&&U.id){const re=document.getElementById(ae.current.id);re&&(L=re.getBoundingClientRect().top+window.scrollY)}const $=document.getElementById("header");$&&(L=L-$.offsetHeight-x),L<0&&(L=0),window.scrollTo({top:L,behavior:"smooth"}),R()},disabled:M||V||s.disabled,"data-gtm-event-context":c.context,"data-gtm-event-type":c.event,children:E?C:M||V?I.formatMessage({id:`form_${M?"submitting":"submitted"}`}):C}];return k&&_.unshift({...o,className:"gtm-trackable","data-gtm-event-context":c.context,"data-gtm-event-type":c.event,disabled:M||V,onClick:p,children:o.text||I.formatMessage({id:"form_cancel"})}),d.jsxs(d.Fragment,{children:[y.createElement(e,{...f,id:r,className:Y("form",n),ref:ae},d.jsxs(d.Fragment,{children:[j!=null&&j.general?d.jsx(un,{variant:"error",text:I.formatMessage({id:"form_error_generalError"})}):null,u,(!S||!M&&!V||D)&&t.map((A,L)=>{const{id:$=A.name||L,component:U,functions:re={onChange:()=>{}},submitOnEnter:te=!1}=A;if(U)return d.jsx(U,{...A.props||{}},`component-${$}-${L}`);const ne=(G==null?void 0:G[$])||"",le={...re,onChange:Q=>{F({type:"updateValue",payload:{key:$,value:Q}}),re.onChange(Q&&Q.toString(),F)}};return te&&(le.onKeyDown=Q=>{Q.key==="Enter"&&(Q.stopPropagation(),Q.preventDefault(),R()),re.onKeyDown&&re.onKeyDown(Q)}),d.jsx(Lm,{intlPath:i,...A,showRequiredLabels:q,value:ne,error:j==null?void 0:j[$],functions:le},$)}),v?null:(M||V)&&D?D:d.jsx(rr,{className:Y("cta",{center:M||V,submitted:V}),buttons:_})]})),N&&V&&d.jsx(Fr,{className:"success",children:typeof N=="string"?N:I.formatMessage({id:"form_success"})})]})};const Yr="passwordRules_",ld="isMoreThanEightCharacters",cd="includesNumberAndSymbol",dd="includesLowerAndUppercase",qm={[ld]:"8Characters",[cd]:"numberSymbol",[dd]:"lowercaseUppercase"},Wm=({matchingRules:e={isMoreThanEightCharacters:!1,includesNumberAndSymbol:!1,includesLowerAndUppercase:!1},className:t=""})=>{const n=ue.useIntl();return d.jsxs("aside",{className:Y("password-rules",t),children:[d.jsx("small",{children:n.formatMessage({id:`${Yr}intro`})}),d.jsx("ul",{children:[ld,cd,dd].map(r=>d.jsxs("li",{className:Y({matches:e[r]}),children:[d.jsxs(Ie,{children:[n.formatMessage({id:`${Yr}rule_label`})," "]}),d.jsx("span",{children:n.formatMessage({id:`${Yr}rule_${qm[r]}`})}),!e[r]&&d.jsxs(Ie,{element:"strong",children:[" ",n.formatMessage({id:`${Yr}notMet`})]})]},`rule-${r}`))})]})},fd=y.memo(Wm);const Hm=({text:e={},topRating:t=5,functions:{createRating:n=()=>null,updateRating:r=()=>{},reportError:a=()=>{}},className:i="",hasLoaded:s=!1})=>{const o=ue.useIntl(),[l,u]=y.useState({setUp:!1,id:null,rating:null,disabled:!0}),c=async()=>{try{const v=await n();u(E=>({...E,setUp:!0,id:v&&v.id,disabled:!1}))}catch(v){u(E=>({...E,setUp:!0,disabled:!0})),a(v)}};if(y.useEffect(()=>{s&&!l.setUp&&c()},[s]),!s)return d.jsx(kt,{className:"rating-placeholder"});const{id:h,rating:p,disabled:m}=l,g="ratings_",f={text:o.formatMessage({id:`${g}text`}),low:o.formatMessage({id:`${g}low`}),high:o.formatMessage({id:`${g}high`}),success:o.formatMessage({id:`${g}success`}),...e},D=async v=>{if(!(!h||m))try{u(E=>({...E,rating:v,disabled:!0})),await r({id:h,value:v})}catch(E){u(B=>({...B,rating:null})),a(E)}finally{u(E=>({...E,disabled:!1}))}};return d.jsxs("div",{className:Y("rating",i),children:[d.jsx("span",{className:"label",children:f[p?"success":"text"]}),d.jsx("ol",{children:Array.from(new Array(t).keys()).map(v=>{const E=v+1;return d.jsx("li",{className:Y({selected:p&&E<=p}),children:d.jsx(_e,{variant:"tertiary",size:"small",icon:{icon:`star${!p||E>p?"_empty":""}`,position:"left",hover:"star"},screenreaderText:`${o.formatMessage({id:`${g}stars`},{number:E,total:t})}${E===1||E===t?` - ${f[E===1?"low":"high"]}`:""}`,onClick:B=>{B.preventDefault(),B.stopPropagation(),D(E)},disabled:m})},`rating-${E}`)})})]})};function Um(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}function hs(e,t){return Array(t+1).join(e)}function Vm(e){return e.replace(/^\n*/,"")}function Km(e){for(var t=e.length;t>0&&e[t-1]===`
|
|
39
|
+
${dr(t,"mailto",n)}&src=email`)}`},{key:"clipboard-copy",icon:"share_copy-link",url:dr(t,"copy",n),shouldRender:()=>navigator&&navigator.clipboard&&navigator.clipboard.writeText,onClick:(r,a)=>(r.preventDefault(),r.stopPropagation(),navigator.clipboard.writeText(a))}];const Tm="shareLinks_",Sm=({title:e,link:t,referrer:n,gtmContext:r="ShareLinks",size:a="large",variant:i="default",className:s=""})=>{const o=ue.useIntl(),l=Am({title:e,link:t,referrer:n});return d.jsxs("aside",{className:Y("share-links",a,i,s),children:[d.jsx("p",{className:"text-small",children:o.formatMessage({id:"shareLinks_label"})}),d.jsx("ul",{children:l.map(({key:u,icon:c,url:h,shouldRender:p=!0,onClick:m})=>{if(typeof p=="function"&&!p())return null;const g={};return m&&(g.onClick=f=>m(f,h)),d.jsx("li",{children:d.jsx(_e,{size:a,variant:"tertiary",icon:{icon:c||u},href:h,target:"_blank",rel:"noopener noreferrer",className:"gtm-trackable","data-gtm-event-context":`${r}-SocialButtons`,"data-gtm-event-type":`${u}-click`,"data-testid":"link",screenreaderText:o.formatMessage({id:`${Tm}link_${u}`}),...g})},u)})})]})};const jm=({tabs:e,className:t="",preventLocationChange:n})=>{var p;const r=(m,g,f)=>(m||(m=`panel-${window.btoa(g)}-${f}`),m);let a=e.findIndex(m=>m.current===!0);if(a<0&&(a=0),window.location.hash){const m=window.location.hash.replace("#","");if(e.find(f=>f.id===m)){for(let f=0;f<e.length;f++)if(r(e[f].id,e[f].text,f)===m){a=f;break}}}const[i,s]=y.useState((p=e[a])!=null&&p.id?e[a].id:r(e[a].id,e[a].text,a)),[o,l]=y.useState(""),u=(m,g)=>{switch(m.key){case"ArrowLeft":case"ArrowRight":{m.preventDefault();let f=g;m.key==="ArrowLeft"?g>0?f=g-1:f=e.length-1:m.key==="ArrowRight"&&(g<e.length-1?f=g+1:f=0);const D=r(e[f].id,e[f].text,f),v=document.getElementById(`tab-${D}`);v==null||v.focus(),l(D);break}case"Enter":s(o),window.location.hash=`#${o}`;break}};y.useEffect(()=>{if(e[a].hasCarousel){const m=new CustomEvent("hiddenSectionVisible",{detail:{id:i}});window.dispatchEvent(m)}},[i]);const c=[],h=[];return e.forEach(({id:m,text:g,content:f,href:D,hasCarousel:v},E)=>{m=r(m,g,E);const B=i===m,x={};D||(x["aria-controls"]=m,x.onClick=k=>{k.preventDefault(),k.stopPropagation(),s(m),!n&&(window.location.hash=`#${m}`)},h.push(d.jsx("section",{id:m,hidden:!B,role:"tabpanel","aria-labelledby":`tab-${m}`,"aria-live":B?"assertive":"off",children:typeof f=="string"?d.jsx("p",{children:f}):f},`section-${m}`))),c.push(d.jsx("li",{"data-testid":"navigation-tab",children:d.jsx("a",{href:D||`#${m}`,id:`tab-${m}`,"aria-controls":m,className:Y({selected:B}),role:"tab",tabIndex:B?0:-1,"aria-selected":B,onKeyDown:k=>u(k,E),...x,children:g})},`tab-${m}`))}),d.jsxs("div",{className:Y("tabs-wrapper",t),children:[d.jsx("ul",{className:"tabs",role:"tablist",children:c}),d.jsx("div",{className:"tab-content",children:h})]})};const Om={"2-1":901,"1-3":769,"1-1":769},id=({layout:e="2-1",hideOnMobile:t=!1,hasCSSContainers:n=!1,className:r="",children:a})=>{const i=tr(!0);let s=a;return y.Children.count(a)===1&&(s=y.Children.toArray(a)[0],s.props&&(s=s.props.children)),d.jsx("section",{className:Y("columns",`layout-${e}`,r,{"has-containers":n}),children:y.Children.map(s,(o,l)=>t!==!1&&l===t&&i&&i<Om[e]?null:o)})};const Gs=({id:e="character-limit",limit:t,valueLength:n,...r})=>{const a=ue.useIntl(),i="form_fieldWrapper_characterLimit";if(t===0)return null;const s=t-n,o=Math.abs(n-t),l=n>=.99*t,u=n>=.9*t&&n<.99*t,c=n>t;return d.jsxs(d.Fragment,{children:[d.jsx("small",{id:e,className:Y("character-limit",{"near-limit":l,"approaching-limit":u}),"aria-live":"polite","aria-label":c?"":a.formatMessage({id:`${i}_aria_${s<0?"over":"default"}`},{remaining:s,over:o,limit:t}),children:c?a.formatMessage({id:`${i}_aria_${s<0?"over":"default"}`},{remaining:s,over:o,limit:t}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"hidden",children:a.formatMessage({id:i})}),n," / ",t]})}),d.jsx(Ie,{showOnFocus:!1,id:`${e}-info`,children:a.formatMessage({id:`${i}_info`},{limit:t})})]})},Ya=e=>(e==null?void 0:e.toString().length)||0,sd=(e,t=null)=>{const n={};return e===0||(n["data-character-limit"]=e,t&&(n.functions={onChange:r=>{Ya(r)>e&&(r=r==null?void 0:r.toString().slice(0,e)),t(r)}})),n};const Zr="emailHelperTextBox_",od=({id:e="email-helper-textbox",type:t,email:n,redirectPath:r,resendVerificationCode:a})=>{const i=ue.useIntl(),[s,o]=y.useState({path:`${Zr}default`,type:"default",link:{},mail:{},error:""}),[l,u]=y.useState(!1),c=y.useCallback(g=>{g.preventDefault(),g.stopPropagation();const f=D=>{o({path:`${Zr}error_verificationFailedToSend`,type:"error",link:{"data-gtm-event-context":"VerifyEmailBox","data-gtm-event-type":"SendEmailClick",className:"gtm-trackable",onClick:v=>c(v),href:"#","data-testid":"send-verify-email-click"},mail:{href:"mailto:concierge@apolitical.co",className:"gtm-trackable","data-gtm-event-context":"ErrorVerifyingBox","data-gtm-event-type":"email-concierge-click"},error:D})};if(typeof a!="function"){f(i.formatMessage({id:`${Zr}error_noFunction`}));return}u(!0),a(n).then(()=>{localStorage.setItem("email",n),window.location.href=r||"/signup/verify-email"}).catch(D=>{f(D.message)}).finally(()=>{u(!1)})},[n,r,a]);y.useEffect(()=>{let g=Zr,f="default",D={},v={};switch(t){case"gov":g+="autoApproved",f="success";break;case"nonGov":g+="unrecognisedEmail",f="error",D={href:"https://about.apolitical.co/who-can-join-the-community","data-gtm-event-context":"NonGovEmailHelperTextBox","data-gtm-event-type":"LearnMoreClick"};break;case"pending":g+="pendingApproval",f="error",v={href:"mailto:concierge@apolitical.co",className:"gtm-trackable","data-gtm-event-context":"EmailExistsBox","data-gtm-event-type":"email-concierge-click"};break;case"verify":g+="emailUnverified",f="error",D={href:"#","data-gtm-event-context":"VerifyEmailBox","data-gtm-event-type":"SendEmailClick",className:"gtm-trackable",onClick:E=>c(E),"data-testid":"send-verify-email-click"};break;case"exists":g+="emailAlreadyExists",f="error",D={href:"/user-onboarding/login","data-gtm-event-context":"EmailExistsBox","data-gtm-event-type":"login-click"},v={href:"mailto:concierge@apolitical.co",className:"gtm-trackable","data-gtm-event-context":"EmailExistsBox","data-gtm-event-type":"email-concierge-click"};break;default:g+="default",D={href:"https://about.apolitical.co/who-can-join-the-community","data-gtm-event-context":"DefaultEmailHelperTextBox","data-gtm-event-type":"LearnMoreClick"};break}o({...s,path:g,type:f,link:D,mail:v})},[t]);const h={};return["link","mail"].forEach(g=>{h[g]=Object.keys(s[g]).length?f=>d.jsx("a",{...s[g],children:f}):f=>f}),d.jsx(Uc,{id:e,type:s.type,heading:l?!1:i.formatMessage({id:`${s.path}_title`}),children:l?d.jsxs(d.Fragment,{children:[d.jsx(kt,{element:"span"}),d.jsx(kt,{element:"span"})]}):i.formatMessage({id:`${s.path}_text`},{...h,strong:g=>d.jsx("strong",{children:g}),em:g=>d.jsx("em",{children:g}),br:d.jsxs(d.Fragment,{children:[d.jsx("br",{}),d.jsx("br",{})]}),error:s.error})})},Ln=({className:e="",element:t="input",id:n,inputRef:r,functions:a={onChange:()=>{}},name:i=n,placeholder:s,type:o="text",value:l,autoFocus:u,...c})=>{const h=y.useRef(),p=r||h;return y.useEffect(()=>{var m;u&&((m=p.current)==null||m.focus())},[]),!(c!=null&&c.autoComplete)&&["email"].includes(o)&&(c.autoComplete="email"),y.createElement(t,{ref:p,...c,type:o,id:n,name:i,className:Y(e,t,{"has-scrollbar":o==="textarea"&&p.current&&p.current.clientHeight<p.current.scrollHeight}),value:l,placeholder:s,autoFocus:u,...a,onChange:m=>{const g=m.target;a.onChange(g.value)}})};const Pn={UP:"ArrowUp",DOWN:"ArrowDown",ENTER:"Enter"},Pm=500,Nm=({id:e,name:t=e,value:n,placeholder:r,functions:a={onChange:()=>{},onKeyInput:async()=>new Promise(()=>{})},...i})=>{const{onChange:s=()=>{},onKeyInput:o=async()=>{}}=a,[{input:l,displayInput:u,debouncedInput:c},h]=y.useState({input:n,displayInput:n,debouncedInput:n}),[{predictions:p,activePredictionIndex:m,isPredictionSelected:g},f]=y.useState({predictions:[],activePredictionIndex:-1,isPredictionSelected:!!n}),{formatMessage:D}=ue.useIntl();r||(r=D({id:"inputAutocomplete_placeholder"})),y.useEffect(()=>{const x=setTimeout(()=>{g||h(k=>({...k,debouncedInput:l}))},Pm);return()=>{clearTimeout(x)}},[l,g]),y.useEffect(()=>{c&&!g?(async()=>{try{const k=await o(c)||[];f(T=>({...T,predictions:k}))}catch(k){console.error("Error fetching predictions:",k),f(T=>({...T,predictions:[]}))}})():f(x=>({...x,predictions:[]}))},[c,g]),y.useEffect(()=>{m>=0&&p[m]&&h(x=>({...x,displayInput:p[m].description}))},[m,p]);const v=x=>{[Pn.DOWN,Pn.UP,Pn.ENTER].includes(x.key)&&(x.preventDefault(),x.key===Pn.DOWN&&m<p.length-1?f(k=>({...k,activePredictionIndex:m+1})):x.key===Pn.UP&&m>0?f(k=>({...k,activePredictionIndex:m-1})):x.key===Pn.ENTER&&m>-1&&(s(p[m].description),h(k=>({...k,input:p[m].description})),f(k=>({...k,predictions:[],isPredictionSelected:!0}))))},E=x=>{s(x.target.value),h(k=>({...k,input:x.target.value,displayInput:x.target.value})),f(k=>({...k,activePredictionIndex:-1,isPredictionSelected:!1}))},B=x=>{s(x.description),h(k=>({...k,input:x.description,displayInput:x.description})),f(k=>({...k,isPredictionSelected:!0,predictions:[]}))};return d.jsxs(d.Fragment,{children:[d.jsx("input",{type:"text",value:u,onChange:E,onKeyDown:v,placeholder:r,name:t,id:e,...i}),d.jsx("ul",{className:"predictions-list",children:p.map((x,k)=>d.jsx("li",{onClick:()=>B(x),onMouseEnter:()=>f(T=>({...T,activePredictionIndex:k})),className:Y("predictions-list-item",{active:k===m}),children:x.description},k))})]})};const ud=({className:e="",disabled:t,element:n="p",functions:r={onChange:()=>{}},id:a,inputRef:i,intlPath:s=!1,label:o,shownValue:l=!0,type:u="checkbox",value:c,...h})=>{const p=ue.useIntl(),{onChange:m,...g}=r,f=()=>{t||m(c?null:l)},D=d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:i,id:a,name:a,type:u,value:l,checked:c,onKeyDown:v=>{(v.key==="Enter"||v.code==="Space")&&(v.preventDefault(),v.stopPropagation(),f())},readOnly:!0,disabled:t}),d.jsx("span",{className:"pretty-checkbox","data-testid":"pretty-checkbox"}),d.jsx("label",{htmlFor:a,children:o||p.formatMessage({id:s?`${s}_${a}`:a})})]});return y.createElement(n,{onClick:v=>{const E=v.target;E.nodeName.toLowerCase()==="a"||E.parentNode&&E.parentNode.nodeName.toLowerCase()==="a"||(v.preventDefault(),v.stopPropagation(),f())},className:Y("checkbox-wrapper",e),...h,...g},D)};const Rm=y.memo(function({direction:t="down"}){return d.jsx(Wa,{className:Y("rotating-chevron",`direction-${t}`)})});const Mm=({className:e,options:t,initialValue:n,value:r,functions:a={onChange:()=>{},onMultiSelectSubmit:()=>{}},gtm:{context:i}={context:""},placeholder:s,multiSelect:o,multiSelectOptions:l,id:u})=>{const c=ue.useIntl(),[h,p]=y.useState(!1),m=r||n,g=Array.isArray(m)?[...m]:m?[m]:[],[f,D]=y.useState(g);let v;Array.isArray(f)&&f.length===1&&typeof f[0]=="string"?v=t&&f?t.find(S=>S.id===f[0]):t?t[0]:{id:"",label:""}:Array.isArray(f)&&f.length===1&&typeof f[0]!="string"?v=f[0]:v={id:"",label:""},y.useEffect(()=>{D(g)},[r,n]);const{onChange:E,onMultiSelectSubmit:B,...x}=a,k=S=>{if(o){let q=[];f!=null&&f.includes(S.id)?q=f.filter(N=>N!==S.id):q=[...f,S.id],D([...q]),E&&E([...q])}else D([S]),E&&E(S.id),p(!1)},T=S=>{if(S==="all"){const q=(t==null?void 0:t.map(N=>N.id))||[];D(q),E&&E(q)}else D([]),E&&E([])};return d.jsxs("div",{className:Y("dropdown-wrapper",e),children:[d.jsxs("button",{className:"input","aria-expanded":h,"aria-haspopup":"listbox","aria-controls":"dropdown-list",onClick:S=>{S.preventDefault(),S.stopPropagation(),p(!h)},"data-testid":"dropdown-selector",...x,children:[o?`${s} · ${f.length}`:v.label,d.jsx(Rm,{direction:h?"up":"down"})]}),d.jsx("select",{defaultValue:v.id,onChange:S=>{S.preventDefault(),S.stopPropagation();const q=t&&t.find(N=>N.id===S.target.value);k(q)},hidden:!h,...x,children:t==null?void 0:t.map(S=>d.jsx("option",{value:S.id,className:"gtm-trackable","data-gtm-event-type":`${S.id}-click`,"data-gtm-event-context":i,children:S.label},S.id))}),d.jsxs("div",{className:"menu-options input dropdown-menu",role:"menu",hidden:!h,children:[d.jsxs("div",{className:"dropdown-menu-list",children:[(l==null?void 0:l.topbar)&&d.jsxs("div",{className:"action-bar",children:[d.jsx("p",{children:`${f==null?void 0:f.length} selected`}),d.jsxs("ul",{children:[d.jsx("li",{children:d.jsx(_e,{variant:"tertiary",size:"small",onClick:()=>T("all"),className:"gtm-trackable","data-gtm-event-type":"all-click","data-gtm-event-context":i,children:c.formatMessage({id:"dropdown_menu_multiselect_all"})})}),d.jsx("li",{children:d.jsx(_e,{variant:"tertiary",size:"small",onClick:()=>T("none"),className:"gtm-trackable","data-gtm-event-type":"none-click","data-gtm-event-context":i,children:c.formatMessage({id:"dropdown_menu_multiselect_none"})})})]})]}),d.jsx("ul",{children:t==null?void 0:t.map(S=>{const q=S.id===v.id||(f==null?void 0:f.includes(S))||(f==null?void 0:f.includes(S.id));return d.jsx("li",{"data-testid":"dropdown-options",children:d.jsxs("button",{className:Y("gtm-trackable",{selected:q,"selected-single":q&&!o}),"data-gtm-event-type":`${S.id}-click`,"data-gtm-event-context":i,onClick:N=>{N.preventDefault(),N.stopPropagation(),k(S)},role:"menuitem","aria-current":q,"data-testid":q?"current-selection":"",children:[o&&d.jsx("span",{className:"pretty-checkbox","data-testid":"pretty-checkbox"}),d.jsx("span",{className:Y({"menu-option-label":o}),children:S.label})]})},S.id)})})]}),(l==null?void 0:l.submitSection)&&d.jsx("p",{className:"submit",children:d.jsx(_e,{variant:"secondary",onClick:()=>{B&&B(f),document.dispatchEvent(new CustomEvent("dropdownMultiSelectSubmit",{detail:{id:u||"dropdown-multi-select",value:f}})),p(!1)},children:c.formatMessage({id:"form_submit"})})})]})]})};const Im=({className:e="",functions:t={onChange:()=>{}},intlPath:n=!1,id:r,label:a,multiSelect:i=!1,name:s,options:o,required:l,type:u="checkboxes",value:c,...h})=>{const p=ue.useIntl(),m=i?c:[],g=c;return d.jsx("ul",{...h,className:Y("options-wrapper",e),"data-testid":`ul-${r}`,children:o==null?void 0:o.map(({id:f,label:D=!1,value:v=f,disabled:E=!1})=>{const B=`${r}_${f}`,x=()=>{if(E)return;let k;if(i){const T=m==null?void 0:m.indexOf(v);Array.isArray(m)&&T>=0?(k=m,k.splice(T,1)):(!m||m.length===0?k=[]:k=m,k.push(v))}else k=g===v?void 0:v;t.onChange(k)};return d.jsx(ud,{element:"li",id:B,type:u==="checkboxes"?"checkbox":"radio",shownValue:v,value:i?m==null?void 0:m.includes(v):g===v,functions:{...t,onChange:x},intlPath:n,label:D||p.formatMessage({id:n?`${n}_${f}`:f}),disabled:E},B)})})};const $m=({inputRef:e,type:t="password",gtm:{context:n}={context:void 0},autoComplete:r="on",...a})=>{const i=ue.useIntl(),s=y.useRef(),o=e||s,[l,u]=y.useState(!1),[c,h]=y.useState(t),p=()=>{var m;u(!l),h(l?"password":"text"),(m=o.current)==null||m.focus()};return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:Y("show-password gtm-trackable",{"password-visible":l}),"data-gtm-event-context":n,"data-gtm-event-type":`${l?"hide":"show"}-password-click`,onClick:p,"aria-label":i.formatMessage({id:`showpassword_aria_${l?"hide":"show"}`}),children:i.formatMessage({id:`showpassword_${l?"hide":"show"}`})}),d.jsx(Ln,{inputRef:o,type:c,autoComplete:r,...a})]})};const Nn={text:{component:Ln},email:{component:Ln},url:{component:Ln},textarea:{component:Ln,props:{element:"textarea",rows:4,cols:10}},checkbox:{component:ud},checkboxes:{component:Im,props:{multiSelect:!0}},select:{component:Mm},password:{component:$m},autocomplete:{component:Nm}},Lm=({id:e,intlPath:t=!1,className:n="",error:r,functions:a={onChange:()=>{}},limit:i=0,showRequiredLabels:s=!0,type:o,validation:l,value:u,submitOnEnter:c,...h})=>{const p=ue.useIntl(),m=l&&l.some(({condition:N})=>N==="required"),g=Ya(u),f=o&&Nn[o]&&Nn[o].component?Nn[o].component:Ln,D=o&&["checkboxes"].includes(o),v=r&&`error-${e}`,E=`character-limit-${e}`,B={};D?B.element="legend":B.htmlFor=e;let x={...h,id:e,name:e,className:r?"error":"",type:o,required:m,"aria-required":m,functions:bn(a),value:u};const k=N=>{x["aria-describedby"]?x["aria-describedby"]+=` ${N}`:x["aria-describedby"]=N};if(i>0){const N=sd(i,a.onChange);k(`${E}-info`),x={...x,...N},N.functions&&typeof N.functions=="object"&&(x.functions={...x.functions,...N.functions})}o&&Nn[o]&&Nn[o].props&&(x={...x,...Nn[o].props}),D&&(x.intlPath=`${t}_${e}`),r&&(x["aria-invalid"]=!0,x["aria-errormessage"]=v,k(v));const T=h.label||p.formatMessage({id:t?`${t}_${e}`:e}),S=({...N})=>r?y.createElement(N.as||"p",{id:v,className:"error text-small",...N},r):null;if(o&&["checkbox"].includes(o))return d.jsxs(d.Fragment,{children:[d.jsx(f,{...x,label:T,className:Y("field-wrapper",n)}),d.jsx(S,{as:"p"})]});const q=N=>y.createElement(N.element||"label",{...N,className:"checkboxes-label text-small","data-testid":`label-${e}`});return d.jsx(d.Fragment,{children:y.createElement(D?"fieldset":"div",{className:Y("field-wrapper text-medium",n)},d.jsxs(d.Fragment,{children:[y.createElement(D?"div":"p",{className:"field-label"},d.jsx(d.Fragment,{children:d.jsxs(q,{...B,children:[T,m&&s&&d.jsxs(d.Fragment,{children:[" ",d.jsxs("small",{children:["(",p.formatMessage({id:"form_fieldWrapper_required"}),")"]})]})]})})),y.createElement(D?"div":"p",{className:"field-component"},d.jsxs(d.Fragment,{children:[d.jsx(f,{...x}),d.jsx(Gs,{id:E,limit:i,valueLength:g})]})),d.jsx(S,{})]}))})},zm=(e,t)=>{const{type:n,payload:r}=t,a=e.errors?bn(e.errors):{},i=e.values?bn(e.values):{};switch(n){case"toggleSubmitting":return{...e,isSubmitting:!e.isSubmitting};case"updateValue":if(r!=null&&r.key&&a[r==null?void 0:r.key]&&delete a[r==null?void 0:r.key],r!=null&&r.key){if(["isSubmitting","formSubmitted","errors"].includes(r==null?void 0:r.key))return{...e,errors:a,[r==null?void 0:r.key]:r==null?void 0:r.value};i[r==null?void 0:r.key]=r==null?void 0:r.value}return{...e,errors:a,values:i};case"addError":return r!=null&&r.key&&!a[r==null?void 0:r.key]&&(a[r==null?void 0:r.key]=r==null?void 0:r.value),{...e,errors:a};case"removeError":return r!=null&&r.key&&a[r==null?void 0:r.key]&&delete a[r==null?void 0:r.key],{...e,errors:a};case"submitForm":{const{fields:s=[],dispatch:o=()=>{},onSuccess:l=()=>{},onFailure:u=()=>{},intl:c}=r,h=bn(Object.keys(a));for(const p of s)if(p.validation)for(let m=0;m<p.validation.length;m++){const{condition:g="required",error:f=!1}=p.validation[m];let D=!1;if(typeof g=="function"){const v=g(i);v&&(D=f||v)}else{const v=i[p.id];switch(g){case"required":(!v||typeof v=="string"&&v.trim().length===0)&&(D=f||(c==null?void 0:c.formatMessage({id:"form_error_required"})));break;case"no-numbers":{v&&!/^([^0-9]*)$/.test(v)&&(D=f||(c==null?void 0:c.formatMessage({id:"form_error_numbers"})));break}case"valid-email":{v&&!/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(v)&&(D=f||(c==null?void 0:c.formatMessage({id:"form_error_email"})));break}case"valid-url":{v&&!/^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/.test(v)&&(D=f||(c==null?void 0:c.formatMessage({id:"form_error_url"})));break}default:console.warn("WARNING! No field validation condition has been set")}}if(D){o({type:"addError",payload:{key:p.id,value:D}}),h.push(p.id);break}}return h.length===0?l(i):u(i,h),{...e,isSubmitting:!1}}case"formSubmitted":return{...e,isSubmitting:!1,formSubmitted:!0,errors:{}};case"formSubmittedAndReset":return{isSubmitting:!1,formSubmitted:!0,errors:{}};default:return e}};let hi=null;const ln=({element:e="form",fields:t,className:n="",id:r=t.length?`form__${t[0].id}`:"form",formRef:a,intlPath:i=!1,button:s={variant:"primary",size:"large",customOnSubmit:!1},secondaryActionButton:o={variant:"secondary",size:"large"},meta:l,children:u,gtm:c={context:"Form",event:"form-submit-click"},functions:{onSuccess:h=async()=>{},onCancel:p=()=>{},onCatch:m=()=>{},onFailure:g=()=>{}}={onSuccess:async()=>{},onCancel:()=>{},onCatch:()=>{},onFailure:()=>{}},...f})=>{const{customOnSubmit:D,hideButton:v,overwriteSubmittingText:E=!1,...B}=s,x=40,{shouldShowCancelButton:k=!1,shouldReset:T=!0,shouldHide:S=!0,showRequiredLabels:q=!0,showSuccessMessage:N=!1}=l||{},I=ue.useIntl(),z={};t.length&&t.forEach(A=>{const L=A.id||A.name;L&&(z[L]=A.value||"")});const[w,F]=y.useReducer(zm,{isSubmitting:!1,formSubmitted:!1,errors:{},values:z}),{errors:j,isSubmitting:M,formSubmitted:V,values:G}=w;y.useEffect(()=>{T&&V&&(hi=setTimeout(()=>{F({type:"updateValue",payload:{key:"formSubmitted",value:!1}})},3e3))},[V]),y.useEffect(()=>()=>{hi&&clearTimeout(hi)},[]),y.useEffect(()=>{const A=L=>{F({type:"updateValue",payload:{key:L.detail.id,value:L.detail.value}})};return document.addEventListener("dropdownMultiSelectSubmit",A),()=>{document.removeEventListener("dropdownMultiSelectSubmit",A)}},[]);const J=y.useRef(null),ae=a||J;if(!t.length)return null;let C=B.text;C||(C=s.children||I.formatMessage({id:"form_submit"})),delete B.text;const R=()=>{if(!M){if(F({type:"toggleSubmitting"}),s.disabled){typeof s.disabled=="object"&&s.disabled.isClickable&&F({type:"submitForm",payload:{fields:t,dispatch:F,intl:I}});return}F({type:"submitForm",payload:{fields:t,dispatch:F,onSuccess:async A=>{try{await h(A),F({type:T?"formSubmittedAndReset":"formSubmitted"})}catch(L){m(L),F({type:"updateValue",payload:{key:"isSubmitting",value:!1}})}},onFailure:(A,L)=>{g(A,L),F({type:"updateValue",payload:{key:"isSubmitting",value:!1}})},intl:I}})}},_=[{...B,icon:V?{icon:"tick",position:"left"}:!1,className:"gtm-trackable",onClick:A=>{var U;if(A.preventDefault(),A.stopPropagation(),M)return;let L=0;if((U=ae==null?void 0:ae.current)!=null&&U.id){const re=document.getElementById(ae.current.id);re&&(L=re.getBoundingClientRect().top+window.scrollY)}const $=document.getElementById("header");$&&(L=L-$.offsetHeight-x),L<0&&(L=0),window.scrollTo({top:L,behavior:"smooth"}),R()},disabled:M||V||s.disabled,"data-gtm-event-context":c.context,"data-gtm-event-type":c.event,children:E?C:M||V?I.formatMessage({id:`form_${M?"submitting":"submitted"}`}):C}];return k&&_.unshift({...o,className:"gtm-trackable","data-gtm-event-context":c.context,"data-gtm-event-type":c.event,disabled:M||V,onClick:p,children:o.text||I.formatMessage({id:"form_cancel"})}),d.jsxs(d.Fragment,{children:[y.createElement(e,{...f,id:r,className:Y("form",n),ref:ae},d.jsxs(d.Fragment,{children:[j!=null&&j.general?d.jsx(un,{variant:"error",text:I.formatMessage({id:"form_error_generalError"})}):null,u,(!S||!M&&!V||D)&&t.map((A,L)=>{const{id:$=A.name||L,component:U,functions:re={onChange:()=>{}},submitOnEnter:te=!1}=A;if(U)return d.jsx(U,{...A.props||{}},`component-${$}-${L}`);const ne=(G==null?void 0:G[$])||"",le={...re,onChange:Q=>{F({type:"updateValue",payload:{key:$,value:Q}}),re.onChange(Q&&Q.toString(),F)}};return te&&(le.onKeyDown=Q=>{Q.key==="Enter"&&(Q.stopPropagation(),Q.preventDefault(),R()),re.onKeyDown&&re.onKeyDown(Q)}),d.jsx(Lm,{intlPath:i,...A,showRequiredLabels:q,value:ne,error:j==null?void 0:j[$],functions:le},$)}),v?null:(M||V)&&D?D:d.jsx(rr,{className:Y("cta",{center:M||V,submitted:V}),buttons:_})]})),N&&V&&d.jsx(Fr,{className:"success",children:typeof N=="string"?N:I.formatMessage({id:"form_success"})})]})};const Yr="passwordRules_",ld="isMoreThanEightCharacters",cd="includesNumberAndSymbol",dd="includesLowerAndUppercase",qm={[ld]:"8Characters",[cd]:"numberSymbol",[dd]:"lowercaseUppercase"},Wm=({matchingRules:e={isMoreThanEightCharacters:!1,includesNumberAndSymbol:!1,includesLowerAndUppercase:!1},className:t=""})=>{const n=ue.useIntl();return d.jsxs("aside",{className:Y("password-rules",t),children:[d.jsx("small",{children:n.formatMessage({id:`${Yr}intro`})}),d.jsx("ul",{children:[ld,cd,dd].map(r=>d.jsxs("li",{className:Y({matches:e[r]}),children:[d.jsxs(Ie,{children:[n.formatMessage({id:`${Yr}rule_label`})," "]}),d.jsx("span",{children:n.formatMessage({id:`${Yr}rule_${qm[r]}`})}),!e[r]&&d.jsxs(Ie,{element:"strong",children:[" ",n.formatMessage({id:`${Yr}notMet`})]})]},`rule-${r}`))})]})},fd=y.memo(Wm);const Hm=({text:e={},topRating:t=5,functions:{createRating:n=()=>null,updateRating:r=()=>{},reportError:a=()=>{}},className:i="",hasLoaded:s=!1})=>{const o=ue.useIntl(),[l,u]=y.useState({setUp:!1,id:null,rating:null,disabled:!0}),c=async()=>{try{const v=await n();u(E=>({...E,setUp:!0,id:v&&v.id,disabled:!1}))}catch(v){u(E=>({...E,setUp:!0,disabled:!0})),a(v)}};if(y.useEffect(()=>{s&&!l.setUp&&c()},[s]),!s)return d.jsx(kt,{className:"rating-placeholder"});const{id:h,rating:p,disabled:m}=l,g="ratings_",f={text:o.formatMessage({id:`${g}text`}),low:o.formatMessage({id:`${g}low`}),high:o.formatMessage({id:`${g}high`}),success:o.formatMessage({id:`${g}success`}),...e},D=async v=>{if(!(!h||m))try{u(E=>({...E,rating:v,disabled:!0})),await r({id:h,value:v})}catch(E){u(B=>({...B,rating:null})),a(E)}finally{u(E=>({...E,disabled:!1}))}};return d.jsxs("div",{className:Y("rating",i),children:[d.jsx("span",{className:"label",children:f[p?"success":"text"]}),d.jsx("ol",{children:Array.from(new Array(t).keys()).map(v=>{const E=v+1;return d.jsx("li",{className:Y({selected:p&&E<=p}),children:d.jsx(_e,{variant:"tertiary",size:"small",icon:{icon:`star${!p||E>p?"_empty":""}`,position:"left",hover:"star"},screenreaderText:`${o.formatMessage({id:`${g}stars`},{number:E,total:t})}${E===1||E===t?` - ${f[E===1?"low":"high"]}`:""}`,onClick:B=>{B.preventDefault(),B.stopPropagation(),D(E)},disabled:m})},`rating-${E}`)})})]})};function Um(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}function hs(e,t){return Array(t+1).join(e)}function Vm(e){return e.replace(/^\n*/,"")}function Km(e){for(var t=e.length;t>0&&e[t-1]===`
|
|
40
40
|
`;)t--;return e.substring(0,t)}var Zm=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"];function Qs(e){return Js(e,Zm)}var hd=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function md(e){return Js(e,hd)}function Ym(e){return gd(e,hd)}var pd=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function Gm(e){return Js(e,pd)}function Qm(e){return gd(e,pd)}function Js(e,t){return t.indexOf(e.nodeName)>=0}function gd(e,t){return e.getElementsByTagName&&t.some(function(n){return e.getElementsByTagName(n).length})}var rt={};rt.paragraph={filter:"p",replacement:function(e){return`
|
|
41
41
|
|
|
42
42
|
`+e+`
|
|
@@ -137,7 +137,7 @@ ${m}${h?"1.":"-"} ${u}${p?`
|
|
|
137
137
|
|
|
138
138
|
`}),W=_.turndown(W)}o&&o.mentions&&(W=await Lc({text:W,template:`[${Fs}{{name}}]({{id}})`,mentions:o.mentions,listMembers:p||(()=>Promise.resolve([]))})),MC(W,_=>{x([{type:"initialValue",value:_},{type:"editorKey",value:T.toString()}]),setTimeout(()=>{x([{type:"stringValue",value:Hl(J)}])},150)})})()},[T]),y.useEffect(()=>{t!==""||!J||is(T,t)&&!z||(b.withoutNormalizing(J,()=>{X.delete(J,{at:{anchor:b.start(J,[]),focus:b.end(J,[])}}),X.deselect(J),J.children.length!==0&&X.unwrapNodes(J,{at:[0]}),X.insertNodes(J,v,{at:[0]})}),x([{type:"initialValue",value:v},{type:"lastAnchor",value:null}]))},[t]);const C=Bc(()=>{zC({editor:J,isShowing:F.show,numberOfUsers:F.numberOfUsers,listMembers:p,dispatch:x})},100);return S?d.jsx("div",{id:M,className:"rich-text-editor",children:d.jsxs(Qt.Provider,{value:{...B,id:M,isInOverlay:h,setFocus:j,dispatch:x,onMention:f,reportError:D},children:[d.jsxs(r1,{editor:J,initialValue:S,onChange:R=>{if(J.operations.some(_=>_.type!=="set_selection")){const _=WC(R);g(_),x([{type:"stringValue",value:Hl(J)}]),z||x([{type:"hasInteracted",value:!0}]),C(),c&&console.log({serialized:_,json:R})}},...l,children:[d.jsx(Zy,{className:"input",renderElement:V,renderLeaf:G,placeholder:n||u.formatMessage({id:"richTextEditor_placeholder"}),autoFocus:s,tabIndex:0,onKeyDown:R=>{if(R.key==="Enter"){F.show&&(R.preventDefault(),R.stopPropagation(),Af(J,F,x,M));const{selection:W}=J;if(W){const _=K.isCollapsed(W),[A,L]=b.node(J,W,{depth:1});let $=A,U=$.type;const re=$.children[0];if(re&&[Z.ol,Z.ul].includes(re.type)&&($=re,U=re.type),$&&de.isElement($)&&U!==Z.paragraph){if(U===Z.blockquote&&!R.shiftKey){R.stopPropagation(),R.preventDefault(),X.insertNodes(J,v);return}if(_){const[te,ne]=b.parent(J,W,{edge:"end"}),Q=te.type;if([Z.ul,Z.ol].includes(U))if(R.stopPropagation(),R.preventDefault(),Q===Z.li&&I==="Enter"){te.children.length===1&&"text"in te.children[0]&&te.children[0].text===""&&X.removeNodes(J,{at:ne}),X.insertNodes(J,v,{at:P.next(L)}),X.select(J,b.end(J,P.next(L)));return}else{const[pe,he]=IC(J,Z.li),ye={type:Z.li,children:[{text:""}]};X.insertNodes(J,ye,{at:P.next(he)}),X.select(J,b.end(J,P.next(he)))}}}}}else if(R.key==="Escape"){if(F.show){R.preventDefault(),R.stopPropagation(),x([{type:"mentionPopover",value:{...F,show:!1}}]);return}}else if(["ArrowUp","ArrowDown"].includes(R.key)&&F.show){R.preventDefault(),R.stopPropagation();const{selectedUser:W,possibleUsers:_}=F;let A=R.key==="ArrowUp"?W-1:W+1;A<0&&(A=_.length-1),A>=_.length+1&&(A=0),x([{type:"mentionPopover",value:{...F,selectedUser:A}}])}x([{type:"lastKey",value:R.key}]),LC(R,J,x,D)},onBlur:()=>{J.selection&&x([{type:"lastAnchor",value:J.selection.anchor}])},onFocus:()=>{if(N){if(!P.isPath(N.path)||!oe.has(J,N.path))return;const R=oe.get(J,N.path);let W=0;if(fe.isText(R)?W=R.text.length:R.children&&(W=R.children.length),N.offset>W)return;try{X.select(J,{anchor:N,focus:N})}catch(_){const A=_.message;D(`Error focusing editor: ${A}`)}}}}),d.jsx(ex,{}),p?d.jsx(HC,{onFallbackClick:m}):null]},k),d.jsx(Gs,{id:`character-limit-${e}`,limit:r,valueLength:Ya(q)})]})}):d.jsx(d.Fragment,{})};const cx=({id:e="form-toggle",label:t,options:n,initialValue:r,functions:{onChange:a=()=>{}},isDisabled:i=!1,className:s=""})=>{const[o,l]=y.useState(typeof r=="boolean"||typeof r=="string"?r:n[0].value);y.useEffect(()=>{r&&l(r)},[r]);const u=c=>{i||(l(c),a(c))};return d.jsxs("div",{className:Y("toggle",s),onClick:c=>{c.preventDefault(),c.stopPropagation(),u(o===n[0].value?n[1].value:n[0].value)},children:[d.jsx("p",{children:t}),d.jsx("ul",{className:Y("toggle-options",{disabled:i,on:o===n[1].value}),children:n.map(c=>{const h=`${e}-${c.value}`;return d.jsxs("li",{className:"hidden",children:[d.jsx("input",{type:"radio",id:h,name:e,value:c.value,checked:o===c.value,onChange:()=>u(c.value),disabled:i}),d.jsx("label",{htmlFor:h,children:c.label})]},h)})})]})};function dx({className:e="",userId:t,userName:n,src:r,setUserImage:a,uploadImage:i}){const[s,o]=y.useState(!1),[l,u]=y.useState(!1),c=y.useRef(null),h=async p=>{o(!0),u(!1);try{const m=p.target.files&&p.target.files[0];if(!m||!t)throw o(!1),new Error("Image file or userID is missing");const g=await i({fileObject:m,userId:t});a(f=>({...f,image:{thumbnail:g.thumbnailURL,full:g.originalURL}}))}catch{u(!0)}finally{o(!1)}o(!1)};return d.jsxs("div",{className:Y("profile-image-change-figure",e),children:[d.jsx(Yt,{className:"profile-image-change-picture",name:n,src:r,"data-testid":"profile-picture"}),l&&d.jsx("p",{className:"error text-small",children:d.jsx(ue.FormattedMessage,{id:"profile_image_change_error"})}),d.jsx("input",{id:"file",type:"file",accept:"image/*",ref:c,onChange:h,hidden:!0,"data-testid":"file-input"}),d.jsx(_e,{onClick:()=>c.current&&c.current.click(),variant:"secondary","data-gtm-event-context":"ImageField","data-gtm-event-type":`${r?"change-photo":"add-photo"}-click`,className:"gtm-trackable",disabled:s,children:d.jsx(ue.FormattedMessage,{id:s?"profile_image_change_uploading_text":r?"profile_image_change_cta_with_picture":"profile_image_change_cta_without_picture"})})]})}const If=({gtm:e,functions:{onSuccess:t=async()=>{},onFailure:n=()=>{}}})=>{const{context:r="FooterContactUsForm",event:a="contact-form-submit-click"}=e||{};return d.jsx(ln,{id:"contact-us-form",fields:[{id:"name",type:"text",className:"short",validation:[{condition:"required"}],autoComplete:"name"},{id:"email",type:"email",className:"short",validation:[{condition:"required"},{condition:"valid-email"}]},{id:"organisation",type:"text"},{id:"interests",type:"checkboxes",options:[{id:"publishingCourse",label:"Publishing or creating a course"},{id:"buyingCourse",label:"Buying courses for my team"},{id:"learningExperience",label:"Customised learning experiences"},{id:"somethingElse",label:"Something else"}]},{id:"message",type:"textarea",limit:1e3,validation:[{condition:"required"}]}],intlPath:"contactForm",gtm:{context:r,event:a},functions:{onSuccess:t,onFailure:n}})};const $f=({title:e,label:t,ctaMessage:n,titleColor:r,labelColor:a,backgroundColor:i,onClose:s,reportError:o,sendInvites:l,initialFormStatus:u="NOT_SUBMITTED"})=>{const[c,h]=y.useState([]),[p,m]=y.useState(!0),[g,f]=y.useState(u),{formatMessage:D}=ue.useIntl(),v=async x=>{x.preventDefault();try{await l(c),h([]),f("SUCCESS")}catch(k){f("ERROR"),o(k)}},E=x=>{x.preventDefault(),f("NOT_SUBMITTED"),m(!0),h([])},B=x=>{x.preventDefault(),s(),f("CLOSED")};return g==="CLOSED"?null:g==="ERROR"||g==="SUCCESS"?d.jsxs("div",{className:"invite-form-wrapper",children:[d.jsx("div",{className:"content centred",children:g==="SUCCESS"?d.jsx("h2",{className:"success-title",children:D({id:"inviteForm_success"})}):d.jsxs("h2",{className:"error-title",children:[" ",D({id:"inviteForm_error"})]})}),d.jsx(Kt,{}),d.jsx("div",{className:"footer",children:g==="SUCCESS"?d.jsxs(d.Fragment,{children:[d.jsx(_e,{variant:"secondary",onClick:E,children:D({id:"inviteForm_ctaSendMoreInvites"})}),d.jsx(_e,{onClick:B,children:D({id:"inviteForm_ctaDone"})})]}):d.jsx(_e,{onClick:E,children:D({id:"inviteForm_ctaTryAgain"})})})]}):d.jsx("div",{className:"invite-form-wrapper",children:d.jsxs("form",{style:{backgroundColor:i},onSubmit:v,className:Y("invite-form gtm-trackable"),children:[d.jsxs("fieldset",{className:"content",children:[d.jsx("h2",{className:"title",style:{color:r},children:e}),d.jsx("label",{htmlFor:"email-input",className:"label",style:{color:a},children:t}),d.jsx(Ah.ReactMultiEmail,{id:"email-input",inputClassName:"email-input input",placeholder:D({id:"inviteForm_email_placeholder"}),emails:c,onChange:x=>{h(x),m(!x.length)},autoFocus:!1,getLabel:(x,k,T)=>d.jsxs("div",{className:"email text-medium",children:[d.jsx("div",{"data-tag-item":!0,children:x}),d.jsx(_e,{variant:"tertiary",size:"small",icon:{icon:"close"},onClick:()=>{T(k),m(!c.length)},className:"remove-email-button",screenreaderText:D({id:"overlay_close"})})]},k)})]}),d.jsx(Kt,{}),d.jsx("fieldset",{className:"footer",children:d.jsx(_e,{className:"sendEmailsButton",disabled:p,children:n})})]})})},Da=e=>e.map(t=>({condition:t})),Dt={FORM_ID:"manage-account-password-change",NEW_PASSWORD:"newPassword",CONFIRMED_PASSWORD:"confirmedPassword",CURRENT_PASSWORD:"oldPassword"},fx=({functions:e,...t})=>{const{formatMessage:n}=ue.useIntl(),[r,a]=y.useState(null),[i,s]=y.useState(!1),[o,l]=y.useState({isMoreThanEightCharacters:!1,includesNumberAndSymbol:!1,includesLowerAndUppercase:!1}),u=m=>m[Dt.NEW_PASSWORD]!==m[Dt.CONFIRMED_PASSWORD]?n({id:"passwordRules_unmatched_text"}):null,c=m=>!ls(m[Dt.NEW_PASSWORD]).isValid,h=[{"data-testid":Dt.NEW_PASSWORD,id:Dt.NEW_PASSWORD,type:"password",autoComplete:"new-password",placeholder:"",label:n({id:"passwordRules_newPassword_label"}),validation:Da(["required",c]),functions:{onChange:m=>l(ls(m).matchingRules),onFocus:()=>s(!0),onBlur:()=>s(!1)}},{"data-testid":Dt.CONFIRMED_PASSWORD,id:Dt.CONFIRMED_PASSWORD,type:"password",autoComplete:"new-password",placeholder:"",label:n({id:"passwordRules_confirmPassword_label"}),validation:Da(["required",u])}];t.isPasswordChange&&h.unshift({"data-testid":Dt.CURRENT_PASSWORD,id:Dt.CURRENT_PASSWORD,type:"password",autoComplete:"current-password",placeholder:"",label:n({id:"passwordRules_currentPassword_label"}),validation:Da(["required"])}),i&&h.push({component:fd,props:{matchingRules:o}});const p={id:Dt.FORM_ID,fields:h,functions:{...e,onSuccess:async m=>(e.createPassword(m),e.onSuccess&&e.onSuccess(m)),onCatch:m=>a(m==null?void 0:m.statusCode),onFailure:(m,g)=>{(g.includes(Dt.NEW_PASSWORD)||g.includes(Dt.CONFIRMED_PASSWORD))&&s(!0)}},meta:{shouldReset:!0},...t};return d.jsxs(d.Fragment,{children:[d.jsx(ln,{...p}),r&&d.jsx(un,{variant:"error",text:r})]})};const Lf=({id:e="search",className:t="",handleToggle:n=!1,defaultValue:r="",gtmContext:a="search-bar",gtmEvent:i="form-submission"})=>{const{searchIsOpen:s=!0,isDesktopVersion:o=!1}=n||{},l=ue.useIntl(),u=y.useRef(null);Yn(()=>{!n||o||!s||u.current&&u.current.focus()},[s]);const c=h=>{h.preventDefault(),h.stopPropagation(),!(!u.current||!u.current.value||u.current.value.length<1)&&(window.location.href=`/search?search=${encodeURIComponent(u.current.value)}`)};return d.jsx("form",{onSubmit:c,className:Y("search-form gtm-trackable",t),role:"search","data-gtm-event-context":a,"data-gtm-event-type":i,children:d.jsx("fieldset",{id:`${e}-form`,hidden:n?!s:!1,children:d.jsxs("p",{children:[d.jsx(Ie,{element:"label",htmlFor:e,children:l.formatMessage({id:"search_label"})}),d.jsx("input",{ref:u,type:"search",id:e,name:e,defaultValue:r,placeholder:l.formatMessage({id:"search_placeholder"}),onKeyDown:h=>{h.key==="Enter"&&c(h)}}),d.jsx("button",{className:"clear",onClick:h=>{h.preventDefault(),h.stopPropagation(),u.current&&u.current.value&&(u.current.value="")},children:d.jsx(Ie,{children:l.formatMessage({id:"search_clear"})})}),d.jsx("button",{className:"search",onClick:c,children:d.jsx(Ie,{children:l.formatMessage({id:"search_cta"})})})]})})})},Yl=async({ref:e,validateEmail:t,dispatch:n})=>{const r=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;if(!e.current.validity.valid||!r.test(e.current.value))return n([{type:"validFields.email",value:!1}]);const a=e.current.value.toString().toLowerCase().trim(),i={valid:!1,autoApproved:!1,exists:{auth:!1,engagement:!1,registration:!1,user:!1}};let s=Object.assign({},i);try{s=await t(a),s===void 0&&(s=i)}catch{return n([{type:"shouldManuallyApprove",value:!0},{type:"emailDetails",value:{email:a,boxType:"nonGov",isEnd2End:!1}},{type:"validFields.email",value:!1}])}const{valid:o=!1,autoApproved:l=!1,exists:u}=s;let c="";return o?c=l?"gov":"nonGov":u.registration?u.engagement&&!u.user?c=u.auth?"verify":"pending":c="exists":u.auth&&(c="exists"),n([{type:"shouldDisableButton",value:!1},{type:"shouldManuallyApprove",value:!l},{type:"emailDetails",value:{email:a,boxType:c,isEnd2End:/testing\+[0-9]+@apolitical.co$/.test(a)}},{type:"validFields.email",value:!0}])},hx=e=>{const t={};for(const n of e.entries())t[n[0]]=n[1];return{name:t.full_name.toString().trim(),email:t.email_address.toString().toLowerCase().trim(),jobTitle:t.job_title,organization:t.organization,bioLink:t.url,optIn:!0,expectation:t.expectation,page:window.location.pathname,"g-recaptcha-response":t["g-recaptcha-response"]}},mx=async({refs:e,dataToSubmit:t,createAccount:n,onSuccess:r,dispatch:a,state:i})=>{if(!e.form||!e.form.current)throw new Error("No refs.form");if(!e.form.current.checkValidity()){e.hiddenValidation&&e.hiddenValidation.current&&e.hiddenValidation.current.click();return}const s=hx(new FormData(e.form.current)),o=Object.assign(s,t);await n(o),localStorage.setItem("email",s.email),r&&r({...s,...i.values}),a([{type:"showSuccessMessage",value:!0}])},px=({shouldShow:e,placeholders:t,labels:n,functions:{validateEmail:r,resendVerificationCode:a},refs:i,state:s,dispatch:o,dataToSubmit:l,intl:u})=>{const{emailDetails:c}=s,h=(m,g)=>{m.current&&s.validFields[g]!==m.current.validity.valid&&o([{type:`validFields.${g}`,value:m.current.validity.valid}])},p=[{id:"full_name",type:"text",inputRef:i.name,placeholder:u.formatMessage({id:"signup_full_name_placeholder"}),functions:{onChange:()=>h(i.name,"name"),onFocus:()=>o([{type:"loadRecaptcha",value:!0}])},autoComplete:"name",validation:[{condition:"required"},{condition:"no-numbers"}],"data-testid":"signup-name-input"},{id:"email_address",type:"email",inputRef:i.email,placeholder:u.formatMessage({id:"signup_email_address_placeholder"}),"aria-describedby":"email-helper-textbox",functions:{onBlur:()=>{Yl({ref:i.email,validateEmail:r,dispatch:o})},onChange:(m,g)=>{o([{type:"shouldDisableButton",value:!0}]),g&&g({type:"updateValue",payload:{key:"terms",value:!1}})},onFocus:()=>o([{type:"loadRecaptcha",value:!0}])},autoComplete:"email",validation:[{condition:"required"},{condition:"valid-email"}],"data-testid":"signup-email-input"},{component:od,props:{email:c.email,type:c.boxType,resendVerificationCode:a}}];return s.shouldManuallyApprove&&(p.push({id:"job_title",type:"text",inputRef:i.jobTitle,placeholder:u.formatMessage({id:"signup_job_title_placeholder"}),functions:{onChange:()=>h(i.jobTitle,"jobTitle")},validation:[{condition:"required"}],"data-testid":"signup-job-input"},{id:"organization",type:"text",inputRef:i.organisation,placeholder:u.formatMessage({id:"signup_organization_placeholder"}),functions:{onChange:()=>{h(i.organisation,"organisation")}},validation:[{condition:"required"}],autoComplete:"organization","data-testid":"signup-org-input"}),e.url&&p.push({id:"url",type:"text",label:u.formatMessage({id:"signup_url"},{small:m=>d.jsx("small",{children:m})}),placeholder:u.formatMessage({id:"signup_url_placeholder"}),validation:[{condition:"valid-url"}],"data-testid":"signup-url-input"})),e.expectation&&p.push({id:"expectation",className:"expectation",type:"text",label:(n==null?void 0:n.expectation)||u.formatMessage({id:"signup_expectation"},{small:m=>d.jsx("small",{className:"notes text-small",children:m})}),placeholder:(t==null?void 0:t.expectation)||u.formatMessage({id:"signup_expectation_placeholder"}),"data-testid":"signup-events-question"}),p.push({id:"terms",className:"text-small",type:"checkbox",inputRef:i.tc,label:u.formatMessage({id:"signup_terms"},{terms:m=>d.jsx("a",{href:"https://about.apolitical.co/terms-and-conditions","data-gtm-event-context":"SignupForm","data-gtm-event-type":"terms-of-service-click",className:"gtm-trackable",children:m}),privacy:m=>d.jsx("a",{href:"https://about.apolitical.co/privacy-policy","data-gtm-event-context":"SignupForm","data-gtm-event-type":"privacy-policy-click",className:"gtm-trackable",children:m})}),shownValue:"accepted",functions:{onChange:m=>{if(!m)return;const g=[];["name","email"].forEach(f=>{s.validFields[f]!==i[f].current.validity.valid&&(g.push({type:`validFields.${f}`,value:i[f].current.validity.valid}),f==="email"&&Yl({ref:i.email,validateEmail:r,dispatch:o}))}),g.length&&o(g)}},validation:[{condition:"required"}],"data-testid":"signup-terms-checkbox"}),p};const gx=({className:e=""})=>d.jsxs("div",{className:Y("success-message",e),"data-testid":"success-message",children:[d.jsx("p",{className:"success-title",children:d.jsx(ue.FormattedMessage,{id:"signup_success_title"})}),d.jsx(ue.FormattedMessage,{id:"signup_success_text",values:{p:t=>d.jsx("p",{children:t})}})]});const vx={validFields:{name:!1,email:!1,jobTitle:!1,organisation:!1},emailDetails:{email:"",boxType:"",isEnd2End:!1},shouldManuallyApprove:!1,shouldDisableButton:!0,loadRecaptcha:!1,showSuccessMessage:!1,showError:!1},bx=({className:e="",labels:t={},placeholders:n={},functions:r={validateEmail:()=>Promise.resolve(),createAccount:()=>Promise.resolve(),handleError:()=>{},resendVerificationCode:()=>Promise.resolve()},shouldShow:a={},submitButton:i,dataToSubmit:s={ref:"sign-up-form"},...o})=>{const l=ue.useIntl(),{title:u=!0,expectation:c=!1,url:h=!0,logInButton:p=!0,successMessage:m=!0}=a,g={title:u,expectation:c,url:h,logInButton:p,successMessage:m},[f,D]=y.useReducer(Ir,vx),{validFields:v,emailDetails:E,shouldManuallyApprove:B,shouldDisableButton:x,showSuccessMessage:k,showError:T}=f,[S,q]=Is.useCookies(["signup-this-session","functional-cookie-consent"]),N={form:y.createRef(),name:y.createRef(),email:y.createRef(),jobTitle:y.createRef(),organisation:y.createRef(),tc:y.createRef(),hiddenValidation:y.createRef()};y.useEffect(()=>{B===!0&&N.jobTitle.current&&N.jobTitle.current.focus()},[B]),y.useEffect(()=>{S["signup-this-session"]&&D([{type:"showSuccessMessage",value:!0}])},[S]),y.useEffect(()=>{k&&S["functional-cookie-consent"]&&q("signup-this-session","true",{path:"/",maxAge:3600})},[k]);const I=y.useMemo(()=>px({placeholders:n,labels:t,shouldShow:g,functions:r,refs:N,state:f,dispatch:D,dataToSubmit:s,intl:l}),[s,r,l,N,g,f]),z=x?!0:B?!Object.values(v).every(w=>w===!0):!v.name||!v.email||["exists","pending","verify"].includes(E.boxType);return g.successMessage&&k?d.jsx(gx,{className:e}):d.jsxs("fieldset",{className:Y("signup-form-fieldset",e),"data-testid":"signup-form",children:[g.title&&d.jsx("p",{className:"signup-title",children:d.jsx(ue.FormattedMessage,{id:"signup_title"})}),T&&d.jsx(un,{variant:"error",text:l.formatMessage({id:"signup_error"})}),d.jsx(ln,{className:"signup-form",formRef:N.form,id:"sign-up-form",fields:I,intlPath:"signup",button:{variant:"primary",size:"medium",text:i||l.formatMessage({id:"signup_button_join"}),disabled:z?{isClickable:!0}:!1,styling:{fullWidth:!0},"data-testid":"signup-button"},secondaryActionButton:{className:"login-button",styling:{fullWidth:!0},variant:"tertiary",size:"medium",href:"/user-onboarding/login","data-gtm-event-context":"SignupForm","data-gtm-event-type":"login-click",text:l.formatMessage({id:"signup_button_login"})},meta:{shouldReset:!1,showRequiredLabels:!1,shouldShowCancelButton:g.logInButton},gtm:{context:"SignupForm",event:"signup-submit-click"},functions:{onSuccess:async()=>{await mx({refs:N,dataToSubmit:s,createAccount:r.createAccount,onSuccess:r.onSuccess,dispatch:D,state:f})},onCatch:w=>{r.handleError(w),D([{type:"showSuccessMessage",value:!1},{type:"showError",value:!0}])}}}),d.jsx("button",{className:"validation-button",ref:N.hiddenValidation})]})};const fn=({children:e,className:t="",styling:n={},...r})=>{const{background:a="default"}=n;return d.jsx("section",{className:Y("full-width-section",t,{[a]:a!=="default"}),...r,children:e})};const yx=({text:e,buttons:t,className:n=""})=>{const r=[];return t.forEach(a=>{r.push({href:a.link,variant:"secondary",size:{mobile:"medium",1024:"large"},className:"gtm-trackable","data-gtm-event-type":"download-click","data-gtm-event-context":a.eventContext||"Download",target:"_blank",children:a.text})}),d.jsx(fn,{className:Y("download-section",n),children:d.jsxs("div",{className:"content-default",children:[y.createElement(typeof e=="string"?"h2":e.element,{className:"text"},typeof e=="string"?e:e.text),d.jsx(rr,{buttons:r})]})})};function zf({href:e,setShowModal:t}){typeof e!="string"&&t(!0)}const Dx=({icon:e,description:t,ctaMessage:n,href:r,showEditButton:a,setShowModal:i})=>{const{formatMessage:s}=ue.useIntl();return d.jsxs("div",{className:Y("edit-section-placeholder",{"has-icon":!!e}),style:Mc(e),children:[d.jsx("p",{children:t||s({id:"edit_section_placeholder_description"})}),a&&d.jsx(_e,{href:r,variant:"secondary",size:"small",onClick:()=>zf({href:r,setShowModal:i}),children:n||s({id:"edit_section_placeholder_cta"})})]})},Cx=({children:e,className:t="",formProps:n,href:r,title:a,modalTitle:i,placeholder:s,showDivider:o=!0})=>{const[l,u]=y.useState(!1),c=typeof r=="string"||!!n,h=()=>u(!1);return d.jsxs("section",{className:Y("edit-section",t),children:[n&&d.jsx(sr,{title:i||`Edit ${a}`,isOpen:l,showDivider:!1,showIcon:!1,functions:{onClose:h},className:Y("edit-section-modal"),children:d.jsx(ln,{...n,fields:n.fields,meta:{...n==null?void 0:n.meta,shouldShowCancelButton:!0,shouldReset:!1,showSuccessMessage:!0},functions:{...n==null?void 0:n.functions,onSuccess:async p=>{var m,g;(m=n==null?void 0:n.functions)!=null&&m.onSuccess&&await((g=n==null?void 0:n.functions)==null?void 0:g.onSuccess(p)),u(!1)},onCancel:h}})}),d.jsxs("div",{className:"edit-section-header",children:[d.jsx("h2",{className:"edit-section-header-title",children:a}),c&&d.jsx(_e,{href:r,variant:"tertiary",size:"small",icon:"pencil",onClick:()=>zf({href:r,setShowModal:u}),children:"Edit"})]}),e||d.jsx(Dx,{...s,href:r,setShowModal:u,showEditButton:c}),o&&d.jsx(Kt,{})]})};const xx=({title:e=!1,text:t,logos:n=[],styling:r={},className:a=""})=>{const i=n.length;if(i===0)return null;const s={element:typeof e=="object"?e.element:"h2",text:typeof e=="string"?e:typeof e=="object"?e.text:"",className:typeof e=="object"?e.className:""},{wrapLogos:o=!1,align:l="center",display:u="block"}=r;return d.jsxs("div",{className:Y("logos",a,`align-${l}`,{[u]:u!=="block","wrap-logos":o}),children:[e&&y.createElement(s.element,{className:Y("title",s.className)},s.text),t&&d.jsx("p",{children:t}),d.jsx("ul",{className:Y({"two-col":i===2||i===4,"three-col":i===5||i<=10&&i%3===0}),children:n.map(({logo:c,nameOfBusiness:h,link:p=!1,description:m=!1},g)=>{if(!c||!c.url)return null;const f=d.jsx("img",{src:c.url,width:c.width||"auto",height:c.height||"auto",alt:h});return d.jsxs("li",{children:[d.jsx("p",{className:"img-wrapper",children:p?d.jsx("a",{href:p,target:"_blank",rel:"nofollow noreferrer noopener",children:f}):f}),m&&d.jsx("small",{children:m})]},window.btoa(`${c.url}_${g}`))})})]})};let Li;const zi="contactFooter_",wx=({onSuccess:e=async()=>{},onFailure:t=()=>{}})=>{const n=y.useRef(null),[r,a]=y.useState(0),[i,s]=y.useState(!1),o=()=>{n.current&&a(n.current.clientHeight)},l=()=>{i||(s(!0),clearTimeout(Li),Li=setTimeout(()=>{o(),s(!1)},500))};return y.useEffect(()=>(o(),window.addEventListener("resize",l),()=>{clearTimeout(Li),window.removeEventListener("resize",l)}),[]),d.jsx(fn,{id:"contactForm",className:"contact-footer",children:d.jsxs("div",{className:"inner-wrapper",children:[d.jsx("h2",{children:d.jsx(ue.FormattedMessage,{id:`${zi}title`})}),d.jsxs("div",{className:"content-wrapper",ref:n,"data-testid":"content-wrapper",style:i?{}:{minHeight:r},children:[d.jsxs("aside",{children:[d.jsx("p",{children:d.jsx(ue.FormattedMessage,{id:`${zi}text`})}),d.jsx(Tn,{className:"mailto-link",href:"mailto:hello@apolitical.co",children:d.jsx(ue.FormattedMessage,{id:`${zi}email`})})]}),d.jsx(If,{functions:{onSuccess:e,onFailure:t},gtm:{context:"FooterContactUsForm",event:"contact-form-submit-click"}})]})]})})},Ex=({activeLink:e,...t})=>d.jsx(fn,{children:d.jsx(id,{layout:"1-3",children:d.jsxs(d.Fragment,{children:[d.jsx(ad,{activeLink:e}),d.jsx(Kc,{...t})]})})});const qi="cookieBanner_",Wi=["apol-cookie-banner","apolitical-performance-cookie-consent","functional-cookie-consent"],Hi=new Date(Date.now()+12*30*24*60*60*1e3),qf=()=>{const e=ue.useIntl(),[t,n,r]=Is.useCookies(Wi),[a,i]=y.useState(!t["apol-cookie-banner"]),s=()=>{Wi.forEach(c=>{n(c,!0,{path:"/",expires:Hi,domain:c==="apolitical-performance-cookie-consent"?".apolitical.co":void 0})}),i(!1),window.location.reload()},o=()=>{n("apol-cookie-banner",!0,{path:"/",expires:Hi}),Wi.forEach(c=>{if(c==="apol-cookie-banner"){n(c,!0,{path:"/",expires:Hi});return}r(c)}),i(!1)};if(!a)return null;const l=[{id:"settings",href:"/pages/cookie-policy",gtmType:"policy-page"},{id:"reject",onClick:o,gtmType:"reject-all"},{id:"accept",onClick:s,gtmType:"accepted-all"}],u=[];return l.forEach(c=>{u.push({variant:c.href?"tertiary":"primary",href:c.href,onClick:c.onClick,className:"gtm-trackable","data-gtm-event-context":"cookie-banner","data-gtm-event-type":`cookie-${c.gtmType}-click`,children:e.formatMessage({id:`${qi}buttons_${c.id}`})})}),d.jsxs("aside",{id:"cookie-banner",className:"text-medium",children:[d.jsx("h6",{children:e.formatMessage({id:`${qi}title`})}),d.jsx("p",{children:e.formatMessage({id:`${qi}text`})}),d.jsx(rr,{buttons:u})]})},Ut={platform:{order:["events","courses","articles","communities"],events:{href:"/events/",gtmType:"events-click"},courses:{href:"/microcourses/",gtmType:"microcourses-click"},articles:{href:"/solution-articles/",gtmType:"articles-click"},communities:{href:"/communities/",gtmType:"communities-click"}},community:{order:["support","post","join","guidelines"],support:{name:"Support FAQ",href:"/pages/support-faq",gtmType:"support-faq-click"},post:{href:"/pages/post-an-article",gtmType:"post-an-article-click"},join:{href:"/pages/who-can-join-the-community",gtmType:"who-can-join-click"},guidelines:{href:"/pages/values-and-guidelines",gtmType:"guidelines-and-values-click"}},company:{order:["news","insights","story","team","careers","partner","contact"],news:{href:"/learning-hub/updates/",gtmType:"news-click"},insights:{href:"/learning-hub/global-insights/",gtmType:"insights-click"},story:{href:"/pages/our-story",gtmType:"our-story-click"},team:{href:"/pages/meet-our-team",gtmType:"team-click"},careers:{href:"/pages/careers",gtmType:"careers-click"},partner:{href:"/partnerships/",gtmType:"partner-with-us-click"},contact:{href:"/pages/get-in-touch",gtmType:"contact-click"},child:"legal"},legal:{order:["privacy","terms","cookie","accessibility","ai"],privacy:{href:"https://about.apolitical.co/privacy-policy",gtmType:"privacy-policy-link"},terms:{href:"https://about.apolitical.co/terms-and-conditions",gtmType:"terms-conditions-link"},cookie:{href:"/pages/cookie-policy",gtmType:"cookie-policy-link"},ai:{href:"/pages/ai-principles",gtmType:"ai-principles-link"},accessibility:{href:"/pages/accessibility-statement",gtmType:"accessibility-link"},text:{order:["dataProtection","euDataProtection"],dataProtection:{email:$n["data-protection"].default,gtmType:"email-dpo-link"},euDataProtection:{email:$n["data-protection"].eu,gtmType:"email-eu-dpo-link"}}},contact:{text:{order:["correspondence","registered","berlin","support","business"],correspondence:{address:!0},registered:{address:!0},berlin:{address:!0},support:{email:$n.support,gtmType:"concierge-email-click"},business:{email:$n.general,gtmType:"hello-email-click"}}},social:{order:["linkedin","twitter","facebook"],linkedin:{href:"https://www.linkedin.com/company/apolitical"},twitter:{href:"https://twitter.com/apoliticalco"},facebook:{href:"https://www.facebook.com/apoliticalco"}}};const Un="footer_",Sa="SiteFooter",Gl=({group:e})=>{const t=Ut[e].order||[];let n=!1;return"text"in Ut[e]&&(n=Ut[e].text),d.jsxs(y.Fragment,{children:[d.jsx("p",{className:"pre-title",children:d.jsx(ue.FormattedMessage,{id:`${Un}${e}`})}),Array.isArray(t)&&t.length>0&&d.jsx("ul",{className:"text-medium",children:t.map(r=>{if(["order","child","text"].includes(r))return null;const{href:a,gtmType:i}=Ut[e][r],s={};return["legal"].includes(e)&&(s.target="_blank",s.rel="noopener"),d.jsx("li",{children:d.jsx("a",{href:a,className:"gtm-trackable","data-gtm-event-context":Sa,"data-gtm-event-type":i,...s,children:d.jsx(ue.FormattedMessage,{id:`${Un}${e}_${r}`})})},`${e}_${r}`)})}),typeof n!="boolean"&&"order"in n&&Array.isArray(n.order)&&d.jsx("dl",{className:"text-medium",children:n.order.map(r=>d.jsxs(y.Fragment,{children:[d.jsx("dt",{children:d.jsx(ue.FormattedMessage,{id:`${Un}${e}_${r}`})}),d.jsxs("dd",{children:[typeof n!="boolean"&&n[r].address&&d.jsx("address",{children:d.jsx(ue.FormattedMessage,{id:`${Un}${e}_${r}_address`,values:{br:d.jsx("br",{})}})}),typeof n!="boolean"&&n[r].email&&d.jsx("a",{href:`mailto:${n[r].email}`,className:"gtm-trackable","data-gtm-event-context":Sa,"data-gtm-event-type":n[r].gtmType,children:n[r].email})]})]},`dl-${e}-${r}`))})]},e)},Eo=()=>d.jsx("div",{id:"footer",children:d.jsxs("div",{className:"wrapper",children:[d.jsx(Wa,{element:"hr"}),d.jsx(Ys,{variant:"inverted",version:"full",className:"gtm-trackable","data-gtm-event-context":Sa,"data-gtm-event-type":"logo-homepage-link"}),d.jsx("footer",{children:["platform","community","company","contact"].map(e=>d.jsxs("div",{className:"group",children:[d.jsx(Gl,{group:e}),Object.keys(Ut[e]).includes("child")&&d.jsx(Gl,{group:Ut[e].child})]},e))}),d.jsx("hr",{}),d.jsxs("div",{className:"sub-footer",children:[d.jsx("ul",{children:Array.isArray(Ut.social.order)&&Ut.social.order.map(e=>{const t=Ut.social[e];return d.jsx("li",{className:e,children:d.jsx("a",{href:t.href,target:"_blank",rel:"noopener noreferrer",className:"gtm-trackable","data-gtm-event-context":Sa,"data-gtm-event-type":"social-click",children:d.jsx("span",{className:"hidden",children:d.jsx(ue.FormattedMessage,{id:`${Un}social_${e}`})})})},e)})}),d.jsx("small",{children:d.jsx(ue.FormattedMessage,{id:`${Un}copyright`,values:{currentYear:new Date().getFullYear()}})})]})]})}),$e={timeouts:{},handlerCalled:{},getIsDesktopVersion:(e,t)=>{const n={navigation:{loggedIn:769,loggedOut:881},search:{loggedIn:961,loggedOut:1121}},r=i=>{const s=`logged${e?"In":"Out"}`;return t>=n[i][s]};let a={};return["navigation","search"].forEach(i=>{a[i]=r(i)}),a},shouldChangeHeaderIsVisible:(e,t,n)=>{Object.values(t).filter(a=>a===!0).length||n([{type:"headerIsVisible",value:e}])},handleMenus:({id:e,value:t,menus:n,dispatch:r,forceHandle:a=!1})=>{if(!a&&n[e]===t||!a&&e===gt.ACCOUNT&&t===!1&&n[gt.SITE]===!0)return;const i=Date.now();if(!a&&!t&&$e.handlerCalled[e]&&i-$e.handlerCalled[e]<500)return;$e.handlerCalled[e]=i;let s=[{type:`menus.${e}`,value:t}];if(t===!0)Object.keys(n).forEach(o=>{o===e||n[o]===!1||s.push({type:`menus.${o}`,value:!1})});else{let o=null;switch(e){case gt.SITE:o=document.querySelector("#header .menu-button"),o||(o=document.querySelector("#navigation .navigation-button"));break;case gt.SEARCH:o=document.querySelector("#header .toggle-search-button");break;case gt.ACCOUNT:o=document.querySelector("#header .account-button");break;default:return}o&&o.focus()}r(s)},findFirstChild:(e,t,n=!1)=>{if(!e||!e[0])return!1;for(let r=0;r<=e.length;r++){if(!e[r])continue;if(e[r][t]&&(!n||e[r][t].includes(n)))return e[r];if(!t.includes("."))continue;const a=wc(e[r],t);if(!(typeof a>"u")&&(!n||a[t]&&a[t].includes(n)||a.value&&a.value.includes(n)||a.toString().includes(n)))return e[r]}return e[0].children?$e.findFirstChild(e[0].children,t,n):!1},autoFocus:({menu:e,navigationRef:t,isDesktopVersion:n,focusElements:r,dispatch:a})=>{var l;if(!t.current||!t.current.children)return;const i=n?"desktop":"default";if(r[e][i]){(l=document.querySelector(`#header ul a[href="${r[e][i]}"]:last-child`))==null||l.focus();return}let s,o;switch(e){case gt.SITE:if(n){const u=$e.findFirstChild(t.current.children,"attributes.aria-controls",gt.SITE);s=$e.findFirstChild(u.children,"href")}else s=$e.findFirstChild(t.current.children,"href");break;case gt.ACCOUNT:if(o=$e.findFirstChild(t.current.children,"className","account"),!o||!o.children)return;s=$e.findFirstChild(o.children,"href");break;default:return}s&&(a([{type:`focusElements.${e}.${i}`,value:s.attributes.href.value}]),s.focus())},events:{onClick:(e,{id:t,callback:n,isOpen:r})=>{e.target&&e.target.attributes&&e.target.attributes.href||(e.preventDefault(),e.stopPropagation(),clearTimeout($e.timeouts[t]),n(t,!r))},onFocus:({id:e})=>{clearTimeout($e.timeouts[e])},onMouseEnter:({id:e,callback:t})=>{clearTimeout($e.timeouts[e]),t(e,!0)},onBlur:({id:e,callback:t})=>{$e.timeouts[e]=setTimeout(()=>{t(e,!1)},250)}}},Mr={order:["home","topics","partners","account"],home:{href:"/home/",hasVariantText:!0,gtmType:"homepage-click"},topics:{order:["explore","topics"],menuId:"site-navigation",explore:{order:["events","courses","articles","communities"],events:{href:"/events/",className:"icon events"},courses:{href:"/microcourses/",gtmType:"microcourses-click",className:"icon courses"},articles:{href:"/solution-articles/",gtmType:"articles-click",className:"icon articles"},communities:{href:"/communities/",gtmType:"communities-click",className:"icon communities"}},topics:{order:["climate","cities-and-local-government","digital-and-data","education","equity-justice-and-inclusion","health-and-social-care","innovation","leadership-and-skills","life-in-government","policymaking","transport-and-infrastructure","work-and-the-economy"],className:"columns",climate:{href:"/topics/climate/"},"cities-and-local-government":{href:"/topics/cities-and-local-government/"},"digital-and-data":{href:"/topics/digital-and-data/"},education:{href:"/topics/education/"},"equity-justice-and-inclusion":{href:"/topics/equity-justice-and-inclusion/"},"health-and-social-care":{href:"/topics/health-and-social-care/"},innovation:{href:"/topics/innovation/"},"leadership-and-skills":{href:"/topics/leadership-and-skills/"},"life-in-government":{href:"/topics/life-in-government/"},policymaking:{href:"/topics/policymaking/"},"transport-and-infrastructure":{href:"/topics/transport-and-infrastructure/"},"work-and-the-economy":{href:"/topics/work-and-the-economy/"}}},partners:{href:"/partnerships/",onlyShow:"logged-out"},account:{menuId:"account-navigation",order:["profile","settings","log-out"],className:"account",onlyShow:"logged-in",doTrack:!1,profile:{href:"/profiles/me"},settings:{href:"/profiles/me/manage-account"},"log-out":{href:"/user-onboarding/logout",className:"divider"}},buttons:{order:["login","signup"],login:{href:"/user-onboarding/login"},signup:{href:"/signup?ref=header-banner",props:{variant:"primary"}}}},ja=({id:e,isLoggedIn:t=!1,isDesktopVersion:n=!1,menus:r={},callback:a=()=>{},doTrack:i=null})=>{const s=ue.useIntl(),o=wc(Mr,e);if(!o||o.onlyShow&&(o.onlyShow==="logged-in"&&!t||o.onlyShow==="logged-out"&&t))return null;const l="doTrack"in o,u=i===null?l?o.doTrack:!0:i,c=e.includes("buttons.");let h=`header_${e.replaceAll(".","_")}`;o.hasVariantText&&(h+=`_logged${t?"In":"Out"}`);let p=!1;if(o.href){let B=o.gtmType||`${e}-click`;if(B.includes(".")){const x=B.split("."),k=x[x.length-2];B=`${k==="topics"?`${k}-`:""}${x[x.length-1]}`}p={href:o.href},u&&(p={...p,className:"gtm-trackable","data-gtm-event-type":B,"data-gtm-event-context":"HeaderButtons"}),c&&(p={...p,variant:"secondary",size:{mobile:"small",881:"large"},...o.props||{}})}const m=o.order&&o.order[0]&&o[o.order[0]],g=m&&o[o.order[0]].order,f=p&&window.location.pathname===o.href;let D={},v={},E={};if(f&&(D={...D,"aria-current":"page"}),m){const B=o.menuId||e,x={onClick:k=>$e.events.onClick(k,{id:B,callback:a,isOpen:r[B]}),onFocus:()=>$e.events.onFocus({id:B}),onBlur:()=>$e.events.onBlur({id:B,callback:a}),onMouseLeave:()=>$e.events.onBlur({id:B,callback:a}),onMouseEnter:()=>$e.events.onMouseEnter({id:B,callback:a})};v={...x,id:B===gt.SITE?gt.SITE:gt.ACCOUNT},n&&(g&&(E={...x,className:"navigation-button",onKeyPress:k=>{k.key==="Enter"&&$e.events.onClick(k,{id:B,callback:a,isOpen:r[B]})},"aria-haspopup":!0,"aria-expanded":r[B],"aria-controls":B}),v={...v,hidden:B in r?!r[B]:!0}),g||(v={...v})}return d.jsxs("li",{className:Y({[o.className]:o.className,"has-submenu":m,parent:g,active:f}),...D,children:[p?y.createElement(c?_e:"a",p,s.formatMessage({id:h})):n&&o.order&&g?d.jsxs("button",{...E,children:[s.formatMessage({id:h}),d.jsx(Ie,{children:s.formatMessage({id:`header_menu_${r[gt.SITE]?"hide":"show"}`})})]}):s.formatMessage({id:h}),o.order&&d.jsx("ul",{...v,children:o.order.map(B=>{if(!o[B])return null;const x={isLoggedIn:t,isDesktopVersion:n,menus:r,callback:a,doTrack:l?u:null};return o[B].order?d.jsxs("li",{className:Y({[o[B].className]:o[B].className}),children:[s.formatMessage({id:`${h}_${B}`}),d.jsx("ul",{children:o[B].order.map(k=>d.jsx(ja,{id:`${e}.${B}.${k}`,...x},k))})]},B):d.jsx(ja,{id:`${e}.${B}`,...x},B)})})]},e)};const kx={height:67,height_desktop:83};var gt=(e=>(e.NAVIGATION="navigation",e.SEARCH="search",e.ACCOUNT="account-navigation",e.SITE="site-navigation",e))(gt||{});const ko=({showNavigation:e=!0})=>{const t=ue.useIntl(),n=y.useContext(Lt),r=tr(!0,!0),a=n&&typeof n.id=="string",i=y.useMemo(()=>$e.getIsDesktopVersion(a,r),[a,r]),[s,o]=y.useReducer(Ir,{headerIsVisible:!0,menus:{"site-navigation":!1,search:!1,"account-navigation":!1},focusElements:{"site-navigation":{desktop:!1,default:!1},"account-navigation":{desktop:!1,default:!1}}}),{headerIsVisible:l,menus:u,focusElements:c}=s,h=y.useRef(s);y.useEffect(()=>{h.current=s},[s]),Ac({scrollPosition:kx[`height${i.navigation?"_desktop":""}`],callbacks:{scrollUp:()=>{const v=h.current.menus;!i&&v["site-navigation"]||$e.shouldChangeHeaderIsVisible(!0,v,o)},scrollDown:()=>{const v=h.current.menus;!i&&v["site-navigation"]||$e.shouldChangeHeaderIsVisible(!1,v,o)}}});const p=(v,E,B=!1)=>{$e.handleMenus({id:v,value:E,menus:h.current.menus,dispatch:o,forceHandle:B})},m=y.useRef(null),g=v=>{v.key==="Escape"&&["site-navigation","search","account-navigation"].forEach(E=>{h.current.menus[E]&&p(E,!1,!0)})};y.useEffect(()=>{var v;return(v=document.getElementById("header"))==null||v.addEventListener("keydown",g),()=>{var E;(E=document.getElementById("header"))==null||E.removeEventListener("keydown",g)}},[]),Yn(()=>{u["site-navigation"]&&$e.autoFocus({menu:"site-navigation",navigationRef:m,isDesktopVersion:i.navigation,focusElements:c,dispatch:o})},[u["site-navigation"]]),Yn(()=>{u["account-navigation"]&&$e.autoFocus({menu:"account-navigation",navigationRef:m,isDesktopVersion:i.navigation,focusElements:c,dispatch:o})},[u["account-navigation"]]);const f=d.jsxs(d.Fragment,{children:[!i.search&&d.jsx("button",{className:"search toggle-search-button",onClick:v=>{v.preventDefault(),v.stopPropagation(),p("search",!u.search)},"aria-haspopup":"true","aria-expanded":u.search,"aria-controls":"search-form",children:d.jsx(Ie,{children:t.formatMessage({id:`header_search_${u.search?"hide":"show"}`})})}),d.jsx(Lf,{id:"global-search",handleToggle:{searchIsOpen:u.search,isDesktopVersion:i.search},gtmContext:"search-bar-header",gtmEvent:"form-submission"})]}),D=d.jsxs(d.Fragment,{children:[!i.navigation&&d.jsx("button",{className:"menu-button gtm-trackable",onClick:v=>{v.preventDefault(),v.stopPropagation(),p("site-navigation",!u["site-navigation"])},"data-gtm-event-type":"open-tab-menu-click","data-gtm-event-context":"HeaderLeft-Chevron","aria-haspopup":"true","aria-expanded":u["site-navigation"],"aria-controls":"site-navigation",children:d.jsx(Ie,{children:t.formatMessage({id:`header_menu_${u["site-navigation"]?"hide":"show"}`})})}),d.jsx("ul",{ref:m,id:"navigation",hidden:i.navigation||u["account-navigation"]?!1:!u["site-navigation"],"data-showing":!i.navigation&&u["account-navigation"]?"account":"default",children:Mr.order.map(v=>d.jsx(ja,{id:v,isLoggedIn:a,isDesktopVersion:i.navigation,menus:{"site-navigation":u["site-navigation"],"account-navigation":u["account-navigation"]},callback:p},v))})]});return n&&n.isLoading?null:d.jsxs(d.Fragment,{children:[d.jsxs("nav",{id:"header",className:Y({"logged-in":a,"logged-out":!a,visible:l}),children:[d.jsx(Ie,{element:"a",href:"#content-of-page",children:t.formatMessage({id:"header_skip"})}),d.jsx(Ys,{variant:"monochrome"}),e&&d.jsxs(d.Fragment,{children:[i.navigation?d.jsxs(d.Fragment,{children:[D,f]}):d.jsxs(d.Fragment,{children:[f,D]}),a?d.jsxs("button",{className:"account-button",onClick:v=>$e.events.onClick(v,{id:"account-navigation",callback:p,isOpen:u["account-navigation"]}),onMouseEnter:()=>$e.events.onMouseEnter({id:"account-navigation",callback:p}),onMouseLeave:()=>$e.events.onBlur({id:"account-navigation",callback:p}),"aria-haspopup":"true","aria-expanded":u["account-navigation"],"aria-controls":"account-navigation",children:[d.jsx(Ie,{children:t.formatMessage({id:`header_account_${u["account-navigation"]?"hide":"show"}`})}),d.jsx(Yt,{name:n&&n.name||"",src:n&&n.image&&n.image.thumbnail||""})]}):d.jsx("ul",{className:"sign-in-buttons",children:Mr.buttons.order.map(v=>d.jsx(ja,{id:`buttons.${v}`},v))})]})]}),d.jsx("hr",{id:"content-of-page"}),d.jsx("div",{className:Y("overlay",{open:u["site-navigation"]||u["account-navigation"]||!i.search&&u.search})})]})};const _x=()=>{const e=ue.useIntl();return d.jsxs(d.Fragment,{children:[d.jsx(ko,{}),d.jsx("div",{id:"content",children:d.jsx(un,{variant:"error",text:e.formatMessage({id:"pageLayout_error"})})}),d.jsx(Eo,{})]})},Wf=({children:e,additionalContent:{prepended:t,appended:n}={},reportError:r,forceShow:a={},styling:i={},className:s="",locale:o="en"})=>{const{navigation:l=!0,footer:u=!0}=a,{background:c="default",variant:h="default",circle:p="default",modal:m="default"}=i,g=_c(),[f,D]=y.useState(""),v=T=>{const{detail:{message:S}}=T;D(S)};y.useEffect(()=>(window.scrollTo(0,0),document.addEventListener("ariaLive",v),()=>{document.removeEventListener("ariaLive",v)}),[g]);const E=fa(e,{locale:o}),B=fa(t,{locale:o}),x=fa(n,{locale:o}),k={};return c!=="default"&&(k[c]=!0),h!=="default"&&(k[h]=!0),p!=="default"&&(k[p]=!0),d.jsx(Th.ErrorBoundary,{onError:r,fallback:d.jsx(_x,{}),children:d.jsxs(y.Suspense,{fallback:null,children:[d.jsxs("div",{id:"wrapper",className:Y(s,k,{"has-footer":u}),children:[d.jsx(ko,{showNavigation:l}),d.jsxs("main",{id:"content-wrapper",children:[B&&d.jsx("div",{className:Y("additional-content prepended",{"large-modal":m==="large"}),children:B}),y.createElement(c==="bold"?jo:"div",{id:"content",children:E,className:Y({"large-modal":m==="large"})})]}),x&&d.jsx("div",{className:"additional-content appended",children:x}),u&&d.jsx(Eo,{}),d.jsx(qf,{})]}),f&&d.jsx(Ie,{"aria-live":"polite",showOnFocus:!1,"data-testid":"layout-aria-live",children:f})]})})},Ql={default:"tags_",headerTopics:"header_topics_topics_"},Ui={topic:{Climate:"climate",CitiesAndLocalGovernment:"cities-and-local-government",DigitalAndData:"digital-and-data",Education:"education",EquityJusticeAndInclusion:"equity-justice-and-inclusion",HealthAndSocialCare:"health-and-social-care",Innovation:"innovation",LeadershipAndSkills:"leadership-and-skills",LifeInGovernment:"life-in-government",Policymaking:"policymaking",TransportAndInfrastructure:"transport-and-infrastructure",WorkAndTheEconomy:"work-and-the-economy"},"from the community":"community"},Bx={getTagDetails:e=>{if(e.includes("topic_")){if(e=Ui.topic[e.replace("topic_","")],e){const t=Mr.topics.topics[e].href;return t?{id:e,href:t,text:`${Ql.headerTopics}${e}`}:null}return null}return Ui[e]?(e=Ui[e],{id:e,text:`${Ql.default}${e}`}):null}};const Fx=({tags:e=[],color:t="default",forceOneLine:n=!1,canHaveLinks:r=!0,className:a="",gtmType:i="tag-click",gtmContext:s="tags"})=>{const o=ue.useIntl();if(!e||e.length<1)return null;const l=[];return e.forEach(u=>{if(!u)return;const c=Bx.getTagDetails(u);c&&l.push(c)}),l.length<1?null:d.jsx("ul",{className:Y("tags text-small",t,a,{"one-line":n}),children:l.map(u=>{const c=o.formatMessage({id:u.text});return d.jsx("li",{children:u.href&&r?d.jsx("a",{href:u.href,className:"gtm-trackable","data-gtm-event-type":i,"data-gtm-event-context":s,children:c}):c},u.id)})})};const Ax=({members:{data:e=[],total:t=e.length},hasNextPage:n=!1,loadNextPage:r=()=>{},gtmContext:a="member",gtmType:i="member-click",className:s=""})=>{const o=ue.useIntl();return e.length===0?null:d.jsxs("div",{className:Y("members-list",s),children:[d.jsxs("h1",{children:[o.formatMessage({id:"membersList"}),d.jsx("span",{className:"count",children:t})]}),d.jsx("ul",{children:e.map((l,u)=>d.jsxs("li",{children:[d.jsx(wn,{member:l,gtmContext:a,gtmType:i}),l.isAdmin&&d.jsx(gn,{children:o.formatMessage({id:"membersList_admin"})})]},u))}),n&&d.jsx($r,{hasNextPage:n,loadNextPage:r,icon:{icon:"arrow-down",position:"right"},gtmContext:a})]})},Tx={showForm:!1},ri=y.createContext(Tx),Hf=({children:e})=>{const[t,n]=y.useState({showForm:!1});return d.jsx(ri.Provider,{value:{...t,updateConversation:n},children:e})},Jl=e=>{const t={};return Object.keys(e).forEach(n=>n.includes("Id")?t[n]=e[n]:t[`${n}Slug`]=e[n]),t},Sx=({intlPath:e,showGuidelines:t,type:n,gtmContext:r})=>{const a=ue.useIntl();return t?d.jsx("small",{children:Bt(a.formatMessage,`${e}explainer`,n,"action",{a:i=>d.jsx("a",{href:"https://about.apolitical.co/q-and-a-community-guidelines",target:"_blank",className:"gtm-trackable","data-gtm-event-context":r,"data-gtm-event-type":"community-guidelines-link",rel:"noreferrer",children:i})})}):d.jsx(d.Fragment,{})},jx=({formID:e,intlPath:t,showLabel:n,type:r})=>{const a=ue.useIntl();return n?d.jsx("label",{htmlFor:`${e}-input`,className:"text-small",onClick:i=>{i.preventDefault(),i.stopPropagation();const s=new CustomEvent("focusEditor",{detail:{id:`rte-${e}-input`}});window.dispatchEvent(s)},children:a.formatMessage({id:`${t}label`})}):d.jsx(Ie,{element:"label",showOnFocus:!1,htmlFor:`${e}-input`,children:Bt(a.formatMessage,`${t}label_action`,r,"action")})};let ia=null;const Je="discussion_form_",zr=({id:e,content:t={type:"response",slugs:{}},userHasPermissions:n=!0,meta:r,placeholder:a,maxLength:i=0,buttons:s,forceShow:o={cancel:!1,error:!1},isCommunity:l=!1,functions:u,data:c={},gtmContext:h="DiscussionForm"})=>{var Fe,Ae,He;const p=ue.useIntl(),m=y.useContext(Lt),[g,f]=y.useState(""),{isLoading:D=!1,isInWrapper:v=!1,isInOverlay:E=!1,isAutoFocused:B=!1,isEditing:x=!1,hasTitleField:k=!1,isPrepopulated:T=!1,showTitle:S=!1,showGuidelines:q=!0,showDivider:N=!1,showSuccessMessage:I=!0}=r||{},{onChange:z=()=>{},create:w=()=>{},handleSaveEdit:F=()=>{},handleCancel:j=()=>{},callback:M=()=>{},onMention:V=()=>{},listMembers:G=()=>Promise.resolve([]),clickMentionFallback:J=()=>{},props:ae={create:{projectNames:["questions-answers"]}}}=u,[C,R]=y.useState({title:k&&k.text||"",body:x&&x.text||T&&T.text||""}),[W,_]=y.useState(o.error||!1),[A,L]=y.useState(!1);if(y.useEffect(()=>{l&&!x&&T&&T!==C.body&&R({...C,body:T.text||""})},[T]),D)return d.jsx(kt,{className:"discussion-card discussion-form","data-testid":"loading-placeholder"});const $=Se=>{R({...C,body:Se}),z({body:Se});let Te;!m||!m.id?Te=Bt(p.formatMessage,`${Je}error_loggedOut`,t.type,"action"):n?i>0&&Se.length>=i&&(Te=`${Je}error_tooLong`):Te=Bt(p.formatMessage,`${Je}error_noPermission`,t.type,"action"),Te?_(Te):W&&_(!1)};let U=`${t.type}-form`;if(t.type==="response"||t.type==="reply"){const Se=((Fe=t.slugs)==null?void 0:Fe.reply)||((Ae=t.slugs)==null?void 0:Ae.answer)||((He=t.slugs)==null?void 0:He.question)||"";Se&&(U=`${U}-${Se.slice(-15)}`)}e&&(U=`${e}-${U}`);const re=async()=>{if(!m||!m.id||!n||Q)return;ia&&clearTimeout(ia),L("submitting");const Se=window.location.pathname;try{let Te;switch(t.type){case"post":Te=await w({title:C.title,content:C.body});break;case"question":Te=await w({title:C.body,authorId:m&&m.id,...ae==null?void 0:ae.create});break;case"response":Te=await w({questionSlug:t.slugs.question},{body:C.body,authorId:m&&m.id,contentPath:Se});break;case"reply":Te=await w({questionSlug:t.slugs.question,answerSlug:t.slugs.answer},{body:C.body,authorId:m&&m.id,contentPath:Se});break;default:break}await zh(1e3),M&&await M(Te),ia=setTimeout(()=>{R({title:"",body:""}),L("submitted"),f(Bt(p.formatMessage,`${Je}success`,t.type,"action"));const Ne=new Event("discussionFormSubmitted");document.dispatchEvent(Ne),te()},500)}catch(Te){const Ne=Te;let ke=`${Je}error`;Ne!=null&&Ne.message.includes("entry already exists")&&(ke=Bt(p.formatMessage,`${Je}error_alreadyExists`,t.type,"action")),Ne!=null&&Ne.message.includes("429")?ke=Bt(p.formatMessage,`${Je}error_tooMany`,t.type,"action"):Ne!=null&&Ne.message.includes("400")&&(ke=`${Je}error`),_(ke),te()}},te=()=>{ia=setTimeout(()=>{_(!1),L(!1),f("")},5e3)},ne=!C.title||!Wo(C.title),le=!C.body||!Wo(C.body);let Q=le;k&&(Q=ne&&le);const pe=A==="submitting",he=[{component:jx,props:{formID:U,intlPath:Je,showLabel:k!==!1,type:t.type}},{component:Mf,props:{id:`${U}-input`,value:A==="submitting"&&!W?"":C.body,placeholder:a||Bt(p.formatMessage,`${Je}placeholder`,t.type,"action"),maxLength:i,meta:{isInOverlay:E},functions:{onChange:$,onMention:V,listMembers:G,clickMentionFallback:J},data:c,autoFocus:x!==!1||B&&!k,"aria-invalid":!!W,"aria-errormessage":"error-message"}},{component:Sx,props:{intlPath:Je,showGuidelines:q,type:t.type,gtmContext:h}}];N&&he.push({component:Kt}),k&&he.unshift({id:"title",type:"text",value:k.text,limit:250,autoFocus:B,label:p.formatMessage({id:`${Je}titleField_label`}),placeholder:p.formatMessage({id:`${Je}titleField_placeholder`}),functions:{onChange:Se=>{R({...C,title:Se}),z({title:Se})}},validation:[{condition:()=>Q,error:p.formatMessage({id:`${Je}titleField_error`})}]});let ye=!m||!m.id||!n||Q||pe;return x&&(k?ye=ye||C.body===x.text&&C.title===k.text:ye=ye||C.body===x.text),d.jsxs(d.Fragment,{children:[d.jsxs(ln,{id:U,className:Y("discussion-card discussion-form",{"no-styling":v&&x}),meta:{shouldReset:!0,shouldHide:!1,showRequiredLabels:!1,shouldShowCancelButton:x&&!pe||o.cancel},functions:{onSuccess:async()=>{if(x){L("submitting"),F(C);return}await re()},onCancel:j},fields:he,intlPath:Je,button:{variant:"primary",size:{mobile:"small",600:"medium"},className:"gtm-trackable","data-gtm-event-context":h,"data-gtm-event-type":`${x?"save":"submit"}-${t.type}-click`,"data-testid":"save-button",disabled:ye,overwriteSubmittingText:!0,text:!pe&&!x&&(s!=null&&s.submit)?s==null?void 0:s.submit:p.formatMessage({id:`${Je}${pe?x?"saving":"posting":x?"save":"post"}`})},secondaryActionButton:{variant:"secondary",size:{mobile:"small",600:"medium"},className:"gtm-trackable","data-gtm-event-context":h,"data-gtm-event-type":`cancel-${t.type}-click`,disabled:!o.cancel&&(!m||!m.id||!C.body),text:s!=null&&s.cancel?s==null?void 0:s.cancel:p.formatMessage({id:`${Je}cancel`})},gtm:{context:h,event:`${t.type}-form`},"data-testid":`discussion-${t.type}-form`,children:[S&&!x&&["question"].includes(t.type)&&d.jsx("h2",{children:Bt(p.formatMessage,`${Je}title`,t.type,"action")}),d.jsx(wn,{member:m?{...m,link:!1}:"community",gtmContext:h,gtmType:"profile-click"})]}),A==="submitted"&&I&&d.jsx(Fr,{className:"success","data-testid":"success",children:Bt(p.formatMessage,`${Je}success`,t.type,"action")}),W&&d.jsx(Fr,{id:"error-message",className:"error","data-testid":"error",children:o.error?o.error:typeof W=="string"?W.includes(" ")?W:p.formatMessage({id:W},{action:p.formatMessage({id:`discussion_action_${t.type}`}),maxLength:i}):W}),g&&d.jsx(Ie,{"aria-live":"polite",showOnFocus:!1,children:g})]})},Ox=Object.freeze(Object.defineProperty({__proto__:null,default:zr},Symbol.toStringTag,{value:"Module"})),Px=({question:e,answer:t,reply:n})=>({...e&&{questionSlug:e},...t&&{answerSlug:t},...n&&{replySlug:n}}),Nx=(e,t=10)=>!e||e.length===0?[]:e.slice(0,t);const Oa=({icon:e,className:t="",...n})=>d.jsx(_e,{className:Y("discussion-button",t),variant:"tertiary",icon:e,...n});let kr=!1;const Vi=()=>{kr!==!1&&(clearTimeout(kr),kr=!1)},Ki=5;let Zi=null;const Uf=({element:e="div",likes:t=0,peopleWhoLiked:n=!1,isShort:r=!0,userLiked:a=!1,content:i={type:"reply",slugs:{}},canLike:s=!0,functions:{createLike:o=()=>{},deleteLike:l=()=>{}}={}})=>{const u=ue.useIntl(),c={numberOfLikes:t,userLikedContent:a,ignoreInteractions:!1,showLikers:!1,tabbableLink:0},[h,p]=y.useReducer(Ir,c),{numberOfLikes:m,userLikedContent:g,ignoreInteractions:f,showLikers:D,tabbableLink:v}=h;y.useEffect(()=>{p([{type:"userLikedContent",value:a}])},[a]);const E=y.useMemo(()=>Nx(n,Ki),[n]),B=S=>{if(S.preventDefault(),S.stopPropagation(),p([{type:"showLikers",value:!1}]),kr)return Vi(),!1;if(Vi(),f||!s)return!1;kr=setTimeout(x,350)},x=async()=>{if(Vi(),f||!s)return!1;let S=g?m-1:m+1;S<0&&(S=0),p([{type:"ignoreInteractions",value:!0},{type:"numberOfLikes",value:S},{type:"userLikedContent",value:!g}]);try{if(i&&i.slugs){const q=Px(i.slugs);g?await l(q):await o({...q,payload:{contentPath:window.location.pathname}})}}catch{p([{type:"numberOfLikes",value:t},{type:"userLikedContent",value:a}])}finally{p([{type:"ignoreInteractions",value:!1}])}},k=()=>{Zi=setTimeout(()=>{p([{type:"showLikers",value:!1}])},500)},T=()=>{Zi&&clearTimeout(Zi)};return y.createElement(e,{className:"likes-wrapper",onKeyDown:S=>{S.key==="Escape"&&p([{type:"showLikers",value:!1}])},onMouseEnter:()=>{T(),p([{type:"showLikers",value:!0}])},onMouseLeave:()=>{k()}},d.jsxs(d.Fragment,{children:[d.jsx(Oa,{className:Y("discussion-button text-medium action-button",{"show-spinner":f,"is-liked":g,disabled:!s}),icon:{icon:g?"heart":"heart_empty",animate:"bounce"},disabled:!s,"data-testid":"like-button","data-gtm-event-context":"Likes","data-gtm-event-type":`like-${i.type}-click`,onClick:B,screenreaderText:s?u.formatMessage({id:`discussion_likes_${g?"unlike":"like"}`},{action:u.formatMessage({id:`discussion_action_${i.type}`})}):!1,"aria-pressed":g,children:d.jsx("span",{"data-testid":"number-of-likes",className:"number-of-likes",children:u.formatMessage({id:`discussion_likes${r?"_short":""}`},{number:m})})}),n&&d.jsxs(d.Fragment,{children:[d.jsx(Ie,{"data-testid":"like-a11y-button",element:"button",className:"tertiary small icon navigation_arrow",onFocus:()=>{T()},onBlur:()=>k,onClick:S=>{var N;S.preventDefault(),S.stopPropagation(),T(),p([{type:"showLikers",value:!0}]);const q=(N=S.currentTarget.nextSibling)==null?void 0:N.childNodes[0];if(q){const I=q.querySelector("li:first-child a");I&&(p([{type:"tabbableLink",value:0}]),setTimeout(()=>{I.focus()},100))}},onKeyDown:S=>{S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),k())},"aria-expanded":D,"aria-controls":`likes-tooltip-${i.slug}`,children:d.jsx(Ie,{showOnFocus:!1,children:u.formatMessage({id:"discussion_likes_show"},{action:i.type})})}),d.jsx(An,{id:`likes-tooltip-${i.slug}`,isOpen:D,isLoading:n.length===0,children:n.length&&d.jsxs("ul",{children:[E.map((S,q)=>{if(typeof S=="string"||!S.name)return null;const N={};return v!==q&&(N.tabIndex=-1),d.jsx("li",{"data-index":q,children:d.jsx(Tn,{href:S.id?`/profiles/${S.id}`:void 0,gtmContext:"Likes",gtmType:"liked-name-click",onClick:I=>I==null?void 0:I.stopPropagation(),onFocus:()=>T(),onKeyDown:I=>{var M,V,G,J;if(!I||!["ArrowUp","ArrowDown"].includes(I.key||""))return;I.stopPropagation(),I.preventDefault();const z=I.key==="ArrowUp"?"up":"down",w=(M=I.currentTarget)==null?void 0:M.parentElement;let F=w==null?void 0:w.nextElementSibling;if(z==="up"){const ae=w==null?void 0:w.previousElementSibling;ae?F=ae:(F=(V=w==null?void 0:w.parentElement)==null?void 0:V.lastElementChild,(F==null?void 0:F.getAttribute("data-index"))==="-1"&&(F=F==null?void 0:F.previousElementSibling))}else(!F||(F==null?void 0:F.getAttribute("data-index"))==="-1")&&(F=(G=w==null?void 0:w.parentElement)==null?void 0:G.firstElementChild);if(!F)return;const j=(F==null?void 0:F.getAttribute("data-index"))||"0";p([{type:"tabbableLink",value:j}]),(J=F==null?void 0:F.querySelector("a"))==null||J.focus()},...N,children:S.name})},S.id||window.btoa(S.name))}),t>Ki&&d.jsx("li",{"data-index":"-1",children:u.formatMessage({id:"discussion_likes_more"},{number:t-Ki})})]})})]})]}))},Yi=({children:e,class:t,...n})=>{const r={...n,class:Y("subtle",t)};return d.jsx("blockquote",{...r,children:e})},Rx=280,_o=async(e,t,n,r=()=>Promise.resolve([]))=>{let a=t?Zn(e,typeof t=="number"?t:Rx):e;a=a.trim();const i=`<br>
|
|
139
139
|
|
|
140
|
-
`;return a.slice(0,i.length)===i&&(a=a.slice(i.length)),n?await Lc({text:a,template:"[@{{name}}](/profiles/{{id}})",mentions:n,listMembers:r}):a};const Mx=3e3,Ix=({url:e,gtm:t={context:"ShareLink",event:"copy-link-click"}})=>{const n=ue.useIntl(),[r,a]=y.useState({isOpen:!1,isCopied:!1});return d.jsxs("li",{children:[d.jsx(An,{className:Y("tooltip-share-link",{"tooltip-share-link-copied":r.isCopied}),isOpen:r.isOpen,styling:{hasPointer:"bottom",extraPadding:!1},children:r.isCopied?n.formatMessage({id:"discussion_share_copy_link_success"}):n.formatMessage({id:"discussion_share_copy_link"})}),d.jsx(Oa,{className:"gtm-trackable",icon:{icon:"link_chain"},onMouseOver:()=>a({...r,isOpen:!0}),onFocus:()=>a({...r,isOpen:!0}),onMouseOut:()=>a({isOpen:!1,isCopied:!1}),onBlur:()=>a({isOpen:!1,isCopied:!1}),onClick:()=>{navigator.clipboard.writeText(e).then(()=>{a({isOpen:!0,isCopied:!0}),setTimeout(()=>{a({isOpen:!1,isCopied:!1})},Mx)})},"data-gtm-event-context":t.context,"data-gtm-event-type":t.event})]})},Ht="discussion_",$x=195,qr=({element:e="div",content:t,userHasPermissions:n=!0,isLoading:r=!1,originalAuthorId:a,forceHide:i={actionBar:!1,comments:!1,likes:!1},functions:s,links:o={},className:l,gtmContext:u="DiscussionAnswer",children:c,isTruncated:h=!1,styling:{showShareLinkButton:p=!1}={},setFocus:m=!1,isCommunity:g=!1})=>{var Fe,Ae,He,Se,Te,Ne,ke,Ue;const f=ue.useIntl(),D=y.useContext(Lt),v=y.useContext(ri),{createContent:E=async()=>{},deleteContent:B=async()=>{},updateContent:x=async()=>{}}=s.content||{},{createLike:k=()=>{},deleteLike:T=()=>{}}=s.likes||{},{openComments:S=()=>{}}=s.comments||{},{listMembers:q=()=>Promise.resolve([]),clickMentionFallback:N=()=>{}}=s.mentions||{},{author:I,canLike:z,createdAt:w,id:F,likes:j=0,userLiked:M,comments:V=0,mentions:G}=t,J=D&&D.id&&typeof I!="string"&&I.id&&I.id===D.id||!1,ae=typeof z=="boolean"?z:!0,C=J&&(!t.createdAt||$h(t.createdAt,10,"seconds")),R=y.useRef(null),[W,_]=y.useState({title:t&&t.body!==t.title&&t.title||"",body:t&&t.body||"",isEditing:!1,didEdit:t&&t.isEdited||!1,postBody:""}),[A,L]=y.useState(!1),[$,U]=y.useState(C?"highlighted":"default"),[re,te]=y.useState("");y.useEffect(()=>{const ge=R.current;if(!(!ge||$==="default"))return document.addEventListener("discussionFormSubmitted",ne),ge.addEventListener("transitionend",le),()=>{document.removeEventListener("discussionFormSubmitted",ne),ge.removeEventListener("transitionend",le)}},[]),y.useEffect(()=>{_({...W,title:t&&t.title||"",body:t&&t.body||"",didEdit:t&&t.isEdited||!1})},[t.isEdited]),y.useEffect(()=>{(async()=>{const H=await _o(W.body,h,G,q);_({...W,postBody:H})})()},[W.body,G]);const ne=()=>{setTimeout(()=>{U("fading")},1e3)},le=({propertyName:ge})=>{ge==="background-color"&&U(H=>(H==="default"&&(document.removeEventListener("discussionFormSubmitted",ne),R.current&&R.current.removeEventListener("transitionend",le)),H==="fading"?"default":H))};if(r||!t||t.type==="answer"&&(!t.slugs||!t.slugs.question)||W.postBody===""&&t.title==="")return d.jsx(kt,{className:"discussion-card"});const Q=async({title:ge,body:H})=>{ge||(ge=""),H||(H=""),te("");try{if(!is(ge,W.title)||!is(H,W.body)){const ie=t.type==="question"?{title:H}:{title:ge,body:H};await x(Jl(t.slugs),ie)}_({...W,title:ge,body:H,isEditing:!1,didEdit:!0})}catch{te(`${Ht}form_error`)}},pe=()=>{if(v&&v.updateConversation){const ge={showForm:!0},H=t.author;H&&H.id&&(g&&(ge.prepopulateForm=`@{{${H.id}}}`),ge.mentionData={id:H.id,name:H.name}),v.updateConversation(ge)}setTimeout(()=>{var ve,we,Ke;const H=`reply-form-${(t.type==="answer"?t.slug:((ve=t.slugs)==null?void 0:ve.reply)||((we=t.slugs)==null?void 0:we.answer)||((Ke=t.slugs)==null?void 0:Ke.question)||"").toLowerCase().slice(-15)}`,ie=document.getElementById(H),me=document.getElementById(`${H}-input`);me&&me.focus(),ie&&ie.scrollIntoView({behavior:"smooth"})},0)},he=async()=>{L(!1);try{await B(Jl(t.slugs))}catch{te("delete-error")}},ye=[{text:f.formatMessage({id:`${Ht}moreMenu_report`}),onClick:ge=>{ge.stopPropagation()},href:`mailto:community@apolitical.co?subject=${encodeURI(f.formatMessage({id:`${Ht}report_subject`}))}&body=${encodeURI(f.formatMessage({id:`${Ht}report_body`},{contentType:t.type||"",contentSlug:t.slug||"",contentUrl:`${window.origin}${typeof process<"u"&&process.env.PUBLIC_URL||""}/${t.slugs.question||""}`}))}`,icon:"flag"}];return n&&J&&ye.push({text:f.formatMessage({id:`${Ht}moreMenu_edit`}),onClick:()=>_({...W,isEditing:!0}),icon:"pencil-paper",className:"gtm-trackable","data-gtm-event-context":u,"data-gtm-event-type":`edit-${t.type}-click`},{text:f.formatMessage({id:`${Ht}moreMenu_delete`}),onClick:ge=>{ge.preventDefault(),ge.stopPropagation(),L(!0)},icon:"trash",className:"gtm-trackable","data-gtm-event-context":u,"data-gtm-event-type":`delete-${t.type}-click`,...mh(`delete-${t.slug}-modal`,A)}),m&&((Fe=R==null?void 0:R.current)==null||Fe.focus(),(Ae=R==null?void 0:R.current)==null||Ae.scrollIntoView({behavior:"smooth"})),y.createElement(e,{className:Y("discussion-post",l,{[$]:!l||!l.includes("highlighted-text-box"),"has-link":o.post&&!W.isEditing}),ref:R,tabIndex:m?0:null,"data-testid":`discussion-${t.type}-thread`,"data-gtm-event-context":`${u}-post-click`,onClick:ge=>{!o.post||W.isEditing||(ge.preventDefault(),ge.stopPropagation(),window.location.href=o.post)},children:d.jsxs(d.Fragment,{children:[d.jsxs("div",{id:F||t.slug,className:Y("discussion-card",t.type,{editing:W.isEditing,"has-link":o.post&&!W.isEditing}),children:[!W.isEditing&&d.jsx(wn,{member:I,additionalContent:{createdAt:w,didEdit:W.didEdit},className:typeof I!="string"&&I.id===a?"highlighted":"",gtmContext:u,gtmType:"profile-click"}),W.isEditing?d.jsx(zr,{id:`editing-${t.slug}`,content:{type:t.type,slugs:t.slugs},userHasPermissions:n,meta:{isLoading:r,isInWrapper:!0,hasTitleField:W.title!==""?{text:W.title}:!1,isEditing:{text:W.body},isPrepopulated:!1},isCommunity:g,maxLength:t.type==="question"?250:5e4,forceShow:{error:re!==""&&re!=="delete-error"?f.formatMessage({id:re},{action:f.formatMessage({id:`discussion_action_${t.type}`})}):!1},functions:{create:E,handleSaveEdit:Q,handleCancel:()=>{te(""),_({...W,isEditing:!1})},listMembers:q,clickMentionFallback:N},gtmContext:`${u}Form`,data:{mentions:t.mentions}}):o.post?d.jsxs("a",{href:o.post,children:[(W==null?void 0:W.title)&&d.jsx("p",{className:"content-title",children:W==null?void 0:W.title}),W.postBody.length>$x?d.jsx(Vc,{text:W.postBody,markdownOptions:{overrides:{a:ds,blockquote:{component:Yi}}}}):d.jsx(xn,{options:{overrides:{a:ds,blockquote:{component:Yi}}},children:W.postBody})]}):d.jsxs(d.Fragment,{children:[(W==null?void 0:W.title)&&d.jsx("p",{className:"content-title",children:W==null?void 0:W.title}),d.jsx(xn,{options:{wrapper:t.type==="question"?"h1":y.Fragment,forceWrapper:t.type==="question",forceInline:t.type==="question",forceBlock:t.type!=="question",overrides:{blockquote:{component:Yi}}},children:W.postBody})]}),!W.isEditing&&!(i!=null&&i.actionBar)&&d.jsxs("ul",{className:Y("actions text-medium",t.type),"data-testid":`${t.type}-actions`,children:[!i.likes&&d.jsx(Uf,{element:"li",likes:j,isShort:!1,userLiked:M,content:{type:t.type,slugs:t.slugs,slug:t.slug},canLike:ae,peopleWhoLiked:t.peopleWhoLiked,functions:{createLike:k,deleteLike:T}}),!i.comments&&(["question","post"].includes(t.type)||o.comments)&&d.jsx("li",{children:d.jsx(Oa,{onClick:ge=>{ge.preventDefault(),ge.stopPropagation(),o.comments&&(window.location.href=o.comments),typeof S=="function"&&S()},icon:{icon:"speech-bubble_square"},"data-gtm-event-context":u,"data-gtm-event-type":`answer-${t.type}-click`,screenreaderText:f.formatMessage({id:`${Ht}comments_screenReader`},{count:V}),children:f.formatMessage({id:`${Ht}comments`},{count:V})})}),(t.type==="answer"||t.type==="reply")&&d.jsx("li",{children:d.jsx(Oa,{styling:{muted:!0},onClick:pe,icon:{icon:"speech-bubble_square"},children:f.formatMessage({id:`${Ht}reply`})})}),p&&d.jsx(Ix,{url:(He=t.slugs)!=null&&He.reply?`${window.location.origin}${(Se=t.slugs)==null?void 0:Se.question}/${(Te=t.slugs)==null?void 0:Te.answer}#${(Ne=t.slugs)==null?void 0:Ne.reply}`:`${window.location.origin}${(ke=t.slugs)==null?void 0:ke.question}/${(Ue=t.slugs)==null?void 0:Ue.answer}`,gtm:{context:u,event:`copy-link-${t.type}-click`}}),d.jsx(rd,{element:"li",id:`more-${t.slug}`,options:ye})]})]}),c,d.jsx(sr,{id:`delete-${t.slug}-modal`,isOpen:A,functions:{onOpen:()=>{},onClose:()=>L(!1)},forceShow:{error:re==="delete-error"?f.formatMessage({id:"discussion_delete_error"},{action:f.formatMessage({id:`discussion_action_${t.type}`})}):!1},title:f.formatMessage({id:"discussion_delete_title"},{action:f.formatMessage({id:`discussion_action_${t.type}`})}),buttons:[{variant:"secondary",onClick:()=>L(!1),children:f.formatMessage({id:"discussion_delete_cancel"})},{variant:"primary",className:"destructive",onClick:he,children:f.formatMessage({id:"discussion_delete_delete"})}],gtmContext:`${t.type.charAt(0).toUpperCase()}${t.type.slice(1)}:${t.slug}`,children:d.jsx(ue.FormattedMessage,{id:"discussion_delete_text",values:{p:ge=>d.jsx("p",{children:ge}),action:f.formatMessage({id:`discussion_action_${t.type}`})}})})]})})};const Lx=y.lazy(()=>Promise.resolve().then(()=>kE)),zx=65,Vf=({forceShow:e,form:t,className:n})=>{const r=ue.useIntl(),i=y.useContext(Lt)||"community",s=Ka(i);s.name||(s.name=r.formatMessage({id:`member_${typeof i=="string"?i:"community"}`}));const{modal:o=!1}=e||{},[l,u]=y.useState(o||Yh("showPost")==="true"||!1),[c,h]=y.useState({showCachedText:!1});y.useEffect(()=>{if(!c.showCachedText)return;(async()=>{const g=await _o(c.title||c.body||"",zx,c.mentions);h(f=>({...f,prettifiedText:g}))})()},[c.showCachedText,c.title,c.body]);let p=r.formatMessage({id:"discussionFormCard_placeholder"});return c.showCachedText&&(c.title||c.body)&&(p=c.prettifiedText||p),d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:Y("discussion-form-card",n),onClick:m=>{m.preventDefault(),m.stopPropagation(),u(!0)},"data-testid":"discussion-form-card",children:[d.jsx(Yt,{name:s.name,src:s.image,alt:""}),d.jsx(xn,{className:Y("input",{placeholder:!c.showCachedText}),element:"span",options:{forceInline:!0,overrides:{a:Ct,blockquote:Ct,br:Ct,em:Ct,li:Ct,ol:Ct,p:Ct,s:Ct,span:Ct,strong:Ct,ul:Ct}},children:p})]}),d.jsx(Ua,{children:d.jsx(Lx,{showModal:l,functions:{cacheText:h,onClose:()=>{u(!1)}},form:t,cachedText:c,className:"in-portal"})})]})},qx=y.lazy(()=>Promise.resolve().then(()=>Ox)),Bo=({isCard:e=!1,form:t,membershipRequiredToPost:{isMember:n,required:r,join:a,leave:i,notMemberStateText:s}})=>{if(r&&!n)return d.jsx(un,{text:s,button:{breakpoints:{mobile:!0,901:!1},component:d.jsx(Zs,{isShort:!0,functions:{join:a,leave:i}})}});const{content:o,functions:l,meta:u,...c}=t,h={content:{type:(o==null?void 0:o.type)||"reply",slugs:(o==null?void 0:o.slugs)||{}},functions:{...l,create:(l==null?void 0:l.create)||(()=>{})},meta:{...u,isEditing:(u==null?void 0:u.isEditing)||!1,isPrepopulated:!1,showSuccessMessage:!1},...c,id:`add-post-${c.id||""}`};return e?d.jsx(Vf,{form:h}):d.jsx(qx,{...h})};const Gi="discussion_responses_",Kf=({type:e="answer",responses:t=0,isLoading:n=!1})=>{const r=ue.useIntl();return t=parseInt(t),d.jsxs("div",{className:"responses-heading",children:[d.jsx("h4",{children:r.formatMessage({id:`${Gi}title`},{action:r.formatMessage({id:`${Gi}${e}`}),count:t})}),!n&&t===0&&d.jsx("p",{children:Bt(r.formatMessage,`${Gi}empty`,e,e)})]})};const Zf=({loadMore:{isLoading:e,hasNextPage:t,loadNextPage:n}={isLoading:!1,hasNextPage:!1,loadNextPage:()=>{}},form:r,children:a})=>{const i=ue.useIntl(),s=y.useContext(ri),o=fa(a,{element:"li"});if(s.prepopulateForm&&(r!=null&&r.meta)&&(r.meta.isPrepopulated={text:s.prepopulateForm},s.mentionData)){const l=r.data||{};l.mentions||(l.mentions={});const u=s.mentionData.id||"1";l.mentions[u]={created_at:"",updated_at:"",id:u,data:s.mentionData},r.data=l,r.meta.isAutoFocused=!0}return d.jsxs("div",{className:Y("thread-wrapper",{"empty-thread":!o}),children:[!Object.is(o,null)&&d.jsx("ul",{className:"thread",children:o}),!e&&d.jsx($r,{hasNextPage:t,loadNextPage:n,size:"small",styling:{muted:!0},icon:{icon:"arrow_corner-down_right",position:"left"},messages:{button:i.formatMessage({id:"discussion_thread_loadMore"}),error:i.formatMessage({id:"loadMore_error"})}}),r&&s.showForm&&d.jsx(zr,{...r})]})},Wx="post",Hx="reply",Yf="00000000-0000-0000-0000-000000000000";function Fo({queryClient:e,queryKey:t}){function n(r,a,i){e.setQueryData(t,i)}return n}function Ao({queryClient:e,queryKey:t}){async function n(r){await e.cancelQueries({queryKey:t});const a=e.getQueryData(t);return e.setQueryData(t,r),a}return n}function Ux(){return{latest_reactions:{like:[],reply:[]},reaction_counts:{like:0,reply:0},own_reactions:{like:[],reply:[]}}}function Vx(){return{latest_children:{like:[],reply:[]},children_counts:{like:0,reply:0},own_children:{like:[],reply:[]}}}function Gf(e){const{id:t="",name:n="",organization:r="",jobTitle:a="",image:i={}}=e,{thumbnail:s=""}=i;return{id:t,data:{name:n,organization:r,jobTitle:a,thumbnail:s}}}function Kx({title:e,content:t}){return{title:e,content:t,id:Yf,time:new Date().toISOString(),verb:Wx}}function Xl({activity:e,user:t}){return{...e,actor:Gf(t),...Ux()}}function Pa({activity:e,reaction:t}){var n,r,a;t?(e.latest_reactions={...e.latest_reactions||{},like:[...((r=e.latest_reactions)==null?void 0:r.like)||[],t]},e.own_reactions={...e.own_reactions||{},like:[...((a=e.own_reactions)==null?void 0:a.like)||[],t]}):e.reaction_counts={...e.reaction_counts||{},like:(n=e.reaction_counts)!=null&&n.like?e.reaction_counts.like+1:1}}function Qf({activity:e,user:t}){var n,r,a;e.reaction_counts={...e.reaction_counts||{},like:(n=e.reaction_counts)!=null&&n.like?e.reaction_counts.like-1:0},t!=null&&t.id&&(e.latest_reactions={...e.latest_reactions||{},like:(((r=e.latest_reactions)==null?void 0:r.like)||[]).filter(({user_id:i})=>i!==t.id)},e.own_reactions={...e.own_reactions||{},like:(((a=e.own_reactions)==null?void 0:a.like)||[]).filter(({user_id:i})=>i!==t.id)})}function Zx({activityId:e,replyId:t,content:n}){return{activity_id:e,data:{content:n},id:Yf,kind:Hx,parent:t||""}}function ec({reply:e,user:t}){const n=Gf(t);return{...e,user_id:n.id,user:n,...Vx()}}function tc({reply:e,reaction:t}){var n,r,a;t?(e.latest_children={...e.latest_children||{},like:[...((r=e.latest_children)==null?void 0:r.like)||[],t]},e.own_children={...e.own_children||{},like:[...((a=e.own_children)==null?void 0:a.like)||[],t]}):e.children_counts={...e.children_counts||{},like:(n=e.children_counts)!=null&&n.like?e.children_counts.like+1:1}}function Yx({reply:e,user:t}){var n,r,a;e.children_counts={...e.children_counts||{},like:(n=e.children_counts)!=null&&n.like?e.children_counts.like-1:0},t!=null&&t.id&&(e.latest_children={...e.latest_children||{},like:(((r=e.latest_children)==null?void 0:r.like)||[]).filter(({user_id:i})=>i!==t.id)},e.own_children={...e.own_children||{},like:(((a=e.own_children)==null?void 0:a.like)||[]).filter(({user_id:i})=>i!==t.id)})}const Jf=e=>{const t=new CustomEvent("discussionPostAdded",{detail:e});document.dispatchEvent(t)};let nc,Qi=0;const Xf=()=>{y.useEffect(()=>(document.addEventListener("discussionPostAdded",e),()=>{document.removeEventListener("discussionPostAdded",e)}),[]);const e=t=>{const n=t.detail;if(!n)return;clearTimeout(nc);const r=document.getElementById(n);if(r){r.scrollIntoView({behavior:"smooth",block:"start"}),Qi=0;return}Qi++,!(Qi>10)&&(nc=setTimeout(()=>{e(t)},50))}},Xn=Object.freeze({id:"some-user-id-1",name:"some user name 1",organization:"some user organization 1",jobTitle:"some user job title 1",image:{thumbnail:"https://some-user-thumbnail.com/avatar1.png"},isLoading:!1}),on=Object.freeze({id:"some-user-id-2",name:"some user name 2",organization:"some user organization 2",jobTitle:"some user job title 2",image:{thumbnail:"https://some-user-thumbnail.com/avatar2.png"},isLoading:!1}),eh=Object.freeze({actor:`SU:${Xn.id}`,content:"some content 1",duration:"5.53ms",feed_id:"some-feed-id-1",foreign_id:"post:some-foriegn-id-1",id:"some-activity-id-1",object:"comment",time:"2023-11-24T17:52:36.162000",verb:"post"}),Gx=Object.freeze({actor:`SU:${on.id}`,content:"some content 2",duration:"5.53ms",feed_id:"some-feed-id-2",foreign_id:"post:some-foriegn-id-2",id:"some-activity-id-2",object:"comment",time:"2023-11-24T17:54:36.162000",verb:"post"}),Qx=Object.freeze({actor:`SU:${Xn.id}`,content:"some content 3",duration:"5.53ms",feed_id:"some-feed-id-3",foreign_id:"post:some-foriegn-id-3",id:"some-activity-id-3",object:"comment",time:"2023-11-24T17:56:36.162000",verb:"post"}),Jx=Object.freeze({actor:`SU:${on.id}`,content:"some content 4",duration:"5.53ms",feed_id:"some-feed-id-4",foreign_id:"post:some-foriegn-id-4",id:"some-activity-id-4",object:"comment",time:"2023-11-24T17:54:36.162000",verb:"post"});Object.freeze({id:"some-reaction-id-1",activity_id:eh.id,kind:"like",created_at:"2023-11-24T17:58:36.162000",data:{},parent:"",updated_at:"2023-11-24T17:58:36.162000",user_id:on.id,children_counts:{},latest_children:{},latest_children_extra:{},own_children:{},user:{id:on.id,data:{},created_at:"2023-11-24T17:58:36.162000",updated_at:"2023-11-24T17:58:36.162000"}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-1",user_id:on.id,user:{id:on.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:eh.id,data:{content:"Some content 1..."},parent:"",latest_children:{},children_counts:{}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-2",user_id:Xn.id,user:{id:Xn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Gx.id,data:{content:"Some content 2..."},parent:"",latest_children:{},children_counts:{}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-3",user_id:on.id,user:{id:on.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Qx.id,data:{content:"Some content 3..."},parent:"",latest_children:{},children_counts:{}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-3",user_id:Xn.id,user:{id:Xn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Jx.id,data:{content:"Some content 4..."},parent:"",latest_children:{},children_counts:{}});function Xx({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a,user:i}){const{mutate:s}=Ye.useMutation({mutationFn:e,onMutate:o=>t(l=>{const u=Xl({activity:Kx(o),user:i});return rc(u,l)}),onError:n,onSuccess:(o,l,u)=>{const c=Xl({activity:o,user:i});r.setQueryData(a,rc(c,u,!0)),setTimeout(()=>{Jf(c.id)},0)}});return s}function ew({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ye.useMutation({mutationFn:e,onMutate:({activityId:a,content:i})=>t(s=>{const o=Na(a,s);return o&&(o.content=i),s}),onError:n});return r}function tw({queryFns:{create:e,edit:t,like:n,list:r,remove:a,unlike:i},queryKey:s,rankingMethod:o}){const l=Ye.useQueryClient(),u=Za(),c={queryClient:l,queryKey:s},h={mutationHandlers:{error:Fo(c),mutate:Ao(c)},user:u,...c},p=Xx({...h,mutationFn:e}),m=ew({...h,mutationFn:t}),g=nw({...h,mutationFn:n}),f=aw({...h,mutationFn:a}),D=iw({...h,mutationFn:i}),{activities:v,...E}=rw({queryKey:s,queryFn:r,rankingMethod:o});return{activities:v,mutations:{create:p,edit:m,remove:f,like:g,unlike:D},user:u,...E}}function nw({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=Ye.useMutation({mutationFn:e,onMutate:({activityId:s})=>t(o=>{const l=Na(s,o);return l&&Pa({activity:l}),o}),onError:n,onSuccess:(s,{activityId:o},l)=>{const u=Na(o,l);u&&Pa({activity:u,reaction:s}),r.setQueryData(a,l)}});return i}function rw({queryFn:e,queryKey:t,rankingMethod:n}){const{data:r,error:a,isLoading:i,hasNextPage:s,fetchNextPage:o}=Ye.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:`ranking=${n}`,getNextPageParam:l=>`${l==null?void 0:l.next}&ranking=${n}`||null});return{activities:ow(r),error:a,isLoading:i,hasNextPage:s,fetchNextPage:o}}function aw({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ye.useMutation({mutationFn:e,onMutate:({activityId:a})=>t(i=>sw(a,i)),onError:n});return r}function iw({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=Ye.useMutation({mutationFn:e,onMutate:({activityId:i})=>t(s=>{const o=Na(i,s);return o&&Qf({activity:o,user:r}),s}),onError:n});return a}function rc(e,t,n=!1){return t?(n?t.pages[0].results[0]=e:t.pages[0].results=[e,...t.pages[0].results],t):{pages:[{next:"",results:[e]}],pageParams:[""]}}function Na(e,t){if(t)for(const{results:n}of t.pages){const r=n.find(({id:a})=>a===e);if(r)return r}}function sw(e,t){for(const{results:n}of t.pages){const r=n.findIndex(({id:a})=>a===e);if(r!==-1){n.splice(r,1);break}}return t}function ow(e){var t;return((t=e==null?void 0:e.pages)==null?void 0:t.reduce((n,{results:r})=>[...n,...r],[]))||[]}const uw=({basePath:e,parentId:t,isMember:n,functions:{activities:r,mentions:a,join:i,leave:s}})=>{const o=Dm(Us.COMMUNITY_RANKING),l=ue.useIntl(),[u,c]=y.useState("recent"),[h,p]=y.useState([{id:"recent",label:"recent"},{id:"community_feed_live",label:"popular"}]),{activities:m,error:g,fetchNextPage:f,hasNextPage:D,isLoading:v,mutations:{create:E,edit:B,remove:x,like:k,unlike:T}}=tw({queryKey:[e,t,"activities",u],queryFns:r,rankingMethod:u});y.useEffect(()=>{o&&p(h.concat(o))},[o]);const[S,q]=y.useState(null),N=()=>{q(m.length),f()};return Xf(),g?d.jsx(un,{variant:"error",text:g.message}):d.jsxs("section",{children:[d.jsx(Bo,{isCard:!0,form:{content:{type:"post",slugs:{}},functions:{create:E,...a},meta:{isEditing:!1,isAutoFocused:!1,isPrepopulated:!1,showSuccessMessage:!1}},membershipRequiredToPost:{isMember:n,required:!0,join:i,leave:s,notMemberStateText:l.formatMessage({id:"community_joinToPost"})}}),d.jsx(ln,{className:"activities-feed-sorting-form",fields:[{id:"feed-sorting",label:l.formatMessage({id:"activitiesFeed_sorting_label"}),type:"select",options:h.map(({id:I,label:z})=>({id:I,label:l.formatMessage({id:`activitiesFeed_rankingMethod_${z}`})})),initialValue:u,functions:{onChange:I=>c(I)}}],button:{hideButton:!0},functions:{onCatch:()=>{},onFailure:()=>{},onSuccess:async()=>{},onCancel:()=>{}},id:"activities-feed-sorting-form"}),m==null?void 0:m.map((I,z)=>{var W,_,A,L,$,U,re,te;const{id:w,own_reactions:F,latest_reactions:j,reaction_counts:M,mentioned_users:V}=I,G=(((W=j==null?void 0:j.like)==null?void 0:W.length)||0)>0,J=(((_=F==null?void 0:F.like)==null?void 0:_.length)||0)>0,ae=J?F==null?void 0:F.like[0].id:"",C=G?(A=j==null?void 0:j.like)==null?void 0:A.map(ne=>{var le,Q,pe;return{id:(le=ne==null?void 0:ne.user)==null?void 0:le.id,name:(pe=(Q=ne==null?void 0:ne.user)==null?void 0:Q.data)==null?void 0:pe.name}}):!1,R=I==null?void 0:I.actor;return d.jsx(y.Fragment,{children:d.jsx(qr,{content:{type:"post",title:I==null?void 0:I.title,body:I==null?void 0:I.content,canLike:n,createdAt:(I==null?void 0:I.time)||"",slugs:{question:`${e}/${t}`,answer:w},slug:w,author:{id:R==null?void 0:R.id,name:(L=R==null?void 0:R.data)==null?void 0:L.name,organization:($=R==null?void 0:R.data)==null?void 0:$.organization,jobTitle:(U=R==null?void 0:R.data)==null?void 0:U.jobTitle,location:(re=R==null?void 0:R.data)==null?void 0:re.location,image:{thumbnail:((te=R==null?void 0:R.data)==null?void 0:te.thumbnail)||void 0}},userLiked:J,likes:(M==null?void 0:M.like)||0,comments:(M==null?void 0:M.reply)||0,peopleWhoLiked:C,mentions:V},links:{post:`${e}/${t}/${w}`,comments:`${e}/${t}/${w}`},gtmContext:"community",functions:{content:{createContent:()=>null,deleteContent:()=>x({activityId:w}),updateContent:(ne,{body:le})=>B({activityId:w,content:le})},likes:{createLike:()=>k({activityId:w}),deleteLike:()=>T({activityId:w,reactionId:ae})},comments:{openComments:()=>null},mentions:a},isTruncated:!0,styling:{showShareLinkButton:!0},setFocus:z===S})},w)}),!v&&d.jsx($r,{hasNextPage:D,loadNextPage:N,icon:{icon:"arrow-down",position:"right"},messages:{button:l.formatMessage({id:"loadMore_button"}),error:l.formatMessage({id:"loadMore_error"})}})]})},lw={next:"id_lt=67ef0342-6f6e-4807-beea-5a9184ec140c&limit=5",results:[{created_at:"2023-12-03T18:47:44.081716Z",updated_at:"2023-12-03T18:47:44.081716Z",id:"256b921e-ffe6-410d-b754-ac1aaee989ce",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 17..."},parent:"",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:02.517688Z",updated_at:"2023-12-03T18:47:24.852582Z",id:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 16 (edited)..."},parent:"",latest_children:{reply:[{created_at:"2023-12-03T19:28:09.799652Z",updated_at:"2023-12-03T19:28:09.799652Z",id:"bf1ec451-e7c3-4ebe-a60e-248b0ec2a671",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 3..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:59.756761Z",updated_at:"2023-12-03T19:27:59.756761Z",id:"7887d921-e2ba-48ef-8089-db24536dbf70",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 2..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:46.534650Z",updated_at:"2023-12-03T19:27:46.534650Z",id:"73f5bdf3-7080-48ac-a8dc-185f71b38b42",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 1..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}}]},own_children:{reply:[{created_at:"2023-12-03T19:28:09.799652Z",updated_at:"2023-12-03T19:28:09.799652Z",id:"bf1ec451-e7c3-4ebe-a60e-248b0ec2a671",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 3..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:59.756761Z",updated_at:"2023-12-03T19:27:59.756761Z",id:"7887d921-e2ba-48ef-8089-db24536dbf70",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 2..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:46.534650Z",updated_at:"2023-12-03T19:27:46.534650Z",id:"73f5bdf3-7080-48ac-a8dc-185f71b38b42",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 1..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}}]},children_counts:{reply:3}},{created_at:"2023-12-03T17:47:45.107092Z",updated_at:"2023-12-03T17:47:45.107092Z",id:"27a59e8f-f094-442f-88ec-1d5ec2f72790",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 14..."},parent:"",latest_children:{reply:[{created_at:"2023-12-03T18:47:10.603929Z",updated_at:"2023-12-03T18:47:10.603929Z",id:"c32b83d5-c5fc-4253-8531-eb99dcb01f28",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 8..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:47:04.856649Z",updated_at:"2023-12-03T18:47:04.856649Z",id:"5efd80e3-cb11-4748-8c64-f46b71df69c4",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 7..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:22.687552Z",updated_at:"2023-12-03T18:36:22.687552Z",id:"a3a2ebae-6df2-4dc0-beee-2296188b67aa",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 6..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:16.129336Z",updated_at:"2023-12-03T18:36:16.129336Z",id:"72948da5-bf3c-4bd5-9a21-2cee36e0ce8a",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 5..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:40.850756Z",updated_at:"2023-12-03T17:56:40.850756Z",id:"81ebc855-d1f6-4a2c-a788-a251bae406b6",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 4..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:34.103420Z",updated_at:"2023-12-03T17:56:34.103420Z",id:"ddc28de7-4e89-4572-8122-c95dceacc2fd",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 3..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:26.410145Z",updated_at:"2023-12-03T17:56:26.410145Z",id:"916ed4b6-ad87-47bc-9e00-7b0c46180276",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 2..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:19.921740Z",updated_at:"2023-12-03T17:56:19.921740Z",id:"92cddcb2-cbdc-4e69-9c8e-5afe3a607411",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 1..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}}]},own_children:{reply:[{created_at:"2023-12-03T18:47:10.603929Z",updated_at:"2023-12-03T18:47:10.603929Z",id:"c32b83d5-c5fc-4253-8531-eb99dcb01f28",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 8..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:47:04.856649Z",updated_at:"2023-12-03T18:47:04.856649Z",id:"5efd80e3-cb11-4748-8c64-f46b71df69c4",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 7..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:22.687552Z",updated_at:"2023-12-03T18:36:22.687552Z",id:"a3a2ebae-6df2-4dc0-beee-2296188b67aa",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 6..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:16.129336Z",updated_at:"2023-12-03T18:36:16.129336Z",id:"72948da5-bf3c-4bd5-9a21-2cee36e0ce8a",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 5..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:40.850756Z",updated_at:"2023-12-03T17:56:40.850756Z",id:"81ebc855-d1f6-4a2c-a788-a251bae406b6",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 4..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}}]},children_counts:{reply:8}},{created_at:"2023-12-03T17:47:40.066170Z",updated_at:"2023-12-03T17:47:40.066170Z",id:"9ed6a1d0-00b5-4a03-94d7-ac01e188e2e2",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 13..."},parent:"",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:47:33.107894Z",updated_at:"2023-12-03T17:47:33.107894Z",id:"67ef0342-6f6e-4807-beea-5a9184ec140c",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 12..."},parent:"",latest_children:{},children_counts:{}}],duration:"6.48ms"};function cw({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a,user:i}){const{mutate:s}=Ye.useMutation({mutationFn:e,onMutate:o=>t(l=>{const u=ec({reply:Zx(o),user:i});return ac(u,l,{replace:!1,append:(o==null?void 0:o.replyId)!==void 0})}),onError:n,onSuccess:(o,l,u)=>{const c=ec({reply:o,user:i});r.setQueryData(a,ac(c,u,{replace:!0,append:(l==null?void 0:l.replyId)!==void 0})),setTimeout(()=>{Jf(c.id)},0)}});return s}function dw({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ye.useMutation({mutationFn:e,onMutate:({replyId:a,content:i})=>t(s=>{const o=Ra(a,s);return o&&(o.data.content=i),s}),onError:n});return r}function th({queryFns:{create:e,edit:t,like:n,list:r,remove:a,unlike:i},queryKey:s}){const o=Ye.useQueryClient(),l=Za(),u={queryClient:o,queryKey:s},c={mutationHandlers:{error:Fo(u),mutate:Ao(u)},user:l,...u},h=cw({...c,mutationFn:e}),p=dw({...c,mutationFn:t}),m=fw({...c,mutationFn:n}),g=mw({...c,mutationFn:a}),f=pw({...c,mutationFn:i}),{replies:D,...v}=hw({queryKey:s,queryFn:r});return{replies:D,mutations:{create:h,edit:p,remove:g,like:m,unlike:f},user:l,...v}}function fw({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=Ye.useMutation({mutationFn:e,onMutate:({replyId:s})=>t(o=>{const l=Ra(s,o);return l&&tc({reply:l}),o}),onError:n,onSuccess:(s,{replyId:o},l)=>{const u=Ra(o,l);u&&tc({reply:u,reaction:s}),r.setQueryData(a,l)}});return i}function hw({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}=Ye.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:{next:""},getNextPageParam:u=>(u==null?void 0:u.next)||null}),o=Dw(n),l=`${o.length||0}${i?"+":""}`;return{replies:o,repliesCount:l,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}}function mw({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ye.useMutation({mutationFn:e,onMutate:({replyId:a})=>t(i=>yw(a,i)),onError:n});return r}function pw({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=Ye.useMutation({mutationFn:e,onMutate:({replyId:i})=>t(s=>{const o=Ra(i,s);return o&&Yx({reply:o,user:r}),s}),onError:n});return a}function gw(e){return{pages:[{next:"",results:[e]}],pageParams:[""]}}function vw(e,t,n){const r=t.pages.length-1,a=t.pages[r].results.length-1;return n!=null&&n.replace?t.pages[r].results[a]=e:t.pages[r].results.push(e),t}function bw(e,t,n){return n!=null&&n.replace?t.pages[0].results[0]=e:t.pages[0].results=[e,...t.pages[0].results],t}function ac(e,t,n){return t?n!=null&&n.append?vw(e,t,n):bw(e,t,n):gw(e)}function Ra(e,t){if(t)for(const{results:n}of t.pages){const r=n.find(({id:a})=>a===e);if(r)return r}}function yw(e,t){for(const{results:n}of t.pages){const r=n.findIndex(({id:a})=>a===e);if(r!==-1){n.splice(r,1);break}}return t}function Dw(e){var t;return((t=e==null?void 0:e.pages)==null?void 0:t.reduce((n,r)=>[...n,...r==null?void 0:r.results],[]))||[]}const Cw=({basePath:e,parentId:t,activityId:n,replyId:r,isMember:a,functions:i})=>{const s=ue.useIntl(),o=3,{replies:l,fetchNextPage:u,hasNextPage:c,isLoading:h,mutations:{create:p,edit:m,like:g,remove:f,unlike:D},user:v}=th({queryKey:[e,t,n,r,"replies"],queryFns:{...i,list:x=>i.list({...x,reactionId:r})}});$s([h]);const[E,B]=y.useState(!0);return d.jsxs(d.Fragment,{children:[(l==null?void 0:l.length)>=o&&d.jsx(_e,{className:"nested-replies-show-toggle",variant:"secondary",size:"small",icon:{icon:`arrow_corner-${E?"up_left":"down_right"}`,position:"left"},onClick:()=>B(!E),children:s.formatMessage({id:`discussion_thread_${E?"hide":"show"}`},{count:l==null?void 0:l.length})}),E&&d.jsx(Zf,{loadMore:{isLoading:h,hasNextPage:c,loadNextPage:()=>u()},form:{content:{type:"reply",slugs:{question:`${e}/${t}`,answer:n,reply:r}},functions:{create:(x,{body:k})=>p({activityId:n,replyId:r,content:k}),listMembers:i.listMembers,clickMentionFallback:i.clickMentionFallback},meta:{isEditing:!1,isAutoFocused:!0,isPrepopulated:!1,showSuccessMessage:!1}},children:l&&l.length>0?l==null?void 0:l.map(x=>{var J,ae,C,R,W,_,A,L,$,U,re,te;const{id:k,own_children:T,latest_children:S,children_counts:q,data:{mentioned_users:N}}=x,z=(((J=T==null?void 0:T.like)==null?void 0:J.length)||0)>0?(ae=T==null?void 0:T.like)==null?void 0:ae.find(ne=>{var le;return((le=ne==null?void 0:ne.user)==null?void 0:le.id)===(v==null?void 0:v.id)}):!1,w=z?z==null?void 0:z.id:"",F=!!z,M=(((C=S==null?void 0:S.like)==null?void 0:C.length)||0)>0?(R=S==null?void 0:S.like)==null?void 0:R.map(ne=>{var le,Q,pe;return{id:(le=ne==null?void 0:ne.user)==null?void 0:le.id,name:(pe=(Q=ne==null?void 0:ne.user)==null?void 0:Q.data)==null?void 0:pe.name}}):!1,V=x==null?void 0:x.user,G=typeof x.data.content=="string"?(W=x==null?void 0:x.data)==null?void 0:W.content:((A=(_=x==null?void 0:x.data)==null?void 0:_.content)==null?void 0:A.text)||"";return d.jsx(qr,{isCommunity:!0,content:{id:k,type:"reply",body:G,canLike:a,createdAt:x==null?void 0:x.created_at,slugs:{question:`${e}/${t}`,answer:n,reply:x==null?void 0:x.parent},slug:"",author:{id:V==null?void 0:V.id,name:(L=V.data)==null?void 0:L.name,organization:($=V.data)==null?void 0:$.organization,jobTitle:(U=V.data)==null?void 0:U.jobTitle,location:(re=V.data)==null?void 0:re.location,image:{thumbnail:((te=V.data)==null?void 0:te.thumbnail)||void 0}},userLiked:F,likes:(q==null?void 0:q.like)||0,peopleWhoLiked:M,mentions:N},functions:{content:{createContent:()=>null,deleteContent:()=>f({replyId:k}),updateContent:(ne,{body:le})=>m({replyId:k,content:le})},likes:{createLike:()=>g({replyId:k}),deleteLike:()=>D({replyId:k,reactionId:w})},comments:{},mentions:{listMembers:i.listMembers,clickMentionFallback:i.clickMentionFallback}},styling:{showShareLinkButton:!0}},k)}):null})]})};const nh=({basePath:e,parentId:t,activityId:n,isMember:r,functions:{reactions:a,mentions:i,join:s,leave:o}})=>{const l=ue.useIntl(),{replies:u,repliesCount:c,fetchNextPage:h,hasNextPage:p,isLoading:m,mutations:{create:g,edit:f,like:D,remove:v,unlike:E},user:B}=th({queryKey:[e,t,n,"replies"],queryFns:a}),x=()=>{T(u.length),h()},[k,T]=y.useState(null);return $s([m]),Xf(),d.jsxs("section",{className:"replies-feed",children:[d.jsx(Kf,{type:"comment",responses:c,isLoading:m}),d.jsx(Bo,{form:{content:{type:"reply",slugs:{}},functions:{create:(S,{body:q})=>g({activityId:n,content:q}),...i},meta:{isEditing:!1,isAutoFocused:!1,isPrepopulated:!1,showSuccessMessage:!1},placeholder:l.formatMessage({id:"discussion_responses_placeholder"})},membershipRequiredToPost:{isMember:r,required:!0,join:s,leave:o,notMemberStateText:l.formatMessage({id:"community_joinToPost"})}}),u==null?void 0:u.map((S,q)=>{var W,_,A,L,$,U,re,te,ne,le,Q,pe;const{id:N,own_children:I,latest_children:z,children_counts:w,data:{mentioned_users:F}}=S,M=(((W=I==null?void 0:I.like)==null?void 0:W.length)||0)>0?(_=I==null?void 0:I.like)==null?void 0:_.find(he=>{var ye;return((ye=he==null?void 0:he.user)==null?void 0:ye.id)===(B==null?void 0:B.id)}):!1,V=M?M==null?void 0:M.id:"",G=!!M,ae=(((A=z==null?void 0:z.like)==null?void 0:A.length)||0)>0?(L=z==null?void 0:z.like)==null?void 0:L.map(he=>{var ye,Fe,Ae;return{id:(ye=he==null?void 0:he.user)==null?void 0:ye.id,name:(Ae=(Fe=he==null?void 0:he.user)==null?void 0:Fe.data)==null?void 0:Ae.name}}):!1,C=S==null?void 0:S.user,R=typeof S.data.content=="string"?($=S==null?void 0:S.data)==null?void 0:$.content:((re=(U=S==null?void 0:S.data)==null?void 0:U.content)==null?void 0:re.text)||"";return d.jsx(Hf,{children:d.jsx(qr,{isCommunity:!0,content:{id:N,type:"reply",body:R,canLike:r,createdAt:S==null?void 0:S.created_at,slugs:{question:`${e}/${t}`,answer:n,reply:N},slug:N,author:{id:C==null?void 0:C.id,name:(te=C.data)==null?void 0:te.name,organization:(ne=C.data)==null?void 0:ne.organization,jobTitle:(le=C.data)==null?void 0:le.jobTitle,location:(Q=C.data)==null?void 0:Q.location,image:{thumbnail:((pe=C.data)==null?void 0:pe.thumbnail)||void 0}},userLiked:G,likes:(w==null?void 0:w.like)||0,peopleWhoLiked:ae,mentions:F},functions:{content:{createContent:()=>null,deleteContent:()=>v({replyId:N}),updateContent:(he,{body:ye})=>f({replyId:N,content:ye})},likes:{createLike:()=>D({replyId:N}),deleteLike:()=>E({replyId:N,reactionId:V})},comments:{},mentions:i},children:d.jsx(Cw,{basePath:e,parentId:t,activityId:n,replyId:N,isMember:r,functions:{...a,...i}}),styling:{showShareLinkButton:!0},setFocus:q===k},N)},N)}),!m&&d.jsx($r,{hasNextPage:p,loadNextPage:x,icon:{icon:"arrow-down",position:"right"},messages:{button:l.formatMessage({id:"loadMore_button"}),error:l.formatMessage({id:"loadMore_error"})}})]})};function xw({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ye.useMutation({mutationFn:e,onMutate:({content:a,title:i})=>t(s=>(s&&(a!=null&&(s.content=a),i!=null&&(s.title=i)),s)),onError:n});return r}function ww({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:a,isFetching:i}=Ye.useQuery({queryFn:e,queryKey:t});return{activity:n,error:r,isLoading:a,isFetching:i}}function Ew({queryFns:{read:e,edit:t,like:n,unlike:r},queryKey:a}){const i=Ye.useQueryClient(),s=Za(),o={queryClient:i,queryKey:a},l={mutationHandlers:{error:Fo(o),mutate:Ao(o)},user:s,...o},u=xw({...l,mutationFn:t}),c=kw({...l,mutationFn:n}),h=_w({...l,mutationFn:r}),{activity:p,...m}=ww({queryKey:a,queryFn:e});return{activity:p,mutations:{edit:u,like:c,unlike:h},user:s,...m}}function kw({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=Ye.useMutation({mutationFn:e,onMutate:s=>t(o=>(o&&Pa({activity:o}),o)),onError:n,onSuccess:(s,o,l)=>{l&&Pa({activity:l,reaction:s}),r.setQueryData(a,l)}});return i}function _w({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=Ye.useMutation({mutationFn:e,onMutate:i=>t(s=>(s&&Qf({activity:s,user:r}),s)),onError:n});return a}const Bw=({basePath:e,parentId:t,activityId:n,isMember:r,functions:{activities:{remove:a,...i},reactions:s,mentions:o,join:l,leave:u}})=>{var N,I,z,w,F,j,M,V,G,J;const c=ue.useIntl(),{activity:h,error:p,isLoading:m,mutations:{edit:g,like:f,unlike:D}}=Ew({queryFns:i,queryKey:[e,t,n]});if(m)return d.jsx(kt,{style:{height:"400px"}});if(p||!h)return d.jsx(un,{variant:"error",text:c.formatMessage({id:"activitySection_notFoundError"})});const{own_reactions:v,latest_reactions:E,mentioned_users:B}=h,x=(((N=E==null?void 0:E.like)==null?void 0:N.length)||0)>0,k=(((I=v==null?void 0:v.like)==null?void 0:I.length)||0)>0,T=k?v==null?void 0:v.like[0].id:"",S=x?(z=E==null?void 0:E.like)==null?void 0:z.map(ae=>{var C,R,W;return{id:(C=ae==null?void 0:ae.user)==null?void 0:C.id,name:(W=(R=ae==null?void 0:ae.user)==null?void 0:R.data)==null?void 0:W.name}}):!1,q=h==null?void 0:h.actor;return d.jsxs("section",{className:"activity-section",children:[d.jsx(qr,{className:"highlighted-text-box subtle",isCommunity:!0,content:{id:n,type:"post",title:h==null?void 0:h.title,body:h==null?void 0:h.content,canLike:r,createdAt:(h==null?void 0:h.time)||"",slugs:{question:`${e}/${t}`,answer:h==null?void 0:h.id},slug:n,author:{id:q.id,name:(w=q.data)==null?void 0:w.name,organization:(F=q.data)==null?void 0:F.organization,jobTitle:(j=q.data)==null?void 0:j.jobTitle,location:(M=q.data)==null?void 0:M.location,image:{thumbnail:((V=q.data)==null?void 0:V.thumbnail)||void 0}},userLiked:k,likes:((G=h==null?void 0:h.reaction_counts)==null?void 0:G.like)||0,comments:((J=h==null?void 0:h.reaction_counts)==null?void 0:J.reply)||0,peopleWhoLiked:S,mentions:B},originalAuthorId:q==null?void 0:q.id,forceHide:{comments:!0},functions:{content:{createContent:()=>null,deleteContent:a,updateContent:(ae,{title:C,body:R})=>g({title:C,content:R})},likes:{createLike:()=>f({activityId:n}),deleteLike:()=>D({activityId:n,reactionId:T})},comments:{openComments:()=>{}},mentions:o},styling:{showShareLinkButton:!0}},n),d.jsx(nh,{basePath:e,parentId:t,activityId:n,isMember:r,functions:{reactions:s,mentions:o,join:l,leave:u}})]})};var Ns={exports:{}},sa={exports:{}},Re={};/** @license React v16.13.1
|
|
140
|
+
`;return a.slice(0,i.length)===i&&(a=a.slice(i.length)),n?await Lc({text:a,template:"[@{{name}}](/profiles/{{id}})",mentions:n,listMembers:r}):a};const Mx=3e3,Ix=({url:e,gtm:t={context:"ShareLink",event:"copy-link-click"}})=>{const n=ue.useIntl(),[r,a]=y.useState({isOpen:!1,isCopied:!1});return d.jsxs("li",{children:[d.jsx(An,{className:Y("tooltip-share-link",{"tooltip-share-link-copied":r.isCopied}),isOpen:r.isOpen,styling:{hasPointer:"bottom",extraPadding:!1},children:r.isCopied?n.formatMessage({id:"discussion_share_copy_link_success"}):n.formatMessage({id:"discussion_share_copy_link"})}),d.jsx(Oa,{className:"gtm-trackable",icon:{icon:"link_chain"},onMouseOver:()=>a({...r,isOpen:!0}),onFocus:()=>a({...r,isOpen:!0}),onMouseOut:()=>a({isOpen:!1,isCopied:!1}),onBlur:()=>a({isOpen:!1,isCopied:!1}),onClick:()=>{navigator.clipboard.writeText(e).then(()=>{a({isOpen:!0,isCopied:!0}),setTimeout(()=>{a({isOpen:!1,isCopied:!1})},Mx)})},"data-gtm-event-context":t.context,"data-gtm-event-type":t.event})]})},Ht="discussion_",$x=195,qr=({element:e="div",content:t,userHasPermissions:n=!0,isLoading:r=!1,originalAuthorId:a,forceHide:i={actionBar:!1,comments:!1,likes:!1},functions:s,links:o={},className:l,gtmContext:u="DiscussionAnswer",children:c,isTruncated:h=!1,styling:{showShareLinkButton:p=!1}={},setFocus:m=!1,isCommunity:g=!1})=>{var Fe,Ae,He,Se,Te,Ne,ke,Ue;const f=ue.useIntl(),D=y.useContext(Lt),v=y.useContext(ri),{createContent:E=async()=>{},deleteContent:B=async()=>{},updateContent:x=async()=>{}}=s.content||{},{createLike:k=()=>{},deleteLike:T=()=>{}}=s.likes||{},{openComments:S=()=>{}}=s.comments||{},{listMembers:q=()=>Promise.resolve([]),clickMentionFallback:N=()=>{}}=s.mentions||{},{author:I,canLike:z,createdAt:w,id:F,likes:j=0,userLiked:M,comments:V=0,mentions:G}=t,J=D&&D.id&&typeof I!="string"&&I.id&&I.id===D.id||!1,ae=typeof z=="boolean"?z:!0,C=J&&(!t.createdAt||$h(t.createdAt,10,"seconds")),R=y.useRef(null),[W,_]=y.useState({title:t&&t.body!==t.title&&t.title||"",body:t&&t.body||"",isEditing:!1,didEdit:t&&t.isEdited||!1,postBody:""}),[A,L]=y.useState(!1),[$,U]=y.useState(C?"highlighted":"default"),[re,te]=y.useState("");y.useEffect(()=>{const ge=R.current;if(!(!ge||$==="default"))return document.addEventListener("discussionFormSubmitted",ne),ge.addEventListener("transitionend",le),()=>{document.removeEventListener("discussionFormSubmitted",ne),ge.removeEventListener("transitionend",le)}},[]),y.useEffect(()=>{_({...W,title:t&&t.title||"",body:t&&t.body||"",didEdit:t&&t.isEdited||!1})},[t.isEdited]),y.useEffect(()=>{(async()=>{const H=await _o(W.body,h,G,q);_({...W,postBody:H})})()},[W.body,G]);const ne=()=>{setTimeout(()=>{U("fading")},1e3)},le=({propertyName:ge})=>{ge==="background-color"&&U(H=>(H==="default"&&(document.removeEventListener("discussionFormSubmitted",ne),R.current&&R.current.removeEventListener("transitionend",le)),H==="fading"?"default":H))};if(r||!t||t.type==="answer"&&(!t.slugs||!t.slugs.question)||W.postBody===""&&t.title==="")return d.jsx(kt,{className:"discussion-card"});const Q=async({title:ge,body:H})=>{ge||(ge=""),H||(H=""),te("");try{if(!is(ge,W.title)||!is(H,W.body)){const ie=t.type==="question"?{title:H}:{title:ge,body:H};await x(Jl(t.slugs),ie)}_({...W,title:ge,body:H,isEditing:!1,didEdit:!0})}catch{te(`${Ht}form_error`)}},pe=()=>{if(v&&v.updateConversation){const ge={showForm:!0},H=t.author;H&&H.id&&(g&&(ge.prepopulateForm=`@{{${H.id}}}`),ge.mentionData={id:H.id,name:H.name}),v.updateConversation(ge)}setTimeout(()=>{var ve,we,Ke;const H=`reply-form-${(t.type==="answer"?t.slug:((ve=t.slugs)==null?void 0:ve.reply)||((we=t.slugs)==null?void 0:we.answer)||((Ke=t.slugs)==null?void 0:Ke.question)||"").toLowerCase().slice(-15)}`,ie=document.getElementById(H),me=document.getElementById(`${H}-input`);me&&me.focus(),ie&&ie.scrollIntoView({behavior:"smooth"})},0)},he=async()=>{L(!1);try{await B(Jl(t.slugs))}catch{te("delete-error")}},ye=[{text:f.formatMessage({id:`${Ht}moreMenu_report`}),onClick:ge=>{ge.stopPropagation()},href:`mailto:community@apolitical.co?subject=${encodeURI(f.formatMessage({id:`${Ht}report_subject`}))}&body=${encodeURI(f.formatMessage({id:`${Ht}report_body`},{contentType:t.type||"",contentSlug:t.slug||"",contentUrl:`${window.origin}${typeof process<"u"&&process.env.PUBLIC_URL||""}/${t.slugs.question||""}`}))}`,icon:"flag"}];return n&&J&&ye.push({text:f.formatMessage({id:`${Ht}moreMenu_edit`}),onClick:()=>_({...W,isEditing:!0}),icon:"pencil-paper",className:"gtm-trackable","data-gtm-event-context":u,"data-gtm-event-type":`edit-${t.type}-click`},{text:f.formatMessage({id:`${Ht}moreMenu_delete`}),onClick:ge=>{ge.preventDefault(),ge.stopPropagation(),L(!0)},icon:"trash",className:"gtm-trackable","data-gtm-event-context":u,"data-gtm-event-type":`delete-${t.type}-click`,...mh(`delete-${t.slug}-modal`,A)}),m&&((Fe=R==null?void 0:R.current)==null||Fe.focus(),(Ae=R==null?void 0:R.current)==null||Ae.scrollIntoView({behavior:"smooth"})),y.createElement(e,{className:Y("discussion-post",l,{[$]:!l||!l.includes("highlighted-text-box"),"has-link":o.post&&!W.isEditing}),ref:R,tabIndex:m?0:null,"data-testid":`discussion-${t.type}-thread`,"data-gtm-event-context":`${u}-post-click`,onClick:ge=>{!o.post||W.isEditing||(ge.preventDefault(),ge.stopPropagation(),window.location.href=o.post)},children:d.jsxs(d.Fragment,{children:[d.jsxs("div",{id:F||t.slug,className:Y("discussion-card",t.type,{editing:W.isEditing,"has-link":o.post&&!W.isEditing}),children:[!W.isEditing&&d.jsx(wn,{member:I,additionalContent:{createdAt:w,didEdit:W.didEdit},className:typeof I!="string"&&I.id===a?"highlighted":"",gtmContext:u,gtmType:"profile-click"}),W.isEditing?d.jsx(zr,{id:`editing-${t.slug}`,content:{type:t.type,slugs:t.slugs},userHasPermissions:n,meta:{isLoading:r,isInWrapper:!0,hasTitleField:W.title!==""?{text:W.title}:!1,isEditing:{text:W.body},isPrepopulated:!1},isCommunity:g,maxLength:t.type==="question"?250:5e4,forceShow:{error:re!==""&&re!=="delete-error"?f.formatMessage({id:re},{action:f.formatMessage({id:`discussion_action_${t.type}`})}):!1},functions:{create:E,handleSaveEdit:Q,handleCancel:()=>{te(""),_({...W,isEditing:!1})},listMembers:q,clickMentionFallback:N},gtmContext:`${u}Form`,data:{mentions:t.mentions}}):o.post?d.jsxs("a",{href:o.post,children:[(W==null?void 0:W.title)&&d.jsx("p",{className:"content-title",children:W==null?void 0:W.title}),W.postBody.length>$x?d.jsx(Vc,{text:W.postBody,markdownOptions:{overrides:{a:ds,blockquote:{component:Yi}}}}):d.jsx(xn,{options:{overrides:{a:ds,blockquote:{component:Yi}}},children:W.postBody})]}):d.jsxs(d.Fragment,{children:[(W==null?void 0:W.title)&&d.jsx("p",{className:"content-title",children:W==null?void 0:W.title}),d.jsx(xn,{options:{wrapper:t.type==="question"?"h1":y.Fragment,forceWrapper:t.type==="question",forceInline:t.type==="question",forceBlock:t.type!=="question",overrides:{blockquote:{component:Yi}}},children:W.postBody})]}),!W.isEditing&&!(i!=null&&i.actionBar)&&d.jsxs("ul",{className:Y("actions text-medium",t.type),"data-testid":`${t.type}-actions`,children:[!i.likes&&d.jsx(Uf,{element:"li",likes:j,isShort:!1,userLiked:M,content:{type:t.type,slugs:t.slugs,slug:t.slug},canLike:ae,peopleWhoLiked:t.peopleWhoLiked,functions:{createLike:k,deleteLike:T}}),!i.comments&&(["question","post"].includes(t.type)||o.comments)&&d.jsx("li",{children:d.jsx(Oa,{onClick:ge=>{ge.preventDefault(),ge.stopPropagation(),o.comments&&(window.location.href=o.comments),typeof S=="function"&&S()},icon:{icon:"speech-bubble_square"},"data-gtm-event-context":u,"data-gtm-event-type":`answer-${t.type}-click`,screenreaderText:f.formatMessage({id:`${Ht}comments_screenReader`},{count:V}),children:f.formatMessage({id:`${Ht}comments`},{count:V})})}),(t.type==="answer"||t.type==="reply")&&d.jsx("li",{children:d.jsx(Oa,{styling:{muted:!0},onClick:pe,icon:{icon:"speech-bubble_square"},children:f.formatMessage({id:`${Ht}reply`})})}),p&&d.jsx(Ix,{url:(He=t.slugs)!=null&&He.reply?`${window.location.origin}${(Se=t.slugs)==null?void 0:Se.question}/${(Te=t.slugs)==null?void 0:Te.answer}#${(Ne=t.slugs)==null?void 0:Ne.reply}`:`${window.location.origin}${(ke=t.slugs)==null?void 0:ke.question}/${(Ue=t.slugs)==null?void 0:Ue.answer}`,gtm:{context:u,event:`copy-link-${t.type}-click`}}),d.jsx(rd,{element:"li",id:`more-${t.slug}`,options:ye})]})]}),c,d.jsx(sr,{id:`delete-${t.slug}-modal`,isOpen:A,functions:{onOpen:()=>{},onClose:()=>L(!1)},forceShow:{error:re==="delete-error"?f.formatMessage({id:"discussion_delete_error"},{action:f.formatMessage({id:`discussion_action_${t.type}`})}):!1},title:f.formatMessage({id:"discussion_delete_title"},{action:f.formatMessage({id:`discussion_action_${t.type}`})}),buttons:[{variant:"secondary",onClick:()=>L(!1),children:f.formatMessage({id:"discussion_delete_cancel"})},{variant:"primary",className:"destructive",onClick:he,children:f.formatMessage({id:"discussion_delete_delete"})}],gtmContext:`${t.type.charAt(0).toUpperCase()}${t.type.slice(1)}:${t.slug}`,children:d.jsx(ue.FormattedMessage,{id:"discussion_delete_text",values:{p:ge=>d.jsx("p",{children:ge}),action:f.formatMessage({id:`discussion_action_${t.type}`})}})})]})})};const Lx=y.lazy(()=>Promise.resolve().then(()=>kE)),zx=65,Vf=({forceShow:e,form:t,className:n})=>{const r=ue.useIntl(),i=y.useContext(Lt)||"community",s=Ka(i);s.name||(s.name=r.formatMessage({id:`member_${typeof i=="string"?i:"community"}`}));const{modal:o=!1}=e||{},[l,u]=y.useState(o||Yh("showPost")==="true"||!1),[c,h]=y.useState({showCachedText:!1});y.useEffect(()=>{if(!c.showCachedText)return;(async()=>{const g=await _o(c.title||c.body||"",zx,c.mentions);h(f=>({...f,prettifiedText:g}))})()},[c.showCachedText,c.title,c.body]);let p=r.formatMessage({id:"discussionFormCard_placeholder"});return c.showCachedText&&(c.title||c.body)&&(p=c.prettifiedText||p),d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:Y("discussion-form-card",n),onClick:m=>{m.preventDefault(),m.stopPropagation(),u(!0)},"data-testid":"discussion-form-card",children:[d.jsx(Yt,{name:s.name,src:s.image,alt:""}),d.jsx(xn,{className:Y("input",{placeholder:!c.showCachedText}),element:"span",options:{forceInline:!0,overrides:{a:Ct,blockquote:Ct,br:Ct,em:Ct,li:Ct,ol:Ct,p:Ct,s:Ct,span:Ct,strong:Ct,ul:Ct}},children:p})]}),d.jsx(Ua,{children:d.jsx(Lx,{showModal:l,functions:{cacheText:h,onClose:()=>{u(!1)}},form:t,cachedText:c,className:"in-portal"})})]})},qx=y.lazy(()=>Promise.resolve().then(()=>Ox)),Bo=({isCard:e=!1,form:t,membershipRequiredToPost:{isMember:n,required:r,join:a,leave:i,notMemberStateText:s}})=>{if(r&&!n)return d.jsx(un,{text:s,button:{breakpoints:{mobile:!0,901:!1},component:d.jsx(Zs,{isShort:!0,functions:{join:a,leave:i}})}});const{content:o,functions:l,meta:u,...c}=t,h={content:{type:(o==null?void 0:o.type)||"reply",slugs:(o==null?void 0:o.slugs)||{}},functions:{...l,create:(l==null?void 0:l.create)||(()=>{})},meta:{...u,isEditing:(u==null?void 0:u.isEditing)||!1,isPrepopulated:!1,showSuccessMessage:!1},...c,id:`add-post-${c.id||""}`};return e?d.jsx(Vf,{form:h}):d.jsx(qx,{...h})};const Gi="discussion_responses_",Kf=({type:e="answer",responses:t=0,isLoading:n=!1})=>{const r=ue.useIntl();return t=parseInt(t),d.jsxs("div",{className:"responses-heading",children:[d.jsx("h4",{children:r.formatMessage({id:`${Gi}title`},{action:r.formatMessage({id:`${Gi}${e}`}),count:t})}),!n&&t===0&&d.jsx("p",{children:Bt(r.formatMessage,`${Gi}empty`,e,e)})]})};const Zf=({loadMore:{isLoading:e,hasNextPage:t,loadNextPage:n}={isLoading:!1,hasNextPage:!1,loadNextPage:()=>{}},form:r,children:a})=>{const i=ue.useIntl(),s=y.useContext(ri),o=fa(a,{element:"li"});if(s.prepopulateForm&&(r!=null&&r.meta)&&(r.meta.isPrepopulated={text:s.prepopulateForm},s.mentionData)){const l=r.data||{};l.mentions||(l.mentions={});const u=s.mentionData.id||"1";l.mentions[u]={created_at:"",updated_at:"",id:u,data:s.mentionData},r.data=l,r.meta.isAutoFocused=!0}return d.jsxs("div",{className:Y("thread-wrapper",{"empty-thread":!o}),children:[!Object.is(o,null)&&d.jsx("ul",{className:"thread",children:o}),!e&&d.jsx($r,{hasNextPage:t,loadNextPage:n,size:"small",styling:{muted:!0},icon:{icon:"arrow_corner-down_right",position:"left"},messages:{button:i.formatMessage({id:"discussion_thread_loadMore"}),error:i.formatMessage({id:"loadMore_error"})}}),r&&s.showForm&&d.jsx(zr,{...r})]})},Wx="post",Hx="reply",Yf="00000000-0000-0000-0000-000000000000";function Fo({queryClient:e,queryKey:t}){function n(r,a,i){e.setQueryData(t,i)}return n}function Ao({queryClient:e,queryKey:t}){async function n(r){await e.cancelQueries({queryKey:t});const a=e.getQueryData(t);return e.setQueryData(t,r),a}return n}function Ux(){return{latest_reactions:{like:[],reply:[]},reaction_counts:{like:0,reply:0},own_reactions:{like:[],reply:[]}}}function Vx(){return{latest_children:{like:[],reply:[]},children_counts:{like:0,reply:0},own_children:{like:[],reply:[]}}}function Gf(e){const{id:t="",name:n="",organization:r="",jobTitle:a="",image:i={}}=e,{thumbnail:s=""}=i;return{id:t,data:{name:n,organization:r,jobTitle:a,thumbnail:s}}}function Kx({title:e,content:t}){return{title:e,content:t,id:Yf,time:new Date().toISOString(),verb:Wx}}function Xl({activity:e,user:t}){return{...e,actor:Gf(t),...Ux()}}function Pa({activity:e,reaction:t}){var n,r,a;t?(e.latest_reactions={...e.latest_reactions||{},like:[...((r=e.latest_reactions)==null?void 0:r.like)||[],t]},e.own_reactions={...e.own_reactions||{},like:[...((a=e.own_reactions)==null?void 0:a.like)||[],t]}):e.reaction_counts={...e.reaction_counts||{},like:(n=e.reaction_counts)!=null&&n.like?e.reaction_counts.like+1:1}}function Qf({activity:e,user:t}){var n,r,a;e.reaction_counts={...e.reaction_counts||{},like:(n=e.reaction_counts)!=null&&n.like?e.reaction_counts.like-1:0},t!=null&&t.id&&(e.latest_reactions={...e.latest_reactions||{},like:(((r=e.latest_reactions)==null?void 0:r.like)||[]).filter(({user_id:i})=>i!==t.id)},e.own_reactions={...e.own_reactions||{},like:(((a=e.own_reactions)==null?void 0:a.like)||[]).filter(({user_id:i})=>i!==t.id)})}function Zx({activityId:e,replyId:t,content:n}){return{activity_id:e,data:{content:n},id:Yf,kind:Hx,parent:t||""}}function ec({reply:e,user:t}){const n=Gf(t);return{...e,user_id:n.id,user:n,...Vx()}}function tc({reply:e,reaction:t}){var n,r,a;t?(e.latest_children={...e.latest_children||{},like:[...((r=e.latest_children)==null?void 0:r.like)||[],t]},e.own_children={...e.own_children||{},like:[...((a=e.own_children)==null?void 0:a.like)||[],t]}):e.children_counts={...e.children_counts||{},like:(n=e.children_counts)!=null&&n.like?e.children_counts.like+1:1}}function Yx({reply:e,user:t}){var n,r,a;e.children_counts={...e.children_counts||{},like:(n=e.children_counts)!=null&&n.like?e.children_counts.like-1:0},t!=null&&t.id&&(e.latest_children={...e.latest_children||{},like:(((r=e.latest_children)==null?void 0:r.like)||[]).filter(({user_id:i})=>i!==t.id)},e.own_children={...e.own_children||{},like:(((a=e.own_children)==null?void 0:a.like)||[]).filter(({user_id:i})=>i!==t.id)})}const Jf=e=>{const t=new CustomEvent("discussionPostAdded",{detail:e});document.dispatchEvent(t)};let nc,Qi=0;const Xf=()=>{y.useEffect(()=>(document.addEventListener("discussionPostAdded",e),()=>{document.removeEventListener("discussionPostAdded",e)}),[]);const e=t=>{const n=t.detail;if(!n)return;clearTimeout(nc);const r=document.getElementById(n);if(r){r.scrollIntoView({behavior:"smooth",block:"start"}),Qi=0;return}Qi++,!(Qi>10)&&(nc=setTimeout(()=>{e(t)},50))}},Xn=Object.freeze({id:"some-user-id-1",name:"some user name 1",organization:"some user organization 1",jobTitle:"some user job title 1",image:{thumbnail:"https://some-user-thumbnail.com/avatar1.png"},isLoading:!1}),on=Object.freeze({id:"some-user-id-2",name:"some user name 2",organization:"some user organization 2",jobTitle:"some user job title 2",image:{thumbnail:"https://some-user-thumbnail.com/avatar2.png"},isLoading:!1}),eh=Object.freeze({actor:`SU:${Xn.id}`,content:"some content 1",duration:"5.53ms",feed_id:"some-feed-id-1",foreign_id:"post:some-foriegn-id-1",id:"some-activity-id-1",object:"comment",time:"2023-11-24T17:52:36.162000",verb:"post"}),Gx=Object.freeze({actor:`SU:${on.id}`,content:"some content 2",duration:"5.53ms",feed_id:"some-feed-id-2",foreign_id:"post:some-foriegn-id-2",id:"some-activity-id-2",object:"comment",time:"2023-11-24T17:54:36.162000",verb:"post"}),Qx=Object.freeze({actor:`SU:${Xn.id}`,content:"some content 3",duration:"5.53ms",feed_id:"some-feed-id-3",foreign_id:"post:some-foriegn-id-3",id:"some-activity-id-3",object:"comment",time:"2023-11-24T17:56:36.162000",verb:"post"}),Jx=Object.freeze({actor:`SU:${on.id}`,content:"some content 4",duration:"5.53ms",feed_id:"some-feed-id-4",foreign_id:"post:some-foriegn-id-4",id:"some-activity-id-4",object:"comment",time:"2023-11-24T17:54:36.162000",verb:"post"});Object.freeze({id:"some-reaction-id-1",activity_id:eh.id,kind:"like",created_at:"2023-11-24T17:58:36.162000",data:{},parent:"",updated_at:"2023-11-24T17:58:36.162000",user_id:on.id,children_counts:{},latest_children:{},latest_children_extra:{},own_children:{},user:{id:on.id,data:{},created_at:"2023-11-24T17:58:36.162000",updated_at:"2023-11-24T17:58:36.162000"}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-1",user_id:on.id,user:{id:on.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:eh.id,data:{content:"Some content 1..."},parent:"",latest_children:{},children_counts:{}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-2",user_id:Xn.id,user:{id:Xn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Gx.id,data:{content:"Some content 2..."},parent:"",latest_children:{},children_counts:{}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-3",user_id:on.id,user:{id:on.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Qx.id,data:{content:"Some content 3..."},parent:"",latest_children:{},children_counts:{}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-3",user_id:Xn.id,user:{id:Xn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Jx.id,data:{content:"Some content 4..."},parent:"",latest_children:{},children_counts:{}});function Xx({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a,user:i}){const{mutate:s}=Ye.useMutation({mutationFn:e,onMutate:o=>t(l=>{const u=Xl({activity:Kx(o),user:i});return rc(u,l)}),onError:n,onSuccess:(o,l,u)=>{const c=Xl({activity:o,user:i});r.setQueryData(a,rc(c,u,!0)),setTimeout(()=>{Jf(c.id)},0)}});return s}function ew({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ye.useMutation({mutationFn:e,onMutate:({activityId:a,content:i})=>t(s=>{const o=Na(a,s);return o&&(o.content=i),s}),onError:n});return r}function tw({queryFns:{create:e,edit:t,like:n,list:r,remove:a,unlike:i},queryKey:s,rankingMethod:o}){const l=Ye.useQueryClient(),u=Za(),c={queryClient:l,queryKey:s},h={mutationHandlers:{error:Fo(c),mutate:Ao(c)},user:u,...c},p=Xx({...h,mutationFn:e}),m=ew({...h,mutationFn:t}),g=nw({...h,mutationFn:n}),f=aw({...h,mutationFn:a}),D=iw({...h,mutationFn:i}),{activities:v,...E}=rw({queryKey:s,queryFn:r,rankingMethod:o});return{activities:v,mutations:{create:p,edit:m,remove:f,like:g,unlike:D},user:u,...E}}function nw({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=Ye.useMutation({mutationFn:e,onMutate:({activityId:s})=>t(o=>{const l=Na(s,o);return l&&Pa({activity:l}),o}),onError:n,onSuccess:(s,{activityId:o},l)=>{const u=Na(o,l);u&&Pa({activity:u,reaction:s}),r.setQueryData(a,l)}});return i}function rw({queryFn:e,queryKey:t,rankingMethod:n}){const{data:r,error:a,isLoading:i,hasNextPage:s,fetchNextPage:o}=Ye.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:`ranking=${n}`,getNextPageParam:l=>l!=null&&l.next?`${l==null?void 0:l.next}&ranking=${n}`:null});return{activities:ow(r),error:a,isLoading:i,hasNextPage:s,fetchNextPage:o}}function aw({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ye.useMutation({mutationFn:e,onMutate:({activityId:a})=>t(i=>sw(a,i)),onError:n});return r}function iw({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=Ye.useMutation({mutationFn:e,onMutate:({activityId:i})=>t(s=>{const o=Na(i,s);return o&&Qf({activity:o,user:r}),s}),onError:n});return a}function rc(e,t,n=!1){return t?(n?t.pages[0].results[0]=e:t.pages[0].results=[e,...t.pages[0].results],t):{pages:[{next:"",results:[e]}],pageParams:[""]}}function Na(e,t){if(t)for(const{results:n}of t.pages){const r=n.find(({id:a})=>a===e);if(r)return r}}function sw(e,t){for(const{results:n}of t.pages){const r=n.findIndex(({id:a})=>a===e);if(r!==-1){n.splice(r,1);break}}return t}function ow(e){var t;return((t=e==null?void 0:e.pages)==null?void 0:t.reduce((n,{results:r})=>[...n,...r],[]))||[]}const uw=({basePath:e,parentId:t,isMember:n,functions:{activities:r,mentions:a,join:i,leave:s}})=>{const o=Dm(Us.COMMUNITY_RANKING),l=ue.useIntl(),[u,c]=y.useState("recent"),[h,p]=y.useState([{id:"recent",label:"recent"},{id:"community_feed_live",label:"popular"}]),{activities:m,error:g,fetchNextPage:f,hasNextPage:D,isLoading:v,mutations:{create:E,edit:B,remove:x,like:k,unlike:T}}=tw({queryKey:[e,t,"activities",u],queryFns:r,rankingMethod:u});y.useEffect(()=>{o&&p(h.concat(o))},[o]);const[S,q]=y.useState(null),N=()=>{q(m.length),f()};return Xf(),g?d.jsx(un,{variant:"error",text:g.message}):d.jsxs("section",{children:[d.jsx(Bo,{isCard:!0,form:{content:{type:"post",slugs:{}},functions:{create:E,...a},meta:{isEditing:!1,isAutoFocused:!1,isPrepopulated:!1,showSuccessMessage:!1}},membershipRequiredToPost:{isMember:n,required:!0,join:i,leave:s,notMemberStateText:l.formatMessage({id:"community_joinToPost"})}}),d.jsx(ln,{className:"activities-feed-sorting-form",fields:[{id:"feed-sorting",label:l.formatMessage({id:"activitiesFeed_sorting_label"}),type:"select",options:h.map(({id:I,label:z})=>({id:I,label:l.formatMessage({id:`activitiesFeed_rankingMethod_${z}`})})),initialValue:u,functions:{onChange:I=>c(I)},gtm:{context:"Community Sorting",event:"community-sorting-click"}}],button:{hideButton:!0},functions:{onCatch:()=>{},onFailure:()=>{},onSuccess:async()=>{},onCancel:()=>{}},id:"activities-feed-sorting-form"}),m==null?void 0:m.map((I,z)=>{var W,_,A,L,$,U,re,te;const{id:w,own_reactions:F,latest_reactions:j,reaction_counts:M,mentioned_users:V}=I,G=(((W=j==null?void 0:j.like)==null?void 0:W.length)||0)>0,J=(((_=F==null?void 0:F.like)==null?void 0:_.length)||0)>0,ae=J?F==null?void 0:F.like[0].id:"",C=G?(A=j==null?void 0:j.like)==null?void 0:A.map(ne=>{var le,Q,pe;return{id:(le=ne==null?void 0:ne.user)==null?void 0:le.id,name:(pe=(Q=ne==null?void 0:ne.user)==null?void 0:Q.data)==null?void 0:pe.name}}):!1,R=I==null?void 0:I.actor;return d.jsx(y.Fragment,{children:d.jsx(qr,{content:{type:"post",title:I==null?void 0:I.title,body:I==null?void 0:I.content,canLike:n,createdAt:(I==null?void 0:I.time)||"",slugs:{question:`${e}/${t}`,answer:w},slug:w,author:{id:R==null?void 0:R.id,name:(L=R==null?void 0:R.data)==null?void 0:L.name,organization:($=R==null?void 0:R.data)==null?void 0:$.organization,jobTitle:(U=R==null?void 0:R.data)==null?void 0:U.jobTitle,location:(re=R==null?void 0:R.data)==null?void 0:re.location,image:{thumbnail:((te=R==null?void 0:R.data)==null?void 0:te.thumbnail)||void 0}},userLiked:J,likes:(M==null?void 0:M.like)||0,comments:(M==null?void 0:M.reply)||0,peopleWhoLiked:C,mentions:V},links:{post:`${e}/${t}/${w}`,comments:`${e}/${t}/${w}`},gtmContext:"community",functions:{content:{createContent:()=>null,deleteContent:()=>x({activityId:w}),updateContent:(ne,{body:le})=>B({activityId:w,content:le})},likes:{createLike:()=>k({activityId:w}),deleteLike:()=>T({activityId:w,reactionId:ae})},comments:{openComments:()=>null},mentions:a},isTruncated:!0,styling:{showShareLinkButton:!0},setFocus:z===S})},w)}),!v&&d.jsx($r,{hasNextPage:D,loadNextPage:N,icon:{icon:"arrow-down",position:"right"},messages:{button:l.formatMessage({id:"loadMore_button"}),error:l.formatMessage({id:"loadMore_error"})}})]})},lw={next:"id_lt=67ef0342-6f6e-4807-beea-5a9184ec140c&limit=5",results:[{created_at:"2023-12-03T18:47:44.081716Z",updated_at:"2023-12-03T18:47:44.081716Z",id:"256b921e-ffe6-410d-b754-ac1aaee989ce",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 17..."},parent:"",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:02.517688Z",updated_at:"2023-12-03T18:47:24.852582Z",id:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 16 (edited)..."},parent:"",latest_children:{reply:[{created_at:"2023-12-03T19:28:09.799652Z",updated_at:"2023-12-03T19:28:09.799652Z",id:"bf1ec451-e7c3-4ebe-a60e-248b0ec2a671",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 3..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:59.756761Z",updated_at:"2023-12-03T19:27:59.756761Z",id:"7887d921-e2ba-48ef-8089-db24536dbf70",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 2..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:46.534650Z",updated_at:"2023-12-03T19:27:46.534650Z",id:"73f5bdf3-7080-48ac-a8dc-185f71b38b42",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 1..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}}]},own_children:{reply:[{created_at:"2023-12-03T19:28:09.799652Z",updated_at:"2023-12-03T19:28:09.799652Z",id:"bf1ec451-e7c3-4ebe-a60e-248b0ec2a671",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 3..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:59.756761Z",updated_at:"2023-12-03T19:27:59.756761Z",id:"7887d921-e2ba-48ef-8089-db24536dbf70",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 2..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:46.534650Z",updated_at:"2023-12-03T19:27:46.534650Z",id:"73f5bdf3-7080-48ac-a8dc-185f71b38b42",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 1..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}}]},children_counts:{reply:3}},{created_at:"2023-12-03T17:47:45.107092Z",updated_at:"2023-12-03T17:47:45.107092Z",id:"27a59e8f-f094-442f-88ec-1d5ec2f72790",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 14..."},parent:"",latest_children:{reply:[{created_at:"2023-12-03T18:47:10.603929Z",updated_at:"2023-12-03T18:47:10.603929Z",id:"c32b83d5-c5fc-4253-8531-eb99dcb01f28",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 8..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:47:04.856649Z",updated_at:"2023-12-03T18:47:04.856649Z",id:"5efd80e3-cb11-4748-8c64-f46b71df69c4",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 7..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:22.687552Z",updated_at:"2023-12-03T18:36:22.687552Z",id:"a3a2ebae-6df2-4dc0-beee-2296188b67aa",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 6..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:16.129336Z",updated_at:"2023-12-03T18:36:16.129336Z",id:"72948da5-bf3c-4bd5-9a21-2cee36e0ce8a",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 5..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:40.850756Z",updated_at:"2023-12-03T17:56:40.850756Z",id:"81ebc855-d1f6-4a2c-a788-a251bae406b6",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 4..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:34.103420Z",updated_at:"2023-12-03T17:56:34.103420Z",id:"ddc28de7-4e89-4572-8122-c95dceacc2fd",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 3..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:26.410145Z",updated_at:"2023-12-03T17:56:26.410145Z",id:"916ed4b6-ad87-47bc-9e00-7b0c46180276",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 2..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:19.921740Z",updated_at:"2023-12-03T17:56:19.921740Z",id:"92cddcb2-cbdc-4e69-9c8e-5afe3a607411",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 1..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}}]},own_children:{reply:[{created_at:"2023-12-03T18:47:10.603929Z",updated_at:"2023-12-03T18:47:10.603929Z",id:"c32b83d5-c5fc-4253-8531-eb99dcb01f28",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 8..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:47:04.856649Z",updated_at:"2023-12-03T18:47:04.856649Z",id:"5efd80e3-cb11-4748-8c64-f46b71df69c4",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 7..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:22.687552Z",updated_at:"2023-12-03T18:36:22.687552Z",id:"a3a2ebae-6df2-4dc0-beee-2296188b67aa",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 6..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:16.129336Z",updated_at:"2023-12-03T18:36:16.129336Z",id:"72948da5-bf3c-4bd5-9a21-2cee36e0ce8a",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 5..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:40.850756Z",updated_at:"2023-12-03T17:56:40.850756Z",id:"81ebc855-d1f6-4a2c-a788-a251bae406b6",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 4..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}}]},children_counts:{reply:8}},{created_at:"2023-12-03T17:47:40.066170Z",updated_at:"2023-12-03T17:47:40.066170Z",id:"9ed6a1d0-00b5-4a03-94d7-ac01e188e2e2",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 13..."},parent:"",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:47:33.107894Z",updated_at:"2023-12-03T17:47:33.107894Z",id:"67ef0342-6f6e-4807-beea-5a9184ec140c",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 12..."},parent:"",latest_children:{},children_counts:{}}],duration:"6.48ms"};function cw({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a,user:i}){const{mutate:s}=Ye.useMutation({mutationFn:e,onMutate:o=>t(l=>{const u=ec({reply:Zx(o),user:i});return ac(u,l,{replace:!1,append:(o==null?void 0:o.replyId)!==void 0})}),onError:n,onSuccess:(o,l,u)=>{const c=ec({reply:o,user:i});r.setQueryData(a,ac(c,u,{replace:!0,append:(l==null?void 0:l.replyId)!==void 0})),setTimeout(()=>{Jf(c.id)},0)}});return s}function dw({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ye.useMutation({mutationFn:e,onMutate:({replyId:a,content:i})=>t(s=>{const o=Ra(a,s);return o&&(o.data.content=i),s}),onError:n});return r}function th({queryFns:{create:e,edit:t,like:n,list:r,remove:a,unlike:i},queryKey:s}){const o=Ye.useQueryClient(),l=Za(),u={queryClient:o,queryKey:s},c={mutationHandlers:{error:Fo(u),mutate:Ao(u)},user:l,...u},h=cw({...c,mutationFn:e}),p=dw({...c,mutationFn:t}),m=fw({...c,mutationFn:n}),g=mw({...c,mutationFn:a}),f=pw({...c,mutationFn:i}),{replies:D,...v}=hw({queryKey:s,queryFn:r});return{replies:D,mutations:{create:h,edit:p,remove:g,like:m,unlike:f},user:l,...v}}function fw({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=Ye.useMutation({mutationFn:e,onMutate:({replyId:s})=>t(o=>{const l=Ra(s,o);return l&&tc({reply:l}),o}),onError:n,onSuccess:(s,{replyId:o},l)=>{const u=Ra(o,l);u&&tc({reply:u,reaction:s}),r.setQueryData(a,l)}});return i}function hw({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}=Ye.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:{next:""},getNextPageParam:u=>(u==null?void 0:u.next)||null}),o=Dw(n),l=`${o.length||0}${i?"+":""}`;return{replies:o,repliesCount:l,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}}function mw({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ye.useMutation({mutationFn:e,onMutate:({replyId:a})=>t(i=>yw(a,i)),onError:n});return r}function pw({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=Ye.useMutation({mutationFn:e,onMutate:({replyId:i})=>t(s=>{const o=Ra(i,s);return o&&Yx({reply:o,user:r}),s}),onError:n});return a}function gw(e){return{pages:[{next:"",results:[e]}],pageParams:[""]}}function vw(e,t,n){const r=t.pages.length-1,a=t.pages[r].results.length-1;return n!=null&&n.replace?t.pages[r].results[a]=e:t.pages[r].results.push(e),t}function bw(e,t,n){return n!=null&&n.replace?t.pages[0].results[0]=e:t.pages[0].results=[e,...t.pages[0].results],t}function ac(e,t,n){return t?n!=null&&n.append?vw(e,t,n):bw(e,t,n):gw(e)}function Ra(e,t){if(t)for(const{results:n}of t.pages){const r=n.find(({id:a})=>a===e);if(r)return r}}function yw(e,t){for(const{results:n}of t.pages){const r=n.findIndex(({id:a})=>a===e);if(r!==-1){n.splice(r,1);break}}return t}function Dw(e){var t;return((t=e==null?void 0:e.pages)==null?void 0:t.reduce((n,r)=>[...n,...r==null?void 0:r.results],[]))||[]}const Cw=({basePath:e,parentId:t,activityId:n,replyId:r,isMember:a,functions:i})=>{const s=ue.useIntl(),o=3,{replies:l,fetchNextPage:u,hasNextPage:c,isLoading:h,mutations:{create:p,edit:m,like:g,remove:f,unlike:D},user:v}=th({queryKey:[e,t,n,r,"replies"],queryFns:{...i,list:x=>i.list({...x,reactionId:r})}});$s([h]);const[E,B]=y.useState(!0);return d.jsxs(d.Fragment,{children:[(l==null?void 0:l.length)>=o&&d.jsx(_e,{className:"nested-replies-show-toggle",variant:"secondary",size:"small",icon:{icon:`arrow_corner-${E?"up_left":"down_right"}`,position:"left"},onClick:()=>B(!E),children:s.formatMessage({id:`discussion_thread_${E?"hide":"show"}`},{count:l==null?void 0:l.length})}),E&&d.jsx(Zf,{loadMore:{isLoading:h,hasNextPage:c,loadNextPage:()=>u()},form:{content:{type:"reply",slugs:{question:`${e}/${t}`,answer:n,reply:r}},functions:{create:(x,{body:k})=>p({activityId:n,replyId:r,content:k}),listMembers:i.listMembers,clickMentionFallback:i.clickMentionFallback},meta:{isEditing:!1,isAutoFocused:!0,isPrepopulated:!1,showSuccessMessage:!1}},children:l&&l.length>0?l==null?void 0:l.map(x=>{var J,ae,C,R,W,_,A,L,$,U,re,te;const{id:k,own_children:T,latest_children:S,children_counts:q,data:{mentioned_users:N}}=x,z=(((J=T==null?void 0:T.like)==null?void 0:J.length)||0)>0?(ae=T==null?void 0:T.like)==null?void 0:ae.find(ne=>{var le;return((le=ne==null?void 0:ne.user)==null?void 0:le.id)===(v==null?void 0:v.id)}):!1,w=z?z==null?void 0:z.id:"",F=!!z,M=(((C=S==null?void 0:S.like)==null?void 0:C.length)||0)>0?(R=S==null?void 0:S.like)==null?void 0:R.map(ne=>{var le,Q,pe;return{id:(le=ne==null?void 0:ne.user)==null?void 0:le.id,name:(pe=(Q=ne==null?void 0:ne.user)==null?void 0:Q.data)==null?void 0:pe.name}}):!1,V=x==null?void 0:x.user,G=typeof x.data.content=="string"?(W=x==null?void 0:x.data)==null?void 0:W.content:((A=(_=x==null?void 0:x.data)==null?void 0:_.content)==null?void 0:A.text)||"";return d.jsx(qr,{isCommunity:!0,content:{id:k,type:"reply",body:G,canLike:a,createdAt:x==null?void 0:x.created_at,slugs:{question:`${e}/${t}`,answer:n,reply:x==null?void 0:x.parent},slug:"",author:{id:V==null?void 0:V.id,name:(L=V.data)==null?void 0:L.name,organization:($=V.data)==null?void 0:$.organization,jobTitle:(U=V.data)==null?void 0:U.jobTitle,location:(re=V.data)==null?void 0:re.location,image:{thumbnail:((te=V.data)==null?void 0:te.thumbnail)||void 0}},userLiked:F,likes:(q==null?void 0:q.like)||0,peopleWhoLiked:M,mentions:N},functions:{content:{createContent:()=>null,deleteContent:()=>f({replyId:k}),updateContent:(ne,{body:le})=>m({replyId:k,content:le})},likes:{createLike:()=>g({replyId:k}),deleteLike:()=>D({replyId:k,reactionId:w})},comments:{},mentions:{listMembers:i.listMembers,clickMentionFallback:i.clickMentionFallback}},styling:{showShareLinkButton:!0}},k)}):null})]})};const nh=({basePath:e,parentId:t,activityId:n,isMember:r,functions:{reactions:a,mentions:i,join:s,leave:o}})=>{const l=ue.useIntl(),{replies:u,repliesCount:c,fetchNextPage:h,hasNextPage:p,isLoading:m,mutations:{create:g,edit:f,like:D,remove:v,unlike:E},user:B}=th({queryKey:[e,t,n,"replies"],queryFns:a}),x=()=>{T(u.length),h()},[k,T]=y.useState(null);return $s([m]),Xf(),d.jsxs("section",{className:"replies-feed",children:[d.jsx(Kf,{type:"comment",responses:c,isLoading:m}),d.jsx(Bo,{form:{content:{type:"reply",slugs:{}},functions:{create:(S,{body:q})=>g({activityId:n,content:q}),...i},meta:{isEditing:!1,isAutoFocused:!1,isPrepopulated:!1,showSuccessMessage:!1},placeholder:l.formatMessage({id:"discussion_responses_placeholder"})},membershipRequiredToPost:{isMember:r,required:!0,join:s,leave:o,notMemberStateText:l.formatMessage({id:"community_joinToPost"})}}),u==null?void 0:u.map((S,q)=>{var W,_,A,L,$,U,re,te,ne,le,Q,pe;const{id:N,own_children:I,latest_children:z,children_counts:w,data:{mentioned_users:F}}=S,M=(((W=I==null?void 0:I.like)==null?void 0:W.length)||0)>0?(_=I==null?void 0:I.like)==null?void 0:_.find(he=>{var ye;return((ye=he==null?void 0:he.user)==null?void 0:ye.id)===(B==null?void 0:B.id)}):!1,V=M?M==null?void 0:M.id:"",G=!!M,ae=(((A=z==null?void 0:z.like)==null?void 0:A.length)||0)>0?(L=z==null?void 0:z.like)==null?void 0:L.map(he=>{var ye,Fe,Ae;return{id:(ye=he==null?void 0:he.user)==null?void 0:ye.id,name:(Ae=(Fe=he==null?void 0:he.user)==null?void 0:Fe.data)==null?void 0:Ae.name}}):!1,C=S==null?void 0:S.user,R=typeof S.data.content=="string"?($=S==null?void 0:S.data)==null?void 0:$.content:((re=(U=S==null?void 0:S.data)==null?void 0:U.content)==null?void 0:re.text)||"";return d.jsx(Hf,{children:d.jsx(qr,{isCommunity:!0,content:{id:N,type:"reply",body:R,canLike:r,createdAt:S==null?void 0:S.created_at,slugs:{question:`${e}/${t}`,answer:n,reply:N},slug:N,author:{id:C==null?void 0:C.id,name:(te=C.data)==null?void 0:te.name,organization:(ne=C.data)==null?void 0:ne.organization,jobTitle:(le=C.data)==null?void 0:le.jobTitle,location:(Q=C.data)==null?void 0:Q.location,image:{thumbnail:((pe=C.data)==null?void 0:pe.thumbnail)||void 0}},userLiked:G,likes:(w==null?void 0:w.like)||0,peopleWhoLiked:ae,mentions:F},functions:{content:{createContent:()=>null,deleteContent:()=>v({replyId:N}),updateContent:(he,{body:ye})=>f({replyId:N,content:ye})},likes:{createLike:()=>D({replyId:N}),deleteLike:()=>E({replyId:N,reactionId:V})},comments:{},mentions:i},children:d.jsx(Cw,{basePath:e,parentId:t,activityId:n,replyId:N,isMember:r,functions:{...a,...i}}),styling:{showShareLinkButton:!0},setFocus:q===k},N)},N)}),!m&&d.jsx($r,{hasNextPage:p,loadNextPage:x,icon:{icon:"arrow-down",position:"right"},messages:{button:l.formatMessage({id:"loadMore_button"}),error:l.formatMessage({id:"loadMore_error"})}})]})};function xw({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ye.useMutation({mutationFn:e,onMutate:({content:a,title:i})=>t(s=>(s&&(a!=null&&(s.content=a),i!=null&&(s.title=i)),s)),onError:n});return r}function ww({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:a,isFetching:i}=Ye.useQuery({queryFn:e,queryKey:t});return{activity:n,error:r,isLoading:a,isFetching:i}}function Ew({queryFns:{read:e,edit:t,like:n,unlike:r},queryKey:a}){const i=Ye.useQueryClient(),s=Za(),o={queryClient:i,queryKey:a},l={mutationHandlers:{error:Fo(o),mutate:Ao(o)},user:s,...o},u=xw({...l,mutationFn:t}),c=kw({...l,mutationFn:n}),h=_w({...l,mutationFn:r}),{activity:p,...m}=ww({queryKey:a,queryFn:e});return{activity:p,mutations:{edit:u,like:c,unlike:h},user:s,...m}}function kw({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=Ye.useMutation({mutationFn:e,onMutate:s=>t(o=>(o&&Pa({activity:o}),o)),onError:n,onSuccess:(s,o,l)=>{l&&Pa({activity:l,reaction:s}),r.setQueryData(a,l)}});return i}function _w({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=Ye.useMutation({mutationFn:e,onMutate:i=>t(s=>(s&&Qf({activity:s,user:r}),s)),onError:n});return a}const Bw=({basePath:e,parentId:t,activityId:n,isMember:r,functions:{activities:{remove:a,...i},reactions:s,mentions:o,join:l,leave:u}})=>{var N,I,z,w,F,j,M,V,G,J;const c=ue.useIntl(),{activity:h,error:p,isLoading:m,mutations:{edit:g,like:f,unlike:D}}=Ew({queryFns:i,queryKey:[e,t,n]});if(m)return d.jsx(kt,{style:{height:"400px"}});if(p||!h)return d.jsx(un,{variant:"error",text:c.formatMessage({id:"activitySection_notFoundError"})});const{own_reactions:v,latest_reactions:E,mentioned_users:B}=h,x=(((N=E==null?void 0:E.like)==null?void 0:N.length)||0)>0,k=(((I=v==null?void 0:v.like)==null?void 0:I.length)||0)>0,T=k?v==null?void 0:v.like[0].id:"",S=x?(z=E==null?void 0:E.like)==null?void 0:z.map(ae=>{var C,R,W;return{id:(C=ae==null?void 0:ae.user)==null?void 0:C.id,name:(W=(R=ae==null?void 0:ae.user)==null?void 0:R.data)==null?void 0:W.name}}):!1,q=h==null?void 0:h.actor;return d.jsxs("section",{className:"activity-section",children:[d.jsx(qr,{className:"highlighted-text-box subtle",isCommunity:!0,content:{id:n,type:"post",title:h==null?void 0:h.title,body:h==null?void 0:h.content,canLike:r,createdAt:(h==null?void 0:h.time)||"",slugs:{question:`${e}/${t}`,answer:h==null?void 0:h.id},slug:n,author:{id:q.id,name:(w=q.data)==null?void 0:w.name,organization:(F=q.data)==null?void 0:F.organization,jobTitle:(j=q.data)==null?void 0:j.jobTitle,location:(M=q.data)==null?void 0:M.location,image:{thumbnail:((V=q.data)==null?void 0:V.thumbnail)||void 0}},userLiked:k,likes:((G=h==null?void 0:h.reaction_counts)==null?void 0:G.like)||0,comments:((J=h==null?void 0:h.reaction_counts)==null?void 0:J.reply)||0,peopleWhoLiked:S,mentions:B},originalAuthorId:q==null?void 0:q.id,forceHide:{comments:!0},functions:{content:{createContent:()=>null,deleteContent:a,updateContent:(ae,{title:C,body:R})=>g({title:C,content:R})},likes:{createLike:()=>f({activityId:n}),deleteLike:()=>D({activityId:n,reactionId:T})},comments:{openComments:()=>{}},mentions:o},styling:{showShareLinkButton:!0}},n),d.jsx(nh,{basePath:e,parentId:t,activityId:n,isMember:r,functions:{reactions:s,mentions:o,join:l,leave:u}})]})};var Ns={exports:{}},sa={exports:{}},Re={};/** @license React v16.13.1
|
|
141
141
|
* react-is.production.min.js
|
|
142
142
|
*
|
|
143
143
|
* Copyright (c) Facebook, Inc. and its affiliates.
|