@theoremjs/studio 0.3.4-next.409.g25ad907 → 0.3.4-next.415.g3597d47

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 (65) hide show
  1. package/README.md +1 -1
  2. package/browser-transport.js +9 -0
  3. package/mod.d.ts +1 -1
  4. package/mod.js +1 -1
  5. package/package.json +4 -4
  6. package/page/assets/Banner-8YJcS8-V.js +2 -0
  7. package/page/assets/CollapsibleGroup-PavPZ114.js +1 -0
  8. package/page/assets/ConsoleFrame-DU_VbYY8.js +3 -0
  9. package/page/assets/{ContextMenu-VPTaWK-b.js → ContextMenu-BM8iCtOh.js} +2 -2
  10. package/page/assets/{ToolResultCharts-Dq13qCma.js → ToolResultCharts-2ZnwTSBM.js} +1 -1
  11. package/page/assets/TraceInspector-BMPAqts9.js +1 -0
  12. package/page/assets/{TraceOverview-DybxPVl-.js → TraceOverview-CAcG99rb.js} +1 -1
  13. package/page/assets/{_virtual_studio-type-sources-BJMljtdu.js → _virtual_studio-type-sources-Cwv7y4JN.js} +20 -11
  14. package/page/assets/browser-engine-CZIMsNT9.js +11 -0
  15. package/page/assets/{browser-transport-LKSluKnw.js → browser-transport-1C-yqvF_.js} +5 -5
  16. package/page/assets/{export-agent-CXeoKMBQ.js → export-agent-CtTlaPls.js} +1 -1
  17. package/page/assets/{guardrail-tester-BqEC6z_w.js → guardrail-tester-DSqEFs8L.js} +2 -2
  18. package/page/assets/{index-pXL_YUn6.js → index-BCMKIa3t.js} +68 -68
  19. package/page/assets/index-Cbs7B46A.css +1 -0
  20. package/page/assets/labels-provider-BSiD6Lrb.js +3 -0
  21. package/page/assets/{live-messages-BZGmMo_v.js → live-messages-CI-oP2dK.js} +1 -1
  22. package/page/assets/reader-CVFKFctz.js +7 -0
  23. package/page/assets/{stub-DpBSP8Ld.js → stub-Bf9DC2iQ.js} +1 -1
  24. package/page/assets/{studio-code-pane-x7-LT6o5.js → studio-code-pane-PK_Sla3w.js} +3 -3
  25. package/page/assets/{studio-console-Csza4hhE.js → studio-console-CfDp9X-T.js} +1 -1
  26. package/page/assets/{studio-decision-D5MMKOqJ.js → studio-decision-B4KZCD5V.js} +1 -1
  27. package/page/assets/{studio-embedding-Bek5oqS0.js → studio-embedding-CB4lSSWM.js} +1 -1
  28. package/page/assets/{studio-host-console-D_q5Nyv-.js → studio-host-console-C3PBxw_t.js} +2 -2
  29. package/page/assets/{studio-labels-BEjKXPex.js → studio-labels-Jw1KQ1X1.js} +1 -1
  30. package/page/assets/{studio-live-tjh1LcdQ.js → studio-live-BfBbeQVS.js} +2 -2
  31. package/page/assets/{studio-map-C9eDWUud.js → studio-map-D3GkuREn.js} +1 -1
  32. package/page/assets/{studio-trace-replay-CHoGJIBE.js → studio-trace-replay-BSDZA9i6.js} +1 -1
  33. package/page/assets/{studio-type-checker-Cm6RZxV3.js → studio-type-checker-xhy-9-yy.js} +1 -1
  34. package/page/assets/{tool-schema-CgpwKFX7.js → tool-schema-BlUbzOu9.js} +1 -1
  35. package/page/assets/{tree-BxX70aqA.js → tree-6F02tTxC.js} +1 -1
  36. package/page/assets/{turn-client-BZUECwPn.js → turn-client-4GHmGV_4.js} +2 -2
  37. package/page/assets/types-DN_oZAOJ.js +1 -0
  38. package/page/assets/{use-one-call-TdPLk5Rh.js → use-one-call-CY-cA5FL.js} +1 -1
  39. package/page/assets/{SidePanel-OYp0bLNO.js → use-trace-records-BkAYJz0M.js} +1 -1
  40. package/page/assets/workspace-MlrGUH2-.js +1 -0
  41. package/page/index.html +16 -16
  42. package/runtime.d.ts +1 -1
  43. package/runtime.js +5 -2
  44. package/server/draft-handler.js +17 -1
  45. package/transport.js +10 -0
  46. package/ui/inspector-context.d.ts +5 -0
  47. package/ui/inspector-context.js +2 -0
  48. package/ui/profile-editor.js +10 -3
  49. package/ui/studio-run.js +2 -12
  50. package/ui/studio-screen.js +141 -158
  51. package/ui/studio.css +29 -13
  52. package/ui/use-phone.d.ts +2 -0
  53. package/ui/use-phone.js +13 -0
  54. package/workspace.d.ts +7 -0
  55. package/workspace.js +48 -0
  56. package/page/assets/Banner-CYShUDUy.js +0 -2
  57. package/page/assets/CollapsibleGroup-CL8h1IzH.js +0 -1
  58. package/page/assets/ConsoleFrame-DFm0uALE.js +0 -3
  59. package/page/assets/TraceInspector-CxprTtsH.js +0 -1
  60. package/page/assets/browser-engine-DmuH9Q0j.js +0 -11
  61. package/page/assets/index-Oo9otEIT.css +0 -1
  62. package/page/assets/labels-provider-BqgbdxdT.js +0 -3
  63. package/page/assets/reader-paEmSrWc.js +0 -7
  64. package/page/assets/types-BoECJ8mE.js +0 -1
  65. package/page/assets/workspace-Bc---F49.js +0 -1
