text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.encodeLabelhash = encodeLabelhash;
  exports.decodeLabelhash = decodeLabelhash;
  exports.isEncodedLabelhash = isEncodedLabelhash;
  exports.isDecrypted = isDecrypted;
  exports.labelhash = labelhash;
  
  var _ethEnsNamehash = require("eth-ens-namehash");
  
  var sha3 = require('js-sha3').keccak_256;
  
  function encodeLabelhash(hash) {
    if (!hash.startsWith('0x')) {
      throw new Error('Expected label hash to start with 0x');
    }
  
    if (hash.length !== 66) {
      throw new Error('Expected label hash to have a length of 66');
    }
  
    return "[".concat(hash.slice(2), "]");
  }
  
  function decodeLabelhash(hash) {
    if (!(hash.startsWith('[') && hash.endsWith(']'))) {
      throw Error('Expected encoded labelhash to start and end with square brackets');
    }
  
    if (hash.length !== 66) {
      throw Error('Expected encoded labelhash to have a length of 66');
    }
  
    return "".concat(hash.slice(1, -1));
  }
  
  function isEncodedLabelhash(hash) {
    return hash.startsWith('[') && hash.endsWith(']') && hash.length === 66;
  }
  
  function isDecrypted(name) {
    var nameArray = name.split('.');
    var decrypted = nameArray.reduce(function (acc, label) {
      if (acc === false) return false;
      return isEncodedLabelhash(label) ? false : true;
    }, true);
    return decrypted;
  }
  
  function labelhash(unnormalisedLabelOrLabelhash) {
    return isEncodedLabelhash(unnormalisedLabelOrLabelhash) ? '0x' + decodeLabelhash(unnormalisedLabelOrLabelhash) : '0x' + sha3((0, _ethEnsNamehash.normalize)(unnormalisedLabelOrLabelhash));
  }