// Supabase client — boots BEFORE any other Babel script that touches the cloud.
// Loaded as plain JS (not Babel) so it runs synchronously alongside the SDK.
//
// The publishable key below is safe to ship in the browser — Supabase row-level
// security rules (defined in SQL) restrict every row to its owner. Anyone with
// the key can attempt requests, but unauthenticated requests see nothing.

(function () {
  const SUPABASE_URL  = 'https://rnfkeplbqpjgajcixwfu.supabase.co';
  const SUPABASE_ANON = 'sb_publishable_FUTuW7-y9KP-iR4Dx4uxVQ_UZHTT7H7';

  if (!window.supabase || !window.supabase.createClient) {
    console.error('[Home Hub] Supabase SDK failed to load. Cloud sync disabled.');
    return;
  }

  window.SB = window.supabase.createClient(SUPABASE_URL, SUPABASE_ANON, {
    auth: {
      persistSession: true,
      autoRefreshToken: true,
      detectSessionInUrl: true,
      flowType: 'pkce',
    },
  });
})();
