"use strict";(self.webpackChunkweb_toolbox=self.webpackChunkweb_toolbox||[]).push([[861],{32376:(e,t,a)=>{a.d(t,{A:()=>m});var n=a(9950),o=a(69935),r=a(10226),l=a(67243),i=a.n(l),s=a(77671);const m=e=>{let{data:t,isDisabled:a,hoverMessage:l,feedbackMessage:m,Icon:c=o.A,...d}=e;const{setToasterState:u}=(0,s.dq)();return n.createElement(r.A,Object.assign({disabled:!t||a,title:null!==l&&void 0!==l?l:"Copy to clipboard",variant:"contained","data-testid":"copy-to-clipboard",color:"primary"},d,{onClick:()=>{if(!t)return;const e=null!==m&&void 0!==m?m:"Content copied into clipboard: ".concat(t.substring(0,25)," \u2026");i()(t,{format:"text/plain"}),u({open:!0,message:e,type:"success",autoHideDuration:2e3})}}),n.createElement(c,null))}},50057:(e,t,a)=>{a.d(t,{n:()=>s});var n=a(9950),o=a(25131),r=a(72772),l=a(73931);const i=(0,o.A)((e=>({root:{margin:e.spacing(1)}}))),s=e=>{let{title:t,iconType:a,children:o}=e;const s=i();return n.createElement(n.Fragment,null,n.createElement(r.m,{titleTemplate:"Web Toolbox - %s",defaultTitle:"Web Toolbox",title:t}),n.createElement("div",{className:s.root},n.createElement(l.A,{iconType:a,title:t}),o))}},73931:(e,t,a)=>{a.d(t,{A:()=>l});var n=a(9950),o=a(82053);const r=(0,a(25131).A)((e=>({title:{wordBreak:"break-word"},titleWithIcon:{display:"flex",justifyContent:"center",alignItems:"center",marginBottom:e.spacing(1)},icon:{height:"40px",width:"40px",marginRight:e.spacing(1)}}))),l=e=>{let{title:t,iconType:a}=e;const l=r();return n.createElement("div",{className:l.titleWithIcon},n.createElement(a,{className:l.icon}),n.createElement(o.A,{variant:"h5",className:l.title},t))}},78861:(e,t,a)=>{a.r(t),a.d(t,{default:()=>me,mapDispatchToProps:()=>se,mapStateToProps:()=>ie});var n=a(9950),o=a(26592),r=a(54684),l=a(84689),i=a(53316),s=a(62375),m=a(62462),c=a(60899),d=a(1320),u=a(2235),p=a(15769),g=a(69780),E=a(9213),h=a(25333),v=a(34075),y=a(82053),k=a(10226),f=a(88021),b=a(10300),A=a(28429),N=a(33602),P=a(58757),C=a(32376),S=a(50057),x=a(77671),w=a(98927),I=a(32193);const U=function(){let e=arguments.length>1?arguments[1]:void 0;return{type:"vote",payload:{username:arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",estimate:e,estimatedAtISO8601:e?(new Date).toISOString():void 0}}},T=["?","0","0.5","1","1.5","2","2.5","3","3.5","4","4.5","5","8","13","20","40","100"],D=["?","0","1","2","3","5","8","13","20","40","100"],L=["?","S","M","L","XL"],W=["?","XS","S","M","L","XL","XXL"],R=e=>(t,a)=>{var n,o;return e.indexOf(null!==(n=t.estimate)&&void 0!==n?n:"?")-e.indexOf(null!==(o=a.estimate)&&void 0!==o?o:"?")},O={fibonnacy:{values:D,displayValue:D.slice(2).join(" "),sorter:R(D)},"fibonnacy-variant-1":{values:T,displayValue:T.slice(2).map((e=>e.replace("0.5","\xbd"))).map((e=>e.replace(".5","\xbd"))).join(" "),sorter:R(T)},"t-shirt":{values:L,displayValue:L.slice(1).join(" "),sorter:R(L)},"t-shirt-variant-1":{values:W,displayValue:W.slice(1).join(" "),sorter:R(W)}},H="fibonnacy",M="default",j="localhost",V=new Map([[WebSocket.CLOSED,"closed"],[WebSocket.OPEN,"open"],[WebSocket.CLOSING,"closing"],[WebSocket.CONNECTING,"connecting"]]);var X=a(14857),J=a(1810);const B=e=>{let{value:t,isDisabled:a,isSelected:o,onClick:r}=e;const l=(0,X.A)(),i=(0,J.Pb)("md")?"70px":"48px";return n.createElement(k.A,{style:{maxWidth:i,maxHeight:i,minWidth:i,minHeight:i,margin:l.spacing(1)},variant:o?"contained":"outlined",disabled:a,title:"Estimate the current story point as: [".concat(t,"]"),color:"primary",onClick:()=>r(t)},n.createElement(y.A,{variant:"h5"},t))};var _=a(13260),q=a(25979),z=a(2046),G=a(23266),Z=a(8145),F=a(21671),Q=a(39287),Y=a(25131);const K=(0,Q.A)((()=>({body:{fontSize:14,whiteSpace:"normal",wordBreak:"break-word"}})))(F.A),$=(0,Q.A)((e=>({root:{"&:nth-of-type(even)":{backgroundColor:e.palette.action.hover}}})))(E.A),ee=(0,Y.A)((e=>({toolbar:{height:"100%",margin:0,padding:0,"& > *":{marginLeft:e.spacing(1)}},formControl:{marginRight:e.spacing(1)},submitEstimate:{marginTop:e.spacing(2),display:"flex",justifyContent:"center",flexWrap:"wrap"},teamEstimates:{marginTop:e.spacing(4)},tableHeader:{backgroundColor:e.palette.primary.main}})));const te=(0,b.Ng)((function(e){return{lastPokerPlanningHostName:e.textInputs.lastPokerPlanningHostName,lastPokerPlanningRoomName:e.textInputs.lastPokerPlanningRoomName,lastPokerPlanningUsername:e.textInputs.lastPokerPlanningUsername,lastPokerCardsListingCategoryName:e.textInputs.lastPokerCardsListingCategoryName}}),(function(e){return{storeInputText:(t,a)=>e((0,N.s)(t,a))}}))((e=>{let{lastPokerPlanningRoomName:t,lastPokerPlanningUsername:a,lastPokerPlanningHostName:o,lastPokerCardsListingCategoryName:r,storeInputText:l,socketState:i}=e;const s=ee(),m=(0,X.A)(),{hostName:d,roomUUID:u,roomName:p}=(0,A.g)(),g=(0,w.Ed)(p)&&(0,w.Ed)(d)&&(0,w.Ed)(u),E=r||H;return n.createElement(c.Ay,{container:!0,spacing:1},n.createElement(c.Ay,{item:!0,md:4,xs:6},n.createElement(q.A,{className:s.formControl,fullWidth:!0},n.createElement(Z.A,{label:"Serveur (channel ".concat(i,")"),placeholder:"Type the poker plannind hostname here",variant:"outlined",fullWidth:!0,margin:"normal",value:o,title:o,disabled:g,onChange:e=>l("lastPokerPlanningHostName",e.target.value),InputProps:{endAdornment:n.createElement(z.A,{position:"end"},n.createElement(h.A,{title:"Instruction to setup a poker planning server",target:"_blank",href:"https://github.com/amwebexpert/ws-poker-planning#wspokerplanning-server-production-deployment"},n.createElement(_.A,null)))}}))),n.createElement(c.Ay,{item:!0,md:2,xs:6},n.createElement(q.A,{className:s.formControl,fullWidth:!0},n.createElement(Z.A,{label:"Team name",placeholder:"Type the team name here",variant:"outlined",fullWidth:!0,margin:"normal",value:t,title:t,disabled:g,onChange:e=>l("lastPokerPlanningRoomName",e.target.value)}))),n.createElement(c.Ay,{item:!0,md:2,xs:6},n.createElement(q.A,{className:s.formControl,fullWidth:!0},n.createElement(Z.A,{label:"Your name",placeholder:"Type your name here",variant:"outlined",fullWidth:!0,margin:"normal",value:a,onChange:e=>l("lastPokerPlanningUsername",e.target.value)}))),n.createElement(c.Ay,{item:!0,md:4,xs:6},n.createElement(q.A,{className:s.formControl,fullWidth:!0},n.createElement(Z.A,{select:!0,label:"Poker card types",style:{marginTop:m.spacing(2)},variant:"outlined",fullWidth:!0,title:E,value:E,onChange:e=>l("lastPokerCardsListingCategoryName",e.target.value)},Object.entries(O).map((e=>{let[t,a]=e;return n.createElement(G.A,{key:t,value:t,title:t},a.displayValue)}))))))}));var ae=a(31219),ne=a(99946);const oe=e=>{var t;return null!==(t=V.get(e))&&void 0!==t?t:"closed"},re=e=>{let{hostName:t=j,roomName:a=M,roomUUID:n=(0,ne.A)()}=e;return"/PokerPlanning/".concat(t,"/").concat(n,"/").concat(encodeURIComponent(a))},le=e=>document.location.href.split("/#/")[0]+"/#"+re(e);function ie(e){return{lastPokerPlanningHostName:e.textInputs.lastPokerPlanningHostName,lastPokerPlanningRoomName:e.textInputs.lastPokerPlanningRoomName,lastPokerPlanningUsername:e.textInputs.lastPokerPlanningUsername,lastPokerCardsListingCategoryName:e.textInputs.lastPokerCardsListingCategoryName}}function se(e){return{storeInputText:(t,a)=>e((0,N.s)(t,a))}}const me=(0,b.Ng)(ie,se)((e=>{var t;let{lastPokerPlanningRoomName:a,lastPokerPlanningUsername:b,lastPokerPlanningHostName:N,lastPokerCardsListingCategoryName:T,storeInputText:D}=e;const L=ee(),W=(0,A.Zp)(),{showConfirmationDialog:R}=(0,P.Z)(),{setToasterState:M}=(0,x.dq)(),{hostName:V,roomUUID:X,roomName:J}=(0,A.g)(),_=(0,n.useRef)(),[q,z]=(0,n.useState)("closed"),[G,Z]=(0,n.useState)(),[F,Q]=(0,n.useState)(),[Y,ie]=(0,n.useState)(!1),[se,me]=(0,n.useState)(),ce="Poker planning ".concat(null!==a&&void 0!==a?a:"").trim(),de=null!==(t=null===se||void 0===se?void 0:se.estimates)&&void 0!==t?t:[],ue=O[T||H],{estimatesAverage:pe,isEstimatesCleared:ge,isUserMemberOfRoom:Ee}=((e,t)=>{const a=e.map((e=>e.estimate)).filter((e=>!!e)).filter((e=>(0,w.kf)(e))).map((e=>Number(e))),n=a.reduce(((e,t)=>e+Number(t)),0),o=a.length>0?n/a.length:0;return{values:a,estimatesSum:n,estimatesAverage:Math.round(10*o+Number.EPSILON)/10,isEstimatesCleared:e.length>0&&e.every((e=>void 0===e.estimate)),isUserMemberOfRoom:!(null===t||void 0===t||!t.trim())&&e.some((e=>e.username===t))}})(de,b),he=_&&(0,w.Ed)(J)&&(0,w.Ed)(V)&&(0,w.Ed)(X),ve=he&&(0,w.Ed)(b),ye=(0,w.Ed)(N)&&(0,w.Ed)(a);(0,n.useEffect)((()=>{V&&D("lastPokerPlanningHostName",V)}),[V,D]),(0,n.useEffect)((()=>{J&&D("lastPokerPlanningRoomName",J)}),[J,D]),(0,n.useEffect)((()=>{if(!se||!b)return;I.Lh&&console.info("poker session",se);const e=se.estimates.find((e=>e.username===b));e&&Z(e.estimate)}),[b,se]),(0,n.useEffect)((()=>{if(he)return _.current=(e=>{let{hostName:t=j,roomUUID:a=(0,ne.A)(),onSocketStateUpdate:n,onSessionUpdate:o}=e;const r="https:"===document.location.protocol?"wss":"ws",l="".concat(r,"://").concat(t,"/ws?roomUUID=").concat(a),i=new ae.A(l);return i.onopen=()=>n(oe(i.readyState)),i.onerror=()=>n(oe(i.readyState)),i.onclose=()=>n(oe(i.readyState)),i.onmessage=e=>{const t=JSON.parse(e.data);o(t)},i})({hostName:V,roomUUID:X,onSessionUpdate:me,onSocketStateUpdate:z}),()=>{var e;return null===(e=_.current)||void 0===e?void 0:e.close()}}),[_,he,V,X]);(0,n.useEffect)((()=>{ge&&(ie(!1),Z(void 0))}),[ge]);const ke=e=>{_.current&&"open"===q?_.current.send(JSON.stringify(e)):Q(e)};(0,n.useEffect)((()=>{_.current&&"open"===q&&F&&(_.current.send(JSON.stringify(F)),Q(void 0))}),[F,q]);return n.createElement(S.n,{iconType:r.A,title:ce},n.createElement(c.Ay,{container:!0},n.createElement(c.Ay,{item:!0,md:9,xs:12},n.createElement(te,{socketState:q})),n.createElement(c.Ay,{item:!0,md:3,xs:12},n.createElement(c.Ay,{container:!0,justifyContent:"flex-end",alignItems:"center",className:L.toolbar},n.createElement(k.A,{sx:{mr:1},variant:"contained",title:"Register the team and start planning in a new room",color:"primary",disabled:!ye,onClick:()=>{const e=re({hostName:N,roomName:a});W(e,{replace:!0})}},"New"),n.createElement(k.A,{sx:{mr:1},variant:"contained",title:"Enter existing room",color:"primary",disabled:Ee||!ve,onClick:()=>ke(U(b))},"Join"),n.createElement(C.A,{sx:{mr:1},isDisabled:!he,data:le({hostName:V,roomUUID:X,roomName:J}),Icon:i.A,hoverMessage:"Copy link to clipboard for sharing",feedbackMessage:"Link copied to clipboard, you can now share to all members"}),n.createElement(k.A,{variant:"contained",title:"Copy QRCode for sharing",disabled:!he,onClick:async()=>{try{const e=le({hostName:V,roomUUID:X,roomName:J}),t=await f.toDataURL(e,{type:"image/png",width:200}),a=await fetch(t),n=await a.blob();await navigator.clipboard.write([new ClipboardItem({"image/png":n})]),M({open:!0,message:"Image copied",type:"success",autoHideDuration:2e3})}catch(e){console.error(e);M({open:!0,message:"Unexpected copy error, see detail on console",type:"warning",autoHideDuration:2e3})}},color:"primary"},n.createElement(l.A,null))))),n.createElement("div",{className:L.submitEstimate},ue.values.map((e=>n.createElement(B,{key:e,isDisabled:!ve,isSelected:G===e,value:e,onClick:()=>(e=>{e!==G?(Z(e),ke(U(b,e))):(Z(void 0),ke(U(b)))})(e)})))),n.createElement(d.A,{component:u.A,className:L.teamEstimates},n.createElement(p.A,{size:"small"},n.createElement(g.A,{className:L.tableHeader},n.createElement(E.A,null,n.createElement(K,{component:"th",scope:"row",width:30}),n.createElement(K,{component:"th",scope:"row"},"Team member"),n.createElement(K,{component:"th",scope:"row",align:"center"},"Points",n.createElement(h.A,{title:"Toggle story points visibility",disabled:!Ee,onClick:()=>ie((e=>!e))},Y?n.createElement(m.A,null):n.createElement(s.A,null)),n.createElement(h.A,{onClick:()=>R({title:"Confirmation",description:"Are you sure you want to delete all votes?",onConfirm:()=>ke({type:"reset"})}),title:"Clear all votes",disabled:!Ee},n.createElement(o.A,null))))),n.createElement(v.A,null,de.sort(ue.sorter).map((e=>{let{username:t,estimate:a}=e;const r=null!==a&&void 0!==a?a:"\u2026",l=a?"\u2714":"\u2026";return n.createElement($,{key:t},n.createElement(K,{width:30},n.createElement(h.A,{disabled:!Ee,onClick:()=>ke(function(){return{type:"remove",payload:arguments.length>0&&void 0!==arguments[0]?arguments[0]:""}}(t)),title:'Remove user "'.concat(t,'"')},n.createElement(o.A,null))),n.createElement(K,null,t),n.createElement(K,{align:"center"},Y?r:l))})),n.createElement($,{key:"average"},n.createElement(K,{width:30}),n.createElement(K,null,n.createElement(y.A,null,"Story points average")),n.createElement(K,{align:"center"},n.createElement(y.A,null,Y?pe:"")))))))}))}}]);