aizek-chatbot 1.0.11 → 1.0.13

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/index.cjs CHANGED
@@ -1,251 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var React = require('react');
4
- var jsxRuntime = require('react/jsx-runtime');
3
+ var react = require('react');
5
4
  var OpenAI = require('openai');
6
5
  var ReactMarkdown = require('react-markdown');
7
6
  var remarkGfm = require('remark-gfm');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
10
 
11
- function _interopNamespace(e) {
12
- if (e && e.__esModule) return e;
13
- var n = Object.create(null);
14
- if (e) {
15
- Object.keys(e).forEach(function (k) {
16
- if (k !== 'default') {
17
- var d = Object.getOwnPropertyDescriptor(e, k);
18
- Object.defineProperty(n, k, d.get ? d : {
19
- enumerable: true,
20
- get: function () { return e[k]; }
21
- });
22
- }
23
- });
24
- }
25
- n.default = e;
26
- return Object.freeze(n);
27
- }
28
-
29
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
30
11
  var OpenAI__default = /*#__PURE__*/_interopDefault(OpenAI);
31
12
  var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
32
13
  var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
33
14
 
34
- // src/utils/cx.ts
35
- function cx(...args) {
36
- return args.filter(Boolean).join(" ");
37
- }
38
- function validateHeaders(headers, authConfig, opts = {}) {
39
- const { caseSensitive = false, allowExtra = false } = opts;
40
- const normalize = (s) => caseSensitive ? s : s.toLowerCase();
41
- const headerEntries = Object.entries(headers).map(([k, v]) => [normalize(k), v.trim()]);
42
- const authEntries = Object.entries(authConfig).map(([k, v]) => [normalize(k), v.trim()]);
43
- const headerKeys = headerEntries.map(([k]) => k);
44
- const authKeys = authEntries.map(([k]) => k);
45
- const requiredSet = new Set(authKeys);
46
- const missingKeys = authKeys.filter((k) => !headerKeys.includes(k));
47
- const extraKeys = headerKeys.filter((k) => !requiredSet.has(k));
48
- const hasAllRequired = missingKeys.length === 0;
49
- const hasExtraKeys = extraKeys.length > 0 && !allowExtra;
50
- const emptyValueKeys = authKeys.filter((k) => {
51
- const val = headerEntries.find(([key]) => key === k)?.[1];
52
- return !val || val.length === 0;
53
- });
54
- const isValid = hasAllRequired && !hasExtraKeys && emptyValueKeys.length === 0;
55
- return { isValid, missingKeys, extraKeys, emptyValueKeys };
56
- }
57
- var base = {
58
- display: "inline-flex",
59
- alignItems: "center",
60
- justifyContent: "center",
61
- borderRadius: 12,
62
- fontWeight: 600,
63
- lineHeight: 1,
64
- transition: "background-color .2s ease, color .2s ease, border-color .2s ease",
65
- outline: "none",
66
- cursor: "pointer"
67
- };
68
- var sizes = {
69
- sm: { height: 36, padding: "0 12px", fontSize: 14 },
70
- md: { height: 40, padding: "0 16px", fontSize: 16 },
71
- lg: { height: 44, padding: "0 20px", fontSize: 18 }
72
- };
73
- var palette = {
74
- brand: {
75
- primary: "#2563eb",
76
- primaryHover: "#1d4ed8"
77
- }
78
- };
79
- function styleFor(variant) {
80
- switch (variant) {
81
- case "outline":
82
- return {
83
- background: "transparent",
84
- color: palette.brand.primary,
85
- border: `1px solid ${palette.brand.primary}`
86
- };
87
- case "ghost":
88
- return {
89
- background: "transparent",
90
- color: palette.brand.primary,
91
- border: "1px solid transparent"
92
- };
93
- default:
94
- return {
95
- background: palette.brand.primary,
96
- color: "#fff",
97
- border: "1px solid transparent"
98
- };
99
- }
100
- }
101
- var Button = React__namespace.forwardRef(
102
- ({ variant = "primary", size = "md", style, className, onMouseEnter, onMouseLeave, ...props }, ref) => {
103
- const [hover, setHover] = React__namespace.useState(false);
104
- const hoverStyle = variant === "primary" ? { background: hover ? palette.brand.primaryHover : palette.brand.primary } : variant === "outline" ? { borderColor: hover ? palette.brand.primaryHover : palette.brand.primary } : { background: hover ? "rgba(37, 99, 235, 0.08)" : "transparent" };
105
- return /* @__PURE__ */ jsxRuntime.jsx(
106
- "button",
107
- {
108
- ref,
109
- className: cx("rui-btn", className),
110
- style: { ...base, ...sizes[size], ...styleFor(variant), ...hover ? hoverStyle : {}, ...style },
111
- onMouseEnter: (e) => {
112
- setHover(true);
113
- onMouseEnter?.(e);
114
- },
115
- onMouseLeave: (e) => {
116
- setHover(false);
117
- onMouseLeave?.(e);
118
- },
119
- ...props
120
- }
121
- );
122
- }
123
- );
124
- Button.displayName = "Button";
125
- var useChatbot = (options = {}) => {
126
- const { mcpUrl, apiKey, config } = options;
127
- const client = new OpenAI__default.default({ apiKey, dangerouslyAllowBrowser: true });
128
- const [responseId, setResponseId] = React.useState(null);
129
- const [messages, setMessages] = React.useState([]);
130
- const [isLoading, setIsLoading] = React.useState(false);
131
- const generateId = () => {
132
- return Date.now().toString() + Math.random().toString(36).substr(2, 9);
133
- };
134
- const addMessage = (payload, role) => {
135
- const newMessage = {
136
- id: generateId(),
137
- text: payload.text,
138
- ui: payload.ui,
139
- role,
140
- timestamp: /* @__PURE__ */ new Date()
141
- };
142
- setMessages((prev) => [...prev, newMessage]);
143
- return newMessage;
144
- };
145
- const extractUiComponents = (raw) => {
146
- const regex = /```ui-component([\s\S]*?)```/g;
147
- const components = [];
148
- let cleaned = raw;
149
- let match;
150
- let componentIndex = 0;
151
- while ((match = regex.exec(raw)) !== null) {
152
- const block = match[1].trim();
153
- try {
154
- const json = JSON.parse(block);
155
- if (json.type === "buttons" && json.data && typeof json.data === "object" && !Array.isArray(json.data)) {
156
- if (json.data.options && Array.isArray(json.data.options)) {
157
- json.data = json.data.options.map((opt) => {
158
- if (opt.id && opt.label) {
159
- return {
160
- label: opt.label,
161
- value: opt.id,
162
- variant: opt.variant
163
- };
164
- }
165
- return opt;
166
- });
167
- }
168
- }
169
- if (json.type === "table" && json.data) {
170
- if (Array.isArray(json.data.columns) && json.data.columns.length > 0) {
171
- const firstCol = json.data.columns[0];
172
- if (typeof firstCol === "string") {
173
- json.data.columns = json.data.columns.map(
174
- (col, idx) => ({
175
- id: `col-${idx}`,
176
- label: col
177
- })
178
- );
179
- }
180
- }
181
- if (Array.isArray(json.data.rows) && json.data.rows.length > 0) {
182
- const firstRow = json.data.rows[0];
183
- if (Array.isArray(firstRow) && typeof firstRow[0] === "string") {
184
- json.data.rows = json.data.rows.map((row) => {
185
- const rowObj = {};
186
- json.data.columns.forEach((col, idx) => {
187
- const colId = typeof col === "string" ? `col-${idx}` : col.id;
188
- const cellValue = row[idx];
189
- if (typeof cellValue === "string" && (cellValue.startsWith("http") || cellValue.startsWith("data:"))) {
190
- rowObj[colId] = {
191
- type: "image",
192
- src: cellValue,
193
- alt: ""
194
- };
195
- } else {
196
- rowObj[colId] = {
197
- type: "text",
198
- value: cellValue || ""
199
- };
200
- }
201
- });
202
- return rowObj;
203
- });
204
- }
205
- }
206
- }
207
- if (json.type === "form" && json.data) {
208
- if (!json.data.id) {
209
- json.data.id = json.id || `form-${componentIndex}`;
210
- }
211
- if (json.data.fields && Array.isArray(json.data.fields)) {
212
- json.data.fields = json.data.fields.map((field) => {
213
- if (field.optional !== void 0) {
214
- field.required = !field.optional;
215
- delete field.optional;
216
- }
217
- if (!field.type) {
218
- field.type = "text";
219
- }
220
- if (field.options && Array.isArray(field.options)) {
221
- const firstOption = field.options[0];
222
- if (typeof firstOption === "string") {
223
- field.options = field.options.map((opt) => ({
224
- label: opt,
225
- value: opt
226
- }));
227
- }
228
- }
229
- return field;
230
- });
231
- }
232
- }
233
- if (json.id && typeof json.id !== "string") {
234
- json.id = String(json.id);
235
- }
236
- if (!json.id || !json.id.trim()) {
237
- json.id = `ui-comp-${componentIndex}-${Date.now()}`;
238
- }
239
- components.push(json);
240
- componentIndex++;
241
- } catch (e) {
242
- console.error("Invalid ui-component JSON:", e, block);
243
- }
244
- cleaned = cleaned.replace(match[0], "").trim();
245
- }
246
- return { text: cleaned, components };
247
- };
248
- const instructions = `You are Aizek, an AI assistant running in an environment with Model Context Protocol (MCP) tools.
15
+ // src/utils/prompt.ts
16
+ var instructions = `You are Aizek, an AI assistant running in an environment with Model Context Protocol (MCP) tools.
249
17
 
250
18
  Your top priority is to USE MCP TOOLS whenever they can handle the user's request.
251
19
  Do NOT bypass available tools to answer from generic knowledge, web browsing, or other external sources if a suitable MCP tool exists.
@@ -387,33 +155,301 @@ In this order of priority:
387
155
 
388
156
  Always keep in mind:
389
157
  Your core value in this environment is to be an intelligent router and operator for MCP tools, not a generic, unconstrained chatbot.`;
390
- const SYSTEM_PROMPT = `
158
+ var SYSTEM_PROMPT = `
391
159
  You are a helpful assistant that can generate both natural language responses and UI components.
392
160
 
393
161
  You MUST:
394
162
  - Always respond with normal conversational text.
395
163
  - Optionally include one or more UI components inside code blocks with language "ui-component".
396
164
 
397
- When to use components:
165
+ IMPORTANT:
166
+ - Do NOT invent HTML. Only JSON as described.
167
+ - Keep JSON strictly valid.
168
+ - Text response should be outside of code blocks.
169
+
170
+ STRICT REQUIREMENTS (CRITICAL):
171
+ - All component JSON must STRICTLY MATCH the TypeScript types given below.
172
+ - You MUST NOT create extra fields not defined in the types.
173
+ - You MUST NOT rename keys. Example: using "key" instead of "id" in a form field is INVALID.
174
+ - Only use the exact field names defined in the interfaces below.
175
+ - All JSON must be strictly valid.
176
+
177
+ -------------------------------------------
178
+ TYPES YOU MUST FOLLOW EXACTLY:
179
+
180
+ UIField =
181
+ UITextField | UIImageField | UILinkField | UIBadgeField | UIListField
182
+
183
+ UITextField:
184
+ {
185
+ "type": "text",
186
+ "value": string
187
+ }
188
+
189
+ UIImageField:
190
+ {
191
+ "type": "image",
192
+ "src": string,
193
+ "alt"?: string
194
+ }
195
+
196
+ UILinkField:
197
+ {
198
+ "type": "link",
199
+ "label": string,
200
+ "href": string
201
+ }
202
+
203
+ UIBadgeField:
204
+ {
205
+ "type": "badge",
206
+ "label": string,
207
+ "tone"?: "success" | "warning" | "danger" | "info" | "neutral"
208
+ }
209
+
210
+ UIListField:
211
+ {
212
+ "type": "list",
213
+ "items": UIField[]
214
+ }
215
+
216
+ -------------------------------------------------
217
+
218
+ UIFormData:
219
+ {
220
+ "id": string,
221
+ "title"?: string,
222
+ "fields": UIFormField[],
223
+ "submitLabel"?: string
224
+ }
225
+
226
+ UIFormField:
227
+ {
228
+ "id": string,
229
+ "name": string,
230
+ "label": string,
231
+ "placeholder"?: string,
232
+ "type": "text" | "select" | "number" | "file",
233
+ "accept"?: string,
234
+ "required"?: boolean,
235
+ "validation"?: string,
236
+ "options"?: { "label": string, "value": string }[],
237
+ "value"?: string | number,
238
+ "min"?: number,
239
+ "max"?: number
240
+ }
241
+
242
+ -------------------------------------------------
243
+
244
+ UIButtonData:
245
+ {
246
+ "label": string,
247
+ "value": string,
248
+ "variant"?: "primary" | "secondary" | "danger"
249
+ }
250
+
251
+ -------------------------------------------------
252
+
253
+ UITableData:
254
+ {
255
+ "caption"?: string,
256
+ "columns": UITableColumn[] | string[],
257
+ "rows": Array<Record<string, UIField | string>> | string[][]
258
+ }
259
+
260
+ UITableColumn:
261
+ {
262
+ "id"?: string,
263
+ "key"?: string,
264
+ "label": string,
265
+ "type"?: "image" | "text" | "badge"
266
+ }
267
+
268
+ -------------------------------------------------
269
+
270
+ UICardData:
271
+ {
272
+ "title"?: string,
273
+ "description"?: string,
274
+ "image"?: string,
275
+ "status"?: string,
276
+ "subtitle"?: string,
277
+ "fields"?: UICardField[],
278
+ "attributes"?: UICardField[],
279
+ "items"?: UICardItem[],
280
+ "[key: string]": any
281
+ }
282
+
283
+ UICardField:
284
+ {
285
+ "label": string,
286
+ "value": string
287
+ }
288
+
289
+ UICardItem:
290
+ {
291
+ "id"?: string,
292
+ "title"?: string,
293
+ "subtitle"?: string,
294
+ "image"?: string,
295
+ "label"?: string,
296
+ "value"?: string
297
+ }
298
+
299
+ -------------------------------------------------
300
+
301
+ UIComponent:
302
+ {
303
+ "type": "form" | "buttons" | "table" | "card",
304
+ "data": (the relevant data according to type)
305
+ }
306
+
307
+ -------------------------------------------
308
+
309
+ RULES FOR WHEN TO USE COMPONENTS:
398
310
  - User needs to provide multiple structured values \u2192 generate a FORM
399
311
  - User must choose among options \u2192 generate BUTTONS
400
312
  - User must see structured data comparison \u2192 generate a TABLE
401
313
  - User must see entity details/summary \u2192 generate a CARD
402
314
 
403
- Format for each component (strictly):
315
+ FORMAT FOR EACH COMPONENT:
404
316
 
405
317
  \`\`\`ui-component
406
318
  {
407
- "type": "form" | "buttons" | "table" | "card",
408
- "data": { ...component-specific fields... }
319
+ "type": "...",
320
+ "data": { ... }
409
321
  }
410
322
  \`\`\`
411
-
412
- IMPORTANT:
413
- - Do NOT invent HTML. Only JSON as described.
414
- - Keep JSON strictly valid.
415
- - Text response should be outside of code blocks.
416
323
  `;
324
+
325
+ // src/hooks/use-chatbot.ts
326
+ var useChatbot = (options = {}) => {
327
+ const { mcpUrl, apiKey, config } = options;
328
+ const client = new OpenAI__default.default({
329
+ apiKey,
330
+ baseURL: "https://api.anthropic.com/v1/",
331
+ dangerouslyAllowBrowser: true
332
+ });
333
+ const [responseId, setResponseId] = react.useState(null);
334
+ const [messages, setMessages] = react.useState([]);
335
+ const [isLoading, setIsLoading] = react.useState(false);
336
+ const generateId = () => {
337
+ return Date.now().toString() + Math.random().toString(36).substr(2, 9);
338
+ };
339
+ const addMessage = (payload, role) => {
340
+ const newMessage = {
341
+ id: generateId(),
342
+ text: payload.text,
343
+ ui: payload.ui,
344
+ role,
345
+ timestamp: /* @__PURE__ */ new Date()
346
+ };
347
+ setMessages((prev) => [...prev, newMessage]);
348
+ return newMessage;
349
+ };
350
+ const extractUiComponents = (raw) => {
351
+ const regex = /```ui-component([\s\S]*?)```/g;
352
+ const components = [];
353
+ let cleaned = raw;
354
+ let match;
355
+ let componentIndex = 0;
356
+ while ((match = regex.exec(raw)) !== null) {
357
+ const block = match[1].trim();
358
+ try {
359
+ const json = JSON.parse(block);
360
+ if (json.type === "buttons" && json.data && typeof json.data === "object" && !Array.isArray(json.data)) {
361
+ if (json.data.options && Array.isArray(json.data.options)) {
362
+ json.data = json.data.options.map((opt) => {
363
+ if (opt.id && opt.label) {
364
+ return {
365
+ label: opt.label,
366
+ value: opt.id,
367
+ variant: opt.variant
368
+ };
369
+ }
370
+ return opt;
371
+ });
372
+ }
373
+ }
374
+ if (json.type === "table" && json.data) {
375
+ if (Array.isArray(json.data.columns) && json.data.columns.length > 0) {
376
+ const firstCol = json.data.columns[0];
377
+ if (typeof firstCol === "string") {
378
+ json.data.columns = json.data.columns.map(
379
+ (col, idx) => ({
380
+ id: `col-${idx}`,
381
+ label: col
382
+ })
383
+ );
384
+ }
385
+ }
386
+ if (Array.isArray(json.data.rows) && json.data.rows.length > 0) {
387
+ const firstRow = json.data.rows[0];
388
+ if (Array.isArray(firstRow) && typeof firstRow[0] === "string") {
389
+ json.data.rows = json.data.rows.map((row) => {
390
+ const rowObj = {};
391
+ json.data.columns.forEach((col, idx) => {
392
+ const colId = typeof col === "string" ? `col-${idx}` : col.id;
393
+ const cellValue = row[idx];
394
+ if (typeof cellValue === "string" && (cellValue.startsWith("http") || cellValue.startsWith("data:"))) {
395
+ rowObj[colId] = {
396
+ type: "image",
397
+ src: cellValue,
398
+ alt: ""
399
+ };
400
+ } else {
401
+ rowObj[colId] = {
402
+ type: "text",
403
+ value: cellValue || ""
404
+ };
405
+ }
406
+ });
407
+ return rowObj;
408
+ });
409
+ }
410
+ }
411
+ }
412
+ if (json.type === "form" && json.data) {
413
+ if (!json.data.id) {
414
+ json.data.id = json.id || `form-${componentIndex}`;
415
+ }
416
+ if (json.data.fields && Array.isArray(json.data.fields)) {
417
+ json.data.fields = json.data.fields.map((field) => {
418
+ if (field.optional !== void 0) {
419
+ field.required = !field.optional;
420
+ delete field.optional;
421
+ }
422
+ if (!field.type) {
423
+ field.type = "text";
424
+ }
425
+ if (field.options && Array.isArray(field.options)) {
426
+ const firstOption = field.options[0];
427
+ if (typeof firstOption === "string") {
428
+ field.options = field.options.map((opt) => ({
429
+ label: opt,
430
+ value: opt
431
+ }));
432
+ }
433
+ }
434
+ return field;
435
+ });
436
+ }
437
+ }
438
+ if (json.id && typeof json.id !== "string") {
439
+ json.id = String(json.id);
440
+ }
441
+ if (!json.id || !json.id.trim()) {
442
+ json.id = `ui-comp-${componentIndex}-${Date.now()}`;
443
+ }
444
+ components.push(json);
445
+ componentIndex++;
446
+ } catch (e) {
447
+ console.error("Invalid ui-component JSON:", e, block);
448
+ }
449
+ cleaned = cleaned.replace(match[0], "").trim();
450
+ }
451
+ return { text: cleaned, components };
452
+ };
417
453
  const sendMessage = async (message, approval) => {
418
454
  if (!message.trim() || isLoading) return;
419
455
  if (approval) {
@@ -425,7 +461,7 @@ IMPORTANT:
425
461
  try {
426
462
  let resp;
427
463
  resp = await client.responses.create({
428
- model: "gpt-5",
464
+ model: "claude-sonnet-4-5",
429
465
  tools: [
430
466
  {
431
467
  type: "mcp",
@@ -485,7 +521,7 @@ IMPORTANT:
485
521
  };
486
522
  };
487
523
 
488
- // src/services/chatWidgetApi.ts
524
+ // src/services/chat-widget-api.ts
489
525
  var API_BASE_URL = "https://api-alpha.aizek.ai";
490
526
  var fetchChatWidgetSettings = async (clientId) => {
491
527
  try {
@@ -530,730 +566,25 @@ var mapApiSettingsToConfig = (apiSettings) => {
530
566
  };
531
567
  };
532
568
 
533
- // src/styles/messageStyles.ts
534
- var getMessageBubbleStyles = (isUser, isTyping) => ({
535
- maxWidth: "80%",
536
- padding: "12px 16px",
537
- borderRadius: isUser ? "18px 18px 4px 18px" : "18px 18px 18px 4px",
538
- marginBottom: "8px",
539
- wordWrap: "break-word",
540
- lineHeight: 1.4,
541
- fontSize: "14px",
542
- position: "relative",
543
- ...isUser ? {
544
- background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
545
- color: "#ffffff",
546
- marginLeft: "auto",
547
- marginRight: "0"
548
- } : {
549
- background: "#f8fafc",
550
- color: "#334155",
551
- border: "1px solid #e2e8f0",
552
- marginLeft: "0",
553
- marginRight: "auto"
554
- }
555
- });
556
- var getTimeStyles = (isUser) => ({
557
- fontSize: "11px",
558
- opacity: 0.7,
559
- marginTop: "4px",
560
- textAlign: isUser ? "right" : "left"
561
- });
562
- var getMarkdownStyles = () => ({
563
- lineHeight: 1.6,
564
- marginBottom: "6px"
565
- });
566
- var getMarkdownElementStyles = (isUser) => `
567
- .markdown-content p {
568
- margin: 0 0 12px 0;
569
- line-height: 1.6;
570
- }
571
- .markdown-content p:last-child {
572
- margin-bottom: 0;
573
- }
574
- .markdown-content ul {
575
- margin: 12px 0 16px 0;
576
- padding-left: 0;
577
- list-style: none;
578
- }
579
- .markdown-content li {
580
- margin-bottom: 12px;
581
- line-height: 1.6;
582
- padding: 12px 16px;
583
- background: ${isUser ? "rgba(255,255,255,0.1)" : "#ffffff"};
584
- border-radius: 12px;
585
- border: 1px solid ${isUser ? "rgba(255,255,255,0.2)" : "#e2e8f0"};
586
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
587
- position: relative;
588
- transition: all 0.2s ease;
589
- }
590
- .markdown-content li:hover {
591
- transform: translateY(-1px);
592
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
593
- }
594
- .markdown-content li::before {
595
- content: "\u2022";
596
- color: ${isUser ? "#ffffff" : "#667eea"};
597
- font-weight: bold;
598
- font-size: 18px;
599
- position: absolute;
600
- left: -8px;
601
- top: 12px;
602
- }
603
- .markdown-content li strong {
604
- display: block;
605
- font-size: 15px;
606
- margin-bottom: 4px;
607
- color: ${isUser ? "#ffffff" : "#1e293b"};
608
- }
609
- .markdown-content li em {
610
- display: block;
611
- font-size: 13px;
612
- opacity: 0.8;
613
- margin-top: 4px;
614
- }
615
- .markdown-content strong {
616
- font-weight: 600;
617
- color: ${isUser ? "#ffffff" : "#1e293b"};
618
- }
619
- .markdown-content em {
620
- font-style: italic;
621
- opacity: 0.9;
622
- }
623
- .markdown-content code {
624
- background: ${isUser ? "rgba(255,255,255,0.2)" : "#f1f5f9"};
625
- padding: 2px 6px;
626
- border-radius: 4px;
627
- font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
628
- font-size: 13px;
629
- }
630
- .markdown-content pre {
631
- background: ${isUser ? "rgba(255,255,255,0.1)" : "#f8fafc"};
632
- padding: 12px;
633
- border-radius: 8px;
634
- overflow-x: auto;
635
- margin: 8px 0;
636
- border: 1px solid ${isUser ? "rgba(255,255,255,0.2)" : "#e2e8f0"};
637
- }
638
- .markdown-content pre code {
639
- background: none;
640
- padding: 0;
641
- }
642
- .markdown-content blockquote {
643
- border-left: 3px solid ${isUser ? "rgba(255,255,255,0.5)" : "#cbd5e1"};
644
- padding-left: 12px;
645
- margin: 8px 0;
646
- opacity: 0.8;
647
- }
648
- .markdown-content h1, .markdown-content h2, .markdown-content h3 {
649
- margin: 16px 0 8px 0;
650
- font-weight: 600;
651
- }
652
- .markdown-content h1 {
653
- font-size: 18px;
654
- }
655
- .markdown-content h2 {
656
- font-size: 16px;
657
- }
658
- .markdown-content h3 {
659
- font-size: 15px;
660
- }
661
- .markdown-content table {
662
- border-collapse: collapse;
663
- width: 100%;
664
- margin: 8px 0;
665
- }
666
- .markdown-content th, .markdown-content td {
667
- border: 1px solid ${isUser ? "rgba(255,255,255,0.3)" : "#e2e8f0"};
668
- padding: 8px 12px;
669
- text-align: left;
670
- }
671
- .markdown-content th {
672
- background: ${isUser ? "rgba(255,255,255,0.1)" : "#f8fafc"};
673
- font-weight: 600;
674
- }
675
-
676
- /* Enhanced list styling */
677
- .markdown-content li {
678
- position: relative;
679
- overflow: hidden;
680
- }
681
-
682
- .markdown-content li::after {
683
- content: "";
684
- position: absolute;
685
- top: 0;
686
- left: 0;
687
- width: 4px;
688
- height: 100%;
689
- background: linear-gradient(135deg, ${isUser ? "#ffffff" : "#667eea"}, ${isUser ? "rgba(255,255,255,0.5)" : "#764ba2"});
690
- border-radius: 0 2px 2px 0;
691
- }
692
-
693
- /* Product name styling */
694
- .markdown-content li strong:first-child {
695
- color: ${isUser ? "#ffffff" : "#1e293b"};
696
- font-size: 16px;
697
- font-weight: 700;
698
- display: block;
699
- margin-bottom: 8px;
700
- }
701
-
702
- /* Product details styling */
703
- .markdown-content li strong:not(:first-child) {
704
- color: ${isUser ? "#ffffff" : "#059669"};
705
- font-size: 13px;
706
- font-weight: 600;
707
- margin-right: 8px;
708
- }
709
-
710
- /* Add some spacing between product details */
711
- .markdown-content li br + * {
712
- margin-top: 4px;
713
- }
714
-
715
- /* Hover effect enhancement */
716
- .markdown-content li:hover::after {
717
- width: 6px;
718
- background: linear-gradient(135deg, ${isUser ? "#ffffff" : "#667eea"}, ${isUser ? "#ffffff" : "#764ba2"});
719
- }
720
- `;
721
- var getMessageContainerStyles = (isUser) => ({
722
- display: "flex",
723
- flexDirection: "column",
724
- alignItems: isUser ? "flex-end" : "flex-start",
725
- width: "100%"
726
- });
727
-
728
- // src/styles/inputStyles.ts
729
- var getInputContainerStyles = () => ({
730
- display: "flex",
731
- alignItems: "flex-end",
732
- gap: "12px",
733
- padding: "16px",
734
- background: "#ffffff",
735
- borderTop: "1px solid #e2e8f0",
736
- borderRadius: "0 0 12px 12px"
737
- });
738
- var getTextareaStyles = (isLoading) => ({
739
- flex: 1,
740
- minHeight: "44px",
741
- maxHeight: "120px",
742
- padding: "12px 16px",
743
- border: "1px solid #e2e8f0",
744
- borderRadius: "22px",
745
- fontSize: "14px",
746
- lineHeight: 1.4,
747
- resize: "none",
748
- outline: "none",
749
- transition: "border-color 0.2s ease, box-shadow 0.2s ease",
750
- fontFamily: "inherit",
751
- background: "#f8fafc",
752
- color: "#334155",
753
- ...isLoading ? {
754
- opacity: 0.6,
755
- cursor: "not-allowed"
756
- } : {}
757
- });
758
- var getSendButtonStyles = (isLoading, hasMessage) => ({
759
- width: "44px",
760
- height: "44px",
761
- borderRadius: "50%",
762
- border: "none",
763
- background: isLoading || !hasMessage ? "#e2e8f0" : "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
764
- color: "#ffffff",
765
- cursor: isLoading || !hasMessage ? "not-allowed" : "pointer",
766
- display: "flex",
767
- alignItems: "center",
768
- justifyContent: "center",
769
- transition: "all 0.2s ease",
770
- fontSize: "16px"
771
- });
772
-
773
- // src/styles/headerStyles.ts
774
- var getHeaderStyles = (headerBackground) => ({
775
- padding: "16px 20px",
776
- background: headerBackground,
777
- color: "#ffffff",
778
- display: "flex",
779
- alignItems: "center",
780
- gap: "12px"
781
- });
782
- var getLogoContainerStyles = () => ({
783
- width: "40px",
784
- height: "40px",
785
- borderRadius: "50%",
786
- background: "rgba(255, 255, 255, 0.2)",
787
- display: "flex",
788
- alignItems: "center",
789
- justifyContent: "center",
790
- fontSize: "18px",
791
- overflow: "hidden"
792
- });
793
- var getLogoImageStyles = () => ({
794
- width: "100%",
795
- height: "100%",
796
- objectFit: "cover",
797
- borderRadius: "50%"
798
- });
799
- var getLogoTextStyles = () => ({
800
- fontSize: "16px",
801
- fontWeight: "bold"
802
- });
803
- var getCompanyNameStyles = () => ({
804
- margin: 0,
805
- fontSize: "16px",
806
- fontWeight: 600
807
- });
808
- var getStatusTextStyles = () => ({
809
- margin: 0,
810
- fontSize: "12px",
811
- opacity: 0.8
812
- });
813
-
814
- // src/styles/containerStyles.ts
815
- var getButtonSizes = () => ({
816
- sm: { width: "50px", height: "50px", fontSize: "20px" },
817
- md: { width: "60px", height: "60px", fontSize: "24px" },
818
- lg: { width: "70px", height: "70px", fontSize: "28px" }
819
- });
820
- var getFloatingButtonStyles = (buttonPosition, buttonSize, buttonBackground, isOpen) => {
821
- const buttonSizes = getButtonSizes();
822
- const buttonSizeStyle = buttonSizes[buttonSize];
823
- return {
824
- position: "fixed",
825
- [buttonPosition === "bottom-left" ? "left" : "right"]: "20px",
826
- bottom: "20px",
827
- width: buttonSizeStyle.width,
828
- height: buttonSizeStyle.height,
829
- borderRadius: "50%",
830
- background: buttonBackground,
831
- border: "none",
832
- color: "#ffffff",
833
- cursor: "pointer",
834
- display: "flex",
835
- alignItems: "center",
836
- justifyContent: "center",
837
- fontSize: buttonSizeStyle.fontSize,
838
- boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
839
- transition: "all 0.3s ease",
840
- zIndex: 1e3,
841
- transform: isOpen ? "scale(0.9)" : "scale(1)"
842
- };
843
- };
844
- var getChatContainerStyles = (buttonPosition, chatWidth, chatHeight, isOpen) => ({
845
- position: "fixed",
846
- [buttonPosition === "bottom-left" ? "left" : "right"]: "20px",
847
- bottom: "90px",
848
- width: chatWidth,
849
- height: chatHeight,
850
- zIndex: 9999999,
851
- transform: isOpen ? "translateY(0) scale(1)" : "translateY(20px) scale(0.95)",
852
- opacity: isOpen ? 1 : 0,
853
- visibility: isOpen ? "visible" : "hidden",
854
- transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
855
- transformOrigin: buttonPosition === "bottom-left" ? "bottom left" : "bottom right"
856
- });
857
- var getOverlayStyles = (isOpen) => ({
858
- position: "fixed",
859
- top: 0,
860
- left: 0,
861
- right: 0,
862
- bottom: 0,
863
- background: "rgba(0, 0, 0, 0.1)",
864
- zIndex: 998,
865
- opacity: isOpen ? 1 : 0,
866
- visibility: isOpen ? "visible" : "hidden",
867
- transition: "all 0.3s ease"
868
- });
869
- var getChatbotContainerStyles = () => ({
870
- display: "flex",
871
- flexDirection: "column",
872
- height: "100%",
873
- background: "#ffffff",
874
- borderRadius: "12px",
875
- boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
876
- border: "1px solid #e2e8f0",
877
- overflow: "hidden"
878
- });
879
- var getMessagesContainerStyles = () => ({
880
- flex: 1,
881
- overflowY: "auto",
882
- padding: "16px",
883
- display: "flex",
884
- flexDirection: "column",
885
- gap: "4px",
886
- background: "#f8fafc"
887
- });
888
- var getEmptyStateStyles = () => ({
889
- display: "flex",
890
- flexDirection: "column",
891
- alignItems: "center",
892
- justifyContent: "center",
893
- height: "100%",
894
- color: "#64748b",
895
- textAlign: "center",
896
- padding: "40px 20px"
897
- });
898
-
899
- // src/styles/loadingStyles.ts
900
- var getLoadingSpinnerStyles = () => ({
901
- width: "16px",
902
- height: "16px",
903
- border: "2px solid transparent",
904
- borderTop: "2px solid currentColor",
905
- borderRadius: "50%",
906
- animation: "spin 1s linear infinite"
907
- });
908
-
909
- // src/styles/alertStyles.ts
910
- var getAlertContainerStyles = (type) => {
911
- const colors = {
912
- error: {
913
- background: "linear-gradient(135deg, #ef4444 0%, #dc2626 100%)",
914
- border: "#dc2626",
915
- shadow: "rgba(239, 68, 68, 0.2)"
916
- },
917
- warning: {
918
- background: "linear-gradient(135deg, #f59e0b 0%, #d97706 100%)",
919
- border: "#d97706",
920
- shadow: "rgba(245, 158, 11, 0.2)"
921
- },
922
- success: {
923
- background: "linear-gradient(135deg, #10b981 0%, #059669 100%)",
924
- border: "#059669",
925
- shadow: "rgba(16, 185, 129, 0.2)"
926
- }
927
- };
928
- const selectedColor = colors[type];
929
- return {
930
- background: selectedColor.background,
931
- border: `1px solid ${selectedColor.border}`,
932
- borderRadius: "12px",
933
- padding: "14px 16px",
934
- margin: "12px 16px",
935
- boxShadow: `0 4px 12px ${selectedColor.shadow}`,
936
- color: "#ffffff",
937
- fontSize: "13px",
938
- display: "flex",
939
- alignItems: "flex-start",
940
- gap: "12px",
941
- position: "relative",
942
- animation: "slideDown 0.3s ease-out"
943
- };
944
- };
945
- var getAlertIconContainerStyles = () => ({
946
- display: "flex",
947
- alignItems: "center",
948
- justifyContent: "center",
949
- width: "24px",
950
- height: "24px",
951
- flexShrink: 0,
952
- marginTop: "2px"
953
- });
954
- var getAlertContentStyles = () => ({
955
- flex: 1,
956
- display: "flex",
957
- flexDirection: "column",
958
- gap: "8px"
959
- });
960
- var getAlertTitleStyles = () => ({
961
- fontWeight: 600,
962
- fontSize: "14px",
963
- margin: 0,
964
- lineHeight: 1.4
965
- });
966
- var getAlertMessageStyles = () => ({
967
- margin: 0,
968
- lineHeight: 1.5,
969
- opacity: 0.95
970
- });
971
- var getAlertListStyles = () => ({
972
- margin: "8px 0 0 0",
973
- paddingLeft: "20px",
974
- listStyle: "none"
975
- });
976
- var getAlertListItemStyles = () => ({
977
- marginBottom: "4px",
978
- position: "relative",
979
- paddingLeft: "12px",
980
- lineHeight: 1.4
981
- });
982
- var getAlertCloseButtonStyles = () => ({
983
- position: "absolute",
984
- top: "12px",
985
- right: "12px",
986
- background: "rgba(255, 255, 255, 0.2)",
987
- border: "none",
988
- borderRadius: "6px",
989
- width: "24px",
990
- height: "24px",
991
- display: "flex",
992
- alignItems: "center",
993
- justifyContent: "center",
994
- cursor: "pointer",
995
- color: "#ffffff",
996
- transition: "all 0.2s ease",
997
- padding: 0
998
- });
999
- var getAlertAnimationStyles = () => `
1000
- @keyframes slideDown {
1001
- from {
1002
- opacity: 0;
1003
- transform: translateY(-10px);
1004
- }
1005
- to {
1006
- opacity: 1;
1007
- transform: translateY(0);
1008
- }
1009
- }
1010
- `;
1011
- function UIRenderer({ components, onInteraction }) {
1012
- console.log(components);
1013
- if (!Array.isArray(components) || components.length === 0) {
1014
- return null;
1015
- }
1016
- return /* @__PURE__ */ jsxRuntime.jsx(
1017
- "div",
1018
- {
1019
- style: {
1020
- display: "flex",
1021
- flexDirection: "column",
1022
- gap: "16px",
1023
- width: "100%"
1024
- },
1025
- children: components.map((comp, idx) => {
1026
- if (!comp || typeof comp !== "object" || !comp.type) {
1027
- return null;
1028
- }
1029
- const key = typeof comp.id === "string" && comp.id.trim() ? comp.id : `${comp.type}-${idx}`;
1030
- switch (comp.type) {
1031
- case "form":
1032
- return /* @__PURE__ */ jsxRuntime.jsx(
1033
- FormComponent,
1034
- {
1035
- data: comp.data,
1036
- onSubmit: (values) => onInteraction?.({
1037
- type: "formSubmit",
1038
- componentId: comp.data.id,
1039
- values
1040
- })
1041
- },
1042
- key
1043
- );
1044
- case "buttons":
1045
- if (!comp.data || !Array.isArray(comp.data)) {
1046
- return null;
1047
- }
1048
- return /* @__PURE__ */ jsxRuntime.jsx(
1049
- ButtonsComponent,
1050
- {
1051
- data: comp.data,
1052
- onClick: (value) => onInteraction?.({ type: "buttonClick", value })
1053
- },
1054
- key
1055
- );
1056
- case "table":
1057
- return /* @__PURE__ */ jsxRuntime.jsx(TableComponent, { data: comp.data }, key);
1058
- case "card":
1059
- return /* @__PURE__ */ jsxRuntime.jsx(CardComponent, { data: comp.data }, key);
1060
- default:
1061
- return null;
1062
- }
1063
- })
1064
- }
1065
- );
1066
- }
1067
- function FormComponent({
1068
- data,
1069
- onSubmit
1070
- }) {
1071
- const handleSubmit = (e) => {
1072
- e.preventDefault();
1073
- console.log(e.currentTarget);
1074
- const formData = new FormData(e.currentTarget);
1075
- console.log(formData);
1076
- const values = {};
1077
- data.fields.forEach((f) => {
1078
- values[f.id || f.name] = String(formData.get(f.id || f.name) ?? "");
1079
- });
1080
- onSubmit(values);
1081
- };
1082
- console.log("formdata", data);
1083
- return /* @__PURE__ */ jsxRuntime.jsxs(
1084
- "form",
1085
- {
1086
- onSubmit: handleSubmit,
1087
- style: {
1088
- width: "100%",
1089
- maxWidth: "500px",
1090
- border: "1px solid #e0e0e0",
1091
- borderRadius: "12px",
1092
- padding: "24px",
1093
- backgroundColor: "#ffffff",
1094
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.08)",
1095
- fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'
1096
- },
1097
- children: [
1098
- data.title && /* @__PURE__ */ jsxRuntime.jsx(
1099
- "h3",
1100
- {
1101
- style: {
1102
- fontWeight: 600,
1103
- fontSize: "16px",
1104
- marginBottom: "20px",
1105
- color: "#1a1a1a",
1106
- marginTop: 0
1107
- },
1108
- children: data.title
1109
- }
1110
- ),
1111
- /* @__PURE__ */ jsxRuntime.jsx(
1112
- "div",
1113
- {
1114
- style: {
1115
- display: "flex",
1116
- flexDirection: "column",
1117
- gap: "20px"
1118
- },
1119
- children: data.fields.map((field, fieldIdx) => {
1120
- const fieldKey = typeof field.id === "string" && field.id.trim() ? field.id : `field-${fieldIdx}`;
1121
- return /* @__PURE__ */ jsxRuntime.jsxs(
1122
- "div",
1123
- {
1124
- style: {
1125
- display: "flex",
1126
- flexDirection: "column",
1127
- gap: "8px"
1128
- },
1129
- children: [
1130
- /* @__PURE__ */ jsxRuntime.jsxs(
1131
- "label",
1132
- {
1133
- style: {
1134
- fontWeight: 500,
1135
- fontSize: "13px",
1136
- color: "#374151",
1137
- display: "flex",
1138
- alignItems: "center",
1139
- gap: "4px"
1140
- },
1141
- children: [
1142
- field.label,
1143
- field.required && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#ef4444", fontSize: "14px" }, children: "*" })
1144
- ]
1145
- }
1146
- ),
1147
- field.type === "select" ? /* @__PURE__ */ jsxRuntime.jsxs(
1148
- "select",
1149
- {
1150
- name: field.id || field.name,
1151
- required: field.required,
1152
- defaultValue: field.value ? String(field.value) : "",
1153
- style: {
1154
- border: "1px solid #d1d5db",
1155
- borderRadius: "8px",
1156
- padding: "10px 12px",
1157
- fontSize: "13px",
1158
- color: "#1a1a1a",
1159
- backgroundColor: "#ffffff",
1160
- fontFamily: "inherit",
1161
- outline: "none",
1162
- transition: "border-color 0.15s ease, box-shadow 0.15s ease",
1163
- cursor: "pointer"
1164
- },
1165
- onFocus: (e) => {
1166
- e.currentTarget.style.borderColor = "#3b82f6";
1167
- e.currentTarget.style.boxShadow = "0 0 0 3px rgba(59, 130, 246, 0.1)";
1168
- },
1169
- onBlur: (e) => {
1170
- e.currentTarget.style.borderColor = "#d1d5db";
1171
- e.currentTarget.style.boxShadow = "none";
1172
- },
1173
- children: [
1174
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Se\xE7iniz" }),
1175
- field.options?.map((opt, optIdx) => {
1176
- const optKey = typeof opt.value === "string" ? opt.value : `opt-${fieldIdx}-${optIdx}`;
1177
- return /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt.value, children: opt.label }, optKey);
1178
- })
1179
- ]
1180
- }
1181
- ) : /* @__PURE__ */ jsxRuntime.jsx(
1182
- "input",
1183
- {
1184
- type: field.type === "number" ? "number" : "text",
1185
- name: field.id || field.name,
1186
- required: field.required,
1187
- defaultValue: field.value ? String(field.value) : "",
1188
- placeholder: field.placeholder || "",
1189
- min: field.min,
1190
- max: field.max,
1191
- style: {
1192
- border: "1px solid #d1d5db",
1193
- borderRadius: "8px",
1194
- padding: "10px 12px",
1195
- fontSize: "13px",
1196
- color: "#1a1a1a",
1197
- backgroundColor: "#ffffff",
1198
- fontFamily: "inherit",
1199
- outline: "none",
1200
- transition: "border-color 0.15s ease, box-shadow 0.15s ease"
1201
- },
1202
- onFocus: (e) => {
1203
- e.currentTarget.style.borderColor = "#3b82f6";
1204
- e.currentTarget.style.boxShadow = "0 0 0 3px rgba(59, 130, 246, 0.1)";
1205
- },
1206
- onBlur: (e) => {
1207
- e.currentTarget.style.borderColor = "#d1d5db";
1208
- e.currentTarget.style.boxShadow = "none";
1209
- }
1210
- }
1211
- )
1212
- ]
1213
- },
1214
- fieldKey
1215
- );
1216
- })
1217
- }
1218
- ),
1219
- /* @__PURE__ */ jsxRuntime.jsx(
1220
- "button",
1221
- {
1222
- type: "submit",
1223
- style: {
1224
- marginTop: "24px",
1225
- display: "inline-flex",
1226
- alignItems: "center",
1227
- justifyContent: "center",
1228
- borderRadius: "8px",
1229
- padding: "12px 24px",
1230
- fontSize: "13px",
1231
- fontWeight: 500,
1232
- backgroundColor: "#3b82f6",
1233
- color: "#ffffff",
1234
- border: "none",
1235
- cursor: "pointer",
1236
- transition: "background-color 0.15s ease, transform 0.1s ease",
1237
- fontFamily: "inherit"
1238
- },
1239
- onMouseEnter: (e) => {
1240
- e.currentTarget.style.backgroundColor = "#2563eb";
1241
- },
1242
- onMouseLeave: (e) => {
1243
- e.currentTarget.style.backgroundColor = "#3b82f6";
1244
- },
1245
- onMouseDown: (e) => {
1246
- e.currentTarget.style.transform = "scale(0.98)";
1247
- },
1248
- onMouseUp: (e) => {
1249
- e.currentTarget.style.transform = "scale(1)";
1250
- },
1251
- children: data.submitLabel ?? "G\xF6nder"
1252
- }
1253
- )
1254
- ]
1255
- }
1256
- );
569
+ // src/utils/cx.ts
570
+ function validateHeaders(headers, authConfig, opts = {}) {
571
+ const { caseSensitive = false, allowExtra = false } = opts;
572
+ const normalize = (s) => caseSensitive ? s : s.toLowerCase();
573
+ const headerEntries = Object.entries(headers).map(([k, v]) => [normalize(k), v.trim()]);
574
+ const authEntries = Object.entries(authConfig).map(([k, v]) => [normalize(k), v.trim()]);
575
+ const headerKeys = headerEntries.map(([k]) => k);
576
+ const authKeys = authEntries.map(([k]) => k);
577
+ const requiredSet = new Set(authKeys);
578
+ const missingKeys = authKeys.filter((k) => !headerKeys.includes(k));
579
+ const extraKeys = headerKeys.filter((k) => !requiredSet.has(k));
580
+ const hasAllRequired = missingKeys.length === 0;
581
+ const hasExtraKeys = extraKeys.length > 0 && !allowExtra;
582
+ const emptyValueKeys = authKeys.filter((k) => {
583
+ const val = headerEntries.find(([key]) => key === k)?.[1];
584
+ return !val || val.length === 0;
585
+ });
586
+ const isValid = hasAllRequired && !hasExtraKeys && emptyValueKeys.length === 0;
587
+ return { isValid, missingKeys, extraKeys, emptyValueKeys };
1257
588
  }
1258
589
  function ButtonsComponent({
1259
590
  data,
@@ -1262,319 +593,30 @@ function ButtonsComponent({
1262
593
  if (!Array.isArray(data) || data.length === 0) {
1263
594
  return null;
1264
595
  }
1265
- const getButtonStyles = (variant) => {
1266
- const baseStyles = {
1267
- borderRadius: "8px",
1268
- padding: "10px 20px",
1269
- fontSize: "13px",
1270
- fontWeight: 500,
1271
- border: "1px solid #e0e0e0",
1272
- backgroundColor: "#ffffff",
1273
- color: "#374151",
1274
- cursor: "pointer",
1275
- transition: "all 0.15s ease",
1276
- fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
1277
- outline: "none"
1278
- };
1279
- if (variant === "primary") {
1280
- return {
1281
- ...baseStyles,
1282
- backgroundColor: "#3b82f6",
1283
- color: "#ffffff",
1284
- borderColor: "#3b82f6"
1285
- };
1286
- } else if (variant === "secondary") {
1287
- return {
1288
- ...baseStyles,
1289
- backgroundColor: "#f3f4f6",
1290
- color: "#374151",
1291
- borderColor: "#d1d5db"
1292
- };
1293
- } else if (variant === "danger") {
1294
- return {
1295
- ...baseStyles,
1296
- backgroundColor: "#ef4444",
1297
- color: "#ffffff",
1298
- borderColor: "#ef4444"
1299
- };
1300
- }
1301
- return baseStyles;
1302
- };
1303
- const getHoverStyles = (variant) => {
1304
- if (variant === "primary") {
1305
- return { backgroundColor: "#2563eb", borderColor: "#2563eb" };
1306
- } else if (variant === "secondary") {
1307
- return { backgroundColor: "#e5e7eb", borderColor: "#9ca3af" };
1308
- } else if (variant === "danger") {
1309
- return { backgroundColor: "#dc2626", borderColor: "#dc2626" };
1310
- }
1311
- return { backgroundColor: "#f9fafb", borderColor: "#d1d5db" };
1312
- };
1313
- return /* @__PURE__ */ jsxRuntime.jsx(
1314
- "div",
1315
- {
1316
- style: {
1317
- display: "flex",
1318
- gap: "12px",
1319
- flexWrap: "wrap"
1320
- },
1321
- children: data.map((btn, idx) => {
1322
- if (!btn || typeof btn !== "object") {
1323
- return null;
1324
- }
1325
- const btnValue = typeof btn.value === "string" ? btn.value : typeof btn.value === "number" ? String(btn.value) : btn.value && typeof btn.value === "object" ? JSON.stringify(btn.value) : `btn-value-${idx}`;
1326
- const btnKey = typeof btn.value === "string" && btn.value.trim() ? btn.value : `btn-${idx}`;
1327
- const btnLabel = btn.label || `Button ${idx + 1}`;
1328
- const buttonStyles = getButtonStyles(btn.variant);
1329
- const hoverStyles = getHoverStyles(btn.variant);
1330
- return /* @__PURE__ */ jsxRuntime.jsx(
1331
- "button",
1332
- {
1333
- onClick: () => {
1334
- try {
1335
- onClick(btnValue);
1336
- } catch (error) {
1337
- console.error("Error in button onClick:", error);
1338
- }
1339
- },
1340
- style: buttonStyles,
1341
- onMouseEnter: (e) => {
1342
- Object.assign(e.currentTarget.style, hoverStyles);
1343
- },
1344
- onMouseLeave: (e) => {
1345
- Object.assign(e.currentTarget.style, buttonStyles);
1346
- },
1347
- onMouseDown: (e) => {
1348
- e.currentTarget.style.transform = "scale(0.97)";
1349
- },
1350
- onMouseUp: (e) => {
1351
- e.currentTarget.style.transform = "scale(1)";
1352
- },
1353
- children: btnLabel
1354
- },
1355
- btnKey
1356
- );
1357
- })
596
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "buttons-component", children: data.map((btn, idx) => {
597
+ if (!btn || typeof btn !== "object") {
598
+ return null;
1358
599
  }
1359
- );
1360
- }
1361
- function TableComponent({ data }) {
1362
- if (!data.columns || !Array.isArray(data.columns) || data.columns.length === 0) {
1363
- return null;
1364
- }
1365
- return /* @__PURE__ */ jsxRuntime.jsxs(
1366
- "div",
1367
- {
1368
- style: {
1369
- border: "1px solid #e0e0e0",
1370
- borderRadius: "12px",
1371
- overflow: "hidden",
1372
- fontSize: "13px",
1373
- backgroundColor: "#ffffff",
1374
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.08)",
1375
- fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'
1376
- },
1377
- children: [
1378
- data.caption && /* @__PURE__ */ jsxRuntime.jsx(
1379
- "div",
1380
- {
1381
- style: {
1382
- padding: "16px 20px",
1383
- fontWeight: 600,
1384
- fontSize: "14px",
1385
- borderBottom: "1px solid #e0e0e0",
1386
- backgroundColor: "#f8f9fa",
1387
- color: "#1a1a1a"
1388
- },
1389
- children: data.caption
1390
- }
1391
- ),
1392
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { overflowX: "auto" }, children: /* @__PURE__ */ jsxRuntime.jsxs(
1393
- "table",
1394
- {
1395
- style: {
1396
- width: "100%",
1397
- borderCollapse: "collapse",
1398
- minWidth: "100%"
1399
- },
1400
- children: [
1401
- /* @__PURE__ */ jsxRuntime.jsx("thead", { style: { backgroundColor: "#f8f9fa" }, children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: data.columns.map((col, i) => {
1402
- const colKey = typeof col === "string" ? `col-${i}` : col.key || col.id || `col-${i}`;
1403
- const colLabel = typeof col === "string" ? col : col.label || "";
1404
- return /* @__PURE__ */ jsxRuntime.jsx(
1405
- "th",
1406
- {
1407
- style: {
1408
- borderBottom: "2px solid #e0e0e0",
1409
- padding: "14px 20px",
1410
- textAlign: "left",
1411
- fontWeight: 600,
1412
- fontSize: "12px",
1413
- color: "#4a5568",
1414
- textTransform: "uppercase",
1415
- letterSpacing: "0.5px",
1416
- whiteSpace: "nowrap"
1417
- },
1418
- children: colLabel
1419
- },
1420
- colKey
1421
- );
1422
- }) }) }),
1423
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: data.rows && data.rows.length > 0 ? data.rows.map((row, rowIdx) => /* @__PURE__ */ jsxRuntime.jsx(
1424
- "tr",
1425
- {
1426
- style: {
1427
- backgroundColor: rowIdx % 2 === 0 ? "#ffffff" : "#fafbfc",
1428
- transition: "background-color 0.15s ease"
1429
- },
1430
- onMouseEnter: (e) => {
1431
- e.currentTarget.style.backgroundColor = "#f0f4f8";
1432
- },
1433
- onMouseLeave: (e) => {
1434
- e.currentTarget.style.backgroundColor = rowIdx % 2 === 0 ? "#ffffff" : "#fafbfc";
1435
- },
1436
- children: data.columns.map((col, colIdx) => {
1437
- const colKey = typeof col === "string" ? `col-${colIdx}` : col.key || col.id || `col-${colIdx}`;
1438
- const colType = typeof col === "object" ? col.type : void 0;
1439
- const cellKey = `cell-${rowIdx}-${colIdx}`;
1440
- let cellContent = null;
1441
- if (typeof row === "object" && row !== null && !Array.isArray(row)) {
1442
- const cellValue = row[colKey];
1443
- if (cellValue !== void 0 && cellValue !== null) {
1444
- if (typeof cellValue === "object" && "type" in cellValue) {
1445
- cellContent = renderField(cellValue);
1446
- } else {
1447
- const stringValue = String(cellValue);
1448
- const isImageUrl = typeof stringValue === "string" && (stringValue.startsWith("http") || stringValue.startsWith("data:") || stringValue.startsWith("/")) && (stringValue.match(
1449
- /\.(jpg|jpeg|png|gif|webp|svg)$/i
1450
- ) || stringValue.includes("image") || stringValue.includes("avatar"));
1451
- if (colType === "image" || !colType && isImageUrl) {
1452
- cellContent = /* @__PURE__ */ jsxRuntime.jsx(
1453
- "div",
1454
- {
1455
- style: {
1456
- display: "flex",
1457
- alignItems: "center"
1458
- },
1459
- children: /* @__PURE__ */ jsxRuntime.jsx(
1460
- "img",
1461
- {
1462
- src: stringValue,
1463
- alt: "",
1464
- style: {
1465
- width: "40px",
1466
- height: "40px",
1467
- borderRadius: "8px",
1468
- objectFit: "cover",
1469
- border: "1px solid #e0e0e0"
1470
- },
1471
- onError: (e) => {
1472
- e.target.style.display = "none";
1473
- }
1474
- }
1475
- )
1476
- }
1477
- );
1478
- } else {
1479
- cellContent = /* @__PURE__ */ jsxRuntime.jsx(
1480
- "span",
1481
- {
1482
- style: {
1483
- color: "#2d3748",
1484
- lineHeight: "1.5"
1485
- },
1486
- children: stringValue
1487
- }
1488
- );
1489
- }
1490
- }
1491
- }
1492
- } else if (Array.isArray(row)) {
1493
- const cellValue = row[colIdx];
1494
- if (cellValue !== void 0 && cellValue !== null) {
1495
- const stringValue = String(cellValue);
1496
- const isImageUrl = typeof stringValue === "string" && (stringValue.startsWith("http") || stringValue.startsWith("data:") || stringValue.startsWith("/")) && (stringValue.match(
1497
- /\.(jpg|jpeg|png|gif|webp|svg)$/i
1498
- ) || stringValue.includes("image") || stringValue.includes("avatar"));
1499
- if (colType === "image" || !colType && isImageUrl) {
1500
- cellContent = /* @__PURE__ */ jsxRuntime.jsx(
1501
- "div",
1502
- {
1503
- style: { display: "flex", alignItems: "center" },
1504
- children: /* @__PURE__ */ jsxRuntime.jsx(
1505
- "img",
1506
- {
1507
- src: stringValue,
1508
- alt: "",
1509
- style: {
1510
- width: "40px",
1511
- height: "40px",
1512
- borderRadius: "8px",
1513
- objectFit: "cover",
1514
- border: "1px solid #e0e0e0"
1515
- },
1516
- onError: (e) => {
1517
- e.target.style.display = "none";
1518
- }
1519
- }
1520
- )
1521
- }
1522
- );
1523
- } else {
1524
- cellContent = /* @__PURE__ */ jsxRuntime.jsx(
1525
- "span",
1526
- {
1527
- style: {
1528
- color: "#2d3748",
1529
- lineHeight: "1.5"
1530
- },
1531
- children: stringValue
1532
- }
1533
- );
1534
- }
1535
- }
1536
- }
1537
- return /* @__PURE__ */ jsxRuntime.jsx(
1538
- "td",
1539
- {
1540
- style: {
1541
- borderBottom: "1px solid #e8e8e8",
1542
- padding: "16px 20px",
1543
- fontSize: "13px",
1544
- verticalAlign: "middle"
1545
- },
1546
- children: cellContent || /* @__PURE__ */ jsxRuntime.jsx(
1547
- "span",
1548
- {
1549
- style: { color: "#a0a0a0", fontStyle: "italic" },
1550
- children: "\u2014"
1551
- }
1552
- )
1553
- },
1554
- cellKey
1555
- );
1556
- })
1557
- },
1558
- `row-${rowIdx}`
1559
- )) : /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx(
1560
- "td",
1561
- {
1562
- colSpan: data.columns.length,
1563
- style: {
1564
- padding: "40px",
1565
- textAlign: "center",
1566
- color: "#9ca3af",
1567
- fontSize: "13px"
1568
- },
1569
- children: "Veri bulunamad\u0131"
1570
- }
1571
- ) }) })
1572
- ]
600
+ const btnValue = typeof btn.value === "string" ? btn.value : typeof btn.value === "number" ? String(btn.value) : btn.value && typeof btn.value === "object" ? JSON.stringify(btn.value) : `btn-value-${idx}`;
601
+ const btnKey = typeof btn.value === "string" && btn.value.trim() ? btn.value : `btn-${idx}`;
602
+ const btnLabel = btn.label || `Button ${idx + 1}`;
603
+ const variantClass = btn.variant || "";
604
+ return /* @__PURE__ */ jsxRuntime.jsx(
605
+ "button",
606
+ {
607
+ onClick: () => {
608
+ try {
609
+ onClick(btnValue);
610
+ } catch (error) {
611
+ console.error("Error in button onClick:", error);
1573
612
  }
1574
- ) })
1575
- ]
1576
- }
1577
- );
613
+ },
614
+ className: `button-component ${variantClass}`,
615
+ children: btnLabel
616
+ },
617
+ btnKey
618
+ );
619
+ }) });
1578
620
  }
