@grafana/assistant 0.0.20 → 0.1.0
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 +6 -5
- package/dist/components/OpenAssistantButton.stories.d.ts +1 -0
- package/dist/context/page.d.ts +10 -1
- package/dist/context/questions.d.ts +2 -1
- package/dist/hook.d.ts +8 -4
- package/dist/index.js +1 -1
- package/dist/plugin.d.ts +2 -0
- package/dist/sidebar.d.ts +1 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -29,9 +29,9 @@ isAssistantAvailable().subscribe((available) => {
|
|
|
29
29
|
import { useAssistant } from '@grafana/assistant';
|
|
30
30
|
|
|
31
31
|
function MyComponent() {
|
|
32
|
-
const
|
|
32
|
+
const { isAvailable, openAssistant, closeAssistant } = useAssistant();
|
|
33
33
|
|
|
34
|
-
if (!isAvailable) {
|
|
34
|
+
if (!isAvailable || !openAssistant) {
|
|
35
35
|
return <div>Assistant not available</div>;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -506,14 +506,15 @@ function MyDashboard() {
|
|
|
506
506
|
|
|
507
507
|
### React Hooks
|
|
508
508
|
|
|
509
|
-
#### `useAssistant():
|
|
509
|
+
#### `useAssistant(): AssistantHook`
|
|
510
510
|
|
|
511
511
|
A React hook that provides assistant availability status and control functions.
|
|
512
512
|
|
|
513
|
-
**Returns:**
|
|
514
|
-
- `isAvailable: boolean` - Whether the
|
|
513
|
+
**Returns:** An object with the following properties:
|
|
514
|
+
- `isAvailable: boolean` - Whether the Assistant is available
|
|
515
515
|
- `openAssistant?: (props: OpenAssistantProps) => void` - Function to open the assistant (undefined if not available)
|
|
516
516
|
- `closeAssistant?: () => void` - Function to close the assistant (undefined if not available)
|
|
517
|
+
- `toggleAssistant?: (props: OpenAssistantProps) => void` - Function to toggle the assistant (undefined if not available)
|
|
517
518
|
|
|
518
519
|
#### `usePageContext(): ChatContextItem[]`
|
|
519
520
|
|
package/dist/context/page.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ export interface PageContextRegistration {
|
|
|
8
8
|
* Registers context items for specific pages based on URL patterns.
|
|
9
9
|
* Returns a setter function to update the context dynamically, similar to useState.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Multiple registrations with the same URL pattern are allowed and will all be merged
|
|
12
|
+
* when the pattern matches. Each call creates a new independent registration.
|
|
12
13
|
*
|
|
13
14
|
* @param urlPattern - URL pattern (string or RegExp) to match against page URLs
|
|
14
15
|
* @param initialContext - Initial array of ChatContextItem to provide when the pattern matches
|
|
@@ -30,3 +31,11 @@ export declare function usePageContext(options?: {
|
|
|
30
31
|
allowQuestions: boolean;
|
|
31
32
|
allowComponents: boolean;
|
|
32
33
|
}): ChatContextItem[];
|
|
34
|
+
export declare function generateRegistrationId(prefix?: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Test utility function to clear all registrations from the registry.
|
|
37
|
+
* This should only be used in tests to ensure a clean slate between test runs.
|
|
38
|
+
*
|
|
39
|
+
* @internal This is for testing purposes only
|
|
40
|
+
*/
|
|
41
|
+
export declare function __clearPageContextRegistryForTesting(): void;
|
|
@@ -12,7 +12,8 @@ export interface QuestionRegistration {
|
|
|
12
12
|
* Registers questions for specific pages based on URL patterns.
|
|
13
13
|
* Returns a setter function to update the questions dynamically, similar to useState.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* Multiple registrations with the same URL pattern are allowed and will all be merged
|
|
16
|
+
* when the pattern matches. Each call creates a new independent registration.
|
|
16
17
|
*
|
|
17
18
|
* @param urlPattern - URL pattern (string or RegExp) to match against page URLs
|
|
18
19
|
* @param initialQuestions - Initial array of questions to provide when the pattern matches
|
package/dist/hook.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { OpenAssistantProps } from './sidebar';
|
|
2
|
-
type AssistantHook =
|
|
2
|
+
export type AssistantHook = {
|
|
3
|
+
isAvailable: boolean;
|
|
4
|
+
openAssistant: ((props: OpenAssistantProps) => void) | undefined;
|
|
5
|
+
closeAssistant: (() => void) | undefined;
|
|
6
|
+
toggleAssistant: ((props: OpenAssistantProps) => void) | undefined;
|
|
7
|
+
};
|
|
3
8
|
/**
|
|
4
|
-
* Hook to check if the assistant is available and return the open and
|
|
5
|
-
* @returns
|
|
9
|
+
* Hook to check if the assistant is available and return the open, close, and toggle functions.
|
|
10
|
+
* @returns {AssistantHook}
|
|
6
11
|
*/
|
|
7
12
|
export declare function useAssistant(): AssistantHook;
|
|
8
|
-
export {};
|
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 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:()=>O,ComponentNodeData:()=>b,DashboardNodeData:()=>w,DatasourceNodeData:()=>E,EntityNodeData:()=>C,FolderNodeData:()=>k,LabelNameNodeData:()=>$,LabelValueNodeData:()=>A,OpenAssistantButton:()=>dt,StructuredNodeData:()=>r,closeAssistant:()=>B,createAssistantContextItem:()=>L,getExposeAssistantFunctionsConfig:()=>j,isAssistantAvailable:()=>R,newFunctionNamespace:()=>P,openAssistant:()=>z,provideComponents:()=>x,providePageContext:()=>h,provideQuestions:()=>T,useAssistant:()=>G,usePageComponents:()=>y,usePageContext:()=>v,useProvidePageContext:()=>m,useProvideQuestions:()=>_,useQuestions:()=>U});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",d="grafana-assistant:page-context-update",l="grafana-assistant:page-context-remove",p="grafana-assistant:location-changed";let f=!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(d,{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(d,{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(l,{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(p,{detail:{pathname:e}}))}(n),e())}));return e(),window.addEventListener(u,t),window.addEventListener(d,t),window.addEventListener(l,t),window.addEventListener(p,s),()=>{o.unsubscribe(),window.removeEventListener(u,t),window.removeEventListener(d,t),window.removeEventListener(l,t),window.removeEventListener(p,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}f||(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(d,(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(l,(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)}})),f=!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 x(e,t,n,a=/.*/){return h(a,[L("component",{components:n,prompt:e,namespace:t})])}class w 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){var t,n,a;super({id:`${e.type}-${e.name}-${[null===(t=e.scope)||void 0===t?void 0:t.env,null===(n=e.scope)||void 0===n?void 0:n.site,null===(a=e.scope)||void 0===a?void 0:a.namespace].filter(Boolean).join("-")}`,type:"entity",title:e.title,hidden:e.hidden,img:e.img,icon:e.icon,text:e.name}),this.entityType=e.type,this.name=e.name,this.scope=e.scope,this.properties=e.properties,this.text=e.name}formatForLLM(e){return{type:"entity",codeElementIds:e,data:{name:this.name,text:this.text,type:this.entityType,scope:this.scope,properties:this.properties}}}}class $ 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 S(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 N={datasource:"database",label_name:"database",label_value:"database",dashboard:"dashboard",dashboard_folder:"folder",unknown:"circle-mono",structured:"gf-grid",component:"gf-grid",entity:"asserts"};function L(e,t){var n,s,o;const i=function(e,t){switch(e){case"datasource":return new E({...t,...S(t.datasourceUid)});case"label_name":return new $({...t,...S(t.datasourceUid)});case"label_value":return new A({...t,...S(t.datasourceUid)});case"dashboard":return new w(t);case"dashboard_folder":return new k(t);case"structured":return new r(t);case"component":return new b({...t,hidden:!0});case"entity":return new C(t);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:N[e],navigable:!1,selectable:!0,data:i},occurrences:[]}}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=h(e,n(t)),r=e=>{a(n(e))};return r.unregister=a.unregister,r}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:[]}))),a=m(e,n(t));return e=>{a(n(e))}}function U(){const e=v({allowQuestions:!0,allowComponents:!1});return I(e)}const I=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)||[]}})),O="grafana-assistant-app/callback/v0-alpha";function P(e,t){return{namespace:e,functions:t}}function j(e){return{title:"callback",targets:[O],fn:()=>e.map((e=>({namespace:e.namespace,functions:e.functions})))}}const M=require("rxjs");function R(){if(!s.getObservablePluginLinks)return(0,M.of)(!1);return(0,s.getObservablePluginLinks)({extensionPointId:"grafana/extension-sidebar/v0-alpha"}).pipe((0,M.map)((e=>e.some((e=>"grafana-assistant-app"===e.pluginId&&"Grafana Assistant"===e.title)))))}const q=require("@grafana/data");class D extends q.BusEventWithPayload{}D.type="open-extension-sidebar";class F extends q.BusEventBase{}function z(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 D({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 B(){!function(){const e=new F;(0,s.getAppEvents)().publish(e)}()}function G(){const[e,t]=(0,o.useState)(!1);return(0,o.useEffect)((()=>{const e=R().subscribe((e=>t(e)));return()=>{e.unsubscribe()}}),[]),[e,e?z:void 0,e?B:void 0]}F.type="close-extension-sidebar";const V=require("@grafana/ui");var Q=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}(),W=Math.abs,H=String.fromCharCode,J=Object.assign;function K(e){return e.trim()}function X(e,t,n){return e.replace(t,n)}function Z(e,t){return e.indexOf(t)}function Y(e,t){return 0|e.charCodeAt(t)}function ee(e,t,n){return e.slice(t,n)}function te(e){return e.length}function ne(e){return e.length}function ae(e,t){return t.push(e),e}var re=1,se=1,oe=0,ie=0,ce=0,ue="";function de(e,t,n,a,r,s,o){return{value:e,root:t,parent:n,type:a,props:r,children:s,line:re,column:se,length:o,return:""}}function le(e,t){return J(de("",null,null,"",null,null,0),e,{length:-e.length},t)}function pe(){return ce=ie>0?Y(ue,--ie):0,se--,10===ce&&(se=1,re--),ce}function fe(){return ce=ie<oe?Y(ue,ie++):0,se++,10===ce&&(se=1,re++),ce}function he(){return Y(ue,ie)}function me(){return ie}function ve(e,t){return ee(ue,e,t)}function ge(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 be(e){return re=se=1,oe=te(ue=e),ie=0,[]}function ye(e){return ue="",e}function xe(e){return K(ve(ie-1,Ee(91===e?e+2:40===e?e+1:e)))}function we(e){for(;(ce=he())&&ce<33;)fe();return ge(e)>2||ge(ce)>3?"":" "}function ke(e,t){for(;--t&&fe()&&!(ce<48||ce>102||ce>57&&ce<65||ce>70&&ce<97););return ve(e,me()+(t<6&&32==he()&&32==fe()))}function Ee(e){for(;fe();)switch(ce){case e:return ie;case 34:case 39:34!==e&&39!==e&&Ee(ce);break;case 40:41===e&&Ee(e);break;case 92:fe()}return ie}function Ce(e,t){for(;fe()&&e+ce!==57&&(e+ce!==84||47!==he()););return"/*"+ve(t,ie-1)+"*"+H(47===e?e:fe())}function $e(e){for(;!ge(he());)fe();return ve(e,ie)}var Ae="-ms-",Se="-moz-",Ne="-webkit-",Le="comm",Te="rule",_e="decl",Ue="@keyframes";function Ie(e,t){for(var n="",a=ne(e),r=0;r<a;r++)n+=t(e[r],r,e,t)||"";return n}function Oe(e,t,n,a){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case _e:return e.return=e.return||e.value;case Le:return"";case Ue:return e.return=e.value+"{"+Ie(e.children,a)+"}";case Te:e.value=e.props.join(",")}return te(n=Ie(e.children,a))?e.return=e.value+"{"+n+"}":""}function Pe(e){return ye(je("",null,null,null,[""],e=be(e),0,[0],e))}function je(e,t,n,a,r,s,o,i,c){for(var u=0,d=0,l=o,p=0,f=0,h=0,m=1,v=1,g=1,b=0,y="",x=r,w=s,k=a,E=y;v;)switch(h=b,b=fe()){case 40:if(108!=h&&58==Y(E,l-1)){-1!=Z(E+=X(xe(b),"&","&\f"),"&\f")&&(g=-1);break}case 34:case 39:case 91:E+=xe(b);break;case 9:case 10:case 13:case 32:E+=we(h);break;case 92:E+=ke(me()-1,7);continue;case 47:switch(he()){case 42:case 47:ae(Re(Ce(fe(),me()),t,n),c);break;default:E+="/"}break;case 123*m:i[u++]=te(E)*g;case 125*m:case 59:case 0:switch(b){case 0:case 125:v=0;case 59+d:-1==g&&(E=X(E,/\f/g,"")),f>0&&te(E)-l&&ae(f>32?qe(E+";",a,n,l-1):qe(X(E," ","")+";",a,n,l-2),c);break;case 59:E+=";";default:if(ae(k=Me(E,t,n,u,d,r,i,y,x=[],w=[],l),s),123===b)if(0===d)je(E,t,k,k,x,s,l,i,w);else switch(99===p&&110===Y(E,3)?100:p){case 100:case 108:case 109:case 115:je(e,k,k,a&&ae(Me(e,k,k,0,0,r,i,y,r,x=[],l),w),r,w,l,i,a?x:w);break;default:je(E,k,k,k,[""],w,0,i,w)}}u=d=f=0,m=g=1,y=E="",l=o;break;case 58:l=1+te(E),f=h;default:if(m<1)if(123==b)--m;else if(125==b&&0==m++&&125==pe())continue;switch(E+=H(b),b*m){case 38:g=d>0?1:(E+="\f",-1);break;case 44:i[u++]=(te(E)-1)*g,g=1;break;case 64:45===he()&&(E+=xe(fe())),p=he(),d=l=te(y=E+=$e(me())),b++;break;case 45:45===h&&2==te(E)&&(m=0)}}return s}function Me(e,t,n,a,r,s,o,i,c,u,d){for(var l=r-1,p=0===r?s:[""],f=ne(p),h=0,m=0,v=0;h<a;++h)for(var g=0,b=ee(e,l+1,l=W(m=o[h])),y=e;g<f;++g)(y=K(m>0?p[g]+" "+b:X(b,/&\f/g,p[g])))&&(c[v++]=y);return de(e,t,n,0===r?Te:i,c,u,d)}function Re(e,t,n){return de(e,t,n,Le,H(ce),ee(e,2,-2),0)}function qe(e,t,n,a){return de(e,t,n,_e,ee(e,0,a),ee(e,a+1,-1),a)}var De=function(e,t,n){for(var a=0,r=0;a=r,r=he(),38===a&&12===r&&(t[n]=1),!ge(r);)fe();return ve(e,ie)},Fe=new WeakMap,ze=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)||Fe.get(n))&&!a){Fe.set(e,!0);for(var r=[],s=function(e,t){return ye(function(e,t){var n=-1,a=44;do{switch(ge(a)){case 0:38===a&&12===he()&&(t[n]=1),e[n]+=De(ie-1,t,n);break;case 2:e[n]+=xe(a);break;case 4:if(44===a){e[++n]=58===he()?"&\f":"",t[n]=e[n].length;break}default:e[n]+=H(a)}}while(a=fe());return e}(be(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]}}},Be=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^Y(e,0)?(((t<<2^Y(e,0))<<2^Y(e,1))<<2^Y(e,2))<<2^Y(e,3):0}(e,t)){case 5103:return Ne+"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 Ne+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Ne+e+Se+e+Ae+e+e;case 6828:case 4268:return Ne+e+Ae+e+e;case 6165:return Ne+e+Ae+"flex-"+e+e;case 5187:return Ne+e+X(e,/(\w+).+(:[^]+)/,Ne+"box-$1$2"+Ae+"flex-$1$2")+e;case 5443:return Ne+e+Ae+"flex-item-"+X(e,/flex-|-self/,"")+e;case 4675:return Ne+e+Ae+"flex-line-pack"+X(e,/align-content|flex-|-self/,"")+e;case 5548:return Ne+e+Ae+X(e,"shrink","negative")+e;case 5292:return Ne+e+Ae+X(e,"basis","preferred-size")+e;case 6060:return Ne+"box-"+X(e,"-grow","")+Ne+e+Ae+X(e,"grow","positive")+e;case 4554:return Ne+X(e,/([^-])(transform)/g,"$1"+Ne+"$2")+e;case 6187:return X(X(X(e,/(zoom-|grab)/,Ne+"$1"),/(image-set)/,Ne+"$1"),e,"")+e;case 5495:case 3959:return X(e,/(image-set\([^]*)/,Ne+"$1$`$1");case 4968:return X(X(e,/(.+:)(flex-)?(.*)/,Ne+"box-pack:$3"+Ae+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Ne+e+e;case 4095:case 3583:case 4068:case 2532:return X(e,/(.+)-inline(.+)/,Ne+"$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(te(e)-1-t>6)switch(Y(e,t+1)){case 109:if(45!==Y(e,t+4))break;case 102:return X(e,/(.+:)(.+)-([^]+)/,"$1"+Ne+"$2-$3$1"+Se+(108==Y(e,t+3)?"$3":"$2-$3"))+e;case 115:return~Z(e,"stretch")?Ge(X(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==Y(e,t+1))break;case 6444:switch(Y(e,te(e)-3-(~Z(e,"!important")&&10))){case 107:return X(e,":",":"+Ne)+e;case 101:return X(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Ne+(45===Y(e,14)?"inline-":"")+"box$3$1"+Ne+"$2$3$1"+Ae+"$2box$3")+e}break;case 5936:switch(Y(e,t+11)){case 114:return Ne+e+Ae+X(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ne+e+Ae+X(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ne+e+Ae+X(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return Ne+e+Ae+e+e}return e}var Ve=[function(e,t,n,a){if(e.length>-1&&!e.return)switch(e.type){case _e:e.return=Ge(e.value,e.length);break;case Ue:return Ie([le(e,{value:X(e.value,"@","@"+Ne)})],a);case Te: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 Ie([le(e,{props:[X(t,/:(read-\w+)/,":-moz-$1")]})],a);case"::placeholder":return Ie([le(e,{props:[X(t,/:(plac\w+)/,":"+Ne+"input-$1")]}),le(e,{props:[X(t,/:(plac\w+)/,":-moz-$1")]}),le(e,{props:[X(t,/:(plac\w+)/,Ae+"input-$1")]})],a)}return""}))}}],Qe={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 We(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var He=/[A-Z]|^ms/g,Je=/_EMO_([^_]+?)_([^]*?)_EMO_/g,Ke=function(e){return 45===e.charCodeAt(1)},Xe=function(e){return null!=e&&"boolean"!=typeof e},Ze=We((function(e){return Ke(e)?e:e.replace(He,"-$&").toLowerCase()})),Ye=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(Je,(function(e,t,n){return tt={name:t,styles:n,next:tt},t}))}return 1===Qe[e]||Ke(e)||"number"!=typeof t||0===t?t:t+"px"};function et(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 tt={name:r.name,styles:r.styles,next:tt},r.name;var s=n;if(void 0!==s.styles){var o=s.next;if(void 0!==o)for(;void 0!==o;)tt={name:o.name,styles:o.styles,next:tt},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+=et(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]+"}":Xe(i)&&(a+=Ze(s)+":"+Ye(s,i)+";")}else if(!Array.isArray(o)||"string"!=typeof o[0]||null!=t&&void 0!==t[o[0]]){var c=et(e,t,o);switch(s){case"animation":case"animationName":a+=Ze(s)+":"+c+";";break;default:a+=s+"{"+c+"}"}}else for(var u=0;u<o.length;u++)Xe(o[u])&&(a+=Ze(s)+":"+Ye(s,o[u])+";")}return a}(e,t,n);case"function":if(void 0!==e){var i=tt,c=n(e);return tt=i,et(e,t,c)}}var u=n;if(null==t)return u;var d=t[u];return void 0!==d?d:u}var tt,nt=/label:\s*([^\s;{]+)\s*(;|$)/g;function at(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="";tt=void 0;var s=e[0];null==s||void 0===s.raw?(a=!1,r+=et(n,t,s)):r+=s[0];for(var o=1;o<e.length;o++)r+=et(n,t,e[o]),a&&(r+=s[o]);nt.lastIndex=0;for(var i,c="";null!==(i=nt.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:tt}}function rt(e,t,n){var a="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):n&&(a+=n+" ")})),a}function st(e,t){if(void 0===e.inserted[t.name])return e.insert("",t,e.sheet,!0)}function ot(e,t,n){var a=[],r=rt(e,a,n);return a.length<2?n:r+t(a)}var it=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 ct=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||Ve,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,d,l,p=[Oe,(l=function(e){c.insert(e)},function(e){e.root||(e=e.return)&&l(e)})],f=(u=[ze,Be].concat(s,p),d=ne(u),function(e,t,n,a){for(var r="",s=0;s<d;s++)r+=u[s](e,t,n,a)||"";return r});r=function(e,t,n,a){c=n,Ie(Pe(e?e+"{"+t.styles+"}":t.styles),f),a&&(h.inserted[t.name]=!0)};var h={key:t,sheet:new Q({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=at(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 ot(t.registered,n,it(a))},injectGlobal:function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];var r=at(n,t.registered);st(t,r)},keyframes:function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];var r=at(n,t.registered),s="animation-"+r.name;return st(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:rt.bind(null,t.registered),merge:ot.bind(null,t.registered,n)}}({key:"css"}),ut=(ct.flush,ct.hydrate,ct.cx,ct.merge,ct.getRegisteredStyles,ct.injectGlobal,ct.keyframes,ct.css);function dt(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:d}){const l=(0,V.useStyles2)(pt);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(V.IconButton,{name:"ai-sparkle",onClick:()=>d({prompt:e,context:n,autoSend:a,origin:t}),variant:"secondary",size:c,"aria-label":r,className:l.icon,tooltip:r,"data-testid":"assistant-icon-button"}):i().createElement(V.Button,{icon:"ai-sparkle",onClick:()=>d({prompt:e,context:n,autoSend:a,origin:t}),variant:"secondary",fill:"solid",size:c,title:r,"aria-label":r,className:l.button,"data-testid":"assistant-button"},r))}ct.sheet,ct.cache;const pt=e=>({button:ut({label:"assistant-button",border:"1px solid transparent",borderImage:"linear-gradient(90deg, rgb(168, 85, 247), rgb(249, 115, 22)) 1"}),icon:ut({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,{ASSISTANT_PLUGIN_ID:()=>q,ASSISTANT_PLUGIN_TITLE:()=>D,CALLBACK_EXTENSION_POINT:()=>P,ComponentNodeData:()=>y,DashboardNodeData:()=>k,DatasourceNodeData:()=>$,EntityNodeData:()=>A,FolderNodeData:()=>E,LabelNameNodeData:()=>S,LabelValueNodeData:()=>C,OpenAssistantButton:()=>mt,StructuredNodeData:()=>r,closeAssistant:()=>W,createAssistantContextItem:()=>L,getExposeAssistantFunctionsConfig:()=>j,isAssistantAvailable:()=>F,newFunctionNamespace:()=>M,openAssistant:()=>Q,provideComponents:()=>w,providePageContext:()=>h,provideQuestions:()=>_,toggleAssistant:()=>H,useAssistant:()=>J,usePageComponents:()=>x,usePageContext:()=>v,useProvidePageContext:()=>m,useProvideQuestions:()=>I,useQuestions:()=>U});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",p="grafana-assistant:location-changed";let f=!1;function h(e,t){const n={id:g(),urlPattern:e,context:[...t]};c.push(n),window.dispatchEvent(new CustomEvent(l,{detail:n})),window.dispatchEvent(new CustomEvent(u,{detail:{registry:c}}));const a=e=>{const t=c.findIndex((e=>e.id===n.id));-1!==t&&(c[t].context=[...e],window.dispatchEvent(new CustomEvent(l,{detail:c[t]})))};return a.unregister=()=>{const e=c.findIndex((e=>e.id===n.id));-1!==e&&(c.splice(e,1),window.dispatchEvent(new CustomEvent(d,{detail:{id:n.id}})))},a}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)b(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(p,{detail:{pathname:e}}))}(n),e())}));return e(),window.addEventListener(u,t),window.addEventListener(l,t),window.addEventListener(d,t),window.addEventListener(p,s),()=>{o.unsubscribe(),window.removeEventListener(u,t),window.removeEventListener(l,t),window.removeEventListener(d,t),window.removeEventListener(p,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="page-context"){return`${e}-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function b(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}f||(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)}})),f=!0);class y 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 x(){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,[L("component",{components:n,prompt:e,namespace:t})])}class k 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 E 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 $ 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 A extends a{constructor(e){var t,n,a;super({id:`${e.type}-${e.name}-${[null===(t=e.scope)||void 0===t?void 0:t.env,null===(n=e.scope)||void 0===n?void 0:n.site,null===(a=e.scope)||void 0===a?void 0:a.namespace].filter(Boolean).join("-")}`,type:"entity",title:e.title,hidden:e.hidden,img:e.img,icon:e.icon,text:e.name}),this.entityType=e.type,this.name=e.name,this.scope=e.scope,this.properties=e.properties,this.text=e.name}formatForLLM(e){return{type:"entity",codeElementIds:e,data:{name:this.name,text:this.text,type:this.entityType,scope:this.scope,properties:this.properties}}}}class S 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 C 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 N(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 T={datasource:"database",label_name:"database",label_value:"database",dashboard:"dashboard",dashboard_folder:"folder",unknown:"circle-mono",structured:"gf-grid",component:"gf-grid",entity:"asserts"};function L(e,t){var n,s,o;const i=function(e,t){switch(e){case"datasource":return new $({...t,...N(t.datasourceUid)});case"label_name":return new S({...t,...N(t.datasourceUid)});case"label_value":return new C({...t,...N(t.datasourceUid)});case"dashboard":return new k(t);case"dashboard_folder":return new E(t);case"structured":return new r(t);case"component":return new y({...t,hidden:!0});case"entity":return new A(t);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:T[e],navigable:!1,selectable:!0,data:i},occurrences:[]}}function _(e,t){const n=g("question"),a=e=>e.map(((e,t)=>({node:{id:`question-${n}-${t}`,name:e.prompt,navigable:!1,selectable:!0,icon:"question-circle",data:{type:"question",prompt:e.prompt,context:e.context||[]}},occurrences:[]}))),r=h(e,a(t)),s=e=>{r(a(e))};return s.unregister=r.unregister,s}function I(e,t=[]){const n=(0,o.useMemo)((()=>g("question")),[]),a=e=>e.map(((e,t)=>({node:{id:`question-${n}-${t}`,name:e.prompt,navigable:!1,selectable:!0,icon:"question-circle",data:{type:"question",prompt:e.prompt,context:e.context||[]}},occurrences:[]}))),r=m(e,a(t));return e=>{r(a(e))}}function U(){const e=v({allowQuestions:!0,allowComponents:!1});return O(e)}const O=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)||[]}})),P="grafana-assistant-app/callback/v0-alpha";function M(e,t){return{namespace:e,functions:t}}function j(e){return{title:"callback",targets:[P],fn:()=>e.map((e=>({namespace:e.namespace,functions:e.functions})))}}const R=require("rxjs"),q="grafana-assistant-app",D="Grafana Assistant";function F(){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=>e.pluginId===q&&e.title===D)))))}const z=require("@grafana/data");class B extends z.BusEventWithPayload{}B.type="open-extension-sidebar";class G extends z.BusEventBase{}G.type="close-extension-sidebar";class V extends z.BusEventWithPayload{}function Q(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 B({pluginId:e,componentTitle:t,props:n});(0,s.getAppEvents)().publish(a)}(q,D,{initialPrompt:e.prompt,initialContext:e.context,initialAutoSend:null===(n=e.autoSend)||void 0===n||n,origin:e.origin})}function W(){!function(){const e=new G;(0,s.getAppEvents)().publish(e)}()}function H(e){var t,n;(0,s.reportInteraction)("grafana_assistant_app_toggled_sidebar",{from:e.origin,prompt:null!==(t=e.prompt)&&void 0!==t?t:""}),function(e,t,n){const a=new V({pluginId:e,componentTitle:t,props:n});(0,s.getAppEvents)().publish(a)}(q,D,{initialPrompt:e.prompt,initialContext:e.context,initialAutoSend:null===(n=e.autoSend)||void 0===n||n,origin:e.origin})}function J(){const[e,t]=(0,o.useState)(!1);return(0,o.useEffect)((()=>{const e=F().subscribe((e=>t(e)));return()=>{e.unsubscribe()}}),[]),{isAvailable:e,openAssistant:e?Q:void 0,closeAssistant:e?W:void 0,toggleAssistant:e?H:void 0}}V.type="toggle-extension-sidebar";const K=require("@grafana/ui");var X=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}(),Z=Math.abs,Y=String.fromCharCode,ee=Object.assign;function te(e){return e.trim()}function ne(e,t,n){return e.replace(t,n)}function ae(e,t){return e.indexOf(t)}function re(e,t){return 0|e.charCodeAt(t)}function se(e,t,n){return e.slice(t,n)}function oe(e){return e.length}function ie(e){return e.length}function ce(e,t){return t.push(e),e}var ue=1,le=1,de=0,pe=0,fe=0,he="";function me(e,t,n,a,r,s,o){return{value:e,root:t,parent:n,type:a,props:r,children:s,line:ue,column:le,length:o,return:""}}function ve(e,t){return ee(me("",null,null,"",null,null,0),e,{length:-e.length},t)}function ge(){return fe=pe>0?re(he,--pe):0,le--,10===fe&&(le=1,ue--),fe}function be(){return fe=pe<de?re(he,pe++):0,le++,10===fe&&(le=1,ue++),fe}function ye(){return re(he,pe)}function xe(){return pe}function we(e,t){return se(he,e,t)}function ke(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 Ee(e){return ue=le=1,de=oe(he=e),pe=0,[]}function $e(e){return he="",e}function Ae(e){return te(we(pe-1,Ne(91===e?e+2:40===e?e+1:e)))}function Se(e){for(;(fe=ye())&&fe<33;)be();return ke(e)>2||ke(fe)>3?"":" "}function Ce(e,t){for(;--t&&be()&&!(fe<48||fe>102||fe>57&&fe<65||fe>70&&fe<97););return we(e,xe()+(t<6&&32==ye()&&32==be()))}function Ne(e){for(;be();)switch(fe){case e:return pe;case 34:case 39:34!==e&&39!==e&&Ne(fe);break;case 40:41===e&&Ne(e);break;case 92:be()}return pe}function Te(e,t){for(;be()&&e+fe!==57&&(e+fe!==84||47!==ye()););return"/*"+we(t,pe-1)+"*"+Y(47===e?e:be())}function Le(e){for(;!ke(ye());)be();return we(e,pe)}var _e="-ms-",Ie="-moz-",Ue="-webkit-",Oe="comm",Pe="rule",Me="decl",je="@keyframes";function Re(e,t){for(var n="",a=ie(e),r=0;r<a;r++)n+=t(e[r],r,e,t)||"";return n}function qe(e,t,n,a){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case Me:return e.return=e.return||e.value;case Oe:return"";case je:return e.return=e.value+"{"+Re(e.children,a)+"}";case Pe:e.value=e.props.join(",")}return oe(n=Re(e.children,a))?e.return=e.value+"{"+n+"}":""}function De(e){return $e(Fe("",null,null,null,[""],e=Ee(e),0,[0],e))}function Fe(e,t,n,a,r,s,o,i,c){for(var u=0,l=0,d=o,p=0,f=0,h=0,m=1,v=1,g=1,b=0,y="",x=r,w=s,k=a,E=y;v;)switch(h=b,b=be()){case 40:if(108!=h&&58==re(E,d-1)){-1!=ae(E+=ne(Ae(b),"&","&\f"),"&\f")&&(g=-1);break}case 34:case 39:case 91:E+=Ae(b);break;case 9:case 10:case 13:case 32:E+=Se(h);break;case 92:E+=Ce(xe()-1,7);continue;case 47:switch(ye()){case 42:case 47:ce(Be(Te(be(),xe()),t,n),c);break;default:E+="/"}break;case 123*m:i[u++]=oe(E)*g;case 125*m:case 59:case 0:switch(b){case 0:case 125:v=0;case 59+l:-1==g&&(E=ne(E,/\f/g,"")),f>0&&oe(E)-d&&ce(f>32?Ge(E+";",a,n,d-1):Ge(ne(E," ","")+";",a,n,d-2),c);break;case 59:E+=";";default:if(ce(k=ze(E,t,n,u,l,r,i,y,x=[],w=[],d),s),123===b)if(0===l)Fe(E,t,k,k,x,s,d,i,w);else switch(99===p&&110===re(E,3)?100:p){case 100:case 108:case 109:case 115:Fe(e,k,k,a&&ce(ze(e,k,k,0,0,r,i,y,r,x=[],d),w),r,w,d,i,a?x:w);break;default:Fe(E,k,k,k,[""],w,0,i,w)}}u=l=f=0,m=g=1,y=E="",d=o;break;case 58:d=1+oe(E),f=h;default:if(m<1)if(123==b)--m;else if(125==b&&0==m++&&125==ge())continue;switch(E+=Y(b),b*m){case 38:g=l>0?1:(E+="\f",-1);break;case 44:i[u++]=(oe(E)-1)*g,g=1;break;case 64:45===ye()&&(E+=Ae(be())),p=ye(),l=d=oe(y=E+=Le(xe())),b++;break;case 45:45===h&&2==oe(E)&&(m=0)}}return s}function ze(e,t,n,a,r,s,o,i,c,u,l){for(var d=r-1,p=0===r?s:[""],f=ie(p),h=0,m=0,v=0;h<a;++h)for(var g=0,b=se(e,d+1,d=Z(m=o[h])),y=e;g<f;++g)(y=te(m>0?p[g]+" "+b:ne(b,/&\f/g,p[g])))&&(c[v++]=y);return me(e,t,n,0===r?Pe:i,c,u,l)}function Be(e,t,n){return me(e,t,n,Oe,Y(fe),se(e,2,-2),0)}function Ge(e,t,n,a){return me(e,t,n,Me,se(e,0,a),se(e,a+1,-1),a)}var Ve=function(e,t,n){for(var a=0,r=0;a=r,r=ye(),38===a&&12===r&&(t[n]=1),!ke(r);)be();return we(e,pe)},Qe=new WeakMap,We=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)||Qe.get(n))&&!a){Qe.set(e,!0);for(var r=[],s=function(e,t){return $e(function(e,t){var n=-1,a=44;do{switch(ke(a)){case 0:38===a&&12===ye()&&(t[n]=1),e[n]+=Ve(pe-1,t,n);break;case 2:e[n]+=Ae(a);break;case 4:if(44===a){e[++n]=58===ye()?"&\f":"",t[n]=e[n].length;break}default:e[n]+=Y(a)}}while(a=be());return e}(Ee(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]}}},He=function(e){if("decl"===e.type){var t=e.value;108===t.charCodeAt(0)&&98===t.charCodeAt(2)&&(e.return="",e.value="")}};function Je(e,t){switch(function(e,t){return 45^re(e,0)?(((t<<2^re(e,0))<<2^re(e,1))<<2^re(e,2))<<2^re(e,3):0}(e,t)){case 5103:return Ue+"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 Ue+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Ue+e+Ie+e+_e+e+e;case 6828:case 4268:return Ue+e+_e+e+e;case 6165:return Ue+e+_e+"flex-"+e+e;case 5187:return Ue+e+ne(e,/(\w+).+(:[^]+)/,Ue+"box-$1$2"+_e+"flex-$1$2")+e;case 5443:return Ue+e+_e+"flex-item-"+ne(e,/flex-|-self/,"")+e;case 4675:return Ue+e+_e+"flex-line-pack"+ne(e,/align-content|flex-|-self/,"")+e;case 5548:return Ue+e+_e+ne(e,"shrink","negative")+e;case 5292:return Ue+e+_e+ne(e,"basis","preferred-size")+e;case 6060:return Ue+"box-"+ne(e,"-grow","")+Ue+e+_e+ne(e,"grow","positive")+e;case 4554:return Ue+ne(e,/([^-])(transform)/g,"$1"+Ue+"$2")+e;case 6187:return ne(ne(ne(e,/(zoom-|grab)/,Ue+"$1"),/(image-set)/,Ue+"$1"),e,"")+e;case 5495:case 3959:return ne(e,/(image-set\([^]*)/,Ue+"$1$`$1");case 4968:return ne(ne(e,/(.+:)(flex-)?(.*)/,Ue+"box-pack:$3"+_e+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Ue+e+e;case 4095:case 3583:case 4068:case 2532:return ne(e,/(.+)-inline(.+)/,Ue+"$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(oe(e)-1-t>6)switch(re(e,t+1)){case 109:if(45!==re(e,t+4))break;case 102:return ne(e,/(.+:)(.+)-([^]+)/,"$1"+Ue+"$2-$3$1"+Ie+(108==re(e,t+3)?"$3":"$2-$3"))+e;case 115:return~ae(e,"stretch")?Je(ne(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==re(e,t+1))break;case 6444:switch(re(e,oe(e)-3-(~ae(e,"!important")&&10))){case 107:return ne(e,":",":"+Ue)+e;case 101:return ne(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+Ue+(45===re(e,14)?"inline-":"")+"box$3$1"+Ue+"$2$3$1"+_e+"$2box$3")+e}break;case 5936:switch(re(e,t+11)){case 114:return Ue+e+_e+ne(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ue+e+_e+ne(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ue+e+_e+ne(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return Ue+e+_e+e+e}return e}var Ke=[function(e,t,n,a){if(e.length>-1&&!e.return)switch(e.type){case Me:e.return=Je(e.value,e.length);break;case je:return Re([ve(e,{value:ne(e.value,"@","@"+Ue)})],a);case Pe: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 Re([ve(e,{props:[ne(t,/:(read-\w+)/,":-moz-$1")]})],a);case"::placeholder":return Re([ve(e,{props:[ne(t,/:(plac\w+)/,":"+Ue+"input-$1")]}),ve(e,{props:[ne(t,/:(plac\w+)/,":-moz-$1")]}),ve(e,{props:[ne(t,/:(plac\w+)/,_e+"input-$1")]})],a)}return""}))}}],Xe={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 Ze(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var Ye=/[A-Z]|^ms/g,et=/_EMO_([^_]+?)_([^]*?)_EMO_/g,tt=function(e){return 45===e.charCodeAt(1)},nt=function(e){return null!=e&&"boolean"!=typeof e},at=Ze((function(e){return tt(e)?e:e.replace(Ye,"-$&").toLowerCase()})),rt=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(et,(function(e,t,n){return ot={name:t,styles:n,next:ot},t}))}return 1===Xe[e]||tt(e)||"number"!=typeof t||0===t?t:t+"px"};function st(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 ot={name:r.name,styles:r.styles,next:ot},r.name;var s=n;if(void 0!==s.styles){var o=s.next;if(void 0!==o)for(;void 0!==o;)ot={name:o.name,styles:o.styles,next:ot},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+=st(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]+"}":nt(i)&&(a+=at(s)+":"+rt(s,i)+";")}else if(!Array.isArray(o)||"string"!=typeof o[0]||null!=t&&void 0!==t[o[0]]){var c=st(e,t,o);switch(s){case"animation":case"animationName":a+=at(s)+":"+c+";";break;default:a+=s+"{"+c+"}"}}else for(var u=0;u<o.length;u++)nt(o[u])&&(a+=at(s)+":"+rt(s,o[u])+";")}return a}(e,t,n);case"function":if(void 0!==e){var i=ot,c=n(e);return ot=i,st(e,t,c)}}var u=n;if(null==t)return u;var l=t[u];return void 0!==l?l:u}var ot,it=/label:\s*([^\s;{]+)\s*(;|$)/g;function ct(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="";ot=void 0;var s=e[0];null==s||void 0===s.raw?(a=!1,r+=st(n,t,s)):r+=s[0];for(var o=1;o<e.length;o++)r+=st(n,t,e[o]),a&&(r+=s[o]);it.lastIndex=0;for(var i,c="";null!==(i=it.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:ot}}function ut(e,t,n){var a="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):n&&(a+=n+" ")})),a}function lt(e,t){if(void 0===e.inserted[t.name])return e.insert("",t,e.sheet,!0)}function dt(e,t,n){var a=[],r=ut(e,a,n);return a.length<2?n:r+t(a)}var pt=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 ft=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||Ke,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,p=[qe,(d=function(e){c.insert(e)},function(e){e.root||(e=e.return)&&d(e)})],f=(u=[We,He].concat(s,p),l=ie(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,Re(De(e?e+"{"+t.styles+"}":t.styles),f),a&&(h.inserted[t.name]=!0)};var h={key:t,sheet:new X({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=ct(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 dt(t.registered,n,pt(a))},injectGlobal:function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];var r=ct(n,t.registered);lt(t,r)},keyframes:function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];var r=ct(n,t.registered),s="animation-"+r.name;return lt(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:ut.bind(null,t.registered),merge:dt.bind(null,t.registered,n)}}({key:"css"}),ht=(ft.flush,ft.hydrate,ft.cx,ft.merge,ft.getRegisteredStyles,ft.injectGlobal,ft.keyframes,ft.css);function mt(e){const{isAvailable:t,openAssistant:n}=J();return t&&n?i().createElement(vt,{...e,openAssistant:n}):null}function vt({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,K.useStyles2)(gt);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(K.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(K.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))}ft.sheet,ft.cache;const gt=e=>{const t=e.colors.secondary.main,n=e.colors.emphasize(t,.05),a=e.colors.background.canvas,r=e.shape.radius.default,s=`max(calc(${r} - 1px), 1px)`,o={content:'""',position:"absolute",inset:0,borderRadius:r,background:"linear-gradient(90deg, rgb(168, 85, 247), rgb(249, 115, 22))",zIndex:-2,pointerEvents:"none"},i=e=>({content:'""',position:"absolute",inset:"1px",borderRadius:s,background:`linear-gradient(${e}, ${e}), ${a}`,zIndex:-1,transition:"none",pointerEvents:"none"});return{button:ht({label:"assistant-button",position:"relative",isolation:"isolate",border:"none",transition:"none !important","&::before":o,"&::after":{...i(t),transition:"none"},"&:hover":{transition:"none !important"},"&:hover::after":{background:`linear-gradient(${n}, ${n}), ${a}`}}),icon:ht({label:"assistant-icon",position:"relative",isolation:"isolate",border:"none",background:"none",padding:e.spacing(.5),"&::before":{...o,transition:"background 0.1s ease"},"&:hover::after":{...i(t),background:`linear-gradient(${n}, ${n}), ${a}`}})}};module.exports=t})();
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
+
export declare const ASSISTANT_PLUGIN_ID = "grafana-assistant-app";
|
|
3
|
+
export declare const ASSISTANT_PLUGIN_TITLE = "Grafana Assistant";
|
|
2
4
|
/**
|
|
3
5
|
* Check if the assistant is available.
|
|
4
6
|
* @returns An observable that emits true if the assistant is available, false otherwise.
|
package/dist/sidebar.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/assistant",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Type definitions and helper functions for Grafana Assistant",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/grafana/grafana-assistant-app.git",
|
|
8
|
+
"directory": "packages/@grafana/assistant"
|
|
9
|
+
},
|
|
5
10
|
"main": "dist/index.js",
|
|
6
11
|
"types": "dist/index.d.ts",
|
|
7
12
|
"files": [
|