{"version":3,"file":"_utils.DQuP2rDF.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/eSlbzLBXJ10sKJ49G3B9/ikylEbBVmlAiX2rGrRhS/_utils.js"],"sourcesContent":["import{useEffect,useState}from\"react\";/**\n * Formats the given path string by performing the following steps:\n * 1. Removes the '.md' extension if it exists.\n * 2. Converts camel case to kebab case (replacing uppercase letters with their lowercase equivalent, prefixed by a hyphen).\n * 3. Removes a leading hyphen, if present.\n */export function formatPathString(pathString){return pathString.replace(/\\.md$/,\"\").replace(/[A-Z]/g,match=>`-${match.toLowerCase()}`).replace(/^-/,\"\");}/**\n * Returns the current page URL if it is found in the navigation items.\n * The function iterates through the navigation items and checks if the formatted path includes the current URL.\n */export function getCurrentPageUrl(navigation,currentUrl){navigation.items.map(link=>{const formattedPath=formatPathString(link.path);if(formattedPath.includes(currentUrl)){return currentUrl;}});}/**\n * Updates the page's title with the new title and restores the original title when the component is unmounted.\n * The function re-runs the effect and cleanup when the currentPageTitle changes.\n */export function updatePageMetadata(originalTitle,newTitle,currentPageTitle){useEffect(()=>{document.title=newTitle;return()=>{// Restore the original title when the component is unmounted\ndocument.title=originalTitle;};},[currentPageTitle]);}/**\n * Generates a Markdown file name based on the last segment of the given URL.\n * The function processes the last segment by converting it to camel case and appending the '.md' extension.\n */export function getMdFileName(currentUrl){const segments=currentUrl.split(\"/\");const lastSegment=segments[segments.length-1];const capitalizedLastSegment=lastSegment.charAt(0).toUpperCase()+lastSegment.slice(1);const camelCaseLastSegment=capitalizedLastSegment.split(\"-\").map(word=>word.charAt(0).toUpperCase()+word.slice(1)).join(\"\");const mdFileName=camelCaseLastSegment+\".md\";return mdFileName;}/**\n * Removes all HTML comments from the provided content.\n */export function removeHtmlComments(content){return content.replace(/<!--[\\s\\S]*?-->/g,\"\");}export const formatPageName=pageName=>{return pageName.split(\"-\").map(word=>word.split(/(?=[A-Z])/).join(\" \").charAt(0).toUpperCase()+word.slice(1)).join(\" \");};/**\n * Returns the appropriate repository name based on the platform found in the given URL.\n */export function getRepoName(url){if(!url)return\"storyteller-sdk-kotlin\"// for testing\n;const match=url.match(/documentation\\/(.*?)\\//);if(!match||!match[1])return\"storyteller-sdk-kotlin\"// Return default value if no match found\n;const platform=match[1];switch(platform){case\"ios\":return\"storyteller-sdk-swift\";case\"android\":return\"storyteller-sdk-kotlin\";case\"web\":return\"storyteller-sdk-javascript\";case\"react-native\":return\"storyteller-sdk-react-native-internal\";case\"storyteller-cms\":return\"storyteller-cms\";default:return\"storyteller-sdk-kotlin\";}}/**\n * Returns the appropriate repository name based on the platform.\n */export const getRepoByPlatform=platform=>{switch(platform){case\"ios\":return\"storyteller-sdk-swift\";case\"android\":return\"storyteller-sdk-kotlin\";case\"web\":return\"storyteller-sdk-javascript\";case\"react-native\":return\"storyteller-sdk-react-native-internal\";default:return\"storyteller-sdk-kotlin\";}};/**\n * Returns the appropriate repository owner based on the repository name provided.\n */export function getRepoOwner(repo){switch(repo){case\"storyteller-sdk-swift\":return\"stormideas\";case\"storyteller-sdk-kotlin\":return\"stormideas\";case\"storyteller-sdk-javascript\":return\"stormideas\";case\"storyteller-sdk-react-native-internal\":return\"stormideas\";default:return\"stormideas\";}}export function parseRepoName(repoName){return repoName.replace(\"storyteller-sdk-\",\"\").replace(\"kotlin\",\"android\").replace(\"swift\",\"ios\").replace(\"javascript\",\"web\").replace(\"react-native-internal\",\"react-native\").toLowerCase();}/**\n * Returns formatted documentation url based on the platform and path provided.\n */export const createLinkHref=(section,platform,path)=>{const formattedPath=formatPathString(path);return`/${section}/${platform}/${formattedPath}`;};export const uniqueId=`custom-style-${Date.now()}-${Math.floor(Math.random()*1e5)}`;/**\n * Updates the navigation state based on the parsed content and the current URL.\n * This function sets the previous page URL, previous page title, next page URL,\n * next page title, and current page title.\n *\n */export function updateNavigation(parsedContent,currentUrl,formatPathString,setPreviousPageUrl,setPreviousPageTitle,setNextPageUrl,setNextPageTitle,setCurrentPageTitle){// Find the current, previous, and next pages\nconst currentPageIndex=parsedContent.items.findIndex(link=>currentUrl.includes(formatPathString(link.path)));if(currentPageIndex>=0){if(currentPageIndex>0){setPreviousPageUrl(formatPathString(parsedContent.items[currentPageIndex-1].path));setPreviousPageTitle(parsedContent.items[currentPageIndex-1].text);}if(currentPageIndex<parsedContent.items.length-1){setNextPageUrl(formatPathString(parsedContent.items[currentPageIndex+1].path));setNextPageTitle(parsedContent.items[currentPageIndex+1].text);setCurrentPageTitle(parsedContent.items[currentPageIndex].text);}}}/**\n * Updates the navigation state based on the parsed content and the current URL.\n * This function sets the previous page URL, previous page title, next page URL,\n * next page title, and current page title.\n *\n */export const updateUserGuideNavigation=(parsedContent,currentUrl,formatPathString,setPreviousPageUrl,setPreviousPageTitle,setNextPageUrl,setNextPageTitle,setCurrentPageTitle)=>{const items=Array.isArray(parsedContent)?{items:parsedContent}:parsedContent;const currentSectionIndex=items.items.findIndex(section=>section.items&&section.items.some(link=>currentUrl.includes(formatPathString(link.path))));if(currentSectionIndex>=0){const currentSection=items.items[currentSectionIndex].items;const currentPageIndex=currentSection.findIndex(link=>currentUrl.includes(formatPathString(link.path)));if(currentPageIndex>=0){if(currentPageIndex>0){setPreviousPageUrl(formatPathString(currentSection[currentPageIndex-1].path));setPreviousPageTitle(currentSection[currentPageIndex-1].text);}if(currentPageIndex<currentSection.length-1){setNextPageUrl(formatPathString(currentSection[currentPageIndex+1].path));setNextPageTitle(currentSection[currentPageIndex+1].text);setCurrentPageTitle(currentSection[currentPageIndex].text);}}}};function getWindowDimensions(){//NOTE: Defaults required for initial SSR so use of window doesn't cause error.\nconst defaultWidth=1e3;const defaultHeight=2e3;if(typeof window!==\"undefined\"){const{innerWidth:width,innerHeight:height}=window;return{width,height};}else{return{width:defaultWidth,height:defaultHeight};}}export function useWindowDimensions(){const[windowDimensions,setWindowDimensions]=useState(getWindowDimensions());useEffect(()=>{function handleResize(){setWindowDimensions(getWindowDimensions());}window.addEventListener(\"resize\",handleResize);return()=>window.removeEventListener(\"resize\",handleResize);},[]);return windowDimensions;}// Force smooth scroll between sections as scrollIntoView smooth behavior is not respected from component level\nexport function useSmoothScroll(){useEffect(()=>{const htmlElement=document.querySelector(\"html\");if(htmlElement){htmlElement.style.scrollBehavior=\"smooth\";}return()=>{if(htmlElement){htmlElement.style.scrollBehavior=\"\";}};},[]);}// Returns formatted title from url\nexport function getTitleFromUrl(url){const pathParts=url.split(\"/\");const lastPart=pathParts[pathParts.length-1];const title=lastPart.split(\"-\").map(word=>word.charAt(0).toUpperCase()+word.slice(1)).join(\" \");return title;}const initialState={windowLocation:\"\"};export const windowLocation=(state=initialState,action)=>{if(action.type===\"SET\"){var _window_location_href,_window_location,_window,_window_location1,_window1;return Object.assign({},state,{...state,windowLocation:typeof window!==\"undefined\"&&((_window=window)===null||_window===void 0?void 0:(_window_location=_window.location)===null||_window_location===void 0?void 0:(_window_location_href=_window_location.href)===null||_window_location_href===void 0?void 0:_window_location_href.includes(\"?\"))?(_window1=window)===null||_window1===void 0?void 0:(_window_location1=_window1.location)===null||_window_location1===void 0?void 0:_window_location1.href:state.windowLocation});}return state;};// This function returns UTM params based on window location - used in the SignUp form\nexport const useWindowLocation=()=>{var _window_location,_window;const[utmMedium,setUtmMedium]=useState(\"\");const[utmSource,setUtmSource]=useState(\"\");const[utmCampaign,setUtmCampaign]=useState(\"\");const[gclid,setGclid]=useState(\"\");const windowLocation=(_window=window)===null||_window===void 0?void 0:(_window_location=_window.location)===null||_window_location===void 0?void 0:_window_location.href;useEffect(()=>{const extractData=param=>{var _param_split;return param===null||param===void 0?void 0:(_param_split=param.split(\"=\"))===null||_param_split===void 0?void 0:_param_split.splice(1,1)[0];};if(typeof windowLocation===\"string\"){var _windowLocation_split_splice_,_windowLocation_split;const windowLocationData=windowLocation===null||windowLocation===void 0?void 0:(_windowLocation_split=windowLocation.split(\"?\"))===null||_windowLocation_split===void 0?void 0:(_windowLocation_split_splice_=_windowLocation_split.splice(1,2)[0])===null||_windowLocation_split_splice_===void 0?void 0:_windowLocation_split_splice_.split(\"&\");if(windowLocationData){windowLocationData.forEach(param=>{if(param.includes(\"utm_source\")){setUtmSource(extractData(param));}if(param.includes(\"utm_medium\")){setUtmMedium(extractData(param));}if(param.includes(\"utm_campaign\")){setUtmCampaign(extractData(param));}if(param.includes(\"gclid\")){setGclid(extractData(param));}});}}},[windowLocation]);return{utmCampaign,utmMedium,utmSource,gclid};};// Utility function that finds index by URL - used in the sidebar accordion on doc pages\nexport const findAccordionIndexByUrl=(currentUrl,navigation,isMobile,currentIndex,setCurrentIndex)=>{if(!currentUrl||!navigation)return-1;let foundIndex=isMobile?0:-1;for(let index=0;index<navigation.length;index++){const nav=navigation[index];const isCurrent=currentUrl.includes(nav.platform)&&nav.items.some(item=>currentUrl.endsWith(createLinkHref(\"documentation\",nav.platform,item.path)));if(isCurrent){foundIndex=index;}}if(foundIndex!==currentIndex){localStorage.setItem(\"docSidebarCurrentIndex\",foundIndex);setCurrentIndex(foundIndex);}return foundIndex;};// Returns true if the string does not include http(s): prefix in the URL\nexport function isInternalLink(url){return!url.includes(\"http://\")&&!url.includes(\"https://\");}\nexport const __FramerMetadata__ = {\"exports\":{\"updateUserGuideNavigation\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"isInternalLink\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useWindowDimensions\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"parseRepoName\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getMdFileName\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"removeHtmlComments\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getRepoByPlatform\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"createLinkHref\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"formatPathString\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getRepoOwner\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"updatePageMetadata\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"formatPageName\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"windowLocation\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getCurrentPageUrl\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useSmoothScroll\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"findAccordionIndexByUrl\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"updateNavigation\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useWindowLocation\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"uniqueId\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getTitleFromUrl\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getRepoName\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./_utils.map"],"mappings":"yHAKG,SAAgB,EAAiB,EAAW,CAAC,OAAO,EAAW,QAAQ,QAAQ,EAAE,CAAC,CAAC,QAAQ,SAAS,GAAO,IAAI,EAAM,YAAY,GAAG,CAAC,CAAC,QAAQ,KAAK,EAAE,CAAE,CAMvJ,SAAgB,EAAmB,EAAc,EAAS,EAAiB,CAAC,OAAe,SAAS,MAAM,MAAmB,CAChI,SAAS,MAAM,CAAc,GAAI,CAAC,CAAgB,CAAC,CAAE,CA0B48B,SAAS,GAAqB,CACh/B,GAAU,IAAS,OAAY,CAAC,GAAK,CAAC,WAAW,EAAM,YAAY,GAAQ,EAAO,MAAM,CAAC,QAAM,QAAM,CAAE,MAAM,MAAM,CAAC,MAAM,IAAa,OAAO,GAAa,CAAG,CAAC,SAAgB,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