{"version":3,"file":"NextPrev.MBTRMWuR.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/V9TTiBEDmAnnV9rhMhiJ/aXtqDEJxnBteEUSSHund/NextPrev.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget,// @ts-ignore\nuseQueryData}from\"framer\";import{useState,useEffect}from\"react\";import{findQueryInProps,updateQueryInProps}from\"https://framer.com/m/Utlis-SwIN.js@U9vmYX0zDZtz999aDBu4\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerIntrinsicWidth 600\n * @framerSupportedLayoutHeight auto\n */export default function Prev_Next(props){var _props_collectionList,_props_collectionList1,_props_collectionList2;const{type,currentSlug,repeat,style}=props;if(!((_props_collectionList=props.collectionList)===null||_props_collectionList===void 0?void 0:_props_collectionList[0])){return /*#__PURE__*/_jsx(SetupMessage,{title:\"Set Up the Component\",description:\"Add layer or component to the component property.\",containerStyle:style});}const collectionList={...(_props_collectionList1=props.collectionList)===null||_props_collectionList1===void 0?void 0:_props_collectionList1[0],props:{...(_props_collectionList2=props.collectionList)===null||_props_collectionList2===void 0?void 0:_props_collectionList2[0].props,style}};const isCanvas=RenderTarget.current()===RenderTarget.canvas;const[newCollectionList,setNewCollectionList]=useState();const query=!isCanvas?findQueryInProps(collectionList===null||collectionList===void 0?void 0:collectionList.props):undefined;const queryWithoutLimitAndOffset={...query,limit:null,offset:null};const queryData=query?useQueryData(queryWithoutLimitAndOffset):[];useEffect(()=>{const init=async()=>{const currentIndex=findIndex(queryData,currentSlug);const newOffset=getNewOffset(queryData,type,currentIndex,repeat);setNewCollectionList({...collectionList,props:updateQueryInProps(collectionList.props,{...query,limit:{type:\"LiteralValue\",value:1},offset:{type:\"LiteralValue\",value:newOffset}})});};!isCanvas&&init();},[]);return /*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\"},children:isCanvas?collectionList:newCollectionList});}const findIndex=(data,currentSlug)=>{return data.findIndex(item=>Object.values(item).includes(currentSlug));};const getNewOffset=(items,type,currentIndex,repeat)=>{const lastIndex=items.length-1;const isLastIndex=currentIndex===lastIndex;const isFirstIndex=currentIndex===0;if(type===\"next\"){if(repeat){return isLastIndex?0:currentIndex+1;}return isLastIndex?items.length:currentIndex+1;}if(type===\"previous\"){if(repeat){return isFirstIndex?lastIndex:currentIndex-1;}return isFirstIndex?items.length:currentIndex-1;}return currentIndex;};const SetupMessage=({title,description,containerStyle})=>{return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",alignItems:\"center\",textAlign:\"center\",justifyContent:\"center\",backgroundColor:\"rgba(136, 85, 255, 0.1)\",padding:\"40px 80px 40px 80px\",...containerStyle},children:[/*#__PURE__*/_jsx(\"span\",{role:\"img\",\"aria-label\":\"icon\",style:{fontSize:\"32px\"},children:\"✨\"}),/*#__PURE__*/_jsxs(\"div\",{style:{maxWidth:\"240px\"},children:[/*#__PURE__*/_jsx(\"h1\",{style:{fontSize:11,color:\"#96F\",fontWeight:600},children:title}),/*#__PURE__*/_jsx(\"p\",{style:{fontSize:11,color:\"rgba(153, 102, 255, 0.7)\",lineHeight:1.5},children:description})]})]});};addPropertyControls(Prev_Next,{collectionList:{title:\"Collection list\",type:ControlType.ComponentInstance},currentSlug:{title:\"Current slug\",type:ControlType.String},type:{title:\"Next/Previous\",type:ControlType.Enum,defaultValue:\"next\",displaySegmentedControl:true,segmentedControlDirection:\"vertical\",options:[\"next\",\"previous\"],optionTitles:[\"Next\",\"Previous\"]},repeat:{type:ControlType.Boolean,title:\"Repeat\",enabledTitle:\"Yes\",disabledTitle:\"No\",description:\"v2.0 \\n [via SegmentUI](https://www.segmentUI.com)\"}});Prev_Next.displayName=\"New Prev and Next item\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Prev_Next\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"*\",\"framerSupportedLay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