@theoremjs/studio 0.3.4-next.598.gb003e90 → 0.3.4-next.602.gb5a7fab

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.
Files changed (63) hide show
  1. package/package.json +4 -4
  2. package/page/assets/Banner-p9SclVnW.js +4 -0
  3. package/page/assets/ConsoleFrame-Bk7U_dkx.js +3 -0
  4. package/page/assets/{MenuBottomSheet-B8bZZgjf.js → MenuBottomSheet-BQlpVmEr.js} +1 -1
  5. package/page/assets/{SchemaFields-BVWsFTc6.js → SchemaFields-knHoiON5.js} +1 -1
  6. package/page/assets/{ToolResultCharts-DVVuoOH8.js → ToolResultCharts-DrK7h289.js} +1 -1
  7. package/page/assets/{TraceInspector-DgOd5uwx.js → TraceInspector-Ix8TGKUr.js} +1 -1
  8. package/page/assets/{TraceOverview-Daolem_3.js → TraceOverview-D30xb36O.js} +1 -1
  9. package/page/assets/{_virtual_studio-type-sources-BOljuYdZ.js → _virtual_studio-type-sources-CUVOpqcN.js} +0 -4
  10. package/page/assets/browser-connection-pM-ZbsQr.js +3 -0
  11. package/page/assets/browser-engine-BBSrAkpf.js +11 -0
  12. package/page/assets/browser-transport-DI2MaVLx.js +45 -0
  13. package/page/assets/{crypto-qwXH_zFb.js → crypto-CY8dSBJ4.js} +1 -1
  14. package/page/assets/encode-files-DxWGM2XV.js +1 -0
  15. package/page/assets/{export-agent-DwnIwJFq.js → export-agent-BjRGGhHp.js} +2 -2
  16. package/page/assets/{guardrail-tester-Bu0YJX9s.js → guardrail-tester-jChXDXvA.js} +2 -2
  17. package/page/assets/index-D-9zkt1z.js +146 -0
  18. package/page/assets/{labels-provider-C_KY4x6D.js → labels-provider-Bt3Q2GjB.js} +1 -1
  19. package/page/assets/{live-messages-CVmXXeLQ.js → live-messages-QLwxUT0i.js} +1 -1
  20. package/page/assets/reader-D_UCUUJt.js +5 -0
  21. package/page/assets/shaped-data-C4yaGRz9.js +20 -0
  22. package/page/assets/{stub-Z-Vm8Sv8.js → stub-DSUcPMOV.js} +2 -2
  23. package/page/assets/{studio-code-pane-BDV47nwZ.js → studio-code-pane-D0gvxh9E.js} +3 -3
  24. package/page/assets/{studio-console-C3uZUuqy.js → studio-console-DgngrbWF.js} +1 -1
  25. package/page/assets/studio-decision-17k-mqAR.js +1 -0
  26. package/page/assets/{studio-embedding-B89jIyAy.js → studio-embedding-BDSfOSHQ.js} +1 -1
  27. package/page/assets/studio-host-console-BIRwm7JW.js +2 -0
  28. package/page/assets/studio-labels-Ch9-yR_t.js +3 -0
  29. package/page/assets/{studio-live-DFLAIpSa.js → studio-live-DboP35Z1.js} +3 -3
  30. package/page/assets/studio-map-qFa39sGA.js +1 -0
  31. package/page/assets/{studio-trace-replay-BFtV9j-3.js → studio-trace-replay-CNZg-u6a.js} +2 -2
  32. package/page/assets/{studio-type-checker-BPZzvJmB.js → studio-type-checker-BD42Vls4.js} +1 -1
  33. package/page/assets/tool-schema-CPVHlZ7w.js +17 -0
  34. package/page/assets/{trace-record-DjsOJFNa.js → trace-record-jV4PFwk_.js} +1 -1
  35. package/page/assets/tree-DfG6CXsC.js +3 -0
  36. package/page/assets/{turn-client-DzIqP2qE.js → turn-client-BCpbITbw.js} +2 -2
  37. package/page/assets/use-one-call-D089AxXD.js +1 -0
  38. package/page/assets/{use-second-ticker-B9Dklglz.js → use-second-ticker-BSCE_-wM.js} +1 -1
  39. package/page/assets/workspace-CzTPlUdi.js +1 -0
  40. package/page/index.html +18 -21
  41. package/tool-schema.js +30 -2
  42. package/ui/studio-screen.js +6 -2
  43. package/workspace.js +1 -1
  44. package/page/assets/Banner-B_2gi5vH.js +0 -4
  45. package/page/assets/ConsoleFrame-CEavxV8f.js +0 -3
  46. package/page/assets/ContextMenu-BPGWn4aq.js +0 -2
  47. package/page/assets/MenuBottomSheetActionList-3L0HS4Kf.js +0 -1
  48. package/page/assets/browser-connection-CfhefDFM.js +0 -3
  49. package/page/assets/browser-engine-DOETo2NM.js +0 -11
  50. package/page/assets/browser-transport-DwKQIgk5.js +0 -45
  51. package/page/assets/encode-files-v-W0DoVP.js +0 -1
  52. package/page/assets/index-BK6Cf7vm.js +0 -146
  53. package/page/assets/reader-CJEp4m2A.js +0 -5
  54. package/page/assets/shaped-data-BO6EAfYh.js +0 -20
  55. package/page/assets/studio-decision-BOnqIS6C.js +0 -1
  56. package/page/assets/studio-host-console-CPYsftTx.js +0 -2
  57. package/page/assets/studio-labels-D1QhaZ40.js +0 -3
  58. package/page/assets/studio-map-DFIoea5d.js +0 -1
  59. package/page/assets/tool-schema-CWSpXHJV.js +0 -17
  60. package/page/assets/tree-BTHpYpj5.js +0 -3
  61. package/page/assets/use-one-call-BJxTAI48.js +0 -1
  62. package/page/assets/useContainerReveal-BFy8N_QU.js +0 -1
  63. package/page/assets/workspace-DT7jMw84.js +0 -1
@@ -0,0 +1 @@
1
+ import{E as e,a as t,c as n,i as r,n as i,o as a,r as o,s,w as c,y as l}from"./tree-DfG6CXsC.js";function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e){let t=e=>{if(Array.isArray(e))return e.map(t);if(!u(e))return e;let n=Object.keys(e).filter(t=>e[t]!==void 0).sort();return Object.fromEntries(n.map(n=>[n,t(e[n])]))};return JSON.stringify(t(e))??`undefined`}var f=`agent:`;function p(e,t=`identity`){return t===`identity`?`${f}${e}`:`${f}${e}/${t}`}function m(e){if(!e.startsWith(f))return;let t=e.slice(6),n=t.indexOf(`/`);return n<0?{key:t,inner:`identity`}:{key:t.slice(0,n),inner:t.slice(n+1)}}function h(e,t){return a(t)===void 0?p(e,t):t}function g(e,t){let n=a(t);if(n!==void 0)return e.toolSpecs.some(e=>e.key===n)?{tool:n}:void 0;let o=i(t);if(o!==void 0)return e.providers.some(e=>e.id===o)?{provider:o}:void 0;let s=m(t),c=s&&e.agents.find(e=>e.key===s.key);if(!s||!c||a(s.inner)!==void 0)return;let l=r(_(c,[],e.providers),s.inner);return l?{agent:c.key,ref:l}:void 0}function _(e,t,n){let{key:r,tools:{allow:i,...a},...o}=e,s=new Map(t.map(e=>[e.key,e]));return{...o,providers:n,tools:a,toolSpecs:i.flatMap(e=>s.get(e)??[])}}function ee(e,t){let n=e.agents.find(e=>e.key===t);return n&&_(n,e.toolSpecs,e.providers)}function v(e,t=c(`agent`)){let{toolSpecs:n,tools:r,providers:i,...a}=e;return{...a,key:t,tools:{...r,allow:n.map(e=>e.key)}}}function y(e,t){let n=new Map(t.map(e=>[e.key,e])),r=new Set(e.map(e=>e.key)),i=t.filter(e=>!r.has(e.key));return!e.some(e=>(n.get(e.key)??e)!==e)&&i.length===0?e:[...e.map(e=>n.get(e.key)??e),...i]}function b(e,t,n){return e.agents.map(e=>e.key===t?n(e):e)}var x=e=>e.key,S=e=>e.id;function C(e){let t=Object.fromEntries(e.agents.map(t=>[t.key,e.starts.agents[t.key]??t])),n=new Map(e.toolSpecs.map(e=>[e.key,e])),r=new Set([...n.keys(),...Object.values(t).flatMap(e=>e.tools.allow)]),i={};for(let t of r){let r=e.starts.tools[t]??n.get(t);r&&(i[t]=r)}let a=Object.fromEntries(e.providers.map(t=>[t.id,e.starts.providers[t.id]??t]));for(let n of Object.values(t).flatMap(w)){let t=e.starts.providers[n];t&&!(n in a)&&(a[n]=t)}return{...e,starts:{agents:t,tools:i,providers:a}}}var w=e=>e.modelBindings.map(e=>e.provider);function te(e,t){let n=new Set(e.providers.map(S)),r=[...new Set(t.flatMap(w))].flatMap(t=>{let r=e.starts.providers[t];return r&&!n.has(t)?[r]:[]});return r.length?[...e.providers,...r]:e.providers}function ne(e,t){let n=e.agents.find(e=>e.key===t);return n?C({...e,starts:{...e.starts,agents:{...e.starts.agents,[t]:n}}}):e}function T(e,t,n,r){if(!e.agents.some(e=>e.key===t))return e;let i=r?y(e.toolSpecs,[...r]):e.toolSpecs;return C({...e,toolSpecs:y(i,n.toolSpecs),agents:b(e,t,()=>v(n,t))})}function E(e,t=`identity`){let n=v(e);return G(C({v:5,agents:[n],toolSpecs:e.toolSpecs,providers:e.providers,selected:h(n.key,t),chatWith:n.key,starts:{agents:{},tools:{},providers:{}}}))}function D(e,t){let n=e.agents.find(e=>e.key===t);return n&&{..._(n,[],e.providers),toolSpecs:e.toolSpecs}}function O(e,t,n){if(!e.agents.find(e=>e.key===t))return e;let r=new Set(n.toolSpecs.map(e=>e.key)),i=new Set(e.toolSpecs.map(e=>e.key)),a=n.toolSpecs.filter(e=>!i.has(e.key)).map(e=>e.key),o=e=>e.filter(e=>r.has(e)),{toolSpecs:s,providers:c,tools:l,...u}=n;return C({...e,toolSpecs:n.toolSpecs,agents:e.agents.map(e=>e.key===t?{...u,key:t,tools:{...l,allow:[...o(e.tools.allow),...a]}}:e.tools.allow.every(e=>r.has(e))?e:{...e,tools:{...e.tools,allow:o(e.tools.allow)}})})}function re(t,n=l()){let r=new Map(t.toolSpecs.map(e=>[e.toolName,e.key])),i=n.identity.agentId.trim(),a=t.agents.map(e=>e.identity.agentId),o=i&&e(i,a,e=>`${i}_${e}`),s=v({...n,identity:{...n.identity,agentId:o}});return s.tools.allow=n.toolSpecs.map(e=>r.get(e.toolName)??e.key),C({...t,agents:[...t.agents,s],toolSpecs:[...t.toolSpecs,...n.toolSpecs.filter(e=>!r.has(e.toolName))],selected:p(s.key)})}function ie(t,n){let r=t.agents.findIndex(e=>e.key===n),i=t.agents[r];if(!i)return t;let a=i.identity.agentId.trim()||`agent`,o=t.agents.map(e=>e.identity.agentId),s={...structuredClone(i),key:c(`agent`)};s.identity.agentId=e(`${a}_copy`,o,e=>`${a}_copy${e}`);let l=[...t.agents];return l.splice(r+1,0,s),C({...t,agents:l,selected:p(s.key)})}function ae(e,t){let n=e.agents.findIndex(e=>e.key===t);if(n<0||e.agents.length===1)return e;let r=e.agents[n+1]??e.agents[n-1];if(!r)return e;let i=new Set(e.toolSpecs.filter(e=>e.toolType===`agent`&&e.agentKey===t).map(e=>e.key)),a=e.agents.filter(e=>e.key!==t).map(e=>({...e,tools:{...e.tools,allow:e.tools.allow.filter(e=>!i.has(e))},modelBindings:e.modelBindings.map(e=>e.compactWith===t?{...e,compactWith:void 0}:e)})),o=m(e.selected)?.key===t||[...i].some(t=>e.selected===s(t));return C({...e,agents:a,toolSpecs:e.toolSpecs.filter(e=>!i.has(e.key)).map(e=>e.stageAgentKey===t?{...e,stageAgentKey:void 0}:e),selected:o?p(r.key):e.selected,chatWith:e.chatWith===t?r.key:e.chatWith})}function oe(e,t,n,r){let i=e.agents.find(e=>e.key===t);if(!i||!e.toolSpecs.some(e=>e.key===n)||i.tools.allow.includes(n)===r)return e;let a=r?[...i.tools.allow,n]:i.tools.allow.filter(e=>e!==n);return{...e,agents:b(e,t,()=>({...i,tools:{...i.tools,allow:a}}))}}function se(e,t){if(!e.toolSpecs.some(e=>e.key===t))return e;let n=e.agents.map(e=>e.tools.allow.includes(t)?{...e,tools:{...e.tools,allow:e.tools.allow.filter(e=>e!==t)}}:e);return C({...e,agents:n,toolSpecs:e.toolSpecs.filter(e=>e.key!==t),selected:e.selected===s(t)?p(e.agents[0]?.key??``):e.selected})}var k=(e,t)=>e===t||d(e)===d(t),A=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function ce(e){let{agents:t,tools:n,providers:r}=e.starts;return e.agents.every(e=>k(e,t[e.key]))&&e.toolSpecs.every(e=>k(e,n[e.key]))&&e.providers.every(e=>k(e,r[e.id]))&&Object.keys(n).length===e.toolSpecs.length}function le(e){return{...e,starts:{agents:Object.fromEntries(e.agents.map(e=>[e.key,e])),tools:Object.fromEntries(e.toolSpecs.map(e=>[e.key,e])),providers:Object.fromEntries(e.providers.map(e=>[e.id,e]))}}}function ue(e,t,n,r){return{...e,identity:{...e.identity,agentId:t},tools:{...e.tools,allow:e.tools.allow.filter(e=>n.has(e))},modelBindings:e.modelBindings.map(e=>e.compactWith&&!r.has(e.compactWith)?{...e,compactWith:void 0}:e)}}function j(t,n){let r=t.starts.agents[n],i=t.agents.find(e=>e.key===n);if(!r||!i)return t;let a=new Set(t.agents.map(e=>e.key)),o=new Set(t.toolSpecs.map(e=>e.key)),s=t.toolSpecs.map(e=>e.toolName),c=[];for(let n of r.tools.allow){let r=t.starts.tools[n];if(o.has(n)||!r||r.toolType===`agent`&&!a.has(r.agentKey??``))continue;let i=e(r.toolName,s,e=>`${r.toolName}_${e}`);s.push(i),c.push({...r,toolName:i})}let l=c.length?[...t.toolSpecs,...c]:t.toolSpecs,u=new Set(l.map(e=>e.key)),d=r.identity.agentId,f=t.agents.filter(e=>e.key!==n).map(e=>e.identity.agentId),m=ue(r,d&&e(d,f,e=>`${d}_${e}`),u,a);if(c.length===0&&k(m,i))return t;let h=te(t,[r]),_={...t,agents:b(t,n,()=>m),toolSpecs:l,providers:h};return g(_,_.selected)?_:{..._,selected:p(n)}}function de(e,t,n){if(n.facet===`identity`)return j(e,t);if(n.facet===`toolSpec`)return Y(e,n.key);let r=j(e,t),i=r.agents.find(e=>e.key===t),a=e.agents.find(e=>e.key===t);if(r===e||!i||!a)return e;let o=fe(a,i,n);return k(o,a)?e:{...e,agents:b(e,t,()=>o),toolSpecs:n.facet===`tools`?r.toolSpecs:e.toolSpecs,providers:n.facet===`models`||n.facet===`modelBinding`?r.providers:e.providers}}function fe(e,t,n){if(n.facet===`models`)return{...e,models:t.models,modelBindings:t.modelBindings};if(n.facet===`modelBinding`){let r=t.modelBindings.find(e=>e.key===n.key);return r?{...e,modelBindings:e.modelBindings.map(e=>e.key===n.key?r:e)}:e}return n.facet===`toolSpec`?e:M(e,t,n.facet)}function M(e,t,n){return{...e,[n]:t[n]}}function N(e,t){let n=new Map(Object.values(t.starts.agents).map(e=>[e.identity.agentId,e.key])),r=new Map(Object.values(t.starts.tools).map(e=>[e.toolName,e.key])),i=JSON.stringify(e),a=(e,t)=>{t!==void 0&&t!==e&&(i=i.split(e).join(t))};for(let t of e.agents)a(t.key,n.get(t.identity.agentId));for(let t of e.toolSpecs)a(t.key,r.get(t.toolName));let o=JSON.parse(i);return{...o,selected:g(o,t.selected)?t.selected:o.selected,chatWith:o.agents.some(e=>e.key===t.chatWith)?t.chatWith:o.chatWith}}function P(e,t){let n=N(t,e),r=(e,t,n,r,i)=>{let a=new Map(r.map(t=>[e(t),t])),o=new Set([...t.map(e),...Object.keys(n)]),s=t.map(t=>k(t,n[e(t)])?a.get(e(t))??t:t),c=s.filter(t=>!(e(t)in i)).map(t=>[e(t),n[e(t)]??t]);return{held:[...s,...r.filter(t=>!o.has(e(t)))],starts:{...Object.fromEntries(c),...i}}},i=r(x,e.agents,e.starts.agents,n.agents,n.starts.agents),a=r(x,e.toolSpecs,e.starts.tools,n.toolSpecs,n.starts.tools),o=r(S,e.providers,e.starts.providers,n.providers,n.starts.providers);return{...e,agents:i.held,toolSpecs:a.held,providers:o.held,starts:{agents:i.starts,tools:a.starts,providers:o.starts}}}function F(e){let t=new Map,n=e=>{if(Array.isArray(e))for(let t of e)n(t);else if(typeof e==`object`&&e)for(let[r,i]of Object.entries(e))r!==`key`||typeof i!=`string`?n(i):t.has(i)||t.set(i,`#${t.size}`)},r=e=>typeof e==`string`?t.get(e)??e:Array.isArray(e)?e.map(r):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).map(([e,n])=>[t.get(e)??e,r(n)])),i={agents:e.agents,toolSpecs:e.toolSpecs,providers:e.providers};n(i);let a=JSON.stringify(r(i)),o=2166136261,s=16777619;for(let e=0;e<a.length;e+=1){let t=a.charCodeAt(e);o=Math.imul(o^t,16777619),s=Math.imul(s^t,2246822507)}return`${a.length.toString(36)}-${(o>>>0).toString(36)}${(s>>>0).toString(36)}`}function I(e,t){return F(e)!==t}var L=/^(agent|model|tool|question|criterion|reference)-[0-9a-f]{8}$/;function R(e){let t=new Map;return JSON.stringify(e).replace(/\b(agent|model|tool|question|criterion|reference)-[0-9a-f]{8}\b/g,e=>(t.has(e)||t.set(e,`#${t.size}`),t.get(e)??e))}function z(e,t){let n=t.map(R),r=new Set,i=[],a=[];for(let o of e){let e=R(o),s=n.findIndex((t,n)=>t===e&&!r.has(n));s<0?a.push(o):(r.add(s),i.push([o,t[s]]))}let o=t.filter((e,t)=>!r.has(t));for(let[e,t]of a.slice(0,o.length).entries())i.push([t,o[e]]);return i}function B(e,t){let n=JSON.stringify(e),r=(e,t,r,i)=>{let a=new Set(r.map(e=>e.key)),o=new Set(e.map(e=>e.key)),s=e.flatMap(e=>a.has(e.key)?[]:t[e.key]??[]),c=r.filter(e=>!o.has(e.key)&&!t[e.key]),[l,u]=[s[0],c[0]];s.length===1&&c.length===1&&l&&u&&R(i(l))===R(i(u))&&(n=n.split(u.key).join(l.key))};return r(t.agents,t.starts.agents,e.agents,e=>({...e,identity:{...e.identity,agentId:``}})),r(t.toolSpecs,t.starts.tools,e.toolSpecs,e=>({...e,toolName:``})),JSON.parse(n)}function V(e,t){let n=JSON.stringify(e);for(let e=0;e<4;e+=1){let e=JSON.parse(n),r=new Map,i=(e,t)=>{if(Array.isArray(e)&&Array.isArray(t))for(let[n,r]of z(e,t))i(n,r);else if(A(e)&&A(t))for(let[n,a]of Object.entries(e)){let e=t[n];n===`key`?typeof a==`string`&&typeof e==`string`&&a!==e&&L.test(a)&&L.test(e)&&r.set(e,a):i(a,e)}};for(let n of e.agents)i(t.agents[n.key],n);for(let n of e.toolSpecs)i(t.tools[n.key],n);if(r.size===0)return e;for(let[e,t]of r)n=n.split(e).join(t)}return JSON.parse(n)}var H=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)&&new Set(e).size===e.length,U=e=>Array.isArray(e)&&e.every(e=>A(e)&&typeof e.key==`string`);function W(e,t,n,r,i){if(k(e,n)||k(t,n))return t;if(A(e)&&A(t)&&A(n)){let a={};for(let o of new Set([...Object.keys(n),...Object.keys(t),...Object.keys(e)])){let s=W(e[o],t[o],n[o],[...r,o],i);s!==void 0&&(a[o]=s)}return a}if(U(e)&&U(t)&&U(n)){let a=new Map(e.map(e=>[e.key,e])),o=new Map(n.map(e=>[e.key,e])),s=[];for(let e of t){let[t,n]=[a.get(e.key),o.get(e.key)],c=[...r,s.length];t?n?s.push(W(t,e,n,c,i)):k(e,t)?i.updated(c):(i.conflict(c,e,void 0),s.push(e)):s.push(e)}let c=new Set(t.map(e=>e.key)),l=s.length;for(let e of n){if(c.has(e.key))continue;let t=a.get(e.key);t?k(e,t)||i.conflict([...r,l++],void 0,e):(i.updated([...r,s.length]),s.push(e),l+=1)}return s}if(k(e,t))return i.updated(r),n;if(H(e)&&H(t)&&H(n)){let a=e.filter(e=>!n.includes(e)),o=n.filter(n=>!e.includes(n)&&!t.includes(n));return i.updated(r),[...t.filter(e=>!a.includes(e)),...o]}return i.conflict(r,t,n),t}function G(e){let t=new Set(e.agents.map(e=>e.key)),n=e.toolSpecs.filter(e=>e.toolType!==`agent`||t.has(e.agentKey??``)).map(e=>e.stageAgentKey&&!t.has(e.stageAgentKey)?{...e,stageAgentKey:void 0}:e),r=new Set(n.map(e=>e.key)),i=e.agents.map(e=>{let n=e.tools.allow.filter(e=>r.has(e)),i=e.modelBindings.map(e=>e.compactWith&&!t.has(e.compactWith)?{...e,compactWith:void 0}:e),a={...e,tools:{...e.tools,allow:n},modelBindings:i};return k(a,e)?e:a}),a=C({...e,agents:i,toolSpecs:n}),o=i[0];return{...a,selected:g(a,a.selected)||!o?a.selected:p(o.key),chatWith:t.has(a.chatWith)||!o?a.chatWith:o.key}}function pe(e,t,n){let r=V(B(N(t,e),e),e.starts),i=[],a=[],o=(e,t,n,r,o,s,c,l)=>{let u=new Map(s.map(e=>[t(e),e])),d=new Set(r.map(e=>t(e))),f=new Set(r.map(e=>n(o[t(e)]??e))),p=new Set(l?.map(n)),m=[],h={...c};for(let s of r){let[r,c]=[o[t(s)],u.get(t(s))],l={kind:e,key:t(s),name:n(c??r??s)};!r||!c&&!p.has(n(r))?(m.push(s),h[t(s)]=r??s):c?m.push(W(r,s,c,[],{updated:e=>i.push({...l,path:e}),conflict:(e,t,n)=>a.push({...l,path:e,mine:t,theirs:n})})):k(s,r)?i.push({...l,path:[]}):(a.push({...l,path:[],mine:s,theirs:void 0}),m.push(s),h[t(s)]=r)}let g=e=>{let r=o[t(e)]??l?.find(t=>n(t)===n(e)&&!f.has(n(t)));if(r)return R(r)===R(e)?`unchanged`:`changed`};for(let r of s){if(d.has(t(r)))continue;let o={kind:e,key:t(r),name:n(r),path:[]},s=g(r);s===`changed`?a.push({...o,mine:void 0,theirs:r}):s===void 0&&(m.push(r),i.push(o))}return{held:m,starts:h}},s=o(`agent`,x,e=>e.identity.agentId,e.agents,e.starts.agents,r.agents,r.starts.agents,n?.agents),c=o(`tool`,x,e=>e.toolName,e.toolSpecs,e.starts.tools,r.toolSpecs,r.starts.tools,n?.toolSpecs),l=o(`provider`,S,S,e.providers,e.starts.providers,r.providers,r.starts.providers,n?.providers);return{workspace:G({...e,agents:s.held,toolSpecs:c.held,providers:l.held,starts:{agents:s.starts,tools:c.starts,providers:l.starts}}),updated:i,conflicts:a,files:r}}var K=Object.freeze({gone:!0});function q(e){if(Array.isArray(e))return e.filter(e=>e!==K).map(q);if(!A(e))return e;let t=Object.entries(e).map(([e,t])=>[e,q(t)]);return Object.fromEntries(t)}function J(e,t,n){let[r,...i]=t;if(r===void 0)return n;if(Array.isArray(e))return typeof r==`number`&&r>=e.length?n===void 0?e:[...e,n]:e.map((e,t)=>t===r?i.length===0&&n===void 0?K:J(e,i,n):e);let a={...A(e)?e:{}},o=J(a[r],i,n);return o===void 0?delete a[r]:a[r]=o,a}function me(e,t){let{agents:n,toolSpecs:r,providers:i}=e.workspace,a={agents:{...e.workspace.starts.agents},tools:{...e.workspace.starts.tools},providers:{...e.workspace.starts.providers}},o=(e,t,n,r)=>r.path.length>0?t.map(t=>e(t)===r.key?J(t,r.path,r.theirs):t):r.theirs===void 0?(delete n[r.key],t.filter(t=>e(t)!==r.key)):(n[r.key]=r.theirs,[...t,r.theirs]);for(let s of new Set(t)){let t=e.conflicts[s];if(t){if(t.kind===`tool`)r=o(x,r,a.tools,t);else if(t.kind===`provider`)i=o(S,i,a.providers,t);else{if(n=o(x,n,a.agents,t),t.path.length>0||t.theirs===void 0)continue;let i=new Set(r.map(e=>e.key)),s=e.files.toolSpecs.filter(e=>e.toolType===`agent`&&e.agentKey===t.key&&!i.has(e.key));for(let e of s)a.tools[e.key]=e;r=[...r,...s],n=n.map(t=>{let n=e.files.agents.find(e=>e.key===t.key)?.tools.allow??[],r=s.map(e=>e.key).filter(e=>n.includes(e)&&!t.tools.allow.includes(e));return r.length?{...t,tools:{...t.tools,allow:[...t.tools.allow,...r]}}:t})}}}return[n,r]=[q(n),q(r)],G({...e.workspace,agents:n,toolSpecs:r,providers:i,starts:a})}function Y(t,n){let r=t.starts.tools[n],i=t.toolSpecs.find(e=>e.key===n);if(!r||!i)return t;let a=t.toolSpecs.filter(e=>e.key!==n).map(e=>e.toolName),o={...r,toolName:e(r.toolName,a,e=>`${r.toolName}_${e}`)};return k(o,i)?t:{...t,toolSpecs:t.toolSpecs.map(e=>e.key===n?o:e)}}function X(e,t){let n=e.providers.find(e=>e.id===t.id);return!n||k(n,t)?e:{...e,providers:e.providers.map(e=>e.id===t.id?t:e)}}function Z(e,t){let n=e.agents.map(e=>w(e).filter(e=>e===t).length);return{models:n.reduce((e,t)=>e+t,0),agents:n.filter(e=>e>0).length}}function Q(e,t,n,r,i){let a=e=>e.provider===r&&e.apiId.trim()===i.trim();return{models:(e.agents.find(e=>e.key===t)?.modelBindings??[]).filter(e=>e.key!==n&&a(e)).map(e=>e.modelId.trim()||`new`),agents:e.agents.filter(e=>e.key!==t&&e.modelBindings.some(a)).map(e=>e.identity.agentId.trim()||`New agent`)}}function he(t,n){return{id:e(`provider`,t,e=>`provider_${e}`),definition:n,connection:{}}}function ge(e,t){return e.providers.some(e=>e.id===t.id)?e:C({...e,providers:[...e.providers,t],selected:o(t.id)})}function _e(e,t){return!e.providers.some(e=>e.id===t)||Z(e,t).models>0?e:C({...e,providers:e.providers.filter(e=>e.id!==t),selected:e.selected===o(t)?p(e.agents[0]?.key??``):e.selected})}function ve(e,t,n){let r=n.trim();if(!e.providers.some(e=>e.id===t)||!r||e.providers.some(e=>e.id===r))return e;let{[t]:i,...a}=e.starts.providers,s=e=>e.provider===t;return{...e,providers:e.providers.map(e=>e.id===t?{...e,id:r}:e),agents:e.agents.map(e=>e.modelBindings.some(s)?{...e,modelBindings:e.modelBindings.map(e=>s(e)?{...e,provider:r}:e)}:e),selected:e.selected===o(t)?o(r):e.selected,starts:{...e.starts,providers:i?{...a,[r]:{...i,id:r}}:a}}}function ye(e){return e.providers.flatMap(t=>{let n=e.starts.providers[t.id];return n&&k(n,t)?[t.id]:[]})}function be(e,t){let n=e.starts.providers[t];return n?X(e,n):e}function $(e,t){return{...t,id:p(e,t.id),children:t.children.map(t=>$(e,t))}}function xe(e,n){let r=$(e.key,t(_(e,[],n)));return e.identity.agentId.trim()?r:{...r,label:`New agent`}}function Se(e){return{agents:e.agents.map(t=>xe(t,e.providers)),tools:n(e.toolSpecs)}}export{me as A,de as C,oe as D,h as E,Se as F,d as I,X as M,E as N,le as O,g as P,j as S,be as T,ae as _,ce as a,ve as b,F as c,pe as d,Q as f,P as g,ye as h,p as i,O as j,T as k,D as l,Z as m,ge as n,ie as o,he as p,ee as r,I as s,re as t,ne as u,se as v,Y as w,N as x,_e as y};
package/page/index.html CHANGED
@@ -10,7 +10,7 @@
10
10
  href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%23000'/%3E%3Cg transform='translate(4 4)' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4.5 18.5c2 0 3-1.2 4.2-3.4l2.6-5c1-1.9 2.1-3.1 4.2-3.1'/%3E%3Cpath d='M5.5 8.2c1.6-.9 3.2-.4 3.8 1.6l2.3 6.6c.6 1.7 2.1 2.4 3.9 1.7'/%3E%3Ccircle cx='19.5' cy='4.5' r='1.6' fill='%23fff' stroke='none'/%3E%3C/g%3E%3C/svg%3E"
