"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const icons_1 = require("@gravity-ui/icons");
const uikit_1 = require("@gravity-ui/uikit");
const iframeContext_1 = require("../../context/iframeContext/index.js");
const useMainEditorStore_1 = require("../../hooks/useMainEditorStore.js");
const cn_1 = require("../../utils/cn.js");
const b = (0, cn_1.editorCn)('source');
const Source = () => {
    const { resetInitialize } = (0, useMainEditorStore_1.useMainEditorStore)();
    const { disableUrlField, url, setUrl } = React.useContext(iframeContext_1.IframeContext);
    const onUpdateUrl = React.useCallback((value) => {
        setUrl(value);
        resetInitialize();
    }, [resetInitialize, setUrl]);
    const reloadIframe = () => {
        setUrl('');
        setTimeout(() => {
            setUrl(url);
        }, 0);
    };
    return ((0, jsx_runtime_1.jsxs)("div", { className: b(), children: [(0, jsx_runtime_1.jsx)(uikit_1.Button, { className: b('icon'), view: "flat", size: "m", onClick: reloadIframe, children: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.ArrowRotateRight, size: 18 }) }), (0, jsx_runtime_1.jsx)(uikit_1.TextInput, { disabled: disableUrlField, className: b('text'), size: "m", value: url, onUpdate: onUpdateUrl })] }));
};
exports.default = Source;
//# sourceMappingURL=Source.js.map
