@heroui/agent 0.2.0-beta.7 → 0.2.0-beta.9
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/CHANGELOG.md +20 -2
- package/README.md +15 -10
- package/dist/chart-content-BBHQVMP4.js +1 -0
- package/dist/chunk-2XBFFSW2.js +1 -0
- package/dist/chunk-64RI74L5.js +1 -0
- package/dist/chunk-6ZJJN322.js +1 -0
- package/dist/chunk-7KCGPNEN.js +1 -0
- package/dist/chunk-BBB5EHDN.js +5 -0
- package/dist/chunk-CR3H7AVI.js +1 -0
- package/dist/chunk-HCLXS4HQ.js +1 -0
- package/dist/chunk-MXLGM4WV.js +1 -0
- package/dist/chunk-OA3TG5CS.js +1 -0
- package/dist/chunk-PZJ4NC3J.js +1 -0
- package/dist/chunk-RNNGE7KM.js +1 -0
- package/dist/chunk-S6OIAJSC.js +1 -0
- package/dist/chunk-SUDHJNTJ.js +2 -0
- package/dist/chunk-WUAFMD7Z.js +2 -0
- package/dist/component-renderer-GG6JVRUG.js +1 -0
- package/dist/composer-draft-NSKK65F3.js +1 -0
- package/dist/composer-image-draft-KAGTNQR7.js +1 -0
- package/dist/contracts.d.ts +50 -19
- package/dist/contracts.js +2 -2545
- package/dist/css/index.css +1 -1
- package/dist/embed-runtime-GYXK7V6N.js +5 -0
- package/dist/identity-3P8-17km.d.ts +95 -0
- package/dist/index.d.ts +46 -10
- package/dist/index.js +1 -28
- package/dist/interactive-map-surface-WC2LPCR7.js +1 -0
- package/dist/internal/client-tools.js +1 -0
- package/dist/internal/models.js +1 -0
- package/dist/internal/runtime.js +1 -0
- package/dist/internal/theme.js +1 -0
- package/dist/next.d.ts +2 -1
- package/dist/next.js +1 -22
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -260
- package/package.json +6 -6
- package/dist/chart-content-E4NPTUPR.js +0 -2696
- package/dist/chunk-3FG5NRTX.js +0 -9
- package/dist/chunk-6O3SFXJK.js +0 -325
- package/dist/chunk-FNGGMHVR.js +0 -625
- package/dist/chunk-OQGXZY5L.js +0 -1091
- package/dist/chunk-TOOT6SZ2.js +0 -74
- package/dist/chunk-V5S5FRGV.js +0 -984
- package/dist/chunk-VJA52U5P.js +0 -137
- package/dist/component-renderer-46EJDPTB.js +0 -10627
- package/dist/embed-runtime-UF7XJIFA.js +0 -7650
- package/dist/identity-Z6i6pL0F.d.ts +0 -166
- package/dist/interactive-map-surface-67KHT3VB.js +0 -362
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
declare const agentThemeSchema: z.ZodEnum<{
|
|
4
|
-
dark: "dark";
|
|
5
|
-
light: "light";
|
|
6
|
-
system: "system";
|
|
7
|
-
}>;
|
|
8
|
-
declare const agentSurfaceVariantSchema: z.ZodEnum<{
|
|
9
|
-
surface: "surface";
|
|
10
|
-
outline: "outline";
|
|
11
|
-
plain: "plain";
|
|
12
|
-
"surface-secondary": "surface-secondary";
|
|
13
|
-
}>;
|
|
14
|
-
declare const pageContextSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
15
|
-
declare const agentIdentityIdSchema: z.ZodString;
|
|
16
|
-
declare const agentAuthIdentitySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
17
|
-
id: z.ZodString;
|
|
18
|
-
type: z.ZodLiteral<"anonymous">;
|
|
19
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
20
|
-
id: z.ZodString;
|
|
21
|
-
type: z.ZodLiteral<"user">;
|
|
22
|
-
}, z.core.$strip>], "type">;
|
|
23
|
-
declare const agentAuthProfileSchema: z.ZodObject<{
|
|
24
|
-
avatarUrl: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodURL>>;
|
|
25
|
-
email: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEmail>>;
|
|
26
|
-
name: z.ZodOptional<z.ZodString>;
|
|
27
|
-
}, z.core.$strip>;
|
|
28
|
-
/** Server-to-server request for a short-lived browser credential. */
|
|
29
|
-
declare const createAgentAuthTokenRequestSchema: z.ZodObject<{
|
|
30
|
-
anonymousId: z.ZodOptional<z.ZodString>;
|
|
31
|
-
identity: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
32
|
-
id: z.ZodString;
|
|
33
|
-
type: z.ZodLiteral<"anonymous">;
|
|
34
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
35
|
-
id: z.ZodString;
|
|
36
|
-
type: z.ZodLiteral<"user">;
|
|
37
|
-
}, z.core.$strip>], "type">;
|
|
38
|
-
profile: z.ZodOptional<z.ZodObject<{
|
|
39
|
-
avatarUrl: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodURL>>;
|
|
40
|
-
email: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEmail>>;
|
|
41
|
-
name: z.ZodOptional<z.ZodString>;
|
|
42
|
-
}, z.core.$strip>>;
|
|
43
|
-
}, z.core.$strip>;
|
|
44
|
-
declare const agentAuthTokenSchema: z.ZodObject<{
|
|
45
|
-
expiresAt: z.ZodNumber;
|
|
46
|
-
token: z.ZodString;
|
|
47
|
-
}, z.core.$strip>;
|
|
48
|
-
declare const agentTokenClaimsSchema: z.ZodObject<{
|
|
49
|
-
agentId: z.ZodString;
|
|
50
|
-
apiKeyId: z.ZodString;
|
|
51
|
-
aud: z.ZodLiteral<"heroui-agent">;
|
|
52
|
-
exp: z.ZodNumber;
|
|
53
|
-
iat: z.ZodNumber;
|
|
54
|
-
iss: z.ZodLiteral<"https://api.heroui.com">;
|
|
55
|
-
jti: z.ZodUUID;
|
|
56
|
-
protocolVersion: z.ZodLiteral<5>;
|
|
57
|
-
sub: z.ZodString;
|
|
58
|
-
}, z.core.$strip>;
|
|
59
|
-
declare const trustedAgentClientDataSchema: z.ZodObject<{
|
|
60
|
-
agentId: z.ZodString;
|
|
61
|
-
billingLicenseId: z.ZodNullable<z.ZodString>;
|
|
62
|
-
billingOwnerUserId: z.ZodString;
|
|
63
|
-
clientTools: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
64
|
-
description: z.ZodString;
|
|
65
|
-
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
66
|
-
name: z.ZodString;
|
|
67
|
-
needsApproval: z.ZodOptional<z.ZodBoolean>;
|
|
68
|
-
}, z.core.$strip>>>;
|
|
69
|
-
conversationId: z.ZodUUID;
|
|
70
|
-
endUserKey: z.ZodOptional<z.ZodString>;
|
|
71
|
-
imageSearch: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
-
modelId: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodEnum<{
|
|
73
|
-
"moonshotai/Kimi-K3": "moonshotai/Kimi-K3";
|
|
74
|
-
"openai/gpt-5.6-luna": "openai/gpt-5.6-luna";
|
|
75
|
-
"openai/gpt-5.6-terra": "openai/gpt-5.6-terra";
|
|
76
|
-
"openai/gpt-5.6-sol": "openai/gpt-5.6-sol";
|
|
77
|
-
"google/gemini-3.6-flash": "google/gemini-3.6-flash";
|
|
78
|
-
"anthropic/claude-sonnet-5": "anthropic/claude-sonnet-5";
|
|
79
|
-
"anthropic/claude-opus-4.8": "anthropic/claude-opus-4.8";
|
|
80
|
-
}>>>;
|
|
81
|
-
newsSearch: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
-
pageContext: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
83
|
-
preview: z.ZodOptional<z.ZodBoolean>;
|
|
84
|
-
protocolVersion: z.ZodLiteral<5>;
|
|
85
|
-
requestId: z.ZodUUID;
|
|
86
|
-
sdkVersion: z.ZodString;
|
|
87
|
-
signedAt: z.ZodNumber;
|
|
88
|
-
subject: z.ZodString;
|
|
89
|
-
webSearch: z.ZodOptional<z.ZodBoolean>;
|
|
90
|
-
}, z.core.$strip>;
|
|
91
|
-
declare const signedTrustedAgentClientDataSchema: z.ZodObject<{
|
|
92
|
-
agentId: z.ZodString;
|
|
93
|
-
billingLicenseId: z.ZodNullable<z.ZodString>;
|
|
94
|
-
billingOwnerUserId: z.ZodString;
|
|
95
|
-
clientTools: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
96
|
-
description: z.ZodString;
|
|
97
|
-
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
98
|
-
name: z.ZodString;
|
|
99
|
-
needsApproval: z.ZodOptional<z.ZodBoolean>;
|
|
100
|
-
}, z.core.$strip>>>;
|
|
101
|
-
conversationId: z.ZodUUID;
|
|
102
|
-
endUserKey: z.ZodOptional<z.ZodString>;
|
|
103
|
-
imageSearch: z.ZodOptional<z.ZodBoolean>;
|
|
104
|
-
modelId: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodEnum<{
|
|
105
|
-
"moonshotai/Kimi-K3": "moonshotai/Kimi-K3";
|
|
106
|
-
"openai/gpt-5.6-luna": "openai/gpt-5.6-luna";
|
|
107
|
-
"openai/gpt-5.6-terra": "openai/gpt-5.6-terra";
|
|
108
|
-
"openai/gpt-5.6-sol": "openai/gpt-5.6-sol";
|
|
109
|
-
"google/gemini-3.6-flash": "google/gemini-3.6-flash";
|
|
110
|
-
"anthropic/claude-sonnet-5": "anthropic/claude-sonnet-5";
|
|
111
|
-
"anthropic/claude-opus-4.8": "anthropic/claude-opus-4.8";
|
|
112
|
-
}>>>;
|
|
113
|
-
newsSearch: z.ZodOptional<z.ZodBoolean>;
|
|
114
|
-
pageContext: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
115
|
-
preview: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
-
protocolVersion: z.ZodLiteral<5>;
|
|
117
|
-
requestId: z.ZodUUID;
|
|
118
|
-
sdkVersion: z.ZodString;
|
|
119
|
-
signedAt: z.ZodNumber;
|
|
120
|
-
subject: z.ZodString;
|
|
121
|
-
webSearch: z.ZodOptional<z.ZodBoolean>;
|
|
122
|
-
sig: z.ZodString;
|
|
123
|
-
}, z.core.$strip>;
|
|
124
|
-
/**
|
|
125
|
-
* How a persisted conversation was started. Rows written before this existed
|
|
126
|
-
* carry no source and are treated as `embed`.
|
|
127
|
-
*/
|
|
128
|
-
declare const AGENT_CONVERSATION_SOURCE: {
|
|
129
|
-
readonly embed: "embed";
|
|
130
|
-
readonly preview: "preview";
|
|
131
|
-
};
|
|
132
|
-
type AgentConversationSource = (typeof AGENT_CONVERSATION_SOURCE)[keyof typeof AGENT_CONVERSATION_SOURCE];
|
|
133
|
-
declare const agentProjectConfigSchema: z.ZodObject<{
|
|
134
|
-
agentId: z.ZodString;
|
|
135
|
-
minimumProtocolVersion: z.ZodLiteral<5>;
|
|
136
|
-
name: z.ZodString;
|
|
137
|
-
presence: z.ZodOptional<z.ZodObject<{
|
|
138
|
-
appId: z.ZodUUID;
|
|
139
|
-
}, z.core.$strip>>;
|
|
140
|
-
protocolVersion: z.ZodLiteral<5>;
|
|
141
|
-
sdkVersion: z.ZodDefault<z.ZodString>;
|
|
142
|
-
suggestedPrompts: z.ZodArray<z.ZodString>;
|
|
143
|
-
surfaceVariant: z.ZodDefault<z.ZodEnum<{
|
|
144
|
-
surface: "surface";
|
|
145
|
-
outline: "outline";
|
|
146
|
-
plain: "plain";
|
|
147
|
-
"surface-secondary": "surface-secondary";
|
|
148
|
-
}>>;
|
|
149
|
-
theme: z.ZodEnum<{
|
|
150
|
-
dark: "dark";
|
|
151
|
-
light: "light";
|
|
152
|
-
system: "system";
|
|
153
|
-
}>;
|
|
154
|
-
}, z.core.$strip>;
|
|
155
|
-
type AgentAuthIdentity = z.infer<typeof agentAuthIdentitySchema>;
|
|
156
|
-
type AgentAuthProfile = z.infer<typeof agentAuthProfileSchema>;
|
|
157
|
-
type AgentAuthToken = z.infer<typeof agentAuthTokenSchema>;
|
|
158
|
-
type CreateAgentAuthTokenRequest = z.infer<typeof createAgentAuthTokenRequestSchema>;
|
|
159
|
-
type AgentTokenClaims = z.infer<typeof agentTokenClaimsSchema>;
|
|
160
|
-
type AgentTheme = z.infer<typeof agentThemeSchema>;
|
|
161
|
-
type AgentSurfaceVariant = z.infer<typeof agentSurfaceVariantSchema>;
|
|
162
|
-
type AgentProjectConfig = z.infer<typeof agentProjectConfigSchema>;
|
|
163
|
-
type SignedTrustedAgentClientData = z.infer<typeof signedTrustedAgentClientDataSchema>;
|
|
164
|
-
type TrustedAgentClientData = z.infer<typeof trustedAgentClientDataSchema>;
|
|
165
|
-
|
|
166
|
-
export { AGENT_CONVERSATION_SOURCE as A, type CreateAgentAuthTokenRequest as C, type SignedTrustedAgentClientData as S, type TrustedAgentClientData as T, type AgentAuthIdentity as a, type AgentAuthProfile as b, type AgentAuthToken as c, type AgentConversationSource as d, type AgentProjectConfig as e, type AgentSurfaceVariant as f, type AgentTheme as g, type AgentTokenClaims as h, agentAuthIdentitySchema as i, agentAuthProfileSchema as j, agentAuthTokenSchema as k, agentIdentityIdSchema as l, agentProjectConfigSchema as m, agentSurfaceVariantSchema as n, agentThemeSchema as o, agentTokenClaimsSchema as p, createAgentAuthTokenRequestSchema as q, pageContextSchema as r, signedTrustedAgentClientDataSchema as s, trustedAgentClientDataSchema as t };
|
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
createMapLayout,
|
|
4
|
-
getMapSelectionCenter
|
|
5
|
-
} from "./chunk-VJA52U5P.js";
|
|
6
|
-
import {
|
|
7
|
-
mergeClassNames
|
|
8
|
-
} from "./chunk-3FG5NRTX.js";
|
|
9
|
-
|
|
10
|
-
// ../agent-ui/src/components/display-information/map/interactive-map-surface.tsx
|
|
11
|
-
import { StarFill } from "@gravity-ui/icons";
|
|
12
|
-
|
|
13
|
-
// ../agent-ui/src/components/display-information/map/interactive-map.tsx
|
|
14
|
-
import MapLibreGL from "maplibre-gl";
|
|
15
|
-
import { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
16
|
-
import { createPortal } from "react-dom";
|
|
17
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
-
var InteractiveMapContext = createContext(null);
|
|
19
|
-
function getDocumentTheme() {
|
|
20
|
-
if (typeof document === "undefined") return void 0;
|
|
21
|
-
if (document.documentElement.classList.contains("dark") || document.documentElement.dataset["theme"] === "dark") {
|
|
22
|
-
return "dark";
|
|
23
|
-
}
|
|
24
|
-
if (document.documentElement.classList.contains("light") || document.documentElement.dataset["theme"] === "light") {
|
|
25
|
-
return "light";
|
|
26
|
-
}
|
|
27
|
-
return void 0;
|
|
28
|
-
}
|
|
29
|
-
function getLocalTheme(element) {
|
|
30
|
-
const themeRoot = element?.closest("[data-theme]");
|
|
31
|
-
const theme = themeRoot?.dataset["theme"];
|
|
32
|
-
return theme === "dark" || theme === "light" ? theme : void 0;
|
|
33
|
-
}
|
|
34
|
-
function getSystemTheme() {
|
|
35
|
-
if (typeof window === "undefined") return "light";
|
|
36
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
37
|
-
}
|
|
38
|
-
function useMapTheme(containerRef) {
|
|
39
|
-
const [theme, setTheme] = useState(() => getDocumentTheme() ?? getSystemTheme());
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
const localThemeRoot = containerRef.current?.closest("[data-theme]");
|
|
42
|
-
const updateTheme = () => setTheme(getLocalTheme(containerRef.current) ?? getDocumentTheme() ?? getSystemTheme());
|
|
43
|
-
const observer = new MutationObserver(updateTheme);
|
|
44
|
-
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
45
|
-
updateTheme();
|
|
46
|
-
observer.observe(document.documentElement, {
|
|
47
|
-
attributeFilter: ["class", "data-theme"],
|
|
48
|
-
attributes: true
|
|
49
|
-
});
|
|
50
|
-
if (localThemeRoot && localThemeRoot !== document.documentElement) {
|
|
51
|
-
observer.observe(localThemeRoot, {
|
|
52
|
-
attributeFilter: ["data-theme"],
|
|
53
|
-
attributes: true
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
mediaQuery.addEventListener("change", updateTheme);
|
|
57
|
-
return () => {
|
|
58
|
-
observer.disconnect();
|
|
59
|
-
mediaQuery.removeEventListener("change", updateTheme);
|
|
60
|
-
};
|
|
61
|
-
}, [containerRef]);
|
|
62
|
-
return theme;
|
|
63
|
-
}
|
|
64
|
-
function InteractiveMapRoot({
|
|
65
|
-
center,
|
|
66
|
-
children,
|
|
67
|
-
className,
|
|
68
|
-
padding,
|
|
69
|
-
styles,
|
|
70
|
-
zoom,
|
|
71
|
-
...options
|
|
72
|
-
}) {
|
|
73
|
-
const [longitude, latitude] = center;
|
|
74
|
-
const containerRef = useRef(null);
|
|
75
|
-
const initialOptionsRef = useRef({
|
|
76
|
-
...options,
|
|
77
|
-
center: [longitude, latitude],
|
|
78
|
-
zoom
|
|
79
|
-
});
|
|
80
|
-
const [map, setMap] = useState(null);
|
|
81
|
-
const [loadState, setLoadState] = useState("loading");
|
|
82
|
-
const theme = useMapTheme(containerRef);
|
|
83
|
-
const activeStyle = styles[theme];
|
|
84
|
-
const activeStyleRef = useRef(activeStyle);
|
|
85
|
-
const initialPaddingRef = useRef(padding);
|
|
86
|
-
const zoomRef = useRef(zoom);
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
const container = containerRef.current;
|
|
89
|
-
if (!container) return;
|
|
90
|
-
const nextMap = new MapLibreGL.Map({
|
|
91
|
-
attributionControl: false,
|
|
92
|
-
container,
|
|
93
|
-
renderWorldCopies: false,
|
|
94
|
-
style: activeStyleRef.current,
|
|
95
|
-
...initialOptionsRef.current
|
|
96
|
-
});
|
|
97
|
-
const loadTimeout = window.setTimeout(() => setLoadState("error"), 12e3);
|
|
98
|
-
const handleLoad = () => {
|
|
99
|
-
window.clearTimeout(loadTimeout);
|
|
100
|
-
setLoadState("loaded");
|
|
101
|
-
};
|
|
102
|
-
const observer = new ResizeObserver(() => nextMap.resize());
|
|
103
|
-
nextMap.touchZoomRotate.disableRotation();
|
|
104
|
-
if (initialPaddingRef.current) nextMap.setPadding(initialPaddingRef.current);
|
|
105
|
-
nextMap.on("load", handleLoad);
|
|
106
|
-
observer.observe(container);
|
|
107
|
-
setMap(nextMap);
|
|
108
|
-
return () => {
|
|
109
|
-
window.clearTimeout(loadTimeout);
|
|
110
|
-
observer.disconnect();
|
|
111
|
-
nextMap.off("load", handleLoad);
|
|
112
|
-
nextMap.remove();
|
|
113
|
-
setMap(null);
|
|
114
|
-
};
|
|
115
|
-
}, []);
|
|
116
|
-
useEffect(() => {
|
|
117
|
-
if (!map || activeStyleRef.current === activeStyle) return;
|
|
118
|
-
const styleLoadTimeout = window.setTimeout(() => setLoadState("error"), 12e3);
|
|
119
|
-
const handleStyleLoad = () => {
|
|
120
|
-
window.clearTimeout(styleLoadTimeout);
|
|
121
|
-
setLoadState("loaded");
|
|
122
|
-
};
|
|
123
|
-
const handleStyleLoading = () => setLoadState("loading");
|
|
124
|
-
activeStyleRef.current = activeStyle;
|
|
125
|
-
map.once("styledataloading", handleStyleLoading);
|
|
126
|
-
map.setStyle(activeStyle, { diff: false });
|
|
127
|
-
map.once("style.load", handleStyleLoad);
|
|
128
|
-
return () => {
|
|
129
|
-
window.clearTimeout(styleLoadTimeout);
|
|
130
|
-
map.off("style.load", handleStyleLoad);
|
|
131
|
-
map.off("styledataloading", handleStyleLoading);
|
|
132
|
-
};
|
|
133
|
-
}, [activeStyle, map]);
|
|
134
|
-
useEffect(() => {
|
|
135
|
-
if (!map) return;
|
|
136
|
-
const currentCenter = map.getCenter();
|
|
137
|
-
const centerChanged = currentCenter.lng !== longitude || currentCenter.lat !== latitude;
|
|
138
|
-
const zoomChanged = zoomRef.current !== zoom;
|
|
139
|
-
zoomRef.current = zoom;
|
|
140
|
-
if (!centerChanged && !zoomChanged) return;
|
|
141
|
-
map.easeTo({
|
|
142
|
-
center: [longitude, latitude],
|
|
143
|
-
duration: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : 350,
|
|
144
|
-
...zoomChanged ? { zoom } : {}
|
|
145
|
-
});
|
|
146
|
-
}, [latitude, longitude, map, zoom]);
|
|
147
|
-
return /* @__PURE__ */ jsx(InteractiveMapContext, { value: map, children: /* @__PURE__ */ jsxs(
|
|
148
|
-
"div",
|
|
149
|
-
{
|
|
150
|
-
ref: containerRef,
|
|
151
|
-
className: mergeClassNames("aui-interactive-map", className),
|
|
152
|
-
"data-load-state": loadState,
|
|
153
|
-
"data-slot": "agent-ui-interactive-map",
|
|
154
|
-
children: [
|
|
155
|
-
loadState === "loading" ? /* @__PURE__ */ jsx("div", { "aria-label": "Loading map", className: "aui-interactive-map__loader", role: "status", children: /* @__PURE__ */ jsx("span", {}) }) : null,
|
|
156
|
-
loadState === "error" ? /* @__PURE__ */ jsxs("div", { className: "aui-interactive-map__error", role: "status", children: [
|
|
157
|
-
/* @__PURE__ */ jsx("strong", { children: "Map unavailable" }),
|
|
158
|
-
/* @__PURE__ */ jsx("span", { children: "Location results remain available." })
|
|
159
|
-
] }) : null,
|
|
160
|
-
map ? children : null
|
|
161
|
-
]
|
|
162
|
-
}
|
|
163
|
-
) });
|
|
164
|
-
}
|
|
165
|
-
function InteractiveMapMarker({ children, latitude, longitude }) {
|
|
166
|
-
const map = useContext(InteractiveMapContext);
|
|
167
|
-
const initialPositionRef = useRef({ latitude, longitude });
|
|
168
|
-
const [marker, setMarker] = useState(null);
|
|
169
|
-
useEffect(() => {
|
|
170
|
-
const nextElement = document.createElement("div");
|
|
171
|
-
const initialPosition = initialPositionRef.current;
|
|
172
|
-
const nextMarker = new MapLibreGL.Marker({ element: nextElement }).setLngLat([
|
|
173
|
-
initialPosition.longitude,
|
|
174
|
-
initialPosition.latitude
|
|
175
|
-
]);
|
|
176
|
-
nextElement.className = "aui-interactive-map__marker-host";
|
|
177
|
-
setMarker(nextMarker);
|
|
178
|
-
return () => {
|
|
179
|
-
nextMarker.remove();
|
|
180
|
-
};
|
|
181
|
-
}, []);
|
|
182
|
-
useEffect(() => {
|
|
183
|
-
if (!map || !marker) return;
|
|
184
|
-
marker.addTo(map);
|
|
185
|
-
const markerElement = marker.getElement();
|
|
186
|
-
markerElement.removeAttribute("aria-label");
|
|
187
|
-
markerElement.removeAttribute("role");
|
|
188
|
-
markerElement.removeAttribute("tabindex");
|
|
189
|
-
return () => {
|
|
190
|
-
marker.remove();
|
|
191
|
-
};
|
|
192
|
-
}, [map, marker]);
|
|
193
|
-
useEffect(() => {
|
|
194
|
-
marker?.setLngLat([longitude, latitude]);
|
|
195
|
-
}, [latitude, longitude, marker]);
|
|
196
|
-
return marker ? createPortal(
|
|
197
|
-
/* @__PURE__ */ jsx("div", { className: "aui-interactive-map__marker-content", children }),
|
|
198
|
-
marker.getElement()
|
|
199
|
-
) : null;
|
|
200
|
-
}
|
|
201
|
-
function ControlButton({ children, label, ...props }) {
|
|
202
|
-
return /* @__PURE__ */ jsx(
|
|
203
|
-
"button",
|
|
204
|
-
{
|
|
205
|
-
"aria-label": label,
|
|
206
|
-
className: "aui-interactive-map__control-button",
|
|
207
|
-
type: "button",
|
|
208
|
-
...props,
|
|
209
|
-
children
|
|
210
|
-
}
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
function PlusIcon(props) {
|
|
214
|
-
return /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", fill: "none", viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ jsx("path", { d: "M8 3v10M3 8h10", stroke: "currentColor", strokeLinecap: "round", strokeWidth: "1.5" }) });
|
|
215
|
-
}
|
|
216
|
-
function MinusIcon(props) {
|
|
217
|
-
return /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", fill: "none", viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ jsx("path", { d: "M3 8h10", stroke: "currentColor", strokeLinecap: "round", strokeWidth: "1.5" }) });
|
|
218
|
-
}
|
|
219
|
-
function CompassIcon(props) {
|
|
220
|
-
return /* @__PURE__ */ jsxs("svg", { "aria-hidden": "true", fill: "none", viewBox: "0 0 24 24", ...props, children: [
|
|
221
|
-
/* @__PURE__ */ jsx("path", { d: "M12 2 16 12h-4V2Z", "data-needle": "north-right" }),
|
|
222
|
-
/* @__PURE__ */ jsx("path", { d: "m12 2-4 10h4V2Z", "data-needle": "north-left" }),
|
|
223
|
-
/* @__PURE__ */ jsx("path", { d: "m12 22 4-10h-4v10Z", "data-needle": "south-right" }),
|
|
224
|
-
/* @__PURE__ */ jsx("path", { d: "m12 22-4-10h4v10Z", "data-needle": "south-left" })
|
|
225
|
-
] });
|
|
226
|
-
}
|
|
227
|
-
function InteractiveMapControls() {
|
|
228
|
-
const map = useContext(InteractiveMapContext);
|
|
229
|
-
const compassRef = useRef(null);
|
|
230
|
-
const updateCompass = useCallback(() => {
|
|
231
|
-
if (!map || !compassRef.current) return;
|
|
232
|
-
compassRef.current.style.transform = `rotateX(${map.getPitch()}deg) rotateZ(${-map.getBearing()}deg)`;
|
|
233
|
-
}, [map]);
|
|
234
|
-
useEffect(() => {
|
|
235
|
-
if (!map) return;
|
|
236
|
-
map.on("pitch", updateCompass);
|
|
237
|
-
map.on("rotate", updateCompass);
|
|
238
|
-
updateCompass();
|
|
239
|
-
return () => {
|
|
240
|
-
map.off("pitch", updateCompass);
|
|
241
|
-
map.off("rotate", updateCompass);
|
|
242
|
-
};
|
|
243
|
-
}, [map, updateCompass]);
|
|
244
|
-
return /* @__PURE__ */ jsxs("div", { className: "aui-interactive-map__controls", "data-slot": "agent-ui-map-controls", children: [
|
|
245
|
-
/* @__PURE__ */ jsxs("div", { className: "aui-interactive-map__control-group", children: [
|
|
246
|
-
/* @__PURE__ */ jsx(
|
|
247
|
-
ControlButton,
|
|
248
|
-
{
|
|
249
|
-
label: "Zoom in",
|
|
250
|
-
onClick: () => map?.zoomTo(map.getZoom() + 1, { duration: 250 }),
|
|
251
|
-
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
252
|
-
}
|
|
253
|
-
),
|
|
254
|
-
/* @__PURE__ */ jsx(
|
|
255
|
-
ControlButton,
|
|
256
|
-
{
|
|
257
|
-
label: "Zoom out",
|
|
258
|
-
onClick: () => map?.zoomTo(map.getZoom() - 1, { duration: 250 }),
|
|
259
|
-
children: /* @__PURE__ */ jsx(MinusIcon, {})
|
|
260
|
-
}
|
|
261
|
-
)
|
|
262
|
-
] }),
|
|
263
|
-
/* @__PURE__ */ jsx("div", { className: "aui-interactive-map__control-group", children: /* @__PURE__ */ jsx(
|
|
264
|
-
ControlButton,
|
|
265
|
-
{
|
|
266
|
-
label: "Reset bearing to north",
|
|
267
|
-
onClick: () => map?.resetNorthPitch({ duration: 250 }),
|
|
268
|
-
children: /* @__PURE__ */ jsx(CompassIcon, { ref: compassRef, className: "aui-interactive-map__compass" })
|
|
269
|
-
}
|
|
270
|
-
) })
|
|
271
|
-
] });
|
|
272
|
-
}
|
|
273
|
-
var InteractiveMap = Object.assign(InteractiveMapRoot, {
|
|
274
|
-
Controls: InteractiveMapControls,
|
|
275
|
-
Marker: InteractiveMapMarker
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
// ../agent-ui/src/components/display-information/map/interactive-map-surface.tsx
|
|
279
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
280
|
-
var mapStyles = {
|
|
281
|
-
dark: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
|
|
282
|
-
light: "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json"
|
|
283
|
-
};
|
|
284
|
-
var resultRailPadding = { bottom: 132, left: 0, right: 0, top: 0 };
|
|
285
|
-
var ratingFormatter = new Intl.NumberFormat(void 0, {
|
|
286
|
-
maximumFractionDigits: 1,
|
|
287
|
-
minimumFractionDigits: 1
|
|
288
|
-
});
|
|
289
|
-
function InteractiveMapSurface({
|
|
290
|
-
component,
|
|
291
|
-
onSelect,
|
|
292
|
-
selectedLocationId
|
|
293
|
-
}) {
|
|
294
|
-
const layout = createMapLayout(component);
|
|
295
|
-
const center = getMapSelectionCenter(component.locations, selectedLocationId, layout.center);
|
|
296
|
-
return /* @__PURE__ */ jsxs2(
|
|
297
|
-
"div",
|
|
298
|
-
{
|
|
299
|
-
"aria-label": `${component.title} map with ${component.locations.length} locations`,
|
|
300
|
-
className: "aui-map__surface",
|
|
301
|
-
"data-renderer": "interactive",
|
|
302
|
-
"data-slot": "agent-ui-map-surface",
|
|
303
|
-
role: "region",
|
|
304
|
-
children: [
|
|
305
|
-
/* @__PURE__ */ jsxs2(
|
|
306
|
-
InteractiveMap,
|
|
307
|
-
{
|
|
308
|
-
center: [center.longitude, center.latitude],
|
|
309
|
-
className: "aui-map__interactive-map",
|
|
310
|
-
dragRotate: false,
|
|
311
|
-
padding: resultRailPadding,
|
|
312
|
-
pitchWithRotate: false,
|
|
313
|
-
styles: mapStyles,
|
|
314
|
-
zoom: layout.zoom,
|
|
315
|
-
children: [
|
|
316
|
-
component.locations.map((location, index) => {
|
|
317
|
-
const selected = location.id === selectedLocationId;
|
|
318
|
-
const markerLabel = location.rating !== void 0 ? ratingFormatter.format(location.rating) : location.relevance !== void 0 ? `${Math.round(location.relevance * 100)}%` : String(index + 1);
|
|
319
|
-
const accessibleLabel = `Select ${location.title} on map${location.rating === void 0 ? "" : `, rated ${ratingFormatter.format(location.rating)} out of 5`}`;
|
|
320
|
-
return /* @__PURE__ */ jsx2(
|
|
321
|
-
InteractiveMap.Marker,
|
|
322
|
-
{
|
|
323
|
-
latitude: location.latitude,
|
|
324
|
-
longitude: location.longitude,
|
|
325
|
-
children: /* @__PURE__ */ jsxs2(
|
|
326
|
-
"button",
|
|
327
|
-
{
|
|
328
|
-
"aria-label": accessibleLabel,
|
|
329
|
-
"aria-pressed": selected,
|
|
330
|
-
className: "aui-map__marker",
|
|
331
|
-
"data-renderer": "interactive",
|
|
332
|
-
"data-selected": selected,
|
|
333
|
-
"data-slot": "agent-ui-map-marker",
|
|
334
|
-
title: location.title,
|
|
335
|
-
type: "button",
|
|
336
|
-
onClick: () => onSelect(location),
|
|
337
|
-
children: [
|
|
338
|
-
/* @__PURE__ */ jsx2(StarFill, { "aria-hidden": "true" }),
|
|
339
|
-
/* @__PURE__ */ jsx2("span", { children: markerLabel })
|
|
340
|
-
]
|
|
341
|
-
}
|
|
342
|
-
)
|
|
343
|
-
},
|
|
344
|
-
location.id
|
|
345
|
-
);
|
|
346
|
-
}),
|
|
347
|
-
/* @__PURE__ */ jsx2(InteractiveMap.Controls, {})
|
|
348
|
-
]
|
|
349
|
-
}
|
|
350
|
-
),
|
|
351
|
-
/* @__PURE__ */ jsxs2("span", { className: "aui-map__attribution", "data-slot": "agent-ui-map-attribution", children: [
|
|
352
|
-
/* @__PURE__ */ jsx2("a", { href: "https://www.openstreetmap.org/copyright", rel: "noreferrer", target: "_blank", children: "\xA9 OpenStreetMap" }),
|
|
353
|
-
/* @__PURE__ */ jsx2("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
354
|
-
/* @__PURE__ */ jsx2("a", { href: "https://carto.com/attributions", rel: "noreferrer", target: "_blank", children: "\xA9 CARTO" })
|
|
355
|
-
] })
|
|
356
|
-
]
|
|
357
|
-
}
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
export {
|
|
361
|
-
InteractiveMapSurface
|
|
362
|
-
};
|