# frozen_string_literal: true require_relative "emoji/constants" require_relative "emoji/index" module Unicode module Emoji PROPERTY_NAMES = { E: "Emoji", B: "Emoji_Modifier_Base", M: "Emoji_Modifier", C: "Emoji_Component", P: "Emoji_Presentation", X: "Extended_Pictographic", } EMOJI_VARIATION_SELECTOR = 0xFE0F TEXT_VARIATION_SELECTOR = 0xFE0E EMOJI_TAG_BASE_FLAG = 0x1F3F4 CANCEL_TAG = 0xE007F TAGS = [*0xE0020..0xE007E] EMOJI_KEYCAP_SUFFIX = 0x20E3 ZWJ = 0x200D REGIONAL_INDICATORS = [*0x1F1E6..0x1F1FF] EMOJI_CHAR = INDEX[:PROPERTIES].select{ |ord, props| props.include?(:E) }.keys.freeze EMOJI_PRESENTATION = INDEX[:PROPERTIES].select{ |ord, props| props.include?(:P) }.keys.freeze TEXT_PRESENTATION = INDEX[:PROPERTIES].select{ |ord, props| props.include?(:E) && !props.include?(:P) }.keys.freeze EMOJI_COMPONENT = INDEX[:PROPERTIES].select{ |ord, props| props.include?(:C) }.keys.freeze EMOJI_MODIFIER_BASES = INDEX[:PROPERTIES].select{ |ord, props| props.include?(:B) }.keys.freeze EMOJI_MODIFIERS = INDEX[:PROPERTIES].select{ |ord, props| props.include?(:M) }.keys.freeze EXTENDED_PICTOGRAPHIC = INDEX[:PROPERTIES].select{ |ord, props| props.include?(:X) }.keys.freeze EXTENDED_PICTOGRAPHIC_NO_EMOJI= INDEX[:PROPERTIES].select{ |ord, props| props.include?(:X) && !props.include?(:E) }.keys.freeze EMOJI_KEYCAPS = INDEX[:KEYCAPS].freeze VALID_REGION_FLAGS = INDEX[:FLAGS].freeze VALID_SUBDIVISIONS = INDEX[:SD].freeze RECOMMENDED_SUBDIVISION_FLAGS = INDEX[:TAGS].freeze RECOMMENDED_ZWJ_SEQUENCES = INDEX[:ZWJ].freeze LIST = INDEX[:LIST].freeze.each_value(&:freeze) LIST_REMOVED_KEYS = [ "Smileys & People", ] pack = ->(ord){ Regexp.escape(Array(ord).pack("U*")) } join = -> (*strings){ "(?:" + strings.join("|") + ")" } pack_and_join = ->(ords){ join[*ords.map{ |ord| pack[ord] }] } if ENABLE_NATIVE_EMOJI_UNICODE_PROPERTIES emoji_character = "\\p{Emoji}" emoji_modifier = "\\p{Emoji Modifier}" emoji_modifier_base = "\\p{Emoji Modifier Base}" emoji_component = "\\p{Emoji Component}" emoji_presentation = "\\p{Emoji Presentation}" picto = "\\p{Extended Pictographic}" picto_no_emoji = "\\p{Extended Pictographic}(?