import {Meta} from '@storybook/addon-docs/blocks'

<Meta title='@dxtmisha/en/functional-basic/# Geo and Formatting'/>

# Geo and Formatting

Tools for managing localization (i18n), geographic data, and smart formatting. The system automatically detects user settings and ensures correct display of currencies, dates, and numbers according to government standards.

## Localization (Geo)
Manage global state for country, language, and timezone. Supports browser auto-detection and session persistence.

```javascript
import { Geo } from '@dxtmisha/functional-basic'

// Global Settings
Geo.set('en-US', true)      // Set locale and persist in browser
Geo.setTimezone('-05:00')   // Override timezone offset
Geo.getCountry()            // 'US'

// Reference data
const list = Geo.getList()  // Full list of countries and languages
const current = Geo.getItem() // Current locale data object
const hasFR = Geo.hasCountry('FR') // Check if country is supported
```

## Formatting (GeoIntl)
A universal engine for data formatting built on native `Intl`.

```javascript
import { GeoIntl } from '@dxtmisha/functional-basic'

const intl = GeoIntl.getInstance()

// Numbers & Currencies
intl.currency(1000, 'USD')          // '$1,000.00'
intl.percent(0.15)                  // '15%'

// Dates & Time
intl.date(new Date(), 'full')       // Full long-form date
intl.relative(new Date() - 3600000) // '1 hour ago'
intl.relativeLimit(pastDate, 7)     // Relative (up to 7 days) or absolute date

// Utilities
intl.plural(5, 'apple|apples')      // Pluralization
intl.sizeFile(1024 * 1024)          // '1 MB'
intl.sort(['apple', 'Zebra', 'banana']) // Locale-aware smart sorting
intl.displayNames('DE', 'region')   // 'Germany' (localized)
```

## Country Flags (GeoFlag)
Retrieve flag icons and country names in native or system language.

```javascript
import { GeoFlag } from '@dxtmisha/functional-basic'

const geoFlag = new GeoFlag('en-US')

// Specific country data
const ru = geoFlag.get('RU') // { icon: 'f-ru', country: 'Russia', area: '7', ... }

// List names in their native language
const native = geoFlag.getNational(['DE']) 
// [{ country: 'Germany', nationalCountry: 'Deutschland', ... }]
```

## Phones (GeoPhone)
Auto-detect country by phone number and work with international masks.

```javascript
import { GeoPhone } from '@dxtmisha/functional-basic'

// Smart Detection
const { item, phone } = GeoPhone.getByPhone('14155552671') 
// item — country data (US), phone — cleaned number

// Formatting
GeoPhone.toMask(phone, item.mask) // '+1 (415) 555-2671'
GeoPhone.clear(' +1 (415) 555-2671 ') // '14155552671' (cleaning)
```

## Lists (Formatters)
Bulk transformation of object arrays. Automatically creates new properties with a `Format` suffix.

```javascript
import { Formatters } from '@dxtmisha/functional-basic'

const options = {
  price: { type: 'currency', options: 'USD' },
  birthday: { type: 'date' },
  'user.name': { type: 'name' }, // Combines firstName/lastName
  count: { type: 'plural', options: 'item|items' },
  status: { 
    transformation: (v) => v === 1 ? 'Ok' : 'Error' 
  }
}

// transformed — copy of data with priceFormat, birthdayFormat, etc.
const transformed = new Formatters(options, data).to()
```
