1import{j as e,u as Y}from"./vendor-react-Caf6nGZS.js";import{u as Z,F as ee}from"./vendor-forms-CJIvkx3-.js";import{U as P,H as h,m as C,f as R,c as te,q as re,e as ae,S as A,s as N}from"./message-utils-BjsgoZPu.js";import{N as H}from"./not-found-error-Bw3dmpMP.js";import{u as j,G as se,D as oe}from"./grid-page-D_E8WOFv.js";import{F as ie}from"./index-CqrSV8St.js";import{F as ne,C as le}from"./vendor-icons-CPDSsqVu.js";import{u as ce}from"./useInfiniteQuery-DzkMB6_Q.js";import{f as w,L as de}from"./load-more-DZt9WPl2.js";import{u as O}from"./vendor-i18n-DjMpJ670.js";import{b,F as pe,V as g,T as v,B as m,e as ue,t as me,H as ge,a as he,i as fe,D as xe}from"./vendor-chakra-vTj1AOQN.js";import{S as be}from"./skip-links-r5tlWYEE.js";import"./vendor-live-BnuEDD1a.js";import"./number-to-brazillian-currency-BfE81M-A.js";import"./url-builder-DjlYk8Vg.js";import"./remove-string-html-BgM2n6Mw.js";import"./vendor-video-C24YjE40.js";import"./translator-SQ4T_ypS.js";import"./evaluation-stars-BK7W0g_S.js";import"./difficulty-icon-BixREb4S.js";import"./index-LkN4aDLv.js";import"./preload-helper-I4rgV-VL.js";import"./index-CYeJW1Tb.js";class ye{constructor(t,i){this.url=t,this.httpClient=i}url;httpClient;async loadById({id:t}){const i=await this.httpClient.request({url:`${this.url}/api/v1/trail/${t}`,method:"GET"}),a=i.body?.data||{};switch(i.status){case h.OK:return a;case h.NO_CONTENT:return a;case h.NOT_FOUND:throw new H;default:throw new P}}}class Te{constructor(t){this.httpClient=t}httpClient;async enroll(t){await this.httpClient.request({url:`/api/v1/trail/${t}/enroll`,method:"POST",headers:{"Content-Type":"application/json"}})}}function Ie(){return new Te(C())}class je{constructor(t,i){this.url=t,this.httpClient=i}url;httpClient;async loadById({id:t,page:i,filterBy:a,value:n}){let c={page:i};a&&n&&(c={...c,filterBy:a,value:n});const p=await this.httpClient.request({url:`${this.url}/api/v1/trail/${t}/items`,method:"GET",params:c}),f=p.body?.success?{data:p.body?.data,meta:p.body?.meta}:{data:[]};switch(p.status){case h.OK:return f;case h.NO_CONTENT:return f;case h.NOT_FOUND:throw new H;default:throw new P}}}const we=()=>new je(R(),C());function ve(r){return Ie().enroll(r)}function Ce(){return te({mutationFn:ve,onSuccess:()=>{re.refetchQueries({queryKey:["trail"]})}})}function Le({id:r,page:t,filterBy:i,value:a}){return we().loadById({id:r,page:t,filterBy:i,value:a})}function Fe({id:r,filterBy:t,value:i}){return ce({queryKey:["trail-items",r,t,i],queryFn:({pageParam:a=1})=>Le({id:r,page:a,filterBy:t,value:i}),initialPageParam:1,refetchOnWindowFocus:!1,refetchOnMount:!1,getNextPageParam:a=>{const n=a.meta.current_page+1;return n>a.meta.last_page?void 0:n}})}function Se(){const r=({format:i,type:a})=>{if(!a)return 2;if(i==="course")return a;switch(a){case 1:return 9;case 3:return 5;case 15:return 8;default:return 2}};return{getRemapedType:r,getRemapedTypeString:({format:i,type:a})=>{if(!a)return"all";switch(r({format:i,type:a})){case 1:return"component";case 2:return"course";case 9:return"text";case 5:return"video";case 8:return"pdf";default:return"all"}}}}const _e=()=>new ye(R(),C());function Ee({id:r}){return _e().loadById({id:r})}function ke({id:r}){return ae({queryKey:["trail",r],queryFn:()=>Ee({id:r}),refetchOnWindowFocus:!1})}function Ne({id:r,description:t,hasFavoriteButton:i}){const{t:a}=O(),n=j("pages.trailInfo.descriptionLabel",t||"",{stripHtml:!0}),c=b("rgba(0, 0, 0, 0.8)","rgba(255, 255, 255, 0.8)");return e.jsx(e.Fragment,{children:e.jsxs(pe,{px:["1rem","1rem","3rem","3rem"],align:"center",justify:"space-between",children:[e.jsx(g,{align:"left",mt:"3rem",children:t&&e.jsxs(g,{align:"left",spacing:2,children:[e.jsx(A,{size:"md",children:a("pages.trailInfo.descriptionLabel")}),e.jsx(v,{color:c,tabIndex:0,"aria-label":n,_focus:w,dangerouslySetInnerHTML:{__html:t}})]})}),e.jsx(m,{children:i&&r&&e.jsx(ie,{size:"lg",id:r,type:3})})]})})}function rt(){const{id:r}=Y(),{t}=O(),i=ue(),a=b("#F9F9F9","black"),n=b("gray.800","white"),c=b("gray.200","gray.700"),p=b("gray.600","gray.400"),f=Z({defaultValues:{filterBy:{type:"all",value:"all"},inputs:{format:"all",tag:"all",difficulty:"all"}}}),{watch:L}=f,{data:s,isError:F,isLoading:S}
1=ke({id:Number(r)}),B=j("pages.trailInfo.trailTitle",s?.title||""),$=j("pages.trailInfo.contentsCount",`${s?.totalContentsTrail||0} ${t("pages.trailInfo.contentsLabel")}`),{data:y,hasNextPage:_,isLoading:T,fetchNextPage:q,isFetchingNextPage:M}=Fe({id:Number(r),filterBy:L("filterBy.type"),value:L("filterBy.value")}),{getRemapedType:z}=Se(),D=Ce(),U=()=>{D.mutate(r,{onSuccess:()=>{i({title:t("pages.trailId.successTitle"),description:t("pages.trailId.successDescription"),status:"success",duration:3e3,isClosable:!0})},onError:()=>{i({title:t("pages.trailId.errorTitle"),description:t("pages.trailId.errorDescription"),status:"error",duration:3e3,isClosable:!0})}})},I=()=>{const d=y?.pages.reduce((o,u)=>{const x=u.data.map(l=>l.id);return o.push(...x),o},[]);return d?d.length<=0:!0},E=y?.pages.reduce((d,o)=>(o.data.forEach(u=>{d.push({href:`#content-card-${u.id}`,label:`${t("pages.trailId.skipToContent")} ${u.title}`})}),d),[])||[];return _&&!I()&&E.push({href:"#load-more",label:t("pages.trailId.skipToLoadMore")}),e.jsxs(ee,{...f,children:[e.jsx(be,{links:E}),e.jsxs(g,{align:"left",spacing:"0",marginTop:"64px",bg:a,children:[e.jsxs(m,{position:"relative",w:"100%",marginBottom:0,minH:s?.image?"auto":"55vh",children:[s?.image&&e.jsx(me,{src:s.image,w:"100%",maxH:"55vh",objectFit:"cover",loading:"lazy",alt:t("pages.trailId.trailCoverImage",{title:s?.title})}),e.jsx(m,{position:"absolute",top:"0",left:"0",bg:s?.image?"linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.6) 100%)":"linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.7) 100%)",w:"100%",h:"100%"}),e.jsxs(ge,{position:"absolute",align:"center",bottom:20,w:"100%",paddingX:[6,20],justifyContent:"space-between",children:[e.jsxs(g,{align:"left",spacing:2,children:[e.jsx(he,{as:"h1",color:"white",fontSize:["2xl","4xl"],textShadow:"2px 2px 4px rgba(0,0,0,0.8)",tabIndex:0,"aria-label":B,_focus:w,children:s?.title}),s?.totalContentsTrail&&e.jsx(v,{color:"white",fontSize:"lg",fontWeight:"500",textShadow:"1px 1px 2px rgba(0,0,0,0.8)",tabIndex:0,"aria-label":$,_focus:w,children:t("pages.trailId.contentsCount",{count:s.totalContentsTrail})})]}),!s?.isEnrolled&&e.jsx(fe,{size:"lg",bg:"brand-scheme.500",color:"white",borderRadius:"full",width:["58px","58px","64px","64px"],height:["58px","58px","64px","64px"],onClick:U,_hover:{bg:"brand-scheme.600",transform:"scale(1.05)"},_active:{bg:"brand-scheme.400"},_focus:{boxShadow:"0 0 0 5px rgba(66, 153, 225, 0.8)",outline:"none"},transition:"all 0.2s",p:0,display:"flex",alignItems:"center",justifyContent:"center","aria-label":t("pages.trailId.startTrail"),tabIndex:0,children:e.jsx(ne,{icon:le,style:{marginLeft:"0.25rem",fontSize:"1.525rem",color:"white"}})})]})]}),e.jsx(N,{level:2,children:e.jsxs(g,{align:"left",spacing:"3rem",paddingTop:"4rem",paddingX:[4,8],w:"100%",children:[e.jsx(Ne,{id:s?.id,description:s?.description,hasFavoriteButton:!!(s&&s?.id)}),s?.isEnrolled&&s?.progress!==null&&s?.progress!==void 0&&e.jsx(N,{level:3,children:e.jsxs(g,{align:"left",spacing:4,w:"100%",px:["1rem","1rem","3rem","3rem"],children:[e.jsx(A,{fontSize:"xl",fontWeight:"600",color:n,children:t("pages.trailId.progress")}),e.jsx(m,{w:"100%",bg:c,borderRadius:"md",overflow:"hidden",children:e.jsx(m,{bg:"brand-scheme.500",h:"8px",borderRadius:"md",transition:"width 0.3s ease",width:`${s.progress}%`})}),e.jsxs(v,{fontSize:"sm",color:p,children:[s.progress,"% ",t("pages.trailId.completed")]})]})}),e.jsx(xe,{}),e.jsx("main",{id:"trail-content",role:"main",tabIndex:-1,children:e.jsxs(se,{isLoading:S||T,isError:F,isEmpty:!T&&I(),children:[e.jsx("ol",{role:"list",style:{listStyle:"none",padding:0,margin:0,display:"contents"},children:y?.pages.map(d=>d.data.map((o,u)=>{const x=o.order||u+1;let l=null;if(x>1)for(const X of y?.pages||[]){const k=X.data.find(J=>J.order===x-1);if(k){l=k;break}}const K=l?.progress||0,G=l?.completedAt||null,V=l?.approval||null,W=l?.media||null,Q=l?.hasAssessments??!1;return e.jsx("li",{role:"listitem",id:`content-card-${o.id}`,children:e.jsx("article",{children:e.jsx(oe,{title:o.title,description:o.description,image:o.image,id:o.id,difficulty:o.difficulty,stars:o.evaluation?.overall,hasCertificate:!!o.hasCertificate,tags:o.markers,hours:o.duration,type:z({format:o.format,type:o.type}),progress:o.progress,trailId:s?.id,author:o.author&&{name:o.author.name,avatar:o.author.avatar},disableFavorite:!0,types_access_criteria:s?.types_access_criteria,days_release_course:s?.days_release_course,itemOrder:x,previousItemProgress:K,previousCompletedAt:G,previousItemApproval:V||void 0,previousItemMedia:W||void 0,previousItemHasAssessments:Q})})},`content-${o.id}`)}))}),!S&&!T&&!F&&!I()&&e.jsx(m,{gridColumn:"1 / -1",width:"100%",id:"load-more",children:e.jsx(de,{hasNextPage:_,isLoading:T,fetchNextPage:q,isFetchingNextPage:M})})]})})]})})]})]})}export{rt as ListTrailIdPage};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.