import { p as e, o as r } from "./antd-97b654da.js";
import { c as i, A as o, a as t, b as s, H as a } from "./materialUtils-a3f26e34.js";
import { gu as n, cz as p, dW as m, fB as l, gv as c, fg as d, fm as f, fC as g, av as h, cr as j, fe as u, ff as x, fh as v, fw as b, fx as y, gw as w, gx as k, fn as C, fF as T, fv as _, gy as A } from "./index-2be62fff.js";
import S, { useContext as z, useState as q, useMemo as M } from "react";
import { lA as $, lR as H, lS as O, nh as P, ni as R, nj as B } from "./ant-design-icons-14ab96af.js";
import { d as D } from "./styled-components-c6abe9a3.js";
import { b as E } from "./react-router-8d1fc2f1.js";
import { g as I } from "./enterpriseSelectors-1897ddd8.js";
import "react-dom";
import "./dayjs-7fc5ce65.js";
import "./alasql-f59e855e.js";
import "./lodash-226cb5b1.js";
import "./crypto-js-8020edb5.js";
import "./customerService-c27e6cd5.js";
import "./redux-saga-1b0a458d.js";
import "./folderSelector-82f1bcf3.js";
import "./loglevel-5e7e37fc.js";
import "./axios-125479b5.js";
import "./redux-devtools-f8b1cd80.js";
import "./fontawesome-89eb6278.js";
import "./dnd-kit-e67c9595.js";
import "./moment-d8baa15a.js";
import "./numbro-48e81844.js";
import "./papaparse-088c0adc.js";
import "./uuid-82f303b2.js";
import "./supabase-2e4a9112.js";
import "./fetch-6a200310.js";
import "./react-draggable-fda4f1cb.js";
import "./remark-gfm-e9b5dec7.js";
import "./buffer-e20f80c8.js";
import "./rehype-raw-41b6145f.js";
import "./parse5-6476676e.js";
import "./rehype-sanitize-deb53e9a.js";
import "./simplebar-react-cab52c82.js";
import "./react-best-gradient-color-picker-812be7ee.js";
import "./ua-parser-js-1d18a3f8.js";
import "./clsx-469c2c43.js";
import "./codemirror-edf161cb.js";
import "./really-relaxed-json-e5391d6a.js";
import "./immer-c0428a8d.js";
import "./hotkeys-js-0dddb21a.js";
import "./cnchar-8c3eaa86.js";
import "./react-documents-ae08f8b5.js";
import "./sql-formatter-69e8df59.js";
import "./rc-trigger-9e54e169.js";
import "./react-json-view-364658b4.js";
import "./qrcode-react-e4f7745b.js";
import "./katex-cda5b990.js";
import "./ecogis-maps-10bb29cf.js";
import "./devextreme-28d23085.js";
import "./exceljs-1678d36b.js";
import "./file-saver-es-c18fae8f.js";
const L = process.env.VNPT_APP_URL, U = D.div`
    font-weight: 500;
    font-size: 14px;
    color: ${(e2) => n(e2.$bgColor) ? "#ffffff" : "#000000"};
    font-style: normal;
    line-height: 24px;
    margin-right: 8px;
    margin-left: 20px;
    max-width: 264px;
    ${p};
`, V = D.a`
    display: flex;
    align-items: center;
`, F = D(T)`
    height: 28px;
    width: 28px;
`, G = D(_)`
    min-width: 60px;
    padding: 0;
    height: 28px;
    margin-right: 4px;
`, J = D(_)`
    min-width: 60px;
    height: 28px;
`, K = D(_)`
    &&& {
        color: #ffffff;
        background: #8b8fa34c;
        border: none;
        height: 28px;
        margin-right: 8px;
        min-width: 60px;
        padding: 0;
        cursor: pointer;

        &:hover {
            background: #666666;
            color: #ffffff;
            border: none;
        }

        &:focus {
            background: #666666;
            color: #ffffff;
            border: none;
        }
    }
`, N = D(A)`
    margin-right: 4px;

    g g {
        fill: #ffffff;
    }
`, W = D(_)`
    min-width: 60px;
    height: 28px;
    margin-right: 24px;
    padding: 0;
`, Q = D.div`
    display: inherit;
    @media screen and (max-width: 500px) {
        > div:nth-of-type(1),
        > button {
            display: none;
        }
    }
`, X = D.img`
    height: 28px;
`;
function Y(r2) {
  const { user: o2 } = r2, t2 = m(l), s2 = m(c), a2 = m(d);
  return t2 ? $(e.Avatar, { shape: "circle", size: 28 }) : $("div", { children: o2.isAnonymous ? s2 ? null : $(G, { buttonType: "primary", onClick: () => {
    var _a;
    a2 ? (_a = window.top) == null ? void 0 : _a.open(`${L}/user/auth/login`) : f.push(g);
  }, children: h("userAuth.login") }) : $(i, { user: o2, profileSide: 28, fontSize: 12 }) });
}
const Z = S.memo(() => {
  var _a, _b, _c, _d, _e;
  const e2 = E(), i2 = z(j), n2 = m(u), p2 = m(x), l2 = m(d), g2 = v(), T2 = m(c), _2 = m(I), [A2, S2] = q(false), D2 = "view_marketplace" === e2.viewMode || l2, L2 = H(O, { children: [$(V, { onClick: () => !l2 && f.push(C), children: ((_a = _2 == null ? void 0 : _2.config_set) == null ? void 0 : _a.logo) ? Boolean(_2 == null ? void 0 : _2.orgId) ? $(X, { src: s((_b = _2 == null ? void 0 : _2.config_set) == null ? void 0 : _b.logo) }) : $(X, { src: (_c = _2 == null ? void 0 : _2.config_set) == null ? void 0 : _c.logo }) : $(F, { branding: true }) }), D2 && $(a, { setEdit: () => {
  }, isViewMarketplaceMode: D2 }), !D2 && $(U, { $bgColor: ((_d = _2 == null ? void 0 : _2.config_set) == null ? void 0 : _d.appHeaderColor) ?? "#2c2c2c", children: p2 && p2.name })] }), G2 = H(Q, { children: [b(n2, p2) && !l2 && $(o, { applicationId: g2, visible: A2, onVisibleChange: (e3) => !e3 && S2(false) }), b(n2, p2) && !l2 && $(K, { onClick: () => S2(true), children: y }), w(n2, p2) && !l2 && H(W, { buttonType: "primary", onClick: () => window.open(k(g2, "edit")), children: [$(N, {}), h("edit")] }), !!T2 && $(J, { style: { marginRight: n2.isAnonymous ? "" : "24px" }, buttonType: "primary", onClick: () => {
    window.open(h("template.cloneUrl") + T2);
  }, children: h("header.clone") }), $(Y, { user: n2 })] }), Z2 = M(() => l2 ? null : H(O, { children: [$(r, { options: [{ value: "mobile", icon: $(P, {}) }, { value: "tablet", icon: $(R, {}) }, { value: "desktop", icon: $(B, {}) }], value: i2.deviceType, onChange: (e3) => {
    i2.setDeviceType(e3);
  } }), "desktop" !== i2.deviceType && $(r, { options: [{ value: "portrait", label: "Portrait" }, { value: "landscape", label: "Landscape" }], value: i2.deviceOrientation, onChange: (e3) => {
    i2.setDeviceOrientation(e3);
  } })] }), [l2, i2.deviceType, i2.deviceOrientation]);
  return $(t, { headerStart: L2, headerMiddle: Z2, headerEnd: G2, style: { backgroundColor: ((_e = _2 == null ? void 0 : _2.config_set) == null ? void 0 : _e.appHeaderColor) || "#0066b3" } });
});
export {
  Y as HeaderProfile,
  Z as PreviewHeader
};
