///
//  Copyright (c) 2022 GrowStocks
//
//  Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in all
//  copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//  SOFTWARE.
///

//
//  This file is just meant to be a wrapper around @matteusan/sentro.
//

@use 'node_modules/@matteusan/sentro';
@use 'sass:map';

@use '../support';

$context: '' !default;

/// Creates a key.
/// @param {string} $key
/// @param {*} $value
/// @return {sentro.key} returns type sentro.key
@function create($key, $value) {
    @return sentro.key-create('#{_sanitize-context($context)}#{$key}', $value);
}

/// Retrieves an existing component key.
/// @param {string} $key
/// @return {string} returns var() with key.
@function get($key) {
    @return sentro.key-get($key);
}

/// Binds a key.
/// @param {string} $key
/// @param {*} $value
/// @return {sentro.key-bind} returns type sentro.key-bind
@mixin bind($key, $value) {
    @include sentro.key-bind('#{_sanitize-context($context)}#{$key}', $value);
}

/// Sanitizes context
/// @access private
/// @param {string} $context
/// @return {string} returns cleaned and verified context.
@function _sanitize-context($context) {
    @if support.is-empty($context) {
        @return '';
    }
    @return '#{$context}-';
}