import{j as n,ag as i,aL as u,T as F,F as R,Q as c,c4 as f,bO as _,O as x,bk as B,ar as G,cm as C,aq as U,b4 as $,aX as E,R as d,bT as V}from"./app-BgLa5dit.js";const p="_avatar_rpeug_1",H={avatar:p};function M(e){const{imageUrl:t,initials:a}=e,o={};return t&&(o.backgroundImage=`url('${t}')`),n.jsx("div",{className:H.avatar,style:o,children:t?n.jsx(n.Fragment,{children:" "}):a})}const L="_svgContainer_kq46n_1",D="_selection_kq46n_5",O="_expander_kq46n_8",P="_iconContainer_kq46n_14",z="_icon_kq46n_14",A="_bubble_kq46n_30",Q="_spinnerContainer_kq46n_46",W="_remove_kq46n_51",X="_removeBubble_kq46n_60",s={svgContainer:L,selection:D,expander:O,iconContainer:P,icon:z,bubble:A,spinnerContainer:Q,remove:W,removeBubble:X},J=R.encloseNamespace("shared.inputSelection");function K(e){var t;switch(e.typeId){case i.Classroom:return"text-teal-hover";case i.ClassroomGroup:return`text-${C((t=e.metadata)==null?void 0:t.colour)}-hover`}}function j(e){var a;let t=`${s.svgContainer} ${s.icon}`;return e.typeId===i.Classroom?t+=" text-teal":t+=` text-${C((a=e.metadata)==null?void 0:a.colour)}`,t}function Y(e){var o;const t=K(e.selection),a=e.selection.typeId===i.Classroom;if(!e.canExpand){if(!e.selection.typeId||e.selection.typeId===i.User){const r=e.selection;return n.jsx("div",{className:s.svgContainer,children:n.jsx(M,{imageUrl:(o=r.avatar)==null?void 0:o.url,initials:u.getInitials(e.selection.name,e.selection.surname)})})}return n.jsx(F,{title:J(a?"emptyClassroom":"emptyGroup"),children:n.jsx("div",{className:`align-items-center border border-white bg-white ${s.iconContainer}`,children:n.jsx(c,{className:j(e.selection),svg:a?f:_})})})}return e.hasExpanded?n.jsx("div",{className:`d-flex align-items-center text-white ${s.spinnerContainer} ${s.svgContainer}`,children:n.jsx(G,{as:"div",size:"sm",animation:"border",role:"status"})}):n.jsxs(n.Fragment,{children:[n.jsx(x,{className:`align-items-center cursor-pointer text-white border border-white rounded-circle ${s.expander} ${t}`,onClick:e.onClickExpand,children:n.jsx(c,{svg:B,className:`d-flex align-items-center ${s.svgContainer}`})}),n.jsx("div",{className:`align-items-center border border-white bg-white ${s.iconContainer}`,children:n.jsx(c,{className:j(e.selection),svg:a?f:_})})]})}function m(e){var t;if(!e.typeId)return"ultramarine";switch(e.typeId){case i.User:return typeof e.userType=="number"?e.userType===2?"ultramarine":"indigo":e.userType===V.Learner?"ultramarine":"indigo";case i.Classroom:return"teal";case i.ClassroomGroup:return C((t=e.metadata)==null?void 0:t.colour)}}function ee(e){var g,v,h;const t=E.isType(e.selection,i.Classroom),a=E.isType(e.selection,i.ClassroomGroup),o=e.onClickExpand&&(t||a),r=!!((g=e.selection.users||e.selection.enrolments)!=null&&g.count),y=!!((h=(v=e.selection.users)==null?void 0:v.data)!=null&&h.length),[N,S]=d.useState(!1),[T,I]=d.useState(o&&r);d.useEffect(()=>{I(o&&r)},[o,r]);function w(){S(!0),e.onClickExpand(e.selection.id)}if(y){const q=e.selection,l=m(e.selection);return n.jsxs("div",{className:`d-flex align-items-center flex-wrap me-1 mt-1 pb-1 ps-1 pe-4 position-relative border-${l} text-${l} ${s.bubble}`,children:[q.users.data.map(b=>n.jsx(k,{selection:b,colourVariant:l,hasStudentExperience:e.hasStudentExperience},`${b.id}:${e.selection.id}`)),n.jsx(x,{className:`cursor-pointer position-absolute text-${l} ${s.removeBubble}`,onClick:()=>e.onClickRemove(e.selection),children:n.jsx(c,{svg:$,className:`d-flex align-items-center ${s.svgContainer}`})})]})}return n.jsx(k,{selection:e.selection,canExpand:T,hasExpanded:N,onClickExpand:w,onClickRemove:e.onClickRemove,colourVariant:m(e.selection),hasStudentExperience:e.hasStudentExperience})}function k(e){const t=e.colourVariant||m(e.selection);let a=e.selection.name;return e.selection.typeId===i.User&&(a=e.hasStudentExperience?u.getDisplayName(e.selection):u.getFullName(e.selection)),n.jsxs("div",{className:`${s.selection} bg-${t} rounded-pill text-${t} d-flex align-items-center me-1 mt-1 overflow-hidden`,children:[!e.hideExpander&&n.jsx(Y,{canExpand:e.canExpand,hasExpanded:e.hasExpanded,onClickExpand:e.onClickExpand,selection:e.selection}),n.jsx("span",{className:"mx-1 text-white text-truncate",children:a}),U.isFunction(e.onClickRemove)&&n.jsx(x,{className:`d-flex align-items-center cursor-pointer align-self-stretch text-white ${s.remove}`,onClick:()=>e.onClickRemove(e.selection),children:n.jsx(c,{svg:$,className:`d-flex align-items-center ${s.svgContainer}`})})]})}export{k as I,ee as a};
//# sourceMappingURL=BSRfXcBg.chunk.js.map
