<commit_before>/**
 * @module ol/control/OverviewMap
 */
import {inherits} from '../index.js';
import Collection from '../Collection.js';
import PluggableMap from '../PluggableMap.js';
import MapEventType from '../MapEventType.js';
import MapProperty from '../MapProperty.js';
import {getChangeEventType} from '../Object.js';
import ObjectEventType from '../ObjectEventType.js';
import Overlay from '../Overlay.js';
import OverlayPositioning from '../OverlayPositioning.js';
import ViewProperty from '../ViewProperty.js';
import Control from '../control/Control.js';
import {rotate as rotateCoordinate, add as addCoordinate} from '../coordinate.js';
import {CLASS_CONTROL, CLASS_UNSELECTABLE, CLASS_COLLAPSED} from '../css.js';
import {replaceNode} from '../dom.js';
import {listen, listenOnce, unlisten} from '../events.js';
import EventType from '../events/EventType.js';
import {containsExtent, getBottomLeft, getBottomRight, getTopLeft, getTopRight, scaleFromCenter} from '../extent.js';


/**
 * Maximum width and/or height extent ratio that determines when the overview
 * map should be zoomed out.
 * @type {number}
 */
const MAX_RATIO = 0.75;


/**
 * Minimum width and/or height extent ratio that determines when the overview
 * map should be zoomed in.
 * @type {number}
 */
const MIN_RATIO = 0.1;


/**
 * @typedef {Object} Options
 * @property {boolean} [collapsed=true] Whether the control should start collapsed
 * or not (expanded).
 * @property {string|Element} [collapseLabel='«'] Text label to use for the
 * expanded overviewmap button. Instead of text, also an element (e.g. a `span` element) can be used.
 * @property {boolean} [collapsible=true] Whether the control can be collapsed or not.
 * @property {string|Element} [label='»'] Text label to use for the collapsed
 * overviewmap button. Instead of text, also an element (e.g. a `span` element) can be used.
 * @property {Array.<module:ol/layer/Layer~Layer>|module:ol/Collection~Collection.<module:ol/layer/Layer~Layer>} [layers]
 * Layers for the overview map. If not set, then all main map layers are used
 * instead.
 * @property {function(module:ol/MapEvent~MapEvent)} [render] Function called when the control
 * should be re-rendered. This is called in a `requestAnimationFrame` callback.
 * @property {Element|string} [target] Specify a target if you want the control
 * to be rendered outside of the map's viewport.
 * @property {string} [tipLabel='Overview map'] Text label to use for the button tip.
 * @property {module:ol/View~View} [view] Custom view for the overview map. If not provided,
 * a default view with an EPSG:3857 projection will be used.
 */


/**
 * Create a new control with a map acting as an overview map for an other
 * defined map.
 * @constructor
 * @extends {module:ol/control/Control~Control}
 * @param {module:ol/control/OverviewMap~Options=} opt_options OverviewMap options.
 * @api
 */
