var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
import { jsx as _jsx } from "react/jsx-runtime";
import { memo, useEffect } from "react";
import { id } from "tsafe/id";
import { symToStr } from "tsafe/symToStr";
import { useIsDarkModeEnabled } from "onyxia-ui/lib";
import { ThemeProvider, useTheme } from "./theme";
export function getStoryFactory(params) {
    var wrappedComponent = params.wrappedComponent, sectionName = params.sectionName, defaultWidth = params.defaultWidth, _a = params.argTypes, argTypes = _a === void 0 ? {} : _a, parameters = params.parameters;
    var title = "".concat(sectionName, "/").concat(symToStr(wrappedComponent));
    var Component = Object.entries(wrappedComponent).map(function (_a) {
        var _b = __read(_a, 2), component = _b[1];
        return component;
    })[0];
    var Template = function (args) {
        var darkMode = args.darkMode;
        var setIsDarkModeEnabled = useIsDarkModeEnabled().setIsDarkModeEnabled;
        useEffect(function () {
            setIsDarkModeEnabled(darkMode);
        }, [darkMode]);
        return (_jsx(ThemeProvider, { children: _jsx(ContentWrapper, { Component: _jsx(Component, __assign({}, args)), width: defaultWidth }) }));
    };
    var getStory = function (props) {
        var out = Template.bind({});
        out.args = __assign({ "darkMode": true }, props);
        return out;
    };
    return {
        "meta": id({
            title: title,
            "component": Component,
            "argTypes": __assign({}, argTypes),
            "parameters": __assign(__assign({}, parameters), { "viewMode": "story", "previewTabs": {
                    "storybook/docs/panel": {
                        "hidden": true,
                    },
                } }),
        }),
        getStory: getStory,
    };
}
var ContentWrapper = (function () {
    var ContentWrapper = memo(function (props) {
        var Component = props.Component, width = props.width;
        var colors = useTheme().colors;
        return (_jsx("div", __assign({ style: {
                "maxWidth": width,
                "backgroundColor": colors.useCases.surfaces.background,
                "overflow": "hidden",
            } }, { children: Component })));
    });
    return { ContentWrapper: ContentWrapper };
})().ContentWrapper;
//# sourceMappingURL=getStory.js.map