@@ -1,3 +1,3 @@
1
- import{C as e,Gt as t,Jn as n,M as r,ar as i,cr as a,er as o,h as ee,hr as s,j as c,ln as l,lr as u,mn as d,n as te,p as f,t as ne,vr as p,y as re,z as ie,zt as ae}from"./tool-schema-CgpwKFX7.js";import{En as m,Sn as h,qt as g,rn as _,tn as oe}from"./shaped-data-0GUF7Al3.js";import{a as se,r as v}from"./live-ingress-lDUGPwth.js";var ce=[{id:`identity`,profilePath:`identity`,role:`root`,optional:!1,editor:`structural`,label:`Identity`,ownsFields:[`profile.id`,`profile.type`]},{id:`models`,profilePath:`models`,role:`spine`,optional:!1,editor:`structural`,label:`Models`,ownsFields:[`profile.defaultModel`,`profile.allowModelSelect`,`profile.maxSteps`,`providerContinuation`]},{id:`modelBinding`,profilePath:`models.*`,role:`branch`,parent:`models`,optional:!1,editor:`structural`,label:`Model binding`},{id:`decision`,profilePath:`decision`,role:`spine`,optional:!1,editor:`structural`,label:`Decision`,ownsFields:[`inputs`]},{id:`image`,profilePath:`image`,role:`spine`,optional:!1,editor:`structural`,label:`Image`},{id:`speech`,profilePath:`speech`,role:`spine`,optional:!1,editor:`structural`,label:`Speech`},{id:`live`,profilePath:`live`,role:`spine`,optional:!1,editor:`structural`,label:`Live`},{id:`tools`,profilePath:`tools`,role:`spine`,optional:!1,editor:`structural`,label:`Tools`},{id:`toolSpec`,profilePath:`tools.allow`,role:`branch`,parent:`tools`,optional:!0,editor:`structural`,label:`Tool`},{id:`inputs`,profilePath:`inputs`,role:`spine`,optional:!1,editor:`structural`,label:`Inputs`},{id:`outputs`,profilePath:`outputs`,role:`spine`,optional:!0,editor:`structural`,label:`Outputs`},{id:`turnBehaviour`,profilePath:`turnBehaviour`,role:`spine`,optional:!0,editor:`structural`,label:`Turn behaviour`},{id:`guardrails`,profilePath:`guardrails`,role:`spine`,optional:!0,editor:`structural`,label:`Guardrails`},{id:`observability`,profilePath:`observability`,role:`spine`,optional:!0,editor:`structural`,label:`Observability`},{id:`labels`,profilePath:`labels`,role:`spine`,optional:!0,editor:`structural`,label:`Labels`}],le={identity:s,inputs:p(`inputs`).filter(e=>e!==`decision`)},y=ce.map(e=>({...e,profileTypes:le[e.id]??p(e.profilePath)}));function ue(e){return y.find(t=>t.id===e)}function de(e){return e.modelBindings.length>1}function fe(e){return e.modelBindings.some(t=>t.provider!==`local`&&!r(e.providers,t).keySlot)}function pe(e,t){let n={provider:t.provider,keySlot:t.keySlot||e.models.key,fallbackKeySlot:t.fallbackKeySlot||e.models.fallbackKey},i=r(e.providers,n);return{...i,given:{keySlot:!!i.keySlot&&!n.keySlot,fallbackKeySlot:!!i.fallbackKeySlot&&!n.fallbackKeySlot}}}function me(e){let t=e.efforts.map(({alias:e})=>e.trim()).filter(Boolean);return new Set(t).size>1}function he(e){return e.attachmentsAccept.length>0||e.voiceAccept.length>0}var ge=o,b={compactMaxTokens:32e3,compactAt:.75,compactKeep:4},x={"continue.instruction":`turnBehaviour`,"canary.bind_note":`guardrails`,"quota.exhausted":`guardrails`,"repair.default_guidance":`outputs`,"egress.default_repair_guidance":`guardrails`,"egress.refusal":`guardrails`};function S(e){return`${e}-${crypto.randomUUID().slice(0,8)}`}function C(e){return{key:S(`model`),modelId:`fast`,protocol:`openRouter`,provider:`openrouter`,apiId:``,options:{},timeoutMs:null,efforts:[],defaultEffort:``,allowEffortSelect:!1,summaries:null,maxOutputTokens:null,temperature:null,builtInTools:[],...e}}var w=`Studio stub tool — returns a fixed result.`;function T(e){return{key:S(`tool`),toolName:`my_tool`,toolType:`function`,description:w,category:`studio`,access:i[0],permission:u[0],loadTier:a[0],paths:[`*`],inputJson:ne,outputJson:te,...e}}function E(e,t,n){return(!e.description.trim()||e.description===w)&&n?{agentKey:t,description:`Asks ${n} and returns its answer.`}:{agentKey:t}}function D(){return{name:``,kind:`words`,pattern:``,flags:``,words:[]}}function O(){return{key:``,label:``,at:m(h,()=>`ignore`),patterns:[D()],hint:``}}function k(){let e=d(void 0);return{canaryBindNote:``,detect:m(g,t=>({...e.detect[t]})),sources:Object.fromEntries(oe.map(e=>[e,{theorem:!0,patterns:[],hint:``}])),own:[],quotaEnabled:!1,quotaPerDay:null,quotaMessage:``,allow:{ungiven_images:{hosts:[],fromTools:!0},ungiven_links:{hosts:[],fromTools:!0}},innocentNames:[],blockedReplyOnBlock:``,blockedReplyMaxRetries:null,egressRepairGuidance:``,egressRefusal:``,allowPrivateNetworks:!1,allowedHosts:[],allowedSchemes:[],taintAfterRemoteRead:``,taintRemoteDestination:``}}function A(){let e=se({});return{writeTo:f,destination:f,sampleRate:e.sampleRate,include:{...e.include},scrub:{sensitive:!!e.scrub.sensitive,injection:!!e.scrub.injection,canary:!!e.scrub.canary},retainForDays:null,rotateAfterMiB:null,resourceJson:``}}function j(e){return e.map(([e,t])=>({key:S(`criterion`),label:e,text:t}))}function M(){return{contract:`guardrails.tool_call.v1`,maxStateBytes:null,questions:[{key:S(`question`),id:`verdict`,type:`choice`,instructions:`Given what the user asked for and what the call would do, should it run?`,criteria:j([[`allow`,`Safe, and what the user asked for.`],[`flag`,`Probably fine, but unusual or sensitive enough for a person to look first.`],[`block`,`Harmful, or clearly beyond what the user asked for.`]])},{key:S(`question`),id:`risk`,type:`score`,instructions:`How much harm would this call do if it were wrong?`,criteria:j([[``,`Low: reversible, and affects only the user.`],[``,`High: hard to undo, or affects other people or money.`]])}],images:[]}}var N=JSON.stringify({context:`The user asked the agent to tidy up old screenshots on their desktop.`,tool_call:{name:`delete_files`,path:`~/Documents`,recursive:!0},outcome:`Would delete 1,284 files, including tax_return_2025.pdf.`},null,2),P=JSON.stringify(`The user asked to tidy screenshots. The proposed call recursively deletes 1,284 files, including a tax return.`),F=`To clear your desktop, select the screenshots and move them to the Trash. Empty the Trash to delete them for good.(Screen captures save to the desktop by default. You can change where they go in the Screenshot app's Options menu.(Press Command-Shift-5 to record the screen or capture a window. Recordings are saved as movie files next to your screenshots.(Stacks group desktop files by kind, date or tag, so a cluttered desktop folds into a few piles you can open one at a time.(Deleted files stay in the Trash for 30 days. Drag a file out of the Trash to put it back where it was.(When your disk is almost full, open Storage settings and review the largest files. Old downloads and installers are safe to remove.(Offloading unused apps frees space and keeps their documents. Reinstalling an app brings its data back.(Photos you have backed up can be optimised so the originals live in the cloud and smaller copies stay on the device.(Your plan renews on the same date each month. You can see the next charge under Billing, then Upcoming invoices.(To get a refund, open the invoice and choose Request refund. Charges from the last 14 days are refunded in full.(Update your card under Billing, then Payment methods. The new card is used for the next renewal, not for past invoices.(Annual plans cost two months less than paying monthly. Switching mid-term credits the unused months to the new plan.(Invoices are emailed as PDFs and list your company name and tax number. Edit those details before the invoice is issued.(Turn on two-step verification under Security. You will be asked for a code from your authenticator app each time you sign in on a new device.(If you forget your password, choose Forgot password on the sign-in page. The reset link expires after one hour.(Review signed-in devices under Security and sign out any you don't recognise. This ends their sessions immediately.(Passkeys replace your password with your fingerprint or face. Create one under Security, then Passkeys.(To close your account, export your data first. Closing deletes your workspace after a 30-day grace period.(Share a folder by choosing Share, then entering an email address. Viewers can read; editors can change and delete.(Public links work for anyone who has them. Set an expiry date, or turn the link off to stop sharing at once.(Transfer ownership of a folder before you leave a team, or its contents will be archived with your account.(Lisbon has mild, wet winters and warm, dry summers. Expect highs near 28 °C in August.(The best months for the Algarve coast are May, June and September, when the beaches are warm and the crowds are thin.(Trams in Lisbon climb the steep hills of Alfama and Graça. Line 28 is the famous one, and the busiest.(For a crisp pizza base, preheat the oven and the baking tray together at the highest setting for at least thirty minutes.(Rest steak for five minutes after cooking so the juices settle back into the meat instead of running onto the board.`.split(`(`).join(`
1
+ import{C as e,Gt as t,Jn as n,M as r,ar as i,cr as a,er as o,h as ee,hr as s,j as c,ln as l,lr as u,mn as d,n as te,p as f,t as ne,vr as p,y as re,z as ie,zt as ae}from"./tool-schema-BlUbzOu9.js";import{En as m,Sn as h,qt as g,rn as _,tn as oe}from"./shaped-data-0GUF7Al3.js";import{a as se,r as v}from"./live-ingress-lDUGPwth.js";var ce=[{id:`identity`,profilePath:`identity`,role:`root`,optional:!1,editor:`structural`,label:`Identity`,ownsFields:[`profile.id`,`profile.type`]},{id:`models`,profilePath:`models`,role:`spine`,optional:!1,editor:`structural`,label:`Models`,ownsFields:[`profile.defaultModel`,`profile.allowModelSelect`,`profile.maxSteps`,`providerContinuation`]},{id:`modelBinding`,profilePath:`models.*`,role:`branch`,parent:`models`,optional:!1,editor:`structural`,label:`Model binding`},{id:`decision`,profilePath:`decision`,role:`spine`,optional:!1,editor:`structural`,label:`Decision`,ownsFields:[`inputs`]},{id:`image`,profilePath:`image`,role:`spine`,optional:!1,editor:`structural`,label:`Image`},{id:`speech`,profilePath:`speech`,role:`spine`,optional:!1,editor:`structural`,label:`Speech`},{id:`live`,profilePath:`live`,role:`spine`,optional:!1,editor:`structural`,label:`Live`},{id:`tools`,profilePath:`tools`,role:`spine`,optional:!1,editor:`structural`,label:`Tools`},{id:`toolSpec`,profilePath:`tools.allow`,role:`branch`,parent:`tools`,optional:!0,editor:`structural`,label:`Tool`},{id:`inputs`,profilePath:`inputs`,role:`spine`,optional:!1,editor:`structural`,label:`Inputs`},{id:`outputs`,profilePath:`outputs`,role:`spine`,optional:!0,editor:`structural`,label:`Outputs`},{id:`turnBehaviour`,profilePath:`turnBehaviour`,role:`spine`,optional:!0,editor:`structural`,label:`Turn behaviour`},{id:`guardrails`,profilePath:`guardrails`,role:`spine`,optional:!0,editor:`structural`,label:`Guardrails`},{id:`observability`,profilePath:`observability`,role:`spine`,optional:!0,editor:`structural`,label:`Observability`},{id:`labels`,profilePath:`labels`,role:`spine`,optional:!0,editor:`structural`,label:`Labels`}],le={identity:s,inputs:p(`inputs`).filter(e=>e!==`decision`)},y=ce.map(e=>({...e,profileTypes:le[e.id]??p(e.profilePath)}));function ue(e){return y.find(t=>t.id===e)}function de(e){return e.modelBindings.length>1}function fe(e){return e.modelBindings.some(t=>t.provider!==`local`&&!r(e.providers,t).keySlot)}function pe(e,t){let n={provider:t.provider,keySlot:t.keySlot||e.models.key,fallbackKeySlot:t.fallbackKeySlot||e.models.fallbackKey},i=r(e.providers,n);return{...i,given:{keySlot:!!i.keySlot&&!n.keySlot,fallbackKeySlot:!!i.fallbackKeySlot&&!n.fallbackKeySlot}}}function me(e){let t=e.efforts.map(({alias:e})=>e.trim()).filter(Boolean);return new Set(t).size>1}function he(e){return e.attachmentsAccept.length>0||e.voiceAccept.length>0}var ge=o,b={compactMaxTokens:32e3,compactAt:.75,compactKeep:4},x={"continue.instruction":`turnBehaviour`,"canary.bind_note":`guardrails`,"quota.exhausted":`guardrails`,"repair.default_guidance":`outputs`,"egress.default_repair_guidance":`guardrails`,"egress.refusal":`guardrails`};function S(e){return`${e}-${crypto.randomUUID().slice(0,8)}`}function C(e){return{key:S(`model`),modelId:`fast`,protocol:`openRouter`,provider:`openrouter`,apiId:``,options:{},timeoutMs:null,efforts:[],defaultEffort:``,allowEffortSelect:!1,summaries:null,maxOutputTokens:null,temperature:null,builtInTools:[],...e}}var w=`Studio stub tool — returns a fixed result.`;function T(e){return{key:S(`tool`),toolName:`my_tool`,toolType:`function`,description:w,category:`studio`,access:i[0],permission:u[0],loadTier:a[0],paths:[`*`],inputJson:ne,outputJson:te,...e}}function E(e,t,n){return(!e.description.trim()||e.description===w)&&n?{agentKey:t,description:`Asks ${n} and returns its answer.`}:{agentKey:t}}function D(){return{name:``,kind:`words`,pattern:``,flags:``,words:[]}}function O(){return{key:``,label:``,at:m(h,()=>`ignore`),patterns:[D()],hint:``}}function k(){let e=d(void 0);return{canaryBindNote:``,detect:m(g,t=>({...e.detect[t]})),sources:Object.fromEntries(oe.map(e=>[e,{theorem:!0,patterns:[],hint:``}])),own:[],quotaEnabled:!1,quotaPerDay:null,quotaMessage:``,allow:{ungiven_images:{hosts:[],fromTools:!0},ungiven_links:{hosts:[],fromTools:!0}},innocentNames:[],blockedReplyOnBlock:``,blockedReplyMaxRetries:null,egressRepairGuidance:``,egressRefusal:``,allowPrivateNetworks:!1,allowedHosts:[],allowedSchemes:[],taintAfterRemoteRead:``,taintRemoteDestination:``}}function A(){let e=se({});return{writeTo:f,destination:f,sampleRate:e.sampleRate,include:{...e.include},scrub:{sensitive:!!e.scrub.sensitive,injection:!!e.scrub.injection,canary:!!e.scrub.canary},retainForDays:null,rotateAfterMiB:null,resourceJson:``}}function j(e){return e.map(([e,t])=>({key:S(`criterion`),label:e,text:t}))}function M(){return{contract:`guardrails.tool_call.v1`,maxStateBytes:null,questions:[{key:S(`question`),id:`verdict`,type:`choice`,instructions:`Given what the user asked for and what the call would do, should it run?`,criteria:j([[`allow`,`Safe, and what the user asked for.`],[`flag`,`Probably fine, but unusual or sensitive enough for a person to look first.`],[`block`,`Harmful, or clearly beyond what the user asked for.`]])},{key:S(`question`),id:`risk`,type:`score`,instructions:`How much harm would this call do if it were wrong?`,criteria:j([[``,`Low: reversible, and affects only the user.`],[``,`High: hard to undo, or affects other people or money.`]])}],images:[]}}var N=JSON.stringify({context:`The user asked the agent to tidy up old screenshots on their desktop.`,tool_call:{name:`delete_files`,path:`~/Documents`,recursive:!0},outcome:`Would delete 1,284 files, including tax_return_2025.pdf.`},null,2),P=JSON.stringify(`The user asked to tidy screenshots. The proposed call recursively deletes 1,284 files, including a tax return.`),F=`To clear your desktop, select the screenshots and move them to the Trash. Empty the Trash to delete them for good.(Screen captures save to the desktop by default. You can change where they go in the Screenshot app's Options menu.(Press Command-Shift-5 to record the screen or capture a window. Recordings are saved as movie files next to your screenshots.(Stacks group desktop files by kind, date or tag, so a cluttered desktop folds into a few piles you can open one at a time.(Deleted files stay in the Trash for 30 days. Drag a file out of the Trash to put it back where it was.(When your disk is almost full, open Storage settings and review the largest files. Old downloads and installers are safe to remove.(Offloading unused apps frees space and keeps their documents. Reinstalling an app brings its data back.(Photos you have backed up can be optimised so the originals live in the cloud and smaller copies stay on the device.(Your plan renews on the same date each month. You can see the next charge under Billing, then Upcoming invoices.(To get a refund, open the invoice and choose Request refund. Charges from the last 14 days are refunded in full.(Update your card under Billing, then Payment methods. The new card is used for the next renewal, not for past invoices.(Annual plans cost two months less than paying monthly. Switching mid-term credits the unused months to the new plan.(Invoices are emailed as PDFs and list your company name and tax number. Edit those details before the invoice is issued.(Turn on two-step verification under Security. You will be asked for a code from your authenticator app each time you sign in on a new device.(If you forget your password, choose Forgot password on the sign-in page. The reset link expires after one hour.(Review signed-in devices under Security and sign out any you don't recognise. This ends their sessions immediately.(Passkeys replace your password with your fingerprint or face. Create one under Security, then Passkeys.(To close your account, export your data first. Closing deletes your workspace after a 30-day grace period.(Share a folder by choosing Share, then entering an email address. Viewers can read; editors can change and delete.(Public links work for anyone who has them. Set an expiry date, or turn the link off to stop sharing at once.(Transfer ownership of a folder before you leave a team, or its contents will be archived with your account.(Lisbon has mild, wet winters and warm, dry summers. Expect highs near 28 °C in August.(The best months for the Algarve coast are May, June and September, when the beaches are warm and the crowds are thin.(Trams in Lisbon climb the steep hills of Alfama and Graça. Line 28 is the famous one, and the busiest.(For a crisp pizza base, preheat the oven and the baking tray together at the highest setting for at least thirty minutes.(Rest steak for five minutes after cooking so the juices settle back into the meat instead of running onto the board.`.split(`(`).join(`
2
2
 
3
3
  `),I=`How do I delete every screenshot on my desktop?`;function L(e,t=`choice`){let n=K(`question`,e.decision.questions.map(e=>e.id),e=>`question_${e}`);return{key:S(`question`),id:n,type:t,instructions:``,criteria:R(t)}}function _e(e,t,n){let r=t.replace(/\.[^.]*$/,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_|_$/g,``)||`image`,i=K(r,e.decision.images.map(e=>e.name),e=>`${r}_${e}`);return{key:S(`image`),name:i,...n}}function R(e){return e===`noul`||e===`box`?[]:j(e===`choice`?[[`yes`,``],[`no`,``]]:[[``,``],[``,``]])}function ve(){return{identity:{agentId:``,profileType:``,handle:``,system:``,systemByRoleJson:``},included:[`observability`,`labels`],models:{defaultModel:``,allowModelSelect:!1,maxSteps:null,key:``},modelBindings:[],providers:[...e],tools:{t2Loader:``,parallel:!1},toolSpecs:[],inputs:{text:!0,attachmentsAccept:[],voiceAccept:[],maxFiles:null,maxBytes:null,maxTurnBytes:null,limitsByMimeJson:``,slotsJson:``,contextFrom:[],contextMaxChars:null},outputs:{mode:`text`,schemaId:``,schemaJson:``,streamMode:``,streamThoughts:!0,validationEnabled:!1,maxRetries:null,itemRules:{},repairGuidance:``},turnBehaviour:{resumeEnabled:!1,allowContinue:[],autoContinue:[],maxContinues:null,continueInstruction:``,allowSteering:t({type:`text`}),atStepLimit:`stop`},guardrails:k(),observability:A(),image:{aspectRatio:``,resolution:``,mimeType:``,quality:``,background:``,n:null,seed:null,outputCompression:null,includeText:!1,references:[]},speech:{voice:``,style:``,speed:null,format:``},live:{ingressAudio:v(`audio`),ingressVideo:v(`video`),ingressText:v(`text`),voice:``,sessionResumption:!1,greeting:``,resumedPrompt:``,resumedAfterMs:null,contextCompression:!1,compressionTriggerTokens:null,compressionTargetTokens:null,transcriptionInput:!1,transcriptionOutput:!1,vadActivityHandling:``,vadStartSensitivity:``,vadEndSensitivity:``,vadPrefixPaddingMs:null,vadSilenceDurationMs:null},decision:M(),labels:{}}}var ye=new Set([`guardrails`]);function z(e,t){return e.profileTypes.includes(t)&&!(t===`decision`&&ye.has(e.id))}function B(e){let t=e.identity.profileType;if(!t)return[`identity`];let n=new Set(e.included);return y.filter(e=>e.role!==`branch`&&z(e,t)&&(!e.optional||n.has(e.id))).map(e=>e.id)}function V(e,t){let n=e.identity.profileType;return n!==``&&p(t).includes(n)}function be(e){return V(e,`identity.system`)&&_(e.guardrails.detect,`canary_leak`)}function H(e){let t=e.identity.profileType;return t!==``&&ae.includes(t)}function U(e){let t=e.identity.profileType;return t?y.filter(n=>n.role===`spine`&&n.optional&&z(n,t)&&!e.included.includes(n.id)).map(e=>e.id):[]}function xe(e){return{...e,attachmentsAccept:e.attachmentsAccept.filter(e=>l(n,e)),voiceAccept:[]}}function Se(e,t,n){let r=e.modelBindings.find(e=>e.key===t);return r?{...e,models:n.modelId!==void 0&&e.models.defaultModel===r.modelId?{...e.models,defaultModel:n.modelId}:e.models,modelBindings:e.modelBindings.map(e=>e.key===t?{...e,...n}:e)}:e}function W(e,t){if(t.some(t=>t.modelId===e))return e;let[n,...r]=t;return n&&!r.length?n.modelId:``}function Ce(e,t){if(!e.modelBindings.find(e=>e.key===t))return e;let n=e.modelBindings.filter(e=>e.key!==t);return{...e,models:{...e.models,defaultModel:W(e.models.defaultModel,n)},modelBindings:n}}function G(e,t){let n=e.identity.profileType,r=n&&n!==`host`?n:`text`,i=e.modelBindings.map(e=>e.modelId),a=re(r,t),o=K(a.modelId,i,e=>`${a.modelId}${e}`);return C({...a,modelId:o})}function we(e){return T({toolName:K(`my_tool`,e.toolSpecs.map(e=>e.toolName),e=>`my_tool_${e}`)})}function K(e,t,n){let r=new Set(t),i=e;for(let e=2;r.has(i);e++)i=n(e);return i}function Te(e,t,n){if(t===`host`)return{...e,identity:{...e.identity,profileType:t}};let r=e.modelBindings.filter(r=>{let i=c(e.providers,t,r),a=e.providers.find(e=>e.id===r.provider);return ie(a,t,r.protocol)&&!Oe(n,t,i)}),i={...e,identity:{...e.identity,profileType:t},modelBindings:r},a=r.length?r:[G(i,n?.start)],o=!e.models.key&&fe({...i,modelBindings:a}),s=t===`speech`&&!e.speech.voice.trim()&&a.some(n=>ee(c(e.providers,t,n)));return{...i,inputs:t===`image`?xe(e.inputs):e.inputs,...s?{speech:{...e.speech,voice:Ee}}:{},models:{...e.models,defaultModel:W(e.models.defaultModel,a),key:o?ke:e.models.key},modelBindings:a}}var Ee=`Kore`,De=[`text`,`image`,`speech`,`live`,`decision`];function Oe(e,t,n){if(!e)return!1;let r=t=>e.models(t,n.definition).some(e=>e.id===n.apiId.trim());return!r(t)&&De.some(e=>e!==t&&r(e))}var ke=`slot_a`;function Ae(e,t){return U(e).includes(t)?{...e,included:[...e.included,t]}:e}function je(e,t){return{...e,included:e.included.filter(e=>e!==t)}}function q(e){return`modelBinding:${e}`}var J=`toolSpec:`;function Y(e){return`${J}${e}`}function X(e){return e.startsWith(J)?e.slice(9):void 0}var Z=`provider:`;function Me(e){return`${Z}${e}`}function Ne(e){return e.startsWith(Z)?e.slice(9):void 0}var Pe=new Map(y.map(e=>[e.id,e.label]));function Q(e){return Pe.get(e)??e}function Fe(e,t){let[n,r]=t.split(`:`,2);if(n===`modelBinding`&&r!==void 0)return e.modelBindings.some(e=>e.key===r)?{facet:n,key:r}:void 0;let i=X(t);if(i!==void 0)return e.toolSpecs.some(e=>e.key===i)?{facet:`toolSpec`,key:i}:void 0;let a=B(e);if(r===void 0&&a.includes(t))return{facet:t}}function Ie(e,t){return t===`models`?e.modelBindings.map(e=>({id:q(e.key),ref:{facet:`modelBinding`,key:e.key},label:e.modelId.trim()||Q(`modelBinding`),children:[]})):t===`tools`?$(e.toolSpecs):[]}function $(e){return e.map(e=>({id:Y(e.key),ref:{facet:`toolSpec`,key:e.key},label:e.toolName.trim()||Q(`toolSpec`),children:[]}))}function Le(e){let t=B(e).filter(e=>e!==`identity`).map(t=>({id:t,ref:{facet:t},label:Q(t),children:Ie(e,t)}));return{id:`identity`,ref:{facet:`identity`},label:e.identity.agentId.trim()||Q(`identity`),children:t}}export{G as A,me as B,je as C,R as D,Ae as E,Ce as F,he as H,Te as I,H as L,D as M,we as N,_e as O,be as P,Se as R,S,U as T,y as U,de as V,ue as W,ve as _,Le as a,V as b,$ as c,I as d,F as f,E as g,ge as h,Fe as i,O as j,L as k,b as l,x as m,Ne as n,X as o,P as p,Me as r,Y as s,q as t,N as u,C as v,K as w,B as x,T as y,pe as z};
@@ -1,2 +1,2 @@
1
- import{Lt as e,Mn as t}from"./tool-schema-CgpwKFX7.js";import{c as n}from"./host-patterns-C9RMP16Q.js";import{A as r,Mn as i,en as a}from"./shaped-data-0GUF7Al3.js";import{F as o,bt as s}from"./reader-paEmSrWc.js";import{r as c}from"./encode-files-DZ4tVtEQ.js";function l(e,t){let r=typeof t==`string`?t.trim():``;if(!r)throw new n(`request`,`A typed credential must be a non-empty string`);if(e===`bearer`)return{type:`bearer`,token:r};if(e===`api_key`)return{type:`api_key`,key:r};throw new n(`request`,`A '${e}' sign-in takes no typed credential; the host's callback saves it`)}function ee(e,t){if(!e)throw new n(`request`,`a typed credential answers only a sign-in gate`);return{slot:e.slot,credential:l(e.authType,t)}}var u=18e5;function te(e,t){let r=t??u;if(!Number.isFinite(r)||r<=0)throw new n(`config`,`${e} gateTtlMs must be a positive number of milliseconds; got ${r}.`);return r}function ne(e,t,n){return t-e>=n}var d=[`approve`,`deny`,`abandon`];function f(e,t=!1){return e.decision===`approve`?{granted:!0,...e.edited?{edited:e.edited}:{},...t?{signIn:t}:{}}:{granted:!1,cause:e.decision===`deny`?`declined`:`abandoned`,...t?{signIn:t}:{}}}function p(e,t,n){return n!==`session_consent`||e.includes(t)?[...e]:[...e,t]}function re(e,t,r){let{callId:i,decision:a,input:o,secret:s,page:c}=e;if((o!==void 0||s!==void 0||c!==void 0)&&a!==`approve`)throw new n(`request`,`only an approval takes edited input, a secret, or a page answer (call ${i})`);if(a!==`approve`)return{resume:f({decision:a},t.auth!==void 0),input:t.arguments,sessionPermissions:[...r]};let l=s===void 0?void 0:ee(t.auth,s);return{resume:{...f(o===void 0?{decision:a}:{decision:a,edited:{from:t.arguments}},t.auth!==void 0),...t.gateKind?{gateKind:t.gateKind}:{}},input:o??t.arguments,sessionPermissions:p(r,t.name,t.permission),...l?{typed:l}:{},...c?{page:c}:{}}}var m={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
2
- `,r:`\r`,t:` `};function h(e,t){let n=``,r=t+1;for(;r<e.length;){let t=e.charAt(r);if(t===`"`)return{text:n,end:r+1};if(t!==`\\`){n+=t,r++;continue}if(r+1>=e.length)break;let i=e.charAt(r+1);if(i===`u`){let t=e.slice(r+2,r+6);if(t.length<4)break;if(/^[0-9a-fA-F]{4}$/.test(t)){n+=String.fromCharCode(Number.parseInt(t,16)),r+=6;continue}}n+=m[i]??i,r+=2}return{text:n}}function g(e,t){let n=t;for(;/\s/.test(e.charAt(n));)n++;return n}function ie(e,t){if(e.charAt(t)===`"`){let n=h(e,t);return n.end===void 0?void 0:_(e,t,n.end)}let n=0;for(let r=t;r<e.length;r++){let i=e.charAt(r);if(i===`"`){let t=h(e,r).end;if(t===void 0)return;r=t-1}else if(i===`{`||i===`[`)n++;else if(i===`}`||i===`]`){if(n===0)return _(e,t,r);if(n--,n===0)return _(e,t,r+1)}else if(i===`,`&&n===0)return _(e,t,r)}}function _(e,t,n){try{return{value:JSON.parse(e.slice(t,n)),end:n}}catch{return}}function v(e){let t={},n=g(e,0);if(e.charAt(n)!==`{`)return t;for(n++;;){if(n=g(e,n),e.charAt(n)===`,`&&(n=g(e,n+1)),e.charAt(n)!==`"`)return t;let r=h(e,n);if(r.end===void 0||(n=g(e,r.end),e.charAt(n)!==`:`)||(n=g(e,n+1),n>=e.length))return t;let i=ie(e,n);if(!i)return e.charAt(n)===`"`&&(t[r.text]=h(e,n).text),t;t[r.text]=i.value,n=i.end}}function y(e,t){if(t.phase===void 0)return{name:t.name,callId:t.callId,...t.operationId?{operationId:t.operationId}:{},arguments:t.arguments,...t.reasoning?{reasoning:t.reasoning}:{},...t.stepId?{stepId:t.stepId}:{},artifacts:[]};if(e===void 0)throw new n(`bad_response`,`Tool event '${t.phase}' for call '${t.callId}' arrived before the call.`);if(e.callId!==t.callId||e.name!==t.name)throw new n(`bad_response`,i(`error.bad_response`));switch(t.phase){case`running`:{let{endedAt:n,outputDraft:r,...i}=e;return{...i,state:t,startedAt:t.at,...t.edited?{edited:t.edited}:{},...t.activity?{activity:t.activity}:{}}}case`complete`:return{...b(e),state:t,endedAt:t.at,...t.activityPast?{activityPast:t.activityPast}:{}};case`error`:return{...b(e),state:t,endedAt:t.at,...t.activityPast?{activityPast:t.activityPast}:{}};case`cancel`:case`gate`:return{...b(e),state:t,endedAt:t.at};case`draft`:return{...e,outputDraft:(e.outputDraft??``)+t.text};case`artifact`:return{...e,artifacts:[...e.artifacts,t.artifact]};case`dispatch`:case`progress`:case`trace`:case`warning`:return e}}function b(e){let{outputDraft:t,...n}=e;return n}function x(e,t){return{arguments:{},artifacts:[],...e,name:t.name,callId:t.callId,draft:(e?.draft??``)+t.text}}function ae(e){let t=new Map;for(let n of e){if(n.type===`tool_draft`){t.set(n.callId,x(t.get(n.callId),n));continue}if(n.type!==`tool`)continue;let{tool:e}=n,r=e.operationId??e.callId;e.phase===void 0&&t.get(e.callId)?.draft!==void 0&&t.delete(e.callId),t.set(r,y(t.get(r),e))}return[...t.values()]}function S(e){return(e.state?.phase===`gate`?e.state.gate.preparedArguments:void 0)??e.edited?.to??e.arguments}function C(e,t){return e.type!==`tool`||e.tool.callId!==t?!1:e.tool.phase===`complete`||e.tool.phase===`error`}var w={avif:`image/avif`,gif:`image/gif`,heic:`image/heic`,heif:`image/heif`,jpeg:`image/jpeg`,jpg:`image/jpeg`,png:`image/png`,svg:`image/svg+xml`,webp:`image/webp`,mp4:`video/mp4`,webm:`video/webm`,mov:`video/quicktime`,ogv:`video/ogg`,mp3:`audio/mpeg`,m4a:`audio/mp4`,ogg:`audio/ogg`,wav:`audio/wav`};function oe(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0||n===t.length-1?void 0:w[t.slice(n+1).toLowerCase()]}function se(e){let t=e.trim();if(t.length===0)return;let n;try{n=new URL(t)}catch{return}if(n.protocol!==`http:`&&n.protocol!==`https:`)return;let r=oe(n.pathname);if(r)return{url:n.href,mimeType:r}}var ce=/^(.*)\/thumb(\/.+\/([^/]+))\/(\d+)px-\3(?:\.[a-z0-9]+)?$/i;function le(e){let t=new URL(e),n=t.hostname.split(`.`).slice(-2).join(`.`);for(let e of[...t.searchParams.keys()])e.startsWith(`utm_`)&&t.searchParams.delete(e);let r=ce.exec(t.pathname);return{key:`${n}${r?`${r[1]}${r[2]}`:t.pathname}${t.search}`,width:r?Number(r[4]):1/0}}function ue(e){let t=new Map,n=[],r=e=>{if(typeof e==`string`){let r=se(e);if(!r)return;let i=le(r.url),a=t.get(i.key);if(!a){t.set(i.key,{index:n.length,largest:i.width,smallest:i.width}),n.push(r);return}let o=n[a.index];i.width>a.largest?(a.largest=i.width,n[a.index]={...o,url:r.url,previewUrl:o.previewUrl??o.url}):i.width<a.smallest&&(a.smallest=i.width,n[a.index]={...o,previewUrl:r.url})}else if(Array.isArray(e))for(let t of e)r(t);else if(typeof e==`object`&&e)for(let t of Object.values(e))r(t)};return r(e),n}var T=0;function E(e){return e===`user`?`user-${globalThis.crypto.randomUUID()}`:(T+=1,`${e}-${String(T)}`)}function de(e,t){return e?.kind===t}function D(e,t,n,r){let i=e.at(-1);de(i,t)?i.text+=n:e.push({id:E(r),kind:t,text:n})}function O(e,t){let n=e.at(-1),r=n?.kind===`text`||n?.kind===`thought`;e.splice(r?e.length-1:e.length,0,t)}function k(e,t){return e.find(e=>e.kind===`tool`&&e.id===t)}function A(e,t){let n=`tool-${t.operationId??t.callId}`,r=k(e,n),i=y(r?.tool,t);if(r){r.tool=i;return}let a=t.phase===void 0?k(e,`tool-${t.callId}`):void 0;a?.tool.draft===void 0?e.push({id:n,kind:`tool`,tool:i}):(a.id=n,a.tool=i)}function j(e,t){let n=`tool-${t.callId}`,r=k(e,n),i=x(r?.tool,t);r?r.tool=i:e.push({id:n,kind:`tool`,tool:i})}function M(e){return e.findLast(e=>e.kind===`structured`&&e.draft!==void 0)}function N(e,t,n){let r=M(e),i=(r?.draft??``)+t;r?(r.draft=i,r.value=v(i)):e.push({id:E(n),kind:`structured`,value:v(i),draft:i})}function P(e,t,n){let r=M(e);r?(r.value=t,delete r.draft):e.push({id:E(n),kind:`structured`,value:t})}function F(e,t){return e.type===t.type?e.placeId&&t.placeId?e.placeId===t.placeId:e.uri===t.uri:!1}function I(e,t,n){let r=e.find(e=>e.kind===`citation`&&e.callId===t.callId),i=r?[...r.sources]:[];for(let e of t.sources)i.some(t=>F(t,e))||i.push(e);r?r.sources=i:e.push({id:E(n),kind:`citation`,sources:i,...t.callId===void 0?{}:{callId:t.callId}})}function L(e,t,n,r){if(t.phase===`complete`&&t.output!==void 0)for(let i of ue(t.output))r.has(i.url)||(r.add(i.url),e.push({id:E(n),kind:`media`,mimeType:i.mimeType,url:i.url,...i.previewUrl?{previewUrl:i.previewUrl}:{}}))}function R(e,t=`user`){let n=[],r=e.text?.trim();r&&n.push({id:E(t),kind:`user-text`,text:r});for(let r of e.attachments??[])n.push({id:E(t),kind:`user-attachment`,name:r.name,mimeType:r.mimeType,sizeBytes:r.sizeBytes,...r.data===void 0?{}:{data:r.data}});for(let r of e.voice??[])n.push({id:E(t),kind:`user-voice`,name:r.name,mimeType:r.mimeType,sizeBytes:r.sizeBytes,...r.data===void 0?{}:{data:r.data}});return n}function z(e,n={}){let r=n.idPrefix??`turn`,i=n.showThoughts??!0;T=0;let a=[],o=new Set;for(let n of t(e))switch(n.type){case`thought`:i&&n.text&&D(a,`thought`,n.text,r);break;case`text`:n.text&&D(a,`text`,n.text,r);break;case`tool_draft`:j(a,n);break;case`tool`:A(a,n.tool),L(a,n.tool,r,o);break;case`structured_draft`:N(a,n.text,r);break;case`structured`:P(a,n.structured,r);break;case`media`:n.media&&a.push({id:E(r),kind:`media`,mimeType:n.media.mimeType,data:n.media.data});break;case`grounding`:a.push({id:E(r),kind:`grounding`,grounding:n.grounding});break;case`citation`:I(a,n,r);break;case`evidence`:a.push({id:E(r),kind:`evidence`,evidence:n.evidence});break;case`guardrail`:O(a,{id:E(r),kind:`guardrail`,guardrail:n.guardrail});break;case`error`:n.error&&a.push({id:E(r),kind:`error`,message:n.error});break;case`done`:a.push({id:E(r),kind:`turn-done`,stop:n.stop,tokens:n.tokens,interactionId:n.interactionId,compaction:n.compaction!==void 0})}return a}function B(e,t,n={}){return[...R(e,`user`),...z(t,n)]}function V(e){if(!e)return a;let{detect:t,patterns:n}=e;if(!n)return t;let r=Object.fromEntries(Object.entries(n).map(([e,{theorem:t}])=>[e,{theorem:t,matchers:[]}]));return{...t,sources:r}}function H(e,t){if(e.text===void 0)return e;let n=r(e.text,`user`,V(t));return{...e,text:n.text??e.text}}function U(e,t,n){let r=o(e,t);if(!r.ok)return{ok:!1,issues:r.issues};let i=H(t,n);return{ok:!0,draft:i,blocks:R(i)}}function W(e,t){if(t)return e.models[t]}function G(e){return!!(e.allowModelSelect&&Object.keys(e.models).length>=2)}function K(e,t){let n=W(e,t);return n?.allowEffortSelect?Object.keys(n.efforts??{}).length>=2:!1}function q(e,t){let n=W(e,t);if(!n?.efforts)return;let r=n.defaultEffort?.trim();return r&&n.efforts[r]?r:Object.keys(n.efforts)[0]}function fe(e){return G(e)?Object.entries(e.models).map(([e,t])=>({id:e,label:t.apiId})):[]}function pe(e,t){if(!K(e,t))return[];let n=W(e,t);return n?.efforts?Object.entries(n.efforts).map(([e,t])=>({alias:e,level:t})):[]}function me(e){let t=new Set;for(let n of e)if(n.type===`tool`&&n.tool.phase===`complete`)for(let e of s(n.tool.output)??[])t.add(e);return[...t]}function he(t){let n=e(t,e=>e.type===`done`&&e.tools!==void 0);return n?.type===`done`?n.tools:void 0}function J(e){return e?.streaming?.streamThoughts!==!1}function Y(e){return e.defaultModel??Object.keys(e.models)[0]}function ge(e,t,n){let r=t.model!==void 0&&Object.hasOwn(e.models,t.model)&&(n===void 0||t.model!==Y(n))?t.model:Y(e),i=r===void 0?void 0:e.models[r]?.efforts;return{model:r,effort:r===t.model&&t.effort!==void 0&&i!==void 0&&Object.hasOwn(i,t.effort)&&(n===void 0||t.effort!==q(n,r))?t.effort:q(e,r)}}function X(e){if(!e.operationId)throw new n(`request`,i(`session.gate_expired`));return e.operationId}function _e(e,t){return t.selectedModel??Y(e)}function ve(e,t,n){if(!n||!Object.hasOwn(e.models,n))return;let r=e.models[n];if(r.allowEffortSelect)return t.selectedEffort??r.defaultEffort}function Z(e,t){let n=_e(e,t),r=e.allowModelSelect?n:void 0,i=ve(e,t,n);return{...r?{model:r}:{},...i?{effort:i}:{}}}function ye(e,t,n){return{name:n.name,input:n.input,...n.gateKind?{gateKind:n.gateKind}:{},sessionPermissions:n.sessionPermissions??t.sessionPermissions,...t.toolSnapshot?{snapshot:t.toolSnapshot}:{},...t.promotedToolIds.length?{promoted:[...t.promotedToolIds]}:{},...Z(e,t)}}function Q(e){return{...e.conversation?{conversation:e.conversation}:{},...e.turnId?{turnId:e.turnId}:{}}}function be(e,t,n,r={}){let i=(r.walkAway?.calls??[]).map(e=>({callId:e.callId,operationId:X(e)}));return{...Q(r),...Z(e,t),input:n,...i.length?{abandon:i}:{},replay:{sessionPermissions:t.sessionPermissions}}}function xe(e,t,n,r={}){return{...Q(r),gateId:n.gateId,operationId:n.operationId,decision:n.decision,...n.secret===void 0?{}:{secret:n.secret},...n.page===void 0?{}:{page:n.page},replay:ye(e,t,{...n,gateKind:n.gateKind??(t.gatedTool?.callId===n.gateId?t.gatedTool.gateKind:void 0)})}}function $(e,t){return U(e.inputs,t,e.guardrails)}function Se(e,t,n,r=[]){return $(e,{...t.trim()?{text:t}:{},...n.length?{attachments:c(n)}:{},...r.length?{voice:c(r)}:{}})}function Ce(e,t){return z(t,{showThoughts:J(e.outputs)})}export{d as C,f as D,te as E,p as O,ae as S,ne as T,B as _,Se as a,C as b,J as c,q as d,K as f,U as g,G as h,X as i,me as l,fe as m,be as n,$ as o,pe as p,Ce as r,ge as s,xe as t,he as u,z as v,re as w,S as x,y};
1
+ import{Lt as e,Mn as t}from"./tool-schema-BlUbzOu9.js";import{c as n}from"./host-patterns-C9RMP16Q.js";import{A as r,Mn as i,en as a}from"./shaped-data-0GUF7Al3.js";import{F as o,bt as s}from"./reader-CVFKFctz.js";import{r as c}from"./encode-files-DZ4tVtEQ.js";function l(e,t){let r=typeof t==`string`?t.trim():``;if(!r)throw new n(`request`,`A typed credential must be a non-empty string`);if(e===`bearer`)return{type:`bearer`,token:r};if(e===`api_key`)return{type:`api_key`,key:r};throw new n(`request`,`A '${e}' sign-in takes no typed credential; the host's callback saves it`)}function ee(e,t){if(!e)throw new n(`request`,`a typed credential answers only a sign-in gate`);return{slot:e.slot,credential:l(e.authType,t)}}var u=18e5;function te(e,t){let r=t??u;if(!Number.isFinite(r)||r<=0)throw new n(`config`,`${e} gateTtlMs must be a positive number of milliseconds; got ${r}.`);return r}function ne(e,t,n){return t-e>=n}var d=[`approve`,`deny`,`abandon`];function f(e,t=!1){return e.decision===`approve`?{granted:!0,...e.edited?{edited:e.edited}:{},...t?{signIn:t}:{}}:{granted:!1,cause:e.decision===`deny`?`declined`:`abandoned`,...t?{signIn:t}:{}}}function p(e,t,n){return n!==`session_consent`||e.includes(t)?[...e]:[...e,t]}function re(e,t,r){let{callId:i,decision:a,input:o,secret:s,page:c}=e;if((o!==void 0||s!==void 0||c!==void 0)&&a!==`approve`)throw new n(`request`,`only an approval takes edited input, a secret, or a page answer (call ${i})`);if(a!==`approve`)return{resume:f({decision:a},t.auth!==void 0),input:t.arguments,sessionPermissions:[...r]};let l=s===void 0?void 0:ee(t.auth,s);return{resume:{...f(o===void 0?{decision:a}:{decision:a,edited:{from:t.arguments}},t.auth!==void 0),...t.gateKind?{gateKind:t.gateKind}:{}},input:o??t.arguments,sessionPermissions:p(r,t.name,t.permission),...l?{typed:l}:{},...c?{page:c}:{}}}var m={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
2
+ `,r:`\r`,t:` `};function h(e,t){let n=``,r=t+1;for(;r<e.length;){let t=e.charAt(r);if(t===`"`)return{text:n,end:r+1};if(t!==`\\`){n+=t,r++;continue}if(r+1>=e.length)break;let i=e.charAt(r+1);if(i===`u`){let t=e.slice(r+2,r+6);if(t.length<4)break;if(/^[0-9a-fA-F]{4}$/.test(t)){n+=String.fromCharCode(Number.parseInt(t,16)),r+=6;continue}}n+=m[i]??i,r+=2}return{text:n}}function g(e,t){let n=t;for(;/\s/.test(e.charAt(n));)n++;return n}function ie(e,t){if(e.charAt(t)===`"`){let n=h(e,t);return n.end===void 0?void 0:_(e,t,n.end)}let n=0;for(let r=t;r<e.length;r++){let i=e.charAt(r);if(i===`"`){let t=h(e,r).end;if(t===void 0)return;r=t-1}else if(i===`{`||i===`[`)n++;else if(i===`}`||i===`]`){if(n===0)return _(e,t,r);if(n--,n===0)return _(e,t,r+1)}else if(i===`,`&&n===0)return _(e,t,r)}}function _(e,t,n){try{return{value:JSON.parse(e.slice(t,n)),end:n}}catch{return}}function v(e){let t={},n=g(e,0);if(e.charAt(n)!==`{`)return t;for(n++;;){if(n=g(e,n),e.charAt(n)===`,`&&(n=g(e,n+1)),e.charAt(n)!==`"`)return t;let r=h(e,n);if(r.end===void 0||(n=g(e,r.end),e.charAt(n)!==`:`)||(n=g(e,n+1),n>=e.length))return t;let i=ie(e,n);if(!i)return e.charAt(n)===`"`&&(t[r.text]=h(e,n).text),t;t[r.text]=i.value,n=i.end}}function y(e,t){if(t.phase===void 0)return{name:t.name,callId:t.callId,...t.operationId?{operationId:t.operationId}:{},arguments:t.arguments,...t.reasoning?{reasoning:t.reasoning}:{},...t.stepId?{stepId:t.stepId}:{},artifacts:[]};if(e===void 0)throw new n(`bad_response`,`Tool event '${t.phase}' for call '${t.callId}' arrived before the call.`);if(e.callId!==t.callId||e.name!==t.name)throw new n(`bad_response`,i(`error.bad_response`));switch(t.phase){case`running`:{let{endedAt:n,outputDraft:r,...i}=e;return{...i,state:t,startedAt:t.at,...t.edited?{edited:t.edited}:{},...t.activity?{activity:t.activity}:{}}}case`complete`:return{...b(e),state:t,endedAt:t.at,...t.activityPast?{activityPast:t.activityPast}:{}};case`error`:return{...b(e),state:t,endedAt:t.at,...t.activityPast?{activityPast:t.activityPast}:{}};case`cancel`:case`gate`:return{...b(e),state:t,endedAt:t.at};case`draft`:return{...e,outputDraft:(e.outputDraft??``)+t.text};case`artifact`:return{...e,artifacts:[...e.artifacts,t.artifact]};case`dispatch`:case`progress`:case`trace`:case`warning`:return e}}function b(e){let{outputDraft:t,...n}=e;return n}function x(e,t){return{arguments:{},artifacts:[],...e,name:t.name,callId:t.callId,draft:(e?.draft??``)+t.text}}function ae(e){let t=new Map;for(let n of e){if(n.type===`tool_draft`){t.set(n.callId,x(t.get(n.callId),n));continue}if(n.type!==`tool`)continue;let{tool:e}=n,r=e.operationId??e.callId;e.phase===void 0&&t.get(e.callId)?.draft!==void 0&&t.delete(e.callId),t.set(r,y(t.get(r),e))}return[...t.values()]}function S(e){return(e.state?.phase===`gate`?e.state.gate.preparedArguments:void 0)??e.edited?.to??e.arguments}function C(e,t){return e.type!==`tool`||e.tool.callId!==t?!1:e.tool.phase===`complete`||e.tool.phase===`error`}var w={avif:`image/avif`,gif:`image/gif`,heic:`image/heic`,heif:`image/heif`,jpeg:`image/jpeg`,jpg:`image/jpeg`,png:`image/png`,svg:`image/svg+xml`,webp:`image/webp`,mp4:`video/mp4`,webm:`video/webm`,mov:`video/quicktime`,ogv:`video/ogg`,mp3:`audio/mpeg`,m4a:`audio/mp4`,ogg:`audio/ogg`,wav:`audio/wav`};function oe(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0||n===t.length-1?void 0:w[t.slice(n+1).toLowerCase()]}function se(e){let t=e.trim();if(t.length===0)return;let n;try{n=new URL(t)}catch{return}if(n.protocol!==`http:`&&n.protocol!==`https:`)return;let r=oe(n.pathname);if(r)return{url:n.href,mimeType:r}}var ce=/^(.*)\/thumb(\/.+\/([^/]+))\/(\d+)px-\3(?:\.[a-z0-9]+)?$/i;function le(e){let t=new URL(e),n=t.hostname.split(`.`).slice(-2).join(`.`);for(let e of[...t.searchParams.keys()])e.startsWith(`utm_`)&&t.searchParams.delete(e);let r=ce.exec(t.pathname);return{key:`${n}${r?`${r[1]}${r[2]}`:t.pathname}${t.search}`,width:r?Number(r[4]):1/0}}function ue(e){let t=new Map,n=[],r=e=>{if(typeof e==`string`){let r=se(e);if(!r)return;let i=le(r.url),a=t.get(i.key);if(!a){t.set(i.key,{index:n.length,largest:i.width,smallest:i.width}),n.push(r);return}let o=n[a.index];i.width>a.largest?(a.largest=i.width,n[a.index]={...o,url:r.url,previewUrl:o.previewUrl??o.url}):i.width<a.smallest&&(a.smallest=i.width,n[a.index]={...o,previewUrl:r.url})}else if(Array.isArray(e))for(let t of e)r(t);else if(typeof e==`object`&&e)for(let t of Object.values(e))r(t)};return r(e),n}var T=0;function E(e){return e===`user`?`user-${globalThis.crypto.randomUUID()}`:(T+=1,`${e}-${String(T)}`)}function de(e,t){return e?.kind===t}function D(e,t,n,r){let i=e.at(-1);de(i,t)?i.text+=n:e.push({id:E(r),kind:t,text:n})}function O(e,t){let n=e.at(-1),r=n?.kind===`text`||n?.kind===`thought`;e.splice(r?e.length-1:e.length,0,t)}function k(e,t){return e.find(e=>e.kind===`tool`&&e.id===t)}function A(e,t){let n=`tool-${t.operationId??t.callId}`,r=k(e,n),i=y(r?.tool,t);if(r){r.tool=i;return}let a=t.phase===void 0?k(e,`tool-${t.callId}`):void 0;a?.tool.draft===void 0?e.push({id:n,kind:`tool`,tool:i}):(a.id=n,a.tool=i)}function j(e,t){let n=`tool-${t.callId}`,r=k(e,n),i=x(r?.tool,t);r?r.tool=i:e.push({id:n,kind:`tool`,tool:i})}function M(e){return e.findLast(e=>e.kind===`structured`&&e.draft!==void 0)}function N(e,t,n){let r=M(e),i=(r?.draft??``)+t;r?(r.draft=i,r.value=v(i)):e.push({id:E(n),kind:`structured`,value:v(i),draft:i})}function P(e,t,n){let r=M(e);r?(r.value=t,delete r.draft):e.push({id:E(n),kind:`structured`,value:t})}function F(e,t){return e.type===t.type?e.placeId&&t.placeId?e.placeId===t.placeId:e.uri===t.uri:!1}function I(e,t,n){let r=e.find(e=>e.kind===`citation`&&e.callId===t.callId),i=r?[...r.sources]:[];for(let e of t.sources)i.some(t=>F(t,e))||i.push(e);r?r.sources=i:e.push({id:E(n),kind:`citation`,sources:i,...t.callId===void 0?{}:{callId:t.callId}})}function L(e,t,n,r){if(t.phase===`complete`&&t.output!==void 0)for(let i of ue(t.output))r.has(i.url)||(r.add(i.url),e.push({id:E(n),kind:`media`,mimeType:i.mimeType,url:i.url,...i.previewUrl?{previewUrl:i.previewUrl}:{}}))}function R(e,t){return e.messages.flatMap(e=>{if(e.role!==`user`)return[];let n=e.parts??[],r=[e.content??``,...n.map(e=>`text`in e?e.text:``)].join(``).trim();return[...r?[{id:E(t),kind:`user-text`,text:r}]:[],...n.flatMap(e=>`text`in e?[]:[{id:E(t),kind:e.type===`audio`?`user-voice`:`user-attachment`,name:e.mimeType,mimeType:e.mimeType,...`data`in e?{sizeBytes:Math.floor(e.data.length*3/4),data:e.data}:{sizeBytes:0}}])]})}function z(e,t=`user`){let n=[],r=e.text?.trim();r&&n.push({id:E(t),kind:`user-text`,text:r});for(let r of e.attachments??[])n.push({id:E(t),kind:`user-attachment`,name:r.name,mimeType:r.mimeType,sizeBytes:r.sizeBytes,...r.data===void 0?{}:{data:r.data}});for(let r of e.voice??[])n.push({id:E(t),kind:`user-voice`,name:r.name,mimeType:r.mimeType,sizeBytes:r.sizeBytes,...r.data===void 0?{}:{data:r.data}});return n}function B(e,t){switch(e.type){case`media`:return e.media?{id:E(t),kind:`media`,mimeType:e.media.mimeType,data:e.media.data}:void 0;case`grounding`:return{id:E(t),kind:`grounding`,grounding:e.grounding};case`evidence`:return{id:E(t),kind:`evidence`,evidence:e.evidence};case`error`:return e.error?{id:E(t),kind:`error`,message:e.error}:void 0;case`done`:return{id:E(t),kind:`turn-done`,stop:e.stop,tokens:e.tokens,interactionId:e.interactionId,compaction:e.compaction!==void 0};default:return}}function V(e,n={}){let r=n.idPrefix??`turn`,i=n.showThoughts??!0;T=0;let a=[],o=new Set;for(let n of t(e))switch(n.type){case`thought`:i&&n.text&&D(a,`thought`,n.text,r);break;case`text`:n.text&&D(a,`text`,n.text,r);break;case`tool_draft`:j(a,n);break;case`tool`:A(a,n.tool),L(a,n.tool,r,o);break;case`structured_draft`:N(a,n.text,r);break;case`structured`:P(a,n.structured,r);break;case`citation`:I(a,n,r);break;case`guardrail`:O(a,{id:E(r),kind:`guardrail`,guardrail:n.guardrail});break;case`stage`:for(let e of n.injected??[])a.push(...R(e,r));break;default:{let e=B(n,r);e&&a.push(e)}}return a}function H(e,t,n={}){return[...z(e,`user`),...V(t,n)]}function fe(e){if(!e)return a;let{detect:t,patterns:n}=e;if(!n)return t;let r=Object.fromEntries(Object.entries(n).map(([e,{theorem:t}])=>[e,{theorem:t,matchers:[]}]));return{...t,sources:r}}function pe(e,t){if(e.text===void 0)return e;let n=r(e.text,`user`,fe(t));return{...e,text:n.text??e.text}}function U(e,t,n){let r=o(e,t);if(!r.ok)return{ok:!1,issues:r.issues};let i=pe(t,n);return{ok:!0,draft:i,blocks:z(i)}}function W(e,t){if(t)return e.models[t]}function G(e){return!!(e.allowModelSelect&&Object.keys(e.models).length>=2)}function K(e,t){let n=W(e,t);return n?.allowEffortSelect?Object.keys(n.efforts??{}).length>=2:!1}function q(e,t){let n=W(e,t);if(!n?.efforts)return;let r=n.defaultEffort?.trim();return r&&n.efforts[r]?r:Object.keys(n.efforts)[0]}function me(e){return G(e)?Object.entries(e.models).map(([e,t])=>({id:e,label:t.apiId})):[]}function he(e,t){if(!K(e,t))return[];let n=W(e,t);return n?.efforts?Object.entries(n.efforts).map(([e,t])=>({alias:e,level:t})):[]}function ge(e){let t=new Set;for(let n of e)if(n.type===`tool`&&n.tool.phase===`complete`)for(let e of s(n.tool.output)??[])t.add(e);return[...t]}function _e(t){let n=e(t,e=>e.type===`done`&&e.tools!==void 0);return n?.type===`done`?n.tools:void 0}function J(e){return e?.streaming?.streamThoughts!==!1}function Y(e){return e.defaultModel??Object.keys(e.models)[0]}function ve(e,t,n){let r=t.model!==void 0&&Object.hasOwn(e.models,t.model)&&(n===void 0||t.model!==Y(n))?t.model:Y(e),i=r===void 0?void 0:e.models[r]?.efforts;return{model:r,effort:r===t.model&&t.effort!==void 0&&i!==void 0&&Object.hasOwn(i,t.effort)&&(n===void 0||t.effort!==q(n,r))?t.effort:q(e,r)}}function X(e){if(!e.operationId)throw new n(`request`,i(`session.gate_expired`));return e.operationId}function ye(e,t){return t.selectedModel??Y(e)}function be(e,t,n){if(!n||!Object.hasOwn(e.models,n))return;let r=e.models[n];if(r.allowEffortSelect)return t.selectedEffort??r.defaultEffort}function Z(e,t){let n=ye(e,t),r=e.allowModelSelect?n:void 0,i=be(e,t,n);return{...r?{model:r}:{},...i?{effort:i}:{}}}function xe(e,t,n){return{name:n.name,input:n.input,...n.gateKind?{gateKind:n.gateKind}:{},sessionPermissions:n.sessionPermissions??t.sessionPermissions,...t.toolSnapshot?{snapshot:t.toolSnapshot}:{},...t.promotedToolIds.length?{promoted:[...t.promotedToolIds]}:{},...Z(e,t)}}function Q(e){return{...e.conversation?{conversation:e.conversation}:{},...e.turnId?{turnId:e.turnId}:{}}}function Se(e,t,n,r={}){let i=(r.walkAway?.calls??[]).map(e=>({callId:e.callId,operationId:X(e)}));return{...Q(r),...Z(e,t),input:n,...i.length?{abandon:i}:{},replay:{sessionPermissions:t.sessionPermissions}}}function Ce(e,t,n,r={}){return{...Q(r),gateId:n.gateId,operationId:n.operationId,decision:n.decision,...n.secret===void 0?{}:{secret:n.secret},...n.page===void 0?{}:{page:n.page},replay:xe(e,t,{...n,gateKind:n.gateKind??(t.gatedTool?.callId===n.gateId?t.gatedTool.gateKind:void 0)})}}function $(e,t){return U(e.inputs,t,e.guardrails)}function we(e,t,n,r=[]){return $(e,{...t.trim()?{text:t}:{},...n.length?{attachments:c(n)}:{},...r.length?{voice:c(r)}:{}})}function Te(e,t){return V(t,{showThoughts:J(e.outputs)})}export{d as C,f as D,te as E,p as O,ae as S,ne as T,H as _,we as a,C as b,J as c,q as d,K as f,U as g,G as h,X as i,ge as l,me as m,Se as n,$ as o,he as p,Te as r,ve as s,Ce as t,_e as u,V as v,re as w,S as x,y};
@@ -0,0 +1 @@
1
+ import{ur as e}from"./tool-schema-BlUbzOu9.js";var t=e.filter(e=>e!==`builtin`),n=`Tool type must be ${t.join(`, `).replace(/, ([^,]+)$/,`, or $1`)}.`;export{n,t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{t as r}from"./VStack-CkVMcNiK.js";import{n as i}from"./StackItem-CQviqAfM.js";import{N as a,U as o,c as s,l as c}from"./browser-transport-LKSluKnw.js";import{t as l}from"./Icon-ZfFwTt8n.js";import{t as u}from"./IconButton-CG5klqF1.js";import{t as d}from"./Text-BsiAsowd.js";import{n as f,o as p}from"./labels-provider-BqgbdxdT.js";import{n as m}from"./Card-Ghe4ozhC.js";import{t as h}from"./Tooltip-CTEuMRLe.js";import{n as g,t as _}from"./arrive-DvbqpeRS.js";import{d as v}from"./reader-paEmSrWc.js";import{_ as y,b,g as x,y as S}from"./ConsoleFrame-DFm0uALE.js";import{c as C,i as w}from"./trace-patterns-CS99kExN.js";import{t as T}from"./CardWall-CBRLdDZW.js";var E=e(n(),1),D=t(),O=`var(--duration-medium) var(--ease-standard)`,k=12;function A(){let e=m();return(0,E.useMemo)(()=>({percent:new Intl.NumberFormat(e,{style:`percent`,maximumFractionDigits:0}),decimal:new Intl.NumberFormat(e,{maximumFractionDigits:2}),usd:new Intl.NumberFormat(e,{style:`currency`,currency:`USD`,maximumSignificantDigits:2})}),[e])}function j(e){return C(e?`clear`:`shade2`)}function M({value:e,isLead:t}){return(0,D.jsx)(`div`,{style:{height:k,width:`${String(Math.max(e,.01)*100)}%`,borderRadius:4,background:j(t),transition:`width ${O}`}})}function N({title:e,aside:t,detail:n,answer:a}){let o=f(),s=A(),c=Object.entries(a.probabilities).sort(([,e],[,t])=>t-e);return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:a.choice,note:o(`@theorem.decision.confidence`,{percent:s.percent.format(a.confidence)}),children:(0,D.jsx)(r,{gap:2,role:`list`,children:c.map(([e,t])=>(0,D.jsxs)(r,{gap:1,role:`listitem`,"aria-label":o(`@theorem.decision.option`,{label:e,percent:s.percent.format(t)}),children:[(0,D.jsxs)(i,{gap:2,hAlign:`between`,"aria-hidden":!0,children:[(0,D.jsx)(d,{type:`supporting`,color:`secondary`,maxLines:1,children:e}),(0,D.jsx)(d,{type:`supporting`,hasTabularNumbers:!0,children:s.percent.format(t)})]}),(0,D.jsx)(M,{value:t,isLead:e===a.choice})]},e))})})}var P=56;function F(e){let t=e.split(/[:—–]\s/)[0]?.trim()??``;return t&&t.length<=32&&t!==e?t:e}function I({title:e,aside:t,detail:n,answer:i,labels:a}){let o=f(),s=A(),c=a.length,l=Math.min(c-1,Math.max(0,Math.round(i.score)));return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:a[l]===void 0?s.decimal.format(i.score):F(a[l]),note:[o(`@theorem.decision.score_of`,{score:s.decimal.format(i.score),max:s.decimal.format(c-1)}),o(`@theorem.decision.confidence`,{percent:s.percent.format(i.confidence)})].join(` · `),children:(0,D.jsxs)(r,{gap:1,children:[(0,D.jsxs)(`div`,{"aria-hidden":!0,style:{position:`relative`,display:`flex`,alignItems:`flex-end`,gap:4,height:P},children:[a.map((e,t)=>(0,D.jsx)(`div`,{style:{flex:1,height:`${String(Math.max(.04,i.probabilities[String(t)]??0)*100)}%`,borderRadius:4,background:j(t===l),transition:`height ${O}`}},`${String(t)}:${e}`)),(0,D.jsx)(`div`,{style:{position:`absolute`,insetBlock:-4,left:`${String((i.score+.5)/c*100)}%`,width:0,borderInlineStart:`1.5px dashed var(--color-text-secondary)`,transition:`left ${O}`}})]}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:4},children:a.map((e,t)=>(0,D.jsx)(`div`,{style:{flex:1,minWidth:0},title:e,children:(0,D.jsx)(d,{type:`supporting`,color:`secondary`,maxLines:1,children:F(e)})},`${String(t)}:${e}`))}),(0,D.jsx)(`span`,{style:{position:`absolute`,width:1,height:1,overflow:`hidden`,clipPath:`inset(50%)`},children:a.map((e,t)=>o(`@theorem.decision.option`,{label:e,percent:s.percent.format(i.probabilities[String(t)]??0)})).join(`; `)})]})})}function L({title:e,aside:t,detail:n,answer:r}){let i=A();return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:i.decimal.format(r.noul)})}var R=72,z=168;function B(e){let[t,n]=(0,E.useState)(null);return(0,E.useEffect)(()=>{let t=new Image;t.onload=()=>{n({width:t.naturalWidth,height:t.naturalHeight})},t.src=e},[e]),t}function V(e,t){let n=e.style.color;e.style.color=`var(${t})`;let r=getComputedStyle(e).color;return e.style.color=n,r}function H({source:e,box:t,caption:n}){let r=f(),i=S(e),a=B(i),[o,l]=(0,E.useState)(null);if(!a)return null;let u=y(t),d=a.width*(t.right-t.left)/(a.height*(t.bottom-t.top)),p=r(`@theorem.decision.open_box`);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(h,{content:p,children:(0,D.jsx)(c,{label:p,padding:0,onClick:e=>{let n={outline:V(e.currentTarget,`--color-accent`),shade:V(e.currentTarget,`--color-overlay`)};b(i,t,n).then(l)},children:(0,D.jsx)(`div`,{role:`img`,"aria-label":r(`@theorem.decision.box_in`),style:{position:`relative`,overflow:`hidden`,aspectRatio:String(d),height:z,maxWidth:`100%`,borderRadius:4},children:(0,D.jsx)(`img`,{src:i,alt:``,style:{position:`absolute`,width:`${String(u.width)}%`,height:`${String(u.height)}%`,left:`${String(u.left)}%`,top:`${String(u.top)}%`,maxWidth:`none`}})})})}),(0,D.jsx)(s,{isOpen:o!==null,onOpenChange:e=>{e||l(null)},media:{src:o??i,alt:r(`@theorem.decision.box_marked`),caption:n},hasZoom:!0})]})}function U({title:e,aside:t,detail:n,answer:r,field:i,asked:a}){let o=f(),s=a&&x(a.images,a.state,i),c=A(),{top:l,bottom:u,left:d,right:p}=r.box,m=o(`@theorem.decision.box_edges`,{left:c.percent.format(d),top:c.percent.format(l),right:c.percent.format(p),bottom:c.percent.format(u)});return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:m,note:o(`@theorem.decision.confidence`,{percent:c.percent.format(r.confidence)}),children:s?(0,D.jsx)(H,{source:s,box:r.box,caption:`${e}: ${m}`}):(0,D.jsx)(`div`,{"aria-hidden":!0,style:{position:`relative`,height:R,borderRadius:4,border:`1px solid var(--color-border)`},children:(0,D.jsx)(`div`,{style:{position:`absolute`,insetInlineStart:`${String(d*100)}%`,insetBlockStart:`${String(l*100)}%`,width:`${String((p-d)*100)}%`,height:`${String((u-l)*100)}%`,borderRadius:2,background:j(!0),transition:`all ${O}`}})})})}function W({question:e,answer:t,asked:n,onQuestion:r,detail:i}){let a=f(),s=`${e.id} · ${a(`@theorem.decision.type.${e.type}`)}`;if(!t)return null;let c=a(`@theorem.decision.edit_question`,{question:e.id}),d={title:s,detail:i,aside:r?(0,D.jsx)(u,{label:c,tooltip:c,size:`sm`,variant:`ghost`,icon:(0,D.jsx)(l,{icon:o,size:`xsm`,color:`secondary`}),onClick:()=>{r(e.id)}}):void 0};return t.type===`choice`?(0,D.jsx)(N,{...d,answer:t}):t.type===`score`?(0,D.jsx)(I,{...d,answer:t,labels:e.labels}):t.type===`noul`?(0,D.jsx)(L,{...d,answer:t}):(0,D.jsx)(U,{...d,answer:t,field:e.field,asked:n})}function G({model:e,usage:t,elapsedMs:n,isStale:i,tokens:a,children:o}){let s=f(),c=A();return(0,D.jsx)(g,{children:(0,D.jsxs)(r,{gap:3,style:{opacity:i?.5:1,transition:`opacity ${O}`},"aria-busy":i,children:[o,(0,D.jsx)(_,{children:(0,D.jsx)(d,{type:`supporting`,color:`secondary`,hasTabularNumbers:!0,children:p(s,c.usd,{model:e,usage:t,elapsedMs:n,tokens:a})})})]},n??0)})}function K({iface:e,result:t,elapsedMs:n,isStale:r,asked:i,onQuestion:a,questionText:o}){let s=f();return(0,D.jsx)(G,{model:t.model,usage:t.usage,elapsedMs:n,isStale:r,tokens:e=>s(`@theorem.decision.tokens`,{count:e}),children:(0,D.jsx)(T,{minWidth:260,children:e.questions.map(e=>(0,D.jsx)(_,{children:(0,D.jsx)(W,{question:e,answer:t.answers[e.id],asked:i,onQuestion:a,detail:o?.[e.id]})},e.id))})})}var q={status:`idle`,result:null,elapsedMs:null,startedAt:null,failure:null};function J(e,t){for(let n of t??[])e.traces?.push(n)}function Y(e,t,n){let[r,i]=(0,E.useState)(q),o=(0,E.useRef)(null);(0,E.useEffect)(()=>()=>o.current?.abort(),[]);let s=(0,E.useCallback)(()=>{o.current?.abort(),o.current=null,i(e=>e.status===t?{...e,status:e.result?`done`:`idle`,startedAt:null}:e)},[t]),c=(0,E.useCallback)(async(...r)=>{o.current?.abort();let s=new AbortController;o.current=s,i(e=>({status:t,result:e.result,elapsedMs:e.elapsedMs,startedAt:Date.now(),failure:null}));let c=performance.now();try{let t=await n(e,s.signal,...r);if(s.signal.aborted)return;J(e,t.traces),i({status:`done`,result:t.result,elapsedMs:performance.now()-c,startedAt:null,failure:null})}catch(t){if(s.signal.aborted)return;J(e,v(t)),i(e=>({...e,status:`error`,startedAt:null,failure:a(t)}))}finally{o.current===s&&(o.current=null)}},[e,t,n]);return{...r,call:c,cancel:s}}export{A as a,K as i,G as n,M as r,Y as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{t as r}from"./VStack-CkVMcNiK.js";import{n as i}from"./StackItem-CQviqAfM.js";import{N as a,U as o,c as s,l as c}from"./browser-transport-1C-yqvF_.js";import{t as l}from"./Icon-ZfFwTt8n.js";import{t as u}from"./IconButton-CG5klqF1.js";import{t as d}from"./Text-BsiAsowd.js";import{n as f,o as p}from"./labels-provider-BSiD6Lrb.js";import{n as m}from"./Card-Ghe4ozhC.js";import{t as h}from"./Tooltip-CTEuMRLe.js";import{n as g,t as _}from"./arrive-DvbqpeRS.js";import{d as v}from"./reader-CVFKFctz.js";import{_ as y,b,g as x,y as S}from"./ConsoleFrame-DU_VbYY8.js";import{c as C,i as w}from"./trace-patterns-CS99kExN.js";import{t as T}from"./CardWall-CBRLdDZW.js";var E=e(n(),1),D=t(),O=`var(--duration-medium) var(--ease-standard)`,k=12;function A(){let e=m();return(0,E.useMemo)(()=>({percent:new Intl.NumberFormat(e,{style:`percent`,maximumFractionDigits:0}),decimal:new Intl.NumberFormat(e,{maximumFractionDigits:2}),usd:new Intl.NumberFormat(e,{style:`currency`,currency:`USD`,maximumSignificantDigits:2})}),[e])}function j(e){return C(e?`clear`:`shade2`)}function M({value:e,isLead:t}){return(0,D.jsx)(`div`,{style:{height:k,width:`${String(Math.max(e,.01)*100)}%`,borderRadius:4,background:j(t),transition:`width ${O}`}})}function N({title:e,aside:t,detail:n,answer:a}){let o=f(),s=A(),c=Object.entries(a.probabilities).sort(([,e],[,t])=>t-e);return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:a.choice,note:o(`@theorem.decision.confidence`,{percent:s.percent.format(a.confidence)}),children:(0,D.jsx)(r,{gap:2,role:`list`,children:c.map(([e,t])=>(0,D.jsxs)(r,{gap:1,role:`listitem`,"aria-label":o(`@theorem.decision.option`,{label:e,percent:s.percent.format(t)}),children:[(0,D.jsxs)(i,{gap:2,hAlign:`between`,"aria-hidden":!0,children:[(0,D.jsx)(d,{type:`supporting`,color:`secondary`,maxLines:1,children:e}),(0,D.jsx)(d,{type:`supporting`,hasTabularNumbers:!0,children:s.percent.format(t)})]}),(0,D.jsx)(M,{value:t,isLead:e===a.choice})]},e))})})}var P=56;function F(e){let t=e.split(/[:—–]\s/)[0]?.trim()??``;return t&&t.length<=32&&t!==e?t:e}function I({title:e,aside:t,detail:n,answer:i,labels:a}){let o=f(),s=A(),c=a.length,l=Math.min(c-1,Math.max(0,Math.round(i.score)));return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:a[l]===void 0?s.decimal.format(i.score):F(a[l]),note:[o(`@theorem.decision.score_of`,{score:s.decimal.format(i.score),max:s.decimal.format(c-1)}),o(`@theorem.decision.confidence`,{percent:s.percent.format(i.confidence)})].join(` · `),children:(0,D.jsxs)(r,{gap:1,children:[(0,D.jsxs)(`div`,{"aria-hidden":!0,style:{position:`relative`,display:`flex`,alignItems:`flex-end`,gap:4,height:P},children:[a.map((e,t)=>(0,D.jsx)(`div`,{style:{flex:1,height:`${String(Math.max(.04,i.probabilities[String(t)]??0)*100)}%`,borderRadius:4,background:j(t===l),transition:`height ${O}`}},`${String(t)}:${e}`)),(0,D.jsx)(`div`,{style:{position:`absolute`,insetBlock:-4,left:`${String((i.score+.5)/c*100)}%`,width:0,borderInlineStart:`1.5px dashed var(--color-text-secondary)`,transition:`left ${O}`}})]}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:4},children:a.map((e,t)=>(0,D.jsx)(`div`,{style:{flex:1,minWidth:0},title:e,children:(0,D.jsx)(d,{type:`supporting`,color:`secondary`,maxLines:1,children:F(e)})},`${String(t)}:${e}`))}),(0,D.jsx)(`span`,{style:{position:`absolute`,width:1,height:1,overflow:`hidden`,clipPath:`inset(50%)`},children:a.map((e,t)=>o(`@theorem.decision.option`,{label:e,percent:s.percent.format(i.probabilities[String(t)]??0)})).join(`; `)})]})})}function L({title:e,aside:t,detail:n,answer:r}){let i=A();return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:i.decimal.format(r.noul)})}var R=72,z=168;function B(e){let[t,n]=(0,E.useState)(null);return(0,E.useEffect)(()=>{let t=new Image;t.onload=()=>{n({width:t.naturalWidth,height:t.naturalHeight})},t.src=e},[e]),t}function V(e,t){let n=e.style.color;e.style.color=`var(${t})`;let r=getComputedStyle(e).color;return e.style.color=n,r}function H({source:e,box:t,caption:n}){let r=f(),i=S(e),a=B(i),[o,l]=(0,E.useState)(null);if(!a)return null;let u=y(t),d=a.width*(t.right-t.left)/(a.height*(t.bottom-t.top)),p=r(`@theorem.decision.open_box`);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(h,{content:p,children:(0,D.jsx)(c,{label:p,padding:0,onClick:e=>{let n={outline:V(e.currentTarget,`--color-accent`),shade:V(e.currentTarget,`--color-overlay`)};b(i,t,n).then(l)},children:(0,D.jsx)(`div`,{role:`img`,"aria-label":r(`@theorem.decision.box_in`),style:{position:`relative`,overflow:`hidden`,aspectRatio:String(d),height:z,maxWidth:`100%`,borderRadius:4},children:(0,D.jsx)(`img`,{src:i,alt:``,style:{position:`absolute`,width:`${String(u.width)}%`,height:`${String(u.height)}%`,left:`${String(u.left)}%`,top:`${String(u.top)}%`,maxWidth:`none`}})})})}),(0,D.jsx)(s,{isOpen:o!==null,onOpenChange:e=>{e||l(null)},media:{src:o??i,alt:r(`@theorem.decision.box_marked`),caption:n},hasZoom:!0})]})}function U({title:e,aside:t,detail:n,answer:r,field:i,asked:a}){let o=f(),s=a&&x(a.images,a.state,i),c=A(),{top:l,bottom:u,left:d,right:p}=r.box,m=o(`@theorem.decision.box_edges`,{left:c.percent.format(d),top:c.percent.format(l),right:c.percent.format(p),bottom:c.percent.format(u)});return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:m,note:o(`@theorem.decision.confidence`,{percent:c.percent.format(r.confidence)}),children:s?(0,D.jsx)(H,{source:s,box:r.box,caption:`${e}: ${m}`}):(0,D.jsx)(`div`,{"aria-hidden":!0,style:{position:`relative`,height:R,borderRadius:4,border:`1px solid var(--color-border)`},children:(0,D.jsx)(`div`,{style:{position:`absolute`,insetInlineStart:`${String(d*100)}%`,insetBlockStart:`${String(l*100)}%`,width:`${String((p-d)*100)}%`,height:`${String((u-l)*100)}%`,borderRadius:2,background:j(!0),transition:`all ${O}`}})})})}function W({question:e,answer:t,asked:n,onQuestion:r,detail:i}){let a=f(),s=`${e.id} · ${a(`@theorem.decision.type.${e.type}`)}`;if(!t)return null;let c=a(`@theorem.decision.edit_question`,{question:e.id}),d={title:s,detail:i,aside:r?(0,D.jsx)(u,{label:c,tooltip:c,size:`sm`,variant:`ghost`,icon:(0,D.jsx)(l,{icon:o,size:`xsm`,color:`secondary`}),onClick:()=>{r(e.id)}}):void 0};return t.type===`choice`?(0,D.jsx)(N,{...d,answer:t}):t.type===`score`?(0,D.jsx)(I,{...d,answer:t,labels:e.labels}):t.type===`noul`?(0,D.jsx)(L,{...d,answer:t}):(0,D.jsx)(U,{...d,answer:t,field:e.field,asked:n})}function G({model:e,usage:t,elapsedMs:n,isStale:i,tokens:a,children:o}){let s=f(),c=A();return(0,D.jsx)(g,{children:(0,D.jsxs)(r,{gap:3,style:{opacity:i?.5:1,transition:`opacity ${O}`},"aria-busy":i,children:[o,(0,D.jsx)(_,{children:(0,D.jsx)(d,{type:`supporting`,color:`secondary`,hasTabularNumbers:!0,children:p(s,c.usd,{model:e,usage:t,elapsedMs:n,tokens:a})})})]},n??0)})}function K({iface:e,result:t,elapsedMs:n,isStale:r,asked:i,onQuestion:a,questionText:o}){let s=f();return(0,D.jsx)(G,{model:t.model,usage:t.usage,elapsedMs:n,isStale:r,tokens:e=>s(`@theorem.decision.tokens`,{count:e}),children:(0,D.jsx)(T,{minWidth:260,children:e.questions.map(e=>(0,D.jsx)(_,{children:(0,D.jsx)(W,{question:e,answer:t.answers[e.id],asked:i,onQuestion:a,detail:o?.[e.id]})},e.id))})})}var q={status:`idle`,result:null,elapsedMs:null,startedAt:null,failure:null};function J(e,t){for(let n of t??[])e.traces?.push(n)}function Y(e,t,n){let[r,i]=(0,E.useState)(q),o=(0,E.useRef)(null);(0,E.useEffect)(()=>()=>o.current?.abort(),[]);let s=(0,E.useCallback)(()=>{o.current?.abort(),o.current=null,i(e=>e.status===t?{...e,status:e.result?`done`:`idle`,startedAt:null}:e)},[t]),c=(0,E.useCallback)(async(...r)=>{o.current?.abort();let s=new AbortController;o.current=s,i(e=>({status:t,result:e.result,elapsedMs:e.elapsedMs,startedAt:Date.now(),failure:null}));let c=performance.now();try{let t=await n(e,s.signal,...r);if(s.signal.aborted)return;J(e,t.traces),i({status:`done`,result:t.result,elapsedMs:performance.now()-c,startedAt:null,failure:null})}catch(t){if(s.signal.aborted)return;J(e,v(t)),i(e=>({...e,status:`error`,startedAt:null,failure:a(t)}))}finally{o.current===s&&(o.current=null)}},[e,t,n]);return{...r,call:c,cancel:s}}export{A as a,K as i,G as n,M as r,Y as t};
@@ -1 +1 @@
1
- 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{_ as o,g as s,l as c,u as l,v as u}from"./SegmentedControlItem-BLuJOusN.js";import{a as ee,h as d,l as f,n as te,t as p,y as m}from"./padding.stylex-B76907Zf.js";import{t as h}from"./VStack-CkVMcNiK.js";import{n as g,t as _}from"./StackItem-CQviqAfM.js";import{t as v}from"./mergeProps-ptS-gIMz.js";import{t as y}from"./sharedResizeObserver-4U9Xq5Oq.js";import{r as b}from"./useLayerDismissal-BAnTRYTt.js";import{S as x}from"./fieldParts-Cs6Amprh.js";import{x as S}from"./Icon-ZfFwTt8n.js";import"./devWarning-DxuplmRl.js";import{r as C}from"./focusOutline.stylex-BT0kfa4t.js";import{t as w}from"./IconButton-CG5klqF1.js";import{r as ne,t as T}from"./Text-BsiAsowd.js";import{t as E}from"./Card-Ghe4ozhC.js";import{t as D}from"./Tooltip-CTEuMRLe.js";import{t as O}from"./createReactComponent-CZwsv6DD.js";import{t as k}from"./ScrollableArea-C8AVuqnt.js";var A=e(i(),1),j=t(),M={header:{kmuXW:`x2lah0s`,$$css:!0},inner:{kB7OPa:`x9f619`,ks0D6T:`xjl2t3p`,kUOVxO:`xvueqy4`,kZCmMZ:`xaku5ci`,kwRFfy:`x19eyx77`,kLKAdn:`xuqi0w`,kGO01o:`xg476vw`,"--container-padding-inline-start":`xt2a87w`,"--container-padding-inline-end":`xhq06x6`,"--container-padding-block-start":`x186o6qk`,"--container-padding-block-end":`xi9ns85`,$$css:!0},fullBleed:{kZCmMZ:`x1c1uobl`,kwRFfy:`xyri2b`,kLKAdn:`xexx8yu`,kGO01o:`x18d9i69`,"--container-padding-inline-start":`xrhngw9`,"--container-padding-inline-end":`xjsfl84`,"--container-padding-block-start":`x1047aw6`,"--container-padding-block-end":`xax9j7h`,$$css:!0},divider:{kt9PQ7:`xso031l`,kfdmCh:`x1q0q8m5`,kL6WhQ:`xw8gpjh`,$$css:!0}},N={sizing:e=>[{kZKoxP:e==null?e:`x16ye13r`,$$css:!0},{"--x-height":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]};function P({children:e,hasDivider:t,height:i,label:a,padding:o,paddingBlockEnd:c,role:l,xstyle:u,className:m,style:h,ref:g,..._}){let y=(0,A.use)(s),b=t??y?.defaultHasDividers??!1,x=o===0;return(0,j.jsx)(`div`,{ref:g,role:l,"aria-label":a,"data-divider":b||void 0,...v(r(`layout-header`),n(M.header,N.sizing(i??null),b&&M.divider,u),m,h),..._,children:(0,j.jsx)(`div`,{...n(M.inner,x&&M.fullBleed,o!=null&&d[o],o!=null&&ee[o],o!=null&&te[o],o!=null&&p[o],c!=null&&f[c],c!=null&&p[c]),children:e})})}P.displayName=`LayoutHeader`;var F={panel:{kB7OPa:`x9f619`,kmuXW:`x2lah0s`,kVQacm:`x7giv3`,kZCmMZ:`xwjyata`,kwRFfy:`x1peupej`,kLKAdn:`xqty4a`,kGO01o:`xg476vw`,"--container-padding-inline-start":`x408pgh`,"--container-padding-inline-end":`xikqloz`,"--container-padding-block-start":`xjmgx01`,"--container-padding-block-end":`xi9ns85`,$$css:!0},startPanel:{kZCmMZ:`xaku5ci`,$$css:!0},endPanel:{kwRFfy:`x19eyx77`,$$css:!0},noHeader:{kLKAdn:`xuqi0w`,$$css:!0},noFooter:{kGO01o:`x1363qu6`,$$css:!0},fullBleed:{kZCmMZ:`x1c1uobl`,kwRFfy:`xyri2b`,kLKAdn:`xexx8yu`,kGO01o:`x18d9i69`,"--container-padding-inline-start":`xrhngw9`,"--container-padding-inline-end":`xjsfl84`,"--container-padding-block-start":`x1047aw6`,"--container-padding-block-end":`xax9j7h`,$$css:!0},scrollable:{kVQacm:`xysyzu8`,$$css:!0},dividerEnd:{ke9TFa:`x1lun4ml`,k8ry5P:`x18b5jzi`,kBCPoo:`x1gejf6u`,$$css:!0},dividerStart:{k2ei4v:`xpilrb4`,kVhnKS:`x1t7ytsu`,kGJrpR:`x1j92z86`,$$css:!0},collapseStart:{keTefX:`x1wim8z0`,$$css:!0},collapseEnd:{k71WvV:`x1kpg4um`,$$css:!0}},I={sizing:e=>[{kzqmXN:e==null?e:`x5lhr3w`,$$css:!0},{"--x-width":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]};function L({children:e,hasDivider:t=!1,isScrollable:i=!0,label:a,padding:s,role:c,width:l,resizable:f,xstyle:m,className:h,style:g,ref:_,...y}){let b=(0,A.use)(u),{hasHeader:x,hasFooter:S}=(0,A.use)(o),C=f?f._size:l,w=b===`start`,ne=b===`end`,T=s===0,E=!t&&!T&&s==null,D=w?F.dividerEnd:ne?F.dividerStart:null,O=w?F.collapseEnd:ne?F.collapseStart:null;return(0,j.jsx)(`div`,{ref:_,role:c,"aria-label":a,...v(r(`layout-panel`),n(F.panel,I.sizing(C??null),w&&!T&&s==null&&F.startPanel,ne&&!T&&s==null&&F.endPanel,!x&&!T&&s==null&&F.noHeader,!S&&!T&&s==null&&F.noFooter,i&&F.scrollable,T&&F.fullBleed,s!=null&&d[s],s!=null&&ee[s],s!=null&&te[s],s!=null&&p[s],t&&D,E&&O,m),h,g),...y,children:e})}L.displayName=`LayoutPanel`;var R=O(`outline`,`eye-off`,`EyeOff`,[[`path`,{d:`M10.585 10.587a2 2 0 0 0 2.829 2.828`,key:`svg-0`}],[`path`,{d:`M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87`,key:`svg-1`}],[`path`,{d:`M3 3l18 18`,key:`svg-2`}]]),re=O(`outline`,`info-circle`,`InfoCircle`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0`,key:`svg-0`}],[`path`,{d:`M12 9h.01`,key:`svg-1`}],[`path`,{d:`M11 12h1v4h1`,key:`svg-2`}]]),ie=(0,A.createContext)(null);ie.displayName=`CollapsibleGroupContext`;var z=m(null);z.displayName=`CollapsibleGroupPresentationContext`;function B(e){let{isCollapsible:t,value:n}=e,r=(0,A.use)(ie),i=r!=null&&n!=null,a=t===!0?{}:t||null,o=a!=null,[s,c]=(0,A.useState)(()=>i?!0:a?.isOpen===void 0?a?.defaultIsOpen??!0:a.isOpen),l;return l=i&&n!=null?r.isOpen(n):a?.isOpen===void 0?s:a.isOpen,{isEnabled:o,isOpen:l,toggle:()=>{if(i&&n!=null){r.toggle(n);return}let e=!l;a?.isOpen===void 0&&c(e),a?.onOpenChange?.(e)}}}var ae=50,oe=40,V=`astryx-resizable:`;function H(e,t,n,r){let i=Math.min(n,Math.max(t,e));if(r.length>0){let e=r[0],a=Math.abs(i-e);for(let t=1;t<r.length;t++){let n=Math.abs(i-r[t]);n<a&&(e=r[t],a=n)}return Math.min(n,Math.max(t,e))}return i}function se(e){if(typeof window>`u`)return null;try{let t=localStorage.getItem(V+e);if(t==null)return null;let n=JSON.parse(t);if(typeof n==`number`)return Number.isFinite(n)?n===0?{size:null,isCollapsed:!0}:{size:n,isCollapsed:null}:null;if(typeof n==`object`&&n){let{size:e,isCollapsed:t}=n,r=typeof e==`number`&&Number.isFinite(e)&&e>0;if(r||t===!0)return{size:r?e:null,isCollapsed:t===!0}}}catch{}return null}function ce(e,t){if(typeof window<`u`)try{localStorage.setItem(V+e,JSON.stringify(t))}catch{}}var U=1200,le=()=>()=>{},ue=250,de=`Use a non-negative number of pixels, an exact "Npx" string, an exact "N%" string from 0% to 100%, pixel(value), or percent(value, {min: pixel(value)}) / percent(value, {max: pixel(value)}).`,W=/^(\d+(?:\.\d+)?)px$/,fe=/^(\d+(?:\.\d+)?)%$/;function pe(e){let t=W.exec(e);if(t){let e=Number(t[1]);return Number.isFinite(e)?{kind:`px`,value:e}:null}let n=fe.exec(e);if(n){let e=Number(n[1]);return Number.isFinite(e)&&e<=100?{kind:`percent`,value:e}:null}return null}function G(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;return t.type===`pixel`&&typeof t.value==`number`&&Number.isFinite(t.value)&&t.value>=0?t.value:null}function me(e){if(Array.isArray(e))return null;let t=e;if(t.type!==`percent`||typeof t.value!=`number`||!Number.isFinite(t.value)||t.value<0||t.value>100)return null;let n=t.min!==void 0;if(n===(t.max!==void 0))return null;if(n){let e=G(t.min);return e==null?null:{kind:`percent`,value:t.value,min:e}}let r=G(t.max);return r==null?null:{kind:`percent`,value:t.value,max:r}}function he(e){if(typeof e==`number`)return Number.isFinite(e)&&e>=0?{kind:`px`,value:e}:null;if(typeof e==`string`)return pe(e);if(typeof e==`object`&&e){let t=G(e);return t==null?me(e):{kind:`px`,value:t}}return null}function ge(e){return e?.kind===`percent`}function _e(e,t){if(e.kind===`px`)return e.value;if(t==null)return null;let n=Math.round(e.value/100*t);return e.min===void 0?e.max===void 0?n:Math.min(n,e.max):Math.max(n,e.min)}function K(e){if(typeof e==`number`&&!Number.isFinite(e))return String(e);try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function ve(e){if(typeof e!=`object`||!e||Array.isArray(e))return K(e);let t=e;return t.type===`pixel`?`{"type":"pixel","value":${K(t.value)}}`:K(e)}function q(e){if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e;if(t.type===`pixel`)return ve(e);if(t.type===`percent`){let e=[`"type":"percent"`,`"value":${K(t.value)}`];return t.min!==void 0&&e.push(`"min":${ve(t.min)}`),t.max!==void 0&&e.push(`"max":${ve(t.max)}`),`{${e.join(`,`)}}`}}return K(e)}function ye(e,t,n,r,i,a,o){return e===void 0?r:e===1/0&&r===1/0?1/0:t==null?(o.current||(o.current=!0,`${i}${q(e)}${a}${r}`),r):_e(t,n)??r}function be(e,t,n){let r=n?.contentBoxSize?.[0];if(r)return t===`vertical`?r.blockSize:r.inlineSize;let i=typeof window>`u`?null:window.getComputedStyle(e);if(i==null)return null;let a=t===`vertical`?e.clientHeight-parseFloat(i.paddingTop)-parseFloat(i.paddingBottom):e.clientWidth-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight);return Number.isFinite(a)?a:null}function J(e){let{defaultSize:t,minSize:n,maxSize:r,containerRef:i,direction:a=`horizontal`,collapsible:o=!1,collapsedSize:s=oe,snaps:c,autoSaveId:l,defaultIsCollapsed:u,isCollapsed:ee,onSizeChange:d,onCollapseChange:f}=e,te=(0,A.useRef)([]),p=c??te.current,m=n,h=r,g=he(t),_=he(n),v=he(r),x=i!=null,S=l?se(l):null,C=(0,A.useRef)(null),[,w]=(0,A.useState)(0),ne=ge(g),T=ge(_)||ge(v),E=S?.size==null&&ne&&C.current?.isFinal!==!0,D=x&&(T||E),O=!x&&T,k=(0,A.useRef)(null),[,j]=(0,A.useState)(0),M=(0,A.useRef)(null),N=D?k.current:null;b(()=>{if(!D){k.current=null,M.current=null;return}let e=i?.current??null;e!==k.current&&(M.current=null,k.current=e,j(e=>e+1))});let P=(0,A.useCallback)(e=>!D||N==null||N!==i?.current?()=>{}:y(N,t=>{M.current=be(N,a,t),e()}),[N,D,a,i]),F=(0,A.useCallback)(()=>!D||N==null?(M.current=null,null):(M.current??=be(N,a),M.current),[N,D,a]),I=(0,A.useSyncExternalStore)(P,F,()=>null),L=(0,A.useCallback)(e=>x||!O||typeof window>`u`?()=>{}:(window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)),[x,O]),R=(0,A.useSyncExternalStore)(L,()=>typeof window>`u`?U:window.innerWidth,()=>U),re=(0,A.useSyncExternalStore)(le,()=>typeof window>`u`?null:a===`vertical`?window.innerHeight:window.innerWidth,()=>null),ie=D,z=I!=null&&I>0,B=x?z?I:U:R,V=!ie||z,W=(0,A.useRef)(null),[fe,pe]=(0,A.useState)(0),G=W.current??B,me=(0,A.useRef)(!1),_e=(0,A.useRef)(!1),K=(0,A.useRef)(!1),ve=(0,A.useRef)(!1),q=ye(m,_,G,ae,`minSize`,de,me),J=ye(h,v,G,1/0,`maxSize`,de,_e);(C.current==null||!C.current.isFinal)&&(C.current={px:ye(t,g,G,ue,`defaultSize`,de,K),isFinal:V});let xe=C.current.px,[we,Te]=(0,A.useState)(()=>S?.size==null?V?H(xe,q,J,p):null:S.size);x&&!T&&V&&E&&we!=null&&w(e=>e+1),V&&we==null&&Te(H(xe,q,J,p));let[Ee,De]=(0,A.useState)({min:q,max:J});V&&W.current==null&&(Ee.min!==q||Ee.max!==J)&&(De({min:q,max:J}),Te(e=>e==null?null:H(e,q,J,p)));let Y=H(we??xe,q,J,p),[Oe,ke]=(0,A.useState)(()=>S?.isCollapsed??u??!1),Ae=ee!==void 0,X=o&&(Ae?ee:Oe),Z=(0,A.useRef)(Y),Q=(0,A.useRef)(X);Q.current=X;let $=(0,A.useCallback)(e=>{Ae||(Q.current=e,ke(e))},[Ae]);(0,A.useEffect)(()=>{q>J&&!ve.current&&(ve.current=!0,`${q}${J}`)},[q,J]),(0,A.useEffect)(()=>{l&&V&&ce(l,{size:Y,isCollapsed:X})},[Y,X,l,V]);let je=(0,A.useCallback)(()=>{o&&!Q.current&&($(!0),f?.(!0),d?.(0))},[o,$,f,d]),Me=(0,A.useCallback)(()=>{let e=Q.current;$(!1),e&&f?.(!1),d?.(Y)},[$,Y,f,d]),Ne=(0,A.useCallback)(e=>{if(!Number.isFinite(e)||e<0){`${String(e)}`;return}let t=H(e,q,J,p),n=Q.current;Te(t),$(!1),n&&f?.(!1),d?.(t)},[q,J,p,$,f,d]),Pe=(0,A.useCallback)(()=>{W.current=B,Z.current=Q.current?0:Y},[Y,B]),Fe=(0,A.useCallback)(e=>{let t=Z.current+e;if(o&&t<s){Q.current||($(!0),f?.(!0),d?.(0));return}Q.current&&t>=s&&($(!1),f?.(!1));let n=H(t,q,J,p);Te(n),d?.(n)},[o,s,$,q,J,p,d,f]),Ie=(0,A.useCallback)(()=>{W.current!=null&&(W.current=null,pe(e=>e+1))},[]),Le=(0,A.useCallback)(()=>{Ie()},[Ie]),Re=Ie,ze=x?z&&D?I:null:re,Be=J===1/0?ze==null?void 0:Math.max(ze,X?q:Y):J,Ve={_size:X?0:Y,_isCollapsed:X,_onResizeStart:Pe,_onResizeMove:Fe,_onResizeEnd:Le,_onResizeCancel:Re,_minSizePx:q,_maxSizePx:J,_snaps:p,_collapsedSize:s,_collapsible:o,_direction:a,_isResizableProps:!0};return Se.set(Ve,{collapse:je,expand:Me}),Be!=null&&Ce.set(Ve,Be),{size:X?0:Y,isCollapsed:X,collapse:je,expand:Me,resize:Ne,props:Ve}}function xe(e){let{regions:t,autoSaveId:n,containerRef:r,direction:i}=e,a=Object.entries(t),o=a.map(([e,t])=>J({...t,containerRef:r,direction:i,autoSaveId:n?`${n}:${e}`:void 0})),s={};return a.forEach(([e],t)=>{s[e]=o[t]}),s}var Se=new WeakMap,Ce=new WeakMap;function we(e){return Ce.get(e)}function Te(e){return Se.get(e)}function Ee(e){return`regions`in e?xe(e):J(e)}var De=10,Y=50;function Oe(e,t,n){if(e!==`auto`)return e;let r=t?`end`:`start`;return n?r===`start`?`end`:`start`:r}function ke(e){return e===`center`?null:e===`start`?-1:1}function Ae(e){document.body.style.cursor=e?`col-resize`:`row-resize`,document.body.style.userSelect=`none`}function X(){document.body.style.cursor=``,document.body.style.userSelect=``}var Z={handle:{kVAEAm:`x1n2onr6`,kmuXW:`x2lah0s`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kWkggS:`x1m4xfpy`,k1ekBW:`x15406qy`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,$$css:!0},overlay:{kVAEAm:`x10l6tqk`,kY2c9j:`xhtitgo`,kWkggS:`xjbqb8w`,$$css:!0},overlayHorizontal:{kt4wiu:`xtijo5x`,k87sOh:`x13vifvy`,krVfgx:`x1ey2m1c`,kzqmXN:`xkhob8h`,$$css:!0},overlayVertical:{krVfgx:`x1ey2m1c`,kLqNvP:`x1o0tod`,kt4wiu:`xtijo5x`,kZKoxP:`x5kfih4`,$$css:!0},horizontal:{kzqmXN:`x1i1rx1s`,kZKoxP:`x5yr21d`,kkrTdU:`xicojor x16khyan`,$$css:!0},vertical:{kZKoxP:`xjm9jq1`,kzqmXN:`xh8yej3`,kkrTdU:`xyozgr7 x16khyan`,$$css:!0},noDividerHorizontal:{kWkggS:`xjbqb8w`,kzqmXN:`xnalus7`,$$css:!0},noDividerVertical:{kWkggS:`xjbqb8w`,kZKoxP:`xqtp20y`,$$css:!0},handleHover:{kWkggS:`x1m4xfpy`,$$css:!0},handleActive:{kWkggS:`x7njt3n`,$$css:!0},disabled:{kkrTdU:`xt0e3qv`,kfzvcC:`x47corl`,$$css:!0},hitArea:{kVAEAm:`x10l6tqk`,kY2c9j:`x1vjfegm`,kFalU9:`x5ve5x3`,kfSwDN:`x87ps6o`,$$css:!0},hitAreaHorizontal:{kzqmXN:`x12xnipv`,k87sOh:`x13vifvy`,krVfgx:`x1ey2m1c`,kkrTdU:`xicojor x16khyan`,$$css:!0},hitAreaVertical:{kZKoxP:`x6b6gus`,kLqNvP:`x1o0tod`,kt4wiu:`xtijo5x`,kkrTdU:`xyozgr7 x16khyan`,$$css:!0},hitAreaCenteredY:{k87sOh:`xwa60dl`,k3aq6I:`x1cb1t30`,$$css:!0},pill:{kVAEAm:`x10l6tqk`,kY2c9j:`xhtitgo`,kfzvcC:`x47corl`,kaIpWk:`xjspbzw`,kWkggS:`x1m4xfpy`,k1ekBW:`x1wbls7o`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,k87sOh:`xwa60dl`,$$css:!0},pillHorizontal:{kzqmXN:`x1g8rjiy`,kZKoxP:`x18to7ep`,$$css:!0},pillVertical:{kzqmXN:`xgc8j7m`,kZKoxP:`xuoj239`,$$css:!0},pillHidden:{kSiTet:`xg01cxk`,$$css:!0},pillVisible:{kSiTet:`x1hc1fzr`,$$css:!0},pillHover:{kSiTet:`x1hc1fzr`,kWkggS:`x1m4xfpy`,$$css:!0},pillActive:{kSiTet:`x1hc1fzr`,kWkggS:`x7njt3n`,$$css:!0}},Q={kLqNvP:`x1o0tod`,k3aq6I:`x11wx31z x75qhwu`,$$css:!0},$={k87sOh:`x13vifvy`,k3aq6I:`xsqj5wx`,$$css:!0},je={kLqNvP:`x1o0tod`,k3aq6I:`xsqj5wx`,$$css:!0},Me={k87sOh:`x13vifvy`,k3aq6I:`xsqj5wx`,$$css:!0},Ne={hitAreaOffsetX:e=>[Q,{"--x-qthpiu":`translateX(calc(${e} * (3px + ${a[`--spacing-1`]}) - 6.5px))`==null?void 0:`translateX(calc(${e} * (3px + ${a[`--spacing-1`]}) - 6.5px))`,"--x-sj6hyi":`translateX(calc(${e} * (3px + ${a[`--spacing-1`]}) + 6.5px))`==null?void 0:`translateX(calc(${e} * (3px + ${a[`--spacing-1`]}) + 6.5px))`}],hitAreaOffsetY:e=>[$,{"--x-transform":`translateY(calc(${e} * (3px + ${a[`--spacing-1`]}) - 6.5px))`==null?void 0:`translateY(calc(${e} * (3px + ${a[`--spacing-1`]}) - 6.5px))`}],pillOffsetX:e=>[je,{"--x-transform":`translate(calc(${e} * (100% + ${a[`--spacing-1`]})), -50%)`==null?void 0:`translate(calc(${e} * (100% + ${a[`--spacing-1`]})), -50%)`}],pillOffsetY:e=>[Me,{"--x-transform":`translate(-50%, calc(${e} * (100% + ${a[`--spacing-1`]})))`==null?void 0:`translate(-50%, calc(${e} * (100% + ${a[`--spacing-1`]})))`}]};function Pe(e,t,n){let r=[...new Set(e._snaps.map(t=>Math.min(e._maxSizePx,Math.max(e._minSizePx,t))))].sort((e,t)=>e-t),i=e._size,a=t>0?r.filter(e=>e>i):r.filter(e=>e<i).reverse();return a.length===0?i:a[Math.min(n,a.length)-1]}function Fe(e){let t=Te(e);t?e._isCollapsed?t.expand():t.collapse():(e._onResizeStart(),e._onResizeMove(e._isCollapsed?e._minSizePx:-e._size),e._onResizeEnd())}function Ie({direction:e=`horizontal`,position:t=`inline`,isReversed:i=!1,isDisabled:a=!1,hasDivider:o=!1,isAlwaysVisible:s=!0,pillPlacement:c=`auto`,label:l,resizable:u,children:ee,xstyle:d,className:f,ref:te,...p}){let m=S(),h=l??m(`@astryx.resizable.handle.label`),g=(0,A.useRef)(null),_=(0,A.useRef)(null),[y,b]=(0,A.useState)(!1),[w,T]=(0,A.useState)(!1),[E,D]=(0,A.useState)(!1),O=e===`horizontal`,k=t===`overlay`,M=i?-1:1,N=Oe(c,i,u?._isCollapsed??!1),P=ke(N),F=(0,A.useCallback)(()=>{let e=g.current;return e&&getComputedStyle(e).direction===`rtl`?-1:1},[]),I=w||E,L=(0,A.useRef)(!1);(0,A.useEffect)(()=>{let t=u?._direction;t!=null&&t!==e&&!L.current&&(L.current=!0,`${e}${t}`)},[e,u]);let R=(0,A.useCallback)(()=>{_.current=null,b(!1),X()},[]),re=(0,A.useCallback)(e=>{a||!u||_.current||(e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture?.(e.pointerId),_.current={pointerId:e.pointerId,startPos:O?e.clientX:e.clientY,rtl:O?F():1},b(!0),u._onResizeStart(),Ae(O))},[a,u,O,F]),ie=(0,A.useCallback)(e=>{let t=_.current;if(!t||t.pointerId!==e.pointerId||!u)return;let n=O?e.clientX:e.clientY;u._onResizeMove((n-t.startPos)*t.rtl*M)},[u,O,M]),z=(0,A.useCallback)(e=>{_.current?.pointerId===e.pointerId&&(R(),u?._onResizeEnd())},[R,u]),B=(0,A.useCallback)(e=>{_.current?.pointerId===e.pointerId&&(R(),u?._onResizeCancel?.())},[R,u]),ae=(0,A.useCallback)(e=>{if(a||!u)return;let t=e.shiftKey?Y:De,n=O?F():1,r=e=>(e===`ArrowRight`||e===`ArrowDown`?1:e===`ArrowLeft`||e===`ArrowUp`?-1:0)*(O?n:1)*M>0;switch(e.key){case`ArrowRight`:case`ArrowDown`:case`ArrowLeft`:case`ArrowUp`:{if(e.preventDefault(),u._isCollapsed){r(e.key)&&(u._onResizeStart(),u._onResizeMove(Math.max(u._minSizePx+t,u._collapsedSize)),u._onResizeEnd());break}if(u._snaps.length>0){u._onResizeStart(),u._onResizeMove(Pe(u,r(e.key)?1:-1,e.shiftKey?2:1)-u._size),u._onResizeEnd();break}let i=e.key===`ArrowRight`||e.key===`ArrowDown`?1:-1;u._onResizeStart(),u._onResizeMove(i*t*(O?n:1)*M),u._onResizeEnd();break}case`Home`:e.preventDefault(),u._onResizeStart(),u._onResizeMove(u._minSizePx-u._size),u._onResizeEnd();break;case`End`:e.preventDefault(),u._maxSizePx!==1/0&&(u._onResizeStart(),u._onResizeMove(u._maxSizePx-u._size),u._onResizeEnd());break;case`Enter`:e.preventDefault(),u._collapsible&&Fe(u)}},[a,u,O,F,M]),oe=(0,A.useCallback)(()=>{!a&&u&&u._collapsible&&Fe(u)},[a,u]),V=(0,A.useRef)(void 0);V.current=u?._onResizeCancel,(0,A.useEffect)(()=>()=>{_.current&&(_.current=null,X(),V.current?.())},[]);let H=u?._isCollapsed??!1,se=u?H?Math.max(u._size,u._minSizePx):u._size:void 0,ce=u?u._minSizePx:void 0,U=u?we(u)??(u._maxSizePx===1/0?void 0:u._maxSizePx):void 0,le=U!=null&&Number.isFinite(U)?U:void 0,ue=u&&H?m(`@astryx.resizable.collapsed`):void 0;return(0,j.jsxs)(`div`,{ref:ne(te,g),role:`separator`,"aria-orientation":O?`vertical`:`horizontal`,"aria-valuenow":se,"aria-valuemin":ce,"aria-valuemax":le,"aria-valuetext":ue,"aria-label":h,"aria-disabled":a||void 0,tabIndex:a?-1:0,onDoubleClick:oe,onFocus:()=>D(!0),onBlur:()=>D(!1),"data-resizing":y||void 0,...v(r(`resize-handle`),C.focusVisible(Z.handle,k&&Z.overlay,k&&(O?Z.overlayHorizontal:Z.overlayVertical),!k&&(O?Z.horizontal:Z.vertical),!k&&!o&&(O?Z.noDividerHorizontal:Z.noDividerVertical),!k&&o&&I&&!y&&Z.handleHover,!k&&o&&y&&Z.handleActive,a&&Z.disabled,d),f),...p,onKeyDown:e=>{p.onKeyDown?.(e),ae(e)},children:[(0,j.jsx)(`div`,{...n(Z.hitArea,O?Z.hitAreaHorizontal:Z.hitAreaVertical,P==null?O?x.centerInline(`0px`):Z.hitAreaCenteredY:O?Ne.hitAreaOffsetX(P):Ne.hitAreaOffsetY(P),a&&Z.disabled),onPointerDown:re,onPointerMove:ie,onPointerUp:z,onPointerCancel:B,onLostPointerCapture:B,onPointerEnter:()=>T(!0),onPointerLeave:()=>{y||T(!1)}}),ee??(0,j.jsx)(`div`,{...v(r(`resize-handle-pill`),n(Z.pill,O?Z.pillHorizontal:Z.pillVertical,N===`center`?x.centerInline(`-50%`):O?Ne.pillOffsetX(N===`start`?-1:1):Ne.pillOffsetY(N===`start`?-1:1),s?Z.pillVisible:Z.pillHidden,I&&!y&&Z.pillHover,y&&Z.pillActive))})]})}Ie.displayName=`ResizeHandle`;var Le={defaultSize:`33%`,minSize:280,maxSize:`50%`};function Re(e){return e>=Le.minSize*2}function ze(e,t){let n=(0,A.useId)(),[r,i]=(0,A.useState)(t);return{id:n,open:r,toggle:(0,A.useCallback)(()=>i(e=>!e),[]),resizable:Ee({...Le,containerRef:e})}}function Be({children:e,floating:t=!1}){return t?(0,j.jsx)(`div`,{style:{position:`absolute`,insetBlockStart:`var(--spacing-4)`,insetInlineEnd:`var(--spacing-4)`,zIndex:3},children:(0,j.jsx)(g,{hAlign:`end`,gap:1,children:e})}):(0,j.jsx)(P,{hasDivider:!1,children:(0,j.jsx)(g,{hAlign:`end`,gap:1,children:e})})}function Ve({labels:e,icon:t,panelId:n,open:r,onToggle:i}){let a=r?e.hide:e.show;return(0,j.jsx)(w,{label:a,tooltip:a,variant:r?`secondary`:`ghost`,"aria-expanded":r,"aria-controls":n,icon:t,onClick:i})}var He={background:`var(--theorem-pane-background, var(--color-background-card))`,borderRadius:`var(--radius-page)`,overflow:`hidden`};function Ue({padding:e,inset:t=`end`,className:n,children:r}){return(0,j.jsx)(h,{height:`100%`,className:n,paddingInlineStart:t===`end`?void 0:3,paddingInlineEnd:t===`start`?void 0:3,paddingBlockEnd:4,children:(0,j.jsx)(E,{variant:`transparent`,height:`100%`,padding:e,style:He,children:r})})}function We({label:e,padding:t,children:n}){return(0,j.jsx)(k,{className:`theorem-panel-scroll`,label:e,height:`100%`,padding:t,children:n})}function Ge({id:e,labels:t,resizable:n,open:r=!0,padding:i,side:a=`end`,className:o,children:s}){let c=r?(0,j.jsx)(Ie,{direction:`horizontal`,isReversed:a===`end`,hasDivider:!1,isAlwaysVisible:!1,resizable:n.props,label:t.resize}):null,l=(0,j.jsx)(L,{id:e,className:o,label:t.name,role:`complementary`,width:r?n.size:0,hasDivider:!1,padding:0,isScrollable:!1,inert:!r,children:(0,j.jsx)(Ue,{padding:i,inset:a,children:r?s:null})});return a===`start`?(0,j.jsxs)(j.Fragment,{children:[l,c]}):(0,j.jsxs)(j.Fragment,{children:[c,l]})}function Ke(){let[e,t]=(0,A.useState)(0);return{ref:(0,A.useCallback)(e=>{if(!e)return;let n=new ResizeObserver(([e])=>t(e?.contentRect.width??0));return n.observe(e),()=>n.disconnect()},[]),width:e}}function qe({id:e,header:t,children:n}){let{ref:r,width:i}=Ke();return(0,j.jsx)(l,{height:`fill`,style:{position:`relative`},header:t,content:(0,j.jsx)(c,{padding:0,isScrollable:!1,children:(0,j.jsx)(h,{height:`100%`,padding:3,children:(0,j.jsx)(E,{variant:`transparent`,height:`100%`,padding:0,style:He,children:(0,j.jsx)(`div`,{id:e,ref:r,style:{height:`100%`},children:n(Re(i))})})})})})}function Je({isWide:e,label:t,detailLabel:n,lead:r,overview:i,detail:a}){return e?(0,j.jsxs)(g,{height:`100%`,gap:0,children:[(0,j.jsx)(_,{size:`fill`,children:(0,j.jsxs)(We,{label:t,children:[r,i]})}),a?(0,j.jsx)(`div`,{style:{width:`48%`,flexShrink:0,height:`100%`,borderInlineStart:`1px solid var(--color-border)`},children:(0,j.jsx)(We,{label:n,children:a})}):null]}):(0,j.jsxs)(We,{label:t,children:[r,a||i]})}function Ye({title:e,doc:t,children:n}){return(0,j.jsx)(E,{padding:3,variant:`muted`,style:{background:`var(--color-background-surface)`},children:(0,j.jsxs)(h,{gap:2,children:[(0,j.jsx)(D,{content:t??e,children:(0,j.jsx)(T,{type:`supporting`,color:`secondary`,children:e})}),n]})})}function Xe({text:e}){return(0,j.jsx)(`span`,{style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:e})}function Ze({view:e,children:t}){return(0,j.jsxs)(j.Fragment,{children:[e,(0,j.jsx)(`div`,{style:{display:e?`none`:`contents`},children:t})]})}export{P as C,L as S,B as _,We as a,re as b,qe as c,Ve as d,Re as f,Ee as g,Ie as h,Ue as i,Ge as l,Ke as m,Je as n,Xe as o,ze as p,Ye as r,He as s,Ze as t,Be as u,ie as v,R as x,z as y};
1
+ 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{_ as o,g as s,l as c,u as l,v as u}from"./SegmentedControlItem-BLuJOusN.js";import{a as ee,h as d,l as f,n as te,t as p,y as m}from"./padding.stylex-B76907Zf.js";import{t as h}from"./VStack-CkVMcNiK.js";import{n as g,t as _}from"./StackItem-CQviqAfM.js";import{t as v}from"./mergeProps-ptS-gIMz.js";import{t as y}from"./sharedResizeObserver-4U9Xq5Oq.js";import{r as b}from"./useLayerDismissal-BAnTRYTt.js";import{S as x}from"./fieldParts-Cs6Amprh.js";import{x as S}from"./Icon-ZfFwTt8n.js";import"./devWarning-DxuplmRl.js";import{r as C}from"./focusOutline.stylex-BT0kfa4t.js";import{t as w}from"./IconButton-CG5klqF1.js";import{r as ne,t as T}from"./Text-BsiAsowd.js";import{t as E}from"./Card-Ghe4ozhC.js";import{t as D}from"./Tooltip-CTEuMRLe.js";import{t as O}from"./createReactComponent-CZwsv6DD.js";import{t as k}from"./ScrollableArea-C8AVuqnt.js";var A=e(i(),1),j=t(),M={header:{kmuXW:`x2lah0s`,$$css:!0},inner:{kB7OPa:`x9f619`,ks0D6T:`xjl2t3p`,kUOVxO:`xvueqy4`,kZCmMZ:`xaku5ci`,kwRFfy:`x19eyx77`,kLKAdn:`xuqi0w`,kGO01o:`xg476vw`,"--container-padding-inline-start":`xt2a87w`,"--container-padding-inline-end":`xhq06x6`,"--container-padding-block-start":`x186o6qk`,"--container-padding-block-end":`xi9ns85`,$$css:!0},fullBleed:{kZCmMZ:`x1c1uobl`,kwRFfy:`xyri2b`,kLKAdn:`xexx8yu`,kGO01o:`x18d9i69`,"--container-padding-inline-start":`xrhngw9`,"--container-padding-inline-end":`xjsfl84`,"--container-padding-block-start":`x1047aw6`,"--container-padding-block-end":`xax9j7h`,$$css:!0},divider:{kt9PQ7:`xso031l`,kfdmCh:`x1q0q8m5`,kL6WhQ:`xw8gpjh`,$$css:!0}},N={sizing:e=>[{kZKoxP:e==null?e:`x16ye13r`,$$css:!0},{"--x-height":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]};function P({children:e,hasDivider:t,height:i,label:a,padding:o,paddingBlockEnd:c,role:l,xstyle:u,className:m,style:h,ref:g,..._}){let y=(0,A.use)(s),b=t??y?.defaultHasDividers??!1,x=o===0;return(0,j.jsx)(`div`,{ref:g,role:l,"aria-label":a,"data-divider":b||void 0,...v(r(`layout-header`),n(M.header,N.sizing(i??null),b&&M.divider,u),m,h),..._,children:(0,j.jsx)(`div`,{...n(M.inner,x&&M.fullBleed,o!=null&&d[o],o!=null&&ee[o],o!=null&&te[o],o!=null&&p[o],c!=null&&f[c],c!=null&&p[c]),children:e})})}P.displayName=`LayoutHeader`;var F={panel:{kB7OPa:`x9f619`,kmuXW:`x2lah0s`,kVQacm:`x7giv3`,kZCmMZ:`xwjyata`,kwRFfy:`x1peupej`,kLKAdn:`xqty4a`,kGO01o:`xg476vw`,"--container-padding-inline-start":`x408pgh`,"--container-padding-inline-end":`xikqloz`,"--container-padding-block-start":`xjmgx01`,"--container-padding-block-end":`xi9ns85`,$$css:!0},startPanel:{kZCmMZ:`xaku5ci`,$$css:!0},endPanel:{kwRFfy:`x19eyx77`,$$css:!0},noHeader:{kLKAdn:`xuqi0w`,$$css:!0},noFooter:{kGO01o:`x1363qu6`,$$css:!0},fullBleed:{kZCmMZ:`x1c1uobl`,kwRFfy:`xyri2b`,kLKAdn:`xexx8yu`,kGO01o:`x18d9i69`,"--container-padding-inline-start":`xrhngw9`,"--container-padding-inline-end":`xjsfl84`,"--container-padding-block-start":`x1047aw6`,"--container-padding-block-end":`xax9j7h`,$$css:!0},scrollable:{kVQacm:`xysyzu8`,$$css:!0},dividerEnd:{ke9TFa:`x1lun4ml`,k8ry5P:`x18b5jzi`,kBCPoo:`x1gejf6u`,$$css:!0},dividerStart:{k2ei4v:`xpilrb4`,kVhnKS:`x1t7ytsu`,kGJrpR:`x1j92z86`,$$css:!0},collapseStart:{keTefX:`x1wim8z0`,$$css:!0},collapseEnd:{k71WvV:`x1kpg4um`,$$css:!0}},I={sizing:e=>[{kzqmXN:e==null?e:`x5lhr3w`,$$css:!0},{"--x-width":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]};function L({children:e,hasDivider:t=!1,isScrollable:i=!0,label:a,padding:s,role:c,width:l,resizable:f,xstyle:m,className:h,style:g,ref:_,...y}){let b=(0,A.use)(u),{hasHeader:x,hasFooter:S}=(0,A.use)(o),C=f?f._size:l,w=b===`start`,ne=b===`end`,T=s===0,E=!t&&!T&&s==null,D=w?F.dividerEnd:ne?F.dividerStart:null,O=w?F.collapseEnd:ne?F.collapseStart:null;return(0,j.jsx)(`div`,{ref:_,role:c,"aria-label":a,...v(r(`layout-panel`),n(F.panel,I.sizing(C??null),w&&!T&&s==null&&F.startPanel,ne&&!T&&s==null&&F.endPanel,!x&&!T&&s==null&&F.noHeader,!S&&!T&&s==null&&F.noFooter,i&&F.scrollable,T&&F.fullBleed,s!=null&&d[s],s!=null&&ee[s],s!=null&&te[s],s!=null&&p[s],t&&D,E&&O,m),h,g),...y,children:e})}L.displayName=`LayoutPanel`;var R=O(`outline`,`eye-off`,`EyeOff`,[[`path`,{d:`M10.585 10.587a2 2 0 0 0 2.829 2.828`,key:`svg-0`}],[`path`,{d:`M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87`,key:`svg-1`}],[`path`,{d:`M3 3l18 18`,key:`svg-2`}]]),re=O(`outline`,`info-circle`,`InfoCircle`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0`,key:`svg-0`}],[`path`,{d:`M12 9h.01`,key:`svg-1`}],[`path`,{d:`M11 12h1v4h1`,key:`svg-2`}]]),ie=(0,A.createContext)(null);ie.displayName=`CollapsibleGroupContext`;var z=m(null);z.displayName=`CollapsibleGroupPresentationContext`;function B(e){let{isCollapsible:t,value:n}=e,r=(0,A.use)(ie),i=r!=null&&n!=null,a=t===!0?{}:t||null,o=a!=null,[s,c]=(0,A.useState)(()=>i?!0:a?.isOpen===void 0?a?.defaultIsOpen??!0:a.isOpen),l;return l=i&&n!=null?r.isOpen(n):a?.isOpen===void 0?s:a.isOpen,{isEnabled:o,isOpen:l,toggle:()=>{if(i&&n!=null){r.toggle(n);return}let e=!l;a?.isOpen===void 0&&c(e),a?.onOpenChange?.(e)}}}var ae=50,oe=40,V=`astryx-resizable:`;function H(e,t,n,r){let i=Math.min(n,Math.max(t,e));if(r.length>0){let e=r[0],a=Math.abs(i-e);for(let t=1;t<r.length;t++){let n=Math.abs(i-r[t]);n<a&&(e=r[t],a=n)}return Math.min(n,Math.max(t,e))}return i}function se(e){if(typeof window>`u`)return null;try{let t=localStorage.getItem(V+e);if(t==null)return null;let n=JSON.parse(t);if(typeof n==`number`)return Number.isFinite(n)?n===0?{size:null,isCollapsed:!0}:{size:n,isCollapsed:null}:null;if(typeof n==`object`&&n){let{size:e,isCollapsed:t}=n,r=typeof e==`number`&&Number.isFinite(e)&&e>0;if(r||t===!0)return{size:r?e:null,isCollapsed:t===!0}}}catch{}return null}function ce(e,t){if(typeof window<`u`)try{localStorage.setItem(V+e,JSON.stringify(t))}catch{}}var U=1200,le=()=>()=>{},ue=250,de=`Use a non-negative number of pixels, an exact "Npx" string, an exact "N%" string from 0% to 100%, pixel(value), or percent(value, {min: pixel(value)}) / percent(value, {max: pixel(value)}).`,W=/^(\d+(?:\.\d+)?)px$/,fe=/^(\d+(?:\.\d+)?)%$/;function pe(e){let t=W.exec(e);if(t){let e=Number(t[1]);return Number.isFinite(e)?{kind:`px`,value:e}:null}let n=fe.exec(e);if(n){let e=Number(n[1]);return Number.isFinite(e)&&e<=100?{kind:`percent`,value:e}:null}return null}function G(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;return t.type===`pixel`&&typeof t.value==`number`&&Number.isFinite(t.value)&&t.value>=0?t.value:null}function me(e){if(Array.isArray(e))return null;let t=e;if(t.type!==`percent`||typeof t.value!=`number`||!Number.isFinite(t.value)||t.value<0||t.value>100)return null;let n=t.min!==void 0;if(n===(t.max!==void 0))return null;if(n){let e=G(t.min);return e==null?null:{kind:`percent`,value:t.value,min:e}}let r=G(t.max);return r==null?null:{kind:`percent`,value:t.value,max:r}}function he(e){if(typeof e==`number`)return Number.isFinite(e)&&e>=0?{kind:`px`,value:e}:null;if(typeof e==`string`)return pe(e);if(typeof e==`object`&&e){let t=G(e);return t==null?me(e):{kind:`px`,value:t}}return null}function ge(e){return e?.kind===`percent`}function _e(e,t){if(e.kind===`px`)return e.value;if(t==null)return null;let n=Math.round(e.value/100*t);return e.min===void 0?e.max===void 0?n:Math.min(n,e.max):Math.max(n,e.min)}function K(e){if(typeof e==`number`&&!Number.isFinite(e))return String(e);try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function ve(e){if(typeof e!=`object`||!e||Array.isArray(e))return K(e);let t=e;return t.type===`pixel`?`{"type":"pixel","value":${K(t.value)}}`:K(e)}function q(e){if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e;if(t.type===`pixel`)return ve(e);if(t.type===`percent`){let e=[`"type":"percent"`,`"value":${K(t.value)}`];return t.min!==void 0&&e.push(`"min":${ve(t.min)}`),t.max!==void 0&&e.push(`"max":${ve(t.max)}`),`{${e.join(`,`)}}`}}return K(e)}function ye(e,t,n,r,i,a,o){return e===void 0?r:e===1/0&&r===1/0?1/0:t==null?(o.current||(o.current=!0,`${i}${q(e)}${a}${r}`),r):_e(t,n)??r}function be(e,t,n){let r=n?.contentBoxSize?.[0];if(r)return t===`vertical`?r.blockSize:r.inlineSize;let i=typeof window>`u`?null:window.getComputedStyle(e);if(i==null)return null;let a=t===`vertical`?e.clientHeight-parseFloat(i.paddingTop)-parseFloat(i.paddingBottom):e.clientWidth-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight);return Number.isFinite(a)?a:null}function J(e){let{defaultSize:t,minSize:n,maxSize:r,containerRef:i,direction:a=`horizontal`,collapsible:o=!1,collapsedSize:s=oe,snaps:c,autoSaveId:l,defaultIsCollapsed:u,isCollapsed:ee,onSizeChange:d,onCollapseChange:f}=e,te=(0,A.useRef)([]),p=c??te.current,m=n,h=r,g=he(t),_=he(n),v=he(r),x=i!=null,S=l?se(l):null,C=(0,A.useRef)(null),[,w]=(0,A.useState)(0),ne=ge(g),T=ge(_)||ge(v),E=S?.size==null&&ne&&C.current?.isFinal!==!0,D=x&&(T||E),O=!x&&T,k=(0,A.useRef)(null),[,j]=(0,A.useState)(0),M=(0,A.useRef)(null),N=D?k.current:null;b(()=>{if(!D){k.current=null,M.current=null;return}let e=i?.current??null;e!==k.current&&(M.current=null,k.current=e,j(e=>e+1))});let P=(0,A.useCallback)(e=>!D||N==null||N!==i?.current?()=>{}:y(N,t=>{M.current=be(N,a,t),e()}),[N,D,a,i]),F=(0,A.useCallback)(()=>!D||N==null?(M.current=null,null):(M.current??=be(N,a),M.current),[N,D,a]),I=(0,A.useSyncExternalStore)(P,F,()=>null),L=(0,A.useCallback)(e=>x||!O||typeof window>`u`?()=>{}:(window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)),[x,O]),R=(0,A.useSyncExternalStore)(L,()=>typeof window>`u`?U:window.innerWidth,()=>U),re=(0,A.useSyncExternalStore)(le,()=>typeof window>`u`?null:a===`vertical`?window.innerHeight:window.innerWidth,()=>null),ie=D,z=I!=null&&I>0,B=x?z?I:U:R,V=!ie||z,W=(0,A.useRef)(null),[fe,pe]=(0,A.useState)(0),G=W.current??B,me=(0,A.useRef)(!1),_e=(0,A.useRef)(!1),K=(0,A.useRef)(!1),ve=(0,A.useRef)(!1),q=ye(m,_,G,ae,`minSize`,de,me),J=ye(h,v,G,1/0,`maxSize`,de,_e);(C.current==null||!C.current.isFinal)&&(C.current={px:ye(t,g,G,ue,`defaultSize`,de,K),isFinal:V});let xe=C.current.px,[we,Te]=(0,A.useState)(()=>S?.size==null?V?H(xe,q,J,p):null:S.size);x&&!T&&V&&E&&we!=null&&w(e=>e+1),V&&we==null&&Te(H(xe,q,J,p));let[Ee,De]=(0,A.useState)({min:q,max:J});V&&W.current==null&&(Ee.min!==q||Ee.max!==J)&&(De({min:q,max:J}),Te(e=>e==null?null:H(e,q,J,p)));let Y=H(we??xe,q,J,p),[Oe,ke]=(0,A.useState)(()=>S?.isCollapsed??u??!1),Ae=ee!==void 0,X=o&&(Ae?ee:Oe),Z=(0,A.useRef)(Y),Q=(0,A.useRef)(X);Q.current=X;let $=(0,A.useCallback)(e=>{Ae||(Q.current=e,ke(e))},[Ae]);(0,A.useEffect)(()=>{q>J&&!ve.current&&(ve.current=!0,`${q}${J}`)},[q,J]),(0,A.useEffect)(()=>{l&&V&&ce(l,{size:Y,isCollapsed:X})},[Y,X,l,V]);let je=(0,A.useCallback)(()=>{o&&!Q.current&&($(!0),f?.(!0),d?.(0))},[o,$,f,d]),Me=(0,A.useCallback)(()=>{let e=Q.current;$(!1),e&&f?.(!1),d?.(Y)},[$,Y,f,d]),Ne=(0,A.useCallback)(e=>{if(!Number.isFinite(e)||e<0){`${String(e)}`;return}let t=H(e,q,J,p),n=Q.current;Te(t),$(!1),n&&f?.(!1),d?.(t)},[q,J,p,$,f,d]),Pe=(0,A.useCallback)(()=>{W.current=B,Z.current=Q.current?0:Y},[Y,B]),Fe=(0,A.useCallback)(e=>{let t=Z.current+e;if(o&&t<s){Q.current||($(!0),f?.(!0),d?.(0));return}Q.current&&t>=s&&($(!1),f?.(!1));let n=H(t,q,J,p);Te(n),d?.(n)},[o,s,$,q,J,p,d,f]),Ie=(0,A.useCallback)(()=>{W.current!=null&&(W.current=null,pe(e=>e+1))},[]),Le=(0,A.useCallback)(()=>{Ie()},[Ie]),Re=Ie,ze=x?z&&D?I:null:re,Be=J===1/0?ze==null?void 0:Math.max(ze,X?q:Y):J,Ve={_size:X?0:Y,_isCollapsed:X,_onResizeStart:Pe,_onResizeMove:Fe,_onResizeEnd:Le,_onResizeCancel:Re,_minSizePx:q,_maxSizePx:J,_snaps:p,_collapsedSize:s,_collapsible:o,_direction:a,_isResizableProps:!0};return Se.set(Ve,{collapse:je,expand:Me}),Be!=null&&Ce.set(Ve,Be),{size:X?0:Y,isCollapsed:X,collapse:je,expand:Me,resize:Ne,props:Ve}}function xe(e){let{regions:t,autoSaveId:n,containerRef:r,direction:i}=e,a=Object.entries(t),o=a.map(([e,t])=>J({...t,containerRef:r,direction:i,autoSaveId:n?`${n}:${e}`:void 0})),s={};return a.forEach(([e],t)=>{s[e]=o[t]}),s}var Se=new WeakMap,Ce=new WeakMap;function we(e){return Ce.get(e)}function Te(e){return Se.get(e)}function Ee(e){return`regions`in e?xe(e):J(e)}var De=10,Y=50;function Oe(e,t,n){if(e!==`auto`)return e;let r=t?`end`:`start`;return n?r===`start`?`end`:`start`:r}function ke(e){return e===`center`?null:e===`start`?-1:1}function Ae(e){document.body.style.cursor=e?`col-resize`:`row-resize`,document.body.style.userSelect=`none`}function X(){document.body.style.cursor=``,document.body.style.userSelect=``}var Z={handle:{kVAEAm:`x1n2onr6`,kmuXW:`x2lah0s`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kWkggS:`x1m4xfpy`,k1ekBW:`x15406qy`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,$$css:!0},overlay:{kVAEAm:`x10l6tqk`,kY2c9j:`xhtitgo`,kWkggS:`xjbqb8w`,$$css:!0},overlayHorizontal:{kt4wiu:`xtijo5x`,k87sOh:`x13vifvy`,krVfgx:`x1ey2m1c`,kzqmXN:`xkhob8h`,$$css:!0},overlayVertical:{krVfgx:`x1ey2m1c`,kLqNvP:`x1o0tod`,kt4wiu:`xtijo5x`,kZKoxP:`x5kfih4`,$$css:!0},horizontal:{kzqmXN:`x1i1rx1s`,kZKoxP:`x5yr21d`,kkrTdU:`xicojor x16khyan`,$$css:!0},vertical:{kZKoxP:`xjm9jq1`,kzqmXN:`xh8yej3`,kkrTdU:`xyozgr7 x16khyan`,$$css:!0},noDividerHorizontal:{kWkggS:`xjbqb8w`,kzqmXN:`xnalus7`,$$css:!0},noDividerVertical:{kWkggS:`xjbqb8w`,kZKoxP:`xqtp20y`,$$css:!0},handleHover:{kWkggS:`x1m4xfpy`,$$css:!0},handleActive:{kWkggS:`x7njt3n`,$$css:!0},disabled:{kkrTdU:`xt0e3qv`,kfzvcC:`x47corl`,$$css:!0},hitArea:{kVAEAm:`x10l6tqk`,kY2c9j:`x1vjfegm`,kFalU9:`x5ve5x3`,kfSwDN:`x87ps6o`,$$css:!0},hitAreaHorizontal:{kzqmXN:`x12xnipv`,k87sOh:`x13vifvy`,krVfgx:`x1ey2m1c`,kkrTdU:`xicojor x16khyan`,$$css:!0},hitAreaVertical:{kZKoxP:`x6b6gus`,kLqNvP:`x1o0tod`,kt4wiu:`xtijo5x`,kkrTdU:`xyozgr7 x16khyan`,$$css:!0},hitAreaCenteredY:{k87sOh:`xwa60dl`,k3aq6I:`x1cb1t30`,$$css:!0},pill:{kVAEAm:`x10l6tqk`,kY2c9j:`xhtitgo`,kfzvcC:`x47corl`,kaIpWk:`xjspbzw`,kWkggS:`x1m4xfpy`,k1ekBW:`x1wbls7o`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,k87sOh:`xwa60dl`,$$css:!0},pillHorizontal:{kzqmXN:`x1g8rjiy`,kZKoxP:`x18to7ep`,$$css:!0},pillVertical:{kzqmXN:`xgc8j7m`,kZKoxP:`xuoj239`,$$css:!0},pillHidden:{kSiTet:`xg01cxk`,$$css:!0},pillVisible:{kSiTet:`x1hc1fzr`,$$css:!0},pillHover:{kSiTet:`x1hc1fzr`,kWkggS:`x1m4xfpy`,$$css:!0},pillActive:{kSiTet:`x1hc1fzr`,kWkggS:`x7njt3n`,$$css:!0}},Q={kLqNvP:`x1o0tod`,k3aq6I:`x11wx31z x75qhwu`,$$css:!0},$={k87sOh:`x13vifvy`,k3aq6I:`xsqj5wx`,$$css:!0},je={kLqNvP:`x1o0tod`,k3aq6I:`xsqj5wx`,$$css:!0},Me={k87sOh:`x13vifvy`,k3aq6I:`xsqj5wx`,$$css:!0},Ne={hitAreaOffsetX:e=>[Q,{"--x-qthpiu":`translateX(calc(${e} * (3px + ${a[`--spacing-1`]}) - 6.5px))`==null?void 0:`translateX(calc(${e} * (3px + ${a[`--spacing-1`]}) - 6.5px))`,"--x-sj6hyi":`translateX(calc(${e} * (3px + ${a[`--spacing-1`]}) + 6.5px))`==null?void 0:`translateX(calc(${e} * (3px + ${a[`--spacing-1`]}) + 6.5px))`}],hitAreaOffsetY:e=>[$,{"--x-transform":`translateY(calc(${e} * (3px + ${a[`--spacing-1`]}) - 6.5px))`==null?void 0:`translateY(calc(${e} * (3px + ${a[`--spacing-1`]}) - 6.5px))`}],pillOffsetX:e=>[je,{"--x-transform":`translate(calc(${e} * (100% + ${a[`--spacing-1`]})), -50%)`==null?void 0:`translate(calc(${e} * (100% + ${a[`--spacing-1`]})), -50%)`}],pillOffsetY:e=>[Me,{"--x-transform":`translate(-50%, calc(${e} * (100% + ${a[`--spacing-1`]})))`==null?void 0:`translate(-50%, calc(${e} * (100% + ${a[`--spacing-1`]})))`}]};function Pe(e,t,n){let r=[...new Set(e._snaps.map(t=>Math.min(e._maxSizePx,Math.max(e._minSizePx,t))))].sort((e,t)=>e-t),i=e._size,a=t>0?r.filter(e=>e>i):r.filter(e=>e<i).reverse();return a.length===0?i:a[Math.min(n,a.length)-1]}function Fe(e){let t=Te(e);t?e._isCollapsed?t.expand():t.collapse():(e._onResizeStart(),e._onResizeMove(e._isCollapsed?e._minSizePx:-e._size),e._onResizeEnd())}function Ie({direction:e=`horizontal`,position:t=`inline`,isReversed:i=!1,isDisabled:a=!1,hasDivider:o=!1,isAlwaysVisible:s=!0,pillPlacement:c=`auto`,label:l,resizable:u,children:ee,xstyle:d,className:f,ref:te,...p}){let m=S(),h=l??m(`@astryx.resizable.handle.label`),g=(0,A.useRef)(null),_=(0,A.useRef)(null),[y,b]=(0,A.useState)(!1),[w,T]=(0,A.useState)(!1),[E,D]=(0,A.useState)(!1),O=e===`horizontal`,k=t===`overlay`,M=i?-1:1,N=Oe(c,i,u?._isCollapsed??!1),P=ke(N),F=(0,A.useCallback)(()=>{let e=g.current;return e&&getComputedStyle(e).direction===`rtl`?-1:1},[]),I=w||E,L=(0,A.useRef)(!1);(0,A.useEffect)(()=>{let t=u?._direction;t!=null&&t!==e&&!L.current&&(L.current=!0,`${e}${t}`)},[e,u]);let R=(0,A.useCallback)(()=>{_.current=null,b(!1),X()},[]),re=(0,A.useCallback)(e=>{a||!u||_.current||(e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture?.(e.pointerId),_.current={pointerId:e.pointerId,startPos:O?e.clientX:e.clientY,rtl:O?F():1},b(!0),u._onResizeStart(),Ae(O))},[a,u,O,F]),ie=(0,A.useCallback)(e=>{let t=_.current;if(!t||t.pointerId!==e.pointerId||!u)return;let n=O?e.clientX:e.clientY;u._onResizeMove((n-t.startPos)*t.rtl*M)},[u,O,M]),z=(0,A.useCallback)(e=>{_.current?.pointerId===e.pointerId&&(R(),u?._onResizeEnd())},[R,u]),B=(0,A.useCallback)(e=>{_.current?.pointerId===e.pointerId&&(R(),u?._onResizeCancel?.())},[R,u]),ae=(0,A.useCallback)(e=>{if(a||!u)return;let t=e.shiftKey?Y:De,n=O?F():1,r=e=>(e===`ArrowRight`||e===`ArrowDown`?1:e===`ArrowLeft`||e===`ArrowUp`?-1:0)*(O?n:1)*M>0;switch(e.key){case`ArrowRight`:case`ArrowDown`:case`ArrowLeft`:case`ArrowUp`:{if(e.preventDefault(),u._isCollapsed){r(e.key)&&(u._onResizeStart(),u._onResizeMove(Math.max(u._minSizePx+t,u._collapsedSize)),u._onResizeEnd());break}if(u._snaps.length>0){u._onResizeStart(),u._onResizeMove(Pe(u,r(e.key)?1:-1,e.shiftKey?2:1)-u._size),u._onResizeEnd();break}let i=e.key===`ArrowRight`||e.key===`ArrowDown`?1:-1;u._onResizeStart(),u._onResizeMove(i*t*(O?n:1)*M),u._onResizeEnd();break}case`Home`:e.preventDefault(),u._onResizeStart(),u._onResizeMove(u._minSizePx-u._size),u._onResizeEnd();break;case`End`:e.preventDefault(),u._maxSizePx!==1/0&&(u._onResizeStart(),u._onResizeMove(u._maxSizePx-u._size),u._onResizeEnd());break;case`Enter`:e.preventDefault(),u._collapsible&&Fe(u)}},[a,u,O,F,M]),oe=(0,A.useCallback)(()=>{!a&&u&&u._collapsible&&Fe(u)},[a,u]),V=(0,A.useRef)(void 0);V.current=u?._onResizeCancel,(0,A.useEffect)(()=>()=>{_.current&&(_.current=null,X(),V.current?.())},[]);let H=u?._isCollapsed??!1,se=u?H?Math.max(u._size,u._minSizePx):u._size:void 0,ce=u?u._minSizePx:void 0,U=u?we(u)??(u._maxSizePx===1/0?void 0:u._maxSizePx):void 0,le=U!=null&&Number.isFinite(U)?U:void 0,ue=u&&H?m(`@astryx.resizable.collapsed`):void 0;return(0,j.jsxs)(`div`,{ref:ne(te,g),role:`separator`,"aria-orientation":O?`vertical`:`horizontal`,"aria-valuenow":se,"aria-valuemin":ce,"aria-valuemax":le,"aria-valuetext":ue,"aria-label":h,"aria-disabled":a||void 0,tabIndex:a?-1:0,onDoubleClick:oe,onFocus:()=>D(!0),onBlur:()=>D(!1),"data-resizing":y||void 0,...v(r(`resize-handle`),C.focusVisible(Z.handle,k&&Z.overlay,k&&(O?Z.overlayHorizontal:Z.overlayVertical),!k&&(O?Z.horizontal:Z.vertical),!k&&!o&&(O?Z.noDividerHorizontal:Z.noDividerVertical),!k&&o&&I&&!y&&Z.handleHover,!k&&o&&y&&Z.handleActive,a&&Z.disabled,d),f),...p,onKeyDown:e=>{p.onKeyDown?.(e),ae(e)},children:[(0,j.jsx)(`div`,{...n(Z.hitArea,O?Z.hitAreaHorizontal:Z.hitAreaVertical,P==null?O?x.centerInline(`0px`):Z.hitAreaCenteredY:O?Ne.hitAreaOffsetX(P):Ne.hitAreaOffsetY(P),a&&Z.disabled),onPointerDown:re,onPointerMove:ie,onPointerUp:z,onPointerCancel:B,onLostPointerCapture:B,onPointerEnter:()=>T(!0),onPointerLeave:()=>{y||T(!1)}}),ee??(0,j.jsx)(`div`,{...v(r(`resize-handle-pill`),n(Z.pill,O?Z.pillHorizontal:Z.pillVertical,N===`center`?x.centerInline(`-50%`):O?Ne.pillOffsetX(N===`start`?-1:1):Ne.pillOffsetY(N===`start`?-1:1),s?Z.pillVisible:Z.pillHidden,I&&!y&&Z.pillHover,y&&Z.pillActive))})]})}Ie.displayName=`ResizeHandle`;var Le={defaultSize:`33%`,minSize:280,maxSize:`50%`};function Re(e){return e>=Le.minSize*2}function ze(e,t){let n=(0,A.useId)(),[r,i]=(0,A.useState)(t);return{id:n,open:r,toggle:(0,A.useCallback)(()=>i(e=>!e),[]),resizable:Ee({...Le,containerRef:e})}}function Be({children:e,floating:t=!1}){return t?(0,j.jsx)(`div`,{style:{position:`absolute`,insetBlockStart:`var(--spacing-4)`,insetInlineEnd:`var(--spacing-4)`,zIndex:3},children:(0,j.jsx)(g,{hAlign:`end`,gap:1,children:e})}):(0,j.jsx)(P,{hasDivider:!1,children:(0,j.jsx)(g,{hAlign:`end`,gap:1,children:e})})}function Ve({labels:e,icon:t,panelId:n,open:r,onToggle:i}){let a=r?e.hide:e.show;return(0,j.jsx)(w,{label:a,tooltip:a,variant:r?`secondary`:`ghost`,"aria-expanded":r,"aria-controls":n,icon:t,onClick:i})}var He={background:`var(--theorem-pane-background, var(--color-background-card))`,borderRadius:`var(--radius-page)`,overflow:`hidden`};function Ue(e){return`var(--theorem-pane-edge, var(--spacing-${String(e)}))`}function We({padding:e,inset:t=`end`,className:n,children:r}){return(0,j.jsx)(h,{height:`100%`,className:n,paddingInlineStart:t===`end`?void 0:3,style:{paddingInlineEnd:t===`start`?void 0:Ue(3),paddingBlockEnd:Ue(4)},children:(0,j.jsx)(E,{variant:`transparent`,height:`100%`,padding:e,style:He,children:r})})}function Ge({label:e,padding:t,children:n}){return(0,j.jsx)(k,{className:`theorem-panel-scroll`,label:e,height:`100%`,padding:t,children:n})}function Ke({id:e,labels:t,resizable:n,open:r=!0,padding:i,side:a=`end`,className:o,children:s}){let c=r?(0,j.jsx)(Ie,{direction:`horizontal`,isReversed:a===`end`,hasDivider:!1,isAlwaysVisible:!1,resizable:n.props,label:t.resize}):null,l=(0,j.jsx)(L,{id:e,className:o,label:t.name,role:`complementary`,width:r?n.size:0,hasDivider:!1,padding:0,isScrollable:!1,inert:!r,children:(0,j.jsx)(We,{padding:i,inset:a,children:r?s:null})});return a===`start`?(0,j.jsxs)(j.Fragment,{children:[l,c]}):(0,j.jsxs)(j.Fragment,{children:[c,l]})}function qe(){let[e,t]=(0,A.useState)(0);return{ref:(0,A.useCallback)(e=>{if(!e)return;let n=new ResizeObserver(([e])=>t(e?.contentRect.width??0));return n.observe(e),()=>n.disconnect()},[]),width:e}}function Je({id:e,header:t,children:n}){let{ref:r,width:i}=qe();return(0,j.jsx)(l,{height:`fill`,style:{position:`relative`},header:t,content:(0,j.jsx)(c,{padding:0,isScrollable:!1,children:(0,j.jsx)(h,{height:`100%`,paddingInlineStart:3,paddingBlockStart:3,style:{paddingInlineEnd:Ue(3),paddingBlockEnd:Ue(3)},children:(0,j.jsx)(E,{variant:`transparent`,height:`100%`,padding:0,style:He,children:(0,j.jsx)(`div`,{id:e,ref:r,style:{height:`100%`},children:n(Re(i))})})})})})}function Ye({isWide:e,label:t,detailLabel:n,lead:r,overview:i,detail:a}){return e?(0,j.jsxs)(g,{height:`100%`,gap:0,children:[(0,j.jsx)(_,{size:`fill`,children:(0,j.jsxs)(Ge,{label:t,children:[r,i]})}),a?(0,j.jsx)(`div`,{style:{width:`48%`,flexShrink:0,height:`100%`,borderInlineStart:`1px solid var(--color-border)`},children:(0,j.jsx)(Ge,{label:n,children:a})}):null]}):(0,j.jsxs)(Ge,{label:t,children:[r,a||i]})}function Xe({title:e,doc:t,children:n}){return(0,j.jsx)(E,{padding:3,variant:`muted`,style:{background:`var(--color-background-surface)`},children:(0,j.jsxs)(h,{gap:2,children:[(0,j.jsx)(D,{content:t??e,children:(0,j.jsx)(T,{type:`supporting`,color:`secondary`,children:e})}),n]})})}function Ze({text:e}){return(0,j.jsx)(`span`,{style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:e})}function Qe({view:e,children:t}){return(0,j.jsxs)(j.Fragment,{children:[e,(0,j.jsx)(`div`,{style:{display:e?`none`:`contents`},children:t})]})}var $e=[],et=()=>()=>{};function tt(e){return(0,A.useSyncExternalStore)(e?.subscribe??et,e?.records??(()=>$e))}export{R as C,re as S,P as T,Ie as _,We as a,ie as b,He as c,Be as d,Ve as f,qe as g,ze as h,Xe as i,Je as l,Ue as m,Qe as n,Ge as o,Re as p,Ye as r,Ze as s,tt as t,Ke as u,Ee as v,L as w,z as x,B as y};
@@ -0,0 +1 @@
1
+ import{S as e,_ as t,a as n,c as r,i,n as a,o,r as s,s as c,w as l}from"./tree-6F02tTxC.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 o(t)===void 0?p(e,t):t}function g(e,t){let n=o(t);if(n!==void 0)return e.toolSpecs.some(e=>e.key===n)?{tool:n}:void 0;let r=a(t);if(r!==void 0)return e.providers.some(e=>e.id===r)?{provider:r}:void 0;let s=m(t),c=s&&e.agents.find(e=>e.key===s.key);if(!s||!c||o(s.inner)!==void 0)return;let l=i(_(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(t,n=e(`agent`)){let{toolSpecs:r,tools:i,providers:a,...o}=t;return{...o,key:n,tools:{...i,allow:r.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){let n=e.agents.find(e=>e.key===t);return n&&{..._(n,[],e.providers),toolSpecs:e.toolSpecs}}function D(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 O(e,n=t()){let r=new Map(e.toolSpecs.map(e=>[e.toolName,e.key])),i=n.identity.agentId.trim(),a=e.agents.map(e=>e.identity.agentId),o=i&&l(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({...e,agents:[...e.agents,s],toolSpecs:[...e.toolSpecs,...n.toolSpecs.filter(e=>!r.has(e.toolName))],selected:p(s.key)})}function re(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:e(`agent`)};s.identity.agentId=l(`${a}_copy`,o,e=>`${a}_copy${e}`);let c=[...t.agents];return c.splice(r+1,0,s),C({...t,agents:c,selected:p(s.key)})}function ie(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===c(t));return C({...e,agents:a,toolSpecs:e.toolSpecs.filter(e=>!i.has(e.key)),selected:o?p(r.key):e.selected,chatWith:e.chatWith===t?r.key:e.chatWith})}function ae(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 oe(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===c(t)?p(e.agents[0]?.key??``):e.selected})}var k=(e,t)=>d(e)===d(t),A=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function se(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 ce(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 le(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(e,t){let n=e.starts.agents[t],r=e.agents.find(e=>e.key===t);if(!n||!r)return e;let i=new Set(e.agents.map(e=>e.key)),a=new Set(e.toolSpecs.map(e=>e.key)),o=e.toolSpecs.map(e=>e.toolName),s=[];for(let t of n.tools.allow){let n=e.starts.tools[t];if(a.has(t)||!n||n.toolType===`agent`&&!i.has(n.agentKey??``))continue;let r=l(n.toolName,o,e=>`${n.toolName}_${e}`);o.push(r),s.push({...n,toolName:r})}let c=s.length?[...e.toolSpecs,...s]:e.toolSpecs,u=new Set(c.map(e=>e.key)),d=n.identity.agentId,f=e.agents.filter(e=>e.key!==t).map(e=>e.identity.agentId),m=le(n,d&&l(d,f,e=>`${d}_${e}`),u,i);if(s.length===0&&k(m,r))return e;let h=te(e,[n]),_={...e,agents:b(e,t,()=>m),toolSpecs:c,providers:h};return g(_,_.selected)?_:{..._,selected:p(t)}}function ue(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=de(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 de(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??``)),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 fe(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 pe(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(e,t){let n=e.starts.tools[t],r=e.toolSpecs.find(e=>e.key===t);if(!n||!r)return e;let i=e.toolSpecs.filter(e=>e.key!==t).map(e=>e.toolName),a={...n,toolName:l(n.toolName,i,e=>`${n.toolName}_${e}`)};return k(a,r)?e:{...e,toolSpecs:e.toolSpecs.map(e=>e.key===t?a: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 me(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(e,t){return{id:l(`provider`,e,e=>`provider_${e}`),definition:t,connection:{}}}function ge(e,t){return e.providers.some(e=>e.id===t.id)?e:C({...e,providers:[...e.providers,t],selected:s(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===s(t)?p(e.agents[0]?.key??``):e.selected})}function Q(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,o=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(o)?{...e,modelBindings:e.modelBindings.map(e=>o(e)?{...e,provider:r}:e)}:e),selected:e.selected===s(t)?s(r):e.selected,starts:{...e.starts,providers:i?{...a,[r]:{...i,id:r}}:a}}}function ve(e){return e.providers.flatMap(t=>{let n=e.starts.providers[t.id];return n&&k(n,t)?[t.id]:[]})}function ye(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 be(e,t){let r=$(e.key,n(_(e,[],t)));return e.identity.agentId.trim()?r:{...r,label:`New agent`}}function xe(e){return{agents:e.agents.map(t=>be(t,e.providers)),tools:r(e.toolSpecs)}}export{pe as A,ue as C,ae as D,h as E,d as F,X as M,g as N,ce as O,xe as P,j as S,ye as T,ie as _,se as a,Q as b,F as c,fe as d,me as f,P as g,ve as h,p as i,D as j,T as k,E as l,Z as m,ge as n,re as o,he as p,ee as r,I as s,O as t,ne as u,oe 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-pXL_YUn6.js"></script>
13
+ <script type="module" crossorigin src="/studio/assets/index-BCMKIa3t.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">
@@ -40,26 +40,26 @@
40
40
  <link rel="modulepreload" crossorigin href="/studio/assets/container.stylex-BmOi-8DQ.js">
