import { EventBus } from '../core/EventBus.js';
import React from 'react';

/* ────────────────────────────────────────────────────────────────
   Quest & Mission System
   
   A comprehensive quest system with:
   - Multiple quest types (main, side, daily, achievement)
   - Objectives with progress tracking
   - Rewards and prerequisites
   - Quest chains and dependencies
   - State persistence
──────────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════
   QUEST MANAGER
══════════════════════════════════════════════════════════════════ */
class QuestManager {
    constructor(events) {
        this.quests = new Map();
        this.journal = {
            activeQuests: [],
            completedQuests: [],
            failedQuests: [],
        };
        this.playerLevel = 1;
        this.playerItems = new Set();
        this.playerSkills = new Set();
        this.reputation = new Map();
        this.customConditions = new Map();
        this.events = events !== null && events !== void 0 ? events : new EventBus();
    }
    /* ── Quest Registration ───────────────────────────────────────── */
    registerQuest(quest) {
        this.quests.set(quest.id, quest);
    }
    registerQuests(quests) {
        for (const quest of quests) {
            this.registerQuest(quest);
        }
    }
    unregisterQuest(questId) {
        this.quests.delete(questId);
    }
    getQuest(questId) {
        return this.quests.get(questId);
    }
    getAllQuests() {
        return Array.from(this.quests.values());
    }
    /* ── Player State ─────────────────────────────────────────────── */
    setPlayerLevel(level) {
        this.playerLevel = level;
        this.checkQuestUnlocks();
    }
    addPlayerItem(itemId) {
        this.playerItems.add(itemId);
        this.checkQuestUnlocks();
    }
    removePlayerItem(itemId) {
        this.playerItems.delete(itemId);
    }
    addPlayerSkill(skillId) {
        this.playerSkills.add(skillId);
        this.checkQuestUnlocks();
    }
    setReputation(factionId, amount) {
        this.reputation.set(factionId, amount);
        this.checkQuestUnlocks();
    }
    addReputation(factionId, amount) {
        var _a;
        const current = (_a = this.reputation.get(factionId)) !== null && _a !== void 0 ? _a : 0;
        this.reputation.set(factionId, current + amount);
        this.checkQuestUnlocks();
    }
    registerCustomCondition(key, condition) {
        this.customConditions.set(key, condition);
    }
    /* ── Quest State ──────────────────────────────────────────────── */
    getQuestState(questId) {
        var _a, _b;
        return (_b = (_a = this.journal.activeQuests.find(q => q.questId === questId)) !== null && _a !== void 0 ? _a : this.journal.completedQuests.find(q => q.questId === questId)) !== null && _b !== void 0 ? _b : this.journal.failedQuests.find(q => q.questId === questId);
    }
    getQuestStatus(questId) {
        const state = this.getQuestState(questId);
        if (state)
            return state.status;
        const quest = this.quests.get(questId);
        if (!quest)
            return 'locked';
        return this.canUnlockQuest(questId) ? 'available' : 'locked';
    }
    getActiveQuests() {
        return [...this.journal.activeQuests];
    }
    getCompletedQuests() {
        return [...this.journal.completedQuests];
    }
    getAvailableQuests() {
        return this.getAllQuests().filter(q => {
            const status = this.getQuestStatus(q.id);
            return status === 'available';
        });
    }
    getJournal() {
        return { ...this.journal };
    }
    /* ── Quest Flow ───────────────────────────────────────────────── */
    canUnlockQuest(questId) {
        const quest = this.quests.get(questId);
        if (!quest)
            return false;
        // Already active or completed
        const existingState = this.getQuestState(questId);
        if (existingState && (existingState.status === 'active' || existingState.status === 'completed')) {
            // Check if repeatable
            if (!quest.repeatable)
                return false;
            if (existingState.lastCompletedAt && quest.repeatCooldown) {
                if (Date.now() - existingState.lastCompletedAt < quest.repeatCooldown) {
                    return false;
                }
            }
        }
        // Check prerequisites
        return quest.prerequisites.every(prereq => this.checkPrerequisite(prereq));
    }
    checkPrerequisite(prereq) {
        var _a, _b;
        switch (prereq.type) {
            case 'quest':
                if (!prereq.questId)
                    return true;
                const state = this.getQuestState(prereq.questId);
                return (state === null || state === void 0 ? void 0 : state.status) === 'completed';
            case 'level':
                return this.playerLevel >= ((_a = prereq.level) !== null && _a !== void 0 ? _a : 0);
            case 'item':
                return prereq.itemId ? this.playerItems.has(prereq.itemId) : true;
            case 'reputation':
                if (!prereq.reputation)
                    return true;
                const rep = (_b = this.reputation.get(prereq.reputation.factionId)) !== null && _b !== void 0 ? _b : 0;
                return rep >= prereq.reputation.amount;
            case 'skill':
                return prereq.skillId ? this.playerSkills.has(prereq.skillId) : true;
            case 'time':
                if (!prereq.timeWindow)
                    return true;
                const now = Date.now();
                return now >= prereq.timeWindow.start && now <= prereq.timeWindow.end;
            case 'custom':
                if (!prereq.customKey)
                    return true;
                const condition = this.customConditions.get(prereq.customKey);
                return condition ? condition() : false;
            default:
                return true;
        }
    }
    acceptQuest(questId) {
        var _a, _b;
        if (!this.canUnlockQuest(questId))
            return false;
        const quest = this.quests.get(questId);
        if (!quest)
            return false;
        // Remove from failed if re-accepting
        this.journal.failedQuests = this.journal.failedQuests.filter(q => q.questId !== questId);
        // Create fresh objectives with 0 progress
        const objectives = quest.objectives.map(obj => ({
            ...obj,
            current: 0,
            completed: false,
        }));
        const state = {
            questId,
            status: 'active',
            objectives,
            startedAt: Date.now(),
            completionCount: (_b = (_a = this.getQuestState(questId)) === null || _a === void 0 ? void 0 : _a.completionCount) !== null && _b !== void 0 ? _b : 0,
        };
        if (quest.timeLimit) {
            state.timeRemaining = quest.timeLimit * 1000;
        }
        this.journal.activeQuests.push(state);
        this.emitEvent('quest:accepted', questId, {});
        return true;
    }
    abandonQuest(questId) {
        const quest = this.quests.get(questId);
        if (!(quest === null || quest === void 0 ? void 0 : quest.canAbandon))
            return false;
        const stateIndex = this.journal.activeQuests.findIndex(q => q.questId === questId);
        if (stateIndex === -1)
            return false;
        const state = this.journal.activeQuests[stateIndex];
        state.status = 'failed';
        state.endedAt = Date.now();
        this.journal.activeQuests.splice(stateIndex, 1);
        this.journal.failedQuests.push(state);
        this.emitEvent('quest:abandoned', questId, {});
        return true;
    }
    /* ── Objective Progress ───────────────────────────────────────── */
    updateObjectiveProgress(questId, objectiveId, amount) {
        const state = this.journal.activeQuests.find(q => q.questId === questId);
        if (!state || state.status !== 'active')
            return false;
        const objective = state.objectives.find(o => o.id === objectiveId);
        if (!objective || objective.completed)
            return false;
        const previousValue = objective.current;
        objective.current = Math.min(objective.current + amount, objective.target);
        this.emitEvent('quest:objective-progress', questId, {
            objectiveId,
            previous: previousValue,
            current: objective.current,
            target: objective.target,
        });
        // Check if objective completed
        if (objective.current >= objective.target) {
            objective.completed = true;
            this.emitEvent('quest:objective-completed', questId, { objectiveId });
            this.checkQuestCompletion(questId);
        }
        return true;
    }
    setObjectiveProgress(questId, objectiveId, value) {
        const state = this.journal.activeQuests.find(q => q.questId === questId);
        if (!state || state.status !== 'active')
            return false;
        const objective = state.objectives.find(o => o.id === objectiveId);
        if (!objective || objective.completed)
            return false;
        const previousValue = objective.current;
        objective.current = Math.min(value, objective.target);
        if (objective.current !== previousValue) {
            this.emitEvent('quest:objective-progress', questId, {
                objectiveId,
                previous: previousValue,
                current: objective.current,
                target: objective.target,
            });
        }
        if (objective.current >= objective.target) {
            objective.completed = true;
            this.emitEvent('quest:objective-completed', questId, { objectiveId });
            this.checkQuestCompletion(questId);
        }
        return true;
    }
    completeObjective(questId, objectiveId) {
        const state = this.journal.activeQuests.find(q => q.questId === questId);
        if (!state || state.status !== 'active')
            return false;
        const objective = state.objectives.find(o => o.id === objectiveId);
        if (!objective || objective.completed)
            return false;
        objective.current = objective.target;
        objective.completed = true;
        this.emitEvent('quest:objective-completed', questId, { objectiveId });
        this.checkQuestCompletion(questId);
        return true;
    }
    /* ── Quest Completion ─────────────────────────────────────────── */
    checkQuestCompletion(questId) {
        const state = this.journal.activeQuests.find(q => q.questId === questId);
        if (!state)
            return;
        // Check if all required objectives are complete
        const requiredComplete = state.objectives
            .filter(o => !o.optional)
            .every(o => o.completed);
        if (requiredComplete) {
            this.completeQuest(questId);
        }
    }
    completeQuest(questId) {
        const stateIndex = this.journal.activeQuests.findIndex(q => q.questId === questId);
        if (stateIndex === -1)
            return false;
        const state = this.journal.activeQuests[stateIndex];
        state.status = 'completed';
        state.endedAt = Date.now();
        state.completionCount++;
        state.lastCompletedAt = Date.now();
        this.journal.activeQuests.splice(stateIndex, 1);
        this.journal.completedQuests.push(state);
        this.emitEvent('quest:completed', questId, { state: { ...state } });
        this.checkQuestUnlocks();
        this.checkFollowUpQuests(questId);
        return true;
    }
    failQuest(questId) {
        const stateIndex = this.journal.activeQuests.findIndex(q => q.questId === questId);
        if (stateIndex === -1)
            return false;
        const state = this.journal.activeQuests[stateIndex];
        state.status = 'failed';
        state.endedAt = Date.now();
        this.journal.activeQuests.splice(stateIndex, 1);
        this.journal.failedQuests.push(state);
        this.emitEvent('quest:failed', questId, {});
        return true;
    }
    checkQuestUnlocks() {
        for (const quest of this.quests.values()) {
            const status = this.getQuestStatus(quest.id);
            if (status === 'locked' && this.canUnlockQuest(quest.id)) {
                this.emitEvent('quest:unlocked', quest.id, {});
            }
        }
    }
    checkFollowUpQuests(completedQuestId) {
        const quest = this.quests.get(completedQuestId);
        if (!(quest === null || quest === void 0 ? void 0 : quest.followUpQuests))
            return;
        for (const followUpId of quest.followUpQuests) {
            if (this.canUnlockQuest(followUpId)) {
                this.emitEvent('quest:unlocked', followUpId, {});
            }
        }
    }
    /* ── Rewards ──────────────────────────────────────────────────── */
    getQuestRewards(questId) {
        const quest = this.quests.get(questId);
        const state = this.getQuestState(questId);
        if (!quest || (state === null || state === void 0 ? void 0 : state.status) !== 'completed')
            return null;
        const main = [...quest.rewards];
        const bonus = [];
        // Add bonus rewards if optional objectives completed
        if (quest.bonusRewards && state) {
            const optionalComplete = state.objectives
                .filter(o => o.optional)
                .every(o => o.completed);
            if (optionalComplete) {
                bonus.push(...quest.bonusRewards);
            }
        }
        return { main, bonus };
    }
    claimRewards(questId) {
        const rewards = this.getQuestRewards(questId);
        if (!rewards)
            return null;
        const allRewards = [...rewards.main, ...rewards.bonus];
        this.emitEvent('quest:reward-claimed', questId, { rewards: allRewards });
        return allRewards;
    }
    /* ── Quest Tracking ───────────────────────────────────────────── */
    trackQuest(questId) {
        const state = this.journal.activeQuests.find(q => q.questId === questId);
        if (!state)
            return;
        this.journal.trackedQuestId = questId;
        this.emitEvent('quest:tracked', questId, {});
    }
    untrackQuest() {
        this.journal.trackedQuestId = undefined;
    }
    getTrackedQuest() {
        if (!this.journal.trackedQuestId)
            return undefined;
        return this.journal.activeQuests.find(q => q.questId === this.journal.trackedQuestId);
    }
    /* ── Timer Update ─────────────────────────────────────────────── */
    update(deltaMs) {
        for (const state of this.journal.activeQuests) {
            if (state.timeRemaining !== undefined && state.timeRemaining > 0) {
                state.timeRemaining -= deltaMs;
                if (state.timeRemaining <= 0) {
                    state.timeRemaining = 0;
                    this.failQuest(state.questId);
                }
            }
        }
    }
    /* ── Persistence ──────────────────────────────────────────────── */
    saveState() {
        return JSON.parse(JSON.stringify(this.journal));
    }
    loadState(journal) {
        this.journal = JSON.parse(JSON.stringify(journal));
    }
    /* ── Events ───────────────────────────────────────────────────── */
    emitEvent(type, questId, data) {
        this.events.emit(type, {
            type,
            questId,
            data,
            timestamp: Date.now(),
        });
    }
    subscribe(eventType, handler) {
        return this.events.on(eventType, handler);
    }
}
/* ═══════════════════════════════════════════════════════════════
   QUEST BUILDER (Fluent API)
══════════════════════════════════════════════════════════════════ */
class QuestBuilder {
    constructor(id, name) {
        this.objectiveCounter = 0;
        this.rewardCounter = 0;
        this.quest = {
            id,
            name,
            summary: '',
            description: '',
            type: 'side',
            difficulty: 'normal',
            objectives: [],
            rewards: [],
            prerequisites: [],
            canAbandon: true,
            repeatable: false,
        };
    }
    summary(summary) {
        this.quest.summary = summary;
        return this;
    }
    description(description) {
        this.quest.description = description;
        return this;
    }
    type(type) {
        this.quest.type = type;
        return this;
    }
    difficulty(difficulty) {
        this.quest.difficulty = difficulty;
        return this;
    }
    icon(icon) {
        this.quest.icon = icon;
        return this;
    }
    giver(npcId) {
        this.quest.giverNpcId = npcId;
        return this;
    }
    turnIn(npcId) {
        this.quest.turnInNpcId = npcId;
        return this;
    }
    location(hint) {
        this.quest.locationHint = hint;
        return this;
    }
    level(level) {
        this.quest.recommendedLevel = level;
        return this;
    }
    timeLimit(seconds) {
        this.quest.timeLimit = seconds;
        return this;
    }
    cannotAbandon() {
        this.quest.canAbandon = false;
        return this;
    }
    repeatable(cooldownMs = 0) {
        this.quest.repeatable = true;
        this.quest.repeatCooldown = cooldownMs;
        return this;
    }
    tags(tags) {
        this.quest.tags = tags;
        return this;
    }
    followUp(questIds) {
        this.quest.followUpQuests = questIds;
        return this;
    }
    /* ── Prerequisites ────────────────────────────────────────────── */
    requireQuest(questId) {
        this.quest.prerequisites.push({ type: 'quest', questId });
        return this;
    }
    requireLevel(level) {
        this.quest.prerequisites.push({ type: 'level', level });
        return this;
    }
    requireItem(itemId) {
        this.quest.prerequisites.push({ type: 'item', itemId });
        return this;
    }
    requireReputation(factionId, amount) {
        this.quest.prerequisites.push({ type: 'reputation', reputation: { factionId, amount } });
        return this;
    }
    requireSkill(skillId) {
        this.quest.prerequisites.push({ type: 'skill', skillId });
        return this;
    }
    requireCustom(customKey) {
        this.quest.prerequisites.push({ type: 'custom', customKey });
        return this;
    }
    /* ── Objectives ───────────────────────────────────────────────── */
    addObjective(objective) {
        const id = `obj_${++this.objectiveCounter}`;
        this.quest.objectives.push({
            ...objective,
            id,
            current: 0,
            completed: false,
        });
        return this;
    }
    collect(itemId, amount, description, optional = false) {
        return this.addObjective({
            type: 'collect',
            description,
            target: amount,
            optional,
            trackingData: { itemId },
        });
    }
    kill(enemyType, amount, description, optional = false) {
        return this.addObjective({
            type: 'kill',
            description,
            target: amount,
            optional,
            trackingData: { enemyType },
        });
    }
    interact(entityId, description, optional = false) {
        return this.addObjective({
            type: 'interact',
            description,
            target: 1,
            optional,
            trackingData: { entityId },
        });
    }
    reach(locationId, description, optional = false) {
        return this.addObjective({
            type: 'reach',
            description,
            target: 1,
            optional,
            trackingData: { locationId },
        });
    }
    escort(npcId, locationId, description, optional = false) {
        return this.addObjective({
            type: 'escort',
            description,
            target: 1,
            optional,
            trackingData: { npcId, locationId },
        });
    }
    defend(seconds, description, optional = false) {
        return this.addObjective({
            type: 'defend',
            description,
            target: seconds,
            optional,
        });
    }
    survive(seconds, description, optional = false) {
        return this.addObjective({
            type: 'survive',
            description,
            target: seconds,
            optional,
        });
    }
    craft(itemId, amount, description, optional = false) {
        return this.addObjective({
            type: 'craft',
            description,
            target: amount,
            optional,
            trackingData: { itemId },
        });
    }
    talk(npcId, description, optional = false) {
        return this.addObjective({
            type: 'talk',
            description,
            target: 1,
            optional,
            trackingData: { npcId },
        });
    }
    discover(locationId, description, optional = false) {
        return this.addObjective({
            type: 'discover',
            description,
            target: 1,
            optional,
            trackingData: { locationId },
        });
    }
    score(threshold, description, optional = false) {
        return this.addObjective({
            type: 'score',
            description,
            target: threshold,
            optional,
        });
    }
    customObjective(type, target, description, data, optional = false) {
        return this.addObjective({
            type: 'custom',
            description,
            target,
            optional,
            trackingData: data,
        });
    }
    /* ── Rewards ──────────────────────────────────────────────────── */
    generateRewardId() {
        return `reward_${++this.rewardCounter}`;
    }
    rewardXP(amount, name = 'Experience') {
        this.quest.rewards.push({
            id: this.generateRewardId(),
            type: 'experience',
            name,
            amount,
        });
        return this;
    }
    rewardCurrency(amount, currencyName = 'Gold') {
        this.quest.rewards.push({
            id: this.generateRewardId(),
            type: 'currency',
            name: currencyName,
            amount,
        });
        return this;
    }
    rewardItem(itemId, name, quantity = 1, icon) {
        this.quest.rewards.push({
            id: this.generateRewardId(),
            type: 'item',
            name,
            itemId,
            quantity,
            icon,
        });
        return this;
    }
    rewardSkill(skillId, name, icon) {
        this.quest.rewards.push({
            id: this.generateRewardId(),
            type: 'skill',
            name,
            skillId,
            icon,
        });
        return this;
    }
    rewardReputation(factionId, amount, factionName) {
        this.quest.rewards.push({
            id: this.generateRewardId(),
            type: 'reputation',
            name: `${factionName} Reputation`,
            reputation: { factionId, amount },
        });
        return this;
    }
    rewardUnlock(unlockId, name, icon) {
        this.quest.rewards.push({
            id: this.generateRewardId(),
            type: 'unlock',
            name,
            unlockId,
            icon,
        });
        return this;
    }
    rewardAchievement(achievementId, name, icon) {
        this.quest.rewards.push({
            id: this.generateRewardId(),
            type: 'achievement',
            name,
            unlockId: achievementId,
            icon,
        });
        return this;
    }
    bonusXP(amount, name = 'Bonus Experience') {
        if (!this.quest.bonusRewards)
            this.quest.bonusRewards = [];
        this.quest.bonusRewards.push({
            id: this.generateRewardId(),
            type: 'experience',
            name,
            amount,
        });
        return this;
    }
    bonusItem(itemId, name, quantity = 1, icon) {
        if (!this.quest.bonusRewards)
            this.quest.bonusRewards = [];
        this.quest.bonusRewards.push({
            id: this.generateRewardId(),
            type: 'item',
            name,
            itemId,
            quantity,
            icon,
        });
        return this;
    }
    build() {
        return { ...this.quest };
    }
}
const QuestList = ({ quests, questDefinitions, trackedId, onSelect, onTrack, filter, className = '', style, }) => {
    const filteredQuests = filter
        ? quests.filter(q => {
            const def = questDefinitions.get(q.questId);
            return def && filter.includes(def.type);
        })
        : quests;
    return React.createElement('div', {
        className: `nice-quest-list ${className}`,
        style: {
            display: 'flex',
            flexDirection: 'column',
            gap: '8px',
            ...style,
        },
    }, filteredQuests.map(state => {
        const quest = questDefinitions.get(state.questId);
        if (!quest)
            return null;
        const progress = state.objectives.filter(o => !o.optional);
        const completed = progress.filter(o => o.completed).length;
        const total = progress.length;
        const isTracked = trackedId === state.questId;
        return React.createElement('div', {
            key: state.questId,
            className: `nice-quest-item ${isTracked ? 'tracked' : ''}`,
            onClick: () => onSelect === null || onSelect === void 0 ? void 0 : onSelect(state.questId),
            style: {
                padding: '12px',
                backgroundColor: isTracked ? 'rgba(100, 181, 246, 0.2)' : 'rgba(255, 255, 255, 0.05)',
                border: isTracked ? '2px solid #64b5f6' : '2px solid transparent',
                borderRadius: '8px',
                cursor: 'pointer',
            },
        }, [
            React.createElement('div', {
                key: 'header',
                style: { display: 'flex', justifyContent: 'space-between', marginBottom: '4px' },
            }, [
                React.createElement('span', {
                    key: 'name',
                    style: { fontWeight: 'bold' },
                }, quest.name),
                React.createElement('span', {
                    key: 'type',
                    style: {
                        fontSize: '12px',
                        padding: '2px 6px',
                        backgroundColor: getTypeColor(quest.type),
                        borderRadius: '4px',
                    },
                }, quest.type.toUpperCase()),
            ]),
            React.createElement('div', {
                key: 'progress',
                style: { display: 'flex', alignItems: 'center', gap: '8px', marginTop: '8px' },
            }, [
                React.createElement('div', {
                    key: 'bar',
                    style: {
                        flex: 1,
                        height: '4px',
                        backgroundColor: 'rgba(255, 255, 255, 0.2)',
                        borderRadius: '2px',
                        overflow: 'hidden',
                    },
                }, React.createElement('div', {
                    style: {
                        width: `${(completed / total) * 100}%`,
                        height: '100%',
                        backgroundColor: '#4caf50',
                    },
                })),
                React.createElement('span', {
                    key: 'text',
                    style: { fontSize: '12px', opacity: 0.7 },
                }, `${completed}/${total}`),
                onTrack && React.createElement('button', {
                    key: 'track',
                    onClick: (e) => {
                        e.stopPropagation();
                        onTrack(state.questId);
                    },
                    style: {
                        padding: '4px 8px',
                        fontSize: '10px',
                        backgroundColor: isTracked ? '#64b5f6' : 'transparent',
                        border: '1px solid #64b5f6',
                        borderRadius: '4px',
                        color: isTracked ? '#000' : '#64b5f6',
                        cursor: 'pointer',
                    },
                }, isTracked ? 'TRACKED' : 'TRACK'),
            ]),
        ]);
    }));
};
function getTypeColor(type) {
    switch (type) {
        case 'main': return '#f44336';
        case 'side': return '#2196f3';
        case 'daily': return '#4caf50';
        case 'weekly': return '#9c27b0';
        case 'achievement': return '#ff9800';
        case 'tutorial': return '#00bcd4';
        case 'hidden': return '#607d8b';
        default: return '#9e9e9e';
    }
}
const QuestTracker = ({ state, quest, showOptional = false, className = '', style, }) => {
    const objectives = showOptional
        ? state.objectives
        : state.objectives.filter(o => !o.optional);
    return React.createElement('div', {
        className: `nice-quest-tracker ${className}`,
        style: {
            padding: '12px',
            backgroundColor: 'rgba(0, 0, 0, 0.6)',
            borderRadius: '8px',
            color: 'white',
            minWidth: '200px',
            ...style,
        },
    }, [
        React.createElement('div', {
            key: 'header',
            style: {
                fontWeight: 'bold',
                marginBottom: '8px',
                paddingBottom: '8px',
                borderBottom: '1px solid rgba(255, 255, 255, 0.2)',
            },
        }, quest.name),
        React.createElement('div', {
            key: 'objectives',
            style: { display: 'flex', flexDirection: 'column', gap: '4px' },
        }, objectives.map(obj => React.createElement('div', {
            key: obj.id,
            style: {
                display: 'flex',
                alignItems: 'center',
                gap: '8px',
                opacity: obj.completed ? 0.5 : 1,
                textDecoration: obj.completed ? 'line-through' : 'none',
                fontSize: '14px',
            },
        }, [
            React.createElement('span', {
                key: 'check',
                style: { color: obj.completed ? '#4caf50' : '#9e9e9e' },
            }, obj.completed ? '✓' : '○'),
            React.createElement('span', { key: 'desc' }, obj.description),
            obj.target > 1 && React.createElement('span', {
                key: 'progress',
                style: { marginLeft: 'auto', fontSize: '12px', opacity: 0.7 },
            }, `${obj.current}/${obj.target}`),
        ]))),
        state.timeRemaining !== undefined && state.timeRemaining > 0 && React.createElement('div', {
            key: 'timer',
            style: {
                marginTop: '8px',
                paddingTop: '8px',
                borderTop: '1px solid rgba(255, 255, 255, 0.2)',
                textAlign: 'center',
                color: state.timeRemaining < 30000 ? '#f44336' : '#fff',
            },
        }, `Time: ${formatTime(state.timeRemaining)}`),
    ]);
};
function formatTime(ms) {
    const seconds = Math.floor(ms / 1000);
    const minutes = Math.floor(seconds / 60);
    const remainingSeconds = seconds % 60;
    return `${minutes}:${remainingSeconds.toString().padStart(2, '0')}`;
}
/* ═══════════════════════════════════════════════════════════════
   UTILITY FUNCTIONS
══════════════════════════════════════════════════════════════════ */
function createEmptyQuest(id, name) {
    return new QuestBuilder(id, name).build();
}
const DIFFICULTY_COLORS = {
    trivial: '#9e9e9e',
    easy: '#4caf50',
    normal: '#2196f3',
    hard: '#ff9800',
    legendary: '#f44336',
};
const DIFFICULTY_XP_MULTIPLIERS = {
    trivial: 0.5,
    easy: 0.75,
    normal: 1,
    hard: 1.5,
    legendary: 2,
};

export { DIFFICULTY_COLORS, DIFFICULTY_XP_MULTIPLIERS, QuestBuilder, QuestList, QuestManager, QuestTracker, createEmptyQuest };
//# sourceMappingURL=QuestSystem.js.map
