{"version":3,"file":"hslAdjustmentFilter.cjs","sources":["../../../src/filters/hslAdjustmentFilter.ts"],"sourcesContent":["import { HslAdjustmentFilter } from 'pixi-filters';\nimport { type HslAdjustmentFilterConfig, type FilterResult } from './types';\nimport { ShaderResourceManager } from '../managers/ShaderResourceManager';\n\n/**\n * Creates an HSL Adjustment filter for modifying hue, saturation, and lightness\n *\n * This filter allows for precise color adjustments in the HSL color space, including\n * colorization effects and individual control over hue, saturation, and lightness.\n * Uses shader pooling for better performance.\n *\n * @param config - Configuration for the HSL Adjustment filter\n * @returns FilterResult with the filter instance and control functions\n */\nexport function createHslAdjustmentFilter(config: HslAdjustmentFilterConfig): FilterResult {\n    // Get shader manager instance\n    const shaderManager = ShaderResourceManager.getInstance();\n\n    // Create options object for the filter\n    const options: any = {};\n\n    // Apply configuration values if provided, otherwise use defaults\n    if (config.alpha !== undefined) options.alpha = config.alpha;\n    if (config.colorize !== undefined) options.colorize = config.colorize;\n    if (config.hue !== undefined) options.hue = config.hue;\n    if (config.lightness !== undefined) options.lightness = config.lightness;\n    if (config.saturation !== undefined) options.saturation = config.saturation;\n\n    // Create a unique key for this filter configuration\n    const colorizeStr = options.colorize ? 'colorize' : 'nocolorize';\n    const shaderKey = `hsl-adjustment-filter-${colorizeStr}`;\n\n    // Create the filter with options\n    const filter = new HslAdjustmentFilter(options);\n\n    // Register filter with shader manager\n    try {\n        shaderManager.registerFilter(filter, shaderKey);\n    } catch (error) {\n        console.warn('Error registering HSL adjustment filter with shader manager:', error);\n    }\n\n    /**\n     * Update the filter's intensity based on the configuration\n     *\n     * @param intensity - New intensity value (0-10 scale)\n     */\n    const updateIntensity = (intensity: number): void => {\n        // Normalize intensity to a 0-10 scale\n        const normalizedIntensity = Math.max(0, Math.min(10, intensity));\n\n        // Determine which property to adjust based on config\n        if (config.primaryProperty) {\n            switch (config.primaryProperty) {\n                case 'hue':\n                    // Map 0-10 to -180 to 180 degrees for hue\n                    filter.hue = -180 + (normalizedIntensity * 36);\n                    break;\n                case 'saturation':\n                    // Map 0-10 to -1 to 1 for saturation\n                    filter.saturation = -1 + (normalizedIntensity / 5);\n                    break;\n                case 'lightness':\n                    // Map 0-10 to -1 to 1 for lightness\n                    filter.lightness = -1 + (normalizedIntensity / 5);\n                    break;\n                case 'alpha':\n                    // Map 0-10 to 0-1 for alpha\n                    filter.alpha = normalizedIntensity / 10;\n                    break;\n                default:\n                    // Default to adjusting saturation\n                    filter.saturation = -1 + (normalizedIntensity / 5);\n            }\n        } else {\n            // Default behavior - adjust saturation as it's the most visually apparent\n            filter.saturation = -1 + (normalizedIntensity / 5);\n        }\n    };\n\n    // Set initial intensity\n    updateIntensity(config.intensity);\n\n    /**\n     * Reset the filter to default state\n     */\n    const reset = (): void => {\n        // Reset to configured values or defaults if not specified\n        filter.alpha = config.alpha !== undefined ? config.alpha : 1;\n        filter.colorize = config.colorize !== undefined ? config.colorize : false;\n        filter.hue = config.hue !== undefined ? config.hue : 0;\n        filter.lightness = config.lightness !== undefined ? config.lightness : 0;\n        filter.saturation = config.saturation !== undefined ? config.saturation : 0;\n\n        // If intensity was provided in config, apply it\n        if (config.intensity !== undefined) {\n            updateIntensity(config.intensity);\n        }\n    };\n\n    /**\n     * Release any WebGL resources used by this filter\n     */\n    const dispose = (): void => {\n        try {\n            shaderManager.releaseFilter(filter, shaderKey);\n        } catch (error) {\n            console.warn('Error releasing HSL adjustment filter shader:', error);\n        }\n        filter.destroy();\n    };\n\n    return { filter, updateIntensity, reset, dispose };\n}"],"names":["ShaderResourceManager","HslAdjustmentFilter"],"mappings":";;;;;AAcO,SAAS,0BAA0B,MAAiD,EAAA;AAEvF,EAAM,MAAA,aAAA,GAAgBA,4CAAsB,WAAY,EAAA;AAGxD,EAAA,MAAM,UAAe,EAAC;AAGtB,EAAA,IAAI,MAAO,CAAA,KAAA,KAAU,MAAW,EAAA,OAAA,CAAQ,QAAQ,MAAO,CAAA,KAAA;AACvD,EAAA,IAAI,MAAO,CAAA,QAAA,KAAa,MAAW,E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