11
11
  />
12
12
  <title>theorem studio</title>
13
- <script type="module" crossorigin src="/studio/assets/index-BK6Cf7vm.js"></script>
13
+ <script type="module" crossorigin src="/studio/assets/index-D-9zkt1z.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/studio/assets/rolldown-runtime-hePW80VL.js">
15
15
  <link rel="modulepreload" crossorigin href="/studio/assets/themeProps-3IqahpCr.js">
16
16
  <link rel="modulepreload" crossorigin href="/studio/assets/tokens.stylex-DkHf0P9C.js">
@@ -43,51 +43,48 @@
43
43
  <link rel="modulepreload" crossorigin href="/studio/assets/useScrollableArea-DuF_pz9m.js">
44
44
  <link rel="modulepreload" crossorigin href="/studio/assets/ScrollableArea-BHfY7sWH.js">
45
45
  <link rel="modulepreload" crossorigin href="/studio/assets/use-trace-records-B1vrKQmA.js">
46
- <link rel="modulepreload" crossorigin href="/studio/assets/useScrollLock-Dyf6PHJt.js">
47
46
  <link rel="modulepreload" crossorigin href="/studio/assets/IconAlertTriangle-BqAEqqdU.js">
48
47
  <link rel="modulepreload" crossorigin href="/studio/assets/isRenderable-DHkzpAoQ.js">
49
- <link rel="modulepreload" crossorigin href="/studio/assets/labels-provider-C_KY4x6D.js">
48
+ <link rel="modulepreload" crossorigin href="/studio/assets/labels-provider-Bt3Q2GjB.js">
50
49
  <link rel="modulepreload" crossorigin href="/studio/assets/schemas-BQ9Jydzb.js">
51
50
  <link rel="modulepreload" crossorigin href="/studio/assets/host-patterns-F-KZIzkF.js">
52
- <link rel="modulepreload" crossorigin href="/studio/assets/shaped-data-BO6EAfYh.js">
53
- <link rel="modulepreload" crossorigin href="/studio/assets/tool-schema-CWSpXHJV.js">
51
+ <link rel="modulepreload" crossorigin href="/studio/assets/shaped-data-C4yaGRz9.js">
52
+ <link rel="modulepreload" crossorigin href="/studio/assets/tool-schema-CPVHlZ7w.js">
54
53
  <link rel="modulepreload" crossorigin href="/studio/assets/live-ingress-OuSlQ6q7.js">
55
- <link rel="modulepreload" crossorigin href="/studio/assets/tree-BTHpYpj5.js">
56
- <link rel="modulepreload" crossorigin href="/studio/assets/browser-connection-CfhefDFM.js">
57
- <link rel="modulepreload" crossorigin href="/studio/assets/use-second-ticker-B9Dklglz.js">
58
- <link rel="modulepreload" crossorigin href="/studio/assets/Banner-B_2gi5vH.js">
54
+ <link rel="modulepreload" crossorigin href="/studio/assets/tree-DfG6CXsC.js">
55
+ <link rel="modulepreload" crossorigin href="/studio/assets/browser-connection-pM-ZbsQr.js">
56
+ <link rel="modulepreload" crossorigin href="/studio/assets/use-second-ticker-BSCE_-wM.js">
57
+ <link rel="modulepreload" crossorigin href="/studio/assets/Banner-p9SclVnW.js">
59
58
  <link rel="modulepreload" crossorigin href="/studio/assets/arrive-DvbqpeRS.js">
60
59
  <link rel="modulepreload" crossorigin href="/studio/assets/Center-nHS1JSux.js">
61
60
  <link rel="modulepreload" crossorigin href="/studio/assets/IconSearch-BTx66a40.js">
62
61
  <link rel="modulepreload" crossorigin href="/studio/assets/trace-schema-9CdEyG6Q.js">
63
- <link rel="modulepreload" crossorigin href="/studio/assets/stub-Z-Vm8Sv8.js">
64
- <link rel="modulepreload" crossorigin href="/studio/assets/reader-CJEp4m2A.js">
65
- <link rel="modulepreload" crossorigin href="/studio/assets/useContainerReveal-BFy8N_QU.js">
66
- <link rel="modulepreload" crossorigin href="/studio/assets/browser-transport-DwKQIgk5.js">
62
+ <link rel="modulepreload" crossorigin href="/studio/assets/stub-DSUcPMOV.js">
63
+ <link rel="modulepreload" crossorigin href="/studio/assets/reader-D_UCUUJt.js">
64
+ <link rel="modulepreload" crossorigin href="/studio/assets/browser-transport-DI2MaVLx.js">
67
65
  <link rel="modulepreload" crossorigin href="/studio/assets/focusReturn-CTppP2k0.js">
68
66
  <link rel="modulepreload" crossorigin href="/studio/assets/CheckboxInput-CFZ_Wq8-.js">
67
+ <link rel="modulepreload" crossorigin href="/studio/assets/useScrollLock-Dyf6PHJt.js">
69
68
  <link rel="modulepreload" crossorigin href="/studio/assets/chainEventHandlers-C6ttXGfW.js">
70
69
  <link rel="modulepreload" crossorigin href="/studio/assets/Dialog-Sd04KQS2.js">
71
70
  <link rel="modulepreload" crossorigin href="/studio/assets/useClipboard-CbN9bb4J.js">
72
71
  <link rel="modulepreload" crossorigin href="/studio/assets/CodeBlock-CfVOtDeO.js">
73
72
  <link rel="modulepreload" crossorigin href="/studio/assets/HoverCard-DMyWUvwP.js">
74
73
  <link rel="modulepreload" crossorigin href="/studio/assets/IconEye-BB5aY-wQ.js">
75
- <link rel="modulepreload" crossorigin href="/studio/assets/encode-files-v-W0DoVP.js">
76
- <link rel="modulepreload" crossorigin href="/studio/assets/turn-client-DzIqP2qE.js">
74
+ <link rel="modulepreload" crossorigin href="/studio/assets/encode-files-DxWGM2XV.js">
75
+ <link rel="modulepreload" crossorigin href="/studio/assets/turn-client-BCpbITbw.js">
77
76
  <link rel="modulepreload" crossorigin href="/studio/assets/CollapsibleGroup-FIawJRo4.js">
78
- <link rel="modulepreload" crossorigin href="/studio/assets/studio-labels-D1QhaZ40.js">
79
- <link rel="modulepreload" crossorigin href="/studio/assets/crypto-qwXH_zFb.js">
80
- <link rel="modulepreload" crossorigin href="/studio/assets/workspace-DT7jMw84.js">
77
+ <link rel="modulepreload" crossorigin href="/studio/assets/studio-labels-Ch9-yR_t.js">
78
+ <link rel="modulepreload" crossorigin href="/studio/assets/crypto-CY8dSBJ4.js">
79
+ <link rel="modulepreload" crossorigin href="/studio/assets/workspace-CzTPlUdi.js">
81
80
  <link rel="modulepreload" crossorigin href="/studio/assets/lent-keys-C32ems-I.js">
82
81
  <link rel="modulepreload" crossorigin href="/studio/assets/editors-BJX_S59A.js">
83
82
  <link rel="modulepreload" crossorigin href="/studio/assets/studio-session-yEqFQo5o.js">
84
83
  <link rel="modulepreload" crossorigin href="/studio/assets/EmptyState-C_uF9Wyj.js">
85
84
  <link rel="modulepreload" crossorigin href="/studio/assets/useMenuPress-DLG1QOiE.js">
86
- <link rel="modulepreload" crossorigin href="/studio/assets/ListItem-QF7KFt0h.js">
87
- <link rel="modulepreload" crossorigin href="/studio/assets/MenuBottomSheetActionList-3L0HS4Kf.js">
88
85
  <link rel="modulepreload" crossorigin href="/studio/assets/useAdaptivePresentation-Bma4-u1a.js">
89
- <link rel="modulepreload" crossorigin href="/studio/assets/ContextMenu-BPGWn4aq.js">
90
86
  <link rel="modulepreload" crossorigin href="/studio/assets/useFocusReturnVisibility-BHKv5Jwr.js">
87
+ <link rel="modulepreload" crossorigin href="/studio/assets/ListItem-QF7KFt0h.js">
91
88
  <link rel="stylesheet" crossorigin href="/studio/assets/use-second-ticker-GWBt83pd.css">
92
89
  <link rel="stylesheet" crossorigin href="/studio/assets/index-C9rhrCGT.css">
93
90
  <style>html{color-scheme:dark}html,body{margin:0;background:#000}html[data-boot-pending],html[data-boot-pending] body{background:#262626}html[data-boot-pending] .astryx-app-shell{height:100dvh}html[data-boot-pending] .astryx-app-shell-sidenav{position:absolute;inset-block:0;inset-inline-start:0;z-index:0;width:3rem}html[data-boot-pending] #astryx-app-shell-main{position:relative;z-index:1;width:100%;height:100%;max-width:none;margin:0;border-radius:0;clip-path:none;background:#262626;color:#fff}html[data-boot-pending] #astryx-app-shell-main>:not([data-boot]){visibility:hidden}html[data-boot-pending] [data-boot]{position:absolute;inset:0;z-index:2;display:grid;place-items:center;background:#262626;color:#fff}</style>
package/tool-schema.js CHANGED
@@ -19,7 +19,28 @@ export const DEFAULT_TOOL_OUTPUT_SCHEMA = `{
19
19
  * studio run checks a tool's input and output by the same contract the saved code does.
20
20
  */
21
21
  export function zodFromJsonSchema(schema) {
22
- return z.fromJSONSchema(schema);
22
+ let read = zods.get(schema);
23
+ if (!read) {
24
+ read = z.fromJSONSchema(schema);
25
+ zods.set(schema, read);
26
+ }
27
+ return read;
28
+ }
29
+ // why: A compile reads every tool's schemas for every agent that uses the tool, again on each edit that settles.
30
+ /** Each schema object's zod schema, read once. */
31
+ const zods = new WeakMap();
32
+ /** Each schema text that parses, by its text: the same text gives the same schema object, so its zod schema is read once too. */
33
+ const parsedSchemas = new Map();
34
+ /** Texts kept before the cache starts over: past this, they are mostly drafts typed and gone. */
35
+ const MAX_PARSED_SCHEMAS = 1000;
36
+ /** Frozen all the way down: a schema shared by every compile that reads its text must not change under one. */
37
+ function frozen(value) {
38
+ if (value && typeof value === 'object') {
39
+ for (const inner of Object.values(value))
40
+ frozen(inner);
41
+ Object.freeze(value);
42
+ }
43
+ return value;
23
44
  }
24
45
  /** Required fields, and optional ones with an example; the package's form fills a tool's request the same way. */
25
46
  export function sampleFromJsonSchema(schema) {
@@ -49,6 +70,9 @@ export function parseJsonSchema(raw, label) {
49
70
  const trimmed = raw.trim();
50
71
  if (!trimmed)
51
72
  return { ok: false, error: `${label} JSON Schema is required.` };
73
+ const known = parsedSchemas.get(trimmed);
74
+ if (known)
75
+ return { ok: true, schema: known };
52
76
  try {
53
77
  const parsed = JSON.parse(trimmed);
54
78
  if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
@@ -61,7 +85,11 @@ export function parseJsonSchema(raw, label) {
61
85
  catch (err) {
62
86
  return { ok: false, error: `${label} JSON Schema can't be read: ${err.message}.` };
63
87
  }
64
- return { ok: true, schema: parsed };
88
+ if (parsedSchemas.size >= MAX_PARSED_SCHEMAS)
89
+ parsedSchemas.clear();
90
+ const schema = frozen(parsed);
91
+ parsedSchemas.set(trimmed, schema);
92
+ return { ok: true, schema };
65
93
  }
