@box-kite/react 2.0.1 → 2.2.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/.claude/rules/box-kite-rules.md +24 -2
- package/.claude/skills/box-kite/SKILL.md +27 -5
- package/.claude/skills/box-kite/references/components.md +8 -3
- package/.claude/skills/box-kite/references/patterns.md +24 -1
- package/.claude/skills/box-kite/references/styling.md +23 -0
- package/.cursor/rules/box-kite.mdc +25 -3
- package/AGENTS.md +28 -3
- package/BOX_AI_CONTEXT.md +732 -12
- package/BOX_KITE_AI_CONTEXT.md +732 -12
- package/README.md +41 -9
- package/box.cjs +1 -1
- package/box.d.ts +13 -2
- package/box.mjs +25 -18
- package/catalog.cjs +1 -0
- package/catalog.d.ts +8 -0
- package/catalog.mjs +2347 -0
- package/client.cjs +1 -1
- package/client.mjs +59 -53
- package/components/agent.cjs +1 -0
- package/components/agent.d.ts +215 -0
- package/components/agent.mjs +405 -0
- package/components/button.cjs +1 -1
- package/components/button.mjs +10 -14
- package/components/chart.d.ts +1 -0
- package/components/dashboard.cjs +1 -0
- package/components/dashboard.d.ts +121 -0
- package/components/dashboard.mjs +690 -0
- package/components/dataGrid/components/dataGridBody.d.ts +2 -1
- package/components/dataGrid/components/dataGridDetailRow.d.ts +13 -2
- package/components/dataGrid/components/dataGridGroupRow.d.ts +13 -2
- package/components/dataGrid/components/dataGridRow.d.ts +13 -2
- package/components/dataGrid/contracts/dataGridContract.d.ts +66 -2
- package/components/dataGrid/models/cellModel.d.ts +3 -0
- package/components/dataGrid/models/editModel.d.ts +27 -0
- package/components/dataGrid/models/exportModel.d.ts +2 -1
- package/components/dataGrid/models/gridModel.d.ts +3 -0
- package/components/dataGrid/models/rangeModel.d.ts +119 -0
- package/components/dataGrid/models/viewportModel.d.ts +23 -2
- package/components/dataGrid/useGridNavigation.d.ts +10 -2
- package/components/dataGrid.cjs +4 -1
- package/components/dataGrid.d.ts +3 -0
- package/components/dataGrid.mjs +1056 -765
- package/components/flex.cjs +1 -1
- package/components/flex.mjs +10 -13
- package/components/form.cjs +1 -1
- package/components/form.mjs +7 -7
- package/components/grid.cjs +1 -1
- package/components/grid.mjs +10 -13
- package/components/markdown.cjs +1 -0
- package/components/markdown.d.ts +55 -0
- package/components/markdown.mjs +179 -0
- package/components/menu.cjs +1 -1
- package/components/menu.mjs +16 -16
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +35 -34
- package/components/popover.cjs +1 -1
- package/components/popover.mjs +4 -4
- package/components/semantics.cjs +1 -1
- package/components/semantics.d.ts +29 -29
- package/components/semantics.mjs +9 -13
- package/components/skeleton.cjs +1 -0
- package/components/skeleton.d.ts +34 -0
- package/components/skeleton.mjs +25 -0
- package/components/svg.cjs +1 -1
- package/components/svg.mjs +38 -44
- package/components/textarea.cjs +1 -1
- package/components/textarea.mjs +12 -16
- package/components/textbox.cjs +1 -1
- package/components/textbox.mjs +12 -16
- package/components/toaster.cjs +1 -1
- package/components/toaster.mjs +42 -43
- package/components/visuallyHidden.cjs +1 -1
- package/components/visuallyHidden.mjs +10 -13
- package/dashboardSchema.cjs +1 -0
- package/dashboardSchema.mjs +78 -0
- package/docs/a11y.md +2 -3
- package/docs/catalog.md +451 -0
- package/docs/components.md +4 -0
- package/docs/index.md +3 -0
- package/docs/interop.md +237 -0
- package/docs/mcp.md +70 -0
- package/docs/props.md +135 -23
- package/interop.cjs +1 -0
- package/interop.d.ts +51 -0
- package/interop.mjs +454 -0
- package/layer.cjs +1 -1
- package/layer.mjs +61 -59
- package/mcp/src/data.d.ts +88 -0
- package/mcp/src/data.test.d.ts +1 -0
- package/mcp/src/engine.d.ts +23 -0
- package/mcp/src/index.d.ts +1 -0
- package/mcp/src/search.d.ts +26 -0
- package/mcp/src/search.test.d.ts +1 -0
- package/mcp/src/server.d.ts +18 -0
- package/mcp/src/server.test.d.ts +1 -0
- package/mcp/src/styles.d.ts +27 -0
- package/mcp/src/styles.test.d.ts +1 -0
- package/mcp/src/tools.d.ts +18 -0
- package/mcp/src/vocabulary.d.ts +41 -0
- package/package.json +170 -37
- package/react/boxComponent.d.ts +10 -0
- package/react/popover/useTopLayer.d.ts +17 -0
- package/react/spec/renderSpec.d.ts +51 -0
- package/react/spec/specBoundary.d.ts +25 -0
- package/react/spec/specRegistry.d.ts +42 -0
- package/react/spec/specRenderer.d.ts +10 -0
- package/react/theme/theme.d.ts +10 -0
- package/react/useStyles.d.ts +2 -0
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +44 -37
- package/registry/blocks/dashboard-shell/dashboard-shell.d.ts +22 -0
- package/registry/blocks/dashboard-shell/dashboard-stats.d.ts +13 -0
- package/registry/blocks/data-grid/invoice-rows.d.ts +15 -0
- package/registry/blocks/data-grid/invoices-grid.d.ts +1 -0
- package/registry/blocks/settings-form/settings-form.d.ts +17 -0
- package/rsc.cjs +1 -1
- package/rsc.d.ts +11 -1
- package/rsc.mjs +15 -12
- package/spec.cjs +2 -0
- package/spec.d.ts +12 -0
- package/spec.mjs +382 -0
- package/specData.cjs +1 -0
- package/specData.mjs +69 -0
- package/specDefs.cjs +1 -0
- package/specDefs.mjs +33 -0
- package/specSchema.cjs +1 -0
- package/specSchema.mjs +88 -0
- package/ssg.cjs +1 -1
- package/ssg.d.ts +8 -2
- package/ssg.mjs +13 -9
- package/utils/agent/agentUtils.d.ts +81 -0
- package/utils/catalog/catalogContracts.d.ts +19 -0
- package/utils/catalog/catalogManifest.d.ts +8 -0
- package/utils/dashboard/dashboardSchema.d.ts +18 -0
- package/utils/dashboard/dashboardUtils.d.ts +97 -0
- package/utils/environment/environmentUtils.d.ts +5 -0
- package/utils/interop/a2uiInterop.d.ts +82 -0
- package/utils/interop/assistantUiInterop.d.ts +34 -0
- package/utils/interop/toolInterop.d.ts +30 -0
- package/utils/spec/specData.d.ts +19 -0
- package/utils/spec/specDefs.d.ts +11 -0
- package/utils/spec/specProps.d.ts +15 -0
- package/utils/spec/specSchema.d.ts +23 -0
- package/utils/spec/specTypes.d.ts +71 -0
- package/utils/spec/specValidate.d.ts +10 -0
package/interop.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./specDefs.cjs"),t=require("./specData.cjs");var n;(function(e){let t={"input-streaming":`pending`,"input-available":`running`,"output-available":`success`,"output-error":`error`,"approval-requested":`approval`,"approval-responded":`approval`},n={inProgress:`pending`,executing:`running`,complete:`success`},r={running:`running`,complete:`success`,incomplete:`error`,"requires-action":`pending`};function i(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function a(e){return typeof e==`string`&&e!==``?e:void 0}function o(e){return e.input??e.args??e.argsText}function s(e){return e.output??e.result}function c(e){let c=i(e);if(c===null)return null;let l=o(c),u=s(c),d=a(c.state);if(d!==void 0&&d in t){let e=t[d];if(e!==`approval`)return{kind:`call`,status:e,decision:null,input:l,output:u,error:a(c.errorText)};let n=i(c.approval)?.approved;return{kind:`approval`,status:`pending`,decision:typeof n==`boolean`?n?`approved`:`rejected`:null,input:l}}let f=c.status,p=i(f);if(p!==null){let e=a(p.type)??``;return{kind:e===`requires-action`?`approval`:`call`,status:r[e]??`pending`,decision:null,input:l,output:u,error:a(i(p.error)?.message)??a(p.error)}}let m=a(f);if(m!==void 0&&m in n){let e=typeof c.respond==`function`&&m===`executing`;return{kind:e?`approval`:`call`,status:e?`pending`:n[m],decision:null,input:l,output:u}}return null}e.toolPart=c;function l(e,t){let n=i(t),r=a(n?.toolCallId);if(n===null||r===void 0)return e;let o=a(n.type),s=e[r]??{kind:`call`,status:`pending`,decision:null};return o===`TOOL_CALL_START`?{...e,[r]:{...s,kind:`call`,status:`pending`}}:o===`TOOL_CALL_ARGS`?{...e,[r]:{...s,status:`pending`}}:o===`TOOL_CALL_END`?{...e,[r]:{...s,status:`running`}}:o===`TOOL_CALL_RESULT`?{...e,[r]:{...s,status:`success`,output:n.content??n.result}}:o===`INTERRUPT`||o===`RUN_INTERRUPT`?{...e,[r]:{...s,kind:`approval`,status:`pending`}}:o===`RUN_ERROR`?{...e,[r]:{...s,status:`error`,error:a(n.message)}}:e}e.applyEvent=l})(n||={});var r=n,i;(function(t){let n=t.ROOT_ID=`root`,r=t.DEFAULT_SURFACE=`main`;t.EMPTY={surfaces:{},order:[]};function i(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function a(e){return typeof e==`string`&&e!==``?e:void 0}function o(e){return{id:e,components:{},data:{}}}function s(e,t,n){return{surfaces:{...e.surfaces,[t]:n},order:e.order.includes(t)?e.order:[...e.order,t]}}function c(e){let t=i(e),n=a(t?.id);if(t===null||n===void 0)return null;let r=t.component;if(typeof r==`string`){let{id:e,component:i,...a}=t;return{id:n,component:r,...a}}let o=i(r),[s]=o?Object.keys(o):[];return o===null||s===void 0?null:{id:n,component:s,...i(o[s])??{}}}function l(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function u(e){return e===void 0||e===``||e===`/`?[]:(e.startsWith(`/`)?e.slice(1):e).split(`/`).map(l)}function d(e,t){return t.reduce((e,t)=>i(e)?.[t],e)}function f(e,t,n){if(t.length===0)return n;let[r,...a]=t,o=i(e)??{};if(a.length>0)return{...o,[r]:f(o[r],a,n)};if(n!==void 0)return{...o,[r]:n};let{[r]:s,...c}=o;return c}function p(e){if(!Array.isArray(e))return{};let t={};for(let n of e){let e=i(n),r=a(e?.key);e!==null&&r!==void 0&&(`valueString`in e?t[r]=e.valueString:`valueNumber`in e?t[r]=e.valueNumber:`valueBoolean`in e?t[r]=e.valueBoolean:`valueMap`in e&&(t[r]=p(e.valueMap)))}return t}function m(e,t){let n=i(t);if(n===null)return e;let l=i(n.createSurface)??i(n.beginRendering);if(l!==null){let t=a(l.surfaceId)??r,n=e.surfaces[t]??o(t);return s(e,t,{...n,catalogId:a(l.catalogId)??n.catalogId,root:a(l.root)??n.root,theme:i(l.theme)??i(l.styles)??n.theme})}let m=i(n.updateComponents)??i(n.surfaceUpdate);if(m!==null){let t=a(m.surfaceId)??r,n=e.surfaces[t]??o(t),i={...n.components},l=!1;for(let e of Array.isArray(m.components)?m.components:[]){let t=c(e);t!==null&&(i[t.id]=t,l=!0)}return l||!e.surfaces[t]?s(e,t,{...n,components:i}):e}let h=i(n.updateDataModel)??i(n.dataModelUpdate);if(h!==null){let t=a(h.surfaceId)??r,n=e.surfaces[t]??o(t),c=u(a(h.path)),l=`contents`in h?{...i(d(n.data,c))??{},...p(h.contents)}:void 0,m=f(n.data,c,l??h.value);return s(e,t,{...n,data:i(m)??{}})}let g=i(n.deleteSurface);if(g!==null){let t=a(g.surfaceId)??r;if(!e.surfaces[t])return e;let{[t]:n,...i}=e.surfaces;return{surfaces:i,order:e.order.filter(e=>e!==t)}}return e}t.apply=m;function h(e,t){return t.reduce(m,e)}t.applyAll=h;function g(e,t){return t===void 0?e.surfaces[e.order[0]]??null:e.surfaces[t]??null}t.surface=g;function _(e){let t=i(e);return t===null?e:`literalString`in t?t.literalString:`literalNumber`in t?t.literalNumber:`literalBoolean`in t?t.literalBoolean:typeof t.path==`string`?{$data:t.path}:e}function v(e){let t=i(e);return t===null?a(e):a(i(t.event)?.name)??a(t.name)}function y(e){let t=a(e.child);if(t!==void 0)return{ids:[t]};let n=e.children;if(Array.isArray(n))return{ids:n.filter(e=>typeof e==`string`)};let r=i(n);if(r===null)return{ids:[]};if(Array.isArray(r.explicitList))return{ids:r.explicitList.filter(e=>typeof e==`string`)};let o=i(r.template)??r,s=a(o.componentId),c=a(o.path)??a(o.dataBinding);return s!==void 0&&c!==void 0?{ids:[],template:{componentId:s,path:c}}:{ids:[]}}let b=new Set([`id`,`component`,`child`,`children`,`action`]);function x(e,t,n,r,i){let a=e.components[t];if(a===void 0||i>32||r.has(t))return null;let o=new Set(n.catalog?.components[a.component]?.events??[]),s={},c={};for(let[e,t]of Object.entries(a)){if(b.has(e))continue;if(!o.has(e)){s[e]=_(t);continue}let n=v(t);n!==void 0&&(c[e]=n)}let l=v(a.action);l!==void 0&&(c.action=l);let{ids:u,template:d}=y(a),f=new Set([...r,t]),p=[];for(let t of u){let r=x(e,t,n,f,i+1);r!==null&&p.push(r)}if(d!==void 0){let t=x(e,d.componentId,n,f,i+1);t!==null&&p.push({...t,repeat:{$data:d.path}})}return{type:a.component,key:t,...Object.keys(s).length?{props:s}:{},...p.length?{children:p}:{},...Object.keys(c).length?{on:c}:{}}}function S(e,t={}){return e===null?null:x(e,t.root??e.root??n,t,new Set,0)}t.toSpec=S;let C={type:`array`,items:{type:`string`},description:`The ids of this component’s children, each a component of its own in the same surface.`},w={type:`string`,description:`The name of an action the host handles.`};function T(e,t){let n=i(i(e.components)?.[t]);if(n===null)return null;let r=i(e.$defs);return r===null?n:{...n,$defs:r}}t.componentSchema=T;function E(t,n={}){let r=n.catalogId??`urn:box-kite:catalog:${t.version}`,i={},a={};for(let[n,r]of Object.entries(t.components)){let t=e.t.hoist(r.props,i);a[n]={type:`object`,description:r.description,properties:{id:{type:`string`,description:`This component’s id, unique within the surface.`},component:{type:`string`,enum:[n]},...t.properties??{},...Object.fromEntries(r.events.map(e=>[e,w])),...r.slots.length?{children:C}:{}},required:[`id`,`component`,...t.required??[]],additionalProperties:!1}}return{$schema:`https://json-schema.org/draft/2020-12/schema`,$id:r,catalogId:r,title:n.title??`${t.library} catalog`,description:n.description??t.rules.join(` `),...Object.keys(i).length?{$defs:i}:{},components:a}}t.catalogDocument=E})(i||={});var a=i,o;(function(e){function n(e,t){if(typeof e==`string`)return e;if(t>32||typeof e!=`object`||!e||typeof e.component!=`string`)return null;let r=(e.children??[]).map(e=>n(e,t+1)).filter(e=>e!==null);return{type:e.component,...e.key===void 0?{}:{key:e.key},...e.props?{props:e.props}:{},...r.length?{children:r}:{}}}function r(e){return e==null?[]:(Array.isArray(e.root)?e.root:[e.root]).map(e=>n(e,0)).filter(e=>typeof e==`object`&&!!e)}e.toSpec=r;function i(e,n,r,a){if(e==null)return null;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(t.t.isRef(e))return r.push({code:`data-binding`,path:n}),null;if(a>32||typeof e.type!=`string`)return null;let o=e;if(o.repeat&&r.push({code:`repeat`,path:n}),o.on)for(let e of Object.keys(o.on))r.push({code:`event`,path:`${n}.on.${e}`});let s=(o.children===void 0?[]:Array.isArray(o.children)?o.children:[o.children]).map((e,t)=>i(e,`${n}.children.${t}`,r,a+1)).filter(e=>e!==null);return{component:o.type,...o.key===void 0?{}:{key:o.key},...o.props?{props:o.props}:{},...s.length?{children:s}:{}}}function a(e){let t=[];return{spec:{root:(Array.isArray(e)?e:[e]).map((e,n)=>i(e,`root.${n}`,t,0)).filter(e=>e!==null)},losses:t}}e.fromSpec=a})(o||={});var s=o,c=r.toolPart,l=r.applyEvent,u=a.apply,d=a.applyAll,f=a.surface,p=a.toSpec,m=a.catalogDocument,h=a.componentSchema,g=a.EMPTY,_=s.toSpec,v=s.fromSpec;exports.A2uiInterop=a,exports.AssistantUiInterop=s,exports.ToolInterop=r,exports.a2uiApply=u,exports.a2uiApplyAll=d,exports.a2uiCatalog=m,exports.a2uiComponentSchema=h,exports.a2uiEmpty=g,exports.a2uiSurface=f,exports.a2uiToSpec=p,exports.applyToolEvent=l,exports.fromGenerativeUi=_,exports.toGenerativeUi=v,exports.toolPart=c;
|
package/interop.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { default as A2uiInterop } from './utils/interop/a2uiInterop';
|
|
2
|
+
import { default as AssistantUiInterop } from './utils/interop/assistantUiInterop';
|
|
3
|
+
import { default as ToolInterop } from './utils/interop/toolInterop';
|
|
4
|
+
/**
|
|
5
|
+
* `@box-kite/react/interop` — the agentic runtimes, in this library's shapes.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { toolPart, a2uiSurface, a2uiToSpec } from '@box-kite/react/interop';
|
|
9
|
+
*
|
|
10
|
+
* const part = toolPart(message); // AI SDK, assistant-ui or CopilotKit
|
|
11
|
+
* const spec = a2uiToSpec(a2uiSurface(state), { catalog }); // an A2UI stream, as a <SpecRenderer> tree
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Four runtimes generate UI and ask for permission, and every one of them describes the same two things
|
|
15
|
+
* — a tool call, and a tree of components — in words of its own. What ships here is the half this
|
|
16
|
+
* library owns: the mapping, framework-free, with no dependency on any of them. An adapter that pulled
|
|
17
|
+
* in a runtime would be choosing it for the app, and the app has already chosen.
|
|
18
|
+
*
|
|
19
|
+
* Its own entry, and it carries neither the engine nor React: a route handler building an agent's
|
|
20
|
+
* catalog and a client folding its messages both import from here, and neither pays for the other.
|
|
21
|
+
*
|
|
22
|
+
* `docs/interop.md` has the recipe per runtime, json-render and AG-UI included.
|
|
23
|
+
*/
|
|
24
|
+
export { default as ToolInterop } from './utils/interop/toolInterop';
|
|
25
|
+
export type { ToolPart, ToolPartKind } from './utils/interop/toolInterop';
|
|
26
|
+
export { default as A2uiInterop } from './utils/interop/a2uiInterop';
|
|
27
|
+
export type { A2uiCatalogOptions, A2uiComponent, A2uiSpecOptions, A2uiState, A2uiSurface } from './utils/interop/a2uiInterop';
|
|
28
|
+
export { default as AssistantUiInterop } from './utils/interop/assistantUiInterop';
|
|
29
|
+
export type { GenerativeUiLoss, GenerativeUiNode, GenerativeUiSpec } from './utils/interop/assistantUiInterop';
|
|
30
|
+
export type { ApprovalDecision, ToolCallStatus } from './utils/agent/agentUtils';
|
|
31
|
+
export type { SpecNode } from './utils/spec/specTypes';
|
|
32
|
+
/** Where a tool call is, from whichever of the three runtimes handed you the part. */
|
|
33
|
+
export declare const toolPart: typeof ToolInterop.toolPart;
|
|
34
|
+
/** AG-UI reports events rather than parts, so its cards are a fold: one call per event, oldest first. */
|
|
35
|
+
export declare const applyToolEvent: typeof ToolInterop.applyEvent;
|
|
36
|
+
/** One A2UI message folded into the surfaces it names. Pure, and the same state back when nothing moved. */
|
|
37
|
+
export declare const a2uiApply: typeof A2uiInterop.apply;
|
|
38
|
+
export declare const a2uiApplyAll: typeof A2uiInterop.applyAll;
|
|
39
|
+
/** A surface by id, or the first one the agent opened. */
|
|
40
|
+
export declare const a2uiSurface: typeof A2uiInterop.surface;
|
|
41
|
+
/** A surface's adjacency list as one `<SpecRenderer>` tree. */
|
|
42
|
+
export declare const a2uiToSpec: typeof A2uiInterop.toSpec;
|
|
43
|
+
/** `catalog()` as an A2UI catalog document — what an agent generates against. */
|
|
44
|
+
export declare const a2uiCatalog: typeof A2uiInterop.catalogDocument;
|
|
45
|
+
/** One component of that document, self-contained: a `$ref` resolves against the document, not the part. */
|
|
46
|
+
export declare const a2uiComponentSchema: typeof A2uiInterop.componentSchema;
|
|
47
|
+
/** The state an A2UI fold starts from. */
|
|
48
|
+
export declare const a2uiEmpty: import('./interop').A2uiState;
|
|
49
|
+
/** assistant-ui's generative-UI spec as ours, and back. */
|
|
50
|
+
export declare const fromGenerativeUi: typeof AssistantUiInterop.toSpec;
|
|
51
|
+
export declare const toGenerativeUi: typeof AssistantUiInterop.fromSpec;
|
package/interop.mjs
ADDED
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
import { t as e } from "./specDefs.mjs";
|
|
2
|
+
import { t } from "./specData.mjs";
|
|
3
|
+
//#region src/utils/interop/toolInterop.ts
|
|
4
|
+
var n;
|
|
5
|
+
(function(e) {
|
|
6
|
+
let t = {
|
|
7
|
+
"input-streaming": "pending",
|
|
8
|
+
"input-available": "running",
|
|
9
|
+
"output-available": "success",
|
|
10
|
+
"output-error": "error",
|
|
11
|
+
"approval-requested": "approval",
|
|
12
|
+
"approval-responded": "approval"
|
|
13
|
+
}, n = {
|
|
14
|
+
inProgress: "pending",
|
|
15
|
+
executing: "running",
|
|
16
|
+
complete: "success"
|
|
17
|
+
}, r = {
|
|
18
|
+
running: "running",
|
|
19
|
+
complete: "success",
|
|
20
|
+
incomplete: "error",
|
|
21
|
+
"requires-action": "pending"
|
|
22
|
+
};
|
|
23
|
+
function i(e) {
|
|
24
|
+
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
25
|
+
}
|
|
26
|
+
function a(e) {
|
|
27
|
+
return typeof e == "string" && e !== "" ? e : void 0;
|
|
28
|
+
}
|
|
29
|
+
function o(e) {
|
|
30
|
+
return e.input ?? e.args ?? e.argsText;
|
|
31
|
+
}
|
|
32
|
+
function s(e) {
|
|
33
|
+
return e.output ?? e.result;
|
|
34
|
+
}
|
|
35
|
+
function c(e) {
|
|
36
|
+
let c = i(e);
|
|
37
|
+
if (c === null) return null;
|
|
38
|
+
let l = o(c), u = s(c), d = a(c.state);
|
|
39
|
+
if (d !== void 0 && d in t) {
|
|
40
|
+
let e = t[d];
|
|
41
|
+
if (e !== "approval") return {
|
|
42
|
+
kind: "call",
|
|
43
|
+
status: e,
|
|
44
|
+
decision: null,
|
|
45
|
+
input: l,
|
|
46
|
+
output: u,
|
|
47
|
+
error: a(c.errorText)
|
|
48
|
+
};
|
|
49
|
+
let n = i(c.approval)?.approved;
|
|
50
|
+
return {
|
|
51
|
+
kind: "approval",
|
|
52
|
+
status: "pending",
|
|
53
|
+
decision: typeof n == "boolean" ? n ? "approved" : "rejected" : null,
|
|
54
|
+
input: l
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
let f = c.status, p = i(f);
|
|
58
|
+
if (p !== null) {
|
|
59
|
+
let e = a(p.type) ?? "";
|
|
60
|
+
return {
|
|
61
|
+
kind: e === "requires-action" ? "approval" : "call",
|
|
62
|
+
status: r[e] ?? "pending",
|
|
63
|
+
decision: null,
|
|
64
|
+
input: l,
|
|
65
|
+
output: u,
|
|
66
|
+
error: a(i(p.error)?.message) ?? a(p.error)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
let m = a(f);
|
|
70
|
+
if (m !== void 0 && m in n) {
|
|
71
|
+
let e = typeof c.respond == "function" && m === "executing";
|
|
72
|
+
return {
|
|
73
|
+
kind: e ? "approval" : "call",
|
|
74
|
+
status: e ? "pending" : n[m],
|
|
75
|
+
decision: null,
|
|
76
|
+
input: l,
|
|
77
|
+
output: u
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
e.toolPart = c;
|
|
83
|
+
function l(e, t) {
|
|
84
|
+
let n = i(t), r = a(n?.toolCallId);
|
|
85
|
+
if (n === null || r === void 0) return e;
|
|
86
|
+
let o = a(n.type), s = e[r] ?? {
|
|
87
|
+
kind: "call",
|
|
88
|
+
status: "pending",
|
|
89
|
+
decision: null
|
|
90
|
+
};
|
|
91
|
+
return o === "TOOL_CALL_START" ? {
|
|
92
|
+
...e,
|
|
93
|
+
[r]: {
|
|
94
|
+
...s,
|
|
95
|
+
kind: "call",
|
|
96
|
+
status: "pending"
|
|
97
|
+
}
|
|
98
|
+
} : o === "TOOL_CALL_ARGS" ? {
|
|
99
|
+
...e,
|
|
100
|
+
[r]: {
|
|
101
|
+
...s,
|
|
102
|
+
status: "pending"
|
|
103
|
+
}
|
|
104
|
+
} : o === "TOOL_CALL_END" ? {
|
|
105
|
+
...e,
|
|
106
|
+
[r]: {
|
|
107
|
+
...s,
|
|
108
|
+
status: "running"
|
|
109
|
+
}
|
|
110
|
+
} : o === "TOOL_CALL_RESULT" ? {
|
|
111
|
+
...e,
|
|
112
|
+
[r]: {
|
|
113
|
+
...s,
|
|
114
|
+
status: "success",
|
|
115
|
+
output: n.content ?? n.result
|
|
116
|
+
}
|
|
117
|
+
} : o === "INTERRUPT" || o === "RUN_INTERRUPT" ? {
|
|
118
|
+
...e,
|
|
119
|
+
[r]: {
|
|
120
|
+
...s,
|
|
121
|
+
kind: "approval",
|
|
122
|
+
status: "pending"
|
|
123
|
+
}
|
|
124
|
+
} : o === "RUN_ERROR" ? {
|
|
125
|
+
...e,
|
|
126
|
+
[r]: {
|
|
127
|
+
...s,
|
|
128
|
+
status: "error",
|
|
129
|
+
error: a(n.message)
|
|
130
|
+
}
|
|
131
|
+
} : e;
|
|
132
|
+
}
|
|
133
|
+
e.applyEvent = l;
|
|
134
|
+
})(n ||= {});
|
|
135
|
+
var r = n, i;
|
|
136
|
+
(function(t) {
|
|
137
|
+
let n = t.ROOT_ID = "root", r = t.DEFAULT_SURFACE = "main";
|
|
138
|
+
t.EMPTY = {
|
|
139
|
+
surfaces: {},
|
|
140
|
+
order: []
|
|
141
|
+
};
|
|
142
|
+
function i(e) {
|
|
143
|
+
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
144
|
+
}
|
|
145
|
+
function a(e) {
|
|
146
|
+
return typeof e == "string" && e !== "" ? e : void 0;
|
|
147
|
+
}
|
|
148
|
+
function o(e) {
|
|
149
|
+
return {
|
|
150
|
+
id: e,
|
|
151
|
+
components: {},
|
|
152
|
+
data: {}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function s(e, t, n) {
|
|
156
|
+
return {
|
|
157
|
+
surfaces: {
|
|
158
|
+
...e.surfaces,
|
|
159
|
+
[t]: n
|
|
160
|
+
},
|
|
161
|
+
order: e.order.includes(t) ? e.order : [...e.order, t]
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function c(e) {
|
|
165
|
+
let t = i(e), n = a(t?.id);
|
|
166
|
+
if (t === null || n === void 0) return null;
|
|
167
|
+
let r = t.component;
|
|
168
|
+
if (typeof r == "string") {
|
|
169
|
+
let { id: e, component: i, ...a } = t;
|
|
170
|
+
return {
|
|
171
|
+
id: n,
|
|
172
|
+
component: r,
|
|
173
|
+
...a
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
let o = i(r), [s] = o ? Object.keys(o) : [];
|
|
177
|
+
return o === null || s === void 0 ? null : {
|
|
178
|
+
id: n,
|
|
179
|
+
component: s,
|
|
180
|
+
...i(o[s]) ?? {}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function l(e) {
|
|
184
|
+
return e.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
185
|
+
}
|
|
186
|
+
function u(e) {
|
|
187
|
+
return e === void 0 || e === "" || e === "/" ? [] : (e.startsWith("/") ? e.slice(1) : e).split("/").map(l);
|
|
188
|
+
}
|
|
189
|
+
function d(e, t) {
|
|
190
|
+
return t.reduce((e, t) => i(e)?.[t], e);
|
|
191
|
+
}
|
|
192
|
+
function f(e, t, n) {
|
|
193
|
+
if (t.length === 0) return n;
|
|
194
|
+
let [r, ...a] = t, o = i(e) ?? {};
|
|
195
|
+
if (a.length > 0) return {
|
|
196
|
+
...o,
|
|
197
|
+
[r]: f(o[r], a, n)
|
|
198
|
+
};
|
|
199
|
+
if (n !== void 0) return {
|
|
200
|
+
...o,
|
|
201
|
+
[r]: n
|
|
202
|
+
};
|
|
203
|
+
let { [r]: s, ...c } = o;
|
|
204
|
+
return c;
|
|
205
|
+
}
|
|
206
|
+
function p(e) {
|
|
207
|
+
if (!Array.isArray(e)) return {};
|
|
208
|
+
let t = {};
|
|
209
|
+
for (let n of e) {
|
|
210
|
+
let e = i(n), r = a(e?.key);
|
|
211
|
+
e !== null && r !== void 0 && ("valueString" in e ? t[r] = e.valueString : "valueNumber" in e ? t[r] = e.valueNumber : "valueBoolean" in e ? t[r] = e.valueBoolean : "valueMap" in e && (t[r] = p(e.valueMap)));
|
|
212
|
+
}
|
|
213
|
+
return t;
|
|
214
|
+
}
|
|
215
|
+
function m(e, t) {
|
|
216
|
+
let n = i(t);
|
|
217
|
+
if (n === null) return e;
|
|
218
|
+
let l = i(n.createSurface) ?? i(n.beginRendering);
|
|
219
|
+
if (l !== null) {
|
|
220
|
+
let t = a(l.surfaceId) ?? r, n = e.surfaces[t] ?? o(t);
|
|
221
|
+
return s(e, t, {
|
|
222
|
+
...n,
|
|
223
|
+
catalogId: a(l.catalogId) ?? n.catalogId,
|
|
224
|
+
root: a(l.root) ?? n.root,
|
|
225
|
+
theme: i(l.theme) ?? i(l.styles) ?? n.theme
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
let m = i(n.updateComponents) ?? i(n.surfaceUpdate);
|
|
229
|
+
if (m !== null) {
|
|
230
|
+
let t = a(m.surfaceId) ?? r, n = e.surfaces[t] ?? o(t), i = { ...n.components }, l = !1;
|
|
231
|
+
for (let e of Array.isArray(m.components) ? m.components : []) {
|
|
232
|
+
let t = c(e);
|
|
233
|
+
t !== null && (i[t.id] = t, l = !0);
|
|
234
|
+
}
|
|
235
|
+
return l || !e.surfaces[t] ? s(e, t, {
|
|
236
|
+
...n,
|
|
237
|
+
components: i
|
|
238
|
+
}) : e;
|
|
239
|
+
}
|
|
240
|
+
let h = i(n.updateDataModel) ?? i(n.dataModelUpdate);
|
|
241
|
+
if (h !== null) {
|
|
242
|
+
let t = a(h.surfaceId) ?? r, n = e.surfaces[t] ?? o(t), c = u(a(h.path)), l = "contents" in h ? {
|
|
243
|
+
...i(d(n.data, c)) ?? {},
|
|
244
|
+
...p(h.contents)
|
|
245
|
+
} : void 0, m = f(n.data, c, l ?? h.value);
|
|
246
|
+
return s(e, t, {
|
|
247
|
+
...n,
|
|
248
|
+
data: i(m) ?? {}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
let g = i(n.deleteSurface);
|
|
252
|
+
if (g !== null) {
|
|
253
|
+
let t = a(g.surfaceId) ?? r;
|
|
254
|
+
if (!e.surfaces[t]) return e;
|
|
255
|
+
let { [t]: n, ...i } = e.surfaces;
|
|
256
|
+
return {
|
|
257
|
+
surfaces: i,
|
|
258
|
+
order: e.order.filter((e) => e !== t)
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
return e;
|
|
262
|
+
}
|
|
263
|
+
t.apply = m;
|
|
264
|
+
function h(e, t) {
|
|
265
|
+
return t.reduce(m, e);
|
|
266
|
+
}
|
|
267
|
+
t.applyAll = h;
|
|
268
|
+
function g(e, t) {
|
|
269
|
+
return t === void 0 ? e.surfaces[e.order[0]] ?? null : e.surfaces[t] ?? null;
|
|
270
|
+
}
|
|
271
|
+
t.surface = g;
|
|
272
|
+
function _(e) {
|
|
273
|
+
let t = i(e);
|
|
274
|
+
return t === null ? e : "literalString" in t ? t.literalString : "literalNumber" in t ? t.literalNumber : "literalBoolean" in t ? t.literalBoolean : typeof t.path == "string" ? { $data: t.path } : e;
|
|
275
|
+
}
|
|
276
|
+
function v(e) {
|
|
277
|
+
let t = i(e);
|
|
278
|
+
return t === null ? a(e) : a(i(t.event)?.name) ?? a(t.name);
|
|
279
|
+
}
|
|
280
|
+
function y(e) {
|
|
281
|
+
let t = a(e.child);
|
|
282
|
+
if (t !== void 0) return { ids: [t] };
|
|
283
|
+
let n = e.children;
|
|
284
|
+
if (Array.isArray(n)) return { ids: n.filter((e) => typeof e == "string") };
|
|
285
|
+
let r = i(n);
|
|
286
|
+
if (r === null) return { ids: [] };
|
|
287
|
+
if (Array.isArray(r.explicitList)) return { ids: r.explicitList.filter((e) => typeof e == "string") };
|
|
288
|
+
let o = i(r.template) ?? r, s = a(o.componentId), c = a(o.path) ?? a(o.dataBinding);
|
|
289
|
+
return s !== void 0 && c !== void 0 ? {
|
|
290
|
+
ids: [],
|
|
291
|
+
template: {
|
|
292
|
+
componentId: s,
|
|
293
|
+
path: c
|
|
294
|
+
}
|
|
295
|
+
} : { ids: [] };
|
|
296
|
+
}
|
|
297
|
+
let b = /* @__PURE__ */ new Set([
|
|
298
|
+
"id",
|
|
299
|
+
"component",
|
|
300
|
+
"child",
|
|
301
|
+
"children",
|
|
302
|
+
"action"
|
|
303
|
+
]);
|
|
304
|
+
function x(e, t, n, r, i) {
|
|
305
|
+
let a = e.components[t];
|
|
306
|
+
if (a === void 0 || i > 32 || r.has(t)) return null;
|
|
307
|
+
let o = new Set(n.catalog?.components[a.component]?.events ?? []), s = {}, c = {};
|
|
308
|
+
for (let [e, t] of Object.entries(a)) {
|
|
309
|
+
if (b.has(e)) continue;
|
|
310
|
+
if (!o.has(e)) {
|
|
311
|
+
s[e] = _(t);
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
let n = v(t);
|
|
315
|
+
n !== void 0 && (c[e] = n);
|
|
316
|
+
}
|
|
317
|
+
let l = v(a.action);
|
|
318
|
+
l !== void 0 && (c.action = l);
|
|
319
|
+
let { ids: u, template: d } = y(a), f = /* @__PURE__ */ new Set([...r, t]), p = [];
|
|
320
|
+
for (let t of u) {
|
|
321
|
+
let r = x(e, t, n, f, i + 1);
|
|
322
|
+
r !== null && p.push(r);
|
|
323
|
+
}
|
|
324
|
+
if (d !== void 0) {
|
|
325
|
+
let t = x(e, d.componentId, n, f, i + 1);
|
|
326
|
+
t !== null && p.push({
|
|
327
|
+
...t,
|
|
328
|
+
repeat: { $data: d.path }
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
return {
|
|
332
|
+
type: a.component,
|
|
333
|
+
key: t,
|
|
334
|
+
...Object.keys(s).length ? { props: s } : {},
|
|
335
|
+
...p.length ? { children: p } : {},
|
|
336
|
+
...Object.keys(c).length ? { on: c } : {}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function S(e, t = {}) {
|
|
340
|
+
return e === null ? null : x(e, t.root ?? e.root ?? n, t, /* @__PURE__ */ new Set(), 0);
|
|
341
|
+
}
|
|
342
|
+
t.toSpec = S;
|
|
343
|
+
let C = {
|
|
344
|
+
type: "array",
|
|
345
|
+
items: { type: "string" },
|
|
346
|
+
description: "The ids of this component’s children, each a component of its own in the same surface."
|
|
347
|
+
}, w = {
|
|
348
|
+
type: "string",
|
|
349
|
+
description: "The name of an action the host handles."
|
|
350
|
+
};
|
|
351
|
+
function T(e, t) {
|
|
352
|
+
let n = i(i(e.components)?.[t]);
|
|
353
|
+
if (n === null) return null;
|
|
354
|
+
let r = i(e.$defs);
|
|
355
|
+
return r === null ? n : {
|
|
356
|
+
...n,
|
|
357
|
+
$defs: r
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
t.componentSchema = T;
|
|
361
|
+
function E(t, n = {}) {
|
|
362
|
+
let r = n.catalogId ?? `urn:box-kite:catalog:${t.version}`, i = {}, a = {};
|
|
363
|
+
for (let [n, r] of Object.entries(t.components)) {
|
|
364
|
+
let t = e.hoist(r.props, i);
|
|
365
|
+
a[n] = {
|
|
366
|
+
type: "object",
|
|
367
|
+
description: r.description,
|
|
368
|
+
properties: {
|
|
369
|
+
id: {
|
|
370
|
+
type: "string",
|
|
371
|
+
description: "This component’s id, unique within the surface."
|
|
372
|
+
},
|
|
373
|
+
component: {
|
|
374
|
+
type: "string",
|
|
375
|
+
enum: [n]
|
|
376
|
+
},
|
|
377
|
+
...t.properties ?? {},
|
|
378
|
+
...Object.fromEntries(r.events.map((e) => [e, w])),
|
|
379
|
+
...r.slots.length ? { children: C } : {}
|
|
380
|
+
},
|
|
381
|
+
required: [
|
|
382
|
+
"id",
|
|
383
|
+
"component",
|
|
384
|
+
...t.required ?? []
|
|
385
|
+
],
|
|
386
|
+
additionalProperties: !1
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
return {
|
|
390
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
391
|
+
$id: r,
|
|
392
|
+
catalogId: r,
|
|
393
|
+
title: n.title ?? `${t.library} catalog`,
|
|
394
|
+
description: n.description ?? t.rules.join(" "),
|
|
395
|
+
...Object.keys(i).length ? { $defs: i } : {},
|
|
396
|
+
components: a
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
t.catalogDocument = E;
|
|
400
|
+
})(i ||= {});
|
|
401
|
+
var a = i, o;
|
|
402
|
+
(function(e) {
|
|
403
|
+
function n(e, t) {
|
|
404
|
+
if (typeof e == "string") return e;
|
|
405
|
+
if (t > 32 || typeof e != "object" || !e || typeof e.component != "string") return null;
|
|
406
|
+
let r = (e.children ?? []).map((e) => n(e, t + 1)).filter((e) => e !== null);
|
|
407
|
+
return {
|
|
408
|
+
type: e.component,
|
|
409
|
+
...e.key === void 0 ? {} : { key: e.key },
|
|
410
|
+
...e.props ? { props: e.props } : {},
|
|
411
|
+
...r.length ? { children: r } : {}
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
function r(e) {
|
|
415
|
+
return e == null ? [] : (Array.isArray(e.root) ? e.root : [e.root]).map((e) => n(e, 0)).filter((e) => typeof e == "object" && !!e);
|
|
416
|
+
}
|
|
417
|
+
e.toSpec = r;
|
|
418
|
+
function i(e, n, r, a) {
|
|
419
|
+
if (e == null) return null;
|
|
420
|
+
if (typeof e == "string") return e;
|
|
421
|
+
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
422
|
+
if (t.isRef(e)) return r.push({
|
|
423
|
+
code: "data-binding",
|
|
424
|
+
path: n
|
|
425
|
+
}), null;
|
|
426
|
+
if (a > 32 || typeof e.type != "string") return null;
|
|
427
|
+
let o = e;
|
|
428
|
+
if (o.repeat && r.push({
|
|
429
|
+
code: "repeat",
|
|
430
|
+
path: n
|
|
431
|
+
}), o.on) for (let e of Object.keys(o.on)) r.push({
|
|
432
|
+
code: "event",
|
|
433
|
+
path: `${n}.on.${e}`
|
|
434
|
+
});
|
|
435
|
+
let s = (o.children === void 0 ? [] : Array.isArray(o.children) ? o.children : [o.children]).map((e, t) => i(e, `${n}.children.${t}`, r, a + 1)).filter((e) => e !== null);
|
|
436
|
+
return {
|
|
437
|
+
component: o.type,
|
|
438
|
+
...o.key === void 0 ? {} : { key: o.key },
|
|
439
|
+
...o.props ? { props: o.props } : {},
|
|
440
|
+
...s.length ? { children: s } : {}
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
function a(e) {
|
|
444
|
+
let t = [];
|
|
445
|
+
return {
|
|
446
|
+
spec: { root: (Array.isArray(e) ? e : [e]).map((e, n) => i(e, `root.${n}`, t, 0)).filter((e) => e !== null) },
|
|
447
|
+
losses: t
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
e.fromSpec = a;
|
|
451
|
+
})(o ||= {});
|
|
452
|
+
var s = o, c = r.toolPart, l = r.applyEvent, u = a.apply, d = a.applyAll, f = a.surface, p = a.toSpec, m = a.catalogDocument, h = a.componentSchema, g = a.EMPTY, _ = s.toSpec, v = s.fromSpec;
|
|
453
|
+
//#endregion
|
|
454
|
+
export { a as A2uiInterop, s as AssistantUiInterop, r as ToolInterop, u as a2uiApply, d as a2uiApplyAll, m as a2uiCatalog, h as a2uiComponentSchema, g as a2uiEmpty, f as a2uiSurface, p as a2uiToSpec, l as applyToolEvent, _ as fromGenerativeUi, v as toGenerativeUi, c as toolPart };
|
package/layer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./platform.cjs"),t=require("./effects.cjs"),n=require("./behavior.cjs"),r=require("./identity.cjs");let i=require("react");function a(a){let{haspopup:o,id:
|
|
1
|
+
const e=require("./platform.cjs"),t=require("./effects.cjs"),n=require("./behavior.cjs"),r=require("./identity.cjs");let i=require("react");var a=()=>()=>{},o=()=>!0;function s(){return(0,i.useSyncExternalStore)(a,e.a,o)}function c(a){let{haspopup:o,id:c,idPrefix:l,open:u,defaultOpen:d=!1,onOpenChange:f,onOpened:p,onClosing:m,inside:h}=a,g=r.t(l),_=c??g,[v,y]=n.i({value:u,defaultValue:d,onChange:f}),[b,x]=(0,i.useState)(null),[S,C]=(0,i.useState)(null),w=s(),[T,E]=(0,i.useState)(!1),[D,O]=(0,i.useState)(),k=(0,i.useRef)(`imperative`),A=(0,i.useRef)(!1),j=n.a(p),M=n.a(m),N=n.a(e=>{let t=e.newState===`open`,n=e.currentTarget;if(t&&u===!1){e.preventDefault();return}t||(A.current=n.contains(document.activeElement),M(A.current,b)),E(t);let r=t?`trigger`:k.current;k.current=`imperative`,y(t,{reason:r,event:e})}),P=n.a(e=>{let t=e.currentTarget;e.newState===`open`&&j(t)});t.n(()=>{if(!w||!S)return;let e=new AbortController;return S.addEventListener(`beforetoggle`,N,{signal:e.signal}),S.addEventListener(`toggle`,P,{signal:e.signal}),()=>e.abort()},[w,S,N,P]),t.n(()=>{!w||!e.a()||!S||v===T||(v?S.showPopover():S.hidePopover())},[v,T,S,w]),t.n(()=>{if(!w||!v)return;let t=new AbortController,n=(e,n)=>document.addEventListener(e,n,{signal:t.signal,capture:!0});return n(`keydown`,e=>{e.key===`Escape`&&(k.current=`escape`)}),n(`pointerdown`,t=>{let n=!!b&&e.l(t,[b]);k.current=n?`trigger`:`outside-pointer`}),()=>t.abort()},[w,v,b]),t.n(()=>{b&&(b.id||b.setAttribute(`id`,`${_}-trigger`),O(b.id))},[b,_]),t.n(()=>{if(!(!w||!b))return b.setAttribute(`popovertarget`,_),()=>b.removeAttribute(`popovertarget`)},[w,b,_]),t.n(()=>{w||!v||!S||j(S)},[w,v,S,j]),n.r({enabled:!w&&v,inside:[S,b,...h??[]],onDismiss:(e,t)=>y(!1,{reason:e,event:t})}),n.n({enabled:!w&&v,returnTo:b});let F=n.a(e=>{y(e=>!e,{reason:`trigger`,event:e})});return{platform:w,isOpen:v,setOpen:y,id:_,trigger:(0,i.useMemo)(()=>({ref:x,props:{"aria-expanded":v,"aria-haspopup":o,"aria-controls":v?_:void 0,...w?{}:{onClick:F}}}),[F,o,v,_,w]),triggerElement:b,triggerId:D,setPanel:C,panelElement:S}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
|