41
41
  <link rel="modulepreload" crossorigin href="/studio/assets/Card-Ghe4ozhC.js">
42
42
  <link rel="modulepreload" crossorigin href="/studio/assets/ScrollableArea-C8AVuqnt.js">
43
- <link rel="modulepreload" crossorigin href="/studio/assets/SidePanel-OYp0bLNO.js">
43
+ <link rel="modulepreload" crossorigin href="/studio/assets/use-trace-records-BkAYJz0M.js">
44
44
  <link rel="modulepreload" crossorigin href="/studio/assets/IconAlertTriangle-BqAEqqdU.js">
45
- <link rel="modulepreload" crossorigin href="/studio/assets/labels-provider-BqgbdxdT.js">
46
- <link rel="modulepreload" crossorigin href="/studio/assets/Banner-CYShUDUy.js">
45
+ <link rel="modulepreload" crossorigin href="/studio/assets/labels-provider-BSiD6Lrb.js">
46
+ <link rel="modulepreload" crossorigin href="/studio/assets/Banner-8YJcS8-V.js">
47
47
  <link rel="modulepreload" crossorigin href="/studio/assets/arrive-DvbqpeRS.js">
48
48
  <link rel="modulepreload" crossorigin href="/studio/assets/Center-nHS1JSux.js">
