import{u as V,r as n,p as F,o as N,q as $,c as l,a as y,f as c,b as v,d as r,F as _,l as w,w as h,e as j,v as z,T as q,i as D,n as C,h as R,t as k,_ as b,j as s}from"./index-DsXh811X.js";const E=["src"],L={class:"flex flex-col gap-48 my-10 z-10"},P=["src"],A={key:0,class:"bg-slate-50 p-3 font-title text-xl/relaxed text-slate-800"},H=["src"],M={key:0},U={key:1,class:"grow bg-cover flex flex-col justify-around items-center",appear:""},O={__name:"StepView",setup(G){const t=V(),f=n(t.naturalFlow);let d=0;n(0);const x=n(!0),g=n(null),i=n(-1),p=n(t.currentRoute.steps),S=[];p.value.forEach((a,o)=>{S.push(F(`step-${o}`))}),n(null),N(()=>{f.value&&(d=setTimeout(()=>{m()},1e3)),t.flagTriggerCheck()});function T(a){f.value=a,d=setTimeout(()=>{m()},1e3)}function m(a){i.value++;const o=S[i.value];o?(o.value[0].scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),o.value[0].querySelector("audio").play(),d=setTimeout(()=>{i.value<=p.value.length-1&&m()},p.value[i.value].duration)):(x.value=!1,setTimeout(()=>{g.value&&g.value.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},250))}function I(a){a?.targetFlag&&t.triggerFlagById(a?.targetFlag),a?.targetScene&&t.selectNextRoute(a?.targetScene)}function B(a){let o=!0;for(var e=0;e<a.flagCondition.length;e++)if(t.getFlagById(a.flagCondition[e].flagId)?.value!=a.flagCondition[e].condition){o=!1;break}return o}return $(()=>{clearTimeout(d)}),(a,o)=>f.value?(s(),l("section",{key:0,class:C(["grow bg-cover flex flex-col justify-center items-center bg-fixed",r(t).displayedRoute?.mainStyle]),style:D({backgroundImage:`url(${r(t).displayedRoute?.bgImage})`})},[r(t).displayedRoute?.bgVideo?(s(),l("video",{key:0,class:"absolute pointer-events-none h-screen top-0",muted:"",src:r(t).displayedRoute?.bgVideo,autoplay:"",loop:""},null,8,E)):y("",!0),c("ul",L,[(s(!0),l(_,null,w(r(t).displayedRoute?.steps,(e,u)=>(s(),l("li",{key:u,class:C(["w-1/2 even:self-end opacity-0 transition-opacity duration-500",{"opacity-100":i.value>=u}]),ref_for:!0,ref:`step-${u}`},[c("div",null,[c("img",{src:e.image,alt:""},null,8,P),e.text?(s(),l("p",A,k(e.text),1)):y("",!0),c("audio",{src:e.audio},null,8,H)])],2))),128))]),v(q,{appear:""},{default:h(()=>[j(c("ul",{ref_key:"buttons",ref:g,class:"p-3 flex gap-2 justify-around items-center w-1/2 transition-all z-10"},[(s(!0),l(_,null,w(r(t).displayedRoute?.buttons,(e,u)=>(s(),l(_,{key:u},[e.flagCondition==null||B(e)?(s(),l("li",M,[v(b,{image:e?.image,audio:e?.audio,"label-hide":e?.labelHide,onClick:J=>I(e)},{default:h(()=>[R(k(e.label),1)]),_:2},1032,["image","audio","label-hide","onClick"])])):y("",!0)],64))),128))],512),[[z,!x.value]])]),_:1})],6)):(s(),l("section",U,[v(b,{onClick:o[0]||(o[0]=e=>T(!0))},{default:h(()=>[R("Lancer la scene -> "+k(r(t).currentRoute.id),1)]),_:1})]))}};export{O as default};
