'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var errors = require('./errors.js');
var api = require('./api.js');
var subscription = require('./subscription.js');

/**
 * Returns the proposed `shippingAddress` applied to the checkout.
 */
function useShippingAddress() {
  const api$1 = api.useApi();
  const extensionTarget = api$1.extension.target;
  if (!('shippingAddress' in api$1)) {
    throw new errors.ExtensionHasNoFieldError('shippingAddress', extensionTarget);
  }
  const shippingAddress = api$1.shippingAddress;
  if (!shippingAddress) {
    throw new errors.ScopeNotGrantedError('Using shipping address requires having shipping address permissions granted to your app.');
  }
  return subscription.useSubscription(shippingAddress);
}

exports.useShippingAddress = useShippingAddress;
