{"version":3,"file":"shared-lib.C51uk50n.mjs","names":["useStore"],"sources":["https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/jdyxxd8QoGsoiN6mvHya/KbhknNotGKsy2ptfNAbL/State.js","https:/framerusercontent.com/modules/aC33WnqCDMlZQfcIX47o/1jxUP5qDFsHedoZELwHB/siteMetadata.js"],"sourcesContent":["import{useState,useEffect}from\"react\";import{Data,useObserveData}from\"framer\";export function createStore(state1){// Use Data so that a Preview reload resets the state\nconst dataStore=Data({state:Object.freeze({...state1})});// Create a set function that updates the state\nconst setDataStore=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(dataStore.state);}dataStore.state=Object.freeze({...dataStore.state,...newState});};// Store the initial state, copy the object if it's an object\nlet storeState=typeof state1===\"object\"?Object.freeze({...state1}):state1;// Keep a list of all the listeners, in the form of React hook setters\nconst storeSetters=new Set();// Create a set function that updates all the listeners / setters\nconst setStoreState=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(storeState);}storeState=typeof newState===\"object\"?Object.freeze({...storeState,...newState}):newState;// Update all the listeners / setters with the new value\nstoreSetters.forEach(setter=>setter(storeState));};// Create the actual hook based on everything above\nfunction useStore(){// Create the hook we are going to use as a listener\nconst[state,setState]=useState(storeState);// If we unmount the component using this hook, we need to remove the listener\n// @ts-ignore\nuseEffect(()=>{// But right now, we need to add the listener\nstoreSetters.add(setState);return()=>storeSetters.delete(setState);},[]);// If Data context exists, use Data, otherwise use vanilla React state\nif(useObserveData()===true){useObserveData();return[dataStore.state,setDataStore];}else{// Return the state and a function to update the central store\nreturn[state,setStoreState];}}return useStore;}\nexport const __FramerMetadata__ = {\"exports\":{\"createStore\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./createStore.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";// Learn more: https://www.framer.com/developers/overrides/\nconst useStore=createStore({code:\"\",name:\"\",loading:false,error:false});export function withSetCodeOnChange(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onChange:e=>setStore({code:e.target.value})});});}export function withCode(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,text:store.code});});}export function showOnError(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,variant:store.error?\"Visible\":\"Hidden\"});});}export function withDisabledOnNoCode(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,// @ts-expect-error\nvariant:store.code===\"\"?\"Disabled\":props.variant,// @ts-expect-error\nclick:store.code===\"\"?()=>{}:props.click});});}export function withSetNameOnChange(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onChange:e=>setStore({name:e.target.value})});});}export function withName(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,text:store.name});});}export function withRedirectToStream(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();const handleClick=async()=>{console.log(\"Handling click\",store.code,store.name);if(store.code===\"\"||store.name===\"\"||store.loading){return;}setStore({loading:true,error:false});/**\n             * Use the below variables to change which environment is being used.\n             * Comment/uncomment the lines as needed.\n             *//** Production domain */// const host = \"https://metropolis.imporium.dev\"\n/** Staging domain */const host=\"https://metropolis.staging.imporium.dev\";/** Dev testing domain */// const host = \"http://localhost:3003\"\nconst url=new URL(\"/api/stream\",host);url.searchParams.set(\"code\",store.code);url.searchParams.set(\"name\",store.name);if(host.includes(\".staging.\")){url.searchParams.set(\"x-vercel-protection-bypass\",\"u5AArSch6aD9dljpji6epFokVe1NTG6v\");}const response=await fetch(url);console.log(\"Got response\");const data={ok:response.ok,...await response.json()};if(data.ok===false){setStore({loading:false,error:true});// Probably want some way of surfacing an error to the user\nconsole.log(\"Error fetching stream url\",response.status,response.statusText,data.error);throw new Error(\"Failed fetching stream url\");}window.location.href=data.url;};return /*#__PURE__*/_jsx(Component,{ref:ref,...props,click:handleClick,variant:store.name===\"\"||store.code===\"\"?\"Disabled\":store.loading?\"Loading\":props.variant});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withSetCodeOnChange\":{\"type\":\"reactHoc\",\"name\":\"withSetCodeOnChange\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showOnError\":{\"type\":\"reactHoc\",\"name\":\"showOnError\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCode\":{\"type\":\"reactHoc\",\"name\":\"withCode\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withName\":{\"type\":\"reactHoc\",\"name\":\"withName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withDisabledOnNoCode\":{\"type\":\"reactHoc\",\"name\":\"withDisabledOnNoCode\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSetNameOnChange\":{\"type\":\"reactHoc\",\"name\":\"withSetNameOnChange\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRedirectToStream\":{\"type\":\"reactHoc\",\"name\":\"withRedirectToStream\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./State.map","// Generated by Framer (3bdc3c5)\nexport default function metadata(params,activeLocale){return{description:\"Made with Framer\",robots:\"max-image-preview:large\",title:\"Metropolis\"};}export const metadataVersion=1;\nexport const __FramerMetadata__ = {\"exports\":{\"metadataVersion\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"default\":{\"type\":\"function\",\"annotations\":{\"fram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