@hotmeshio/long-tail 0.10.13 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -4
- package/build/api/escalations/analytics.d.ts +6 -0
- package/build/api/escalations/analytics.js +123 -0
- package/build/api/escalations/index.d.ts +1 -0
- package/build/api/escalations/index.js +4 -1
- package/build/api/escalations/metadata.js +1 -1
- package/build/api/escalations/resolve.js +4 -4
- package/build/api/roles.d.ts +4 -0
- package/build/api/roles.js +8 -0
- package/build/api/scan-codes/choice.d.ts +11 -0
- package/build/api/scan-codes/choice.js +136 -0
- package/build/api/scan-codes/context.d.ts +24 -0
- package/build/api/scan-codes/context.js +86 -0
- package/build/api/scan-codes/execute.d.ts +1 -0
- package/build/api/scan-codes/execute.js +49 -244
- package/build/api/scan-codes/identity.d.ts +18 -0
- package/build/api/scan-codes/identity.js +116 -0
- package/build/api/scan-codes/index.d.ts +2 -0
- package/build/api/scan-codes/index.js +6 -1
- package/build/api/scan-codes/locate.d.ts +14 -0
- package/build/api/scan-codes/locate.js +127 -0
- package/build/api/scan-codes/present.d.ts +9 -0
- package/build/api/scan-codes/present.js +59 -0
- package/build/api/scan-codes/verbs.d.ts +15 -0
- package/build/api/scan-codes/verbs.js +205 -0
- package/build/bin/ltc.js +33 -0
- package/build/lib/cli/commands/escalations.d.ts +31 -0
- package/build/lib/cli/commands/escalations.js +88 -0
- package/build/lib/db/schemas/028_role_entity_facet.sql +18 -0
- package/build/lib/db/schemas/029_scan_scheme_kind.sql +31 -0
- package/build/modules/config.d.ts +5 -0
- package/build/modules/config.js +12 -0
- package/build/routes/escalations/acting.d.ts +12 -0
- package/build/routes/escalations/acting.js +25 -0
- package/build/routes/escalations/analytics.d.ts +8 -0
- package/build/routes/escalations/analytics.js +63 -0
- package/build/routes/escalations/index.js +3 -0
- package/build/routes/escalations/resolve.js +8 -1
- package/build/routes/escalations/single.js +13 -4
- package/build/routes/roles.js +1 -1
- package/build/routes/scan-codes.js +28 -2
- package/build/scripts/ortho-populate.js +14 -0
- package/build/scripts/printer-cycle.d.ts +25 -0
- package/build/scripts/printer-cycle.js +169 -0
- package/build/scripts/twin-farm.js +19 -5
- package/build/sdk/index.d.ts +2 -0
- package/build/sdk/index.js +3 -0
- package/build/services/escalation/aggregate-sql.d.ts +36 -0
- package/build/services/escalation/aggregate-sql.js +253 -0
- package/build/services/escalation/aggregate-validate.d.ts +57 -0
- package/build/services/escalation/aggregate-validate.js +218 -0
- package/build/services/escalation/aggregates.d.ts +26 -0
- package/build/services/escalation/aggregates.js +204 -0
- package/build/services/escalation/client.js +57 -21
- package/build/services/escalation/facet-sql.js +17 -0
- package/build/services/escalation/index.d.ts +2 -0
- package/build/services/escalation/index.js +8 -1
- package/build/services/escalation/metrics-cache.d.ts +18 -0
- package/build/services/escalation/metrics-cache.js +47 -1
- package/build/services/escalation/queries.js +2 -0
- package/build/services/escalation/resolver-validation.d.ts +1 -1
- package/build/services/escalation/resolver-validation.js +12 -5
- package/build/services/escalation/submit-guard.d.ts +29 -0
- package/build/services/escalation/submit-guard.js +57 -0
- package/build/services/iam/acting-identity.d.ts +16 -0
- package/build/services/iam/acting-identity.js +60 -0
- package/build/services/role/index.js +2 -0
- package/build/services/role/sql.d.ts +10 -2
- package/build/services/role/sql.js +14 -1
- package/build/services/role/types.d.ts +16 -0
- package/build/services/scan-code/read.js +4 -0
- package/build/services/scan-code/sql.d.ts +4 -4
- package/build/services/scan-code/sql.js +14 -8
- package/build/services/scan-code/validate.d.ts +2 -0
- package/build/services/scan-code/validate.js +86 -0
- package/build/services/scan-code/write.d.ts +4 -0
- package/build/services/scan-code/write.js +16 -2
- package/build/services/user/crud.d.ts +6 -0
- package/build/services/user/crud.js +16 -0
- package/build/services/user/index.d.ts +1 -1
- package/build/services/user/index.js +2 -1
- package/build/services/user/sql.d.ts +8 -0
- package/build/services/user/sql.js +9 -1
- package/build/shared/form-validation/index.d.ts +4 -0
- package/build/shared/form-validation/index.js +4 -0
- package/build/shared/form-validation/x-lt-labels.d.ts +28 -0
- package/build/shared/form-validation/x-lt-labels.js +42 -0
- package/build/shared/form-validation/x-lt-query.d.ts +56 -0
- package/build/shared/form-validation/x-lt-query.js +49 -0
- package/build/shared/form-validation/x-lt-submit-guard.d.ts +46 -0
- package/build/shared/form-validation/x-lt-submit-guard.js +25 -0
- package/build/shared/form-validation/x-lt-submit-on-claim.d.ts +22 -0
- package/build/shared/form-validation/x-lt-submit-on-claim.js +28 -0
- package/build/system/mcp-servers/admin/escalations.js +34 -0
- package/build/system/mcp-servers/admin/scan-codes.js +17 -1
- package/build/system/mcp-servers/admin/schemas.d.ts +643 -25
- package/build/system/mcp-servers/admin/schemas.js +127 -19
- package/build/system/mcp-servers/admin/users.js +3 -1
- package/build/system/mcp-servers/human-queue-schemas.d.ts +2 -2
- package/build/system/seed/tool-manifests-admin.d.ts +2283 -0
- package/build/system/seed/tool-manifests-admin.js +8 -5
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/analytics.d.ts +154 -0
- package/build/types/analytics.js +14 -0
- package/build/types/facets.d.ts +13 -0
- package/build/types/index.d.ts +5 -2
- package/build/types/index.js +5 -1
- package/build/types/scan-choice.d.ts +49 -0
- package/build/types/scan-choice.js +9 -0
- package/build/types/scan-code.d.ts +72 -1
- package/build/types/scan-code.js +30 -1
- package/dashboard/dist/assets/{AdminDashboard-Bv3pHBzn.js → AdminDashboard-DJ3LJQ09.js} +2 -2
- package/dashboard/dist/assets/{AdminDashboard-Bv3pHBzn.js.map → AdminDashboard-DJ3LJQ09.js.map} +1 -1
- package/dashboard/dist/assets/{AgentConfigPage-Dk2zlvDb.js → AgentConfigPage-BMMvaD0z.js} +2 -2
- package/dashboard/dist/assets/{AgentConfigPage-Dk2zlvDb.js.map → AgentConfigPage-BMMvaD0z.js.map} +1 -1
- package/dashboard/dist/assets/{AgentDetailPage-DUno6EGs.js → AgentDetailPage-C6wfsnRe.js} +2 -2
- package/dashboard/dist/assets/{AgentDetailPage-DUno6EGs.js.map → AgentDetailPage-C6wfsnRe.js.map} +1 -1
- package/dashboard/dist/assets/AgentsPage-Cwqka7nE.js +2 -0
- package/dashboard/dist/assets/{AgentsPage-CToVu1qj.js.map → AgentsPage-Cwqka7nE.js.map} +1 -1
- package/dashboard/dist/assets/AvailableEscalationsPage-CVlG_AVC.js +2 -0
- package/dashboard/dist/assets/AvailableEscalationsPage-CVlG_AVC.js.map +1 -0
- package/dashboard/dist/assets/{BotPicker-DQOpVB4M.js → BotPicker-BBkJBXZB.js} +2 -2
- package/dashboard/dist/assets/{BotPicker-DQOpVB4M.js.map → BotPicker-BBkJBXZB.js.map} +1 -1
- package/dashboard/dist/assets/{CapabilitiesPage-Dmf46PUJ.js → CapabilitiesPage-wxmE4917.js} +2 -2
- package/dashboard/dist/assets/{CapabilitiesPage-Dmf46PUJ.js.map → CapabilitiesPage-wxmE4917.js.map} +1 -1
- package/dashboard/dist/assets/{CollapsibleSection-CDADefUY.js → CollapsibleSection-B3FsrHwH.js} +2 -2
- package/dashboard/dist/assets/{CollapsibleSection-CDADefUY.js.map → CollapsibleSection-B3FsrHwH.js.map} +1 -1
- package/dashboard/dist/assets/CountdownTimer-B3nCqJdC.js +2 -0
- package/dashboard/dist/assets/CountdownTimer-B3nCqJdC.js.map +1 -0
- package/dashboard/dist/assets/{CredentialsPage-8LIEvomi.js → CredentialsPage-Bv875IHe.js} +2 -2
- package/dashboard/dist/assets/{CredentialsPage-8LIEvomi.js.map → CredentialsPage-Bv875IHe.js.map} +1 -1
- package/dashboard/dist/assets/{CronLabel-CK3WSsM5.js → CronLabel-CSzjWuwj.js} +2 -2
- package/dashboard/dist/assets/{CronLabel-CK3WSsM5.js.map → CronLabel-CSzjWuwj.js.map} +1 -1
- package/dashboard/dist/assets/{CustomDurationPicker-FPmlA6cE.js → CustomDurationPicker-CCpqf3e4.js} +2 -2
- package/dashboard/dist/assets/{CustomDurationPicker-FPmlA6cE.js.map → CustomDurationPicker-CCpqf3e4.js.map} +1 -1
- package/dashboard/dist/assets/{DropZone-CL9gA7pu.js → DropZone-CJkk-U3o.js} +2 -2
- package/dashboard/dist/assets/{DropZone-CL9gA7pu.js.map → DropZone-CJkk-U3o.js.map} +1 -1
- package/dashboard/dist/assets/{ElapsedCell-BZVkVxE0.js → ElapsedCell-WV6pUaKo.js} +2 -2
- package/dashboard/dist/assets/{ElapsedCell-BZVkVxE0.js.map → ElapsedCell-WV6pUaKo.js.map} +1 -1
- package/dashboard/dist/assets/EntityTimelinePanel-DrL86Yrf.js +2 -0
- package/dashboard/dist/assets/EntityTimelinePanel-DrL86Yrf.js.map +1 -0
- package/dashboard/dist/assets/{EscalationListSchemaPage-kYLdUtZX.js → EscalationListSchemaPage-CTQCALw4.js} +3 -3
- package/dashboard/dist/assets/{EscalationListSchemaPage-kYLdUtZX.js.map → EscalationListSchemaPage-CTQCALw4.js.map} +1 -1
- package/dashboard/dist/assets/{EscalationSchemaPage-kUmCDivo.js → EscalationSchemaPage-D_UgP0pv.js} +3 -3
- package/dashboard/dist/assets/{EscalationSchemaPage-kUmCDivo.js.map → EscalationSchemaPage-D_UgP0pv.js.map} +1 -1
- package/dashboard/dist/assets/{EscalationsOverview-D17auO-m.js → EscalationsOverview-DuIUyxr0.js} +2 -2
- package/dashboard/dist/assets/{EscalationsOverview-D17auO-m.js.map → EscalationsOverview-DuIUyxr0.js.map} +1 -1
- package/dashboard/dist/assets/EventTable-BV6unphX.js +2 -0
- package/dashboard/dist/assets/EventTable-BV6unphX.js.map +1 -0
- package/dashboard/dist/assets/FilterBar-DYFgzXNB.js +2 -0
- package/dashboard/dist/assets/FilterBar-DYFgzXNB.js.map +1 -0
- package/dashboard/dist/assets/{GraphInvokePage-D11uOnZi.js → GraphInvokePage-BGHVUipJ.js} +2 -2
- package/dashboard/dist/assets/{GraphInvokePage-D11uOnZi.js.map → GraphInvokePage-BGHVUipJ.js.map} +1 -1
- package/dashboard/dist/assets/HomePage-B-S2cK3E.js +2 -0
- package/dashboard/dist/assets/{HomePage-Bcq10Bxx.js.map → HomePage-B-S2cK3E.js.map} +1 -1
- package/dashboard/dist/assets/ListToolbar-Bl7F3A28.js +2 -0
- package/dashboard/dist/assets/{ListToolbar-IPXsTb3Q.js.map → ListToolbar-Bl7F3A28.js.map} +1 -1
- package/dashboard/dist/assets/{McpOverview-Dx2j0KkF.js → McpOverview-_T9IsCD_.js} +2 -2
- package/dashboard/dist/assets/{McpOverview-Dx2j0KkF.js.map → McpOverview-_T9IsCD_.js.map} +1 -1
- package/dashboard/dist/assets/{McpQueryDetailPage-CzF_bna8.js → McpQueryDetailPage-DtsVqKPw.js} +2 -2
- package/dashboard/dist/assets/{McpQueryDetailPage-CzF_bna8.js.map → McpQueryDetailPage-DtsVqKPw.js.map} +1 -1
- package/dashboard/dist/assets/McpQueryPage-DX5u-1bx.js +2 -0
- package/dashboard/dist/assets/{McpQueryPage-CNsuiw_q.js.map → McpQueryPage-DX5u-1bx.js.map} +1 -1
- package/dashboard/dist/assets/McpRunDetailPage-BhcqqtYS.js +2 -0
- package/dashboard/dist/assets/McpRunDetailPage-BhcqqtYS.js.map +1 -0
- package/dashboard/dist/assets/{McpRunsPage-CK96s3Nt.js → McpRunsPage-L-1y8wnX.js} +2 -2
- package/dashboard/dist/assets/{McpRunsPage-CK96s3Nt.js.map → McpRunsPage-L-1y8wnX.js.map} +1 -1
- package/dashboard/dist/assets/{NamespacePill-B9Vc_Pz2.js → NamespacePill-in1SLd0W.js} +2 -2
- package/dashboard/dist/assets/{NamespacePill-B9Vc_Pz2.js.map → NamespacePill-in1SLd0W.js.map} +1 -1
- package/dashboard/dist/assets/OperationsPage-i8KcDpKo.js +3 -0
- package/dashboard/dist/assets/OperationsPage-i8KcDpKo.js.map +1 -0
- package/dashboard/dist/assets/OperatorDashboard-CIbDzOlh.js +2 -0
- package/dashboard/dist/assets/{OperatorDashboard-C-jE0IRA.js.map → OperatorDashboard-CIbDzOlh.js.map} +1 -1
- package/dashboard/dist/assets/{PageHeader-Ce4GcIYo.js → PageHeader-BJgWMZtw.js} +2 -2
- package/dashboard/dist/assets/{PageHeader-Ce4GcIYo.js.map → PageHeader-BJgWMZtw.js.map} +1 -1
- package/dashboard/dist/assets/{PageHeaderWithStats-Ck0KZvXD.js → PageHeaderWithStats-Ccio4vyG.js} +2 -2
- package/dashboard/dist/assets/{PageHeaderWithStats-Ck0KZvXD.js.map → PageHeaderWithStats-Ccio4vyG.js.map} +1 -1
- package/dashboard/dist/assets/{PersonaDetailPage-CJ6jqo7h.js → PersonaDetailPage-BOaf0TW1.js} +2 -2
- package/dashboard/dist/assets/{PersonaDetailPage-CJ6jqo7h.js.map → PersonaDetailPage-BOaf0TW1.js.map} +1 -1
- package/dashboard/dist/assets/{PersonasPage-D8hL3kL5.js → PersonasPage-DSdRb90f.js} +2 -2
- package/dashboard/dist/assets/{PersonasPage-D8hL3kL5.js.map → PersonasPage-DSdRb90f.js.map} +1 -1
- package/dashboard/dist/assets/{ProcessDetailPage-Vnx8Z5_y.js → ProcessDetailPage-DN9NqfeP.js} +2 -2
- package/dashboard/dist/assets/{ProcessDetailPage-Vnx8Z5_y.js.map → ProcessDetailPage-DN9NqfeP.js.map} +1 -1
- package/dashboard/dist/assets/{ProcessesListPage-DRYtvS3N.js → ProcessesListPage-CfQEWaD4.js} +2 -2
- package/dashboard/dist/assets/{ProcessesListPage-DRYtvS3N.js.map → ProcessesListPage-CfQEWaD4.js.map} +1 -1
- package/dashboard/dist/assets/RoleDetailPage-BC5HL7ls.js +8 -0
- package/dashboard/dist/assets/RoleDetailPage-BC5HL7ls.js.map +1 -0
- package/dashboard/dist/assets/{RolePill-CnuBPhPw.js → RolePill-BNAP-uK6.js} +2 -2
- package/dashboard/dist/assets/{RolePill-CnuBPhPw.js.map → RolePill-BNAP-uK6.js.map} +1 -1
- package/dashboard/dist/assets/RolesPage-DCnW0VmD.js +2 -0
- package/dashboard/dist/assets/RolesPage-DCnW0VmD.js.map +1 -0
- package/dashboard/dist/assets/RunAsSelector-twbuX7fB.js +2 -0
- package/dashboard/dist/assets/{RunAsSelector-CS3KQ-BF.js.map → RunAsSelector-twbuX7fB.js.map} +1 -1
- package/dashboard/dist/assets/ScanCodesPage-CPNg6K--.js +2 -0
- package/dashboard/dist/assets/ScanCodesPage-CPNg6K--.js.map +1 -0
- package/dashboard/dist/assets/ScanSchemeDetailPage-DyLmCamO.js +2 -0
- package/dashboard/dist/assets/ScanSchemeDetailPage-DyLmCamO.js.map +1 -0
- package/dashboard/dist/assets/ScanStationPage-DoZccU5B.js +2 -0
- package/dashboard/dist/assets/ScanStationPage-DoZccU5B.js.map +1 -0
- package/dashboard/dist/assets/{ScopeBadge-BUpYpS3x.js → ScopeBadge-BG7KkZ8Q.js} +2 -2
- package/dashboard/dist/assets/{ScopeBadge-BUpYpS3x.js.map → ScopeBadge-BG7KkZ8Q.js.map} +1 -1
- package/dashboard/dist/assets/SegmentedTabs-DXNzY05q.js +2 -0
- package/dashboard/dist/assets/SegmentedTabs-DXNzY05q.js.map +1 -0
- package/dashboard/dist/assets/StickyPagination-DIeYMPPd.js +2 -0
- package/dashboard/dist/assets/StickyPagination-DIeYMPPd.js.map +1 -0
- package/dashboard/dist/assets/{StreamMessageDetail-DyJyZwBl.js → StreamMessageDetail-gU4CUeQI.js} +2 -2
- package/dashboard/dist/assets/{StreamMessageDetail-DyJyZwBl.js.map → StreamMessageDetail-gU4CUeQI.js.map} +1 -1
- package/dashboard/dist/assets/{SwimlaneTimeline-BlzV74V5.js → SwimlaneTimeline-Br-nBA4l.js} +2 -2
- package/dashboard/dist/assets/{SwimlaneTimeline-BlzV74V5.js.map → SwimlaneTimeline-Br-nBA4l.js.map} +1 -1
- package/dashboard/dist/assets/{TagInput-BbZ25nNe.js → TagInput-CvM5n6ww.js} +2 -2
- package/dashboard/dist/assets/{TagInput-BbZ25nNe.js.map → TagInput-CvM5n6ww.js.map} +1 -1
- package/dashboard/dist/assets/{TaskDetailPage-B0p_Z4J_.js → TaskDetailPage-_9cr_R0u.js} +2 -2
- package/dashboard/dist/assets/{TaskDetailPage-B0p_Z4J_.js.map → TaskDetailPage-_9cr_R0u.js.map} +1 -1
- package/dashboard/dist/assets/{TaskQueuePill-D0QKBrN3.js → TaskQueuePill-D4JPHXOq.js} +2 -2
- package/dashboard/dist/assets/{TaskQueuePill-D0QKBrN3.js.map → TaskQueuePill-D4JPHXOq.js.map} +1 -1
- package/dashboard/dist/assets/{TasksListPage-CiGR2QiQ.js → TasksListPage-DVENC9Jp.js} +2 -2
- package/dashboard/dist/assets/{TasksListPage-CiGR2QiQ.js.map → TasksListPage-DVENC9Jp.js.map} +1 -1
- package/dashboard/dist/assets/{TimeAgo-D_DA9ucC.js → TimeAgo-C9yYnOui.js} +2 -2
- package/dashboard/dist/assets/{TimeAgo-D_DA9ucC.js.map → TimeAgo-C9yYnOui.js.map} +1 -1
- package/dashboard/dist/assets/{TimestampCell-C7rkC9nh.js → TimestampCell-DoB8cYgw.js} +2 -2
- package/dashboard/dist/assets/{TimestampCell-C7rkC9nh.js.map → TimestampCell-DoB8cYgw.js.map} +1 -1
- package/dashboard/dist/assets/{ToolPill-8xY9rkoc.js → ToolPill-BUjbC-Tj.js} +2 -2
- package/dashboard/dist/assets/{ToolPill-8xY9rkoc.js.map → ToolPill-BUjbC-Tj.js.map} +1 -1
- package/dashboard/dist/assets/{ToolTestPanel-E8efYGYs.js → ToolTestPanel-CBtsIP8K.js} +2 -2
- package/dashboard/dist/assets/{ToolTestPanel-E8efYGYs.js.map → ToolTestPanel-CBtsIP8K.js.map} +1 -1
- package/dashboard/dist/assets/{TopicDetailPage-B455XrRc.js → TopicDetailPage-mR4Jaz83.js} +4 -4
- package/dashboard/dist/assets/{TopicDetailPage-B455XrRc.js.map → TopicDetailPage-mR4Jaz83.js.map} +1 -1
- package/dashboard/dist/assets/TopicsPage-CP7HFxIC.js +2 -0
- package/dashboard/dist/assets/{TopicsPage-1VAc29Qw.js.map → TopicsPage-CP7HFxIC.js.map} +1 -1
- package/dashboard/dist/assets/{UserName-DikzjQHJ.js → UserName-BnLF6yhz.js} +2 -2
- package/dashboard/dist/assets/{UserName-DikzjQHJ.js.map → UserName-BnLF6yhz.js.map} +1 -1
- package/dashboard/dist/assets/WorkflowExecutionPage-xL956RZi.js +2 -0
- package/dashboard/dist/assets/WorkflowExecutionPage-xL956RZi.js.map +1 -0
- package/dashboard/dist/assets/{WorkflowPill-Da406nEj.js → WorkflowPill-tXU0-eXu.js} +2 -2
- package/dashboard/dist/assets/{WorkflowPill-Da406nEj.js.map → WorkflowPill-tXU0-eXu.js.map} +1 -1
- package/dashboard/dist/assets/WorkflowsDashboard-B-u7zFKM.js +2 -0
- package/dashboard/dist/assets/{WorkflowsDashboard-BMQd_0tW.js.map → WorkflowsDashboard-B-u7zFKM.js.map} +1 -1
- package/dashboard/dist/assets/{WorkflowsOverview-CdxjVifp.js → WorkflowsOverview-CqZVarK-.js} +2 -2
- package/dashboard/dist/assets/{WorkflowsOverview-CdxjVifp.js.map → WorkflowsOverview-CqZVarK-.js.map} +1 -1
- package/dashboard/dist/assets/{YamlWorkflowDetailPage-DNVffIXa.js → YamlWorkflowDetailPage-DiFLavW0.js} +10 -10
- package/dashboard/dist/assets/{YamlWorkflowDetailPage-DNVffIXa.js.map → YamlWorkflowDetailPage-DiFLavW0.js.map} +1 -1
- package/dashboard/dist/assets/{YamlWorkflowsPage-BGP8wuos.js → YamlWorkflowsPage-BuQM6uZA.js} +2 -2
- package/dashboard/dist/assets/{YamlWorkflowsPage-BGP8wuos.js.map → YamlWorkflowsPage-BuQM6uZA.js.map} +1 -1
- package/dashboard/dist/assets/{agents-BZJLIJ4h.js → agents-DU9GPovp.js} +2 -2
- package/dashboard/dist/assets/{agents-BZJLIJ4h.js.map → agents-DU9GPovp.js.map} +1 -1
- package/dashboard/dist/assets/{bots-ClLcDGJb.js → bots-Cy-Hmg7w.js} +2 -2
- package/dashboard/dist/assets/{bots-ClLcDGJb.js.map → bots-Cy-Hmg7w.js.map} +1 -1
- package/dashboard/dist/assets/capabilities-sSJJqrp-.js +2 -0
- package/dashboard/dist/assets/{capabilities-IaCcS7ge.js.map → capabilities-sSJJqrp-.js.map} +1 -1
- package/dashboard/dist/assets/{controlplane-Zi4m_MSx.js → controlplane-TVCjDHQ-.js} +2 -2
- package/dashboard/dist/assets/{controlplane-Zi4m_MSx.js.map → controlplane-TVCjDHQ-.js.map} +1 -1
- package/dashboard/dist/assets/escalation-columns-BpkjKYGd.js +2 -0
- package/dashboard/dist/assets/escalation-columns-BpkjKYGd.js.map +1 -0
- package/dashboard/dist/assets/index-5TblaCXQ.css +1 -0
- package/dashboard/dist/assets/index-7BP6FaCZ.js +2 -0
- package/dashboard/dist/assets/{index-Dldi3Q3M.js.map → index-7BP6FaCZ.js.map} +1 -1
- package/dashboard/dist/assets/{index-BzkE48xJ.js → index-B7IaBPBg.js} +4 -4
- package/dashboard/dist/assets/{index-BzkE48xJ.js.map → index-B7IaBPBg.js.map} +1 -1
- package/dashboard/dist/assets/index-BE0phFw0.js +2 -0
- package/dashboard/dist/assets/{index-CLmZaNTK.js.map → index-BE0phFw0.js.map} +1 -1
- package/dashboard/dist/assets/{index-BqGnhkh0.js → index-BYNN9N1T.js} +2 -2
- package/dashboard/dist/assets/{index-BqGnhkh0.js.map → index-BYNN9N1T.js.map} +1 -1
- package/dashboard/dist/assets/{index-kiKZresb.js → index-CLPVqbVY.js} +2 -2
- package/dashboard/dist/assets/{index-kiKZresb.js.map → index-CLPVqbVY.js.map} +1 -1
- package/dashboard/dist/assets/{index-C3o4OisO.js → index-Cfv86_L9.js} +2 -2
- package/dashboard/dist/assets/{index-C3o4OisO.js.map → index-Cfv86_L9.js.map} +1 -1
- package/dashboard/dist/assets/{index-yGNt29V9.js → index-CtwbQ_-m.js} +2 -2
- package/dashboard/dist/assets/{index-yGNt29V9.js.map → index-CtwbQ_-m.js.map} +1 -1
- package/dashboard/dist/assets/index-DOai950R.js +3 -0
- package/dashboard/dist/assets/index-DOai950R.js.map +1 -0
- package/dashboard/dist/assets/index-DTtHNC-D.js +5 -0
- package/dashboard/dist/assets/{index-CvNBdkB1.js.map → index-DTtHNC-D.js.map} +1 -1
- package/dashboard/dist/assets/{index-CJu2PBNx.js → index-DsWnVyVN.js} +2 -2
- package/dashboard/dist/assets/{index-CJu2PBNx.js.map → index-DsWnVyVN.js.map} +1 -1
- package/dashboard/dist/assets/{index-D0zFReGL.js → index-Dy-MMYti.js} +2 -2
- package/dashboard/dist/assets/{index-D0zFReGL.js.map → index-Dy-MMYti.js.map} +1 -1
- package/dashboard/dist/assets/index-errgQT5x.js +65 -0
- package/dashboard/dist/assets/index-errgQT5x.js.map +1 -0
- package/dashboard/dist/assets/{index-CmnNqpWg.js → index-fgBDhnI6.js} +2 -2
- package/dashboard/dist/assets/{index-CmnNqpWg.js.map → index-fgBDhnI6.js.map} +1 -1
- package/dashboard/dist/assets/{knowledge-DWLxGTib.js → knowledge-arh4NfmL.js} +2 -2
- package/dashboard/dist/assets/{knowledge-DWLxGTib.js.map → knowledge-arh4NfmL.js.map} +1 -1
- package/dashboard/dist/assets/{mcp-B6AARZ2I.js → mcp-QGf5jHCo.js} +2 -2
- package/dashboard/dist/assets/{mcp-B6AARZ2I.js.map → mcp-QGf5jHCo.js.map} +1 -1
- package/dashboard/dist/assets/{mcp-query-DrkvBU3a.js → mcp-query-BEJN1nMZ.js} +2 -2
- package/dashboard/dist/assets/{mcp-query-DrkvBU3a.js.map → mcp-query-BEJN1nMZ.js.map} +1 -1
- package/dashboard/dist/assets/{personas-Cmz2SAEU.js → personas-DYtw1COf.js} +2 -2
- package/dashboard/dist/assets/{personas-Cmz2SAEU.js.map → personas-DYtw1COf.js.map} +1 -1
- package/dashboard/dist/assets/{pipelines-CSgfVCMy.js → pipelines-Byi6PnbE.js} +2 -2
- package/dashboard/dist/assets/{pipelines-CSgfVCMy.js.map → pipelines-Byi6PnbE.js.map} +1 -1
- package/dashboard/dist/assets/{tasks-UOtUkDk-.js → tasks-D0SQdENz.js} +2 -2
- package/dashboard/dist/assets/{tasks-UOtUkDk-.js.map → tasks-D0SQdENz.js.map} +1 -1
- package/dashboard/dist/assets/{topics-Df5hGh6o.js → topics-DgDv5ZXP.js} +2 -2
- package/dashboard/dist/assets/{topics-Df5hGh6o.js.map → topics-DgDv5ZXP.js.map} +1 -1
- package/dashboard/dist/assets/useEventHooks-DZaYzE7s.js +2 -0
- package/dashboard/dist/assets/{useEventHooks-PDbuSJ12.js.map → useEventHooks-DZaYzE7s.js.map} +1 -1
- package/dashboard/dist/assets/{useNamespace-tZSOlge3.js → useNamespace-C1OqiNXN.js} +2 -2
- package/dashboard/dist/assets/{useNamespace-tZSOlge3.js.map → useNamespace-C1OqiNXN.js.map} +1 -1
- package/dashboard/dist/assets/{useYamlActivityEvents-CINLzE32.js → useYamlActivityEvents-CkmXDm-Z.js} +2 -2
- package/dashboard/dist/assets/{useYamlActivityEvents-CINLzE32.js.map → useYamlActivityEvents-CkmXDm-Z.js.map} +1 -1
- package/dashboard/dist/assets/{users-G8qwyZKS.js → users-D4DCFPH1.js} +2 -2
- package/dashboard/dist/assets/{users-G8qwyZKS.js.map → users-D4DCFPH1.js.map} +1 -1
- package/dashboard/dist/assets/{vendor-icons-BpZiWH2f.js → vendor-icons-BxuyFxH2.js} +156 -136
- package/dashboard/dist/assets/vendor-icons-BxuyFxH2.js.map +1 -0
- package/dashboard/dist/assets/{workflows-DbPqi1TW.js → workflows-qyc0ku_5.js} +2 -2
- package/dashboard/dist/assets/{workflows-DbPqi1TW.js.map → workflows-qyc0ku_5.js.map} +1 -1
- package/dashboard/dist/assets/{yaml-workflows-DozD8hpR.js → yaml-workflows-DWFww9Xn.js} +2 -2
- package/dashboard/dist/assets/{yaml-workflows-DozD8hpR.js.map → yaml-workflows-DWFww9Xn.js.map} +1 -1
- package/dashboard/dist/index.html +3 -3
- package/docs/api/http/escalations.md +133 -0
- package/docs/api/http/roles.md +6 -0
- package/docs/api/mcp/admin.md +53 -0
- package/docs/api/sdk/escalations.md +58 -0
- package/docs/cli.md +11 -0
- package/docs/dashboard.md +22 -20
- package/docs/data.md +12 -4
- package/docs/design-principles.md +9 -7
- package/docs/escalation-analytics.md +251 -0
- package/docs/hitl/roles.md +1 -1
- package/docs/hitl/x-lt-embed.md +8 -4
- package/docs/hitl/x-lt-footer.md +67 -0
- package/docs/hitl/x-lt-list-schema.md +10 -3
- package/docs/hitl-guide.md +11 -2
- package/docs/iam.md +12 -0
- package/docs/operations.md +17 -0
- package/docs/scan-codes.md +112 -0
- package/docs/sdk.md +1 -1
- package/package.json +2 -1
- package/dashboard/dist/assets/AgentsPage-CToVu1qj.js +0 -2
- package/dashboard/dist/assets/AvailableEscalationsPage-DldboL4W.js +0 -2
- package/dashboard/dist/assets/AvailableEscalationsPage-DldboL4W.js.map +0 -1
- package/dashboard/dist/assets/CountdownTimer-DPjIkerB.js +0 -2
- package/dashboard/dist/assets/CountdownTimer-DPjIkerB.js.map +0 -1
- package/dashboard/dist/assets/EventTable-CwPWl163.js +0 -2
- package/dashboard/dist/assets/EventTable-CwPWl163.js.map +0 -1
- package/dashboard/dist/assets/FilterBar-D7GghUsU.js +0 -2
- package/dashboard/dist/assets/FilterBar-D7GghUsU.js.map +0 -1
- package/dashboard/dist/assets/HomePage-Bcq10Bxx.js +0 -2
- package/dashboard/dist/assets/ListToolbar-IPXsTb3Q.js +0 -2
- package/dashboard/dist/assets/McpQueryPage-CNsuiw_q.js +0 -2
- package/dashboard/dist/assets/McpRunDetailPage-BJguEMS0.js +0 -2
- package/dashboard/dist/assets/McpRunDetailPage-BJguEMS0.js.map +0 -1
- package/dashboard/dist/assets/OperationsPage-DvWrLuH6.js +0 -2
- package/dashboard/dist/assets/OperationsPage-DvWrLuH6.js.map +0 -1
- package/dashboard/dist/assets/OperatorDashboard-C-jE0IRA.js +0 -2
- package/dashboard/dist/assets/RoleDetailPage-BKkUvTO-.js +0 -8
- package/dashboard/dist/assets/RoleDetailPage-BKkUvTO-.js.map +0 -1
- package/dashboard/dist/assets/RolesPage-BHzWK9n6.js +0 -2
- package/dashboard/dist/assets/RolesPage-BHzWK9n6.js.map +0 -1
- package/dashboard/dist/assets/RunAsSelector-CS3KQ-BF.js +0 -2
- package/dashboard/dist/assets/ScanCodesPage-BW4P4zWf.js +0 -2
- package/dashboard/dist/assets/ScanCodesPage-BW4P4zWf.js.map +0 -1
- package/dashboard/dist/assets/ScanSchemeDetailPage-BLykA4j-.js +0 -2
- package/dashboard/dist/assets/ScanSchemeDetailPage-BLykA4j-.js.map +0 -1
- package/dashboard/dist/assets/StickyPagination-hMrnLXde.js +0 -2
- package/dashboard/dist/assets/StickyPagination-hMrnLXde.js.map +0 -1
- package/dashboard/dist/assets/TopicsPage-1VAc29Qw.js +0 -2
- package/dashboard/dist/assets/WorkflowExecutionPage-C15GSAoe.js +0 -2
- package/dashboard/dist/assets/WorkflowExecutionPage-C15GSAoe.js.map +0 -1
- package/dashboard/dist/assets/WorkflowsDashboard-BMQd_0tW.js +0 -2
- package/dashboard/dist/assets/capabilities-IaCcS7ge.js +0 -2
- package/dashboard/dist/assets/escalation-columns-BY2mg9DY.js +0 -2
- package/dashboard/dist/assets/escalation-columns-BY2mg9DY.js.map +0 -1
- package/dashboard/dist/assets/index-CLmZaNTK.js +0 -2
- package/dashboard/dist/assets/index-CfAi1OsI.js +0 -65
- package/dashboard/dist/assets/index-CfAi1OsI.js.map +0 -1
- package/dashboard/dist/assets/index-CvNBdkB1.js +0 -5
- package/dashboard/dist/assets/index-Dldi3Q3M.js +0 -2
- package/dashboard/dist/assets/index-mKcQGi2B.js +0 -3
- package/dashboard/dist/assets/index-mKcQGi2B.js.map +0 -1
- package/dashboard/dist/assets/index-zQiUPfxA.css +0 -1
- package/dashboard/dist/assets/useEventHooks-PDbuSJ12.js +0 -2
- package/dashboard/dist/assets/vendor-icons-BpZiWH2f.js.map +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{b as Le,a as m,j as t}from"./vendor-query-RUZdMvN6.js";import{W as ws,X as pt,g as ft,Q as Vt,Y as St,J as kt,c as ks,d as _s,P as st,b as Jt,n as we,Z as Ut,_ as Pe,U as Kt,m as te,M as We,j as Fe,$ as Cs,a0 as Es,i as As,a1 as Ts,a2 as Rs,u as Os,x as Is,l as Ms,a3 as Ds}from"./index-errgQT5x.js";import{u as qe,C as Ve,a as Ss}from"./CustomDurationPicker-CCpqf3e4.js";import{M as Je}from"./Modal-BU7No9NH.js";import{a as Ue,u as ee,L as ht,b as $s,e as Ls}from"./vendor-react-CdqEC2zv.js";import{P as Ps}from"./PageHeader-BJgWMZtw.js";import{L as Ws}from"./ListToolbar-Bl7F3A28.js";import{i as Dt,b as Fs,d as qs,C as $t,H as Vs,g as se,m as Js,c as nt,r as ne,e as He}from"./CountdownTimer-B3nCqJdC.js";import{u as Us}from"./workflows-qyc0ku_5.js";import{g as Hs}from"./useEventHooks-DZaYzE7s.js";import{S as ze}from"./StatusBadge-DkgllZHv.js";import{R as zs}from"./RolePill-BNAP-uK6.js";import{C as it}from"./CopyableId-4Lqlc5cU.js";import{U as Be}from"./UserName-BnLF6yhz.js";import{a2 as Xe,J as Bs,S as Xs,at as Gs,_ as Qs,o as Ys,af as Ge,U as Zs,ai as Ks,aj as tn,a8 as en,au as sn,av as nn,aw as Qt,ax as rn,ay as ke,az as an,K as _e,O as Ce,aA as on,X as ln}from"./vendor-icons-BxuyFxH2.js";import"./constants-BHkpVaqx.js";import"./DataTable-Bir0Xs1p.js";import"./EmptyState-lpUFYfun.js";import"./StickyPagination-DIeYMPPd.js";import"./users-D4DCFPH1.js";const cn={SCHEMA_VALIDATION:"schema_validation"};function dn(e){return typeof e=="object"&&e!==null&&e.code===cn.SCHEMA_VALIDATION&&Array.isArray(e.violations)}function un({escalationId:e}){var f;const s=Ue(),r=ee(),n=Le(),i=(f=s.state)==null?void 0:f[ws],[o,d]=m.useState(!1),[c,a]=m.useState(null),[x,l]=m.useState(!1);if(!i||i.escalationId!==e||x)return null;const u=()=>{l(!0),r(s.pathname,{replace:!0,state:null})},p=async()=>{var N,g,b;d(!0),a(null);try{switch(i.verb){case pt.CANCEL:await ft(`/escalations/${e}/cancel`,{method:"POST"});break;case pt.CLAIM:case pt.CLAIM_SHOW_DETAIL:await ft(`/escalations/${e}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:((N=i.params)==null?void 0:N.durationMinutes)??30})});break;case pt.RELEASE:await ft(`/escalations/${e}/release`,{method:"POST"});break;case pt.RESOLVE:await ft(`/escalations/${e}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:((g=i.params)==null?void 0:g.resolverPayload)??{}})});break;case pt.ESCALATE:await ft(`/escalations/${e}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:(b=i.params)==null?void 0:b.targetRole})});break;default:throw new Error(`Unsupported confirm verb "${i.verb}"`)}n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]}),u()}catch(y){a(y.message)}finally{d(!1)}};return t.jsx(Je,{open:!0,onClose:u,title:"Confirm scan action",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-text-secondary",children:i.prompt}),c&&t.jsx("p",{className:"text-xs text-status-error",children:c}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:u,disabled:o,className:"btn-secondary text-xs",children:"No, go back"}),t.jsx("button",{onClick:p,disabled:o,className:"btn-primary text-xs",children:o?"Working…":"Yes, continue"})]})]})})}const Mt={pending:"rgb(var(--lt-status-queued-graphic))",claimed:"rgb(var(--lt-status-claimed-graphic))",resolved:"rgb(var(--lt-status-success-graphic))",cancelled:"rgb(var(--lt-status-error))"},Ht=4;function Ee({pct:e,place:s,label:r,title:n,emphasis:i}){const o=t.jsx("span",{className:"w-px h-1 bg-text-quaternary/70","aria-hidden":!0}),d=t.jsx("span",{className:`whitespace-nowrap leading-none tabular-nums text-[10px] ${i?"text-text-tertiary":"text-text-quaternary"}`,children:r});return t.jsx("div",{title:n,className:`absolute ${s==="above"?"bottom-0":"top-0"} flex flex-col items-center gap-0 -translate-x-1/2 cursor-help`,style:{left:`${e}%`},children:s==="above"?t.jsxs(t.Fragment,{children:[d,o]}):t.jsxs(t.Fragment,{children:[o,d]})})}function xn({esc:e,className:s=""}){const r=new Date(e.created_at).getTime(),n=e.claimed_at?new Date(e.claimed_at).getTime():null,i=e.status==="resolved",o=e.status==="cancelled"||e.status==="expired",d=i||o,c=Dt(e),a=!!n&&(c||d),x=i&&e.resolved_at?new Date(e.resolved_at).getTime():o?new Date(e.updated_at).getTime():Date.now(),l=Math.max(x-r,1),u=a&&n?Math.max(n-r,0):l,p=a&&n?Math.max(x-n,0):0,f=Math.min(100,Math.max(0,u/l*100)),N=a?Math.max(0,100-f):0,g=i?Mt.resolved:o?Mt.cancelled:Mt.claimed,b=i?"Resolved after":o?"Cancelled after":"In progress",y=Vt(u),_=Vt(l),h=i?`Resolved in ${_} total`:o?`Cancelled after ${_}`:`Open ${_} so far`,C=`Lifecycle bar: blue = time waiting to be claimed, ${i?"green":o?"red":"orange"} = ${b.toLowerCase()} the claim.`;return t.jsxs("div",{className:s,title:C,children:[t.jsx("div",{className:"relative h-2.5 font-mono",children:a&&t.jsx(Ee,{pct:f,place:"above",label:y,title:`Time to claim: ${y}`})}),t.jsxs("div",{className:"flex w-full rounded-full overflow-hidden",style:{height:Ht,backgroundColor:"rgb(var(--lt-surface-sunken))"},title:C,children:[t.jsx("div",{style:{width:`${f}%`,minWidth:Ht,backgroundColor:Mt.pending,opacity:.75},title:`Waiting ${y} — created → claimed`}),a&&N>0&&t.jsx("div",{style:{width:`${N}%`,minWidth:Ht,backgroundColor:g,opacity:.75},title:`${b} ${Vt(p)}`})]}),t.jsx("div",{className:"relative h-2.5 font-mono",children:t.jsx(Ee,{pct:100,place:"below",emphasis:!0,label:_,title:h})})]})}function pn({triage:e,payload:s}){const r=e.confidence??0,n=r>=.8?"text-status-success":r>=.5?"text-status-pending":"text-status-error",i=mn(e.originalData,s);return t.jsxs("div",{className:"space-y-5",children:[e.diagnosis&&t.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:e.diagnosis}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-text-tertiary",children:[e.tool_calls_made!=null&&t.jsxs("span",{children:[e.tool_calls_made," tool call",e.tool_calls_made!==1?"s":""]}),e.tool_calls_made!=null&&t.jsx("span",{className:"text-text-quaternary",children:"·"}),t.jsxs("span",{className:`font-medium ${n}`,children:[Math.round(r*100),"% confidence"]})]}),e.actions_taken&&e.actions_taken.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.actions_taken.map((o,d)=>t.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-2xs
|
|
2
|
+
text-text-secondary`,children:[t.jsx("svg",{className:"w-3 h-3 text-status-success shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),o]},d))}),e.recommendation&&t.jsx("p",{className:"text-2xs text-text-tertiary italic",children:e.recommendation}),i.length>0&&t.jsx("div",{className:"space-y-4 pt-2",children:i.map(o=>t.jsx(fn,{diff:o},o.key))})]})}function mn(e,s){if(!e)return[];const r=[];for(const n of Object.keys(e)){if(n.startsWith("_"))continue;const i=e[n],o=s[n];o!==void 0&&JSON.stringify(i)!==JSON.stringify(o)&&r.push({key:n,label:n.replace(/[_-]/g," "),original:i,corrected:o})}return r}function fn({diff:e}){const s=Ae(e.original),r=Ae(e.corrected);return s!==null&&r!==null?t.jsx("div",{className:"@container",children:t.jsxs("div",{className:"grid grid-cols-1 @form-cols:grid-cols-2 gap-x-8 gap-y-3",children:[t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal",children:"(original)"})]}),t.jsx("p",{className:"text-sm text-text-tertiary leading-relaxed line-through decoration-text-tertiary/30",children:s})]}),t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal text-status-success",children:"(corrected)"})]}),t.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:r})]})]})}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal",children:"(original)"})]}),t.jsx("pre",{className:"text-xs text-text-tertiary font-mono whitespace-pre-wrap leading-relaxed",children:typeof e.original=="object"?JSON.stringify(e.original,null,2):String(e.original)})]}),t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal text-status-success",children:"(corrected)"})]}),t.jsx("pre",{className:"text-xs text-text-primary font-mono whitespace-pre-wrap leading-relaxed",children:typeof e.corrected=="object"?JSON.stringify(e.corrected,null,2):String(e.corrected)})]})]})}function Ae(e){return e==null?"null":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):null}function Q(e,s){const r=s==null?void 0:s.title;if(typeof r=="string"&&r.trim().length>0)return r.trim();const n=e.split(/[_-]+/).filter(Boolean);return n.length<=1?e:n.map(i=>hn(i)?i:i.charAt(0).toUpperCase()+i.slice(1)).join(" ")}function hn(e){return e.length>1&&e===e.toUpperCase()&&/[A-Z]/.test(e)}const B={HELP:"help",DETAILS:"details",TRIAGE:"triage",METADATA:"metadata",CONTEXT:"context",RECORD:"record",ERRORS:"errors"},Qe="lt:escalation:panel:view";function gn(e){try{const s=localStorage.getItem(Qe);if(s&&e.includes(s))return s}catch{}return B.HELP}const bn=new Set(["form_schema"]);function jn({metadata:e,role:s}){const r=Object.entries(e??{}).filter(([n])=>!n.startsWith("_")&&!bn.has(n));return r.length===0?t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No metadata on this escalation."}):t.jsx("dl",{className:"space-y-3.5",children:r.map(([n,i])=>{const o=typeof i=="object"&&i!==null?JSON.stringify(i):String(i),d=we(n,i,s),c=we(n,i);return t.jsxs("div",{className:"group relative",children:[t.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:Q(n)}),t.jsxs("dd",{className:"mt-0.5 flex items-center gap-1",children:[t.jsx("span",{className:"text-xs text-text-primary font-mono break-all flex-1",children:o}),t.jsx(ht,{to:d,title:`Filter this queue: ${n} = ${o}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:t.jsx(Ks,{className:"w-3 h-3"})}),t.jsx(ht,{to:c,title:`Search all queues: ${n} = ${o}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:t.jsx(tn,{className:"w-3 h-3"})})]})]},n)})})}function yn({esc:e,claimed:s,isTerminal:r,isBuilder:n,traceUrl:i}){return t.jsxs("div",{className:"space-y-5",children:[t.jsxs("dl",{className:"space-y-3.5",children:[t.jsx(st,{label:"Status",children:t.jsx(ze,{status:e.status})}),t.jsx(st,{label:"Assigned to Role",children:t.jsx(zs,{role:e.role,size:"md"})}),t.jsxs(st,{label:"Priority",children:["P",e.priority]}),(s||r)&&e.assigned_to&&t.jsx(st,{label:"Claimed By",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium text-text-primary",children:[t.jsx(Zs,{className:"w-3 h-3 shrink-0 text-accent/75"}),t.jsx(Be,{userId:e.assigned_to})]})}),t.jsx(st,{label:"Created",children:t.jsx(Jt,{date:e.created_at})}),(s||r)&&e.claimed_at&&t.jsx(st,{label:"Claimed",children:t.jsx(Jt,{date:e.claimed_at})}),s&&!r&&e.assigned_until&&t.jsx(st,{label:"Time Remaining",children:t.jsx($t,{until:e.assigned_until})}),e.resolved_at&&t.jsx(st,{label:"Completed",children:t.jsx("span",{className:"text-status-success",children:t.jsx(Jt,{date:e.resolved_at})})})]}),n&&t.jsxs(t.Fragment,{children:[t.jsx("hr",{className:"border-surface-border/60"}),t.jsxs("div",{className:"space-y-3.5",children:[t.jsx(it,{label:"Escalation ID",value:e.id}),e.task_id&&t.jsx(it,{label:"Task ID",value:e.task_id,href:`/workflows/tasks/detail/${e.task_id}`}),e.workflow_type&&t.jsx(it,{label:"Workflow Name",value:e.workflow_type,href:`/workflows/executions?entity=${encodeURIComponent(e.workflow_type)}`}),e.workflow_id&&t.jsx(it,{label:"Workflow ID",value:e.workflow_id,href:`/workflows/executions/${e.workflow_id}`}),e.task_queue&&t.jsx(it,{label:"Task Queue",value:e.task_queue,href:`/admin/controlplane?queue=${encodeURIComponent(e.task_queue)}`}),e.origin_id&&e.origin_id!==e.workflow_id&&t.jsx(it,{label:"Origin",value:e.origin_id,href:`/processes/detail/${e.origin_id}`}),e.trace_id&&t.jsx(it,{label:"Trace",value:e.trace_id,href:i?i.replace("{traceId}",e.trace_id):void 0,external:!0})]})]})]})}function Nn({errors:e,schema:s}){const r=n=>{const i=document.querySelector(`[data-field-key="${n}"]`);i&&(i.scrollIntoView({behavior:"smooth",block:"center"}),i.focus({preventScroll:!0}))};return e.length===0?t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No errors to display."}):t.jsxs("div",{className:"space-y-1",role:"alert","aria-live":"polite",children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-wider text-status-error mb-4",children:[e.length," ",e.length===1?"issue":"issues"," to resolve"]}),t.jsx("div",{className:"space-y-1.5",children:e.map(({field:n,message:i})=>{var o;return t.jsxs("button",{onClick:()=>r(n),className:"w-full text-left flex items-start gap-3 px-3 py-2.5 rounded hover:bg-status-error/5 transition-colors group",children:[t.jsx(Ge,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-status-error/60 group-hover:text-status-error transition-colors"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-2xs font-semibold text-text-primary leading-snug",children:Q(n,(o=s==null?void 0:s.properties)==null?void 0:o[n])}),t.jsx("p",{className:"text-2xs text-text-tertiary group-hover:text-text-secondary transition-colors leading-snug mt-0.5",children:i})]})]},n)})}),t.jsx("p",{className:"text-2xs text-text-quaternary mt-4 px-3",children:"Click an issue to scroll to and focus the field."})]})}function vn({esc:e,schema:s,envelope:r,payload:n,resolver:i,triage:o,hasAI:d,claimed:c,claimedByMe:a,isTerminal:x,isBuilder:l,traceUrl:u,open:p,noGutter:f,formErrors:N,activePanel:g,onPanelChange:b}){const y=ee(),_=Object.values(B),[h,C]=m.useState(()=>gn(_)),T=g??h,L=m.useCallback(E=>{try{localStorage.setItem(Qe,E)}catch{}C(E),b==null||b(E)},[b]);m.useEffect(()=>{g&&g!==h&&C(g)},[g]);const $=m.useMemo(()=>Fs(s,{escalation:e,metadata:e.metadata??null,envelope:r,payload:n,resolver:i})??qs({isTerminal:x,status:e.status,claimed:c,claimedByMe:a}),[s,e,r,n,i,x,c,a]),R=m.useCallback(E=>{const A=E.target.closest("a"),S=A==null?void 0:A.getAttribute("href");S!=null&&S.startsWith("/")&&(E.preventDefault(),y(S))},[y]),k=[{id:B.HELP,icon:Xe,label:"Instructions",content:t.jsx(St,{content:$,onClick:R})},{id:B.DETAILS,icon:Bs,label:"Details",content:t.jsx(yn,{esc:e,claimed:c,isTerminal:x,isBuilder:l,traceUrl:u})},...d&&o?[{id:B.TRIAGE,icon:Xs,label:"AI Analysis",content:t.jsx(pn,{triage:o,payload:n??{}})}]:[],{id:B.METADATA,icon:Gs,label:"Metadata",content:t.jsx(jn,{metadata:e.metadata,role:e.role})},{id:B.CONTEXT,icon:Qs,label:"Context",content:t.jsxs("div",{className:"space-y-5",children:[r!=null&&t.jsx(kt,{data:r,label:"Input Envelope"}),n!=null&&t.jsx(kt,{data:n,label:"Escalation Context"}),i!=null&&t.jsx(kt,{data:i,label:"Resolver Payload"}),r==null&&n==null&&i==null&&t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No context on this escalation."})]})},...l?[{id:B.RECORD,icon:Ys,label:"Record",content:t.jsx(kt,{data:e,label:"Escalation Record"})}]:[],...N&&N.length>0?[{id:B.ERRORS,icon:(({className:E})=>t.jsx(Ge,{className:`${E??""} text-status-error`})),label:"Errors",content:t.jsx(Nn,{errors:N,schema:s})}]:[]];return t.jsx(ks,{open:p,width:384,className:"h-full",children:t.jsx("div",{className:`h-full${f?"":" pl-6"}`,children:t.jsxs("div",{className:"h-full flex flex-col bg-surface-hover",children:[t.jsx("div",{className:"shrink-0 pt-2 pb-0 flex justify-center",children:t.jsx(xn,{esc:e,className:"w-[80%]"})}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(_s,{views:k,activeId:T,onViewChange:L,stickyClassName:"h-full min-h-0"})})]})})})}function wn(e,s){if(typeof e!="string"||!s)return[];const r=e.indexOf(".");if(r===-1)return[];const n=s[e.slice(0,r)];if(!n||typeof n!="object")return[];let i=n;for(const o of e.slice(r+1).split("."))if(i=i[o],i===void 0)return[];return Array.isArray(i)?i:[]}function kn(e,s,r){if((s==null?void 0:s["x-lt-widget"])!=="checklist"||s["x-lt-require-all"]!==!0)return;const i=wn(s["x-lt-source"],r).filter(c=>c.required!==!1);if(i.length===0)return;const o=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},d=i.filter(c=>!o[c.id]).length;if(d!==0)return`${d} of ${i.length} checks incomplete`}function _n(e,s){const r=s==null?void 0:s.type;if(typeof r=="string"&&!(e==null||e===""))switch(r){case"string":return typeof e=="string"?void 0:"Expected text";case"number":return typeof e=="number"&&Number.isFinite(e)?void 0:"Expected a number";case"integer":return typeof e=="number"&&Number.isInteger(e)?void 0:"Expected a whole number";case"boolean":return typeof e=="boolean"?void 0:"Expected true or false";case"array":return Array.isArray(e)?void 0:"Expected a list";case"object":return typeof e=="object"&&!Array.isArray(e)?void 0:"Expected an object";default:return}}function Cn(e,s,r){if(!s)return;const n=s.enum;if(Array.isArray(n)&&n.length>0&&e!==void 0&&e!==null&&e!==""&&!n.includes(e))return`Must be one of: ${n.map(i=>String(i)).join(", ")}`;if(typeof e=="string"){const i=e.trim();if(i==="")return;const o=mt(s.minLength,s["x-lt-min-length"],r);if(o!==void 0&&i.length<o)return`Minimum ${o} character${o===1?"":"s"}`;const d=mt(s.maxLength,s["x-lt-max-length"],r);if(d!==void 0&&i.length>d)return`Maximum ${d} characters (${i.length} entered)`;const c=s.pattern;if(c)try{if(!new RegExp(c).test(i))return s["x-lt-pattern-error"]??"Invalid format"}catch{}const a=s.format;if(a==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i))return"Enter a valid email address";if(a==="uri"&&!/^https?:\/\/.+/.test(i))return"Enter a valid URL"}if(typeof e=="number"){const i=mt(s.minimum,s["x-lt-minimum"],r),o=mt(s.exclusiveMinimum,void 0,r),d=mt(s.maximum,s["x-lt-maximum"],r),c=mt(s.exclusiveMaximum,void 0,r);if(i!==void 0&&e<i)return`Minimum value is ${i}`;if(o!==void 0&&e<=o)return`Must be greater than ${o}`;if(d!==void 0&&e>d)return`Maximum value is ${d}`;if(c!==void 0&&e>=c)return`Must be less than ${c}`}}function mt(e,s,r){if(typeof e=="number")return e;if(typeof s=="string"&&r){const n=s.indexOf(".");if(n!==-1){const i=s.slice(0,n),o=s.slice(n+1),d=r[i];if(d&&typeof d=="object"){const c=o.split(".");let a=d;for(const x of c)if(a=a[x],a===void 0)break;if(typeof a=="number")return a;if(typeof a=="string"){const x=Number(a);if(!Number.isNaN(x))return x}}}}}function Ye(e,s,r,n,i){if(!n)return;if(r){if(e==null||typeof e=="boolean"&&!e||typeof e=="string"&&e.trim()==="")return"Required";if(typeof e=="object"&&!Array.isArray(e)&&e!==null){const c=Object.values(e);if(c.length===0||c.every(a=>!a))return"Required"}}const o=_n(e,s);if(o)return o;const d=kn(e,s,i);return d||Cn(e,s,i)}function Te(e){return e!=null&&e!==""&&e!==!1&&e!==0}function En(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Re(e,s){const r=e.indexOf("."),n=r===-1?e:e.slice(0,r);if(!Vs.includes(n))return{known:!1,value:void 0};const i=s[n];if(r===-1)return{known:!0,value:i};try{return{known:!0,value:se(i,e.slice(r+1))}}catch{return{known:!0,value:void 0}}}function Ze(e,s){if(typeof e!="string"||e.length===0||!s)return!0;const r=e.startsWith("!"),n=r?e.slice(1):e,i=n.indexOf("!="),o=n.indexOf("=");if(i!==-1||o!==-1&&o!==i+1){const a=i!==-1&&(o===-1||i<o),x=a?i:o,l=n.slice(0,x).trim(),u=n.slice(x+(a?2:1)).trim(),{known:p,value:f}=Re(l,s);if(!p)return!0;const N=En(f)===u,g=a?!N:N;return r?!g:g}const{known:d,value:c}=Re(n,s);return d?r?!Te(c):Te(c):!0}function Ke(e,s,r){if(!e)return[];const n=e.properties??{},i=new Set(e.required??[]),o={...r??{},resolver:s},d=[];for(const[c,a]of Object.entries(n)){if(!Ze(a["x-lt-showIf"],o))continue;const x=Ye(s[c],a,i.has(c),!0,o);x&&d.push({field:c,message:x})}return d}function Yt(e,s){let r;try{r=JSON.parse(e)}catch{return{payload:null,errors:[],parseError:"Invalid JSON"}}const n=r._form_schema;if(n){const d=Ke(n,r,s);if(d.length>0)return{payload:null,errors:d,parseError:null}}const{_form_schema:i,...o}=r;return{payload:Js(o,n),errors:[],parseError:null}}function An(e){const{mode:s,activeView:r,onActiveViewChange:n,onClaim:i,claimPending:o,claimNudge:d,workflowType:c,json:a,onResolve:x,resolvePending:l,resolveError:u,requestTriage:p,triageNotes:f,onRelease:N,releasePending:g,onCancel:b,assignedTo:y,assignedUntil:_,onSubmitAttempt:h,onValidationErrors:C,escalationContext:T,labels:L={},submitBlocked:$,submitBlockedMessage:R,actingName:k,badgePrompt:E}=e,A=qe(),[S,q]=m.useState("30"),[P,J]=m.useState(0),[Y,V]=m.useState(""),v=S==="custom",O=m.useCallback(D=>J(D),[]),w=!!$&&!p;if(s==="terminal")return null;const M=()=>{const D=v?P:parseInt(S);!D||D<=0||i(D)},F=()=>{if(V(""),p){const H={_lt:{needsTriage:!0}};f.trim()&&(H.notes=f.trim()),x(H);return}const D=Yt(a,T);if(D.parseError){V(D.parseError);return}if(D.errors.length>0){h==null||h(),C==null||C(D.errors);return}x(D.payload)},Z=D=>`text-xs transition-colors ${D?"text-accent font-medium":"text-text-tertiary hover:text-accent"}`;return t.jsxs("div",{className:"shrink-0 h-[80px] bg-surface/95 backdrop-blur-sm border-t border-surface-border -ml-10 pl-10 pr-10 pt-3 pb-5","data-testid":"escalation-action-bar",children:[s==="available"&&t.jsxs("div",{"data-testid":"claim-bar",children:[t.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[A.map(D=>t.jsx("button",{onClick:()=>{q(D.value),J(0)},className:Z(!v&&S===D.value),children:D.label},D.value)),t.jsx("button",{onClick:()=>q("custom"),className:Z(v),children:"Other"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:b,className:"text-xs text-text-tertiary hover:text-status-error transition-colors",children:L.cancel??"Cancel escalation"}),t.jsx("div",{className:"flex-1"}),v&&t.jsx(Ve,{onChange:O,compact:!0,autoFocus:!0}),t.jsx("button",{onClick:M,disabled:o||v&&P<=0,className:`btn-primary text-xs ${d?"animate-[field-shake_0.4s_ease-in-out]":""}`,"data-testid":"claim-button",children:o?"Claiming...":L.claim??"Claim"},d)]})]}),s==="claimed_by_other"&&t.jsxs("div",{className:"flex items-center gap-4","data-testid":"claimed-other-bar",children:[t.jsxs("p",{className:"text-sm text-text-secondary",children:["Claimed by ",t.jsx("span",{className:"font-medium text-text-primary",children:y?t.jsx(Be,{userId:y}):"unknown"})]}),_&&t.jsx($t,{until:_}),u&&t.jsx("span",{className:"text-xs text-status-error",children:u.message}),E&&t.jsx("p",{className:"text-xs text-text-tertiary","data-testid":"badge-prompt",children:"If this is your claim, scan your badge."})]}),s==="claimed_by_me"&&t.jsxs("div",{"data-testid":"action-bar",children:[t.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[t.jsx("button",{onClick:()=>n("resolve"),className:Z(r==="resolve"),children:c?"Resolve":"Acknowledge"}),t.jsx("button",{onClick:()=>n("release"),className:`text-xs transition-colors ${r==="release"?"text-status-error font-medium":"text-text-tertiary hover:text-status-error"}`,children:L.release??"Release"}),t.jsx("button",{onClick:b,className:"text-xs transition-colors text-text-tertiary hover:text-status-error",children:L.cancel??"Cancel"})]}),r==="resolve"&&t.jsxs("div",{className:"flex items-center gap-4",children:[k&&t.jsxs("p",{className:"text-sm text-text-secondary","data-testid":"acting-claim-note",children:["Claimed by you ",t.jsxs("span",{className:"font-medium text-text-primary",children:["(",k,")"]})]}),k&&_&&t.jsx($t,{until:_}),t.jsx("div",{className:"flex-1"}),Y&&t.jsx("span",{className:"text-xs text-status-error",children:Y}),u&&t.jsx("span",{className:"text-xs text-status-error",children:u.message}),w&&R&&t.jsx("span",{className:"text-xs text-status-pending","data-testid":"submit-guard-message",children:R}),t.jsx("button",{onClick:F,disabled:l||w,className:"btn-primary text-xs",children:l?c?"Submitting...":"Acknowledging...":p?"Send to Triage":L.submit??(c?"Submit":"Acknowledge")})]}),r==="release"&&t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"text-xs text-text-secondary",children:"Release back to pool?"}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:()=>n("resolve"),className:"btn-secondary text-xs",children:"Back"}),t.jsx("button",{onClick:N,disabled:g,className:"btn-primary text-xs bg-status-error hover:bg-status-error/80",children:g?"Releasing...":"Yes, Release"})]})]})]})}function zt({children:e}){return t.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:e})}function Tn({payload:e,isTerminal:s,resolverPayload:r,onRetryTriage:n,isRetrying:i}){const o=e.title,d=e.summary,c=e.diagnosis,a=e.tool_calls_made,x=e.result,l=r==null?void 0:r._lt,u=(l==null?void 0:l.triaged)===!0,p=l==null?void 0:l.triageWorkflowId,f=s&&u,[N,g]=m.useState(!1);return f?t.jsxs("div",{className:"rounded-md border border-status-success/30 bg-surface-raised",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4 text-status-success shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm3.36 4.65a.5.5 0 00-.72 0L7 9.29 5.36 7.65a.5.5 0 10-.72.7l2 2a.5.5 0 00.72 0l4-4a.5.5 0 000-.7z"})}),t.jsx("span",{className:"text-xs font-medium text-status-success",children:"Resolved by AI Triage"})]}),typeof a=="number"&&t.jsxs("span",{className:"text-2xs font-mono px-2 py-0.5 rounded-full bg-status-success/10 text-status-success",children:[a," tool calls used"]})]}),t.jsxs("div",{className:"px-4 py-4 space-y-4",children:[o&&t.jsx("p",{className:"text-sm font-medium text-text-primary",children:o}),c&&t.jsxs("div",{children:[t.jsx(zt,{children:"Triage diagnosis"}),t.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:t.jsx(Ut,{content:c})})]}),t.jsx("div",{className:"flex items-center gap-3",children:p&&t.jsx(ht,{to:`/workflows/executions/${p}`,className:"text-2xs text-accent hover:underline",children:"View triage execution"})})]})]}):t.jsxs("div",{className:"rounded-md border border-status-warning/30 bg-surface-raised",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4 text-status-warning shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm0 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 4zm0 7a.75.75 0 100-1.5.75.75 0 000 1.5z"})}),t.jsx("span",{className:"text-xs font-medium text-status-warning",children:"Tool Rounds Exhausted"})]}),typeof a=="number"&&t.jsxs("span",{className:"text-2xs font-mono px-2 py-0.5 rounded-full bg-status-warning/10 text-status-warning",children:[a," tool calls used"]})]}),t.jsxs("div",{className:"px-4 py-4 space-y-4",children:[o&&t.jsx("p",{className:"text-sm font-medium text-text-primary",children:o}),d&&t.jsxs("div",{children:[t.jsx(zt,{children:"What happened"}),t.jsx("div",{className:"text-xs text-text-secondary leading-relaxed",children:t.jsx(Ut,{content:d})})]}),c&&t.jsxs("div",{children:[t.jsx(zt,{children:"What went wrong"}),t.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:t.jsx(Ut,{content:c})})]}),x!=null&&t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>g(!N),className:"flex items-center gap-1 text-2xs font-semibold uppercase tracking-widest text-text-tertiary hover:text-text-secondary transition-colors",children:[t.jsx("svg",{className:`w-3 h-3 transition-transform ${N?"rotate-90":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M4.5 2l4 4-4 4"})}),"Partial results"]}),N&&t.jsx("div",{className:"mt-2",children:t.jsx(kt,{data:x,defaultMode:"tree"})})]}),n&&!s&&t.jsx("div",{className:"pt-2",children:t.jsxs("button",{onClick:n,disabled:i,className:"inline-flex items-center gap-2 px-4 py-2 text-xs font-medium bg-accent text-text-inverse rounded-md hover:bg-accent/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 14 14",fill:"currentColor",children:t.jsx("path",{d:"M7 1a6 6 0 100 12A6 6 0 007 1zm2.5 6.5l-3.5 2V5.5l3.5 2z"})}),i?"Sending to triage...":"Retry with AI Triage"]})})]})]})}function Oe(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function ts({src:e,escalation:s,schema:r,onResolve:n,onEscalate:i,submitAttempted:o,fill:d}){const c=m.useRef(null),a=m.useRef("");m.useEffect(()=>{try{const l=new URL(e);a.current=l.origin}catch{a.current=""}},[e]);const x=m.useCallback(()=>{const l=c.current;if(!(l!=null&&l.contentWindow)||!a.current)return;const p={type:"lt:init",escalation:{id:s.id,type:s.type,subtype:s.subtype,description:s.description,status:s.status,priority:s.priority,role:s.role,workflow_type:s.workflow_type,envelope:Oe(s.envelope),metadata:s.metadata??null,escalation_payload:Oe(s.escalation_payload)},schema:r};l.contentWindow.postMessage(p,a.current)},[s,r]);return m.useEffect(()=>{const l=u=>{if(u.origin!==a.current)return;const p=u.data;if(!(!p||typeof p!="object"||typeof p.type!="string"))switch(p.type){case"lt:ready":x();break;case"lt:submit":p.payload&&typeof p.payload=="object"&&n(p.payload);break;case"lt:escalate":typeof p.target=="string"&&p.target&&i(p.target);break;case"lt:resize":{const f=c.current;f&&typeof p.height=="number"&&p.height>0&&(f.style.height=`${Math.min(p.height,2e3)}px`);break}}};return window.addEventListener("message",l),()=>window.removeEventListener("message",l)},[x,n,i]),m.useEffect(()=>{if(!o)return;const l=c.current;l!=null&&l.contentWindow&&a.current&&l.contentWindow.postMessage({type:"lt:validate"},a.current)},[o]),d?t.jsx("div",{className:"absolute inset-0 overflow-hidden",children:t.jsx("iframe",{ref:c,src:e,sandbox:"allow-scripts allow-same-origin allow-forms allow-pointer-lock allow-downloads",className:"w-full h-full border-0 block",title:"HITL Viewport",onLoad:x})}):t.jsx("div",{className:"rounded-md border border-surface-border overflow-hidden bg-white",children:t.jsx("iframe",{ref:c,src:e,sandbox:"allow-scripts allow-same-origin allow-forms allow-pointer-lock allow-downloads",className:"w-full border-0",style:{minHeight:"600px"},title:"HITL Viewport",onLoad:x})})}function W({children:e,isRequired:s,htmlFor:r}){return t.jsxs("label",{htmlFor:r,className:"block text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[e,s&&t.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]})}function X({id:e,children:s}){return t.jsx("p",{id:e,className:"text-2xs text-text-tertiary mt-0.5 leading-snug",children:s})}function ot({error:e,id:s}){return e?t.jsx("p",{id:s,role:"alert",className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:e}):null}function Nt(e){return e?"input text-sm w-full mt-1 border-status-error/50 focus:border-status-error animate-[field-shake_0.4s_ease-in-out]":"input text-sm w-full mt-1"}function Rn(e){return e?"select text-sm mt-1 min-w-[min(16rem,100%)] max-w-full border-status-error/50 focus:border-status-error animate-[field-shake_0.4s_ease-in-out]":"select text-sm mt-1 min-w-[min(16rem,100%)] max-w-full"}function On({fieldKey:e,value:s,onChange:r,schema:n,isRequired:i}){const o=m.useRef(null),d=(n==null?void 0:n.accept)??void 0,c=Q(e,n),a=n==null?void 0:n.description,x=m.useCallback(u=>{var N;const p=(N=u.target.files)==null?void 0:N[0];if(!p)return;const f=new FileReader;f.onload=()=>{typeof f.result=="string"&&r(f.result)},f.readAsDataURL(p)},[r]),l=s.startsWith("data:");return t.jsxs("div",{children:[t.jsx(W,{isRequired:i,children:c}),a&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:a}),t.jsxs("div",{className:"mt-1",children:[t.jsx("input",{ref:o,type:"file",accept:d,onChange:x,className:"hidden"}),t.jsx("button",{type:"button",onClick:()=>{var u;return(u=o.current)==null?void 0:u.click()},className:"btn-secondary text-xs px-3 py-1.5",children:l?"Replace file":"Choose file"}),l&&t.jsx("span",{className:"ml-2 text-xs text-status-success",children:"File attached"})]})]})}function In({fieldKey:e,value:s,onChange:r,schema:n,isRequired:i}){const o=Q(e,n),d=n==null?void 0:n.description,c=(n==null?void 0:n["x-lt-language"])??"",a=m.useCallback(x=>{if(x.key==="Tab"){x.preventDefault();const l=x.currentTarget,u=l.selectionStart,p=l.selectionEnd,f=s.substring(0,u)+" "+s.substring(p);r(f),requestAnimationFrame(()=>{l.selectionStart=l.selectionEnd=u+2})}},[s,r]);return t.jsxs("div",{children:[t.jsxs(W,{isRequired:i,children:[o,c&&t.jsx("span",{className:"ml-2 text-text-tertiary/60 normal-case font-normal",children:c})]}),d&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:d}),t.jsx("textarea",{value:s,onChange:x=>r(x.target.value),onKeyDown:a,className:"input w-full mt-1 font-mono text-xs leading-relaxed",rows:10,spellCheck:!1})]})}function Mn({fieldKey:e,value:s,onChange:r,schema:n,isRequired:i}){const o=m.useRef(null),[d,c]=m.useState(!1),a=Q(e,n),x=n==null?void 0:n.description;m.useEffect(()=>{const g=o.current;if(!g)return;const b=g.getContext("2d");if(b&&(b.lineWidth=2,b.lineCap="round",b.strokeStyle="#1E1535",s&&s.startsWith("data:"))){const y=new Image;y.onload=()=>b.drawImage(y,0,0),y.src=s}},[]);const l=m.useCallback(g=>{const b=o.current,y=b.getBoundingClientRect(),_=y.width>0?b.width/y.width:1,h=y.height>0?b.height/y.height:1;return"touches"in g?{x:(g.touches[0].clientX-y.left)*_,y:(g.touches[0].clientY-y.top)*h}:{x:(g.clientX-y.left)*_,y:(g.clientY-y.top)*h}},[]),u=m.useCallback(g=>{var _;c(!0);const b=(_=o.current)==null?void 0:_.getContext("2d");if(!b)return;const y=l(g);b.beginPath(),b.moveTo(y.x,y.y)},[l]),p=m.useCallback(g=>{var _;if(!d)return;const b=(_=o.current)==null?void 0:_.getContext("2d");if(!b)return;const y=l(g);b.lineTo(y.x,y.y),b.stroke()},[d,l]),f=m.useCallback(()=>{c(!1);const g=o.current;g&&r(g.toDataURL("image/png"))},[r]),N=m.useCallback(()=>{const g=o.current;if(!g)return;const b=g.getContext("2d");b&&(b.clearRect(0,0,g.width,g.height),r(""))},[r]);return t.jsxs("div",{children:[t.jsx(W,{isRequired:i,children:a}),x&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:x}),t.jsx("div",{className:"mt-1 max-w-[25rem] border border-surface-border rounded-md overflow-hidden bg-white",children:t.jsx("canvas",{ref:o,width:400,height:150,className:"w-full cursor-crosshair touch-none",onMouseDown:u,onMouseMove:p,onMouseUp:f,onMouseLeave:f,onTouchStart:u,onTouchMove:p,onTouchEnd:f})}),t.jsx("button",{type:"button",onClick:N,className:"mt-1 text-2xs text-text-tertiary hover:text-accent transition-colors",children:"Clear"})]})}function Dn({fieldKey:e,value:s,onChange:r,schema:n,isRequired:i}){const o=Q(e,n),d=n==null?void 0:n.description;return t.jsxs("div",{children:[t.jsx(W,{isRequired:i,children:o}),d&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:d}),t.jsx("textarea",{value:s,onChange:c=>r(c.target.value),className:"input w-full mt-1 text-sm leading-relaxed",rows:8,placeholder:"Supports plain text. Markdown formatting is preserved."})]})}function Sn({fieldKey:e,value:s,onChange:r,schema:n,isRequired:i}){const[o,d]=m.useState("write"),c=Q(e,n),a=n==null?void 0:n.description;return(n==null?void 0:n.readOnly)===!0?t.jsx(St,{content:s,className:"my-1"}):t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(W,{isRequired:i,children:c}),t.jsx("div",{className:"flex items-center gap-0.5",children:["write","preview"].map(l=>t.jsx("button",{type:"button",onClick:()=>d(l),className:`px-2 py-0.5 text-2xs rounded transition-colors ${o===l?"bg-accent/10 text-accent font-semibold":"text-text-quaternary hover:text-text-secondary"}`,children:l==="write"?"Write":"Preview"},l))})]}),a&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:a}),o==="write"?t.jsx("textarea",{value:s,onChange:l=>r(l.target.value),className:"input w-full mt-1 text-sm font-mono leading-relaxed",rows:10,placeholder:"Write markdown — headings, lists, tables, code blocks, and links all render."}):t.jsx("div",{className:"mt-1 px-3 py-2 border border-surface-border rounded min-h-[120px]",children:s.trim()?t.jsx(St,{content:s}):t.jsx("p",{className:"text-xs text-text-quaternary italic",children:"Nothing to preview."})})]})}const $n=28;function Ln({fieldKey:e,value:s,onChange:r,schema:n,escalationContext:i,isRequired:o,submitAttempted:d,error:c}){const a=n==null?void 0:n["x-lt-source"],x=(n==null?void 0:n["x-lt-require-all"])===!0,l=[];if(a&&i){const h=a.indexOf(".");if(h!==-1){const C=a.slice(0,h),T=a.slice(h+1);try{const L=se(i[C],T);Array.isArray(L)&&l.push(...L)}catch{}}}let u={};try{s&&(u=JSON.parse(s))}catch{}const p=h=>r(JSON.stringify({...u,[h]:!u[h]})),f=Q(e,n),N=n==null?void 0:n.description;if(l.length===0)return t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"No checklist items. Provide checklist_items in the escalation envelope or metadata."}),c&&t.jsx("p",{className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:c})]});const g=n==null?void 0:n["x-lt-variant"],b=g==="chips"||g==="rows"?g:x||l.some(h=>h.label.length>$n)?"rows":"chips",y=l.filter(h=>u[h.id]).length,_=(l.find(h=>!u[h.id]&&h.required!==!1)??l[0]).id;return t.jsxs("div",{role:"group","aria-label":f,"aria-required":o||void 0,"aria-invalid":c?!0:void 0,children:[t.jsx(W,{isRequired:o,children:f}),N&&t.jsx(X,{children:N}),b==="chips"?t.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:l.map(h=>{const C=u[h.id]??!1,T=!C&&!!d&&y===0&&(h.required||o);return t.jsxs("label",{className:`inline-flex items-center gap-1.5 cursor-pointer select-none px-3.5 py-2 text-sm border transition-colors rounded-[var(--lt-radius-field)] ${C?"bg-accent border-accent text-text-inverse":T?"bg-surface-field border-status-error/60 text-status-error":"bg-surface-field border-surface-field-border text-text-secondary hover:border-accent hover:text-text-primary"}`,children:[t.jsx("input",{type:"checkbox",checked:C,onChange:()=>p(h.id),className:"sr-only","data-testid":`checklist-item-${h.id}`,...h.id===_?{"data-field-key":e}:{}}),C&&t.jsx(en,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:2.5}),h.label]},h.id)})}):t.jsx("div",{className:"space-y-2.5 mt-2",children:l.map(h=>{const C=u[h.id]??!1,T=!C&&!!d&&(x?h.required!==!1:y===0&&(h.required||o));return t.jsxs("label",{className:`flex items-start gap-3 cursor-pointer group select-none rounded px-2 py-1 -mx-2 transition-colors ${T?"bg-status-error/5":"hover:bg-surface-hover"}`,children:[t.jsx("input",{type:"checkbox",checked:C,onChange:()=>p(h.id),className:`mt-0.5 w-3.5 h-3.5 shrink-0 rounded ${T?"accent-status-error":"accent-accent"}`,"data-testid":`checklist-item-${h.id}`,...h.id===_?{"data-field-key":e}:{}}),t.jsxs("span",{className:`text-sm leading-snug transition-colors ${T?"text-status-error":"text-text-secondary group-hover:text-text-primary"}`,children:[h.label,h.required&&t.jsx("span",{className:`ml-0.5 text-2xs ${T?"text-status-error":"text-text-quaternary"}`,children:"*"})]})]},h.id)})}),t.jsx("p",{className:"text-2xs text-text-quaternary mt-3 tabular-nums",children:b==="chips"?t.jsxs(t.Fragment,{children:[y," selected",o&&y===0&&!!d&&t.jsx("span",{className:"ml-1 text-text-quaternary/60",children:"(check at least one)"})]}):t.jsxs(t.Fragment,{children:[y," / ",l.length," confirmed",x?t.jsxs("span",{className:"ml-1 text-text-quaternary/60",children:["(all required",l.some(h=>h.required===!1)?" except optional":"",")"]}):o&&y===0&&!!d&&t.jsx("span",{className:"ml-1 text-text-quaternary/60",children:"(at least one required)"})]})}),c&&t.jsx("p",{role:"alert",className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:c})]})}const Pn=/\.(png|jpe?g|gif|webp|avif|bmp|svg)(\?.*)?$/i;function Wn(e){var n,i,o,d;const s=e.trim();if(!s)return{kind:"none"};const r=(i=(n=/^data:([^;,]+)[;,]/.exec(s))==null?void 0:n[1])==null?void 0:i.toLowerCase();if(r)return r.startsWith("image/")?{kind:"image",src:s}:{kind:"file",href:s,label:r==="application/pdf"?"PDF":r,isData:!0};if(/^https?:\/\//i.test(s)){if(Pn.test(s))return{kind:"image",src:s};const c=(d=(o=/\.([a-z0-9]{2,5})(\?.*)?$/i.exec(s))==null?void 0:o[1])==null?void 0:d.toUpperCase();return{kind:"file",href:s,label:c??"attachment",isData:!1}}return{kind:"none"}}function Ie({fieldKey:e,value:s,schema:r}){const[n,i]=m.useState(!1),o=Wn(s??""),d=e.replace(/[_-]/g," "),c=r==null?void 0:r.description,a=t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary",children:d}),c&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:c})]});return o.kind==="none"?t.jsxs("div",{children:[a,t.jsx("p",{className:"text-xs text-text-quaternary italic mt-1",children:"No attachment"})]}):o.kind==="image"?t.jsxs("div",{children:[a,t.jsxs("div",{className:"mt-1",children:[t.jsx("button",{type:"button",onClick:()=>i(!0),className:"block rounded-[0.125em] border border-surface-border overflow-hidden hover:border-accent transition-colors",title:"View full size",children:t.jsx("img",{src:o.src,alt:e.replace(/[_-]/g," "),className:"max-h-48 max-w-full object-contain","data-testid":`attachment-image-${e}`})}),n&&t.jsx("div",{className:"fixed inset-0 z-[100] bg-text-primary/60 backdrop-blur-sm flex items-center justify-center p-8 cursor-zoom-out",onClick:()=>i(!1),role:"dialog","aria-modal":"true","aria-label":`${d} — full size`,children:t.jsx("img",{src:o.src,alt:d,className:"max-h-[90vh] max-w-[90vw] object-contain"})})]})]}):t.jsxs("div",{children:[a,t.jsx("div",{className:"mt-1",children:t.jsxs("a",{href:o.href,...o.isData?{download:`${e}.${o.label==="PDF"?"pdf":"bin"}`}:{target:"_blank",rel:"noopener noreferrer"},className:"inline-flex items-center gap-1.5 text-xs text-accent hover:text-accent-hover transition-colors","data-testid":`attachment-link-${e}`,children:[t.jsx(sn,{className:"w-3.5 h-3.5",strokeWidth:1.5}),o.isData?`Download ${o.label}`:`Open ${o.label}`,o.isData?t.jsx(nn,{className:"w-3 h-3",strokeWidth:1.5}):t.jsx(Qt,{className:"w-3 h-3",strokeWidth:1.5})]})})]})}function Fn({fieldKey:e,schema:s,escalationContext:r}){const n=(s==null?void 0:s["x-lt-href"])??"",i=n&&r?nt(n,r):n,o=(s==null?void 0:s.title)??(s==null?void 0:s.description)??"Open",d=s==null?void 0:s.description,c=i.startsWith("/"),a=!i.trim();return t.jsxs("div",{"data-field-key":e,children:[t.jsx(W,{children:o}),d&&t.jsx(X,{children:d}),t.jsx("div",{className:"mt-1",children:a?t.jsx("span",{className:"text-xs text-text-quaternary italic",children:"No link configured"}):c?t.jsxs(ht,{to:i,className:"inline-flex items-center gap-1 text-xs text-accent hover:text-accent-hover transition-colors","data-testid":`link-widget-${e}`,children:[o,t.jsx(Qt,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}):t.jsxs("a",{href:i,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-accent hover:text-accent-hover transition-colors","data-testid":`link-widget-${e}`,children:[o,t.jsx(Qt,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]})})]})}function es({to:e,className:s=""}){return t.jsxs(ht,{to:e,title:"View details",tabIndex:-1,className:`inline-flex items-center justify-center w-6 h-6 shrink-0 rounded border border-surface-border text-accent/70 hover:text-accent hover:border-accent/60 hover:bg-accent/5 transition-colors ${s}`,children:[t.jsx(rn,{className:"w-3.5 h-3.5",strokeWidth:2}),t.jsx("span",{className:"sr-only",children:"View details"})]})}const Me="—";function qn(e,s){if(!e||!s)return"";const r=e.indexOf(".");if(r===-1)return"";const n=e.slice(0,r),i=e.slice(r+1);try{const o=se(s[n],i);return typeof o=="string"?o:""}catch{return""}}function Vn(e,s){if(!e||e===Me)return Me;if(s==="age"){const r=new Date(e);return Number.isNaN(r.getTime())?e:Kt(e)}return e}function Jn({fieldKey:e,schema:s,escalationContext:r}){const n=s==null?void 0:s["x-lt-source"],i=(s==null?void 0:s["x-lt-fields"])??[],o=(s==null?void 0:s.title)??"Linked escalation",d=s==null?void 0:s.description,c=qn(n,r),{data:a,isLoading:x,isError:l}=Pe(c);return t.jsxs("div",{"data-field-key":e,children:[t.jsx(W,{children:o}),d&&t.jsx(X,{children:d}),t.jsx("div",{className:"mt-1",children:!c||l?t.jsx("p",{className:"text-xs text-text-quaternary italic","data-testid":`escalation-widget-empty-${e}`,children:"No linked record"}):x?t.jsx(Hn,{}):a?t.jsx(Un,{esc:a,fields:i,fieldKey:e}):t.jsx("p",{className:"text-xs text-text-quaternary italic",children:"No linked record"})})]})}function Un({esc:e,fields:s,fieldKey:r}){if(!e)return null;const n=ne(e);return t.jsxs("div",{className:"border-l-2 border-accent-faint pl-3 py-2 space-y-2","data-testid":`escalation-widget-card-${r}`,children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:"text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[e.type,e.subtype&&e.subtype!==e.type?` · ${e.subtype}`:""]}),t.jsx(ze,{status:e.status})]}),e.description&&t.jsx("p",{className:"text-xs text-text-primary leading-snug",children:e.description}),s.length>0&&t.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-0.5",children:s.map(i=>{const o=nt(i.value,n),d=Vn(o,i.format);return t.jsxs("div",{className:"contents",children:[t.jsx("dt",{className:"text-2xs text-text-tertiary whitespace-nowrap",children:i.label}),t.jsx("dd",{className:"text-2xs text-text-primary",children:d})]},i.label)})}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("span",{className:"text-2xs text-text-quaternary",children:[e.role," · ",Kt(e.created_at)]}),t.jsx(es,{to:`/escalations/detail/${e.id}`})]})]})}function Hn(){return t.jsxs("div",{className:"border-l-2 border-accent-faint pl-3 py-2 space-y-2 animate-pulse",children:[t.jsx("div",{className:"h-3 w-32 bg-surface-sunken rounded"}),t.jsx("div",{className:"h-3 w-48 bg-surface-sunken rounded"}),t.jsx("div",{className:"h-3 w-24 bg-surface-sunken rounded"})]})}function zn(e,s){if(!e)return{};const r={};for(const[n,i]of Object.entries(e))r[n]=typeof i=="string"?nt(i,s):i;return r}function ss(e,s,r){const n=zn(e.facets,s),i={role:e.role,status:e.status??"pending",facets:n,limit:e.limit,enabled:!!(e.role||Object.keys(n).length)};return e.assigned==="me"?{...i,assigned_to:r,available:!1,enabled:i.enabled&&!!r}:e.assigned==="any"?i:{...i,available:e.available??!0}}const Bn=[{label:"Description",value:"{{escalation.description}}"},{label:"Role",value:"{{escalation.role}}"},{label:"Age",value:"{{escalation.created_at}}",format:"age"}],De="—";function Xn(e,s){if(!e||e===De)return De;if(s==="age"){const r=new Date(e);return Number.isNaN(r.getTime())?e:Kt(e)}return e}function Zt(e,s){return typeof e=="string"?nt(e,s):Array.isArray(e)?e.map(r=>Zt(r,s)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,n])=>[r,Zt(n,s)])):e}function Gn({fieldKey:e,schema:s,escalationContext:r}){const n=(s==null?void 0:s["x-lt-query"])??{},i=(s==null?void 0:s["x-lt-columns"])??Bn,o=(s==null?void 0:s["x-lt-actions"])??[],d=(s==null?void 0:s.title)??"Related items",c=s==null?void 0:s.description,a=r??{},{user:x}=te(),l=ss(n,a,x==null?void 0:x.userId),{data:u,isLoading:p}=We({role:l.role,status:l.status,facets:l.facets,assigned_to:l.assigned_to,available:l.available,limit:l.limit??5,enabled:l.enabled}),f=(u==null?void 0:u.escalations)??[],N=Fe(),[g,b]=m.useState({}),[y,_]=m.useState(null),h=async(C,T)=>{const L=ne(C);if(!(T.confirm&&!window.confirm(nt(T.confirm,L)))){_(C.id),b($=>({...$,[C.id]:""}));try{await N.mutateAsync({id:C.id,resolverPayload:Zt(T.resolverPayload,L)})}catch($){b(R=>({...R,[C.id]:$.message}))}finally{_(null)}}};return t.jsxs("div",{"data-field-key":e,children:[t.jsx(W,{children:d}),c&&t.jsx(X,{children:c}),t.jsx("div",{className:"mt-1","data-testid":`escalation-list-widget-${e}`,children:p?t.jsx(Yn,{columns:i.length}):t.jsx(Qn,{escalations:f,columns:i,fieldKey:e,actions:o,onAction:h,pendingRow:y,rowErrors:g})})]})}function Qn({escalations:e,columns:s,fieldKey:r,actions:n,onAction:i,pendingRow:o,rowErrors:d}){return e.length===0?t.jsx("p",{className:"text-xs text-text-quaternary italic py-1","data-testid":`escalation-list-empty-${r}`,children:"No items found"}):t.jsxs("table",{className:"w-full text-xs border-collapse","data-testid":`escalation-list-table-${r}`,children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-surface-border",children:[s.map(c=>t.jsx("th",{className:"text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary pb-1 pr-3 last:pr-0",children:c.label},c.label)),n.length>0&&t.jsx("th",{className:"w-px"}),t.jsx("th",{className:"w-8"})]})}),t.jsx("tbody",{children:e.map(c=>{const a=ne(c),x=d[c.id];return t.jsxs("tr",{className:"border-b border-surface-border/50 last:border-0 hover:bg-surface-sunken/50 transition-colors",children:[s.map(l=>{const u=nt(l.value,a),p=Xn(u,l.format);return t.jsx("td",{className:"py-1 pr-3 last:pr-0 text-text-primary align-top",children:p},l.label)}),n.length>0&&t.jsxs("td",{className:"py-1 pr-2 align-top whitespace-nowrap",children:[n.map(l=>t.jsx("button",{type:"button",onClick:()=>i(c,l),disabled:o===c.id,className:"px-2 py-0.5 text-2xs font-medium text-accent border border-accent/40 rounded hover:bg-accent/10 disabled:opacity-40 disabled:cursor-default transition-colors ml-1 first:ml-0","data-testid":`escalation-list-action-${c.id}`,children:l.label},l.label)),x&&t.jsx("p",{className:"text-2xs text-status-error mt-0.5 whitespace-normal max-w-[16rem]","data-testid":`escalation-list-action-error-${c.id}`,children:x})]}),t.jsx("td",{className:"py-1 pl-2 align-top",children:t.jsx(es,{to:`/escalations/detail/${c.id}`})})]},c.id)})})]})}function Yn({columns:e}){return t.jsx("div",{className:"space-y-1.5 animate-pulse",children:[0,1,2].map(s=>t.jsx("div",{className:"flex gap-4",children:Array.from({length:e},(r,n)=>t.jsx("div",{className:"h-3 bg-surface-sunken rounded flex-1"},n))},s))})}const Bt={"file-upload":On,"code-editor":In,signature:Mn,"rich-text":Dn,markdown:Sn,checklist:Ln,attachment:Ie,image:Ie,link:Fn,escalation:Jn,"escalation-list":Gn};function ns({fieldKey:e,value:s,onChange:r,onBlur:n,schema:i,isRequired:o,isReadOnly:d,error:c,escalationContext:a,submitAttempted:x}){var $;const l=($=i==null?void 0:i.properties)==null?void 0:$[e],u=Q(e,l),p=l==null?void 0:l["x-lt-widget"],f=`lt-field-${e}`,N=`${f}-error`,g=`${f}-help`,b=typeof(l==null?void 0:l.description)=="string"&&l.description.length>0?l.description:void 0,h={id:f,"aria-required":o||void 0,"aria-invalid":c?!0:void 0,"aria-describedby":c?N:b!==void 0?g:void 0},C=p==="markdown"&&typeof s=="string",T=(p==="attachment"||p==="image")&&typeof s=="string",L=!!(p&&p in Bt);if(d&&!C&&!T&&!L){const R=s===null?"null":typeof s=="object"?JSON.stringify(s,null,2):String(s);return t.jsxs("div",{children:[t.jsx(W,{isRequired:o,children:u}),t.jsx("p",{className:"text-sm text-text-secondary mt-0.5 whitespace-pre-wrap",children:R})]})}if(p&&p in Bt){const R=Bt[p],k=o||(l==null?void 0:l["x-lt-require-all"])===!0,E={fieldKey:e,schema:l,escalationContext:a,isRequired:k,submitAttempted:x,error:c};if((l==null?void 0:l.type)==="object"){const A=typeof s=="string"?s:typeof s=="object"&&s!==null&&!Array.isArray(s)?JSON.stringify(s):"";return t.jsx(R,{...E,value:A,onChange:S=>{try{r(JSON.parse(S))}catch{r(S)}}})}if(typeof s=="string")return t.jsx(R,{...E,value:s,onChange:A=>r(A)});if(typeof s=="object"&&s!==null&&!Array.isArray(s))return t.jsx(R,{...E,value:JSON.stringify(s),onChange:A=>{try{r(JSON.parse(A))}catch{r(A)}}})}if(typeof s=="boolean")return t.jsxs("div",{children:[t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:s,onChange:R=>{r(R.target.checked),n==null||n()},className:"w-3.5 h-3.5 rounded accent-accent","data-field-key":e,...h}),t.jsxs("span",{className:"text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[u,o&&t.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]})]}),b&&t.jsx(X,{id:g,children:b}),t.jsx(ot,{error:c,id:N})]});if(typeof s=="number")return t.jsxs("div",{children:[t.jsx(W,{isRequired:o,htmlFor:f,children:u}),b&&t.jsx(X,{id:g,children:b}),t.jsx("input",{type:"number",value:s,onChange:R=>r(parseFloat(R.target.value)||0),onBlur:n,step:"any","data-field-key":e,className:`${Nt(!!c)} max-w-48`,...h}),t.jsx(ot,{error:c,id:N})]});if(typeof s=="string"){const R=(l==null?void 0:l.format)==="password",k=l==null?void 0:l.enum;if(k!=null&&k.length){const q=s===""&&!k.includes("");return t.jsxs("div",{children:[t.jsx(W,{isRequired:o,htmlFor:f,children:u}),b&&t.jsx(X,{id:g,children:b}),t.jsxs("select",{value:s,onChange:P=>r(P.target.value),onBlur:n,"data-field-key":e,className:Rn(!!c),...h,children:[q&&t.jsx("option",{value:"",disabled:!0,children:"Choose…"}),k.map(P=>t.jsx("option",{value:P,children:P},P))]}),t.jsx(ot,{error:c,id:N})]})}if(R)return t.jsxs("div",{children:[t.jsx(W,{isRequired:o,htmlFor:f,children:u}),b&&t.jsx(X,{id:g,children:b}),t.jsx("input",{type:"password",value:s,onChange:q=>r(q.target.value),onBlur:n,"data-field-key":e,className:Nt(!!c),autoComplete:"off",...h}),t.jsx(ot,{error:c,id:N})]});const E=l==null?void 0:l.format,A={date:"date","date-time":"datetime-local",email:"email",uri:"url"},S={date:"max-w-48","date-time":"max-w-64"};if(E&&E in A)return t.jsxs("div",{children:[t.jsx(W,{isRequired:o,htmlFor:f,children:u}),b&&t.jsx(X,{id:g,children:b}),t.jsx("input",{type:A[E],value:s,onChange:q=>r(q.target.value),onBlur:n,"data-field-key":e,className:`${Nt(!!c)} ${S[E]??""}`,...h}),t.jsx(ot,{error:c,id:N})]});if(E==="textarea"||s.length>80){const q=l==null?void 0:l.maxLength,P=l==null?void 0:l["x-lt-max-length"];let J=q;if(J===void 0&&P&&a){const V=P.indexOf(".");if(V!==-1){const v=P.slice(0,V),O=P.slice(V+1),w=a[v];if(w&&typeof w=="object"){let M=w;for(const F of O.split("."))if(M=M[F],M===void 0)break;if(typeof M=="number")J=M;else if(typeof M=="string"){const F=Number(M);Number.isNaN(F)||(J=F)}}}}const Y=J!==void 0&&s.length>J;return t.jsxs("div",{children:[t.jsx(W,{isRequired:o,htmlFor:f,children:u}),b&&t.jsx(X,{id:g,children:b}),t.jsx("textarea",{value:s,onChange:V=>{r(V.target.value),n==null||n()},onBlur:n,"data-field-key":e,className:`${Nt(!!c)} leading-relaxed`,rows:Math.min(6,Math.max(3,Math.ceil(s.length/60))),...h}),J!==void 0&&t.jsxs("p",{className:`text-2xs mt-0.5 text-right tabular-nums ${Y?"text-status-error font-medium":"text-text-quaternary"}`,children:[s.length," / ",J]}),t.jsx(ot,{error:c,id:N})]})}return t.jsxs("div",{children:[t.jsx(W,{isRequired:o,htmlFor:f,children:u}),b&&t.jsx(X,{id:g,children:b}),t.jsx("input",{type:"text",value:s,onChange:q=>r(q.target.value),onBlur:n,"data-field-key":e,className:Nt(!!c),...h}),t.jsx(ot,{error:c,id:N})]})}if(s===null)return t.jsxs("div",{children:[t.jsx(W,{isRequired:o,children:u}),t.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"null"})]});if(Array.isArray(s))return t.jsxs("div",{children:[t.jsx(W,{isRequired:o,children:u}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:s.map((R,k)=>t.jsx("span",{className:"px-2 py-0.5 text-2xs font-mono bg-surface-sunken rounded text-text-secondary",children:String(R)},k))})]});if(typeof s=="object"){const R=Object.entries(s);return t.jsxs("div",{children:[t.jsx(W,{isRequired:o,children:u}),t.jsx("div",{className:"ml-4 mt-2 pl-4 border-l border-accent-faint space-y-3",children:R.map(([k,E])=>t.jsx(ns,{fieldKey:k,value:E,onChange:A=>r({...s,[k]:A})},k))})]})}return null}function Zn({items:e,columns:s=1}){if(e.length===0)return null;const r=s>=2&&e.length>1?"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr] @dict-pairs:grid-cols-[max-content_1fr_max-content_1fr]":"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr]";return t.jsx("div",{className:"@container",children:t.jsx("dl",{className:`grid ${r} items-baseline gap-x-6 @dict-pairs:gap-x-8 gap-y-1.5`,children:e.map(({key:n,label:i,value:o})=>t.jsxs(m.Fragment,{children:[t.jsx("dt",{className:"text-2xs font-semibold uppercase tracking-wide text-text-secondary mt-2 first:mt-0 @dict-inline:mt-0",children:i}),t.jsx("dd",{className:"text-sm text-text-primary break-words min-w-0","data-field-key":n,children:Kn(o)})]},n))})})}function Kn(e){return e==null||e===""?"—":typeof e=="boolean"?e?"Yes":"No":typeof e=="object"?JSON.stringify(e):String(e)}const Xt="dictionary",tr=new Set(["markdown","attachment","image"]);function rs(e,s){if(!s)return;const r=e==null?void 0:e["x-lt-section-options"],n=r==null?void 0:r[s];return n&&typeof n=="object"?n:void 0}function er(e,s,r){var c,a;const n=(c=e==null?void 0:e.properties)==null?void 0:c[r];if((n==null?void 0:n.readOnly)!==!0)return!1;const i=n==null?void 0:n["x-lt-widget"];if(typeof i=="string"&&tr.has(i))return!1;const o=n==null?void 0:n["x-lt-display"];if(typeof o=="string")return o===Xt;const d=(a=rs(e,s))==null?void 0:a.display;return typeof d=="string"?d===Xt:(e==null?void 0:e["x-lt-display"])===Xt}function sr(e,s,r,n){var o;const i=[];for(const d of e){const[c]=d,a=i[i.length-1];if(er(s,r,c)){(a==null?void 0:a.kind)==="dictionary"?a.entries.push(d):i.push({kind:"dictionary",entries:[d]});continue}const x=(o=s==null?void 0:s.properties)==null?void 0:o[c],l=x==null?void 0:x["x-lt-column-group"];if(n==="two-column"&&typeof l=="string"&&l.trim()){(a==null?void 0:a.kind)==="column-group"&&a.name===l?a.entries.push(d):i.push({kind:"column-group",name:l,entries:[d]});continue}i.push({kind:"field",entry:d})}return i}function nr({name:e,entries:s,formSchema:r,layout:n,renderField:i}){const o=sr(s,r,e,n),d=rs(r,e),c=(d==null?void 0:d.columns)??(n==="two-column"?2:1),a=l=>l.map(([u,p])=>{var f;return{key:u,label:Q(u,(f=r==null?void 0:r.properties)==null?void 0:f[u]),value:p}}),x=()=>o.map((l,u)=>l.kind==="dictionary"?t.jsx("div",{className:n==="two-column"?"col-span-full":"",children:t.jsx(Zn,{items:a(l.entries),columns:c})},`dict-${u}`):l.kind==="column-group"?t.jsx("div",{className:"@container",children:t.jsx("div",{className:"grid grid-cols-1 @grp-cols:grid-cols-2 gap-x-4 gap-y-5",children:l.entries.map(p=>i(p))})},`group-${l.name}-${u}`):i(l.entry));return t.jsxs("div",{className:e?"border border-surface-border bg-surface-sunken rounded-[var(--lt-radius-section)] p-4 animate-[section-enter_0.25s_ease-out]":"",children:[e&&t.jsx("p",{className:"mb-4 text-[1.40625rem] font-semibold tracking-wider text-heading [font-variant-caps:small-caps]",children:e}),n==="two-column"?t.jsx("div",{className:"@container",children:t.jsx("div",{className:"grid grid-cols-1 @form-cols:grid-cols-2 gap-x-col-gap gap-y-5",children:x()})}):t.jsx("div",{className:"space-y-5",children:x()})]})}function as({value:e,onChange:s,disabled:r,submitAttempted:n,escalationContext:i,onOpenHelp:o,onDisabledClick:d}){var Y,V;const[c,a]=m.useState({}),[x,l]=m.useState({}),[u,p]=m.useState(null),[f,N]=m.useState(!1),[g,b]=m.useState(new Set);m.useEffect(()=>{try{const v=JSON.parse(e);if(typeof v=="object"&&v!==null&&!Array.isArray(v)){const O={},w={};for(const[M,F]of Object.entries(v))M.startsWith("_")?w[M]=F:O[M]=F;a(O),l(w),p(w._form_schema&&typeof w._form_schema=="object"?w._form_schema:null),N(!1)}}catch{N(!0)}},[e]);const y=m.useCallback(v=>{a(v),s(JSON.stringify({...v,...x},null,2))},[x,s]),_=m.useCallback((v,O)=>{y({...c,[v]:O})},[c,y]),h=m.useCallback(v=>{b(O=>{if(O.has(v))return O;const w=new Set(O);return w.add(v),w})},[]);if(f)return t.jsx("p",{className:"text-xs text-status-error",children:"Unable to parse resolver data as form. Use the JSON editor below."});const C=Object.entries(c);if(C.length===0)return t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No resolver fields defined."});const T=u==null?void 0:u["x-lt-order"],L=T?[...C].sort((v,O)=>{const w=T.indexOf(v[0]),M=T.indexOf(O[0]);return(w===-1?1/0:w)-(M===-1?1/0:M)}):C,$={...i??{},resolver:c},R=L.filter(([v,O])=>{var M;const w=(M=u==null?void 0:u.properties)==null?void 0:M[v];return!(!Ze(w==null?void 0:w["x-lt-showIf"],$)||(w==null?void 0:w["x-lt-hide-if-empty"])===!0&&(O==null||O===""||O===!1||O===0))}),k=new Set((u==null?void 0:u.required)??[]),E=u==null?void 0:u["x-lt-layout"],A=u==null?void 0:u.title,S=u==null?void 0:u.description,q=typeof(u==null?void 0:u["x-lt-help"])=="string"||typeof(u==null?void 0:u["x-lt-context"])=="string",P=[];for(const v of R){const[O]=v,w=(Y=u==null?void 0:u.properties)==null?void 0:Y[O],M=((V=w==null?void 0:w["x-lt-section"])==null?void 0:V.trim())||null,F=P[P.length-1];!F||F.name!==M?P.push({name:M,entries:[v]}):F.entries.push(v)}const J=([v,O])=>{var ct;const w=(ct=u==null?void 0:u.properties)==null?void 0:ct[v],M=(w==null?void 0:w.readOnly)===!0,F=(w==null?void 0:w["x-lt-span"])??1,Z=k.has(v),D=g.has(v)||!!n,H=Ye(O,w,Z,D,$);return t.jsx("div",{className:`animate-[field-enter_0.2s_ease-out] ${E==="two-column"&&F>=2?"col-span-full":""}`,children:t.jsx(ns,{fieldKey:v,value:O,onChange:Lt=>_(v,Lt),onBlur:()=>h(v),schema:u,isRequired:Z,isReadOnly:M,error:H,escalationContext:$,submitAttempted:!!n})},v)};return t.jsx("div",{className:"pb-8 max-w-form",onClick:r?d:void 0,children:t.jsxs("div",{className:r?"pointer-events-none":void 0,inert:r||void 0,"aria-disabled":r||void 0,children:[A&&t.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.jsx("h3",{className:"heading-3",children:A}),q&&o&&t.jsx("button",{type:"button",onClick:o,title:"Open instructions","aria-label":"Open instructions",className:"p-1 rounded-md text-text-tertiary hover:text-accent hover:bg-surface-hover transition-colors",children:t.jsx(Xe,{className:"w-4 h-4",strokeWidth:1.5})})]}),S&&t.jsx("p",{className:"text-sm text-text-secondary leading-relaxed mb-6",children:S}),t.jsx("div",{className:"space-y-8",children:P.map((v,O)=>t.jsx(nr,{name:v.name,entries:v.entries,formSchema:u,layout:E,renderField:J},v.name??`__s${O}`))})]})})}function rr({json:e,onJsonChange:s,requestTriage:r,onRequestTriageChange:n,triageNotes:i,onTriageNotesChange:o,disabled:d=!1,submitAttempted:c=!1,showTriage:a=!1,escalationContext:x,onOpenHelp:l,onDisabledClick:u}){return t.jsxs(t.Fragment,{children:[a&&t.jsx("div",{className:"flex items-center justify-between mb-3",children:r?t.jsxs("button",{onClick:()=>n(!1),className:"group flex items-center gap-2 text-left","data-testid":"triage-cancel",children:[t.jsx("span",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent/10 text-accent shrink-0",children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),t.jsxs("span",{className:"text-xs text-text-secondary group-hover:text-text-primary transition-colors",children:["AI Triage active."," ",t.jsx("span",{className:"text-accent group-hover:underline",children:"Cancel"})]})]}):t.jsxs("button",{onClick:()=>n(!0),className:"group flex items-center gap-2.5 text-left my-4","data-testid":"triage-callout",children:[t.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-accent/10 text-accent shrink-0 animate-[triage-glow_6s_ease-in-out_infinite]",children:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.663 17h4.674M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),t.jsxs("span",{className:"text-sm text-text-secondary group-hover:text-text-primary transition-colors",children:["This form doesn't capture the issue?"," ",t.jsx("span",{className:"text-accent group-hover:underline",children:"Request AI Triage"})]})]})}),t.jsxs("div",{className:"relative min-h-[200px]",children:[t.jsx("div",{className:r?"pointer-events-none select-none":"",children:t.jsx(as,{value:e,onChange:s,disabled:d,submitAttempted:c,escalationContext:x,onOpenHelp:l,onDisabledClick:u})}),r&&t.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col bg-surface/90 backdrop-blur-[2px] rounded-md border border-accent/20 p-5","data-testid":"triage-overlay",children:[t.jsx("p",{className:"text-xs text-text-secondary mb-3 leading-relaxed",children:"The resolution form will not be submitted. Describe the issue so AI triage can diagnose and fix it using available tools. The corrected result will come back as a new escalation for your review."}),t.jsx("textarea",{value:i,onChange:p=>o(p.target.value),placeholder:"e.g. Content is in Spanish — needs translation to English before review...",className:"input text-xs w-full flex-1 min-h-[80px] resize-none",autoFocus:!0,"data-testid":"triage-notes"})]})]})]})}function is(e,s){if(!e.includes("{"))return e;try{const r=i=>{if(!i)return{};try{return JSON.parse(i)}catch{return{}}},n={...s.metadata??{},...r(s.envelope),...r(s.escalation_payload)};return e.replace(/\{([^}]+)\}/g,(i,o)=>Object.prototype.hasOwnProperty.call(n,o)?String(n[o]):`{${o}}`)}catch{return e}}function Se(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function lt(e){return{escalation:e,metadata:e.metadata??null,envelope:Se(e.envelope),payload:Se(e.escalation_payload),resolver:null}}function ar({isRoundsExhausted:e,payloadObj:s,isTerminal:r,resolverPayload:n,onRetryTriage:i,isRetrying:o}){return t.jsxs(t.Fragment,{children:[e&&s&&t.jsx("div",{className:"mt-8",children:t.jsx(Tn,{payload:s,isTerminal:r,resolverPayload:n,onRetryTriage:i,isRetrying:o})}),(s==null?void 0:s.category)==="missing_credential"&&t.jsxs("div",{className:"mt-8 bg-status-warning/10 border border-status-warning/30 rounded-md px-5 py-4 flex items-start gap-3",children:[t.jsx(ke,{size:20,className:"text-status-warning mt-0.5 shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-text-primary mb-1",children:"Missing Credential"}),t.jsxs("p",{className:"text-xs text-text-secondary mb-3",children:["This workflow requires a ",t.jsx("span",{className:"font-medium capitalize",children:String(s.provider)})," credential to continue. Register one and then resolve this escalation to retry."]}),t.jsxs(ht,{to:"/credentials",className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[t.jsx(ke,{size:12}),"Go to Credentials"]})]})]})]})}function ir({esc:e,resolverPayload:s,isTerminal:r,claimedByMe:n,activeView:i,metadataFormSchema:o,effectiveSchema:d,json:c,onJsonChange:a,requestTriage:x,onRequestTriageChange:l,triageNotes:u,onTriageNotesChange:p,onResolve:f,onEscalate:N,onClaim:g,submitAttempted:b,isCertified:y,hasAI:_,onOpenHelp:h,onDisabledClick:C}){const T=d,L=lt(e);if(r){if(s==null)return null;const E=typeof s=="object"&&s!==null?s:{},A=d??o,S=A!=null&&A.properties?{...He(E,A),_form_schema:A}:E;return t.jsx("div",{className:"mt-3",children:t.jsx(as,{value:JSON.stringify(S,null,2),onChange:()=>{},disabled:!0,escalationContext:L})})}if(i!=="resolve"||!(e.workflow_type||d))return null;const $=T==null?void 0:T["x-lt-viewport"],R=($==null?void 0:$.type)==="iframe"&&!!$.src&&f&&N;if(R&&!n)return t.jsxs("button",{onClick:()=>g==null?void 0:g(),disabled:!g,className:"flex flex-col items-center justify-center min-h-[55vh] w-full gap-3 text-center group disabled:opacity-50 disabled:cursor-default",children:[t.jsx(an,{className:"w-10 h-10 text-text-tertiary group-hover:text-accent transition-colors",strokeWidth:1}),t.jsx("p",{className:"text-base font-medium text-text-primary group-hover:text-accent transition-colors",children:"Claim to launch the editor"})]});const k=R?is($.src,e):"";return t.jsx("div",{className:"mt-3",children:R?t.jsx(ts,{src:k,escalation:e,schema:T,onResolve:f,onEscalate:N,submitAttempted:b}):t.jsx(rr,{json:c,onJsonChange:a,requestTriage:x,onRequestTriageChange:l,triageNotes:u,onTriageNotesChange:p,disabled:!n,submitAttempted:b,showTriage:!!y&&!!_,escalationContext:L,onOpenHelp:h,onDisabledClick:C})})}function or({open:e,assignedUntil:s,onClose:r,onExtend:n,isPending:i}){const o=qe(),[d,c]=m.useState("30"),[a,x]=m.useState(0),l=d==="custom",u=l?a:parseInt(d),p=m.useCallback(f=>x(f),[]);return t.jsx(Je,{open:e,onClose:r,title:"Claim Expiring",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-sm text-text-secondary",children:["Your claim on this escalation expires in"," ",t.jsx($t,{until:s}),". When it lapses, the form locks and the item returns to the queue — your edits are kept as a draft. Extend to keep working."]}),t.jsxs("select",{value:d,onChange:f=>{c(f.target.value),x(0)},className:"select w-full text-sm","aria-label":"Extension duration",children:[o.map(f=>t.jsx("option",{value:f.value,children:f.label},f.value)),t.jsx("option",{value:"custom",children:"Other..."})]}),l&&t.jsx(Ve,{onChange:p,autoFocus:!0}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:r,className:"btn-secondary text-xs",children:"Dismiss"}),t.jsx("button",{onClick:()=>n(u),className:"btn-primary text-xs",disabled:i||!u||u<=0,children:i?"Extending...":"Extend Claim"})]})]})})}const lr=9e4;function cr(e,s=lr){const[,r]=m.useState(0);if(m.useEffect(()=>{if(!e)return;const i=new Date(e).getTime()-Date.now();if(i<=0)return;const o=()=>r(a=>a+1),d=[],c=i-s;return c>0&&d.push(window.setTimeout(o,c)),d.push(window.setTimeout(o,i)),()=>d.forEach(a=>window.clearTimeout(a))},[e,s]),!e)return{expired:!1,expiringSoon:!1,msRemaining:0};const n=Math.max(0,new Date(e).getTime()-Date.now());return{expired:n<=0,expiringSoon:n>0&&n<=s,msRemaining:n}}const dr="lt:escalation:draft:";function re(e){return`${dr}${e}`}function ur(e){try{return localStorage.getItem(re(e))}catch{return null}}function xr(e,s){try{localStorage.setItem(re(e),s)}catch{}}function Gt(e){try{localStorage.removeItem(re(e))}catch{}}const pr="x-lt-transition",mr="x-lt-transition-message",fr="x-lt-transition-max-wait-seconds",hr="x-lt-transition-done",gr="Submitted. Preparing your next step…",br=30,jr=5,yr=300;function Nr(e){const s=typeof e=="number"?e:Number(e);return!Number.isFinite(s)||s<=0?br:Math.min(yr,Math.max(jr,Math.round(s)))}function $e(e){if(!e||!e[pr])return null;const s=e[mr];return{message:typeof s=="string"&&s.trim().length>0?s:gr,maxWaitSeconds:Nr(e[fr])}}function vr(e){const s=e==null?void 0:e[hr];return typeof s=="string"&&s.trim().length>0?s:null}const wr="x-lt-submit-on-claim";function kr(e){return!!(e!=null&&e[wr])}const _r="x-lt-labels",Cr=["claim","cancel","submit","escalate","release"];function Er(e){const s=e==null?void 0:e[_r];if(!s||typeof s!="object"||Array.isArray(s))return{};const r=s,n={};for(const i of Cr){const o=r[i];typeof o=="string"&&o.trim().length>0&&(n[i]=o.trim())}return n}const Ar="x-lt-submit-guard",Tr="{{count}} related items are still pending";function Rr(e){const s=e==null?void 0:e[Ar];if(!s||typeof s!="object"||Array.isArray(s))return;const r=s;if(!(!r.query||typeof r.query!="object"))return r}function Or(e,s){const{user:r}=te(),n=ss((e==null?void 0:e.query)??{},s??{},r==null?void 0:r.userId),{data:i,isSuccess:o}=We({role:n.role,status:n.status,facets:n.facets,assigned_to:n.assigned_to,available:n.available,limit:1,enabled:!!e&&n.enabled}),d=!!e&&e.mustBeEmpty!==!1&&n.enabled,c=(i==null?void 0:i.total)??0,a=d&&o&&c===0,x=d&&!a;let l="";if(x)if(c>0){const u=(e==null?void 0:e.message)??Tr;l=nt(u.replace(/\{\{count\}\}/g,String(c)),s??{})}else l="Checking related items…";return{blocked:x,count:c,message:l,confirmedEmpty:a}}function Ir({open:e,message:s}){return e?$s.createPortal(t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center px-4",children:[t.jsx("div",{className:"absolute inset-0 bg-text-primary/40 backdrop-blur-sm"}),t.jsxs("div",{role:"status","aria-live":"polite",className:"relative w-full max-w-sm bg-surface-raised border border-surface-border rounded-lg shadow-xl px-6 py-7 text-center",children:[t.jsx("div",{className:"flex justify-center mb-4","aria-hidden":"true",children:t.jsx("span",{className:"inline-block w-7 h-7 rounded-full border-2 border-surface-border border-t-accent animate-spin"})}),t.jsx("div",{className:"text-sm text-text-secondary [&_p]:m-0 [&_p+p]:mt-2",children:t.jsx(St,{content:s})})]})]}),document.body):null}const os="lt:escalation:panel:open";function Mr(){try{const e=localStorage.getItem(os);return e===null?!0:e==="true"}catch{return!0}}function vt(e){try{localStorage.setItem(os,String(e))}catch{}}function wt(e){if(!e)return null;try{return JSON.parse(e)}catch{return e}}function sa(){const{id:e}=Ls();return t.jsx(Dr,{id:e},e)}function Dr({id:e}){var fe,he,ge,be,je;const{user:s}=te(),{identity:r}=Cs(),n=Es(),i=(r==null?void 0:r.actorId)??(s==null?void 0:s.userId),o=ee(),d=Ue(),c=Le(),{data:a,isLoading:x,refetch:l,isFetching:u}=Pe(e);Hs(e);const p=As(),f=Fe(),N=Ts(),g=Rs(),[b,y]=m.useState(!1),{data:_}=Us(),{data:h}=Os(),{isBuilder:C}=Is(),T=_==null?void 0:_.find(j=>j.workflow_type===(a==null?void 0:a.workflow_type)),L=((fe=h==null?void 0:h.telemetry)==null?void 0:fe.traceUrl)??null,[$,R]=m.useState("resolve"),[k,E]=m.useState("{}"),[A,S]=m.useState(Mr),[q,P]=m.useState(!1),[J,Y]=m.useState(""),[V,v]=m.useState(!1),[O,w]=m.useState([]),[M,F]=m.useState(0),[Z,D]=m.useState(void 0),[H,ct]=m.useState(null),[Lt,ae]=m.useState(!1),ie=m.useRef(!1),_t=m.useRef(null),oe=m.useRef(!1),Ct=m.useRef(null),ls=cr(a==null?void 0:a.assigned_until),[cs,ds]=m.useState(null);m.useEffect(()=>{if(!(!V||!a))try{const j=JSON.parse(k),I=j._form_schema;if(!I){w([]);return}w(Ke(I,j,lt(a)))}catch{}},[k,V,a]);const Et=((he=a==null?void 0:a.metadata)==null?void 0:he.form_schema)??null,dt=(a==null?void 0:a.form_schema)??(T==null?void 0:T.resolver_schema)??null,U=Et??dt,le=kr(U),Pt=Er(U),gt=Rr(U),bt=Or(gt,a?lt(a):void 0),At=m.useRef(!1),Tt=m.useRef(null);m.useEffect(()=>{if(At.current)return;const j=Et??(dt!=null&&dt.properties?dt:null);if(j!=null&&j.properties){At.current=!0;const I=wt(a==null?void 0:a.envelope),z=I==null?void 0:I.formDefaults,G={...(a==null?void 0:a.metadata)??{},...typeof z=="object"&&z!==null?z:{}},at=He(G,j),et={_form_schema:j};for(const[Ne,Ns]of Object.entries(j.properties)){const ve=Ns,vs=ve.type==="object"?{}:"";et[Ne]=at[Ne]??ve.default??vs}Tt.current=JSON.stringify(et,null,2);const ye=!((a==null?void 0:a.status)==="resolved"||(a==null?void 0:a.status)==="cancelled")&&(a!=null&&a.id)?ur(a.id):null,It=ye?wt(ye):null;It&&typeof It=="object"&&!Array.isArray(It)?E(JSON.stringify({...It,_form_schema:j},null,2)):E(Tt.current)}else U&&(At.current=!0,E(JSON.stringify(U,null,2)))},[U,Et,dt,a==null?void 0:a.envelope,a==null?void 0:a.metadata,a==null?void 0:a.id,a==null?void 0:a.status]),m.useEffect(()=>{if(!At.current||Tt.current===null||!(a!=null&&a.id)||a.status!=="pending")return;const j=a.id,I=window.setTimeout(()=>{k===Tt.current?Gt(j):xr(j,k)},400);return()=>window.clearTimeout(I)},[k,a==null?void 0:a.id,a==null?void 0:a.status]),m.useEffect(()=>{if(!H)return;const j=window.setTimeout(async()=>{var z;try{const G=new URLSearchParams({parent_id:e,assigned_to:i??"",status:"pending",limit:"1"}),at=await ft(`/escalations?${G}`),et=(z=at==null?void 0:at.escalations)==null?void 0:z[0];if(et!=null&&et.id&&et.parent_id===e){ct(null),o(`/escalations/detail/${et.id}`);return}}catch{}ct(null),c.resetQueries({queryKey:["escalations"]}),c.resetQueries({queryKey:["escalationStats"]});const I=H.doneDest;I?I.startsWith("/")?o(I):window.location.assign(I):o(-1)},H.maxWaitSeconds*1e3);return()=>window.clearTimeout(j)},[H,e,i,o,c]),m.useEffect(()=>{var j,I;ie.current||(j=d.state)!=null&&j.autoStart&&(!a||a.status!=="pending"||Dt(a)||k!=="{}"&&(ie.current=!0,(I=_t.current)==null||I.call(_t)))},[a,k,d.state]),m.useEffect(()=>{var j;oe.current||!(gt!=null&>.autoResolveWhenEmpty)||!bt.confirmedEmpty||!a||a.status!=="pending"||!Dt(a)||a.assigned_to===i&&k!=="{}"&&(oe.current=!0,(j=Ct.current)==null||j.call(Ct))},[bt.confirmedEmpty,gt,a,k,i]);const us=(a==null?void 0:a.subtype)==="rounds_exhausted";if(x)return t.jsxs("div",{className:"animate-pulse space-y-8",children:[t.jsx("div",{className:"h-8 bg-surface-sunken rounded w-64"}),t.jsx("div",{className:"h-32 bg-surface-sunken rounded w-full"})]});if(!a)return t.jsx("p",{className:"text-sm text-text-secondary",children:"Escalation not found."});const Wt=Dt(a),K=Wt&&a.assigned_to===i,ce=Wt&&!K,ut=a.status==="resolved"||a.status==="cancelled",rt=U==null?void 0:U["x-lt-viewport"],Ft=(rt==null?void 0:rt.type)==="iframe"&&!!(rt!=null&&rt.src)&&K&&!ut,Rt=wt(a.escalation_payload),xt=wt(a.resolver_payload),Ot=wt(a.envelope),xs=!!((ge=Ot==null?void 0:Ot.metadata)!=null&&ge.certified),de=Ms(),ue=de!==null?de:!!((be=h==null?void 0:h.ai)!=null&&be.enabled),tt=typeof Rt=="object"&&Rt!==null&&!Array.isArray(Rt)?Rt:null,ps=tt==null?void 0:tt._triage,ms=typeof xt=="object"&&xt!==null&&!Array.isArray(xt)?xt:null,fs=ut?"terminal":K?"claimed_by_me":ce?"claimed_by_other":"available",qt=j=>{p.mutate({id:e,durationMinutes:j})},jt=()=>{c.resetQueries({queryKey:["escalations"]}),c.resetQueries({queryKey:["escalationStats"]}),o(-1)},hs=()=>{const j=vr(U);return j&&nt(j,lt(a))||null},gs=j=>{c.resetQueries({queryKey:["escalations"]}),c.resetQueries({queryKey:["escalationStats"]}),j.startsWith("/")?o(j):window.location.assign(j)},yt=async j=>{try{await f.mutateAsync({id:e,resolverPayload:j})}catch(G){if(G instanceof Ds&&dn(G.body)){v(!0),w(G.body.violations),D(B.ERRORS);return}throw G}Gt(e);const I=$e(U),z=hs();if(I){ct({...I,doneDest:z});return}if(z){gs(z);return}jt()},xe=async j=>{try{await p.mutateAsync({id:e,durationMinutes:j})}catch{return}if(bt.blocked)return;const I=Yt(k,lt(a));if(!I.parseError){if(I.errors.length>0){v(!0),w(I.errors),S(!0),vt(!0),D(B.ERRORS);return}await yt(I.payload)}};_t.current=async()=>{var I;const j=(I=d.state)==null?void 0:I.durationMinutes;ae(!0),await xe(typeof j=="number"&&j>0?j:30),ae(!1)},Ct.current=()=>{const j=Yt(k,lt(a));j.parseError||j.errors.length>0||yt(j.payload)};const pe=async j=>{j&&(await N.mutateAsync({id:e,targetRole:j}),jt())},bs=async()=>{K||await p.mutateAsync({id:e,durationMinutes:30});const j=(tt==null?void 0:tt.diagnosis)||a.description||"";await f.mutateAsync({id:e,resolverPayload:{_lt:{needsTriage:!0},notes:j}}),jt()},me=async()=>{await p.mutateAsync({id:e,durationMinutes:0}),jt()},js=async()=>{await g.mutateAsync(e),Gt(e),y(!1),jt()},ys=t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ws,{onRefresh:()=>l(),isFetching:u,apiPath:`/escalations/${a.id}`,standalone:!0}),t.jsx("button",{onClick:()=>S(j=>(vt(!j),!j)),className:"ml-2 text-accent/60 hover:text-accent transition-colors",title:A?"Hide side panel":"Show side panel",children:A?t.jsx(_e,{className:"w-5 h-5",strokeWidth:1.5}):t.jsx(Ce,{className:"w-5 h-5",strokeWidth:1.5})})]});return t.jsxs("div",{className:"flex-1 min-h-0 min-w-0 flex items-stretch -mt-8 -mr-page-x -mb-16",children:[t.jsxs("div",{className:"flex-1 min-w-0 flex flex-col min-h-0",children:[Ft?t.jsxs("div",{className:"relative flex-1 min-h-0 -ml-page-x",children:[t.jsx("div",{className:"absolute top-3 right-3 z-50 flex items-center gap-0.5 bg-surface/90 backdrop-blur-sm rounded-lg px-1.5 py-1 shadow-sm border border-surface-border/40",children:[{onClick:me,disabled:p.isPending,label:Pt.release??"Release",hoverClass:"hover:text-accent",icon:t.jsx(on,{className:"w-4 h-4",strokeWidth:1.5})},{onClick:()=>y(!0),disabled:!1,label:Pt.cancel??"Cancel",hoverClass:"hover:text-status-error",icon:t.jsx(ln,{className:"w-4 h-4",strokeWidth:1.5})},{onClick:()=>S(j=>(vt(!j),!j)),disabled:!1,label:A?"Hide panel":"Show panel",hoverClass:"hover:text-accent",icon:A?t.jsx(_e,{className:"w-4 h-4",strokeWidth:1.5}):t.jsx(Ce,{className:"w-4 h-4",strokeWidth:1.5})}].map(({onClick:j,disabled:I,label:z,hoverClass:G,icon:at})=>t.jsxs("div",{className:"relative group/tip",children:[t.jsx("button",{onClick:j,disabled:I,className:`text-text-tertiary ${G} transition-colors disabled:opacity-40 disabled:cursor-default p-1.5 rounded-md`,children:at}),t.jsx("span",{className:"pointer-events-none absolute top-full left-1/2 -translate-x-1/2 mt-1.5 px-2 py-0.5 rounded text-2xs bg-surface-sunken text-text-primary whitespace-nowrap opacity-0 group-hover/tip:opacity-100 transition-opacity",children:z})]},z))}),t.jsx(ts,{src:is(rt.src,a),escalation:a,schema:U,onResolve:yt,onEscalate:pe,submitAttempted:V,fill:!0})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"shrink-0 pt-8 pr-page-x",children:t.jsx(Ps,{title:a.description||"Escalation",actions:ys})}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto pr-page-x",children:[t.jsx(ar,{isRoundsExhausted:us,payloadObj:tt,isTerminal:ut,resolverPayload:xt,onRetryTriage:bs,isRetrying:p.isPending||f.isPending}),t.jsx(ir,{esc:a,resolverPayload:xt,isTerminal:ut,claimedByMe:K,activeView:$,metadataFormSchema:Et,effectiveSchema:U,json:k,onJsonChange:E,requestTriage:q,onRequestTriageChange:P,triageNotes:J,onTriageNotesChange:Y,onResolve:yt,onEscalate:pe,onClaim:()=>qt(30),submitAttempted:V,isCertified:xs,hasAI:ue,onOpenHelp:()=>{S(!0),vt(!0),D(B.HELP)},onDisabledClick:()=>F(j=>j+1)}),t.jsx("div",{className:"h-10"})]})]}),!Ft&&t.jsx(An,{escalationContext:lt(a),mode:fs,activeView:$,onActiveViewChange:R,onClaim:le?xe:qt,claimPending:p.isPending||le&&f.isPending,claimNudge:M,workflowType:a.workflow_type,json:k,onResolve:yt,resolvePending:f.isPending||f.isSuccess,resolveError:f.error,requestTriage:q,triageNotes:J,onRelease:me,releasePending:p.isPending,onCancel:()=>y(!0),assignedTo:a.assigned_to,assignedUntil:a.assigned_until,actingName:r&&K?r.displayName:null,badgePrompt:n&&!r&&ce,onSubmitAttempt:()=>v(!0),onValidationErrors:j=>{w(j),S(!0),vt(!0),D(B.ERRORS)},labels:Pt,submitBlocked:bt.blocked,submitBlockedMessage:bt.message})]}),t.jsx(vn,{esc:a,schema:U,envelope:Ot,payload:tt,resolver:ms,triage:ps??null,hasAI:ue,claimed:Wt,claimedByMe:K,isTerminal:ut,isBuilder:C,traceUrl:L,open:A,noGutter:Ft,formErrors:O,activePanel:Z,onPanelChange:D}),t.jsx(Ss,{open:b,onClose:()=>y(!1),onConfirm:js,isPending:g.isPending,error:g.error}),t.jsx(un,{escalationId:e}),t.jsx(Ir,{open:!!H||Lt,message:(H==null?void 0:H.message)??((je=$e(U))==null?void 0:je.message)??"Starting…"}),K&&!ut&&a.assigned_until&&t.jsx(or,{open:ls.expiringSoon&&a.assigned_until!==cs,assignedUntil:a.assigned_until,onClose:()=>ds(a.assigned_until??null),onExtend:qt,isPending:p.isPending})]})}export{sa as EscalationDetailPage};
|
|
3
|
+
//# sourceMappingURL=index-DOai950R.js.map
|