-- Chattyness Development Seed Data
-- PostgreSQL 18
--
-- Sample data for development and testing.
-- Load via: psql -f seeds/development.sql
--
-- WARNING: This will insert data. Run only on development databases.

\set ON_ERROR_STOP on

BEGIN;

-- =============================================================================
-- Test Users
-- =============================================================================

INSERT INTO auth.users (id, username, email, password_hash, display_name, reputation_tier, status)
VALUES
    ('11111111-1111-1111-1111-111111111111', 'admin', 'admin@example.com',
     '$2a$12$dummy.hash.for.development.only', 'Server Admin', 'elder', 'active'),
    ('22222222-2222-2222-2222-222222222222', 'alice', 'alice@example.com',
     '$2a$12$dummy.hash.for.development.only', 'Alice', 'trusted', 'active'),
    ('33333333-3333-3333-3333-333333333333', 'bob', 'bob@example.com',
     '$2a$12$dummy.hash.for.development.only', 'Bob', 'established', 'active'),
    ('44444444-4444-4444-4444-444444444444', 'charlie', 'charlie@example.com',
     '$2a$12$dummy.hash.for.development.only', 'Charlie', 'member', 'active')
ON CONFLICT DO NOTHING;

-- Make admin a server admin
INSERT INTO server.staff (user_id, role, appointed_by)
VALUES ('11111111-1111-1111-1111-111111111111', 'owner', '11111111-1111-1111-1111-111111111111')
ON CONFLICT DO NOTHING;

-- =============================================================================
-- Sample Props in Server Library
-- =============================================================================

INSERT INTO server.props (id, name, slug, description, asset_path, default_layer, default_position, tags)
VALUES
    ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'Red Hat', 'red-hat',
     'A stylish red hat', 'props/hats/red-hat.png', 'accessories', 1, ARRAY['hat', 'accessory', 'red']),
    ('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'Blue Shirt', 'blue-shirt',
     'A casual blue shirt', 'props/clothing/blue-shirt.png', 'clothes', 4, ARRAY['shirt', 'clothing', 'blue']),
    ('cccccccc-cccc-cccc-cccc-cccccccccccc', 'Gold Coin', 'gold-coin',
     'A shiny gold coin', 'props/items/gold-coin.png', NULL, NULL, ARRAY['currency', 'collectible']),
    ('dddddddd-dddd-dddd-dddd-dddddddddddd', 'Trophy', 'trophy',
     'Achievement trophy', 'props/items/trophy.png', NULL, NULL, ARRAY['achievement', 'collectible'])
ON CONFLICT DO NOTHING;

-- =============================================================================
-- Sample Realm
-- =============================================================================

INSERT INTO realm.realms (id, name, slug, description, owner_id, privacy)
VALUES
    ('55555555-5555-5555-5555-555555555555', 'Welcome Plaza', 'welcome-plaza',
     'The main gathering place for new users', '11111111-1111-1111-1111-111111111111', 'public')
ON CONFLICT DO NOTHING;

-- =============================================================================
-- Sample Scenes
-- =============================================================================

INSERT INTO realm.scenes (id, realm_id, name, slug, description, bounds, is_entry_point, sort_order)
VALUES
    ('66666666-6666-6666-6666-666666666666', '55555555-5555-5555-5555-555555555555',
     'Main Hall', 'main-hall', 'The central gathering space',
     ST_MakeEnvelope(0, 0, 1024, 768, 0), true, 0),
    ('77777777-7777-7777-7777-777777777777', '55555555-5555-5555-5555-555555555555',
     'Garden', 'garden', 'A peaceful outdoor garden',
     ST_MakeEnvelope(0, 0, 1280, 720, 0), false, 1)
ON CONFLICT DO NOTHING;

-- Set default scene for realm
UPDATE realm.realms
SET default_scene_id = '66666666-6666-6666-6666-666666666666'
WHERE id = '55555555-5555-5555-5555-555555555555';

-- =============================================================================
-- Sample Channels (Public instances of scenes)
-- =============================================================================

INSERT INTO realm.channels (id, scene_id, channel_type, max_users)
VALUES
    ('88888888-8888-8888-8888-888888888888', '66666666-6666-6666-6666-666666666666', 'public', 50),
    ('99999999-9999-9999-9999-999999999999', '77777777-7777-7777-7777-777777777777', 'public', 50)
ON CONFLICT DO NOTHING;

-- =============================================================================
-- Sample Memberships
-- =============================================================================

INSERT INTO realm.memberships (realm_id, user_id, role)
VALUES
    ('55555555-5555-5555-5555-555555555555', '11111111-1111-1111-1111-111111111111', 'owner'),
    ('55555555-5555-5555-5555-555555555555', '22222222-2222-2222-2222-222222222222', 'moderator'),
    ('55555555-5555-5555-5555-555555555555', '33333333-3333-3333-3333-333333333333', 'member'),
    ('55555555-5555-5555-5555-555555555555', '44444444-4444-4444-4444-444444444444', 'member')
ON CONFLICT DO NOTHING;

-- =============================================================================
-- Sample Spots
-- =============================================================================

INSERT INTO realm.spots (scene_id, name, slug, region, spot_type)
VALUES
    ('66666666-6666-6666-6666-666666666666', 'Info Desk', 'info-desk',
     ST_SetSRID(ST_MakePolygon(ST_MakeLine(ARRAY[
         ST_MakePoint(100, 100), ST_MakePoint(200, 100),
         ST_MakePoint(200, 200), ST_MakePoint(100, 200),
         ST_MakePoint(100, 100)
     ])), 0),
     'normal'),
    ('66666666-6666-6666-6666-666666666666', 'Garden Portal', 'garden-portal',
     ST_SetSRID(ST_Buffer(ST_MakePoint(800, 400), 50), 0),
     'door')
ON CONFLICT DO NOTHING;

-- =============================================================================
-- Sample Friendships
-- =============================================================================

INSERT INTO auth.friendships (friend_a, friend_b, initiated_by, is_accepted, accepted_at)
VALUES
    -- Alice and Bob are friends (Alice < Bob alphabetically in UUIDs)
    ('22222222-2222-2222-2222-222222222222', '33333333-3333-3333-3333-333333333333',
     '22222222-2222-2222-2222-222222222222', true, now())
ON CONFLICT DO NOTHING;

COMMIT;

\echo 'Development seed data loaded successfully!'
