import { p as e, o as r } from "./antd-04a23d13.js";
import { c as o, A as i, a as t, b as s, H as a } from "./materialUtils-79f50233.js";
import { gH as n, cz as p, dW as m, fO as l, gI as c, ft as d, fz as f, fP as g, av as h, cr as j, fr as u, fs as x, fu as b, fJ as v, fK as y, gJ as w, gK as k, fA as C, fS as A, fI as S, gL as T } from "./index-f50c05c4.js";
import _, { useContext as z, useState as H, useMemo as I } from "react";
import { lA as P, lR as $, lS as q, nk as L, nl as M, nm as O } from "./ant-design-icons-b1480d8d.js";
import { d as D } from "./styled-components-1e696d6b.js";
import { b as E } from "./react-router-a1807b5b.js";
import { g as J } from "./enterpriseSelectors-1897ddd8.js";
import "react-dom";
import "./dayjs-844325ae.js";
import "./alasql-0ff6dabf.js";
import "./lodash-f1e42446.js";
import "./crypto-js-d5eac8ba.js";
import "./customerService-f3231f11.js";
import "./redux-saga-5514e228.js";
import "./folderSelector-82f1bcf3.js";
import "./loglevel-6fb66d22.js";
import "./axios-84bb1c75.js";
import "./redux-devtools-d38e5b33.js";
import "./fontawesome-2445f580.js";
import "./dnd-kit-56a2f36f.js";
import "./numbro-c1edb412.js";
import "./papaparse-1bac8e5f.js";
import "./uuid-82f303b2.js";
import "./supabase-c27c62e3.js";
import "./fetch-a3c8ad94.js";
import "./react-draggable-60f59f09.js";
import "./remark-gfm-f2973785.js";
import "./buffer-d3713d77.js";
import "./rehype-raw-41b6145f.js";
import "./parse5-6476676e.js";
import "./rehype-sanitize-deb53e9a.js";
import "./simplebar-react-e1b123a3.js";
import "./react-best-gradient-color-picker-4dd60dac.js";
import "./ua-parser-js-094f59ba.js";
import "./clsx-469c2c43.js";
import "./codemirror-73d8c217.js";
import "./really-relaxed-json-49b6a70d.js";
import "./immer-c0428a8d.js";
import "./hotkeys-js-0dddb21a.js";
import "./cnchar-5678e6bc.js";
import "./react-documents-eb6de859.js";
import "./sql-formatter-69e8df59.js";
import "./rc-trigger-5125aafe.js";
import "./react-json-view-9403d8a1.js";
import "./qrcode-react-cb73d2b6.js";
import "./katex-a34f0265.js";
import "./ecogis-maps-bb0d63f9.js";
import "./devextreme-2fa5bb9a.js";
const K = process.env.VNPT_APP_URL, R = 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};
`, U = D.a`
    display: flex;
    align-items: center;
`, V = D(A)`
    height: 28px;
    width: 28px;
`, B = D(S)`
    min-width: 60px;
    padding: 0;
    height: 28px;
    margin-right: 4px;
`, N = D(S)`
    min-width: 60px;
    height: 28px;
`, F = D(S)`
    &&& {
        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;
        }
    }
`, G = D(T)`
    margin-right: 4px;

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