"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var visible_width_of_exports = {};
__export(visible_width_of_exports, {
  visibleWidthOf: () => visibleWidthOf
});
module.exports = __toCommonJS(visible_width_of_exports);
/**
 * @license
 * Copyright 2022-2026 Greg Lauckhart <greg@lauckhart.com>
 * SPDX-License-Identifier: Apache-2.0
 */
function visibleWidthOf(str) {
  let width = 0;
  for (let i = 0; i < str.length; i++) {
    const charCode = str.charCodeAt(i);
    if (charCode === 27 && str.charCodeAt(i + 1) === 91) {
      i += 2;
      while (i < str.length) {
        const ch = str.charCodeAt(i);
        if (ch >= 32 && ch <= 63) {
          i++;
        } else {
          break;
        }
      }
      continue;
    }
    switch (charCode) {
      case 8203:
      // zwsp
      case 8204:
      // zero width non-joiner
      case 8205:
      // zero width joiner
      case 8288:
      // word joiner
      case 65279:
        continue;
    }
    width++;
    if (charCode >= 55296 && charCode < 56320) {
      const charCode2 = str.charCodeAt(i + 1);
      if (charCode2 !== void 0 && charCode2 >= 56320 && charCode2 < 57344) {
        i++;
      }
    }
  }
  return width;
}
//# sourceMappingURL=visible-width-of.js.map
