<%-
# Copyright (C) 2012 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.

-%><!DOCTYPE html>
<html class="scripts-not-loaded" dir="<%= I18n.rtl? ? 'rtl' : 'ltr' %>"   lang=<%= raw I18n.locale.to_json %>>
<head>
  <meta charset="utf-8">
  <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
  <% if Setting.get('disable_lato_extended', false) == 'false' %>
    <%= stylesheet_link_tag(css_url_for('lato_extended')) %>
  <% else %>
    <%= stylesheet_link_tag(css_url_for('lato')) %>
  <% end %>
  <link href="https://fonts.googleapis.com/css2?family=Architects+Daughter&display=swap" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css2?family=Balsamiq+Sans&display=swap" rel="stylesheet">
  <% unless params && (params[:controller]&.starts_with?('login/') || params[:controller]&.starts_with?('oauth'))  # some windows apps need to do the oauth login dance from an ie11 webview %>
    <script>if (navigator.userAgent.match(/(MSIE|Trident\/)/)) location.replace('/ie-is-not-supported.html')</script>
  <% end %>
  <%= render_datadog_rum_js %>
  <%= favicon_link_tag(favicon) %>
  <%= favicon_link_tag(brand_variable('ic-brand-apple-touch-icon'), rel: 'apple-touch-icon', type: nil) %>
  <%= stylesheet_link_tag(active_brand_config_url('css'), media: "all") %>
  <%= yield :head %>
  <%= include_custom_meta_tags %>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="theme-color" content="<%= brand_variable('ic-brand-primary') %>">
  <%= benchmark("include_css_bundles") { include_css_bundles } %>
  <%= include_account_css %>
  <script>
    <%#
      listen for any clicks on links that have href="#" or data-method set and queue them to be fired on dom ready.
      note: the events targeted for a[data-method] elems don't get properly replayed, but
      at least we can gobble them up here to prevent errors.
    %>
    function _earlyClick(e){
      var c = e.target
      while (c && c.ownerDocument) {
        if (c.getAttribute('href') == '#' || c.getAttribute('data-method')) {
          e.preventDefault()
          (_earlyClick.clicks = _earlyClick.clicks || []).push(c)
          break
        }
        c = c.parentNode
      }
    }
    document.addEventListener('click', _earlyClick)
  </script>

  <% js_bundle :navigation_header unless @headers == false %>

  <% js_env(active_context_tab: get_active_tab) %>
  <script>
    INST = <%= benchmark("rendering INST") { raw(inst_env.to_json) } %>;
    ENV = <%= benchmark("rendering ENV") { raw(render_js_env) } %>;
  </script>

  <%= benchmark("include_head_js") { include_head_js } %>
  <% @xhrs_to_prefetch_from_controller&.each do |(args, kwargs)| %>
    <%= prefetch_xhr(*args, **kwargs) %>
  <% end %>
  <% @content_for_head&.each do |string| %>
    <%= string %>
  <% end %>
  <title><%= @page_title || (yield :page_title).presence || t('default_page_title', "Canvas LMS") %></title>
  <%= render partial: 'layouts/google_analytics_snippet' %>

  <% if fullstory_enabled_for_session?(session) %>
    <%= render :partial => "shared/fullstory_snippet" %>
  <% end %>

  <% if @include_recaptcha %>
  <script src="https://www.google.com/recaptcha/api.js?render=explicit&hl=<%= I18n.locale %>" async defer></script>
  <% end %>
</head>
