{"version":3,"file":"STPGAdminAccess.BOASjfR-.mjs","names":["React.useState","React.useCallback","__esmMin","init_npm_react_18_3_1","ne","init_ssg_sandbox_shims","te","window","_e","p","J","init_jsx_runtime","ce","init_framer_BWFVvmND","ControlType","addPropertyControls","supabase","init_supabase","GateStateView","props","message","showPortalButton","onPortalClick","linkHref","linkTarget","linkLabel","withSTPGAdminAccess","status","setStatus","loginHref","setLoginHref","cancelled","verify","userData","userError","explicitLoginUrl","adminData","adminError","Component","STPGAdminSignOut","handleSignOut","borderColor","backgroundColor","textColor","style","init_STPGAdminAccess"],"sources":["https:/framerusercontent.com/modules/uFfDlcHERFAgsbgBfmxi/ke9tb5auhtnXE6kTknvt/STPGAdminAccess.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";// @ts-ignore Local file resolution in Framer supports explicit .ts extension in code components.\nimport{supabase}from\"https://framerusercontent.com/modules/UPsPLHTsnLusMJKVd80p/XzBJOS8JKX2Im1BZmeRN/supabase.js\";function GateStateView(props){const{message,showPortalButton,onPortalClick,linkHref,linkLabel,linkTarget}=props;return /*#__PURE__*/_jsxs(\"div\",{role:\"status\",\"aria-live\":\"polite\",style:{position:\"relative\",width:\"100%\",height:\"100%\",minHeight:120,boxSizing:\"border-box\",background:\"#0D0D0E\",color:\"#F3F0E8\",border:\"1px solid #2A2B2F\",display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",gap:12,padding:16,textAlign:\"center\",fontFamily:'\"Big Shoulders Display\", \"Inter Tight\", \"Roboto Condensed\", Inter, system-ui, sans-serif',letterSpacing:\"0.05em\",textTransform:\"uppercase\"},children:[/*#__PURE__*/_jsx(\"div\",{children:message}),showPortalButton?/*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:onPortalClick,style:{border:\"1px solid #FF6A1A\",background:\"transparent\",color:\"#FF6A1A\",padding:\"8px 12px\",fontSize:12,fontWeight:700,letterSpacing:\"0.06em\",textTransform:\"uppercase\",cursor:\"pointer\"},children:\"Go to Driver Portal\"}):null,linkHref?/*#__PURE__*/_jsx(\"a\",{href:linkHref,target:linkTarget,rel:linkTarget===\"_blank\"?\"noopener noreferrer\":undefined,style:{border:\"1px solid #FF6A1A\",background:\"transparent\",color:\"#FF6A1A\",padding:\"8px 12px\",fontSize:12,fontWeight:700,letterSpacing:\"0.06em\",textTransform:\"uppercase\",textDecoration:\"none\"},children:linkLabel||\"Go to Login\"}):null]});}export function withSTPGAdminAccess(Component){return /*#__PURE__*/React.forwardRef(function WithSTPGAdminAccess(props,ref){const[status,setStatus]=React.useState(\"checking\");const[loginHref,setLoginHref]=React.useState(\"\");React.useEffect(()=>{let cancelled=false;async function verify(){const{data:userData,error:userError}=await supabase.auth.getUser();if(cancelled)return;if(userError||!userData?.user){if(typeof window!==\"undefined\"){const explicitLoginUrl=`${window.location.origin}/login`;const isEmbedded=window.self!==window.top;if(isEmbedded){React.startTransition(()=>{setLoginHref(\"https://drivestpg.com/login\");setStatus(\"unauth\");});return;}window.location.assign(explicitLoginUrl);}React.startTransition(()=>setStatus(\"checking\"));return;}const{data:adminData,error:adminError}=await supabase.rpc(\"is_stpg_admin\");if(cancelled)return;if(adminError||adminData!==true){React.startTransition(()=>setStatus(\"denied\"));return;}React.startTransition(()=>setStatus(\"ok\"));}verify().catch(()=>{if(cancelled)return;React.startTransition(()=>setStatus(\"denied\"));});return()=>{cancelled=true;};},[]);if(status===\"checking\"){return /*#__PURE__*/_jsx(GateStateView,{message:\"VERIFYING ADMIN ACCESS...\"});}if(status===\"unauth\"){return /*#__PURE__*/_jsx(GateStateView,{message:\"STPG ADMIN LOGIN REQUIRED\",linkHref:loginHref,linkLabel:\"Go to Admin Login\",linkTarget:\"_top\"});}if(status===\"denied\"){return /*#__PURE__*/_jsx(GateStateView,{message:\"ACCESS DENIED — ADMIN ONLY\",showPortalButton:true,onPortalClick:()=>{if(typeof window!==\"undefined\"){window.location.assign(\"/driver-portal\");}}});}return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export function STPGAdminSignOut(props){const{backgroundColor,borderColor,textColor,style}=props;const handleSignOut=React.useCallback(async()=>{await supabase.auth.signOut();if(typeof window!==\"undefined\"){window.location.assign(\"/login\");}},[]);return /*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:handleSignOut,style:{position:\"relative\",width:\"100%\",boxSizing:\"border-box\",border:`1px solid ${borderColor}`,background:backgroundColor,color:textColor,borderRadius:8,padding:\"10px 14px\",fontSize:12,fontWeight:700,letterSpacing:\"0.08em\",textTransform:\"uppercase\",cursor:\"pointer\",fontFamily:'\"Big Shoulders Display\", \"Inter Tight\", \"Roboto Condensed\", Inter, system-ui, sans-serif',...style},children:\"SIGN OUT\"});}addPropertyControls(STPGAdminSignOut,{backgroundColor:{type:ControlType.Color,title:\"Surface\",defaultValue:\"#111214\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"#FF6A1A\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#F3F0E8\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"STPGAdminSignOut\":{\"type\":\"reactComponent\",\"name\":\"STPGAdminSignOut\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"withSTPGAdminAccess\":{\"type\":\"reactHoc\",\"name\":\"withSTPGAdminAccess\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"A,8QACkH,SAASkB,EAAc,EAAM,CAAC,GAAK,CAAC,UAAQ,mBAAiB,gBAAc,WAAS,YAAU,cAAYC,EAAM,MAAoB,gBAAM,MAAM,CAAC,KAAK,SAAS,YAAY,SAAS,MAAM,CAAC,SAAS,WAAW,MAAM,OAAO,OAAO,OAA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