@apolitical/component-library 4.4.0 → 4.4.1-4581.5

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.
@@ -5,6 +5,10 @@ export interface IShouldShowProps {
5
5
  logInButton?: boolean;
6
6
  successMessage?: boolean;
7
7
  }
8
+ export interface IOnSuccessProps {
9
+ jobTitle: string;
10
+ organization: string;
11
+ }
8
12
  interface ISignupForm {
9
13
  className?: string;
10
14
  labels?: {
@@ -14,18 +18,19 @@ interface ISignupForm {
14
18
  expectation?: string;
15
19
  };
16
20
  functions: {
17
- validateEmail: () => Promise<any>;
21
+ validateEmail: (email: string) => Promise<any>;
18
22
  createAccount: (arg: any) => Promise<any>;
19
- onSuccess?: () => void;
23
+ onSuccess?: (arg?: IOnSuccessProps) => void;
24
+ onCatch?: (arg?: string) => void;
20
25
  handleError: (error: string) => void;
21
26
  /** Callback function to resend verification code (used when user already signed up but not verified) */
22
- resendVerificationCode: () => void;
27
+ resendVerificationCode: (email: string) => Promise<unknown>;
23
28
  };
24
29
  shouldShow: IShouldShowProps;
25
30
  dataToSubmit: {
26
31
  [key: string]: string;
27
32
  };
28
- submitButton: string;
33
+ submitButton?: string;
29
34
  }
30
35
  declare const SignupForm: ({ className, labels, placeholders, functions, shouldShow: shouldShowProps, submitButton, dataToSubmit, ...props }: ISignupForm) => import("react/jsx-runtime").JSX.Element;
31
36
  export default SignupForm;
package/index.js CHANGED
@@ -129,7 +129,7 @@ ${u}
129
129
  `:""}`;case o[Z.paragraph]:return`${u}
130
130
 
131
131
  `;case o[Z.hr]:return`---
132
- `;default:return u}}function Nn(e,t){const n=e.trim(),r=n,a=`${t}${r}${ql(t)}`;if(r.length===e.length)return a;const i=t+r+ql(t);return e.replace(n,i)}const ql=e=>e.split("").reverse().join(""),bC=e=>e.map(t=>gf(t)).join("").trim();const yC=()=>{const e=An(),{dispatch:t,mentionPopover:n,id:r}=C.useContext(Kt),{show:a,selectedUser:i,possibleUsers:s}=n,o=Jd(e,"mention-popover",`toolbar-${r}`);return!a||!s.length?null:d.jsx(Is,{children:d.jsx(Ic,{ref:o,className:"mention-popover",onKeyDown:l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),t([{type:"showMentionPopover",value:!1}]))},children:d.jsx("ul",{children:s.map(({userId:l,user:u},c)=>d.jsx(nr,{element:"li",className:Y({selected:c===i}),member:{id:l,...u,link:!1},functions:{onClick:f=>{f.preventDefault(),f.stopPropagation();const p={...n,selectedUser:c};t([{type:"mentionPopover",value:p}]),pf(e,p,t,r)}}},l))})})})},po=({id:e,active:t,hasDivider:n=!1,callback:r,className:a="",children:i,...s})=>{const o=ue.useIntl(),l=An(),{id:u,tabbableOption:c,setFocus:f,openTooltip:p,dispatch:m}=C.useContext(Kt),g={};return e!==c&&(g.tabIndex=-1),d.jsxs("li",{id:`${u}-${e}`,className:Y(e,{"has-divider":n}),onMouseEnter:()=>{m([{type:"openTooltip",value:e}])},onMouseLeave:()=>{m([{type:"openTooltip",value:null}])},onFocus:()=>{m([{type:"openTooltip",value:e}])},onBlur:h=>{h.stopPropagation();const D=[{type:"openTooltip",value:null}];l.selection&&D.push({type:"lastAnchor",value:l.selection.anchor}),m(D)},contentEditable:!1,children:[d.jsxs("button",{...s,...g,className:Y(e,a,{active:t}),onClick:h=>{h.stopPropagation(),h.preventDefault()},onMouseDown:h=>{h.stopPropagation(),h.preventDefault(),r()},onKeyDown:h=>{var D,v,E,k;if(h.key!=="Tab")switch(h.key){case"Enter":h.stopPropagation(),h.preventDefault(),r();break;case"ArrowLeft":case"ArrowRight":h.stopPropagation(),h.preventDefault();const _=h.currentTarget.closest("li");let x=_==null?void 0:_.nextElementSibling;if(h.key==="ArrowLeft"){const z=_==null?void 0:_.previousElementSibling;z?x=z:x=(D=_==null?void 0:_.parentElement)==null?void 0:D.lastElementChild}else x||(x=(v=_==null?void 0:_.parentElement)==null?void 0:v.firstElementChild);const F=x==null?void 0:x.className.split(" ")[0];F&&(f(F),(E=x==null?void 0:x.querySelector("button"))==null||E.focus());break;default:const S=h.currentTarget.closest("fieldset");if(S){(k=S==null?void 0:S.previousElementSibling)==null||k.focus();break}}},children:[d.jsx(Re,{showOnFocus:!1,children:o.formatMessage({id:`richTextEditor_${e}`})}),d.jsx(kn,{id:`tooltip-${e}`,styling:{extraPadding:!1,hasPointer:"bottom"},isOpen:p===e,"aria-hidden":!0,children:o.formatMessage({id:`richTextEditor_${e}`})})]}),i]})},Wl=[Z.ol,Z.ul],vf=(e,t)=>{const{selection:n}=e;if(!n)return!1;const[r]=Array.from(b.nodes(e,{at:b.unhangRange(e,n),match:a=>{const i=a;return!b.isEditor(a)&&ce.isElement(a)&&i.type===t}}));return!!r},DC=e=>{const[t]=b.nodes(e,{match:n=>n.type===Z.blockquote});return!!t},bf=(e,t,n)=>{try{const r=DC(e),a=vf(e,t),i=Wl.includes(t);Q.unwrapNodes(e,{match:l=>{const u=l;return!b.isEditor(u)&&ce.isElement(u)&&Wl.includes(u.type)},split:!0});const o={type:a?Z.paragraph:i?Z.li:t};if(Q.setNodes(e,o),i)if(a){const{selection:l}=e;if(!l)return;const[u,c]=b.parent(e,l,{edge:"end"});Array.from(b.nodes(e,{at:c,match:p=>{const m=p;return!b.isEditor(p)&&ce.isElement(p)&&m.type===Z.li}})).forEach(([p,m])=>{oe.string(p).trim()===""&&Q.removeNodes(e,{at:m})})}else{if(r){const u={type:Z.blockquote,children:[]};Q.wrapNodes(e,u)}const l={type:t,children:[]};Q.wrapNodes(e,l)}}catch(r){const a=r.message;n(`Error toggling block: ${a}`)}},CC=({format:e,hasDivider:t=!1})=>{const{setFocus:n,reportError:r}=C.useContext(Kt),a=An(),i=vf(a,e);return d.jsx(po,{id:e,active:i,hasDivider:t,callback:()=>{bf(a,e,r),n(i?null:e)}})},xr=e=>{const[t]=b.nodes(e,{match:n=>{const r=n;return!b.isEditor(n)&&ce.isElement(n)&&r.type===Z.link}});return!!t},xC=(e,t,n,r)=>{e.selection&&go(e,t,n,r)},wC=(e,t,n,r)=>{const{selection:a}=e;if(a&&V.isCollapsed(a)){const[s]=b.nodes(e,{match:o=>{const l=o;return!b.isEditor(o)&&ce.isElement(o)&&l.type===Z.link}});if(s){const[o,l]=s,u={link:t};Q.setNodes(e,u,{at:l}),mo(n)}}else go(e,t,n,r)},go=(e,t,n,r=a=>{console.error(a)})=>{try{xr(e)&&yf(e);const{selection:a}=e,i=a&&V.isCollapsed(a),s={type:Z.link,link:t,children:i?[{text:t}]:[]};i?(Q.insertNodes(e,s),Q.move(e,{distance:1,unit:"offset"})):(Q.wrapNodes(e,s,{split:!0}),Q.collapse(e,{edge:"end"}),Q.insertNodes(e,{text:""}),Q.move(e,{distance:1,unit:"offset"})),mo(n)}catch(a){const i=a.message;r(`Error in wrapLink: ${i}`)}},yf=e=>{Q.unwrapNodes(e,{match:t=>{const n=t;return!b.isEditor(t)&&ce.isElement(t)&&n.type===Z.link}})};let Pi=null;const EC=()=>{const e=ue.useIntl(),t="richTextEditor_link_",{id:n,showLinkEditor:r,dispatch:a,reportError:i}=C.useContext(Kt),s=An(),o=$y(s),l=(o==null?void 0:o.text)||mC(s),[u,c]=C.useState(xr(s)),f=Jd(s,"link-editor",`${n}-link`),p=C.useRef(null);C.useEffect(()=>{var D;!u&&r&&((D=p.current)==null||D.focus())},[u]),C.useEffect(()=>{Pi&&clearTimeout(Pi),Pi=setTimeout(()=>{c(xr(s))},500)},[s.selection]);const m=[],g=["open","edit","remove"].map(D=>{const v={variant:"tertiary",size:"small",children:e.formatMessage({id:`${t}${D}`},{link:o==null?void 0:o.pretty})};switch(m.push({className:D}),D){case"open":v.href=(o==null?void 0:o.full)||"",v.onClick=E=>{E.preventDefault(),E.stopPropagation(),window.open((o==null?void 0:o.full)||"","_blank"),a([{type:"showLinkEditor",value:!1}])},v.children=d.jsxs(d.Fragment,{children:[v.children,d.jsx(Re,{children:e.formatMessage({id:`${t}${D}_text`})})]});break;case"edit":v.onClick=()=>{c(!1)};break;case"remove":v.onClick=()=>{const E=[{type:"showLinkEditor",value:!1}];xr(s)&&(yf(s),E.push({type:"lastAnchor",value:null})),a(E)};break}return v}),h=[{id:"url",type:"url",inputRef:p,label:e.formatMessage({id:`${t}url`}),placeholder:e.formatMessage({id:`${t}placeholder`}),value:(o==null?void 0:o.full)||"",validation:[{condition:"required",error:e.formatMessage({id:`${t}error_required`})},{condition:"valid-url"}],submitOnEnter:!0,autoFocus:!0}];return l&&h.unshift({component:()=>d.jsxs("p",{children:[d.jsx("strong",{"aria-label":e.formatMessage({id:`${t}text_aria`}),children:e.formatMessage({id:`${t}text`})})," ",l]})}),d.jsx(Is,{children:d.jsx(kn,{ref:f,className:"link-editor",isOpen:r,styling:{extraPadding:!1,hasForm:!u},functions:{onBlur:()=>{a([{type:"showLinkEditor",value:!1}])}},callbacks:{onOpen:()=>{setTimeout(()=>{var D;return(D=p.current)==null?void 0:D.focus()})}},children:u?d.jsx(_n,{wrappers:m,buttons:g}):d.jsx(rr,{element:"fieldset",id:`${n}-link-editor`,className:Y({"show-labels":l}),meta:{shouldReset:!0,showRequiredLabels:!1},functions:{onSuccess:async D=>{setTimeout(()=>{const v=[{type:"showLinkEditor",value:!1}];if(D.url){const{full:E}=Mc(D.url);o!=null&&o.full?wC(s,E,n,i):xC(s,E,n,i),v.push({type:"lastAnchor",value:null})}a(v)})}},fields:h,button:{text:e.formatMessage({id:`${t}button`}),variant:"tertiary",size:"small"}})})})},kC=()=>{const e=An(),{setFocus:t,dispatch:n}=C.useContext(Kt),[r,a]=C.useState(!1);return C.useEffect(()=>{a(xr(e))},[e.selection]),d.jsx(po,{id:"link",active:r,hasDivider:!0,callback:()=>{n([{type:"showLinkEditor",value:!0}]),t(r?null:"link"),a(!0)}})},_C=e=>[Z.bold,Z.italic,Z.strikethrough].includes(e),Df=(e,t)=>{const n=b.marks(e);return n?n[t]===!0:!1},Cf=(e,t,n)=>{try{Df(e,t)?b.removeMark(e,t):b.addMark(e,t,!0)}catch(r){const a=r.message;n(`Error toggling mark: ${a}`)}},BC=({format:e,hasDivider:t=!1})=>{const{setFocus:n,reportError:r}=C.useContext(Kt),a=An(),i=Df(a,e);return d.jsx(po,{id:e,active:i,hasDivider:t,callback:()=>{Cf(a,e,r),n(i?null:e)}})},Aa=[Z.bold,Z.italic,Z.strikethrough],AC=[Z.ol,Z.ul,Z.blockquote];const FC=({...e})=>{const t=ue.useIntl(),{id:n}=C.useContext(Kt);return d.jsxs(d.Fragment,{children:[d.jsxs("fieldset",{id:`toolbar-${n}`,className:"toolbar",...e,children:[d.jsx(Re,{element:"legend",showOnFocus:!1,children:t.formatMessage({id:"richTextEditor_toolbar"})}),d.jsxs("ul",{children:[Aa.map((r,a)=>d.jsx(BC,{format:r,hasDivider:a===Aa.length-1},r)),d.jsx(kC,{}),AC.map((r,a)=>d.jsx(CC,{format:r,hasDivider:a===1},r))]})]}),d.jsx(EC,{})]})};var TC=PC,SC=/^(?:\w+:)?\/\/(\S+)$/,jC=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,OC=/^[^\s\.]+\.\S{2,}$/;function PC(e){if(typeof e!="string")return!1;var t=e.match(SC);if(!t)return!1;var n=t[1];return n?!!(jC.test(n)||OC.test(n)):!1}const NC=En(TC),RC=(e,t,n)=>{const{insertText:r,isInline:a}=e;try{e.isInline=i=>{const s=i;return[Z.link].includes(s.type)||a(i)},e.insertText=i=>{i&&NC(i)?go(e,i,t):r(i)}}catch(i){const s=i.message;n(`Error in withInlines: ${s}`)}return e},MC=(e,t)=>{const{isInline:n,isVoid:r,markableVoid:a}=e;try{e.isInline=i=>i.type===Z.mention?!0:n(i),e.isVoid=i=>i.type===Z.mention?!0:r(i),e.markableVoid=i=>i.type===Z.mention||a(i)}catch(i){const s=i.message;t(`Error in withMentions: ${s}`)}return e},IC=(e,t)=>{const{normalizeNode:n}=e;try{e.normalizeNode=([r,a])=>{if(r.type===Z.link&&oe.string(r).trim()===""){Q.removeNodes(e,{at:a});return}n([r,a])}}catch(r){const a=r.message;t(`Error in withoutEmptyLinks: ${a}`)}return e};const xf=({id:e="rich-text-editor",value:t,placeholder:n,maxLength:r=0,functions:a,autoFocus:i=!0,data:s,...o})=>{const l=ue.useIntl(),u=Ph(),{listMembers:c,onChange:f=()=>{},reportError:p=R=>{console.error(R)}}=a||{},m=[{type:Z.paragraph,children:[{text:""}]}],g={editorKey:null,originalValue:t||"",initialValue:t?null:m,tabbableOption:Aa[0],openTooltip:null,showLinkEditor:!1,mentionPopover:{show:!1,selectedUser:0,possibleUsers:[],position:null},lastAnchor:null,stringValue:"",lastKey:null,hasInteracted:!1,hasLoaded:!1},[h,D]=C.useReducer(Nr,g),{editorKey:v,originalValue:E,initialValue:k,stringValue:_,lastAnchor:x,lastKey:F,hasInteracted:S,hasLoaded:z,mentionPopover:N}=h,$=R=>{const W=R||Aa[0];R&&D([{type:"tabbableOption",value:W}])},I=`rte-${e}`,w=C.useCallback(R=>d.jsx(My,{...R}),[]),A=C.useCallback(R=>d.jsx(Iy,{...R}),[]),T=C.useMemo(()=>RC(MC(IC(Ev(Ny(xv())),p),p),I,p),[]);C.useEffect(()=>{if(!t)return;kr.lastIndex=0;const R=t.match(kr);!R||R.length>1||R[0].length!==t.length||S||D([{type:"originalValue",value:t}])},[t]),C.useEffect(()=>{E&&(async()=>{let W=gn(E);W.includes("<")&&(W=new Ca().turndown(W)),s&&s.mentions&&(W=await Rc({text:W,template:`[${Es}{{name}}]({{id}})`,mentions:s.mentions,listMembers:c||(()=>Promise.resolve([]))})),hC(W,X=>{D([{type:"initialValue",value:X},{type:"editorKey",value:E.toString()}]),setTimeout(()=>{D([{type:"stringValue",value:$l(T)}])},150)})})()},[E]),C.useEffect(()=>{if(T.children.length>0&&!z){if(D([{type:"hasLoaded",value:!0}]),!i)return;const R=b.end(T,[]);Q.select(T,R),J.focus(T)}},[T.children.length,k]),C.useEffect(()=>{t!==""||!T||bc(E,t)&&!S||(b.withoutNormalizing(T,()=>{Q.delete(T,{at:{anchor:b.start(T,[]),focus:b.end(T,[])}}),Q.deselect(T),T.children.length!==0&&Q.unwrapNodes(T,{at:[0]}),Q.insertNodes(T,m,{at:[0]})}),D([{type:"initialValue",value:m},{type:"lastAnchor",value:null}]))},[t]);const M=wc(()=>{gC(T,N.show,c,D)},100);return k?d.jsx("div",{id:I,className:"rich-text-editor",children:d.jsxs(Kt.Provider,{value:{...h,id:I,setFocus:$,dispatch:D,reportError:p},children:[d.jsxs(Oy,{editor:T,initialValue:k,onChange:R=>{if(T.operations.some(X=>X.type!=="set_selection")){const X=bC(R);f(X),D([{type:"stringValue",value:$l(T)}]),S||D([{type:"hasInteracted",value:!0}]),M(),u&&console.log({serialized:X,json:R})}},...o,children:[d.jsx(Ey,{className:"input",renderElement:w,renderLeaf:A,placeholder:n||l.formatMessage({id:"richTextEditor_placeholder"}),autoFocus:i,tabIndex:0,onKeyDown:R=>{if(R.key==="Enter"){N.show&&(R.preventDefault(),R.stopPropagation(),pf(T,N,D,I));const{selection:W}=T;if(W){const X=V.isCollapsed(W),[G,y]=b.node(T,W,{depth:1});let H=G,te=H.type;const B=H.children[0];if(B&&[Z.ol,Z.ul].includes(B.type)&&(H=B,te=B.type),H&&ce.isElement(H)&&te!==Z.paragraph){if(te===Z.blockquote&&!R.shiftKey){R.stopPropagation(),R.preventDefault(),Q.insertNodes(T,m);return}if(X){const[j]=b.parent(T,W,{edge:"end"}),L=j.type;if(F==="Enter"&&L===Z.li&&[Z.ul,Z.ol].includes(te)){R.stopPropagation(),R.preventDefault(),Q.insertNodes(T,m,{at:P.next(y)}),Q.select(T,b.end(T,P.next(y)));return}}}}}else if(R.key==="Escape"){if(N.show){R.preventDefault(),R.stopPropagation(),D([{type:"mentionPopover",value:{...N,show:!1}}]);return}}else if(["ArrowUp","ArrowDown"].includes(R.key)&&N.show){R.preventDefault(),R.stopPropagation();const{selectedUser:W,possibleUsers:X}=N;let G=R.key==="ArrowUp"?W-1:W+1;G<0&&(G=X.length-1),G>=X.length&&(G=0),D([{type:"mentionPopover",value:{...N,selectedUser:G}}])}D([{type:"lastKey",value:R.key}]),pC(R,T,D,p)},onBlur:()=>{T.selection&&D([{type:"lastAnchor",value:T.selection.anchor}])},onFocus:()=>{if(x){if(!P.isPath(x.path)||!oe.has(T,x.path))return;const R=oe.get(T,x.path);let W=0;if(de.isText(R)?W=R.text.length:R.children&&(W=R.children.length),x.offset>W)return;try{Q.select(T,{anchor:x,focus:x})}catch(X){const G=X.message;p(`Error focusing editor: ${G}`)}}}}),d.jsx(FC,{}),c?d.jsx(yC,{}):null]},v),d.jsx(Ws,{limit:r,valueLength:Ha(_)})]})}):null};const $C=({id:e="form-toggle",label:t,options:n,initialValue:r,functions:{onChange:a=()=>{}},isDisabled:i=!1,className:s=""})=>{const[o,l]=C.useState(typeof r=="boolean"||typeof r=="string"?r:n[0].value);C.useEffect(()=>{r&&l(r)},[r]);const u=c=>{i||(l(c),a(c))};return d.jsxs("div",{className:Y("toggle",s),onClick:c=>{c.preventDefault(),c.stopPropagation(),u(o===n[0].value?n[1].value:n[0].value)},children:[d.jsx("p",{children:t}),d.jsx("ul",{className:Y("toggle-options",{disabled:i,on:o===n[1].value}),children:n.map(c=>{const f=`${e}-${c.value}`;return d.jsxs("li",{className:"hidden",children:[d.jsx("input",{type:"radio",id:f,name:e,value:c.value,checked:o===c.value,onChange:()=>u(c.value),disabled:i}),d.jsx("label",{htmlFor:f,children:c.label})]},f)})})]})};function LC({className:e="",userId:t,userName:n,src:r,setUserImage:a,uploadImage:i}){const[s,o]=C.useState(!1),[l,u]=C.useState(!1),c=C.useRef(null),f=async p=>{o(!0),u(!1);try{const m=p.target.files&&p.target.files[0];if(!m||!t)throw o(!1),new Error("Image file or userID is missing");const g=await i({fileObject:m,userId:t});a(h=>({...h,image:{thumbnail:g.thumbnailURL,full:g.originalURL}}))}catch{u(!0)}finally{o(!1)}o(!1)};return d.jsxs("div",{className:Y("profile-image-change-figure",e),children:[d.jsx(on,{className:"profile-image-change-picture",name:n,src:r,"data-testid":"profile-picture"}),l&&d.jsx("p",{className:"error text-small",children:d.jsx(ue.FormattedMessage,{id:"profile_image_change_error"})}),d.jsx("input",{id:"file",type:"file",accept:"image/*",ref:c,onChange:f,hidden:!0,"data-testid":"file-input"}),d.jsx(_e,{onClick:()=>c.current&&c.current.click(),variant:"secondary","data-gtm-event-context":"ImageField","data-gtm-event-type":`${r?"change-photo":"add-photo"}-click`,className:"gtm-trackable",disabled:s,children:d.jsx(ue.FormattedMessage,{id:s?"profile_image_change_uploading_text":r?"profile_image_change_cta_with_picture":"profile_image_change_cta_without_picture"})})]})}const wf=({gtm:e,functions:{onSuccess:t=async()=>{},onFailure:n=()=>{}}})=>{const{context:r="FooterContactUsForm",event:a="contact-form-submit-click"}=e||{};return d.jsx(rr,{id:"contact-us-form",fields:[{id:"name",type:"text",className:"short",validation:[{condition:"required"}]},{id:"email",type:"email",className:"short",validation:[{condition:"required"},{condition:"valid-email"}]},{id:"organisation",type:"text"},{id:"interests",type:"checkboxes",options:[{id:"publishingCourse",label:"Publishing or creating a course"},{id:"buyingCourse",label:"Buying courses for my team"},{id:"learningExperience",label:"Customised learning experiences"},{id:"somethingElse",label:"Something else"}]},{id:"message",type:"textarea",limit:1e3,validation:[{condition:"required"}]}],intlPath:"contactForm",gtm:{context:r,event:a},functions:{onSuccess:t,onFailure:n}})};const Ef=({title:e,label:t,ctaMessage:n,titleColor:r,labelColor:a,backgroundColor:i,onClose:s,reportError:o,sendInvites:l,initialFormStatus:u="NOT_SUBMITTED"})=>{const[c,f]=C.useState([]),[p,m]=C.useState(!0),[g,h]=C.useState(u),{formatMessage:D}=ue.useIntl(),v=async _=>{_.preventDefault();try{await l(c),f([]),h("SUCCESS")}catch(x){h("ERROR"),o(x)}},E=_=>{_.preventDefault(),h("NOT_SUBMITTED"),m(!0),f([])},k=_=>{_.preventDefault(),s(),h("CLOSED")};return g==="CLOSED"?null:g==="ERROR"||g==="SUCCESS"?d.jsxs("div",{className:"invite-form-wrapper",children:[d.jsx("div",{className:"content centred",children:g==="SUCCESS"?d.jsx("h2",{className:"success-title",children:D({id:"inviteForm_success"})}):d.jsxs("h2",{className:"error-title",children:[" ",D({id:"inviteForm_error"})]})}),d.jsx(nn,{}),d.jsx("div",{className:"footer",children:g==="SUCCESS"?d.jsxs(d.Fragment,{children:[d.jsx(_e,{variant:"secondary",onClick:E,children:D({id:"inviteForm_ctaSendMoreInvites"})}),d.jsx(_e,{onClick:k,children:D({id:"inviteForm_ctaDone"})})]}):d.jsx(_e,{onClick:E,children:D({id:"inviteForm_ctaTryAgain"})})})]}):d.jsx("div",{className:"invite-form-wrapper",children:d.jsxs("form",{style:{backgroundColor:i},onSubmit:v,className:Y("invite-form gtm-trackable"),children:[d.jsxs("fieldset",{className:"content",children:[d.jsx("h2",{className:"title",style:{color:r},children:e}),d.jsx("label",{htmlFor:"email-input",className:"label",style:{color:a},children:t}),d.jsx(Ch.ReactMultiEmail,{id:"email-input",inputClassName:"email-input input",placeholder:D({id:"inviteForm_email_placeholder"}),emails:c,onChange:_=>{f(_),m(!_.length)},autoFocus:!1,getLabel:(_,x,F)=>d.jsxs("div",{className:"email text-medium",children:[d.jsx("div",{"data-tag-item":!0,children:_}),d.jsx(_e,{variant:"tertiary",size:"small",icon:{icon:"close"},onClick:()=>{F(x),m(!c.length)},className:"remove-email-button",screenreaderText:D({id:"overlay_close"})})]},x)})]}),d.jsx(nn,{}),d.jsx("fieldset",{className:"footer",children:d.jsx(_e,{className:"sendEmailsButton",disabled:p,children:n})})]})})},ga=e=>e.map(t=>({condition:t})),Dt={FORM_ID:"manage-account-password-change",NEW_PASSWORD:"newPassword",CONFIRMED_PASSWORD:"confirmedPassword",CURRENT_PASSWORD:"oldPassword"},zC=({functions:e,...t})=>{const{formatMessage:n}=ue.useIntl(),[r,a]=C.useState(null),[i,s]=C.useState(!1),[o,l]=C.useState({isMoreThanEightCharacters:!1,includesNumberAndSymbol:!1,includesLowerAndUppercase:!1}),u=m=>m[Dt.NEW_PASSWORD]!==m[Dt.CONFIRMED_PASSWORD]?n({id:"passwordRules_unmatched_text"}):null,c=m=>!is(m[Dt.NEW_PASSWORD]).isValid,f=[{"data-testid":Dt.NEW_PASSWORD,id:Dt.NEW_PASSWORD,type:"password",autoComplete:"password",placeholder:"",label:n({id:"passwordRules_newPassword_label"}),validation:ga(["required",c]),functions:{onChange:m=>l(is(m).matchingRules),onFocus:()=>s(!0),onBlur:()=>s(!1)}},{"data-testid":Dt.CONFIRMED_PASSWORD,id:Dt.CONFIRMED_PASSWORD,type:"password",autoComplete:"password",placeholder:"",label:n({id:"passwordRules_confirmPassword_label"}),validation:ga(["required",u])}];t.isPasswordChange&&f.unshift({"data-testid":Dt.CURRENT_PASSWORD,id:Dt.CURRENT_PASSWORD,type:"password",placeholder:"",label:n({id:"passwordRules_currentPassword_label"}),validation:ga(["required"])}),i&&f.push({component:Jc,props:{matchingRules:o}});const p={id:Dt.FORM_ID,fields:f,functions:{...e,onSuccess:async m=>(e.createPassword(m),e.onSuccess&&e.onSuccess(m)),onCatch:m=>a(m==null?void 0:m.statusCode),onFailure:(m,g)=>{(g.includes(Dt.NEW_PASSWORD)||g.includes(Dt.CONFIRMED_PASSWORD))&&s(!0)}},meta:{shouldReset:!0},...t};return d.jsxs(d.Fragment,{children:[d.jsx(rr,{...p}),r&&d.jsx(sn,{variant:"error",text:r})]})};const kf=({id:e="search",className:t="",handleToggle:n=!1,defaultValue:r="",gtmContext:a="search-bar",gtmEvent:i="form-submission"})=>{const{searchIsOpen:s=!0,isDesktopVersion:o=!1}=n||{},l=ue.useIntl(),u=C.useRef(null);Vn(()=>{!n||o||!s||u.current&&u.current.focus()},[s]);const c=f=>{f.preventDefault(),f.stopPropagation(),!(!u.current||!u.current.value||u.current.value.length<1)&&(window.location.href=`/search?search=${encodeURIComponent(u.current.value)}`)};return d.jsx("form",{onSubmit:c,className:Y("search-form gtm-trackable",t),role:"search","data-gtm-event-context":a,"data-gtm-event-type":i,children:d.jsx("fieldset",{id:`${e}-form`,hidden:n?!s:!1,children:d.jsxs("p",{children:[d.jsx(Re,{element:"label",htmlFor:e,children:l.formatMessage({id:"search_label"})}),d.jsx("input",{ref:u,type:"search",id:e,name:e,defaultValue:r,placeholder:l.formatMessage({id:"search_placeholder"}),onKeyDown:f=>{f.key==="Enter"&&c(f)}}),d.jsx("button",{className:"clear",onClick:f=>{f.preventDefault(),f.stopPropagation(),u.current&&u.current.value&&(u.current.value="")},children:d.jsx(Re,{children:l.formatMessage({id:"search_clear"})})}),d.jsx("button",{className:"search",onClick:c,children:d.jsx(Re,{children:l.formatMessage({id:"search_cta"})})})]})})})},Hl=async({ref:e,validateEmail:t,dispatch:n})=>{const r=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;if(!e.current.validity.valid||!r.test(e.current.value))return n([{type:"validFields.email",value:!1}]);const a=e.current.value.toString().toLowerCase().trim(),i={valid:!1,autoApproved:!1,exists:{auth:!1,engagement:!1,registration:!1,user:!1}};let s=Object.assign({},i);try{s=await t(a),s===void 0&&(s=i)}catch{return n([{type:"shouldManuallyApprove",value:!0},{type:"emailDetails",value:{email:a,boxType:"nonGov",isEnd2End:!1}},{type:"validFields.email",value:!1}])}const{valid:o=!1,autoApproved:l=!1,exists:u}=s;let c="";return o?c=l?"gov":"nonGov":u.registration?u.engagement&&!u.user?c=u.auth?"verify":"pending":c="exists":u.auth&&(c="exists"),n([{type:"shouldDisableButton",value:!1},{type:"shouldManuallyApprove",value:!l},{type:"emailDetails",value:{email:a,boxType:c,isEnd2End:/testing\+[0-9]+@apolitical.co$/.test(a)}},{type:"validFields.email",value:!0}])},qC=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"]}},WC=async({refs:e,dataToSubmit:t,createAccount:n,onSuccess:r,dispatch:a,state:i})=>{if(!e.form||!e.form.current)throw new Error("No refs.form");if(!e.form.current.checkValidity()){e.hiddenValidation&&e.hiddenValidation.current&&e.hiddenValidation.current.click();return}const s=qC(new FormData(e.form.current)),o=Object.assign(s,t);await n(o),localStorage.setItem("email",s.email),r&&r({...s,...i.values}),a([{type:"showSuccessMessage",value:!0}])},HC=({shouldShow:e,placeholders:t,labels:n,functions:{validateEmail:r,resendVerificationCode:a},refs:i,state:s,dispatch:o,dataToSubmit:l,intl:u})=>{const{emailDetails:c}=s,f=(m,g)=>{m.current&&s.validFields[g]!==m.current.validity.valid&&o([{type:`validFields.${g}`,value:m.current.validity.valid}])},p=[{id:"full_name",type:"text",inputRef:i.name,placeholder:u.formatMessage({id:"signup_full_name_placeholder"}),functions:{onChange:()=>f(i.name,"name"),onFocus:()=>o([{type:"loadRecaptcha",value:!0}])},autoComplete:"name",validation:[{condition:"required"},{condition:"no-numbers"}],"data-testid":"signup-name-input"},{id:"email_address",type:"email",inputRef:i.email,placeholder:u.formatMessage({id:"signup_email_address_placeholder"}),functions:{onBlur:()=>{Hl({ref:i.email,validateEmail:r,dispatch:o})},onChange:(m,g)=>{o([{type:"shouldDisableButton",value:!0}]),g&&g({type:"updateValue",payload:{key:"terms",value:!1}})},onFocus:()=>o([{type:"loadRecaptcha",value:!0}])},autoComplete:"email",validation:[{condition:"required"},{condition:"valid-email"}],"data-testid":"signup-email-input"},{component:Kc,props:{email:c.email,type:c.boxType,resendVerificationCode:a}}];return s.shouldManuallyApprove&&(p.push({id:"job_title",type:"text",inputRef:i.jobTitle,placeholder:u.formatMessage({id:"signup_job_title_placeholder"}),functions:{onChange:()=>f(i.jobTitle,"jobTitle")},validation:[{condition:"required"}],"data-testid":"signup-job-input"},{id:"organization",type:"text",inputRef:i.organisation,placeholder:u.formatMessage({id:"signup_organization_placeholder"}),functions:{onChange:()=>{f(i.organisation,"organisation")}},validation:[{condition:"required"}],"data-testid":"signup-org-input"}),e.url&&p.push({id:"url",type:"text",label:u.formatMessage({id:"signup_url"},{small:m=>d.jsx("small",{children:m})}),placeholder:u.formatMessage({id:"signup_url_placeholder"}),validation:[{condition:"valid-url"}],"data-testid":"signup-url-input"})),e.expectation&&p.push({id:"expectation",className:"expectation",type:"text",label:(n==null?void 0:n.expectation)||u.formatMessage({id:"signup_expectation"},{small:m=>d.jsx("small",{className:"notes text-small",children:m})}),placeholder:(t==null?void 0:t.expectation)||u.formatMessage({id:"signup_expectation_placeholder"}),"data-testid":"signup-events-question"}),p.push({id:"terms",className:"text-small",type:"checkbox",inputRef:i.tc,label:u.formatMessage({id:"signup_terms"},{terms:m=>d.jsx("a",{href:"https://about.apolitical.co/terms-and-conditions","data-gtm-event-context":"SignupForm","data-gtm-event-type":"terms-of-service-click",className:"gtm-trackable",children:m}),privacy:m=>d.jsx("a",{href:"https://about.apolitical.co/privacy-policy","data-gtm-event-context":"SignupForm","data-gtm-event-type":"privacy-policy-click",className:"gtm-trackable",children:m})}),shownValue:"accepted",functions:{onChange:m=>{if(!m)return;const g=[];["name","email"].forEach(h=>{s.validFields[h]!==i[h].current.validity.valid&&(g.push({type:`validFields.${h}`,value:i[h].current.validity.valid}),h==="email"&&Hl({ref:i.email,validateEmail:r,dispatch:o}))}),g.length&&o(g)}},validation:[{condition:"required"}],"data-testid":"signup-terms-checkbox"}),p};const UC=({className:e=""})=>d.jsxs("div",{className:Y("success-message",e),"data-testid":"success-message",children:[d.jsx("p",{className:"success-title",children:d.jsx(ue.FormattedMessage,{id:"signup_success_title"})}),d.jsx(ue.FormattedMessage,{id:"signup_success_text",values:{p:t=>d.jsx("p",{children:t})}})]});const VC={validFields:{name:!1,email:!1,jobTitle:!1,organisation:!1},emailDetails:{email:"",boxType:"",isEnd2End:!1},shouldManuallyApprove:!1,shouldDisableButton:!0,loadRecaptcha:!1,showSuccessMessage:!1,showError:!1},KC=({className:e="",labels:t={},placeholders:n={},functions:r={validateEmail:()=>Promise.resolve(),createAccount:()=>Promise.resolve(),handleError:()=>{},resendVerificationCode:()=>{}},shouldShow:a={},submitButton:i,dataToSubmit:s={ref:"sign-up-form"},...o})=>{const l=ue.useIntl(),{title:u=!0,expectation:c=!1,url:f=!0,logInButton:p=!0,successMessage:m=!0}=a,g={title:u,expectation:c,url:f,logInButton:p,successMessage:m},[h,D]=C.useReducer(Nr,VC),{validFields:v,emailDetails:E,shouldManuallyApprove:k,shouldDisableButton:_,showSuccessMessage:x,showError:F}=h,[S,z]=Ps.useCookies(["signup-this-session","functional-cookie-consent"]),N={form:C.createRef(),name:C.createRef(),email:C.createRef(),jobTitle:C.createRef(),organisation:C.createRef(),tc:C.createRef(),hiddenValidation:C.createRef()};C.useEffect(()=>{k===!0&&N.jobTitle.current&&N.jobTitle.current.focus()},[k]),C.useEffect(()=>{S["signup-this-session"]&&D([{type:"showSuccessMessage",value:!0}])},[S]),C.useEffect(()=>{x&&S["functional-cookie-consent"]&&z("signup-this-session","true",{path:"/",maxAge:3600})},[x]);const $=C.useMemo(()=>HC({placeholders:n,labels:t,shouldShow:g,functions:r,refs:N,state:h,dispatch:D,dataToSubmit:s,intl:l}),[s,r,l,N,g,h]),I=_?!0:k?!Object.values(v).every(w=>w===!0):!v.name||!v.email||["exists","pending","verify"].includes(E.boxType);return g.successMessage&&x?d.jsx(UC,{className:e}):d.jsxs("fieldset",{className:Y("signup-form-fieldset",e),"data-testid":"signup-form",children:[g.title&&d.jsx("p",{className:"signup-title",children:d.jsx(ue.FormattedMessage,{id:"signup_title"})}),F&&d.jsx(sn,{variant:"error",text:l.formatMessage({id:"signup_error"})}),d.jsx(rr,{className:"signup-form",formRef:N.form,id:"sign-up-form",fields:$,intlPath:"signup",button:{variant:"primary",size:"medium",text:i||l.formatMessage({id:"signup_button_join"}),disabled:I?{isClickable:!0}:!1,styling:{fullWidth:!0},"data-testid":"signup-button"},secondaryActionButton:{className:"login-button",styling:{fullWidth:!0},variant:"tertiary",size:"medium",href:"/user-onboarding/login","data-gtm-event-context":"SignupForm","data-gtm-event-type":"login-click",text:l.formatMessage({id:"signup_button_login"})},meta:{shouldReset:!1,showRequiredLabels:!1,shouldShowCancelButton:g.logInButton},gtm:{context:"SignupForm",event:"signup-submit-click"},functions:{onSuccess:async()=>{await WC({refs:N,dataToSubmit:s,createAccount:r.createAccount,onSuccess:r.onSuccess,dispatch:D,state:h})},onCatch:w=>{r.handleError(w),D([{type:"showSuccessMessage",value:!1},{type:"showError",value:!0}])}}}),d.jsx("button",{className:"validation-button",ref:N.hiddenValidation})]})};var Ss={exports:{}},ea={exports:{}},Oe={};/** @license React v16.13.1
132
+ `;default:return u}}function Nn(e,t){const n=e.trim(),r=n,a=`${t}${r}${ql(t)}`;if(r.length===e.length)return a;const i=t+r+ql(t);return e.replace(n,i)}const ql=e=>e.split("").reverse().join(""),bC=e=>e.map(t=>gf(t)).join("").trim();const yC=()=>{const e=An(),{dispatch:t,mentionPopover:n,id:r}=C.useContext(Kt),{show:a,selectedUser:i,possibleUsers:s}=n,o=Jd(e,"mention-popover",`toolbar-${r}`);return!a||!s.length?null:d.jsx(Is,{children:d.jsx(Ic,{ref:o,className:"mention-popover",onKeyDown:l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),t([{type:"showMentionPopover",value:!1}]))},children:d.jsx("ul",{children:s.map(({userId:l,user:u},c)=>d.jsx(nr,{element:"li",className:Y({selected:c===i}),member:{id:l,...u,link:!1},functions:{onClick:f=>{f.preventDefault(),f.stopPropagation();const p={...n,selectedUser:c};t([{type:"mentionPopover",value:p}]),pf(e,p,t,r)}}},l))})})})},po=({id:e,active:t,hasDivider:n=!1,callback:r,className:a="",children:i,...s})=>{const o=ue.useIntl(),l=An(),{id:u,tabbableOption:c,setFocus:f,openTooltip:p,dispatch:m}=C.useContext(Kt),g={};return e!==c&&(g.tabIndex=-1),d.jsxs("li",{id:`${u}-${e}`,className:Y(e,{"has-divider":n}),onMouseEnter:()=>{m([{type:"openTooltip",value:e}])},onMouseLeave:()=>{m([{type:"openTooltip",value:null}])},onFocus:()=>{m([{type:"openTooltip",value:e}])},onBlur:h=>{h.stopPropagation();const D=[{type:"openTooltip",value:null}];l.selection&&D.push({type:"lastAnchor",value:l.selection.anchor}),m(D)},contentEditable:!1,children:[d.jsxs("button",{...s,...g,className:Y(e,a,{active:t}),onClick:h=>{h.stopPropagation(),h.preventDefault()},onMouseDown:h=>{h.stopPropagation(),h.preventDefault(),r()},onKeyDown:h=>{var D,v,E,k;if(h.key!=="Tab")switch(h.key){case"Enter":h.stopPropagation(),h.preventDefault(),r();break;case"ArrowLeft":case"ArrowRight":h.stopPropagation(),h.preventDefault();const _=h.currentTarget.closest("li");let x=_==null?void 0:_.nextElementSibling;if(h.key==="ArrowLeft"){const z=_==null?void 0:_.previousElementSibling;z?x=z:x=(D=_==null?void 0:_.parentElement)==null?void 0:D.lastElementChild}else x||(x=(v=_==null?void 0:_.parentElement)==null?void 0:v.firstElementChild);const F=x==null?void 0:x.className.split(" ")[0];F&&(f(F),(E=x==null?void 0:x.querySelector("button"))==null||E.focus());break;default:const S=h.currentTarget.closest("fieldset");if(S){(k=S==null?void 0:S.previousElementSibling)==null||k.focus();break}}},children:[d.jsx(Re,{showOnFocus:!1,children:o.formatMessage({id:`richTextEditor_${e}`})}),d.jsx(kn,{id:`tooltip-${e}`,styling:{extraPadding:!1,hasPointer:"bottom"},isOpen:p===e,"aria-hidden":!0,children:o.formatMessage({id:`richTextEditor_${e}`})})]}),i]})},Wl=[Z.ol,Z.ul],vf=(e,t)=>{const{selection:n}=e;if(!n)return!1;const[r]=Array.from(b.nodes(e,{at:b.unhangRange(e,n),match:a=>{const i=a;return!b.isEditor(a)&&ce.isElement(a)&&i.type===t}}));return!!r},DC=e=>{const[t]=b.nodes(e,{match:n=>n.type===Z.blockquote});return!!t},bf=(e,t,n)=>{try{const r=DC(e),a=vf(e,t),i=Wl.includes(t);Q.unwrapNodes(e,{match:l=>{const u=l;return!b.isEditor(u)&&ce.isElement(u)&&Wl.includes(u.type)},split:!0});const o={type:a?Z.paragraph:i?Z.li:t};if(Q.setNodes(e,o),i)if(a){const{selection:l}=e;if(!l)return;const[u,c]=b.parent(e,l,{edge:"end"});Array.from(b.nodes(e,{at:c,match:p=>{const m=p;return!b.isEditor(p)&&ce.isElement(p)&&m.type===Z.li}})).forEach(([p,m])=>{oe.string(p).trim()===""&&Q.removeNodes(e,{at:m})})}else{if(r){const u={type:Z.blockquote,children:[]};Q.wrapNodes(e,u)}const l={type:t,children:[]};Q.wrapNodes(e,l)}}catch(r){const a=r.message;n(`Error toggling block: ${a}`)}},CC=({format:e,hasDivider:t=!1})=>{const{setFocus:n,reportError:r}=C.useContext(Kt),a=An(),i=vf(a,e);return d.jsx(po,{id:e,active:i,hasDivider:t,callback:()=>{bf(a,e,r),n(i?null:e)}})},xr=e=>{const[t]=b.nodes(e,{match:n=>{const r=n;return!b.isEditor(n)&&ce.isElement(n)&&r.type===Z.link}});return!!t},xC=(e,t,n,r)=>{e.selection&&go(e,t,n,r)},wC=(e,t,n,r)=>{const{selection:a}=e;if(a&&V.isCollapsed(a)){const[s]=b.nodes(e,{match:o=>{const l=o;return!b.isEditor(o)&&ce.isElement(o)&&l.type===Z.link}});if(s){const[o,l]=s,u={link:t};Q.setNodes(e,u,{at:l}),mo(n)}}else go(e,t,n,r)},go=(e,t,n,r=a=>{console.error(a)})=>{try{xr(e)&&yf(e);const{selection:a}=e,i=a&&V.isCollapsed(a),s={type:Z.link,link:t,children:i?[{text:t}]:[]};i?(Q.insertNodes(e,s),Q.move(e,{distance:1,unit:"offset"})):(Q.wrapNodes(e,s,{split:!0}),Q.collapse(e,{edge:"end"}),Q.insertNodes(e,{text:""}),Q.move(e,{distance:1,unit:"offset"})),mo(n)}catch(a){const i=a.message;r(`Error in wrapLink: ${i}`)}},yf=e=>{Q.unwrapNodes(e,{match:t=>{const n=t;return!b.isEditor(t)&&ce.isElement(t)&&n.type===Z.link}})};let Pi=null;const EC=()=>{const e=ue.useIntl(),t="richTextEditor_link_",{id:n,showLinkEditor:r,dispatch:a,reportError:i}=C.useContext(Kt),s=An(),o=$y(s),l=(o==null?void 0:o.text)||mC(s),[u,c]=C.useState(xr(s)),f=Jd(s,"link-editor",`${n}-link`),p=C.useRef(null);C.useEffect(()=>{var D;!u&&r&&((D=p.current)==null||D.focus())},[u]),C.useEffect(()=>{Pi&&clearTimeout(Pi),Pi=setTimeout(()=>{c(xr(s))},500)},[s.selection]);const m=[],g=["open","edit","remove"].map(D=>{const v={variant:"tertiary",size:"small",children:e.formatMessage({id:`${t}${D}`},{link:o==null?void 0:o.pretty})};switch(m.push({className:D}),D){case"open":v.href=(o==null?void 0:o.full)||"",v.onClick=E=>{E.preventDefault(),E.stopPropagation(),window.open((o==null?void 0:o.full)||"","_blank"),a([{type:"showLinkEditor",value:!1}])},v.children=d.jsxs(d.Fragment,{children:[v.children,d.jsx(Re,{children:e.formatMessage({id:`${t}${D}_text`})})]});break;case"edit":v.onClick=()=>{c(!1)};break;case"remove":v.onClick=()=>{const E=[{type:"showLinkEditor",value:!1}];xr(s)&&(yf(s),E.push({type:"lastAnchor",value:null})),a(E)};break}return v}),h=[{id:"url",type:"url",inputRef:p,label:e.formatMessage({id:`${t}url`}),placeholder:e.formatMessage({id:`${t}placeholder`}),value:(o==null?void 0:o.full)||"",validation:[{condition:"required",error:e.formatMessage({id:`${t}error_required`})},{condition:"valid-url"}],submitOnEnter:!0,autoFocus:!0}];return l&&h.unshift({component:()=>d.jsxs("p",{children:[d.jsx("strong",{"aria-label":e.formatMessage({id:`${t}text_aria`}),children:e.formatMessage({id:`${t}text`})})," ",l]})}),d.jsx(Is,{children:d.jsx(kn,{ref:f,className:"link-editor",isOpen:r,styling:{extraPadding:!1,hasForm:!u},functions:{onBlur:()=>{a([{type:"showLinkEditor",value:!1}])}},callbacks:{onOpen:()=>{setTimeout(()=>{var D;return(D=p.current)==null?void 0:D.focus()})}},children:u?d.jsx(_n,{wrappers:m,buttons:g}):d.jsx(rr,{element:"fieldset",id:`${n}-link-editor`,className:Y({"show-labels":l}),meta:{shouldReset:!0,showRequiredLabels:!1},functions:{onSuccess:async D=>{setTimeout(()=>{const v=[{type:"showLinkEditor",value:!1}];if(D.url){const{full:E}=Mc(D.url);o!=null&&o.full?wC(s,E,n,i):xC(s,E,n,i),v.push({type:"lastAnchor",value:null})}a(v)})}},fields:h,button:{text:e.formatMessage({id:`${t}button`}),variant:"tertiary",size:"small"}})})})},kC=()=>{const e=An(),{setFocus:t,dispatch:n}=C.useContext(Kt),[r,a]=C.useState(!1);return C.useEffect(()=>{a(xr(e))},[e.selection]),d.jsx(po,{id:"link",active:r,hasDivider:!0,callback:()=>{n([{type:"showLinkEditor",value:!0}]),t(r?null:"link"),a(!0)}})},_C=e=>[Z.bold,Z.italic,Z.strikethrough].includes(e),Df=(e,t)=>{const n=b.marks(e);return n?n[t]===!0:!1},Cf=(e,t,n)=>{try{Df(e,t)?b.removeMark(e,t):b.addMark(e,t,!0)}catch(r){const a=r.message;n(`Error toggling mark: ${a}`)}},BC=({format:e,hasDivider:t=!1})=>{const{setFocus:n,reportError:r}=C.useContext(Kt),a=An(),i=Df(a,e);return d.jsx(po,{id:e,active:i,hasDivider:t,callback:()=>{Cf(a,e,r),n(i?null:e)}})},Aa=[Z.bold,Z.italic,Z.strikethrough],AC=[Z.ol,Z.ul,Z.blockquote];const FC=({...e})=>{const t=ue.useIntl(),{id:n}=C.useContext(Kt);return d.jsxs(d.Fragment,{children:[d.jsxs("fieldset",{id:`toolbar-${n}`,className:"toolbar",...e,children:[d.jsx(Re,{element:"legend",showOnFocus:!1,children:t.formatMessage({id:"richTextEditor_toolbar"})}),d.jsxs("ul",{children:[Aa.map((r,a)=>d.jsx(BC,{format:r,hasDivider:a===Aa.length-1},r)),d.jsx(kC,{}),AC.map((r,a)=>d.jsx(CC,{format:r,hasDivider:a===1},r))]})]}),d.jsx(EC,{})]})};var TC=PC,SC=/^(?:\w+:)?\/\/(\S+)$/,jC=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,OC=/^[^\s\.]+\.\S{2,}$/;function PC(e){if(typeof e!="string")return!1;var t=e.match(SC);if(!t)return!1;var n=t[1];return n?!!(jC.test(n)||OC.test(n)):!1}const NC=En(TC),RC=(e,t,n)=>{const{insertText:r,isInline:a}=e;try{e.isInline=i=>{const s=i;return[Z.link].includes(s.type)||a(i)},e.insertText=i=>{i&&NC(i)?go(e,i,t):r(i)}}catch(i){const s=i.message;n(`Error in withInlines: ${s}`)}return e},MC=(e,t)=>{const{isInline:n,isVoid:r,markableVoid:a}=e;try{e.isInline=i=>i.type===Z.mention?!0:n(i),e.isVoid=i=>i.type===Z.mention?!0:r(i),e.markableVoid=i=>i.type===Z.mention||a(i)}catch(i){const s=i.message;t(`Error in withMentions: ${s}`)}return e},IC=(e,t)=>{const{normalizeNode:n}=e;try{e.normalizeNode=([r,a])=>{if(r.type===Z.link&&oe.string(r).trim()===""){Q.removeNodes(e,{at:a});return}n([r,a])}}catch(r){const a=r.message;t(`Error in withoutEmptyLinks: ${a}`)}return e};const xf=({id:e="rich-text-editor",value:t,placeholder:n,maxLength:r=0,functions:a,autoFocus:i=!0,data:s,...o})=>{const l=ue.useIntl(),u=Ph(),{listMembers:c,onChange:f=()=>{},reportError:p=R=>{console.error(R)}}=a||{},m=[{type:Z.paragraph,children:[{text:""}]}],g={editorKey:null,originalValue:t||"",initialValue:t?null:m,tabbableOption:Aa[0],openTooltip:null,showLinkEditor:!1,mentionPopover:{show:!1,selectedUser:0,possibleUsers:[],position:null},lastAnchor:null,stringValue:"",lastKey:null,hasInteracted:!1,hasLoaded:!1},[h,D]=C.useReducer(Nr,g),{editorKey:v,originalValue:E,initialValue:k,stringValue:_,lastAnchor:x,lastKey:F,hasInteracted:S,hasLoaded:z,mentionPopover:N}=h,$=R=>{const W=R||Aa[0];R&&D([{type:"tabbableOption",value:W}])},I=`rte-${e}`,w=C.useCallback(R=>d.jsx(My,{...R}),[]),A=C.useCallback(R=>d.jsx(Iy,{...R}),[]),T=C.useMemo(()=>RC(MC(IC(Ev(Ny(xv())),p),p),I,p),[]);C.useEffect(()=>{if(!t)return;kr.lastIndex=0;const R=t.match(kr);!R||R.length>1||R[0].length!==t.length||S||D([{type:"originalValue",value:t}])},[t]),C.useEffect(()=>{E&&(async()=>{let W=gn(E);W.includes("<")&&(W=new Ca().turndown(W)),s&&s.mentions&&(W=await Rc({text:W,template:`[${Es}{{name}}]({{id}})`,mentions:s.mentions,listMembers:c||(()=>Promise.resolve([]))})),hC(W,X=>{D([{type:"initialValue",value:X},{type:"editorKey",value:E.toString()}]),setTimeout(()=>{D([{type:"stringValue",value:$l(T)}])},150)})})()},[E]),C.useEffect(()=>{if(T.children.length>0&&!z){if(D([{type:"hasLoaded",value:!0}]),!i)return;const R=b.end(T,[]);Q.select(T,R),J.focus(T)}},[T.children.length,k]),C.useEffect(()=>{t!==""||!T||bc(E,t)&&!S||(b.withoutNormalizing(T,()=>{Q.delete(T,{at:{anchor:b.start(T,[]),focus:b.end(T,[])}}),Q.deselect(T),T.children.length!==0&&Q.unwrapNodes(T,{at:[0]}),Q.insertNodes(T,m,{at:[0]})}),D([{type:"initialValue",value:m},{type:"lastAnchor",value:null}]))},[t]);const M=wc(()=>{gC(T,N.show,c,D)},100);return k?d.jsx("div",{id:I,className:"rich-text-editor",children:d.jsxs(Kt.Provider,{value:{...h,id:I,setFocus:$,dispatch:D,reportError:p},children:[d.jsxs(Oy,{editor:T,initialValue:k,onChange:R=>{if(T.operations.some(X=>X.type!=="set_selection")){const X=bC(R);f(X),D([{type:"stringValue",value:$l(T)}]),S||D([{type:"hasInteracted",value:!0}]),M(),u&&console.log({serialized:X,json:R})}},...o,children:[d.jsx(Ey,{className:"input",renderElement:w,renderLeaf:A,placeholder:n||l.formatMessage({id:"richTextEditor_placeholder"}),autoFocus:i,tabIndex:0,onKeyDown:R=>{if(R.key==="Enter"){N.show&&(R.preventDefault(),R.stopPropagation(),pf(T,N,D,I));const{selection:W}=T;if(W){const X=V.isCollapsed(W),[G,y]=b.node(T,W,{depth:1});let H=G,te=H.type;const B=H.children[0];if(B&&[Z.ol,Z.ul].includes(B.type)&&(H=B,te=B.type),H&&ce.isElement(H)&&te!==Z.paragraph){if(te===Z.blockquote&&!R.shiftKey){R.stopPropagation(),R.preventDefault(),Q.insertNodes(T,m);return}if(X){const[j]=b.parent(T,W,{edge:"end"}),L=j.type;if(F==="Enter"&&L===Z.li&&[Z.ul,Z.ol].includes(te)){R.stopPropagation(),R.preventDefault(),Q.insertNodes(T,m,{at:P.next(y)}),Q.select(T,b.end(T,P.next(y)));return}}}}}else if(R.key==="Escape"){if(N.show){R.preventDefault(),R.stopPropagation(),D([{type:"mentionPopover",value:{...N,show:!1}}]);return}}else if(["ArrowUp","ArrowDown"].includes(R.key)&&N.show){R.preventDefault(),R.stopPropagation();const{selectedUser:W,possibleUsers:X}=N;let G=R.key==="ArrowUp"?W-1:W+1;G<0&&(G=X.length-1),G>=X.length&&(G=0),D([{type:"mentionPopover",value:{...N,selectedUser:G}}])}D([{type:"lastKey",value:R.key}]),pC(R,T,D,p)},onBlur:()=>{T.selection&&D([{type:"lastAnchor",value:T.selection.anchor}])},onFocus:()=>{if(x){if(!P.isPath(x.path)||!oe.has(T,x.path))return;const R=oe.get(T,x.path);let W=0;if(de.isText(R)?W=R.text.length:R.children&&(W=R.children.length),x.offset>W)return;try{Q.select(T,{anchor:x,focus:x})}catch(X){const G=X.message;p(`Error focusing editor: ${G}`)}}}}),d.jsx(FC,{}),c?d.jsx(yC,{}):null]},v),d.jsx(Ws,{limit:r,valueLength:Ha(_)})]})}):null};const $C=({id:e="form-toggle",label:t,options:n,initialValue:r,functions:{onChange:a=()=>{}},isDisabled:i=!1,className:s=""})=>{const[o,l]=C.useState(typeof r=="boolean"||typeof r=="string"?r:n[0].value);C.useEffect(()=>{r&&l(r)},[r]);const u=c=>{i||(l(c),a(c))};return d.jsxs("div",{className:Y("toggle",s),onClick:c=>{c.preventDefault(),c.stopPropagation(),u(o===n[0].value?n[1].value:n[0].value)},children:[d.jsx("p",{children:t}),d.jsx("ul",{className:Y("toggle-options",{disabled:i,on:o===n[1].value}),children:n.map(c=>{const f=`${e}-${c.value}`;return d.jsxs("li",{className:"hidden",children:[d.jsx("input",{type:"radio",id:f,name:e,value:c.value,checked:o===c.value,onChange:()=>u(c.value),disabled:i}),d.jsx("label",{htmlFor:f,children:c.label})]},f)})})]})};function LC({className:e="",userId:t,userName:n,src:r,setUserImage:a,uploadImage:i}){const[s,o]=C.useState(!1),[l,u]=C.useState(!1),c=C.useRef(null),f=async p=>{o(!0),u(!1);try{const m=p.target.files&&p.target.files[0];if(!m||!t)throw o(!1),new Error("Image file or userID is missing");const g=await i({fileObject:m,userId:t});a(h=>({...h,image:{thumbnail:g.thumbnailURL,full:g.originalURL}}))}catch{u(!0)}finally{o(!1)}o(!1)};return d.jsxs("div",{className:Y("profile-image-change-figure",e),children:[d.jsx(on,{className:"profile-image-change-picture",name:n,src:r,"data-testid":"profile-picture"}),l&&d.jsx("p",{className:"error text-small",children:d.jsx(ue.FormattedMessage,{id:"profile_image_change_error"})}),d.jsx("input",{id:"file",type:"file",accept:"image/*",ref:c,onChange:f,hidden:!0,"data-testid":"file-input"}),d.jsx(_e,{onClick:()=>c.current&&c.current.click(),variant:"secondary","data-gtm-event-context":"ImageField","data-gtm-event-type":`${r?"change-photo":"add-photo"}-click`,className:"gtm-trackable",disabled:s,children:d.jsx(ue.FormattedMessage,{id:s?"profile_image_change_uploading_text":r?"profile_image_change_cta_with_picture":"profile_image_change_cta_without_picture"})})]})}const wf=({gtm:e,functions:{onSuccess:t=async()=>{},onFailure:n=()=>{}}})=>{const{context:r="FooterContactUsForm",event:a="contact-form-submit-click"}=e||{};return d.jsx(rr,{id:"contact-us-form",fields:[{id:"name",type:"text",className:"short",validation:[{condition:"required"}]},{id:"email",type:"email",className:"short",validation:[{condition:"required"},{condition:"valid-email"}]},{id:"organisation",type:"text"},{id:"interests",type:"checkboxes",options:[{id:"publishingCourse",label:"Publishing or creating a course"},{id:"buyingCourse",label:"Buying courses for my team"},{id:"learningExperience",label:"Customised learning experiences"},{id:"somethingElse",label:"Something else"}]},{id:"message",type:"textarea",limit:1e3,validation:[{condition:"required"}]}],intlPath:"contactForm",gtm:{context:r,event:a},functions:{onSuccess:t,onFailure:n}})};const Ef=({title:e,label:t,ctaMessage:n,titleColor:r,labelColor:a,backgroundColor:i,onClose:s,reportError:o,sendInvites:l,initialFormStatus:u="NOT_SUBMITTED"})=>{const[c,f]=C.useState([]),[p,m]=C.useState(!0),[g,h]=C.useState(u),{formatMessage:D}=ue.useIntl(),v=async _=>{_.preventDefault();try{await l(c),f([]),h("SUCCESS")}catch(x){h("ERROR"),o(x)}},E=_=>{_.preventDefault(),h("NOT_SUBMITTED"),m(!0),f([])},k=_=>{_.preventDefault(),s(),h("CLOSED")};return g==="CLOSED"?null:g==="ERROR"||g==="SUCCESS"?d.jsxs("div",{className:"invite-form-wrapper",children:[d.jsx("div",{className:"content centred",children:g==="SUCCESS"?d.jsx("h2",{className:"success-title",children:D({id:"inviteForm_success"})}):d.jsxs("h2",{className:"error-title",children:[" ",D({id:"inviteForm_error"})]})}),d.jsx(nn,{}),d.jsx("div",{className:"footer",children:g==="SUCCESS"?d.jsxs(d.Fragment,{children:[d.jsx(_e,{variant:"secondary",onClick:E,children:D({id:"inviteForm_ctaSendMoreInvites"})}),d.jsx(_e,{onClick:k,children:D({id:"inviteForm_ctaDone"})})]}):d.jsx(_e,{onClick:E,children:D({id:"inviteForm_ctaTryAgain"})})})]}):d.jsx("div",{className:"invite-form-wrapper",children:d.jsxs("form",{style:{backgroundColor:i},onSubmit:v,className:Y("invite-form gtm-trackable"),children:[d.jsxs("fieldset",{className:"content",children:[d.jsx("h2",{className:"title",style:{color:r},children:e}),d.jsx("label",{htmlFor:"email-input",className:"label",style:{color:a},children:t}),d.jsx(Ch.ReactMultiEmail,{id:"email-input",inputClassName:"email-input input",placeholder:D({id:"inviteForm_email_placeholder"}),emails:c,onChange:_=>{f(_),m(!_.length)},autoFocus:!1,getLabel:(_,x,F)=>d.jsxs("div",{className:"email text-medium",children:[d.jsx("div",{"data-tag-item":!0,children:_}),d.jsx(_e,{variant:"tertiary",size:"small",icon:{icon:"close"},onClick:()=>{F(x),m(!c.length)},className:"remove-email-button",screenreaderText:D({id:"overlay_close"})})]},x)})]}),d.jsx(nn,{}),d.jsx("fieldset",{className:"footer",children:d.jsx(_e,{className:"sendEmailsButton",disabled:p,children:n})})]})})},ga=e=>e.map(t=>({condition:t})),Dt={FORM_ID:"manage-account-password-change",NEW_PASSWORD:"newPassword",CONFIRMED_PASSWORD:"confirmedPassword",CURRENT_PASSWORD:"oldPassword"},zC=({functions:e,...t})=>{const{formatMessage:n}=ue.useIntl(),[r,a]=C.useState(null),[i,s]=C.useState(!1),[o,l]=C.useState({isMoreThanEightCharacters:!1,includesNumberAndSymbol:!1,includesLowerAndUppercase:!1}),u=m=>m[Dt.NEW_PASSWORD]!==m[Dt.CONFIRMED_PASSWORD]?n({id:"passwordRules_unmatched_text"}):null,c=m=>!is(m[Dt.NEW_PASSWORD]).isValid,f=[{"data-testid":Dt.NEW_PASSWORD,id:Dt.NEW_PASSWORD,type:"password",autoComplete:"password",placeholder:"",label:n({id:"passwordRules_newPassword_label"}),validation:ga(["required",c]),functions:{onChange:m=>l(is(m).matchingRules),onFocus:()=>s(!0),onBlur:()=>s(!1)}},{"data-testid":Dt.CONFIRMED_PASSWORD,id:Dt.CONFIRMED_PASSWORD,type:"password",autoComplete:"password",placeholder:"",label:n({id:"passwordRules_confirmPassword_label"}),validation:ga(["required",u])}];t.isPasswordChange&&f.unshift({"data-testid":Dt.CURRENT_PASSWORD,id:Dt.CURRENT_PASSWORD,type:"password",placeholder:"",label:n({id:"passwordRules_currentPassword_label"}),validation:ga(["required"])}),i&&f.push({component:Jc,props:{matchingRules:o}});const p={id:Dt.FORM_ID,fields:f,functions:{...e,onSuccess:async m=>(e.createPassword(m),e.onSuccess&&e.onSuccess(m)),onCatch:m=>a(m==null?void 0:m.statusCode),onFailure:(m,g)=>{(g.includes(Dt.NEW_PASSWORD)||g.includes(Dt.CONFIRMED_PASSWORD))&&s(!0)}},meta:{shouldReset:!0},...t};return d.jsxs(d.Fragment,{children:[d.jsx(rr,{...p}),r&&d.jsx(sn,{variant:"error",text:r})]})};const kf=({id:e="search",className:t="",handleToggle:n=!1,defaultValue:r="",gtmContext:a="search-bar",gtmEvent:i="form-submission"})=>{const{searchIsOpen:s=!0,isDesktopVersion:o=!1}=n||{},l=ue.useIntl(),u=C.useRef(null);Vn(()=>{!n||o||!s||u.current&&u.current.focus()},[s]);const c=f=>{f.preventDefault(),f.stopPropagation(),!(!u.current||!u.current.value||u.current.value.length<1)&&(window.location.href=`/search?search=${encodeURIComponent(u.current.value)}`)};return d.jsx("form",{onSubmit:c,className:Y("search-form gtm-trackable",t),role:"search","data-gtm-event-context":a,"data-gtm-event-type":i,children:d.jsx("fieldset",{id:`${e}-form`,hidden:n?!s:!1,children:d.jsxs("p",{children:[d.jsx(Re,{element:"label",htmlFor:e,children:l.formatMessage({id:"search_label"})}),d.jsx("input",{ref:u,type:"search",id:e,name:e,defaultValue:r,placeholder:l.formatMessage({id:"search_placeholder"}),onKeyDown:f=>{f.key==="Enter"&&c(f)}}),d.jsx("button",{className:"clear",onClick:f=>{f.preventDefault(),f.stopPropagation(),u.current&&u.current.value&&(u.current.value="")},children:d.jsx(Re,{children:l.formatMessage({id:"search_clear"})})}),d.jsx("button",{className:"search",onClick:c,children:d.jsx(Re,{children:l.formatMessage({id:"search_cta"})})})]})})})},Hl=async({ref:e,validateEmail:t,dispatch:n})=>{const r=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;if(!e.current.validity.valid||!r.test(e.current.value))return n([{type:"validFields.email",value:!1}]);const a=e.current.value.toString().toLowerCase().trim(),i={valid:!1,autoApproved:!1,exists:{auth:!1,engagement:!1,registration:!1,user:!1}};let s=Object.assign({},i);try{s=await t(a),s===void 0&&(s=i)}catch{return n([{type:"shouldManuallyApprove",value:!0},{type:"emailDetails",value:{email:a,boxType:"nonGov",isEnd2End:!1}},{type:"validFields.email",value:!1}])}const{valid:o=!1,autoApproved:l=!1,exists:u}=s;let c="";return o?c=l?"gov":"nonGov":u.registration?u.engagement&&!u.user?c=u.auth?"verify":"pending":c="exists":u.auth&&(c="exists"),n([{type:"shouldDisableButton",value:!1},{type:"shouldManuallyApprove",value:!l},{type:"emailDetails",value:{email:a,boxType:c,isEnd2End:/testing\+[0-9]+@apolitical.co$/.test(a)}},{type:"validFields.email",value:!0}])},qC=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"]}},WC=async({refs:e,dataToSubmit:t,createAccount:n,onSuccess:r,dispatch:a,state:i})=>{if(!e.form||!e.form.current)throw new Error("No refs.form");if(!e.form.current.checkValidity()){e.hiddenValidation&&e.hiddenValidation.current&&e.hiddenValidation.current.click();return}const s=qC(new FormData(e.form.current)),o=Object.assign(s,t);await n(o),localStorage.setItem("email",s.email),r&&r({...s,...i.values}),a([{type:"showSuccessMessage",value:!0}])},HC=({shouldShow:e,placeholders:t,labels:n,functions:{validateEmail:r,resendVerificationCode:a},refs:i,state:s,dispatch:o,dataToSubmit:l,intl:u})=>{const{emailDetails:c}=s,f=(m,g)=>{m.current&&s.validFields[g]!==m.current.validity.valid&&o([{type:`validFields.${g}`,value:m.current.validity.valid}])},p=[{id:"full_name",type:"text",inputRef:i.name,placeholder:u.formatMessage({id:"signup_full_name_placeholder"}),functions:{onChange:()=>f(i.name,"name"),onFocus:()=>o([{type:"loadRecaptcha",value:!0}])},autoComplete:"name",validation:[{condition:"required"},{condition:"no-numbers"}],"data-testid":"signup-name-input"},{id:"email_address",type:"email",inputRef:i.email,placeholder:u.formatMessage({id:"signup_email_address_placeholder"}),functions:{onBlur:()=>{Hl({ref:i.email,validateEmail:r,dispatch:o})},onChange:(m,g)=>{o([{type:"shouldDisableButton",value:!0}]),g&&g({type:"updateValue",payload:{key:"terms",value:!1}})},onFocus:()=>o([{type:"loadRecaptcha",value:!0}])},autoComplete:"email",validation:[{condition:"required"},{condition:"valid-email"}],"data-testid":"signup-email-input"},{component:Kc,props:{email:c.email,type:c.boxType,resendVerificationCode:a}}];return s.shouldManuallyApprove&&(p.push({id:"job_title",type:"text",inputRef:i.jobTitle,placeholder:u.formatMessage({id:"signup_job_title_placeholder"}),functions:{onChange:()=>f(i.jobTitle,"jobTitle")},validation:[{condition:"required"}],"data-testid":"signup-job-input"},{id:"organization",type:"text",inputRef:i.organisation,placeholder:u.formatMessage({id:"signup_organization_placeholder"}),functions:{onChange:()=>{f(i.organisation,"organisation")}},validation:[{condition:"required"}],"data-testid":"signup-org-input"}),e.url&&p.push({id:"url",type:"text",label:u.formatMessage({id:"signup_url"},{small:m=>d.jsx("small",{children:m})}),placeholder:u.formatMessage({id:"signup_url_placeholder"}),validation:[{condition:"valid-url"}],"data-testid":"signup-url-input"})),e.expectation&&p.push({id:"expectation",className:"expectation",type:"text",label:(n==null?void 0:n.expectation)||u.formatMessage({id:"signup_expectation"},{small:m=>d.jsx("small",{className:"notes text-small",children:m})}),placeholder:(t==null?void 0:t.expectation)||u.formatMessage({id:"signup_expectation_placeholder"}),"data-testid":"signup-events-question"}),p.push({id:"terms",className:"text-small",type:"checkbox",inputRef:i.tc,label:u.formatMessage({id:"signup_terms"},{terms:m=>d.jsx("a",{href:"https://about.apolitical.co/terms-and-conditions","data-gtm-event-context":"SignupForm","data-gtm-event-type":"terms-of-service-click",className:"gtm-trackable",children:m}),privacy:m=>d.jsx("a",{href:"https://about.apolitical.co/privacy-policy","data-gtm-event-context":"SignupForm","data-gtm-event-type":"privacy-policy-click",className:"gtm-trackable",children:m})}),shownValue:"accepted",functions:{onChange:m=>{if(!m)return;const g=[];["name","email"].forEach(h=>{s.validFields[h]!==i[h].current.validity.valid&&(g.push({type:`validFields.${h}`,value:i[h].current.validity.valid}),h==="email"&&Hl({ref:i.email,validateEmail:r,dispatch:o}))}),g.length&&o(g)}},validation:[{condition:"required"}],"data-testid":"signup-terms-checkbox"}),p};const UC=({className:e=""})=>d.jsxs("div",{className:Y("success-message",e),"data-testid":"success-message",children:[d.jsx("p",{className:"success-title",children:d.jsx(ue.FormattedMessage,{id:"signup_success_title"})}),d.jsx(ue.FormattedMessage,{id:"signup_success_text",values:{p:t=>d.jsx("p",{children:t})}})]});const VC={validFields:{name:!1,email:!1,jobTitle:!1,organisation:!1},emailDetails:{email:"",boxType:"",isEnd2End:!1},shouldManuallyApprove:!1,shouldDisableButton:!0,loadRecaptcha:!1,showSuccessMessage:!1,showError:!1},KC=({className:e="",labels:t={},placeholders:n={},functions:r={validateEmail:()=>Promise.resolve(),createAccount:()=>Promise.resolve(),handleError:()=>{},resendVerificationCode:()=>Promise.resolve()},shouldShow:a={},submitButton:i,dataToSubmit:s={ref:"sign-up-form"},...o})=>{const l=ue.useIntl(),{title:u=!0,expectation:c=!1,url:f=!0,logInButton:p=!0,successMessage:m=!0}=a,g={title:u,expectation:c,url:f,logInButton:p,successMessage:m},[h,D]=C.useReducer(Nr,VC),{validFields:v,emailDetails:E,shouldManuallyApprove:k,shouldDisableButton:_,showSuccessMessage:x,showError:F}=h,[S,z]=Ps.useCookies(["signup-this-session","functional-cookie-consent"]),N={form:C.createRef(),name:C.createRef(),email:C.createRef(),jobTitle:C.createRef(),organisation:C.createRef(),tc:C.createRef(),hiddenValidation:C.createRef()};C.useEffect(()=>{k===!0&&N.jobTitle.current&&N.jobTitle.current.focus()},[k]),C.useEffect(()=>{S["signup-this-session"]&&D([{type:"showSuccessMessage",value:!0}])},[S]),C.useEffect(()=>{x&&S["functional-cookie-consent"]&&z("signup-this-session","true",{path:"/",maxAge:3600})},[x]);const $=C.useMemo(()=>HC({placeholders:n,labels:t,shouldShow:g,functions:r,refs:N,state:h,dispatch:D,dataToSubmit:s,intl:l}),[s,r,l,N,g,h]),I=_?!0:k?!Object.values(v).every(w=>w===!0):!v.name||!v.email||["exists","pending","verify"].includes(E.boxType);return g.successMessage&&x?d.jsx(UC,{className:e}):d.jsxs("fieldset",{className:Y("signup-form-fieldset",e),"data-testid":"signup-form",children:[g.title&&d.jsx("p",{className:"signup-title",children:d.jsx(ue.FormattedMessage,{id:"signup_title"})}),F&&d.jsx(sn,{variant:"error",text:l.formatMessage({id:"signup_error"})}),d.jsx(rr,{className:"signup-form",formRef:N.form,id:"sign-up-form",fields:$,intlPath:"signup",button:{variant:"primary",size:"medium",text:i||l.formatMessage({id:"signup_button_join"}),disabled:I?{isClickable:!0}:!1,styling:{fullWidth:!0},"data-testid":"signup-button"},secondaryActionButton:{className:"login-button",styling:{fullWidth:!0},variant:"tertiary",size:"medium",href:"/user-onboarding/login","data-gtm-event-context":"SignupForm","data-gtm-event-type":"login-click",text:l.formatMessage({id:"signup_button_login"})},meta:{shouldReset:!1,showRequiredLabels:!1,shouldShowCancelButton:g.logInButton},gtm:{context:"SignupForm",event:"signup-submit-click"},functions:{onSuccess:async()=>{await WC({refs:N,dataToSubmit:s,createAccount:r.createAccount,onSuccess:r.onSuccess,dispatch:D,state:h})},onCatch:w=>{r.handleError(w),D([{type:"showSuccessMessage",value:!1},{type:"showError",value:!0}])}}}),d.jsx("button",{className:"validation-button",ref:N.hiddenValidation})]})};var Ss={exports:{}},ea={exports:{}},Oe={};/** @license React v16.13.1
133
133
  * react-is.production.min.js
134
134
  *
135
135
  * Copyright (c) Facebook, Inc. and its affiliates.
package/index.mjs CHANGED
@@ -18355,8 +18355,7 @@ const Mx = {
18355
18355
  createAccount: () => Promise.resolve(),
18356
18356
  handleError: () => {
18357
18357
  },
18358
- resendVerificationCode: () => {
18359
- }
18358
+ resendVerificationCode: () => Promise.resolve()
18360
18359
  },
18361
18360
  shouldShow: a = {},
18362
18361
  submitButton: i,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apolitical/component-library",
3
- "version": "4.4.0",
3
+ "version": "4.4.1-4581.5",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {