veza/apps/web/dist_verification/assets/EducationView-CybxtgC5.js

2 lines
12 KiB
JavaScript
Raw Normal View History

import{a as l,j as e,R as F}from"./vendor-react-Dkpvlwai.js";import{S as g,C as M,B as Y,l as Q}from"./index-jE2AGx2y.js";import{a as D}from"./progress-5klaDPNN.js";import{bb as z,bc as B,b as U,bd as L,C as X,x as Z,G as H,aX as T}from"./vendor-icons-CbmLcMl-.js";import{S as K}from"./input-CpxrTzwP.js";import{y as E}from"./vendor-CAoAb3tF.js";import"./vendor-router-4bycex72.js";import"./vendor-tanstack-BoI3DtL9.js";import"./vendor-utils-CDFfoeXY.js";function _(s,{threshold:n=0,root:a=null,rootMargin:t="0%",freezeOnceVisible:i=!1}){const[c,r]=l.useState(),o=c?.isIntersecting&&i;return l.useEffect(()=>{const p=s?.current;if(!!!window.IntersectionObserver||o||!p)return;const u={threshold:n,root:a,rootMargin:t},A=new IntersectionObserver(([m])=>{r(m)},u);return A.observe(p),()=>A.disconnect()},[s,n,a,t,o]),c}function q({blurDataURL:s,width:n,height:a,className:t=""}){return s?e.jsx("img",{src:s,alt:"",className:`blur-sm ${t}`,style:{width:n,height:a},"aria-hidden":"true"}):e.jsx(g,{className:t,style:{width:n,height:a}})}const P=["webp","avif","jpeg","png","gif"],J="jpeg";function ee(s,n){const a=s.replace(/\.[^/.]+$/,""),t=n??"100vw";return P.map(i=>({src:`${a}.${i}`,type:`image/${i}`,sizes:t}))}function se(){const[s,n]=l.useState([]);return l.useEffect(()=>{(async()=>{const t=[],i=await new Promise(r=>{const o=new Image;o.onload=o.onerror=()=>r(o.height===2),o.src="data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA"}),c=await new Promise(r=>{const o=new Image;o.onload=o.onerror=()=>r(o.height===2),o.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEAwgMgkAAAAAAAAG8AAAAA=="});i&&t.push("webp"),c&&t.push("avif"),t.push("jpeg","png","gif"),n(t)})()},[]),s}function te({src:s,alt:n,width:a,height:t,className:i="",placeholder:c,blurDataURL:r,priority:o=!1,quality:p=75,sizes:f="100vw",onLoad:u,onError:A,fallback:m}){const[d,j]=l.useState(!1),[b,v]=l.useState(!1),[G,R]=l.useState(null),V=l.useRef(null),N=se(),C=l.useRef(null),S=!!_(C,{threshold:.1,rootMargin:"50px"})?.isIntersecting,w=F.useMemo(()=>ee(s,f),[s,f]),I=l.useCallback(()=>{const x=N.find(y=>P.includes(y))||J;return w.find(y=>y.type===`image/${x}`)?.src||s},[N,w,s]),k=l.useCallback(()=>{if(d||b)return;const x=I();R(x);const h=new Image;h.onload=()=>{j(!0),u?.()},h.onerror=()=>{v(!0),A?.()},h.src=x},[d,b,I,u,A]);l.useEffect(()=>{(o||S)&&k()},[o,S,k]);const O=l.useCallback(()=>{v(!0),A?.()},[A]),W=l.useCallback(()=>{j(!0),u?.()},[u]);return b?m||e.jsx("div",{className:`bg-muted flex items-center justify-center ${i}`,style:{width:a,height:t},children:e.jsx("span",{className:"text-muted-foreground text-sm",children:"Image non disponible"})}):!d&&!o?e.jsxs("div",{ref:C,className:`relative ${i}`,style:{width:a,height:t},children:[e.jsx(q,{blurDataURL:r,width:a,height:t,className:"absolute inset-0"}),c&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:c})]}):e.jsxs("picture",{className:i,children:[w.map((x,h)=>e.jsx("source",{srcSet:x.src,type:x.type,sizes:x.sizes},`${x.type}-${h}`)),e.jsx("img",{ref:V,src:G||s,alt:n,width:a,height:t,className:`transition-opacity duration-[var(--sumi-duration-normal)] ${d?"opacity-100":"opacity-0"} ${i}`,onLoad:W,onError:O,loading:o?"eager":"lazy",decoding:"async",style:{width:a,height:t}})]})}function re(s){return!s.modules||s.modules.length===0?0:s.modules.reduce((n,a)=>n+(a.lessons?.length??0),0)}const ae=({course:s,onClick:n,showProgress:a=!1})=>{const t=re(s);return e.jsxs(M,{variant:"default",className:"group p-0 overflow-hidden cursor-pointer hover:border-border/80 hover:shadow-xl transition-all duration-[var(--sumi-duration-normal)] flex flex-col h-full",onClick:()=>n(s),children:[