66
94
  catch {
67
95
  return { ok: false, error: `${label} JSON Schema is not valid JSON.` };
@@ -164,14 +164,18 @@ function agentItems(state) {
164
164
  return workspace.agents.map((agent) => {
165
165
  const draft = libraryDraft(workspace, agent.key) ?? createBlankDraft();
166
166
  const name = agent.identity.agentId || 'this agent';
167
+ const whole = resetAgent(workspace, agent.key);
167
168
  return agentItem({
168
169
  draft,
169
170
  scope: (id) => scopedNodeId(agent.key, id),
170
171
  selectedId,
171
172
  onSelect,
172
173
  setDraft,
173
- resetOf: (ref, label) => reset(resetAgentNode(workspace, agent.key, ref), `Reset ${label} to how it started.`),
174
- }, agent.key === focus, rowActions(name, reset(resetAgent(workspace, agent.key), `Reset ${name} to how it started.`), actionButton(`Duplicate ${name}`, IconCopyPlus, () => {
174
+ // why: An agent at its start has every section at its start, so its rows need no reset each.
175
+ resetOf: (ref, label) => whole === workspace
176
+ ? undefined
177
+ : reset(resetAgentNode(workspace, agent.key, ref), `Reset ${label} to how it started.`),
178
+ }, agent.key === focus, rowActions(name, reset(whole, `Reset ${name} to how it started.`), actionButton(`Duplicate ${name}`, IconCopyPlus, () => {
175
179
  update((current) => duplicateAgent(current, agent.key));
176
180
  }), !isOnly &&
177
181
  actionButton(`Remove ${name}`, IconX, () => {
package/workspace.js CHANGED
@@ -307,7 +307,7 @@ export function removeLibraryTool(workspace, toolKey) {
307
307
  });
308
308
  }
309
309
  /** The same settings with the same values. The order they are held in is not a difference. */
310
- const same = (a, b) => canonical(a) === canonical(b);
310
+ const same = (a, b) => a === b || canonical(a) === canonical(b);
311
311
  const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
312
312
  /** Whether every agent, tool, and provider is as it started, and no tool was added or removed. */
313
313
  export function atStart(workspace) {
@@ -1,4 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TraceInspector-DgOd5uwx.js","assets/rolldown-runtime-hePW80VL.js","assets/themeProps-3IqahpCr.js","assets/tokens.stylex-DkHf0P9C.js","assets/SegmentedControlItem-BBGRPrxp.js","assets/padding.stylex-B76907Zf.js","assets/VStack-CkVMcNiK.js","assets/mergeProps-ptS-gIMz.js","assets/StackItem-CQviqAfM.js","assets/useLayerDismissal-BAnTRYTt.js","assets/fieldParts-B7DYLgh4.js","assets/Icon-BqkS-pIq.js","assets/devWarning-DxuplmRl.js","assets/Text-BOqCfzZC.js","assets/sharedResizeObserver-4U9Xq5Oq.js","assets/preload-helper-DpV6A1kQ.js","assets/useMediaQuery-BCT0NUeZ.js","assets/useResolvedRequired-DbsOcDqy.js","assets/useAnnounce-DTSHZvjg.js","assets/Tooltip-BWs5DLrM.js","assets/useTooltip-c097gL_-.js","assets/focusOutline.stylex-BT0kfa4t.js","assets/IconButton-DVUFx-8p.js","assets/focusableSelector-DXZeMU85.js","assets/useDevWarning-Z9SoixOP.js","assets/createReactComponent-CZwsv6DD.js","assets/isRtlElement-BG33-k_H.js","assets/plainDate-BHiJcj7o.js","assets/DateInput-B1ICJtHn.js","assets/focusReturn-CTppP2k0.js","assets/Card-DruykyeB.js","assets/container.stylex-BmOi-8DQ.js","assets/ScrollableArea-BHfY7sWH.js","assets/useScrollableArea-DuF_pz9m.js","assets/chainEventHandlers-C6ttXGfW.js","assets/BottomSheet-Dbh6A5Vl.js","assets/useScrollLock-Dyf6PHJt.js","assets/use-trace-records-B1vrKQmA.js","assets/CheckboxInput-CFZ_Wq8-.js","assets/isRenderable-DHkzpAoQ.js","assets/IconAlertTriangle-BqAEqqdU.js","assets/arrive-DvbqpeRS.js","assets/IconShield-DDOh7Gr5.js","assets/shaped-data-BO6EAfYh.js","assets/host-patterns-F-KZIzkF.js","assets/trace-record-DjsOJFNa.js","assets/TraceOverview-Daolem_3.js","assets/labels-provider-C_KY4x6D.js","assets/CodeBlock-CfVOtDeO.js","assets/useClipboard-CbN9bb4J.js","assets/index-BK6Cf7vm.js","assets/browser-transport-DwKQIgk5.js","assets/Center-nHS1JSux.js","assets/IconSearch-BTx66a40.js","assets/schemas-BQ9Jydzb.js","assets/tool-schema-CWSpXHJV.js","assets/reader-CJEp4m2A.js","assets/browser-connection-CfhefDFM.js","assets/live-ingress-OuSlQ6q7.js","assets/trace-schema-9CdEyG6Q.js","assets/stub-Z-Vm8Sv8.js","assets/useContainerReveal-BFy8N_QU.js","assets/Dialog-Sd04KQS2.js","assets/HoverCard-DMyWUvwP.js","assets/IconEye-BB5aY-wQ.js","assets/studio-labels-D1QhaZ40.js","assets/turn-client-DzIqP2qE.js","assets/encode-files-v-W0DoVP.js","assets/CollapsibleGroup-FIawJRo4.js","assets/tree-BTHpYpj5.js","assets/crypto-qwXH_zFb.js","assets/use-second-ticker-B9Dklglz.js","assets/use-second-ticker-GWBt83pd.css","assets/workspace-DT7jMw84.js","assets/lent-keys-C32ems-I.js","assets/editors-BJX_S59A.js","assets/studio-session-yEqFQo5o.js","assets/EmptyState-C_uF9Wyj.js","assets/ContextMenu-BPGWn4aq.js","assets/MenuBottomSheetActionList-3L0HS4Kf.js","assets/useMenuPress-DLG1QOiE.js","assets/ListItem-QF7KFt0h.js","assets/useAdaptivePresentation-Bma4-u1a.js","assets/useFocusReturnVisibility-BHKv5Jwr.js","assets/index-C9rhrCGT.css","assets/trace-patterns-D6TbkLLr.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n,n as r,u as i}from"./themeProps-3IqahpCr.js";import{h as a}from"./tokens.stylex-DkHf0P9C.js";import{t as o}from"./mergeProps-ptS-gIMz.js";import{x as s}from"./fieldParts-B7DYLgh4.js";import{t as c}from"./isRenderable-DHkzpAoQ.js";import{t as l,x as u}from"./Icon-BqkS-pIq.js";import{b as d,d as f,f as p,g as m,h,l as g,n as _,p as v,t as y,u as ee}from"./use-trace-records-B1vrKQmA.js";import{t as b}from"./preload-helper-DpV6A1kQ.js";import{n as x,t as te}from"./labels-provider-C_KY4x6D.js";import{c as ne,n as re,t as ie}from"./IconButton-DVUFx-8p.js";import{t as S}from"./createReactComponent-CZwsv6DD.js";import{a as ae}from"./ScrollableArea-BHfY7sWH.js";import{$n as oe,F as C,Qn as se,R as w,Y as T,_ as ce,h as E,i as D,j as O,mn as k,q as A,v as le,xr as j,yt as M,z as N}from"./tool-schema-CWSpXHJV.js";import{c as ue,r as P}from"./host-patterns-F-KZIzkF.js";import{On as de,Sn as fe,Wn as pe,Zt as F,en as me,in as he,nn as ge,qt as I,wn as L}from"./shaped-data-BO6EAfYh.js";import{C as R,G as _e,K as ve,S as z,U as ye,V as be,W as xe,_ as Se,h as Ce,l as we,m as Te,s as Ee,t as B}from"./tree-BTHpYpj5.js";import{W as De,_ as Oe,c as ke,h as Ae,u as V}from"./browser-connection-CfhefDFM.js";import{a as je,r as Me}from"./live-ingress-OuSlQ6q7.js";import{n as Ne,r as Pe}from"./use-second-ticker-B9Dklglz.js";var Fe=S(`outline`,`check`,`Check`,[[`path`,{d:`M5 12l5 5l10 -10`,key:`svg-0`}]]),Ie=S(`outline`,`copy`,`Copy`,[[`path`,{d:`M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666`,key:`svg-0`}],[`path`,{d:`M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1`,key:`svg-1`}]]),Le=S(`outline`,`download`,`Download`,[[`path`,{d:`M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2`,key:`svg-0`}],[`path`,{d:`M7 11l5 5l5 -5`,key:`svg-1`}],[`path`,{d:`M12 4l0 12`,key:`svg-2`}]]),H=`••••`,Re=/auth|key|token|secret|passw|pwd|cookie|session|signature|^sig$|credential|^code$|appid/i,ze=/auth|key|token|secret|passw|pwd|signature|credential|appid/i,Be=[[/^AIza/,`Google API key`],[/^sk-or-/,`OpenRouter key`],[/^sk-ant-/,`Anthropic key`],[/^sk-/,`OpenAI key`],[/^(?:ghp_|github_pat_)/,`GitHub token`],[/^xox[baprs]-/,`Slack token`],[/^AKIA/,`AWS access key id`],[/^eyJ[\w-]+\.[\w-]+\./,`JWT`],[/^Bearer\s/i,`a whole Bearer header, not a bare token`],[/^https?:\/\//i,`a URL, not a key`]],Ve=16;function He(e,t={}){let n=typeof e==`string`?e:``,r=n.trim(),i=[];/^(?:<.*>|x{3,}|\.{3}|your[-_ ]?(?:api[-_ ]?)?key|changeme|todo)$/i.test(r)?i.push(`a placeholder, not a real value`):(r&&r!==n&&i.push(`spaces or a line break around it`),/[\r\n]/.test(r)?i.push(`a line break inside`):/\s/.test(r)&&i.push(`a space inside`),/^(['"`]).*\1$/.test(r)&&i.push(`wrapped in quotes`),r&&r.length<Ve&&i.push(`shorter than keys usually are`));let a=Be.find(([e])=>e.test(r))?.[1];return{secret:!0,set:r.length>0,...a?{looksLike:a}:{},problems:i,sameAs:[...t.sameAs??[]],usedBy:[...t.usedBy??[]]}}var U=/^([a-z][a-z0-9+.-]*:\/\/)([^/?#@]*)@/i,W=/([?&;])([^=?&;#\s]*)=([^&;#\s]*)/g;function G(e){let t=e.indexOf(`:`);return t<0?[e,void 0]:[e.slice(0,t),e.slice(t+1)]}function Ue(e){try{return decodeURIComponent(e)}catch{return e}}function K(e){return Re.test(e)}function We(e){let t=URL.canParse(e)?Re:ze;return e.replace(U,(e,t,n)=>{let[r,i]=G(n);return`${t}${r&&`••••`}${i===void 0?``:`:${i&&`••••`}`}@`}).replace(W,(e,n,r,i)=>i&&t.test(Ue(r))?`${n}${r}=${H}`:e)}function Ge(e,t){let[n,r]=G(U.exec(t)?.[2]??``),i=new Map;for(let[,,e=``,n=``]of t.matchAll(W))i.set(e,[...i.get(e)??[],n]);return e.replace(U,(e,t,i)=>{let[a,o]=G(i),s=a===`••••`&&n?n:a,c=o===`••••`&&r?r:o;return`${t}${s}${c===void 0?``:`:${c}`}@`}).replace(W,(e,t,n,r)=>{let a=r===`••••`?i.get(n)?.shift():void 0;return a?`${t}${n}=${a}`:e})}function Ke(e){if(e==null||e===``)return e;let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return`(not a JSON object, ${String(e.length)} characters)`}if(typeof t!=`object`||!t||Array.isArray(t))return`(not a JSON object)`;let n=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,K(e)?H:t]));return typeof e==`string`?JSON.stringify(n):n}var qe=/\{\s*private\s*:/g;function Je(e,t){return e.slice(0,t).split(`
3
- `).length}function Ye(e){let t=[],n=0;for(let r of e.matchAll(qe)){if(r.index<n)continue;let i=1,a=r.index+r[0].length;for(;a<e.length&&i>0;a++)e[a]===`{`?i++:e[a]===`}`&&i--;if(i>0)return{ok:!1,message:`The {private: section on line ${String(Je(e,r.index))} has no closing }.`};let o=e.slice(r.index+r[0].length,a-1).trim();if(!o)return{ok:!1,message:`The {private: section on line ${String(Je(e,r.index))} is empty.`};t.push(e.slice(n,r.index),{private:o}),n=a}if(t.push(e.slice(n)),t.length===1)return{ok:!0,prompt:e.trim()||void 0};let r=t[0],i=t.at(-1);return typeof r==`string`&&(t[0]=r.trimStart()),typeof i==`string`&&(t[t.length-1]=i.trimEnd()),{ok:!0,prompt:t.filter(e=>e!==``)}}var Xe=()=>void 0,Ze=()=>void 0;function q(e){return(e??[]).map(e=>e.trim()).filter(Boolean)}function J(e,t,n,r,i,a){i===null||Number.isInteger(i)&&i>=a||e(t,`${r} must be a ${a?`positive`:`non-negative`} whole number.`,n)}var Qe={agentId:{label:`Profile id`,max:64},handle:{label:`Handle`,max:32}};function $e(e,t,n){let{label:r,max:i}=Qe[t];n.trim()?Array.from(n).length>i&&e(`identity`,`${r} is at most ${i} characters.`,t):e(`identity`,`${r} is required.`,t)}function et(e,t){$e(t,`agentId`,e.identity.agentId),e.identity.profileType!==`host`&&$e(t,`handle`,e.identity.handle)}function tt(e,t,n,r){let i=B(e.key),a=O(n,t,{...e,apiId:e.apiId.trim()}),o=n.find(t=>t.id===e.provider);if(!o)r(i,`No provider is defined as ${e.provider}.`,`provider`);else if(!N(o,t))r(i,`${e.provider} doesn't serve ${t} agents.`,`provider`);else if(!N(o,t,e.protocol)){let n=(w(o,t)??[]).map(e=>e.id).join(` or `);r(i,n?`${e.provider} runs ${t} agents on ${n}, not ${e.protocol}.`:`${e.provider} doesn't serve ${t} agents on ${e.protocol}.`,`protocol`)}return a.apiId||r(i,`API model is required.`,`apiId`),a}function nt(e){return e.length<2?e[0]??``:`${e.slice(0,-1).join(`, `)} or ${e.at(-1)}`}function rt(e,t){let n=C(e).map(e=>e.path.split(`.`)[0]??e.path).find(e=>e.toLowerCase()===t.toLowerCase());return n?`${e.id} has no option ${t}. Did you mean ${n}?`:`${e.id} has no option ${t}.`}function it(e,t,n,r){let i={};e.efforts.forEach(({alias:a,level:o},s)=>{let c=a.trim();c?c in i?r(n,`Effort alias '${c}' is used twice.`,`efforts`,s):i[c]=o:r(n,`Every effort needs an alias.`,`efforts`,s),E(t)&&!T.includes(o)&&r(n,`${e.provider} takes the ${nt(T)} thinking level, not ${o}.`,`efforts`,s)}),e.allowEffortSelect&&Object.keys(i).length<2&&r(n,`Effort select needs at least two efforts.`,`allowEffortSelect`);let a=e.defaultEffort.trim();if(!a&&xe(e))r(n,`Pick a default effort — there is more than one.`,`defaultEffort`);else if(a&&!(a in i)){let e=Object.keys(i);r(n,e.length?`Default effort '${a}' is not one of the efforts. Pick ${nt(e)}.`:`Default effort '${a}' is not one of the efforts.`,`defaultEffort`)}return{efforts:i,defaultEffort:a}}function at(e,t,n,r,i){let a=B(e.key),o=tt(e,t,n,r),{apiId:s}=o,{efforts:c,defaultEffort:l}=it(e,o,a,r),u=Object.keys(c).length;J(r,a,`maxOutputTokens`,`Max output tokens`,e.maxOutputTokens,1),e.temperature!==null&&!(Number.isFinite(e.temperature)&&e.temperature>=0)&&r(a,`Temperature must be zero or more.`,`temperature`),st(e,n,t,a,r);let d=ct(e,t,a,r,i),f=ot(e,a,r);return{protocol:e.protocol,provider:e.provider,apiId:s,...e.keySlot?{keySlot:e.keySlot}:{},...e.fallbackKeySlot?{fallbackKeySlot:e.fallbackKeySlot}:{},...u?{efforts:c}:{},...l?{defaultEffort:l}:{},...e.allowEffortSelect?{allowEffortSelect:!0}:{},...e.summaries===null?{}:{summaries:e.summaries},...e.maxOutputTokens===null?{}:{maxOutputTokens:e.maxOutputTokens},...e.temperature===null?{}:{temperature:e.temperature},...e.builtInTools.length?{builtInTools:[...e.builtInTools]}:{},...Object.keys(e.options).length?{options:e.options}:{},...f?{limits:f}:{},...d?{compaction:d}:{}}}function ot(e,t,n){let r={};for(let{name:i,label:a,isTimer:o}of Ce){let s=e.limits?.[i]??null;s!==null&&(J(n,t,`limits.${i}`,a,s,1),o&&s>2147483647&&n(t,`${a} must be at most ${Se} ms.`,`limits.${i}`),r[i]=s)}return Object.keys(r).length?r:void 0}function st(e,t,n,r,i){let a=t.find(t=>t.id===e.provider),o=a&&w(a,n)?.find(t=>t.id===e.protocol);for(let t of o?.options.safeParse(e.options).error?.issues??[]){let e=t.code===`unrecognized_keys`?t.keys[0]:t.path[0];i(r,o&&t.code===`unrecognized_keys`&&typeof e==`string`?rt(o,e):t.message,typeof e==`string`?`options.${e}`:`options`)}let s=e.apiId.trim();for(let t of s?o?.refusedOptions?.(s)??[]:[])e.options[t]!==void 0&&i(r,`${s} takes no ${t}.`,`options.${t}`)}function ct(e,t,n,r,i){let a=e.compactTiming;if(!a)return;t!==`text`&&r(n,`Only a text agent compacts its own history.`,`compactTiming`);let o=e.compactMaxTokens??null,s=e.compactAt??we.compactAt,c=e.compactKeep??null;o===null&&r(n,`Compaction needs a budget.`,`compactMaxTokens`),J(r,n,`compactMaxTokens`,`Budget`,o,1),s>0&&s<1||r(n,`Compaction must start between 0 and 1 of the budget.`,`compactAt`),c!==null&&(c===0||Number.isInteger(c)&&c>=1||c>0&&c<s)||r(n,`Keep a whole number of exchanges, a fraction of the budget below where compaction starts, or 0.`,`compactKeep`);let l=e.compactWith??``,u=l?i(l):void 0;return l&&!u&&r(n,`The agent that summarised is gone. Pick another, or this agent.`,`compactWith`),{maxTokens:o??0,compactAt:s,...u?{profile:u}:{},previousExchanges:c??0,timing:a,...e.compactMeter?{meter:e.compactMeter}:{}}}function lt(e,t,n){let{models:r,modelBindings:i}=e;i.length||n(`models`,`Add at least one model.`);let a=r.defaultModel.trim();return a&&!(a in t)?n(`models`,`Default model '${a}' is not one of the models.`,`defaultModel`):!a&&_e(e)&&n(`models`,`Pick a default model — there is more than one.`,`defaultModel`),r.maxSteps!==null&&!Number.isInteger(r.maxSteps)&&n(`models`,`Max steps must be a whole number.`,`maxSteps`),a}function ut(e,t,n,r){let{models:i,modelBindings:a}=e,o={};for(let s of a){let a=at({...s,keySlot:s.keySlot||i.key||void 0,fallbackKeySlot:s.fallbackKeySlot||i.fallbackKey||void 0},t,e.providers,n,r),c=s.modelId.trim(),l=B(s.key);c?c in o?n(l,`Model id '${c}' is used twice.`,`modelId`):o[c]=a:n(l,`Model id is required.`,`modelId`)}let s=lt(e,o,n),c=i.providerHistory===`provider`||i.providerHistory===`stateless`?i.providerHistory:void 0;return{models:o,...s?{defaultModel:s}:{},...c?{providerContinuation:{history:c}}:{},...i.allowModelSelect?{allowModelSelect:!0}:{},...i.maxSteps===null?{}:{maxSteps:i.maxSteps}}}function Y(e,t){if(!e?.trim())return;let n;try{n=JSON.parse(e)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=Object.entries(n);return r.every(([,e])=>t(e))?r.length?Object.fromEntries(r):void 0:null}var dt=e=>typeof e==`string`,ft=e=>!0;function pt(e){return Y(e,dt)}var mt=e=>De(e,`system`)===void 0;function ht(e,t){let n=Y(e,mt);if(n===null){t(`Instructions by role must be a JSON object of text, or of lists of text and { "private": text }.`);return}if(!n)return;let r={};for(let[e,i]of Object.entries(n)){if(typeof i!=`string`){r[e]=i;continue}let n=Ye(i);if(!n.ok){t(`${e}: ${n.message}`);return}n.prompt!==void 0&&(r[e]=n.prompt)}return r}function gt(e,t,n){let r=Y(e,t);return r===null&&n(),r??void 0}function _t(e,t){if(!e.authType||e.authType===`none`)return;let n=e.authService?.trim()??``;n||t(`Service is required.`,`authService`);let r=q(e.authScopes),i=e.authType===`api_key`?e.authQueryParam?.trim():void 0;i&&q(e.queryParams).includes(i)&&t(`${i} is also one of the query parameters the model fills.`,`authQueryParam`);let a=i?{queryParam:i}:{...e.authHeaderName?.trim()?{headerName:e.authHeaderName.trim()}:{},...e.authHeaderPrefix===void 0?{}:{headerPrefix:e.authHeaderPrefix}};return{slot:e.authSlot?.trim()||`default`,type:e.authType,service:n,...a,onUnauthenticated:e.authUnauthenticated??`gate`,...r.length?{scopes:r}:{},...e.authClientId?.trim()?{clientId:e.authClientId.trim()}:{},...e.authRedirectUri?.trim()?{redirectUri:e.authRedirectUri.trim()}:{}}}function vt(e){try{return new URL(e),!0}catch{return!1}}function yt(e,t){e?ce(e)&&t(`${e} is a provider builtin — turn it on under the model's built-in tools.`,`toolName`):t(`Tool name is required.`,`toolName`)}function bt(e,t,n){let r=e.toolName.trim();yt(r,t);let i=e.description.trim();i||t(`Description is required.`,`description`);let a=e.toolType===`agent`?{inputSchema:n(e.agentKey??``)??St,outputSchema:Ct}:xt(e,t),o=q(e.paths);return{name:r,description:i,category:e.category.trim()||`studio`,access:e.access,permission:e.permission,loadTier:e.loadTier,paths:o.length?o:[`*`],...a}}function xt(e,t){let n=D(e.inputJson,`Input`);n.ok||t(n.error,`inputJson`);let r=D(e.outputJson,`Output`);return r.ok||t(r.error,`outputJson`),{inputSchema:n.ok?n.schema:{},outputSchema:r.ok?r.schema:{}}}var St=V(Ae({type:`text`}),`input`),Ct=V(Oe,`output`);function wt(e){let t=e.identity.profileType;if(t!==`text`&&t!==`image`&&t!==`speech`)return;let n=t!==`speech`&&R(e).includes(`inputs`)?Bt(e.inputs,t,()=>{}):void 0;return V(Ae({type:t,...n?{inputs:n}:{}}),`input`)}function Tt(e){return(e??``).split(`
4
- `).map(e=>e.trim()).filter(Boolean)}function Et(e,t,n){let r={},i={activity:{input:t.inputSchema},activityPast:{input:t.inputSchema,output:t.outputSchema},activityFailed:{input:t.inputSchema},request:{input:t.inputSchema}};for(let t of[`activity`,`activityPast`,`activityFailed`,`request`]){let a=Tt(e[t]),[o]=a;if(o===void 0)continue;let s=a.length===1?o:a,c=M(s,i[t]);c?n(c,t):r[t]=s}return Object.keys(r).length?r:void 0}function Dt(e){let t=Object.entries(e??{}).find(([e,t])=>K(e)&&t!==`••••`)?.[0];return t?`${t} looks like a credential. Put it under Auth instead: Auth asks for it when a call runs and nothing saves it.`:void 0}function Ot(e){if(!e||!URL.canParse(e))return;let t=[...new URL(e).searchParams].find(([e,t])=>K(e)&&t&&t!==`••••`)?.[0];return t?`${t} in the URL looks like a credential. Put it under Auth instead, as an API key with ${t} as its query parameter: Auth asks for it when a call runs and nothing saves it.`:void 0}function kt(e,t){let n=pt(e.headersJson);n===null&&t(`Headers must be a JSON object of strings. Until they are, a reload brings back the headers as they started.`,`headersJson`);let r=Dt(n??void 0);r&&t(r,`headersJson`);let i=e.toolType===`mcp`?`serverUrl`:`endpoint`,a=Ot(e[i]?.trim());a&&t(a,i);let o=_t(e,t),s=e.maxResponseBytes??null;return s!==null&&!(Number.isInteger(s)&&s>=1)&&t(`Max response must be a positive whole number.`,`maxResponseBytes`),{...n?{headers:n}:{},...o?{auth:o}:{},...s===null?{}:{maxResponseBytes:s}}}function At(e,t,n,r){let i=e[t]?.trim()??``;return i?vt(i)||r(`${n} must be a full URL.`,t):r(`${n} is required.`,t),i}function jt(e,t,n){let r=At(e,`endpoint`,`Endpoint URL`,n),i=q(e.pathParams),a=q(e.queryParams),o=e.bodyParam?.trim(),s={...i.length?{pathParams:i}:{},...a.length?{queryParams:a}:{},...o?{bodyParam:o}:{}};return{type:`http`,...t,endpoint:r,method:e.method??se[0],...kt(e,n),...Object.keys(s).length?{mapping:s}:{}}}function Mt(e,t,n){let r=At(e,`serverUrl`,`MCP server URL`,n),i=e.mcpToolName?.trim()??``;return i||n(`MCP tool name is required.`,`mcpToolName`),{type:`mcp`,...t,serverUrl:r,mcpToolName:i,...kt(e,n),...Nt(e,n)}}function Nt(e,t){let n=e.sessionIdleMs??null,r=e.sessionMax??null;n!==null&&!(Number.isInteger(n)&&n>=1)&&t(`Idle must be a positive whole number.`,`sessionIdleMs`),r!==null&&!(Number.isInteger(r)&&r>=1)&&t(`Max must be a positive whole number.`,`sessionMax`);let i={...n===null?{}:{idleMs:n},...r===null?{}:{max:r}};return Object.keys(i).length?{session:i}:{}}function Pt(e,t,n){let r=e.answeredBy===`page`?{answeredBy:`page`}:{};if(!e.stubOutputJson?.trim())return{type:`function`,...t,...r};let i=D(e.stubOutputJson,`Stub output`);return i.ok||n(i.error.replace(` JSON Schema`,``),`stubOutputJson`),{type:`function`,...t,...r,...i.ok?{stubResponse:i.schema}:{}}}function Ft(e,t,n,r){let i=e.agentKey??``,a=i?r(i):void 0;i?a||n(`The agent this tool ran is gone. Pick another.`,`agentKey`):n(`Pick the agent this tool runs.`,`agentKey`);let o=e.maxCallsPerTurn??null;return o!==null&&!(Number.isInteger(o)&&o>=1)&&n(`Calls per turn must be a positive whole number.`,`maxCallsPerTurn`),{type:`agent`,...t,profile:a??``,...o===null?{}:{maxCallsPerTurn:o}}}var It={http:jt,mcp:Mt,function:Pt,agent:Ft};function Lt(e){return Ne.includes(e)}function Rt(e,t,n,r){let i=Ee(e.key);if(!Lt(e.toolType)){t(i,Pe,`toolType`);return}let a=!1,o=(e,n)=>{a=!0,t(i,e,n)},s=bt(e,o,r),c=Et(e,s,o),l=It[e.toolType](e,s,o,n),u=e.toolType===`agent`?``:e.stageAgentKey?.trim()??``,d=u?n(u):void 0;return a?void 0:{...l,...c?{labels:c}:{},...d&&l.type!==`agent`?{stageAgent:d}:{}}}function zt(e,t,n,r,i,a){let o=[],s=new Set;for(let t of e.toolSpecs){let e=Rt(t,r,i,a);e&&(s.has(e.name)?r(Ee(t.key),`Tool name '${e.name}' is used twice.`,`toolName`):(s.add(e.name),o.push(e)))}let c=o.map(e=>e.name),l=t?e.tools.t2Loader.trim():``;l&&!s.has(l)&&r(`tools`,`T2 loader '${l}' must be one of the custom tools.`,`t2Loader`);let u=n&&e.tools.parallel;return{customTools:o,tools:{allow:c,...l?{t2Loader:l}:{},...u?{parallel:u}:{}}}}function Bt(e,t,n){let r=t===`image`?e.attachmentsAccept.filter(e=>!k(oe,e)):[];if(r.length&&n(`inputs`,`An image profile takes images, video, and PDF only, not ${r.join(`, `)}.`,`attachmentsAccept`),!e.text&&!e.attachmentsAccept.length&&!e.voiceAccept.length&&n(`inputs`,`Take text, files, or voice notes: with none, the agent can be sent nothing.`,`text`),ve(e)){let t=[[`maxFiles`,`Max files`,e.maxFiles],[`maxBytes`,`Max bytes`,e.maxBytes],[`maxTurnBytes`,`Max turn bytes`,e.maxTurnBytes]];for(let[e,r,i]of t)i===null&&n(`inputs`,`${r} is required with attachments or voice.`,e)}J(n,`inputs`,`maxFiles`,`Max files`,e.maxFiles,1),J(n,`inputs`,`maxBytes`,`Max bytes`,e.maxBytes,1),J(n,`inputs`,`maxTurnBytes`,`Max turn bytes`,e.maxTurnBytes,1);let i=Ht(e,n),a=Wt(e,n),o=Vt(e,n);return{...e.text?{}:{text:!1},...e.attachmentsAccept.length?{attachments:{accept:[...e.attachmentsAccept]}}:{},...e.voiceAccept.length?{voice:{accept:[...e.voiceAccept]}}:{},...e.maxFiles===null?{}:{maxFiles:e.maxFiles},...e.maxBytes===null?{}:{maxBytes:e.maxBytes},...e.maxTurnBytes===null?{}:{maxTurnBytes:e.maxTurnBytes},...i?{limitsByMime:i}:{},...a?{slots:a}:{},...o?{context:o}:{}}}function Vt(e,t){if(e.contextFrom.length)return e.contextMaxChars===null&&t(`inputs`,`Max characters is required with context.`,`contextMaxChars`),J(t,`inputs`,`contextMaxChars`,`Max characters`,e.contextMaxChars,1),{from:[...e.contextFrom],maxChars:e.contextMaxChars??0}}function Ht(e,t){let n=Object.entries(e.limitsByMime);for(let[e,r]of n)Number.isInteger(r)&&r>=1||t(`inputs`,`Max size for ${e} must be a whole number of at least 1.`,`limitsByMime`);return n.length?{...e.limitsByMime}:void 0}function Ut(e,t,n){let r=e.name.trim(),i=[];r?n.findIndex(e=>e.name.trim()===r)<t&&i.push(`Another slot is called ${r}.`):i.push(`Name this slot.`);let a=e.choices.map(e=>e.value.trim());a.some(Boolean)||i.push(`Give this slot a choice.`),e.choices.some((e,t)=>!a[t]&&e.description.trim())&&i.push(`Every choice with a description needs a value.`);let o=a.filter((e,t)=>e&&a.indexOf(e)<t);for(let e of new Set(o))i.push(`${e} is a choice twice.`);return i}function Wt(e,t){if(e.slots.length)return e.slots.forEach((n,r)=>{for(let i of Ut(n,r,e.slots))t(`inputs`,i,`slots`,r)}),Object.fromEntries(e.slots.map(e=>{let t=e.label.trim(),n=e.choices.filter(e=>e.value.trim()).map(e=>({value:e.value.trim(),description:e.description.trim()})),r=!t&&n.every(e=>!e.description)?n.map(e=>e.value):{...t?{label:t}:{},choices:n.map(({value:e,description:t})=>t?{value:e,description:t}:{value:e})};return[e.name.trim(),r]}))}function Gt(e,t){let n=Wt(e,t),r=Vt(e,t);return!n&&!r?{}:{inputs:{...n?{slots:n}:{},...r?{context:r}:{}}}}function Kt(e,t,n){let r,i=t&&e.validationEnabled;if(t&&e.mode===`structured`){let t=e.schemaId.trim();t||n(`outputs`,`Structured output needs a schema id.`,`schemaId`);let i=D(e.schemaJson,`Structured output`);i.ok||n(`outputs`,i.error,`schemaJson`),t&&i.ok&&(r={id:t,spec:{jsonSchema:i.schema}})}i&&J(n,`outputs`,`maxRetries`,`Validation max retries`,e.maxRetries,0);let a=Object.fromEntries(Object.entries(e.itemRules).map(([e,t])=>[e,{onFail:t}])),o=i?{...e.maxRetries===null?{}:{maxRetries:e.maxRetries},...Object.keys(a).length?{items:a}:{}}:{},s={...e.streamMode?{mode:e.streamMode}:{},...e.streamThoughts?{}:{streamThoughts:!1}},c={...r?{structured:r.id}:{},...Object.keys(o).length?{validation:o}:{},...Object.keys(s).length?{streaming:s}:{}};return{...Object.keys(c).length?{outputs:c}:{},...r?{structured:r}:{}}}function qt(e,t){return e.resumeEnabled?(J(t,`turnBehaviour`,`maxContinues`,`Max continues`,e.maxContinues,1),{allowContinue:[...e.allowContinue],autoContinue:[...e.autoContinue],...e.maxContinues===null?{}:{maxContinues:e.maxContinues}}):{allowContinue:[],autoContinue:[]}}function Jt(e,t,n){let r=t?qt(e,n):void 0,i={...r?{resumption:r}:{},...e.allowSteering?{}:{allowSteering:!1},...e.atStepLimit===`answer`?{atStepLimit:e.atStepLimit}:{}};return Object.keys(i).length?i:void 0}function Yt(e,t,n,r){let i=[],a=e=>t.has(e)||t.has(`labels`),{turnBehaviour:o,guardrails:s,outputs:c}=e;if(a(`turnBehaviour`)&&be(e)&&i.push([`turnBehaviour`,`continueInstruction`,`continue.instruction`,o.continueInstruction.trim()]),a(`guardrails`)&&n(`identity.system`)&&i.push([`guardrails`,`canaryBindNote`,`canary.bind_note`,s.canaryBindNote.trim()]),a(`guardrails`)&&n(`guardrails.quota`)&&i.push([`guardrails`,`quotaMessage`,`quota.exhausted`,s.quotaMessage.trim()]),a(`outputs`)&&n(`outputs.validation`)&&i.push([`outputs`,`repairGuidance`,`repair.default_guidance`,c.repairGuidance.trim()]),a(`guardrails`)&&n(`guardrails.blockedReply`)&&(i.push([`guardrails`,`egressRepairGuidance`,`egress.default_repair_guidance`,s.egressRepairGuidance.trim()]),i.push([`guardrails`,`egressRefusal`,`egress.refusal`,s.egressRefusal.trim()])),t.has(`labels`))for(let[t,n]of Object.entries(e.labels))Te[t]||i.push([`labels`,t,t,n.trim()]);let l={};for(let[e,t,n,a]of i)if(a)try{pe({[n]:a},`Profile labels`),l[n]=a}catch(n){r(e,de(n),t)}return Object.keys(l).length?l:void 0}function Xt(e,t){if(e.quotaEnabled){if(e.quotaPerDay===null)t(`guardrails`,`Quota needs turns per day.`,`quotaPerDay`);else return J(t,`guardrails`,`quotaPerDay`,`Quota per day`,e.quotaPerDay,1),{perDay:e.quotaPerDay}}}function Zt(e,t){J(t,`guardrails`,`blockedReplyMaxRetries`,`Blocked reply max retries`,e.blockedReplyMaxRetries,0);let n={...e.blockedReplyOnBlock?{onBlock:e.blockedReplyOnBlock}:{},...e.blockedReplyMaxRetries===null?{}:{maxRetries:e.blockedReplyMaxRetries}};return Object.keys(n).length?n:void 0}function Qt(e){return $t(e,()=>{})}function $t(e,t){let n=e.allowedHosts.map(e=>e.trim()),r=n.indexOf(``);r!==-1&&t(`guardrails`,`Allowed hosts cannot be blank.`,`allowedHosts`,r);let i=q(e.allowedSchemes);if(e.allowPrivateNetworks||n.length||i.length)return{...e.allowPrivateNetworks?{allowPrivateNetworks:!0}:{},...n.length?{allowedHosts:n}:{},...i.length?{allowedSchemes:i}:{}}}function en(e,t,n){let r=t.hosts.map(e=>e.trim()),i=r.indexOf(``);i!==-1&&n(`guardrails`,`Allowed hosts cannot be blank.`,`allow.${e}.hosts`,i);let a=r.filter(Boolean),o={...a.length?{hosts:a}:{},...t.fromTools?{}:{fromTools:!1}};return Object.keys(o).length?o:void 0}function tn(e,t){for(let[t,n]of e.entries()){let e=`Pattern ${t+1}`;if(!n.name.trim())return`${e} needs a name.`;if(n.kind===`words`){if(!q(n.words).length)return`${e} needs a word to match.`}else if(!n.pattern)return`${e} needs a regular expression.`}let n=P(``,t);if(n===void 0)return;let r=/^\.patterns\[(\d+)\](?:\.(\w+))?:? (.*)$/s.exec(n);if(!r)return n.replace(/^\.patterns/,`This`);let[,i,a,o]=r;return`Pattern ${Number(i)+1}${a?`, ${a}`:``}: ${o}`}function nn(e,t,n){let r=e.map(e=>{let t=e.name.trim();if(e.kind===`words`)return{name:t,words:q(e.words)};let n=e.flags.trim();return{name:t,pattern:e.pattern,...n?{flags:n}:{}}}),i=tn(e,r);return i!==void 0&&n(`guardrails`,i,t),r}function rn(e,t,n){if(!t||!F[e].patterns)return{};let r=an(t.hint,`sources.${e}.hint`,n),i=nn(t.patterns,`sources.${e}.patterns`,n);return{...t.theorem?{}:{theorem:!1},...i.length?{patterns:i}:{},...i.length&&r?{hint:r}:{}}}function an(e,t,n){let r=e.trim();if(!r)return;let i=he(`The retry hint`,r);return i!==void 0&&n(`guardrails`,`${i}.`,t),r}function on(e,t){if(!e)return`Give this detector a key, such as acme.codenames.`;let n={label:e,action:`flag`,find:cn};return ge(`Detect`,{[e]:n},t)===void 0?void 0:`A key is a namespace, a dot, and a name, in lower case letters, digits and _, such as acme.codenames.`}function sn(e,t,n){let r={};for(let[i,a]of e.entries()){let e=a.key.trim();if(Object.hasOwn(r,e)){n(`guardrails`,`Detector ${e} is listed twice.`,`own`,i);continue}let o=t.filter(e=>a.at[e]!==`ignore`),s=an(a.hint,`own.${i}.hint`,n),c=nn(a.patterns,`own.${i}.patterns`,n),l=a.label.trim(),u=on(e,t);u!==void 0&&n(`guardrails`,u,`own`,i),l||n(`guardrails`,`Give this detector a name.`,`own.${i}.label`),o.length||n(`guardrails`,`Pick what a match does. It is ignored now.`,`own.${i}.at`),u===void 0&&l&&o.length&&(r[e]={label:l,at:Object.fromEntries(o.map(e=>[e,a.at[e]])),patterns:c,...s?{hint:s}:{}})}return r}var cn=()=>[];function ln(e){return e===void 0||typeof e==`string`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>{if(typeof t==`string`||t.patterns===void 0)return[e,t];let{patterns:n,...r}=t;if(e.includes(`.`))return[e,{...r,find:cn}];let{hint:i,...a}=r;return[e,a]}))}function un(e){let{guardrails:t}=e;return!t||!(`detect`in t)||t.detect===void 0?e:{...e,guardrails:{...t,detect:ln(t.detect)}}}function dn(e,t,n){let{detect:r}=e,i={};for(let a of I){let o=t.filter(e=>r[a][e]!==me[a][e]),s=t.some(e=>r[a][e]!==`ignore`)?fn(a,e,n):void 0,c=rn(a,e.sources[a],n);(o.length||s||Object.keys(c).length)&&(i[a]={...o.length?{at:Object.fromEntries(o.map(e=>[e,r[a][e]]))}:{},...c,...s?{allow:s}:{}})}Object.assign(i,sn(e.own,t,n));let a=ge(`Detect`,ln(i),t);return a!==void 0&&n(`guardrails`,a,`detect`),Object.keys(i).length?i:void 0}function fn(e,t,n){if(pn(e))return en(e,t.allow[e],n);if(F[e].allow!==`names`)return;let r=t.innocentNames.map(e=>e.trim()),i=r.indexOf(``);i!==-1&&n(`guardrails`,`Allowed names cannot be blank.`,`innocentNames`,i);let a=r.filter(Boolean);return a.length?{names:a}:void 0}function pn(e){return F[e].allow===`urls`}function mn(e){let{taintAfterRemoteRead:t,taintRemoteDestination:n}=e;if(t||n)return{...t?{afterRemoteRead:t}:{},...n?{remoteDestination:n}:{}}}function hn(e,t,n=fe){let r={detect:dn(e,n,t),quota:Xt(e,t),blockedReply:Zt(e,t),network:$t(e,t),taint:mn(e)},i=Object.fromEntries(Object.entries(r).filter(([,e])=>e!==void 0));return Object.keys(i).length?i:void 0}function gn(e,t){let n=je({}),{writeTo:r}=e,{sampleRate:i}=e;Number.isFinite(i)&&i>=0&&i<=1||t(`observability`,`Sample rate must be between 0 and 1.`,`sampleRate`),e.retainForDays!==null&&!Number.isFinite(e.retainForDays)&&t(`observability`,`Retain for days must be a number.`,`retainForDays`),e.rotateAfterMiB!==null&&!(Number.isFinite(e.rotateAfterMiB)&&e.rotateAfterMiB>0)&&t(`observability`,`Rotate after MiB must be more than zero.`,`rotateAfterMiB`);let a=gt(e.resourceJson,ft,()=>{t(`observability`,`Resource must be a JSON object.`,`resourceJson`)}),o=Object.fromEntries(Object.entries(e.include).filter(([e,t])=>t!==n.include[e])),s=Object.fromEntries(Object.entries(e.scrub).filter(([e,t])=>t!==n.scrub[e])),c={writeTo:r,...i===n.sampleRate?{}:{sampleRate:i},...Object.keys(o).length?{include:o}:{},...Object.keys(s).length?{scrub:s}:{},...e.retainForDays===null?{}:{retainForDays:e.retainForDays},...e.rotateAfterMiB===null?{}:{rotateAfterMiB:e.rotateAfterMiB},...a?{resource:a}:{}};return Object.keys(c).length?c:void 0}var _n={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,webp:`image/webp`,gif:`image/gif`};function vn(e){if(!URL.canParse(e))return;let t=new URL(e);return t.protocol!==`https:`&&t.protocol!==`http:`?void 0:_n[t.pathname.split(`.`).pop()?.toLowerCase()??``]}function yn(e,t){return e.flatMap((e,n)=>{if(`data`in e)return e.mimeType.startsWith(`image/`)&&e.data?[{mimeType:e.mimeType,data:e.data,name:e.name}]:(t(`image`,`${e.name||`A reference`} is not an image.`,`references`,n),[]);let r=e.uri.trim(),i=vn(r);return i?[{mimeType:i,uri:r,...e.name?{name:e.name}:{}}]:(t(`image`,r?`Link to a .png, .jpg, .webp or .gif image over http(s).`:`Add a link or remove the reference.`,`references`,n),[])})}function bn(e,t){J(t,`image`,`n`,`Images per request`,e.n,1),J(t,`image`,`seed`,`Seed`,e.seed,0),J(t,`image`,`outputCompression`,`Compression`,e.outputCompression,0),e.outputCompression!==null&&e.outputCompression>100&&t(`image`,`Compression goes from 0 to 100.`,`outputCompression`);let n=yn(e.references,t);return{...e.aspectRatio.trim()?{aspectRatio:e.aspectRatio.trim()}:{},...e.resolution.trim()?{resolution:e.resolution.trim()}:{},...e.mimeType.trim()?{mimeType:e.mimeType.trim()}:{},...e.quality.trim()?{quality:e.quality.trim()}:{},...e.background.trim()?{background:e.background.trim()}:{},...e.n===null?{}:{n:e.n},...e.seed===null?{}:{seed:e.seed},...e.outputCompression===null?{}:{outputCompression:e.outputCompression},...e.includeText?{includeText:!0}:{},...n.length?{references:n}:{}}}function xn(e,t,n){let{format:r}=e;if(r){let e=t.modelBindings.find(e=>E(O(t.providers,`speech`,e))&&!A.includes(r));e&&n(`speech`,`Google doesn't make ${r}; ${e.modelId} is on ${e.provider}.`,`format`)}let i=t.modelBindings.find(e=>E(O(t.providers,`speech`,e)));i&&!e.voice.trim()&&n(`speech`,`Gemini needs a voice to speak; ${i.modelId} is on ${i.provider}.`,`voice`);let{speed:a}=e;return{...e.voice.trim()?{voice:e.voice.trim()}:{},...e.style.trim()?{style:e.style.trim()}:{},...a===null?{}:{speed:a},...r?{format:r}:{}}}function Sn(e,t){J(t,`live`,`resumedAfterMs`,`Away for`,e.resumedAfterMs,0);let n=e.resumedPrompt.trim();if(n&&!e.sessionResumption&&t(`live`,`A resume prompt needs Resumption on.`,`resumedPrompt`),!n)e.resumedAfterMs!==null&&t(`live`,`Away for needs a resume prompt.`,`resumedAfterMs`);else return{prompt:n,...e.resumedAfterMs===null?{}:{afterMs:e.resumedAfterMs}}}function Cn(e,t,n){!e.ingressAudio&&!e.ingressVideo&&!e.ingressText&&t(`live`,`Turn on at least one ingress channel.`),J(t,`live`,`vadPrefixPaddingMs`,`VAD prefix padding`,e.vadPrefixPaddingMs,0),J(t,`live`,`vadSilenceDurationMs`,`VAD silence duration`,e.vadSilenceDurationMs,0),e.contextCompression&&wn(e,t,n.mode===`demo`?n.keys.liveInputTokens:void 0);let r=Sn(e,t),i={audio:e.ingressAudio,video:e.ingressVideo,text:e.ingressText},a=Object.fromEntries(Object.entries(i).filter(([e,t])=>t!==Me(e))),o={...e.vadActivityHandling?{activityHandling:e.vadActivityHandling}:{},...e.vadStartSensitivity?{startSensitivity:e.vadStartSensitivity}:{},...e.vadEndSensitivity?{endSensitivity:e.vadEndSensitivity}:{},...e.vadPrefixPaddingMs===null?{}:{prefixPaddingMs:e.vadPrefixPaddingMs},...e.vadSilenceDurationMs===null?{}:{silenceDurationMs:e.vadSilenceDurationMs}},s={...e.transcriptionInput?{input:!0}:{},...e.transcriptionOutput?{output:!0}:{}};return{...Object.keys(a).length?{ingress:a}:{},...e.voice.trim()?{voice:e.voice.trim()}:{},...Object.keys(o).length?{vad:o}:{},...e.sessionResumption?{sessionResumption:!0}:{},...e.greeting.trim()?{greeting:e.greeting.trim()}:{},...r?{resumed:r}:{},...e.contextCompression?{contextCompression:Tn(e)}:{},...Object.keys(s).length?{transcription:s}:{}}}function wn(e,t,n){J(t,`live`,`compressionTriggerTokens`,`Compression trigger`,e.compressionTriggerTokens,1),J(t,`live`,`compressionTargetTokens`,`Compression target`,e.compressionTargetTokens,1);let r=e.compressionTriggerTokens,i=e.compressionTargetTokens,a=n?.toLocaleString(`en-US`);n!==void 0&&r!==null&&r>n&&t(`live`,`Compression trigger can't exceed the ${a} input tokens a session holds on these keys.`,`compressionTriggerTokens`),i!==null&&(r!==null&&i>=r||n!==void 0&&r===null&&i>=n)&&t(`live`,r===null?`Compression target must be below the ${a} input tokens a session holds on these keys.`:`Compression target must be below the trigger.`,`compressionTargetTokens`)}function Tn(e){let t=e.compressionTriggerTokens,n=e.compressionTargetTokens;return{...t===null?{}:{triggerTokens:t},slidingWindow:n===null?{}:{targetTokens:n}}}function En(e,t){let[n,...r]=t,{[n]:i,...a}=e;return!r.length||typeof i!=`object`||!i?a:{...a,[n]:En(i,r)}}function Dn(e){let t=e;for(let{path:n}of j(e))t=En(t,n.split(`.`));return t}function On(e,t){let n=Object.create(null);return e.questionsBuilt||(e.questions.length||t(`decision`,`Add at least one question.`,`questions`),e.questions.forEach((e,r)=>{let i=e=>t(`decision`,e,`questions`,r),a=e.id.trim(),o=e.instructions.trim();a?Object.hasOwn(n,a)&&i(`Question id '${a}' is used twice.`):i(`Each question needs an id.`),o||i(`Question '${a||r+1}' needs instructions.`);let s=e.criteria.map(e=>({label:e.label.trim(),text:e.text.trim()}));if(!a||!o)return;if(e.type===`box`){let t=e.image?.trim();n[a]={type:`box`,instructions:o,...t?{image:t}:{}};return}if(e.type===`score`){(s.length<2||s.some(e=>!e.text))&&i(`Score '${a}' needs at least two levels, each described.`),n[a]={type:`score`,instructions:o,criteria:s.map(e=>e.text)};return}let c=Object.create(null);for(let e of s)e.label?Object.hasOwn(c,e.label)?i(`Option '${e.label}' of '${a}' is used twice.`):c[e.label]=e.text||e.label:i(`Every option of '${a}' needs a label.`);e.type===`choice`?(s.length<2&&i(`Choice '${a}' needs at least two options.`),n[a]={type:`choice`,instructions:o,criteria:c}):n[a]={type:`noul`,instructions:o,...s.length?{criteria:c}:{}}})),n}var kn=/^[a-z0-9_]+$/,An=[`image/png`,`image/jpeg`];function jn(e,t){let n=Object.create(null);return e.images.forEach((e,r)=>{let i=e=>t(`decision`,e,`images`,r),a=e.name.trim(),o=`<${a}>`;kn.test(a)?Object.hasOwn(n,o)?i(`Image ${o} is used twice.`):!An.includes(e.mimeType)||!e.data?i(`${o} is not a PNG or JPEG.`):n[o]={mimeType:e.mimeType,data:e.data}:i(`Name an image with lowercase letters, digits, and _.`)}),e.questions.forEach((e,r)=>{let i=[...e.instructions.matchAll(/<[a-z0-9_]+>/g)].map(([e])=>e),a=e.type===`box`?e.image?.trim():void 0;a?.startsWith(`<`)&&i.push(a);for(let e of new Set(i))Object.hasOwn(n,e)||t(`decision`,`No image is named ${e}.`,`questions`,r)}),n}function X(e,t,n){let r=t.has(`observability`)?gn(e.observability,n):void 0,i=Yt(e,t,t=>z(e,t),n);return{...r?{observability:r}:{},...i?{labels:i}:{}}}function Mn(e,t){let{decision:n}=e,r=n.contract.trim();return r||t(`decision`,`Contract is required.`,`contract`),r}function Nn(e,t,n,r){let i=n.decision,{decision:a,identity:o}=e,s=(e,t)=>e.trim().length>t;s(a.contract,i.idChars)&&r(`decision`,`Contract is limited to ${i.idChars} characters on these keys.`,`contract`),s(o.agentId,i.idChars)&&r(`identity`,`Profile id is limited to ${i.idChars} characters on these keys.`,`agentId`),s(o.handle,i.nameChars)&&r(`identity`,`Handle is limited to ${i.nameChars} characters on these keys.`,`handle`);let c=e.modelBindings[0];if(c){let e=B(c.key);c.timeoutMs!==null&&c.timeoutMs>i.timeoutMs&&r(e,`Timeout is limited to ${i.timeoutMs} ms on these keys.`,`timeoutMs`),s(c.modelId,i.nameChars)&&r(e,`Model id is limited to ${i.nameChars} characters on these keys.`,`modelId`),s(c.apiId,i.idChars)&&r(e,`API model is limited to ${i.idChars} characters on these keys.`,`apiId`)}a.maxStateBytes!==null&&a.maxStateBytes>i.stateBytes&&r(`decision`,`These keys take at most ${i.stateBytes} bytes of state.`,`maxStateBytes`),a.questions.length>i.questions&&r(`decision`,`These keys ask at most ${i.questions} questions.`,`questions`),a.images.length>i.images&&r(`decision`,`These keys send at most ${i.images} images.`,`images`),a.images.forEach((e,t)=>{Math.floor(e.data.length*3/4)>i.imageBytes&&r(`decision`,`Each image is limited to ${i.imageBytes} bytes on these keys.`,`images`,t)}),a.questions.forEach((a,o)=>{let l=e=>r(`decision`,e,`questions`,o);s(a.id,i.nameChars)&&l(`Question ids are limited to ${i.nameChars} characters on these keys.`),a.type===`box`&&i.images===0&&l(`These keys take no images, so a Box question has nothing to read.`),s(a.instructions,i.instructionsChars)&&l(`Instructions are limited to ${i.instructionsChars} characters on these keys.`),a.criteria.length>i.criteria&&l(`A question has at most ${i.criteria} options or levels on these keys.`),a.criteria.some(e=>s(e.text,i.criterionChars))&&l(`Each option or level is limited to ${i.criterionChars} characters on these keys.`),a.criteria.some(e=>s(e.label,i.nameChars))&&l(`Option labels are limited to ${i.nameChars} characters on these keys.`);let u=t[a.id.trim()],d=c&&u&&n.questionViolation(O(e.providers,`decision`,c),u);d&&l(d)})}function Pn(e,t,n){let{decision:r}=e,i=new Set(R(e)),a=Mn(e,t);e.modelBindings.length!==1&&t(`models`,`A decision needs exactly one model binding.`);let o=e.modelBindings[0],s=o?B(o.key):`models`;o&&(tt(o,`decision`,e.providers,t),st(o,e.providers,`decision`,s,t),o.modelId.trim()||t(s,`Model id is required.`,`modelId`),J(t,s,`timeoutMs`,`Timeout`,o.timeoutMs,1));let c=o?ot(o,s,t):void 0;J(t,`decision`,`maxStateBytes`,`Max state`,r.maxStateBytes,1);let l=On(r,t),u=jn(r,t);return n.mode===`demo`&&Nn(e,l,n.keys,t),{profile:{type:`decision`,id:e.identity.agentId.trim(),identity:{handle:e.identity.handle.trim()},models:o?{[o.modelId.trim()]:{protocol:o.protocol,provider:o.provider,apiId:o.apiId.trim(),...Object.keys(o.options).length?{options:o.options}:{},...o.keySlot||e.models.key?{keySlot:o.keySlot||e.models.key}:{},...o.fallbackKeySlot?{fallbackKeySlot:o.fallbackKeySlot}:{},...o.timeoutMs===null?{}:{timeoutMs:o.timeoutMs},...c?{limits:c}:{}}}:{},inputs:{state:`json`,...r.maxStateBytes===null?{}:{maxStateBytes:r.maxStateBytes}},decision:{contract:a},...X(e,i,t)},customTools:[],...r.questionsBuilt?{}:{questions:l},...Object.keys(u).length?{images:{...u}}:{}}}function Fn(e,t,n,r){let i=new Set(R(e)),{customTools:a,tools:o}=zt(e,z(e,`tools.t2Loader`),z(e,`tools.parallel`),t,n,r);a.length||t(`tools`,`Add at least one tool: a host runs only its tools.`);let s=i.has(`guardrails`)?hn(e.guardrails,t,L):void 0;return{profile:Dn({type:`host`,id:e.identity.agentId.trim(),tools:o,...s?{guardrails:s}:{},...X(e,i,t)}),customTools:a}}function In(e,t,n,r,i,a){let o=new Set(R(e)),s=t=>z(e,t),c=typeof e.identity.system==`string`?Ye(e.identity.system):{ok:!1,message:`The system prompt must be text.`};c.ok||n(`identity`,c.message,`system`);let l=c.ok?c.prompt:void 0,u=ht(e.identity.systemByRoleJson,e=>{n(`identity`,e,`systemByRoleJson`)}),d=ut(e,t,n,i),{outputs:f,structured:p}=o.has(`outputs`)?Kt(e.outputs,s(`outputs.structured`),n):{},{customTools:m,tools:h}=o.has(`tools`)?zt(e,s(`tools.t2Loader`),s(`tools.parallel`),n,i,a):{customTools:[]},g=o.has(`turnBehaviour`)?Jt(e.turnBehaviour,s(`turnBehaviour.resumption`),n):void 0,_=o.has(`guardrails`)?hn(e.guardrails,n):void 0;return{profile:Dn({type:t,id:e.identity.agentId.trim(),identity:{handle:e.identity.handle.trim(),...l?{system:l}:{},...u?{systemByRole:u}:{}},...d,...o.has(`image`)?{image:bn(e.image,n)}:{},...o.has(`speech`)?{speech:xn(e.speech,e,n)}:{},...o.has(`live`)?{live:Cn(e.live,n,r)}:{},...h?{tools:h}:{},...o.has(`inputs`)?t===`live`?Gt(e.inputs,n):{inputs:Bt(e.inputs,t,n)}:{},...f?{outputs:f}:{},...g?{turnBehaviour:g}:{},..._?{guardrails:_}:{},...X(e,o,n)}),customTools:m,...p?{structured:p}:{}}}function Ln(e,t,n=Xe,r=Ze){let i=[],a=(e,t,n,r)=>{i.push({nodeId:e,message:t,...n===void 0?{}:{field:n},...r===void 0?{}:{index:r}})};et(e,a),new Set([e.models.key,e.models.fallbackKey,...e.modelBindings.flatMap(t=>{let{keySlot:n,fallbackKeySlot:r}=ye(e,t);return[n,r]})].filter(Boolean)).size>32&&a(`models`,`The studio supports up to 32 key slots.`,`key`);let o=e.identity.profileType;if(!o)return a(`identity`,`Pick a profile type.`,`profileType`),{ok:!1,issues:i};if(o!==`host`)for(let n of e.modelBindings){if(!n.apiId.trim())continue;let r=le({...O(e.providers,o,n),builtInTools:n.builtInTools},t);r&&a(B(n.key),r.message,r.field)}let s=o===`decision`?Pn(e,a,t):o===`host`?Fn(e,a,n,r):In(e,o,a,t,n,r);if(i.length)return{ok:!1,issues:i};try{ke(un(s.profile))}catch(e){if(!(e instanceof ue))throw e;return{ok:!1,issues:[{nodeId:`identity`,message:e.message}]}}return{ok:!0,agentId:s.profile.id,providers:e.providers,...s}}var Z=e(i(),1),Q=t(),Rn=(0,Z.lazy)(()=>b(()=>import(`./TraceInspector-DgOd5uwx.js`).then(e=>({default:e.TraceGuardrailsBody})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85]))),zn=(0,Z.lazy)(()=>b(()=>import(`./TraceInspector-DgOd5uwx.js`).then(e=>({default:e.TraceFeedBody})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85]))),Bn=(0,Z.createContext)(`replace`);function Vn({value:e,children:t}){return(0,Q.jsx)(Bn,{value:e,children:t})}function Hn({id:e,header:t,traces:n}){return(0,Q.jsx)(g,{id:e,header:t,children:e=>(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(zn,{traces:n,isWide:e})})})}function Un(e,t,n){let r=x(),i=(0,Z.useId)(),[a,o]=(0,Z.useState)(!1),s=(0,Z.use)(Bn),c={name:r(`@theorem.panel.trace.name`),show:r(`@theorem.panel.trace.show`),hide:r(`@theorem.panel.trace.hide`),resize:r(`@theorem.panel.trace.resize`)};if(e.observability?.record!==!0)return{toggle:null,view:null,labels:c,offered:!1};let u=n??a,d=n===void 0?(0,Q.jsx)(p,{labels:c,icon:(0,Q.jsx)(l,{icon:ae}),panelId:i,open:u,onToggle:()=>o(e=>!e)}):null;return{toggle:d,view:u?Wn(s===`panel`,i,t,d):null,labels:c,offered:!0}}function Wn(e,t,n,r){let i=(0,Q.jsxs)(f,{floating:!0,children:[(0,Q.jsx)(qn,{traces:n}),r]});return e?(0,Q.jsx)(Gn,{id:t,header:i,traces:n}):(0,Q.jsx)(Hn,{id:t,header:i,traces:n})}function Gn({id:e,header:t,traces:n}){let{ref:r,width:i}=m();return(0,Q.jsxs)(`div`,{id:e,ref:r,style:{height:`100%`,position:`relative`},children:[t,(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(zn,{traces:n,isWide:v(i)})})]})}function Kn(e){for(let t of e)for(let e of t.spans){let t=e.attributes[`gen_ai.agent.name`];if(typeof t==`string`&&t)return t}return`trace`}function qn({traces:e}){let t=x(),n=y(e);if(n.length===0)return null;let r=t(`@theorem.panel.trace.download`);return(0,Q.jsx)(ie,{label:r,variant:`ghost`,tooltip:r,icon:(0,Q.jsx)(l,{icon:Le,size:`sm`}),onClick:()=>{let e=new Date().toISOString().replaceAll(`:`,`-`).slice(0,19),t=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),r=URL.createObjectURL(t),i=document.createElement(`a`);i.href=r,i.download=`${Kn(n)}-${e}.trace.json`,i.click(),URL.revokeObjectURL(r)}})}function Jn({inspector:e,children:t}){let n=(0,Z.useRef)(null),r=h(n,!1),i=(0,Z.useRef)(void 0),a=(0,Z.useCallback)(e=>{n.current=e;let t=i.current;typeof t==`function`?t(e):t!=null&&(t.current=e)},[]);if(!(0,Z.isValidElement)(t))return(0,Q.jsx)(_,{view:e.view,children:t});i.current=t.props.ref;let o=e.view!=null;return(0,Z.cloneElement)(t,{ref:a,end:(0,Q.jsx)(ee,{labels:e.labels,resizable:r.resizable,open:o,children:e.view})})}function Yn({inspector:e,children:t}){return(0,Z.use)(Bn)===`panel`&&e.offered?(0,Q.jsx)(Jn,{inspector:e,children:t}):(0,Q.jsx)(_,{view:e.view,children:t})}function Xn({records:e,head:t}){return(0,Q.jsx)(te,{children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Rn,{records:e,head:t})})})}var Zn={info:`info`,warning:`warning`,error:`error`,success:`success`},Qn={info:`accent`,warning:`warning`,error:`error`,success:`success`},$={root:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kMv6JI:`xjb2p0i`,$$css:!0},rootElevatedCard:{kaIpWk:`x1vf2byn`,$$css:!0},header:{k1xSpc:`x78zum5`,kGNEyG:`x1cy8zhl`,kwnvtZ:`x1a02dak`,k1C7PZ:`xak3so`,khm7nJ:`x4olc9o`,k8WAf4:`x8o8v82`,kg3NbH:`x1pzlopt`,$$css:!0},headerCardStandalone:{kaIpWk:`x1vf2byn`,$$css:!0},headerCardWithContent:{krdFHd:`xwxb7qi`,kfmiAY:`x13nour3`,kVL7Gh:`xbiv7yw`,kT0f0o:`x16uus16`,$$css:!0},headerCentered:{kGNEyG:`x6s0dn4`,$$css:!0},endArea:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kwnvtZ:`x1a02dak`,kjj79g:`x13a6bvl`,kOIVth:`x1txdalj`,kmuXW:`x2lah0s`,ks0D6T:`x193iq5w`,keTefX:`xvc5jky`,kqGvvJ:`x81ka23`,$$css:!0},chevron:{k1ekBW:`x11xpdln`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,$$css:!0},chevronExpanded:{k3aq6I:`x19jd1h0`,$$css:!0}},$n={info:{kWkggS:`xgcxg3y`,$$css:!0},warning:{kWkggS:`x24i8r5`,$$css:!0},error:{kWkggS:`x1pritpl`,$$css:!0},success:{kWkggS:`xu13z74`,$$css:!0}};function er(e){return Object.prototype.hasOwnProperty.call($n,e)}var tr={none:{kGVxlE:`x1gnnqk1`,$$css:!0},low:{kGVxlE:`x1i5ehqx`,$$css:!0},med:{kGVxlE:`x14hfi27`,$$css:!0},high:{kGVxlE:`x1kcpxr7`,$$css:!0}};function nr({status:e,title:t,description:i,icon:f,isDismissable:p=!1,onDismiss:m,dismissLabel:h,endContent:g,container:_=`card`,elevation:v=`none`,collapsible:y=!0,children:ee,xstyle:b,className:x,style:te,ref:ie,onFocusCapture:S,onPointerDownCapture:ae,...oe}){let C=u(),[se,w]=(0,Z.useState)(!1),T=typeof y==`object`&&y?y:{},{isEnabled:ce,isOpen:E,toggle:D}=d({isCollapsible:y!==!1&&{...T,defaultIsOpen:T.defaultIsOpen??!1}}),O=(0,Z.useRef)(null),k=(0,Z.useId)(),A=Zn[e],le=Qn[e],j=c(ee),M=C(`@astryx.banner.dismiss`),N=h??M,ue=h??(typeof t==`string`?C(`@astryx.banner.dismissTitled`,{dismiss:M,title:t}):M);if(se)return null;let P=(e,t)=>{e instanceof HTMLElement&&e!==document.body&&!t.contains(e)&&(O.current=e)},de=e=>{P(e.relatedTarget,e.currentTarget)},fe=e=>{P(document.activeElement,e.currentTarget)},pe=()=>{let e=O.current;w(!0),m?.(),e?.isConnected&&e.focus()},F=ce&&j,me=c(g)||p||F,he=c(g)||p,ge=!c(i)&&he,I=j&&(!ce||E),L=_===`card`;return(0,Q.jsxs)(`div`,{ref:ie,onFocusCapture:s(S,de),onPointerDownCapture:s(ae,fe),...o(r(`banner-frame`,{container:_,elevation:v}),n($.root,tr[v],L&&v!==`none`&&$.rootElevatedCard,b),x,te),...oe,children:[(0,Q.jsxs)(`div`,{...o(r(`banner`,{container:_,status:e}),n($.header,ge&&$.headerCentered,er(e)&&$n[e],L&&(I?$.headerCardWithContent:$.headerCardStandalone))),children:[(0,Q.jsx)(`div`,{...c(f)?o(r(`banner-icon`,{status:e}),{className:`x78zum5 x6s0dn4 x2lah0s`}):{className:`x78zum5 x6s0dn4 x2lah0s`},"aria-hidden":`true`,children:c(f)?f:A==null?null:(0,Q.jsx)(l,{icon:A,size:`md`,color:le,...r(`banner-icon`,{status:e})})}),(0,Q.jsxs)(`div`,{...{0:{className:`x78zum5 xdt5ytf xxhr3t x98rzlu xeuugli`},1:{className:`x78zum5 xdt5ytf xxhr3t x98rzlu xeuugli xgualba`}}[!!c(g)|0],children:[(0,Q.jsx)(`div`,{className:`x1ghz6dp xjb2p0i xcr08ib x2mo6ok x1kq96og x1tgivj0 xj0a0fe`,children:t}),c(i)&&(0,Q.jsx)(`div`,{...o(r(`banner-description`),{className:`x1ghz6dp xjb2p0i x141an7d x1sodnla x1ltkj2j xv1l7n4 xj0a0fe`}),children:i})]}),me&&(0,Q.jsxs)(`div`,{...n($.endArea,ne.inset(a[`--spacing-2`])),children:[g,F&&(0,Q.jsx)(re,{variant:`ghost`,size:`sm`,label:C(E?`@astryx.banner.collapse`:`@astryx.banner.expand`),tooltip:C(E?`@astryx.banner.collapse`:`@astryx.banner.expand`),icon:(0,Q.jsx)(l,{icon:`chevronDown`,size:`sm`,color:`inherit`,xstyle:[$.chevron,E&&$.chevronExpanded]}),onClick:D,"aria-expanded":E,"aria-controls":I?k:void 0,isIconOnly:!0}),p&&(0,Q.jsx)(re,{variant:`ghost`,size:`sm`,label:ue,tooltip:N,icon:(0,Q.jsx)(l,{icon:`close`,size:`sm`,color:`inherit`}),onClick:pe,isIconOnly:!0})]})]}),I&&(0,Q.jsx)(`div`,{id:F?k:void 0,...o(r(`banner-content`,{container:_,status:e}),{0:{className:`x1de1mus x8o8v82 x1pzlopt xgbv0en xw8tdv1 x92x3c3 x1t7ytsu x18b5jzi x1q0q8m5 x1j92z86 x1gejf6u xw8gpjh`},1:{className:`x1de1mus x8o8v82 x1pzlopt xgbv0en xw8tdv1 x92x3c3 x1t7ytsu x18b5jzi x1q0q8m5 x1j92z86 x1gejf6u xw8gpjh x1k5g1gk x1eprgri`}}[!!L|0]),children:ee})]})}nr.displayName=`Banner`;export{Ie as _,Un as a,Dt as c,un as d,H as f,Ge as g,He as h,Yn as i,Ot as l,We as m,Xn as n,wt as o,Ke as p,Vn as r,Ln as s,nr as t,Qt as u,Fe as v};
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{c as r,l as i,n as a,t as o}from"./SegmentedControlItem-BBGRPrxp.js";import{t as s}from"./VStack-CkVMcNiK.js";import{n as c,t as l}from"./StackItem-CQviqAfM.js";import{c as u,u as d}from"./browser-transport-DwKQIgk5.js";import{p as f}from"./fieldParts-B7DYLgh4.js";import{i as p}from"./useResolvedRequired-DbsOcDqy.js";import{a as m,c as ee,d as te,m as ne,o as h,u as re,v as g}from"./use-trace-records-B1vrKQmA.js";import{t as _}from"./Text-BOqCfzZC.js";import{n as v}from"./labels-provider-C_KY4x6D.js";import{n as ie,t as y}from"./Card-DruykyeB.js";import{n as b,t as ae}from"./IconButton-DVUFx-8p.js";import{n as x}from"./ScrollableArea-BHfY7sWH.js";import{i as S}from"./Banner-B_2gi5vH.js";import{a as oe}from"./arrive-DvbqpeRS.js";import{t as se}from"./Center-nHS1JSux.js";import{a as C,o as ce}from"./shaped-data-BO6EAfYh.js";import{n as w}from"./trace-patterns-D6TbkLLr.js";import{E as le,b as T,w as ue,x as E,xt as de,y as fe}from"./index-BK6Cf7vm.js";var D=e(n(),1),pe=new Set([`image/png`,`image/jpeg`]),O=`image/png,image/jpeg`;function me(e,t){let n=e.replace(/\.[^.]*$/,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`image`,r=`<${n}>`;for(let e=2;t.includes(r);e+=1)r=`<${n}_${String(e)}>`;return r}async function he(e){if(!pe.has(e.type))return null;let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return{mimeType:e.type,data:btoa(n)}}function k(e){return`data:${e.mimeType};base64,${e.data}`}function A(e,t){return typeof e==`string`?e===t:Array.isArray(e)?e.some(e=>A(e,t)):typeof e==`object`&&e?Object.values(e).some(e=>A(e,t)):!1}function j(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>A(t,e)))}function M(e,t,n){let r=me(e,[...Object.keys(t),...n.map(e=>`<${e}>`)]);return{key:r.slice(1,-1),reference:r}}function N(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function P(e,t){let{images:n,state:r}=t;for(let[i,a]of e){let{key:e,reference:o}=M(i.name,{...t.host,...n},Object.keys(r));n={...n,[o]:a},r={...r,[e]:o}}return{images:n,state:r}}function F(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=Array.isArray(n)?n[Number(e)]:n[e]}return n}function I(e,t,n){let r=n===void 0||n in e?n:F(t,n);if(typeof r==`string`&&r in e)return e[r];let i=Object.values(e);return n===void 0&&i.length===1?i[0]:void 0}function L(e,t,n){return{x:e.left*t,y:e.top*n,width:(e.right-e.left)*t,height:(e.bottom-e.top)*n,line:Math.max(2,Math.round(Math.min(t,n)/200))}}var R=.45;async function ge(e,t,n){let r=new Image;r.src=e,await r.decode();let i=document.createElement(`canvas`);i.width=r.naturalWidth,i.height=r.naturalHeight;let a=i.getContext(`2d`);if(!a)return e;let o=L(t,i.width,i.height);return a.drawImage(r,0,0),a.fillStyle=n.shade,a.globalAlpha=R,a.beginPath(),a.rect(0,0,i.width,i.height),a.rect(o.x,o.y,o.width,o.height),a.fill(`evenodd`),a.globalAlpha=1,a.strokeStyle=n.outline,a.lineWidth=o.line,a.strokeRect(o.x,o.y,o.width,o.height),i.toDataURL(`image/png`)}function _e(e){let t=e.right-e.left,n=e.bottom-e.top;return{width:100/t,height:100/n,left:-e.left/t*100,top:-e.top/n*100}}function ve(e){return e.every(e=>typeof e==`string`)}function z(e){return e==null||typeof e==`string`?``:typeof e==`number`?0:typeof e==`boolean`?!1:Array.isArray(e)?[]:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,z(t)]))}function ye(e){let t=e[0];if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=Object.keys(t);return n.length===0||n.length>4||!e.every(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).join()===n.join()&&Object.values(e).every(e=>typeof e!=`object`||!e))?null:n.map(t=>{let n=e.map(e=>String(e[t]??``).length),r=Math.max(t.length,...n);return{key:t,weight:Math.min(4,Math.max(1,Math.round(r/10)))}})}var B=t();function be(e){return e===null?[]:Array.isArray(e)?e:[e]}function V(){let e=v(),[t,n]=(0,D.useState)(null);return{read:async e=>{n(null);let t=[];for(let r of be(e)){let e=await he(r);e?t.push([r,e]):n(r.name)}return t},status:t===null?void 0:{type:`error`,message:e(`@theorem.decision.image_bad`,{file:t})}}}function xe({onImages:e}){let t=v(),{read:n,status:r}=V();return(0,B.jsx)(T,{label:t(`@theorem.decision.add_image`),isLabelHidden:!0,mode:`dropzone`,isMultiple:!0,accept:O,value:null,placeholder:t(`@theorem.decision.add_image_hint`),status:r,statusVariant:`detached`,onChange:t=>{n(t).then(t=>{t.length>0&&e(t)})}})}var Se={search:()=>[],bootstrap:()=>[]},Ce=48;function H(e,t,n){return Math.min(Math.max(e.split(`
2
- `).length,t),n)}var U=(0,D.createContext)({images:{},onImages:()=>{}});function we({value:e,label:t,isLabelHidden:n}){let r=v(),{images:i,onImages:a}=(0,D.useContext)(U),{read:o,status:s}=V(),[f,p]=(0,D.useState)(!1),m=Object.hasOwn(i,e)?k(i[e]):void 0;return(0,B.jsxs)(c,{gap:2,vAlign:`center`,children:[(0,B.jsx)(d,{src:m,alt:t,label:e,onClick:m?()=>p(!0):void 0}),m?(0,B.jsx)(u,{isOpen:f,onOpenChange:p,media:{src:m,alt:t,caption:e},hasZoom:!0}):null,(0,B.jsx)(l,{size:`fill`,children:(0,B.jsx)(T,{label:t,isLabelHidden:n,accept:O,value:null,placeholder:r(`@theorem.decision.replace_image`),status:s,statusVariant:`detached`,onChange:t=>{o(t).then(([t])=>{t&&a({...i,[e]:t[1]})})}})})]})}function W({value:e,onChange:t,label:n,isLabelHidden:r}){let{images:i}=(0,D.useContext)(U),[a]=(0,D.useState)(()=>typeof e==`string`&&(e.length>Ce||e.includes(`
3
- `))),[o]=(0,D.useState)(()=>typeof e==`string`&&Object.hasOwn(i,e));if(o&&typeof e==`string`)return(0,B.jsx)(we,{value:e,label:n,isLabelHidden:r});if(typeof e==`boolean`)return(0,B.jsx)(fe,{label:n,value:e,onChange:t});if(typeof e==`number`)return(0,B.jsx)(le,{label:n,isLabelHidden:r,size:`sm`,value:e,isWheelEnabled:!1,onChange:t});if(e===null)return(0,B.jsx)(x,{label:n,isLabelHidden:r,size:`sm`,value:``,placeholder:`null`,isDisabled:!0,onChange:()=>{}});let s=String(e);return a?(0,B.jsx)(E,{label:n,isLabelHidden:r,size:`sm`,rows:H(s,2,12),value:s,onChange:t}):(0,B.jsx)(x,{label:n,isLabelHidden:r,size:`sm`,value:s,onChange:t})}function G({label:e,isRequired:t,description:n,children:r}){let i=(0,D.useId)();return(0,B.jsxs)(s,{gap:2,role:`group`,"aria-labelledby":i,children:[(0,B.jsx)(p,{label:e,inputID:``,labelID:i,isGroupLabel:!0,isRequired:t,description:n}),r]})}function K({children:e,...t}){return(0,B.jsx)(G,{...t,children:(0,B.jsx)(`div`,{style:{paddingInlineStart:12,borderInlineStart:`1px solid var(--color-border)`},children:e})})}function q({field:e,onAdd:t}){let n=v();return(0,B.jsx)(c,{children:(0,B.jsx)(b,{label:n(`@theorem.decision.add_item`,{field:e}),size:`sm`,variant:`ghost`,icon:(0,B.jsx)(de,{size:14}),onClick:t})})}function J({index:e,onRemove:t}){let n=v();return(0,B.jsx)(ae,{label:n(`@theorem.decision.remove_item`,{item:n(`@theorem.data.item`,{index:String(e+1)})}),size:`sm`,variant:`ghost`,icon:(0,B.jsx)(f,{size:14}),onClick:t})}function Y({value:e,onChange:t}){return(0,B.jsx)(s,{gap:3,children:Object.entries(e).map(([n,r])=>(0,B.jsx)(X,{label:C(n),value:r,onChange:r=>t({...e,[n]:r})},n))})}function Te({value:e,onChange:t,label:n}){let r=v(),i=oe(e);if(ve(e))return(0,B.jsx)(ue,{label:n,size:`sm`,value:e.map((e,t)=>({id:`${String(t)}:${e}`,label:e})),searchSource:Se,hasCreate:!0,debounceMs:0,placeholder:r(`@theorem.decision.add_value`),onChange:e=>t(e.map(e=>e.label))});let a=ye(e),o=(0,B.jsx)(q,{field:n,onAdd:()=>t([...e,z(e.at(-1))])}),u=n=>(0,B.jsx)(J,{index:n,onRemove:()=>{i.drop(n),t(e.filter((e,t)=>t!==n))}});if(a){let r={display:`grid`,gap:8,alignItems:`start`,gridTemplateColumns:`${a.map(e=>`minmax(0, ${String(e.weight)}fr)`).join(` `)} auto`},s=e;return(0,B.jsxs)(G,{label:n,children:[(0,B.jsxs)(`div`,{style:r,"aria-hidden":!0,children:[a.map(e=>(0,B.jsx)(_,{type:`supporting`,color:`secondary`,maxLines:1,children:C(e.key)},e.key)),(0,B.jsx)(`span`,{style:{width:28}})]}),i.rows.map(({index:e,key:n})=>{let i=s[e];return(0,B.jsxs)(`div`,{style:r,children:[a.map(n=>(0,B.jsx)(W,{label:`${C(n.key)} ${String(e+1)}`,isLabelHidden:!0,value:i[n.key]??null,onChange:r=>t(s.map((t,i)=>i===e?{...t,[n.key]:r}:t))},n.key)),u(e)]},n)}),o]})}return(0,B.jsx)(K,{label:n,children:(0,B.jsxs)(s,{gap:3,children:[i.rows.map(({item:n,index:i,key:a})=>{let o=r(`@theorem.data.item`,{index:String(i+1)}),s=n=>t(e.map((e,t)=>t===i?n:e));return(0,B.jsxs)(c,{gap:2,vAlign:`start`,children:[(0,B.jsx)(l,{size:`fill`,children:ce(n)?(0,B.jsx)(W,{label:o,isLabelHidden:!0,value:n,onChange:s}):(0,B.jsx)(X,{label:o,value:n,onChange:s})}),u(i)]},a)}),o]})})}function X({value:e,onChange:t,label:n}){return Array.isArray(e)?(0,B.jsx)(Te,{label:n,value:e,onChange:t}):typeof e==`object`&&e?(0,B.jsx)(K,{label:n,children:(0,B.jsx)(Y,{value:e,onChange:t})}):(0,B.jsx)(W,{label:n,value:e,onChange:t})}function Ee({value:e,onChange:t,label:n}){return typeof e==`object`&&e&&!Array.isArray(e)?(0,B.jsx)(Y,{value:e,onChange:t}):(0,B.jsx)(X,{label:n,value:e,onChange:t})}var De={"--theorem-console-card":`var(--color-background-muted)`},Z=`(width < 768px)`,Q=(0,D.createContext)(!0);function $(){return(0,D.useSyncExternalStore)(e=>{let t=globalThis.matchMedia(Z);return t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}},()=>globalThis.matchMedia(Z).matches,()=>!1)}function Oe({flush:e,wide:t,maxWidth:n,children:r}){return(0,B.jsx)(s,{height:`100%`,paddingInlineStart:3,style:{...e?De:void 0,paddingInlineEnd:ne(3)},children:(0,B.jsx)(y,{variant:`transparent`,height:`100%`,padding:0,style:e?{overflowY:`auto`}:{...ee,overflowY:`auto`},children:(0,B.jsx)(se,{axis:`horizontal`,width:`100%`,minHeight:`100%`,children:(0,B.jsx)(s,{width:`100%`,maxWidth:t?void 0:n,gap:3,padding:4,children:r})})})})}function ke({inspector:e,maxWidth:t,flush:n=!1,columns:a=!1,requestLabel:o,className:s,style:c,children:l}){let u=(0,D.useRef)(null),d=e.toggle?(0,B.jsx)(te,{floating:!0,children:e.toggle}):void 0;return(0,B.jsx)(S,{inspector:e,children:(0,B.jsx)(i,{ref:u,height:`fill`,className:s,style:{position:`relative`,...c},header:d,content:(0,B.jsx)(r,{padding:0,isScrollable:!1,children:(0,B.jsx)(Ae,{layoutRef:u,flush:n,columns:a,maxWidth:t,requestLabel:o,children:l})})})})}function Ae({layoutRef:e,flush:t,columns:n,maxWidth:r,requestLabel:i,children:a}){let o=$(),s=D.Children.toArray(a).length,c=n&&s>1;return c&&!o?(0,B.jsx)(je,{requestLabel:i,basisWidth:e.current?.clientWidth??0,children:a}):(0,B.jsx)(Oe,{flush:t,wide:c,maxWidth:r,children:a})}function je({requestLabel:e=`Request`,basisWidth:t,children:n}){let a=v(),o=(0,D.useRef)(null),s=g({defaultSize:t>0?Math.round(t*.4):`40%`,minSize:280,maxSize:`70%`,containerRef:o}),[c,l]=D.Children.toArray(n),u={name:e,show:e,hide:e,resize:a(`@theorem.panel.resize`,{name:e})};return(0,B.jsx)(Q,{value:!1,children:(0,B.jsx)(i,{ref:o,height:`fill`,start:(0,B.jsx)(re,{side:`start`,className:`theorem-console-request`,labels:u,resizable:s,open:!0,children:(0,B.jsx)(h,{label:e,children:c})}),content:(0,B.jsx)(r,{padding:0,isScrollable:!1,children:(0,B.jsx)(m,{inset:`beside`,className:`theorem-console-response`,children:l})})})})}function Me({children:e}){return(0,B.jsx)(y,{variant:`muted`,padding:0,className:`theorem-console-card`,style:w,children:(0,B.jsx)(Q,{value:!1,children:e})})}function Ne({label:e,fill:t=!1,children:n}){return(0,D.use)(Q)?(0,B.jsx)(y,{variant:`muted`,padding:t?0:4,className:`theorem-console-card`,style:w,children:t?n:(0,B.jsx)(s,{height:`100%`,gap:3,children:n})}):t?n:(0,B.jsx)(h,{label:e,padding:4,children:n})}function Pe(e){return t=>{t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e())}}function Fe({title:e,onRun:t,children:n,...r}){let i=v(),l=(0,D.use)(Q),u=(0,B.jsxs)(s,{gap:3,padding:l?void 0:4,onKeyDown:Pe(t),children:[(0,B.jsxs)(c,{gap:2,hAlign:`between`,vAlign:`center`,children:[(0,B.jsx)(_,{type:`supporting`,color:`secondary`,as:`h3`,children:e}),r.onView?(0,B.jsxs)(a,{label:i(`@theorem.decision.view`),size:`sm`,value:r.view,onChange:e=>{r.onView(e===`json`?`json`:`fields`)},children:[(0,B.jsx)(o,{value:`fields`,label:i(`@theorem.decision.fields`),isDisabled:!r.hasFields}),(0,B.jsx)(o,{value:`json`,label:i(`@theorem.data.json`)})]}):r.actions]}),n]});return l?(0,B.jsx)(y,{variant:`muted`,padding:4,className:`theorem-console-card`,style:w,children:u}):u}var Ie={"--font-family-body":`var(--font-family-code)`};function Le({label:e,text:t,isInvalid:n,onChange:r}){return(0,B.jsx)(E,{label:e,isLabelHidden:!0,value:t,onChange:r,rows:H(t,8,24),hasSpellCheck:!1,status:n?{type:`error`}:void 0,controlStyle:Ie})}function Re({note:e,isReady:t,isRunning:n,runLabel:r,runningLabel:i,stopLabel:a,onRun:o,onStop:s}){return(0,B.jsxs)(c,{gap:3,hAlign:`between`,vAlign:`center`,children:[(0,B.jsx)(_,{type:`supporting`,color:`secondary`,style:t?void 0:{color:`var(--color-error)`},hasTabularNumbers:!0,children:e}),(0,B.jsxs)(c,{gap:2,vAlign:`center`,children:[n?(0,B.jsx)(b,{label:a,variant:`ghost`,onClick:s}):null,(0,B.jsx)(b,{label:n?i:r,variant:`primary`,isLoading:n,isDisabled:!t,onClick:o})]})]})}function ze(){let e=ie();return(0,D.useMemo)(()=>{let t=new Intl.NumberFormat(e,{style:`unit`,unit:`byte`,unitDisplay:`narrow`}),n=new Intl.NumberFormat(e,{style:`unit`,unit:`kilobyte`,unitDisplay:`narrow`,maximumFractionDigits:1});return e=>e<1024?t.format(e):n.format(e/1024)},[e])}export{N as S,_e as _,Ne as a,ge as b,q as c,J as d,Ee as f,I as g,xe as h,Fe as i,K as l,H as m,Me as n,Re as o,U as p,Le as r,ze as s,ke as t,G as u,P as v,j as x,k as y};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MenuBottomSheet-B8bZZgjf.js","assets/themeProps-3IqahpCr.js","assets/rolldown-runtime-hePW80VL.js","assets/BottomSheet-Dbh6A5Vl.js","assets/tokens.stylex-DkHf0P9C.js","assets/padding.stylex-B76907Zf.js","assets/mergeProps-ptS-gIMz.js","assets/useLayerDismissal-BAnTRYTt.js","assets/focusReturn-CTppP2k0.js","assets/focusOutline.stylex-BT0kfa4t.js","assets/useMediaQuery-BCT0NUeZ.js","assets/useScrollLock-Dyf6PHJt.js","assets/useDevWarning-Z9SoixOP.js","assets/devWarning-DxuplmRl.js","assets/useScrollableArea-DuF_pz9m.js","assets/sharedResizeObserver-4U9Xq5Oq.js","assets/focusableSelector-DXZeMU85.js","assets/container.stylex-BmOi-8DQ.js","assets/index-BK6Cf7vm.js","assets/SegmentedControlItem-BBGRPrxp.js","assets/VStack-CkVMcNiK.js","assets/StackItem-CQviqAfM.js","assets/fieldParts-B7DYLgh4.js","assets/Icon-BqkS-pIq.js","assets/Text-BOqCfzZC.js","assets/preload-helper-DpV6A1kQ.js","assets/useResolvedRequired-DbsOcDqy.js","assets/useAnnounce-DTSHZvjg.js","assets/Tooltip-BWs5DLrM.js","assets/useTooltip-c097gL_-.js","assets/IconButton-DVUFx-8p.js","assets/createReactComponent-CZwsv6DD.js","assets/isRtlElement-BG33-k_H.js","assets/plainDate-BHiJcj7o.js","assets/browser-transport-DwKQIgk5.js","assets/use-trace-records-B1vrKQmA.js","assets/Card-DruykyeB.js","assets/ScrollableArea-BHfY7sWH.js","assets/IconAlertTriangle-BqAEqqdU.js","assets/Banner-B_2gi5vH.js","assets/isRenderable-DHkzpAoQ.js","assets/labels-provider-C_KY4x6D.js","assets/tool-schema-CWSpXHJV.js","assets/schemas-BQ9Jydzb.js","assets/host-patterns-F-KZIzkF.js","assets/shaped-data-BO6EAfYh.js","assets/tree-BTHpYpj5.js","assets/live-ingress-OuSlQ6q7.js","assets/browser-connection-CfhefDFM.js","assets/use-second-ticker-B9Dklglz.js","assets/use-second-ticker-GWBt83pd.css","assets/arrive-DvbqpeRS.js","assets/Center-nHS1JSux.js","assets/IconSearch-BTx66a40.js","assets/reader-CJEp4m2A.js","assets/trace-schema-9CdEyG6Q.js","assets/stub-Z-Vm8Sv8.js","assets/useContainerReveal-BFy8N_QU.js","assets/CheckboxInput-CFZ_Wq8-.js","assets/Dialog-Sd04KQS2.js","assets/chainEventHandlers-C6ttXGfW.js","assets/CodeBlock-CfVOtDeO.js","assets/useClipboard-CbN9bb4J.js","assets/HoverCard-DMyWUvwP.js","assets/IconEye-BB5aY-wQ.js","assets/studio-labels-D1QhaZ40.js","assets/turn-client-DzIqP2qE.js","assets/encode-files-v-W0DoVP.js","assets/CollapsibleGroup-FIawJRo4.js","assets/crypto-qwXH_zFb.js","assets/workspace-DT7jMw84.js","assets/lent-keys-C32ems-I.js","assets/editors-BJX_S59A.js","assets/studio-session-yEqFQo5o.js","assets/EmptyState-C_uF9Wyj.js","assets/MenuBottomSheetActionList-3L0HS4Kf.js","assets/useMenuPress-DLG1QOiE.js","assets/ListItem-QF7KFt0h.js","assets/useAdaptivePresentation-Bma4-u1a.js","assets/useFocusReturnVisibility-BHKv5Jwr.js","assets/index-C9rhrCGT.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n,n as r,u as i}from"./themeProps-3IqahpCr.js";import{h as a}from"./tokens.stylex-DkHf0P9C.js";import{y as o}from"./padding.stylex-B76907Zf.js";import{t as s}from"./mergeProps-ptS-gIMz.js";import{n as c,o as l,r as u,s as d,t as f}from"./useLayerDismissal-BAnTRYTt.js";import{_ as p,g as m,h,l as ee,x as g}from"./fieldParts-B7DYLgh4.js";import{t as _}from"./isRenderable-DHkzpAoQ.js";import{b as v,n as y,t as b,x}from"./Icon-BqkS-pIq.js";import{c as S,f as te}from"./useResolvedRequired-DbsOcDqy.js";import{i as C}from"./focusOutline.stylex-BT0kfa4t.js";import{n as ne,r as w}from"./useAnnounce-DTSHZvjg.js";import{a as T,d as E,l as D,n as re}from"./useTooltip-c097gL_-.js";import{r as ie}from"./Text-BOqCfzZC.js";import{t as O}from"./preload-helper-DpV6A1kQ.js";import{n as ae}from"./IconButton-DVUFx-8p.js";import{t as oe}from"./useMediaQuery-BCT0NUeZ.js";import{a as k,c as A,l as se}from"./CheckboxInput-CFZ_Wq8-.js";import{t as ce}from"./useDevWarning-Z9SoixOP.js";import{a as le,i as ue,o as de,r as fe,s as pe,t as me}from"./MenuBottomSheetActionList-3L0HS4Kf.js";import{i as he,n as ge,r as _e,t as ve}from"./useMenuPress-DLG1QOiE.js";import{i as ye,n as be,r as xe}from"./useAdaptivePresentation-Bma4-u1a.js";var j=e(i(),1),Se=o(null);Se.displayName=`DropdownMenuSurfaceContext`;var Ce=o(null);Ce.displayName=`DropdownMenuRootOpenContext`;function we(){return(0,j.use)(Ce)!==!1}var Te=o(null);Te.displayName=`DropdownMenuContext`;function Ee(){return(0,j.use)(Te)}var De=(0,j.createContext)(null);De.displayName=`DropdownMenuRadioGroupContext`;function Oe(e,t){if(t||e.pointerType!==`mouse`)return;let n=e.currentTarget;n!==n.ownerDocument.activeElement&&n.focus({preventScroll:!0})}var M=t(),N={root:{kB7OPa:`x9f619`,kzqmXN:`xh8yej3`,k8WAf4:`xce4md1`,kg3NbH:`xf314gf`,kaIpWk:`x1ws5lxm`,kMv6JI:`x9ynric`,kGuDYH:`xcr08ib`,kMwMTN:`x1tgivj0`,kWkggS:`xjbqb8w x1c52tdz xprvw0a`,kMzoRj:`xc342km`,ksu8eU:`xng3xce`,kkrTdU:`x1ypdohk x16khyan`,k9WMMc:`x1yc453h`,kI3sdo:`x1a2a7pz`,$$css:!0},disabled:{kSiTet:`xbyyjgo`,kkrTdU:`xt0e3qv`,$$css:!0},destructive:{kMwMTN:`xjt36v0`,"--_item-label-color":`xufyqxy`,"--_item-description-color":`xqlix59`,$$css:!0}},ke={sm:{k8WAf4:`xu0wf1k`,kg3NbH:`xf314gf`,$$css:!0},md:{k8WAf4:`x1vofgu7`,$$css:!0},lg:{$$css:!0}};function P({icon:e,label:t,description:n,onClick:i,href:a,target:o,rel:c,isDisabled:l=!1,endContent:u,hasCloseOnSelect:d=!0,variant:f=`default`,xstyle:p,className:m,style:h,ref:ee,onPointerMove:_,onAuxClick:v,...b}){let x=Ee(),S=x?.menuSize??`md`,te=ne(),C=(0,j.useCallback)(e=>{l?e.preventDefault():(a!=null&&pe(e)||i?.(e),d&&x?.closeMenu())},[l,a,i,d,x]),T=(0,j.useCallback)(e=>{l?e.preventDefault():a!=null&&e.button===1&&d&&x?.closeMenu()},[l,a,d,x]),E=(0,j.useCallback)(e=>Oe(e,l),[l]),D=f===`destructive`,re=w();return(0,M.jsx)(k,{...b,ref:ee,as:a==null?void 0:re,role:`menuitem`,tabIndex:l?void 0:-1,onPointerMove:g(E,_),...te,startContent:e?y(e,{size:`sm`,color:D?`error`:`secondary`}):void 0,label:t,description:n,endContent:u,onClick:C,onAuxClick:g(T,v),href:a,target:o,rel:c,draggable:a==null&&void 0,isDisabled:l,xstyle:[N.root,ke[S],D&&N.destructive,l&&N.disabled,p],...s(r(`dropdown-menu-item`,{size:S,variant:D?`destructive`:null}),{className:m,style:h})})}P.displayName=`DropdownMenuItem`;var Ae={divider:{kqGvvJ:`xsq74q5`,$$css:!0}},F=r(`dropdown-menu-divider`).className;function I({xstyle:e,className:t,style:n,ref:r,...i}){return(0,M.jsx)(A,{...i,ref:r,xstyle:[Ae.divider,e],className:t?`${F} ${t}`:F,style:n})}I.displayName=`DropdownMenuDivider`;var je=E(),Me=(0,j.createContext)(!1);Me.displayName=`MenuRegionsContext`;function L(e){return e==null?[]:p(e).filter(t=>t.tabIndex>=0&&!R(t,e))}function R(e,t){if(typeof window>`u`||!window.getComputedStyle)return!1;for(let n=e.parentElement;n!=null&&n!==t.parentElement;n=n.parentElement)if(window.getComputedStyle(n).display===`none`)return!0;return!1}function z(e,t,n){let r=new Map,i=e=>e instanceof HTMLInputElement&&e.getAttribute(`type`)===`radio`&&e.name!==``?`${e.form?.id??``}\u0000${e.name}`:null;for(let t of e){let e=i(t);if(e!=null){let n=r.get(e)??[];n.push(t),r.set(e,n)}}let a=new Set,o=[];for(let s of e){let e=i(s);if(e==null){o.push(s);continue}if(a.has(e))continue;a.add(e);let c=r.get(e)??[],l=c.find(e=>e===t)??c.find(e=>e.checked)??(n?c[c.length-1]:c[0]);o.push(l)}return o}function Ne(e){return e.focus(),e.ownerDocument.activeElement===e}function Pe(e,t,n,r,i=!1){if(t==null)return;e.preventDefault(),e.stopPropagation();let a=document.activeElement,o=z([...L(n),t,...L(r)],a,e.shiftKey);if(o.length===1){i&&t.focus();return}let s=o.indexOf(t),c=t.contains(a)?s:o.findIndex(e=>e===a||e.contains(a));c<0&&(c=s);let l=e.shiftKey?-1:1,u=o[(c+l+o.length)%o.length];Ne(u)||t.focus()}var B=500,V=300,Fe=8;function Ie(e,t,n){return(e.x-n.x)*(t.y-n.y)-(t.x-n.x)*(e.y-n.y)}function Le(e,t,n,r){let i=Ie(e,t,n),a=Ie(e,n,r),o=Ie(e,r,t);return!((i<0||a<0||o<0)&&(i>0||a>0||o>0))}function Re(e,t,n){let r=Fe,i,a;if(t.x<=n.left)i={x:n.left,y:n.top-r},a={x:n.left,y:n.bottom+r};else if(t.x>=n.right)i={x:n.right,y:n.top-r},a={x:n.right,y:n.bottom+r};else if(t.y<=n.top)i={x:n.left-r,y:n.top},a={x:n.right+r,y:n.top};else if(t.y>=n.bottom)i={x:n.left-r,y:n.bottom},a={x:n.right+r,y:n.bottom};else return!1;return Le(e,t,i,a)}function ze(e){let{show:t,hide:n,isOpen:r,isEnabled:i,showDelay:a=150,hideDelay:o=200,clickGuardMs:s=B,itemSelector:c,popoverId:l,ownsFocus:d=!0,flyoutRef:f}=e,p=oe(`(hover: hover)`),m=(0,j.useRef)(null),h=(0,j.useRef)(null),g=(0,j.useRef)(null),_=(0,j.useRef)(null),v=(0,j.useRef)(!1),y=(0,j.useRef)(0),b=(0,j.useRef)(0),x=(0,j.useRef)(r),S=(0,j.useCallback)(()=>{m.current&&=(clearTimeout(m.current),null),h.current&&=(clearTimeout(h.current),null),_.current?.(),_.current=null},[]);u(()=>{let e=x.current;x.current=r,e&&!r&&(S(),v.current=!1,b.current=0,y.current=Date.now())},[r,S]);let te=(0,j.useRef)(()=>{}),{listRef:C,handleKeyDown:ne,focusFirst:w}=ee({itemSelector:c,onEscape:()=>te.current()}),T=(0,j.useCallback)(()=>{let e=C.current?.contains(document.activeElement)??!1;n(),e&&g.current?.focus()},[n,C]);(0,j.useEffect)(()=>{te.current=()=>{S(),T()}},[S,T]),(0,j.useEffect)(()=>()=>S(),[S]),(0,j.useEffect)(()=>{i||S()},[i,S]);let E=(0,j.useCallback)(()=>{w()||C.current?.focus()},[w,C]),D=(0,j.useCallback)(()=>{d?(t({skipAutoFocus:!0}),E()):t()},[d,t,E]),re=(0,j.useCallback)(()=>s>0&&b.current>0&&Date.now()-b.current<s&&(v.current=!1,b.current=0,!0),[s]),ie=(0,j.useCallback)(e=>{l&&e?.preventDefault(),S(),e!=null&&e.detail===0?(y.current=0,v.current=!1,b.current=0,r?d&&E():D()):r?re()?d&&E():T():(y.current=0,v.current=!1,b.current=0,D())},[l,S,r,d,re,D,E,T]),O=(0,j.useCallback)(()=>{if(!p||y.current>0&&Date.now()-y.current<V)return;if(r){S();return}v.current=!0,S();let e=()=>{b.current=Date.now(),t({skipAutoFocus:!0})};a>0?m.current=setTimeout(e,a):e()},[p,r,S,t,a]),ae=(0,j.useCallback)(e=>{if(y.current=0,!v.current)return;S();let t=null,i=!1,a=()=>!1,s=()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{i&&t!=null&&a(t)?s():n()},o)};s();let c=f?.current??C.current,l=e==null?null:{x:e.clientX,y:e.clientY};if(c==null||l==null||!r)return;let u=c.getBoundingClientRect();if(u.width<=0||u.height<=0)return;let d=c.ownerDocument;a=e=>Re(e,l,u),i=!0,t=l;let p=e=>{let n={x:e.clientX,y:e.clientY};t=n,a(n)?s():(i=!1,_.current?.(),_.current=null)};d.addEventListener(`pointermove`,p,!0),_.current=()=>{d.removeEventListener(`pointermove`,p,!0)}},[S,n,o,r,C,f]),k=(0,j.useCallback)(()=>{S()},[S]),A=(0,j.useCallback)(e=>{g.current=e},[]),se=(0,j.useCallback)(()=>{},[]),ce=(0,j.useCallback)(e=>{},[]),le=(0,j.useCallback)(e=>{},[]);return i?{triggerProps:{onClick:ie,onMouseEnter:O,onMouseLeave:ae,...l?{popoverTarget:l}:null},contentProps:{onMouseEnter:k,onMouseLeave:ae,onKeyDown:ne},menuRef:C,focusFirst:w,focusMenu:E,confirmHoverOpen:re,close:T,setTriggerEl:A}:{triggerProps:{onClick:se,onMouseEnter:se,onMouseLeave:se},contentProps:{onMouseEnter:se,onMouseLeave:se,onKeyDown:le},menuRef:C,focusFirst:w,focusMenu:E,confirmHoverOpen:re,close:T,setTriggerEl:ce}}function Be(e,t){return typeof e==`string`&&m(e)?{property:`inlineSize`,value:e.trim()}:{property:`minWidth`,value:h(e,t)}}`${D.maxBlockSize}`,`${D.maxBlockSizeFallback}`;var Ve={root:{kB7OPa:`x9f619`,kzqmXN:`xh8yej3`,k8WAf4:`xce4md1`,kg3NbH:`xf314gf`,kaIpWk:`x1ws5lxm`,kMv6JI:`x9ynric`,kGuDYH:`xcr08ib`,kMwMTN:`x1tgivj0`,kWkggS:`xjbqb8w x1c52tdz`,kMzoRj:`xc342km`,ksu8eU:`xng3xce`,kkrTdU:`x1ypdohk x16khyan`,k9WMMc:`x1yc453h`,kI3sdo:`x1a2a7pz`,$$css:!0},open:{kWkggS:`x1lmrjuc`,$$css:!0},disabled:{kSiTet:`xbyyjgo`,kkrTdU:`xt0e3qv`,$$css:!0}},He={sm:{k8WAf4:`xu0wf1k`,kg3NbH:`xf314gf`,$$css:!0},md:{k8WAf4:`x1vofgu7`,$$css:!0},lg:{$$css:!0}},Ue={kzqmXN:`x1uyokj7`,$$css:!0},H={scrollable:{kORKVm:`x1odjw0f`,kXHlph:`x6ikm8r`,kZeWKH:`xish69e`,$$css:!0},touchPinchZoom:{kFalU9:`x1j4r261`,$$css:!0},touchPanYPinchZoom:{kFalU9:`xge0x1e`,kZeWKH:`xish69e`,$$css:!0},popoverViewport:{kB7OPa:`x9f619`,kskxy:`x1uh1i8a`,$$css:!0},popover:{k7Eaqz:`x1b27s9g`,$$css:!0},popoverCustomWidth:e=>[{k7Eaqz:e==null?e:`xkj4a21`,$$css:!0},{"--x-minWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}],popoverCustomIntrinsicWidth:e=>[Ue,{"--x-inlineSize":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]},We={kskxy:`x1jols5v`,$$css:!0},Ge={viewMaxHeight:e=>[We,{"--x-maxHeight":(e=>typeof e==`number`?e+`px`:e??void 0)(`min(${e}, ${D.maxBlockSize})`)}]},Ke={frame:{kB7OPa:`x9f619`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kskxy:`x1uh1i8a`,"--_dropdown-menu-radius":`x1fcsqxe`,"--_dropdown-menu-padding":`xgory14`,kaIpWk:`x1n97fys`,$$css:!0},menu:{kB7OPa:`x9f619`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kOIVth:`x1lsbc85`,kzQI83:`x1iyjqo2`,kmuXW:`xs83m0k`,kAzted:`x2lwn1j`,kmVPX3:`x9epnlk`,kI3sdo:`x1a2a7pz`,k7VYTy:`xpdipgo`,kfSwDN:`x87ps6o`,$$css:!0},hidden:{k1xSpc:`x1s85apg`,$$css:!0}};function qe(e){if(e==null)return;let t=e.ownerDocument,n=e.querySelectorAll(`[aria-expanded="true"][aria-controls]`);for(let e of[...n].reverse()){let n=t.getElementById(e.getAttribute(`aria-controls`)??``);if(n?.getAttribute(`data-astryx-submenu-regions`)!==`flyout`)continue;let r=n.closest(`[popover]`);if(r!=null){if(typeof r.hidePopover==`function`)r.matches(`:popover-open`)&&r.hidePopover();else if(r.style.display===`block`){r.style.display=`none`;let e=new Event(`toggle`,{bubbles:!1});Object.defineProperty(e,"newState",{value:`closed`,configurable:!0}),r.dispatchEvent(e)}}}}function Je(e){let{icon:t,label:i,description:o,isDisabled:c=!1,hasSpinner:u=!1,menuWidth:f,onOpenChange:p,presentation:m=`adaptive`,header:h,footer:ne,children:w,xstyle:E,className:O,style:ae,"data-testid":oe,menuDataTestId:A,ref:se,id:pe,onMouseEnter:me,onMouseLeave:he,onPointerMove:be,onClick:De,onKeyDown:N,...ke}=e,Ae=x(),F=Ee(),I=(0,j.use)(Se),L=(0,j.use)(Me),R=F?.menuSize??`md`,z=!c,Ne=_(h)||_(ne),B=I!=null,V=Ne&&B,Fe=I?.host.getElement()??null;ce(`DropdownMenuSubMenu`,`header and footer show only inside a DropdownMenu; this menu has no place outside its rows for them, so they are not rendered.`,Ne&&!B);let Ie=(0,j.useId)(),Le=(0,j.useRef)(null),Re=(0,j.useRef)(null),Ue=(0,j.useRef)(null),[We,Je]=(0,j.useState)(!1),U=(0,j.useId)(),Ye=(0,j.useId)(),W=pe??Ye,G=(0,j.useRef)(null),Xe=F?.drillIn,K=Xe!=null&&(m===`drill-in`||m===`adaptive`&&Xe.isCompactTouch)?Xe:null,Ze=K!=null,q=(0,j.useId)(),J=K?.viewStack.includes(q)===!0,Y=J&&K?.viewStack.at(-1)===q,X=typeof i==`string`?i:void 0,Qe=F?.menuLabel,$e=Qe==null?Ae(`@astryx.dropdownMenu.back`):Ae(`@astryx.dropdownMenu.backTo`,{parent:Qe}),[et,tt]=(0,j.useState)(!1),nt=Ze?J:et,rt=(0,j.useRef)(!1),it=(0,j.useRef)(!1),Z=T({mode:`context`,lightDismiss:!1,onShow:(0,j.useCallback)(()=>{it.current=!1,tt(!0),p?.(!0)},[p]),onHide:(0,j.useCallback)(()=>{it.current=!1,qe(G.current?.ownerDocument.getElementById(U)??null),tt(!1),p?.(!1)},[p,U])}),at=(0,j.useCallback)(()=>{z&&Z.show()},[z,Z]),ot=(0,j.useCallback)(()=>{V&&rt.current?it.current=!0:Z.hide()},[Z,V]),st=(0,j.useCallback)(()=>{rt.current=!0},[]),ct=(0,j.useCallback)(e=>{if(rt.current=!1,!it.current)return;let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||setTimeout(()=>{!rt.current&&it.current&&G.current?.isConnected===!0&&(it.current=!1,Z.hide())},0)},[Z]),lt=(0,j.useCallback)(()=>{it.current=!1},[]),{listRef:Q,handleKeyDown:ut,focusFirst:dt,focusItem:ft,ownsEvent:pt,getItems:mt}=ee({itemSelector:le,boundarySelector:fe,wrap:!0,hasPaging:!0,onEscape:()=>$({focusTrigger:!0})}),ht=xe(Q,w,nt&&(!Ze||V)),gt=ye({getItemLabels:()=>mt().map(e=>e.textContent),onMatch:ft,getCurrentIndex:()=>mt().findIndex(e=>e===document.activeElement||e.contains(document.activeElement))}),_t=we();S(u&&_t,Ae(`@astryx.spinner.loading`),G);let{triggerProps:vt,contentProps:yt,confirmHoverOpen:bt}=ze({show:at,hide:ot,isOpen:et,isEnabled:z&&!Ze&&_t,flyoutRef:V?Le:Q}),xt=(0,j.useRef)(null),St=(0,j.useRef)(!1),Ct=(0,j.useCallback)(e=>{z&&(K==null?(Z.show(),e?.focusFirst&&(dt()||Q.current?.focus())):(xt.current=e?.focusFirst?`first`:`container`,K.push(q),p?.(!0)))},[z,K,q,p,Z,dt,Q]),$=(0,j.useCallback)(e=>{K==null?(Z.hide(),e?.focusTrigger!==!1&&G.current?.focus()):J&&(St.current=e?.focusTrigger!==!1,K.pop(),p?.(!1))},[K,J,p,Z]);(0,j.useEffect)(()=>{if(!Y||K?.host==null)return;let e=xt.current;if(e==null)return;xt.current=null;let t=mt(),n=e===`first`?t[1]??t[0]:null;n==null?Q.current?.focus({preventScroll:!0}):n.focus({preventScroll:!0})},[Y,K?.host,mt,Q]),(0,j.useEffect)(()=>{!J&&St.current&&(St.current=!1,G.current?.focus({preventScroll:!0}))},[J]);let wt=Z.ref,Tt=(0,j.useCallback)(e=>{G.current=e,wt(e)},[wt]),Et=ie(Tt,se),Dt=(0,j.useCallback)(e=>{if(c)e.preventDefault();else if(Ze){let t=e.detail>0||ge();Ct({focusFirst:!t})}else if(et){if(bt()){dt()||Q.current?.focus();return}$({focusTrigger:!0})}else Ct({focusFirst:!0})},[c,Ze,et,Ct,$,bt,dt,Q]),Ot=(0,j.useCallback)(e=>{g(Dt,De)(e)},[Dt,De]),kt=(0,j.useCallback)(e=>{if(c)return;let t=typeof window<`u`&&G.current&&window.getComputedStyle(G.current).direction===`rtl`?`ArrowLeft`:`ArrowRight`;(e.key===t||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Ct({focusFirst:!0}))},[c,Ct]),At=(0,j.useCallback)(e=>Oe(e,c),[c]),jt=(0,j.useCallback)(e=>{if(e.key===`Tab`){if(V){Pe(e,Q.current,Re.current,Ue.current,!pt(e));return}if(L){$({focusTrigger:!1});return}}if(!pt(e))return;if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),$({focusTrigger:!0});return}if(e.key===`Enter`||e.key===` `){if(e.preventDefault(),e.repeat)return;let t=document.activeElement;t&&ue.has(t.getAttribute(`role`)??``)&&de(t,e);return}let t=typeof window<`u`&&Q.current&&window.getComputedStyle(Q.current).direction===`rtl`?`ArrowRight`:`ArrowLeft`;e.key===t?(e.preventDefault(),$({focusTrigger:!0})):gt.onKeyDown(e)?e.preventDefault():ut(e)},[pt,$,ut,gt,Q,L,V]),Mt=(0,j.useCallback)(e=>{e.key===`Tab`?Pe(e,Q.current,Re.current,Ue.current):e.key===`Escape`&&!e.defaultPrevented&&!l(e.nativeEvent)&&(e.preventDefault(),e.stopPropagation(),$({focusTrigger:!0}))},[Q,$]),Nt=(0,j.useMemo)(()=>({menuSize:R,closeMenu:()=>{$({focusTrigger:!1}),F?.closeMenu()},drillIn:Xe,menuLabel:X}),[R,$,F,Xe,X]),Pt=_e({menuRef:Q,itemSelector:le,onDismiss:Nt.closeMenu}),Ft=u?(0,M.jsx)(`span`,{className:`x78zum5 x6s0dn4`,children:(0,M.jsx)(v,{size:`sm`,"aria-hidden":`true`})}):(0,M.jsx)(`span`,{className:`x78zum5 x6s0dn4`,children:(0,M.jsx)(b,{icon:`chevronRight`,size:`sm`,color:`secondary`,xstyle:te.mirror,...r(`dropdown-menu-indicator-icon`)})}),It=f?Be(f,D.maxInlineSizeFallback):null,Lt=It?It.property===`inlineSize`?H.popoverCustomIntrinsicWidth(It.value):H.popoverCustomWidth(It.value):H.popover,Rt=(0,M.jsx)(Te,{value:Nt,children:(0,M.jsxs)(Se,{value:I,children:[Ze&&(0,M.jsx)(P,{icon:(0,M.jsx)(b,{icon:`chevronLeft`,size:`sm`,color:`secondary`,xstyle:te.mirror}),label:$e,hasCloseOnSelect:!1,onClick:()=>$({focusTrigger:!0})}),w]})}),zt=(0,M.jsx)(Ce,{value:_t&&nt,children:V?(0,M.jsx)(Me,{value:!0,children:Rt}):Rt}),Bt=V&&I!=null?{[ve]:I.ownerId}:void 0,Vt=(e,t,i)=>(0,M.jsxs)(`div`,{ref:Le,id:Ie,role:`dialog`,"aria-modal":`true`,"data-astryx-submenu-regions":i,...t,...i===`flyout`?{onFocus:st,onBlur:ct,onPointerEnter:lt}:void 0,...i===`flyout`?s(r(`dropdown-menu`),{className:`x9f619 x78zum5 xdt5ytf x1uh1i8a x1fcsqxe xgory14 x1n97fys xc0b1yq x1prclbq x1i5ehqx x1hc1fzr x19991ni xuedmi6 xlr8y92`}):n(Ke.frame,I?.menuMaxHeight!=null&&Ge.viewMaxHeight(I.menuMaxHeight),t.hidden===!0&&Ke.hidden),children:[_(h)&&(0,M.jsx)(`div`,{ref:Re,onKeyDown:Mt,className:`x2lah0s x9epnlk`,children:h}),e,_(ne)&&(0,M.jsx)(`div`,{ref:Ue,onKeyDown:Mt,className:`x2lah0s x9epnlk`,children:ne})]}),Ht=e=>V&&Fe!=null?(0,je.createPortal)(e,Fe):e,Ut=e=>{V&&e.target===e.currentTarget&&Je(d()===`keyboard`)},Wt=e=>{V&&e.target===e.currentTarget&&Je(!1)};return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(k,{...ke,ref:Et,id:W,role:`menuitem`,tabIndex:c?void 0:-1,"aria-haspopup":V?`dialog`:`menu`,"aria-expanded":nt,"aria-controls":nt?V?Ie:U:void 0,"aria-disabled":c||void 0,"data-testid":oe,onMouseEnter:g(vt.onMouseEnter,me),onMouseLeave:g(vt.onMouseLeave,he),onPointerMove:g(At,be),startContent:t?y(t,{size:`sm`,color:`secondary`}):void 0,label:i,description:o,endContent:Ft,onClick:Ot,onKeyDown:g(kt,N),isDisabled:c,xstyle:[Ve.root,He[R],nt&&Ve.open,c&&Ve.disabled,E],...s(r(`dropdown-menu-item`,{size:R}),{className:O,style:ae})}),K==null?Ht(Z.render(V?Vt((0,M.jsx)(`div`,{ref:Q,id:U,role:`menu`,tabIndex:0,"aria-labelledby":W,onKeyDown:jt,onFocus:Ut,onBlur:Wt,"data-testid":A,...Pt.menuProps,...Bt,...n(Ke.menu,ht?H.touchPanYPinchZoom:H.touchPinchZoom,ht&&H.scrollable,We&&C.focusVisible),children:zt}),{"aria-labelledby":W,onMouseEnter:yt.onMouseEnter,onMouseLeave:yt.onMouseLeave},`flyout`):(0,M.jsx)(`div`,{ref:Q,id:U,role:`menu`,tabIndex:ht?0:-1,"aria-labelledby":W,onKeyDown:jt,onMouseEnter:yt.onMouseEnter,onMouseLeave:yt.onMouseLeave,"data-testid":A,...Pt.menuProps,...s(r(`dropdown-menu`),{0:{className:`x9f619 x78zum5 xdt5ytf x1lsbc85 xc0b1yq x1uh1i8a x1fcsqxe xgory14 x9epnlk x1n97fys x1prclbq x1i5ehqx x1hc1fzr x19991ni xuedmi6 xlr8y92 xpdipgo x87ps6o x1j4r261`},2:{className:`x9f619 x78zum5 xdt5ytf x1lsbc85 xc0b1yq x1uh1i8a x1fcsqxe xgory14 x9epnlk x1n97fys x1prclbq x1i5ehqx x1hc1fzr x19991ni xuedmi6 xlr8y92 xpdipgo x87ps6o xge0x1e xish69e`},1:{className:`x9f619 x78zum5 xdt5ytf x1lsbc85 xc0b1yq x1uh1i8a x1fcsqxe xgory14 x9epnlk x1n97fys x1prclbq x1i5ehqx x1hc1fzr x19991ni xuedmi6 xlr8y92 xpdipgo x87ps6o x1j4r261 x1odjw0f x6ikm8r xish69e`},3:{className:`x9f619 x78zum5 xdt5ytf x1lsbc85 xc0b1yq x1uh1i8a x1fcsqxe xgory14 x9epnlk x1n97fys x1prclbq x1i5ehqx x1hc1fzr x19991ni xuedmi6 xlr8y92 xpdipgo x87ps6o xge0x1e x1odjw0f x6ikm8r xish69e`}}[!!ht<<1|!!ht]),children:zt}),{placement:`end`,alignment:`start`,offset:a[`--spacing-1`],xstyle:[H.popoverViewport,Lt,re.end]})):J&&K.host!=null&&(V?(0,je.createPortal)(Vt((0,M.jsx)(`div`,{ref:Q,id:U,role:`menu`,tabIndex:0,"aria-label":X,"aria-labelledby":X==null?W:void 0,onKeyDown:jt,onFocus:Ut,onBlur:Wt,"data-testid":A,...Pt.menuProps,...Bt,...n(Ke.menu,ht&&H.scrollable,ht?H.touchPanYPinchZoom:H.touchPinchZoom,We&&C.focusVisible),children:zt}),{"aria-label":X,"aria-labelledby":X==null?W:void 0,hidden:!Y,inert:!Y},`view`),Fe??K.host):(0,je.createPortal)((0,M.jsx)(`div`,{ref:Q,id:U,role:`menu`,tabIndex:-1,"aria-label":X,"aria-labelledby":X==null?W:void 0,hidden:!Y,inert:!Y,onKeyDown:jt,"data-testid":A,...Pt.menuProps,...{0:{className:`x78zum5 xdt5ytf x1lsbc85 x1a2a7pz xpdipgo x87ps6o`},1:{className:`xdt5ytf x1lsbc85 x1a2a7pz xpdipgo x87ps6o x1s85apg`}}[!Y|0],children:zt}),K.host))]})}Je.displayName=`DropdownMenuSubMenu`;function U(e,t){return`item-${e.id??t}`}function Ye(e,t){return`section-${e.id??t}`}function W(e,t){let{items:n,id:r,...i}=e;return(0,M.jsx)(P,{...i},U(e,t))}function G(e){let t=[];for(let n=0;n<e.length;n++){let i=e[n];`type`in i&&i.type===`divider`?t.push((0,M.jsx)(I,{},`divider-${n}`)):`type`in i&&i.type===`section`?t.push((0,M.jsxs)(`div`,{role:`group`,"aria-label":i.title,children:[i.title&&(0,M.jsx)(`div`,{"aria-hidden":`true`,...s(r(`dropdown-menu-section-heading`),{className:`xu0wf1k xf314gf x9ynric x141an7d x1ltkj2j xv1l7n4 x87ps6o`}),children:i.title}),i.items.map(W)]},Ye(i,n))):`type`in i||(i.items&&i.items.length>0?t.push((0,M.jsx)(Je,{icon:i.icon,label:i.label,isDisabled:i.isDisabled,children:G(i.items)},U(i,n))):t.push(W(i,n)))}return t}function Xe(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: 768px) and (pointer: coarse)`).matches}function K(e){let[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)([]),[a,o]=(0,j.useState)(null),[s,c]=(0,j.useState)(e);s!==e&&(c(e),e?n(Xe()):r.length>0&&i([]));let l=(0,j.useCallback)(e=>{i(t=>t.includes(e)?t:[...t,e])},[]),u=(0,j.useCallback)(()=>{i(e=>e.length===0?e:e.slice(0,-1))},[]),d=(0,j.useMemo)(()=>({isCompactTouch:t,viewStack:r,host:a,push:l,pop:u}),[t,r,a,l,u]),f=r.length>0;return{drillIn:d,isDrilled:f,wrapContent:(0,j.useCallback)(e=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{hidden:f,inert:f,...{0:{className:`xjp7ctv`},1:{className:`x1s85apg`}}[!!f|0],children:e}),(0,M.jsx)(`div`,{ref:o,className:`xjp7ctv`})]}),[f])}}var Ze=(0,j.lazy)(async()=>O(()=>import(`./MenuBottomSheet-B8bZZgjf.js`).then(e=>({default:e.MenuBottomSheet})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]))),q={trigger:{kVAEAm:`x1n2onr6`,k7VYTy:`xpdipgo`,kO7zv1:`x1winvzj`,kfSwDN:`x87ps6o`,$$css:!0},menu:{kB7OPa:`x9f619`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kOIVth:`x1lsbc85`,kskxy:`xuyqlj2`,kORKVm:`x1odjw0f`,"--_dropdown-menu-radius":`x1fcsqxe`,"--_dropdown-menu-padding":`xgory14`,kmVPX3:`x9epnlk`,kaIpWk:`x1n97fys`,kWkggS:`x1prclbq`,kGVxlE:`x1i5ehqx`,kSiTet:`x1hc1fzr`,k1ekBW:`x19991ni`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,kfSwDN:`x87ps6o`,k7VYTy:`xpdipgo`,$$css:!0},touchPinchZoom:{kFalU9:`x1j4r261`,$$css:!0},touchPanYPinchZoom:{kFalU9:`xge0x1e`,kZeWKH:`xish69e`,$$css:!0},popover:{k7Eaqz:`x5w4yej`,$$css:!0},popoverCustomWidth:e=>[{k7Eaqz:(typeof e==`number`?`${e}px`:e)==null?typeof e==`number`?`${e}px`:e:`xkj4a21`,$$css:!0},{"--x-minWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(typeof e==`number`?`${e}px`:e)}],sheetMenu:{kB7OPa:`x9f619`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kOIVth:`x1lsbc85`,kzqmXN:`xh8yej3`,"--_dropdown-menu-radius":`x1fcsqxe`,"--_dropdown-menu-padding":`xgory14`,kmVPX3:`x9epnlk`,kaIpWk:`x1n97fys`,kWkggS:`x10xzikg`,kI3sdo:`x1a2a7pz`,kfSwDN:`x87ps6o`,$$css:!0},sheetRootHeading:{keTefX:`x6i7dpz`,$$css:!0},sheetViewHeading:{kI3sdo:`x1a2a7pz`,$$css:!0}};function J(e,t){return e>t-1&&e<=t?Math.max(t-1,0):e}function Y({children:e,menuWidth:t,size:i=`md`,label:a,isDisabled:o=!1,onOpenChange:l,presentation:u=`popover`,triggerAs:d=`div`,ref:p,className:m,style:h,xstyle:g,triggerXstyle:_,onContextMenu:v,onTouchStart:y,onTouchMove:S,onTouchEnd:C,onTouchCancel:ne,"data-testid":w,...E}){let D=x(),O=a??D(`@astryx.contextMenu.label`),oe=D(`@astryx.dropdownMenu.back`),k=be(u)===`bottom-sheet`,{items:A,menuContent:ce,...pe}=E,ge=A??[],ve=ce,Se=(0,j.useId)(),we=(0,j.useRef)({x:0,y:0}),Ee=(0,j.useRef)(null),De=(0,j.useRef)(null),Oe=(0,j.useRef)(null),[N,ke]=(0,j.useState)(!1),[P,Ae]=(0,j.useState)([]),F=P.at(-1),I=F?.items??ge,je=F?.label??O,Me=typeof je==`string`?je:O,L=(0,j.useCallback)(e=>{e||Ae([]),ke(e),l?.(e)},[l]),R=T({mode:`context`,onHide:(0,j.useCallback)(()=>{ke(!1),l?.(!1);let e=Oe.current;Oe.current=null,e&&document.contains(e)&&e.focus()},[l]),onShow:(0,j.useCallback)(()=>{ke(!0),l?.(!0)},[l]),lightDismiss:!1}),z=(0,j.useCallback)(()=>{k?L(!1):R.hide()},[R,L,k]),Ne=(0,j.useCallback)((e,t)=>{e.isDisabled||(e.onClick?.(t),e.hasCloseOnSelect!==!1&&z())},[z]),Pe=(0,j.useCallback)(e=>{e&&N&&P.length>0&&e.focus({preventScroll:!0})},[N,P.length]),{listRef:B,handleKeyDown:V,focusFirst:Fe,focusItem:Ie,ownsEvent:Le,getItems:Re}=ee({itemSelector:le,boundarySelector:fe,wrap:!0,hasPaging:!0});f({isActive:N&&!k,onDismiss:z,getContainer:()=>B.current});let ze=ye({getItemLabels:()=>Re().map(e=>e.textContent),onMatch:Ie,getCurrentIndex:()=>Re().findIndex(e=>e===document.activeElement||e.contains(document.activeElement))});(0,j.useEffect)(()=>{if(!N||k)return;let e=B.current?.getRootNode(),t=e instanceof ShadowRoot?e:null,n=new WeakSet,r=e=>{let t=B.current;n.has(e)||(n.add(e),t&&!t.contains(e.target)&&z())};return document.addEventListener(`mousedown`,r),t?.addEventListener(`mousedown`,r),()=>{document.removeEventListener(`mousedown`,r),t?.removeEventListener(`mousedown`,r)}},[N,z,B,k]);let Be=(0,j.useCallback)(e=>{if(Le(e)){if(e.key===`Enter`||e.key===` `){if(e.preventDefault(),e.repeat)return;let t=document.activeElement;t&&ue.has(t.getAttribute(`role`)??``)&&de(t,e)}else e.key===`Tab`?z():ze.onKeyDown(e)?e.preventDefault():V(e)}},[V,z,ze,Le]),Ve=(0,j.useCallback)((e,t,n)=>{let r=De.current?.getBoundingClientRect(),i=r?J(e,r.width):e,a=r?J(t,r.height):t;we.current={x:i,y:a};let o=Ee.current;o&&(o.style.left=`${i}px`,o.style.top=`${a}px`),Oe.current=document.activeElement instanceof HTMLElement?document.activeElement:n,k?L(!0):(R.show(),requestAnimationFrame(()=>Fe()))},[R,Fe,L,k]),He=(0,j.useCallback)(()=>De.current?.getBoundingClientRect(),[]),Ue=(0,j.useCallback)(e=>{if(o)return;e.preventDefault();let t=He(),n=e.clientX===0&&e.clientY===0&&e.detail===0,r=n||!t?0:e.clientX-t.left,i=n||!t?t?.height??0:e.clientY-t.top;Ve(r,i,e.currentTarget)},[o,Ve,He]),{onTouchStart:H,onTouchMove:We,onTouchEnd:Ge,onTouchCancel:Ke}=he({disabled:o,onLongPress:(0,j.useCallback)(e=>{let t=He();Ve(t?e.x-t.left:e.x,t?e.y-t.top:e.y,De.current)},[Ve,He])}),qe=(0,j.useCallback)(e=>{Ue(e),v?.(e)},[Ue,v]),Je=(0,j.useCallback)(e=>{H(e),y?.(e)},[H,y]),U=(0,j.useCallback)(e=>{We(e),S?.(e)},[We,S]),Ye=(0,j.useCallback)(e=>{Ge(),C?.(e)},[Ge,C]),W=(0,j.useCallback)(e=>{Ke(),ne?.(e)},[Ke,ne]),Xe=t?q.popoverCustomWidth(t):q.popover,{drillIn:Y,wrapContent:X}=K(N&&!k),Qe=(0,j.useMemo)(()=>({closeMenu:z,menuSize:i,drillIn:Y,menuLabel:O}),[z,i,Y,O]),$e=X(A===void 0?ve:G(ge)),et=xe(B,$e,N&&!k),tt=_e({menuRef:B,itemSelector:le,onDismiss:z,isEnabled:!k}),nt=(0,M.jsx)(`div`,{ref:B,id:Se,role:`menu`,"data-autofocus":k?``:void 0,tabIndex:k?0:-1,"aria-label":O,onKeyDown:Be,onContextMenu:e=>e.preventDefault(),...tt.menuProps,...s(r(`context-menu`),n(k?q.sheetMenu:q.menu,!k&&(et?q.touchPanYPinchZoom:q.touchPinchZoom),g),m,h),children:(0,M.jsx)(Te,{value:Qe,children:(0,M.jsx)(Ce,{value:N,children:$e})})}),rt=A===void 0?nt:(0,M.jsxs)(`div`,{ref:B,"data-autofocus":``,tabIndex:0,...s(r(`context-menu`),n(q.sheetMenu,g),m,h),children:[(0,M.jsxs)(`div`,{className:`x78zum5 x1q0g3np x6s0dn4 xzye2dw x1p37lm5`,children:[P.length>0&&(0,M.jsx)(ae,{label:oe,variant:`ghost`,size:`sm`,icon:(0,M.jsx)(b,{icon:`chevronLeft`,size:`sm`,xstyle:te.mirror}),isIconOnly:!0,onClick:()=>Ae(e=>e.slice(0,-1))}),(0,M.jsx)(se,{ref:Pe,level:3,tabIndex:-1,xstyle:[q.sheetViewHeading,P.length===0&&q.sheetRootHeading],children:je})]}),(0,M.jsx)(me,{items:I,onSelect:Ne,onOpenSubmenu:e=>Ae(t=>[...t,e])})]});return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(d===`div`?`div`:`span`,{ref:ie(p,De),...pe,onContextMenu:qe,onTouchStart:Je,onTouchMove:U,onTouchEnd:Ye,onTouchCancel:W,"data-testid":w,...n(q.trigger,..._?Array.isArray(_)?_:[_]:[]),children:[e,(0,M.jsx)(`span`,{ref:ie(Ee,R.ref),"aria-hidden":`true`,...s({className:`x10l6tqk x1i1rx1s xjm9jq1 x47corl`},{style:{left:`${we.current.x}px`,top:`${we.current.y}px`}})})]}),k?(0,M.jsx)(j.Suspense,{fallback:null,children:(0,M.jsx)(Ze,{isOpen:N,onOpenChange:L,label:Me,children:rt})}):R.render((0,M.jsx)(c,{children:nt}),{placement:`below`,alignment:`start`,xstyle:[Xe,re.below]})]})}Y.displayName=`ContextMenu`;export{ze as a,Te as c,Be as i,Ce as l,K as n,Pe as o,G as r,Me as s,Y as t,Se as u};
@@ -1 +0,0 @@
1
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{c as n,u as r}from"./themeProps-3IqahpCr.js";import{s as i}from"./useLayerDismissal-BAnTRYTt.js";import{n as a,t as o}from"./Icon-BqkS-pIq.js";import{f as s}from"./useResolvedRequired-DbsOcDqy.js";import{c,l}from"./CheckboxInput-CFZ_Wq8-.js";import{r as u}from"./useMenuPress-DLG1QOiE.js";import{n as d,t as f}from"./ListItem-QF7KFt0h.js";var p=t(r(),1),m=new Set([`menuitem`,`menuitemradio`,`menuitemcheckbox`]),h=[...m].map(e=>`[role="${e}"]:not([aria-disabled="true"])`).join(`,`),g=`[role="menu"]`;function _(e){return e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0}function v(e,t){e.dispatchEvent(new MouseEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,metaKey:t.metaKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey}))}var y=e({MenuBottomSheetActionList:()=>w}),b=n(),x=`button:not(:disabled), a[href]`,S={list:{k7VYTy:`xpdipgo`,kfSwDN:`x87ps6o`,$$css:!0},destructiveAction:{"--_item-label-color":`xufyqxy`,"--_item-description-color":`xqlix59`,kMwMTN:`xjt36v0`,$$css:!0},divider:{kqGvvJ:`xsq74q5`,$$css:!0},sectionHeading:{kg3NbH:`xrrkdod`,$$css:!0}};function C(e,t){return`item-${e.id??t}`}function w({items:e,onSelect:t,onOpenSubmenu:n}){let r=(0,p.useRef)(null),m=u({menuRef:r,itemSelector:x}),h=(e,r)=>{let c=e.items!=null&&e.items.length>0,l=e.variant===`destructive`,u=!c&&e.href!=null,d=r=>{u&&e.isDisabled?r.preventDefault():(i()===`pointer`&&r.currentTarget.blur(),c?n(e):u&&_(r)?t({...e,onClick:void 0},r):t(e,r))};return(0,b.jsx)(f,{label:e.label,description:e.description,startContent:e.icon?a(e.icon,{size:`sm`,color:l?`error`:`secondary`}):void 0,endContent:c?(0,b.jsx)(o,{icon:`chevronRight`,size:`sm`,color:`secondary`,xstyle:s.mirror}):e.endContent,isDisabled:e.isDisabled,href:u?e.href:void 0,target:u?e.target:void 0,rel:u?e.rel:void 0,onClick:u?void 0:d,onClickCapture:u?d:void 0,xstyle:l&&S.destructiveAction},C(e,r))};return(0,b.jsx)(d,{ref:r,density:`spacious`,xstyle:S.list,...m.menuProps,children:e.map((e,t)=>`type`in e&&e.type===`divider`?(0,b.jsx)(`li`,{role:`presentation`,className:`x3ct3a4`,children:(0,b.jsx)(c,{xstyle:S.divider})},`divider-${t}`):`type`in e&&e.type===`section`?(0,b.jsx)(`li`,{className:`x3ct3a4`,children:(0,b.jsxs)(`div`,{role:`group`,"aria-label":e.title,className:`x78zum5 xdt5ytf xzye2dw`,children:[e.title&&(0,b.jsx)(l,{level:4,xstyle:S.sectionHeading,children:e.title}),(0,b.jsx)(d,{density:`spacious`,children:e.items.map(h)})]})},`section-${e.id??t}`):h(e,t))})}w.displayName=`MenuBottomSheetActionList`;export{h as a,m as i,y as n,v as o,g as r,_ as s,w as t};
@@ -1,3 +0,0 @@
1
- import{C as e,E as t,O as n,T as r,l as i,o as a,u as o,v as s,w as c,y as l}from"./schemas-BQ9Jydzb.js";import{$n as ee,Cr as te,Er as ne,Fn as re,H as ie,Ln as ae,Pr as u,Sr as oe,Wt as se,Yn as d,ar as f,gn as p,hn as m,in as ce,ir as le,lr as ue,mn as de,nn as fe,pn as pe,tn as me,vn as he,xr as ge,zn as _e,zt as ve}from"./tool-schema-CWSpXHJV.js";import{c as h}from"./host-patterns-F-KZIzkF.js";import{An as ye,Un as g,Wn as be,k as xe,mn as Se,nn as _,pn as Ce,wn as we}from"./shaped-data-BO6EAfYh.js";import{a as Te,n as Ee}from"./live-ingress-OuSlQ6q7.js";var De=2,Oe=4,ke=3,Ae=/(^|,)(\s*)("?)(?:([=@])|([+-])(?![0-9."]))/gm,je=/^[A-Za-z0-9+/]*={0,2}$/,Me=new Set([`text/csv`,`text/plain`,`text/markdown`]);function v(e){let{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}=e;if(t&&n&&r)return{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}}function Ne(e,t){if(t.limitsByMime){let n=he(e);if(t.limitsByMime[n])return t.limitsByMime[n];let[r]=n.split(`/`),i=`${r}/*`;if(t.limitsByMime[i])return t.limitsByMime[i]}return t.maxBytes}function y(e){return`uri`in e}function Pe(e){if(e.type===`speech`)throw new h(`request`,`Profile ${e.id} (speech) does not accept media input`);if(e.type===`live`)throw new h(`request`,`Profile ${e.id} (live) does not accept turn attachment input`);if(e.type===`host`||e.type===`decision`||e.type===`embedding`)throw new h(`request`,`Profile ${e.id} (${e.type}) does not accept turn input`);let t=v(e.inputs??{});if(!t)throw new h(`config`,`Profile ${e.id} must set maxFiles, maxBytes, and maxTurnBytes`);return t}function Fe(e){let t=0;return e.endsWith(`==`)?t=De:e.endsWith(`=`)&&(t=1),Math.floor(e.length*ke/Oe)-t}function Ie(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return new TextDecoder(`latin1`).decode(e)}}function Le(e){return e.replace(Ae,(e,...t)=>{let[n,r,i,a,o]=t;return`${n}${r}${i}'${a??``}${o??``}`})}function Re(e,t,n){let r=Ie(t);return e===`text/csv`&&(r=Le(r)),new TextEncoder().encode(n.read(r))}function b(e,t){return t?{...e,fileName:t}:e}function x(e,t,n){return t.filter(t=>!de(e,t.mimeType)).map(e=>b({code:`mime_not_allowed`,params:{mimeType:e.mimeType,channel:n}},e.name))}function ze(e,t){let n=[];e.length>t.maxFiles&&n.push({code:`too_many_files`,params:{maxFiles:t.maxFiles}});let r=0;for(let i of e){if(i.sizeBytes===void 0)continue;let e=Ne(i.mimeType,t);i.sizeBytes>e&&n.push(b({code:`file_too_large`,params:{maxBytes:e}},i.name)),r+=i.sizeBytes}return r>t.maxTurnBytes&&n.push({code:`turn_too_large`,params:{maxTurnBytes:t.maxTurnBytes}}),n}function S(e,t,n){let r=[];return t.length>0&&!e.attachments&&r.push({code:`attachments_not_accepted`,params:{channel:`attachment`}}),n.length>0&&!e.voice&&r.push({code:`voice_not_accepted`,params:{channel:`voice`}}),r.length>0||t.length===0&&n.length===0?r:(e.attachments&&r.push(...x(e.attachments,t,`attachment`)),e.voice&&r.push(...x(e.voice,n,`voice`)),e.limits?[...r,...ze([...t,...n],e.limits)]:[...r,{code:`limits_unconfigured`}])}var Be={mime_not_allowed:`attachments.mime_not_allowed`,too_many_files:`attachments.too_many_files`,too_many_of_kind:`attachments.too_many_of_kind`,file_too_large:`attachments.file_too_large`,turn_too_large:`attachments.turn_too_large`,attachments_not_accepted:`attachments.not_accepted`,voice_not_accepted:`attachments.not_accepted`,limits_unconfigured:`attachments.limits_unconfigured`};function C(e){let t={};for(let[n,r]of Object.entries(e.params??{}))r!==void 0&&(t[n]=r);return e.fileName!==void 0&&(t.fileName=e.fileName),{key:Be[e.code],params:t}}function Ve(e,t){let n=C(e);return g(n.key,n.params,t)}function w(e){return new h(`input`,`attachments refused: ${e.map(e=>e.code).join(`, `)}`,{copy:e.map(C)})}function T(e){if(!je.test(e))throw new h(`request`,`attachment data must be base64`);return Fe(e)}function E(e){let t={mimeType:e.mimeType,name:e.name};return y(e)||(t.sizeBytes=T(e.data)),t}function He(e,t,n){if(!Ue(t,n))return;let r=Pe(e),i=S({attachments:m(e,`attachments`),voice:m(e,`voice`),limits:r},(t??[]).map(E),(n??[]).map(E));if(i.length>0)throw w(i)}function D(e,t){if(y(e))return e;let{mimeType:n,data:r}=e;if(!Me.has(he(n)))return e;let i=Re(n,Ce(r),t);return{...e,data:Se(i)}}function Ue(e,t){return(e?.length??0)>0||(t?.length??0)>0}function We(e,t,n,r){return He(e,t,n),{attachments:t?.length?t.map(e=>D(e,r.attachment)):t,voice:n?.length?n.map(e=>D(e,r.voice)):n}}var Ge=`
2
-
3
- `;function Ke(e){if(typeof e==`string`)return;if(typeof e!=`object`||!e||Array.isArray(e))return`must be a string or { private: string }`;let t=Object.keys(e);if(t.length!==1||t[0]!==`private`)return`must have exactly one key, private`;let n=e.private;if(typeof n!=`string`)return`must be a string`;if(n===``)return`must not be empty`}function O(e,t){if(typeof e!=`string`){if(!Array.isArray(e))return`${t} must be a string or an array of parts`;if(e.length===0)return`${t} must not be an empty array`;for(let[n,r]of e.entries()){let e=Ke(r);if(e)return`${t}[${n}]${typeof r==`object`&&r&&`private`in r?`.private`:``} ${e}`}}}function k(e,t){let n=O(e,t);if(n)throw new h(`config`,n)}function qe(e,t,n){return k(e,t),typeof e==`string`?n(e):e.map(e=>typeof e==`string`?n(e):{private:n(e.private)})}function Je(e){if(typeof e==`string`)return[{text:e,private:!0}];let t=e.some(e=>typeof e!=`string`);return e.map(e=>typeof e==`string`?{text:e,private:!t}:{text:e.private,private:!0})}function A(e){let t=[];for(let n of e)n.some(e=>e.text)&&(t.length>0&&t.push({text:Ge,private:!0}),t.push(...n));return t}function Ye(e){return e.map(e=>e.text).join(``)}function Xe(e){let t=[],n=``;for(let r of e)r.private?n+=r.text:(n.trim()&&t.push(n),n=``);return n.trim()&&t.push(n),{text:Ye(e),private:t}}function Ze(e,t){return Xe(A([e,...t.map(e=>e?[{text:e,private:!0}]:[])]))}function j(e){let t=Object.keys(e);return t.length===1?t[0]:void 0}function M(e,t){let n=e.get(t);return n!==void 0&&n.type!==`builtin`}function N(e,t){return!e||e.includes(`*`)?!0:t?e.includes(t):!1}function Qe(e,t){return t.filter(n=>{let r=e.get(n);return r?.type!==`builtin`||!(r.conflictsWith??[]).some(e=>t.includes(e))})}function P(e){return`tools`in e?e.tools.allow:[]}function F(e){return e.type===`text`||e.type===`image`?e.tools:void 0}function $e(e){return`tools`in e?e.tools.parallel:void 0}function et(e,t,n){return P(t).filter(r=>{let i=e.get(r);return!i||i.type===`builtin`?!1:t.type===`host`||N(i.paths,n.path)})}function tt(e,t,n,r){let i=t.models[r];return i?(i.builtInTools??[]).filter(t=>{let r=e.get(t);return r?.type===`builtin`&&N(r.paths,n.path)}):[]}function I(e,t){let n=e.get(t);if(n&&n.type!==`builtin`)return{type:`function`,name:n.name,description:n.description,parameters:n.inputSchema}}function nt(e,t){let n=[];for(let r of t){let t=I(e,r);t&&n.push(t)}return n}function L(e,t,n){if(t.visible.includes(n))return;t.visible.push(n);let r=I(e,n);r&&!t.wire.some(e=>e.name===n)&&t.wire.push(r)}function rt(e,t,n){if(t.builtins.includes(n))return;let r=e.get(n);if(r?.type!==`builtin`)return;let i=r.conflictsWith??[];t.builtins=t.builtins.filter(t=>{if(i.includes(t))return!1;let r=e.get(t);return!(r?.type===`builtin`&&r.conflictsWith?.includes(n))}),t.builtins.push(n)}function it(e,t,n){return t.type===`live`||t.type===`host`?[...n]:n.filter(t=>e.get(t)?.loadTier===`T0`)}function at(e,t,n){return Qe(e,n.filter(n=>{let r=e.get(n);return r?.type===`builtin`&&(t.type===`live`||r.loadTier===`T0`)}))}function R(e,t,n,r){let i=et(e,t,n),a=t.type===`host`||t.type===`decision`||t.type===`embedding`||r===void 0?[]:tt(e,t,n,r),o=[...i,...a],s=at(e,t,o),c=it(e,t,o);return{builtins:s,gated:o,visible:c,executable:c.filter(t=>M(e,t)),path:n.path,sessionPermissions:n.sessionPermissions,wire:nt(e,c)}}async function ot(e,t,n,r){let i=R(e,t,n,r);return await z(e,i,t,n),i}function st(e){return{builtins:[...e.builtins],gated:[...e.gated],visible:[...e.visible],executable:[...e.executable],path:e.path,sessionPermissions:e.sessionPermissions?[...e.sessionPermissions]:void 0,wire:e.wire.map(e=>({...e,parameters:structuredClone(e.parameters)}))}}async function z(e,t,n,r){let i=F(n)?.t1Policy;if(!i)return;let a;try{a=await i({profile:n,input:r.input,path:r.path,sessionPermissions:r.sessionPermissions,gated:t.gated,host:r.host})}catch(e){let t=e instanceof Error?e.message:String(e);throw new h(`config`,`Profile '${n.id}' tools.t1Policy rejected: ${t}`,{cause:e})}if(!Array.isArray(a))throw new h(`config`,`Profile '${n.id}' tools.t1Policy must return ToolId[]`);for(let n of a){if(!t.gated.includes(n))continue;let r=e.get(n);r?.loadTier===`T2`&&(r.type===`builtin`?rt(e,t,n):L(e,t,n))}t.executable=t.visible.filter(t=>M(e,t))}var ct=new Set([`__proto__`,`constructor`,`prototype`]);function lt(e){if(!xe(e))return;let{loaded:t}=e;if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t}function ut(e,t,n,r){if(r.type===`live`||r.type===`host`)return{promoted:[]};let i=[];for(let a of n){if(typeof a!=`string`||ct.has(a))return{promoted:[],failure:{code:`invalid_output`,kind:`bad_response`,message:`tools.t2Loader loaded ids must be plain strings`}};let n=dt(e,a,r);if(`failure`in n)return{promoted:[],failure:n.failure};let{tool:o}=n;N(o.paths,t.path)&&t.gated.includes(a)&&i.push(a)}let a=[];for(let n of i)L(e,t,n),a.push(n);return t.executable=t.visible.filter(t=>M(e,t)),{promoted:a}}function B(e){return{failure:{code:`invalid_output`,kind:`bad_response`,message:e}}}function dt(e,t,n){if(!P(n).includes(t))return B(`tools.t2Loader attempted to promote tool '${t}' outside profile allow`);let r=e.get(t);return r?r.type===`builtin`?B(`tools.t2Loader attempted to promote builtin '${t}' — only custom tools may be promoted`):r.loadTier===`T2`?{tool:r}:B(`tools.t2Loader attempted to promote tool '${t}' with loadTier '${r.loadTier}' — only T2 tools may be promoted`):B(`tools.t2Loader attempted to promote unknown tool '${t}'`)}function V(e){return Array.isArray(e)?[...e]:e.choices.map(e=>e.value)}function ft(e){return Array.isArray(e)?{choices:e.map(e=>({value:e}))}:{...e.label!==void 0&&e.label!==``?{label:e.label}:{},choices:e.choices.map(e=>({value:e.value,...e.description!==void 0&&e.description!==``?{description:e.description}:{}}))}}function pt(e){if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,ft(t)]))}function H(e){return e?.slots?{...e,slots:pt(e.slots)}:e}function mt(e){return e==null}function U(e){return mt(e)||typeof e!=`object`||Array.isArray(e)?null:e}function W(e){let t=U(e);return!t||t.type!==void 0&&t.type!==`object`?null:t}function G(e){let t=e.required;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function K(e){let t=e.properties;return U(t)??{}}function ht(e,t){return e?`${e}.${t}`:t}function gt(e,t){t.push({path:e,error:`required field '${e}' is missing`})}async function _t(e,t,n,r,i){if(!n)return;let a=await n(t,r);a.isValid||i.push({path:e,error:a.error||a.finding||`Validation failed for '${e}'`})}async function vt(e){let{path:t,propSchema:n,child:r,isRequired:i,fields:a,slots:o,failures:s}=e;if(mt(r)){i&&gt(t,s);return}await _t(t,r,a?.[t],o,s);let c=W(n),l=c?U(r):null;c&&l&&await yt(c,l,t,a,o,s)}async function yt(e,t,n,r,i,a){let o=K(e),s=new Set(G(e)),c=new Set([...Object.keys(o),...s]),l=U(t);for(let e of c)await vt({path:ht(n,e),propSchema:o[e],child:l?.[e],isRequired:s.has(e),fields:r,slots:i,failures:a})}async function bt(e,t,n,r){let i=W(e);if(!i)throw new h(`config`,`structured validation requires a JSON Schema object root`);let a=[];if(!U(t)){for(let e of G(i))gt(e,a);return a}return await yt(i,t,``,n,r,a),a}function xt(e,t){let n=e;for(let e of t.split(`.`)){let t=W(n);if(!t)return!1;let r=K(t);if(!Object.hasOwn(r,e)&&!G(t).includes(e))return!1;n=r[e]}return!0}function St(e){return e.map(e=>e.error).join(`; `)}function q(e,t){let n=e;for(let e of t.split(`.`))n=U(n)?.[e];return n}function Ct(e,t,n){let[r,...i]=t.split(`.`),a=U(e)??{};return r===void 0?e:{...a,[r]:i.length?Ct(a[r],i.join(`.`),n):n}}async function wt(e,t,n){let r=[];for(let[i,a]of Object.entries(t??{})){let t=q(e,i);if(Array.isArray(t))for(let[e,o]of t.entries()){let t=await a.check(o,n);t.isValid||r.push({path:i,index:e,item:o,reason:t.error||t.finding||`Validation failed for '${i}'`,onFail:a.onFail})}}return r}function Tt(e,t){let n=e;for(let e of t.split(`.`)){let t=W(n);if(!t)return;n=K(t)[e]}let r=U(n);if(r?.type===`array`)return U(r.items)??void 0}var Et=class extends Error{failure;constructor(e){super(e.message),this.failure=e}},Dt=new Set([`text`,`image`,`speech`]),Ot=c().regex(/\S/),kt=e({mimeType:c(),data:o(),name:c().optional()}),At=e({mimeType:c(),uri:c(),name:c().optional()}),jt=e({voice:c().optional(),style:c().optional(),speed:s().positive().optional()});function Mt(t){return e(Object.fromEntries(Object.entries(t).map(([e,t])=>{let n=V(t);return[e,a(n).optional()]})))}var Nt=new Set([`text`,`attachments`,`voice`,`slots`,`speech`]);function Pt(e,t){if(!e.hostFields)return{sent:t};let n={...t},r={};for(let t of Object.keys(e.hostFields))n[t]!==void 0&&(r[t]=n[t]);let{text:i,attachments:a,voice:o,slots:s,speech:c}=t;return{sent:{text:i,...a?{attachments:a}:{},...o?{voice:o}:{},...s?{slots:s}:{},...c?{speech:c}:{}},hostInput:r}}function Ft(t,n){let{inputs:a}=t,o={text:Ot};a?.attachments&&(o.attachments=i(r([kt,At])).optional()),a?.voice&&(o.voice=i(kt).optional()),a?.slots&&(o.slots=Mt(a.slots).optional()),t.type===`speech`&&(o.speech=jt.optional());for(let e of n?.hostOnly??[]){if(!o[e])throw new h(`config`,`Tool '${n?.name}' keeps '${e}' for the host, which its profile does not take`);delete o[e]}for(let[e,t]of Object.entries(n?.fieldText??{})){let r=o[e];if(!r)throw new h(`config`,`Tool '${n?.name}' describes '${e}', which its profile does not take`);o[e]=r.describe(t)}for(let[e,t]of Object.entries(n?.hostFields??{})){if(Nt.has(e))throw new h(`config`,`Tool '${n?.name}' declares the host field '${e}', which is a field of every agent tool`);o[e]=t}return e(o)}var It=l({text:c().optional(),structured:t().optional(),removed:i(l({path:c(),reason:c(),item:t()})).optional(),parts:i(re).optional(),sources:i(_e).optional()});function Lt(e){return e.type===`speech`||(e.type===`text`||e.type===`image`)&&e.inputs.text!==!1}function Rt(e){return e.type===`builtin`?!1:e.permission!==`auto`||`auth`in e&&e.auth!==void 0&&(e.auth.onUnauthenticated??`gate`)===`gate`}function zt(e,t){if(!Dt.has(e.type))return`it is a ${e.type} profile; an agent tool runs a text, image, or speech profile`;if(!Lt(e))return`it does not take text`;for(let n of P(e)){let e=t(n);if(!e)return`its tool '${n}' is not registered; register it first`;if(Rt(e))return`its tool '${n}' can stop on a gate; give it permission 'auto' and no sign-in`}}function Bt(e,t,n){let r=`Agent tool "${e.name}"`,i=e.maxCallsPerTurn;if(i!==void 0&&!(Number.isInteger(i)&&i>0))throw new h(`config`,`${r}: maxCallsPerTurn must be a whole number above 0`);let a=t(e.profile);if(!a)throw new h(`config`,`${r}: profile '${e.profile}' must be registered before the tool`);let o=zt(a,n);if(o)throw new h(`config`,`${r} can't run '${e.profile}': ${o}`);return a}function Vt(e){if(!e)return`delegated`;let t=`models`in e&&Object.values(e.models).some(e=>(e.builtInTools?.length??0)>0);return P(e).length===0&&!t?`local`:`delegated`}function Ht(e){let t=ae(e),n=t.flatMap(e=>e.type===`text`?[e.text]:[]).join(``),r=ve(t,e=>e.type===`structured`),i=r?.structured,a=t.flatMap(e=>e.type===`media`?[{type:e.media.mimeType.startsWith(`audio/`)?`audio`:`image`,mimeType:e.media.mimeType,data:e.media.data}]:[]),o=t.flatMap(e=>e.type===`citation`?e.sources:[]);return{...i===void 0?{text:n}:{structured:i},...r?.removed?.length?{removed:r.removed}:{},...a.length>0?{parts:a}:{},...o.length>0?{sources:o}:{}}}function Ut(e,t,n){return{...e,type:`agent`,input:t,output:It,sources:e=>e.sources??[],...n}}function Wt(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return n.push(`${t}: schema must be an object`),!1;let r=typeof e.type==`string`||Array.isArray(e.type),i=e.anyOf!==void 0||e.oneOf!==void 0;if(!r&&!i){if(t!==`$`)return!0;n.push(`${t}: missing type or combinator`)}return e.type===`array`&&e.items===void 0&&n.push(`${t}: array schema must define items`),!0}function Gt(e,t,n,r){let i=Array.isArray(t)?t:[];for(let t of i)typeof t==`string`&&!Object.hasOwn(e,t)&&r.push(`${n}: required key '${t}' missing from properties`);for(let[t,i]of Object.entries(e))i&&typeof i==`object`&&J(i,`${n}.properties.${t}`,r)}function J(e,t,n){if(!Wt(e,t,n))return;let r=e.properties;r&&typeof r==`object`&&!Array.isArray(r)&&Gt(r,e.required,t,n),e.items&&typeof e.items==`object`&&!Array.isArray(e.items)&&J(e.items,`${t}.items`,n);for(let r of[`anyOf`,`oneOf`]){let i=e[r];Array.isArray(i)&&i.forEach((e,i)=>{e&&typeof e==`object`&&J(e,`${t}.${r}[${i}]`,n)})}}function Kt(e,t){let n=[];if(J(e,`$`,n),n.length>0)throw new h(`config`,`Invalid tool ${t} schema: ${n.join(`; `)}`)}function qt(e,t=`output`){let r=n(e,{target:`draft-7`,io:t});return delete r.$schema,r.type||=`object`,r}function Y(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(Y);let t={};for(let n of Object.keys(e))n!==`__proto__`&&n!==`constructor`&&n!==`prototype`&&(t[n]=Y(e[n]));return t}function Jt(e){let t=/^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec(e)?.[0];if(!t||/[{}]/.test(t))throw new h(`config`,`Endpoint "${e}" must start with a fixed scheme and host; placeholders belong in the path or query`)}function Yt(e,t,n,r){if(!n.provider?.trim()||!n.apiId?.trim())throw new h(`config`,g(`provider.binding_identity`))}function Xt(e){on(e.id,e.models),Z(e.id,e.observability),Jn(e.id,e.inputs);for(let[t,n]of Object.entries(e.models))cn(e.id,t,n);return{type:`embedding`,id:e.id,identity:{handle:e.identity.handle},models:e.models,defaultModel:sn(e.id,e),allowModelSelect:e.allowModelSelect,inputs:e.inputs,guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function Zt(e,t,n,r){let i=r.safeParse(n);if(!i.success)throw new h(`config`,`Profile ${e} model '${t}': ${i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `)}`)}function Qt(e,t,n){if(Zt(e,t,n,fe),Yt(e,t,n,`decision`),`retry`in n)throw new h(`config`,`Profile ${e} model '${t}': a decision binding takes no retry; a decision retries only a transient failure, by the kernel's rule`);if(n.timeoutMs!==void 0&&(!Number.isFinite(n.timeoutMs)||n.timeoutMs<=0))throw new h(`config`,`Profile ${e} model '${t}' timeoutMs must be > 0`)}function $t(e){let t=e.models?j(e.models):void 0;if(!t)throw new h(`config`,`Profile ${e.id}: type 'decision' must declare exactly one model`);Qt(e.id,t,e.models[t])}function en(e){if(e.inputs.state!==`json`)throw new h(`config`,`Profile ${e.id}: decision inputs.state must be 'json'`);let t=e.inputs.maxStateBytes;if(t!==void 0&&!(Number.isInteger(t)&&t>0))throw new h(`config`,`Profile ${e.id}: decision inputs.maxStateBytes must be a positive integer`);if(!e.decision.contract.trim())throw new h(`config`,`Profile ${e.id}: decision.contract must be non-empty`)}function tn(e){return $t(e),en(e),Z(e.id,e.observability),{...e,identity:{handle:e.identity.handle}}}function nn(e){return e===void 0?{}:{parallel:e}}function rn(e){return an(e.id,e.tools),Z(e.id,e.observability),{type:`host`,id:e.id,tools:{allow:e.tools.allow,...nn(e.tools.parallel)},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function an(e,t){if(!Array.isArray(t.allow))throw new h(`config`,`Profile ${e}: type 'host' must set tools.allow`)}function on(e,t){if(Object.keys(t).length===0)throw new h(`config`,`Profile ${e} must declare at least one model`)}function sn(e,t){let n=t.defaultModel??j(t.models);if(!n)throw new h(`config`,`Profile ${e} must set defaultModel when more than one model is declared`);if(!t.models[n])throw new h(`config`,`Profile ${e} defaultModel '${n}' is not declared`);return n}function cn(e,t,n){ln(e,t,n),Zt(e,t,n,ce),ln(e,t,n)}function ln(e,t,n){let r=n.efforts;if(!r||Object.keys(r).length===0){if(n.defaultEffort||n.allowEffortSelect)throw new h(`config`,`Profile ${e} model '${t}': defaultEffort and allowEffortSelect require efforts`);return}for(let[n,i]of Object.entries(r))if(!ue.includes(i))throw new h(`config`,`Profile ${e} model '${t}' effort '${n}': '${i}' is not a thinking level (${ue.join(`, `)})`);let i=Object.keys(r),a=n.defaultEffort??(i.length===1?i[0]:void 0);if(!a)throw new h(`config`,`Profile ${e} model '${t}' must set defaultEffort when more than one effort is declared`);if(!r[a])throw new h(`config`,`Profile ${e} model '${t}' defaultEffort '${a}' is not declared`);if(n.allowEffortSelect&&i.length<2)throw new h(`config`,`Profile ${e} model '${t}' allowEffortSelect requires at least two efforts`)}function un(e){return{providerContinuation:e.providerContinuation?ne.parse(e.providerContinuation):{},models:e.models,defaultModel:sn(e.id,e),allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps}}function dn(e,t,n){if(n?.length){for(let r of n)if(!se(r))throw new h(`config`,`Profile ${e}: turnBehaviour.resumption.${t} may only include ContinueStopKind (length | stream_incomplete | provider_error); got '${r}'`)}}function fn(e,t){t&&(dn(e,`allowContinue`,t.allowContinue),dn(e,`autoContinue`,t.autoContinue))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pn(e,t){let n=[e];for(let e of t)n=n.flatMap(t=>X(t)?e===`*`?Object.values(t):[t[e]]:[]);return n}var mn=Object.entries(le).filter(([,e])=>e.required===!0).map(([e,t])=>[e,t.profileTypes]).sort(([e],[t])=>e.split(`.`).length-t.split(`.`).length);function hn(e){if(!X(e))throw new h(`config`,`Profile definition must be an object`);let t=typeof e.id==`string`&&e.id.trim()?e.id:void 0;if(!t)throw new h(`config`,`Profile definition must set id`);if(!f.find(t=>t===e.type))throw new h(`config`,`Profile ${t}: type must be one of ${f.join(`, `)}`)}function gn(e){let t=e.identity?.handle,n=[[`id`,e.id,64],[`identity.handle`,typeof t==`string`?t:``,32]];for(let[t,r,i]of n)if(!(Array.from(r).length<=i))throw new h(`config`,`Profile ${e.id.slice(0,64)}: ${t} must be at most ${i} characters`)}function _n(e){let{id:t,type:n}=e,r=e;for(let[e,i]of mn){if(i&&!i.includes(n))continue;let a=oe(e),o=pn(r,a.slice(0,-1)),s=a[a.length-1];if(o.some(e=>{if(!X(e))return!1;let t=e[s];return t==null||t===``}))throw new h(`config`,`Profile ${t}: type '${n}' must set ${a.join(`.`)}`)}}function vn(e){let{id:t,type:n}=e;if(n!==`live`&&te(`inputs`).includes(n)&&e.inputs==null)throw new h(`config`,`Profile ${t}: type '${n}' must set inputs`)}function yn(e){let[t]=ge(e);if(!t)return;let{offValue:n,reason:r}=t.scope,i=n===void 0?``:` (other than ${n})`;throw new h(`config`,`Profile ${e.id}: type '${e.type}' must not set ${t.path}${i} — ${r}`)}function bn(e,t){let n=t.turnBehaviour;fn(e,n?.resumption)}function xn(e,t){let n=t=>new h(`config`,`Profile ${e}: ${t}`),r=t?.maxRetries;if(r!==void 0&&(!Number.isInteger(r)||r<0))throw n(`outputs.validation.maxRetries must be a non-negative integer`)}function Sn(e,t){let n=t=>new h(`config`,`Profile ${e}: ${t}`),r=Object.keys(t??{}).find(e=>!Cn.includes(e));if(r!==void 0)throw n(`guardrails.${r} is not a setting; it takes ${Cn.join(`, `)}`);Tn(t?.blockedReply,n)}var Cn=[`quota`,`detect`,`blockedReply`,`network`,`taint`],wn=[`onBlock`,`maxRetries`];function Tn(e,t){if(e===void 0)return;let n=Object.keys(e).find(e=>!wn.includes(e));if(n!==void 0)throw t(`guardrails.blockedReply.${n} is not a setting; it takes onBlock and maxRetries`);let{onBlock:r,maxRetries:i}=e;if(r!==void 0&&!u.includes(r))throw t(`guardrails.blockedReply.onBlock must be one of ${u.join(`, `)}`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw t(`guardrails.blockedReply.maxRetries must be a non-negative integer`)}function En(e){let t=e.guardrails?.detect,n=e.type===`host`?_(`guardrails.detect`,t,we):_(`guardrails.detect`,t);if(n!==void 0)throw new h(`config`,`Profile ${e.id}: ${n}`)}function Z(e,t){try{let n=Te(t);if(!Number.isFinite(n.retainForDays))throw new h(`config`,`Profile ${e}: observability.retainForDays must be a finite number`);if(n.rotateAfterMiB<=0||!Number.isFinite(n.rotateAfterMiB))throw new h(`config`,`Profile ${e}: observability.rotateAfterMiB must be a positive number`)}catch(t){if(t instanceof h&&t.message.startsWith(`Profile `))throw t;let n=t instanceof Error?t.message:String(t);throw new h(ye(t),`Profile ${e}: ${n}`,{cause:t})}}function Dn(e){if(e.type===`host`||e.type===`decision`||e.type===`speech`||e.type===`embedding`)return;let{system:t,systemByRole:n}=e.identity;t!==void 0&&k(t,`Profile ${e.id} identity.system`);for(let[t,r]of Object.entries(n??{}))k(r,`Profile ${e.id} identity.systemByRole.${t}`)}function On(e){hn(e);for(let t of[`key`,`fallbackKey`,`protocol`,`provider`])if(t in e)throw new h(`config`,g(`provider.profile_configuration`,{profile:e.id,field:t}));if(yn(e),vn(e),_n(e),gn(e),e.labels&&be(e.labels,`Profile ${e.id}`),Dn(e),En(e),e.type===`host`)return rn(e);if(e.type===`decision`)return tn(e);if(e.type===`embedding`)return Xt(e);on(e.id,e.models),bn(e.id,e),Sn(e.id,e.guardrails),e.type===`text`&&xn(e.id,e.outputs?.validation),Z(e.id,e.observability);for(let[t,n]of Object.entries(e.models))cn(e.id,t,n);let t=e.type===`speech`?{handle:e.identity.handle}:{handle:e.identity.handle,system:e.identity.system,systemByRole:e.identity.systemByRole},n=e.guardrails,r=e.observability,i=e.labels,a=un(e),o;switch(e.type){case`text`:o={type:`text`,id:e.id,identity:t,...a,tools:e.tools,inputs:H(e.inputs),outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i};break;case`image`:o={type:`image`,id:e.id,identity:t,...a,image:e.image,tools:e.tools,inputs:H(e.inputs),outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Pn(o.id,o.inputs.attachments?.accept),Nn(o.id,o.image);break;case`speech`:o={type:`speech`,id:e.id,identity:t,...a,speech:e.speech,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i};break;case`live`:o={type:`live`,id:e.id,identity:t,...a,live:e.live,inputs:e.inputs?H(e.inputs):e.inputs,tools:{allow:e.tools.allow,...nn(e.tools.parallel)},turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Ee(o),In(o.id,o.live.contextCompression),Fn(o);break;default:throw new h(`config`,`Unknown profile type '${String(e)}'`)}return jn(o),kn(o),An(o),o}function kn(e){let{maxSteps:t}=e;if(!(t===void 0||Number.isInteger(t)&&t>0))throw new h(`config`,`Profile ${e.id}: maxSteps must be a whole number of 1 or more; leave it out for the default of 20`)}function An(e){if(e.type===`text`&&e.turnBehaviour?.atStepLimit===`answer`&&e.maxSteps===1)throw new h(`config`,`Profile ${e.id}: turnBehaviour.atStepLimit 'answer' with maxSteps 1 leaves no step that can call a tool`)}function jn(e){if(e.type===`live`)return;let t=e.outputs?.structured;if(!t||typeof t==`string`)return;let n=p(e)?.slots?.[t.by];if(!n)throw new h(`config`,`Profile ${e.id}: outputs.structured.by '${t.by}' is not a slot in inputs.slots`);let r=V(n),i=Object.keys(t.map).filter(e=>!r.includes(e));if(i.length)throw new h(`config`,`Profile ${e.id}: outputs.structured.map maps ${i.join(`, `)}, not a choice of slot '${t.by}'`)}var Mn={n:{ok:e=>Number.isInteger(e)&&e>=1,rule:`a whole number of 1 or more`},seed:{ok:Number.isInteger,rule:`a whole number`},outputCompression:{ok:e=>Number.isInteger(e)&&e>=0&&e<=100,rule:`a whole number from 0 to 100`}};function Nn(e,t){for(let[n,{ok:r,rule:i}]of Object.entries(Mn)){let a=t[n];if(a!==void 0&&!r(a))throw new h(`config`,`Profile ${e}: image.${n} must be ${i}`)}t.references?.forEach((t,n)=>{let r=`Profile ${e}: image.references[${n}]`;if(pe(t.mimeType)!==`image`)throw new h(`config`,`${r} must be an image, not '${t.mimeType}'`);if(!(y(t)?t.uri:t.data))throw new h(`config`,`${r} needs its bytes or its uri`)})}function Pn(e,t){let n=t?.filter(e=>!de(ee,e));if(n?.length)throw new h(`config`,`Profile ${e}: an image profile's attachments take images, video, and PDF only, not ${n.join(`, `)}`)}function Fn(e){let{greeting:t,resumed:n,sessionResumption:r}=e.live,i=`Profile ${e.id} live`;if(t!==void 0&&(typeof t!=`string`||!t.trim()))throw new h(`config`,`${i}.greeting must be a prompt; leave it out to wait`);if(!n)return;if(typeof n.prompt!=`string`||!n.prompt.trim())throw new h(`config`,`${i}.resumed.prompt must be a prompt`);let{afterMs:a}=n;if(a!==void 0&&!(Number.isFinite(a)&&a>=0))throw new h(`config`,`${i}.resumed.afterMs must be 0 or more milliseconds`);if(!r)throw new h(`config`,`${i}.resumed needs live.sessionResumption: without it no call resumes`)}function In(e,t){if(!t)return;let n=`Profile ${e} live.contextCompression`,r=t.triggerTokens,i=t.slidingWindow.targetTokens;if(Ln(`${n}.triggerTokens`,r),Ln(`${n}.slidingWindow.targetTokens`,i),r!==void 0&&i!==void 0&&i>=r)throw new h(`config`,`${n}: slidingWindow.targetTokens must be below triggerTokens`)}function Ln(e,t){if(!(t===void 0||Number.isInteger(t)&&t>0))throw new h(`config`,`${e} must be a whole number above 0`)}function Rn(e,t,n,r){let i=`Profile ${t.id} model ${n} compaction`;if(zn(i,r),Bn(i,r),r.meter!=null&&r.meter!==`history`&&r.meter!==`input`)throw new h(`config`,`${i}: meter must be 'history' or 'input'`);if(r.profile===void 0){if(t.type!==`text`||t.inputs.text===!1)throw new h(`config`,`${i}: a profile that compacts itself must be a text profile that takes text`);return}let a=e.get(r.profile);if(!a)throw new h(`config`,`${i}: compaction profile '${r.profile}' must be registered before '${t.id}'`);if(a.type!==`text`||a.inputs.text===!1)throw new h(`config`,`${i}: compaction profile '${r.profile}' must be a text profile that takes text`)}function zn(e,t){if(t.maxTokens<=0)throw new h(`config`,`${e}: maxTokens must be > 0`);if(t.compactAt<=0||t.compactAt>=1)throw new h(`config`,`${e}: compactAt must be in (0, 1)`)}function Bn(e,t){if(t.previousExchanges<0)throw new h(`config`,`${e}: previousExchanges must be >= 0`);if(t.previousExchanges<1&&t.previousExchanges>=t.compactAt)throw new h(`config`,`${e}: previousExchanges as fraction (${t.previousExchanges}) must be < compactAt (${t.compactAt})`);if(t.previousExchanges>1&&!Number.isInteger(t.previousExchanges))throw new h(`config`,`${e}: previousExchanges >= 1 must be an integer`)}function Vn(e,t){for(let n of P(t))if(e.get(n)?.type===`builtin`)throw new h(`config`,t.type===`host`?`Profile ${t.id} lists builtin '${n}' in tools.allow — type 'host' never runs a model`:`Profile ${t.id} lists builtin '${n}' in tools.allow — declare it on models.*.builtInTools instead`)}function Hn(e,t){let n=F(t)?.t2Loader;if(n){if(!P(t).includes(n))throw new h(`config`,`Profile ${t.id} tools.t2Loader '${n}' must also be listed in tools.allow`);if(e.get(n)?.type!==`function`)throw new h(`config`,`Profile ${t.id} tools.t2Loader '${n}' must be a registered type: 'function' tool`)}}function*Un(e){for(let[t,n]of Object.entries(e.models))for(let e of n.builtInTools??[])yield{modelId:t,id:e}}function Wn(e,t){for(let{modelId:n,id:r}of Un(t))if(e.get(r)?.type!==`builtin`)throw new h(`config`,`Profile ${t.id} model '${n}' lists '${r}' in builtInTools — not a registered builtin`)}function Gn(e){let t=e.type===`text`?e.outputs?.structured:void 0;return t?typeof t==`string`?[t]:[...new Set([...Object.values(t.map),t.fallback])]:[]}function Kn(e,t){let n=Gn(t).map(n=>{let r=e.find(n);if(!r)throw new h(`config`,`Profile ${t.id}: outputs.structured names '${n}', which is not a registered schema; register it before the profile`);return r}),r=t.type===`text`?t.outputs?.validation:void 0,i=Object.keys(r?.fields??{}),a=Object.keys(r?.items??{});if(!i.length&&!a.length)return;if(!n.length)throw new h(`config`,`Profile ${t.id}: outputs.validation checks a structured reply, so it needs outputs.structured`);let o=a.filter(e=>!n.some(t=>Tt(t.jsonSchema,e)));if(o.length)throw new h(`config`,`Profile ${t.id}: outputs.validation.items has ${o.join(`, `)}, which no structured schema reaches as a list with an items schema`);let s=i.filter(e=>!n.some(t=>xt(t.jsonSchema,e)));if(s.length)throw new h(`config`,`Profile ${t.id}: outputs.validation.fields has ${s.join(`, `)}, which no structured schema reaches through object properties`)}function qn(e){let t=p(e)?.context;if(!t)return;let n=d;if(t.from.length===0||t.from.some(e=>!n.includes(e)))throw new h(`config`,`Profile ${e.id}: inputs.context.from must list ${d.join(` or `)}`);if(!(Number.isInteger(t.maxChars)&&t.maxChars>0))throw new h(`config`,`Profile ${e.id}: inputs.context.maxChars must be a positive integer`)}function Jn(e,t){if(!t)return;let{attachments:n,voice:r,maxFiles:i,maxBytes:a,maxTurnBytes:o,limitsByMime:s}=t,c={maxFiles:i,maxBytes:a,maxTurnBytes:o};if((n||r)&&Object.values(c).some(e=>e===void 0))throw new h(`config`,`Profile ${e} must set maxFiles, maxBytes, and maxTurnBytes`);for(let[e,t]of Object.entries(s??{}))c[`limitsByMime['${e}']`]=t;for(let[t,n]of Object.entries(c))if(n!==void 0&&!(Number.isInteger(n)&&n>0))throw new h(`config`,`Profile ${e}: inputs.${t} must be a positive integer`)}function Yn(e,t,n){let r=new Map,i=i=>{let a=On(i),o=n&&a.type!==`host`?{...a,models:Object.fromEntries(Object.entries(a.models).map(([e,t])=>[e,me(n.require(t.provider,t.apiId),t,a.type)]))}:a;if(Vn(e,o),Hn(e,o),o.type!==`host`&&o.type!==`decision`&&o.type!==`embedding`){Wn(e,o),Jn(o.id,p(o)),qn(o),Kn(t,o);for(let[e,t]of Object.entries(o.models))t.compaction&&Rn(r,o,e,t.compaction)}r.set(o.id,o)};return{register:i,registerMany(e){for(let t of e)i(t)},get(e){let t=r.get(e);if(!t)throw new h(`config`,`Unknown profile '${e}'`);return t},find:e=>r.get(e),has:e=>r.has(e),list:()=>[...r.values()],clear:()=>r.clear()}}function Xn(e){let t=e?.trim()??``;if(t.startsWith(`AIza`))return`gemini`;if(t.startsWith(`sk-or-`))return`openrouter`}function Q(e){let t;try{t=new URL(e.baseUrl)}catch{throw new h(`config`,`Enter a valid localhost URL.`)}if(![`http:`,`https:`].includes(t.protocol)||![`localhost`,`127.0.0.1`,`[::1]`].includes(t.hostname)||t.username||t.password||t.search||t.hash)throw new h(`config`,`Use a localhost URL without credentials, query parameters or a fragment.`);return{baseUrl:t.href.replace(/\/$/,``),fetch:(e,n)=>new URL(e instanceof Request?e.url:String(e)).origin===t.origin?fetch(e,{...n,redirect:`error`,credentials:`omit`}):Promise.reject(new h(`blocked`,`Local requests must stay on the configured origin.`))}}var Zn=l({data:i(l({id:c().min(1)}))});async function Qn(e,t){let n=Q(e);if(!n?.fetch)throw new h(`config`,`Enter a local endpoint.`);let r=await n.fetch(`${n.baseUrl}/v1/models`,{signal:t,headers:{Accept:`application/json`}});if(!r.ok)throw new h(`network`,`Local model list returned HTTP ${r.status}.`);let i=Zn.safeParse(await r.json());if(!i.success)throw new h(`request`,`The endpoint returned an invalid model list.`);return[...new Set(i.data.data.map(e=>e.id))]}var $n=`https://openrouter.ai/api/v1/models`,er=`https://openrouter.ai/api/v1/embeddings/models`,tr=[{id:`gemini-embedding-2-preview`,label:`Gemini Embeddings 2 (preview)`},{id:`gemini-embedding-001`,label:`Gemini Embedding 001`}],nr=[{id:`liquid/lfm-2.5-embedding-350m:free`,label:`Liquid LFM 2.5 Embedding 350M (free)`},{id:`nvidia/nemotron-3-embed-1b:free`,label:`NVIDIA Nemotron 3 Embed 1B (free)`},{id:`nvidia/llama-nemotron-embed-vl-1b-v2:free`,label:`NVIDIA Llama Nemotron Embed VL 1B v2 (free)`}],rr={text:`text`,image:`image`,speech:`speech`,live:void 0,embedding:void 0},ir=l({data:i(l({id:c().min(1),name:c().optional(),architecture:l({output_modalities:i(c()).optional()}).optional()}))}),ar=l({data:i(l({id:c().min(1),name:c().optional()}))}),or=l({models:i(l({name:c().min(1),displayName:c().optional(),supportedGenerationMethods:i(c()).optional()})).optional(),nextPageToken:c().optional()}),sr=5;async function $(e,t,n){let r=await fetch(t,{...n,redirect:`error`,credentials:`omit`});if(r.status===400||r.status===401||r.status===403)throw new h(`auth`,`${e} refused the key.`);if(!r.ok)throw new h(`network`,`${e} model list returned HTTP ${r.status}.`);return await r.json()}async function cr(e,t,n,r){let i=n?.trim();if(t===`embedding`&&!i)return[...e===`openrouter`?nr:tr];if(e===`openrouter`)return await lr(t,i,r);if(!i)throw new h(`auth`,`Choose a key to list Gemini models.`);return await dr(t,i,r)}async function lr(e,t,n){let r={signal:n,headers:{Accept:`application/json`,...t?{Authorization:[`Bearer`,t].join(` `)}:{}}};if(e===`embedding`){let e=ar.safeParse(await $(`OpenRouter`,er,r));if(!e.success)throw new h(`bad_response`,`OpenRouter returned an invalid embedding model list.`);return e.data.data.map(e=>({id:e.id,label:e.name??e.id}))}let i=rr[e];if(!i)return[];let a=ir.safeParse(await $(`OpenRouter`,`${$n}?output_modalities=${i}`,r));if(!a.success)throw new h(`bad_response`,`OpenRouter returned an invalid model list.`);return a.data.data.filter(e=>e.architecture?.output_modalities?.includes(i)??!0).map(e=>({id:e.id,label:e.name??e.id}))}var ur={live:`bidiGenerateContent`,embedding:`embedContent`};async function dr(e,t,n){let r=ur[e]??`generateContent`,i=[],a;for(let e=0;e<sr;e++){let e=new URL(ie);e.searchParams.set(`pageSize`,`1000`),a&&e.searchParams.set(`pageToken`,a);let o=or.safeParse(await $(`Google`,e.href,{signal:n,headers:{Accept:`application/json`,"x-goog-api-key":t}}));if(!o.success)throw new h(`bad_response`,`Google returned an invalid model list.`);for(let e of o.data.models??[]){if(!e.supportedGenerationMethods?.includes(r))continue;let t=e.name.replace(/^models\//,``);i.push({id:t,label:e.displayName??t})}if(a=o.data.nextPageToken,!a)break}return i}function fr(e){return[...new Set([e.key,e.fallbackKey,...Object.values(e.models??{}).flatMap(e=>[e.keySlot,e.fallbackKeySlot])].filter(e=>!!e))]}function pr(e,t){return Object.fromEntries(e.map(e=>[e,Object.hasOwn(t,e)?t[e]:void 0]))}export{st as A,Ze as B,bt as C,Ct as D,q as E,$e as F,Ve as G,qe as H,F as I,T as J,S as K,ut as L,lt as M,ot as N,pt as O,P,R,wt as S,Tt as T,Je as U,A as V,O as W,v as X,y as Y,We as Z,It as _,fr as a,Ut as b,On as c,Y as d,Kt as f,Vt as g,Ft as h,Q as i,z as j,V as k,Jt as l,zt as m,Qn as n,pr as o,Et as p,w as q,cr as r,Yn as s,Xn as t,qt as u,Ht as v,St as w,Pt as x,Bt as y,j as z};