getkova 2026.4.21 → 2026.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.
- package/dist/control-ui/apple-touch-icon.png +0 -0
- package/dist/control-ui/assets/agents-CLtFQRXd.js +918 -0
- package/dist/control-ui/assets/agents-CLtFQRXd.js.map +1 -0
- package/dist/control-ui/assets/anthropic-CFEPAL-v.js +37 -0
- package/dist/control-ui/assets/anthropic-CFEPAL-v.js.map +1 -0
- package/dist/control-ui/assets/azure-openai-responses-CxiWQLmZ.js +2 -0
- package/dist/control-ui/assets/azure-openai-responses-CxiWQLmZ.js.map +1 -0
- package/dist/control-ui/assets/briefing-DS4VWpUL.js +121 -0
- package/dist/control-ui/assets/briefing-DS4VWpUL.js.map +1 -0
- package/dist/control-ui/assets/canvas-BfC_2Nqy.js +17 -0
- package/dist/control-ui/assets/canvas-BfC_2Nqy.js.map +1 -0
- package/dist/control-ui/assets/channel-config-extras-YNNd-4PG.js +2 -0
- package/dist/control-ui/assets/channel-config-extras-YNNd-4PG.js.map +1 -0
- package/dist/control-ui/assets/channels-BKdM7i5r.js +471 -0
- package/dist/control-ui/assets/channels-BKdM7i5r.js.map +1 -0
- package/dist/control-ui/assets/cron-C11m3yJi.js +928 -0
- package/dist/control-ui/assets/cron-C11m3yJi.js.map +1 -0
- package/dist/control-ui/assets/de-rLAkQOBc.js +2 -0
- package/dist/control-ui/assets/de-rLAkQOBc.js.map +1 -0
- package/dist/control-ui/assets/debug-DFf2qCcM.js +94 -0
- package/dist/control-ui/assets/debug-DFf2qCcM.js.map +1 -0
- package/dist/control-ui/assets/dist-D8DZLmCF.js +18 -0
- package/dist/control-ui/assets/dist-D8DZLmCF.js.map +1 -0
- package/dist/control-ui/assets/employees-DV-5FV4K.js +104 -0
- package/dist/control-ui/assets/employees-DV-5FV4K.js.map +1 -0
- package/dist/control-ui/assets/es-CIeD3O54.js +2 -0
- package/dist/control-ui/assets/es-CIeD3O54.js.map +1 -0
- package/dist/control-ui/assets/event-stream-B8X6sYaV.js +2 -0
- package/dist/control-ui/assets/event-stream-B8X6sYaV.js.map +1 -0
- package/dist/control-ui/assets/format-BahKhiOC.js +2 -0
- package/dist/control-ui/assets/format-BahKhiOC.js.map +1 -0
- package/dist/control-ui/assets/github-copilot-headers-CrI0CIJ7.js +2 -0
- package/dist/control-ui/assets/github-copilot-headers-CrI0CIJ7.js.map +1 -0
- package/dist/control-ui/assets/google-BT0bmsh5.js +2 -0
- package/dist/control-ui/assets/google-BT0bmsh5.js.map +1 -0
- package/dist/control-ui/assets/google-gemini-cli-BpxbH95Q.js +3 -0
- package/dist/control-ui/assets/google-gemini-cli-BpxbH95Q.js.map +1 -0
- package/dist/control-ui/assets/google-shared-CbPHVnPr.js +12 -0
- package/dist/control-ui/assets/google-shared-CbPHVnPr.js.map +1 -0
- package/dist/control-ui/assets/google-vertex-lQwbjEII.js +2 -0
- package/dist/control-ui/assets/google-vertex-lQwbjEII.js.map +1 -0
- package/dist/control-ui/assets/hash-Bt1aVMQ3.js +2 -0
- package/dist/control-ui/assets/hash-Bt1aVMQ3.js.map +1 -0
- package/dist/control-ui/assets/inbox-C4tOnlJr.js +100 -0
- package/dist/control-ui/assets/inbox-C4tOnlJr.js.map +1 -0
- package/dist/control-ui/assets/index-DYMuTfvX.css +1 -0
- package/dist/control-ui/assets/index-XGDpaFxG.js +5482 -0
- package/dist/control-ui/assets/index-XGDpaFxG.js.map +1 -0
- package/dist/control-ui/assets/instances-Cyr-tbN6.js +57 -0
- package/dist/control-ui/assets/instances-Cyr-tbN6.js.map +1 -0
- package/dist/control-ui/assets/kova-logo.png +0 -0
- package/dist/control-ui/assets/lit-zdTgzAJI.js +3 -0
- package/dist/control-ui/assets/lit-zdTgzAJI.js.map +1 -0
- package/dist/control-ui/assets/local-storage-D3baoRWx.js +2 -0
- package/dist/control-ui/assets/local-storage-D3baoRWx.js.map +1 -0
- package/dist/control-ui/assets/logs-B7--7dYP.js +74 -0
- package/dist/control-ui/assets/logs-B7--7dYP.js.map +1 -0
- package/dist/control-ui/assets/meetings-DSqn6s7n.js +185 -0
- package/dist/control-ui/assets/meetings-DSqn6s7n.js.map +1 -0
- package/dist/control-ui/assets/mistral-CBrDC_Gv.js +8 -0
- package/dist/control-ui/assets/mistral-CBrDC_Gv.js.map +1 -0
- package/dist/control-ui/assets/nodes-Cvq_sAqT.js +430 -0
- package/dist/control-ui/assets/nodes-Cvq_sAqT.js.map +1 -0
- package/dist/control-ui/assets/openai-Cn7eGqwa.js +17 -0
- package/dist/control-ui/assets/openai-Cn7eGqwa.js.map +1 -0
- package/dist/control-ui/assets/openai-codex-responses-DuhESMYF.js +8 -0
- package/dist/control-ui/assets/openai-codex-responses-DuhESMYF.js.map +1 -0
- package/dist/control-ui/assets/openai-completions-Bv33lqKL.js +6 -0
- package/dist/control-ui/assets/openai-completions-Bv33lqKL.js.map +1 -0
- package/dist/control-ui/assets/openai-responses-BPxpapOg.js +2 -0
- package/dist/control-ui/assets/openai-responses-BPxpapOg.js.map +1 -0
- package/dist/control-ui/assets/openai-responses-shared-8nKH8ywL.js +11 -0
- package/dist/control-ui/assets/openai-responses-shared-8nKH8ywL.js.map +1 -0
- package/dist/control-ui/assets/pdf-BwYFZMZM.js +57 -0
- package/dist/control-ui/assets/pdf-BwYFZMZM.js.map +1 -0
- package/dist/control-ui/assets/pdf.worker.min-BmpgcBpm.js +2 -0
- package/dist/control-ui/assets/pdf.worker.min-BmpgcBpm.js.map +1 -0
- package/dist/control-ui/assets/pdf.worker.min-C8PGFc0r.mjs +28 -0
- package/dist/control-ui/assets/preload-helper-Chd9yIcd.js +1 -0
- package/dist/control-ui/assets/pt-BR-lSsBb08k.js +2 -0
- package/dist/control-ui/assets/pt-BR-lSsBb08k.js.map +1 -0
- package/dist/control-ui/assets/routing-DizI_FiJ.js +157 -0
- package/dist/control-ui/assets/routing-DizI_FiJ.js.map +1 -0
- package/dist/control-ui/assets/sessions-N9rgJP2R.js +236 -0
- package/dist/control-ui/assets/sessions-N9rgJP2R.js.map +1 -0
- package/dist/control-ui/assets/skills-D1vP4MkL.js +280 -0
- package/dist/control-ui/assets/skills-D1vP4MkL.js.map +1 -0
- package/dist/control-ui/assets/skills-shared-Bg0Qcnkp.js +11 -0
- package/dist/control-ui/assets/skills-shared-Bg0Qcnkp.js.map +1 -0
- package/dist/control-ui/assets/transform-messages-XKqwKV3D.js +2 -0
- package/dist/control-ui/assets/transform-messages-XKqwKV3D.js.map +1 -0
- package/dist/control-ui/assets/zh-CN-C5tPG8Eu.js +2 -0
- package/dist/control-ui/assets/zh-CN-C5tPG8Eu.js.map +1 -0
- package/dist/control-ui/assets/zh-TW-CPSoC7Wz.js +2 -0
- package/dist/control-ui/assets/zh-TW-CPSoC7Wz.js.map +1 -0
- package/dist/control-ui/favicon-32.png +0 -0
- package/dist/control-ui/favicon.ico +0 -0
- package/dist/control-ui/favicon.png +0 -0
- package/dist/control-ui/favicon.svg +22 -0
- package/dist/control-ui/index.html +73 -0
- package/dist/control-ui/openclaw-canvas-auth-sw.js +57 -0
- package/package.json +1 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e,t}from"./event-stream-B8X6sYaV.js";import{a as n,i as r,r as i}from"./transform-messages-XKqwKV3D.js";import{c as a,i as o,l as s,n as c,o as l,r as u,s as d,t as f}from"./google-shared-CbPHVnPr.js";var p=`v1`,m={THINKING_LEVEL_UNSPECIFIED:s.THINKING_LEVEL_UNSPECIFIED,MINIMAL:s.MINIMAL,LOW:s.LOW,MEDIUM:s.MEDIUM,HIGH:s.HIGH},h=0,g=(n,r,i)=>{let a=new t;return(async()=>{let t={role:`assistant`,content:[],api:`google-vertex`,provider:n.provider,model:n.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let s=b(i),c=s?y(n,s,i?.headers):v(n,S(i),C(i),i?.headers),l=w(n,r,i),f=await i?.onPayload?.(l,n);f!==void 0&&(l=f);let p=await c.models.generateContentStream(l);a.push({type:`start`,partial:t});let m=null,g=t.content,_=()=>g.length-1;for await(let r of p){t.responseId||=r.responseId;let i=r.candidates?.[0];if(i?.content?.parts)for(let e of i.content.parts){if(e.text!==void 0){let n=u(e);(!m||n&&m.type!==`thinking`||!n&&m.type!==`text`)&&(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:g.length-1,content:m.text,partial:t}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:t})),n?(m={type:`thinking`,thinking:``,thinkingSignature:void 0},t.content.push(m),a.push({type:`thinking_start`,contentIndex:_(),partial:t})):(m={type:`text`,text:``},t.content.push(m),a.push({type:`text_start`,contentIndex:_(),partial:t}))),m.type===`thinking`?(m.thinking+=e.text,m.thinkingSignature=d(m.thinkingSignature,e.thoughtSignature),a.push({type:`thinking_delta`,contentIndex:_(),delta:e.text,partial:t})):(m.text+=e.text,m.textSignature=d(m.textSignature,e.thoughtSignature),a.push({type:`text_delta`,contentIndex:_(),delta:e.text,partial:t}))}if(e.functionCall){m&&=(m.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:m.text,partial:t}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:t}),null);let n=e.functionCall.id,r={type:`toolCall`,id:!n||t.content.some(e=>e.type===`toolCall`&&e.id===n)?`${e.functionCall.name}_${Date.now()}_${++h}`:n,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};t.content.push(r),a.push({type:`toolcall_start`,contentIndex:_(),partial:t}),a.push({type:`toolcall_delta`,contentIndex:_(),delta:JSON.stringify(r.arguments),partial:t}),a.push({type:`toolcall_end`,contentIndex:_(),toolCall:r,partial:t})}}i?.finishReason&&(t.stopReason=o(i.finishReason),t.content.some(e=>e.type===`toolCall`)&&(t.stopReason=`toolUse`)),r.usageMetadata&&(t.usage={input:(r.usageMetadata.promptTokenCount||0)-(r.usageMetadata.cachedContentTokenCount||0),output:(r.usageMetadata.candidatesTokenCount||0)+(r.usageMetadata.thoughtsTokenCount||0),cacheRead:r.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:r.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},e(n,t.usage))}if(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:m.text,partial:t}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:t})),i?.signal?.aborted)throw Error(`Request was aborted`);if(t.stopReason===`aborted`||t.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:t.stopReason,message:t}),a.end()}catch(e){for(let e of t.content)`index`in e&&delete e.index;t.stopReason=i?.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:JSON.stringify(e),a.push({type:`error`,reason:t.stopReason,error:t}),a.end()}})(),a},_=(e,t,n)=>{let a=i(e,n,void 0);if(!n?.reasoning)return g(e,t,{...a,thinking:{enabled:!1}});let o=r(n.reasoning),s=e;return T(s)||E(s)?g(e,t,{...a,thinking:{enabled:!0,level:O(o,s)}}):g(e,t,{...a,thinking:{enabled:!0,budgetTokens:k(s,o,n.thinkingBudgets)}})};function v(e,t,n,r){let i={};return(e.headers||r)&&(i.headers={...e.headers,...r}),new a({vertexai:!0,project:t,location:n,apiVersion:p,httpOptions:Object.values(i).some(Boolean)?i:void 0})}function y(e,t,n){let r={};return(e.headers||n)&&(r.headers={...e.headers,...n}),new a({vertexai:!0,apiKey:t,apiVersion:p,httpOptions:Object.values(r).some(Boolean)?r:void 0})}function b(e){let t=e?.apiKey?.trim()||{}.GOOGLE_CLOUD_API_KEY?.trim();if(!(!t||x(t)))return t}function x(e){return/^<[^>]+>$/.test(e)}function S(e){let t=e?.project||{}.GOOGLE_CLOUD_PROJECT||{}.GCLOUD_PROJECT;if(!t)throw Error(`Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.`);return t}function C(e){let t=e?.location||{}.GOOGLE_CLOUD_LOCATION;if(!t)throw Error(`Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.`);return t}function w(e,t,r={}){let i=f(e,t),a={};r.temperature!==void 0&&(a.temperature=r.temperature),r.maxTokens!==void 0&&(a.maxOutputTokens=r.maxTokens);let o={...Object.keys(a).length>0&&a,...t.systemPrompt&&{systemInstruction:n(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:c(t.tools)}};if(t.tools&&t.tools.length>0&&r.toolChoice?o.toolConfig={functionCallingConfig:{mode:l(r.toolChoice)}}:o.toolConfig=void 0,r.thinking?.enabled&&e.reasoning){let e={includeThoughts:!0};r.thinking.level===void 0?r.thinking.budgetTokens!==void 0&&(e.thinkingBudget=r.thinking.budgetTokens):e.thinkingLevel=m[r.thinking.level],o.thinkingConfig=e}else e.reasoning&&r.thinking&&!r.thinking.enabled&&(o.thinkingConfig=D(e));if(r.signal){if(r.signal.aborted)throw Error(`Request aborted`);o.abortSignal=r.signal}return{model:e.id,contents:i,config:o}}function T(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function E(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function D(e){let t=e;return T(t)?{thinkingLevel:s.LOW}:E(t)?{thinkingLevel:s.MINIMAL}:{thinkingBudget:0}}function O(e,t){if(T(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}function k(e,t,n){return n?.[t]===void 0?e.id.includes(`2.5-pro`)?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes(`2.5-flash`)?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1:n[t]}export{g as streamGoogleVertex,_ as streamSimpleGoogleVertex};
|
|
2
|
+
//# sourceMappingURL=google-vertex-lQwbjEII.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-vertex-lQwbjEII.js","names":[],"sources":["../../../node_modules/@mariozechner/pi-ai/dist/providers/google-vertex.js"],"sourcesContent":["import { GoogleGenAI, ThinkingLevel, } from \"@google/genai\";\nimport { calculateCost } from \"../models.js\";\nimport { AssistantMessageEventStream } from \"../utils/event-stream.js\";\nimport { sanitizeSurrogates } from \"../utils/sanitize-unicode.js\";\nimport { convertMessages, convertTools, isThinkingPart, mapStopReason, mapToolChoice, retainThoughtSignature, } from \"./google-shared.js\";\nimport { buildBaseOptions, clampReasoning } from \"./simple-options.js\";\nconst API_VERSION = \"v1\";\nconst THINKING_LEVEL_MAP = {\n THINKING_LEVEL_UNSPECIFIED: ThinkingLevel.THINKING_LEVEL_UNSPECIFIED,\n MINIMAL: ThinkingLevel.MINIMAL,\n LOW: ThinkingLevel.LOW,\n MEDIUM: ThinkingLevel.MEDIUM,\n HIGH: ThinkingLevel.HIGH,\n};\n// Counter for generating unique tool call IDs\nlet toolCallCounter = 0;\nexport const streamGoogleVertex = (model, context, options) => {\n const stream = new AssistantMessageEventStream();\n (async () => {\n const output = {\n role: \"assistant\",\n content: [],\n api: \"google-vertex\",\n provider: model.provider,\n model: model.id,\n usage: {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n totalTokens: 0,\n cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n },\n stopReason: \"stop\",\n timestamp: Date.now(),\n };\n try {\n const apiKey = resolveApiKey(options);\n // Create the client using either a Vertex API key, if provided, or ADC with project and location\n const client = apiKey\n ? createClientWithApiKey(model, apiKey, options?.headers)\n : createClient(model, resolveProject(options), resolveLocation(options), options?.headers);\n let params = buildParams(model, context, options);\n const nextParams = await options?.onPayload?.(params, model);\n if (nextParams !== undefined) {\n params = nextParams;\n }\n const googleStream = await client.models.generateContentStream(params);\n stream.push({ type: \"start\", partial: output });\n let currentBlock = null;\n const blocks = output.content;\n const blockIndex = () => blocks.length - 1;\n for await (const chunk of googleStream) {\n // Vertex uses the same @google/genai GenerateContentResponse type as Gemini.\n // responseId is documented there as an output-only identifier for each response.\n output.responseId ||= chunk.responseId;\n const candidate = chunk.candidates?.[0];\n if (candidate?.content?.parts) {\n for (const part of candidate.content.parts) {\n if (part.text !== undefined) {\n const isThinking = isThinkingPart(part);\n if (!currentBlock ||\n (isThinking && currentBlock.type !== \"thinking\") ||\n (!isThinking && currentBlock.type !== \"text\")) {\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blocks.length - 1,\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n }\n if (isThinking) {\n currentBlock = { type: \"thinking\", thinking: \"\", thinkingSignature: undefined };\n output.content.push(currentBlock);\n stream.push({ type: \"thinking_start\", contentIndex: blockIndex(), partial: output });\n }\n else {\n currentBlock = { type: \"text\", text: \"\" };\n output.content.push(currentBlock);\n stream.push({ type: \"text_start\", contentIndex: blockIndex(), partial: output });\n }\n }\n if (currentBlock.type === \"thinking\") {\n currentBlock.thinking += part.text;\n currentBlock.thinkingSignature = retainThoughtSignature(currentBlock.thinkingSignature, part.thoughtSignature);\n stream.push({\n type: \"thinking_delta\",\n contentIndex: blockIndex(),\n delta: part.text,\n partial: output,\n });\n }\n else {\n currentBlock.text += part.text;\n currentBlock.textSignature = retainThoughtSignature(currentBlock.textSignature, part.thoughtSignature);\n stream.push({\n type: \"text_delta\",\n contentIndex: blockIndex(),\n delta: part.text,\n partial: output,\n });\n }\n }\n if (part.functionCall) {\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blockIndex(),\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n currentBlock = null;\n }\n const providedId = part.functionCall.id;\n const needsNewId = !providedId || output.content.some((b) => b.type === \"toolCall\" && b.id === providedId);\n const toolCallId = needsNewId\n ? `${part.functionCall.name}_${Date.now()}_${++toolCallCounter}`\n : providedId;\n const toolCall = {\n type: \"toolCall\",\n id: toolCallId,\n name: part.functionCall.name || \"\",\n arguments: part.functionCall.args ?? {},\n ...(part.thoughtSignature && { thoughtSignature: part.thoughtSignature }),\n };\n output.content.push(toolCall);\n stream.push({ type: \"toolcall_start\", contentIndex: blockIndex(), partial: output });\n stream.push({\n type: \"toolcall_delta\",\n contentIndex: blockIndex(),\n delta: JSON.stringify(toolCall.arguments),\n partial: output,\n });\n stream.push({ type: \"toolcall_end\", contentIndex: blockIndex(), toolCall, partial: output });\n }\n }\n }\n if (candidate?.finishReason) {\n output.stopReason = mapStopReason(candidate.finishReason);\n if (output.content.some((b) => b.type === \"toolCall\")) {\n output.stopReason = \"toolUse\";\n }\n }\n if (chunk.usageMetadata) {\n output.usage = {\n input: (chunk.usageMetadata.promptTokenCount || 0) - (chunk.usageMetadata.cachedContentTokenCount || 0),\n output: (chunk.usageMetadata.candidatesTokenCount || 0) + (chunk.usageMetadata.thoughtsTokenCount || 0),\n cacheRead: chunk.usageMetadata.cachedContentTokenCount || 0,\n cacheWrite: 0,\n totalTokens: chunk.usageMetadata.totalTokenCount || 0,\n cost: {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n total: 0,\n },\n };\n calculateCost(model, output.usage);\n }\n }\n if (currentBlock) {\n if (currentBlock.type === \"text\") {\n stream.push({\n type: \"text_end\",\n contentIndex: blockIndex(),\n content: currentBlock.text,\n partial: output,\n });\n }\n else {\n stream.push({\n type: \"thinking_end\",\n contentIndex: blockIndex(),\n content: currentBlock.thinking,\n partial: output,\n });\n }\n }\n if (options?.signal?.aborted) {\n throw new Error(\"Request was aborted\");\n }\n if (output.stopReason === \"aborted\" || output.stopReason === \"error\") {\n throw new Error(\"An unknown error occurred\");\n }\n stream.push({ type: \"done\", reason: output.stopReason, message: output });\n stream.end();\n }\n catch (error) {\n // Remove internal index property used during streaming\n for (const block of output.content) {\n if (\"index\" in block) {\n delete block.index;\n }\n }\n output.stopReason = options?.signal?.aborted ? \"aborted\" : \"error\";\n output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);\n stream.push({ type: \"error\", reason: output.stopReason, error: output });\n stream.end();\n }\n })();\n return stream;\n};\nexport const streamSimpleGoogleVertex = (model, context, options) => {\n const base = buildBaseOptions(model, options, undefined);\n if (!options?.reasoning) {\n return streamGoogleVertex(model, context, {\n ...base,\n thinking: { enabled: false },\n });\n }\n const effort = clampReasoning(options.reasoning);\n const geminiModel = model;\n if (isGemini3ProModel(geminiModel) || isGemini3FlashModel(geminiModel)) {\n return streamGoogleVertex(model, context, {\n ...base,\n thinking: {\n enabled: true,\n level: getGemini3ThinkingLevel(effort, geminiModel),\n },\n });\n }\n return streamGoogleVertex(model, context, {\n ...base,\n thinking: {\n enabled: true,\n budgetTokens: getGoogleBudget(geminiModel, effort, options.thinkingBudgets),\n },\n });\n};\nfunction createClient(model, project, location, optionsHeaders) {\n const httpOptions = {};\n if (model.headers || optionsHeaders) {\n httpOptions.headers = { ...model.headers, ...optionsHeaders };\n }\n const hasHttpOptions = Object.values(httpOptions).some(Boolean);\n return new GoogleGenAI({\n vertexai: true,\n project,\n location,\n apiVersion: API_VERSION,\n httpOptions: hasHttpOptions ? httpOptions : undefined,\n });\n}\nfunction createClientWithApiKey(model, apiKey, optionsHeaders) {\n const httpOptions = {};\n if (model.headers || optionsHeaders) {\n httpOptions.headers = { ...model.headers, ...optionsHeaders };\n }\n const hasHttpOptions = Object.values(httpOptions).some(Boolean);\n return new GoogleGenAI({\n vertexai: true,\n apiKey,\n apiVersion: API_VERSION,\n httpOptions: hasHttpOptions ? httpOptions : undefined,\n });\n}\nfunction resolveApiKey(options) {\n const apiKey = options?.apiKey?.trim() || process.env.GOOGLE_CLOUD_API_KEY?.trim();\n if (!apiKey || isPlaceholderApiKey(apiKey)) {\n return undefined;\n }\n return apiKey;\n}\nfunction isPlaceholderApiKey(apiKey) {\n return /^<[^>]+>$/.test(apiKey);\n}\nfunction resolveProject(options) {\n const project = options?.project || process.env.GOOGLE_CLOUD_PROJECT || process.env.GCLOUD_PROJECT;\n if (!project) {\n throw new Error(\"Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.\");\n }\n return project;\n}\nfunction resolveLocation(options) {\n const location = options?.location || process.env.GOOGLE_CLOUD_LOCATION;\n if (!location) {\n throw new Error(\"Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.\");\n }\n return location;\n}\nfunction buildParams(model, context, options = {}) {\n const contents = convertMessages(model, context);\n const generationConfig = {};\n if (options.temperature !== undefined) {\n generationConfig.temperature = options.temperature;\n }\n if (options.maxTokens !== undefined) {\n generationConfig.maxOutputTokens = options.maxTokens;\n }\n const config = {\n ...(Object.keys(generationConfig).length > 0 && generationConfig),\n ...(context.systemPrompt && { systemInstruction: sanitizeSurrogates(context.systemPrompt) }),\n ...(context.tools && context.tools.length > 0 && { tools: convertTools(context.tools) }),\n };\n if (context.tools && context.tools.length > 0 && options.toolChoice) {\n config.toolConfig = {\n functionCallingConfig: {\n mode: mapToolChoice(options.toolChoice),\n },\n };\n }\n else {\n config.toolConfig = undefined;\n }\n if (options.thinking?.enabled && model.reasoning) {\n const thinkingConfig = { includeThoughts: true };\n if (options.thinking.level !== undefined) {\n thinkingConfig.thinkingLevel = THINKING_LEVEL_MAP[options.thinking.level];\n }\n else if (options.thinking.budgetTokens !== undefined) {\n thinkingConfig.thinkingBudget = options.thinking.budgetTokens;\n }\n config.thinkingConfig = thinkingConfig;\n }\n else if (model.reasoning && options.thinking && !options.thinking.enabled) {\n config.thinkingConfig = getDisabledThinkingConfig(model);\n }\n if (options.signal) {\n if (options.signal.aborted) {\n throw new Error(\"Request aborted\");\n }\n config.abortSignal = options.signal;\n }\n const params = {\n model: model.id,\n contents,\n config,\n };\n return params;\n}\nfunction isGemini3ProModel(model) {\n return /gemini-3(?:\\.\\d+)?-pro/.test(model.id.toLowerCase());\n}\nfunction isGemini3FlashModel(model) {\n return /gemini-3(?:\\.\\d+)?-flash/.test(model.id.toLowerCase());\n}\nfunction getDisabledThinkingConfig(model) {\n // Google docs: Gemini 3.1 Pro cannot disable thinking, and Gemini 3 Flash / Flash-Lite\n // do not support full thinking-off either. For Gemini 3 models, use the lowest supported\n // thinkingLevel without includeThoughts so hidden thinking remains invisible to pi.\n const geminiModel = model;\n if (isGemini3ProModel(geminiModel)) {\n return { thinkingLevel: ThinkingLevel.LOW };\n }\n if (isGemini3FlashModel(geminiModel)) {\n return { thinkingLevel: ThinkingLevel.MINIMAL };\n }\n // Gemini 2.x supports disabling via thinkingBudget = 0.\n return { thinkingBudget: 0 };\n}\nfunction getGemini3ThinkingLevel(effort, model) {\n if (isGemini3ProModel(model)) {\n switch (effort) {\n case \"minimal\":\n case \"low\":\n return \"LOW\";\n case \"medium\":\n case \"high\":\n return \"HIGH\";\n }\n }\n switch (effort) {\n case \"minimal\":\n return \"MINIMAL\";\n case \"low\":\n return \"LOW\";\n case \"medium\":\n return \"MEDIUM\";\n case \"high\":\n return \"HIGH\";\n }\n}\nfunction getGoogleBudget(model, effort, customBudgets) {\n if (customBudgets?.[effort] !== undefined) {\n return customBudgets[effort];\n }\n if (model.id.includes(\"2.5-pro\")) {\n const budgets = {\n minimal: 128,\n low: 2048,\n medium: 8192,\n high: 32768,\n };\n return budgets[effort];\n }\n if (model.id.includes(\"2.5-flash\")) {\n const budgets = {\n minimal: 128,\n low: 2048,\n medium: 8192,\n high: 24576,\n };\n return budgets[effort];\n }\n return -1;\n}\n//# sourceMappingURL=google-vertex.js.map"],"x_google_ignoreList":[0],"mappings":"qNAMA,IAAM,EAAc,KACd,EAAqB,CACvB,2BAA4B,EAAc,2BAC1C,QAAS,EAAc,QACvB,IAAK,EAAc,IACnB,OAAQ,EAAc,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IAAK,KACL,OAAQ,KACR,KAAM,MACT,CACc,GAEf,EAAM,GAAG,SAAS,YAAY,CACd,CACZ,QAAS,IACT,IAAK,KACL,OAAQ,KACR,KAAM,MACT,CACc,GAEZ,GApBI,EAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(n>>>0).toString(36)+(t>>>0).toString(36)}export{e as t};
|
|
2
|
+
//# sourceMappingURL=hash-Bt1aVMQ3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-Bt1aVMQ3.js","names":[],"sources":["../../../node_modules/@mariozechner/pi-ai/dist/utils/hash.js"],"sourcesContent":["/** Fast deterministic hash to shorten long strings */\nexport function shortHash(str) {\n let h1 = 0xdeadbeef;\n let h2 = 0x41c6ce57;\n for (let i = 0; i < str.length; i++) {\n const ch = str.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n return (h2 >>> 0).toString(36) + (h1 >>> 0).toString(36);\n}\n//# sourceMappingURL=hash.js.map"],"x_google_ignoreList":[0],"mappings":"AACA,SAAgB,EAAU,EAAK,CAC3B,IAAI,EAAK,WACL,EAAK,WACT,IAAK,IAAI,EAAI,EAAG,EAAI,EAAI,OAAQ,IAAK,CACjC,IAAM,EAAK,EAAI,WAAW,EAAE,CAC5B,EAAK,KAAK,KAAK,EAAK,EAAI,WAAW,CACnC,EAAK,KAAK,KAAK,EAAK,EAAI,WAAW,CAIvC,MAFA,GAAK,KAAK,KAAK,EAAM,IAAO,GAAK,WAAW,CAAG,KAAK,KAAK,EAAM,IAAO,GAAK,WAAW,CACtF,EAAK,KAAK,KAAK,EAAM,IAAO,GAAK,WAAW,CAAG,KAAK,KAAK,EAAM,IAAO,GAAK,WAAW,EAC9E,IAAO,GAAG,SAAS,GAAG,EAAI,IAAO,GAAG,SAAS,GAAG"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import{i as e,n as t}from"./lit-zdTgzAJI.js";import{l as n}from"./format-BahKhiOC.js";import{B as r,H as i,U as a,V as o,W as s,z as c}from"./index-XGDpaFxG.js";var l=[{id:`all`,label:`All`},{id:`telegram`,label:`Telegram`},{id:`whatsapp`,label:`WhatsApp`},{id:`unanswered`,label:`Unanswered`}];function u(){return e`
|
|
2
|
+
${Array.from({length:3},(t,n)=>e`
|
|
3
|
+
<div class="card" style="display: grid; gap: 14px; opacity: 0.7;" data-skeleton=${n}>
|
|
4
|
+
<div class="row" style="justify-content: space-between; gap: 16px; align-items: center;">
|
|
5
|
+
<div style="display: flex; gap: 12px; align-items: center; min-width: 0;">
|
|
6
|
+
<div style="width: 36px; height: 36px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);"></div>
|
|
7
|
+
<div style="display: grid; gap: 8px; min-width: 0;">
|
|
8
|
+
<div style="width: 140px; height: 10px; border-radius: 999px; background: var(--surface);"></div>
|
|
9
|
+
<div style="width: 220px; height: 10px; border-radius: 999px; background: var(--surface);"></div>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
<div style="width: 52px; height: 10px; border-radius: 999px; background: var(--surface);"></div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
`)}
|
|
16
|
+
`}function d(n,r){return n.loading?t:(n.sessions??[]).length===0?e`
|
|
17
|
+
<div class="card" style="display: grid; gap: 8px; max-width: 820px;">
|
|
18
|
+
<div class="card-title">No conversations yet</div>
|
|
19
|
+
<div class="card-sub">Connect a channel to start receiving messages.</div>
|
|
20
|
+
</div>
|
|
21
|
+
`:r.length===0?e`
|
|
22
|
+
<div class="card" style="display: grid; gap: 8px; max-width: 820px;">
|
|
23
|
+
<div class="card-title">No conversations match this filter</div>
|
|
24
|
+
<div class="card-sub">Try a different channel filter or refresh the inbox.</div>
|
|
25
|
+
</div>
|
|
26
|
+
`:t}function f(t){let n=a(t);return n===`telegram`?e`<span class="chip chip-ok">✈️ Telegram</span>`:n===`whatsapp`?e`<span class="chip chip-ok">📱 WhatsApp</span>`:e`<span class="chip">Conversation</span>`}function p(r,l){let u=a(r),d=`${c(`chat`,l.basePath)}?session=${encodeURIComponent(r.key)}`,p=r.displayName?.trim()||r.label?.trim()||r.subject?.trim()||r.derivedTitle?.trim()||r.key,m=r.updatedAt?n(r.updatedAt):`n/a`,h=i(r),g=!s(r);return e`
|
|
27
|
+
<a
|
|
28
|
+
href=${d}
|
|
29
|
+
class="card"
|
|
30
|
+
style="display: block; text-decoration: none; color: inherit; transition: transform var(--duration-fast) ease, border-color var(--duration-fast) ease;"
|
|
31
|
+
@click=${e=>{e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||l.onNavigateToChat&&(e.preventDefault(),l.onNavigateToChat(r.key))}}
|
|
32
|
+
>
|
|
33
|
+
<div class="row" style="justify-content: space-between; gap: 16px; align-items: flex-start;">
|
|
34
|
+
<div style="display: flex; gap: 14px; align-items: flex-start; min-width: 0; flex: 1;">
|
|
35
|
+
<div
|
|
36
|
+
style="width: 40px; height: 40px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; flex: 0 0 auto;"
|
|
37
|
+
aria-hidden="true"
|
|
38
|
+
>
|
|
39
|
+
${u===`whatsapp`?`📱`:`✈️`}
|
|
40
|
+
</div>
|
|
41
|
+
<div style="display: grid; gap: 8px; min-width: 0; flex: 1;">
|
|
42
|
+
<div class="row" style="gap: 8px; flex-wrap: wrap; align-items: center;">
|
|
43
|
+
<div style="font-weight: 600; color: var(--text-strong); min-width: 0;">${p}</div>
|
|
44
|
+
${f(r)}
|
|
45
|
+
</div>
|
|
46
|
+
<div class="muted" style="font-size: 13px; line-height: 1.45;">
|
|
47
|
+
${o(r)}
|
|
48
|
+
</div>
|
|
49
|
+
<div class="muted" style="font-size: 12px;">
|
|
50
|
+
${h}
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
<div style="display: grid; gap: 8px; justify-items: end; flex: 0 0 auto;">
|
|
55
|
+
<div class="muted" style="font-size: 12px; white-space: nowrap;">${m}</div>
|
|
56
|
+
${g?e`
|
|
57
|
+
<span
|
|
58
|
+
title="Awaiting employee reply"
|
|
59
|
+
style="width: 10px; height: 10px; border-radius: 999px; background: var(--warn, #f59e0b); display: inline-block;"
|
|
60
|
+
></span>
|
|
61
|
+
`:t}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</a>
|
|
65
|
+
`}function m(n){let i=n.sessions??[],a=r(i,n.filter);return e`
|
|
66
|
+
<section class="page page--settings" style="display: grid; gap: 20px;">
|
|
67
|
+
<div class="card" style="display: grid; gap: 16px; max-width: 920px;">
|
|
68
|
+
<div class="row" style="justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap;">
|
|
69
|
+
<div style="display: grid; gap: 4px;">
|
|
70
|
+
<div class="card-title">Inbox</div>
|
|
71
|
+
<div class="card-sub">All conversations across your connected channels.</div>
|
|
72
|
+
</div>
|
|
73
|
+
<button class="btn" ?disabled=${n.loading} @click=${()=>n.onRefresh()}>
|
|
74
|
+
${n.loading?`Refreshing...`:`Refresh`}
|
|
75
|
+
</button>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<div class="chip-row">
|
|
79
|
+
${l.map(t=>e`
|
|
80
|
+
<button
|
|
81
|
+
class="chip ${n.filter===t.id?`chip-ok`:``}"
|
|
82
|
+
style="cursor: pointer;"
|
|
83
|
+
@click=${()=>n.onFilterChange(t.id)}
|
|
84
|
+
>
|
|
85
|
+
${t.label}
|
|
86
|
+
</button>
|
|
87
|
+
`)}
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
${n.error?e`<div class="callout danger">${n.error}</div>`:t}
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
<div style="display: grid; gap: 14px; max-width: 920px;">
|
|
94
|
+
${n.loading&&i.length===0?u():t}
|
|
95
|
+
${a.map(e=>p(e,n))}
|
|
96
|
+
${d(n,a)}
|
|
97
|
+
</div>
|
|
98
|
+
</section>
|
|
99
|
+
`}export{m as renderInbox};
|
|
100
|
+
//# sourceMappingURL=inbox-C4tOnlJr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbox-C4tOnlJr.js","names":[],"sources":["../../../ui/src/ui/views/inbox.ts"],"sourcesContent":["import { html, nothing } from \"lit\";\nimport { formatRelativeTimestamp } from \"../format.ts\";\nimport { pathForTab } from \"../navigation.ts\";\nimport type { GatewaySessionRow } from \"../types.ts\";\nimport {\n filterByChannel,\n formatLastMessage,\n formatResponder,\n getChannelFromSession,\n hasEmployeeReply,\n type InboxChannelFilter,\n} from \"../controllers/inbox.ts\";\n\nexport type InboxProps = {\n loading: boolean;\n error: string | null;\n sessions: GatewaySessionRow[] | null;\n filter: InboxChannelFilter;\n basePath: string;\n onFilterChange: (next: InboxChannelFilter) => void;\n onRefresh: () => void;\n onNavigateToChat?: (sessionKey: string) => void;\n};\n\nconst FILTER_TABS: Array<{ id: InboxChannelFilter; label: string }> = [\n { id: \"all\", label: \"All\" },\n { id: \"telegram\", label: \"Telegram\" },\n { id: \"whatsapp\", label: \"WhatsApp\" },\n { id: \"unanswered\", label: \"Unanswered\" },\n];\n\nfunction renderSkeletonRows() {\n return html`\n ${Array.from({ length: 3 }, (_, index) => html`\n <div class=\"card\" style=\"display: grid; gap: 14px; opacity: 0.7;\" data-skeleton=${index}>\n <div class=\"row\" style=\"justify-content: space-between; gap: 16px; align-items: center;\">\n <div style=\"display: flex; gap: 12px; align-items: center; min-width: 0;\">\n <div style=\"width: 36px; height: 36px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);\"></div>\n <div style=\"display: grid; gap: 8px; min-width: 0;\">\n <div style=\"width: 140px; height: 10px; border-radius: 999px; background: var(--surface);\"></div>\n <div style=\"width: 220px; height: 10px; border-radius: 999px; background: var(--surface);\"></div>\n </div>\n </div>\n <div style=\"width: 52px; height: 10px; border-radius: 999px; background: var(--surface);\"></div>\n </div>\n </div>\n `)}\n `;\n}\n\nfunction renderEmptyState(props: InboxProps, filteredSessions: GatewaySessionRow[]) {\n if (props.loading) {\n return nothing;\n }\n if ((props.sessions ?? []).length === 0) {\n return html`\n <div class=\"card\" style=\"display: grid; gap: 8px; max-width: 820px;\">\n <div class=\"card-title\">No conversations yet</div>\n <div class=\"card-sub\">Connect a channel to start receiving messages.</div>\n </div>\n `;\n }\n if (filteredSessions.length === 0) {\n return html`\n <div class=\"card\" style=\"display: grid; gap: 8px; max-width: 820px;\">\n <div class=\"card-title\">No conversations match this filter</div>\n <div class=\"card-sub\">Try a different channel filter or refresh the inbox.</div>\n </div>\n `;\n }\n return nothing;\n}\n\nfunction renderChannelBadge(session: GatewaySessionRow) {\n const channel = getChannelFromSession(session);\n if (channel === \"telegram\") {\n return html`<span class=\"chip chip-ok\">✈️ Telegram</span>`;\n }\n if (channel === \"whatsapp\") {\n return html`<span class=\"chip chip-ok\">📱 WhatsApp</span>`;\n }\n return html`<span class=\"chip\">Conversation</span>`;\n}\n\nfunction renderInboxRow(\n session: GatewaySessionRow,\n props: InboxProps,\n) {\n const channel = getChannelFromSession(session);\n const href = `${pathForTab(\"chat\", props.basePath)}?session=${encodeURIComponent(session.key)}`;\n const title =\n session.displayName?.trim() ||\n session.label?.trim() ||\n session.subject?.trim() ||\n session.derivedTitle?.trim() ||\n session.key;\n const updated = session.updatedAt ? formatRelativeTimestamp(session.updatedAt) : \"n/a\";\n const responder = formatResponder(session);\n const unanswered = !hasEmployeeReply(session);\n\n return html`\n <a\n href=${href}\n class=\"card\"\n style=\"display: block; text-decoration: none; color: inherit; transition: transform var(--duration-fast) ease, border-color var(--duration-fast) ease;\"\n @click=${(event: MouseEvent) => {\n if (\n event.defaultPrevented ||\n event.button !== 0 ||\n event.metaKey ||\n event.ctrlKey ||\n event.shiftKey ||\n event.altKey\n ) {\n return;\n }\n if (props.onNavigateToChat) {\n event.preventDefault();\n props.onNavigateToChat(session.key);\n }\n }}\n >\n <div class=\"row\" style=\"justify-content: space-between; gap: 16px; align-items: flex-start;\">\n <div style=\"display: flex; gap: 14px; align-items: flex-start; min-width: 0; flex: 1;\">\n <div\n style=\"width: 40px; height: 40px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; flex: 0 0 auto;\"\n aria-hidden=\"true\"\n >\n ${channel === \"whatsapp\" ? \"📱\" : \"✈️\"}\n </div>\n <div style=\"display: grid; gap: 8px; min-width: 0; flex: 1;\">\n <div class=\"row\" style=\"gap: 8px; flex-wrap: wrap; align-items: center;\">\n <div style=\"font-weight: 600; color: var(--text-strong); min-width: 0;\">${title}</div>\n ${renderChannelBadge(session)}\n </div>\n <div class=\"muted\" style=\"font-size: 13px; line-height: 1.45;\">\n ${formatLastMessage(session)}\n </div>\n <div class=\"muted\" style=\"font-size: 12px;\">\n ${responder}\n </div>\n </div>\n </div>\n <div style=\"display: grid; gap: 8px; justify-items: end; flex: 0 0 auto;\">\n <div class=\"muted\" style=\"font-size: 12px; white-space: nowrap;\">${updated}</div>\n ${unanswered\n ? html`\n <span\n title=\"Awaiting employee reply\"\n style=\"width: 10px; height: 10px; border-radius: 999px; background: var(--warn, #f59e0b); display: inline-block;\"\n ></span>\n `\n : nothing}\n </div>\n </div>\n </a>\n `;\n}\n\nexport function renderInbox(props: InboxProps) {\n const allSessions = props.sessions ?? [];\n const filteredSessions = filterByChannel(allSessions, props.filter);\n\n return html`\n <section class=\"page page--settings\" style=\"display: grid; gap: 20px;\">\n <div class=\"card\" style=\"display: grid; gap: 16px; max-width: 920px;\">\n <div class=\"row\" style=\"justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap;\">\n <div style=\"display: grid; gap: 4px;\">\n <div class=\"card-title\">Inbox</div>\n <div class=\"card-sub\">All conversations across your connected channels.</div>\n </div>\n <button class=\"btn\" ?disabled=${props.loading} @click=${() => props.onRefresh()}>\n ${props.loading ? \"Refreshing...\" : \"Refresh\"}\n </button>\n </div>\n\n <div class=\"chip-row\">\n ${FILTER_TABS.map(\n (tab) => html`\n <button\n class=\"chip ${props.filter === tab.id ? \"chip-ok\" : \"\"}\"\n style=\"cursor: pointer;\"\n @click=${() => props.onFilterChange(tab.id)}\n >\n ${tab.label}\n </button>\n `,\n )}\n </div>\n\n ${props.error ? html`<div class=\"callout danger\">${props.error}</div>` : nothing}\n </div>\n\n <div style=\"display: grid; gap: 14px; max-width: 920px;\">\n ${props.loading && allSessions.length === 0 ? renderSkeletonRows() : nothing}\n ${filteredSessions.map((session) => renderInboxRow(session, props))}\n ${renderEmptyState(props, filteredSessions)}\n </div>\n </section>\n `;\n}\n"],"mappings":"iKAwBA,IAAM,EAAgE,CACpE,CAAE,GAAI,MAAO,MAAO,MAAO,CAC3B,CAAE,GAAI,WAAY,MAAO,WAAY,CACrC,CAAE,GAAI,WAAY,MAAO,WAAY,CACrC,CAAE,GAAI,aAAc,MAAO,aAAc,CAC1C,CAED,SAAS,GAAqB,CAC5B,MAAO,EAAI;MACP,MAAM,KAAK,CAAE,OAAQ,EAAG,EAAG,EAAG,IAAU,CAAI;wFACsC,EAAM;;;;;;;;;;;;MAYxF,CAAC;IAIP,SAAS,EAAiB,EAAmB,EAAuC,CAoBlF,OAnBI,EAAM,QACD,GAEJ,EAAM,UAAY,EAAE,EAAE,SAAW,EAC7B,CAAI;;;;;MAOT,EAAiB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