@grafana/assistant 0.0.16 → 0.0.18

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/README.md CHANGED
@@ -37,7 +37,7 @@ function MyComponent() {
37
37
 
38
38
  return (
39
39
  <button onClick={() => openAssistant({
40
- origin: 'button',
40
+ origin: 'grafana/panel-data-analyzer',
41
41
  prompt: 'Help me analyze data' })}>
42
42
  Open Assistant
43
43
  </button>
@@ -51,14 +51,14 @@ function MyComponent() {
51
51
  import { openAssistant, closeAssistant } from '@grafana/assistant';
52
52
 
53
53
  // Open the assistant with an initial prompt
54
- openAssistant({ origin: 'some-feature', prompt: 'Show me CPU usage over the last hour' });
54
+ openAssistant({ origin: 'grafana/some-feature', prompt: 'Show me CPU usage over the last hour' });
55
55
 
56
56
  // Open the assistant with initial prompt and autoSend set to false
57
- openAssistant({ origin: 'some-feature', prompt: 'Help me analyze data', autoSend: false })
57
+ openAssistant({ origin: 'grafana-datasources/prometheus/some-feature', prompt: 'Help me analyze data', autoSend: false })
58
58
 
59
59
  // Open the assistant without an initial prompt
60
60
  openAssistant({
61
- origin: 'some-page',
61
+ origin: 'grafana-slo-app/some-page',
62
62
  });
63
63
 
64
64
  // Close the assistant
@@ -84,7 +84,7 @@ const dashboardContext = createAssistantContextItem('dashboard', {
84
84
 
85
85
  // Open the assistant with initial prompt and context
86
86
  openAssistant({
87
- origin: 'dashboard-page',
87
+ origin: 'grafana/dashboard-page',
88
88
  prompt: 'Analyze the CPU metrics from this dashboard',
89
89
  context: [datasourceContext, dashboardContext]
90
90
  });
@@ -262,6 +262,20 @@ const genericContext = createAssistantContextItem('unknown', {
262
262
  text: 'Some additional context information'
263
263
  });
264
264
 
265
+ // Create component context for custom React components
266
+ const componentContext = createAssistantContextItem('component', {
267
+ components: {
268
+ MyCustomComponent: MyCustomComponentImplementation,
269
+ AnotherComponent: AnotherComponentImplementation,
270
+ },
271
+ prompt: `
272
+ - When mentioning specific entities, use the your_app_MyCustomComponent with the syntax: <your_app_MyCustomComponent prop1={'value1'} prop2={'value2'} />
273
+ - Custom components must never be wrapped in code blocks (backticks \` or \`\`\`).
274
+ - Always provide all required props when using custom components.
275
+ `,
276
+ namespace: 'your_app', // Optional: Namespace for your components (defaults to 'components')
277
+ });
278
+
265
279
  // Create hidden context (useful for system instructions)
266
280
  const hiddenInstructions = createAssistantContextItem('structured', {
267
281
  hidden: true, // Won't be shown in UI pills but will be sent to the assistant
@@ -273,6 +287,101 @@ const hiddenInstructions = createAssistantContextItem('structured', {
273
287
  });
274
288
  ```
275
289
 
290
+ ### Registering Custom Components for Assistant Usage
291
+
292
+ The `component` context type allows you to register custom React components that the assistant can use in its responses. This is particularly useful for rendering domain-specific UI elements that enhance the user experience.
293
+
294
+ > **⚠️ Important:** Components must be approved by #grafana-assistant before usage. Please reach out to the Grafana Assistant team for review and approval of your custom components before implementing them in production.
295
+
296
+ #### Method 1: Using provideComponents (Recommended)
297
+
298
+ ```typescript
299
+ import { provideComponents } from '@grafana/assistant';
300
+ import MyEntityMention from 'components/MyEntityMentionComponent';
301
+ import MyCustomChart from 'components/MyCustomChartComponent';
302
+
303
+ /**
304
+ * Configure the assistant context for your app plugin.
305
+ * This sets up custom components that will be available to the Grafana Assistant
306
+ * when users are on any page matching the provided pattern.
307
+ */
308
+ export function configureAssistantContext() {
309
+ provideComponents(
310
+ `
311
+ - When mentioning an entity in text, always use the your_app_MyEntityMention component: <your_app_MyEntityMention name={'entity name here'} type={'entity type here'} />
312
+ - For displaying charts, use the your_app_MyCustomChart component: <your_app_MyCustomChart data={chartData} title={'Chart Title'} />
313
+ - Custom components must never be wrapped in code blocks (backticks \` or \`\`\`).
314
+ `,
315
+ 'your_app', // namespace
316
+ {
317
+ MyEntityMention,
318
+ MyCustomChart,
319
+ },
320
+ /.*/ // matches all pages
321
+ );
322
+ }
323
+ ```
324
+
325
+ #### Method 2: Using createAssistantContextItem with providePageContext
326
+
327
+ ```typescript
328
+ import { createAssistantContextItem, providePageContext } from '@grafana/assistant';
329
+ import MyEntityMention from 'components/MyEntityMentionComponent';
330
+ import MyCustomChart from 'components/MyCustomChartComponent';
331
+
332
+ export function configureAssistantContext() {
333
+ providePageContext(/.*/, [
334
+ createAssistantContextItem('component', {
335
+ components: {
336
+ MyEntityMention,
337
+ MyCustomChart,
338
+ },
339
+ prompt: `
340
+ - When mentioning an entity in text, always use the your_app_MyEntityMention component: <your_app_MyEntityMention name={'entity name here'} type={'entity type here'} />
341
+ - For displaying charts, use the your_app_MyCustomChart component: <your_app_MyCustomChart data={chartData} title={'Chart Title'} />
342
+ - Custom components must never be wrapped in code blocks (backticks \` or \`\`\`).
343
+ `,
344
+ namespace: 'your_app', // Optional: defaults to 'components' if not provided
345
+ }),
346
+ ]);
347
+ }
348
+ ```
349
+
350
+ **Key Points for Component Context:**
351
+
352
+ - **Approval Required**: ⚠️ Components must be approved by #grafana-assistant before usage
353
+ - **Components**: A record of component names to their React component implementations
354
+ - **Prompt**: Instructions for the assistant on how and when to use these components
355
+ - **Namespace**: A unique identifier for your app's components (e.g., 'your_app', 'datasource'). Optional - defaults to 'components' if not provided
356
+ - **Component Usage**: Components are referenced in assistant responses as `<namespace_ComponentName prop={'value'} />` (note the underscore format)
357
+ - **No Code Blocks**: Custom components should never be wrapped in markdown code blocks
358
+
359
+ **Example Component Implementation:**
360
+ ```typescript
361
+ interface MyEntityMentionProps {
362
+ name: string;
363
+ type: string;
364
+ env?: string;
365
+ site?: string;
366
+ namespace?: string;
367
+ properties?: string;
368
+ }
369
+
370
+ const MyEntityMention: React.FC<MyEntityMentionProps> = ({ name, type, env, site, namespace, properties }) => {
371
+ return (
372
+ <span
373
+ className="entity-mention"
374
+ data-entity-type={type}
375
+ title={`${type}: ${name}`}
376
+ >
377
+ {name}
378
+ </span>
379
+ );
380
+ };
381
+
382
+ export default MyEntityMention;
383
+ ```
384
+
276
385
  ### Using Hidden Context for System Instructions
277
386
 
278
387
  The `hidden` parameter allows you to provide context to the assistant without showing it in the UI pills. This is particularly useful for:
@@ -368,7 +477,7 @@ function MyDashboard() {
368
477
  <OpenAssistantButton
369
478
  prompt="Help me analyze the CPU usage trends in this dashboard"
370
479
  context={[dashboardContext]}
371
- origin="dashboard-menu"
480
+ origin="grafana/dashboard-menu"
372
481
  />
373
482
 
374
483
  {/* Icon-only button */}
@@ -377,7 +486,7 @@ function MyDashboard() {
377
486
  iconOnlyButton={true}
378
487
  name="Get AI suggestions"
379
488
  size="md"
380
- origin="loki-query-editor"
489
+ origin="grafana-datasources/loki/query-editor"
381
490
  />
382
491
 
383
492
  {/* Button without auto-send */}
@@ -386,7 +495,7 @@ function MyDashboard() {
386
495
  autoSend={false}
387
496
  name="Ask Assistant"
388
497
  size="lg"
389
- origin="panel-viewer"
498
+ origin="grafana/panel-viewer"
390
499
  />
391
500
  </div>
392
501
  );
@@ -422,6 +531,30 @@ A React hook for providing page context that automatically cleans up on unmount.
422
531
 
423
532
  **Returns:** A setter function to update the context
424
533
 
534
+ #### `usePageComponents(): Record<string, ComponentImplementation>`
535
+
536
+ A React hook that provides all components available for the current page. This hook automatically updates when the URL changes or when component registrations change.
537
+
538
+ **Returns:** Object containing all components available for the current page, keyed by `namespace_componentName` format.
539
+
540
+ **Example:**
541
+ ```typescript
542
+ import { usePageComponents } from '@grafana/assistant';
543
+
544
+ function MyAssistantComponent() {
545
+ const components = usePageComponents();
546
+
547
+ // Access components registered with namespace 'myapp' and component name 'EntityMention'
548
+ const EntityMentionComponent = components['myapp_EntityMention'];
549
+
550
+ return (
551
+ <div>
552
+ Available components: {Object.keys(components).join(', ')}
553
+ </div>
554
+ );
555
+ }
556
+ ```
557
+
425
558
  ### React Components
426
559
 
427
560
  #### `<OpenAssistantButton />`
@@ -430,7 +563,7 @@ A pre-built React component that renders a button to open the Grafana Assistant
430
563
 
431
564
  **Parameters:**
432
565
  - `prompt: string` - **Required** The initial prompt to display in the assistant
433
- - `origin: string` - **Required** Origin of the request that opened the assistant
566
+ - `origin: string` - **Required** Origin of the request that opened the assistant. Should be structured using forward slashes with the first part as a namespace. Examples: 'grafana-datasources/prometheus/query-builder', 'grafana-slo-app/slo-editor-overview'
434
567
  - `context?: ChatContextItem[]` - Optional context items created with `createAssistantContextItem`
435
568
  - `autoSend?: boolean` - Whether to automatically send the initial prompt (defaults to `true`)
436
569
  - `title?: string` - Text to display on the button (defaults to `'Analyze with Assistant'`)
@@ -455,7 +588,7 @@ Opens the Grafana Assistant sidebar.
455
588
 
456
589
  **Parameters:**
457
590
  - `props: OpenAssistantProps` - Configuration object
458
- - `origin: string` - The origin of the request that opened the assistant. This is used to track the source of the request. Should be a static string that helps identify the source of the request.
591
+ - `origin: string` - Origin of the request that opened the assistant. Should be structured using forward slashes with the first part as a namespace. Examples: 'grafana-datasources/prometheus/query-builder', 'grafana-slo-app/slo-editor-overview'
459
592
  - `prompt?: string` - Optional initial prompt to display in the assistant
460
593
  - `context?: ChatContextItem[]` - Optional context items to provide additional information to the assistant
461
594
  - `autoSend?: boolean` - Optional flag to automatically send the initial prompt
@@ -478,6 +611,7 @@ Creates a context item that can be passed to the assistant to provide additional
478
611
  - `'label_name'` - Label name context
479
612
  - `'label_value'` - Label value context
480
613
  - `'structured'` - Custom structured data context
614
+ - `'component'` - Custom React components context
481
615
  - `'unknown'` - Generic text context
482
616
  - `params` - Parameters specific to the context type (see Context Types section). All context types support:
483
617
  - `hidden?: boolean` - If true, the context item will not be shown in the UI pills but will still be sent to the assistant. This is useful for providing system instructions, behavioral guidelines, or other metadata that shouldn't clutter the user interface.
@@ -512,6 +646,50 @@ setDashboardContext([...newContext]);
512
646
  setDashboardContext.unregister();
513
647
  ```
514
648
 
649
+ #### `provideComponents(prompt: string, namespace: string, components: Record<string, ComponentImplementation>, urlPattern?: string | RegExp): ((context: ChatContextItem[]) => void) & { unregister: () => void }`
650
+
651
+ A simplified function for providing components to the assistant. This is a convenience wrapper around `providePageContext` specifically for registering components.
652
+
653
+ **Parameters:**
654
+ - `prompt` - Instructions for the assistant on how and when to use these components
655
+ - `namespace` - A unique identifier for your app's components (e.g., 'myapp', 'datasource')
656
+ - `components` - A record of component names to their React component implementations
657
+ - `urlPattern` - Optional URL pattern to match against page URLs (defaults to `/.*/` - matches all pages)
658
+
659
+ **Returns:** A setter function to update the context, with an `unregister` method attached for cleanup
660
+
661
+ **Example:**
662
+ ```typescript
663
+ import { provideComponents } from '@grafana/assistant';
664
+ import MyEntityMention from './components/MyEntityMention';
665
+ import MyCustomChart from './components/MyCustomChart';
666
+
667
+ // Register components for all pages
668
+ const setComponents = provideComponents(
669
+ `
670
+ - When mentioning entities, use the myapp_MyEntityMention component: <myapp_MyEntityMention name={'entity-name'} type={'entity-type'} />
671
+ - For charts, use the myapp_MyCustomChart component: <myapp_MyCustomChart data={chartData} title={'Chart Title'} />
672
+ - Custom components must never be wrapped in code blocks.
673
+ `,
674
+ 'myapp',
675
+ {
676
+ MyEntityMention,
677
+ MyCustomChart,
678
+ }
679
+ );
680
+
681
+ // Register components only for dashboard pages
682
+ const setDashboardComponents = provideComponents(
683
+ 'Use components to enhance dashboard analysis.',
684
+ 'dashboard',
685
+ { MyEntityMention },
686
+ '/d/*'
687
+ );
688
+
689
+ // Cleanup when done
690
+ setComponents.unregister();
691
+ ```
692
+
515
693
  ### Questions System
516
694
 
517
695
  The questions system allows external parties to provide sample prompts with optional context for specific pages. It reuses the existing page context infrastructure but presents a simpler interface focused on questions.
@@ -757,6 +935,19 @@ interface StructuredNodeDataParams {
757
935
  }
758
936
  ```
759
937
 
938
+ #### Component Context Parameters
939
+
940
+ ```typescript
941
+ interface CreateComponentContextParams {
942
+ components: Record<string, React.ComponentType<any>>;
943
+ prompt: string;
944
+ namespace?: string; // Optional: defaults to 'components' if not provided
945
+ title?: string;
946
+ icon?: IconName;
947
+ hidden?: boolean; // If true, the context item will not be shown in the context pills
948
+ }
949
+ ```
950
+
760
951
  #### Generic Context Parameters
761
952
 
762
953
  ```typescript
@@ -847,8 +1038,12 @@ export type LabelValueNodeData;
847
1038
  export type StructuredNodeData;
848
1039
  export type TreeNode;
849
1040
  export type ItemDataType;
1041
+
1042
+ // Component types
1043
+ export type ComponentImplementation;
1044
+ export type NamedComponents;
850
1045
  ```
851
1046
 
852
1047
  ## License
853
1048
 
854
- Apache-2.0
1049
+ Apache-2.0
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
2
  import { ChatContextItem } from '../context/types';
3
+ import { OpenAssistantProps } from '../sidebar';
3
4
  export interface OpenAssistantButtonProps {
4
5
  /** Prompt to pass to the openAssistant function. */
5
6
  prompt: string;
6
- /** Origin of the request that opened the assistant. This is used to track the source of the request. Should be a static string that helps identify the source of the request. */
7
+ /** Origin of the request that opened the assistant. This is used to track the source of the request. Should be a structured string using forward slashes, with the first part as a namespace. Examples: 'grafana-datasources/prometheus/query-builder', 'grafana-slo-app/slo-editor-overview', 'grafana/trace-view-analyzer`. */
7
8
  origin: string;
8
9
  /** Context to pass to the openAssistant function. Optional, defaults to undefined. Created with `createAssistantContextItem`. */
9
10
  context?: ChatContextItem[];
@@ -19,4 +20,11 @@ export interface OpenAssistantButtonProps {
19
20
  /**
20
21
  * A button component that opens the Grafana Assistant with configurable prompt and context.
21
22
  */
22
- export declare function OpenAssistantButton({ prompt, origin, context, autoSend, title, size, iconOnlyButton, }: OpenAssistantButtonProps): React.JSX.Element | null;
23
+ export declare function OpenAssistantButton(props: OpenAssistantButtonProps): React.JSX.Element | null;
24
+ /**
25
+ * Presentational component separated from OpenAssistantButton to avoid hook dependencies in Storybook.
26
+ * It is not exported for users of the package.
27
+ */
28
+ export declare function OpenAssistantButtonView({ prompt, origin, context, autoSend, title, size, iconOnlyButton, openAssistant, }: OpenAssistantButtonProps & {
29
+ openAssistant: (props: OpenAssistantProps) => void;
30
+ }): React.JSX.Element;
@@ -0,0 +1,9 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { OpenAssistantButtonView } from './OpenAssistantButton';
3
+ declare const meta: Meta<typeof OpenAssistantButtonView>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof OpenAssistantButtonView>;
6
+ export declare const Default: Story;
7
+ export declare const IconOnly: Story;
8
+ export declare const LargeButton: Story;
9
+ export declare const CustomTitle: Story;
@@ -1,5 +1,5 @@
1
1
  import { IconName } from '@grafana/ui';
2
- import { type ContextItemData } from './types';
2
+ import { ItemDataType, type ContextItemData } from './types';
3
3
  export interface BaseParams {
4
4
  title?: string;
5
5
  hidden?: boolean;
@@ -8,21 +8,23 @@ export interface BaseParams {
8
8
  }
9
9
  export interface NodeDataParams extends BaseParams {
10
10
  id: string;
11
+ type: ItemDataType;
11
12
  text?: string;
12
13
  }
13
14
  export declare class NodeData {
14
15
  params: NodeDataParams;
15
16
  id: string;
16
17
  text: string;
18
+ type: ItemDataType;
17
19
  constructor(params: NodeDataParams);
18
20
  formatForLLM(codeElementIds?: string[]): ContextItemData;
21
+ equals(other: unknown): boolean;
19
22
  }
20
23
  export interface StructuredNodeDataParams extends BaseParams {
21
24
  data: Record<string, any>;
22
25
  }
23
- export declare class StructuredNodeData {
24
- params: StructuredNodeDataParams;
25
- id: string;
26
+ export declare class StructuredNodeData extends NodeData {
27
+ data: Record<string, any>;
26
28
  constructor(params: StructuredNodeDataParams);
27
29
  formatForLLM(codeElementIds?: string[]): ContextItemData;
28
30
  }
@@ -0,0 +1,38 @@
1
+ import { ComponentType } from 'react';
2
+ import { BaseParams, NodeData } from './base';
3
+ import { type ContextItemData } from './types';
4
+ export type ComponentImplementation = ComponentType<any>;
5
+ export type NamedComponents = Record<string, ComponentImplementation>;
6
+ /**
7
+ * Type used to create a component context item.
8
+ */
9
+ export interface CreateComponentContextParams extends BaseParams {
10
+ components: Record<string, ComponentType<any>>;
11
+ prompt: string;
12
+ namespace?: string;
13
+ }
14
+ export declare class ComponentNodeData extends NodeData {
15
+ components: Record<string, ComponentType<any>>;
16
+ prompt: string;
17
+ namespace: string;
18
+ constructor(params: CreateComponentContextParams);
19
+ formatForLLM(codeElementIds?: string[]): ContextItemData;
20
+ }
21
+ /**
22
+ * React hook that provides all components available for the current page.
23
+ * This hook automatically updates when the URL changes or when component registrations change.
24
+ *
25
+ * @returns Object containing all components available for the current page, keyed by namespace.componentName
26
+ */
27
+ export declare function usePageComponents(): Record<string, ComponentImplementation>;
28
+ /**
29
+ * Provide components to the assistant.
30
+ *
31
+ * @param prompt - The prompt to use for the components.
32
+ * @param namespace - The namespace to use for the components.
33
+ * @param components - The components to provide.
34
+ * @param urlPattern - The URL pattern to match for the components.
35
+ */
36
+ export declare function provideComponents(prompt: string, namespace: string, components: Record<string, ComponentImplementation>, urlPattern?: string | RegExp): ((context: import("./types").ChatContextItem[]) => void) & {
37
+ unregister: () => void;
38
+ };
@@ -1,4 +1,5 @@
1
1
  import { NodeData, NodeDataParams, StructuredNodeData, StructuredNodeDataParams } from './base';
2
+ import { ComponentNodeData, type CreateComponentContextParams } from './component';
2
3
  import { DashboardNodeData, FolderNodeData, type CreateDashboardContextParams, type CreateFolderContextParams } from './dashboard';
3
4
  import { DatasourceNodeData, type CreateDatasourceContextParams } from './datasource';
4
5
  import { LabelNameNodeData, LabelValueNodeData, type CreateLabelNameContextParams, type CreateLabelValueContextParams } from './label';
@@ -30,6 +31,10 @@ export type ContextTypeRegistry = {
30
31
  params: StructuredNodeDataParams;
31
32
  node: StructuredNodeData;
32
33
  };
34
+ component: {
35
+ params: CreateComponentContextParams;
36
+ node: ComponentNodeData;
37
+ };
33
38
  unknown: {
34
39
  params: NodeDataParams;
35
40
  node: NodeData;
@@ -1,5 +1,6 @@
1
1
  export * from './base';
2
2
  export * from './chat';
3
+ export * from './component';
3
4
  export * from './dashboard';
4
5
  export * from './datasource';
5
6
  export * from './factory';
@@ -28,4 +28,5 @@ export declare function providePageContext(urlPattern: string | RegExp, initialC
28
28
  export declare function useProvidePageContext(urlPattern: string | RegExp, initialContext?: ChatContextItem[]): (context: ChatContextItem[]) => void;
29
29
  export declare function usePageContext(options?: {
30
30
  allowQuestions: boolean;
31
+ allowComponents: boolean;
31
32
  }): ChatContextItem[];
@@ -1,11 +1,12 @@
1
1
  import { IconName } from '@grafana/ui';
2
+ import { ComponentType } from 'react';
2
3
  export interface BaseItemData {
3
4
  name: string;
4
5
  text: string;
5
6
  }
6
7
  export interface UnknownItemData extends BaseItemData {
7
8
  }
8
- export type ItemDataType = 'unknown' | 'datasource' | 'label_name' | 'label_value' | 'dashboard' | 'dashboard_folder' | 'structured';
9
+ export type ItemDataType = 'unknown' | 'datasource' | 'label_name' | 'label_value' | 'dashboard' | 'dashboard_folder' | 'structured' | 'component';
9
10
  export interface ContextItemData {
10
11
  type: ItemDataType;
11
12
  codeElementIds?: string[];
@@ -47,6 +48,11 @@ export interface FolderItemData extends BaseItemData {
47
48
  folderUid: string;
48
49
  folderTitle: string;
49
50
  }
51
+ export interface ComponentItemData extends BaseItemData {
52
+ components: Record<string, ComponentType<any>>;
53
+ prompt: string;
54
+ namespace: string;
55
+ }
50
56
  export interface ChatContextItem {
51
57
  node: TreeNode;
52
58
  occurrences: string[];
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { createAssistantContextItem, ChatContextItem, DashboardNodeData, DatasourceNodeData, FolderNodeData, ItemDataType, LabelNameNodeData, LabelValueNodeData, StructuredNodeData, TreeNode, providePageContext, useProvidePageContext, PageContextRegistration, usePageContext, provideQuestions, useProvideQuestions, useQuestions, Question, QuestionRegistration, } from './context/index';
1
+ export { createAssistantContextItem, ChatContextItem, ComponentNodeData, DashboardNodeData, DatasourceNodeData, FolderNodeData, ItemDataType, LabelNameNodeData, LabelValueNodeData, StructuredNodeData, TreeNode, providePageContext, useProvidePageContext, PageContextRegistration, usePageContext, provideQuestions, useProvideQuestions, useQuestions, Question, QuestionRegistration, usePageComponents, provideComponents, ComponentImplementation, NamedComponents, } from './context/index';
2
2
  export * from './functions';
3
3
  export * from './hook';
4
4
  export * from './plugin';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return(t>>>0).toString(16)}e.r(t),e.d(t,{CALLBACK_EXTENSION_POINT:()=>T,DashboardNodeData:()=>i,DatasourceNodeData:()=>c,FolderNodeData:()=>o,LabelNameNodeData:()=>u,LabelValueNodeData:()=>l,OpenAssistantButton:()=>it,StructuredNodeData:()=>a,closeAssistant:()=>q,createAssistantContextItem:()=>p,getExposeAssistantFunctionsConfig:()=>_,isAssistantAvailable:()=>O,newFunctionNamespace:()=>U,openAssistant:()=>j,providePageContext:()=>k,provideQuestions:()=>S,useAssistant:()=>D,usePageContext:()=>A,useProvidePageContext:()=>E,useProvideQuestions:()=>$,useQuestions:()=>N});class r{constructor(e){this.params=e,this.text="",this.id=n(e.id)}formatForLLM(e){var t,n;return{type:"unknown",codeElementIds:e,data:{name:null!==(t=this.params.text)&&void 0!==t?t:"",text:null!==(n=this.params.text)&&void 0!==n?n:""}}}}class a{constructor(e){this.params=e,this.id=n(JSON.stringify(e.data))}formatForLLM(e){return{type:"structured",codeElementIds:e,data:this.params.data}}}const s=require("@grafana/runtime");class i extends r{constructor(e){super({...e,id:e.dashboardUid}),this.dashboardUid=e.dashboardUid,this.dashboardTitle=e.dashboardTitle,this.folderUid=e.folderUid,this.folderTitle=e.folderTitle,this.text=e.dashboardTitle}formatForLLM(e){return{type:"dashboard",codeElementIds:e,data:{name:this.dashboardTitle,dashboardUid:this.dashboardUid,dashboardTitle:this.dashboardTitle,folderUid:this.folderUid,folderTitle:this.folderTitle,text:this.text}}}}class o extends r{constructor(e){super({...e,id:e.folderUid}),this.text="",this.folderUid=e.folderUid,this.folderTitle=e.folderTitle,this.text=e.folderTitle}formatForLLM(e){return{type:"dashboard_folder",codeElementIds:e,data:{name:this.folderTitle,folderUid:this.folderUid,folderTitle:this.folderTitle,text:this.text}}}}class c extends r{constructor(e){super({...e,id:e.datasourceUid}),this.datasourceUid=e.datasourceUid,this.datasourceType=e.datasourceType,this.datasourceName=e.datasourceName,this.img=e.img,this.text=e.datasourceName}formatForLLM(e){return{type:"datasource",codeElementIds:e,data:{name:this.datasourceName,uid:this.datasourceUid,type:this.datasourceType,text:this.text,img:this.img}}}}class u extends r{constructor(e){super({...e,id:`${e.datasourceUid}-${e.labelName}`}),this.datasourceUid=e.datasourceUid,this.datasourceType=e.datasourceType,this.datasourceName=e.datasourceName,this.labelName=e.labelName,this.text=e.labelName,this.img=e.img}formatForLLM(e){return{type:"label_name",codeElementIds:e,data:{name:this.labelName,datasourceUid:this.datasourceUid,datasourceType:this.datasourceType,datasourceName:this.datasourceName,labelName:this.labelName,img:this.img,text:this.text}}}}class l extends r{constructor(e){super({...e,id:`${e.datasourceUid}-${e.labelName}-${e.labelValue}`}),this.datasourceUid=e.datasourceUid,this.datasourceType=e.datasourceType,this.datasourceName=e.datasourceName,this.labelName=e.labelName,this.labelValue=e.labelValue,this.text=e.labelValue,this.img=e.img}formatForLLM(e){return{type:"label_value",codeElementIds:e,data:{name:this.labelValue,datasourceUid:this.datasourceUid,datasourceType:this.datasourceType,datasourceName:this.datasourceName,labelName:this.labelName,labelValue:this.labelValue,text:this.text,img:this.img}}}}function d(e){var t,n,r,a,i;const o=(0,s.getDataSourceSrv)().getInstanceSettings(e);return{datasourceType:null!==(t=null==o?void 0:o.type)&&void 0!==t?t:"unknown",datasourceName:null!==(n=null==o?void 0:o.name)&&void 0!==n?n:e,img:null===(i=null===(a=null===(r=null==o?void 0:o.meta)||void 0===r?void 0:r.info)||void 0===a?void 0:a.logos)||void 0===i?void 0:i.small}}const f={datasource:"database",label_name:"database",label_value:"database",dashboard:"dashboard",dashboard_folder:"folder",unknown:"circle-mono",structured:"gf-grid"};function p(e,t){var n,s,p;const h=function(e,t){switch(e){case"datasource":return new c({...t,...d(t.datasourceUid)});case"label_name":return new u({...t,...d(t.datasourceUid)});case"label_value":return new l({...t,...d(t.datasourceUid)});case"dashboard":return new i(t);case"dashboard_folder":return new o(t);case"structured":return new a(t);case"unknown":return new r(t);default:return console.error(`Unknown context type: ${e}`),new r(t)}}(e,t),m=null!==(n=t.title)&&void 0!==n?n:function(e){var t;return e instanceof a?e.formatForLLM().data.name:null!==(t=e.text)&&void 0!==t?t:"Given Context"}(h),v=null!==(s=t.img)&&void 0!==s?s:function(e){if("img"in e)return e.img}(h);return{node:{id:h.id,name:m,img:v,icon:null!==(p=t.icon)&&void 0!==p?p:f[e],navigable:!1,selectable:!0,data:h},occurrences:[]}}const h=require("react");var m=e.n(h);const v=[],g="grafana-assistant:page-context-sync",b="grafana-assistant:page-context-update",y="grafana-assistant:page-context-remove",x="grafana-assistant:location-changed";let w=!1;function k(e,t){const n=v.findIndex((t=>{return n=t.urlPattern,r=e,"string"==typeof n&&"string"==typeof r?n===r:n instanceof RegExp&&r instanceof RegExp&&n.source===r.source&&n.flags===r.flags;var n,r}));let r;-1!==n?(r=v[n],r.context=[...t]):(r={id:`page-context-${Date.now()}-${Math.random().toString(36).slice(2,11)}`,urlPattern:e,context:[...t]},v.push(r)),window.dispatchEvent(new CustomEvent(b,{detail:r})),window.dispatchEvent(new CustomEvent(g,{detail:{registry:v}}));const a=e=>{const t=v.findIndex((e=>e.id===r.id));-1!==t&&(v[t].context=[...e],window.dispatchEvent(new CustomEvent(b,{detail:v[t]})))};return a.unregister=()=>{const e=v.findIndex((e=>e.id===r.id));-1!==e&&(v.splice(e,1),window.dispatchEvent(new CustomEvent(y,{detail:{id:r.id}})))},a}function E(e,t=[]){const n=(0,h.useRef)(void 0),r=(0,h.useRef)(t);return r.current=t,(0,h.useEffect)((()=>(n.current=k(e,r.current),()=>{var e;null===(e=n.current)||void 0===e||e.unregister()})),[e]),(0,h.useEffect)((()=>{n.current&&n.current(t)}),[t]),(0,h.useCallback)((e=>{var t;null===(t=n.current)||void 0===t||t.call(n,e)}),[])}function A(e={allowQuestions:!1}){const[t,n]=(0,h.useState)([]),r=(0,s.useLocationService)(),a=(0,h.useRef)("");return(0,h.useEffect)((()=>{const e=()=>{const e=function(e,t){if(!e)return[];const n=[];for(const r of t)C(e,r.urlPattern)&&n.push(...r.context);return n}(r.getLocation().pathname,v);n(e)},t=()=>{e()},s=t=>{var n;const a=null===(n=t.detail)||void 0===n?void 0:n.pathname;a&&a===r.getLocation().pathname&&e()},i=r.getLocationObservable().subscribe((t=>{const n=t.pathname;n!==a.current&&(a.current=n,function(e){window.dispatchEvent(new CustomEvent(x,{detail:{pathname:e}}))}(n),e())}));return e(),window.addEventListener(g,t),window.addEventListener(b,t),window.addEventListener(y,t),window.addEventListener(x,s),()=>{i.unsubscribe(),window.removeEventListener(g,t),window.removeEventListener(b,t),window.removeEventListener(y,t),window.removeEventListener(x,s)}}),[r]),e.allowQuestions?t:t.filter((e=>{var t;return"question"!==(null===(t=e.node.data)||void 0===t?void 0:t.type)}))}function C(e,t){if(t instanceof RegExp)return t.test(e);if("string"==typeof t){const n=t.replace(/\*\*/g,"\0DOUBLE_STAR\0").replace(/\*/g,"[^/]*").replace(/\u0000DOUBLE_STAR\u0000/g,".*").replace(/\?/g,".");return new RegExp(`^${n}$`).test(e)}return!1}function S(e,t){const n=e=>e.map(((e,t)=>({node:{id:`question-${t}`,name:e.prompt,navigable:!1,selectable:!0,icon:"question-circle",data:{type:"question",prompt:e.prompt,context:e.context||[]}},occurrences:[]}))),r=k(e,n(t)),a=e=>{r(n(e))};return a.unregister=r.unregister,a}function $(e,t=[]){const n=e=>e.map(((e,t)=>({node:{id:`question-${t}`,name:e.prompt,navigable:!1,selectable:!0,icon:"question-circle",data:{type:"question",prompt:e.prompt,context:e.context||[]}},occurrences:[]}))),r=E(e,n(t));return e=>{r(n(e))}}function N(){const e=A({allowQuestions:!0});return L(e)}w||(window.addEventListener(g,(e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.registry;if(n){const e=new Set(v.map((e=>e.id))),t=n.filter((t=>!e.has(t.id)));v.push(...t)}})),window.addEventListener(b,(e=>{const t=e.detail;if(t){const e=v.findIndex((e=>e.id===t.id));-1!==e?v[e]=t:v.push(t)}})),window.addEventListener(y,(e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.id;if(n){const e=v.findIndex((e=>e.id===n));-1!==e&&v.splice(e,1)}})),w=!0);const L=e=>e.filter((e=>{var t;return"question"===(null===(t=e.node.data)||void 0===t?void 0:t.type)})).map((e=>{var t,n;return{prompt:(null===(t=e.node.data)||void 0===t?void 0:t.prompt)||e.node.name,context:(null===(n=e.node.data)||void 0===n?void 0:n.context)||[]}})),T="grafana-assistant-app/callback/v0-alpha";function U(e,t){return{namespace:e,functions:t}}function _(e){return{title:"callback",targets:[T],fn:()=>e.map((e=>({namespace:e.namespace,functions:e.functions})))}}const I=require("rxjs");function O(){if(!s.getObservablePluginLinks)return(0,I.of)(!1);return(0,s.getObservablePluginLinks)({extensionPointId:"grafana/extension-sidebar/v0-alpha"}).pipe((0,I.map)((e=>e.some((e=>"grafana-assistant-app"===e.pluginId&&"Grafana Assistant"===e.title)))))}const P=require("@grafana/data");class R extends P.BusEventWithPayload{}R.type="open-extension-sidebar";class M extends P.BusEventBase{}function j(e){var t,n;(0,s.reportInteraction)("grafana_assistant_app_opened_sidebar",{from:e.origin,prompt:null!==(t=e.prompt)&&void 0!==t?t:""}),function(e,t,n){const r=new R({pluginId:"grafana-assistant-app",componentTitle:"Grafana Assistant",props:n});(0,s.getAppEvents)().publish(r)}(0,0,{initialPrompt:e.prompt,initialContext:e.context,initialAutoSend:null===(n=e.autoSend)||void 0===n||n})}function q(){!function(){const e=new M;(0,s.getAppEvents)().publish(e)}()}function D(){const[e,t]=(0,h.useState)(!1);return(0,h.useEffect)((()=>{const e=O().subscribe((e=>t(e)));return()=>{e.unsubscribe()}}),[]),[e,e?j:void 0,e?q:void 0]}M.type="close-extension-sidebar";const F=require("@grafana/ui");var z=function(){function e(e){var t=this;this._insertTag=function(e){var n;n=0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling,t.container.insertBefore(e,n),t.tags.push(e)},this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if(this.isSpeedy){var n=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(t);try{n.insertRule(e,n.cssRules.length)}catch(e){}}else t.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach((function(e){var t;return null==(t=e.parentNode)?void 0:t.removeChild(e)})),this.tags=[],this.ctr=0},e}(),G=Math.abs,B=String.fromCharCode,V=Object.assign;function Q(e){return e.trim()}function W(e,t,n){return e.replace(t,n)}function H(e,t){return e.indexOf(t)}function J(e,t){return 0|e.charCodeAt(t)}function K(e,t,n){return e.slice(t,n)}function X(e){return e.length}function Z(e){return e.length}function Y(e,t){return t.push(e),e}var ee=1,te=1,ne=0,re=0,ae=0,se="";function ie(e,t,n,r,a,s,i){return{value:e,root:t,parent:n,type:r,props:a,children:s,line:ee,column:te,length:i,return:""}}function oe(e,t){return V(ie("",null,null,"",null,null,0),e,{length:-e.length},t)}function ce(){return ae=re>0?J(se,--re):0,te--,10===ae&&(te=1,ee--),ae}function ue(){return ae=re<ne?J(se,re++):0,te++,10===ae&&(te=1,ee++),ae}function le(){return J(se,re)}function de(){return re}function fe(e,t){return K(se,e,t)}function pe(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function he(e){return ee=te=1,ne=X(se=e),re=0,[]}function me(e){return se="",e}function ve(e){return Q(fe(re-1,ye(91===e?e+2:40===e?e+1:e)))}function ge(e){for(;(ae=le())&&ae<33;)ue();return pe(e)>2||pe(ae)>3?"":" "}function be(e,t){for(;--t&&ue()&&!(ae<48||ae>102||ae>57&&ae<65||ae>70&&ae<97););return fe(e,de()+(t<6&&32==le()&&32==ue()))}function ye(e){for(;ue();)switch(ae){case e:return re;case 34:case 39:34!==e&&39!==e&&ye(ae);break;case 40:41===e&&ye(e);break;case 92:ue()}return re}function xe(e,t){for(;ue()&&e+ae!==57&&(e+ae!==84||47!==le()););return"/*"+fe(t,re-1)+"*"+B(47===e?e:ue())}function we(e){for(;!pe(le());)ue();return fe(e,re)}var ke="-ms-",Ee="-moz-",Ae="-webkit-",Ce="comm",Se="rule",$e="decl",Ne="@keyframes";function Le(e,t){for(var n="",r=Z(e),a=0;a<r;a++)n+=t(e[a],a,e,t)||"";return n}function Te(e,t,n,r){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case $e:return e.return=e.return||e.value;case Ce:return"";case Ne:return e.return=e.value+"{"+Le(e.children,r)+"}";case Se:e.value=e.props.join(",")}return X(n=Le(e.children,r))?e.return=e.value+"{"+n+"}":""}function Ue(e){return me(_e("",null,null,null,[""],e=he(e),0,[0],e))}function _e(e,t,n,r,a,s,i,o,c){for(var u=0,l=0,d=i,f=0,p=0,h=0,m=1,v=1,g=1,b=0,y="",x=a,w=s,k=r,E=y;v;)switch(h=b,b=ue()){case 40:if(108!=h&&58==J(E,d-1)){-1!=H(E+=W(ve(b),"&","&\f"),"&\f")&&(g=-1);break}case 34:case 39:case 91:E+=ve(b);break;case 9:case 10:case 13:case 32:E+=ge(h);break;case 92:E+=be(de()-1,7);continue;case 47:switch(le()){case 42:case 47:Y(Oe(xe(ue(),de()),t,n),c);break;default:E+="/"}break;case 123*m:o[u++]=X(E)*g;case 125*m:case 59:case 0:switch(b){case 0:case 125:v=0;case 59+l:-1==g&&(E=W(E,/\f/g,"")),p>0&&X(E)-d&&Y(p>32?Pe(E+";",r,n,d-1):Pe(W(E," ","")+";",r,n,d-2),c);break;case 59:E+=";";default:if(Y(k=Ie(E,t,n,u,l,a,o,y,x=[],w=[],d),s),123===b)if(0===l)_e(E,t,k,k,x,s,d,o,w);else switch(99===f&&110===J(E,3)?100:f){case 100:case 108:case 109:case 115:_e(e,k,k,r&&Y(Ie(e,k,k,0,0,a,o,y,a,x=[],d),w),a,w,d,o,r?x:w);break;default:_e(E,k,k,k,[""],w,0,o,w)}}u=l=p=0,m=g=1,y=E="",d=i;break;case 58:d=1+X(E),p=h;default:if(m<1)if(123==b)--m;else if(125==b&&0==m++&&125==ce())continue;switch(E+=B(b),b*m){case 38:g=l>0?1:(E+="\f",-1);break;case 44:o[u++]=(X(E)-1)*g,g=1;break;case 64:45===le()&&(E+=ve(ue())),f=le(),l=d=X(y=E+=we(de())),b++;break;case 45:45===h&&2==X(E)&&(m=0)}}return s}function Ie(e,t,n,r,a,s,i,o,c,u,l){for(var d=a-1,f=0===a?s:[""],p=Z(f),h=0,m=0,v=0;h<r;++h)for(var g=0,b=K(e,d+1,d=G(m=i[h])),y=e;g<p;++g)(y=Q(m>0?f[g]+" "+b:W(b,/&\f/g,f[g])))&&(c[v++]=y);return ie(e,t,n,0===a?Se:o,c,u,l)}function Oe(e,t,n){return ie(e,t,n,Ce,B(ae),K(e,2,-2),0)}function Pe(e,t,n,r){return ie(e,t,n,$e,K(e,0,r),K(e,r+1,-1),r)}var Re=function(e,t,n){for(var r=0,a=0;r=a,a=le(),38===r&&12===a&&(t[n]=1),!pe(a);)ue();return fe(e,re)},Me=new WeakMap,je=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,n=e.parent,r=e.column===n.column&&e.line===n.line;"rule"!==n.type;)if(!(n=n.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||Me.get(n))&&!r){Me.set(e,!0);for(var a=[],s=function(e,t){return me(function(e,t){var n=-1,r=44;do{switch(pe(r)){case 0:38===r&&12===le()&&(t[n]=1),e[n]+=Re(re-1,t,n);break;case 2:e[n]+=ve(r);break;case 4:if(44===r){e[++n]=58===le()?"&\f":"",t[n]=e[n].length;break}default:e[n]+=B(r)}}while(r=ue());return e}(he(e),t))}(t,a),i=n.props,o=0,c=0;o<s.length;o++)for(var u=0;u<i.length;u++,c++)e.props[c]=a[o]?s[o].replace(/&\f/g,i[u]):i[u]+" "+s[o]}}},qe=function(e){if("decl"===e.type){var t=e.value;108===t.charCodeAt(0)&&98===t.charCodeAt(2)&&(e.return="",e.value="")}};function De(e,t){switch(function(e,t){return 45^J(e,0)?(((t<<2^J(e,0))<<2^J(e,1))<<2^J(e,2))<<2^J(e,3):0}(e,t)){case 5103:return Ae+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Ae+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Ae+e+Ee+e+ke+e+e;case 6828:case 4268:return Ae+e+ke+e+e;case 6165:return Ae+e+ke+"flex-"+e+e;case 5187:return Ae+e+W(e,/(\w+).+(:[^]+)/,Ae+"box-$1$2"+ke+"flex-$1$2")+e;case 5443:return Ae+e+ke+"flex-item-"+W(e,/flex-|-self/,"")+e;case 4675:return Ae+e+ke+"flex-line-pack"+W(e,/align-content|flex-|-self/,"")+e;case 5548:return Ae+e+ke+W(e,"shrink","negative")+e;case 5292:return Ae+e+ke+W(e,"basis","preferred-size")+e;case 6060:return Ae+"box-"+W(e,"-grow","")+Ae+e+ke+W(e,"grow","positive")+e;case 4554:return Ae+W(e,/([^-])(transform)/g,"$1"+Ae+"$2")+e;case 6187:return W(W(W(e,/(zoom-|grab)/,Ae+"$1"),/(image-set)/,Ae+"$1"),e,"")+e;case 5495:case 3959:return W(e,/(image-set\([^]*)/,Ae+"$1$`$1");case 4968:return W(W(e,/(.+:)(flex-)?(.*)/,Ae+"box-pack:$3"+ke+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Ae+e+e;case 4095:case 3583:case 4068:case 2532:return W(e,/(.+)-inline(.+)/,Ae+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(X(e)-1-t>6)switch(J(e,t+1)){case 109:if(45!==J(e,t+4))break;case 102:return W(e,/(.+:)(.+)-([^]+)/,"$1"+Ae+"$2-$3$1"+Ee+(108==J(e,t+3)?"$3":"$2-$3"))+e;case 115:return~H(e,"stretch")?De(W(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==J(e,t+1))break;case 6444:switch(J(e,X(e)-3-(~H(e,"!important")&&10))){case 107:return W(e,":",":"+Ae)+e;case 101:return W(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Ae+(45===J(e,14)?"inline-":"")+"box$3$1"+Ae+"$2$3$1"+ke+"$2box$3")+e}break;case 5936:switch(J(e,t+11)){case 114:return Ae+e+ke+W(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ae+e+ke+W(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ae+e+ke+W(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return Ae+e+ke+e+e}return e}var Fe=[function(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case $e:e.return=De(e.value,e.length);break;case Ne:return Le([oe(e,{value:W(e.value,"@","@"+Ae)})],r);case Se:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e){return(e=/(::plac\w+|:read-\w+)/.exec(e))?e[0]:e}(t)){case":read-only":case":read-write":return Le([oe(e,{props:[W(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return Le([oe(e,{props:[W(t,/:(plac\w+)/,":"+Ae+"input-$1")]}),oe(e,{props:[W(t,/:(plac\w+)/,":-moz-$1")]}),oe(e,{props:[W(t,/:(plac\w+)/,ke+"input-$1")]})],r)}return""}))}}],ze={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function Ge(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var Be=/[A-Z]|^ms/g,Ve=/_EMO_([^_]+?)_([^]*?)_EMO_/g,Qe=function(e){return 45===e.charCodeAt(1)},We=function(e){return null!=e&&"boolean"!=typeof e},He=Ge((function(e){return Qe(e)?e:e.replace(Be,"-$&").toLowerCase()})),Je=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(Ve,(function(e,t,n){return Xe={name:t,styles:n,next:Xe},t}))}return 1===ze[e]||Qe(e)||"number"!=typeof t||0===t?t:t+"px"};function Ke(e,t,n){if(null==n)return"";var r=n;if(void 0!==r.__emotion_styles)return r;switch(typeof n){case"boolean":return"";case"object":var a=n;if(1===a.anim)return Xe={name:a.name,styles:a.styles,next:Xe},a.name;var s=n;if(void 0!==s.styles){var i=s.next;if(void 0!==i)for(;void 0!==i;)Xe={name:i.name,styles:i.styles,next:Xe},i=i.next;return s.styles+";"}return function(e,t,n){var r="";if(Array.isArray(n))for(var a=0;a<n.length;a++)r+=Ke(e,t,n[a])+";";else for(var s in n){var i=n[s];if("object"!=typeof i){var o=i;null!=t&&void 0!==t[o]?r+=s+"{"+t[o]+"}":We(o)&&(r+=He(s)+":"+Je(s,o)+";")}else if(!Array.isArray(i)||"string"!=typeof i[0]||null!=t&&void 0!==t[i[0]]){var c=Ke(e,t,i);switch(s){case"animation":case"animationName":r+=He(s)+":"+c+";";break;default:r+=s+"{"+c+"}"}}else for(var u=0;u<i.length;u++)We(i[u])&&(r+=He(s)+":"+Je(s,i[u])+";")}return r}(e,t,n);case"function":if(void 0!==e){var o=Xe,c=n(e);return Xe=o,Ke(e,t,c)}}var u=n;if(null==t)return u;var l=t[u];return void 0!==l?l:u}var Xe,Ze=/label:\s*([^\s;{]+)\s*(;|$)/g;function Ye(e,t,n){if(1===e.length&&"object"==typeof e[0]&&null!==e[0]&&void 0!==e[0].styles)return e[0];var r=!0,a="";Xe=void 0;var s=e[0];null==s||void 0===s.raw?(r=!1,a+=Ke(n,t,s)):a+=s[0];for(var i=1;i<e.length;i++)a+=Ke(n,t,e[i]),r&&(a+=s[i]);Ze.lastIndex=0;for(var o,c="";null!==(o=Ze.exec(a));)c+="-"+o[1];var u=function(e){for(var t,n=0,r=0,a=e.length;a>=4;++r,a-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(a){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(a)+c;return{name:u,styles:a,next:Xe}}function et(e,t,n){var r="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):n&&(r+=n+" ")})),r}function tt(e,t){if(void 0===e.inserted[t.name])return e.insert("",t,e.sheet,!0)}function nt(e,t,n){var r=[],a=et(e,r,n);return r.length<2?n:a+t(r)}var rt=function e(t){for(var n="",r=0;r<t.length;r++){var a=t[r];if(null!=a){var s=void 0;switch(typeof a){case"boolean":break;case"object":if(Array.isArray(a))s=e(a);else for(var i in s="",a)a[i]&&i&&(s&&(s+=" "),s+=i);break;default:s=a}s&&(n&&(n+=" "),n+=s)}}return n};var at=function(e){var t=function(e){var t=e.key;if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var r,a,s=e.stylisPlugins||Fe,i={},o=[];r=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n<t.length;n++)i[t[n]]=!0;o.push(e)}));var c,u,l,d,f=[Te,(d=function(e){c.insert(e)},function(e){e.root||(e=e.return)&&d(e)})],p=(u=[je,qe].concat(s,f),l=Z(u),function(e,t,n,r){for(var a="",s=0;s<l;s++)a+=u[s](e,t,n,r)||"";return a});a=function(e,t,n,r){c=n,Le(Ue(e?e+"{"+t.styles+"}":t.styles),p),r&&(h.inserted[t.name]=!0)};var h={key:t,sheet:new z({key:t,container:r,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend,insertionPoint:e.insertionPoint}),nonce:e.nonce,inserted:i,registered:{},insert:a};return h.sheet.hydrate(o),h}(e);t.sheet.speedy=function(e){this.isSpeedy=e},t.compat=!0;var n=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var a=Ye(n,t.registered,void 0);return function(e,t){!function(e,t){var n=e.key+"-"+t.name;void 0===e.registered[n]&&(e.registered[n]=t.styles)}(e,t);var n=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var r=t;do{e.insert(t===r?"."+n:"",r,e.sheet,!0),r=r.next}while(void 0!==r)}}(t,a),t.key+"-"+a.name};return{css:n,cx:function(){for(var e=arguments.length,r=new Array(e),a=0;a<e;a++)r[a]=arguments[a];return nt(t.registered,n,rt(r))},injectGlobal:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var a=Ye(n,t.registered);tt(t,a)},keyframes:function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var a=Ye(n,t.registered),s="animation-"+a.name;return tt(t,{name:a.name,styles:"@keyframes "+s+"{"+a.styles+"}"}),s},hydrate:function(e){e.forEach((function(e){t.inserted[e]=!0}))},flush:function(){t.registered={},t.inserted={},t.sheet.flush()},sheet:t.sheet,cache:t,getRegisteredStyles:et.bind(null,t.registered),merge:nt.bind(null,t.registered,n)}}({key:"css"}),st=(at.flush,at.hydrate,at.cx,at.merge,at.getRegisteredStyles,at.injectGlobal,at.keyframes,at.css);function it({prompt:e,origin:t,context:n,autoSend:r=!0,title:a="Analyze with Assistant",size:s="sm",iconOnlyButton:i=!1}){const o=(0,F.useStyles2)(ot),[c,u]=D();return c&&u?m().createElement(m().Fragment,null,i?m().createElement(F.IconButton,{name:"ai-sparkle",onClick:()=>u({prompt:e,context:n,autoSend:r,origin:t}),variant:"secondary",size:s,"aria-label":a,className:o.icon,tooltip:a}):m().createElement(F.Button,{icon:"ai-sparkle",onClick:()=>u({prompt:e,context:n,autoSend:r,origin:t}),variant:"secondary",fill:"solid",size:s,title:a,"aria-label":a,className:o.button},a)):null}at.sheet,at.cache;const ot=e=>({button:st({label:"assistant-button",border:"1px solid transparent",borderImage:"linear-gradient(90deg, rgb(168, 85, 247), rgb(249, 115, 22)) 1"}),icon:st({label:"assistant-icon",border:"1px solid transparent",backgroundClip:"padding-box",padding:e.spacing(.5),"&:hover":{borderImage:"linear-gradient(90deg, rgb(168, 85, 247), rgb(249, 115, 22)) 1 !important",border:"1px solid transparent",backgroundClip:"padding-box"}})});module.exports=t})();
1
+ (()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var a in n)e.o(n,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:n[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return(t>>>0).toString(16)}e.r(t),e.d(t,{CALLBACK_EXTENSION_POINT:()=>I,ComponentNodeData:()=>b,DashboardNodeData:()=>x,DatasourceNodeData:()=>E,FolderNodeData:()=>k,LabelNameNodeData:()=>C,LabelValueNodeData:()=>A,OpenAssistantButton:()=>ut,StructuredNodeData:()=>r,closeAssistant:()=>z,createAssistantContextItem:()=>N,getExposeAssistantFunctionsConfig:()=>P,isAssistantAvailable:()=>j,newFunctionNamespace:()=>O,openAssistant:()=>F,provideComponents:()=>w,providePageContext:()=>h,provideQuestions:()=>L,useAssistant:()=>G,usePageComponents:()=>y,usePageContext:()=>v,useProvidePageContext:()=>m,useProvideQuestions:()=>T,useQuestions:()=>_});class a{constructor(e){this.params=e,this.text="",this.id=n(e.id),this.type=e.type}formatForLLM(e){var t,n;return{type:this.type,codeElementIds:e,data:{name:null!==(t=this.params.text)&&void 0!==t?t:"",text:null!==(n=this.params.text)&&void 0!==n?n:""}}}equals(e){return e instanceof a&&this.id===e.id&&this.type===e.type}}class r extends a{constructor(e){super({...e,id:n(JSON.stringify(e.data)),type:"structured"}),this.data=e.data}formatForLLM(e){return{type:this.type,codeElementIds:e,data:this.data}}}const s=require("@grafana/runtime"),o=require("react");var i=e.n(o);const c=[],u="grafana-assistant:page-context-sync",l="grafana-assistant:page-context-update",d="grafana-assistant:page-context-remove",f="grafana-assistant:location-changed";let p=!1;function h(e,t){const n=c.findIndex((t=>{return n=t.urlPattern,a=e,"string"==typeof n&&"string"==typeof a?n===a:n instanceof RegExp&&a instanceof RegExp&&n.source===a.source&&n.flags===a.flags;var n,a}));let a;-1!==n?(a=c[n],a.context=[...t]):(a={id:`page-context-${Date.now()}-${Math.random().toString(36).slice(2,11)}`,urlPattern:e,context:[...t]},c.push(a)),window.dispatchEvent(new CustomEvent(l,{detail:a})),window.dispatchEvent(new CustomEvent(u,{detail:{registry:c}}));const r=e=>{const t=c.findIndex((e=>e.id===a.id));-1!==t&&(c[t].context=[...e],window.dispatchEvent(new CustomEvent(l,{detail:c[t]})))};return r.unregister=()=>{const e=c.findIndex((e=>e.id===a.id));-1!==e&&(c.splice(e,1),window.dispatchEvent(new CustomEvent(d,{detail:{id:a.id}})))},r}function m(e,t=[]){const n=(0,o.useRef)(void 0),a=(0,o.useRef)(t);return a.current=t,(0,o.useEffect)((()=>(n.current=h(e,a.current),()=>{var e;null===(e=n.current)||void 0===e||e.unregister()})),[e]),(0,o.useEffect)((()=>{n.current&&n.current(t)}),[t]),(0,o.useCallback)((e=>{var t;null===(t=n.current)||void 0===t||t.call(n,e)}),[])}function v(e={allowQuestions:!1,allowComponents:!1}){const[t,n]=(0,o.useState)([]),a=(0,s.useLocationService)(),r=(0,o.useRef)("");(0,o.useEffect)((()=>{const e=()=>{const e=function(e,t){if(!e)return[];const n=[];for(const a of t)g(e,a.urlPattern)&&n.push(...a.context);return n}(a.getLocation().pathname,c);n(e)},t=()=>{e()},s=t=>{var n;const r=null===(n=t.detail)||void 0===n?void 0:n.pathname;r&&r===a.getLocation().pathname&&e()},o=a.getLocationObservable().subscribe((t=>{const n=t.pathname;n!==r.current&&(r.current=n,function(e){window.dispatchEvent(new CustomEvent(f,{detail:{pathname:e}}))}(n),e())}));return e(),window.addEventListener(u,t),window.addEventListener(l,t),window.addEventListener(d,t),window.addEventListener(f,s),()=>{o.unsubscribe(),window.removeEventListener(u,t),window.removeEventListener(l,t),window.removeEventListener(d,t),window.removeEventListener(f,s)}}),[a]);let i=t;return e.allowQuestions||(i=i.filter((e=>{var t;return"question"!==(null===(t=e.node.data)||void 0===t?void 0:t.type)}))),e.allowComponents||(i=i.filter((e=>{var t;return"component"!==(null===(t=e.node.data)||void 0===t?void 0:t.type)}))),i}function g(e,t){if(t instanceof RegExp)return t.test(e);if("string"==typeof t){const n=t.replace(/\*\*/g,"\0DOUBLE_STAR\0").replace(/\*/g,"[^/]*").replace(/\u0000DOUBLE_STAR\u0000/g,".*").replace(/\?/g,".");return new RegExp(`^${n}$`).test(e)}return!1}p||(window.addEventListener(u,(e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.registry;if(n){const e=new Set(c.map((e=>e.id))),t=n.filter((t=>!e.has(t.id)));c.push(...t)}})),window.addEventListener(l,(e=>{const t=e.detail;if(t){const e=c.findIndex((e=>e.id===t.id));-1!==e?c[e]=t:c.push(t)}})),window.addEventListener(d,(e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.id;if(n){const e=c.findIndex((e=>e.id===n));-1!==e&&c.splice(e,1)}})),p=!0);class b extends a{constructor(e){const t=e.namespace||"components";super({...e,id:`${t}-${Object.keys(e.components).join("-")}`,type:"component"}),this.components=e.components,this.prompt=e.prompt,this.namespace=t}formatForLLM(e){return{type:this.type,codeElementIds:e,data:{name:`${this.namespace} components`,prompt:this.prompt,namespace:this.namespace}}}}function y(){const e=v({allowComponents:!0,allowQuestions:!1});return(0,o.useMemo)((()=>{const t={};return e.filter((e=>{var t;return null===(t=e.node.data)||void 0===t?void 0:t.components})).forEach((e=>{const n=e.node.data;if(null==n?void 0:n.components){const e=n.namespace||n.name||"components";Object.entries(n.components).forEach((([n,a])=>{t[`${e}_${n}`]=a}))}})),t}),[e])}function w(e,t,n,a=/.*/){return h(a,[N("component",{components:n,prompt:e,namespace:t})])}class x extends a{constructor(e){super({...e,id:e.dashboardUid,type:"dashboard"}),this.dashboardUid=e.dashboardUid,this.dashboardTitle=e.dashboardTitle,this.folderUid=e.folderUid,this.folderTitle=e.folderTitle,this.text=e.dashboardTitle}formatForLLM(e){return{type:this.type,codeElementIds:e,data:{name:this.dashboardTitle,dashboardUid:this.dashboardUid,dashboardTitle:this.dashboardTitle,folderUid:this.folderUid,folderTitle:this.folderTitle,text:this.text}}}}class k extends a{constructor(e){super({...e,id:e.folderUid,type:"dashboard_folder"}),this.text="",this.folderUid=e.folderUid,this.folderTitle=e.folderTitle,this.text=e.folderTitle}formatForLLM(e){return{type:this.type,codeElementIds:e,data:{name:this.folderTitle,folderUid:this.folderUid,folderTitle:this.folderTitle,text:this.text}}}}class E extends a{constructor(e){super({...e,id:e.datasourceUid,type:"datasource"}),this.datasourceUid=e.datasourceUid,this.datasourceType=e.datasourceType,this.datasourceName=e.datasourceName,this.img=e.img,this.text=e.datasourceName}formatForLLM(e){return{type:this.type,codeElementIds:e,data:{name:this.datasourceName,uid:this.datasourceUid,type:this.datasourceType,text:this.text,img:this.img}}}}class C extends a{constructor(e){super({...e,id:`${e.datasourceUid}-${e.labelName}`,type:"label_name"}),this.datasourceUid=e.datasourceUid,this.datasourceType=e.datasourceType,this.datasourceName=e.datasourceName,this.labelName=e.labelName,this.text=e.labelName,this.img=e.img}formatForLLM(e){return{type:this.type,codeElementIds:e,data:{name:this.labelName,datasourceUid:this.datasourceUid,datasourceType:this.datasourceType,datasourceName:this.datasourceName,labelName:this.labelName,img:this.img,text:this.text}}}}class A extends a{constructor(e){super({...e,id:`${e.datasourceUid}-${e.labelName}-${e.labelValue}`,type:"label_value"}),this.datasourceUid=e.datasourceUid,this.datasourceType=e.datasourceType,this.datasourceName=e.datasourceName,this.labelName=e.labelName,this.labelValue=e.labelValue,this.text=e.labelValue,this.img=e.img}formatForLLM(e){return{type:this.type,codeElementIds:e,data:{name:this.labelValue,datasourceUid:this.datasourceUid,datasourceType:this.datasourceType,datasourceName:this.datasourceName,labelName:this.labelName,labelValue:this.labelValue,text:this.text,img:this.img}}}}function $(e){var t,n,a,r,o;const i=(0,s.getDataSourceSrv)().getInstanceSettings(e);return{datasourceType:null!==(t=null==i?void 0:i.type)&&void 0!==t?t:"unknown",datasourceName:null!==(n=null==i?void 0:i.name)&&void 0!==n?n:e,img:null===(o=null===(r=null===(a=null==i?void 0:i.meta)||void 0===a?void 0:a.info)||void 0===r?void 0:r.logos)||void 0===o?void 0:o.small}}const S={datasource:"database",label_name:"database",label_value:"database",dashboard:"dashboard",dashboard_folder:"folder",unknown:"circle-mono",structured:"gf-grid",component:"gf-grid"};function N(e,t){var n,s,o;const i=function(e,t){switch(e){case"datasource":return new E({...t,...$(t.datasourceUid)});case"label_name":return new C({...t,...$(t.datasourceUid)});case"label_value":return new A({...t,...$(t.datasourceUid)});case"dashboard":return new x(t);case"dashboard_folder":return new k(t);case"structured":return new r(t);case"component":return new b({...t,hidden:!0});case"unknown":return new a(t);default:return console.error(`Unknown context type: ${e}`),new a(t)}}(e,t),c=null!==(n=t.title)&&void 0!==n?n:function(e){var t;return e instanceof r?e.formatForLLM().data.name:null!==(t=e.text)&&void 0!==t?t:"Given Context"}(i),u=null!==(s=t.img)&&void 0!==s?s:function(e){if("img"in e)return e.img}(i);return{node:{id:i.id,name:c,img:u,icon:null!==(o=t.icon)&&void 0!==o?o:S[e],navigable:!1,selectable:!0,data:i},occurrences:[]}}function L(e,t){const n=e=>e.map(((e,t)=>({node:{id:`question-${t}`,name:e.prompt,navigable:!1,selectable:!0,icon:"question-circle",data:{type:"question",prompt:e.prompt,context:e.context||[]}},occurrences:[]}))),a=h(e,n(t)),r=e=>{a(n(e))};return r.unregister=a.unregister,r}function T(e,t=[]){const n=e=>e.map(((e,t)=>({node:{id:`question-${t}`,name:e.prompt,navigable:!1,selectable:!0,icon:"question-circle",data:{type:"question",prompt:e.prompt,context:e.context||[]}},occurrences:[]}))),a=m(e,n(t));return e=>{a(n(e))}}function _(){const e=v({allowQuestions:!0,allowComponents:!1});return U(e)}const U=e=>e.filter((e=>{var t;return"question"===(null===(t=e.node.data)||void 0===t?void 0:t.type)})).map((e=>{var t,n;return{prompt:(null===(t=e.node.data)||void 0===t?void 0:t.prompt)||e.node.name,context:(null===(n=e.node.data)||void 0===n?void 0:n.context)||[]}})),I="grafana-assistant-app/callback/v0-alpha";function O(e,t){return{namespace:e,functions:t}}function P(e){return{title:"callback",targets:[I],fn:()=>e.map((e=>({namespace:e.namespace,functions:e.functions})))}}const R=require("rxjs");function j(){if(!s.getObservablePluginLinks)return(0,R.of)(!1);return(0,s.getObservablePluginLinks)({extensionPointId:"grafana/extension-sidebar/v0-alpha"}).pipe((0,R.map)((e=>e.some((e=>"grafana-assistant-app"===e.pluginId&&"Grafana Assistant"===e.title)))))}const M=require("@grafana/data");class q extends M.BusEventWithPayload{}q.type="open-extension-sidebar";class D extends M.BusEventBase{}function F(e){var t,n;(0,s.reportInteraction)("grafana_assistant_app_opened_sidebar",{from:e.origin,prompt:null!==(t=e.prompt)&&void 0!==t?t:""}),function(e,t,n){const a=new q({pluginId:"grafana-assistant-app",componentTitle:"Grafana Assistant",props:n});(0,s.getAppEvents)().publish(a)}(0,0,{initialPrompt:e.prompt,initialContext:e.context,initialAutoSend:null===(n=e.autoSend)||void 0===n||n})}function z(){!function(){const e=new D;(0,s.getAppEvents)().publish(e)}()}function G(){const[e,t]=(0,o.useState)(!1);return(0,o.useEffect)((()=>{const e=j().subscribe((e=>t(e)));return()=>{e.unsubscribe()}}),[]),[e,e?F:void 0,e?z:void 0]}D.type="close-extension-sidebar";const B=require("@grafana/ui");var V=function(){function e(e){var t=this;this._insertTag=function(e){var n;n=0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling,t.container.insertBefore(e,n),t.tags.push(e)},this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if(this.isSpeedy){var n=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(t);try{n.insertRule(e,n.cssRules.length)}catch(e){}}else t.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach((function(e){var t;return null==(t=e.parentNode)?void 0:t.removeChild(e)})),this.tags=[],this.ctr=0},e}(),Q=Math.abs,W=String.fromCharCode,H=Object.assign;function J(e){return e.trim()}function K(e,t,n){return e.replace(t,n)}function X(e,t){return e.indexOf(t)}function Z(e,t){return 0|e.charCodeAt(t)}function Y(e,t,n){return e.slice(t,n)}function ee(e){return e.length}function te(e){return e.length}function ne(e,t){return t.push(e),e}var ae=1,re=1,se=0,oe=0,ie=0,ce="";function ue(e,t,n,a,r,s,o){return{value:e,root:t,parent:n,type:a,props:r,children:s,line:ae,column:re,length:o,return:""}}function le(e,t){return H(ue("",null,null,"",null,null,0),e,{length:-e.length},t)}function de(){return ie=oe>0?Z(ce,--oe):0,re--,10===ie&&(re=1,ae--),ie}function fe(){return ie=oe<se?Z(ce,oe++):0,re++,10===ie&&(re=1,ae++),ie}function pe(){return Z(ce,oe)}function he(){return oe}function me(e,t){return Y(ce,e,t)}function ve(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function ge(e){return ae=re=1,se=ee(ce=e),oe=0,[]}function be(e){return ce="",e}function ye(e){return J(me(oe-1,ke(91===e?e+2:40===e?e+1:e)))}function we(e){for(;(ie=pe())&&ie<33;)fe();return ve(e)>2||ve(ie)>3?"":" "}function xe(e,t){for(;--t&&fe()&&!(ie<48||ie>102||ie>57&&ie<65||ie>70&&ie<97););return me(e,he()+(t<6&&32==pe()&&32==fe()))}function ke(e){for(;fe();)switch(ie){case e:return oe;case 34:case 39:34!==e&&39!==e&&ke(ie);break;case 40:41===e&&ke(e);break;case 92:fe()}return oe}function Ee(e,t){for(;fe()&&e+ie!==57&&(e+ie!==84||47!==pe()););return"/*"+me(t,oe-1)+"*"+W(47===e?e:fe())}function Ce(e){for(;!ve(pe());)fe();return me(e,oe)}var Ae="-ms-",$e="-moz-",Se="-webkit-",Ne="comm",Le="rule",Te="decl",_e="@keyframes";function Ue(e,t){for(var n="",a=te(e),r=0;r<a;r++)n+=t(e[r],r,e,t)||"";return n}function Ie(e,t,n,a){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case Te:return e.return=e.return||e.value;case Ne:return"";case _e:return e.return=e.value+"{"+Ue(e.children,a)+"}";case Le:e.value=e.props.join(",")}return ee(n=Ue(e.children,a))?e.return=e.value+"{"+n+"}":""}function Oe(e){return be(Pe("",null,null,null,[""],e=ge(e),0,[0],e))}function Pe(e,t,n,a,r,s,o,i,c){for(var u=0,l=0,d=o,f=0,p=0,h=0,m=1,v=1,g=1,b=0,y="",w=r,x=s,k=a,E=y;v;)switch(h=b,b=fe()){case 40:if(108!=h&&58==Z(E,d-1)){-1!=X(E+=K(ye(b),"&","&\f"),"&\f")&&(g=-1);break}case 34:case 39:case 91:E+=ye(b);break;case 9:case 10:case 13:case 32:E+=we(h);break;case 92:E+=xe(he()-1,7);continue;case 47:switch(pe()){case 42:case 47:ne(je(Ee(fe(),he()),t,n),c);break;default:E+="/"}break;case 123*m:i[u++]=ee(E)*g;case 125*m:case 59:case 0:switch(b){case 0:case 125:v=0;case 59+l:-1==g&&(E=K(E,/\f/g,"")),p>0&&ee(E)-d&&ne(p>32?Me(E+";",a,n,d-1):Me(K(E," ","")+";",a,n,d-2),c);break;case 59:E+=";";default:if(ne(k=Re(E,t,n,u,l,r,i,y,w=[],x=[],d),s),123===b)if(0===l)Pe(E,t,k,k,w,s,d,i,x);else switch(99===f&&110===Z(E,3)?100:f){case 100:case 108:case 109:case 115:Pe(e,k,k,a&&ne(Re(e,k,k,0,0,r,i,y,r,w=[],d),x),r,x,d,i,a?w:x);break;default:Pe(E,k,k,k,[""],x,0,i,x)}}u=l=p=0,m=g=1,y=E="",d=o;break;case 58:d=1+ee(E),p=h;default:if(m<1)if(123==b)--m;else if(125==b&&0==m++&&125==de())continue;switch(E+=W(b),b*m){case 38:g=l>0?1:(E+="\f",-1);break;case 44:i[u++]=(ee(E)-1)*g,g=1;break;case 64:45===pe()&&(E+=ye(fe())),f=pe(),l=d=ee(y=E+=Ce(he())),b++;break;case 45:45===h&&2==ee(E)&&(m=0)}}return s}function Re(e,t,n,a,r,s,o,i,c,u,l){for(var d=r-1,f=0===r?s:[""],p=te(f),h=0,m=0,v=0;h<a;++h)for(var g=0,b=Y(e,d+1,d=Q(m=o[h])),y=e;g<p;++g)(y=J(m>0?f[g]+" "+b:K(b,/&\f/g,f[g])))&&(c[v++]=y);return ue(e,t,n,0===r?Le:i,c,u,l)}function je(e,t,n){return ue(e,t,n,Ne,W(ie),Y(e,2,-2),0)}function Me(e,t,n,a){return ue(e,t,n,Te,Y(e,0,a),Y(e,a+1,-1),a)}var qe=function(e,t,n){for(var a=0,r=0;a=r,r=pe(),38===a&&12===r&&(t[n]=1),!ve(r);)fe();return me(e,oe)},De=new WeakMap,Fe=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,n=e.parent,a=e.column===n.column&&e.line===n.line;"rule"!==n.type;)if(!(n=n.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||De.get(n))&&!a){De.set(e,!0);for(var r=[],s=function(e,t){return be(function(e,t){var n=-1,a=44;do{switch(ve(a)){case 0:38===a&&12===pe()&&(t[n]=1),e[n]+=qe(oe-1,t,n);break;case 2:e[n]+=ye(a);break;case 4:if(44===a){e[++n]=58===pe()?"&\f":"",t[n]=e[n].length;break}default:e[n]+=W(a)}}while(a=fe());return e}(ge(e),t))}(t,r),o=n.props,i=0,c=0;i<s.length;i++)for(var u=0;u<o.length;u++,c++)e.props[c]=r[i]?s[i].replace(/&\f/g,o[u]):o[u]+" "+s[i]}}},ze=function(e){if("decl"===e.type){var t=e.value;108===t.charCodeAt(0)&&98===t.charCodeAt(2)&&(e.return="",e.value="")}};function Ge(e,t){switch(function(e,t){return 45^Z(e,0)?(((t<<2^Z(e,0))<<2^Z(e,1))<<2^Z(e,2))<<2^Z(e,3):0}(e,t)){case 5103:return Se+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Se+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Se+e+$e+e+Ae+e+e;case 6828:case 4268:return Se+e+Ae+e+e;case 6165:return Se+e+Ae+"flex-"+e+e;case 5187:return Se+e+K(e,/(\w+).+(:[^]+)/,Se+"box-$1$2"+Ae+"flex-$1$2")+e;case 5443:return Se+e+Ae+"flex-item-"+K(e,/flex-|-self/,"")+e;case 4675:return Se+e+Ae+"flex-line-pack"+K(e,/align-content|flex-|-self/,"")+e;case 5548:return Se+e+Ae+K(e,"shrink","negative")+e;case 5292:return Se+e+Ae+K(e,"basis","preferred-size")+e;case 6060:return Se+"box-"+K(e,"-grow","")+Se+e+Ae+K(e,"grow","positive")+e;case 4554:return Se+K(e,/([^-])(transform)/g,"$1"+Se+"$2")+e;case 6187:return K(K(K(e,/(zoom-|grab)/,Se+"$1"),/(image-set)/,Se+"$1"),e,"")+e;case 5495:case 3959:return K(e,/(image-set\([^]*)/,Se+"$1$`$1");case 4968:return K(K(e,/(.+:)(flex-)?(.*)/,Se+"box-pack:$3"+Ae+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Se+e+e;case 4095:case 3583:case 4068:case 2532:return K(e,/(.+)-inline(.+)/,Se+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(ee(e)-1-t>6)switch(Z(e,t+1)){case 109:if(45!==Z(e,t+4))break;case 102:return K(e,/(.+:)(.+)-([^]+)/,"$1"+Se+"$2-$3$1"+$e+(108==Z(e,t+3)?"$3":"$2-$3"))+e;case 115:return~X(e,"stretch")?Ge(K(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==Z(e,t+1))break;case 6444:switch(Z(e,ee(e)-3-(~X(e,"!important")&&10))){case 107:return K(e,":",":"+Se)+e;case 101:return K(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Se+(45===Z(e,14)?"inline-":"")+"box$3$1"+Se+"$2$3$1"+Ae+"$2box$3")+e}break;case 5936:switch(Z(e,t+11)){case 114:return Se+e+Ae+K(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Se+e+Ae+K(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Se+e+Ae+K(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return Se+e+Ae+e+e}return e}var Be=[function(e,t,n,a){if(e.length>-1&&!e.return)switch(e.type){case Te:e.return=Ge(e.value,e.length);break;case _e:return Ue([le(e,{value:K(e.value,"@","@"+Se)})],a);case Le:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e){return(e=/(::plac\w+|:read-\w+)/.exec(e))?e[0]:e}(t)){case":read-only":case":read-write":return Ue([le(e,{props:[K(t,/:(read-\w+)/,":-moz-$1")]})],a);case"::placeholder":return Ue([le(e,{props:[K(t,/:(plac\w+)/,":"+Se+"input-$1")]}),le(e,{props:[K(t,/:(plac\w+)/,":-moz-$1")]}),le(e,{props:[K(t,/:(plac\w+)/,Ae+"input-$1")]})],a)}return""}))}}],Ve={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function Qe(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var We=/[A-Z]|^ms/g,He=/_EMO_([^_]+?)_([^]*?)_EMO_/g,Je=function(e){return 45===e.charCodeAt(1)},Ke=function(e){return null!=e&&"boolean"!=typeof e},Xe=Qe((function(e){return Je(e)?e:e.replace(We,"-$&").toLowerCase()})),Ze=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(He,(function(e,t,n){return et={name:t,styles:n,next:et},t}))}return 1===Ve[e]||Je(e)||"number"!=typeof t||0===t?t:t+"px"};function Ye(e,t,n){if(null==n)return"";var a=n;if(void 0!==a.__emotion_styles)return a;switch(typeof n){case"boolean":return"";case"object":var r=n;if(1===r.anim)return et={name:r.name,styles:r.styles,next:et},r.name;var s=n;if(void 0!==s.styles){var o=s.next;if(void 0!==o)for(;void 0!==o;)et={name:o.name,styles:o.styles,next:et},o=o.next;return s.styles+";"}return function(e,t,n){var a="";if(Array.isArray(n))for(var r=0;r<n.length;r++)a+=Ye(e,t,n[r])+";";else for(var s in n){var o=n[s];if("object"!=typeof o){var i=o;null!=t&&void 0!==t[i]?a+=s+"{"+t[i]+"}":Ke(i)&&(a+=Xe(s)+":"+Ze(s,i)+";")}else if(!Array.isArray(o)||"string"!=typeof o[0]||null!=t&&void 0!==t[o[0]]){var c=Ye(e,t,o);switch(s){case"animation":case"animationName":a+=Xe(s)+":"+c+";";break;default:a+=s+"{"+c+"}"}}else for(var u=0;u<o.length;u++)Ke(o[u])&&(a+=Xe(s)+":"+Ze(s,o[u])+";")}return a}(e,t,n);case"function":if(void 0!==e){var i=et,c=n(e);return et=i,Ye(e,t,c)}}var u=n;if(null==t)return u;var l=t[u];return void 0!==l?l:u}var et,tt=/label:\s*([^\s;{]+)\s*(;|$)/g;function nt(e,t,n){if(1===e.length&&"object"==typeof e[0]&&null!==e[0]&&void 0!==e[0].styles)return e[0];var a=!0,r="";et=void 0;var s=e[0];null==s||void 0===s.raw?(a=!1,r+=Ye(n,t,s)):r+=s[0];for(var o=1;o<e.length;o++)r+=Ye(n,t,e[o]),a&&(r+=s[o]);tt.lastIndex=0;for(var i,c="";null!==(i=tt.exec(r));)c+="-"+i[1];var u=function(e){for(var t,n=0,a=0,r=e.length;r>=4;++a,r-=4)t=1540483477*(65535&(t=255&e.charCodeAt(a)|(255&e.charCodeAt(++a))<<8|(255&e.charCodeAt(++a))<<16|(255&e.charCodeAt(++a))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(r){case 3:n^=(255&e.charCodeAt(a+2))<<16;case 2:n^=(255&e.charCodeAt(a+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(a)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(r)+c;return{name:u,styles:r,next:et}}function at(e,t,n){var a="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):n&&(a+=n+" ")})),a}function rt(e,t){if(void 0===e.inserted[t.name])return e.insert("",t,e.sheet,!0)}function st(e,t,n){var a=[],r=at(e,a,n);return a.length<2?n:r+t(a)}var ot=function e(t){for(var n="",a=0;a<t.length;a++){var r=t[a];if(null!=r){var s=void 0;switch(typeof r){case"boolean":break;case"object":if(Array.isArray(r))s=e(r);else for(var o in s="",r)r[o]&&o&&(s&&(s+=" "),s+=o);break;default:s=r}s&&(n&&(n+=" "),n+=s)}}return n};var it=function(e){var t=function(e){var t=e.key;if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var a,r,s=e.stylisPlugins||Be,o={},i=[];a=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n<t.length;n++)o[t[n]]=!0;i.push(e)}));var c,u,l,d,f=[Ie,(d=function(e){c.insert(e)},function(e){e.root||(e=e.return)&&d(e)})],p=(u=[Fe,ze].concat(s,f),l=te(u),function(e,t,n,a){for(var r="",s=0;s<l;s++)r+=u[s](e,t,n,a)||"";return r});r=function(e,t,n,a){c=n,Ue(Oe(e?e+"{"+t.styles+"}":t.styles),p),a&&(h.inserted[t.name]=!0)};var h={key:t,sheet:new V({key:t,container:a,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend,insertionPoint:e.insertionPoint}),nonce:e.nonce,inserted:o,registered:{},insert:r};return h.sheet.hydrate(i),h}(e);t.sheet.speedy=function(e){this.isSpeedy=e},t.compat=!0;var n=function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];var r=nt(n,t.registered,void 0);return function(e,t){!function(e,t){var n=e.key+"-"+t.name;void 0===e.registered[n]&&(e.registered[n]=t.styles)}(e,t);var n=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var a=t;do{e.insert(t===a?"."+n:"",a,e.sheet,!0),a=a.next}while(void 0!==a)}}(t,r),t.key+"-"+r.name};return{css:n,cx:function(){for(var e=arguments.length,a=new Array(e),r=0;r<e;r++)a[r]=arguments[r];return st(t.registered,n,ot(a))},injectGlobal:function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];var r=nt(n,t.registered);rt(t,r)},keyframes:function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];var r=nt(n,t.registered),s="animation-"+r.name;return rt(t,{name:r.name,styles:"@keyframes "+s+"{"+r.styles+"}"}),s},hydrate:function(e){e.forEach((function(e){t.inserted[e]=!0}))},flush:function(){t.registered={},t.inserted={},t.sheet.flush()},sheet:t.sheet,cache:t,getRegisteredStyles:at.bind(null,t.registered),merge:st.bind(null,t.registered,n)}}({key:"css"}),ct=(it.flush,it.hydrate,it.cx,it.merge,it.getRegisteredStyles,it.injectGlobal,it.keyframes,it.css);function ut(e){const[t,n]=G();return t&&n?i().createElement(lt,{...e,openAssistant:n}):null}function lt({prompt:e,origin:t,context:n,autoSend:a=!0,title:r="Analyze with Assistant",size:c="sm",iconOnlyButton:u=!1,openAssistant:l}){const d=(0,B.useStyles2)(dt);return(0,o.useEffect)((()=>{(0,s.reportInteraction)("grafana_assistant_app_open_sidebar_button_displayed",{from:t})}),[t]),i().createElement(i().Fragment,null,u?i().createElement(B.IconButton,{name:"ai-sparkle",onClick:()=>l({prompt:e,context:n,autoSend:a,origin:t}),variant:"secondary",size:c,"aria-label":r,className:d.icon,tooltip:r,"data-testid":"assistant-icon-button"}):i().createElement(B.Button,{icon:"ai-sparkle",onClick:()=>l({prompt:e,context:n,autoSend:a,origin:t}),variant:"secondary",fill:"solid",size:c,title:r,"aria-label":r,className:d.button,"data-testid":"assistant-button"},r))}it.sheet,it.cache;const dt=e=>({button:ct({label:"assistant-button",border:"1px solid transparent",borderImage:"linear-gradient(90deg, rgb(168, 85, 247), rgb(249, 115, 22)) 1"}),icon:ct({label:"assistant-icon",border:"1px solid transparent",backgroundClip:"padding-box",padding:e.spacing(.5),"&:hover":{borderImage:"linear-gradient(90deg, rgb(168, 85, 247), rgb(249, 115, 22)) 1 !important",border:"1px solid transparent",backgroundClip:"padding-box"}})});module.exports=t})();
package/dist/sidebar.d.ts CHANGED
@@ -9,7 +9,7 @@ export type OpenAssistantProps = {
9
9
  * Open the Grafana Assistant sidebar with a given initial prompt.
10
10
  *
11
11
  * @param props - The props to pass to the assistant.
12
- * @param props.origin - The origin of the request that opened the assistant. This is used to track the source of the request. Should be a static string that helps identify the source of the request.
12
+ * @param props.origin - The origin of the request that opened the assistant. This is used to track the source of the request. Should be a structured string using forward slashes, with the first part as a namespace. Examples: 'grafana-datasources/prometheus/query-builder', 'grafana-slo-app/slo-editor-overview', 'grafana/trace-view-analyzer`.
13
13
  * @param props.prompt - The initial prompt to display in the assistant.
14
14
  * @param props.context - The initial context to display in the assistant. Created with `createContext`.
15
15
  * @param props.autoSend - Whether to automatically send the initial prompt. When true, opens a chat and sends the initial prompt right away. When false, opens chat and updates user message without sending it. Defaults to true.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/assistant",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "Type definitions and helper functions for Grafana Assistant",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,7 +11,10 @@
11
11
  "prebuild": "rm -rf dist",
12
12
  "build": "webpack --config webpack.config.cjs --mode production && tsc --emitDeclarationOnly",
13
13
  "dev": "webpack --config webpack.config.cjs --mode development",
14
- "clean": "rm -rf dist"
14
+ "clean": "rm -rf dist",
15
+ "test": "jest",
16
+ "test:watch": "jest --watch --onlyChanged",
17
+ "test:ci": "jest --passWithNoTests --maxWorkers 4"
15
18
  },
16
19
  "keywords": [
17
20
  "grafana",
@@ -22,6 +25,13 @@
22
25
  "author": "Grafana Labs",
23
26
  "license": "Apache-2.0",
24
27
  "devDependencies": {
28
+ "@storybook/react": "^8.6.14",
29
+ "@testing-library/jest-dom": "6.1.4",
30
+ "@testing-library/react": "14.0.0",
31
+ "@types/jest": "^29.5.0",
32
+ "@types/testing-library__jest-dom": "5.14.8",
33
+ "jest": "^29.5.0",
34
+ "jest-environment-jsdom": "^29.5.0",
25
35
  "react": "18.3.1",
26
36
  "rxjs": "7.8.2",
27
37
  "ts-loader": "^9.0.0",