import{ao as e,b0 as D,aI as c,hp as x,az as I,aj as V,be as w,gS as G,bS as P,cm as M,bT as K,cu as A,bW as O,cv as Q,aq as i,L as W,aC as J,at as X,ev as R,du as Y}from"./app-k0jcl5PQ.js";import{F as Z}from"./kLXBNYk1.chunk.js";import{L as o}from"./CCKlkV4O.chunk.js";import{L as ee}from"./BCKXZxoz.chunk.js";import{u as ae}from"./BDd2EAdq.chunk.js";const ne="_aviBackground_dbywv_1",te="_aviContainer_dbywv_5",se="_aviIcon_dbywv_8",f={aviBackground:ne,aviContainer:te,aviIcon:se},re=["🐵","🐒","🦍","🦧","🐶","🐕","🦮","🐕‍🦺","🐩","🐺","🦊","🦝","🐱","🐈","🐈‍⬛","🦁","🐯","🐅","🐆","🐴","🐎","🦄","🦓","🦌","🐮","🐂","🐃","🐄","🐷","🐖","🐗","🐽","🐏","🐑","🐐","🦙","🦒","🐘","🦣","🦏","🦛","🦘","🦥","🦦","🦨","🦡","🐇","🐁","🐀","🦔","🐿️","🦇","🐉","🦎","🐍","🐢","🐊","🦖","🦕","🐙","🦑","🦐","🦞","🦀","🦪","🐡","🐠","🐟","🐬","🐳","🐋","🦈","🦭","🐾"],ie=["bg-orange","bg-indigo","bg-teal","bg-cyan","bg-purple","bg-pink","bg-red","bg-yellow","bg-green","bg-blue"];function F(t,b){let r=0;for(let u=0;u<((t==null?void 0:t.length)??0);u++)r+=t.charCodeAt(u);return b[r%b.length]}function _(t){return e.jsxs("span",{className:`h1 d-block mb-0 position-relative ${f.aviContainer}`,children:[e.jsx("span",{className:`
        ${F(t.recipient.publicName,ie)}
        rounded-circle
        position-absolute
        top-0
        start-0
        bottom-0
        end-0
        ${f.aviBackground}
      `}),e.jsx("span",{className:`
          ${f.aviIcon}
          position-absolute
          top-50
          start-50
        `,children:F(t.recipient.publicName,re)})]})}const oe="_confirmationContainer_11fqp_1",ce={confirmationContainer:oe},s="launchpad.selectAnonUser",B=W.encloseNamespace(s);function pe(t){var y;const b=D(),[r,u]=c.useState(x.getAnonUser(t.shareId)||""),[L,H]=c.useState(!!x.getAnonUser(t.shareId)),[g,N]=c.useState(""),[j,l]=c.useState("enter-name"),[C,p]=c.useState(null),[n,v]=c.useState(null),k=I(V.currentUser()),m=ae(t.shareId),d=I(w.getShareRecipients(t.shareId));function U(a){u(a.target.value),N("")}c.useLayoutEffect(()=>{G.remove()},[]),c.useEffect(()=>{var a,h;if(d.hasCompleted){if(x.getAnonUser(t.shareId)){l("confirm"),p((a=d.data)!=null&&a.length?"select-user":"enter-name");return}(h=d.data)!=null&&h.length&&l("select-user")}},[d.hasCompleted]);async function T(){var a;x.setAnonUser(t.shareId,(n==null?void 0:n.publicName)||r.trim());try{const h=w.createAnonSession(t.shareId,R.getClientSessionData((a=k.data)==null?void 0:a.id).windowId,(n==null?void 0:n.publicName)||r.trim());await b(h)}finally{Y.Reload()}}function S(a){if(a.preventDefault(),!(r!=null&&r.trim())){N("Please provide a name");return}C||p("enter-name"),l("confirm")}function $(){n&&(p("select-user"),l("confirm"))}function E(a){v(a)}function q(){var a;u(""),l(C),H(!1),R.resetClientSession((a=k.data)==null?void 0:a.id)}if(!(m&&d.hasCompleted))return e.jsx(e.Fragment,{});const z=P.createUrl(M.getImageUrl(m),{size:K.Large});return e.jsxs(o,{children:[e.jsx(o.LeftImage,{title:m.name,imageUrl:z,objectType:m.typeId,fallbackImages:ee}),e.jsxs(o.Right,{children:[e.jsx(o.Header,{}),e.jsxs(o.Content,{children:[e.jsxs("div",{className:"mb-auto text-center",children:[A.isInteractive(m)&&e.jsx("div",{className:"mb-3 d-lg-none d-block w-75 mx-auto",children:e.jsx(O,{data:A.getThumbnail(m),imageType:Q.Thumbnails,className:"rounded-3 overflow-hidden"})}),e.jsx("h1",{className:"h2",children:m.name})]}),j==="enter-name"&&e.jsxs(e.Fragment,{children:[e.jsx(o.NarrowContent,{className:"mb-auto",children:e.jsx("form",{onSubmit:S,children:e.jsxs("div",{className:"form-group",children:[e.jsx("label",{className:"h2",htmlFor:"name",children:e.jsx(i,{namespace:s,phrase:"label"})}),e.jsx("input",{className:`form-control form-control-lg ${g?"is-invalid":""}`,type:"text","aria-label":B("placeholder"),placeholder:B("placeholder"),autoFocus:!0,value:r,onChange:U,autoComplete:"off",autoCorrect:"off",autoCapitalize:"none",spellCheck:"false",name:"name",id:"name"}),!!g&&e.jsx(Z,{name:"name",children:g})]})})}),e.jsxs(o.Buttons,{children:[!!((y=d.data)!=null&&y.length)&&e.jsx("button",{className:"btn btn-link btn-lg",onClick:()=>l("select-user"),children:e.jsx(i,{namespace:s,phrase:"back"})}),e.jsx("div",{className:"d-flex justify-content-end w-100",children:e.jsx("button",{className:"btn btn-lg btn-dark",onClick:S,children:e.jsx(i,{namespace:s,phrase:"continue"})})})]})]}),j==="select-user"&&e.jsxs(e.Fragment,{children:[e.jsxs(o.NarrowContent,{className:"mb-auto",children:[e.jsx("h2",{children:e.jsx(i,{namespace:s,phrase:"selectName"})}),e.jsx("ul",{className:"list-unstyled row",children:J.sortBy(d.data,a=>a.publicName).map((a,h)=>e.jsx("li",{className:"col-3 p-2",children:e.jsxs(X,{className:`text-center rounded border py-2 ${(n==null?void 0:n.id)===a.id?"border-info bg-light-blue":""}`,onClick:()=>E(a),children:[e.jsx("div",{className:"px-3",children:e.jsx(_,{recipient:a})}),e.jsx("p",{className:"mb-0 mt-2 fw-semibold text-truncate",children:a.publicName})]})},h))})]}),e.jsx(o.Buttons,{children:e.jsxs("div",{className:"d-flex justify-content-between w-100",children:[e.jsx("button",{className:"btn btn-lg btn-link",onClick:()=>{v(null),l("enter-name"),p("select-user")},children:e.jsx(i,{namespace:s,phrase:"cantFindName"})}),e.jsx("button",{className:"btn btn-lg btn-dark",onClick:$,disabled:!n,children:e.jsx(i,{namespace:s,phrase:"continue"})})]})})]}),j==="confirm"&&e.jsxs(o.NarrowContent,{className:"mb-auto text-center",children:[n&&e.jsx("div",{className:`${ce.confirmationContainer} mx-auto`,children:e.jsx(_,{recipient:n})}),e.jsx("p",{className:"h2",children:e.jsx(i,{namespace:s,phrase:L?"welcome":"hi",options:{name:(n==null?void 0:n.publicName)||r}})}),e.jsx("p",{className:"h2 mb-4",children:e.jsx(i,{namespace:s,phrase:"ready"})}),e.jsx("button",{className:"btn btn-lg btn-dark w-100 mb-3",onClick:T,children:e.jsx(i,{namespace:s,phrase:"start"})}),e.jsx("button",{className:"btn btn-lg btn-link w-100",onClick:q,children:e.jsx(i,{namespace:s,phrase:"notMyName"})})]})]})]})]})}export{pe as SelectAnonUserView};
//# sourceMappingURL=BPPq7XAU.chunk.js.map
