{"version":3,"file":"ProjectScroll.D373hHHN.mjs","names":["React.useRef","React.useState","React.useCallback","__esmMin","init_npm_react_18_3_1","ne","init_ssg_sandbox_shims","window","_e","p","c","init_jsx_runtime","ce","de","init_framer_D6uXRwWs","addPropertyControls","ControlType","ProjectScroll","root","viewport","cards","drag","position","setPosition","isDragging","setDragging","color","props","muted","reduced","update","el","visible","card","offset","first","step","index","old","frame","measure","width","list","found","cardWidth","empty","schedule","resize","mutation","go","next","previous","stop","event","control","d","dx","init_ProjectScroll"],"sources":["https:/framerusercontent.com/modules/vx0JRB8koQIIaKN4D6vD/hlrDAORw5VckbP5B9bYd/ProjectScroll.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function ProjectScroll(props){const root=React.useRef(null);const viewport=React.useRef(null);const cards=React.useRef([]);const drag=React.useRef({active:false,start:0,left:0,moved:false,pointer:0});const[position,setPosition]=React.useState({index:0,count:0,end:true});const[isDragging,setDragging]=React.useState(false);const color=props.color||\"#F4F1EA\";const muted=props.muted||\"#867D71\";const reduced=()=>typeof window!==\"undefined\"&&window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;const update=React.useCallback(()=>{const el=viewport.current;if(!el)return;const visible=cards.current.filter(card=>card.getClientRects().length>0);const offset=el.scrollLeft;const first=visible[0];const step=first?first.getBoundingClientRect().width+24:1;const atEnd=offset>2&&offset>=el.scrollWidth-el.clientWidth-2;const index=atEnd?Math.max(0,visible.length-1):Math.min(Math.max(0,Math.round(offset/step)),Math.max(0,visible.length-1));setPosition(old=>old.index===index&&old.count===visible.length&&old.end===offset>=el.scrollWidth-el.clientWidth-2?old:{index,count:visible.length,end:offset>=el.scrollWidth-el.clientWidth-2});},[]);React.useEffect(()=>{const el=viewport.current;if(!el)return;let frame=0;const measure=()=>{const width=el.clientWidth;if(!width)return;const list=el.querySelector('[data-framer-name=\"Proyectos filtrados\"]');if(list){list.style.width=\"max-content\";list.style.minWidth=\"100%\";list.style.flexShrink=\"0\";}const found=Array.from(el.querySelectorAll('[data-framer-name=\"Proyecto del carrusel\"]'));cards.current=found;const cardWidth=width<600?width:Math.max(240,(width-48)/2.3);found.forEach(card=>{card.style.width=cardWidth+\"px\";card.style.minWidth=cardWidth+\"px\";card.style.maxWidth=cardWidth+\"px\";card.style.height=Math.max(220,cardWidth/(width<600?1.45:1.8))+\"px\";card.style.flexShrink=\"0\";card.style.scrollSnapAlign=\"start\";});const empty=el.querySelector('[data-framer-name=\"Sin proyectos en esta categor\\xeda\"]');if(empty){empty.style.width=width+\"px\";empty.style.minWidth=width+\"px\";}update();};const schedule=()=>{cancelAnimationFrame(frame);frame=requestAnimationFrame(measure);};const resize=new ResizeObserver(schedule);resize.observe(el);const mutation=new MutationObserver(schedule);mutation.observe(el,{childList:true,subtree:true});el.addEventListener(\"scroll\",update,{passive:true});schedule();return()=>{cancelAnimationFrame(frame);resize.disconnect();mutation.disconnect();el.removeEventListener(\"scroll\",update);};},[props.content,update]);const go=index=>{const el=viewport.current,card=cards.current[index];if(!el||!card)return;el.scrollTo({left:card.getBoundingClientRect().left-el.getBoundingClientRect().left+el.scrollLeft,behavior:reduced()?\"auto\":\"smooth\"});};const next=()=>{const el=viewport.current;if(!el)return;el.scrollBy({left:(cards.current[0]?.getBoundingClientRect().width||el.clientWidth)+24,behavior:reduced()?\"auto\":\"smooth\"});};const previous=()=>{const el=viewport.current;if(!el)return;el.scrollBy({left:-((cards.current[0]?.getBoundingClientRect().width||el.clientWidth)+24),behavior:reduced()?\"auto\":\"smooth\"});};const stop=event=>{if(!drag.current.active)return;drag.current.active=false;setDragging(false);if(viewport.current?.hasPointerCapture(event.pointerId))viewport.current.releasePointerCapture(event.pointerId);};const control={width:40,height:40,padding:8,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",border:\"1px solid \"+muted,borderRadius:40,background:\"transparent\",color,cursor:\"pointer\"};return /*#__PURE__*/_jsxs(\"div\",{ref:root,style:{...props.style,width:\"100%\",display:\"flex\",flexDirection:\"column\",gap:12,minWidth:0},children:[/*#__PURE__*/_jsx(\"div\",{ref:viewport,role:\"region\",\"aria-label\":\"Carrusel de proyectos\",tabIndex:0,style:{width:\"100%\",overflowX:\"auto\",overflowY:\"hidden\",scrollbarWidth:\"none\",scrollSnapType:isDragging?\"none\":\"x mandatory\",touchAction:\"pan-x pan-y\",cursor:isDragging?\"grabbing\":\"grab\",overscrollBehaviorX:\"contain\"},onKeyDown:e=>{if(e.target!==e.currentTarget)return;if(e.key===\"ArrowRight\"){e.preventDefault();next();}if(e.key===\"ArrowLeft\"){e.preventDefault();previous();}},onPointerDown:e=>{if(e.pointerType!==\"mouse\"||e.button!==0)return;drag.current={active:true,start:e.clientX,left:e.currentTarget.scrollLeft,moved:false,pointer:e.pointerId};},onPointerMove:e=>{const d=drag.current;if(!d.active)return;const dx=e.clientX-d.start;if(Math.abs(dx)>5){d.moved=true;setDragging(true);e.currentTarget.setPointerCapture(e.pointerId);}if(d.moved){e.preventDefault();e.currentTarget.scrollLeft=d.left-dx;}},onPointerUp:stop,onPointerCancel:stop,onDragStart:e=>e.preventDefault(),onClickCapture:e=>{if(drag.current.moved){e.preventDefault();e.stopPropagation();drag.current.moved=false;}},children:props.content}),position.count>0&&/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",justifyContent:\"space-between\",alignItems:\"center\",minHeight:40,gap:12},children:[/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",alignItems:\"center\",gap:6,flexWrap:\"wrap\"},\"aria-label\":\"Posici\\xf3n del carrusel\",children:Array.from({length:position.count},(_,index)=>/*#__PURE__*/_jsx(\"button\",{\"aria-label\":\"Ir al proyecto \"+(index+1),\"aria-current\":position.index===index?\"true\":undefined,onClick:()=>go(index),style:{border:0,background:\"transparent\",padding:\"10px 2px\",cursor:\"pointer\"},children:/*#__PURE__*/_jsx(\"span\",{style:{display:\"block\",height:2,width:18,background:index===position.index?color:muted,opacity:index===position.index?1:.5}})},index))}),/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",gap:12},children:[/*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":\"Proyecto anterior\",disabled:position.index===0,onClick:previous,style:{...control,opacity:position.index===0?.35:1},children:props.previousIcon}),/*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":\"Proyecto siguiente\",disabled:position.end,onClick:next,style:{...control,opacity:position.end?.35:1},children:props.nextIcon})]})]})]});}addPropertyControls(ProjectScroll,{content:{type:ControlType.ComponentInstance,title:\"Contenido\"},previousIcon:{type:ControlType.ComponentInstance,title:\"Anterior\"},nextIcon:{type:ControlType.ComponentInstance,title:\"Siguiente\"},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#F4F1EA\"},muted:{type:ControlType.Color,title:\"Atenuado\",defaultValue:\"#867D71\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ProjectScroll\",\"slots\":[\"content\",\"previousIcon\",\"nextIcon\"],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ProjectScroll.map"],"mappings":"A,oNAGG,SAAwBiB,EAAc,EAAM,CAAC,IAAMC,EAAKlB,EAAa,IAAI,EAAQmB,EAASnB,EAAa,IAAI,EAAQoB,EAAMpB,EAAa,CAAC,CAAC,EAAQqB,EAAKrB,EAAa,CAAC,OAAO,GAAM,MAAM,EAAE,KAAK,EAAE,MAAM,GAAM,QAAQ,CAAC,CAAC,EAAO,CAACsB,EAASC,GAAatB,EAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAI,CAAC,EAAO,CAACuB,EAAWC,GAAaxB,EAAe,EAAK,EAAQyB,EAAMC,EAAM,OAAO,UAAgBC,EAAMD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