{"version":3,"file":"BookLoop.D_oRdkVS.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/FFyHUnIWuGRZ3zCVcMQN/Ub9bO9oQAdZOrlXGQ4vE/BookLoop.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef}from\"react\";function createBookLoop(Component,allowFocus){return /*#__PURE__*/forwardRef(function BookLoop(props,forwardedRef){const ownRef=useRef(null);useEffect(()=>{const el=ownRef.current;if(!el||typeof window===\"undefined\")return;let focus=false;const books=allowFocus?Array.from(el.children).filter(node=>node instanceof HTMLElement):[];const originalBookStyles=books.map(book=>({transform:book.style.transform,opacity:book.style.opacity,transformOrigin:book.style.transformOrigin}));const renderFocus=()=>{if(!focus)return;const center=el.scrollLeft+el.clientWidth/2;books.forEach(book=>{const distance=Math.min(1,Math.abs(book.offsetLeft+book.offsetWidth/2-center)/(el.clientWidth*.43));const scale=1-distance*.24;book.style.transform=\"translateY(\"+(distance*12).toFixed(2)+\"px) scale(\"+scale.toFixed(4)+\")\";book.style.transformOrigin=\"50% 50%\";book.style.opacity=String(1-distance*.46);});};const reduced=window.matchMedia(\"(prefers-reduced-motion: reduce)\");let frame=0,last=0,resumeTimer=0,position=el.scrollLeft,period=0;let touching=false,userControl=false,paused=false,visible=false,eligible=false,initialized=false;let mousePointer=null;let startX=0,startScroll=0;const previousStyle={cursor:el.style.cursor,touchAction:el.style.touchAction,userSelect:el.style.userSelect,scrollBehavior:el.style.scrollBehavior};const held=()=>touching||mousePointer!==null;const stop=()=>{cancelAnimationFrame(frame);frame=0;last=0;};const clearResume=()=>{window.clearTimeout(resumeTimer);resumeTimer=0;};const canPlay=()=>eligible&&!held()&&!userControl&&!paused&&visible&&!document.hidden&&!reduced.matches;// Rebase only while idle. The middle of three identical sets provides room in both directions.\nconst rebase=()=>{if(!eligible||held())return;position=period+(el.scrollLeft%period+period)%period;el.scrollLeft=position;};const tick=time=>{frame=0;if(!canPlay())return;if(last)position+=Math.min(time-last,40)*.022;if(position>=period*2)position-=period;last=time;el.scrollLeft=position;frame=requestAnimationFrame(tick);};const start=()=>{if(!frame&&canPlay())frame=requestAnimationFrame(tick);};const pauseForUser=()=>{userControl=true;stop();clearResume();};const scheduleResume=()=>{clearResume();if(held()||!eligible)return;resumeTimer=window.setTimeout(()=>{resumeTimer=0;if(held())return;userControl=false;rebase();start();},400);};const measure=()=>{const style=getComputedStyle(el);focus=allowFocus&&el.clientWidth>=680&&Math.abs(el.clientHeight-336)<2;const padding=parseFloat(style.paddingLeft)+parseFloat(style.paddingRight);period=focus&&books.length===15?books[5].offsetLeft-books[0].offsetLeft:(el.scrollWidth-padding+(parseFloat(style.columnGap)||0))/3;eligible=style.overflowX===\"auto\"&&period>el.clientWidth;el.style.cursor=eligible?mousePointer===null?\"grab\":\"grabbing\":previousStyle.cursor;el.style.touchAction=eligible?\"pan-x pan-y pinch-zoom\":previousStyle.touchAction;el.style.userSelect=eligible?\"none\":previousStyle.userSelect;el.style.scrollBehavior=eligible?\"auto\":previousStyle.scrollBehavior;stop();if(eligible&&!initialized&&!userControl&&!held()){rebase();initialized=true;}renderFocus();if(!held()&&!userControl){position=el.scrollLeft;start();}};// Touch scrolling and its momentum belong exclusively to the browser.\nconst touchStart=()=>{if(eligible){touching=true;pauseForUser();}};const touchEnd=event=>{if(!touching||event.touches.length)return;touching=false;scheduleResume();};const down=event=>{if(!eligible||event.isPrimary===false||event.button!==0)return;if(event.pointerType!==\"mouse\"){pauseForUser();return;}if(mousePointer!==null)return;pauseForUser();mousePointer=event.pointerId;startX=event.clientX;startScroll=el.scrollLeft;el.style.cursor=\"grabbing\";el.setPointerCapture(event.pointerId);};const move=event=>{if(mousePointer===null||event.pointerId!==mousePointer)return;if(event.cancelable)event.preventDefault();el.scrollLeft=Math.max(0,Math.min(el.scrollWidth-el.clientWidth,startScroll+startX-event.clientX));};const finishMouse=()=>{if(mousePointer===null)return;const pointer=mousePointer;mousePointer=null;if(el.hasPointerCapture(pointer))el.releasePointerCapture(pointer);el.style.cursor=eligible?\"grab\":previousStyle.cursor;scheduleResume();};// A browser pointercancel during touch must never restart autoplay.\nconst up=event=>{if(event.pointerId===mousePointer)finishMouse();};const scroll=()=>{renderFocus();if(userControl&&!held())scheduleResume();};const wheel=()=>{if(eligible){pauseForUser();scheduleResume();}};const preventImageDrag=event=>{if(eligible)event.preventDefault();};const key=event=>{if(event.code===\"Space\"){event.preventDefault();paused=!paused;stop();start();}else if([\"ArrowLeft\",\"ArrowRight\",\"Home\",\"End\"].includes(event.key))wheel();};const blur=()=>{touching=false;finishMouse();if(userControl)scheduleResume();};const visibility=()=>{stop();start();};const resize=typeof ResizeObserver!==\"undefined\"?new ResizeObserver(measure):null;if(resize)resize.observe(el);else window.addEventListener(\"resize\",measure);const setVisible=next=>{visible=next;if(visible)start();else stop();};const checkVisible=()=>{const rect=el.getBoundingClientRect();setVisible(rect.bottom>0&&rect.top<window.innerHeight&&rect.right>0&&rect.left<window.innerWidth);};const observer=typeof IntersectionObserver!==\"undefined\"?new IntersectionObserver(entries=>setVisible(entries[0]?.isIntersecting??false)):null;if(observer)observer.observe(el);else{checkVisible();window.addEventListener(\"scroll\",checkVisible,{passive:true});window.addEventListener(\"resize\",checkVisible);}el.addEventListener(\"pointerdown\",down,{passive:true});el.addEventListener(\"touchstart\",touchStart,{passive:true});el.addEventListener(\"scroll\",scroll,{passive:true});el.addEventListener(\"wheel\",wheel,{passive:true});el.addEventListener(\"dragstart\",preventImageDrag);el.addEventListener(\"lostpointercapture\",up);el.addEventListener(\"keydown\",key);window.addEventListener(\"pointermove\",move,{passive:false});window.addEventListener(\"pointerup\",up);window.addEventListener(\"pointercancel\",up);window.addEventListener(\"touchend\",touchEnd,{passive:true});window.addEventListener(\"touchcancel\",touchEnd,{passive:true});window.addEventListener(\"blur\",blur);document.addEventListener(\"visibilitychange\",visibility);if(reduced.addEventListener)reduced.addEventListener(\"change\",visibility);else reduced.addListener(visibility);measure();return()=>{stop();clearResume();resize?.disconnect();observer?.disconnect();window.removeEventListener(\"resize\",measure);window.removeEventListener(\"scroll\",checkVisible);window.removeEventListener(\"resize\",checkVisible);el.removeEventListener(\"pointerdown\",down);el.removeEventListener(\"touchstart\",touchStart);el.removeEventListener(\"scroll\",scroll);el.removeEventListener(\"wheel\",wheel);el.removeEventListener(\"keydown\",key);el.removeEventListener(\"dragstart\",preventImageDrag);el.removeEventListener(\"lostpointercapture\",up);window.removeEventListener(\"pointermove\",move);window.removeEventListener(\"pointerup\",up);window.removeEventListener(\"pointercancel\",up);window.removeEventListener(\"touchend\",touchEnd);window.removeEventListener(\"touchcancel\",touchEnd);window.removeEventListener(\"blur\",blur);document.removeEventListener(\"visibilitychange\",visibility);if(reduced.removeEventListener)reduced.removeEventListener(\"change\",visibility);else reduced.removeListener(visibility);if(mousePointer!==null&&el.hasPointerCapture(mousePointer))el.releasePointerCapture(mousePointer);Object.assign(el.style,previousStyle);books.forEach((book,index)=>Object.assign(book.style,originalBookStyles[index]));};},[]);return /*#__PURE__*/_jsx(Component,{...props,ref:node=>{ownRef.current=node;if(typeof forwardedRef===\"function\")forwardedRef(node);else if(forwardedRef)forwardedRef.current=node;},tabIndex:0,role:\"region\",\"aria-roledescription\":\"캐러셀\",\"aria-label\":\"저서 목록. 좌우로 넘겨보세요. 스페이스 키로 자동 재생 정지 또는 재개\"});});}export function withBookLoop(Component){return createBookLoop(Component,false);}export function withBookFocus(Component){return createBookLoop(Component,true);}\nexport const __FramerMetadata__ = {\"exports\":{\"withBookLoop\":{\"type\":\"reactHoc\",\"name\":\"withBookLoop\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withBookFocus\":{\"type\":\"reactHoc\",\"name\":\"withBookFocus\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BookLoop.map"],"mappings":"8IAA0F,SAAS,EAAe,EAAU,EAAW,CAAC,OAAoB,EAAW,SAAkB,EAAM,EAAa,CAAC,IAAM,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