{
  "version": 3,
  "sources": ["ssg: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:\"\u2728\"}),/*#__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\":\"*\",\"framerSupportedLayoutHeight\":\"auto\",\"fram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kBAAkB,KAAKsC,EAAY,iBAAiB,EAAE,YAAY,CAAC,MAAM,eAAe,KAAKA,EAAY,MAAM,EAAE,KAAK,CAAC,MAAM,gBAAgB,KAAKA,EAAY,KAAK,aAAa,OAAO,wBAAwB,GAAK,0BAA0B,WAAW,QAAQ,CAAC,OAAO,UAAU,EAAE,aAAa,CAAC,OAAO,UAAU,CAAC,EAAE,OAAO,CAAC,KAAKA,EAAY,QAAQ,MAAM,SAAS,aAAa,MAAM,cAAc,KAAK,YAAY;AAAA,4CAAoD,CAAC,CAAC,EAAEtC,EAAU,YAAY",
  "names": ["Prev_Next", "props", "_props_collectionList", "_props_collectionList1", "_props_collectionList2", "type", "currentSlug", "repeat", "style", "p", "SetupMessage", "collectionList", "isCanvas", "RenderTarget", "newCollectionList", "setNewCollectionList", "ye", "query", "findQueryInProps", "queryWithoutLimitAndOffset", "queryData", "useQueryData", "ue", "currentIndex", "findIndex", "newOffset", "getNewOffset", "updateQueryInProps", "data", "item", "items", "lastIndex", "isLastIndex", "isFirstIndex", "title", "description", "containerStyle", "addPropertyControls", "ControlType"]
}
