@polderlabs/bizar 6.3.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/hooks/sessionend-recall.mjs +3 -3
- package/.claude/hooks/worker-suggest.mjs +110 -0
- package/.claude/settings.json +9 -0
- package/bizar-dash/dist/assets/{EnvVarsSection-B58aiJiE.js → EnvVarsSection-CW6fWKds.js} +3 -3
- package/bizar-dash/dist/assets/{EnvVarsSection-B58aiJiE.js.map → EnvVarsSection-CW6fWKds.js.map} +1 -1
- package/bizar-dash/dist/assets/MobileChat-D7zRhU9K.js +1 -0
- package/bizar-dash/dist/assets/{MobileChat-BJrqwVDd.js.map → MobileChat-D7zRhU9K.js.map} +1 -1
- package/bizar-dash/dist/assets/MobileSettings-K-sNsn_r.js +1 -0
- package/bizar-dash/dist/assets/{MobileSettings-CEQNJNLJ.js.map → MobileSettings-K-sNsn_r.js.map} +1 -1
- package/bizar-dash/dist/assets/{Toast-Cpl6-E63.js → Toast-WTxc3m2g.js} +1 -1
- package/bizar-dash/dist/assets/{Toast-Cpl6-E63.js.map → Toast-WTxc3m2g.js.map} +1 -1
- package/bizar-dash/dist/assets/flow-BpU0-gK2.js +1 -0
- package/bizar-dash/dist/assets/flow-BpU0-gK2.js.map +1 -0
- package/bizar-dash/dist/assets/fuzzy-l0sNRNKZ.js +1 -0
- package/bizar-dash/dist/assets/fuzzy-l0sNRNKZ.js.map +1 -0
- package/bizar-dash/dist/assets/{icons-Do5N2jmX.js → icons-B0AKnYI3.js} +98 -103
- package/bizar-dash/dist/assets/icons-B0AKnYI3.js.map +1 -0
- package/bizar-dash/dist/assets/main-C-Md3DaY.css +1 -0
- package/bizar-dash/dist/assets/main-CO8fIxQK.js +18 -0
- package/bizar-dash/dist/assets/main-CO8fIxQK.js.map +1 -0
- package/bizar-dash/dist/assets/markdown-w2bDDkAH.js +1 -0
- package/bizar-dash/dist/assets/{markdown-tOLaD6nm.js.map → markdown-w2bDDkAH.js.map} +1 -1
- package/bizar-dash/dist/assets/mobile-DXYCA0hC.js +1 -0
- package/bizar-dash/dist/assets/{mobile-DYCHcUpq.js.map → mobile-DXYCA0hC.js.map} +1 -1
- package/bizar-dash/dist/assets/mobile-layout-DSmtNPja.js +2 -0
- package/bizar-dash/dist/assets/mobile-layout-DSmtNPja.js.map +1 -0
- package/bizar-dash/dist/assets/react-vendor-BnuhLJ6X.css +1 -0
- package/bizar-dash/dist/assets/react-vendor-D3pra6w-.js +46 -0
- package/bizar-dash/dist/assets/react-vendor-D3pra6w-.js.map +1 -0
- package/bizar-dash/dist/assets/useSlashCommands-3DFLOfpk.js +2 -0
- package/bizar-dash/dist/assets/useSlashCommands-3DFLOfpk.js.map +1 -0
- package/bizar-dash/dist/assets/vendor-Di7Cp-rw.js +45 -0
- package/bizar-dash/dist/assets/vendor-Di7Cp-rw.js.map +1 -0
- package/bizar-dash/dist/index.html +12 -10
- package/bizar-dash/dist/mobile.html +7 -4
- package/bizar-dash/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/bizar-dash/src/server/api.mjs +11 -0
- package/bizar-dash/src/server/memory-consolidator.mjs +218 -0
- package/bizar-dash/src/server/memory-distillation.mjs +296 -0
- package/bizar-dash/src/server/routes/distill.mjs +129 -0
- package/bizar-dash/src/server/routes/goal-planner.mjs +236 -0
- package/bizar-dash/src/web/App.tsx +4 -0
- package/bizar-dash/src/web/components/Tag.tsx +18 -5
- package/bizar-dash/src/web/components/Topbar.tsx +3 -0
- package/bizar-dash/src/web/components/agents/CommunicationLog.tsx +126 -0
- package/bizar-dash/src/web/components/agents/DependencyGraph.tsx +163 -0
- package/bizar-dash/src/web/components/agents/QualityGates.tsx +123 -0
- package/bizar-dash/src/web/components/agents/RealTimeEventLog.tsx +127 -0
- package/bizar-dash/src/web/components/agents/RoutingDecisions.test.tsx +148 -0
- package/bizar-dash/src/web/components/agents/RoutingDecisions.tsx +160 -0
- package/bizar-dash/src/web/components/goals/GoalInput.tsx +86 -0
- package/bizar-dash/src/web/components/goals/PlanVisualization.tsx +111 -0
- package/bizar-dash/src/web/lib/goapPlanner.ts +614 -0
- package/bizar-dash/src/web/lib/types.ts +25 -0
- package/bizar-dash/src/web/styles/agents-redesign.css +311 -0
- package/bizar-dash/src/web/styles/main.css +251 -0
- package/bizar-dash/src/web/styles/tasks-redesign.css +231 -0
- package/bizar-dash/src/web/ui/controls/Button.tsx +77 -0
- package/bizar-dash/src/web/ui/controls/Checkbox.tsx +95 -0
- package/bizar-dash/src/web/ui/controls/IconButton.tsx +66 -0
- package/bizar-dash/src/web/ui/controls/Kbd.tsx +24 -0
- package/bizar-dash/src/web/ui/controls/NumberInput.tsx +77 -0
- package/bizar-dash/src/web/ui/controls/RadioGroup.tsx +109 -0
- package/bizar-dash/src/web/ui/controls/SearchInput.tsx +91 -0
- package/bizar-dash/src/web/ui/controls/Select.tsx +92 -0
- package/bizar-dash/src/web/ui/controls/Slider.tsx +70 -0
- package/bizar-dash/src/web/ui/controls/TextInput.tsx +67 -0
- package/bizar-dash/src/web/ui/controls/Toggle.tsx +79 -0
- package/bizar-dash/src/web/ui/controls/controls.css +454 -0
- package/bizar-dash/src/web/ui/controls/index.ts +33 -0
- package/bizar-dash/src/web/ui/data/BarChart.tsx +60 -0
- package/bizar-dash/src/web/ui/data/DataTable.tsx +216 -0
- package/bizar-dash/src/web/ui/data/EmptyState.tsx +60 -0
- package/bizar-dash/src/web/ui/data/ErrorState.tsx +56 -0
- package/bizar-dash/src/web/ui/data/KeyValueList.tsx +106 -0
- package/bizar-dash/src/web/ui/data/LoadingState.tsx +65 -0
- package/bizar-dash/src/web/ui/data/Sparkline.tsx +87 -0
- package/bizar-dash/src/web/ui/data/StatTile.tsx +87 -0
- package/bizar-dash/src/web/ui/data/data.css +535 -0
- package/bizar-dash/src/web/ui/data/index.ts +31 -0
- package/bizar-dash/src/web/ui/feedback/Badge.tsx +49 -0
- package/bizar-dash/src/web/ui/feedback/Dialog.tsx +209 -0
- package/bizar-dash/src/web/ui/feedback/ProgressBar.tsx +69 -0
- package/bizar-dash/src/web/ui/feedback/StatusDot.tsx +50 -0
- package/bizar-dash/src/web/ui/feedback/Toast.tsx +200 -0
- package/bizar-dash/src/web/ui/feedback/Tooltip.tsx +126 -0
- package/bizar-dash/src/web/ui/feedback/feedback.css +314 -0
- package/bizar-dash/src/web/ui/feedback/index.ts +43 -0
- package/bizar-dash/src/web/ui/index.ts +56 -0
- package/bizar-dash/src/web/ui/layout/AppShell.tsx +51 -0
- package/bizar-dash/src/web/ui/layout/Breadcrumbs.tsx +97 -0
- package/bizar-dash/src/web/ui/layout/Panel.tsx +73 -0
- package/bizar-dash/src/web/ui/layout/PanelHeader.tsx +39 -0
- package/bizar-dash/src/web/ui/layout/Sidebar.tsx +131 -0
- package/bizar-dash/src/web/ui/layout/Tabs.tsx +133 -0
- package/bizar-dash/src/web/ui/layout/Topbar.tsx +42 -0
- package/bizar-dash/src/web/ui/layout/index.ts +33 -0
- package/bizar-dash/src/web/ui/layout/layout.css +413 -0
- package/bizar-dash/src/web/ui/navigation/CommandPalette.tsx +199 -0
- package/bizar-dash/src/web/ui/navigation/NavGroup.tsx +95 -0
- package/bizar-dash/src/web/ui/navigation/NavLink.tsx +93 -0
- package/bizar-dash/src/web/ui/navigation/index.ts +17 -0
- package/bizar-dash/src/web/ui/navigation/navigation.css +343 -0
- package/bizar-dash/src/web/ui/primitives/Box.tsx +91 -0
- package/bizar-dash/src/web/ui/primitives/Grid.tsx +49 -0
- package/bizar-dash/src/web/ui/primitives/Inline.tsx +55 -0
- package/bizar-dash/src/web/ui/primitives/Separator.tsx +46 -0
- package/bizar-dash/src/web/ui/primitives/Stack.tsx +54 -0
- package/bizar-dash/src/web/ui/primitives/VisuallyHidden.tsx +26 -0
- package/bizar-dash/src/web/ui/primitives/index.ts +23 -0
- package/bizar-dash/src/web/ui/primitives/primitives.css +183 -0
- package/bizar-dash/src/web/ui/styles/globals.css +86 -0
- package/bizar-dash/src/web/ui/styles/reset.css +125 -0
- package/bizar-dash/src/web/ui/styles/tokens.css +195 -0
- package/bizar-dash/src/web/ui/theme/ThemeProvider.tsx +142 -0
- package/bizar-dash/src/web/ui/theme/tokens.ts +131 -0
- package/bizar-dash/src/web/ui/theme/useTheme.ts +22 -0
- package/bizar-dash/src/web/ui/utils/cx.ts +42 -0
- package/bizar-dash/src/web/views/Agents.tsx +506 -266
- package/bizar-dash/src/web/views/GoalPlanner.tsx +158 -0
- package/bizar-dash/src/web/views/Overview.tsx +996 -448
- package/bizar-dash/src/web/views/Tasks.tsx +277 -273
- package/bizar-dash/tests/communication-log.test.tsx +67 -0
- package/bizar-dash/tests/dep-graph.test.tsx +40 -0
- package/bizar-dash/tests/event-log.test.tsx +61 -0
- package/bizar-dash/tests/goal-input.test.tsx +72 -0
- package/bizar-dash/tests/goap-planner.test.ts +68 -0
- package/bizar-dash/tests/quality-gates.test.tsx +59 -0
- package/bizar-dash/tests/setup.ts +31 -1
- package/bizar-dash/tests/ui/controls/Button.test.tsx +50 -0
- package/bizar-dash/tests/ui/controls/Checkbox.test.tsx +44 -0
- package/bizar-dash/tests/ui/controls/IconButton.test.tsx +37 -0
- package/bizar-dash/tests/ui/controls/Kbd.test.tsx +39 -0
- package/bizar-dash/tests/ui/controls/NumberInput.test.tsx +56 -0
- package/bizar-dash/tests/ui/controls/RadioGroup.test.tsx +58 -0
- package/bizar-dash/tests/ui/controls/SearchInput.test.tsx +52 -0
- package/bizar-dash/tests/ui/controls/Select.test.tsx +66 -0
- package/bizar-dash/tests/ui/controls/Slider.test.tsx +41 -0
- package/bizar-dash/tests/ui/controls/TextInput.test.tsx +44 -0
- package/bizar-dash/tests/ui/controls/Toggle.test.tsx +39 -0
- package/bizar-dash/tests/ui/data/BarChart.test.tsx +55 -0
- package/bizar-dash/tests/ui/data/DataTable.test.tsx +112 -0
- package/bizar-dash/tests/ui/data/EmptyState.test.tsx +57 -0
- package/bizar-dash/tests/ui/data/ErrorState.test.tsx +47 -0
- package/bizar-dash/tests/ui/data/KeyValueList.test.tsx +59 -0
- package/bizar-dash/tests/ui/data/LoadingState.test.tsx +37 -0
- package/bizar-dash/tests/ui/data/Sparkline.test.tsx +56 -0
- package/bizar-dash/tests/ui/data/StatTile.test.tsx +69 -0
- package/bizar-dash/tests/ui/feedback/Badge.test.tsx +41 -0
- package/bizar-dash/tests/ui/feedback/Dialog.test.tsx +99 -0
- package/bizar-dash/tests/ui/feedback/ProgressBar.test.tsx +66 -0
- package/bizar-dash/tests/ui/feedback/StatusDot.test.tsx +41 -0
- package/bizar-dash/tests/ui/feedback/Toast.test.tsx +124 -0
- package/bizar-dash/tests/ui/feedback/Tooltip.test.tsx +102 -0
- package/bizar-dash/tests/ui/layout/AppShell.test.tsx +50 -0
- package/bizar-dash/tests/ui/layout/Breadcrumbs.test.tsx +85 -0
- package/bizar-dash/tests/ui/layout/Panel.test.tsx +52 -0
- package/bizar-dash/tests/ui/layout/PanelHeader.test.tsx +32 -0
- package/bizar-dash/tests/ui/layout/Sidebar.test.tsx +95 -0
- package/bizar-dash/tests/ui/layout/Tabs.test.tsx +87 -0
- package/bizar-dash/tests/ui/layout/Topbar.test.tsx +41 -0
- package/bizar-dash/tests/ui/navigation/CommandPalette.test.tsx +105 -0
- package/bizar-dash/tests/ui/navigation/NavGroup.test.tsx +55 -0
- package/bizar-dash/tests/ui/navigation/NavLink.test.tsx +61 -0
- package/bizar-dash/tests/ui/primitives/Box.test.tsx +49 -0
- package/bizar-dash/tests/ui/primitives/Grid.test.tsx +37 -0
- package/bizar-dash/tests/ui/primitives/Inline.test.tsx +33 -0
- package/bizar-dash/tests/ui/primitives/Separator.test.tsx +34 -0
- package/bizar-dash/tests/ui/primitives/Stack.test.tsx +45 -0
- package/bizar-dash/tests/ui/primitives/VisuallyHidden.test.tsx +27 -0
- package/bizar-dash/tests/views/Agents.test.tsx +359 -0
- package/bizar-dash/tests/views/Overview.test.tsx +413 -0
- package/bizar-dash/tests/views/Tasks.test.tsx +250 -0
- package/bizar-dash/vitest.config.ts +3 -1
- package/cli/__tests__/cost-gate.test.mjs +301 -0
- package/cli/__tests__/feature-list-bridge.test.mjs +371 -0
- package/cli/bin.mjs +38 -0
- package/cli/commands/claim.mjs +282 -0
- package/cli/commands/cost.mjs +279 -0
- package/cli/cost-gate.mjs +501 -0
- package/cli/feature-list-bridge.mjs +400 -0
- package/cli/memory-constants.mjs +17 -0
- package/cli/worker-dispatcher.mjs +259 -0
- package/cli/worker-dispatcher.test.mjs +204 -0
- package/config/trigger-patterns.json +186 -0
- package/package.json +2 -2
- package/packages/sdk/package.json +1 -1
- package/packages/sdk/src/agent-registry.ts +304 -0
- package/packages/sdk/src/consensus/byzantine.ts +587 -0
- package/packages/sdk/src/consensus/index.ts +147 -0
- package/packages/sdk/src/consensus/queen.ts +173 -0
- package/packages/sdk/src/consensus/types.ts +199 -0
- package/packages/sdk/src/federation/audit.ts +156 -0
- package/packages/sdk/src/federation/budget.ts +269 -0
- package/packages/sdk/src/federation/envelope.ts +144 -0
- package/packages/sdk/src/federation/hmac.ts +160 -0
- package/packages/sdk/src/federation/index.ts +443 -0
- package/packages/sdk/src/federation/pii.ts +241 -0
- package/packages/sdk/src/federation/policy.ts +112 -0
- package/packages/sdk/src/federation/trust.ts +146 -0
- package/packages/sdk/src/index.ts +67 -0
- package/packages/sdk/src/mcp/server.ts +351 -1
- package/packages/sdk/src/router/codemod-intent.ts +125 -0
- package/packages/sdk/src/router/index.ts +247 -0
- package/packages/sdk/src/router/memory-distillation-shim.mjs +18 -0
- package/packages/sdk/src/router/memory-distillation.ts +249 -0
- package/packages/sdk/src/router/model-router.ts +235 -0
- package/packages/sdk/src/router/q-learning-router.ts +304 -0
- package/packages/sdk/src/swarm-topology.ts +279 -0
- package/packages/sdk/tests/agent-registry.test.ts +285 -0
- package/packages/sdk/tests/consensus.test.ts +376 -0
- package/packages/sdk/tests/federation/audit.test.ts +164 -0
- package/packages/sdk/tests/federation/budget.test.ts +189 -0
- package/packages/sdk/tests/federation/envelope.test.ts +120 -0
- package/packages/sdk/tests/federation/hmac.test.ts +194 -0
- package/packages/sdk/tests/federation/orchestrator.test.ts +176 -0
- package/packages/sdk/tests/federation/pii.test.ts +106 -0
- package/packages/sdk/tests/federation/policy.test.ts +140 -0
- package/packages/sdk/tests/federation/trust.test.ts +124 -0
- package/packages/sdk/tests/mcp-tools.test.ts +204 -0
- package/packages/sdk/tests/memory-distillation.test.mjs +186 -0
- package/packages/sdk/tests/model-router.test.mjs +108 -0
- package/packages/sdk/tests/q-learning-router.test.mjs +100 -0
- package/packages/sdk/tests/router-orchestrator.test.mjs +172 -0
- package/packages/sdk/tests/router.test.mjs +91 -0
- package/packages/sdk/tests/sdk.test.mjs +26 -2
- package/packages/sdk/tests/swarm-topology.test.ts +258 -0
- package/scripts/bh-full-e2e.mjs +11 -15
- package/bizar-dash/dist/assets/MobileChat-BJrqwVDd.js +0 -1
- package/bizar-dash/dist/assets/MobileSettings-CEQNJNLJ.js +0 -1
- package/bizar-dash/dist/assets/icons-Do5N2jmX.js.map +0 -1
- package/bizar-dash/dist/assets/main-IvfQAOfy.js +0 -18
- package/bizar-dash/dist/assets/main-IvfQAOfy.js.map +0 -1
- package/bizar-dash/dist/assets/main-ietCEg_R.css +0 -1
- package/bizar-dash/dist/assets/markdown-tOLaD6nm.js +0 -1
- package/bizar-dash/dist/assets/mobile-DYCHcUpq.js +0 -1
- package/bizar-dash/dist/assets/mobile-layout-CBHjpwsb.js +0 -2
- package/bizar-dash/dist/assets/mobile-layout-CBHjpwsb.js.map +0 -1
- package/bizar-dash/dist/assets/react-vendor-Dn4wqh4Z.js +0 -40
- package/bizar-dash/dist/assets/react-vendor-Dn4wqh4Z.js.map +0 -1
- package/bizar-dash/dist/assets/useSlashCommands-Bd7_FA6U.js +0 -2
- package/bizar-dash/dist/assets/useSlashCommands-Bd7_FA6U.js.map +0 -1
- package/bizar-dash/dist/assets/vendor-C843201K.js +0 -29
- package/bizar-dash/dist/assets/vendor-C843201K.js.map +0 -1
- package/packages/sdk/package-lock.json +0 -32
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as E,t as p,b,V as O,d as M,v,e as P,g as d,h as j,i as N,j as T}from"./vendor-Di7Cp-rw.js";import{j as u}from"./react-vendor-D3pra6w-.js";function R(r){const e=this;e.parser=s;function s(n){return E(n,{...e.data("settings"),...r,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function H(r,e){return r&&"run"in r?async function(s,n){const l=p(s,{file:n,...e});await r.run(l,n)}:function(s,n){return p(s,{file:n,...r||e})}}const F="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",w=[],g={allowDangerousHtml:!0},S=/^(https?|ircs?|mailto|xmpp)$/i,D=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function K(r){const e=I(r),s=U(r);return V(e.runSync(e.parse(s),s),r)}function I(r){const e=r.rehypePlugins||w,s=r.remarkPlugins||w,n=r.remarkRehypeOptions?{...r.remarkRehypeOptions,...g}:g;return b().use(R).use(s).use(H,n).use(e)}function U(r){const e=r.children||"",s=new O;return typeof e=="string"&&(s.value=e),s}function V(r,e){const s=e.allowedElements,n=e.allowElement,l=e.components,m=e.disallowedElements,c=e.skipHtml,h=e.unwrapDisallowed,k=e.urlTransform||q;for(const o of D)Object.hasOwn(e,o.from)&&M("Unexpected `"+o.from+"` prop, "+(o.to?"use `"+o.to+"` instead":"remove it")+" (see <"+F+"#"+o.id+"> for more info)");return e.className&&(r={type:"element",tagName:"div",properties:{className:e.className},children:r.type==="root"?r.children:[r]}),v(r,y),P(r,{Fragment:u.Fragment,components:l,ignoreInvalidStyle:!0,jsx:u.jsx,jsxs:u.jsxs,passKeys:!0,passNode:!0});function y(o,a,i){if(o.type==="raw"&&i&&typeof a=="number")return c?i.children.splice(a,1):i.children[a]={type:"text",value:o.value},a;if(o.type==="element"){let t;for(t in d)if(Object.hasOwn(d,t)&&Object.hasOwn(o.properties,t)){const x=o.properties[t],f=d[t];(f===null||f.includes(o.tagName))&&(o.properties[t]=k(String(x||""),t,o))}}if(o.type==="element"){let t=s?!s.includes(o.tagName):m?m.includes(o.tagName):!1;if(!t&&n&&typeof a=="number"&&(t=!n(o,a,i)),t&&i&&typeof a=="number")return h&&o.children?i.children.splice(a,1,...o.children):i.children.splice(a,1),a}}}function q(r){const e=r.indexOf(":"),s=r.indexOf("?"),n=r.indexOf("#"),l=r.indexOf("/");return e===-1||l!==-1&&e>l||s!==-1&&e>s||n!==-1&&e>n||S.test(r.slice(0,e))?r:""}const A={};function L(r){const e=this,s=r||A,n=e.data(),l=n.micromarkExtensions||(n.micromarkExtensions=[]),m=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),c=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);l.push(j(s)),m.push(N()),c.push(T(s))}export{K as M,L as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-tOLaD6nm.js","sources":["../../../node_modules/remark-parse/lib/index.js","../../../node_modules/remark-rehype/lib/index.js","../../../node_modules/react-markdown/lib/index.js","../../../node_modules/remark-gfm/lib/index.js"],"sourcesContent":["/**\n * @typedef {import('mdast').Root} Root\n * @typedef {import('mdast-util-from-markdown').Options} FromMarkdownOptions\n * @typedef {import('unified').Parser<Root>} Parser\n * @typedef {import('unified').Processor<Root>} Processor\n */\n\n/**\n * @typedef {Omit<FromMarkdownOptions, 'extensions' | 'mdastExtensions'>} Options\n */\n\nimport {fromMarkdown} from 'mdast-util-from-markdown'\n\n/**\n * Aadd support for parsing from markdown.\n *\n * @param {Readonly<Options> | null | undefined} [options]\n * Configuration (optional).\n * @returns {undefined}\n * Nothing.\n */\nexport default function remarkParse(options) {\n /** @type {Processor} */\n // @ts-expect-error: TS in JSDoc generates wrong types if `this` is typed regularly.\n const self = this\n\n self.parser = parser\n\n /**\n * @type {Parser}\n */\n function parser(doc) {\n return fromMarkdown(doc, {\n ...self.data('settings'),\n ...options,\n // Note: these options are not in the readme.\n // The goal is for them to be set by plugins on `data` instead of being\n // passed by users.\n extensions: self.data('micromarkExtensions') || [],\n mdastExtensions: self.data('fromMarkdownExtensions') || []\n })\n }\n}\n","/**\n * @import {Root as HastRoot} from 'hast'\n * @import {Root as MdastRoot} from 'mdast'\n * @import {Options as ToHastOptions} from 'mdast-util-to-hast'\n * @import {Processor} from 'unified'\n * @import {VFile} from 'vfile'\n */\n\n/**\n * @typedef {Omit<ToHastOptions, 'file'>} Options\n *\n * @callback TransformBridge\n * Bridge-mode.\n *\n * Runs the destination with the new hast tree.\n * Discards result.\n * @param {MdastRoot} tree\n * Tree.\n * @param {VFile} file\n * File.\n * @returns {Promise<undefined>}\n * Nothing.\n *\n * @callback TransformMutate\n * Mutate-mode.\n *\n * Further transformers run on the hast tree.\n * @param {MdastRoot} tree\n * Tree.\n * @param {VFile} file\n * File.\n * @returns {HastRoot}\n * Tree (hast).\n */\n\nimport {toHast} from 'mdast-util-to-hast'\n\n/**\n * Turn markdown into HTML.\n *\n * ##### Notes\n *\n * ###### Signature\n *\n * * if a processor is given,\n * runs the (rehype) plugins used on it with a hast tree,\n * then discards the result (*bridge mode*)\n * * otherwise,\n * returns a hast tree,\n * the plugins used after `remarkRehype` are rehype plugins (*mutate mode*)\n *\n * > 👉 **Note**:\n * > It’s highly unlikely that you want to pass a `processor`.\n *\n * ###### HTML\n *\n * Raw HTML is available in mdast as `html` nodes and can be embedded in hast\n * as semistandard `raw` nodes.\n * Most plugins ignore `raw` nodes but two notable ones don’t:\n *\n * * `rehype-stringify` also has an option `allowDangerousHtml` which will\n * output the raw HTML.\n * This is typically discouraged as noted by the option name but is useful if\n * you completely trust authors\n * * `rehype-raw` can handle the raw embedded HTML strings by parsing them\n * into standard hast nodes (`element`, `text`, etc);\n * this is a heavy task as it needs a full HTML parser,\n * but it is the only way to support untrusted content\n *\n * ###### Footnotes\n *\n * Many options supported here relate to footnotes.\n * Footnotes are not specified by CommonMark,\n * which we follow by default.\n * They are supported by GitHub,\n * so footnotes can be enabled in markdown with `remark-gfm`.\n *\n * The options `footnoteBackLabel` and `footnoteLabel` define natural language\n * that explains footnotes,\n * which is hidden for sighted users but shown to assistive technology.\n * When your page is not in English,\n * you must define translated values.\n *\n * Back references use ARIA attributes,\n * but the section label itself uses a heading that is hidden with an\n * `sr-only` class.\n * To show it to sighted users,\n * define different attributes in `footnoteLabelProperties`.\n *\n * ###### Clobbering\n *\n * Footnotes introduces a problem,\n * as it links footnote calls to footnote definitions on the page through `id`\n * attributes generated from user content,\n * which results in DOM clobbering.\n *\n * DOM clobbering is this:\n *\n * ```html\n * <p id=x></p>\n * <script>alert(x) // `x` now refers to the DOM `p#x` element</script>\n * ```\n *\n * Elements by their ID are made available by browsers on the `window` object,\n * which is a security risk.\n * Using a prefix solves this problem.\n *\n * More information on how to handle clobbering and the prefix is explained in\n * *Example: headings (DOM clobbering)* in `rehype-sanitize`.\n *\n * ###### Unknown nodes\n *\n * Unknown nodes are nodes with a type that isn’t in `handlers` or `passThrough`.\n * The default behavior for unknown nodes is:\n *\n * * when the node has a `value`\n * (and doesn’t have `data.hName`, `data.hProperties`, or `data.hChildren`,\n * see later),\n * create a hast `text` node\n * * otherwise,\n * create a `<div>` element (which could be changed with `data.hName`),\n * with its children mapped from mdast to hast as well\n *\n * This behavior can be changed by passing an `unknownHandler`.\n *\n * @overload\n * @param {Processor} processor\n * @param {Readonly<Options> | null | undefined} [options]\n * @returns {TransformBridge}\n *\n * @overload\n * @param {Readonly<Options> | null | undefined} [options]\n * @returns {TransformMutate}\n *\n * @overload\n * @param {Readonly<Options> | Processor | null | undefined} [destination]\n * @param {Readonly<Options> | null | undefined} [options]\n * @returns {TransformBridge | TransformMutate}\n *\n * @param {Readonly<Options> | Processor | null | undefined} [destination]\n * Processor or configuration (optional).\n * @param {Readonly<Options> | null | undefined} [options]\n * When a processor was given,\n * configuration (optional).\n * @returns {TransformBridge | TransformMutate}\n * Transform.\n */\nexport default function remarkRehype(destination, options) {\n if (destination && 'run' in destination) {\n /**\n * @type {TransformBridge}\n */\n return async function (tree, file) {\n // Cast because root in -> root out.\n const hastTree = /** @type {HastRoot} */ (\n toHast(tree, {file, ...options})\n )\n await destination.run(hastTree, file)\n }\n }\n\n /**\n * @type {TransformMutate}\n */\n return function (tree, file) {\n // Cast because root in -> root out.\n // To do: in the future, disallow ` || options` fallback.\n // With `unified-engine`, `destination` can be `undefined` but\n // `options` will be the file set.\n // We should not pass that as `options`.\n return /** @type {HastRoot} */ (\n toHast(tree, {file, ...(destination || options)})\n )\n }\n}\n","/**\n * @import {Element, ElementContent, Nodes, Parents, Root} from 'hast'\n * @import {Root as MdastRoot} from 'mdast'\n * @import {ComponentProps, ElementType, ReactElement} from 'react'\n * @import {Options as RemarkRehypeOptions} from 'remark-rehype'\n * @import {BuildVisitor} from 'unist-util-visit'\n * @import {PluggableList, Processor} from 'unified'\n */\n\n/**\n * @callback AllowElement\n * Filter elements.\n * @param {Readonly<Element>} element\n * Element to check.\n * @param {number} index\n * Index of `element` in `parent`.\n * @param {Readonly<Parents> | undefined} parent\n * Parent of `element`.\n * @returns {boolean | null | undefined}\n * Whether to allow `element` (default: `false`).\n */\n\n/**\n * @typedef ExtraProps\n * Extra fields we pass.\n * @property {Element | undefined} [node]\n * passed when `passNode` is on.\n */\n\n/**\n * @typedef {{\n * [Key in Extract<ElementType, string>]?: ElementType<ComponentProps<Key> & ExtraProps>\n * }} Components\n * Map tag names to components.\n */\n\n/**\n * @typedef Deprecation\n * Deprecation.\n * @property {string} from\n * Old field.\n * @property {string} id\n * ID in readme.\n * @property {keyof Options} [to]\n * New field.\n */\n\n/**\n * @typedef Options\n * Configuration.\n * @property {AllowElement | null | undefined} [allowElement]\n * Filter elements (optional);\n * `allowedElements` / `disallowedElements` is used first.\n * @property {ReadonlyArray<string> | null | undefined} [allowedElements]\n * Tag names to allow (default: all tag names);\n * cannot combine w/ `disallowedElements`.\n * @property {string | null | undefined} [children]\n * Markdown.\n * @property {string | null | undefined} [className]\n * Wrap in a `div` with this class name.\n * @property {Components | null | undefined} [components]\n * Map tag names to components.\n * @property {ReadonlyArray<string> | null | undefined} [disallowedElements]\n * Tag names to disallow (default: `[]`);\n * cannot combine w/ `allowedElements`.\n * @property {PluggableList | null | undefined} [rehypePlugins]\n * List of rehype plugins to use.\n * @property {PluggableList | null | undefined} [remarkPlugins]\n * List of remark plugins to use.\n * @property {Readonly<RemarkRehypeOptions> | null | undefined} [remarkRehypeOptions]\n * Options to pass through to `remark-rehype`.\n * @property {boolean | null | undefined} [skipHtml=false]\n * Ignore HTML in markdown completely (default: `false`).\n * @property {boolean | null | undefined} [unwrapDisallowed=false]\n * Extract (unwrap) what’s in disallowed elements (default: `false`);\n * normally when say `strong` is not allowed, it and it’s children are dropped,\n * with `unwrapDisallowed` the element itself is replaced by its children.\n * @property {UrlTransform | null | undefined} [urlTransform]\n * Change URLs (default: `defaultUrlTransform`)\n */\n\n/**\n * @callback UrlTransform\n * Transform all URLs.\n * @param {string} url\n * URL.\n * @param {string} key\n * Property name (example: `'href'`).\n * @param {Readonly<Element>} node\n * Node.\n * @returns {string | null | undefined}\n * Transformed URL (optional).\n */\n\nimport {unreachable} from 'devlop'\nimport {toJsxRuntime} from 'hast-util-to-jsx-runtime'\nimport {urlAttributes} from 'html-url-attributes'\nimport {Fragment, jsx, jsxs} from 'react/jsx-runtime'\nimport {createElement, useEffect, useState} from 'react'\nimport remarkParse from 'remark-parse'\nimport remarkRehype from 'remark-rehype'\nimport {unified} from 'unified'\nimport {visit} from 'unist-util-visit'\nimport {VFile} from 'vfile'\n\nconst changelog =\n 'https://github.com/remarkjs/react-markdown/blob/main/changelog.md'\n\n/** @type {PluggableList} */\nconst emptyPlugins = []\n/** @type {Readonly<RemarkRehypeOptions>} */\nconst emptyRemarkRehypeOptions = {allowDangerousHtml: true}\nconst safeProtocol = /^(https?|ircs?|mailto|xmpp)$/i\n\n// Mutable because we `delete` any time it’s used and a message is sent.\n/** @type {ReadonlyArray<Readonly<Deprecation>>} */\nconst deprecations = [\n {from: 'astPlugins', id: 'remove-buggy-html-in-markdown-parser'},\n {from: 'allowDangerousHtml', id: 'remove-buggy-html-in-markdown-parser'},\n {\n from: 'allowNode',\n id: 'replace-allownode-allowedtypes-and-disallowedtypes',\n to: 'allowElement'\n },\n {\n from: 'allowedTypes',\n id: 'replace-allownode-allowedtypes-and-disallowedtypes',\n to: 'allowedElements'\n },\n {\n from: 'disallowedTypes',\n id: 'replace-allownode-allowedtypes-and-disallowedtypes',\n to: 'disallowedElements'\n },\n {from: 'escapeHtml', id: 'remove-buggy-html-in-markdown-parser'},\n {from: 'includeElementIndex', id: '#remove-includeelementindex'},\n {\n from: 'includeNodeIndex',\n id: 'change-includenodeindex-to-includeelementindex'\n },\n {from: 'linkTarget', id: 'remove-linktarget'},\n {from: 'plugins', id: 'change-plugins-to-remarkplugins', to: 'remarkPlugins'},\n {from: 'rawSourcePos', id: '#remove-rawsourcepos'},\n {from: 'renderers', id: 'change-renderers-to-components', to: 'components'},\n {from: 'source', id: 'change-source-to-children', to: 'children'},\n {from: 'sourcePos', id: '#remove-sourcepos'},\n {from: 'transformImageUri', id: '#add-urltransform', to: 'urlTransform'},\n {from: 'transformLinkUri', id: '#add-urltransform', to: 'urlTransform'}\n]\n\n/**\n * Component to render markdown.\n *\n * This is a synchronous component.\n * When using async plugins,\n * see {@linkcode MarkdownAsync} or {@linkcode MarkdownHooks}.\n *\n * @param {Readonly<Options>} options\n * Props.\n * @returns {ReactElement}\n * React element.\n */\nexport function Markdown(options) {\n const processor = createProcessor(options)\n const file = createFile(options)\n return post(processor.runSync(processor.parse(file), file), options)\n}\n\n/**\n * Component to render markdown with support for async plugins\n * through async/await.\n *\n * Components returning promises are supported on the server.\n * For async support on the client,\n * see {@linkcode MarkdownHooks}.\n *\n * @param {Readonly<Options>} options\n * Props.\n * @returns {Promise<ReactElement>}\n * Promise to a React element.\n */\nexport async function MarkdownAsync(options) {\n const processor = createProcessor(options)\n const file = createFile(options)\n const tree = await processor.run(processor.parse(file), file)\n return post(tree, options)\n}\n\n/**\n * Component to render markdown with support for async plugins through hooks.\n *\n * This uses `useEffect` and `useState` hooks.\n * Hooks run on the client and do not immediately render something.\n * For async support on the server,\n * see {@linkcode MarkdownAsync}.\n *\n * @param {Readonly<Options>} options\n * Props.\n * @returns {ReactElement}\n * React element.\n */\nexport function MarkdownHooks(options) {\n const processor = createProcessor(options)\n const [error, setError] = useState(\n /** @type {Error | undefined} */ (undefined)\n )\n const [tree, setTree] = useState(/** @type {Root | undefined} */ (undefined))\n\n useEffect(\n /* c8 ignore next 7 -- hooks are client-only. */\n function () {\n const file = createFile(options)\n processor.run(processor.parse(file), file, function (error, tree) {\n setError(error)\n setTree(tree)\n })\n },\n [\n options.children,\n options.rehypePlugins,\n options.remarkPlugins,\n options.remarkRehypeOptions\n ]\n )\n\n /* c8 ignore next -- hooks are client-only. */\n if (error) throw error\n\n /* c8 ignore next -- hooks are client-only. */\n return tree ? post(tree, options) : createElement(Fragment)\n}\n\n/**\n * Set up the `unified` processor.\n *\n * @param {Readonly<Options>} options\n * Props.\n * @returns {Processor<MdastRoot, MdastRoot, Root, undefined, undefined>}\n * Result.\n */\nfunction createProcessor(options) {\n const rehypePlugins = options.rehypePlugins || emptyPlugins\n const remarkPlugins = options.remarkPlugins || emptyPlugins\n const remarkRehypeOptions = options.remarkRehypeOptions\n ? {...options.remarkRehypeOptions, ...emptyRemarkRehypeOptions}\n : emptyRemarkRehypeOptions\n\n const processor = unified()\n .use(remarkParse)\n .use(remarkPlugins)\n .use(remarkRehype, remarkRehypeOptions)\n .use(rehypePlugins)\n\n return processor\n}\n\n/**\n * Set up the virtual file.\n *\n * @param {Readonly<Options>} options\n * Props.\n * @returns {VFile}\n * Result.\n */\nfunction createFile(options) {\n const children = options.children || ''\n const file = new VFile()\n\n if (typeof children === 'string') {\n file.value = children\n } else {\n unreachable(\n 'Unexpected value `' +\n children +\n '` for `children` prop, expected `string`'\n )\n }\n\n return file\n}\n\n/**\n * Process the result from unified some more.\n *\n * @param {Nodes} tree\n * Tree.\n * @param {Readonly<Options>} options\n * Props.\n * @returns {ReactElement}\n * React element.\n */\nfunction post(tree, options) {\n const allowedElements = options.allowedElements\n const allowElement = options.allowElement\n const components = options.components\n const disallowedElements = options.disallowedElements\n const skipHtml = options.skipHtml\n const unwrapDisallowed = options.unwrapDisallowed\n const urlTransform = options.urlTransform || defaultUrlTransform\n\n for (const deprecation of deprecations) {\n if (Object.hasOwn(options, deprecation.from)) {\n unreachable(\n 'Unexpected `' +\n deprecation.from +\n '` prop, ' +\n (deprecation.to\n ? 'use `' + deprecation.to + '` instead'\n : 'remove it') +\n ' (see <' +\n changelog +\n '#' +\n deprecation.id +\n '> for more info)'\n )\n }\n }\n\n if (allowedElements && disallowedElements) {\n unreachable(\n 'Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other'\n )\n }\n\n // Wrap in `div` if there’s a class name.\n if (options.className) {\n tree = {\n type: 'element',\n tagName: 'div',\n properties: {className: options.className},\n // Assume no doctypes.\n children: /** @type {Array<ElementContent>} */ (\n tree.type === 'root' ? tree.children : [tree]\n )\n }\n }\n\n visit(tree, transform)\n\n return toJsxRuntime(tree, {\n Fragment,\n // @ts-expect-error\n // React components are allowed to return numbers,\n // but not according to the types in hast-util-to-jsx-runtime\n components,\n ignoreInvalidStyle: true,\n jsx,\n jsxs,\n passKeys: true,\n passNode: true\n })\n\n /** @type {BuildVisitor<Root>} */\n function transform(node, index, parent) {\n if (node.type === 'raw' && parent && typeof index === 'number') {\n if (skipHtml) {\n parent.children.splice(index, 1)\n } else {\n parent.children[index] = {type: 'text', value: node.value}\n }\n\n return index\n }\n\n if (node.type === 'element') {\n /** @type {string} */\n let key\n\n for (key in urlAttributes) {\n if (\n Object.hasOwn(urlAttributes, key) &&\n Object.hasOwn(node.properties, key)\n ) {\n const value = node.properties[key]\n const test = urlAttributes[key]\n if (test === null || test.includes(node.tagName)) {\n node.properties[key] = urlTransform(String(value || ''), key, node)\n }\n }\n }\n }\n\n if (node.type === 'element') {\n let remove = allowedElements\n ? !allowedElements.includes(node.tagName)\n : disallowedElements\n ? disallowedElements.includes(node.tagName)\n : false\n\n if (!remove && allowElement && typeof index === 'number') {\n remove = !allowElement(node, index, parent)\n }\n\n if (remove && parent && typeof index === 'number') {\n if (unwrapDisallowed && node.children) {\n parent.children.splice(index, 1, ...node.children)\n } else {\n parent.children.splice(index, 1)\n }\n\n return index\n }\n }\n }\n}\n\n/**\n * Make a URL safe.\n *\n * @satisfies {UrlTransform}\n * @param {string} value\n * URL.\n * @returns {string}\n * Safe URL.\n */\nexport function defaultUrlTransform(value) {\n // Same as:\n // <https://github.com/micromark/micromark/blob/929275e/packages/micromark-util-sanitize-uri/dev/index.js#L34>\n // But without the `encode` part.\n const colon = value.indexOf(':')\n const questionMark = value.indexOf('?')\n const numberSign = value.indexOf('#')\n const slash = value.indexOf('/')\n\n if (\n // If there is no protocol, it’s relative.\n colon === -1 ||\n // If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.\n (slash !== -1 && colon > slash) ||\n (questionMark !== -1 && colon > questionMark) ||\n (numberSign !== -1 && colon > numberSign) ||\n // It is a protocol, it should be allowed.\n safeProtocol.test(value.slice(0, colon))\n ) {\n return value\n }\n\n return ''\n}\n","/**\n * @import {Root} from 'mdast'\n * @import {Options} from 'remark-gfm'\n * @import {} from 'remark-parse'\n * @import {} from 'remark-stringify'\n * @import {Processor} from 'unified'\n */\n\nimport {gfmFromMarkdown, gfmToMarkdown} from 'mdast-util-gfm'\nimport {gfm} from 'micromark-extension-gfm'\n\n/** @type {Options} */\nconst emptyOptions = {}\n\n/**\n * Add support GFM (autolink literals, footnotes, strikethrough, tables,\n * tasklists).\n *\n * @param {Options | null | undefined} [options]\n * Configuration (optional).\n * @returns {undefined}\n * Nothing.\n */\nexport default function remarkGfm(options) {\n // @ts-expect-error: TS is wrong about `this`.\n // eslint-disable-next-line unicorn/no-this-assignment\n const self = /** @type {Processor<Root>} */ (this)\n const settings = options || emptyOptions\n const data = self.data()\n\n const micromarkExtensions =\n data.micromarkExtensions || (data.micromarkExtensions = [])\n const fromMarkdownExtensions =\n data.fromMarkdownExtensions || (data.fromMarkdownExtensions = [])\n const toMarkdownExtensions =\n data.toMarkdownExtensions || (data.toMarkdownExtensions = [])\n\n micromarkExtensions.push(gfm(settings))\n fromMarkdownExtensions.push(gfmFromMarkdown())\n toMarkdownExtensions.push(gfmToMarkdown(settings))\n}\n"],"names":["remarkParse","options","self","parser","doc","fromMarkdown","remarkRehype","destination","tree","file","hastTree","toHast","changelog","emptyPlugins","emptyRemarkRehypeOptions","safeProtocol","deprecations","Markdown","processor","createProcessor","createFile","post","rehypePlugins","remarkPlugins","remarkRehypeOptions","unified","children","VFile","allowedElements","allowElement","components","disallowedElements","skipHtml","unwrapDisallowed","urlTransform","defaultUrlTransform","deprecation","unreachable","visit","transform","toJsxRuntime","Fragment","jsx","jsxs","node","index","parent","key","urlAttributes","value","test","remove","colon","questionMark","numberSign","slash","emptyOptions","remarkGfm","settings","data","micromarkExtensions","fromMarkdownExtensions","toMarkdownExtensions","gfm","gfmFromMarkdown","gfmToMarkdown"],"mappings":"yJAqBe,SAASA,EAAYC,EAAS,CAG3C,MAAMC,EAAO,KAEbA,EAAK,OAASC,EAKd,SAASA,EAAOC,EAAK,CACnB,OAAOC,EAAaD,EAAK,CACvB,GAAGF,EAAK,KAAK,UAAU,EACvB,GAAGD,EAIH,WAAYC,EAAK,KAAK,qBAAqB,GAAK,CAAA,EAChD,gBAAiBA,EAAK,KAAK,wBAAwB,GAAK,CAAA,CAC9D,CAAK,CACH,CACF,CCyGe,SAASI,EAAaC,EAAaN,EAAS,CACzD,OAAIM,GAAe,QAASA,EAInB,eAAgBC,EAAMC,EAAM,CAEjC,MAAMC,EACJC,EAAOH,EAAM,CAAC,KAAAC,EAAM,GAAGR,CAAO,CAAC,EAEjC,MAAMM,EAAY,IAAIG,EAAUD,CAAI,CACtC,EAMK,SAAUD,EAAMC,EAAM,CAM3B,OACEE,EAAOH,EAAM,CAAC,KAAAC,EAAM,GAAIF,GAAeN,CAAQ,CAAC,CAEpD,CACF,CCrEA,MAAMW,EACJ,oEAGIC,EAAe,CAAA,EAEfC,EAA2B,CAAC,mBAAoB,EAAI,EACpDC,EAAe,gCAIfC,EAAe,CACnB,CAAC,KAAM,aAAc,GAAI,sCAAsC,EAC/D,CAAC,KAAM,qBAAsB,GAAI,sCAAsC,EACvE,CACE,KAAM,YACN,GAAI,qDACJ,GAAI,cACR,EACE,CACE,KAAM,eACN,GAAI,qDACJ,GAAI,iBACR,EACE,CACE,KAAM,kBACN,GAAI,qDACJ,GAAI,oBACR,EACE,CAAC,KAAM,aAAc,GAAI,sCAAsC,EAC/D,CAAC,KAAM,sBAAuB,GAAI,6BAA6B,EAC/D,CACE,KAAM,mBACN,GAAI,gDACR,EACE,CAAC,KAAM,aAAc,GAAI,mBAAmB,EAC5C,CAAC,KAAM,UAAW,GAAI,kCAAmC,GAAI,eAAe,EAC5E,CAAC,KAAM,eAAgB,GAAI,sBAAsB,EACjD,CAAC,KAAM,YAAa,GAAI,iCAAkC,GAAI,YAAY,EAC1E,CAAC,KAAM,SAAU,GAAI,4BAA6B,GAAI,UAAU,EAChE,CAAC,KAAM,YAAa,GAAI,mBAAmB,EAC3C,CAAC,KAAM,oBAAqB,GAAI,oBAAqB,GAAI,cAAc,EACvE,CAAC,KAAM,mBAAoB,GAAI,oBAAqB,GAAI,cAAc,CACxE,EAcO,SAASC,EAAShB,EAAS,CAChC,MAAMiB,EAAYC,EAAgBlB,CAAO,EACnCQ,EAAOW,EAAWnB,CAAO,EAC/B,OAAOoB,EAAKH,EAAU,QAAQA,EAAU,MAAMT,CAAI,EAAGA,CAAI,EAAGR,CAAO,CACrE,CA0EA,SAASkB,EAAgBlB,EAAS,CAChC,MAAMqB,EAAgBrB,EAAQ,eAAiBY,EACzCU,EAAgBtB,EAAQ,eAAiBY,EACzCW,EAAsBvB,EAAQ,oBAChC,CAAC,GAAGA,EAAQ,oBAAqB,GAAGa,CAAwB,EAC5DA,EAQJ,OANkBW,EAAO,EACtB,IAAIzB,CAAW,EACf,IAAIuB,CAAa,EACjB,IAAIjB,EAAckB,CAAmB,EACrC,IAAIF,CAAa,CAGtB,CAUA,SAASF,EAAWnB,EAAS,CAC3B,MAAMyB,EAAWzB,EAAQ,UAAY,GAC/BQ,EAAO,IAAIkB,EAEjB,OAAI,OAAOD,GAAa,WACtBjB,EAAK,MAAQiB,GASRjB,CACT,CAYA,SAASY,EAAKb,EAAMP,EAAS,CAC3B,MAAM2B,EAAkB3B,EAAQ,gBAC1B4B,EAAe5B,EAAQ,aACvB6B,EAAa7B,EAAQ,WACrB8B,EAAqB9B,EAAQ,mBAC7B+B,EAAW/B,EAAQ,SACnBgC,EAAmBhC,EAAQ,iBAC3BiC,EAAejC,EAAQ,cAAgBkC,EAE7C,UAAWC,KAAepB,EACpB,OAAO,OAAOf,EAASmC,EAAY,IAAI,GACzCC,EACE,eACED,EAAY,KACZ,YACCA,EAAY,GACT,QAAUA,EAAY,GAAK,YAC3B,aACJ,UACAxB,EACA,IACAwB,EAAY,GACZ,kBACV,EAWE,OAAInC,EAAQ,YACVO,EAAO,CACL,KAAM,UACN,QAAS,MACT,WAAY,CAAC,UAAWP,EAAQ,SAAS,EAEzC,SACEO,EAAK,OAAS,OAASA,EAAK,SAAW,CAACA,CAAI,CAEpD,GAGE8B,EAAM9B,EAAM+B,CAAS,EAEdC,EAAahC,EAAM,CAC5B,SAAIiC,EAAAA,SAIA,WAAAX,EACA,mBAAoB,GACxB,IAAIY,EAAAA,IACJ,KAAIC,EAAAA,KACA,SAAU,GACV,SAAU,EACd,CAAG,EAGD,SAASJ,EAAUK,EAAMC,EAAOC,EAAQ,CACtC,GAAIF,EAAK,OAAS,OAASE,GAAU,OAAOD,GAAU,SACpD,OAAIb,EACFc,EAAO,SAAS,OAAOD,EAAO,CAAC,EAE/BC,EAAO,SAASD,CAAK,EAAI,CAAC,KAAM,OAAQ,MAAOD,EAAK,KAAK,EAGpDC,EAGT,GAAID,EAAK,OAAS,UAAW,CAE3B,IAAIG,EAEJ,IAAKA,KAAOC,EACV,GACE,OAAO,OAAOA,EAAeD,CAAG,GAChC,OAAO,OAAOH,EAAK,WAAYG,CAAG,EAClC,CACA,MAAME,EAAQL,EAAK,WAAWG,CAAG,EAC3BG,EAAOF,EAAcD,CAAG,GAC1BG,IAAS,MAAQA,EAAK,SAASN,EAAK,OAAO,KAC7CA,EAAK,WAAWG,CAAG,EAAIb,EAAa,OAAOe,GAAS,EAAE,EAAGF,EAAKH,CAAI,EAEtE,CAEJ,CAEA,GAAIA,EAAK,OAAS,UAAW,CAC3B,IAAIO,EAASvB,EACT,CAACA,EAAgB,SAASgB,EAAK,OAAO,EACtCb,EACEA,EAAmB,SAASa,EAAK,OAAO,EACxC,GAMN,GAJI,CAACO,GAAUtB,GAAgB,OAAOgB,GAAU,WAC9CM,EAAS,CAACtB,EAAae,EAAMC,EAAOC,CAAM,GAGxCK,GAAUL,GAAU,OAAOD,GAAU,SACvC,OAAIZ,GAAoBW,EAAK,SAC3BE,EAAO,SAAS,OAAOD,EAAO,EAAG,GAAGD,EAAK,QAAQ,EAEjDE,EAAO,SAAS,OAAOD,EAAO,CAAC,EAG1BA,CAEX,CACF,CACF,CAWO,SAASV,EAAoBc,EAAO,CAIzC,MAAMG,EAAQH,EAAM,QAAQ,GAAG,EACzBI,EAAeJ,EAAM,QAAQ,GAAG,EAChCK,EAAaL,EAAM,QAAQ,GAAG,EAC9BM,EAAQN,EAAM,QAAQ,GAAG,EAE/B,OAEEG,IAAU,IAETG,IAAU,IAAMH,EAAQG,GACxBF,IAAiB,IAAMD,EAAQC,GAC/BC,IAAe,IAAMF,EAAQE,GAE9BvC,EAAa,KAAKkC,EAAM,MAAM,EAAGG,CAAK,CAAC,EAEhCH,EAGF,EACT,CC1aA,MAAMO,EAAe,CAAA,EAWN,SAASC,EAAUxD,EAAS,CAGzC,MAAMC,EAAuC,KACvCwD,EAAWzD,GAAWuD,EACtBG,EAAOzD,EAAK,KAAI,EAEhB0D,EACJD,EAAK,sBAAwBA,EAAK,oBAAsB,CAAA,GACpDE,EACJF,EAAK,yBAA2BA,EAAK,uBAAyB,CAAA,GAC1DG,EACJH,EAAK,uBAAyBA,EAAK,qBAAuB,CAAA,GAE5DC,EAAoB,KAAKG,EAAIL,CAAQ,CAAC,EACtCG,EAAuB,KAAKG,EAAe,CAAE,EAC7CF,EAAqB,KAAKG,EAAcP,CAAQ,CAAC,CACnD","x_google_ignoreList":[0,1,2,3]}
|
|
1
|
+
{"version":3,"file":"markdown-w2bDDkAH.js","sources":["../../../node_modules/remark-parse/lib/index.js","../../../node_modules/remark-rehype/lib/index.js","../../../node_modules/react-markdown/lib/index.js","../../../node_modules/remark-gfm/lib/index.js"],"sourcesContent":["/**\n * @typedef {import('mdast').Root} Root\n * @typedef {import('mdast-util-from-markdown').Options} FromMarkdownOptions\n * @typedef {import('unified').Parser<Root>} Parser\n * @typedef {import('unified').Processor<Root>} Processor\n */\n\n/**\n * @typedef {Omit<FromMarkdownOptions, 'extensions' | 'mdastExtensions'>} Options\n */\n\nimport {fromMarkdown} from 'mdast-util-from-markdown'\n\n/**\n * Aadd support for parsing from markdown.\n *\n * @param {Readonly<Options> | null | undefined} [options]\n * Configuration (optional).\n * @returns {undefined}\n * Nothing.\n */\nexport default function remarkParse(options) {\n /** @type {Processor} */\n // @ts-expect-error: TS in JSDoc generates wrong types if `this` is typed regularly.\n const self = this\n\n self.parser = parser\n\n /**\n * @type {Parser}\n */\n function parser(doc) {\n return fromMarkdown(doc, {\n ...self.data('settings'),\n ...options,\n // Note: these options are not in the readme.\n // The goal is for them to be set by plugins on `data` instead of being\n // passed by users.\n extensions: self.data('micromarkExtensions') || [],\n mdastExtensions: self.data('fromMarkdownExtensions') || []\n })\n }\n}\n","/**\n * @import {Root as HastRoot} from 'hast'\n * @import {Root as MdastRoot} from 'mdast'\n * @import {Options as ToHastOptions} from 'mdast-util-to-hast'\n * @import {Processor} from 'unified'\n * @import {VFile} from 'vfile'\n */\n\n/**\n * @typedef {Omit<ToHastOptions, 'file'>} Options\n *\n * @callback TransformBridge\n * Bridge-mode.\n *\n * Runs the destination with the new hast tree.\n * Discards result.\n * @param {MdastRoot} tree\n * Tree.\n * @param {VFile} file\n * File.\n * @returns {Promise<undefined>}\n * Nothing.\n *\n * @callback TransformMutate\n * Mutate-mode.\n *\n * Further transformers run on the hast tree.\n * @param {MdastRoot} tree\n * Tree.\n * @param {VFile} file\n * File.\n * @returns {HastRoot}\n * Tree (hast).\n */\n\nimport {toHast} from 'mdast-util-to-hast'\n\n/**\n * Turn markdown into HTML.\n *\n * ##### Notes\n *\n * ###### Signature\n *\n * * if a processor is given,\n * runs the (rehype) plugins used on it with a hast tree,\n * then discards the result (*bridge mode*)\n * * otherwise,\n * returns a hast tree,\n * the plugins used after `remarkRehype` are rehype plugins (*mutate mode*)\n *\n * > 👉 **Note**:\n * > It’s highly unlikely that you want to pass a `processor`.\n *\n * ###### HTML\n *\n * Raw HTML is available in mdast as `html` nodes and can be embedded in hast\n * as semistandard `raw` nodes.\n * Most plugins ignore `raw` nodes but two notable ones don’t:\n *\n * * `rehype-stringify` also has an option `allowDangerousHtml` which will\n * output the raw HTML.\n * This is typically discouraged as noted by the option name but is useful if\n * you completely trust authors\n * * `rehype-raw` can handle the raw embedded HTML strings by parsing them\n * into standard hast nodes (`element`, `text`, etc);\n * this is a heavy task as it needs a full HTML parser,\n * but it is the only way to support untrusted content\n *\n * ###### Footnotes\n *\n * Many options supported here relate to footnotes.\n * Footnotes are not specified by CommonMark,\n * which we follow by default.\n * They are supported by GitHub,\n * so footnotes can be enabled in markdown with `remark-gfm`.\n *\n * The options `footnoteBackLabel` and `footnoteLabel` define natural language\n * that explains footnotes,\n * which is hidden for sighted users but shown to assistive technology.\n * When your page is not in English,\n * you must define translated values.\n *\n * Back references use ARIA attributes,\n * but the section label itself uses a heading that is hidden with an\n * `sr-only` class.\n * To show it to sighted users,\n * define different attributes in `footnoteLabelProperties`.\n *\n * ###### Clobbering\n *\n * Footnotes introduces a problem,\n * as it links footnote calls to footnote definitions on the page through `id`\n * attributes generated from user content,\n * which results in DOM clobbering.\n *\n * DOM clobbering is this:\n *\n * ```html\n * <p id=x></p>\n * <script>alert(x) // `x` now refers to the DOM `p#x` element</script>\n * ```\n *\n * Elements by their ID are made available by browsers on the `window` object,\n * which is a security risk.\n * Using a prefix solves this problem.\n *\n * More information on how to handle clobbering and the prefix is explained in\n * *Example: headings (DOM clobbering)* in `rehype-sanitize`.\n *\n * ###### Unknown nodes\n *\n * Unknown nodes are nodes with a type that isn’t in `handlers` or `passThrough`.\n * The default behavior for unknown nodes is:\n *\n * * when the node has a `value`\n * (and doesn’t have `data.hName`, `data.hProperties`, or `data.hChildren`,\n * see later),\n * create a hast `text` node\n * * otherwise,\n * create a `<div>` element (which could be changed with `data.hName`),\n * with its children mapped from mdast to hast as well\n *\n * This behavior can be changed by passing an `unknownHandler`.\n *\n * @overload\n * @param {Processor} processor\n * @param {Readonly<Options> | null | undefined} [options]\n * @returns {TransformBridge}\n *\n * @overload\n * @param {Readonly<Options> | null | undefined} [options]\n * @returns {TransformMutate}\n *\n * @overload\n * @param {Readonly<Options> | Processor | null | undefined} [destination]\n * @param {Readonly<Options> | null | undefined} [options]\n * @returns {TransformBridge | TransformMutate}\n *\n * @param {Readonly<Options> | Processor | null | undefined} [destination]\n * Processor or configuration (optional).\n * @param {Readonly<Options> | null | undefined} [options]\n * When a processor was given,\n * configuration (optional).\n * @returns {TransformBridge | TransformMutate}\n * Transform.\n */\nexport default function remarkRehype(destination, options) {\n if (destination && 'run' in destination) {\n /**\n * @type {TransformBridge}\n */\n return async function (tree, file) {\n // Cast because root in -> root out.\n const hastTree = /** @type {HastRoot} */ (\n toHast(tree, {file, ...options})\n )\n await destination.run(hastTree, file)\n }\n }\n\n /**\n * @type {TransformMutate}\n */\n return function (tree, file) {\n // Cast because root in -> root out.\n // To do: in the future, disallow ` || options` fallback.\n // With `unified-engine`, `destination` can be `undefined` but\n // `options` will be the file set.\n // We should not pass that as `options`.\n return /** @type {HastRoot} */ (\n toHast(tree, {file, ...(destination || options)})\n )\n }\n}\n","/**\n * @import {Element, ElementContent, Nodes, Parents, Root} from 'hast'\n * @import {Root as MdastRoot} from 'mdast'\n * @import {ComponentProps, ElementType, ReactElement} from 'react'\n * @import {Options as RemarkRehypeOptions} from 'remark-rehype'\n * @import {BuildVisitor} from 'unist-util-visit'\n * @import {PluggableList, Processor} from 'unified'\n */\n\n/**\n * @callback AllowElement\n * Filter elements.\n * @param {Readonly<Element>} element\n * Element to check.\n * @param {number} index\n * Index of `element` in `parent`.\n * @param {Readonly<Parents> | undefined} parent\n * Parent of `element`.\n * @returns {boolean | null | undefined}\n * Whether to allow `element` (default: `false`).\n */\n\n/**\n * @typedef ExtraProps\n * Extra fields we pass.\n * @property {Element | undefined} [node]\n * passed when `passNode` is on.\n */\n\n/**\n * @typedef {{\n * [Key in Extract<ElementType, string>]?: ElementType<ComponentProps<Key> & ExtraProps>\n * }} Components\n * Map tag names to components.\n */\n\n/**\n * @typedef Deprecation\n * Deprecation.\n * @property {string} from\n * Old field.\n * @property {string} id\n * ID in readme.\n * @property {keyof Options} [to]\n * New field.\n */\n\n/**\n * @typedef Options\n * Configuration.\n * @property {AllowElement | null | undefined} [allowElement]\n * Filter elements (optional);\n * `allowedElements` / `disallowedElements` is used first.\n * @property {ReadonlyArray<string> | null | undefined} [allowedElements]\n * Tag names to allow (default: all tag names);\n * cannot combine w/ `disallowedElements`.\n * @property {string | null | undefined} [children]\n * Markdown.\n * @property {string | null | undefined} [className]\n * Wrap in a `div` with this class name.\n * @property {Components | null | undefined} [components]\n * Map tag names to components.\n * @property {ReadonlyArray<string> | null | undefined} [disallowedElements]\n * Tag names to disallow (default: `[]`);\n * cannot combine w/ `allowedElements`.\n * @property {PluggableList | null | undefined} [rehypePlugins]\n * List of rehype plugins to use.\n * @property {PluggableList | null | undefined} [remarkPlugins]\n * List of remark plugins to use.\n * @property {Readonly<RemarkRehypeOptions> | null | undefined} [remarkRehypeOptions]\n * Options to pass through to `remark-rehype`.\n * @property {boolean | null | undefined} [skipHtml=false]\n * Ignore HTML in markdown completely (default: `false`).\n * @property {boolean | null | undefined} [unwrapDisallowed=false]\n * Extract (unwrap) what’s in disallowed elements (default: `false`);\n * normally when say `strong` is not allowed, it and it’s children are dropped,\n * with `unwrapDisallowed` the element itself is replaced by its children.\n * @property {UrlTransform | null | undefined} [urlTransform]\n * Change URLs (default: `defaultUrlTransform`)\n */\n\n/**\n * @callback UrlTransform\n * Transform all URLs.\n * @param {string} url\n * URL.\n * @param {string} key\n * Property name (example: `'href'`).\n * @param {Readonly<Element>} node\n * Node.\n * @returns {string | null | undefined}\n * Transformed URL (optional).\n */\n\nimport {unreachable} from 'devlop'\nimport {toJsxRuntime} from 'hast-util-to-jsx-runtime'\nimport {urlAttributes} from 'html-url-attributes'\nimport {Fragment, jsx, jsxs} from 'react/jsx-runtime'\nimport {createElement, useEffect, useState} from 'react'\nimport remarkParse from 'remark-parse'\nimport remarkRehype from 'remark-rehype'\nimport {unified} from 'unified'\nimport {visit} from 'unist-util-visit'\nimport {VFile} from 'vfile'\n\nconst changelog =\n 'https://github.com/remarkjs/react-markdown/blob/main/changelog.md'\n\n/** @type {PluggableList} */\nconst emptyPlugins = []\n/** @type {Readonly<RemarkRehypeOptions>} */\nconst emptyRemarkRehypeOptions = {allowDangerousHtml: true}\nconst safeProtocol = /^(https?|ircs?|mailto|xmpp)$/i\n\n// Mutable because we `delete` any time it’s used and a message is sent.\n/** @type {ReadonlyArray<Readonly<Deprecation>>} */\nconst deprecations = [\n {from: 'astPlugins', id: 'remove-buggy-html-in-markdown-parser'},\n {from: 'allowDangerousHtml', id: 'remove-buggy-html-in-markdown-parser'},\n {\n from: 'allowNode',\n id: 'replace-allownode-allowedtypes-and-disallowedtypes',\n to: 'allowElement'\n },\n {\n from: 'allowedTypes',\n id: 'replace-allownode-allowedtypes-and-disallowedtypes',\n to: 'allowedElements'\n },\n {\n from: 'disallowedTypes',\n id: 'replace-allownode-allowedtypes-and-disallowedtypes',\n to: 'disallowedElements'\n },\n {from: 'escapeHtml', id: 'remove-buggy-html-in-markdown-parser'},\n {from: 'includeElementIndex', id: '#remove-includeelementindex'},\n {\n from: 'includeNodeIndex',\n id: 'change-includenodeindex-to-includeelementindex'\n },\n {from: 'linkTarget', id: 'remove-linktarget'},\n {from: 'plugins', id: 'change-plugins-to-remarkplugins', to: 'remarkPlugins'},\n {from: 'rawSourcePos', id: '#remove-rawsourcepos'},\n {from: 'renderers', id: 'change-renderers-to-components', to: 'components'},\n {from: 'source', id: 'change-source-to-children', to: 'children'},\n {from: 'sourcePos', id: '#remove-sourcepos'},\n {from: 'transformImageUri', id: '#add-urltransform', to: 'urlTransform'},\n {from: 'transformLinkUri', id: '#add-urltransform', to: 'urlTransform'}\n]\n\n/**\n * Component to render markdown.\n *\n * This is a synchronous component.\n * When using async plugins,\n * see {@linkcode MarkdownAsync} or {@linkcode MarkdownHooks}.\n *\n * @param {Readonly<Options>} options\n * Props.\n * @returns {ReactElement}\n * React element.\n */\nexport function Markdown(options) {\n const processor = createProcessor(options)\n const file = createFile(options)\n return post(processor.runSync(processor.parse(file), file), options)\n}\n\n/**\n * Component to render markdown with support for async plugins\n * through async/await.\n *\n * Components returning promises are supported on the server.\n * For async support on the client,\n * see {@linkcode MarkdownHooks}.\n *\n * @param {Readonly<Options>} options\n * Props.\n * @returns {Promise<ReactElement>}\n * Promise to a React element.\n */\nexport async function MarkdownAsync(options) {\n const processor = createProcessor(options)\n const file = createFile(options)\n const tree = await processor.run(processor.parse(file), file)\n return post(tree, options)\n}\n\n/**\n * Component to render markdown with support for async plugins through hooks.\n *\n * This uses `useEffect` and `useState` hooks.\n * Hooks run on the client and do not immediately render something.\n * For async support on the server,\n * see {@linkcode MarkdownAsync}.\n *\n * @param {Readonly<Options>} options\n * Props.\n * @returns {ReactElement}\n * React element.\n */\nexport function MarkdownHooks(options) {\n const processor = createProcessor(options)\n const [error, setError] = useState(\n /** @type {Error | undefined} */ (undefined)\n )\n const [tree, setTree] = useState(/** @type {Root | undefined} */ (undefined))\n\n useEffect(\n /* c8 ignore next 7 -- hooks are client-only. */\n function () {\n const file = createFile(options)\n processor.run(processor.parse(file), file, function (error, tree) {\n setError(error)\n setTree(tree)\n })\n },\n [\n options.children,\n options.rehypePlugins,\n options.remarkPlugins,\n options.remarkRehypeOptions\n ]\n )\n\n /* c8 ignore next -- hooks are client-only. */\n if (error) throw error\n\n /* c8 ignore next -- hooks are client-only. */\n return tree ? post(tree, options) : createElement(Fragment)\n}\n\n/**\n * Set up the `unified` processor.\n *\n * @param {Readonly<Options>} options\n * Props.\n * @returns {Processor<MdastRoot, MdastRoot, Root, undefined, undefined>}\n * Result.\n */\nfunction createProcessor(options) {\n const rehypePlugins = options.rehypePlugins || emptyPlugins\n const remarkPlugins = options.remarkPlugins || emptyPlugins\n const remarkRehypeOptions = options.remarkRehypeOptions\n ? {...options.remarkRehypeOptions, ...emptyRemarkRehypeOptions}\n : emptyRemarkRehypeOptions\n\n const processor = unified()\n .use(remarkParse)\n .use(remarkPlugins)\n .use(remarkRehype, remarkRehypeOptions)\n .use(rehypePlugins)\n\n return processor\n}\n\n/**\n * Set up the virtual file.\n *\n * @param {Readonly<Options>} options\n * Props.\n * @returns {VFile}\n * Result.\n */\nfunction createFile(options) {\n const children = options.children || ''\n const file = new VFile()\n\n if (typeof children === 'string') {\n file.value = children\n } else {\n unreachable(\n 'Unexpected value `' +\n children +\n '` for `children` prop, expected `string`'\n )\n }\n\n return file\n}\n\n/**\n * Process the result from unified some more.\n *\n * @param {Nodes} tree\n * Tree.\n * @param {Readonly<Options>} options\n * Props.\n * @returns {ReactElement}\n * React element.\n */\nfunction post(tree, options) {\n const allowedElements = options.allowedElements\n const allowElement = options.allowElement\n const components = options.components\n const disallowedElements = options.disallowedElements\n const skipHtml = options.skipHtml\n const unwrapDisallowed = options.unwrapDisallowed\n const urlTransform = options.urlTransform || defaultUrlTransform\n\n for (const deprecation of deprecations) {\n if (Object.hasOwn(options, deprecation.from)) {\n unreachable(\n 'Unexpected `' +\n deprecation.from +\n '` prop, ' +\n (deprecation.to\n ? 'use `' + deprecation.to + '` instead'\n : 'remove it') +\n ' (see <' +\n changelog +\n '#' +\n deprecation.id +\n '> for more info)'\n )\n }\n }\n\n if (allowedElements && disallowedElements) {\n unreachable(\n 'Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other'\n )\n }\n\n // Wrap in `div` if there’s a class name.\n if (options.className) {\n tree = {\n type: 'element',\n tagName: 'div',\n properties: {className: options.className},\n // Assume no doctypes.\n children: /** @type {Array<ElementContent>} */ (\n tree.type === 'root' ? tree.children : [tree]\n )\n }\n }\n\n visit(tree, transform)\n\n return toJsxRuntime(tree, {\n Fragment,\n // @ts-expect-error\n // React components are allowed to return numbers,\n // but not according to the types in hast-util-to-jsx-runtime\n components,\n ignoreInvalidStyle: true,\n jsx,\n jsxs,\n passKeys: true,\n passNode: true\n })\n\n /** @type {BuildVisitor<Root>} */\n function transform(node, index, parent) {\n if (node.type === 'raw' && parent && typeof index === 'number') {\n if (skipHtml) {\n parent.children.splice(index, 1)\n } else {\n parent.children[index] = {type: 'text', value: node.value}\n }\n\n return index\n }\n\n if (node.type === 'element') {\n /** @type {string} */\n let key\n\n for (key in urlAttributes) {\n if (\n Object.hasOwn(urlAttributes, key) &&\n Object.hasOwn(node.properties, key)\n ) {\n const value = node.properties[key]\n const test = urlAttributes[key]\n if (test === null || test.includes(node.tagName)) {\n node.properties[key] = urlTransform(String(value || ''), key, node)\n }\n }\n }\n }\n\n if (node.type === 'element') {\n let remove = allowedElements\n ? !allowedElements.includes(node.tagName)\n : disallowedElements\n ? disallowedElements.includes(node.tagName)\n : false\n\n if (!remove && allowElement && typeof index === 'number') {\n remove = !allowElement(node, index, parent)\n }\n\n if (remove && parent && typeof index === 'number') {\n if (unwrapDisallowed && node.children) {\n parent.children.splice(index, 1, ...node.children)\n } else {\n parent.children.splice(index, 1)\n }\n\n return index\n }\n }\n }\n}\n\n/**\n * Make a URL safe.\n *\n * @satisfies {UrlTransform}\n * @param {string} value\n * URL.\n * @returns {string}\n * Safe URL.\n */\nexport function defaultUrlTransform(value) {\n // Same as:\n // <https://github.com/micromark/micromark/blob/929275e/packages/micromark-util-sanitize-uri/dev/index.js#L34>\n // But without the `encode` part.\n const colon = value.indexOf(':')\n const questionMark = value.indexOf('?')\n const numberSign = value.indexOf('#')\n const slash = value.indexOf('/')\n\n if (\n // If there is no protocol, it’s relative.\n colon === -1 ||\n // If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.\n (slash !== -1 && colon > slash) ||\n (questionMark !== -1 && colon > questionMark) ||\n (numberSign !== -1 && colon > numberSign) ||\n // It is a protocol, it should be allowed.\n safeProtocol.test(value.slice(0, colon))\n ) {\n return value\n }\n\n return ''\n}\n","/**\n * @import {Root} from 'mdast'\n * @import {Options} from 'remark-gfm'\n * @import {} from 'remark-parse'\n * @import {} from 'remark-stringify'\n * @import {Processor} from 'unified'\n */\n\nimport {gfmFromMarkdown, gfmToMarkdown} from 'mdast-util-gfm'\nimport {gfm} from 'micromark-extension-gfm'\n\n/** @type {Options} */\nconst emptyOptions = {}\n\n/**\n * Add support GFM (autolink literals, footnotes, strikethrough, tables,\n * tasklists).\n *\n * @param {Options | null | undefined} [options]\n * Configuration (optional).\n * @returns {undefined}\n * Nothing.\n */\nexport default function remarkGfm(options) {\n // @ts-expect-error: TS is wrong about `this`.\n // eslint-disable-next-line unicorn/no-this-assignment\n const self = /** @type {Processor<Root>} */ (this)\n const settings = options || emptyOptions\n const data = self.data()\n\n const micromarkExtensions =\n data.micromarkExtensions || (data.micromarkExtensions = [])\n const fromMarkdownExtensions =\n data.fromMarkdownExtensions || (data.fromMarkdownExtensions = [])\n const toMarkdownExtensions =\n data.toMarkdownExtensions || (data.toMarkdownExtensions = [])\n\n micromarkExtensions.push(gfm(settings))\n fromMarkdownExtensions.push(gfmFromMarkdown())\n toMarkdownExtensions.push(gfmToMarkdown(settings))\n}\n"],"names":["remarkParse","options","self","parser","doc","fromMarkdown","remarkRehype","destination","tree","file","hastTree","toHast","changelog","emptyPlugins","emptyRemarkRehypeOptions","safeProtocol","deprecations","Markdown","processor","createProcessor","createFile","post","rehypePlugins","remarkPlugins","remarkRehypeOptions","unified","children","VFile","allowedElements","allowElement","components","disallowedElements","skipHtml","unwrapDisallowed","urlTransform","defaultUrlTransform","deprecation","unreachable","visit","transform","toJsxRuntime","Fragment","jsx","jsxs","node","index","parent","key","urlAttributes","value","test","remove","colon","questionMark","numberSign","slash","emptyOptions","remarkGfm","settings","data","micromarkExtensions","fromMarkdownExtensions","toMarkdownExtensions","gfm","gfmFromMarkdown","gfmToMarkdown"],"mappings":"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","x_google_ignoreList":[0,1,2,3]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{M as r}from"./mobile-layout-DSmtNPja.js";import{b as e,j as o,r as m}from"./react-vendor-D3pra6w-.js";import"./icons-B0AKnYI3.js";import"./vendor-Di7Cp-rw.js";import"./flow-BpU0-gK2.js";const t=document.getElementById("root");if(!t)throw new Error("Root element #root not found");e(t).render(o.jsx(m.StrictMode,{children:o.jsx(r,{})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobile-
|
|
1
|
+
{"version":3,"file":"mobile-DXYCA0hC.js","sources":["../../src/web/mobile.tsx"],"sourcesContent":["// src/mobile.tsx — entry point for mobile dashboard.\nimport { StrictMode } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { MobileApp } from './MobileApp';\nimport './styles/mobile.css';\nimport './styles/mobile-layout.css';\n\nconst root = document.getElementById('root');\nif (!root) throw new Error('Root element #root not found');\ncreateRoot(root).render(\n <StrictMode>\n <MobileApp />\n </StrictMode>,\n);\n"],"names":["root","createRoot","jsx","StrictMode","MobileApp"],"mappings":"iMAOA,MAAMA,EAAO,SAAS,eAAe,MAAM,EAC3C,GAAI,CAACA,EAAM,MAAM,IAAI,MAAM,8BAA8B,EACzDC,EAAWD,CAAI,EAAE,OACfE,EAAAA,IAACC,EAAAA,WAAA,CACC,SAAAD,EAAAA,IAACE,EAAA,CAAA,CAAU,CAAA,CACb,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MobileSettings-K-sNsn_r.js","assets/react-vendor-D3pra6w-.js","assets/vendor-Di7Cp-rw.js","assets/flow-BpU0-gK2.js","assets/react-vendor-BnuhLJ6X.css","assets/EnvVarsSection-CW6fWKds.js","assets/Toast-WTxc3m2g.js","assets/icons-B0AKnYI3.js","assets/MobileChat-D7zRhU9K.js","assets/useSlashCommands-3DFLOfpk.js","assets/markdown-w2bDDkAH.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Ze=Object.defineProperty;var et=(s,t,n)=>t in s?Ze(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var U=(s,t,n)=>et(s,typeof t!="symbol"?t+"":t,n);import{j as e,r as o,R as Be}from"./react-vendor-D3pra6w-.js";import{bc as tt,X as G,r as me,a5 as st,ag as te,aw as at,R as _,B as ae,g as ue,t as B,aa as nt,a9 as ne,af as lt,q as J,aD as it,l as he,aI as Fe,_ as H,k as be,aV as qe,e as ye,ad as _e,M as Y,ai as Ne,bd as ot,S as se,b as ct,i as ke,at as rt,be as dt}from"./icons-B0AKnYI3.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const m of i)if(m.type==="childList")for(const b of m.addedNodes)b.tagName==="LINK"&&b.rel==="modulepreload"&&r(b)}).observe(document,{childList:!0,subtree:!0});function n(i){const m={};return i.integrity&&(m.integrity=i.integrity),i.referrerPolicy&&(m.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?m.credentials="include":i.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function r(i){if(i.ep)return;i.ep=!0;const m=n(i);fetch(i.href,m)}})();function X(...s){return s.filter(Boolean).join(" ")}function K(s){if(!s&&s!==0)return"";const t=typeof s=="number"?s:new Date(s).getTime();if(Number.isNaN(t))return"";const n=Date.now()-t;return n<0||n<6e4?"just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:n<7*864e5?`${Math.floor(n/864e5)}d ago`:new Date(t).toLocaleDateString()}function is(s){if(!s)return"";const t=typeof s=="number"?new Date(s):new Date(s);return Number.isNaN(t.getTime())?"":t.toLocaleString()}function os(s,t=160){return s?s.length>t?s.slice(0,t)+"…":s:""}const mt={low:"var(--text-dim)",normal:"var(--info)",high:"var(--error)"},ee="bizar-auth-token",we="bizar-loopback-trusted";class Se extends Error{constructor(n,r,i){super(n);U(this,"status");U(this,"data");this.name="ApiError",this.status=r,this.data=i}}class ut{constructor(){U(this,"base","/api")}getToken(){try{return localStorage.getItem(ee)||""}catch{return""}}setToken(t){try{t?localStorage.setItem(ee,t):localStorage.removeItem(ee)}catch{}}pickupTokenFromUrl(){try{const t=new URLSearchParams(window.location.search),n=t.get("token");if(!n)return!1;this.setToken(n),t.delete("token");const r=t.toString(),i=r?`${window.location.pathname}?${r}`:window.location.pathname;return history.replaceState(null,"",i),!0}catch{return!1}}urlWithToken(t){const n=this.base+t,r=this.getToken();if(!r)return n;const i=n.includes("?")?"&":"?";return`${n}${i}token=${encodeURIComponent(r)}`}async probeAuthStatus(){try{const t=await this.get("/auth/status");try{localStorage.setItem(we,t.loopback?"1":"0")}catch{}return t}catch{return{required:!1,loopback:!0,peer:""}}}isLoopbackTrusted(){try{return localStorage.getItem(we)!=="0"}catch{return!0}}async get(t,n){return this.req("GET",t,void 0,n)}async post(t,n,r){return this.req("POST",t,n,r)}async put(t,n,r){return this.req("PUT",t,n,r)}async patch(t,n,r){return this.req("PATCH",t,n,r)}async del(t,n){return this.req("DELETE",t,void 0,n)}async req(t,n,r,i){const m={"Content-Type":"application/json"},b=this.getToken();b&&(m.Authorization=`Bearer ${b}`);const d={method:t,headers:m};r!=null&&(d.body=typeof r=="string"?r:JSON.stringify(r)),i&&(d.signal=i);const x=await fetch(this.base+n,d);if((x.headers.get("content-type")||"").includes("application/json")){const j=await x.json();if(!x.ok){const v=(j&&typeof j=="object"&&"message"in j?j.message:void 0)||`${t} ${n}: ${x.status}`;throw new Se(v,x.status,j)}return j}const a=await x.text();if(!x.ok)throw new Se(`${t} ${n}: ${x.status} — ${a.slice(0,200)}`,x.status,a);try{return JSON.parse(a)}catch{return a}}}const C=new ut;C.pickupTokenFromUrl();async function cs(s){return s}const Ce=typeof window<"u"&&!window.location.hostname.includes("production"),Q={debug(...s){Ce&&console.debug("[bizar]",...s)},info(...s){Ce&&console.info("[bizar]",...s)},warn(...s){console.warn("[bizar]",...s)},error(...s){console.error("[bizar]",...s)}};function ht(){if(typeof location>"u")return"ws://localhost/ws";const s=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`;let t="";try{t=localStorage.getItem(ee)||""}catch{}return t?`${s}?token=${encodeURIComponent(t)}`:s}class We{constructor(t){U(this,"urlOverride");U(this,"handlers",new Set);U(this,"statusHandlers",new Set);U(this,"ws",null);U(this,"reconnectDelay",1e3);U(this,"maxReconnectDelay",15e3);U(this,"reconnectTimer",null);U(this,"_status","connecting");U(this,"pingTimer",null);U(this,"closed",!1);this.urlOverride=t,this.connect()}on(t){return this.handlers.add(t),()=>{this.handlers.delete(t)}}onStatus(t){return this.statusHandlers.add(t),t(this._status),()=>{this.statusHandlers.delete(t)}}get status(){return this._status}send(t){return this.ws&&this.ws.readyState===WebSocket.OPEN?(this.ws.send(JSON.stringify(t)),!0):!1}close(){var t;this.closed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.pingTimer&&clearInterval(this.pingTimer),this.pingTimer=null;try{(t=this.ws)==null||t.close()}catch{}this.ws=null,this.setStatus("disconnected")}connect(){if(this.closed)return;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.setStatus("connecting");const t=this.urlOverride??ht();let n;try{n=new WebSocket(t),this.ws=n}catch(r){Q.warn("[ws] construct failed:",r),this.scheduleReconnect();return}n.addEventListener("open",()=>{this.ws!==n||this.closed||(this.reconnectDelay=1e3,this.setStatus("connected"),this.pingTimer&&clearInterval(this.pingTimer),this.pingTimer=setInterval(()=>{this._status==="connected"&&this.send({type:"ping"})},3e4))}),n.addEventListener("close",()=>{this.ws===n&&(this.ws=null,this.setStatus("disconnected"),this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=null),this.closed||this.scheduleReconnect())}),n.addEventListener("error",()=>{this.ws===n&&Q.warn("[ws] error")}),n.addEventListener("message",r=>{let i;try{i=JSON.parse(r.data)}catch{Q.warn("[ws] bad message");return}for(const m of this.handlers)try{m(i)}catch(b){Q.error("[ws] handler error:",b)}})}scheduleReconnect(){this.closed||this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*1.6,this.maxReconnectDelay))}setStatus(t){this._status=t;for(const n of this.statusHandlers)try{n(t)}catch(r){Q.error("[ws] status handler error:",r)}}}const rs=Object.freeze(Object.defineProperty({__proto__:null,Ws:We},Symbol.toStringTag,{value:"Module"}));function Te(s){const t=typeof s=="string"?s:s.mode,n=t==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark":t==="light"?"light":"dark";return typeof document<"u"&&(n==="light"?document.documentElement.setAttribute("data-theme","light"):document.documentElement.removeAttribute("data-theme")),n}function Ee(s){if(typeof document>"u")return;const t=document.documentElement;t.style.setProperty("--accent",s.accent),t.style.setProperty("--success",s.success),t.style.setProperty("--warning",s.warning),t.style.setProperty("--error",s.error),t.style.setProperty("--info",s.info),t.style.setProperty("--accent-bg",Ae(s.accent,.12)),t.style.setProperty("--accent-border",Ae(s.accent,.4)),s.fontFamily&&t.style.setProperty("--font-sans",`'${s.fontFamily}', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif`),s.fontSize&&t.style.setProperty("--base-font-size",`${s.fontSize}px`),t.dataset.compactMode=s.compactMode?"true":"false",t.dataset.animations=s.animations?"true":"false"}function Ae(s,t){const n=/^#?([0-9a-f]{6})$/i.exec(s||"");if(!n)return`rgba(139, 92, 246, ${t})`;const r=parseInt(n[1],16),i=r>>16&255,m=r>>8&255,b=r&255;return`rgba(${i}, ${m}, ${b}, ${t})`}const bt="modulepreload",pt=function(s){return"/"+s},$e={},He=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const b=document.querySelector("meta[property=csp-nonce]"),d=(b==null?void 0:b.nonce)||(b==null?void 0:b.getAttribute("nonce"));i=Promise.allSettled(n.map(x=>{if(x=pt(x),x in $e)return;$e[x]=!0;const y=x.endsWith(".css"),a=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${x}"]${a}`))return;const j=document.createElement("link");if(j.rel=y?"stylesheet":bt,y||(j.as="script"),j.crossOrigin="",j.href=x,d&&j.setAttribute("nonce",d),document.head.appendChild(j),y)return new Promise((v,u)=>{j.addEventListener("load",v),j.addEventListener("error",()=>u(new Error(`Unable to preload CSS for ${x}`)))})}))}function m(b){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=b,window.dispatchEvent(d),!d.defaultPrevented)throw b}return i.then(b=>{for(const d of b||[])d.status==="rejected"&&m(d.reason);return t().catch(m)})};function ce({size:s="md",className:t,label:n}){return e.jsx("span",{className:X("spinner",`spinner-${s}`,t),role:"status","aria-label":n||"Loading"})}function ft({onMenuClick:s,scrolled:t,activeTab:n,onSettings:r,onSearch:i}){return e.jsxs("header",{className:X("mobile-header",t&&"is-scrolled"),children:[e.jsx("button",{onClick:s,className:"mobile-menu-btn","aria-label":"Open menu",type:"button",children:e.jsx(tt,{size:20})}),e.jsx("h1",{className:"mobile-header-title",children:n==="settings"?"Settings":"Bizar"}),r?e.jsx("button",{onClick:r,className:"mobile-settings-exit","aria-label":"Exit settings",type:"button",children:e.jsx(G,{size:20})}):e.jsx("button",{onClick:i,className:"mobile-search-btn","aria-label":"Search",type:"button",children:e.jsx(me,{size:20})})]})}function xt({open:s,onClose:t,tabs:n,activeTab:r,onTabChange:i}){return e.jsxs(e.Fragment,{children:[s&&e.jsx("div",{className:"mobile-drawer-overlay",onClick:t,"aria-hidden":"true"}),e.jsxs("aside",{className:X("mobile-drawer",s&&"is-open"),role:"dialog","aria-modal":"true","aria-label":"All views",children:[e.jsxs("div",{className:"mobile-drawer-head",children:[e.jsx("h2",{children:"All Views"}),e.jsx("button",{onClick:t,"aria-label":"Close menu",type:"button",className:"mobile-drawer-close",children:e.jsx(G,{size:20})})]}),e.jsx("div",{className:"mobile-drawer-grid",children:n.map(m=>{const b=m.icon;return e.jsxs("button",{role:"tab","aria-selected":r===m.id,className:X("mobile-drawer-item",r===m.id&&"is-active"),onClick:()=>i(m.id),type:"button",children:[e.jsx(b,{size:22}),e.jsx("span",{children:m.label})]},m.id)})})]})]})}function jt({tabs:s,activeTab:t,onTabChange:n}){return e.jsx("nav",{className:"mobile-bottom-nav",role:"tablist","aria-label":"Primary navigation",children:s.map(r=>{const i=r.icon;return e.jsxs("button",{role:"tab","aria-selected":t===r.id,className:X("mobile-nav-item",t===r.id&&"is-active"),onClick:()=>n(r.id),type:"button",children:[e.jsx(i,{size:20}),e.jsx("span",{className:"mobile-nav-label",children:r.label})]},r.id)})})}function gt({children:s,activeTab:t,onTabChange:n,tabs:r,fullTabs:i,onExitSettings:m,onSearch:b}){const[d,x]=o.useState(!1),[y,a]=o.useState(!1);return e.jsxs("div",{className:"mobile-layout",children:[e.jsx(ft,{onMenuClick:()=>x(!0),scrolled:y,activeTab:t,onSettings:t==="settings"?m:null,onSearch:b}),e.jsx(xt,{open:d,onClose:()=>x(!1),tabs:i,activeTab:t,onTabChange:j=>{n(j),x(!1)}}),e.jsx("main",{className:"mobile-content",onScroll:j=>a(j.currentTarget.scrollTop>10),children:s}),e.jsx(jt,{tabs:r,activeTab:t,onTabChange:n})]})}function q({open:s,onClose:t,title:n,children:r,actions:i,maxHeight:m="85vh"}){const b=o.useRef(null),d=o.useRef(null),x=o.useId(),y=o.useRef(null),a=o.useRef(null),j=o.useRef(0),v=o.useRef(0),u=()=>{var p;return((p=b.current)==null?void 0:p.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'))??[]};if(o.useEffect(()=>{if(!s)return;y.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const p=g=>{var I;if(g.key==="Escape"&&t(),g.key!=="Tab")return;const E=Array.from(u());if(E.length===0){g.preventDefault(),(I=b.current)==null||I.focus();return}const S=E[0],D=E[E.length-1],R=document.activeElement;if(g.shiftKey){(!R||R===S||R===b.current)&&(g.preventDefault(),D==null||D.focus());return}R===D&&(g.preventDefault(),S==null||S.focus())};return window.addEventListener("keydown",p),requestAnimationFrame(()=>{var g,E;((g=d.current)==null?void 0:g.focus())??((E=b.current)==null||E.focus())}),()=>{var g;window.removeEventListener("keydown",p),(g=y.current)==null||g.focus()}},[s,t]),o.useEffect(()=>(s?(v.current=window.scrollY,document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${v.current}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%"):(document.documentElement.style.overflow="",document.body.style.overflow="",document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width=""),()=>{document.documentElement.style.overflow="",document.body.style.overflow="",document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="",window.scrollTo(0,v.current)}),[s]),!s)return null;const c=p=>{var g;p.isPrimary&&(a.current=p.clientY,j.current=0,(g=b.current)==null||g.setPointerCapture(p.pointerId))},l=p=>{if(a.current==null||!b.current)return;const g=Math.max(0,p.clientY-a.current);j.current=g,b.current.style.transform=`translateY(${g}px)`},N=p=>{if(!b.current)return;p&&b.current.hasPointerCapture(p.pointerId)&&b.current.releasePointerCapture(p.pointerId);const g=j.current;b.current.style.transform="",a.current=null,j.current=0,g>72&&t()};return e.jsx("div",{className:"mobile-sheet-overlay",onClick:t,children:e.jsxs("div",{ref:b,className:"mobile-sheet",style:{maxHeight:m},onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":!0,"aria-label":n?void 0:"Sheet","aria-labelledby":n?x:void 0,tabIndex:-1,children:[e.jsx("div",{className:"mobile-sheet-handle",onPointerDown:c,onPointerMove:l,onPointerUp:N,onPointerCancel:N,"aria-hidden":"true"}),e.jsxs("div",{className:"mobile-sheet-header",children:[n?e.jsx("h3",{id:x,className:"mobile-sheet-title",children:n}):e.jsx("div",{}),e.jsx("button",{ref:d,type:"button",className:"mobile-icon-btn",onClick:t,"aria-label":"Close",children:e.jsx(G,{size:18})})]}),e.jsx("div",{className:"mobile-sheet-content",children:r}),i&&e.jsx("div",{className:"mobile-sheet-actions",children:i})]})})}const vt=["all","tasks","agents","bg","artifacts","mods"],re={all:"All",tasks:"Tasks",agents:"Agents",bg:"Background",artifacts:"Plans",mods:"Mods"};function yt({snapshot:s,onRefresh:t}){var P;const[n,r]=o.useState(((P=s.overview)==null?void 0:P.recentActivity)||[]),[i,m]=o.useState(!0),[b,d]=o.useState("all"),[x,y]=o.useState(!1),[a,j]=o.useState(null),[v,u]=o.useState(""),[c,l]=o.useState(!1);o.useEffect(()=>{var f;(f=s.overview)!=null&&f.recentActivity?(r(s.overview.recentActivity),m(!1)):N()},[s.overview]);const N=async()=>{var f;try{const L=await C.get("/snapshot");r(((f=L.overview)==null?void 0:f.recentActivity)||[])}catch{}finally{m(!1)}},p=b==="all"?n:n.filter(f=>{var L,h,w,T,A,M;return b==="tasks"?(L=f.kind)==null?void 0:L.startsWith("task"):b==="agents"?(h=f.kind)==null?void 0:h.startsWith("agent"):b==="bg"?((w=f.kind)==null?void 0:w.includes("bg"))||((T=f.kind)==null?void 0:T.includes("schedule")):b==="artifacts"?(A=f.kind)==null?void 0:A.includes("artifacts"):b==="mods"?(M=f.kind)==null?void 0:M.includes("mod"):!0}),g=s.agents||[],E=s.tasks||[],S=E.filter(f=>f.status==="doing"||f.status==="queued"),D=E.filter(f=>f.status==="done"),R=async()=>{if(!(!v.trim()||c)){l(!0);try{await C.post("/chat",{message:v.trim(),agent:"odin"}),u(""),await t().catch(()=>{}),await N()}catch{}finally{l(!1)}}},I=async()=>{await t().catch(()=>{}),await N()};return e.jsxs("div",{className:"mobile-view",children:[e.jsxs("div",{className:"mobile-submit-hero",children:[e.jsx("textarea",{className:"mobile-submit-input",placeholder:"What needs to be done? Describe a task, bug, or refactor for Odin to artifacts…",value:v,onChange:f=>u(f.target.value),rows:2}),e.jsxs("div",{className:"mobile-submit-actions",children:[e.jsx("div",{className:"mobile-submit-chips",children:["Implement feature","Fix bug","Refactor","Investigate","Write tests"].map(f=>e.jsx("button",{type:"button",className:"mobile-submit-chip",onClick:()=>u(L=>L?`${L} ${f}`:f),children:f},f))}),e.jsxs("button",{type:"button",className:"mobile-btn",disabled:!v.trim()||c,onClick:R,children:[e.jsx(st,{size:14})," Submit to Odin"]})]})]}),e.jsxs("div",{className:"mobile-stats",children:[e.jsxs("div",{className:"mobile-stat",children:[e.jsx("div",{className:"mobile-stat-value",children:g.length}),e.jsx("div",{className:"mobile-stat-label",children:"Agents"})]}),e.jsxs("div",{className:"mobile-stat",children:[e.jsx("div",{className:"mobile-stat-value",children:S.length}),e.jsx("div",{className:"mobile-stat-label",children:"Active"})]}),e.jsxs("div",{className:"mobile-stat",children:[e.jsx("div",{className:"mobile-stat-value",children:D.length}),e.jsx("div",{className:"mobile-stat-label",children:"Done"})]}),e.jsxs("div",{className:"mobile-stat",children:[e.jsx("div",{className:"mobile-stat-value",children:s.artifacts.length||0}),e.jsx("div",{className:"mobile-stat-label",children:"Plans"})]})]}),i&&n.length===0&&e.jsx("div",{className:"mobile-loading mobile-loading-inline",children:e.jsx("p",{children:"Loading activity…"})}),e.jsxs("div",{className:"mobile-activity-header",children:[e.jsx("h3",{className:"mobile-section-title",style:{margin:0},children:"Recent Activity"}),e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>y(f=>!f),"aria-label":x?"Resume":"Pause",children:x?e.jsx(te,{size:14}):e.jsx(at,{size:14})}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:I,"aria-label":"Refresh",children:e.jsx(_,{size:14})})]})]}),e.jsx("div",{className:"mobile-search-scopes",children:vt.map(f=>e.jsx("button",{type:"button",className:`mobile-scope-chip ${b===f?"active":""}`,onClick:()=>d(f),children:re[f]},f))}),g.length>0&&e.jsxs("section",{className:"mobile-section",children:[e.jsxs("h3",{className:"mobile-section-title",children:[e.jsx(ae,{size:14})," Agents"]}),e.jsx("div",{className:"mobile-card-list",children:g.slice(0,6).map(f=>e.jsxs("div",{className:"mobile-agent-card",children:[e.jsx("div",{className:"mobile-agent-dot","data-status":f.status||"idle"}),e.jsxs("div",{className:"mobile-agent-info",children:[e.jsx("span",{className:"mobile-agent-name",children:f.name}),e.jsx("span",{className:"mobile-agent-meta",children:f.status||"idle"})]})]},f.name))})]}),!x&&p.length>0&&e.jsx("section",{className:"mobile-section",children:e.jsx("div",{className:"mobile-card-list",children:p.slice(0,30).map((f,L)=>e.jsxs("button",{type:"button",className:"mobile-event-item",onClick:()=>j(f),children:[e.jsx("span",{className:"mobile-event-kind","data-kind":f.kind,children:re[f.kind]||f.kind}),e.jsx("span",{className:"mobile-event-msg",children:Nt(f)}),e.jsx("span",{className:"mobile-event-time",children:K(f.ts)})]},`${f.ts}-${f.kind}-${L}`))})}),!x&&p.length===0&&n.length>0&&e.jsxs("div",{className:"mobile-empty",children:[e.jsx(ue,{size:40}),e.jsx("p",{children:"No matching activity."}),e.jsx("p",{className:"muted",children:"Try a different filter."})]}),a&&e.jsx(q,{open:!0,onClose:()=>j(null),title:re[a.kind]||a.kind,children:e.jsxs("div",{className:"mobile-agent-detail-meta",children:[e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Kind"}),e.jsx("span",{children:a.kind})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Time"}),e.jsx("span",{children:new Date(a.ts).toLocaleString()})]}),Object.entries(a).filter(([f])=>!["ts","kind"].includes(f)).map(([f,L])=>e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:f}),e.jsx("span",{style:{fontSize:12,maxWidth:200,wordBreak:"break-all"},children:typeof L=="object"?JSON.stringify(L):String(L)})]},f))]})}),g.length===0&&S.length===0&&e.jsxs("div",{className:"mobile-empty",children:[e.jsx(ue,{size:40}),e.jsx("p",{children:"No activity yet."}),e.jsx("p",{className:"muted",children:"Start a task or chat to see things here."})]})]})}function Nt(s){const t=s.kind||"";return t.includes("task")?`Task: ${s.title||s.id||"updated"}`:t.includes("agent")?`Agent: ${s.name||"status changed"}`:t.includes("artifacts")?`Plan: ${s.slug||"changed"}`:t.includes("mod")?`Mod: ${s.name||"changed"}`:t.includes("schedule")?`Schedule: ${s.name||"triggered"}`:JSON.stringify(s).slice(0,80)}function W({open:s,onClose:t,title:n,children:r,actions:i}){const m=o.useRef(null),b=o.useRef(null),d=o.useRef(null),x=o.useId(),y=o.useRef(0);return o.useEffect(()=>{if(!s)return;d.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const a='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',j=v=>{var p,g;if(v.key==="Escape"&&t(),v.key!=="Tab")return;const u=Array.from(((p=m.current)==null?void 0:p.querySelectorAll(a))??[]);if(u.length===0){v.preventDefault(),(g=m.current)==null||g.focus();return}const c=u[0],l=u[u.length-1],N=document.activeElement;if(v.shiftKey){(!N||N===c||N===m.current)&&(v.preventDefault(),l==null||l.focus());return}N===l&&(v.preventDefault(),c==null||c.focus())};return window.addEventListener("keydown",j),y.current=window.scrollY,document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${y.current}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%",requestAnimationFrame(()=>{var v,u;((v=b.current)==null?void 0:v.focus())??((u=m.current)==null||u.focus())}),()=>{var v;window.removeEventListener("keydown",j),document.documentElement.style.overflow="",document.body.style.overflow="",document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="",window.scrollTo(0,y.current),(v=d.current)==null||v.focus()}},[s,t]),s?e.jsx("div",{className:"mobile-modal-overlay",onClick:a=>{a.target===a.currentTarget&&t()},children:e.jsxs("div",{ref:m,className:"mobile-modal",onClick:a=>a.stopPropagation(),role:"dialog","aria-modal":!0,"aria-label":n?void 0:"Modal","aria-labelledby":n?x:void 0,tabIndex:-1,children:[e.jsxs("div",{className:"mobile-modal-header",children:[n?e.jsx("h2",{id:x,className:"mobile-modal-title",children:n}):e.jsx("div",{}),e.jsx("button",{ref:b,type:"button",className:"mobile-icon-btn",onClick:t,"aria-label":"Close",children:e.jsx(G,{size:20})})]}),e.jsx("div",{className:"mobile-modal-content",children:r}),i&&e.jsx("div",{className:"mobile-modal-actions",children:i})]})}):null}const Ve=["reasoning","code","design","planning","gitops","analysis"],Le={reasoning:"var(--accent)",code:"var(--info)",design:"var(--success)",planning:"var(--warning)",gitops:"var(--error)",analysis:"var(--text-dim)"};function ze({snapshot:s,onBack:t,onOpenAgent:n,selectedAgent:r,onRefresh:i}){const[m,b]=o.useState(s.agents||[]),[d,x]=o.useState(!s.agents),[y,a]=o.useState(""),[j,v]=o.useState(""),[u,c]=o.useState(null),[l,N]=o.useState(!1),[p,g]=o.useState(""),[E,S]=o.useState(!1);o.useEffect(()=>{if(r){const h=m.find(w=>w.name===r);h&&c(h)}},[r,m]);const D=async()=>{try{const h=await C.get("/agents");b(h.agents||[])}catch{}finally{x(!1)}},R=m.filter(h=>{if(y&&h.category!==y)return!1;if(j){const w=j.toLowerCase();if(!h.name.toLowerCase().includes(w)&&!(h.description||"").toLowerCase().includes(w))return!1}return!0}),I=async(h,w)=>{try{await C.post(`/agents/${encodeURIComponent(h)}/invoke`,{prompt:w}),S(!1),g("")}catch{}},P=async h=>{try{await C.post(`/agents/${encodeURIComponent(h)}/restart`),await D()}catch{}},f=async h=>{if(confirm(`Delete agent "${h}"?`))try{await C.del(`/agents/${encodeURIComponent(h)}`),b(w=>w.filter(T=>T.name!==h)),c(null),i==null||i()}catch{}},L=async h=>{try{const w=await C.post("/agents",h);b(T=>[...T,w]),N(!1),i==null||i()}catch{}};return e.jsxs("div",{className:"mobile-view",children:[e.jsxs("div",{className:"mobile-tasks-toolbar",children:[e.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search agents…",value:j,onChange:h=>v(h.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>D(),"aria-label":"Refresh",children:e.jsx(_,{size:16})}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>N(!0),"aria-label":"New agent",children:e.jsx(B,{size:16})})]}),e.jsxs("div",{className:"mobile-search-scopes",children:[e.jsx("button",{type:"button",className:`mobile-scope-chip ${y?"":"active"}`,onClick:()=>a(""),children:"All"}),Ve.map(h=>e.jsx("button",{type:"button",className:`mobile-scope-chip ${y===h?"active":""}`,onClick:()=>a(h),children:h},h))]}),d?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading…"})}):R.length===0?e.jsxs("div",{className:"mobile-empty",children:[e.jsx(ae,{size:40}),e.jsx("p",{children:"No agents found."})]}):e.jsx("div",{className:"mobile-card-list",children:R.map(h=>e.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>{c(h),n(h.name)},children:[e.jsx("div",{className:"mobile-agent-dot","data-status":h.status||"idle"}),e.jsxs("div",{className:"mobile-list-content",children:[e.jsx("span",{className:"mobile-list-title",children:h.name}),e.jsx("span",{className:"mobile-list-meta",children:h.model||h.mode||"—"})]}),h.category&&e.jsx("span",{className:"mobile-list-badge",style:{color:Le[h.category]||"var(--text-dim)"},children:h.category}),e.jsx("span",{className:"mobile-list-badge","data-status":h.status||"idle",children:h.status||"idle"})]},h.name))}),u&&e.jsx(q,{open:!0,onClose:()=>c(null),title:u.name,actions:e.jsxs("div",{className:"mobile-task-detail-actions",children:[e.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>{g(""),S(!0)},children:[e.jsx(te,{size:14})," Invoke"]}),(u.isStuck||u.status==="error"||u.status==="working")&&e.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>P(u.name),children:[e.jsx(nt,{size:14})," Restart"]}),e.jsx("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>f(u.name),children:e.jsx(ne,{size:14})})]}),children:e.jsxs("div",{className:"mobile-agent-detail",children:[e.jsxs("div",{className:"mobile-agent-detail-status",children:[e.jsx("span",{className:"mobile-agent-dot","data-status":u.status||"idle"}),e.jsx("span",{className:"mobile-agent-detail-status-text",children:u.status||"idle"}),u.category&&e.jsx("span",{className:"mobile-list-badge",style:{color:Le[u.category]},children:u.category})]}),e.jsx("p",{className:"mobile-agent-detail-desc",children:u.description||"No description."}),e.jsxs("div",{className:"mobile-agent-detail-meta",children:[e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Model"}),e.jsx("span",{className:"mono",children:u.model||"—"})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Mode"}),e.jsx("span",{children:u.mode||"subagent"})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Path"}),e.jsx("span",{className:"mono",style:{fontSize:11},children:u.path})]}),u.lastError&&e.jsxs("div",{className:"mobile-task-detail-row",style:{color:"var(--error)"},children:[e.jsx("span",{children:"Last error"}),e.jsx("span",{children:u.lastError.message})]}),u.tasksTotal!=null&&u.tasksTotal>0&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Success rate"}),e.jsxs("span",{children:[Math.round((u.successRate||0)*100),"%"]})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Last modified"}),e.jsx("span",{children:K(u.mtime)})]})]})]})}),e.jsxs(W,{open:E,onClose:()=>S(!1),title:`Invoke ${u==null?void 0:u.name}`,actions:e.jsxs("button",{type:"button",className:"mobile-btn",style:{width:"100%"},disabled:!p.trim(),onClick:()=>{u&&I(u.name,p.trim())},children:[e.jsx(te,{size:14})," Invoke"]}),children:[e.jsxs("p",{className:"muted",style:{marginBottom:12},children:["Model: ",e.jsx("span",{className:"mono",children:(u==null?void 0:u.model)||"—"})]}),e.jsx("textarea",{className:"mobile-input",rows:5,placeholder:"What should this agent do?",value:p,onChange:h=>g(h.target.value),autoFocus:!0})]}),e.jsx(kt,{open:l,onClose:()=>N(!1),onCreate:L})]})}function kt({open:s,onClose:t,onCreate:n}){const[r,i]=o.useState(""),[m,b]=o.useState(""),[d,x]=o.useState(""),[y,a]=o.useState("subagent"),[j,v]=o.useState("#8b5cf6"),[u,c]=o.useState(""),[l,N]=o.useState(""),[p,g]=o.useState(""),E=S=>{S.preventDefault(),r.trim()&&(n({name:r.trim(),description:m.trim(),model:d,mode:y,color:j,tools:[],tags:l.split(",").map(D=>D.trim()).filter(Boolean),category:u,prompt:p}),i(""),b(""),x(""),a("subagent"),v("#8b5cf6"),c(""),N(""),g(""))};return e.jsx(W,{open:s,onClose:t,title:"New Agent",actions:e.jsxs("button",{type:"submit",form:"new-agent-form",className:"mobile-btn",style:{width:"100%"},children:[e.jsx(B,{size:14})," Create"]}),children:e.jsxs("form",{id:"new-agent-form",onSubmit:E,className:"mobile-task-form",children:[e.jsx("label",{className:"mobile-field-label",children:"Name *"}),e.jsx("input",{className:"mobile-input",type:"text",placeholder:"my-agent",pattern:"[a-z0-9][a-z0-9-]{0,63}",value:r,onChange:S=>i(S.target.value),autoFocus:!0,required:!0}),e.jsx("label",{className:"mobile-field-label",children:"Description"}),e.jsx("input",{className:"mobile-input",type:"text",placeholder:"What does this agent do?",value:m,onChange:S=>b(S.target.value)}),e.jsx("label",{className:"mobile-field-label",children:"Model"}),e.jsx("input",{className:"mobile-input",type:"text",placeholder:"(provider default)",value:d,onChange:S=>x(S.target.value)}),e.jsx("label",{className:"mobile-field-label",children:"Category"}),e.jsxs("select",{className:"mobile-input",value:u,onChange:S=>c(S.target.value),children:[e.jsx("option",{value:"",children:"None"}),Ve.map(S=>e.jsx("option",{value:S,children:S},S))]}),e.jsx("label",{className:"mobile-field-label",children:"Tags (comma-separated)"}),e.jsx("input",{className:"mobile-input",type:"text",placeholder:"tag1, tag2",value:l,onChange:S=>N(S.target.value)})]})})}function wt({onBack:s}){const[t,n]=o.useState([]),[r,i]=o.useState(!0),[m,b]=o.useState({}),[d,x]=o.useState(!1),y=async()=>{try{const l=await C.get("/config"),N=Object.entries(l).map(([p,g])=>({key:p,value:g,type:a(g)}));n(N),b(Object.fromEntries(Object.entries(l).map(([p,g])=>[p,g])))}catch{}finally{i(!1)}};o.useEffect(()=>{y()},[]);const a=l=>typeof l=="boolean"?"boolean":typeof l=="number"?"number":typeof l=="string"?"string":Array.isArray(l)?"array":l&&typeof l=="object"?"object":"unknown",j=(l,N)=>{b(p=>({...p,[l]:N}))},v=async()=>{x(!0);try{await C.patch("/config",m),await y()}catch{}finally{x(!1)}},u=(l,N)=>{b(p=>({...p,[l]:N}))},c=l=>{const N=m[l.key];switch(l.type){case"boolean":return e.jsxs("label",{className:"mobile-toggle",children:[e.jsx("input",{type:"checkbox",checked:!!N,onChange:p=>j(l.key,p.target.checked)}),e.jsx("span",{className:"mobile-toggle-slider"})]});case"number":return e.jsx("input",{className:"mobile-input mobile-input-sm",type:"number",inputMode:"numeric",value:String(N??""),onChange:p=>j(l.key,Number(p.target.value))});case"string":return e.jsx("input",{className:"mobile-input mobile-input-sm",type:"text",value:String(N??""),onChange:p=>j(l.key,p.target.value)});case"object":case"array":return e.jsx("textarea",{className:"mobile-input mobile-input-sm",rows:2,value:JSON.stringify(N??null,null,2),onChange:p=>{try{j(l.key,JSON.parse(p.target.value))}catch{}}});default:return e.jsx("span",{className:"mobile-setting-value mono",children:String(N??"null")})}};return e.jsxs("div",{className:"mobile-view",children:[e.jsxs("div",{className:"mobile-tasks-toolbar",children:[e.jsxs("span",{style:{fontSize:14,color:"var(--text-muted)",flex:1},children:[t.length," config entries"]}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>y(),"aria-label":"Refresh",children:e.jsx(_,{size:16})}),e.jsxs("button",{type:"button",className:"mobile-btn",disabled:d,onClick:()=>v(),children:[e.jsx(lt,{size:14})," ",d?"Saving…":"Save all"]})]}),r?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading…"})}):t.length===0?e.jsxs("div",{className:"mobile-empty",children:[e.jsx(J,{size:40}),e.jsx("p",{children:"No config entries."})]}):e.jsx("div",{className:"mobile-config-list",children:t.map(l=>e.jsxs("div",{className:"mobile-config-row",children:[e.jsxs("div",{className:"mobile-config-key",children:[e.jsx("span",{className:"mono",children:l.key}),e.jsx("span",{className:"mobile-config-type",children:l.type})]}),e.jsx("div",{className:"mobile-config-value",children:c(l)}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>u(l.key,l.defaultValue),"aria-label":"Reset to default",title:"Reset",children:e.jsx(it,{size:14})})]},l.key))})]})}function St({onBack:s}){const[t,n]=o.useState([]),[r,i]=o.useState(!0),[m,b]=o.useState(null),[d,x]=o.useState(""),y=async()=>{try{const u=await C.get("/history");if(Array.isArray(u.history)){n(u.history);return}if(Array.isArray(u.projects)){const c=new Map;for(const l of u.events||[]){const N=l.projectId;if(!N)continue;const p=c.get(N);(!p||new Date(l.ts).getTime()>new Date(p.ts).getTime())&&c.set(N,l)}n(u.projects.map(l=>{const N=c.get(l.id);return{id:l.id,ts:l.lastAccessed||(N==null?void 0:N.ts)||new Date(0).toISOString(),agent:l.name,taskCount:l.tasks.total,summary:`${l.path} · ${l.tasks.done}/${l.tasks.total} done · ${l.plans} plan${l.plans===1?"":"s"}`,output:N?`${N.kind}${N.text?` — ${N.text}`:""}`:"No recent events."}}));return}n([])}catch{}finally{i(!1)}};o.useEffect(()=>{y()},[]);const a=u=>{if(!u)return"—";const c=Math.floor(u/1e3);if(c<60)return`${c}s`;const l=Math.floor(c/60),N=c%60;return`${l}m ${N}s`},j=u=>new Date(u).toLocaleString(),v=d.trim()?t.filter(u=>{const c=d.toLowerCase();return(u.agent||"session").toLowerCase().includes(c)||(u.summary||"").toLowerCase().includes(c)||(u.output||"").toLowerCase().includes(c)}):t;return e.jsxs("div",{className:"mobile-view",children:[e.jsxs("div",{className:"mobile-tasks-toolbar",children:[e.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search history…",value:d,onChange:u=>x(u.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>y(),"aria-label":"Refresh",children:e.jsx(_,{size:16})})]}),r?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading…"})}):v.length===0?e.jsxs("div",{className:"mobile-empty",children:[e.jsx(he,{size:40}),e.jsx("p",{children:t.length===0?"No history yet.":"No matching sessions."})]}):e.jsx("div",{className:"mobile-card-list",children:v.map(u=>e.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>b(u),children:[e.jsx("div",{className:"mobile-list-icon",children:e.jsx(he,{size:16})}),e.jsxs("div",{className:"mobile-list-content",children:[e.jsx("span",{className:"mobile-list-title",children:u.agent||"Session"}),e.jsxs("span",{className:"mobile-list-meta",children:[j(u.ts),u.duration?` · ${a(u.duration)}`:"",u.taskCount?` · ${u.taskCount} tasks`:""]})]})]},u.id))}),m&&e.jsxs(q,{open:!0,onClose:()=>b(null),title:"Session Detail",children:[e.jsxs("div",{className:"mobile-agent-detail-meta",children:[e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Agent"}),e.jsx("span",{children:m.agent||"—"})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Started"}),e.jsx("span",{children:j(m.ts)})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Duration"}),e.jsx("span",{children:a(m.duration)})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Tasks"}),e.jsx("span",{children:m.taskCount||0})]})]}),m.summary&&e.jsxs("div",{style:{marginTop:12},children:[e.jsx("h4",{style:{fontSize:12,color:"var(--text-muted)",marginBottom:4},children:"Summary"}),e.jsx("p",{style:{fontSize:13},children:m.summary})]}),m.output&&e.jsxs("div",{style:{marginTop:12},children:[e.jsx("h4",{style:{fontSize:12,color:"var(--text-muted)",marginBottom:4},children:"Output"}),e.jsxs("pre",{className:"mono",style:{fontSize:11,whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--bg-elev-2)",padding:8,borderRadius:6},children:[m.output.slice(0,1e3),m.output.length>1e3?"…":""]})]})]})]})}function Ct({snapshot:s,onBack:t}){const[n,r]=o.useState(s.mods||[]),[i,m]=o.useState(!s.mods),[b,d]=o.useState(""),[x,y]=o.useState("all"),[a,j]=o.useState(null),v=async()=>{try{const l=await C.get("/mods");r(l.mods||[])}catch{}finally{m(!1)}};o.useEffect(()=>{s.mods?(r(s.mods),m(!1)):v()},[s.mods]);const u=async(l,N)=>{try{await C.patch(`/mods/${encodeURIComponent(l)}`,{enabled:N}),r(p=>p.map(g=>g.id===l?{...g,enabled:N}:g)),(a==null?void 0:a.id)===l&&j(p=>p&&{...p,enabled:N})}catch{}},c=n.filter(l=>{if(x==="enabled"&&!l.enabled||x==="disabled"&&l.enabled)return!1;if(b){const N=b.toLowerCase();return l.name.toLowerCase().includes(N)||l.description.toLowerCase().includes(N)}return!0});return e.jsxs("div",{className:"mobile-view",children:[e.jsxs("div",{className:"mobile-tasks-toolbar",children:[e.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search mods…",value:b,onChange:l=>d(l.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>v(),"aria-label":"Refresh",children:e.jsx(_,{size:16})})]}),e.jsx("div",{className:"mobile-search-scopes",children:["all","enabled","disabled"].map(l=>e.jsx("button",{type:"button",className:`mobile-scope-chip ${x===l?"active":""}`,onClick:()=>y(l),children:l.charAt(0).toUpperCase()+l.slice(1)},l))}),i?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading…"})}):c.length===0?e.jsxs("div",{className:"mobile-empty",children:[e.jsx(J,{size:40}),e.jsx("p",{children:"No mods found."})]}):e.jsx("div",{className:"mobile-card-list",children:c.map(l=>e.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>j(l),children:[e.jsx("div",{className:"mobile-list-icon",children:e.jsx(J,{size:16})}),e.jsxs("div",{className:"mobile-list-content",children:[e.jsx("span",{className:"mobile-list-title",children:l.name}),e.jsxs("span",{className:"mobile-list-meta",children:["v",l.version," · ",l.author]})]}),e.jsx("span",{className:`mobile-list-badge ${l.enabled?"badge-on":"badge-off"}`,children:l.enabled?"on":"off"})]},l.id))}),a&&e.jsx(q,{open:!0,onClose:()=>j(null),title:a.name,actions:e.jsx("div",{className:"mobile-task-detail-actions",children:e.jsxs("button",{type:"button",className:"mobile-btn",style:{flex:1},onClick:()=>{a&&u(a.id,!a.enabled)},children:[e.jsx(Fe,{size:14})," ",a.enabled?"Disable":"Enable"]})}),children:e.jsxs("div",{className:"mobile-agent-detail",children:[e.jsx("p",{className:"mobile-agent-detail-desc",children:a.description||"No description."}),e.jsxs("div",{className:"mobile-agent-detail-meta",children:[e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Version"}),e.jsx("span",{className:"mono",children:a.version})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Author"}),e.jsx("span",{children:a.author})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Bizar"}),e.jsx("span",{className:"mono",children:a.bizar})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Type"}),e.jsx("span",{children:a.type})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Permissions"}),e.jsx("span",{children:a.permissions.length})]}),a.installedAt&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Installed"}),e.jsx("span",{children:new Date(a.installedAt).toLocaleDateString()})]})]})]})})]})}function Tt({snapshot:s,onNavigate:t}){var b,d,x;const[n,r]=o.useState(""),i=[{id:"artifacts",icon:H,label:"Plans",count:s.artifacts.length||0,desc:"Visual artifacts with elements & comments"},{id:"agents",icon:ae,label:"Agents",count:((b=s.agents)==null?void 0:b.length)||0,desc:"The Norse pantheon"},{id:"skills",icon:J,label:"Skills",count:null,desc:"Agent capabilities & tools"},{id:"mods",icon:J,label:"Mods",count:((d=s.mods)==null?void 0:d.length)||0,desc:"Installed modifications"},{id:"schedules",icon:be,label:"Schedules",count:((x=s.schedules)==null?void 0:x.length)||0,desc:"Cron jobs & automated tasks"},{id:"history",icon:he,label:"History",count:null,desc:"Past sessions & outputs"},{id:"config",icon:qe,label:"Config",count:null,desc:"Key-value configuration editor"}],m=n.trim()?i.filter(y=>y.label.toLowerCase().includes(n.toLowerCase())||y.desc.toLowerCase().includes(n.toLowerCase())):i;return e.jsxs("div",{className:"mobile-view",children:[e.jsx("div",{className:"mobile-tasks-toolbar",children:e.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search…",value:n,onChange:y=>r(y.target.value),style:{flex:1}})}),e.jsx("div",{className:"mobile-card-list",children:m.map(y=>{const a=y.icon;return e.jsxs("button",{type:"button",className:"mobile-more-nav-item",onClick:()=>t(y.id),children:[e.jsx("div",{className:"mobile-more-nav-icon",children:e.jsx(a,{size:20})}),e.jsxs("div",{className:"mobile-more-nav-content",children:[e.jsxs("span",{className:"mobile-more-nav-label",children:[y.label,y.count!=null&&e.jsx("span",{className:"mobile-more-nav-count",children:y.count})]}),e.jsx("span",{className:"mobile-more-nav-desc",children:y.desc})]}),e.jsx(ye,{size:16,className:"mobile-more-nav-arrow"})]},y.id)})}),e.jsx("div",{className:"mobile-more-footer",children:e.jsxs("a",{href:"/?desktop=1",className:"mobile-more-link",children:["Switch to Desktop ",e.jsx(ye,{size:14})]})})]})}const pe=[{id:"task",label:"Task",color:"var(--info)"},{id:"note",label:"Note",color:"var(--text-dim)"},{id:"decision",label:"Decision",color:"var(--accent)"},{id:"question",label:"Question",color:"var(--warning)"}];function de(s){var t;return((t=pe.find(n=>n.id===s))==null?void 0:t.color)||"var(--text-dim)"}function Et({type:s,size:t=12}){switch(s){case"task":return e.jsx(se,{size:t,style:{color:"var(--info)"}});case"note":return e.jsx(Ne,{size:t,style:{color:"var(--text-dim)"}});case"decision":return e.jsx(se,{size:t,style:{color:"var(--accent)"}});case"question":return e.jsx(ot,{size:t,style:{color:"var(--warning)"}});default:return e.jsx(Ne,{size:t})}}function At({slug:s,onBack:t}){const[n,r]=o.useState(null),[i,m]=o.useState(null),[b,d]=o.useState(!0),[x,y]=o.useState(!1),[a,j]=o.useState(null),[v,u]=o.useState(!1),[c,l]=o.useState(!1),[N,p]=o.useState(!1),[g,E]=o.useState(""),S=async()=>{d(!0);try{const f=await C.get(`/plans/${encodeURIComponent(s)}`);r(f.canvas),m(f.meta)}catch{}finally{d(!1)}};o.useEffect(()=>{S()},[s]);const D=async(f,L,h)=>{try{const w=((n==null?void 0:n.elements)||[]).reduce((A,M)=>Math.max(A,M.x||0),40),T=((n==null?void 0:n.elements)||[]).reduce((A,M)=>Math.max(A,M.y||0),40);await C.post(`/plans/${encodeURIComponent(s)}/elements`,{type:f,title:L,content:h,x:20+w,y:20+T,width:240,height:120}),await S(),l(!1)}catch{}},R=async(f,L)=>{try{await C.put(`/plans/${encodeURIComponent(s)}/elements/${encodeURIComponent(f)}`,L),await S(),j(null)}catch{}},I=async f=>{if(confirm("Delete this element?"))try{await C.del(`/plans/${encodeURIComponent(s)}/elements/${encodeURIComponent(f)}`),j(null),await S()}catch{}},P=async(f,L)=>{try{const h=L?`/plans/${encodeURIComponent(s)}/elements/${encodeURIComponent(L)}/comments`:`/plans/${encodeURIComponent(s)}/comments`;await C.post(h,{text:f,elementId:L}),await S(),E(""),p(!1)}catch{}};return b||!n||!i?e.jsx("div",{className:"mobile-view",children:e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading canvas…"})})}):e.jsxs("div",{className:"mobile-view mobile-view-canvas",children:[e.jsxs("div",{className:"mobile-canvas-bar",children:[e.jsxs("div",{className:"mobile-canvas-meta",children:[e.jsx("span",{className:"mobile-canvas-title",children:i.title||s}),e.jsx("span",{className:"mobile-canvas-status","data-status":i.status,children:i.status})]}),e.jsxs("div",{className:"mobile-canvas-actions",children:[e.jsx("button",{type:"button",className:`mobile-icon-btn ${x?"active":""}`,onClick:()=>y(f=>!f),"aria-label":x?"Done editing":"Edit",children:e.jsx(_e,{size:16})}),e.jsxs("button",{type:"button",className:"mobile-icon-btn",onClick:()=>u(f=>!f),"aria-label":"Comments",children:[e.jsx(Y,{size:16}),n.comments.length>0&&e.jsx("span",{className:"mobile-canvas-comment-count",children:n.comments.length})]}),x&&e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>l(!0),"aria-label":"Add element",children:e.jsx(B,{size:16})})]})]}),e.jsxs("div",{className:"mobile-canvas-elements",children:[n.elements.length===0&&e.jsxs("div",{className:"mobile-empty",children:[e.jsx("p",{children:"No elements yet."}),x&&e.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>l(!0),children:[e.jsx(B,{size:14})," Add Element"]})]}),n.elements.map(f=>e.jsxs("button",{type:"button",className:`mobile-canvas-element ${(a==null?void 0:a.id)===f.id?"selected":""}`,style:{borderColor:de(f.type)},onClick:()=>{x&&j(f)},"aria-pressed":(a==null?void 0:a.id)===f.id,children:[e.jsxs("div",{className:"mobile-canvas-el-header",style:{background:`${de(f.type)}18`},children:[e.jsx(Et,{type:f.type,size:12}),e.jsx("span",{className:"mobile-canvas-el-type",style:{color:de(f.type)},children:f.type}),f.status&&f.status!=="open"&&e.jsx("span",{className:"mobile-canvas-el-status",children:f.status})]}),e.jsx("div",{className:"mobile-canvas-el-title",children:f.title||"Untitled"}),f.content&&e.jsxs("div",{className:"mobile-canvas-el-content",children:[f.content.slice(0,120),f.content.length>120?"…":""]}),e.jsxs("div",{className:"mobile-canvas-el-comments",children:[e.jsx(Y,{size:10}),n.comments.filter(L=>L.elementId===f.id).length]})]},f.id))]}),v&&e.jsxs("div",{className:"mobile-canvas-comments",children:[e.jsxs("div",{className:"mobile-canvas-comments-header",children:[e.jsxs("h4",{children:["Comments (",n.comments.length,")"]}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>u(!1),children:e.jsx(G,{size:16})})]}),e.jsxs("div",{className:"mobile-canvas-comment-list",children:[n.comments.length===0&&e.jsx("p",{className:"mobile-empty-inline",children:"No comments yet."}),n.comments.map(f=>e.jsxs("div",{className:"mobile-canvas-comment",children:[e.jsxs("div",{className:"mobile-canvas-comment-head",children:[e.jsx("span",{className:"mono",children:f.author}),e.jsx("span",{className:"muted",children:K(f.created)})]}),e.jsx("div",{className:"mobile-canvas-comment-text",children:f.text})]},f.id))]}),e.jsxs("div",{className:"mobile-canvas-comment-input",children:[e.jsx("textarea",{className:"mobile-input",rows:2,placeholder:"Add a comment…",value:g,onChange:f=>E(f.target.value)}),e.jsx("button",{type:"button",className:"mobile-btn",disabled:!g.trim(),onClick:()=>{P(g.trim(),null)},children:"Post"})]})]}),a&&e.jsx(q,{open:!0,onClose:()=>j(null),title:`Edit ${a.title||a.type}`,actions:e.jsxs("div",{className:"mobile-task-detail-actions",children:[e.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>I(a.id),children:[e.jsx(ne,{size:14})," Delete"]}),e.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>p(!0),children:[e.jsx(Y,{size:14})," Comment"]})]}),children:e.jsx($t,{element:a,onSave:f=>R(a.id,f),onClose:()=>j(null)})}),e.jsx(Lt,{open:c,onClose:()=>l(!1),onAdd:D}),e.jsx(W,{open:N,onClose:()=>p(!1),title:"Add Comment",actions:e.jsxs("button",{type:"button",className:"mobile-btn",style:{width:"100%"},disabled:!g.trim(),onClick:()=>{P(g.trim(),(a==null?void 0:a.id)||null),p(!1)},children:[e.jsx(Y,{size:14})," Post"]}),children:e.jsx("textarea",{className:"mobile-input",rows:3,placeholder:"Your comment…",value:g,onChange:f=>E(f.target.value),autoFocus:!0})})]})}function $t({element:s,onSave:t,onClose:n}){const[r,i]=o.useState(s.type),[m,b]=o.useState(s.title||""),[d,x]=o.useState(s.content||""),[y,a]=o.useState(s.status||"open");return e.jsxs("form",{className:"mobile-task-form",onSubmit:j=>{j.preventDefault(),t({type:r,title:m,content:d,status:y}),n()},children:[e.jsx("label",{className:"mobile-field-label",children:"Type"}),e.jsx("select",{className:"mobile-input",value:r,onChange:j=>i(j.target.value),children:pe.map(j=>e.jsx("option",{value:j.id,children:j.label},j.id))}),e.jsx("label",{className:"mobile-field-label",children:"Title"}),e.jsx("input",{className:"mobile-input",type:"text",value:m,onChange:j=>b(j.target.value)}),e.jsx("label",{className:"mobile-field-label",children:"Status"}),e.jsx("input",{className:"mobile-input",type:"text",value:y,onChange:j=>a(j.target.value),placeholder:"open / done / blocked"}),e.jsx("label",{className:"mobile-field-label",children:"Content (markdown)"}),e.jsx("textarea",{className:"mobile-input",rows:4,value:d,onChange:j=>x(j.target.value)}),e.jsx("button",{type:"submit",className:"mobile-btn",style:{width:"100%",marginTop:8},children:"Save"})]})}function Lt({open:s,onClose:t,onAdd:n}){const[r,i]=o.useState("task"),[m,b]=o.useState(""),[d,x]=o.useState(""),y=a=>{a.preventDefault(),m.trim()&&(n(r,m.trim(),d.trim()),b(""),x(""))};return e.jsx(W,{open:s,onClose:t,title:"Add Element",actions:e.jsxs("button",{type:"submit",form:"add-el-form",className:"mobile-btn",style:{width:"100%"},children:[e.jsx(B,{size:14})," Add"]}),children:e.jsxs("form",{id:"add-el-form",onSubmit:y,className:"mobile-task-form",children:[e.jsx("label",{className:"mobile-field-label",children:"Type"}),e.jsx("select",{className:"mobile-input",value:r,onChange:a=>i(a.target.value),children:pe.map(a=>e.jsx("option",{value:a.id,children:a.label},a.id))}),e.jsx("label",{className:"mobile-field-label",children:"Title *"}),e.jsx("input",{className:"mobile-input",type:"text",placeholder:"Element title",value:m,onChange:a=>b(a.target.value),autoFocus:!0,required:!0}),e.jsx("label",{className:"mobile-field-label",children:"Content (markdown)"}),e.jsx("textarea",{className:"mobile-input",rows:3,placeholder:"Description…",value:d,onChange:a=>x(a.target.value)})]})})}function zt({snapshot:s,onBack:t,onOpenArtifact:n}){const[r,i]=o.useState(s.artifacts||[]),[m,b]=o.useState(!s.artifacts),[d,x]=o.useState(""),[y,a]=o.useState(!1),[j,v]=o.useState(""),[u,c]=o.useState(""),l=async()=>{try{const g=await C.get("/artifacts");i(g.artifacts||[])}catch{}finally{b(!1)}},N=async()=>{if(j.trim())try{const g=await C.post("/artifacts",{slug:j.trim(),title:u.trim()||void 0});a(!1),v(""),c(""),n(g.slug)}catch{}},p=d.trim()?r.filter(g=>(g.title||g.slug||"").toLowerCase().includes(d.toLowerCase())):r;return e.jsxs("div",{className:"mobile-view",children:[e.jsxs("div",{className:"mobile-tasks-toolbar",children:[e.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search artifacts…",value:d,onChange:g=>x(g.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>l(),"aria-label":"Refresh",children:e.jsx(_,{size:16})})]}),e.jsx("div",{style:{marginBottom:12},children:e.jsxs("button",{type:"button",className:"mobile-btn",style:{width:"100%"},onClick:()=>a(!0),children:[e.jsx(B,{size:14})," New Artifact"]})}),m?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading…"})}):p.length===0?e.jsxs("div",{className:"mobile-empty",children:[e.jsx(H,{size:40}),e.jsx("p",{children:"No artifacts yet."})]}):e.jsx("div",{className:"mobile-card-list",children:p.map(g=>e.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>n(g.slug),children:[e.jsx("div",{className:"mobile-list-icon",children:e.jsx(H,{size:16})}),e.jsxs("div",{className:"mobile-list-content",children:[e.jsx("span",{className:"mobile-list-title",children:g.title||g.slug}),e.jsxs("span",{className:"mobile-list-meta",children:[g.status," · ",g.source,g.elementCount!=null?` · ${g.elementCount} elements`:"",g.commentCount!=null?` · ${g.commentCount} comments`:""]})]}),e.jsx("span",{className:"mobile-list-badge","data-status":g.status,children:g.status})]},g.slug))}),e.jsx(W,{open:y,onClose:()=>a(!1),title:"New Artifact",actions:e.jsxs("button",{type:"submit",form:"new-plan-form",className:"mobile-btn",style:{width:"100%"},children:[e.jsx(B,{size:14})," Create"]}),children:e.jsxs("form",{id:"new-plan-form",onSubmit:g=>{g.preventDefault(),N()},className:"mobile-task-form",children:[e.jsx("label",{className:"mobile-field-label",children:"Slug *"}),e.jsx("input",{className:"mobile-input",type:"text",placeholder:"my-plan",pattern:"[a-z0-9][a-z0-9-]{0,63}",value:j,onChange:g=>v(g.target.value),autoFocus:!0,required:!0}),e.jsx("label",{className:"mobile-field-label",children:"Title (optional)"}),e.jsx("input",{className:"mobile-input",type:"text",placeholder:"My Artifact",value:u,onChange:g=>c(g.target.value)})]})})]})}const Dt=["cron","interval","once"],It=["command","agent","webhook"],De=["UTC","America/New_York","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Tokyo"],Ye=Array.from({length:24},(s,t)=>({value:t,label:t===0?"12 AM":t<12?`${t} AM`:t===12?"12 PM":`${t-12} PM`})),Rt=Array.from({length:12},(s,t)=>t*5),Ke=[{value:"*",label:"Every day"},{value:"0",label:"Sun"},{value:"1",label:"Mon"},{value:"2",label:"Tue"},{value:"3",label:"Wed"},{value:"4",label:"Thu"},{value:"5",label:"Fri"},{value:"6",label:"Sat"}],Mt=[{value:"s",label:"sec"},{value:"m",label:"min"},{value:"h",label:"hr"},{value:"d",label:"day"}];function Pt({snapshot:s}){var N;const[t,n]=o.useState(s.schedules||[]),[r,i]=o.useState(!s.schedules),[m,b]=o.useState(""),[d,x]=o.useState(null),[y,a]=o.useState({open:!1}),j=async()=>{try{const p=await C.get("/schedules");n(p.schedules||[])}catch{}finally{i(!1)}};o.useEffect(()=>{s.schedules?(n(s.schedules),i(!1)):j()},[s.schedules]);const v=async(p,g)=>{try{await C.patch(`/schedules/${encodeURIComponent(p)}`,{enabled:g}),n(E=>E.map(S=>S.id===p?{...S,enabled:g}:S)),(d==null?void 0:d.id)===p&&x(E=>E&&{...E,enabled:g})}catch{}},u=async p=>{if(confirm("Delete this schedule?"))try{await C.del(`/schedules/${encodeURIComponent(p)}`),n(g=>g.filter(E=>E.id!==p)),(d==null?void 0:d.id)===p&&x(null)}catch{}},c=async p=>{try{await C.post(`/schedules/${encodeURIComponent(p)}/trigger`)}catch{}},l=m.trim()?t.filter(p=>p.name.toLowerCase().includes(m.toLowerCase())):t;return e.jsxs("div",{className:"mobile-view",children:[e.jsxs("div",{className:"mobile-tasks-toolbar",children:[e.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search schedules…",value:m,onChange:p=>b(p.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>j(),"aria-label":"Refresh",children:e.jsx(_,{size:16})}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>a({open:!0}),"aria-label":"New schedule",children:e.jsx(B,{size:16})})]}),r?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading…"})}):l.length===0?e.jsxs("div",{className:"mobile-empty",children:[e.jsx(be,{size:40}),e.jsx("p",{children:"No schedules found."})]}):e.jsx("div",{className:"mobile-card-list",children:l.map(p=>e.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>x(p),children:[e.jsx("div",{className:"mobile-list-icon",children:e.jsx(be,{size:16})}),e.jsxs("div",{className:"mobile-list-content",children:[e.jsx("span",{className:"mobile-list-title",children:p.name}),e.jsxs("span",{className:"mobile-list-meta",children:[Me(p)," ·"," ",p.nextRun?`next ${Re(p.nextRun,p.timezone)}`:"no next run"]})]}),e.jsx("span",{className:`mobile-list-badge ${p.enabled?"badge-on":"badge-off"}`,children:p.enabled?"on":"off"})]},p.id))}),d&&e.jsx(q,{open:!0,onClose:()=>x(null),title:d.name,actions:e.jsxs("div",{className:"mobile-task-detail-actions",children:[e.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>{d&&c(d.id)},children:[e.jsx(te,{size:14})," Trigger now"]}),e.jsx("button",{type:"button",className:`mobile-btn ${d.enabled?"mobile-btn-secondary":""}`,onClick:()=>{d&&v(d.id,!d.enabled)},children:d.enabled?"Disable":"Enable"}),e.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>{d&&(a({open:!0,initial:d}),x(null))},children:[e.jsx(_e,{size:14})," Edit"]}),e.jsx("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>{d&&u(d.id)},children:e.jsx(ne,{size:14})})]}),children:e.jsx("div",{className:"mobile-agent-detail",children:e.jsxs("div",{className:"mobile-agent-detail-meta",children:[e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Type"}),e.jsx("span",{children:d.type})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Schedule"}),e.jsx("span",{className:"mono",children:Me(d)||d.schedule})]}),d.timezone&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Timezone"}),e.jsx("span",{className:"mono",children:d.timezone})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Action"}),e.jsxs("span",{children:[d.action.type,": ",d.action.target]})]}),d.action.type==="agent"&&d.action.prompt&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Prompt"}),e.jsx("span",{style:{fontSize:12},children:d.action.prompt})]}),((N=d.budgetCheck)==null?void 0:N.skipIfBudgetLow)&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Budget gate"}),e.jsxs("span",{children:["skip if ≥ ",d.budgetCheck.maxConcurrent??6," concurrent"]})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Next run"}),e.jsx("span",{children:d.nextRun?Re(d.nextRun,d.timezone):"—"})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Last run"}),e.jsx("span",{children:d.lastRun?Bt(d.lastRun):"—"})]}),d.lastResult&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Last result"}),e.jsx("span",{style:{fontSize:12},children:d.lastResult})]}),d.lastError&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Last error"}),e.jsx("span",{style:{fontSize:12},children:d.lastError})]})]})})}),e.jsx(Ut,{open:y.open,initial:y.initial,onClose:()=>a({open:!1}),onSaved:()=>{a({open:!1}),j()}})]})}function Ie(s){var r,i;if(!s)return{name:"",type:"cron",cronMinute:0,cronHour:13,cronDow:"0",intervalN:30,intervalUnit:"m",onceAt:"",timezone:"UTC",actionType:"agent",actionTarget:"",actionPrompt:"",skipIfBudgetLow:!1,maxConcurrent:6,enabled:!0};const t=s.type==="cron"?Je(s.schedule):null,n=s.type==="interval"?Ft(s.schedule):null;return{name:s.name||"",type:s.type,cronMinute:(t==null?void 0:t.minute)??0,cronHour:(t==null?void 0:t.hour)??9,cronDow:(t==null?void 0:t.dow)??"*",intervalN:(n==null?void 0:n.n)??30,intervalUnit:(n==null?void 0:n.unit)??"m",onceAt:s.type==="once"?qt(s.schedule):"",timezone:s.timezone||"UTC",actionType:s.action.type,actionTarget:s.action.target||"",actionPrompt:s.action.prompt||"",skipIfBudgetLow:!!((r=s.budgetCheck)!=null&&r.skipIfBudgetLow),maxConcurrent:Number.isFinite((i=s.budgetCheck)==null?void 0:i.maxConcurrent)?s.budgetCheck.maxConcurrent:6,enabled:s.enabled!==!1}}function Ot(s){if(s.type==="cron")return`${s.cronMinute} ${s.cronHour} * * ${s.cronDow}`;if(s.type==="interval")return`${s.intervalN}${s.intervalUnit}`;if(!s.onceAt)return"";try{return new Date(s.onceAt).toISOString()}catch{return s.onceAt}}function Ut({open:s,initial:t,onClose:n,onSaved:r}){const[i,m]=o.useState(()=>Ie(t)),[b,d]=o.useState(!1);o.useEffect(()=>{s&&m(Ie(t))},[s,t]);const x=(a,j)=>{m(v=>({...v,[a]:j}))},y=async a=>{if(a.preventDefault(),!i.name.trim())return;const j=Ot(i);if(j){d(!0);try{const v={name:i.name.trim(),type:i.type,schedule:j,timezone:i.timezone,action:{type:i.actionType,target:i.actionTarget.trim(),...i.actionType==="agent"&&i.actionPrompt.trim()?{prompt:i.actionPrompt.trim()}:{}},budgetCheck:{maxConcurrent:i.maxConcurrent,skipIfBudgetLow:i.skipIfBudgetLow},enabled:i.enabled};t?await C.put(`/schedules/${encodeURIComponent(t.id)}`,v):await C.post("/schedules",v),r()}catch{}finally{d(!1)}}};return e.jsx(W,{open:s,onClose:n,title:t?`Edit ${t.name}`:"New schedule",actions:e.jsxs("button",{type:"submit",form:"mobile-schedule-form",className:"mobile-btn",style:{width:"100%"},disabled:b,children:[e.jsx(B,{size:14})," ",t?"Save":"Create"]}),children:e.jsxs("form",{id:"mobile-schedule-form",onSubmit:y,className:"mobile-task-form",children:[e.jsx("label",{className:"mobile-field-label",children:"Name *"}),e.jsx("input",{className:"mobile-input",type:"text",placeholder:"Weekly review",value:i.name,onChange:a=>x("name",a.target.value),autoFocus:!0,required:!0}),e.jsx("label",{className:"mobile-field-label",children:"Type"}),e.jsx("select",{className:"mobile-input",value:i.type,onChange:a=>x("type",a.target.value),children:Dt.map(a=>e.jsx("option",{value:a,children:a},a))}),i.type==="cron"&&e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"mobile-field-label",children:"Day of week"}),e.jsx("select",{className:"mobile-input",value:i.cronDow,onChange:a=>x("cronDow",a.target.value),children:Ke.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))}),e.jsxs("div",{className:"mobile-form-row",children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{className:"mobile-field-label",children:"Hour"}),e.jsx("select",{className:"mobile-input",value:String(i.cronHour),onChange:a=>x("cronHour",parseInt(a.target.value,10)),children:Ye.map(a=>e.jsx("option",{value:String(a.value),children:a.label},a.value))})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{className:"mobile-field-label",children:"Minute"}),e.jsx("select",{className:"mobile-input",value:String(i.cronMinute),onChange:a=>x("cronMinute",parseInt(a.target.value,10)),children:Rt.map(a=>e.jsx("option",{value:String(a),children:String(a).padStart(2,"0")},a))})]})]})]}),i.type==="interval"&&e.jsxs("div",{className:"mobile-form-row",children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{className:"mobile-field-label",children:"Every"}),e.jsx("input",{className:"mobile-input",type:"number",min:1,value:i.intervalN,onChange:a=>x("intervalN",parseInt(a.target.value,10)||1)})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{className:"mobile-field-label",children:"Unit"}),e.jsx("select",{className:"mobile-input",value:i.intervalUnit,onChange:a=>x("intervalUnit",a.target.value),children:Mt.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))})]})]}),i.type==="once"&&e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"mobile-field-label",children:"Run at"}),e.jsx("input",{className:"mobile-input",type:"datetime-local",value:i.onceAt,onChange:a=>x("onceAt",a.target.value)})]}),e.jsx("label",{className:"mobile-field-label",children:"Timezone"}),e.jsx("select",{className:"mobile-input",value:De.includes(i.timezone)?i.timezone:"UTC",onChange:a=>x("timezone",a.target.value),children:De.map(a=>e.jsx("option",{value:a,children:a},a))}),e.jsx("label",{className:"mobile-field-label",children:"Action type"}),e.jsx("select",{className:"mobile-input",value:i.actionType,onChange:a=>x("actionType",a.target.value),children:It.map(a=>e.jsx("option",{value:a,children:a},a))}),e.jsx("label",{className:"mobile-field-label",children:"Target"}),e.jsx("input",{className:"mobile-input",type:"text",placeholder:i.actionType==="webhook"?"https://...":i.actionType==="agent"?"agent or task ref":"echo hello",value:i.actionTarget,onChange:a=>x("actionTarget",a.target.value)}),i.actionType==="agent"&&e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"mobile-field-label",children:"Prompt"}),e.jsx("textarea",{className:"mobile-input",rows:3,placeholder:"What should the agent do?",value:i.actionPrompt,onChange:a=>x("actionPrompt",a.target.value)})]}),e.jsxs("fieldset",{className:"mobile-budget-card",children:[e.jsx("legend",{children:"Budget pre-flight"}),e.jsxs("label",{className:"mobile-checkbox-row",children:[e.jsx("input",{type:"checkbox",checked:i.skipIfBudgetLow,onChange:a=>x("skipIfBudgetLow",a.target.checked)}),e.jsx("span",{children:"Skip if too many bg tasks are running"})]}),e.jsx("label",{className:"mobile-field-label",children:"Cap"}),e.jsx("input",{className:"mobile-input",type:"number",min:1,max:64,value:i.maxConcurrent,onChange:a=>x("maxConcurrent",parseInt(a.target.value,10)||6),disabled:!i.skipIfBudgetLow})]}),e.jsxs("label",{className:"mobile-checkbox-row",children:[e.jsx("input",{type:"checkbox",checked:i.enabled,onChange:a=>x("enabled",a.target.checked)}),e.jsx("span",{children:"Enabled"})]})]})})}function Bt(s){const t=Date.now()-new Date(s).getTime();return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(s).toLocaleDateString()}function Re(s,t){try{return new Date(s).toLocaleString(void 0,{timeZone:t||void 0,weekday:"short",hour:"numeric",minute:"2-digit",month:"short",day:"numeric"})}catch{return new Date(s).toLocaleString()}}function Je(s){if(typeof s!="string")return null;const t=s.trim().split(/\s+/);if(t.length!==5)return null;const[n,r,,,i]=t,m=parseInt(n,10),b=parseInt(r,10);return!Number.isFinite(m)||!Number.isFinite(b)||n!==String(m)||r!==String(b)?null:{minute:m,hour:b,dow:i==="*"?"*":Number.isFinite(parseInt(i,10))?i:"*"}}function Ft(s){if(typeof s!="string")return null;const t=/^(\d+)([smhd])$/i.exec(s.trim());return t?{n:parseInt(t[1],10),unit:t[2].toLowerCase()}:null}function qt(s){if(!s)return"";try{const t=new Date(s);if(Number.isNaN(t.getTime()))return"";const n=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}catch{return""}}function Me(s){var m,b;if(s.type!=="cron")return s.schedule;const t=Je(s.schedule);if(!t)return s.schedule;const n=((m=Ke.find(d=>d.value===t.dow))==null?void 0:m.label)||t.dow,r=((b=Ye.find(d=>d.value===t.hour))==null?void 0:b.label)||`${t.hour}`,i=String(t.minute).padStart(2,"0");return n==="Every day"?`Every day ${r} :${i}`:`Every ${n} ${r} :${i}`}const _t=["all","tasks","agents","artifacts","projects","settings"],Wt={tasks:se,agents:ae,plans:H,projects:ct,settings:J};function Ht({open:s,onClose:t,onNavigate:n}){const[r,i]=o.useState(""),[m,b]=o.useState("all"),[d,x]=o.useState([]),[y,a]=o.useState(!1),j=o.useRef(null);o.useEffect(()=>{s&&(i(""),x([]),requestAnimationFrame(()=>{var c;return(c=j.current)==null?void 0:c.focus()}))},[s]),o.useEffect(()=>{if(!r.trim()){x([]);return}const c=setTimeout(async()=>{a(!0);try{const l=await C.get(`/search?q=${encodeURIComponent(r)}&scope=${m}`);x(l.results||[])}catch{x([])}finally{a(!1)}},250);return()=>clearTimeout(c)},[r,m]);const v=c=>{const l=c.item,N=l.id||l.slug||l.name||"";n(c.type,N),t()},u=d.reduce((c,l)=>(c[l.type]||(c[l.type]=[]),c[l.type].push(l),c),{});return e.jsx(W,{open:s,onClose:t,title:"Search",children:e.jsxs("div",{className:"mobile-search-container",children:[e.jsxs("div",{className:"mobile-search-input-row",children:[e.jsx(me,{size:16,style:{color:"var(--text-muted)",flexShrink:0}}),e.jsx("input",{ref:j,className:"mobile-search-field",type:"text",placeholder:"Search…",value:r,onChange:c=>i(c.target.value),enterKeyHint:"search",onKeyDown:c=>{c.key==="Escape"&&t(),c.key==="Enter"&&d.length>0&&v(d[0])}}),r&&e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>i(""),"aria-label":"Clear",children:e.jsx(G,{size:16})})]}),e.jsx("div",{className:"mobile-search-scopes",children:_t.map(c=>e.jsx("button",{type:"button",className:`mobile-scope-chip ${m===c?"active":""}`,onClick:()=>b(c),children:c==="all"?"All":c.charAt(0).toUpperCase()+c.slice(1)},c))}),e.jsxs("div",{className:"mobile-search-results",children:[y&&e.jsx("div",{className:"mobile-search-loading",children:"Searching…"}),!y&&r&&d.length===0&&e.jsxs("div",{className:"mobile-empty",children:[e.jsx(me,{size:32}),e.jsx("p",{children:"No results found"})]}),!y&&!r&&e.jsx("div",{className:"mobile-empty",children:e.jsx("p",{children:"Type to search across tasks, agents, plans, and more."})}),Object.entries(u).map(([c,l])=>{const N=Wt[c]||H;return e.jsxs("div",{className:"mobile-search-group",children:[e.jsxs("h4",{className:"mobile-search-group-title",children:[e.jsx(N,{size:12})," ",c.charAt(0).toUpperCase()+c.slice(1)," (",l.length,")"]}),l.map((p,g)=>{const E=p.item;return e.jsxs("button",{type:"button",className:"mobile-search-result-item",onClick:()=>v(p),children:[e.jsx("span",{className:"mobile-search-result-title",children:E.title||E.name||E.slug||"(unnamed)"}),E.description&&e.jsx("span",{className:"mobile-search-result-meta",children:E.description.slice(0,80)})]},g)})]},c)})]})]})})}const Vt=["languages","framework","design","testing","devops","data","security","integration"];function Yt({snapshot:s,onBack:t}){const[n,r]=o.useState([]),[i,m]=o.useState(!0),[b,d]=o.useState(""),[x,y]=o.useState(""),[a,j]=o.useState(null),v=async()=>{try{const l=await C.get("/skills");r(l.skills||[])}catch{}finally{m(!1)}};o.useEffect(()=>{v()},[]);const u=async(l,N)=>{try{await C.patch(`/skills/${encodeURIComponent(l)}`,{enabled:N}),r(p=>p.map(g=>g.id===l?{...g,enabled:N}:g)),(a==null?void 0:a.id)===l&&j(p=>p&&{...p,enabled:N})}catch{}},c=n.filter(l=>{if(x&&l.category!==x)return!1;if(b){const N=b.toLowerCase();return l.name.toLowerCase().includes(N)||l.description.toLowerCase().includes(N)}return!0});return e.jsxs("div",{className:"mobile-view",children:[e.jsxs("div",{className:"mobile-tasks-toolbar",children:[e.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search skills…",value:b,onChange:l=>d(l.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>v(),"aria-label":"Refresh",children:e.jsx(_,{size:16})})]}),e.jsxs("div",{className:"mobile-search-scopes",children:[e.jsx("button",{type:"button",className:`mobile-scope-chip ${x?"":"active"}`,onClick:()=>y(""),children:"All"}),Vt.map(l=>e.jsx("button",{type:"button",className:`mobile-scope-chip ${x===l?"active":""}`,onClick:()=>y(l),children:l},l))]}),i?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading…"})}):c.length===0?e.jsxs("div",{className:"mobile-empty",children:[e.jsx(ke,{size:40}),e.jsx("p",{children:"No skills found."})]}):e.jsx("div",{className:"mobile-card-list",children:c.map(l=>e.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>j(l),children:[e.jsx("div",{className:"mobile-list-icon",children:e.jsx(ke,{size:16})}),e.jsxs("div",{className:"mobile-list-content",children:[e.jsx("span",{className:"mobile-list-title",children:l.name}),e.jsxs("span",{className:"mobile-list-meta",children:[l.category," · v",l.version]})]}),e.jsx("span",{className:`mobile-list-badge ${l.enabled?"badge-on":"badge-off"}`,children:l.enabled?"on":"off"})]},l.id))}),a&&e.jsx(q,{open:!0,onClose:()=>j(null),title:a.name,actions:e.jsxs("button",{type:"button",className:`mobile-btn ${a.enabled?"mobile-btn-secondary":""}`,style:{width:"100%"},onClick:()=>{a&&u(a.id,!a.enabled)},children:[e.jsx(Fe,{size:14})," ",a.enabled?"Disable":"Enable"]}),children:e.jsxs("div",{className:"mobile-agent-detail",children:[e.jsx("p",{className:"mobile-agent-detail-desc",children:a.description||"No description."}),e.jsxs("div",{className:"mobile-agent-detail-meta",children:[e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Category"}),e.jsx("span",{children:a.category})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Version"}),e.jsx("span",{className:"mono",children:a.version})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Source"}),e.jsx("span",{children:a.source})]}),a.tags.length>0&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Tags"}),e.jsx("span",{children:a.tags.join(", ")})]})]})]})})]})}const Kt=["queued","doing","blocked","done"],Z={queued:"Queued",doing:"Doing",blocked:"Blocked",done:"Done"},Pe={queued:"doing",doing:"done",blocked:"queued",done:"queued"};function Jt(s){const t=s.metadata??{};return!!(t.sessionId||t.bgInstanceId)}function Gt(s){var n;const t=s.metadata??{};return!!((n=t.artifactIds)!=null&&n.length||t.artifactId)}function Oe({snapshot:s,onRefresh:t,selectedTaskId:n,onCloseDetail:r,onOpenChat:i,onOpenArtifact:m}){var ge,ve;const[b,d]=o.useState(s.tasks||[]),[x,y]=o.useState(!s.tasks),[a,j]=o.useState(""),[v,u]=o.useState("queued"),[c,l]=o.useState(null),[N,p]=o.useState(!1),[g,E]=o.useState(null),[S,D]=o.useState([]),[R,I]=o.useState(""),[P,f]=o.useState(null),[L,h]=o.useState(!1),[w,T]=o.useState(""),[A,M]=o.useState("updated");o.useEffect(()=>{var k;if(s.tasks&&(d(s.tasks),y(!1)),n){const z=(k=s.tasks)==null?void 0:k.find($=>$.id===n);z&&l(z)}},[s.tasks,n]),o.useEffect(()=>{if(n){const k=b.find(z=>z.id===n);k&&l(k)}},[n,b]);const F=async()=>{try{const k=await C.get("/tasks");d(Array.isArray(k)?k:[])}catch{}finally{y(!1)}},le=async(k,z)=>{d($=>$.map(O=>O.id===k?{...O,status:z}:O)),(c==null?void 0:c.id)===k&&l($=>$&&{...$,status:z});try{await C.patch(`/tasks/${encodeURIComponent(k)}/status`,{status:z})}catch{await F()}},V=async k=>{if(confirm("Delete this task?"))try{await C.del(`/tasks/${encodeURIComponent(k)}`),d(z=>z.filter($=>$.id!==k)),(c==null?void 0:c.id)===k&&l(null)}catch{await F()}},Ge=async k=>{try{await C.post(`/tasks/${encodeURIComponent(k)}/archive`),d(z=>z.filter($=>$.id!==k)),(c==null?void 0:c.id)===k&&l(null)}catch{}},fe=[...b.filter(k=>{var z,$;if(a.trim()){const O=a.toLowerCase();if(!(k.title||"").toLowerCase().includes(O)&&!(k.description||"").toLowerCase().includes(O))return!1}if(w.trim()){const O=w==="mine"?(($=(z=s.settings)==null?void 0:z.data)==null?void 0:$.defaultAgent)||Qt(s):w.replace(/^@/,"");if((k.assignee||"").toLowerCase()!==O.toLowerCase())return!1}return!0})].sort((k,z)=>{switch(A){case"priority":{const $={high:0,normal:1,low:2};return($[k.priority]??1)-($[z.priority]??1)}case"created":return new Date(z.createdAt).getTime()-new Date(k.createdAt).getTime();case"updated":default:return new Date(z.updatedAt).getTime()-new Date(k.updatedAt).getTime()}}),xe=fe.filter(k=>k.status===v),je=s.agents||[],Qe=async(k,z,$,O)=>{try{const ie=await C.post("/tasks",{title:k,description:z,assignee:$||null,priority:O});d(oe=>[ie,...oe]),p(!1)}catch{}},Xe=async k=>{h(!0),I(""),f(null),E(k);try{const $=((await C.get(`/tasks/${encodeURIComponent(k)}/artifacts`)).artifacts||[]).map(O=>O.id);if(D($),$.length>0){const[O,ie]=await Promise.all([C.get(`/artifacts/${encodeURIComponent($[0])}`),fetch(C.urlWithToken(`/artifacts/${encodeURIComponent($[0])}/content`)).then(oe=>oe.text())]);f(O),I(ie)}}catch{}finally{h(!1)}};return x?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading…"})}):e.jsxs("div",{className:"mobile-view mobile-view-tasks",children:[e.jsxs("div",{className:"mobile-tasks-toolbar",children:[e.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search tasks…",value:a,onChange:k=>j(k.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>F(),"aria-label":"Refresh",children:e.jsx(_,{size:16})})]}),e.jsxs("div",{className:"mobile-tasks-filters",children:[e.jsxs("select",{className:"mobile-filter-select",value:w,onChange:k=>T(k.target.value),children:[e.jsx("option",{value:"",children:"All"}),e.jsx("option",{value:"mine",children:"Mine"}),je.map(k=>e.jsxs("option",{value:`@${k.name}`,children:["@",k.name]},k.name))]}),e.jsxs("select",{className:"mobile-filter-select",value:A,onChange:k=>M(k.target.value),children:[e.jsx("option",{value:"updated",children:"Updated"}),e.jsx("option",{value:"created",children:"Created"}),e.jsx("option",{value:"priority",children:"Priority"})]})]}),e.jsx("div",{className:"mobile-kanban-tabs",children:Kt.map(k=>{const z=fe.filter($=>$.status===k).length;return e.jsxs("button",{type:"button",className:`mobile-kanban-tab ${v===k?"active":""}`,onClick:()=>u(k),children:[Z[k]," (",z,")"]},k)})}),e.jsxs("div",{className:"mobile-card-list",children:[xe.length===0&&e.jsxs("div",{className:"mobile-empty mobile-empty-compact",children:[e.jsxs("p",{children:["No ",Z[v].toLowerCase()," tasks."]}),e.jsx("p",{className:"muted",children:"Create one or switch columns."})]}),xe.map(k=>{var z;return e.jsxs("button",{type:"button",className:"mobile-task-card",onClick:()=>l(k),children:[e.jsx("div",{className:"priority-dot",style:{background:mt[k.priority]||"var(--info)"}}),e.jsxs("div",{className:"task-content",children:[e.jsx("div",{className:"task-title",children:k.title}),e.jsxs("div",{className:"task-meta",children:[k.assignee?`@${k.assignee}`:"unassigned"," · ",K(k.updatedAt||k.createdAt),(z=k.dependencies)!=null&&z.length?` · ${k.dependencies.length} deps`:""]})]})]},k.id)})]}),e.jsx("button",{type:"button",className:"mobile-fab",onClick:()=>p(!0),"aria-label":"Add task",children:e.jsx(B,{size:24})}),e.jsx(q,{open:!!c,onClose:()=>{l(null),r==null||r()},title:"Task Detail",actions:c&&e.jsxs("div",{className:"mobile-task-detail-actions",children:[c.status!=="done"&&e.jsxs("button",{type:"button",className:"mobile-btn",style:{flex:1},onClick:()=>{c&&le(c.id,Pe[c.status])},children:["Move to ",Z[Pe[c.status]||"queued"]]}),e.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>{c&&Ge(c.id)},children:[e.jsx(rt,{size:14})," Archive"]}),Jt(c)&&e.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>{i==null||i(c.id)},children:[e.jsx(Y,{size:14})," Chat"]}),Gt(c)&&e.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>{Xe(c.id)},children:[e.jsx(H,{size:14})," Artifact"]}),e.jsx("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>{c&&V(c.id)},children:e.jsx(ne,{size:14})})]}),children:c&&e.jsxs("div",{className:"mobile-task-detail",children:[e.jsxs("div",{className:"mobile-task-detail-header",children:[e.jsx("span",{className:`mobile-task-status-badge status-${c.status}`,children:Z[c.status]||c.status}),e.jsx("span",{className:`mobile-task-priority priority-${c.priority}`,children:c.priority})]}),e.jsx("h3",{className:"mobile-task-detail-title",children:c.title}),c.description&&e.jsx("p",{className:"mobile-task-detail-desc",children:c.description}),e.jsxs("div",{className:"mobile-task-detail-meta",children:[c.assignee&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Assignee"}),e.jsxs("span",{children:["@",c.assignee]})]}),c.dueDate&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Due"}),e.jsx("span",{children:new Date(c.dueDate).toLocaleDateString()})]}),c.timeSpent!=null&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Time spent"}),e.jsxs("span",{children:[Math.round(c.timeSpent/6e4),"min"]})]}),(ge=c.dependencies)!=null&&ge.length?e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Dependencies"}),e.jsx("span",{children:c.dependencies.length})]}):null,(ve=c.comments)!=null&&ve.length?e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Comments"}),e.jsx("span",{children:c.comments.length})]}):null,e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Created"}),e.jsx("span",{children:K(c.createdAt)})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Updated"}),e.jsx("span",{children:K(c.updatedAt)})]})]})]})}),e.jsx(Xt,{open:N,onClose:()=>p(!1),onCreate:Qe,agents:je}),e.jsx(q,{open:!!g,onClose:()=>{E(null),I(""),f(null)},title:(P==null?void 0:P.name)||"Artifact",actions:S.length>1?e.jsx("div",{className:"mobile-task-detail-actions",children:S.map((k,z)=>e.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",style:{flex:1},onClick:()=>{h(!0),Promise.all([C.get(`/artifacts/${encodeURIComponent(k)}`),fetch(C.urlWithToken(`/artifacts/${encodeURIComponent(k)}/content`)).then($=>$.text())]).then(([$,O])=>{f($),I(O),h(!1)}).catch(()=>h(!1))},children:["Artifact ",z+1]},k))}):null,children:e.jsx("div",{className:"mobile-artifact-viewer",children:L?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading artifact…"})}):R?e.jsx("iframe",{srcDoc:R,className:"mobile-artifact-iframe",sandbox:"allow-scripts allow-forms allow-popups allow-same-origin",title:(P==null?void 0:P.name)||"Artifact",loading:"lazy"}):e.jsxs("div",{className:"mobile-empty",children:[e.jsx(H,{size:32}),e.jsx("p",{className:"muted",children:"No artifact content available."})]})})})]})}function Qt(s){var t,n;return((n=(t=s.settings)==null?void 0:t.data)==null?void 0:n.defaultAgent)||"odin"}function Xt({open:s,onClose:t,onCreate:n,agents:r}){const[i,m]=o.useState(""),[b,d]=o.useState(""),[x,y]=o.useState(""),[a,j]=o.useState("normal"),v=u=>{u.preventDefault(),i.trim()&&(n(i.trim(),b.trim(),x,a),m(""),d(""),y(""),j("normal"))};return e.jsx(W,{open:s,onClose:t,title:"New Task",actions:e.jsxs("button",{type:"submit",form:"new-task-form",className:"mobile-btn",style:{width:"100%"},children:[e.jsx(B,{size:14})," Create Task"]}),children:e.jsxs("form",{id:"new-task-form",onSubmit:v,className:"mobile-task-form",children:[e.jsx("label",{className:"mobile-field-label",children:"Title *"}),e.jsx("input",{className:"mobile-input",type:"text",placeholder:"Task title",value:i,onChange:u=>m(u.target.value),autoFocus:!0,required:!0}),e.jsx("label",{className:"mobile-field-label",children:"Description"}),e.jsx("textarea",{className:"mobile-input",rows:3,placeholder:"Optional description",value:b,onChange:u=>d(u.target.value)}),e.jsx("label",{className:"mobile-field-label",children:"Assignee"}),e.jsxs("select",{className:"mobile-input",value:x,onChange:u=>y(u.target.value),children:[e.jsx("option",{value:"",children:"Unassigned"}),r.map(u=>e.jsxs("option",{value:u.name,children:["@",u.name]},u.name))]}),e.jsx("label",{className:"mobile-field-label",children:"Priority"}),e.jsxs("select",{className:"mobile-input",value:a,onChange:u=>j(u.target.value),children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"normal",children:"Normal"}),e.jsx("option",{value:"high",children:"High"})]})]})})}const Zt=Be.lazy(()=>He(()=>import("./MobileSettings-K-sNsn_r.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(s=>({default:s.MobileSettings}))),es=Be.lazy(()=>He(()=>import("./MobileChat-D7zRhU9K.js"),__vite__mapDeps([8,1,2,3,4,9,7,10,6])).then(s=>({default:s.MobileChat}))),Ue=[{id:"activity",label:"Activity",icon:ue},{id:"chat",label:"Chat",icon:Y},{id:"tasks",label:"Tasks",icon:se},{id:"settings",label:"Settings",icon:qe},{id:"more",label:"More",icon:dt}];function ts(s){const t=s.meta??{},n=typeof t.taskId=="string"?t.taskId:null,r=typeof t.slug=="string"?t.slug:null,i=typeof t.agent=="string"?t.agent:null;if(n)return{id:"task-detail",taskId:n};if(r)return{id:"artifacts?-detail",slug:r};if(i)return{id:"agent-detail",name:i};const m=s.link??"";return m.startsWith("/artifacts?/")?{id:"artifacts?-detail",slug:decodeURIComponent(m.slice(12))}:m.startsWith("/tasks/")?{id:"task-detail",taskId:decodeURIComponent(m.slice(7))}:m.startsWith("/agents/")?{id:"agent-detail",name:decodeURIComponent(m.slice(8))}:null}function ds(){const[s,t]=o.useState("activity"),[n,r]=o.useState([]),[i,m]=o.useState(!1),[b,d]=o.useState(!1),[x,y]=o.useState(null),[a,j]=o.useState(null),[v,u]=o.useState(null),[c,l]=o.useState(null),[N,p]=o.useState(!0),[g,E]=o.useState(0);o.useMemo(()=>n[n.length-1]??{id:s},[s,n]);const S=o.useCallback(h=>{r(w=>[...w,h])},[]),D=o.useCallback(()=>{r(h=>h.slice(0,-1))},[]),R=o.useCallback(h=>{r([]),t(h)},[]),I=o.useCallback(async()=>{var h;try{const w=await C.get("/snapshot");j(w),(h=w.settings)!=null&&h.data&&u(w.settings.data),l(null)}catch(w){throw l(w.message||"Dashboard server unreachable."),w}},[]);o.useEffect(()=>{let h=!1;return Promise.all([C.get("/snapshot").catch(()=>null),C.get("/settings").catch(()=>null),C.probeAuthStatus().catch(()=>null)]).then(([w,T])=>{var M;if(h)return;const A=(T==null?void 0:T.data)??((M=w==null?void 0:w.settings)==null?void 0:M.data)??null;w&&j(w),A&&u(A),l(!w&&!A?"Dashboard server unreachable.":null)}).catch(w=>{h||l(w.message||"Dashboard server unreachable.")}).finally(()=>{h||p(!1)}),()=>{h=!0}},[]),o.useEffect(()=>{v!=null&&v.theme&&(Te(v.theme),Ee(v.theme))},[v==null?void 0:v.theme]),o.useEffect(()=>{var T;if(((T=v==null?void 0:v.theme)==null?void 0:T.mode)!=="system")return;const h=window.matchMedia("(prefers-color-scheme: light)"),w=()=>{v!=null&&v.theme&&(Te(v.theme),Ee(v.theme))};return h.addEventListener("change",w),()=>h.removeEventListener("change",w)},[v==null?void 0:v.theme]),o.useEffect(()=>{const h=()=>{E(T=>T+1),I().catch(()=>{})},w=()=>{document.visibilityState==="visible"&&h()};return window.addEventListener("online",h),window.addEventListener("pageshow",h),document.addEventListener("visibilitychange",w),()=>{window.removeEventListener("online",h),window.removeEventListener("pageshow",h),document.removeEventListener("visibilitychange",w)}},[I]),o.useEffect(()=>{const h=new We,w=h.on(T=>{if(T.type==="snapshot"&&"data"in T&&T.data)j(A=>({...A??{},...T.data}));else if(T.type==="change")I().catch(()=>{});else if(T.type==="tasks:change"){const A=T.task;j(M=>{if(!M)return M;const F=(M.tasks||[]).map(V=>V.id===A.id?A:V),le=F.some(V=>V.id===A.id);return{...M,tasks:le?F:[A,...F]}})}else T.type==="tasks:delete"?j(A=>A&&{...A,tasks:(A.tasks||[]).filter(M=>M.id!==T.id)}):T.type==="settings:change"?T.settings&&u(T.settings):T.type==="project:change"||T.type==="agents:change"||T.type==="schedules:change"||T.type==="artifact:change"?I().catch(()=>{}):(T.type==="agent:status"||T.type==="agent:restarted")&&j(A=>{if(!A)return A;const M=(A.agents||[]).map(F=>F.name===T.agent.name?T.agent:F);return{...A,agents:M}})});return()=>{w(),h.close()}},[I,g]);const P=o.useCallback(h=>{(h==="activity"||h==="chat"||h==="tasks"||h==="settings"||h==="more")&&R(h)},[R]),f=o.useCallback((h,w,T)=>{if(h==="notification"){const A=ts({link:w||null,meta:T??null});A&&S(A);return}if(h==="task"&&w){S({id:"task-detail",taskId:w});return}if(h==="artifacts?"&&w){S({id:"artifacts?-detail",slug:w});return}if(h==="agent"&&w){S({id:"agent-detail",name:w});return}if(h==="project"){R("activity");return}h==="setting"&&R("settings")},[R,S]),L=()=>{if(!a||!v)return null;if(n.length>0){const h=n[n.length-1];switch(h.id){case"artifacts?":return e.jsx(zt,{snapshot:a,onBack:D,onOpenArtifact:w=>S({id:"artifacts?-detail",slug:w})});case"agents":return e.jsx(ze,{snapshot:a,onBack:D,onOpenAgent:w=>S({id:"agent-detail",name:w}),onRefresh:I});case"skills":return e.jsx(Yt,{snapshot:a,onBack:D});case"mods":return e.jsx(Ct,{snapshot:a,onBack:D});case"schedules":return e.jsx(Pt,{snapshot:a,onBack:D});case"history":return e.jsx(St,{onBack:D});case"config":return e.jsx(wt,{onBack:D});case"artifacts?-detail":return e.jsx(At,{slug:h.slug,onBack:D});case"agent-detail":return e.jsx(ze,{snapshot:a,onBack:D,onOpenAgent:()=>{},onRefresh:I,selectedAgent:h.name});case"task-detail":return e.jsx(Oe,{snapshot:a,onRefresh:I,selectedTaskId:h.taskId,onCloseDetail:D,onOpenChat:w=>{y(w),R("chat")}});default:return null}}switch(s){case"activity":return e.jsx(yt,{snapshot:a,onRefresh:I});case"chat":return e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"mobile-loading",children:e.jsx(ce,{size:"lg"})}),children:e.jsx(es,{snapshot:a,settings:v,initialTaskId:x,onClearTaskId:()=>y(null)})});case"tasks":return e.jsx(Oe,{snapshot:a,onRefresh:I,onOpenChat:h=>{y(h),R("chat")}});case"settings":return e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"mobile-loading",children:e.jsx(ce,{size:"lg"})}),children:e.jsx(Zt,{settings:v,snapshot:a,onRefresh:I})});case"more":return e.jsx(Tt,{snapshot:a,onNavigate:h=>{(h==="artifacts?"||h==="agents"||h==="skills"||h==="mods"||h==="schedules"||h==="history"||h==="config")&&S({id:h})}});default:return null}};return N?e.jsxs("div",{className:"mobile-loading",children:[e.jsx(ce,{size:"lg"}),e.jsx("p",{children:"Loading Bizar…"})]}):c||!a||!v?e.jsxs("div",{className:"mobile-loading",children:[e.jsx("h2",{children:"Dashboard unavailable"}),e.jsx("p",{children:c||"Dashboard server unreachable."}),e.jsx("p",{className:"muted",children:"Make sure the Bizar dashboard server is running."})]}):e.jsxs(e.Fragment,{children:[e.jsxs(gt,{activeTab:s,onTabChange:P,tabs:Ue,fullTabs:Ue,onExitSettings:()=>R("activity"),onSearch:()=>m(!0),children:[n.length>0&&e.jsx("button",{type:"button",className:"mobile-back-btn",onClick:D,"aria-label":"Go back",children:"← Back"}),L()]}),e.jsx(Ht,{open:i,onClose:()=>m(!1),onNavigate:f})]})}export{Se as A,ds as M,ce as S,We as W,He as _,C as a,is as b,X as c,Ee as d,cs as e,K as f,Te as g,Q as l,os as t,rs as w};
|