49
49
  <link rel="modulepreload" crossorigin href="/studio/assets/IconSearch-BTx66a40.js">
50
50
  <link rel="modulepreload" crossorigin href="/studio/assets/schemas-BQ9Jydzb.js">
51
51
  <link rel="modulepreload" crossorigin href="/studio/assets/host-patterns-C9RMP16Q.js">
52
52
  <link rel="modulepreload" crossorigin href="/studio/assets/shaped-data-0GUF7Al3.js">
53
- <link rel="modulepreload" crossorigin href="/studio/assets/tool-schema-CgpwKFX7.js">
53
+ <link rel="modulepreload" crossorigin href="/studio/assets/tool-schema-BlUbzOu9.js">
54
54
  <link rel="modulepreload" crossorigin href="/studio/assets/live-ingress-lDUGPwth.js">
55
55
  <link rel="modulepreload" crossorigin href="/studio/assets/trace-schema-9CdEyG6Q.js">
56
- <link rel="modulepreload" crossorigin href="/studio/assets/stub-DpBSP8Ld.js">
57
- <link rel="modulepreload" crossorigin href="/studio/assets/reader-paEmSrWc.js">
58
- <link rel="modulepreload" crossorigin href="/studio/assets/tree-BxX70aqA.js">
59
- <link rel="modulepreload" crossorigin href="/studio/assets/types-BoECJ8mE.js">
56
+ <link rel="modulepreload" crossorigin href="/studio/assets/stub-Bf9DC2iQ.js">
57
+ <link rel="modulepreload" crossorigin href="/studio/assets/reader-CVFKFctz.js">
58
+ <link rel="modulepreload" crossorigin href="/studio/assets/tree-6F02tTxC.js">
59
+ <link rel="modulepreload" crossorigin href="/studio/assets/types-DN_oZAOJ.js">
60
60
  <link rel="modulepreload" crossorigin href="/studio/assets/useScrollLock-Dyf6PHJt.js">