const OverviewMap = function(opt_options) {

  const options = opt_options ? opt_options : {};

  /**
   * @type {boolean}
   * @private
   */
  this.collapsed_ = options.collapsed !== undefined ? options.collapsed : true;

  /**
   * @private
   * @type {boolean}
   */
  this.collapsible_ = options.collapsible !== undefined ?
    options.collapsible : true;

  if (!this.collapsible_) {
    this.collapsed_ = false;
  }

  const className = options.className !== undefined ? options.className : 'ol-overviewmap';

  const tipLabel = options.tipLabel !== undefined ? options.tipLabel : 'Overview map';

  const collapseLabel = options.collapseLabel !== undefined ? options.collapseLabel : '\u00AB';

  if (typeof collapseLabel === 'string') {
    /**
     * @private
     * @type {Element}
     */
    this.collapseLabel_ = document.createElement('span');
    this.collapseLabel_.textContent = collapseLabel;
  } else {
    this.collapseLabel_ = collapseLabel;
  }

  const label = options.label !== undefined ? options.label : '\u00BB';


  if (typeof label === 'string') {
    /**
     * @private
     * @type {Element}
     */
    this.label_ = document.createElement('span');
    this.label_.textContent = label;
  } else {
    this.label_ = label;
  }

  const activeLabel = (this.collapsible_ && !this.collapsed_) ?
    this.collapseLabel_ : this.label_;
  const button = document.createElement('button');
  button.setAttribute('type', 'button');
  button.title = tipLabel;
  button.appendChild(activeLabel);

  listen(button, EventType.CLICK,
    this.handleClick_, this);

  /**
   * @type {Element}
   * @private
   */
  this.ovmapDiv_ = document.createElement('DIV');
  this.ovmapDiv_.className = 'ol-overviewmap-map';

  /**
   * @type {module:ol/PluggableMap~PluggableMap}
   * @private
   */
  this.ovmap_ = new PluggableMap({
    controls: new Collection(),
    interactions: new Collection(),
    view: options.view
  });
  const ovmap = this.ovmap_;

  if (options.layers) {
    options.layers.forEach(
      /**
       * @param {module:ol/layer/Layer~Layer} layer Layer.
       */
      function(layer) {
        ovmap.addLayer(layer);
      }.bind(this));
  }

  const box = document.createElement('DIV');
  box.className = 'ol-overviewmap-box';
  box.style.boxSizing = 'border-box';

  /**
   * @type {ol.Overlay}
   * @private
   */
  this.boxOverlay_ = new Overlay({
    position: [0, 0],
    positioning: OverlayPositioning.BOTTOM_LEFT,
    element: box
  });
  this.ovmap_.addOverlay(this.boxOverlay_);

  const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
      (this.collapsed_ && this.collapsible_ ? ' ' + CLASS_COLLAPSED : '') +
      (this.collapsible_ ? '' : ' ol-uncollapsible');
  const element = document.createElement('div');
  element.className = cssClasses;
  element.appendChild(this.ovmapDiv_);
  element.appendChild(button);

  Control.call(this, {
    element: element,
    render: options.render || render,
    target: options.target<commit_msg>Module type for ol.Overlay<commit_after>/**
 * @module ol/control/OverviewMap
 */
import {inherits} from '../index.js';
import Collection from '../Collection.js';
import PluggableMap from '../PluggableMap.js';
import MapEventType from '../MapEventType.js';
import MapProperty from '../MapProperty.js';
import {getChangeEventType} from '../Object.js';
import ObjectEventType from '../ObjectEventType.js';
import Overlay from '../Overlay.js';
import OverlayPositioning from '../OverlayPositioning.js';
import ViewProperty from '../ViewProperty.js';
import Control from '../control/Control.js';
import {rotate as rotateCoordinate, add as addCoordinate} from '../coordinate.js';
import {CLASS_CONTROL, CLASS_UNSELECTABLE, CLASS_COLLAPSED} from '../css.js';
import {replaceNode} from '../dom.js';
import {listen, listenOnce, unlisten} from '../events.js';
import EventType from '../events/EventType.js';
import {containsExtent, getBottomLeft, getBottomRight, getTopLeft, getTopRight, scaleFromCenter} from '../extent.js';


/**
 * Maximum width and/or height extent ratio that determines when the overview
 * map should be zoomed out.
 * @type {number}
 */
const MAX_RATIO = 0.75;


/**
 * Minimum width and/or height extent ratio that determines when the overview
 * map should be zoomed in.
 * @type {number}
 */
const MIN_RATIO = 0.1;


/**
 * @typedef {Object} Options
 * @property {boolean} [collapsed=true] Whether the control should start collapsed
 * or not (expanded).
 * @property {string|Element} [collapseLabel='«'] Text label to use for the
 * expanded overviewmap button. Instead of text, also an element (e.g. a `span` element) can be used.
 * @property {boolean} [collapsible=true] Whether the control can be collapsed or not.
 * @property {string|Element} [label='»'] Text label to use for the collapsed
 * overviewmap button. Instead of text, also an element (e.g. a `span` element) can be used.
 * @property {Array.<module:ol/layer/Layer~Layer>|module:ol/Collection~Collection.<module:ol/layer/Layer~Layer>} [layers]
 * Layers for the overview map. If not set, then all main map layers are used
 * instead.
 * @property {function(module:ol/MapEvent~MapEvent)} [render] Function called when the control
 * should be re-rendered. This is called in a `requestAnimationFrame` callback.
 * @property {Element|string} [target] Specify a target if you want the control
 * to be rendered outside of the map's viewport.
 * @property {string} [tipLabel='Overview map'] Text label to use for the button tip.
 * @property {module:ol/View~View} [view] Custom view for the overview map. If not provided,
 * a default view with an EPSG:3857 projection will be used.
 */


/**
 * Create a new control with a map acting as an overview map for an other
 * defined map.
 * @constructor
 * @extends {module:ol/control/Control~Control}
 * @param {module:ol/control/OverviewMap~Options=} opt_options OverviewMap options.
 * @api
 */
const OverviewMap = function(opt_options) {

  const options = opt_options ? opt_options : {};

  /**
   * @type {boolean}
   * @private
   */
  this.collapsed_ = options.collapsed !== undefined ? options.collapsed : true;

  /**
   * @private
   * @type {boolean}
   */
  this.collapsible_ = options.collapsible !== undefined ?
    options.collapsible : true;

  if (!this.collapsible_) {
    this.collapsed_ = false;
  }

  const className = options.className !== undefined ? options.className : 'ol-overviewmap';

  const tipLabel = options.tipLabel !== undefined ? options.tipLabel : 'Overview map';

  const collapseLabel = options.collapseLabel !== undefined ? options.collapseLabel : '\u00AB';

  if (typeof collapseLabel === 'string') {
    /**
     * @private
     * @type {Element}
     */
    this.collapseLabel_ = document.createElement('span');
    this.collapseLabel_.textContent = collapseLabel;
  } else {
    this.collapseLabel_ = collapseLabel;
  }

  const label = options.label !== undefined ? options.label : '\u00BB';


  if (typeof label === 'string') {
    /**
     * @private
     * @type {Element}
     */
    this.label_ = document.createElement('span');
    this.label_.textContent = label;
  } else {
    this.label_ = label;
  }

  const activeLabel = (this.collapsible_ && !this.collapsed_) ?
    this.collapseLabel_ : this.label_;
  const button = document.createElement('button');
  button.setAttribute('type', 'button');
  button.title = tipLabel;
  button.appendChild(activeLabel);

  listen(button, EventType.CLICK,
    this.handleClick_, this);

  /**
   * @type {Element}
   * @private
   */
  this.ovmapDiv_ = document.createElement('DIV');
  this.ovmapDiv_.className = 'ol-overviewmap-map';

  /**
   * @type {module:ol/PluggableMap~PluggableMap}
   * @private
   */
  this.ovmap_ = new PluggableMap({
    controls: new Collection(),
    interactions: new Collection(),
    view: options.view
  });
  const ovmap = this.ovmap_;

  if (options.layers) {
    options.layers.forEach(
      /**
       * @param {module:ol/layer/Layer~Layer} layer Layer.
       */
      function(layer) {
        ovmap.addLayer(layer);
      }.bind(this));
  }

  const box = document.createElement('DIV');
  box.className = 'ol-overviewmap-box';
  box.style.boxSizing = 'border-box';

  /**
   * @type {module:ol/Overlay~Overlay}
   * @private
   */
  this.boxOverlay_ = new Overlay({
    position: [0, 0],
    positioning: OverlayPositioning.BOTTOM_LEFT,
    element: box
  });
  this.ovmap_.addOverlay(this.boxOverlay_);

  const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
      (this.collapsed_ && this.collapsible_ ? ' ' + CLASS_COLLAPSED : '') +
      (this.collapsible_ ? '' : ' ol-uncollapsible');
  const element = document.createElement('div');
  element.className = cssClasses;
  element.appendChild(this.ovmapDiv_);
  element.appendChild(button);

  Control.call(this, {
    element: element,
    render: options.render || render,
    target: options.target
{'fraction_non_alphanumeric': 0.13735244519392917, 'fraction_numerical': 0.002529510961214165, 'mean_word_length': 3.727381426863292, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1855981', 'n_tokens_mistral': 3630, 'n_tokens_neox': 3529, 'n_words': 1000}