tarsk 0.4.21 → 0.4.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/index.js +52 -152
  2. package/dist/public/assets/{account-view-D1kGyryt.js → account-view-pOQZWJfl.js} +1 -1
  3. package/dist/public/assets/{alert-dialog-Bk7neo_n.js → alert-dialog-BeLER45U.js} +1 -1
  4. package/dist/public/assets/{api-DL5XaoTS.js → api-Bagaj1rQ.js} +1 -1
  5. package/dist/public/assets/{browser-tab-BUOT-D_w.js → browser-tab-DmootUHa.js} +1 -1
  6. package/dist/public/assets/chat-input-container-CfXgimBQ.js +1 -0
  7. package/dist/public/assets/context-menu-BlG_bTqN.js +1 -0
  8. package/dist/public/assets/conversation-history-view-DjO711iz.js +1 -0
  9. package/dist/public/assets/{dialogs-config-DmDjliuA.js → dialogs-config-Dwpv4SNp.js} +1 -1
  10. package/dist/public/assets/{diff-view-DXIv51Tn.js → diff-view-B8Grak1p.js} +2 -2
  11. package/dist/public/assets/{explorer-tab-view-tyn_6pBh.js → explorer-tab-view-lFzzjVe8.js} +2 -2
  12. package/dist/public/assets/explorer-tree-CyWyxQvY.js +1 -0
  13. package/dist/public/assets/{explorer-view-Bw3-gTSX.js → explorer-view-DjN4dtgh.js} +1 -1
  14. package/dist/public/assets/{history-view-BOjZoBCb.js → history-view-BvAOaO8q.js} +1 -1
  15. package/dist/public/assets/index-C7dA1l3u.js +50 -0
  16. package/dist/public/assets/onboarding-dialog-DSmKEXk4.js +1 -0
  17. package/dist/public/assets/onboarding-vGz3IczM.js +1 -0
  18. package/dist/public/assets/{page-toolbar-CvreDTwj.js → page-toolbar-CBE5_3E3.js} +1 -1
  19. package/dist/public/assets/{project-settings-view-BJYR_l3u.js → project-settings-view-B13GlkU6.js} +1 -1
  20. package/dist/public/assets/{provider-details-view-B1eTEo0M.js → provider-details-view-BQQKYvR8.js} +1 -1
  21. package/dist/public/assets/providers-sidebar-C2RknYQn.js +1 -0
  22. package/dist/public/assets/react-vendor-CYvpNUsM.js +17 -0
  23. package/dist/public/assets/{resizable-DJ5w1ZWX.js → resizable-C82J5y6K.js} +1 -1
  24. package/dist/public/assets/{run-stop-button-iZHomql0.js → run-stop-button-1ECLRujs.js} +2 -2
  25. package/dist/public/assets/{settings-view-C38jeeqJ.js → settings-view-CxiVTevy.js} +2 -2
  26. package/dist/public/assets/{side-panel-container-BqWSTCOr.js → side-panel-container-B9Dn9qD2.js} +2 -2
  27. package/dist/public/assets/{standard-list-item-CpBjveM0.js → standard-list-item-BJWg4I9s.js} +1 -1
  28. package/dist/public/assets/{store-CAPnOXso.js → store-Cn1lT5YJ.js} +1 -1
  29. package/dist/public/assets/{tab-context-Bmd79Rk0.js → tab-context-COCYkRNN.js} +1 -1
  30. package/dist/public/assets/{tabs-DEmnnGvq.js → tabs-M7nUZf6O.js} +1 -1
  31. package/dist/public/assets/{terminal-panel-r8cb3-tk.js → terminal-panel-Cea0pLdX.js} +2 -2
  32. package/dist/public/assets/{textarea-BjfyGfGR.js → textarea-C5IMo2ya.js} +1 -1
  33. package/dist/public/assets/todos-view-DDVfCfgF.js +1 -0
  34. package/dist/public/assets/{use-toast-C9B1H3P9.js → use-toast-rlEtMnzM.js} +1 -1
  35. package/dist/public/assets/{utils-BG_JNnOl.js → utils-C3gmypZX.js} +1 -1
  36. package/dist/public/index.html +18 -18
  37. package/package.json +1 -1
  38. package/dist/public/assets/chat-input-container-2a99CMGs.js +0 -1
  39. package/dist/public/assets/context-menu-DHHElhQ1.js +0 -1
  40. package/dist/public/assets/conversation-history-view-HVFzgO9e.js +0 -1
  41. package/dist/public/assets/explorer-tree-DOg67ane.js +0 -1
  42. package/dist/public/assets/index-DAw9BEzt.js +0 -50
  43. package/dist/public/assets/onboarding-BgEjTEKs.js +0 -1
  44. package/dist/public/assets/onboarding-dialog-EiVl-ynw.js +0 -1
  45. package/dist/public/assets/providers-sidebar-Df50eL_5.js +0 -1
  46. package/dist/public/assets/react-vendor-CaS5zjF7.js +0 -17
  47. package/dist/public/assets/todos-view-MAb840dD.js +0 -1
package/dist/index.js CHANGED
@@ -17605,111 +17605,19 @@ import { existsSync as existsSync17 } from "fs";
17605
17605
  init_utils();
17606
17606
  import { existsSync as existsSync16, readFileSync as readFileSync5, statSync as statSync4 } from "fs";
17607
17607
  import { isAbsolute as isAbsolute3, normalize as normalize2, resolve as resolve3, join as join27 } from "path";
