@heroui/agent 0.2.0-beta.1
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 +64 -0
- package/LICENSE +21 -0
- package/README.md +205 -0
- package/dist/chart-content-VZ66GD22.js +1391 -0
- package/dist/chunk-3FG5NRTX.js +9 -0
- package/dist/chunk-CU6MPKAJ.js +359 -0
- package/dist/chunk-DW4AQRM5.js +297 -0
- package/dist/chunk-GDDNN2XY.js +954 -0
- package/dist/chunk-RQCTC4JB.js +1084 -0
- package/dist/chunk-TOOT6SZ2.js +74 -0
- package/dist/chunk-VJA52U5P.js +137 -0
- package/dist/component-renderer-IBJDNXSO.js +9780 -0
- package/dist/contracts.d.ts +1293 -0
- package/dist/contracts.js +2325 -0
- package/dist/css/index.css +2 -0
- package/dist/embed-runtime-XOPQY7Z5.js +7254 -0
- package/dist/identity-NYCXY1mT.d.ts +164 -0
- package/dist/index.d.ts +594 -0
- package/dist/index.js +28 -0
- package/dist/interactive-map-surface-67KHT3VB.js +362 -0
- package/dist/next.d.ts +4 -0
- package/dist/next.js +22 -0
- package/dist/server.d.ts +31 -0
- package/dist/server.js +256 -0
- package/package.json +133 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mergeClassNames
|
|
3
|
+
} from "./chunk-3FG5NRTX.js";
|
|
4
|
+
|
|
5
|
+
// ../agent-ui/src/components/display-information/card/card.tsx
|
|
6
|
+
import { createContext, useContext } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
var CardVariantContext = createContext(void 0);
|
|
9
|
+
function CardVariantProvider({ children, variant }) {
|
|
10
|
+
return /* @__PURE__ */ jsx(CardVariantContext, { value: variant, children });
|
|
11
|
+
}
|
|
12
|
+
function Card({
|
|
13
|
+
actions,
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
|
+
"data-component-kind": componentKind,
|
|
17
|
+
description,
|
|
18
|
+
footer,
|
|
19
|
+
legend,
|
|
20
|
+
title,
|
|
21
|
+
variant
|
|
22
|
+
}) {
|
|
23
|
+
const inheritedVariant = useContext(CardVariantContext);
|
|
24
|
+
const hasHeader = title != null || description != null || legend != null || actions != null;
|
|
25
|
+
const resolvedVariant = inheritedVariant ?? variant ?? "surface";
|
|
26
|
+
return /* @__PURE__ */ jsxs(
|
|
27
|
+
"section",
|
|
28
|
+
{
|
|
29
|
+
className: mergeClassNames("aui-card", className),
|
|
30
|
+
"data-component-kind": componentKind,
|
|
31
|
+
"data-has-footer": footer != null,
|
|
32
|
+
"data-has-header": hasHeader,
|
|
33
|
+
"data-slot": "agent-ui-card",
|
|
34
|
+
"data-variant": resolvedVariant,
|
|
35
|
+
children: [
|
|
36
|
+
hasHeader ? /* @__PURE__ */ jsxs(
|
|
37
|
+
"header",
|
|
38
|
+
{
|
|
39
|
+
className: "aui-card__header",
|
|
40
|
+
"data-has-actions": actions != null,
|
|
41
|
+
"data-slot": "agent-ui-card-header",
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ jsxs("span", { className: "aui-card__heading", "data-slot": "agent-ui-card-heading", children: [
|
|
44
|
+
title != null ? /* @__PURE__ */ jsx("span", { className: "aui-card__title", "data-slot": "agent-ui-card-title", children: title }) : null,
|
|
45
|
+
description != null ? /* @__PURE__ */ jsx("span", { className: "aui-card__description", "data-slot": "agent-ui-card-description", children: description }) : null
|
|
46
|
+
] }),
|
|
47
|
+
actions != null ? /* @__PURE__ */ jsx("span", { className: "aui-card__actions", "data-slot": "agent-ui-card-actions", children: actions }) : null,
|
|
48
|
+
legend
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
) : null,
|
|
52
|
+
/* @__PURE__ */ jsx("div", { className: "aui-card__content", "data-slot": "agent-ui-card-content", children }),
|
|
53
|
+
footer != null ? /* @__PURE__ */ jsx("footer", { className: "aui-card__footer", "data-slot": "agent-ui-card-footer", children: footer }) : null
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ../agent-ui/src/utils/overlay-portal.ts
|
|
60
|
+
function resolveOverlayPortalContainer(node) {
|
|
61
|
+
if (!node) return void 0;
|
|
62
|
+
const overlayRoot = node.closest("[data-agent-overlay-root], dialog");
|
|
63
|
+
if (overlayRoot) {
|
|
64
|
+
return overlayRoot.querySelector("[data-agent-overlay-portal]") ?? overlayRoot;
|
|
65
|
+
}
|
|
66
|
+
const root = node.getRootNode();
|
|
67
|
+
return typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root : void 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
CardVariantProvider,
|
|
72
|
+
Card,
|
|
73
|
+
resolveOverlayPortalContainer
|
|
74
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// ../agent-ui/src/components/display-information/map/map-utils.ts
|
|
2
|
+
var MAX_MERCATOR_LATITUDE = 85.051129;
|
|
3
|
+
var TILE_SIZE = 256;
|
|
4
|
+
var TILE_RADIUS_X = 3;
|
|
5
|
+
var TILE_RADIUS_Y = 2;
|
|
6
|
+
function getMapSelectionCenter(locations, selectedLocationId, fallback) {
|
|
7
|
+
const selectedLocation = locations.find((location) => location.id === selectedLocationId);
|
|
8
|
+
return selectedLocation ? { latitude: selectedLocation.latitude, longitude: selectedLocation.longitude } : fallback;
|
|
9
|
+
}
|
|
10
|
+
function clamp(value, min, max) {
|
|
11
|
+
return Math.min(Math.max(value, min), max);
|
|
12
|
+
}
|
|
13
|
+
function project({ latitude, longitude }, zoom) {
|
|
14
|
+
const scale = TILE_SIZE * 2 ** zoom;
|
|
15
|
+
const clampedLatitude = clamp(latitude, -MAX_MERCATOR_LATITUDE, MAX_MERCATOR_LATITUDE);
|
|
16
|
+
const latitudeRadians = clampedLatitude * Math.PI / 180;
|
|
17
|
+
const sinLatitude = Math.sin(latitudeRadians);
|
|
18
|
+
return {
|
|
19
|
+
x: (longitude + 180) / 360 * scale,
|
|
20
|
+
y: (0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI)) * scale
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function wrapWorldDelta(delta, worldSize) {
|
|
24
|
+
if (delta > worldSize / 2) return delta - worldSize;
|
|
25
|
+
if (delta < -worldSize / 2) return delta + worldSize;
|
|
26
|
+
return delta;
|
|
27
|
+
}
|
|
28
|
+
function resolveLongitudeCenter(locations) {
|
|
29
|
+
if (locations.length === 1) return locations[0].longitude;
|
|
30
|
+
const longitudes = locations.map((location) => (location.longitude + 360) % 360).sort((first, second) => first - second);
|
|
31
|
+
let largestGap = -1;
|
|
32
|
+
let arcStart = longitudes[0];
|
|
33
|
+
for (let index = 0; index < longitudes.length; index += 1) {
|
|
34
|
+
const current = longitudes[index];
|
|
35
|
+
const next = index === longitudes.length - 1 ? longitudes[0] + 360 : longitudes[index + 1];
|
|
36
|
+
const gap = next - current;
|
|
37
|
+
if (gap > largestGap) {
|
|
38
|
+
largestGap = gap;
|
|
39
|
+
arcStart = next % 360;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const center = (arcStart + (360 - largestGap) / 2) % 360;
|
|
43
|
+
return center > 180 ? center - 360 : center;
|
|
44
|
+
}
|
|
45
|
+
function resolveCenter(locations, center) {
|
|
46
|
+
if (center) return center;
|
|
47
|
+
let minLatitude = locations[0].latitude;
|
|
48
|
+
let maxLatitude = locations[0].latitude;
|
|
49
|
+
for (const location of locations.slice(1)) {
|
|
50
|
+
minLatitude = Math.min(minLatitude, location.latitude);
|
|
51
|
+
maxLatitude = Math.max(maxLatitude, location.latitude);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
latitude: (minLatitude + maxLatitude) / 2,
|
|
55
|
+
longitude: resolveLongitudeCenter(locations)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function resolveZoom(locations, center, zoom, maximumZoom) {
|
|
59
|
+
if (zoom !== void 0) return clamp(zoom, 1, maximumZoom);
|
|
60
|
+
if (locations.length === 1) return Math.min(14, maximumZoom);
|
|
61
|
+
for (let candidate = Math.min(16, maximumZoom); candidate >= 2; candidate -= 1) {
|
|
62
|
+
const centerPoint = project(center, candidate);
|
|
63
|
+
const worldSize = TILE_SIZE * 2 ** candidate;
|
|
64
|
+
const first = project(locations[0], candidate);
|
|
65
|
+
const firstX = wrapWorldDelta(first.x - centerPoint.x, worldSize);
|
|
66
|
+
const firstY = first.y - centerPoint.y;
|
|
67
|
+
let minX = firstX;
|
|
68
|
+
let maxX = firstX;
|
|
69
|
+
let minY = firstY;
|
|
70
|
+
let maxY = firstY;
|
|
71
|
+
for (const location of locations.slice(1)) {
|
|
72
|
+
const point = project(location, candidate);
|
|
73
|
+
const pointX = wrapWorldDelta(point.x - centerPoint.x, worldSize);
|
|
74
|
+
const pointY = point.y - centerPoint.y;
|
|
75
|
+
minX = Math.min(minX, pointX);
|
|
76
|
+
maxX = Math.max(maxX, pointX);
|
|
77
|
+
minY = Math.min(minY, pointY);
|
|
78
|
+
maxY = Math.max(maxY, pointY);
|
|
79
|
+
}
|
|
80
|
+
if (maxX - minX <= 420 && maxY - minY <= 190) return candidate;
|
|
81
|
+
}
|
|
82
|
+
return Math.min(2, maximumZoom);
|
|
83
|
+
}
|
|
84
|
+
function createMapLayout(component, maximumZoom = 18) {
|
|
85
|
+
maximumZoom = Number.isFinite(maximumZoom) ? clamp(Math.floor(maximumZoom), 1, 18) : 18;
|
|
86
|
+
const center = resolveCenter(component.locations, component.viewport?.center);
|
|
87
|
+
const zoom = resolveZoom(component.locations, center, component.viewport?.zoom, maximumZoom);
|
|
88
|
+
const centerPoint = project(center, zoom);
|
|
89
|
+
const centerTileX = Math.floor(centerPoint.x / TILE_SIZE);
|
|
90
|
+
const centerTileY = Math.floor(centerPoint.y / TILE_SIZE);
|
|
91
|
+
const tileCount = 2 ** zoom;
|
|
92
|
+
const tiles = [];
|
|
93
|
+
for (let y = centerTileY - TILE_RADIUS_Y; y <= centerTileY + TILE_RADIUS_Y; y += 1) {
|
|
94
|
+
if (y < 0 || y >= tileCount) continue;
|
|
95
|
+
for (let x = centerTileX - TILE_RADIUS_X; x <= centerTileX + TILE_RADIUS_X; x += 1) {
|
|
96
|
+
const wrappedX = (x % tileCount + tileCount) % tileCount;
|
|
97
|
+
tiles.push({
|
|
98
|
+
key: `${zoom}-${x}-${y}`,
|
|
99
|
+
x: x * TILE_SIZE - centerPoint.x,
|
|
100
|
+
xIndex: wrappedX,
|
|
101
|
+
y: y * TILE_SIZE - centerPoint.y,
|
|
102
|
+
yIndex: y,
|
|
103
|
+
zoom
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
center,
|
|
109
|
+
points: component.locations.map((location) => {
|
|
110
|
+
const point = project(location, zoom);
|
|
111
|
+
const worldSize = TILE_SIZE * 2 ** zoom;
|
|
112
|
+
return {
|
|
113
|
+
id: location.id,
|
|
114
|
+
x: wrapWorldDelta(point.x - centerPoint.x, worldSize),
|
|
115
|
+
y: point.y - centerPoint.y
|
|
116
|
+
};
|
|
117
|
+
}),
|
|
118
|
+
tiles,
|
|
119
|
+
zoom
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function getInitialMapLocationId(component) {
|
|
123
|
+
if (component.initialLocationId && component.locations.some((location) => location.id === component.initialLocationId)) {
|
|
124
|
+
return component.initialLocationId;
|
|
125
|
+
}
|
|
126
|
+
let best = component.locations[0];
|
|
127
|
+
for (const location of component.locations.slice(1)) {
|
|
128
|
+
if ((location.relevance ?? -1) > (best.relevance ?? -1)) best = location;
|
|
129
|
+
}
|
|
130
|
+
return best.id;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export {
|
|
134
|
+
getMapSelectionCenter,
|
|
135
|
+
createMapLayout,
|
|
136
|
+
getInitialMapLocationId
|
|
137
|
+
};
|