61
61
  <link rel="modulepreload" crossorigin href="/studio/assets/useContainerReveal-BFy8N_QU.js">
62
- <link rel="modulepreload" crossorigin href="/studio/assets/browser-transport-LKSluKnw.js">
62
+ <link rel="modulepreload" crossorigin href="/studio/assets/browser-transport-1C-yqvF_.js">
63
63
  <link rel="modulepreload" crossorigin href="/studio/assets/focusReturn-CTppP2k0.js">
64
64
  <link rel="modulepreload" crossorigin href="/studio/assets/chainEventHandlers-C6ttXGfW.js">
65
65
  <link rel="modulepreload" crossorigin href="/studio/assets/Dialog-BDUExlk_.js">
@@ -67,22 +67,22 @@
67
67
  <link rel="modulepreload" crossorigin href="/studio/assets/CheckboxInput-C9kbVyhK.js">
68
68
  <link rel="modulepreload" crossorigin href="/studio/assets/IconEye-BB5aY-wQ.js">
69
69
  <link rel="modulepreload" crossorigin href="/studio/assets/encode-files-DZ4tVtEQ.js">
70
- <link rel="modulepreload" crossorigin href="/studio/assets/turn-client-BZUECwPn.js">
71
- <link rel="modulepreload" crossorigin href="/studio/assets/CollapsibleGroup-CL8h1IzH.js">
72
- <link rel="modulepreload" crossorigin href="/studio/assets/studio-labels-BEjKXPex.js">
70
+ <link rel="modulepreload" crossorigin href="/studio/assets/turn-client-4GHmGV_4.js">
71
+ <link rel="modulepreload" crossorigin href="/studio/assets/CollapsibleGroup-PavPZ114.js">
72
+ <link rel="modulepreload" crossorigin href="/studio/assets/studio-labels-Jw1KQ1X1.js">
73
73
  <link rel="modulepreload" crossorigin href="/studio/assets/crypto-Boxudvjl.js">
