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

<Meta title='@dxtmisha/en/functional/Classes/GeoRef - Reactive Geographic Manager'/>

# GeoRef Class

A static reactive class for managing global geographic data. It provides centralized access to information such as the current country, language, standard locale, and the first day of the week, ensuring that any changes are reflected across the application.

## Key Features

- **Global Reactivity** — uses a shared reactive state for geographic data.
- **Centralized Management** — single point of truth for country and language settings.
- **Static Access** — methods can be called directly on the class without instantiation.

## Global Usage

Since `GeoRef` is a static class, its methods are called directly without creating an instance. It serves as a single access point for the application's geographic settings.

```typescript
import { GeoRef } from '@dxtmisha/functional'
import { watch } from 'vue'

// 1. Getting a reactive value
const country = GeoRef.getCountry()
console.log('Current country:', country.value)

// 2. Tracking changes
watch(GeoRef.getLanguage(), (lang) => {
  console.log('Language changed to:', lang)
})

// 3. Global location change
GeoRef.set('en-US') 
// All calls to getCountry, getLanguage, etc., will update automatically
```

## State and Data Retrieval

- `get(): Ref<GeoItemFull>` — returns a reactive object containing the full geographical information.
- `getCountry(): ComputedRef<string>` — current country code (e.g., `'US'`).
- `getLanguage(): ComputedRef<string>` — current language code (e.g., `'en'`).
- `getStandard(): ComputedRef<string>` — full standard locale format (e.g., `'en-US'`).
- `getFirstDay(): ComputedRef<string>` — first day of the week (e.g., `'monday'`).

## Actions

### `set`
Changes the global geographic data based on the provided code. This action instantly updates all reactive dependencies of `GeoRef` across the entire application.

**Parameters:**
- `code: string` — country code, full form language-country (e.g., "en-US"), or one of them.

**Returns:** `void`

## Types

### GeoItemFull
Object structure with full geographical information.

- `country: string` — current country code.
- `language: string` — current language code.
- `standard: string` — standard locale code.
- `firstDay: string` — first day of the week.
- `countryAlternative?: string[]` — list of alternative country codes.
- `languageAlternative?: string[]` — list of alternative language codes.
- `zone?: string | null` — current timezone.
- `phoneCode?: string` — phone country code.
- `phoneMask?: string | string[]` — typical phone number mask.
