////
/// @group tools/assets
////
@use "sass:meta";

/// Image URL
///
/// If a custom image-url handler is defined ($govuk-image-url-function) then
/// it will be called, otherwise a url will be returned with the filename
/// appended to the image path.
///
/// @param {String} Filename for the image to load
/// @return {String} URL for the filename, wrapped in `url()`
/// @access public

@function govuk-image-url($filename) {
  // prettier-ignore
  $custom-function: meta.variable-exists("govuk-image-url-function")
    and $govuk-image-url-function;

  @if meta.type-of($custom-function) == "string" {
    @if meta.function-exists($custom-function) {
      $custom-function: meta.get-function($custom-function);
    } @else {
      $custom-function: null;
    }
  }

  @if $custom-function {
    @return meta.call($custom-function, $filename);
  } @else {
    @return url($govuk-images-path + $filename);
  }
}

/*# sourceMappingURL=_image-url.scss.map */
