@gram-ai/elements 1.18.1 → 1.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/buttonVariants.d.ts +1 -1
- package/dist/contexts/ElementsProvider.d.ts +6 -1
- package/dist/elements.cjs +50 -50
- package/dist/elements.js +19589 -19539
- package/dist/hooks/useAuth.d.ts +16 -0
- package/dist/hooks/useMCPTools.d.ts +3 -4
- package/dist/hooks/useSession.d.ts +1 -1
- package/dist/index-Bj7jPiuy.cjs +16 -0
- package/dist/{index-1qi_Rje5.js → index-CJRypLIa.js} +210 -210
- package/dist/index.d.ts +1 -1
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.js +1 -1
- package/dist/types/index.d.ts +40 -32
- package/package.json +1 -1
- package/dist/index-DY3aJC4I.cjs +0 -16
package/dist/types/index.d.ts
CHANGED
|
@@ -10,29 +10,6 @@ import { Plugin } from './plugins';
|
|
|
10
10
|
export type GetSessionFn = (init: {
|
|
11
11
|
projectSlug: string;
|
|
12
12
|
}) => Promise<string>;
|
|
13
|
-
export interface ElementsProviderProps {
|
|
14
|
-
/**
|
|
15
|
-
* The children to render.
|
|
16
|
-
*/
|
|
17
|
-
children: ReactNode;
|
|
18
|
-
/**
|
|
19
|
-
* Configuration object for the Elements library.
|
|
20
|
-
*/
|
|
21
|
-
config: ElementsConfig;
|
|
22
|
-
/**
|
|
23
|
-
* Function to retrieve the session token from the backend endpoint.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* const config: ElementsConfig = {
|
|
27
|
-
* getSession: async () => {
|
|
28
|
-
* return fetch('/chat/session').then(res => res.json()).then(data => data.client_token)
|
|
29
|
-
* },
|
|
30
|
-
* }
|
|
31
|
-
*
|
|
32
|
-
* @default Use this default if you are using the Elements server handlers, and have mounted the session handler at /chat/session.
|
|
33
|
-
*/
|
|
34
|
-
getSession?: GetSessionFn;
|
|
35
|
-
}
|
|
36
13
|
type ServerUrl = string;
|
|
37
14
|
export declare const VARIANTS: readonly ["widget", "sidecar", "standalone"];
|
|
38
15
|
export type Variant = (typeof VARIANTS)[number];
|
|
@@ -83,15 +60,6 @@ export interface ElementsConfig {
|
|
|
83
60
|
* }
|
|
84
61
|
*/
|
|
85
62
|
components?: ComponentOverrides;
|
|
86
|
-
/**
|
|
87
|
-
* The Gram API URL to use for the Elements library.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* const config: ElementsConfig = {
|
|
91
|
-
* apiURL: 'https://api.getgram.ai',
|
|
92
|
-
* }
|
|
93
|
-
*/
|
|
94
|
-
apiURL?: string;
|
|
95
63
|
/**
|
|
96
64
|
* The project slug to use for the Elements library.
|
|
97
65
|
*
|
|
@@ -263,7 +231,47 @@ export interface ElementsConfig {
|
|
|
263
231
|
* }
|
|
264
232
|
*/
|
|
265
233
|
tools?: ToolsConfig;
|
|
234
|
+
api?: {
|
|
235
|
+
/**
|
|
236
|
+
* The Gram API URL to use for the Elements library.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* const config: ElementsConfig = {
|
|
240
|
+
* apiURL: 'https://api.getgram.ai',
|
|
241
|
+
* }
|
|
242
|
+
*/
|
|
243
|
+
url?: string;
|
|
244
|
+
} & AuthConfig;
|
|
266
245
|
}
|
|
246
|
+
export type AuthConfig = {
|
|
247
|
+
/**
|
|
248
|
+
* The function to use to retrieve the session token from the backend endpoint.
|
|
249
|
+
* By default, this will attempt to fetch the session token from `/chat/session`.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* const config: ElementsConfig = {
|
|
253
|
+
* api: {
|
|
254
|
+
* sessionFn: async () => {
|
|
255
|
+
* return fetch('/chat/session').then(res => res.json()).then(data => data.client_token)
|
|
256
|
+
* },
|
|
257
|
+
* },
|
|
258
|
+
* }
|
|
259
|
+
*/
|
|
260
|
+
sessionFn?: GetSessionFn;
|
|
261
|
+
} | {
|
|
262
|
+
/**
|
|
263
|
+
* The API key to use if you haven't yet configured a session endpoint.
|
|
264
|
+
* Do not use this in production.
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* const config: ElementsConfig = {
|
|
268
|
+
* api: {
|
|
269
|
+
* UNSAFE_apiKey: 'your-api-key',
|
|
270
|
+
* },
|
|
271
|
+
* }
|
|
272
|
+
*/
|
|
273
|
+
UNSAFE_apiKey: string;
|
|
274
|
+
};
|
|
267
275
|
/**
|
|
268
276
|
* The LLM model to use for the Elements library.
|
|
269
277
|
*
|
package/package.json
CHANGED
package/dist/index-DY3aJC4I.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";const B=require("react/jsx-runtime"),C=require("react"),$e=require("@assistant-ui/react"),oe=require("vega"),Ce=C.createContext(void 0),De=C.createContext(null),ie=()=>{const e=C.useContext(Ce);if(!e)throw new Error("useElements must be used within a ElementsProvider");return e},qe={compact:{"p-xs":"p-1","p-sm":"p-1.5","p-md":"p-2","p-lg":"p-2.5","p-xl":"p-3","px-xs":"px-1","px-sm":"px-1.5","px-md":"px-2","px-lg":"px-2.5","px-xl":"px-3","py-xs":"py-1","py-sm":"py-1.5","py-md":"py-2","py-lg":"py-2.5","py-xl":"py-3","gap-sm":"gap-1","gap-md":"gap-1.5","gap-lg":"gap-2","gap-xl":"gap-2.5","h-header":"h-10","h-input":"min-h-10","text-base":"text-sm","text-title":"text-xl","text-subtitle":"text-sm"},normal:{"p-xs":"p-1","p-sm":"p-2","p-md":"p-3","p-lg":"p-4","p-xl":"p-6","px-xs":"px-1","px-sm":"px-2","px-md":"px-3","px-lg":"px-4","px-xl":"px-6","py-xs":"py-1","py-sm":"py-2","py-md":"py-3","py-lg":"py-4","py-xl":"py-6","gap-sm":"gap-1.5","gap-md":"gap-2","gap-lg":"gap-3","gap-xl":"gap-4","h-header":"h-12","h-input":"min-h-12","text-base":"text-base","text-title":"text-2xl","text-subtitle":"text-base"},spacious:{"p-xs":"p-2","p-sm":"p-3","p-md":"p-4","p-lg":"p-6","p-xl":"p-10","px-xs":"px-2","px-sm":"px-3","px-md":"px-4","px-lg":"px-6","px-xl":"px-10","py-xs":"py-2","py-sm":"py-3","py-md":"py-4","py-lg":"py-6","py-xl":"py-10","gap-sm":"gap-2","gap-md":"gap-3","gap-lg":"gap-4","gap-xl":"gap-6","h-header":"h-14","h-input":"min-h-16","text-base":"text-lg","text-title":"text-3xl","text-subtitle":"text-lg"}},ze=()=>{const{config:e}=ie(),r=e.theme?.density??"normal";return o=>qe[r][o]},Je={sharp:{sm:"rounded-sm",md:"rounded",lg:"rounded-md",xl:"rounded-lg",full:"rounded-lg"},soft:{sm:"rounded",md:"rounded-lg",lg:"rounded-xl",xl:"rounded-2xl",full:"rounded-full"},round:{sm:"rounded-lg",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-3xl",full:"rounded-full"}},Ae=()=>{const{config:e}=ie(),r=e.theme?.radius??"soft";return o=>Je[r][o]};function Se(e){var r,o,t="";if(typeof e=="string"||typeof e=="number")t+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(r=0;r<a;r++)e[r]&&(o=Se(e[r]))&&(t&&(t+=" "),t+=o)}else for(o in e)e[o]&&(t&&(t+=" "),t+=o);return t}function Re(){for(var e,r,o=0,t="",a=arguments.length;o<a;o++)(e=arguments[o])&&(r=Se(e))&&(t&&(t+=" "),t+=r);return t}const Ye=(e,r)=>{const o=new Array(e.length+r.length);for(let t=0;t<e.length;t++)o[t]=e[t];for(let t=0;t<r.length;t++)o[e.length+t]=r[t];return o},Xe=(e,r)=>({classGroupId:e,validator:r}),Ie=(e=new Map,r=null,o)=>({nextPart:e,validators:r,classGroupId:o}),Q="-",he=[],Ze="arbitrary..",He=e=>{const r=Qe(e),{conflictingClassGroups:o,conflictingClassGroupModifiers:t}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Ke(i);const u=i.split(Q),c=u[0]===""&&u.length>1?1:0;return Ne(u,c,r)},getConflictingClassGroupIds:(i,u)=>{if(u){const c=t[i],g=o[i];return c?g?Ye(g,c):c:g||he}return o[i]||he}}},Ne=(e,r,o)=>{if(e.length-r===0)return o.classGroupId;const a=e[r],l=o.nextPart.get(a);if(l){const g=Ne(e,r+1,l);if(g)return g}const i=o.validators;if(i===null)return;const u=r===0?e.join(Q):e.slice(r).join(Q),c=i.length;for(let g=0;g<c;g++){const f=i[g];if(f.validator(u))return f.classGroupId}},Ke=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=e.slice(1,-1),o=r.indexOf(":"),t=r.slice(0,o);return t?Ze+t:void 0})(),Qe=e=>{const{theme:r,classGroups:o}=e;return et(o,r)},et=(e,r)=>{const o=Ie();for(const t in e){const a=e[t];le(a,o,t,r)}return o},le=(e,r,o,t)=>{const a=e.length;for(let l=0;l<a;l++){const i=e[l];tt(i,r,o,t)}},tt=(e,r,o,t)=>{if(typeof e=="string"){rt(e,r,o);return}if(typeof e=="function"){ot(e,r,o,t);return}st(e,r,o,t)},rt=(e,r,o)=>{const t=e===""?r:Ee(r,e);t.classGroupId=o},ot=(e,r,o,t)=>{if(nt(e)){le(e(t),r,o,t);return}r.validators===null&&(r.validators=[]),r.validators.push(Xe(o,e))},st=(e,r,o,t)=>{const a=Object.entries(e),l=a.length;for(let i=0;i<l;i++){const[u,c]=a[i];le(c,Ee(r,u),o,t)}},Ee=(e,r)=>{let o=e;const t=r.split(Q),a=t.length;for(let l=0;l<a;l++){const i=t[l];let u=o.nextPart.get(i);u||(u=Ie(),o.nextPart.set(i,u)),o=u}return o},nt=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,at=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,o=Object.create(null),t=Object.create(null);const a=(l,i)=>{o[l]=i,r++,r>e&&(r=0,t=o,o=Object.create(null))};return{get(l){let i=o[l];if(i!==void 0)return i;if((i=t[l])!==void 0)return a(l,i),i},set(l,i){l in o?o[l]=i:a(l,i)}}},ae="!",xe=":",it=[],ye=(e,r,o,t,a)=>({modifiers:e,hasImportantModifier:r,baseClassName:o,maybePostfixModifierPosition:t,isExternal:a}),lt=e=>{const{prefix:r,experimentalParseClassName:o}=e;let t=a=>{const l=[];let i=0,u=0,c=0,g;const f=a.length;for(let z=0;z<f;z++){const k=a[z];if(i===0&&u===0){if(k===xe){l.push(a.slice(c,z)),c=z+1;continue}if(k==="/"){g=z;continue}}k==="["?i++:k==="]"?i--:k==="("?u++:k===")"&&u--}const x=l.length===0?a:a.slice(c);let y=x,A=!1;x.endsWith(ae)?(y=x.slice(0,-1),A=!0):x.startsWith(ae)&&(y=x.slice(1),A=!0);const E=g&&g>c?g-c:void 0;return ye(l,A,y,E)};if(r){const a=r+xe,l=t;t=i=>i.startsWith(a)?l(i.slice(a.length)):ye(it,!1,i,void 0,!0)}if(o){const a=t;t=l=>o({className:l,parseClassName:a})}return t},ct=e=>{const r=new Map;return e.orderSensitiveModifiers.forEach((o,t)=>{r.set(o,1e6+t)}),o=>{const t=[];let a=[];for(let l=0;l<o.length;l++){const i=o[l],u=i[0]==="[",c=r.has(i);u||c?(a.length>0&&(a.sort(),t.push(...a),a=[]),t.push(i)):a.push(i)}return a.length>0&&(a.sort(),t.push(...a)),t}},dt=e=>({cache:at(e.cacheSize),parseClassName:lt(e),sortModifiers:ct(e),...He(e)}),pt=/\s+/,mt=(e,r)=>{const{parseClassName:o,getClassGroupId:t,getConflictingClassGroupIds:a,sortModifiers:l}=r,i=[],u=e.trim().split(pt);let c="";for(let g=u.length-1;g>=0;g-=1){const f=u[g],{isExternal:x,modifiers:y,hasImportantModifier:A,baseClassName:E,maybePostfixModifierPosition:z}=o(f);if(x){c=f+(c.length>0?" "+c:c);continue}let k=!!z,T=t(k?E.substring(0,z):E);if(!T){if(!k){c=f+(c.length>0?" "+c:c);continue}if(T=t(E),!T){c=f+(c.length>0?" "+c:c);continue}k=!1}const D=y.length===0?"":y.length===1?y[0]:l(y).join(":"),_=A?D+ae:D,j=_+T;if(i.indexOf(j)>-1)continue;i.push(j);const G=a(T,k);for(let M=0;M<G.length;++M){const U=G[M];i.push(_+U)}c=f+(c.length>0?" "+c:c)}return c},ut=(...e)=>{let r=0,o,t,a="";for(;r<e.length;)(o=e[r++])&&(t=Te(o))&&(a&&(a+=" "),a+=t);return a},Te=e=>{if(typeof e=="string")return e;let r,o="";for(let t=0;t<e.length;t++)e[t]&&(r=Te(e[t]))&&(o&&(o+=" "),o+=r);return o},gt=(e,...r)=>{let o,t,a,l;const i=c=>{const g=r.reduce((f,x)=>x(f),e());return o=dt(g),t=o.cache.get,a=o.cache.set,l=u,u(c)},u=c=>{const g=t(c);if(g)return g;const f=mt(c,o);return a(c,f),f};return l=i,(...c)=>l(ut(...c))},ft=[],b=e=>{const r=o=>o[e]||ft;return r.isThemeGetter=!0,r},Me=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Oe=/^\((?:(\w[\w-]*):)?(.+)\)$/i,bt=/^\d+\/\d+$/,ht=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,xt=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,yt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,wt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,kt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,V=e=>bt.test(e),m=e=>!!e&&!Number.isNaN(Number(e)),N=e=>!!e&&Number.isInteger(Number(e)),se=e=>e.endsWith("%")&&m(e.slice(0,-1)),I=e=>ht.test(e),vt=()=>!0,Ct=e=>xt.test(e)&&!yt.test(e),Pe=()=>!1,zt=e=>wt.test(e),At=e=>kt.test(e),St=e=>!s(e)&&!n(e),Rt=e=>F(e,Le,Pe),s=e=>Me.test(e),P=e=>F(e,Ve,Ct),ne=e=>F(e,Mt,m),we=e=>F(e,je,Pe),It=e=>F(e,Ge,At),H=e=>F(e,Fe,zt),n=e=>Oe.test(e),$=e=>W(e,Ve),Nt=e=>W(e,Ot),ke=e=>W(e,je),Et=e=>W(e,Le),Tt=e=>W(e,Ge),K=e=>W(e,Fe,!0),F=(e,r,o)=>{const t=Me.exec(e);return t?t[1]?r(t[1]):o(t[2]):!1},W=(e,r,o=!1)=>{const t=Oe.exec(e);return t?t[1]?r(t[1]):o:!1},je=e=>e==="position"||e==="percentage",Ge=e=>e==="image"||e==="url",Le=e=>e==="length"||e==="size"||e==="bg-size",Ve=e=>e==="length",Mt=e=>e==="number",Ot=e=>e==="family-name",Fe=e=>e==="shadow",Pt=()=>{const e=b("color"),r=b("font"),o=b("text"),t=b("font-weight"),a=b("tracking"),l=b("leading"),i=b("breakpoint"),u=b("container"),c=b("spacing"),g=b("radius"),f=b("shadow"),x=b("inset-shadow"),y=b("text-shadow"),A=b("drop-shadow"),E=b("blur"),z=b("perspective"),k=b("aspect"),T=b("ease"),D=b("animate"),_=()=>["auto","avoid","all","avoid-page","page","left","right","column"],j=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],G=()=>[...j(),n,s],M=()=>["auto","hidden","clip","visible","scroll"],U=()=>["auto","contain","none"],p=()=>[n,s,c],S=()=>[V,"full","auto",...p()],ce=()=>[N,"none","subgrid",n,s],de=()=>["auto",{span:["full",N,n,s]},N,n,s],q=()=>[N,"auto",n,s],pe=()=>["auto","min","max","fr",n,s],ee=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],L=()=>["start","end","center","stretch","center-safe","end-safe"],R=()=>["auto",...p()],O=()=>[V,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...p()],d=()=>[e,n,s],me=()=>[...j(),ke,we,{position:[n,s]}],ue=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ge=()=>["auto","cover","contain",Et,Rt,{size:[n,s]}],te=()=>[se,$,P],w=()=>["","none","full",g,n,s],v=()=>["",m,$,P],J=()=>["solid","dashed","dotted","double"],fe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],h=()=>[m,se,ke,we],be=()=>["","none",E,n,s],Y=()=>["none",m,n,s],X=()=>["none",m,n,s],re=()=>[m,n,s],Z=()=>[V,"full",...p()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[I],breakpoint:[I],color:[vt],container:[I],"drop-shadow":[I],ease:["in","out","in-out"],font:[St],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[I],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[I],shadow:[I],spacing:["px",m],text:[I],"text-shadow":[I],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",V,s,n,k]}],container:["container"],columns:[{columns:[m,s,n,u]}],"break-after":[{"break-after":_()}],"break-before":[{"break-before":_()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:G()}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:U()}],"overscroll-x":[{"overscroll-x":U()}],"overscroll-y":[{"overscroll-y":U()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:S()}],"inset-x":[{"inset-x":S()}],"inset-y":[{"inset-y":S()}],start:[{start:S()}],end:[{end:S()}],top:[{top:S()}],right:[{right:S()}],bottom:[{bottom:S()}],left:[{left:S()}],visibility:["visible","invisible","collapse"],z:[{z:[N,"auto",n,s]}],basis:[{basis:[V,"full","auto",u,...p()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[m,V,"auto","initial","none",s]}],grow:[{grow:["",m,n,s]}],shrink:[{shrink:["",m,n,s]}],order:[{order:[N,"first","last","none",n,s]}],"grid-cols":[{"grid-cols":ce()}],"col-start-end":[{col:de()}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":ce()}],"row-start-end":[{row:de()}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":pe()}],"auto-rows":[{"auto-rows":pe()}],gap:[{gap:p()}],"gap-x":[{"gap-x":p()}],"gap-y":[{"gap-y":p()}],"justify-content":[{justify:[...ee(),"normal"]}],"justify-items":[{"justify-items":[...L(),"normal"]}],"justify-self":[{"justify-self":["auto",...L()]}],"align-content":[{content:["normal",...ee()]}],"align-items":[{items:[...L(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...L(),{baseline:["","last"]}]}],"place-content":[{"place-content":ee()}],"place-items":[{"place-items":[...L(),"baseline"]}],"place-self":[{"place-self":["auto",...L()]}],p:[{p:p()}],px:[{px:p()}],py:[{py:p()}],ps:[{ps:p()}],pe:[{pe:p()}],pt:[{pt:p()}],pr:[{pr:p()}],pb:[{pb:p()}],pl:[{pl:p()}],m:[{m:R()}],mx:[{mx:R()}],my:[{my:R()}],ms:[{ms:R()}],me:[{me:R()}],mt:[{mt:R()}],mr:[{mr:R()}],mb:[{mb:R()}],ml:[{ml:R()}],"space-x":[{"space-x":p()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":p()}],"space-y-reverse":["space-y-reverse"],size:[{size:O()}],w:[{w:[u,"screen",...O()]}],"min-w":[{"min-w":[u,"screen","none",...O()]}],"max-w":[{"max-w":[u,"screen","none","prose",{screen:[i]},...O()]}],h:[{h:["screen","lh",...O()]}],"min-h":[{"min-h":["screen","lh","none",...O()]}],"max-h":[{"max-h":["screen","lh",...O()]}],"font-size":[{text:["base",o,$,P]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[t,n,ne]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",se,s]}],"font-family":[{font:[Nt,s,r]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,n,s]}],"line-clamp":[{"line-clamp":[m,"none",n,ne]}],leading:[{leading:[l,...p()]}],"list-image":[{"list-image":["none",n,s]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",n,s]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:d()}],"text-color":[{text:d()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...J(),"wavy"]}],"text-decoration-thickness":[{decoration:[m,"from-font","auto",n,P]}],"text-decoration-color":[{decoration:d()}],"underline-offset":[{"underline-offset":[m,"auto",n,s]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:p()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",n,s]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",n,s]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:me()}],"bg-repeat":[{bg:ue()}],"bg-size":[{bg:ge()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},N,n,s],radial:["",n,s],conic:[N,n,s]},Tt,It]}],"bg-color":[{bg:d()}],"gradient-from-pos":[{from:te()}],"gradient-via-pos":[{via:te()}],"gradient-to-pos":[{to:te()}],"gradient-from":[{from:d()}],"gradient-via":[{via:d()}],"gradient-to":[{to:d()}],rounded:[{rounded:w()}],"rounded-s":[{"rounded-s":w()}],"rounded-e":[{"rounded-e":w()}],"rounded-t":[{"rounded-t":w()}],"rounded-r":[{"rounded-r":w()}],"rounded-b":[{"rounded-b":w()}],"rounded-l":[{"rounded-l":w()}],"rounded-ss":[{"rounded-ss":w()}],"rounded-se":[{"rounded-se":w()}],"rounded-ee":[{"rounded-ee":w()}],"rounded-es":[{"rounded-es":w()}],"rounded-tl":[{"rounded-tl":w()}],"rounded-tr":[{"rounded-tr":w()}],"rounded-br":[{"rounded-br":w()}],"rounded-bl":[{"rounded-bl":w()}],"border-w":[{border:v()}],"border-w-x":[{"border-x":v()}],"border-w-y":[{"border-y":v()}],"border-w-s":[{"border-s":v()}],"border-w-e":[{"border-e":v()}],"border-w-t":[{"border-t":v()}],"border-w-r":[{"border-r":v()}],"border-w-b":[{"border-b":v()}],"border-w-l":[{"border-l":v()}],"divide-x":[{"divide-x":v()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":v()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...J(),"hidden","none"]}],"divide-style":[{divide:[...J(),"hidden","none"]}],"border-color":[{border:d()}],"border-color-x":[{"border-x":d()}],"border-color-y":[{"border-y":d()}],"border-color-s":[{"border-s":d()}],"border-color-e":[{"border-e":d()}],"border-color-t":[{"border-t":d()}],"border-color-r":[{"border-r":d()}],"border-color-b":[{"border-b":d()}],"border-color-l":[{"border-l":d()}],"divide-color":[{divide:d()}],"outline-style":[{outline:[...J(),"none","hidden"]}],"outline-offset":[{"outline-offset":[m,n,s]}],"outline-w":[{outline:["",m,$,P]}],"outline-color":[{outline:d()}],shadow:[{shadow:["","none",f,K,H]}],"shadow-color":[{shadow:d()}],"inset-shadow":[{"inset-shadow":["none",x,K,H]}],"inset-shadow-color":[{"inset-shadow":d()}],"ring-w":[{ring:v()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:d()}],"ring-offset-w":[{"ring-offset":[m,P]}],"ring-offset-color":[{"ring-offset":d()}],"inset-ring-w":[{"inset-ring":v()}],"inset-ring-color":[{"inset-ring":d()}],"text-shadow":[{"text-shadow":["none",y,K,H]}],"text-shadow-color":[{"text-shadow":d()}],opacity:[{opacity:[m,n,s]}],"mix-blend":[{"mix-blend":[...fe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":fe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[m]}],"mask-image-linear-from-pos":[{"mask-linear-from":h()}],"mask-image-linear-to-pos":[{"mask-linear-to":h()}],"mask-image-linear-from-color":[{"mask-linear-from":d()}],"mask-image-linear-to-color":[{"mask-linear-to":d()}],"mask-image-t-from-pos":[{"mask-t-from":h()}],"mask-image-t-to-pos":[{"mask-t-to":h()}],"mask-image-t-from-color":[{"mask-t-from":d()}],"mask-image-t-to-color":[{"mask-t-to":d()}],"mask-image-r-from-pos":[{"mask-r-from":h()}],"mask-image-r-to-pos":[{"mask-r-to":h()}],"mask-image-r-from-color":[{"mask-r-from":d()}],"mask-image-r-to-color":[{"mask-r-to":d()}],"mask-image-b-from-pos":[{"mask-b-from":h()}],"mask-image-b-to-pos":[{"mask-b-to":h()}],"mask-image-b-from-color":[{"mask-b-from":d()}],"mask-image-b-to-color":[{"mask-b-to":d()}],"mask-image-l-from-pos":[{"mask-l-from":h()}],"mask-image-l-to-pos":[{"mask-l-to":h()}],"mask-image-l-from-color":[{"mask-l-from":d()}],"mask-image-l-to-color":[{"mask-l-to":d()}],"mask-image-x-from-pos":[{"mask-x-from":h()}],"mask-image-x-to-pos":[{"mask-x-to":h()}],"mask-image-x-from-color":[{"mask-x-from":d()}],"mask-image-x-to-color":[{"mask-x-to":d()}],"mask-image-y-from-pos":[{"mask-y-from":h()}],"mask-image-y-to-pos":[{"mask-y-to":h()}],"mask-image-y-from-color":[{"mask-y-from":d()}],"mask-image-y-to-color":[{"mask-y-to":d()}],"mask-image-radial":[{"mask-radial":[n,s]}],"mask-image-radial-from-pos":[{"mask-radial-from":h()}],"mask-image-radial-to-pos":[{"mask-radial-to":h()}],"mask-image-radial-from-color":[{"mask-radial-from":d()}],"mask-image-radial-to-color":[{"mask-radial-to":d()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":j()}],"mask-image-conic-pos":[{"mask-conic":[m]}],"mask-image-conic-from-pos":[{"mask-conic-from":h()}],"mask-image-conic-to-pos":[{"mask-conic-to":h()}],"mask-image-conic-from-color":[{"mask-conic-from":d()}],"mask-image-conic-to-color":[{"mask-conic-to":d()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:me()}],"mask-repeat":[{mask:ue()}],"mask-size":[{mask:ge()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",n,s]}],filter:[{filter:["","none",n,s]}],blur:[{blur:be()}],brightness:[{brightness:[m,n,s]}],contrast:[{contrast:[m,n,s]}],"drop-shadow":[{"drop-shadow":["","none",A,K,H]}],"drop-shadow-color":[{"drop-shadow":d()}],grayscale:[{grayscale:["",m,n,s]}],"hue-rotate":[{"hue-rotate":[m,n,s]}],invert:[{invert:["",m,n,s]}],saturate:[{saturate:[m,n,s]}],sepia:[{sepia:["",m,n,s]}],"backdrop-filter":[{"backdrop-filter":["","none",n,s]}],"backdrop-blur":[{"backdrop-blur":be()}],"backdrop-brightness":[{"backdrop-brightness":[m,n,s]}],"backdrop-contrast":[{"backdrop-contrast":[m,n,s]}],"backdrop-grayscale":[{"backdrop-grayscale":["",m,n,s]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[m,n,s]}],"backdrop-invert":[{"backdrop-invert":["",m,n,s]}],"backdrop-opacity":[{"backdrop-opacity":[m,n,s]}],"backdrop-saturate":[{"backdrop-saturate":[m,n,s]}],"backdrop-sepia":[{"backdrop-sepia":["",m,n,s]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":p()}],"border-spacing-x":[{"border-spacing-x":p()}],"border-spacing-y":[{"border-spacing-y":p()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",n,s]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[m,"initial",n,s]}],ease:[{ease:["linear","initial",T,n,s]}],delay:[{delay:[m,n,s]}],animate:[{animate:["none",D,n,s]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[z,n,s]}],"perspective-origin":[{"perspective-origin":G()}],rotate:[{rotate:Y()}],"rotate-x":[{"rotate-x":Y()}],"rotate-y":[{"rotate-y":Y()}],"rotate-z":[{"rotate-z":Y()}],scale:[{scale:X()}],"scale-x":[{"scale-x":X()}],"scale-y":[{"scale-y":X()}],"scale-z":[{"scale-z":X()}],"scale-3d":["scale-3d"],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[n,s,"","none","gpu","cpu"]}],"transform-origin":[{origin:G()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Z()}],"translate-x":[{"translate-x":Z()}],"translate-y":[{"translate-y":Z()}],"translate-z":[{"translate-z":Z()}],"translate-none":["translate-none"],accent:[{accent:d()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:d()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",n,s]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":p()}],"scroll-mx":[{"scroll-mx":p()}],"scroll-my":[{"scroll-my":p()}],"scroll-ms":[{"scroll-ms":p()}],"scroll-me":[{"scroll-me":p()}],"scroll-mt":[{"scroll-mt":p()}],"scroll-mr":[{"scroll-mr":p()}],"scroll-mb":[{"scroll-mb":p()}],"scroll-ml":[{"scroll-ml":p()}],"scroll-p":[{"scroll-p":p()}],"scroll-px":[{"scroll-px":p()}],"scroll-py":[{"scroll-py":p()}],"scroll-ps":[{"scroll-ps":p()}],"scroll-pe":[{"scroll-pe":p()}],"scroll-pt":[{"scroll-pt":p()}],"scroll-pr":[{"scroll-pr":p()}],"scroll-pb":[{"scroll-pb":p()}],"scroll-pl":[{"scroll-pl":p()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",n,s]}],fill:[{fill:["none",...d()]}],"stroke-w":[{stroke:[m,$,P,ne]}],stroke:[{stroke:["none",...d()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},jt=gt(Pt);function We(...e){return jt(Re(e))}function Gt(e){throw new Error(`Unexpected value: ${e}`)}function Lt(e,r){if(!e)throw new Error(r)}const Vt=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ft=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,o,t)=>t?t.toUpperCase():o.toLowerCase()),ve=e=>{const r=Ft(e);return r.charAt(0).toUpperCase()+r.slice(1)},_e=(...e)=>e.filter((r,o,t)=>!!r&&r.trim()!==""&&t.indexOf(r)===o).join(" ").trim(),Wt=e=>{for(const r in e)if(r.startsWith("aria-")||r==="role"||r==="title")return!0};var _t={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Ut=C.forwardRef(({color:e="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:t,className:a="",children:l,iconNode:i,...u},c)=>C.createElement("svg",{ref:c,..._t,width:r,height:r,stroke:e,strokeWidth:t?Number(o)*24/Number(r):o,className:_e("lucide",a),...!l&&!Wt(u)&&{"aria-hidden":"true"},...u},[...i.map(([g,f])=>C.createElement(g,f)),...Array.isArray(l)?l:[l]]));const Ue=(e,r)=>{const o=C.forwardRef(({className:t,...a},l)=>C.createElement(Ut,{ref:l,iconNode:r,className:_e(`lucide-${Vt(ve(e))}`,`lucide-${e}`,t),...a}));return o.displayName=ve(e),o};const Bt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],$t=Ue("circle-alert",Bt),Dt=({code:e})=>{const r=$e.useAssistantState(({message:x})=>x),o=C.useRef(null),t=C.useRef(null),[a,l]=C.useState(null),i=r.status?.type==="complete",u=Ae(),c=ze(),g=C.useMemo(()=>{const x=e.trim();if(!x)return null;try{return JSON.parse(x)}catch{return null}},[e]),f=i&&g!==null;return C.useEffect(()=>!o.current||!f?void 0:(l(null),(async()=>{try{t.current&&(t.current.finalize(),t.current=null);const y=oe.parse(g),A=new oe.View(y,{container:o.current??void 0,renderer:"svg",hover:!0,logLevel:oe.Warn});t.current=A,await A.runAsync()}catch(y){console.error("Failed to render chart:",y),l(y instanceof Error?y.message:"Failed to render chart")}})(),()=>{t.current&&(t.current.finalize(),t.current=null)}),[f,g]),B.jsxs("div",{className:We("relative flex min-h-[400px] w-fit max-w-full min-w-[400px] items-center justify-center border p-6 after:hidden",u("lg"),c("p-lg")),children:[!f&&!a&&B.jsx("div",{className:"shimmer text-muted-foreground bg-background/80 absolute inset-0 z-10 flex items-center justify-center",children:"Rendering chart..."}),a&&B.jsxs("div",{className:"bg-background absolute inset-0 z-10 flex items-center justify-center gap-2 text-rose-500",children:[B.jsx($t,{name:"alert-circle",className:"h-4 w-4"}),a]}),B.jsx("div",{ref:o,className:f?"block":"hidden"})]})},Be={language:"vega",prompt:`When a user requests a chart or visualization, respond with a valid Vega specification (https://vega.github.io/vega/) in a code block annotated with the language identifier 'vega'.
|
|
2
|
-
|
|
3
|
-
CRITICAL JSON REQUIREMENTS:
|
|
4
|
-
- The code block MUST contain ONLY valid, parseable JSON
|
|
5
|
-
- NO comments (no // or /* */ anywhere)
|
|
6
|
-
- NO trailing commas
|
|
7
|
-
- Use double quotes for all strings and keys
|
|
8
|
-
- NO text before or after the JSON object
|
|
9
|
-
- The JSON must start with { and end with }
|
|
10
|
-
|
|
11
|
-
CONTENT GUIDELINES:
|
|
12
|
-
- Outside the code block, describe trends and insights found in the data
|
|
13
|
-
- Do not describe visual properties or technical implementation details
|
|
14
|
-
- Do not mention "Vega" or other technical terms - this is user-facing
|
|
15
|
-
|
|
16
|
-
The Vega spec will be parsed with JSON.parse() - if it fails, the chart will error. Ensure strict JSON validity.`,Component:Dt,Header:void 0},qt=[Be];exports.ElementsContext=Ce;exports.ToolApprovalContext=De;exports.assert=Lt;exports.assertNever=Gt;exports.chart=Be;exports.clsx=Re;exports.cn=We;exports.createLucideIcon=Ue;exports.recommended=qt;exports.useDensity=ze;exports.useElements=ie;exports.useRadius=Ae;
|