74
- <link rel="modulepreload" crossorigin href="/studio/assets/workspace-Bc---F49.js">
74
+ <link rel="modulepreload" crossorigin href="/studio/assets/workspace-MlrGUH2-.js">
75
75
  <link rel="modulepreload" crossorigin href="/studio/assets/lent-keys-C32ems-I.js">
76
76
  <link rel="modulepreload" crossorigin href="/studio/assets/editors-BJX_S59A.js">
77
77
  <link rel="modulepreload" crossorigin href="/studio/assets/studio-session-yEqFQo5o.js">
78
78
  <link rel="modulepreload" crossorigin href="/studio/assets/EmptyState-C8W4JKBZ.js">
79
79
  <link rel="modulepreload" crossorigin href="/studio/assets/use-second-ticker-VX91zrxj.js">
80
80
  <link rel="modulepreload" crossorigin href="/studio/assets/useAdaptivePresentation-BY_zvjIp.js">
81
- <link rel="modulepreload" crossorigin href="/studio/assets/ContextMenu-VPTaWK-b.js">
81
+ <link rel="modulepreload" crossorigin href="/studio/assets/ContextMenu-BM8iCtOh.js">
82
82
  <link rel="modulepreload" crossorigin href="/studio/assets/BottomSheet-BQPskY35.js">
