<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <!-- Call this template instead of "web.assets_tests" to have the proper conditional check -->
    <template id="conditional_assets_tests" name="Tests Assets Bundle">
        <t t-if="'tests' in debug or test_mode_enabled">
            <t t-if="ignore_missing_deps">
                <!-- FIXME: This is only to ignore the errors for the lazy loading. To allow all tests assets and tours to be in the same bundle, the assets_tests bundle ignores missing dependencies -->
                <t t-call-assets="web.__assets_tests_call__" defer_load="True" />
            </t>
            <t t-else="">
                <t t-call-assets="web.assets_tests" defer_load="True" />
            </t>
        </t>
    </template>

    <template id="web.layout" name="Web layout">&lt;!DOCTYPE html&gt;
<html t-att="html_data or {}">
    <head>
        <meta charset="utf-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
        <title t-out="title or 'Odoo'"/>
        <link type="image/x-icon" rel="shortcut icon" t-att-href="x_icon or '/web/static/img/favicon.ico'"/>
        <script id="web.layout.odooscript" type="text/javascript">
            var odoo = {
                csrf_token: "<t t-out="request.csrf_token(None)"/>",
                debug: "<t t-out="debug"/>",
            };
        </script>
        <t t-out="head"/>
    </head>
    <body t-att-class="body_classname">
        <t t-out="0"/>
    </body>
