@polderlabs/bizar 5.0.2 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bizar-dash/dist/assets/MobileChat-TCputYzr.js +1 -0
- package/bizar-dash/dist/assets/MobileChat-TCputYzr.js.map +1 -0
- package/bizar-dash/dist/assets/MobileSettings-BxcbL5XT.js +1 -0
- package/bizar-dash/dist/assets/MobileSettings-BxcbL5XT.js.map +1 -0
- package/bizar-dash/dist/assets/{icons-Bo0iH9EC.js → icons-DRDXfbBP.js} +151 -136
- package/bizar-dash/dist/assets/icons-DRDXfbBP.js.map +1 -0
- package/bizar-dash/dist/assets/main-D5Ditnrd.js +19 -0
- package/bizar-dash/dist/assets/main-D5Ditnrd.js.map +1 -0
- package/bizar-dash/dist/assets/{main-DTkNlLrw.css → main-xFpWMd32.css} +1 -1
- package/bizar-dash/dist/assets/markdown-C6mXtQxD.js +1 -0
- package/bizar-dash/dist/assets/markdown-C6mXtQxD.js.map +1 -0
- package/bizar-dash/dist/assets/mobile--17fkfrl.js +1 -0
- package/bizar-dash/dist/assets/{mobile-DD-FZrTC.js.map → mobile--17fkfrl.js.map} +1 -1
- package/bizar-dash/dist/assets/mobile-j3rOZK6v.js +2 -0
- package/bizar-dash/dist/assets/mobile-j3rOZK6v.js.map +1 -0
- package/bizar-dash/dist/assets/{react-vendor-DZRUXSPQ.js → react-vendor-Dn4wqh4Z.js} +8 -8
- package/bizar-dash/dist/assets/react-vendor-Dn4wqh4Z.js.map +1 -0
- package/bizar-dash/dist/assets/useSlashCommands-BG-DhEck.js +2 -0
- package/bizar-dash/dist/assets/useSlashCommands-BG-DhEck.js.map +1 -0
- package/bizar-dash/dist/assets/vendor-CeHGtduv.js +29 -0
- package/bizar-dash/dist/assets/vendor-CeHGtduv.js.map +1 -0
- package/bizar-dash/dist/index.html +8 -6
- package/bizar-dash/dist/mobile.html +4 -5
- package/bizar-dash/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/bizar-dash/src/server/api.mjs +4 -0
- package/bizar-dash/src/server/eval.mjs +93 -3
- package/bizar-dash/src/server/metrics.mjs +75 -0
- package/bizar-dash/src/server/otel.mjs +141 -14
- package/bizar-dash/src/server/plugins/registry.mjs +145 -43
- package/bizar-dash/src/server/routes/chat.mjs +46 -9
- package/bizar-dash/src/server/routes/opencode-session-detail.mjs +120 -17
- package/bizar-dash/src/server/routes/plugins.mjs +131 -16
- package/bizar-dash/src/server/routes/tailscale.mjs +46 -0
- package/bizar-dash/src/server/routes/voice.mjs +42 -6
- package/bizar-dash/src/server/routes/workspaces.mjs +156 -61
- package/bizar-dash/src/server/server.mjs +57 -15
- package/bizar-dash/src/server/voice-store.mjs +27 -0
- package/bizar-dash/src/server/workers/transcription-worker.mjs +213 -0
- package/bizar-dash/src/web/App.tsx +9 -0
- package/bizar-dash/src/web/MobileApp.tsx +18 -10
- package/bizar-dash/src/web/components/EvalDiff.tsx +157 -0
- package/bizar-dash/src/web/components/EvalRunCard.tsx +78 -0
- package/bizar-dash/src/web/components/PluginCard.tsx +64 -0
- package/bizar-dash/src/web/components/PluginPermissions.tsx +36 -0
- package/bizar-dash/src/web/components/TailscaleSettings.tsx +161 -0
- package/bizar-dash/src/web/components/Toggle.tsx +31 -0
- package/bizar-dash/src/web/components/Topbar.tsx +6 -0
- package/bizar-dash/src/web/mobile/MobileChat.tsx +138 -0
- package/bizar-dash/src/web/mobile/MobileSettings.tsx +196 -0
- package/bizar-dash/src/web/styles/main.css +545 -0
- package/bizar-dash/src/web/views/Eval.tsx +172 -0
- package/bizar-dash/src/web/views/EvalReport.tsx +349 -0
- package/bizar-dash/src/web/views/Plugins.tsx +128 -0
- package/bizar-dash/src/web/views/Settings.tsx +2 -0
- package/bizar-dash/tests/bundle-analysis.test.mjs +5 -4
- package/bizar-dash/tests/cli-tailscale.test.mjs +113 -0
- package/bizar-dash/tests/components/plugin-permissions.test.tsx +95 -0
- package/bizar-dash/tests/eval/fixtures-extra.test.mjs +285 -0
- package/bizar-dash/tests/eval-web-ui.test.tsx +220 -0
- package/bizar-dash/tests/otel-spans.test.mjs +253 -0
- package/bizar-dash/tests/plugins-registry-fallback.test.mjs +259 -0
- package/bizar-dash/tests/voice-transcribe-worker.test.mjs +343 -0
- package/cli/bin.mjs +14 -0
- package/cli/commands/dash.mjs +19 -1
- package/cli/commands/service.mjs +7 -0
- package/cli/commands/tailscale.mjs +251 -0
- package/package.json +1 -1
- package/templates/eval-fixtures/citation.json +16 -0
- package/templates/eval-fixtures/code-review.json +16 -0
- package/templates/eval-fixtures/concise-output.json +16 -0
- package/templates/eval-fixtures/context-window.json +16 -0
- package/templates/eval-fixtures/error-recovery.json +16 -0
- package/templates/eval-fixtures/json-output.json +20 -0
- package/templates/eval-fixtures/multi-language.json +16 -0
- package/templates/eval-fixtures/safe-paths.json +16 -0
- package/templates/eval-fixtures/tool-call-multi-step.json +18 -0
- package/templates/eval-fixtures/unicode-handling.json +16 -0
- package/bizar-dash/dist/assets/icons-Bo0iH9EC.js.map +0 -1
- package/bizar-dash/dist/assets/index-DmpSFPJY.js +0 -9
- package/bizar-dash/dist/assets/index-DmpSFPJY.js.map +0 -1
- package/bizar-dash/dist/assets/main-C1cpttnv.js +0 -19
- package/bizar-dash/dist/assets/main-C1cpttnv.js.map +0 -1
- package/bizar-dash/dist/assets/markdown-DIquRulQ.js +0 -29
- package/bizar-dash/dist/assets/markdown-DIquRulQ.js.map +0 -1
- package/bizar-dash/dist/assets/mobile-BtxQJftK.js +0 -2
- package/bizar-dash/dist/assets/mobile-BtxQJftK.js.map +0 -1
- package/bizar-dash/dist/assets/mobile-DD-FZrTC.js +0 -1
- package/bizar-dash/dist/assets/react-vendor-DZRUXSPQ.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as E,t as p,u as b,V as O,a as M,v,b as P,c as d,g as j,d as N,e as T}from"./vendor-CeHGtduv.js";import{j as u}from"./react-vendor-Dn4wqh4Z.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-C6mXtQxD.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]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{M as r}from"./mobile-j3rOZK6v.js";import{b as e,j as o,r as n}from"./react-vendor-Dn4wqh4Z.js";import"./icons-DRDXfbBP.js";const t=document.getElementById("root");if(!t)throw new Error("Root element #root not found");e(t).render(o.jsx(n.StrictMode,{children:o.jsx(r,{})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobile
|
|
1
|
+
{"version":3,"file":"mobile--17fkfrl.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';\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":"kIAMA,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-BxcbL5XT.js","assets/react-vendor-Dn4wqh4Z.js","assets/icons-DRDXfbBP.js","assets/MobileChat-TCputYzr.js","assets/useSlashCommands-BG-DhEck.js","assets/markdown-C6mXtQxD.js","assets/vendor-CeHGtduv.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Qe=Object.defineProperty;var Xe=(s,t,n)=>t in s?Qe(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var U=(s,t,n)=>Xe(s,typeof t!="symbol"?t+"":t,n);import{j as e,r as i,R as Me}from"./react-vendor-Dn4wqh4Z.js";import{X as ee,y as xe,bd as Ze,d as et,Q as tt,aa as X,aq as st,R as q,B as te,g as ce,s as B,a1 as at,Y as se,a8 as nt,p as V,aG as it,l as re,Z as Pe,K as W,k as de,aS as Oe,e as je,a4 as Ue,M as Y,ac as ge,be as lt,S as Z,q as ve,b as ot,i as ye,x as ct,bf as rt}from"./icons-DRDXfbBP.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const b of u.addedNodes)b.tagName==="LINK"&&b.rel==="modulepreload"&&r(b)}).observe(document,{childList:!0,subtree:!0});function n(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function r(l){if(l.ep)return;l.ep=!0;const u=n(l);fetch(l.href,u)}})();function Be(...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 cs(s){if(!s)return"";const t=typeof s=="number"?new Date(s):new Date(s);return Number.isNaN(t.getTime())?"":t.toLocaleString()}function rs(s,t=160){return s?s.length>t?s.slice(0,t)+"…":s:""}const dt={low:"var(--text-dim)",normal:"var(--info)",high:"var(--error)"},Q="bizar-auth-token",Ne="bizar-loopback-trusted";class ke extends Error{constructor(n,r,l){super(n);U(this,"status");U(this,"data");this.name="ApiError",this.status=r,this.data=l}}class mt{constructor(){U(this,"base","/api")}getToken(){try{return localStorage.getItem(Q)||""}catch{return""}}setToken(t){try{t?localStorage.setItem(Q,t):localStorage.removeItem(Q)}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(),l=r?`${window.location.pathname}?${r}`:window.location.pathname;return history.replaceState(null,"",l),!0}catch{return!1}}urlWithToken(t){const n=this.base+t,r=this.getToken();if(!r)return n;const l=n.includes("?")?"&":"?";return`${n}${l}token=${encodeURIComponent(r)}`}async probeAuthStatus(){try{const t=await this.get("/auth/status");try{localStorage.setItem(Ne,t.loopback?"1":"0")}catch{}return t}catch{return{required:!1,loopback:!0,peer:""}}}isLoopbackTrusted(){try{return localStorage.getItem(Ne)!=="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,l){const u={"Content-Type":"application/json"},b=this.getToken();b&&(u.Authorization=`Bearer ${b}`);const c={method:t,headers:u};r!=null&&(c.body=typeof r=="string"?r:JSON.stringify(r)),l&&(c.signal=l);const m=await fetch(this.base+n,c);if((m.headers.get("content-type")||"").includes("application/json")){const x=await m.json();if(!m.ok){const k=(x&&typeof x=="object"&&"message"in x?x.message:void 0)||`${t} ${n}: ${m.status}`;throw new ke(k,m.status,x)}return x}const a=await m.text();if(!m.ok)throw new ke(`${t} ${n}: ${m.status} — ${a.slice(0,200)}`,m.status,a);try{return JSON.parse(a)}catch{return a}}}const T=new mt;T.pickupTokenFromUrl();async function ds(s){return s}function ut(){if(typeof location>"u")return"ws://localhost/ws";const s=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`;let t="";try{t=localStorage.getItem(Q)||""}catch{}return t?`${s}?token=${encodeURIComponent(t)}`:s}class Fe{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??ut();let n;try{n=new WebSocket(t),this.ws=n}catch(r){console.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&&console.warn("[ws] error")}),n.addEventListener("message",r=>{let l;try{l=JSON.parse(r.data)}catch{console.warn("[ws] bad message");return}for(const u of this.handlers)try{u(l)}catch(b){console.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){console.error("[ws] status handler error:",r)}}}const ms=Object.freeze(Object.defineProperty({__proto__:null,Ws:Fe},Symbol.toStringTag,{value:"Module"}));function we(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 Se(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",Ce(s.accent,.12)),t.style.setProperty("--accent-border",Ce(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 Ce(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),l=r>>16&255,u=r>>8&255,b=r&255;return`rgba(${l}, ${u}, ${b}, ${t})`}function ie({size:s="md",className:t,label:n}){return e.jsx("span",{className:Be("spinner",`spinner-${s}`,t),role:"status","aria-label":n||"Loading"})}const ht="modulepreload",bt=function(s){return"/"+s},Te={},qe=function(t,n,r){let l=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const b=document.querySelector("meta[property=csp-nonce]"),c=(b==null?void 0:b.nonce)||(b==null?void 0:b.getAttribute("nonce"));l=Promise.allSettled(n.map(m=>{if(m=bt(m),m in Te)return;Te[m]=!0;const y=m.endsWith(".css"),a=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${a}`))return;const x=document.createElement("link");if(x.rel=y?"stylesheet":ht,y||(x.as="script"),x.crossOrigin="",x.href=m,c&&x.setAttribute("nonce",c),document.head.appendChild(x),y)return new Promise((k,h)=>{x.addEventListener("load",k),x.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${m}`)))})}))}function u(b){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=b,window.dispatchEvent(c),!c.defaultPrevented)throw b}return l.then(b=>{for(const c of b||[])c.status==="rejected"&&u(c.reason);return t().catch(u)})};function pt({tabs:s,activeTab:t,onChange:n}){return e.jsx("nav",{className:"mobile-bottom-nav",role:"navigation","aria-label":"Mobile navigation",children:s.map(r=>{const l=r.icon;return e.jsxs("button",{type:"button",className:Be("mobile-nav-btn",t===r.id&&"mobile-nav-btn-active"),onClick:()=>n(r.id),"aria-label":r.label,"aria-current":t===r.id?"page":void 0,children:[e.jsx(l,{size:22}),e.jsx("span",{className:"mobile-nav-label",children:r.label})]},r.id)})})}function F({open:s,onClose:t,title:n,children:r,actions:l,maxHeight:u="85vh"}){const b=i.useRef(null),c=i.useRef(null),m=i.useId(),y=i.useRef(null),a=i.useRef(null),x=i.useRef(0),k=i.useRef(0),h=()=>{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(i.useEffect(()=>{if(!s)return;y.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const p=j=>{var P;if(j.key==="Escape"&&t(),j.key!=="Tab")return;const A=Array.from(h());if(A.length===0){j.preventDefault(),(P=b.current)==null||P.focus();return}const S=A[0],R=A[A.length-1],z=document.activeElement;if(j.shiftKey){(!z||z===S||z===b.current)&&(j.preventDefault(),R==null||R.focus());return}z===R&&(j.preventDefault(),S==null||S.focus())};return window.addEventListener("keydown",p),requestAnimationFrame(()=>{var j,A;((j=c.current)==null?void 0:j.focus())??((A=b.current)==null||A.focus())}),()=>{var j;window.removeEventListener("keydown",p),(j=y.current)==null||j.focus()}},[s,t]),i.useEffect(()=>(s?(k.current=window.scrollY,document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${k.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,k.current)}),[s]),!s)return null;const d=p=>{var j;p.isPrimary&&(a.current=p.clientY,x.current=0,(j=b.current)==null||j.setPointerCapture(p.pointerId))},o=p=>{if(a.current==null||!b.current)return;const j=Math.max(0,p.clientY-a.current);x.current=j,b.current.style.transform=`translateY(${j}px)`},N=p=>{if(!b.current)return;p&&b.current.hasPointerCapture(p.pointerId)&&b.current.releasePointerCapture(p.pointerId);const j=x.current;b.current.style.transform="",a.current=null,x.current=0,j>72&&t()};return e.jsx("div",{className:"mobile-sheet-overlay",onClick:t,children:e.jsxs("div",{ref:b,className:"mobile-sheet",style:{maxHeight:u},onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":!0,"aria-label":n?void 0:"Sheet","aria-labelledby":n?m:void 0,tabIndex:-1,children:[e.jsx("div",{className:"mobile-sheet-handle",onPointerDown:d,onPointerMove:o,onPointerUp:N,onPointerCancel:N,"aria-hidden":"true"}),e.jsxs("div",{className:"mobile-sheet-header",children:[n?e.jsx("h3",{id:m,className:"mobile-sheet-title",children:n}):e.jsx("div",{}),e.jsx("button",{ref:c,type:"button",className:"mobile-icon-btn",onClick:t,"aria-label":"Close",children:e.jsx(ee,{size:18})})]}),e.jsx("div",{className:"mobile-sheet-content",children:r}),l&&e.jsx("div",{className:"mobile-sheet-actions",children:l})]})})}function ft(s){switch(s){case"success":return"✓";case"error":return"✗";case"warning":return"⚠";default:return"ℹ"}}function xt(s){const t=new Date(s),r=Date.now()-t.getTime();return r<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:t.toLocaleDateString()}function jt({onSelect:s}){const[t,n]=i.useState(!1),[r,l]=i.useState([]),[u,b]=i.useState(0),c=async()=>{var a;try{const x=await T.get("/notifications");l(x.notifications||[]),b(((a=x.stats)==null?void 0:a.unread)||0)}catch{}};i.useEffect(()=>{c()},[]),i.useEffect(()=>{t&&c()},[t]);const m=async()=>{try{await T.post("/notifications/read-all"),l(a=>a.map(x=>({...x,read:!0}))),b(0)}catch{}},y=async a=>{try{await T.post(`/notifications/${encodeURIComponent(a)}/read`),l(x=>x.map(k=>k.id===a?{...k,read:!0}:k)),b(x=>Math.max(0,x-1))}catch{}};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"mobile-icon-btn mobile-notif-btn",onClick:()=>n(!0),"aria-label":`Notifications${u>0?` (${u} unread)`:""}`,children:[e.jsx(xe,{size:20}),u>0&&e.jsx("span",{className:"mobile-notif-badge",children:u>9?"9+":u})]}),e.jsx(F,{open:t,onClose:()=>n(!1),title:"Notifications",actions:u>0?e.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",style:{width:"100%"},onClick:m,children:[e.jsx(Ze,{size:14})," Mark all read"]}):void 0,children:e.jsxs("div",{className:"mobile-notif-list",children:[r.length===0&&e.jsxs("div",{className:"mobile-empty",children:[e.jsx(xe,{size:32}),e.jsx("p",{children:"No notifications"})]}),r.map(a=>e.jsxs("button",{type:"button",className:`mobile-notif-item ${a.read?"read":"unread"}`,onClick:()=>{a.read||y(a.id),s(a),n(!1)},children:[e.jsx("span",{className:`mobile-notif-icon severity-${a.severity}`,children:ft(a.severity)}),e.jsxs("div",{className:"mobile-notif-body",children:[e.jsx("span",{className:"mobile-notif-title",children:a.title||a.message}),a.message&&a.title&&e.jsx("span",{className:"mobile-notif-text",children:a.message}),e.jsx("span",{className:"mobile-notif-time",children:xt(a.ts)})]}),!a.read&&e.jsx("span",{className:"mobile-notif-dot"})]},a.id))]})})]})}const gt={activity:"Activity",chat:"Chat",tasks:"Tasks",settings:"Settings",more:"More",plans:"Plans",agents:"Agents",skills:"Skills",mods:"Mods",schedules:"Schedules",history:"History",config:"Config","plan-detail":"Plan","agent-detail":"Agent","task-detail":"Task"};function vt({activeTab:s,snapshot:t,onSearch:n,onNavigate:r}){const[l,u]=i.useState(!1),b=async c=>{try{await T.post(`/projects/${encodeURIComponent(c)}/activate`),u(!1),window.location.reload()}catch{}};return e.jsxs("header",{className:"mobile-topbar",children:[e.jsxs("div",{className:"mobile-topbar-left",children:[e.jsx("span",{className:"mobile-logo",children:"ᛒ"}),(t==null?void 0:t.activeProject)&&e.jsxs("button",{type:"button",className:"mobile-project-btn",onClick:()=>u(!0),"aria-label":"Select project",children:[e.jsx("span",{className:"mobile-project-name",children:t.activeProject.name}),e.jsx(et,{size:14})]}),e.jsx("span",{className:"mobile-title",children:gt[s]||"Bizar"})]}),e.jsxs("div",{className:"mobile-topbar-right",children:[e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:n,"aria-label":"Search",children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.35-4.35"})]})}),e.jsx(jt,{onSelect:c=>{r("notification",c.link||"",c.meta??null)}}),(t==null?void 0:t.activeProject)&&e.jsx(F,{open:l,onClose:()=>u(!1),title:"Projects",children:e.jsx("div",{className:"mobile-project-list",children:(t.projects||[]).map(c=>{var m,y;return e.jsxs("button",{type:"button",className:`mobile-project-item ${c.id===((m=t.activeProject)==null?void 0:m.id)?"active":""}`,onClick:()=>b(c.id),children:[e.jsx("div",{className:"mobile-project-status","data-status":c.status}),e.jsxs("div",{className:"mobile-project-info",children:[e.jsx("span",{className:"mobile-project-item-name",children:c.name}),e.jsx("span",{className:"mobile-project-item-path",children:c.path})]}),c.id===((y=t.activeProject)==null?void 0:y.id)&&e.jsx("span",{className:"mobile-active-badge",children:"active"})]},c.id)})})})]})]})}const yt=["all","tasks","agents","bg","artifacts","mods"],le={all:"All",tasks:"Tasks",agents:"Agents",bg:"Background",artifacts:"Plans",mods:"Mods"};function Nt({snapshot:s,onRefresh:t}){var D;const[n,r]=i.useState(((D=s.overview)==null?void 0:D.recentActivity)||[]),[l,u]=i.useState(!0),[b,c]=i.useState("all"),[m,y]=i.useState(!1),[a,x]=i.useState(null),[k,h]=i.useState(""),[d,o]=i.useState(!1);i.useEffect(()=>{var f;(f=s.overview)!=null&&f.recentActivity?(r(s.overview.recentActivity),u(!1)):N()},[s.overview]);const N=async()=>{var f;try{const v=await T.get("/snapshot");r(((f=v.overview)==null?void 0:f.recentActivity)||[])}catch{}finally{u(!1)}},p=b==="all"?n:n.filter(f=>{var v,g,C,E,I,O;return b==="tasks"?(v=f.kind)==null?void 0:v.startsWith("task"):b==="agents"?(g=f.kind)==null?void 0:g.startsWith("agent"):b==="bg"?((C=f.kind)==null?void 0:C.includes("bg"))||((E=f.kind)==null?void 0:E.includes("schedule")):b==="artifacts"?(I=f.kind)==null?void 0:I.includes("artifacts"):b==="mods"?(O=f.kind)==null?void 0:O.includes("mod"):!0}),j=s.agents||[],A=s.tasks||[],S=A.filter(f=>f.status==="doing"||f.status==="queued"),R=A.filter(f=>f.status==="done"),z=async()=>{if(!(!k.trim()||d)){o(!0);try{await T.post("/chat",{message:k.trim(),agent:"odin"}),h(""),await t().catch(()=>{}),await N()}catch{}finally{o(!1)}}},P=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:k,onChange:f=>h(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:()=>h(v=>v?`${v} ${f}`:f),children:f},f))}),e.jsxs("button",{type:"button",className:"mobile-btn",disabled:!k.trim()||d,onClick:z,children:[e.jsx(tt,{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:j.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:R.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"})]})]}),l&&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":m?"Resume":"Pause",children:m?e.jsx(X,{size:14}):e.jsx(st,{size:14})}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:P,"aria-label":"Refresh",children:e.jsx(q,{size:14})})]})]}),e.jsx("div",{className:"mobile-search-scopes",children:yt.map(f=>e.jsx("button",{type:"button",className:`mobile-scope-chip ${b===f?"active":""}`,onClick:()=>c(f),children:le[f]},f))}),j.length>0&&e.jsxs("section",{className:"mobile-section",children:[e.jsxs("h3",{className:"mobile-section-title",children:[e.jsx(te,{size:14})," Agents"]}),e.jsx("div",{className:"mobile-card-list",children:j.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))})]}),!m&&p.length>0&&e.jsx("section",{className:"mobile-section",children:e.jsx("div",{className:"mobile-card-list",children:p.slice(0,30).map((f,v)=>e.jsxs("button",{type:"button",className:"mobile-event-item",onClick:()=>x(f),children:[e.jsx("span",{className:"mobile-event-kind","data-kind":f.kind,children:le[f.kind]||f.kind}),e.jsx("span",{className:"mobile-event-msg",children:kt(f)}),e.jsx("span",{className:"mobile-event-time",children:K(f.ts)})]},`${f.ts}-${f.kind}-${v}`))})}),!m&&p.length===0&&n.length>0&&e.jsxs("div",{className:"mobile-empty",children:[e.jsx(ce,{size:40}),e.jsx("p",{children:"No matching activity."}),e.jsx("p",{className:"muted",children:"Try a different filter."})]}),a&&e.jsx(F,{open:!0,onClose:()=>x(null),title:le[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,v])=>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 v=="object"?JSON.stringify(v):String(v)})]},f))]})}),j.length===0&&S.length===0&&e.jsxs("div",{className:"mobile-empty",children:[e.jsx(ce,{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 kt(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 _({open:s,onClose:t,title:n,children:r,actions:l}){const u=i.useRef(null),b=i.useRef(null),c=i.useRef(null),m=i.useId(),y=i.useRef(0);return i.useEffect(()=>{if(!s)return;c.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"])',x=k=>{var p,j;if(k.key==="Escape"&&t(),k.key!=="Tab")return;const h=Array.from(((p=u.current)==null?void 0:p.querySelectorAll(a))??[]);if(h.length===0){k.preventDefault(),(j=u.current)==null||j.focus();return}const d=h[0],o=h[h.length-1],N=document.activeElement;if(k.shiftKey){(!N||N===d||N===u.current)&&(k.preventDefault(),o==null||o.focus());return}N===o&&(k.preventDefault(),d==null||d.focus())};return window.addEventListener("keydown",x),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 k,h;((k=b.current)==null?void 0:k.focus())??((h=u.current)==null||h.focus())}),()=>{var k;window.removeEventListener("keydown",x),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),(k=c.current)==null||k.focus()}},[s,t]),s?e.jsx("div",{className:"mobile-modal-overlay",onClick:a=>{a.target===a.currentTarget&&t()},children:e.jsxs("div",{ref:u,className:"mobile-modal",onClick:a=>a.stopPropagation(),role:"dialog","aria-modal":!0,"aria-label":n?void 0:"Modal","aria-labelledby":n?m:void 0,tabIndex:-1,children:[e.jsxs("div",{className:"mobile-modal-header",children:[n?e.jsx("h2",{id:m,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(ee,{size:20})})]}),e.jsx("div",{className:"mobile-modal-content",children:r}),l&&e.jsx("div",{className:"mobile-modal-actions",children:l})]})}):null}const _e=["reasoning","code","design","planning","gitops","analysis"],Ae={reasoning:"var(--accent)",code:"var(--info)",design:"var(--success)",planning:"var(--warning)",gitops:"var(--error)",analysis:"var(--text-dim)"};function Ee({snapshot:s,onBack:t,onOpenAgent:n,selectedAgent:r,onRefresh:l}){const[u,b]=i.useState(s.agents||[]),[c,m]=i.useState(!s.agents),[y,a]=i.useState(""),[x,k]=i.useState(""),[h,d]=i.useState(null),[o,N]=i.useState(!1),[p,j]=i.useState(""),[A,S]=i.useState(!1);i.useEffect(()=>{if(r){const g=u.find(C=>C.name===r);g&&d(g)}},[r,u]);const R=async()=>{try{const g=await T.get("/agents");b(g.agents||[])}catch{}finally{m(!1)}},z=u.filter(g=>{if(y&&g.category!==y)return!1;if(x){const C=x.toLowerCase();if(!g.name.toLowerCase().includes(C)&&!(g.description||"").toLowerCase().includes(C))return!1}return!0}),P=async(g,C)=>{try{await T.post(`/agents/${encodeURIComponent(g)}/invoke`,{prompt:C}),S(!1),j("")}catch{}},D=async g=>{try{await T.post(`/agents/${encodeURIComponent(g)}/restart`),await R()}catch{}},f=async g=>{if(confirm(`Delete agent "${g}"?`))try{await T.del(`/agents/${encodeURIComponent(g)}`),b(C=>C.filter(E=>E.name!==g)),d(null),l==null||l()}catch{}},v=async g=>{try{const C=await T.post("/agents",g);b(E=>[...E,C]),N(!1),l==null||l()}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:x,onChange:g=>k(g.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>R(),"aria-label":"Refresh",children:e.jsx(q,{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"}),_e.map(g=>e.jsx("button",{type:"button",className:`mobile-scope-chip ${y===g?"active":""}`,onClick:()=>a(g),children:g},g))]}),c?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading…"})}):z.length===0?e.jsxs("div",{className:"mobile-empty",children:[e.jsx(te,{size:40}),e.jsx("p",{children:"No agents found."})]}):e.jsx("div",{className:"mobile-card-list",children:z.map(g=>e.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>{d(g),n(g.name)},children:[e.jsx("div",{className:"mobile-agent-dot","data-status":g.status||"idle"}),e.jsxs("div",{className:"mobile-list-content",children:[e.jsx("span",{className:"mobile-list-title",children:g.name}),e.jsx("span",{className:"mobile-list-meta",children:g.model||g.mode||"—"})]}),g.category&&e.jsx("span",{className:"mobile-list-badge",style:{color:Ae[g.category]||"var(--text-dim)"},children:g.category}),e.jsx("span",{className:"mobile-list-badge","data-status":g.status||"idle",children:g.status||"idle"})]},g.name))}),h&&e.jsx(F,{open:!0,onClose:()=>d(null),title:h.name,actions:e.jsxs("div",{className:"mobile-task-detail-actions",children:[e.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>{j(""),S(!0)},children:[e.jsx(X,{size:14})," Invoke"]}),(h.isStuck||h.status==="error"||h.status==="working")&&e.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>D(h.name),children:[e.jsx(at,{size:14})," Restart"]}),e.jsx("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>f(h.name),children:e.jsx(se,{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":h.status||"idle"}),e.jsx("span",{className:"mobile-agent-detail-status-text",children:h.status||"idle"}),h.category&&e.jsx("span",{className:"mobile-list-badge",style:{color:Ae[h.category]},children:h.category})]}),e.jsx("p",{className:"mobile-agent-detail-desc",children:h.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:h.model||"—"})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Mode"}),e.jsx("span",{children:h.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:h.path})]}),h.lastError&&e.jsxs("div",{className:"mobile-task-detail-row",style:{color:"var(--error)"},children:[e.jsx("span",{children:"Last error"}),e.jsx("span",{children:h.lastError.message})]}),h.tasksTotal!=null&&h.tasksTotal>0&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Success rate"}),e.jsxs("span",{children:[Math.round((h.successRate||0)*100),"%"]})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Last modified"}),e.jsx("span",{children:K(h.mtime)})]})]})]})}),e.jsxs(_,{open:A,onClose:()=>S(!1),title:`Invoke ${h==null?void 0:h.name}`,actions:e.jsxs("button",{type:"button",className:"mobile-btn",style:{width:"100%"},disabled:!p.trim(),onClick:()=>{h&&P(h.name,p.trim())},children:[e.jsx(X,{size:14})," Invoke"]}),children:[e.jsxs("p",{className:"muted",style:{marginBottom:12},children:["Model: ",e.jsx("span",{className:"mono",children:(h==null?void 0:h.model)||"—"})]}),e.jsx("textarea",{className:"mobile-input",rows:5,placeholder:"What should this agent do?",value:p,onChange:g=>j(g.target.value),autoFocus:!0})]}),e.jsx(wt,{open:o,onClose:()=>N(!1),onCreate:v})]})}function wt({open:s,onClose:t,onCreate:n}){const[r,l]=i.useState(""),[u,b]=i.useState(""),[c,m]=i.useState(""),[y,a]=i.useState("subagent"),[x,k]=i.useState("#8b5cf6"),[h,d]=i.useState(""),[o,N]=i.useState(""),[p,j]=i.useState(""),A=S=>{S.preventDefault(),r.trim()&&(n({name:r.trim(),description:u.trim(),model:c,mode:y,color:x,tools:[],tags:o.split(",").map(R=>R.trim()).filter(Boolean),category:h,prompt:p}),l(""),b(""),m(""),a("subagent"),k("#8b5cf6"),d(""),N(""),j(""))};return e.jsx(_,{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:A,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=>l(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:u,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:c,onChange:S=>m(S.target.value)}),e.jsx("label",{className:"mobile-field-label",children:"Category"}),e.jsxs("select",{className:"mobile-input",value:h,onChange:S=>d(S.target.value),children:[e.jsx("option",{value:"",children:"None"}),_e.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:o,onChange:S=>N(S.target.value)})]})})}function St({onBack:s}){const[t,n]=i.useState([]),[r,l]=i.useState(!0),[u,b]=i.useState({}),[c,m]=i.useState(!1),y=async()=>{try{const o=await T.get("/config"),N=Object.entries(o).map(([p,j])=>({key:p,value:j,type:a(j)}));n(N),b(Object.fromEntries(Object.entries(o).map(([p,j])=>[p,j])))}catch{}finally{l(!1)}};i.useEffect(()=>{y()},[]);const a=o=>typeof o=="boolean"?"boolean":typeof o=="number"?"number":typeof o=="string"?"string":Array.isArray(o)?"array":o&&typeof o=="object"?"object":"unknown",x=(o,N)=>{b(p=>({...p,[o]:N}))},k=async()=>{m(!0);try{await T.patch("/config",u),await y()}catch{}finally{m(!1)}},h=(o,N)=>{b(p=>({...p,[o]:N}))},d=o=>{const N=u[o.key];switch(o.type){case"boolean":return e.jsxs("label",{className:"mobile-toggle",children:[e.jsx("input",{type:"checkbox",checked:!!N,onChange:p=>x(o.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=>x(o.key,Number(p.target.value))});case"string":return e.jsx("input",{className:"mobile-input mobile-input-sm",type:"text",value:String(N??""),onChange:p=>x(o.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{x(o.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(q,{size:16})}),e.jsxs("button",{type:"button",className:"mobile-btn",disabled:c,onClick:()=>k(),children:[e.jsx(nt,{size:14})," ",c?"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(V,{size:40}),e.jsx("p",{children:"No config entries."})]}):e.jsx("div",{className:"mobile-config-list",children:t.map(o=>e.jsxs("div",{className:"mobile-config-row",children:[e.jsxs("div",{className:"mobile-config-key",children:[e.jsx("span",{className:"mono",children:o.key}),e.jsx("span",{className:"mobile-config-type",children:o.type})]}),e.jsx("div",{className:"mobile-config-value",children:d(o)}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>h(o.key,o.defaultValue),"aria-label":"Reset to default",title:"Reset",children:e.jsx(it,{size:14})})]},o.key))})]})}function Ct({onBack:s}){const[t,n]=i.useState([]),[r,l]=i.useState(!0),[u,b]=i.useState(null),[c,m]=i.useState(""),y=async()=>{try{const h=await T.get("/history");if(Array.isArray(h.history)){n(h.history);return}if(Array.isArray(h.projects)){const d=new Map;for(const o of h.events||[]){const N=o.projectId;if(!N)continue;const p=d.get(N);(!p||new Date(o.ts).getTime()>new Date(p.ts).getTime())&&d.set(N,o)}n(h.projects.map(o=>{const N=d.get(o.id);return{id:o.id,ts:o.lastAccessed||(N==null?void 0:N.ts)||new Date(0).toISOString(),agent:o.name,taskCount:o.tasks.total,summary:`${o.path} · ${o.tasks.done}/${o.tasks.total} done · ${o.plans} plan${o.plans===1?"":"s"}`,output:N?`${N.kind}${N.text?` — ${N.text}`:""}`:"No recent events."}}));return}n([])}catch{}finally{l(!1)}};i.useEffect(()=>{y()},[]);const a=h=>{if(!h)return"—";const d=Math.floor(h/1e3);if(d<60)return`${d}s`;const o=Math.floor(d/60),N=d%60;return`${o}m ${N}s`},x=h=>new Date(h).toLocaleString(),k=c.trim()?t.filter(h=>{const d=c.toLowerCase();return(h.agent||"session").toLowerCase().includes(d)||(h.summary||"").toLowerCase().includes(d)||(h.output||"").toLowerCase().includes(d)}):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:c,onChange:h=>m(h.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>y(),"aria-label":"Refresh",children:e.jsx(q,{size:16})})]}),r?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading…"})}):k.length===0?e.jsxs("div",{className:"mobile-empty",children:[e.jsx(re,{size:40}),e.jsx("p",{children:t.length===0?"No history yet.":"No matching sessions."})]}):e.jsx("div",{className:"mobile-card-list",children:k.map(h=>e.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>b(h),children:[e.jsx("div",{className:"mobile-list-icon",children:e.jsx(re,{size:16})}),e.jsxs("div",{className:"mobile-list-content",children:[e.jsx("span",{className:"mobile-list-title",children:h.agent||"Session"}),e.jsxs("span",{className:"mobile-list-meta",children:[x(h.ts),h.duration?` · ${a(h.duration)}`:"",h.taskCount?` · ${h.taskCount} tasks`:""]})]})]},h.id))}),u&&e.jsxs(F,{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:u.agent||"—"})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Started"}),e.jsx("span",{children:x(u.ts)})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Duration"}),e.jsx("span",{children:a(u.duration)})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Tasks"}),e.jsx("span",{children:u.taskCount||0})]})]}),u.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:u.summary})]}),u.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:[u.output.slice(0,1e3),u.output.length>1e3?"…":""]})]})]})]})}function Tt({snapshot:s,onBack:t}){const[n,r]=i.useState(s.mods||[]),[l,u]=i.useState(!s.mods),[b,c]=i.useState(""),[m,y]=i.useState("all"),[a,x]=i.useState(null),k=async()=>{try{const o=await T.get("/mods");r(o.mods||[])}catch{}finally{u(!1)}};i.useEffect(()=>{s.mods?(r(s.mods),u(!1)):k()},[s.mods]);const h=async(o,N)=>{try{await T.patch(`/mods/${encodeURIComponent(o)}`,{enabled:N}),r(p=>p.map(j=>j.id===o?{...j,enabled:N}:j)),(a==null?void 0:a.id)===o&&x(p=>p&&{...p,enabled:N})}catch{}},d=n.filter(o=>{if(m==="enabled"&&!o.enabled||m==="disabled"&&o.enabled)return!1;if(b){const N=b.toLowerCase();return o.name.toLowerCase().includes(N)||o.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:o=>c(o.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>k(),"aria-label":"Refresh",children:e.jsx(q,{size:16})})]}),e.jsx("div",{className:"mobile-search-scopes",children:["all","enabled","disabled"].map(o=>e.jsx("button",{type:"button",className:`mobile-scope-chip ${m===o?"active":""}`,onClick:()=>y(o),children:o.charAt(0).toUpperCase()+o.slice(1)},o))}),l?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading…"})}):d.length===0?e.jsxs("div",{className:"mobile-empty",children:[e.jsx(V,{size:40}),e.jsx("p",{children:"No mods found."})]}):e.jsx("div",{className:"mobile-card-list",children:d.map(o=>e.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>x(o),children:[e.jsx("div",{className:"mobile-list-icon",children:e.jsx(V,{size:16})}),e.jsxs("div",{className:"mobile-list-content",children:[e.jsx("span",{className:"mobile-list-title",children:o.name}),e.jsxs("span",{className:"mobile-list-meta",children:["v",o.version," · ",o.author]})]}),e.jsx("span",{className:`mobile-list-badge ${o.enabled?"badge-on":"badge-off"}`,children:o.enabled?"on":"off"})]},o.id))}),a&&e.jsx(F,{open:!0,onClose:()=>x(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&&h(a.id,!a.enabled)},children:[e.jsx(Pe,{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 At({snapshot:s,onNavigate:t}){var b,c,m;const[n,r]=i.useState(""),l=[{id:"artifacts",icon:W,label:"Plans",count:s.artifacts.length||0,desc:"Visual artifacts with elements & comments"},{id:"agents",icon:te,label:"Agents",count:((b=s.agents)==null?void 0:b.length)||0,desc:"The Norse pantheon"},{id:"skills",icon:V,label:"Skills",count:null,desc:"Agent capabilities & tools"},{id:"mods",icon:V,label:"Mods",count:((c=s.mods)==null?void 0:c.length)||0,desc:"Installed modifications"},{id:"schedules",icon:de,label:"Schedules",count:((m=s.schedules)==null?void 0:m.length)||0,desc:"Cron jobs & automated tasks"},{id:"history",icon:re,label:"History",count:null,desc:"Past sessions & outputs"},{id:"config",icon:Oe,label:"Config",count:null,desc:"Key-value configuration editor"}],u=n.trim()?l.filter(y=>y.label.toLowerCase().includes(n.toLowerCase())||y.desc.toLowerCase().includes(n.toLowerCase())):l;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:u.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(je,{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(je,{size:14})]})})]})}const me=[{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 oe(s){var t;return((t=me.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(Z,{size:t,style:{color:"var(--info)"}});case"note":return e.jsx(ge,{size:t,style:{color:"var(--text-dim)"}});case"decision":return e.jsx(Z,{size:t,style:{color:"var(--accent)"}});case"question":return e.jsx(lt,{size:t,style:{color:"var(--warning)"}});default:return e.jsx(ge,{size:t})}}function $t({slug:s,onBack:t}){const[n,r]=i.useState(null),[l,u]=i.useState(null),[b,c]=i.useState(!0),[m,y]=i.useState(!1),[a,x]=i.useState(null),[k,h]=i.useState(!1),[d,o]=i.useState(!1),[N,p]=i.useState(!1),[j,A]=i.useState(""),S=async()=>{c(!0);try{const f=await T.get(`/plans/${encodeURIComponent(s)}`);r(f.canvas),u(f.meta)}catch{}finally{c(!1)}};i.useEffect(()=>{S()},[s]);const R=async(f,v,g)=>{try{const C=((n==null?void 0:n.elements)||[]).reduce((I,O)=>Math.max(I,O.x||0),40),E=((n==null?void 0:n.elements)||[]).reduce((I,O)=>Math.max(I,O.y||0),40);await T.post(`/plans/${encodeURIComponent(s)}/elements`,{type:f,title:v,content:g,x:20+C,y:20+E,width:240,height:120}),await S(),o(!1)}catch{}},z=async(f,v)=>{try{await T.put(`/plans/${encodeURIComponent(s)}/elements/${encodeURIComponent(f)}`,v),await S(),x(null)}catch{}},P=async f=>{if(confirm("Delete this element?"))try{await T.del(`/plans/${encodeURIComponent(s)}/elements/${encodeURIComponent(f)}`),x(null),await S()}catch{}},D=async(f,v)=>{try{const g=v?`/plans/${encodeURIComponent(s)}/elements/${encodeURIComponent(v)}/comments`:`/plans/${encodeURIComponent(s)}/comments`;await T.post(g,{text:f,elementId:v}),await S(),A(""),p(!1)}catch{}};return b||!n||!l?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:l.title||s}),e.jsx("span",{className:"mobile-canvas-status","data-status":l.status,children:l.status})]}),e.jsxs("div",{className:"mobile-canvas-actions",children:[e.jsx("button",{type:"button",className:`mobile-icon-btn ${m?"active":""}`,onClick:()=>y(f=>!f),"aria-label":m?"Done editing":"Edit",children:e.jsx(Ue,{size:16})}),e.jsxs("button",{type:"button",className:"mobile-icon-btn",onClick:()=>h(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})]}),m&&e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>o(!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."}),m&&e.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>o(!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:oe(f.type)},onClick:()=>{m&&x(f)},"aria-pressed":(a==null?void 0:a.id)===f.id,children:[e.jsxs("div",{className:"mobile-canvas-el-header",style:{background:`${oe(f.type)}18`},children:[e.jsx(Et,{type:f.type,size:12}),e.jsx("span",{className:"mobile-canvas-el-type",style:{color:oe(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(v=>v.elementId===f.id).length]})]},f.id))]}),k&&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:()=>h(!1),children:e.jsx(ee,{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:j,onChange:f=>A(f.target.value)}),e.jsx("button",{type:"button",className:"mobile-btn",disabled:!j.trim(),onClick:()=>{D(j.trim(),null)},children:"Post"})]})]}),a&&e.jsx(F,{open:!0,onClose:()=>x(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:()=>P(a.id),children:[e.jsx(se,{size:14})," Delete"]}),e.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>p(!0),children:[e.jsx(Y,{size:14})," Comment"]})]}),children:e.jsx(Lt,{element:a,onSave:f=>z(a.id,f),onClose:()=>x(null)})}),e.jsx(zt,{open:d,onClose:()=>o(!1),onAdd:R}),e.jsx(_,{open:N,onClose:()=>p(!1),title:"Add Comment",actions:e.jsxs("button",{type:"button",className:"mobile-btn",style:{width:"100%"},disabled:!j.trim(),onClick:()=>{D(j.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:j,onChange:f=>A(f.target.value),autoFocus:!0})})]})}function Lt({element:s,onSave:t,onClose:n}){const[r,l]=i.useState(s.type),[u,b]=i.useState(s.title||""),[c,m]=i.useState(s.content||""),[y,a]=i.useState(s.status||"open");return e.jsxs("form",{className:"mobile-task-form",onSubmit:x=>{x.preventDefault(),t({type:r,title:u,content:c,status:y}),n()},children:[e.jsx("label",{className:"mobile-field-label",children:"Type"}),e.jsx("select",{className:"mobile-input",value:r,onChange:x=>l(x.target.value),children:me.map(x=>e.jsx("option",{value:x.id,children:x.label},x.id))}),e.jsx("label",{className:"mobile-field-label",children:"Title"}),e.jsx("input",{className:"mobile-input",type:"text",value:u,onChange:x=>b(x.target.value)}),e.jsx("label",{className:"mobile-field-label",children:"Status"}),e.jsx("input",{className:"mobile-input",type:"text",value:y,onChange:x=>a(x.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:c,onChange:x=>m(x.target.value)}),e.jsx("button",{type:"submit",className:"mobile-btn",style:{width:"100%",marginTop:8},children:"Save"})]})}function zt({open:s,onClose:t,onAdd:n}){const[r,l]=i.useState("task"),[u,b]=i.useState(""),[c,m]=i.useState(""),y=a=>{a.preventDefault(),u.trim()&&(n(r,u.trim(),c.trim()),b(""),m(""))};return e.jsx(_,{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=>l(a.target.value),children:me.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:u,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:c,onChange:a=>m(a.target.value)})]})})}function Rt({snapshot:s,onBack:t,onOpenArtifact:n}){const[r,l]=i.useState(s.artifacts||[]),[u,b]=i.useState(!s.artifacts),[c,m]=i.useState(""),[y,a]=i.useState(!1),[x,k]=i.useState(""),[h,d]=i.useState(""),o=async()=>{try{const j=await T.get("/artifacts");l(j.artifacts||[])}catch{}finally{b(!1)}},N=async()=>{if(x.trim())try{const j=await T.post("/artifacts",{slug:x.trim(),title:h.trim()||void 0});a(!1),k(""),d(""),n(j.slug)}catch{}},p=c.trim()?r.filter(j=>(j.title||j.slug||"").toLowerCase().includes(c.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:c,onChange:j=>m(j.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>o(),"aria-label":"Refresh",children:e.jsx(q,{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"]})}),u?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading…"})}):p.length===0?e.jsxs("div",{className:"mobile-empty",children:[e.jsx(W,{size:40}),e.jsx("p",{children:"No artifacts yet."})]}):e.jsx("div",{className:"mobile-card-list",children:p.map(j=>e.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>n(j.slug),children:[e.jsx("div",{className:"mobile-list-icon",children:e.jsx(W,{size:16})}),e.jsxs("div",{className:"mobile-list-content",children:[e.jsx("span",{className:"mobile-list-title",children:j.title||j.slug}),e.jsxs("span",{className:"mobile-list-meta",children:[j.status," · ",j.source,j.elementCount!=null?` · ${j.elementCount} elements`:"",j.commentCount!=null?` · ${j.commentCount} comments`:""]})]}),e.jsx("span",{className:"mobile-list-badge","data-status":j.status,children:j.status})]},j.slug))}),e.jsx(_,{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:j=>{j.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:x,onChange:j=>k(j.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:h,onChange:j=>d(j.target.value)})]})})]})}const It=["cron","interval","once"],Dt=["command","agent","webhook"],$e=["UTC","America/New_York","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Tokyo"],We=Array.from({length:24},(s,t)=>({value:t,label:t===0?"12 AM":t<12?`${t} AM`:t===12?"12 PM":`${t-12} PM`})),Mt=Array.from({length:12},(s,t)=>t*5),He=[{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"}],Pt=[{value:"s",label:"sec"},{value:"m",label:"min"},{value:"h",label:"hr"},{value:"d",label:"day"}];function Ot({snapshot:s}){var N;const[t,n]=i.useState(s.schedules||[]),[r,l]=i.useState(!s.schedules),[u,b]=i.useState(""),[c,m]=i.useState(null),[y,a]=i.useState({open:!1}),x=async()=>{try{const p=await T.get("/schedules");n(p.schedules||[])}catch{}finally{l(!1)}};i.useEffect(()=>{s.schedules?(n(s.schedules),l(!1)):x()},[s.schedules]);const k=async(p,j)=>{try{await T.patch(`/schedules/${encodeURIComponent(p)}`,{enabled:j}),n(A=>A.map(S=>S.id===p?{...S,enabled:j}:S)),(c==null?void 0:c.id)===p&&m(A=>A&&{...A,enabled:j})}catch{}},h=async p=>{if(confirm("Delete this schedule?"))try{await T.del(`/schedules/${encodeURIComponent(p)}`),n(j=>j.filter(A=>A.id!==p)),(c==null?void 0:c.id)===p&&m(null)}catch{}},d=async p=>{try{await T.post(`/schedules/${encodeURIComponent(p)}/trigger`)}catch{}},o=u.trim()?t.filter(p=>p.name.toLowerCase().includes(u.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:u,onChange:p=>b(p.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>x(),"aria-label":"Refresh",children:e.jsx(q,{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…"})}):o.length===0?e.jsxs("div",{className:"mobile-empty",children:[e.jsx(de,{size:40}),e.jsx("p",{children:"No schedules found."})]}):e.jsx("div",{className:"mobile-card-list",children:o.map(p=>e.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>m(p),children:[e.jsx("div",{className:"mobile-list-icon",children:e.jsx(de,{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:[Re(p)," ·"," ",p.nextRun?`next ${ze(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))}),c&&e.jsx(F,{open:!0,onClose:()=>m(null),title:c.name,actions:e.jsxs("div",{className:"mobile-task-detail-actions",children:[e.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>{c&&d(c.id)},children:[e.jsx(X,{size:14})," Trigger now"]}),e.jsx("button",{type:"button",className:`mobile-btn ${c.enabled?"mobile-btn-secondary":""}`,onClick:()=>{c&&k(c.id,!c.enabled)},children:c.enabled?"Disable":"Enable"}),e.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>{c&&(a({open:!0,initial:c}),m(null))},children:[e.jsx(Ue,{size:14})," Edit"]}),e.jsx("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>{c&&h(c.id)},children:e.jsx(se,{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:c.type})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Schedule"}),e.jsx("span",{className:"mono",children:Re(c)||c.schedule})]}),c.timezone&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Timezone"}),e.jsx("span",{className:"mono",children:c.timezone})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Action"}),e.jsxs("span",{children:[c.action.type,": ",c.action.target]})]}),c.action.type==="agent"&&c.action.prompt&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Prompt"}),e.jsx("span",{style:{fontSize:12},children:c.action.prompt})]}),((N=c.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 ≥ ",c.budgetCheck.maxConcurrent??6," concurrent"]})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Next run"}),e.jsx("span",{children:c.nextRun?ze(c.nextRun,c.timezone):"—"})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Last run"}),e.jsx("span",{children:c.lastRun?Ft(c.lastRun):"—"})]}),c.lastResult&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Last result"}),e.jsx("span",{style:{fontSize:12},children:c.lastResult})]}),c.lastError&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Last error"}),e.jsx("span",{style:{fontSize:12},children:c.lastError})]})]})})}),e.jsx(Bt,{open:y.open,initial:y.initial,onClose:()=>a({open:!1}),onSaved:()=>{a({open:!1}),x()}})]})}function Le(s){var r,l;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"?Ye(s.schedule):null,n=s.type==="interval"?qt(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"?_t(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((l=s.budgetCheck)==null?void 0:l.maxConcurrent)?s.budgetCheck.maxConcurrent:6,enabled:s.enabled!==!1}}function Ut(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 Bt({open:s,initial:t,onClose:n,onSaved:r}){const[l,u]=i.useState(()=>Le(t)),[b,c]=i.useState(!1);i.useEffect(()=>{s&&u(Le(t))},[s,t]);const m=(a,x)=>{u(k=>({...k,[a]:x}))},y=async a=>{if(a.preventDefault(),!l.name.trim())return;const x=Ut(l);if(x){c(!0);try{const k={name:l.name.trim(),type:l.type,schedule:x,timezone:l.timezone,action:{type:l.actionType,target:l.actionTarget.trim(),...l.actionType==="agent"&&l.actionPrompt.trim()?{prompt:l.actionPrompt.trim()}:{}},budgetCheck:{maxConcurrent:l.maxConcurrent,skipIfBudgetLow:l.skipIfBudgetLow},enabled:l.enabled};t?await T.put(`/schedules/${encodeURIComponent(t.id)}`,k):await T.post("/schedules",k),r()}catch{}finally{c(!1)}}};return e.jsx(_,{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:l.name,onChange:a=>m("name",a.target.value),autoFocus:!0,required:!0}),e.jsx("label",{className:"mobile-field-label",children:"Type"}),e.jsx("select",{className:"mobile-input",value:l.type,onChange:a=>m("type",a.target.value),children:It.map(a=>e.jsx("option",{value:a,children:a},a))}),l.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:l.cronDow,onChange:a=>m("cronDow",a.target.value),children:He.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(l.cronHour),onChange:a=>m("cronHour",parseInt(a.target.value,10)),children:We.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(l.cronMinute),onChange:a=>m("cronMinute",parseInt(a.target.value,10)),children:Mt.map(a=>e.jsx("option",{value:String(a),children:String(a).padStart(2,"0")},a))})]})]})]}),l.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:l.intervalN,onChange:a=>m("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:l.intervalUnit,onChange:a=>m("intervalUnit",a.target.value),children:Pt.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))})]})]}),l.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:l.onceAt,onChange:a=>m("onceAt",a.target.value)})]}),e.jsx("label",{className:"mobile-field-label",children:"Timezone"}),e.jsx("select",{className:"mobile-input",value:$e.includes(l.timezone)?l.timezone:"UTC",onChange:a=>m("timezone",a.target.value),children:$e.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:l.actionType,onChange:a=>m("actionType",a.target.value),children:Dt.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:l.actionType==="webhook"?"https://...":l.actionType==="agent"?"agent or task ref":"echo hello",value:l.actionTarget,onChange:a=>m("actionTarget",a.target.value)}),l.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:l.actionPrompt,onChange:a=>m("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:l.skipIfBudgetLow,onChange:a=>m("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:l.maxConcurrent,onChange:a=>m("maxConcurrent",parseInt(a.target.value,10)||6),disabled:!l.skipIfBudgetLow})]}),e.jsxs("label",{className:"mobile-checkbox-row",children:[e.jsx("input",{type:"checkbox",checked:l.enabled,onChange:a=>m("enabled",a.target.checked)}),e.jsx("span",{children:"Enabled"})]})]})})}function Ft(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 ze(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 Ye(s){if(typeof s!="string")return null;const t=s.trim().split(/\s+/);if(t.length!==5)return null;const[n,r,,,l]=t,u=parseInt(n,10),b=parseInt(r,10);return!Number.isFinite(u)||!Number.isFinite(b)||n!==String(u)||r!==String(b)?null:{minute:u,hour:b,dow:l==="*"?"*":Number.isFinite(parseInt(l,10))?l:"*"}}function qt(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 _t(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 Re(s){var u,b;if(s.type!=="cron")return s.schedule;const t=Ye(s.schedule);if(!t)return s.schedule;const n=((u=He.find(c=>c.value===t.dow))==null?void 0:u.label)||t.dow,r=((b=We.find(c=>c.value===t.hour))==null?void 0:b.label)||`${t.hour}`,l=String(t.minute).padStart(2,"0");return n==="Every day"?`Every day ${r} :${l}`:`Every ${n} ${r} :${l}`}const Wt=["all","tasks","agents","artifacts","projects","settings"],Ht={tasks:Z,agents:te,plans:W,projects:ot,settings:V};function Yt({open:s,onClose:t,onNavigate:n}){const[r,l]=i.useState(""),[u,b]=i.useState("all"),[c,m]=i.useState([]),[y,a]=i.useState(!1),x=i.useRef(null);i.useEffect(()=>{s&&(l(""),m([]),requestAnimationFrame(()=>{var d;return(d=x.current)==null?void 0:d.focus()}))},[s]),i.useEffect(()=>{if(!r.trim()){m([]);return}const d=setTimeout(async()=>{a(!0);try{const o=await T.get(`/search?q=${encodeURIComponent(r)}&scope=${u}`);m(o.results||[])}catch{m([])}finally{a(!1)}},250);return()=>clearTimeout(d)},[r,u]);const k=d=>{const o=d.item,N=o.id||o.slug||o.name||"";n(d.type,N),t()},h=c.reduce((d,o)=>(d[o.type]||(d[o.type]=[]),d[o.type].push(o),d),{});return e.jsx(_,{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(ve,{size:16,style:{color:"var(--text-muted)",flexShrink:0}}),e.jsx("input",{ref:x,className:"mobile-search-field",type:"text",placeholder:"Search…",value:r,onChange:d=>l(d.target.value),enterKeyHint:"search",onKeyDown:d=>{d.key==="Escape"&&t(),d.key==="Enter"&&c.length>0&&k(c[0])}}),r&&e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>l(""),"aria-label":"Clear",children:e.jsx(ee,{size:16})})]}),e.jsx("div",{className:"mobile-search-scopes",children:Wt.map(d=>e.jsx("button",{type:"button",className:`mobile-scope-chip ${u===d?"active":""}`,onClick:()=>b(d),children:d==="all"?"All":d.charAt(0).toUpperCase()+d.slice(1)},d))}),e.jsxs("div",{className:"mobile-search-results",children:[y&&e.jsx("div",{className:"mobile-search-loading",children:"Searching…"}),!y&&r&&c.length===0&&e.jsxs("div",{className:"mobile-empty",children:[e.jsx(ve,{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(h).map(([d,o])=>{const N=Ht[d]||W;return e.jsxs("div",{className:"mobile-search-group",children:[e.jsxs("h4",{className:"mobile-search-group-title",children:[e.jsx(N,{size:12})," ",d.charAt(0).toUpperCase()+d.slice(1)," (",o.length,")"]}),o.map((p,j)=>{const A=p.item;return e.jsxs("button",{type:"button",className:"mobile-search-result-item",onClick:()=>k(p),children:[e.jsx("span",{className:"mobile-search-result-title",children:A.title||A.name||A.slug||"(unnamed)"}),A.description&&e.jsx("span",{className:"mobile-search-result-meta",children:A.description.slice(0,80)})]},j)})]},d)})]})]})})}const Kt=["languages","framework","design","testing","devops","data","security","integration"];function Vt({snapshot:s,onBack:t}){const[n,r]=i.useState([]),[l,u]=i.useState(!0),[b,c]=i.useState(""),[m,y]=i.useState(""),[a,x]=i.useState(null),k=async()=>{try{const o=await T.get("/skills");r(o.skills||[])}catch{}finally{u(!1)}};i.useEffect(()=>{k()},[]);const h=async(o,N)=>{try{await T.patch(`/skills/${encodeURIComponent(o)}`,{enabled:N}),r(p=>p.map(j=>j.id===o?{...j,enabled:N}:j)),(a==null?void 0:a.id)===o&&x(p=>p&&{...p,enabled:N})}catch{}},d=n.filter(o=>{if(m&&o.category!==m)return!1;if(b){const N=b.toLowerCase();return o.name.toLowerCase().includes(N)||o.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:o=>c(o.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>k(),"aria-label":"Refresh",children:e.jsx(q,{size:16})})]}),e.jsxs("div",{className:"mobile-search-scopes",children:[e.jsx("button",{type:"button",className:`mobile-scope-chip ${m?"":"active"}`,onClick:()=>y(""),children:"All"}),Kt.map(o=>e.jsx("button",{type:"button",className:`mobile-scope-chip ${m===o?"active":""}`,onClick:()=>y(o),children:o},o))]}),l?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading…"})}):d.length===0?e.jsxs("div",{className:"mobile-empty",children:[e.jsx(ye,{size:40}),e.jsx("p",{children:"No skills found."})]}):e.jsx("div",{className:"mobile-card-list",children:d.map(o=>e.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>x(o),children:[e.jsx("div",{className:"mobile-list-icon",children:e.jsx(ye,{size:16})}),e.jsxs("div",{className:"mobile-list-content",children:[e.jsx("span",{className:"mobile-list-title",children:o.name}),e.jsxs("span",{className:"mobile-list-meta",children:[o.category," · v",o.version]})]}),e.jsx("span",{className:`mobile-list-badge ${o.enabled?"badge-on":"badge-off"}`,children:o.enabled?"on":"off"})]},o.id))}),a&&e.jsx(F,{open:!0,onClose:()=>x(null),title:a.name,actions:e.jsxs("button",{type:"button",className:`mobile-btn ${a.enabled?"mobile-btn-secondary":""}`,style:{width:"100%"},onClick:()=>{a&&h(a.id,!a.enabled)},children:[e.jsx(Pe,{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 Jt=["queued","doing","blocked","done"],G={queued:"Queued",doing:"Doing",blocked:"Blocked",done:"Done"},Ie={queued:"doing",doing:"done",blocked:"queued",done:"queued"};function Gt(s){const t=s.metadata??{};return!!(t.sessionId||t.bgInstanceId)}function Qt(s){var n;const t=s.metadata??{};return!!((n=t.artifactIds)!=null&&n.length||t.artifactId)}function De({snapshot:s,onRefresh:t,selectedTaskId:n,onCloseDetail:r,onOpenChat:l,onOpenArtifact:u}){var pe,fe;const[b,c]=i.useState(s.tasks||[]),[m,y]=i.useState(!s.tasks),[a,x]=i.useState(""),[k,h]=i.useState("queued"),[d,o]=i.useState(null),[N,p]=i.useState(!1),[j,A]=i.useState(null),[S,R]=i.useState([]),[z,P]=i.useState(""),[D,f]=i.useState(null),[v,g]=i.useState(!1),[C,E]=i.useState(""),[I,O]=i.useState("updated");i.useEffect(()=>{var w;if(s.tasks&&(c(s.tasks),y(!1)),n){const L=(w=s.tasks)==null?void 0:w.find($=>$.id===n);L&&o(L)}},[s.tasks,n]),i.useEffect(()=>{if(n){const w=b.find(L=>L.id===n);w&&o(w)}},[n,b]);const J=async()=>{try{const w=await T.get("/tasks");c(Array.isArray(w)?w:[])}catch{}finally{y(!1)}},H=async(w,L)=>{c($=>$.map(M=>M.id===w?{...M,status:L}:M)),(d==null?void 0:d.id)===w&&o($=>$&&{...$,status:L});try{await T.patch(`/tasks/${encodeURIComponent(w)}/status`,{status:L})}catch{await J()}},Ke=async w=>{if(confirm("Delete this task?"))try{await T.del(`/tasks/${encodeURIComponent(w)}`),c(L=>L.filter($=>$.id!==w)),(d==null?void 0:d.id)===w&&o(null)}catch{await J()}},Ve=async w=>{try{await T.post(`/tasks/${encodeURIComponent(w)}/archive`),c(L=>L.filter($=>$.id!==w)),(d==null?void 0:d.id)===w&&o(null)}catch{}},ue=[...b.filter(w=>{var L,$;if(a.trim()){const M=a.toLowerCase();if(!(w.title||"").toLowerCase().includes(M)&&!(w.description||"").toLowerCase().includes(M))return!1}if(C.trim()){const M=C==="mine"?(($=(L=s.settings)==null?void 0:L.data)==null?void 0:$.defaultAgent)||Xt(s):C.replace(/^@/,"");if((w.assignee||"").toLowerCase()!==M.toLowerCase())return!1}return!0})].sort((w,L)=>{switch(I){case"priority":{const $={high:0,normal:1,low:2};return($[w.priority]??1)-($[L.priority]??1)}case"created":return new Date(L.createdAt).getTime()-new Date(w.createdAt).getTime();case"updated":default:return new Date(L.updatedAt).getTime()-new Date(w.updatedAt).getTime()}}),he=ue.filter(w=>w.status===k),be=s.agents||[],Je=async(w,L,$,M)=>{try{const ae=await T.post("/tasks",{title:w,description:L,assignee:$||null,priority:M});c(ne=>[ae,...ne]),p(!1)}catch{}},Ge=async w=>{g(!0),P(""),f(null),A(w);try{const $=((await T.get(`/tasks/${encodeURIComponent(w)}/artifacts`)).artifacts||[]).map(M=>M.id);if(R($),$.length>0){const[M,ae]=await Promise.all([T.get(`/artifacts/${encodeURIComponent($[0])}`),fetch(T.urlWithToken(`/artifacts/${encodeURIComponent($[0])}/content`)).then(ne=>ne.text())]);f(M),P(ae)}}catch{}finally{g(!1)}};return m?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:w=>x(w.target.value),style:{flex:1}}),e.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>J(),"aria-label":"Refresh",children:e.jsx(q,{size:16})})]}),e.jsxs("div",{className:"mobile-tasks-filters",children:[e.jsxs("select",{className:"mobile-filter-select",value:C,onChange:w=>E(w.target.value),children:[e.jsx("option",{value:"",children:"All"}),e.jsx("option",{value:"mine",children:"Mine"}),be.map(w=>e.jsxs("option",{value:`@${w.name}`,children:["@",w.name]},w.name))]}),e.jsxs("select",{className:"mobile-filter-select",value:I,onChange:w=>O(w.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:Jt.map(w=>{const L=ue.filter($=>$.status===w).length;return e.jsxs("button",{type:"button",className:`mobile-kanban-tab ${k===w?"active":""}`,onClick:()=>h(w),children:[G[w]," (",L,")"]},w)})}),e.jsxs("div",{className:"mobile-card-list",children:[he.length===0&&e.jsxs("div",{className:"mobile-empty mobile-empty-compact",children:[e.jsxs("p",{children:["No ",G[k].toLowerCase()," tasks."]}),e.jsx("p",{className:"muted",children:"Create one or switch columns."})]}),he.map(w=>{var L;return e.jsxs("button",{type:"button",className:"mobile-task-card",onClick:()=>o(w),children:[e.jsx("div",{className:"priority-dot",style:{background:dt[w.priority]||"var(--info)"}}),e.jsxs("div",{className:"task-content",children:[e.jsx("div",{className:"task-title",children:w.title}),e.jsxs("div",{className:"task-meta",children:[w.assignee?`@${w.assignee}`:"unassigned"," · ",K(w.updatedAt||w.createdAt),(L=w.dependencies)!=null&&L.length?` · ${w.dependencies.length} deps`:""]})]})]},w.id)})]}),e.jsx("button",{type:"button",className:"mobile-fab",onClick:()=>p(!0),"aria-label":"Add task",children:e.jsx(B,{size:24})}),e.jsx(F,{open:!!d,onClose:()=>{o(null),r==null||r()},title:"Task Detail",actions:d&&e.jsxs("div",{className:"mobile-task-detail-actions",children:[d.status!=="done"&&e.jsxs("button",{type:"button",className:"mobile-btn",style:{flex:1},onClick:()=>{d&&H(d.id,Ie[d.status])},children:["Move to ",G[Ie[d.status]||"queued"]]}),e.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>{d&&Ve(d.id)},children:[e.jsx(ct,{size:14})," Archive"]}),Gt(d)&&e.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>{l==null||l(d.id)},children:[e.jsx(Y,{size:14})," Chat"]}),Qt(d)&&e.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>{Ge(d.id)},children:[e.jsx(W,{size:14})," Artifact"]}),e.jsx("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>{d&&Ke(d.id)},children:e.jsx(se,{size:14})})]}),children:d&&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-${d.status}`,children:G[d.status]||d.status}),e.jsx("span",{className:`mobile-task-priority priority-${d.priority}`,children:d.priority})]}),e.jsx("h3",{className:"mobile-task-detail-title",children:d.title}),d.description&&e.jsx("p",{className:"mobile-task-detail-desc",children:d.description}),e.jsxs("div",{className:"mobile-task-detail-meta",children:[d.assignee&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Assignee"}),e.jsxs("span",{children:["@",d.assignee]})]}),d.dueDate&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Due"}),e.jsx("span",{children:new Date(d.dueDate).toLocaleDateString()})]}),d.timeSpent!=null&&e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Time spent"}),e.jsxs("span",{children:[Math.round(d.timeSpent/6e4),"min"]})]}),(pe=d.dependencies)!=null&&pe.length?e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Dependencies"}),e.jsx("span",{children:d.dependencies.length})]}):null,(fe=d.comments)!=null&&fe.length?e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Comments"}),e.jsx("span",{children:d.comments.length})]}):null,e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Created"}),e.jsx("span",{children:K(d.createdAt)})]}),e.jsxs("div",{className:"mobile-task-detail-row",children:[e.jsx("span",{children:"Updated"}),e.jsx("span",{children:K(d.updatedAt)})]})]})]})}),e.jsx(Zt,{open:N,onClose:()=>p(!1),onCreate:Je,agents:be}),e.jsx(F,{open:!!j,onClose:()=>{A(null),P(""),f(null)},title:(D==null?void 0:D.name)||"Artifact",actions:S.length>1?e.jsx("div",{className:"mobile-task-detail-actions",children:S.map((w,L)=>e.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",style:{flex:1},onClick:()=>{g(!0),Promise.all([T.get(`/artifacts/${encodeURIComponent(w)}`),fetch(T.urlWithToken(`/artifacts/${encodeURIComponent(w)}/content`)).then($=>$.text())]).then(([$,M])=>{f($),P(M),g(!1)}).catch(()=>g(!1))},children:["Artifact ",L+1]},w))}):null,children:e.jsx("div",{className:"mobile-artifact-viewer",children:v?e.jsx("div",{className:"mobile-loading",children:e.jsx("p",{children:"Loading artifact…"})}):z?e.jsx("iframe",{srcDoc:z,className:"mobile-artifact-iframe",sandbox:"allow-scripts allow-forms allow-popups allow-same-origin",title:(D==null?void 0:D.name)||"Artifact",loading:"lazy"}):e.jsxs("div",{className:"mobile-empty",children:[e.jsx(W,{size:32}),e.jsx("p",{className:"muted",children:"No artifact content available."})]})})})]})}function Xt(s){var t,n;return((n=(t=s.settings)==null?void 0:t.data)==null?void 0:n.defaultAgent)||"odin"}function Zt({open:s,onClose:t,onCreate:n,agents:r}){const[l,u]=i.useState(""),[b,c]=i.useState(""),[m,y]=i.useState(""),[a,x]=i.useState("normal"),k=h=>{h.preventDefault(),l.trim()&&(n(l.trim(),b.trim(),m,a),u(""),c(""),y(""),x("normal"))};return e.jsx(_,{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:k,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:l,onChange:h=>u(h.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:h=>c(h.target.value)}),e.jsx("label",{className:"mobile-field-label",children:"Assignee"}),e.jsxs("select",{className:"mobile-input",value:m,onChange:h=>y(h.target.value),children:[e.jsx("option",{value:"",children:"Unassigned"}),r.map(h=>e.jsxs("option",{value:h.name,children:["@",h.name]},h.name))]}),e.jsx("label",{className:"mobile-field-label",children:"Priority"}),e.jsxs("select",{className:"mobile-input",value:a,onChange:h=>x(h.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 es=Me.lazy(()=>qe(()=>import("./MobileSettings-BxcbL5XT.js"),__vite__mapDeps([0,1,2])).then(s=>({default:s.MobileSettings}))),ts=Me.lazy(()=>qe(()=>import("./MobileChat-TCputYzr.js"),__vite__mapDeps([3,1,4,2,5,6])).then(s=>({default:s.MobileChat}))),ss=[{id:"activity",label:"Activity",icon:ce},{id:"chat",label:"Chat",icon:Y},{id:"tasks",label:"Tasks",icon:Z},{id:"settings",label:"Settings",icon:Oe},{id:"more",label:"More",icon:rt}];function as(s){const t=s.meta??{},n=typeof t.taskId=="string"?t.taskId:null,r=typeof t.slug=="string"?t.slug:null,l=typeof t.agent=="string"?t.agent:null;if(n)return{id:"task-detail",taskId:n};if(r)return{id:"artifacts?-detail",slug:r};if(l)return{id:"agent-detail",name:l};const u=s.link??"";return u.startsWith("/artifacts?/")?{id:"artifacts?-detail",slug:decodeURIComponent(u.slice(12))}:u.startsWith("/tasks/")?{id:"task-detail",taskId:decodeURIComponent(u.slice(7))}:u.startsWith("/agents/")?{id:"agent-detail",name:decodeURIComponent(u.slice(8))}:null}function us(){const[s,t]=i.useState("activity"),[n,r]=i.useState([]),[l,u]=i.useState(!1),[b,c]=i.useState(null),[m,y]=i.useState(null),[a,x]=i.useState(null),[k,h]=i.useState(null),[d,o]=i.useState(!0),[N,p]=i.useState(0),j=i.useMemo(()=>n[n.length-1]??{id:s},[s,n]),A=i.useCallback(v=>{r(g=>[...g,v])},[]),S=i.useCallback(()=>{r(v=>v.slice(0,-1))},[]),R=i.useCallback(v=>{r([]),t(v)},[]),z=i.useCallback(async()=>{var v;try{const g=await T.get("/snapshot");y(g),(v=g.settings)!=null&&v.data&&x(g.settings.data),h(null)}catch(g){throw h(g.message||"Dashboard server unreachable."),g}},[]);i.useEffect(()=>{let v=!1;return Promise.all([T.get("/snapshot").catch(()=>null),T.get("/settings").catch(()=>null),T.probeAuthStatus().catch(()=>null)]).then(([g,C])=>{var I;if(v)return;const E=(C==null?void 0:C.data)??((I=g==null?void 0:g.settings)==null?void 0:I.data)??null;g&&y(g),E&&x(E),h(!g&&!E?"Dashboard server unreachable.":null)}).catch(g=>{v||h(g.message||"Dashboard server unreachable.")}).finally(()=>{v||o(!1)}),()=>{v=!0}},[]),i.useEffect(()=>{a!=null&&a.theme&&(we(a.theme),Se(a.theme))},[a==null?void 0:a.theme]),i.useEffect(()=>{var C;if(((C=a==null?void 0:a.theme)==null?void 0:C.mode)!=="system")return;const v=window.matchMedia("(prefers-color-scheme: light)"),g=()=>{a!=null&&a.theme&&(we(a.theme),Se(a.theme))};return v.addEventListener("change",g),()=>v.removeEventListener("change",g)},[a==null?void 0:a.theme]),i.useEffect(()=>{const v=()=>{p(C=>C+1),z().catch(()=>{})},g=()=>{document.visibilityState==="visible"&&v()};return window.addEventListener("online",v),window.addEventListener("pageshow",v),document.addEventListener("visibilitychange",g),()=>{window.removeEventListener("online",v),window.removeEventListener("pageshow",v),document.removeEventListener("visibilitychange",g)}},[z]),i.useEffect(()=>{const v=new Fe,g=v.on(C=>{if(C.type==="snapshot"&&"data"in C&&C.data)y(E=>({...E??{},...C.data}));else if(C.type==="change")z().catch(()=>{});else if(C.type==="tasks:change"){const E=C.task;y(I=>{if(!I)return I;const O=(I.tasks||[]).map(H=>H.id===E.id?E:H),J=O.some(H=>H.id===E.id);return{...I,tasks:J?O:[E,...O]}})}else C.type==="tasks:delete"?y(E=>E&&{...E,tasks:(E.tasks||[]).filter(I=>I.id!==C.id)}):C.type==="settings:change"?C.settings&&x(C.settings):C.type==="project:change"||C.type==="agents:change"||C.type==="schedules:change"||C.type==="artifact:change"?z().catch(()=>{}):(C.type==="agent:status"||C.type==="agent:restarted")&&y(E=>{if(!E)return E;const I=(E.agents||[]).map(O=>O.name===C.agent.name?C.agent:O);return{...E,agents:I}})});return()=>{g(),v.close()}},[z,N]);const P=i.useCallback(v=>{(v==="activity"||v==="chat"||v==="tasks"||v==="settings"||v==="more")&&R(v)},[R]),D=i.useCallback((v,g,C)=>{if(v==="notification"){const E=as({link:g||null,meta:C??null});E&&A(E);return}if(v==="task"&&g){A({id:"task-detail",taskId:g});return}if(v==="artifacts?"&&g){A({id:"artifacts?-detail",slug:g});return}if(v==="agent"&&g){A({id:"agent-detail",name:g});return}if(v==="project"){R("activity");return}v==="setting"&&R("settings")},[R,A]),f=()=>{if(!m||!a)return null;if(n.length>0){const v=n[n.length-1];switch(v.id){case"artifacts?":return e.jsx(Rt,{snapshot:m,onBack:S,onOpenArtifact:g=>A({id:"artifacts?-detail",slug:g})});case"agents":return e.jsx(Ee,{snapshot:m,onBack:S,onOpenAgent:g=>A({id:"agent-detail",name:g}),onRefresh:z});case"skills":return e.jsx(Vt,{snapshot:m,onBack:S});case"mods":return e.jsx(Tt,{snapshot:m,onBack:S});case"schedules":return e.jsx(Ot,{snapshot:m,onBack:S});case"history":return e.jsx(Ct,{onBack:S});case"config":return e.jsx(St,{onBack:S});case"artifacts?-detail":return e.jsx($t,{slug:v.slug,onBack:S});case"agent-detail":return e.jsx(Ee,{snapshot:m,onBack:S,onOpenAgent:()=>{},onRefresh:z,selectedAgent:v.name});case"task-detail":return e.jsx(De,{snapshot:m,onRefresh:z,selectedTaskId:v.taskId,onCloseDetail:S,onOpenChat:g=>{c(g),R("chat")}});default:return null}}switch(s){case"activity":return e.jsx(Nt,{snapshot:m,onRefresh:z});case"chat":return e.jsx(i.Suspense,{fallback:e.jsx("div",{className:"mobile-loading",children:e.jsx(ie,{size:"lg"})}),children:e.jsx(ts,{snapshot:m,settings:a,initialTaskId:b,onClearTaskId:()=>c(null)})});case"tasks":return e.jsx(De,{snapshot:m,onRefresh:z,onOpenChat:v=>{c(v),R("chat")}});case"settings":return e.jsx(i.Suspense,{fallback:e.jsx("div",{className:"mobile-loading",children:e.jsx(ie,{size:"lg"})}),children:e.jsx(es,{settings:a,snapshot:m,onRefresh:z})});case"more":return e.jsx(At,{snapshot:m,onNavigate:v=>{(v==="artifacts?"||v==="agents"||v==="skills"||v==="mods"||v==="schedules"||v==="history"||v==="config")&&A({id:v})}});default:return null}};return d?e.jsxs("div",{className:"mobile-loading",children:[e.jsx(ie,{size:"lg"}),e.jsx("p",{children:"Loading Bizar…"})]}):k||!m||!a?e.jsxs("div",{className:"mobile-loading",children:[e.jsx("h2",{children:"Dashboard unavailable"}),e.jsx("p",{children:k||"Dashboard server unreachable."}),e.jsx("p",{className:"muted",children:"Make sure the Bizar dashboard server is running."})]}):e.jsxs("div",{className:"mobile-app",children:[e.jsx(vt,{activeTab:j.id,snapshot:m,onSearch:()=>u(!0),onNavigate:D}),e.jsx("main",{className:"mobile-content",children:f()}),n.length===0&&e.jsx(pt,{tabs:ss,activeTab:s,onChange:P}),n.length>0&&e.jsx("button",{type:"button",className:"mobile-back-btn",onClick:S,"aria-label":"Go back",children:"← Back"}),e.jsx(Yt,{open:l,onClose:()=>u(!1),onNavigate:D})]})}export{ke as A,us as M,ie as S,Fe as W,qe as _,T as a,cs as b,Be as c,Se as d,ds as e,K as f,we as g,dt as p,rs as t,ms as w};
|