1 line
14 KiB
JavaScript
1 line
14 KiB
JavaScript
import{Ct as e,Dt as t,Jt as n,Kt as r,Ln as i,Ot as a,Rn as o,Rt as s,St as c,Xt as l,Yt as u,an as d,bt as f,gn as p,ht as m,kt as h,l as ee,on as g,wt as _,xn as v,xt as y,zn as b}from"./client-lOiq7Q_J.js";import{n as x,r as te,t as ne}from"./ui-GnK2cvI_.js";import{t as re}from"./Button-DfvYTndQ.js";import{t as S}from"./_plugin-vue_export-helper-DFB8HrqU.js";import{n as ie,t as ae}from"./PlaceBlock-D2hRRmTG.js";import{t as C}from"./Input-CIaNJLrA.js";import{t as w}from"./Alert-CkPrF7-5.js";import{t as T}from"./Flex-BB8sb381.js";import{t as oe}from"./Rate-DoHcEwPI.js";import{t as se}from"./QrCode-DwT9G7ka.js";import{i as ce,o as le,r as ue,st as E,w as de}from"./index-C3-4MRIk.js";import{t as D}from"./HeaderText-DrPkNVVP.js";import{t as fe}from"./useDeviceContext-DrZWG3Q_.js";import{t as O}from"./MessagePaper-AWb1GqOb.js";var k={xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,viewBox:`0 0 24 24`},A=h({name:`ContactMailRound`,render:function(e,t){return r(),_(`svg`,k,t[0]||=[y(`path`,{d:`M21 8V7l-3 2l-3-2v1l2.72 1.82a.5.5 0 0 0 .55 0L21 8zm1-5H2C.9 3 0 3.9 0 5v14c0 1.1.9 2 2 2h20c1.1 0 1.99-.9 1.99-2L24 5c0-1.1-.9-2-2-2zM8 6c1.66 0 3 1.34 3 3s-1.34 3-3 3s-3-1.34-3-3s1.34-3 3-3zm6 12H2v-1c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1zm7.5-6h-7c-.28 0-.5-.22-.5-.5v-5c0-.28.22-.5.5-.5h7c.28 0 .5.22.5.5v5c0 .28-.22.5-.5.5z`,fill:`currentColor`},null,-1)])}}),j={xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,viewBox:`0 0 512 512`},M=h({name:`Footsteps`,render:function(e,t){return r(),_(`svg`,j,t[0]||=[y(`path`,{d:`M133.83 361.27c-22.61 0-41-8.17-54.79-24.39s-22.84-40.29-28.11-75.31c-7.76-51.61-.06-95.11 21.68-122.48c12.8-16.12 29.6-25.44 48.58-26.94c16.25-1.3 40.54 5.29 64 44c14.69 24.24 25.86 56.44 30.65 88.34c5.79 38.51 1.48 66.86-13.18 86.65c-11.64 15.72-29.54 25.46-53.21 29a106.46 106.46 0 0 1-15.62 1.13z`,fill:`currentColor`},null,-1),y(`path`,{d:`M173 496c-13.21 0-26.6-4.23-38.66-12.36a79.79 79.79 0 0 1-33.52-50.6c-2.85-14.66-1.14-26.31 5.22-35.64c10.33-15.15 28.87-18.56 48.49-22.18c2.07-.38 4.17-.76 6.3-1.17c4.52-.86 9.14-2 13.62-3.11c16.78-4.14 34.14-8.43 48.47 1.75c9.59 6.8 15 18.36 16.62 35.32c1.84 19.57-2.36 39.1-11.83 55c-10.19 17.11-25.47 28.42-43 31.86A61 61 0 0 1 173 496z`,fill:`currentColor`},null,-1),y(`path`,{d:`M378.17 265.27a106.69 106.69 0 0 1-15.6-1.2c-23.66-3.5-41.56-13.25-53.2-29c-14.66-19.79-19-48.13-13.18-86.65c4.79-31.93 15.93-64.1 30.55-88.25c23.34-38.57 47.66-45.26 64-44.08c18.92 1.38 35.69 10.57 48.51 26.6c21.89 27.37 29.65 71 21.86 122.84c-5.27 35-14.2 58.95-28.11 75.31s-32.22 24.43-54.83 24.43z`,fill:`currentColor`},null,-1),y(`path`,{d:`M339 400a61 61 0 0 1-11.68-1.13c-17.56-3.44-32.84-14.75-43-31.86c-9.47-15.9-13.67-35.43-11.83-55c1.6-17 7-28.52 16.62-35.33c14.33-10.17 31.69-5.89 48.47-1.74c4.48 1.1 9.1 2.24 13.62 3.11l6.29 1.17c19.63 3.61 38.17 7 48.5 22.17c6.36 9.33 8.07 21 5.22 35.64a79.78 79.78 0 0 1-33.52 50.61C365.56 395.78 352.17 400 339 400z`,fill:`currentColor`},null,-1)])}}),N={},P={class:`belt-block`};function F(e,t){return r(),_(`div`,null,[t[0]||=y(`div`,{class:`shadow shadow-top`},null,-1),t[1]||=y(`div`,{class:`shadow shadow-bottom`},null,-1),y(`div`,P,[u(e.$slots,`default`,{},void 0,!0)])])}var I=S(N,[[`render`,F],[`__scopeId`,`data-v-bec154c5`]]),L={},R={class:`plate-block`},z={class:`metal-plate-block`};function B(e,t){return r(),_(`div`,R,[y(`div`,z,[u(e.$slots,`default`,{},void 0,!0)]),t[0]||=y(`div`,{class:`pin pin-top-left`},null,-1),t[1]||=y(`div`,{class:`pin pin-top-right`},null,-1),t[2]||=y(`div`,{class:`pin pin-bottom-right`},null,-1),t[3]||=y(`div`,{class:`pin pin-bottom-left`},null,-1)])}var V=S(L,[[`render`,B],[`__scopeId`,`data-v-4833fe7e`]]),H={class:`form-custom`},U={class:`center-block-700`},W={class:`controller`},G={class:`counters-block`},K={class:`counter-block`},q={class:`places-text`},J={class:`counter-block`},pe={class:`places-text`},Y={class:`game-input`},X=[`placeholder`,`disabled`],Z=[`aria-busy`,`disabled`],me=S(h({__name:`GameInputForm`,props:{addAction:{type:Function},allPlacesCount:{},newPlacesCount:{},gameStatus:{}},setup(i){let o=i,s=p(``),l=p(!1);async function u(){if(!(l.value||o.gameStatus!=`run`||s.value.length==0)){l.value=!0;try{await o.addAction(s.value)&&(s.value=``)}finally{l.value=!1}}}function f(e){e%=100;let t=Math.floor(e/10)%10,n=e%10,r=`–`,i=`–`;return t>0&&(r=String(t)),(n>0||t>0)&&(i=String(n)),[r,i]}return(p,h)=>(r(),_(`div`,H,[a(I,{class:`input-form`},{default:d(()=>[a(V,{class:`controller-metal controller-metal-left`}),a(V,{class:`controller-metal controller-metal-right`}),y(`div`,U,[y(`div`,W,[y(`div`,G,[y(`div`,K,[y(`div`,q,[a(v(x),{class:`icon-for-counter`},{default:d(()=>[a(v(M))]),_:1})]),(r(!0),_(m,null,n(f(i.allPlacesCount),(e,t)=>(r(),_(`div`,{key:t,class:`places-text places-text-number`},b(e),1))),128))]),y(`div`,J,[y(`div`,pe,[a(v(x),{class:`icon-for-counter`},{default:d(()=>[a(v(A))]),_:1})]),(r(!0),_(m,null,n(f(i.newPlacesCount),(e,t)=>(r(),_(`div`,{key:t,class:`places-text places-text-number`},b(e),1))),128))])]),y(`div`,Y,[g(y(`input`,{id:`run`,class:`game-input-run`,"onUpdate:modelValue":h[0]||=e=>s.value=e,type:`text`,placeholder:o.gameStatus==`run`?`Место назначения`:`Ходы запрещены`,disabled:o.gameStatus!=`run`||l.value},null,8,X),[[E,s.value]])]),h[3]||=y(`div`,{class:`game-button-run-shadow`},null,-1),y(`button`,{class:`game-button-run`,type:`submit`,"aria-busy":l.value,disabled:o.gameStatus!=`run`||s.value.length==0||l.value,onClick:u},[o.gameStatus==`run`?(r(),c(D,{key:0},{default:d(()=>[t(b(l.value?`Отправляем…`:`Поехали`),1)]),_:1})):e(``,!0),o.gameStatus==`pause`||o.gameStatus==`draft`?(r(),c(D,{key:1},{default:d(()=>[...h[1]||=[t(`Ждём`,-1)]]),_:1})):e(``,!0),o.gameStatus==`finish`?(r(),c(D,{key:2},{default:d(()=>[...h[2]||=[t(`Всё`,-1)]]),_:1})):e(``,!0)],8,Z)])])]),_:1})]))}}),[[`__scopeId`,`data-v-b5d098e6`]]),he={key:1,class:`center-block-custom`},ge={class:`width700`},_e={key:0,class:`width700`},ve=[`disabled`],ye={key:1,class:`width700`},be={class:`question-text`},xe={class:`qr-main-block-text`},Se={class:`qr-block`},Ce={key:4,class:`edit-panel`},Q=S(h({__name:`TeamStoryPage`,setup(u){let h=le(),g=ne(),x=ce(),S=te(),E=ee(),D=String(E.params.id),k=E.query.password;fe(()=>({teamID:D,password:typeof k==`string`?k:void 0}));let A=p(0),j=p([]),M=p(``),N=0,P=0,F=!1,I=p(),L=p({introduction:void 0,places:[],questions:[]}),R=p({ID:void 0,name:void 0,description:void 0,startAt:void 0,status:void 0,format:void 0,location:void 0,scenario:void 0,teams:void 0,export:void 0}),z=p(``),B=f(()=>R.value?.teams?.find(e=>e.ID===D)?.name),V=f(()=>g.environment===`prod`&&R.value?.export?.state===`ready`),H=`game-review-${D}`,U=p(localStorage.getItem(H)===`1`),W=p(0),G=p(0),K=p(``),q=p(!1),J=window.location.href,pe=()=>{let e=I.value;return e?e.scrollHeight-e.scrollTop-e.clientHeight<1:!1};async function Y(e=!1){let t=++N;P++;let n;try{n=await x.GetTeamStory({ID:D,password:k})}catch(e){return t===N?(M.value=`Не удалось загрузить дело. Попробуйте обновить страницу.`,console.error(`Failed to load team story:`,e),!1):!1}finally{P--}if(t!==N)return!1;let r=L.value;M.value=``,R.value=n.game;let i=pe();i&&(A.value=0);let a=L.value.places.length;L.value={background:n.story.background,introduction:n.story.introduction,places:n.story.places?.map((e,t)=>({place:e,mode:r?.places[t]?.mode||`show`}))||[],questions:n.story.questions||[]},j.value=n.actions||[];let o=L.value.places.length;if(o>a&&a!=0&&(A.value+=o-a),await s(),e){let e=I.value,t=e?.querySelectorAll(`.story-place`),n=t?.item(t.length-1);e&&n&&e.scrollTo({top:e.scrollTop+n.getBoundingClientRect().top-e.getBoundingClientRect().top,behavior:`instant`}),A.value=0}else if(i&&a!=0){let e=I.value;if(!e)return!1;e.scrollTop=e.scrollHeight}return!0}g.load().catch(e=>{S.error(`Не удалось загрузить сведения сервера`),console.error(`Failed to load server information:`,e)}),Y(),Q();async function X(e){if(F)return!1;F=!0,N++;try{return await x.AddTeamAction({ID:D,password:k,code:e}),z.value=``,await Y(!0)||S.error(`Ход сохранён, но не удалось обновить дело. Обновите страницу.`),!0}catch(e){return S.error(e instanceof Error?e.message:`Не удалось сделать ход`),!1}finally{F=!1}}let Z=p({});async function Q(){let e;try{e=await x.GetTeamAnswers({ID:D,password:k})}catch(e){M.value=`Не удалось загрузить ответы команды. Попробуйте обновить страницу.`,console.error(`Failed to load team answers:`,e);return}M.value=``;let t={};for(let n of e.answers||[])t[n.questionCode||``]=n.answer||``;Z.value=t}async function we(){await x.SubmitTeamAnswers({ID:D,password:k,answers:(L.value.questions||[]).map(e=>({questionCode:e.code,answer:Z.value[e.code||``]||``}))}),S.success(`Ответы сохранены`),await Q()}let Te=f(()=>R.value?.format!==`offline`&&(R.value?.status==`run`||R.value?.status==`pause`)),Ee=f(()=>R.value?.format!==`offline`&&(L.value.questions?.length||0)>0),$={Input:{border:`1px dashed black`,borderDisabled:`1px dashed black`,borderFocus:`1px solid black`,borderHover:`1px dashed black`,boxShadowFocus:`0 0 0 1px black`,caretColor:`black`,color:`transparent`,colorDisabled:`transparent`,colorFocus:`transparent`,fontSizeMedium:`18px`,placeholderColor:`black`,placeholderColorDisabled:`black`,textColor:`black`,textColorDisabled:`black`},Rate:{itemColor:`black`,itemColorHover:`#b8860b`,itemColorActive:`#b8860b`}};async function De(){if(!W.value||!G.value||K.value.trim()===``){S.error(`Поставьте оценки и напишите отзыв`);return}q.value=!0,await x.CreateGameReview({gameID:Number(R.value?.ID),teamID:D,password:k,rating:W.value,difficulty:G.value,text:K.value.trim()}),q.value=!1,U.value=!0,localStorage.setItem(H,`1`),S.success(`Спасибо за отзыв`)}async function Oe(){await x.DeleteLastTeamAction({ID:D}),await Y(),z.value=``}return ue(()=>{!F&&P===0&&Y()},2e3),(s,u)=>{let f=l(`n-space`);return r(),_(m,null,[L.value.background&&!V.value?(r(),_(`div`,{key:0,class:`case-background`,style:o({backgroundImage:`url(${JSON.stringify(L.value.background)})`}),"aria-hidden":`true`},null,4)):e(``,!0),V.value?(r(),_(`div`,he,[y(`div`,ge,[a(v(w),{type:`error`,role:`alert`},{default:d(()=>[...u[4]||=[t(` Подключитесь к Wi-Fi организатора и обновите страницу. `,-1)]]),_:1})])])):(r(),_(`div`,{key:2,class:i([`center-block-custom bottom-margin smooth-scroll`,{"game-finished":R.value?.status===`finish`}]),ref_key:`scrollContainer`,ref:I},[R.value?.status===`finish`?(r(),_(`div`,_e,[a(O,{role:`status`},{default:d(()=>[...u[5]||=[y(`div`,{class:`font`},`Игра завершена. Спасибо за участие!`,-1)]]),_:1}),U.value?e(``,!0):(r(),c(O,{key:0,class:`review-block`},{default:d(()=>[u[8]||=y(`div`,{class:`font`},`Оцените игру`,-1),u[9]||=y(`hr`,{class:`questions-hr`},null,-1),a(v(de),{"theme-overrides":$},{default:d(()=>[u[6]||=y(`div`,{class:`review-rating font`},`Оценка`,-1),a(v(oe),{value:W.value,"onUpdate:value":u[0]||=e=>W.value=e,count:5,class:`review-rate`},null,8,[`value`]),u[7]||=y(`div`,{class:`review-rating font`},`Сложность`,-1),a(v(oe),{value:G.value,"onUpdate:value":u[1]||=e=>G.value=e,count:3,class:`review-rate`},null,8,[`value`]),a(v(C),{value:K.value,"onUpdate:value":u[2]||=e=>K.value=e,class:`review-input`,type:`textarea`,autosize:{minRows:4,maxRows:8},placeholder:`Расскажите, как прошла игра`},null,8,[`value`]),a(v(T),{justify:`end`,class:`questions-actions`},{default:d(()=>[y(`button`,{type:`button`,class:`paper-button`,disabled:q.value,onClick:De},` Отправить отзыв `,8,ve)]),_:1})]),_:1})]),_:1}))])):(r(),_(`div`,ye,[M.value?(r(),c(v(w),{key:0,type:`error`,role:`alert`},{default:d(()=>[t(b(M.value),1)]),_:1})):e(``,!0),a(me,{addAction:X,allPlacesCount:L.value.places.length,newPlacesCount:A.value,gameStatus:R.value?.status||``},null,8,[`allPlacesCount`,`newPlacesCount`,`gameStatus`]),R.value?.format!==`offline`&&R.value?.status&&R.value.status!=`draft`&&L.value.introduction&&(L.value.introduction.text||L.value.introduction.audio)?(r(),c(ie,{key:1,introduction:L.value.introduction,mode:`show`},null,8,[`introduction`])):e(``,!0),Ee.value&&R.value?.status&&R.value.status!=`draft`?(r(),c(O,{key:2,class:`questions-block`},{default:d(()=>[u[10]||=y(`div`,{class:`font`},`Вопросы дела`,-1),u[11]||=y(`hr`,{class:`questions-hr`},null,-1),u[12]||=y(`p`,{class:`questions-hint font`},` Ответьте на вопросы дела. Ответы можно менять, пока игра идёт. `,-1),a(v(de),{"theme-overrides":$},{default:d(()=>[(r(!0),_(m,null,n(L.value.questions,e=>(r(),_(`div`,{key:e.code,class:`question-item font`},[y(`div`,be,b(e.code)+`: `+b(e.text),1),a(v(C),{value:Z.value[e.code||``],"onUpdate:value":t=>Z.value[e.code||``]=t,type:`textarea`,autosize:{minRows:2,maxRows:6},disabled:!Te.value,placeholder:`Ваш ответ...`},null,8,[`value`,`onUpdate:value`,`disabled`])]))),128)),Te.value?(r(),c(v(T),{key:0,justify:`end`,class:`questions-actions`},{default:d(()=>[y(`button`,{type:`button`,class:`paper-button`,onClick:u[3]||=e=>we()},` Сохранить ответы `)]),_:1})):e(``,!0)]),_:1})]),_:1})):e(``,!0),(r(!0),_(m,null,n(L.value.places,(e,t)=>(r(),_(`div`,{key:`${R.value?.format}:${e.place.code}`,class:`story-place`},[a(ae,{place:e.place,mode:e.mode,"onUpdate:mode":t=>e.mode=t,mcp:v(h).hasRole(`author`)&&j.value[t]?.mcp,addAction:X},null,8,[`place`,`mode`,`onUpdate:mode`,`mcp`])]))),128)),L.value.places.length==0&&R.value?.status==`draft`?(r(),c(O,{key:3,class:`qr-main-block`},{default:d(()=>[a(f,{vertical:``},{default:d(()=>[y(`p`,xe,[y(`strong`,null,b(B.value),1)]),u[13]||=y(`h2`,{class:`qr-main-block-text`},`Код для подключения`,-1),y(`div`,Se,[a(v(se),{value:v(J),size:300,padding:0},null,8,[`value`])]),u[14]||=y(`p`,{class:`qr-main-block-text`},`Игра скоро начнется`,-1)]),_:1})]),_:1})):e(``,!0),v(h).hasRole(`author`)&&L.value.places.length>0?(r(),_(`div`,Ce,[a(v(T),{justify:`end`},{default:d(()=>[a(v(re),{onClick:Oe},{default:d(()=>[...u[15]||=[t(`Удалить последний ход`,-1)]]),_:1})]),_:1})])):e(``,!0)]))],2))],64)}}}),[[`__scopeId`,`data-v-02b0041c`]]),we=h({__name:`TeamStoryView`,setup(e){let t=ee();return(e,n)=>(r(),c(Q,{key:v(t).fullPath}))}});export{we as default}; |