> ## 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.

# SearchElement (Eski)

> Eski SearchElement için başvuru. Yeni entegrasyonlarda @whop/elements içindeki arama katmanını kullanın.

## Genel bakış

Kullanıcıların bir kanalda, DM'de veya destek sohbetinde mesaj aramasına olanak tanıyan bir UI öğesi.

## Kullanım

### Temel kullanım

```typescript theme={null}
// Create the element
const element = session.createElement("search-element", {
  onClose: (ev) => {
    console.log("Search element closed");
  },
});

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

### Modal olarak kullanma

```typescript theme={null}
// Show the element in a modal overlay
const modal = session.showSearchModal({
  channelId: "feed_XXXXXXXXXXXXXX",
  onResultClick: (ev) => {
    console.log("Result clicked!", ev.detail.messageId);
    // Element auto-unmounts by default
  },
});
```

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

## Olaylar

SearchElement 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üklenmeyi tamamlayıp kullanıcı etkileşimine hazır olduğunda yayılır.

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

### `optionsUpdated`

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

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

### `snapshot`

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

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

### `close`

Kullanıcı arama öğesini kapattığında yayılır.
Öğenin otomatik olarak kaldırılmasını önlemek için `ev.preventDefault()` çağırın.

**Geri çağırma imzası:** (ev: `CustomEvent`\<`any`>) => void

### `resultClick`

Kullanıcı bir arama sonucuna tıkladığında tetiklenen geri çağırma.
Öğenin otomatik olarak kaldırılmasını önlemek için `ev.preventDefault()` çağırın.

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

## Metotlar

### `mount(container)`

Öğeyi bir DOM kapsayıcısına bağlar.

Kapsayıcı boş bir öğe olmalıdır. Öğe, alt öğe olarak eklenir.
Öğe zaten bağlıysa, bu metot 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.
Tekrar bağlamanız gerekiyorsa 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)`

Öğenin yapılandırma seçeneklerini oluşturulduktan sonra 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`\<[`SearchElementOptions`](#searchelementoptions)> | 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ü, öğenin yükleme durumu, form değerleri veya diğer öğeye özgü
veriler gibi mevcut dahili durumunu içerir.

**Döndürür:** [`SearchElementSnapshot`](#searchelementsnapshot)

```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 verme

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 başvurusuna](https://docs.whop.com/tr/sdk/elements/styling-reference.md) bakın.

## Türler

### SearchElementOptions

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

| Özellik | Tür | Zorunlu | Varsayılan | Açıklama |
| - | - | - | - | - |
| `companyId` | `string \| undefined` | Hayır | - | Mesajların aranacağı hesabın kimliği. |
| `channelId` | `string \| undefined` | Hayır | - | Mesajların aranacağı kanalın, DM'in veya destek sohbetinin kimliği. |
| `onReady` | `((element: SearchElement) => void) \| undefined` | Hayır | - | Öğe yüklenmeyi tamamlayıp etkileşime hazır olduğunda tetiklenen geri çağırma. 'ready' olayını dinlemekle eşdeğerdir. |
| `onClose` | `((ev: CustomEvent) => void) \| undefined` | Hayır | - | Kullanıcı öğeyi kapattığında tetiklenen geri çağırma. Varsayılan olarak öğe kapatıldığında kaldırılır. Bağlı tutmak için 'ev.preventDefault()' çağırın. |
| `onResultClick` | `((ev: CustomEvent<{ messageId: string; channelId: string; }>) => void) \| undefined` | Hayır | - | Kullanıcı bir arama sonucuna tıkladığında tetiklenen geri çağırma. Varsayılan olarak öğe, sonuca tıklandıktan sonra kaldırılır. Bağlı tutmak için 'ev.preventDefault()' çağırın. |

### SearchElementSnapshot

SearchElement'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şimli |


## Related topics

- [SearchElement](https://docs.whop.com/tr/elements/latest/chat/search.md)
- [Sohbet Oturumu Oluşturun](https://docs.whop.com/tr/sdk/elements/chat-session.md)
- [ChatElement (Eski)](https://docs.whop.com/tr/sdk/elements/chat-element.md)