</html>
    </template>

    <template id="web.frontend_layout" name="Frontend Layout" inherit_id="web.layout" primary="True">
      <xpath expr="//head/meta[last()]" position="after">
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
      </xpath>
      <xpath expr="//head/link[last()]" position="after">
        <t t-call-assets="web.fontawesome" t-binary="True"/>
        <t t-call-assets="web.odoo_ui_icons" t-binary="True"/>
        <t t-call-assets="web.assets_frontend" t-js="false"/>
      </xpath>
      <xpath expr="//head/script[@id='web.layout.odooscript']" position="after">
        <script type="text/javascript">
            odoo.__session_info__ = <t t-out="json.dumps(env['ir.http'].get_frontend_session_info())"/>;
            if (!/(^|;\s)tz=/.test(document.cookie)) {
                const userTZ = Intl.DateTimeFormat().resolvedOptions().timeZone;
                document.cookie = `tz=${userTZ}; path=/`;
            }
        </script>
        <t t-call-assets="web.assets_frontend_minimal" t-css="false" defer_load="True"/>
        <t t-call="web.conditional_assets_tests" ignore_missing_deps="True"/>
        <t t-call-assets="web.assets_frontend_lazy" t-css="false" lazy_load="True"/>
      </xpath>
        <xpath expr="//t[@t-out='0']" position="replace">
            <div id="wrapwrap" t-attf-class="#{pageName or ''}">
                <header t-if="not no_header" id="top" data-anchor="true">
                    <img class="img-responsive d-block mx-auto"
                        t-attf-src="/web/binary/company_logo"
                        alt="Logo"/>
                </header>
                <main>
                    <t t-out="0"/>
                </main>
                <footer t-if="not no_footer" id="bottom" data-anchor="true" t-attf-class="bg-light o_footer">
                    <div id="footer"/>
                    <div t-if="not no_copyright" class="o_footer_copyright">
                        <div class="container py-3">
                            <div class="row row-gap-2">
                                <div class="col-md text-center text-sm-start text-muted">
                                    <span class="o_footer_copyright_name me-2">Copyright &amp;copy; <span t-field="res_company.name" itemprop="name">Company name</span></span>
                                </div>
                                <div class="col-md text-center text-sm-end">
                                    <t t-call="web.brand_promotion"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </footer>
            </div>
        </xpath>
    </template>

    <template id="brand_promotion_message" name="Brand Promotion Message">
        <t t-set="odoo_logo">
            <strong>
                <a target="_blank"
                    t-attf-href="http://www.odoo.com?utm_source=db&amp;utm_medium=#{_utm_medium}">
                    Odoo
                </a>
            </strong>
        </t>
        <t t-set="final_message">Powered by %s%s</t>
        <t t-out="final_message % (odoo_logo, _message and ('- ' + _message) or '')"/>
    </template>
    <template id="brand_promotion" name="Brand Promotion">
        <div class="o_brand_promotion">
            <t t-call="web.brand_promotion_message" _message.translate="" _utm_medium.f="portal"/>
        </div>
    </template>

    <template id="web.login_layout" name="Login Layout">
        <t t-call="web.frontend_layout"
            html_data="{'style': 'height: 100%;'}"
            body_classname.f="bg-100"
            no_header="True"
            no_footer="True">

            <div class="container py-5">
                <div t-attf-class="card border-0 mx-auto bg-100 {{login_card_classes}} o_database_list" style="max-width: 300px;">
                    <div class="card-body">
                        <div class="text-center pb-3 border-bottom mb-4">
                            <img t-attf-src="/web/binary/company_logo{{ '?dbname='+db if db else '' }}" alt="Logo" style="max-height:120px; max-width: 100%; width:auto"/>
                        </div>
                        <t t-out="0"/>
                        <div class="text-center small mt-4 pt-3 border-top" t-if="not disable_footer">
                            <t t-if="not disable_database_manager">
                                <a class="border-end pe-2 me-1" href="/web/database/manager">Manage Databases</a>
                            </t>
                            <a href="https://www.odoo.com?utm_source=db&amp;utm_medium=auth" target="_blank">Powered by <span>Odoo</span></a>
                        </div>
                    </div>
                </div>
            </div>
        </t>
    </template>

    <template id="web.login" name="Login">
        <t t-call="web.login_layout">
            <h1 class="visually-hidden">Login</h1>
            <div class="oe_structure" id="oe_structure_login_top"/>
            <owl-component t-if="not login" name="web.user_switch" />
            <form t-attf-class="oe_login_form #{'' if login else 'd-none'}" role="form" t-attf-action="/web/login" method="post" onsubmit="this.action = '/web/login' + location.hash" data-captcha="login">
                <input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>

                <div class="mb-3" t-if="databases and len(databases) &gt; 1">
                    <label for="db" class="col-form-label">Database</label>
                    <div class="input-group">
                        <input type="text" name="db" t-att-value="request.db" id="db" class="form-control" required="required" readonly="readonly"/>
                        <a role="button" href="/web/database/selector" class="btn border border-start-0">Select <i class="fa fa-database" role="img" aria-label="Database" title="Database"></i></a>
                    </div>
                </div>

                <div class="mb-3 field-login">
                    <label for="login" class="form-label d-flex justify-content-between">Email</label>
                    <input type="text" placeholder="Enter your email" name="login" t-att-value="login" id="login" class="form-control" required="required" autocapitalize="off" autocomplete="username"/>
                </div>

                <div class="o_caps_lock_warning">
                    <div class="d-flex justify-content-between align-items-start">
                        <label for="password" class="form-label">Password</label>
                    </div>
                    <div class="input-group mb-1">
                        <input type="password" placeholder="Enter your password" name="password" id="password" class="form-control" required="required" autocomplete="current-password" t-att-autofocus="'autofocus' if login else None" maxlength="4096"/>
                        <button type="button" class="btn btn-sm border border-start-0 o_show_password">
                            <i class="fa fa-eye"/>
                        </button>
                    </div>
                </div>

                <p class="alert alert-danger" t-if="error" role="alert">
                    <t t-out="error"/>
                </p>
                <p class="alert alert-success" t-if="message" role="status">
                    <t t-out="message"/>
                </p>

                <div class="oe_login_buttons text-center d-grid mb-1 pt-3">
                    <button type="submit" class="btn btn-primary">Log in</button>
                    <t t-if="debug">
                        <button type="submit" name="redirect" value="/web/become" class="btn btn-link btn-sm">Log in as superuser</button>
                    </t>
                    <t t-call="web.login_oauth"/>
                </div>

                <input type="hidden" name="type" value="password"/>
                <input type="hidden" name="redirect" t-att-value="redirect"/>
            </form>
            <div class="oe_structure" id="oe_structure_login_bottom"/>
        </t>
    </template>

    <template id="web.login_successful" name="Login successful">
        <t t-call="web.login_layout">
            <div class="oe_login_form">
                <p>
                    You are logged in.
                </p>
                <div t-attf-class="clearfix oe_login_buttons text-center mb-1 pt-3">
                    <form method="POST" action="/web/session/logout" class="text-center">
                        <input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
                        <button type="submit" class="btn btn-primary">
                            Logout
                        </button>
                    </form>
                </div>
            </div>
        </t>
    </template>

    <template id="web.login_oauth" name="Login OAuth">
        <!-- Use auth_btns to insert login options displayed under the
        login form -->
        <t t-set="auth_btns" t-value="[]"/>
        <div t-if="auth_btns" class="o_login_auth">
            <em class="d-block my-3 small text-center text-muted">- or -</em>
            <div class="list-group">
                <a t-foreach="auth_btns" t-as="p" t-attf-class="{{p.get('list_item_class')}} list-group-item list-group-item-action d-flex align-items-center gap-2 py-2" t-att-href="p.get('auth_link') or '#'">
                    <i t-att-class="p['css_class']" role="presentation"/>
                    <span class="mx-auto" t-out="p['body']"/>
                </a>
            </div>
        </div>
    </template>

    <template id="web.check_identity" name="Check Identity">
        <t t-call="web.login_layout">
            <div class="oe_check_identity_form">
                <div class="text-center">
                    <img t-attf-src="/logo.png?company={{ env.company.id }}" style="padding: 0px; margin: 0px; height: auto; height: 48px;" t-att-alt="env.company.name"/>
                    <h3>Confirm access</h3>
                </div>
                <owl-component name="web.check_identity_form" t-att-props="json.dumps({'redirect': redirect})"/>
            </div>
        </t>
    </template>

    <template id="web.test_helpers">
        <t t-call-assets="web.tests_assets" t-js="False"/>
        <style>
            body {
                position: relative; /* bootstrap-datepicker needs this */
            }
            body:not(.debug) .modal-backdrop, body:not(.debug) .modal:not(.o_module_error), body:not(.debug) .ui-autocomplete {
                opacity: 0 !important;
            }
            #qunit-testrunner-toolbar label {
                font-weight: inherit;
                margin-bottom: inherit;
            }
            #qunit-testrunner-toolbar input[type=text] {
                width: inherit;
                display: inherit;
            }
        </style>
        <t t-call-assets="web.tests_assets" t-css="False"/>
    </template>

    <template id="web.unit_tests_suite">
        <t t-set="head">
            <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>

            <script type="text/javascript">
                odoo.__session_info__ = <t t-out="json.dumps(session_info)"/>;
            </script>

            <t t-call-assets="web.assets_unit_tests_setup" />
            <t t-call-assets="web.assets_unit_tests" defer_load="True" />
        </t>
        <t t-call="web.layout"
            html_data="{'style': 'height: 100%;'}"
            title.translate="Web Unit Tests"
            head="head"/>
    </template>

    <template id="web.qunit_suite">
        <t t-set="head">
            <script type="text/javascript">
                odoo.__session_info__ = <t t-out="json.dumps(session_info)"/>;
            </script>

            <t t-call="web.test_helpers"/>

            <t t-call-assets="web.qunit_suite_tests" t-js="false"/>
            <t t-call-assets="web.qunit_suite_tests" t-css="false"/>
        </t>
        <t t-call="web.layout"
            html_data="{'style': 'height: 100%;'}"
            title.translate="Web Tests"
            head="head">
            <div id="qunit"/>
            <div id="qunit-fixture"/>
        </t>
    </template>

    <template id="web.webclient_bootstrap">
        <t t-set="head">
            <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
            <meta name="theme-color" content="#71639e"/>
            <link rel="manifest" href="/web/manifest.webmanifest" crossorigin="use-credentials"/>
            <link rel="apple-touch-icon" href="/web/static/img/odoo-icon-ios.png"/>
            <script type="text/javascript">
                // Block to avoid leaking variables in the script scope
                {
                    odoo.__session_info__ = <t t-out="json.dumps(session_info)"/>;
                    const { user_context } = odoo.__session_info__;
                    const lang = new URLSearchParams(document.location.search).get("lang");
                    let menuURL = "/web/webclient/load_menus";
                    if (lang) {
                        user_context.lang = lang;
                        menuURL += `&amp;lang=${lang}`;
                    }
                    odoo.reloadMenus = () =&gt; fetch(menuURL, { cache: "no-store" }).then(res =&gt; res.json());
                    odoo.loadMenusPromise = odoo.reloadMenus();
                }
            </script>
            <t t-call-assets="web.assets_web_print" media="print" t-js="false"/>
            <t t-call-assets="web.assets_web" t-css="false"/>

            <t t-if="color_scheme == 'dark'">
                <t t-call-assets="web.assets_web_dark" media="screen" t-js="false"/>
            </t>
            <t t-else="">
                <t t-call-assets="web.assets_web" media="screen" t-js="false"/>
            </t>
            <t t-call="web.conditional_assets_tests"/>
            <t t-out="head"/>
        </t>
        <t t-call="web.layout"
            head="head"
            body_classname.f="o_web_client"/>
    </template>

    <template id="webclient_offline">
        <t t-set="head">
            <script type="text/javascript">
                document.addEventListener("DOMContentLoaded", () =&gt; {
                    const cookies = document.cookie.split(';').map(c =&gt; c.trim());
                    if (cookies.includes('color_scheme=dark')) {
                        document.body.style.backgroundColor = "#262A36";
                        document.body.style.color = "#FFFFFF";
                    }
                });
                window.addEventListener('online', () =&gt; location.reload());
            </script>
            <style>
                body {
                font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Ubuntu, "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
                padding:0;
                margin:0;
                background-color: #fff;
                color: rgb(17, 24, 39);
                display: flex;
                align-items: center;
                justify-content: center;
                text-align: center;
                height: 100vh;
                width: 100vw;
                user-select: none;
                }
                .card {
                width: 80%;
                }
                .card img {
                width: 96px;
                height: auto;
                filter: grayscale(.6);
                }
                .card button {
                background-color: #714B67;
                color: #FFFFFF;
                border: 1px solid #714B67;
                border-radius: .25rem;
                padding: .5rem 1rem;
                cursor: pointer;
                font-size: 1.2rem;
                font-weight: 500;
                }
            </style>
            <meta name="viewport" content="width=device-width, initial-scale=1"/>
        </t>
        <t t-call="web.layout"
            html_data="{'style': 'height: 100%;'}"
            title.translate="Offline"
            head="head">
            <div class="card">
                <img t-attf-src="data:image/png;base64,{{odoo_icon}}" alt="Odoo logo"/>
                <h1>You are offline</h1>
                <p>Check your network connection and come back here. Odoo will load as soon as you're back online.</p>
                <button onclick="location.reload()">Check again</button>
            </div>
        </t>
    </template>

    <template id="webclient_scoped_app">
        <t t-set="x_icon" t-value="'/scoped_app_icon_png?app_id=%s' % (app_id)" />
        <t t-set="head">
            <t t-call-assets="web.assets_frontend_minimal"/>
            <t t-call-assets="web.assets_frontend_lazy"/>
            <link rel="apple-touch-icon" t-att-href="x_icon"/>
            <link rel="manifest" t-att-href="safe_manifest_url" crossorigin="use-credentials" />
            <meta name="viewport" content="width=device-width, initial-scale=1"/>
        </t>
        <t t-call="web.layout"
            html_data="{'style': 'height: 100%;'}"
            title="'Install %s' % (app_name)"
            x_icon="x_icon"
            head="head">
            <owl-component name="web.install_scoped_app" />
        </t>
    </template>
</odoo>
