import { _ as _asyncToGenerator, r as regenerator } from './asyncToGenerator-1ebeb135.js';
import './_commonjsHelpers-0c4b6f40.js';
import './core.get-iterator-method-95db387d.js';
import './web.dom.iterable-3fffc027.js';
import './_library-528f1934.js';
import './_set-species-7d3317b7.js';
import './_iter-detect-2f89237f.js';

var _this = undefined;

var _require = require('@supabase/supabase-js'),
    createClient = _require.createClient;

var SUPABASE_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJvbGUiOiJhbm9uIiwiaWF0IjoxNjQyNjIxNjAyLCJleHAiOjE5NTgxOTc2MDJ9.EkxMVx3xgnzkKAXk7-IRi5rLjKyUmlOE7p49LvYKHvY';
var SUPABASE_URL = "https://mefavzufrirdpagxuxvd.supabase.co";

var supabase = createClient(SUPABASE_URL, SUPABASE_KEY);

var getTIData = function () {
    var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(tableName, brandName) {
        var _ref2, tiData, error, _ref3, _tiData, _error;

        return regenerator.wrap(function _callee$(_context) {
            while (1) {
                switch (_context.prev = _context.next) {
                    case 0:
                        if (brandName) {
                            _context.next = 13;
                            break;
                        }

                        _context.next = 3;
                        return supabase.from('' + tableName).select('*');

                    case 3:
                        _ref2 = _context.sent;
                        tiData = _ref2.data;
                        error = _ref2.error;

                        if (!error) {
                            _context.next = 10;
                            break;
                        }

                        return _context.abrupt('return', {
                            msg: error.message,
                            fail: true
                        });

                    case 10:
                        return _context.abrupt('return', tiData);

                    case 11:
                        _context.next = 23;
                        break;

                    case 13:
                        _context.next = 15;
                        return supabase.from('' + tableName).select('*').eq('brandName', '' + brandName);

                    case 15:
                        _ref3 = _context.sent;
                        _tiData = _ref3.data;
                        _error = _ref3.error;

                        if (!_error) {
                            _context.next = 22;
                            break;
                        }

                        return _context.abrupt('return', {
                            msg: _error.message,
                            fail: true
                        });

                    case 22:
                        return _context.abrupt('return', _tiData);

                    case 23:
                    case 'end':
                        return _context.stop();
                }
            }
        }, _callee, _this);
    }));

    return function getTIData(_x, _x2) {
        return _ref.apply(this, arguments);
    };
}();
module.exports = getTIData;
