@apolitical/component-library 4.5.2 → 4.5.3-4658.1
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 +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -131,7 +131,7 @@ ${u}
|
|
|
131
131
|
`:""}`;case o[Y.paragraph]:return`${u}
|
|
132
132
|
|
|
133
133
|
`;case o[Y.hr]:return`---
|
|
134
|
-
`;default:return u}}function Nn(e,t){const n=e.trim(),r=n,a=`${t}${r}${Hl(t)}`;if(r.length===e.length)return a;const i=t+r+Hl(t);return e.replace(n,i)}const Hl=e=>e.split("").reverse().join(""),MC=e=>e.map(t=>Bf(t)).join("").trim();const IC=()=>{const e=An(),{dispatch:t,isInOverlay:n,mentionPopover:r,id:a}=D.useContext(Gt),{show:i,selectedUser:s,possibleUsers:o}=r,l=lf(e,"mention-popover",`toolbar-${a}`);if(!i||!o.length)return null;const u=_f(n);return c.jsx(Ha,{parent:u,children:c.jsx($c,{ref:l,className:"mention-popover",onKeyDown:d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),t([{type:"showMentionPopover",value:!1}]))},children:c.jsx("ul",{children:o.map(({userId:d,user:h},p)=>c.jsx(rr,{element:"li",className:G({selected:p===s}),member:{id:d,...h,link:!1},functions:{onClick:m=>{m.preventDefault(),m.stopPropagation();const g={...r,selectedUser:p};t([{type:"mentionPopover",value:g}]),kf(e,g,t,a)}}},d))})})})},Do=({id:e,active:t,hasDivider:n=!1,callback:r,className:a="",children:i,...s})=>{const o=ue.useIntl(),l=An(),{id:u,tabbableOption:d,setFocus:h,openTooltip:p,dispatch:m}=D.useContext(Gt),g={};return e!==d&&(g.tabIndex=-1),c.jsxs("li",{id:`${u}-${e}`,className:G(e,{"has-divider":n}),onMouseEnter:()=>{m([{type:"openTooltip",value:e}])},onMouseLeave:()=>{m([{type:"openTooltip",value:null}])},onFocus:()=>{m([{type:"openTooltip",value:e}])},onBlur:f=>{f.stopPropagation();const C=[{type:"openTooltip",value:null}];l.selection&&C.push({type:"lastAnchor",value:l.selection.anchor}),m(C)},contentEditable:!1,children:[c.jsxs("button",{...s,...g,className:G(e,a,{active:t}),onClick:f=>{f.stopPropagation(),f.preventDefault()},onMouseDown:f=>{f.stopPropagation(),f.preventDefault(),r()},onKeyDown:f=>{var C,v,w,_;if(f.key!=="Tab")switch(f.key){case"Enter":f.stopPropagation(),f.preventDefault(),r();break;case"ArrowLeft":case"ArrowRight":f.stopPropagation(),f.preventDefault();const E=f.currentTarget.closest("li");let x=E==null?void 0:E.nextElementSibling;if(f.key==="ArrowLeft"){const W=E==null?void 0:E.previousElementSibling;W?x=W:x=(C=E==null?void 0:E.parentElement)==null?void 0:C.lastElementChild}else x||(x=(v=E==null?void 0:E.parentElement)==null?void 0:v.firstElementChild);const T=x==null?void 0:x.className.split(" ")[0];T&&(h(T),(w=x==null?void 0:x.querySelector("button"))==null||w.focus());break;default:const S=f.currentTarget.closest("fieldset");if(S){(_=S==null?void 0:S.previousElementSibling)==null||_.focus();break}}},children:[c.jsx(Me,{showOnFocus:!1,children:o.formatMessage({id:`richTextEditor_${e}`})}),c.jsx(kn,{id:`tooltip-${e}`,styling:{extraPadding:!1,hasPointer:"bottom"},isOpen:p===e,"aria-hidden":!0,children:o.formatMessage({id:`richTextEditor_${e}`})})]}),i]})},Ul=[Y.ol,Y.ul],Af=(e,t)=>{const{selection:n}=e;if(!n)return!1;const[r]=Array.from(b.nodes(e,{at:b.unhangRange(e,n),match:a=>{const i=a;return!b.isEditor(a)&&ce.isElement(a)&&i.type===t}}));return!!r},$C=e=>{const[t]=b.nodes(e,{match:n=>n.type===Y.blockquote});return!!t},Ff=(e,t,n)=>{try{const r=$C(e),a=Af(e,t),i=Ul.includes(t);J.unwrapNodes(e,{match:l=>{const u=l;return!b.isEditor(u)&&ce.isElement(u)&&Ul.includes(u.type)},split:!0});const o={type:a?Y.paragraph:i?Y.li:t};if(J.setNodes(e,o),i)if(a){const{selection:l}=e;if(!l)return;const[u,d]=b.parent(e,l,{edge:"end"});Array.from(b.nodes(e,{at:d,match:p=>{const m=p;return!b.isEditor(p)&&ce.isElement(p)&&m.type===Y.li}})).forEach(([p,m])=>{oe.string(p).trim()===""&&J.removeNodes(e,{at:m})})}else{if(r){const u={type:Y.blockquote,children:[]};J.wrapNodes(e,u)}const l={type:t,children:[]};J.wrapNodes(e,l)}}catch(r){const a=r.message;n(`Error toggling block: ${a}`)}},LC=({format:e,hasDivider:t=!1})=>{const{setFocus:n,reportError:r}=D.useContext(Gt),a=An(),i=Af(a,e);return c.jsx(Do,{id:e,active:i,hasDivider:t,callback:()=>{Ff(a,e,r),n(i?null:e)}})},wr=e=>{const[t]=b.nodes(e,{match:n=>{const r=n;return!b.isEditor(n)&&ce.isElement(n)&&r.type===Y.link}});return!!t},zC=(e,t,n,r)=>{e.selection&&Co(e,t,n,r)},qC=(e,t,n,r)=>{const{selection:a}=e;if(a&&Z.isCollapsed(a)){const[s]=b.nodes(e,{match:o=>{const l=o;return!b.isEditor(o)&&ce.isElement(o)&&l.type===Y.link}});if(s){const[o,l]=s,u={link:t};J.setNodes(e,u,{at:l}),yo(n)}}else Co(e,t,n,r)},Co=(e,t,n,r=a=>{console.error(a)})=>{try{wr(e)&&Tf(e);const{selection:a}=e,i=a&&Z.isCollapsed(a),s={type:Y.link,link:t,children:i?[{text:t}]:[]};i?(J.insertNodes(e,s),J.move(e,{distance:1,unit:"offset"})):(J.wrapNodes(e,s,{split:!0}),J.collapse(e,{edge:"end"}),J.insertNodes(e,{text:""}),J.move(e,{distance:1,unit:"offset"})),yo(n)}catch(a){const i=a.message;r(`Error in wrapLink: ${i}`)}},Tf=e=>{J.unwrapNodes(e,{match:t=>{const n=t;return!b.isEditor(t)&&ce.isElement(t)&&n.type===Y.link}})};let Ii=null;const WC=()=>{const e=ue.useIntl(),t="richTextEditor_link_",{id:n,showLinkEditor:r,isInOverlay:a,dispatch:i,reportError:s}=D.useContext(Gt),o=An(),l=a1(o),u=(l==null?void 0:l.text)||OC(o),[d,h]=D.useState(wr(o)),p=lf(o,"link-editor",`${n}-link`),m=D.useRef(null);D.useEffect(()=>{var w;!d&&r&&((w=m.current)==null||w.focus())},[d]),D.useEffect(()=>{Ii&&clearTimeout(Ii),Ii=setTimeout(()=>{h(wr(o))},500)},[o.selection]);const g=[],f=["open","edit","remove"].map(w=>{const _={variant:"tertiary",size:"small",children:e.formatMessage({id:`${t}${w}`},{link:l==null?void 0:l.pretty})};switch(g.push({className:w}),w){case"open":_.href=(l==null?void 0:l.full)||"",_.onClick=E=>{E.preventDefault(),E.stopPropagation(),window.open((l==null?void 0:l.full)||"","_blank"),i([{type:"showLinkEditor",value:!1}])},_.children=c.jsxs(c.Fragment,{children:[_.children,c.jsx(Me,{children:e.formatMessage({id:`${t}${w}_text`})})]});break;case"edit":_.onClick=()=>{h(!1)};break;case"remove":_.onClick=()=>{const E=[{type:"showLinkEditor",value:!1}];wr(o)&&(Tf(o),E.push({type:"lastAnchor",value:null})),i(E)};break}return _}),C=[{id:"url",type:"url",inputRef:m,label:e.formatMessage({id:`${t}url`}),placeholder:e.formatMessage({id:`${t}placeholder`}),value:(l==null?void 0:l.full)||"",validation:[{condition:"required",error:e.formatMessage({id:`${t}error_required`})},{condition:"valid-url"}],submitOnEnter:!0,autoFocus:!0}];u&&C.unshift({component:()=>c.jsxs("p",{children:[c.jsx("strong",{"aria-label":e.formatMessage({id:`${t}text_aria`}),children:e.formatMessage({id:`${t}text`})})," ",u]})});const v=_f(a);return c.jsx(Ha,{parent:v,children:c.jsx(kn,{ref:p,id:`${n}-link-editor`,className:"link-editor",isOpen:r,styling:{extraPadding:!1,hasForm:!d},functions:{onBlur:()=>{i([{type:"showLinkEditor",value:!1}])}},callbacks:{onOpen:()=>{setTimeout(()=>{var w;return(w=m.current)==null?void 0:w.focus()})}},children:d?c.jsx(tr,{wrappers:g,buttons:f}):c.jsx(Bn,{element:"fieldset",id:`${n}-link-editor`,className:G({"show-labels":u}),meta:{shouldReset:!0,showRequiredLabels:!1},functions:{onSuccess:async w=>{setTimeout(()=>{const _=[{type:"showLinkEditor",value:!1}];if(w.url){const{full:E}=Ic(w.url);l!=null&&l.full?qC(o,E,n,s):zC(o,E,n,s),_.push({type:"lastAnchor",value:null})}i(_)})}},fields:C,button:{text:e.formatMessage({id:`${t}button`}),variant:"tertiary",size:"small"}})})})},HC=()=>{const e=An(),{setFocus:t,dispatch:n}=D.useContext(Gt),[r,a]=D.useState(!1);return D.useEffect(()=>{a(wr(e))},[e.selection]),c.jsx(Do,{id:"link",active:r,hasDivider:!0,callback:()=>{n([{type:"showLinkEditor",value:!0}]),t(r?null:"link"),a(!0)}})},UC=e=>[Y.bold,Y.italic,Y.strikethrough].includes(e),Sf=(e,t)=>{const n=b.marks(e);return n?n[t]===!0:!1},jf=(e,t,n)=>{try{Sf(e,t)?b.removeMark(e,t):b.addMark(e,t,!0)}catch(r){const a=r.message;n(`Error toggling mark: ${a}`)}},VC=({format:e,hasDivider:t=!1})=>{const{setFocus:n,reportError:r}=D.useContext(Gt),a=An(),i=Sf(a,e);return c.jsx(Do,{id:e,active:i,hasDivider:t,callback:()=>{jf(a,e,r),n(i?null:e)}})},Fa=[Y.bold,Y.italic,Y.strikethrough],KC=[Y.ol,Y.ul,Y.blockquote];const ZC=({...e})=>{const t=ue.useIntl(),{id:n}=D.useContext(Gt);return c.jsxs(c.Fragment,{children:[c.jsxs("fieldset",{id:`toolbar-${n}`,className:"toolbar",...e,children:[c.jsx(Me,{element:"legend",showOnFocus:!1,children:t.formatMessage({id:"richTextEditor_toolbar"})}),c.jsxs("ul",{children:[Fa.map((r,a)=>c.jsx(VC,{format:r,hasDivider:a===Fa.length-1},r)),c.jsx(HC,{}),KC.map((r,a)=>c.jsx(LC,{format:r,hasDivider:a===1},r))]})]}),c.jsx(WC,{})]})};var YC=XC,GC=/^(?:\w+:)?\/\/(\S+)$/,QC=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,JC=/^[^\s\.]+\.\S{2,}$/;function XC(e){if(typeof e!="string")return!1;var t=e.match(GC);if(!t)return!1;var n=t[1];return n?!!(QC.test(n)||JC.test(n)):!1}const ex=En(YC),tx=(e,t,n)=>{const{insertText:r,isInline:a}=e;try{e.isInline=i=>{const s=i;return[Y.link].includes(s.type)||a(i)},e.insertText=i=>{i&&ex(i)?Co(e,i,t):r(i)}}catch(i){const s=i.message;n(`Error in withInlines: ${s}`)}return e},nx=(e,t)=>{const{isInline:n,isVoid:r,markableVoid:a}=e;try{e.isInline=i=>i.type===Y.mention?!0:n(i),e.isVoid=i=>i.type===Y.mention?!0:r(i),e.markableVoid=i=>i.type===Y.mention||a(i)}catch(i){const s=i.message;t(`Error in withMentions: ${s}`)}return e},rx=(e,t)=>{const{normalizeNode:n}=e;try{e.normalizeNode=([r,a])=>{if(r.type===Y.link&&oe.string(r).trim()===""){J.removeNodes(e,{at:a});return}n([r,a])}}catch(r){const a=r.message;t(`Error in withoutEmptyLinks: ${a}`)}return e};const Of=({id:e="rich-text-editor",value:t,placeholder:n,maxLength:r=0,meta:a,functions:i,autoFocus:s,data:o,...l})=>{const u=ue.useIntl(),d=Ih();typeof s>"u"&&(s=!0);const{isInOverlay:h=!1}=a||{},{listMembers:p,onChange:m=()=>{},reportError:g=H=>{console.error(H)}}=i||{},f=[{type:Y.paragraph,children:[{text:""}]}];t==="<br>"&&(t="");const C={editorKey:null,originalValue:t||"",initialValue:t?null:f,tabbableOption:Fa[0],openTooltip:null,showLinkEditor:!1,mentionPopover:{show:!1,selectedUser:0,possibleUsers:[],position:null},lastAnchor:null,stringValue:"",lastKey:null,hasInteracted:!1,hasLoaded:!1},[v,w]=D.useReducer(Rr,C),{editorKey:_,originalValue:E,initialValue:x,stringValue:T,lastAnchor:S,lastKey:W,hasInteracted:O,hasLoaded:q,mentionPopover:I}=v,k=H=>{const y=H||Fa[0];H&&w([{type:"tabbableOption",value:y}])},A=`rte-${e}`,P=D.useCallback(H=>c.jsx(n1,{...H}),[]),$=D.useCallback(H=>c.jsx(r1,{...H}),[]),R=D.useMemo(()=>tx(nx(rx(Wv(e1(zv())),g),g),A,g),[]);D.useEffect(()=>{if(!t)return;_r.lastIndex=0;const H=t.match(_r);!H||H.length>1||H[0].length!==t.length||O||w([{type:"originalValue",value:t}])},[t]);const U=H=>{if(!R||H!==A)return;const y=b.end(R,[]);J.select(R,y),X.focus(R)};D.useEffect(()=>{const H=y=>{var B;const z=y,ee=((B=z==null?void 0:z.detail)==null?void 0:B.id)||null;ee&&U(ee)};return window.addEventListener("focusEditor",H),()=>{window.removeEventListener("focusEditor",H)}},[]),D.useEffect(()=>{if(R.children.length>0&&!q){if(w([{type:"hasLoaded",value:!0}]),!s)return;U(A)}},[R.children.length,x]),D.useEffect(()=>{E&&(async()=>{let y=gn(E);y.includes("<")&&(y=new xa().turndown(y)),o&&o.mentions&&(y=await Mc({text:y,template:`[${Bs}{{name}}]({{id}})`,mentions:o.mentions,listMembers:p||(()=>Promise.resolve([]))})),jC(y,z=>{w([{type:"initialValue",value:z},{type:"editorKey",value:E.toString()}]),setTimeout(()=>{w([{type:"stringValue",value:zl(R)}])},150)})})()},[E]),D.useEffect(()=>{t!==""||!R||as(E,t)&&!O||(b.withoutNormalizing(R,()=>{J.delete(R,{at:{anchor:b.start(R,[]),focus:b.end(R,[])}}),J.deselect(R),R.children.length!==0&&J.unwrapNodes(R,{at:[0]}),J.insertNodes(R,f,{at:[0]})}),w([{type:"initialValue",value:f},{type:"lastAnchor",value:null}]))},[t]);const se=Ec(()=>{NC(R,I.show,p,w)},100);return x?c.jsx("div",{id:A,className:"rich-text-editor",children:c.jsxs(Gt.Provider,{value:{...v,id:A,isInOverlay:h,setFocus:k,dispatch:w,reportError:g},children:[c.jsxs(Jy,{editor:R,initialValue:x,onChange:H=>{if(R.operations.some(z=>z.type!=="set_selection")){const z=MC(H);m(z),w([{type:"stringValue",value:zl(R)}]),O||w([{type:"hasInteracted",value:!0}]),se(),d&&console.log({serialized:z,json:H})}},...l,children:[c.jsx(Wy,{className:"input",renderElement:P,renderLeaf:$,placeholder:n||u.formatMessage({id:"richTextEditor_placeholder"}),autoFocus:s,tabIndex:0,onKeyDown:H=>{if(H.key==="Enter"){I.show&&(H.preventDefault(),H.stopPropagation(),kf(R,I,w,A));const{selection:y}=R;if(y){const z=Z.isCollapsed(y),[ee,B]=b.node(R,y,{depth:1});let F=ee,L=F.type;const M=F.children[0];if(M&&[Y.ol,Y.ul].includes(M.type)&&(F=M,L=M.type),F&&ce.isElement(F)&&L!==Y.paragraph){if(L===Y.blockquote&&!H.shiftKey){H.stopPropagation(),H.preventDefault(),J.insertNodes(R,f);return}if(z){const[V]=b.parent(R,y,{edge:"end"}),te=V.type;if(W==="Enter"&&te===Y.li&&[Y.ul,Y.ol].includes(L)){H.stopPropagation(),H.preventDefault(),J.insertNodes(R,f,{at:N.next(B)}),J.select(R,b.end(R,N.next(B)));return}}}}}else if(H.key==="Escape"){if(I.show){H.preventDefault(),H.stopPropagation(),w([{type:"mentionPopover",value:{...I,show:!1}}]);return}}else if(["ArrowUp","ArrowDown"].includes(H.key)&&I.show){H.preventDefault(),H.stopPropagation();const{selectedUser:y,possibleUsers:z}=I;let ee=H.key==="ArrowUp"?y-1:y+1;ee<0&&(ee=z.length-1),ee>=z.length&&(ee=0),w([{type:"mentionPopover",value:{...I,selectedUser:ee}}])}w([{type:"lastKey",value:H.key}]),PC(H,R,w,g)},onBlur:()=>{R.selection&&w([{type:"lastAnchor",value:R.selection.anchor}])},onFocus:()=>{if(S){if(!N.isPath(S.path)||!oe.has(R,S.path))return;const H=oe.get(R,S.path);let y=0;if(fe.isText(H)?y=H.text.length:H.children&&(y=H.children.length),S.offset>y)return;try{J.select(R,{anchor:S,focus:S})}catch(z){const ee=z.message;g(`Error focusing editor: ${ee}`)}}}}),c.jsx(ZC,{}),p?c.jsx(IC,{}):null]},_),c.jsx(Zs,{id:`character-limit-${e}`,limit:r,valueLength:Za(T)})]})}):null};const ax=({id:e="form-toggle",label:t,options:n,initialValue:r,functions:{onChange:a=()=>{}},isDisabled:i=!1,className:s=""})=>{const[o,l]=D.useState(typeof r=="boolean"||typeof r=="string"?r:n[0].value);D.useEffect(()=>{r&&l(r)},[r]);const u=d=>{i||(l(d),a(d))};return c.jsxs("div",{className:G("toggle",s),onClick:d=>{d.preventDefault(),d.stopPropagation(),u(o===n[0].value?n[1].value:n[0].value)},children:[c.jsx("p",{children:t}),c.jsx("ul",{className:G("toggle-options",{disabled:i,on:o===n[1].value}),children:n.map(d=>{const h=`${e}-${d.value}`;return c.jsxs("li",{className:"hidden",children:[c.jsx("input",{type:"radio",id:h,name:e,value:d.value,checked:o===d.value,onChange:()=>u(d.value),disabled:i}),c.jsx("label",{htmlFor:h,children:d.label})]},h)})})]})};function ix({className:e="",userId:t,userName:n,src:r,setUserImage:a,uploadImage:i}){const[s,o]=D.useState(!1),[l,u]=D.useState(!1),d=D.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 c.jsxs("div",{className:G("profile-image-change-figure",e),children:[c.jsx(Zt,{className:"profile-image-change-picture",name:n,src:r,"data-testid":"profile-picture"}),l&&c.jsx("p",{className:"error text-small",children:c.jsx(ue.FormattedMessage,{id:"profile_image_change_error"})}),c.jsx("input",{id:"file",type:"file",accept:"image/*",ref:d,onChange:h,hidden:!0,"data-testid":"file-input"}),c.jsx(Ae,{onClick:()=>d.current&&d.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:c.jsx(ue.FormattedMessage,{id:s?"profile_image_change_uploading_text":r?"profile_image_change_cta_with_picture":"profile_image_change_cta_without_picture"})})]})}const Pf=({gtm:e,functions:{onSuccess:t=async()=>{},onFailure:n=()=>{}}})=>{const{context:r="FooterContactUsForm",event:a="contact-form-submit-click"}=e||{};return c.jsx(Bn,{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 Nf=({title:e,label:t,ctaMessage:n,titleColor:r,labelColor:a,backgroundColor:i,onClose:s,reportError:o,sendInvites:l,initialFormStatus:u="NOT_SUBMITTED"})=>{const[d,h]=D.useState([]),[p,m]=D.useState(!0),[g,f]=D.useState(u),{formatMessage:C}=ue.useIntl(),v=async E=>{E.preventDefault();try{await l(d),h([]),f("SUCCESS")}catch(x){f("ERROR"),o(x)}},w=E=>{E.preventDefault(),f("NOT_SUBMITTED"),m(!0),h([])},_=E=>{E.preventDefault(),s(),f("CLOSED")};return g==="CLOSED"?null:g==="ERROR"||g==="SUCCESS"?c.jsxs("div",{className:"invite-form-wrapper",children:[c.jsx("div",{className:"content centred",children:g==="SUCCESS"?c.jsx("h2",{className:"success-title",children:C({id:"inviteForm_success"})}):c.jsxs("h2",{className:"error-title",children:[" ",C({id:"inviteForm_error"})]})}),c.jsx(Vt,{}),c.jsx("div",{className:"footer",children:g==="SUCCESS"?c.jsxs(c.Fragment,{children:[c.jsx(Ae,{variant:"secondary",onClick:w,children:C({id:"inviteForm_ctaSendMoreInvites"})}),c.jsx(Ae,{onClick:_,children:C({id:"inviteForm_ctaDone"})})]}):c.jsx(Ae,{onClick:w,children:C({id:"inviteForm_ctaTryAgain"})})})]}):c.jsx("div",{className:"invite-form-wrapper",children:c.jsxs("form",{style:{backgroundColor:i},onSubmit:v,className:G("invite-form gtm-trackable"),children:[c.jsxs("fieldset",{className:"content",children:[c.jsx("h2",{className:"title",style:{color:r},children:e}),c.jsx("label",{htmlFor:"email-input",className:"label",style:{color:a},children:t}),c.jsx(kh.ReactMultiEmail,{id:"email-input",inputClassName:"email-input input",placeholder:C({id:"inviteForm_email_placeholder"}),emails:d,onChange:E=>{h(E),m(!E.length)},autoFocus:!1,getLabel:(E,x,T)=>c.jsxs("div",{className:"email text-medium",children:[c.jsx("div",{"data-tag-item":!0,children:E}),c.jsx(Ae,{variant:"tertiary",size:"small",icon:{icon:"close"},onClick:()=>{T(x),m(!d.length)},className:"remove-email-button",screenreaderText:C({id:"overlay_close"})})]},x)})]}),c.jsx(Vt,{}),c.jsx("fieldset",{className:"footer",children:c.jsx(Ae,{className:"sendEmailsButton",disabled:p,children:n})})]})})},ba=e=>e.map(t=>({condition:t})),Dt={FORM_ID:"manage-account-password-change",NEW_PASSWORD:"newPassword",CONFIRMED_PASSWORD:"confirmedPassword",CURRENT_PASSWORD:"oldPassword"},sx=({functions:e,...t})=>{const{formatMessage:n}=ue.useIntl(),[r,a]=D.useState(null),[i,s]=D.useState(!1),[o,l]=D.useState({isMoreThanEightCharacters:!1,includesNumberAndSymbol:!1,includesLowerAndUppercase:!1}),u=m=>m[Dt.NEW_PASSWORD]!==m[Dt.CONFIRMED_PASSWORD]?n({id:"passwordRules_unmatched_text"}):null,d=m=>!us(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:ba(["required",d]),functions:{onChange:m=>l(us(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:ba(["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:ba(["required"])}),i&&h.push({component:ud,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 c.jsxs(c.Fragment,{children:[c.jsx(Bn,{...p}),r&&c.jsx(on,{variant:"error",text:r})]})};const Rf=({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=D.useRef(null);Vn(()=>{!n||o||!s||u.current&&u.current.focus()},[s]);const d=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 c.jsx("form",{onSubmit:d,className:G("search-form gtm-trackable",t),role:"search","data-gtm-event-context":a,"data-gtm-event-type":i,children:c.jsx("fieldset",{id:`${e}-form`,hidden:n?!s:!1,children:c.jsxs("p",{children:[c.jsx(Me,{element:"label",htmlFor:e,children:l.formatMessage({id:"search_label"})}),c.jsx("input",{ref:u,type:"search",id:e,name:e,defaultValue:r,placeholder:l.formatMessage({id:"search_placeholder"}),onKeyDown:h=>{h.key==="Enter"&&d(h)}}),c.jsx("button",{className:"clear",onClick:h=>{h.preventDefault(),h.stopPropagation(),u.current&&u.current.value&&(u.current.value="")},children:c.jsx(Me,{children:l.formatMessage({id:"search_clear"})})}),c.jsx("button",{className:"search",onClick:d,children:c.jsx(Me,{children:l.formatMessage({id:"search_cta"})})})]})})})},Vl=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 d="";return o?d=l?"gov":"nonGov":u.registration?u.engagement&&!u.user?d=u.auth?"verify":"pending":d="exists":u.auth&&(d="exists"),n([{type:"shouldDisableButton",value:!1},{type:"shouldManuallyApprove",value:!l},{type:"emailDetails",value:{email:a,boxType:d,isEnd2End:/testing\+[0-9]+@apolitical.co$/.test(a)}},{type:"validFields.email",value:!0}])},ox=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"]}},ux=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=ox(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}])},lx=({shouldShow:e,placeholders:t,labels:n,functions:{validateEmail:r,resendVerificationCode:a},refs:i,state:s,dispatch:o,dataToSubmit:l,intl:u})=>{const{emailDetails:d}=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:()=>{Vl({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:rd,props:{email:d.email,type:d.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=>c.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=>c.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=>c.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=>c.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"&&Vl({ref:i.email,validateEmail:r,dispatch:o}))}),g.length&&o(g)}},validation:[{condition:"required"}],"data-testid":"signup-terms-checkbox"}),p};const cx=({className:e=""})=>c.jsxs("div",{className:G("success-message",e),"data-testid":"success-message",children:[c.jsx("p",{className:"success-title",children:c.jsx(ue.FormattedMessage,{id:"signup_success_title"})}),c.jsx(ue.FormattedMessage,{id:"signup_success_text",values:{p:t=>c.jsx("p",{children:t})}})]});const dx={validFields:{name:!1,email:!1,jobTitle:!1,organisation:!1},emailDetails:{email:"",boxType:"",isEnd2End:!1},shouldManuallyApprove:!1,shouldDisableButton:!0,loadRecaptcha:!1,showSuccessMessage:!1,showError:!1},fx=({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:d=!1,url:h=!0,logInButton:p=!0,successMessage:m=!0}=a,g={title:u,expectation:d,url:h,logInButton:p,successMessage:m},[f,C]=D.useReducer(Rr,dx),{validFields:v,emailDetails:w,shouldManuallyApprove:_,shouldDisableButton:E,showSuccessMessage:x,showError:T}=f,[S,W]=Ms.useCookies(["signup-this-session","functional-cookie-consent"]),O={form:D.createRef(),name:D.createRef(),email:D.createRef(),jobTitle:D.createRef(),organisation:D.createRef(),tc:D.createRef(),hiddenValidation:D.createRef()};D.useEffect(()=>{_===!0&&O.jobTitle.current&&O.jobTitle.current.focus()},[_]),D.useEffect(()=>{S["signup-this-session"]&&C([{type:"showSuccessMessage",value:!0}])},[S]),D.useEffect(()=>{x&&S["functional-cookie-consent"]&&W("signup-this-session","true",{path:"/",maxAge:3600})},[x]);const q=D.useMemo(()=>lx({placeholders:n,labels:t,shouldShow:g,functions:r,refs:O,state:f,dispatch:C,dataToSubmit:s,intl:l}),[s,r,l,O,g,f]),I=E?!0:_?!Object.values(v).every(k=>k===!0):!v.name||!v.email||["exists","pending","verify"].includes(w.boxType);return g.successMessage&&x?c.jsx(cx,{className:e}):c.jsxs("fieldset",{className:G("signup-form-fieldset",e),"data-testid":"signup-form",children:[g.title&&c.jsx("p",{className:"signup-title",children:c.jsx(ue.FormattedMessage,{id:"signup_title"})}),T&&c.jsx(on,{variant:"error",text:l.formatMessage({id:"signup_error"})}),c.jsx(Bn,{className:"signup-form",formRef:O.form,id:"sign-up-form",fields:q,intlPath:"signup",button:{variant:"primary",size:"medium",text:i||l.formatMessage({id:"signup_button_join"}),disabled:I?{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 ux({refs:O,dataToSubmit:s,createAccount:r.createAccount,onSuccess:r.onSuccess,dispatch:C,state:f})},onCatch:k=>{r.handleError(k),C([{type:"showSuccessMessage",value:!1},{type:"showError",value:!0}])}}}),c.jsx("button",{className:"validation-button",ref:O.hiddenValidation})]})};const cn=({children:e,className:t="",styling:n={},...r})=>{const{background:a="default"}=n;return c.jsx("section",{className:G("full-width-section",t,{[a]:a!=="default"}),...r,children:e})};const hx=({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})}),c.jsx(cn,{className:G("download-section",n),children:c.jsxs("div",{className:"content-default",children:[D.createElement(typeof e=="string"?"h2":e.element,{className:"text"},typeof e=="string"?e:e.text),c.jsx(tr,{buttons:r})]})})};function Mf({href:e,setShowModal:t}){typeof e!="string"&&t(!0)}const mx=({icon:e,description:t,ctaMessage:n,href:r,showEditButton:a,setShowModal:i})=>{const{formatMessage:s}=ue.useIntl();return c.jsxs("div",{className:G("edit-section-placeholder",{"has-icon":!!e}),style:Pc(e),children:[c.jsx("p",{children:t||s({id:"edit_section_placeholder_description"})}),a&&c.jsx(Ae,{href:r,variant:"secondary",size:"small",onClick:()=>Mf({href:r,setShowModal:i}),children:n||s({id:"edit_section_placeholder_cta"})})]})},px=({children:e,className:t="",formProps:n,href:r,title:a,modalTitle:i,placeholder:s,showDivider:o=!0})=>{const[l,u]=D.useState(!1),d=typeof r=="string"||!!n,h=()=>u(!1);return c.jsxs("section",{className:G("edit-section",t),children:[n&&c.jsx(ir,{title:i||`Edit ${a}`,isOpen:l,showDivider:!1,showIcon:!1,functions:{onClose:h},className:G("edit-section-modal"),children:c.jsx(Bn,{...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}})}),c.jsxs("div",{className:"edit-section-header",children:[c.jsx("h2",{className:"edit-section-header-title",children:a}),d&&c.jsx(Ae,{href:r,variant:"tertiary",size:"small",icon:"pencil",onClick:()=>Mf({href:r,setShowModal:u}),children:"Edit"})]}),e||c.jsx(mx,{...s,href:r,setShowModal:u,showEditButton:d}),o&&c.jsx(Vt,{})]})};const gx=({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 c.jsxs("div",{className:G("logos",a,`align-${l}`,{[u]:u!=="block","wrap-logos":o}),children:[e&&D.createElement(s.element,{className:G("title",s.className)},s.text),t&&c.jsx("p",{children:t}),c.jsx("ul",{className:G({"two-col":i===2||i===4,"three-col":i===5||i<=10&&i%3===0}),children:n.map(({logo:d,nameOfBusiness:h,link:p=!1,description:m=!1},g)=>{if(!d||!d.url)return null;const f=c.jsx("img",{src:d.url,width:d.width||"auto",height:d.height||"auto",alt:h});return c.jsxs("li",{children:[c.jsx("p",{className:"img-wrapper",children:p?c.jsx("a",{href:p,target:"_blank",rel:"nofollow noreferrer noopener",children:f}):f}),m&&c.jsx("small",{children:m})]},window.btoa(`${d.url}_${g}`))})})]})};let $i;const Li="contactFooter_",vx=({onSuccess:e=async()=>{},onFailure:t=()=>{}})=>{const n=D.useRef(null),[r,a]=D.useState(0),[i,s]=D.useState(!1),o=()=>{n.current&&a(n.current.clientHeight)},l=()=>{i||(s(!0),clearTimeout($i),$i=setTimeout(()=>{o(),s(!1)},500))};return D.useEffect(()=>(o(),window.addEventListener("resize",l),()=>{clearTimeout($i),window.removeEventListener("resize",l)}),[]),c.jsx(cn,{id:"contactForm",className:"contact-footer",children:c.jsxs("div",{className:"inner-wrapper",children:[c.jsx("h2",{children:c.jsx(ue.FormattedMessage,{id:`${Li}title`})}),c.jsxs("div",{className:"content-wrapper",ref:n,"data-testid":"content-wrapper",style:i?{}:{minHeight:r},children:[c.jsxs("aside",{children:[c.jsx("p",{children:c.jsx(ue.FormattedMessage,{id:`${Li}text`})}),c.jsx(_n,{className:"mailto-link",href:"mailto:hello@apolitical.co",children:c.jsx(ue.FormattedMessage,{id:`${Li}email`})})]}),c.jsx(Pf,{functions:{onSuccess:e,onFailure:t},gtm:{context:"FooterContactUsForm",event:"contact-form-submit-click"}})]})]})})},bx=({activeLink:e,...t})=>c.jsx(cn,{children:c.jsx(td,{layout:"1-3",children:c.jsxs(c.Fragment,{children:[c.jsx(ed,{activeLink:e}),c.jsx(Hc,{...t})]})})});const zi="cookieBanner_",qi=["apol-cookie-banner","apolitical-performance-cookie-consent","functional-cookie-consent"],Wi=new Date(Date.now()+12*30*24*60*60*1e3),If=()=>{const e=ue.useIntl(),[t,n,r]=Ms.useCookies(qi),[a,i]=D.useState(!t["apol-cookie-banner"]),s=()=>{qi.forEach(d=>{n(d,!0,{path:"/",expires:Wi,domain:d==="apolitical-performance-cookie-consent"?".apolitical.co":void 0})}),i(!1),window.location.reload()},o=()=>{n("apol-cookie-banner",!0,{path:"/",expires:Wi}),qi.forEach(d=>{if(d==="apol-cookie-banner"){n(d,!0,{path:"/",expires:Wi});return}r(d)}),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(d=>{u.push({variant:d.href?"tertiary":"primary",href:d.href,onClick:d.onClick,className:"gtm-trackable","data-gtm-event-context":"cookie-banner","data-gtm-event-type":`cookie-${d.gtmType}-click`,children:e.formatMessage({id:`${zi}buttons_${d.id}`})})}),c.jsxs("aside",{id:"cookie-banner",className:"text-medium",children:[c.jsx("h6",{children:e.formatMessage({id:`${zi}title`})}),c.jsx("p",{children:e.formatMessage({id:`${zi}text`})}),c.jsx(tr,{buttons:u})]})},Wt={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:Rn["data-protection"].default,gtmType:"email-dpo-link"},euDataProtection:{email:Rn["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:Rn.support,gtmType:"concierge-email-click"},business:{email:Rn.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 qn="footer_",Ta="SiteFooter",Kl=({group:e})=>{const t=Wt[e].order||[];let n=!1;return"text"in Wt[e]&&(n=Wt[e].text),c.jsxs(D.Fragment,{children:[c.jsx("p",{className:"pre-title",children:c.jsx(ue.FormattedMessage,{id:`${qn}${e}`})}),Array.isArray(t)&&t.length>0&&c.jsx("ul",{className:"text-medium",children:t.map(r=>{if(["order","child","text"].includes(r))return null;const{href:a,gtmType:i}=Wt[e][r],s={};return["legal"].includes(e)&&(s.target="_blank",s.rel="noopener"),c.jsx("li",{children:c.jsx("a",{href:a,className:"gtm-trackable","data-gtm-event-context":Ta,"data-gtm-event-type":i,...s,children:c.jsx(ue.FormattedMessage,{id:`${qn}${e}_${r}`})})},`${e}_${r}`)})}),typeof n!="boolean"&&"order"in n&&Array.isArray(n.order)&&c.jsx("dl",{className:"text-medium",children:n.order.map(r=>c.jsxs(D.Fragment,{children:[c.jsx("dt",{children:c.jsx(ue.FormattedMessage,{id:`${qn}${e}_${r}`})}),c.jsxs("dd",{children:[typeof n!="boolean"&&n[r].address&&c.jsx("address",{children:c.jsx(ue.FormattedMessage,{id:`${qn}${e}_${r}_address`,values:{br:c.jsx("br",{})}})}),typeof n!="boolean"&&n[r].email&&c.jsx("a",{href:`mailto:${n[r].email}`,className:"gtm-trackable","data-gtm-event-context":Ta,"data-gtm-event-type":n[r].gtmType,children:n[r].email})]})]},`dl-${e}-${r}`))})]},e)},xo=()=>c.jsx("div",{id:"footer",children:c.jsxs("div",{className:"wrapper",children:[c.jsx(qa,{element:"hr"}),c.jsx(Ks,{variant:"inverted",version:"full",className:"gtm-trackable","data-gtm-event-context":Ta,"data-gtm-event-type":"logo-homepage-link"}),c.jsx("footer",{children:["platform","community","company","contact"].map(e=>c.jsxs("div",{className:"group",children:[c.jsx(Kl,{group:e}),Object.keys(Wt[e]).includes("child")&&c.jsx(Kl,{group:Wt[e].child})]},e))}),c.jsx("hr",{}),c.jsxs("div",{className:"sub-footer",children:[c.jsx("ul",{children:Array.isArray(Wt.social.order)&&Wt.social.order.map(e=>{const t=Wt.social[e];return c.jsx("li",{className:e,children:c.jsx("a",{href:t.href,target:"_blank",rel:"noopener noreferrer",className:"gtm-trackable","data-gtm-event-context":Ta,"data-gtm-event-type":"social-click",children:c.jsx("span",{className:"hidden",children:c.jsx(ue.FormattedMessage,{id:`${qn}social_${e}`})})})},e)})}),c.jsx("small",{children:c.jsx(ue.FormattedMessage,{id:`${qn}copyright`,values:{currentYear:new Date().getFullYear()}})})]})]})}),Ie={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&&Ie.handlerCalled[e]&&i-Ie.handlerCalled[e]<500)return;Ie.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=Dc(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?Ie.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=Ie.findFirstChild(t.current.children,"attributes.aria-controls",gt.SITE);s=Ie.findFirstChild(u.children,"href")}else s=Ie.findFirstChild(t.current.children,"href");break;case gt.ACCOUNT:if(o=Ie.findFirstChild(t.current.children,"className","account"),!o||!o.children)return;s=Ie.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(Ie.timeouts[t]),n(t,!r))},onFocus:({id:e})=>{clearTimeout(Ie.timeouts[e])},onMouseEnter:({id:e,callback:t})=>{clearTimeout(Ie.timeouts[e]),t(e,!0)},onBlur:({id:e,callback:t})=>{Ie.timeouts[e]=setTimeout(()=>{t(e,!1)},250)}}},Nr={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"}}}},Sa=({id:e,isLoggedIn:t=!1,isDesktopVersion:n=!1,menus:r={},callback:a=()=>{},doTrack:i=null})=>{const s=ue.useIntl(),o=Dc(Nr,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,d=e.includes("buttons.");let h=`header_${e.replaceAll(".","_")}`;o.hasVariantText&&(h+=`_logged${t?"In":"Out"}`);let p=!1;if(o.href){let _=o.gtmType||`${e}-click`;if(_.includes(".")){const E=_.split("."),x=E[E.length-2];_=`${x==="topics"?`${x}-`:""}${E[E.length-1]}`}p={href:o.href},u&&(p={...p,className:"gtm-trackable","data-gtm-event-type":_,"data-gtm-event-context":"HeaderButtons"}),d&&(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 C={},v={},w={};if(f&&(C={...C,"aria-current":"page"}),m){const _=o.menuId||e,E={onClick:x=>Ie.events.onClick(x,{id:_,callback:a,isOpen:r[_]}),onFocus:()=>Ie.events.onFocus({id:_}),onBlur:()=>Ie.events.onBlur({id:_,callback:a}),onMouseLeave:()=>Ie.events.onBlur({id:_,callback:a}),onMouseEnter:()=>Ie.events.onMouseEnter({id:_,callback:a})};v={...E,id:_===gt.SITE?gt.SITE:gt.ACCOUNT},n&&(g&&(w={...E,className:"navigation-button",onKeyPress:x=>{x.key==="Enter"&&Ie.events.onClick(x,{id:_,callback:a,isOpen:r[_]})},"aria-haspopup":!0,"aria-expanded":r[_],"aria-controls":_}),v={...v,hidden:_ in r?!r[_]:!0}),g||(v={...v})}return c.jsxs("li",{className:G({[o.className]:o.className,"has-submenu":m,parent:g,active:f}),...C,children:[p?D.createElement(d?Ae:"a",p,s.formatMessage({id:h})):n&&o.order&&g?c.jsxs("button",{...w,children:[s.formatMessage({id:h}),c.jsx(Me,{children:s.formatMessage({id:`header_menu_${r[gt.SITE]?"hide":"show"}`})})]}):s.formatMessage({id:h}),o.order&&c.jsx("ul",{...v,children:o.order.map(_=>{if(!o[_])return null;const E={isLoggedIn:t,isDesktopVersion:n,menus:r,callback:a,doTrack:l?u:null};return o[_].order?c.jsxs("li",{className:G({[o[_].className]:o[_].className}),children:[s.formatMessage({id:`${h}_${_}`}),c.jsx("ul",{children:o[_].order.map(x=>c.jsx(Sa,{id:`${e}.${_}.${x}`,...E},x))})]},_):c.jsx(Sa,{id:`${e}.${_}`,...E},_)})})]},e)};const yx={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 wo=({showNavigation:e=!0})=>{const t=ue.useIntl(),n=D.useContext(It),r=Xn(!0,!0),a=n&&typeof n.id=="string",i=D.useMemo(()=>Ie.getIsDesktopVersion(a,r),[a,r]),[s,o]=D.useReducer(Rr,{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:d}=s,h=D.useRef(s);D.useEffect(()=>{h.current=s},[s]),_c({scrollPosition:yx[`height${i.navigation?"_desktop":""}`],callbacks:{scrollUp:()=>{const v=h.current.menus;!i&&v["site-navigation"]||Ie.shouldChangeHeaderIsVisible(!0,v,o)},scrollDown:()=>{const v=h.current.menus;!i&&v["site-navigation"]||Ie.shouldChangeHeaderIsVisible(!1,v,o)}}});const p=(v,w,_=!1)=>{Ie.handleMenus({id:v,value:w,menus:h.current.menus,dispatch:o,forceHandle:_})},m=D.useRef(null),g=v=>{v.key==="Escape"&&["site-navigation","search","account-navigation"].forEach(w=>{h.current.menus[w]&&p(w,!1,!0)})};D.useEffect(()=>{var v;return(v=document.getElementById("header"))==null||v.addEventListener("keydown",g),()=>{var w;(w=document.getElementById("header"))==null||w.removeEventListener("keydown",g)}},[]),Vn(()=>{u["site-navigation"]&&Ie.autoFocus({menu:"site-navigation",navigationRef:m,isDesktopVersion:i.navigation,focusElements:d,dispatch:o})},[u["site-navigation"]]),Vn(()=>{u["account-navigation"]&&Ie.autoFocus({menu:"account-navigation",navigationRef:m,isDesktopVersion:i.navigation,focusElements:d,dispatch:o})},[u["account-navigation"]]);const f=c.jsxs(c.Fragment,{children:[!i.search&&c.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:c.jsx(Me,{children:t.formatMessage({id:`header_search_${u.search?"hide":"show"}`})})}),c.jsx(Rf,{id:"global-search",handleToggle:{searchIsOpen:u.search,isDesktopVersion:i.search},gtmContext:"search-bar-header",gtmEvent:"form-submission"})]}),C=c.jsxs(c.Fragment,{children:[!i.navigation&&c.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:c.jsx(Me,{children:t.formatMessage({id:`header_menu_${u["site-navigation"]?"hide":"show"}`})})}),c.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:Nr.order.map(v=>c.jsx(Sa,{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:c.jsxs(c.Fragment,{children:[c.jsxs("nav",{id:"header",className:G({"logged-in":a,"logged-out":!a,visible:l}),children:[c.jsx(Me,{element:"a",href:"#content-of-page",children:t.formatMessage({id:"header_skip"})}),c.jsx(Ks,{variant:"monochrome"}),e&&c.jsxs(c.Fragment,{children:[i.navigation?c.jsxs(c.Fragment,{children:[C,f]}):c.jsxs(c.Fragment,{children:[f,C]}),a?c.jsxs("button",{className:"account-button",onClick:v=>Ie.events.onClick(v,{id:"account-navigation",callback:p,isOpen:u["account-navigation"]}),onMouseEnter:()=>Ie.events.onMouseEnter({id:"account-navigation",callback:p}),onMouseLeave:()=>Ie.events.onBlur({id:"account-navigation",callback:p}),"aria-haspopup":"true","aria-expanded":u["account-navigation"],"aria-controls":"account-navigation",children:[c.jsx(Me,{children:t.formatMessage({id:`header_account_${u["account-navigation"]?"hide":"show"}`})}),c.jsx(Zt,{name:n&&n.name||"",src:n&&n.image&&n.image.thumbnail||""})]}):c.jsx("ul",{className:"sign-in-buttons",children:Nr.buttons.order.map(v=>c.jsx(Sa,{id:`buttons.${v}`},v))})]})]}),c.jsx("hr",{id:"content-of-page"}),c.jsx("div",{className:G("overlay",{open:u["site-navigation"]||u["account-navigation"]||!i.search&&u.search})})]})};const Dx=()=>{const e=ue.useIntl();return c.jsxs(c.Fragment,{children:[c.jsx(wo,{}),c.jsx("div",{id:"content",children:c.jsx(on,{variant:"error",text:e.formatMessage({id:"pageLayout_error"})})}),c.jsx(xo,{})]})},$f=({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:d="default",variant:h="default",circle:p="default",modal:m="default"}=i,g=wc(),[f,C]=D.useState(""),v=T=>{const{detail:{message:S}}=T;C(S)};D.useEffect(()=>(window.scrollTo(0,0),document.addEventListener("ariaLive",v),()=>{document.removeEventListener("ariaLive",v)}),[g]);const w=ca(e,{locale:o}),_=ca(t,{locale:o}),E=ca(n,{locale:o}),x={};return d!=="default"&&(x[d]=!0),h!=="default"&&(x[h]=!0),p!=="default"&&(x[p]=!0),c.jsx(_h.ErrorBoundary,{onError:r,fallback:c.jsx(Dx,{}),children:c.jsxs(D.Suspense,{fallback:null,children:[c.jsxs("div",{id:"wrapper",className:G(s,x,{"has-footer":u}),children:[c.jsx(wo,{showNavigation:l}),c.jsxs("main",{id:"content-wrapper",children:[_&&c.jsx("div",{className:G("additional-content prepended",{"large-modal":m==="large"}),children:_}),D.createElement(d==="bold"?Fo:"div",{id:"content",children:w,className:G({"large-modal":m==="large"})})]}),E&&c.jsx("div",{className:"additional-content appended",children:E}),u&&c.jsx(xo,{}),c.jsx(If,{})]}),f&&c.jsx(Me,{"aria-live":"polite",showOnFocus:!1,"data-testid":"layout-aria-live",children:f})]})})},Zl={default:"tags_",headerTopics:"header_topics_topics_"},Hi={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"},Cx={getTagDetails:e=>{if(e.includes("topic_")){if(e=Hi.topic[e.replace("topic_","")],e){const t=Nr.topics.topics[e].href;return t?{id:e,href:t,text:`${Zl.headerTopics}${e}`}:null}return null}return Hi[e]?(e=Hi[e],{id:e,text:`${Zl.default}${e}`}):null}};const xx=({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 d=Cx.getTagDetails(u);d&&l.push(d)}),l.length<1?null:c.jsx("ul",{className:G("tags text-small",t,a,{"one-line":n}),children:l.map(u=>{const d=o.formatMessage({id:u.text});return c.jsx("li",{children:u.href&&r?c.jsx("a",{href:u.href,className:"gtm-trackable","data-gtm-event-type":i,"data-gtm-event-context":s,children:d}):d},u.id)})})};const wx=({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:c.jsxs("div",{className:G("members-list",s),children:[c.jsxs("h1",{children:[o.formatMessage({id:"membersList"}),c.jsx("span",{className:"count",children:t})]}),c.jsx("ul",{children:e.map((l,u)=>c.jsxs("li",{children:[c.jsx(rr,{member:l,gtmContext:a,gtmType:i}),l.isAdmin&&c.jsx(mn,{children:o.formatMessage({id:"membersList_admin"})})]},u))}),n&&c.jsx(Mr,{hasNextPage:n,loadNextPage:r,icon:{icon:"arrow-down",position:"right"},gtmContext:a})]})};const Ex=D.lazy(()=>Promise.resolve().then(()=>yE)),Lf=({forceShow:e,form:t,className:n})=>{const r=ue.useIntl(),i=D.useContext(It)||"community",s=Va(i);s.name||(s.name=r.formatMessage({id:`member_${typeof i=="string"?i:"community"}`}));const{modal:o=!1}=e||{},[l,u]=D.useState(o||Uh("showPost")==="true"||!1);return c.jsxs(c.Fragment,{children:[c.jsxs("button",{className:G("discussion-form-card",n),onClick:d=>{d.preventDefault(),d.stopPropagation(),u(!0)},"data-testid":"discussion-form-card",children:[c.jsx(Zt,{name:s.name,src:s.image,alt:""}),c.jsx("span",{className:"input",children:r.formatMessage({id:"discussionFormCard_placeholder"})})]}),c.jsx(Ha,{children:c.jsx(Ex,{showModal:l,onClose:()=>{u(!1)},form:t,className:"in-portal"})})]})},kx=D.lazy(()=>Promise.resolve().then(()=>Fx)),Eo=({isCard:e=!1,form:t,membershipRequiredToPost:{isMember:n,required:r,join:a,leave:i,notMemberStateText:s}})=>{if(r&&!n)return c.jsx(on,{text:s,button:{breakpoints:{mobile:!0,901:!1},component:c.jsx(Vs,{isShort:!0,functions:{join:a,leave:i}})}});const{content:o,functions:l,meta:u,...d}=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},...d,id:`add-post-${d.id||""}`};return e?c.jsx(Lf,{form:h}):c.jsx(kx,{...h})},_x={showForm:!1},ni=D.createContext(_x),zf=({children:e})=>{const[t,n]=D.useState({showForm:!1});return c.jsx(ni.Provider,{value:{...t,updateConversation:n},children:e})},Bx=({intlPath:e,showGuidelines:t,type:n,gtmContext:r})=>{const a=ue.useIntl();return t?c.jsx("small",{children:_t(a.formatMessage,`${e}explainer`,n,"action",{a:i=>c.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})})}):c.jsx(c.Fragment,{})},Ax=({formID:e,intlPath:t,showLabel:n,type:r})=>{const a=ue.useIntl();return n?c.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`})}):c.jsx(Me,{element:"label",showOnFocus:!1,htmlFor:`${e}-input`,children:_t(a.formatMessage,`${t}label_action`,r,"action")})};let ra=null;const Je="discussion_form_",$r=({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:d={},gtmContext:h="DiscussionForm"})=>{var be,he,Ee;const p=ue.useIntl(),m=D.useContext(It),[g,f]=D.useState(""),{isLoading:C=!1,isInWrapper:v=!1,isInOverlay:w=!1,isAutoFocused:_=!1,isEditing:E=!1,hasTitleField:x=!1,isPrepopulated:T=!1,showTitle:S=!1,showGuidelines:W=!0,showDivider:O=!1,showSuccessMessage:q=!0}=r||{},{create:I=()=>{},handleSaveEdit:k=()=>{},handleCancel:A=()=>{},callback:P=()=>{},listMembers:$=()=>Promise.resolve([]),props:R={create:{projectNames:["questions-answers"]}}}=u,[U,se]=D.useState({title:x&&x.text||"",body:E&&E.text||T&&T.text||""}),[H,y]=D.useState(o.error||!1),[z,ee]=D.useState(!1);if(D.useEffect(()=>{l&&!E&&T&&T!==U.body&&se({...U,body:T.text||""})},[T]),C)return c.jsx(Et,{className:"discussion-card discussion-form","data-testid":"loading-placeholder"});const B=ke=>{se({...U,body:ke});let De;!m||!m.id?De=_t(p.formatMessage,`${Je}error_loggedOut`,t.type,"action"):n?i>0&&ke.length>=i&&(De=`${Je}error_tooLong`):De=_t(p.formatMessage,`${Je}error_noPermission`,t.type,"action"),De?y(De):H&&y(!1)};let F=`${t.type}-form`;if(t.type==="response"||t.type==="reply"){const ke=((be=t.slugs)==null?void 0:be.reply)||((he=t.slugs)==null?void 0:he.answer)||((Ee=t.slugs)==null?void 0:Ee.question)||"";ke&&(F=`${F}-${ke.slice(-15)}`)}e&&(F=`${e}-${F}`);const L=async()=>{if(!m||!m.id||!n||te)return;ra&&clearTimeout(ra),ee("submitting");const ke=window.location.pathname;try{let De;switch(t.type){case"post":De=await I({title:U.title,content:U.body});break;case"question":De=await I({title:U.body,authorId:m&&m.id,...R==null?void 0:R.create});break;case"response":De=await I({questionSlug:t.slugs.question},{body:U.body,authorId:m&&m.id,contentPath:ke});break;case"reply":De=await I({questionSlug:t.slugs.question,answerSlug:t.slugs.answer},{body:U.body,authorId:m&&m.id,contentPath:ke});break;default:break}await Mh(1e3),P&&await P(De),ra=setTimeout(()=>{se({title:"",body:""}),ee("submitted"),f(_t(p.formatMessage,`${Je}success`,t.type,"action"));const je=new Event("discussionFormSubmitted");document.dispatchEvent(je),M()},500)}catch(De){const je=De;let Le=`${Je}error`;je!=null&&je.message.includes("entry already exists")&&(Le=_t(p.formatMessage,`${Je}error_alreadyExists`,t.type,"action")),je!=null&&je.message.includes("429")?Le=_t(p.formatMessage,`${Je}error_tooMany`,t.type,"action"):je!=null&&je.message.includes("400")&&(Le=`${Je}error`),y(Le),M()}},M=()=>{ra=setTimeout(()=>{y(!1),ee(!1),f("")},5e3)},V=!U.title||!Lo(U.title),ne=!U.body||!Lo(U.body);let te=ne;x&&(te=V&&ne);const re=z==="submitting",de=[{component:Ax,props:{formID:F,intlPath:Je,showLabel:x!==!1,type:t.type}},{component:Of,props:{id:`${F}-input`,value:z==="submitting"&&!H?"":U.body,placeholder:a||_t(p.formatMessage,`${Je}placeholder`,t.type,"action"),maxLength:i,meta:{isInOverlay:w},functions:{onChange:B,listMembers:$},data:d,autoFocus:E!==!1||_&&!x,"aria-invalid":!!H,"aria-errormessage":"error-message"}},{component:Bx,props:{intlPath:Je,showGuidelines:W,type:t.type,gtmContext:h}}];O&&de.push({component:Vt}),x&&de.unshift({id:"title",type:"text",value:x.text,limit:250,autoFocus:_,label:p.formatMessage({id:`${Je}titleField_label`}),functions:{onChange:ke=>{se({...U,title:ke})}},validation:[{condition:()=>te,error:p.formatMessage({id:`${Je}titleField_error`})}]});let Q=!m||!m.id||!n||te||re;return E&&(x?Q=Q||U.body===E.text&&U.title===x.text:Q=Q||U.body===E.text),c.jsxs(c.Fragment,{children:[c.jsxs(Bn,{id:F,className:G("discussion-card discussion-form",{"no-styling":v&&E}),meta:{shouldReset:!0,shouldHide:!1,showRequiredLabels:!1,shouldShowCancelButton:E&&!re||o.cancel},functions:{onSuccess:async()=>{if(E){ee("submitting"),k(U);return}await L()},onCancel:A},fields:de,intlPath:Je,button:{variant:"primary",size:{mobile:"small",600:"medium"},className:"gtm-trackable","data-gtm-event-context":h,"data-gtm-event-type":`${E?"save":"submit"}-${t.type}-click`,"data-testid":"save-button",disabled:Q,overwriteSubmittingText:!0,text:!re&&!E&&(s!=null&&s.submit)?s==null?void 0:s.submit:p.formatMessage({id:`${Je}${re?E?"saving":"posting":E?"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||!U.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&&!E&&["question"].includes(t.type)&&c.jsx("h2",{children:_t(p.formatMessage,`${Je}title`,t.type,"action")}),c.jsx(rr,{member:m?{...m,link:!1}:"community",gtmContext:h,gtmType:"profile-click"})]}),z==="submitted"&&q&&c.jsx(Br,{className:"success","data-testid":"success",children:_t(p.formatMessage,`${Je}success`,t.type,"action")}),H&&c.jsx(Br,{id:"error-message",className:"error","data-testid":"error",children:o.error?o.error:typeof H=="string"?H.includes(" ")?H:p.formatMessage({id:H},{action:p.formatMessage({id:`discussion_action_${t.type}`}),maxLength:i}):H}),g&&c.jsx(Me,{"aria-live":"polite",showOnFocus:!1,children:g})]})},Fx=Object.freeze(Object.defineProperty({__proto__:null,default:$r},Symbol.toStringTag,{value:"Module"})),Tx=({question:e,answer:t,reply:n})=>({...e&&{questionSlug:e},...t&&{answerSlug:t},...n&&{replySlug:n}}),Sx=(e,t=10)=>!e||e.length===0?[]:e.slice(0,t);const ja=({icon:e,className:t="",...n})=>c.jsx(Ae,{className:G("discussion-button",t),variant:"tertiary",icon:e,...n});let Er=!1;const Ui=()=>{Er!==!1&&(clearTimeout(Er),Er=!1)},Vi=5;let Ki=null;const qf=({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(),d={numberOfLikes:t,userLikedContent:a,ignoreInteractions:!1,showLikers:!1,tabbableLink:0},[h,p]=D.useReducer(Rr,d),{numberOfLikes:m,userLikedContent:g,ignoreInteractions:f,showLikers:C,tabbableLink:v}=h;D.useEffect(()=>{p([{type:"userLikedContent",value:a}])},[a]);const w=D.useMemo(()=>Sx(n,Vi),[n]),_=S=>{if(S.preventDefault(),S.stopPropagation(),p([{type:"showLikers",value:!1}]),Er)return Ui(),!1;if(Ui(),f||!s)return!1;Er=setTimeout(E,350)},E=async()=>{if(Ui(),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 W=Tx(i.slugs);g?await l(W):await o({...W,payload:{contentPath:window.location.pathname}})}}catch{p([{type:"numberOfLikes",value:t},{type:"userLikedContent",value:a}])}finally{p([{type:"ignoreInteractions",value:!1}])}},x=()=>{Ki=setTimeout(()=>{p([{type:"showLikers",value:!1}])},500)},T=()=>{Ki&&clearTimeout(Ki)};return D.createElement(e,{className:"likes-wrapper",onKeyDown:S=>{S.key==="Escape"&&p([{type:"showLikers",value:!1}])},onMouseEnter:()=>{T(),p([{type:"showLikers",value:!0}])},onMouseLeave:()=>{x()}},c.jsxs(c.Fragment,{children:[c.jsx(ja,{className:G("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:_,screenreaderText:s?u.formatMessage({id:`discussion_likes_${g?"unlike":"like"}`},{action:u.formatMessage({id:`discussion_action_${i.type}`})}):!1,"aria-pressed":g,children:c.jsx("span",{"data-testid":"number-of-likes",className:"number-of-likes",children:u.formatMessage({id:`discussion_likes${r?"_short":""}`},{number:m})})}),n&&c.jsxs(c.Fragment,{children:[c.jsx(Me,{"data-testid":"like-a11y-button",element:"button",className:"tertiary small icon navigation_arrow",onFocus:()=>{T()},onBlur:()=>x,onClick:S=>{var O;S.preventDefault(),S.stopPropagation(),T(),p([{type:"showLikers",value:!0}]);const W=(O=S.currentTarget.nextSibling)==null?void 0:O.childNodes[0];if(W){const q=W.querySelector("li:first-child a");q&&(p([{type:"tabbableLink",value:0}]),setTimeout(()=>{q.focus()},100))}},onKeyDown:S=>{S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),x())},"aria-expanded":C,"aria-controls":`likes-tooltip-${i.slug}`,children:c.jsx(Me,{showOnFocus:!1,children:u.formatMessage({id:"discussion_likes_show"},{action:i.type})})}),c.jsx(kn,{id:`likes-tooltip-${i.slug}`,isOpen:C,isLoading:n.length===0,children:n.length&&c.jsxs("ul",{children:[w.map((S,W)=>{if(typeof S=="string"||!S.name)return null;const O={};return v!==W&&(O.tabIndex=-1),c.jsx("li",{"data-index":W,children:c.jsx(_n,{href:S.id?`/profiles/${S.id}`:void 0,gtmContext:"Likes",gtmType:"liked-name-click",onClick:q=>q==null?void 0:q.stopPropagation(),onFocus:()=>T(),onKeyDown:q=>{var $,R,U,se;if(!q||!["ArrowUp","ArrowDown"].includes(q.key||""))return;q.stopPropagation(),q.preventDefault();const I=q.key==="ArrowUp"?"up":"down",k=($=q.currentTarget)==null?void 0:$.parentElement;let A=k==null?void 0:k.nextElementSibling;if(I==="up"){const H=k==null?void 0:k.previousElementSibling;H?A=H:(A=(R=k==null?void 0:k.parentElement)==null?void 0:R.lastElementChild,(A==null?void 0:A.getAttribute("data-index"))==="-1"&&(A=A==null?void 0:A.previousElementSibling))}else(!A||(A==null?void 0:A.getAttribute("data-index"))==="-1")&&(A=(U=k==null?void 0:k.parentElement)==null?void 0:U.firstElementChild);if(!A)return;const P=(A==null?void 0:A.getAttribute("data-index"))||"0";p([{type:"tabbableLink",value:P}]),(se=A==null?void 0:A.querySelector("a"))==null||se.focus()},...O,children:S.name})},S.id||window.btoa(S.name))}),t>Vi&&c.jsx("li",{"data-index":"-1",children:u.formatMessage({id:"discussion_likes_more"},{number:t-Vi})})]})})]})]}))},Yl=e=>{const t={};return Object.keys(e).forEach(n=>n.includes("Id")?t[n]=e[n]:t[`${n}Slug`]=e[n]),t},Zi=({children:e,class:t,...n})=>{const r={...n,class:G("subtle",t)};return c.jsx("blockquote",{...r,children:e})},jx=280,Ox=async(e,t,n,r=()=>Promise.resolve([]))=>{let a=t?Un(e,jx):e;a=a.trim();const i=`<br>
|
|
134
|
+
`;default:return u}}function Nn(e,t){const n=e.trim(),r=n,a=`${t}${r}${Hl(t)}`;if(r.length===e.length)return a;const i=t+r+Hl(t);return e.replace(n,i)}const Hl=e=>e.split("").reverse().join(""),MC=e=>e.map(t=>Bf(t)).join("").trim();const IC=()=>{const e=An(),{dispatch:t,isInOverlay:n,mentionPopover:r,id:a}=D.useContext(Gt),{show:i,selectedUser:s,possibleUsers:o}=r,l=lf(e,"mention-popover",`toolbar-${a}`);if(!i||!o.length)return null;const u=_f(n);return c.jsx(Ha,{parent:u,children:c.jsx($c,{ref:l,className:"mention-popover",onKeyDown:d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),t([{type:"showMentionPopover",value:!1}]))},children:c.jsx("ul",{children:o.map(({userId:d,user:h},p)=>c.jsx(rr,{element:"li",className:G({selected:p===s}),member:{id:d,...h,link:!1},functions:{onClick:m=>{m.preventDefault(),m.stopPropagation();const g={...r,selectedUser:p};t([{type:"mentionPopover",value:g}]),kf(e,g,t,a)}}},d))})})})},Do=({id:e,active:t,hasDivider:n=!1,callback:r,className:a="",children:i,...s})=>{const o=ue.useIntl(),l=An(),{id:u,tabbableOption:d,setFocus:h,openTooltip:p,dispatch:m}=D.useContext(Gt),g={};return e!==d&&(g.tabIndex=-1),c.jsxs("li",{id:`${u}-${e}`,className:G(e,{"has-divider":n}),onMouseEnter:()=>{m([{type:"openTooltip",value:e}])},onMouseLeave:()=>{m([{type:"openTooltip",value:null}])},onFocus:()=>{m([{type:"openTooltip",value:e}])},onBlur:f=>{f.stopPropagation();const C=[{type:"openTooltip",value:null}];l.selection&&C.push({type:"lastAnchor",value:l.selection.anchor}),m(C)},contentEditable:!1,children:[c.jsxs("button",{...s,...g,className:G(e,a,{active:t}),onClick:f=>{f.stopPropagation(),f.preventDefault()},onMouseDown:f=>{f.stopPropagation(),f.preventDefault(),r()},onKeyDown:f=>{var C,v,w,_;if(f.key!=="Tab")switch(f.key){case"Enter":f.stopPropagation(),f.preventDefault(),r();break;case"ArrowLeft":case"ArrowRight":f.stopPropagation(),f.preventDefault();const E=f.currentTarget.closest("li");let x=E==null?void 0:E.nextElementSibling;if(f.key==="ArrowLeft"){const W=E==null?void 0:E.previousElementSibling;W?x=W:x=(C=E==null?void 0:E.parentElement)==null?void 0:C.lastElementChild}else x||(x=(v=E==null?void 0:E.parentElement)==null?void 0:v.firstElementChild);const T=x==null?void 0:x.className.split(" ")[0];T&&(h(T),(w=x==null?void 0:x.querySelector("button"))==null||w.focus());break;default:const S=f.currentTarget.closest("fieldset");if(S){(_=S==null?void 0:S.previousElementSibling)==null||_.focus();break}}},children:[c.jsx(Me,{showOnFocus:!1,children:o.formatMessage({id:`richTextEditor_${e}`})}),c.jsx(kn,{id:`tooltip-${e}`,styling:{extraPadding:!1,hasPointer:"bottom"},isOpen:p===e,"aria-hidden":!0,children:o.formatMessage({id:`richTextEditor_${e}`})})]}),i]})},Ul=[Y.ol,Y.ul],Af=(e,t)=>{const{selection:n}=e;if(!n)return!1;const[r]=Array.from(b.nodes(e,{at:b.unhangRange(e,n),match:a=>{const i=a;return!b.isEditor(a)&&ce.isElement(a)&&i.type===t}}));return!!r},$C=e=>{const[t]=b.nodes(e,{match:n=>n.type===Y.blockquote});return!!t},Ff=(e,t,n)=>{try{const r=$C(e),a=Af(e,t),i=Ul.includes(t);J.unwrapNodes(e,{match:l=>{const u=l;return!b.isEditor(u)&&ce.isElement(u)&&Ul.includes(u.type)},split:!0});const o={type:a?Y.paragraph:i?Y.li:t};if(J.setNodes(e,o),i)if(a){const{selection:l}=e;if(!l)return;const[u,d]=b.parent(e,l,{edge:"end"});Array.from(b.nodes(e,{at:d,match:p=>{const m=p;return!b.isEditor(p)&&ce.isElement(p)&&m.type===Y.li}})).forEach(([p,m])=>{oe.string(p).trim()===""&&J.removeNodes(e,{at:m})})}else{if(r){const u={type:Y.blockquote,children:[]};J.wrapNodes(e,u)}const l={type:t,children:[]};J.wrapNodes(e,l)}}catch(r){const a=r.message;n(`Error toggling block: ${a}`)}},LC=({format:e,hasDivider:t=!1})=>{const{setFocus:n,reportError:r}=D.useContext(Gt),a=An(),i=Af(a,e);return c.jsx(Do,{id:e,active:i,hasDivider:t,callback:()=>{Ff(a,e,r),n(i?null:e)}})},wr=e=>{const[t]=b.nodes(e,{match:n=>{const r=n;return!b.isEditor(n)&&ce.isElement(n)&&r.type===Y.link}});return!!t},zC=(e,t,n,r)=>{e.selection&&Co(e,t,n,r)},qC=(e,t,n,r)=>{const{selection:a}=e;if(a&&Z.isCollapsed(a)){const[s]=b.nodes(e,{match:o=>{const l=o;return!b.isEditor(o)&&ce.isElement(o)&&l.type===Y.link}});if(s){const[o,l]=s,u={link:t};J.setNodes(e,u,{at:l}),yo(n)}}else Co(e,t,n,r)},Co=(e,t,n,r=a=>{console.error(a)})=>{try{wr(e)&&Tf(e);const{selection:a}=e,i=a&&Z.isCollapsed(a),s={type:Y.link,link:t,children:i?[{text:t}]:[]};i?(J.insertNodes(e,s),J.move(e,{distance:1,unit:"offset"})):(J.wrapNodes(e,s,{split:!0}),J.collapse(e,{edge:"end"}),J.insertNodes(e,{text:""}),J.move(e,{distance:1,unit:"offset"})),yo(n)}catch(a){const i=a.message;r(`Error in wrapLink: ${i}`)}},Tf=e=>{J.unwrapNodes(e,{match:t=>{const n=t;return!b.isEditor(t)&&ce.isElement(t)&&n.type===Y.link}})};let Ii=null;const WC=()=>{const e=ue.useIntl(),t="richTextEditor_link_",{id:n,showLinkEditor:r,isInOverlay:a,dispatch:i,reportError:s}=D.useContext(Gt),o=An(),l=a1(o),u=(l==null?void 0:l.text)||OC(o),[d,h]=D.useState(wr(o)),p=lf(o,"link-editor",`${n}-link`),m=D.useRef(null);D.useEffect(()=>{var w;!d&&r&&((w=m.current)==null||w.focus())},[d]),D.useEffect(()=>{Ii&&clearTimeout(Ii),Ii=setTimeout(()=>{h(wr(o))},500)},[o.selection]);const g=[],f=["open","edit","remove"].map(w=>{const _={variant:"tertiary",size:"small",children:e.formatMessage({id:`${t}${w}`},{link:l==null?void 0:l.pretty})};switch(g.push({className:w}),w){case"open":_.href=(l==null?void 0:l.full)||"",_.onClick=E=>{E.preventDefault(),E.stopPropagation(),window.open((l==null?void 0:l.full)||"","_blank"),i([{type:"showLinkEditor",value:!1}])},_.children=c.jsxs(c.Fragment,{children:[_.children,c.jsx(Me,{children:e.formatMessage({id:`${t}${w}_text`})})]});break;case"edit":_.onClick=()=>{h(!1)};break;case"remove":_.onClick=()=>{const E=[{type:"showLinkEditor",value:!1}];wr(o)&&(Tf(o),E.push({type:"lastAnchor",value:null})),i(E)};break}return _}),C=[{id:"url",type:"url",inputRef:m,label:e.formatMessage({id:`${t}url`}),placeholder:e.formatMessage({id:`${t}placeholder`}),value:(l==null?void 0:l.full)||"",validation:[{condition:"required",error:e.formatMessage({id:`${t}error_required`})},{condition:"valid-url"}],submitOnEnter:!0,autoFocus:!0}];u&&C.unshift({component:()=>c.jsxs("p",{children:[c.jsx("strong",{"aria-label":e.formatMessage({id:`${t}text_aria`}),children:e.formatMessage({id:`${t}text`})})," ",u]})});const v=_f(a);return c.jsx(Ha,{parent:v,children:c.jsx(kn,{ref:p,id:`${n}-link-editor`,className:"link-editor",isOpen:r,styling:{extraPadding:!1,hasForm:!d},functions:{onBlur:()=>{i([{type:"showLinkEditor",value:!1}])}},callbacks:{onOpen:()=>{setTimeout(()=>{var w;return(w=m.current)==null?void 0:w.focus()})}},children:d?c.jsx(tr,{wrappers:g,buttons:f}):c.jsx(Bn,{element:"fieldset",id:`${n}-link-editor`,className:G({"show-labels":u}),meta:{shouldReset:!0,showRequiredLabels:!1},functions:{onSuccess:async w=>{setTimeout(()=>{const _=[{type:"showLinkEditor",value:!1}];if(w.url){const{full:E}=Ic(w.url);l!=null&&l.full?qC(o,E,n,s):zC(o,E,n,s),_.push({type:"lastAnchor",value:null})}i(_)})}},fields:C,button:{text:e.formatMessage({id:`${t}button`}),variant:"tertiary",size:"small"}})})})},HC=()=>{const e=An(),{setFocus:t,dispatch:n}=D.useContext(Gt),[r,a]=D.useState(!1);return D.useEffect(()=>{a(wr(e))},[e.selection]),c.jsx(Do,{id:"link",active:r,hasDivider:!0,callback:()=>{n([{type:"showLinkEditor",value:!0}]),t(r?null:"link"),a(!0)}})},UC=e=>[Y.bold,Y.italic,Y.strikethrough].includes(e),Sf=(e,t)=>{const n=b.marks(e);return n?n[t]===!0:!1},jf=(e,t,n)=>{try{Sf(e,t)?b.removeMark(e,t):b.addMark(e,t,!0)}catch(r){const a=r.message;n(`Error toggling mark: ${a}`)}},VC=({format:e,hasDivider:t=!1})=>{const{setFocus:n,reportError:r}=D.useContext(Gt),a=An(),i=Sf(a,e);return c.jsx(Do,{id:e,active:i,hasDivider:t,callback:()=>{jf(a,e,r),n(i?null:e)}})},Fa=[Y.bold,Y.italic,Y.strikethrough],KC=[Y.ol,Y.ul,Y.blockquote];const ZC=({...e})=>{const t=ue.useIntl(),{id:n}=D.useContext(Gt);return c.jsxs(c.Fragment,{children:[c.jsxs("fieldset",{id:`toolbar-${n}`,className:"toolbar",...e,children:[c.jsx(Me,{element:"legend",showOnFocus:!1,children:t.formatMessage({id:"richTextEditor_toolbar"})}),c.jsxs("ul",{children:[Fa.map((r,a)=>c.jsx(VC,{format:r,hasDivider:a===Fa.length-1},r)),c.jsx(HC,{}),KC.map((r,a)=>c.jsx(LC,{format:r,hasDivider:a===1},r))]})]}),c.jsx(WC,{})]})};var YC=XC,GC=/^(?:\w+:)?\/\/(\S+)$/,QC=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,JC=/^[^\s\.]+\.\S{2,}$/;function XC(e){if(typeof e!="string")return!1;var t=e.match(GC);if(!t)return!1;var n=t[1];return n?!!(QC.test(n)||JC.test(n)):!1}const ex=En(YC),tx=(e,t,n)=>{const{insertText:r,isInline:a}=e;try{e.isInline=i=>{const s=i;return[Y.link].includes(s.type)||a(i)},e.insertText=i=>{i&&ex(i)?Co(e,i,t):r(i)}}catch(i){const s=i.message;n(`Error in withInlines: ${s}`)}return e},nx=(e,t)=>{const{isInline:n,isVoid:r,markableVoid:a}=e;try{e.isInline=i=>i.type===Y.mention?!0:n(i),e.isVoid=i=>i.type===Y.mention?!0:r(i),e.markableVoid=i=>i.type===Y.mention||a(i)}catch(i){const s=i.message;t(`Error in withMentions: ${s}`)}return e},rx=(e,t)=>{const{normalizeNode:n}=e;try{e.normalizeNode=([r,a])=>{if(r.type===Y.link&&oe.string(r).trim()===""){J.removeNodes(e,{at:a});return}n([r,a])}}catch(r){const a=r.message;t(`Error in withoutEmptyLinks: ${a}`)}return e};const Of=({id:e="rich-text-editor",value:t,placeholder:n,maxLength:r=0,meta:a,functions:i,autoFocus:s,data:o,...l})=>{const u=ue.useIntl(),d=Ih();typeof s>"u"&&(s=!0);const{isInOverlay:h=!1}=a||{},{listMembers:p,onChange:m=()=>{},reportError:g=H=>{console.error(H)}}=i||{},f=[{type:Y.paragraph,children:[{text:""}]}];t==="<br>"&&(t="");const C={editorKey:null,originalValue:t||"",initialValue:t?null:f,tabbableOption:Fa[0],openTooltip:null,showLinkEditor:!1,mentionPopover:{show:!1,selectedUser:0,possibleUsers:[],position:null},lastAnchor:null,stringValue:"",lastKey:null,hasInteracted:!1,hasLoaded:!1},[v,w]=D.useReducer(Rr,C),{editorKey:_,originalValue:E,initialValue:x,stringValue:T,lastAnchor:S,lastKey:W,hasInteracted:O,hasLoaded:q,mentionPopover:I}=v,k=H=>{const y=H||Fa[0];H&&w([{type:"tabbableOption",value:y}])},A=`rte-${e}`,P=D.useCallback(H=>c.jsx(n1,{...H}),[]),$=D.useCallback(H=>c.jsx(r1,{...H}),[]),R=D.useMemo(()=>tx(nx(rx(Wv(e1(zv())),g),g),A,g),[]);D.useEffect(()=>{if(!t)return;_r.lastIndex=0;const H=t.match(_r);!H||H.length>1||H[0].length!==t.length||O||w([{type:"originalValue",value:t}])},[t]);const U=H=>{if(!R||H!==A)return;const y=b.end(R,[]);J.select(R,y),X.focus(R)};D.useEffect(()=>{const H=y=>{var B;const z=y,ee=((B=z==null?void 0:z.detail)==null?void 0:B.id)||null;ee&&U(ee)};return window.addEventListener("focusEditor",H),()=>{window.removeEventListener("focusEditor",H)}},[]),D.useEffect(()=>{if(R.children.length>0&&!q){if(w([{type:"hasLoaded",value:!0}]),!s)return;U(A)}},[R.children.length,x]),D.useEffect(()=>{E&&(async()=>{let y=gn(E);y.includes("<")&&(y=new xa().turndown(y)),o&&o.mentions&&(y=await Mc({text:y,template:`[${Bs}{{name}}]({{id}})`,mentions:o.mentions,listMembers:p||(()=>Promise.resolve([]))})),jC(y,z=>{w([{type:"initialValue",value:z},{type:"editorKey",value:E.toString()}]),setTimeout(()=>{w([{type:"stringValue",value:zl(R)}])},150)})})()},[E]),D.useEffect(()=>{t!==""||!R||as(E,t)&&!O||(b.withoutNormalizing(R,()=>{J.delete(R,{at:{anchor:b.start(R,[]),focus:b.end(R,[])}}),J.deselect(R),R.children.length!==0&&J.unwrapNodes(R,{at:[0]}),J.insertNodes(R,f,{at:[0]})}),w([{type:"initialValue",value:f},{type:"lastAnchor",value:null}]))},[t]);const se=Ec(()=>{NC(R,I.show,p,w)},100);return x?c.jsx("div",{id:A,className:"rich-text-editor",children:c.jsxs(Gt.Provider,{value:{...v,id:A,isInOverlay:h,setFocus:k,dispatch:w,reportError:g},children:[c.jsxs(Jy,{editor:R,initialValue:x,onChange:H=>{if(R.operations.some(z=>z.type!=="set_selection")){const z=MC(H);m(z),w([{type:"stringValue",value:zl(R)}]),O||w([{type:"hasInteracted",value:!0}]),se(),d&&console.log({serialized:z,json:H})}},...l,children:[c.jsx(Wy,{className:"input",renderElement:P,renderLeaf:$,placeholder:n||u.formatMessage({id:"richTextEditor_placeholder"}),autoFocus:s,tabIndex:0,onKeyDown:H=>{if(H.key==="Enter"){I.show&&(H.preventDefault(),H.stopPropagation(),kf(R,I,w,A));const{selection:y}=R;if(y){const z=Z.isCollapsed(y),[ee,B]=b.node(R,y,{depth:1});let F=ee,L=F.type;const M=F.children[0];if(M&&[Y.ol,Y.ul].includes(M.type)&&(F=M,L=M.type),F&&ce.isElement(F)&&L!==Y.paragraph){if(L===Y.blockquote&&!H.shiftKey){H.stopPropagation(),H.preventDefault(),J.insertNodes(R,f);return}if(z){const[V]=b.parent(R,y,{edge:"end"}),te=V.type;if(W==="Enter"&&te===Y.li&&[Y.ul,Y.ol].includes(L)){H.stopPropagation(),H.preventDefault(),J.insertNodes(R,f,{at:N.next(B)}),J.select(R,b.end(R,N.next(B)));return}}}}}else if(H.key==="Escape"){if(I.show){H.preventDefault(),H.stopPropagation(),w([{type:"mentionPopover",value:{...I,show:!1}}]);return}}else if(["ArrowUp","ArrowDown"].includes(H.key)&&I.show){H.preventDefault(),H.stopPropagation();const{selectedUser:y,possibleUsers:z}=I;let ee=H.key==="ArrowUp"?y-1:y+1;ee<0&&(ee=z.length-1),ee>=z.length&&(ee=0),w([{type:"mentionPopover",value:{...I,selectedUser:ee}}])}w([{type:"lastKey",value:H.key}]),PC(H,R,w,g)},onBlur:()=>{R.selection&&w([{type:"lastAnchor",value:R.selection.anchor}])},onFocus:()=>{if(S){if(!N.isPath(S.path)||!oe.has(R,S.path))return;const H=oe.get(R,S.path);let y=0;if(fe.isText(H)?y=H.text.length:H.children&&(y=H.children.length),S.offset>y)return;try{J.select(R,{anchor:S,focus:S})}catch(z){const ee=z.message;g(`Error focusing editor: ${ee}`)}}}}),c.jsx(ZC,{}),p?c.jsx(IC,{}):null]},_),c.jsx(Zs,{id:`character-limit-${e}`,limit:r,valueLength:Za(T)})]})}):null};const ax=({id:e="form-toggle",label:t,options:n,initialValue:r,functions:{onChange:a=()=>{}},isDisabled:i=!1,className:s=""})=>{const[o,l]=D.useState(typeof r=="boolean"||typeof r=="string"?r:n[0].value);D.useEffect(()=>{r&&l(r)},[r]);const u=d=>{i||(l(d),a(d))};return c.jsxs("div",{className:G("toggle",s),onClick:d=>{d.preventDefault(),d.stopPropagation(),u(o===n[0].value?n[1].value:n[0].value)},children:[c.jsx("p",{children:t}),c.jsx("ul",{className:G("toggle-options",{disabled:i,on:o===n[1].value}),children:n.map(d=>{const h=`${e}-${d.value}`;return c.jsxs("li",{className:"hidden",children:[c.jsx("input",{type:"radio",id:h,name:e,value:d.value,checked:o===d.value,onChange:()=>u(d.value),disabled:i}),c.jsx("label",{htmlFor:h,children:d.label})]},h)})})]})};function ix({className:e="",userId:t,userName:n,src:r,setUserImage:a,uploadImage:i}){const[s,o]=D.useState(!1),[l,u]=D.useState(!1),d=D.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 c.jsxs("div",{className:G("profile-image-change-figure",e),children:[c.jsx(Zt,{className:"profile-image-change-picture",name:n,src:r,"data-testid":"profile-picture"}),l&&c.jsx("p",{className:"error text-small",children:c.jsx(ue.FormattedMessage,{id:"profile_image_change_error"})}),c.jsx("input",{id:"file",type:"file",accept:"image/*",ref:d,onChange:h,hidden:!0,"data-testid":"file-input"}),c.jsx(Ae,{onClick:()=>d.current&&d.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:c.jsx(ue.FormattedMessage,{id:s?"profile_image_change_uploading_text":r?"profile_image_change_cta_with_picture":"profile_image_change_cta_without_picture"})})]})}const Pf=({gtm:e,functions:{onSuccess:t=async()=>{},onFailure:n=()=>{}}})=>{const{context:r="FooterContactUsForm",event:a="contact-form-submit-click"}=e||{};return c.jsx(Bn,{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 Nf=({title:e,label:t,ctaMessage:n,titleColor:r,labelColor:a,backgroundColor:i,onClose:s,reportError:o,sendInvites:l,initialFormStatus:u="NOT_SUBMITTED"})=>{const[d,h]=D.useState([]),[p,m]=D.useState(!0),[g,f]=D.useState(u),{formatMessage:C}=ue.useIntl(),v=async E=>{E.preventDefault();try{await l(d),h([]),f("SUCCESS")}catch(x){f("ERROR"),o(x)}},w=E=>{E.preventDefault(),f("NOT_SUBMITTED"),m(!0),h([])},_=E=>{E.preventDefault(),s(),f("CLOSED")};return g==="CLOSED"?null:g==="ERROR"||g==="SUCCESS"?c.jsxs("div",{className:"invite-form-wrapper",children:[c.jsx("div",{className:"content centred",children:g==="SUCCESS"?c.jsx("h2",{className:"success-title",children:C({id:"inviteForm_success"})}):c.jsxs("h2",{className:"error-title",children:[" ",C({id:"inviteForm_error"})]})}),c.jsx(Vt,{}),c.jsx("div",{className:"footer",children:g==="SUCCESS"?c.jsxs(c.Fragment,{children:[c.jsx(Ae,{variant:"secondary",onClick:w,children:C({id:"inviteForm_ctaSendMoreInvites"})}),c.jsx(Ae,{onClick:_,children:C({id:"inviteForm_ctaDone"})})]}):c.jsx(Ae,{onClick:w,children:C({id:"inviteForm_ctaTryAgain"})})})]}):c.jsx("div",{className:"invite-form-wrapper",children:c.jsxs("form",{style:{backgroundColor:i},onSubmit:v,className:G("invite-form gtm-trackable"),children:[c.jsxs("fieldset",{className:"content",children:[c.jsx("h2",{className:"title",style:{color:r},children:e}),c.jsx("label",{htmlFor:"email-input",className:"label",style:{color:a},children:t}),c.jsx(kh.ReactMultiEmail,{id:"email-input",inputClassName:"email-input input",placeholder:C({id:"inviteForm_email_placeholder"}),emails:d,onChange:E=>{h(E),m(!E.length)},autoFocus:!1,getLabel:(E,x,T)=>c.jsxs("div",{className:"email text-medium",children:[c.jsx("div",{"data-tag-item":!0,children:E}),c.jsx(Ae,{variant:"tertiary",size:"small",icon:{icon:"close"},onClick:()=>{T(x),m(!d.length)},className:"remove-email-button",screenreaderText:C({id:"overlay_close"})})]},x)})]}),c.jsx(Vt,{}),c.jsx("fieldset",{className:"footer",children:c.jsx(Ae,{className:"sendEmailsButton",disabled:p,children:n})})]})})},ba=e=>e.map(t=>({condition:t})),Dt={FORM_ID:"manage-account-password-change",NEW_PASSWORD:"newPassword",CONFIRMED_PASSWORD:"confirmedPassword",CURRENT_PASSWORD:"oldPassword"},sx=({functions:e,...t})=>{const{formatMessage:n}=ue.useIntl(),[r,a]=D.useState(null),[i,s]=D.useState(!1),[o,l]=D.useState({isMoreThanEightCharacters:!1,includesNumberAndSymbol:!1,includesLowerAndUppercase:!1}),u=m=>m[Dt.NEW_PASSWORD]!==m[Dt.CONFIRMED_PASSWORD]?n({id:"passwordRules_unmatched_text"}):null,d=m=>!us(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:ba(["required",d]),functions:{onChange:m=>l(us(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:ba(["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:ba(["required"])}),i&&h.push({component:ud,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 c.jsxs(c.Fragment,{children:[c.jsx(Bn,{...p}),r&&c.jsx(on,{variant:"error",text:r})]})};const Rf=({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=D.useRef(null);Vn(()=>{!n||o||!s||u.current&&u.current.focus()},[s]);const d=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 c.jsx("form",{onSubmit:d,className:G("search-form gtm-trackable",t),role:"search","data-gtm-event-context":a,"data-gtm-event-type":i,children:c.jsx("fieldset",{id:`${e}-form`,hidden:n?!s:!1,children:c.jsxs("p",{children:[c.jsx(Me,{element:"label",htmlFor:e,children:l.formatMessage({id:"search_label"})}),c.jsx("input",{ref:u,type:"search",id:e,name:e,defaultValue:r,placeholder:l.formatMessage({id:"search_placeholder"}),onKeyDown:h=>{h.key==="Enter"&&d(h)}}),c.jsx("button",{className:"clear",onClick:h=>{h.preventDefault(),h.stopPropagation(),u.current&&u.current.value&&(u.current.value="")},children:c.jsx(Me,{children:l.formatMessage({id:"search_clear"})})}),c.jsx("button",{className:"search",onClick:d,children:c.jsx(Me,{children:l.formatMessage({id:"search_cta"})})})]})})})},Vl=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 d="";return o?d=l?"gov":"nonGov":u.registration?u.engagement&&!u.user?d=u.auth?"verify":"pending":d="exists":u.auth&&(d="exists"),n([{type:"shouldDisableButton",value:!1},{type:"shouldManuallyApprove",value:!l},{type:"emailDetails",value:{email:a,boxType:d,isEnd2End:/testing\+[0-9]+@apolitical.co$/.test(a)}},{type:"validFields.email",value:!0}])},ox=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"]}},ux=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=ox(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}])},lx=({shouldShow:e,placeholders:t,labels:n,functions:{validateEmail:r,resendVerificationCode:a},refs:i,state:s,dispatch:o,dataToSubmit:l,intl:u})=>{const{emailDetails:d}=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:()=>{Vl({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:rd,props:{email:d.email,type:d.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=>c.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=>c.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=>c.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=>c.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"&&Vl({ref:i.email,validateEmail:r,dispatch:o}))}),g.length&&o(g)}},validation:[{condition:"required"}],"data-testid":"signup-terms-checkbox"}),p};const cx=({className:e=""})=>c.jsxs("div",{className:G("success-message",e),"data-testid":"success-message",children:[c.jsx("p",{className:"success-title",children:c.jsx(ue.FormattedMessage,{id:"signup_success_title"})}),c.jsx(ue.FormattedMessage,{id:"signup_success_text",values:{p:t=>c.jsx("p",{children:t})}})]});const dx={validFields:{name:!1,email:!1,jobTitle:!1,organisation:!1},emailDetails:{email:"",boxType:"",isEnd2End:!1},shouldManuallyApprove:!1,shouldDisableButton:!0,loadRecaptcha:!1,showSuccessMessage:!1,showError:!1},fx=({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:d=!1,url:h=!0,logInButton:p=!0,successMessage:m=!0}=a,g={title:u,expectation:d,url:h,logInButton:p,successMessage:m},[f,C]=D.useReducer(Rr,dx),{validFields:v,emailDetails:w,shouldManuallyApprove:_,shouldDisableButton:E,showSuccessMessage:x,showError:T}=f,[S,W]=Ms.useCookies(["signup-this-session","functional-cookie-consent"]),O={form:D.createRef(),name:D.createRef(),email:D.createRef(),jobTitle:D.createRef(),organisation:D.createRef(),tc:D.createRef(),hiddenValidation:D.createRef()};D.useEffect(()=>{_===!0&&O.jobTitle.current&&O.jobTitle.current.focus()},[_]),D.useEffect(()=>{S["signup-this-session"]&&C([{type:"showSuccessMessage",value:!0}])},[S]),D.useEffect(()=>{x&&S["functional-cookie-consent"]&&W("signup-this-session","true",{path:"/",maxAge:3600})},[x]);const q=D.useMemo(()=>lx({placeholders:n,labels:t,shouldShow:g,functions:r,refs:O,state:f,dispatch:C,dataToSubmit:s,intl:l}),[s,r,l,O,g,f]),I=E?!0:_?!Object.values(v).every(k=>k===!0):!v.name||!v.email||["exists","pending","verify"].includes(w.boxType);return g.successMessage&&x?c.jsx(cx,{className:e}):c.jsxs("fieldset",{className:G("signup-form-fieldset",e),"data-testid":"signup-form",children:[g.title&&c.jsx("p",{className:"signup-title",children:c.jsx(ue.FormattedMessage,{id:"signup_title"})}),T&&c.jsx(on,{variant:"error",text:l.formatMessage({id:"signup_error"})}),c.jsx(Bn,{className:"signup-form",formRef:O.form,id:"sign-up-form",fields:q,intlPath:"signup",button:{variant:"primary",size:"medium",text:i||l.formatMessage({id:"signup_button_join"}),disabled:I?{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 ux({refs:O,dataToSubmit:s,createAccount:r.createAccount,onSuccess:r.onSuccess,dispatch:C,state:f})},onCatch:k=>{r.handleError(k),C([{type:"showSuccessMessage",value:!1},{type:"showError",value:!0}])}}}),c.jsx("button",{className:"validation-button",ref:O.hiddenValidation})]})};const cn=({children:e,className:t="",styling:n={},...r})=>{const{background:a="default"}=n;return c.jsx("section",{className:G("full-width-section",t,{[a]:a!=="default"}),...r,children:e})};const hx=({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})}),c.jsx(cn,{className:G("download-section",n),children:c.jsxs("div",{className:"content-default",children:[D.createElement(typeof e=="string"?"h2":e.element,{className:"text"},typeof e=="string"?e:e.text),c.jsx(tr,{buttons:r})]})})};function Mf({href:e,setShowModal:t}){typeof e!="string"&&t(!0)}const mx=({icon:e,description:t,ctaMessage:n,href:r,showEditButton:a,setShowModal:i})=>{const{formatMessage:s}=ue.useIntl();return c.jsxs("div",{className:G("edit-section-placeholder",{"has-icon":!!e}),style:Pc(e),children:[c.jsx("p",{children:t||s({id:"edit_section_placeholder_description"})}),a&&c.jsx(Ae,{href:r,variant:"secondary",size:"small",onClick:()=>Mf({href:r,setShowModal:i}),children:n||s({id:"edit_section_placeholder_cta"})})]})},px=({children:e,className:t="",formProps:n,href:r,title:a,modalTitle:i,placeholder:s,showDivider:o=!0})=>{const[l,u]=D.useState(!1),d=typeof r=="string"||!!n,h=()=>u(!1);return c.jsxs("section",{className:G("edit-section",t),children:[n&&c.jsx(ir,{title:i||`Edit ${a}`,isOpen:l,showDivider:!1,showIcon:!1,functions:{onClose:h},className:G("edit-section-modal"),children:c.jsx(Bn,{...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}})}),c.jsxs("div",{className:"edit-section-header",children:[c.jsx("h2",{className:"edit-section-header-title",children:a}),d&&c.jsx(Ae,{href:r,variant:"tertiary",size:"small",icon:"pencil",onClick:()=>Mf({href:r,setShowModal:u}),children:"Edit"})]}),e||c.jsx(mx,{...s,href:r,setShowModal:u,showEditButton:d}),o&&c.jsx(Vt,{})]})};const gx=({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 c.jsxs("div",{className:G("logos",a,`align-${l}`,{[u]:u!=="block","wrap-logos":o}),children:[e&&D.createElement(s.element,{className:G("title",s.className)},s.text),t&&c.jsx("p",{children:t}),c.jsx("ul",{className:G({"two-col":i===2||i===4,"three-col":i===5||i<=10&&i%3===0}),children:n.map(({logo:d,nameOfBusiness:h,link:p=!1,description:m=!1},g)=>{if(!d||!d.url)return null;const f=c.jsx("img",{src:d.url,width:d.width||"auto",height:d.height||"auto",alt:h});return c.jsxs("li",{children:[c.jsx("p",{className:"img-wrapper",children:p?c.jsx("a",{href:p,target:"_blank",rel:"nofollow noreferrer noopener",children:f}):f}),m&&c.jsx("small",{children:m})]},window.btoa(`${d.url}_${g}`))})})]})};let $i;const Li="contactFooter_",vx=({onSuccess:e=async()=>{},onFailure:t=()=>{}})=>{const n=D.useRef(null),[r,a]=D.useState(0),[i,s]=D.useState(!1),o=()=>{n.current&&a(n.current.clientHeight)},l=()=>{i||(s(!0),clearTimeout($i),$i=setTimeout(()=>{o(),s(!1)},500))};return D.useEffect(()=>(o(),window.addEventListener("resize",l),()=>{clearTimeout($i),window.removeEventListener("resize",l)}),[]),c.jsx(cn,{id:"contactForm",className:"contact-footer",children:c.jsxs("div",{className:"inner-wrapper",children:[c.jsx("h2",{children:c.jsx(ue.FormattedMessage,{id:`${Li}title`})}),c.jsxs("div",{className:"content-wrapper",ref:n,"data-testid":"content-wrapper",style:i?{}:{minHeight:r},children:[c.jsxs("aside",{children:[c.jsx("p",{children:c.jsx(ue.FormattedMessage,{id:`${Li}text`})}),c.jsx(_n,{className:"mailto-link",href:"mailto:hello@apolitical.co",children:c.jsx(ue.FormattedMessage,{id:`${Li}email`})})]}),c.jsx(Pf,{functions:{onSuccess:e,onFailure:t},gtm:{context:"FooterContactUsForm",event:"contact-form-submit-click"}})]})]})})},bx=({activeLink:e,...t})=>c.jsx(cn,{children:c.jsx(td,{layout:"1-3",children:c.jsxs(c.Fragment,{children:[c.jsx(ed,{activeLink:e}),c.jsx(Hc,{...t})]})})});const zi="cookieBanner_",qi=["apol-cookie-banner","apolitical-performance-cookie-consent","functional-cookie-consent"],Wi=new Date(Date.now()+12*30*24*60*60*1e3),If=()=>{const e=ue.useIntl(),[t,n,r]=Ms.useCookies(qi),[a,i]=D.useState(!t["apol-cookie-banner"]),s=()=>{qi.forEach(d=>{n(d,!0,{path:"/",expires:Wi,domain:d==="apolitical-performance-cookie-consent"?".apolitical.co":void 0})}),i(!1),window.location.reload()},o=()=>{n("apol-cookie-banner",!0,{path:"/",expires:Wi}),qi.forEach(d=>{if(d==="apol-cookie-banner"){n(d,!0,{path:"/",expires:Wi});return}r(d)}),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(d=>{u.push({variant:d.href?"tertiary":"primary",href:d.href,onClick:d.onClick,className:"gtm-trackable","data-gtm-event-context":"cookie-banner","data-gtm-event-type":`cookie-${d.gtmType}-click`,children:e.formatMessage({id:`${zi}buttons_${d.id}`})})}),c.jsxs("aside",{id:"cookie-banner",className:"text-medium",children:[c.jsx("h6",{children:e.formatMessage({id:`${zi}title`})}),c.jsx("p",{children:e.formatMessage({id:`${zi}text`})}),c.jsx(tr,{buttons:u})]})},Wt={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:Rn["data-protection"].default,gtmType:"email-dpo-link"},euDataProtection:{email:Rn["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:Rn.support,gtmType:"concierge-email-click"},business:{email:Rn.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 qn="footer_",Ta="SiteFooter",Kl=({group:e})=>{const t=Wt[e].order||[];let n=!1;return"text"in Wt[e]&&(n=Wt[e].text),c.jsxs(D.Fragment,{children:[c.jsx("p",{className:"pre-title",children:c.jsx(ue.FormattedMessage,{id:`${qn}${e}`})}),Array.isArray(t)&&t.length>0&&c.jsx("ul",{className:"text-medium",children:t.map(r=>{if(["order","child","text"].includes(r))return null;const{href:a,gtmType:i}=Wt[e][r],s={};return["legal"].includes(e)&&(s.target="_blank",s.rel="noopener"),c.jsx("li",{children:c.jsx("a",{href:a,className:"gtm-trackable","data-gtm-event-context":Ta,"data-gtm-event-type":i,...s,children:c.jsx(ue.FormattedMessage,{id:`${qn}${e}_${r}`})})},`${e}_${r}`)})}),typeof n!="boolean"&&"order"in n&&Array.isArray(n.order)&&c.jsx("dl",{className:"text-medium",children:n.order.map(r=>c.jsxs(D.Fragment,{children:[c.jsx("dt",{children:c.jsx(ue.FormattedMessage,{id:`${qn}${e}_${r}`})}),c.jsxs("dd",{children:[typeof n!="boolean"&&n[r].address&&c.jsx("address",{children:c.jsx(ue.FormattedMessage,{id:`${qn}${e}_${r}_address`,values:{br:c.jsx("br",{})}})}),typeof n!="boolean"&&n[r].email&&c.jsx("a",{href:`mailto:${n[r].email}`,className:"gtm-trackable","data-gtm-event-context":Ta,"data-gtm-event-type":n[r].gtmType,children:n[r].email})]})]},`dl-${e}-${r}`))})]},e)},xo=()=>c.jsx("div",{id:"footer",children:c.jsxs("div",{className:"wrapper",children:[c.jsx(qa,{element:"hr"}),c.jsx(Ks,{variant:"inverted",version:"full",className:"gtm-trackable","data-gtm-event-context":Ta,"data-gtm-event-type":"logo-homepage-link"}),c.jsx("footer",{children:["platform","community","company","contact"].map(e=>c.jsxs("div",{className:"group",children:[c.jsx(Kl,{group:e}),Object.keys(Wt[e]).includes("child")&&c.jsx(Kl,{group:Wt[e].child})]},e))}),c.jsx("hr",{}),c.jsxs("div",{className:"sub-footer",children:[c.jsx("ul",{children:Array.isArray(Wt.social.order)&&Wt.social.order.map(e=>{const t=Wt.social[e];return c.jsx("li",{className:e,children:c.jsx("a",{href:t.href,target:"_blank",rel:"noopener noreferrer",className:"gtm-trackable","data-gtm-event-context":Ta,"data-gtm-event-type":"social-click",children:c.jsx("span",{className:"hidden",children:c.jsx(ue.FormattedMessage,{id:`${qn}social_${e}`})})})},e)})}),c.jsx("small",{children:c.jsx(ue.FormattedMessage,{id:`${qn}copyright`,values:{currentYear:new Date().getFullYear()}})})]})]})}),Ie={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&&Ie.handlerCalled[e]&&i-Ie.handlerCalled[e]<500)return;Ie.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=Dc(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?Ie.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=Ie.findFirstChild(t.current.children,"attributes.aria-controls",gt.SITE);s=Ie.findFirstChild(u.children,"href")}else s=Ie.findFirstChild(t.current.children,"href");break;case gt.ACCOUNT:if(o=Ie.findFirstChild(t.current.children,"className","account"),!o||!o.children)return;s=Ie.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(Ie.timeouts[t]),n(t,!r))},onFocus:({id:e})=>{clearTimeout(Ie.timeouts[e])},onMouseEnter:({id:e,callback:t})=>{clearTimeout(Ie.timeouts[e]),t(e,!0)},onBlur:({id:e,callback:t})=>{Ie.timeouts[e]=setTimeout(()=>{t(e,!1)},250)}}},Nr={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"}}}},Sa=({id:e,isLoggedIn:t=!1,isDesktopVersion:n=!1,menus:r={},callback:a=()=>{},doTrack:i=null})=>{const s=ue.useIntl(),o=Dc(Nr,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,d=e.includes("buttons.");let h=`header_${e.replaceAll(".","_")}`;o.hasVariantText&&(h+=`_logged${t?"In":"Out"}`);let p=!1;if(o.href){let _=o.gtmType||`${e}-click`;if(_.includes(".")){const E=_.split("."),x=E[E.length-2];_=`${x==="topics"?`${x}-`:""}${E[E.length-1]}`}p={href:o.href},u&&(p={...p,className:"gtm-trackable","data-gtm-event-type":_,"data-gtm-event-context":"HeaderButtons"}),d&&(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 C={},v={},w={};if(f&&(C={...C,"aria-current":"page"}),m){const _=o.menuId||e,E={onClick:x=>Ie.events.onClick(x,{id:_,callback:a,isOpen:r[_]}),onFocus:()=>Ie.events.onFocus({id:_}),onBlur:()=>Ie.events.onBlur({id:_,callback:a}),onMouseLeave:()=>Ie.events.onBlur({id:_,callback:a}),onMouseEnter:()=>Ie.events.onMouseEnter({id:_,callback:a})};v={...E,id:_===gt.SITE?gt.SITE:gt.ACCOUNT},n&&(g&&(w={...E,className:"navigation-button",onKeyPress:x=>{x.key==="Enter"&&Ie.events.onClick(x,{id:_,callback:a,isOpen:r[_]})},"aria-haspopup":!0,"aria-expanded":r[_],"aria-controls":_}),v={...v,hidden:_ in r?!r[_]:!0}),g||(v={...v})}return c.jsxs("li",{className:G({[o.className]:o.className,"has-submenu":m,parent:g,active:f}),...C,children:[p?D.createElement(d?Ae:"a",p,s.formatMessage({id:h})):n&&o.order&&g?c.jsxs("button",{...w,children:[s.formatMessage({id:h}),c.jsx(Me,{children:s.formatMessage({id:`header_menu_${r[gt.SITE]?"hide":"show"}`})})]}):s.formatMessage({id:h}),o.order&&c.jsx("ul",{...v,children:o.order.map(_=>{if(!o[_])return null;const E={isLoggedIn:t,isDesktopVersion:n,menus:r,callback:a,doTrack:l?u:null};return o[_].order?c.jsxs("li",{className:G({[o[_].className]:o[_].className}),children:[s.formatMessage({id:`${h}_${_}`}),c.jsx("ul",{children:o[_].order.map(x=>c.jsx(Sa,{id:`${e}.${_}.${x}`,...E},x))})]},_):c.jsx(Sa,{id:`${e}.${_}`,...E},_)})})]},e)};const yx={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 wo=({showNavigation:e=!0})=>{const t=ue.useIntl(),n=D.useContext(It),r=Xn(!0,!0),a=n&&typeof n.id=="string",i=D.useMemo(()=>Ie.getIsDesktopVersion(a,r),[a,r]),[s,o]=D.useReducer(Rr,{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:d}=s,h=D.useRef(s);D.useEffect(()=>{h.current=s},[s]),_c({scrollPosition:yx[`height${i.navigation?"_desktop":""}`],callbacks:{scrollUp:()=>{const v=h.current.menus;!i&&v["site-navigation"]||Ie.shouldChangeHeaderIsVisible(!0,v,o)},scrollDown:()=>{const v=h.current.menus;!i&&v["site-navigation"]||Ie.shouldChangeHeaderIsVisible(!1,v,o)}}});const p=(v,w,_=!1)=>{Ie.handleMenus({id:v,value:w,menus:h.current.menus,dispatch:o,forceHandle:_})},m=D.useRef(null),g=v=>{v.key==="Escape"&&["site-navigation","search","account-navigation"].forEach(w=>{h.current.menus[w]&&p(w,!1,!0)})};D.useEffect(()=>{var v;return(v=document.getElementById("header"))==null||v.addEventListener("keydown",g),()=>{var w;(w=document.getElementById("header"))==null||w.removeEventListener("keydown",g)}},[]),Vn(()=>{u["site-navigation"]&&Ie.autoFocus({menu:"site-navigation",navigationRef:m,isDesktopVersion:i.navigation,focusElements:d,dispatch:o})},[u["site-navigation"]]),Vn(()=>{u["account-navigation"]&&Ie.autoFocus({menu:"account-navigation",navigationRef:m,isDesktopVersion:i.navigation,focusElements:d,dispatch:o})},[u["account-navigation"]]);const f=c.jsxs(c.Fragment,{children:[!i.search&&c.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:c.jsx(Me,{children:t.formatMessage({id:`header_search_${u.search?"hide":"show"}`})})}),c.jsx(Rf,{id:"global-search",handleToggle:{searchIsOpen:u.search,isDesktopVersion:i.search},gtmContext:"search-bar-header",gtmEvent:"form-submission"})]}),C=c.jsxs(c.Fragment,{children:[!i.navigation&&c.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:c.jsx(Me,{children:t.formatMessage({id:`header_menu_${u["site-navigation"]?"hide":"show"}`})})}),c.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:Nr.order.map(v=>c.jsx(Sa,{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:c.jsxs(c.Fragment,{children:[c.jsxs("nav",{id:"header",className:G({"logged-in":a,"logged-out":!a,visible:l}),children:[c.jsx(Me,{element:"a",href:"#content-of-page",children:t.formatMessage({id:"header_skip"})}),c.jsx(Ks,{variant:"monochrome"}),e&&c.jsxs(c.Fragment,{children:[i.navigation?c.jsxs(c.Fragment,{children:[C,f]}):c.jsxs(c.Fragment,{children:[f,C]}),a?c.jsxs("button",{className:"account-button",onClick:v=>Ie.events.onClick(v,{id:"account-navigation",callback:p,isOpen:u["account-navigation"]}),onMouseEnter:()=>Ie.events.onMouseEnter({id:"account-navigation",callback:p}),onMouseLeave:()=>Ie.events.onBlur({id:"account-navigation",callback:p}),"aria-haspopup":"true","aria-expanded":u["account-navigation"],"aria-controls":"account-navigation",children:[c.jsx(Me,{children:t.formatMessage({id:`header_account_${u["account-navigation"]?"hide":"show"}`})}),c.jsx(Zt,{name:n&&n.name||"",src:n&&n.image&&n.image.thumbnail||""})]}):c.jsx("ul",{className:"sign-in-buttons",children:Nr.buttons.order.map(v=>c.jsx(Sa,{id:`buttons.${v}`},v))})]})]}),c.jsx("hr",{id:"content-of-page"}),c.jsx("div",{className:G("overlay",{open:u["site-navigation"]||u["account-navigation"]||!i.search&&u.search})})]})};const Dx=()=>{const e=ue.useIntl();return c.jsxs(c.Fragment,{children:[c.jsx(wo,{}),c.jsx("div",{id:"content",children:c.jsx(on,{variant:"error",text:e.formatMessage({id:"pageLayout_error"})})}),c.jsx(xo,{})]})},$f=({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:d="default",variant:h="default",circle:p="default",modal:m="default"}=i,g=wc(),[f,C]=D.useState(""),v=T=>{const{detail:{message:S}}=T;C(S)};D.useEffect(()=>(window.scrollTo(0,0),document.addEventListener("ariaLive",v),()=>{document.removeEventListener("ariaLive",v)}),[g]);const w=ca(e,{locale:o}),_=ca(t,{locale:o}),E=ca(n,{locale:o}),x={};return d!=="default"&&(x[d]=!0),h!=="default"&&(x[h]=!0),p!=="default"&&(x[p]=!0),c.jsx(_h.ErrorBoundary,{onError:r,fallback:c.jsx(Dx,{}),children:c.jsxs(D.Suspense,{fallback:null,children:[c.jsxs("div",{id:"wrapper",className:G(s,x,{"has-footer":u}),children:[c.jsx(wo,{showNavigation:l}),c.jsxs("main",{id:"content-wrapper",children:[_&&c.jsx("div",{className:G("additional-content prepended",{"large-modal":m==="large"}),children:_}),D.createElement(d==="bold"?Fo:"div",{id:"content",children:w,className:G({"large-modal":m==="large"})})]}),E&&c.jsx("div",{className:"additional-content appended",children:E}),u&&c.jsx(xo,{}),c.jsx(If,{})]}),f&&c.jsx(Me,{"aria-live":"polite",showOnFocus:!1,"data-testid":"layout-aria-live",children:f})]})})},Zl={default:"tags_",headerTopics:"header_topics_topics_"},Hi={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"},Cx={getTagDetails:e=>{if(e.includes("topic_")){if(e=Hi.topic[e.replace("topic_","")],e){const t=Nr.topics.topics[e].href;return t?{id:e,href:t,text:`${Zl.headerTopics}${e}`}:null}return null}return Hi[e]?(e=Hi[e],{id:e,text:`${Zl.default}${e}`}):null}};const xx=({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 d=Cx.getTagDetails(u);d&&l.push(d)}),l.length<1?null:c.jsx("ul",{className:G("tags text-small",t,a,{"one-line":n}),children:l.map(u=>{const d=o.formatMessage({id:u.text});return c.jsx("li",{children:u.href&&r?c.jsx("a",{href:u.href,className:"gtm-trackable","data-gtm-event-type":i,"data-gtm-event-context":s,children:d}):d},u.id)})})};const wx=({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:c.jsxs("div",{className:G("members-list",s),children:[c.jsxs("h1",{children:[o.formatMessage({id:"membersList"}),c.jsx("span",{className:"count",children:t})]}),c.jsx("ul",{children:e.map((l,u)=>c.jsxs("li",{children:[c.jsx(rr,{member:l,gtmContext:a,gtmType:i}),l.isAdmin&&c.jsx(mn,{children:o.formatMessage({id:"membersList_admin"})})]},u))}),n&&c.jsx(Mr,{hasNextPage:n,loadNextPage:r,icon:{icon:"arrow-down",position:"right"},gtmContext:a})]})};const Ex=D.lazy(()=>Promise.resolve().then(()=>yE)),Lf=({forceShow:e,form:t,className:n})=>{const r=ue.useIntl(),i=D.useContext(It)||"community",s=Va(i);s.name||(s.name=r.formatMessage({id:`member_${typeof i=="string"?i:"community"}`}));const{modal:o=!1}=e||{},[l,u]=D.useState(o||Uh("showPost")==="true"||!1);return c.jsxs(c.Fragment,{children:[c.jsxs("button",{className:G("discussion-form-card",n),onClick:d=>{d.preventDefault(),d.stopPropagation(),u(!0)},"data-testid":"discussion-form-card",children:[c.jsx(Zt,{name:s.name,src:s.image,alt:""}),c.jsx("span",{className:"input",children:r.formatMessage({id:"discussionFormCard_placeholder"})})]}),c.jsx(Ha,{children:c.jsx(Ex,{showModal:l,onClose:()=>{u(!1)},form:t,className:"in-portal"})})]})},kx=D.lazy(()=>Promise.resolve().then(()=>Fx)),Eo=({isCard:e=!1,form:t,membershipRequiredToPost:{isMember:n,required:r,join:a,leave:i,notMemberStateText:s}})=>{if(r&&!n)return c.jsx(on,{text:s,button:{breakpoints:{mobile:!0,901:!1},component:c.jsx(Vs,{isShort:!0,functions:{join:a,leave:i}})}});const{content:o,functions:l,meta:u,...d}=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},...d,id:`add-post-${d.id||""}`};return e?c.jsx(Lf,{form:h}):c.jsx(kx,{...h})},_x={showForm:!1},ni=D.createContext(_x),zf=({children:e})=>{const[t,n]=D.useState({showForm:!1});return c.jsx(ni.Provider,{value:{...t,updateConversation:n},children:e})},Bx=({intlPath:e,showGuidelines:t,type:n,gtmContext:r})=>{const a=ue.useIntl();return t?c.jsx("small",{children:_t(a.formatMessage,`${e}explainer`,n,"action",{a:i=>c.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})})}):c.jsx(c.Fragment,{})},Ax=({formID:e,intlPath:t,showLabel:n,type:r})=>{const a=ue.useIntl();return n?c.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`})}):c.jsx(Me,{element:"label",showOnFocus:!1,htmlFor:`${e}-input`,children:_t(a.formatMessage,`${t}label_action`,r,"action")})};let ra=null;const Je="discussion_form_",$r=({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:d={},gtmContext:h="DiscussionForm"})=>{var be,he,Ee;const p=ue.useIntl(),m=D.useContext(It),[g,f]=D.useState(""),{isLoading:C=!1,isInWrapper:v=!1,isInOverlay:w=!1,isAutoFocused:_=!1,isEditing:E=!1,hasTitleField:x=!1,isPrepopulated:T=!1,showTitle:S=!1,showGuidelines:W=!0,showDivider:O=!1,showSuccessMessage:q=!0}=r||{},{create:I=()=>{},handleSaveEdit:k=()=>{},handleCancel:A=()=>{},callback:P=()=>{},listMembers:$=()=>Promise.resolve([]),props:R={create:{projectNames:["questions-answers"]}}}=u,[U,se]=D.useState({title:x&&x.text||"",body:E&&E.text||T&&T.text||""}),[H,y]=D.useState(o.error||!1),[z,ee]=D.useState(!1);if(D.useEffect(()=>{l&&!E&&T&&T!==U.body&&se({...U,body:T.text||""})},[T]),C)return c.jsx(Et,{className:"discussion-card discussion-form","data-testid":"loading-placeholder"});const B=ke=>{se({...U,body:ke});let De;!m||!m.id?De=_t(p.formatMessage,`${Je}error_loggedOut`,t.type,"action"):n?i>0&&ke.length>=i&&(De=`${Je}error_tooLong`):De=_t(p.formatMessage,`${Je}error_noPermission`,t.type,"action"),De?y(De):H&&y(!1)};let F=`${t.type}-form`;if(t.type==="response"||t.type==="reply"){const ke=((be=t.slugs)==null?void 0:be.reply)||((he=t.slugs)==null?void 0:he.answer)||((Ee=t.slugs)==null?void 0:Ee.question)||"";ke&&(F=`${F}-${ke.slice(-15)}`)}e&&(F=`${e}-${F}`);const L=async()=>{if(!m||!m.id||!n||te)return;ra&&clearTimeout(ra),ee("submitting");const ke=window.location.pathname;try{let De;switch(t.type){case"post":De=await I({title:U.title,content:U.body});break;case"question":De=await I({title:U.body,authorId:m&&m.id,...R==null?void 0:R.create});break;case"response":De=await I({questionSlug:t.slugs.question},{body:U.body,authorId:m&&m.id,contentPath:ke});break;case"reply":De=await I({questionSlug:t.slugs.question,answerSlug:t.slugs.answer},{body:U.body,authorId:m&&m.id,contentPath:ke});break;default:break}await Mh(1e3),P&&await P(De),ra=setTimeout(()=>{se({title:"",body:""}),ee("submitted"),f(_t(p.formatMessage,`${Je}success`,t.type,"action"));const je=new Event("discussionFormSubmitted");document.dispatchEvent(je),M()},500)}catch(De){const je=De;let Le=`${Je}error`;je!=null&&je.message.includes("entry already exists")&&(Le=_t(p.formatMessage,`${Je}error_alreadyExists`,t.type,"action")),je!=null&&je.message.includes("429")?Le=_t(p.formatMessage,`${Je}error_tooMany`,t.type,"action"):je!=null&&je.message.includes("400")&&(Le=`${Je}error`),y(Le),M()}},M=()=>{ra=setTimeout(()=>{y(!1),ee(!1),f("")},5e3)},V=!U.title||!Lo(U.title),ne=!U.body||!Lo(U.body);let te=ne;x&&(te=V&&ne);const re=z==="submitting",de=[{component:Ax,props:{formID:F,intlPath:Je,showLabel:x!==!1,type:t.type}},{component:Of,props:{id:`${F}-input`,value:z==="submitting"&&!H?"":U.body,placeholder:a||_t(p.formatMessage,`${Je}placeholder`,t.type,"action"),maxLength:i,meta:{isInOverlay:w},functions:{onChange:B,listMembers:$},data:d,autoFocus:E!==!1||_&&!x,"aria-invalid":!!H,"aria-errormessage":"error-message"}},{component:Bx,props:{intlPath:Je,showGuidelines:W,type:t.type,gtmContext:h}}];O&&de.push({component:Vt}),x&&de.unshift({id:"title",type:"text",value:x.text,limit:250,autoFocus:_,label:p.formatMessage({id:`${Je}titleField_label`}),functions:{onChange:ke=>{se({...U,title:ke})}},validation:[{condition:()=>te,error:p.formatMessage({id:`${Je}titleField_error`})}]});let Q=!m||!m.id||!n||te||re;return E&&(x?Q=Q||U.body===E.text&&U.title===x.text:Q=Q||U.body===E.text),c.jsxs(c.Fragment,{children:[c.jsxs(Bn,{id:F,className:G("discussion-card discussion-form",{"no-styling":v&&E}),meta:{shouldReset:!0,shouldHide:!1,showRequiredLabels:!1,shouldShowCancelButton:E&&!re||o.cancel},functions:{onSuccess:async()=>{if(E){ee("submitting"),k(U);return}await L()},onCancel:A},fields:de,intlPath:Je,button:{variant:"primary",size:{mobile:"small",600:"medium"},className:"gtm-trackable","data-gtm-event-context":h,"data-gtm-event-type":`${E?"save":"submit"}-${t.type}-click`,"data-testid":"save-button",disabled:Q,overwriteSubmittingText:!0,text:!re&&!E&&(s!=null&&s.submit)?s==null?void 0:s.submit:p.formatMessage({id:`${Je}${re?E?"saving":"posting":E?"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||!U.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&&!E&&["question"].includes(t.type)&&c.jsx("h2",{children:_t(p.formatMessage,`${Je}title`,t.type,"action")}),c.jsx(rr,{member:m?{...m,link:!1}:"community",gtmContext:h,gtmType:"profile-click"})]}),z==="submitted"&&q&&c.jsx(Br,{className:"success","data-testid":"success",children:_t(p.formatMessage,`${Je}success`,t.type,"action")}),H&&c.jsx(Br,{id:"error-message",className:"error","data-testid":"error",children:o.error?o.error:typeof H=="string"?H.includes(" ")?H:p.formatMessage({id:H},{action:p.formatMessage({id:`discussion_action_${t.type}`}),maxLength:i}):H}),g&&c.jsx(Me,{"aria-live":"polite",showOnFocus:!1,children:g})]})},Fx=Object.freeze(Object.defineProperty({__proto__:null,default:$r},Symbol.toStringTag,{value:"Module"})),Tx=({question:e,answer:t,reply:n})=>({...e&&{questionSlug:e},...t&&{answerSlug:t},...n&&{replySlug:n}}),Sx=(e,t=10)=>!e||e.length===0?[]:e.slice(0,t);const ja=({icon:e,className:t="",...n})=>c.jsx(Ae,{className:G("discussion-button",t),variant:"tertiary",icon:e,...n});let Er=!1;const Ui=()=>{Er!==!1&&(clearTimeout(Er),Er=!1)},Vi=5;let Ki=null;const qf=({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(),d={numberOfLikes:t,userLikedContent:a,ignoreInteractions:!1,showLikers:!1,tabbableLink:0},[h,p]=D.useReducer(Rr,d),{numberOfLikes:m,userLikedContent:g,ignoreInteractions:f,showLikers:C,tabbableLink:v}=h;D.useEffect(()=>{p([{type:"userLikedContent",value:a}])},[a]);const w=D.useMemo(()=>Sx(n,Vi),[n]),_=S=>{if(S.preventDefault(),S.stopPropagation(),p([{type:"showLikers",value:!1}]),Er)return Ui(),!1;if(Ui(),f||!s)return!1;Er=setTimeout(E,350)},E=async()=>{if(Ui(),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 W=Tx(i.slugs);g?await l(W):await o({...W,payload:{contentPath:window.location.pathname}})}}catch{p([{type:"numberOfLikes",value:t},{type:"userLikedContent",value:a}])}finally{p([{type:"ignoreInteractions",value:!1}])}},x=()=>{Ki=setTimeout(()=>{p([{type:"showLikers",value:!1}])},500)},T=()=>{Ki&&clearTimeout(Ki)};return D.createElement(e,{className:"likes-wrapper",onKeyDown:S=>{S.key==="Escape"&&p([{type:"showLikers",value:!1}])},onMouseEnter:()=>{T(),p([{type:"showLikers",value:!0}])},onMouseLeave:()=>{x()}},c.jsxs(c.Fragment,{children:[c.jsx(ja,{className:G("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:_,screenreaderText:s?u.formatMessage({id:`discussion_likes_${g?"unlike":"like"}`},{action:u.formatMessage({id:`discussion_action_${i.type}`})}):!1,"aria-pressed":g,children:c.jsx("span",{"data-testid":"number-of-likes",className:"number-of-likes",children:u.formatMessage({id:`discussion_likes${r?"_short":""}`},{number:m})})}),n&&c.jsxs(c.Fragment,{children:[c.jsx(Me,{"data-testid":"like-a11y-button",element:"button",className:"tertiary small icon navigation_arrow",onFocus:()=>{T()},onBlur:()=>x,onClick:S=>{var O;S.preventDefault(),S.stopPropagation(),T(),p([{type:"showLikers",value:!0}]);const W=(O=S.currentTarget.nextSibling)==null?void 0:O.childNodes[0];if(W){const q=W.querySelector("li:first-child a");q&&(p([{type:"tabbableLink",value:0}]),setTimeout(()=>{q.focus()},100))}},onKeyDown:S=>{S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),x())},"aria-expanded":C,"aria-controls":`likes-tooltip-${i.slug}`,children:c.jsx(Me,{showOnFocus:!1,children:u.formatMessage({id:"discussion_likes_show"},{action:i.type})})}),c.jsx(kn,{id:`likes-tooltip-${i.slug}`,isOpen:C,isLoading:n.length===0,children:n.length&&c.jsxs("ul",{children:[w.map((S,W)=>{if(typeof S=="string"||!S.name)return null;const O={};return v!==W&&(O.tabIndex=-1),c.jsx("li",{"data-index":W,children:c.jsx(_n,{href:S.id?`/profiles/${S.id}`:void 0,gtmContext:"Likes",gtmType:"liked-name-click",onClick:q=>q==null?void 0:q.stopPropagation(),onFocus:()=>T(),onKeyDown:q=>{var $,R,U,se;if(!q||!["ArrowUp","ArrowDown"].includes(q.key||""))return;q.stopPropagation(),q.preventDefault();const I=q.key==="ArrowUp"?"up":"down",k=($=q.currentTarget)==null?void 0:$.parentElement;let A=k==null?void 0:k.nextElementSibling;if(I==="up"){const H=k==null?void 0:k.previousElementSibling;H?A=H:(A=(R=k==null?void 0:k.parentElement)==null?void 0:R.lastElementChild,(A==null?void 0:A.getAttribute("data-index"))==="-1"&&(A=A==null?void 0:A.previousElementSibling))}else(!A||(A==null?void 0:A.getAttribute("data-index"))==="-1")&&(A=(U=k==null?void 0:k.parentElement)==null?void 0:U.firstElementChild);if(!A)return;const P=(A==null?void 0:A.getAttribute("data-index"))||"0";p([{type:"tabbableLink",value:P}]),(se=A==null?void 0:A.querySelector("a"))==null||se.focus()},...O,children:S.name})},S.id||window.btoa(S.name))}),t>Vi&&c.jsx("li",{"data-index":"-1",children:u.formatMessage({id:"discussion_likes_more"},{number:t-Vi})})]})})]})]}))},Yl=e=>{const t={};return Object.keys(e).forEach(n=>n.includes("Id")?t[n]=e[n]:t[`${n}Slug`]=e[n]),t},Zi=({children:e,class:t,...n})=>{const r={...n,class:G("subtle",t)};return c.jsx("blockquote",{...r,children:e})},jx=280,Ox=async(e,t,n,r=()=>Promise.resolve([]))=>{let a=t?Un(e,jx):e;a=a.trim();const i=`<br>
|
|
135
135
|
|
|
136
136
|
`;return a.slice(0,i.length)===i&&(a=a.slice(i.length)),n?await Mc({text:a,template:"[@{{name}}](/profiles/{{id}})",mentions:n,listMembers:r}):a};const Px=3e3,Nx=({url:e,gtm:t={context:"ShareLink",event:"copy-link-click"}})=>{const n=ue.useIntl(),[r,a]=D.useState({isOpen:!1,isCopied:!1});return c.jsxs("li",{children:[c.jsx(kn,{className:G("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"})}),c.jsx(ja,{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})},Px)})},"data-gtm-event-context":t.context,"data-gtm-event-type":t.event})]})},qt="discussion_",Rx=195,Lr=({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:d,isTruncated:h=!1,styling:{showShareLinkButton:p=!1}={},setFocus:m=!1,isCommunity:g=!1})=>{var Ee,ke,De,je,Le,Ue,Qe,Se;const f=ue.useIntl(),C=D.useContext(It),v=D.useContext(ni),{createContent:w=async()=>{},deleteContent:_=async()=>{},updateContent:E=async()=>{}}=s.content||{},{createLike:x=()=>{},deleteLike:T=()=>{}}=s.likes||{},{openComments:S=()=>{}}=s.comments||{},{listMembers:W=()=>Promise.resolve([])}=s.mentions||{},{author:O,canLike:q,createdAt:I,id:k,likes:A=0,userLiked:P,comments:$=0,mentions:R}=t,U=C&&C.id&&typeof O!="string"&&O.id&&O.id===C.id||!1,se=typeof q=="boolean"?q:!0,H=U&&(!t.createdAt||Nh(t.createdAt,10,"seconds")),y=D.useRef(null),[z,ee]=D.useState({title:t&&t.title||"",body:t&&t.body||"",isEditing:!1,didEdit:t&&t.isEdited||!1,postBody:""}),[B,F]=D.useState(!1),[L,M]=D.useState(H?"highlighted":"default"),[V,ne]=D.useState("");D.useEffect(()=>{const pe=y.current;if(!(!pe||L==="default"))return document.addEventListener("discussionFormSubmitted",te),pe.addEventListener("transitionend",re),()=>{document.removeEventListener("discussionFormSubmitted",te),pe.removeEventListener("transitionend",re)}},[]),D.useEffect(()=>{ee({...z,title:t&&t.title||"",body:t&&t.body||"",didEdit:t&&t.isEdited||!1})},[t.isEdited]),D.useEffect(()=>{(async()=>{const we=await Ox(z.body,h,R,W);ee({...z,postBody:we})})()},[z.body,R]);const te=()=>{setTimeout(()=>{M("fading")},1e3)},re=({propertyName:pe})=>{pe==="background-color"&&M(we=>(we==="default"&&(document.removeEventListener("discussionFormSubmitted",te),y.current&&y.current.removeEventListener("transitionend",re)),we==="fading"?"default":we))};if(r||!t||t.type==="answer"&&(!t.slugs||!t.slugs.question)||z.postBody===""&&t.title==="")return c.jsx(Et,{className:"discussion-card"});const de=async({title:pe,body:we})=>{pe||(pe=""),we||(we=""),ne("");try{if(!as(pe,z.title)||!as(we,z.body)){const K=t.type==="question"?{title:we}:{title:pe,body:we};await E(Yl(t.slugs),K)}ee({...z,title:pe,body:we,isEditing:!1,didEdit:!0})}catch{ne(`${qt}form_error`)}},Q=()=>{if(v&&v.updateConversation){const pe={showForm:!0},we=t.author;we&&we.id&&(g&&(pe.prepopulateForm=`@{{${we.id}}}`),pe.mentionData={id:we.id,name:we.name}),v.updateConversation(pe)}setTimeout(()=>{var me,ge,_e;const we=`reply-form-${(t.type==="answer"?t.slug:((me=t.slugs)==null?void 0:me.reply)||((ge=t.slugs)==null?void 0:ge.answer)||((_e=t.slugs)==null?void 0:_e.question)||"").toLowerCase().slice(-15)}`,K=document.getElementById(we),ie=document.getElementById(`${we}-input`);ie&&ie.focus(),K&&K.scrollIntoView({behavior:"smooth"})},0)},be=async()=>{F(!1);try{await _(Yl(t.slugs))}catch{ne("delete-error")}},he=[{text:f.formatMessage({id:`${qt}moreMenu_report`}),onClick:pe=>{pe.stopPropagation()},href:`mailto:community@apolitical.co?subject=${encodeURI(f.formatMessage({id:`${qt}report_subject`}))}&body=${encodeURI(f.formatMessage({id:`${qt}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&&U&&he.push({text:f.formatMessage({id:`${qt}moreMenu_edit`}),onClick:()=>ee({...z,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:`${qt}moreMenu_delete`}),onClick:pe=>{pe.preventDefault(),pe.stopPropagation(),F(!0)},icon:"trash",className:"gtm-trackable","data-gtm-event-context":u,"data-gtm-event-type":`delete-${t.type}-click`,...ch(`delete-${t.slug}-modal`,B)}),m&&((Ee=y==null?void 0:y.current)==null||Ee.focus(),(ke=y==null?void 0:y.current)==null||ke.scrollIntoView({behavior:"smooth"})),D.createElement(e,{className:G("discussion-post",l,{[L]:!l||!l.includes("highlighted-text-box"),"has-link":o.post&&!z.isEditing}),ref:y,tabIndex:m?0:null,"data-testid":`discussion-${t.type}-thread`,"data-gtm-event-context":`${u}-post-click`,onClick:pe=>{!o.post||z.isEditing||(pe.preventDefault(),pe.stopPropagation(),window.location.href=o.post)},children:c.jsxs(c.Fragment,{children:[c.jsxs("div",{id:k||t.slug,className:G("discussion-card",t.type,{editing:z.isEditing,"has-link":o.post&&!z.isEditing}),children:[!z.isEditing&&c.jsx(rr,{member:O,additionalContent:{createdAt:I,didEdit:z.didEdit},className:typeof O!="string"&&O.id===a?"highlighted":"",gtmContext:u,gtmType:"profile-click"}),z.isEditing?c.jsx($r,{id:`editing-${t.slug}`,content:{type:t.type,slugs:t.slugs},userHasPermissions:n,meta:{isLoading:r,isInWrapper:!0,hasTitleField:z.title!==""?{text:z.title}:!1,isEditing:{text:z.body},isPrepopulated:!1},isCommunity:g,maxLength:t.type==="question"?250:5e4,forceShow:{error:V!==""&&V!=="delete-error"?f.formatMessage({id:V},{action:f.formatMessage({id:`discussion_action_${t.type}`})}):!1},functions:{create:w,handleSaveEdit:de,handleCancel:()=>{ne(""),ee({...z,isEditing:!1})},listMembers:W},gtmContext:`${u}Form`,data:{mentions:t.mentions}}):o.post?c.jsxs("a",{href:o.post,children:[(z==null?void 0:z.title)&&c.jsx("p",{className:"content-title",children:z==null?void 0:z.title}),z.postBody.length>Rx?c.jsx(Wc,{text:z.postBody,markdownOptions:{overrides:{a:cs,blockquote:{component:Zi}}}}):c.jsx(Kn,{options:{overrides:{a:cs,blockquote:{component:Zi}}},children:z.postBody})]}):c.jsxs(c.Fragment,{children:[(z==null?void 0:z.title)&&c.jsx("p",{className:"content-title",children:z==null?void 0:z.title}),c.jsx(Kn,{options:{wrapper:t.type==="question"?"h1":D.Fragment,forceWrapper:t.type==="question",forceInline:t.type==="question",forceBlock:t.type!=="question",overrides:{blockquote:{component:Zi}}},children:z.postBody})]}),!z.isEditing&&!(i!=null&&i.actionBar)&&c.jsxs("ul",{className:G("actions text-medium",t.type),"data-testid":`${t.type}-actions`,children:[!i.likes&&c.jsx(qf,{element:"li",likes:A,isShort:!1,userLiked:P,content:{type:t.type,slugs:t.slugs,slug:t.slug},canLike:se,peopleWhoLiked:t.peopleWhoLiked,functions:{createLike:x,deleteLike:T}}),!i.comments&&(["question","post"].includes(t.type)||o.comments)&&c.jsx("li",{children:c.jsx(ja,{onClick:pe=>{pe.preventDefault(),pe.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:`${qt}comments_screenReader`},{count:$}),children:f.formatMessage({id:`${qt}comments`},{count:$})})}),(t.type==="answer"||t.type==="reply")&&c.jsx("li",{children:c.jsx(ja,{styling:{muted:!0},onClick:Q,icon:{icon:"speech-bubble_square"},children:f.formatMessage({id:`${qt}reply`})})}),p&&c.jsx(Nx,{url:(De=t.slugs)!=null&&De.reply?`${window.location.origin}${(je=t.slugs)==null?void 0:je.question}/${(Le=t.slugs)==null?void 0:Le.answer}#${(Ue=t.slugs)==null?void 0:Ue.reply}`:`${window.location.origin}${(Qe=t.slugs)==null?void 0:Qe.question}/${(Se=t.slugs)==null?void 0:Se.answer}`,gtm:{context:u,event:`copy-link-${t.type}-click`}}),c.jsx(Xc,{element:"li",id:`more-${t.slug}`,options:he})]})]}),d,c.jsx(ir,{id:`delete-${t.slug}-modal`,isOpen:B,functions:{onOpen:()=>{},onClose:()=>F(!1)},forceShow:{error:V==="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:()=>F(!1),children:f.formatMessage({id:"discussion_delete_cancel"})},{variant:"primary",className:"destructive",onClick:be,children:f.formatMessage({id:"discussion_delete_delete"})}],gtmContext:`${t.type.charAt(0).toUpperCase()}${t.type.slice(1)}:${t.slug}`,children:c.jsx(ue.FormattedMessage,{id:"discussion_delete_text",values:{p:pe=>c.jsx("p",{children:pe}),action:f.formatMessage({id:`discussion_action_${t.type}`})}})})]})})};const Yi="discussion_responses_",Wf=({type:e="answer",responses:t=0,isLoading:n=!1})=>{const r=ue.useIntl();return t=parseInt(t),c.jsxs("div",{className:"responses-heading",children:[c.jsx("h4",{children:r.formatMessage({id:`${Yi}title`},{action:r.formatMessage({id:`${Yi}${e}`}),count:t})}),!n&&t===0&&c.jsx("p",{children:_t(r.formatMessage,`${Yi}empty`,e,e)})]})};const Hf=({loadMore:{isLoading:e,hasNextPage:t,loadNextPage:n}={isLoading:!1,hasNextPage:!1,loadNextPage:()=>{}},form:r,children:a})=>{const i=ue.useIntl(),s=D.useContext(ni),o=ca(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 c.jsxs("div",{className:G("thread-wrapper",{"empty-thread":!o}),children:[!Object.is(o,null)&&c.jsx("ul",{className:"thread",children:o}),!e&&c.jsx(Mr,{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&&c.jsx($r,{...r})]})},Mx="post",Ix="reply",Uf="00000000-0000-0000-0000-000000000000";function ko({queryClient:e,queryKey:t}){function n(r,a,i){e.setQueryData(t,i)}return n}function _o({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 $x(){return{latest_reactions:{like:[],reply:[]},reaction_counts:{like:0,reply:0},own_reactions:{like:[],reply:[]}}}function Lx(){return{latest_children:{like:[],reply:[]},children_counts:{like:0,reply:0},own_children:{like:[],reply:[]}}}function Vf(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 zx({title:e,content:t}){return{title:e,content:t,id:Uf,time:new Date().toISOString(),verb:Mx}}function Gl({activity:e,user:t}){return{...e,actor:Vf(t),...$x()}}function Oa({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 Kf({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 qx({activityId:e,replyId:t,content:n}){return{activity_id:e,data:{content:n},id:Uf,kind:Ix,parent:t||""}}function Ql({reply:e,user:t}){const n=Vf(t);return{...e,user_id:n.id,user:n,...Lx()}}function Jl({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 Wx({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 Zf=e=>{const t=new CustomEvent("discussionPostAdded",{detail:e});document.dispatchEvent(t)};let Xl,Gi=0;const Yf=()=>{D.useEffect(()=>(document.addEventListener("discussionPostAdded",e),()=>{document.removeEventListener("discussionPostAdded",e)}),[]);const e=t=>{const n=t.detail;if(!n)return;clearTimeout(Xl);const r=document.getElementById(n);if(r){r.scrollIntoView({behavior:"smooth",block:"start"}),Gi=0;return}Gi++,!(Gi>10)&&(Xl=setTimeout(()=>{e(t)},50))}},Qn=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}),sn=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}),Gf=Object.freeze({actor:`SU:${Qn.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"}),Hx=Object.freeze({actor:`SU:${sn.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"}),Ux=Object.freeze({actor:`SU:${Qn.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"}),Vx=Object.freeze({actor:`SU:${sn.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:Gf.id,kind:"like",created_at:"2023-11-24T17:58:36.162000",data:{},parent:"",updated_at:"2023-11-24T17:58:36.162000",user_id:sn.id,children_counts:{},latest_children:{},latest_children_extra:{},own_children:{},user:{id:sn.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:sn.id,user:{id:sn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Gf.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:Qn.id,user:{id:Qn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Hx.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:sn.id,user:{id:sn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Ux.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:Qn.id,user:{id:Qn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Vx.id,data:{content:"Some content 4..."},parent:"",latest_children:{},children_counts:{}});function Kx({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a,user:i}){const{mutate:s}=Ke.useMutation({mutationFn:e,onMutate:o=>t(l=>{const u=Gl({activity:zx(o),user:i});return ec(u,l)}),onError:n,onSuccess:(o,l,u)=>{const d=Gl({activity:o,user:i});r.setQueryData(a,ec(d,u,!0)),setTimeout(()=>{Zf(d.id)},0)}});return s}function Zx({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ke.useMutation({mutationFn:e,onMutate:({activityId:a,content:i})=>t(s=>{const o=Pa(a,s);return o&&(o.content=i),s}),onError:n});return r}function Yx({queryFns:{create:e,edit:t,like:n,list:r,remove:a,unlike:i},queryKey:s}){const o=Ke.useQueryClient(),l=Ka(),u={queryClient:o,queryKey:s},d={mutationHandlers:{error:ko(u),mutate:_o(u)},user:l,...u},h=Kx({...d,mutationFn:e}),p=Zx({...d,mutationFn:t}),m=Gx({...d,mutationFn:n}),g=Jx({...d,mutationFn:a}),f=Xx({...d,mutationFn:i}),{activities:C,...v}=Qx({queryKey:s,queryFn:r});return{activities:C,mutations:{create:h,edit:p,remove:g,like:m,unlike:f},user:l,...v}}function Gx({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=Ke.useMutation({mutationFn:e,onMutate:({activityId:s})=>t(o=>{const l=Pa(s,o);return l&&Oa({activity:l}),o}),onError:n,onSuccess:(s,{activityId:o},l)=>{const u=Pa(o,l);u&&Oa({activity:u,reaction:s}),r.setQueryData(a,l)}});return i}function Qx({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}=Ke.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:{next:null},getNextPageParam:o=>(o==null?void 0:o.next)||null});return{activities:tw(n),error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}}function Jx({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ke.useMutation({mutationFn:e,onMutate:({activityId:a})=>t(i=>ew(a,i)),onError:n});return r}function Xx({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=Ke.useMutation({mutationFn:e,onMutate:({activityId:i})=>t(s=>{const o=Pa(i,s);return o&&Kf({activity:o,user:r}),s}),onError:n});return a}function ec(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 Pa(e,t){if(t)for(const{results:n}of t.pages){const r=n.find(({id:a})=>a===e);if(r)return r}}function ew(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 tw(e){var t;return((t=e==null?void 0:e.pages)==null?void 0:t.reduce((n,{results:r})=>[...n,...r],[]))||[]}const nw=({basePath:e,parentId:t,isMember:n,functions:{activities:r,mentions:a,join:i,leave:s}})=>{const o=ue.useIntl(),{activities:l,error:u,fetchNextPage:d,hasNextPage:h,isLoading:p,mutations:{create:m,edit:g,remove:f,like:C,unlike:v}}=Yx({queryKey:[e,t,"activities"],queryFns:r}),[w,_]=D.useState(null),E=()=>{_(l.length),d()};return Yf(),u?c.jsx(on,{variant:"error",text:u.message}):c.jsxs("section",{children:[c.jsx(Eo,{isCard:!0,form:{content:{type:"post",slugs:{}},functions:{create:m,listMembers:a.listMembers},meta:{isEditing:!1,isAutoFocused:!1,isPrepopulated:!1,showSuccessMessage:!1}},membershipRequiredToPost:{isMember:n,required:!0,join:i,leave:s,notMemberStateText:o.formatMessage({id:"community_joinToPost"})}}),l==null?void 0:l.map((x,T)=>{var U,se,H,y,z,ee,B,F;const{id:S,own_reactions:W,latest_reactions:O,reaction_counts:q,mentioned_users:I}=x,k=(((U=O==null?void 0:O.like)==null?void 0:U.length)||0)>0,A=(((se=W==null?void 0:W.like)==null?void 0:se.length)||0)>0,P=A?W==null?void 0:W.like[0].id:"",$=k?(H=O==null?void 0:O.like)==null?void 0:H.map(L=>{var M,V,ne;return{id:(M=L==null?void 0:L.user)==null?void 0:M.id,name:(ne=(V=L==null?void 0:L.user)==null?void 0:V.data)==null?void 0:ne.name}}):!1,R=x==null?void 0:x.actor;return c.jsx(D.Fragment,{children:c.jsx(Lr,{content:{type:"post",title:x==null?void 0:x.title,body:x==null?void 0:x.content,canLike:n,createdAt:(x==null?void 0:x.time)||"",slugs:{question:`${e}/${t}`,answer:S},slug:S,author:{id:R==null?void 0:R.id,name:(y=R==null?void 0:R.data)==null?void 0:y.name,organization:(z=R==null?void 0:R.data)==null?void 0:z.organization,jobTitle:(ee=R==null?void 0:R.data)==null?void 0:ee.jobTitle,location:(B=R==null?void 0:R.data)==null?void 0:B.location,image:{thumbnail:((F=R==null?void 0:R.data)==null?void 0:F.thumbnail)||void 0}},userLiked:A,likes:(q==null?void 0:q.like)||0,comments:(q==null?void 0:q.reply)||0,peopleWhoLiked:$,mentions:I},links:{post:`${e}/${t}/${S}`,comments:`${e}/${t}/${S}`},gtmContext:"community",functions:{content:{createContent:()=>null,deleteContent:()=>f({activityId:S}),updateContent:(L,{body:M})=>g({activityId:S,content:M})},likes:{createLike:()=>C({activityId:S}),deleteLike:()=>v({activityId:S,reactionId:P})},comments:{openComments:()=>null},mentions:a},isTruncated:!0,styling:{showShareLinkButton:!0},setFocus:T===w})},S)}),!p&&c.jsx(Mr,{hasNextPage:h,loadNextPage:E,icon:{icon:"arrow-down",position:"right"},messages:{button:o.formatMessage({id:"loadMore_button"}),error:o.formatMessage({id:"loadMore_error"})}})]})},rw={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 aw({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a,user:i}){const{mutate:s}=Ke.useMutation({mutationFn:e,onMutate:o=>t(l=>{const u=Ql({reply:qx(o),user:i});return tc(u,l,{replace:!1,append:(o==null?void 0:o.replyId)!==void 0})}),onError:n,onSuccess:(o,l,u)=>{const d=Ql({reply:o,user:i});r.setQueryData(a,tc(d,u,{replace:!0,append:(l==null?void 0:l.replyId)!==void 0})),setTimeout(()=>{Zf(d.id)},0)}});return s}function iw({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ke.useMutation({mutationFn:e,onMutate:({replyId:a,content:i})=>t(s=>{const o=Na(a,s);return o&&(o.data.content=i),s}),onError:n});return r}function Qf({queryFns:{create:e,edit:t,like:n,list:r,remove:a,unlike:i},queryKey:s}){const o=Ke.useQueryClient(),l=Ka(),u={queryClient:o,queryKey:s},d={mutationHandlers:{error:ko(u),mutate:_o(u)},user:l,...u},h=aw({...d,mutationFn:e}),p=iw({...d,mutationFn:t}),m=sw({...d,mutationFn:n}),g=uw({...d,mutationFn:a}),f=lw({...d,mutationFn:i}),{replies:C,...v}=ow({queryKey:s,queryFn:r});return{replies:C,mutations:{create:h,edit:p,remove:g,like:m,unlike:f},user:l,...v}}function sw({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=Ke.useMutation({mutationFn:e,onMutate:({replyId:s})=>t(o=>{const l=Na(s,o);return l&&Jl({reply:l}),o}),onError:n,onSuccess:(s,{replyId:o},l)=>{const u=Na(o,l);u&&Jl({reply:u,reaction:s}),r.setQueryData(a,l)}});return i}function ow({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}=Ke.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:{next:""},getNextPageParam:u=>(u==null?void 0:u.next)||null}),o=mw(n),l=`${o.length||0}${i?"+":""}`;return{replies:o,repliesCount:l,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}}function uw({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ke.useMutation({mutationFn:e,onMutate:({replyId:a})=>t(i=>hw(a,i)),onError:n});return r}function lw({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=Ke.useMutation({mutationFn:e,onMutate:({replyId:i})=>t(s=>{const o=Na(i,s);return o&&Wx({reply:o,user:r}),s}),onError:n});return a}function cw(e){return{pages:[{next:"",results:[e]}],pageParams:[""]}}function dw(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 fw(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 tc(e,t,n){return t?n!=null&&n.append?dw(e,t,n):fw(e,t,n):cw(e)}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 hw(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 mw(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 pw=({basePath:e,parentId:t,activityId:n,replyId:r,isMember:a,functions:i})=>{const s=ue.useIntl(),o=3,{replies:l,fetchNextPage:u,hasNextPage:d,isLoading:h,mutations:{create:p,edit:m,like:g,remove:f,unlike:C},user:v}=Qf({queryKey:[e,t,n,r,"replies"],queryFns:{...i,list:E=>i.list({...E,reactionId:r})}});Is([h]);const[w,_]=D.useState(!0);return c.jsxs(c.Fragment,{children:[(l==null?void 0:l.length)>=o&&c.jsx(Ae,{className:"nested-replies-show-toggle",variant:"secondary",size:"small",icon:{icon:`arrow_corner-${w?"up_left":"down_right"}`,position:"left"},onClick:()=>_(!w),children:s.formatMessage({id:`discussion_thread_${w?"hide":"show"}`},{count:l==null?void 0:l.length})}),w&&c.jsx(Hf,{loadMore:{isLoading:h,hasNextPage:d,loadNextPage:()=>u()},form:{content:{type:"reply",slugs:{question:`${e}/${t}`,answer:n,reply:r}},functions:{create:(E,{body:x})=>p({activityId:n,replyId:r,content:x}),listMembers:i.listMembers},meta:{isEditing:!1,isAutoFocused:!0,isPrepopulated:!1,showSuccessMessage:!1}},children:l&&l.length>0?l==null?void 0:l.map(E=>{var se,H,y,z,ee,B,F,L,M,V,ne,te;const{id:x,own_children:T,latest_children:S,children_counts:W,data:{mentioned_users:O}}=E,I=(((se=T==null?void 0:T.like)==null?void 0:se.length)||0)>0?(H=T==null?void 0:T.like)==null?void 0:H.find(re=>{var de;return((de=re==null?void 0:re.user)==null?void 0:de.id)===(v==null?void 0:v.id)}):!1,k=I?I==null?void 0:I.id:"",A=!!I,$=(((y=S==null?void 0:S.like)==null?void 0:y.length)||0)>0?(z=S==null?void 0:S.like)==null?void 0:z.map(re=>{var de,Q,be;return{id:(de=re==null?void 0:re.user)==null?void 0:de.id,name:(be=(Q=re==null?void 0:re.user)==null?void 0:Q.data)==null?void 0:be.name}}):!1,R=E==null?void 0:E.user,U=typeof E.data.content=="string"?(ee=E==null?void 0:E.data)==null?void 0:ee.content:((F=(B=E==null?void 0:E.data)==null?void 0:B.content)==null?void 0:F.text)||"";return c.jsx(Lr,{isCommunity:!0,content:{id:x,type:"reply",body:U,canLike:a,createdAt:E==null?void 0:E.created_at,slugs:{question:`${e}/${t}`,answer:n,reply:E==null?void 0:E.parent},slug:"",author:{id:R==null?void 0:R.id,name:(L=R.data)==null?void 0:L.name,organization:(M=R.data)==null?void 0:M.organization,jobTitle:(V=R.data)==null?void 0:V.jobTitle,location:(ne=R.data)==null?void 0:ne.location,image:{thumbnail:((te=R.data)==null?void 0:te.thumbnail)||void 0}},userLiked:A,likes:(W==null?void 0:W.like)||0,peopleWhoLiked:$,mentions:O},functions:{content:{createContent:()=>null,deleteContent:()=>f({replyId:x}),updateContent:(re,{body:de})=>m({replyId:x,content:de})},likes:{createLike:()=>g({replyId:x}),deleteLike:()=>C({replyId:x,reactionId:k})},comments:{},mentions:{listMembers:i.listMembers}},styling:{showShareLinkButton:!0}},x)}):null})]})};const Jf=({basePath:e,parentId:t,activityId:n,isMember:r,functions:{reactions:a,mentions:i,join:s,leave:o}})=>{const l=ue.useIntl(),{replies:u,repliesCount:d,fetchNextPage:h,hasNextPage:p,isLoading:m,mutations:{create:g,edit:f,like:C,remove:v,unlike:w},user:_}=Qf({queryKey:[e,t,n,"replies"],queryFns:a}),E=()=>{T(u.length),h()},[x,T]=D.useState(null);return Is([m]),Yf(),c.jsxs("section",{className:"replies-feed",children:[c.jsx(Wf,{type:"comment",responses:d,isLoading:m}),c.jsx(Eo,{form:{content:{type:"reply",slugs:{}},functions:{create:(S,{body:W})=>g({activityId:n,content:W}),...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,W)=>{var ee,B,F,L,M,V,ne,te,re,de,Q,be;const{id:O,own_children:q,latest_children:I,children_counts:k,data:{mentioned_users:A}}=S,$=(((ee=q==null?void 0:q.like)==null?void 0:ee.length)||0)>0?(B=q==null?void 0:q.like)==null?void 0:B.find(he=>{var Ee;return((Ee=he==null?void 0:he.user)==null?void 0:Ee.id)===(_==null?void 0:_.id)}):!1,R=$?$==null?void 0:$.id:"",U=!!$,H=(((F=I==null?void 0:I.like)==null?void 0:F.length)||0)>0?(L=I==null?void 0:I.like)==null?void 0:L.map(he=>{var Ee,ke,De;return{id:(Ee=he==null?void 0:he.user)==null?void 0:Ee.id,name:(De=(ke=he==null?void 0:he.user)==null?void 0:ke.data)==null?void 0:De.name}}):!1,y=S==null?void 0:S.user,z=typeof S.data.content=="string"?(M=S==null?void 0:S.data)==null?void 0:M.content:((ne=(V=S==null?void 0:S.data)==null?void 0:V.content)==null?void 0:ne.text)||"";return c.jsx(zf,{children:c.jsx(Lr,{isCommunity:!0,content:{id:O,type:"reply",body:z,canLike:r,createdAt:S==null?void 0:S.created_at,slugs:{question:`${e}/${t}`,answer:n,reply:O},slug:O,author:{id:y==null?void 0:y.id,name:(te=y.data)==null?void 0:te.name,organization:(re=y.data)==null?void 0:re.organization,jobTitle:(de=y.data)==null?void 0:de.jobTitle,location:(Q=y.data)==null?void 0:Q.location,image:{thumbnail:((be=y.data)==null?void 0:be.thumbnail)||void 0}},userLiked:U,likes:(k==null?void 0:k.like)||0,peopleWhoLiked:H,mentions:A},functions:{content:{createContent:()=>null,deleteContent:()=>v({replyId:O}),updateContent:(he,{body:Ee})=>f({replyId:O,content:Ee})},likes:{createLike:()=>C({replyId:O}),deleteLike:()=>w({replyId:O,reactionId:R})},comments:{},mentions:i},children:c.jsx(pw,{basePath:e,parentId:t,activityId:n,replyId:O,isMember:r,functions:{...a,...i}}),styling:{showShareLinkButton:!0},setFocus:W===x},O)},O)}),!m&&c.jsx(Mr,{hasNextPage:p,loadNextPage:E,icon:{icon:"arrow-down",position:"right"},messages:{button:l.formatMessage({id:"loadMore_button"}),error:l.formatMessage({id:"loadMore_error"})}})]})};function gw({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=Ke.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 vw({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:a,isFetching:i}=Ke.useQuery({queryFn:e,queryKey:t});return{activity:n,error:r,isLoading:a,isFetching:i}}function bw({queryFns:{read:e,edit:t,like:n,unlike:r},queryKey:a}){const i=Ke.useQueryClient(),s=Ka(),o={queryClient:i,queryKey:a},l={mutationHandlers:{error:ko(o),mutate:_o(o)},user:s,...o},u=gw({...l,mutationFn:t}),d=yw({...l,mutationFn:n}),h=Dw({...l,mutationFn:r}),{activity:p,...m}=vw({queryKey:a,queryFn:e});return{activity:p,mutations:{edit:u,like:d,unlike:h},user:s,...m}}function yw({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=Ke.useMutation({mutationFn:e,onMutate:s=>t(o=>(o&&Oa({activity:o}),o)),onError:n,onSuccess:(s,o,l)=>{l&&Oa({activity:l,reaction:s}),r.setQueryData(a,l)}});return i}function Dw({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=Ke.useMutation({mutationFn:e,onMutate:i=>t(s=>(s&&Kf({activity:s,user:r}),s)),onError:n});return a}const Cw=({basePath:e,parentId:t,activityId:n,isMember:r,functions:{activities:{remove:a,...i},reactions:s,mentions:o,join:l,leave:u}})=>{var O,q,I,k,A,P,$,R,U,se;const d=ue.useIntl(),{activity:h,error:p,isLoading:m,mutations:{edit:g,like:f,unlike:C}}=bw({queryFns:i,queryKey:[e,t,n]});if(m)return c.jsx(Et,{style:{height:"400px"}});if(p||!h)return c.jsx(on,{variant:"error",text:d.formatMessage({id:"activitySection_notFoundError"})});const{own_reactions:v,latest_reactions:w,mentioned_users:_}=h,E=(((O=w==null?void 0:w.like)==null?void 0:O.length)||0)>0,x=(((q=v==null?void 0:v.like)==null?void 0:q.length)||0)>0,T=x?v==null?void 0:v.like[0].id:"",S=E?(I=w==null?void 0:w.like)==null?void 0:I.map(H=>{var y,z,ee;return{id:(y=H==null?void 0:H.user)==null?void 0:y.id,name:(ee=(z=H==null?void 0:H.user)==null?void 0:z.data)==null?void 0:ee.name}}):!1,W=h==null?void 0:h.actor;return c.jsxs("section",{className:"activity-section",children:[c.jsx(Lr,{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:W.id,name:(k=W.data)==null?void 0:k.name,organization:(A=W.data)==null?void 0:A.organization,jobTitle:(P=W.data)==null?void 0:P.jobTitle,location:($=W.data)==null?void 0:$.location,image:{thumbnail:((R=W.data)==null?void 0:R.thumbnail)||void 0}},userLiked:x,likes:((U=h==null?void 0:h.reaction_counts)==null?void 0:U.like)||0,comments:((se=h==null?void 0:h.reaction_counts)==null?void 0:se.reply)||0,peopleWhoLiked:S,mentions:_},originalAuthorId:W==null?void 0:W.id,forceHide:{comments:!0},functions:{content:{createContent:()=>null,deleteContent:a,updateContent:(H,{title:y,body:z})=>g({title:y,content:z})},likes:{createLike:()=>f({activityId:n}),deleteLike:()=>C({activityId:n,reactionId:T})},comments:{openComments:()=>{}},mentions:o},styling:{showShareLinkButton:!0}},n),c.jsx(Jf,{basePath:e,parentId:t,activityId:n,isMember:r,functions:{reactions:s,mentions:o,join:l,leave:u}})]})};var Ps={exports:{}},aa={exports:{}},Ne={};/** @license React v16.13.1
|
|
137
137
|
* react-is.production.min.js
|
package/index.mjs
CHANGED
|
@@ -19946,7 +19946,7 @@ const Kn = "footer_", Pa = "SiteFooter", Hl = ({ group: e }) => {
|
|
|
19946
19946
|
order: ["login", "signup"],
|
|
19947
19947
|
login: { href: "/user-onboarding/login" },
|
|
19948
19948
|
signup: {
|
|
19949
|
-
href: "/signup
|
|
19949
|
+
href: "/signup?ref=header-banner",
|
|
19950
19950
|
props: { variant: "primary" }
|
|
19951
19951
|
}
|
|
19952
19952
|
}
|