> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whop.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Treat these docs and the Whop MCP server as the source of truth for Whop API behavior. Don't infer endpoint behavior from marketing pages.
> MCP server: connect https://mcp.whop.com/mcp (streamable HTTP, browser sign-in, no API key in the client config) to search these docs and read or change live Whop data. Setup: https://docs.whop.com/developer/guides/ai_and_mcp.md
> Whop CLI: install with `curl -fsSL https://whop.com/install.sh | sh` to scaffold, run, and deploy Whop apps and websites. It acts on production, not the sandbox. Overview: https://docs.whop.com/cli/overview.md Agent mode: https://docs.whop.com/cli/agent-mode.md
> Hosting: Whop serves a site or app from the build `whop apps deploy` uploads, with rollbacks, secrets, and server logs. Guide: https://docs.whop.com/developer/websites/hosting.md
> Plugins: in Claude Code, run `/plugin marketplace add whopio/plugins`, then `/plugin install whop@whop`. Guide: https://docs.whop.com/developer/guides/plugins/claude-code.md Every agent tool: https://docs.whop.com/developer/ai/overview.md
> Environments: build and test in the sandbox (API `https://sandbox-api.whop.com/api/v1`, keys at https://sandbox.whop.com/dashboard/developer, SDK environment `Sandbox`; no real money). Production (API `https://api.whop.com/api/v1`, keys at https://whop.com/dashboard/developer, SDK environment `Production`, the SDK default) moves real money, so use it only at launch. The two share no accounts, keys, products, or webhooks, and their keys look identical: never mix them. Sandbox guide: https://docs.whop.com/developer/guides/sandbox.md Comparison: https://docs.whop.com/developer/quickstart.md
> API: send `Authorization: Bearer <API_KEY>` from your server only, and pin a dated version with the `Api-Version-Date` header. OpenAPI spec: https://api.whop.com/api/v1/openapi.json
> Which API: build on the Current API, whose pages live under https://docs.whop.com/api-reference/ (start at https://docs.whop.com/api-reference/overview.md). Pages under /api-reference/legacy/ are the Legacy API. Use one only when https://docs.whop.com/api-reference/stability.md lists the resource as Legacy-only.

# ChatElement (Eski)

> Eski ChatElement için referans. Yeni entegrasyonlar için @whop/elements içindeki ChatElement'i kullanın.

## Genel bakış

Bir sohbet arayüzü görüntüleyen bir kullanıcı arayüzü öğesi.

## Kullanım

### Temel kullanım

```typescript theme={null}
// Create the element
const element = session.createElement("chat-element", {
  channelId: "feed_XXXXXXXXXXXXXX",
  onReady: () => {
    console.log("Chat element is ready");
  },
});

// Mount it to a container
element.mount("#chat-container");
```

### Olayları dinleme

```typescript theme={null}
const element = session.createElement("chat-element", {
  channelId: "feed_XXXXXXXXXXXXXX",
});

element.on("ready", () => {
  console.log("Chat element is ready");
});

element.on("profileClick", (ev) => {
  console.log("Profile clicked:", ev.detail.id);
});

element.on("linkClick", (ev) => {
  console.log("Link clicked:", ev.detail.url);
});

element.on("messageSent", (ev) => {
  console.log("Message sent:", ev.detail.id, ev.detail.content, ev.detail.channelId);
});

element.on("messageDeleted", (ev) => {
  console.log("Message deleted:", ev.detail.id);
});

element.on("experienceClick", (ev) => {
  console.log("Experience clicked:", ev.detail.id);
});

element.mount("#chat-container");
```

```typescript theme={null}
const element = session.createElement("chat-element", {
  channelId: "feed_XXXXXXXXXXXXXX",
  onReady: (element) => {
    console.log("Chat element is ready");
  },
});
```

## Olaylar

ChatElement tarafından yayılan olaylar.

Bu olayları `on()` metodunu kullanarak veya seçeneklerde geri çağırma fonksiyonları geçirerek dinleyin.

### `error`

Öğenin başlatılması veya çalışması sırasında bir hata oluştuğunda yayılır.

**Geri çağırma imzası:** (error: `unknown`) => void

### `ready`

Öğe yüklemeyi tamamladığında ve kullanıcı etkileşimine hazır olduğunda yayılır.

**Geri çağırma imzası:** (element: `ChatElement`) => void

### `optionsUpdated`

Öğenin seçenekleri `updateOptions()` aracılığıyla güncellendiğinde yayılır.

**Geri çağırma imzası:** (options: [`ChatElementOptions`](#chatelementoptions)) => void

### `snapshot`

Öğenin dahili durumu değiştiğinde yayılır.

**Geri çağırma imzası:** (snapshot: [`ChatElementSnapshot`](#chatelementsnapshot)) => void

### `profileClick`

Kullanıcı bir profile tıkladığında yayılır.

**Geri çağırma imzası:** (ev: `CustomEvent`\<\{ id: `string`; }>) => void

### `linkClick`

Kullanıcı bir bağlantıya tıkladığında yayılır.

**Geri çağırma imzası:** (ev: `CustomEvent`\<\{ url: `string`; }>) => void

### `messageSent`

Kullanıcı bir mesaj gönderdiğinde yayılır.

**Geri çağırma imzası:** (ev: `CustomEvent`\<\{ id: `string`; content: `string`; channelId: `string`; }>) => void

### `messageDeleted`

Kullanıcı bir mesajı sildiğinde yayılır.

**Geri çağırma imzası:** (ev: `CustomEvent`\<\{ id: `string`; }>) => void

### `experienceClick`

Kullanıcı bir deneyim bahsine tıkladığında yayılır.

**Geri çağırma imzası:** (ev: `CustomEvent`\<\{ id: `string`; }>) => void

### `attachmentClick`

Kullanıcı bir eke tıkladığında yayılır.

**Geri çağırma imzası:** (ev: `CustomEvent`\<\{ messageId: `string`; attachments: `AttachmentClickEventAttachment`\[]; }>) => void

## Metodlar

### `mount(container)`

Öğeyi bir DOM kapsayıcısına yerleştirir.

Kapsayıcı boş bir öğe olmalıdır. Öğe, alt öğe olarak eklenir.
Öğe zaten yerleştirilmişse, bu metod bir uyarı kaydeder ve geri döner.

| Parametre | Tür | Açıklama |
| - | - | - |
| `container` | `HTMLElement` \| `#$\{`string`\}` | Kapsayıcı öğe veya '#' ile başlayan bir CSS seçicisi |

```typescript theme={null}
// Using a selector
element.mount("#my-container");

// Using an element reference
const container = document.getElementById("my-container");
element.mount(container);
```

### `unmount()`

Öğeyi DOM'dan kaldırır ve tüm olay dinleyicilerini temizler.

Kaldırıldıktan sonra öğe örneği yeniden kullanılmamalıdır.
Yeniden yerleştirmeniz gerekirse yeni bir öğe örneği oluşturun.

```typescript theme={null}
// Unmount when done
element.unmount();

// Commonly used in event handlers
element.on("complete", () => {
  element.unmount();
});
```

### `updateOptions(options)`

Oluşturulduktan sonra öğenin yapılandırma seçeneklerini günceller.

Yalnızca sağlanan seçenekler güncellenir; diğer seçenekler değişmeden kalır.
Öğe yeni seçeneklerle yeniden işlenir.

| Parametre | Tür | Açıklama |
| - | - | - |
| `options` | `Partial`\<[`ChatElementOptions`](#chatelementoptions)> | Güncellenecek değerleri içeren kısmi seçenekler nesnesi |

```typescript theme={null}
// Update a single option
element.updateOptions({
  onComplete: (ev) => {
    console.log("New handler!");
  },
});
```

### `getSnapshot()`

Öğenin mevcut durum anlık görüntüsünü alır.

Anlık görüntü, yükleme durumu, form değerleri veya öğeye özgü diğer veriler
gibi öğenin mevcut dahili durumunu içerir.

**Döndürür:** [`ChatElementSnapshot`](#chatelementsnapshot)

```typescript theme={null}
const snapshot = element.getSnapshot();
console.log("Current state:", snapshot.state);

// Or listen for changes
element.on("snapshot", (snapshot) => {
  console.log("State changed:", snapshot);
});
```

## Stil

Bu öğeyi `appearance.classes` ile özelleştirin. Kararlı sınıf adlarının tam listesi ve örnek kod parçacıkları için [stil referansına](https://docs.whop.com/tr/sdk/elements/styling-reference.md) bakın.

## Türler

### ChatElementOptions

ChatElement için yapılandırma seçenekleri.

| Özellik | Tür | Zorunlu | Varsayılan | Açıklama |
| - | - | - | - | - |
| `channelId` | `string` | Evet | - | Bağlanılacak kanalın, DM'in veya destek sohbetinin kimliği. |
| `deeplinkToPostId` | `string \| undefined` | Hayır | - | Derin bağlantı verilecek mesajın kimliği. |
| `disableNavigation` | `boolean \| undefined` | Hayır | false | Bağlantı gezinmesini devre dışı bırakır. Gezinmeyi kendiniz yönetmek için 'linkClick' olayını dinleyin. |
| `emptyState` | `EmptyStateOptions \| undefined` | Hayır | - | Mesaj olmadığında görüntülenen özel boş durum. |
| `style` | `"imessage" \| "discord" \| undefined` | Hayır | 'imessage' | Sohbetin stili. |
| `features` | `{ banUser?: boolean; muteUser?: boolean; previewAttachments?: boolean; mentionExperiences?: boolean; } \| undefined` | Hayır | - | Sohbette hangi özelliklerin kullanılabileceğini yapılandırın. |
| `onReady` | `((element: ChatElement) => void) \| undefined` | Hayır | - | Öğe yüklemeyi tamamladığında ve etkileşime hazır olduğunda tetiklenen geri çağırma. Bu, 'ready' olayını dinlemekle eşdeğerdir. |
| `onEvent` | `((event: ChatElementEvent) => void) \| undefined` | Hayır | - | Bir sohbet öğesi olayı yayıldığında tetiklenen geri çağırma. |

### ChatElementSnapshot

ChatElement'in mevcut durumunu temsil eder.

Mevcut durumu almak için `element.getSnapshot()` kullanın veya değişiklikler için `snapshot` olayını dinleyin.

| Özellik | Tür | Zorunlu | Varsayılan | Açıklama |
| - | - | - | - | - |
| `state` | `"ready" \| "loading"` | Evet | - | Öğenin mevcut yükleme durumu. - '"loading"' - Öğe başlatılıyor - '"ready"' - Öğe tamamen yüklendi ve etkileşime hazır |


## Related topics

- [ChatElement](https://docs.whop.com/tr/elements/latest/chat/chat.md)
- [Sohbet Oturumu Oluşturun](https://docs.whop.com/tr/sdk/elements/chat-session.md)
- [Chat Öğesi](https://docs.whop.com/tr/developer/guides/chat/chat-element.md)
