@apolitical/component-library 8.4.3 → 8.4.4-ST.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 +2 -2
- package/index.mjs +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -159,7 +159,7 @@ ${p}${d?"1.":"-"} ${u}${f?`
|
|
|
159
159
|
|
|
160
160
|
`.substring(0,i);return n+a+r}function JP(e){return e!=null&&(typeof e=="string"||e.nodeType&&(e.nodeType===1||e.nodeType===9||e.nodeType===11))}var eR={isHistory(e){return tn(e)&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(e.redos.length===0||zi.isOperationList(e.redos[0].operations))&&(e.undos.length===0||zi.isOperationList(e.undos[0].operations))}},Od=new WeakMap,Nd=new WeakMap,ps={isHistoryEditor(e){return eR.isHistory(e.history)&&O.isEditor(e)},isMerging(e){return Nd.get(e)},isSaving(e){return Od.get(e)},redo(e){e.redo()},undo(e){e.undo()},withoutMerging(e,t){var n=ps.isMerging(e);Nd.set(e,!1),t(),Nd.set(e,n)},withoutSaving(e,t){var n=ps.isSaving(e);Od.set(e,!1),t(),Od.set(e,n)}},tR=e=>{var t=e,{apply:n}=t;return t.history={undos:[],redos:[]},t.redo=()=>{var{history:r}=t,{redos:i}=r;if(i.length>0){var a=i[i.length-1];a.selectionBefore&&le.setSelection(t,a.selectionBefore),ps.withoutSaving(t,()=>{O.withoutNormalizing(t,()=>{for(var s of a.operations)t.apply(s)})}),r.redos.pop(),t.writeHistory("undos",a)}},t.undo=()=>{var{history:r}=t,{undos:i}=r;if(i.length>0){var a=i[i.length-1];ps.withoutSaving(t,()=>{O.withoutNormalizing(t,()=>{var s=a.operations.map(zi.inverse).reverse();for(var o of s)t.apply(o);a.selectionBefore&&le.setSelection(t,a.selectionBefore)})}),t.writeHistory("redos",a),r.undos.pop()}},t.apply=r=>{var{operations:i,history:a}=t,{undos:s}=a,o=s[s.length-1],l=o&&o.operations[o.operations.length-1],u=ps.isSaving(t),c=ps.isMerging(t);if(u==null&&(u=rR(r)),u){if(c==null&&(o==null?c=!1:i.length!==0?c=!0:c=nR(r,l)),o&&c)o.operations.push(r);else{var d={operations:[r],selectionBefore:t.selection};t.writeHistory("undos",d)}for(;s.length>100;)s.shift();a.redos=[]}n(r)},t.writeHistory=(r,i)=>{t.history[r].push(i)},t},nR=(e,t)=>!!(t&&e.type==="insert_text"&&t.type==="insert_text"&&e.offset===t.offset+t.text.length&&V.equals(e.path,t.path)||t&&e.type==="remove_text"&&t.type==="remove_text"&&e.offset+e.text.length===t.offset&&V.equals(e.path,t.path)),rR=(e,t)=>e.type!=="set_selection";const iR=(e,t)=>{const{apply:n}=e;try{e.apply=r=>{if(r.type==="remove_node"&&"type"in r.node&&r.node.type===ne.link){const i=r.node;if(i.link){const a=new CustomEvent("linkRemoved",{detail:{url:i.link}});window.dispatchEvent(a)}}n(r)}}catch(r){const i=r.message;t(`Error in withLinkRemovalListener: ${i}`)}return e};var aR=uR,sR=/^(?:\w+:)?\/\/(\S+)$/,oR=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,lR=/^[^\s\.]+\.\S{2,}$/;function uR(e){if(typeof e!="string")return!1;var t=e.match(sR);if(!t)return!1;var n=t[1];return n?!!(oR.test(n)||lR.test(n)):!1}const cR=_r(aR),dR=(e,t,n)=>{const{insertText:r,isInline:i}=e;try{e.isInline=a=>{const s=a;return[ne.link].includes(s.type)||i(a)},e.insertText=a=>{a&&cR(a)?am(e,a,t):r(a)}}catch(a){const s=a.message;n(`Error in withInlines: ${s}`)}return e},fR=(e,t)=>{const{isInline:n,isVoid:r,markableVoid:i}=e;try{e.isInline=a=>a.type===ne.mention?!0:n(a),e.isVoid=a=>a.type===ne.mention?!0:r(a),e.markableVoid=a=>a.type===ne.mention||i(a)}catch(a){const s=a.message;t(`Error in withMentions: ${s}`)}return e},hR=(e,t)=>{const{normalizeNode:n}=e;try{e.normalizeNode=([r,i])=>{if(r.type===ne.link&&Ee.string(r).trim()===""){le.removeNodes(e,{at:i});return}n([r,i])}}catch(r){const i=r.message;t(`Error in withoutEmptyLinks: ${i}`)}return e};const um=({id:e="rich-text-editor",value:t,placeholder:n,maxLength:r=0,meta:i,functions:a,autoFocus:s,data:o,styling:l,...u})=>{const c=he.useIntl(),d=hx();typeof s>"u"&&(s=!0);const{isInOverlay:f=!1}=i||{},{listMembers:p,clickMentionFallback:g,onChange:m=()=>{},onChangeData:E=()=>{},getLinkPreview:v=()=>Promise.resolve({}),onMention:b=()=>{},reportError:T=z=>{console.error(z)}}=a||{},C=[{type:ne.paragraph,children:[{text:""}]}];t==="<br>"&&(t="");const _={editorKey:null,originalValue:t||"",initialValue:t?null:C,showLinkEditor:!1,mentionPopover:{show:!1,selectedUser:0,possibleUsers:[],position:null,numberOfUsers:null},lastAnchor:null,stringValue:"",lastKey:null,hasInteracted:!1,hasLoaded:!1,enrichedUrl:!1},[x,S]=y.useReducer(Us,_),{editorKey:F,originalValue:R,initialValue:L,stringValue:P,lastAnchor:I,lastKey:k,hasInteracted:B,hasLoaded:H,enrichedUrl:q,mentionPopover:N}=x,J=async z=>{const U=await v(z);U.url&&S([{type:"enrichedUrl",value:U}])},X=`rte-${e}`,D=y.useCallback(z=>h.jsx(G6,{...z}),[]),A=y.useCallback(z=>h.jsx(Y6,{...z}),[]),Z=y.useMemo(()=>iR(dR(fR(hR(tR(FO(Lk())),T),T),X,T),T),[]),M=z=>{if(!Z||z!==X)return;const U=O.end(Z,[]);le.select(Z,U),ce.focus(Z)};y.useEffect(()=>{const z=U=>{var Y;const $=U,ae=((Y=$==null?void 0:$.detail)==null?void 0:Y.id)||null;ae&&M(ae)};return window.addEventListener("focusEditor",z),()=>{window.removeEventListener("focusEditor",z)}},[]),y.useEffect(()=>{if(Z.children.length>0&&!H){if(S([{type:"hasLoaded",value:!0}]),!s)return;M(X)}},[Z.children.length,L]),y.useEffect(()=>{R&&(async()=>{let U=tr(R);if(U.endsWith("<br/>")&&(U=U.slice(0,-5)),U.includes("<")){pl.prototype.escape=ae=>ae;const $=new pl;$.addRule("br",{filter:["br"],replacement:ae=>ae+`
|
|
161
161
|
|
|
162
|
-
`}),U=$.turndown(U)}o&&o.mentions&&(U=await l4({text:U,template:`[${Ah}{{name}}]({{id}})`,mentions:o.mentions,listMembers:p||(()=>Promise.resolve([]))})),cP(U,$=>{const ae=[{type:"initialValue",value:$},{type:"editorKey",value:R.toString()}];o!=null&&o.link&&(ae.push({type:"enrichedUrl",value:o.link}),o.link.url&&J(o.link.url)),S(ae),setTimeout(()=>{S([{type:"stringValue",value:o9(Z)}])},150)})})()},[R]),y.useEffect(()=>{if(q===void 0&&Z){const U=hP(Z);U&&J(U)}const z=U=>{var Y;const $=U,ae=((Y=$==null?void 0:$.detail)==null?void 0:Y.url)||null;ae&&q&&q.url===ae&&S([{type:"enrichedUrl",value:void 0}])};return window.addEventListener("linkRemoved",z),()=>{window.removeEventListener("linkRemoved",z)}},[q]),y.useEffect(()=>{if(t){al.lastIndex=0;const z=t.match(al);z&&z.length===1&&z[0].length===t.length&&!B&&S([{type:"originalValue",value:t}])}t!==""||!Z||vc(R,t)&&!B||(O.withoutNormalizing(Z,()=>{le.delete(Z,{at:{anchor:O.start(Z,[]),focus:O.end(Z,[])}}),le.deselect(Z),Z.children.length!==0&&le.unwrapNodes(Z,{at:[0]}),le.insertNodes(Z,C,{at:[0]})}),S([{type:"initialValue",value:C},{type:"lastAnchor",value:null},{type:"enrichedUrl",value:!1}]))},[t]),y.useEffect(()=>{E({link:q})},[q]),y.useEffect(()=>{P===""&&q&&S([{type:"enrichedUrl",value:void 0}])},[P]);const j=rl(()=>{mP({editor:Z,isShowing:N.show,numberOfUsers:N.numberOfUsers,listMembers:p,dispatch:S})},100);return L?h.jsx("div",{id:X,className:"rich-text-editor input text-medium",children:h.jsxs(_i.Provider,{value:{...x,id:X,isInOverlay:f,dispatch:S,onMention:b,reportError:T},children:[h.jsxs(PO,{editor:Z,initialValue:L,onChange:z=>{if(Z.operations.some($=>$.type!=="set_selection")){let $=vP(z);$==="<br>"&&($=""),m($,q),S([{type:"stringValue",value:o9(Z)}]),B||S([{type:"hasInteracted",value:!0}]),j(),d&&console.log({serialized:$,json:z})}},...u,children:[h.jsx(xO,{className:"editor",renderElement:D,renderLeaf:A,placeholder:n||c.formatMessage({id:"richTextEditor_placeholder"}),autoFocus:s,tabIndex:0,onPaste:async z=>{const U=q!==!1,$=z.clipboardData.getData("text");if((Y=>{try{return new URL(Y),!0}catch{return!1}})($)){let Y=$;if($){const{full:te}=mp($);Y=te}if($&&v&&!U){const te=await v(Y);te.url&&S([{type:"enrichedUrl",value:te}])}}},onKeyDown:z=>{if(z.key==="Enter"){N.show&&(z.preventDefault(),z.stopPropagation(),gT(Z,N,S,X));const{selection:U}=Z;if(U){const $=oe.isCollapsed(U),[ae,Y]=O.node(Z,U,{depth:1});let te=ae,se=te.type;const re=te.children[0];if(se===ne.h3){z.preventDefault(),z.stopPropagation();const xe=O.start(Z,Y),ke=O.end(Z,Y),Te=Ge.equals(U.anchor,xe),ue=Ge.equals(U.anchor,ke);if(Te)le.insertNodes(Z,C,{at:Y});else if(ue)le.insertNodes(Z,C,{at:V.next(Y)}),le.select(Z,O.end(Z,V.next(Y)));else{const fe=U.anchor,[,we]=O.parent(Z,U);le.splitNodes(Z,{at:fe}),le.setNodes(Z,{type:ne.paragraph},{at:V.next(we)})}return}if(re&&[ne.ol,ne.ul].includes(re.type)&&(te=re,se=re.type),te&&Se.isElement(te)&&se!==ne.paragraph){if(se===ne.blockquote&&!z.shiftKey){z.stopPropagation(),z.preventDefault(),le.insertNodes(Z,C);return}if($){const[xe,ke]=O.parent(Z,U,{edge:"end"}),ue=xe.type;if([ne.ul,ne.ol].includes(se))if(z.stopPropagation(),z.preventDefault(),ue===ne.li&&k==="Enter"){xe.children.length===1&&"text"in xe.children[0]&&xe.children[0].text===""&&le.removeNodes(Z,{at:ke}),le.insertNodes(Z,C,{at:V.next(Y)}),le.select(Z,O.end(Z,V.next(Y)));return}else{const[fe,we]=dP(Z,ne.li),Ie={type:ne.li,children:[{text:""}]};le.insertNodes(Z,Ie,{at:V.next(we)}),le.select(Z,O.end(Z,V.next(we)))}}}}}else if(z.key==="Escape"){if(N.show){z.preventDefault(),z.stopPropagation(),S([{type:"mentionPopover",value:{...N,show:!1}}]);return}}else if(["ArrowUp","ArrowDown"].includes(z.key)&&N.show){z.preventDefault(),z.stopPropagation();const{selectedUser:U,possibleUsers:$}=N;let ae=z.key==="ArrowUp"?U-1:U+1;ae<0&&(ae=$.length-1),ae>=$.length+1&&(ae=0),S([{type:"mentionPopover",value:{...N,selectedUser:ae}}])}S([{type:"lastKey",value:z.key}]),pP(z,Z,S,T)},onBlur:()=>{Z.selection&&S([{type:"lastAnchor",value:Z.selection.anchor}])},onFocus:()=>{if(I){if(!V.isPath(I.path)||!Ee.has(Z,I.path))return;const z=Ee.get(Z,I.path);let U=0;if(De.isText(z)?U=z.text.length:z.children&&(U=z.children.length),I.offset>U)return;try{le.select(Z,{anchor:I,focus:I})}catch($){const ae=$.message;T(`Error focusing editor: ${ae}`)}}}}),q?h.jsx(cm,{data:q,variant:"condensed",onClick:()=>{S([{type:"enrichedUrl",value:!1}]);const z=new CustomEvent("ariaLive",{detail:{message:c.formatMessage({id:"richTextEditor_link_enrichedUrl_aria_live"})}});document.dispatchEvent(z)},"aria-label":c.formatMessage({id:"richTextEditor_link_enrichedUrl_aria"},{title:q.title||c.formatMessage({id:"richTextEditor_link_enrichedUrl_aria_fallback"})})}):h.jsx(h.Fragment,{}),h.jsx(kP,{styling:l==null?void 0:l.toolbar}),p?h.jsx(EP,{onFallbackClick:g}):h.jsx(h.Fragment,{})]},F),h.jsx(Fp,{id:`character-limit-${e}`,limit:r,valueLength:t1(P)})]})}):h.jsx(h.Fragment,{})};const pR=({id:e="form-toggle",label:t,options:n,initialValue:r,functions:{onChange:i=()=>{}},isDisabled:a=!1,className:s=""})=>{const[o,l]=y.useState(typeof r=="boolean"||typeof r=="string"?r:n[0].value);y.useEffect(()=>{r&&l(r)},[r]);const u=c=>{a||(l(c),i(c))};return h.jsxs("div",{className:ee("toggle",s),onClick:c=>{c.preventDefault(),c.stopPropagation(),u(o===n[0].value?n[1].value:n[0].value)},children:[h.jsx("p",{children:t}),h.jsx("ul",{className:ee("toggle-options",{disabled:a,on:o===n[1].value}),children:n.map(c=>{const d=`${e}-${c.value}`;return h.jsxs("li",{className:"hidden",children:[h.jsx("input",{type:"radio",id:d,name:e,value:c.value,checked:o===c.value,onChange:()=>u(c.value),disabled:a}),h.jsx("label",{htmlFor:d,children:c.label})]},d)})})]})};function NT({className:e="",userId:t,userName:n,src:r,uploadImage:i,button:a,callback:s}){const o=he.useIntl(),l="profileImageChange_",[u,c]=y.useState(r),[d,f]=y.useState(!1),[p,g]=y.useState(!1),m=y.useRef(null),E=async C=>{f(!0),g(!1);try{const _=C.target.files&&C.target.files[0];if(!_||!t)throw f(!1),new Error("Image file or userID is missing");const x=await i({fileObject:_,userId:t}),S={thumbnail:x.thumbnailURL,full:x.originalURL};c(S),s(S)}catch{g(!0)}finally{f(!1)}f(!1)},{upload:v=o.formatMessage({id:`${l}cta_upload`}),change:b=o.formatMessage({id:`${l}cta_change`}),uploading:T=o.formatMessage({id:`${l}cta_uploading`})}=(a==null?void 0:a.text)||{};return h.jsxs("div",{className:ee("profile-image-change-figure",e),children:[h.jsx(bi,{className:"profile-image-change-picture",name:n,src:u==null?void 0:u.thumbnail,showInitials:!1,alt:"","data-testid":"profile-picture"}),p&&h.jsx("p",{className:"error text-small",children:o.formatMessage({id:`${l}error`})}),h.jsx("input",{id:"file",type:"file",accept:"image/*",ref:m,onChange:E,hidden:!0,"data-testid":"file-input"}),h.jsx(Me,{onClick:()=>m.current&&m.current.click(),variant:"secondary","data-gtm-event-context":"ImageField","data-gtm-event-type":`${u?"change-photo":"add-photo"}-click`,className:"gtm-trackable",disabled:d,children:d?T:u?b:v})]})}const IT=({gtm:e,functions:{onSuccess:t=async()=>{},onFailure:n=()=>{}}})=>{const{context:r="FooterContactUsForm",event:i="contact-form-submit-click"}=e||{};return h.jsx(Cr,{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:i},functions:{onSuccess:t,onFailure:n},button:{className:"new"}})};const mR=({emails:e,setEmails:t,setIsDisabled:n})=>{const{formatMessage:r}=he.useIntl();return h.jsx(G3.ReactMultiEmail,{id:"email-input",inputClassName:"email-input input",placeholder:r({id:"inviteForm_email_placeholder"}),emails:e,onChange:i=>{t(i),n(!i.length)},autoFocus:!1,getLabel:(i,a,s)=>h.jsxs("div",{className:"email text-medium",children:[h.jsx("div",{"data-tag-item":!0,children:i}),h.jsx(Me,{variant:"tertiary",size:"small",icon:{icon:"close"},onClick:()=>{s(a),n(!e.length)},className:"remove-email-button",screenreaderText:r({id:"overlay_close"})})]},a)})},PT=({title:e,label:t,messagePlaceholder:n,ctaMessage:r,titleColor:i,labelColor:a,backgroundColor:s,onClose:o,reportError:l,sendInvites:u,initialFormStatus:c="NOT_SUBMITTED",gtm:d={context:"Form",event:"form-submit-click"},secondaryActionButton:f,meta:p})=>{const[g,m]=y.useState([]),[E,v]=y.useState(!0),[b,T]=y.useState(c),{formatMessage:C}=he.useIntl(),_=async F=>{try{await u(g,F.message),m([]),T("SUCCESS")}catch(R){T("ERROR"),l(R)}},x=F=>{F.preventDefault(),T("NOT_SUBMITTED"),v(!0),m([])},S=F=>{F.preventDefault(),o(),T("CLOSED")};return b==="CLOSED"?null:b==="ERROR"||b==="SUCCESS"&&!(p!=null&&p.shouldHideDoneButtonOnSubmit)?h.jsxs("div",{className:"invite-form-wrapper",children:[h.jsx("div",{className:"content centred",children:b==="SUCCESS"?h.jsx("h2",{className:"success-title",children:C({id:"inviteForm_success"})}):h.jsxs("h2",{className:"error-title",children:[" ",C({id:"inviteForm_error"})]})}),h.jsx(Tr,{}),h.jsx("div",{className:"footer",children:b==="SUCCESS"?h.jsxs(h.Fragment,{children:[h.jsx(Me,{variant:"secondary",onClick:x,children:C({id:"inviteForm_ctaSendMoreInvites"})}),h.jsx(Me,{onClick:S,children:C({id:"inviteForm_ctaDone"})})]}):h.jsx(Me,{onClick:x,children:C({id:"inviteForm_ctaTryAgain"})})})]}):h.jsxs("div",{className:"invite-form-wrapper",style:{backgroundColor:s},children:[h.jsxs("div",{className:"content",children:[h.jsx("h2",{className:"title",style:{color:i},children:e}),h.jsx("label",{htmlFor:"email-input",className:"label",style:{color:a},children:t})]}),h.jsx(Cr,{id:"invite-form",fields:[{component:mR,props:{emails:g,setEmails:m,setIsDisabled:v},required:!0},{id:"message",type:"textarea",label:C({id:"inviteForm_message_label"}),placeholder:n||C({id:"inviteForm_message_placeholder"})}],functions:{onSuccess:_},button:{text:r,size:"medium",disabled:E},gtm:d,meta:p,secondaryActionButton:f})]})},tc=e=>e.map(t=>({condition:t}));const Vn={FORM_ID:"manage-account-password-change",NEW_PASSWORD:"newPassword",CONFIRMED_PASSWORD:"confirmedPassword",CURRENT_PASSWORD:"oldPassword"},gR=({functions:e,...t})=>{const{formatMessage:n}=he.useIntl(),[r,i]=y.useState(null),[a,s]=y.useState(!1),[o,l]=y.useState({isMoreThanEightCharacters:!1,includesNumberAndSymbol:!1,includesLowerAndUppercase:!1}),u=p=>p[Vn.NEW_PASSWORD]!==p[Vn.CONFIRMED_PASSWORD]?n({id:"passwordRules_unmatched_text"}):null,c=p=>!ih(p[Vn.NEW_PASSWORD]).isValid,d=[{"data-testid":Vn.NEW_PASSWORD,id:Vn.NEW_PASSWORD,type:"password",autoComplete:"new-password",placeholder:"",label:n({id:"passwordRules_newPassword_label"}),validation:tc(["required",c]),functions:{onChange:p=>l(ih(p).matchingRules),onFocus:()=>s(!0),onBlur:()=>s(!1)}},{"data-testid":Vn.CONFIRMED_PASSWORD,id:Vn.CONFIRMED_PASSWORD,type:"password",autoComplete:"new-password",placeholder:"",label:n({id:"passwordRules_confirmPassword_label"}),validation:tc(["required",u])}];t.isPasswordChange&&d.unshift({"data-testid":Vn.CURRENT_PASSWORD,id:Vn.CURRENT_PASSWORD,type:"password",autoComplete:"current-password",placeholder:"",label:n({id:"passwordRules_currentPassword_label"}),validation:tc(["required"])}),a&&d.push({component:sb,props:{matchingRules:o}});const f={id:Vn.FORM_ID,fields:d,functions:{...e,onSuccess:async p=>(e.createPassword(p),e.onSuccess&&e.onSuccess(p)),onCatch:p=>i(p==null?void 0:p.statusCode),onFailure:(p,g)=>{(g.includes(Vn.NEW_PASSWORD)||g.includes(Vn.CONFIRMED_PASSWORD))&&s(!0)}},meta:{shouldReset:!0},...t};return h.jsxs(h.Fragment,{children:[h.jsx(Cr,{...f}),r&&h.jsx(Wr,{variant:"error",text:r})]})};const RT=({isCreateProfile:e=!1,hooks:t,functions:n,meta:r={},gtm:i,...a})=>{var F;const s=he.useIntl(),o="profileForm_",l=y.useContext(Mt),[u,c]=y.useState(l.image),[d,f]=y.useState(!1),{uploadImage:p=()=>{},onSuccess:g=async R=>{},onCancel:m=()=>{},onFailure:E=()=>{}}=n,{buildLocation:v,isValidPlace:b,predictPlaces:T}=t.useMaps(),{context:C="ProfileForm",event:_="profile-form-submit-click"}=i||{},x=[{id:"jobTitle",type:"text",label:s.formatMessage({id:`${o}jobTitle`}),placeholder:s.formatMessage({id:`${o}jobTitle_placeholder`}),value:l.jobTitle,validation:[{condition:"required"}]},{id:"organization",type:"text",label:s.formatMessage({id:`${o}organization`}),placeholder:s.formatMessage({id:`${o}organization_placeholder`}),value:l.organization,validation:[{condition:"required"}]},{id:"location",type:"autocomplete",label:s.formatMessage({id:`${o}location`}),placeholder:s.formatMessage({id:`${o}location_placeholder`}),value:(F=l.location)==null?void 0:F.en,validation:[{condition:"required"},{condition:({location:R})=>R&&!d?!1:!b(R),error:s.formatMessage({id:`${o}location_error`})}],functions:{onChange:()=>{d||f(!0)},onKeyInput:T}}],S=[{component:NT,props:{userName:l.name,userId:l.id,src:u,uploadImage:p,callback:c,button:{text:{upload:s.formatMessage({id:`${o}image`})}}}},{id:"name",type:"text",label:s.formatMessage({id:`${o}name`}),placeholder:s.formatMessage({id:`${o}name_placeholder`}),value:l.name,autoComplete:"name",validation:[{condition:"required"}]},...x,{id:"biography",type:"textarea",label:s.formatMessage({id:`${o}bio`}),placeholder:s.formatMessage({id:`${o}bio_placeholder`}),limit:1e3,value:l.biography},{component:Tr}];return h.jsx(Cr,{id:"profile-details-form",fields:e?x:S,meta:{shouldShowCancelButton:!e,shouldReset:!1,shouldHide:!1,showRequiredLabels:e,...r},intlPath:o,gtm:{context:C,event:_},functions:{onSuccess:async R=>{try{const L={...R,image:u||null,location:d?await v(R==null?void 0:R.location):l.location,...e?{onboardingState:"completed"}:{}};l.updateDetails&&l.updateDetails(P=>({...P,...L})),await g(L)}catch{E()}},onCancel:m,onFailure:E},button:{size:"large",text:{default:s.formatMessage({id:`${o}cta`}),submitting:s.formatMessage({id:`${o}cta_submitting`}),submitted:s.formatMessage({id:`${o}cta_submitted`})}},...a})},vR=()=>{const e=he.useIntl(),[t,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>{n(i=>{if(i>=95)return clearInterval(r),95;const a=Math.round(Math.random()*10);return Math.min(i+a,95)})},800);return()=>{clearInterval(r)}},[]),h.jsx(k4,{progress:t,steps:{0:{icon:"layers",text:e.formatMessage({id:"publishArticleForm_progressBar"})}}})};function ER({coverImage:e,setShowImagePicker:t}){return e&&e.url?h.jsx(Wr,{className:"cover-image-preview",text:h.jsx(Zi,{className:"cover-image",image:{description:e.description||"",height:e.height,width:e.width,url:e.url,color:e.color,type:"image/jpeg"}}),button:{component:h.jsx(Me,{variant:"tertiary",onClick:()=>t(!0),children:h.jsx(he.FormattedMessage,{id:"publishArticleForm_replaceImage_button"})})}}):h.jsx(Wr,{button:{component:h.jsx(Me,{variant:"secondary",onClick:()=>t(!0),children:h.jsx(he.FormattedMessage,{id:"publishArticleForm_selectImage_button"})})}})}var FT=(e=>(e.CitiesAndLocalGovernment="topic_CitiesAndLocalGovernment",e.Climate="topic_Climate",e.DigitalAndData="topic_DigitalAndData",e.Education="topic_Education",e.EquityJusticeAndInclusion="topic_EquityJusticeAndInclusion",e.HealthAndSocialCare="topic_HealthAndSocialCare",e.Innovation="topic_Innovation",e.LeadershipAndSkills="topic_LeadershipAndSkills",e.LifeInGovernment="topic_LifeInGovernment",e.Policymaking="topic_Policymaking",e.TransportAndInfrastructure="topic_TransportAndInfrastructure",e.WorkingAndTheEconomy="topic_WorkAndTheEconomy",e))(FT||{});let Id=null;const Ut="publishArticleForm_",p9={},m9=10,yR=({id:e="publish-article-form",values:t=p9,setShowImagePicker:n,functions:r,meta:i,gtm:a,isEditMode:s=!1})=>{var P;const o=he.useIntl(),l=y.useContext(Mt),{create:u,edit:c,onSuccess:d=()=>{},onFailure:f=()=>{}}=r||{},{isInOverlay:p=!1}=i||{},[g,m]=y.useState(!1),[E,v]=y.useState(t.body||""),[b,T]=y.useState(!1),[C,_]=y.useState("");y.useEffect(()=>{vc(t,p9)||sl(t.body)&&t.body!==E&&t.body!==void 0&&v(t.body)},[t.body]);const x=()=>{!l||!l.id?T(o.formatMessage({id:`${Ut}error_loggedOut`})):b&&T(!1)},S=I=>({condition:k=>{const B=k[I];return!B||typeof B!="string"?!0:B.length<m9},error:o.formatMessage({id:`${Ut}error_underMinLength`},{length:m9})}),F=!!E&&sl(E),R=()=>h.jsxs(h.Fragment,{children:[h.jsx(Tr,{}),h.jsx("p",{className:"text-medium",children:o.formatMessage({id:`${Ut}disclaimer`})})]}),L=[{id:"title",type:"textarea",value:t.title||"",limit:65,label:o.formatMessage({id:`${Ut}title_label`}),placeholder:o.formatMessage({id:`${Ut}title_placeholder`}),styling:{autosizeToFit:!0},functions:{onChange:x},validation:[{condition:"required"},S("title")]},{id:"subtitle",type:"textarea",value:t.subtitle,limit:115,label:o.formatMessage({id:`${Ut}subtitle_label`}),styling:{autosizeToFit:!0},placeholder:o.formatMessage({id:`${Ut}subtitle_placeholder`}),functions:{onChange:x},validation:[{condition:"required"},S("subtitle")]},{component:Ic,props:{formID:e,label:{visible:o.formatMessage({id:`${Ut}body_label`})},showLabel:!0}},{component:um,props:{id:`${e}-input`,value:E,placeholder:o.formatMessage({id:`${Ut}body_placeholder`}),meta:{isInOverlay:p},autoFocus:!1,functions:{onChange:I=>{v(I),x()}},styling:{toolbar:{showHeadingOption:!0}},"aria-invalid":!!b,"aria-errormessage":"error-message"}},{id:"tags",label:o.formatMessage({id:`${Ut}tags_label`}),type:"checkboxes",styling:{displayOptionsAsPills:!0},options:Object.values(FT).map(I=>({id:I,label:o.formatMessage({id:`${Ut}_tags_${I}`})})),value:t.tags||[],multipleOptions:{limit:3},validation:[{condition:"required",error:o.formatMessage({id:`${Ut}tags_error_required`})},{condition:I=>{var k;return((k=I==null?void 0:I.tags)==null?void 0:k.length)>3},error:o.formatMessage({id:`${Ut}tags_error_over_three`})}]},{component:Ic,props:{formID:e,label:{visible:o.formatMessage({id:`${Ut}cover_image_label`})},showLabel:!0}},{component:ER,props:{coverImage:t.coverImage||{},setShowImagePicker:n}}];return g?L.push({component:Tr}):L.push({component:R}),h.jsxs("section",{className:"publish-article-form",children:[h.jsx(Cr,{id:e,meta:{shouldReset:!1,shouldHide:!1,showRequiredLabels:!1,shouldScrollOnSuccess:!1},functions:{onSuccess:async I=>{if(!l||!l.id||!F)return;Id&&clearTimeout(Id),m(!0);const k={...I,body:E,coverImage:t.coverImage};try{s&&c?await c(k):u&&await u(k),Id=setTimeout(()=>{_(o.formatMessage({id:`${Ut}aria_success${s?"_edit":""}`})),d(k)},500)}catch{T(o.formatMessage({id:`${Ut}error`})),_(""),f()}},onFailure:f},fields:L,intlPath:Ut,button:{variant:"primary",size:{mobile:"small",600:"medium"},"data-gtm-event-context":a==null?void 0:a.context,"data-gtm-event-type":"publish-article-click",disabled:!l||!l.id||!F||!((P=t==null?void 0:t.coverImage)!=null&&P.url),text:{default:o.formatMessage({id:`${Ut}cta_submit${s?"_edit":""}`}),submitting:o.formatMessage({id:`${Ut}cta_submitting${s?"_edit":""}`}),submitted:o.formatMessage({id:`${Ut}cta_submitted${s?"_edit":""}`})},customOnSubmit:b?h.jsx(h.Fragment,{}):h.jsx(vR,{})},gtm:a}),b&&h.jsx(Ds,{id:"error-message",className:"error",children:typeof b=="string"&&b.includes(" ")?b:o.formatMessage({id:`${Ut}error`})}),C&&h.jsx(ot,{"aria-live":"polite",showOnFocus:!1,children:C})]})};const BT=({id:e="search",className:t="",handleToggle:n=!1,defaultValue:r="",gtmContext:i="search-bar",gtmEvent:a="form-submission"})=>{const{searchIsOpen:s=!0,isDesktopVersion:o=!1}=n||{},l=he.useIntl(),u=y.useRef(null);ks(()=>{!n||o||!s||u.current&&u.current.focus()},[s]);const c=d=>{d.preventDefault(),d.stopPropagation(),!(!u.current||!u.current.value||u.current.value.length<1)&&(window.location.href=`/search?search=${encodeURIComponent(u.current.value)}`)};return h.jsx("form",{onSubmit:c,className:ee("search-form gtm-trackable",t),role:"search","data-gtm-event-context":i,"data-gtm-event-type":a,children:h.jsx("fieldset",{id:`${e}-form`,hidden:n?!s:!1,children:h.jsxs("p",{children:[h.jsx(ot,{element:"label",htmlFor:e,children:l.formatMessage({id:"search_label"})}),h.jsx("input",{ref:u,type:"search",id:e,name:e,defaultValue:r,placeholder:l.formatMessage({id:"search_placeholder"}),onKeyDown:d=>{d.key==="Enter"&&c(d)}}),h.jsx("button",{className:"clear",onClick:d=>{d.preventDefault(),d.stopPropagation(),u.current&&u.current.value&&(u.current.value="")},children:h.jsx(ot,{children:l.formatMessage({id:"search_clear"})})}),h.jsx("button",{className:"search",onClick:c,children:h.jsx(ot,{children:l.formatMessage({id:"search_cta"})})})]})})})},g9=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 i=e.current.value.toString().toLowerCase().trim(),a={valid:!1,autoApproved:!1,exists:{auth:!1,engagement:!1,registration:!1,user:!1}};let s=Object.assign({},a);try{s=await t(i),s===void 0&&(s=a)}catch{return n([{type:"shouldManuallyApprove",value:!0},{type:"emailDetails",value:{email:i,boxType:"nonGov",isEnd2End:!1}},{type:"validFields.email",value:!1}])}const{valid:o=!1,autoApproved:l=!1,exists:u}=s;let c="";return o?c=l?"gov":"nonGov":u.registration?u.engagement&&!u.user?c=u.auth?"verify":"pending":c="exists":u.auth&&(c="exists"),n([{type:"shouldDisableButton",value:!1},{type:"shouldManuallyApprove",value:!l},{type:"emailDetails",value:{email:i,boxType:c,isEnd2End:/testing\+[0-9]+@apolitical.co$/.test(i)}},{type:"validFields.email",value:!0}])},bR=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"]}},TR=async({refs:e,dataToSubmit:t,createAccount:n,onSuccess:r,dispatch:i,state:a})=>{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=bR(new FormData(e.form.current)),o=Object.assign(s,t);await n(o),sessionStorage.setItem(hp.SESSION_STORAGE.EMAIL,s.email),r&&r({...s,...a.values}),i([{type:"showSuccessMessage",value:!0}])},_R=({shouldShow:e,placeholders:t,labels:n,functions:{validateEmail:r,resendVerificationCode:i},refs:a,state:s,dispatch:o,dataToSubmit:l,intl:u})=>{const{emailDetails:c}=s,d=(p,g)=>{p.current&&s.validFields[g]!==p.current.validity.valid&&o([{type:`validFields.${g}`,value:p.current.validity.valid}])},f=[{id:"full_name",type:"text",inputRef:a.name,placeholder:u.formatMessage({id:"signup_full_name_placeholder"}),functions:{onChange:()=>d(a.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:a.email,placeholder:u.formatMessage({id:"signup_email_address_placeholder"}),"aria-describedby":"email-helper-textbox",functions:{onBlur:()=>{g9({ref:a.email,validateEmail:r,dispatch:o})},onChange:(p,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:eb,props:{email:c.email,type:c.boxType,resendVerificationCode:i}}];return s.shouldManuallyApprove&&(f.push({id:"job_title",type:"text",inputRef:a.jobTitle,placeholder:u.formatMessage({id:"signup_job_title_placeholder"}),functions:{onChange:()=>d(a.jobTitle,"jobTitle")},validation:[{condition:"required"}],"data-testid":"signup-job-input"},{id:"organization",type:"text",inputRef:a.organisation,placeholder:u.formatMessage({id:"signup_organization_placeholder"}),functions:{onChange:()=>{d(a.organisation,"organisation")}},validation:[{condition:"required"}],autoComplete:"organization","data-testid":"signup-org-input"}),e.url&&f.push({id:"url",type:"text",label:u.formatMessage({id:"signup_url"},{small:p=>h.jsx("small",{children:p})}),placeholder:u.formatMessage({id:"signup_url_placeholder"}),validation:[{condition:"valid-url"}],"data-testid":"signup-url-input"})),e.expectation&&f.push({id:"expectation",className:"expectation",type:"text",label:(n==null?void 0:n.expectation)||u.formatMessage({id:"signup_expectation"},{small:p=>h.jsx("small",{className:"notes text-small",children:p})}),placeholder:(t==null?void 0:t.expectation)||u.formatMessage({id:"signup_expectation_placeholder"}),"data-testid":"signup-events-question"}),f.push({id:"terms",className:"text-small",type:"checkbox",inputRef:a.tc,label:u.formatMessage({id:"signup_terms"},{terms:p=>h.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:p}),privacy:p=>h.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:p})}),shownValue:"accepted",functions:{onChange:p=>{if(!p)return;const g=[];["name","email"].forEach(m=>{s.validFields[m]!==a[m].current.validity.valid&&(g.push({type:`validFields.${m}`,value:a[m].current.validity.valid}),m==="email"&&g9({ref:a.email,validateEmail:r,dispatch:o}))}),g.length&&o(g)}},validation:[{condition:"required"}],"data-testid":"signup-terms-checkbox"}),f};const CR=({className:e=""})=>h.jsxs("div",{className:ee("success-message",e),"data-testid":"success-message",children:[h.jsx("p",{className:"success-title",children:h.jsx(he.FormattedMessage,{id:"signup_success_title"})}),h.jsx(he.FormattedMessage,{id:"signup_success_text",values:{p:t=>h.jsx("p",{children:t})}})]});const xR={validFields:{name:!1,email:!1,jobTitle:!1,organisation:!1},emailDetails:{email:"",boxType:"",isEnd2End:!1},shouldManuallyApprove:!1,shouldDisableButton:!0,loadRecaptcha:!1,showSuccessMessage:!1,showError:!1},wR=({className:e="",labels:t={},placeholders:n={},functions:r={validateEmail:()=>Promise.resolve(),createAccount:()=>Promise.resolve(),handleError:()=>{},resendVerificationCode:()=>Promise.resolve()},shouldShow:i={},submitButton:a,dataToSubmit:s={ref:"sign-up-form"},...o})=>{const l=he.useIntl(),u=window.location.pathname.includes("/signup")?"/login":`/login?returnTo=${window.location.pathname}`,{title:c=!0,expectation:d=!1,url:f=!0,logInButton:p=!0,successMessage:g=!0}=i,m={title:c,expectation:d,url:f,logInButton:p,successMessage:g},[E,v]=y.useReducer(Us,xR),{validFields:b,emailDetails:T,shouldManuallyApprove:C,shouldDisableButton:_,showSuccessMessage:x,showError:S}=E,[F,R]=up.useCookies(["signup-this-session","functional-cookie-consent"]),L={form:y.createRef(),name:y.createRef(),email:y.createRef(),jobTitle:y.createRef(),organisation:y.createRef(),tc:y.createRef(),hiddenValidation:y.createRef()};y.useEffect(()=>{C===!0&&L.jobTitle.current&&L.jobTitle.current.focus()},[C]),y.useEffect(()=>{F["signup-this-session"]&&v([{type:"showSuccessMessage",value:!0}])},[F]),y.useEffect(()=>{x&&F["functional-cookie-consent"]&&R("signup-this-session","true",{path:"/",maxAge:3600})},[x]);const P=y.useMemo(()=>_R({placeholders:n,labels:t,shouldShow:m,functions:r,refs:L,state:E,dispatch:v,dataToSubmit:s,intl:l}),[s,r,l,L,m,E]),I=_?!0:C?!Object.values(b).every(k=>k===!0):!b.name||!b.email||["exists","pending","verify"].includes(T.boxType);return m.successMessage&&x?h.jsx(CR,{className:e}):h.jsxs("fieldset",{className:ee("signup-form-fieldset",e),"data-testid":"signup-form",children:[m.title&&h.jsx("p",{className:"signup-title",children:h.jsx(he.FormattedMessage,{id:"signup_title"})}),S&&h.jsx(Wr,{variant:"error",text:l.formatMessage({id:"signup_error"})}),h.jsx(Cr,{className:"signup-form",formRef:L.form,id:"sign-up-form",fields:P,intlPath:"signup",button:{variant:"primary",size:"medium",text:a||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:u,"data-gtm-event-context":"SignupForm","data-gtm-event-type":"login-click",text:l.formatMessage({id:"signup_button_login"})},meta:{shouldReset:!1,showRequiredLabels:!1,shouldShowCancelButton:m.logInButton},gtm:{context:"SignupForm",event:"signup-submit-click"},functions:{onSuccess:async()=>{await TR({refs:L,dataToSubmit:s,createAccount:r.createAccount,onSuccess:r.onSuccess,dispatch:v,state:E})},onCatch:k=>{r.handleError(k),v([{type:"showSuccessMessage",value:!1},{type:"showError",value:!0}])}}}),h.jsx("button",{className:"validation-button",ref:L.hiddenValidation})]})};function AR({parentId:e,isMember:t,formFunctions:n,leave:r,join:i,meta:a}){const s=he.useIntl();return h.jsx(x0,{form:{content:{type:Ke.Reply,slugs:{}},functions:n,meta:{isEditing:!1,isAutoFocused:!1,isPrepopulated:!1,showSuccessMessage:!1,...a},placeholder:s.formatMessage({id:"discussion_responses_placeholder"})},parentId:e,membershipRequiredToPost:{isMember:t,required:!0,join:i,leave:r,notMemberStateText:s.formatMessage({id:"community_joinToPost"})}})}function SR({hasNextPage:e,fetchNextPage:t,setFocusReplyIndex:n,totalReplies:r}){const i=he.useIntl(),a=()=>{n(r),t()};return h.jsx(xl,{hasNextPage:e,loadNextPage:a,icon:{icon:"arrow-down",position:"right"},messages:{button:i.formatMessage({id:"loadMore_button"}),error:i.formatMessage({id:"loadMore_error"})}})}function kR({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:i,user:a}){const{mutate:s}=vt.useMutation({mutationFn:e,onMutate:o=>t(l=>{const u=fg({reply:d6(o),user:a});return Is(u,l,{replace:!1,append:(o==null?void 0:o.replyId)!==void 0})}),onError:n,onSuccess:(o,l,u)=>{const c=fg({reply:o,user:a});r.setQueryData(i,Is(c,u,{replace:!0,append:(l==null?void 0:l.replyId)!==void 0})),setTimeout(()=>{Pp(c.id,"reply")},0)}});return s}function DR({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=vt.useMutation({mutationFn:e,onMutate:({replyId:i,content:a})=>t(s=>{const o=Dn(i,s);return o&&(o.data.content=a),s}),onError:n});return r}function OR({replies:e,user:t,replyType:n}){return!e||!(t!=null&&t.id)?[]:e.map(({id:r,own_children:i,latest_children:a,children_counts:s,data:o,created_at:l,parent:u,...c})=>{var E,v,b,T;const d=(((E=i==null?void 0:i.like)==null?void 0:E.length)||0)>0,f=(((v=a==null?void 0:a.like)==null?void 0:v.length)||0)>0,p=d?(b=i==null?void 0:i.like)==null?void 0:b.find(C=>{var _;return((_=C==null?void 0:C.user)==null?void 0:_.id)===(t==null?void 0:t.id)}):!1,g=typeof p=="object"?(p==null?void 0:p.id)??"":"",m=f?(T=a==null?void 0:a.like)==null?void 0:T.map(C=>{var _,x,S;return{id:(_=C==null?void 0:C.user)==null?void 0:_.id,name:(S=(x=C==null?void 0:C.user)==null?void 0:x.data)==null?void 0:S.name}}):!1;return{user:c==null?void 0:c.user,body:n===$t.Courses?p6({content:o.content}):IR(o),locale:o==null?void 0:o.locale,createdAt:l,data:NR(o),likeId:g,liked:f,likes:(s==null?void 0:s.like)||0,peopleWhoLiked:m,replyId:r,parent:u,userLiked:!!p}})}function NR(e){if(!e||!e.mentioned_users)return{};const t=e==null?void 0:e.mentioned_users,n=(e==null?void 0:e.additional_data)||{};return{mentions:t,...n}}function IR(e){var t;return e?typeof e.content=="string"?e.content:((t=e==null?void 0:e.content)==null?void 0:t.text)||"":""}function MT({queryFns:{create:e,edit:t,like:n,list:r,remove:i,unlike:a},queryKey:s,type:o=$t.Communities}){const l=vt.useQueryClient(),u=Xc(),c={queryClient:l,queryKey:s},d={mutationHandlers:{error:kp(c),mutate:Dp(c)},user:u,...c},f=kR({...d,mutationFn:e}),p=DR({...d,mutationFn:t}),g=PR({...d,mutationFn:n}),m=FR({...d,mutationFn:i}),E=BR({...d,mutationFn:a}),{replies:v,...b}=RR({queryKey:s,queryFn:r});return{replies:OR({replies:v,user:u,replyType:o}),mutations:{create:f,edit:p,remove:m,like:g,unlike:E},user:u,...b}}function PR({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:i}){const{mutate:a}=vt.useMutation({mutationFn:e,onMutate:({replyId:s})=>t(o=>{const l=Dn(s,o);return l&&hg({reply:l}),o}),onError:n,onSuccess:(s,{replyId:o},l)=>{const u=Dn(o,l);u&&hg({reply:u,reaction:s}),r.setQueryData(i,l)}});return a}function RR({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:i,hasNextPage:a,fetchNextPage:s}=vt.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:{next:""},getNextPageParam:o=>(o==null?void 0:o.next)||null});return{replies:Ip(n),error:r,isLoading:i,hasNextPage:a,fetchNextPage:s}}function FR({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=vt.useMutation({mutationFn:e,onMutate:({replyId:i})=>t(a=>Y4(i,a)),onError:n});return r}function BR({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:i}=vt.useMutation({mutationFn:e,onMutate:({replyId:a})=>t(s=>{const o=Dn(a,s);return o&&f6({reply:o,user:r}),s}),onError:n});return i}const MR=({activityId:e,basePath:t,isMember:n,parentId:r,replyId:i,functions:{reactions:a,form:s,likes:o},type:l=$t.Communities})=>{const u=he.useIntl(),c=3,{replies:d,fetchNextPage:f,hasNextPage:p,isLoading:g,mutations:{create:m,edit:E,like:v,remove:b,unlike:T}}=MT({queryKey:[t,r,e,i,"replies"],queryFns:{...a,list:x=>a.list({...x,reactionId:i})},type:l});dp([g]);const[C,_]=y.useState(!0);return h.jsxs(h.Fragment,{children:[(d==null?void 0:d.length)>=c&&h.jsx(Me,{className:"nested-replies-show-toggle",variant:"secondary",size:"small",styling:{muted:!0},icon:{icon:`arrow_corner-${C?"up_left":"down_right"}`,position:"left"},onClick:()=>_(!C),children:u.formatMessage({id:`discussion_thread_${C?"hide":"show"}`},{count:d==null?void 0:d.length})}),C&&h.jsx(I3,{loadMore:{isLoading:g,hasNextPage:p,loadNextPage:()=>f()},form:{parentId:r,content:{type:Ke.Reply,slugs:{question:`${t}/${r}`,answer:e,reply:i}},functions:{create:(x,{body:S})=>m({activityId:e,replyId:i,content:S}),...s},meta:{isEditing:!1,isAutoFocused:!0,isPrepopulated:!1,showSuccessMessage:!1}},children:d&&d.length>0?d==null?void 0:d.map(({replyId:x,likes:S,data:F,body:R,createdAt:L,userLiked:P,peopleWhoLiked:I,parent:k,user:B,likeId:H})=>h.jsx(Ll,{isCommunity:!0,content:{id:x,type:Ke.Reply,body:R,createdAt:L,slugs:{question:`${t}/${r}`,answer:e,reply:k},slug:"",author:Vs(B),userLiked:P,likes:S,peopleWhoLiked:l===$t.Courses?!1:I,data:F},forceHide:{shareLink:l===$t.Courses},userHasPermissions:n,functions:{content:{createContent:()=>null,deleteContent:()=>b({replyId:x}),updateContent:(q,{body:N})=>E({replyId:x,content:N})},likes:{createLike:()=>v({replyId:x}),deleteLike:()=>T({replyId:x,reactionId:H}),listLikes:q=>o.list({replyId:x,...q})},comments:{},form:s},styling:{showShareLinkButton:!0},badges:{showBadges:!0,scopes:[{scope:ln.Communities,area:r||""},{scope:ln.Platform,area:"all"}]},disableMentions:l===$t.Courses,basePath:t,parentId:r},x)):null})]})};function LR({formFns:e,activityId:t,basePath:n,focus:r,isMember:i,parentId:a,reply:s,type:o=$t.Communities}){const{body:l,data:u,likeId:c,likes:d,peopleWhoLiked:f,replyId:p,createdAt:g,user:m,userLiked:E}=s,{edit:v,like:b,remove:T,unlike:C}=e.mutations;return h.jsx(k3,{children:h.jsx(Ll,{isCommunity:!0,content:{id:p,type:Ke.Reply,body:l,createdAt:g,slugs:{question:`${n}/${a}`,answer:t,reply:p},slug:p,author:Vs(m),userLiked:E,likes:d,peopleWhoLiked:o===$t.Courses?!1:f,data:u},userHasPermissions:i,functions:{content:{createContent:()=>null,deleteContent:()=>T({replyId:p}),updateContent:(_,{body:x})=>v({replyId:p,content:x})},likes:{createLike:()=>b({replyId:p}),deleteLike:()=>C({replyId:p,reactionId:c}),listLikes:_=>e.likes.list({replyId:p,..._})},comments:{},form:e.form},forceHide:{shareLink:o===$t.Courses},badges:{showBadges:!0,scopes:[{scope:ln.Communities,area:a||""},{scope:ln.Platform,area:"all"}]},disableMentions:o===$t.Courses,children:h.jsx(MR,{basePath:n,parentId:a,activityId:t,replyId:p,isMember:i,functions:e,type:o}),styling:{showShareLinkButton:!0},setFocus:r,basePath:n,parentId:a},p)},p)}const ru="ALL",LT=({activityId:e,basePath:t,parentId:n,activityTotalReplies:r,isMember:i,functions:{form:a,join:s,leave:o,likes:l,reactions:u},profile:c,showReplies:d,type:f=$t.Communities,repliesFilters:p})=>{const g=he.useIntl(),m=y.useContext(Mt),{fetchNextPage:E,hasNextPage:v,isLoading:b,replies:T,mutations:{create:C,remove:_,edit:x,like:S,unlike:F}}=MT({queryKey:[t,n,e,"replies"],queryFns:u,type:f}),[R,L]=y.useState(f===$t.Courses&&m.locale||ru),[P,I]=y.useState([]),k=y.useMemo(()=>T,[JSON.stringify(T)]);y.useEffect(()=>{if(!k)return;const N=!R||R===ru||f!==$t.Courses?k:k.filter(J=>J.locale===R);I(N)},[k,R]);const[B,H]=y.useState(null);dp([b]),Z4();const q={create:(N,J)=>{const{body:X}=J;C({activityId:e,content:X})},...a};return h.jsxs("section",{className:"replies-feed",children:[h.jsx(N3,{type:"comment",responses:r,isLoading:b}),d?h.jsxs(h.Fragment,{children:[h.jsx(AR,{parentId:n,isMember:i,join:s,leave:o,formFunctions:q,meta:{isAutoFocused:f===$t.Courses||!1}}),f===$t.Courses&&(p==null?void 0:p.isEnabled)&&h.jsxs("section",{className:"replies-feed-language-switcher",style:{display:"flex"},children:[h.jsx(Cr,{id:"replies-feed-language-switcher",fields:[{id:"language",label:!1,type:"select",initialValue:R,options:[{id:ru,label:g.formatMessage({id:"activitySection_language_switcher_all_languages_option"})},...(p==null?void 0:p.options)||[]],functions:{onChange:N=>L(N)}}],functions:{},button:{hideButton:!0}}),h.jsx(Me,{icon:"info-inside-circle",variant:"tertiary",className:"language-switcher-info-button",tooltip:g.formatMessage({id:"activitySection_language_switcher_info"}),forceTooltip:!0,children:h.jsx(ot,{children:g.formatMessage({id:"activitySection_language_switcher_info"})})})]}),P==null?void 0:P.map((N,J)=>h.jsx(LR,{activityId:e,basePath:t,focus:B===J,formFns:{form:a,likes:l,reactions:u,mutations:{remove:_,edit:x,like:S,unlike:F}},isMember:i,parentId:n,reply:N,type:f},N.replyId)),b?h.jsx(h.Fragment,{children:" "}):h.jsx(SR,{hasNextPage:v,fetchNextPage:E,setFocusReplyIndex:H,totalReplies:T.length})]}):h.jsx(Ln,{children:h.jsx(he.FormattedMessage,{id:"replies_feed_missing_polls_vote_message"})}),h.jsx(w0,{form:c})]})};function $R({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:i,hasNextPage:a,fetchNextPage:s,refetch:o}=vt.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:{next:""},getNextPageParam:c=>(c==null?void 0:c.next)||null}),l=Ip(n),u=`${l.length||0}${a?"+":""}`;return{likes:l,likesCount:u,error:r,isLoading:i,hasNextPage:a,fetchNextPage:s,refetch:o}}function jR({queryFns:{list:e},queryKey:t}){const{likes:n,...r}=$R({queryKey:t,queryFn:e});return{likes:n,...r}}function $T({basePath:e,parentId:t,activityId:n,likeCount:r,functions:i}){const{likes:a,fetchNextPage:s,hasNextPage:o,refetch:l}=jR({queryKey:[e,t,n,"likes"],queryFns:i.likes});y.useEffect(()=>{l()},[l]);const u=a.map(({user:c})=>c).map(c=>c?Vs(c):void 0).filter(c=>c&&typeof c!="string");return h.jsx("section",{className:"likes-feed",children:h.jsx(S3,{members:{data:u,total:r},showHeader:!1,showPlaceholders:!0,communitySlug:t,hasNextPage:o&&u.length<r,loadNextPage:s})})}const jT=({showModal:e=!0,functions:{onClose:t,likes:n},likeCount:r,className:i,...a})=>{const s=he.useIntl();return h.jsx(Ti,{id:"likes-modal",title:s.formatMessage({id:"discussion_likes"},{number:r}),isOpen:e,functions:{onClose:t},className:ee("profile-modal in-portal",i,{open:e}),maxWidth:600,children:h.jsx($T,{...a,likeCount:r??0,functions:{likes:n}})})},HR=Object.freeze(Object.defineProperty({__proto__:null,default:jT},Symbol.toStringTag,{value:"Module"})),UR={results:[{created_at:"2024-05-16T13:17:45.940899Z",updated_at:"2024-05-16T13:17:45.940899Z",id:"ab4b7ab0-f4fe-469f-a8e7-5a52b3e55333",user_id:"9ed21585-63be-4446-96ce-3e703820eb73",user:{id:"1234",data:{name:"Han Solo",thumbnail:"https://placehold.co/400x400",jobTitle:"Smuggler",organization:"Rebel Alliance",badges:{communities:{"endor-alumni":["blue-badge"]}}}},kind:"like",activity_id:"869e5a90-0eba-11ef-8080-80017b714aaf",data:{mentioned_users:null},parent:"",latest_children:{},children_counts:{}},{created_at:"2024-05-16T13:17:45.940899Z",updated_at:"2024-05-16T13:17:45.940899Z",id:"db4b7ab0-f4fe-469f-a8e7-5a52b3e55373",user_id:"9ed21585-63be-4446-96ce-3e703820eb73",user:{created_at:"2023-08-22T11:56:10.585365Z",updated_at:"2024-03-13T11:31:49.447916Z",id:"9ed21585-63be-4446-96ce-3e703820eb73",data:{jobTitle:"Admiral",name:"Princess Leia",organization:"Rebela Alliance",thumbnail:"https://placehold.co/400x400",badges:{platform:{all:["orange-badge"]}}}},kind:"pin",activity_id:"769e5a90-0eba-11ef-8080-80017b714aaf",data:{mentioned_users:null},parent:"",latest_children:{},children_counts:{}}],next:"xy12345"};const zR=3e3,HT=({url:e,gtm:t={context:"ShareLink",event:"copy-link-click"}})=>{const n=he.useIntl(),r="discussion_share_copy_link",[i,a]=y.useState({isOpen:!1,isCopied:!1});return h.jsxs("li",{className:"share-link-wrapper",children:[h.jsx(Es,{className:"gtm-trackable",icon:{icon:"link_chain"},onMouseOver:()=>a({...i,isOpen:!0}),onFocus:()=>a({...i,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});const s=new CustomEvent("ariaLive",{detail:{message:n.formatMessage({id:`${r}_success`})}});document.dispatchEvent(s),setTimeout(()=>{a({isOpen:!1,isCopied:!1})},zR)})},"data-gtm-event-context":t.context,"data-gtm-event-type":t.event,"data-testid":"share-link",screenreaderText:n.formatMessage({id:r})}),h.jsx(Fa,{className:ee({copied:i.isCopied}),isOpen:i.isOpen,styling:{hasPointer:"bottom",extraPadding:!1},children:n.formatMessage({id:`${r}${i.isCopied?"_success":""}`})})]})};const sa="discussion_",UT=({className:e,gtmContext:t,contentType:n,likes:r,comments:i,replies:a,edit:s,shareLink:o,moreMenu:l})=>{const u=he.useIntl(),c=[];return l&&l.reportData&&c.push({text:u.formatMessage({id:`${sa}moreMenu_report`}),onClick:d=>{d.stopPropagation()},href:`mailto:community@apolitical.co?subject=${encodeURI(u.formatMessage({id:`${sa}report_subject`}))}&body=${encodeURI(u.formatMessage({id:`${sa}report_body`},{contentType:n||"",contentSlug:l&&l.reportData&&l.contentSlug||"",contentUrl:l&&l.reportData&&l.reportData.contentUrl||""}))}`,icon:"flag"}),h.jsxs("ul",{className:ee("actions text-medium",e),"data-testid":`${n}-actions`,children:[r?h.jsx(Q4,{element:"li",likes:r.count,isShort:!1,userLiked:r.userLiked,content:{type:n,slugs:r.content.slugs,slug:r.content.slug},canLike:r.canLike,peopleWhoLiked:r.peopleWhoLiked,activityId:r.activityId,functions:r.functions,basePath:r.basePath||"",parentId:r.parentId||""}):h.jsx(h.Fragment,{}),i?h.jsx("li",{children:h.jsx(Es,{shortText:`${i.count??0}`,onClick:d=>{d.preventDefault(),d.stopPropagation(),i.functions.onClick()},icon:{icon:"speech-bubble_square"},"data-testid":"comment","data-gtm-event-context":t,"data-gtm-event-type":`answer-${n}-click`,screenreaderText:u.formatMessage({id:`${sa}comments_screenReader`},{count:i.count}),children:u.formatMessage({id:`${sa}comments${i.count===null?"_loading":""}`},{count:i.count})})}):h.jsx(h.Fragment,{}),a?h.jsx("li",{children:h.jsx(Es,{styling:{muted:!0},onClick:a.functions.onClick,icon:{icon:"speech-bubble_square"},"data-testid":"reply",disabled:!a.canReply,children:u.formatMessage({id:`${sa}reply`})})}):h.jsx(h.Fragment,{}),s?h.jsx("li",{className:"edit-button-item",children:h.jsx(Es,{styling:{muted:!0},onClick:s.onClick,icon:{icon:"pencil-paper"},"data-testid":"edit",children:u.formatMessage({id:`${sa}action_edit`})})}):h.jsx(h.Fragment,{}),o?h.jsx(HT,{url:o.url,gtm:{context:t||"",event:`copy-link-${n}-click`}}):h.jsx(h.Fragment,{}),l?h.jsx(Rc,{element:"li",id:`more-${l.contentSlug}`,options:[...l.options||[],...c]}):h.jsx(h.Fragment,{})]})};const qR=({breadcrumbs:e,cutoff:t=20,className:n=""})=>{const r=he.useIntl();return h.jsxs(h.Fragment,{children:[h.jsx(ot,{element:"p",children:r.formatMessage({id:"breadcrumbs_label"})}),h.jsx("ul",{className:ee("breadcrumbs text-small",n),children:e.map(({text:i,href:a,current:s=!1},o)=>{const l={};return s&&(l["aria-current"]="location"),h.jsxs("li",{children:[s&&h.jsx(ot,{element:"span",children:r.formatMessage({id:"breadcrumbs_currentPage"})}),h.jsx(Qi,{href:s?void 0:a,...l,children:Ss(i,t)})]},`${window.btoa(i)}_${o}`)})})]})};const cm=({variant:e="default",data:{image:t,url:n,title:r,description:i},onClick:a,gtm:s,...o})=>{if(!n)return h.jsx(h.Fragment,{});let l=n.split("//");l.length>1?l=l[1]:l=l[0],l=l.split("/"),l=l[0];const{context:u="EnrichedLink",event:c="enriched-link-click"}=s??{};return h.jsxs("aside",{className:ee("enriched-url gtm-trackable",{"has-image":t,[e]:e!=="default"}),onClick:d=>{if(d.preventDefault(),d.stopPropagation(),a){a(d);return}window.open(n,"_blank")},"data-gtm-event-context":u,"data-gtm-event-type":c,children:[h.jsx("small",{children:l}),h.jsx("p",{className:"title text-medium",children:h.jsx("a",{...o,href:n,target:"_blank",rel:"noreferrer",children:r})}),i&&e!=="condensed"?h.jsx("p",{className:"text-small",children:i}):h.jsx(h.Fragment,{}),t&&t.src?h.jsx("p",{className:"img",children:h.jsx("img",{src:t.src,alt:t.alt||"",loading:"lazy",fetchpriority:"low",width:t.width||"auto",height:t.height||"100%"})}):h.jsx(h.Fragment,{})]})};const zT=({options:e,defaultOptions:t=[],allOption:n=!1,allowMultiple:r=!0,onChange:i=()=>{},preventNoOptionSelected:a=!1,className:s="",styling:o,gtm:l})=>{const u=he.useIntl(),{muted:c,large:d}=o||{},f=n?[{id:"all",text:typeof n!="boolean"&&n.text||u.formatMessage({id:"filters_all"})},...e]:e,[p,g]=y.useState(n?["all"]:t.length?t.map(b=>b.id):[]),[m,E]=y.useState(0),v=(b,T)=>{let C=[];p.includes(b)&&!a?C=p.filter(_=>_!==b):b==="all"?C=["all"]:r?C=[...p.filter(_=>_!=="all"),b]:C=[b],g(_=>(i&&typeof i=="function"&&i({current:C,previous:_}),C)),T&&typeof T=="function"&&T()};return h.jsx("ul",{className:ee("filters",s),children:f.map(({id:b,text:T,disabled:C=!1,callback:_=()=>{},content:x},S)=>{let F={tabIndex:m===S?0:-1};return C&&(F={disabled:!0,"aria-label":u.formatMessage({id:"filters_disabled"},{name:T})}),h.jsx("li",{children:h.jsx("button",{"data-gtm-event-context":(l==null?void 0:l.context)||"filters","data-gtm-event-type":(l==null?void 0:l.type)||`${T.toLowerCase().replace(" ","-")}-click`,className:ee(b,{selected:p.includes(b),large:d,muted:c}),onClick:R=>{R.preventDefault(),R.stopPropagation(),v(b,_)},onKeyDown:R=>{var k,B;let L=S+1,P,I;switch(R.code){case"Enter":case"Space":R.preventDefault(),R.stopPropagation(),v(b,_);break;case"ArrowLeft":case"ArrowRight":R.preventDefault(),R.stopPropagation(),R.code==="ArrowLeft"?(L=S-1,L<0&&(L=f.length-1)):L>=f.length&&(L=0),E(L),P=R.currentTarget.closest("li"),I=(k=P==null?void 0:P.parentElement)==null?void 0:k.children[L],(B=I==null?void 0:I.querySelector("button"))==null||B.focus();break}},"aria-selected":p.includes(b),...F,children:x||T})},b)})})},WR=(e,t,n)=>{const r=String(e);if(!n||!n.length)return t?`/${r}/${t}`:`/${r}`;let i="",a=!1;return n.forEach(({url:s,position:o})=>{o==="before-lang"?(i+=`/${s}`,a=!0):(i.includes(`/${r}/`)||(i+=`/${r}`),i+=`/${s}`)}),i.includes(`/${r}/`)||(i+=`/${r}`),t&&(i+=`/${t}`),a?{url:i,urlForRouter:`/${i.split("/").slice(2).join("/")}`}:i};const iu="languageSwitcher_",VR=({currentLanguage:e,isOriginalLanguage:t=!1,isHumanTranslation:n=!1,translations:r,onChange:i,urlParts:a,variant:s="default",label:o,className:l=""})=>{const u=he.useIntl(),{updateLanguage:c=()=>{}}=y.useContext(vp),[d,f]=y.useState(e);if(y.useEffect(()=>{e!==d&&f(e)},[e]),!r||!Object.values(r).some(E=>E&&E.post_name))return null;const g=Object.keys(r),m=d!==e;return h.jsxs("div",{className:ee("language-switcher text-small",s,l),children:[h.jsxs("nav",{children:[s!=="short"&&h.jsx("p",{children:o||u.formatMessage({id:`${iu}label`})}),h.jsx("ul",{children:g.map(E=>{var C;if(!gc.ALL_LOCALES.includes(E))return null;const v=(C=r[E])==null?void 0:C.post_name,b=gc.ALL_LOCALES_WITH_LABELS.filter(_=>_.value===E)[0].title;let T={className:E};if(d===E)T["aria-label"]=u.formatMessage({id:`${iu}selected`},{language:b});else{const _=WR(E,v,a);T={...T,href:typeof _=="string"?_:_.url,onClick:x=>{f(E),c(E),typeof i<"u"&&(x.preventDefault(),x.stopPropagation(),i(E,typeof _=="string"?_:_.urlForRouter))}}}return h.jsx("li",{children:h.jsx(Qi,{...T,fallbackElement:"span",children:b})},E)})}),s!=="short"&&!m&&h.jsx("p",{children:u.formatMessage({id:`${iu}translation_${t?"original":n?"human":"machine"}`})})]}),s!=="short"&&!m&&!t&&!n&&h.jsx("small",{children:u.formatMessage({id:`${iu}disclaimer`},{email:us.support,link:E=>{const v=`mailto:${E}`;return h.jsx("a",{href:v,children:E})}})})]})};const Pd=he.createIntl({locale:"en",messages:zn}),xl=({hasNextPage:e=!0,loadNextPage:t=()=>{},isLoading:n=!1,variant:r="secondary",size:i="medium",styling:a={muted:!1,fullWidth:!1},icon:s=!1,messages:o={button:Pd.formatMessage({id:"loadMore_button"}),endOfFeed:Pd.formatMessage({id:"loadMore_endOfFeed"}),error:Pd.formatMessage({id:"loadMore_error"})},className:l="",gtmContext:u="LoadMore"})=>{const[c,d]=y.useState(""),f=async p=>{if(!n)try{await t(p)}catch(g){g instanceof Error?d(g.message):d("Unknown error")}};return!c&&!e&&!o.endOfFeed?null:h.jsx("footer",{className:ee("load-more",l),children:!c&&e?h.jsx(Me,{variant:r,size:i,styling:a,icon:s,onClick:f,"data-gtm-event-context":u,"data-gtm-event-type":"load-more-click",disabled:n,className:"gtm-trackable","data-testid":"load-more-button",children:o.button}):o.endOfFeed&&(!c||c!=null&&c.includes("Cannot read items"))?h.jsx("p",{children:o.endOfFeed}):c&&h.jsx("p",{className:"error",children:o.error})})};const dm=({variant:e="default",version:t="default",className:n="",...r})=>{const i=cp();return h.jsx("p",{className:"logo-wrapper",children:h.jsx("a",{href:i||"/home/",className:ee("logo",e,t,n),...r,children:h.jsx(ot,{children:h.jsx(he.FormattedMessage,{id:"apolitical"})})})})};let au=!1;const Rc=({element:e="div",id:t="more-menu",options:n,className:r=""})=>{const i=he.useIntl(),a=y.useRef(null),[s,o]=y.useState(!1),l=u=>{a.current&&u.target instanceof HTMLElement&&!a.current.contains(u.target)&&o(!1)};return y.useEffect(()=>(document.addEventListener("click",l,!0),()=>{document.removeEventListener("click",l,!0)})),y.createElement(e,{ref:a,className:ee("more-menu text-medium",r),children:h.jsxs(h.Fragment,{children:[h.jsx(Me,{variant:"tertiary",size:"medium","data-testid":"more-menu",icon:{icon:"ellipsis"},onClick:()=>o(!s),"aria-haspopup":"true","aria-expanded":s,"aria-controls":t,screenreaderText:i.formatMessage({id:"moreMenu"}),className:"more-menu-button"}),h.jsx("ul",{id:t,hidden:!s,children:n.map(({href:u,onClick:c,text:d,icon:f,...p},g)=>{const m={...p,onClick:E=>{o(!1),typeof c=="function"&&c(E)},onFocus:()=>{au&&(clearTimeout(au),au=!1)},onBlur:()=>{au=setTimeout(()=>{o(!1)},100)}};return u&&(m.href=u),h.jsx("li",{className:"more-menu-list-item",children:h.jsx(Me,{variant:"tertiary",size:"medium",icon:f?{icon:f,position:"left"}:!1,...m,children:d})},`${window.btoa(d)}_${g}`)})})]})})},KR=(e,t=!1)=>t?e.replaceAll("/","")===t:typeof window<"u"&&window.location&&window.location.pathname===e;const GR=y.lazy(()=>Promise.resolve().then(()=>i7)),YR=[{key:"homepage",href:"/home/"},{key:"events",href:"/events/"},{key:"microcourses",href:"/microcourses/"},{key:"articles",href:"/solution-articles/"},{key:"communities",href:"/communities/"}],qT=({activeLink:e,profile:t})=>{const n=he.useIntl(),r=y.useContext(Mt),i=r&&typeof r.id=="string";return h.jsxs("ul",{id:"navigation-menu",className:"text-medium",children:[YR.map(({key:a,href:s})=>{const o=KR(s,e),l={};return o&&(l["aria-current"]="page"),h.jsx("li",{className:ee(a,{active:o}),children:h.jsx("a",{href:s,"data-gtm-event-type":`${a}-click`,"data-gtm-event-context":"NavigationMenu",className:"gtm-trackable",...l,children:n.formatMessage({id:`navigationMenu_links_${a}`})})},a)}),i&&t&&h.jsx(GR,{element:"li",member:r,styling:{variant:"card",isCondensed:!1},functions:{profile:t},className:"profile gtm-trackable","data-testid":"profile-link",alt:"",gtmContext:"NavigationMenu",gtmType:"profile-click"})]})},co=(e,t,n)=>`${e}?share=${t}${n?`&uuid=${n}`:""}`,ZR=({title:e,link:t,referrer:n})=>[{key:"linkedin",icon:"social_linkedin",url:`https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(`${co(t,"linkedin",n)}&src=linkedin`)}&title=${encodeURIComponent(e)}&source=Apolitical`},{key:"twitter",icon:"social_twitter",url:`https://twitter.com/share?ref_src=twsrc%5Etfw&url=${encodeURIComponent(`${co(t,"twitter",n)}&src=twitter`)}&text=${encodeURIComponent(e)}&via=${encodeURIComponent("apoliticalco")}`},{key:"facebook",icon:"social_facebook",url:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(`${co(t,"facebook",n)}`)}&t=${e}`},{key:"email",icon:"share_email",url:`mailto:?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`${e}
|
|
162
|
+
`}),U=$.turndown(U)}o&&o.mentions&&(U=await l4({text:U,template:`[${Ah}{{name}}]({{id}})`,mentions:o.mentions,listMembers:p||(()=>Promise.resolve([]))})),cP(U,$=>{const ae=[{type:"initialValue",value:$},{type:"editorKey",value:R.toString()}];o!=null&&o.link&&(ae.push({type:"enrichedUrl",value:o.link}),o.link.url&&J(o.link.url)),S(ae),setTimeout(()=>{S([{type:"stringValue",value:o9(Z)}])},150)})})()},[R]),y.useEffect(()=>{if(q===void 0&&Z){const U=hP(Z);U&&J(U)}const z=U=>{var Y;const $=U,ae=((Y=$==null?void 0:$.detail)==null?void 0:Y.url)||null;ae&&q&&q.url===ae&&S([{type:"enrichedUrl",value:void 0}])};return window.addEventListener("linkRemoved",z),()=>{window.removeEventListener("linkRemoved",z)}},[q]),y.useEffect(()=>{if(t){al.lastIndex=0;const z=t.match(al);z&&z.length===1&&z[0].length===t.length&&!B&&S([{type:"originalValue",value:t}])}t!==""||!Z||vc(R,t)&&!B||(O.withoutNormalizing(Z,()=>{le.delete(Z,{at:{anchor:O.start(Z,[]),focus:O.end(Z,[])}}),le.deselect(Z),Z.children.length!==0&&le.unwrapNodes(Z,{at:[0]}),le.insertNodes(Z,C,{at:[0]})}),S([{type:"initialValue",value:C},{type:"lastAnchor",value:null},{type:"enrichedUrl",value:!1}]))},[t]),y.useEffect(()=>{E({link:q})},[q]),y.useEffect(()=>{P===""&&q&&S([{type:"enrichedUrl",value:void 0}])},[P]);const j=rl(()=>{mP({editor:Z,isShowing:N.show,numberOfUsers:N.numberOfUsers,listMembers:p,dispatch:S})},100);return L?h.jsx("div",{id:X,className:"rich-text-editor input text-medium",children:h.jsxs(_i.Provider,{value:{...x,id:X,isInOverlay:f,dispatch:S,onMention:b,reportError:T},children:[h.jsxs(PO,{editor:Z,initialValue:L,onChange:z=>{if(Z.operations.some($=>$.type!=="set_selection")){let $=vP(z);$==="<br>"&&($=""),m($,q),S([{type:"stringValue",value:o9(Z)}]),B||S([{type:"hasInteracted",value:!0}]),j(),d&&console.log({serialized:$,json:z})}},...u,children:[h.jsx(xO,{className:"editor",renderElement:D,renderLeaf:A,placeholder:n||c.formatMessage({id:"richTextEditor_placeholder"}),autoFocus:s,tabIndex:0,onPaste:async z=>{const U=q!==!1,$=z.clipboardData.getData("text");if((Y=>{try{return new URL(Y),!0}catch{return!1}})($)){let Y=$;if($){const{full:te}=mp($);Y=te}if($&&v&&!U){const te=await v(Y);te.url&&S([{type:"enrichedUrl",value:te}])}}},onKeyDown:z=>{if(z.key==="Enter"){N.show&&(z.preventDefault(),z.stopPropagation(),gT(Z,N,S,X));const{selection:U}=Z;if(U){const $=oe.isCollapsed(U),[ae,Y]=O.node(Z,U,{depth:1});let te=ae,se=te.type;const re=te.children[0];if(se===ne.h3){z.preventDefault(),z.stopPropagation();const xe=O.start(Z,Y),ke=O.end(Z,Y),Te=Ge.equals(U.anchor,xe),ue=Ge.equals(U.anchor,ke);if(Te)le.insertNodes(Z,C,{at:Y});else if(ue)le.insertNodes(Z,C,{at:V.next(Y)}),le.select(Z,O.end(Z,V.next(Y)));else{const fe=U.anchor,[,we]=O.parent(Z,U);le.splitNodes(Z,{at:fe}),le.setNodes(Z,{type:ne.paragraph},{at:V.next(we)})}return}if(re&&[ne.ol,ne.ul].includes(re.type)&&(te=re,se=re.type),te&&Se.isElement(te)&&se!==ne.paragraph){if(se===ne.blockquote&&!z.shiftKey){z.stopPropagation(),z.preventDefault(),le.insertNodes(Z,C);return}if($){const[xe,ke]=O.parent(Z,U,{edge:"end"}),ue=xe.type;if([ne.ul,ne.ol].includes(se))if(z.stopPropagation(),z.preventDefault(),ue===ne.li&&k==="Enter"){xe.children.length===1&&"text"in xe.children[0]&&xe.children[0].text===""&&le.removeNodes(Z,{at:ke}),le.insertNodes(Z,C,{at:V.next(Y)}),le.select(Z,O.end(Z,V.next(Y)));return}else{const[fe,we]=dP(Z,ne.li),Ie={type:ne.li,children:[{text:""}]};le.insertNodes(Z,Ie,{at:V.next(we)}),le.select(Z,O.end(Z,V.next(we)))}}}}}else if(z.key==="Escape"){if(N.show){z.preventDefault(),z.stopPropagation(),S([{type:"mentionPopover",value:{...N,show:!1}}]);return}}else if(["ArrowUp","ArrowDown"].includes(z.key)&&N.show){z.preventDefault(),z.stopPropagation();const{selectedUser:U,possibleUsers:$}=N;let ae=z.key==="ArrowUp"?U-1:U+1;ae<0&&(ae=$.length-1),ae>=$.length+1&&(ae=0),S([{type:"mentionPopover",value:{...N,selectedUser:ae}}])}S([{type:"lastKey",value:z.key}]),pP(z,Z,S,T)},onBlur:()=>{Z.selection&&S([{type:"lastAnchor",value:Z.selection.anchor}])},onFocus:()=>{if(I){if(!V.isPath(I.path)||!Ee.has(Z,I.path))return;const z=Ee.get(Z,I.path);let U=0;if(De.isText(z)?U=z.text.length:z.children&&(U=z.children.length),I.offset>U)return;try{le.select(Z,{anchor:I,focus:I})}catch($){const ae=$.message;T(`Error focusing editor: ${ae}`)}}}}),q?h.jsx(cm,{data:q,variant:"condensed",onClick:()=>{S([{type:"enrichedUrl",value:!1}]);const z=new CustomEvent("ariaLive",{detail:{message:c.formatMessage({id:"richTextEditor_link_enrichedUrl_aria_live"})}});document.dispatchEvent(z)},"aria-label":c.formatMessage({id:"richTextEditor_link_enrichedUrl_aria"},{title:q.title||c.formatMessage({id:"richTextEditor_link_enrichedUrl_aria_fallback"})})}):h.jsx(h.Fragment,{}),h.jsx(kP,{styling:l==null?void 0:l.toolbar}),p?h.jsx(EP,{onFallbackClick:g}):h.jsx(h.Fragment,{})]},F),h.jsx(Fp,{id:`character-limit-${e}`,limit:r,valueLength:t1(P)})]})}):h.jsx(h.Fragment,{})};const pR=({id:e="form-toggle",label:t,options:n,initialValue:r,functions:{onChange:i=()=>{}},isDisabled:a=!1,className:s=""})=>{const[o,l]=y.useState(typeof r=="boolean"||typeof r=="string"?r:n[0].value);y.useEffect(()=>{r&&l(r)},[r]);const u=c=>{a||(l(c),i(c))};return h.jsxs("div",{className:ee("toggle",s),onClick:c=>{c.preventDefault(),c.stopPropagation(),u(o===n[0].value?n[1].value:n[0].value)},children:[h.jsx("p",{children:t}),h.jsx("ul",{className:ee("toggle-options",{disabled:a,on:o===n[1].value}),children:n.map(c=>{const d=`${e}-${c.value}`;return h.jsxs("li",{className:"hidden",children:[h.jsx("input",{type:"radio",id:d,name:e,value:c.value,checked:o===c.value,onChange:()=>u(c.value),disabled:a}),h.jsx("label",{htmlFor:d,children:c.label})]},d)})})]})};function NT({className:e="",userId:t,userName:n,src:r,uploadImage:i,button:a,callback:s}){const o=he.useIntl(),l="profileImageChange_",[u,c]=y.useState(r),[d,f]=y.useState(!1),[p,g]=y.useState(!1),m=y.useRef(null),E=async C=>{f(!0),g(!1);try{const _=C.target.files&&C.target.files[0];if(!_||!t)throw f(!1),new Error("Image file or userID is missing");const x=await i({fileObject:_,userId:t}),S={thumbnail:x.thumbnailURL,full:x.originalURL};c(S),s(S)}catch{g(!0)}finally{f(!1)}f(!1)},{upload:v=o.formatMessage({id:`${l}cta_upload`}),change:b=o.formatMessage({id:`${l}cta_change`}),uploading:T=o.formatMessage({id:`${l}cta_uploading`})}=(a==null?void 0:a.text)||{};return h.jsxs("div",{className:ee("profile-image-change-figure",e),children:[h.jsx(bi,{className:"profile-image-change-picture",name:n,src:u==null?void 0:u.thumbnail,showInitials:!1,alt:"","data-testid":"profile-picture"}),p&&h.jsx("p",{className:"error text-small",children:o.formatMessage({id:`${l}error`})}),h.jsx("input",{id:"file",type:"file",accept:"image/*",ref:m,onChange:E,hidden:!0,"data-testid":"file-input"}),h.jsx(Me,{onClick:()=>m.current&&m.current.click(),variant:"secondary","data-gtm-event-context":"ImageField","data-gtm-event-type":`${u?"change-photo":"add-photo"}-click`,className:"gtm-trackable",disabled:d,children:d?T:u?b:v})]})}const IT=({gtm:e,functions:{onSuccess:t=async()=>{},onFailure:n=()=>{}}})=>{const{context:r="FooterContactUsForm",event:i="contact-form-submit-click"}=e||{};return h.jsx(Cr,{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:i},functions:{onSuccess:t,onFailure:n},button:{className:"new"}})};const mR=({emails:e,setEmails:t,setIsDisabled:n})=>{const{formatMessage:r}=he.useIntl();return h.jsx(G3.ReactMultiEmail,{id:"email-input",inputClassName:"email-input input",placeholder:r({id:"inviteForm_email_placeholder"}),emails:e,onChange:i=>{t(i),n(!i.length)},autoFocus:!1,getLabel:(i,a,s)=>h.jsxs("div",{className:"email text-medium",children:[h.jsx("div",{"data-tag-item":!0,children:i}),h.jsx(Me,{variant:"tertiary",size:"small",icon:{icon:"close"},onClick:()=>{s(a),n(!e.length)},className:"remove-email-button",screenreaderText:r({id:"overlay_close"})})]},a)})},PT=({title:e,label:t,messagePlaceholder:n,ctaMessage:r,titleColor:i,labelColor:a,backgroundColor:s,onClose:o,reportError:l,sendInvites:u,initialFormStatus:c="NOT_SUBMITTED",gtm:d={context:"Form",event:"form-submit-click"},secondaryActionButton:f,meta:p})=>{const[g,m]=y.useState([]),[E,v]=y.useState(!0),[b,T]=y.useState(c),{formatMessage:C}=he.useIntl(),_=async F=>{try{await u(g,F.message),m([]),T("SUCCESS")}catch(R){T("ERROR"),l(R)}},x=F=>{F.preventDefault(),T("NOT_SUBMITTED"),v(!0),m([])},S=F=>{F.preventDefault(),o(),T("CLOSED")};return b==="CLOSED"?null:b==="ERROR"||b==="SUCCESS"&&!(p!=null&&p.shouldHideDoneButtonOnSubmit)?h.jsxs("div",{className:"invite-form-wrapper",children:[h.jsx("div",{className:"content centred",children:b==="SUCCESS"?h.jsx("h2",{className:"success-title",children:C({id:"inviteForm_success"})}):h.jsxs("h2",{className:"error-title",children:[" ",C({id:"inviteForm_error"})]})}),h.jsx(Tr,{}),h.jsx("div",{className:"footer",children:b==="SUCCESS"?h.jsxs(h.Fragment,{children:[h.jsx(Me,{variant:"secondary",onClick:x,children:C({id:"inviteForm_ctaSendMoreInvites"})}),h.jsx(Me,{onClick:S,children:C({id:"inviteForm_ctaDone"})})]}):h.jsx(Me,{onClick:x,children:C({id:"inviteForm_ctaTryAgain"})})})]}):h.jsxs("div",{className:"invite-form-wrapper",style:{backgroundColor:s},children:[h.jsxs("div",{className:"content",children:[h.jsx("h2",{className:"title",style:{color:i},children:e}),h.jsx("label",{htmlFor:"email-input",className:"label",style:{color:a},children:t})]}),h.jsx(Cr,{id:"invite-form",fields:[{component:mR,props:{emails:g,setEmails:m,setIsDisabled:v},required:!0},{id:"message",type:"textarea",label:C({id:"inviteForm_message_label"}),placeholder:n||C({id:"inviteForm_message_placeholder"})}],functions:{onSuccess:_},button:{text:r,size:"medium",disabled:E},gtm:d,meta:p,secondaryActionButton:f})]})},tc=e=>e.map(t=>({condition:t}));const Vn={FORM_ID:"manage-account-password-change",NEW_PASSWORD:"newPassword",CONFIRMED_PASSWORD:"confirmedPassword",CURRENT_PASSWORD:"oldPassword"},gR=({functions:e,...t})=>{const{formatMessage:n}=he.useIntl(),[r,i]=y.useState(null),[a,s]=y.useState(!1),[o,l]=y.useState({isMoreThanEightCharacters:!1,includesNumberAndSymbol:!1,includesLowerAndUppercase:!1}),u=p=>p[Vn.NEW_PASSWORD]!==p[Vn.CONFIRMED_PASSWORD]?n({id:"passwordRules_unmatched_text"}):null,c=p=>!ih(p[Vn.NEW_PASSWORD]).isValid,d=[{"data-testid":Vn.NEW_PASSWORD,id:Vn.NEW_PASSWORD,type:"password",autoComplete:"new-password",placeholder:"",label:n({id:"passwordRules_newPassword_label"}),validation:tc(["required",c]),functions:{onChange:p=>l(ih(p).matchingRules),onFocus:()=>s(!0),onBlur:()=>s(!1)}},{"data-testid":Vn.CONFIRMED_PASSWORD,id:Vn.CONFIRMED_PASSWORD,type:"password",autoComplete:"new-password",placeholder:"",label:n({id:"passwordRules_confirmPassword_label"}),validation:tc(["required",u])}];t.isPasswordChange&&d.unshift({"data-testid":Vn.CURRENT_PASSWORD,id:Vn.CURRENT_PASSWORD,type:"password",autoComplete:"current-password",placeholder:"",label:n({id:"passwordRules_currentPassword_label"}),validation:tc(["required"])}),a&&d.push({component:sb,props:{matchingRules:o}});const f={id:Vn.FORM_ID,fields:d,functions:{...e,onSuccess:async p=>(e.createPassword(p),e.onSuccess&&e.onSuccess(p)),onCatch:p=>i(p==null?void 0:p.statusCode),onFailure:(p,g)=>{(g.includes(Vn.NEW_PASSWORD)||g.includes(Vn.CONFIRMED_PASSWORD))&&s(!0)}},meta:{shouldReset:!0},...t};return h.jsxs(h.Fragment,{children:[h.jsx(Cr,{...f}),r&&h.jsx(Wr,{variant:"error",text:r})]})};const RT=({isCreateProfile:e=!1,hooks:t,functions:n,meta:r={},gtm:i,...a})=>{var F;const s=he.useIntl(),o="profileForm_",l=y.useContext(Mt),[u,c]=y.useState(l.image),[d,f]=y.useState(!1),{uploadImage:p=()=>{},onSuccess:g=async R=>{},onCancel:m=()=>{},onFailure:E=()=>{}}=n,{buildLocation:v,isValidPlace:b,predictPlaces:T}=t.useMaps(),{context:C="ProfileForm",event:_="profile-form-submit-click"}=i||{},x=[{id:"jobTitle",type:"text",label:s.formatMessage({id:`${o}jobTitle`}),placeholder:s.formatMessage({id:`${o}jobTitle_placeholder`}),value:l.jobTitle,validation:[{condition:"required"}]},{id:"organization",type:"text",label:s.formatMessage({id:`${o}organization`}),placeholder:s.formatMessage({id:`${o}organization_placeholder`}),value:l.organization,validation:[{condition:"required"}]},{id:"location",type:"autocomplete",label:s.formatMessage({id:`${o}location`}),placeholder:s.formatMessage({id:`${o}location_placeholder`}),value:(F=l.location)==null?void 0:F.en,validation:[{condition:"required"},{condition:({location:R})=>R&&!d?!1:!b(R),error:s.formatMessage({id:`${o}location_error`})}],functions:{onChange:()=>{d||f(!0)},onKeyInput:T}}],S=[{component:NT,props:{userName:l.name,userId:l.id,src:u,uploadImage:p,callback:c,button:{text:{upload:s.formatMessage({id:`${o}image`})}}}},{id:"name",type:"text",label:s.formatMessage({id:`${o}name`}),placeholder:s.formatMessage({id:`${o}name_placeholder`}),value:l.name,autoComplete:"name",validation:[{condition:"required"}]},...x,{id:"biography",type:"textarea",label:s.formatMessage({id:`${o}bio`}),placeholder:s.formatMessage({id:`${o}bio_placeholder`}),limit:1e3,value:l.biography},{component:Tr}];return h.jsx(Cr,{id:"profile-details-form",fields:e?x:S,meta:{shouldShowCancelButton:!e,shouldReset:!1,shouldHide:!1,showRequiredLabels:e,...r},intlPath:o,gtm:{context:C,event:_},functions:{onSuccess:async R=>{try{const L={...R,image:u||null,location:d?await v(R==null?void 0:R.location):l.location,...e?{onboardingState:"completed"}:{}};l.updateDetails&&l.updateDetails(P=>({...P,...L})),await g(L)}catch{E()}},onCancel:m,onFailure:E},button:{size:"large",text:{default:s.formatMessage({id:`${o}cta`}),submitting:s.formatMessage({id:`${o}cta_submitting`}),submitted:s.formatMessage({id:`${o}cta_submitted`})}},...a})},vR=()=>{const e=he.useIntl(),[t,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>{n(i=>{if(i>=95)return clearInterval(r),95;const a=Math.round(Math.random()*10);return Math.min(i+a,95)})},800);return()=>{clearInterval(r)}},[]),h.jsx(k4,{progress:t,steps:{0:{icon:"layers",text:e.formatMessage({id:"publishArticleForm_progressBar"})}}})};function ER({coverImage:e,setShowImagePicker:t}){return e&&e.url?h.jsx(Wr,{className:"cover-image-preview",text:h.jsx(Zi,{className:"cover-image",image:{description:e.description||"",height:e.height,width:e.width,url:e.url,color:e.color,type:"image/jpeg"}}),button:{component:h.jsx(Me,{variant:"tertiary",onClick:()=>t(!0),children:h.jsx(he.FormattedMessage,{id:"publishArticleForm_replaceImage_button"})})}}):h.jsx(Wr,{button:{component:h.jsx(Me,{variant:"secondary",onClick:()=>t(!0),children:h.jsx(he.FormattedMessage,{id:"publishArticleForm_selectImage_button"})})}})}var FT=(e=>(e.CitiesAndLocalGovernment="topic_CitiesAndLocalGovernment",e.Climate="topic_Climate",e.DigitalAndData="topic_DigitalAndData",e.Education="topic_Education",e.EquityJusticeAndInclusion="topic_EquityJusticeAndInclusion",e.HealthAndSocialCare="topic_HealthAndSocialCare",e.Innovation="topic_Innovation",e.LeadershipAndSkills="topic_LeadershipAndSkills",e.LifeInGovernment="topic_LifeInGovernment",e.Policymaking="topic_Policymaking",e.TransportAndInfrastructure="topic_TransportAndInfrastructure",e.WorkingAndTheEconomy="topic_WorkAndTheEconomy",e))(FT||{});let Id=null;const Ut="publishArticleForm_",p9={},m9=10,yR=({id:e="publish-article-form",values:t=p9,setShowImagePicker:n,functions:r,meta:i,gtm:a,isEditMode:s=!1})=>{var P;const o=he.useIntl(),l=y.useContext(Mt),{create:u,edit:c,onSuccess:d=()=>{},onFailure:f=()=>{}}=r||{},{isInOverlay:p=!1}=i||{},[g,m]=y.useState(!1),[E,v]=y.useState(t.body||""),[b,T]=y.useState(!1),[C,_]=y.useState("");y.useEffect(()=>{vc(t,p9)||sl(t.body)&&t.body!==E&&t.body!==void 0&&v(t.body)},[t.body]);const x=()=>{!l||!l.id?T(o.formatMessage({id:`${Ut}error_loggedOut`})):b&&T(!1)},S=I=>({condition:k=>{const B=k[I];return!B||typeof B!="string"?!0:B.length<m9},error:o.formatMessage({id:`${Ut}error_underMinLength`},{length:m9})}),F=!!E&&sl(E),R=()=>h.jsxs(h.Fragment,{children:[h.jsx(Tr,{}),h.jsx("p",{className:"text-medium",children:o.formatMessage({id:`${Ut}disclaimer`})})]}),L=[{id:"title",type:"textarea",value:t.title||"",limit:65,label:o.formatMessage({id:`${Ut}title_label`}),placeholder:o.formatMessage({id:`${Ut}title_placeholder`}),styling:{autosizeToFit:!0},functions:{onChange:x},validation:[{condition:"required"},S("title")]},{id:"subtitle",type:"textarea",value:t.subtitle,limit:115,label:o.formatMessage({id:`${Ut}subtitle_label`}),styling:{autosizeToFit:!0},placeholder:o.formatMessage({id:`${Ut}subtitle_placeholder`}),functions:{onChange:x},validation:[{condition:"required"},S("subtitle")]},{component:Ic,props:{formID:e,label:{visible:o.formatMessage({id:`${Ut}body_label`})},showLabel:!0}},{component:um,props:{id:`${e}-input`,value:E,placeholder:o.formatMessage({id:`${Ut}body_placeholder`}),meta:{isInOverlay:p},autoFocus:!1,functions:{onChange:I=>{v(I),x()}},styling:{toolbar:{showHeadingOption:!0}},"aria-invalid":!!b,"aria-errormessage":"error-message"}},{id:"tags",label:o.formatMessage({id:`${Ut}tags_label`}),type:"checkboxes",styling:{displayOptionsAsPills:!0},options:Object.values(FT).map(I=>({id:I,label:o.formatMessage({id:`${Ut}_tags_${I}`})})),value:t.tags||[],multipleOptions:{limit:3},validation:[{condition:"required",error:o.formatMessage({id:`${Ut}tags_error_required`})},{condition:I=>{var k;return((k=I==null?void 0:I.tags)==null?void 0:k.length)>3},error:o.formatMessage({id:`${Ut}tags_error_over_three`})}]},{component:Ic,props:{formID:e,label:{visible:o.formatMessage({id:`${Ut}cover_image_label`})},showLabel:!0}},{component:ER,props:{coverImage:t.coverImage||{},setShowImagePicker:n}}];return g?L.push({component:Tr}):L.push({component:R}),h.jsxs("section",{className:"publish-article-form",children:[h.jsx(Cr,{id:e,meta:{shouldReset:!1,shouldHide:!1,showRequiredLabels:!1,shouldScrollOnSuccess:!1},functions:{onSuccess:async I=>{if(!l||!l.id||!F)return;Id&&clearTimeout(Id),m(!0);const k={...I,body:E,coverImage:t.coverImage};try{s&&c?await c(k):u&&await u(k),Id=setTimeout(()=>{_(o.formatMessage({id:`${Ut}aria_success${s?"_edit":""}`})),d(k)},500)}catch{T(o.formatMessage({id:`${Ut}error`})),_(""),f()}},onFailure:f},fields:L,intlPath:Ut,button:{variant:"primary",size:{mobile:"small",600:"medium"},"data-gtm-event-context":a==null?void 0:a.context,"data-gtm-event-type":"publish-article-click",disabled:!l||!l.id||!F||!((P=t==null?void 0:t.coverImage)!=null&&P.url),text:{default:o.formatMessage({id:`${Ut}cta_submit${s?"_edit":""}`}),submitting:o.formatMessage({id:`${Ut}cta_submitting${s?"_edit":""}`}),submitted:o.formatMessage({id:`${Ut}cta_submitted${s?"_edit":""}`})},customOnSubmit:b?h.jsx(h.Fragment,{}):h.jsx(vR,{})},gtm:a}),b&&h.jsx(Ds,{id:"error-message",className:"error",children:typeof b=="string"&&b.includes(" ")?b:o.formatMessage({id:`${Ut}error`})}),C&&h.jsx(ot,{"aria-live":"polite",showOnFocus:!1,children:C})]})};const BT=({id:e="search",className:t="",handleToggle:n=!1,defaultValue:r="",gtmContext:i="search-bar",gtmEvent:a="form-submission"})=>{const{searchIsOpen:s=!0,isDesktopVersion:o=!1}=n||{},l=he.useIntl(),u=y.useRef(null);ks(()=>{!n||o||!s||u.current&&u.current.focus()},[s]);const c=d=>{d.preventDefault(),d.stopPropagation(),!(!u.current||!u.current.value||u.current.value.length<1)&&(window.location.href=`/search?search=${encodeURIComponent(u.current.value)}`)};return h.jsx("form",{onSubmit:c,className:ee("search-form gtm-trackable",t),role:"search","data-gtm-event-context":i,"data-gtm-event-type":a,children:h.jsx("fieldset",{id:`${e}-form`,hidden:n?!s:!1,children:h.jsxs("p",{children:[h.jsx(ot,{element:"label",htmlFor:e,children:l.formatMessage({id:"search_label"})}),h.jsx("input",{ref:u,type:"search",id:e,name:e,defaultValue:r,placeholder:l.formatMessage({id:"search_placeholder"}),onKeyDown:d=>{d.key==="Enter"&&c(d)}}),h.jsx("button",{className:"clear",onClick:d=>{d.preventDefault(),d.stopPropagation(),u.current&&u.current.value&&(u.current.value="")},children:h.jsx(ot,{children:l.formatMessage({id:"search_clear"})})}),h.jsx("button",{className:"search",onClick:c,children:h.jsx(ot,{children:l.formatMessage({id:"search_cta"})})})]})})})},g9=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 i=e.current.value.toString().toLowerCase().trim(),a={valid:!1,autoApproved:!1,exists:{auth:!1,engagement:!1,registration:!1,user:!1}};let s=Object.assign({},a);try{s=await t(i),s===void 0&&(s=a)}catch{return n([{type:"shouldManuallyApprove",value:!0},{type:"emailDetails",value:{email:i,boxType:"nonGov",isEnd2End:!1}},{type:"validFields.email",value:!1}])}const{valid:o=!1,autoApproved:l=!1,exists:u}=s;let c="";return o?c=l?"gov":"nonGov":u.registration?u.engagement&&!u.user?c=u.auth?"verify":"pending":c="exists":u.auth&&(c="exists"),n([{type:"shouldDisableButton",value:!1},{type:"shouldManuallyApprove",value:!l},{type:"emailDetails",value:{email:i,boxType:c,isEnd2End:/testing\+[0-9]+@apolitical.co$/.test(i)}},{type:"validFields.email",value:!0}])},bR=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"]}},TR=async({refs:e,dataToSubmit:t,createAccount:n,onSuccess:r,dispatch:i,state:a})=>{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=bR(new FormData(e.form.current)),o=Object.assign(s,t);await n(o),sessionStorage.setItem(hp.SESSION_STORAGE.EMAIL,s.email),r&&r({...s,...a.values}),i([{type:"showSuccessMessage",value:!0}])},_R=({shouldShow:e,placeholders:t,labels:n,functions:{validateEmail:r,resendVerificationCode:i},refs:a,state:s,dispatch:o,dataToSubmit:l,intl:u})=>{const{emailDetails:c}=s,d=(p,g)=>{p.current&&s.validFields[g]!==p.current.validity.valid&&o([{type:`validFields.${g}`,value:p.current.validity.valid}])},f=[{id:"full_name",type:"text",inputRef:a.name,placeholder:u.formatMessage({id:"signup_full_name_placeholder"}),functions:{onChange:()=>d(a.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:a.email,placeholder:u.formatMessage({id:"signup_email_address_placeholder"}),"aria-describedby":"email-helper-textbox",functions:{onBlur:()=>{g9({ref:a.email,validateEmail:r,dispatch:o})},onChange:(p,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:eb,props:{email:c.email,type:c.boxType,resendVerificationCode:i}}];return s.shouldManuallyApprove&&(f.push({id:"job_title",type:"text",inputRef:a.jobTitle,placeholder:u.formatMessage({id:"signup_job_title_placeholder"}),functions:{onChange:()=>d(a.jobTitle,"jobTitle")},validation:[{condition:"required"}],"data-testid":"signup-job-input"},{id:"organization",type:"text",inputRef:a.organisation,placeholder:u.formatMessage({id:"signup_organization_placeholder"}),functions:{onChange:()=>{d(a.organisation,"organisation")}},validation:[{condition:"required"}],autoComplete:"organization","data-testid":"signup-org-input"}),e.url&&f.push({id:"url",type:"text",label:u.formatMessage({id:"signup_url"},{small:p=>h.jsx("small",{children:p})}),placeholder:u.formatMessage({id:"signup_url_placeholder"}),validation:[{condition:"valid-url"}],"data-testid":"signup-url-input"})),e.expectation&&f.push({id:"expectation",className:"expectation",type:"text",label:(n==null?void 0:n.expectation)||u.formatMessage({id:"signup_expectation"},{small:p=>h.jsx("small",{className:"notes text-small",children:p})}),placeholder:(t==null?void 0:t.expectation)||u.formatMessage({id:"signup_expectation_placeholder"}),"data-testid":"signup-events-question"}),f.push({id:"terms",className:"text-small",type:"checkbox",inputRef:a.tc,label:u.formatMessage({id:"signup_terms"},{terms:p=>h.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:p}),privacy:p=>h.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:p})}),shownValue:"accepted",functions:{onChange:p=>{if(!p)return;const g=[];["name","email"].forEach(m=>{s.validFields[m]!==a[m].current.validity.valid&&(g.push({type:`validFields.${m}`,value:a[m].current.validity.valid}),m==="email"&&g9({ref:a.email,validateEmail:r,dispatch:o}))}),g.length&&o(g)}},validation:[{condition:"required"}],"data-testid":"signup-terms-checkbox"}),f};const CR=({className:e=""})=>h.jsxs("div",{className:ee("success-message",e),"data-testid":"success-message",children:[h.jsx("p",{className:"success-title",children:h.jsx(he.FormattedMessage,{id:"signup_success_title"})}),h.jsx(he.FormattedMessage,{id:"signup_success_text",values:{p:t=>h.jsx("p",{children:t})}})]});const xR={validFields:{name:!1,email:!1,jobTitle:!1,organisation:!1},emailDetails:{email:"",boxType:"",isEnd2End:!1},shouldManuallyApprove:!1,shouldDisableButton:!0,loadRecaptcha:!1,showSuccessMessage:!1,showError:!1},wR=({className:e="",labels:t={},placeholders:n={},functions:r={validateEmail:()=>Promise.resolve(),createAccount:()=>Promise.resolve(),handleError:()=>{},resendVerificationCode:()=>Promise.resolve()},shouldShow:i={},submitButton:a,dataToSubmit:s={ref:"sign-up-form"},...o})=>{const l=he.useIntl(),u=window.location.pathname.includes("/signup")?"/login":`/login?returnTo=${window.location.pathname+window.location.search}`,{title:c=!0,expectation:d=!1,url:f=!0,logInButton:p=!0,successMessage:g=!0}=i,m={title:c,expectation:d,url:f,logInButton:p,successMessage:g},[E,v]=y.useReducer(Us,xR),{validFields:b,emailDetails:T,shouldManuallyApprove:C,shouldDisableButton:_,showSuccessMessage:x,showError:S}=E,[F,R]=up.useCookies(["signup-this-session","functional-cookie-consent"]),L={form:y.createRef(),name:y.createRef(),email:y.createRef(),jobTitle:y.createRef(),organisation:y.createRef(),tc:y.createRef(),hiddenValidation:y.createRef()};y.useEffect(()=>{C===!0&&L.jobTitle.current&&L.jobTitle.current.focus()},[C]),y.useEffect(()=>{F["signup-this-session"]&&v([{type:"showSuccessMessage",value:!0}])},[F]),y.useEffect(()=>{x&&F["functional-cookie-consent"]&&R("signup-this-session","true",{path:"/",maxAge:3600})},[x]);const P=y.useMemo(()=>_R({placeholders:n,labels:t,shouldShow:m,functions:r,refs:L,state:E,dispatch:v,dataToSubmit:s,intl:l}),[s,r,l,L,m,E]),I=_?!0:C?!Object.values(b).every(k=>k===!0):!b.name||!b.email||["exists","pending","verify"].includes(T.boxType);return m.successMessage&&x?h.jsx(CR,{className:e}):h.jsxs("fieldset",{className:ee("signup-form-fieldset",e),"data-testid":"signup-form",children:[m.title&&h.jsx("p",{className:"signup-title",children:h.jsx(he.FormattedMessage,{id:"signup_title"})}),S&&h.jsx(Wr,{variant:"error",text:l.formatMessage({id:"signup_error"})}),h.jsx(Cr,{className:"signup-form",formRef:L.form,id:"sign-up-form",fields:P,intlPath:"signup",button:{variant:"primary",size:"medium",text:a||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:u,"data-gtm-event-context":"SignupForm","data-gtm-event-type":"login-click",text:l.formatMessage({id:"signup_button_login"})},meta:{shouldReset:!1,showRequiredLabels:!1,shouldShowCancelButton:m.logInButton},gtm:{context:"SignupForm",event:"signup-submit-click"},functions:{onSuccess:async()=>{await TR({refs:L,dataToSubmit:s,createAccount:r.createAccount,onSuccess:r.onSuccess,dispatch:v,state:E})},onCatch:k=>{r.handleError(k),v([{type:"showSuccessMessage",value:!1},{type:"showError",value:!0}])}}}),h.jsx("button",{className:"validation-button",ref:L.hiddenValidation})]})};function AR({parentId:e,isMember:t,formFunctions:n,leave:r,join:i,meta:a}){const s=he.useIntl();return h.jsx(x0,{form:{content:{type:Ke.Reply,slugs:{}},functions:n,meta:{isEditing:!1,isAutoFocused:!1,isPrepopulated:!1,showSuccessMessage:!1,...a},placeholder:s.formatMessage({id:"discussion_responses_placeholder"})},parentId:e,membershipRequiredToPost:{isMember:t,required:!0,join:i,leave:r,notMemberStateText:s.formatMessage({id:"community_joinToPost"})}})}function SR({hasNextPage:e,fetchNextPage:t,setFocusReplyIndex:n,totalReplies:r}){const i=he.useIntl(),a=()=>{n(r),t()};return h.jsx(xl,{hasNextPage:e,loadNextPage:a,icon:{icon:"arrow-down",position:"right"},messages:{button:i.formatMessage({id:"loadMore_button"}),error:i.formatMessage({id:"loadMore_error"})}})}function kR({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:i,user:a}){const{mutate:s}=vt.useMutation({mutationFn:e,onMutate:o=>t(l=>{const u=fg({reply:d6(o),user:a});return Is(u,l,{replace:!1,append:(o==null?void 0:o.replyId)!==void 0})}),onError:n,onSuccess:(o,l,u)=>{const c=fg({reply:o,user:a});r.setQueryData(i,Is(c,u,{replace:!0,append:(l==null?void 0:l.replyId)!==void 0})),setTimeout(()=>{Pp(c.id,"reply")},0)}});return s}function DR({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=vt.useMutation({mutationFn:e,onMutate:({replyId:i,content:a})=>t(s=>{const o=Dn(i,s);return o&&(o.data.content=a),s}),onError:n});return r}function OR({replies:e,user:t,replyType:n}){return!e||!(t!=null&&t.id)?[]:e.map(({id:r,own_children:i,latest_children:a,children_counts:s,data:o,created_at:l,parent:u,...c})=>{var E,v,b,T;const d=(((E=i==null?void 0:i.like)==null?void 0:E.length)||0)>0,f=(((v=a==null?void 0:a.like)==null?void 0:v.length)||0)>0,p=d?(b=i==null?void 0:i.like)==null?void 0:b.find(C=>{var _;return((_=C==null?void 0:C.user)==null?void 0:_.id)===(t==null?void 0:t.id)}):!1,g=typeof p=="object"?(p==null?void 0:p.id)??"":"",m=f?(T=a==null?void 0:a.like)==null?void 0:T.map(C=>{var _,x,S;return{id:(_=C==null?void 0:C.user)==null?void 0:_.id,name:(S=(x=C==null?void 0:C.user)==null?void 0:x.data)==null?void 0:S.name}}):!1;return{user:c==null?void 0:c.user,body:n===$t.Courses?p6({content:o.content}):IR(o),locale:o==null?void 0:o.locale,createdAt:l,data:NR(o),likeId:g,liked:f,likes:(s==null?void 0:s.like)||0,peopleWhoLiked:m,replyId:r,parent:u,userLiked:!!p}})}function NR(e){if(!e||!e.mentioned_users)return{};const t=e==null?void 0:e.mentioned_users,n=(e==null?void 0:e.additional_data)||{};return{mentions:t,...n}}function IR(e){var t;return e?typeof e.content=="string"?e.content:((t=e==null?void 0:e.content)==null?void 0:t.text)||"":""}function MT({queryFns:{create:e,edit:t,like:n,list:r,remove:i,unlike:a},queryKey:s,type:o=$t.Communities}){const l=vt.useQueryClient(),u=Xc(),c={queryClient:l,queryKey:s},d={mutationHandlers:{error:kp(c),mutate:Dp(c)},user:u,...c},f=kR({...d,mutationFn:e}),p=DR({...d,mutationFn:t}),g=PR({...d,mutationFn:n}),m=FR({...d,mutationFn:i}),E=BR({...d,mutationFn:a}),{replies:v,...b}=RR({queryKey:s,queryFn:r});return{replies:OR({replies:v,user:u,replyType:o}),mutations:{create:f,edit:p,remove:m,like:g,unlike:E},user:u,...b}}function PR({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:i}){const{mutate:a}=vt.useMutation({mutationFn:e,onMutate:({replyId:s})=>t(o=>{const l=Dn(s,o);return l&&hg({reply:l}),o}),onError:n,onSuccess:(s,{replyId:o},l)=>{const u=Dn(o,l);u&&hg({reply:u,reaction:s}),r.setQueryData(i,l)}});return a}function RR({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:i,hasNextPage:a,fetchNextPage:s}=vt.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:{next:""},getNextPageParam:o=>(o==null?void 0:o.next)||null});return{replies:Ip(n),error:r,isLoading:i,hasNextPage:a,fetchNextPage:s}}function FR({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=vt.useMutation({mutationFn:e,onMutate:({replyId:i})=>t(a=>Y4(i,a)),onError:n});return r}function BR({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:i}=vt.useMutation({mutationFn:e,onMutate:({replyId:a})=>t(s=>{const o=Dn(a,s);return o&&f6({reply:o,user:r}),s}),onError:n});return i}const MR=({activityId:e,basePath:t,isMember:n,parentId:r,replyId:i,functions:{reactions:a,form:s,likes:o},type:l=$t.Communities})=>{const u=he.useIntl(),c=3,{replies:d,fetchNextPage:f,hasNextPage:p,isLoading:g,mutations:{create:m,edit:E,like:v,remove:b,unlike:T}}=MT({queryKey:[t,r,e,i,"replies"],queryFns:{...a,list:x=>a.list({...x,reactionId:i})},type:l});dp([g]);const[C,_]=y.useState(!0);return h.jsxs(h.Fragment,{children:[(d==null?void 0:d.length)>=c&&h.jsx(Me,{className:"nested-replies-show-toggle",variant:"secondary",size:"small",styling:{muted:!0},icon:{icon:`arrow_corner-${C?"up_left":"down_right"}`,position:"left"},onClick:()=>_(!C),children:u.formatMessage({id:`discussion_thread_${C?"hide":"show"}`},{count:d==null?void 0:d.length})}),C&&h.jsx(I3,{loadMore:{isLoading:g,hasNextPage:p,loadNextPage:()=>f()},form:{parentId:r,content:{type:Ke.Reply,slugs:{question:`${t}/${r}`,answer:e,reply:i}},functions:{create:(x,{body:S})=>m({activityId:e,replyId:i,content:S}),...s},meta:{isEditing:!1,isAutoFocused:!0,isPrepopulated:!1,showSuccessMessage:!1}},children:d&&d.length>0?d==null?void 0:d.map(({replyId:x,likes:S,data:F,body:R,createdAt:L,userLiked:P,peopleWhoLiked:I,parent:k,user:B,likeId:H})=>h.jsx(Ll,{isCommunity:!0,content:{id:x,type:Ke.Reply,body:R,createdAt:L,slugs:{question:`${t}/${r}`,answer:e,reply:k},slug:"",author:Vs(B),userLiked:P,likes:S,peopleWhoLiked:l===$t.Courses?!1:I,data:F},forceHide:{shareLink:l===$t.Courses},userHasPermissions:n,functions:{content:{createContent:()=>null,deleteContent:()=>b({replyId:x}),updateContent:(q,{body:N})=>E({replyId:x,content:N})},likes:{createLike:()=>v({replyId:x}),deleteLike:()=>T({replyId:x,reactionId:H}),listLikes:q=>o.list({replyId:x,...q})},comments:{},form:s},styling:{showShareLinkButton:!0},badges:{showBadges:!0,scopes:[{scope:ln.Communities,area:r||""},{scope:ln.Platform,area:"all"}]},disableMentions:l===$t.Courses,basePath:t,parentId:r},x)):null})]})};function LR({formFns:e,activityId:t,basePath:n,focus:r,isMember:i,parentId:a,reply:s,type:o=$t.Communities}){const{body:l,data:u,likeId:c,likes:d,peopleWhoLiked:f,replyId:p,createdAt:g,user:m,userLiked:E}=s,{edit:v,like:b,remove:T,unlike:C}=e.mutations;return h.jsx(k3,{children:h.jsx(Ll,{isCommunity:!0,content:{id:p,type:Ke.Reply,body:l,createdAt:g,slugs:{question:`${n}/${a}`,answer:t,reply:p},slug:p,author:Vs(m),userLiked:E,likes:d,peopleWhoLiked:o===$t.Courses?!1:f,data:u},userHasPermissions:i,functions:{content:{createContent:()=>null,deleteContent:()=>T({replyId:p}),updateContent:(_,{body:x})=>v({replyId:p,content:x})},likes:{createLike:()=>b({replyId:p}),deleteLike:()=>C({replyId:p,reactionId:c}),listLikes:_=>e.likes.list({replyId:p,..._})},comments:{},form:e.form},forceHide:{shareLink:o===$t.Courses},badges:{showBadges:!0,scopes:[{scope:ln.Communities,area:a||""},{scope:ln.Platform,area:"all"}]},disableMentions:o===$t.Courses,children:h.jsx(MR,{basePath:n,parentId:a,activityId:t,replyId:p,isMember:i,functions:e,type:o}),styling:{showShareLinkButton:!0},setFocus:r,basePath:n,parentId:a},p)},p)}const ru="ALL",LT=({activityId:e,basePath:t,parentId:n,activityTotalReplies:r,isMember:i,functions:{form:a,join:s,leave:o,likes:l,reactions:u},profile:c,showReplies:d,type:f=$t.Communities,repliesFilters:p})=>{const g=he.useIntl(),m=y.useContext(Mt),{fetchNextPage:E,hasNextPage:v,isLoading:b,replies:T,mutations:{create:C,remove:_,edit:x,like:S,unlike:F}}=MT({queryKey:[t,n,e,"replies"],queryFns:u,type:f}),[R,L]=y.useState(f===$t.Courses&&m.locale||ru),[P,I]=y.useState([]),k=y.useMemo(()=>T,[JSON.stringify(T)]);y.useEffect(()=>{if(!k)return;const N=!R||R===ru||f!==$t.Courses?k:k.filter(J=>J.locale===R);I(N)},[k,R]);const[B,H]=y.useState(null);dp([b]),Z4();const q={create:(N,J)=>{const{body:X}=J;C({activityId:e,content:X})},...a};return h.jsxs("section",{className:"replies-feed",children:[h.jsx(N3,{type:"comment",responses:r,isLoading:b}),d?h.jsxs(h.Fragment,{children:[h.jsx(AR,{parentId:n,isMember:i,join:s,leave:o,formFunctions:q,meta:{isAutoFocused:f===$t.Courses||!1}}),f===$t.Courses&&(p==null?void 0:p.isEnabled)&&h.jsxs("section",{className:"replies-feed-language-switcher",style:{display:"flex"},children:[h.jsx(Cr,{id:"replies-feed-language-switcher",fields:[{id:"language",label:!1,type:"select",initialValue:R,options:[{id:ru,label:g.formatMessage({id:"activitySection_language_switcher_all_languages_option"})},...(p==null?void 0:p.options)||[]],functions:{onChange:N=>L(N)}}],functions:{},button:{hideButton:!0}}),h.jsx(Me,{icon:"info-inside-circle",variant:"tertiary",className:"language-switcher-info-button",tooltip:g.formatMessage({id:"activitySection_language_switcher_info"}),forceTooltip:!0,children:h.jsx(ot,{children:g.formatMessage({id:"activitySection_language_switcher_info"})})})]}),P==null?void 0:P.map((N,J)=>h.jsx(LR,{activityId:e,basePath:t,focus:B===J,formFns:{form:a,likes:l,reactions:u,mutations:{remove:_,edit:x,like:S,unlike:F}},isMember:i,parentId:n,reply:N,type:f},N.replyId)),b?h.jsx(h.Fragment,{children:" "}):h.jsx(SR,{hasNextPage:v,fetchNextPage:E,setFocusReplyIndex:H,totalReplies:T.length})]}):h.jsx(Ln,{children:h.jsx(he.FormattedMessage,{id:"replies_feed_missing_polls_vote_message"})}),h.jsx(w0,{form:c})]})};function $R({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:i,hasNextPage:a,fetchNextPage:s,refetch:o}=vt.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:{next:""},getNextPageParam:c=>(c==null?void 0:c.next)||null}),l=Ip(n),u=`${l.length||0}${a?"+":""}`;return{likes:l,likesCount:u,error:r,isLoading:i,hasNextPage:a,fetchNextPage:s,refetch:o}}function jR({queryFns:{list:e},queryKey:t}){const{likes:n,...r}=$R({queryKey:t,queryFn:e});return{likes:n,...r}}function $T({basePath:e,parentId:t,activityId:n,likeCount:r,functions:i}){const{likes:a,fetchNextPage:s,hasNextPage:o,refetch:l}=jR({queryKey:[e,t,n,"likes"],queryFns:i.likes});y.useEffect(()=>{l()},[l]);const u=a.map(({user:c})=>c).map(c=>c?Vs(c):void 0).filter(c=>c&&typeof c!="string");return h.jsx("section",{className:"likes-feed",children:h.jsx(S3,{members:{data:u,total:r},showHeader:!1,showPlaceholders:!0,communitySlug:t,hasNextPage:o&&u.length<r,loadNextPage:s})})}const jT=({showModal:e=!0,functions:{onClose:t,likes:n},likeCount:r,className:i,...a})=>{const s=he.useIntl();return h.jsx(Ti,{id:"likes-modal",title:s.formatMessage({id:"discussion_likes"},{number:r}),isOpen:e,functions:{onClose:t},className:ee("profile-modal in-portal",i,{open:e}),maxWidth:600,children:h.jsx($T,{...a,likeCount:r??0,functions:{likes:n}})})},HR=Object.freeze(Object.defineProperty({__proto__:null,default:jT},Symbol.toStringTag,{value:"Module"})),UR={results:[{created_at:"2024-05-16T13:17:45.940899Z",updated_at:"2024-05-16T13:17:45.940899Z",id:"ab4b7ab0-f4fe-469f-a8e7-5a52b3e55333",user_id:"9ed21585-63be-4446-96ce-3e703820eb73",user:{id:"1234",data:{name:"Han Solo",thumbnail:"https://placehold.co/400x400",jobTitle:"Smuggler",organization:"Rebel Alliance",badges:{communities:{"endor-alumni":["blue-badge"]}}}},kind:"like",activity_id:"869e5a90-0eba-11ef-8080-80017b714aaf",data:{mentioned_users:null},parent:"",latest_children:{},children_counts:{}},{created_at:"2024-05-16T13:17:45.940899Z",updated_at:"2024-05-16T13:17:45.940899Z",id:"db4b7ab0-f4fe-469f-a8e7-5a52b3e55373",user_id:"9ed21585-63be-4446-96ce-3e703820eb73",user:{created_at:"2023-08-22T11:56:10.585365Z",updated_at:"2024-03-13T11:31:49.447916Z",id:"9ed21585-63be-4446-96ce-3e703820eb73",data:{jobTitle:"Admiral",name:"Princess Leia",organization:"Rebela Alliance",thumbnail:"https://placehold.co/400x400",badges:{platform:{all:["orange-badge"]}}}},kind:"pin",activity_id:"769e5a90-0eba-11ef-8080-80017b714aaf",data:{mentioned_users:null},parent:"",latest_children:{},children_counts:{}}],next:"xy12345"};const zR=3e3,HT=({url:e,gtm:t={context:"ShareLink",event:"copy-link-click"}})=>{const n=he.useIntl(),r="discussion_share_copy_link",[i,a]=y.useState({isOpen:!1,isCopied:!1});return h.jsxs("li",{className:"share-link-wrapper",children:[h.jsx(Es,{className:"gtm-trackable",icon:{icon:"link_chain"},onMouseOver:()=>a({...i,isOpen:!0}),onFocus:()=>a({...i,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});const s=new CustomEvent("ariaLive",{detail:{message:n.formatMessage({id:`${r}_success`})}});document.dispatchEvent(s),setTimeout(()=>{a({isOpen:!1,isCopied:!1})},zR)})},"data-gtm-event-context":t.context,"data-gtm-event-type":t.event,"data-testid":"share-link",screenreaderText:n.formatMessage({id:r})}),h.jsx(Fa,{className:ee({copied:i.isCopied}),isOpen:i.isOpen,styling:{hasPointer:"bottom",extraPadding:!1},children:n.formatMessage({id:`${r}${i.isCopied?"_success":""}`})})]})};const sa="discussion_",UT=({className:e,gtmContext:t,contentType:n,likes:r,comments:i,replies:a,edit:s,shareLink:o,moreMenu:l})=>{const u=he.useIntl(),c=[];return l&&l.reportData&&c.push({text:u.formatMessage({id:`${sa}moreMenu_report`}),onClick:d=>{d.stopPropagation()},href:`mailto:community@apolitical.co?subject=${encodeURI(u.formatMessage({id:`${sa}report_subject`}))}&body=${encodeURI(u.formatMessage({id:`${sa}report_body`},{contentType:n||"",contentSlug:l&&l.reportData&&l.contentSlug||"",contentUrl:l&&l.reportData&&l.reportData.contentUrl||""}))}`,icon:"flag"}),h.jsxs("ul",{className:ee("actions text-medium",e),"data-testid":`${n}-actions`,children:[r?h.jsx(Q4,{element:"li",likes:r.count,isShort:!1,userLiked:r.userLiked,content:{type:n,slugs:r.content.slugs,slug:r.content.slug},canLike:r.canLike,peopleWhoLiked:r.peopleWhoLiked,activityId:r.activityId,functions:r.functions,basePath:r.basePath||"",parentId:r.parentId||""}):h.jsx(h.Fragment,{}),i?h.jsx("li",{children:h.jsx(Es,{shortText:`${i.count??0}`,onClick:d=>{d.preventDefault(),d.stopPropagation(),i.functions.onClick()},icon:{icon:"speech-bubble_square"},"data-testid":"comment","data-gtm-event-context":t,"data-gtm-event-type":`answer-${n}-click`,screenreaderText:u.formatMessage({id:`${sa}comments_screenReader`},{count:i.count}),children:u.formatMessage({id:`${sa}comments${i.count===null?"_loading":""}`},{count:i.count})})}):h.jsx(h.Fragment,{}),a?h.jsx("li",{children:h.jsx(Es,{styling:{muted:!0},onClick:a.functions.onClick,icon:{icon:"speech-bubble_square"},"data-testid":"reply",disabled:!a.canReply,children:u.formatMessage({id:`${sa}reply`})})}):h.jsx(h.Fragment,{}),s?h.jsx("li",{className:"edit-button-item",children:h.jsx(Es,{styling:{muted:!0},onClick:s.onClick,icon:{icon:"pencil-paper"},"data-testid":"edit",children:u.formatMessage({id:`${sa}action_edit`})})}):h.jsx(h.Fragment,{}),o?h.jsx(HT,{url:o.url,gtm:{context:t||"",event:`copy-link-${n}-click`}}):h.jsx(h.Fragment,{}),l?h.jsx(Rc,{element:"li",id:`more-${l.contentSlug}`,options:[...l.options||[],...c]}):h.jsx(h.Fragment,{})]})};const qR=({breadcrumbs:e,cutoff:t=20,className:n=""})=>{const r=he.useIntl();return h.jsxs(h.Fragment,{children:[h.jsx(ot,{element:"p",children:r.formatMessage({id:"breadcrumbs_label"})}),h.jsx("ul",{className:ee("breadcrumbs text-small",n),children:e.map(({text:i,href:a,current:s=!1},o)=>{const l={};return s&&(l["aria-current"]="location"),h.jsxs("li",{children:[s&&h.jsx(ot,{element:"span",children:r.formatMessage({id:"breadcrumbs_currentPage"})}),h.jsx(Qi,{href:s?void 0:a,...l,children:Ss(i,t)})]},`${window.btoa(i)}_${o}`)})})]})};const cm=({variant:e="default",data:{image:t,url:n,title:r,description:i},onClick:a,gtm:s,...o})=>{if(!n)return h.jsx(h.Fragment,{});let l=n.split("//");l.length>1?l=l[1]:l=l[0],l=l.split("/"),l=l[0];const{context:u="EnrichedLink",event:c="enriched-link-click"}=s??{};return h.jsxs("aside",{className:ee("enriched-url gtm-trackable",{"has-image":t,[e]:e!=="default"}),onClick:d=>{if(d.preventDefault(),d.stopPropagation(),a){a(d);return}window.open(n,"_blank")},"data-gtm-event-context":u,"data-gtm-event-type":c,children:[h.jsx("small",{children:l}),h.jsx("p",{className:"title text-medium",children:h.jsx("a",{...o,href:n,target:"_blank",rel:"noreferrer",children:r})}),i&&e!=="condensed"?h.jsx("p",{className:"text-small",children:i}):h.jsx(h.Fragment,{}),t&&t.src?h.jsx("p",{className:"img",children:h.jsx("img",{src:t.src,alt:t.alt||"",loading:"lazy",fetchpriority:"low",width:t.width||"auto",height:t.height||"100%"})}):h.jsx(h.Fragment,{})]})};const zT=({options:e,defaultOptions:t=[],allOption:n=!1,allowMultiple:r=!0,onChange:i=()=>{},preventNoOptionSelected:a=!1,className:s="",styling:o,gtm:l})=>{const u=he.useIntl(),{muted:c,large:d}=o||{},f=n?[{id:"all",text:typeof n!="boolean"&&n.text||u.formatMessage({id:"filters_all"})},...e]:e,[p,g]=y.useState(n?["all"]:t.length?t.map(b=>b.id):[]),[m,E]=y.useState(0),v=(b,T)=>{let C=[];p.includes(b)&&!a?C=p.filter(_=>_!==b):b==="all"?C=["all"]:r?C=[...p.filter(_=>_!=="all"),b]:C=[b],g(_=>(i&&typeof i=="function"&&i({current:C,previous:_}),C)),T&&typeof T=="function"&&T()};return h.jsx("ul",{className:ee("filters",s),children:f.map(({id:b,text:T,disabled:C=!1,callback:_=()=>{},content:x},S)=>{let F={tabIndex:m===S?0:-1};return C&&(F={disabled:!0,"aria-label":u.formatMessage({id:"filters_disabled"},{name:T})}),h.jsx("li",{children:h.jsx("button",{"data-gtm-event-context":(l==null?void 0:l.context)||"filters","data-gtm-event-type":(l==null?void 0:l.type)||`${T.toLowerCase().replace(" ","-")}-click`,className:ee(b,{selected:p.includes(b),large:d,muted:c}),onClick:R=>{R.preventDefault(),R.stopPropagation(),v(b,_)},onKeyDown:R=>{var k,B;let L=S+1,P,I;switch(R.code){case"Enter":case"Space":R.preventDefault(),R.stopPropagation(),v(b,_);break;case"ArrowLeft":case"ArrowRight":R.preventDefault(),R.stopPropagation(),R.code==="ArrowLeft"?(L=S-1,L<0&&(L=f.length-1)):L>=f.length&&(L=0),E(L),P=R.currentTarget.closest("li"),I=(k=P==null?void 0:P.parentElement)==null?void 0:k.children[L],(B=I==null?void 0:I.querySelector("button"))==null||B.focus();break}},"aria-selected":p.includes(b),...F,children:x||T})},b)})})},WR=(e,t,n)=>{const r=String(e);if(!n||!n.length)return t?`/${r}/${t}`:`/${r}`;let i="",a=!1;return n.forEach(({url:s,position:o})=>{o==="before-lang"?(i+=`/${s}`,a=!0):(i.includes(`/${r}/`)||(i+=`/${r}`),i+=`/${s}`)}),i.includes(`/${r}/`)||(i+=`/${r}`),t&&(i+=`/${t}`),a?{url:i,urlForRouter:`/${i.split("/").slice(2).join("/")}`}:i};const iu="languageSwitcher_",VR=({currentLanguage:e,isOriginalLanguage:t=!1,isHumanTranslation:n=!1,translations:r,onChange:i,urlParts:a,variant:s="default",label:o,className:l=""})=>{const u=he.useIntl(),{updateLanguage:c=()=>{}}=y.useContext(vp),[d,f]=y.useState(e);if(y.useEffect(()=>{e!==d&&f(e)},[e]),!r||!Object.values(r).some(E=>E&&E.post_name))return null;const g=Object.keys(r),m=d!==e;return h.jsxs("div",{className:ee("language-switcher text-small",s,l),children:[h.jsxs("nav",{children:[s!=="short"&&h.jsx("p",{children:o||u.formatMessage({id:`${iu}label`})}),h.jsx("ul",{children:g.map(E=>{var C;if(!gc.ALL_LOCALES.includes(E))return null;const v=(C=r[E])==null?void 0:C.post_name,b=gc.ALL_LOCALES_WITH_LABELS.filter(_=>_.value===E)[0].title;let T={className:E};if(d===E)T["aria-label"]=u.formatMessage({id:`${iu}selected`},{language:b});else{const _=WR(E,v,a);T={...T,href:typeof _=="string"?_:_.url,onClick:x=>{f(E),c(E),typeof i<"u"&&(x.preventDefault(),x.stopPropagation(),i(E,typeof _=="string"?_:_.urlForRouter))}}}return h.jsx("li",{children:h.jsx(Qi,{...T,fallbackElement:"span",children:b})},E)})}),s!=="short"&&!m&&h.jsx("p",{children:u.formatMessage({id:`${iu}translation_${t?"original":n?"human":"machine"}`})})]}),s!=="short"&&!m&&!t&&!n&&h.jsx("small",{children:u.formatMessage({id:`${iu}disclaimer`},{email:us.support,link:E=>{const v=`mailto:${E}`;return h.jsx("a",{href:v,children:E})}})})]})};const Pd=he.createIntl({locale:"en",messages:zn}),xl=({hasNextPage:e=!0,loadNextPage:t=()=>{},isLoading:n=!1,variant:r="secondary",size:i="medium",styling:a={muted:!1,fullWidth:!1},icon:s=!1,messages:o={button:Pd.formatMessage({id:"loadMore_button"}),endOfFeed:Pd.formatMessage({id:"loadMore_endOfFeed"}),error:Pd.formatMessage({id:"loadMore_error"})},className:l="",gtmContext:u="LoadMore"})=>{const[c,d]=y.useState(""),f=async p=>{if(!n)try{await t(p)}catch(g){g instanceof Error?d(g.message):d("Unknown error")}};return!c&&!e&&!o.endOfFeed?null:h.jsx("footer",{className:ee("load-more",l),children:!c&&e?h.jsx(Me,{variant:r,size:i,styling:a,icon:s,onClick:f,"data-gtm-event-context":u,"data-gtm-event-type":"load-more-click",disabled:n,className:"gtm-trackable","data-testid":"load-more-button",children:o.button}):o.endOfFeed&&(!c||c!=null&&c.includes("Cannot read items"))?h.jsx("p",{children:o.endOfFeed}):c&&h.jsx("p",{className:"error",children:o.error})})};const dm=({variant:e="default",version:t="default",className:n="",...r})=>{const i=cp();return h.jsx("p",{className:"logo-wrapper",children:h.jsx("a",{href:i||"/home/",className:ee("logo",e,t,n),...r,children:h.jsx(ot,{children:h.jsx(he.FormattedMessage,{id:"apolitical"})})})})};let au=!1;const Rc=({element:e="div",id:t="more-menu",options:n,className:r=""})=>{const i=he.useIntl(),a=y.useRef(null),[s,o]=y.useState(!1),l=u=>{a.current&&u.target instanceof HTMLElement&&!a.current.contains(u.target)&&o(!1)};return y.useEffect(()=>(document.addEventListener("click",l,!0),()=>{document.removeEventListener("click",l,!0)})),y.createElement(e,{ref:a,className:ee("more-menu text-medium",r),children:h.jsxs(h.Fragment,{children:[h.jsx(Me,{variant:"tertiary",size:"medium","data-testid":"more-menu",icon:{icon:"ellipsis"},onClick:()=>o(!s),"aria-haspopup":"true","aria-expanded":s,"aria-controls":t,screenreaderText:i.formatMessage({id:"moreMenu"}),className:"more-menu-button"}),h.jsx("ul",{id:t,hidden:!s,children:n.map(({href:u,onClick:c,text:d,icon:f,...p},g)=>{const m={...p,onClick:E=>{o(!1),typeof c=="function"&&c(E)},onFocus:()=>{au&&(clearTimeout(au),au=!1)},onBlur:()=>{au=setTimeout(()=>{o(!1)},100)}};return u&&(m.href=u),h.jsx("li",{className:"more-menu-list-item",children:h.jsx(Me,{variant:"tertiary",size:"medium",icon:f?{icon:f,position:"left"}:!1,...m,children:d})},`${window.btoa(d)}_${g}`)})})]})})},KR=(e,t=!1)=>t?e.replaceAll("/","")===t:typeof window<"u"&&window.location&&window.location.pathname===e;const GR=y.lazy(()=>Promise.resolve().then(()=>i7)),YR=[{key:"homepage",href:"/home/"},{key:"events",href:"/events/"},{key:"microcourses",href:"/microcourses/"},{key:"articles",href:"/solution-articles/"},{key:"communities",href:"/communities/"}],qT=({activeLink:e,profile:t})=>{const n=he.useIntl(),r=y.useContext(Mt),i=r&&typeof r.id=="string";return h.jsxs("ul",{id:"navigation-menu",className:"text-medium",children:[YR.map(({key:a,href:s})=>{const o=KR(s,e),l={};return o&&(l["aria-current"]="page"),h.jsx("li",{className:ee(a,{active:o}),children:h.jsx("a",{href:s,"data-gtm-event-type":`${a}-click`,"data-gtm-event-context":"NavigationMenu",className:"gtm-trackable",...l,children:n.formatMessage({id:`navigationMenu_links_${a}`})})},a)}),i&&t&&h.jsx(GR,{element:"li",member:r,styling:{variant:"card",isCondensed:!1},functions:{profile:t},className:"profile gtm-trackable","data-testid":"profile-link",alt:"",gtmContext:"NavigationMenu",gtmType:"profile-click"})]})},co=(e,t,n)=>`${e}?share=${t}${n?`&uuid=${n}`:""}`,ZR=({title:e,link:t,referrer:n})=>[{key:"linkedin",icon:"social_linkedin",url:`https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(`${co(t,"linkedin",n)}&src=linkedin`)}&title=${encodeURIComponent(e)}&source=Apolitical`},{key:"twitter",icon:"social_twitter",url:`https://twitter.com/share?ref_src=twsrc%5Etfw&url=${encodeURIComponent(`${co(t,"twitter",n)}&src=twitter`)}&text=${encodeURIComponent(e)}&via=${encodeURIComponent("apoliticalco")}`},{key:"facebook",icon:"social_facebook",url:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(`${co(t,"facebook",n)}`)}&t=${e}`},{key:"email",icon:"share_email",url:`mailto:?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`${e}
|
|
163
163
|
|
|
164
164
|
${co(t,"mailto",n)}&src=email`)}`},{key:"clipboard-copy",icon:"share_copy-link",url:co(t,"copy",n),shouldRender:()=>navigator&&navigator.clipboard&&navigator.clipboard.writeText,onClick:(r,i)=>(r.preventDefault(),r.stopPropagation(),navigator.clipboard.writeText(i))}];const QR="shareLinks_",XR=({title:e,link:t,referrer:n,gtmContext:r="ShareLinks",size:i="large",variant:a="default",className:s=""})=>{const o=he.useIntl(),l=ZR({title:e,link:t,referrer:n});return h.jsxs("aside",{className:ee("share-links",i,a,s),children:[h.jsx("p",{className:"text-small",children:o.formatMessage({id:"shareLinks_label"})}),h.jsx("ul",{children:l.map(({key:u,icon:c,url:d,shouldRender:f=!0,onClick:p})=>{if(typeof f=="function"&&!f())return null;const g={};return p&&(g.onClick=m=>p(m,d)),h.jsx("li",{children:h.jsx(Me,{size:i,variant:"tertiary",icon:{icon:c||u},href:d,target:"_blank",rel:"noopener noreferrer",className:"gtm-trackable","data-gtm-event-context":`${r}-SocialButtons`,"data-gtm-event-type":`${u}-click`,"data-testid":"link",screenreaderText:o.formatMessage({id:`${QR}link_${u}`}),...g})},u)})})]})};const JR=({tabs:e,className:t="",preventLocationChange:n})=>{var g;const r=(m,E,v)=>(m||(m=`panel-${window.btoa(E)}-${v}`),m),i=Yi(!0)||0;let a=e.findIndex(m=>m.current===!0);if(a<0&&(a=0),window.location.hash){const m=window.location.hash.replace("#","");if(e.find(v=>v.id===m)){for(let v=0;v<e.length;v++)if(r(e[v].id,e[v].text,v)===m){a=v;break}}}const[s,o]=y.useState((g=e[a])!=null&&g.id?e[a].id:r(e[a].id,e[a].text,a)),[l,u]=y.useState(""),c=(m,E)=>{switch(m.key){case"ArrowLeft":case"ArrowRight":{m.preventDefault();let v=E;m.key==="ArrowLeft"?E>0?v=E-1:v=e.length-1:m.key==="ArrowRight"&&(E<e.length-1?v=E+1:v=0);const b=r(e[v].id,e[v].text,v),T=document.getElementById(`tab-${b}`);T==null||T.focus(),u(b);break}case"Enter":o(l),window.location.hash=`#${l}`;break}},d=m=>{let E=!1;return m.target==="min-width"&&i>=m.value&&(E=!0),m.target==="max-width"&&i<=m.value&&(E=!0),E};y.useEffect(()=>{if(e[a].hasCarousel){const m=new CustomEvent("hiddenSectionVisible",{detail:{id:s}});window.dispatchEvent(m)}},[s]);const f=[],p=[];return e.forEach(({id:m,text:E,content:v,href:b,hasCarousel:T,breakpoint:C},_)=>{if(C&&!d(C))return;m=r(m,E,_);const x=s===m,S={};b||(S["aria-controls"]=m,S.onClick=F=>{F.preventDefault(),F.stopPropagation(),o(m),!n&&window.history.replaceState(null,"",`#${m}`)},p.push(h.jsx("section",{id:m,hidden:!x,role:"tabpanel","aria-labelledby":`tab-${m}`,"aria-live":x?"assertive":"off",children:typeof v=="string"?h.jsx("p",{children:v}):v},`section-${m}`))),f.push(h.jsx("li",{"data-testid":"navigation-tab",children:h.jsx("a",{href:b||`#${m}`,id:`tab-${m}`,"aria-controls":m,className:ee({selected:x}),role:"tab",tabIndex:x?0:-1,"aria-selected":x,onKeyDown:F=>c(F,_),...S,children:E})},`tab-${m}`))}),h.jsxs("div",{className:ee("tabs-wrapper",t),children:[h.jsx("ul",{className:"tabs",role:"tablist",children:f}),h.jsx("div",{className:"tab-content",children:p})]})};const eF={"2-1":901,"1-3":769,"1-1":769},WT=({layout:e="2-1",hideOnMobile:t=!1,hasCSSContainers:n=!1,className:r="",children:i})=>{const a=Yi(!0);let s=i;return y.Children.count(i)===1&&(s=y.Children.toArray(i)[0],s.props&&(s=s.props.children)),h.jsx("section",{className:ee("columns",`layout-${e}`,r,{"has-containers":n}),children:y.Children.map(s,(o,l)=>t!==!1&&l===t&&a&&a<eF[e]?null:o)})};const ea=({children:e,className:t="",styling:n={},...r})=>{const{background:i="default",padding:a="none"}=n;return h.jsx("section",{className:ee("full-width-section",t,{[i]:i!=="default",[a]:a!=="none"}),...r,children:e})};const tF=({text:e,buttons:t,className:n=""})=>{const r=[];return t.forEach(i=>{r.push({href:i.link,variant:"secondary",size:{mobile:"medium",1024:"large"},className:"gtm-trackable new","data-gtm-event-type":"download-click","data-gtm-event-context":i.eventContext||"Download",target:"_blank",children:i.text})}),h.jsx(ea,{className:ee("download-section",n),styling:{background:"dark"},children:h.jsxs("div",{className:"content-default",children:[y.createElement(typeof e=="string"?"h2":e.element,{className:"text"},typeof e=="string"?e:e.text),h.jsx(zs,{buttons:r})]})})};const Rh="editSection_";function VT({href:e,setShowModal:t}){typeof e!="string"&&t(!0)}const nF=({icon:e,description:t,ctaMessage:n,href:r,showEditButton:i,setShowModal:a})=>{const{formatMessage:s}=he.useIntl();return h.jsxs(Ln,{variant:"muted",icon:e,children:[h.jsx("p",{children:t||s({id:`${Rh}placeholder_description`})}),i&&h.jsx("p",{children:h.jsx(Me,{href:r,variant:"secondary",size:"small",onClick:()=>VT({href:r,setShowModal:a}),children:n||s({id:`${Rh}placeholder_cta`})})})]})},rF=({children:e,className:t="",formProps:n,formComponent:r,href:i,title:a,showTitle:s=!0,modalTitle:o,placeholder:l,showDivider:u=!0})=>{const{formatMessage:c}=he.useIntl(),[d,f]=y.useState(!1),p=()=>f(!1),g=!!n||!!r,m=typeof i=="string"||g;let E;return r&&(E=y.cloneElement(r,{functions:{...r.props.functions,onSuccess:async v=>{try{r.props.functions.onSuccess&&await r.props.functions.onSuccess(v)}finally{p()}},onCancel:()=>{r.props.functions.onCancel&&r.props.functions.onCancel(),p()}}})),h.jsxs("section",{className:ee("edit-section",t),children:[g&&h.jsx(Ti,{title:o||`Edit ${a}`,isOpen:d,showDivider:!1,showIcon:!1,functions:{onClose:p},className:ee("edit-section-modal"),children:E||(n?h.jsx(Cr,{...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 v=>{var b,T;(b=n==null?void 0:n.functions)!=null&&b.onSuccess&&await((T=n==null?void 0:n.functions)==null?void 0:T.onSuccess(v)),f(!1)},onCancel:p}}):h.jsx(h.Fragment,{}))}),h.jsxs("div",{className:ee("edit-section-header",{"no-title":!s}),children:[s&&h.jsx("h2",{className:"edit-section-header-title",children:a}),m&&h.jsx(Me,{href:i,variant:"tertiary",size:"small",icon:"pencil",onClick:()=>VT({href:i,setShowModal:f}),children:c({id:`${Rh}edit`})})]}),e||h.jsx(nF,{...l,href:i,setShowModal:f,showEditButton:m}),u&&h.jsx(Tr,{})]})};const iF=({title:e=!1,text:t,logos:n=[],styling:r={},className:i=""})=>{const a=n.length;if(a===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 h.jsxs("div",{className:ee("logos",i,`align-${l}`,{[u]:u!=="block","wrap-logos":o}),children:[e&&y.createElement(s.element,{className:ee("title",s.className)},s.text),t&&h.jsx("p",{children:t}),h.jsx("ul",{className:ee({"two-col":a===2||a===4,"three-col":a===5||a<=10&&a%3===0}),children:n.map(({logo:c,nameOfBusiness:d,link:f=!1,description:p=!1},g)=>{if(!c||!c.url)return null;const m=h.jsx("img",{src:c.url,width:c.width||"auto",height:c.height||"auto",alt:d});return h.jsxs("li",{children:[h.jsx("p",{className:"img-wrapper",children:f?h.jsx("a",{href:f,target:"_blank",rel:"nofollow noreferrer noopener",children:m}):m}),p&&h.jsx("small",{children:p})]},window.btoa(`${c.url}_${g}`))})})]})};let Rd;const Fd="contactFooter_",aF=({onSuccess:e=async()=>{},onFailure:t=()=>{}})=>{const n=y.useRef(null),[r,i]=y.useState(0),[a,s]=y.useState(!1),o=()=>{n.current&&i(n.current.clientHeight)},l=()=>{a||(s(!0),clearTimeout(Rd),Rd=setTimeout(()=>{o(),s(!1)},500))};return y.useEffect(()=>(o(),window.addEventListener("resize",l),()=>{clearTimeout(Rd),window.removeEventListener("resize",l)}),[]),h.jsx(ea,{id:"contactForm",className:"contact-footer",children:h.jsxs("div",{className:"inner-wrapper",children:[h.jsx("h2",{children:h.jsx(he.FormattedMessage,{id:`${Fd}title`})}),h.jsxs("div",{className:"content-wrapper",ref:n,"data-testid":"content-wrapper",style:a?{}:{minHeight:r},children:[h.jsxs("aside",{children:[h.jsx("p",{children:h.jsx(he.FormattedMessage,{id:`${Fd}text`})}),h.jsx(Qi,{className:"mailto-link",href:"mailto:hello@apolitical.co",children:h.jsx(he.FormattedMessage,{id:`${Fd}email`})})]}),h.jsx(IT,{functions:{onSuccess:e,onFailure:t},gtm:{context:"FooterContactUsForm",event:"contact-form-submit-click"}})]})]})})},sF=({activeLink:e,profile:t,...n})=>h.jsx(ea,{children:h.jsx(WT,{layout:"1-3",children:h.jsxs(h.Fragment,{children:[h.jsx(qT,{activeLink:e,profile:t}),h.jsx(x4,{...n})]})})});const Bd="cookieBanner_",Md=["apol-cookie-banner","apolitical-performance-cookie-consent","functional-cookie-consent"],Ld=new Date(Date.now()+12*30*24*60*60*1e3),KT=()=>{const e=he.useIntl(),[t,n,r]=up.useCookies(Md),[i,a]=y.useState(!t["apol-cookie-banner"]),s=()=>{Md.forEach(c=>{n(c,!0,{path:"/",expires:Ld,domain:c==="apolitical-performance-cookie-consent"?".apolitical.co":void 0})}),a(!1),window.location.reload()},o=()=>{n("apol-cookie-banner",!0,{path:"/",expires:Ld}),Md.forEach(c=>{if(c==="apol-cookie-banner"){n(c,!0,{path:"/",expires:Ld});return}r(c)}),a(!1)};if(!i)return null;const l=[{id:"settings",href:"/pages/cookie-policy",gtmType:"policy-page"},{id:"reject",onClick:o,gtmType:"reject-all"},{id:"accept",onClick:s,gtmType:"accepted-all"}],u=[];return l.forEach(c=>{u.push({variant:c.href?"tertiary":"primary",href:c.href,onClick:c.onClick,className:"gtm-trackable","data-gtm-event-context":"cookie-banner","data-gtm-event-type":`cookie-${c.gtmType}-click`,children:e.formatMessage({id:`${Bd}buttons_${c.id}`})})}),h.jsxs("aside",{id:"cookie-banner",className:"text-medium",children:[h.jsx("h6",{children:e.formatMessage({id:`${Bd}title`})}),h.jsx("p",{children:e.formatMessage({id:`${Bd}text`})}),h.jsx(zs,{buttons:u})]})},fi={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:us["data-protection"].default,gtmType:"email-dpo-link"},euDataProtection:{email:us["data-protection"].eu,gtmType:"email-eu-dpo-link"}}},contact:{text:{order:["london","washington","berlin","registered","support","business"],london:{address:!0},washington:{address:!0},registered:{address:!0},berlin:{address:!0},support:{email:us.support,gtmType:"concierge-email-click"},business:{email:us.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 ms="footer_",Fc="SiteFooter",v9=({group:e})=>{const t=fi[e].order||[];let n=!1;return"text"in fi[e]&&(n=fi[e].text),h.jsxs(y.Fragment,{children:[h.jsx("p",{className:"pre-title",children:h.jsx(he.FormattedMessage,{id:`${ms}${e}`})}),Array.isArray(t)&&t.length>0&&h.jsx("ul",{className:"text-medium",children:t.map(r=>{if(["order","child","text"].includes(r))return null;const{href:i,gtmType:a}=fi[e][r],s={};return["legal"].includes(e)&&(s.target="_blank",s.rel="noopener"),h.jsx("li",{children:h.jsx("a",{href:i,className:"gtm-trackable","data-gtm-event-context":Fc,"data-gtm-event-type":a,...s,children:h.jsx(he.FormattedMessage,{id:`${ms}${e}_${r}`})})},`${e}_${r}`)})}),typeof n!="boolean"&&"order"in n&&Array.isArray(n.order)&&h.jsx("dl",{className:"text-medium",children:n.order.map(r=>h.jsxs(y.Fragment,{children:[h.jsx("dt",{children:h.jsx(he.FormattedMessage,{id:`${ms}${e}_${r}`})}),h.jsxs("dd",{children:[typeof n!="boolean"&&n[r].address&&h.jsx("address",{children:h.jsx(he.FormattedMessage,{id:`${ms}${e}_${r}_address`,values:{br:h.jsx("br",{})}})}),typeof n!="boolean"&&n[r].email&&h.jsx("a",{href:`mailto:${n[r].email}`,className:"gtm-trackable","data-gtm-event-context":Fc,"data-gtm-event-type":n[r].gtmType,children:n[r].email})]})]},`dl-${e}-${r}`))})]},e)},fm=()=>h.jsx("div",{id:"footer",children:h.jsxs("div",{className:"wrapper",children:[h.jsx(Yc,{element:"hr"}),h.jsx(dm,{variant:"inverted",version:"full",className:"gtm-trackable","data-gtm-event-context":Fc,"data-gtm-event-type":"logo-homepage-link"}),h.jsx("footer",{children:["platform","community","company","contact"].map(e=>h.jsxs("div",{className:"group",children:[h.jsx(v9,{group:e}),Object.keys(fi[e]).includes("child")&&h.jsx(v9,{group:fi[e].child})]},e))}),h.jsx("hr",{}),h.jsxs("div",{className:"sub-footer",children:[h.jsx("ul",{children:Array.isArray(fi.social.order)&&fi.social.order.map(e=>{const t=fi.social[e];return h.jsx("li",{className:e,children:h.jsx("a",{href:t.href,target:"_blank",rel:"noopener noreferrer",className:"gtm-trackable","data-gtm-event-context":Fc,"data-gtm-event-type":"social-click",children:h.jsx("span",{className:"hidden",children:h.jsx(he.FormattedMessage,{id:`${ms}social_${e}`})})})},e)})}),h.jsx("small",{children:h.jsx(he.FormattedMessage,{id:`${ms}copyright`,values:{currentYear:new Date().getFullYear()}})})]})]})}),Kr=Object.create(null);Kr.open="0";Kr.close="1";Kr.ping="2";Kr.pong="3";Kr.message="4";Kr.upgrade="5";Kr.noop="6";const nc=Object.create(null);Object.keys(Kr).forEach(e=>{nc[Kr[e]]=e});const Fh={type:"error",data:"parser error"},GT=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",YT=typeof ArrayBuffer=="function",ZT=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,hm=({type:e,data:t},n,r)=>GT&&t instanceof Blob?n?r(t):E9(t,r):YT&&(t instanceof ArrayBuffer||ZT(t))?n?r(t):E9(new Blob([t]),r):r(Kr[e]+(t||"")),E9=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function y9(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let $d;function oF(e,t){if(GT&&e.data instanceof Blob)return e.data.arrayBuffer().then(y9).then(t);if(YT&&(e.data instanceof ArrayBuffer||ZT(e.data)))return t(y9(e.data));hm(e,!1,n=>{$d||($d=new TextEncoder),t($d.encode(n))})}const b9="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Po=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<b9.length;e++)Po[b9.charCodeAt(e)]=e;const lF=e=>{let t=e.length*.75,n=e.length,r,i=0,a,s,o,l;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const u=new ArrayBuffer(t),c=new Uint8Array(u);for(r=0;r<n;r+=4)a=Po[e.charCodeAt(r)],s=Po[e.charCodeAt(r+1)],o=Po[e.charCodeAt(r+2)],l=Po[e.charCodeAt(r+3)],c[i++]=a<<2|s>>4,c[i++]=(s&15)<<4|o>>2,c[i++]=(o&3)<<6|l&63;return u},uF=typeof ArrayBuffer=="function",pm=(e,t)=>{if(typeof e!="string")return{type:"message",data:QT(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:cF(e.substring(1),t)}:nc[n]?e.length>1?{type:nc[n],data:e.substring(1)}:{type:nc[n]}:Fh},cF=(e,t)=>{if(uF){const n=lF(e);return QT(n,t)}else return{base64:!0,data:e}},QT=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},XT=String.fromCharCode(30),dF=(e,t)=>{const n=e.length,r=new Array(n);let i=0;e.forEach((a,s)=>{hm(a,!1,o=>{r[s]=o,++i===n&&t(r.join(XT))})})},fF=(e,t)=>{const n=e.split(XT),r=[];for(let i=0;i<n.length;i++){const a=pm(n[i],t);if(r.push(a),a.type==="error")break}return r};function hF(){return new TransformStream({transform(e,t){oF(e,n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const a=new DataView(i.buffer);a.setUint8(0,126),a.setUint16(1,r)}else{i=new Uint8Array(9);const a=new DataView(i.buffer);a.setUint8(0,127),a.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}let jd;function su(e){return e.reduce((t,n)=>t+n.length,0)}function ou(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function pF(e,t){jd||(jd=new TextDecoder);const n=[];let r=0,i=-1,a=!1;return new TransformStream({transform(s,o){for(n.push(s);;){if(r===0){if(su(n)<1)break;const l=ou(n,1);a=(l[0]&128)===128,i=l[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(su(n)<2)break;const l=ou(n,2);i=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(su(n)<8)break;const l=ou(n,8),u=new DataView(l.buffer,l.byteOffset,l.length),c=u.getUint32(0);if(c>Math.pow(2,53-32)-1){o.enqueue(Fh);break}i=c*Math.pow(2,32)+u.getUint32(4),r=3}else{if(su(n)<i)break;const l=ou(n,i);o.enqueue(pm(a?l:jd.decode(l),t)),r=0}if(i===0||i>e){o.enqueue(Fh);break}}}})}const JT=4;function Vt(e){if(e)return mF(e)}function mF(e){for(var t in Vt.prototype)e[t]=Vt.prototype[t];return e}Vt.prototype.on=Vt.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};Vt.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};Vt.prototype.off=Vt.prototype.removeListener=Vt.prototype.removeAllListeners=Vt.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+e],this};Vt.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this};Vt.prototype.emitReserved=Vt.prototype.emit;Vt.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};Vt.prototype.hasListeners=function(e){return!!this.listeners(e).length};const u1=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0))(),er=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())(),gF="arraybuffer";function e8(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const vF=er.setTimeout,EF=er.clearTimeout;function c1(e,t){t.useNativeTimers?(e.setTimeoutFn=vF.bind(er),e.clearTimeoutFn=EF.bind(er)):(e.setTimeoutFn=er.setTimeout.bind(er),e.clearTimeoutFn=er.clearTimeout.bind(er))}const yF=1.33;function bF(e){return typeof e=="string"?TF(e):Math.ceil((e.byteLength||e.size)*yF)}function TF(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function t8(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function _F(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function CF(e){let t={},n=e.split("&");for(let r=0,i=n.length;r<i;r++){let a=n[r].split("=");t[decodeURIComponent(a[0])]=decodeURIComponent(a[1])}return t}class xF extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class mm extends Vt{constructor(t){super(),this.writable=!1,c1(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new xF(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=pm(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=_F(t);return n.length?"?"+n:""}}class wF extends mm{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};fF(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,dF(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=t8()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let n8=!1;try{n8=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const AF=n8;function SF(){}class kF extends wF{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){const r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(i,a)=>{this.onError("xhr post error",i,a)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}}class jr extends Vt{constructor(t,n,r){super(),this.createRequest=t,c1(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const n=e8(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=jr.requestsCount++,jr.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=SF,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete jr.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}jr.requestsCount=0;jr.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",T9);else if(typeof addEventListener=="function"){const e="onpagehide"in er?"pagehide":"unload";addEventListener(e,T9,!1)}}function T9(){for(let e in jr.requests)jr.requests.hasOwnProperty(e)&&jr.requests[e].abort()}const DF=function(){const e=r8({xdomain:!1});return e&&e.responseType!==null}();class OF extends kF{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=DF&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new jr(r8,this.uri(),t)}}function r8(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||AF))return new XMLHttpRequest}catch{}if(!t)try{return new er[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const i8=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class NF extends mm{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=i8?{}:e8(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],i=n===t.length-1;hm(r,this.supportsBinary,a=>{try{this.doWrite(r,a)}catch{}i&&u1(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=t8()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const Hd=er.WebSocket||er.MozWebSocket;class IF extends NF{createSocket(t,n,r){return i8?new Hd(t,n,r):n?new Hd(t,n):new Hd(t)}doWrite(t,n){this.ws.send(n)}}class PF extends mm{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=pF(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),i=hF();i.readable.pipeTo(t.writable),this._writer=i.writable.getWriter();const a=()=>{r.read().then(({done:o,value:l})=>{o||(this.onPacket(l),a())}).catch(o=>{})};a();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],i=n===t.length-1;this._writer.write(r).then(()=>{i&&u1(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const RF={websocket:IF,webtransport:PF,polling:OF},FF=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,BF=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Bh(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let i=FF.exec(e||""),a={},s=14;for(;s--;)a[BF[s]]=i[s]||"";return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=MF(a,a.path),a.queryKey=LF(a,a.query),a}function MF(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function LF(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,a){i&&(n[i]=a)}),n}const Mh=typeof addEventListener=="function"&&typeof removeEventListener=="function",rc=[];Mh&&addEventListener("offline",()=>{rc.forEach(e=>e())},!1);class Vi extends Vt{constructor(t,n){if(super(),this.binaryType=gF,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const r=Bh(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=Bh(n.host).host);c1(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const i=r.prototype.name;this.transports.push(i),this._transportsByName[i]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=CF(this.opts.query)),Mh&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},rc.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=JT,n.transport=t,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&Vi.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Vi.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(n+=bF(i)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,u1(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,i){if(typeof n=="function"&&(i=n,n=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const a={type:t,data:n,options:r};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),i&&this.once("flush",i),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(Vi.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Mh&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=rc.indexOf(this._offlineEventListener);r!==-1&&rc.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}Vi.protocol=JT;class $F extends Vi{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;Vi.priorWebsocketSuccess=!1;const i=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",d=>{if(!r)if(d.type==="pong"&&d.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Vi.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(c(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const f=new Error("probe error");f.transport=n.name,this.emitReserved("upgradeError",f)}}))};function a(){r||(r=!0,c(),n.close(),n=null)}const s=d=>{const f=new Error("probe error: "+d);f.transport=n.name,a(),this.emitReserved("upgradeError",f)};function o(){s("transport closed")}function l(){s("socket closed")}function u(d){n&&d.name!==n.name&&a()}const c=()=>{n.removeListener("open",i),n.removeListener("error",s),n.removeListener("close",o),this.off("close",l),this.off("upgrading",u)};n.once("open",i),n.once("error",s),n.once("close",o),this.once("close",l),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}}let jF=class extends $F{constructor(t,n={}){const r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(i=>RF[i]).filter(i=>!!i)),super(t,r)}};function HF(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=Bh(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const a=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+a+":"+r.port+t,r.href=r.protocol+"://"+a+(n&&n.port===r.port?"":":"+r.port),r}const UF=typeof ArrayBuffer=="function",zF=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,a8=Object.prototype.toString,qF=typeof Blob=="function"||typeof Blob<"u"&&a8.call(Blob)==="[object BlobConstructor]",WF=typeof File=="function"||typeof File<"u"&&a8.call(File)==="[object FileConstructor]";function gm(e){return UF&&(e instanceof ArrayBuffer||zF(e))||qF&&e instanceof Blob||WF&&e instanceof File}function ic(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(ic(e[n]))return!0;return!1}if(gm(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return ic(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&ic(e[n]))return!0;return!1}function VF(e){const t=[],n=e.data,r=e;return r.data=Lh(n,t),r.attachments=t.length,{packet:r,buffers:t}}function Lh(e,t){if(!e)return e;if(gm(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=Lh(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=Lh(e[r],t));return n}return e}function KF(e,t){return e.data=$h(e.data,t),delete e.attachments,e}function $h(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=$h(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=$h(e[n],t));return e}const GF=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],YF=5;var st;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(st||(st={}));class ZF{constructor(t){this.replacer=t}encode(t){return(t.type===st.EVENT||t.type===st.ACK)&&ic(t)?this.encodeAsBinary({type:t.type===st.EVENT?st.BINARY_EVENT:st.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===st.BINARY_EVENT||t.type===st.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=VF(t),r=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(r),i}}function _9(e){return Object.prototype.toString.call(e)==="[object Object]"}class vm extends Vt{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const r=n.type===st.BINARY_EVENT;r||n.type===st.BINARY_ACK?(n.type=r?st.EVENT:st.ACK,this.reconstructor=new QF(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(gm(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const r={type:Number(t.charAt(0))};if(st[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===st.BINARY_EVENT||r.type===st.BINARY_ACK){const a=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const s=t.substring(a,n);if(s!=Number(s)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(s)}if(t.charAt(n+1)==="/"){const a=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(a,n)}else r.nsp="/";const i=t.charAt(n+1);if(i!==""&&Number(i)==i){const a=n+1;for(;++n;){const s=t.charAt(n);if(s==null||Number(s)!=s){--n;break}if(n===t.length)break}r.id=Number(t.substring(a,n+1))}if(t.charAt(++n)){const a=this.tryParse(t.substr(n));if(vm.isPayloadValid(r.type,a))r.data=a;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case st.CONNECT:return _9(n);case st.DISCONNECT:return n===void 0;case st.CONNECT_ERROR:return typeof n=="string"||_9(n);case st.EVENT:case st.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&GF.indexOf(n[0])===-1);case st.ACK:case st.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class QF{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=KF(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const XF=Object.freeze(Object.defineProperty({__proto__:null,Decoder:vm,Encoder:ZF,get PacketType(){return st},protocol:YF},Symbol.toStringTag,{value:"Module"}));function Er(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const JF=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class s8 extends Vt{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Er(t,"open",this.onopen.bind(this)),Er(t,"packet",this.onpacket.bind(this)),Er(t,"error",this.onerror.bind(this)),Er(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,i,a;if(JF.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const s={type:st.EVENT,data:n};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const c=this.ids++,d=n.pop();this._registerAckCallback(c,d),s.id=c}const o=(i=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||i===void 0?void 0:i.writable,l=this.connected&&!(!((a=this.io.engine)===null||a===void 0)&&a._hasPingExpired());return this.flags.volatile&&!o||(l?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(t,n){var r;const i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[t]=n;return}const a=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===t&&this.sendBuffer.splice(o,1);n.call(this,new Error("operation has timed out"))},i),s=(...o)=>{this.io.clearTimeoutFn(a),n.apply(this,o)};s.withError=!0,this.acks[t]=s}emitWithAck(t,...n){return new Promise((r,i)=>{const a=(s,o)=>s?i(s):r(o);a.withError=!0,n.push(a),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((i,...a)=>r!==this._queue[0]?void 0:(i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...a)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:st.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case st.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case st.EVENT:case st.BINARY_EVENT:this.onevent(t);break;case st.ACK:case st.BINARY_ACK:this.onack(t);break;case st.DISCONNECT:this.ondisconnect();break;case st.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let r=!1;return function(...i){r||(r=!0,n.packet({type:st.ACK,id:t,data:i}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:st.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,t.data)}}}function Gs(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Gs.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0};Gs.prototype.reset=function(){this.attempts=0};Gs.prototype.setMin=function(e){this.ms=e};Gs.prototype.setMax=function(e){this.max=e};Gs.prototype.setJitter=function(e){this.jitter=e};class jh extends Vt{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,c1(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Gs({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const i=n.parser||XF;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new jF(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=Er(n,"open",function(){r.onopen(),t&&t()}),a=o=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",o),t?t(o):this.maybeReconnectOnOpen()},s=Er(n,"error",a);if(this._timeout!==!1){const o=this._timeout,l=this.setTimeoutFn(()=>{i(),a(new Error("timeout")),n.close()},o);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(i),this.subs.push(s),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Er(t,"ping",this.onping.bind(this)),Er(t,"data",this.ondata.bind(this)),Er(t,"error",this.onerror.bind(this)),Er(t,"close",this.onclose.bind(this)),Er(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){u1(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new s8(this,t,n),this.nsps[t]=r),r}_destroy(t){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(i=>{i?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",i)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const fo={};function ac(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=HF(e,t.path||"/socket.io"),r=n.source,i=n.id,a=n.path,s=fo[i]&&a in fo[i].nsps,o=t.forceNew||t["force new connection"]||t.multiplex===!1||s;let l;return o?l=new jh(r,t):(fo[i]||(fo[i]=new jh(r,t)),l=fo[i]),n.query&&!t.query&&(t.query=n.queryKey),l.socket(n.path,t)}Object.assign(ac,{Manager:jh,Socket:s8,io:ac,connect:ac});const C9=e=>{let t;const n=new Set,r=(c,d)=>{const f=typeof c=="function"?c(t):c;if(!Object.is(f,t)){const p=t;t=d??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,p))}},i=()=>t,l={setState:r,getState:i,getInitialState:()=>u,subscribe:c=>(n.add(c),()=>n.delete(c)),destroy:()=>{n.clear()}},u=t=e(r,i,l);return l},o8=e=>e?C9(e):C9;function eB(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(i){i(n)}),(r=e.get("*"))&&r.slice().map(function(i){i(t,n)})}}}function Mn(){return Mn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Mn.apply(this,arguments)}class tB extends Error{constructor(t){super(t),this.name=void 0,this.name="SuprSendError"}}function _a(){return Math.round(Date.now())}function oa(){var e=new Date().getTime(),t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var r=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(n=="x"?r:r&3|8).toString(16)});return t}const pn=o8()(()=>({apiUrl:"https://inboxs.live",collectorApiUrl:"https://hub.suprsend.com",socketUrl:"https://betainbox.suprsend.com",pageSize:20})),nB={unseenCount:0,stores:{},activeStoreId:null,pageNumber:1,hasNext:!0,initialLoading:!1,fetchMoreLoading:!1,initialFetchTime:null},at=o8()(()=>nB);class rB{constructor(t){this.socket=void 0,this.config=void 0,this.config=t;const n=pn.getState();this.socket=ac(n.socketUrl,{transports:["websocket"],auth:{subscriber_id:this.config.subscriberId,distinct_id:this.config.distinctId,authorization:`${this.config.workspaceKey}:${oa()}`,tenant_id:this.config.tenantId},reconnectionAttempts:25,reconnectionDelay:5e3,reconnectionDelayMax:1e4}),this._initializeSocketEvents()}orderNotifications(t,n){if(t.is_pinned)return[t,...n];{let r=!1,i=[];return n.forEach(a=>{a.is_pinned||r?i.push(a):(i.push(t),i.push(a),r=!0)}),r?i:[...n,t]}}_initializeSocketEvents(){var t=this;this.socket.on("new_notification",async function(n){n.n_id&&setTimeout(async function(){try{const i=await(await t.getNotificationDetails(n.n_id)).json(),a=at.getState();if(t.config.stores){let s=!1;for(let o of t.config.stores){const l=a.stores[o.storeId];t._notificationBelongToStore(i.data,o)&&(s=!0,l.notifications=t.orderNotifications(i.data,l.notifications),l.unseenCount+=1)}s&&(a.unseenCount+=1,t.config.emitter.emit("new_notification",i.data)),at.setState({unseenCount:a.unseenCount,stores:Mn({},a.stores)})}else{if(!a.activeStoreId)return;let s=a.stores[a.activeStoreId];a.unseenCount+=1,s.unseenCount+=1,s.notifications=t.orderNotifications(i.data,s.notifications),at.setState({unseenCount:a.unseenCount,stores:Mn({},a.stores)}),t.config.emitter.emit("new_notification",i.data)}t.config.emitter.emit("sync_notif_store")}catch(r){console.log("SuprSend: error in new_notification event",r)}},1e3)}),this.socket.on("notification_updated",async function(n){n.n_id&&setTimeout(async function(){try{const a=await Promise.allSettled([t.getNotificationDetails(n.n_id),t.getNotificationsCount()]),s=at.getState();let o=s.activeStoreId;if(a[0].status==="fulfilled"){var r;const u=await a[0].value.json(),c=u.data;if(!o)return;let d=s.stores[o];const f=(r=t.config.stores)==null?void 0:r.find(p=>p.storeId===o);if((n==null?void 0:n.type)==="archive"){var i;f!=null&&(i=f.query)!=null&&i.archived?t._notificationBelongToStore(c,f)&&(s.stores[o].notifications=[c,...d.notifications]):s.stores[o].notifications=d.notifications.filter(p=>p.n_id!==n.n_id)}else s.stores[o].notifications=d.notifications.map(p=>p.n_id===n.n_id?u.data:p);at.setState({stores:Mn({},s.stores)})}if(a[1].status==="fulfilled"){const u=await a[1].value.json();at.setState(c=>{for(let d in c.stores){const f=c.stores[d];f.unseenCount=u[d]||0}return{unseenCount:u.ss_bell_count,stores:Mn({},c.stores)}})}t.config.emitter.emit("sync_notif_store")}catch(a){console.log("SuprSend: error in notification_updated event",a)}},1e3)}),this.socket.on("update_badge",async function(){at.setState({unseenCount:0}),t.config.emitter.emit("sync_notif_store")}),this.socket.on("mark_all_read",async function(){const n=at.getState(),r=_a();for(let i in n.stores){const a=n.stores[i];a.notifications.forEach(s=>{s.seen_on||(s.seen_on=r)}),a.unseenCount=0}at.setState({stores:n.stores}),t.config.emitter.emit("sync_notif_store")})}_notificationBelongToStore(t,n){var r,i,a,s;const o=!!t.seen_on,l=t.archived,u=t.tags,c=t.n_category,d=n==null||(r=n.query)==null?void 0:r.read,f=n==null||(i=n.query)==null?void 0:i.archived,p=n==null||(a=n.query)==null?void 0:a.tags,g=n==null||(s=n.query)==null?void 0:s.categories,m=!d||o===d,E=!f||l===f;let v,b;return Array.isArray(p)&&p.length>0?p.forEach(T=>{u!=null&&u.includes(T)&&(v=!0)}):v=!0,Array.isArray(g)&&g.length>0?g.includes(c)&&(b=!0):b=!0,m&&v&&b&&E}_getStoreQueryString(t){const n=t==null?void 0:t.query;let r=(n==null?void 0:n.tags)||[],i=(n==null?void 0:n.categories)||[];const a=n==null?void 0:n.read,s=n==null?void 0:n.archived;return{store_id:t.storeId,query:{read:a,archived:s,tags:{or:r},categories:{or:i}}}}_getStoresQueryString(){const t=this.config.stores;return t==null?void 0:t.map(r=>this._getStoreQueryString(r))}getNotificationsCount(){const{apiUrl:t}=pn.getState();let n=`/notification_count/?subscriber_id=${this.config.subscriberId}&distinct_id=${this.config.distinctId}&tenant_id=${this.config.tenantId}`;if(this.config.stores){const r=this._getStoresQueryString();n+=`&stores=${encodeURIComponent(JSON.stringify(r))}`}return fetch(`${t}${n}`,{method:"GET",headers:{Authorization:`${this.config.workspaceKey}:${oa()}`}})}getNotifications(t,n,r=20,i){const{apiUrl:a}=pn.getState();let s=`/notifications/?subscriber_id=${this.config.subscriberId}&distinct_id=${this.config.distinctId}&tenant_id=${this.config.tenantId}&page_no=${n}&page_size=${r}&before=${i}`;if(t){const o=this._getStoreQueryString(t);s+=`&store=${encodeURIComponent(JSON.stringify(o))}`}return fetch(`${a}${s}`,{method:"GET",headers:{Authorization:`${this.config.workspaceKey}:${oa()}`}})}getNotificationDetails(t){const{apiUrl:n}=pn.getState(),r=`/notification/${t}/?subscriber_id=${this.config.subscriberId}&distinct_id=${this.config.distinctId}&tenant_id=${this.config.tenantId}`;return fetch(`${n}${r}`,{method:"GET",headers:{Authorization:`${this.config.workspaceKey}:${oa()}`}})}markBellClicked(){const{apiUrl:t}=pn.getState(),n="/bell-clicked/",r=JSON.stringify({time:_a(),distinct_id:this.config.distinctId,subscriber_id:this.config.subscriberId,tenant_id:this.config.tenantId});return fetch(`${t}${n}`,{method:"POST",body:r,headers:{Authorization:`${this.config.workspaceKey}:${oa()}`,"Content-Type":"application/json"}})}markAllRead(){const{apiUrl:t}=pn.getState(),n="/mark-all-read/",r=JSON.stringify({time:_a(),distinct_id:this.config.distinctId,subscriber_id:this.config.subscriberId,tenant_id:this.config.tenantId});return fetch(`${t}${n}`,{method:"POST",body:r,headers:{Authorization:`${this.config.workspaceKey}:${oa()}`,"Content-Type":"application/json"}})}markNotificationClicked(t){const{collectorApiUrl:n}=pn.getState(),r={event:"$notification_clicked",env:this.config.workspaceKey,$insert_id:oa(),$time:_a(),properties:{id:t}};return fetch(`${n}/event/`,{method:"POST",body:JSON.stringify(r),headers:{Authorization:`${this.config.workspaceKey}:`,"Content-Type":"application/json"}})}markNotificationRead(t){const{apiUrl:n}=pn.getState();return fetch(`${n}/notification/${t}/action`,{method:"POST",body:JSON.stringify({action:"read",distinct_id:this.config.distinctId,subscriber_id:this.config.subscriberId}),headers:{Authorization:`${this.config.workspaceKey}:`,"Content-Type":"application/json"}})}markNotificationUnRead(t){const{apiUrl:n}=pn.getState();return fetch(`${n}/notification/${t}/action`,{method:"POST",body:JSON.stringify({action:"unread",distinct_id:this.config.distinctId,subscriber_id:this.config.subscriberId}),headers:{Authorization:`${this.config.workspaceKey}:`,"Content-Type":"application/json"}})}markNotificationArchive(t){const{apiUrl:n}=pn.getState();return fetch(`${n}/notification/${t}/action`,{method:"POST",body:JSON.stringify({action:"archive",distinct_id:this.config.distinctId,subscriber_id:this.config.subscriberId}),headers:{Authorization:`${this.config.workspaceKey}:`,"Content-Type":"application/json"}})}}let x9=class{constructor(t){this.config=void 0,this.config=t}_overallFirstApiCall(){const t=at.getState();for(let n in t.stores)if(t.stores[n].isFirstCall===!1)return!1;return!0}async fetchNotifications(){var t,n;const r=this.config.client,i=at.getState(),a=pn.getState(),s=i.activeStoreId;if(!s||!((t=i.stores)!=null&&t[s]))return;const o=i.stores[s],l=o.isFirstCall,u=i.initialFetchTime||Date.now(),c=(n=this.config.stores)==null?void 0:n.find(d=>d.storeId===s);try{if(!r||!i.hasNext)return;l?(at.setState({initialLoading:!0}),this._overallFirstApiCall()&&this.getNotificationsCount()):i.pageNumber>1&&at.setState({fetchMoreLoading:!0}),this.config.emitter.emit("sync_notif_store");const f=await(await r.getNotifications(c,i.pageNumber,a.pageSize,u)).json();let p;l||!l&&i.pageNumber===1?p=f.results:p=[...o.notifications,...f.results],i.stores[s].notifications=p,i.stores[s].isFirstCall=!1,at.setState({stores:i.stores,pageNumber:i.pageNumber+1,hasNext:f.meta.current_page<f.meta.total_pages,initialFetchTime:u,initialLoading:!1,fetchMoreLoading:!1}),this.config.emitter.emit("sync_notif_store"),this.config._startExipryCheck()}catch(d){console.log("SUPRSEND: error getting latest notifications",d),at.setState({initialLoading:!1,fetchMoreLoading:!1}),this.config.emitter.emit("sync_notif_store")}}async getNotificationsCount(){const t=this.config.client;if(t)try{const r=await(await t.getNotificationsCount()).json();at.setState(i=>{for(let a in i.stores){const s=i.stores[a];s.unseenCount=r[a]||0}return{unseenCount:r.ss_bell_count,stores:Mn({},i.stores)}}),this.config.emitter.emit("sync_notif_store")}catch(n){console.log("SUPRSEND: error getting notifications count",n)}}async markClicked(t){var n;const r=this.config.client,i=at.getState(),a=i.activeStoreId;if(!a||!((n=i.stores)!=null&&n[a]))return;const l=i.stores[a].notifications.find(c=>c.n_id===t);if(l&&(!l.interacted_on||!l.seen_on)){if(!r)return;try{l.interacted_on?l.seen_on||r.markNotificationRead(t):r.markNotificationClicked(t);const c=_a();if(l.interacted_on=c,!l.seen_on)for(let d in i==null?void 0:i.stores){var u;const f=i.stores[d];(u=f.notifications)==null||u.forEach(p=>{p.n_id===l.n_id&&(p.seen_on=c,p.interacted_on=c,f.unseenCount>0&&(f.unseenCount-=1))})}at.setState(Mn({},i)),this.config.emitter.emit("sync_notif_store")}catch(c){console.log("SUPRSEND: error marking notification clicked",c)}}}async markAllSeen(){const t=this.config.client;try{if(!t)return;t.markBellClicked(),at.setState({unseenCount:0}),this.config.emitter.emit("sync_notif_store")}catch(n){console.log("SUPRSEND: error marking all notifications seen",n)}}async markAllRead(){const t=this.config.client;try{if(!t)return;t.markAllRead();const n=at.getState(),r=_a();for(let i in n.stores){const a=n.stores[i];a.notifications.forEach(s=>{s.seen_on||(s.seen_on=r)}),a.unseenCount=0}at.setState({stores:n.stores}),this.config.emitter.emit("sync_notif_store")}catch(n){console.log("SUPRSEND: error marking all notifications read",n)}}async markRead(t){var n;const r=this.config.client,i=at.getState(),a=i.activeStoreId;if(!a||!((n=i.stores)!=null&&n[a]))return;const l=i.stores[a].notifications.find(c=>c.n_id===t);if(l&&!l.seen_on){if(!r)return;try{r.markNotificationRead(t);const c=_a();if(!l.seen_on)for(let d in i==null?void 0:i.stores){var u;const f=i.stores[d];(u=f.notifications)==null||u.forEach(p=>{p.n_id===l.n_id&&(p.seen_on=c,f.unseenCount>0&&(f.unseenCount-=1))})}at.setState(Mn({},i)),this.config.emitter.emit("sync_notif_store")}catch(c){console.log("SUPRSEND: error marking notification read",c)}}}async markUnRead(t){var n;const r=this.config.client,i=at.getState(),a=i.activeStoreId;if(!a||!((n=i.stores)!=null&&n[a]))return;const l=i.stores[a].notifications.find(c=>c.n_id===t);if(l&&l.seen_on){if(!r)return;try{if(r.markNotificationUnRead(t),l.seen_on)for(let c in i==null?void 0:i.stores){var u;const d=i.stores[c];(u=d.notifications)==null||u.forEach(f=>{f.n_id===l.n_id&&(f.seen_on=void 0,d.unseenCount>=0&&(d.unseenCount+=1))})}at.setState(Mn({},i)),this.config.emitter.emit("sync_notif_store")}catch(c){console.log("SUPRSEND: error marking notification read",c)}}}markArchived(t){var n;const r=this.config.client,i=at.getState(),a=i.activeStoreId;if(!a||!((n=i.stores)!=null&&n[a]))return;const o=(i==null?void 0:i.stores)[a],l=o.notifications.find(u=>u.n_id===t);if(l&&!l.archived){if(!r)return;try{r.markNotificationArchive(t),o.notifications=o.notifications.filter(u=>u.n_id!==t),!l.seen_on&&o.unseenCount>0&&(o.unseenCount-=1),at.setState(Mn({},i)),this.config.emitter.emit("sync_notif_store")}catch(u){console.log("SUPRSEND: error marking notification archived",u)}}}get stores(){return this.config.stores}get data(){const t=at.getState(),n=t.activeStoreId,r=this.stores;if(n)return{unseenCount:t.unseenCount,activeStoreId:t.activeStoreId,stores:t.stores,hasStores:r?(r==null?void 0:r.length)>0:!1,hasNext:t.hasNext,initialLoading:t.initialLoading,fetchMoreLoading:t.fetchMoreLoading}}};class iB{constructor(t,n){this.workspaceKey="",this.tenantId=void 0,this.stores=void 0,this.distinctId=void 0,this.subscriberId=void 0,this._client=void 0,this._expiryTimerId=void 0,this.feed=new x9(this),this.emitter=eB(),this._validateConfig(t),this._setConfigStoreState((n==null?void 0:n.host)||{}),this.tenantId=(n==null?void 0:n.tenantID)||"default",this._validateStore(n==null?void 0:n.stores),this._validatePageSize(n==null?void 0:n.pageSize),this._initializeStoreState()}_validateConfig(t){if(t)this.workspaceKey=t;else throw new tB("workspaceKey missing")}_validateStore(t){if(!t||!Array.isArray(t))return;const n=[];t.forEach(r=>{if(!r.storeId){console.log("SuprSendInbox: storeId is mandatory if stores are used");return}const i=r==null?void 0:r.query;let a,s=[],o=[],l;typeof(i==null?void 0:i.read)=="boolean"&&(a=i.read),typeof(i==null?void 0:i.archived)=="boolean"&&(l=i.archived),typeof(i==null?void 0:i.tags)=="string"?s=[i.tags]:Array.isArray(i==null?void 0:i.tags)&&(s=i==null?void 0:i.tags.filter(u=>typeof u=="string")),typeof(i==null?void 0:i.categories)=="string"?o=[i.categories]:Array.isArray(i==null?void 0:i.categories)&&(o=i==null?void 0:i.categories.filter(u=>typeof u=="string")),n.push({storeId:r.storeId,label:r.label||r.storeId,query:{archived:l,read:a,tags:s,categories:o}})}),this.stores=n}_validatePageSize(t){if(t&&typeof t=="number"){const r=t<=50?t:50;pn.setState({pageSize:r})}}_setConfigStoreState(t){t&&(t!=null&&t.socketHost&&pn.setState({socketUrl:t.socketHost}),t!=null&&t.apiHost&&pn.setState({apiUrl:t.apiHost}),t!=null&&t.collectorHost&&pn.setState({collectorApiUrl:t.collectorHost}))}_initializeStoreState(){const t="default_store",n={notifications:[],unseenCount:0,isFirstCall:!0};if(this.stores&&Array.isArray(this.stores)&&this.stores.length>0){const r={};this.stores.map(i=>{r[i.storeId]=Mn({},n)}),at.setState({stores:r,activeStoreId:this.stores[0].storeId})}else at.setState({stores:{[t]:Mn({},n)},activeStoreId:t});setTimeout(()=>{this.emitter.emit("sync_notif_store")},0)}_startExipryCheck(){var t=this;this._expiryTimerId||(this._expiryTimerId=setInterval(async function(){const r=at.getState().stores;let i=!1;for(let a in r){let s=r[a].notifications;s=s.filter(o=>(o.expiry?Date.now()>o.expiry:!1)?(i=!0,!1):!0),r[a].notifications=s}i&&(at.setState({stores:r}),await t.feed.getNotificationsCount(),t.emitter.emit("sync_notif_store"))},3e4))}get client(){return this.distinctId&&this.subscriberId&&(this._client||(this._client=new rB(this))),this._client}identifyUser(t,n){this.distinctId=t,this.subscriberId=n}changeActiveStore(t){var n;const r=at.getState(),i={};if(r.activeStoreId!==t&&(n=r.stores)!=null&&n[t]){for(let a in r.stores){const s=r.stores[a],o=s.notifications.slice(0,20);i[a]={notifications:o,unseenCount:s.unseenCount,isFirstCall:s.isFirstCall}}at.setState({activeStoreId:t,stores:i,pageNumber:1,hasNext:!0,initialLoading:!1,fetchMoreLoading:!1,initialFetchTime:null}),this.client&&this.feed.fetchNotifications()}}resetUser(){var t;at.setState({unseenCount:0,pageNumber:1,hasNext:!0,initialLoading:!1,fetchMoreLoading:!1,initialFetchTime:null}),this._initializeStoreState(),(t=this._client)==null||t.socket.disconnect(),this.distinctId=void 0,this.subscriberId=void 0,this._client=void 0,clearInterval(this._expiryTimerId),this._expiryTimerId=void 0,this.feed=new x9(this)}}var w9=function(t){return t.reduce(function(n,r){var i=r[0],a=r[1];return n[i]=a,n},{})},A9=typeof window<"u"&&window.document&&window.document.createElement?rn.useLayoutEffect:rn.useEffect,Sn="top",or="bottom",lr="right",kn="left",Em="auto",wl=[Sn,or,lr,kn],Ms="start",ml="end",aB="clippingParents",l8="viewport",ho="popper",sB="reference",S9=wl.reduce(function(e,t){return e.concat([t+"-"+Ms,t+"-"+ml])},[]),u8=[].concat(wl,[Em]).reduce(function(e,t){return e.concat([t,t+"-"+Ms,t+"-"+ml])},[]),oB="beforeRead",lB="read",uB="afterRead",cB="beforeMain",dB="main",fB="afterMain",hB="beforeWrite",pB="write",mB="afterWrite",gB=[oB,lB,uB,cB,dB,fB,hB,pB,mB];function Gr(e){return e?(e.nodeName||"").toLowerCase():null}function Un(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Pa(e){var t=Un(e).Element;return e instanceof t||e instanceof Element}function ir(e){var t=Un(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function ym(e){if(typeof ShadowRoot>"u")return!1;var t=Un(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function vB(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var r=t.styles[n]||{},i=t.attributes[n]||{},a=t.elements[n];!ir(a)||!Gr(a)||(Object.assign(a.style,r),Object.keys(i).forEach(function(s){var o=i[s];o===!1?a.removeAttribute(s):a.setAttribute(s,o===!0?"":o)}))})}function EB(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(r){var i=t.elements[r],a=t.attributes[r]||{},s=Object.keys(t.styles.hasOwnProperty(r)?t.styles[r]:n[r]),o=s.reduce(function(l,u){return l[u]="",l},{});!ir(i)||!Gr(i)||(Object.assign(i.style,o),Object.keys(a).forEach(function(l){i.removeAttribute(l)}))})}}const yB={name:"applyStyles",enabled:!0,phase:"write",fn:vB,effect:EB,requires:["computeStyles"]};function Hr(e){return e.split("-")[0]}var Sa=Math.max,Bc=Math.min,Ls=Math.round;function Hh(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function c8(){return!/^((?!chrome|android).)*safari/i.test(Hh())}function $s(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),i=1,a=1;t&&ir(e)&&(i=e.offsetWidth>0&&Ls(r.width)/e.offsetWidth||1,a=e.offsetHeight>0&&Ls(r.height)/e.offsetHeight||1);var s=Pa(e)?Un(e):window,o=s.visualViewport,l=!c8()&&n,u=(r.left+(l&&o?o.offsetLeft:0))/i,c=(r.top+(l&&o?o.offsetTop:0))/a,d=r.width/i,f=r.height/a;return{width:d,height:f,top:c,right:u+d,bottom:c+f,left:u,x:u,y:c}}function bm(e){var t=$s(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function d8(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&ym(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function vi(e){return Un(e).getComputedStyle(e)}function bB(e){return["table","td","th"].indexOf(Gr(e))>=0}function ta(e){return((Pa(e)?e.ownerDocument:e.document)||window.document).documentElement}function d1(e){return Gr(e)==="html"?e:e.assignedSlot||e.parentNode||(ym(e)?e.host:null)||ta(e)}function k9(e){return!ir(e)||vi(e).position==="fixed"?null:e.offsetParent}function TB(e){var t=/firefox/i.test(Hh()),n=/Trident/i.test(Hh());if(n&&ir(e)){var r=vi(e);if(r.position==="fixed")return null}var i=d1(e);for(ym(i)&&(i=i.host);ir(i)&&["html","body"].indexOf(Gr(i))<0;){var a=vi(i);if(a.transform!=="none"||a.perspective!=="none"||a.contain==="paint"||["transform","perspective"].indexOf(a.willChange)!==-1||t&&a.willChange==="filter"||t&&a.filter&&a.filter!=="none")return i;i=i.parentNode}return null}function Al(e){for(var t=Un(e),n=k9(e);n&&bB(n)&&vi(n).position==="static";)n=k9(n);return n&&(Gr(n)==="html"||Gr(n)==="body"&&vi(n).position==="static")?t:n||TB(e)||t}function Tm(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function Vo(e,t,n){return Sa(e,Bc(t,n))}function _B(e,t,n){var r=Vo(e,t,n);return r>n?n:r}function f8(){return{top:0,right:0,bottom:0,left:0}}function h8(e){return Object.assign({},f8(),e)}function p8(e,t){return t.reduce(function(n,r){return n[r]=e,n},{})}var CB=function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,h8(typeof t!="number"?t:p8(t,wl))};function xB(e){var t,n=e.state,r=e.name,i=e.options,a=n.elements.arrow,s=n.modifiersData.popperOffsets,o=Hr(n.placement),l=Tm(o),u=[kn,lr].indexOf(o)>=0,c=u?"height":"width";if(!(!a||!s)){var d=CB(i.padding,n),f=bm(a),p=l==="y"?Sn:kn,g=l==="y"?or:lr,m=n.rects.reference[c]+n.rects.reference[l]-s[l]-n.rects.popper[c],E=s[l]-n.rects.reference[l],v=Al(a),b=v?l==="y"?v.clientHeight||0:v.clientWidth||0:0,T=m/2-E/2,C=d[p],_=b-f[c]-d[g],x=b/2-f[c]/2+T,S=Vo(C,x,_),F=l;n.modifiersData[r]=(t={},t[F]=S,t.centerOffset=S-x,t)}}function wB(e){var t=e.state,n=e.options,r=n.element,i=r===void 0?"[data-popper-arrow]":r;i!=null&&(typeof i=="string"&&(i=t.elements.popper.querySelector(i),!i)||d8(t.elements.popper,i)&&(t.elements.arrow=i))}const AB={name:"arrow",enabled:!0,phase:"main",fn:xB,effect:wB,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function js(e){return e.split("-")[1]}var SB={top:"auto",right:"auto",bottom:"auto",left:"auto"};function kB(e,t){var n=e.x,r=e.y,i=t.devicePixelRatio||1;return{x:Ls(n*i)/i||0,y:Ls(r*i)/i||0}}function D9(e){var t,n=e.popper,r=e.popperRect,i=e.placement,a=e.variation,s=e.offsets,o=e.position,l=e.gpuAcceleration,u=e.adaptive,c=e.roundOffsets,d=e.isFixed,f=s.x,p=f===void 0?0:f,g=s.y,m=g===void 0?0:g,E=typeof c=="function"?c({x:p,y:m}):{x:p,y:m};p=E.x,m=E.y;var v=s.hasOwnProperty("x"),b=s.hasOwnProperty("y"),T=kn,C=Sn,_=window;if(u){var x=Al(n),S="clientHeight",F="clientWidth";if(x===Un(n)&&(x=ta(n),vi(x).position!=="static"&&o==="absolute"&&(S="scrollHeight",F="scrollWidth")),x=x,i===Sn||(i===kn||i===lr)&&a===ml){C=or;var R=d&&x===_&&_.visualViewport?_.visualViewport.height:x[S];m-=R-r.height,m*=l?1:-1}if(i===kn||(i===Sn||i===or)&&a===ml){T=lr;var L=d&&x===_&&_.visualViewport?_.visualViewport.width:x[F];p-=L-r.width,p*=l?1:-1}}var P=Object.assign({position:o},u&&SB),I=c===!0?kB({x:p,y:m},Un(n)):{x:p,y:m};if(p=I.x,m=I.y,l){var k;return Object.assign({},P,(k={},k[C]=b?"0":"",k[T]=v?"0":"",k.transform=(_.devicePixelRatio||1)<=1?"translate("+p+"px, "+m+"px)":"translate3d("+p+"px, "+m+"px, 0)",k))}return Object.assign({},P,(t={},t[C]=b?m+"px":"",t[T]=v?p+"px":"",t.transform="",t))}function DB(e){var t=e.state,n=e.options,r=n.gpuAcceleration,i=r===void 0?!0:r,a=n.adaptive,s=a===void 0?!0:a,o=n.roundOffsets,l=o===void 0?!0:o,u={placement:Hr(t.placement),variation:js(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:i,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,D9(Object.assign({},u,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:l})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,D9(Object.assign({},u,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const OB={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:DB,data:{}};var lu={passive:!0};function NB(e){var t=e.state,n=e.instance,r=e.options,i=r.scroll,a=i===void 0?!0:i,s=r.resize,o=s===void 0?!0:s,l=Un(t.elements.popper),u=[].concat(t.scrollParents.reference,t.scrollParents.popper);return a&&u.forEach(function(c){c.addEventListener("scroll",n.update,lu)}),o&&l.addEventListener("resize",n.update,lu),function(){a&&u.forEach(function(c){c.removeEventListener("scroll",n.update,lu)}),o&&l.removeEventListener("resize",n.update,lu)}}const IB={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:NB,data:{}};var PB={left:"right",right:"left",bottom:"top",top:"bottom"};function sc(e){return e.replace(/left|right|bottom|top/g,function(t){return PB[t]})}var RB={start:"end",end:"start"};function O9(e){return e.replace(/start|end/g,function(t){return RB[t]})}function _m(e){var t=Un(e),n=t.pageXOffset,r=t.pageYOffset;return{scrollLeft:n,scrollTop:r}}function Cm(e){return $s(ta(e)).left+_m(e).scrollLeft}function FB(e,t){var n=Un(e),r=ta(e),i=n.visualViewport,a=r.clientWidth,s=r.clientHeight,o=0,l=0;if(i){a=i.width,s=i.height;var u=c8();(u||!u&&t==="fixed")&&(o=i.offsetLeft,l=i.offsetTop)}return{width:a,height:s,x:o+Cm(e),y:l}}function BB(e){var t,n=ta(e),r=_m(e),i=(t=e.ownerDocument)==null?void 0:t.body,a=Sa(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),s=Sa(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),o=-r.scrollLeft+Cm(e),l=-r.scrollTop;return vi(i||n).direction==="rtl"&&(o+=Sa(n.clientWidth,i?i.clientWidth:0)-a),{width:a,height:s,x:o,y:l}}function xm(e){var t=vi(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function m8(e){return["html","body","#document"].indexOf(Gr(e))>=0?e.ownerDocument.body:ir(e)&&xm(e)?e:m8(d1(e))}function Ko(e,t){var n;t===void 0&&(t=[]);var r=m8(e),i=r===((n=e.ownerDocument)==null?void 0:n.body),a=Un(r),s=i?[a].concat(a.visualViewport||[],xm(r)?r:[]):r,o=t.concat(s);return i?o:o.concat(Ko(d1(s)))}function Uh(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function MB(e,t){var n=$s(e,!1,t==="fixed");return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function N9(e,t,n){return t===l8?Uh(FB(e,n)):Pa(t)?MB(t,n):Uh(BB(ta(e)))}function LB(e){var t=Ko(d1(e)),n=["absolute","fixed"].indexOf(vi(e).position)>=0,r=n&&ir(e)?Al(e):e;return Pa(r)?t.filter(function(i){return Pa(i)&&d8(i,r)&&Gr(i)!=="body"}):[]}function $B(e,t,n,r){var i=t==="clippingParents"?LB(e):[].concat(t),a=[].concat(i,[n]),s=a[0],o=a.reduce(function(l,u){var c=N9(e,u,r);return l.top=Sa(c.top,l.top),l.right=Bc(c.right,l.right),l.bottom=Bc(c.bottom,l.bottom),l.left=Sa(c.left,l.left),l},N9(e,s,r));return o.width=o.right-o.left,o.height=o.bottom-o.top,o.x=o.left,o.y=o.top,o}function g8(e){var t=e.reference,n=e.element,r=e.placement,i=r?Hr(r):null,a=r?js(r):null,s=t.x+t.width/2-n.width/2,o=t.y+t.height/2-n.height/2,l;switch(i){case Sn:l={x:s,y:t.y-n.height};break;case or:l={x:s,y:t.y+t.height};break;case lr:l={x:t.x+t.width,y:o};break;case kn:l={x:t.x-n.width,y:o};break;default:l={x:t.x,y:t.y}}var u=i?Tm(i):null;if(u!=null){var c=u==="y"?"height":"width";switch(a){case Ms:l[u]=l[u]-(t[c]/2-n[c]/2);break;case ml:l[u]=l[u]+(t[c]/2-n[c]/2);break}}return l}function gl(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=r===void 0?e.placement:r,a=n.strategy,s=a===void 0?e.strategy:a,o=n.boundary,l=o===void 0?aB:o,u=n.rootBoundary,c=u===void 0?l8:u,d=n.elementContext,f=d===void 0?ho:d,p=n.altBoundary,g=p===void 0?!1:p,m=n.padding,E=m===void 0?0:m,v=h8(typeof E!="number"?E:p8(E,wl)),b=f===ho?sB:ho,T=e.rects.popper,C=e.elements[g?b:f],_=$B(Pa(C)?C:C.contextElement||ta(e.elements.popper),l,c,s),x=$s(e.elements.reference),S=g8({reference:x,element:T,strategy:"absolute",placement:i}),F=Uh(Object.assign({},T,S)),R=f===ho?F:x,L={top:_.top-R.top+v.top,bottom:R.bottom-_.bottom+v.bottom,left:_.left-R.left+v.left,right:R.right-_.right+v.right},P=e.modifiersData.offset;if(f===ho&&P){var I=P[i];Object.keys(L).forEach(function(k){var B=[lr,or].indexOf(k)>=0?1:-1,H=[Sn,or].indexOf(k)>=0?"y":"x";L[k]+=I[H]*B})}return L}function jB(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=n.boundary,a=n.rootBoundary,s=n.padding,o=n.flipVariations,l=n.allowedAutoPlacements,u=l===void 0?u8:l,c=js(r),d=c?o?S9:S9.filter(function(g){return js(g)===c}):wl,f=d.filter(function(g){return u.indexOf(g)>=0});f.length===0&&(f=d);var p=f.reduce(function(g,m){return g[m]=gl(e,{placement:m,boundary:i,rootBoundary:a,padding:s})[Hr(m)],g},{});return Object.keys(p).sort(function(g,m){return p[g]-p[m]})}function HB(e){if(Hr(e)===Em)return[];var t=sc(e);return[O9(e),t,O9(t)]}function UB(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var i=n.mainAxis,a=i===void 0?!0:i,s=n.altAxis,o=s===void 0?!0:s,l=n.fallbackPlacements,u=n.padding,c=n.boundary,d=n.rootBoundary,f=n.altBoundary,p=n.flipVariations,g=p===void 0?!0:p,m=n.allowedAutoPlacements,E=t.options.placement,v=Hr(E),b=v===E,T=l||(b||!g?[sc(E)]:HB(E)),C=[E].concat(T).reduce(function(j,z){return j.concat(Hr(z)===Em?jB(t,{placement:z,boundary:c,rootBoundary:d,padding:u,flipVariations:g,allowedAutoPlacements:m}):z)},[]),_=t.rects.reference,x=t.rects.popper,S=new Map,F=!0,R=C[0],L=0;L<C.length;L++){var P=C[L],I=Hr(P),k=js(P)===Ms,B=[Sn,or].indexOf(I)>=0,H=B?"width":"height",q=gl(t,{placement:P,boundary:c,rootBoundary:d,altBoundary:f,padding:u}),N=B?k?lr:kn:k?or:Sn;_[H]>x[H]&&(N=sc(N));var J=sc(N),X=[];if(a&&X.push(q[I]<=0),o&&X.push(q[N]<=0,q[J]<=0),X.every(function(j){return j})){R=P,F=!1;break}S.set(P,X)}if(F)for(var D=g?3:1,A=function(z){var U=C.find(function($){var ae=S.get($);if(ae)return ae.slice(0,z).every(function(Y){return Y})});if(U)return R=U,"break"},Z=D;Z>0;Z--){var M=A(Z);if(M==="break")break}t.placement!==R&&(t.modifiersData[r]._skip=!0,t.placement=R,t.reset=!0)}}const zB={name:"flip",enabled:!0,phase:"main",fn:UB,requiresIfExists:["offset"],data:{_skip:!1}};function I9(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function P9(e){return[Sn,lr,or,kn].some(function(t){return e[t]>=0})}function qB(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,a=t.modifiersData.preventOverflow,s=gl(t,{elementContext:"reference"}),o=gl(t,{altBoundary:!0}),l=I9(s,r),u=I9(o,i,a),c=P9(l),d=P9(u);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:u,isReferenceHidden:c,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":c,"data-popper-escaped":d})}const WB={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:qB};function VB(e,t,n){var r=Hr(e),i=[kn,Sn].indexOf(r)>=0?-1:1,a=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,s=a[0],o=a[1];return s=s||0,o=(o||0)*i,[kn,lr].indexOf(r)>=0?{x:o,y:s}:{x:s,y:o}}function KB(e){var t=e.state,n=e.options,r=e.name,i=n.offset,a=i===void 0?[0,0]:i,s=u8.reduce(function(c,d){return c[d]=VB(d,t.rects,a),c},{}),o=s[t.placement],l=o.x,u=o.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=u),t.modifiersData[r]=s}const GB={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:KB};function YB(e){var t=e.state,n=e.name;t.modifiersData[n]=g8({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const ZB={name:"popperOffsets",enabled:!0,phase:"read",fn:YB,data:{}};function QB(e){return e==="x"?"y":"x"}function XB(e){var t=e.state,n=e.options,r=e.name,i=n.mainAxis,a=i===void 0?!0:i,s=n.altAxis,o=s===void 0?!1:s,l=n.boundary,u=n.rootBoundary,c=n.altBoundary,d=n.padding,f=n.tether,p=f===void 0?!0:f,g=n.tetherOffset,m=g===void 0?0:g,E=gl(t,{boundary:l,rootBoundary:u,padding:d,altBoundary:c}),v=Hr(t.placement),b=js(t.placement),T=!b,C=Tm(v),_=QB(C),x=t.modifiersData.popperOffsets,S=t.rects.reference,F=t.rects.popper,R=typeof m=="function"?m(Object.assign({},t.rects,{placement:t.placement})):m,L=typeof R=="number"?{mainAxis:R,altAxis:R}:Object.assign({mainAxis:0,altAxis:0},R),P=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,I={x:0,y:0};if(x){if(a){var k,B=C==="y"?Sn:kn,H=C==="y"?or:lr,q=C==="y"?"height":"width",N=x[C],J=N+E[B],X=N-E[H],D=p?-F[q]/2:0,A=b===Ms?S[q]:F[q],Z=b===Ms?-F[q]:-S[q],M=t.elements.arrow,j=p&&M?bm(M):{width:0,height:0},z=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:f8(),U=z[B],$=z[H],ae=Vo(0,S[q],j[q]),Y=T?S[q]/2-D-ae-U-L.mainAxis:A-ae-U-L.mainAxis,te=T?-S[q]/2+D+ae+$+L.mainAxis:Z+ae+$+L.mainAxis,se=t.elements.arrow&&Al(t.elements.arrow),re=se?C==="y"?se.clientTop||0:se.clientLeft||0:0,xe=(k=P==null?void 0:P[C])!=null?k:0,ke=N+Y-xe-re,Te=N+te-xe,ue=Vo(p?Bc(J,ke):J,N,p?Sa(X,Te):X);x[C]=ue,I[C]=ue-N}if(o){var fe,we=C==="x"?Sn:kn,Ie=C==="x"?or:lr,Qe=x[_],ct=_==="y"?"height":"width",We=Qe+E[we],Xe=Qe-E[Ie],Ve=[Sn,kn].indexOf(v)!==-1,ie=(fe=P==null?void 0:P[_])!=null?fe:0,me=Ve?We:Qe-S[ct]-F[ct]-ie+L.altAxis,Oe=Ve?Qe+S[ct]+F[ct]-ie-L.altAxis:Xe,ge=p&&Ve?_B(me,Qe,Oe):Vo(p?me:We,Qe,p?Oe:Xe);x[_]=ge,I[_]=ge-Qe}t.modifiersData[r]=I}}const JB={name:"preventOverflow",enabled:!0,phase:"main",fn:XB,requiresIfExists:["offset"]};function eM(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function tM(e){return e===Un(e)||!ir(e)?_m(e):eM(e)}function nM(e){var t=e.getBoundingClientRect(),n=Ls(t.width)/e.offsetWidth||1,r=Ls(t.height)/e.offsetHeight||1;return n!==1||r!==1}function rM(e,t,n){n===void 0&&(n=!1);var r=ir(t),i=ir(t)&&nM(t),a=ta(t),s=$s(e,i,n),o={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((Gr(t)!=="body"||xm(a))&&(o=tM(t)),ir(t)?(l=$s(t,!0),l.x+=t.clientLeft,l.y+=t.clientTop):a&&(l.x=Cm(a))),{x:s.left+o.scrollLeft-l.x,y:s.top+o.scrollTop-l.y,width:s.width,height:s.height}}function iM(e){var t=new Map,n=new Set,r=[];e.forEach(function(a){t.set(a.name,a)});function i(a){n.add(a.name);var s=[].concat(a.requires||[],a.requiresIfExists||[]);s.forEach(function(o){if(!n.has(o)){var l=t.get(o);l&&i(l)}}),r.push(a)}return e.forEach(function(a){n.has(a.name)||i(a)}),r}function aM(e){var t=iM(e);return gB.reduce(function(n,r){return n.concat(t.filter(function(i){return i.phase===r}))},[])}function sM(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}function oM(e){var t=e.reduce(function(n,r){var i=n[r.name];return n[r.name]=i?Object.assign({},i,r,{options:Object.assign({},i.options,r.options),data:Object.assign({},i.data,r.data)}):r,n},{});return Object.keys(t).map(function(n){return t[n]})}var R9={placement:"bottom",modifiers:[],strategy:"absolute"};function F9(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function lM(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,r=n===void 0?[]:n,i=t.defaultOptions,a=i===void 0?R9:i;return function(o,l,u){u===void 0&&(u=a);var c={placement:"bottom",orderedModifiers:[],options:Object.assign({},R9,a),modifiersData:{},elements:{reference:o,popper:l},attributes:{},styles:{}},d=[],f=!1,p={state:c,setOptions:function(v){var b=typeof v=="function"?v(c.options):v;m(),c.options=Object.assign({},a,c.options,b),c.scrollParents={reference:Pa(o)?Ko(o):o.contextElement?Ko(o.contextElement):[],popper:Ko(l)};var T=aM(oM([].concat(r,c.options.modifiers)));return c.orderedModifiers=T.filter(function(C){return C.enabled}),g(),p.update()},forceUpdate:function(){if(!f){var v=c.elements,b=v.reference,T=v.popper;if(F9(b,T)){c.rects={reference:rM(b,Al(T),c.options.strategy==="fixed"),popper:bm(T)},c.reset=!1,c.placement=c.options.placement,c.orderedModifiers.forEach(function(L){return c.modifiersData[L.name]=Object.assign({},L.data)});for(var C=0;C<c.orderedModifiers.length;C++){if(c.reset===!0){c.reset=!1,C=-1;continue}var _=c.orderedModifiers[C],x=_.fn,S=_.options,F=S===void 0?{}:S,R=_.name;typeof x=="function"&&(c=x({state:c,options:F,name:R,instance:p})||c)}}}},update:sM(function(){return new Promise(function(E){p.forceUpdate(),E(c)})}),destroy:function(){m(),f=!0}};if(!F9(o,l))return p;p.setOptions(u).then(function(E){!f&&u.onFirstUpdate&&u.onFirstUpdate(E)});function g(){c.orderedModifiers.forEach(function(E){var v=E.name,b=E.options,T=b===void 0?{}:b,C=E.effect;if(typeof C=="function"){var _=C({state:c,name:v,instance:p,options:T}),x=function(){};d.push(_||x)}})}function m(){d.forEach(function(E){return E()}),d=[]}return p}}var uM=[IB,ZB,OB,yB,GB,zB,JB,AB,WB],cM=lM({defaultModifiers:uM}),dM=typeof Element<"u",fM=typeof Map=="function",hM=typeof Set=="function",pM=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function oc(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var n,r,i;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!oc(e[r],t[r]))return!1;return!0}var a;if(fM&&e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(a=e.entries();!(r=a.next()).done;)if(!t.has(r.value[0]))return!1;for(a=e.entries();!(r=a.next()).done;)if(!oc(r.value[1],t.get(r.value[0])))return!1;return!0}if(hM&&e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(a=e.entries();!(r=a.next()).done;)if(!t.has(r.value[0]))return!1;return!0}if(pM&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf&&typeof e.valueOf=="function"&&typeof t.valueOf=="function")return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString&&typeof e.toString=="function"&&typeof t.toString=="function")return e.toString()===t.toString();if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[r]))return!1;if(dM&&e instanceof Element)return!1;for(r=n;r--!==0;)if(!((i[r]==="_owner"||i[r]==="__v"||i[r]==="__o")&&e.$$typeof)&&!oc(e[i[r]],t[i[r]]))return!1;return!0}return e!==e&&t!==t}var mM=function(t,n){try{return oc(t,n)}catch(r){if((r.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw r}};const gM=_r(mM);var vM=[],EM=function(t,n,r){r===void 0&&(r={});var i=rn.useRef(null),a={onFirstUpdate:r.onFirstUpdate,placement:r.placement||"bottom",strategy:r.strategy||"absolute",modifiers:r.modifiers||vM},s=rn.useState({styles:{popper:{position:a.strategy,left:"0",top:"0"},arrow:{position:"absolute"}},attributes:{}}),o=s[0],l=s[1],u=rn.useMemo(function(){return{name:"updateState",enabled:!0,phase:"write",fn:function(p){var g=p.state,m=Object.keys(g.elements);Y3.flushSync(function(){l({styles:w9(m.map(function(E){return[E,g.styles[E]||{}]})),attributes:w9(m.map(function(E){return[E,g.attributes[E]]}))})})},requires:["computeStyles"]}},[]),c=rn.useMemo(function(){var f={onFirstUpdate:a.onFirstUpdate,placement:a.placement,strategy:a.strategy,modifiers:[].concat(a.modifiers,[u,{name:"applyStyles",enabled:!1}])};return gM(i.current,f)?i.current||f:(i.current=f,f)},[a.onFirstUpdate,a.placement,a.strategy,a.modifiers,u]),d=rn.useRef();return A9(function(){d.current&&d.current.setOptions(c)},[c]),A9(function(){if(!(t==null||n==null)){var f=r.createPopper||cM,p=f(t,n,c);return d.current=p,function(){p.destroy(),d.current=null}}},[t,n,r.createPopper]),{state:d.current?d.current.state:null,styles:o.styles,attributes:o.attributes,update:d.current?d.current.update:null,forceUpdate:d.current?d.current.forceUpdate:null}};function zh(){return zh=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},zh.apply(this,arguments)}function v8(e){var t=Object.create(null);return function(n){return t[n]===void 0&&(t[n]=e(n)),t[n]}}var yM=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,bM=v8(function(e){return yM.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91}),TM=!1;function _M(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}function CM(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),e.nonce!==void 0&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}var xM=function(){function e(n){var r=this;this._insertTag=function(i){var a;r.tags.length===0?r.insertionPoint?a=r.insertionPoint.nextSibling:r.prepend?a=r.container.firstChild:a=r.before:a=r.tags[r.tags.length-1].nextSibling,r.container.insertBefore(i,a),r.tags.push(i)},this.isSpeedy=n.speedy===void 0?!TM:n.speedy,this.tags=[],this.ctr=0,this.nonce=n.nonce,this.key=n.key,this.container=n.container,this.prepend=n.prepend,this.insertionPoint=n.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(r){r.forEach(this._insertTag)},t.insert=function(r){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(CM(this));var i=this.tags[this.tags.length-1];if(this.isSpeedy){var a=_M(i);try{a.insertRule(r,a.cssRules.length)}catch{}}else i.appendChild(document.createTextNode(r));this.ctr++},t.flush=function(){this.tags.forEach(function(r){var i;return(i=r.parentNode)==null?void 0:i.removeChild(r)}),this.tags=[],this.ctr=0},e}(),sn="-ms-",Mc="-moz-",pt="-webkit-",E8="comm",wm="rule",Am="decl",wM="@import",y8="@keyframes",AM="@layer",SM=Math.abs,f1=String.fromCharCode,kM=Object.assign;function DM(e,t){return nn(e,0)^45?(((t<<2^nn(e,0))<<2^nn(e,1))<<2^nn(e,2))<<2^nn(e,3):0}function b8(e){return e.trim()}function OM(e,t){return(e=t.exec(e))?e[0]:e}function mt(e,t,n){return e.replace(t,n)}function qh(e,t){return e.indexOf(t)}function nn(e,t){return e.charCodeAt(t)|0}function vl(e,t,n){return e.slice(t,n)}function Pr(e){return e.length}function Sm(e){return e.length}function uu(e,t){return t.push(e),e}function NM(e,t){return e.map(t).join("")}var h1=1,Hs=1,T8=0,On=0,Wt=0,Ys="";function p1(e,t,n,r,i,a,s){return{value:e,root:t,parent:n,type:r,props:i,children:a,line:h1,column:Hs,length:s,return:""}}function po(e,t){return kM(p1("",null,null,"",null,null,0),e,{length:-e.length},t)}function IM(){return Wt}function PM(){return Wt=On>0?nn(Ys,--On):0,Hs--,Wt===10&&(Hs=1,h1--),Wt}function $n(){return Wt=On<T8?nn(Ys,On++):0,Hs++,Wt===10&&(Hs=1,h1++),Wt}function Ur(){return nn(Ys,On)}function lc(){return On}function Sl(e,t){return vl(Ys,e,t)}function El(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function _8(e){return h1=Hs=1,T8=Pr(Ys=e),On=0,[]}function C8(e){return Ys="",e}function uc(e){return b8(Sl(On-1,Wh(e===91?e+2:e===40?e+1:e)))}function RM(e){for(;(Wt=Ur())&&Wt<33;)$n();return El(e)>2||El(Wt)>3?"":" "}function FM(e,t){for(;--t&&$n()&&!(Wt<48||Wt>102||Wt>57&&Wt<65||Wt>70&&Wt<97););return Sl(e,lc()+(t<6&&Ur()==32&&$n()==32))}function Wh(e){for(;$n();)switch(Wt){case e:return On;case 34:case 39:e!==34&&e!==39&&Wh(Wt);break;case 40:e===41&&Wh(e);break;case 92:$n();break}return On}function BM(e,t){for(;$n()&&e+Wt!==47+10;)if(e+Wt===42+42&&Ur()===47)break;return"/*"+Sl(t,On-1)+"*"+f1(e===47?e:$n())}function MM(e){for(;!El(Ur());)$n();return Sl(e,On)}function LM(e){return C8(cc("",null,null,null,[""],e=_8(e),0,[0],e))}function cc(e,t,n,r,i,a,s,o,l){for(var u=0,c=0,d=s,f=0,p=0,g=0,m=1,E=1,v=1,b=0,T="",C=i,_=a,x=r,S=T;E;)switch(g=b,b=$n()){case 40:if(g!=108&&nn(S,d-1)==58){qh(S+=mt(uc(b),"&","&\f"),"&\f")!=-1&&(v=-1);break}case 34:case 39:case 91:S+=uc(b);break;case 9:case 10:case 13:case 32:S+=RM(g);break;case 92:S+=FM(lc()-1,7);continue;case 47:switch(Ur()){case 42:case 47:uu($M(BM($n(),lc()),t,n),l);break;default:S+="/"}break;case 123*m:o[u++]=Pr(S)*v;case 125*m:case 59:case 0:switch(b){case 0:case 125:E=0;case 59+c:v==-1&&(S=mt(S,/\f/g,"")),p>0&&Pr(S)-d&&uu(p>32?M9(S+";",r,n,d-1):M9(mt(S," ","")+";",r,n,d-2),l);break;case 59:S+=";";default:if(uu(x=B9(S,t,n,u,c,i,o,T,C=[],_=[],d),a),b===123)if(c===0)cc(S,t,x,x,C,a,d,o,_);else switch(f===99&&nn(S,3)===110?100:f){case 100:case 108:case 109:case 115:cc(e,x,x,r&&uu(B9(e,x,x,0,0,i,o,T,i,C=[],d),_),i,_,d,o,r?C:_);break;default:cc(S,x,x,x,[""],_,0,o,_)}}u=c=p=0,m=v=1,T=S="",d=s;break;case 58:d=1+Pr(S),p=g;default:if(m<1){if(b==123)--m;else if(b==125&&m++==0&&PM()==125)continue}switch(S+=f1(b),b*m){case 38:v=c>0?1:(S+="\f",-1);break;case 44:o[u++]=(Pr(S)-1)*v,v=1;break;case 64:Ur()===45&&(S+=uc($n())),f=Ur(),c=d=Pr(T=S+=MM(lc())),b++;break;case 45:g===45&&Pr(S)==2&&(m=0)}}return a}function B9(e,t,n,r,i,a,s,o,l,u,c){for(var d=i-1,f=i===0?a:[""],p=Sm(f),g=0,m=0,E=0;g<r;++g)for(var v=0,b=vl(e,d+1,d=SM(m=s[g])),T=e;v<p;++v)(T=b8(m>0?f[v]+" "+b:mt(b,/&\f/g,f[v])))&&(l[E++]=T);return p1(e,t,n,i===0?wm:o,l,u,c)}function $M(e,t,n){return p1(e,t,n,E8,f1(IM()),vl(e,2,-2),0)}function M9(e,t,n,r){return p1(e,t,n,Am,vl(e,0,r),vl(e,r+1,-1),r)}function Ts(e,t){for(var n="",r=Sm(e),i=0;i<r;i++)n+=t(e[i],i,e,t)||"";return n}function jM(e,t,n,r){switch(e.type){case AM:if(e.children.length)break;case wM:case Am:return e.return=e.return||e.value;case E8:return"";case y8:return e.return=e.value+"{"+Ts(e.children,r)+"}";case wm:e.value=e.props.join(",")}return Pr(n=Ts(e.children,r))?e.return=e.value+"{"+n+"}":""}function HM(e){var t=Sm(e);return function(n,r,i,a){for(var s="",o=0;o<t;o++)s+=e[o](n,r,i,a)||"";return s}}function UM(e){return function(t){t.root||(t=t.return)&&e(t)}}var zM=function(t,n,r){for(var i=0,a=0;i=a,a=Ur(),i===38&&a===12&&(n[r]=1),!El(a);)$n();return Sl(t,On)},qM=function(t,n){var r=-1,i=44;do switch(El(i)){case 0:i===38&&Ur()===12&&(n[r]=1),t[r]+=zM(On-1,n,r);break;case 2:t[r]+=uc(i);break;case 4:if(i===44){t[++r]=Ur()===58?"&\f":"",n[r]=t[r].length;break}default:t[r]+=f1(i)}while(i=$n());return t},WM=function(t,n){return C8(qM(_8(t),n))},L9=new WeakMap,VM=function(t){if(!(t.type!=="rule"||!t.parent||t.length<1)){for(var n=t.value,r=t.parent,i=t.column===r.column&&t.line===r.line;r.type!=="rule";)if(r=r.parent,!r)return;if(!(t.props.length===1&&n.charCodeAt(0)!==58&&!L9.get(r))&&!i){L9.set(t,!0);for(var a=[],s=WM(n,a),o=r.props,l=0,u=0;l<s.length;l++)for(var c=0;c<o.length;c++,u++)t.props[u]=a[l]?s[l].replace(/&\f/g,o[c]):o[c]+" "+s[l]}}},KM=function(t){if(t.type==="decl"){var n=t.value;n.charCodeAt(0)===108&&n.charCodeAt(2)===98&&(t.return="",t.value="")}};function x8(e,t){switch(DM(e,t)){case 5103:return pt+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return pt+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return pt+e+Mc+e+sn+e+e;case 6828:case 4268:return pt+e+sn+e+e;case 6165:return pt+e+sn+"flex-"+e+e;case 5187:return pt+e+mt(e,/(\w+).+(:[^]+)/,pt+"box-$1$2"+sn+"flex-$1$2")+e;case 5443:return pt+e+sn+"flex-item-"+mt(e,/flex-|-self/,"")+e;case 4675:return pt+e+sn+"flex-line-pack"+mt(e,/align-content|flex-|-self/,"")+e;case 5548:return pt+e+sn+mt(e,"shrink","negative")+e;case 5292:return pt+e+sn+mt(e,"basis","preferred-size")+e;case 6060:return pt+"box-"+mt(e,"-grow","")+pt+e+sn+mt(e,"grow","positive")+e;case 4554:return pt+mt(e,/([^-])(transform)/g,"$1"+pt+"$2")+e;case 6187:return mt(mt(mt(e,/(zoom-|grab)/,pt+"$1"),/(image-set)/,pt+"$1"),e,"")+e;case 5495:case 3959:return mt(e,/(image-set\([^]*)/,pt+"$1$`$1");case 4968:return mt(mt(e,/(.+:)(flex-)?(.*)/,pt+"box-pack:$3"+sn+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+pt+e+e;case 4095:case 3583:case 4068:case 2532:return mt(e,/(.+)-inline(.+)/,pt+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(Pr(e)-1-t>6)switch(nn(e,t+1)){case 109:if(nn(e,t+4)!==45)break;case 102:return mt(e,/(.+:)(.+)-([^]+)/,"$1"+pt+"$2-$3$1"+Mc+(nn(e,t+3)==108?"$3":"$2-$3"))+e;case 115:return~qh(e,"stretch")?x8(mt(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(nn(e,t+1)!==115)break;case 6444:switch(nn(e,Pr(e)-3-(~qh(e,"!important")&&10))){case 107:return mt(e,":",":"+pt)+e;case 101:return mt(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+pt+(nn(e,14)===45?"inline-":"")+"box$3$1"+pt+"$2$3$1"+sn+"$2box$3")+e}break;case 5936:switch(nn(e,t+11)){case 114:return pt+e+sn+mt(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return pt+e+sn+mt(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return pt+e+sn+mt(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return pt+e+sn+e+e}return e}var GM=function(t,n,r,i){if(t.length>-1&&!t.return)switch(t.type){case Am:t.return=x8(t.value,t.length);break;case y8:return Ts([po(t,{value:mt(t.value,"@","@"+pt)})],i);case wm:if(t.length)return NM(t.props,function(a){switch(OM(a,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return Ts([po(t,{props:[mt(a,/:(read-\w+)/,":"+Mc+"$1")]})],i);case"::placeholder":return Ts([po(t,{props:[mt(a,/:(plac\w+)/,":"+pt+"input-$1")]}),po(t,{props:[mt(a,/:(plac\w+)/,":"+Mc+"$1")]}),po(t,{props:[mt(a,/:(plac\w+)/,sn+"input-$1")]})],i)}return""})}},YM=[GM],ZM=function(t){var n=t.key;if(n==="css"){var r=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(r,function(m){var E=m.getAttribute("data-emotion");E.indexOf(" ")!==-1&&(document.head.appendChild(m),m.setAttribute("data-s",""))})}var i=t.stylisPlugins||YM,a={},s,o=[];s=t.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+n+' "]'),function(m){for(var E=m.getAttribute("data-emotion").split(" "),v=1;v<E.length;v++)a[E[v]]=!0;o.push(m)});var l,u=[VM,KM];{var c,d=[jM,UM(function(m){c.insert(m)})],f=HM(u.concat(i,d)),p=function(E){return Ts(LM(E),f)};l=function(E,v,b,T){c=b,p(E?E+"{"+v.styles+"}":v.styles),T&&(g.inserted[v.name]=!0)}}var g={key:n,sheet:new xM({key:n,container:s,nonce:t.nonce,speedy:t.speedy,prepend:t.prepend,insertionPoint:t.insertionPoint}),nonce:t.nonce,inserted:a,registered:{},insert:l};return g.sheet.hydrate(o),g},w8=xp(),QM={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},XM={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},A8={};A8[w8.ForwardRef]=QM;A8[w8.Memo]=XM;var JM=!0;function eL(e,t,n){var r="";return n.split(" ").forEach(function(i){e[i]!==void 0?t.push(e[i]+";"):i&&(r+=i+" ")}),r}var S8=function(t,n,r){var i=t.key+"-"+n.name;(r===!1||JM===!1)&&t.registered[i]===void 0&&(t.registered[i]=n.styles)},tL=function(t,n,r){S8(t,n,r);var i=t.key+"-"+n.name;if(t.inserted[n.name]===void 0){var a=n;do t.insert(n===a?"."+i:"",a,t.sheet,!0),a=a.next;while(a!==void 0)}};function nL(e){for(var t=0,n,r=0,i=e.length;i>=4;++r,i-=4)n=e.charCodeAt(r)&255|(e.charCodeAt(++r)&255)<<8|(e.charCodeAt(++r)&255)<<16|(e.charCodeAt(++r)&255)<<24,n=(n&65535)*1540483477+((n>>>16)*59797<<16),n^=n>>>24,t=(n&65535)*1540483477+((n>>>16)*59797<<16)^(t&65535)*1540483477+((t>>>16)*59797<<16);switch(i){case 3:t^=(e.charCodeAt(r+2)&255)<<16;case 2:t^=(e.charCodeAt(r+1)&255)<<8;case 1:t^=e.charCodeAt(r)&255,t=(t&65535)*1540483477+((t>>>16)*59797<<16)}return t^=t>>>13,t=(t&65535)*1540483477+((t>>>16)*59797<<16),((t^t>>>15)>>>0).toString(36)}var rL={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},iL=!1,aL=/[A-Z]|^ms/g,sL=/_EMO_([^_]+?)_([^]*?)_EMO_/g,k8=function(t){return t.charCodeAt(1)===45},$9=function(t){return t!=null&&typeof t!="boolean"},Ud=v8(function(e){return k8(e)?e:e.replace(aL,"-$&").toLowerCase()}),j9=function(t,n){switch(t){case"animation":case"animationName":if(typeof n=="string")return n.replace(sL,function(r,i,a){return Rr={name:i,styles:a,next:Rr},i})}return rL[t]!==1&&!k8(t)&&typeof n=="number"&&n!==0?n+"px":n},oL="Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";function yl(e,t,n){if(n==null)return"";var r=n;if(r.__emotion_styles!==void 0)return r;switch(typeof n){case"boolean":return"";case"object":{var i=n;if(i.anim===1)return Rr={name:i.name,styles:i.styles,next:Rr},i.name;var a=n;if(a.styles!==void 0){var s=a.next;if(s!==void 0)for(;s!==void 0;)Rr={name:s.name,styles:s.styles,next:Rr},s=s.next;var o=a.styles+";";return o}return lL(e,t,n)}case"function":{if(e!==void 0){var l=Rr,u=n(e);return Rr=l,yl(e,t,u)}break}}var c=n;if(t==null)return c;var d=t[c];return d!==void 0?d:c}function lL(e,t,n){var r="";if(Array.isArray(n))for(var i=0;i<n.length;i++)r+=yl(e,t,n[i])+";";else for(var a in n){var s=n[a];if(typeof s!="object"){var o=s;t!=null&&t[o]!==void 0?r+=a+"{"+t[o]+"}":$9(o)&&(r+=Ud(a)+":"+j9(a,o)+";")}else{if(a==="NO_COMPONENT_SELECTOR"&&iL)throw new Error(oL);if(Array.isArray(s)&&typeof s[0]=="string"&&(t==null||t[s[0]]===void 0))for(var l=0;l<s.length;l++)$9(s[l])&&(r+=Ud(a)+":"+j9(a,s[l])+";");else{var u=yl(e,t,s);switch(a){case"animation":case"animationName":{r+=Ud(a)+":"+u+";";break}default:r+=a+"{"+u+"}"}}}}return r}var H9=/label:\s*([^\s;{]+)\s*(;|$)/g,Rr;function D8(e,t,n){if(e.length===1&&typeof e[0]=="object"&&e[0]!==null&&e[0].styles!==void 0)return e[0];var r=!0,i="";Rr=void 0;var a=e[0];if(a==null||a.raw===void 0)r=!1,i+=yl(n,t,a);else{var s=a;i+=s[0]}for(var o=1;o<e.length;o++)if(i+=yl(n,t,e[o]),r){var l=a;i+=l[o]}H9.lastIndex=0;for(var u="",c;(c=H9.exec(i))!==null;)u+="-"+c[1];var d=nL(i)+u;return{name:d,styles:i,next:Rr}}var uL=function(t){return t()},cL=rn["useInsertionEffect"]?rn["useInsertionEffect"]:!1,dL=cL||uL,O8=rn.createContext(typeof HTMLElement<"u"?ZM({key:"css"}):null);O8.Provider;var fL=function(t){return y.forwardRef(function(n,r){var i=y.useContext(O8);return t(n,i,r)})},hL=rn.createContext({});function pL(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return D8(t)}var mL=function(){var t=pL.apply(void 0,arguments),n="animation-"+t.name;return{name:n,styles:"@keyframes "+n+"{"+t.styles+"}",anim:1,toString:function(){return"_EMO_"+this.name+"_"+this.styles+"_EMO_"}}},gL=bM,vL=function(t){return t!=="theme"},U9=function(t){return typeof t=="string"&&t.charCodeAt(0)>96?gL:vL},z9=function(t,n,r){var i;if(n){var a=n.shouldForwardProp;i=t.__emotion_forwardProp&&a?function(s){return t.__emotion_forwardProp(s)&&a(s)}:a}return typeof i!="function"&&r&&(i=t.__emotion_forwardProp),i},EL=!1,yL=function(t){var n=t.cache,r=t.serialized,i=t.isStringTag;return S8(n,r,i),dL(function(){return tL(n,r,i)}),null},bL=function e(t,n){var r=t.__emotion_real===t,i=r&&t.__emotion_base||t,a,s;n!==void 0&&(a=n.label,s=n.target);var o=z9(t,n,r),l=o||U9(i),u=!l("as");return function(){var c=arguments,d=r&&t.__emotion_styles!==void 0?t.__emotion_styles.slice(0):[];if(a!==void 0&&d.push("label:"+a+";"),c[0]==null||c[0].raw===void 0)d.push.apply(d,c);else{d.push(c[0][0]);for(var f=c.length,p=1;p<f;p++)d.push(c[p],c[0][p])}var g=fL(function(m,E,v){var b=u&&m.as||i,T="",C=[],_=m;if(m.theme==null){_={};for(var x in m)_[x]=m[x];_.theme=rn.useContext(hL)}typeof m.className=="string"?T=eL(E.registered,C,m.className):m.className!=null&&(T=m.className+" ");var S=D8(d.concat(C),E.registered,_);T+=E.key+"-"+S.name,s!==void 0&&(T+=" "+s);var F=u&&o===void 0?U9(b):l,R={};for(var L in m)u&&L==="as"||F(L)&&(R[L]=m[L]);return R.className=T,v&&(R.ref=v),rn.createElement(rn.Fragment,null,rn.createElement(yL,{cache:E,serialized:S,isStringTag:typeof b=="string"}),rn.createElement(b,R))});return g.displayName=a!==void 0?a:"Styled("+(typeof i=="string"?i:i.displayName||i.name||"Component")+")",g.defaultProps=t.defaultProps,g.__emotion_real=g,g.__emotion_base=i,g.__emotion_styles=d,g.__emotion_forwardProp=o,Object.defineProperty(g,"toString",{value:function(){return s===void 0&&EL?"NO_COMPONENT_SELECTOR":"."+s}}),g.withComponent=function(m,E){return e(m,zh({},n,E,{shouldForwardProp:z9(g,E,!0)})).apply(void 0,d)},g}},TL=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],Pe=bL.bind();TL.forEach(function(e){Pe[e]=Pe(e)});var Ya={}.hasOwnProperty,N8=_L;function _L(e){return!e||typeof e!="object"?"":Ya.call(e,"position")||Ya.call(e,"type")?q9(e.position):Ya.call(e,"start")||Ya.call(e,"end")?q9(e):Ya.call(e,"line")||Ya.call(e,"column")?Vh(e):""}function Vh(e){return(!e||typeof e!="object")&&(e={}),W9(e.line)+":"+W9(e.column)}function q9(e){return(!e||typeof e!="object")&&(e={}),Vh(e.start)+"-"+Vh(e.end)}function W9(e){return e&&typeof e=="number"?e:1}var CL=N8,xL=km;function I8(){}I8.prototype=Error.prototype;km.prototype=new I8;var na=km.prototype;na.file="";na.name="";na.reason="";na.message="";na.stack="";na.fatal=null;na.column=null;na.line=null;function km(e,t,n){var r,i,a;typeof t=="string"&&(n=t,t=null),r=wL(n),i=CL(t)||"1:1",a={start:{line:null,column:null},end:{line:null,column:null}},t&&t.position&&(t=t.position),t&&(t.start?(a=t,t=t.start):a.start=t),e.stack&&(this.stack=e.stack,e=e.message),this.message=e,this.name=i,this.reason=e,this.line=t?t.line:null,this.column=t?t.column:null,this.location=a,this.source=r[0],this.ruleId=r[1]}function wL(e){var t=[null,null],n;return typeof e=="string"&&(n=e.indexOf(":"),n===-1?t[1]=e:(t[0]=e.slice(0,n),t[1]=e.slice(n+1))),t}var Zs={};Zs.basename=AL;Zs.dirname=SL;Zs.extname=kL;Zs.join=DL;Zs.sep="/";function AL(e,t){var n=0,r=-1,i,a,s,o;if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');if(kl(e),i=e.length,t===void 0||!t.length||t.length>e.length){for(;i--;)if(e.charCodeAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";for(a=-1,o=t.length-1;i--;)if(e.charCodeAt(i)===47){if(s){n=i+1;break}}else a<0&&(s=!0,a=i+1),o>-1&&(e.charCodeAt(i)===t.charCodeAt(o--)?o<0&&(r=i):(o=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function SL(e){var t,n,r;if(kl(e),!e.length)return".";for(t=-1,r=e.length;--r;)if(e.charCodeAt(r)===47){if(n){t=r;break}}else n||(n=!0);return t<0?e.charCodeAt(0)===47?"/":".":t===1&&e.charCodeAt(0)===47?"//":e.slice(0,t)}function kL(e){var t=-1,n=0,r=-1,i=0,a,s,o;for(kl(e),o=e.length;o--;){if(s=e.charCodeAt(o),s===47){if(a){n=o+1;break}continue}r<0&&(a=!0,r=o+1),s===46?t<0?t=o:i!==1&&(i=1):t>-1&&(i=-1)}return t<0||r<0||i===0||i===1&&t===r-1&&t===n+1?"":e.slice(t,r)}function DL(){for(var e=-1,t;++e<arguments.length;)kl(arguments[e]),arguments[e]&&(t=t===void 0?arguments[e]:t+"/"+arguments[e]);return t===void 0?".":OL(t)}function OL(e){var t,n;return kl(e),t=e.charCodeAt(0)===47,n=NL(e,!t),!n.length&&!t&&(n="."),n.length&&e.charCodeAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function NL(e,t){for(var n="",r=0,i=-1,a=0,s=-1,o,l;++s<=e.length;){if(s<e.length)o=e.charCodeAt(s);else{if(o===47)break;o=47}if(o===47){if(!(i===s-1||a===1))if(i!==s-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=s,a=0;continue}}else if(n.length){n="",r=0,i=s,a=0;continue}}t&&(n=n.length?n+"/..":"..",r=2)}else n.length?n+="/"+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===46&&a>-1?a++:a=-1}return n}function kl(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var P8={};P8.cwd=IL;function IL(){return"/"}/*!
|
|
165
165
|
* Determine if an object is a Buffer
|
|
@@ -567,6 +567,6 @@ and limitations under the License.
|
|
|
567
567
|
.Toastify__toast-body {
|
|
568
568
|
padding: 0px;
|
|
569
569
|
}
|
|
570
|
-
`]))),Ere={storeData:{},unseenCount:0,hasNext:!1,initialLoading:!1,fetchMoreLoading:!1};y.createContext({notificationsData:Ere});function yre(e){var t=e.workspaceKey,n=t===void 0?"":t,r=e.tenantId,i=r===void 0?"":r,a=e.distinctId,s=a===void 0?"":a,o=e.subscriberId,l=o===void 0?"":o,u=e.inboxId,c=u===void 0?"":u,d=e.stores,f=e.toastProps,p=e.notificationClickHandler,g=e.primaryActionClickHandler,m=e.secondaryActionClickHandler,E=e.bellComponent,v=e.badgeComponent,b=e.notificationComponent,T=e.noNotificationsComponent,C=e.loaderComponent,_=e.tabBadgeComponent,x=e.headerRightComponent,S=e.hideAvatar,F=S===void 0?!1:S,R=e.hideInbox,L=e.hideToast,P=e.theme,I=e.themeType,k=I===void 0?"light":I,B=e.pagination,H=B===void 0?!0:B,q=e.pageSize,N=e.popperPosition,J=N===void 0?"bottom":N,X=e.showUnreadCountOnTabs,D=X===void 0?!0:X,A=e.host;c&&(l=c);var Z=y.useState(!1),M=Z[0],j=Z[1],z=y.useState(),U=z[0],$=z[1],ae=y.useState({storeData:{},count:0}),Y=ae[0],te=ae[1],se=y.useState(""),re=se[0],xe=se[1],ke=y.useState(!1),Te=ke[0],ue=ke[1];y.useEffect(function(){var we=new iB(n,{pageSize:q,tenantID:i,stores:d,host:A});return $(we),we.emitter.on("sync_notif_store",function(){var Ie=we.feed.data;te({storeData:(Ie==null?void 0:Ie.stores)||{},count:(Ie==null?void 0:Ie.unseenCount)||0,hasNext:Ie==null?void 0:Ie.hasNext,initialLoading:Ie==null?void 0:Ie.initialLoading,activeStoreId:Ie==null?void 0:Ie.activeStoreId}),xe(Ie==null?void 0:Ie.activeStoreId)}),we.emitter.on("new_notification",function(Ie){gre({notificationsData:Ie,toastProps:f})}),function(){we.emitter.all.clear()}},[]),y.useEffect(function(){M&&l&&U&&U.feed.markAllSeen()},[M,l,U]),y.useEffect(function(){if(!(!l||!U))return te({storeData:{},count:0}),U.identifyUser(s,l),U.feed.fetchNotifications(),function(){U.resetUser()}},[l,U]);var fe=k==="dark"?T3(Qte,P):P||{};return y.createElement(y3.Provider,{value:fe},y.createElement(E3.Provider,{value:{workspaceKey:n,notificationsData:Y,setNotificationsData:te,notificationClickHandler:p,primaryActionClickHandler:g,secondaryActionClickHandler:m,bellComponent:E,badgeComponent:v,notificationComponent:b,noNotificationsComponent:T,tabBadgeComponent:_,headerRightComponent:x,toggleInbox:j,inbox:U,loaderComponent:C,pagination:H,hideAvatar:F,activeStore:re,setActiveStore:xe,changingActiveStore:Te,setChangingActiveStore:ue,showUnreadCountOnTabs:D,themeType:k}},!R&&y.createElement(sre,{openInbox:M,toggleInbox:j,popperPosition:J}),!L&&y.createElement(mre,f)))}const bt={timeouts:{},handlerCalled:{},getIsDesktopVersion:(e,t)=>{const n={navigation:{loggedIn:769,loggedOut:881},search:{loggedIn:961,loggedOut:1121}},r=a=>{const s=`logged${e?"In":"Out"}`;return t>=n[a][s]};let i={};return["navigation","search"].forEach(a=>{i[a]=r(a)}),i},shouldChangeHeaderIsVisible:(e,t,n)=>{Object.values(t).filter(i=>i===!0).length||n([{type:"headerIsVisible",value:e}])},handleMenus:({id:e,value:t,menus:n,dispatch:r,forceHandle:i=!1})=>{if(!i&&n[e]===t||!i&&e===Bn.ACCOUNT&&t===!1&&n[Bn.SITE]===!0)return;const a=Date.now();if(!i&&!t&&bt.handlerCalled[e]&&a-bt.handlerCalled[e]<500)return;bt.handlerCalled[e]=a;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 Bn.SITE:o=document.querySelector("#header .menu-button"),o||(o=document.querySelector("#navigation .navigation-button"));break;case Bn.SEARCH:o=document.querySelector("#header .toggle-search-button");break;case Bn.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 i=qy(e[r],t);if(!(typeof i>"u")&&(!n||i[t]&&i[t].includes(n)||i.value&&i.value.includes(n)||i.toString().includes(n)))return e[r]}return e[0].children?bt.findFirstChild(e[0].children,t,n):!1},autoFocus:({menu:e,navigationRef:t,isDesktopVersion:n,focusElements:r,dispatch:i})=>{var l;if(!t.current||!t.current.children)return;const a=n?"desktop":"default";if(r[e][a]){(l=document.querySelector(`#header ul a[href="${r[e][a]}"]:last-child`))==null||l.focus();return}let s,o;switch(e){case Bn.SITE:if(n){const u=bt.findFirstChild(t.current.children,"className","has-submenu parent"),c=bt.findFirstChild(u.children,"id",Bn.SITE);s=bt.findFirstChild(c.children,"href")}else s=bt.findFirstChild(t.current.children,"href");break;case Bn.ACCOUNT:if(o=bt.findFirstChild(t.current.children,"className","account"),!o||!o.children)return;s=bt.findFirstChild(o.children,"href");break;default:return}s&&(i([{type:`focusElements.${e}.${a}`,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(bt.timeouts[t]),n(t,!r))},onFocus:({id:e})=>{clearTimeout(bt.timeouts[e])},onMouseEnter:({id:e,callback:t})=>{clearTimeout(bt.timeouts[e]),t(e,!0)},onBlur:({id:e,callback:t})=>{bt.timeouts[e]=setTimeout(()=>{t(e,!1)},250)}}},As={order:["home","communities","topics","partners","account"],home:{href:"/home/",hasVariantText:!0,gtmType:"homepage-click"},communities:{href:"/communities/",gtmType:"communities-click",onlyShow:"logged-in"},topics:{onlyShow:"logged-in",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:["cities-and-local-government","digital-and-data","education","climate","health-and-social-care","equity-justice-and-inclusion","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:"/logout",className:"divider"}},buttons:{order:["login","signup"],login:{href:"/login",withReturnTo:!0},signup:{href:"/signup?ref=header-banner",props:{variant:"primary"}}}},Vc=({id:e,isLoggedIn:t=!1,isDesktopVersion:n=!1,menus:r={},callback:i=()=>{},doTrack:a=null,getHref:s})=>{const o=he.useIntl(),l=qy(As,e);if(!l||l.onlyShow&&(l.onlyShow==="logged-in"&&!t||l.onlyShow==="logged-out"&&t))return null;const u="doTrack"in l,c=a===null?u?l.doTrack:!0:a,d=e.includes("buttons.");let f=`header_${e.replaceAll(".","_")}`;l.hasVariantText&&(f+=`_logged${t?"In":"Out"}`);let p=!1;if(l.href){let C=l.gtmType||`${e}-click`;if(C.includes(".")){const _=C.split("."),x=_[_.length-2];C=`${x==="topics"?`${x}-`:""}${_[_.length-1]}`}p={href:s?s(l.href):l.withReturnTo?`${l.href}?returnTo=${window.location.pathname}`:l.href},c&&(p={...p,className:"gtm-trackable","data-gtm-event-type":C,"data-gtm-event-context":"HeaderButtons"}),d&&(p={...p,variant:"secondary",size:{mobile:"small",881:"large"},...l.props||{}})}const g=l.order&&l.order[0]&&l[l.order[0]],m=g&&l[l.order[0]].order,E=p&&window.location.pathname===l.href;let v={},b={},T={};if(E&&(v={...v,"aria-current":"page"}),g){const C=l.menuId||e,_={onClick:x=>bt.events.onClick(x,{id:C,callback:i,isOpen:r[C]}),onFocus:()=>bt.events.onFocus({id:C}),onBlur:()=>bt.events.onBlur({id:C,callback:i}),onMouseLeave:()=>bt.events.onBlur({id:C,callback:i}),onMouseEnter:()=>bt.events.onMouseEnter({id:C,callback:i})};b={..._,id:C===Bn.SITE?Bn.SITE:Bn.ACCOUNT},n&&(m&&(T={..._,className:"navigation-button",onKeyPress:x=>{x.key==="Enter"&&bt.events.onClick(x,{id:C,callback:i,isOpen:r[C]})},"aria-haspopup":!0,"aria-expanded":r[C],"aria-controls":C}),b={...b,hidden:C in r?!r[C]:!0}),m||(b={...b})}return h.jsxs("li",{className:ee({[l.className]:l.className,"has-submenu":g,parent:m,active:E}),...v,children:[p?y.createElement(d?Me:"a",p,o.formatMessage({id:f})):n&&l.order&&m?h.jsxs("button",{...T,children:[o.formatMessage({id:f}),h.jsx(ot,{children:o.formatMessage({id:`header_menu_${r[Bn.SITE]?"hide":"show"}`})})]}):o.formatMessage({id:f}),l.order&&h.jsx("ul",{...b,children:l.order.map(C=>{if(!l[C])return null;const _={isLoggedIn:t,isDesktopVersion:n,menus:r,callback:i,doTrack:u?c:null};return l[C].order?h.jsxs("li",{className:ee({[l[C].className]:l[C].className}),children:[o.formatMessage({id:`${f}_${C}`}),h.jsx("ul",{children:l[C].order.map(x=>h.jsx(Vc,{id:`${e}.${C}.${x}`,..._},x))})]},C):h.jsx(Vc,{id:`${e}.${C}`,..._},C)})})]},e)};const bre=({headerIsVisible:e,locale:t})=>{const n=he.useIntl();return h.jsx("div",{id:"language-unavailable-message",className:ee({visible:e}),children:h.jsx("p",{className:"text",children:n.formatMessage({id:`header_language_unavailable_${t}`},{link:r=>h.jsx("a",{href:"/pages/multilingual-transition",children:r})})})})},Tre={colors:{primary:"#4F43BA",primaryHover:"#7C72E1",error:"#C34141",icon:"#000000",text:{primary:"#151921",secondary:"#64748B"},background:{primary:"#FFFFFF",hover:"#F8FAFC"},border:"#E2E8F0"},typography:{fontSizes:{xs:"12px",sm:"14px",md:"16px",lg:"24px"},fontWeights:{medium:"medium",bold:"bold"}},spacing:{xs:"8px",sm:"12px",md:"16px"},borderRadius:{sm:"8px",md:"12px",full:"9999px"},shadows:{sm:"0px 4px 6px rgba(0, 0, 0, 0.1)"},circleSizes:{avatar:"40px",dot:"10px"}},{colors:{primary:ko,primaryHover:_re,error:My,text:oi,background:li,border:Kf,icon:Cre},typography:{fontSizes:ui,fontWeights:pa},spacing:ma,borderRadius:Uu,shadows:Ly,circleSizes:$y}=Tre,xre={bell:{color:Cre},badge:{backgroundColor:My,color:li.primary},header:{container:{backgroundColor:li.primary,borderBottom:`1px solid ${Kf}`},headerText:{color:oi.primary,fontSize:ui.lg,fontWeight:pa.bold},markAllReadText:{color:ko,fontWeight:pa.medium,fontSize:ui.sm}},notificationsContainer:{container:{borderRadius:Uu.md,overflow:"auto",backgroundColor:li.primary,boxShadow:Ly.sm,border:"none"},loader:{color:ko},noNotificationsText:{color:oi.primary,fontSize:ui.md,fontWeight:pa.medium},noNotificationsSubtext:{color:oi.secondary,fontSize:ui.sm}},notification:{unseenDot:{backgroundColor:My,width:$y.dot,height:$y.dot,right:ma.md,top:ma.md},container:{unreadBackgroundColor:li.primary,readBackgroundColor:li.primary,hoverBackgroundColor:li.hover,borderBottom:`1px solid ${Kf}`,padding:ma.md},headerText:{color:oi.primary,fontSize:ui.md,fontWeight:pa.medium},bodyText:{color:oi.primary,fontSize:ui.md},subtext:{color:oi.secondary,fontSize:ui.sm},actions:[{container:{backgroundColor:ko,color:li.primary,borderRadius:Uu.full,padding:`${ma.xs} ${ma.md}`,fontSize:ui.sm,fontWeight:pa.medium,hoverBackgroundColor:_re}},{container:{borderColor:ko,color:oi.secondary,backgroundColor:li.primary,borderRadius:Uu.full,padding:`${ma.xs} ${ma.md}`,fontSize:ui.sm,fontWeight:pa.medium},text:{color:ko}}]},toast:{container:{backgroundColor:li.primary,borderRadius:Uu.sm,boxShadow:Ly.sm,border:`1px solid ${Kf}`},headerText:{color:oi.primary,fontWeight:pa.medium},bodyText:{color:oi.secondary}}};const Gf={height:67,height_desktop:83,additional_message_height:40};var Bn=(e=>(e.NAVIGATION="navigation",e.SEARCH="search",e.ACCOUNT="account-navigation",e.SITE="site-navigation",e))(Bn||{});const T0=({showNavigation:e=!0,showLanguageUnavailableMessage:t=!0,showLanguageSwitcher:n=!0,onLanguageSwitcherClick:r,suprSendWorkspaceKey:i})=>{var H,q;const a=he.useIntl(),s=y.useContext(Mt),o=cp();o&&(As.home.href=o);const l=Yi(!0,!0),u=s&&typeof s.id=="string",c=y.useMemo(()=>bt.getIsDesktopVersion(u,l),[u,l]),d=th("suprsend-notifications")&&i,f=(q=(H=s==null?void 0:s.externalsMetadata)==null?void 0:H.suprsend)==null?void 0:q.subscriberId,p=th("language-switcher")&&n,[g,m]=y.useState(!1);y.useEffect(()=>{t&&p&&(s!=null&&s.id)&&(s==null?void 0:s.locale)!==Ns&&m(!0)},[t,p,s]);const[E,v]=y.useReducer(Us,{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:b,menus:T,focusElements:C}=E,_=y.useRef(E);y.useEffect(()=>{_.current=E},[E]),Xy({scrollPosition:g?Gf[`height${c.navigation?"_desktop":""}`]+Gf.additional_message_height:Gf[`height${c.navigation?"_desktop":""}`],callbacks:{scrollUp:()=>{const N=_.current.menus;!c&&N["site-navigation"]||bt.shouldChangeHeaderIsVisible(!0,N,v)},scrollDown:()=>{const N=_.current.menus;!c&&N["site-navigation"]||bt.shouldChangeHeaderIsVisible(!1,N,v)}}});const x=(N,J,X=!1)=>{bt.handleMenus({id:N,value:J,menus:_.current.menus,dispatch:v,forceHandle:X})},S=y.useRef(null),F=N=>{N.key==="Escape"&&["site-navigation","search","account-navigation"].forEach(J=>{_.current.menus[J]&&x(J,!1,!0)})};y.useEffect(()=>{var N;return(N=document.getElementById("header"))==null||N.addEventListener("keydown",F),()=>{var J;(J=document.getElementById("header"))==null||J.removeEventListener("keydown",F)}},[]),ks(()=>{T["site-navigation"]&&bt.autoFocus({menu:"site-navigation",navigationRef:S,isDesktopVersion:c.navigation,focusElements:C,dispatch:v})},[T["site-navigation"]]),ks(()=>{T["account-navigation"]&&bt.autoFocus({menu:"account-navigation",navigationRef:S,isDesktopVersion:c.navigation,focusElements:C,dispatch:v})},[T["account-navigation"]]);const R=u&&h.jsxs(h.Fragment,{children:[!c.search&&h.jsx("button",{className:"search toggle-search-button",onClick:N=>{N.preventDefault(),N.stopPropagation(),x("search",!T.search)},children:h.jsx(ot,{children:a.formatMessage({id:`header_search_${T.search?"hide":"show"}`})})}),h.jsx(BT,{id:"global-search",handleToggle:{searchIsOpen:T.search,isDesktopVersion:c.search},gtmContext:"search-bar-header",gtmEvent:"form-submission"})]}),L=h.jsx("button",{className:"earth icon language-switcher-button","aria-label":"Language switcher",onClick:N=>{N.preventDefault(),N.stopPropagation(),r?r():m(!g)},children:h.jsx(ot,{children:a.formatMessage({id:"header_language_switcher"})})}),P=[d&&f&&h.jsx("div",{id:"suprsend-notifications",children:h.jsx(yre,{workspaceKey:i,distinctId:(s==null?void 0:s.id)??"",subscriberId:f,theme:xre})})],I=h.jsxs(h.Fragment,{children:[!c.navigation&&h.jsx("button",{className:"menu-button gtm-trackable",onClick:N=>{N.preventDefault(),N.stopPropagation(),x("site-navigation",!T["site-navigation"])},"data-gtm-event-type":"open-tab-menu-click","data-gtm-event-context":"HeaderLeft-Chevron","aria-haspopup":"true","aria-expanded":T["site-navigation"],"aria-controls":"site-navigation",children:h.jsx(ot,{children:a.formatMessage({id:`header_menu_${T["site-navigation"]?"hide":"show"}`})})}),h.jsx("ul",{ref:S,id:"navigation",hidden:c.navigation||T["account-navigation"]?!1:!T["site-navigation"],"data-showing":!c.navigation&&T["account-navigation"]?"account":"default",children:As.order.map(N=>h.jsx(Vc,{id:N,isLoggedIn:u,isDesktopVersion:c.navigation,menus:{"site-navigation":T["site-navigation"],"account-navigation":T["account-navigation"]},callback:x},N))})]}),k=window.location.pathname.match(new RegExp("(courses/[^/]+/[^/]+|microcourses/[^/]+/[^/]+)")),B=N=>{var j;const[J,X]=N.split("?"),D=new URLSearchParams(X||""),Z=new URLSearchParams(window.location.search).get("ref");if(D.set("ref",Z||"course-overview"),window.location.pathname){const z=window.location.pathname.match(new RegExp("(courses/([^/]+)/([^/]+)|microcourses/[^/]+/([^/]+))"));if(z){const[,,U,$,ae]=z;ae?D.set("courseSlug",ae):(D.set("courseSlug",U),D.set("journeySlug",$||"default")),D.set("signupRedirectUrl",window.location.pathname+(window.location.search||""))}}return`${((j=window.location.pathname.match(/^\/([^/]+)/))==null?void 0:j[0])||""}${J}?${D.toString()}`};return s&&s.isLoading?null:h.jsxs(h.Fragment,{children:[h.jsxs("nav",{id:"header",className:ee({"logged-in":u,"logged-out":!u,visible:b}),children:[h.jsx(ot,{element:"a",href:"#content-of-page",children:a.formatMessage({id:"header_skip"})}),h.jsx(dm,{variant:"monochrome"}),e?h.jsxs(h.Fragment,{children:[c.navigation?h.jsxs(h.Fragment,{children:[I,R,p&&L,P]}):h.jsxs(h.Fragment,{children:[R,p&&L,P,I]}),u?h.jsxs("button",{className:"account-button",onClick:N=>bt.events.onClick(N,{id:"account-navigation",callback:x,isOpen:T["account-navigation"]}),onMouseEnter:()=>bt.events.onMouseEnter({id:"account-navigation",callback:x}),onMouseLeave:()=>bt.events.onBlur({id:"account-navigation",callback:x}),"aria-haspopup":"true","aria-expanded":T["account-navigation"],"aria-controls":"account-navigation",children:[h.jsx(ot,{children:a.formatMessage({id:`header_account_${T["account-navigation"]?"hide":"show"}`})}),h.jsx(bi,{name:s&&s.name||"",src:s&&s.image&&s.image.thumbnail||""})]}):h.jsx("ul",{className:"sign-in-buttons",children:As.buttons.order.map(N=>h.jsx(Vc,{id:`buttons.${N}`,getHref:N==="signup"&&k?B:void 0},N))})]}):p&&L]}),g&&h.jsx(bre,{headerIsVisible:b,locale:(s==null?void 0:s.locale)||Ns}),h.jsx("hr",{id:"content-of-page"}),h.jsx("div",{className:ee("overlay",{open:T["site-navigation"]||T["account-navigation"]||!c.search&&T.search})})]})};const wre=()=>{const e=he.useIntl();return h.jsxs(h.Fragment,{children:[h.jsx(T0,{}),h.jsx("div",{id:"content",children:h.jsx(Wr,{variant:"error",text:e.formatMessage({id:"pageLayout_error"})})}),h.jsx(fm,{})]})},w3=({children:e,additionalContent:{prepended:t,appended:n}={},reportError:r,forceShow:i={},styling:a={},className:s="",locale:o="en",suprSendWorkspaceKey:l})=>{const u=he.useIntl(),{navigation:c=!0,footer:d=!0}=i,{background:f="default",variant:p="default",circle:g="default",modal:m="default"}=a,E=Yy(),[v,b]=y.useState(""),T=F=>{const{detail:{message:R}}=F;b(R)};y.useEffect(()=>(window.scrollTo(0,0),document.addEventListener("ariaLive",T),()=>{document.removeEventListener("ariaLive",T)}),[E]);const C=Ku(e,{locale:o}),_=Ku(t,{locale:o}),x=Ku(n,{locale:o}),S={};return f!=="default"&&(S[f]=!0),p!=="default"&&(S[p]=!0),g!=="default"&&(S[g]=!0),h.jsx(K3.ErrorBoundary,{onError:r,fallback:h.jsx(wre,{}),children:h.jsxs(y.Suspense,{fallback:null,children:[h.jsxs("div",{id:"wrapper",className:ee(s,S,{"has-footer":d}),"data-too-small":u.formatMessage({id:"pageLayout_browserTooSmall"}),children:[h.jsx(T0,{suprSendWorkspaceKey:l,showNavigation:c}),h.jsxs("main",{id:"content-wrapper",children:[_&&h.jsx("div",{className:ee("additional-content prepended",{"large-modal":m==="large"}),children:_}),y.createElement(f==="bold"?Cp:"div",{id:"content",children:C,className:ee({"large-modal":m==="large"})})]}),x&&h.jsx("div",{className:"additional-content appended",children:x}),d&&h.jsx(fm,{}),h.jsx(KT,{})]}),v&&h.jsx(ot,{"aria-live":"polite",showOnFocus:!1,"data-testid":"layout-aria-live",children:v})]})})},jy={default:"tags_",headerTopics:"header_topics_topics_"},Yf={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"},Are={getTagDetails:e=>{if(e.includes("topic_")){if(e=Yf.topic[e.replace("topic_","")],e){const t=As.topics.topics[e].href;return t?{id:e,href:t,text:`${jy.headerTopics}${e}`}:null}return null}return Yf[e]?(e=Yf[e],{id:e,text:`${jy.default}${e}`}):null}};const Sre=({tags:e=[],color:t="default",forceOneLine:n=!1,canHaveLinks:r=!0,className:i="",gtmType:a="tag-click",gtmContext:s="tags"})=>{const o=he.useIntl();if(!e||e.length<1)return null;const l=[];return e.forEach(u=>{if(!u)return;const c=Are.getTagDetails(u);c&&l.push(c)}),l.length<1?null:h.jsx("ul",{className:ee("tags text-small",t,i,{"one-line":n}),children:l.map(u=>{const c=o.formatMessage({id:u.text});return h.jsx("li",{children:u.href&&r?h.jsx("a",{href:u.href,className:"gtm-trackable","data-gtm-event-type":a,"data-gtm-event-context":s,children:c}):c},u.id)})})};const A3=25,kre=({members:{data:e=[],total:t=e.length},communitySlug:n,isMember:r=!1,hasNextPage:i=!1,loadNextPage:a=()=>{},profile:s,gtmContext:o="member",gtmType:l="member-click",showHeader:u=!0,showPlaceholders:c=!1,className:d=""})=>{const f=he.useIntl(),p="membersList",g=y.useContext(Mt),[m,E]=y.useState(!1);return e.length===0&&!c?null:h.jsxs("div",{className:ee("members-list",d),children:[u?h.jsxs("h1",{children:[f.formatMessage({id:p}),h.jsx("span",{className:"count",children:t})]}):h.jsx(h.Fragment,{}),h.jsxs("ul",{children:[r?h.jsxs("li",{children:[h.jsx(pi,{member:g,gtmContext:o,gtmType:l,badges:{showBadges:!0,scopes:[{scope:ln.Communities,area:n||""},{scope:ln.Platform,area:"all"}]}}),h.jsx(Qi,{href:"/profiles/me",className:"text-small",onClick:v=>{v==null||v.preventDefault(),v==null||v.stopPropagation(),E(!0)},children:f.formatMessage({id:`${p}_profile`})})]}):h.jsx(h.Fragment,{}),e.map((v,b)=>g&&v.id===g.id?h.jsx(h.Fragment,{}):h.jsxs("li",{children:[h.jsx(pi,{member:v,gtmContext:o,gtmType:l,badges:{showBadges:!0,scopes:[{scope:ln.Communities,area:n||""},{scope:ln.Platform,area:"all"}]}}),v.isAdmin&&h.jsx($r,{children:f.formatMessage({id:`${p}_admin`})})]},b)),c&&e.length===0&&t>0?[...new Array(Math.min(t,A3))].map((v,b)=>h.jsx("li",{children:h.jsx(Jc,{layout:"member"})},b)):h.jsx(h.Fragment,{})]}),i&&h.jsx(xl,{hasNextPage:i,loadNextPage:a,icon:{icon:"arrow-down",position:"right"},messages:{button:f.formatMessage({id:"loadMore_button"}),error:f.formatMessage({id:"loadMore_error"})},gtmContext:o}),s?h.jsx($1,{form:s,showModal:m,content:{title:f.formatMessage({id:`${p}_modal_title`})},functions:{onClose:()=>{E(!1)}}}):h.jsx(h.Fragment,{})]})},S3=kre,Dre=({intlPath:e,showGuidelines:t,type:n,gtmContext:r})=>{const i=he.useIntl();return t?h.jsx("small",{children:vr(i.formatMessage,`${e}explainer`,n,"action",{a:a=>h.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:a})})}):h.jsx(h.Fragment,{})},Ore=({intlPath:e,type:t,...n})=>{const r=he.useIntl();return h.jsx(Ic,{label:{visible:r.formatMessage({id:`${e}label`}),screenreader:vr(r.formatMessage,`${e}label_action`,t,"action")},...n})},Hy=5,Uy=2,Nre=e=>{var r;let t=0;const n=[];return(r=e==null?void 0:e["poll-options"])==null||r.forEach((i,a)=>{i!==""&&(t++,n.push({position:t,description:{en:i}}))}),{title:{en:e.title},options:n,settings:{allow_multiple_votes:e["multiple-answers"]||!1}}};const Ft="discussion_form_",Ml=({id:e,parentId:t,content:n={type:Ke.Response,slugs:{}},userHasPermissions:r=!0,meta:i,placeholder:a,maxLength:s=0,buttons:o,forceShow:l={cancel:!1,error:!1},functions:u,data:c={},gtmContext:d="DiscussionForm"})=>{var ie,me,Oe;const f=he.useIntl(),p=y.useContext(Mt),[g,m]=y.useState(n.type),[E,v]=y.useState(""),{isLoading:b=!1,isInWrapper:T=!1,isInOverlay:C=!1,isAutoFocused:_=!1,isEditing:x=!1,hasTitleField:S=!1,canBePrepopulated:F=!1,isPrepopulated:R=!1,showTitle:L=!1,showGuidelines:P=!0,showDivider:I=!1,showSuccessMessage:k=!0,showPostType:B=!1,postCategories:H=[]}=i||{},{onChange:q=()=>{},create:N=()=>{},createPoll:J=()=>Promise,handleSaveEdit:X=()=>{},handleCancel:D=()=>{},callback:A=()=>{},onMention:Z=()=>{},listMembers:M=()=>Promise.resolve([]),clickMentionFallback:j=()=>{},getLinkPreview:z=()=>Promise.resolve({}),props:U={create:{projectNames:["questions-answers"]}}}=u,[$,ae]=y.useState({body:x&&x.text||R&&R.text||"",data:c!=null&&c.link?{link:c==null?void 0:c.link}:{}}),[Y,te]=y.useState(l.error||!1),se={status:!1,title:S&&S.text||"",polls:0},[re,xe]=y.useState(se);y.useEffect(()=>{F&&!x&&R&&R!==$.body&&ae(ge=>({...ge,body:R.text||""}))},[R]),y.useEffect(()=>{m(n.type)},[n.type]);const ke=rl((ge,Q)=>{ae(_e=>({..._e,body:ge,data:{link:Q}})),q({body:ge});let de;!p||!p.id?de=vr(f.formatMessage,`${Ft}error_loggedOut`,g,"action"):r?s>0&&ge.length>=s&&(de=`${Ft}error_tooLong`):de=vr(f.formatMessage,`${Ft}error_noPermission`,g,"action"),de?te(de):Y&&te(!1)},50);let Te=`${g}-form`;if(g===Ke.Response||g===Ke.Reply){const ge=((ie=n.slugs)==null?void 0:ie.reply)||((me=n.slugs)==null?void 0:me.answer)||((Oe=n.slugs)==null?void 0:Oe.question)||"";ge&&(Te=`${Te}-${ge.slice(-15)}`)}e&&(Te=`${e}-${Te}`);const ue=async ge=>{if(!p||!p.id||!r||ct)throw new Error("You do not have permission to post.");xe(de=>({...de,status:"submitting"}));const Q=window.location.pathname;try{let de;switch(g){case Ke.Post:de=await N({title:ge.title,content:ge.body,categories:ge.postType,data:ge.data});break;case Ke.Poll:de=await J(Nre(ge));break;case Ke.Question:de=await N({title:ge.body,authorId:p&&p.id,data:ge.data,...U==null?void 0:U.create});break;case Ke.Response:de=await N({questionSlug:n.slugs.question},{body:ge.body,authorId:p&&p.id,contentPath:Q,data:ge.data});break;case Ke.Reply:de=await N({questionSlug:n.slugs.question,answerSlug:n.slugs.answer},{body:ge.body,authorId:p&&p.id,contentPath:Q,data:ge.data});break;default:break}await B0(1e3),A&&await A(de),ae({body:"",data:{}}),m(n.type),xe(Fe=>({...Fe,status:"submitted"})),v(vr(f.formatMessage,`${Ft}success`,g,"action"));const _e=new Event(Yt.DISCUSSION_FORM_SUBMITTED);return document.dispatchEvent(_e),await fe(),de}catch(de){const _e=de;let Fe=`${Ft}error`;_e!=null&&_e.message.includes("entry already exists")&&(Fe=vr(f.formatMessage,`${Ft}error_alreadyExists`,g,"action")),_e!=null&&_e.message.includes("429")?Fe=vr(f.formatMessage,`${Ft}error_tooMany`,g,"action"):_e!=null&&_e.message.includes("400")&&(Fe=`${Ft}error`),te(Fe),await fe()}},fe=async()=>{await B0(5e3),te(!1),xe(se),v("")},we=rl(async ge=>{const Q={...$,...ge};if(x){xe(de=>({...de,status:"submitting"})),X(Q);return}try{if(!await ue(Q))throw Error("No response from handleSubmit")}catch{}},100);if(b)return h.jsx(sr,{className:"discussion-card discussion-form","data-testid":"loading-placeholder"});const Ie=!$.body||!sl($.body),Qe=!re.title||!sl(re.title);let ct=!1;g!==Ke.Poll&&(ct=Ie),S&&(ct=ct&&Qe);const We=re.status==="submitting",Xe=[];g===Ke.Poll?Xe.push({id:"poll-options",label:f.formatMessage({id:`${Ft}option_label`}),type:"multiple-inputs",element:"textarea",placeholder:f.formatMessage({id:`${Ft}option_placeholder`}),limit:100,multipleInputs:{showCount:!0,defaultInputs:Uy,maxInputs:Hy,hasButton:{variant:"secondary",size:"small",styling:{muted:!0},icon:"plus",children:f.formatMessage({id:`${Ft}option_cta`})}},styling:{autosizeToFit:!0},functions:{onChange:ge=>{var de;let Q=0;ge&&Array.isArray(ge)&&(Q=((de=ge==null?void 0:ge.filter(_e=>_e!==""))==null?void 0:de.length)||0),re.polls!==Q&&xe(_e=>({..._e,polls:Q})),q({polls:ge})}},validation:[{condition:"required"}]},{type:"checkbox",id:"multiple-answers",label:f.formatMessage({id:`${Ft}multiplePollAnswers`}),className:"text-medium"}):Xe.push({component:Ore,props:{formID:Te,intlPath:Ft,showLabel:S!==!1,type:g}},{component:um,props:{id:`${Te}-input`,value:re.status==="submitting"&&!Y?"":$.body,placeholder:a||vr(f.formatMessage,`${Ft}placeholder`,g,"action"),maxLength:s,meta:{isInOverlay:C},functions:{onChange:ke,onChangeData:ge=>{ae(Q=>({...Q,data:ge}))},onMention:Z,listMembers:M,clickMentionFallback:j,getLinkPreview:z},data:c,autoFocus:x!==!1||_&&!S,"aria-invalid":!!Y,"aria-errormessage":"error-message"}},{component:Dre,props:{intlPath:Ft,showGuidelines:P,type:g,gtmContext:d}}),I&&Xe.push({component:Tr}),S&&Xe.unshift({id:"title",type:"textarea",value:S.text,limit:250,label:f.formatMessage({id:`${Ft}${g===Ke.Poll?"question":"titleField"}_label`}),styling:{autosizeToFit:!0},placeholder:f.formatMessage({id:`${Ft}${g===Ke.Poll?"question":"titleField"}_placeholder`}),functions:{onChange:ge=>{xe(Q=>({...Q,title:ge})),q({title:ge})}},validation:g===Ke.Poll?[{condition:"required"}]:[]}),B&&Xe.unshift({id:"postType",type:"radio",value:"no-category",accessibilityOptions:{checkboxes:{navigateWithArrowKeys:!0}},styling:{displayOptionsAsPills:!0},label:f.formatMessage({id:`${Ft}postType_label`}),options:H.map(ge=>({id:ge.slug,label:ge.name})),validation:[{condition:"required"}],functions:{onChange:ge=>{q({postType:ge}),ge.includes(Ke.Poll)?m(Ke.Poll):g!==Ke.Post&&m(Ke.Post)}}});let Ve=!p||!p.id||!r||We;if(g===Ke.Poll){const ge=re.polls;Ve=Ve||Qe||ge<Uy||ge>Hy}else Ve=Ve||ct,x&&(S?Ve=Ve||$.body===x.text&&re.title===S.text:Ve=Ve||$.body===x.text);return h.jsxs(h.Fragment,{children:[h.jsxs(Cr,{id:Te,className:ee("discussion-card discussion-form",{"no-styling":T&&x}),meta:{shouldReset:!0,shouldHide:!1,showRequiredLabels:!1,shouldShowCancelButton:x&&!We||l.cancel},functions:{onSuccess:async ge=>{await we(ge)},onCancel:D},fields:Xe,intlPath:Ft,button:{variant:"primary",size:{mobile:"small",600:"medium"},"data-gtm-event-context":d,"data-gtm-event-type":`${x?"save":"submit"}-${g}-click`,"data-testid":"save-button",disabled:Ve,text:{default:!x&&(o!=null&&o.submit)?o==null?void 0:o.submit:f.formatMessage({id:`${Ft}${x?"save":"post"}`}),submitting:f.formatMessage({id:`${Ft}${x?"saving":"posting"}`})}},secondaryActionButton:{variant:"secondary",size:{mobile:"small",600:"medium"},"data-gtm-event-context":d,"data-gtm-event-type":`cancel-${g}-click`,disabled:!l.cancel&&(!p||!p.id||!$.body),text:o!=null&&o.cancel?o==null?void 0:o.cancel:f.formatMessage({id:`${Ft}cancel`})},gtm:{context:d,event:`${g}-form`},"data-testid":`discussion-${g}-form`,children:[L&&!x&&g===Ke.Question&&h.jsx("h2",{children:vr(f.formatMessage,`${Ft}title`,g,"action")}),h.jsx(pi,{member:p?{...p,link:!1}:"community",gtmContext:d,gtmType:"profile-click",badges:{showBadges:!0,scopes:[{scope:ln.Communities,area:t||""},{scope:ln.Platform,area:"all"}]}})]}),re.status==="submitted"&&k&&h.jsx(Ds,{className:"success","data-testid":"success",children:vr(f.formatMessage,`${Ft}success`,g,"action")}),Y&&h.jsx(Ds,{id:"error-message",className:"error","data-testid":"error",children:l.error?l.error:typeof Y=="string"?Y.includes(" ")?Y:f.formatMessage({id:Y},{action:f.formatMessage({id:`discussion_action_${g}`}),maxLength:s}):Y}),E&&h.jsx(ot,{"aria-live":"polite",showOnFocus:!1,children:E})]})},Ire=Object.freeze(Object.defineProperty({__proto__:null,default:Ml},Symbol.toStringTag,{value:"Module"})),Pre=280,_0=async(e,t,n,r=()=>Promise.resolve([]))=>{let i=t?Ss(e,typeof t=="number"?t:Pre):e;i=i.trim();const a=`<br>
|
|
570
|
+
`]))),Ere={storeData:{},unseenCount:0,hasNext:!1,initialLoading:!1,fetchMoreLoading:!1};y.createContext({notificationsData:Ere});function yre(e){var t=e.workspaceKey,n=t===void 0?"":t,r=e.tenantId,i=r===void 0?"":r,a=e.distinctId,s=a===void 0?"":a,o=e.subscriberId,l=o===void 0?"":o,u=e.inboxId,c=u===void 0?"":u,d=e.stores,f=e.toastProps,p=e.notificationClickHandler,g=e.primaryActionClickHandler,m=e.secondaryActionClickHandler,E=e.bellComponent,v=e.badgeComponent,b=e.notificationComponent,T=e.noNotificationsComponent,C=e.loaderComponent,_=e.tabBadgeComponent,x=e.headerRightComponent,S=e.hideAvatar,F=S===void 0?!1:S,R=e.hideInbox,L=e.hideToast,P=e.theme,I=e.themeType,k=I===void 0?"light":I,B=e.pagination,H=B===void 0?!0:B,q=e.pageSize,N=e.popperPosition,J=N===void 0?"bottom":N,X=e.showUnreadCountOnTabs,D=X===void 0?!0:X,A=e.host;c&&(l=c);var Z=y.useState(!1),M=Z[0],j=Z[1],z=y.useState(),U=z[0],$=z[1],ae=y.useState({storeData:{},count:0}),Y=ae[0],te=ae[1],se=y.useState(""),re=se[0],xe=se[1],ke=y.useState(!1),Te=ke[0],ue=ke[1];y.useEffect(function(){var we=new iB(n,{pageSize:q,tenantID:i,stores:d,host:A});return $(we),we.emitter.on("sync_notif_store",function(){var Ie=we.feed.data;te({storeData:(Ie==null?void 0:Ie.stores)||{},count:(Ie==null?void 0:Ie.unseenCount)||0,hasNext:Ie==null?void 0:Ie.hasNext,initialLoading:Ie==null?void 0:Ie.initialLoading,activeStoreId:Ie==null?void 0:Ie.activeStoreId}),xe(Ie==null?void 0:Ie.activeStoreId)}),we.emitter.on("new_notification",function(Ie){gre({notificationsData:Ie,toastProps:f})}),function(){we.emitter.all.clear()}},[]),y.useEffect(function(){M&&l&&U&&U.feed.markAllSeen()},[M,l,U]),y.useEffect(function(){if(!(!l||!U))return te({storeData:{},count:0}),U.identifyUser(s,l),U.feed.fetchNotifications(),function(){U.resetUser()}},[l,U]);var fe=k==="dark"?T3(Qte,P):P||{};return y.createElement(y3.Provider,{value:fe},y.createElement(E3.Provider,{value:{workspaceKey:n,notificationsData:Y,setNotificationsData:te,notificationClickHandler:p,primaryActionClickHandler:g,secondaryActionClickHandler:m,bellComponent:E,badgeComponent:v,notificationComponent:b,noNotificationsComponent:T,tabBadgeComponent:_,headerRightComponent:x,toggleInbox:j,inbox:U,loaderComponent:C,pagination:H,hideAvatar:F,activeStore:re,setActiveStore:xe,changingActiveStore:Te,setChangingActiveStore:ue,showUnreadCountOnTabs:D,themeType:k}},!R&&y.createElement(sre,{openInbox:M,toggleInbox:j,popperPosition:J}),!L&&y.createElement(mre,f)))}const bt={timeouts:{},handlerCalled:{},getIsDesktopVersion:(e,t)=>{const n={navigation:{loggedIn:769,loggedOut:881},search:{loggedIn:961,loggedOut:1121}},r=a=>{const s=`logged${e?"In":"Out"}`;return t>=n[a][s]};let i={};return["navigation","search"].forEach(a=>{i[a]=r(a)}),i},shouldChangeHeaderIsVisible:(e,t,n)=>{Object.values(t).filter(i=>i===!0).length||n([{type:"headerIsVisible",value:e}])},handleMenus:({id:e,value:t,menus:n,dispatch:r,forceHandle:i=!1})=>{if(!i&&n[e]===t||!i&&e===Bn.ACCOUNT&&t===!1&&n[Bn.SITE]===!0)return;const a=Date.now();if(!i&&!t&&bt.handlerCalled[e]&&a-bt.handlerCalled[e]<500)return;bt.handlerCalled[e]=a;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 Bn.SITE:o=document.querySelector("#header .menu-button"),o||(o=document.querySelector("#navigation .navigation-button"));break;case Bn.SEARCH:o=document.querySelector("#header .toggle-search-button");break;case Bn.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 i=qy(e[r],t);if(!(typeof i>"u")&&(!n||i[t]&&i[t].includes(n)||i.value&&i.value.includes(n)||i.toString().includes(n)))return e[r]}return e[0].children?bt.findFirstChild(e[0].children,t,n):!1},autoFocus:({menu:e,navigationRef:t,isDesktopVersion:n,focusElements:r,dispatch:i})=>{var l;if(!t.current||!t.current.children)return;const a=n?"desktop":"default";if(r[e][a]){(l=document.querySelector(`#header ul a[href="${r[e][a]}"]:last-child`))==null||l.focus();return}let s,o;switch(e){case Bn.SITE:if(n){const u=bt.findFirstChild(t.current.children,"className","has-submenu parent"),c=bt.findFirstChild(u.children,"id",Bn.SITE);s=bt.findFirstChild(c.children,"href")}else s=bt.findFirstChild(t.current.children,"href");break;case Bn.ACCOUNT:if(o=bt.findFirstChild(t.current.children,"className","account"),!o||!o.children)return;s=bt.findFirstChild(o.children,"href");break;default:return}s&&(i([{type:`focusElements.${e}.${a}`,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(bt.timeouts[t]),n(t,!r))},onFocus:({id:e})=>{clearTimeout(bt.timeouts[e])},onMouseEnter:({id:e,callback:t})=>{clearTimeout(bt.timeouts[e]),t(e,!0)},onBlur:({id:e,callback:t})=>{bt.timeouts[e]=setTimeout(()=>{t(e,!1)},250)}}},As={order:["home","communities","topics","partners","account"],home:{href:"/home/",hasVariantText:!0,gtmType:"homepage-click"},communities:{href:"/communities/",gtmType:"communities-click",onlyShow:"logged-in"},topics:{onlyShow:"logged-in",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:["cities-and-local-government","digital-and-data","education","climate","health-and-social-care","equity-justice-and-inclusion","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:"/logout",className:"divider"}},buttons:{order:["login","signup"],login:{href:"/login",withReturnTo:!0},signup:{href:"/signup?ref=header-banner",props:{variant:"primary"}}}},Vc=({id:e,isLoggedIn:t=!1,isDesktopVersion:n=!1,menus:r={},callback:i=()=>{},doTrack:a=null,getHref:s})=>{const o=he.useIntl(),l=qy(As,e);if(!l||l.onlyShow&&(l.onlyShow==="logged-in"&&!t||l.onlyShow==="logged-out"&&t))return null;const u="doTrack"in l,c=a===null?u?l.doTrack:!0:a,d=e.includes("buttons.");let f=`header_${e.replaceAll(".","_")}`;l.hasVariantText&&(f+=`_logged${t?"In":"Out"}`);let p=!1;if(l.href){let C=l.gtmType||`${e}-click`;if(C.includes(".")){const _=C.split("."),x=_[_.length-2];C=`${x==="topics"?`${x}-`:""}${_[_.length-1]}`}p={href:s?s(l.href):l.withReturnTo?`${l.href}?returnTo=${window.location.pathname+window.location.search}`:l.href},c&&(p={...p,className:"gtm-trackable","data-gtm-event-type":C,"data-gtm-event-context":"HeaderButtons"}),d&&(p={...p,variant:"secondary",size:{mobile:"small",881:"large"},...l.props||{}})}const g=l.order&&l.order[0]&&l[l.order[0]],m=g&&l[l.order[0]].order,E=p&&window.location.pathname===l.href;let v={},b={},T={};if(E&&(v={...v,"aria-current":"page"}),g){const C=l.menuId||e,_={onClick:x=>bt.events.onClick(x,{id:C,callback:i,isOpen:r[C]}),onFocus:()=>bt.events.onFocus({id:C}),onBlur:()=>bt.events.onBlur({id:C,callback:i}),onMouseLeave:()=>bt.events.onBlur({id:C,callback:i}),onMouseEnter:()=>bt.events.onMouseEnter({id:C,callback:i})};b={..._,id:C===Bn.SITE?Bn.SITE:Bn.ACCOUNT},n&&(m&&(T={..._,className:"navigation-button",onKeyPress:x=>{x.key==="Enter"&&bt.events.onClick(x,{id:C,callback:i,isOpen:r[C]})},"aria-haspopup":!0,"aria-expanded":r[C],"aria-controls":C}),b={...b,hidden:C in r?!r[C]:!0}),m||(b={...b})}return h.jsxs("li",{className:ee({[l.className]:l.className,"has-submenu":g,parent:m,active:E}),...v,children:[p?y.createElement(d?Me:"a",p,o.formatMessage({id:f})):n&&l.order&&m?h.jsxs("button",{...T,children:[o.formatMessage({id:f}),h.jsx(ot,{children:o.formatMessage({id:`header_menu_${r[Bn.SITE]?"hide":"show"}`})})]}):o.formatMessage({id:f}),l.order&&h.jsx("ul",{...b,children:l.order.map(C=>{if(!l[C])return null;const _={isLoggedIn:t,isDesktopVersion:n,menus:r,callback:i,doTrack:u?c:null};return l[C].order?h.jsxs("li",{className:ee({[l[C].className]:l[C].className}),children:[o.formatMessage({id:`${f}_${C}`}),h.jsx("ul",{children:l[C].order.map(x=>h.jsx(Vc,{id:`${e}.${C}.${x}`,..._},x))})]},C):h.jsx(Vc,{id:`${e}.${C}`,..._},C)})})]},e)};const bre=({headerIsVisible:e,locale:t})=>{const n=he.useIntl();return h.jsx("div",{id:"language-unavailable-message",className:ee({visible:e}),children:h.jsx("p",{className:"text",children:n.formatMessage({id:`header_language_unavailable_${t}`},{link:r=>h.jsx("a",{href:"/pages/multilingual-transition",children:r})})})})},Tre={colors:{primary:"#4F43BA",primaryHover:"#7C72E1",error:"#C34141",icon:"#000000",text:{primary:"#151921",secondary:"#64748B"},background:{primary:"#FFFFFF",hover:"#F8FAFC"},border:"#E2E8F0"},typography:{fontSizes:{xs:"12px",sm:"14px",md:"16px",lg:"24px"},fontWeights:{medium:"medium",bold:"bold"}},spacing:{xs:"8px",sm:"12px",md:"16px"},borderRadius:{sm:"8px",md:"12px",full:"9999px"},shadows:{sm:"0px 4px 6px rgba(0, 0, 0, 0.1)"},circleSizes:{avatar:"40px",dot:"10px"}},{colors:{primary:ko,primaryHover:_re,error:My,text:oi,background:li,border:Kf,icon:Cre},typography:{fontSizes:ui,fontWeights:pa},spacing:ma,borderRadius:Uu,shadows:Ly,circleSizes:$y}=Tre,xre={bell:{color:Cre},badge:{backgroundColor:My,color:li.primary},header:{container:{backgroundColor:li.primary,borderBottom:`1px solid ${Kf}`},headerText:{color:oi.primary,fontSize:ui.lg,fontWeight:pa.bold},markAllReadText:{color:ko,fontWeight:pa.medium,fontSize:ui.sm}},notificationsContainer:{container:{borderRadius:Uu.md,overflow:"auto",backgroundColor:li.primary,boxShadow:Ly.sm,border:"none"},loader:{color:ko},noNotificationsText:{color:oi.primary,fontSize:ui.md,fontWeight:pa.medium},noNotificationsSubtext:{color:oi.secondary,fontSize:ui.sm}},notification:{unseenDot:{backgroundColor:My,width:$y.dot,height:$y.dot,right:ma.md,top:ma.md},container:{unreadBackgroundColor:li.primary,readBackgroundColor:li.primary,hoverBackgroundColor:li.hover,borderBottom:`1px solid ${Kf}`,padding:ma.md},headerText:{color:oi.primary,fontSize:ui.md,fontWeight:pa.medium},bodyText:{color:oi.primary,fontSize:ui.md},subtext:{color:oi.secondary,fontSize:ui.sm},actions:[{container:{backgroundColor:ko,color:li.primary,borderRadius:Uu.full,padding:`${ma.xs} ${ma.md}`,fontSize:ui.sm,fontWeight:pa.medium,hoverBackgroundColor:_re}},{container:{borderColor:ko,color:oi.secondary,backgroundColor:li.primary,borderRadius:Uu.full,padding:`${ma.xs} ${ma.md}`,fontSize:ui.sm,fontWeight:pa.medium},text:{color:ko}}]},toast:{container:{backgroundColor:li.primary,borderRadius:Uu.sm,boxShadow:Ly.sm,border:`1px solid ${Kf}`},headerText:{color:oi.primary,fontWeight:pa.medium},bodyText:{color:oi.secondary}}};const Gf={height:67,height_desktop:83,additional_message_height:40};var Bn=(e=>(e.NAVIGATION="navigation",e.SEARCH="search",e.ACCOUNT="account-navigation",e.SITE="site-navigation",e))(Bn||{});const T0=({showNavigation:e=!0,showLanguageUnavailableMessage:t=!0,showLanguageSwitcher:n=!0,onLanguageSwitcherClick:r,suprSendWorkspaceKey:i})=>{var H,q;const a=he.useIntl(),s=y.useContext(Mt),o=cp();o&&(As.home.href=o);const l=Yi(!0,!0),u=s&&typeof s.id=="string",c=y.useMemo(()=>bt.getIsDesktopVersion(u,l),[u,l]),d=th("suprsend-notifications")&&i,f=(q=(H=s==null?void 0:s.externalsMetadata)==null?void 0:H.suprsend)==null?void 0:q.subscriberId,p=th("language-switcher")&&n,[g,m]=y.useState(!1);y.useEffect(()=>{t&&p&&(s!=null&&s.id)&&(s==null?void 0:s.locale)!==Ns&&m(!0)},[t,p,s]);const[E,v]=y.useReducer(Us,{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:b,menus:T,focusElements:C}=E,_=y.useRef(E);y.useEffect(()=>{_.current=E},[E]),Xy({scrollPosition:g?Gf[`height${c.navigation?"_desktop":""}`]+Gf.additional_message_height:Gf[`height${c.navigation?"_desktop":""}`],callbacks:{scrollUp:()=>{const N=_.current.menus;!c&&N["site-navigation"]||bt.shouldChangeHeaderIsVisible(!0,N,v)},scrollDown:()=>{const N=_.current.menus;!c&&N["site-navigation"]||bt.shouldChangeHeaderIsVisible(!1,N,v)}}});const x=(N,J,X=!1)=>{bt.handleMenus({id:N,value:J,menus:_.current.menus,dispatch:v,forceHandle:X})},S=y.useRef(null),F=N=>{N.key==="Escape"&&["site-navigation","search","account-navigation"].forEach(J=>{_.current.menus[J]&&x(J,!1,!0)})};y.useEffect(()=>{var N;return(N=document.getElementById("header"))==null||N.addEventListener("keydown",F),()=>{var J;(J=document.getElementById("header"))==null||J.removeEventListener("keydown",F)}},[]),ks(()=>{T["site-navigation"]&&bt.autoFocus({menu:"site-navigation",navigationRef:S,isDesktopVersion:c.navigation,focusElements:C,dispatch:v})},[T["site-navigation"]]),ks(()=>{T["account-navigation"]&&bt.autoFocus({menu:"account-navigation",navigationRef:S,isDesktopVersion:c.navigation,focusElements:C,dispatch:v})},[T["account-navigation"]]);const R=u&&h.jsxs(h.Fragment,{children:[!c.search&&h.jsx("button",{className:"search toggle-search-button",onClick:N=>{N.preventDefault(),N.stopPropagation(),x("search",!T.search)},children:h.jsx(ot,{children:a.formatMessage({id:`header_search_${T.search?"hide":"show"}`})})}),h.jsx(BT,{id:"global-search",handleToggle:{searchIsOpen:T.search,isDesktopVersion:c.search},gtmContext:"search-bar-header",gtmEvent:"form-submission"})]}),L=h.jsx("button",{className:"earth icon language-switcher-button","aria-label":"Language switcher",onClick:N=>{N.preventDefault(),N.stopPropagation(),r?r():m(!g)},children:h.jsx(ot,{children:a.formatMessage({id:"header_language_switcher"})})}),P=[d&&f&&h.jsx("div",{id:"suprsend-notifications",children:h.jsx(yre,{workspaceKey:i,distinctId:(s==null?void 0:s.id)??"",subscriberId:f,theme:xre})})],I=h.jsxs(h.Fragment,{children:[!c.navigation&&h.jsx("button",{className:"menu-button gtm-trackable",onClick:N=>{N.preventDefault(),N.stopPropagation(),x("site-navigation",!T["site-navigation"])},"data-gtm-event-type":"open-tab-menu-click","data-gtm-event-context":"HeaderLeft-Chevron","aria-haspopup":"true","aria-expanded":T["site-navigation"],"aria-controls":"site-navigation",children:h.jsx(ot,{children:a.formatMessage({id:`header_menu_${T["site-navigation"]?"hide":"show"}`})})}),h.jsx("ul",{ref:S,id:"navigation",hidden:c.navigation||T["account-navigation"]?!1:!T["site-navigation"],"data-showing":!c.navigation&&T["account-navigation"]?"account":"default",children:As.order.map(N=>h.jsx(Vc,{id:N,isLoggedIn:u,isDesktopVersion:c.navigation,menus:{"site-navigation":T["site-navigation"],"account-navigation":T["account-navigation"]},callback:x},N))})]}),k=window.location.pathname.match(new RegExp("(courses/[^/]+/[^/]+|microcourses/[^/]+/[^/]+)")),B=N=>{var j;const[J,X]=N.split("?"),D=new URLSearchParams(X||""),Z=new URLSearchParams(window.location.search).get("ref");if(D.set("ref",Z||"course-overview"),window.location.pathname){const z=window.location.pathname.match(new RegExp("(courses/([^/]+)/([^/]+)|microcourses/[^/]+/([^/]+))"));if(z){const[,,U,$,ae]=z;ae?D.set("courseSlug",ae):(D.set("courseSlug",U),D.set("journeySlug",$||"default")),D.set("signupRedirectUrl",window.location.pathname+(window.location.search||""))}}return`${((j=window.location.pathname.match(/^\/([^/]+)/))==null?void 0:j[0])||""}${J}?${D.toString()}`};return s&&s.isLoading?null:h.jsxs(h.Fragment,{children:[h.jsxs("nav",{id:"header",className:ee({"logged-in":u,"logged-out":!u,visible:b}),children:[h.jsx(ot,{element:"a",href:"#content-of-page",children:a.formatMessage({id:"header_skip"})}),h.jsx(dm,{variant:"monochrome"}),e?h.jsxs(h.Fragment,{children:[c.navigation?h.jsxs(h.Fragment,{children:[I,R,p&&L,P]}):h.jsxs(h.Fragment,{children:[R,p&&L,P,I]}),u?h.jsxs("button",{className:"account-button",onClick:N=>bt.events.onClick(N,{id:"account-navigation",callback:x,isOpen:T["account-navigation"]}),onMouseEnter:()=>bt.events.onMouseEnter({id:"account-navigation",callback:x}),onMouseLeave:()=>bt.events.onBlur({id:"account-navigation",callback:x}),"aria-haspopup":"true","aria-expanded":T["account-navigation"],"aria-controls":"account-navigation",children:[h.jsx(ot,{children:a.formatMessage({id:`header_account_${T["account-navigation"]?"hide":"show"}`})}),h.jsx(bi,{name:s&&s.name||"",src:s&&s.image&&s.image.thumbnail||""})]}):h.jsx("ul",{className:"sign-in-buttons",children:As.buttons.order.map(N=>h.jsx(Vc,{id:`buttons.${N}`,getHref:N==="signup"&&k?B:void 0},N))})]}):p&&L]}),g&&h.jsx(bre,{headerIsVisible:b,locale:(s==null?void 0:s.locale)||Ns}),h.jsx("hr",{id:"content-of-page"}),h.jsx("div",{className:ee("overlay",{open:T["site-navigation"]||T["account-navigation"]||!c.search&&T.search})})]})};const wre=()=>{const e=he.useIntl();return h.jsxs(h.Fragment,{children:[h.jsx(T0,{}),h.jsx("div",{id:"content",children:h.jsx(Wr,{variant:"error",text:e.formatMessage({id:"pageLayout_error"})})}),h.jsx(fm,{})]})},w3=({children:e,additionalContent:{prepended:t,appended:n}={},reportError:r,forceShow:i={},styling:a={},className:s="",locale:o="en",suprSendWorkspaceKey:l})=>{const u=he.useIntl(),{navigation:c=!0,footer:d=!0}=i,{background:f="default",variant:p="default",circle:g="default",modal:m="default"}=a,E=Yy(),[v,b]=y.useState(""),T=F=>{const{detail:{message:R}}=F;b(R)};y.useEffect(()=>(window.scrollTo(0,0),document.addEventListener("ariaLive",T),()=>{document.removeEventListener("ariaLive",T)}),[E]);const C=Ku(e,{locale:o}),_=Ku(t,{locale:o}),x=Ku(n,{locale:o}),S={};return f!=="default"&&(S[f]=!0),p!=="default"&&(S[p]=!0),g!=="default"&&(S[g]=!0),h.jsx(K3.ErrorBoundary,{onError:r,fallback:h.jsx(wre,{}),children:h.jsxs(y.Suspense,{fallback:null,children:[h.jsxs("div",{id:"wrapper",className:ee(s,S,{"has-footer":d}),"data-too-small":u.formatMessage({id:"pageLayout_browserTooSmall"}),children:[h.jsx(T0,{suprSendWorkspaceKey:l,showNavigation:c}),h.jsxs("main",{id:"content-wrapper",children:[_&&h.jsx("div",{className:ee("additional-content prepended",{"large-modal":m==="large"}),children:_}),y.createElement(f==="bold"?Cp:"div",{id:"content",children:C,className:ee({"large-modal":m==="large"})})]}),x&&h.jsx("div",{className:"additional-content appended",children:x}),d&&h.jsx(fm,{}),h.jsx(KT,{})]}),v&&h.jsx(ot,{"aria-live":"polite",showOnFocus:!1,"data-testid":"layout-aria-live",children:v})]})})},jy={default:"tags_",headerTopics:"header_topics_topics_"},Yf={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"},Are={getTagDetails:e=>{if(e.includes("topic_")){if(e=Yf.topic[e.replace("topic_","")],e){const t=As.topics.topics[e].href;return t?{id:e,href:t,text:`${jy.headerTopics}${e}`}:null}return null}return Yf[e]?(e=Yf[e],{id:e,text:`${jy.default}${e}`}):null}};const Sre=({tags:e=[],color:t="default",forceOneLine:n=!1,canHaveLinks:r=!0,className:i="",gtmType:a="tag-click",gtmContext:s="tags"})=>{const o=he.useIntl();if(!e||e.length<1)return null;const l=[];return e.forEach(u=>{if(!u)return;const c=Are.getTagDetails(u);c&&l.push(c)}),l.length<1?null:h.jsx("ul",{className:ee("tags text-small",t,i,{"one-line":n}),children:l.map(u=>{const c=o.formatMessage({id:u.text});return h.jsx("li",{children:u.href&&r?h.jsx("a",{href:u.href,className:"gtm-trackable","data-gtm-event-type":a,"data-gtm-event-context":s,children:c}):c},u.id)})})};const A3=25,kre=({members:{data:e=[],total:t=e.length},communitySlug:n,isMember:r=!1,hasNextPage:i=!1,loadNextPage:a=()=>{},profile:s,gtmContext:o="member",gtmType:l="member-click",showHeader:u=!0,showPlaceholders:c=!1,className:d=""})=>{const f=he.useIntl(),p="membersList",g=y.useContext(Mt),[m,E]=y.useState(!1);return e.length===0&&!c?null:h.jsxs("div",{className:ee("members-list",d),children:[u?h.jsxs("h1",{children:[f.formatMessage({id:p}),h.jsx("span",{className:"count",children:t})]}):h.jsx(h.Fragment,{}),h.jsxs("ul",{children:[r?h.jsxs("li",{children:[h.jsx(pi,{member:g,gtmContext:o,gtmType:l,badges:{showBadges:!0,scopes:[{scope:ln.Communities,area:n||""},{scope:ln.Platform,area:"all"}]}}),h.jsx(Qi,{href:"/profiles/me",className:"text-small",onClick:v=>{v==null||v.preventDefault(),v==null||v.stopPropagation(),E(!0)},children:f.formatMessage({id:`${p}_profile`})})]}):h.jsx(h.Fragment,{}),e.map((v,b)=>g&&v.id===g.id?h.jsx(h.Fragment,{}):h.jsxs("li",{children:[h.jsx(pi,{member:v,gtmContext:o,gtmType:l,badges:{showBadges:!0,scopes:[{scope:ln.Communities,area:n||""},{scope:ln.Platform,area:"all"}]}}),v.isAdmin&&h.jsx($r,{children:f.formatMessage({id:`${p}_admin`})})]},b)),c&&e.length===0&&t>0?[...new Array(Math.min(t,A3))].map((v,b)=>h.jsx("li",{children:h.jsx(Jc,{layout:"member"})},b)):h.jsx(h.Fragment,{})]}),i&&h.jsx(xl,{hasNextPage:i,loadNextPage:a,icon:{icon:"arrow-down",position:"right"},messages:{button:f.formatMessage({id:"loadMore_button"}),error:f.formatMessage({id:"loadMore_error"})},gtmContext:o}),s?h.jsx($1,{form:s,showModal:m,content:{title:f.formatMessage({id:`${p}_modal_title`})},functions:{onClose:()=>{E(!1)}}}):h.jsx(h.Fragment,{})]})},S3=kre,Dre=({intlPath:e,showGuidelines:t,type:n,gtmContext:r})=>{const i=he.useIntl();return t?h.jsx("small",{children:vr(i.formatMessage,`${e}explainer`,n,"action",{a:a=>h.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:a})})}):h.jsx(h.Fragment,{})},Ore=({intlPath:e,type:t,...n})=>{const r=he.useIntl();return h.jsx(Ic,{label:{visible:r.formatMessage({id:`${e}label`}),screenreader:vr(r.formatMessage,`${e}label_action`,t,"action")},...n})},Hy=5,Uy=2,Nre=e=>{var r;let t=0;const n=[];return(r=e==null?void 0:e["poll-options"])==null||r.forEach((i,a)=>{i!==""&&(t++,n.push({position:t,description:{en:i}}))}),{title:{en:e.title},options:n,settings:{allow_multiple_votes:e["multiple-answers"]||!1}}};const Ft="discussion_form_",Ml=({id:e,parentId:t,content:n={type:Ke.Response,slugs:{}},userHasPermissions:r=!0,meta:i,placeholder:a,maxLength:s=0,buttons:o,forceShow:l={cancel:!1,error:!1},functions:u,data:c={},gtmContext:d="DiscussionForm"})=>{var ie,me,Oe;const f=he.useIntl(),p=y.useContext(Mt),[g,m]=y.useState(n.type),[E,v]=y.useState(""),{isLoading:b=!1,isInWrapper:T=!1,isInOverlay:C=!1,isAutoFocused:_=!1,isEditing:x=!1,hasTitleField:S=!1,canBePrepopulated:F=!1,isPrepopulated:R=!1,showTitle:L=!1,showGuidelines:P=!0,showDivider:I=!1,showSuccessMessage:k=!0,showPostType:B=!1,postCategories:H=[]}=i||{},{onChange:q=()=>{},create:N=()=>{},createPoll:J=()=>Promise,handleSaveEdit:X=()=>{},handleCancel:D=()=>{},callback:A=()=>{},onMention:Z=()=>{},listMembers:M=()=>Promise.resolve([]),clickMentionFallback:j=()=>{},getLinkPreview:z=()=>Promise.resolve({}),props:U={create:{projectNames:["questions-answers"]}}}=u,[$,ae]=y.useState({body:x&&x.text||R&&R.text||"",data:c!=null&&c.link?{link:c==null?void 0:c.link}:{}}),[Y,te]=y.useState(l.error||!1),se={status:!1,title:S&&S.text||"",polls:0},[re,xe]=y.useState(se);y.useEffect(()=>{F&&!x&&R&&R!==$.body&&ae(ge=>({...ge,body:R.text||""}))},[R]),y.useEffect(()=>{m(n.type)},[n.type]);const ke=rl((ge,Q)=>{ae(_e=>({..._e,body:ge,data:{link:Q}})),q({body:ge});let de;!p||!p.id?de=vr(f.formatMessage,`${Ft}error_loggedOut`,g,"action"):r?s>0&&ge.length>=s&&(de=`${Ft}error_tooLong`):de=vr(f.formatMessage,`${Ft}error_noPermission`,g,"action"),de?te(de):Y&&te(!1)},50);let Te=`${g}-form`;if(g===Ke.Response||g===Ke.Reply){const ge=((ie=n.slugs)==null?void 0:ie.reply)||((me=n.slugs)==null?void 0:me.answer)||((Oe=n.slugs)==null?void 0:Oe.question)||"";ge&&(Te=`${Te}-${ge.slice(-15)}`)}e&&(Te=`${e}-${Te}`);const ue=async ge=>{if(!p||!p.id||!r||ct)throw new Error("You do not have permission to post.");xe(de=>({...de,status:"submitting"}));const Q=window.location.pathname;try{let de;switch(g){case Ke.Post:de=await N({title:ge.title,content:ge.body,categories:ge.postType,data:ge.data});break;case Ke.Poll:de=await J(Nre(ge));break;case Ke.Question:de=await N({title:ge.body,authorId:p&&p.id,data:ge.data,...U==null?void 0:U.create});break;case Ke.Response:de=await N({questionSlug:n.slugs.question},{body:ge.body,authorId:p&&p.id,contentPath:Q,data:ge.data});break;case Ke.Reply:de=await N({questionSlug:n.slugs.question,answerSlug:n.slugs.answer},{body:ge.body,authorId:p&&p.id,contentPath:Q,data:ge.data});break;default:break}await B0(1e3),A&&await A(de),ae({body:"",data:{}}),m(n.type),xe(Fe=>({...Fe,status:"submitted"})),v(vr(f.formatMessage,`${Ft}success`,g,"action"));const _e=new Event(Yt.DISCUSSION_FORM_SUBMITTED);return document.dispatchEvent(_e),await fe(),de}catch(de){const _e=de;let Fe=`${Ft}error`;_e!=null&&_e.message.includes("entry already exists")&&(Fe=vr(f.formatMessage,`${Ft}error_alreadyExists`,g,"action")),_e!=null&&_e.message.includes("429")?Fe=vr(f.formatMessage,`${Ft}error_tooMany`,g,"action"):_e!=null&&_e.message.includes("400")&&(Fe=`${Ft}error`),te(Fe),await fe()}},fe=async()=>{await B0(5e3),te(!1),xe(se),v("")},we=rl(async ge=>{const Q={...$,...ge};if(x){xe(de=>({...de,status:"submitting"})),X(Q);return}try{if(!await ue(Q))throw Error("No response from handleSubmit")}catch{}},100);if(b)return h.jsx(sr,{className:"discussion-card discussion-form","data-testid":"loading-placeholder"});const Ie=!$.body||!sl($.body),Qe=!re.title||!sl(re.title);let ct=!1;g!==Ke.Poll&&(ct=Ie),S&&(ct=ct&&Qe);const We=re.status==="submitting",Xe=[];g===Ke.Poll?Xe.push({id:"poll-options",label:f.formatMessage({id:`${Ft}option_label`}),type:"multiple-inputs",element:"textarea",placeholder:f.formatMessage({id:`${Ft}option_placeholder`}),limit:100,multipleInputs:{showCount:!0,defaultInputs:Uy,maxInputs:Hy,hasButton:{variant:"secondary",size:"small",styling:{muted:!0},icon:"plus",children:f.formatMessage({id:`${Ft}option_cta`})}},styling:{autosizeToFit:!0},functions:{onChange:ge=>{var de;let Q=0;ge&&Array.isArray(ge)&&(Q=((de=ge==null?void 0:ge.filter(_e=>_e!==""))==null?void 0:de.length)||0),re.polls!==Q&&xe(_e=>({..._e,polls:Q})),q({polls:ge})}},validation:[{condition:"required"}]},{type:"checkbox",id:"multiple-answers",label:f.formatMessage({id:`${Ft}multiplePollAnswers`}),className:"text-medium"}):Xe.push({component:Ore,props:{formID:Te,intlPath:Ft,showLabel:S!==!1,type:g}},{component:um,props:{id:`${Te}-input`,value:re.status==="submitting"&&!Y?"":$.body,placeholder:a||vr(f.formatMessage,`${Ft}placeholder`,g,"action"),maxLength:s,meta:{isInOverlay:C},functions:{onChange:ke,onChangeData:ge=>{ae(Q=>({...Q,data:ge}))},onMention:Z,listMembers:M,clickMentionFallback:j,getLinkPreview:z},data:c,autoFocus:x!==!1||_&&!S,"aria-invalid":!!Y,"aria-errormessage":"error-message"}},{component:Dre,props:{intlPath:Ft,showGuidelines:P,type:g,gtmContext:d}}),I&&Xe.push({component:Tr}),S&&Xe.unshift({id:"title",type:"textarea",value:S.text,limit:250,label:f.formatMessage({id:`${Ft}${g===Ke.Poll?"question":"titleField"}_label`}),styling:{autosizeToFit:!0},placeholder:f.formatMessage({id:`${Ft}${g===Ke.Poll?"question":"titleField"}_placeholder`}),functions:{onChange:ge=>{xe(Q=>({...Q,title:ge})),q({title:ge})}},validation:g===Ke.Poll?[{condition:"required"}]:[]}),B&&Xe.unshift({id:"postType",type:"radio",value:"no-category",accessibilityOptions:{checkboxes:{navigateWithArrowKeys:!0}},styling:{displayOptionsAsPills:!0},label:f.formatMessage({id:`${Ft}postType_label`}),options:H.map(ge=>({id:ge.slug,label:ge.name})),validation:[{condition:"required"}],functions:{onChange:ge=>{q({postType:ge}),ge.includes(Ke.Poll)?m(Ke.Poll):g!==Ke.Post&&m(Ke.Post)}}});let Ve=!p||!p.id||!r||We;if(g===Ke.Poll){const ge=re.polls;Ve=Ve||Qe||ge<Uy||ge>Hy}else Ve=Ve||ct,x&&(S?Ve=Ve||$.body===x.text&&re.title===S.text:Ve=Ve||$.body===x.text);return h.jsxs(h.Fragment,{children:[h.jsxs(Cr,{id:Te,className:ee("discussion-card discussion-form",{"no-styling":T&&x}),meta:{shouldReset:!0,shouldHide:!1,showRequiredLabels:!1,shouldShowCancelButton:x&&!We||l.cancel},functions:{onSuccess:async ge=>{await we(ge)},onCancel:D},fields:Xe,intlPath:Ft,button:{variant:"primary",size:{mobile:"small",600:"medium"},"data-gtm-event-context":d,"data-gtm-event-type":`${x?"save":"submit"}-${g}-click`,"data-testid":"save-button",disabled:Ve,text:{default:!x&&(o!=null&&o.submit)?o==null?void 0:o.submit:f.formatMessage({id:`${Ft}${x?"save":"post"}`}),submitting:f.formatMessage({id:`${Ft}${x?"saving":"posting"}`})}},secondaryActionButton:{variant:"secondary",size:{mobile:"small",600:"medium"},"data-gtm-event-context":d,"data-gtm-event-type":`cancel-${g}-click`,disabled:!l.cancel&&(!p||!p.id||!$.body),text:o!=null&&o.cancel?o==null?void 0:o.cancel:f.formatMessage({id:`${Ft}cancel`})},gtm:{context:d,event:`${g}-form`},"data-testid":`discussion-${g}-form`,children:[L&&!x&&g===Ke.Question&&h.jsx("h2",{children:vr(f.formatMessage,`${Ft}title`,g,"action")}),h.jsx(pi,{member:p?{...p,link:!1}:"community",gtmContext:d,gtmType:"profile-click",badges:{showBadges:!0,scopes:[{scope:ln.Communities,area:t||""},{scope:ln.Platform,area:"all"}]}})]}),re.status==="submitted"&&k&&h.jsx(Ds,{className:"success","data-testid":"success",children:vr(f.formatMessage,`${Ft}success`,g,"action")}),Y&&h.jsx(Ds,{id:"error-message",className:"error","data-testid":"error",children:l.error?l.error:typeof Y=="string"?Y.includes(" ")?Y:f.formatMessage({id:Y},{action:f.formatMessage({id:`discussion_action_${g}`}),maxLength:s}):Y}),E&&h.jsx(ot,{"aria-live":"polite",showOnFocus:!1,children:E})]})},Ire=Object.freeze(Object.defineProperty({__proto__:null,default:Ml},Symbol.toStringTag,{value:"Module"})),Pre=280,_0=async(e,t,n,r=()=>Promise.resolve([]))=>{let i=t?Ss(e,typeof t=="number"?t:Pre):e;i=i.trim();const a=`<br>
|
|
571
571
|
|
|
572
572
|
`;return i.slice(0,a.length)===a&&(i=i.slice(a.length)),n?await l4({text:i,template:"[@{{name}}](/profiles/{{id}})",mentions:n,listMembers:r}):i},C0=(e,t)=>t.length===0||e.length===0?[]:e.map(n=>t.find(r=>r.slug===n)).filter(n=>n!==void 0),Rre=(e,t,n)=>{let r=!1;function i(a){let s=30;for(;a||s<=0;){if(t.some(o=>Array.from(a==null?void 0:a.classList).includes(o))){r=!0;break}if(Array.from(a==null?void 0:a.classList).includes(n))break;a=a.parentElement,s--}}return i(e.target),r},Fre=(e,t)=>e?typeof e=="string"?e:e[t]:"";const Bre={showForm:!1},L1=y.createContext(Bre),k3=({children:e})=>{const[t,n]=y.useState({showForm:!1});return h.jsx(L1.Provider,{value:{...t,updateConversation:n},children:e})};function Mre({author:e,originalAuthorId:t,createdAt:n,contentData:r,content:i,gtmContext:a,badges:s}){var d;const o="discussion_",l=he.useIntl(),u=(d=i==null?void 0:i.componentProps)==null?void 0:d.member.additionalContent,c=u?u.customMessage:void 0;return h.jsxs("div",{className:"author-section",children:[h.jsx(pi,{member:e,additionalContent:{createdAt:n,didEdit:r.didEdit,customMessage:c},className:ee({highlighted:typeof e!="string"&&e.id===t}),styling:{additionalContentNewLine:!!c},gtmContext:a,gtmType:"profile-click",badges:s}),i.pinned&&h.jsx($r,{variant:"naked",size:"xlarge",icon:"pin",children:h.jsx(ot,{children:l.formatMessage({id:`${o}pinned_post`})})})]})}const Zf=({children:e,class:t,...n})=>{const r={...n,class:ee("subtle",t)};return h.jsx("blockquote",{...r,children:e})};function Lre({content:e}){var t;return!e||!((t=e.categories)!=null&&t.length)?h.jsx(h.Fragment,{}):h.jsx("ul",{className:"categories-list",children:e.categories.map(n=>!n.slug||!n.name?h.jsx(h.Fragment,{}):h.jsx($r,{size:"small",element:"li",children:n.name},n.slug))})}var Kc=(e=>(e.Always="always",e.AfterVoting="after-voting",e))(Kc||{});const $re=(e,t,n)=>n===void 0?0:e.some(i=>i.hasUserVoted)?t?e.findIndex(i=>!i.hasUserVoted):e.findIndex(i=>i.hasUserVoted):0,jre=(e,t,n,r=0)=>{if(!e)return{nextElement:null,nextIndex:0};let i=n==="next"?e.nextElementSibling:e.previousElementSibling,a=r+(n==="next"?1:-1);for(;i;){if(!i.classList.contains(t))return{nextElement:i,nextIndex:a};i=n==="next"?i.nextElementSibling:i.previousElementSibling,a=a+(n==="next"?1:-1)}const s=e.parentElement;if(s)for(i=n==="next"?s.firstElementChild:s.lastElementChild,a=n==="next"?0:s.childElementCount-1;i&&i!==e;){if(!i.classList.contains(t))return{nextElement:i,nextIndex:a};i=n==="next"?i.nextElementSibling:i.previousElementSibling,a=a+(n==="next"?1:-1)}return{nextElement:null,nextIndex:0}};const Hre=({user:e,option:t,optionIndex:n,totalPollVotes:r=0,allowMultipleVotes:i=!1,showResults:a=!1,hasVotedOnPoll:s=!1,isTabbable:o=!1,functions:l})=>{var E;const[u,c]=y.useState(t.hasUserVoted);let d=0,f={};const p=(i||!s)&&!t.hasUserVoted;a&&(d=Math.round(t.numVotes/r*100)||0,f={"--vote-perc":`${d}%`});const g=v=>{v.stopPropagation(),p&&(l==null||l.createVote(t),c(!0))},m={htmlFor:t.id,className:ee({"can-vote":p}),tabIndex:o&&p?0:-1,"data-testid":"poll-option-label","data-gtm-event-type":"poll-option-click","data-gtm-event-context":"PollOption","aria-selected":t.hasUserVoted,onClick:g,onKeyDown:v=>{var b;if(v.code!=="Tab")switch(v.code){case"Enter":case"Space":v.preventDefault(),v.stopPropagation(),g(v),c(!0);break;case"ArrowUp":case"ArrowDown":v.stopPropagation(),v.preventDefault();const T=v.code==="ArrowUp"?"prev":"next",{nextElement:C,nextIndex:_}=jre(v.currentTarget.parentElement,"selected",T,n);C&&((b=C.querySelector("label"))==null||b.focus(),l==null||l.setTabbableOption(_));break}}};return h.jsxs("li",{"data-testid":"poll-option",style:f,className:ee("poll-option text-small",{selected:t.hasUserVoted}),children:[h.jsx("label",{...m,children:h.jsx("span",{children:t.label})}),a&&h.jsxs("div",{className:"vote-details",children:[t.hasUserVoted&&h.jsx(bi,{className:"author-profile-picture",name:e.name,src:(E=e==null?void 0:e.image)==null?void 0:E.thumbnail}),h.jsxs("p",{className:"vote-perc text-medium","data-testid":"vote-perc",children:[d,"%"]})]}),h.jsx("input",{type:i?"radio":"checkbox",id:t.id,name:t.id,checked:u,tabIndex:-1})]})};const D3=({title:e,options:t,settings:n,functions:r})=>{const i="poll_",a=he.useIntl(),s=y.useContext(Mt),{showRemoveVote:o=!1,allowMultipleVotes:l=!1,resultsVisibility:u=Kc.AfterVoting}=n||{},[c,d]=y.useState($re(t,l,s==null?void 0:s.id)),f=t.reduce((v,b)=>v+b.numVotes,0),p=t.filter(v=>v.hasUserVoted).length,g=t.filter(v=>v.hasUserVoted),m=y.useCallback(async v=>{await r.createVote({reactionId:v.id})},[]),E=y.useCallback(async()=>{t.forEach(async v=>{v.hasUserVoted&&v.userVote&&r.removeVote({reactionId:v.userVote.id})})},[t]);return h.jsxs("div",{className:"poll-wrapper",children:[h.jsx("p",{className:"poll-title",children:e}),h.jsxs("aside",{className:"poll-info",children:[h.jsx("p",{className:"poll-instructions","data-testid":"poll-instructions",children:h.jsx("small",{children:a.formatMessage({id:`${i}instructions`},{allowMultipleVotes:l})})}),h.jsx("p",{className:"poll-num-votes",children:h.jsx("small",{"data-testid":"poll-total-votes",children:a.formatMessage({id:`${i}num_votes`},{number:f})})}),o&&h.jsx("p",{className:"poll-remove-vote",children:h.jsx(Me,{variant:"tertiary",onClick:E,"data-testid":"remove-votes-button",disabled:p===0,children:h.jsx("small",{children:a.formatMessage({id:`${i}remove_vote_button`},{number:p})})})})]}),t&&h.jsx("form",{children:h.jsx("fieldset",{children:h.jsx("ul",{className:"poll-options",children:t==null?void 0:t.map((v,b)=>h.jsx(Hre,{isTabbable:c===b,user:s,option:v,optionIndex:b,totalPollVotes:f,showResults:u==Kc.Always||!!p,allowMultipleVotes:l,hasVotedOnPoll:!!p,functions:{createVote:m,setTabbableOption:d}},v.id))})})}),h.jsxs(ot,{"aria-live":"polite",children:[a.formatMessage({id:`${i}aria_votes`},{number:p}),!!p&&h.jsx("ul",{children:g.map(v=>h.jsx("li",{children:v.label}))})]})]})};function Ure({content:e,contentData:t,functions:n}){return h.jsx(D3,{title:t.title,options:(e==null?void 0:e.pollOptions)||[],settings:(e==null?void 0:e.pollSettings)||{},functions:{createVote:n.createVote,removeVote:n.removeVote}})}function zre({links:e={},contentData:t,postCutOff:n,content:r,gtmContext:i}){var a;return h.jsxs(h.Fragment,{children:[e.post?h.jsxs("a",{href:e.post,className:"gtm-trackable gtm-visible","data-gtm-event-type":`discussion-${r.type}`,"data-gtm-event-context":i,children:[(t==null?void 0:t.title)&&h.jsx("p",{className:"content-title",children:t==null?void 0:t.title}),t.postBody.length>n?h.jsx(p4,{text:t.postBody,markdownOptions:{overrides:{a:sh,blockquote:{component:Zf}}}}):h.jsx(ka,{options:{overrides:{a:sh,blockquote:{component:Zf}}},children:t.postBody})]}):h.jsxs(h.Fragment,{children:[(t==null?void 0:t.title)&&h.jsx("p",{className:"content-title",children:t==null?void 0:t.title}),h.jsx(ka,{options:{wrapper:r.type===Ke.Question?"h1":y.Fragment,forceWrapper:r.type===Ke.Question,forceInline:r.type===Ke.Question,forceBlock:r.type!==Ke.Question,overrides:{blockquote:{component:Zf}}},children:t.postBody})]}),(a=t.data)!=null&&a.link?h.jsx(cm,{data:t.data.link}):h.jsx(h.Fragment,{})]})}const pr="discussion_",qre=195;let zu=null;const Ll=({element:e="div",content:t,userHasPermissions:n=!0,userHasOwnerPermissions:r=!1,isLoading:i=!1,originalAuthorId:a,forceHide:s,functions:o,links:l={},className:u,gtmContext:c="DiscussionAnswer",children:d,isTruncated:f=!1,setFocus:p=!1,isCommunity:g=!1,badges:m,basePath:E,parentId:v,locale:b="en",disableMentions:T})=>{var Ve,ie,me,Oe,ge,Q;const C=he.useIntl(),_=y.useContext(L1),x=y.useContext(Mt),{createContent:S=async()=>{},deleteContent:F=async()=>{},updateContent:R=async()=>{}}=o.content||{},{createLike:L=()=>{},deleteLike:P=()=>{},listLikes:I=async()=>({})}=o.likes||{},{openComments:k=()=>{}}=o.comments||{},{listMembers:B=()=>Promise.resolve([]),clickMentionFallback:H=()=>{}}=o.form||{},{createVote:q=()=>{},removeVote:N=()=>{},removePoll:J=()=>{}}=o.polls||{},{author:X,createdAt:D,id:A,likes:Z=0,userLiked:M,comments:j=0,data:z}=t,U=Fre(t.title,b),$=x&&x.id&&typeof X!="string"&&X.id&&X.id===x.id||!1,ae=$&&(!t.createdAt||dx(t.createdAt,10,"seconds")),Y=y.useRef(null),[te,se]=y.useState({title:t.body!==U&&U||"",body:t&&t.body||"",isEditing:!1,didEdit:t&&t.isEdited||!1,postBody:"",data:t&&t.data||{}}),[re,xe]=y.useState(!1),[ke,Te]=y.useState(ae?"highlighted":"default"),[ue,fe]=y.useState("");y.useEffect(()=>{const de=Y.current;if(!(!de||ke==="default"))return document.addEventListener(Yt.DISCUSSION_FORM_SUBMITTED,we),de.addEventListener("transitionend",Ie),()=>{document.removeEventListener(Yt.DISCUSSION_FORM_SUBMITTED,we),de.removeEventListener("transitionend",Ie)}},[]),y.useEffect(()=>{se(de=>({...de,title:t&&U||"",body:t&&t.body||"",didEdit:t&&t.isEdited||!1,data:t&&t.data||{}}))},[t.isEdited]),y.useEffect(()=>{(async()=>{const _e=await _0(te.body,f,z==null?void 0:z.mentions,B);se(Fe=>({...Fe,postBody:_e}))})()},[te.body,z==null?void 0:z.mentions]);const we=()=>{setTimeout(()=>{Te("fading")},1e3)},Ie=({propertyName:de})=>{de==="background-color"&&Te(_e=>(_e==="default"&&(document.removeEventListener(Yt.DISCUSSION_FORM_SUBMITTED,we),Y.current&&Y.current.removeEventListener("transitionend",Ie)),_e==="fading"?"default":_e))};if(i||!t||t.type===Ke.Answer&&(!t.slugs||!t.slugs.question)||te.postBody===""&&t.title==="")return h.jsx(sr,{className:"discussion-card"});const Qe=async({title:de,body:_e,data:Fe})=>{de||(de=""),_e||(_e=""),fe("");try{if(!vc(de,te.title)||!vc(_e,te.body)){const ft=t.type===Ke.Question?{title:_e}:{title:de,body:_e,data:Fe};await R(dh(t.slugs),ft)}se(ft=>({...ft,title:de||"",body:_e||"",data:{...ft.data,...Fe},isEditing:!1,didEdit:!0}))}catch{fe(`${pr}form_error`)}},ct=()=>{if(_&&_.updateConversation){const de={showForm:!0},_e=t.author;_e&&_e.id&&!T&&(g&&(de.prepopulateForm=`@{{${_e.id}}}`),de.mentionData={id:_e.id,name:_e.name}),_.updateConversation(de)}setTimeout(()=>{var tt,dt,jt;const _e=`reply-form-${(t.type===Ke.Answer?t.slug:((tt=t.slugs)==null?void 0:tt.reply)||((dt=t.slugs)==null?void 0:dt.answer)||((jt=t.slugs)==null?void 0:jt.question)||"").toLowerCase().slice(-15)}`,Fe=document.getElementById(_e),ft=document.getElementById(`${_e}-input`);ft&&ft.focus(),Fe&&Fe.scrollIntoView({behavior:"smooth"})},0)},We=async()=>{xe(!1);try{t.type===Ke.Poll?(await J(),window.location.href=`${E}/${v}`):await F(dh(t.slugs))}catch{fe("delete-error")}},Xe=[];return n&&$&&(t.type!==Ke.Poll&&Xe.push({text:C.formatMessage({id:`${pr}moreMenu_edit`}),onClick:()=>se(de=>({...de,isEditing:!0})),icon:"pencil-paper",className:"gtm-trackable","data-gtm-event-context":c,"data-gtm-event-type":`edit-${t.type}-click`}),Xe.push({text:C.formatMessage({id:`${pr}moreMenu_delete`}),onClick:de=>{de.preventDefault(),de.stopPropagation(),xe(!0)},icon:"trash",className:"gtm-trackable","data-gtm-event-context":c,"data-gtm-event-type":`delete-${t.type}-click`,...U4(`delete-${t.slug}-modal`,re)})),r&&o.pins&&Xe.push({text:C.formatMessage({id:`${pr}moreMenu_${t.pinned?"unpin":"pin"}`}),onClick:t.pinned?o.pins.deletePin:o.pins.createPin,icon:t.pinned?"unpin":"pin",className:"gtm-trackable","data-gtm-event-context":c,"data-gtm-event-type":`edit-${t.type}-click`}),p&&((Ve=Y==null?void 0:Y.current)==null||Ve.focus(),(ie=Y==null?void 0:Y.current)==null||ie.scrollIntoView({behavior:"smooth"})),y.createElement(e,{className:ee("discussion-post",u,{[ke]:!u||!u.includes("highlighted-text-box"),"has-link":l.post&&!te.isEditing,"is-pinned":(t==null?void 0:t.pinned)||!1}),ref:Y,tabIndex:p?0:null,"data-testid":`discussion-${t.type}-thread`,"data-gtm-event-context":`${c}-post-click`,onClick:de=>{if(!l.post||te.isEditing||t.type===Ke.Poll&&Rre(de,["poll-options","poll-info"],"discussion-post"))return;de.preventDefault(),de.stopPropagation(),zu&&clearTimeout(zu),zu=setTimeout(()=>{window.location.href=l.post},150);const _e=new CustomEvent(Yt.DISCUSSION_POST_CLICKED,{detail:{link:l.post,timeout:zu}});document.dispatchEvent(_e)},children:h.jsxs(h.Fragment,{children:[h.jsxs("div",{id:A||t.slug,className:ee("discussion-card text-medium",t.type,{editing:te.isEditing,"has-link":l.post&&!te.isEditing}),children:[!te.isEditing&&h.jsx(Mre,{author:X,originalAuthorId:a,createdAt:D,contentData:{didEdit:te.didEdit},content:t,gtmContext:c,badges:m}),te.isEditing?h.jsx(Ml,{id:`editing-${t.slug}`,content:{type:t.type,slugs:t.slugs},userHasPermissions:n,meta:{isLoading:i,isInWrapper:!0,hasTitleField:te.title!==""?{text:te.title}:!1,isEditing:{text:te.body,categories:[]},canBePrepopulated:g,isPrepopulated:!1},maxLength:t.type===Ke.Question?250:5e4,forceShow:{error:ue!==""&&ue!=="delete-error"?C.formatMessage({id:ue},{action:C.formatMessage({id:`${pr}action_${t.type}`})}):!1},functions:{create:S,handleSaveEdit:Qe,handleCancel:()=>{fe(""),se(de=>({...de,isEditing:!1}))},listMembers:B,clickMentionFallback:H},gtmContext:`${c}Form`,data:z}):h.jsxs(h.Fragment,{children:[t.type===Ke.Poll?h.jsx(Ure,{content:t,contentData:te,functions:{createVote:q,removeVote:N}}):h.jsx(zre,{links:l,contentData:te,postCutOff:qre,content:t,gtmContext:c}),h.jsx(Lre,{content:t})]}),!te.isEditing&&!(s!=null&&s.actionBar)&&h.jsx(UT,{className:t.type,gtmContext:c,contentType:t.type,likes:s!=null&&s.likes?!1:{count:Z||0,userLiked:M||!1,canLike:n??!0,peopleWhoLiked:t.peopleWhoLiked,activityId:t.id||t.slug,content:{slugs:t.slugs||{},slug:t.slug},functions:{createLike:L,deleteLike:P,listLikes:I},basePath:E,parentId:v},comments:!(s!=null&&s.comments)&&([Ke.Question,Ke.Post].includes(t.type)||l.comments)?{count:j||0,functions:{onClick:()=>{l!=null&&l.comments&&(window.location.href=l.comments),typeof k=="function"&&k()}}}:!1,replies:t.type==="answer"||t.type==="reply"?{canReply:n??!0,functions:{onClick:ct}}:!1,shareLink:!(s!=null&&s.shareLink)&&{url:`${window.location.origin}${(me=t.slugs)==null?void 0:me.question}/${(Oe=t.slugs)==null?void 0:Oe.answer}${(ge=t.slugs)!=null&&ge.reply?`#${(Q=t.slugs)==null?void 0:Q.reply}`:""}`},moreMenu:!(s!=null&&s.moreMenu)&&{options:Xe,contentSlug:t.slug,reportData:{contentUrl:`${window.origin}${typeof process<"u"&&process.env.PUBLIC_URL||""}/${t.slugs.question||""}`}}})]}),d,h.jsx(Ti,{id:`delete-${t.slug}-modal`,isOpen:re,functions:{onOpen:()=>{},onClose:()=>xe(!1)},forceShow:{error:ue==="delete-error"?C.formatMessage({id:"${intlPath}delete_error"},{action:C.formatMessage({id:`${pr}action_${t.type}`})}):!1},title:C.formatMessage({id:`${pr}delete_title`},{action:C.formatMessage({id:`${pr}action_${t.type}`})}),buttons:[{variant:"secondary",onClick:()=>xe(!1),children:C.formatMessage({id:`${pr}delete_cancel`})},{variant:"primary",className:"destructive",onClick:We,children:C.formatMessage({id:`${pr}delete_delete`})}],gtmContext:`${(t.type||"").charAt(0).toUpperCase()}${(t.type||"").slice(1)}:${t.slug}`,children:h.jsx(he.FormattedMessage,{id:"discussion_delete_text",values:{p:de=>h.jsx("p",{children:de}),action:C.formatMessage({id:`${pr}action_${t.type}`})}})})]})})};const Wre=y.lazy(()=>Promise.resolve().then(()=>aie)),Vre=65,O3=({forceShow:e,form:t,className:n})=>{const r=he.useIntl(),i="discussionFormCard_",a="DiscardDraftModal",o=y.useContext(Mt)||"community",l=e1(o);l.name||(l.name=r.formatMessage({id:`member_${typeof o=="string"?o:"community"}`}));const u=Yi(!0,!1),c=u?u<768:0,{modal:d=!1}=e||{},[f,p]=y.useState({form:d||u4("showPost")==="true"||!1,warning:!1}),[g,m]=y.useState({showCachedText:!1});y.useEffect(()=>{if(!g.showCachedText)return;(async()=>{const T=await _0(g.title||g.body||"",Vre,g.mentions);m(C=>({...C,prettifiedText:T}))})()},[g.showCachedText,g.title,g.body]);const E=b=>{if(!g.showCachedText||typeof f.warning=="string")return;let T;if("detail"in b&&b.detail.link)b.detail.timeout&&clearTimeout(b.detail.timeout),T=b.detail.link;else{const C=b;C.preventDefault(),C.stopPropagation();const x=C.target.closest("a");T=x&&x.getAttribute("href")}p(C=>({...C,warning:T||!1}))};y.useEffect(()=>{if(!g.showCachedText){document.removeEventListener(Yt.DISCUSSION_POST_CLICKED,E),document.removeEventListener(Yt.MEMBER_CLICKED,E),document.removeEventListener("click",E);return}return document.addEventListener(Yt.DISCUSSION_POST_CLICKED,E),document.addEventListener(Yt.MEMBER_CLICKED,E),document.addEventListener("click",E),()=>{document.removeEventListener(Yt.DISCUSSION_POST_CLICKED,E),document.removeEventListener(Yt.MEMBER_CLICKED,E),document.removeEventListener("click",E)}},[g.showCachedText]),y.useEffect(()=>{const b=T=>{if(!(!g.showCachedText||f.warning!==!1))return T.preventDefault(),T.returnValue=""};return window.addEventListener("beforeunload",b,{capture:!0}),()=>{window.removeEventListener("beforeunload",b,{capture:!0})}},[g.showCachedText,f.warning]);let v=r.formatMessage({id:`${i}placeholder${c?"":"_long"}`});return g.showCachedText&&(g.title||g.body)&&(v=g.prettifiedText||v),h.jsxs(h.Fragment,{children:[h.jsxs("button",{className:ee("discussion-form-card",n),onClick:b=>{b.preventDefault(),b.stopPropagation(),p(T=>({...T,form:!0}))},"data-testid":"discussion-form-card",children:[h.jsx(bi,{name:l.name,src:l.image,alt:""}),h.jsx(ka,{className:ee("input",{placeholder:!g.showCachedText}),element:"span",options:{forceInline:!0,overrides:{a:Zn,blockquote:Zn,br:Zn,em:Zn,li:Zn,ol:Zn,p:Zn,s:Zn,span:Zn,strong:Zn,ul:Zn}},children:v})]}),h.jsxs(qs,{children:[h.jsx(Wre,{showModal:f.form,functions:{cacheText:m,onClose:()=>{p(b=>({...b,form:!1}))}},form:t,cachedText:g,className:"in-portal"}),h.jsx(Ti,{id:t.id?`${t.id}-warning`:"discussion-form-card-warning",className:"in-portal",isOpen:f.warning!==!1,functions:{onClose:()=>{p(b=>({...b,warning:!1}))}},title:r.formatMessage({id:`${i}overlay_title`}),buttons:[{variant:"secondary",children:r.formatMessage({id:`${i}overlay_cta_discard`}),onClick:b=>{b.preventDefault(),b.stopPropagation(),typeof f.warning=="string"&&(window.location.href=f.warning)},"data-gtm-event-type":"discard-click","data-gtm-event-context":a},{variant:"primary",children:r.formatMessage({id:`${i}overlay_cta_continue`}),onClick:()=>{p({form:!0,warning:!1})},"data-gtm-event-type":"continue-editing-click","data-gtm-event-context":a}],children:h.jsx("p",{children:r.formatMessage({id:`${i}overlay_text`})})})]})]})},Kre=y.lazy(()=>Promise.resolve().then(()=>Ire)),x0=({isCard:e=!1,form:t,parentId:n,categories:r,membershipRequiredToPost:{isMember:i,required:a,join:s,leave:o,notMemberStateText:l},locale:u=Ns})=>{if(a&&!i)return h.jsx(Wr,{text:l,button:{breakpoints:{mobile:!0,901:!1},component:h.jsx(Sp,{isShort:!0,functions:{join:s,leave:o}})}});const{content:c,functions:d,meta:f,...p}=t,g={content:{type:(c==null?void 0:c.type)||"reply",slugs:(c==null?void 0:c.slugs)||{}},functions:{...d,create:(d==null?void 0:d.create)||(()=>{})},parentId:n,meta:{...f,isEditing:(f==null?void 0:f.isEditing)||!1,isPrepopulated:!1,showSuccessMessage:!1,postCategories:[{name:"Post",slug:"no-category"},...r||[]]},...p,id:`add-post-${p.id||""}`};return e?h.jsx(O3,{form:g}):h.jsx(Kre,{...g})},w0=({form:e})=>{const t=y.useContext(Mt),n=he.useIntl(),[r,i]=y.useState(!1),a=()=>{wx(t)||i(!0)};y.useEffect(()=>{if(e&&!(e!=null&&e.isDisabled)||(e==null?void 0:e.isDisabled)===void 0)return document.addEventListener(Yt.DISCUSSION_POST_ADDED,a),()=>{document.removeEventListener(Yt.DISCUSSION_POST_ADDED,a)}});const s={};return["successMessage","title","text"].forEach(o=>{s[o]=n.formatMessage({id:`profileModalLauncher_${o}`})}),h.jsx($1,{form:e,showModal:r,functions:{onClose:()=>{i(!1)}},content:s})};const Qf="discussion_responses_",N3=({type:e="answer",responses:t=0,isLoading:n=!1})=>{const r=he.useIntl();return t=parseInt(t),h.jsxs("div",{className:"responses-heading",children:[h.jsx("h4",{children:r.formatMessage({id:`${Qf}title`},{action:r.formatMessage({id:`${Qf}${e}`}),count:t})}),!n&&t===0&&h.jsx("p",{children:vr(r.formatMessage,`${Qf}empty`,e,e)})]})};const I3=({loadMore:{isLoading:e,hasNextPage:t,loadNextPage:n}={isLoading:!1,hasNextPage:!1,loadNextPage:()=>{}},form:r,children:i})=>{const a=he.useIntl(),s=y.useContext(L1),o=Ku(i,{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 h.jsxs("div",{className:ee("thread-wrapper",{"empty-thread":!o}),children:[!Object.is(o,null)&&h.jsx("ul",{className:"thread",children:o}),!e&&h.jsx(xl,{hasNextPage:t,loadNextPage:n,size:"small",styling:{muted:!0},icon:{icon:"arrow_corner-down_right",position:"left"},messages:{button:a.formatMessage({id:"discussion_thread_loadMore"}),error:a.formatMessage({id:"loadMore_error"})}}),r&&s.showForm&&h.jsx(Ml,{...r})]})};function Gre(e){var n,r;let t=!1;return(r=(n=e.latest_reactions)==null?void 0:n["poll-option"])==null||r.forEach(i=>{var a,s;(s=(a=i.own_children)==null?void 0:a["poll-vote"])!=null&&s.length&&(t=!0)}),t}function Yre({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:i,user:a}){const{mutate:s}=vt.useMutation({mutationFn:e,onMutate:({reactionId:o})=>t(l=>(z4({activity:l,reactionId:o,user:a}),l)),onError:n,onSuccess:(o,{reactionId:l},u)=>{u&&q4({activity:u,reactionId:l,correctReactionId:o.body.id,user:a}),r.setQueryData(i,u)}});return s}function Zre({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=vt.useMutation({mutationFn:e,onMutate:({content:i,title:a})=>t(s=>(s&&(i!=null&&(s.content=i),a!=null&&(s.title=a)),s)),onError:n});return r}function Qre({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:i}){const{mutate:a}=vt.useMutation({mutationFn:e,onMutate:s=>t(o=>(o&&xc({activity:o}),o)),onError:n,onSuccess:(s,o,l)=>{l&&xc({activity:l,reaction:s}),r.setQueryData(i,l)}});return a}function Xre({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:i}){const{mutate:a}=vt.useMutation({mutationFn:e,onMutate:s=>t(o=>(o&&wc({activity:o}),o)),onError:n,onSuccess:(s,o,l)=>{l&&wc({activity:l,reaction:s}),r.setQueryData(i,l)}});return a}function Jre({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:i,isFetching:a}=vt.useQuery({queryFn:e,queryKey:t});return{activity:n,error:r,isLoading:i,isFetching:a}}function eie({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:i}=vt.useMutation({mutationFn:e,onMutate:({reactionId:a})=>t(s=>(W4({activity:s,reactionId:a}),s)),onError:n});return i}function tie({queryFns:{read:e,edit:t,like:n,unlike:r,pin:i,unpin:a,createVote:s,removeVote:o},queryKey:l}){const u=vt.useQueryClient(),c=Xc(),d={queryClient:u,queryKey:l},f={mutationHandlers:{error:kp(d),mutate:Dp(d)},user:c,...d},p=Zre({...f,mutationFn:t}),g=Qre({...f,mutationFn:n}),m=nie({...f,mutationFn:r}),E=Xre({...f,mutationFn:i}),v=rie({...f,mutationFn:a}),b=Yre({...f,mutationFn:s}),T=eie({...f,mutationFn:o}),{activity:C,..._}=Jre({queryKey:l,queryFn:e});return{activity:C,mutations:{edit:p,like:g,unlike:m,pin:E,unpin:v,createVote:b,removeVote:T},user:c,..._}}function nie({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:i}=vt.useMutation({mutationFn:e,onMutate:a=>t(s=>(s&&V4({activity:s,user:r}),s)),onError:n});return i}function rie({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:i}=vt.useMutation({mutationFn:e,onMutate:a=>(console.log("unpin"),t(s=>(s&&K4({activity:s,user:r}),s))),onError:n});return i}const iie=({basePath:e,parentId:t,activityId:n,isMember:r,isOwner:i,functions:{activities:{remove:a,...s},likes:o,reactions:l,form:u,join:c,leave:d,polls:f},profile:p,categories:g,locale:m=Ns,type:E=$t.Communities,repliesFilters:v})=>{var z,U,$,ae,Y,te,se,re,xe,ke,Te,ue;const b=he.useIntl(),T=y.useContext(Mt),C={...s,...f},{activity:_,error:x,isLoading:S,mutations:{edit:F,like:R,unlike:L,pin:P,unpin:I,createVote:k,removeVote:B}}=tie({queryFns:C,queryKey:[e,t,n]});if(S)return h.jsx(sr,{style:{height:"400px",width:E===$t.Courses?"100%":"initial"}});if(x||!_)return h.jsx(Wr,{variant:"error",text:b.formatMessage({id:"activitySection_notFoundError"})});const{own_reactions:H,verb:q,latest_reactions:N,mentioned_users:J,additional_data:X}=_,D=(((z=N==null?void 0:N.like)==null?void 0:z.length)||0)>0,A=!!((U=H==null?void 0:H.like)!=null&&U.find(fe=>{var we;return((we=fe.user)==null?void 0:we.id)===(T==null?void 0:T.id)})),Z=A?H==null?void 0:H.like[0].id:"",M=D?($=N==null?void 0:N.like)==null?void 0:$.map(fe=>{var we,Ie,Qe;return{id:(we=fe==null?void 0:fe.user)==null?void 0:we.id,name:(Qe=(Ie=fe==null?void 0:fe.user)==null?void 0:Ie.data)==null?void 0:Qe.name}}):!1,j=_==null?void 0:_.actor;return h.jsxs("section",{className:"activity-section",children:[h.jsx(Ll,{className:"highlighted-text-box subtle",isCommunity:!0,content:{id:n,type:q,title:_==null?void 0:_.title,body:E===$t.Courses?h6({content:_.content,locale:m}):_==null?void 0:_.content,categories:C0((_==null?void 0:_.categories)||[],g||[]),createdAt:(_==null?void 0:_.time)||"",slugs:{question:`${e}/${t}`,answer:_==null?void 0:_.id},slug:n,author:Vs(j),userLiked:A,likes:((ae=_==null?void 0:_.reaction_counts)==null?void 0:ae.like)||0,comments:(_==null?void 0:_.total_replies)||0,peopleWhoLiked:E===$t.Courses?!1:M,data:{mentions:J,...X||{}},pinned:((Y=_==null?void 0:_.reaction_counts)==null?void 0:Y.pin)&&((te=_==null?void 0:_.reaction_counts)==null?void 0:te.pin)>0||!1,pollOptions:Op(_,m),pollSettings:{showRemoveVote:(se=_==null?void 0:_.settings)==null?void 0:se.show_remove_vote,allowMultipleVotes:(re=_==null?void 0:_.settings)==null?void 0:re.allow_multiple_votes,deadlineAt:(xe=_==null?void 0:_.settings)==null?void 0:xe.deadline_at,hideParticipants:(ke=_==null?void 0:_.settings)==null?void 0:ke.hide_participants,numberOfWinners:(Te=_==null?void 0:_.settings)==null?void 0:Te.number_of_winners,resultsVisibility:(ue=_==null?void 0:_.settings)==null?void 0:ue.results_visibility}},originalAuthorId:j==null?void 0:j.id,forceHide:{comments:!0,shareLink:E===$t.Courses},functions:{content:{createContent:()=>null,deleteContent:a,updateContent:(fe,{title:we,body:Ie})=>F({title:we,content:Ie})},likes:{createLike:()=>R({activityId:n}),deleteLike:()=>L({activityId:n,reactionId:Z}),listLikes:fe=>o.list({activityId:n,...fe})},comments:{openComments:()=>{}},pins:{createPin:()=>P({activityId:n}),deletePin:()=>{var fe;return I({activityId:n,reactionId:(fe=N==null?void 0:N.pin)==null?void 0:fe[0].id})}},polls:{createVote:({reactionId:fe})=>k({reactionId:fe}),removeVote:({reactionId:fe})=>B({reactionId:fe}),removePoll:()=>f.removePoll({activityId:n})},form:u},styling:{showShareLinkButton:!0},userHasPermissions:r,userHasOwnerPermissions:i,badges:{showBadges:!0,scopes:[{scope:ln.Communities,area:t||""},{scope:ln.Platform,area:"all"}]},basePath:e,parentId:t},n),h.jsx(LT,{basePath:e,parentId:t,activityId:n,showReplies:q===Ke.Poll?Gre(_):!0,activityTotalReplies:(_==null?void 0:_.total_replies)||0,isMember:r,functions:{reactions:l,likes:o,form:u,join:c,leave:d},profile:p,type:E,repliesFilters:v})]})};const P3=({showModal:e=!0,functions:t,form:n,cachedText:r,className:i})=>{const a=he.useIntl(),s="discussionFormModal_",{onClose:o=()=>{},cacheText:l=()=>{}}=t,{data:u,meta:c,functions:d}=n,{title:f="",body:p="",mentions:g}=r||{},m="discussion-form-modal";return h.jsx(Ti,{id:m,title:a.formatMessage({id:`${s}title`}),isOpen:e,functions:{onClose:()=>{(f!==""||p!=="")&&l(E=>({...E,showCachedText:!0})),o()}},className:ee("discussion-form-modal",i),children:h.jsx(Ml,{...n,data:{...u,mentions:g||(u==null?void 0:u.mentions)},meta:{...c,isAutoFocused:!0,isInOverlay:`${m}-overlay`,hasTitleField:{text:f},isPrepopulated:{text:p||(c==null?void 0:c.isPrepopulated)!==!1&&(c==null?void 0:c.isPrepopulated.text)||""},showGuidelines:!1,showDivider:!0,showPostType:!0},buttons:{submit:a.formatMessage({id:`${s}cta`})},functions:{...d,onChange:E=>{l(v=>({...v,...E}))},onMention:({id:E,name:v}={})=>{if(!E||!v)return;const b=g||{};b[E]={created_at:"",updated_at:"",id:E,data:{name:v}},l(T=>({...T,mentions:b}))},create:async E=>{o(),d.create&&await d.create(E),l({showCachedText:!1})},createPoll:async E=>{const v=()=>{o(),l({showCachedText:!1})};if(d.createPoll)try{const b=await d.createPoll(E);return new Promise(T=>(v(),T(b)))}catch{return new Promise((T,C)=>C())}else return v(),new Promise(b=>b({}))},handleSaveEdit:async E=>{o(),d.handleSaveEdit&&await d.handleSaveEdit(E),l({showCachedText:!1})}}})})},aie=Object.freeze(Object.defineProperty({__proto__:null,default:P3},Symbol.toStringTag,{value:"Module"}));const sie=({className:e,showModal:t=!0,title:n,messagePlaceholder:r,formTitle:i,formLabel:a,ctaMessage:s,showIcon:o,onClose:l,reportError:u=()=>{},sendInvites:c})=>{const d=he.useIntl();return i||(i=d.formatMessage({id:"inviteModal_formTitle"})),a||(a=d.formatMessage({id:"inviteModal_formLabel"})),s||(s=d.formatMessage({id:"inviteModal_cta"})),h.jsx(Ti,{id:"invite-user-modal",title:n,isOpen:t,showDivider:!1,showIcon:o,functions:{onClose:l},className:ee("invite-modal",e,{success:!!n}),children:h.jsx(PT,{title:i,label:a,messagePlaceholder:r,ctaMessage:s,onClose:l,sendInvites:c,reportError:u})})};const oie=({showModal:e=!0,content:{successMessage:t,title:n,text:r}={},functions:i,form:a,className:s})=>{const o=he.useIntl(),[l,u]=y.useState(u4("showProfile")==="true"||e);y.useEffect(()=>{u(e)},[e]);const{onClose:c=()=>{}}=i;return h.jsx(Ti,{id:"profile-form-modal",title:t||n||o.formatMessage({id:"profileModal_title"}),isOpen:l,showDivider:!t,functions:{onClose:c},className:ee("profile-modal",s,{success:!!t}),maxWidth:700,children:h.jsxs(h.Fragment,{children:[t&&n||r?h.jsxs("div",{className:"intro",children:[t&&n?h.jsx("h3",{children:n}):"",r?h.jsx("p",{children:r}):""]}):null,h.jsx(RT,{...a,meta:{shouldShowCancelButton:!1},functions:{...(a==null?void 0:a.functions)||{},onSuccess:async d=>{var f;try{(f=a==null?void 0:a.functions)!=null&&f.onSuccess&&await a.functions.onSuccess(d)}finally{c()}}}})]})})},$1=oie,lie=Object.freeze(Object.defineProperty({__proto__:null,default:$1},Symbol.toStringTag,{value:"Module"}));const uie=({members:e})=>{const[t,n]=y.useState(!1),r=i=>{const{fullName:a,jobTitle:s,organisation:o,photo:l}=i||{};return h.jsxs(h.Fragment,{children:[h.jsx(bi,{name:a,src:l}),h.jsx("p",{children:a}),h.jsx("small",{className:"text-medium",children:o?`${s}, ${o}`:s})]})};return h.jsxs("div",{className:"directory-wrapper",children:[h.jsx("ul",{className:"directory",children:e.map(i=>h.jsx("li",{children:h.jsx("button",{onClick:a=>{a.preventDefault(),a.stopPropagation(),n(i)},children:r(i)})},i.fullName))}),h.jsx(Ti,{isOpen:t!==!1,children:t===!1?"":h.jsxs(h.Fragment,{children:[r(t),h.jsx(ka,{children:t.text})]}),buttons:[{size:"small",variant:"tertiary",onClick:()=>n(!1),children:"Close"}],functions:{onClose:()=>n(!1)}})]})};const cie=({email:e,settings:t={}})=>{const{formatMessage:n}=he.useIntl(),r=y.useContext(Mt),{myProfile:i,isConnected:a,cannotConnect:s}=t,[o,l]=y.useState(!1),[u,c]=y.useState(!1);return r?e&&i?h.jsx(Me,{icon:{icon:"info-inside-circle",position:"right"},size:"small",variant:"secondary",styling:{muted:!0},tooltip:n({id:"member_show_email_tooltip_mine"}),forceTooltip:!0,className:"show-email fake-button",children:e}):s?h.jsx(Me,{icon:"email",size:"small",variant:"secondary",styling:{muted:!0},tooltip:n({id:"member_show_email_tooltip_private"}),forceTooltip:!0,className:"show-email fake-button",children:n({id:"member_show_email_private"})}):a?e&&a?h.jsx(h.Fragment,{children:o?h.jsx(Me,{icon:{icon:"copy",position:"right"},size:"small",variant:"secondary",styling:{muted:!0},className:"show-email copy-button",tooltip:n({id:`member_show_email_tooltip${u?"_copied":""}`}),forceTooltip:!0,"data-gtm-event-context":"connections-email-address-button","data-gtm-event-type":"copy-email-click",onClick:()=>{navigator.clipboard.writeText(e).then(()=>{c(!0),setTimeout(()=>{c(!1)},2e3)})},children:e}):h.jsx(Me,{icon:"email",size:"small","data-gtm-event-context":"connections-email-address-button","data-gtm-event-type":"show-email-click",onClick:()=>l(!0),children:n({id:"member_show_email_show"})})}):h.jsx(h.Fragment,{}):h.jsx(Me,{icon:"email",size:"small",variant:"secondary",styling:{muted:!0},className:"show-email fake-button",children:n({id:"member_show_email_hide"})}):h.jsx(h.Fragment,{})};const die=({author:e,authorCite:t,content:n,member:r,className:i=""})=>h.jsxs("blockquote",{className:ee("testimonial-block",i),children:[h.jsx(Lr,{className:"testimonial",children:n}),r?h.jsx(pi,{member:r,styling:{size:"large"}}):h.jsxs(h.Fragment,{children:[e&&h.jsx("p",{className:ee("author",{"text-small":!i.includes("new")}),children:e}),t&&h.jsx("p",{className:ee("author-cite",{"text-small":!i.includes("new")}),children:h.jsx("cite",{children:t})})]})]}),fie=y.memo(die);const hie=({items:e=[],selector:t="",className:n=""})=>{const r=he.useIntl(),[i,a]=y.useState(e);return y.useEffect(()=>{if(e.length)return;let s="";Array(6).fill(0).forEach((u,c)=>{s+=`${c>0?", ":""}${t} h${c+1}`});const l=Array.from(document.querySelectorAll(s)).filter(u=>u.id).map(u=>({id:u.id,text:u.textContent||""}));a(l)},[]),i&&i.length>0&&h.jsxs(Ln,{variant:"subtle",className:ee("table-of-contents",n),children:[h.jsx("h2",{children:r.formatMessage({id:"tableOfContents"})}),h.jsx("nav",{children:h.jsx("ul",{children:i.map(({id:s,text:o})=>h.jsx("li",{children:h.jsx("a",{href:`#${s}`,children:o})},s))})})]})};const j1=({time:e,rangeTime:t,prependedText:n,appendedText:r,className:i=""})=>{const a=he.useIntl(),s="timeToComplete_";if(!e||typeof e!="number")return null;const o=c=>{const d=c/60,f=Math.floor(d),p=(d-f)*60,g=Math.round(p),m=`${a.formatMessage({id:`${s}hours`},{time:f})}${f>0&&g>0?", ":""}${a.formatMessage({id:`${s}minutes`},{time:g})}`;return{text:`${f>0?`${a.formatMessage({id:`${s}hours_short`},{time:f})} `:""}${g>0?a.formatMessage({id:`${s}minutes_short`},{time:g}):""}`,ariaText:m}};let{text:l,ariaText:u}=o(e);if(t){const{text:c,ariaText:d}=o(e+t);l=a.formatMessage({id:`${s}range`},{early:l,late:c}),u=a.formatMessage({id:`${s}range_aria`},{early:u,late:d})}return n&&(u=`${n} ${u}`,l=`${n} ${l}`),r&&(u=`${u} ${r}`,l=`${l} ${r}`),h.jsx("span",{className:ee("time-to-complete",i),"aria-label":u,children:l})};const pie=({className:e="",image:t,...n})=>t?(typeof t=="string"&&(t={width:1080,height:200,type:"image/png",url:t}),t.range=[{height:124,width:425},{height:200,width:768},{height:200,width:1368}],t.query="fit=thumb&f=center",h.jsx(Zi,{...n,className:ee("banner",e),image:{...t,aspect:"banner"}})):null;const mie=["small","span","strong","em","p","h1","h2","h3","h4","h5","h6","blockquote","q"],gie=({className:e="",content:t,image:n,variant:r,spacing:i="normal",styling:a,hideElements:s={eyebrow:!1,title:!1,text:!1},cta:o,children:l})=>{var g,m;const u={imageFullWidth:!0,...a};r||(r=u.imageFullWidth?"default":"light");const c=["eyebrow","title","text"],d={eyebrow:"small",title:"h1",text:"p"},f={};c.forEach(E=>{if(!t[E]){f[E]=!1;return}if(!s[E]){if(typeof t[E]=="object"){f[E]=t[E];const{text:v,element:b}=t[E];if(b&&mie.includes(b.toLowerCase()))return;f[E]={text:v,element:d[E]};return}f[E]={text:t[E],element:d[E]}}});const p=o&&o.text&&o.link;return p&&o.link[0]==="#"&&(o.props||(o.props={}),o.props.onClick=E=>{E.preventDefault(),E.stopPropagation();const v=document.getElementById(o.link.substring(1));v&&v.scrollIntoView({behavior:"smooth"})}),h.jsx(ea,{className:ee("banner-section",r,i,e,{"has-image":n,"image-full-width":n&&u.imageFullWidth,"image-inline":n&&!u.imageFullWidth,"has-cta":p,"has-extra-spacing":r!=="subtle"&&i==="normal"&&f.eyebrow&&f.title}),children:h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"content-wrapper",children:[c.map(E=>{if(f[E]&&typeof f[E]=="object"){const{text:v,element:b=""}=f[E];return E==="text"?h.jsx(ka,{overrideType:"text-only",className:"text",children:v},E):y.createElement(b,{key:E,className:E},v)}return null}),l,p&&h.jsx(Me,{variant:n||["light","subtle"].includes(r)?"primary":"secondary",size:{mobile:"medium",768:"large"},href:o.link,...o.props,className:ee({new:r==="subtle",[(g=o.props)==null?void 0:g.className]:(m=o.props)==null?void 0:m.className}),children:o.text})]}),n&&h.jsx(Zi,{image:{...n,aspect:u.imageFullWidth?"banner":n.aspect||void 0}})]})})},vie=y.memo(gie);const Eie=({image:e,variant:t="default",children:n,className:r=""})=>{const i={};return e&&(i["--image"]=`url(${e})`),h.jsx(ea,{className:ee("custom-content-banner",t,r,{"has-image":e}),style:i,children:h.jsx("div",{className:"content-slim",children:n})})};const yie=({alignImage:e="left",className:t,content:n,image:r})=>{const i=typeof n=="string"?h.jsx(ka,{children:n}):n;return h.jsxs(ea,{className:ee("highlight-section",t),children:[r&&h.jsx("div",{className:ee("highlight-container highlight-image",{[`highlight-image-${e}`]:e==="right"}),children:h.jsx(Zi,{image:{...r,description:"",query:"q=85",aspect:"highlightSection"}})}),h.jsx("div",{className:ee("highlight-container highlight-content-wrapper",{"no-image":!r}),children:h.jsx("div",{className:ee("highlight-content",{"highlight-content-right":e==="left"}),children:r?i:h.jsx("div",{className:"content-default",children:i})})})]})},bie=y.memo(yie);const Tie=({variant:e="primary",button:t=null,title:n,text:r,gtmContext:i})=>!n&&!r?null:h.jsxs("aside",{className:ee("marketing-block",e),children:[n&&h.jsx("p",{className:"title",children:n}),r&&h.jsx("p",{children:r}),t&&h.jsx(Me,{variant:t.variant||"secondary",size:"medium",href:t.link,className:"gtm-trackable","data-gtm-event-context":i,"data-gtm-event-type":"learn-more-click",children:t.text})]}),_ie=({type:e,data:t})=>{const n=he.useIntl(),{answers:r,createdAt:i,dateHasPassed:a,isOngoingEvent:s,pill:o,readingTime:l,publishedDate:u,startDate:c}=t;if(e==="question"){const d=i&&rh(i);return h.jsxs("p",{className:"details answers","data-testid":"question-answers",children:[n.formatMessage({id:"card_answers"},{number:r}),i&&h.jsxs("span",{"data-testid":"question-created-at",children:[" ","·"," ",n.formatMessage({id:"card_time_ago"},{time:d?n.formatMessage({id:`dates_${d.path}`},{number:d.number}):0})]})]})}if(c&&!a||s)return h.jsx("p",{className:"details",children:s?n.formatMessage({id:"card_bootcamp"}):pp(c)});if(o)return h.jsx($r,{variant:o==="free"?"subtle":"highlighted",className:o,"data-testid":"course-type",children:o});if(l||u){const d=u&&rh(u);return h.jsxs("ul",{className:"details",children:[l&&h.jsx("li",{"data-testid":"reading-time",children:n.formatMessage({id:"card_time_read"},{time:l})}),u&&h.jsx("li",{"data-testid":"published-date",children:n.formatMessage({id:"card_time_ago"},{time:d?n.formatMessage({id:`dates_${d.path}`},{number:d.number}):0})})]})}return null},Cie={title:66,text:3e3,secondaryText:1e3,partner:34},Gc={communityPage:{basePath:"/communities/",className:"communityPage",gtmEvent:"community"},customCard:{className:"custom",gtmEvent:"custom",length:{text:335,secondaryText:150}},event:{basePath:"/events/",className:"event",gtmEvent:"event"},microcourse:{basePath:"/microcourses/en/",className:"course",gtmEvent:"microcourse-overview"},courseJourney:{basePath:"/courses/",className:"course",gtmEvent:"microcourse-overview"},solutionArticle:{basePath:"/solution-articles/en/",className:"article",length:{title:60},gtmEvent:"article"},qaQuestion:{basePath:"/questions-answers/",className:"question",length:{title:190},gtmEvent:"q-and-a-question"},listPage:{basePath:"/list/en/",className:"list",gtmEvent:"list"},people:{basePath:"/profiles/",className:"people",length:{people:1e3},gtmEvent:"person"},learningHub:{basePath:"/learning-hub/",className:"learning-hub",length:{title:190},gtmEvent:"learning-hub"}},xie=({data:e,cta:t,link:n,gtmContext:r})=>{var m,E;const i=he.useIntl(),[a,s]=y.useState({loading:!1,registered:e.registered||!1});y.useEffect(()=>{e.registered&&s(v=>({...v,registered:!0}))},[e.registered]);const{customLinkText:o,startDate:l,dateHasPassed:u,pill:c,slug:d}=e,f=e.contentType;let p="";if((m=Gc[f])!=null&&m.gtmEvent&&(p=Gc[f].gtmEvent),l&&u)return n?h.jsx("a",{href:n,className:"details additional-link gtm-trackable","data-gtm-event-context":`${r}-CarouselCard`,"data-gtm-event-type":`${p}-click`,children:o||i.formatMessage({id:"card_watch"})}):null;if(f==="people")return n?h.jsx(Me,{variant:"tertiary",size:"small",href:n,className:"gtm-trackable","data-gtm-event-context":`${r}-Card-Button`,"data-gtm-event-type":`${p}-click`,children:o||i.formatMessage({id:"card_cta_people"})}):null;const g=["communityPage","microcourse","event"];if(t&&t.onClick&&g.includes(f)&&c!=="premium"){const v=a.loading||a.registered||((E=e==null?void 0:e.members)==null?void 0:E.isMember),b=async T=>{var C;if(T.preventDefault(),T.stopPropagation(),window&&((C=window.dataLayer)==null||C.push({event:"gtm.click","gtm.element":n,"gtm.elementClasses":"gtm-trackable","gtm.elementUrl":n,EventType:`${r}-${f}-register-click`,EventContext:`${r}Page-${f}: ${d}`})),!(v||!t||!t.onClick)){s(_=>({..._,loading:!0}));try{const _=await t.onClick(e);s(_==="success"?()=>({registered:!0,loading:!1}):x=>({...x,loading:!1}))}catch{s(x=>({...x,loading:!1}))}}};return h.jsx("p",{className:ee("cta-wrapper",{"has-member-section":e==null?void 0:e.members}),children:h.jsx(Me,{onClick:b,className:"gtm-trackable",size:"small",styling:{fullWidth:!0},disabled:v,"data-gtm-event-context":`${r}Page-${f}: ${d}`,"data-gtm-event-type":`${r}-${f}-register-click`,"data-testid":"in-card-button",children:o||i.formatMessage({id:`card_cta_${f}${v?`_${a.loading?"loading":"done"}`:""}`})})})}return null};function wie({buildMemberData:e,communitySlug:t}){const n=he.useIntl(),r=y.useContext(Mt),[i,a]=y.useState({count:"...",isMember:!1,memberType:""});return y.useEffect(()=>{e(t,typeof(r==null?void 0:r.id)<"u").then(s=>{if(!s)return;const{membersCount:o,role:l="",pagination:u}=s;let c=0;o?c=o:u!=null&&u.total&&(c=u==null?void 0:u.total),a({count:c.toString(),isMember:!!l,memberType:l})})},[t,e]),h.jsxs("span",{className:"member-information",children:[i.isMember&&h.jsx($r,{size:"small",variant:"registered",icon:(i==null?void 0:i.memberType)==="owner"?"user":"tick",children:n.formatMessage({id:`card_member_type_${i.memberType}`})}),h.jsx("span",{className:"label member-count",children:n.formatMessage({id:"card_member_count"},{count:i.count})})]})}const A0=({id:e="",className:t="",buildCardData:n,buildMemberData:r,card:i,cta:a,gtmContext:s="Carousel",handleCardClick:o,meta:l})=>{var k,B;const u=he.useIntl(),c=y.useContext(Mt),d=!!(c!=null&&c.id),{isTabbable:f=!0,setFocus:p=!1}=l||{},g=y.useRef(null),[m,E]=y.useState({data:null,isLoading:!0});y.useEffect(()=>{n(i,d).then(H=>{E({data:H,isLoading:!1})}).catch(()=>E(H=>({...H,isLoading:!1})))},[i,d,n]);const{data:v,isLoading:b}=m;if(b||!v)return h.jsx(sr,{element:"li",className:"card-wrapper","data-testid":"card-placeholder"});o&&!a&&(a={text:u.formatMessage({id:`card_cta_${i.contentType}`}),onClick:o});const{contentType:T}=v;if(!T||!Gc[T])return h.jsx(sr,{element:"li",className:"card-wrapper"});const{basePath:C="",className:_,length:x,gtmEvent:S}=Gc[T];let F=f&&v.slug?`${v.locale?`/${v.locale}`:""}${C}${v.slug}`:!1;f&&v.slug&&(v.slug.slice(0,4)==="http"||v.slug.slice(0,2)==="//"||v.slug.slice(0,6)==="mailto"||v.slug.slice(0,3)==="tel")&&(F=v.slug);const R=H=>{if(F){H.preventDefault(),H.stopPropagation();const q=H.currentTarget.getAttribute("data-url");window&&window.dataLayer.push({event:"gtm.click","gtm.element":q,"gtm.elementClasses":"gtm-trackable","gtm.elementUrl":q,EventType:`${s}-CarouselCard`,EventContext:`${S}-click`}),window.location.href=q}},L={...Cie,...x};let P={className:"card"},I={};return F&&(I={href:F,className:"gtm-trackable","data-gtm-event-context":`${s}-CarouselCard`,"data-gtm-event-type":`${S}-click`,"data-testid":"link"},v.openInNewTab&&(I.target="_blank"),P={onClick:R,className:"card gtm-trackable","data-gtm-event-context":`${s}-CarouselCard`,"data-gtm-event-type":`${S}-click`}),p&&(P={...P,tabIndex:"0"},(k=g==null?void 0:g.current)==null||k.focus(),(B=g==null?void 0:g.current)==null||B.scrollIntoView({behavior:"smooth"})),h.jsx("li",{className:ee("card-wrapper text-medium",_,t,{"has-link":F,"no-link":!F,"has-image":v.banner}),"data-testid":`${T}-card`,children:h.jsxs("div",{...P,ref:g,"data-url":F,children:[h.jsx(d4,{className:"card-label",contentType:T,customIcon:v.isPrivate?"lock-locked":v.customIcon,customLabel:v.customLabel}),T==="communityPage"&&(v==null?void 0:v.createdAt)&&fx(v==null?void 0:v.createdAt,60)&&h.jsx($r,{size:"small",variant:"information","data-testid":"new-community",children:u.formatMessage({id:"card_new"})}),v.startDate&&!v.isOngoingEvent&&h.jsx($r,{size:"small",variant:v.dateHasPassed?"default":"information","data-testid":"date",children:v.dateHasPassed?u.formatMessage({id:"card_ended"}):s4(v.startDate)}),v.banner?h.jsxs("p",{className:"img",children:[v.registered&&h.jsx($r,{size:"small",variant:"registered",children:u.formatMessage({id:"card_registered"})}),h.jsx(Zi,{image:{...v.banner,description:""}})]}):_==="people"?h.jsx(bi,{name:v.title||"",src:v.profile,"data-testid":"people-profile-picture"}):null,v.contributors&&h.jsx(_p,{contributors:{data:v.contributors},styling:{size:"small",showGap:_!=="question",showText:!0},multipleText:["event","solutionArticle"].includes(T)?u.formatMessage({id:`card_contributors_${T}`}):void 0,"data-testid":"contributors"}),v.partner&&h.jsx("p",{className:"partners","data-testid":"partners",children:v.partner.length>1?u.formatMessage({id:"card_partner"},{partner:v.partner[0],number:v.partner.length-1}):Ss(v.partner[0],L.partner)}),["title","text","secondaryText"].map(H=>{const q=v[H];if(!q)return null;const N=t4(H),J={key:H,className:N,"data-testid":N},X={wrapper:"p",forceWrapper:!0,forceInline:!0},D=Ss(q,L[H]);return["title","text"].includes(H)&&F?(X.wrapper="a",h.jsx("p",{...J,children:h.jsx(Lr,{options:X,...I,children:D})})):h.jsx(Lr,{options:X,...J,children:D})}),i.contentType==="communityPage"&&(i.slug||v.slug)&&r&&h.jsx(wie,{communitySlug:i.slug||v.slug,buildMemberData:r}),h.jsx(_ie,{type:_||"",data:v}),h.jsx(xie,{data:v,cta:a,link:F||"",gtmContext:s})]})})};const R3=({cards:e,cardTypes:t,className:n="",gtmContext:r="",...i})=>h.jsx("ul",{className:ee("card-block",n),children:e.map((a,s)=>{const o=a.slug?`${a.slug}-${t[s]}`:`${t[s]}-${s}`;return h.jsx(A0,{id:o,card:{...a,contentType:t[s]},meta:{setFocus:s===(i==null?void 0:i.focusCardIndex)},...i},`${o}-${r}-${a.title}`)})}),Aie=(e,t,n,r)=>{const i=t*n<=e,a=e<t*(n+1),s=r.includes(Math.floor(e/t));return{inView:i&&a,isLoaded:s}},Sie=({id:e,title:t})=>{const n=he.useIntl();if(!t||!t.text)return null;const{text:r,element:i="h2",variant:a="default",size:s="medium",link:o}=t;return y.createElement(i,{className:ee("title",a,s,{"highlighted-title":a==="highlighted"}),children:h.jsxs(h.Fragment,{children:[r,o&&h.jsx("a",{href:o,className:"text-medium gtm-trackable","data-gtm-event-context":"CarouselViewAll","data-gtm-event-type":`${e||window.btoa(r)}-view-all-click`,children:n.formatMessage({id:"card_carousel_viewAll"})})]})})};const Xf={fourCards:1024,threeCards:769,twoCards:480};let qu=null,Jf=null;const kie=({id:e,cards:t,cardTypes:n,buildCardData:r,title:i,className:a,gtmContext:s,...o})=>{const l=he.useIntl(),u="carousel_pagination_",[c,d]=y.useState({cardsPerPage:4,isLoading:!0}),{cardsPerPage:f,isLoading:p}=c,[g,m]=y.useState({currentPage:0,loadedPages:[0]}),{currentPage:E,loadedPages:v}=g,[b,T]=y.useState(""),C=t.length,_=Math.ceil(C/f),x=y.useRef(null),S=Yi(!0,!0,x==null?void 0:x.current);y.useEffect(()=>{let k=1;S&&(S>=Xf.fourCards?k=4:S>=Xf.threeCards?k=3:S>=Xf.twoCards&&(k=2),k>C&&(k=C)),d(B=>({...B,cardsPerPage:k,isLoading:!1}))},[S,C]);const F=(k="next")=>{Jf&&clearTimeout(Jf);let B=E;if(typeof k=="string")if(k==="next")if(E<_-1)B=E+1;else return;else if(E>0)B=E-1;else return;else B=k;T(""),m(q=>({...q,currentPage:B,loadedPages:[...new Set([...v,B])]}));const H=()=>{const q=B*c.cardsPerPage,N=q+c.cardsPerPage;return t.slice(q,N).length};Jf=setTimeout(()=>{T(l.formatMessage({id:`${u}ariaLive${typeof k=="string"?"":"_slide"}`},{direction:l.formatMessage({id:`${u}${typeof k=="string"?k:"next"}`}),slide:typeof k=="string"?1:k+1,count:H()}))},500)},R=k=>{qu=k.touches[0].clientX},L=k=>{if(qu===null)return;const B=k.touches[0].clientX,H=qu-B;H>5?F("next"):H<-5&&F("previous"),qu=null},P={"--width":`${S||0}px`,"--total-cards":C,"--cards-per-page":f,"--page":E};if(p)return h.jsx(Jc,{layout:`carousel${i?"-with-title":""}`});const I=(k,B)=>{var q;let H=null;return(q=k==null?void 0:k.sys)!=null&&q.id?H=`card-${k.sys.id}`:k!=null&&k.slug?H=`card-${k.slug}`:[n[B],k.contentType].includes("customCard")&&(H=`card-${window.btoa(`${k.title} ${k.createdAt}`)}-${B}`),H};return h.jsxs("section",{ref:x,className:ee("carousel-wrapper",a),"data-testid":"carousel",children:[h.jsx(Sie,{id:e,title:i}),h.jsx("ul",{className:"carousel",onTouchStart:R,onTouchMove:L,style:P,"data-testid":"carousel-list",children:t.map((k,B)=>{let H=I(k,B);const{inView:q,isLoaded:N}=Aie(B,f,E,v);return H&&(q||N)?h.jsx(A0,{id:H,card:{...k,contentType:n[B]},buildCardData:r,gtmContext:s,meta:{isTabbable:q},...o},H):(H=H||`${e}-card-${B}`,h.jsx(sr,{element:"li",className:"card-wrapper","data-testid":"card-placeholder"},H))})}),_<=1?null:h.jsxs(h.Fragment,{children:[h.jsxs("ul",{className:"controls","data-testid":"carousel-controls",children:[h.jsx("li",{className:"arrow previous",children:h.jsx(Me,{variant:"secondary",size:"large",icon:{icon:"chevron_left"},onClick:k=>{k.preventDefault(),k.stopPropagation(),F("previous")},screenreaderText:l.formatMessage({id:`${u}previousSlide`}),disabled:E<=0})}),[...Array(_)].map((k,B)=>h.jsx("li",{"data-testid":"carousel-controls-button",children:h.jsx("button",{className:ee("page-indicator",{selected:B===E}),onClick:H=>{H.preventDefault(),H.stopPropagation(),F(B)},children:h.jsx(ot,{showOnFocus:!1,children:l.formatMessage({id:`${u}slide`},{number:B+1,total:_})})})},`page-indicator-${B}`)),h.jsx("li",{className:"arrow next",children:h.jsx(Me,{variant:"secondary",size:"large",icon:{icon:"chevron_right"},onClick:k=>{k.preventDefault(),k.stopPropagation(),F("next")},screenreaderText:l.formatMessage({id:`${u}nextSlide`}),disabled:E>=_-1})})]}),h.jsx(ot,{"aria-live":"polite",showOnFocus:!1,children:b})]})]})},Die=({carousels:e=[],isLoading:t,title:n,className:r="",...i})=>!e||!e.length?null:e.map(({title:a,viewAllUrl:s,cards:o,cardsTypes:l},u)=>{const c=a?window.btoa(a):`carousel-${u}`,d=u===e.length-1;return t?h.jsxs(y.Fragment,{children:[h.jsx(Jc,{layout:`carousel${a?"-with-title":""}`,"data-testid":"carousel-placeholder"}),d?null:h.jsx(Tr,{})]},`placeholder-${c}`):h.jsxs(y.Fragment,{children:[h.jsx(kie,{cards:o,cardTypes:l,title:n!=null&&n.hidden?{}:{...n,text:a,link:s},...i}),d?null:h.jsx(Tr,{})]},`carousel-${c}`)});const Oie=({element:e="div",className:t="",card:n,gtmContext:r="NarrowCard"})=>{const{banner:i,title:a,text:s,isPrivate:o,slug:l}=n;let u={};return l&&(u={onClick:d=>{l&&(d.preventDefault(),d.stopPropagation(),window.location.href=l)},tabIndex:"0","data-gtm-event-context":`${r}-NarrowCard`,"data-gtm-event-type":`${r}-click`}),y.createElement(e,{className:ee("narrow-card",t,{"has-link":l,"gtm-trackable":l,"no-link":!l}),...u,children:h.jsxs(h.Fragment,{children:[h.jsx("div",{className:ee("img",{private:o,"no-image":!i}),children:i&&h.jsx(Zi,{image:i})}),h.jsxs("div",{className:"content",children:[a&&h.jsx("p",{className:"title text-medium",children:a}),s&&h.jsx("p",{className:"text text-medium",children:s})]})]})})};const Nie=({element:e="p",data:{timeLeftToFinish:t,percentageCompleted:{inTime:n=0,inLessons:r=0},shouldShowTimes:i=!0},graph:a,styling:s={},className:o=""})=>{const l=he.useIntl();let u=i?n:r;u>99?u=100:u<1&&(u=0);const{highlightPercentage:c=!1}=s;return y.createElement(e,{className:ee("course-progression",o,{"highlight-percentage":c,"has-circle-graph":a==="circle"}),children:h.jsxs(h.Fragment,{children:[h.jsx(Tp,{progress:u,styling:{layout:a||"bar",size:a&&a==="circle"?"small":"default"}}),h.jsx("span",{className:"percentage",children:l.formatMessage({id:"courseProgression_done"},{percent:d=>h.jsx("strong",{children:d}),number:u})}),u<100&&i&&h.jsx(j1,{time:t,appendedText:l.formatMessage({id:"courseProgression_timeLeft"})})]})})};const F3=({element:e="span",sectionId:t,subsectionId:n,title:r,className:i=""})=>y.createElement(e,{className:ee("lesson-name",i),"data-number":`${t}.${n}`,children:r});const B3=({size:e="default",completionTime:t,icon:n,optional:r,type:i,children:a})=>{const s=he.useIntl(),o=Zc(`lessonType_${i}`)?s.formatMessage({id:`lessonType_${i}`}):r4(i||"");return h.jsxs("small",{className:ee("content-type",{[e]:e!=="default"}),children:[h.jsx("span",{className:ee("type",n),children:o})," ",t>0&&!r&&h.jsx(j1,{time:t})," ",a?h.jsx("span",{className:"additional",children:a}):null]})};const Iie=({course:{articles:e,canAccessCourse:t,description:n,hideTimes:r,isEnrolled:i,sectionId:a,sectionTime:s,slug:o,timeLeft:l,title:u},quizScores:c})=>{const d=he.useIntl(),f="courseStructure_",p=u.toLowerCase().includes("course conclusion");return h.jsxs(Qc,{className:"course-structure",label:h.jsxs(h.Fragment,{children:[h.jsxs("small",{children:[d.formatMessage({id:`${f}section${p?"_end":""}`},{number:a})," ",!r&&s>=0&&h.jsx("span",{className:"time",children:i&&l===0?d.formatMessage({id:`${f}time_completed`}):h.jsx(j1,{time:s,appendedText:i?d.formatMessage({id:`${f}time_left`}):""})})]}),h.jsx("h3",{children:u})]}),shouldAnimate:!0,children:[h.jsx("p",{children:n}),h.jsx("ol",{children:e&&e.length>0&&e.map(({completed:g,completionTime:m,contentType:E,icon:v,image:b,isIntroduction:T,optional:C,slug:_,subsectionId:x,title:S,type:F})=>{const R=i&&t||T,L={};return b&&(L.style={"--image":`url(${b})`}),h.jsx("li",{className:ee({article:E===Do.ARTICLE,discussion:E===Do.DISCUSSION,quiz:E===Do.QUIZ,completed:g&&E===Do.ARTICLE,locked:!R}),...L,children:h.jsx(Qi,{href:R?`/microcourses/en/${o}/${_}`:void 0,fallbackElement:"span",className:"inner",gtmContext:`MicrocourseOutline${n4(S)}`,gtmType:"article-click",children:h.jsxs(h.Fragment,{children:[h.jsx(F3,{sectionId:a,subsectionId:x,title:S,className:"course-title"})," ",h.jsx(B3,{completionTime:m,icon:v,optional:C,type:F,children:c&&c[_]&&h.jsx("span",{className:"quiz-score",children:`${c[_]}%`})})]})})},_)})})]})};const Pie=({isComplete:e=!1,onClick:t,...n})=>{const r=he.useIntl();return n["data-gtm-event-context"]||(n["data-gtm-event-context"]="LessonIntroduction"),h.jsx(Me,{...n,variant:"tertiary",icon:e?{icon:"check-inside-circle_no-overlap_inverted"}:{icon:"check-inside-circle_no-overlap",hover:"check-inside-circle_no-overlap_inverted"},onClick:t,className:ee("mark-complete-button center gtm-trackable",{completed:e}),"data-gtm-event-type":"mark-as-complete",disabled:e,children:r.formatMessage({id:`markCompleteButton${e?"_completed":""}`})})},Rie=({id:e,data:{jobTitle:t,name:n,organization:r,thumbnail:i}})=>({id:e,name:n,jobTitle:t,organization:r,image:{thumbnail:i}}),zy=[{contentType:"solutionArticle",banner:{description:"",url:"//images.ctfassets.net/txbhe1wabmyx/kCcBdXurt3uOKu6NdTPm0/1b6d19179b21f98dbdadf2477c03d267/devin-avery-7gwqj0yyrhm-unsplash.jpg",width:295,height:180,type:"image/jpeg",aspect:"responsiveCard",query:"w=295&h=180&fit=thumb&f=center"},slug:"why-public-servants-must-learn-to-fail",contributors:["community"]},{contentType:"solutionArticle",banner:{description:"",url:"//images.ctfassets.net/txbhe1wabmyx/12Y0W1K0zVcDKzgLZlbfyC/6eb0757a02cbeea19b1b42d7da04d553/ashkan-forouzani-m0l9nbcivuk-unsplash.jpg",width:295,height:180,type:"image/jpeg",aspect:"responsiveCard",query:"w=295&h=180&fit=thumb&f=center"},slug:"organisational-culture-change-and-failure",contributors:[{name:"Mari-Liis",id:"bdb7509c-89ed-4633-8bc0-dbf11f5d9be1"}]},{contentType:"solutionArticle",banner:{description:"",url:"//images.ctfassets.net/txbhe1wabmyx/26TEwu0xVkbQDguuW89fY6/d54ce406cdd652d68979770d526398ab/nik-shuliahin-bunwp1bl0nc-unsplash.jpg",width:295,height:180,type:"image/jpeg",aspect:"responsiveCard",query:"w=295&h=180&fit=thumb&f=center"},slug:"how-to-learn-from-failure-without-causing-a-scandal",contributors:["community"]}];const Wu="notFoundError_",Fie=()=>{const e=he.useIntl(),t=[];return zy.forEach((n,r)=>{n.title=e.formatMessage({id:`${Wu}post_${r+1}`}),t.push("solutionArticle")}),h.jsxs(w3,{styling:{background:"bold",circle:"small",variant:"alt-2"},additionalContent:{appended:h.jsxs(ea,{children:[h.jsx(R3,{cards:zy,cardTypes:t,buildCardData:n=>new Promise((r,i)=>{r(n)})}),h.jsx(Me,{href:"/solution-articles/",children:e.formatMessage({id:`${Wu}cta`})})]})},reportError:()=>{},className:"not-found-error",children:[h.jsx("h1",{children:e.formatMessage({id:`${Wu}title`})}),h.jsx("p",{children:e.formatMessage({id:`${Wu}text`})})]})};exports.ASSETS_URL=qr;exports.ActionBar=UT;exports.ActionButton=Es;exports.ActivitiesFeed=R6;exports.ActivitySection=iie;exports.ActivityType=Ws;exports.AddPost=x0;exports.Badge=w4;exports.BadgeScope=ln;exports.Badges=A4;exports.BadgesContext=gp;exports.BadgesProvider=g4;exports.Banner=pie;exports.BannerSection=vie;exports.Breadcrumbs=qR;exports.Buckets=Px;exports.Button=Me;exports.ButtonWrapper=zs;exports.COURSE_CONTENT_TYPES=Do;exports.CacheProvider=v4;exports.Card=A0;exports.CardBlock=R3;exports.Carousel=Die;exports.CharacterLimit=Fp;exports.Checkbox=Bp;exports.CollapsibleSection=Qc;exports.Columns=WT;exports.CommunityDetails=t6;exports.ConnectionCta=S4;exports.ConnectionDirectionType=bp;exports.ConnectionStatusType=yp;exports.ContactFooter=aF;exports.ContactForm=IT;exports.ContentTypeLabel=d4;exports.Contributors=_p;exports.ConversationContext=L1;exports.CookieBanner=KT;exports.CourseProgression=Nie;exports.CourseStructure=Iie;exports.CustomContentBanner=Eie;exports.CustomEvents=Yt;exports.DELETED_USER_ID=il;exports.Directory=uie;exports.DiscussionContentType=Ke;exports.DiscussionConversation=k3;exports.DiscussionForm=Ml;exports.DiscussionFormCard=O3;exports.DiscussionFormModal=P3;exports.DiscussionPost=Ll;exports.DiscussionThread=I3;exports.DiscussionType=$t;exports.Divider=Tr;exports.DownloadSection=tF;exports.EMAILS=us;exports.EditSection=rF;exports.EmailHelperTextBox=eb;exports.EmptyStateBox=Wr;exports.EnrichedUrl=cm;exports.FeatureFlags=y4;exports.Filters=zT;exports.FlagsProvider=E4;exports.Footer=fm;exports.Form=Cr;exports.Formatting=ne;exports.Fragment=Zn;exports.FullWidthSection=ea;exports.GET_STREAM_USER_PREFIX=nh;exports.GlobalProviders=zx;exports.Header=T0;exports.HelperTextBox=h4;exports.HiddenFromScreenReaders=Yc;exports.HideShowTextBox=p4;exports.HighlightSection=bie;exports.HighlightedTextBox=Ln;exports.INVALID_TOKEN=i4;exports.IconBulletedList=Bx;exports.ImageContainer=Dx;exports.IntlProvider=b4;exports.InviteForm=PT;exports.InviteModal=sie;exports.JoinButton=Sp;exports.Label=Ic;exports.LanguageContext=vp;exports.LanguageSwitcher=VR;exports.LessonName=F3;exports.LessonType=B3;exports.LikesButton=Q4;exports.LikesFeed=$T;exports.LikesModal=jT;exports.Link=Qi;exports.LoadMore=xl;exports.LoadingBlock=k4;exports.LoadingPlaceholder=sr;exports.LoadingState=Jc;exports.Logo=dm;exports.LogoSection=iF;exports.MEMBERS_PER_PAGE=A3;exports.MENTION_REGEX=a4;exports.MarkCompleteButton=Pie;exports.MarkdownText=ka;exports.MarketingBlock=Tie;exports.Marks=Mr;exports.Member=pi;exports.MembersList=S3;exports.Modal=Cp;exports.MoreMenu=Rc;exports.NUMBER_OF_COUNTRIES=ux;exports.NUMBER_OF_USERS=lx;exports.NarrowCard=Oie;exports.NavigationMenu=qT;exports.NotFoundError=Fie;exports.Overlay=Ti;exports.OverlayContext=Ep;exports.OverlayProvider=C4;exports.PageHeading=x4;exports.PageLayout=w3;exports.Password=tb;exports.PasswordForm=gR;exports.PasswordRules=sb;exports.Pill=$r;exports.Poll=D3;exports.Popover=c4;exports.Portal=qs;exports.ProfileForm=RT;exports.ProfileImageChange=NT;exports.ProfileModal=$1;exports.ProfileModalLauncher=w0;exports.ProfilePicture=bi;exports.ProgressBar=Tp;exports.ProgressTracker=Nx;exports.PublishArticleForm=yR;exports.Rating=W6;exports.RepliesFeed=LT;exports.ResponsesHeading=N3;exports.ResponsiveImage=Zi;exports.ResultsVisibility=Kc;exports.ReturnToNavButton=Ix;exports.RichTextEditor=um;exports.STORAGE_KEYS=hp;exports.SearchForm=BT;exports.ShareLink=HT;exports.ShareLinks=XR;exports.ShowEmail=cie;exports.SignupForm=wR;exports.Span=sh;exports.StatusBanner=Ds;exports.TableOfContents=hie;exports.Tabs=JR;exports.Tags=Sre;exports.TestimonialBlock=fie;exports.TimeToComplete=j1;exports.Toggle=pR;exports.Tooltip=Fa;exports.TopLevelPage=sF;exports.UUID_V4_REGEX=al;exports.UserContext=Mt;exports.UserProvider=T4;exports.VisuallyHidden=ot;exports.addAriaProps=U4;exports.basicReducer=Us;exports.camelCaseToDashCase=t4;exports.checkIntlPathExists=Zc;exports.constructActivityContent=G4;exports.courseDiscussionRepliesFeedMock=B6;exports.enrichPostCategories=C0;exports.generateConditions=tc;exports.generateCssIcon=cx;exports.getActivityPollOptions=Op;exports.getAuthorData=Vs;exports.getCharacterLimitProps=J4;exports.getLongDate=pp;exports.getMember=e1;exports.getPostBody=_0;exports.getShortDate=s4;exports.getValueLength=t1;exports.headerData=As;exports.likesResponseMock=UR;exports.mapGetStreamData=Rie;exports.pageReady=o4;exports.passwordValidator=ih;exports.repliesFeedMock=F6;exports.toCamelCase=n4;exports.toCapitalisedCase=ox;exports.toSentenceCase=r4;exports.transformSlugs=dh;exports.useActivitiesFeed=X4;exports.useAutoResize=Gy;exports.useBadges=m4;exports.useCurrentPath=Yy;exports.useEffectAfterMount=ks;exports.useElementWidth=Yi;exports.useHomepagePath=cp;exports.useOverlay=_4;exports.useScrollListener=Xy;exports.useScrollToHash=dp;exports.useTooltips=fp;exports.useUser=Xc;
|
package/index.mjs
CHANGED
|
@@ -24774,7 +24774,7 @@ const pR = {
|
|
|
24774
24774
|
dataToSubmit: s = { ref: "sign-up-form" },
|
|
24775
24775
|
...o
|
|
24776
24776
|
}) => {
|
|
24777
|
-
const l = Ee(), u = window.location.pathname.includes("/signup") ? "/login" : `/login?returnTo=${window.location.pathname}`, {
|
|
24777
|
+
const l = Ee(), u = window.location.pathname.includes("/signup") ? "/login" : `/login?returnTo=${window.location.pathname + window.location.search}`, {
|
|
24778
24778
|
title: c = !0,
|
|
24779
24779
|
expectation: d = !1,
|
|
24780
24780
|
url: f = !0,
|
|
@@ -46126,7 +46126,7 @@ const xt = {
|
|
|
46126
46126
|
_ = `${C === "topics" ? `${C}-` : ""}${T[T.length - 1]}`;
|
|
46127
46127
|
}
|
|
46128
46128
|
p = {
|
|
46129
|
-
href: s ? s(l.href) : l.withReturnTo ? `${l.href}?returnTo=${window.location.pathname}` : l.href
|
|
46129
|
+
href: s ? s(l.href) : l.withReturnTo ? `${l.href}?returnTo=${window.location.pathname + window.location.search}` : l.href
|
|
46130
46130
|
}, c && (p = {
|
|
46131
46131
|
...p,
|
|
46132
46132
|
className: "gtm-trackable",
|