17608
- import {
17609
- completeSimple,
17610
- getModel as getModel2
17611
- } from "@mariozechner/pi-ai";
17612
- var PROVIDER_NAME_TO_PI2 = {
17613
- anthropic: "anthropic",
17614
- openai: "openai",
17615
- google: "google",
17616
- groq: "groq",
17617
- cerebras: "cerebras",
17618
- xai: "xai",
17619
- openrouter: "openrouter",
17620
- "github copilot": "github-copilot",
17621
- minimax: "minimax",
17622
- "kimi coding plan": "kimi-coding",
17623
- "hugging face": "huggingface",
17624
- codex: "openai-codex",
17625
- mistral: "mistral"
17626
- };
17627
- var DEFAULT_MODEL_MAP = {
17628
- Anthropic: "claude-3-5-sonnet-20241022",
17629
- OpenAI: "gpt-4o-mini",
17630
- OpenRouter: "anthropic/claude-3.5-sonnet",
17631
- Groq: "llama-3.3-70b-versatile",
17632
- DeepSeek: "deepseek-chat"
17633
- };
17634
- function resolveModelForGit(providerName, modelId, apiUrl) {
17635
- const piProvider = PROVIDER_NAME_TO_PI2[providerName.toLowerCase()];
17636
- if (piProvider) {
17637
- try {
17638
- return getModel2(piProvider, modelId);
17639
- } catch {
17640
- }
17641
- }
17642
- if (!apiUrl) throw new Error(`No API URL configured for provider: ${providerName}`);
17643
- const apiType = apiUrl.includes("/anthropic/") || apiUrl.includes("api.anthropic.com") ? "anthropic-messages" : "openai-completions";
17644
- return {
17645
- id: modelId,
17646
- name: modelId,
17647
- api: apiType,
17648
- provider: providerName.toLowerCase(),
17649
- baseUrl: apiUrl,
17650
- reasoning: false,
17651
- input: ["text"],
17652
- cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
17653
- contextWindow: 128e3,
17654
- maxTokens: 16384
17655
- };
17656
- }
17657
- async function getAllProviders() {
17658
- const catalog = await getModelsCatalog();
17659
- if (!catalog) return [];
17660
- return Object.values(catalog);
17661
- }
17662
- async function findProviderByName(name) {
17663
- const providers = await getAllProviders();
17664
- return providers.find((p) => p.name.toLowerCase() === name.toLowerCase()) ?? null;
17665
- }
17666
- async function overlayCatalogApi(prov) {
17667
- return prov;
17668
- }
17669
- async function resolveProviderAndKey(metadataProviderKeys, preferredProvider) {
17670
- if (preferredProvider) {
17671
- const prov = await findProviderByName(preferredProvider);
17672
- if (prov) {
17673
- const envKey = prov.env.length > 0 ? prov.env[0] : void 0;
17674
- const key = envKey && process.env[envKey] ? process.env[envKey] : metadataProviderKeys[prov.name] ?? (() => {
17675
- const foundKey = Object.keys(metadataProviderKeys).find(
17676
- (k) => k.toLowerCase() === prov.name.toLowerCase()
17677
- );
17678
- return foundKey ? metadataProviderKeys[foundKey] : void 0;
17679
- })();
17680
- if (key) return { provider: await overlayCatalogApi(prov), apiKey: key };
17681
- }
17682
- }
17683
- const providerPriority = ["Anthropic", "OpenAI", "OpenRouter", "Groq", "DeepSeek"];
17684
- for (const name of providerPriority) {
17685
- const prov = await findProviderByName(name);
17686
- if (prov && prov.env.length > 0) {
17687
- const envKey = process.env[prov.env[0]];
17688
- if (envKey) return { provider: await overlayCatalogApi(prov), apiKey: envKey };
17689
- }
17690
- }
17691
- for (const name of providerPriority) {
17692
- const prov = await findProviderByName(name);
17693
- if (prov && metadataProviderKeys[prov.name]) {
17694
- return { provider: await overlayCatalogApi(prov), apiKey: metadataProviderKeys[prov.name] };
17695
- }
17696
- }
17697
- const allProviders = await getAllProviders();
17698
- for (const prov of allProviders) {
17699
- if (prov.api && prov.env.length > 0) {
17700
- const envKey = process.env[prov.env[0]];
17701
- if (envKey) return { provider: await overlayCatalogApi(prov), apiKey: envKey };
17702
- const metadataKey = Object.keys(metadataProviderKeys).find(
17703
- (k) => k.toLowerCase() === prov.name.toLowerCase()
17704
- );
17705
- if (metadataKey)
17706
- return {
17707
- provider: await overlayCatalogApi(prov),
17708
- apiKey: metadataProviderKeys[metadataKey]
17709
- };
17710
- }
17608
+ import { completeSimple } from "@mariozechner/pi-ai";
17609
+ async function resolveModelAndKey(provider, modelId, metadataManager) {
17610
+ const providerConfig = await resolveProviderConfig(provider);
17611
+ if (!providerConfig) return null;
17612
+ let apiKey = providerConfig.env && providerConfig.env.length > 0 ? process.env[providerConfig.env[0]] : void 0;
17613
+ if (!apiKey) {
17614
+ const providerKeys = await metadataManager.getProviderKeys();
17615
+ apiKey = providerKeys[providerConfig.id];
17711
17616
  }
17712
- return null;
17617
+ if (!apiKey) return null;
17618
+ const cleanModelId = modelId.replace(`${provider.toLowerCase()}/`, "");
17619
+ const resolvedModel = resolveModel(provider, cleanModelId, providerConfig);
17620
+ return { model: resolvedModel, apiKey };
17713
17621
  }
17714
17622
  async function generatePRInfoWithAI(commitLog, detailedCommits, diff, currentBranch, baseBranch, metadataManager, model, provider) {
17715
17623
  let promptContent;
@@ -17745,29 +17653,21 @@ Generate the response in this exact format:
17745
17653
  TITLE: <title here>
17746
17654
  DESCRIPTION: <description here>`;
17747
17655
  try {
17748
- const providerKeys = await metadataManager.getProviderKeys();
17749
- const resolved = await resolveProviderAndKey(providerKeys, provider);
17656
+ if (!provider || !model) {
17657
+ console.log(`[pr-generation] Missing provider or model`);
17658
+ return { title: "Update", description: "" };
17659
+ }
17660
+ const resolved = await resolveModelAndKey(provider, model, metadataManager);
17750
17661
  if (!resolved) {
17751
- const errorMsg = provider ? `AI provider "${provider}" is specified but no API key is configured. Please add the API key in settings.` : `No AI provider configured. Please configure a provider in settings.`;
17662
+ const errorMsg = `AI provider "${provider}" is specified but no API key is configured. Please add the API key in settings.`;
17752
17663
  console.log(`[pr-generation] ${errorMsg}`);
17753
17664
  return { title: "Update", description: "" };
17754
17665
  }
17755
- let selectedModel = model;
17756
- if (selectedModel) {
17757
- selectedModel = selectedModel.replace(`${resolved.provider.name.toLowerCase()}/`, "");
17758
- } else {
17759
- selectedModel = DEFAULT_MODEL_MAP[resolved.provider.name] || "default";
17760
- }
17761
- const resolvedModel = resolveModelForGit(
17762
- resolved.provider.name,
17763
- selectedModel,
17764
- resolved.provider.api
17765
- );
17766
17666
  console.log(
17767
- `[pr-generation] Using model: ${resolvedModel.name} provider: ${resolved.provider.name}. key: ${resolved.apiKey ? "exists" : "undefined"} prompt length: ${prompt.length}`
17667
+ `[pr-generation] Using model: ${resolved.model.id} provider: ${provider}. key: ${resolved.apiKey ? "exists" : "undefined"} prompt length: ${prompt.length}`
17768
17668
  );
17769
17669
  const response = await completeSimple(
17770
- resolvedModel,
17670
+ resolved.model,
17771
17671
  {
17772
17672
  messages: [{ role: "user", content: prompt, timestamp: Date.now() }]
17773
17673
  },
@@ -17800,30 +17700,24 @@ ${truncatedDiff}
17800
17700
 
17801
17701
  Generate only the commit message, nothing else:`;
17802
17702
  try {
17803
- const providerKeys = await metadataManager.getProviderKeys();
17804
- const resolved = await resolveProviderAndKey(providerKeys, provider);
17805
- if (!resolved) {
17806
- const errorMsg = provider ? `AI provider "${provider}" is specified but no API key is configured. Please add the API key in settings.` : `No AI provider configured. Please configure a provider in settings.`;
17703
+ if (!provider || !model) {
17704
+ const errorMsg = `No provider or model specified for commit message generation.`;
17807
17705
  process.stdout.write(`[generate-commit-message] ${errorMsg}
17808
17706
  `);
17809
17707
  return `AI Error: ${errorMsg}`;
17810
17708
  }
17811
- let selectedModel = model;
17812
- if (selectedModel) {
17813
- selectedModel = selectedModel.replace(`${resolved.provider.name.toLowerCase()}/`, "");
17814
- } else {
17815
- selectedModel = DEFAULT_MODEL_MAP[resolved.provider.name] || "default";
17709
+ const resolved = await resolveModelAndKey(provider, model, metadataManager);
17710
+ if (!resolved) {
17711
+ const errorMsg = `AI provider "${provider}" is specified but no API key is configured. Please add the API key in settings.`;
17712
+ process.stdout.write(`[generate-commit-message] ${errorMsg}
17713
+ `);
17714
+ return `AI Error: ${errorMsg}`;
17816
17715
  }
17817
- const resolvedModel = resolveModelForGit(
17818
- resolved.provider.name,
17819
- selectedModel,
17820
- resolved.provider.api
17821
- );
17822
17716
  console.log(
17823
- `[generate-commit-message] Using model: ${resolvedModel.name} provider: ${resolved.provider.name}. key: ${resolved.apiKey ? "exists" : "undefined"} prompt: ${prompt}`
17717
+ `[generate-commit-message] Using model: ${resolved.model.id} provider: ${provider}. key: ${resolved.apiKey ? "exists" : "undefined"} prompt: ${prompt}`
17824
17718
  );
17825
17719
  const response = await completeSimple(
17826
- resolvedModel,
17720
+ resolved.model,
17827
17721
  {
17828
17722
  messages: [{ role: "user", content: prompt, timestamp: Date.now() }]
17829
17723
  },
@@ -18729,11 +18623,12 @@ async function gitGenerateCommitMessageHandler(c, metadataManager) {
18729
18623
  process.stdout.write("[generate-commit-message] thread path missing\n");
18730
18624
  return c.json({ error: "Thread path not found" }, 404);
18731
18625
  }
18732
- const provider = thread.modelProvider;
18626
+ const body = await c.req.json().catch(() => ({}));
18627
+ const provider = body.provider ?? thread.modelProvider;
18733
18628
  if (!provider) {
18734
- throw new Error("Provider not found in thread metadata and cannot be extracted from model");
18629
+ throw new Error("Provider not found in request or thread metadata");
18735
18630
  }
18736
- const model = thread.model;
18631
+ const model = body.model ?? thread.model;
18737
18632
  const absolutePath = resolveThreadPath(repoPath);
18738
18633
  process.stdout.write(`[generate-commit-message] resolved path: ${absolutePath}
18739
18634
  `);
@@ -18946,19 +18841,20 @@ async function gitGeneratePrInfoHandler(c, metadataManager) {
18946
18841
  console.log(`[pr-generation] Thread path not found for threadId: ${threadId}`);
18947
18842
  return c.json({ error: "Thread path not found" }, 404);
18948
18843
  }
18949
- const provider = thread.modelProvider;
18844
+ const body = await c.req.json().catch(() => ({}));
18845
+ const provider = body.provider ?? thread.modelProvider;
18950
18846
  if (!provider) {
18951
- console.log(`[pr-generation] \u2717 Provider not found in thread metadata`);
18847
+ console.log(`[pr-generation] \u2717 Provider not found in request or thread metadata`);
18952
18848
  return c.json(
18953
18849
  {
18954
18850
  title: "Update",
18955
18851
  description: "",
18956
- error: "Provider not found in thread metadata"
18852
+ error: "Provider not found in request or thread metadata"
18957
18853
  },
18958
18854
  400
18959
18855
  );
18960
18856
  }
18961
- const model = thread.model;
18857
+ const model = body.model ?? thread.model;
18962
18858
  console.log(`[pr-generation] Using provider: ${provider}, model: ${model}`);
18963
18859
  const absolutePath = resolveThreadPath(repoPath);
18964
18860
  console.log(`[pr-generation] Resolved path: ${absolutePath}`);
@@ -20771,17 +20667,21 @@ Return ONLY the title text, nothing else.
20771
20667
 
20772
20668
  Todo description: ${description}`;
20773
20669
  try {
20774
- const providerKeys = await metadataManager.getProviderKeys();
20775
- const resolved = await resolveProviderAndKey(providerKeys);
20670
+ const DEFAULT_MODELS = {
20671
+ anthropic: "claude-3-5-sonnet-20241022",
20672
+ openai: "gpt-4o-mini",
20673
+ openrouter: "anthropic/claude-3.5-sonnet",
20674
+ groq: "llama-3.3-70b-versatile",
20675
+ deepseek: "deepseek-chat"
20676
+ };
20677
+ let resolved = null;
20678
+ for (const [slug, defaultModel] of Object.entries(DEFAULT_MODELS)) {
20679
+ resolved = await resolveModelAndKey(slug, defaultModel, metadataManager);
20680
+ if (resolved) break;
20681
+ }
20776
20682
  if (!resolved) return description.slice(0, 60);
20777
- const selectedModel = DEFAULT_MODEL_MAP[resolved.provider.name] || "default";
20778
- const resolvedModel = resolveModelForGit(
20779
- resolved.provider.name,
20780
- selectedModel,
20781
- resolved.provider.api
20782
- );
20783
20683
  const response = await completeSimple2(
20784
- resolvedModel,
20684
+ resolved.model,
20785
20685
  {
20786
20686
  messages: [{ role: "user", content: prompt, timestamp: Date.now() }]
20787
20687
  },
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$i as t,Cr as n,Gt as r,Pn as i,Wn as a,Z as o,fi as s,la as c,sa as l,zi as u}from"./dialogs-config-DmDjliuA.js";import{t as d}from"./use-toast-C9B1H3P9.js";var f=e(c(),1),p=l(),m=n();function h(e){let t=(0,p.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=a(`animate-pulse rounded-md bg-muted`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,m.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o}function g(){let[e,n]=(0,f.useState)(null),[a,c]=(0,f.useState)(!0);(0,f.useEffect)(()=>{l();let e=()=>{document.visibilityState===`visible`&&l()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);async function l(){c(!0);try{n(await o())}catch(e){d({title:`Error`,description:e instanceof Error?e.message:`Failed to load account info`,variant:`destructive`})}finally{c(!1)}}function p(){r(`https://buy.stripe.com/14AcN6feK0Jjbheb2H3Nm03?client_reference_id=${e?.clientReferenceId??``}`)}function g(){r(`https://buy.stripe.com/9B67sMd6CgIh70Y0o33Nm04?client_reference_id=${e?.clientReferenceId??``}`)}if(a)return(0,m.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,m.jsxs)(`div`,{className:`mb-6`,children:[(0,m.jsx)(h,{className:`h-8 w-32 mb-2`}),(0,m.jsx)(h,{className:`h-4 w-64`})]}),(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`flex gap-4`,children:[(0,m.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,m.jsx)(h,{className:`h-4 w-20`}),(0,m.jsx)(h,{className:`h-9 w-28`})]}),(0,m.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,m.jsx)(h,{className:`h-4 w-24`}),(0,m.jsx)(h,{className:`h-6 w-32`}),(0,m.jsx)(h,{className:`h-4 w-full`})]})]}),(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(h,{className:`h-4 w-24`}),(0,m.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,m.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,m.jsx)(h,{className:`h-5 w-28`}),(0,m.jsx)(h,{className:`h-4 w-64`})]}),(0,m.jsx)(h,{className:`h-9 w-28 shrink-0`})]}),(0,m.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,m.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,m.jsx)(h,{className:`h-5 w-36`}),(0,m.jsx)(h,{className:`h-4 w-56`}),(0,m.jsx)(h,{className:`h-4 w-32`})]}),(0,m.jsx)(h,{className:`h-9 w-24 shrink-0`})]})]})]})]});let _=e?.plan===`unlimited-pro`;return(0,m.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,m.jsxs)(`div`,{className:`mb-6`,children:[(0,m.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Account`}),(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:`Manage your Tarsk plan and prompt balance.`})]}),(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`flex gap-4`,children:[(0,m.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,m.jsx)(s,{className:`h-4 w-4`}),`Balance`]}),(0,m.jsx)(`div`,{className:`flex items-end gap-2`,children:_?(0,m.jsx)(`span`,{className:`text-3xl font-bold`,children:`Unlimited`}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`text-3xl font-bold`,children:e?.promptsRemaining.toLocaleString()??0}),(0,m.jsx)(`span`,{className:`text-muted-foreground mb-1 text-sm`,children:`prompts remaining`})]})})]}),(0,m.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,m.jsx)(u,{className:`h-4 w-4`}),`Current Plan`]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(`span`,{className:`text-lg font-semibold`,children:_?`Unlimited Pro`:`Pay as you go`}),_&&(0,m.jsx)(`span`,{className:`rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:`Active`})]}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:_?`You have unlimited prompts with no restrictions.`:`Purchase prompts as needed. Upgrade to Pro for unlimited access.`})]})]}),!_&&(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wide`,children:`Add Prompts`}),(0,m.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,m.jsxs)(`div`,{className:`space-y-1`,children:[(0,m.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,m.jsx)(`span`,{className:`font-semibold`,children:`1,000 Prompts`})}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Top up your balance with 1,000 additional prompts for $5.`})]}),(0,m.jsx)(i,{onClick:p,className:`shrink-0`,children:`Top Up Balance`})]}),(0,m.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,m.jsxs)(`div`,{className:`space-y-1`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(u,{className:`h-4 w-4 text-primary`}),(0,m.jsx)(`span`,{className:`font-semibold`,children:`Unlimited Pro Plan`})]}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Unlimited prompts for $100 and lifetime access to Tarsk.`}),(0,m.jsxs)(`ul`,{className:`text-sm text-muted-foreground space-y-0.5`,children:[(0,m.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(t,{className:`h-3 w-3 text-primary`}),`Unlimited prompts`]}),(0,m.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(t,{className:`h-3 w-3 text-primary`}),`Priority access`]})]})]}),(0,m.jsx)(i,{onClick:g,className:`shrink-0`,children:`Purchase`})]})]})]})]})}export{g as default};
1
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Bi as t,Cr as n,Gt as r,Pn as i,Wn as a,Z as o,ca as s,ea as c,fi as l,ua as u}from"./dialogs-config-Dwpv4SNp.js";import{t as d}from"./use-toast-rlEtMnzM.js";var f=e(u(),1),p=s(),m=n();function h(e){let t=(0,p.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=a(`animate-pulse rounded-md bg-muted`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,m.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o}function g(){let[e,n]=(0,f.useState)(null),[a,s]=(0,f.useState)(!0);(0,f.useEffect)(()=>{u();let e=()=>{document.visibilityState===`visible`&&u()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);async function u(){s(!0);try{n(await o())}catch(e){d({title:`Error`,description:e instanceof Error?e.message:`Failed to load account info`,variant:`destructive`})}finally{s(!1)}}function p(){r(`https://buy.stripe.com/14AcN6feK0Jjbheb2H3Nm03?client_reference_id=${e?.clientReferenceId??``}`)}function g(){r(`https://buy.stripe.com/9B67sMd6CgIh70Y0o33Nm04?client_reference_id=${e?.clientReferenceId??``}`)}if(a)return(0,m.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,m.jsxs)(`div`,{className:`mb-6`,children:[(0,m.jsx)(h,{className:`h-8 w-32 mb-2`}),(0,m.jsx)(h,{className:`h-4 w-64`})]}),(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`flex gap-4`,children:[(0,m.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,m.jsx)(h,{className:`h-4 w-20`}),(0,m.jsx)(h,{className:`h-9 w-28`})]}),(0,m.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,m.jsx)(h,{className:`h-4 w-24`}),(0,m.jsx)(h,{className:`h-6 w-32`}),(0,m.jsx)(h,{className:`h-4 w-full`})]})]}),(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(h,{className:`h-4 w-24`}),(0,m.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,m.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,m.jsx)(h,{className:`h-5 w-28`}),(0,m.jsx)(h,{className:`h-4 w-64`})]}),(0,m.jsx)(h,{className:`h-9 w-28 shrink-0`})]}),(0,m.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,m.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,m.jsx)(h,{className:`h-5 w-36`}),(0,m.jsx)(h,{className:`h-4 w-56`}),(0,m.jsx)(h,{className:`h-4 w-32`})]}),(0,m.jsx)(h,{className:`h-9 w-24 shrink-0`})]})]})]})]});let _=e?.plan===`unlimited-pro`;return(0,m.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,m.jsxs)(`div`,{className:`mb-6`,children:[(0,m.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Account`}),(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:`Manage your Tarsk plan and prompt balance.`})]}),(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`flex gap-4`,children:[(0,m.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,m.jsx)(l,{className:`h-4 w-4`}),`Balance`]}),(0,m.jsx)(`div`,{className:`flex items-end gap-2`,children:_?(0,m.jsx)(`span`,{className:`text-3xl font-bold`,children:`Unlimited`}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`text-3xl font-bold`,children:e?.promptsRemaining.toLocaleString()??0}),(0,m.jsx)(`span`,{className:`text-muted-foreground mb-1 text-sm`,children:`prompts remaining`})]})})]}),(0,m.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,m.jsx)(t,{className:`h-4 w-4`}),`Current Plan`]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(`span`,{className:`text-lg font-semibold`,children:_?`Unlimited Pro`:`Pay as you go`}),_&&(0,m.jsx)(`span`,{className:`rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:`Active`})]}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:_?`You have unlimited prompts with no restrictions.`:`Purchase prompts as needed. Upgrade to Pro for unlimited access.`})]})]}),!_&&(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wide`,children:`Add Prompts`}),(0,m.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,m.jsxs)(`div`,{className:`space-y-1`,children:[(0,m.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,m.jsx)(`span`,{className:`font-semibold`,children:`1,000 Prompts`})}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Top up your balance with 1,000 additional prompts for $5.`})]}),(0,m.jsx)(i,{onClick:p,className:`shrink-0`,children:`Top Up Balance`})]}),(0,m.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,m.jsxs)(`div`,{className:`space-y-1`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(t,{className:`h-4 w-4 text-primary`}),(0,m.jsx)(`span`,{className:`font-semibold`,children:`Unlimited Pro Plan`})]}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Unlimited prompts for $100 and lifetime access to Tarsk.`}),(0,m.jsxs)(`ul`,{className:`text-sm text-muted-foreground space-y-0.5`,children:[(0,m.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(c,{className:`h-3 w-3 text-primary`}),`Unlimited prompts`]}),(0,m.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(c,{className:`h-3 w-3 text-primary`}),`Priority access`]})]})]}),(0,m.jsx)(i,{onClick:g,className:`shrink-0`,children:`Purchase`})]})]})]})]})}export{g as default};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Fn as n,Wn as r,la as i,sa as a}from"./dialogs-config-DmDjliuA.js";import{at as o,ct as s,it as c,lt as l,ot as u,rt as d,st as f,ut as p}from"./react-vendor-CaS5zjF7.js";var m=a(),h=e(i(),1),g=t(),_=l,v=s,y=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(f,{className:o,...a,ref:t}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});y.displayName=f.displayName;var b=h.forwardRef((e,t)=>{let n=(0,m.c)(10),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let s;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,g.jsx)(y,{}),n[3]=s):s=n[3];let c;n[4]===i?c=n[5]:(c=r(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,i),n[4]=i,n[5]=c);let l;return n[6]!==a||n[7]!==t||n[8]!==c?(l=(0,g.jsxs)(v,{children:[s,(0,g.jsx)(o,{ref:t,className:c,...a})]}),n[6]=a,n[7]=t,n[8]=c,n[9]=l):l=n[9],l});b.displayName=o.displayName;var x=e=>{let t=(0,m.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`flex flex-col space-y-2 text-center sm:text-left`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};x.displayName=`AlertDialogHeader`;var S=e=>{let t=(0,m.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};S.displayName=`AlertDialogFooter`;var C=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`text-lg font-semibold`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(p,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});C.displayName=p.displayName;var w=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`text-sm text-muted-foreground`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(u,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});w.displayName=u.displayName;var T=h.forwardRef((e,t)=>{let i=(0,m.c)(9),a,o;i[0]===e?(a=i[1],o=i[2]):({className:a,...o}=e,i[0]=e,i[1]=a,i[2]=o);let s;i[3]===a?s=i[4]:(s=r(n(),a),i[3]=a,i[4]=s);let c;return i[5]!==o||i[6]!==t||i[7]!==s?(c=(0,g.jsx)(d,{ref:t,className:s,...o}),i[5]=o,i[6]=t,i[7]=s,i[8]=c):c=i[8],c});T.displayName=d.displayName;var E=h.forwardRef((e,t)=>{let i=(0,m.c)(9),a,o;i[0]===e?(a=i[1],o=i[2]):({className:a,...o}=e,i[0]=e,i[1]=a,i[2]=o);let s;i[3]===a?s=i[4]:(s=r(n({variant:`outline`}),`mt-2 sm:mt-0`,a),i[3]=a,i[4]=s);let l;return i[5]!==o||i[6]!==t||i[7]!==s?(l=(0,g.jsx)(c,{ref:t,className:s,...o}),i[5]=o,i[6]=t,i[7]=s,i[8]=l):l=i[8],l});E.displayName=c.displayName;export{w as a,C as c,b as i,T as n,S as o,E as r,x as s,_ as t};
1
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Fn as n,Wn as r,ca as i,ua as a}from"./dialogs-config-Dwpv4SNp.js";import{at as o,ct as s,it as c,lt as l,ot as u,rt as d,st as f,ut as p}from"./react-vendor-CYvpNUsM.js";var m=i(),h=e(a(),1),g=t(),_=l,v=s,y=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(f,{className:o,...a,ref:t}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});y.displayName=f.displayName;var b=h.forwardRef((e,t)=>{let n=(0,m.c)(10),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let s;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,g.jsx)(y,{}),n[3]=s):s=n[3];let c;n[4]===i?c=n[5]:(c=r(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,i),n[4]=i,n[5]=c);let l;return n[6]!==a||n[7]!==t||n[8]!==c?(l=(0,g.jsxs)(v,{children:[s,(0,g.jsx)(o,{ref:t,className:c,...a})]}),n[6]=a,n[7]=t,n[8]=c,n[9]=l):l=n[9],l});b.displayName=o.displayName;var x=e=>{let t=(0,m.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`flex flex-col space-y-2 text-center sm:text-left`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};x.displayName=`AlertDialogHeader`;var S=e=>{let t=(0,m.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};S.displayName=`AlertDialogFooter`;var C=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`text-lg font-semibold`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(p,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});C.displayName=p.displayName;var w=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`text-sm text-muted-foreground`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(u,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});w.displayName=u.displayName;var T=h.forwardRef((e,t)=>{let i=(0,m.c)(9),a,o;i[0]===e?(a=i[1],o=i[2]):({className:a,...o}=e,i[0]=e,i[1]=a,i[2]=o);let s;i[3]===a?s=i[4]:(s=r(n(),a),i[3]=a,i[4]=s);let c;return i[5]!==o||i[6]!==t||i[7]!==s?(c=(0,g.jsx)(d,{ref:t,className:s,...o}),i[5]=o,i[6]=t,i[7]=s,i[8]=c):c=i[8],c});T.displayName=d.displayName;var E=h.forwardRef((e,t)=>{let i=(0,m.c)(9),a,o;i[0]===e?(a=i[1],o=i[2]):({className:a,...o}=e,i[0]=e,i[1]=a,i[2]=o);let s;i[3]===a?s=i[4]:(s=r(n({variant:`outline`}),`mt-2 sm:mt-0`,a),i[3]=a,i[4]=s);let l;return i[5]!==o||i[6]!==t||i[7]!==s?(l=(0,g.jsx)(c,{ref:t,className:s,...o}),i[5]=o,i[6]=t,i[7]=s,i[8]=l):l=i[8],l});E.displayName=c.displayName;export{w as a,C as c,b as i,T as n,S as o,E as r,x as s,_ as t};
@@ -1 +1 @@
1
- import{Cn as e,Dn as t,En as n,On as r,Sn as i,Tn as a,wn as o}from"./dialogs-config-DmDjliuA.js";async function s(t,n){return o(`api/threads/${e(t)}/explorer?path=${encodeURIComponent(n)}`)}async function c(t,n){return o(`api/threads/${e(t)}/ai-file?path=${encodeURIComponent(n)}`)}async function l(t,n,i){return r(`api/threads/${e(t)}/ai-file`,{path:n,content:i})}async function u(t,n){return i(`api/threads/${e(t)}/explorer?path=${encodeURIComponent(n)}`)}async function d(t,r,i){return n(`api/threads/${e(t)}/explorer`,{path:r,newName:i})}async function f(n,r,i){return t(`api/threads/${e(n)}/explorer/file`,{dirPath:r,name:i})}function p(t,n){return`${a()}/api/threads/${e(t)}/explorer/media?path=${encodeURIComponent(n)}`}async function m(n,r,i){return t(`api/threads/${e(n)}/explorer/folder`,{dirPath:r,name:i})}export{p as a,l as c,c as i,m as n,s as o,u as r,d as s,f as t};
1
+ import{Cn as e,Dn as t,En as n,On as r,Sn as i,Tn as a,wn as o}from"./dialogs-config-Dwpv4SNp.js";async function s(t,n){return o(`api/threads/${e(t)}/explorer?path=${encodeURIComponent(n)}`)}async function c(t,n){return o(`api/threads/${e(t)}/ai-file?path=${encodeURIComponent(n)}`)}async function l(t,n,i){return r(`api/threads/${e(t)}/ai-file`,{path:n,content:i})}async function u(t,n){return i(`api/threads/${e(t)}/explorer?path=${encodeURIComponent(n)}`)}async function d(t,r,i){return n(`api/threads/${e(t)}/explorer`,{path:r,newName:i})}async function f(n,r,i){return t(`api/threads/${e(n)}/explorer/file`,{dirPath:r,name:i})}function p(t,n){return`${a()}/api/threads/${e(t)}/explorer/media?path=${encodeURIComponent(n)}`}async function m(n,r,i){return t(`api/threads/${e(n)}/explorer/folder`,{dirPath:r,name:i})}export{p as a,l as c,c as i,m as n,s as o,u as r,d as s,f as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Gt as n,Ii as r,Rr as i,Wr as a,Xr as o,la as s,sa as c,si as l}from"./dialogs-config-DmDjliuA.js";import{a as u}from"./store-CAPnOXso.js";import{n as d}from"./tab-context-Bmd79Rk0.js";import{t as f}from"./run-stop-button-iZHomql0.js";var p=c(),m=e(s(),1),h=t();function g(){let e=(0,p.c)(41),{devServerUrl:t,browserResetTrigger:s}=d(),{state:c}=u(),{selectedProjectId:g,projects:_}=c,v;if(e[0]!==_||e[1]!==g){let t;e[3]===g?t=e[4]:(t=e=>e.projectId===g,e[3]=g,e[4]=t),v=_.find(t),e[0]=_,e[1]=g,e[2]=v}else v=e[2];let y=v,[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(`desktop`),E=(0,m.useRef)(null),D;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>{C(``),x(``),E.current&&(E.current.src=``)},e[5]=D):D=e[5];let O;e[6]===s?O=e[7]:(O=[s],e[6]=s,e[7]=O),(0,m.useEffect)(D,O);let k,A;e[8]===t?(k=e[9],A=e[10]):(k=()=>{t&&(x(t),C(t))},A=[t],e[8]=t,e[9]=k,e[10]=A),(0,m.useEffect)(k,A);let j;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{let t=e.trim();t&&(!t.startsWith(`http://`)&&!t.startsWith(`https://`)&&(t=`http://`+t),x(t),C(t))},e[11]=j):j=e[11];let M=j,N;e[12]===b?N=e[13]:(N=e=>{e.key===`Enter`&&M(b)},e[12]=b,e[13]=N);let P=N,F;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{if(E.current){let e=E.current.src;E.current.src=``,setTimeout(()=>{E.current&&(E.current.src=e)},0)}},e[14]=F):F=e[14];let I=F,L;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(L={desktop:{width:`100%`,height:`100%`},tablet:{width:`768px`,height:`1024px`},mobile:{width:`375px`,height:`667px`}},e[15]=L):L=e[15];let R=L[w],z;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>x(e.target.value),e[16]=z):z=e[16];let B;e[17]!==P||e[18]!==b?(B=(0,h.jsx)(`input`,{type:`text`,value:b,onChange:z,onKeyDown:P,placeholder:`Enter URL...`,className:`flex-1 px-4 py-1.5 text-sm bg-muted rounded-full border border-border outline-none focus:ring-1 focus:ring-ring font-mono`,spellCheck:!1}),e[17]=P,e[18]=b,e[19]=B):B=e[19];let V;e[20]===S?V=e[21]:(V=S&&(0,h.jsx)(`button`,{onClick:I,title:`Refresh page`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(o,{size:15})}),e[20]=S,e[21]=V);let H;e[22]!==w||e[23]!==S?(H=S&&(0,h.jsxs)(`div`,{className:`flex items-center bg-muted rounded-md p-0.5`,children:[(0,h.jsx)(`button`,{onClick:()=>T(`desktop`),title:`Desktop view`,className:`p-1.5 rounded transition-colors ${w===`desktop`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(l,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`tablet`),title:`Tablet view`,className:`p-1.5 rounded transition-colors ${w===`tablet`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(i,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`mobile`),title:`Mobile view`,className:`p-1.5 rounded transition-colors ${w===`mobile`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(a,{size:15})})]}),e[22]=w,e[23]=S,e[24]=H):H=e[24];let U;e[25]===S?U=e[26]:(U=S&&(0,h.jsx)(`button`,{onClick:()=>void n(S),title:`Open in external browser`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(r,{size:15})}),e[25]=S,e[26]=U);let W;e[27]!==B||e[28]!==V||e[29]!==H||e[30]!==U?(W=(0,h.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border shrink-0`,children:[B,V,H,U]}),e[27]=B,e[28]=V,e[29]=H,e[30]=U,e[31]=W):W=e[31];let G;e[32]!==R||e[33]!==w||e[34]!==S||e[35]!==y||e[36]!==g?(G=S?(0,h.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-background`,children:w===`desktop`?(0,h.jsx)(`iframe`,{ref:E,src:S,className:`flex-1 w-full h-full border-none`,title:`Browser`}):(0,h.jsx)(`div`,{className:`bg-white border border-border rounded-lg shadow-lg overflow-hidden transition-all duration-200`,style:{width:R.width,height:R.height,maxWidth:`100%`,maxHeight:`100%`},children:(0,h.jsx)(`iframe`,{ref:E,src:S,className:`w-full h-full border-none`,title:`Browser`})})}):(0,h.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-6 text-muted-foreground`,children:g&&y?.runCommand?(0,h.jsx)(f,{projectId:g,runCommand:y.runCommand,large:!0}):(0,h.jsx)(`p`,{className:`text-sm`,children:`Enter a URL to browse`})}),e[32]=R,e[33]=w,e[34]=S,e[35]=y,e[36]=g,e[37]=G):G=e[37];let K;return e[38]!==W||e[39]!==G?(K=(0,h.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[W,G]}),e[38]=W,e[39]=G,e[40]=K):K=e[40],K}export{g as BrowserTab};
1
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Gt as n,Li as r,Rr as i,Wr as a,Xr as o,ca as s,si as c,ua as l}from"./dialogs-config-Dwpv4SNp.js";import{a as u}from"./store-Cn1lT5YJ.js";import{n as d}from"./tab-context-COCYkRNN.js";import{t as f}from"./run-stop-button-1ECLRujs.js";var p=s(),m=e(l(),1),h=t();function g(){let e=(0,p.c)(41),{devServerUrl:t,browserResetTrigger:s}=d(),{state:l}=u(),{selectedProjectId:g,projects:_}=l,v;if(e[0]!==_||e[1]!==g){let t;e[3]===g?t=e[4]:(t=e=>e.projectId===g,e[3]=g,e[4]=t),v=_.find(t),e[0]=_,e[1]=g,e[2]=v}else v=e[2];let y=v,[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(`desktop`),E=(0,m.useRef)(null),D;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>{C(``),x(``),E.current&&(E.current.src=``)},e[5]=D):D=e[5];let O;e[6]===s?O=e[7]:(O=[s],e[6]=s,e[7]=O),(0,m.useEffect)(D,O);let k,A;e[8]===t?(k=e[9],A=e[10]):(k=()=>{t&&(x(t),C(t))},A=[t],e[8]=t,e[9]=k,e[10]=A),(0,m.useEffect)(k,A);let j;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{let t=e.trim();t&&(!t.startsWith(`http://`)&&!t.startsWith(`https://`)&&(t=`http://`+t),x(t),C(t))},e[11]=j):j=e[11];let M=j,N;e[12]===b?N=e[13]:(N=e=>{e.key===`Enter`&&M(b)},e[12]=b,e[13]=N);let P=N,F;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{if(E.current){let e=E.current.src;E.current.src=``,setTimeout(()=>{E.current&&(E.current.src=e)},0)}},e[14]=F):F=e[14];let I=F,L;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(L={desktop:{width:`100%`,height:`100%`},tablet:{width:`768px`,height:`1024px`},mobile:{width:`375px`,height:`667px`}},e[15]=L):L=e[15];let R=L[w],z;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>x(e.target.value),e[16]=z):z=e[16];let B;e[17]!==P||e[18]!==b?(B=(0,h.jsx)(`input`,{type:`text`,value:b,onChange:z,onKeyDown:P,placeholder:`Enter URL...`,className:`flex-1 px-4 py-1.5 text-sm bg-muted rounded-full border border-border outline-none focus:ring-1 focus:ring-ring font-mono`,spellCheck:!1}),e[17]=P,e[18]=b,e[19]=B):B=e[19];let V;e[20]===S?V=e[21]:(V=S&&(0,h.jsx)(`button`,{onClick:I,title:`Refresh page`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(o,{size:15})}),e[20]=S,e[21]=V);let H;e[22]!==w||e[23]!==S?(H=S&&(0,h.jsxs)(`div`,{className:`flex items-center bg-muted rounded-md p-0.5`,children:[(0,h.jsx)(`button`,{onClick:()=>T(`desktop`),title:`Desktop view`,className:`p-1.5 rounded transition-colors ${w===`desktop`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(c,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`tablet`),title:`Tablet view`,className:`p-1.5 rounded transition-colors ${w===`tablet`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(i,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`mobile`),title:`Mobile view`,className:`p-1.5 rounded transition-colors ${w===`mobile`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(a,{size:15})})]}),e[22]=w,e[23]=S,e[24]=H):H=e[24];let U;e[25]===S?U=e[26]:(U=S&&(0,h.jsx)(`button`,{onClick:()=>void n(S),title:`Open in external browser`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(r,{size:15})}),e[25]=S,e[26]=U);let W;e[27]!==B||e[28]!==V||e[29]!==H||e[30]!==U?(W=(0,h.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border shrink-0`,children:[B,V,H,U]}),e[27]=B,e[28]=V,e[29]=H,e[30]=U,e[31]=W):W=e[31];let G;e[32]!==R||e[33]!==w||e[34]!==S||e[35]!==y||e[36]!==g?(G=S?(0,h.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-background`,children:w===`desktop`?(0,h.jsx)(`iframe`,{ref:E,src:S,className:`flex-1 w-full h-full border-none`,title:`Browser`}):(0,h.jsx)(`div`,{className:`bg-white border border-border rounded-lg shadow-lg overflow-hidden transition-all duration-200`,style:{width:R.width,height:R.height,maxWidth:`100%`,maxHeight:`100%`},children:(0,h.jsx)(`iframe`,{ref:E,src:S,className:`w-full h-full border-none`,title:`Browser`})})}):(0,h.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-6 text-muted-foreground`,children:g&&y?.runCommand?(0,h.jsx)(f,{projectId:g,runCommand:y.runCommand,large:!0}):(0,h.jsx)(`p`,{className:`text-sm`,children:`Enter a URL to browse`})}),e[32]=R,e[33]=w,e[34]=S,e[35]=y,e[36]=g,e[37]=G):G=e[37];let K;return e[38]!==W||e[39]!==G?(K=(0,h.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[W,G]}),e[38]=W,e[39]=G,e[40]=K):K=e[40],K}export{g as BrowserTab};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$ as t,Ai as n,Cr as r,D as i,Ei as a,Jr as o,Lr as s,Ni as c,Nr as l,Or as u,Pi as d,Pn as f,Q as p,Qr as m,Si as h,Tn as g,Tt as _,Vr as v,Wn as y,Xi as b,Y as x,Yt as S,_i as C,bi as w,bn as T,ca as E,cn as D,d as O,di as k,ea as A,fn as j,ia as M,jt as N,kr as P,kt as F,m as I,nt as L,on as ee,pn as te,ti as ne,tt as re,ua as R,ui as ie,w as z,xn as B,y as V}from"./dialogs-config-Dwpv4SNp.js";import{gt as H}from"./react-vendor-CYvpNUsM.js";import{a as U,l as W,s as G,t as K,u as q}from"./store-Cn1lT5YJ.js";import{c as J,s as Y,u as ae}from"./history-view-BvAOaO8q.js";import{a as oe,c as se,i as ce,o as le,s as ue,t as de}from"./alert-dialog-BeLER45U.js";import{n as X}from"./tab-context-COCYkRNN.js";import{r as fe}from"./onboarding-vGz3IczM.js";var Z=E(),Q=e(R(),1),$=r();function pe(e){let t=(0,Z.c)(24),{node:n,level:r,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l}=e,u=!!(n.children&&n.children.length>0),d=c[n.id]??a,f;t[0]!==n.id||t[1]!==l?(f=()=>l(n.id),t[0]=n.id,t[1]=l,t[2]=f):f=t[2];let p=f,m;t[3]!==u||t[4]!==d||t[5]!==r||t[6]!==n||t[7]!==i||t[8]!==p?(m=i(n,{isOpen:d,level:r,toggle:p,hasChildren:u}),t[3]=u,t[4]=d,t[5]=r,t[6]=n,t[7]=i,t[8]=p,t[9]=m):m=t[9];let h;t[10]!==s||t[11]!==a||t[12]!==u||t[13]!==o||t[14]!==d||t[15]!==r||t[16]!==n.children||t[17]!==l||t[18]!==c||t[19]!==i?(h=u&&d&&(0,$.jsx)(`div`,{style:{paddingLeft:o},className:s,children:n.children.map(e=>(0,$.jsx)(pe,{node:e,level:r+1,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l},e.id))}),t[10]=s,t[11]=a,t[12]=u,t[13]=o,t[14]=d,t[15]=r,t[16]=n.children,t[17]=l,t[18]=c,t[19]=i,t[20]=h):h=t[20];let g;return t[21]!==m||t[22]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[21]=m,t[22]=h,t[23]=g):g=t[23],g}function me(e){let t=(0,Z.c)(23),{nodes:n,renderNode:r,resetKey:i,defaultOpen:a,indent:o,childContainerClassName:s,className:c}=e,l=a===void 0?!1:a,u=o===void 0?16:o,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d={},t[0]=d):d=t[0];let[f,p]=(0,Q.useState)(d),[m,h]=(0,Q.useState)(i);i!==m&&(h(i),p({}));let g;t[1]===l?g=t[2]:(g=e=>{p(t=>({...t,[e]:!(t[e]??l)}))},t[1]=l,t[2]=g);let _=g,v;t[3]===c?v=t[4]:(v=y(`min-w-0`,c),t[3]=c,t[4]=v);let b;if(t[5]!==s||t[6]!==l||t[7]!==_||t[8]!==u||t[9]!==n||t[10]!==f||t[11]!==r){let e;t[13]!==s||t[14]!==l||t[15]!==_||t[16]!==u||t[17]!==f||t[18]!==r?(e=e=>(0,$.jsx)(pe,{node:e,level:0,renderNode:r,defaultOpen:l,indent:u,childContainerClassName:s,openState:f,onToggle:_},e.id),t[13]=s,t[14]=l,t[15]=_,t[16]=u,t[17]=f,t[18]=r,t[19]=e):e=t[19],b=n.map(e),t[5]=s,t[6]=l,t[7]=_,t[8]=u,t[9]=n,t[10]=f,t[11]=r,t[12]=b}else b=t[12];let x;return t[20]!==v||t[21]!==b?(x=(0,$.jsx)(`div`,{className:v,children:b}),t[20]=v,t[21]=b,t[22]=x):x=t[22],x}var he=new Map,ge=new Map;function _e(e){return he.get(e)}function ve(e,t){let n=ge.get(e);return n||(n=new Set,ge.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&ge.delete(e)}}function ye(e){let t=ge.get(e);if(t)for(let e of t)e()}function be(e,t){return async function(n,r){let i=await fetch(e+`/api/browser-js/execute-tool`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:t,toolName:n,params:r})});if(!i.ok){let e=await i.text();try{let t=JSON.parse(e).error||{};e=t.details||t.message||e}catch{}return{text:null,error:`Tool `+n+` failed: `+e}}let a=await i.json();return{text:a.content&&a.content[0]?a.content[0].text:null,error:null}}}function xe(e,t,n){if(he.has(e))return;he.set(e,{status:`running`}),ye(e);let r=g();(async()=>{try{let i=be(r,n),a=Object.getPrototypeOf(async function(){}).constructor,o=await new a(`callTool`,t)(i),s=o===void 0?null:o;he.set(e,{status:`success`,result:s}),ye(e),await j(e,s)}catch(t){let n=t instanceof Error?t.stack||t.message:String(t);he.set(e,{status:`error`,error:n}),ye(e);try{await j(e,{error:n})}catch(e){console.error(`[browser-js-executor] failed to submit error result`,e)}}})()}var Se=()=>{if(typeof window>`u`)return null;let e=window.SpeechRecognition||window.webkitSpeechRecognition;return e?new e:null};function Ce(){let e=(0,Z.c)(14),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(null),u=(0,Q.useRef)(``),d,f;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{try{let e=Se();e?(e.continuous=!0,e.interimResults=!0,e.lang=`en-US`,e.onstart=()=>{n(!0),o(null),u.current=``},e.onresult=e=>{let t=``;for(let n=e.resultIndex;n<e.results.length;n++){let r=e.results[n][0].transcript;e.results[n].isFinal?i(e=>e+r+` `):t+=r}u.current=t},e.onerror=e=>{console.error(`Speech recognition error:`,e.error),o(e.error||`An error occurred during speech recognition`)},e.onend=()=>{n(!1)},l.current=e,c(!0)):(c(!1),o(`Speech Recognition API is not supported in your browser`))}catch(e){console.error(`Failed to initialize speech recognition:`,e),c(!1),o(`Failed to initialize speech recognition`)}return()=>{l.current&&l.current.abort()}},f=[],e[0]=d,e[1]=f):(d=e[0],f=e[1]),(0,Q.useEffect)(d,f);let p;e[2]===t?p=e[3]:(p=()=>{l.current&&!t&&l.current.start()},e[2]=t,e[3]=p);let m=p,h;e[4]===t?h=e[5]:(h=()=>{l.current&&t&&l.current.stop()},e[4]=t,e[5]=h);let g=h,_;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{i(``),u.current=``},e[6]=_):_=e[6];let v=_,y;return e[7]!==a||e[8]!==t||e[9]!==s||e[10]!==m||e[11]!==g||e[12]!==r?(y={isListening:t,transcript:r,error:a,startListening:m,stopListening:g,resetTranscript:v,isSupported:s},e[7]=a,e[8]=t,e[9]=s,e[10]=m,e[11]=g,e[12]=r,e[13]=y):y=e[13],y}function we({initialValue:e}={}){let{state:n,dispatch:r}=U(),[i,a]=(0,Q.useState)(e??``),[o,s]=(0,Q.useState)(-1),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(0),[f,m]=(0,Q.useState)([]),[h,g]=(0,Q.useState)(()=>(n.selectedThreadId?n.projectModelSelections[n.selectedThreadId]:void 0)??null),v=(0,Q.useRef)(h?.id??``),y=(0,Q.useRef)(h?.provider??``),b=(0,Q.useRef)(null),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)([]),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)([]),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)([]),[ee,te]=(0,Q.useState)(!1),[ne,R]=(0,Q.useState)(``),[ie,B]=(0,Q.useState)(0),[V,H]=(0,Q.useState)([]),[W,G]=(0,Q.useState)([]),[q,J]=(0,Q.useState)(!1),[Y,ae]=(0,Q.useState)(``),oe=(0,Q.useRef)(null),se=(0,Q.useRef)(null),ce=(0,Q.useRef)(null),le=(0,Q.useRef)(null),ue=(0,Q.useRef)(null),de=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{v.current=h?.id??``,y.current=h?.provider??``},[h?.id,h?.provider]);let X=(0,Q.useCallback)((e,t)=>{g(e);let i=n.selectedThreadId;if(!i||(r({type:K.SetProjectModel,threadId:i,model:e}),t?.persist===!1))return;let a=`${i}:${e.provider??``}:${e.id}`;b.current!==a&&(b.current=a,console.log(`[useChatInputState] Persisting model to thread:`,{threadId:i,model:{id:e.id,provider:e.provider}}),T(i,{model:e.id,modelProvider:e.provider}).then(()=>{b.current===a&&(b.current=null),console.log(`[useChatInputState] Model persisted successfully`)}).catch(e=>{b.current===a&&(b.current=null),console.error(`Failed to save model to thread:`,e)}))},[n.selectedThreadId,r]);(0,Q.useEffect)(()=>{(async()=>{let e=n.selectedProjectId?n.projects.find(e=>e.projectId===n.selectedProjectId)?.threads.find(e=>e.threadId===n.selectedThreadId):void 0,r=n.selectedThreadId?n.projectModelSelections[n.selectedThreadId]:void 0,i=e?.model??r?.id??null,a=e?.modelProvider??r?.provider??null;console.log(`[useChatInputState] Loading models for thread:`,{threadId:n.selectedThreadId,projectId:n.selectedProjectId,currentThread:e?{model:e.model,modelProvider:e.modelProvider}:void 0,storedModel:r?{id:r.id,provider:r.provider}:void 0,savedModelId:i,savedModelProvider:a});try{let e=await t(),n=Object.values(e).flat();if(n.length===0){m([]),g(null);return}m(n);let r=i&&a?n.find(e=>e.id===i&&e.provider===a)??null:null,o=n[0],s=r??o,c=!r&&!!(i||a),l=v.current===s.id&&y.current===s.provider;console.log(`[useChatInputState] Model selection decision:`,{matchedSavedModel:r?{id:r.id}:null,fallbackModel:{id:o.id},modelToSelect:{id:s.id},shouldPersistFallback:c,hasSameSelection:l,currentSelected:{id:v.current,provider:y.current}}),l||X(s,{persist:c})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[n.selectedThreadId,n.selectedProjectId,n.projects,X]);let fe=(0,Q.useRef)(X);(0,Q.useEffect)(()=>{fe.current=X},[X]),(0,Q.useEffect)(()=>{n.configUpdatedAt!==0&&(async()=>{try{let e=await t(),n=Object.values(e).flat();if(n.length>0){m(n);let e=v.current,t=y.current;n.some(n=>n.id===e&&n.provider===t)||fe.current(n[0],{persist:!0})}}catch(e){console.error(`Failed to reload enabled models:`,e)}})()},[n.configUpdatedAt]),(0,Q.useEffect)(()=>{!A||M.length>0||(async()=>{try{let e=await p(),t=Object.values(e).flat();t.length>0&&(N(t),F(e=>e??t[0]))}catch(e){console.error(`Failed to load image models:`,e)}})()},[A,M.length]);let[Z,$]=(0,Q.useState)(n.selectedThreadId);return(0,Q.useEffect)(()=>{n.selectedThreadId!==Z&&setTimeout(()=>{$(n.selectedThreadId),L([]),te(!1),H([]),G([]),J(!1),k(!1),j(!1)},0)},[n.selectedThreadId,Z]),(0,Q.useEffect)(()=>{n.selectedThreadId&&_(n.selectedThreadId).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),H(e),G(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[n.selectedThreadId]),(0,Q.useEffect)(()=>{n.focusChatInput&&n.selectedThreadId&&!n.isStreaming&&(se.current?.focus(),r({type:K.ClearFocusChatInput}))},[n.focusChatInput,n.selectedThreadId,n.isStreaming,r]),(0,Q.useEffect)(()=>{let e=e=>{ce.current&&!ce.current.contains(e.target)&&S(!1),le.current&&!le.current.contains(e.target)&&w(!1)};if(x||C)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[x,C]),{message:i,setMessage:a,historyIndex:o,setHistoryIndex:s,draftMessage:c,setDraftMessage:l,cursorPosition:u,setCursorPosition:d,availableModels:f,setAvailableModels:m,selectedModel:h,setSelectedModel:X,selectedModelIdRef:v,showModelMenu:x,setShowModelMenu:S,showPlusMenu:C,setShowPlusMenu:w,attachments:E,setAttachments:D,planMode:O,setPlanMode:k,imageMode:A,setImageMode:j,availableImageModels:M,setAvailableImageModels:N,selectedImageModel:P,setSelectedImageModel:F,allFiles:I,setAllFiles:L,showSuggestions:ee,setShowSuggestions:te,suggestionQuery:ne,setSuggestionQuery:R,selectedIndex:ie,setSelectedIndex:B,slashCommands:V,setSlashCommands:H,skills:W,setSkills:G,showCommandSuggestions:q,setShowCommandSuggestions:J,commandQuery:Y,setCommandQuery:ae,fileInputRef:oe,textareaRef:se,modelMenuRef:ce,plusMenuRef:le,suggestionsRef:ue,commandSuggestionsRef:de,handleNewChat:async()=>{if(n.selectedThreadId)try{let e=await z(n.selectedThreadId);r({type:K.ClearMessages}),console.log(`New conversation started:`,e);let t=await re(n.selectedThreadId);r({type:K.SetMessages,messages:t.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},state:n,dispatch:r}}var Te=e=>{O(e)};function Ee(e){let t=(0,Z.c)(99),{message:n,setMessage:r,attachments:i,selectedModel:a,onSend:o,isStreaming:s,selectedThreadId:c,isListening:l,stopListening:u,resetTranscript:d,dispatch:f,historyIndex:p,setHistoryIndex:m,draftMessage:h,setDraftMessage:g,cursorPosition:_,setCursorPosition:v,showSuggestions:y,setShowSuggestions:b,suggestionQuery:x,setSuggestionQuery:S,allFiles:C,setAllFiles:w,selectedIndex:T,setSelectedIndex:E,showCommandSuggestions:D,setShowCommandSuggestions:O,commandQuery:k,setCommandQuery:A,slashCommands:j,skills:M,textareaRef:N,setAttachments:P,planMode:L,setPlanMode:ee,imageMode:te,selectedImageModel:ne}=e,re;t[0]!==i||t[1]!==f||t[2]!==te||t[3]!==l||t[4]!==s||t[5]!==n||t[6]!==o||t[7]!==L||t[8]!==d||t[9]!==ne||t[10]!==a||t[11]!==c||t[12]!==P||t[13]!==g||t[14]!==m||t[15]!==r||t[16]!==u||t[17]!==N?(re=()=>{if(!n.trim()&&i.length===0||!c)return;let e=te?ne:a;e&&(l&&(u(),d()),s?f({type:K.EnqueueChatMessage,message:{id:`queued-${Date.now()}`,threadId:c,message:n,model:e.id,attachments:i,provider:e.provider,planMode:L,imageMode:te}}):o(n,e.id,i,e.provider,L,te),Te(n),r(``),P([]),m(-1),g(``),N.current&&(N.current.style.height=`auto`))},t[0]=i,t[1]=f,t[2]=te,t[3]=l,t[4]=s,t[5]=n,t[6]=o,t[7]=L,t[8]=d,t[9]=ne,t[10]=a,t[11]=c,t[12]=P,t[13]=g,t[14]=m,t[15]=r,t[16]=u,t[17]=N,t[18]=re):re=t[18];let R=re,ie;t[19]!==_||t[20]!==n||t[21]!==r||t[22]!==b||t[23]!==x||t[24]!==N?(ie=e=>{let t=n.substring(0,_-x.length-1);r(`${t}${e} ${n.substring(_)}`),b(!1),setTimeout(()=>{if(N.current){N.current.focus();let n=t.length+e.length+1;N.current.setSelectionRange(n,n)}},0)},t[19]=_,t[20]=n,t[21]=r,t[22]=b,t[23]=x,t[24]=N,t[25]=ie):ie=t[25];let z=ie,B;t[26]!==k||t[27]!==_||t[28]!==n||t[29]!==r||t[30]!==ee||t[31]!==O||t[32]!==N?(B=e=>{let t=n.substring(0,_-k.length-1),i=n.substring(_);r(`${t}${e.content}${i}`),O(!1),setTimeout(()=>{if(N.current){N.current.focus();let n=t.length+e.content.length;N.current.setSelectionRange(n,n)}},0),e.metadata.mode===`plan`&&ee(!0)},t[26]=k,t[27]=_,t[28]=n,t[29]=r,t[30]=ee,t[31]=O,t[32]=N,t[33]=B):B=t[33];let V=B,H;t[34]!==k||t[35]!==_||t[36]!==n||t[37]!==r||t[38]!==O||t[39]!==N?(H=e=>{let t=n.substring(0,_-k.length-1),i=n.substring(_),a=e.name.includes(` `)?`/"${e.name}"`:`/${e.name}`;r(`${t}${a}${i}`),O(!1),setTimeout(()=>{if(N.current){N.current.focus();let e=t.length+a.length;N.current.setSelectionRange(e,e)}},0)},t[34]=k,t[35]=_,t[36]=n,t[37]=r,t[38]=O,t[39]=N,t[40]=H):H=t[40];let U=H,W,G,q,J;if(t[41]!==C||t[42]!==k||t[43]!==h||t[44]!==R||t[45]!==p||t[46]!==V||t[47]!==z||t[48]!==U||t[49]!==n||t[50]!==T||t[51]!==c||t[52]!==w||t[53]!==A||t[54]!==v||t[55]!==g||t[56]!==m||t[57]!==r||t[58]!==E||t[59]!==O||t[60]!==b||t[61]!==S||t[62]!==D||t[63]!==y||t[64]!==M||t[65]!==j||t[66]!==x){q=e=>{if(D){if(e.key===`ArrowDown`){e.preventDefault(),E((T+1)%W.length);return}if(e.key===`ArrowUp`){e.preventDefault(),E((T-1+W.length)%W.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=W[T];t&&(t.type===`command`?V(t.data):U(t.data));return}if(e.key===`Escape`){O(!1);return}}if(y){let t=G.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),E((T+1)%G.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),E((T-1+G.length)%G.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),G[T]&&z(G[T]);return}if(e.key===`Escape`){b(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),R();return}let t=I();t.length!==0&&(e.key===`ArrowUp`?(e.preventDefault(),p===-1?(g(n),m(t.length-1),r(t[t.length-1])):p>0&&(m(p-1),r(t[p-1]))):e.key===`ArrowDown`&&(e.preventDefault(),p>0?(m(p-1),r(t[p-1])):p===0&&(m(-1),r(h))))};let e;t[71]!==C||t[72]!==c||t[73]!==w||t[74]!==A||t[75]!==v||t[76]!==r||t[77]!==E||t[78]!==O||t[79]!==b||t[80]!==S?(e=e=>{let t=e.target.value,n=e.target.selectionStart;r(t),v(n);let i=t.substring(0,n),a=i.lastIndexOf(`/`);if(a!==-1){let e=a>0?i[a-1]:``;if(a===0||/\s/.test(e)){let e=i.substring(a+1);e.includes(` `)?O(!1):(A(e),O(!0),b(!1),E(0))}else O(!1)}else{O(!1);let e=i.lastIndexOf(`#`);if(e!==-1){let t=e>0?i[e-1]:``;if(e===0||/\s/.test(t)){let t=i.substring(e+1);t.includes(` `)?b(!1):(S(t),b(!0),E(0),C.length===0&&c&&F(c).then(e=>{w(e)}).catch(ke))}else b(!1)}else b(!1)}let o=e.target;o.style.height=`auto`,o.style.height=`${Math.min(o.scrollHeight,160)}px`},t[71]=C,t[72]=c,t[73]=w,t[74]=A,t[75]=v,t[76]=r,t[77]=E,t[78]=O,t[79]=b,t[80]=S,t[81]=e):e=t[81],J=e;let i;if(t[82]!==k||t[83]!==M||t[84]!==j){let e;t[86]===k?e=t[87]:(e=e=>e.name.toLowerCase().includes(k.toLowerCase()),t[86]=k,t[87]=e);let n=j.filter(e),r;t[88]===k?r=t[89]:(r=e=>e.name.toLowerCase().includes(k.toLowerCase()),t[88]=k,t[89]=r);let a=M.filter(r);i=[...n.map(Oe),...a.map(De)],t[82]=k,t[83]=M,t[84]=j,t[85]=i}else i=t[85];W=i.slice(0,10),G=y?C.filter(e=>e.toLowerCase().includes(x.toLowerCase())).slice(0,10):[],t[41]=C,t[42]=k,t[43]=h,t[44]=R,t[45]=p,t[46]=V,t[47]=z,t[48]=U,t[49]=n,t[50]=T,t[51]=c,t[52]=w,t[53]=A,t[54]=v,t[55]=g,t[56]=m,t[57]=r,t[58]=E,t[59]=O,t[60]=b,t[61]=S,t[62]=D,t[63]=y,t[64]=M,t[65]=j,t[66]=x,t[67]=W,t[68]=G,t[69]=q,t[70]=J}else W=t[67],G=t[68],q=t[69],J=t[70];let Y;return t[90]!==W||t[91]!==G||t[92]!==q||t[93]!==R||t[94]!==J||t[95]!==V||t[96]!==z||t[97]!==U?(Y={handleSend:R,handleKeyDown:q,handleTextareaInput:J,insertFileReference:z,insertCommand:V,insertSkill:U,allSuggestions:W,fileSuggestions:G},t[90]=W,t[91]=G,t[92]=q,t[93]=R,t[94]=J,t[95]=V,t[96]=z,t[97]=U,t[98]=Y):Y=t[98],Y}function De(e){return{type:`skill`,data:e}}function Oe(e){return{type:`command`,data:e}}function ke(e){return console.error(`Failed to fetch files:`,e)}function Ae(e){let t=(0,Z.c)(21),{visible:n,commands:r,skills:i,query:a,selectedIndex:o,onSelectCommand:c,onSelectSkill:l,onMouseEnterSuggestion:d,containerRef:f}=e;if(!n)return null;let p;if(t[0]!==r||t[1]!==a||t[2]!==i){let e;t[4]===a?e=t[5]:(e=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[4]=a,t[5]=e);let n=r.filter(e),o;t[6]===a?o=t[7]:(o=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[6]=a,t[7]=o);let s=i.filter(o);p=[...n.map(Me),...s.map(je)].slice(0,10),t[0]=r,t[1]=a,t[2]=i,t[3]=p}else p=t[3];let m=p,h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(s,{className:`h-3 w-3`}),t[8]=h):h=t[8];let g=a&&` matching "${a}"`,_;t[9]===g?_=t[10]:(_=(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[h,`Commands & Skills`,g]}),t[9]=g,t[10]=_);let v;t[11]!==m||t[12]!==d||t[13]!==c||t[14]!==l||t[15]!==o?(v=m.length>0?m.map((e,t)=>{let n=t===o;if(e.type===`command`){let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:y(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>c(r),onMouseEnter:()=>d(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(s,{className:`h-3 w-3 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),r.metadata.argumentHint&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.argumentHint}),r.scope===`project`&&(0,$.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),r.metadata.description&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.description})]},`cmd-${r.name}`)}else{let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:y(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>l(r),onMouseEnter:()=>d(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(u,{className:`h-3 w-3 text-amber-500`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),(0,$.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-amber-500/10 px-1.5 py-0.5 text-amber-700 dark:text-amber-400`,children:`skill`}),r.scope===`project`&&(0,$.jsx)(`span`,{className:`text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.description})]},`skill-${r.name}`)}}):(0,$.jsxs)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:[`No commands or skills found.`,(0,$.jsx)(`br`,{}),(0,$.jsxs)(`span`,{className:`text-[10px]`,children:[`Create commands in `,(0,$.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/commands/`}),` or skills in `,(0,$.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/skills/`})]})]}),t[11]=m,t[12]=d,t[13]=c,t[14]=l,t[15]=o,t[16]=v):v=t[16];let b;return t[17]!==f||t[18]!==_||t[19]!==v?(b=(0,$.jsxs)(`div`,{ref:f,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[_,v]}),t[17]=f,t[18]=_,t[19]=v,t[20]=b):b=t[20],b}function je(e){return{type:`skill`,data:e}}function Me(e){return{type:`command`,data:e}}function Ne(e){return e.startsWith(`image/`)}function Pe(e){let t=(0,Z.c)(7),{attachments:n,onRemove:r}=e;if(n.length===0)return null;let i;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=(e,t)=>(0,$.jsx)(`div`,{className:`group relative flex items-center gap-1 rounded-md bg-muted text-xs text-muted-foreground`,children:Ne(e.mimeType)?(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:e.fileName,className:`h-16 w-16 rounded-md object-cover`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-foreground text-background opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(P,{className:`h-2.5 w-2.5`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]}):(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,$.jsx)(ne,{className:`h-3 w-3`}),e.fileName,(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`ml-1 hover:text-foreground`,children:[(0,$.jsx)(P,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]})},t),t[3]=r,t[4]=e),i=n.map(e),t[0]=n,t[1]=r,t[2]=i}else i=t[2];let a;return t[5]===i?a=t[6]:(a=(0,$.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:i}),t[5]=i,t[6]=a),a}function Fe(e,t){let n=e.target.files;if(!n||n.length===0)return;let r=Array.from(n),i=r.length,a=Array.from({length:i}),o=0;e.target.value=``,r.forEach((e,n)=>{let r=new FileReader;r.onload=()=>{let s=r.result.split(`,`)[1];a[n]={fileName:e.name,content:s,mimeType:e.type||`application/octet-stream`},o+=1,o===i&&t(a)},r.readAsDataURL(e)})}function Ie(e){let t=(0,Z.c)(16),{showSuggestions:n,fileSuggestions:r,suggestionQuery:i,selectedIndex:a,onSelectFile:s,onMouseEnterSuggestion:l,containerRef:u}=e;if(!n||r.length===0)return null;let f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(o,{className:`h-3 w-3`}),t[0]=f):f=t[0];let p;t[1]===i?p=t[2]:(p=(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[f,`Files matching "`,i,`"`]}),t[1]=i,t[2]=p);let m;if(t[3]!==r||t[4]!==l||t[5]!==s||t[6]!==a){let e;t[8]!==l||t[9]!==s||t[10]!==a?(e=(e,t)=>{let n=e.split(`/`).pop()??e;return(0,$.jsxs)(`button`,{type:`button`,className:y(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-left transition-colors`,t===a?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>s(e),onMouseEnter:()=>l(t),children:[e.endsWith(`.ts`)||e.endsWith(`.tsx`)||e.endsWith(`.js`)||e.endsWith(`.jsx`)?(0,$.jsx)(d,{className:`h-4 w-4 text-blue-500`}):(0,$.jsx)(c,{className:`h-4 w-4 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:n}),(0,$.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground opacity-70`,children:e})]})]},e)},t[8]=l,t[9]=s,t[10]=a,t[11]=e):e=t[11],m=r.map(e),t[3]=r,t[4]=l,t[5]=s,t[6]=a,t[7]=m}else m=t[7];let h;return t[12]!==u||t[13]!==p||t[14]!==m?(h=(0,$.jsxs)(`div`,{ref:u,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[p,m]}),t[12]=u,t[13]=p,t[14]=m,t[15]=h):h=t[15],h}function Le(e){let t=(0,Z.c)(3),{provider:n}=e;if(!n)return null;let r=`https://models.tarsk.io/svg/${n}.svg`,i=`${n} logo`,a;return t[0]!==r||t[1]!==i?(a=(0,$.jsx)(`img`,{src:r,alt:i,className:`h-3.5 w-3.5 flex-shrink-0`,onError:Re}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a}function Re(e){e.currentTarget.style.visibility=`hidden`}function ze(e){let t=(0,Z.c)(26),{availableModels:n,selectedModel:r,onModelSelect:i}=e,[a,o]=Q.useState(!1),s=Q.useRef(null),c,l;t[0]===a?(c=t[1],l=t[2]):(c=()=>{let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};if(a)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},l=[a],t[0]=a,t[1]=c,t[2]=l),Q.useEffect(c,l);let u;t[3]===i?u=t[4]:(u=e=>{i(e),o(!1)},t[3]=i,t[4]=u);let d=u,p;t[5]===a?p=t[6]:(p=()=>o(!a),t[5]=a,t[6]=p);let m=r?.provider,h;t[7]===m?h=t[8]:(h=(0,$.jsx)(Le,{provider:m}),t[7]=m,t[8]=h);let g;t[9]===r?g=t[10]:(g=r?fe(r.id):`No model`,t[9]=r,t[10]=g);let _;t[11]===g?_=t[12]:(_=(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:g}),t[11]=g,t[12]=_);let v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(b,{className:`h-3 w-3`}),t[13]=v):v=t[13];let y;t[14]!==p||t[15]!==h||t[16]!==_?(y=(0,$.jsxs)(f,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:p,children:[h,_,v]}),t[14]=p,t[15]=h,t[16]=_,t[17]=y):y=t[17];let x;t[18]!==n||t[19]!==d||t[20]!==r?.id||t[21]!==a?(x=a&&(0,$.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-80 max-h-80 overflow-y-auto rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:Object.entries(n.reduce(Be,{})).map(e=>{let[t,n]=e;return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:[(0,$.jsx)(Le,{provider:t}),t]}),n.map(e=>(0,$.jsx)(`button`,{type:`button`,className:`flex w-full items-center whitespace-nowrap rounded-md px-3 py-1.5 pl-8 text-sm text-popover-foreground hover:bg-accent ${e.id===r?.id?`bg-accent font-medium`:``}`,onClick:()=>d(e),children:fe(e.id)},e.id))]},t)})}),t[18]=n,t[19]=d,t[20]=r?.id,t[21]=a,t[22]=x):x=t[22];let S;return t[23]!==y||t[24]!==x?(S=(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[y,x]}),t[23]=y,t[24]=x,t[25]=S):S=t[25],S}function Be(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}var Ve=[{value:`build`,label:`Build`,icon:h},{value:`plan`,label:`Plan`,icon:C},{value:`image`,label:`Image`,icon:w}];function He(e,t){return e?`plan`:t?`image`:`build`}function Ue(e){let t=(0,Z.c)(29),{planMode:n,imageMode:r,setPlanMode:i,setImageMode:a}=e,[o,s]=Q.useState(!1),c=Q.useRef(null),l;t[0]!==r||t[1]!==n?(l=He(n,r),t[0]=r,t[1]=n,t[2]=l):l=t[2];let u=l,d;t[3]===u?d=t[4]:(d=Ve.find(e=>e.value===u),t[3]=u,t[4]=d);let p=d,m=p.icon,h,g;t[5]===o?(h=t[6],g=t[7]):(h=()=>{let e=function(e){c.current&&!c.current.contains(e.target)&&s(!1)};if(o)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},g=[o],t[5]=o,t[6]=h,t[7]=g),Q.useEffect(h,g);let _;t[8]!==a||t[9]!==i?(_=function(e){i(e===`plan`),a(e===`image`),s(!1)},t[8]=a,t[9]=i,t[10]=_):_=t[10];let v=_,y;t[11]===o?y=t[12]:(y=()=>s(!o),t[11]=o,t[12]=y);let x;t[13]===m?x=t[14]:(x=(0,$.jsx)(m,{className:`h-3.5 w-3.5`}),t[13]=m,t[14]=x);let S;t[15]===p.label?S=t[16]:(S=(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:p.label}),t[15]=p.label,t[16]=S);let C;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(b,{className:`h-3 w-3`}),t[17]=C):C=t[17];let w;t[18]!==y||t[19]!==x||t[20]!==S?(w=(0,$.jsxs)(f,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:y,children:[x,S,C]}),t[18]=y,t[19]=x,t[20]=S,t[21]=w):w=t[21];let T;t[22]!==u||t[23]!==o||t[24]!==v?(T=o&&(0,$.jsx)(`div`,{className:`absolute bottom-full right-0 mb-1 w-40 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:Ve.map(e=>{let t=e.icon,n=e.value===u;return(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:()=>v(e.value),children:[(0,$.jsx)(t,{className:`h-3.5 w-3.5`}),e.label,n&&(0,$.jsx)(A,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})}),t[22]=u,t[23]=o,t[24]=v,t[25]=T):T=t[25];let E;return t[26]!==w||t[27]!==T?(E=(0,$.jsxs)(`div`,{className:`relative`,ref:c,children:[w,T]}),t[26]=w,t[27]=T,t[28]=E):E=t[28],E}function We(e){let t=(0,Z.c)(17),{onFileAttach:n}=e,[r,i]=Q.useState(!1),a=Q.useRef(null),o,s;t[0]===r?(o=t[1],s=t[2]):(o=()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&i(!1)};if(r)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},s=[r],t[0]=r,t[1]=o,t[2]=s),Q.useEffect(o,s);let c;t[3]===n?c=t[4]:(c=function(){n(),i(!1)},t[3]=n,t[4]=c);let l=c,u;t[5]===r?u=t[6]:(u=()=>i(!r),t[5]=r,t[6]=u);let d,p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(m,{}),p=(0,$.jsx)(`span`,{className:`sr-only`,children:`More options`}),t[7]=d,t[8]=p):(d=t[7],p=t[8]);let h;t[9]===u?h=t[10]:(h=(0,$.jsxs)(f,{variant:`action`,size:`icon-sm`,onClick:u,children:[d,p]}),t[9]=u,t[10]=h);let g;t[11]!==l||t[12]!==r?(g=r&&(0,$.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-48 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:l,children:[(0,$.jsx)(ne,{className:`h-3.5 w-3.5`}),`Attach File`]})}),t[11]=l,t[12]=r,t[13]=g):g=t[13];let _;return t[14]!==h||t[15]!==g?(_=(0,$.jsxs)(`div`,{className:`relative`,ref:a,children:[h,g]}),t[14]=h,t[15]=g,t[16]=_):_=t[16],_}function Ge(e){let t=(0,Z.c)(14),{onToggleSpeech:n}=e,{isListening:r,isSupported:i}=Ce();if(!i)return null;let a=r?`bg-red-500/20 text-red-500 hover:bg-red-500/30`:`text-muted-foreground hover:text-background`,o;t[0]===r?o=t[1]:(o=r?(0,$.jsx)(k,{}):(0,$.jsx)(ie,{}),t[0]=r,t[1]=o);let s=r?`Stop listening`:`Start listening`,c;t[2]===s?c=t[3]:(c=(0,$.jsx)(`span`,{className:`sr-only`,children:s}),t[2]=s,t[3]=c);let l;t[4]!==n||t[5]!==a||t[6]!==o||t[7]!==c?(l=(0,$.jsx)(ae,{asChild:!0,children:(0,$.jsxs)(f,{variant:`ghost`,size:`icon-sm`,className:a,onClick:n,children:[o,c]})}),t[4]=n,t[5]=a,t[6]=o,t[7]=c,t[8]=l):l=t[8];let u=r?`Stop listening`:`Start listening`,d;t[9]===u?d=t[10]:(d=(0,$.jsx)(J,{side:`top`,className:`bg-popover text-popover-foreground`,children:u}),t[9]=u,t[10]=d);let p;return t[11]!==l||t[12]!==d?(p=(0,$.jsxs)(Y,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=p):p=t[13],p}function Ke(e){let t=(0,Z.c)(8),{queuedMessages:n,onRemoveQueuedMessage:r}=e;if(n.length===0)return null;let i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Queued messages`}),t[0]=i):i=t[0];let a;if(t[1]!==r||t[2]!==n){let e;t[4]===r?e=t[5]:(e=e=>(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border/60 bg-background px-3 py-2 text-sm`,children:[(0,$.jsx)(`p`,{className:`flex-1 whitespace-pre-wrap text-foreground`,children:e.message}),(0,$.jsx)(`button`,{type:`button`,className:`rounded-full p-1 text-muted-foreground transition-colors hover:bg-foreground hover:text-background`,onClick:()=>r(e.id),"aria-label":`Remove queued message`,children:(0,$.jsx)(P,{className:`h-3.5 w-3.5`})})]},e.id),t[4]=r,t[5]=e),a=n.map(e),t[1]=r,t[2]=n,t[3]=a}else a=t[3];let o;return t[6]===a?o=t[7]:(o=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border/60 bg-muted/30 px-4 py-3`,children:[i,(0,$.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:a})]}),t[6]=a,t[7]=o),o}function qe(e){let t=(0,Z.c)(141),{onSend:n,onStop:r,isStreaming:i,disabled:a,initialValue:o,queuedMessages:s,onRemoveQueuedMessage:c,isOverlay:u}=e,d=i===void 0?!1:i,p=u===void 0?!1:u,{isListening:m,transcript:h,startListening:g,stopListening:_,resetTranscript:y}=Ce(),b;t[0]===o?b=t[1]:(b={initialValue:o},t[0]=o,t[1]=b);let{message:x,setMessage:S,historyIndex:C,setHistoryIndex:w,draftMessage:T,setDraftMessage:E,cursorPosition:D,setCursorPosition:O,availableModels:k,selectedModel:A,setSelectedModel:j,attachments:N,setAttachments:P,planMode:F,setPlanMode:I,imageMode:L,setImageMode:ee,availableImageModels:te,selectedImageModel:ne,setSelectedImageModel:re,allFiles:R,setAllFiles:ie,showSuggestions:z,setShowSuggestions:B,suggestionQuery:V,setSuggestionQuery:H,selectedIndex:U,setSelectedIndex:W,slashCommands:G,skills:K,showCommandSuggestions:q,setShowCommandSuggestions:J,commandQuery:Y,setCommandQuery:ae,fileInputRef:oe,textareaRef:se,suggestionsRef:ce,commandSuggestionsRef:le,state:ue,dispatch:de}=we(b),X=L?ne:A,fe=L?te:k,pe=ue.selectedThreadId??void 0,me;t[2]!==R||t[3]!==N||t[4]!==Y||t[5]!==D||t[6]!==de||t[7]!==T||t[8]!==C||t[9]!==L||t[10]!==m||t[11]!==d||t[12]!==x||t[13]!==n||t[14]!==F||t[15]!==y||t[16]!==ne||t[17]!==U||t[18]!==A||t[19]!==ie||t[20]!==P||t[21]!==ae||t[22]!==O||t[23]!==E||t[24]!==w||t[25]!==S||t[26]!==I||t[27]!==W||t[28]!==J||t[29]!==B||t[30]!==H||t[31]!==q||t[32]!==z||t[33]!==K||t[34]!==G||t[35]!==_||t[36]!==V||t[37]!==pe||t[38]!==se?(me={message:x,setMessage:S,attachments:N,selectedModel:A,onSend:n,isStreaming:d,selectedThreadId:pe,isListening:m,stopListening:_,resetTranscript:y,dispatch:de,historyIndex:C,setHistoryIndex:w,draftMessage:T,setDraftMessage:E,cursorPosition:D,setCursorPosition:O,showSuggestions:z,setShowSuggestions:B,suggestionQuery:V,setSuggestionQuery:H,allFiles:R,setAllFiles:ie,selectedIndex:U,setSelectedIndex:W,showCommandSuggestions:q,setShowCommandSuggestions:J,commandQuery:Y,setCommandQuery:ae,slashCommands:G,skills:K,textareaRef:se,setAttachments:P,planMode:F,setPlanMode:I,imageMode:L,selectedImageModel:ne},t[2]=R,t[3]=N,t[4]=Y,t[5]=D,t[6]=de,t[7]=T,t[8]=C,t[9]=L,t[10]=m,t[11]=d,t[12]=x,t[13]=n,t[14]=F,t[15]=y,t[16]=ne,t[17]=U,t[18]=A,t[19]=ie,t[20]=P,t[21]=ae,t[22]=O,t[23]=E,t[24]=w,t[25]=S,t[26]=I,t[27]=W,t[28]=J,t[29]=B,t[30]=H,t[31]=q,t[32]=z,t[33]=K,t[34]=G,t[35]=_,t[36]=V,t[37]=pe,t[38]=se,t[39]=me):me=t[39];let{handleSend:he,handleKeyDown:ge,handleTextareaInput:_e,insertFileReference:ve,insertCommand:ye,insertSkill:be,fileSuggestions:xe}=Ee(me),Se=Q.useRef(``),Te,De;t[40]!==S||t[41]!==h?(Te=()=>{if(h&&h!==Se.current){let e=h.substring(Se.current.length);S(t=>(t.endsWith(` `),t+e)),Se.current=h}},De=[h,S],t[40]=S,t[41]=h,t[42]=Te,t[43]=De):(Te=t[42],De=t[43]),Q.useEffect(Te,De);let Oe;t[44]===P?Oe=t[45]:(Oe=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(Ye);if(n.length!==0){e.preventDefault();for(let e of n){let t=e.getAsFile();if(!t)continue;let n=new FileReader;n.onload=()=>{let e=n.result.split(`,`)[1];P(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[44]=P,t[45]=Oe);let ke=Oe,je;t[46]!==m||t[47]!==y||t[48]!==g||t[49]!==_?(je=()=>{m?(_(),y()):(y(),g())},t[46]=m,t[47]=y,t[48]=g,t[49]=_,t[50]=je):je=t[50];let Me=je,Ne=p?`absolute inset-x-0 bottom-0 mx-auto w-full max-w-3xl px-4 pb-4 pointer-events-none`:`relative mx-auto w-full max-w-3xl px-4 pb-4`,Le=`flex flex-col rounded-2xl border focus-within:ring-2 focus-within:ring-brand pointer-events-auto ${p?`border-border/50 bg-background/80 shadow-lg backdrop-blur-sm`:`border-border bg-background shadow-2xl`}`,Re;t[51]!==c||t[52]!==s?(Re=(0,$.jsx)(Ke,{queuedMessages:s,onRemoveQueuedMessage:c}),t[51]=c,t[52]=s,t[53]=Re):Re=t[53];let Be=F?`Describe what you want Tarsk to plan...`:L?`Describe the image you want to generate...`:`Ask Tarsk anything, # for files, / for commands & skills`,Ve;t[54]!==a||t[55]!==ge||t[56]!==ke||t[57]!==_e||t[58]!==x||t[59]!==Be||t[60]!==se?(Ve=(0,$.jsx)(`textarea`,{ref:se,value:x,onChange:_e,onKeyDown:ge,onPaste:ke,placeholder:Be,rows:1,className:`w-full resize-none bg-transparent px-6 pt-4 pb-4 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none`,disabled:a}),t[54]=a,t[55]=ge,t[56]=ke,t[57]=_e,t[58]=x,t[59]=Be,t[60]=se,t[61]=Ve):Ve=t[61];let He;t[62]!==Y||t[63]!==le||t[64]!==ye||t[65]!==be||t[66]!==U||t[67]!==W||t[68]!==q||t[69]!==K||t[70]!==G?(He=(0,$.jsx)(Ae,{visible:q,commands:G,skills:K,query:Y,selectedIndex:U,onSelectCommand:ye,onSelectSkill:be,onMouseEnterSuggestion:W,containerRef:le}),t[62]=Y,t[63]=le,t[64]=ye,t[65]=be,t[66]=U,t[67]=W,t[68]=q,t[69]=K,t[70]=G,t[71]=He):He=t[71];let qe;t[72]!==xe||t[73]!==ve||t[74]!==U||t[75]!==W||t[76]!==z||t[77]!==V||t[78]!==ce?(qe=(0,$.jsx)(Ie,{showSuggestions:z,fileSuggestions:xe,suggestionQuery:V,selectedIndex:U,onSelectFile:ve,onMouseEnterSuggestion:W,containerRef:ce}),t[72]=xe,t[73]=ve,t[74]=U,t[75]=W,t[76]=z,t[77]=V,t[78]=ce,t[79]=qe):qe=t[79];let Xe;t[80]!==N||t[81]!==A?.id||t[82]!==A?.name||t[83]!==A?.supportsImages||t[84]!==P?(Xe=N.length>0&&(0,$.jsxs)(`div`,{className:`px-4`,children:[(0,$.jsx)(Pe,{attachments:N,onRemove:e=>P(t=>t.filter((t,n)=>n!==e))}),N.some(Je)&&A?.supportsImages===!1&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs text-amber-500`,children:[(0,$.jsx)(l,{className:`h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[`Images are not supported by `,A?.name||A?.id]})]})]}),t[80]=N,t[81]=A?.id,t[82]=A?.name,t[83]=A?.supportsImages,t[84]=P,t[85]=Xe):Xe=t[85];let Ze;t[86]===oe?Ze=t[87]:(Ze=(0,$.jsx)(We,{onFileAttach:()=>oe.current?.click()}),t[86]=oe,t[87]=Ze);let Qe;t[88]===Me?Qe=t[89]:(Qe=(0,$.jsx)(Ge,{onToggleSpeech:Me}),t[88]=Me,t[89]=Qe);let $e=L?re:j,et;t[90]!==fe||t[91]!==X||t[92]!==$e?(et=(0,$.jsx)(ze,{availableModels:fe,selectedModel:X,onModelSelect:$e}),t[90]=fe,t[91]=X,t[92]=$e,t[93]=et):et=t[93];let tt;t[94]!==Ze||t[95]!==Qe||t[96]!==et?(tt=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Ze,Qe,et]}),t[94]=Ze,t[95]=Qe,t[96]=et,t[97]=tt):tt=t[97];let nt;t[98]!==L||t[99]!==F||t[100]!==ee||t[101]!==I?(nt=(0,$.jsx)(Ue,{planMode:F,imageMode:L,setPlanMode:I,setImageMode:ee}),t[98]=L,t[99]=F,t[100]=ee,t[101]=I,t[102]=nt):nt=t[102];let rt=d?r:he,it;t[103]!==N.length||t[104]!==a||t[105]!==X||t[106]!==d||t[107]!==x?(it=!d&&((a??!1)||!x.trim()&&N.length===0||!X),t[103]=N.length,t[104]=a,t[105]=X,t[106]=d,t[107]=x,t[108]=it):it=t[108];let at;t[109]===d?at=t[110]:(at=d?(0,$.jsx)(v,{className:`h-3 w-3 fill-current`}):(0,$.jsx)(M,{className:`h-3 w-3`}),t[109]=d,t[110]=at);let ot=d?`Stop generation`:`Send message`,st;t[111]===ot?st=t[112]:(st=(0,$.jsx)(`span`,{className:`sr-only`,children:ot}),t[111]=ot,t[112]=st);let ct;t[113]!==rt||t[114]!==it||t[115]!==at||t[116]!==st?(ct=(0,$.jsxs)(f,{size:`icon`,className:`h-7 w-7 rounded-full`,onClick:rt,disabled:it,children:[at,st]}),t[113]=rt,t[114]=it,t[115]=at,t[116]=st,t[117]=ct):ct=t[117];let lt;t[118]!==nt||t[119]!==ct?(lt=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[nt,ct]}),t[118]=nt,t[119]=ct,t[120]=lt):lt=t[120];let ut;t[121]!==tt||t[122]!==lt?(ut=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[tt,lt]}),t[121]=tt,t[122]=lt,t[123]=ut):ut=t[123];let dt;t[124]!==Le||t[125]!==Re||t[126]!==Ve||t[127]!==He||t[128]!==qe||t[129]!==Xe||t[130]!==ut?(dt=(0,$.jsxs)(`div`,{className:Le,children:[Re,Ve,He,qe,Xe,ut]}),t[124]=Le,t[125]=Re,t[126]=Ve,t[127]=He,t[128]=qe,t[129]=Xe,t[130]=ut,t[131]=dt):dt=t[131];let ft;t[132]===P?ft=t[133]:(ft=e=>Fe(e,e=>P(t=>[...t,...e])),t[132]=P,t[133]=ft);let pt;t[134]!==oe||t[135]!==ft?(pt=(0,$.jsx)(`input`,{ref:oe,type:`file`,multiple:!0,className:`hidden`,onChange:ft}),t[134]=oe,t[135]=ft,t[136]=pt):pt=t[136];let mt;return t[137]!==Ne||t[138]!==dt||t[139]!==pt?(mt=(0,$.jsxs)(`div`,{className:Ne,children:[dt,pt]}),t[137]=Ne,t[138]=dt,t[139]=pt,t[140]=mt):mt=t[140],mt}function Je(e){return e.mimeType.startsWith(`image/`)}function Ye(e){return e.type.startsWith(`image/`)}function Xe({threadId:e}){let[t,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{e&&L(e).then(a).catch(()=>{})},[e]),(0,$.jsx)(`div`,{className:`flex items-center justify-end gap-2 px-8 py-2 mt-[-1rem] min-h-[2.25rem]`,children:e&&(0,$.jsxs)(Y,{children:[(0,$.jsx)(ae,{asChild:!0,children:(0,$.jsx)(f,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-50 hover:opacity-80`,onClick:async()=>{if(!(!e||t)){r(!0);try{let t=await L(e);await navigator.clipboard.writeText(t)}finally{r(!1)}}},disabled:t,"aria-label":`Copy repository folder path`,children:(0,$.jsx)(n,{className:`h-3 w-3`})})}),(0,$.jsxs)(J,{side:`top`,className:`bg-slate-900 text-white`,children:[(0,$.jsx)(`div`,{children:`Copy repository folder path`}),i&&(0,$.jsx)(`div`,{className:`opacity-70 text-xs`,children:i})]})]})})}function Ze(e,t){if(!(!t||!e.includes(`"run_js"`)))try{let n=JSON.parse(e.trim());if(!Array.isArray(n))return;for(let e of n)e?.type===`tool_use`&&e?.name===`run_js`&&e?.id&&e?.input?.code&&xe(e.id,e.input.code,t)}catch{}}function Qe(){let{state:e,dispatch:t}=U(),[n,r]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(``),c=(0,Q.useRef)(``),l=(0,Q.useRef)([]),u=(0,Q.useRef)(!1),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(()=>{}),[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(!1),_=(0,Q.useRef)(!1),v=(0,Q.useRef)(null),y=(0,Q.useRef)(null),b=(0,Q.useRef)(null),{selectedThreadId:C,selectedProjectId:w,messages:E,queuedChatMessages:O,isStreaming:k,streamingModel:A,processingThreadIds:j}=e,M=!!(C&&j.includes(C)),N=(0,Q.useCallback)(n=>{if(d.current=null,f.current=null,g.current){g.current=!1;return}let r=l.current,i=G(r)||`...`;if(v.current&&(r.length===0||i===`...`)){let r={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${v.current}`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||n,isThinking:!1};t({type:K.AddMessage,message:r}),t({type:K.ResetStream}),C&&t({type:K.RemoveProcessingThread,threadId:C}),v.current=null;return}let a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:i,contentType:`markdown`,timestamp:new Date().toISOString(),model:e.streamingModel||n,isThinking:!1};s.current=``,c.current=``,l.current=[],v.current=null,t({type:K.AddMessage,message:a}),t({type:K.ResetStream}),C&&(t({type:K.MarkThreadCompleted,threadId:C}),t({type:K.RemoveProcessingThread,threadId:C}))},[e.streamingModel,t,C]);(0,Q.useEffect)(()=>{p.current=N},[N]);let P=(0,Q.useCallback)(()=>{C&&h(C),g.current=!0,C&&D(C),d.current&&=(d.current.abort(),null),f.current&&=(f.current(),null),s.current=``,c.current=``,l.current=[],v.current=null;let n={messageId:`msg-${Date.now()}-stopped`,sender:`agent`,content:`I've stopped working on your request.`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||`default`,isThinking:!1};t({type:K.AddMessage,message:n}),t({type:K.ResetStream}),C&&(t({type:K.MarkThreadCompleted,threadId:C}),t({type:K.RemoveProcessingThread,threadId:C}))},[C,t,e.streamingModel]);(0,Q.useEffect)(()=>{_.current&&!k&&d.current&&(d.current.abort(),d.current=null,f.current&&=(f.current(),null),p.current(A||`default`)),_.current=k},[k,A]),(0,Q.useEffect)(()=>{if(y.current&&=(clearTimeout(y.current),null),k){let e=12e4,t=n=>{y.current&&=(clearTimeout(y.current),null),y.current=setTimeout(()=>{let n=Date.now(),r=b?.current??null;if(r!=null){let i=n-r;if(i<e){t(e-i);return}}console.warn(`[stream-safety] Streaming stuck for 2 minutes with no activity, auto-finalizing`),d.current&&=(d.current.abort(),null),f.current&&=(f.current(),null),p.current(A||`default`)},n)},n=e;if(b?.current!=null){let t=Date.now()-b.current;n=t>=e?0:e-t}t(n)}return()=>{y.current&&=(clearTimeout(y.current),null)}},[k,A]),(0,Q.useEffect)(()=>()=>{d.current&&=(d.current.abort(),null),f.current&&=(f.current(),null),s.current=``,c.current=``,l.current=[],u.current=!1,v.current=null,t({type:K.ResetStream})},[C,t]),(0,Q.useEffect)(()=>{if(!C)return;let e=!1;async function n(){try{let n=await re(C);e||t({type:K.SetMessages,messages:n.messages})}catch(n){console.error(`Failed to load chat history:`,n),e||t({type:K.SetMessages,messages:[]})}}return n(),()=>{e=!0}},[C,w,t]),(0,Q.useEffect)(()=>{if(!C||!M||k)return;let e=new AbortController;return d.current=e,t({type:K.ResetStream}),t({type:K.SetStreaming,isStreaming:!0}),s.current=``,c.current=``,l.current=[],u.current=!1,v.current=null,te(C,e.signal).then(n=>{if(!n||e.signal.aborted){p.current(`default`);return}f.current=S(n,e=>{if(e.type===`error`){let t=e.content||`Unknown error occurred`;v.current=t,r(t);return}if(e.type!==`message`){if(e.type===`toolcall_delta`){e.partial?.content?.[0]?.id&&e.delta&&t({type:K.UpdateToolCallProgress,toolCallId:e.partial.content[0].id,progress:{toolCallId:e.partial.content[0].id,toolName:e.partial.content[0].name,delta:e.delta,partial:e.partial}});return}if(e.model&&t({type:K.SetStreamModel,model:e.model}),e.type===`thinking`||e.isThinking){let n=e.content??``;Ze(n,C),c.current+=n;let r=W(l.current,`thinking`,n);l.current=r,t({type:K.AppendStreamChunk,chunkType:`thinking`,content:n,segments:r})}else if(e.type===`result`)u.current=!0,s.current=e.content??``,l.current=q(l.current,e.content??``),t({type:K.SetStreamContent,content:e.content??``});else{if(u.current)return;s.current+=e.content??``;let n=W(l.current,`content`,e.content??``);l.current=n,t({type:K.AppendStreamChunk,chunkType:`content`,content:e.content??``,segments:n})}}},()=>{p.current(`default`)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){p.current(`default`);return}v.current=e,r(e)},e=>{if(e.role===`assistant`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(e.isThinking??!1){c.current+=r;let e=W(l.current,`thinking`,r);l.current=e,t({type:K.AppendStreamChunk,chunkType:`thinking`,content:r,segments:e});return}let i=!1;if(typeof n==`object`&&Array.isArray(n)&&n.length>0)i=!0;else if(typeof r==`string`&&r.trim().startsWith(`[`))try{let e=JSON.parse(r);i=Array.isArray(e)&&e.length>0}catch{}if(i)u.current=!0,s.current=r,l.current=q(l.current,r),t({type:K.SetStreamContent,content:r});else{s.current+=r;let e=W(l.current,`content`,r);l.current=e,t({type:K.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}else if(e.role===`tool`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(r){s.current+=r;let e=W(l.current,`content`,r);l.current=e,t({type:K.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}})}).catch(e=>{if(e instanceof Error&&e.name===`AbortError`){t({type:K.ResetStream});return}if(e instanceof Error&&e.message.includes(`not currently processing`)){t({type:K.ResetStream});return}console.error(`Failed to subscribe to chat stream:`,e),t({type:K.ResetStream})}),()=>{e.abort(),f.current&&=(f.current(),null)}},[C,M]);let F=(0,Q.useCallback)(async(n,a,m,g,_,y)=>{if(!C)return;r(null),h(null),d.current&&d.current.abort(),f.current&&f.current();let b=`msg-${Date.now()}`,E;try{let e=await i(C,b);e.success&&e.stashed&&e.checkpointRef&&(E=e.checkpointRef)}catch{}let D={messageId:b,sender:`user`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:a,attachments:m.map(e=>({fileName:e.fileName,content:e.content,mimeType:e.mimeType})),checkpointRef:E};t({type:K.AddMessage,message:D});let O=n.trim().replace(/\n/g,` `).slice(0,100);if(w&&C&&(T(C,{title:O}).catch(e=>{console.error(`Failed to update thread title:`,e)}),t({type:K.UpdateThreadTitle,projectId:w,threadId:C,title:O})),y){let e=g??void 0;if(!e&&typeof a==`string`){let t=a.split(/[:/]/)[0]?.trim();t&&(e=t)}if(!e){let e={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Image generation is not available because no provider is configured for the selected model.`,contentType:`text`,timestamp:new Date().toISOString(),model:a,isThinking:!1};t({type:K.AddMessage,message:e}),t({type:K.ResetStream});return}t({type:K.SetStreaming,isStreaming:!0});try{let r=await x(n,a,e,C),i={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:a,isThinking:!1,generatedImageUrl:r.imageUrl,generatedImageData:r.imageData};t({type:K.AddMessage,message:i})}catch(e){let n=e instanceof Error?e.message:`Image generation failed`,r={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${n}`,contentType:`text`,timestamp:new Date().toISOString(),model:a,isThinking:!1};t({type:K.AddMessage,message:r})}finally{t({type:K.ResetStream})}return}t({type:K.ResetStream}),t({type:K.SetStreaming,isStreaming:!0}),s.current=``,u.current=!1;let k=new AbortController;d.current=k;try{let i=await ee(C,n,a,m,k.signal,g,_);if(!i){p.current(a);return}f.current=S(i,n=>{if(n.type===`error`){let e=n.content||`Unknown error occurred`;v.current=e,r(e);return}if(n.type!==`message`){if(n.type===`toolcall_delta`){if(n.partial?.content?.[0]?.id&&n.delta){let e=n.partial.content[0].id,r=n.partial.content[0].name;t({type:K.UpdateToolCallProgress,toolCallId:e,progress:{toolCallId:e,toolName:r,delta:n.delta,partial:n.partial}})}return}if(n.model&&t({type:K.SetStreamModel,model:n.model}),n.type===`thinking`||n.isThinking){let r=n.content??``;Ze(r,e.selectedThreadId),c.current+=r;let i=W(l.current,`thinking`,r);l.current=i,t({type:K.AppendStreamChunk,chunkType:`thinking`,content:r,segments:i})}else if(n.type===`result`)u.current=!0,s.current=n.content??``,l.current=q(l.current,n.content??``),t({type:K.SetStreamContent,content:n.content??``});else{if(u.current)return;s.current+=n.content??``;let e=W(l.current,`content`,n.content??``);l.current=e,t({type:K.AppendStreamChunk,chunkType:`content`,content:n.content??``,segments:e})}}},()=>{p.current(a)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){p.current(a);return}v.current=e,r(e)},e=>{if(e.role===`assistant`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(e.isThinking??!1){c.current+=r;let e=W(l.current,`thinking`,r);l.current=e,t({type:K.AppendStreamChunk,chunkType:`thinking`,content:r,segments:e});return}let i=!1;if(typeof n==`object`&&Array.isArray(n)&&n.length>0)i=!0;else if(typeof r==`string`&&r.trim().startsWith(`[`))try{let e=JSON.parse(r);i=Array.isArray(e)&&e.length>0}catch{}if(i)u.current=!0,s.current=r,l.current=q(l.current,r),t({type:K.SetStreamContent,content:r});else{s.current+=r;let e=W(l.current,`content`,r);l.current=e,t({type:K.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}else if(e.role===`tool`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(r){s.current+=r;let e=W(l.current,`content`,r);l.current=e,t({type:K.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}})}catch(e){if(e instanceof Error&&e.name===`AbortError`||e instanceof Error&&e.message.includes(`BodyStreamBuffer was aborted`))return;if(e instanceof V){t({type:K.ResetStream}),o(!0);return}r(e instanceof Error?e.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`),v.current=e instanceof Error?e.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`,t({type:K.ResetStream})}},[C,w,t]);(0,Q.useEffect)(()=>{let n=e.pendingChatMessage;if(!n||k||n.threadId!==C)return;let r=setTimeout(()=>{t({type:K.ClearPendingChatMessage}),F(n.message,n.model,[],n.provider)},100);return()=>clearTimeout(r)},[e.pendingChatMessage,k,C,t,F]);let I=(0,Q.useMemo)(()=>C?O.filter(e=>e.threadId===C):[],[C,O]),L=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{if(k||!C||I.length===0||L.current)return;let[e]=I;L.current=!0,t({type:K.RemoveQueuedChatMessage,queuedMessageId:e.id});let n=setTimeout(()=>{F(e.message,e.model,e.attachments,e.provider,e.planMode),L.current=!1},0);return()=>{clearTimeout(n),L.current=!1}},[t,F,k,I,C]),{error:n,setError:r,handleSend:F,handleStop:P,isStreaming:k,selectedThreadId:C,queuedMessagesForThread:I,handleRemoveQueuedMessage:(0,Q.useCallback)(e=>{let n=I.find(t=>t.id===e);t({type:K.RemoveQueuedChatMessage,queuedMessageId:e}),!(!n||k||E.length>0||!C)&&F(n.message,n.model,n.attachments,n.provider,n.planMode)},[t,F,k,E.length,I,C]),showEmptyBalanceDialog:a,setShowEmptyBalanceDialog:o}}function $e(e){let t=(0,Z.c)(10),{open:n,onClose:r}=e,i=H(),a;t[0]===r?a=t[1]:(a=e=>{e||r()},t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(ue,{children:[(0,$.jsx)(se,{children:`Balance empty`}),(0,$.jsx)(oe,{children:`You have no prompts remaining. Purchase additional prompts to continue.`})]}),t[2]=o):o=t[2];let s;t[3]!==i||t[4]!==r?(s=(0,$.jsxs)(ce,{children:[o,(0,$.jsx)(le,{children:(0,$.jsx)(f,{onClick:()=>{r(),i(`/settings/account`)},children:`Go to Account`})})]}),t[3]=i,t[4]=r,t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==a||t[8]!==s?(c=(0,$.jsx)(de,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}var et=3e4;function tt(e){let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(void 0),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(`Up to date`),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(void 0),[D,O]=(0,Q.useState)(void 0),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),P=(0,Q.useRef)(!0),F=(0,Q.useCallback)(e=>{n(e.hasChanges),i(e.changedFilesCount),o(e.hasUnpushedCommits),c(e.currentBranch),v(e.hasRemoteBranch),u(e.isOnGitHub),f(e.remoteUrl),m(e.canCreateRepo),g(e.repoUrl),b(e.status),S(e.defaultBranch??null),w(e.prExists),E(e.prUrl),O(e.prState),A(e.commitsAheadOfDefault??!1)},[]),I=(0,Q.useCallback)(async(t=!1)=>{if(!e)return;let n=setTimeout(()=>M(!0),100);try{let n=`unified-git-status-${e}`;t&&B.invalidate(n),F(await B.get(n,()=>N(e,t),et))}catch(e){console.error(`Failed to fetch unified git status:`,e)}finally{clearTimeout(n),M(!1)}},[e,F]);return(0,Q.useEffect)(()=>{e&&(async()=>{if(P.current){let t=`unified-git-status-${e}`,n=B.getSync(t);n&&F(n),P.current=!1}await I()})()},[e,I,F]),{hasChanges:t,changedFilesCount:r,hasUnpushedCommits:a,hasRemoteBranch:_,currentBranch:s,isOnGitHub:l,remoteUrl:d,canCreateRepo:p,repoUrl:h,status:y,defaultBranch:x,prExists:C,prUrl:T,prState:D,commitsAheadOfDefault:k,isRefreshing:j,fetchUnifiedStatus:I}}function nt(e){let t=(0,Z.c)(34),{messages:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?[]:n,t[0]=n,t[1]=r);let i=r,{state:o,dispatch:s}=U(),{isCreatingProject:c,selectedThreadId:l}=o,{handleSend:u,handleStop:d,isStreaming:p,queuedMessagesForThread:h,handleRemoveQueuedMessage:g,showEmptyBalanceDialog:_,setShowEmptyBalanceDialog:v}=Qe(),y=o.pendingChatMessage?.threadId===l,b=p||y,x=i.length>0,{hasChanges:S,changedFilesCount:C}=tt(l??void 0),{setActiveMainTab:w}=X(),T;t[2]!==s||t[3]!==l?(T=async()=>{if(l)try{let e=await z(l);s({type:K.ClearMessages}),console.log(`New conversation started:`,e);let t=await re(l);s({type:K.SetMessages,messages:t.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},t[2]=s,t[3]=l,t[4]=T):T=t[4];let E=T,D;t[5]===v?D=t[6]:(D=()=>v(!1),t[5]=v,t[6]=D);let O;t[7]!==_||t[8]!==D?(O=(0,$.jsx)($e,{open:_,onClose:D}),t[7]=_,t[8]=D,t[9]=O):O=t[9];let k;t[10]!==C||t[11]!==E||t[12]!==S||t[13]!==x||t[14]!==w?(k=x&&(0,$.jsxs)(`div`,{className:`absolute -top-8 left-0 z-10 ml-8`,children:[(0,$.jsxs)(f,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs bg-background`,onClick:E,children:[(0,$.jsx)(m,{className:`h-3.5 w-3.5 mr-1`}),`New Chat`]}),S&&(0,$.jsxs)(f,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs bg-background ml-2`,onClick:()=>w(`review`),children:[(0,$.jsx)(a,{className:`h-3.5 w-3.5 mr-1`}),C,` `,C===1?`File`:`Files`,` Changed`]})]}),t[10]=C,t[11]=E,t[12]=S,t[13]=x,t[14]=w,t[15]=k):k=t[15];let A=!l&&!c,j;t[16]!==b||t[17]!==g||t[18]!==u||t[19]!==d||t[20]!==h||t[21]!==A?(j=(0,$.jsx)(qe,{onSend:u,onStop:d,isStreaming:b,disabled:A,initialValue:``,queuedMessages:h,onRemoveQueuedMessage:g,isOverlay:!1}),t[16]=b,t[17]=g,t[18]=u,t[19]=d,t[20]=h,t[21]=A,t[22]=j):j=t[22];let M;t[23]!==k||t[24]!==j?(M=(0,$.jsxs)(`div`,{className:`relative`,children:[k,j]}),t[23]=k,t[24]=j,t[25]=M):M=t[25];let N=l??void 0,P;t[26]===N?P=t[27]:(P=(0,$.jsx)(Xe,{threadId:N}),t[26]=N,t[27]=P);let F;t[28]!==P||t[29]!==M?(F=(0,$.jsxs)(`div`,{className:`relative mx-auto min-w-[400px] w-[90vw] max-w-3xl`,children:[M,P]}),t[28]=P,t[29]=M,t[30]=F):F=t[30];let I;return t[31]!==F||t[32]!==O?(I=(0,$.jsxs)($.Fragment,{children:[O,F]}),t[31]=F,t[32]=O,t[33]=I):I=t[33],I}export{ve as a,_e as i,tt as n,me as o,xe as r,nt as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Ki as n,Wn as r,Zi as i,ca as a,ea as o,ua as s}from"./dialogs-config-Dwpv4SNp.js";import{a as c,d as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,s as _,t as v,u as y}from"./react-vendor-CYvpNUsM.js";var b=a(),x=e(s(),1),S=t(),C=y,w=u,T=x.forwardRef((e,t)=>{let n=(0,b.c)(14),a,o,s,c;n[0]===e?(a=n[1],o=n[2],s=n[3],c=n[4]):({className:o,inset:s,children:a,...c}=e,n[0]=e,n[1]=a,n[2]=o,n[3]=s,n[4]=c);let l=s&&`pl-8`,u;n[5]!==o||n[6]!==l?(u=r(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,l,o),n[5]=o,n[6]=l,n[7]=u):u=n[7];let d;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,S.jsx)(i,{className:`ml-auto h-4 w-4`}),n[8]=d):d=n[8];let f;return n[9]!==a||n[10]!==c||n[11]!==t||n[12]!==u?(f=(0,S.jsxs)(p,{ref:t,className:u,...c,children:[a,d]}),n[9]=a,n[10]=c,n[11]=t,n[12]=u,n[13]=f):f=n[13],f});T.displayName=p.displayName;var E=x.forwardRef((e,t)=>{let n=(0,b.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,S.jsx)(g,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});E.displayName=g.displayName;var D=x.forwardRef((e,t)=>{let n=(0,b.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,S.jsx)(_,{children:(0,S.jsx)(m,{ref:t,className:o,...a})}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});D.displayName=m.displayName;var O=x.forwardRef((e,t)=>{let n=(0,b.c)(11),i,a,o;n[0]===e?(i=n[1],a=n[2],o=n[3]):({className:i,inset:a,...o}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=o);let s=a&&`pl-8`,c;n[4]!==i||n[5]!==s?(c=r(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,s,i),n[4]=i,n[5]=s,n[6]=c):c=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==c?(l=(0,S.jsx)(d,{ref:t,className:c,...o}),n[7]=o,n[8]=t,n[9]=c,n[10]=l):l=n[10],l});O.displayName=d.displayName;var k=x.forwardRef((e,t)=>{let n=(0,b.c)(14),i,a,s,l;n[0]===e?(i=n[1],a=n[2],s=n[3],l=n[4]):({className:s,children:a,checked:i,...l}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=s,n[4]=l);let u;n[5]===s?u=n[6]:(u=r(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,s),n[5]=s,n[6]=u);let d;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(c,{children:(0,S.jsx)(o,{className:`h-4 w-4`})})}),n[7]=d):d=n[7];let f;return n[8]!==i||n[9]!==a||n[10]!==l||n[11]!==t||n[12]!==u?(f=(0,S.jsxs)(v,{ref:t,className:u,checked:i,...l,children:[d,a]}),n[8]=i,n[9]=a,n[10]=l,n[11]=t,n[12]=u,n[13]=f):f=n[13],f});k.displayName=v.displayName;var A=x.forwardRef((e,t)=>{let i=(0,b.c)(12),a,o,s;i[0]===e?(a=i[1],o=i[2],s=i[3]):({className:o,children:a,...s}=e,i[0]=e,i[1]=a,i[2]=o,i[3]=s);let l;i[4]===o?l=i[5]:(l=r(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,o),i[4]=o,i[5]=l);let u;i[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(c,{children:(0,S.jsx)(n,{className:`h-2 w-2 fill-current`})})}),i[6]=u):u=i[6];let d;return i[7]!==a||i[8]!==s||i[9]!==t||i[10]!==l?(d=(0,S.jsxs)(f,{ref:t,className:l,...s,children:[u,a]}),i[7]=a,i[8]=s,i[9]=t,i[10]=l,i[11]=d):d=i[11],d});A.displayName=f.displayName;var j=x.forwardRef((e,t)=>{let n=(0,b.c)(11),i,a,o;n[0]===e?(i=n[1],a=n[2],o=n[3]):({className:i,inset:a,...o}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=o);let s=a&&`pl-8`,c;n[4]!==i||n[5]!==s?(c=r(`px-2 py-1.5 text-sm font-semibold text-foreground`,s,i),n[4]=i,n[5]=s,n[6]=c):c=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==c?(l=(0,S.jsx)(h,{ref:t,className:c,...o}),n[7]=o,n[8]=t,n[9]=c,n[10]=l):l=n[10],l});j.displayName=h.displayName;var M=x.forwardRef((e,t)=>{let n=(0,b.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`-mx-1 my-1 h-px bg-border`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,S.jsx)(l,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});M.displayName=l.displayName;var N=e=>{let t=(0,b.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`ml-auto text-xs tracking-widest text-muted-foreground`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,S.jsx)(`span`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};N.displayName=`ContextMenuShortcut`;export{w as a,M as i,D as n,O as r,C as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./history-view-BvAOaO8q.js";export{e as ConversationHistoryView,e as default};
@@ -48,4 +48,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
48
48
  Is it ok to install Vite Plus using the following command?
49
49
 
50
50
  macOS / Linux: curl -fsSL https://vite.plus | bash
51
- Windows: irm https://vite.plus/ps1 | iex`)){O(!1);return}let{success:e,error:t}=await FI();if(!e){window.alert(`Failed to install Vite Plus:\n${t||`Unknown error`}`),O(!1);return}}}catch(e){console.error(`Vite Plus check/install failed:`,e)}finally{O(!1)}}let e=ne.trim();g(``),v(!1),u(1),t(!1),s(`choice`),i(e,N,x).catch(()=>{})},de=e=>e.trim().toLowerCase().replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``),I=o===`choice`?1:c,fe=e=>e===1?I>1:e===2?I>=2:e===3?I>=2&&(o===`clone`?d.trim().length>0:ce):!1,pe=e=>{e===1?(s(`choice`),u(1),f(``),g(``)):u(e)};return(0,V.jsx)(ZP,{open:e,onOpenChange:e=>!e&&oe(),children:(0,V.jsxs)(eF,{className:`max-w-2xl h-[min(42rem,90dvh)] flex flex-col p-0 overflow-hidden`,children:[(0,V.jsxs)(`div`,{className:`px-6 pt-6 pb-2`,children:[(0,V.jsxs)(`div`,{className:`mx-auto flex items-center gap-1 mb-6 w-2/3`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>fe(1)&&pe(1),className:K(`flex items-center justify-center h-8 w-8 rounded-full text-sm font-medium shrink-0 transition-colors transition-transform duration-300 ease-out`,I===1?`bg-primary text-primary-foreground scale-110`:I>1?`bg-brand text-brand-foreground`:`bg-muted text-muted-foreground`,fe(1)&&`cursor-pointer hover:opacity-90`),"aria-label":`Go to step 1`,children:`1`}),(0,V.jsx)(`div`,{className:`h-0.5 flex-1 min-w-0 relative rounded-full overflow-hidden bg-muted`,children:(0,V.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-brand transition-[width] duration-300 ease-out rounded-full`,style:{width:I>=2?`100%`:`0%`}})}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>fe(2)&&pe(2),className:K(`flex items-center justify-center h-8 w-8 rounded-full text-sm font-medium shrink-0 transition-colors transition-transform duration-300 ease-out`,I===2?`bg-primary text-primary-foreground scale-110`:I>2?`bg-brand text-brand-foreground`:`bg-muted text-muted-foreground`,fe(2)&&`cursor-pointer hover:opacity-90`),"aria-label":`Go to step 2`,children:`2`}),(0,V.jsx)(`div`,{className:`h-0.5 flex-1 min-w-0 relative rounded-full overflow-hidden bg-muted`,children:(0,V.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-brand transition-[width] duration-300 ease-out rounded-full`,style:{width:I>=3?`100%`:`0%`}})}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>fe(3)&&pe(3),className:K(`flex items-center justify-center h-8 w-8 rounded-full text-sm font-medium shrink-0 transition-colors transition-transform duration-300 ease-out`,I===3?`bg-primary text-primary-foreground scale-110`:`bg-muted text-muted-foreground`,fe(3)&&`cursor-pointer hover:opacity-90`),"aria-label":`Go to step 3`,children:`3`})]}),(0,V.jsxs)(tF,{children:[(0,V.jsxs)(rF,{children:[I===1&&`New Project`,I===2&&o===`clone`&&`Clone Repository`,I===2&&o===`webapp`&&`Create App`,I===3&&o===`clone`&&`Clone Repository`,I===3&&o===`webapp`&&(P===`Capacitor Plugin`?`Create Capacitor Plugin`:P?`Create ${P} App`:`Create App`)]}),(0,V.jsxs)(iF,{children:[I===1&&`Choose how to add a new project.`,I===2&&o===`clone`&&`Enter a git repository URL to clone.`,I===2&&o===`webapp`&&`Choose a template type.`,I===3&&o===`clone`&&`Choose commit workflow.`,I===3&&o===`webapp`&&`Name your project and choose variation, package manager, and commit workflow.`]})]})]}),I===1&&(0,V.jsx)(hI,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,V.jsx)(`div`,{className:`px-6 py-4`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,V.jsx)(wz,{role:`button`,tabIndex:0,className:`cursor-pointer transition-colors hover:border-primary/50 hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:ae,onKeyDown:e=>e.key===`Enter`&&ae(),children:(0,V.jsxs)(Oz,{className:`flex items-start gap-4 p-4`,children:[(0,V.jsx)(`div`,{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-brand text-brand-foreground`,children:(0,V.jsx)(sp,{className:`h-6 w-6`})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,V.jsx)(`p`,{className:`font-semibold`,children:`Clone repo`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connect an existing repository by URL`})]})]})}),(0,V.jsx)(wz,{role:`button`,tabIndex:0,className:`cursor-pointer transition-colors hover:border-primary/50 hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:ie,onKeyDown:e=>e.key===`Enter`&&ie(),children:(0,V.jsxs)(Oz,{className:`flex items-start gap-4 p-4`,children:[(0,V.jsx)(`div`,{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-brand text-brand-foreground`,children:(0,V.jsx)(ub,{className:`h-6 w-6`})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,V.jsx)(`p`,{className:`font-semibold`,children:`Create App`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Scaffold a new React, Vue, Next.js, or other template`})]})]})}),(0,V.jsx)(wz,{role:`button`,tabIndex:0,className:`cursor-pointer transition-colors hover:border-primary/50 hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>{oe(),a()},onKeyDown:e=>{e.key===`Enter`&&(oe(),a())},children:(0,V.jsxs)(Oz,{className:`flex items-start gap-4 p-4`,children:[(0,V.jsx)(`div`,{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-brand text-brand-foreground`,children:(0,V.jsx)(yf,{className:`h-6 w-6`})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,V.jsx)(`p`,{className:`font-semibold`,children:`Open Folder`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Create a project from an existing local folder`})]})]})})]})})}),I===2&&o===`clone`&&(0,V.jsx)(hI,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,V.jsx)(`div`,{className:`px-6 py-4`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(DF,{htmlFor:`gitUrl`,children:`Repository URL`}),(0,V.jsx)(xF,{id:`gitUrl`,placeholder:`https://github.com/user/repo.git`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.key===`Enter`&&ce&&u(3)})]})})}),I===2&&o===`webapp`&&(0,V.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 px-6 pb-4`,children:(0,V.jsx)(`div`,{className:`flex-1 min-h-0 flex flex-col py-2`,children:(0,V.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto -mx-1`,children:(0,V.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2 p-1 mr-2`,children:T?(0,V.jsx)(`p`,{className:`col-span-full p-4 text-sm text-muted-foreground`,children:`Loading…`}):A.map(e=>{let t=j[e]?.[0]?.type,n=t?nB[t]:null;return(0,V.jsxs)(`button`,{type:`button`,onClick:()=>b(M[e]??``),onDoubleClick:()=>{b(M[e]??``),u(3)},className:K(`flex flex-col items-center gap-2 rounded-lg border px-3 py-3 text-center transition-colors`,P===e?`border-primary bg-accent text-accent-foreground`:`border-border bg-card hover:bg-muted/50 hover:border-muted-foreground/30 shadow-sm`),children:[n?(0,V.jsx)(`img`,{src:`/template-types/${n}`,alt:``,className:K(`size-8 shrink-0 transition-opacity duration-300`,ee.has(n)?`opacity-100`:`opacity-0`),onLoad:()=>te(n),"aria-hidden":!0}):null,(0,V.jsx)(`span`,{className:`font-medium text-sm truncate w-full`,children:e})]},e)})})})})}),I===3&&o===`webapp`&&(0,V.jsx)(hI,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,V.jsxs)(`div`,{className:`px-6 py-4 flex flex-col gap-6`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(DF,{htmlFor:`projectName`,children:`Project name`}),(0,V.jsx)(xF,{id:`projectName`,placeholder:`My App`,value:ne,onChange:e=>{g(e.target.value),v(!0)},className:`max-w-xs`})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[F.length>1&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(DF,{className:`text-sm font-medium`,children:`Variation`}),(0,V.jsx)($z,{type:`single`,value:N,onValueChange:e=>e&&b(e),variant:`outline`,className:`flex flex-wrap gap-0 justify-start [&>button]:rounded-none [&>button:first-child]:rounded-l-md [&>button:last-child]:rounded-r-md [&>button:not(:first-child)]:-ml-px`,children:F.map(e=>(0,V.jsx)(eB,{value:e.id,className:`text-sm`,children:e.variationName},e.id))})]}),(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[re?.description??F[0]?.description??``,re?.url&&(0,V.jsxs)(V.Fragment,{children:[` `,(0,V.jsxs)(`a`,{href:re.url,target:`_blank`,rel:`noreferrer`,className:`text-brand hover:underline hover:text-brand/80 inline-flex items-center gap-0.5`,children:[`Documentation `,(0,V.jsx)(mu,{className:`h-3 w-3`})]})]})]})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,V.jsx)(DF,{className:`text-sm font-medium`,children:`Package manager`}),(0,V.jsx)($z,{type:`single`,value:x,onValueChange:e=>{e&&(S(e),HR(e))},variant:`outline`,className:`flex flex-wrap gap-0 justify-start [&>button]:rounded-none [&>button:first-child]:rounded-l-md [&>button:last-child]:rounded-r-md [&>button:not(:first-child)]:-ml-px`,children:Object.values(Cz).map(e=>(0,V.jsx)(eB,{value:e.id,className:`text-sm`,children:e.label},e.id))})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,V.jsx)(DF,{className:`text-sm font-medium`,children:`Commit method`}),(0,V.jsxs)($z,{type:`single`,value:p,onValueChange:e=>{(e===$.PullRequest||e===$.Direct)&&(m(e),WR(e))},variant:`outline`,className:`flex flex-wrap gap-0 justify-start [&>button]:rounded-none [&>button:first-child]:rounded-l-md [&>button:last-child]:rounded-r-md [&>button:not(:first-child)]:-ml-px`,children:[(0,V.jsx)(eB,{value:$.PullRequest,className:`text-sm`,children:`Pull Requests`}),(0,V.jsx)(eB,{value:$.Direct,className:`text-sm`,children:`Direct Commits`})]}),(0,V.jsx)(`p`,{className:`text-xs text-slate-600 dark:text-slate-400`,children:p===$.PullRequest?`Creates a feature branch and allows you to create pull requests.`:`Commits directly to the main branch without creating feature branches.`})]})]})}),I===3&&o===`clone`&&(0,V.jsx)(hI,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,V.jsx)(`div`,{className:`px-6 py-4 flex flex-col gap-6`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,V.jsx)(DF,{className:`text-sm font-medium`,children:`Commit method`}),(0,V.jsxs)($z,{type:`single`,value:p,onValueChange:e=>{(e===$.PullRequest||e===$.Direct)&&(m(e),WR(e))},variant:`outline`,className:`flex flex-wrap gap-0 justify-start [&>button]:rounded-none [&>button:first-child]:rounded-l-md [&>button:last-child]:rounded-r-md [&>button:not(:first-child)]:-ml-px`,children:[(0,V.jsx)(eB,{value:$.PullRequest,className:`text-sm`,children:`Pull Requests`}),(0,V.jsx)(eB,{value:$.Direct,className:`text-sm`,children:`Direct Commits`})]}),(0,V.jsx)(`p`,{className:`text-xs text-slate-600 dark:text-slate-400`,children:p===$.PullRequest?`Creates a feature branch and allows you to create pull requests.`:`Commits directly to the main branch without creating feature branches.`})]})})}),(0,V.jsx)(`div`,{className:`px-6 py-4 border-t border-border bg-muted/10 min-h-[4.5rem] flex flex-col justify-end`,children:(0,V.jsxs)(nF,{children:[I>1&&(0,V.jsx)(bF,{variant:`ghost`,onClick:se,children:`Back`}),I===2&&(0,V.jsx)(bF,{onClick:()=>u(3),disabled:!ce,children:`Next`}),I===3&&o===`clone`&&(0,V.jsx)(bF,{onClick:le,children:`Clone Repository`}),I===3&&o===`webapp`&&(0,V.jsx)(bF,{onClick:ue,disabled:!ne.trim()||D,children:D?`Preparing...`:`Create App`})]})})]})})}export{yL as $,Ma as $i,GN as $n,ex as $r,XL as $t,II as A,uf as Ai,AF as An,wA as Ar,hR as At,FR as B,Wc as Bi,iF as Bn,_E as Br,zL as Bt,sR as C,zp as Ci,X as Cn,IA as Cr,LI as Ct,HL as D,sp as Di,Y as Dn,MA as Dr,jR as Dt,TL as E,cp as Ei,CI as En,z as Er,QL as Et,GL as F,gu as Fi,yF as Fn,lO as Fr,PL as Ft,bL as G,Qo as Gi,XP as Gn,AC as Gr,BI as Gt,vL as H,Pc as Hi,tF as Hn,L as Hr,TR as Ht,OR as I,mu as Ii,vF as In,UD as Ir,FL as It,OL as J,oo as Ji,JP as Jn,vC as Jr,fL as Jt,gL as K,Uo as Ki,qP as Kn,kC as Kr,JI as Kt,XI as L,Rl as Li,uF as Ln,fD as Lr,LL as Lt,QI as M,_d as Mi,DF as Mn,YO as Mr,RL as Mt,PR as N,Bu as Ni,xF as Nn,yO as Nr,kL as Nt,VL as O,Af as Oi,SI as On,OA as Or,AR as Ot,NR as P,_u as Pi,bF as Pn,vO as Pr,IL as Pt,xL as Q,Va as Qi,KN as Qn,ix as Qr,qL as Qt,pR as R,Ml as Ri,ZP as Rn,QE as Rr,jL as Rt,_R as S,Gp as Si,TI as Sn,RA as Sr,RI as St,cR as T,bp as Ti,vI as Tn,B as Tr,dR as Tt,SL as U,ic as Ui,rF as Un,Rw as Ur,ZI as Ut,CL as V,Ic as Vi,nF as Vn,oE as Vr,ML as Vt,_L as W,Ms as Wi,K as Wn,Ow as Wr,rR as Wt,NL as X,Ga as Xi,qN as Xn,DS as Xr,lR as Xt,wL as Y,Ka as Yi,XN as Yn,pC as Yr,lL as Yt,VI as Z,Wa as Zi,YN as Zn,TS as Zr,UL as Zt,XR as _,sg as _i,pL as _n,YA as _r,wR as _t,Ez as a,et as aa,cy as ai,nL as an,cN as ar,aR as at,AI as b,Xm as bi,eL as bn,UA as br,YL as bt,xz as c,o as ca,mv as ci,cL as cn,Rj as cr,GI as ct,ez as d,nv as di,yR as dn,vj as dr,oR as dt,Kr as ea,ub as ei,WL as en,UN as er,HI as et,qR as f,ev as fi,bR as fn,uj as fr,KL as ft,JR as g,Sg as gi,hL as gn,nj as gr,xR as gt,ZR as h,Og as hi,uL as hn,H as hr,CR as ht,Tz as i,st as ia,Iy as ii,MR as in,dN as ir,gR as it,fR as j,Ed as ji,kF as jn,mk as jr,DL as jt,qI as k,yf as ki,hI as kn,TA as kr,JL as kt,lz as l,i as la,dv as li,nR as ln,Ij as lr,ER as lt,$R as m,f_ as mi,eR as mn,U as mr,kR as mt,wz as n,vr as na,Zy as ni,DR as nn,WN as nr,iL as nt,$ as o,We as oa,kv as oi,aL as on,$M as or,BL as ot,YR as p,y_ as pi,oL as pn,_j as pr,SR as pt,tL as q,_o as qi,YP as qn,OC as qr,dL as qt,Oz as r,xt as ra,qy as ri,zI as rn,RN as rr,mR as rt,Sz as s,c as sa,Ov as si,tR as sn,Uj as sr,WI as st,tB as t,Lr as ta,lb as ti,EL as tn,JN as tr,rL as tt,tz as u,rv as ui,ZL as un,Cj as ur,$L as ut,QR as v,vh as vi,mL as vn,QA as vr,UI as vt,sL as w,xp as wi,J as wn,PA as wr,uR as wt,vR as x,Mm as xi,Z as xn,BA as xr,KI as xt,jI as y,eh as yi,iR as yn,GA as yr,YI as yt,$I as z,Xc as zi,eF as zn,NE as zr,AL as zt};
51
+ Windows: irm https://vite.plus/ps1 | iex`)){O(!1);return}let{success:e,error:t}=await FI();if(!e){window.alert(`Failed to install Vite Plus:\n${t||`Unknown error`}`),O(!1);return}}}catch(e){console.error(`Vite Plus check/install failed:`,e)}finally{O(!1)}}let e=ne.trim();g(``),v(!1),u(1),t(!1),s(`choice`),i(e,N,x).catch(()=>{})},de=e=>e.trim().toLowerCase().replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``),I=o===`choice`?1:c,fe=e=>e===1?I>1:e===2?I>=2:e===3?I>=2&&(o===`clone`?d.trim().length>0:ce):!1,pe=e=>{e===1?(s(`choice`),u(1),f(``),g(``)):u(e)};return(0,V.jsx)(ZP,{open:e,onOpenChange:e=>!e&&oe(),children:(0,V.jsxs)(eF,{className:`max-w-2xl h-[min(42rem,90dvh)] flex flex-col p-0 overflow-hidden`,children:[(0,V.jsxs)(`div`,{className:`px-6 pt-6 pb-2`,children:[(0,V.jsxs)(`div`,{className:`mx-auto flex items-center gap-1 mb-6 w-2/3`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>fe(1)&&pe(1),className:K(`flex items-center justify-center h-8 w-8 rounded-full text-sm font-medium shrink-0 transition-colors transition-transform duration-300 ease-out`,I===1?`bg-primary text-primary-foreground scale-110`:I>1?`bg-brand text-brand-foreground`:`bg-muted text-muted-foreground`,fe(1)&&`cursor-pointer hover:opacity-90`),"aria-label":`Go to step 1`,children:`1`}),(0,V.jsx)(`div`,{className:`h-0.5 flex-1 min-w-0 relative rounded-full overflow-hidden bg-muted`,children:(0,V.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-brand transition-[width] duration-300 ease-out rounded-full`,style:{width:I>=2?`100%`:`0%`}})}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>fe(2)&&pe(2),className:K(`flex items-center justify-center h-8 w-8 rounded-full text-sm font-medium shrink-0 transition-colors transition-transform duration-300 ease-out`,I===2?`bg-primary text-primary-foreground scale-110`:I>2?`bg-brand text-brand-foreground`:`bg-muted text-muted-foreground`,fe(2)&&`cursor-pointer hover:opacity-90`),"aria-label":`Go to step 2`,children:`2`}),(0,V.jsx)(`div`,{className:`h-0.5 flex-1 min-w-0 relative rounded-full overflow-hidden bg-muted`,children:(0,V.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-brand transition-[width] duration-300 ease-out rounded-full`,style:{width:I>=3?`100%`:`0%`}})}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>fe(3)&&pe(3),className:K(`flex items-center justify-center h-8 w-8 rounded-full text-sm font-medium shrink-0 transition-colors transition-transform duration-300 ease-out`,I===3?`bg-primary text-primary-foreground scale-110`:`bg-muted text-muted-foreground`,fe(3)&&`cursor-pointer hover:opacity-90`),"aria-label":`Go to step 3`,children:`3`})]}),(0,V.jsxs)(tF,{children:[(0,V.jsxs)(rF,{children:[I===1&&`New Project`,I===2&&o===`clone`&&`Clone Repository`,I===2&&o===`webapp`&&`Create App`,I===3&&o===`clone`&&`Clone Repository`,I===3&&o===`webapp`&&(P===`Capacitor Plugin`?`Create Capacitor Plugin`:P?`Create ${P} App`:`Create App`)]}),(0,V.jsxs)(iF,{children:[I===1&&`Choose how to add a new project.`,I===2&&o===`clone`&&`Enter a git repository URL to clone.`,I===2&&o===`webapp`&&`Choose a template type.`,I===3&&o===`clone`&&`Choose commit workflow.`,I===3&&o===`webapp`&&`Name your project and choose variation, package manager, and commit workflow.`]})]})]}),I===1&&(0,V.jsx)(hI,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,V.jsx)(`div`,{className:`px-6 py-4`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,V.jsx)(wz,{role:`button`,tabIndex:0,className:`cursor-pointer transition-colors hover:border-primary/50 hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:ae,onKeyDown:e=>e.key===`Enter`&&ae(),children:(0,V.jsxs)(Oz,{className:`flex items-start gap-4 p-4`,children:[(0,V.jsx)(`div`,{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-brand text-brand-foreground`,children:(0,V.jsx)(sp,{className:`h-6 w-6`})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,V.jsx)(`p`,{className:`font-semibold`,children:`Clone repo`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connect an existing repository by URL`})]})]})}),(0,V.jsx)(wz,{role:`button`,tabIndex:0,className:`cursor-pointer transition-colors hover:border-primary/50 hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:ie,onKeyDown:e=>e.key===`Enter`&&ie(),children:(0,V.jsxs)(Oz,{className:`flex items-start gap-4 p-4`,children:[(0,V.jsx)(`div`,{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-brand text-brand-foreground`,children:(0,V.jsx)(ub,{className:`h-6 w-6`})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,V.jsx)(`p`,{className:`font-semibold`,children:`Create App`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Scaffold a new React, Vue, Next.js, or other template`})]})]})}),(0,V.jsx)(wz,{role:`button`,tabIndex:0,className:`cursor-pointer transition-colors hover:border-primary/50 hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>{oe(),a()},onKeyDown:e=>{e.key===`Enter`&&(oe(),a())},children:(0,V.jsxs)(Oz,{className:`flex items-start gap-4 p-4`,children:[(0,V.jsx)(`div`,{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-brand text-brand-foreground`,children:(0,V.jsx)(yf,{className:`h-6 w-6`})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,V.jsx)(`p`,{className:`font-semibold`,children:`Open Folder`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Create a project from an existing local folder`})]})]})})]})})}),I===2&&o===`clone`&&(0,V.jsx)(hI,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,V.jsx)(`div`,{className:`px-6 py-4`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(DF,{htmlFor:`gitUrl`,children:`Repository URL`}),(0,V.jsx)(xF,{id:`gitUrl`,placeholder:`https://github.com/user/repo.git`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.key===`Enter`&&ce&&u(3)})]})})}),I===2&&o===`webapp`&&(0,V.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 px-6 pb-4`,children:(0,V.jsx)(`div`,{className:`flex-1 min-h-0 flex flex-col py-2`,children:(0,V.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto -mx-1`,children:(0,V.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2 p-1 mr-2`,children:T?(0,V.jsx)(`p`,{className:`col-span-full p-4 text-sm text-muted-foreground`,children:`Loading…`}):A.map(e=>{let t=j[e]?.[0]?.type,n=t?nB[t]:null;return(0,V.jsxs)(`button`,{type:`button`,onClick:()=>b(M[e]??``),onDoubleClick:()=>{b(M[e]??``),u(3)},className:K(`flex flex-col items-center gap-2 rounded-lg border px-3 py-3 text-center transition-colors`,P===e?`border-primary bg-accent text-accent-foreground`:`border-border bg-card hover:bg-muted/50 hover:border-muted-foreground/30 shadow-sm`),children:[n?(0,V.jsx)(`img`,{src:`/template-types/${n}`,alt:``,className:K(`size-8 shrink-0 transition-opacity duration-300`,ee.has(n)?`opacity-100`:`opacity-0`),onLoad:()=>te(n),"aria-hidden":!0}):null,(0,V.jsx)(`span`,{className:`font-medium text-sm truncate w-full`,children:e})]},e)})})})})}),I===3&&o===`webapp`&&(0,V.jsx)(hI,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,V.jsxs)(`div`,{className:`px-6 py-4 flex flex-col gap-6`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(DF,{htmlFor:`projectName`,children:`Project name`}),(0,V.jsx)(xF,{id:`projectName`,placeholder:`My App`,value:ne,onChange:e=>{g(e.target.value),v(!0)},className:`max-w-xs`})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[F.length>1&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(DF,{className:`text-sm font-medium`,children:`Variation`}),(0,V.jsx)($z,{type:`single`,value:N,onValueChange:e=>e&&b(e),variant:`outline`,className:`flex flex-wrap gap-0 justify-start [&>button]:rounded-none [&>button:first-child]:rounded-l-md [&>button:last-child]:rounded-r-md [&>button:not(:first-child)]:-ml-px`,children:F.map(e=>(0,V.jsx)(eB,{value:e.id,className:`text-sm`,children:e.variationName},e.id))})]}),(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[re?.description??F[0]?.description??``,re?.url&&(0,V.jsxs)(V.Fragment,{children:[` `,(0,V.jsxs)(`a`,{href:re.url,target:`_blank`,rel:`noreferrer`,className:`text-brand hover:underline hover:text-brand/80 inline-flex items-center gap-0.5`,children:[`Documentation `,(0,V.jsx)(mu,{className:`h-3 w-3`})]})]})]})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,V.jsx)(DF,{className:`text-sm font-medium`,children:`Package manager`}),(0,V.jsx)($z,{type:`single`,value:x,onValueChange:e=>{e&&(S(e),HR(e))},variant:`outline`,className:`flex flex-wrap gap-0 justify-start [&>button]:rounded-none [&>button:first-child]:rounded-l-md [&>button:last-child]:rounded-r-md [&>button:not(:first-child)]:-ml-px`,children:Object.values(Cz).map(e=>(0,V.jsx)(eB,{value:e.id,className:`text-sm`,children:e.label},e.id))})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,V.jsx)(DF,{className:`text-sm font-medium`,children:`Commit method`}),(0,V.jsxs)($z,{type:`single`,value:p,onValueChange:e=>{(e===$.PullRequest||e===$.Direct)&&(m(e),WR(e))},variant:`outline`,className:`flex flex-wrap gap-0 justify-start [&>button]:rounded-none [&>button:first-child]:rounded-l-md [&>button:last-child]:rounded-r-md [&>button:not(:first-child)]:-ml-px`,children:[(0,V.jsx)(eB,{value:$.PullRequest,className:`text-sm`,children:`Pull Requests`}),(0,V.jsx)(eB,{value:$.Direct,className:`text-sm`,children:`Direct Commits`})]}),(0,V.jsx)(`p`,{className:`text-xs text-slate-600 dark:text-slate-400`,children:p===$.PullRequest?`Creates a feature branch and allows you to create pull requests.`:`Commits directly to the main branch without creating feature branches.`})]})]})}),I===3&&o===`clone`&&(0,V.jsx)(hI,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,V.jsx)(`div`,{className:`px-6 py-4 flex flex-col gap-6`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,V.jsx)(DF,{className:`text-sm font-medium`,children:`Commit method`}),(0,V.jsxs)($z,{type:`single`,value:p,onValueChange:e=>{(e===$.PullRequest||e===$.Direct)&&(m(e),WR(e))},variant:`outline`,className:`flex flex-wrap gap-0 justify-start [&>button]:rounded-none [&>button:first-child]:rounded-l-md [&>button:last-child]:rounded-r-md [&>button:not(:first-child)]:-ml-px`,children:[(0,V.jsx)(eB,{value:$.PullRequest,className:`text-sm`,children:`Pull Requests`}),(0,V.jsx)(eB,{value:$.Direct,className:`text-sm`,children:`Direct Commits`})]}),(0,V.jsx)(`p`,{className:`text-xs text-slate-600 dark:text-slate-400`,children:p===$.PullRequest?`Creates a feature branch and allows you to create pull requests.`:`Commits directly to the main branch without creating feature branches.`})]})})}),(0,V.jsx)(`div`,{className:`px-6 py-4 border-t border-border bg-muted/10 min-h-[4.5rem] flex flex-col justify-end`,children:(0,V.jsxs)(nF,{children:[I>1&&(0,V.jsx)(bF,{variant:`ghost`,onClick:se,children:`Back`}),I===2&&(0,V.jsx)(bF,{onClick:()=>u(3),disabled:!ce,children:`Next`}),I===3&&o===`clone`&&(0,V.jsx)(bF,{onClick:le,children:`Clone Repository`}),I===3&&o===`webapp`&&(0,V.jsx)(bF,{onClick:ue,disabled:!ne.trim()||D,children:D?`Preparing...`:`Create App`})]})})]})})}export{yL as $,Va as $i,GN as $n,ex as $r,XL as $t,II as A,yf as Ai,AF as An,wA as Ar,hR as At,FR as B,Xc as Bi,iF as Bn,_E as Br,zL as Bt,sR as C,zp as Ci,X as Cn,IA as Cr,LI as Ct,HL as D,cp as Di,Y as Dn,MA as Dr,jR as Dt,TL as E,dp as Ei,CI as En,z as Er,QL as Et,GL as F,_u as Fi,yF as Fn,lO as Fr,PL as Ft,bL as G,Ms as Gi,XP as Gn,AC as Gr,BI as Gt,vL as H,Ic as Hi,tF as Hn,L as Hr,TR as Ht,OR as I,gu as Ii,vF as In,UD as Ir,FL as It,OL as J,_o as Ji,JP as Jn,vC as Jr,fL as Jt,gL as K,Qo as Ki,qP as Kn,kC as Kr,JI as Kt,XI as L,mu as Li,uF as Ln,fD as Lr,LL as Lt,QI as M,Ed as Mi,DF as Mn,YO as Mr,RL as Mt,PR as N,_d as Ni,xF as Nn,yO as Nr,kL as Nt,VL as O,sp as Oi,SI as On,OA as Or,AR as Ot,NR as P,Bu as Pi,bF as Pn,vO as Pr,IL as Pt,xL as Q,Wa as Qi,KN as Qn,ix as Qr,qL as Qt,pR as R,Rl as Ri,ZP as Rn,QE as Rr,jL as Rt,_R as S,Gp as Si,TI as Sn,RA as Sr,RI as St,cR as T,bp as Ti,vI as Tn,B as Tr,dR as Tt,SL as U,Pc as Ui,rF as Un,Rw as Ur,ZI as Ut,CL as V,Wc as Vi,nF as Vn,oE as Vr,ML as Vt,_L as W,ic as Wi,K as Wn,Ow as Wr,rR as Wt,NL as X,Ka as Xi,qN as Xn,DS as Xr,lR as Xt,wL as Y,oo as Yi,XN as Yn,pC as Yr,lL as Yt,VI as Z,Ga as Zi,YN as Zn,TS as Zr,UL as Zt,XR as _,sg as _i,pL as _n,YA as _r,wR as _t,Ez as a,st as aa,cy as ai,nL as an,cN as ar,aR as at,AI as b,Xm as bi,eL as bn,UA as br,YL as bt,xz as c,c as ca,mv as ci,cL as cn,Rj as cr,GI as ct,ez as d,nv as di,yR as dn,vj as dr,oR as dt,Ma as ea,ub as ei,WL as en,UN as er,HI as et,qR as f,ev as fi,bR as fn,uj as fr,KL as ft,JR as g,Sg as gi,hL as gn,nj as gr,xR as gt,ZR as h,Og as hi,uL as hn,H as hr,CR as ht,Tz as i,xt as ia,Iy as ii,MR as in,dN as ir,gR as it,fR as j,uf as ji,kF as jn,mk as jr,DL as jt,qI as k,Af as ki,hI as kn,TA as kr,JL as kt,lz as l,o as la,dv as li,nR as ln,Ij as lr,ER as lt,$R as m,f_ as mi,eR as mn,U as mr,kR as mt,wz as n,Lr as na,Zy as ni,DR as nn,WN as nr,iL as nt,$ as o,et as oa,kv as oi,aL as on,$M as or,BL as ot,YR as p,y_ as pi,oL as pn,_j as pr,SR as pt,tL as q,Uo as qi,YP as qn,OC as qr,dL as qt,Oz as r,vr as ra,qy as ri,zI as rn,RN as rr,mR as rt,Sz as s,We as sa,Ov as si,tR as sn,Uj as sr,WI as st,tB as t,Kr as ta,lb as ti,EL as tn,JN as tr,rL as tt,tz as u,i as ua,rv as ui,ZL as un,Cj as ur,$L as ut,QR as v,vh as vi,mL as vn,QA as vr,UI as vt,sL as w,xp as wi,J as wn,PA as wr,uR as wt,vR as x,Mm as xi,Z as xn,BA as xr,KI as xt,jI as y,eh as yi,iR as yn,GA as yr,YI as yt,$I as z,Ml as zi,eF as zn,NE as zr,AL as zt};