1579
621
  function CardComponent({ data }) {
1580
622
  if (data.title) {
@@ -1584,290 +626,165 @@ function CardComponent({ data }) {
1584
626
  const hasStatus = data.status && typeof data.status === "string";
1585
627
  const hasSubtitle = data.subtitle && typeof data.subtitle === "string";
1586
628
  const displayFields = hasAttributes ? data.attributes : hasFields ? data.fields : [];
1587
- return /* @__PURE__ */ jsxRuntime.jsx(
1588
- "div",
1589
- {
1590
- style: {
1591
- border: "1px solid #e5e7eb",
1592
- borderRadius: "16px",
1593
- padding: "16px",
1594
- backgroundColor: "#ffffff",
1595
- boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1)",
1596
- overflow: "hidden",
1597
- marginBottom: "12px"
1598
- },
1599
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "12px" }, children: [
1600
- hasImage && /* @__PURE__ */ jsxRuntime.jsx(
1601
- "img",
1602
- {
1603
- src: data.image,
1604
- alt: data.title || "Card image",
1605
- style: {
1606
- width: "64px",
1607
- height: "64px",
1608
- borderRadius: "8px",
1609
- objectFit: "cover",
1610
- flexShrink: 0
1611
- },
1612
- onError: (e) => {
1613
- e.target.style.display = "none";
1614
- }
629
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "card-component", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "card-content", children: [
630
+ hasImage && /* @__PURE__ */ jsxRuntime.jsx(
631
+ "img",
632
+ {
633
+ src: data.image,
634
+ alt: data.title || "Card image",
635
+ className: "card-image",
636
+ onError: (e) => {
637
+ e.target.style.display = "none";
638
+ }
639
+ }
640
+ ),
641
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "card-info", children: [
642
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "card-title", children: data.title }),
643
+ hasStatus && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "card-status", children: [
644
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "card-status-label", children: "Durum:" }),
645
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "card-status-value", children: data.status })
646
+ ] }),
647
+ hasSubtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "card-subtitle", children: data.subtitle }),
648
+ displayFields && displayFields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "card-fields", children: displayFields.map((field, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "card-field", children: [
649
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "card-field-label", children: [
650
+ field.label,
651
+ ":"
652
+ ] }),
653
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "card-field-value", children: field.value })
654
+ ] }, i)) }),
655
+ data.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "card-description", children: data.description })
656
+ ] })
657
+ ] }) });
658
+ }
659
+ if (!data.items || !Array.isArray(data.items) || data.items.length === 0) {
660
+ return null;
661
+ }
662
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "card-list", children: [
663
+ data.title && !data.items.some((item) => item.title) && /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "card-list-title", children: data.title }),
664
+ data.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "card-list-description", children: data.description }),
665
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "card-grid", children: data.items.map((item, i) => {
666
+ const itemKey = item.id || `card-item-${i}`;
667
+ const hasImage = item.image && typeof item.image === "string";
668
+ const hasTitle = item.title && typeof item.title === "string";
669
+ const hasSubtitle = item.subtitle && typeof item.subtitle === "string";
670
+ const isLegacyFormat = item.label && item.value;
671
+ if (isLegacyFormat && !hasTitle) {
672
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "card-item", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "card-item-legacy", children: [
673
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { className: "card-item-legacy-label", children: item.label }),
674
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { className: "card-item-legacy-value", children: item.value })
675
+ ] }) }, itemKey);
676
+ }
677
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "card-item", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "card-item-content", children: [
678
+ hasImage && /* @__PURE__ */ jsxRuntime.jsx(
679
+ "img",
680
+ {
681
+ src: item.image,
682
+ alt: item.title || `Card ${i + 1}`,
683
+ className: "card-item-image",
684
+ onError: (e) => {
685
+ e.target.style.display = "none";
1615
686
  }
1616
- ),
1617
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [
1618
- /* @__PURE__ */ jsxRuntime.jsx(
1619
- "h4",
1620
- {
1621
- style: {
1622
- fontWeight: 600,
1623
- fontSize: "14px",
1624
- marginBottom: "8px",
1625
- overflow: "hidden",
1626
- textOverflow: "ellipsis",
1627
- whiteSpace: "nowrap"
1628
- },
1629
- children: data.title
1630
- }
1631
- ),
1632
- hasStatus && /* @__PURE__ */ jsxRuntime.jsxs(
1633
- "div",
687
+ }
688
+ ),
689
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "card-item-info", children: [
690
+ hasTitle && /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "card-item-title", children: item.title }),
691
+ hasSubtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "card-item-subtitle", children: item.subtitle })
692
+ ] })
693
+ ] }) }, itemKey);
694
+ }) })
695
+ ] });
696
+ }
697
+ function FormComponent({
698
+ data,
699
+ onSubmit
700
+ }) {
701
+ const handleSubmit = (e) => {
702
+ e.preventDefault();
703
+ const formData = new FormData(e.currentTarget);
704
+ const values = {};
705
+ data.fields.forEach((f) => {
706
+ const fieldName = f.id || f.name || `field-${data.fields.indexOf(f)}`;
707
+ values[fieldName] = String(formData.get(fieldName) ?? "");
708
+ if (f.type === "file") {
709
+ const file = formData.get(fieldName);
710
+ values[fieldName] = JSON.stringify({
711
+ name: file?.name,
712
+ size: file?.size,
713
+ type: file?.type
714
+ });
715
+ }
716
+ });
717
+ console.log(values);
718
+ onSubmit(values);
719
+ };
720
+ return /* @__PURE__ */ jsxRuntime.jsxs(
721
+ "form",
722
+ {
723
+ onSubmit: handleSubmit,
724
+ className: "form-component",
725
+ children: [
726
+ data.title && /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "form-title", children: data.title }),
727
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-fields", children: data.fields.map((field, fieldIdx) => {
728
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "form-field", children: [
729
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "form-label", children: [
730
+ field.label,
731
+ field.required && /* @__PURE__ */ jsxRuntime.jsx("span", { children: "*" })
732
+ ] }),
733
+ field.type === "select" ? /* @__PURE__ */ jsxRuntime.jsxs(
734
+ "select",
1634
735
  {
1635
- style: {
1636
- display: "flex",
1637
- gap: "8px",
1638
- fontSize: "12px",
1639
- marginBottom: "4px"
1640
- },
736
+ name: field.id || field.name,
737
+ required: field.required,
738
+ defaultValue: field.value ? String(field.value) : "",
739
+ className: "form-select",
1641
740
  children: [
1642
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#6b7280", fontWeight: 500 }, children: "Durum:" }),
1643
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#374151" }, children: data.status })
741
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Se\xE7iniz" }),
742
+ field.options?.map((opt, optIdx) => {
743
+ const optKey = typeof opt.value === "string" ? opt.value : `opt-${fieldIdx}-${optIdx}`;
744
+ return /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt.value, children: opt.label }, optKey);
745
+ })
1644
746
  ]
1645
747
  }
1646
- ),
1647
- hasSubtitle && /* @__PURE__ */ jsxRuntime.jsx(
1648
- "p",
1649
- {
1650
- style: {
1651
- color: "#6b7280",
1652
- fontSize: "12px",
1653
- marginBottom: "4px",
1654
- margin: 0
1655
- },
1656
- children: data.subtitle
1657
- }
1658
- ),
1659
- displayFields && displayFields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1660
- "div",
748
+ ) : field.type === "file" ? /* @__PURE__ */ jsxRuntime.jsx(
749
+ "input",
1661
750
  {
1662
- style: { display: "flex", flexDirection: "column", gap: "4px" },
1663
- children: displayFields.map((field, i) => /* @__PURE__ */ jsxRuntime.jsxs(
1664
- "div",
1665
- {
1666
- style: { display: "flex", gap: "8px", fontSize: "12px" },
1667
- children: [
1668
- /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { color: "#6b7280", fontWeight: 500 }, children: [
1669
- field.label,
1670
- ":"
1671
- ] }),
1672
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#374151" }, children: field.value })
1673
- ]
1674
- },
1675
- i
1676
- ))
751
+ type: "file",
752
+ name: field.id || field.name,
753
+ required: field.required,
754
+ className: "form-input",
755
+ accept: field.accept || "*"
1677
756
  }
1678
- ),
1679
- data.description && /* @__PURE__ */ jsxRuntime.jsx(
1680
- "p",
757
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
758
+ "input",
1681
759
  {
1682
- style: {
1683
- color: "#6b7280",
1684
- fontSize: "12px",
1685
- marginTop: "8px",
1686
- margin: 0
1687
- },
1688
- children: data.description
760
+ type: field.type === "number" ? "number" : "text",
761
+ name: field.id || field.name,
762
+ required: field.required,
763
+ defaultValue: field.value ? String(field.value) : "",
764
+ placeholder: field.placeholder || "",
765
+ min: field.min,
766
+ max: field.max,
767
+ className: "form-input"
1689
768
  }
1690
769
  )
1691
- ] })
1692
- ] })
1693
- }
1694
- );
1695
- }
1696
- if (!data.items || !Array.isArray(data.items) || data.items.length === 0) {
1697
- return null;
1698
- }
1699
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: "100%" }, children: [
1700
- data.title && !data.items.some((item) => item.title) && /* @__PURE__ */ jsxRuntime.jsx(
1701
- "h3",
1702
- {
1703
- style: {
1704
- fontWeight: 600,
1705
- marginBottom: "12px",
1706
- fontSize: "14px",
1707
- color: "#1a1a1a",
1708
- marginTop: 0
1709
- },
1710
- children: data.title
1711
- }
1712
- ),
1713
- data.description && /* @__PURE__ */ jsxRuntime.jsx(
1714
- "p",
1715
- {
1716
- style: {
1717
- color: "#6b7280",
1718
- marginBottom: "12px",
1719
- fontSize: "12px",
1720
- marginTop: 0
1721
- },
1722
- children: data.description
1723
- }
1724
- ),
1725
- /* @__PURE__ */ jsxRuntime.jsx(
1726
- "div",
1727
- {
1728
- style: {
1729
- display: "grid",
1730
- gridTemplateColumns: "repeat(auto-fit, minmax(250px, 1fr))",
1731
- gap: "12px"
1732
- },
1733
- children: data.items.map((item, i) => {
1734
- const itemKey = item.id || `card-item-${i}`;
1735
- const hasImage = item.image && typeof item.image === "string";
1736
- const hasTitle = item.title && typeof item.title === "string";
1737
- const hasSubtitle = item.subtitle && typeof item.subtitle === "string";
1738
- const isLegacyFormat = item.label && item.value;
1739
- if (isLegacyFormat && !hasTitle) {
1740
- return /* @__PURE__ */ jsxRuntime.jsx(
1741
- "div",
1742
- {
1743
- style: {
1744
- border: "1px solid #e0e0e0",
1745
- borderRadius: "12px",
1746
- padding: "16px",
1747
- backgroundColor: "#ffffff",
1748
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.08)",
1749
- fontSize: "12px"
1750
- },
1751
- children: /* @__PURE__ */ jsxRuntime.jsxs(
1752
- "div",
1753
- {
1754
- style: {
1755
- display: "flex",
1756
- justifyContent: "space-between",
1757
- gap: "8px"
1758
- },
1759
- children: [
1760
- /* @__PURE__ */ jsxRuntime.jsx("dt", { style: { color: "#6b7280", margin: 0 }, children: item.label }),
1761
- /* @__PURE__ */ jsxRuntime.jsx(
1762
- "dd",
1763
- {
1764
- style: {
1765
- fontWeight: 500,
1766
- color: "#1a1a1a",
1767
- margin: 0
1768
- },
1769
- children: item.value
1770
- }
1771
- )
1772
- ]
1773
- }
1774
- )
1775
- },
1776
- itemKey
1777
- );
1778
- }
1779
- return /* @__PURE__ */ jsxRuntime.jsx(
1780
- "div",
1781
- {
1782
- style: {
1783
- border: "1px solid #e0e0e0",
1784
- borderRadius: "12px",
1785
- padding: "16px",
1786
- backgroundColor: "#ffffff",
1787
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.08)",
1788
- overflow: "hidden"
1789
- },
1790
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "12px" }, children: [
1791
- hasImage && /* @__PURE__ */ jsxRuntime.jsx(
1792
- "img",
1793
- {
1794
- src: item.image,
1795
- alt: item.title || `Card ${i + 1}`,
1796
- style: {
1797
- width: "64px",
1798
- height: "64px",
1799
- borderRadius: "8px",
1800
- objectFit: "cover",
1801
- flexShrink: 0
1802
- },
1803
- onError: (e) => {
1804
- e.target.style.display = "none";
1805
- }
1806
- }
1807
- ),
1808
- /* @__PURE__ */ jsxRuntime.jsxs(
1809
- "div",
1810
- {
1811
- style: {
1812
- flex: 1,
1813
- minWidth: 0
1814
- },
1815
- children: [
1816
- hasTitle && /* @__PURE__ */ jsxRuntime.jsx(
1817
- "h4",
1818
- {
1819
- style: {
1820
- fontWeight: 600,
1821
- fontSize: "14px",
1822
- marginBottom: "4px",
1823
- overflow: "hidden",
1824
- textOverflow: "ellipsis",
1825
- whiteSpace: "nowrap",
1826
- color: "#1a1a1a",
1827
- marginTop: 0
1828
- },
1829
- children: item.title
1830
- }
1831
- ),
1832
- hasSubtitle && /* @__PURE__ */ jsxRuntime.jsx(
1833
- "p",
1834
- {
1835
- style: {
1836
- color: "#6b7280",
1837
- fontSize: "12px",
1838
- margin: 0
1839
- },
1840
- children: item.subtitle
1841
- }
1842
- )
1843
- ]
1844
- }
1845
- )
1846
- ] })
1847
- },
1848
- itemKey
1849
- );
1850
- })
1851
- }
1852
- )
1853
- ] });
770
+ ] }, fieldIdx);
771
+ }) }),
772
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", className: "form-submit-button", children: data.submitLabel ?? "G\xF6nder" })
773
+ ]
774
+ }
775
+ );
1854
776
  }
1855
777
  function renderField(field) {
1856
778
  switch (field.type) {
1857
779
  case "text":
1858
- return /* @__PURE__ */ jsxRuntime.jsx("span", { children: field.value });
780
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "field-text", children: field.value });
1859
781
  case "image":
1860
782
  return /* @__PURE__ */ jsxRuntime.jsx(
1861
783
  "img",
1862
784
  {
1863
785
  src: field.src,
1864
786
  alt: field.alt ?? "",
1865
- style: {
1866
- width: 24,
1867
- height: 24,
1868
- borderRadius: "999px",
1869
- objectFit: "cover"
1870
- }
787
+ className: "field-image"
1871
788
  }
1872
789
  );
1873
790
  case "link":
@@ -1877,38 +794,143 @@ function renderField(field) {
1877
794
  href: field.href,
1878
795
  target: "_blank",
1879
796
  rel: "noreferrer",
1880
- style: { textDecoration: "underline" },
797
+ className: "field-link",
1881
798
  children: field.label
1882
799
  }
1883
800
  );
1884
801
  case "badge":
1885
- return /* @__PURE__ */ jsxRuntime.jsx(
1886
- "span",
1887
- {
1888
- style: {
1889
- display: "inline-block",
1890
- padding: "2px 6px",
1891
- borderRadius: 999,
1892
- fontSize: 10,
1893
- fontWeight: 500,
1894
- backgroundColor: field.tone === "success" ? "#e0fce5" : field.tone === "warning" ? "#fff7d6" : field.tone === "danger" ? "#ffe4e4" : "#f2f2f2",
1895
- color: field.tone === "success" ? "#1a7f36" : field.tone === "warning" ? "#8a6a00" : field.tone === "danger" ? "#b42318" : "#333"
1896
- },
1897
- children: field.label
1898
- }
1899
- );
802
+ const toneClass = field.tone || "neutral";
803
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: `field-badge ${toneClass}`, children: field.label });
1900
804
  case "list":
1901
- return /* @__PURE__ */ jsxRuntime.jsx("ul", { style: { margin: 0, paddingLeft: 16 }, children: field.items.map((item, i) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: renderField(item) }, i)) });
805
+ return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "field-list", children: field.items.map((item, i) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: renderField(item) }, i)) });
1902
806
  default:
1903
807
  return null;
1904
808
  }
1905
809
  }
810
+ function TableComponent({ data }) {
811
+ if (!data.columns || !Array.isArray(data.columns) || data.columns.length === 0) {
812
+ return null;
813
+ }
814
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "table-component", children: [
815
+ data.caption && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "table-caption", children: data.caption }),
816
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "table-wrapper", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "table", children: [
817
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "table-header", children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: data.columns.map((col, i) => {
818
+ const colKey = typeof col === "string" ? `col-${i}` : col.key || col.id || `col-${i}`;
819
+ const colLabel = typeof col === "string" ? col : col.label || "";
820
+ return /* @__PURE__ */ jsxRuntime.jsx("th", { className: "table-th", children: colLabel }, colKey);
821
+ }) }) }),
822
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "table-tbody", children: data.rows && data.rows.length > 0 ? data.rows.map((row, rowIdx) => /* @__PURE__ */ jsxRuntime.jsx("tr", { children: data.columns.map((col, colIdx) => {
823
+ const colKey = typeof col === "string" ? `col-${colIdx}` : col.key || col.id || `col-${colIdx}`;
824
+ const colType = typeof col === "object" ? col.type : void 0;
825
+ const cellKey = `cell-${rowIdx}-${colIdx}`;
826
+ let cellContent = null;
827
+ if (typeof row === "object" && row !== null && !Array.isArray(row)) {
828
+ const cellValue = row[colKey];
829
+ if (cellValue !== void 0 && cellValue !== null) {
830
+ if (typeof cellValue === "object" && "type" in cellValue) {
831
+ cellContent = renderField(cellValue);
832
+ } else {
833
+ const stringValue = String(cellValue);
834
+ const isImageUrl = typeof stringValue === "string" && (stringValue.startsWith("http") || stringValue.startsWith("data:") || stringValue.startsWith("/")) && (stringValue.match(
835
+ /\.(jpg|jpeg|png|gif|webp|svg)$/i
836
+ ) || stringValue.includes("image") || stringValue.includes("avatar"));
837
+ if (colType === "image" || !colType && isImageUrl) {
838
+ cellContent = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "table-cell-image", children: /* @__PURE__ */ jsxRuntime.jsx(
839
+ "img",
840
+ {
841
+ src: stringValue,
842
+ alt: "",
843
+ className: "table-image",
844
+ onError: (e) => {
845
+ e.target.style.display = "none";
846
+ }
847
+ }
848
+ ) });
849
+ } else {
850
+ cellContent = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "table-cell-text", children: stringValue });
851
+ }
852
+ }
853
+ }
854
+ } else if (Array.isArray(row)) {
855
+ const cellValue = row[colIdx];
856
+ if (cellValue !== void 0 && cellValue !== null) {
857
+ const stringValue = String(cellValue);
858
+ const isImageUrl = typeof stringValue === "string" && (stringValue.startsWith("http") || stringValue.startsWith("data:") || stringValue.startsWith("/")) && (stringValue.match(
859
+ /\.(jpg|jpeg|png|gif|webp|svg)$/i
860
+ ) || stringValue.includes("image") || stringValue.includes("avatar"));
861
+ if (colType === "image" || !colType && isImageUrl) {
862
+ cellContent = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "table-cell-image", children: /* @__PURE__ */ jsxRuntime.jsx(
863
+ "img",
864
+ {
865
+ src: stringValue,
866
+ alt: "",
867
+ className: "table-image",
868
+ onError: (e) => {
869
+ e.target.style.display = "none";
870
+ }
871
+ }
872
+ ) });
873
+ } else {
874
+ cellContent = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "table-cell-text", children: stringValue });
875
+ }
876
+ }
877
+ }
878
+ return /* @__PURE__ */ jsxRuntime.jsx("td", { className: "table-td", children: cellContent || /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u2014" }) }, cellKey);
879
+ }) }, `row-${rowIdx}`)) : /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: data.columns.length, className: "table-empty", children: "Veri bulunamad\u0131" }) }) })
880
+ ] }) })
881
+ ] });
882
+ }
883
+ function GenerativeUI({ components, onInteraction }) {
884
+ console.log(components);
885
+ if (!Array.isArray(components) || components.length === 0) {
886
+ return null;
887
+ }
888
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ui-renderer", children: components.map((comp, idx) => {
889
+ if (!comp || typeof comp !== "object" || !comp.type) {
890
+ return null;
891
+ }
892
+ const key = typeof comp.id === "string" && comp.id.trim() ? comp.id : `${comp.type}-${idx}`;
893
+ switch (comp.type) {
894
+ case "form":
895
+ return /* @__PURE__ */ jsxRuntime.jsx(
896
+ FormComponent,
897
+ {
898
+ data: comp.data,
899
+ onSubmit: (values) => onInteraction?.({
900
+ type: "formSubmit",
901
+ componentId: comp.data.id,
902
+ values
903
+ })
904
+ },
905
+ key
906
+ );
907
+ case "buttons":
908
+ if (!comp.data || !Array.isArray(comp.data)) {
909
+ return null;
910
+ }
911
+ return /* @__PURE__ */ jsxRuntime.jsx(
912
+ ButtonsComponent,
913
+ {
914
+ data: comp.data,
915
+ onClick: (value) => onInteraction?.({ type: "buttonClick", value })
916
+ },
917
+ key
918
+ );
919
+ case "table":
920
+ return /* @__PURE__ */ jsxRuntime.jsx(TableComponent, { data: comp.data }, key);
921
+ case "card":
922
+ return /* @__PURE__ */ jsxRuntime.jsx(CardComponent, { data: comp.data }, key);
923
+ default:
924
+ return null;
925
+ }
926
+ }) });
927
+ }
1906
928
  var AizekChatBot = ({
1907
929
  clientId,
1908
930
  headers
1909
931
  }) => {
1910
932
  const defaultConfig = {
1911
- welcomeMessage: "Merhaba! Size nas\u0131l yard\u0131mc\u0131 olabilirim?",
933
+ welcomeMessage: "Merhaba! Size nas\u0131l yard\u0131mc\u0131 olabilirimmmmm?",
1912
934
  buttonBackground: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
1913
935
  placeholder: "Mesaj\u0131n\u0131z\u0131 yaz\u0131n...",
1914
936
  buttonPosition: "bottom-left",
@@ -1921,10 +943,10 @@ var AizekChatBot = ({
1921
943
  companyLogo: void 0,
1922
944
  companyName: "AI Asistan"
1923
945
  };
1924
- const [config, setConfig] = React.useState(defaultConfig);
1925
- const [isConfigLoading, setIsConfigLoading] = React.useState(true);
1926
- const [finalMcpUrl, setFinalMcpUrl] = React.useState("");
1927
- const [apiKey, setApiKey] = React.useState("");
946
+ const [config, setConfig] = react.useState(defaultConfig);
947
+ const [isConfigLoading, setIsConfigLoading] = react.useState(true);
948
+ const [finalMcpUrl, setFinalMcpUrl] = react.useState("");
949
+ const [apiKey, setApiKey] = react.useState("");
1928
950
  const {
1929
951
  welcomeMessage,
1930
952
  buttonBackground,
@@ -1939,10 +961,10 @@ var AizekChatBot = ({
1939
961
  companyLogo,
1940
962
  companyName
1941
963
  } = config;
1942
- const [isOpen, setIsOpen] = React.useState(false);
1943
- const [headerValidation, setHeaderValidation] = React.useState(null);
1944
- const [showAlert, setShowAlert] = React.useState(true);
1945
- React.useEffect(() => {
964
+ const [isOpen, setIsOpen] = react.useState(false);
965
+ const [headerValidation, setHeaderValidation] = react.useState(null);
966
+ const [showAlert, setShowAlert] = react.useState(true);
967
+ react.useEffect(() => {
1946
968
  const loadConfig = async () => {
1947
969
  try {
1948
970
  setIsConfigLoading(true);
@@ -1988,59 +1010,42 @@ var AizekChatBot = ({
1988
1010
  const newIsOpen = !isOpen;
1989
1011
  setIsOpen(newIsOpen);
1990
1012
  };
1991
- React.useEffect(() => {
1013
+ react.useEffect(() => {
1992
1014
  setIsOpen(initialOpen);
1993
1015
  }, [initialOpen]);
1994
- const messagesEndRef = React.useRef(null);
1995
- React.useEffect(() => {
1016
+ const messagesEndRef = react.useRef(null);
1017
+ react.useEffect(() => {
1996
1018
  messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
1997
1019
  }, [messages]);
1998
1020
  const MessageBubble = ({ message, onAction }) => {
1999
1021
  const isUser = message.role === "user";
2000
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: getMessageContainerStyles(isUser), children: [
2001
- /* @__PURE__ */ jsxRuntime.jsx("style", { children: getMarkdownElementStyles(isUser) }),
1022
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `message-container ${isUser ? "user" : "assistant"}`, children: [
2002
1023
  isUser && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2003
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: getMessageBubbleStyles(isUser), children: message.text && /* @__PURE__ */ jsxRuntime.jsx("div", { style: getMarkdownStyles(), children: message.text }) }),
2004
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: getTimeStyles(isUser), children: message.timestamp.toLocaleTimeString("tr-TR", {
1024
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `message-bubble ${isUser ? "user" : "assistant"}`, children: message.text && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "markdown-content", children: message.text }) }),
1025
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `message-time ${isUser ? "user" : "assistant"}`, children: message.timestamp.toLocaleTimeString("tr-TR", {
2005
1026
  hour: "2-digit",
2006
1027
  minute: "2-digit"
2007
1028
  }) })
2008
1029
  ] }),
2009
1030
  !isUser && message.role !== "approval" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2010
- /* @__PURE__ */ jsxRuntime.jsx(
2011
- "div",
2012
- {
2013
- style: getMessageBubbleStyles(isUser, message.isTyping ?? false),
2014
- children: message.isTyping ? /* @__PURE__ */ jsxRuntime.jsx(
2015
- "div",
2016
- {
2017
- style: {
2018
- display: "inline-flex",
2019
- alignItems: "center",
2020
- marginLeft: message.text ? "8px" : "0"
2021
- },
2022
- children: /* @__PURE__ */ jsxRuntime.jsx(TypingDots, {})
2023
- }
2024
- ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2025
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: getMarkdownStyles(), className: "markdown-content", children: /* @__PURE__ */ jsxRuntime.jsx(ReactMarkdown__default.default, { remarkPlugins: [remarkGfm__default.default], children: message.text }) }),
2026
- message.ui && /* @__PURE__ */ jsxRuntime.jsx(
2027
- UIRenderer,
2028
- {
2029
- components: message.ui,
2030
- onInteraction: (event) => {
2031
- console.log(event);
2032
- if (event.type === "buttonClick" && typeof event.value === "string") {
2033
- onAction(event.value, true);
2034
- } else if (event.type === "formSubmit") {
2035
- onAction(JSON.stringify(event.values), true);
2036
- }
2037
- }
1031
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `message-bubble ${isUser ? "user" : "assistant"}`, children: message.isTyping ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "message-typing-indicator", children: /* @__PURE__ */ jsxRuntime.jsx(TypingDots, {}) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1032
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "markdown-content", children: /* @__PURE__ */ jsxRuntime.jsx(ReactMarkdown__default.default, { remarkPlugins: [remarkGfm__default.default], children: message.text }) }),
1033
+ message.ui && /* @__PURE__ */ jsxRuntime.jsx(
1034
+ GenerativeUI,
1035
+ {
1036
+ components: message.ui,
1037
+ onInteraction: (event) => {
1038
+ console.log(event);
1039
+ if (event.type === "buttonClick" && typeof event.value === "string") {
1040
+ onAction(event.value, true);
1041
+ } else if (event.type === "formSubmit") {
1042
+ onAction(JSON.stringify(event.values), true);
2038
1043
  }
2039
- )
2040
- ] })
2041
- }
2042
- ),
2043
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: getTimeStyles(isUser), children: message.timestamp.toLocaleTimeString("tr-TR", {
1044
+ }
1045
+ }
1046
+ )
1047
+ ] }) }),
1048
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `message-time ${isUser ? "user" : "assistant"}`, children: message.timestamp.toLocaleTimeString("tr-TR", {
2044
1049
  hour: "2-digit",
2045
1050
  minute: "2-digit"
2046
1051
  }) })
@@ -2048,8 +1053,8 @@ var AizekChatBot = ({
2048
1053
  ] });
2049
1054
  };
2050
1055
  const TypingDots = () => {
2051
- const [dots, setDots] = React.useState("");
2052
- React.useEffect(() => {
1056
+ const [dots, setDots] = react.useState("");
1057
+ react.useEffect(() => {
2053
1058
  const interval = setInterval(() => {
2054
1059
  setDots((prev) => {
2055
1060
  if (prev === "...") return "";
@@ -2075,136 +1080,48 @@ var AizekChatBot = ({
2075
1080
  }
2076
1081
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" }) });
2077
1082
  };
2078
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2079
- /* @__PURE__ */ jsxRuntime.jsx("style", { children: getAlertAnimationStyles() }),
2080
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: getAlertContainerStyles(alertType), children: [
2081
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: getAlertIconContainerStyles(), children: getAlertIcon() }),
2082
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: getAlertContentStyles(), children: [
2083
- /* @__PURE__ */ jsxRuntime.jsx("h4", { style: getAlertTitleStyles(), children: hasErrors ? "Header Do\u011Frulama Hatas\u0131" : "Header Uyar\u0131s\u0131" }),
2084
- /* @__PURE__ */ jsxRuntime.jsx("p", { style: getAlertMessageStyles(), children: hasErrors && hasWarnings ? "Header yap\u0131land\u0131rman\u0131zda hatalar ve uyar\u0131lar bulundu." : hasErrors ? "Header yap\u0131land\u0131rman\u0131zda hatalar bulundu." : "Header yap\u0131land\u0131rman\u0131zda fazla anahtarlar bulundu." }),
2085
- missingKeys.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2086
- /* @__PURE__ */ jsxRuntime.jsx("strong", { style: { fontSize: "13px" }, children: "Eksik Header'lar:" }),
2087
- /* @__PURE__ */ jsxRuntime.jsx("ul", { style: getAlertListStyles(), children: missingKeys.map((key, index) => /* @__PURE__ */ jsxRuntime.jsxs("li", { style: getAlertListItemStyles(), children: [
2088
- /* @__PURE__ */ jsxRuntime.jsx(
2089
- "span",
2090
- {
2091
- style: {
2092
- position: "absolute",
2093
- left: "0",
2094
- top: "2px",
2095
- fontWeight: "bold"
2096
- },
2097
- children: "\u2022"
2098
- }
2099
- ),
2100
- /* @__PURE__ */ jsxRuntime.jsx(
2101
- "code",
2102
- {
2103
- style: {
2104
- background: "rgba(255, 255, 255, 0.2)",
2105
- padding: "2px 6px",
2106
- borderRadius: "4px",
2107
- fontFamily: "monospace",
2108
- fontSize: "12px"
2109
- },
2110
- children: key
2111
- }
2112
- )
2113
- ] }, index)) })
2114
- ] }),
2115
- emptyValueKeys.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2116
- /* @__PURE__ */ jsxRuntime.jsx("strong", { style: { fontSize: "13px" }, children: "Bo\u015F De\u011Ferli Header'lar:" }),
2117
- /* @__PURE__ */ jsxRuntime.jsx("ul", { style: getAlertListStyles(), children: emptyValueKeys.map((key, index) => /* @__PURE__ */ jsxRuntime.jsxs("li", { style: getAlertListItemStyles(), children: [
2118
- /* @__PURE__ */ jsxRuntime.jsx(
2119
- "span",
2120
- {
2121
- style: {
2122
- position: "absolute",
2123
- left: "0",
2124
- top: "2px",
2125
- fontWeight: "bold"
2126
- },
2127
- children: "\u2022"
2128
- }
2129
- ),
2130
- /* @__PURE__ */ jsxRuntime.jsx(
2131
- "code",
2132
- {
2133
- style: {
2134
- background: "rgba(255, 255, 255, 0.2)",
2135
- padding: "2px 6px",
2136
- borderRadius: "4px",
2137
- fontFamily: "monospace",
2138
- fontSize: "12px"
2139
- },
2140
- children: key
2141
- }
2142
- ),
2143
- /* @__PURE__ */ jsxRuntime.jsx(
2144
- "span",
2145
- {
2146
- style: {
2147
- marginLeft: "6px",
2148
- fontSize: "11px",
2149
- opacity: 0.9
2150
- },
2151
- children: "(de\u011Fer bo\u015F olamaz)"
2152
- }
2153
- )
2154
- ] }, index)) })
2155
- ] }),
2156
- extraKeys.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2157
- /* @__PURE__ */ jsxRuntime.jsx("strong", { style: { fontSize: "13px" }, children: "Fazla Header'lar:" }),
2158
- /* @__PURE__ */ jsxRuntime.jsx("ul", { style: getAlertListStyles(), children: extraKeys.map((key, index) => /* @__PURE__ */ jsxRuntime.jsxs("li", { style: getAlertListItemStyles(), children: [
2159
- /* @__PURE__ */ jsxRuntime.jsx(
2160
- "span",
2161
- {
2162
- style: {
2163
- position: "absolute",
2164
- left: "0",
2165
- top: "2px",
2166
- fontWeight: "bold"
2167
- },
2168
- children: "\u2022"
2169
- }
2170
- ),
2171
- /* @__PURE__ */ jsxRuntime.jsx(
2172
- "code",
2173
- {
2174
- style: {
2175
- background: "rgba(255, 255, 255, 0.2)",
2176
- padding: "2px 6px",
2177
- borderRadius: "4px",
2178
- fontFamily: "monospace",
2179
- fontSize: "12px"
2180
- },
2181
- children: key
2182
- }
2183
- )
2184
- ] }, index)) })
2185
- ] })
1083
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `alert-container ${alertType}`, children: [
1084
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "alert-icon-container", children: getAlertIcon() }),
1085
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "alert-content", children: [
1086
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "alert-title", children: hasErrors ? "Header Do\u011Frulama Hatas\u0131" : "Header Uyar\u0131s\u0131" }),
1087
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "alert-message", children: hasErrors && hasWarnings ? "Header yap\u0131land\u0131rman\u0131zda hatalar ve uyar\u0131lar bulundu." : hasErrors ? "Header yap\u0131land\u0131rman\u0131zda hatalar bulundu." : "Header yap\u0131land\u0131rman\u0131zda fazla anahtarlar bulundu." }),
1088
+ missingKeys.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1089
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Eksik Header'lar:" }),
1090
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "alert-list", children: missingKeys.map((key, index) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "alert-list-item", children: [
1091
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u2022" }),
1092
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: key })
1093
+ ] }, index)) })
2186
1094
  ] }),
2187
- /* @__PURE__ */ jsxRuntime.jsx(
2188
- "button",
2189
- {
2190
- onClick: () => setShowAlert(false),
2191
- style: getAlertCloseButtonStyles(),
2192
- onMouseEnter: (e) => {
2193
- e.currentTarget.style.background = "rgba(255, 255, 255, 0.3)";
2194
- },
2195
- onMouseLeave: (e) => {
2196
- e.currentTarget.style.background = "rgba(255, 255, 255, 0.2)";
2197
- },
2198
- "aria-label": "Uyar\u0131y\u0131 kapat",
2199
- children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) })
2200
- }
2201
- )
2202
- ] })
2203
- ] });
1095
+ emptyValueKeys.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1096
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Bo\u015F De\u011Ferli Header'lar:" }),
1097
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "alert-list", children: emptyValueKeys.map((key, index) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "alert-list-item", children: [
1098
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u2022" }),
1099
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: key }),
1100
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "(de\u011Fer bo\u015F olamaz)" })
1101
+ ] }, index)) })
1102
+ ] }),
1103
+ extraKeys.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1104
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Fazla Header'lar:" }),
1105
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "alert-list", children: extraKeys.map((key, index) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "alert-list-item", children: [
1106
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u2022" }),
1107
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: key })
1108
+ ] }, index)) })
1109
+ ] })
1110
+ ] }),
1111
+ /* @__PURE__ */ jsxRuntime.jsx(
1112
+ "button",
1113
+ {
1114
+ onClick: () => setShowAlert(false),
1115
+ className: "alert-close-button",
1116
+ "aria-label": "Uyar\u0131y\u0131 kapat",
1117
+ children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) })
1118
+ }
1119
+ )
1120
+ ] }) });
2204
1121
  };
2205
1122
  const ChatInput = () => {
2206
- const [message, setMessage] = React.useState("");
2207
- const textareaRef = React.useRef(null);
1123
+ const [message, setMessage] = react.useState("");
1124
+ const textareaRef = react.useRef(null);
2208
1125
  const handleSubmit = (e) => {
2209
1126
  e.preventDefault();
2210
1127
  if (message.trim() && !isLoading) {
@@ -2227,7 +1144,7 @@ var AizekChatBot = ({
2227
1144
  textarea.style.height = "auto";
2228
1145
  textarea.style.height = Math.min(textarea.scrollHeight, 120) + "px";
2229
1146
  };
2230
- return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: getInputContainerStyles(), children: [
1147
+ return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "input-container", children: [
2231
1148
  /* @__PURE__ */ jsxRuntime.jsx(
2232
1149
  "textarea",
2233
1150
  {
@@ -2237,7 +1154,7 @@ var AizekChatBot = ({
2237
1154
  onKeyDown: handleKeyDown,
2238
1155
  placeholder,
2239
1156
  disabled: isLoading,
2240
- style: getTextareaStyles(isLoading)
1157
+ className: "textarea"
2241
1158
  }
2242
1159
  ),
2243
1160
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2245,124 +1162,80 @@ var AizekChatBot = ({
2245
1162
  {
2246
1163
  type: "submit",
2247
1164
  disabled: isLoading || !message.trim(),
2248
- style: getSendButtonStyles(isLoading, !!message.trim()),
2249
- onMouseEnter: (e) => {
2250
- if (!isLoading && message.trim()) {
2251
- e.currentTarget.style.transform = "scale(1.05)";
2252
- }
2253
- },
2254
- onMouseLeave: (e) => {
2255
- e.currentTarget.style.transform = "scale(1)";
2256
- },
1165
+ className: "send-button",
2257
1166
  children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner, {}) : /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" }) })
2258
1167
  }
2259
1168
  )
2260
1169
  ] });
2261
1170
  };
2262
1171
  const LoadingSpinner = () => {
2263
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: getLoadingSpinnerStyles() });
1172
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "loading-spinner" });
2264
1173
  };
2265
1174
  if (isConfigLoading) {
2266
1175
  return /* @__PURE__ */ jsxRuntime.jsx(
2267
- "div",
1176
+ "button",
2268
1177
  {
2269
- style: getFloatingButtonStyles(
2270
- buttonPosition,
2271
- buttonSize,
2272
- buttonBackground,
2273
- false
2274
- ),
2275
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: getLoadingSpinnerStyles() })
1178
+ className: `floating-button ${buttonPosition} button-sizes ${buttonSize}`,
1179
+ style: { background: buttonBackground },
1180
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "loading-spinner" })
2276
1181
  }
2277
1182
  );
2278
1183
  }
2279
1184
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2280
- isOpen && /* @__PURE__ */ jsxRuntime.jsx(
2281
- "div",
2282
- {
2283
- style: getOverlayStyles(isOpen),
2284
- onClick: toggleChat,
2285
- className: "floating-chat-overlay"
2286
- }
2287
- ),
2288
- /* @__PURE__ */ jsxRuntime.jsx(
2289
- "div",
2290
- {
2291
- style: getChatContainerStyles(
2292
- buttonPosition,
2293
- chatWidth,
2294
- chatHeight,
2295
- isOpen
2296
- ),
2297
- className: "floating-chat-container",
2298
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: getChatbotContainerStyles(), children: [
2299
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: getHeaderStyles(headerBackground), children: [
2300
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: getLogoContainerStyles(), children: companyLogo ? companyLogo.startsWith("http") || companyLogo.startsWith("data:") ? /* @__PURE__ */ jsxRuntime.jsx(
2301
- "img",
2302
- {
2303
- src: companyLogo,
2304
- alt: "Company Logo",
2305
- style: getLogoImageStyles()
2306
- }
2307
- ) : /* @__PURE__ */ jsxRuntime.jsx("span", { style: getLogoTextStyles(), children: companyLogo }) : "\u{1F916}" }),
2308
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2309
- /* @__PURE__ */ jsxRuntime.jsx("h3", { style: getCompanyNameStyles(), children: companyName }),
2310
- /* @__PURE__ */ jsxRuntime.jsx("p", { style: getStatusTextStyles(), children: isLoading ? "Yaz\u0131yor..." : "\xC7evrimi\xE7i" })
2311
- ] })
2312
- ] }),
2313
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: getMessagesContainerStyles(), children: [
2314
- /* @__PURE__ */ jsxRuntime.jsx(HeaderValidationAlert, {}),
2315
- messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: getEmptyStateStyles(), children: [
2316
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "48px", marginBottom: "16px" }, children: "\u{1F4AC}" }),
2317
- /* @__PURE__ */ jsxRuntime.jsx("h4", { style: { margin: "0 0 8px 0", fontSize: "18px" }, children: welcomeMessage }),
2318
- /* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0, fontSize: "14px", opacity: 0.8 }, children: "A\u015Fa\u011F\u0131daki alana mesaj\u0131n\u0131z\u0131 yazarak ba\u015Flayabilirsiniz." })
2319
- ] }) : messages.map((message) => /* @__PURE__ */ jsxRuntime.jsx(
2320
- MessageBubble,
2321
- {
2322
- message,
2323
- onAction: handleSendMessage
2324
- },
2325
- message.id
2326
- )),
2327
- showTypingIndicator && isLoading && messages.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
2328
- MessageBubble,
2329
- {
2330
- message: {
2331
- id: `typing-${messages.length}`,
2332
- text: "",
2333
- role: "assistant",
2334
- timestamp: /* @__PURE__ */ new Date(),
2335
- isTyping: true
2336
- },
2337
- onAction: handleSendMessage
2338
- },
2339
- `typing-${messages.length}`
2340
- ),
2341
- /* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
2342
- ] }),
2343
- /* @__PURE__ */ jsxRuntime.jsx(ChatInput, {})
1185
+ isOpen && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `overlay floating-chat-overlay ${isOpen ? "is-open" : ""}`, onClick: toggleChat }),
1186
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `chat-container ${buttonPosition} ${isOpen ? "is-open" : ""}`, style: { width: chatWidth, height: chatHeight }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "chatbot-container", children: [
1187
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "header", style: { background: headerBackground }, children: [
1188
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "logo-container", children: companyLogo ? companyLogo.startsWith("http") || companyLogo.startsWith("data:") ? /* @__PURE__ */ jsxRuntime.jsx(
1189
+ "img",
1190
+ {
1191
+ src: companyLogo,
1192
+ alt: "Company Logo",
1193
+ className: "logo-image"
1194
+ }
1195
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "logo-text", children: companyLogo }) : "\u{1F916}" }),
1196
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1197
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "company-name", children: companyName }),
1198
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "status-text", children: isLoading ? "Yaz\u0131yor..." : "\xC7evrimi\xE7i" })
2344
1199
  ] })
2345
- }
2346
- ),
1200
+ ] }),
1201
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "messages-container", children: [
1202
+ /* @__PURE__ */ jsxRuntime.jsx(HeaderValidationAlert, {}),
1203
+ messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "empty-state", children: [
1204
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "empty-state-icon", children: "\u{1F4AC}" }),
1205
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "empty-state-title", children: welcomeMessage }),
1206
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "empty-state-description", children: "A\u015Fa\u011F\u0131daki alana mesaj\u0131n\u0131z\u0131 yazarak ba\u015Flayabilirsiniz." })
1207
+ ] }) : messages.map((message) => /* @__PURE__ */ jsxRuntime.jsx(
1208
+ MessageBubble,
1209
+ {
1210
+ message,
1211
+ onAction: handleSendMessage
1212
+ },
1213
+ message.id
1214
+ )),
1215
+ showTypingIndicator && isLoading && messages.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1216
+ MessageBubble,
1217
+ {
1218
+ message: {
1219
+ id: `typing-${messages.length}`,
1220
+ text: "",
1221
+ role: "assistant",
1222
+ timestamp: /* @__PURE__ */ new Date(),
1223
+ isTyping: true
1224
+ },
1225
+ onAction: handleSendMessage
1226
+ },
1227
+ `typing-${messages.length}`
1228
+ ),
1229
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
1230
+ ] }),
1231
+ /* @__PURE__ */ jsxRuntime.jsx(ChatInput, {})
1232
+ ] }) }),
2347
1233
  /* @__PURE__ */ jsxRuntime.jsx(
2348
1234
  "button",
2349
1235
  {
2350
1236
  onClick: toggleChat,
2351
- style: getFloatingButtonStyles(
2352
- buttonPosition,
2353
- buttonSize,
2354
- buttonBackground,
2355
- isOpen
2356
- ),
2357
- onMouseEnter: (e) => {
2358
- e.currentTarget.style.transform = isOpen ? "scale(0.85)" : "scale(1.1)";
2359
- e.currentTarget.style.boxShadow = "0 6px 20px rgba(0, 0, 0, 0.25)";
2360
- },
2361
- onMouseLeave: (e) => {
2362
- e.currentTarget.style.transform = isOpen ? "scale(0.9)" : "scale(1)";
2363
- e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.15)";
2364
- },
2365
- className: "floating-chat-button",
1237
+ className: `floating-button ${buttonPosition} button-sizes ${buttonSize} ${isOpen ? "is-open" : ""}`,
1238
+ style: { background: buttonBackground },
2366
1239
  "aria-label": isOpen ? "Chati kapat" : "Chati a\xE7",
2367
1240
  children: isOpen ? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) }) : /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h4l4 4 4-4h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z" }) })
2368
1241
  }
@@ -2371,7 +1244,5 @@ var AizekChatBot = ({
2371
1244
  };
2372
1245
 
2373
1246
  exports.AizekChatBot = AizekChatBot;
2374
- exports.Button = Button;
2375
- exports.useChatbot = useChatbot;
2376
1247
  //# sourceMappingURL=index.cjs.map
2377
1248
  //# sourceMappingURL=index.cjs.map