83
83
  <link rel="modulepreload" crossorigin href="/studio/assets/Section-DJ97F7QE.js">
84
84
  <link rel="stylesheet" crossorigin href="/studio/assets/use-second-ticker-CnxaP3LD.css">
85
- <link rel="stylesheet" crossorigin href="/studio/assets/index-Oo9otEIT.css">
85
+ <link rel="stylesheet" crossorigin href="/studio/assets/index-Cbs7B46A.css">
86
86
  <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>
87
87
  <noscript> <style>html[data-boot-pending],html[data-boot-pending] body{background:#000}html[data-boot-pending] #astryx-app-shell-main>:not([data-boot]){visibility:visible !important}[data-boot]{display:none !important}</style>
88
88
  </noscript>
package/runtime.d.ts CHANGED
@@ -32,7 +32,7 @@ export declare function streamStudioTurn(args: StudioDraftRun & {
32
32
  request: TheoremTurnRequest;
33
33
  conversations: StudioConversations;
34
34
  signal: AbortSignal;
35
- /** Where the turn's mid-turn steers queue. */
35
+ /** Where the turn's mid-turn steers queue, and its stop arrives. */
36
36
  steer: SteerInbox;
37
37
  }): AsyncGenerator<ReplyLine | StudioTraceLine | StudioSteerLine>;
38
38
  /**
package/runtime.js CHANGED
@@ -2,7 +2,7 @@ import { labelText, registerTraceDestination, resolveObservabilityPolicy, Theore
2
2
  import { gatedToolsFromEvents, interfaceFromProfile, promotedToolIdsFromEvents, toolSnapshotFromEvents, } from '@theoremjs/agents/interface';
3
3
  import { answerGatedCall, memoryCredentialSource, } from '@theoremjs/agents/kernel';
4
4
  import { decisionAssets, withFailedTraces, } from '@theoremjs/web/client';
5
- import { answerReply, checkRequest, conversationView, messageReply, openConversation, postedMessage, readerConversationHost, rewindConversation, startConversation, statelessRefusal, steerStage, waitingCalls, } from '@theoremjs/web/server';
5
+ import { answerReply, checkRequest, conversationView, messageReply, openConversation, postedMessage, readerConversationHost, rewindConversation, startConversation, statelessRefusal, steerStage, stopOnRequest, waitingCalls, } from '@theoremjs/web/server';
6
6
  import { STUDIO_TRACE_DESTINATION } from "./policy.js";
7
7
  import { studioReader } from "./reader.js";
8
8
  import { agentCallHook, runtimeProvider, studioScope, } from "./runtime-scope.js";
@@ -111,7 +111,7 @@ function answerPaused(scope, profile, opened, request, sessionPermissions, runti
111
111
  * walks away from settle first, then the reply runs.
112
112
  */
113
113
  export async function* streamStudioTurn(args) {
114
- const { request, runtime, signal } = args;
114
+ const { request, runtime } = args;
115
115
  const { scope, profile, iface, host } = await studioChat(args, args.conversations);
116
116
  const message = postedMessage(iface, request.input);
117
117
  const sessionPermissions = request.replay?.sessionPermissions;
@@ -134,6 +134,9 @@ export async function* streamStudioTurn(args) {
134
134
  // Random and picked here, so only the run's own browser can steer it.
135
135
  const inbox = globalThis.crypto.randomUUID();
136
136
  await args.steer.open(inbox);
137
+ const stop = new AbortController();
138
+ stopOnRequest(args.steer, inbox, stop);
139
+ const signal = AbortSignal.any([args.signal, stop.signal]);
137
140
  const steerLine = { type: 'steer_inbox', inbox };
138
141
  yield steerLine;
139
142
  try {
@@ -13,7 +13,7 @@
13
13
  */
14
14
  import { TheoremError, z } from '@theoremjs/agents';
15
15
  import { clientError } from '@theoremjs/agents/host';
16
- import { checkRequest, createMemoryPageToolBroker, createMemorySessionStore, createMemorySteerInbox, createSealedConversationStore, createTheoremSessionBoundary, pageToolResultSchema, readBody, steerUnitOf, theoremConversationRequestSchema, theoremHostCallRequestSchema, theoremInvokeRequestSchema, theoremRewindRequestSchema, theoremStartRequestSchema, theoremSteerRequestSchema, theoremTurnRequestSchema, } from '@theoremjs/web/server';
16
+ import { checkRequest, createMemoryPageToolBroker, createMemorySessionStore, createMemorySteerInbox, createSealedConversationStore, createTheoremSessionBoundary, pageToolResultSchema, readBody, steerUnitOf, theoremConversationRequestSchema, theoremHostCallRequestSchema, theoremInvokeRequestSchema, theoremRewindRequestSchema, theoremStartRequestSchema, theoremSteerRequestSchema, theoremStopRequestSchema, theoremTurnRequestSchema, } from '@theoremjs/web/server';
17
17
  import { newConversationKey } from "../conversation-key.js";
18
18
  import { rewindStudio, startStudioConversation, streamStudioCall, streamStudioHostInvoke, streamStudioInvoke, streamStudioTurn, studioConversation, } from "../runtime.js";
19
19
  import { draftDecide } from "./draft-decide.js";
@@ -156,6 +156,22 @@ export function createStudioDraftHandler(options = {}) {
156
156
  return errorJson(err);
157
157
  }
158
158
  },
159
+ 'turn/stop': async (request) => {
160
+ try {
161
+ // The inbox the server opened for the turn is the turn id the browser stops.
162
+ const asked = checkRequest(theoremStopRequestSchema, await readBody(request, z.unknown()), 'request body');
163
+ if (!(await steer.stop(asked.turnId))) {
164
+ // labels-exempt: internal diagnostic; the user reads session.turn_ended
165
+ throw new TheoremError('request', 'stop: no open run has this inbox', {
166
+ copy: { key: 'session.turn_ended' },
167
+ });
168
+ }
169
+ return Response.json({ ok: true });
170
+ }
171
+ catch (err) {
172
+ return errorJson(err);
173
+ }
174
+ },
159
175
  'page-result': async (request) => {
160
176
  try {
161
177
  const boundary = await createTheoremSessionBoundary({
package/transport.js CHANGED
@@ -140,6 +140,16 @@ export function createStudioTransport(payload, options = {}) {
140
140
  // The server's inbox is the turn it steers, so the body is a `TheoremSteerRequest`.
141
141
  await postJson('/api/studio/turn/steer', { turnId: inbox, id, inject }, options);
142
142
  },
143
+ async stop({ turnId }) {
144
+ const inbox = inboxes.get(turnId);
145
+ if (!inbox) {
146
+ // labels-exempt: internal diagnostic; the user reads session.turn_ended
147
+ throw new TheoremError('request', 'stop: the turn has not opened its inbox', {
148
+ copy: { key: 'session.turn_ended' },
149
+ });
150
+ }
151
+ await postJson('/api/studio/turn/stop', { turnId: inbox }, options);
152
+ },
143
153
  traces,
144
154
  };
145
155
  }
@@ -56,6 +56,11 @@ export declare const ISSUE_ROW_ATTRIBUTE = "data-issue";
56
56
  * is at its default width or wider, one once it is narrowed.
57
57
  */
58
58
  export declare const ListBadges: import("react").Context<number>;
59
+ /** The preview's guardrail test: whether it is open, and the button that opens or closes it. Null while no agent compiles. */
60
+ export declare const GuardrailTest: import("react").Context<{
61
+ open: boolean;
62
+ toggle: () => void;
63
+ } | null>;
59
64
  /** What the studio runs on: the page's lent keys, the builder's own, or their machine. */
60
65
  export declare const RunsOn: import("react").Context<StudioRunsOn>;
61
66
  export declare const LocalConnection: import("react").Context<Pick<{
@@ -68,6 +68,8 @@ export const ISSUE_ROW_ATTRIBUTE = 'data-issue';
68
68
  * is at its default width or wider, one once it is narrowed.
69
69
  */
70
70
  export const ListBadges = createContext(1);
71
+ /** The preview's guardrail test: whether it is open, and the button that opens or closes it. Null while no agent compiles. */
72
+ export const GuardrailTest = createContext(null);
71
73
  /** What the studio runs on: the page's lent keys, the builder's own, or their machine. */
72
74
  export const RunsOn = createContext(ON_OWN_KEYS);
73
75
  export const LocalConnection = createContext(null);
@@ -23,7 +23,7 @@ import { Thumbnail } from '@astryxdesign/core/Thumbnail';
23
23
  import { Token } from '@astryxdesign/core/Token';
24
24
  import { Tooltip } from '@astryxdesign/core/Tooltip';
25
25
  import { VStack } from '@astryxdesign/core/VStack';
26
- import { IconAbc, IconAdjustmentsHorizontal, IconAlertTriangle, IconAlignLeft, IconAntennaBars1, IconAntennaBars2, IconAntennaBars3, IconAntennaBars4, IconAntennaBars5, IconAntennaBarsOff, IconArrowDown, IconArrowLeft, IconArrowUp, IconBan, IconBandage, IconBiohazard, IconBolt, IconBraces, IconBulb, IconBulbOff, IconCertificate, IconCheck, IconChevronRight, IconCircleDashed, IconDatabase, IconDeviceDesktop, IconEraser, IconEye, IconEyeOff, IconFeather, IconFlag, IconFlame, IconFlask, IconGauge, IconHandOff, IconHandStop, IconHeadset, IconHourglass, IconHttpDelete, IconHttpGet, IconHttpPatch, IconHttpPost, IconHttpPut, IconInfoCircle, IconInputAi, IconKey, IconLayersUnion, IconLockOpen, IconMessage, IconMicrophone, IconPackage, IconPaperclip, IconPencil, IconPlayerPause, IconPlayerPlay, IconPlayerStop, IconPlayerTrackNext, IconPlugConnected, IconPlus, IconRefresh, IconRegex, IconSearch, IconSend, IconServer, IconShieldLock, IconShieldOff, IconSquareRoundedNumber0, IconSquareRoundedNumber2, IconTool, IconTrash, IconUser, IconUserCheck, IconWaveSine, IconWriting, IconX, } from '@tabler/icons-react';
26
+ import { IconAbc, IconAdjustmentsHorizontal, IconAlertTriangle, IconAlignLeft, IconAntennaBars1, IconAntennaBars2, IconAntennaBars3, IconAntennaBars4, IconAntennaBars5, IconAntennaBarsOff, IconArrowDown, IconArrowLeft, IconArrowUp, IconBan, IconBandage, IconBiohazard, IconBolt, IconBraces, IconBulb, IconBulbOff, IconCertificate, IconCheck, IconChevronRight, IconCircleDashed, IconDatabase, IconDeviceDesktop, IconEraser, IconEye, IconEyeOff, IconFeather, IconFlag, IconFlame, IconFlask, IconGauge, IconHandOff, IconHandStop, IconHeadset, IconHourglass, IconHttpDelete, IconHttpGet, IconHttpPatch, IconHttpPost, IconHttpPut, IconInfoCircle, IconInputAi, IconKey, IconLayersUnion, IconLockOpen, IconMessage, IconMicrophone, IconPackage, IconPaperclip, IconPencil, IconPlayerPause, IconPlayerPlay, IconPlayerStop, IconPlayerTrackNext, IconPlugConnected, IconPlus, IconRefresh, IconRegex, IconSearch, IconSend, IconServer, IconShieldLock, IconShieldOff, IconShieldSearch, IconSquareRoundedNumber0, IconSquareRoundedNumber2, IconTool, IconTrash, IconUser, IconUserCheck, IconWaveSine, IconWriting, IconX, } from '@tabler/icons-react';
27
27
  import { ATTACHMENT_ACCEPT_MIMES, CONTINUE_STOP_KINDS, fieldMeta, GOOGLE_BUILTIN_TOOLS, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_OUTPUT_MIMES, GOOGLE_IMAGE_RESOLUTIONS, GOOGLE_SPEECH_VOICES, HTTP_METHODS, IMAGE_ATTACHMENT_ACCEPT_MIMES, LABEL_KEYS, labelDefault, PROFILE_HANDLE_MAX_CHARS, PROFILE_ID_MAX_CHARS, profileGraphFacet, THINKING_LEVELS, VOICE_ACCEPT_MIMES, } from '@theoremjs/agents';
28
28
  import { BOUNDARIES, BOUNDARY_META, DETECT_ACTION_META, DETECT_ACTIONS, DETECTOR_BOUNDARIES, DETECTOR_GROUP_META, DETECTOR_GROUPS, DETECTOR_META, DETECTORS, TOOL_BOUNDARIES, TOOL_KINDS, } from '@theoremjs/agents/guardrails';
29
29
  import { lazy, Suspense, useContext, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, } from 'react';
@@ -31,7 +31,7 @@ import { acceptSections, agentToolTarget, bindingSlots, COMPACTION_DRAFT_DEFAULT
31
31
  import { AddProviderButton } from "./add-provider.js";
32
32
  import { IconGoogle, IconOpenAi, IconOpenRouter, IconTypeSafe } from "./brand-icons.js";
33
33
  import { ChoiceRow, InspectorGroupTitle, InspectorRow, InspectorSection, ListRow, NamesRow, NumberRow, OriginLine, SegmentedRow, SetInCode, SliderRow, SwitchRow, TextAreaRow, TextRow, } from "./inspector.js";
34
- import { ConfirmWrite, LeavePage, ListBadges, LocalConnection, NodeIssues, ProjectAsks, QuestionLink, RowOrigins, RunsOn, SaidOrigin, useFieldStatus, useRowOrigin, WorkspaceContext, } from "./inspector-context.js";
34
+ import { ConfirmWrite, GuardrailTest, LeavePage, ListBadges, LocalConnection, NodeIssues, ProjectAsks, QuestionLink, RowOrigins, RunsOn, SaidOrigin, useFieldStatus, useRowOrigin, WorkspaceContext, } from "./inspector-context.js";
35
35
  import { CONTEXT_PLACEHOLDER, contextErrorOf, draftSlots, usePageValues, } from "./lib/studio-page.js";
36
36
  import { useProject } from "./lib/studio-project.js";
37
37
  import { setToolCredential, subscribeToolCredentials, toolCredential, } from "./lib/tool-credentials.js";
@@ -1538,6 +1538,13 @@ function PageFrame({ viewKey, view, listScroll, children, }) {
1538
1538
  }, [viewKey, view, listScroll]);
1539
1539
  return (_jsx("div", { ref: view, className: "editor-page", children: children }, viewKey));
1540
1540
  }
1541
+ /** Opens the guardrail test in the preview's place, or closes it; there while an agent compiles. */
1542
+ function GuardrailTestButton() {
1543
+ const test = useContext(GuardrailTest);
1544
+ if (!test)
1545
+ return null;
1546
+ return (_jsx(Section, { variant: "transparent", paddingInline: 3, paddingBlockStart: 3, children: _jsx(Button, { label: test.open ? 'Close guardrail test' : 'Test guardrails', variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconShieldSearch, size: "sm" }), "aria-pressed": test.open, onClick: test.toggle }) }));
1547
+ }
1541
1548
  function GuardrailsEditor({ draft, setDraft }) {
1542
1549
  const { guardrails } = draft;
1543
1550
  const set = patch(setDraft, 'guardrails');
@@ -1549,7 +1556,7 @@ function GuardrailsEditor({ draft, setDraft }) {
1549
1556
  });
1550
1557
  if (page)
1551
1558
  return frame(JSON.stringify(open), page);
1552
- return frame('list', _jsxs(_Fragment, { children: [_jsx(DetectSection, { guardrails: guardrails, boundaries: boundaries, set: set, onOpen: show }), draftAllows(draft, 'guardrails.blockedReply') && (_jsx(BlockedReplySection, { guardrails: guardrails, withheld: labelValue(draft, 'error.safety') || labelDefault('error.safety'), set: set })), _jsx(NetworkSection, { guardrails: guardrails, set: set }), draftAllows(draft, 'guardrails.taint') && (_jsxs(InspectorSection, { title: "After a remote read", path: "guardrails.taint", note: studioTaintNote(on), children: [_jsx(SegmentedRow, { label: "Refuse calls", path: "guardrails.taint.afterRemoteRead", value: guardrails.taintAfterRemoteRead || 'off', segments: TAINT_SEGMENTS, onChange: (gate) => {
1559
+ return frame('list', _jsxs(_Fragment, { children: [_jsx(GuardrailTestButton, {}), _jsx(DetectSection, { guardrails: guardrails, boundaries: boundaries, set: set, onOpen: show }), draftAllows(draft, 'guardrails.blockedReply') && (_jsx(BlockedReplySection, { guardrails: guardrails, withheld: labelValue(draft, 'error.safety') || labelDefault('error.safety'), set: set })), _jsx(NetworkSection, { guardrails: guardrails, set: set }), draftAllows(draft, 'guardrails.taint') && (_jsxs(InspectorSection, { title: "After a remote read", path: "guardrails.taint", note: studioTaintNote(on), children: [_jsx(SegmentedRow, { label: "Refuse calls", path: "guardrails.taint.afterRemoteRead", value: guardrails.taintAfterRemoteRead || 'off', segments: TAINT_SEGMENTS, onChange: (gate) => {
1553
1560
  set({ taintAfterRemoteRead: gate === 'off' ? '' : gate });
1554
1561
  } }), _jsx(SegmentedRow, { label: "New address", path: "guardrails.taint.remoteDestination", value: guardrails.taintRemoteDestination || 'off', segments: DESTINATION_SEGMENTS, onChange: (gate) => {
1555
1562
  set({ taintRemoteDestination: gate === 'off' ? '' : gate });