agent-lyceum 0.50.0 → 0.52.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/dist/cli.js +6 -2
- package/dist/decision-log.d.ts +23 -0
- package/dist/decision-log.js +148 -11
- package/dist/memory-tidy.d.ts +8 -0
- package/dist/memory-tidy.js +19 -3
- package/dist/run-store.d.ts +1 -1
- package/dist/web-console.d.ts +1 -0
- package/dist/web-console.js +16 -0
- package/package.json +1 -1
- package/web/dist/public/assets/{index-DvGpGOU4.css → index-CGaxjULR.css} +1 -1
- package/web/dist/public/assets/{index-C92kC3HN.js → index-CRFWCH8w.js} +2 -2
- package/web/dist/public/index.html +2 -2
- package/web/dist/server/api.js +2 -0
- package/web/dist/server/hub.js +3 -1
- package/web/dist/start.js +5 -0
|
@@ -82,6 +82,6 @@ ${e}</tr>
|
|
|
82
82
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
83
83
|
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${no(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?no(n,!0):this.parser.parseInline(r),o=io(e);if(o===null)return a;e=no(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+no(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=io(e);if(i===null)return no(n);e=i;let a=`<img src="${no(e)}" alt="${no(n)}"`;return t&&(a+=` title="${no(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:no(e.text)}},To=class{parser;strong({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}em({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}codespan({text:e}){return e}del({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}html({text:e}){return e}text({text:e}){return e}link({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}image({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}br(){return`
|
|
84
84
|
`}checkbox({raw:e}){return e}},Eo=class e{options;renderer;textRenderer;constructor(e){this.options=e||Mi,this.options.renderer=this.options.renderer||new wo,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new To,this.textRenderer.parser=this}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n===!1?``:n??``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e===!1?``:e??``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Do=class{options;block;constructor(e){this.options=e||Mi}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Co.lex:Co.lexInline}provideParser(e=this.block){return e?Eo.parse:Eo.parseInline}};function Oo(e,t){if(Array.isArray(t))for(let n=0;n<t.length;n++)e.push(t[n]);else e.push(t)}var ko=new class{defaults=ji();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Eo;Renderer=wo;TextRenderer=To;Lexer=Co;Tokenizer=So;Hooks=Do;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(Oo(n,t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)Oo(n,this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)Oo(n,this.walkTokens(e.tokens,t));break}case`list`:{let e=r;Oo(n,this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);Oo(n,this.walkTokens(i,t))}):e.tokens&&Oo(n,this.walkTokens(e.tokens,t))}}return n}use(...e){let t=this.defaults.extensions||{renderers:Object.create(null),childTokens:Object.create(null)};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new wo(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n===!1?``:n??``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new So(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Do;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=Do.passThroughHooks.has(n)?e=>{if(t.options.async&&Do.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(t.options.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return Oo(n,r.call(this,e)),t&&Oo(n,t.call(this,e)),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Co.lex(e,t??this.defaults)}parser(e,t){return Eo.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Co.lex:Co.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Eo.parse:Eo.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Co.lex:Co.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Eo.parse:Eo.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
85
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+no(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function W(e,t){return ko.parse(e,t)}W.options=W.setOptions=function(e){return ko.setOptions(e),W.defaults=ko.defaults,Ni(W.defaults),W},W.getDefaults=ji,W.defaults=Mi;function Ao(...e){return ko.use(...e),W.defaults=ko.defaults,Ni(W.defaults),W}W.use=Ao,W.walkTokens=function(e,t){return ko.walkTokens(e,t)},W.parseInline=ko.parseInline,W.Parser=Eo,W.parser=Eo.parse,W.Renderer=wo,W.TextRenderer=To,W.Lexer=Co,W.lexer=Co.lex,W.Tokenizer=So,W.Hooks=Do,W.parse=W,W.options,W.setOptions,W.walkTokens,W.parseInline,Eo.parse,Co.lex,Ai.addHook(`afterSanitizeAttributes`,e=>{e instanceof HTMLAnchorElement&&e.hasAttribute(`href`)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))});function jo(e){let t=W.parse(e,{async:!1,gfm:!0});return Ai.sanitize(t,{USE_PROFILES:{html:!0}})}var Mo={active:`有效`,superseded:`已被取代`},No=`inline-flex min-h-11 shrink-0 items-center gap-2 rounded-lg border px-3 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`;function Po(){let[e,t]=(0,b.useState)(),[n,r]=(0,b.useState)(),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)();(0,b.useEffect)(()=>{let e=!0;return Rn().then(n=>e&&t(n??`error`)),()=>{e=!1}},[]);let c=Array.isArray(e)?e:[],l=c.find(e=>e.project===n)??c.find(e=>e.decisions.length>0)??c[0],u=(l?.decisions??[]).filter(e=>i||e.status===`active`),d=(l?.decisions.length??0)-u.length;return(0,z.jsxs)(`article`,{className:`enter animate-in fade-in p-4 duration-200 sm:p-6`,children:[(0,z.jsx)(`h1`,{className:`text-balance text-2xl font-semibold tracking-tight`,children:`決策`}),(0,z.jsx)(`p`,{className:`text-pretty mt-2 text-sm text-ink/70`,children:`依專案分類,以 ADR 格式呈現。資料來自專案紀錄,清除任務後仍會保留。`}),e===void 0?(0,z.jsx)(`p`,{role:`status`,className:`mt-6 text-sm`,children:`讀取中…`}):e===`error`?(0,z.jsx)(`p`,{role:`alert`,className:`mt-6 text-sm text-failed`,children:`讀不到決策,請重新整理頁面。`}):c.length===0?(0,z.jsx)(`p`,{className:`mt-6 text-sm`,children:`還沒有已註冊的專案。`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`ul`,{"aria-label":`專案`,className:`mt-5 flex gap-2 overflow-x-auto pb-1`,children:c.map(e=>{let t=e.project===l?.project;return(0,z.jsx)(`li`,{children:(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":t,className:R(No,t?`border-line bg-paper font-medium`:`border-transparent hover:bg-paper/70`),onClick:()=>{r(e.project),s(void 0)},children:[(0,z.jsx)(`span`,{className:`truncate`,children:e.project}),(0,z.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-ink/60`,children:e.decisions.filter(e=>e.status===`active`).length})]})},e.project)})}),l?.error&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-failed`,children:l.error}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-[minmax(0,22rem)_minmax(0,1fr)]`,children:[(0,z.jsxs)(`section`,{"aria-label":`決策列表`,children:[(0,z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-[var(--c-signal)]`,checked:i,onChange:e=>a(e.target.checked)}),`顯示已被取代的決策`,d>0&&!i?`(${d})`:``]}),u.length===0?(0,z.jsx)(`p`,{className:`panel mt-2 p-4 text-sm text-ink/70`,children:l&&l.decisions.length===0?`這個專案還沒有決策紀錄。`:`沒有有效的決策。`}):(0,z.jsx)(`ul`,{className:`mt-2 grid gap-2`,children:u.map(e=>{let t=o?.project===l?.project&&o?.id===e.id;return(0,z.jsx)(`li`,{children:(0,z.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,className:R(`panel block min-h-11 w-full p-3 text-left hover:bg-wall focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`,t&&`border-signal`,e.status===`superseded`&&`opacity-70`),onClick:()=>l&&s({project:l.project,id:e.id}),children:[(0,z.jsxs)(`span`,{className:`block font-mono text-xs tabular-nums text-ink/60`,children:[e.date||`日期不明`,` · `,e.id]}),(0,z.jsx)(`span`,{className:`text-pretty mt-1 block text-sm font-medium`,children:e.title}),(0,z.jsx)(Fo,{item:e})]})},e.id)})})]}),(0,z.jsx)(`section`,{"aria-label":`決策內容`,"aria-live":`polite`,children:o?(0,z.jsx)(Io,{pick:o,onJump:e=>s({project:o.project,id:e})},`${o.project}/${o.id}`):(0,z.jsx)(`p`,{className:`panel p-4 text-sm text-ink/70`,children:`從左邊選一個決策來閱讀。`})})]})]})]})}function Fo({item:e}){return(0,z.jsxs)(`span`,{className:R(`mt-2 inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs`,e.status===`active`?`bg-signal-soft text-signal`:`bg-warn-soft text-warn`),children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-current`}),Mo[e.status],e.invalid?`・格式有問題`:``]})}function Io({pick:e,onJump:t}){let[n,r]=(0,b.useState)();(0,b.useEffect)(()=>{let t=!0;return zn(e.project,e.id).then(e=>t&&r(e??`error`)),()=>{t=!1}},[e.project,e.id]);let i=(0,b.useMemo)(()=>n&&n!==`error`?jo(n.markdown):``,[n]);if(n===void 0)return(0,z.jsx)(`p`,{role:`status`,className:`panel p-4 text-sm`,children:`讀取中…`});if(n===`error`)return(0,z.jsx)(`p`,{role:`alert`,className:`panel p-4 text-sm text-failed`,children:`找不到這個決策。`});let a=e=>e.map(e=>(0,z.jsx)(`button`,{type:`button`,className:`mr-2 min-h-11 font-mono text-xs underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`,onClick:()=>t(e),children:e},e));return(0,z.jsxs)(`div`,{className:`panel p-4 sm:p-6`,children:[(0,z.jsxs)(`p`,{className:`eyebrow`,children:[`ADR · `,e.project]}),(0,z.jsx)(`h2`,{className:`text-balance mt-1 text-xl font-semibold tracking-tight`,children:n.title}),(0,z.jsxs)(`dl`,{className:`mt-4 grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 border-y border-line py-3 text-sm`,children:[(0,z.jsx)(`dt`,{className:`text-ink/60`,children:`狀態`}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(Fo,{item:n})}),(0,z.jsx)(`dt`,{className:`text-ink/60`,children:`日期`}),(0,z.jsx)(`dd`,{className:`font-mono tabular-nums`,children:n.date||`不明`}),n.run&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{className:`text-ink/60`,children:`來源任務`}),(0,z.jsx)(`dd`,{className:`truncate font-mono text-xs`,children:n.run})]}),n.supersedes.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{className:`text-ink/60`,children:`取代`}),(0,z.jsx)(`dd`,{children:a(n.supersedes)})]}),n.supersededBy.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{className:`text-ink/60`,children:`被取代於`}),(0,z.jsx)(`dd`,{children:a(n.supersededBy)})]})]}),n.invalid&&(0,z.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-failed`,children:[`這份紀錄的格式有問題:`,n.invalid]}),(0,z.jsx)(`article`,{className:`report-prose mt-4`,dangerouslySetInnerHTML:{__html:i}})]})}function Lo(e,t){return t?{tone:`fail`,text:`等太久,已中止`}:e===null?{tone:`fail`,text:`沒能啟動`}:e===0?{tone:`ok`,text:`完成`}:e===2?{tone:`warn`,text:`部分完成,或被擋住(結束碼 2)`}:e===3?{tone:`warn`,text:`正在等你回答問題`}:{tone:`fail`,text:`失敗(結束碼 ${e})`}}var Ro=60;function G(e){let t=e.indexOf(`--`),n=t<0?e:e.slice(0,t),r=t<0?[]:e.slice(t+1),i=e=>{let t=n.indexOf(e);return t>=0?n[t+1]:void 0},a=i(`-p`),o=n.includes(`--tidy`),
|
|
85
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+no(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function W(e,t){return ko.parse(e,t)}W.options=W.setOptions=function(e){return ko.setOptions(e),W.defaults=ko.defaults,Ni(W.defaults),W},W.getDefaults=ji,W.defaults=Mi;function Ao(...e){return ko.use(...e),W.defaults=ko.defaults,Ni(W.defaults),W}W.use=Ao,W.walkTokens=function(e,t){return ko.walkTokens(e,t)},W.parseInline=ko.parseInline,W.Parser=Eo,W.parser=Eo.parse,W.Renderer=wo,W.TextRenderer=To,W.Lexer=Co,W.lexer=Co.lex,W.Tokenizer=So,W.Hooks=Do,W.parse=W,W.options,W.setOptions,W.walkTokens,W.parseInline,Eo.parse,Co.lex,Ai.addHook(`afterSanitizeAttributes`,e=>{e instanceof HTMLAnchorElement&&e.hasAttribute(`href`)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))});function jo(e){let t=W.parse(e,{async:!1,gfm:!0});return Ai.sanitize(t,{USE_PROFILES:{html:!0}})}var Mo={active:`有效`,superseded:`已被取代`},No=`inline-flex min-h-11 shrink-0 items-center gap-2 rounded-lg border px-3 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`;function Po(){let[e,t]=(0,b.useState)(),[n,r]=(0,b.useState)(),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)();(0,b.useEffect)(()=>{let e=!0;return Rn().then(n=>e&&t(n??`error`)),()=>{e=!1}},[]);let c=Array.isArray(e)?e:[],l=c.find(e=>e.project===n)??c.find(e=>e.decisions.length>0)??c[0],u=(l?.decisions??[]).filter(e=>i||e.status===`active`),d=(l?.decisions.length??0)-u.length;return(0,z.jsxs)(`article`,{className:`enter animate-in fade-in p-4 duration-200 sm:p-6`,children:[(0,z.jsx)(`h1`,{className:`text-balance text-2xl font-semibold tracking-tight`,children:`決策`}),(0,z.jsx)(`p`,{className:`text-pretty mt-2 text-sm text-ink/70`,children:`依專案分類,以 ADR 格式呈現。資料來自專案紀錄,清除任務後仍會保留。`}),e===void 0?(0,z.jsx)(`p`,{role:`status`,className:`mt-6 text-sm`,children:`讀取中…`}):e===`error`?(0,z.jsx)(`p`,{role:`alert`,className:`mt-6 text-sm text-failed`,children:`讀不到決策,請重新整理頁面。`}):c.length===0?(0,z.jsx)(`p`,{className:`mt-6 text-sm`,children:`還沒有已註冊的專案。`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`ul`,{"aria-label":`專案`,className:`mt-5 flex gap-2 overflow-x-auto pb-1`,children:c.map(e=>{let t=e.project===l?.project;return(0,z.jsx)(`li`,{children:(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":t,className:R(No,t?`border-line bg-paper font-medium`:`border-transparent hover:bg-paper/70`),onClick:()=>{r(e.project),s(void 0)},children:[(0,z.jsx)(`span`,{className:`truncate`,children:e.project}),(0,z.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-ink/60`,children:e.decisions.filter(e=>e.status===`active`).length})]})},e.project)})}),l?.error&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-failed`,children:l.error}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-[minmax(0,22rem)_minmax(0,1fr)]`,children:[(0,z.jsxs)(`section`,{"aria-label":`決策列表`,children:[(0,z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-[var(--c-signal)]`,checked:i,onChange:e=>a(e.target.checked)}),`顯示已被取代的決策`,d>0&&!i?`(${d})`:``]}),u.length===0?(0,z.jsx)(`p`,{className:`panel mt-2 p-4 text-sm text-ink/70`,children:l&&l.decisions.length===0?`這個專案還沒有決策紀錄。`:`沒有有效的決策。`}):(0,z.jsx)(`ul`,{className:`mt-2 grid gap-2`,children:u.map(e=>{let t=o?.project===l?.project&&o?.id===e.id;return(0,z.jsx)(`li`,{children:(0,z.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,className:R(`panel block min-h-11 w-full p-3 text-left hover:bg-wall focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`,t&&`border-signal`,e.status===`superseded`&&`opacity-70`),onClick:()=>l&&s({project:l.project,id:e.id}),children:[(0,z.jsxs)(`span`,{className:`block font-mono text-xs tabular-nums text-ink/60`,children:[e.date||`日期不明`,` · `,e.id]}),(0,z.jsx)(`span`,{className:`text-pretty mt-1 block text-sm font-medium`,children:e.title}),(0,z.jsx)(Fo,{item:e})]})},e.id)})})]}),(0,z.jsx)(`section`,{"aria-label":`決策內容`,"aria-live":`polite`,children:o?(0,z.jsx)(Io,{pick:o,onJump:e=>s({project:o.project,id:e})},`${o.project}/${o.id}`):(0,z.jsx)(`p`,{className:`panel p-4 text-sm text-ink/70`,children:`從左邊選一個決策來閱讀。`})})]})]})]})}function Fo({item:e}){return(0,z.jsxs)(`span`,{className:R(`mt-2 inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs`,e.status===`active`?`bg-signal-soft text-signal`:`bg-warn-soft text-warn`),children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-current`}),Mo[e.status],e.invalid?`・格式有問題`:``]})}function Io({pick:e,onJump:t}){let[n,r]=(0,b.useState)();(0,b.useEffect)(()=>{let t=!0;return zn(e.project,e.id).then(e=>t&&r(e??`error`)),()=>{t=!1}},[e.project,e.id]);let i=(0,b.useMemo)(()=>n&&n!==`error`?jo(n.markdown):``,[n]);if(n===void 0)return(0,z.jsx)(`p`,{role:`status`,className:`panel p-4 text-sm`,children:`讀取中…`});if(n===`error`)return(0,z.jsx)(`p`,{role:`alert`,className:`panel p-4 text-sm text-failed`,children:`找不到這個決策。`});let a=e=>e.map(e=>(0,z.jsx)(`button`,{type:`button`,className:`mr-2 min-h-11 font-mono text-xs underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`,onClick:()=>t(e),children:e},e));return(0,z.jsxs)(`div`,{className:`panel p-4 sm:p-6`,children:[(0,z.jsxs)(`p`,{className:`eyebrow`,children:[`ADR · `,e.project]}),(0,z.jsx)(`h2`,{className:`text-balance mt-1 text-xl font-semibold tracking-tight`,children:n.title}),(0,z.jsxs)(`dl`,{className:`mt-4 grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 border-y border-line py-3 text-sm`,children:[(0,z.jsx)(`dt`,{className:`text-ink/60`,children:`狀態`}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(Fo,{item:n})}),(0,z.jsx)(`dt`,{className:`text-ink/60`,children:`日期`}),(0,z.jsx)(`dd`,{className:`font-mono tabular-nums`,children:n.date||`不明`}),n.run&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{className:`text-ink/60`,children:`來源任務`}),(0,z.jsx)(`dd`,{className:`truncate font-mono text-xs`,children:n.run})]}),n.supersedes.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{className:`text-ink/60`,children:`取代`}),(0,z.jsx)(`dd`,{children:a(n.supersedes)})]}),n.supersededBy.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{className:`text-ink/60`,children:`被取代於`}),(0,z.jsx)(`dd`,{children:a(n.supersededBy)})]})]}),n.invalid&&(0,z.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-failed`,children:[`這份紀錄的格式有問題:`,n.invalid]}),(0,z.jsx)(`article`,{className:`report-prose mt-4`,dangerouslySetInnerHTML:{__html:i}})]})}function Lo(e,t){return t?{tone:`fail`,text:`等太久,已中止`}:e===null?{tone:`fail`,text:`沒能啟動`}:e===0?{tone:`ok`,text:`完成`}:e===2?{tone:`warn`,text:`部分完成,或被擋住(結束碼 2)`}:e===3?{tone:`warn`,text:`正在等你回答問題`}:{tone:`fail`,text:`失敗(結束碼 ${e})`}}var Ro=60;function G(e){let t=e.indexOf(`--`),n=t<0?e:e.slice(0,t),r=t<0?[]:e.slice(t+1),i=e=>{let t=n.indexOf(e);return t>=0?n[t+1]:void 0},a=i(`-p`),o=e[0],s=n.includes(`--tidy`)||o===`tidy`&&!n.includes(`--dry-run`)&&!n.includes(`--undo`),c;return o===`run`?c=i(`--name`)??zo(r[0]):o===`resume`?c=r[0]:o===`call`&&(c=[n[1],zo(r[0])].filter(Boolean).join(`:`)||void 0),{project:a,target:c,tidy:s}}function zo(e){let t=e?.split(`
|
|
86
86
|
`).find(e=>e.trim())?.trim();if(t)return t.length>Ro?`${t.slice(0,Ro)}…`:t}function Bo(e,t=160){let[n,r]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{if(!e){r(!1);return}let n=window.setTimeout(()=>r(!0),t);return()=>window.clearTimeout(n)},[e,t]),n}function Vo({label:e,className:t}){return(0,z.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:R(`flex min-h-11 items-center gap-2 text-sm text-ink/70`,t),children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`pulse-dot size-2 shrink-0 rounded-full bg-signal`}),(0,z.jsx)(`span`,{children:e})]})}function Ho({label:e,className:t}){return(0,z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:R(`enter animate-in fade-in p-4 duration-200 sm:p-6`,t),children:[(0,z.jsx)(Vo,{label:e}),(0,z.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-hidden":`true`,children:[(0,z.jsx)(`div`,{className:`h-3 w-2/3 motion-safe:animate-pulse rounded bg-line`}),(0,z.jsx)(`div`,{className:`h-3 w-full motion-safe:animate-pulse rounded bg-line`}),(0,z.jsx)(`div`,{className:`h-3 w-5/6 motion-safe:animate-pulse rounded bg-line`}),(0,z.jsxs)(`div`,{className:`mt-6 grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(`div`,{className:`panel h-24 motion-safe:animate-pulse bg-paper`}),(0,z.jsx)(`div`,{className:`panel h-24 motion-safe:animate-pulse bg-paper`})]})]})]})}function Uo({label:e}){return(0,z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:`relative h-1 overflow-hidden bg-line`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:e}),(0,z.jsx)(`span`,{"aria-hidden":!0,className:`loading-bar absolute inset-y-0 w-1/3 rounded-full bg-signal`})]})}function Wo(e,t,n){let r=!0,i,a=async()=>{let o,s=!0;try{o=await e()}catch{s=!1}r&&(s&&t(o),i=setTimeout(()=>void a(),n))};return a(),()=>{r=!1,i!==void 0&&clearTimeout(i)}}var Go={running:`執行中`,ended:`已結束`,lost:`已結束(結束碼不明)`};function Ko(){let[e,t]=(0,b.useState)(),[n,r]=(0,b.useState)(),[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)(!1);return(0,b.useEffect)(()=>Wo(Mn,t,3e3),[]),(0,b.useEffect)(()=>{if(a(void 0),s(!1),n)return Wo(()=>Nn(n),e=>{e?(a(e),s(!1)):(a(e=>e??null),s(!0))},2e3)},[n]),e===void 0?(0,z.jsx)(Ho,{label:`正在讀取任務清單…`}):(0,z.jsxs)(`article`,{className:`enter animate-in fade-in p-4 duration-200 sm:p-6`,children:[(0,z.jsx)(`h1`,{className:`text-balance text-2xl font-semibold tracking-tight`,children:`任務輸出`}),(0,z.jsx)(`p`,{className:`text-pretty mt-2 text-sm`,children:`從網頁啟動的背景指令。它們獨立於這個頁面,關掉頁面也會繼續跑。`}),e.length===0?(0,z.jsx)(`p`,{className:`text-pretty mt-6 text-sm`,children:`還沒有從網頁啟動過的背景指令;若剛啟動過卻沒看到,可能是暫時無法取得清單,稍後會自動重試。`}):(0,z.jsx)(`ul`,{className:`mt-6 flex flex-col gap-2`,children:e.map(e=>{let t=e.state===`ended`?Lo(e.exit??null,!1):void 0,i=G(e.argv);return(0,z.jsx)(`li`,{children:(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":n===e.id,className:R(`panel flex min-h-11 w-full flex-wrap items-center gap-x-4 gap-y-1 px-3 py-2 text-left text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`,n===e.id&&`border-ink/40`),onClick:()=>r(n===e.id?void 0:e.id),children:[(0,z.jsx)(`span`,{className:`font-mono`,children:e.command}),i.project&&(0,z.jsx)(`span`,{className:`font-mono text-ink/70`,children:i.project}),i.target&&(0,z.jsx)(`span`,{className:`min-w-0 max-w-full truncate font-medium`,children:i.target}),i.tidy&&(0,z.jsx)(`span`,{className:`rounded-full border border-line px-2 py-0.5 text-xs text-ink/70`,children:`已 tidy`}),(0,z.jsx)(`span`,{className:`text-ink/60`,children:new Date(e.started_at).toLocaleString()}),(0,z.jsx)(`span`,{className:R(e.state===`running`||t?.tone===`ok`?`text-signal`:t?.tone===`warn`||e.state===`lost`?`text-warn`:`text-failed`),children:e.state===`ended`&&t?t.text:Go[e.state]})]})},e.id)})}),n&&i===void 0&&(0,z.jsxs)(`div`,{className:`mt-6 rounded-lg border border-line bg-paper p-4`,children:[(0,z.jsx)(Vo,{label:`正在讀取輸出…`}),(0,z.jsxs)(`div`,{className:`mt-3 space-y-2`,"aria-hidden":`true`,children:[(0,z.jsx)(`div`,{className:`h-3 w-full motion-safe:animate-pulse rounded bg-line`}),(0,z.jsx)(`div`,{className:`h-3 w-5/6 motion-safe:animate-pulse rounded bg-line`}),(0,z.jsx)(`div`,{className:`h-3 w-2/3 motion-safe:animate-pulse rounded bg-line`})]})]}),n&&i===null&&(0,z.jsx)(`p`,{className:`text-pretty mt-6 text-sm text-failed`,children:`無法取得這個任務的輸出,稍後會自動重試。`}),i&&(0,z.jsxs)(`section`,{"aria-label":`輸出`,className:`mt-6`,children:[(0,z.jsx)(`p`,{className:`eyebrow`,children:i.argv.join(` `)}),o&&(0,z.jsx)(`p`,{className:`mt-1 text-sm text-warn`,children:`更新失敗,稍後重試`}),(0,z.jsx)(`pre`,{className:`mt-2 max-h-[60dvh] overflow-auto rounded-lg border border-line bg-paper p-3 font-mono text-xs whitespace-pre-wrap`,children:i.tail||`(還沒有輸出)`})]})]})}function qo({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=b.useRef(e!==void 0),[a,o]=b.useState(()=>t);return[i&&e!==void 0?e:a,b.useCallback(e=>{i||o(e)},[])]}function Jo(){let[,e]=b.useState({});return b.useCallback(()=>{e({})},[])}var Yo=0;function Xo(e,t=`mui`){let n=b.useRef(void 0),r=Jo(),i=e??n.current;return b.useEffect(()=>{n.current??(Yo+=1,n.current=`${t}-${Yo}`,e??r())},[e,t,r]),i}var Zo=x.useId;function Qo(e,t){if(Zo!==void 0){let n=Zo();return e??(t?`${t}-${n}`:n)}return Xo(e,t)}function $o(e){return Qo(e,`base-ui`)}function es(e,t,n,r){let i=!1,a=!1,o=r??je;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}var ts=`none`,ns=`trigger-press`;function rs(e){b.useEffect(e,Ae)}var is=null;globalThis.requestAnimationFrame;var as=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},os=class e{static create(){return new e}static request(e){return as.request(e)}static cancel(e){return as.cancel(e)}currentId=is;request(e){this.cancel(),this.currentId=as.request(()=>{this.currentId=is,e()})}cancel=()=>{this.currentId!==is&&(as.cancel(this.currentId),this.currentId=is)};disposeEffect=()=>this.cancel};function ss(){let e=C(os.create).current;return rs(e.disposeEffect),e}function cs(e,t=!1,n=!1,r=!1){let[i,a]=b.useState(e&&t?`idle`:void 0),[o,s]=b.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),D(()=>{if(!e&&o&&i!==`ending`&&n){let e=os.request(()=>{a(`ending`)});return()=>{os.cancel(e)}}},[e,o,i,n]),D(()=>{if(!e||t||i===void 0)return;let n=os.request(()=>{a(void 0)});return()=>{os.cancel(n)}},[t,e,i]),D(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=os.request(()=>{a(`idle`)});return()=>{os.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function ls(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=qo({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=cs(a,!0,!0),u=$o(),[d,f]=b.useState(),p=d===null?void 0:d??u,m=ee(e=>{let t=!a,n=es(ns,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return b.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:m,mounted:s,open:a,panelId:p,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,m,s,a,p,c,o,f,l])}var us=b.createContext(void 0);function ds(){let e=b.useContext(us);if(e===void 0)throw Error(he(15));return e}var fs=`data-starting-style`,ps=`data-ending-style`,ms={[fs]:``},hs={[ps]:``},gs={transitionStatus(e){return e===`starting`?ms:e===`ending`?hs:null}},_s=`data-open`,vs=`data-closed`,ys=fs,bs=`data-panel-open`,xs={[_s]:``},Ss={[vs]:``},Cs={open(e){return e?{[bs]:``}:null}},ws={open(e){return e?xs:Ss},...gs},Ts=b.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=ee(o),d=ls({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=b.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=b.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=Fe(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:ws});return(0,z.jsx)(us.Provider,{value:p,children:m})}),Es={...Cs,...gs},Ds=b.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=ds(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=j({disabled:c,native:u});return Fe(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:Es})});function Os(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}var ks=0,As=class e{static create(){return new e}currentId=ks;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=ks,t()},e)}isStarted(){return this.currentId!==ks}clear=()=>{this.currentId!==ks&&(clearTimeout(this.currentId),this.currentId=ks)};disposeEffect=()=>this.clear};function js(e){let t=C(Ms,e).current;return t.next=e,D(t.effect),t}function Ms(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function Ns(e){return e==null?e:`current`in e?e.current:e}function Ps(e,t){return e.getAnimations(t).filter(e=>{let t=e.effect?.getTiming();return t?.duration!==1/0&&t?.iterations!==1/0})}var Fs=c(m(),1),Is=null;function Ls(e){if(!Is){let e=[];Is=e,queueMicrotask(()=>{Is=null,Fs.flushSync(()=>{for(let t of e)t()})})}Is.push(e)}function Rs(e,t=!1,n=!1){let r=ss();return ee((i,a=null)=>{r.cancel();let o=Ns(e);if(o==null)return;let s=o,c=()=>{n?Ls(()=>{a?.aborted||i()}):Fs.flushSync(i)};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(Ps(s).map(e=>e.finished.then(ke))).then(()=>{a?.aborted||c()},()=>{a?.aborted||(Ps(s).some(e=>e.pending||e.playState!==`finished`)?l():c())})}if(t){let e=fs;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0})}else r.request(l)})}function zs(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=ee(a),s=Rs(r,n,i);b.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}var Bs={height:void 0,width:void 0};function Vs(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:l,transitionStatus:u}=e,d=b.useRef(null),f=b.useRef(null),[p,m]=b.useState(Bs),h=b.useRef(Bs),g=b.useRef(!1),_=b.useRef(s),v=b.useRef(!1),[y,x]=b.useState(!1),S=b.useRef(null),C=xe(t,d),w=js(s),T=Rs(d),E=!s&&!a,te=y?`idle`:u,O=s&&(_.current||v.current),ne=!s&&a&&f.current===`css-animation`&&p.height===void 0&&p.width===void 0?h.current:p,re=n&&E&&f.current!==`css-animation`,ie=ee((e,t=!0)=>{t&&(h.current=e),m(e)}),ae=ee(()=>{S.current?.(),S.current=null}),oe=ee(e=>{ae(),S.current=()=>{S.current=null,e()}}),k=ee(()=>{s&&a&&f.current===`css-animation`&&(v.current=!0)});D(()=>{y&&u!==`starting`&&x(!1)},[y,u]),b.useEffect(()=>()=>{k(),ae()},[k,ae]),D(()=>{s||(_.current=!1,v.current=!1);let e=d.current;if(!e)return;!s&&S.current&&ae();let t=Us(e,O);if(f.current=t,s&&u===`idle`&&_.current&&t===`css-animation`){h.current=Hs(e);return}if(s&&u===`starting`){let n=g.current;if(g.current=!1,t===`none`){ie(Hs(e)),x(!0);return}if(t===`css-transition`){let t=Ks(e);if(ie(Hs(e)),!n)return t;let r=Gs(e,`transition-duration`,`0s`);return oe(r),x(!0),t}ie(Hs(e));let r=Gs(e,`animation-name`,`none`);if(!n){r();return}let i=Gs(e,`animation-duration`,`0s`);r(),oe(i),x(!0);return}if(!s&&a&&(u===`idle`||u===`starting`)){if(t===`none`){ie(Bs,!1),c(!1);return}ie(Hs(e));return}if(u!==`ending`)return;if(t===`none`){c(!1);return}let n=Hs(e);n.height>0||n.width>0?(ie(n),t===`css-animation`&&Gs(e,`animation-name`,`none`)()):c(!1)},[a,s,ae,ie,c,oe,O,u]),zs({enabled:s&&a&&te===`idle`,open:!0,ref:d,onComplete(){s&&ie(Bs,!1)}}),b.useEffect(()=>{if(s||!a||te!==`ending`)return;if(!d.current){c(!1),ie(Bs,!1);return}let e=new AbortController,t=-1;function n(){w.current||(c(!1),ie(Bs,!1))}return t=os.request(()=>{T(n,e.signal)}),()=>{os.cancel(t),e.abort()}},[w,a,s,te,T,ie,c]),D(()=>{let e=d.current;e&&n&&E&&e.setAttribute(`hidden`,`until-found`)},[E,n]),b.useEffect(function(){let e=d.current;if(!e)return;let t=As.create(),n=-1,r=(r,i)=>{t.start(0,()=>{w.current||(n=os.request(()=>{w.current||(r&&(g.current=!1),i&&e.setAttribute(ys,``),e.setAttribute(`hidden`,`until-found`))}))})},i=Os(e,`beforematch`,t=>{let n=es(ts,t);if(o(!0,n),n.isCanceled){r(!1,!1);return}g.current=!0;let i=e.hasAttribute(ys);e.removeAttribute(ys),l(!0),r(!0,i)});return()=>{t.clear(),os.cancel(n),i()}},[w,o,l]);let se=i||n||a||s;return{height:ne.height,props:{...re?{[ys]:``}:void 0,hidden:E,id:r},ref:C,shouldPreventOpenAnimation:O,shouldRender:se,transitionStatus:te,width:ne.width}}function Hs(e){return{height:e.scrollHeight,width:e.scrollWidth}}function Us(e,t){let n=v(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&Ws(n.animationDuration),i=Ws(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function Ws(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function Gs(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{r===``?e.style.removeProperty(t):e.style.setProperty(t,r,i)}}function Ks(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{n===``?e.style.removeProperty(t):e.style.setProperty(t,n)})}let r=os.request(n);return()=>{os.cancel(r),n()}}var qs=`--collapsible-panel-height`,Js=`--collapsible-panel-width`,Ys=b.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=ds(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;D(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:ee,transitionStatus:E,width:te}=Vs({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),O={...g,transitionStatus:E},ne=Pe(s,O),re=Fe(`div`,{...e,style:void 0},{state:O,ref:w,props:[C,{style:{[qs]:S===void 0?`auto`:`${S}px`,[Js]:te===void 0?`auto`:`${te}px`}},c,ne?{style:ne}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:ws});return ee?re:null}),Xs=(0,b.createContext)({});function Zs(e){let t=(0,b.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Qs=typeof window<`u`?b.useLayoutEffect:b.useEffect,$s=(0,b.createContext)(null);function ec(e,t){e.indexOf(t)===-1&&e.push(t)}function tc(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var nc=(e,t,n)=>n>t?t:n<e?e:n,rc={},ic=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),ac=e=>typeof e==`object`&&!!e,oc=e=>/^0[^.\s]+$/u.test(e);function sc(e){let t;return()=>(t===void 0&&(t=e()),t)}var cc=e=>e,lc=(...e)=>e.reduce((e,t)=>n=>t(e(n))),uc=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},dc=class{constructor(){this.subscriptions=[]}add(e){return ec(this.subscriptions,e),()=>this.remove(e)}remove(e){tc(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r){if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},fc=e=>e*1e3,pc=e=>e/1e3,mc=(e,t)=>t?1e3/t*e:0,hc=(e,t,n)=>e*(3*(1-e)*((1-e)*t+e*n)+e*e);function gc(e,t,n,r){return e===t&&n===r?cc:i=>{let a=0,o=1,s=i;for(let t=0;;t++){s>=a&&s<=o||(s=(a+o)/2);let r=hc(s,e,n)-i;if(r*r<1e-28||t===40)break;r>0?o=s:a=s,s-=r*1e-7/(hc(s+1e-7,e,n)-i-r)}return hc(s,t,r)}}var _c=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,vc=e=>t=>1-e(1-t),yc=gc(.33,1.53,.69,.99),bc=vc(yc),xc=_c(bc),Sc=e=>e>=1?1:(e*=2)<1?.5*bc(e):.5*(2-2**(-10*(e-1))),Cc=e=>1-Math.sin(Math.acos(e)),wc=vc(Cc),Tc=_c(Cc),Ec=gc(.42,0,1,1),Dc=gc(0,0,.58,1),Oc=gc(.42,0,.58,1),kc=e=>Array.isArray(e)&&typeof e[0]!=`number`,Ac=e=>Array.isArray(e)&&typeof e[0]==`number`,jc={linear:cc,easeIn:Ec,easeInOut:Oc,easeOut:Dc,circIn:Cc,circInOut:Tc,circOut:wc,backIn:bc,backInOut:xc,backOut:yc,anticipate:Sc},Mc=e=>typeof e==`string`,Nc=e=>{if(Ac(e)){let[t,n,r,i]=e;return gc(t,n,r,i)}return Mc(e)?jc[e]:e},Pc={delta:0,timestamp:0,isProcessing:!1},Fc;function Ic(){Fc=void 0}var Lc={now:()=>(Fc===void 0&&Lc.set(Pc.isProcessing||rc.useManualTiming?Pc.timestamp:performance.now()),Fc),set:e=>{Fc=e,queueMicrotask(Ic)}},Rc=e=>Math.round(e*1e5)/1e5,zc=e=>t=>typeof t==`string`&&t.startsWith(e),Bc=zc(`--`),Vc=zc(`var(--`),Hc=e=>Vc(e)?Uc.test(e.split(`/*`)[0].trim()):!1,Uc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Wc(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var Gc={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Kc={...Gc,transform:e=>nc(0,1,e)},qc={...Gc,default:1},Jc=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Yc(e){return e==null}var Xc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Zc=(e,t)=>n=>!!(typeof n==`string`&&Xc.test(n)&&n.startsWith(e)||t&&!Yc(n)&&Object.prototype.hasOwnProperty.call(n,t)),Qc=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Jc);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},$c=e=>nc(0,255,e),el={...Gc,transform:e=>Math.round($c(e))},tl={test:Zc(`rgb`,`red`),parse:Qc(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+el.transform(e)+`, `+el.transform(t)+`, `+el.transform(n)+`, `+Rc(Kc.transform(r))+`)`},nl=(e,t,n)=>{let r=e.substring(1+t*n,1+(t+1)*n);return n>1?r:r+r};function rl(e){let t=e.length>5?2:1,n=nl(e,3,t);return{red:parseInt(nl(e,0,t),16),green:parseInt(nl(e,1,t),16),blue:parseInt(nl(e,2,t),16),alpha:n?parseInt(n,16)/255:1}}var il={test:Zc(`#`),parse:rl,transform:tl.transform},al=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),ol=al(`deg`),sl=al(`%`),K=al(`px`),cl=al(`vh`),ll=al(`vw`),ul={...sl,parse:e=>sl.parse(e)/100,transform:e=>sl.transform(e*100)},dl={test:Zc(`hsl`,`hue`),parse:Qc(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+sl.transform(Rc(t))+`, `+sl.transform(Rc(n))+`, `+Rc(Kc.transform(r))+`)`},fl={test:e=>tl.test(e)||il.test(e)||dl.test(e),parse:e=>tl.test(e)?tl.parse(e):dl.test(e)?dl.parse(e):il.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?tl.transform(e):dl.transform(e),getAnimatableNone:e=>{let t=fl.parse(e);return t.alpha=0,fl.transform(t)}},pl=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,ml=new RegExp(Jc.source),hl=new RegExp(pl.source,`i`);function gl(e){return isNaN(e)&&typeof e==`string`&&(ml.test(e)||hl.test(e))}var _l=`number`,vl=`color`,yl=`var`,bl=`var(`,xl="${}",Sl=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)(?![a-z]*\()/giu;function Cl(e){let t=e.toString();return ml.test(t)||hl.test(t)}function wl(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(Sl,e=>(fl.test(e)?(r.color.push(a),i.push(vl),n.push(fl.parse(e))):e.startsWith(bl)?(r.var.push(a),i.push(yl),n.push(e)):(r.number.push(a),i.push(_l),n.push(parseFloat(e))),++a,xl)).split(xl),indexes:r,types:i}}function Tl(e){return wl(e).values}function El({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];i+=e===_l?Rc(r[a]):e===vl?fl.transform(r[a]):r[a]}return i}}function Dl(e){return El(wl(e))}var Ol=e=>typeof e==`number`?0:fl.test(e)?fl.getAnimatableNone(e):e,kl=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:Ol(e);function Al(e){let t=wl(e);return El(t)(t.values.map((e,n)=>kl(e,t.split[n])))}var jl={test:gl,parse:Tl,createTransformer:Dl,getAnimatableNone:Al};function Ml(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Nl({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=Ml(s,r,e+1/3),a=Ml(s,r,e),o=Ml(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Pl(e,t){return n=>n>0?t:e}var Fl=(e,t,n)=>e+(t-e)*n,Il=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Ll=[il,tl,dl],Rl=e=>Ll.find(t=>t.test(e));function zl(e){let t=Rl(e);if(!t)return!1;let n=t.parse(e);return t===dl&&(n=Nl(n)),n}var Bl=(e,t)=>{let n=zl(e),r=zl(t);if(!n||!r)return Pl(e,t);let i={...n};return e=>(i.red=Il(n.red,r.red,e),i.green=Il(n.green,r.green,e),i.blue=Il(n.blue,r.blue,e),i.alpha=Fl(n.alpha,r.alpha,e),tl.transform(i))},Vl=new Set([`none`,`hidden`]);function Hl(e,t){return Vl.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Ul(e,t){return n=>Fl(e,t,n)}function Wl(e){return typeof e==`number`?Ul:typeof e==`string`?Hc(e)?Pl:fl.test(e)?Bl:Jl:Array.isArray(e)?Gl:typeof e==`object`?fl.test(e)?Bl:Kl:Pl}function Gl(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Wl(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function Kl(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Wl(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function ql(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]],s=e.values[o]??0;n[i]=s,r[a]++}return n}var Jl=(e,t)=>{let n=wl(e),r=wl(t);return n.indexes.var.length===r.indexes.var.length&&n.indexes.color.length===r.indexes.color.length&&n.indexes.number.length>=r.indexes.number.length?Vl.has(e)&&!r.values.length||Vl.has(t)&&!n.values.length?Hl(e,t):lc(Gl(ql(n,r),r.values),El(r)):Pl(e,t)},Yl=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function Xl(e,t){let n=Yl.exec(e);if(!n)return;let r=Yl.exec(t);if(!r||n[2]!==r[2])return;let i=n[2],a=parseFloat(n[1]),o=parseFloat(r[1]);return e=>Rc(Fl(a,o,e))+i}function Zl(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return Fl(e,t,n);if(typeof e==`string`&&typeof t==`string`){let n=Xl(e,t);if(n)return n}return Wl(e)(e,t)}var Ql=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function $l(e){let t=new Set,n=new Set,r=!1,i=!1,a,o=new Set,s={delta:0,timestamp:0,isProcessing:!1};function c(t){o.has(t)&&(n.add(t),e()),(a=t)(s)}let l={schedule:(e,i=!1,s=!1)=>{let c=s&&r,l=c?t:n;return i&&o.add(e),c&&e!==a&&l.delete(e),l.add(e),e},cancel:e=>{n.delete(e),o.delete(e)},process:e=>{if(s=e,r){i=!0;return}r=!0;let o=t;t=n,n=o,t.forEach(c),t.clear(),a=void 0,r=!1,i&&(i=!1,l.process(e))}};return l}var eu=40;function tu(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0,a=()=>r=!0,o=Ql.reduce((e,t)=>(e[t]=$l(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=rc.useManualTiming,o=a?n.timestamp:performance.now();r=!1,a||(n.delta=i?1e3/60:Math.max(Math.min(o-n.timestamp,eu),1)),n.timestamp=o,n.isProcessing=!0,s.process(n),c.process(n),l.process(n),u.process(n),d.process(n),f.process(n),p.process(n),m.process(n),n.isProcessing=!1,r&&t&&(i=!1,e(h))},g=()=>{r=!0,i=!0,n.isProcessing||e(h)};return{schedule:Ql.reduce((e,t)=>{let n=o[t];return e[t]=(e,t=!1,i=!1)=>(r||g(),n.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<Ql.length;t++)o[Ql[t]].cancel(e)},state:n,steps:o}}var{schedule:q,cancel:J,steps:nu}=tu(typeof requestAnimationFrame<`u`?requestAnimationFrame:cc,!0,Pc),ru=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>q.update(t,e),stop:()=>J(t),now:()=>Pc.isProcessing?Pc.timestamp:Lc.now()}},iu=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},au=2e4;function ou(e,t=50,n=au,r){let i=0,a=e.next(i);for(r?.push(a.value);!a.done&&i<n;)i+=t,a=e.next(i),r?.push(a.value);return i>=n?1/0:i}function su(e,t=100,n){let{keyframes:r,velocity:i}=e,a=r&&r[r.length-1]-r[0],o=n({...e,velocity:i&&a?i*t/a:i,keyframes:[0,t]}),s=Math.min(ou(o),au);return{type:`keyframes`,ease:e=>o.next(s*e).value/t,duration:pc(s)}}var cu=100,lu=10,uu=1,du=800,fu=.3,pu=.3,mu=.01,hu=2,gu=.005,_u=.5,vu=.01,yu=10,bu=.05,xu=e=>e<0?1/Math.max(1+e,bu):Math.max(1-e,bu);function Su(e,t){if(!(e>1))return 1;let n=Math.sqrt(e*e-1),r=e-n,i=e+n,a=2*n*Math.exp(-t)*(1+t);return Tu(e=>i*Math.exp(-r*e)-r*Math.exp(-i*e)-a,e=>Math.exp(-i*e)-Math.exp(-r*e),t)/t}function Cu(e,t){return e*Math.sqrt(1-t*t)}var wu=12;function Tu(e,t,n){let r=n;for(let n=1;n<wu;n++)r-=e(r)/t(r);return r}var Eu=.001;function Du({duration:e=du,bounce:t=fu}){let n,r,i=xu(t);e=nc(vu,yu,pc(e)),i<1?(n=t=>{let n=t*i,r=n*e,a=Cu(t,i),o=Math.exp(-r);return Eu-n/a*o},r=t=>{let r=t*i*e,a=i*i*t*t*e,o=Math.exp(-r),s=Cu(t*t,i);return(-n(t)+Eu>0?-1:1)*-a*o/s}):(n=t=>-.001+Math.exp(-t*e)*(t*e+1),r=t=>Math.exp(-t*e)*(-t*(e*e)));let a=5/e,o=Tu(n,r,a),s=o*Su(i,o*e),c=s*s;return{stiffness:c,damping:i*2*Math.sqrt(c),duration:fc(e)}}var Ou=(e,t)=>(t?e>=0:e>0)&&e<1/0;function ku(e,t){if(Ou(e,t))return e}function Au(e){let t=ku(e.stiffness),n=ku(e.damping,!0),r=ku(e.mass),i={...e,stiffness:t??cu,damping:n??lu,mass:r??uu,isResolvedFromDuration:!1,isTimeDefined:(t??n??r)===void 0&&(e.duration!==void 0||e.bounce!==void 0)};if(i.isTimeDefined){if(e.visualDuration){let t=xu(e.bounce||0),n=2*Math.PI/(e.visualDuration*1.2)*Su(t,2*Math.PI/1.2);i.stiffness=n*n,i.damping=2*t*Math.sqrt(i.stiffness)}else Object.assign(i,Du(i)),i.isResolvedFromDuration=!0;Ou(i.stiffness)&&Ou(i.damping,!0)||(i.stiffness=cu,i.damping=lu)}return i}function ju(e=pu,t=fu){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},r=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:o,damping:s,mass:c,duration:l,isResolvedFromDuration:u,isTimeDefined:d}=Au({...n}),f=e=>d?0:-pc(e),p=s/(2*Math.sqrt(o*c)),m=pc(Math.sqrt(o/c)),h=p*m,g={target:i,delta:i-r,velocity:f(n.velocity||0)||0,restSpeed:0,restDelta:0},_=()=>{let e=Math.abs(g.delta)<5;g.restSpeed=n.restSpeed||(e?mu:hu),g.restDelta=n.restDelta||(e?gu:_u)};_();let v,y,b;if(p<1){let e=Cu(m,p),t={A:0,sinC:0,cosC:0,t:-1,env:0,sin:0,cos:0};b=()=>{t.A=(g.velocity+h*g.delta)/e,t.sinC=h*t.A+g.delta*e,t.cosC=h*g.delta-t.A*e};let n=n=>{n!==t.t&&(t.t=n,t.env=Math.exp(-h*n),t.sin=Math.sin(e*n),t.cos=Math.cos(e*n))};v=e=>(n(e),g.target-t.env*(t.A*t.sin+g.delta*t.cos)),y=e=>(n(e),t.env*(t.sinC*t.sin+t.cosC*t.cos))}else if(p===1){v=e=>g.target-Math.exp(-m*e)*(g.delta+(g.velocity+m*g.delta)*e);let e={C:0};b=()=>{e.C=g.velocity+m*g.delta},y=t=>Math.exp(-m*t)*(m*e.C*t-g.velocity)}else{let e=m*Math.sqrt(p*p-1),t=h-e,n=h+e,r=e<1||d?1/0:300/e,i=(e,t)=>Math.exp(t>r?(h-e)*r-h*t:-e*t),a={S:0,F:0};b=()=>{let t=(g.velocity+h*g.delta)/e;a.S=(g.delta+t)/2,a.F=(g.delta-t)/2},v=e=>g.target-a.S*i(t,e)-a.F*i(n,e),y=e=>t*a.S*i(t,e)+n*a.F*i(n,e)}b();let x=u&&l||null,S={calculatedDuration:x,retarget:(e,t)=>{g.target=e[e.length-1],g.delta=g.target-e[0],g.velocity=f(t),n.restSpeed&&n.restDelta||_(),S.calculatedDuration=x,a.done=!1,b()},velocity:e=>fc(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=fc(y(e));a.done=Math.abs(n)<=g.restSpeed&&Math.abs(g.target-t)<=g.restDelta}return a.value=a.done?g.target:t,a},toString:()=>{let e=Math.min(ou(S),au),t=iu(t=>S.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return S}var Mu=Object.assign(ju,{applyToOptions:e=>{let t=su(e,100,ju);return e.ease=t.ease,e.duration=fc(t.duration),e.type=`keyframes`,e}});function Nu({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>e<s||e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o?o(g):g;_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>{let t=v(e);f.done=Math.abs(t)<=l,f.value=f.done?_:e?_+t:d},b,x,S=e=>{p(f.value)&&(b=e,x=Mu({keyframes:[f.value,m(f.value)],velocity:-v(e)/r*1e3,damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return S(0),{calculatedDuration:null,next:e=>{let t=!1;return!x&&b===void 0&&(t=!0,y(e),S(e)),b!==void 0&&e>=b?x.next(e-b):(!t&&y(e),f)}}}function Pu(e,t,n){let r=[],i=n||rc.mix||Zl,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=lc(Array.isArray(t)?t[n]||cc:t,a)),r.push(a)}return r}function Fu(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=Pu(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=uc(e[r],e[r+1],n);return s[r](i)};return n?t=>l(nc(e[0],e[a-1],t)):l}function Iu(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=uc(0,t,r);e.push(Fl(n,1,i))}}function Lu(e){let t=[0];return Iu(t,e.length-1),t}function Ru(e,t){return e.map(e=>e*t)}function zu(e,t){return e.map(()=>t||Oc).splice(0,e.length-1)}function Bu({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=kc(r)?r.map(Nc):Nc(r)||Oc,a={done:!1,value:t[0]};if(t.length===2&&!Array.isArray(i)&&(!n||n.length!==2||n[0]===0&&n[1]===1)){let[n,r]=t,o=n===r?void 0:(rc.mix||Zl)(n,r);return{calculatedDuration:e,next:t=>(a.value=o?o(i(e>0?nc(0,1,t/e):1)):r,a.done=t>=e,a)}}let o=Fu(Ru(n&&n.length===t.length?n:Lu(t),e),t,{ease:Array.isArray(i)?i:zu(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var Vu=5;function Hu(e,t,n){let r=Math.max(t-Vu,0);return mc(n-e(r),t-r)}function Uu(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):Hu(t=>e.next(t).value,t,e.next(t).value)}var Wu=e=>e!==null;function Gu(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(Wu),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var Ku={decay:Nu,inertia:Nu,tween:Bu,keyframes:Bu,spring:Mu};function qu(e){typeof e.type==`string`&&(e.type=Ku[e.type])}var Ju=40,Yu=(e,t)=>t-e>Ju&&!rc.useManualTiming?t:e;function Xu(e,t){return{kind:e,animation:t,timestamp:Lc.now(),frameTimestamp:Pc.timestamp,frameIsProcessing:Pc.isProcessing}}function Y(e,t,n){let r=globalThis.__MOTION_INSPECT__;if(r)try{r({...Xu(`animation-start`,e),options:n?{...t,...n}:t})}catch{}}function Zu(e,t){let n=globalThis.__MOTION_INSPECT__;if(n)try{n({...Xu(`layout-animation-start`,e),node:t})}catch{}}var X=class{constructor(){this.isResolved=!1}get finished(){return this._finished||=this.isResolved?Promise.resolve():new Promise(e=>{this._resolve=e}),this._finished}updateFinished(){this._finished=this._resolve=void 0,this.isResolved=!1}notifyFinished(){this.isResolved=!0,this._resolve?.()}then(e,t){return this.finished.then(e,t)}},Z=e=>e/100,Q=e=>Math.round(e*1e4)/1e4,Qu=class extends X{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Lc.now()&&this.tick(Lc.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),Y(this,this.options)}initAnimation(){let{options:e}=this;qu(e);let{type:t=Bu,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||Bu;s!==Bu&&typeof o[0]!=`number`&&(this.mixKeyframes=lc(Z,Zl(o[0],o[1])),o=[0,100]);let c=s(o===e.keyframes?e:{...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=ou(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){this.currentTime=this.holdTime??Math.round(e-this.startTime)*this.playbackSpeed}tick(e,t=!1){let{generator:n,totalDuration:r,calculatedDuration:i}=this;if(this.startTime===null)return n.next(0);let{delay:a=0,keyframes:o,type:s,onUpdate:c,finalKeyframe:l}=this.options;this.startTime===this.pendingStartTime&&(this.startTime=Yu(this.startTime,e)),this.pendingStartTime=void 0,this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let u=this.currentTime-a*(this.playbackSpeed>=0?1:-1),d=this.playbackSpeed>=0?u<0:u>r;this.currentTime=Math.max(u,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let f=this.generate(this.currentTime,d),{done:p}=f;d||(p=this.playbackSpeed>=0?i<1/0?this.currentTime>=r:p:this.currentTime<=0);let m=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&p);return m&&s!==Nu&&(f.value=Gu(o,this.options,l,this.speed)),c&&c(f.value),m&&this.finish(),f}at(e){return this.holdTime??Q((e-this.startTime)*this.playbackSpeed)}sampleAt(e,t){let{options:n,totalDuration:r}=this,i=this.at(e)-(n.delay||0);return i>=r&&n.type!==Nu?Gu(n.keyframes,n,t?void 0:n.finalKeyframe):this.generate(Math.max(i,0),i<0).value}generate(e,t){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o}=this,{keyframes:s,repeat:c,repeatType:l,repeatDelay:u}=this.options,d=e,f=n;if(c){let t=Math.min(e,r)/o,n=Math.floor(t),i=t%1;!i&&t>=1&&(i=1),i===1&&n--,n=Math.min(n,c+1),n%2&&(l===`reverse`?(i=1-i,u&&(i-=u/o)):l===`mirror`&&(f=a)),d=nc(0,1,i)*o}let p;return t?(this.delayState.value=s[0],p=this.delayState):p=f.next(d),i&&!t&&(p.value=i(p.value)),p}get duration(){return pc(this.calculatedDuration)}get iterationDuration(){return this.duration+pc(this.options.delay??0)}get time(){return pc(this.currentTime)}set time(e){e=fc(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){return Uu(this.generator,this.currentTime,this.options.velocity)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Lc.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=pc(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=ru,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??(this.pendingStartTime=n):this.startTime=n-this.holdTime/(this.playbackSpeed||1),this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(Lc.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.driver?.stop(),this.driver=void 0,this.startTime=this.holdTime=null}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}},$u=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function ed(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Jc)||[];if(!r)return e;let i=n.replace(r,``),a=+!!$u.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var td=/\b([a-z-]*)\(.*?\)/gu,nd={...jl,getAnimatableNone:e=>{let t=e.match(td);return t?t.map(ed).join(` `):e}},rd={...jl,getAnimatableNone:e=>{let t=jl.parse(e);return jl.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},id={...Gc,transform:Math.round},ad={rotate:ol,pathRotation:ol,rotateX:ol,rotateY:ol,rotateZ:ol,scale:qc,scaleX:qc,scaleY:qc,scaleZ:qc,skew:ol,skewX:ol,skewY:ol,distance:K,translateX:K,translateY:K,translateZ:K,x:K,y:K,z:K,perspective:K,transformPerspective:K,opacity:Kc,originX:ul,originY:ul,originZ:K},od={borderWidth:K,borderTopWidth:K,borderRightWidth:K,borderBottomWidth:K,borderLeftWidth:K,borderRadius:K,borderTopLeftRadius:K,borderTopRightRadius:K,borderBottomRightRadius:K,borderBottomLeftRadius:K,width:K,maxWidth:K,height:K,maxHeight:K,top:K,right:K,bottom:K,left:K,inset:K,insetBlock:K,insetBlockStart:K,insetBlockEnd:K,insetInline:K,insetInlineStart:K,insetInlineEnd:K,padding:K,paddingTop:K,paddingRight:K,paddingBottom:K,paddingLeft:K,paddingBlock:K,paddingBlockStart:K,paddingBlockEnd:K,paddingInline:K,paddingInlineStart:K,paddingInlineEnd:K,margin:K,marginTop:K,marginRight:K,marginBottom:K,marginLeft:K,marginBlock:K,marginBlockStart:K,marginBlockEnd:K,marginInline:K,marginInlineStart:K,marginInlineEnd:K,fontSize:K,backgroundPositionX:K,backgroundPositionY:K,...ad,zIndex:id,fillOpacity:Kc,strokeOpacity:Kc,numOctaves:id},sd={...od,color:fl,backgroundColor:fl,outlineColor:fl,fill:fl,stroke:fl,borderColor:fl,borderTopColor:fl,borderRightColor:fl,borderBottomColor:fl,borderLeftColor:fl,filter:nd,WebkitFilter:nd,mask:rd,WebkitMask:rd},cd=e=>sd[e],ld=new Set([nd,rd]);function ud(e,t){let n=cd(e);return ld.has(n)||(n=jl),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function dd(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var fd=e=>e*180/Math.PI,pd=e=>hd(fd(Math.atan2(e[1],e[0]))),md={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scaleZ:()=>1,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:pd,rotateZ:pd,skewX:e=>fd(Math.atan(e[1])),skewY:e=>fd(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},hd=e=>(e%=360,e<0&&(e+=360),e),gd=pd,_d=e=>Math.hypot(e[0],e[1]),vd=e=>Math.hypot(e[4],e[5]),yd={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:_d,scaleY:vd,scaleZ:e=>Math.hypot(e[8],e[9],e[10]),scale:e=>(_d(e)+vd(e))/2,rotateX:e=>hd(fd(Math.atan2(e[6],e[5]))),rotateY:e=>hd(fd(Math.atan2(-e[2],e[0]))),rotateZ:gd,rotate:gd,skewX:e=>fd(Math.atan(e[4])),skewY:e=>fd(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function bd(e){return+!!e.includes(`scale`)}function xd(e,t){if(!e||e===`none`)return bd(t);let n=e.match(/^matrix(3d)?\(([-\d.e\s,]+)\)$/u);if(!n)return bd(t);let r=(n[1]?yd:md)[t],i=n[2].split(`,`).map(e=>parseFloat(e));return typeof r==`function`?r(i):i[r]}var Sd=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return xd(n,t)},Cd=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`scaleZ`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],wd=new Set([...Cd,`pathRotation`]),Td=e=>e===Gc||e===K,Ed=new Set([`x`,`y`,`z`]),Dd=Cd.filter(e=>!Ed.has(e));function Od(e){let t=[];return Dd.forEach(n=>{let r=e.getValue(n);if(r!==void 0){let e=r.get(),i=+!!n.startsWith(`scale`);if(e===i)return;t.push([n,e]),r.set(i)}}),t}var kd=new Set([`bottom`,`right`]);function Ad(e,t,n,r,i,a){let o=parseFloat(e);if(!isNaN(o))return o;let{min:s,max:c}=t()[n],l=c-s;return a===`border-box`?l:l-parseFloat(r)-parseFloat(i)}var jd=({transform:e})=>xd(e,`x`),Md=({transform:e})=>xd(e,`y`),Nd={width:({width:e,paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r},i)=>Ad(e,i,`x`,t,n,r),height:({height:e,paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r},i)=>Ad(e,i,`y`,t,n,r),top:({top:e})=>parseFloat(e),left:({left:e})=>parseFloat(e),bottom:({top:e},t)=>{let{y:n}=t();return parseFloat(e)+(n.max-n.min)},right:({left:e},t)=>{let{x:n}=t();return parseFloat(e)+(n.max-n.min)},x:jd,y:Md,translateX:jd,translateY:Md},Pd=new Set,Fd=!1,Id=!1,Ld=!1;function Rd(){if(Id){let e=[],t=new Set,n=new Set;Pd.forEach(r=>{r.needsMeasurement&&(e.push(r),t.add(r.element),kd.has(r.name)&&n.add(r.element))});let r=new Map;n.forEach(e=>{let t=Od(e);t.length&&(r.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=r.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}Id=!1,Fd=!1,Pd.forEach(e=>e.complete(Ld)),Pd.clear()}function zd(){Pd.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Id=!0)})}function Bd(){Ld=!0,zd(),Rd(),Ld=!1}function Vd(e,t,n){if(typeof e==`string`){if(ic(e)||oc(e))return parseFloat(e);if(!jl.test(e)&&jl.test(n))return ud(t,n)}return e??void 0}var Hd=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(Pd.add(this),Fd||(Fd=!0,q.read(zd),q.resolveKeyframes(Rd))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=Vd(n.readValue(t,a),t,a);r!==void 0&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}dd(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Pd.delete(this)}cancel(){this.state===`scheduled`&&(Pd.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Ud=e=>e.startsWith(`--`);function Wd(e,t,n){Ud(t)?e.style.setProperty(t,n):e.style[t]=n}var Gd={};function Kd(e,t){let n=sc(e);return()=>Gd[t]??n()}var qd=Kd(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),Jd=Kd(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),Yd=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Xd={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:Yd([0,.65,.55,1]),circOut:Yd([.55,0,1,.45]),backIn:Yd([.31,.01,.66,-.59]),backOut:Yd([.33,1.53,.69,.99])};function Zd(e,t){if(e)return typeof e==`function`?Jd()?iu(e,t):`ease-out`:Ac(e)?Yd(e):Array.isArray(e)?e.map(e=>Zd(e,t)||Xd.easeOut):Xd[e]}function Qd(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=Zd(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function $d(e){return typeof e==`function`&&`applyToOptions`in e}function ef({type:e,...t}){return $d(e)&&Jd()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var tf=class extends X{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e;let c=ef(e);this.animation=Qd(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=Gu(r,this.options,o,this.speed);this.updateMotionValue?.(e),Wd(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()},Y(this,e,c)}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){this.isStopped||(this.isStopped=!0,this.state!==`idle`&&this.finishedTime===null&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||(this.animation.onfinish=null,this.cancel())))}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return pc(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+pc(e)}get time(){return pc(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=fc(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,onAttach:t,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&qd()?(this.animation.timeline=e,t?.(this.animation),cc):n(this)}},nf={anticipate:Sc,backInOut:xc,circInOut:Tc};function rf(e){return e in nf}function af(e){typeof e.ease==`string`&&rf(e.ease)&&(e.ease=nf[e.ease])}var of=class extends tf{constructor(e){af(e),qu(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}elapsed(){return this.state===`running`?(Lc.now()-this.startTime)*this.speed:this.time*1e3}sample(e){if(!this.sampler){let{motionValue:e,onUpdate:t,onComplete:n,onPlay:r,onStop:i,element:a,...o}=this.options;this.sampler=new Qu({...o,autoplay:!1}),this.sampler.stop()}return this.sampler.sample(Math.max(0,e)).value}liveValue(){let{state:e}=this;if(e===`running`||e===`paused`)return this.sample(this.elapsed())}updateMotionValue(e){let{motionValue:t,element:n,name:r}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let{speed:i}=this,a=this.elapsed(),o=this.state===`running`&&i?nc(0,10,a):0,s=this.sample(a);n&&r&&Wd(n,r,s),t.setWithVelocity(this.sample(a-o*Math.sign(i)),s,o/Math.abs(i||1))}},sf=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(jl.test(e)||e===`0`)&&!e.startsWith(`url(`));function cf(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function lf(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=sf(i,t),s=sf(a,t);return!o||!s?!1:cf(e)||(n===`spring`||$d(n))&&r}function uf(e){e.duration=0,e.type=`keyframes`}var df=new Set([`opacity`,`clipPath`,`filter`,`transform`]),ff=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function pf(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&ff.test(e[t]))return!0;return!1}var mf=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),hf=()=>!rc.useManualTiming&&Object.hasOwnProperty.call(Element.prototype,`animate`);function gf(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!n||!(df.has(n)||mf.has(n)))return!1;let c=t?.owner?.current;if(!(c instanceof HTMLElement)&&!(c instanceof SVGElement))return!1;let{onUpdate:l,transformTemplate:u}=t.owner.getProps();return hf()&&(df.has(n)||mf.has(n)&&pf(s))&&(n!==`transform`||!u)&&!l&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var _f=(e,t)=>t&&typeof e==`number`?t.transform(e):e,vf={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},yf=Cd.length,bf={},xf=(e,t,n=_f(t,ad[e]))=>(bf[e]||(bf[e]=(vf[e]||e)+`(`))+n+`)`,Sf=(e,t)=>(typeof t==`number`?t:parseFloat(t))===+!!e.startsWith(`scale`);function Cf(e,t,n){let r=``;for(let i=0;i<yf;i++){let a=Cd[i],o=e[a];if(o===void 0)continue;let s=n&&(t[a]=_f(o,od[a]));Sf(a,o)||(r+=xf(a,o,s||void 0)+` `)}let i=e.pathRotation;return i&&(r+=xf(`rotate`,i)),r=r.trim(),n?n(t,r):r||`none`}var wf=new WeakMap,Tf=200,Ef=.001,Df=.1,Of=.001,kf=100,Af=e=>/^(linear|ease(In|Out|InOut))$/.test(e),jf=(e,t)=>e-t,Mf=(e,t,n)=>{let r=[];for(let i=0;i<=n;i++)r.push(Fl(e,t,i/n));return r},Nf=e=>e.motionValue.owner,Pf=e=>wf.get(e),Ff=(e,t)=>e.latestValues?e.latestValues[t]:e.getValue(t)?.get(),If=({name:e,motionValue:t})=>e&&Cd.includes(e)&&t?.owner?.current instanceof HTMLElement&&hf()&&Jd();function Lf(e){let t=Nf(e),{onUpdate:n,transformTemplate:r}=t.getProps();return!e.isHandoff&&!n&&!e.hasOnUpdate&&!r&&e.type!==`inertia`&&(Ff(t,`transform`)||`none`)===`none`&&!Ff(t,`pathRotation`)&&!t.projection?.isProjecting()}var Rf=class extends Qu{constructor(e){let t=Nf(e).current,{driver:n=ru}=e,r,i=Lf(e);e.driver=e=>{let i=n(e);return{js:i,now:i.now,start:(e=!0)=>{let n=Pf(t);!n||n.isJS?i.start(e):n.schedule(!1,!e)},stop:()=>{i.stop();let e=Pf(t);e&&!e.isFinishing&&e.release(r)}}},super(e),r=this,this.canAccelerate=i;let{stop:a}=this;this.stop=()=>{this.isAccelerated()&&this.sync(),a()}}get group(){return Pf(Nf(this.options).current)}get js(){return this.driver?.js}get name(){return this.options.name}timing(){let{startTime:e,speed:t,totalDuration:n}=this,{delay:r=0,repeatType:i}=this.options;return this.holdTime===null?n===1/0?[e+r/t,this.resolvedDuration*(i===`loop`?1:2)/t||1]:[e+(r+n)/t,0]:[1/0,0]}isAccelerated(){let{group:e,state:t}=this;return e?.tracks.has(this)&&!e.isJS&&this.canAccelerate&&(t===`running`||t===`paused`)}liveValue(){return this.isAccelerated()?this.sampleAt(Lc.now()):void 0}tween(){let{keyframes:e,type:t,ease:n,times:r,repeat:i,delay:a=0}=this.options,o=Ac(n)?Yd(n):Af(n)&&Xd[n];if(o&&!i&&!r&&e.length===2&&t===Bu&&this.holdTime===null){let e=this.startTime+a/this.speed;return[e,e+this.resolvedDuration/this.speed,o]}}boundaries(e,t){let{startTime:n,speed:r,resolvedDuration:i,options:a}=this,{delay:o=0,repeat:s=0,repeatDelay:c=0,repeatType:l,times:u,keyframes:d,type:f}=a,p=(f||Bu)===Bu?u||Lu(d):[0,1],m=n+o/r,h=[];if(this.holdTime!==null||!(i>0))return h;for(let n=Math.max(0,Math.floor((e-m)*r/i));n<=s;n++){let a=m+n*i/r;if(a>t)break;for(let o of p){let s=a+(n%2&&l&&l!==`loop`?1-o:o)*(i-c)/r;s>e&&s<t&&h.push(s)}}return h}numberAt(e){return parseFloat(this.sampleAt(e,!0))}sync(){let e=Lc.now();this.options.motionValue.setWithVelocity(this.sampleAt(e-10,!0),this.sampleAt(e,!0),10)}play(){this.isStopped||((this.group||zf(Nf(this.options))).tracks.add(this),super.play())}pause(){super.pause(),this.isAccelerated()&&(this.sync(),this.group.schedule(!1))}complete(){super.complete();let{group:e}=this;e&&!e.isJS&&this.canAccelerate&&this.tick(Lc.now())}get time(){return this.isAccelerated()?pc(nc(0,this.totalDuration,this.at(Lc.now())-(this.options.delay||0))):super.time}set time(e){super.time=e,this.isAccelerated()&&this.sync()}attachTimeline(e){return this.canAccelerate=!1,this.group?.demote(!0),super.attachTimeline(e)}};function zf(e){let t=e.current,n=new Set,r=new Map,i={},a=[],o=new Map,s=[],c=!1,l=!1,u=!1,d=!1,f=-1/0,p=e=>{for(let t of n)if(t.name===e)return!0},m=(t,n)=>{let o={};for(let s of t===void 0?Cd:a){let a=r.get(s),c=t===void 0?Ff(e,s):a?a.sampleAt(n>t&&!a.timing()[1]?n:t):i[s];c!==void 0&&(o[s]=c)}return o},h=(e,t)=>{let n=``;for(let r in e){let i=e[r];t&&Sf(r,i)||(n+=xf(r,i)+` `)}return(t?n.trim():n)||`none`},g=(e,t)=>h(m(e,t)),_=(e=m())=>{t.style.transform=h(e,!0)},v=(e=!0)=>{e&&_(),s.forEach(({animation:e})=>e.cancel()),s=[]},y=(e,n)=>new Animation(new KeyframeEffect(t,e,n)),b=(e,t,n=1/0)=>{let r={animation:e,offset:t,end:n};e.startTime=Lc.now()+t,n<1/0&&(e.onfinish=()=>{r.isDone=!0,s.some(e=>e.end===1/0)&&(e.cancel(),s=s.filter(e=>e!==r)),O.schedule(!1)}),e.oncancel=()=>s.includes(r)&&O.demote(),s.push(r)},x=(e,t,n)=>{let r=(t,n)=>Math.abs(e(n)-e(t)),i=r(t,n);for(;n-t>.01;){let e=(t+n)/2;r(t,e)>r(e,n)?n=e:t=e}return r(t,n)>i/2?[t,n]:[]},S=(e,t,n,r)=>{let i=Math.min(Tf,Math.max(2,Math.ceil((n-t)/10)));if(r.length*4>i)return;let a=Mf(t,n,i).concat(r).sort(jf),o=e=>uc(t,n,e),s,c;for(let t of e){let e=a.map(e=>t.numberAt(e)),[n]=e,r=e.map(e=>e-n),i=r[r.length-1],o=r.some(e=>Math.abs(e)*Ef>Math.abs(i))?0:i,l=r.map(e=>o?e/o:e);if(!o){if(l.some(e=>!(Math.abs(e)<=Ef)))return}else if(!s)s=l,c=e=>(t.numberAt(e)-n)/o;else if(l.some((e,t)=>!(Math.abs(e-s[t])<=Ef)))return}if(!s||s.every((e,t)=>Math.abs(e-o(a[t]))<=Ef))return`linear`;let l=[],u=(e,t=c(e))=>l.push(Q(t)+` `+Q(o(e)*100)+`%`);return s.forEach((e,t)=>{t&&Math.abs(e-s[t-1])>.2&&x(c,a[t-1],a[t]).forEach(e=>u(e)),u(a[t],e)}),`linear(`+l+`)`},C=(e,t,n,r)=>{let i=[t],a=(t,n)=>e.every(e=>!(Math.abs(e.numberAt((t+n)/2)-(e.numberAt(t)+e.numberAt(n))/2)>(e.name.startsWith(`scale`)?Of:Df))),o=(t,n,r)=>{if(n-t<1||a(t,n))i.push(n);else if(r<4)o(t,(t+n)/2,r+1),o((t+n)/2,n,r+1);else{for(let r of e)i.push(...x(e=>r.numberAt(e),t,n));i.push(n)}},s=Mf(t,n,Math.ceil((n-t)/100));for(let e of r)s.push(e,Math.min(e+.01,n));let c=t;for(let e of s.sort(jf))e>c&&o(c,e,0),c=e;return i.sort(jf)},w=e=>{let t;for(let n of e){let e=n.tween();if(!e||t?.some((t,n)=>n<2?Math.abs(e[n]-t)>1:e[n]!==t))return;t=e}return t},T=(e,t,n,r={fill:`both`},i,a)=>{let o=e.flatMap(e=>e.boundaries(t,n)),s=a||S(e,t,n,o),c=s?[t,n]:C(e,t,n,o),l=c.map(e=>g(e,i)),u={transform:l};return s||(u.offset=c.map(e=>uc(t,n,e))),l.every(e=>e===l[0])&&(_(m(t,i)),u=null),y(u,{...r,duration:n-t,easing:s||`linear`})},ee=t=>{let c=t,l=0,u=0,d=[],f=[],p=new Set;r.clear(),o=new Map;for(let e of n){r.set(e.name,e);let[n,i]=e.timing(),a=n===1/0;if(o.set(e,[e.at(t),e.speed,a]),a)e.sync();else{if(e.speed<0)return;if(i){if(l){let e=(n-u)/i;if(Math.abs(i-l)>1||Math.abs(e-Math.round(e))*l>1)return}else l=i,u=n;f.push(e)}else p.add(n);d.push(e),c=Math.max(c,n)}}i={},a=Cd.filter(t=>{if(r.has(t))return!0;let n=i[t]=Ff(e,t);return n!==void 0&&parseFloat(n)!==+!!t.startsWith(`scale`)}),v(!1);let m=!l&&w(d);try{if(m&&m[1]>t){let[e,n,r]=m;b(T(d,e,n,void 0,void 0,r),e-t,n-e)}else c>t&&(b(T(d,t,c),0,c-t),p.forEach(e=>e<c-1&&b(y(null,{duration:e-t}),0,e-t)));if(l){let e=u+Math.floor((c-u)/l)*l;b(T(f,e,e+l,{iterations:1/0,iterationStart:(c-e)/l,fill:`forwards`},c),c-t)}}catch{return}return s.length||v(),!0},E=e=>{let t,r=0;for(let i of n){let n=o.get(i);if(!n)return!1;let[a,s,c]=n,l=i.at(e),u=i.timing()[0]===1/0;if(c){if(u&&l===a)continue;return!1}let d=(l-a)/s,f=u?0:i.speed/s;if(t===void 0)t=d,r=f;else if(Math.abs(d-t)>1||f!==r)return!1}if(t===void 0)return!0;if(!s.length)return!1;for(let{offset:e,end:n,isDone:r}of s){let i=t-e;if(n<1/0&&(r?i<n-1:i<0||i>=n))return!1}for(let{animation:n,offset:i,isDone:a}of s){if(a)continue;let o=t-i;r&&n.updatePlaybackRate&&n.playState===`running`&&Math.abs(Number(n.currentTime)-o)<20?n.playbackRate!==r&&n.updatePlaybackRate(r):r?(n.playbackRate=r,n.startTime=e-o/r):(n.startTime=null,n.currentTime=o)}return!0},te=()=>!n.size&&(u=!0,Pf(t)===O&&wf.delete(t),O.isJS||v(),!0),D=()=>{let t=Lc.now();if(O.isJS||(O.isFinishing=!0,n.forEach(n=>{let[r,a]=n.timing();n.state===`running`&&n.speed>0&&!a&&r<=t+1&&(n.complete(),i[n.name]=Ff(e,n.name),o.has(n)||(c=!0))}),O.isFinishing=!1),l=!1,u||(n.forEach(({state:e},t)=>{(e===`idle`||e===`finished`)&&n.delete(t)}),te()))return;for(let e of n)if(!e.canAccelerate)return O.demote(!0);O.isJS&&(O.isJS=!1,c=!0,n.forEach(e=>e.js?.stop()));let r=c,a=d;if(c=d=!1,r||!E(t)){if(a){if(t-f<kf)return O.demote();f=t}if(!ee(t))return O.demote()}},O={tracks:n,isJS:!1,isFinishing:!1,schedule(e,t){u||(c||=e,d||=!!t,l||(l=!0,Pc.isProcessing?q.render(D,!1,!0):queueMicrotask(D)))},release(e){let{state:t}=e;(t===`idle`||t===`finished`)&&n.delete(e),te()||O.schedule(!0)},check(){if(!O.isJS){for(let t in i)if(Ff(e,t)!==i[t]&&!p(t))return O.schedule(!0,!0)}},demote(e){if(!(O.isJS||u))return n.forEach(t=>{t.isAccelerated()&&t.sync(),e||(t.canAccelerate=!1)}),O.isJS=!0,o=new Map,v(),n.forEach(e=>e.state===`running`&&e.js?.start()),!0}};return wf.set(t,O),O}var Bf=class extends X{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Lc.now();let{keyframes:t,name:n,motionValue:r,element:i}=e,a=e;a.autoplay??=!0,a.delay??=0,a.type??=`keyframes`,a.repeat??=0,a.repeatDelay??=0,a.repeatType??=`loop`;let o=i?.KeyframeResolver||Hd;this.keyframeResolver=new o(t,(e,t,n)=>this.onKeyframesResolved(e,t,a,!n),n,r,i),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=Lc.now();let u=lf(e,i,a,o);u||((rc.instantAnimations||!s)&&l?.(Gu(e,n,t)),e[0]=e[e.length-1],uf(n),n.repeat=0);let{onComplete:d}=n;n.finalKeyframe=t,n.keyframes=e,n.onComplete=()=>{d?.(),this.notifyFinished()};let f=u&&!c&&gf(n),p=!f&&If(n);r&&(f||p||this.resolvedAt!==this.createdAt)&&(n.startTime??=Yu(this.createdAt,this.resolvedAt));let m;if(f){n.element=n.motionValue?.owner?.current;try{m=new of(n)}catch{m=new Qu(n)}}else m=p?new Rf(n):new Qu(n);this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this._animation.finished:super.finished}then(e,t){return this.finished.finally(e).then(()=>{})}liveValue(){return this._animation?.liveValue?.()}get animation(){return this._animation||(this.keyframeResolver?.resume(),Bd()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation?.cancel(),this.keyframeResolver?.cancel()}};function $(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var Vf=30,Hf=e=>!isNaN(parseFloat(e)),Uf={current:void 0},Wf=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Lc.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.dirty(),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Lc.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Hf(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){var n;return e===`change`?this.onChangeSubscribe(t):((n=this.events)[e]||(n[e]=new dc)).add(t)}onChangeSubscribe(e){let{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new dc,t.change.add(this.changeSubscriber),this.changeSubscriber=void 0),t.change.add(e)),()=>{this.changeSubscriber===e?this.changeSubscriber=void 0:t.change?.remove(e),this.stopIfUnobserved()}}stopIfUnobserved(){q.read(()=>{!this.changeSubscriber&&!this.events.change?.getSize()&&this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect?.()}dirty(){let{current:e,changeSubscriber:t}=this;t?t(e):this.events.change?.notify(e)}addDependent(e){(this.dependents||=new Set).add(e)}removeDependent(e){this.dependents?.delete(e)}get(){Uf.current?.push(this);let e=this.animation?.liveValue?.();return e===void 0?this.current:e}getCurrent(){return this.current}getPrevious(){return this.prev}getVelocity(){let e=Lc.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Vf)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Vf);return mc(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0;let n=!1,r;r=e(()=>{n=!0,this.events.animationComplete?.notify(),this.animation===r&&(this.animation=void 0),t()}),n||(this.animation=r),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel?.notify()),this.animation=void 0}isAnimating(){return!!this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect?.()}};function Gf(e,t){return new Wf(e,t)}function Kf(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function qf(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Kf(n,e)}var Jf={type:`spring`,stiffness:500,damping:25,restSpeed:10},Yf=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Xf={type:`keyframes`,duration:.8},Zf={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Qf=(e,{keyframes:t})=>t.length>2?Xf:wd.has(e)?e.startsWith(`scale`)?Yf(t[1]):Jf:Zf,$f=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`,`out`]);function ep(e){for(let t in e)if(!$f.has(t))return!0;return!1}var tp=(e,t,n,r={},i,a)=>o=>{let s=qf(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=fc(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i,hasOnUpdate:!!s.onUpdate};ep(s)||Object.assign(u,Qf(e,u)),u.duration&&=fc(u.duration),u.repeatDelay&&=fc(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(uf(u),u.delay===0&&(d=!0)),(rc.instantAnimations||rc.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,uf(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=Gu(u.keyframes,s);if(e!==void 0){q.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new Qu(u):new Bf(u)},np=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function rp(e){let t=np.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function ip(e,t,n=1){let[r,i]=rp(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return ic(e)?parseFloat(e):e}return Hc(i)?ip(i,t,n+1):i}function ap(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function op(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...ap(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function sp(e,t,n){return op(e.getProps(),t,n,e)}var cp=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,lp=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...Cd]),up=e=>Array.isArray(e);function dp(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Gf(n))}function fp(e){return up(e)?e[e.length-1]||0:e}function pp(e,t){let{transitionEnd:n={},transition:r={},...i}=sp(e,t)||{};i={...i,...n};for(let t in i)dp(e,t,fp(i[t]))}var mp=e=>!!(e&&e.getVelocity);function hp(e){return!!(mp(e)&&e.add)}function gp(e,t){let n=e.getValue(`willChange`);if(hp(n))return n.add(t);if(!n&&rc.WillChange){let n=new rc.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}var _p=`data-framer-appear-id`;function vp(e){return e.props[_p]}var yp=typeof window<`u`;function bp({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function xp(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Kf(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState?.getState()[i],p=a?.path;p&&(p.animateValues?p.animateValues(t=>e.getValue(t,e.latestValues[t]??0),s,a,n,d):p.animateVisualElement?.(e,s,a,n,d));for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&bp(f,t))continue;let o={delay:n,...qf(f?.out[t]||a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){q.update(()=>r.set(i));continue}let p=!1;if(yp&&window.MotionHandoffAnimation){let n=vp(e);if(n){let e=window.MotionHandoffAnimation(n,t,q);e!==null&&(o.startTime=e,p=!0)}}gp(e,t);let m=l??e.shouldReduceMotion;r.start(tp(t,r,i,m&&lp.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>q.update(()=>{o&&pp(e,o)});d.length?Promise.all(d).then(t):t()}return d}function Sp(e,t,n={}){let r=sp(e,t,cp(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?xp(e,r,n):[]),o=(r=0)=>{let{variantChildren:a}=e,{delayChildren:o=0,staggerChildren:s,staggerDirection:c}=i,l=[];return a?.forEach(e=>{e.notify(`AnimationStart`,t),l.push(Sp(e,t,{...n,delay:r+(typeof o==`function`?0:o)+$(a,e,o,s,c)}).then(()=>e.notify(`AnimationComplete`,t)))}),Promise.all(l)},{when:s}=i;return s?s===`beforeChildren`?a().then(()=>o()):o().then(a):Promise.all([a(),o(n.delay)])}function Cp(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>Sp(e,t,n))):typeof t==`string`?Sp(e,t,n):Promise.all(xp(e,sp(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var wp={test:e=>e===`auto`,parse:e=>e},Tp=e=>t=>t.test(e),Ep=[Gc,K,sl,ol,ll,cl,wp],Dp=e=>Ep.find(Tp(e));function Op(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||oc(e)}var kp=new Set([`auto`,`none`,`0`]);function Ap(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!kp.has(t)&&Cl(t)&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]!==i&&(e[r]=ud(n,i))}var jp=class extends Hd{constructor(){super(...arguments),this.isAsync=!0}scheduleResolve(){if(this.canReadNow()&&(this.readKeyframes(),!this.needsMeasurement))return this.complete();super.scheduleResolve()}canReadNow(){let{unresolvedKeyframes:e,element:t,motionValue:n}=this,r=e[0]??n?.get();if(!t?.current||r===void 0)return!1;for(let t=0;t<e.length;t++)if(Wc(t?e[t]:r))return!1;return!0}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t?.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Hc(r))){let i=ip(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!lp.has(n)||e.length!==2)return;let[r,i]=e;if(typeof r==`number`&&typeof i==`number`)return;let a=Dp(r),o=Dp(i);if(Wc(r)!==Wc(i)&&Nd[n])this.needsMeasurement=!0;else if(a!==o){if(Td(a)&&Td(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Nd[n]&&(this.needsMeasurement=!0)}}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||Op(e[t]))&&n.push(t);n.length&&Ap(e,n,t)}measure(){let{element:e,name:t}=this;return Nd[t](window.getComputedStyle(e.current),()=>e.measureViewportBox())}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e?.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=this.measure(),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&this.motionValue?.jump(r,!1)}measureEndState(){let{element:e,unresolvedKeyframes:t}=this;if(!e?.current)return;this.motionValue?.jump(this.measuredOrigin,!1);let n=t.length-1,r=t[n];t[n]=this.measure(),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.resolveNoneKeyframes()}},Mp=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function Np(e){return ac(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function Pp(e){return ac(e)&&`ownerSVGElement`in e}var Fp={};function Ip(e){return Fp.current?.add(e),e}var Lp=e=>Fp.current?Fp.current.bind(e):e;function Rp(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=t?t.current:Fp.current?.root||document,i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}function zp(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}function Bp(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(wd.has(e))o=!0;else if(Bc(e))i[e]=n;else{let t=_f(n,od[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=Cf(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}var Vp={offset:`stroke-dashoffset`,array:`stroke-dasharray`},Hp={offset:`strokeDashoffset`,array:`strokeDasharray`};function Up(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?Vp:Hp;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var Wp=[`transform`,`opacity`,`clipPath`,`filter`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function Gp(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(Bp(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;for(let e of Wp)d[e]!==void 0&&(f[e]=d[e],delete d[e]);(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&Up(d,i,a,o,!1)}function Kp({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function qp({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Jp(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Yp(e){return e===void 0||e===1}function Xp({scale:e,scaleX:t,scaleY:n}){return!Yp(e)||!Yp(t)||!Yp(n)}var Zp=[`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skewX`,`skewY`];function Qp(e){return Xp(e)||em(e)||$p(e)}function $p(e){return e.z||e.rotate||e.rotateX||e.rotateY||e.rotateZ||e.skewX||e.skewY}function em(e){return tm(e.x)||tm(e.y)}function tm(e){return e&&e!==`0%`}function nm(e,t,n){return n+t*(e-n)}function rm(e,t,n,r,i){return i!==void 0&&(e=nm(e,i,r)),nm(e,n,r)+t}function im(e,t=0,n=1,r,i){e.min=rm(e.min,t,n,r,i),e.max=rm(e.max,t,n,r,i)}function am(e,{x:t,y:n}){im(e.x,t.translate,t.scale,t.originPoint),im(e.y,n.translate,n.scale,n.originPoint)}var om=.999999999999,sm=1.0000000000001;function cm(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++)a=n[s],o=a.projectionDelta,a.options.visualElement?.props.style?.display!==`contents`&&(r===!0&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(lm(e.x,-a.scroll.offset.x),lm(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,am(e,o)),r&&(r.path?.[s]||r)!==a&&Qp(a.latestValues)&&fm(e,a.latestValues,a.layout?.layoutBox));t.x<sm&&t.x>om&&(t.x=1),t.y<sm&&t.y>om&&(t.y=1)}function lm(e,t){e.min+=t,e.max+=t}function um(e,t,n,r,i=.5){im(e,t,n,Fl(e.min,e.max,i),r)}function dm(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function fm(e,t,n){let r=n??e;um(e.x,dm(t.x,r.x),t.scaleX,t.scale,t.originX),um(e.y,dm(t.y,r.y),t.scaleY,t.scale,t.originY)}function pm(e,t){return Kp(Jp(e.getBoundingClientRect(),t))}function mm(e,t,n){let r=pm(e,n),{scroll:i}=t;return i&&(lm(r.x,i.offset.x),lm(r.y,i.offset.y)),r}var{schedule:hm,cancel:gm}=tu(queueMicrotask,!1);function _m(e,t,n){let r=mp(e)?e:Gf(e);return r.start(tp(``,r,t,n)),r.animation}var vm={},ym={value:null,addProjectionMetrics:null};function bm(e,t){let n=Lc.now();e=Lp(e);let r=({timestamp:i})=>{let a=i-n;a>=t&&(J(r),e(a-t))};return q.setup(r,!0),Ip(()=>J(r))}function xm(e){return Pp(e)&&e.tagName===`svg`}function Sm(e){return mp(e)?e.get():e}var Cm=e=>typeof e==`number`?e:parseFloat(e),wm=Mp.length,Tm=e=>typeof e==`number`||K.test(e);function Em(e,t,n,r,i,a){i?(e.opacity=Fl(0,n.opacity??1,Om(r)),e.opacityExit=Fl(t.opacity??1,0,km(r))):a&&(e.opacity=Fl(t.opacity??1,n.opacity??1,r));for(let i=0;i<wm;i++){let a=Mp[i],o=Dm(t,a),s=Dm(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||Tm(o)===Tm(s)?(e[a]=Math.max(Fl(Cm(o),Cm(s),r),0),(sl.test(s)||sl.test(o))&&(e[a]+=`%`)):e[a]=s)}for(let i=0;i<Zp.length;i++){let a=Zp[i];(t[a]||n[a])&&(e[a]=Fl(t[a]||0,n[a]||0,r))}}function Dm(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Om=Am(0,.5,wc),km=Am(.5,.95,cc);function Am(e,t,n){return r=>r<e?0:r>t?1:n(uc(e,t,r))}function jm(e,t){e.min=t.min,e.max=t.max}function Mm(e,t){jm(e.x,t.x),jm(e.y,t.y)}function Nm(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Pm=.9999,Fm=1.0001,Im=-.01,Lm=.01;function Rm(e){return e.max-e.min}function zm(e,t,n){return Math.abs(e-t)<=n}function Bm(e,t,n,r=.5){e.origin=r,e.originPoint=Fl(t.min,t.max,e.origin),e.scale=Rm(n)/Rm(t),e.translate=Fl(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Pm&&e.scale<=Fm||isNaN(e.scale))&&(e.scale=1),(e.translate>=Im&&e.translate<=Lm||isNaN(e.translate))&&(e.translate=0)}function Vm(e,t,n,r){Bm(e.x,t.x,n.x,r?.originX),Bm(e.y,t.y,n.y,r?.originY)}function Hm(e,t,n,r=0){e.min=(r?Fl(n.min,n.max,r):n.min)+t.min,e.max=e.min+Rm(t)}function Um(e,t,n,r){Hm(e.x,t.x,n.x,r?.x),Hm(e.y,t.y,n.y,r?.y)}function Wm(e,t,n,r=0){let i=r?Fl(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Rm(t)}function Gm(e,t,n,r){Wm(e.x,t.x,n.x,r?.x),Wm(e.y,t.y,n.y,r?.y)}function Km(e,t,n,r,i){return e-=t,e=nm(e,1/n,r),i!==void 0&&(e=nm(e,1/i,r)),e}function qm(e,t=0,n=1,r=.5,i,a=e,o=e){if(sl.test(t)&&(t=parseFloat(t),t=Fl(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Fl(a.min,a.max,r);e===a&&(s-=t),e.min=Km(e.min,t,n,s,i),e.max=Km(e.max,t,n,s,i)}function Jm(e,t,[n,r,i],a,o){qm(e,t[n],t[r],t[i],t.scale,a,o)}var Ym=[`x`,`scaleX`,`originX`],Xm=[`y`,`scaleY`,`originY`];function Zm(e,t,n,r){Jm(e.x,t,Ym,n?.x,r?.x),Jm(e.y,t,Xm,n?.y,r?.y)}var Qm=()=>({translate:0,scale:1,origin:0,originPoint:0}),$m=()=>({x:Qm(),y:Qm()}),eh=()=>({min:0,max:0}),th=()=>({x:eh(),y:eh()});function nh(e){return e.translate===0&&e.scale===1}function rh(e){return nh(e.x)&&nh(e.y)}function ih(e,t){return e.min===t.min&&e.max===t.max}function ah(e,t){return ih(e.x,t.x)&&ih(e.y,t.y)}function oh(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function sh(e,t){return oh(e.x,t.x)&&oh(e.y,t.y)}function ch(e){return Rm(e.x)/Rm(e.y)}function lh(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}var uh=class{constructor(){this.members=[]}add(e){ec(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;r&&r.isConnected!==!1||n.snapshot||(tc(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(tc(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}};function dh(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var fh={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if(K.test(e))e=parseFloat(e);else return e}return`${dh(e,t.target.x)}% ${dh(e,t.target.y)}%`}},ph={borderRadius:Object.assign({},fh,{applyTo:Mp.slice()}),borderTopLeftRadius:fh,borderTopRightRadius:fh,borderBottomLeftRadius:fh,borderBottomRightRadius:fh,boxShadow:{correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=jl.parse(e);if(i.length>5)return r;let a=jl.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=Fl(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}}};function mh(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e}=n;e&&(r=`perspective(${e}px) ${r}`);for(let e=0;e<Zp.length;e++){let t=Zp[e],i=n[t];i&&(r+=`${t}(${i}deg) `),!e&&n.pathRotation&&(r+=`rotate(${n.pathRotation}deg) `)}}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}function hh(e){return[e(`x`),e(`y`)]}var gh=(e,t)=>e.depth-t.depth,_h=class{constructor(){this.children=[],this.isDirty=!1}add(e){ec(this.children,e),this.isDirty=!0}remove(e){tc(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(gh),this.isDirty=!1,this.children.forEach(e)}},vh={hasAnimatedSinceResize:!0,hasEverUpdated:!1},yh={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},bh=[`z`,`skew`,`skewZ`],xh=1e3,Sh=0;function Ch(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}var wh=e=>e.instance&&wf.get(e.instance)?.demote()&&e.resetSkewAndRotation();function Th(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=vp(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,q,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Th(r)}function Eh({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return Object.assign(vm,{...ph,...vm}),class{constructor(e={},n=t?.()){this.id=Sh++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,ym.value&&(yh.nodes=yh.calculatedTargetDeltas=yh.calculatedProjections=0),this.nodes.forEach(kh),this.nodes.forEach(Bh),this.nodes.forEach(Vh),this.nodes.forEach(Ah),ym.addProjectionMetrics&&ym.addProjectionMetrics(yh)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new _h)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new dc),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){this.eventHandlers.get(e)?.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=Pp(t)&&!xm(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent?.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;q.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n?.(),n=bm(i,250),vh.hasAnimatedSinceResize&&(vh.hasAnimatedSinceResize=!1,this.nodes.forEach(zh)))})}n&&this.root.registerSharedNode(n,this),this.addLayoutListener()}addLayoutListener(){let{layoutId:e,layout:t,visualElement:n,animate:r}=this.options;this.instance&&!this.hasLayoutListener&&r!==!1&&n&&(e||t)&&(this.hasLayoutListener=!0,this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:r,layout:i})=>{if(this.isAnimationBlocked){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||n.getDefaultTransition()||qh,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=n.getProps(),c=!this.targetLayout||!sh(this.targetLayout,i),l=!t&&r;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...qf(a,`layout`),onPlay:o,onComplete:s};(n.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||zh(this),this.isLead()&&this.options.onExitComplete?.();this.targetLayout=i}))}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this),this.getStack()?.remove(this),this.parent?.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),this.hasLayoutListener=!1,J(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes?.forEach(Hh),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete?.();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Th(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;wh(this),this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,wh(t),(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1),t.isAnimationBlocked&&(t.dragSnapshot||=t.measure(),this.dragAncestor=t)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(Nh),this.nodes.forEach(Mh);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Ph);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Ih),this.nodes.forEach(Lh),this.nodes.forEach(Rh),this.nodes.forEach(Dh),this.nodes.forEach(Oh)):this.nodes.forEach(Ph),this.clearAllSnapshots();let e=Lc.now();Pc.delta=nc(0,1e3/60,e-Pc.timestamp),Pc.timestamp=e,Pc.isProcessing=!0,nu.update.process(Pc),nu.preRender.process(Pc),nu.render.process(Pc),Pc.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,hm.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(jh),this.sharedNodes.forEach((e,t)=>e.members.length?e.removeLeadSnapshot():this.sharedNodes.delete(t))}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,q.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){q.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),this.snapshot&&!Rm(this.snapshot.measuredBox.x)&&!Rm(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutCorrected||=th(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t?.notify(`LayoutMeasure`,this.layout.layoutBox,e?.layoutBox)}updateScroll(e=`measure`){let{scroll:t,instance:i}=this,{animationId:a}=this.root;if(this.options.layoutScroll&&i&&!(t&&t.animationId===a&&t.phase===e)){let o=r(i);this.scroll={animationId:a,phase:e,isRoot:o,offset:n(i),wasRoot:t?t.isRoot:o}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout;e&&wh(this);let t=this.projectionDelta&&!rh(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Qp(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),Zh(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return th();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(eg))){let{scroll:e}=this.root;e&&(lm(t.x,e.offset.x),lm(t.y,e.offset.y))}return t}removeElementScroll(e){let t=th();if(Mm(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&Mm(t,e),lm(t.x,i.offset.x),lm(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n,r,i=0){let a=n||th();Mm(a,e);for(let e=i;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(lm(a.x,-n.scroll.offset.x),lm(a.y,-n.scroll.offset.y)),Qp(n.latestValues)&&fm(a,n.latestValues,n.layout?.layoutBox)}return!r&&Qp(this.latestValues)&&fm(a,this.latestValues,this.layout?.layoutBox),a}removeTransform(e){let t=th();Mm(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Qp(n.latestValues))continue;let r;n.instance&&(Xp(n.latestValues)&&n.updateSnapshot(),r=th(),Mm(r,n.measurePageBox())),Zm(t,n.latestValues,n.snapshot?.layoutBox,r)}return Qp(this.latestValues)&&Zm(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade},this.addLayoutListener()}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Pc.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=Pc.timestamp;let a=this.getClosestProjectingParent();!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),(this.relativeTarget||this.targetDelta)&&(this.target||(this.target=th(),this.targetWithTransforms=th()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Um(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target,!0):Mm(this.target,this.layout.layoutBox),am(this.target,this.targetDelta)):Mm(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&(!a.resumingFrom==!this.resumingFrom||a.options.layoutRoot&&!a.resumingFrom)&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),ym.value&&yh.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Xp(this.parent.latestValues)||em(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget=th(),this.relativeTargetOrigin=th(),Gm(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Mm(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Pc.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent?.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;Mm(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;cm(this.layoutCorrected,this.treeScale,this.path,t&&(e.relativeTarget&&!e.relativeParent.resumingFrom?e.relativeParent:!0)),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=th());let{target:s}=e;s?(!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Nm(this.prevProjectionDelta.x,this.projectionDelta.x),Nm(this.prevProjectionDelta.y,this.projectionDelta.y)),Vm(this.projectionDelta,this.layoutCorrected,s,this.latestValues),this.treeScale.x===a&&this.treeScale.y===o&&lh(this.projectionDelta.x,this.prevProjectionDelta.x)&&lh(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),ym.value&&yh.calculatedProjections++):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){this.options.visualElement?.scheduleRender(),e&&this.getStack()?.scheduleRender(),this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=$m(),this.projectionDelta=$m(),this.projectionDeltaWithTransform=$m()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=$m();this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=th(),c=r?.source!==this.layout?.source,l=this.getStack(),u=!l||l.members.length<=1,d=!(!c||u||this.options.crossfade!==!0||this.path.some(Kh));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);Uh(o.x,e.x,n),Uh(o.y,e.y,n),r&&(o.x.translate=r.x,o.y.translate=r.y),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Gm(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),Gh(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&ah(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=th(),Mm(f,this.relativeTarget)),c&&(this.animationValues=a,Em(a,i,this.latestValues,n,d,u)),r?.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(J(this.pendingAnimation),void 0),this.pendingAnimation=q.update(()=>{vh.hasAnimatedSinceResize=!0,this.motionValue||=Gf(0),this.motionValue.jump(0,!1),this.currentAnimation=_m(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),Zu(this.currentAnimation,this),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta?.(xh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,layout:n,latestValues:r}=e,{target:i}=e;if(t&&i&&n){if(this!==e&&this.layout&&n&&$h(this.options.animationType,this.layout.layoutBox,n.layoutBox)){let{layoutBox:e}=this.layout,t=i;i=this.target||th(),Qh(i.x,t.x,e.x),Qh(i.y,t.y,e.y)}Mm(t,i),fm(t,r),Vm(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new uh),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?.transition,preserveFollowOpacity:n?.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){this.getStack()?.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){return this.getStack()?.relegate(this)||!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let{latestValues:t}=e;if(!$p(t))return;let n={};for(let t=0;t<bh.length;t++)Ch(bh[t],e,n,this.animationValues);for(let t=0;t<Zp.length;t++)Ch(Zp[t],e,n,this.animationValues);e.render();for(let t in n)e.setStaticValue(t,n[t]),this.animationValues&&(this.animationValues[t]=n[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;let n=this.getLead();if(!this.isVisible&&n!==this){e.visibility=`hidden`;return}let r=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=Sm(t?.pointerEvents)||``,e.transform=r?r(this.latestValues,``):`none`;return}if(!this.projectionDelta||!this.layout||!n.target){(this.options.layoutId||this.needsShow)&&(this.needsShow=!1,e.visibility=``,e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=Sm(t?.pointerEvents)||``),this.hasProjected&&!Qp(this.latestValues)&&(e.transform=r?r({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=n.animationValues||n.latestValues;this.applyTransformsToTarget();let a=mh(this.projectionDeltaWithTransform,this.treeScale,i);r&&(a=r(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,e.opacity=n.animationValues?n===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:n===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in vm){if(i[t]===void 0)continue;let{correct:r,applyTo:o,isCSSVariable:s}=vm[t],c=a===`none`?i[t]:r(i[t],n);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=n===this?Sm(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=this.dragSnapshot=this.dragAncestor=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(Mh),this.root.sharedNodes.clear()}}}function Dh(e){e.updateLayout(),Fh(e)}function Oh(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source,o=(r,a)=>{if(i===`size`)hh(e=>{let t=Rm(r[e]);r[e].min=a[e].min,r[e].max=r[e].min+t});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;jm(r[e],a[e])}else $h(i,t.layoutBox,n)&&hh(t=>{let n=Rm(a[t]);r[t].max=r[t].min+n,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[t].max=e.relativeTarget[t].min+n)})},s=a?t.measuredBox:t.layoutBox;o(s,n);let c=$m();Vm(c,n,t.layoutBox);let l=$m();Vm(l,a?e.applyTransform(r,!0):n,s);let u=!rh(c),d=!1,f=e.getClosestProjectingParent();if((!e.resumeFrom||f?.options.layoutRoot&&e.resumeFrom.path.includes(f))&&f&&!f.resumeFrom){let{snapshot:r,layout:i}=f;if(r&&i){let s=e.options.layoutAnchor||void 0,c=th();Gm(c,a?e.resumeFrom.applyTransform(t.layoutBox,!0,void 0,!0,f.depth+1):t.layoutBox,r.layoutBox,s);let l=th();Gm(l,n,i.layoutBox,s),a&&o(c,l),sh(c,l)||(d=!0),f.options.layoutRoot&&(e.relativeTarget=l,e.relativeTargetOrigin=c,e.relativeParent=f)}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:l,layoutDelta:c,hasLayoutChanged:u,hasRelativeLayoutChanged:d})}else e.isLead()&&e.options.onExitComplete?.();e.options.transition=void 0}function kh(e){ym.value&&yh.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function Ah(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function jh(e){e.clearSnapshot()}function Mh(e){e.clearMeasurements()}function Nh(e){e.isLayoutDirty=!0,e.updateLayout()}function Ph(e){e.isLayoutDirty=!1}function Fh(e){let{snapshot:t,dragAncestor:n}=e,r=n?.isAnimationBlocked&&n.layout;if(!t||!r||e.resumeFrom||e.isAnimationBlocked)return;let i=n.dragSnapshot;hh(e=>lm(t.layoutBox[e],r.layoutBox[e].min-i.layoutBox[e].min))}function Ih(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.dragSnapshot||e.layout,e.isLayoutDirty=!0)}function Lh(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function Rh(e){let{visualElement:t}=e.options;t?.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function zh(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Bh(e){e.resolveTargetDelta()}function Vh(e){e.calcProjection()}function Hh(e){e.resetSkewAndRotation()}function Uh(e,t,n){e.translate=Fl(t.translate,0,n),e.scale=Fl(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Wh(e,t,n,r){e.min=Fl(t.min,n.min,r),e.max=Fl(t.max,n.max,r)}function Gh(e,t,n,r){Wh(e.x,t.x,n.x,r),Wh(e.y,t.y,n.y,r)}function Kh(e){return e.animationValues?.opacityExit!==void 0}var qh={duration:.45,ease:[.4,0,.1,1]},Jh=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Yh=Jh(`applewebkit/`)&&!Jh(`chrome/`)?Math.round:cc;function Xh(e){e.min=Yh(e.min),e.max=Yh(e.max)}function Zh(e){Xh(e.x),Xh(e.y)}function Qh(e,t,n){e.max=Rm(n)+(e.min=t.min)}function $h(e,t,n){return e===`position`||e===`preserve-aspect`&&!zm(ch(t),ch(n),.2)}function eg(e){return e!==e.root&&e.scroll?.wasRoot}function tg(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var ng=Eh({attachResizeListener:(e,t)=>tg(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),rg={current:void 0},ig=Eh({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!rg.current){let e=new ng({});e.mount(window),e.setOptions({layoutScroll:!0}),rg.current=e}return rg.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),ag=new WeakMap;function og(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function sg(e){return typeof e==`string`||Array.isArray(e)}var cg=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],lg=[`initial`].concat(cg);function ug(e){if(og(e.animate))return!0;for(let t=0;t<lg.length;t++)if(sg(e[lg[t]]))return!0;return!1}function dg(e){return!!(ug(e)||e.variants)}function fg(e,t,n){for(let r in t){let i=t[r],a=n[r];if(mp(i))e.addValue(r,i);else if(mp(a))e.addValue(r,Gf(i,{owner:e}));else if(a!==i){if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,Gf(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var pg={current:null},mg={current:!1},hg=typeof window<`u`;function gg(){if(mg.current=!0,hg){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>pg.current=e.matches;e.addEventListener(`change`,t),t()}else pg.current=!1}}var _g=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],vg={};function yg(e){vg=e}function bg(){return vg}var xg=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Hd,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Lc.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,q.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=ug(t),this.isVariantNode=dg(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&mp(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];if(this.current=e,ag.set(e,this),this.projection?.instance||this.projection?.mount(e),this.isVariantNode&&!this.isControllingVariants){let e=this;do e=e.props.inherit!==!1&&e.parent;while(e&&!e.isVariantNode);if(e){let{variantChildren:t}=e;t.add(this),this.removeFromVariantTree=()=>t.delete(this)}}this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(mg.current||gg(),this.shouldReduceMotion=pg.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection?.unmount(),J(this.notifyUpdate),J(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree?.(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),(this.enteringChildren||=new Set).add(e)}removeChild(e){this.children.delete(e),this.enteringChildren?.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.get(e)?.(),t.accelerate&&df.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new tf({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:fc(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=wd.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&q.preRender(this.notifyUpdate),n&&(this.projection&&(this.projection.isTransformDirty=!0),wf.get(this.current)?.check()),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i?.()})}sortNodePosition(e){return!this.current||!e.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in vg){let t=vg[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):th()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){let{transformTemplate:n,onUpdate:r}=this.props;(e.transformTemplate||n)&&this.scheduleRender(),(e.transformTemplate&&!n||e.onUpdate&&!r)&&wf.get(this.current)?.demote(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<_g.length;t++){let n=_g[t];this.propEventSubscriptions[n]?.(),delete this.propEventSubscriptions[n];let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=fg(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue?.()}getProps(){return this.props}getVariant(e){return this.props.variants?.[e]}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}addValue(e,t){let n=this.values.get(e);if(t!==n){n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t);let r=t.get();r!==void 0&&(this.latestValues[e]=r)}}removeValue(e){this.values.delete(e),this.valueSubscriptions.get(e)?.(),this.valueSubscriptions.delete(e),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){let n=this.props.values?.[e];return n||(n=this.values.get(e),n===void 0&&t!==void 0&&(n=Gf(t??this.getDefaultValue?.(e),{owner:this}),this.addValue(e,n)),n)}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(ic(n)||oc(n))?n=parseFloat(n):typeof n!=`number`&&!jl.test(n)&&jl.test(t)&&(n=ud(e,t)),this.setBaseTarget(e,mp(n)?n.get():n)),mp(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return(this.events[e]||(this.events[e]=new dc)).add(t)}notify(e,...t){this.events[e]?.notify(...t)}scheduleRenderMicrotask(){hm.render(this.render)}},Sg=class extends xg{constructor(){super(...arguments),this.KeyframeResolver=jp}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;mp(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}};function Cg(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function wg(e,{layout:t,layoutId:n}){return wd.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!vm[e]||e===`opacity`)}function Tg(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(mp(r[t])||i&&mp(i[t])||wg(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function Eg(e){return window.getComputedStyle(e)}var Dg=class extends Sg{constructor(){super(...arguments),this.type=`html`,this.renderInstance=Cg}mount(e){super.mount(e)}readValueFromInstance(e,t){if(wd.has(t))return this.projection?.isProjecting?bd(t):Sd(e,t);{let n=Eg(e),r=(Bc(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return pm(e,t)}build(e,t,n){Bp(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Tg(e,t,n)}},Og=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1;function kg(e){return{point:{x:e.pageX,y:e.pageY}}}var Ag=e=>t=>Og(t)&&e(t,kg(t));function jg(e,t,n,r){return tg(e,t,Ag(n),r)}var Mg=new WeakMap,Ng,Pg=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:Pp(r)&&`getBBox`in r?r.getBBox()[t]:r[n],Fg=Pg(`inline`,`width`,`offsetWidth`),Ig=Pg(`block`,`height`,`offsetHeight`);function Lg({target:e,borderBoxSize:t}){Mg.get(e)?.forEach(n=>{n(e,{get width(){return Fg(e,t)},get height(){return Ig(e,t)}})})}function Rg(e){e.forEach(Lg)}function zg(){typeof ResizeObserver<`u`&&(Ng=new ResizeObserver(Rg))}function Bg(e,t){Ng||zg();let n=Rp(e);return n.forEach(e=>{let n=Mg.get(e);n||(n=new Set,Mg.set(e,n)),n.add(t),Ng?.observe(e)}),()=>{n.forEach(e=>{let n=Mg.get(e);n?.delete(t),n?.size||Ng?.unobserve(e)})}}var Vg=new Set,Hg;function Ug(){Hg=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Vg.forEach(t=>t(e))},window.addEventListener(`resize`,Hg)}function Wg(e){return Vg.add(e),Hg||Ug(),()=>{Vg.delete(e),!Vg.size&&typeof Hg==`function`&&(window.removeEventListener(`resize`,Hg),Hg=void 0)}}function Gg(e,t){return Ip(typeof e==`function`?Wg(e):Bg(e,t))}var Kg=(e,t)=>Math.abs(e-t);function qg(e,t){let n=Kg(e.x,t.x),r=Kg(e.y,t.y);return Math.sqrt(n**2+r**2)}var Jg=new Set([`auto`,`scroll`]),Yg=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.hasPendingMove=!1,this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Zg(this.lastRawMoveEventInfo,this.transformPagePoint));let e=$g(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=qg(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e;this.history.push({...r,timestamp:Lc.now()});let{onStart:i,onMove:a}=this.handlers;t||(i?.(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),a?.(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.handleScroll(window),this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=Zg(t,this.transformPagePoint),this.hasPendingMove=!0,q.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.hasPendingMove&&this.updatePoint(),this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i?.(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=$g(e.type===`pointercancel`?this.lastMoveEventInfo:Zg(t,this.transformPagePoint),this.history);this.startEvent&&n?.(e,a),r?.(e,a)},!Og(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=Zg(kg(e),this.transformPagePoint),{point:c}=s;this.history=[{...c,timestamp:Lc.now()}];let{onSessionStart:l}=t;l&&l(e,$g(s,this.history));let u={passive:!0,capture:!0};this.removeListeners=lc(jg(this.contextWindow,`pointermove`,this.handlePointerMove,u),jg(this.contextWindow,`pointerup`,this.handlePointerUp,u),jg(this.contextWindow,`pointercancel`,this.handlePointerUp,u)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Jg.has(e.overflowX)||Jg.has(e.overflowY))&&this.scrollPositions.set(t,Xg(t)),t=t.parentElement}this.scrollPositions.set(window,Xg(window)),this.removeScrollListeners=lc(tg(window,`scroll`,this.onElementScroll,{capture:!0}),tg(window,`scroll`,this.onWindowScroll,{}))}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=Xg(e),i={x:r.x-t.x,y:r.y-t.y};(i.x!==0||i.y!==0)&&(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),q.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners?.(),this.removeScrollListeners?.(),this.scrollPositions.clear(),J(this.updatePoint)}},Xg=e=>e===window?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop};function Zg(e,t){return t?{point:t(e.point)}:e}function Qg(e,t){return{x:e.x-t.x,y:e.y-t.y}}function $g({point:e},t){return{point:e,delta:Qg(e,t_(t)),offset:Qg(e,e_(t)),velocity:n_(t,.1)}}function e_(e){return e[0]}function t_(e){return e[e.length-1]}function n_(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=t_(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>fc(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>fc(t)*2&&(r=e[1]);let a=pc(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}var r_=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function i_(e){return r_.has(e.tagName)||e.isContentEditable===!0}var a_=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function o_(e){return a_.has(e.tagName)||e.isContentEditable===!0}var s_={x:!1,y:!1};function c_(){return s_.x||s_.y}function l_(e){return e===`x`||e===`y`?s_[e]?null:(s_[e]=!0,()=>{s_[e]=!1}):s_.x||s_.y?null:(s_.x=s_.y=!0,()=>{s_.x=s_.y=!1})}function u_(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?Fl(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?Fl(n,e,r.max):Math.min(e,n)),e}function d_(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function f_(e,{top:t,left:n,bottom:r,right:i}){return{x:d_(e.x,n,i),y:d_(e.y,t,r)}}function p_(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function m_(e,t){return{x:p_(e.x,t.x),y:p_(e.y,t.y)}}function h_(e,t){let n=.5,r=Rm(e),i=Rm(t);return i>r?n=uc(t.min,t.max-r,e.min):r>i&&(n=uc(e.min,e.max-i,t.min)),nc(0,1,n)}function g_(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var __=.35;function v_(e=__){return e===!1?e=0:e===!0&&(e=__),{x:y_(e,`left`,`right`),y:y_(e,`top`,`bottom`)}}function y_(e,t,n){return{min:b_(e,t),max:b_(e,n)}}function b_(e,t){return typeof e==`number`?e:e[t]||0}function x_(e){let t=``;for(let n of e.path){n.scroll=void 0,n.updateScroll();let{scroll:r}=n;n!==e.root&&r&&(t+=r.offset.x+`,`+r.offset.y+`,`)}return t}var S_=new WeakMap,C_=class{constructor(e,t=()=>e.getProps()){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=th(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e,this.readProps=t}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){if(this.visualElement.presenceContext?.isPresent===!1)return;let r=e=>{t&&this.snapToCursor(e),this.stopAnimation()},i=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock?.(),this.openDragLock=l_(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints();let{projection:a}=this.visualElement;a&&(a.isAnimationBlocked=!0,a.target=void 0),hh(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Hc(t)&&(t=ip(t,this.visualElement.current)||0),K.test(t))t=parseFloat(t);else if(sl.test(t)){let n=a?.layout?.layoutBox[e];n&&(t=Rm(n)*(parseFloat(t)/100))}this.originPoint[e]=t}),i&&q.update(()=>i(e,t),!1,!0),gp(this.visualElement,`transform`),this.visualElement.animationState?.setActive(`whileDrag`,!0)},a=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){if(this.currentDirection=k_(o),this.currentDirection===null)return;i&&i(this.currentDirection)}this.updateAxis(`x`,o),this.updateAxis(`y`,o),this.visualElement.render(),a&&q.update(()=>a(e,t),!1,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},s=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:c}=this.getProps();this.panSession=new Yg(e,{onSessionStart:r,onStart:i,onMove:a,onSessionEnd:o,resumeAnimation:s},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:n,contextWindow:this.visualElement.current?.ownerDocument.defaultView,element:this.visualElement.current})}stop(e,t,n){let r=e||this.latestPointerEvent,i=t||this.latestPanInfo,a=this.isDragging;if(this.cancel(),!a||!i||!r)return;let{velocity:o}=i;this.startAnimation(o,n);let{onDragEnd:s}=this.getProps();s&&q.postRender(()=>s(r,i))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession(),!this.getProps().dragPropagation&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t?.setActive(`whileDrag`,!1)}endPanSession(){this.panSession?.end(),this.panSession=void 0}updateAxis(e,t){let{drag:n}=this.readProps();if(!t||!O_(e,n,this.currentDirection))return;let r=this.getAxisMotionValue(e),i=this.originPoint[e]+t[e],a=this.constraints&&this.constraints[e];a&&(i=u_(i,a,this.elastic[e])),r.set(i)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),{projection:n}=this.visualElement,r=n&&(n.layout||n.measure(!1)),i=this.constraints;w_(e)?this.constraints&&this.scroll===x_(n)||(this.constraints=this.resolveRefConstraints()):this.constraints=e&&r?f_(r.layoutBox,e):!1,this.elastic=v_(t),i!==this.constraints&&!w_(e)&&r&&this.constraints&&!this.hasMutatedConstraints&&hh(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=g_(r.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!w_(e))return!1;let n=T_(e),{projection:r}=this.visualElement;if(!r||!r.layout)return!1;this.scroll=x_(r);let i=mm(n,r.root,this.visualElement.getTransformPagePoint()),a=m_(r.layout.layoutBox,r.removeElementScroll(i));if(t){let e=t(qp(a));this.hasMutatedConstraints=!!e,e&&(a=Kp(e))}return a}startAnimation(e,t){let{drag:n,dragMomentum:r,dragElastic:i,dragTransition:a,dragSnapToOrigin:o,onDragTransitionEnd:s}=this.getProps(),c=this.constraints||{},l=hh(s=>{if(!O_(s,t||n,this.currentDirection))return;let l=c[s]||{};(o===!0||o===s)&&(l={min:0,max:0});let u=i?200:1e6,d=i?40:1e7,f={type:`inertia`,velocity:r?e[s]:0,bounceStiffness:u,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...a,...l};return this.startAxisValueAnimation(s,f)});return Promise.all(l).then(s)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return gp(this.visualElement,e),n.start(tp(e,n,0,t,this.visualElement,!1))}stopAnimation(){hh(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.readProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor({clientX:e,clientY:t}){let{drag:n}=this.getProps(),r={x:e,y:t},i=this.visualElement.getTransformPagePoint()?.(r)||r,a=this.visualElement.measureViewportBox();hh(e=>{if(!O_(e,n,this.currentDirection))return;let t=this.getAxisMotionValue(e),{min:r,max:o}=a[e];t.set((t.get()||0)+i[e]-Fl(r,o,.5))})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!w_(t)||!n||!this.constraints)return;this.stopAnimation();let r=this.constraints,i={x:0,y:0};hh(e=>{let t=this.getAxisMotionValue(e).get();i[e]=h_({min:t,max:t},r[e])});let{transformTemplate:a}=this.visualElement.getProps();this.visualElement.current.style.transform=a?a({},``):`none`,n.root?.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),hh(t=>{let n=this.getAxisMotionValue(t);if(!O_(t,e,null)||!n.get())return;let{min:r,max:a}=this.constraints[t];n.set(Fl(r,a,i[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;S_.set(this.visualElement,this);let e=this.visualElement.current,t=jg(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&o_(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps(),r=w_(t)&&T_(t);r&&(this.constraints=this.resolveRefConstraints(),n||=D_(e,r,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i.layout||(i.root?.updateScroll(),i.updateLayout()),q.read(r);let o=tg(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(hh(t=>{if(!O_(t,this.getProps().drag,this.currentDirection))return;let n=this.getAxisMotionValue(t);this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate)}),this.visualElement.render())}));return()=>{o(),t(),a(),s(),n?.()}}getProps(){let e=this.readProps(),{dragElastic:t=__,dragMomentum:n=!0}=e;return{...e,dragElastic:t,dragMomentum:n}}};function w_(e){return!!e&&typeof e==`object`&&(`current`in e||`nodeType`in e)}var T_=e=>`current`in e?e.current:e;function E_(e){let t=!0;return()=>{t?t=!1:e()}}function D_(e,t,n){let r=Gg(e,E_(n)),i=Gg(t,E_(n));return()=>{r(),i()}}function O_(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function k_(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}function A_(e,t){let n=Rp(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},Ip(()=>r.abort())]}function j_(e){return!(e.pointerType===`touch`||c_())}function M_(e,t,n={}){t=Lp(t);let[r,i,a]=A_(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{e.pointerType!==`touch`&&(n?r=!0:s(e))};e.addEventListener(`pointerenter`,n=>{if(!j_(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var N_=(e,t)=>t?e===t||N_(e,t.parentElement):!1,P_=new WeakSet;function F_(e){return t=>{t.key===`Enter`&&e(t)}}function I_(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var L_=(e,t)=>{let n=!1,r=F_(()=>{P_.has(e)||(n=!0,I_(e,`down`))}),i=F_(()=>{n&&(n=!1,I_(e,`up`))});e.addEventListener(`keydown`,r,t),e.addEventListener(`keyup`,i,t),e.addEventListener(`blur`,()=>{e.removeEventListener(`keydown`,r),e.removeEventListener(`keyup`,i),n&&I_(e,`cancel`)},{...t,once:!0})};function R_(e){return Og(e)&&!c_()}var z_=new WeakSet;function B_(e,t,n={}){t=Lp(t);let[r,i,a]=A_(e,n),o=e=>{let r=e.currentTarget;if(!R_(e)||z_.has(e))return;P_.add(r),n.stopPropagation&&z_.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),P_.has(r)&&P_.delete(r),R_(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||N_(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),Np(e)&&(e.addEventListener(`focus`,()=>L_(e,i),i),!i_(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}var V_=class{constructor(e){this.isMounted=!1,this.node=e}update(){}},H_=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),U_=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function W_(e,t,n,r){Cg(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(H_.has(n)?n:zp(n),t.attrs[n])}function G_(e,t,n){let r=Tg(e,t,n);for(let n in e)if(n!==`children`&&(mp(e[n])||mp(t[n]))){let t=Cd.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var K_=class extends Sg{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=th}getBaseTargetFromProps(e,t){return wd.has(t)?super.getBaseTargetFromProps(e,t)??bd(t):e[t]}getDefaultValue(e){return wd.has(e)?this.latestValues[e]??bd(e):void 0}readValueFromInstance(e,t){if(wd.has(t)){let e=cd(t);return e&&e.default||0}if(Wp.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=H_.has(t)?t:zp(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return G_(e,t,n)}build(e,t,n){Gp(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){W_(e,t,n,r)}mount(e){this.isSVGTag=U_(e.tagName),super.mount(e)}};function q_(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var J_=[...cg].reverse(),Y_=e=>e?.out===!0?e:e?.out;function X_(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>Cp(e,t,n))),n=Q_(),r=!0,i=!1;function a(a){let{props:o,parent:s,manuallyAnimateOnMount:c}=e,{initial:l}=o,u=r||i,d=[],f=(t=l)=>typeof t!=`boolean`&&sp(e,Array.isArray(t)?t[0]:t,e.presenceContext?.custom)||void 0,p=new Map,m={},h=1/0,g=e;do g=g.props.inherit!==!1&&g.parent;while(g&&!g.isControllingVariants);let _=u&&Y_(f(l??(g&&g.props.initial))?.transition);if(J_.forEach((t,r)=>{let i=n[t],l=o[t],f=g&&g.props[t],v=l===void 0?sg(f)||f===!1?f:void 0:l,y=sg(v),b=t===a?i.isActive:null,x=y&&l===void 0&&!(u&&c);if(i.protectedKeys={...m},!i.isActive&&b===null||!v&&!i.prevProp||og(v)||typeof v==`boolean`)return;if(b===!1&&(h=r),t===`exit`&&i.isActive&&b!==!0){m={...m,...i.prevResolvedValues};return}let S=Z_(i.prevProp,v),C=S||y&&(b&&!x||r>h),w=!1,T=Array.isArray(v)?v:[v],ee={},E;if(b!==!1)for(let n of T){let{transition:r,transitionEnd:i,...a}=sp(e,n,cp(e,t))||{};ee={...ee,...a,...i},E=Y_(r)||E}let{prevResolvedValues:te}=i;for(let t in{...te,...ee}){if(t in m)continue;let n=ee[t],r=te[t],a=Array.isArray(n)&&Array.isArray(r)?!q_(n,r)||S:n!==r,o;if(a&&n==null)p.has(t)||p.set(t,i.prevOut);else if(a||n!==void 0&&p.has(t)){C=!0,o=p.get(t)||_,p.delete(t)&&(w=!0),i.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)}else i.protectedKeys[t]=!0;i.out[t]=o}if(i.prevProp=v,i.prevResolvedValues=ee,i.prevOut=E,i.isActive&&(m={...m,...ee}),C&&(!(x&&S)||w))for(let n of T){let r={type:t};if(typeof n==`string`&&u&&c&&s?.enteringChildren){let t=sp(s,n)?.transition?.delayChildren;r.delay=$(s.enteringChildren,e,t)}d.push({animation:n,options:r})}}),p.size){let t={},n=f(),r=n?.transition;p.forEach((i,a)=>{i&&(r={...r||e.getDefaultTransition(),[a]:i});let s=e.getValue(a);s&&(s.liveStyle=!0);let c=n&&!Array.isArray(l)?n[a]:void 0,u=e.getBaseTargetFromProps(o,a);t[a]=(c===void 0?u!==void 0&&!mp(u)?u:e.initialValues[a]===void 0?e.baseTarget[a]:void 0:c)??null}),r&&(t.transition=r),d.push({animation:t})}let v=u&&e.blockInitialAnimation||r&&!c&&(o.initial===!1||o.initial===o.animate);return r=i=!1,!v&&d.length?t(d):Promise.resolve()}function o(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=a(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:a,setActive:o,setAnimateFunction:n=>{t=n(e)},getState:()=>n,reset:()=>{n=Q_(),i=!0}}}function Z_(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!q_(t,e):!1}function Q_(){let e={};for(let t of cg)e[t]={isActive:t===`animate`,protectedKeys:{},needsAnimating:{},prevResolvedValues:{},out:{}};return e}var $_=(0,b.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function ev(e=!0){let t=(0,b.useContext)($s);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,b.useId)();(0,b.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,b.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var tv=(0,b.createContext)({strict:!1}),nv={animation:[`variants`,...cg],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},rv=!1;function iv(){if(rv)return;let e={};for(let t in nv)e[t]={isEnabled:e=>nv[t].some(t=>!!e[t])};yg(e),rv=!0}function av(){return iv(),bg()}function ov(e){let t=av();for(let n in e)t[n]={...t[n],...e[n]};yg(t)}var sv=(0,b.createContext)({});function cv(e,t){if(ug(e)){let{initial:t,animate:n}=e;return{initial:t===!1||sg(t)?t:void 0,animate:sg(n)?n:void 0}}return e.inherit===!1?{}:t}function lv(e){let{initial:t,animate:n}=cv(e,(0,b.useContext)(sv));return(0,b.useMemo)(()=>({initial:t,animate:n}),[uv(t),uv(n)])}function uv(e){return Array.isArray(e)?e.join(` `):e}var dv=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function fv(e,t,n){for(let r in t)!mp(t[r])&&!wg(r,n)&&(e[r]=t[r])}function pv({transformTemplate:e},t){return(0,b.useMemo)(()=>{let n=dv();return Bp(n,t,e),Object.assign({},n.vars,n.style)},[t])}function mv(e,t){let n=e.style||{},r={};return fv(r,n,e),Object.assign(r,pv(e,t)),r}function hv(e,t){let n={},r=mv(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var gv=()=>({...dv(),attrs:{}});function _v(e,t,n,r){let i=(0,b.useMemo)(()=>{let n=gv();return Gp(n,t,U_(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};return fv(t,e.style,e),{...i,style:{...t,...i.style}}}return i}var vv=new Set(`animate.exit.variants.initial.style.values.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function yv(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||vv.has(e)}function bv(e,t){return e.startsWith(`on`)?!yv(e):t?.(e)??!yv(e)}function xv(e,t,n,r){let i={};for(let a in e)a===`values`&&typeof e.values==`object`||mp(e[a])||(bv(a,r)||n===!0&&yv(a)||!t&&!yv(a)||e.draggable&&a.startsWith(`onDrag`))&&(i[a]=e[a]);return i}var Sv=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function Cv(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(Sv.indexOf(e)>-1||/[A-Z]/u.test(e))}function wv(e,t,n,{latestValues:r},i,a=!1,o,s){let c=(o??Cv(e)?_v:hv)(t,r,i,e),l=xv(t,typeof e==`string`,a,s),u=e===b.Fragment?{}:{...l,...c,ref:n},{children:d}=t,f=(0,b.useMemo)(()=>mp(d)?d.get():d,[d]);return(0,b.createElement)(e,{...u,children:f})}function Tv({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Ev(n,r,i,e),renderState:t()}}function Ev(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=Sm(a[e]);let{initial:o,animate:s}=e,c=ug(e),l=dg(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!og(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=op(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var Dv=e=>(t,n)=>{let r=(0,b.useContext)(sv),i=(0,b.useContext)($s),a=()=>Tv(e,t,r,i);return n?a():Zs(a)},Ov=Dv({scrapeMotionValuesFromProps:Tg,createRenderState:dv}),kv=Dv({scrapeMotionValuesFromProps:G_,createRenderState:gv}),Av=Symbol.for(`motionComponentSymbol`);function jv(e,t,n){let r=(0,b.useRef)(n);(0,b.useInsertionEffect)(()=>{r.current=n});let i=(0,b.useRef)(null);return(0,b.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`){if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n)}else a&&(a.current=n)},[t])}var Mv=(0,b.createContext)({});function Nv(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function Pv(e,t,n,r,i,a){let{visualElement:o}=(0,b.useContext)(sv),s=(0,b.useContext)(tv),c=(0,b.useContext)($s),l=(0,b.useContext)($_),u=l.reducedMotion,d=l.skipAnimations,f=(0,b.useRef)(null),p=(0,b.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,b.useContext)(Mv);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&Fv(f.current,n,i,h),(0,b.useInsertionEffect)(()=>{m&&m.props!==n&&m.update(n,c)});let g=n[_p],_=(0,b.useRef)(!!g&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return Qs(()=>{p.current&&m&&(m.animationState?.animateChanges(),m.enteringChildren=void 0)},[]),Qs(()=>{p.current=!0,m&&(window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),_.current&&m.animationState&&m.animationState.animateChanges())}),(0,b.useEffect)(()=>{m&&(!_.current&&m.animationState&&m.animationState.animateChanges(),_.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),!1),m.enteringChildren=void 0)}),m}function Fv(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t,f=e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:Iv(e.parent));f.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&Nv(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u});let p=f.getStack()?.lead;p&&!f.root.isUpdateBlocked()&&(p.willUpdate(),p.scheduleCheckAfterUnmount())}function Iv(e){if(e)return e.options.allowProjection===!1?Iv(e.parent):e.projection}function Lv(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&ov(r);let a=n?n===`svg`:Cv(e),o=a?kv:Ov;function s(n,s){let c,l=Rv(n);Zs(()=>!!rg.current?.sharedNodes.get(l)?.lead&&n.initial)&&(n={...n,initial:!1});let u={...(0,b.useContext)($_),...n,layoutId:l},{isStatic:d,isValidProp:f}=u,p=lv(n),m=o(n,d);if(!d&&typeof window<`u`){zv(u,r);let t=Bv(u);p.visualElement=Pv(e,m,u,i,t.ProjectionNode,a),(t.isEnabled||p.visualElement?.projection?.options.layoutId)&&(c=t.MeasureLayout)}return(0,z.jsxs)(sv.Provider,{value:p,children:[c&&p.visualElement?(0,z.jsx)(c,{visualElement:p.visualElement,...u}):null,wv(e,n,jv(m,p.visualElement,s),m,d,t,a,f)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,b.forwardRef)(s);return c[Av]=e,c}function Rv({layoutId:e}){let t=(0,b.useContext)(Xs).id;return t&&e!==void 0?t+`-`+e:e}function zv(e,t){(0,b.useContext)(tv).strict}function Bv(e){let{drag:t,layout:n}=av();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:r.MeasureLayout,isEnabled:t?.isEnabled(e)||n?.isEnabled(e),ProjectionNode:r.ProjectionNode}}function Vv(e,t){if(typeof Proxy>`u`)return Lv;let n=new Map,r=(n,r)=>Lv(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,Lv(a,void 0,e,t)),n.get(a))})}var Hv=(e,t)=>t.isSVG??Cv(e)?new K_(t):new Dg(t,{allowProjection:e!==b.Fragment}),Uv=class extends V_{constructor(e){super(e),e.animationState||=X_(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();og(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){this.node.getProps().animate!==this.node.prevProps?.animate&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},Wv=0,Gv={animation:{Feature:Uv},exit:{Feature:class extends V_{constructor(){super(...arguments),this.id=Wv++}update(){let{presenceContext:e,prevPresenceContext:t,animationState:n}=this.node;if(!e||!n)return;let{isPresent:r,onExitComplete:i}=e,a=t?.isPresent;if(r===a)return;if(r&&a===!1){if(this.exit===!0){let{initial:e}=this.node.getProps();if(e&&!Array.isArray(e)){let{transition:t,transitionEnd:n,...r}=sp(this.node,e)||{};for(let e in r)this.node.getValue(e)?.jump(r[e])}this.node.blockInitialAnimation=!1,n.reset(),n.animateChanges()}else n.setActive(`exit`,!1);this.exit=void 0;return}let o=this.exit=n.setActive(`exit`,!r);i&&!r&&o.then(()=>{this.exit===o&&(this.exit=!0,i(this.id))})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id,this.node))}unmount(){}}}},Kv=class extends V_{constructor(e){super(e),this.removeGroupControls=cc,this.removeListeners=cc,this.controls=new C_(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||cc}update(){let{dragControls:e,drag:t}=this.node.getProps(),{dragControls:n,drag:r}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls))),r&&!t&&this.controls.stop(void 0,void 0,r)}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},qv=e=>(t,n)=>{e&&q.update(()=>e(t,n),!1,!0)},Jv=class extends V_{constructor(){super(...arguments),this.removePointerDownListener=cc}onPointerDown(e){this.session=new Yg(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:this.node.current?.ownerDocument.defaultView})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:qv(e),onStart:qv(t),onMove:qv(n),onEnd:(e,t)=>{delete this.session,r&&q.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=jg(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session?.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session?.end()}},Yv=!1,Xv=({layout:e,layoutDependency:t,layoutAnchor:n})=>({layout:e,layoutDependency:t,layoutAnchor:n,animationType:typeof e==`string`?e:`both`}),Zv=(e,t)=>{let{snapshot:n}=e,r=e.getStack();r?.remove(e);let i=r?.lead;if(r?.prevLead===e&&i.resumeFrom===e&&(i.resumeFrom=i.currentAnimation=e.resumingFrom=void 0),e.options.layoutId=t,!t)e.needsShow=!0;else return e.root.registerSharedNode(t,e),()=>{let{resumeFrom:t}=e;t?.isPresent!==!1&&e.getStack().members.includes(t)&&(t.hide(),e.resumeFrom=void 0,e.snapshot=n)}},Qv=class extends b.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group?.add(i),r&&n?.register?.(i),Yv&&i.root.didUpdate(),i.options.layoutId!==r&&Zv(i,r)?.(),i.addEventListener(`animationComplete`,()=>this.safeToRemove()),i.setOptions({...i.options,...Xv(this.props),onExitComplete:()=>this.safeToRemove()})),vh.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,layoutId:n,visualElement:r,drag:i,isPresent:a}=this.props,{projection:o}=r;return o&&(o.isPresent=a,this.takeOver=e.layoutId===n?void 0:(o.willUpdate(),Zv(o,n)),o.setOptions({...o.options,...Xv(this.props)}),Yv=!0,i||e.layoutDependency!==t||t===void 0||e.isPresent!==a?o.willUpdate():this.safeToRemove(),e.isPresent!==a&&(a?o.promote():o.relegate()||q.postRender(()=>{o.getStack()?.members.length||this.safeToRemove()}))),null}componentDidUpdate(){let{projection:e}=this.props.visualElement;e&&(this.takeOver?.(),e.root.didUpdate(),hm.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Yv=!0,r&&(r.scheduleCheckAfterUnmount(),t.group?.remove(r),n?.deregister?.(r))}safeToRemove(){this.props.safeToRemove?.()}render(){return null}};function $v(e){let[t,n]=ev(),r=(0,b.useContext)(Xs);return(0,z.jsx)(Qv,{...e,layoutGroup:r,switchLayoutGroup:(0,b.useContext)(Mv),isPresent:t,safeToRemove:n})}var ey={pan:{Feature:Jv},drag:{Feature:Kv,ProjectionNode:ig,MeasureLayout:$v}};function ty(e,t,n,r){let{props:i}=e,a=`while`+n;e.animationState&&i[a]&&e.animationState.setActive(a,r===`Start`);let o=i[`on`+n+r];o&&q.postRender(()=>o(t,kg(t)))}var ny=class extends V_{mount(){let{current:e}=this.node;e&&(this.unmount=M_(e,(e,t)=>(ty(this.node,t,`Hover`,`Start`),e=>ty(this.node,e,`Hover`,`End`))))}unmount(){}},ry=class extends V_{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}e&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=lc(tg(this.node.current,`focus`,()=>this.onFocus()),tg(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function iy(e,t,n){e.current instanceof HTMLButtonElement&&e.current.disabled||ty(e,t,`Tap`,n)}var ay=class extends V_{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=B_(e,(e,t)=>(iy(this.node,t,`Start`),(e,{success:t})=>iy(this.node,e,t?``:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},oy=new WeakMap,sy=new WeakMap,cy=e=>{let t=oy.get(e.target);t&&t(e)},ly=e=>{e.forEach(cy)};function uy({root:e,...t}){let n=e||document;sy.has(n)||sy.set(n,{});let r=sy.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(ly,{root:e,...t})),r[i]}function dy(e,t,n){let r=uy(t);return oy.set(e,n),r.observe(e),()=>{oy.delete(e),r.unobserve(e)}}var fy={some:0,all:1},py=class extends V_{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:fy[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=dy(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(my(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function my({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var hy=Vv(Object.assign({},Gv,{inView:{Feature:py},tap:{Feature:ay},focus:{Feature:ry},hover:{Feature:ny}},ey,{layout:{ProjectionNode:ig,MeasureLayout:$v}}),Hv);function gy(){!mg.current&&gg();let[e]=(0,b.useState)(pg.current);return e}var _y={some:0,all:1};function vy(e,t,{root:n,margin:r,amount:i=`some`}={}){let a=Rp(e);t=Lp(t);let o=new WeakMap,s=new IntersectionObserver(e=>{e.forEach(e=>{let n=o.get(e.target);if(e.isIntersecting!==!!n){if(e.isIntersecting){let n=t(e.target,e);typeof n==`function`?o.set(e.target,n):s.unobserve(e.target)}else typeof n==`function`&&(n(e),o.delete(e.target))}})},{root:n,rootMargin:r,threshold:typeof i==`number`?i:_y[i]});return a.forEach(e=>s.observe(e)),Ip(()=>s.disconnect())}function yy(e,{root:t,margin:n,amount:r,once:i=!1,initial:a=!1}={}){let[o,s]=(0,b.useState)(a),[c,l]=(0,b.useState)({});return(0,b.useEffect)(()=>{let a=c.current=e.current;return!a||i&&o?void 0:vy(a,()=>(s(!0),i?void 0:()=>s(!1)),{root:t&&t.current||void 0,margin:n,amount:r})},[t,e,n,i,r,c]),(0,b.useEffect)(()=>{e.current!==c.current&&(i||s(!1),l({}))}),o}var by=hy,xy={task:`任務`,reply:`回覆`,done:`完成回報`,ask:`提問`,failure:`失敗`};function Sy({mail:e}){let t=e.digest?.length?e.digest:e.brief?[{label:`摘要`,lines:[e.brief]}]:[];return(0,z.jsxs)(`article`,{className:`mt-3 rounded-lg border border-line bg-paper px-3 py-2`,children:[(0,z.jsxs)(`p`,{className:`eyebrow`,children:[xy[e.type]??e.type,`,來自 `,e.from]}),(0,z.jsx)(`p`,{className:`text-pretty mt-1 text-base font-semibold leading-snug`,children:e.subject}),e.held&&(0,z.jsx)(`p`,{className:`text-pretty mt-1 text-sm text-ink/70`,children:`這封在等空閒的實例。`}),t.length>0&&(0,z.jsx)(`dl`,{className:`mt-3`,children:t.map(e=>(0,z.jsxs)(`div`,{className:`mt-2 flex gap-3 first:mt-0`,children:[(0,z.jsx)(`dt`,{className:`w-16 shrink-0 sm:w-20 text-pretty text-xs text-ink/60`,children:e.label}),(0,z.jsx)(`dd`,{className:`min-w-0`,children:e.lines.map((e,t)=>(0,z.jsx)(`p`,{className:`text-pretty text-sm leading-relaxed`,children:e},`${t}-${e}`))})]},e.label))})]})}var Cy={completed:`完成`,partial:`部分完成`,blocked:`受阻`,failed:`失敗`,cancelled:`已取消`,waiting:`等待回答`};function wy(e){let t=[],n=/"message"\s*:\s*"((?:\\.|[^"\\])*)"/g,r;for(;r=n.exec(e);){let e=r[1];e!==void 0&&t.push(e.replace(/\\n/g,` `).replace(/\\"/g,`"`).replace(/\\\\/g,`\\`))}let i=(t.at(-1)??e.split(/\n\s*\n/).find(e=>e.trim())??e).replace(/\s+/g,` `).trim();return i.length>280?`${i.slice(0,279)}…`:i}function Ty(e){let t=e.match(/^(\S+) attempt (\d+) failed \(/);if(!t)return{head:``,body:e.trim()};let n=e.slice(t[0].length).replace(/\)(?:; [\s\S]*)?\.?\s*$/,``).trim();return{head:`${t[1]} 第 ${t[2]} 次失敗`,body:n}}function Ey(e){return e.map(e=>{let t=e.match(/^(#{1,6})\s+(.*)$/),n=t?.[1];if(t&&n){let e=(t[2]??``).replace(/\*\*/g,``).trim();return{kind:n.length===1?`title`:`label`,text:e}}let r=e.match(/^\*\*([^*]+):\*\*\s*(.*)$/),i=r?.[1];if(r&&i){let e=r[2]??``;return{kind:`fact`,text:i.trim(),extra:Cy[e.trim().toLowerCase()]??e.trim()}}return{kind:`text`,text:e.replace(/\*\*/g,``).replace(/`/g,``).trim()}})}var Dy={completed:`完成`,partial:`部分完成`,blocked:`受阻`,failed:`失敗`,waiting:`等待回答`,cancelled:`已取消`};function Oy(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(1)}M`}function ky(e){return e.state===`running`?`執行中`:e.state===`interrupted`?`已中斷`:e.outcome_verified?Dy[e.outcome??``]??e.outcome??`結束`:e.end_reason===`done`?`完成(未驗證)`:`結束:${e.end_reason===`waiting`?`等待回答`:e.end_reason??`?`}`}function Ay(e){return e.state!==`ended`||e.outcome!==`completed`}function jy(e){let t=e.steps??[];return t.length?`${t.filter(e=>e.done).length}/${t.length} 步`:`已用 ${e.rounds} 輪`}function My(e){return e.instance!==void 0&&e.instance>=2&&e.role?`${e.role} #${e.instance}`:e.name}function Ny(e){let t=Object.values(e.runs??{});return(t.length>0?t:e.report?[e.report]:[]).filter(e=>e.run).sort((e,t)=>Iy(t)-Iy(e))}function Py(e){let t=Ny(e);return t.find(e=>e.run?.state===`running`)??t.find(e=>e.run&&Ay(e.run))??t[0]}function Fy(e){if(!e||e.error)return-1/0;let t=Ny(e)[0];return t?Iy(t):-1/0}function Iy(e){let t=Date.parse(e.run?.started_at??``);return Number.isFinite(t)?t:-1/0}function Ly(e,t){let n=e+t;return n<=0?``:`快取 讀 ${Oy(e)} 寫 ${Oy(t)} 命中 ${Math.round(100*e/n)}%`}function Ry(e,t){let n=t-Date.parse(e);if(!Number.isFinite(n)||n<0)return``;let r=Math.floor(n/1e3);return r<60?`${r}s`:`${Math.floor(r/60)}m${String(r%60).padStart(2,`0`)}s`}function zy(e,t){if(e.state===`running`)return Ry(e.started_at,t)||`0s`;let n=By(e);return n===void 0?`0s`:Ry(e.started_at,n)||`0s`}function By(e){let t=Date.parse(e.ended_at??``);if(Number.isFinite(t))return t;let n=-1/0;for(let t of e.wakes??[]){let e=Date.parse(t.at);Number.isFinite(e)&&e>n&&(n=e)}return n===-1/0?void 0:n}function Vy(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function Hy(e,t,n){if(!e)return null;let r=[];for(let t of e.wakes){let e=Date.parse(t.at);if(!Number.isFinite(e))continue;let n=e+Math.max(0,t.duration_ms);r.push({agent:t.agent,start:e,end:n,ok:t.ok,live:!1,title:Uy(t)})}if(e.state===`running`)for(let[t,i]of Object.entries(e.active)){let e=Date.parse(i.since);Number.isFinite(e)&&r.push({agent:t,start:e,end:Math.max(n,e),ok:!0,live:!0,title:`${t} 第 ${i.round??`?`} 輪,進行中 ${Ry(i.since,n)}`})}if(!r.length)return null;let i=Math.min(...r.map(e=>e.start)),a=Math.max(...r.map(e=>e.end),i+1),o=a-i,s=[...new Set([...t.map(e=>e.name),...r.map(e=>e.agent)])],c=new Set(t.filter(e=>e.lead).map(e=>e.name));return s.sort((e,t)=>Number(c.has(t))-Number(c.has(e))||e.localeCompare(t)),{start:i,end:a,lanes:s.map(e=>({agent:e,bars:r.filter(t=>t.agent===e).map(e=>({x:(e.start-i)/o*1e3,width:Math.max(4,(e.end-e.start)/o*1e3),ok:e.ok,live:e.live,title:e.title}))})).filter(e=>e.bars.length>0)}}function Uy(e){let t=e.output_tokens?`,${Oy(e.output_tokens)} token`:``,n=e.model?`,${e.runtime??``}/${e.model}`:``,r=e.error?`,${e.error}`:``;return`${e.agent} 第 ${e.round} 輪,${e.ok?`成功`:`失敗`},${Math.round(e.duration_ms/1e3)}s${t}${n}${r}`}function Wy(e,t=6){let n=[];for(let r of[...e?.wakes??[]].reverse())for(let e of[...r.sent??[]].reverse())if(n.push({from:r.agent,to:e.to,type:e.type,subject:e.subject}),n.length>=t)return n;return n}function Gy(e){let t=new Map;for(let n of e?.wakes??[]){let e=t.get(n.agent)??{agent:n.agent,output:0,cacheRead:0,cacheWrite:0,failed:0};e.output+=n.output_tokens??0,e.cacheRead+=n.cache_read_tokens??0,e.cacheWrite+=n.cache_write_tokens??0,n.ok||(e.failed+=1),t.set(n.agent,e)}return[...t.values()].sort((e,t)=>t.output-e.output)}function Ky(e,t){return t?.state===`running`?t.active[e.name]?`active`:e.last_wake?.ok===!1?`failed`:(t.queue??[]).some(t=>t.agent===e.name)?`queued`:`idle`:`idle`}var qy={active:0,failed:1,queued:2,idle:3};function Jy(e,t){let n=e.filter(e=>e.lead),r=e.filter(e=>!e.lead).sort((e,n)=>qy[Ky(e,t)]-qy[Ky(n,t)]);return[...n,...r]}function Yy(e,t){return t?.state===`running`?e.filter(e=>Ky(e,t)===`active`).sort((e,n)=>(t.active[n.name]?.since??``).localeCompare(t.active[e.name]?.since??``)||e.name.localeCompare(n.name)):[]}function Xy(e){for(let t of[...e?.wakes??[]].reverse()){let e=[...t.sent??[]].reverse().find(e=>e.to!==`(done)`)?.to;if(e)return{from:t.agent,to:e}}}function Zy(e,t,n){let r=(e.can_message??[]).includes(t.name),i=(t.can_message??[]).includes(e.name);if(!r&&!i)return;let a=!!n&&(n.from===e.name&&n.to===t.name||n.from===t.name&&n.to===e.name);return{glyph:r&&i?`↕`:r?`▼`:`▲`,hot:a}}function Qy({agents:e,run:t,now:n}){let r=Jy(e,t),i=r.find(e=>e.lead),a=r.filter(e=>!e.lead),o=Xy(t),s=Wy(t),c=t?.state===`running`;return(0,z.jsxs)(`section`,{className:`panel p-3 sm:p-4`,children:[(0,z.jsx)(`h2`,{className:`text-balance text-base font-semibold`,children:`隊伍`}),r.length===0?(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm`,children:`沒有 agent。`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`p`,{className:`text-pretty mt-2 text-sm text-ink/70`,children:[`連線是誰可以傳話給誰。▼ 往下,▲ 往上,↕ 雙方。`,c?`會移動的是最近一次交接。`:``]}),(0,z.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[i&&(0,z.jsx)(tb,{agent:i,run:t,now:n}),a.length>0&&(0,z.jsx)(`ul`,{className:`mt-2 list-none space-y-2 border-l border-line p-0`,children:a.map(e=>{let r=i?Zy(i,e,o):void 0;return(0,z.jsxs)(`li`,{className:`relative pt-0 pl-8`,children:[r&&i?(0,z.jsx)($y,{glyph:r.glyph,hot:r.hot,live:c,title:ob(i,e,r)}):(0,z.jsx)(`div`,{className:`h-2`}),(0,z.jsx)(tb,{agent:e,run:t,now:n})]},e.name)})})]})]}),s.length>0&&(0,z.jsx)(`ol`,{className:`mt-6 grid gap-3 text-sm md:grid-cols-2 xl:grid-cols-3`,children:s.map(e=>(0,z.jsxs)(`li`,{className:`rounded-lg border border-line bg-wall/50 px-3 py-2`,children:[(0,z.jsx)(`p`,{className:`eyebrow`,children:e.to===`(done)`?`${e.from} 結束`:`${e.from} 給 ${e.to}`}),(0,z.jsx)(`p`,{className:`text-pretty mt-0.5 leading-snug`,children:e.subject})]},`${e.from}-${e.to}-${e.subject}`))})]})}function $y({glyph:e,hot:t,live:n,title:r}){let i=gy(),a=(0,b.useRef)(null),o=yy(a,{amount:.5}),s=n&&!i&&o,c=s&&t;return(0,z.jsxs)(`div`,{ref:a,title:r,className:`absolute top-3 -left-8 flex size-8 items-center justify-center`,children:[n&&e!==`▲`&&(0,z.jsx)(eb,{y:[0,18],hot:t,play:s}),n&&e!==`▼`&&(0,z.jsx)(eb,{y:[18,0],hot:t,play:s}),(0,z.jsx)(by.span,{className:R(`relative text-sm`,c?`text-signal`:`text-ink/50`),animate:c?{y:e===`▲`?[0,-3,0]:[0,3,0]}:{y:0},transition:c?{duration:.85,repeat:1/0,ease:`easeOut`}:{duration:.2,ease:`easeOut`},children:e})]})}function eb({y:e,hot:t,play:n}){return(0,z.jsx)(by.span,{"aria-hidden":!0,className:R(`absolute left-1/2 size-1.5 -translate-x-1/2 rounded-full`,t?`bg-signal`:`bg-ink/30`),initial:!1,animate:n?{y:e,opacity:[0,1,0]}:{y:(e[0]+e[1])/2,opacity:t?.85:.35},transition:n?{duration:t?1.1:2.8,repeat:1/0,ease:`linear`}:{duration:.2,ease:`easeOut`}})}function tb({agent:e,run:t,now:n}){let r=Ky(e,t),i=r===`active`,a=t?.state===`running`?t.active[e.name]:void 0,o=r===`queued`?(t?.queue??[]).filter(t=>t.agent===e.name).length:0,s=(t?.wakes??[]).filter(t=>t.agent===e.name),c=s.filter(e=>!e.ok).length,l=s.reduce((e,t)=>e+(t.output_tokens??0),0),u=rb(e,t,r);return(0,z.jsxs)(Ts,{defaultOpen:i,className:R(`group rounded-lg border bg-wall/50 px-3`,i?`border-signal/60 bg-signal-soft/40`:`border-line`),children:[(0,z.jsxs)(Ds,{className:`flex w-full items-baseline gap-3 py-3 text-left`,children:[(0,z.jsx)(`strong`,{className:R(`min-w-0 flex-1`,i?`text-balance text-base`:`truncate text-sm text-ink/80`),children:My(e)}),(0,z.jsx)(`span`,{className:R(`shrink-0 font-mono text-xs tabular-nums`,ab(r)),children:ib(r,a?.round,a?Ry(a.since,n):``,o)}),(0,z.jsx)(`span`,{className:`shrink-0 text-sm text-ink/60 group-data-[open]:hidden`,children:`展開`}),(0,z.jsx)(`span`,{className:`hidden shrink-0 text-sm text-ink/60 group-data-[open]:inline`,children:`收合`})]}),(0,z.jsxs)(Ys,{className:`pb-4 text-sm`,children:[(0,z.jsxs)(`dl`,{className:`mt-1 grid gap-x-8 gap-y-1 sm:grid-cols-2 xl:grid-cols-3`,children:[(0,z.jsx)(nb,{label:`執行`,value:`${e.lead?`帶隊,`:``}${e.runtime??`?`}`}),(e.model||e.fallback)&&(0,z.jsx)(nb,{label:`模型`,value:e.fallback?`備援中 ${e.model??``}`:e.model??``}),(0,z.jsx)(nb,{label:`token`,value:Oy(l)}),(0,z.jsx)(nb,{label:`喚醒`,value:`${s.length} 次${c>0?`,失敗 ${c}`:``}`}),e.unread>0&&(0,z.jsx)(nb,{label:`未看`,value:String(e.unread)}),(0,z.jsxs)(`div`,{className:`flex gap-3 sm:col-span-2 xl:col-span-3`,children:[(0,z.jsx)(`dt`,{className:`w-16 shrink-0 sm:w-20 text-ink/60`,children:`可傳話給`}),(0,z.jsx)(`dd`,{className:`flex min-w-0 flex-wrap gap-x-3 gap-y-1`,children:(e.can_message??[]).length>0?(e.can_message??[]).map(e=>(0,z.jsx)(`span`,{children:e},e)):`沒有人`})]})]}),r===`failed`&&e.last_wake?.error&&(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm leading-relaxed text-failed`,children:wy(e.last_wake.error)}),u.length>0&&(0,z.jsx)(`div`,{className:`flex flex-col`,children:u.map((e,t)=>(0,z.jsx)(Sy,{mail:e},`${t}-${e.from}-${e.subject}`))})]})]},i?`${e.name}:on`:e.name)}function nb({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`flex gap-3`,children:[(0,z.jsx)(`dt`,{className:`w-16 shrink-0 sm:w-20 text-ink/60`,children:e}),(0,z.jsx)(`dd`,{className:`min-w-0 text-pretty tabular-nums`,children:t})]})}function rb(e,t,n){return t?n===`active`?t.active[e.name]?.handling??[]:n===`queued`?(t.queue??[]).filter(t=>t.agent===e.name):[]:[]}function ib(e,t,n,r){return e===`active`?`進行中${t?` #${t}`:``} ${n}`.trim():e===`failed`?`上次喚醒失敗`:e===`queued`?`排隊 ${r} 封`:`閒置`}function ab(e){return e===`active`?`text-working`:e===`failed`?`text-failed`:`text-ink/60`}function ob(e,t,n){let r=n.glyph===`▼`?`${e.name} 可傳給 ${t.name}`:n.glyph===`▲`?`${t.name} 可傳給 ${e.name}`:`${e.name} 與 ${t.name} 可互傳`;return n.hot?`${r},最近一次交接`:r}function sb({open:e,title:t,onClose:n,closable:r=!0,wide:i=!1,children:a}){let o=(0,b.useRef)(null),s=(0,b.useId)(),c=(0,b.useRef)(e);c.current=e;let l=(0,b.useRef)(r);l.current=r;let u=(0,b.useRef)(null);return(0,b.useEffect)(()=>{let t=o.current;t&&(e&&!t.open&&(u.current=document.activeElement instanceof HTMLElement?document.activeElement:null,t.showModal()),!e&&t.open&&t.close())},[e]),(0,b.useEffect)(()=>()=>{let e=u.current;c.current&&e?.isConnected&&queueMicrotask(()=>e.focus())},[]),(0,z.jsx)(`dialog`,{ref:o,"aria-labelledby":s,onCancel:e=>{r||e.preventDefault()},onClose:e=>{if(c.current){if(l.current)n();else{let t=e.currentTarget;t.open||t.showModal()}}},className:`m-auto ${i?`w-[min(56rem,calc(100vw-2rem))]`:`w-[min(38rem,calc(100vw-2rem))]`} max-h-[90dvh] overflow-y-auto rounded-xl border border-line bg-paper p-0 text-ink backdrop:bg-black/40`,children:e&&(0,z.jsxs)(`div`,{className:`p-4 sm:p-6`,children:[(0,z.jsx)(`h2`,{id:s,className:`text-balance text-xl font-semibold tracking-tight`,children:t}),a]})})}var cb=`min-h-11 w-full rounded-lg border border-line bg-wall px-3 py-2 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`,lb=`min-h-11 rounded-lg border border-line px-4 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal disabled:opacity-50`;function ub({project:e,runId:t,open:n,onClose:r}){let[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)({}),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)([]),[m,h]=(0,b.useState)();(0,b.useEffect)(()=>{if(!n)return;let r=!0;return a(void 0),s({}),l(!1),p([]),h(void 0),d(!1),Pn(e,t).then(e=>{r&&(a(e??`missing`),e&&s(Object.fromEntries(e.questions.filter(e=>!e.delivered&&e.answer).map(e=>[e.id,e.answer]))))}),()=>{r=!1}},[n,e,t]);let g=async()=>{if(u)return;d(!0),p([]);let n=await Fn(e,t,o,c);n?n.complete?h(await jn(`resume`,{project:e,run:t,answer:!0})):p(n.problems):p([`沒能存下答案,請重新整理頁面再試。`]),d(!1)},_=i&&i!==`missing`?i.questions.filter(e=>!e.delivered):[],v=m?.kind===`short`?Lo(m.result.exit,m.result.timedOut):void 0;return(0,z.jsxs)(sb,{open:n,title:`回答問題`,onClose:r,closable:!u,children:[i===void 0&&(0,z.jsxs)(`div`,{className:`mt-4`,children:[(0,z.jsx)(Vo,{label:`正在讀取問題…`}),(0,z.jsxs)(`div`,{className:`mt-3 space-y-2`,"aria-hidden":`true`,children:[(0,z.jsx)(`div`,{className:`h-3 w-full motion-safe:animate-pulse rounded bg-line`}),(0,z.jsx)(`div`,{className:`h-3 w-4/5 motion-safe:animate-pulse rounded bg-line`}),(0,z.jsx)(`div`,{className:`h-3 w-3/5 motion-safe:animate-pulse rounded bg-line`})]})]}),i===`missing`&&(0,z.jsx)(`p`,{className:`mt-4 text-sm`,children:`這次任務現在沒有待回答的問題。`}),m?(0,z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3`,children:[m.kind===`job`?(0,z.jsxs)(`p`,{className:`text-sm`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`mr-1 text-signal`,children:`✓`}),`答案已送出,任務在背景繼續。`]}):m.kind===`short`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`p`,{className:R(`text-sm font-medium`,v?.tone===`ok`?`text-signal`:v?.tone===`warn`?`text-warn`:`text-failed`),children:[v?.text,m.result.signal?(0,z.jsxs)(`span`,{className:`ml-2 font-mono text-xs`,children:[`(訊號 `,m.result.signal,`)`]}):null]}),(0,z.jsx)(`pre`,{className:`max-h-60 overflow-auto rounded-lg border border-line bg-wall p-3 font-mono text-xs whitespace-pre-wrap`,children:m.result.stdout||m.result.stderr})]}):(0,z.jsx)(`p`,{role:`alert`,className:`text-pretty text-sm text-failed`,children:m.kind===`error`?m.message:m.kind===`invalid`?m.error:`請求被拒絕,請重新整理頁面後再試。`}),(0,z.jsx)(`div`,{className:`flex justify-end`,children:(0,z.jsx)(`button`,{type:`button`,autoFocus:!0,className:R(lb,`bg-ink text-paper`),onClick:r,children:`關閉`})})]}):_.length>0&&(0,z.jsxs)(`form`,{className:`mt-4 flex flex-col gap-5`,onSubmit:e=>{e.preventDefault(),g()},children:[_.map((e,t)=>(0,z.jsx)(db,{q:e,value:o[e.id]??``,autoFocus:t===0,onChange:t=>s(n=>({...n,[e.id]:t}))},e.id)),(0,z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`size-5`,checked:c,onChange:e=>l(e.target.checked)}),(0,z.jsx)(`span`,{children:`沒填的問題,有建議值就採用建議值`})]}),f.length>0&&(0,z.jsx)(`ul`,{role:`alert`,className:`rounded-lg border border-failed/40 bg-failed-soft px-3 py-2 text-sm text-failed`,children:f.map(e=>(0,z.jsx)(`li`,{children:e},e))}),(0,z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:u,className:lb,onClick:r,children:`取消`}),(0,z.jsx)(`button`,{type:`submit`,disabled:u,className:R(lb,`bg-ink text-paper`),children:u?`送出中…`:`送出並繼續任務`})]})]}),(i===`missing`||i!==void 0&&!m&&_.length===0)&&(0,z.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,z.jsx)(`button`,{type:`button`,className:lb,onClick:r,children:`關閉`})})]})}function db({q:e,value:t,autoFocus:n,onChange:r}){let i=(0,b.useId)();return(0,z.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`legend`,{className:`text-pretty text-sm font-medium`,children:[e.text,` `,(0,z.jsxs)(`span`,{className:`font-mono text-xs text-ink/60`,children:[`(`,e.asker,`)`]})]}),e.options?.map(e=>(0,z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,z.jsx)(`input`,{type:`radio`,name:i,className:`size-5`,checked:t===e,onChange:()=>r(e)}),(0,z.jsx)(`span`,{className:`text-pretty`,children:e})]},e)),(0,z.jsx)(`label`,{htmlFor:`${i}-text`,className:`text-xs text-ink/60`,children:e.options?.length?`或自己寫`:`你的答案`}),(0,z.jsx)(`input`,{id:`${i}-text`,className:cb,value:t,autoFocus:n,autoComplete:`off`,onChange:e=>r(e.target.value)}),e.suggested&&(0,z.jsxs)(`button`,{type:`button`,className:`min-h-11 self-start rounded-lg px-1 text-left text-sm underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`,onClick:()=>r(e.suggested?.value??``),children:[`採用建議:`,e.suggested.value,e.suggested.reason?`(${e.suggested.reason})`:``]})]})}var fb=`min-h-11 rounded-lg border border-line bg-paper px-3 text-sm hover:bg-wall focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`,pb={result:`最終結果`,done:`完成回報`,agent:`Agent 報告`};function mb(e){let t=e?new Date(e):void 0;return!t||Number.isNaN(t.getTime())?``:t.toLocaleString(`zh-Hant`,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function hb({project:e,runId:t,open:n,onClose:r}){let[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)();(0,b.useEffect)(()=>{if(!n)return;a(void 0),s(void 0);let r=!0;return In(e,t).then(e=>r&&a(e??`error`)),()=>{r=!1}},[n,e,t]);let c=n=>{s(`loading`),Ln(e,t,n).then(e=>s(e??`error`))},l=(0,b.useMemo)(()=>o&&typeof o==`object`?jo(o.markdown):``,[o]),u=o&&typeof o==`object`?o.title:`報告`;return(0,z.jsxs)(sb,{open:n,title:u,onClose:r,wide:!0,children:[o===void 0?(0,z.jsx)(gb,{items:i,onPick:c}):(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsx)(`button`,{type:`button`,className:fb,onClick:()=>s(void 0),children:`← 回到列表`}),o===`loading`&&(0,z.jsx)(`p`,{className:`mt-4 text-sm`,children:`載入中…`}),o===`error`&&(0,z.jsx)(`p`,{className:`mt-4 text-sm text-failed`,children:`讀不到這份報告。`}),typeof o==`object`&&(0,z.jsx)(`article`,{className:`report-prose mt-4`,dangerouslySetInnerHTML:{__html:l}})]}),(0,z.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,z.jsx)(`button`,{type:`button`,className:fb,onClick:r,children:`關閉`})})]})}function gb({items:e,onPick:t}){return e===void 0?(0,z.jsx)(`p`,{className:`mt-4 text-sm`,children:`載入中…`}):e===`error`?(0,z.jsx)(`p`,{className:`mt-4 text-sm text-failed`,children:`讀不到報告列表。`}):e.length===0?(0,z.jsx)(`p`,{className:`mt-4 text-sm`,children:`這次任務還沒有報告。`}):(0,z.jsx)(`ul`,{className:`mt-4 flex flex-col gap-2`,children:e.map(e=>(0,z.jsx)(`li`,{children:(0,z.jsxs)(`button`,{type:`button`,className:`${fb} block w-full py-2 text-left`,onClick:()=>t(e.id),children:[(0,z.jsxs)(`span`,{className:`flex items-baseline justify-between gap-3 font-mono text-xs tabular-nums text-ink/70`,children:[(0,z.jsx)(`span`,{children:e.agent?`${pb[e.kind]}・${e.agent}`:pb[e.kind]}),(0,z.jsx)(`span`,{children:mb(e.created)})]}),(0,z.jsx)(`span`,{className:`text-pretty mt-1 block text-sm font-medium`,children:e.title}),e.outcome&&(0,z.jsx)(`span`,{className:`mt-0.5 block text-xs text-ink/60`,children:e.outcome})]})},e.id))})}var _b=class extends Error{field;constructor(e,t){super(t),this.field=e}},vb=/^[A-Za-z0-9][A-Za-z0-9_-]*$/,yb=/^[a-z0-9-]{1,30}$/,bb=/^(\/|~\/|[A-Za-z]:[\\/])/,xb=[`claude-code`,`codex`],Sb=[`project`,`global`],Cb=2e5;function wb(e,t,n){let r=e[t];if(r==null||typeof r==`string`&&r.trim()===``){if(n.required)throw new _b(t,`${n.what}必填。`);return}if(typeof r!=`string`)throw new _b(t,`${n.what}格式不對。`);let i=r.trim();if(i.includes(`\0`))throw new _b(t,`${n.what}含有不能用的字元。`);if(i.length>(n.max??256))throw new _b(t,`${n.what}太長。`);if(n.re&&!n.re.test(i))throw new _b(t,`${n.what}格式不對。`);return i}function Tb(e,t){let n=e[t];if(n==null||n===!1)return!1;if(n!==!0)throw new _b(t,`這個選項只能是勾選或不勾選。`);return!0}var Eb=e=>e,Db=e=>Eb(wb(e,`project`,{required:!0,re:vb,what:`專案`})),Ob=(e,t,n,r)=>{let i=wb(e,t,{what:r});if(i!==void 0&&!n.includes(i))throw new _b(t,`${r}只能是 ${n.join(`、`)}。`);return i},kb={name:`project`,label:`專案`,kind:`text`,required:!0},Ab=e=>()=>e,jb=()=>`normal`,Mb=()=>``,Nb={init:{id:`init`,label:`初始化 home`,scope:`home`,fields:[],mode:Ab(`short`),tier:jb,target:Mb,argv:()=>[`init`,`-y`]},"project.list":{id:`project.list`,label:`列出專案`,scope:`home`,fields:[],mode:Ab(`short`),tier:jb,target:Mb,argv:()=>[`project`]},"project.add":{id:`project.add`,label:`註冊專案`,scope:`home`,fields:[{name:`name`,label:`專案名稱`,kind:`text`,required:!0},{name:`dir`,label:`repo 的絕對路徑`,kind:`text`,required:!0,help:`agent 會在這個資料夾工作。`}],mode:Ab(`short`),tier:jb,target:Mb,argv:e=>{let t=Eb(wb(e,`name`,{required:!0,re:vb,what:`專案名稱`})),n=Eb(wb(e,`dir`,{required:!0,re:bb,what:`路徑`,max:1024}));if(n.startsWith(`~`))throw new _b(`dir`,`路徑請用絕對路徑,不支援 ~。`);return[`project`,`add`,t,`--dir`,n]}},"project.remove":{id:`project.remove`,label:`移除專案`,scope:`home`,fields:[{name:`name`,label:`專案名稱`,kind:`text`,required:!0},{name:`purge`,label:`連這個專案的所有 context 一起刪除`,kind:`checkbox`}],mode:Ab(`short`),tier:e=>e.purge===!0?`typed`:`confirm`,target:e=>String(e.name??``),argv:e=>[`project`,`remove`,Eb(wb(e,`name`,{required:!0,re:vb,what:`專案名稱`})),...Tb(e,`purge`)?[`--purge`]:[]]},run:{id:`run`,label:`新任務`,scope:`project`,fields:[kb,{name:`task`,label:`任務`,kind:`textarea`,required:!0},{name:`name`,label:`任務名稱(可留空)`,kind:`text`,help:`小寫英數與 -,最多 30 字。`},{name:`agent`,label:`只交給這一位 agent(可留空)`,kind:`text`},{name:`tidy`,label:`標記為 tidy(整理 commit 的任務)`,kind:`checkbox`},{name:`assumeDefaults`,label:`有建議值的問題直接採用,不暫停`,kind:`checkbox`}],mode:Ab(`detached`),tier:jb,target:Mb,argv:e=>{let t=[`run`,`-p`,Db(e)],n=wb(e,`name`,{re:yb,what:`任務名稱`});n&&t.push(`--name`,n);let r=wb(e,`agent`,{re:vb,what:`agent`});return r&&t.push(`--agent`,r),Tb(e,`tidy`)&&t.push(`--tidy`),Tb(e,`assumeDefaults`)&&t.push(`--assume-defaults`),t.push(`--`,Eb(wb(e,`task`,{required:!0,what:`任務`,max:Cb}))),t}},call:{id:`call`,label:`呼叫單一 agent`,scope:`home`,fields:[{name:`agent`,label:`agent(全域 library 裡的名稱)`,kind:`text`,required:!0},{name:`dir`,label:`工作目錄(絕對路徑)`,kind:`text`,required:!0},{name:`task`,label:`任務`,kind:`textarea`,required:!0}],mode:Ab(`detached`),tier:jb,target:Mb,argv:e=>[`call`,Eb(wb(e,`agent`,{required:!0,re:vb,what:`agent`})),`--dir`,Eb(wb(e,`dir`,{required:!0,re:bb,what:`工作目錄`,max:1024})),`--`,Eb(wb(e,`task`,{required:!0,what:`任務`,max:Cb}))]},resume:{id:`resume`,label:`續跑/追問`,scope:`project`,fields:[kb,{name:`run`,label:`任務 id`,kind:`text`,required:!0},{name:`followup`,label:`追問(只用在已完成的任務,可留空)`,kind:`textarea`},{name:`assumeDefaults`,label:`有建議值的問題直接採用`,kind:`checkbox`}],mode:Ab(`detached`),tier:jb,target:Mb,argv:e=>{let t=Db(e),n=Eb(wb(e,`run`,{required:!0,re:vb,what:`任務 id`,max:120})),r=Tb(e,`answer`),i=wb(e,`followup`,{what:`追問`,max:Cb});if(r&&i)throw new _b(`followup`,`回答問題時不能同時追問。`);let a=[`resume`,`-p`,t];return Tb(e,`assumeDefaults`)&&a.push(`--assume-defaults`),r&&a.push(`--answer`,`--no-edit`),a.push(`--`,n),i&&a.push(i),a}},clear:{id:`clear`,label:`刪除任務`,scope:`project`,fields:[kb,{name:`run`,label:`任務 id`,kind:`text`,required:!0},{name:`dryRun`,label:`只預覽,不刪除`,kind:`checkbox`},{name:`keepWorktrees`,label:`保留 agent 的 worktree 與分支`,kind:`checkbox`}],mode:Ab(`short`),tier:e=>e.dryRun===!0?`normal`:`confirm`,target:Mb,argv:e=>{let t=Db(e),n=Eb(wb(e,`run`,{required:!0,re:vb,what:`任務 id`,max:120}));return[`clear`,`-p`,t,...Tb(e,`dryRun`)?[`--dry-run`]:[],...Tb(e,`keepWorktrees`)?[`--keep-worktrees`]:[],`--`,n]}},"clear.lock":{id:`clear.lock`,label:`清除殘留的 run lock`,scope:`project`,fields:[kb,{name:`run`,label:`任務 id(只有一個 lock 時可留空)`,kind:`text`}],mode:Ab(`short`),tier:()=>`typed`,target:e=>typeof e.run==`string`&&e.run.trim()?e.run.trim():String(e.project??``),argv:e=>{let t=Db(e),n=wb(e,`run`,{re:vb,what:`任務 id`,max:120});return[`clear`,`-p`,t,`--lock`,`--force`,...n?[`--`,n]:[]]}},doctor:{id:`doctor`,label:`檢查設定`,scope:`project`,fields:[kb,{name:`resolved`,label:`顯示合併後的設定與來源`,kind:`checkbox`}],mode:Ab(`short`),tier:jb,target:Mb,argv:e=>[`doctor`,`-p`,Db(e),...Tb(e,`resolved`)?[`--resolved`]:[]]},tidy:{id:`tidy`,label:`整理記憶`,scope:`project`,fields:[kb,{name:`agent`,label:`只整理這一位 agent(可留空)`,kind:`text`},{name:`layer`,label:`層級`,kind:`select`,options:Sb},{name:`dryRun`,label:`只預覽,不整理`,kind:`checkbox`},{name:`undo`,label:`還原某次整理(填時間戳,需指定 agent)`,kind:`text`}],mode:e=>e.dryRun===!0||typeof e.undo==`string`&&e.undo.trim()!==``?`short`:`detached`,tier:e=>e.dryRun===!0?`normal`:`confirm`,target:Mb,argv:e=>{let t=Db(e),n=wb(e,`agent`,{re:vb,what:`agent`}),r=Ob(e,`layer`,Sb,`層級`),i=Tb(e,`dryRun`),a=wb(e,`undo`,{re:vb,what:`時間戳`,max:64});if(a!==void 0){if(i)throw new _b(`undo`,`還原不能和預覽一起用。`);if(!n)throw new _b(`agent`,`還原要指定是哪一位 agent。`)}let o=[`tidy`,`-p`,t];return n&&o.push(`--agent`,n),r&&o.push(`--layer`,r),i&&o.push(`--dry-run`),a!==void 0&&o.push(`--undo`,a),o}},demo:{id:`demo`,label:`示範`,scope:`home`,fields:[{name:`runtime`,label:`執行環境(可留空,自動偵測)`,kind:`select`,options:xb},{name:`setupOnly`,label:`只建立沙盒,不跑 agent`,kind:`checkbox`}],mode:e=>e.setupOnly===!0?`short`:`detached`,tier:jb,target:Mb,argv:e=>{let t=Ob(e,`runtime`,xb,`執行環境`);return[`demo`,`-y`,...t?[`--runtime`,t]:[],...Tb(e,`setupOnly`)?[`--setup-only`]:[]]}}};Object.keys(Nb);var Pb={phase:`form`,errors:{}};function Fb(e,t){switch(t.type){case`submit`:return e.phase===`running`?e:{phase:`running`};case`typed`:return e.phase===`confirm`?{...e,typed:t.value}:e;case`back`:case`reset`:return e.phase===`running`?e:Pb;case`result`:{if(e.phase!==`running`)return e;let n=t.result;return n.kind===`short`||n.kind===`job`?{phase:`done`,result:n}:n.kind===`need`?{phase:`confirm`,need:n.need,...n.target===void 0?{}:{target:n.target},typed:``}:n.kind===`invalid`?n.field?{phase:`form`,errors:{[n.field]:n.error}}:{phase:`form`,errors:{},notice:n.error}:n.kind===`stale`?{phase:`form`,errors:{},notice:`請求被拒絕,請重新整理頁面後再試。`}:{phase:`form`,errors:{},notice:n.message}}}}function Ib(e){return e.phase===`confirm`&&(e.need===`confirm`||e.typed===e.target)}function Lb(){let e=0;return{next:()=>++e,invalidate:()=>{e+=1},isCurrent:t=>t===e}}var Rb={ok:`text-signal`,warn:`text-warn`,fail:`text-failed`},zb={ok:`✓`,warn:`!`,fail:`✕`},Bb=`min-h-11 w-full rounded-lg border border-line bg-wall px-3 py-2 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`,Vb=`min-h-11 rounded-lg border border-line px-4 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal disabled:opacity-50`;function Hb(e,t){return e.fields.some(e=>e.name===`dryRun`)&&t.dryRun!==!0&&!t.undo}function Ub({id:e,open:t,title:n,fixed:r,initial:i,fieldOptions:a,onShortResult:o,onClose:s}){let c=Nb[e],[l,u]=(0,b.useState)(i??{}),[d,f]=(0,b.useReducer)(Fb,Pb),[p,m]=(0,b.useState)(),[h,g]=(0,b.useState)({}),_=(0,b.useRef)(Lb());(0,b.useEffect)(()=>{t&&(_.current.invalidate(),u(i??{}),m(void 0),f({type:`reset`}))},[t]);let v=async(t={})=>{let n={...l,...r,...t},i=_.current.next();m(void 0),g(n),f({type:`submit`});let a=await jn(e,n);a.kind===`short`&&o?.(e,n,a.result),_.current.isCurrent(i)&&(a.kind===`need`&&Hb(c,n)&&jn(e,{...n,dryRun:!0,confirm:void 0,confirmText:void 0}).then(e=>{e.kind===`short`&&_.current.isCurrent(i)&&m(e.result.stdout||e.result.stderr||void 0)}),f({type:`result`,result:a}))},y=c.fields.filter(e=>!(r&&e.name in r)),x=d.phase===`running`;return(0,z.jsxs)(sb,{open:t,title:n??c.label,onClose:s,closable:!x,children:[(d.phase===`form`||d.phase===`running`)&&(0,z.jsxs)(`form`,{className:`mt-4 flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),x||v()},children:[y.map((e,t)=>(0,z.jsx)(Gb,{field:e,value:l[e.name],error:d.phase===`form`?d.errors[e.name]:void 0,options:a?.[e.name],autoFocus:t===0,onChange:t=>u(n=>({...n,[e.name]:t}))},e.name)),d.phase===`form`&&d.notice&&(0,z.jsx)(`p`,{role:`alert`,className:`text-pretty rounded-lg border border-failed/40 bg-failed-soft px-3 py-2 text-sm text-failed`,children:d.notice}),(0,z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:x,className:Vb,onClick:s,children:`取消`}),(0,z.jsx)(`button`,{type:`submit`,disabled:x,className:R(Vb,`bg-ink text-paper`),children:x?`執行中…`:c.label})]})]}),d.phase===`confirm`&&(0,z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,z.jsxs)(`p`,{className:`text-pretty text-sm`,children:[`這個動作不能復原。確定要`,c.label,typeof h.run==`string`?`(${h.run})`:typeof h.name==`string`?`(${h.name})`:``,`嗎?`]}),p!==void 0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`eyebrow`,children:`預覽(不會改動任何東西)`}),(0,z.jsx)(`pre`,{className:`mt-1 max-h-60 overflow-auto rounded-lg border border-line bg-wall p-3 font-mono text-xs whitespace-pre-wrap`,children:p})]}),d.need===`typed`&&(0,z.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,z.jsxs)(`span`,{children:[`輸入 `,(0,z.jsx)(`strong`,{className:`font-mono`,children:d.target}),` 以確認`]}),(0,z.jsx)(`input`,{className:Bb,value:d.typed,autoComplete:`off`,onChange:e=>f({type:`typed`,value:e.target.value})})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,autoFocus:!0,className:Vb,onClick:s,children:`取消`}),(0,z.jsx)(`button`,{type:`button`,className:Vb,onClick:()=>{_.current.invalidate(),m(void 0),f({type:`back`})},children:`回上一步`}),(0,z.jsxs)(`button`,{type:`button`,disabled:!Ib(d),className:R(Vb,`border-failed bg-failed text-paper`),onClick:()=>void v({confirm:!0,...d.need===`typed`?{confirmText:d.typed}:{}}),children:[`確定`,c.label]})]})]}),d.phase===`done`&&(0,z.jsx)(Wb,{result:d.result,onClose:s})]})}function Wb({result:e,onClose:t}){if(e.kind===`job`)return(0,z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,z.jsxs)(`p`,{className:`text-sm`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`mr-1 text-signal`,children:`✓`}),`已在背景啟動(pid `,e.job.pid,`)。關掉這個頁面也會繼續跑。`]}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(`a`,{className:R(Vb,`inline-flex items-center`),href:`#!jobs`,onClick:t,children:`看任務輸出`}),(0,z.jsx)(`button`,{type:`button`,autoFocus:!0,className:R(Vb,`bg-ink text-paper`),onClick:t,children:`關閉`})]})]});if(e.kind!==`short`)return null;let n=Lo(e.result.exit,e.result.timedOut),r=[e.result.stdout,e.result.stderr].filter(Boolean).join(`
|
|
87
|
-
`);return(0,z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,z.jsxs)(`p`,{className:R(`flex flex-wrap items-center gap-2 text-sm font-medium`,Rb[n.tone]),children:[(0,z.jsx)(`span`,{"aria-hidden":!0,children:zb[n.tone]}),n.text,e.result.signal?(0,z.jsxs)(`span`,{className:`font-mono text-xs`,children:[`(訊號 `,e.result.signal,`)`]}):null]}),r&&(0,z.jsx)(`pre`,{className:`max-h-80 overflow-auto rounded-lg border border-line bg-wall p-3 font-mono text-xs whitespace-pre-wrap`,children:r}),e.result.truncated&&(0,z.jsx)(`p`,{className:`text-xs text-ink/60`,children:`輸出太長,已截斷。`}),(0,z.jsx)(`div`,{className:`flex justify-end`,children:(0,z.jsx)(`button`,{type:`button`,autoFocus:!0,className:R(Vb,`bg-ink text-paper`),onClick:t,children:`關閉`})})]})}function Gb({field:e,value:t,error:n,options:r,autoFocus:i,onChange:a}){let o=(0,b.useId)(),s=`${o}-err`,c={id:o,"aria-invalid":n?!0:void 0,"aria-describedby":n?s:void 0,autoFocus:i},l=r??e.options;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.kind===`checkbox`?(0,z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`size-5`,checked:t===!0,onChange:e=>a(e.target.checked),...c}),(0,z.jsx)(`span`,{children:e.label})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{htmlFor:o,className:`text-sm font-medium`,children:[e.label,e.required&&(0,z.jsx)(`span`,{"aria-hidden":!0,className:`text-failed`,children:` *`})]}),e.kind===`textarea`?(0,z.jsx)(`textarea`,{className:R(Bb,`min-h-32`),value:typeof t==`string`?t:``,onChange:e=>a(e.target.value),...c}):l?(0,z.jsxs)(`select`,{className:Bb,value:typeof t==`string`?t:``,onChange:e=>a(e.target.value),...c,children:[(0,z.jsx)(`option`,{value:``,children:e.required?`請選擇`:`(預設)`}),l.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}):(0,z.jsx)(`input`,{className:Bb,value:typeof t==`string`?t:``,autoComplete:`off`,onChange:e=>a(e.target.value),...c})]}),e.help&&!n&&(0,z.jsx)(`p`,{className:`text-xs text-ink/60`,children:e.help}),n&&(0,z.jsx)(`p`,{id:s,role:`alert`,className:`text-sm text-failed`,children:n})]})}function Kb(e){return e?e.state!==`running`||e.live===!1:!1}function qb(e){return e?.tidy===!0||/tidy/i.test(e?.name??``)}var Jb=`lyceum.summaries`,Yb=(e,t)=>`${e}/${t}`;function Xb(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.text==`string`&&t.text.trim().length>0&&typeof t.generatedAt==`number`}function Zb(e){try{let t=JSON.parse(e().getItem(Jb)??`{}`);return!t||typeof t!=`object`||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(([,e])=>Xb(e)))}catch{return{}}}function Qb(e,t){let n=Object.entries(t).sort(([,e],[,t])=>t.generatedAt-e.generatedAt);for(let t=n.length;t>=Math.min(1,n.length);t--)try{e().setItem(Jb,JSON.stringify(Object.fromEntries(n.slice(0,t))));return}catch{}}function $b(e){let t=new Set,n=new Set;return{load:(t,n)=>Zb(e)[Yb(t,n)]??null,save:(r,i,a)=>{let o=Yb(r,i);t.has(o)||n.has(r)||Qb(e,{...Zb(e),[o]:a})},forget:(n,r)=>{let i=Yb(n,r);t.add(i);let a=Zb(e);i in a&&(delete a[i],Qb(e,a))},forgetProject:t=>{n.add(t);let r=`${t}/`,i=Zb(e),a=Object.fromEntries(Object.entries(i).filter(([e])=>!e.startsWith(r)));Object.keys(a).length!==Object.keys(i).length&&Qb(e,a)}}}var ex=$b(()=>window.localStorage);function tx(e){return(t,n,r)=>{r.exit===0&&(t===`clear`&&n.dryRun!==!0&&typeof n.project==`string`&&typeof n.run==`string`?e.forget(n.project,n.run):t===`project.remove`&&n.purge===!0&&typeof n.name==`string`&&e.forgetProject(n.name))}}var nx=tx(ex),rx=`min-h-11 rounded-lg border border-line bg-paper px-3 text-sm hover:bg-wall focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`;function ix({project:e,run:t}){let[n,r]=(0,b.useState)(),i=()=>r(void 0),a=Kb(t),o=!!t?.ask&&t.ask.unanswered>0;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{role:`toolbar`,"aria-label":`操作`,className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,className:rx,onClick:()=>r({id:`run`}),children:`新任務`}),o&&t&&(0,z.jsxs)(`button`,{type:`button`,className:`${rx} border-warn/60 bg-warn-soft text-warn`,onClick:()=>r(`answer`),children:[`回答問題(`,t.ask?.unanswered,`)`]}),a&&t&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,className:rx,onClick:()=>r({id:`resume`,initial:{run:t.run_id}}),children:`續跑/追問`}),(0,z.jsx)(`button`,{type:`button`,className:rx,onClick:()=>r({id:`clear`,initial:{run:t.run_id}}),children:`刪除這次任務`})]}),t&&(0,z.jsx)(`button`,{type:`button`,className:rx,onClick:()=>r(`reports`),children:`查看報告`}),(0,z.jsx)(`button`,{type:`button`,className:rx,onClick:()=>r({id:`tidy`}),children:`整理記憶`}),(0,z.jsx)(`button`,{type:`button`,className:rx,onClick:()=>r({id:`doctor`}),children:`檢查設定`})]}),n&&n!==`answer`&&n!==`reports`&&(0,z.jsx)(Ub,{id:n.id,open:!0,fixed:{project:e},initial:n.initial,onShortResult:nx,onClose:i}),t&&(0,z.jsx)(hb,{project:e,runId:t.run_id,open:n===`reports`,onClose:i}),t&&(0,z.jsx)(ub,{project:e,runId:t.run_id,open:n===`answer`,onClose:i})]})}function ax({run:e,agents:t,now:n}){let r=Hy(e,t,n);return(0,z.jsxs)(`figure`,{className:`panel p-3 sm:p-4`,children:[(0,z.jsx)(`figcaption`,{className:`text-balance text-base font-semibold`,children:`喚醒時間軸`}),r?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`mt-3 space-y-1`,children:r.lanes.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] sm:grid-cols-[7rem_minmax(0,1fr)] items-center gap-2`,children:[(0,z.jsx)(`div`,{className:`truncate font-mono text-xs text-ink/80`,title:e.agent,children:e.agent}),(0,z.jsxs)(`svg`,{viewBox:`0 0 1000 28`,preserveAspectRatio:`none`,className:`h-7 w-full`,role:`img`,"aria-label":`${e.agent} 的喚醒`,children:[(0,z.jsx)(`line`,{x1:`0`,x2:`1000`,y1:`20`,y2:`20`,className:`stroke-line`}),e.bars.map((e,t)=>(0,z.jsx)(`rect`,{x:e.x,y:e.live?6:8,width:Math.max(e.width,4),height:e.live?16:12,rx:`3`,className:e.live?`fill-none stroke-working`:e.ok?`fill-signal/70`:`fill-failed`,strokeWidth:e.live?8:0,children:(0,z.jsx)(`title`,{children:e.title})},`${e.x}-${t}`))]})]},e.agent))}),(0,z.jsxs)(`div`,{className:`mt-1 grid grid-cols-[5rem_minmax(0,1fr)] sm:grid-cols-[7rem_minmax(0,1fr)] text-xs tabular-nums text-ink/60`,children:[(0,z.jsx)(`span`,{}),(0,z.jsxs)(`span`,{className:`flex justify-between`,children:[(0,z.jsx)(`span`,{children:Vy(r.start)}),(0,z.jsx)(`span`,{children:Vy(r.end)})]})]}),(0,z.jsx)(`p`,{className:`text-pretty mt-2 text-sm text-ink/70`,children:`實心是已結束的喚醒,框線延伸到現在的是還在跑的。紅色是失敗。把游標放在色塊上看該輪的時間、token 與錯誤。`})]}):(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm`,children:`這個任務還沒有喚醒紀錄。`})]})}function ox({run:e}){let t=Gy(e),n=Math.max(1,...t.map(e=>e.output)),r=Ly(e?.cache_read_tokens??0,e?.cache_write_tokens??0);return(0,z.jsxs)(`section`,{className:`panel p-3 sm:p-4`,children:[(0,z.jsx)(`h2`,{className:`text-balance text-base font-semibold`,children:`Token 與快取`}),t.length===0?(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm`,children:`還沒有 token 紀錄。`}):(0,z.jsx)(`ul`,{className:`mt-3 grid gap-x-8 gap-y-3 lg:grid-cols-2`,children:t.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsxs)(`div`,{className:`flex justify-between gap-3 text-sm`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:e.agent}),(0,z.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums text-ink/70`,children:[Oy(e.output),e.cacheRead+e.cacheWrite>0?`,快取讀 ${Oy(e.cacheRead)}`:``,e.failed>0?`,失敗 ${e.failed}`:``]})]}),(0,z.jsx)(`div`,{className:`mt-1.5 h-2 overflow-hidden rounded-full bg-wall`,title:`輸出 ${e.output},快取讀 ${e.cacheRead},寫 ${e.cacheWrite}`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full bg-signal`,style:{width:`${e.output/n*100}%`}})})]},e.agent))}),(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm text-ink/70`,children:r||`這個 run 沒有快取紀錄(Codex 與較舊的 run 不會有)。`}),(0,z.jsx)(`p`,{className:`text-pretty text-sm text-ink/70`,children:`長條是輸出 token,相對輸出最多的 agent。`})]})}function sx({project:e,runId:t}){let[n,r]=(0,b.useState)(!1),[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)(()=>ex.load(e,t)?.text);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(He,{type:`button`,disabled:n,className:`panel shrink-0 self-stretch px-4 text-sm font-medium hover:bg-wall disabled:opacity-60`,onClick:()=>{r(!0),a(void 0),fetch(`/summary`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:e,runId:t})}).then(lx).then(n=>{ex.save(e,t,{text:n,generatedAt:Date.now()}),s(n)}).catch(e=>a(e instanceof Error?e.message:`沒有寫出摘要。`)).finally(()=>r(!1))},children:n?`正在總結`:`總結進度`}),(i||n||o)&&(0,z.jsxs)(`div`,{className:`basis-full`,"aria-live":`polite`,children:[i&&(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm text-failed`,children:i}),n&&(0,z.jsxs)(`div`,{className:`mt-4 space-y-2`,"aria-hidden":`true`,children:[(0,z.jsx)(`div`,{className:`h-3 animate-pulse rounded bg-line`}),(0,z.jsx)(`div`,{className:`h-3 w-2/3 animate-pulse rounded bg-line`})]}),!n&&o&&(0,z.jsx)(`div`,{className:`panel mt-3 px-4 pb-4`,children:cx(o).map((e,t)=>(0,z.jsx)(`p`,{className:`text-pretty mt-4 text-base leading-relaxed`,children:e},`${t}-${e.slice(0,24)}`))})]})]})}function cx(e){return e.trim().split(/\n{2,}/).map(e=>e.replace(/\s*\n\s*/g,` `).trim()).filter(Boolean)}async function lx(e){let t={};try{t=await e.json()}catch{throw Error(`沒有寫出摘要。`)}if(!e.ok||!t.text?.trim())throw Error(t.error||`沒有寫出摘要。`);return t.text.trim()}function ux({name:e,frame:t,runId:n,now:r,onRun:i}){if(t.error)return(0,z.jsxs)(`article`,{className:`enter animate-in fade-in p-6 duration-200`,children:[(0,z.jsx)(`h1`,{className:`text-balance text-2xl font-semibold tracking-tight`,children:e}),(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm text-failed`,children:t.error}),(0,z.jsxs)(`p`,{className:`text-pretty mt-2 text-sm`,children:[`在終端執行 agent-lyceum status -p `,e,` 看這個專案。`]})]});let a=Ny(t),o=a.find(e=>e.run?.run_id===n)??Py(t),s=o?.run,c=o?.agents??t.report?.agents??[],l=Yy(c,s);return(0,z.jsxs)(`div`,{className:`enter animate-in fade-in grid w-full gap-4 p-3 duration-200 sm:gap-6 sm:p-4 lg:grid-cols-[minmax(0,1fr)_18rem] lg:p-6 2xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4 sm:gap-6`,children:[(0,z.jsxs)(`header`,{children:[(0,z.jsx)(`p`,{className:`eyebrow`,children:e}),s?(0,z.jsx)(dx,{name:e,run:s,now:r}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`h1`,{className:`text-balance mt-2 text-2xl font-semibold tracking-tight`,children:`還沒有任務`}),(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm`,children:`註冊的 agent 列在下面。`})]}),(0,z.jsx)(`div`,{className:`mt-4`,children:(0,z.jsx)(ix,{project:e,run:s})})]}),s?.ask&&s.ask.unanswered>0&&(0,z.jsxs)(`p`,{className:`text-pretty mt-4 rounded-lg border border-warn/40 bg-warn-soft px-3 py-2 text-sm text-warn`,children:[`等待回答 `,s.ask.unanswered,`/`,s.ask.total,`。檔案在 `,s.ask.path]}),s?.failure&&(0,z.jsxs)(`div`,{className:`mt-4 rounded-lg border border-failed/40 bg-failed-soft px-3 py-2`,children:[(0,z.jsxs)(`p`,{className:`text-sm text-failed`,children:[s.failure.agent,` 連續失敗 `,s.failure.attempts,` 次`]}),s.failure.error&&(0,z.jsx)(`p`,{className:`text-pretty mt-1 text-sm leading-relaxed text-failed`,children:wy(s.failure.error)})]}),l.length>0&&(0,z.jsx)(Qy,{agents:c,run:s,now:r}),(0,z.jsx)(ax,{run:s,agents:c,now:r}),l.length===0&&(0,z.jsx)(Qy,{agents:c,run:s,now:r}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6`,children:[(0,z.jsx)(ox,{run:s}),s&&(0,z.jsx)(mx,{report:o})]})]}),(0,z.jsx)(px,{reports:a,currentId:s?.run_id,onRun:i})]})}function dx({name:e,run:t,now:n}){let r=t.task_summary||t.name||t.run_id,i=Ly(t.cache_read_tokens,t.cache_write_tokens),a=t.live===!1&&t.state===`running`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`h1`,{className:`mt-1 text-balance text-2xl font-semibold leading-snug tracking-tight wrap-break-word md:text-3xl`,children:[r,qb(t)&&(0,z.jsxs)(z.Fragment,{children:[` `,(0,z.jsx)(`span`,{className:`ml-2 align-middle rounded-full border border-line px-2 py-0.5 text-xs font-normal tracking-normal text-ink/70`,children:`已 tidy`})]})]}),(0,z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-stretch gap-3`,children:[(0,z.jsxs)(`dl`,{className:`grid min-w-0 flex-1 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-5`,children:[(0,z.jsxs)(`div`,{className:`panel px-3 py-2`,children:[(0,z.jsx)(`dt`,{className:`eyebrow`,children:`狀態`}),(0,z.jsxs)(`dd`,{className:R(`mt-1 flex items-center gap-2 font-mono text-lg tabular-nums`,yx(t)),children:[t.state===`running`&&(0,z.jsx)(`span`,{"aria-hidden":!0,className:`pulse-dot size-2 rounded-full bg-signal`}),ky(t)]}),a&&(0,z.jsx)(`p`,{className:`text-pretty mt-1 text-sm text-failed`,children:`程序已不存在`})]}),(0,z.jsx)(fx,{label:`輪次`,value:`第 ${t.rounds} 輪`}),(0,z.jsx)(fx,{label:`token`,value:Oy(t.output_tokens)}),(0,z.jsx)(fx,{label:`已經過`,value:zy(t,n)}),(0,z.jsx)(fx,{label:`進度`,value:jy(t)})]}),(0,z.jsx)(sx,{project:e,runId:t.run_id},`${e}/${t.run_id}`)]}),i&&(0,z.jsx)(`p`,{className:`mt-3 font-mono text-sm tabular-nums text-ink/70`,children:i}),t.current_step&&(0,z.jsxs)(`p`,{className:`text-pretty mt-3 text-sm text-ink/80`,children:[(0,z.jsx)(`span`,{className:`eyebrow mr-2`,children:`目前`}),t.current_step]})]})}function fx({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`panel px-3 py-2`,children:[(0,z.jsx)(`dt`,{className:`eyebrow`,children:e}),(0,z.jsx)(`dd`,{className:`mt-1 font-mono text-lg tabular-nums`,children:t})]})}function px({reports:e,currentId:t,onRun:n}){return(0,z.jsxs)(`aside`,{className:`panel p-3 lg:sticky lg:top-14 lg:max-h-[calc(100dvh-4.5rem)] lg:self-start lg:overflow-y-auto`,children:[(0,z.jsx)(`h2`,{className:`eyebrow`,children:`較早班次`}),e.length===0?(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm`,children:`這個專案還沒有任務。`}):(0,z.jsx)(`div`,{className:`mt-3 max-lg:flex max-lg:gap-2 max-lg:overflow-x-auto [&>button]:max-lg:w-64 [&>button]:max-lg:shrink-0`,children:e.map(e=>{let r=e.run;if(!r)return null;let i=r.run_id===t;return(0,z.jsxs)(He,{type:`button`,"aria-current":i?`true`:void 0,className:R(`block min-h-11 w-full rounded-lg border px-3 py-2.5 text-left`,i?`border-line bg-wall`:`border-transparent hover:bg-wall/70`),onClick:()=>n(r.run_id),children:[(0,z.jsxs)(`span`,{className:`flex items-baseline justify-between gap-3 font-mono text-xs tabular-nums`,children:[(0,z.jsx)(`span`,{className:`text-ink/70`,children:vx(r.started_at)}),(0,z.jsx)(`span`,{className:yx(r),children:ky(r)})]}),(0,z.jsxs)(`span`,{className:R(`text-pretty mt-1 block text-sm`,i&&`font-medium`),children:[r.task_summary||r.name||r.run_id,qb(r)&&(0,z.jsx)(`span`,{className:`ml-2 rounded-full border border-line px-2 py-0.5 text-xs font-normal text-ink/70`,children:`已 tidy`})]})]},r.run_id)})})]})}function mx({report:e}){let t=e?.run;if(!t)return null;let n=t.steps??[];return(0,z.jsxs)(`section`,{className:`panel p-3 sm:p-4`,children:[(0,z.jsx)(`h2`,{className:`text-balance text-base font-semibold`,children:`這次任務`}),(0,z.jsxs)(`div`,{className:`grid gap-x-8 md:grid-cols-2 2xl:grid-cols-3`,children:[n.length>0&&(0,z.jsx)(`ol`,{className:`mt-3 list-decimal space-y-1 pl-5 text-sm`,children:n.map(e=>(0,z.jsx)(`li`,{className:R(`text-pretty`,e.done&&`text-ink/60 line-through`),children:e.text},e.text))}),(t.queue??[]).length>0&&(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsx)(`h3`,{className:`eyebrow text-balance`,children:`佇列`}),(t.queue??[]).map((e,t)=>(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mt-4 text-sm text-ink/60`,children:e.agent}),(0,z.jsx)(Sy,{mail:e})]},`${t}-${e.agent}-${e.subject}`))]}),(t.blocked_integrations??[]).length>0&&(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsx)(`h3`,{className:`eyebrow text-balance`,children:`受阻的整合`}),(t.blocked_integrations??[]).map(e=>(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsxs)(`p`,{className:`text-sm`,children:[e.agent,` `,(0,z.jsx)(`span`,{className:`text-ink/60`,children:e.branch})]}),(0,z.jsx)(`p`,{className:`text-pretty mt-1 text-sm leading-relaxed`,children:e.reason})]},`${e.agent}-${e.branch}`))]}),(t.notes??[]).length>0&&(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsx)(`h3`,{className:`eyebrow text-balance`,children:`備註`}),(t.notes??[]).map((e,t)=>(0,z.jsx)(hx,{text:e},`${t}-${e.slice(0,24)}`))]}),(e?.memory_advice??[]).length>0&&(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsx)(`h3`,{className:`eyebrow text-balance`,children:`記憶建議`}),(e?.memory_advice??[]).map(e=>(0,z.jsx)(gx,{text:e},e))]}),(t.result_head??[]).length>0&&(0,z.jsx)(_x,{lines:t.result_head??[]})]})]})}function hx({text:e}){let{head:t,body:n}=Ty(e),r=wy(n),i=n.length>r.length+40;return(0,z.jsxs)(Ts,{className:`group mt-3`,children:[t&&(0,z.jsx)(`p`,{className:`text-sm`,children:t}),(0,z.jsx)(`p`,{className:R(`text-pretty text-sm leading-relaxed`,t&&`mt-1`),children:r}),i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Ds,{className:`mt-1 text-sm text-ink/60`,children:[(0,z.jsx)(`span`,{className:`group-data-[open]:hidden`,children:`展開全文`}),(0,z.jsx)(`span`,{className:`hidden group-data-[open]:inline`,children:`收合全文`})]}),(0,z.jsx)(Ys,{children:(0,z.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-ink/80`,children:n})})]})]})}function gx({text:e}){let t=e.indexOf(`:`);return t===-1?(0,z.jsx)(`p`,{className:`text-pretty mt-2 text-sm leading-relaxed`,children:e}):(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsx)(`p`,{className:`text-sm`,children:e.slice(0,t).trim()}),(0,z.jsx)(`p`,{className:`text-pretty mt-0.5 text-sm leading-relaxed text-ink/80`,children:e.slice(t+1).trim()})]})}function _x({lines:e}){return(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsx)(`h3`,{className:`eyebrow text-balance`,children:`結果`}),Ey(e).map((e,t)=>e.kind===`title`?(0,z.jsx)(`p`,{className:`text-pretty mt-2 text-base font-semibold leading-snug`,children:e.text},t):e.kind===`label`?(0,z.jsx)(`p`,{className:`mt-3 text-sm text-ink/60`,children:e.text},t):e.kind===`fact`?(0,z.jsxs)(`p`,{className:`mt-2 flex gap-3 text-sm`,children:[(0,z.jsx)(`span`,{className:`w-16 shrink-0 sm:w-20 text-ink/60`,children:e.text}),(0,z.jsx)(`span`,{children:e.extra})]},t):(0,z.jsx)(`p`,{className:`text-pretty mt-2 leading-relaxed`,children:e.text},t))]})}function vx(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(`zh-Hant`,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function yx(e){return e.state===`running`?`text-signal`:e.outcome===`failed`?`text-failed`:`text-ink`}function bx(e){if(e.error)return`讀不到`;let t=Py(e)?.run;if(!t)return`閒置`;let n=Object.keys(t.active),r=t.state===`running`&&n.length>0?` ${n.join(` `)}`:``;return`${ky(t)}${r}`}function xx(e,t){return e===`down`?`正在連上本機狀態…`:t===0?`還沒有已註冊的專案。用 agent-lyceum project add 註冊一個。`:`選一個專案。`}var Sx=[{id:`project.add`,blurb:`把一個 repo 註冊成專案。`},{id:`project.remove`,blurb:`取消註冊;預設保留 context。`},{id:`call`,blurb:`不開專案,直接請全域 library 的某位 agent 做一件事。`},{id:`clear.lock`,blurb:`run 當掉後留下的鎖,確認沒人在跑再清。`},{id:`demo`,blurb:`在沙盒裡跑一次完整示範。`},{id:`init`,blurb:`建立 home 與預設的全域 agent library。`}];function Cx({projects:e}){let[t,n]=(0,b.useState)();return(0,z.jsxs)(`article`,{className:`enter animate-in fade-in p-4 duration-200 sm:p-6`,children:[(0,z.jsx)(`h1`,{className:`text-balance text-2xl font-semibold tracking-tight`,children:`工具`}),(0,z.jsx)(`p`,{className:`text-pretty mt-2 text-sm`,children:`專案內的操作(新任務、續跑、回答問題…)在各專案頁面上。這裡放不屬於單一專案的。`}),(0,z.jsx)(`ul`,{className:`mt-6 grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Sx.map(e=>(0,z.jsxs)(`li`,{className:`panel flex flex-col gap-3 p-4`,children:[(0,z.jsx)(`h2`,{className:`font-medium`,children:Nb[e.id].label}),(0,z.jsx)(`p`,{className:`text-pretty text-sm text-ink/70`,children:e.blurb}),(0,z.jsxs)(`button`,{type:`button`,className:`mt-auto min-h-11 self-start rounded-lg border border-line bg-paper px-4 text-sm hover:bg-wall focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`,onClick:()=>n(e.id),children:[Nb[e.id].label,`…`]})]},e.id))}),t&&(0,z.jsx)(Ub,{id:t,open:!0,fieldOptions:t===`project.remove`?{name:e}:t===`clear.lock`?{project:e}:void 0,onShortResult:nx,onClose:()=>n(void 0)})]})}function wx(){let[e,t]=(0,b.useState)(()=>new Map),[n,r]=(0,b.useState)(`down`),[i,a]=(0,b.useState)(()=>Date.now()),[o,s]=(0,b.useState)(Ex),[c,l]=(0,b.useState)(0),[u,d]=(0,b.useState)(void 0),[f,p]=(0,b.useState)(Ax),[m,h]=(0,b.useState)(!1),[g,_]=(0,b.useTransition)(),v=Bo(g);(0,b.useEffect)(()=>{let e=new EventSource(`/events`);return e.onopen=()=>r(`up`),e.onerror=()=>r(`down`),e.onmessage=e=>{let n=JSON.parse(e.data);n.type===`quota`?d(n.reports):(n.type===`snapshot`&&n.quota&&d(n.quota),t(e=>Dx(e,n)))},()=>e.close()},[c]),(0,b.useEffect)(()=>{let e=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(e)},[]),(0,b.useEffect)(()=>{let e=()=>_(()=>s(Ex()));return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let y=[...e.keys()].sort((t,n)=>Ox(Fy(e.get(t)),Fy(e.get(n)))||t.localeCompare(n)),x=m?y:y.filter(e=>!f.has(e)),S=y.filter(e=>f.has(e)).length,C=o.project&&e.has(o.project)?o.project:x[0]??y[0],w=e=>p(t=>{let n=new Set(t);return n.delete(e)||n.add(e),jx(n),n}),T=C?e.get(C):void 0,ee=n===`down`&&y.length===0&&!o.view;return(0,z.jsxs)(`div`,{className:`grid h-dvh grid-cols-1 grid-rows-[auto_minmax(0,1fr)] bg-wall md:grid-cols-[14rem_minmax(0,1fr)] md:grid-rows-1 xl:grid-cols-[16rem_minmax(0,1fr)]`,children:[(0,z.jsxs)(`nav`,{"aria-label":`已註冊專案`,className:`inset-safe z-20 flex items-center gap-2 overflow-x-auto border-b border-line bg-paper p-3 md:sticky md:top-0 md:h-dvh md:flex-col md:items-stretch md:overflow-y-auto md:border-r md:border-b-0`,children:[(0,z.jsx)(`p`,{className:`eyebrow hidden px-2 pt-2 pb-1 md:block`,children:`專案`}),x.length===0?y.length>0?(0,z.jsx)(`p`,{className:`text-pretty px-2 text-sm`,children:`專案都已隱藏。`}):n===`up`?(0,z.jsx)(`p`,{className:`text-pretty px-2 text-sm`,children:`還沒有已註冊的專案。`}):(0,z.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:`flex items-center gap-2 px-2 text-sm text-ink/70`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`pulse-dot size-2 shrink-0 rounded-full bg-signal`}),`正在連上本機狀態…`]}):x.map(t=>{let n=e.get(t),r=!o.view&&t===C,i=n?Py(n)?.run?.state===`running`:!1,a=f.has(t);return(0,z.jsxs)(`div`,{className:R(`group relative shrink-0`,a&&`opacity-60`),children:[(0,z.jsxs)(He,{type:`button`,className:R(`min-h-11 w-full min-w-36 rounded-lg border px-3 py-2 pr-9 text-left md:min-w-0`,r?`border-line bg-wall`:`border-transparent hover:bg-wall/70`),onClick:()=>Tx(t),children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 truncate text-sm font-medium`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:R(`size-2 shrink-0 rounded-full`,i?`pulse-dot bg-signal`:n?.error?`bg-failed`:`bg-ink/25`)}),(0,z.jsx)(`span`,{className:`truncate`,children:t})]}),(0,z.jsx)(`span`,{className:R(`mt-0.5 block truncate pl-4 font-mono text-xs tabular-nums`,i?`text-signal`:`text-ink/60`),children:n?bx(n):``})]}),(0,z.jsx)(He,{type:`button`,"aria-label":a?`顯示 ${t}`:`隱藏 ${t}`,title:a?`取消隱藏`:`隱藏`,className:`absolute top-1 right-1 inline-flex size-7 items-center justify-center rounded-md text-xs text-ink/50 hover:bg-wall hover:text-ink focus-visible:outline-2 focus-visible:outline-signal md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100`,onClick:()=>w(t),children:(0,z.jsx)(Mx,{off:!a})})]},t)}),S>0&&(0,z.jsx)(He,{type:`button`,className:`min-h-9 shrink-0 rounded-lg px-3 text-left text-xs text-ink/60 underline`,onClick:()=>h(e=>!e),children:m?`收起已隱藏`:`顯示已隱藏 (${S})`}),(0,z.jsx)(`div`,{className:`flex items-center gap-2 md:mt-4 md:flex-col md:items-stretch md:border-t md:border-line md:pt-3`,children:[[`decisions`,`決策`],[`tools`,`工具`],[`jobs`,`任務輸出`]].map(([e,t])=>(0,z.jsx)(`a`,{href:`#!${e}`,"aria-current":o.view===e?`page`:void 0,className:R(`inline-flex min-h-11 min-w-24 shrink-0 items-center rounded-lg border px-3 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`,o.view===e?`border-line bg-wall`:`border-transparent hover:bg-wall/70`),children:t},e))}),n===`down`&&(0,z.jsx)(He,{type:`button`,className:`min-h-11 shrink-0 rounded-lg border border-line px-3 text-sm underline md:hidden`,onClick:()=>l(e=>e+1),children:`重新連線`}),(0,z.jsx)(`div`,{className:`mt-auto hidden px-2 pb-2 md:block`,children:n===`up`?(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-ink/60`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-signal`}),`即時更新`]}):(0,z.jsx)(He,{type:`button`,className:`text-sm underline`,onClick:()=>l(e=>e+1),children:`重新連線`})})]}),(0,z.jsxs)(`main`,{className:`min-h-0 overflow-y-auto bg-wall`,"aria-busy":g||ee||void 0,children:[v&&(0,z.jsx)(Uo,{label:`正在切換畫面…`}),(n===`up`||u&&u.length>0)&&(0,z.jsx)(Tn,{reports:u??[],onReports:d}),ee?(0,z.jsx)(Ho,{label:`正在讀取專案狀態…`}):o.view===`decisions`?(0,z.jsx)(Po,{}):o.view===`tools`?(0,z.jsx)(Cx,{projects:y}):o.view===`jobs`?(0,z.jsx)(Ko,{}):T&&C?(0,z.jsx)(`div`,{className:R(v&&`opacity-70 motion-safe:transition-opacity motion-safe:duration-150`),children:(0,z.jsx)(ux,{name:C,frame:T,runId:o.project===C?o.run:void 0,now:i,onRun:e=>Tx(C,e)})},`${C}/${o.project===C?o.run??``:``}`):(0,z.jsxs)(`article`,{className:`enter animate-in fade-in p-4 duration-200 sm:p-6`,children:[(0,z.jsx)(`h1`,{className:`text-balance text-2xl font-semibold tracking-tight`,children:xx(n,y.length)}),n===`up`&&y.length===0&&(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm`,children:`在終端執行 agent-lyceum project add 註冊一個專案。`}),n===`down`&&(0,z.jsx)(He,{type:`button`,className:`mt-4 min-h-11 rounded-md border border-line bg-paper px-4 py-1.5 text-sm hover:bg-wall`,onClick:()=>l(e=>e+1),children:`重新連線`})]})]})]})}function Tx(e,t){let n=t?`${encodeURIComponent(e)}/${encodeURIComponent(t)}`:encodeURIComponent(e);location.hash=n}function Ex(){try{let e=decodeURIComponent(location.hash.replace(/^#/,``));if(!e)return{};if(e===`!tools`||e===`!jobs`||e===`!decisions`)return{view:e.slice(1)};let t=e.indexOf(`/`);return t===-1?{project:e}:{project:e.slice(0,t),run:e.slice(t+1)}}catch{return{}}}function Dx(e,t){if(t.type===`quota`)return e;if(t.type===`snapshot`)return new Map(t.projects.map(e=>[e.name,e.frame]));let n=new Map(e);return t.type===`removed`?n.delete(t.name):n.set(t.name,t.frame),n}function Ox(e,t){return e===t?0:e>t?-1:1}var kx=`lyceum.hiddenProjects`;function Ax(){try{let e=JSON.parse(localStorage.getItem(kx)??`[]`);return new Set(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])}catch{return new Set}}function jx(e){try{localStorage.setItem(kx,JSON.stringify([...e]))}catch{}}function Mx({off:e}){return(0,z.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`path`,{d:`M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z`}),(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),e&&(0,z.jsx)(`path`,{d:`M4 4l16 16`})]})}var Nx=document.getElementById(`root`);Nx&&(0,Ue.createRoot)(Nx).render((0,z.jsx)(b.StrictMode,{children:(0,z.jsx)(wx,{})}));
|
|
87
|
+
`);return(0,z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,z.jsxs)(`p`,{className:R(`flex flex-wrap items-center gap-2 text-sm font-medium`,Rb[n.tone]),children:[(0,z.jsx)(`span`,{"aria-hidden":!0,children:zb[n.tone]}),n.text,e.result.signal?(0,z.jsxs)(`span`,{className:`font-mono text-xs`,children:[`(訊號 `,e.result.signal,`)`]}):null]}),r&&(0,z.jsx)(`pre`,{className:`max-h-80 overflow-auto rounded-lg border border-line bg-wall p-3 font-mono text-xs whitespace-pre-wrap`,children:r}),e.result.truncated&&(0,z.jsx)(`p`,{className:`text-xs text-ink/60`,children:`輸出太長,已截斷。`}),(0,z.jsx)(`div`,{className:`flex justify-end`,children:(0,z.jsx)(`button`,{type:`button`,autoFocus:!0,className:R(Vb,`bg-ink text-paper`),onClick:t,children:`關閉`})})]})}function Gb({field:e,value:t,error:n,options:r,autoFocus:i,onChange:a}){let o=(0,b.useId)(),s=`${o}-err`,c={id:o,"aria-invalid":n?!0:void 0,"aria-describedby":n?s:void 0,autoFocus:i},l=r??e.options;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.kind===`checkbox`?(0,z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`size-5`,checked:t===!0,onChange:e=>a(e.target.checked),...c}),(0,z.jsx)(`span`,{children:e.label})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{htmlFor:o,className:`text-sm font-medium`,children:[e.label,e.required&&(0,z.jsx)(`span`,{"aria-hidden":!0,className:`text-failed`,children:` *`})]}),e.kind===`textarea`?(0,z.jsx)(`textarea`,{className:R(Bb,`min-h-32`),value:typeof t==`string`?t:``,onChange:e=>a(e.target.value),...c}):l?(0,z.jsxs)(`select`,{className:Bb,value:typeof t==`string`?t:``,onChange:e=>a(e.target.value),...c,children:[(0,z.jsx)(`option`,{value:``,children:e.required?`請選擇`:`(預設)`}),l.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}):(0,z.jsx)(`input`,{className:Bb,value:typeof t==`string`?t:``,autoComplete:`off`,onChange:e=>a(e.target.value),...c})]}),e.help&&!n&&(0,z.jsx)(`p`,{className:`text-xs text-ink/60`,children:e.help}),n&&(0,z.jsx)(`p`,{id:s,role:`alert`,className:`text-sm text-failed`,children:n})]})}function Kb(e){return e?e.state!==`running`||e.live===!1:!1}function qb(e){return e?.tidy===!0||/tidy/i.test(e?.name??``)}function Jb(e){return qb(e)}var Yb=`lyceum.summaries`,Xb=(e,t)=>`${e}/${t}`;function Zb(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.text==`string`&&t.text.trim().length>0&&typeof t.generatedAt==`number`}function Qb(e){try{let t=JSON.parse(e().getItem(Yb)??`{}`);return!t||typeof t!=`object`||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(([,e])=>Zb(e)))}catch{return{}}}function $b(e,t){let n=Object.entries(t).sort(([,e],[,t])=>t.generatedAt-e.generatedAt);for(let t=n.length;t>=Math.min(1,n.length);t--)try{e().setItem(Yb,JSON.stringify(Object.fromEntries(n.slice(0,t))));return}catch{}}function ex(e){let t=new Set,n=new Set;return{load:(t,n)=>Qb(e)[Xb(t,n)]??null,save:(r,i,a)=>{let o=Xb(r,i);t.has(o)||n.has(r)||$b(e,{...Qb(e),[o]:a})},forget:(n,r)=>{let i=Xb(n,r);t.add(i);let a=Qb(e);i in a&&(delete a[i],$b(e,a))},forgetProject:t=>{n.add(t);let r=`${t}/`,i=Qb(e),a=Object.fromEntries(Object.entries(i).filter(([e])=>!e.startsWith(r)));Object.keys(a).length!==Object.keys(i).length&&$b(e,a)}}}var tx=ex(()=>window.localStorage);function nx(e){return(t,n,r)=>{r.exit===0&&(t===`clear`&&n.dryRun!==!0&&typeof n.project==`string`&&typeof n.run==`string`?e.forget(n.project,n.run):t===`project.remove`&&n.purge===!0&&typeof n.name==`string`&&e.forgetProject(n.name))}}var rx=nx(tx),ix=`min-h-11 rounded-lg border border-line bg-paper px-3 text-sm hover:bg-wall focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal disabled:cursor-not-allowed disabled:opacity-50`;function ax({project:e,run:t}){let[n,r]=(0,b.useState)(),i=()=>r(void 0),a=Kb(t),o=!!t?.ask&&t.ask.unanswered>0,s=Jb(t);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{role:`toolbar`,"aria-label":`操作`,className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,className:ix,disabled:s,onClick:()=>r({id:`run`}),children:`新任務`}),o&&t&&(0,z.jsxs)(`button`,{type:`button`,className:`${ix} border-warn/60 bg-warn-soft text-warn`,disabled:s,onClick:()=>r(`answer`),children:[`回答問題(`,t.ask?.unanswered,`)`]}),a&&t&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,className:ix,disabled:s,onClick:()=>r({id:`resume`,initial:{run:t.run_id}}),children:`續跑/追問`}),(0,z.jsx)(`button`,{type:`button`,className:ix,disabled:s,onClick:()=>r({id:`clear`,initial:{run:t.run_id}}),children:`刪除這次任務`})]}),t&&(0,z.jsx)(`button`,{type:`button`,className:ix,disabled:s,onClick:()=>r(`reports`),children:`查看報告`}),(0,z.jsx)(`button`,{type:`button`,className:ix,disabled:s,onClick:()=>r({id:`tidy`,initial:t?{run:t.run_id}:void 0}),children:`整理記憶`}),(0,z.jsx)(`button`,{type:`button`,className:ix,disabled:s,onClick:()=>r({id:`doctor`}),children:`檢查設定`}),s&&(0,z.jsx)(`p`,{className:`text-pretty basis-full text-sm text-ink/70`,children:`這個任務已 tidy,按鈕不能再操作。`})]}),n&&n!==`answer`&&n!==`reports`&&(0,z.jsx)(Ub,{id:n.id,open:!0,fixed:{project:e},initial:n.initial,onShortResult:rx,onClose:i}),t&&(0,z.jsx)(hb,{project:e,runId:t.run_id,open:n===`reports`,onClose:i}),t&&(0,z.jsx)(ub,{project:e,runId:t.run_id,open:n===`answer`,onClose:i})]})}function ox({run:e,agents:t,now:n}){let r=Hy(e,t,n);return(0,z.jsxs)(`figure`,{className:`panel p-3 sm:p-4`,children:[(0,z.jsx)(`figcaption`,{className:`text-balance text-base font-semibold`,children:`喚醒時間軸`}),r?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`mt-3 space-y-1`,children:r.lanes.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] sm:grid-cols-[7rem_minmax(0,1fr)] items-center gap-2`,children:[(0,z.jsx)(`div`,{className:`truncate font-mono text-xs text-ink/80`,title:e.agent,children:e.agent}),(0,z.jsxs)(`svg`,{viewBox:`0 0 1000 28`,preserveAspectRatio:`none`,className:`h-7 w-full`,role:`img`,"aria-label":`${e.agent} 的喚醒`,children:[(0,z.jsx)(`line`,{x1:`0`,x2:`1000`,y1:`20`,y2:`20`,className:`stroke-line`}),e.bars.map((e,t)=>(0,z.jsx)(`rect`,{x:e.x,y:e.live?6:8,width:Math.max(e.width,4),height:e.live?16:12,rx:`3`,className:e.live?`fill-none stroke-working`:e.ok?`fill-signal/70`:`fill-failed`,strokeWidth:e.live?8:0,children:(0,z.jsx)(`title`,{children:e.title})},`${e.x}-${t}`))]})]},e.agent))}),(0,z.jsxs)(`div`,{className:`mt-1 grid grid-cols-[5rem_minmax(0,1fr)] sm:grid-cols-[7rem_minmax(0,1fr)] text-xs tabular-nums text-ink/60`,children:[(0,z.jsx)(`span`,{}),(0,z.jsxs)(`span`,{className:`flex justify-between`,children:[(0,z.jsx)(`span`,{children:Vy(r.start)}),(0,z.jsx)(`span`,{children:Vy(r.end)})]})]}),(0,z.jsx)(`p`,{className:`text-pretty mt-2 text-sm text-ink/70`,children:`實心是已結束的喚醒,框線延伸到現在的是還在跑的。紅色是失敗。把游標放在色塊上看該輪的時間、token 與錯誤。`})]}):(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm`,children:`這個任務還沒有喚醒紀錄。`})]})}function sx({run:e}){let t=Gy(e),n=Math.max(1,...t.map(e=>e.output)),r=Ly(e?.cache_read_tokens??0,e?.cache_write_tokens??0);return(0,z.jsxs)(`section`,{className:`panel p-3 sm:p-4`,children:[(0,z.jsx)(`h2`,{className:`text-balance text-base font-semibold`,children:`Token 與快取`}),t.length===0?(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm`,children:`還沒有 token 紀錄。`}):(0,z.jsx)(`ul`,{className:`mt-3 grid gap-x-8 gap-y-3 lg:grid-cols-2`,children:t.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsxs)(`div`,{className:`flex justify-between gap-3 text-sm`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:e.agent}),(0,z.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums text-ink/70`,children:[Oy(e.output),e.cacheRead+e.cacheWrite>0?`,快取讀 ${Oy(e.cacheRead)}`:``,e.failed>0?`,失敗 ${e.failed}`:``]})]}),(0,z.jsx)(`div`,{className:`mt-1.5 h-2 overflow-hidden rounded-full bg-wall`,title:`輸出 ${e.output},快取讀 ${e.cacheRead},寫 ${e.cacheWrite}`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full bg-signal`,style:{width:`${e.output/n*100}%`}})})]},e.agent))}),(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm text-ink/70`,children:r||`這個 run 沒有快取紀錄(Codex 與較舊的 run 不會有)。`}),(0,z.jsx)(`p`,{className:`text-pretty text-sm text-ink/70`,children:`長條是輸出 token,相對輸出最多的 agent。`})]})}function cx({project:e,runId:t,locked:n=!1}){let[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(()=>tx.load(e,t)?.text),l=()=>{i(!0),o(void 0),fetch(`/summary`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:e,runId:t})}).then(ux).then(n=>{tx.save(e,t,{text:n,generatedAt:Date.now()}),c(n)}).catch(e=>o(e instanceof Error?e.message:`沒有寫出摘要。`)).finally(()=>i(!1))};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(He,{type:`button`,disabled:r||n,className:`panel shrink-0 self-stretch px-4 text-sm font-medium hover:bg-wall disabled:cursor-not-allowed disabled:opacity-60`,onClick:()=>{n||l()},children:r?`正在總結`:`總結進度`}),(a||r||s)&&(0,z.jsxs)(`div`,{className:`basis-full`,"aria-live":`polite`,children:[a&&(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm text-failed`,children:a}),r&&(0,z.jsxs)(`div`,{className:`mt-4 space-y-2`,"aria-hidden":`true`,children:[(0,z.jsx)(`div`,{className:`h-3 animate-pulse rounded bg-line`}),(0,z.jsx)(`div`,{className:`h-3 w-2/3 animate-pulse rounded bg-line`})]}),!r&&s&&(0,z.jsx)(`div`,{className:`panel mt-3 px-4 pb-4`,children:lx(s).map((e,t)=>(0,z.jsx)(`p`,{className:`text-pretty mt-4 text-base leading-relaxed`,children:e},`${t}-${e.slice(0,24)}`))})]})]})}function lx(e){return e.trim().split(/\n{2,}/).map(e=>e.replace(/\s*\n\s*/g,` `).trim()).filter(Boolean)}async function ux(e){let t={};try{t=await e.json()}catch{throw Error(`沒有寫出摘要。`)}if(!e.ok||!t.text?.trim())throw Error(t.error||`沒有寫出摘要。`);return t.text.trim()}function dx({name:e,frame:t,runId:n,now:r,onRun:i}){if(t.error)return(0,z.jsxs)(`article`,{className:`enter animate-in fade-in p-6 duration-200`,children:[(0,z.jsx)(`h1`,{className:`text-balance text-2xl font-semibold tracking-tight`,children:e}),(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm text-failed`,children:t.error}),(0,z.jsxs)(`p`,{className:`text-pretty mt-2 text-sm`,children:[`在終端執行 agent-lyceum status -p `,e,` 看這個專案。`]})]});let a=Ny(t),o=a.find(e=>e.run?.run_id===n)??Py(t),s=o?.run,c=o?.agents??t.report?.agents??[],l=Yy(c,s);return(0,z.jsxs)(`div`,{className:`enter animate-in fade-in grid w-full gap-4 p-3 duration-200 sm:gap-6 sm:p-4 lg:grid-cols-[minmax(0,1fr)_18rem] lg:p-6 2xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4 sm:gap-6`,children:[(0,z.jsxs)(`header`,{children:[(0,z.jsx)(`p`,{className:`eyebrow`,children:e}),s?(0,z.jsx)(fx,{name:e,run:s,now:r}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`h1`,{className:`text-balance mt-2 text-2xl font-semibold tracking-tight`,children:`還沒有任務`}),(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm`,children:`註冊的 agent 列在下面。`})]}),(0,z.jsx)(`div`,{className:`mt-4`,children:(0,z.jsx)(ax,{project:e,run:s})})]}),s?.ask&&s.ask.unanswered>0&&(0,z.jsxs)(`p`,{className:`text-pretty mt-4 rounded-lg border border-warn/40 bg-warn-soft px-3 py-2 text-sm text-warn`,children:[`等待回答 `,s.ask.unanswered,`/`,s.ask.total,`。檔案在 `,s.ask.path]}),s?.failure&&(0,z.jsxs)(`div`,{className:`mt-4 rounded-lg border border-failed/40 bg-failed-soft px-3 py-2`,children:[(0,z.jsxs)(`p`,{className:`text-sm text-failed`,children:[s.failure.agent,` 連續失敗 `,s.failure.attempts,` 次`]}),s.failure.error&&(0,z.jsx)(`p`,{className:`text-pretty mt-1 text-sm leading-relaxed text-failed`,children:wy(s.failure.error)})]}),l.length>0&&(0,z.jsx)(Qy,{agents:c,run:s,now:r}),(0,z.jsx)(ox,{run:s,agents:c,now:r}),l.length===0&&(0,z.jsx)(Qy,{agents:c,run:s,now:r}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6`,children:[(0,z.jsx)(sx,{run:s}),s&&(0,z.jsx)(hx,{report:o})]})]}),(0,z.jsx)(mx,{reports:a,currentId:s?.run_id,onRun:i})]})}function fx({name:e,run:t,now:n}){let r=t.task_summary||t.name||t.run_id,i=Ly(t.cache_read_tokens,t.cache_write_tokens),a=t.live===!1&&t.state===`running`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`h1`,{className:`mt-1 text-balance text-2xl font-semibold leading-snug tracking-tight wrap-break-word md:text-3xl`,children:[r,qb(t)&&(0,z.jsxs)(z.Fragment,{children:[` `,(0,z.jsx)(`span`,{className:`ml-2 align-middle rounded-full border border-line px-2 py-0.5 text-xs font-normal tracking-normal text-ink/70`,children:`已 tidy`})]})]}),(0,z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-stretch gap-3`,children:[(0,z.jsxs)(`dl`,{className:`grid min-w-0 flex-1 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-5`,children:[(0,z.jsxs)(`div`,{className:`panel px-3 py-2`,children:[(0,z.jsx)(`dt`,{className:`eyebrow`,children:`狀態`}),(0,z.jsxs)(`dd`,{className:R(`mt-1 flex items-center gap-2 font-mono text-lg tabular-nums`,bx(t)),children:[t.state===`running`&&(0,z.jsx)(`span`,{"aria-hidden":!0,className:`pulse-dot size-2 rounded-full bg-signal`}),ky(t)]}),a&&(0,z.jsx)(`p`,{className:`text-pretty mt-1 text-sm text-failed`,children:`程序已不存在`})]}),(0,z.jsx)(px,{label:`輪次`,value:`第 ${t.rounds} 輪`}),(0,z.jsx)(px,{label:`token`,value:Oy(t.output_tokens)}),(0,z.jsx)(px,{label:`已經過`,value:zy(t,n)}),(0,z.jsx)(px,{label:`進度`,value:jy(t)})]}),(0,z.jsx)(cx,{project:e,runId:t.run_id,locked:Jb(t)},`${e}/${t.run_id}`)]}),i&&(0,z.jsx)(`p`,{className:`mt-3 font-mono text-sm tabular-nums text-ink/70`,children:i}),t.current_step&&(0,z.jsxs)(`p`,{className:`text-pretty mt-3 text-sm text-ink/80`,children:[(0,z.jsx)(`span`,{className:`eyebrow mr-2`,children:`目前`}),t.current_step]})]})}function px({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`panel px-3 py-2`,children:[(0,z.jsx)(`dt`,{className:`eyebrow`,children:e}),(0,z.jsx)(`dd`,{className:`mt-1 font-mono text-lg tabular-nums`,children:t})]})}function mx({reports:e,currentId:t,onRun:n}){return(0,z.jsxs)(`aside`,{className:`panel p-3 lg:sticky lg:top-14 lg:max-h-[calc(100dvh-4.5rem)] lg:self-start lg:overflow-y-auto`,children:[(0,z.jsx)(`h2`,{className:`eyebrow`,children:`較早班次`}),e.length===0?(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm`,children:`這個專案還沒有任務。`}):(0,z.jsx)(`div`,{className:`mt-3 max-lg:flex max-lg:gap-2 max-lg:overflow-x-auto [&>button]:max-lg:w-64 [&>button]:max-lg:shrink-0`,children:e.map(e=>{let r=e.run;if(!r)return null;let i=r.run_id===t;return(0,z.jsxs)(He,{type:`button`,"aria-current":i?`true`:void 0,className:R(`block min-h-11 w-full rounded-lg border px-3 py-2.5 text-left`,i?`border-line bg-wall`:`border-transparent hover:bg-wall/70`),onClick:()=>n(r.run_id),children:[(0,z.jsxs)(`span`,{className:`flex items-baseline justify-between gap-3 font-mono text-xs tabular-nums`,children:[(0,z.jsx)(`span`,{className:`text-ink/70`,children:yx(r.started_at)}),(0,z.jsx)(`span`,{className:bx(r),children:ky(r)})]}),(0,z.jsxs)(`span`,{className:R(`text-pretty mt-1 block text-sm`,i&&`font-medium`),children:[r.task_summary||r.name||r.run_id,qb(r)&&(0,z.jsx)(`span`,{className:`ml-2 rounded-full border border-line px-2 py-0.5 text-xs font-normal text-ink/70`,children:`已 tidy`})]})]},r.run_id)})})]})}function hx({report:e}){let t=e?.run;if(!t)return null;let n=t.steps??[];return(0,z.jsxs)(`section`,{className:`panel p-3 sm:p-4`,children:[(0,z.jsx)(`h2`,{className:`text-balance text-base font-semibold`,children:`這次任務`}),(0,z.jsxs)(`div`,{className:`grid gap-x-8 md:grid-cols-2 2xl:grid-cols-3`,children:[n.length>0&&(0,z.jsx)(`ol`,{className:`mt-3 list-decimal space-y-1 pl-5 text-sm`,children:n.map(e=>(0,z.jsx)(`li`,{className:R(`text-pretty`,e.done&&`text-ink/60 line-through`),children:e.text},e.text))}),(t.queue??[]).length>0&&(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsx)(`h3`,{className:`eyebrow text-balance`,children:`佇列`}),(t.queue??[]).map((e,t)=>(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mt-4 text-sm text-ink/60`,children:e.agent}),(0,z.jsx)(Sy,{mail:e})]},`${t}-${e.agent}-${e.subject}`))]}),(t.blocked_integrations??[]).length>0&&(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsx)(`h3`,{className:`eyebrow text-balance`,children:`受阻的整合`}),(t.blocked_integrations??[]).map(e=>(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsxs)(`p`,{className:`text-sm`,children:[e.agent,` `,(0,z.jsx)(`span`,{className:`text-ink/60`,children:e.branch})]}),(0,z.jsx)(`p`,{className:`text-pretty mt-1 text-sm leading-relaxed`,children:e.reason})]},`${e.agent}-${e.branch}`))]}),(t.notes??[]).length>0&&(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsx)(`h3`,{className:`eyebrow text-balance`,children:`備註`}),(t.notes??[]).map((e,t)=>(0,z.jsx)(gx,{text:e},`${t}-${e.slice(0,24)}`))]}),(e?.memory_advice??[]).length>0&&(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsx)(`h3`,{className:`eyebrow text-balance`,children:`記憶建議`}),(e?.memory_advice??[]).map(e=>(0,z.jsx)(_x,{text:e},e))]}),(t.result_head??[]).length>0&&(0,z.jsx)(vx,{lines:t.result_head??[]})]})]})}function gx({text:e}){let{head:t,body:n}=Ty(e),r=wy(n),i=n.length>r.length+40;return(0,z.jsxs)(Ts,{className:`group mt-3`,children:[t&&(0,z.jsx)(`p`,{className:`text-sm`,children:t}),(0,z.jsx)(`p`,{className:R(`text-pretty text-sm leading-relaxed`,t&&`mt-1`),children:r}),i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Ds,{className:`mt-1 text-sm text-ink/60`,children:[(0,z.jsx)(`span`,{className:`group-data-[open]:hidden`,children:`展開全文`}),(0,z.jsx)(`span`,{className:`hidden group-data-[open]:inline`,children:`收合全文`})]}),(0,z.jsx)(Ys,{children:(0,z.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-ink/80`,children:n})})]})]})}function _x({text:e}){let t=e.indexOf(`:`);return t===-1?(0,z.jsx)(`p`,{className:`text-pretty mt-2 text-sm leading-relaxed`,children:e}):(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsx)(`p`,{className:`text-sm`,children:e.slice(0,t).trim()}),(0,z.jsx)(`p`,{className:`text-pretty mt-0.5 text-sm leading-relaxed text-ink/80`,children:e.slice(t+1).trim()})]})}function vx({lines:e}){return(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsx)(`h3`,{className:`eyebrow text-balance`,children:`結果`}),Ey(e).map((e,t)=>e.kind===`title`?(0,z.jsx)(`p`,{className:`text-pretty mt-2 text-base font-semibold leading-snug`,children:e.text},t):e.kind===`label`?(0,z.jsx)(`p`,{className:`mt-3 text-sm text-ink/60`,children:e.text},t):e.kind===`fact`?(0,z.jsxs)(`p`,{className:`mt-2 flex gap-3 text-sm`,children:[(0,z.jsx)(`span`,{className:`w-16 shrink-0 sm:w-20 text-ink/60`,children:e.text}),(0,z.jsx)(`span`,{children:e.extra})]},t):(0,z.jsx)(`p`,{className:`text-pretty mt-2 leading-relaxed`,children:e.text},t))]})}function yx(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(`zh-Hant`,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function bx(e){return e.state===`running`?`text-signal`:e.outcome===`failed`?`text-failed`:`text-ink`}function xx(e){if(e.error)return`讀不到`;let t=Py(e)?.run;if(!t)return`閒置`;let n=Object.keys(t.active),r=t.state===`running`&&n.length>0?` ${n.join(` `)}`:``;return`${ky(t)}${r}`}function Sx(e,t){return e===`down`?`正在連上本機狀態…`:t===0?`還沒有已註冊的專案。用 agent-lyceum project add 註冊一個。`:`選一個專案。`}var Cx=[{id:`project.add`,blurb:`把一個 repo 註冊成專案。`},{id:`project.remove`,blurb:`取消註冊;預設保留 context。`},{id:`call`,blurb:`不開專案,直接請全域 library 的某位 agent 做一件事。`},{id:`clear.lock`,blurb:`run 當掉後留下的鎖,確認沒人在跑再清。`},{id:`demo`,blurb:`在沙盒裡跑一次完整示範。`},{id:`init`,blurb:`建立 home 與預設的全域 agent library。`}];function wx({projects:e}){let[t,n]=(0,b.useState)();return(0,z.jsxs)(`article`,{className:`enter animate-in fade-in p-4 duration-200 sm:p-6`,children:[(0,z.jsx)(`h1`,{className:`text-balance text-2xl font-semibold tracking-tight`,children:`工具`}),(0,z.jsx)(`p`,{className:`text-pretty mt-2 text-sm`,children:`專案內的操作(新任務、續跑、回答問題…)在各專案頁面上。這裡放不屬於單一專案的。`}),(0,z.jsx)(`ul`,{className:`mt-6 grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Cx.map(e=>(0,z.jsxs)(`li`,{className:`panel flex flex-col gap-3 p-4`,children:[(0,z.jsx)(`h2`,{className:`font-medium`,children:Nb[e.id].label}),(0,z.jsx)(`p`,{className:`text-pretty text-sm text-ink/70`,children:e.blurb}),(0,z.jsxs)(`button`,{type:`button`,className:`mt-auto min-h-11 self-start rounded-lg border border-line bg-paper px-4 text-sm hover:bg-wall focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`,onClick:()=>n(e.id),children:[Nb[e.id].label,`…`]})]},e.id))}),t&&(0,z.jsx)(Ub,{id:t,open:!0,fieldOptions:t===`project.remove`?{name:e}:t===`clear.lock`?{project:e}:void 0,onShortResult:rx,onClose:()=>n(void 0)})]})}function Tx(){let[e,t]=(0,b.useState)(()=>new Map),[n,r]=(0,b.useState)(`down`),[i,a]=(0,b.useState)(()=>Date.now()),[o,s]=(0,b.useState)(Dx),[c,l]=(0,b.useState)(0),[u,d]=(0,b.useState)(void 0),[f,p]=(0,b.useState)(jx),[m,h]=(0,b.useState)(!1),[g,_]=(0,b.useTransition)(),v=Bo(g);(0,b.useEffect)(()=>{let e=new EventSource(`/events`);return e.onopen=()=>r(`up`),e.onerror=()=>r(`down`),e.onmessage=e=>{let n=JSON.parse(e.data);n.type===`quota`?d(n.reports):(n.type===`snapshot`&&n.quota&&d(n.quota),t(e=>Ox(e,n)))},()=>e.close()},[c]),(0,b.useEffect)(()=>{let e=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(e)},[]),(0,b.useEffect)(()=>{let e=()=>_(()=>s(Dx()));return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let y=[...e.keys()].sort((t,n)=>kx(Fy(e.get(t)),Fy(e.get(n)))||t.localeCompare(n)),x=m?y:y.filter(e=>!f.has(e)),S=y.filter(e=>f.has(e)).length,C=o.project&&e.has(o.project)?o.project:x[0]??y[0],w=e=>p(t=>{let n=new Set(t);return n.delete(e)||n.add(e),Mx(n),n}),T=C?e.get(C):void 0,ee=n===`down`&&y.length===0&&!o.view;return(0,z.jsxs)(`div`,{className:`grid h-dvh grid-cols-1 grid-rows-[auto_minmax(0,1fr)] bg-wall md:grid-cols-[14rem_minmax(0,1fr)] md:grid-rows-1 xl:grid-cols-[16rem_minmax(0,1fr)]`,children:[(0,z.jsxs)(`nav`,{"aria-label":`已註冊專案`,className:`inset-safe z-20 flex items-center gap-2 overflow-x-auto border-b border-line bg-paper p-3 md:sticky md:top-0 md:h-dvh md:flex-col md:items-stretch md:overflow-y-auto md:border-r md:border-b-0`,children:[(0,z.jsx)(`p`,{className:`eyebrow hidden px-2 pt-2 pb-1 md:block`,children:`專案`}),x.length===0?y.length>0?(0,z.jsx)(`p`,{className:`text-pretty px-2 text-sm`,children:`專案都已隱藏。`}):n===`up`?(0,z.jsx)(`p`,{className:`text-pretty px-2 text-sm`,children:`還沒有已註冊的專案。`}):(0,z.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:`flex items-center gap-2 px-2 text-sm text-ink/70`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`pulse-dot size-2 shrink-0 rounded-full bg-signal`}),`正在連上本機狀態…`]}):x.map(t=>{let n=e.get(t),r=!o.view&&t===C,i=n?Py(n)?.run?.state===`running`:!1,a=f.has(t);return(0,z.jsxs)(`div`,{className:R(`group relative shrink-0`,a&&`opacity-60`),children:[(0,z.jsxs)(He,{type:`button`,className:R(`min-h-11 w-full min-w-36 rounded-lg border px-3 py-2 pr-9 text-left md:min-w-0`,r?`border-line bg-wall`:`border-transparent hover:bg-wall/70`),onClick:()=>Ex(t),children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 truncate text-sm font-medium`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:R(`size-2 shrink-0 rounded-full`,i?`pulse-dot bg-signal`:n?.error?`bg-failed`:`bg-ink/25`)}),(0,z.jsx)(`span`,{className:`truncate`,children:t})]}),(0,z.jsx)(`span`,{className:R(`mt-0.5 block truncate pl-4 font-mono text-xs tabular-nums`,i?`text-signal`:`text-ink/60`),children:n?xx(n):``})]}),(0,z.jsx)(He,{type:`button`,"aria-label":a?`顯示 ${t}`:`隱藏 ${t}`,title:a?`取消隱藏`:`隱藏`,className:`absolute top-1 right-1 inline-flex size-7 items-center justify-center rounded-md text-xs text-ink/50 hover:bg-wall hover:text-ink focus-visible:outline-2 focus-visible:outline-signal md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100`,onClick:()=>w(t),children:(0,z.jsx)(Nx,{off:!a})})]},t)}),S>0&&(0,z.jsx)(He,{type:`button`,className:`min-h-9 shrink-0 rounded-lg px-3 text-left text-xs text-ink/60 underline`,onClick:()=>h(e=>!e),children:m?`收起已隱藏`:`顯示已隱藏 (${S})`}),(0,z.jsx)(`div`,{className:`flex items-center gap-2 md:mt-4 md:flex-col md:items-stretch md:border-t md:border-line md:pt-3`,children:[[`decisions`,`決策`],[`tools`,`工具`],[`jobs`,`任務輸出`]].map(([e,t])=>(0,z.jsx)(`a`,{href:`#!${e}`,"aria-current":o.view===e?`page`:void 0,className:R(`inline-flex min-h-11 min-w-24 shrink-0 items-center rounded-lg border px-3 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signal`,o.view===e?`border-line bg-wall`:`border-transparent hover:bg-wall/70`),children:t},e))}),n===`down`&&(0,z.jsx)(He,{type:`button`,className:`min-h-11 shrink-0 rounded-lg border border-line px-3 text-sm underline md:hidden`,onClick:()=>l(e=>e+1),children:`重新連線`}),(0,z.jsx)(`div`,{className:`mt-auto hidden px-2 pb-2 md:block`,children:n===`up`?(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-ink/60`,children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-signal`}),`即時更新`]}):(0,z.jsx)(He,{type:`button`,className:`text-sm underline`,onClick:()=>l(e=>e+1),children:`重新連線`})})]}),(0,z.jsxs)(`main`,{className:`min-h-0 overflow-y-auto bg-wall`,"aria-busy":g||ee||void 0,children:[v&&(0,z.jsx)(Uo,{label:`正在切換畫面…`}),(n===`up`||u&&u.length>0)&&(0,z.jsx)(Tn,{reports:u??[],onReports:d}),ee?(0,z.jsx)(Ho,{label:`正在讀取專案狀態…`}):o.view===`decisions`?(0,z.jsx)(Po,{}):o.view===`tools`?(0,z.jsx)(wx,{projects:y}):o.view===`jobs`?(0,z.jsx)(Ko,{}):T&&C?(0,z.jsx)(`div`,{className:R(v&&`opacity-70 motion-safe:transition-opacity motion-safe:duration-150`),children:(0,z.jsx)(dx,{name:C,frame:T,runId:o.project===C?o.run:void 0,now:i,onRun:e=>Ex(C,e)})},`${C}/${o.project===C?o.run??``:``}`):(0,z.jsxs)(`article`,{className:`enter animate-in fade-in p-4 duration-200 sm:p-6`,children:[(0,z.jsx)(`h1`,{className:`text-balance text-2xl font-semibold tracking-tight`,children:Sx(n,y.length)}),n===`up`&&y.length===0&&(0,z.jsx)(`p`,{className:`text-pretty mt-3 text-sm`,children:`在終端執行 agent-lyceum project add 註冊一個專案。`}),n===`down`&&(0,z.jsx)(He,{type:`button`,className:`mt-4 min-h-11 rounded-md border border-line bg-paper px-4 py-1.5 text-sm hover:bg-wall`,onClick:()=>l(e=>e+1),children:`重新連線`})]})]})]})}function Ex(e,t){let n=t?`${encodeURIComponent(e)}/${encodeURIComponent(t)}`:encodeURIComponent(e);location.hash=n}function Dx(){try{let e=decodeURIComponent(location.hash.replace(/^#/,``));if(!e)return{};if(e===`!tools`||e===`!jobs`||e===`!decisions`)return{view:e.slice(1)};let t=e.indexOf(`/`);return t===-1?{project:e}:{project:e.slice(0,t),run:e.slice(t+1)}}catch{return{}}}function Ox(e,t){if(t.type===`quota`)return e;if(t.type===`snapshot`)return new Map(t.projects.map(e=>[e.name,e.frame]));let n=new Map(e);return t.type===`removed`?n.delete(t.name):n.set(t.name,t.frame),n}function kx(e,t){return e===t?0:e>t?-1:1}var Ax=`lyceum.hiddenProjects`;function jx(){try{let e=JSON.parse(localStorage.getItem(Ax)??`[]`);return new Set(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])}catch{return new Set}}function Mx(e){try{localStorage.setItem(Ax,JSON.stringify([...e]))}catch{}}function Nx({off:e}){return(0,z.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`path`,{d:`M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z`}),(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),e&&(0,z.jsx)(`path`,{d:`M4 4l16 16`})]})}var Px=document.getElementById(`root`);Px&&(0,Ue.createRoot)(Px).render((0,z.jsx)(b.StrictMode,{children:(0,z.jsx)(Tx,{})}));
|