offsite 0.0.33 → 0.0.34
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/apps/server/dist/main.mjs +6 -14
- package/apps/server/dist/main.mjs.map +1 -1
- package/apps/web/dist/assets/{dist-BrbsojdV.js → dist-BYXo5M-b.js} +1 -1
- package/apps/web/dist/assets/{index-Dey2-CSd.js → index-BiXADRAn.js} +4 -4
- package/apps/web/dist/index.html +1 -1
- package/apps/web/dist/sw.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/image-viewer-Cqc2TB1C.js","assets/jsx-runtime-D3jfb0Ew.js","assets/zoomable-image-8K4_Vqt3.js","assets/button-B9gb3kFa.js","assets/utils-PtDt7m8t.js","assets/tooltip-CVzJHuCM.js","assets/preview-dialog-CPvYDNeU.js","assets/dist-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/image-viewer-Cqc2TB1C.js","assets/jsx-runtime-D3jfb0Ew.js","assets/zoomable-image-8K4_Vqt3.js","assets/button-B9gb3kFa.js","assets/utils-PtDt7m8t.js","assets/tooltip-CVzJHuCM.js","assets/preview-dialog-CPvYDNeU.js","assets/dist-BYXo5M-b.js","assets/dist-BJ6NAVkJ.js","assets/video-viewer-DAKoRaNT.js","assets/video-player-DsF9gAr6.js","assets/react-BlUBLzv4.js","assets/audio-player-DPpDuqFI.js","assets/video-player-4TBQR7ei.js","assets/zoomable-image-DKc1MmY3.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{a as e,i as t,n,r,t as i}from"./jsx-runtime-D3jfb0Ew.js";import{S as a,_ as o,a as s,b as c,d as l,f as u,g as d,h as f,i as p,l as m,m as h,n as g,o as _,p as v,r as y,s as b,t as x,u as S,v as C,x as w}from"./button-B9gb3kFa.js";import{a as T,c as E,i as D,l as O,n as k,o as A,r as ee,s as j,t as M}from"./tooltip-CVzJHuCM.js";import{C as te,S as ne,T as re,_ as ie,a as ae,b as oe,c as se,d as ce,f as le,g as ue,h as de,i as fe,l as pe,m as me,n as he,o as ge,p as N,r as _e,s as ve,t as ye,u as be,v as xe,w as Se,x as Ce,y as we}from"./preview-dialog-CPvYDNeU.js";import{a as Te,i as Ee,n as De,r as Oe,t as P}from"./utils-PtDt7m8t.js";import{$ as ke,A as Ae,B as je,C as Me,D as Ne,E as Pe,F as Fe,G as Ie,H as Le,I as Re,J as ze,K as Be,L as Ve,M as He,N as Ue,O as We,P as Ge,Q as Ke,R as qe,S as Je,T as Ye,U as Xe,V as Ze,W as Qe,X as $e,Y as et,Z as tt,g as nt,h as rt,j as it,k as at,l as ot,n as st,o as ct,p as lt,q as ut,t as dt,w as ft,x as pt,z as mt}from"./dist-BJ6NAVkJ.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var F=e(n(),1),ht=F.useLayoutEffect;function gt(e){return e[e.length-1]}function _t(e,t){return typeof e==`function`?e(t):e}var vt=Object.prototype.hasOwnProperty;function yt(e){for(let t in e)if(vt.call(e,t))return!0;return!1}var bt=()=>Object.create(null),xt=(e,t)=>St(e,t,!0);function St(e,t,n,r=0){if(e===t)return e;if(r++>500)return t;let i=Array.isArray(e)&&Array.isArray(t);if(!i&&!(Ct(e)&&Ct(t)))return t;let a=Object.keys(e),o=a.length,s=Object.keys(t),c=s.length;if(i?o!==e.length||c!==t.length||o&>(a)!==`${o-1}`||c&>(s)!==`${c-1}`:o!==Object.getOwnPropertyNames(e).length||c!==Object.getOwnPropertyNames(t).length||Object.getOwnPropertySymbols(t).length)return t;let l=0,u,d,f;if(i){for(;l<c&&(f=l,d=e[f],u=t[f],u=d===u?d:typeof d==`object`?St(d,u,n,r):u,u===d);l++);if(l===c&&o===c)return e}else{let i=o===c,p=!0;for(;l<c;l++){f=s[l],d=e[f];let o=t[f];u=d===o?d:typeof d==`object`?St(d,o,n,r):o,i&&=u===d&&(a[l]===f||vt.call(e,f)),p&&=Object.is(u,o),a[l]=u}if(i)return Object.getOwnPropertySymbols(e).length?t:e;if(p)return t}let p=i?s.fill(0):n?bt():{};for(let o=0;o<c;o++)f=i?o:s[o],i?(d=e[f],o>l&&(u=t[f],u=d===u?d:typeof d==`object`?St(d,u,n,r):u),p[f]=o<l?d:u):p[f]=a[o];return p}function Ct(e){return!e||typeof e!=`object`?!1:(Object.getPrototypeOf(e)?.constructor??Object)===Object}function wt(e,t,n,r){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0,a=e.length;i<a;i++){let a=e[i],o=t[i];if(a!==o&&!wt(a,o,n,r))return!1}return!0}if(Ct(e)&&Ct(t)){if(n){for(let i in t)if((r||t[i]!==void 0)&&!wt(e[i],t[i],n,r))return!1;return!0}let i=0;if(r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;for(let a in t)if((r||t[a]!==void 0)&&(i--===0||!wt(e[a],t[a],n,r)))return!1;return i===0}return!1}var Tt=/[\x00-\x1f\x7f"<>`{}]/g;function Et(e){return e.replace(Tt,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function Dt(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return Et(t)}var Ot=[`http:`,`https:`,`mailto:`,`tel:`];function kt(e){if(e[0]!==`/`&&e.includes(`:`))return/^[\x00-\x20]*([a-z][a-z\d+.\t\n\r-]*:)/i.exec(e)?.[1]?.replace(/[\t\n\r]/g,``).toLowerCase()}var At=/^[\x00-\x20]*[\\/][\t\n\r]*[\\/]/;function jt(e,t){if(!e)return!1;if(At.test(e))return!0;let n=kt(e);return n?!t.has(n):!1}function Mt(e){if(!e)return e;let t=e;if(/[%\\\x00-\x1f\x7f]/.test(e)){let n=/%25|%5C/gi,r=0,i;for(t=``;(i=n.exec(e))!==null;)t+=Dt(e.slice(r,i.index))+i[0],r=n.lastIndex;t+=Dt(r?e.slice(r):e)}return t}function Nt(e){return/[\s\u0080-\uFFFF]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function Pt(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ft(){throw Error(`Invariant failed`)}function It(e){return e.replace(/\/{2,}/g,`/`)}function Lt(e){return e===`/`?e:e.replace(/^\/+/,``)}function Rt(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/+$/,``):e}function zt(e){return Rt(Lt(e))}function Bt(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function Vt(e,t,n=`never`,r){if(t.includes(`//`)&&(t=It(t)),t.startsWith(`/`))return t.length===1||n===`preserve`?t:n===`always`?t.endsWith(`/`)?t:`${t}/`:t.endsWith(`/`)?t.slice(0,-1):t;let i=t===`.`,a;if(r){a=i?e:e+`\0`+t;let n=r.get(a);if(n)return n}let o;if(i)o=e.split(`/`);else{for(e.includes(`//`)&&(e=It(e)),o=e.split(`/`);o.length>1&>(o)===``;)o.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&o.push(r):o=[r]:r===`..`?o.length>1?o.pop():o=[``]:r===`.`||o.push(r)}}o.length>1&&(gt(o)===``?n===`never`&&o.pop():n===`always`&&o.push(``));let s=o.join(`/`),c=(i?It(s):s)||`/`;return a&&r&&r.set(a,c),c}function Ht(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=new RegExp([...t.keys()].join(`|`).replace(/[.*()]/g,`\\$&`),`g`);return e=>e.replace(n,e=>t.get(e)??e)}function Ut(e){return e==null||e===``}function Wt(e,t,n){if(typeof t!=`string`)return``+(t??void 0);let r=e===`_splat`;if(r&&(!t||/^[a-zA-Z0-9\-._~!/]*$/.test(t)))return t;let i=encodeURIComponent(t);return r&&(i=i.replaceAll(`%2F`,`/`)),n?n(i):i}function Gt(e,t,n,r,i){let a=e.endsWith(`/`)?`/`:``,o=``;for(let e of t){if(typeof e==`string`){o+=e;continue}let[t,s,c,l]=e,u=t===2,d=u&&l!==void 0?l+a:l,f=n[s];if(t!==3||f!=null){if(i&&(i[s]=f,u&&(i[`*`]=f)),u&&Ut(f)){if(c===`/`&&!d)continue;f=``}o+=c+Wt(s,f,r)+(d||``)}}return o+a||`/`}function Kt(e){return e?.isNotFound===!0}function qt(){try{return sessionStorage}catch{return}}var Jt=`tsr-scroll-restoration-v1_3`,Yt=qt();function Xt(){try{return JSON.parse(Yt?.getItem(`tsr-scroll-restoration-v1_3`)||`{}`)}catch{return{}}}var Zt=Xt(),Qt=`data-scroll-restoration-id`,$t=e=>e.state.__TSR_key||e.href;function en(e){let t=e.getAttribute(Qt);if(t)return`[${Qt}="${t}"]`;let n=``,r=e,i;for(;i=r.parentNode;){let e=1,t=r;for(;t=t.previousElementSibling;)e++;let a=`${r.localName}:nth-child(${e})`;n=n?`${a} > ${n}`:a,r=i}return n}var tn=!1,nn=`window`;function rn(e){try{return typeof e==`function`?e():document.querySelector(e)}catch{}}function an(e){let t=new Set;for(let n of e){if(n===nn)continue;let e=rn(n);e&&t.add(e)}return t}function on(e,t){let n=t??e.options.scrollRestoration,r=e._scroll;n&&(r.e=!0);let i=e.options.getScrollRestorationKey||$t,a=new Set,o=e=>{let t=Zt[e]||={};for(let e of a)e===document?t[nn]={scrollX,scrollY}:e.isConnected&&(t[en(e)]={scrollX:e.scrollLeft,scrollY:e.scrollTop})};n&&!r.s&&(r.s=!0,tn=!1,history.scrollRestoration=`manual`,document.addEventListener(`scroll`,e=>{tn||a.add(e.target)},!0),e.subscribe(`onBeforeLoad`,e=>{e.fromLocation&&o(i(e.fromLocation)),a.clear()}),addEventListener(`pagehide`,()=>{history.scrollRestoration=`auto`,o(i(e.stores.resolvedLocation.get()??e.stores.location.get()));try{Yt?.setItem(Jt,JSON.stringify(Zt))}catch{}}),addEventListener(`pageshow`,e=>{e.persisted&&(history.scrollRestoration=`manual`)})),!r.r&&(r.r=!0,e.subscribe(`onRendered`,t=>{let n=e.options.scrollRestorationBehavior,o=e.options.scrollToTopSelectors,s=r.n,c=r.h,l;if(a.clear(),r.n=!0,r.h=!1,typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return;let u=i(t.toLocation),d=t.fromLocation&&i(t.fromLocation);if(r.e&&d&&d!==u){let e=Zt[d];if(e){let t=Zt[u];for(let n in e){if(n===nn){if(s)continue}else{let e=rn(n);if(!e||s&&o&&(l??=an(o),l.has(e)))continue}t||=Zt[u]={},t[n]??=e[n]}}}tn=!0;try{let e=t.toLocation.hash,i=t.toLocation.state.__hashScrollIntoViewOptions??!0,a=!1;if(s){!e&&o&&(l??=an(o));let t=e&&i&&c,s=r.e?Zt[u]:void 0;if(s)for(let e in s){let{scrollX:r,scrollY:i}=s[e];if(e===nn){if(t)continue;scrollTo({top:i,left:r,behavior:n}),a=!0}else{let t=rn(e);t&&(t.scrollLeft=r,t.scrollTop=i,l?.delete(t))}}if(!e){let e={top:0,left:0,behavior:n};if(a||scrollTo(e),l)for(let t of l)t.scrollTo(e)}}!a&&e&&i&&document.getElementById(e)?.scrollIntoView(i)}finally{tn=!1}}))}function sn(e,t=String){let n;for(let r in e){let i=e[r];i!==void 0&&(n||=new URLSearchParams).set(r,t(i))}return n?n.toString():``}function cn(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function ln(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=cn(r):Array.isArray(t)?t.push(cn(r)):n[e]=[t,cn(r)]}return n}var un=/^(?:\s|["[{\d-]|fa|nu|tr)/,dn=pn(JSON.parse),fn=mn(JSON.stringify,JSON.parse);function pn(e){let t=e===JSON.parse;return n=>{n[0]===`?`&&(n=n.slice(1));let r=ln(n);for(let n in r){let i=r[n];if(typeof i==`string`){if(t&&!un.test(i))continue;try{r[n]=e(i)}catch{}}}return r}}function mn(e,t){let n=t===JSON.parse;function r(r){if(r&&typeof r==`object`)try{return e(r)}catch{}else if(t&&typeof r==`string`){if(n&&!un.test(r))return r;try{return t(r),e(r)}catch{}}return r}return e=>{let t=sn(e,r);return t?`?${t}`:``}}var hn=`__root__`;function gn(e){e.statusCode=e.statusCode||e.code||307;let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function _n(e){return e instanceof Response&&!!e.options}function vn(e){let t=new Map,n,r;return{get(e){let n=t.get(e);if(n)return n.visited=!0,n.value},set(i,a){let o=t.get(i);if(o){o.value=a;return}if(t.size>=e){let e=n?.next().value;for(;!e||e.visited;)e?e.visited=!1:n=t.values(),e=n.next().value;e===r&&(n=void 0),t.delete(e.key)}let s={key:i,value:a,visited:!1};r=s,t.set(i,s)},clear(){t.clear(),n=void 0,r=void 0}}}var yn=4,bn=5;function xn(e){let t=e.names;if(t)return t;let n=[];for(let t of e)typeof t!=`string`&&n.push(t[1]);return e.names=n}function Sn(e,t,n){let r=e.slice(t,n);if(r.charCodeAt(0)===36)return r.length===1?[2,`_splat`,``,void 0]:[1,r.slice(1),``,``];let i=r.indexOf(`{`);if(i>=0){let a=r.indexOf(`}`,i),o=r.charCodeAt(i+1)===45,s=i+(o?3:2);if(a>=0&&r.charCodeAt(s-1)===36&&(!o||s<a)){let c=r.slice(s,a);return[o?3:c?1:2,c||`_splat`,r.slice(0,i),e.slice(t+a+1,c?n:e.length)]}}return r}function Cn(e,t,n,r,i,a){let o=n,s=t.fullPath??t.from,c=t.options,l=s.length,u=s.endsWith(`/`)?l-1:l,d=c?.caseSensitive??e,f=c?.params?.parse??c?.parseParams,p,m=a?n-1:0;if(!r||s.includes(`$`)){p=a?.slice()??[];let e=gt(p);e&&typeof e!=`string`&&e[0]===2&&(p[p.length-1]=[e[0],e[1],e[2],e[3]===void 0?void 0:e[3]+s.substring(n-(s[n-2]===`/`?2:1),u)],m=l)}for(;o<l;){let e=o,t=s.indexOf(`/`,e),n=t===-1?l:t,a=Sn(s,e,n);o=n+1;let c;if(typeof a==`string`){if(!r)continue;let e=a,t;d?t=r.static??=new Map:(e=a.toLowerCase(),t=r.staticInsensitive??=new Map);let n=t.get(e);if(n)c=n;else{let n=Tn(r);c=n,t.set(e,n)}}else{let t=a[0],h=a[2],g=a[3]??``;if(t===2&&(n=l,o=n+1),p&&m<n&&(m<e-1&&p.push(s.slice(m,e-1)),a[2]=`/`+h,t===2&&a[3]!==void 0&&u<l&&(a[3]=g.slice(0,-1)),p.push(a),m=n),!r)continue;let _=d&&!!(h||g);d||(h=h.toLowerCase(),g=g.toLowerCase());let v=t===1?r.dynamic??=[]:t===3?r.optional??=[]:r.wildcard??=[],y=t!==2&&!f&&v.find(e=>!e.parse&&e.caseSensitive===_&&e.prefix===h&&e.suffix===g);if(y)c=y;else{let e=Tn(r,t,_,h,g);c=e,v.push(e),v.length===2&&i?.push(v)}}r=c}p&&m<u&&p.push(s.slice(m,u));let h=p?.slice();if(!r)return h;if(f&&t.children&&!t.isRoot&&t.id&&t.id.charCodeAt(t.id.lastIndexOf(`/`)+1)===95){let e=Tn(r,bn);(r.pathless??=[]).push(e),r=e}let g=(t.path||!t.children)&&!t.isRoot;if(g&&u<l){let e=Tn(r,yn);r.index=e,r=e}return r.parse=f??null,r.priority=c?.params?.priority??0,r.route||(r.data=h,g&&(r.route=t)),[r,o,h]}function wn(e,t){if(e.parse&&!t.parse)return-1;if(!e.parse&&t.parse)return 1;if(e.parse&&t.parse&&(e.priority||t.priority))return t.priority-e.priority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function Tn(e,t=0,n,r,i){return{kind:t,depth:e?e.depth+1:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,data:void 0,parent:e,parse:null,priority:0,caseSensitive:n,prefix:r,suffix:i}}function En(e,t){let n=Tn(),r=[];function i(e,t,n,a){let[o,s,c]=Cn(!1,e,t,n,r,a);if(e.children)for(let t of e.children)i(t,s,o,c)}for(let t of e)i(t,1,n);for(let e of r)e.sort(wn);t.masksTree=n,t.flatCache=vn(1e3)}function Dn(e,t){e||=`/`;let n=t.flatCache.get(e);if(n!==void 0)return n;let r=jn(e,t.masksTree);return t.flatCache.set(e,r),r}function On(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=Tn(),Cn(t,{from:e},1,o),i.singleCache.set(a,o)),jn(r,o,n)}function kn(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=jn(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=Nn(a.route)),t.matchCache.set(r,a),a}function An(e,t=!1){let n=Tn(),r=[],i={},a={},o=0;function s(e,n,c,l){if(e.init(o),e.id in i&&Ft(),i[e.id]=e,o!==0&&e.path){let t=Rt(e.fullPath);(!a[t]||e.fullPath.endsWith(`/`))&&(a[t]=e)}o++;let[u,d,f]=Cn(t,e,n,c,r,l);if(e._interpolation=f,e.children)for(let t of e.children)s(t,d,u,f)}s(e,1,n);for(let e of r)e.sort(wn);return{processedTree:{segmentTree:n,singleCache:vn(1e3),matchCache:vn(1e3),flatCache:null,masksTree:null},routesById:i,routesByPath:a}}function jn(e,t,n=!1){let r=e.split(`/`),i=Fn(e,r,t,n);if(!i)return null;let[a]=Mn(e,r,i);return{route:i.node.route,rawParams:a}}function Mn(e,t,n){let r=Pn(n.node),i=n.node.data&&xn(n.node.data),a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.param??0;for(;s<r.length;o++,s++,c++){let u=r[s];if(u.kind===yn)break;if(u.kind===bn){o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1||u.kind===3){let e=i[l++];if(u.kind===3&&n.skipped&1<<s){o--,c=f-1;continue}let t=u.suffix||u.prefix?d.substring(u.prefix.length,d.length-u.suffix.length):d;(t||u.kind===1)&&(a[e]=decodeURIComponent(t))}else if(u.kind===2){let t=u,n=e.substring(f+t.prefix.length,e.length-t.suffix.length),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,param:l}]}function Nn(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Pn(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function Fn(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!gt(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,statics:0,dynamics:0,optionals:0}],c=null,l=null;for(;s.length;){let n=s.pop(),{node:i,index:u,skipped:d,statics:f,dynamics:p,optionals:m}=n,{extract:h,rawParams:g}=n;if(i.kind===2&&i.route&&!zn(l,n))continue;if(i.parse){if(!Rn(e,t,n))continue;g=n.rawParams,h=n.extract}r&&i.route&&i.kind!==yn&&zn(c,n)&&(c=n);let _=u===o;if(_&&(i.route&&(!a||i.kind===yn||i.kind===2)&&zn(l,n)&&(l=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let v=_?void 0:t[u],y;if(_&&i.index){let n={node:i.index,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g},r=!0;if(i.index.parse&&(Rn(e,t,n)||(r=!1)),r){if(!p&&!m&&!d&&Ln(f,o))return n;zn(l,n)&&(l=n)}}if(i.wildcard)for(let e=i.wildcard.length-1;e>=0;e--){let n=i.wildcard[e],{prefix:r,suffix:a}=n;if(!r||!_&&(n.caseSensitive?v:y??=v.toLowerCase()).startsWith(r)){if(a){if(_)continue;let e=t.slice(u).join(`/`),i=e.slice(-a.length);if((n.caseSensitive?i:i.toLowerCase())!==a||e.length-a.length<r.length)continue}s.push({node:n,index:o,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(i.optional){let e=d|1<<i.depth+1;for(let t=i.optional.length-1;t>=0;t--){let n=i.optional[t];s.push({node:n,index:u,skipped:e,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_)for(let e=i.optional.length-1;e>=0;e--){let t=i.optional[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&e.indexOf(r,e.length-r.length)<n.length)continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p,optionals:m+In(o,u),extract:h,rawParams:g})}}if(!_&&i.dynamic&&v)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&e.indexOf(r,e.length-r.length)<n.length)continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p+In(o,u),optionals:m,extract:h,rawParams:g})}if(!_&&i.staticInsensitive){let e=i.staticInsensitive.get(y??=v.toLowerCase());e&&s.push({node:e,index:u+1,skipped:d,statics:f+In(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_&&i.static){let e=i.static.get(v);e&&s.push({node:e,index:u+1,skipped:d,statics:f+In(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(i.pathless)for(let e=i.pathless.length-1;e>=0;e--){let t=i.pathless[e];s.push({node:t,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(l)return l;if(r&&c){let n=c.index;for(let e=0;e<c.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return c.rawParams??=Object.create(null),c.rawParams[`**`]=decodeURIComponent(r),c}return null}function In(e,t){return 2**(e-t-1)}function Ln(e,t){return e===2**(t-1)-1}function Rn(e,t,n){let r,i;try{[r,i]=Mn(e,t,n)}catch{return null}if(n.rawParams=r,n.extract=i,!n.node.parse)return!0;try{if(n.node.parse(r)===!1)return null}catch{}return!0}function zn(e,t){return!e||t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===yn)>(e.node.kind===yn)||t.node.kind===yn==(e.node.kind===yn)&&t.node.depth>e.node.depth)))}function Bn(e,t,n){let r=zt(e),i=`/${r}`,a=t?i:i.toLowerCase(),o=`${a}/`,s={input:({url:e})=>{let n=t?e.pathname:e.pathname.toLowerCase();return n===a?e.pathname=`/`:n.startsWith(o)&&(e.pathname=e.pathname.slice(i.length)),e},output:({url:e})=>(e.pathname=It(`/${r}${e.pathname}`),e)};return n?{input:({url:e})=>Vn(n,s.input({url:e})),output:({url:e})=>s.output({url:Hn(n,e)})}:s}function Vn(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Hn(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Un(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i}=t,a=new Map,o=n(`idle`),s=n(e),c=n(void 0),l=n([]),u=r(()=>l.get().map(e=>a.get(e).get())),d=r(()=>({status:o.get(),isLoading:o.get()===`pending`,matches:u.get(),location:s.get(),resolvedLocation:c.get()}));function f(e){let t=a.get(e);return t||(t=n(void 0),a.set(e,t)),t}let p={status:o,location:s,resolvedLocation:c,ids:l,matches:u,byRoute:a,__store:d,getMatchStore:f,setMatches:m};function m(e){let t=l.get(),n=e.map(e=>e.routeId);i(()=>{Pt(t,n)||l.set(n);for(let e of t)n.includes(e)||a.get(e).set(()=>void 0);for(let t of e){let e=f(t.routeId);e.get()!==t&&e.set(t)}})}return p}var Wn=`__TSR_index`,Gn=`popstate`,Kn=`beforeunload`,qn=/^[\x00-\x20]*(?:[\\/][\t\n\r]*){2,}/;function Jn(e){let t=qn.exec(e);return t?`/`+e.slice(t[0].length):e}function Yn(e){return/[\x00-\x1f\x7f]/.test(e)&&(e=e.replace(/[\x00-\x1f\x7f]/g,e=>`
|
|
3
3
|
\r`.includes(e)?``:encodeURIComponent(e))),Jn(e)}function Xn(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async n=>{let r=n.navigateOpts?.ignoreBlocker?void 0:e.getBlockers?.();if(typeof document<`u`&&r?.length&&(n.type===`PUSH`||n.type===`REPLACE`))for(let i of r){let r=$n(n.path,n.state);if(await i.blockerFn({currentLocation:t,nextLocation:r,action:n.type})){e.onBlocked?.();return}}n.task()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[Wn];i=Zn(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[Wn];i=Zn(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t,n?.ignoreBlocker??!1),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[Wn]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r,_getBlockers:()=>e.getBlockers?.()??[]}}function Zn(e,t){let n=er();return{...t,key:n,__TSR_key:n,[Wn]:e}}function Qn(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=t=>Yn(e?.createHref?e.createHref(t):t),c=e?.parseLocation??(()=>$n(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=er();t.history.replaceState({[Wn]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_=()=>{g&&(S._ignoreSubscribers=!0,(g[2]?t.history.pushState:t.history.replaceState)(g[1],``,g[0]),S._ignoreSubscribers=!1,g=void 0,u=void 0)},v=(t,n,r)=>{let i=e?.createHref?s(n):void 0,a=!!g;a||(u=l),l=$n(n,r),g=[i??l.href,r,g?.[2]||t],a||queueMicrotask(()=>_())},y=e=>{l=c(),S.notify({type:e})},b=async()=>{if(m=!1,f){f=!1;return}let e=c(),n=e.state[Wn]-l.state[Wn],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let r=a();if(typeof document<`u`&&r.length){for(let i of r)if(await i.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(-n),S.notify(u);return}}}l=c(),S.notify(u)},x=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0||typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},S=Xn({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>v(!0,e,t),replaceState:(e,t)=>v(!1,e,t),back:e=>(e&&(p=!0,m=!0),t.history.back()),forward:e=>{e&&(p=!0,m=!0),t.history.forward()},go:(e,n)=>{d=!0,n&&(p=!0,m=!0),t.history.go(e)},createHref:s,flush:_,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(Kn,x,{capture:!0}),t.removeEventListener(Gn,b)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return S._ignoreNextBeforeUnload=e=>{m=!1;try{e=new URL(e,t.document.baseURI).href,m=/^https?:/.test(e)&&(!e.includes(`#`)||e.split(`#`)[0]!==t.location.href.split(`#`)[0])}catch{}},t.addEventListener(Kn,x,{capture:!0}),t.addEventListener(Gn,b),t.history.pushState=function(...e){let r=n.apply(t.history,e);return S._ignoreSubscribers||y(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return S._ignoreSubscribers||y(`REPLACE`),n},S}function $n(e,t){let n=Yn(e),r=n.indexOf(`#`),i=n.indexOf(`?`);if(!t){let e=er();t={[Wn]:0,key:e,__TSR_key:e}}return{href:n,pathname:n.slice(0,r>-1?i>-1?Math.min(r,i):r:i>-1?i:n.length),hash:r>-1?n.slice(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t}}function er(){return(Math.random()+1).toString(36).slice(7)}function tr(e,t){return e.protocol!==`http:`&&e.protocol!==`https:`||e.origin!==t||!!e.username||!!e.password}function nr(e){return e.pathname+e.search+e.hash}function rr(e){return e.options.loader||e.options.beforeLoad||e.lazyFn||e.options.component?.preload||e.options.pendingComponent?.preload}function ir(e,t){return{fromLocation:t,toLocation:e,pathChanged:t?.pathname!==e.pathname,hrefChanged:t?.href!==e.href,hashChanged:t?.hash!==e.hash}}function ar({key:e,__TSR_key:t,__TSR_index:n,__hashScrollIntoViewOptions:r,...i}){return i}function or(e){return e.findIndex(e=>e.status===`error`||e.status===`notFound`||e._notFound)+1}function sr(e,t,n,r,i,a){r&&(t=t.slice(0,r)),i&&(n=n.slice(0,i));for(let r of t){if(a&&e._tx!==a)return;n.some(e=>e.routeId===r.routeId)||e.routesById[r.routeId].options.onLeave?.(r)}for(let r of n){if(a&&e._tx!==a)return;e.routesById[r.routeId].options[t.some(e=>e.routeId===r.routeId)?`onStay`:`onEnter`]?.(r)}}var cr=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this._scroll={n:!0},this.subscribers=new Set,this._cache=new Map,this._committed=[],this.startTransition=async e=>(e(),!1),this.update=e=>{let t=this.options;this.options={...t,...e},this.isServer=this.options.isServer??!1??typeof document>`u`,this.staticLocations=new WeakMap,this.protocolAllowlist=new Set(this.options.protocolAllowlist),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history?this.options.history:Qn()),this.origin=this.options.origin,this.origin||=window?.origin&&window.origin!==`null`?window.origin:`http://localhost`;let n=this.options.basepath??`/`,r=this.options.rewrite,i=this.basepath!==n||t?.rewrite!==r||t?.caseSensitive!==this.options.caseSensitive;if(i&&(this.basepath=n,this.rewrite=n!==`/`&&zt(n)?Bn(n,this.options.caseSensitive,r):r),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let e;e=this.buildRouteTree(),this.setRoutes(e)}if(this.stores)i&&this.stores.location.set(this.latestLocation);else if(this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=Un(this.latestLocation,e),on(this)}},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let e=An(this.routeTree,this.options.caseSensitive);return this.options.routeMasks&&En(this.options.routeMasks,e.processedTree),{...e,resolvePathCache:vn(1e3)}},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{for(let t of this.subscribers)if(t.eventType===e.type)try{t.fn(e)}catch(e){console.error(e)}},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i},a)=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:Mt(e),external:!1,searchStr:o,search:xt(t?.search,i),hash:Mt(r.slice(1)),state:St(t?.state,a)}}let o=Vn(this.rewrite,new URL(i,this.origin)),s=this.options.parseSearch(o.search),c=this.options.stringifySearch(s);return o.search=c,{href:o.href.replace(o.origin,``),publicHref:i,pathname:Mt(Jn(o.pathname)),external:!!this.rewrite&&tr(o,this.origin),searchStr:c,search:xt(t?.search,s),hash:Mt(o.hash.slice(1)),state:St(t?.state,a)}},r=n(e,e.state),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i,{...i.state,__tempLocation:void 0,key:r.state.key,__TSR_key:r.state.__TSR_key});return e.maskedLocation=r,e}return r},this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>{let t=Object.create(null),n=kn(Rt(e),this.processedTree,!0);return n&&Object.assign(t,n.rawParams),[n?.branch||[this.routesById.__root__],t,n?.route]},this.buildLocation=e=>{{let t=this.staticLocations.get(e);if(t)return t}let t=!1,n=(n={})=>{if(n.href){let e=$n(n.href,{});n={...n,to:Vn(this.rewrite,new URL(e.pathname,this.origin)).pathname,search:this.options.parseSearch(e.search),hash:e.hash.slice(1)}}let r=e._fromLocation||this._pendingLocation||this.latestLocation,i,a=()=>(t=!0,r),o=()=>i??=this.matchRoutesLightweight(a()),s=n.to?`${n.to}`:`.`,c=Vt(s[0]===`/`?``:n.unsafeRelative===`path`?a().pathname:n.from??o()[1],s,this.options.trailingSlash,this.resolvePathCache),l=this.routesByPath[Rt(c)],u=c.includes(`$`),d;if(l)d=l._branch??=Nn(l);else if(u)d=[];else{let[e,t,n]=this.getMatchedRoutes(c);d=e,this.options.notFoundRoute&&(!n||n.path!==`/`&&t[`**`])&&(d=[...d,this.options.notFoundRoute])}let f=u?l?._interpolation??Cn(!1,{fullPath:c},0):void 0,p;for(let e of d){let t=e.options.params?.stringify??e.options.stringifyParams;if(t){let e=o()[3];if(p??=pr(n.params,e),!yt(p))break;p===e&&(p=Object.assign(bt(),p));try{Object.assign(p,t(p))}catch{}}}p??=pr(n.params,mr(n.params,f)?o()[3]:hr);let m=e.leaveParams?c:Jn(Mt(f?Gt(c,f,p,this.pathParamsDecoder):c)),h=gr(d,e._includeValidateSearch),g=()=>{let t=o()[2];if(e._includeValidateSearch&&this.options.search?.strict){let e={};d.forEach(n=>{if(n.options.validateSearch)try{Object.assign(e,fr(n.options.validateSearch,{...e,...t}))}catch{}}),t=e}return t},_=h.length?_r(h,g(),n):n.search===!0?g():typeof n.search==`function`?n.search(g()):n.search||hr,v=this.options.stringifySearch(_),y=n.hash===!0?a().hash:typeof n.hash==`function`?n.hash(a().hash):n.hash||void 0,b=y?`#${y}`:``,x=n.state?n.state===!0?a().state:typeof n.state==`function`?n.state(a().state):n.state:hr,S=`${m}${v}${b}`,C,w,T=!1;if(this.rewrite){let e=new URL(S,this.origin),t=e.origin,n=Hn(this.rewrite,e);C=nr(e),tr(n,t)?(w=n.href,T=!0):w=Jn(nr(n))}else C=Nt(S),w=C;return{publicHref:w,href:C,pathname:m,search:_,searchStr:v,state:x,hash:y??``,external:T,unmaskOnReload:n.unmaskOnReload}},r=n(e);if(e.mask)r.maskedLocation=n({from:e.from,...e.mask});else if(this.options.routeMasks){let t=Dn(r.pathname,this.processedTree);if(t){let i=Object.assign(bt(),t.rawParams),{from:a,params:o,...s}=t.route,c=pr(o,i);r.maskedLocation=n({from:e.from,...s,params:c})}}return!t&&e._fromLocation&&this.staticLocations.set(e,r),r},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r=n.maskedLocation??n;if(r.external)return lr(this,r.publicHref,{replace:n.replace,ignoreBlocker:t});let i,a=Rt(this.latestLocation.href)===Rt(n.href)&&wt(ar(n.state),ar(this.latestLocation.state)),o=this._commitPromise,s,c=new Promise(e=>{s=e});if(c.resolve=()=>{s(),o?.resolve()},this._commitPromise=c,a)this.load();else{let{maskedLocation:r,hashScrollIntoView:a,...o}=n;r&&(o={...r,state:{...r.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload??!1)&&(o.state.__tempKey=this.tempLocationKey)),o.state={...o.state,__hashScrollIntoViewOptions:a??this.options.defaultHashScrollIntoView??!0},this.shouldViewTransition=e,i=n.replace?`REPLACE`:`PUSH`,this.history[i===`REPLACE`?`replace`:`push`](o.publicHref,o.state,{ignoreBlocker:t}),this.history.subscribers.size||this.load({action:{type:i}})}return this._scroll.n=n.resetScroll??!0,this._commitPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,...a}={})=>{let o=this.buildLocation({...a,_includeValidateSearch:!0});this._pendingLocation=o;let s=this.commitLocation({...o,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return queueMicrotask(()=>{this._pendingLocation===o&&(this._pendingLocation=void 0)}),s},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=n?kt(n):void 0;if(a||t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i}),a=t.maskedLocation??t;n??=a.publicHref,r??=a.publicHref}let t=!a&&r?r:n;return lr(this,t,i)}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.load=async e=>{this.updateLatestLocation(),e?.action&&(this._scroll.h=e.action.type===`PUSH`||e.action.type===`REPLACE`),await ui(this,e)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&window.CSS?.supports?.(`selector(:active-view-transition-type(a))`)){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(ir(r,i)):t.types;if(a===!1)return e();n={update:e,types:a}}else n=e;return document.startViewTransition(n).updateCallbackDone}return e()},this.invalidate=e=>{let t=this._committed,n=e?.filter,r=this._preloads,i=new Set,a=e=>{(!n||n(e))&&i.add(e.id)};t.forEach(a),this._cache.forEach(a),r?.forEach(e=>e.forEach(a)),this._tx?.[3].forEach(a);let o=[];for(let[e,t]of r??[])t.some(e=>i.has(e.id))&&(r.delete(e),o.push(e));let s=t=>{if(i.has(t.id)){let n=this.routesById[t.routeId],r={...t,invalid:!0,...(e?.forcePending||t.status===`error`||t.status===`notFound`)&&rr(n)?{status:`pending`,error:void 0}:void 0};return t._flight=void 0,r}return t};this._committed=t.map(s);for(let[t,n]of this._cache)i.has(t)&&(n.invalid=!0,e?.forcePending&&(n.status=`pending`));for(let e of i){let t=this._flights?.get(e);this._flights?.delete(e),t&&!t[2]&&o.push(t[1])}for(let e of o)e.abort();return this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.resolveRedirect=e=>{let t=e.options,n=e.headers.get(`Location`)||t.href;if(!n){let e=this.buildLocation(t);n=(e.maskedLocation??e).publicHref||`/`}let r;if(At.test(n)||(r=kt(n))&&!this.protocolAllowlist.has(r))throw Error(`Redirect blocked: unsafe protocol`);if(r===`http:`||r===`https:`){let e=new URL(n);e.pathname.startsWith(`//`)?n=e.href:tr(e,this.origin)||(n=nr(e),r=void 0)}return r&&(t.reloadDocument=!0),t.href=n,e.headers.set(`Location`,n),e},this.clearCache=e=>{let t=this._cache,n=this._preloads,r=e?.filter,i=[],a=[];for(let[e,n]of t)(!r||r(n))&&(a.push(e),i.push(n));let o=[];for(let[e,t]of n??[])(!r||t.some(r))&&(o.push(e),i.push(...t));for(let e of a)t.delete(e);for(let e of o)n.delete(e);for(let e of i){let t=e._flight;e._flight=void 0,t&&!--t[2]&&(this._flights?.get(e.id)===t&&this._flights.delete(e.id),o.push(t[1]))}for(let e of o)e.abort()},this.loadRouteChunk=Sr,this.preloadRoute=e=>di(this,e),this.matchRoute=(e,t)=>{let n={...e,to:e.to?Vt(e.from||``,e.to,this.options.trailingSlash,this.resolvePathCache):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n),i=this.stores.status.get()===`pending`;if(t?.pending&&!i)return!1;let a=t?.pending??!i?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),o=On(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,a.pathname,this.processedTree);return!o||e.params&&!wt(o.rawParams,e.params,!0)?!1:t?.includeSearch??!0?wt(a.search,r.search,!0)?o.rawParams:!1:o.rawParams},this.getStoreConfig=t,e.pathParamsAllowedCharacters?.length&&(this.pathParamsDecoder=Ht(e.pathParamsAllowedCharacters)),this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??fn,parseSearch:e.parseSearch??dn,protocolAllowlist:e.protocolAllowlist??Ot}),self.__TSR_ROUTER__=this}isShell(){return!!this.options.isShell}get state(){return this.stores.__store.get()}setRoutes(e){Object.assign(this,e),this.lightweightCache=new WeakMap,this.staticLocations=new WeakMap;let t=this.options.notFoundRoute;t&&(t.init(99999999999),this.routesById[t.id]!==t&&(t._interpolation=Cn(!1,t,0)),this.routesById[t.id]=t)}matchRoutesInternal(e,t){let[n,r,i]=this.getMatchedRoutes(e.pathname),a=n,o=!1;(i?i.path!==`/`&&r[`**`]:Rt(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:o=!0);let s=o?vr(this.options.notFoundMode,a):void 0,c=Array(a.length),l=this._committed,u=(e,t)=>{let n=l[t];return n?.routeId===e.id?n:e===this.options.notFoundRoute?l.find(t=>t.routeId===e.id):void 0},d;for(let n=0;n<a.length;n++){let i=a[n],o=c[n-1],l,f,p;{let n=o?.search??e.search,r=o?._strictSearch??void 0;try{let e=fr(i.options.validateSearch,{...n})??void 0;l={...n,...e},f={...r,...e}}catch(e){let r=e;if(e instanceof ur||(r=new ur(e.message,{cause:e})),t?.throwOnError)throw r;l=n,f={},p=r}}let m=``,h=``;try{m=i.options.loaderDeps?.({search:l})??``,h=m&&JSON.stringify(m)||``}catch(e){if(t?.throwOnError)throw e;p??=e}let g=bt(),_=i._interpolation?Gt(i.fullPath,i._interpolation,r,this.pathParamsDecoder,g):i.fullPath,v=i.id+_+h,y=u(i,n),b=this._cache.get(v)??(y?.id===v?y:void 0);d=b?._strictParams??Object.assign(g,d);let x;if(!b)try{yr(i,d)}catch(e){if(x=Kt(e)||_n(e)?e:new dr(e.message,{cause:e}),t?.throwOnError)throw x}let S=y?`stay`:`enter`,C;if(b)C={...b,cause:S,search:xt(y?y.search:b.search,l),_strictSearch:f,searchError:p};else{let e=rr(i)?`pending`:`success`;C={id:v,ssr:i.options.ssr,index:n,routeId:i.id,params:y?.params??d,_strictParams:d,pathname:_,updatedAt:Date.now(),search:y?xt(y.search,l):l,_strictSearch:f,searchError:p,status:e,isFetching:!1,error:void 0,paramsError:x,context:{},abortController:t?._controller??new AbortController,cause:S,loaderDeps:y?St(y.loaderDeps,m):m,invalid:!1,preload:!1,staticData:i.options.staticData||{},fullPath:i.fullPath}}let w=s===i.id;C._notFound&&!w&&(C.error=void 0),C._notFound=w,c[n]=C}for(let e=0;e<c.length;e++){let n=c[e];n.params=n.cause===`stay`?xt(n.params,d):d,t?._controller&&(n.context={})}return c}matchRoutesLightweight(e){let t=gt(this.stores.ids.get()),n=t?this.stores.byRoute.get(t).get():void 0,r=n?.id,i=this.lightweightCache.get(e);if(i&&i[0]===r)return i[1];let[a,o]=this.getMatchedRoutes(e.pathname),s=gt(a),c={...e.search};for(let e of a)try{Object.assign(c,fr(e.options.validateSearch,c))}catch{}let l=n&&n.routeId===s.id&&n.pathname===e.pathname,u;if(l)u=n.params;else{let e=o;for(let t of a)try{yr(t,e)}catch{}u=e}let d=[a,s.fullPath,c,u];return this.lightweightCache.set(e,[r,d]),d}};async function lr(e,t,{replace:n,ignoreBlocker:r}){if(!jt(t,e.protocolAllowlist)){if(!r){let t=e.history._getBlockers();for(let r of t)if(r?.blockerFn&&await r.blockerFn({currentLocation:e.history.location,nextLocation:e.history.location,action:n?`REPLACE`:`PUSH`}))return}e.history._ignoreNextBeforeUnload?.(t),n?window.location.replace(t):window.location.href=t}}var ur=class extends Error{},dr=class extends Error{};function fr(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new ur(`Async validation not supported`);if(n.issues)throw new ur(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function pr(e,t){if(e===void 0||e===!0)return t;let n=Object.create(null);return e===!1||e===null?n:typeof e==`function`?(Object.assign(n,t),Object.assign(n,e(n))):Object.assign(n,t,e)}function mr(e,t){return typeof e==`function`?!0:!t||e===!1||e===null?!1:e===void 0||e===!0||t.some(t=>typeof t!=`string`&&!vt.call(e,t[1]))}var hr=Object.freeze({});function gr(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r].options;`search`in i?i.search?.middlewares&&n.push(...i.search.middlewares):(i.preSearchFilters||i.postSearchFilters)&&n.push(({search:e,next:t})=>{let n=t(i.preSearchFilters?i.preSearchFilters.reduce((e,t)=>t(e),e):e);return i.postSearchFilters?i.postSearchFilters.reduce((e,t)=>t(e),n):n});let a=i.validateSearch;t&&a&&n.push(({search:e,next:t,meta:n})=>{let r=t(e);try{let e=fr(a,r);if(n&&e)for(let t in e)t in r||(n.defaulted||=new Map).set(t,e[t]);return{...r,...e}}catch{}return r})}return n}function _r(e,t,n){let r=(t,i,a)=>{if(t>=e.length){if(!n.search)return{};if(n.search===!0)return i;let e=_t(n.search,i);return a&&(a.explicit=e),e}return e[t]({search:i,next:(e,n)=>{if(n){let n=a||{};return{search:r(t+1,e,n),meta:n}}return r(t+1,e,a)},meta:a})};return r(0,t)}function vr(e,t){if(e!==`root`){let e;for(let n=t.length-1;n>=0;n--){let r=t[n];if(r.options.notFoundComponent)return r.id;e||=r.children&&r.id}if(e)return e}return hn}function yr(e,t){let n=e.options.params?.parse??e.options.parseParams;n&&Object.assign(t,n(t))}function br(e,t){return e.options[t]?.preload?.()}function xr(e,t){let n=br(e,`component`),r=br(e,`pendingComponent`);return t&&(r?r=r.then(t):t()),n&&r?Promise.all([n,r]).then(()=>{}):n??r}function Sr(e,t,n){let r=()=>t===!1?void 0:t?br(e,t):xr(e,n),i=e._lazy;if(i)return i===!0?r():i.then(r);if(!e.lazyFn)return r();let a=e.lazyFn().then(t=>{{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazy=!0}},t=>{throw e._lazy=void 0,t});return e._lazy=a,a.then(r)}function Cr(e){let t=e.findIndex(e=>e.status!==`success`||e._notFound)+1;return t&&t<e.length?e.slice(0,t):e}function wr(e,t,n){let r=e._tx;return t&&r?.[2]===n&&!r[3].some(e=>e.routeId===t)}var Tr=0,Er=1,Dr=2,Or=3,kr=[4];function Ar(e){return typeof e[0]==`number`}function jr(e,t){return t.aborted?Promise.race([Promise.reject(t),e]):new Promise((n,r)=>{let i=()=>r(t);t.addEventListener(`abort`,i,{once:!0}),Promise.resolve(e).then(n,r).then(()=>t.removeEventListener(`abort`,i))})}function Mr(e,t){return e.routesById[t.routeId]}function Nr(e,t,n){return _n(e)?[Or,e]:Kt(e)?(e.routeId||=n,[Dr,e]):t?(typeof e?.then==`function`&&(e=Error(`A Promise was thrown`,{cause:e})),[Er,e]):[Tr,e]}function Pr(e,t){let n=Nr(t,!0,e.id);if(n[0]!==Er)return n;try{e.options.onError?.(n[1])}catch(t){n=Nr(t,!0,e.id)}return n}function Fr(e,t,n,r,i){return i[0].signal.aborted?kr:Zr(e,t,n,Pr(n,r),i)}async function Ir(e,t,n,r,i,a){let[o,s]=t,c=n[0].signal,l=!!n[3];for(let i=n[6]??0;i<r;i++){let r=s[i],u=Mr(e,r);r.abortController=n[0];let d=s[i-1]?.context??e.options.context??{},f={params:r.params,location:o,navigate:t=>e.navigate({...t,_fromLocation:o}),buildLocation:e.buildLocation,cause:l?`preload`:r.cause,abortController:n[0],preload:l,matches:s,routeId:u.id};try{let e=r._ctx||=u.options.context?u.options.context({...f,deps:r.loaderDeps,context:d})||{}:void 0;r.context={...d,...e}}catch(a){return Rr(e,r),[i,Fr(e,t,u,a,n)]}if(c.aborted)return[i,kr];let p=r.paramsError??r.searchError;if(p!==void 0)return Rr(e,r),[i,Fr(e,t,u,p,n)];let m=u.options.beforeLoad;if(!m)continue;let h=r.status;i>=a&&(r.status=`pending`,n[7]?.());try{Vr(e,r,`beforeLoad`,n[0]);let a=m({...f,search:r.search,context:r.context,...e.options.additionalContext}),o=await(typeof a?.then==`function`?jr(a,c):a);if(c.aborted)return[i,kr];let s=Zr(e,t,u,Nr(o,!1,u.id),n);if(s[0]!==Tr)return Rr(e,r),[i,s];r.context={...r.context,...o}}catch(a){return Rr(e,r),[i,Fr(e,t,u,a,n)]}finally{r.status=h,Vr(e,r,!1,n[0])}}i()}function Lr(e,t,n){if(!(!n||--n[2])){if(e._flights?.get(t.id)===n){let n=e._tx;if(n&&!n[0].signal.aborted&&!n[3].includes(t)&&n[3].some(e=>e.id===t.id)&&n[3].some(e=>e.isFetching===`beforeLoad`))return;e._flights.delete(t.id)}return n[1]}}function Rr(e,t){let n=t._flight;t._flight=void 0,Lr(e,t,n)?.abort()}function zr(e,t,n,r){let i=[];for(let a of t)if(!n?.includes(a)){let t=a._flight;if(a._flight=void 0,r&&t?.[2]===1&&e._flights?.get(a.id)===t&&n?.some(e=>e.id===a.id))t[2]=0;else{let n=Lr(e,a,t);n&&i.push(n)}}for(let e of i)e.abort()}function Br(e){for(let t of e){let e=t._flight;e&&e[2]++}}function Vr(e,t,n,r){if(t.isFetching=n,r&&e._tx?.[0]!==r)return;let i=e.stores.byRoute.get(t.routeId),a=i?.get();a?.id===t.id&&i.set({...a,isFetching:n})}function Hr(e,t,n,r,i,a,o){let s=t[0];return{params:n.params,location:s,navigate:t=>e.navigate({...t,_fromLocation:s}),cause:o?`preload`:n.cause,abortController:i,preload:o,deps:n.loaderDeps,parentMatchPromise:a,context:n.context,route:r,...e.options.additionalContext}}async function Ur(e,t,n,r,i,a,o){let s=o[0],c=s.signal;if(c.aborted)return kr;if(!i)return[Tr,void 0];let l=n._flight;Vr(e,n,`loader`,s);try{if(!l){let s=new AbortController;l=[Promise.resolve().then(()=>i(Hr(e,t,n,r,s,a,!!o[3]))).then(e=>Nr(e,!1,r.id),e=>Nr(e,!0,r.id)).then(t=>(t[0]!==Tr&&e._flights?.get(n.id)===l&&(e._flights.delete(n.id),l[2]||s.abort()),t[0]===Er&&l[2]?Pr(r,t[1]):t)),s,1],(e._flights??=new Map).set(n.id,l)}return n._flight=l,n.abortController=l[1],Zr(e,t,r,await jr(l[0],c),o)}catch(t){if(t!==c||!c.aborted)throw t;return Rr(e,n),kr}finally{Vr(e,n,!1,s)}}function Wr(e,t,n){t[0]!==Or&&(e.status=`success`,e.error=void 0,t[0]===Tr?(e.loaderData=t[1],e.invalid=!1,e.updatedAt=Date.now(),e.preload=n):e.invalid=!0)}function Gr(e,t,n){let r=e._cache.get(t.id);if(r!==n||e._committed.some(e=>e.id===t.id&&e._flight===t._flight))return;let i={...t,_notFound:void 0,context:{}};i._flight&&i._flight[2]++,e._cache.set(t.id,i),r&&Rr(e,r)}function Kr(e,t){return t[0]===Er||t[0]===Dr?{...e,status:t[0]===Er?`error`:`notFound`,error:t[1],_flight:void 0}:e}function qr(e,t,n,r,i,a,o){let s=t[1][n],c=Mr(e,s),l=!!a[3],u=e._cache.get(s.id),d,f=!1,p;try{if(s.status===`success`&&(d=c.options.shouldReload,typeof d==`function`&&(d=d(Hr(e,t,s,c,a[0],i,l))),a[0].signal.aborted&&(p=kr)),!p){if(s.status!==`success`)f=!0;else{let t=l||s.preload?c.options.preloadStaleTime??e.options.defaultPreloadStaleTime??3e4:c.options.staleTime??e.options.defaultStaleTime??0;f=!!(s.invalid||d||d===void 0&&Date.now()-s.updatedAt>=t&&(a[5]||s.cause===`enter`||a[2].some(e=>e.routeId===s.routeId&&e.id!==s.id)))}}}catch(n){s.invalid=!0,Rr(e,s),p=Fr(e,t,c,n,a)}let m=c.options.loader,h=typeof m==`function`,g=h?m:m?.handler,_=!l||c.options.preload!==!1,v=_&&m?e._flights?.get(s.id):void 0;v===s._flight||p?v=void 0:v&&!f&&!l&&d===void 0?f=!0:f||(v=void 0);let y=!(!m||!f||s.status!==`success`||l||a[4]||((h?void 0:m.staleReloadMode)??e.options.defaultStaleReloadMode)===`blocking`),b=f&&_,x=b&&!y&&(s.status!==`success`||!!m),S=n>=o?a[7]:void 0,C=c.lazyFn&&c._lazy!==!0?S:void 0;if(b&&!m&&(s.invalid=!1,s.updatedAt=Date.now()),v&&v[2]++,x){let t=s._flight;s._flight=v,Lr(e,s,t)?.abort(),n>=o&&(s.status=`pending`),S?.()}b||(s.isFetching=!1);let w=!p&&x?Ur(e,t,s,c,g,i,a).then(t=>(Wr(s,t,l),t[0]===Tr&&(m&&!a[0].signal.aborted&&Gr(e,s,u),n>=o&&(s.status=`pending`)),t)):Promise.resolve(p??[Tr,s.loaderData]),T=(async()=>{try{let e=Sr(c,void 0,C);e&&await jr(e,a[0].signal)}catch(r){if(!t[1].some((e,t)=>t<=n&&(e.status===`error`||e.status===`notFound`||e._notFound)))return[n,Fr(e,t,c,r,a)]}let r=await w;x&&r[0]===Tr&&s.status===`pending`&&!a[0].signal.aborted&&(s.status=`success`,S?.())})();if(r.push([n,w,T]),!y)return w.then(e=>Kr(s,e));let E={...s,status:`pending`,preload:!1,_flight:v};s.invalid=!1,s.isFetching=`loader`;let D=Ur(e,t,E,c,g,i,a).then(e=>(s.isFetching=!1,Wr(E,e,!1),e));return(t[2]??=[]).push([n,D,T,E]),D.then(e=>Kr(E,e))}async function Jr(e,t,n,r,i=0){let a=n?.[1][1],o=a?.routeId?t.findIndex(e=>e.routeId===a.routeId):n?.[0]??t.length-1;o<0&&(o=0);for(let n=o;n>=0;n--){let i=Mr(e,t[n]);try{let e=Sr(i,!1);e&&await jr(e,r)}catch(e){if(e===r&&r.aborted)throw e}if(i.options.notFoundComponent)return n}return a?.routeId?o:i}function Yr(e,t){t[2]&&=(zr(e,t[2].map(e=>e[3])),void 0)}async function Xr(e,t,n,r){let i;try{await Promise.all(e.map(e=>e[1].then(async t=>{let a=e[0];if(!(r&&a>=await r)){if(t[0]>=Or)throw[a,t];!i&&t[0]!==Tr&&(i=[a,t],await Promise.all((n??[]).map(e=>{if(!(e[0]<=a))return e[1].then(t=>{if(t[0]===Or)throw[e[0],t]})})))}})))}catch(e){return e}return t??i}function Zr(e,t,n,r,i,a){for(;r[0]===Or;){let o=r[1],s=o.options;try{if((s.href||o.headers.has(`Location`))&&(e.resolveRedirect(o),s.reloadDocument)||(s.reloadDocument?i[3]:i[1]>=20))return r;let n=e.buildLocation({...s,_fromLocation:t[0],_includeValidateSearch:!0}),a=n.maskedLocation??n;if(a.external){let t=o.clone();return t.options={...s},t.headers.set(`Location`,a.publicHref),e.resolveRedirect(t),i[3]?[Or,t]:[Or,t,a]}return[Or,o,n]}catch(e){r=a?[Er,e]:Pr(n,e),a=!0}}return r}async function Qr(e,t,n,r,i,a){let o=t[1],s=await i,c=!1,l=o.findIndex(e=>e._notFound),u=t=>t[1][0]===Dr?Jr(e,o,t,r.signal):t[0],d=l<0?o.length:l;if((s?.[1][0]??0)>=Or)d=0;else if(s){d=s[2]??=await u(s);for(let e of n){if(e[0]>=d)break;let t=await e[1];if(t[0]!==Tr&&t[0]<Or&&!(`loaderData`in o[e[0]])){s=[e[0],t],d=s[2]=await u(s);break}}}for(let e of n){if(e[0]>=d)break;let t=await e[2];if(t){s=t;break}}if((s?.[1][0]??0)>=Or){let n=s[1];if(n[0]!==Or||n[1].options.reloadDocument||n[2])return Yr(e,t),n;c=!0,s=[0,[Er,Error(`Too many redirects`)]]}let f=s?s[2]??await u(s):l;if(f>=0){let i=s?.[1],l=i?.[0],u=o[f],d=i?.[1],p=()=>{i&&(u._notFound=void 0,l===Er?u.status=`error`:(d.routeId=u.routeId,u.routeId===e.routeTree.id?(u.status=`success`,u._notFound=!0):u.status=`notFound`),u.error=d,u.isFetching=!1)};p(),i||a?.();let m=Mr(e,u);try{await jr(i?Promise.resolve().then(()=>Sr(m,l===Er?`errorComponent`:`notFoundComponent`)):Promise.all([Sr(m),Sr(m,`notFoundComponent`)]),r.signal)}catch(n){if(n===r.signal&&r.signal.aborted)return Yr(e,t),kr}i?c&&(r.abort(),await Promise.all([...n.map(e=>e[1]),...n.map(e=>e[2]),...(t[2]??[]).map(e=>e[1])]),Yr(e,t),zr(e,o),p()):u.status=`success`}return t}async function $r(e,t,n,r=0,i=t[1].length){let a=t[1];for(let t=r;t<i;t++){let r=a[t],i=Mr(e,r).options;if(i.head||i.scripts)try{let t={ssr:e.options.ssr,matches:a,match:r,params:r.params,loaderData:r.loaderData},[o,s]=await jr(Promise.all([i.head?.(t),i.scripts?.(t)]),n);r.meta=o?.meta,r.links=o?.links,r.headScripts=o?.scripts,r.styles=o?.styles,r.scripts=s}catch(e){if(e===n&&n.aborted)break;console.error(e)}if(r.status!==`success`||r._notFound)break}return t}async function ei(e,t,n,r){let i=[t,n],a=r[0].signal,o;try{let t=e.stores.matches.get(),s=n.findIndex(e=>e._notFound);if(e.options.notFoundMode!==`root`&&s>=0){let t=await Jr(e,n,void 0,a,s);n[s]._notFound=void 0,n[t]._notFound=!0,s=t}let c=s<0?n.length:s+1,l=0;for(;l<c&&l!==s;){let e=n[l],i=r[2][l],a=t[l];if(i?.id!==e.id||i.status!==`success`||e.preload||a?.id!==e.id||a.status!==`success`||(l++,i._notFound||a._notFound))break}let u=[],d=r[6]??0,f=d?Promise.resolve(n[d-1]):void 0,p=()=>{for(let t=d;t<c&&!a.aborted;t++)f=qr(e,i,t,u,f,r,l)},m=await Ir(e,i,r,c,p,l);if(m){if(r[4]=!0,c=m[0],m[1][0]===Dr){let t=await Jr(e,n,m,a);m[2]=t,c=Math.min(c,t+1)}else m[1][0]>=Or&&(c=0);p()}if(!a.aborted&&!r[3]){let t=[];for(let[n,r]of e._flights??[])r[2]||(e._flights.delete(n),t.push(r[1]));for(let e of t)e.abort()}let h=Qr(e,i,u,r[0],Xr(u,m,i[2]),r[7]);i[2]?.length&&(i[3]=Xr(i[2],void 0,void 0,h.then(e=>Ar(e)?0:Cr(n).length,()=>0))),o=await h}catch(t){if(Yr(e,i),t===a&&a.aborted)return kr;throw t}return Ar(o)?o:$r(e,o,a,r[6]===n.length?r[6]:0)}function ti(e,t){if(e._tx!==t)return;let n=t[3],r=e.stores.matches.get(),i=e._pending;for(let a=0;a<n.length;a++){let o=n[a],s=o.status===`success`&&!o._notFound,c=r[a]?.id===o.id&&r[a]?.status===`pending`;if(s&&!c)continue;let l=Mr(e,o),u=s||o.invalid?0:l.options.pendingMs??e.options.defaultPendingMs,d=l.options.pendingComponent??e.options.defaultPendingComponent;if(!d||typeof u!=`number`||u===1/0){i&&(i[0]=t,i[2]=0,i[4]=!0);return}let f=l.options.pendingMinMs??e.options.defaultPendingMinMs??0,p=!1;if(i?.[1]===o.id?(p=i[0]!==t,i[0]=t):(clearTimeout(i?.[3]),e._pending=i=void 0),i||(e._pending=i=[t,o.id,c?Date.now()+f:t[4]+u,void 0,c||void 0,d]),i[4]&&!p&&i[5]===d)return;if(i[5]=d,!i[4]){clearTimeout(i[3]);let n=i[2]-Date.now();if(n>0){i[3]=setTimeout(()=>ti(e,t),n);return}i[2]=0}let m=n.map(e=>({...e,_flight:void 0}));m[a].status=`pending`;let h=i[4]=e.startTransition(()=>e.stores.setMatches(m),m).then(t=>(t&&e._pending===i&&i[4]===h&&!i[2]&&(i[2]=Date.now()+f),t));return}}function ni(e,t){let n=e._pending;(e._tx===t||!e._tx?.[3].some(e=>e.id===n?.[1]))&&(clearTimeout(n?.[3]),e._pending=void 0)}async function ri(e,t){let n=e._pending;if(!n)return;clearTimeout(n[3]);let r=n[2]-Date.now();if(!n[4]||r<=0||!Cr(t[3]).some(e=>e.id===n[1]))return;let i;try{await jr(new Promise(e=>{i=setTimeout(e,r)}),t[0].signal)}catch{}clearTimeout(i)}function ii(e,t){e._committed=t,e.stores.setMatches(t)}function ai(e,t,n,r){let i=e._committed,a=e._lifecycleEnd,o=e._cache;for(let e of n)e.preload=!1,r&&(e._assetEnd=void 0);let s=Cr(n).length,c=new Map;{let t=Date.now(),r=new Set;for(let e=0;e<n.length;e++){let t=n[e];(e<s||t.status===`success`)&&r.add(t.id)}for(let n of[...i,...o.values()]){if(n.status!==`success`||r.has(n.id))continue;let i=Mr(e,n);!i.options.loader||t-n.updatedAt>=(n.preload?i.options.preloadGcTime??e.options.defaultPreloadGcTime??3e5:i.options.gcTime??e.options.defaultGcTime??3e5)||c.set(n.id,o.get(n.id)===n?n:{...n,_flight:void 0,isFetching:!1,context:{}})}}t[3]=[],e._cache=c;let l=e._lifecycleEnd=or(n);ii(e,n),zr(e,[...o.values(),...i].filter(e=>e._flight&&c.get(e.id)!==e),n),sr(e,i,n,a,l,t)}async function oi(e,t){let n=e._tx;for(;n&&n!==t;)t=n,await n[5],n=e._tx}function si(e,t,n){let r=n[1].options,i=n[2];if(!i)return e.navigate({...r,replace:!0,ignoreBlocker:!0});if(r.reloadDocument)return e.navigate({href:(i.maskedLocation??i).publicHref,reloadDocument:!0,replace:!0,ignoreBlocker:!0});i._redirects=t[1]+1,e._pendingLocation=i;let a=e.commitLocation({...i,viewTransition:r.viewTransition,replace:!0,resetScroll:r.resetScroll,hashScrollIntoView:r.hashScrollIntoView,ignoreBlocker:!0});return queueMicrotask(()=>{e._pendingLocation===i&&(e._pendingLocation=void 0)}),a}async function ci(e,t,n,r,i){let a=n.map(e=>({...e}));Br(a);for(let t of r)Rr(e,a[t[0]]),a[t[0]]=t[3];let o=[t[2],a],s;try{s=await Qr(e,o,r,t[0],i)}catch(t){throw zr(e,a),t}if(Ar(s))zr(e,a),s[0]===Or&&e._tx===t&&e._committed===n&&await si(e,t,s);else if(await $r(e,s,t[0].signal),e._tx!==t||e._committed!==n)zr(e,a);else{for(let t of a){let n=e._cache.get(t.id);n?._flight&&n._flight===t._flight&&(e._cache.delete(t.id),Rr(e,n))}ii(e,a),zr(e,n,a)}}async function li(e,t,n,r,i,a){let o=await ei(e,t[2],t[3],[t[0],t[1],e._committed,void 0,i,n,a,r]);if(Ar(o)){let n=o[0]===Or&&e._tx===t;if((!n||o[1].options.reloadDocument)&&ni(e,t),zr(e,t[3]),t[3]=[],!n)return;if(e._tx!==t){ni(e,t);return}await si(e,t,o);return}let s=o[1];if(e._tx===t&&await ri(e,t),e._tx!==t){ni(e,t),zr(e,s),Yr(e,o);return}let c=t[2],l=ir(c,e.stores.resolvedLocation.get()),u=o[2];await e.startViewTransition(async()=>{if(e._tx===t&&await ri(e,t),e._tx!==t){ni(e,t),zr(e,s),Yr(e,o);return}let n=await e.startTransition(()=>{ni(e,t),ai(e,t,s,a),e._tx===t&&(e.emit({type:`onLoad`,...l}),e._tx===t&&e.emit({type:`onBeforeRouteMount`,...l}))},s);e._tx===t?(u?.length&&ci(e,t,s,u,o[3]).catch(console.error),e.batch(()=>{e.stores.resolvedLocation.set(c),e.stores.status.set(`idle`),e._tx===t&&e.emit({type:`onResolved`,...l}),n&&e._tx===t&&e.emit({type:`onRendered`,...l})}),e._tx===t&&(e._commitPromise?.resolve(),e._commitPromise=void 0)):Yr(e,o)})}async function ui(e,t){let n=e._tx,r=e.stores.resolvedLocation.get(),i=r??e.stores.location.get(),a=e.latestLocation,o=e._pendingLocation,s=o?.href===a.href?o._redirects??0:0,c=e._handoff,l=c?.[0](),u=new AbortController,d=e._preflight;if(e._preflight=u,l||c?.[1](),d?.abort(),!u.signal.aborted){let t=ir(a,r);e.emit({type:`onBeforeNavigate`,...t}),u.signal.aborted||e.emit({type:`onBeforeLoad`,...t})}if(u.signal.aborted){await oi(e,n);return}let f=i.href===a.href,p=u,m=e.matchRoutes(a,{_controller:u});Br(m);let h=l?c[1](m):void 0;if(h?p=l:l?.abort(),u.signal.aborted){zr(e,m),await oi(e,n);return}e._preflight=void 0;let g,_=()=>li(e,y,f,()=>ti(e,y),t?.sync,h),v=t?.sync?new Promise(e=>g=e):Promise.resolve().then(_),y=[p,s,a,m,Date.now(),v.then(()=>oi(e,y))];if(e._tx=y,n){for(let t of e.stores.matches.get()){if(e._tx!==y)break;t.isFetching&&Vr(e,t,!1)}n[0].abort(),zr(e,n[3],y[3],!0)}e._tx===y?(e.batch(()=>{e.stores.status.set(`pending`),e.stores.location.set(a)}),(h||!e._committed.length&&m[0]?.status!==`success`&&!m.some(e=>e._notFound))&&ti(e,y),g?.(_()),await y[5]):(zr(e,y[3]),y[3]=[],g?.(),await oi(e,y))}async function di(e,t){let n=e.buildLocation(t);for(let t=0;;t++){let r=e._committed,i=new AbortController,a,o,s;try{try{a=e.matchRoutes(n,{_controller:i}),Br(a),o=(e._preloads??=new Map).set(i,a),s=await ei(e,n,a,[i,t,r,!0])}finally{o&&(o=o.delete(i),zr(e,a)),i.abort()}if(!Ar(s))return s[1];if(!o||s.length<3)return;n=s[2]}catch(e){Kt(e)||console.error(e);return}}}var fi=`Error preloading route! ☝️`,pi=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e,this._branch=void 0;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=hn:this.parentRoute||Ft();let r=n?hn:t?.path;r&&r!==`/`&&(r=Lt(r));let i=t?.id||r,a=n?hn:It((this.parentRoute.id===`__root__`?``:this.parentRoute.id)+`/`+(i??``));r===`__root__`&&(r=`/`);let o=a===`__root__`?`/`:r===void 0?this.parentRoute.fullPath:It(this.parentRoute.fullPath+`/`+r);this._path=r,this._id=a,this._fullPath=o,this._to=Rt(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>gn({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},mi=class extends pi{constructor(e){super(e)}},I=i(),hi=class extends F.Component{constructor(...e){super(...e),this.state={error:0},this.reset=()=>{this.setState({error:0})}}static getDerivedStateFromProps(e,t){let n=e.getResetKey();return t.error&&t.resetKey!==n?{resetKey:n,error:0}:{resetKey:n}}static getDerivedStateFromError(e){return{error:[e]}}componentDidCatch(e,t){this.props.onCatch?.(e,t)}render(){let e=this.state.error;return e?F.createElement(this.props.errorComponent??gi,{error:e[0],reset:this.reset}):this.props.children}};function gi({error:e}){let[t,n]=F.useState(!1);return(0,I.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,I.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,I.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,I.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,I.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,I.jsx)(`div`,{children:(0,I.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e?.message?(0,I.jsx)(`code`,{children:e.message}):null})}):null]})}var _i=()=>!0,vi=()=>!1;function yi({children:e,fallback:t=null}){return(0,I.jsx)(F.Fragment,{children:bi()?e:t})}function bi(e=!0){return F.useSyncExternalStore(xi,_i,e?vi:_i)}function xi(){return()=>{}}var Si=F.createContext(null);function Ci(e){return F.useContext(Si)}function wi(e,t){let n=e.stores.location,r=new Set,i,a,o=n=>{wr(e,t,n)||(i=n,r.forEach(e=>e()))};return[()=>i??n.get(),e=>(r.size||(i=n.get(),a=n.subscribe(o).unsubscribe),r.add(e),()=>{r.delete(e),r.size||(a(),i=void 0)})]}var Ti=F.createContext(void 0),Ei=F.createContext(void 0);function Di({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0)n=e.nextSub;else{for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}}while(1)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(1)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function Oi(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var ki=[],Ai=0,{link:ji,unlink:Mi,propagate:Ni,checkDirty:Pi,shallowPropagate:Fi}=Di({update(e){return e._update()},notify(e){ki[Li++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,Vi(e))}}),Ii=0,Li=0,Ri,zi=0;function Bi(e){try{++zi,e()}finally{--zi||Hi()}}function Vi(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=Mi(n,e)}function Hi(){if(!(zi>0)){for(;Ii<Li;){let e=ki[Ii];ki[Ii++]=void 0,e.notify()}Ii=0,Li=0}}function Ui(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return Ri!==void 0&&ji(i,Ri,Ai),i._snapshot},subscribe(e){let t=Oi(e),n={current:!1},r=Wi(()=>{i.get(),n.current?(Ri=void 0,t.next?.(i._snapshot)):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=Ri,o=t?.compare??Object.is;if(n)Ri=i,++Ai,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{Ri=a,n&&(i.flags&=-5),Vi(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&Pi(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&Fi(e)}}else e&32&&(i.flags=e&-33);return Ri!==void 0&&ji(i,Ri,Ai),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(Ni(e),Fi(e),Hi())}},i}function Wi(e){let t=()=>{let t=Ri;Ri=n,++Ai,n.depsTail=void 0,n.flags=6;try{return e()}finally{Ri=t,n.flags&=-5,Vi(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&Pi(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,Vi(this)}};return t(),n}var Gi=r((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Ki=r(((e,t)=>{t.exports=Gi()})),qi=r((e=>{var t=n(),r=Ki();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Ji=r(((e,t)=>{t.exports=qi()}))();function Yi(e,t){return e===t}function Xi(e,t=e=>e,n){let r=n?.compare??Yi,i=(0,F.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,F.useCallback)(()=>e.get(),[e]);return(0,Ji.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var Zi={};function Qi(e,t){let n=F.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=St(n.current,i):i}}function $i(e){let t=Ci(),n=F.useContext(e.from?Ei:Ti),r=e.from??n,i=t.stores.getMatchStore(r),a=Qi(e,t),o=Xi(i,e=>e?a(e):Zi);if(o!==Zi)return o;(e.shouldThrow??!0)&&Ft()}function ea(e){return $i({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function ta(e){let{select:t,...n}=e;return $i({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function na(e){return $i({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function ra(e){return $i({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function ia(e){let t=Ci();return F.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function aa(e){return $i({...e,select:t=>e.select?e.select(t.context):t.context})}function oa(...e){let t=F.useRef(e),n=t.current;return e.forEach((e,t)=>{wt(n[t],e,!1,!0)||(n[t]=e)}),t.current}function sa(e,t){e.preloadRoute(t).catch(e=>{console.warn(e),console.warn(fi)})}function ca(e,t){let n=typeof e==`string`&&kt(e);if(n)return t.has(n)?e:null}function la(e,t,n,r){let i=Bt(e.pathname,r),a=Bt(t.pathname,r);return(n?.exact?i!==a:!i.startsWith(a)||i.length!==a.length&&i[a.length]!==`/`)||(n?.includeSearch??!0)&&!wt(e.search,t.search,!n?.exact,n?.explicitUndefined)?!1:!n?.includeHash||e.hash===t.hash}function ua(e,t,n){let r=Ci(),i=F.useRef(null),a=F.useCallback(e=>{if(i.current=e,typeof t==`function`)return t(e);t&&(t.current=e)},[t]),{activeOptions:o,to:s,preload:c,preloadDelay:l,disabled:u,target:d,onClick:f,onBlur:p,onFocus:m,onMouseEnter:h,onMouseLeave:g,onTouchStart:_}=e,[v,y,b]=oa(e.search,e.params,o),x=F.useContext(Ti),S=(r.stores._linkScopes??={})[x]??=wi(r,x),[C,w,T]=F.useMemo(()=>{let t=ca(s,r.protocolAllowlist);if(t!==void 0){let n=[t??void 0];return[e,()=>n]}let n={...e},i,a,o,c=()=>{let e=S[0]();if(e!==i){n._fromLocation=e;let t=r.buildLocation(n),o=va(t,r,u),s=u||o&&!kt(o)?la(e,t,b,r.basepath):void 0;(!a||a[0]!==o||a[1]!==s)&&(a=[o,s]),i=e}return a};return[n,c,b?.includeHash&&(()=>{let e=c();return e[1]?o??=[e[0],!1]:e})]},[r,S,e.from,e.hash,e.href,s,v,y,e.state,e.mask,e.unsafeRelative,b,u]),[E,D]=F.useSyncExternalStore(S[1],w,T||w),O=D===void 0&&E,k=u||E===void 0,A=F.useRef(!1),ee=e.reloadDocument||O||k?!1:c??r.options.defaultPreload,j=l??r.options.defaultPreloadDelay??0,M=F.useCallback(e=>{let t=e?.isIntersecting;t??ee===`intent`?j?i.t??=setTimeout(()=>{i.t=void 0,sa(r,C)},j):sa(r,C):t===!1&&ga(i)},[r,C,i,ee,j]);F.useEffect(()=>{if(!ee)return;ee===`render`&&!A.current&&(A.current=!0,sa(r,C));let e=!0,t;return ee===`viewport`&&i.current&&typeof IntersectionObserver==`function`&&(t=new IntersectionObserver(t=>{e&&M(t.pop())},{rootMargin:`100px`}),t.observe(i.current)),()=>{e=!1,t?.disconnect(),ga(i)}},[r,C,ee,M,i]);let te=ma(e,n);if(te.ref=t?a:i,O)return te.href=O,te;let ne=t=>{let n=d??t.currentTarget.getAttribute(`target`);!k&&!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)&&!t.defaultPrevented&&(!n||n===`_self`)&&t.button===0&&(t.preventDefault(),ga(i),r.navigate({...e,_fromLocation:C._fromLocation}))},re=()=>{ee===`intent`&&sa(r,C)},ie=()=>{ee===`intent`&&ga(i)};return te.onClick=_a(f,ne),te.onBlur=_a(p,ie),te.onFocus=_a(m,M),te.onMouseEnter=_a(h,M),te.onMouseLeave=_a(g,ie),te.onTouchStart=_a(_,re),ha(te,e,D,E,k,n)}var da={},fa={className:`active`},pa=new Set([`to`,`params`,`search`,`hash`,`state`,`mask`,`from`,`unsafeRelative`,`reloadDocument`,`preload`,`preloadDelay`,`preloadIntentProximity`,`hashScrollIntoView`,`replace`,`startTransition`,`resetScroll`,`viewTransition`,`ignoreBlocker`,`activeProps`,`inactiveProps`,`activeOptions`,`_asChild`]);function ma(e,t){let n={};for(let r in e)pa.has(r)||r===`type`&&t!==void 0||r===`disabled`&&t===`a`||(n[r]=e[r]);return n}function ha(e,t,n,r,i,a){let{activeProps:o,inactiveProps:s,className:c,style:l,target:u}=t,d=_t(n?o:s,{})??(n?fa:da);Object.assign(e,d),e.href=r,a!==`a`&&(e.disabled=i),e.target=u;let f=d.style;(l||f)&&(e.style=l&&f?{...l,...f}:l||f);let p=d.className;return(c||p)&&(e.className=c?p?`${c} ${p}`:c:p),i&&(e.role=`link`,e[`aria-disabled`]=!0),n&&(e[`data-status`]=`active`,e[`aria-current`]=`page`),e}var ga=e=>{clearTimeout(e.t),e.t=void 0},_a=(e,t)=>e?n=>n.defaultPrevented||(e(n),n.defaultPrevented||t(n)):t;function va(e,t,n){if(n)return;let r=e.maskedLocation??e,i=r.external?r.publicHref:t.history.createHref(r.publicHref)||`/`;if(!r.external&&i===r.publicHref||!jt(i,t.protocolAllowlist))return i}var ya=F.memo(F.forwardRef((e,t)=>{let n=e._asChild||`a`,r=ua(e,t,n),i=typeof e.children==`function`?e.children({isActive:r[`data-status`]===`active`}):e.children;return F.createElement(n,r,i)}),ba);function ba(e,t){let n=0;for(let r in t)if(n++,e[r]!==t[r]&&(!pa.has(r)||!wt(e[r],t[r],!1,!0)))return!1;for(let t in e)n--;return n===0}var xa=class extends pi{constructor(e){super(e),this.useMatch=e=>$i({...e,from:this.id}),this.useRouteContext=e=>aa({...e,from:this.id}),this.useSearch=e=>ra({...e,from:this.id}),this.useParams=e=>na({...e,from:this.id}),this.useLoaderDeps=e=>ta({...e,from:this.id}),this.useLoaderData=e=>ea({...e,from:this.id}),this.useNavigate=()=>ia({from:this.fullPath}),this.Link=F.forwardRef((e,t)=>(0,I.jsx)(ya,{ref:t,from:this.fullPath,...e}))}};function Sa(e){return new xa(e)}var Ca=class extends mi{constructor(e){super(e),this.useMatch=e=>$i({...e,from:this.id}),this.useRouteContext=e=>aa({...e,from:this.id}),this.useSearch=e=>ra({...e,from:this.id}),this.useParams=e=>na({...e,from:this.id}),this.useLoaderDeps=e=>ta({...e,from:this.id}),this.useLoaderData=e=>ea({...e,from:this.id}),this.useNavigate=()=>ia({from:this.fullPath}),this.Link=F.forwardRef((e,t)=>(0,I.jsx)(ya,{ref:t,from:this.fullPath,...e}))}};function wa(e){return new Ca(e)}function Ta(e){let t=Ci(),n=`not-found-${Xi(t.stores.location,e=>e.pathname)}-${Xi(t.stores.status)}`;return(0,I.jsx)(hi,{getResetKey:()=>n,onCatch:(t,n)=>{if(Kt(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(Kt(t))return e.fallback?.(t);throw t},children:e.children})}function Ea(){return(0,I.jsx)(`p`,{children:`Not Found`})}function Da(e,t,n){return t.options.notFoundComponent?(0,I.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,I.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,I.jsx)(Ea,{})}function Oa(e,t){let n=t?.options.pendingComponent??e.options.defaultPendingComponent;return n?(0,I.jsx)(n,{}):null}var ka=(e,t)=>e[0]===t[0]&&e[1]===t[1],Aa=(e,t,n)=>!t.isRoot||t.options.shellComponent||t.options.wrapInSuspense||n===!1||n===`data-only`||!e.ssr,ja=F.memo(function({routeId:e}){let t=Ci();return Ma(t,Xi(t.stores.getMatchStore(e)))});function Ma(e,t){let n=e.routesById[t.routeId],r=Oa(e,n),i=n.options.errorComponent??e.options.defaultErrorComponent,a=n.options.onCatch??e.options.defaultOnCatch,o=n.isRoot?n.options.notFoundComponent??e.options.notFoundRoute?.options.component:n.options.notFoundComponent,s=t.ssr===!1||t.ssr===`data-only`,c=Aa(e,n,t.ssr)&&(n.options.wrapInSuspense??r??(n.options.errorComponent?.preload||s)),l=(0,I.jsx)(Na,{match:t});s&&(l=(0,I.jsx)(yi,{fallback:r,children:l})),o&&(l=(0,I.jsx)(Ta,{fallback:e=>{if(e.routeId??=t.routeId,e.routeId!==t.routeId)throw e;return F.createElement(o,e)},children:l})),i&&(l=(0,I.jsx)(hi,{getResetKey:()=>t,errorComponent:i,onCatch:(e,n)=>{if(Kt(e))throw e.routeId??=t.routeId,e;a?.(e,n)},children:l})),c&&(l=(0,I.jsx)(F.Suspense,{fallback:r,children:l}));let u=n.isRoot&&n.options.shellComponent;return u?(0,I.jsx)(Ti.Provider,{value:t.routeId,children:(0,I.jsxs)(u,{children:[l,null]})}):(0,I.jsxs)(Ti.Provider,{value:t.routeId,children:[l,null]})}var Na=F.memo(function({match:e}){let t=Ci(),n=e.routeId,r=t.routesById[n],i=F.useMemo(()=>{let i=(r.options.remountDeps??t.options.defaultRemountDeps)?.({routeId:n,loaderDeps:e.loaderDeps,params:e._strictParams,search:e._strictSearch});return i?JSON.stringify(i):void 0},[n,e.loaderDeps,e._strictParams,e._strictSearch,r.options.remountDeps,t.options.defaultRemountDeps]),a=F.useMemo(()=>{let e=r.options.component??t.options.defaultComponent;return e?(0,I.jsx)(e,{},i):(0,I.jsx)(Pa,{})},[i,r.options.component,t.options.defaultComponent]);if(e.status===`pending`){if(t.ssr&&!Aa(t,r,e.ssr))return a;if(t._tx)throw t._tx[5];return Oa(t,r)}if(e.status===`notFound`)return Da(t,r,e.error);if(e.status===`error`)throw e.error;return a}),Pa=F.memo(function(){let e=Ci(),t=F.useContext(Ti),n,r,i;{let a=e.stores.getMatchStore(t);[n,r]=Xi(a,e=>[!!e._notFound,e.error],{compare:ka}),i=Xi(e.stores.ids,e=>e[e.indexOf(t)+1])}if(n)return Da(e,e.routesById[t],r);if(!i)return null;let a=(0,I.jsx)(ja,{routeId:i});return t===`__root__`?(0,I.jsx)(F.Suspense,{fallback:Oa(e),children:a}):a});function Fa(e,t){let n=e[1];e.length=0,n?.(t)}function Ia({t:e}){let t=Ci(),n=t._rendered??=[];return t.startTransition=(r,i)=>new Promise(a=>{Fa(n,!1),n.push(i,a),e(t),F.startTransition(r)}),ht(()=>{let e=t.history.subscribe(t.load);t.updateLatestLocation();let r=t.latestLocation,i=t.buildLocation({to:r.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});if(Rt(r.publicHref)!==Rt(i.publicHref))return t.commitLocation({...i,replace:!0,ignoreBlocker:!0}),e;let a=t.stores.resolvedLocation.get();return a?.href===r.href&&a.state.__TSR_key===r.state.__TSR_key?n.push(t.stores.matches.get(),e=>{e&&t.emit({type:`onRendered`,...ir(a,a)})}):t._tx||t.load({sync:!0}).catch(console.error),e},[t,t.history]),null}function La(){let e=Ci(),t=e.routesById[hn],n=Oa(e,t),r=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Ia,{t:F.useState()[1]}),e.ssr?(0,I.jsx)(Ra,{}):(0,I.jsx)(F.Suspense,{fallback:n,children:(0,I.jsx)(Ra,{})})]});return e.options.InnerWrap?(0,I.jsx)(e.options.InnerWrap,{children:r}):r}function Ra(){let e=Ci(),t=e._rendered,n=Xi(e.stores.matches,e=>t[0]??e),r=n[0],i=r?.routeId;ht(()=>{t[0]===n&&Fa(t,!0)},[t,n]);let a=i?(0,I.jsx)(ja,{routeId:i}):null;return e.options.disableGlobalCatchBoundary?a:(0,I.jsx)(hi,{getResetKey:()=>r,onCatch:void 0,children:a})}var za=e=>({createMutableStore:Ui,createReadonlyStore:Ui,batch:Bi}),Ba=e=>new Va(e),Va=class extends cr{constructor(e){super(e,za)}};function Ha({router:e,children:t,...n}){yt(n)&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,I.jsx)(Si.Provider,{value:e,children:t});return e.options.Wrap?(0,I.jsx)(e.options.Wrap,{children:r}):r}function Ua({router:e,...t}){return(0,I.jsx)(Ha,{router:e,...t,children:(0,I.jsx)(La,{})})}var Wa=r((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&ee(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ee(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function ee(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ee(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),eee=r(((e,t)=>{t.exports=Wa()})),Ga=r((e=>{var t=eee(),r=n(),i=a();function o(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function l(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(c(e)!==e)throw Error(o(188))}function f(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return d(i),e;if(a===r)return d(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,l=i.child;l;){if(l===n){s=!0,n=i,r=a;break}if(l===r){s=!0,r=i,n=a;break}l=l.sibling}if(!s){for(l=a.child;l;){if(l===n){s=!0,n=a,r=i;break}if(l===r){s=!0,r=a,n=i;break}l=l.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}function m(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&m(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function h(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function g(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function _(e){var t=[null,null],n=h(e);return n===null||v(t,e,n.child,{foundSelf:!1}),t}function v(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&v(e,t,n.child,r))return!0;n=n.sibling}return!1}function y(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(o(559))}}var b=null,x=null;function S(e,t,n){return e===n||e===t&&(b=e,!0)}function C(e,t,n){return e===n?(x=e,!1):e===t&&(x!==null&&(b=e),!0)}function w(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function T(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var E=Object.assign,D=Symbol.for(`react.element`),O=Symbol.for(`react.transitional.element`),k=Symbol.for(`react.portal`),A=Symbol.for(`react.fragment`),ee=Symbol.for(`react.strict_mode`),j=Symbol.for(`react.profiler`),M=Symbol.for(`react.consumer`),te=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),oe=Symbol.for(`react.lazy`),se=Symbol.for(`react.activity`),ce=Symbol.for(`react.legacy_hidden`),le=Symbol.for(`react.memo_cache_sentinel`),ue=Symbol.for(`react.view_transition`),de=Symbol.for(`react.recoverable`),fe=Symbol.iterator;function pe(e){return typeof e!=`object`||!e?null:(e=fe&&e[fe]||e[`@@iterator`],typeof e==`function`?e:null)}var me=Symbol.for(`react.client.reference`);function he(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===me?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case A:return`Fragment`;case j:return`Profiler`;case ee:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`;case se:return`Activity`;case ue:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case k:return`Portal`;case te:return e.displayName||`Context`;case M:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?he(e.type)||`Memo`:t;case oe:t=e._payload,e=e._init;try{return he(e(t))}catch{}}return null}var ge=Array.isArray,N=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ve={pending:!1,data:null,method:null,action:null},ye=[],be=-1;function xe(e){return{current:e}}function Se(e){0>be||(e.current=ye[be],ye[be]=null,be--)}function Ce(e,t){be++,ye[be]=e.current,e.current=t}var we=xe(null),Te=xe(null),Ee=xe(null),De=xe(null);function Oe(e,t){switch(Ce(Ee,t),Ce(Te,e),Ce(we,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Sp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Sp(t),e=Cp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Se(we),Ce(we,e)}function P(){Se(we),Se(Te),Se(Ee)}function ke(e){var t=e.memoizedState;t!==null&&(yh._currentValue=t.memoizedState,Ce(De,e)),t=we.current;var n=Cp(t,e.type);t!==n&&(Ce(Te,e),Ce(we,n))}function Ae(e){Te.current===e&&(Se(we),Se(Te)),De.current===e&&(Se(De),yh._currentValue=ve)}var je,Me;function Ne(e){if(je===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);je=t&&t[1]||``,Me=-1<e.stack.indexOf(`
|
|
4
4
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
@@ -92,7 +92,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
92
92
|
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
93
93
|
`,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=xP(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}wP.peek=TP;function wP(e){return e.value||``}function TP(){return`<`}EP.peek=DP;function EP(e,t,n,r){let i=hP(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function DP(){return`!`}OP.peek=kP;function OP(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function kP(){return`!`}AP.peek=jP;function AP(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e);if(!e.atBreak)continue;let i;for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function jP(){return"`"}function MP(e,t){let n=Yw(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][+\-.a-z]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}NP.peek=PP;function NP(e,t,n,r){let i=hP(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(MP(e,n)){let t=n.stack;n.stack=t.filter(function(e){return e!==`phrasing`});let r=n.enter(`autolink`),i=o.move(`<`);return i+=o.move(n.containerPhrasing(e,{before:i,after:`>`,...o.current()})),i+=o.move(`>`),r(),n.stack=t,i}let s=n.enter(`link`),c=n.enter(`label`),l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function PP(e,t,n){return MP(e,n)?`<`:`[`}FP.peek=IP;function FP(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function IP(){return`[`}function LP(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function RP(e){let t=LP(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function zP(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function BP(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function VP(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?zP(n):LP(n),s=e.ordered?o===`.`?`)`:`.`:RP(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),BP(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function HP(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function UP(e,t,n,r){let i=HP(n),a=n.bulletCurrent||LP(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function WP(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function GP(e,t,n,r){if(!e.children.some(function(e){return iP(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function KP(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}qP.attention=JP,qP.peek=YP;function qP(e,t,n,r){let i=n.enter(`phrasing`),a=n.containerPhrasing({type:`root`,children:[e]},r);return i(),a}function JP(e,t){return{construct:`strong`,markers:KP(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function YP(e,t,n){return n.options.strong||`*`}function XP(e,t,n,r){let i=t?t.children:[],a=i.indexOf(e);return n.safe(e.value,{...r,afterNode:i[a+1],beforeNode:i[a-1]})}function ZP(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function QP(e,t,n){let r=(BP(n)+(n.options.ruleSpaces?` `:``)).repeat(ZP(n));return n.options.ruleSpaces?r.slice(0,-1):r}var $P={blockquote:aP,break:lP,code:pP,definition:gP,emphasis:vP,hardBreak:lP,heading:CP,html:wP,image:EP,imageReference:OP,inlineCode:AP,link:NP,linkReference:FP,list:VP,listItem:UP,paragraph:WP,root:GP,strong:qP,text:XP,thematicBreak:QP};function eF(){return{enter:{table:tF,tableData:aF,tableHeader:aF,tableRow:rF},exit:{codeText:oF,table:nF,tableData:iF,tableHeader:iF,tableRow:iF}}}function tF(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function nF(e){this.exit(e),this.data.inTable=void 0}function rF(e){this.enter({type:`tableRow`,children:[]},e)}function iF(e){this.exit(e)}function aF(e){this.enter({type:`tableCell`,children:[]},e)}function oF(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,sF));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function sF(e,t){return t===`|`?t:e}function cF(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
94
94
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
95
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return tP(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=$P.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function lF(){return{exit:{taskListCheckValueChecked:dF,taskListCheckValueUnchecked:dF,paragraph:fF}}}function uF(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:pF}}}function dF(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function fF(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function pF(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=$P.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function mF(){return[vN(),HN(),qN(),eF(),lF()]}function hF(e){return{extensions:[yN(),UN(e),JN(),cF(e),uF()]}}var Cie={tokenize:kF,partial:!0},gF={tokenize:AF,partial:!0},_F={tokenize:jF,partial:!0},vF={tokenize:MF,partial:!0},yF={tokenize:NF,partial:!0},bF={name:`wwwAutolink`,tokenize:DF,previous:PF},xF={name:`protocolAutolink`,tokenize:OF,previous:FF},SF={name:`emailAutolink`,tokenize:EF,previous:IF},CF={};function wF(){return{text:CF}}for(var TF=48;TF<123;)CF[TF]=SF,TF++,TF===58?TF=65:TF===91&&(TF=97);CF[43]=SF,CF[45]=SF,CF[46]=SF,CF[95]=SF,CF[72]=[SF,xF],CF[104]=[SF,xF],CF[87]=[SF,bF],CF[119]=[SF,bF];function EF(e,t,n){let r=this,i,a;return o;function o(t){return!LF(t)||!IF.call(r,r.previous)||RF(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return LF(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(yF,u,l)(t):t===45||t===95||sT(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&oT(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function DF(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!PF.call(r,r.previous)||RF(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Cie,e.attempt(gF,e.attempt(_F,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function OF(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&FF.call(r,r.previous)&&!RF(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(oT(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||cT(t)||uT(t)||pT(t)||fT(t)?n(t):e.attempt(gF,e.attempt(_F,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function kF(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function AF(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(vF,c,s)(t):t===null||uT(t)||pT(t)||t!==45&&fT(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function jF(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(vF,t,a)(o):o===null||uT(o)||pT(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function MF(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||uT(o)||pT(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||uT(e)||pT(e)?t(e):r(e)}function a(e){return oT(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):oT(t)?(e.consume(t),o):n(t)}}function NF(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return sT(e)?n(e):t(e)}}function PF(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||uT(e)}function FF(e){return!oT(e)}function IF(e){return!(e===47||LF(e))}function LF(e){return e===43||e===45||e===46||e===95||sT(e)}function RF(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var zF={tokenize:qF,partial:!0};function BF(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:WF,continuation:{tokenize:GF},exit:KF}},text:{91:{name:`gfmFootnoteCall`,tokenize:UF},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:VF,resolveTo:HF}}}}function VF(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=aT(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function HF(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function UF(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||uT(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(aT(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return uT(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function WF(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||uT(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=aT(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return uT(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),gT(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function GF(e,t,n){return e.check(TT,t,e.attempt(zF,t,n))}function KF(e){e.exit(`gfmFootnoteDefinition`)}function qF(e,t,n){let r=this;return gT(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function JF(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&eT(o,o.length,0,ST(s,e.slice(r+1,n),t)),eT(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),eT(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=xT(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=xT(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var YF=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){XF(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function XF(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function ZF(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function QF(){return{flow:{null:{name:`table`,tokenize:$F,resolveAll:eI}}}}function $F(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):V(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):dT(t)?gT(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||uT(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,dT(t)?gT(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return dT(t)?gT(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||V(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return dT(t)?gT(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||V(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||V(n)?(e.exit(`tableRow`),t(n)):dT(n)?gT(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||uT(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function eI(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new YF;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(nI(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=tI(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=tI(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=tI(f,t,o,i,n,d)):(o[0]=o[1],d=tI(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&nI(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=ZF(t.events,n))}return e}function tI(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},rI(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=rI(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=rI(t.events,n[2]),a=rI(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},rI(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function nI(e,t,n,r,i){let a=[],o=rI(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function rI(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var iI={name:`tasklistCheck`,tokenize:oI};function aI(){return{text:{91:iI}}}function oI(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return uT(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return V(r)?t(r):dT(r)?e.check({tokenize:sI},t,n)(r):n(r)}}function sI(e,t,n){return gT(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function cI(e){return rT([wF(),BF(),JF(e),QF(),aI()])}var lI={};function uI(e){let t=this,n=e||lI,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(cI(n)),a.push(mF()),o.push(hF(n))}var dI=[{id:`one-dark-darker`,name:`One Dark Darker`,codeTheme:`one-dark-pro`,background:`#15181C`,foreground:`#ABB2BF`,cursor:`#B3BAC5`,selectionBackground:`#3B414D`,palette:[`#4A4F5A`,`#EE5D69`,`#97C775`,`#B68353`,`#61AFEF`,`#C678DD`,`#56B6C2`,`#CCCCCC`,`#616A7B`,`#FE808A`,`#C2DEAD`,`#D1A47A`,`#93CFFF`,`#E0A8F1`,`#82D2DC`,`#FFFFFF`]},{id:`one-dark-pro`,name:`One Dark Pro`,codeTheme:`one-dark-pro`,background:`#282C34`,foreground:`#ABB2BF`,cursor:`#528BFF`,selectionBackground:`#41454E`,palette:[`#3F4451`,`#E05561`,`#8CC265`,`#D18F52`,`#4AA5F0`,`#C162DE`,`#42B3C2`,`#D7DAE0`,`#4F5666`,`#FF616E`,`#A5E075`,`#F0A45D`,`#4DC4FF`,`#DE73FF`,`#4CD1E0`,`#E6E6E6`]},{id:`dracula`,name:`Dracula`,codeTheme:`dracula`,background:`#282A36`,foreground:`#F8F8F2`,cursor:`#F8F8F2`,selectionBackground:`#44475A`,palette:[`#21222C`,`#FF5555`,`#50FA7B`,`#F1FA8C`,`#BD93F9`,`#FF79C6`,`#8BE9FD`,`#F8F8F2`,`#6272A4`,`#FF6E6E`,`#69FF94`,`#FFFFA5`,`#D6ACFF`,`#FF92DF`,`#A4FFFF`,`#FFFFFF`]},{id:`tokyo-night`,name:`Tokyo Night`,codeTheme:`tokyo-night`,background:`#1A1B26`,foreground:`#C0CAF5`,cursor:`#C0CAF5`,selectionBackground:`#33467C`,palette:[`#15161E`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#A9B1D6`,`#414868`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#C0CAF5`]},{id:`catppuccin-mocha`,name:`Catppuccin Mocha`,codeTheme:`catppuccin-mocha`,background:`#1E1E2E`,foreground:`#CDD6F4`,cursor:`#F5E0DC`,selectionBackground:`#585B70`,palette:[`#45475A`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#BAC2DE`,`#585B70`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#A6ADC8`]},{id:`nord`,name:`Nord`,codeTheme:`nord`,background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,selectionBackground:`#434C5E`,palette:[`#3B4252`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#88C0D0`,`#E5E9F0`,`#4C566A`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#8FBCBB`,`#ECEFF4`]},{id:`gruvbox-dark`,name:`Gruvbox Dark`,codeTheme:`gruvbox-dark-medium`,background:`#282828`,foreground:`#EBDBB2`,cursor:`#EBDBB2`,selectionBackground:`#504945`,palette:[`#282828`,`#CC241D`,`#98971A`,`#D79921`,`#458588`,`#B16286`,`#689D6A`,`#A89984`,`#928374`,`#FB4934`,`#B8BB26`,`#FABD2F`,`#83A598`,`#D3869B`,`#8EC07C`,`#EBDBB2`]},{id:`solarized-dark`,name:`Solarized Dark`,codeTheme:`solarized-dark`,background:`#002B36`,foreground:`#839496`,cursor:`#839496`,selectionBackground:`#073642`,palette:[`#073642`,`#DC322F`,`#859900`,`#B58900`,`#268BD2`,`#D33682`,`#2AA198`,`#EEE8D5`,`#002B36`,`#CB4B16`,`#586E75`,`#657B83`,`#839496`,`#6C71C4`,`#93A1A1`,`#FDF6E3`]},{id:`github-dark`,name:`GitHub Dark`,codeTheme:`github-dark`,background:`#0D1117`,foreground:`#E6EDF3`,cursor:`#E6EDF3`,selectionBackground:`#264F78`,palette:[`#484F58`,`#FF7B72`,`#3FB950`,`#D29922`,`#58A6FF`,`#BC8CFF`,`#39C5CF`,`#B1BAC4`,`#6E7681`,`#FFA198`,`#56D364`,`#E3B341`,`#79C0FF`,`#D2A8FF`,`#56D4DD`,`#FFFFFF`]},{id:`rose-pine`,name:`Rosé Pine`,codeTheme:`rose-pine`,background:`#191724`,foreground:`#E0DEF4`,cursor:`#E0DEF4`,selectionBackground:`#403D52`,palette:[`#26233A`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`,`#6E6A86`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`]}];function fI(){let e=Z().prefs.theme,t=dI.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t}function pI(){let e=Q(e=>e.prefs.theme),t=dI.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t.codeTheme}function mI(){let e=fI(),t=document.documentElement.style;t.setProperty(`--bg`,e.background),t.setProperty(`--text`,e.foreground),t.setProperty(`--blue`,e.palette[4]),t.setProperty(`--danger`,e.palette[1]),t.setProperty(`--green`,e.palette[2]),t.setProperty(`--yellow`,e.palette[3]),document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.background)}function hI(e){let[t,n]=(0,F.useState)(null),r=pI();return(0,F.useEffect)(()=>{let t=!0;return ke(async()=>{let{getSharedHighlighter:e}=await import(`./dist-BrbsojdV.js`);return{getSharedHighlighter:e}},__vite__mapDeps([7,8,1])).then(({getSharedHighlighter:t})=>t({themes:[r],langs:[e.language],preferredHighlighter:`shiki-wasm`}).then(t=>({highlighter:t,lang:e.language})).catch(()=>t({themes:[r],langs:[`text`],preferredHighlighter:`shiki-wasm`}).then(e=>({highlighter:e,lang:`text`})))).then(({highlighter:t,lang:n})=>t.codeToHast(e.code,{lang:n,themes:{light:r,dark:r},defaultColor:!1,transformers:[{pre(e){delete e.properties.style}}]})).then(e=>{t&&n((0,I.jsx)(`div`,{className:`chat-markdown-shiki`,children:Vw(e,{Fragment:F.Fragment,jsx:I.jsx,jsxs:I.jsxs})}))}).catch(e=>console.error(e)),()=>{t=!1}},[e.code,e.language,r]),t===null?(0,I.jsx)(`pre`,{children:(0,I.jsx)(`code`,{children:e.code})}):t}function gI(){let[e,t]=(0,F.useState)(!1);async function n(e){try{if(!window.isSecureContext)throw Error(`Copying needs https or localhost`);await navigator.clipboard.writeText(e),t(!0),setTimeout(()=>t(!1),1500)}catch(e){R9(e)}}return{copied:e,copy:n}}function _I(e){let t=(0,F.useRef)(null),[n,r]=(0,F.useState)(!0),i=gI(),a=n?`Collapse table cells`:`Expand table cells`,o=i.copied?`Copied`:`Copy table`;function s(e){let n=t.current;if(n===null)return;let r=[...n.rows].map(e=>[...e.cells].map(e=>(e.textContent??``).trim())),a=e===`markdown`?r.flatMap((e,t)=>{let n=`| ${e.map(e=>e.replaceAll(`|`,`\\|`)).join(` | `)} |`;return t===0?[n,`| ${e.map(()=>`---`).join(` | `)} |`]:[n]}).join(`
|
|
95
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return tP(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=$P.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function lF(){return{exit:{taskListCheckValueChecked:dF,taskListCheckValueUnchecked:dF,paragraph:fF}}}function uF(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:pF}}}function dF(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function fF(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function pF(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=$P.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function mF(){return[vN(),HN(),qN(),eF(),lF()]}function hF(e){return{extensions:[yN(),UN(e),JN(),cF(e),uF()]}}var Cie={tokenize:kF,partial:!0},gF={tokenize:AF,partial:!0},_F={tokenize:jF,partial:!0},vF={tokenize:MF,partial:!0},yF={tokenize:NF,partial:!0},bF={name:`wwwAutolink`,tokenize:DF,previous:PF},xF={name:`protocolAutolink`,tokenize:OF,previous:FF},SF={name:`emailAutolink`,tokenize:EF,previous:IF},CF={};function wF(){return{text:CF}}for(var TF=48;TF<123;)CF[TF]=SF,TF++,TF===58?TF=65:TF===91&&(TF=97);CF[43]=SF,CF[45]=SF,CF[46]=SF,CF[95]=SF,CF[72]=[SF,xF],CF[104]=[SF,xF],CF[87]=[SF,bF],CF[119]=[SF,bF];function EF(e,t,n){let r=this,i,a;return o;function o(t){return!LF(t)||!IF.call(r,r.previous)||RF(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return LF(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(yF,u,l)(t):t===45||t===95||sT(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&oT(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function DF(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!PF.call(r,r.previous)||RF(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Cie,e.attempt(gF,e.attempt(_F,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function OF(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&FF.call(r,r.previous)&&!RF(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(oT(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||cT(t)||uT(t)||pT(t)||fT(t)?n(t):e.attempt(gF,e.attempt(_F,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function kF(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function AF(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(vF,c,s)(t):t===null||uT(t)||pT(t)||t!==45&&fT(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function jF(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(vF,t,a)(o):o===null||uT(o)||pT(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function MF(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||uT(o)||pT(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||uT(e)||pT(e)?t(e):r(e)}function a(e){return oT(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):oT(t)?(e.consume(t),o):n(t)}}function NF(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return sT(e)?n(e):t(e)}}function PF(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||uT(e)}function FF(e){return!oT(e)}function IF(e){return!(e===47||LF(e))}function LF(e){return e===43||e===45||e===46||e===95||sT(e)}function RF(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var zF={tokenize:qF,partial:!0};function BF(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:WF,continuation:{tokenize:GF},exit:KF}},text:{91:{name:`gfmFootnoteCall`,tokenize:UF},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:VF,resolveTo:HF}}}}function VF(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=aT(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function HF(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function UF(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||uT(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(aT(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return uT(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function WF(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||uT(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=aT(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return uT(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),gT(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function GF(e,t,n){return e.check(TT,t,e.attempt(zF,t,n))}function KF(e){e.exit(`gfmFootnoteDefinition`)}function qF(e,t,n){let r=this;return gT(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function JF(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&eT(o,o.length,0,ST(s,e.slice(r+1,n),t)),eT(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),eT(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=xT(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=xT(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var YF=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){XF(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function XF(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function ZF(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function QF(){return{flow:{null:{name:`table`,tokenize:$F,resolveAll:eI}}}}function $F(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):V(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):dT(t)?gT(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||uT(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,dT(t)?gT(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return dT(t)?gT(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||V(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return dT(t)?gT(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||V(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||V(n)?(e.exit(`tableRow`),t(n)):dT(n)?gT(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||uT(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function eI(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new YF;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(nI(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=tI(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=tI(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=tI(f,t,o,i,n,d)):(o[0]=o[1],d=tI(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&nI(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=ZF(t.events,n))}return e}function tI(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},rI(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=rI(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=rI(t.events,n[2]),a=rI(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},rI(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function nI(e,t,n,r,i){let a=[],o=rI(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function rI(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var iI={name:`tasklistCheck`,tokenize:oI};function aI(){return{text:{91:iI}}}function oI(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return uT(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return V(r)?t(r):dT(r)?e.check({tokenize:sI},t,n)(r):n(r)}}function sI(e,t,n){return gT(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function cI(e){return rT([wF(),BF(),JF(e),QF(),aI()])}var lI={};function uI(e){let t=this,n=e||lI,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(cI(n)),a.push(mF()),o.push(hF(n))}var dI=[{id:`one-dark-darker`,name:`One Dark Darker`,codeTheme:`one-dark-pro`,background:`#15181C`,foreground:`#ABB2BF`,cursor:`#B3BAC5`,selectionBackground:`#3B414D`,palette:[`#4A4F5A`,`#EE5D69`,`#97C775`,`#B68353`,`#61AFEF`,`#C678DD`,`#56B6C2`,`#CCCCCC`,`#616A7B`,`#FE808A`,`#C2DEAD`,`#D1A47A`,`#93CFFF`,`#E0A8F1`,`#82D2DC`,`#FFFFFF`]},{id:`one-dark-pro`,name:`One Dark Pro`,codeTheme:`one-dark-pro`,background:`#282C34`,foreground:`#ABB2BF`,cursor:`#528BFF`,selectionBackground:`#41454E`,palette:[`#3F4451`,`#E05561`,`#8CC265`,`#D18F52`,`#4AA5F0`,`#C162DE`,`#42B3C2`,`#D7DAE0`,`#4F5666`,`#FF616E`,`#A5E075`,`#F0A45D`,`#4DC4FF`,`#DE73FF`,`#4CD1E0`,`#E6E6E6`]},{id:`dracula`,name:`Dracula`,codeTheme:`dracula`,background:`#282A36`,foreground:`#F8F8F2`,cursor:`#F8F8F2`,selectionBackground:`#44475A`,palette:[`#21222C`,`#FF5555`,`#50FA7B`,`#F1FA8C`,`#BD93F9`,`#FF79C6`,`#8BE9FD`,`#F8F8F2`,`#6272A4`,`#FF6E6E`,`#69FF94`,`#FFFFA5`,`#D6ACFF`,`#FF92DF`,`#A4FFFF`,`#FFFFFF`]},{id:`tokyo-night`,name:`Tokyo Night`,codeTheme:`tokyo-night`,background:`#1A1B26`,foreground:`#C0CAF5`,cursor:`#C0CAF5`,selectionBackground:`#33467C`,palette:[`#15161E`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#A9B1D6`,`#414868`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#C0CAF5`]},{id:`catppuccin-mocha`,name:`Catppuccin Mocha`,codeTheme:`catppuccin-mocha`,background:`#1E1E2E`,foreground:`#CDD6F4`,cursor:`#F5E0DC`,selectionBackground:`#585B70`,palette:[`#45475A`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#BAC2DE`,`#585B70`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#A6ADC8`]},{id:`nord`,name:`Nord`,codeTheme:`nord`,background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,selectionBackground:`#434C5E`,palette:[`#3B4252`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#88C0D0`,`#E5E9F0`,`#4C566A`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#8FBCBB`,`#ECEFF4`]},{id:`gruvbox-dark`,name:`Gruvbox Dark`,codeTheme:`gruvbox-dark-medium`,background:`#282828`,foreground:`#EBDBB2`,cursor:`#EBDBB2`,selectionBackground:`#504945`,palette:[`#282828`,`#CC241D`,`#98971A`,`#D79921`,`#458588`,`#B16286`,`#689D6A`,`#A89984`,`#928374`,`#FB4934`,`#B8BB26`,`#FABD2F`,`#83A598`,`#D3869B`,`#8EC07C`,`#EBDBB2`]},{id:`solarized-dark`,name:`Solarized Dark`,codeTheme:`solarized-dark`,background:`#002B36`,foreground:`#839496`,cursor:`#839496`,selectionBackground:`#073642`,palette:[`#073642`,`#DC322F`,`#859900`,`#B58900`,`#268BD2`,`#D33682`,`#2AA198`,`#EEE8D5`,`#002B36`,`#CB4B16`,`#586E75`,`#657B83`,`#839496`,`#6C71C4`,`#93A1A1`,`#FDF6E3`]},{id:`github-dark`,name:`GitHub Dark`,codeTheme:`github-dark`,background:`#0D1117`,foreground:`#E6EDF3`,cursor:`#E6EDF3`,selectionBackground:`#264F78`,palette:[`#484F58`,`#FF7B72`,`#3FB950`,`#D29922`,`#58A6FF`,`#BC8CFF`,`#39C5CF`,`#B1BAC4`,`#6E7681`,`#FFA198`,`#56D364`,`#E3B341`,`#79C0FF`,`#D2A8FF`,`#56D4DD`,`#FFFFFF`]},{id:`rose-pine`,name:`Rosé Pine`,codeTheme:`rose-pine`,background:`#191724`,foreground:`#E0DEF4`,cursor:`#E0DEF4`,selectionBackground:`#403D52`,palette:[`#26233A`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`,`#6E6A86`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`]}];function fI(){let e=Z().prefs.theme,t=dI.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t}function pI(){let e=Q(e=>e.prefs.theme),t=dI.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t.codeTheme}function mI(){let e=fI(),t=document.documentElement.style;t.setProperty(`--bg`,e.background),t.setProperty(`--text`,e.foreground),t.setProperty(`--blue`,e.palette[4]),t.setProperty(`--danger`,e.palette[1]),t.setProperty(`--green`,e.palette[2]),t.setProperty(`--yellow`,e.palette[3]),document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.background)}function hI(e){let[t,n]=(0,F.useState)(null),r=pI();return(0,F.useEffect)(()=>{let t=!0;return ke(async()=>{let{getSharedHighlighter:e}=await import(`./dist-BYXo5M-b.js`);return{getSharedHighlighter:e}},__vite__mapDeps([7,8,1])).then(({getSharedHighlighter:t})=>t({themes:[r],langs:[e.language],preferredHighlighter:`shiki-wasm`}).then(t=>({highlighter:t,lang:e.language})).catch(()=>t({themes:[r],langs:[`text`],preferredHighlighter:`shiki-wasm`}).then(e=>({highlighter:e,lang:`text`})))).then(({highlighter:t,lang:n})=>t.codeToHast(e.code,{lang:n,themes:{light:r,dark:r},defaultColor:!1,transformers:[{pre(e){delete e.properties.style}}]})).then(e=>{t&&n((0,I.jsx)(`div`,{className:`chat-markdown-shiki`,children:Vw(e,{Fragment:F.Fragment,jsx:I.jsx,jsxs:I.jsxs})}))}).catch(e=>console.error(e)),()=>{t=!1}},[e.code,e.language,r]),t===null?(0,I.jsx)(`pre`,{children:(0,I.jsx)(`code`,{children:e.code})}):t}function gI(){let[e,t]=(0,F.useState)(!1);async function n(e){try{if(!window.isSecureContext)throw Error(`Copying needs https or localhost`);await navigator.clipboard.writeText(e),t(!0),setTimeout(()=>t(!1),1500)}catch(e){R9(e)}}return{copied:e,copy:n}}function _I(e){let t=(0,F.useRef)(null),[n,r]=(0,F.useState)(!0),i=gI(),a=n?`Collapse table cells`:`Expand table cells`,o=i.copied?`Copied`:`Copy table`;function s(e){let n=t.current;if(n===null)return;let r=[...n.rows].map(e=>[...e.cells].map(e=>(e.textContent??``).trim())),a=e===`markdown`?r.flatMap((e,t)=>{let n=`| ${e.map(e=>e.replaceAll(`|`,`\\|`)).join(` | `)} |`;return t===0?[n,`| ${e.map(()=>`---`).join(` | `)} |`]:[n]}).join(`
|
|
96
96
|
`):r.map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replaceAll(`"`,`""`)}"`:e).join(`,`)).join(`
|
|
97
97
|
`);i.copy(a)}return(0,I.jsxs)(`div`,{className:`chat-markdown-table-container`,"data-expanded":n,children:[(0,I.jsx)(`div`,{className:`chat-markdown-table-scroll`,children:(0,I.jsx)(`table`,{ref:t,children:e.children})}),(0,I.jsxs)(`div`,{className:`mt-0.5 flex items-center justify-between select-none`,children:[(0,I.jsx)(M,{label:a,children:(0,I.jsx)(x,{type:`button`,variant:n?`secondary`:`ghost-muted`,size:`icon-xs`,"aria-pressed":n,"aria-label":a,onClick:()=>{let e=t.current;if(e!==null&&!n){let t=[];for(let n of e.rows)[...n.cells].forEach((e,n)=>{t[n]=Math.max(t[n]??0,e.getBoundingClientRect().width)});[...e.tHead?.rows[0]?.cells??[]].forEach((e,n)=>{e.style.minWidth=`${t[n]}px`})}r(!n)},children:(0,I.jsx)(w,{icon:n?E_:yee,className:`size-3`})})}),(0,I.jsxs)(yC,{children:[(0,I.jsx)(M,{label:o,children:(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsx)(x,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":o,children:(0,I.jsx)(w,{icon:i.copied?qg:l_,className:`size-3`})})})}),(0,I.jsxs)(SC,{align:`end`,children:[(0,I.jsx)(CC,{onSelect:()=>s(`markdown`),children:`Copy as Markdown`}),(0,I.jsx)(CC,{onSelect:()=>s(`csv`),children:`Copy as CSV`})]})]})]})]})}function vI(e){let[t,n]=(0,F.useState)(e.open),r=F.Children.toArray(e.children),i=r.findIndex(e=>(0,F.isValidElement)(e)&&e.type===`summary`),a=r[i];return(0,I.jsxs)(`div`,{className:`border-border/60 my-2 border-y`,children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":t,className:`text-foreground flex w-full items-center gap-2 py-2 text-left text-sm font-medium`,onClick:()=>n(!t),children:[(0,I.jsx)(w,{icon:Xg,"aria-hidden":!0,className:P(`text-muted-foreground size-4 shrink-0 transition-transform`,t&&`rotate-90`)}),(0,I.jsx)(`span`,{children:(0,F.isValidElement)(a)&&a.props.children!==void 0?a.props.children:`Details`})]}),t&&(0,I.jsx)(`div`,{className:`text-foreground/80 ps-6 pb-3`,children:r.filter((e,t)=>t!==i)})]})}var yI=(0,F.lazy)(async()=>({default:(await ke(async()=>{let{VideoViewer:e}=await import(`./video-viewer-DAKoRaNT.js`);return{VideoViewer:e}},__vite__mapDeps([9,1,6,3,4,10,11]))).VideoViewer}));function bI(e){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(null),a=e.alt===``?e.name:e.alt;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,"aria-label":`Play ${a}`,className:P(`group focus-visible:ring-ring border-border/40 relative inline-block cursor-pointer overflow-hidden rounded-lg border bg-black align-top outline-none focus-visible:ring-2`,e.className),onClick:()=>n(!0),children:[(0,I.jsx)(`video`,{src:`${e.src}#t=0.001`,"aria-hidden":!0,tabIndex:-1,muted:!0,playsInline:!0,preload:`metadata`,className:`pointer-events-none block size-full object-contain`,onError:e.onError,onLoadedMetadata:e=>i(Number.isFinite(e.currentTarget.duration)?e.currentTarget.duration:null)}),(0,I.jsx)(`span`,{className:`absolute inset-0 grid place-items-center bg-black/10 transition-colors group-hover:bg-black/25`,children:(0,I.jsx)(`span`,{className:`grid size-12 place-items-center rounded-full bg-black/60 text-white backdrop-blur-sm transition-transform group-hover:scale-105`,children:(0,I.jsx)(w,{icon:F_,className:`size-5 translate-x-px fill-current`})})}),r!==null&&(0,I.jsx)(`span`,{className:`text-2xs absolute right-2 bottom-2 rounded-md bg-black/60 px-1.5 py-0.5 font-mono text-white tabular-nums`,children:gw(r)})]}),t&&(0,I.jsx)(F.Suspense,{children:(0,I.jsx)(yI,{src:e.src,label:a,name:e.name,onClose:()=>n(!1)})})]})}var xI=new Map([[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.svg`,`image/svg+xml`],[`.mp4`,`video/mp4`],[`.m4v`,`video/mp4`],[`.webm`,`video/webm`],[`.mov`,`video/quicktime`],[`.mp3`,`audio/mpeg`],[`.wav`,`audio/wav`],[`.ogg`,`audio/ogg`],[`.opus`,`audio/ogg`],[`.m4a`,`audio/mp4`],[`.aac`,`audio/aac`],[`.flac`,`audio/flac`]]);function SI(e){let t=/\.[a-z0-9]+$/i.exec(e.split(/[?#]/)[0])?.[0],n=t===void 0?void 0:xI.get(t.toLowerCase());return n?.startsWith(`image/`)===!0?`image`:n?.startsWith(`video/`)===!0?`video`:n?.startsWith(`audio/`)===!0?`audio`:null}async function CI(e,t,n){let r=await L(e,`files.media`,{projectId:t,path:n});return`${wo(e)}/api/media?${new URLSearchParams({token:r})}`}async function wI(e,t){let n=await fetch(e);if(!n.ok)throw Error(await n.text());let r=URL.createObjectURL(await n.blob()),i=document.createElement(`a`);i.href=r,i.download=t.slice(t.lastIndexOf(`/`)+1),i.click(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}var wie=(0,F.lazy)(async()=>({default:(await ke(async()=>{let{AudioPlayer:e}=await import(`./audio-player-DPpDuqFI.js`);return{AudioPlayer:e}},__vite__mapDeps([12,1,4,11]))).AudioPlayer})),Tie={image:S_,video:zee,audio:wee},Eie={image:lee,video:Bee,audio:Iee},Die={image:`Image unavailable`,video:`Video unavailable`,audio:`Audio unavailable`};function Oie(e){let t=Q(e=>e.selection),n=gI(),[r,i]=(0,F.useState)(null);(0,F.useEffect)(()=>{if(t===null)return;let n=!0;async function r(e,t,r){try{let a=await CI(e,t,r);n&&i({path:r,src:a})}catch(e){n&&i({path:r,error:Oe(e)})}}return r(t.machine,t.projectId,e.path),()=>{n=!1}},[t,e.path]);let a=r!==null&&r.path===e.path?r:null;return a!==null&&`error`in a?(0,I.jsx)(EI,{kind:SI(e.path)??`image`,reason:a.error,raw:e.raw}):(0,I.jsxs)(`span`,{className:P(`border-border bg-muted/50 flex flex-col gap-1 rounded-xl border p-1`,SI(e.path)===`audio`&&`w-fit max-w-[min(100%,36rem)]`,SI(e.path)!==`audio`&&`w-1/2`),children:[(0,I.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1.5 pl-1.5 [contain:inline-size]`,children:[(0,I.jsx)(w,{icon:Tie[SI(e.path)??`image`],"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`text-2xs min-w-0 flex-1 truncate font-mono`,title:e.path,children:e.path}),(0,I.jsx)(M,{label:n.copied?`Copied`:`Copy path`,children:(0,I.jsx)(x,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":`Copy path`,onClick:()=>void n.copy(e.path),children:(0,I.jsx)(w,{icon:n.copied?qg:l_,className:`size-3`})})}),(0,I.jsx)(M,{label:`Download`,children:(0,I.jsx)(x,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":`Download`,disabled:a===null,onClick:()=>{if(a===null)throw Error(`media is still loading`);wI(a.src,e.path).catch(R9)},children:(0,I.jsx)(w,{icon:f_,className:`size-3`})})})]}),a!==null&&(0,I.jsx)(TI,{src:a.src,alt:e.alt,name:e.path,kind:SI(e.path)??`image`,raw:e.raw}),a===null&&SI(e.path)!==`audio`&&(0,I.jsx)(`span`,{className:`border-border/40 block aspect-[3/2] w-full rounded-lg border`})]})}function TI(e){let[t,n]=(0,F.useState)(null);return t===e.src?(0,I.jsx)(EI,{kind:e.kind,reason:`It could not be loaded`,raw:e.raw}):e.kind===`video`?(0,I.jsx)(bI,{src:e.src,alt:e.alt,name:e.name,className:`block aspect-[3/2] w-full`,onError:()=>n(e.src)}):e.kind===`audio`?(0,I.jsx)(F.Suspense,{children:(0,I.jsx)(wie,{src:e.src,label:e.alt===``?e.name:e.alt,className:`flex w-[28rem] max-w-full`,onError:()=>n(e.src)})}):(0,I.jsx)(aw,{src:e.src,alt:e.alt,name:e.name,className:`border-border/40 block aspect-[3/2] w-full overflow-hidden rounded-lg border`,imageClassName:`size-full object-contain`,onError:()=>n(e.src)})}function EI(e){return(0,I.jsxs)(`span`,{className:`border-border/70 text-muted-foreground flex w-fit max-w-full flex-col gap-1 rounded-lg border border-dashed px-3 py-2 text-xs`,children:[(0,I.jsxs)(`span`,{className:`flex items-start gap-1.5`,children:[(0,I.jsx)(w,{icon:Eie[e.kind],"aria-hidden":!0,className:`mt-px size-3.5 shrink-0`}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`span`,{className:`text-foreground/80 font-medium`,children:Die[e.kind]}),` · ${e.reason}`]})]}),(0,I.jsx)(`span`,{className:`text-2xs font-mono break-all opacity-80`,children:e.raw})]})}var kie={note:{label:`Note`,icon:uee,border:`border-blue-500/70`,title:`text-blue-600 dark:text-blue-400`},tip:{label:`Tip`,icon:hee,border:`border-emerald-500/70`,title:`text-emerald-600 dark:text-emerald-400`},important:{label:`Important`,icon:See,border:`border-purple-500/70`,title:`text-purple-600 dark:text-purple-400`},warning:{label:`Warning`,icon:Fee,border:`border-amber-500/70`,title:`text-amber-600 dark:text-amber-500`},caution:{label:`Caution`,icon:Eee,border:`border-red-500/70`,title:`text-red-600 dark:text-red-400`}},Aie={...WM,attributes:{...WM.attributes,blockquote:[...WM.attributes?.blockquote??[],`dataAlert`]},protocols:{...WM.protocols,href:[...WM.protocols?.href??[],`file`]}},DI=new Set;function OI(){return e=>{function t(e){e.children?.forEach(t),jie(e)}t(e)}}function jie(e){if(e.type!==`blockquote`)return;let t=e.children?.[0],n=t?.children?.[0];if(t?.type!==`paragraph`||n?.type!==`text`||typeof n.value!=`string`)return;let r=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\](?:\r?\n|$)/i.exec(n.value);if(r===null)return;let i=n.value.slice(r[0].length);if(i.length>0)n.value=i;else if(r[0].endsWith(`
|
|
98
98
|
`)||t.children?.length===1)t.children?.shift(),t.children?.length===0&&e.children?.shift();else return;e.data={...e.data,hProperties:{...e.data?.hProperties,dataAlert:r[1].toLowerCase()}}}var Mie={blockquote({node:e,children:t}){let n=e?.properties.dataAlert,r=n===`note`||n===`tip`||n===`important`||n===`warning`||n===`caution`?kie[n]:null;return r===null?(0,I.jsx)(`blockquote`,{children:t}):(0,I.jsxs)(`div`,{role:`note`,className:P(`my-1 border-l-2 pl-3`,r.border),children:[(0,I.jsxs)(`p`,{className:P(`flex items-center gap-1.5 font-medium`,r.title),children:[(0,I.jsx)(w,{icon:r.icon,"aria-hidden":!0,className:`size-3.5 shrink-0`}),r.label]}),t]})},ol({node:e,start:t,children:n}){let r=e?.children.filter(e=>e.type===`element`&&e.tagName===`li`).length??0,i=t??1,a=Math.max(String(i).length,String(i+Math.max(r-1,0)).length);return(0,I.jsx)(`ol`,{start:t,ref:e=>{e!==null&&a>1&&e.style.setProperty(`--list-gutter`,`${a+2}ch`)},children:n})},a({node:e,href:t,children:n}){let r=Pie(t);if(r!==null)return(0,I.jsx)(`a`,{href:t,onClick:e=>{e.preventDefault(),BC(r)},children:n});let i=Fie(t);if(i===null)return(0,I.jsx)(`a`,{href:t,children:n});let a=e?.children.every(e=>e.type===`text`)?e.children.map(e=>e.type===`text`?e.value:``).join(``):``;return(0,I.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:a===``?n:(0,I.jsx)(Iie,{host:i,text:a})})},table({children:e}){return(0,I.jsx)(_I,{children:e})},details({open:e,children:t}){return(0,I.jsx)(vI,{open:e===!0,children:t})},img({src:e,alt:t}){return typeof e==`string`?e.startsWith(`/`)&&!e.startsWith(`//`)||e.startsWith(`./`)?(0,I.jsx)(Oie,{path:decodeURI(e),alt:t??``,raw:``}):(0,I.jsx)(`span`,{className:P(`block`,SI(e)!==`audio`&&`w-1/2`),children:(0,I.jsx)(TI,{src:e,alt:t??``,name:e.startsWith(`data:`)?`Image`:e.split(/[?#]/)[0],kind:SI(e)??`image`,raw:``})}):null},pre({node:e,children:t}){let n=e?.children[0];if(n?.type!==`element`||n.tagName!==`code`)return(0,I.jsx)(`pre`,{children:t});let r=n.children.map(e=>e.type===`text`?e.value:``).join(``),i=n.properties.className,a=Array.isArray(i)?i.map(String).find(e=>e.startsWith(`language-`))?.slice(9):void 0;return(0,I.jsx)(Rie,{code:r.replace(/\n$/,``),language:a===`gitignore`?`ini`:a??`text`})}},kI=(0,F.memo)(Nie);function Nie(e){return(0,I.jsx)(`div`,{className:P(`chat-markdown text-foreground w-full min-w-0 text-sm leading-relaxed [overflow-wrap:anywhere] [word-break:break-word]`,e.className),"data-streaming":e.streaming===!0?``:void 0,children:(0,I.jsx)(XD,{remarkPlugins:e.lineBreaks===!0?[uI,OI,hN]:[uI,OI],rehypePlugins:e.rawHtml===!1?[]:[HM,[sN,Aie]],components:Mie,urlTransform:e=>e.startsWith(`file:`)?e:eO(e),children:e.text})})}function Pie(e){if(e===void 0||e===``||e.startsWith(`#`)||e.startsWith(`//`))return null;if(e.startsWith(`file:`))return e;if(!/^[a-z]:[\\/]/i.test(e)&&/^[a-z][a-z0-9+.-]*:/i.test(e))return null;try{return decodeURI(e)}catch{return e}}function Fie(e){if(e===void 0||!/^https?:\/\//i.test(e))return null;try{return new URL(e).host}catch{return null}}function Iie(e){let t=/^https?:\/\//i.exec(e.text)?.[0].length??Math.min(e.text.length,1);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`whitespace-nowrap`,children:[(0,I.jsx)(Lie,{host:e.host}),e.text.slice(0,t)]}),Array.from(e.text.slice(t),(e,t)=>(0,I.jsxs)(`span`,{children:[e,(0,I.jsx)(`wbr`,{})]},t))]})}function Lie(e){let[t,n]=(0,F.useState)(DI.has(e.host)),r=e.host.toLowerCase(),i=r===`github.com`||r.endsWith(`.github.com`);return(0,I.jsx)(`span`,{className:`ms-[0.25em] me-[0.2em] inline-flex size-[14px] [vertical-align:-0.125em]`,"aria-hidden":!0,children:i?(0,I.jsx)(w,{icon:iee,className:`block size-full shrink-0 select-none`}):t?(0,I.jsx)(w,{icon:aee,className:`block size-full shrink-0 select-none`}):(0,I.jsx)(`img`,{src:`https://${e.host}/favicon.ico`,alt:``,loading:`lazy`,draggable:!1,className:`block size-full shrink-0 rounded-sm select-none`,onError:()=>{DI.add(e.host),n(!0)}})})}function Rie(e){let[t,n]=(0,F.useState)(!0),r=gI(),i=t?`Disable line wrap`:`Wrap lines`,a=r.copied?`Copied`:`Copy code`;return(0,I.jsxs)(`div`,{className:`chat-markdown-codeblock border-border/70 bg-secondary dark:bg-input/32 my-[0.65rem] overflow-hidden rounded-lg border leading-snug dark:border-transparent`,"data-language":e.language,"data-wrap":t,children:[(0,I.jsxs)(`div`,{className:`chat-markdown-codeblock-header flex items-center justify-between gap-2 pt-1.5 pr-1.5 pb-0 pl-3 select-none`,children:[(0,I.jsx)(`span`,{className:`text-2xs inline-flex min-w-0 items-center gap-1.5 font-mono`,children:ce(e.language)?(0,I.jsx)(M,{label:e.language,children:(0,I.jsx)(`span`,{className:`inline-flex shrink-0 rounded-sm`,"aria-label":`Language: ${e.language}`,children:(0,I.jsx)(be,{path:le(e.language),className:`size-3.5`})})}):(0,I.jsx)(`span`,{className:`truncate`,children:e.language})}),(0,I.jsxs)(`span`,{className:`flex items-center gap-0.5`,role:`toolbar`,children:[(0,I.jsx)(M,{label:i,children:(0,I.jsx)(x,{type:`button`,variant:t?`secondary`:`ghost-muted`,size:`icon-xs`,"aria-pressed":t,"aria-label":i,onClick:()=>n(!t),children:(0,I.jsx)(w,{icon:Z_,className:`size-3`})})}),(0,I.jsx)(M,{label:a,children:(0,I.jsx)(x,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":a,onClick:()=>void r.copy(e.code),children:(0,I.jsx)(w,{icon:r.copied?qg:l_,className:`size-3`})})})]})]}),(0,I.jsx)(hI,{code:e.code,language:e.language})]})}var AI=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r)setTimeout(function(){r(e)},0);else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h)d[r]=void 0;else{if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},zie=new class extends AI{};function Bie(e,t,n){return zie.diff(e,t,n)}function jI(e,t){let n=0;for(;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function MI(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function NI(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function PI(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function FI(e,t){return NI(e,t,``)}function II(e,t){return PI(e,t,``)}function LI(e,t){return t.slice(0,Vie(e,t))}function Vie(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function RI(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function zI(e,t){if(t)return VI(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function BI(e,t){if(t)return VI(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function VI(e,t){if(!t)return[BI(e),zI(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=RI(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var HI=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,Hie=RegExp(`[${HI}]+|\\s+|[^${HI}]`,`ug`);new class extends AI{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=RI(e,r)}else n=e.match(Hie)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&UI(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&UI(n,i,r,null,t.intlSegmenter),e}};function UI(e,t,n,r,i){if(t&&n){let[a,o]=VI(t.value,i),[s,c]=VI(n.value,i);if(e){let r=jI(a,s);e.value=PI(e.value,s,r),t.value=FI(t.value,r),n.value=FI(n.value,r)}if(r){let e=MI(o,c);r.value=NI(r.value,c,e),t.value=II(t.value,e),n.value=II(n.value,e)}}else if(n){if(e){let e=BI(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=BI(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=BI(r.value,i),[a,o]=VI(t.value,i),s=jI(n,a);t.value=FI(t.value,s);let c=MI(FI(n,s),o);t.value=II(t.value,c),r.value=NI(r.value,n,c),e.value=PI(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=BI(r.value,i),n=LI(zI(t.value,i),e);t.value=II(t.value,n)}else if(e){let n=LI(zI(e.value,i),BI(t.value,i));t.value=FI(t.value,n)}}var Uie=new class extends AI{tokenize(e){let t=RegExp(`(\\r?\\n)|[${HI}]+|[^\\S\\n\\r]+|[^${HI}]`,`ug`);return e.match(t)||[]}};function Wie(e,t,n){return Uie.diff(e,t,n)}var Gie=new class extends AI{constructor(){super(...arguments),this.tokenize=GI}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
@@ -108,8 +108,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
108
108
|
`),n=e.split(`
|
|
109
109
|
`).map(e=>e+`
|
|
110
110
|
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function ZI(e){let t=e.item;switch(t.kind){case`file_change`:return(0,I.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.diffs.map((e,t)=>(0,I.jsx)(Qie,{before:e.before,after:e.after},t))});case`todo_list`:return(0,I.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:t.steps.map((e,t)=>(0,I.jsxs)(`li`,{className:P(`text-secondary-label`,e.status===`completed`&&`text-muted-foreground line-through`,e.status===`running`&&`text-foreground`),children:[e.status===`completed`?`☑`:`☐`,` `,e.text]},t))});case`plan`:return(0,I.jsx)(kI,{text:t.plan});case`tool`:return QI(t.name)===`other`?(0,I.jsx)(Zie,{text:JSON.stringify(t.input,null,2)}):null;default:return null}}function Xie(e,t){switch(e.kind){case`command`:return e.command;case`file_change`:return nL(e.path,t);case`web_search`:return e.url??e.query??``;case`subagent`:return e.description;case`skill`:return e.skill;case`tool`:{let n=QI(e.name);return n===`read`?nL($I(e.input),t):n===`search`?tL(e.input.pattern):``}default:return``}}function QI(e){switch(e.toLowerCase()){case`read`:return`read`;case`grep`:case`glob`:return`search`;default:return`other`}}function $I(e){return[e.file_path,e.filePath,e.path].map(tL).find(e=>e!==``)??``}function eL(e){let t=0,n=0;for(let r of e.diffs)for(let e of WI(r.before,r.after))e.added&&(t+=e.count),e.removed&&(n+=e.count);return{added:t,removed:n}}function Zie(e){return(0,I.jsx)(`pre`,{className:`text-foreground/80 text-2xs max-h-64 overflow-auto font-mono leading-relaxed whitespace-pre-wrap`,children:e.text})}function Qie(e){return(0,I.jsx)(`pre`,{className:`border-border/60 text-2xs max-h-80 overflow-auto rounded-md border font-mono leading-relaxed`,children:WI(e.before,e.after).flatMap((e,t)=>e.value.replace(/\n$/,``).split(`
|
|
111
|
-
`).map((n,r)=>(0,I.jsxs)(`div`,{className:P(`px-2 whitespace-pre-wrap`,e.added&&`bg-diff-addition/10 text-diff-addition`,e.removed&&`bg-diff-deletion/10 text-diff-deletion`,!e.added&&!e.removed&&`text-muted-foreground`),children:[e.added?`+`:e.removed?`-`:` `,` `,n]},`${t}:${r}`)))})}function tL(e){return typeof e==`string`?e:``}function nL(e,t){return e.startsWith(t+`/`)?e.slice(t.length+1):e}var rL=`(Recommended)`;function iL(e){let t=e.options.map(e=>e.label).filter(e=>e.endsWith(rL));return e.multiSelect?t:t.slice(0,1)}function aL(e){return(0,I.jsxs)(`span`,{className:P(`mt-0.5 grid size-4 shrink-0 place-items-center border transition-colors`,e.multi?`rounded`:`rounded-full`,e.selected&&`border-primary bg-primary text-primary-foreground`,e.suggested&&`border-primary border-dashed`,!e.selected&&!e.suggested&&`border-muted-foreground/40`),children:[e.selected&&e.multi&&(0,I.jsx)(w,{icon:qg,strokeWidth:3,className:`size-3`}),e.selected&&!e.multi&&(0,I.jsx)(`span`,{className:`bg-primary-foreground size-1.5 rounded-full`})]})}function oL(e){let[t,n]=(0,F.useState)(Date.now);(0,F.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.ceil((e.at-t)/1e3));return(0,I.jsxs)(`span`,{className:`text-muted-foreground text-2xs mr-1 tabular-nums`,children:[e.label,` in`,` `,r<60?`${r}s`:`${Math.ceil(r/60)}m`]})}var $ie=`composer-glass relative mx-auto -mb-[calc(1rem+1px)] w-[calc(100%-2.75rem)] rounded-t-2xl border border-b-0 px-1 pt-1 pb-[calc(1rem+1px+0.25rem)] text-xs/4`;function eae(e){let t=e.request;if(t.kind===`question`)return(0,I.jsx)(tae,{machine:e.machine,request:t,draft:e.draft});let n=t.kind===`plan`,r=n?``:Xie(t.item,e.cwd);return(0,I.jsx)(`div`,{className:P($ie,`border-warning/28 bg-linear-to-b from-warning/8 to-warning/8`),children:(0,I.jsxs)(`div`,{className:`grid grid-cols-[1.5rem_minmax(0,1fr)_auto] items-start gap-x-2 gap-y-3 px-1 py-1`,children:[(0,I.jsx)(`span`,{className:`text-warning flex justify-center pt-0.5`,children:(0,I.jsx)(w,{icon:K_,className:`size-4`})}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,I.jsxs)(`span`,{className:`text-muted-foreground text-2xs flex w-full min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-warning shrink-0 font-medium`,children:n?`Ready to code?`:t.title}),e.count>1&&(0,I.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums`,children:[`1/`,e.count]})]}),r!==``&&(0,I.jsx)(`span`,{className:`text-foreground block max-h-20 w-full min-w-0 overflow-auto font-mono text-xs whitespace-pre`,children:r})]}),(0,I.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[t.autoResolve!==void 0&&(0,I.jsx)(oL,{label:t.autoResolve.decision===`allow`?`Approve`:`Decline`,at:t.autoResolve.at}),(0,I.jsx)(x,{size:`xs`,variant:`outline`,onClick:()=>ZC(t.id,`deny`,null),children:n?`Keep planning`:`Decline`}),t.kind===`approval`&&t.canAlwaysAllow&&(0,I.jsx)(x,{size:`xs`,variant:`outline`,onClick:()=>ZC(t.id,`always`,null),children:`Always`}),(0,I.jsx)(x,{size:`xs`,onClick:()=>ZC(t.id,`allow`,null),children:n?`Approve plan`:`Approve`})]}),n&&(0,I.jsx)(`div`,{className:`col-span-3 max-h-60 overflow-auto px-1 empty:hidden`,children:(0,I.jsx)(kI,{text:t.plan})}),t.kind===`approval`&&t.item.kind!==`command`&&(0,I.jsx)(`div`,{className:`col-span-3 max-h-60 overflow-auto px-1 empty:hidden`,children:(0,I.jsx)(ZI,{item:t.item})})]})})}function tae(e){let t=e.request.questions,[n,r]=(0,F.useState)(0),[i,a]=(0,F.useState)({}),[o,s]=(0,F.useState)({}),c=Object.fromEntries(t.map(e=>[e.question,[...i[e.question]??[],o[e.question]?.trim()??``].filter(e=>e!==``)])),l=Object.fromEntries(t.map(e=>[e.question,(c[e.question].length>0?c[e.question]:iL(e)).join(`, `)])),u=t[n],d=t.flatMap((e,t)=>c[e.question].length===0?[t]:[]),f=d.find(e=>e>n)??d[0];function p(e,c){let l=i[e.question]??[];e.multiSelect?a({...i,[e.question]:l.includes(c)?l.filter(e=>e!==c):[...l,c]}):(a({...i,[e.question]:[c]}),s({...o,[e.question]:``}),n<t.length-1&&r(n+1))}function m(e,t){s({...o,[e.question]:t}),!e.multiSelect&&t.trim()!==``&&a({...i,[e.question]:[]})}async function h(t,n){let r=sw(Z().items,[e.draft,...Object.values(o)]);for(let i of n)try{let n=await NC(e.machine,i),o=n;i.type.startsWith(`image/`)&&(r+=1,o=`[Image #${r}] (saved at ${n})`),s(e=>{let n=e[t.question]??``;return{...e,[t.question]:`${n}${/(^|\s)$/.test(n)?``:` `}${o}`}}),t.multiSelect||a(e=>({...e,[t.question]:[]}))}catch(e){R9(e)}}return(0,I.jsx)(`div`,{className:`composer-glass shadow-composer relative z-10 rounded-3xl border border-(--composer-outline)`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 p-2.5`,children:[(0,I.jsxs)(`div`,{role:`tabpanel`,className:`flex min-w-0 flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-start gap-1.5 pt-1 pr-1 pl-1.5`,children:[(0,I.jsx)(`span`,{className:`bg-primary/18 text-primary grid size-6 shrink-0 place-items-center rounded-md`,children:(0,I.jsx)(w,{icon:xee,className:`size-4`})}),(0,I.jsx)(`p`,{className:`text-foreground min-w-0 flex-1 pt-0.5 text-[15px] leading-5 font-medium`,children:u.question}),(0,I.jsx)(x,{size:`icon-xs`,variant:`ghost`,"aria-label":`Skip questions`,title:`Skip questions`,onClick:()=>ZC(e.request.id,`deny`,null),children:(0,I.jsx)(w,{icon:re})})]}),(0,I.jsxs)(`div`,{role:u.multiSelect?`group`:`radiogroup`,"aria-label":u.question,className:`flex max-h-[min(18rem,32dvh)] flex-col gap-0.5 overflow-y-auto`,children:[u.options.map(e=>{let t=i[u.question]?.includes(e.label)===!0,n=c[u.question].length===0&&iL(u).includes(e.label),r=e.label.endsWith(rL);return(0,I.jsxs)(`button`,{role:u.multiSelect?`checkbox`:`radio`,"aria-checked":t,className:P(`flex cursor-pointer items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors`,t?`bg-muted/70`:`hover:bg-muted/40`),onClick:()=>p(u,e.label),children:[(0,I.jsx)(aL,{multi:u.multiSelect,selected:t,suggested:n}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`text-foreground text-sm`,children:r?e.label.slice(0,-13).trim():e.label}),r&&(0,I.jsx)(`span`,{className:`text-muted-foreground/70 text-[11px]`,children:`Recommended`})]}),e.description!==``&&(0,I.jsx)(`span`,{className:`text-secondary-label mt-0.5 block text-xs leading-4`,children:e.description})]})]},e.label)}),(0,I.jsxs)(`label`,{className:P(`flex cursor-text items-start gap-2.5 rounded-lg px-2.5 py-2 transition-colors`,(o[u.question]??``).trim()===``?`focus-within:bg-muted/40 hover:bg-muted/40`:`bg-muted/70`),children:[(0,I.jsx)(aL,{multi:u.multiSelect,selected:(o[u.question]??``).trim()!==``,suggested:!1}),(0,I.jsx)(`textarea`,{value:o[u.question]??``,rows:1,onChange:e=>m(u,e.target.value),onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);if(t!==``){e.preventDefault(),document.execCommand(`insertText`,!1,t);return}let n=[...e.clipboardData.files];n.length!==0&&(e.preventDefault(),h(u,n))},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),h(u,[...e.dataTransfer.files])},placeholder:`Something else…`,className:`placeholder:text-placeholder/75 [field-sizing:content] max-h-40 min-w-0 flex-1 resize-none bg-transparent text-sm leading-5 outline-none`})]})]})]},u.question),(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t.length>1&&(0,I.jsx)(`div`,{role:`tablist`,className:`flex min-w-0 [scrollbar-width:none] gap-1 overflow-x-auto`,children:t.map((e,t)=>(0,I.jsxs)(`button`,{role:`tab`,"aria-selected":t===n,className:P(`flex h-6 shrink-0 cursor-pointer items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,t===n?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`),onClick:()=>r(t),children:[c[e.question].length>0&&(0,I.jsx)(w,{icon:Jg,"aria-label":`Answered`,className:`text-success size-3.5`}),c[e.question].length===0&&l[e.question]!==``&&(0,I.jsx)(w,{icon:e_,"aria-label":`Using the recommended answer`,className:`text-primary size-3.5`}),l[e.question]===``&&(0,I.jsx)(w,{icon:oee,"aria-label":`Not answered`,className:`text-muted-foreground size-3.5`}),e.header]},e.question))}),(0,I.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5 pr-1`,children:[e.request.autoResolve!==void 0&&(0,I.jsx)(oL,{label:`Skip`,at:e.request.autoResolve.at}),(0,I.jsx)(x,{size:`xs`,variant:`outline`,onClick:()=>ZC(e.request.id,`allow`,{}),children:`Skip`}),(0,I.jsx)(x,{size:`xs`,variant:f===void 0?`default`:`outline`,onClick:()=>ZC(e.request.id,`allow`,Object.fromEntries(t.flatMap(e=>c[e.question].length===0?[]:[[e.question,c[e.question].join(`, `)]]))),children:`Submit`}),f!==void 0&&(0,I.jsx)(x,{size:`xs`,onClick:()=>{c[u.question].length===0&&a({...i,[u.question]:iL(u)}),r(f)},children:`Next`})]})]})]})})}function sL({...e}){return(0,I.jsx)(Fx,{"data-slot":`popover`,...e})}function cL({...e}){return(0,I.jsx)(Lx,{"data-slot":`popover-trigger`,...e})}function lL({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,I.jsx)(Vx,{children:(0,I.jsx)(Ux,{"data-slot":`popover-content`,sideOffset:n,align:t,className:P(`z-50 origin-(--radix-popover-content-transform-origin) overflow-hidden rounded-lg dropdown-glass text-popover-foreground shadow-[0_16px_40px_-18px_rgb(0_0_0/55%)] outline-none dark:shadow-[0_18px_44px_-18px_rgb(0_0_0/80%)] duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}var uL=`relative inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap rounded-(--control-radius) border border-transparent outline-none hover:bg-accent data-[state=open]:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-64 [&_svg]:pointer-events-none [&_svg]:shrink-0`,dL=`h-7 gap-1.5 px-1.5 text-sm sm:px-2.5 font-medium text-secondary-label hover:text-foreground [&_svg:not([class*=text-])]:text-muted-foreground [&_svg:not([class*=size-])]:size-4`;function nae(){let e=Q(e=>e.settings),t=Q(e=>e.capabilities)?.models.find(t=>t.value===e.model);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(rae,{}),(0,I.jsx)(`span`,{className:`bg-border mx-0.5 hidden h-4 w-px shrink-0 sm:block`}),t!==void 0&&t.efforts.length>0&&(0,I.jsx)(iae,{title:`Effort`,trigger:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(w,{icon:Bg}),(0,I.jsx)(`span`,{className:`capitalize`,children:e.effort??`Default`})]}),value:e.effort??`default`,options:[...e.provider===`opencode`?[{value:`default`,label:`Default`}]:[],...t.efforts.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))],onChange:e=>J9({effort:e==="default"?null:e})})]})}function rae(){let e=Q(e=>e.settings),t=Q(e=>e.selection),n=Q(e=>e.machines.find(t=>t.id===e.selection?.machine)),r=[...[...n?.claudeAccounts??[],...n?.codexAccounts??[]].filter(e=>e.valid).map(e=>({key:e.id,provider:e.provider,accountId:e.id,name:e.name,color:e.color,plan:e.plan,error:e.error})),...n?.openCode.available===!0?[{key:`opencode`,provider:`opencode`,accountId:null,name:`OpenCode`,color:null,plan:null,error:null}]:[]].filter(n=>t?.sessionId===null||n.provider===e.provider),i=e.provider===`opencode`?`opencode`:e.accountId,a=Q(e=>e.capabilities),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(i),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)({}),m=(0,F.useRef)(null),h=a?.models.find(t=>t.value===e.model)?.name??e.model??`Choose a model`,g=r.find(e=>e.key===i),_=c===null?[]:c===i?a?.models??null:f[c]??null,v=r.find(e=>e.key===c)?.provider,y=(_??[]).filter(e=>!e.hidden),b=y.length>=5,x=b?u.trim().toLowerCase():``,S=y.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(x));function C(e){if(s(e),e&&(l(i),d(``),t!==null))for(let e of r)e.key!==i&&e.error===null&&L(t.machine,`capabilities`,{provider:e.provider,accountId:e.accountId,projectId:t.projectId}).then(t=>p(n=>({...n,[e.key]:t.models})),R9)}function T(n,i){let a=r.find(e=>e.key===n);if(a===void 0||t===null)return;let o=a.provider,s={accountId:a.accountId,model:i.value,...i.effort===null?{}:{effort:i.effort}};o===e.provider?J9(s):J9({...q9(T9(Z(),t.machine).composer,o),...s})}return(0,I.jsxs)(sL,{open:o,onOpenChange:C,children:[(0,I.jsx)(cL,{asChild:!0,children:(0,I.jsxs)(`button`,{className:P(uL,dL),title:g===void 0?`Model`:`${g.name} · ${h}`,children:[(0,I.jsxs)(`span`,{className:`relative`,children:[(0,I.jsx)(zv,{provider:e.provider,className:`size-4`}),r.filter(t=>t.provider===e.provider).length>1&&g!==void 0&&g.color!==null&&(0,I.jsx)(`span`,{className:`border-card pointer-events-none absolute -right-1 -bottom-1 flex h-3 min-w-3 items-center justify-center rounded-full border px-0.5 text-[8px] leading-none font-semibold text-white shadow-sm`,style:{backgroundColor:g.color},children:g.name.charAt(0).toUpperCase()})]}),(0,I.jsx)(`span`,{className:`max-w-40 truncate`,children:h})]})}),(0,I.jsxs)(lL,{side:`top`,className:`flex max-h-86.5 w-screen max-w-90 flex-row`,onOpenAutoFocus:e=>{e.preventDefault(),m.current?.focus()},onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-composer]`)?.focus()},children:[r.length>1&&(0,I.jsxs)(`div`,{className:`bg-muted/30 flex w-11 shrink-0 [scrollbar-width:none] flex-col gap-1 overflow-y-auto p-1`,children:[r.map(t=>(0,I.jsxs)(`div`,{className:`relative w-full`,children:[t.key===c&&(0,I.jsx)(`div`,{className:`bg-primary pointer-events-none absolute top-1/2 -right-1 z-10 h-5 w-0.75 -translate-y-1/2 rounded-l-full`}),(0,I.jsx)(M,{side:`left`,label:t.error===null?[t.name,t.plan].filter(e=>e!==null).join(` · `):`${t.name} — ${t.error}`,children:(0,I.jsxs)(`button`,{className:P(`hover:bg-foreground/10 focus-visible:bg-foreground/10 relative flex aspect-square w-full cursor-pointer items-center justify-center rounded-md transition-colors focus-visible:outline-none`,t.error!==null&&`cursor-not-allowed opacity-50 hover:bg-transparent`),"aria-label":t.name,"aria-pressed":t.key===c,"aria-disabled":t.error!==null,onClick:()=>{if(t.error!==null)return;let n=f[t.key]?.find(t=>t.value===e.model);t.key!==i&&i!==null&&a!==null&&n!==void 0&&(p(e=>({...e,[i]:a.models})),T(t.key,n)),l(t.key)},children:[(0,I.jsx)(zv,{provider:t.provider,className:`size-5`}),r.filter(e=>e.provider===t.provider).length>1&&t.color!==null&&(0,I.jsx)(`span`,{className:`border-card text-3xs pointer-events-none absolute right-0.5 bottom-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full border px-0.5 leading-none font-semibold text-white shadow-sm`,style:{backgroundColor:t.color},children:t.name.charAt(0).toUpperCase()})]})})]},t.key)),(0,I.jsx)(M,{side:`left`,label:`Manage accounts`,children:(0,I.jsx)(`button`,{className:`text-muted-foreground hover:bg-foreground/10 hover:text-foreground focus-visible:bg-foreground/10 mt-auto flex aspect-square w-full shrink-0 cursor-pointer items-center justify-center rounded-md transition-colors focus-visible:outline-none`,"aria-label":`Manage accounts`,onClick:()=>{s(!1),I9(C9[e.provider])},children:(0,I.jsx)(w,{icon:Ree,className:`size-4.5`})})})]}),(0,I.jsxs)(`div`,{className:P(`bg-muted/40 flex min-h-0 min-w-0 flex-1 flex-col`,r.length>1&&`border-border/70 border-l`),children:[b&&(0,I.jsx)(`div`,{className:`shrink-0 px-3 pt-2.5`,children:(0,I.jsxs)(`div`,{className:`border-border/70 focus-within:border-ring relative border-b pb-1.5 transition-colors`,children:[(0,I.jsx)(w,{icon:H_,className:`text-muted-foreground/55 pointer-events-none absolute top-1.5 left-0 size-4`}),(0,I.jsx)(`input`,{ref:m,value:u,placeholder:`Search models...`,className:`placeholder:text-muted-foreground/70 h-6.5 w-full bg-transparent ps-5 text-sm outline-none`,onChange:e=>d(e.target.value),onKeyDown:e=>{if(e.key!==`Enter`||c===null)return;let t=S.at(0);t!==void 0&&(e.preventDefault(),T(c,t),s(!1))}})]})}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 py-1.5`,children:S.length===0?(0,I.jsx)(`p`,{className:`text-muted-foreground p-2 text-center text-sm`,children:_===null?`Loading models…`:`No models found`}):S.map(t=>(0,I.jsx)(`button`,{className:P(`hover:bg-accent hover:text-accent-foreground mb-0.5 flex min-h-8 w-full cursor-pointer flex-col justify-center rounded-sm px-2 py-1.5 text-left`,c===i&&t.value===e.model&&`text-foreground bg-foreground/[0.08]`),onClick:()=>{c!==null&&(T(c,t),s(!1))},children:(0,I.jsxs)(`span`,{className:`truncate text-sm leading-snug font-medium`,children:[t.name,v===`opencode`&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-2 text-xs font-normal`,children:t.description})]})},t.value))})]})]})]})}function iae(e){return(0,I.jsxs)(yC,{children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsx)(`button`,{className:P(uL,dL),title:e.title,children:e.trigger})}),(0,I.jsxs)(SC,{className:`w-72`,side:`top`,align:`start`,onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-composer]`)?.focus()},children:[(0,I.jsx)(DC,{children:e.title}),(0,I.jsx)(TC,{value:e.value,onValueChange:e.onChange,children:e.options.map(e=>(0,I.jsx)(EC,{value:e.value,children:e.label},e.value))})]})]})}function aae(e){let t=Q(e=>e.selection?.sessionId),n=Q(t=>E9(t,e.machine,e.projectId)),r=Q(e=>e.projects),i=Q(e=>e.machines);return(0,I.jsx)(`div`,{className:`absolute inset-x-0 bottom-full pb-4`,children:(0,I.jsxs)(`h1`,{className:`text-foreground w-full text-center text-2xl font-normal tracking-tight sm:text-3xl`,children:[`What should we build in`,` `,t===null?(0,I.jsxs)(yC,{children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`border-muted-foreground/35 hover:border-foreground/60 inline-flex max-w-64 cursor-pointer border-b border-dotted align-bottom outline-none`,title:n?.path,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:n?.name}),`?`]})}),(0,I.jsx)(SC,{className:`max-h-80 w-64`,onCloseAutoFocus:t=>{t.preventDefault(),e.onCloseMenu()},children:(0,I.jsx)(TC,{value:f9(e.machine,e.projectId),children:[...r].sort((e,t)=>i.findIndex(t=>t.id===e.machine)-i.findIndex(e=>e.id===t.machine)||e.name.localeCompare(t.name)).map(e=>(0,I.jsxs)(EC,{value:f9(e.machine,e.id),title:e.path,onSelect:()=>WC({machine:e.machine,projectId:e.id,sessionId:null}),children:[(0,I.jsx)(Lv,{machine:e.machine,projectId:e.id,className:`size-4 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.name,i.length>1&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-1.5 text-xs`,children:i.find(t=>t.id===e.machine)?.name})]})]},f9(e.machine,e.id)))})})]}):(0,I.jsx)(`span`,{className:`border-muted-foreground/35 inline-block max-w-64 truncate border-b border-dotted align-bottom`,title:n?.path,children:n?.name}),t!==null&&`?`]})})}function oae(){let e=Q(e=>e.queue);return(0,I.jsx)(`div`,{className:`composer-glass relative mx-auto -mb-[calc(1rem+1px)] w-[calc(100%-2.75rem)] rounded-t-2xl border border-b-0 border-(--composer-outline) px-1 pt-1 pb-[calc(1rem+1px+0.25rem)] text-xs/4`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`grid min-h-6 grid-cols-[1.5rem_minmax(0,1fr)_auto_auto] items-center gap-x-1`,children:[(0,I.jsx)(w,{icon:vee,className:`text-muted-foreground mx-auto size-3`}),(0,I.jsx)(`span`,{className:`text-secondary-label truncate`,children:e.prompt.text===``?`${e.prompt.images.length} image(s)`:e.prompt.text}),(0,I.jsx)(x,{variant:`ghost-muted`,size:`icon-xs`,title:`Send now`,onClick:()=>JC(e.id),children:(0,I.jsx)(w,{icon:Rg})}),(0,I.jsx)(x,{variant:`ghost-muted`,size:`icon-xs`,title:`Remove from queue`,onClick:()=>qC(e.id),children:(0,I.jsx)(w,{icon:re})})]},e.id))})}function sae(e){return(0,I.jsxs)(I.Fragment,{children:[e.running&&e.empty&&(0,I.jsx)(`button`,{className:`bg-destructive/90 shadow-destructive/24 hover:bg-destructive flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-full text-white shadow-xs transition-colors`,title:`Stop (Esc)`,"aria-label":`Stop generation`,onClick:e.onStop,children:(0,I.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,I.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})}),!(e.running&&e.empty)&&(0,I.jsx)(`button`,{className:`bg-message-action text-message-action-foreground shadow-message-action/24 hover:bg-message-action-hover relative flex size-9 items-center justify-center overflow-hidden rounded-full shadow-xs transition-all duration-150 hover:scale-105 enabled:cursor-pointer disabled:pointer-events-none disabled:opacity-64 disabled:shadow-none`,title:e.running&&e.delivery===`steer`?`Send now (Enter) · Queue (${Te}+Enter)`:e.running?`Queue (Enter) · Send now (${Te}+Enter)`:`Send (Enter)`,"aria-label":`Send message`,disabled:e.empty,onClick:t=>e.onSubmit(t.metaKey||t.ctrlKey),children:(0,I.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`M7 11.5V2.5M7 2.5L3 6.5M7 2.5L11 6.5`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})})]})}var cae=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],lae=5242880,fL=window.matchMedia(`(pointer: coarse)`);function pL(){let e=Q(e=>e.selection),t=Q(e=>e.loaded),n=Q(e=>e.items.length===0&&e.partial===``),r=Q(e=>e.requests),i=Q(e=>e.queue),a=Q(e=>e.draft),o=Q(e=>e.capabilities),s=Q(e=>e.settings.provider===`opencode`?e.machines.find(t=>t.id===e.selection?.machine)?.openCode.available!==!0:e.settings.accountId===null),[c,l]=(0,F.useState)(0),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(0),[m,h]=(0,F.useState)(!1),[g,_]=(0,F.useState)([]),v=(0,F.useRef)(null),y=(0,F.useRef)(null),b=e?.machine??``,S=e?.projectId??``,C=Q(e=>E9(e,b,S)),T=Q(e=>T9(e,b).status),E=Q(e=>T9(e,b).config?.delivery??null),D=f9(b,e?.sessionId??S),O=zs(D),k=O.text,A=O.images,[ee,j]=(0,F.useState)(k.length),M=Q(j9),te=t&&n&&!M,ne=r.at(0);(0,F.useEffect)(()=>{let e=v.current;e===null||fL.matches||(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[e]),(0,F.useEffect)(()=>{if(a===null)return;let e=cw(a);Bs(D,t=>({...t,...e})),j(e.text.length),N9(null),v.current?.focus()},[a,D]),(0,F.useEffect)(()=>{T===`online`&&L(b,`files.list`,{projectId:S}).then(_,R9)},[b,S,T]);let re=k.slice(0,ee),ie=/^\/\S*$/.exec(re)?.[0]??/(?:^|\s)(@\S*)$/.exec(re)?.[1]??null,ae=ie?.slice(1).toLowerCase()??``,oe=ie===null||m?[]:ie.startsWith(`/`)?(o?.commands??[]).filter(e=>e.name.toLowerCase().includes(ae)).sort((e,t)=>Number(!e.name.toLowerCase().startsWith(ae))-Number(!t.name.toLowerCase().startsWith(ae))).map(e=>({key:e.name,label:`/${e.name}${e.hint===``?``:` ${e.hint}`}`,description:e.description,insert:`/${e.name}`})):g.filter(e=>e.toLowerCase().includes(ae)).slice(0,50).map(e=>({key:e,label:e,description:``,insert:`@${e}`})),se=Math.min(f,oe.length-1),ce=k.trim()===``&&A.length===0||c>0||u||s;function le(e,t){Bs(D,t=>({...t,text:e,images:t.images.filter(t=>e.includes(`[Image #${t.number}]`))})),j(t),p(0),h(!1)}function ue(e){if(ie===null)return;let t=ee-ie.length,n=t+e.insert.length+1;le(`${k.slice(0,t)}${e.insert} ${k.slice(ee)}`,n),requestAnimationFrame(()=>v.current?.setSelectionRange(n,n))}async function de(e){if(!ce){d(!0);try{if(E===null)throw Error(`This machine is not connected`);await KC({text:k.trim(),images:A.map(e=>({mediaType:e.mediaType,data:e.data}))},e?E===`queue`?`steer`:`queue`:E),Bs(D,e=>({...e,text:``,images:[]})),j(0)}catch(e){R9(e)}finally{d(!1)}}}async function fe(e){let t=ee,n=/(^|\s)$/.test(k.slice(0,ee))?``:` `;for(let r of e)if(cae.includes(r.type)&&r.size<=lae){let e=await PC(r),i=sw(Z().items,[Hs(D).text])+1,a={number:i,mediaType:r.type,data:e},o=t,s=`${n}[Image #${i}] `;n=``,Bs(D,e=>({...e,text:`${e.text.slice(0,o)}${s}${e.text.slice(o)}`,images:[...e.images,a]})),t+=s.length,j(t),requestAnimationFrame(()=>v.current?.setSelectionRange(t,t))}else{l(e=>e+1);try{let e=await NC(b,r);Bs(D,t=>({...t,text:`${t.text}${/(^|\s)$/.test(t.text)?``:` `}@${e} `}))}catch(e){R9(e)}finally{l(e=>e-1)}}}return(0,I.jsx)(`div`,{className:P(`pointer-events-none z-20`,te?`absolute inset-0 flex items-center pb-3 sm:pb-4`:`relative shrink-0 before:absolute before:right-(--app-scrollbar-width) before:bottom-full before:left-0 before:h-8 before:bg-linear-to-t before:from-background before:to-transparent`),children:(0,I.jsxs)(FC,{width:`composer`,className:`pointer-events-auto relative z-10`,children:[te&&(0,I.jsx)(aae,{machine:b,projectId:S,onCloseMenu:()=>v.current?.focus()}),i.length>0&&oe.length===0&&(0,I.jsx)(oae,{}),ne!==void 0&&oe.length===0&&(0,I.jsx)(eae,{request:ne,machine:b,cwd:C?.path??``,count:r.length,draft:k},ne.id),oe.length>0&&(0,I.jsx)(lw,{items:oe,active:se,onHover:p,onPick:ue}),(0,I.jsxs)(`div`,{className:P(`composer-glass shadow-composer relative z-10 border border-(--composer-outline) transition-[border-color,box-shadow] duration-300 ease-out focus-within:border-[color-mix(in_srgb,var(--text)_16%,transparent)] focus-within:ring-4 focus-within:ring-[color-mix(in_srgb,var(--text)_4%,transparent)] dark:shadow-none`,te?`rounded-3xl`:`rounded-t-3xl border-b-0`,ne?.kind===`question`&&`hidden`),onMouseDown:e=>{e.target instanceof Element&&e.currentTarget.contains(e.target)&&(e.target.closest(`button, a, input, textarea`)||(e.preventDefault(),v.current?.focus()))},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),fe([...e.dataTransfer.files])},children:[(0,I.jsxs)(`div`,{className:P(`pb-2`,A.length>0&&`pt-3.5 sm:pt-4`),children:[A.length>0&&(0,I.jsx)(ow,{draftKey:D}),(0,I.jsx)(`textarea`,{ref:v,"data-composer":!0,rows:1,spellCheck:!1,autoCorrect:`off`,"data-gramm":`false`,"data-gramm_editor":`false`,"data-enable-grammarly":`false`,"data-lt-active":`false`,value:k,onChange:e=>le(e.target.value,e.target.selectionStart),onSelect:e=>j(e.currentTarget.selectionStart),onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);if(t!==``){e.preventDefault(),document.execCommand(`insertText`,!1,t);return}let n=[...e.clipboardData.files];n.length!==0&&(e.preventDefault(),fe(n))},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(oe.length>0){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;p((se+t+oe.length)%oe.length);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),ue(oe[se]);return}if(e.key===`Escape`){e.preventDefault(),h(!0);return}}if(e.key===`Enter`&&!e.shiftKey&&!fL.matches)e.preventDefault(),de(e.metaKey||e.ctrlKey);else if(e.key===`ArrowUp`&&k===``){let t=uae(Z().items);if(t===null)return;e.preventDefault(),le(t,t.length)}else e.key===`Escape`&&M&&YC()}},placeholder:s?`Add an account in Settings to start`:M&&E===`steer`?`Steer the agent… (${Te}+Enter to queue)`:M?`Queue a follow-up… (${Te}+Enter to send now)`:`Ask anything, @tag files/folders, or / for commands`,className:P(`placeholder:text-placeholder/75 block [field-sizing:content] w-full resize-none bg-transparent px-3 text-sm leading-relaxed outline-none sm:px-4`,A.length>0?`max-h-52 min-h-19.5`:`max-h-55.5 min-h-20 pt-3.5 sm:max-h-56 sm:pt-4 [@media(min-height:840px)]:min-h-23 sm:[@media(min-height:840px)]:min-h-23.5`)})]}),(0,I.jsxs)(`div`,{className:P(`flex min-w-0 items-center justify-between gap-2 px-3 sm:px-4`,te?`pb-3 sm:pb-4`:`pb-2.5 sm:pb-3.5`),children:[(0,I.jsx)(`div`,{className:`-m-1 -ms-3.5 flex min-w-0 flex-1 [scrollbar-width:none] items-center gap-1 overflow-x-auto p-1 ps-2`,children:(0,I.jsx)(nae,{})}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[(0,I.jsx)(`input`,{ref:y,type:`file`,multiple:!0,hidden:!0,onChange:e=>{fe([...e.target.files??[]]),e.target.value=``}}),c>0&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Uploading…`}),(0,I.jsx)(yw,{empty:ce,delivery:E,onSubmit:()=>void de(!0)}),(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:`Attach files`,"aria-label":`Attach files`,onClick:()=>y.current?.click(),children:(0,I.jsx)(w,{icon:A_})}),(0,I.jsx)(sae,{running:M,empty:ce,delivery:E,onSubmit:e=>void de(e),onStop:YC})]})]})]})]})})}function uae(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.kind===`user`&&n.parent===null&&n.format===`text`&&n.text!==``)return n.text}return null}var dae=window.matchMedia(`(pointer: coarse)`);function fae(e){let[t,n]=(0,F.useState)(!1),r=gL(e.repo);return(0,I.jsxs)(sL,{open:t,onOpenChange:n,children:[(0,I.jsx)(cL,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`text-muted-foreground hover:text-foreground hidden max-w-48 cursor-pointer items-center gap-1 text-xs sm:flex`,title:`Switch or create a branch`,children:[(0,I.jsx)(w,{icon:r===null?b_:r.icon,className:`size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.repo.branch??`detached`})]})}),(0,I.jsx)(lL,{align:`end`,className:`flex max-h-86.5 w-72 flex-col`,children:(0,I.jsx)(mL,{target:e,onClose:()=>n(!1)})})]})}function pae(e){return(0,I.jsx)(_e,{open:!0,onOpenChange:e.onClose,children:(0,I.jsxs)(ae,{showCloseButton:!1,"aria-describedby":void 0,className:`flex max-h-[min(30rem,calc(100dvh-2rem))] flex-col gap-0 p-0`,onOpenAutoFocus:e=>{dae.matches&&e.preventDefault()},children:[(0,I.jsx)(pe,{className:`sr-only`,children:`Switch branch`}),(0,I.jsx)(mL,{target:e,onClose:e.onClose})]})})}function mL(e){let t=e.target,n=t.machine,r=t.projectId,i=t.repo.path,a=t.onRefresh,[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(!1),g=gL(t.repo),_=u.trim(),v=(o??[]).filter(e=>e.toLowerCase().includes(_.toLowerCase())),y=(c??[]).filter(e=>e.toLowerCase().includes(_.toLowerCase())),b=(o??[]).includes(_);(0,F.useEffect)(()=>{L(n,`git.localBranches`,{projectId:r,repo:i}).then(s,R9),L(n,`git.fetch`,{projectId:r}).then(a,R9)},[n,r,i,a]);async function x(){h(!0);try{await L(n,`git.sync`,{projectId:r,repo:i}),e.onClose()}catch(e){R9(e)}finally{h(!1),a()}}async function S(t,o){p(!0);try{await L(n,`git.switch`,{projectId:r,repo:i,branch:t,create:o}),e.onClose()}catch(e){R9(e)}finally{p(!1),a()}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`shrink-0 px-3 pt-2.5`,children:(0,I.jsxs)(`div`,{className:`border-border/70 focus-within:border-ring relative border-b pb-1.5 transition-colors`,children:[(0,I.jsx)(w,{icon:H_,className:`text-muted-foreground/55 pointer-events-none absolute top-1.5 left-0 size-4`}),(0,I.jsx)(`input`,{value:u,placeholder:`Search or create a branch...`,disabled:f,className:`placeholder:text-muted-foreground/70 h-6.5 w-full bg-transparent ps-5 text-sm outline-none`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_!==``&&o!==null&&(e.preventDefault(),S(_,!b))}})]})}),g!==null&&(0,I.jsx)(`div`,{className:`border-border/70 shrink-0 border-b px-2 py-1.5`,children:(0,I.jsxs)(`button`,{disabled:m||f,className:`hover:bg-accent hover:text-accent-foreground flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,onClick:()=>void x(),children:[(0,I.jsx)(w,{icon:m?e_:g.icon,className:P(`size-3.5 shrink-0`,m&&`animate-spin`)}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g.label}),(0,I.jsx)(hL,{behind:t.repo.behind,ahead:t.repo.ahead})]})}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 py-1.5`,children:[o===null&&(0,I.jsx)(`p`,{className:`text-muted-foreground p-2 text-center text-sm`,children:`Loading branches…`}),o!==null&&v.length===0&&_===``&&(0,I.jsx)(`p`,{className:`text-muted-foreground p-2 text-center text-sm`,children:`No branches`}),v.map(n=>(0,I.jsxs)(`button`,{disabled:f,className:P(`hover:bg-accent hover:text-accent-foreground mb-0.5 flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,n===t.repo.branch&&`text-foreground bg-foreground/[0.08]`),onClick:()=>{n===t.repo.branch?e.onClose():S(n,!1)},children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),n===t.repo.branch&&(0,I.jsx)(w,{icon:qg,strokeWidth:2.25,className:`size-3.5 shrink-0`})]},n)),c!==null&&y.length>0&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-2 pt-2 pb-1 text-xs font-medium`,children:`Remote`}),y.map(e=>(0,I.jsx)(`button`,{disabled:f,className:`hover:bg-accent hover:text-accent-foreground mb-0.5 flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,onClick:()=>void S(e.slice(e.indexOf(`/`)+1),!1),children:(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})},e)),o!==null&&_!==``&&!b&&(0,I.jsxs)(`button`,{disabled:f,className:`hover:bg-accent hover:text-accent-foreground flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,onClick:()=>void S(_,!0),children:[(0,I.jsx)(w,{icon:E,className:`size-3.5 shrink-0`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`Create branch `,(0,I.jsx)(`span`,{className:`font-medium`,children:_})]})]})]}),(0,I.jsx)(`div`,{className:`border-border/70 shrink-0 border-t px-2 py-1.5`,children:(0,I.jsxs)(`button`,{className:`text-muted-foreground hover:bg-accent hover:text-accent-foreground flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm`,onClick:()=>{c===null?L(n,`git.remoteBranches`,{projectId:r,repo:i}).then(l,R9):l(null)},children:[(0,I.jsx)(w,{icon:r_,className:`size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c===null?`Show remote branches`:`Hide remote branches`})]})})]})}function hL(e){return(0,I.jsxs)(I.Fragment,{children:[e.behind>0&&(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`↓`,e.behind]}),e.ahead>0&&(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`↑`,e.ahead]})]})}function gL(e){return e.branch===null||!e.remote?null:e.upstream===null?{icon:i_,label:`Publish branch`}:e.behind>0&&e.ahead>0?{icon:jg,label:`Pull and push`}:e.behind>0?{icon:Ng,label:`Pull commits`}:e.ahead>0?{icon:Rg,label:`Push commits`}:null}var mae={working:e_,done:$g,failed:kg},_L=new Set,vL=null,yL=0;function bL(e){vL=e;for(let e of _L)e();e?.state===`done`&&setTimeout(()=>{vL?.id===e.id&&bL(null)},5e3)}function hae(e){return _L.add(e),()=>{_L.delete(e)}}function xL(e,t){yL+=1,bL(`url`in t?{id:yL,state:`done`,label:e,error:``,url:t.url}:{id:yL,state:`failed`,label:e,error:t.error,url:null})}async function SL(e){yL+=1;let t=yL;bL({id:t,state:`working`,label:e.labels.working,error:``,url:null});try{let n=await e.task();vL?.id===t&&bL({id:t,state:`done`,label:e.labels.done,error:``,url:n})}catch(n){vL?.id===t&&bL({id:t,state:`failed`,label:e.labels.failed,error:Oe(n),url:null})}finally{e.onRefresh()}}function CL(e,t,n,r){SL({labels:r?{working:`Committing and pushing…`,done:`Committed and pushed`,failed:`Commit and push failed`}:{working:`Committing…`,done:`Committed`,failed:`Commit failed`},task:async()=>(await L(e.machine,`git.commit`,{projectId:e.projectId,repo:t,message:n,push:r}),null),onRefresh:e.onRefresh})}function gae(e,t,n){SL({labels:{working:`Creating pull request…`,done:`Pull request created`,failed:`Couldn't create pull request`},task:async()=>(await L(e.machine,`git.createPullRequest`,{projectId:e.projectId,repo:t,base:n.base,head:n.head,title:n.title,body:n.body})).url,onRefresh:e.onRefresh})}function _ae(){let e=(0,F.useSyncExternalStore)(hae,()=>vL),[t,n]=(0,F.useState)(!1);return e===null?null:(0,I.jsxs)(`div`,{className:`bg-popover text-popover-foreground flex max-w-80 items-center gap-3 rounded-md border py-2 pr-2 pl-3 shadow-md`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,I.jsx)(w,{icon:mae[e.state],className:P(`size-4 shrink-0`,e.state===`working`&&`animate-spin`,e.state===`done`&&`text-success`,e.state===`failed`&&`text-destructive`)}),(0,I.jsx)(`span`,{className:`truncate`,children:e.label})]}),e.url!==null&&(0,I.jsx)(x,{asChild:!0,size:`xs`,variant:`outline`,children:(0,I.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open`})}),e.state===`failed`&&(0,I.jsx)(x,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>n(!0),children:`View`}),(0,I.jsx)(x,{type:`button`,size:`icon-micro`,variant:`ghost-muted`,"aria-label":`Dismiss`,onClick:()=>{n(!1),bL(null)},children:(0,I.jsx)(w,{icon:re,className:`size-3.5`})}),(0,I.jsx)(_e,{open:t&&e.state===`failed`,onOpenChange:n,children:(0,I.jsxs)(ae,{className:`sm:max-w-lg`,children:[(0,I.jsx)(se,{children:(0,I.jsx)(pe,{children:e.label})}),(0,I.jsx)(`pre`,{className:`bg-muted/50 max-h-[60vh] overflow-y-auto rounded-lg border p-3 font-mono text-xs break-words whitespace-pre-wrap`,children:e.error})]})})]})}function wL({className:e,type:t,...n}){return(0,I.jsx)(`input`,{type:t,"data-slot":`input`,className:P(`h-9 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-[color,background-color,border-color,box-shadow] duration-200 ease-out outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/33 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function TL({...e}){return(0,I.jsx)(mS,{"data-slot":`select`,...e})}function EL({...e}){return(0,I.jsx)(vS,{"data-slot":`select-value`,...e})}function DL({className:e,size:t=`default`,children:n,...r}){return(0,I.jsxs)(gS,{"data-slot":`select-trigger`,"data-size":t,className:P(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-[color,background-color,border-color,box-shadow] duration-200 ease-out outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/33 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,I.jsx)(yS,{asChild:!0,children:(0,I.jsx)(w,{icon:Q_,className:`text-muted-foreground pointer-events-none size-4`})})]})}function OL({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,I.jsx)(SS,{children:(0,I.jsxs)(wS,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:P(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,I.jsx)(vae,{}),(0,I.jsx)(IS,{"data-position":n,className:P(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,I.jsx)(yae,{})]})})}function kL({className:e,children:t,...n}){return(0,I.jsxs)(BS,{"data-slot":`select-item`,className:P(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,I.jsx)(WS,{children:(0,I.jsx)(w,{icon:qg,className:`pointer-events-none`})})}),(0,I.jsx)(HS,{children:t})]})}function vae({className:e,...t}){return(0,I.jsx)(KS,{"data-slot":`select-scroll-up-button`,className:P(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(w,{icon:Zg})})}function yae({className:e,...t}){return(0,I.jsx)(JS,{"data-slot":`select-scroll-down-button`,className:P(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(w,{icon:Yg})})}function AL(e){return e.target?.kind===`failed`?(0,I.jsx)(`span`,{className:`text-destructive truncate text-xs`,children:e.target.text}):(0,I.jsxs)(`span`,{className:`text-muted-foreground flex min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsxs)(`span`,{className:`truncate`,children:[e.head,` →`]}),(0,I.jsxs)(TL,{value:e.target?.base??``,disabled:e.target===void 0,onValueChange:e.onBase,children:[(0,I.jsx)(DL,{size:`sm`,className:`max-w-48`,children:(0,I.jsx)(EL,{placeholder:`Loading branches…`})}),(0,I.jsx)(OL,{children:(e.target?.branches??[]).map(e=>(0,I.jsx)(kL,{value:e,children:e},e))})]})]})}function bae(e){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 ps-6`,children:[(0,I.jsxs)(`span`,{className:`text-muted-foreground truncate text-xs`,children:[e.draft.head,` → `,e.draft.base]}),(0,I.jsx)(wL,{value:e.draft.title,onChange:t=>e.onChange({...e.draft,title:t.target.value})}),(0,I.jsx)(`textarea`,{value:e.draft.body,onChange:t=>e.onChange({...e.draft,body:t.target.value}),rows:8,className:`bg-background focus-visible:border-ring focus-visible:ring-ring/33 w-full resize-y rounded-lg border px-3 py-2 font-mono text-xs transition-[border-color,box-shadow] duration-200 ease-out outline-none focus-visible:ring-3`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[e.onSkip!==null&&(0,I.jsx)(x,{variant:`ghost`,size:`sm`,onClick:e.onSkip,children:`Skip`}),(0,I.jsx)(x,{variant:`outline`,size:`sm`,onClick:e.onRegenerate,children:`Regenerate`}),(0,I.jsx)(x,{size:`sm`,disabled:e.draft.title.trim()===``,onClick:e.onCreate,children:`Create PR`})]})]})}var xae={working:e_,review:t_,done:$g,failed:kg,skipped:Cee};function Sae(e){let t=Q(t=>E9(t,e.machine,e.projectId)?.name)??``,[n]=(0,F.useState)(()=>jL(e.repos,e.action)),[r,i]=(0,F.useState)(()=>n.map(e=>e.path)),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)({}),[l,u]=(0,F.useState)(null),d=n.filter(e=>r.includes(e.path)&&s[e.path]?.kind!==`failed`),f=e.action===`pullRequest`&&d.some(e=>s[e.path]===void 0),p=d.filter(e=>e.changed>0);(0,F.useEffect)(()=>{if(e.action===`pullRequest`)for(let t of n)L(e.machine,`git.branches`,{projectId:e.projectId,repo:t.path}).then(e=>c(n=>({...n,[t.path]:{kind:`ready`,...e}})),e=>c(n=>({...n,[t.path]:{kind:`failed`,text:Oe(e)}})))},[e.machine,e.projectId,e.action,n]);function m(e,t){u(n=>n?.map(n=>n.path===e?{...n,...t}:n)??null)}async function h(t,r){try{await r()}catch(r){if(n.length===1){e.onClose(),xL(`Pull request failed`,{error:Oe(r)});return}m(t,{state:`failed`,text:Oe(r),draft:null})}finally{e.onRefresh()}}function g(e,t){c(n=>{let r=n[e];return r?.kind===`ready`?{...n,[e]:{...r,base:t}}:n})}function _(e,t){u(d.map(t=>({path:t.path,state:`working`,text:e,url:null,draft:null})));for(let e of d)h(e.path,()=>t(e.path))}function v(t){if(n.length===1){e.onClose(),CL(e,n[0].path,a,t);return}let r=t?`Committed and pushed`:`Committed`;_(t?`Committing and pushing…`:`Committing…`,async n=>{await L(e.machine,`git.commit`,{projectId:e.projectId,repo:n,message:a,push:t}),m(n,{state:`done`,text:r})})}function y(){_(`Pushing…`,async t=>{await L(e.machine,`git.push`,{projectId:e.projectId,repo:t}),m(t,{state:`done`,text:`Pushed`})})}async function b(t,r,i){m(t,{state:`working`,text:r?`Committing local changes and writing pull request…`:`Writing pull request…`,draft:null});let a=await L(e.machine,`git.pullRequest`,{projectId:e.projectId,repo:t,base:i,commit:r});if(a.kind===`open`){if(n.length===1){e.onClose(),xL(`Pull request already open`,{url:a.url});return}m(t,{state:`done`,text:`A pull request is already open`,url:a.url})}else m(t,{state:`review`,text:`Review and create`,draft:{base:a.base,head:a.head,title:a.title,body:a.body}})}function S(e){_(`Starting…`,async t=>{let n=s[t];if(n?.kind!==`ready`)throw Error(`The branches are not loaded`);await b(t,e&&p.some(e=>e.path===t),n.base)})}function C(t,r){n.length===1?(e.onClose(),gae(e,t,r)):h(t,async()=>{m(t,{state:`working`,text:`Creating pull request…`,draft:null}),m(t,{state:`done`,text:`Created pull request`,url:(await L(e.machine,`git.createPullRequest`,{projectId:e.projectId,repo:t,base:r.base,head:r.head,title:r.title,body:r.body})).url})})}return(0,I.jsx)(_e,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(ae,{className:`top-[12vh] translate-y-0 sm:max-w-lg`,children:[(0,I.jsxs)(se,{children:[(0,I.jsxs)(pe,{children:[e.action===`commit`&&`Commit changes`,e.action===`push`&&`Push`,e.action===`pullRequest`&&`Create pull request`]}),(0,I.jsxs)(ge,{children:[e.action===`commit`&&(n.length===1?`Stages every change and commits it.`:`Stages every change in the selected repositories and commits it.`),e.action===`push`&&`Pushes the selected repositories to their remote.`,e.action===`pullRequest`&&`AI writes the title and description. You review them before the pull request is created.`]})]}),l===null&&(0,I.jsxs)(I.Fragment,{children:[n.length===1&&(0,I.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-1.5 text-xs`,children:[e.action===`pullRequest`?(0,I.jsx)(AL,{head:n[0].branch??`detached`,target:s[n[0].path],onBase:e=>g(n[0].path,e)}):n[0].branch??`detached`,(0,I.jsxs)(`span`,{className:`shrink-0`,children:[`· `,n[0].changed,` `,n[0].changed===1?`change`:`changes`]})]}),n.length>1&&(0,I.jsx)(`div`,{className:`flex max-h-60 flex-col gap-0.5 overflow-y-auto`,children:n.map(n=>(0,I.jsxs)(`label`,{className:`hover:bg-accent flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5`,children:[(0,I.jsx)(`input`,{type:`checkbox`,disabled:s[n.path]?.kind===`failed`,checked:r.includes(n.path)&&s[n.path]?.kind!==`failed`,onChange:e=>i(e.target.checked?[...r,n.path]:r.filter(e=>e!==n.path))}),(0,I.jsx)(`span`,{className:`truncate font-medium`,children:ML(n.path,t)}),e.action===`pullRequest`?(0,I.jsx)(AL,{head:n.branch??`detached`,target:s[n.path],onBase:e=>g(n.path,e)}):(0,I.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,children:n.branch??`detached`}),(0,I.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0 text-xs tabular-nums`,children:e.action===`push`?n.upstream===null?`not pushed yet`:`↑${n.ahead}`:n.changed>0&&`${n.changed} ${n.changed===1?`change`:`changes`}`})]},n.path))}),e.action===`commit`&&(0,I.jsx)(`textarea`,{value:a,onChange:e=>o(e.target.value),placeholder:`Leave empty to write the message with AI`,rows:5,className:`bg-background focus-visible:border-ring focus-visible:ring-ring/33 w-full resize-none rounded-lg border px-3 py-2 font-mono text-xs transition-[border-color,box-shadow] duration-200 ease-out outline-none focus-visible:ring-3`}),e.action===`pullRequest`&&p.length>0&&(0,I.jsxs)(`p`,{children:[`You have local changes`,n.length>1&&` in ${p.map(e=>ML(e.path,t)).join(`, `)}`,`. Do you want to commit and push them before creating the pull request?`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[e.action===`commit`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(x,{variant:`outline`,size:`sm`,disabled:d.length===0,onClick:()=>v(!1),children:`Commit`}),(0,I.jsx)(x,{size:`sm`,disabled:d.length===0,onClick:()=>v(!0),children:`Commit and Push`})]}),e.action===`push`&&(0,I.jsx)(x,{size:`sm`,disabled:d.length===0,onClick:y,children:`Push`}),e.action===`pullRequest`&&p.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(x,{variant:`outline`,size:`sm`,disabled:f,onClick:()=>S(!1),children:`Continue without them`}),(0,I.jsx)(x,{size:`sm`,disabled:f,onClick:()=>S(!0),children:`Commit and continue`})]}),e.action===`pullRequest`&&p.length===0&&(0,I.jsx)(x,{size:`sm`,disabled:f||d.length===0,onClick:()=>S(!1),children:`Create pull request`})]})]}),l!==null&&(0,I.jsx)(`div`,{className:`flex max-h-[60vh] flex-col gap-2 overflow-y-auto`,children:l.map(e=>{let r=e.draft;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(`span`,{className:`mt-0.5 flex size-4 shrink-0 overflow-hidden`,children:(0,I.jsx)(w,{icon:xae[e.state],className:P(`size-4`,e.state===`working`&&`animate-spin`,e.state===`review`&&`text-info`,e.state===`done`&&`text-success`,e.state===`failed`&&`text-destructive`,e.state===`skipped`&&`text-muted-foreground`)})}),(0,I.jsx)(`span`,{className:`shrink-0 font-medium`,children:ML(e.path,t)}),(0,I.jsxs)(`span`,{className:P(`min-w-0 text-xs leading-5 break-words whitespace-pre-wrap`,e.state===`failed`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.url!==null&&(0,I.jsxs)(I.Fragment,{children:[` `,(0,I.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline hover:underline-offset-2`,children:e.url})]})]})]}),e.state===`review`&&r!==null&&(0,I.jsx)(bae,{draft:r,onChange:t=>m(e.path,{draft:t}),onSkip:n.length===1?null:()=>m(e.path,{state:`skipped`,text:`Skipped`,draft:null}),onRegenerate:()=>void h(e.path,()=>b(e.path,!1,r.base)),onCreate:()=>C(e.path,r)})]},e.path)})})]})})}function jL(e,t){if(t===`commit`)return e.filter(e=>e.changed>0);if(t===`push`)return e.filter(e=>e.branch!==null&&(e.upstream===null||e.ahead>0));if(t===`pullRequest`)return e.filter(e=>e.branch!==null);throw Error(`Unknown git action ${String(t)}`)}function ML(e,t){return e===``?t:e}var Cae=3e3,wae=18e4;function NL(e,t,n){let[r,i]=(0,F.useState)(null),[a,o]=(0,F.useState)(0);(0,F.useEffect)(()=>{if(t===null)return;let n=f9(e,t),r={projectId:t},a=!0,o=!1,s=!1;async function c(){if(!o){o=!0;try{let t=await L(e,`git.status`,r);if(!a)return;s=!1,i(e=>e!==null&&e.key===n&&Cs(e.repos,t)?e:{key:n,repos:t})}catch(e){a&&!s&&(s=!0,R9(e))}finally{o=!1}}}function l(){document.hidden||c()}c();let u=window.setInterval(l,Cae);return window.addEventListener(`focus`,l),()=>{a=!1,window.clearInterval(u),window.removeEventListener(`focus`,l)}},[e,t,n,a]),(0,F.useEffect)(()=>{if(t===null)return;let n={projectId:t},r=!0,i=!1;async function a(){if(!document.hidden)try{await L(e,`git.fetch`,n),r&&(i=!1,o(e=>e+1))}catch(e){r&&!i&&(i=!0,R9(e))}}a();let s=window.setInterval(a,wae);return()=>{r=!1,window.clearInterval(s)}},[e,t]);let s=(0,F.useCallback)(()=>o(e=>e+1),[]);return{repos:r!==null&&t!==null&&r.key===f9(e,t)?r.repos:[],refresh:s}}function PL(e){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(!1),l=jL(e.repos,`push`),u=jL(e.repos,`commit`);function d(t){SL({labels:{working:`Pushing…`,done:`Pushed`,failed:`Push failed`},task:async()=>(await L(e.machine,`git.push`,{projectId:e.projectId,repo:t}),null),onRefresh:e.onRefresh})}async function f(){if(u.length===1)i(!1),CL(e,u[0].path,``,!1);else{c(!0);try{for(let t of u)await L(e.machine,`git.commit`,{projectId:e.projectId,repo:t.path,message:``,push:!1});i(!1)}catch(e){R9(e)}finally{c(!1),e.onRefresh()}}}return{target:e,action:t,setAction:n,menuOpen:r,setMenuOpen:i,branchRepo:a,setBranchRepo:o,committing:s,pushable:l,committable:u,push:d,yoloCommit:f}}function FL(e){let t=e.git,n=t.target.repos,r=n.reduce((e,t)=>e+t.ahead,0);return(0,I.jsxs)(I.Fragment,{children:[e.collapsed&&n.map(e=>(0,I.jsxs)(CC,{onSelect:()=>t.setBranchRepo(e.path),children:[(0,I.jsx)(w,{icon:b_}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.path===``?e.branch??`detached`:`${e.path}: ${e.branch??`detached`}`}),(0,I.jsx)(`span`,{className:`text-muted-foreground flex gap-1 text-xs`,children:(0,I.jsx)(hL,{behind:e.behind,ahead:e.ahead})})]},e.path)),e.collapsed&&(0,I.jsx)(OC,{}),e.collapsed&&(0,I.jsxs)(CC,{disabled:t.committable.length===0,onSelect:()=>t.setAction(`commit`),children:[(0,I.jsx)(w,{icon:x_}),`Commit…`]}),(0,I.jsxs)(CC,{disabled:t.pushable.length===0||t.committing,onSelect:()=>{t.pushable.length===1?t.push(t.pushable[0].path):t.setAction(`push`)},children:[(0,I.jsx)(w,{icon:i_}),t.pushable.length>1?`Just Push…`:`Just Push`,r>0&&(0,I.jsxs)(`span`,{className:`text-muted-foreground ml-auto text-xs tabular-nums`,children:[`↑`,r]})]}),(0,I.jsxs)(CC,{disabled:t.committable.length===0||t.committing,onSelect:e=>{e.preventDefault(),t.yoloCommit()},children:[(0,I.jsx)(w,{icon:t.committing?e_:x_,className:P(t.committing&&`animate-spin`)}),t.committing?`Committing…`:`Yolo Commit`]}),(0,I.jsx)(OC,{}),(0,I.jsxs)(CC,{disabled:jL(n,`pullRequest`).length===0,onSelect:()=>t.setAction(`pullRequest`),children:[(0,I.jsx)(w,{icon:ree}),`Create pull request…`]})]})}function IL(e){let t=e.git,n=t.target.repos.find(e=>e.path===t.branchRepo);return(0,I.jsxs)(I.Fragment,{children:[t.action!==null&&(0,I.jsx)(Sae,{machine:t.target.machine,projectId:t.target.projectId,action:t.action,repos:t.target.repos,onClose:()=>t.setAction(null),onRefresh:t.target.onRefresh}),t.branchRepo!==null&&n!==void 0&&(0,I.jsx)(pae,{machine:t.target.machine,projectId:t.target.projectId,repo:n,onRefresh:t.target.onRefresh,onClose:()=>t.setBranchRepo(null)})]})}function Tae(e){let t=PL(e),[n,r]=(0,F.useState)(!1),i=[...new Set(e.repos.map(e=>e.branch??`detached`))],a=e.repos.flatMap(e=>{let t=gL(e);return t===null?[]:[{repo:e,next:t}]}),o=e.repos.map(e=>e.path===``?e.branch??`detached`:`${e.path}: ${e.branch??`detached`}`).join(`
|
|
112
|
-
`),s=i.length===1?i[0]:`${i.length} branches`;async function c(t){r(!0);try{await L(e.machine,`git.sync`,{projectId:e.projectId,repo:t})}catch(e){R9(e)}finally{r(!1),e.onRefresh()}}return(0,I.jsxs)(`div`,{className:`flex w-fit items-center gap-3.5`,children:[e.repos.length===1&&(0,I.jsx)(fae,{machine:e.machine,projectId:e.projectId,repo:e.repos[0],onRefresh:e.onRefresh}),e.repos.length>1&&a.length===0&&(0,I.jsxs)(`span`,{className:`text-muted-foreground hidden max-w-48 items-center gap-1 text-xs sm:flex`,title:o,children:[(0,I.jsx)(w,{icon:b_,className:`size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:s})]}),e.repos.length>1&&a.length>0&&(0,I.jsxs)(yC,{children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`text-muted-foreground hover:text-foreground hidden max-w-48 cursor-pointer items-center gap-1 text-xs sm:flex`,title:o,children:[(0,I.jsx)(w,{icon:n?e_:a.length===1?a[0].next.icon:jg,className:P(`size-3.5 shrink-0`,n&&`animate-spin`)}),(0,I.jsx)(`span`,{className:`truncate`,children:s})]})}),(0,I.jsx)(SC,{align:`end`,className:`w-64`,children:a.map(e=>(0,I.jsxs)(CC,{disabled:n,onSelect:()=>void c(e.repo.path),children:[(0,I.jsx)(w,{icon:e.next.icon}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.next.label,` ·`,` `,e.repo.path===``?e.repo.branch:e.repo.path]}),(0,I.jsx)(`span`,{className:`text-muted-foreground flex gap-1 text-xs`,children:(0,I.jsx)(hL,{behind:e.repo.behind,ahead:e.repo.ahead})})]},e.repo.path))})]}),(0,I.jsxs)(`div`,{className:`flex w-fit`,children:[(0,I.jsxs)(x,{variant:`outline`,size:`xs`,className:`rounded-e-none border-e-0`,disabled:t.committable.length===0,onClick:()=>t.setAction(`commit`),children:[(0,I.jsx)(w,{icon:x_}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:`Commit`})]}),(0,I.jsxs)(yC,{open:t.menuOpen,onOpenChange:t.setMenuOpen,children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsx)(x,{variant:`outline`,size:`icon-xs`,className:`rounded-s-none`,"aria-label":`Git actions`,children:(0,I.jsx)(w,{icon:t.committing?e_:Yg,className:P(`size-4`,t.committing&&`animate-spin`)})})}),(0,I.jsx)(SC,{align:`end`,className:`w-56`,children:(0,I.jsx)(FL,{git:t,collapsed:!1})})]})]}),(0,I.jsx)(IL,{git:t})]})}function LL({...e}){return(0,I.jsx)(Kee,{"data-slot":`alert-dialog`,...e})}function RL({...e}){return(0,I.jsx)(qee,{"data-slot":`alert-dialog-trigger`,...e})}function Eae({...e}){return(0,I.jsx)(Jee,{"data-slot":`alert-dialog-portal`,...e})}function Dae({className:e,...t}){return(0,I.jsx)(Yee,{"data-slot":`alert-dialog-overlay`,className:P(`fixed inset-0 z-50 bg-background/80 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function zL({className:e,size:t=`default`,...n}){return(0,I.jsxs)(Eae,{children:[(0,I.jsx)(Dae,{}),(0,I.jsx)(Qee,{"data-slot":`alert-dialog-content`,"data-size":t,className:P(`group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-background p-4 text-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...n})]})}function BL({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:P(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function VL({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:P(`flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function HL({className:e,...t}){return(0,I.jsx)($ee,{"data-slot":`alert-dialog-title`,className:P(`text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function UL({className:e,...t}){return(0,I.jsx)(ete,{"data-slot":`alert-dialog-description`,className:P(`text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function WL({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,I.jsx)(x,{variant:t,size:n,asChild:!0,children:(0,I.jsx)(tte,{"data-slot":`alert-dialog-action`,className:P(e),...r})})}function GL({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,I.jsx)(x,{variant:t,size:n,asChild:!0,children:(0,I.jsx)(rte,{"data-slot":`alert-dialog-cancel`,className:P(e),...r})})}function KL({className:e,size:t=`default`,...n}){return(0,I.jsx)(fC,{"data-slot":`switch`,"data-size":t,className:P(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,I.jsx)(mC,{"data-slot":`switch-thumb`,className:`bg-background dark:data-checked:bg-primary-foreground dark:data-unchecked:bg-foreground pointer-events-none block rounded-full ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0`})})}var qL=Jh({theme:lh().refine(e=>dI.some(t=>t.id===e)).default(dI[0].id),terminal:Jh({font:Jh({family:lh().default(`FiraCode Nerd Font`),size:Fh().default(14),lineHeight:Fh().default(1.35),ligatures:zh().default(!0)}).prefault({}),cursor:Jh({style:ng([`block`,`bar`,`underline`]).default(`bar`),blink:zh().default(!0)}).prefault({}),padding:Jh({top:Fh().default(4),right:Fh().default(4),bottom:Fh().default(0),left:Fh().default(4)}).prefault({}),scrollback:Fh().default(1e3),boldIsBright:zh().default(!0),behavior:Jh({modernizeShiftEnter:zh().default(!0),pasteBrowserImages:zh().default(!0),captureShortcuts:zh().default(!0),bellFlash:zh().default(!0),bellSound:zh().default(!0),clickToMoveCursor:zh().default(!0),optionAsMeta:ng([`off`,`left`,`right`,`both`]).default(`off`),confirmCloseBusyTab:zh().default(!0)}).prefault({})}).prefault({}),diff:Jh({split:zh().default(!1),wrap:zh().default(!0),collapsed:zh().default(!1)}).prefault({}),rewind:ng([`all`,`chat`,`code`]).default(`chat`)}),JL=`prefs`,YL=qL.parse({});function Oae(){let e=localStorage.getItem(JL);if(e===null)return structuredClone(YL);let t=qL.safeParse(JSON.parse(e));return t.success?t.data:(console.warn(`invalid stored prefs, using the defaults:\n${bl(t.error)}`),structuredClone(YL))}function kae(e){localStorage.setItem(JL,JSON.stringify(e))}function XL(e){return(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`h2`,{className:`text-muted-foreground mb-2 px-1 text-xs font-medium`,children:[e.title,e.note&&(0,I.jsxs)(`span`,{className:`font-normal`,children:[` · `,e.note]})]}),(0,I.jsx)(`div`,{className:`@container divide-y overflow-hidden rounded-xl border`,children:e.children})]})}function ZL(e){return(0,I.jsxs)(`label`,{className:`flex min-h-13 flex-wrap items-center gap-x-4 gap-y-2 px-4 py-2.5`,children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 basis-40 text-sm font-medium`,children:e.label}),(0,I.jsx)(`div`,{className:`max-w-full shrink-0 @max-lg:has-[[data-slot=select-trigger],input:not([type=number])]:w-full @max-lg:has-[[data-slot=select-trigger],input:not([type=number])]:*:w-full @max-lg:**:data-[slot=select-trigger]:w-full`,children:e.children})]})}function QL(e){let[t,n]=(0,F.useState)(e.value);function r(){t!==e.value&&(e.valid&&!e.valid(t)?n(e.value):e.onCommit(t))}return(0,I.jsx)(wL,{className:P(`w-56`,e.className),type:e.type,min:e.type===`number`?0:void 0,step:e.step,placeholder:e.placeholder,value:t,onChange:e=>n(e.target.value),onBlur:r,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}})}function $L(e){return(0,I.jsx)(QL,{type:`number`,className:`w-24`,step:e.step??1,value:String(e.value),valid:e=>e!==``&&Number(e)>=0,onCommit:t=>e.onCommit(Number(t))},e.value)}function Aae(e){let t=e.prefs;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(XL,{title:`Appearance`,children:(0,I.jsx)(ZL,{label:`Theme`,children:(0,I.jsxs)(TL,{value:t.theme,onValueChange:e=>L9({...t,theme:e}),children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsx)(OL,{children:dI.map(e=>(0,I.jsx)(kL,{value:e.id,children:e.name},e.id))})]})})}),(0,I.jsx)(jae,{}),(0,I.jsx)(x,{variant:`outline`,onClick:e.onRestore,children:`Restore browser defaults`})]})}function jae(){let[e,t]=(0,F.useState)(`idle`),[n,r]=(0,F.useState)(null);async function i(){t(`checking`),r(null);try{let e=`serviceWorker`in navigator?await navigator.serviceWorker.getRegistration():void 0;if(e===void 0){location.reload();return}await e.update(),t(e.installing===null&&e.waiting===null?`current`:`updating`)}catch(e){console.error(`could not check for updates`,e),r(Oe(e)),t(`idle`)}}return(0,I.jsx)(XL,{title:`App`,children:(0,I.jsx)(ZL,{label:`Load the newest version of OffSite in this browser`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[n!==null&&(0,I.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[`Could not check: `,n]}),e===`current`&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Up to date`}),e===`updating`&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Updating, the page reloads when it's ready`}),(0,I.jsx)(x,{size:`sm`,variant:`outline`,disabled:e===`checking`||e===`updating`,onClick:()=>void i(),children:`Check for updates`})]})})})}function Mae(e){for(let t=0;t<e.length;t++){let n=e[t];if(!n.startsWith(`-`)&&!n.startsWith(`+`))return!1;let r=n.startsWith(`-`),i=n.slice(1);if(i===``||i===`-`)return!1;if(i.startsWith(`-`)){if(!eR(i.slice(1),r))return!1}else for(let n=0;n<i.length;n++){let a=i[n];if(a===`o`){let a=i.slice(n+1);if(a===``){if(t++,t===e.length)return!1;a=e[t]}if(!eR(a,r))return!1;break}if(a===`b`||a===`c`||r&&`dfnprvx`.includes(a)||!r&&a===`i`)return!1}}return!0}function eR(e,t){let n=e.toLowerCase().replace(/[-_]/g,``),r=t;return n.startsWith(`no`)&&(n=n.slice(2),r=!t),[`rcs`,`globalrcs`,`interactive`,`exec`].includes(n)?r:![`privileged`,`restricted`,`sourcetrace`,`verbose`,`xtrace`].includes(n)||!r}function Nae(e,t,n){if(t===`windows`)return`Not available on Windows`;if(e!==null&&/[\n"'\\$`;&|<>()*?[\]{}#!]/.test(e))return`Not available for commands with shell syntax`;let r=e===null?[n]:e.split(/[ \t]/).filter(e=>e!==``);if(r.length===0)return`Available for bash, zsh and fish`;let i=r[0],a=i.split(`/`).pop(),o=r.slice(1);return a===`bash`?t===`macos`&&(i===`/bin/bash`||!i.includes(`/`))?`Needs a newer bash than the one macOS includes`:o.every(e=>[`-l`,`--login`,`-i`].includes(e))?null:`Not available with these bash options`:a===`zsh`?Mae(o)?null:`Not available with these zsh options`:a===`fish`?o.every(e=>{if(e.startsWith(`--`)){let t=e.slice(2).split(`=`)[0];return t===``||![`command`,`no-config`,`no-execute`].some(e=>e.startsWith(t))}return!(e.startsWith(`-`)&&/[cNn]/.test(e))})?null:`Not available with these fish options`:`Available for bash, zsh and fish`}var Pae=`3.6.8`,Fae=`1.3.1`,tR=[{family:`FiraCode Nerd Font`,label:`Fira Code`},{family:`JetBrainsMono Nerd Font`,label:`JetBrains Mono`},{family:`CaskaydiaCove Nerd Font`,label:`Cascadia Code`},{family:`Hack Nerd Font`,label:`Hack`}],Iae=[{value:`macos`,label:`macOS`},{value:`linux`,label:`Linux`},{value:`windows`,label:`Windows`}];async function nR(e){let t=`${e.font.size}px ${e.font.family}`;await Promise.all([document.fonts.load(t),document.fonts.load(`bold ${t}`)]);let n=document.documentElement.style;n.setProperty(`--pad-top`,`${e.padding.top}px`),n.setProperty(`--pad-right`,`${e.padding.right}px`),n.setProperty(`--pad-bottom`,`${e.padding.bottom}px`),n.setProperty(`--pad-left`,`${e.padding.left}px`)}function Lae(e,t){let n=fI();return{fontFamily:e.font.family,fontSize:e.font.size,lineHeight:e.font.lineHeight,ligatures:e.font.ligatures,cursorStyle:e.cursor.style,cursorBlink:e.cursor.blink,scrollback:e.scrollback,boldIsBright:e.boldIsBright,colors:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorText:n.background,selectionBackground:n.selectionBackground,selectionForeground:n.foreground,palette:n.palette},version:Rae(t),clickToMoveCursor:e.behavior.clickToMoveCursor,optionAsMeta:e.behavior.optionAsMeta}}function Rae(e){if(e===`offsite`)return`offsite 0.0.0`;if(e===`ghostty`)return`ghostty ${Fae}`;if(e===`iterm2`)return`iTerm2 ${Pae}`;throw Error(`unknown terminal identity ${e}`)}var rR=[10,15,30,45,60,120,180,300,600,900,1800,3600];function zae(e){let t=e.config;function n(n){H9(e.machine,{...t,...n})}return(0,I.jsxs)(XL,{title:`Agents`,children:[(0,I.jsx)(ZL,{label:`Send while working`,children:(0,I.jsxs)(TL,{value:t.delivery,onValueChange:n=>{if(n!==`queue`&&n!==`steer`)throw Error(`Unknown delivery ${n}`);H9(e.machine,{...t,delivery:n})},children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`queue`,children:`Queue messages`}),(0,I.jsx)(kL,{value:`steer`,children:`Steer the agent`})]})]})}),(0,I.jsx)(ZL,{label:`Auto-skip questions`,children:(0,I.jsx)(iR,{value:t.autoSkipQuestionTimeout,onChange:e=>n({autoSkipQuestionTimeout:e})})}),(0,I.jsx)(ZL,{label:`Auto-resolve permissions`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.autoPermissionTimeout!==null&&(0,I.jsxs)(TL,{value:t.autoPermissionMode,onValueChange:e=>{if(e!==`allow`&&e!==`deny`)throw Error(`Unknown decision ${e}`);n({autoPermissionMode:e})},children:[(0,I.jsx)(DL,{className:`w-24`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`allow`,children:`Allow`}),(0,I.jsx)(kL,{value:`deny`,children:`Deny`})]})]}),(0,I.jsx)(iR,{value:t.autoPermissionTimeout,onChange:e=>n({autoPermissionTimeout:e})})]})})]})}function iR(e){let t=e.value===null||rR.includes(e.value)?rR:[...rR,e.value].sort((e,t)=>e-t);return(0,I.jsxs)(TL,{value:e.value===null?`off`:String(e.value),onValueChange:t=>e.onChange(t===`off`?null:Number(t)),children:[(0,I.jsx)(DL,{className:`w-40`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`off`,children:`Off`}),t.map(e=>(0,I.jsx)(kL,{value:String(e),children:e===3600?`After 1 hour`:e===60?`After 1 minute`:e%60==0?`After ${e/60} minutes`:`After ${e} seconds`},e))]})]})}function aR(e){let t=e.config.commitMessage,[n,r]=(0,F.useState)(null),[i,a]=(0,F.useState)(null);(0,F.useEffect)(()=>{if(t.provider===null)return;let n=!0;return r(null),a(null),L(e.machine,`capabilities`,{provider:t.provider,accountId:t.accountId,projectId:null}).then(e=>{n&&r(e.models)},e=>{n&&a(Oe(e))}),()=>{n=!1}},[e.machine,t.provider,t.accountId]);function o(t){H9(e.machine,{...e.config,commitMessage:t})}function s(t){if(t===`off`){o({provider:null,accountId:null,model:null});return}if(t===`opencode`){o({provider:`opencode`,accountId:null,model:null});return}let n=[...e.claudeAccounts,...e.codexAccounts].find(e=>e.id===t);if(n===void 0)throw Error(`That account was removed`);o({provider:n.provider,accountId:n.id,model:null})}return(0,I.jsxs)(XL,{title:`Commit messages and pull requests`,children:[(0,I.jsx)(ZL,{label:`Account`,children:(0,I.jsxs)(TL,{value:t.provider===null?`off`:t.provider===`opencode`?`opencode`:t.accountId??`off`,onValueChange:s,children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`off`,children:`Off`}),[...e.claudeAccounts,...e.codexAccounts].map(e=>(0,I.jsxs)(kL,{value:e.id,disabled:!e.valid,children:[(0,I.jsx)(zv,{provider:e.provider,className:`size-4`}),`${uw[e.provider]} · ${e.name}`]},e.id)),e.openCode.available&&(0,I.jsxs)(kL,{value:`opencode`,children:[(0,I.jsx)(zv,{provider:`opencode`,className:`size-4`}),uw.opencode]})]})]})}),t.provider!==null&&(0,I.jsx)(ZL,{label:`Model`,children:(0,I.jsxs)(TL,{value:t.model??void 0,disabled:n===null,onValueChange:e=>o({...t,model:e}),children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{placeholder:i===null?n===null?`Loading…`:`Choose a model`:`Unavailable`})}),(0,I.jsx)(OL,{children:(n??[]).map(e=>(0,I.jsx)(kL,{value:e.value,children:e.name},e.value))})]})}),i!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:i})]})}var oR={zsh:`M11.415 5.038a.58.58 0 0 0-.543.197L.135 18.021a.58.58 0 0 0 .071.814.58.58 0 0 0 .815-.07L11.757 5.979a.58.58 0 0 0-.07-.815.6.6 0 0 0-.272-.126m-8.113.317a3.133 3.133 0 0 0-3.12 3.12 3.13 3.13 0 0 0 3.12 3.119A3.133 3.133 0 0 0 6.42 8.475a3.13 3.13 0 0 0-3.119-3.119m0 1.806a1.3 1.3 0 0 1 1.314 1.313 1.3 1.3 0 0 1-1.314 1.312A1.3 1.3 0 0 1 1.99 8.475a1.3 1.3 0 0 1 1.312-1.314m5.253 5.253a3.13 3.13 0 0 0-3.119 3.119 3.13 3.13 0 0 0 3.12 3.118 3.133 3.133 0 0 0 3.118-3.12 3.133 3.133 0 0 0-3.119-3.118m0 1.805a1.3 1.3 0 0 1 1.313 1.314c0 .735-.577 1.312-1.312 1.312a1.3 1.3 0 0 1-1.314-1.312 1.3 1.3 0 0 1 1.313-1.314m7.201 3.276a.58.58 0 0 0-.578.578.58.58 0 0 0 .578.578h7.666a.58.58 0 0 0 .579-.578.58.58 0 0 0-.579-.578Z`,bash:`M21.038,4.9l-7.577-4.498C13.009,0.134,12.505,0,12,0c-0.505,0-1.009,0.134-1.462,0.403L2.961,4.9 C2.057,5.437,1.5,6.429,1.5,7.503v8.995c0,1.073,0.557,2.066,1.462,2.603l7.577,4.497C10.991,23.866,11.495,24,12,24 c0.505,0,1.009-0.134,1.461-0.402l7.577-4.497c0.904-0.537,1.462-1.529,1.462-2.603V7.503C22.5,6.429,21.943,5.437,21.038,4.9z M15.17,18.946l0.013,0.646c0.001,0.078-0.05,0.167-0.111,0.198l-0.383,0.22c-0.061,0.031-0.111-0.007-0.112-0.085L14.57,19.29 c-0.328,0.136-0.66,0.169-0.872,0.084c-0.04-0.016-0.057-0.075-0.041-0.142l0.139-0.584c0.011-0.046,0.036-0.092,0.069-0.121 c0.012-0.011,0.024-0.02,0.036-0.026c0.022-0.011,0.043-0.014,0.062-0.006c0.229,0.077,0.521,0.041,0.802-0.101 c0.357-0.181,0.596-0.545,0.592-0.907c-0.003-0.328-0.181-0.465-0.613-0.468c-0.55,0.001-1.064-0.107-1.072-0.917 c-0.007-0.667,0.34-1.361,0.889-1.8l-0.007-0.652c-0.001-0.08,0.048-0.168,0.111-0.2l0.37-0.236 c0.061-0.031,0.111,0.007,0.112,0.087l0.006,0.653c0.273-0.109,0.511-0.138,0.726-0.088c0.047,0.012,0.067,0.076,0.048,0.151 l-0.144,0.578c-0.011,0.044-0.036,0.088-0.065,0.116c-0.012,0.012-0.025,0.021-0.038,0.028c-0.019,0.01-0.038,0.013-0.057,0.009 c-0.098-0.022-0.332-0.073-0.699,0.113c-0.385,0.195-0.52,0.53-0.517,0.778c0.003,0.297,0.155,0.387,0.681,0.396 c0.7,0.012,1.003,0.318,1.01,1.023C16.105,17.747,15.736,18.491,15.17,18.946z M19.143,17.859c0,0.06-0.008,0.116-0.058,0.145 l-1.916,1.164c-0.05,0.029-0.09,0.004-0.09-0.056v-0.494c0-0.06,0.037-0.093,0.087-0.122l1.887-1.129 c0.05-0.029,0.09-0.004,0.09,0.056V17.859z M20.459,6.797l-7.168,4.427c-0.894,0.523-1.553,1.109-1.553,2.187v8.833 c0,0.645,0.26,1.063,0.66,1.184c-0.131,0.023-0.264,0.039-0.398,0.039c-0.42,0-0.833-0.114-1.197-0.33L3.226,18.64 c-0.741-0.44-1.201-1.261-1.201-2.142V7.503c0-0.881,0.46-1.702,1.201-2.142l7.577-4.498c0.363-0.216,0.777-0.33,1.197-0.33 c0.419,0,0.833,0.114,1.197,0.33l7.577,4.498c0.624,0.371,1.046,1.013,1.164,1.732C21.686,6.557,21.12,6.411,20.459,6.797z`,fish:`m19.164 9.228-3.016 2.688v.527l3.016 2.688v-1.228l-1.936-1.723 1.936-1.724V9.228m-6.658.046v1.208l1.905 1.696-1.905 1.695v1.209l2.968-2.645v-.518l-2.968-2.645M9.781 7.847a6.519 6.519 0 0 0-2.038-.335c-.672 0-1.349.112-2.03.335a9.23 9.23 0 0 0-2.088 1.017v.723c.69-.4 1.377-.7 2.06-.897a7.388 7.388 0 0 1 2.058-.296c.684 0 1.368.098 2.052.296a9.452 9.452 0 0 1 2.075.897v-.723a9.229 9.229 0 0 0-2.09-1.017m.014 7.78a7.371 7.371 0 0 1-2.052.296 7.388 7.388 0 0 1-2.057-.296 9.18 9.18 0 0 1-2.061-.897v.723a9.228 9.228 0 0 0 2.088 1.017 6.492 6.492 0 0 0 2.03.335c.678 0 1.357-.112 2.038-.335a9.227 9.227 0 0 0 2.089-1.017v-.723c-.7.4-1.391.7-2.075.897m.602-11.23h-.51L7.28 6.92h1.19l1.672-1.62 1.671 1.62h1.191l-2.607-2.525m-2.965 13.68v-.824H6.427v.825l.786 1.527h.614l-.395-1.527M4.127 10.95v1.216H5.13V10.95H4.127m-1.16-1.695L0 11.901v.518l2.967 2.645v-1.208L1.063 12.16l1.904-1.695V9.256m20.68 3.28c-.235-.3-.574-.509-1.017-.626.395-.103.696-.278.902-.525.206-.247.31-.556.31-.926 0-.546-.197-.984-.59-1.314-.393-.33-.919-.495-1.575-.495-.22 0-.473.025-.758.073-.284.048-.61.12-.974.217v.84c.314-.12.613-.21.9-.27a4.05 4.05 0 0 1 .832-.091c.403 0 .714.093.933.278.218.185.328.451.328.798 0 .328-.118.584-.353.768-.235.184-.562.276-.98.276h-.697v.75h.696c.458 0 .821.116 1.09.346.268.23.402.542.402.934 0 .425-.134.75-.402.976-.269.226-.653.339-1.153.339a3.55 3.55 0 0 1-.89-.117 4.395 4.395 0 0 1-.91-.358v.909a6.1 6.1 0 0 0 .95.249c.323.057.639.085.95.085.738 0 1.315-.177 1.733-.53.417-.355.626-.842.626-1.463 0-.449-.118-.823-.353-1.123`,powershell:`M23.181 2.974c.568 0 .923.463.792 1.035l-3.659 15.982c-.13.572-.697 1.035-1.265 1.035H.819c-.568 0-.923-.463-.792-1.035L3.686 4.009c.13-.572.697-1.035 1.265-1.035zm-8.375 9.346c.251-.394.227-.905-.09-1.243L9.122 5.125c-.38-.404-1.037-.407-1.466-.003-.429.402-.468 1.056-.088 1.46l4.662 4.96v.11l-7.42 5.374c-.45.327-.533.977-.187 1.453.346.476.991.597 1.44.27l8.229-5.91c.28-.196.438-.365.514-.52zm-2.796 4.399a.928.928 0 00-.934.923c0 .51.418.923.934.923h4.433a.928.928 0 00.934-.923.928.928 0 00-.934-.923z`,cmd:`M8.165 6V3h7.665v3H8.165zm-.5-3H1c-.55 0-1 .45-1 1v2h7.665V3zM23 3h-6.67v3H24V4c0-.55-.45-1-1-1zM0 6.5h24V20c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V6.5zM11.5 18c0 .3.2.5.5.5h8c.3 0 .5-.2.5-.5v-1.5c0-.3-.2-.5-.5-.5h-8c-.3 0-.5.2-.5.5V18zm-5.2-4.55l-3.1 3.1c-.25.25-.25.6 0 .8l.9.9c.25.25.6.25.8 0l4.4-4.4a.52.52 0 0 0 0-.8l-4.4-4.4c-.2-.2-.6-.2-.8 0l-.9.9c-.25.2-.25.55 0 .8l3.1 3.1z`},sR={zsh:`zsh`,bash:`bash`,fish:`fish`,pwsh:`powershell`,powershell:`powershell`,cmd:`cmd`},cR={macos:[`zsh`,`bash`,`fish`,`pwsh`],linux:[`bash`,`zsh`,`fish`,`pwsh`],windows:[`pwsh`,`powershell`,`cmd`]};function lR(e){let t=e.trim().split(/[\\/]/).pop()?.toLowerCase().replace(/\.exe$/,``);return t===void 0?void 0:sR[t]}function uR(e){return e.replace(/[\\/][^\\/]*$/,``)}function dR(e){return(0,I.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`size-4 flex-none`,fill:`currentColor`,children:(0,I.jsx)(`path`,{d:oR[e.logo]})})}function fR(e){let[t,n]=(0,F.useState)(e.value??``),[r,i]=(0,F.useState)(null),[a,o]=(0,F.useState)(null),s=lR(t),c=e.platform===e.device,l=c?r:cR[e.platform].map(e=>({name:e,path:null}));(0,F.useEffect)(()=>{c&&L(e.machine,`terminal.shells`,void 0).then(i,e=>o(Oe(e)))},[e.machine,c]);function u(t){n(t),t!==(e.value??``)&&e.onCommit(t===``?null:t)}return(0,I.jsxs)(`div`,{className:`relative w-56`,children:[s&&(0,I.jsx)(`span`,{className:`text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2`,children:(0,I.jsx)(dR,{logo:s})}),(0,I.jsx)(wL,{className:s?`pr-9 pl-8`:`pr-9`,placeholder:`System default`,value:t,onChange:e=>n(e.target.value),onBlur:()=>u(t),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}}),(0,I.jsxs)(yC,{children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsx)(x,{variant:`ghost`,size:`icon-xs`,"aria-label":`Known shells`,className:`text-muted-foreground absolute top-1/2 right-1.5 -translate-y-1/2`,children:(0,I.jsx)(w,{icon:Mg})})}),(0,I.jsxs)(SC,{align:`end`,className:`w-72`,children:[a&&(0,I.jsx)(`p`,{className:`text-destructive px-2 py-1.5 text-xs`,children:a}),l?.length===0&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-2 py-1.5 text-xs`,children:`No known shells found`}),l?.map(e=>(0,I.jsxs)(CC,{onSelect:()=>u(e.path??e.name),children:[(0,I.jsx)(dR,{logo:sR[e.name]}),e.name,e.path!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-auto min-w-0 truncate pl-3 text-xs [direction:rtl]`,title:e.path,children:(0,I.jsx)(`bdi`,{children:uR(e.path)})})]},e.path??e.name)),(0,I.jsx)(OC,{}),(0,I.jsx)(CC,{onSelect:()=>u(``),children:`System default`})]})]})]})}function pR(e){let t=e.config.workingDir[e.platform]??``;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(XL,{title:`Projects`,children:(0,I.jsx)(ZL,{label:`Working directory`,children:(0,I.jsx)(QL,{className:`w-72 font-mono`,value:t,placeholder:`Home folder`,onCommit:t=>H9(e.machine,{...e.config,workingDir:{...e.config.workingDir,[e.platform]:t.trim()===``?null:t.trim()}})},`${e.machine}-${t}`)})}),(0,I.jsx)(mR,{machine:e.machine,config:e.config,platform:e.platform,defaultShell:e.defaultShell},e.machine),(0,I.jsx)(zae,{machine:e.machine,config:e.config}),(0,I.jsx)(aR,{machine:e.machine,config:e.config,claudeAccounts:e.claudeAccounts,codexAccounts:e.codexAccounts,openCode:e.openCode},`git-${e.machine}`),(0,I.jsx)(x,{variant:`outline`,onClick:e.onRestore,children:`Restore machine defaults`})]})}function mR(e){let t=e.config.terminal,[n,r]=(0,F.useState)(e.platform),i=Nae(t.shell[e.platform],e.platform,e.defaultShell);function a(t){H9(e.machine,{...e.config,terminal:t})}return(0,I.jsxs)(XL,{title:`Shell`,note:`Applies to new terminals`,children:[(0,I.jsx)(ZL,{label:`Platform`,children:(0,I.jsxs)(TL,{value:n,onValueChange:e=>r(e),children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsx)(OL,{children:Iae.map(t=>(0,I.jsxs)(kL,{value:t.value,children:[t.label,t.value===e.platform&&(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`(this machine)`})]},t.value))})]})}),(0,I.jsx)(ZL,{label:`Command`,children:(0,I.jsx)(fR,{machine:e.machine,platform:n,device:e.platform,value:t.shell[n],onCommit:e=>a({...t,shell:{...t.shell,[n]:e}})},`${e.machine}-${n}-command`)}),(0,I.jsx)(ZL,{label:(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Shell integration`,(0,I.jsx)(M,{label:(0,I.jsxs)(`div`,{children:[`Tells the terminal where prompts and commands start and end.`,(0,I.jsxs)(`ul`,{className:`mt-1 list-disc pl-4`,children:[(0,I.jsx)(`li`,{children:`Click in the command line to move the cursor`}),(0,I.jsx)(`li`,{children:`Ignore clipboard reads once the command that asked has finished`})]})]}),children:(0,I.jsx)(`span`,{onClick:e=>e.preventDefault(),children:(0,I.jsx)(w,{icon:dee,"aria-label":`About shell integration`,className:`text-muted-foreground size-3.5`})})})]}),children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground max-w-32 text-right text-xs sm:max-w-none`,children:i}),(0,I.jsx)(KL,{checked:i===null&&t.behavior.shellIntegration,disabled:i!==null,onCheckedChange:e=>a({...t,behavior:{...t.behavior,shellIntegration:e}})})]})}),(0,I.jsx)(hR,{identity:t.behavior.terminalIdentity,onChange:e=>a({...t,behavior:{...t.behavior,terminalIdentity:e}})})]})}function hR(e){return(0,I.jsx)(ZL,{label:`Report the terminal as`,children:(0,I.jsxs)(TL,{value:e.identity,onValueChange:e.onChange,children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`offsite`,children:`OffSite`}),(0,I.jsx)(kL,{value:`ghostty`,children:`Ghostty`}),(0,I.jsx)(kL,{value:`iterm2`,children:`iTerm2`})]})]})})}var gR=(0,F.createContext)({});function _R(e){let t=(0,F.useRef)(null);return t.current===null&&(t.current=e()),t.current}var vR=typeof window<`u`?F.useLayoutEffect:F.useEffect,yR=(0,F.createContext)(null);function bR(e,t){e.indexOf(t)===-1&&e.push(t)}function xR(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}function SR([...e],t,n){let r=t<0?e.length+t:t;if(r>=0&&r<e.length){let r=n<0?e.length+n:n,[i]=e.splice(t,1);e.splice(r,0,i)}return e}var CR=(e,t,n)=>n>t?t:n<e?e:n,wR={},TR=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),ER=e=>typeof e==`object`&&!!e,DR=e=>/^0[^.\s]+$/u.test(e);function OR(e){let t;return()=>(t===void 0&&(t=e()),t)}var kR=e=>e,AR=(...e)=>e.reduce((e,t)=>n=>t(e(n))),jR=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},MR=class{constructor(){this.subscriptions=[]}add(e){return bR(this.subscriptions,e),()=>this.remove(e)}remove(e){xR(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}},NR=e=>e*1e3,PR=e=>e/1e3,FR=(e,t)=>t?1e3/t*e:0,IR=(e,t,n)=>e*(3*(1-e)*((1-e)*t+e*n)+e*e);function LR(e,t,n,r){return e===t&&n===r?kR:i=>{let a=0,o=1,s=i;for(let t=0;;t++){s>=a&&s<=o||(s=(a+o)/2);let r=IR(s,e,n)-i;if(r*r<1e-28||t===40)break;r>0?o=s:a=s,s-=r*1e-7/(IR(s+1e-7,e,n)-i-r)}return IR(s,t,r)}}var RR=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,zR=e=>t=>1-e(1-t),BR=LR(.33,1.53,.69,.99),VR=zR(BR),HR=RR(VR),UR=e=>e>=1?1:(e*=2)<1?.5*VR(e):.5*(2-2**(-10*(e-1))),WR=e=>1-Math.sin(Math.acos(e)),GR=zR(WR),KR=RR(WR),qR=LR(.42,0,1,1),JR=LR(0,0,.58,1),YR=LR(.42,0,.58,1),XR=e=>Array.isArray(e)&&typeof e[0]!=`number`,ZR=e=>Array.isArray(e)&&typeof e[0]==`number`,QR={linear:kR,easeIn:qR,easeInOut:YR,easeOut:JR,circIn:WR,circInOut:KR,circOut:GR,backIn:VR,backInOut:HR,backOut:BR,anticipate:UR},$R=e=>typeof e==`string`,ez=e=>{if(ZR(e)){e.length;let[t,n,r,i]=e;return LR(t,n,r,i)}return $R(e)?(QR[e],`${e}`,QR[e]):e},tz={delta:0,timestamp:0,isProcessing:!1},nz;function rz(){nz=void 0}var iz={now:()=>(nz===void 0&&iz.set(tz.isProcessing||wR.useManualTiming?tz.timestamp:performance.now()),nz),set:e=>{nz=e,queueMicrotask(rz)}},az=e=>Math.round(e*1e5)/1e5,oz=e=>t=>typeof t==`string`&&t.startsWith(e),sz=oz(`--`),cz=oz(`var(--`),lz=e=>cz(e)?uz.test(e.split(`/*`)[0].trim()):!1,uz=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function dz(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var fz={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},pz={...fz,transform:e=>CR(0,1,e)},mz={...fz,default:1},hz=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function gz(e){return e==null}var _z=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,vz=(e,t)=>n=>!!(typeof n==`string`&&_z.test(n)&&n.startsWith(e)||t&&!gz(n)&&Object.prototype.hasOwnProperty.call(n,t)),yz=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(hz);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},bz=e=>CR(0,255,e),xz={...fz,transform:e=>Math.round(bz(e))},Sz={test:vz(`rgb`,`red`),parse:yz(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+xz.transform(e)+`, `+xz.transform(t)+`, `+xz.transform(n)+`, `+az(pz.transform(r))+`)`};function Cz(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var wz={test:vz(`#`),parse:Cz,transform:Sz.transform},Tz=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Ez=Tz(`deg`),Dz=Tz(`%`),X=Tz(`px`),Oz=Tz(`vh`),kz=Tz(`vw`),Az={...Dz,parse:e=>Dz.parse(e)/100,transform:e=>Dz.transform(e*100)},jz={test:vz(`hsl`,`hue`),parse:yz(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+Dz.transform(az(t))+`, `+Dz.transform(az(n))+`, `+az(pz.transform(r))+`)`},Mz={test:e=>Sz.test(e)||wz.test(e)||jz.test(e),parse:e=>Sz.test(e)?Sz.parse(e):jz.test(e)?jz.parse(e):wz.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Sz.transform(e):jz.transform(e),getAnimatableNone:e=>{let t=Mz.parse(e);return t.alpha=0,Mz.transform(t)}},Nz=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,Pz=new RegExp(hz.source),Fz=new RegExp(Nz.source,`i`);function Iz(e){return isNaN(e)&&typeof e==`string`&&(Pz.test(e)||Fz.test(e))}var Lz=`number`,Rz=`color`,zz=`var`,Bz=`var(`,Vz="${}",Hz=/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 Uz(e){let t=e.toString();return Pz.test(t)||Fz.test(t)}function Wz(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(Hz,e=>(Mz.test(e)?(r.color.push(a),i.push(Rz),n.push(Mz.parse(e))):e.startsWith(Bz)?(r.var.push(a),i.push(zz),n.push(e)):(r.number.push(a),i.push(Lz),n.push(parseFloat(e))),++a,Vz)).split(Vz),indexes:r,types:i}}function Gz(e){return Wz(e).values}function Kz({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===Lz?az(r[a]):e===Rz?Mz.transform(r[a]):r[a]}return i}}function qz(e){return Kz(Wz(e))}var Jz=e=>typeof e==`number`?0:Mz.test(e)?Mz.getAnimatableNone(e):e,Yz=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:Jz(e);function Xz(e){let t=Wz(e);return Kz(t)(t.values.map((e,n)=>Yz(e,t.split[n])))}var Zz={test:Iz,parse:Gz,createTransformer:qz,getAnimatableNone:Xz};function Qz(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 $z({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=Qz(s,r,e+1/3),a=Qz(s,r,e),o=Qz(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function eB(e,t){return n=>n>0?t:e}var tB=(e,t,n)=>e+(t-e)*n,nB=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},rB=[wz,Sz,jz],iB=e=>rB.find(t=>t.test(e));function aB(e){let t=iB(e);if(!t)return`${e}`,!1;let n=t.parse(e);return t===jz&&(n=$z(n)),n}var oB=(e,t)=>{let n=aB(e),r=aB(t);if(!n||!r)return eB(e,t);let i={...n};return e=>(i.red=nB(n.red,r.red,e),i.green=nB(n.green,r.green,e),i.blue=nB(n.blue,r.blue,e),i.alpha=tB(n.alpha,r.alpha,e),Sz.transform(i))},sB=new Set([`none`,`hidden`]);function cB(e,t){return sB.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function lB(e,t){return n=>tB(e,t,n)}function uB(e){return typeof e==`number`?lB:typeof e==`string`?lz(e)?eB:Mz.test(e)?oB:mB:Array.isArray(e)?dB:typeof e==`object`?Mz.test(e)?oB:fB:eB}function dB(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>uB(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function fB(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=uB(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function pB(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 mB=(e,t)=>{let n=Zz.createTransformer(t),r=Wz(e),i=Wz(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?sB.has(e)&&!i.values.length||sB.has(t)&&!r.values.length?cB(e,t):AR(dB(pB(r,i),i.values),n):(`${e}${t}`,eB(e,t))},hB=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function gB(e,t){let n=hB.exec(e);if(!n)return;let r=hB.exec(t);if(!r||n[2]!==r[2])return;let i=n[2],a=parseFloat(n[1]),o=parseFloat(r[1]);return e=>az(tB(a,o,e))+i}function _B(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return tB(e,t,n);if(typeof e==`string`&&typeof t==`string`){let n=gB(e,t);if(n)return n}return uB(e)(e,t)}var vB=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function yB(e){let t=new Set,n=new Set,r=!1,i=!1,a=new Set,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(n.add(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var bB=40;function xB(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0,a=()=>r=!0,o=vB.reduce((e,t)=>(e[t]=yB(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=wR.useManualTiming,o=a?n.timestamp:performance.now();r=!1,a||(n.delta=i?1e3/60:Math.max(Math.min(o-n.timestamp,bB),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:vB.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<vB.length;t++)o[vB[t]].cancel(e)},state:n,steps:o}}var{schedule:SB,cancel:CB,steps:wB}=xB(typeof requestAnimationFrame<`u`?requestAnimationFrame:kR,!0,tz),TB=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>SB.update(t,e),stop:()=>CB(t),now:()=>tz.isProcessing?tz.timestamp:iz.now()}},EB=(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)})`},DB=2e4;function OB(e,t=50,n=DB,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 kB(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(OB(o),DB);return{type:`keyframes`,ease:e=>o.next(s*e).value/t,duration:PR(s)}}var AB={stiffness:100,damping:10,mass:1,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05},jB=e=>e<0?1/Math.max(1+e,AB.minDamping):Math.max(1-e,AB.minDamping);function MB(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 FB(e=>i*Math.exp(-r*e)-r*Math.exp(-i*e)-a,e=>Math.exp(-i*e)-Math.exp(-r*e),t)/t}function NB(e,t){return e*Math.sqrt(1-t*t)}var PB=12;function FB(e,t,n){let r=n;for(let n=1;n<PB;n++)r-=e(r)/t(r);return r}var IB=.001;function LB({duration:e=AB.duration,bounce:t=AB.bounce}){let n,r;AB.maxDuration;let i=jB(t);e=CR(AB.minDuration,AB.maxDuration,PR(e)),i<1?(n=t=>{let n=t*i,r=n*e,a=NB(t,i),o=Math.exp(-r);return IB-n/a*o},r=t=>{let r=t*i*e,a=i*i*t*t*e,o=Math.exp(-r),s=NB(t*t,i);return(-n(t)+IB>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=FB(n,r,a),s=o*MB(i,o*e),c=s*s;return{stiffness:c,damping:i*2*Math.sqrt(c),duration:NR(e)}}var RB=(e,t)=>(t?e>=0:e>0)&&e<1/0;function zB(e,t){if(RB(e,t))return e}function BB(e){let t=zB(e.stiffness),n=zB(e.damping,!0),r=zB(e.mass),i={...e,stiffness:t??AB.stiffness,damping:n??AB.damping,mass:r??AB.mass,isResolvedFromDuration:!1,isTimeDefined:(t??n??r)===void 0&&(e.duration!==void 0||e.bounce!==void 0)};if(i.isTimeDefined){if(e.visualDuration){let t=jB(e.bounce||0),n=2*Math.PI/(e.visualDuration*1.2)*MB(t,2*Math.PI/1.2);i.stiffness=n*n,i.damping=2*t*Math.sqrt(i.stiffness)}else Object.assign(i,LB(i)),i.isResolvedFromDuration=!0;(!RB(i.stiffness)||!RB(i.damping,!0))&&(i.stiffness=AB.stiffness,i.damping=AB.damping)}return i}function VB(e=AB.visualDuration,t=AB.bounce){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}=BB({...n}),f=e=>d?0:-PR(e),p=s/(2*Math.sqrt(o*c)),m=PR(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?AB.restSpeed.granular:AB.restSpeed.default),g.restDelta=n.restDelta||(e?AB.restDelta.granular:AB.restDelta.default)};_();let v,y,b;if(p<1){let e=NB(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=d?1/0:300/e,i=(e,t)=>Math.exp(t>r?-e*r-h*(t-r):-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=>NR(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=NR(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(OB(S),DB),t=EB(t=>S.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return S}VB.applyToOptions=e=>{let t=kB(e,100,VB);return e.ease=t.ease,e.duration=NR(t.duration),e.type=`keyframes`,e};function HB({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===void 0?g:o(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?_:_+t},b,x,S=e=>{p(f.value)&&(b=e,x=VB({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 UB(e,t,n){let r=[],i=n||wR.mix||_B,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=AR(Array.isArray(t)?t[n]||kR:t,a)),r.push(a)}return r}function WB(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,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=UB(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=jR(e[r],e[r+1],n);return s[r](i)};return n?t=>l(CR(e[0],e[a-1],t)):l}function GB(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=jR(0,t,r);e.push(tB(n,1,i))}}function KB(e){let t=[0];return GB(t,e.length-1),t}function qB(e,t){return e.map(e=>e*t)}function JB(e,t){return e.map(()=>t||YR).splice(0,e.length-1)}function YB({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=XR(r)?r.map(ez):ez(r)||YR,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:(wR.mix||_B)(n,r);return{calculatedDuration:e,next:t=>(a.value=o?o(i(e>0?CR(0,1,t/e):1)):r,a.done=t>=e,a)}}let o=WB(qB(n&&n.length===t.length?n:KB(t),e),t,{ease:Array.isArray(i)?i:JB(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var XB=5;function ZB(e,t,n){let r=Math.max(t-XB,0);return FR(n-e(r),t-r)}function QB(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):ZB(t=>e.next(t).value,t,e.next(t).value)}var $B=e=>e!==null;function eV(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter($B),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var tV={decay:HB,inertia:HB,tween:YB,keyframes:YB,spring:VB};function nV(e){typeof e.type==`string`&&(e.type=tV[e.type])}var rV=40,iV=(e,t)=>t-e>rV&&!wR.useManualTiming?t:e;function aV(e,t){return{kind:e,animation:t,timestamp:iz.now(),frameTimestamp:tz.timestamp,frameIsProcessing:tz.isProcessing}}function oV(e,t,n){let r=globalThis.__MOTION_INSPECT__;if(r)try{r({...aV(`animation-start`,e),options:n?{...t,...n}:t})}catch{}}function sV(e,t){let n=globalThis.__MOTION_INSPECT__;if(n)try{n({...aV(`layout-animation-start`,e),node:t})}catch{}}var cV=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)}},lV=e=>e/100,uV=e=>Math.round(e*1e4)/1e4,dV=class extends cV{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!==iz.now()&&this.tick(iz.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),oV(this,this.options)}initAnimation(){let{options:e}=this;nV(e);let{type:t=YB,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||YB;s!==YB&&typeof o[0]!=`number`&&(this.mixKeyframes=AR(lV,_B(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=OB(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.currentTime=this.holdTime===null?t:this.holdTime}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=iV(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&&i!==null&&(p=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let m=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&p);return m&&s!==HB&&(f.value=eV(o,this.options,l,this.speed)),c&&c(f.value),m&&this.finish(),f}at(e){return this.holdTime??uV((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!==HB?eV(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=CR(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}then(e,t){return this.finished.then(e,t)}get duration(){return PR(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+PR(e)}get time(){return PR(this.currentTime)}set time(e){e=NR(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 QB(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(iz.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=PR(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=TB,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(iz.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.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}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)}},fV=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function pV(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(hz)||[];if(!r)return e;let i=n.replace(r,``),a=+!!fV.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var mV=/\b([a-z-]*)\(.*?\)/gu,hV={...Zz,getAnimatableNone:e=>{let t=e.match(mV);return t?t.map(pV).join(` `):e}},gV={...Zz,getAnimatableNone:e=>{let t=Zz.parse(e);return Zz.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},_V={...fz,transform:Math.round},vV={borderWidth:X,borderTopWidth:X,borderRightWidth:X,borderBottomWidth:X,borderLeftWidth:X,borderRadius:X,borderTopLeftRadius:X,borderTopRightRadius:X,borderBottomRightRadius:X,borderBottomLeftRadius:X,width:X,maxWidth:X,height:X,maxHeight:X,top:X,right:X,bottom:X,left:X,inset:X,insetBlock:X,insetBlockStart:X,insetBlockEnd:X,insetInline:X,insetInlineStart:X,insetInlineEnd:X,padding:X,paddingTop:X,paddingRight:X,paddingBottom:X,paddingLeft:X,paddingBlock:X,paddingBlockStart:X,paddingBlockEnd:X,paddingInline:X,paddingInlineStart:X,paddingInlineEnd:X,margin:X,marginTop:X,marginRight:X,marginBottom:X,marginLeft:X,marginBlock:X,marginBlockStart:X,marginBlockEnd:X,marginInline:X,marginInlineStart:X,marginInlineEnd:X,fontSize:X,backgroundPositionX:X,backgroundPositionY:X,rotate:Ez,pathRotation:Ez,rotateX:Ez,rotateY:Ez,rotateZ:Ez,scale:mz,scaleX:mz,scaleY:mz,scaleZ:mz,skew:Ez,skewX:Ez,skewY:Ez,distance:X,translateX:X,translateY:X,translateZ:X,x:X,y:X,z:X,perspective:X,transformPerspective:X,opacity:pz,originX:Az,originY:Az,originZ:X,zIndex:_V,fillOpacity:pz,strokeOpacity:pz,numOctaves:_V},yV={...vV,color:Mz,backgroundColor:Mz,outlineColor:Mz,fill:Mz,stroke:Mz,borderColor:Mz,borderTopColor:Mz,borderRightColor:Mz,borderBottomColor:Mz,borderLeftColor:Mz,filter:hV,WebkitFilter:hV,mask:gV,WebkitMask:gV},bV=e=>yV[e],xV=new Set([hV,gV]);function SV(e,t){let n=bV(e);return xV.has(n)||(n=Zz),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function CV(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var wV=e=>e*180/Math.PI,TV=e=>DV(wV(Math.atan2(e[1],e[0]))),EV={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:TV,rotateZ:TV,skewX:e=>wV(Math.atan(e[1])),skewY:e=>wV(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},DV=e=>(e%=360,e<0&&(e+=360),e),OV=TV,kV=e=>Math.hypot(e[0],e[1]),AV=e=>Math.hypot(e[4],e[5]),jV={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:kV,scaleY:AV,scaleZ:e=>Math.hypot(e[8],e[9],e[10]),scale:e=>(kV(e)+AV(e))/2,rotateX:e=>DV(wV(Math.atan2(e[6],e[5]))),rotateY:e=>DV(wV(Math.atan2(-e[2],e[0]))),rotateZ:OV,rotate:OV,skewX:e=>wV(Math.atan(e[4])),skewY:e=>wV(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function MV(e){return+!!e.includes(`scale`)}function NV(e,t){if(!e||e===`none`)return MV(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=jV,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=EV,i=t}if(!i)return MV(t);let a=r[t],o=i[1].split(`,`).map(FV);return typeof a==`function`?a(o):o[a]}var PV=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return NV(n,t)};function FV(e){return parseFloat(e.trim())}var IV=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`scaleZ`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],LV=new Set([...IV,`pathRotation`]),RV=e=>e===fz||e===X,zV=new Set([`x`,`y`,`z`]),BV=IV.filter(e=>!zV.has(e));function VV(e){let t=[];return BV.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 HV=new Set([`bottom`,`right`]);function UV(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 WV={width:({width:e,paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r},i)=>UV(e,i,`x`,t,n,r),height:({height:e,paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r},i)=>UV(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:({transform:e})=>NV(e,`x`),y:({transform:e})=>NV(e,`y`)};WV.translateX=WV.x,WV.translateY=WV.y;var GV=new Set,KV=!1,qV=!1,JV=!1;function YV(){if(qV){let e=[],t=new Set,n=new Set;GV.forEach(r=>{r.needsMeasurement&&(e.push(r),t.add(r.element),HV.has(r.name)&&n.add(r.element))});let r=new Map;n.forEach(e=>{let t=VV(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)})}qV=!1,KV=!1,GV.forEach(e=>e.complete(JV)),GV.clear()}function XV(){GV.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(qV=!0)})}function ZV(){JV=!0,XV(),YV(),JV=!1}function QV(e,t,n){if(typeof e==`string`){if(TR(e)||DR(e))return parseFloat(e);if(!Zz.test(e)&&Zz.test(n))return SV(t,n)}return e??void 0}var $V=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?(GV.add(this),KV||(KV=!0,SB.read(XV),SB.resolveKeyframes(YV))):(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=QV(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])}CV(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),GV.delete(this)}cancel(){this.state===`scheduled`&&(GV.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},eH=e=>e.startsWith(`--`);function tH(e,t,n){eH(t)?e.style.setProperty(t,n):e.style[t]=n}var nH={};function rH(e,t){let n=OR(e);return()=>nH[t]??n()}var iH=rH(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),aH=rH(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),oH=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,sH={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:oH([0,.65,.55,1]),circOut:oH([.55,0,1,.45]),backIn:oH([.31,.01,.66,-.59]),backOut:oH([.33,1.53,.69,.99])};function cH(e,t){if(e)return typeof e==`function`?aH()?EB(e,t):`ease-out`:ZR(e)?oH(e):Array.isArray(e)?e.map(e=>cH(e,t)||sH.easeOut):sH[e]}function lH(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=cH(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 uH(e){return typeof e==`function`&&`applyToOptions`in e}function dH({type:e,...t}){return uH(e)&&aH()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var fH=class extends cV{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,e.type;let c=dH(e);this.animation=lH(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=eV(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),tH(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()},oV(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(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e!==`idle`&&e!==`finished`&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||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 PR(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+PR(e)}get time(){return PR(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=NR(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&&iH()?(this.animation.timeline=e,t?.(this.animation),kR):n(this)}},pH={anticipate:UR,backInOut:HR,circInOut:KR};function mH(e){return e in pH}function hH(e){typeof e.ease==`string`&&mH(e.ease)&&(e.ease=pH[e.ease])}var gH=class extends fH{constructor(e){hH(e),nV(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}elapsed(){return this.state===`running`?(iz.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 dV({...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?CR(0,10,a):0,s=this.sample(a);n&&r&&tH(n,r,s),t.setWithVelocity(this.sample(a-o*Math.sign(i)),s,o/Math.abs(i||1))}},_H=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Zz.test(e)||e===`0`)&&!e.startsWith(`url(`));function vH(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 yH(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=_H(i,t),s=_H(a,t);return!o||!s?(o!==s&&`${t}${i}${a}${o?a:i}`,!1):vH(e)||(n===`spring`||uH(n))&&r}function bH(e){e.duration=0,e.type=`keyframes`}var xH=new Set([`opacity`,`clipPath`,`filter`,`transform`,`backgroundColor`]),SH=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function CH(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&SH.test(e[t]))return!0;return!1}var wH=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),TH=OR(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function EH(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!n||!(xH.has(n)||wH.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 TH()&&(xH.has(n)||wH.has(n)&&CH(s))&&(n!==`transform`||!u)&&!l&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var DH=(e,t)=>t&&typeof e==`number`?t.transform(e):e,OH={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},kH=IV.length;function AH(e,t,n){let r=``,i=!0;for(let a=0;a<kH;a++){let o=IV[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=DH(s,vV[o]);if(!c){i=!1;let t=OH[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${DH(a,vV.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}var jH=new WeakMap,MH=200,NH=.001,PH=.1,FH=.001,IH=100,LH=e=>/^(linear|ease(In|Out|InOut))$/.test(e),RH=(e,t)=>e-t,zH=(e,t,n)=>{let r=[];for(let i=0;i<=n;i++)r.push(tB(e,t,i/n));return r},BH=e=>e.motionValue.owner,VH=e=>jH.get(e),HH=(e,t)=>e.latestValues?e.latestValues[t]:e.getValue(t)?.get(),UH=({name:e,motionValue:t})=>e&&IV.includes(e)&&t?.owner?.current instanceof HTMLElement&&TH()&&aH();function WH(e){let t=BH(e),{onUpdate:n,transformTemplate:r}=t.getProps();return!e.isHandoff&&!n&&!e.hasOnUpdate&&!r&&e.type!==`inertia`&&(HH(t,`transform`)||`none`)===`none`&&!HH(t,`pathRotation`)&&!t.projection?.isProjecting()}var GH=class extends dV{constructor(e){let t=BH(e).current,{driver:n=TB}=e,r=WH(e);e.driver=e=>{let r=n(e);return{js:r,now:r.now,start:(e=!0)=>{let n=VH(t);!n||n.isJS?r.start(e):n.schedule(!1,!e)},stop:()=>{r.stop();let e=VH(t);e?.schedule(!e.isFinishing)}}},super(e),this.canAccelerate=r;let{stop:i}=this;this.stop=()=>{this.isAccelerated()&&this.sync(),i()}}get group(){return VH(BH(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(iz.now()):void 0}tween(){let{keyframes:e,type:t,ease:n,times:r,repeat:i,delay:a=0}=this.options,o=ZR(n)?oH(n):LH(n)&&sH[n];if(o&&!i&&!r&&e.length===2&&t===YB&&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||YB)===YB?u||KB(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=iz.now();this.options.motionValue.setWithVelocity(this.sampleAt(e-10,!0),this.sampleAt(e,!0),10)}play(){this.isStopped||((this.group||KH(BH(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(iz.now())}get time(){return this.isAccelerated()?PR(CR(0,this.totalDuration,this.at(iz.now())-(this.options.delay||0))):super.time}set time(e){super.time=e}attachTimeline(e){return this.canAccelerate=!1,this.group?.demote(!0),super.attachTimeline(e)}};function KH(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/0,f=e=>{for(let t of n)if(t.name===e)return!0},p=(t,n)=>{let o={};for(let s of t===void 0?IV:a){let a=r.get(s),c=t===void 0?HH(e,s):a?a.sampleAt(n>t&&!a.timing()[1]?n:t):i[s];c!==void 0&&(o[s]=c)}return o},m=(e,t)=>{let n=``,r=p(e,t);for(let e in r)n+=(OH[e]||e)+`(`+DH(r[e],vV[e])+`) `;return n||`none`},h=(e=p())=>{t.style.transform=AH(e,{})},g=(e=!0)=>{e&&h(),s.forEach(({animation:e})=>e.cancel()),s=[]},_=(e,t,n=1/0)=>{let r={animation:e,offset:t,end:n};e.startTime=iz.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)),E.schedule(!1)}),e.oncancel=()=>s.includes(r)&&E.demote(),s.push(r)},v=(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]:[]},y=(e,t,n,r)=>{let i=Math.min(MH,Math.max(2,Math.ceil((n-t)/10)));if(r.length*4>i)return;let a=zH(t,n,i).concat(r).sort(RH),o=e=>jR(t,n,e),s,c;for(let t of e){let e=a.map(e=>t.numberAt(e)),[n]=e,r=e[e.length-1]-n,i=e.map(e=>r?(e-n)/r:e-n);if(!r){if(i.some(e=>!(Math.abs(e)<=NH)))return}else if(!s)s=i,c=e=>(t.numberAt(e)-n)/r;else if(i.some((e,t)=>!(Math.abs(e-s[t])<=NH)))return}if(!s||s.every((e,t)=>Math.abs(e-o(a[t]))<=NH))return`linear`;let l=[],u=(e,t=c(e))=>l.push(uV(t)+` `+uV(o(e)*100)+`%`);return s.forEach((e,t)=>{t&&Math.abs(e-s[t-1])>.2&&v(c,a[t-1],a[t]).forEach(e=>u(e)),u(a[t],e)}),`linear(`+l+`)`},b=(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`)?FH:PH))),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(...v(e=>r.numberAt(e),t,n));i.push(n)}},s=zH(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(RH))e>c&&o(c,e,0),c=e;return i.sort(RH)},x=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},S=(e,n,r,i={fill:`both`},a,o)=>{let s=e.flatMap(e=>e.boundaries(n,r)),c=o||y(e,n,r,s),l=c?[n,r]:b(e,n,r,s),u=l.map(e=>m(e,a)),d={transform:u};return c||(d.offset=l.map(e=>jR(n,r,e))),u.every(e=>e===u[0])&&(h(p(n,a)),d=null),t.animate(d,{...i,duration:r-n,easing:c||`linear`})},C=c=>{let l=c,u=0,d=0,f=[],p=[],m=new Set;r.clear(),o=new Map;for(let e of n){r.set(e.name,e);let[t,n]=e.timing(),i=t===1/0;if(o.set(e,[e.at(c),e.speed,i]),i)e.sync();else{if(e.speed<0)return;if(n){if(u){let e=(t-d)/n;if(Math.abs(n-u)>1||Math.abs(e-Math.round(e))*u>1)return}else u=n,d=t;p.push(e)}else m.add(t);f.push(e),l=Math.max(l,t)}}i={},a=IV.filter(t=>{if(r.has(t))return!0;let n=i[t]=HH(e,t);return n!==void 0&&parseFloat(n)!==+!!t.startsWith(`scale`)}),g(!1);let h=!u&&x(f);try{if(h&&h[1]>c){let[e,t,n]=h;_(S(f,e,t,void 0,void 0,n),e-c,t-e)}else l>c&&(_(S(f,c,l),0,l-c),m.forEach(e=>e<l-1&&_(t.animate(null,{duration:e-c}),0,e-c)));if(u){let e=d+Math.floor((l-d)/u)*u;_(S(p,e,e+u,{iterations:1/0,iterationStart:(l-e)/u,fill:`forwards`},l),l-c)}}catch{return}return s.length||g(),!0},w=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.playbackRate=r,n.startTime=e-o/r):(n.pause(),n.currentTime=o)}return!0},T=()=>{let r=iz.now();if(E.isJS||(E.isFinishing=!0,n.forEach(t=>{let[n,a]=t.timing();t.state===`running`&&t.speed>0&&!a&&n<=r+1&&(t.complete(),i[t.name]=HH(e,t.name),o.has(t)||(c=!0))}),E.isFinishing=!1),l=!1,n.forEach(({state:e},t)=>{(e===`idle`||e===`finished`)&&n.delete(t)}),!n.size){jH.delete(t),E.isJS||g();return}for(let e of n)if(!e.canAccelerate)return E.demote(!0);E.isJS&&(E.isJS=!1,c=!0,n.forEach(e=>e.js?.stop()));let a=c,s=u;if(c=u=!1,a||!w(r)){if(s){if(r-d<IH)return E.demote();d=r}if(!C(r))return E.demote()}},E={tracks:n,isJS:!1,isFinishing:!1,schedule(e,t){c||=e,u||=!!t,l||(l=!0,tz.isProcessing?SB.render(T,!1,!0):queueMicrotask(T))},check(){if(!E.isJS){for(let t in i)if(HH(e,t)!==i[t]&&!f(t))return E.schedule(!0,!0)}},demote(e){E.isJS||(n.forEach(t=>{t.isAccelerated()&&t.sync(),e||(t.canAccelerate=!1)}),E.isJS=!0,o=new Map,g(),n.forEach(e=>e.state===`running`&&e.js?.start()))}};return jH.set(t,E),E}var qH=class extends cV{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=iz.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||$V;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=iz.now();let u=!0;yH(e,i,a,o)||(u=!1,(wR.instantAnimations||!s)&&l?.(eV(e,n,t)),e[0]=e[e.length-1],bH(n),n.repeat=0);let{onComplete:d}=n;n.finalKeyframe=t,n.keyframes=e,n.onComplete=()=>{d?.(),this.notifyFinished()};let f=u&&!c&&EH(n),p=!f&&UH(n);r&&(f||p||this.resolvedAt!==this.createdAt)&&(n.startTime??=iV(this.createdAt,this.resolvedAt));let m;if(f){n.element=n.motionValue?.owner?.current;try{m=new gH(n)}catch{m=new dV(n)}}else m=p?new GH(n):new dV(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(),ZV()),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&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function JH(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 YH=30,XH=e=>!isNaN(parseFloat(e)),ZH={current:void 0},QH=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=iz.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.notifyChange(),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=iz.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=XH(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 MR)).add(t)}onChangeSubscribe(e){let{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new MR,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(){SB.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&&this.stopPassiveEffect()}dirty(){this.notifyChange()}notifyChange(){let{current:e,changeSubscriber:t}=this;t?t(e):this.events.change?.notify(e)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){ZH.current&&ZH.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=iz.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>YH)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,YH);return FR(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.clearAnimation(),t()}),n||(this.animation=r),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){this.animation=void 0}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function $H(e,t){return new QH(e,t)}function eU(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function tU(e,t){let n=e?.[t]??e?.default??e;return n===e?n:eU(n,e)}var nU={type:`spring`,stiffness:500,damping:25,restSpeed:10},rU=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),iU={type:`keyframes`,duration:.8},aU={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},oU=(e,{keyframes:t})=>t.length>2?iU:LV.has(e)?e.startsWith(`scale`)?rU(t[1]):nU:aU,sU=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function cU(e){for(let t in e)if(!sU.has(t))return!0;return!1}var lU=(e,t,n,r={},i,a)=>o=>{let s=tU(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=NR(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};cU(s)||Object.assign(u,oU(e,u)),u.duration&&=NR(u.duration),u.repeatDelay&&=NR(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(bH(u),u.delay===0&&(d=!0)),(wR.instantAnimations||wR.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,bH(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=eV(u.keyframes,s);if(e!==void 0){SB.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new dV(u):new qH(u)},uU=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function dU(e){let t=uU.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function fU(e,t,n=1){`${e}`;let[r,i]=dU(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return TR(e)?parseFloat(e):e}return lz(i)?fU(i,t,n+1):i}function pU(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function mU(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...pU(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function hU(e,t,n){return mU(e.getProps(),t,n,e)}var gU=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,_U=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...IV]),vU=e=>Array.isArray(e);function yU(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,$H(n))}function bU(e){return vU(e)?e[e.length-1]||0:e}function xU(e,t){let{transitionEnd:n={},transition:r={},...i}=hU(e,t)||{};i={...i,...n};for(let t in i)yU(e,t,bU(i[t]))}var SU=e=>!!(e&&e.getVelocity);function CU(e){return!!(SU(e)&&e.add)}function wU(e,t){let n=e.getValue(`willChange`);if(CU(n))return n.add(t);if(!n&&wR.WillChange){let n=new wR.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function TU(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var EU=`data-`+TU(`framerAppearId`);function DU(e){return e.props[EU]}var OU=typeof window<`u`;function kU({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function AU(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?eU(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.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&&kU(f,t))continue;let o={delay:n,...tU(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){SB.update(()=>r.set(i));continue}let p=!1;if(OU&&window.MotionHandoffAnimation){let n=DU(e);if(n){let e=window.MotionHandoffAnimation(n,t,SB);e!==null&&(o.startTime=e,p=!0)}}wU(e,t);let m=l??e.shouldReduceMotion;r.start(lU(t,r,i,m&&_U.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>SB.update(()=>{o&&xU(e,o)});d.length?Promise.all(d).then(t):t()}return d}function jU(e,t,n={}){let r=hU(e,t,gU(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?AU(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(jU(e,t,{...n,delay:r+(typeof o==`function`?0:o)+JH(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 MU(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>jU(e,t,n))):typeof t==`string`?jU(e,t,n):Promise.all(AU(e,hU(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var NU={test:e=>e===`auto`,parse:e=>e},PU=e=>t=>t.test(e),FU=[fz,X,Dz,Ez,kz,Oz,NU],IU=e=>FU.find(PU(e));function LU(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||DR(e)}var RU=new Set([`auto`,`none`,`0`]);function zU(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!RU.has(t)&&Uz(t)&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]!==i&&(e[r]=SV(n,i))}var BU=class extends $V{constructor(e,t,n,r,i){super(e,t,n,r,i,!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(dz(t?e[t]:r))return!1;return!0}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),lz(r))){let i=fU(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!_U.has(n)||e.length!==2)return;let[r,i]=e;if(typeof r==`number`&&typeof i==`number`)return;let a=IU(r),o=IU(i);if(dz(r)!==dz(i)&&WV[n])this.needsMeasurement=!0;else if(a!==o){if(RV(a)&&RV(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else WV[n]&&(this.needsMeasurement=!0)}}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||LU(e[t]))&&n.push(t);n.length&&zU(e,n,t)}measure(){let{element:e,name:t}=this;return WV[t](window.getComputedStyle(e.current),()=>e.measureViewportBox())}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!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||!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.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},VU=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function HU(e){return ER(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function UU(e){return ER(e)&&`ownerSVGElement`in e}function WU(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}function GU(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(LV.has(e))o=!0;else if(sz(e))i[e]=n;else{let t=DH(n,vV[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=AH(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 KU={offset:`stroke-dashoffset`,array:`stroke-dasharray`},qU={offset:`strokeDashoffset`,array:`strokeDasharray`};function JU(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?KU:qU;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var YU=[`transform`,`opacity`,`clipPath`,`filter`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function XU(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(GU(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 YU)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&&JU(d,i,a,o,!1)}function ZU({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function QU({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function $U(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 eW(e){return e===void 0||e===1}function tW({scale:e,scaleX:t,scaleY:n}){return!eW(e)||!eW(t)||!eW(n)}function nW(e){return tW(e)||rW(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function rW(e){return iW(e.x)||iW(e.y)}function iW(e){return e&&e!==`0%`}function aW(e,t,n){return n+t*(e-n)}function oW(e,t,n,r,i){return i!==void 0&&(e=aW(e,i,r)),aW(e,n,r)+t}function sW(e,t=0,n=1,r,i){e.min=oW(e.min,t,n,r,i),e.max=oW(e.max,t,n,r,i)}function cW(e,{x:t,y:n}){sW(e.x,t.translate,t.scale,t.originPoint),sW(e.y,n.translate,n.scale,n.originPoint)}var lW=.999999999999,uW=1.0000000000001;function dW(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;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(fW(e.x,-a.scroll.offset.x),fW(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,cW(e,o)),r&&nW(a.latestValues)&&hW(e,a.latestValues,a.layout?.layoutBox))}t.x<uW&&t.x>lW&&(t.x=1),t.y<uW&&t.y>lW&&(t.y=1)}function fW(e,t){e.min+=t,e.max+=t}function pW(e,t,n,r,i=.5){sW(e,t,n,tB(e.min,e.max,i),r)}function mW(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function hW(e,t,n){let r=n??e;pW(e.x,mW(t.x,r.x),t.scaleX,t.scale,t.originX),pW(e.y,mW(t.y,r.y),t.scaleY,t.scale,t.originY)}function gW(e,t){return ZU($U(e.getBoundingClientRect(),t))}function _W(e,t,n){let r=gW(e,n),{scroll:i}=t;return i&&(fW(r.x,i.offset.x),fW(r.y,i.offset.y)),r}var{schedule:vW,cancel:Bae}=xB(queueMicrotask,!1),yW={x:!1,y:!1};function bW(){return yW.x||yW.y}function xW(e){return e===`x`||e===`y`?yW[e]?null:(yW[e]=!0,()=>{yW[e]=!1}):yW.x||yW.y?null:(yW.x=yW.y=!0,()=>{yW.x=yW.y=!1})}function SW(e,t){let n=WU(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function CW(e){return!(e.pointerType===`touch`||bW())}function wW(e,t,n={}){let[r,i,a]=SW(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(!CW(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 TW=(e,t)=>t?e===t||TW(e,t.parentElement):!1,EW=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,DW=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function OW(e){return DW.has(e.tagName)||e.isContentEditable===!0}var kW=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function AW(e){return kW.has(e.tagName)||e.isContentEditable===!0}var jW=new WeakSet;function MW(e){return t=>{t.key===`Enter`&&e(t)}}function NW(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var PW=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=MW(()=>{if(jW.has(n))return;NW(n,`down`);let e=MW(()=>{NW(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>NW(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function FW(e){return EW(e)&&!bW()}var IW=new WeakSet;function LW(e,t,n={}){let[r,i,a]=SW(e,n),o=e=>{let r=e.currentTarget;if(!FW(e)||IW.has(e))return;jW.add(r),n.stopPropagation&&IW.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),jW.has(r)&&jW.delete(r),FW(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||TW(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),HU(e)&&(e.addEventListener(`focus`,e=>PW(e,i)),!OW(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}var RW=new WeakMap,zW,BW=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:UU(r)&&`getBBox`in r?r.getBBox()[t]:r[n],VW=BW(`inline`,`width`,`offsetWidth`),HW=BW(`block`,`height`,`offsetHeight`);function UW({target:e,borderBoxSize:t}){RW.get(e)?.forEach(n=>{n(e,{get width(){return VW(e,t)},get height(){return HW(e,t)}})})}function WW(e){e.forEach(UW)}function GW(){typeof ResizeObserver<`u`&&(zW=new ResizeObserver(WW))}function KW(e,t){zW||GW();let n=WU(e);return n.forEach(e=>{let n=RW.get(e);n||(n=new Set,RW.set(e,n)),n.add(t),zW?.observe(e)}),()=>{n.forEach(e=>{let n=RW.get(e);n?.delete(t),n?.size||zW?.unobserve(e)})}}var qW=new Set,JW;function YW(){JW=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};qW.forEach(t=>t(e))},window.addEventListener(`resize`,JW)}function XW(e){return qW.add(e),JW||YW(),()=>{qW.delete(e),!qW.size&&typeof JW==`function`&&(window.removeEventListener(`resize`,JW),JW=void 0)}}function ZW(e,t){return typeof e==`function`?XW(e):KW(e,t)}var QW={value:null,addProjectionMetrics:null};function $W(e){return UU(e)&&e.tagName===`svg`}function eG(...e){let t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],i=e[1+n],a=e[2+n],o=e[3+n],s=WB(i,a,o);return t?s(r):s}var tG=e=>typeof e==`number`?e:parseFloat(e),nG=()=>({translate:0,scale:1,origin:0,originPoint:0}),rG=()=>({x:nG(),y:nG()}),iG=()=>({min:0,max:0}),aG=()=>({x:iG(),y:iG()}),oG=new WeakMap;function sG(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function cG(e){return typeof e==`string`||Array.isArray(e)}var lG=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],uG=[`initial`,...lG];function dG(e){if(sG(e.animate))return!0;for(let t=0;t<uG.length;t++)if(cG(e[uG[t]]))return!0;return!1}function fG(e){return!!(dG(e)||e.variants)}function pG(e,t,n){for(let r in t){let i=t[r],a=n[r];if(SU(i))e.addValue(r,i);else if(SU(a))e.addValue(r,$H(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,$H(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var mG={current:null},hG={current:!1},gG=typeof window<`u`;function _G(){if(hG.current=!0,gG){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>mG.current=e.matches;e.addEventListener(`change`,t),t()}else mG.current=!1}}var vG=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],yG={};function bG(e){yG=e}function xG(){return yG}var SG=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=$V,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=iz.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,SB.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=dG(t),this.isVariantNode=fG(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&&SU(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,oG.set(e,this),this.projection&&!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:(hG.current||_G(),this.shouldReduceMotion=mG.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),CB(this.notifyUpdate),CB(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&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,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&xH.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new fH({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:NR(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=LV.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&SB.preRender(this.notifyUpdate),n&&(this.projection&&(this.projection.isTransformDirty=!0),jH.get(this.current)?.check()),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&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 yG){let t=yG[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):aG()}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)&&jH.get(this.current)?.demote(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<vG.length;t++){let n=vG[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=pG(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}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);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=$H(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`&&(TR(n)||DR(n))?n=parseFloat(n):typeof n!=`number`&&!Zz.test(n)&&Zz.test(t)&&(n=SV(e,t)),this.setBaseTarget(e,SU(n)?n.get():n)),SU(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return this.events[e]||(this.events[e]=new MR),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){vW.render(this.render)}},CG=class extends SG{constructor(){super(...arguments),this.KeyframeResolver=BU}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;SU(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},wG=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function TG(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])}var EG={};function DG(e,{layout:t,layoutId:n}){return LV.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!EG[e]||e===`opacity`)}function OG(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(SU(r[t])||i&&SU(i[t])||DG(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function kG(e){return window.getComputedStyle(e)}var AG=class extends CG{constructor(){super(...arguments),this.type=`html`,this.renderInstance=TG}mount(e){e.style,super.mount(e)}readValueFromInstance(e,t){if(LV.has(t))return this.projection?.isProjecting?MV(t):PV(e,t);{let n=kG(e),r=(sz(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return gW(e,t)}build(e,t,n){GU(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return OG(e,t,n)}},jG=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`]),MG=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function NG(e,t,n,r){TG(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(jG.has(n)?n:TU(n),t.attrs[n])}function PG(e,t,n){let r=OG(e,t,n);for(let n in e)if(n!==`children`&&(SU(e[n])||SU(t[n]))){let t=IV.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var FG=class extends CG{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=aG}getBaseTargetFromProps(e,t){return LV.has(t)?super.getBaseTargetFromProps(e,t)??MV(t):e[t]}getDefaultValue(e){return LV.has(e)?this.latestValues[e]??MV(e):void 0}readValueFromInstance(e,t){if(LV.has(t)){let e=bV(t);return e&&e.default||0}if(YU.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=jG.has(t)?t:TU(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return PG(e,t,n)}build(e,t,n){XU(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){NG(e,t,n,r)}mount(e){this.isSVGTag=MG(e.tagName),super.mount(e)}};function IG(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 LG=[...lG].reverse();function RG(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>MU(e,t,n))),n=BG(),r=!0,i=!1;function a(a){let{props:o,parent:s,manuallyAnimateOnMount:c}=e,l=r||i,u=[],d=new Set,f={},p=1/0,m=e;do m=m.props.inherit!==!1&&m.parent;while(m&&!m.isControllingVariants);if(LG.forEach((t,r)=>{let i=n[t],h=o[t],g=m&&m.props[t],_=h===void 0?cG(g)||g===!1?g:void 0:h,v=cG(_),y=t===a?i.isActive:null;y===!1&&(p=r);let b=v&&h===void 0&&!(l&&c);if(i.protectedKeys={...f},!i.isActive&&y===null||!_&&!i.prevProp||sG(_)||typeof _==`boolean`)return;if(t===`exit`&&i.isActive&&y!==!0){f={...f,...i.prevResolvedValues};return}let x=zG(i.prevProp,_),S=x||v&&(y&&!b||r>p),C=!1,w=Array.isArray(_)?_:[_],T={};if(y!==!1)for(let n of w){let{transition:r,transitionEnd:i,...a}=hU(e,n,gU(e,t))||{};T={...T,...a,...i}}let{prevResolvedValues:E}=i;for(let t in{...E,...T}){if(t in f)continue;let n=T[t],r=E[t],a=Array.isArray(n)&&Array.isArray(r)?!IG(n,r)||x:n!==r;if(a&&n==null)d.add(t);else if(a||n!==void 0&&d.has(t)){S=!0,d.delete(t)&&(C=!0),i.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)}else i.protectedKeys[t]=!0}if(i.prevProp=_,i.prevResolvedValues=T,i.isActive&&(f={...f,...T}),S&&(!(b&&x)||C))for(let n of w){let r={type:t};if(typeof n==`string`&&l&&c&&s?.enteringChildren){let t=hU(s,n)?.transition?.delayChildren;r.delay=JH(s.enteringChildren,e,t)}u.push({animation:n,options:r})}}),d.size){let{initial:t}=o,n={},r=typeof t!=`boolean`&&hU(e,Array.isArray(t)?t[0]:t,e.presenceContext?.custom);r&&r.transition&&(n.transition=r.transition),d.forEach(i=>{let a=e.getValue(i);a&&(a.liveStyle=!0);let s=r&&!Array.isArray(t)?r[i]:void 0,c=e.getBaseTargetFromProps(o,i);n[i]=(s===void 0?c!==void 0&&!SU(c)?c:e.initialValues[i]===void 0?e.baseTarget[i]:void 0:s)??null}),u.push({animation:n})}let h=l&&e.blockInitialAnimation||r&&!c&&(o.initial===!1||o.initial===o.animate);return r=i=!1,!h&&u.length?t(u):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=BG(),i=!0}}}function zG(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!IG(t,e):!1}function BG(){let e={};for(let t of lG)e[t]={isActive:t===`animate`,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}};return e}function VG(e,t){e.min=t.min,e.max=t.max}function HG(e,t){VG(e.x,t.x),VG(e.y,t.y)}function UG(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var WG=.9999,GG=1.0001,KG=-.01,qG=.01;function JG(e){return e.max-e.min}function YG(e,t,n){return Math.abs(e-t)<=n}function XG(e,t,n,r=.5){e.origin=r,e.originPoint=tB(t.min,t.max,e.origin),e.scale=JG(n)/JG(t),e.translate=tB(n.min,n.max,e.origin)-e.originPoint,(e.scale>=WG&&e.scale<=GG||isNaN(e.scale))&&(e.scale=1),(e.translate>=KG&&e.translate<=qG||isNaN(e.translate))&&(e.translate=0)}function ZG(e,t,n,r){XG(e.x,t.x,n.x,r?r.originX:void 0),XG(e.y,t.y,n.y,r?r.originY:void 0)}function QG(e,t,n,r=0){e.min=(r?tB(n.min,n.max,r):n.min)+t.min,e.max=e.min+JG(t)}function $G(e,t,n,r){QG(e.x,t.x,n.x,r?.x),QG(e.y,t.y,n.y,r?.y)}function eK(e,t,n,r=0){let i=r?tB(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+JG(t)}function tK(e,t,n,r){eK(e.x,t.x,n.x,r?.x),eK(e.y,t.y,n.y,r?.y)}function nK(e,t,n,r,i){return e-=t,e=aW(e,1/n,r),i!==void 0&&(e=aW(e,1/i,r)),e}function rK(e,t=0,n=1,r=.5,i,a=e,o=e){if(Dz.test(t)&&(t=parseFloat(t),t=tB(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=tB(a.min,a.max,r);e===a&&(s-=t),e.min=nK(e.min,t,n,s,i),e.max=nK(e.max,t,n,s,i)}function iK(e,t,[n,r,i],a,o){rK(e,t[n],t[r],t[i],t.scale,a,o)}var aK=[`x`,`scaleX`,`originX`],oK=[`y`,`scaleY`,`originY`];function sK(e,t,n,r){iK(e.x,t,aK,n?n.x:void 0,r?r.x:void 0),iK(e.y,t,oK,n?n.y:void 0,r?r.y:void 0)}function cK(e){return e.translate===0&&e.scale===1}function lK(e){return cK(e.x)&&cK(e.y)}function uK(e,t){return e.min===t.min&&e.max===t.max}function dK(e,t){return uK(e.x,t.x)&&uK(e.y,t.y)}function fK(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function pK(e,t){return fK(e.x,t.x)&&fK(e.y,t.y)}function mK(e){return JG(e.x)/JG(e.y)}function hK(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function gK(e){return[e(`x`),e(`y`)]}function _K(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var vK={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if(X.test(e))e=parseFloat(e);else return e}return`${_K(e,t.target.x)}% ${_K(e,t.target.y)}%`}},yK={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Zz.parse(e);if(i.length>5)return r;let a=Zz.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=tB(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 bK(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,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}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`}var xK=VU.length,SK=e=>typeof e==`number`||X.test(e);function CK(e,t,n,r,i,a){i?(e.opacity=tB(0,n.opacity??1,TK(r)),e.opacityExit=tB(t.opacity??1,0,EK(r))):a&&(e.opacity=tB(t.opacity??1,n.opacity??1,r));for(let i=0;i<xK;i++){let a=VU[i],o=wK(t,a),s=wK(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||SK(o)===SK(s)?(e[a]=Math.max(tB(tG(o),tG(s),r),0),(Dz.test(s)||Dz.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=tB(t.rotate||0,n.rotate||0,r))}function wK(e,t){return e[t]===void 0?e.borderRadius:e[t]}var TK=DK(0,.5,GR),EK=DK(.5,.95,kR);function DK(e,t,n){return r=>r<e?0:r>t?1:n(jR(e,t,r))}function OK(e,t,n){let r=SU(e)?e:$H(e);return r.start(lU(``,r,t,n)),r.animation}function kK(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var AK=(e,t)=>e.depth-t.depth,jK=class{constructor(){this.children=[],this.isDirty=!1}add(e){bR(this.children,e),this.isDirty=!0}remove(e){xR(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(AK),this.isDirty=!1,this.children.forEach(e)}};function MK(e,t){let n=iz.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(CB(r),e(a-t))};return SB.setup(r,!0),()=>CB(r)}function NK(e){return SU(e)?e.get():e}var PK=class{constructor(){this.members=[]}add(e){bR(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&&(xR(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(xR(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)}},FK={borderRadius:{...vK,applyTo:[...VU]},borderTopLeftRadius:vK,borderTopRightRadius:vK,borderBottomLeftRadius:vK,borderBottomRightRadius:vK,boxShadow:yK},IK={hasAnimatedSinceResize:!0,hasEverUpdated:!1};Object.assign(EG,{...FK,...EG});var LK={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},RK=[``,`X`,`Y`,`Z`],zK=1e3,BK=0;function VK(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}var HK=({instance:e})=>e&&jH.get(e)?.demote();function UK(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=DU(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,SB,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&UK(r)}function WK({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=BK++,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,QW.value&&(LK.nodes=LK.calculatedTargetDeltas=LK.calculatedProjections=0),this.nodes.forEach(qK),this.nodes.forEach(iq),this.nodes.forEach(aq),this.nodes.forEach(JK),QW.addProjectionMetrics&&QW.addProjectionMetrics(LK)},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 jK)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new MR),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=UU(t)&&!$W(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&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;SB.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=MK(i,250),IK.hasAnimatedSinceResize&&(IK.hasAnimatedSinceResize=!1,this.nodes.forEach(rq)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isAnimationBlocked){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||fq,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!pK(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...tU(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||rq(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),CB(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(oq),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&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&UK(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;HK(this),this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,HK(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(ZK),this.nodes.forEach(XK);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(QK);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(eq),this.nodes.forEach(tq),this.nodes.forEach(nq),this.nodes.forEach(GK),this.nodes.forEach(KK)):this.nodes.forEach(QK),this.clearAllSnapshots();let e=iz.now();tz.delta=CR(0,1e3/60,e-tz.timestamp),tz.timestamp=e,tz.isProcessing=!0,wB.update.process(tz),wB.preRender.process(tz),wB.render.process(tz),tz.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,vW.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(YK),this.sharedNodes.forEach(sq)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,SB.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){SB.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),this.snapshot&&!JG(this.snapshot.measuredBox.x)&&!JG(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||=aG(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout;e&&HK(this);let t=this.projectionDelta&&!lK(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||nW(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)),gq(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return aG();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(vq))){let{scroll:e}=this.root;e&&(fW(t.x,e.offset.x),fW(t.y,e.offset.y))}return t}removeElementScroll(e){let t=aG();if(HG(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&&HG(t,e),fW(t.x,i.offset.x),fW(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||aG();HG(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(fW(r.x,-n.scroll.offset.x),fW(r.y,-n.scroll.offset.y)),nW(n.latestValues)&&hW(r,n.latestValues,n.layout?.layoutBox)}return nW(this.latestValues)&&hW(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=aG();HG(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!nW(n.latestValues))continue;let r;n.instance&&(tW(n.latestValues)&&n.updateSnapshot(),r=aG(),HG(r,n.measurePageBox())),sK(t,n.latestValues,n.snapshot?.layoutBox,r)}return nW(this.latestValues)&&sK(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}}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!==tz.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=tz.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=aG(),this.targetWithTransforms=aG()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),$G(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):HG(this.target,this.layout.layoutBox),cW(this.target,this.targetDelta)):HG(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),QW.value&&LK.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||tW(this.parent.latestValues)||rW(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=aG(),this.relativeTargetOrigin=aG(),tK(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),HG(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===tz.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;HG(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;dW(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=aG());let{target:s}=e;s?(!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(UG(this.prevProjectionDelta.x,this.projectionDelta.x),UG(this.prevProjectionDelta.y,this.projectionDelta.y)),ZG(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!hK(this.projectionDelta.x,this.prevProjectionDelta.x)||!hK(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),QW.value&&LK.calculatedProjections++):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=rG(),this.projectionDelta=rG(),this.projectionDeltaWithTransform=rG()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=rG();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=aG(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!(!c||u||this.options.crossfade!==!0||this.path.some(dq));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=tB(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=tB(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(cq(o.x,e.x,n),cq(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(tK(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),uq(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&dK(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=aG(),HG(f,this.relativeTarget)),c&&(this.animationValues=a,CK(a,i,this.latestValues,n,d,u)),r&&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&&=(CB(this.pendingAnimation),void 0),this.pendingAnimation=SB.update(()=>{IK.hasAnimatedSinceResize=!0,this.motionValue||=$H(0),this.motionValue.jump(0,!1),this.currentAnimation=OK(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()}}),sV(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&&this.mixTargetDelta(zK),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&&_q(this.options.animationType,this.layout.layoutBox,n.layoutBox)){i=this.target||aG();let t=JG(this.layout.layoutBox.x);i.x.min=e.target.x.min,i.x.max=i.x.min+t;let n=JG(this.layout.layoutBox.y);i.y.min=e.target.y.min,i.y.max=i.y.min+n}HG(t,i),hW(t,r),ZG(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new PK),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&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}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&VK(`z`,e,r,this.animationValues);for(let t=0;t<RK.length;t++)VK(`rotate${RK[t]}`,e,r,this.animationValues),VK(`skew${RK[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=NK(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=NK(t?.pointerEvents)||``),this.hasProjected&&!nW(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=bK(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,e.opacity=r.animationValues?r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in EG){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=EG[t],c=a===`none`?i[t]:n(i[t],r);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=r===this?NK(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(XK),this.root.sharedNodes.clear()}}}function GK(e){e.updateLayout(),$K(e)}function KK(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;if(i===`size`)gK(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=JG(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;VG(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else _q(i,t.layoutBox,n)&&gK(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=JG(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=rG();ZG(o,n,t.layoutBox);let s=rG();a?ZG(s,e.applyTransform(r,!0),t.measuredBox):ZG(s,n,t.layoutBox);let c=!lK(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=aG();tK(s,t.layoutBox,i.layoutBox,o);let c=aG();tK(c,n,a.layoutBox,o),pK(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function qK(e){QW.value&&LK.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 JK(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function YK(e){e.clearSnapshot()}function XK(e){e.clearMeasurements()}function ZK(e){e.isLayoutDirty=!0,e.updateLayout()}function QK(e){e.isLayoutDirty=!1}function $K(e){let{snapshot:t,dragAncestor:n}=e,r=n?.layout;if(!t||!r||e.resumeFrom||e.isAnimationBlocked)return;let i=n.dragSnapshot;gK(e=>fW(t.layoutBox[e],r.layoutBox[e].min-i.layoutBox[e].min))}function eq(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.dragSnapshot||e.layout,e.isLayoutDirty=!0)}function tq(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function nq(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function rq(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function iq(e){e.resolveTargetDelta()}function aq(e){e.calcProjection()}function oq(e){e.resetSkewAndRotation()}function sq(e){e.removeLeadSnapshot()}function cq(e,t,n){e.translate=tB(t.translate,0,n),e.scale=tB(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function lq(e,t,n,r){e.min=tB(t.min,n.min,r),e.max=tB(t.max,n.max,r)}function uq(e,t,n,r){lq(e.x,t.x,n.x,r),lq(e.y,t.y,n.y,r)}function dq(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var fq={duration:.45,ease:[.4,0,.1,1]},pq=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),mq=pq(`applewebkit/`)&&!pq(`chrome/`)?Math.round:kR;function hq(e){e.min=mq(e.min),e.max=mq(e.max)}function gq(e){hq(e.x),hq(e.y)}function _q(e,t,n){return e===`position`||e===`preserve-aspect`&&!YG(mK(t),mK(n),.2)}function vq(e){return e!==e.root&&e.scroll?.wasRoot}var yq=WK({attachResizeListener:(e,t)=>kK(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),bq={current:void 0},xq=WK({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!bq.current){let e=new yq({});e.mount(window),e.setOptions({layoutScroll:!0}),bq.current=e}return bq.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),Sq=(0,F.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Cq(e=!0){let t=(0,F.useContext)(yR);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,F.useId)();(0,F.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,F.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var wq=(0,F.createContext)({strict:!1}),Tq={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],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`]},Eq=!1;function Dq(){if(Eq)return;let e={};for(let t in Tq)e[t]={isEnabled:e=>Tq[t].some(t=>!!e[t])};bG(e),Eq=!0}function Oq(){return Dq(),xG()}function kq(e){let t=Oq();for(let n in e)t[n]={...t[n],...e[n]};bG(t)}var Aq=(0,F.createContext)({});function jq(e,t){if(dG(e)){let{initial:t,animate:n}=e;return{initial:t===!1||cG(t)?t:void 0,animate:cG(n)?n:void 0}}return e.inherit===!1?{}:t}function Mq(e){let{initial:t,animate:n}=jq(e,(0,F.useContext)(Aq));return(0,F.useMemo)(()=>({initial:t,animate:n}),[Nq(t),Nq(n)])}function Nq(e){return Array.isArray(e)?e.join(` `):e}var Pq=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Fq(e,t,n){for(let r in t)!SU(t[r])&&!DG(r,n)&&(e[r]=t[r])}function Iq({transformTemplate:e},t){return(0,F.useMemo)(()=>{let n=Pq();return GU(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Lq(e,t){let n=e.style||{},r={};return Fq(r,n,e),Object.assign(r,Iq(e,t)),r}function Rq(e,t){let n={},r=Lq(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 zq=()=>({...Pq(),attrs:{}});function Bq(e,t,n,r){let i=(0,F.useMemo)(()=>{let n=zq();return XU(n,t,MG(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Fq(t,e.style,e),i.style={...t,...i.style}}return i}var Vq=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 Hq(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||Vq.has(e)}function Uq(e,t){return e.startsWith(`on`)?!Hq(e):t?.(e)??!Hq(e)}function Wq(e,t,n,r){let i={};for(let a in e)(a!==`values`||typeof e.values!=`object`)&&(SU(e[a])||(Uq(a,r)||n===!0&&Hq(a)||!t&&!Hq(a)||e.draggable&&a.startsWith(`onDrag`))&&(i[a]=e[a]));return i}var Gq=[`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 Kq(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(Gq.indexOf(e)>-1||/[A-Z]/u.test(e))}function qq(e,t,n,{latestValues:r},i,a=!1,o,s){let c=(o??Kq(e)?Bq:Rq)(t,r,i,e),l=Wq(t,typeof e==`string`,a,s),u=e===F.Fragment?{}:{...l,...c,ref:n},{children:d}=t,f=(0,F.useMemo)(()=>SU(d)?d.get():d,[d]);return(0,F.createElement)(e,{...u,children:f})}function Jq({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Yq(n,r,i,e),renderState:t()}}function Yq(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=NK(a[e]);let{initial:o,animate:s}=e,c=dG(e),l=fG(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`&&!sG(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=mU(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 Xq=e=>(t,n)=>{let r=(0,F.useContext)(Aq),i=(0,F.useContext)(yR),a=()=>Jq(e,t,r,i);return n?a():_R(a)},Zq=Xq({scrapeMotionValuesFromProps:OG,createRenderState:Pq}),Qq=Xq({scrapeMotionValuesFromProps:PG,createRenderState:zq}),$q=Symbol.for(`motionComponentSymbol`);function eJ(e,t,n){let r=(0,F.useRef)(n);(0,F.useInsertionEffect)(()=>{r.current=n});let i=(0,F.useRef)(null);return(0,F.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 tJ=(0,F.createContext)({});function nJ(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function rJ(e,t,n,r,i,a){let{visualElement:o}=(0,F.useContext)(Aq),s=(0,F.useContext)(wq),c=(0,F.useContext)(yR),l=(0,F.useContext)(Sq),u=l.reducedMotion,d=l.skipAnimations,f=(0,F.useRef)(null),p=(0,F.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,F.useContext)(tJ);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&iJ(f.current,n,i,h);let g=(0,F.useRef)(!1);(0,F.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[EU],v=(0,F.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return vR(()=>{p.current&&m&&(m.animationState?.animateChanges(),m.enteringChildren=void 0)},[]),vR(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,F.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function iJ(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:aJ(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&nJ(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function aJ(e){if(e)return e.options.allowProjection===!1?aJ(e.parent):e.projection}function oJ(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&kq(r);let a=n?n===`svg`:Kq(e),o=a?Qq:Zq;function s(n,s){let c,l={...(0,F.useContext)(Sq),...n,layoutId:sJ(n)},{isStatic:u,isValidProp:d}=l,f=Mq(n),p=o(n,u);if(!u&&typeof window<`u`){cJ(l,r);let t=lJ(l);c=t.MeasureLayout,f.visualElement=rJ(e,p,l,i,t.ProjectionNode,a)}return(0,I.jsxs)(Aq.Provider,{value:f,children:[c&&f.visualElement?(0,I.jsx)(c,{visualElement:f.visualElement,...l}):null,qq(e,n,eJ(p,f.visualElement,s),p,u,t,a,d)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,F.forwardRef)(s);return c[$q]=e,c}function sJ({layoutId:e}){let t=(0,F.useContext)(gR).id;return t&&e!==void 0?t+`-`+e:e}function cJ(e,t){(0,F.useContext)(wq).strict}function lJ(e){let{drag:t,layout:n}=Oq();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function uJ(e,t){if(typeof Proxy>`u`)return oJ;let n=new Map,r=(n,r)=>oJ(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,oJ(a,void 0,e,t)),n.get(a))})}var dJ=(e,t)=>t.isSVG??Kq(e)?new FG(t):new AG(t,{allowProjection:e!==F.Fragment}),fJ=class extends wG{constructor(e){super(e),e.animationState||=RG(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();sG(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},pJ=0,mJ={animation:{Feature:fJ},exit:{Feature:class extends wG{constructor(){super(...arguments),this.id=pJ++}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}=hU(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))}unmount(){}}}};function hJ(e){return{point:{x:e.pageX,y:e.pageY}}}var gJ=e=>t=>EW(t)&&e(t,hJ(t));function _J(e,t,n,r){return kK(e,t,gJ(n),r)}var vJ=({current:e})=>e?e.ownerDocument.defaultView:null,yJ=(e,t)=>Math.abs(e-t);function bJ(e,t){let n=yJ(e.x,t.x),r=yJ(e.y,t.y);return Math.sqrt(n**2+r**2)}var xJ=new Set([`auto`,`scroll`]),SJ=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.removeScrollListeners=null,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=CJ(this.lastRawMoveEventInfo,this.transformPagePoint));let e=TJ(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=bJ(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e;this.history.push({...r,timestamp:iz.now()});let{onStart:i,onMove:a}=this.handlers;t||(i&&i(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),a&&a(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=CJ(t,this.transformPagePoint),this.hasPendingMove=!0,SB.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&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=TJ(e.type===`pointercancel`?this.lastMoveEventInfo:CJ(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!EW(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=CJ(hJ(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=tz;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,TJ(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=AR(_J(this.contextWindow,`pointermove`,this.handlePointerMove,d),_J(this.contextWindow,`pointerup`,this.handlePointerUp,d),_J(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(xJ.has(e.overflowX)||xJ.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},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),SB.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),CB(this.updatePoint)}};function CJ(e,t){return t?{point:t(e.point)}:e}function wJ(e,t){return{x:e.x-t.x,y:e.y-t.y}}function TJ({point:e},t){return{point:e,delta:wJ(e,DJ(t)),offset:wJ(e,EJ(t)),velocity:OJ(t,.1)}}function EJ(e){return e[0]}function DJ(e){return e[e.length-1]}function OJ(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=DJ(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>NR(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>NR(t)*2&&(r=e[1]);let a=PR(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}function kJ(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?tB(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?tB(n,e,r.max):Math.min(e,n)),e}function AJ(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 jJ(e,{top:t,left:n,bottom:r,right:i}){return{x:AJ(e.x,n,i),y:AJ(e.y,t,r)}}function MJ(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 NJ(e,t){return{x:MJ(e.x,t.x),y:MJ(e.y,t.y)}}function PJ(e,t){let n=.5,r=JG(e),i=JG(t);return i>r?n=jR(t.min,t.max-r,e.min):r>i&&(n=jR(e.min,e.max-i,t.min)),CR(0,1,n)}function FJ(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 IJ=.35;function LJ(e=IJ){return e===!1?e=0:e===!0&&(e=IJ),{x:RJ(e,`left`,`right`),y:RJ(e,`top`,`bottom`)}}function RJ(e,t,n){return{min:zJ(e,t),max:zJ(e,n)}}function zJ(e,t){return typeof e==`number`?e:e[t]||0}var BJ=new WeakMap,VJ=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=aG(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(e),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=xW(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),gK(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Dz.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=JG(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&SB.update(()=>i(e,t),!1,!0),wU(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(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;r&&this.currentDirection===null?(this.currentDirection=GJ(o),this.currentDirection!==null&&i&&i(this.currentDirection)):(this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&SB.update(()=>a(e,t),!1,!0))},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new SJ(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:vJ(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&SB.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!WJ(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=kJ(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&nJ(e)?this.constraints||=this.resolveRefConstraints():this.constraints=e&&n?jJ(n.layoutBox,e):!1,this.elastic=LJ(t),r!==this.constraints&&!nJ(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&gK(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=FJ(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!nJ(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=_W(n,r.root,this.visualElement.getTransformPagePoint()),a=NJ(r.layout.layoutBox,i);if(t){let e=t(QU(a));this.hasMutatedConstraints=!!e,e&&(a=ZU(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=gK(o=>{if(!WJ(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return wU(this.visualElement,e),n.start(lU(e,n,0,t,this.visualElement,!1))}stopAnimation(){gK(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[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();gK(e=>{if(!WJ(e,n,this.currentDirection))return;let t=this.getAxisMotionValue(e),{min:r,max:o}=a[e];t.set((t.get()||0)+i[e]-tB(r,o,.5))})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!nJ(t)||!n||!this.constraints)return;this.stopAnimation();let r=this.constraints,i={x:0,y:0};gK(e=>{let t=this.getAxisMotionValue(e).get();i[e]=PJ({min:t,max:t},r[e])});let{transformTemplate:a}=this.visualElement.getProps();this.visualElement.current.style.transform=a?a({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),gK(t=>{let n=this.getAxisMotionValue(t);if(!WJ(t,e,null)||!n.get())return;let{min:r,max:a}=this.constraints[t];n.set(tB(r,a,i[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;BJ.set(this.visualElement,this);let e=this.visualElement.current,t=_J(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&AW(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();nJ(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=UJ(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),SB.read(r);let o=kK(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(gK(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=IJ,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function HJ(e){let t=!0;return()=>{t?t=!1:e()}}function UJ(e,t,n){let r=ZW(e,HJ(n)),i=ZW(t,HJ(n));return()=>{r(),i()}}function WJ(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function GJ(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var KJ=class extends wG{constructor(e){super(e),this.removeGroupControls=kR,this.removeListeners=kR,this.controls=new VJ(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||kR}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},qJ=e=>(t,n)=>{e&&SB.update(()=>e(t,n),!1,!0)},JJ=class extends wG{constructor(){super(...arguments),this.removePointerDownListener=kR}onPointerDown(e){this.session=new SJ(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:vJ(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:qJ(e),onStart:qJ(t),onMove:qJ(n),onEnd:(e,t)=>{delete this.session,r&&SB.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=_J(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},YJ=!1,XJ=class extends F.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),YJ&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),IK.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a&&(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),YJ=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||SB.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),vW.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;YJ=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function ZJ(e){let[t,n]=Cq(),r=(0,F.useContext)(gR);return(0,I.jsx)(XJ,{...e,layoutGroup:r,switchLayoutGroup:(0,F.useContext)(tJ),isPresent:t,safeToRemove:n})}var QJ={pan:{Feature:JJ},drag:{Feature:KJ,ProjectionNode:xq,MeasureLayout:ZJ}};function $J(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&SB.postRender(()=>i(t,hJ(t)))}var eY=class extends wG{mount(){let{current:e}=this.node;e&&(this.unmount=wW(e,(e,t)=>($J(this.node,t,`Start`),e=>$J(this.node,e,`End`))))}unmount(){}},tY=class extends wG{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=AR(kK(this.node.current,`focus`,()=>this.onFocus()),kK(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function nY(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&SB.postRender(()=>i(t,hJ(t)))}var rY=class extends wG{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=LW(e,(e,t)=>(nY(this.node,t,`Start`),(e,{success:t})=>nY(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},iY=new WeakMap,aY=new WeakMap,oY=e=>{let t=iY.get(e.target);t&&t(e)},sY=e=>{e.forEach(oY)};function cY({root:e,...t}){let n=e||document;aY.has(n)||aY.set(n,{});let r=aY.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(sY,{root:e,...t})),r[i]}function lY(e,t,n){let r=cY(t);return iY.set(e,n),r.observe(e),()=>{iY.delete(e),r.unobserve(e)}}var uY={some:0,all:1},dY=class extends wG{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:uY[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=lY(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(fY(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function fY({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var pY={inView:{Feature:dY},tap:{Feature:rY},focus:{Feature:tY},hover:{Feature:eY}},mY={layout:{ProjectionNode:xq,MeasureLayout:ZJ}},hY=uJ({...mJ,...pY,...QJ,...mY},dJ);function gY(e){let t=_R(()=>$H(e)),{isStatic:n}=(0,F.useContext)(Sq);if(n){let[,n]=(0,F.useState)(e);(0,F.useEffect)(()=>t.on(`change`,n),[])}return t}function _Y(e,t){let n=gY(t()),r=()=>n.set(t());return r(),vR(()=>{let t=()=>SB.preRender(r,!1,!0),n=e.map(e=>e.on(`change`,t));return r(),()=>{n.forEach(e=>e()),CB(r)}}),n}function vY(e){ZH.current=[],e();let t=_Y(ZH.current,e);return ZH.current=void 0,t}function yY(e,t,n,r){if(typeof e==`function`)return vY(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!=`function`)return xY(e,t,n,r);let i=typeof t==`function`?t:eG(t,n,r),a=Array.isArray(e)?bY(e,i):bY([e],([e])=>i(e)),o=Array.isArray(e)?void 0:e.accelerate;if(o&&!o.isTransformed&&typeof t!=`function`&&Array.isArray(n)&&r?.clamp!==!1){let e=r?.ease;a.accelerate={...o,times:[0,...t,1],keyframes:[n[0],...n,n[n.length-1]],isTransformed:!0,...e?{ease:Array.isArray(e)?[e[0],...e]:e}:{}}}return a}function bY(e,t){let n=_R(()=>[]);return _Y(e,()=>{n.length=0;let r=e.length;for(let t=0;t<r;t++)n[t]=e[t].get();return t(n)})}function xY(e,t,n,r){let i=_R(()=>Object.keys(n)),a=_R(()=>({}));for(let o of i)a[o]=yY(e,t,n[o],r);return a}var SY=class{constructor(){this.componentControls=new Set}subscribe(e){return this.componentControls.add(e),()=>this.componentControls.delete(e)}start(e,t){this.componentControls.forEach(n=>{n.start(e.nativeEvent||e,t)})}cancel(){this.componentControls.forEach(e=>{e.cancel()})}stop(){this.componentControls.forEach(e=>{e.stop()})}},CY=()=>new SY;function wY(){return _R(CY)}var TY=(0,F.createContext)(null);function EY(e,t,n,r,i,a=`ltr`){let o=e.findIndex(e=>e.value===t);if(o===-1)return e;if(i===`xy`){let{layout:t}=e[o],r={x:tB(t.x.min,t.x.max,.5)+n.x,y:tB(t.y.min,t.y.max,.5)+n.y},i=DY(e),s=i.find(t=>t.items.includes(e[o])),c=i.reduce((e,t)=>OY(r.y,t)<OY(r.y,e)?t:e);if(c!==s)return kY(e,o,r.x,c,a);let l=AY(r,t),u=-1,d=l;return e.forEach((e,t)=>{if(t===o)return;let n=AY(r,e.layout);n<d&&(u=t,d=n)}),u===-1?e:SR(e,o,o+Math.sign(u-o))}if(!r[i])return e;let s=r[i]>0?1:-1,c=e[o+s];if(!c)return e;let l=e[o].layout[i],u=c.layout[i],d=tB(u.min,u.max,.5);return s===1&&l.max+n[i]>d||s===-1&&l.min+n[i]<d?SR(e,o,o+s):e}function DY(e){let t=[];return e.forEach(e=>{let{min:n,max:r}=e.layout.y,i=t[t.length-1];!i||n>=i.max||r<=i.min?t.push({items:[e],min:n,max:r}):(i.items.push(e),i.min=Math.min(i.min,n),i.max=Math.max(i.max,r))}),t}function OY(e,t){return e<t.min?t.min-e:e>t.max?e-t.max:0}function kY(e,t,n,r,i){let a=e.filter((e,n)=>n!==t),o=r.items.find(e=>{let t=tB(e.layout.x.min,e.layout.x.max,.5);return i===`ltr`?n<t:n>t}),s=o?a.indexOf(o):a.indexOf(r.items[r.items.length-1])+1,c=[...a];return c.splice(s,0,e[t]),c.every((t,n)=>t===e[n])?e:c}function AY(e,t){let n=Math.max(t.x.min-e.x,0,e.x-t.x.max),r=Math.max(t.y.min-e.y,0,e.y-t.y.max);return n*n+r*r}var jY=(e,t)=>e.max<=t.min||t.max<=e.min;function MY(e){let t=!1,n=!1;for(let r=0;r<e.length;r++)for(let i=r+1;i<e.length;i++)if(t||=jY(e[r].x,e[i].x),n||=jY(e[r].y,e[i].y),t&&n)return`xy`;return t?`x`:`y`}function NY({children:e,as:t=`ul`,axis:n,onReorder:r,values:i,onPointerDownCapture:a,onClickCapture:o,...s},c){let l=_R(()=>hY[t]),u=(0,F.useRef)(new Map),[d,f]=(0,F.useState)(`y`),p=(0,F.useRef)(!1),m=(0,F.useRef)(!1),h=(0,F.useRef)(null),g=n||d,_=new Set(i);u.current.forEach((e,t)=>{_.has(t)||u.current.delete(t)});let v={axis:g,groupRef:h,hasReordered:m,registerItem:(e,t)=>{if(u.current.set(e,t),!n){let e=MY(i.flatMap(e=>{let t=u.current.get(e);return t?[t]:[]}));e!==d&&f(e)}},updateOrder:(e,t,n)=>{if(p.current)return;let a=i.flatMap(e=>{let t=u.current.get(e);return t?[{value:e,layout:t}]:[]}),o=h.current?.ownerDocument.defaultView?.getComputedStyle(h.current).direction===`rtl`?`rtl`:`ltr`,s=EY(a,e,t,n,g,o);if(a!==s){p.current=!0,m.current=!0;let e=[...i],t=a.map(({value:e})=>i.indexOf(e));s.forEach(({value:n},r)=>{e[t[r]]=n}),r(e)}}};(0,F.useEffect)(()=>{p.current=!1},[i]);let y=e=>{h.current=e,typeof c==`function`?c(e):c&&(c.current=e)},b={overflowAnchor:`none`,...s.style};return(0,I.jsx)(l,{...s,style:b,ref:y,onPointerDownCapture:e=>{m.current=!1,a?.(e)},onClickCapture:e=>{m.current&&e.detail&&(m.current=!1,e.stopPropagation(),e.preventDefault()),o?.(e)},ignoreStrict:!0,children:(0,I.jsx)(TY.Provider,{value:v,children:e})})}var PY=(0,F.forwardRef)(NY),FY=50,IY=25,LY=new Set([`auto`,`scroll`]),RY=new WeakMap,zY=new WeakMap,BY=null;function VY(){if(BY){let e=UY(BY,`y`);e&&(zY.delete(e),RY.delete(e));let t=UY(BY,`x`);t&&t!==e&&(zY.delete(t),RY.delete(t)),BY=null}}function HY(e,t){let n=getComputedStyle(e),r=t===`x`?n.overflowX:n.overflowY,i=e===document.body||e===document.documentElement;return LY.has(r)||i}function UY(e,t){let n=e?.parentElement;for(;n;){if(HY(n,t))return n;n=n.parentElement}return null}function WY(e,t,n){let r=t.getBoundingClientRect(),i=n===`x`?Math.max(0,r.left):Math.max(0,r.top),a=n===`x`?Math.min(window.innerWidth,r.right):Math.min(window.innerHeight,r.bottom),o=e-i,s=a-e;if(o<FY){let e=1-o/FY;return{amount:-25*e*e,edge:`start`}}if(s<FY){let e=1-s/FY;return{amount:IY*e*e,edge:`end`}}return{amount:0,edge:null}}function GY(e,t,n,r){if(!e)return;BY=e;let i=UY(e,n);if(!i)return;let{amount:a,edge:o}=WY(t-(n===`x`?window.scrollX:window.scrollY),i,n);if(o===null){zY.delete(i),RY.delete(i);return}let s=zY.get(i),c=i===document.body||i===document.documentElement;if(s!==o){if(!(o===`start`&&r<0||o===`end`&&r>0))return;zY.set(i,o);let e=n===`x`?i.scrollWidth-(c?window.innerWidth:i.clientWidth):i.scrollHeight-(c?window.innerHeight:i.clientHeight);RY.set(i,e)}if(a>0){let e=RY.get(i);if((n===`x`?c?window.scrollX:i.scrollLeft:c?window.scrollY:i.scrollTop)>=e)return}n===`x`?c?window.scrollBy({left:a}):i.scrollLeft+=a:c?window.scrollBy({top:a}):i.scrollTop+=a}function KY(e,t=0){return SU(e)?e:gY(t)}function qY({children:e,style:t={},value:n,as:r=`li`,onDrag:i,onDragEnd:a,layout:o=!0,...s},c){let l=_R(()=>hY[r]),u=(0,F.useContext)(TY),d={x:KY(t.x),y:KY(t.y)},f=yY([d.x,d.y],([e,t])=>e||t?1:`unset`),{axis:p,registerItem:m,updateOrder:h,groupRef:g,hasReordered:_}=u;return(0,I.jsx)(l,{drag:p===`xy`||p,...s,dragSnapToOrigin:!0,style:{...t,x:d.x,y:d.y,zIndex:f},layout:o,onDrag:(e,t)=>{let{velocity:r,point:a}=t,o={x:d.x.get(),y:d.y.get()};h(n,o,r);let s=p===`xy`?Math.abs(r.x)>Math.abs(r.y)?`x`:`y`:p;GY(g.current,a[s],s,r[s]),i&&i(e,t)},onDragEnd:(e,t)=>{_.current=!1,VY(),a&&a(e,t)},onLayoutMeasure:e=>{m(n,e)},ref:c,ignoreStrict:!0,children:e})}var JY=(0,F.forwardRef)(qY);function YY(e){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(``),[l,u]=(0,F.useState)(null);return(0,I.jsxs)(`form`,{className:`grid`,onSubmit:async n=>{n.preventDefault(),u(null);try{if(t)await h9(d9(a).address,s.trim()===``?null:s.trim());else{let e=d9(r);await h9(e.address,e.code)}e.onAdded?.()}catch(e){u(Oe(e))}},children:[(0,I.jsxs)(`div`,{className:P(`grid gap-2`,e.fieldsClassName),children:[t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(wL,{"aria-label":`Server URL`,placeholder:`Server URL, e.g. http://127.0.0.1:47841`,spellCheck:!1,autoComplete:`off`,value:a,onChange:e=>o(e.target.value)}),(0,I.jsx)(wL,{"aria-label":`Pairing code`,placeholder:`Pairing code, empty if auth is off`,spellCheck:!1,autoComplete:`off`,value:s,onChange:e=>c(e.target.value)})]}):(0,I.jsx)(wL,{"aria-label":`Pairing link`,placeholder:`Pairing link`,spellCheck:!1,autoComplete:`off`,value:r,onChange:e=>i(e.target.value)}),l!==null&&(0,I.jsx)(`p`,{className:`text-destructive text-sm break-all`,children:l}),(0,I.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground w-fit cursor-pointer text-xs`,onClick:()=>{n(!t),u(null)},children:t?`Paste a pairing link instead`:`Enter the server URL and code separately`})]}),e.actions(t?a.trim()!==``:r.trim()!==``)]})}function XY(e){return(0,I.jsx)(_e,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(ae,{className:`gap-0 overflow-hidden p-0 sm:max-w-md`,children:[(0,I.jsxs)(se,{className:`gap-1 px-6 pt-4 pr-12`,children:[(0,I.jsx)(pe,{className:`text-base`,children:`Add machine`}),(0,I.jsx)(ge,{children:`Paste the pairing link that OffSite printed when it started.`})]}),(0,I.jsx)(YY,{fieldsClassName:`p-6`,onAdded:e.onClose,actions:t=>(0,I.jsxs)(ve,{className:`bg-muted/40 border-t px-6 py-4`,children:[(0,I.jsx)(x,{type:`button`,variant:`outline`,onClick:e.onClose,children:`Cancel`}),(0,I.jsx)(x,{type:`submit`,disabled:!t,children:`Add machine`})]})})]})})}var ZY={connecting:`Connecting…`,online:`Online`,offline:`Offline`,unpaired:`Needs pairing`};function QY(){let e=Q(e=>e.machines),t=Q(e=>e.machines.find(t=>t.id===e.settingsEditedMachine)),[n,r]=(0,F.useState)(!1);return t===void 0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(XL,{title:`Machines`,note:`This browser connects to each one directly. The list stays in this browser`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`flex min-h-13 items-center gap-4 px-4 py-2.5`,children:[(0,I.jsx)(w,{icon:Fv[e.icon],className:`text-muted-foreground size-5 shrink-0`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name}),e.addresses.map(e=>(0,I.jsx)(`p`,{className:`text-muted-foreground truncate font-mono text-xs`,children:e},e)),e.providers.filter(e=>e.state===`error`).map(e=>(0,I.jsxs)(`p`,{className:`text-destructive truncate text-xs`,title:e.error??void 0,children:[uw[e.provider],` threads: `,e.error]},e.provider))]}),(0,I.jsxs)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:[ZY[e.status],e.status===`online`&&e.via!==null&&e.via!==e.addresses[0]&&` · via ${new URL(e.via).host}`]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,I.jsx)(x,{size:`icon-sm`,variant:`ghost`,title:`Reconnect, trying the first address first`,onClick:()=>b9(e.id),children:(0,I.jsx)(w,{icon:z_})}),(0,I.jsx)(x,{size:`icon-sm`,variant:`ghost-muted`,title:`Open machine`,onClick:()=>$({settingsEditedMachine:e.id}),children:(0,I.jsx)(w,{icon:Fg})})]})]},e.id))}),(0,I.jsx)(`div`,{className:`flex gap-2`,children:(0,I.jsx)(x,{variant:`outline`,size:`sm`,onClick:()=>r(!0),children:`Add machine…`})}),n&&(0,I.jsx)(XY,{onClose:()=>r(!1)})]}):(0,I.jsx)($Y,{machine:t})}function $Y(e){let t=e.machine,[n,r]=(0,F.useState)(!1),[i,a]=(0,F.useState)(``),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(null),u=c??t.addresses,d=(0,F.useRef)(null);(0,F.useEffect)(()=>{n&&d.current?.focus()},[n]);function f(e){s(null);try{return v9(t.id,{addresses:[...new Set(e.map(e=>d9(e).address))]}),!0}catch(e){return s(Oe(e)),!1}}async function p(e){s(null);let n=e.trim();if(n===``)return!0;try{let e=n.includes(`#`)?d9(n).code:n;if(e===null)throw Error(`That link has no pairing code`);return await g9(t.id,e),!0}catch(e){return s(Oe(e)),!1}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(XL,{title:`Machine`,children:[(0,I.jsx)(ZL,{label:`Name`,children:(0,I.jsx)(QL,{value:t.label??``,placeholder:t.hostname,onCommit:e=>v9(t.id,{label:e.trim()===``?null:e.trim()})},t.label)}),(0,I.jsxs)(`div`,{className:`flex min-h-13 items-center justify-between gap-4 px-4 py-2.5`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:`Icon`}),(0,I.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:Object.entries(Fv).map(e=>(0,I.jsx)(x,{size:`icon-sm`,variant:e[0]===t.icon?`default`:`ghost`,title:e[0],"aria-pressed":e[0]===t.icon,onClick:()=>v9(t.id,{icon:e[0]}),children:(0,I.jsx)(w,{icon:e[1]})},e[0]))})]})]}),(0,I.jsx)(XL,{title:`Pairing`,children:(0,I.jsxs)(`div`,{className:`flex min-h-13 items-center justify-between gap-4 px-4 py-2.5`,children:[t.pairedAt!==null&&t.status!==`unpaired`&&(0,I.jsx)(`span`,{className:`text-sm`,children:t.pairedAt===null?`Paired`:`Paired ${mw(t.pairedAt)}`}),(t.pairedAt===null||t.status===`unpaired`)&&(0,I.jsxs)(`form`,{className:`flex flex-1 items-center gap-3`,onSubmit:async e=>{e.preventDefault(),await p(i)&&a(``)},children:[(0,I.jsx)(wL,{className:`flex-1 font-mono`,placeholder:`Pairing link or code`,spellCheck:!1,autoComplete:`off`,value:i,onChange:e=>a(e.target.value)}),(0,I.jsxs)(x,{type:`submit`,variant:`outline`,className:`px-4`,disabled:i.trim()===``,children:[(0,I.jsx)(w,{icon:gee}),`Pair`]})]})]})}),(0,I.jsxs)(XL,{title:`Addresses`,note:`OffSite tries them in order whenever it reconnects`,children:[(0,I.jsx)(PY,{as:`div`,axis:`y`,className:`divide-y`,values:u,onReorder:l,children:u.map((e,t)=>(0,I.jsxs)(eX,{address:e,onDragEnd:()=>{c!==null&&f(c),l(null)},children:[(0,I.jsx)(QL,{className:`flex-1 font-mono`,value:e,onCommit:e=>f(u.map((n,r)=>r===t?e:n))}),(0,I.jsx)(x,{size:`icon-sm`,variant:`ghost`,title:`Remove address`,disabled:u.length===1,onClick:()=>f(u.filter((e,n)=>n!==t)),children:(0,I.jsx)(w,{icon:d_})})]},e))}),n&&(0,I.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,I.jsx)(wL,{ref:d,className:`font-mono`,placeholder:`http://192.168.1.10:47841`,spellCheck:!1,autoComplete:`off`,onBlur:e=>{let n=e.target.value.trim();(n===``||f([...t.addresses,n]))&&r(!1)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}})}),!n&&(0,I.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted/50 hover:text-foreground flex w-full items-center gap-2 px-4 py-3 text-sm transition-colors`,onClick:()=>r(!0),children:[(0,I.jsx)(w,{icon:Og,className:`size-4`}),`Add address`]})]}),o!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-1 text-xs break-all`,children:o}),(0,I.jsxs)(LL,{children:[(0,I.jsx)(RL,{asChild:!0,children:(0,I.jsx)(x,{variant:`outline`,className:`text-destructive`,children:`Remove machine`})}),(0,I.jsxs)(zL,{children:[(0,I.jsxs)(BL,{children:[(0,I.jsxs)(HL,{children:[`Remove `,t.name,`?`]}),(0,I.jsx)(UL,{children:`This browser forgets the machine. The machine and its threads stay untouched.`})]}),(0,I.jsxs)(VL,{children:[(0,I.jsx)(GL,{children:`Cancel`}),(0,I.jsx)(WL,{variant:`destructive`,onClick:()=>{$({settingsEditedMachine:null}),eue(t.id)},children:`Remove machine`})]})]})]})]})}function eX(e){let t=wY();return(0,I.jsxs)(JY,{as:`div`,value:e.address,dragListener:!1,dragControls:t,onDragEnd:e.onDragEnd,className:`bg-background relative flex items-center gap-3 px-4 py-2.5`,children:[(0,I.jsx)(`span`,{className:`text-muted-foreground hover:text-foreground cursor-grab touch-none active:cursor-grabbing`,title:`Drag to reorder`,onPointerDown:e=>t.start(e),children:(0,I.jsx)(w,{icon:p_,className:`size-4`})}),e.children]})}var tX=`notifications`,nX=Promise.resolve(),rX=new Set;function iX(){return window.isSecureContext?!(`Notification`in window)||!(`serviceWorker`in navigator)?`unsupported`:Notification.permission:`insecure`}function aX(){let e=localStorage.getItem(tX);if(e===null||e===`on`)return!0;if(e===`off`)return!1;throw Error(`unknown notification setting ${e}`)}async function oX(e){e&&Notification.permission==="default"&&await Notification.requestPermission(),localStorage.setItem(tX,e?`on`:`off`)}async function sX(e,t){(await navigator.permissions.query({name:`notifications`})).addEventListener(`change`,t,{signal:e})}function cX(e,t,n){if(document.hidden)for(let r of t){let t=uX(e,r);dX(e,r,`${t===void 0?`Agent`:uw[t.provider]} ${n}`,t?.title??`Session`,f9(e,r)).catch(e=>console.error(`could not show a notification`,e))}}function lX(e,t,n){dX(e,t,uX(e,t)?.title??`Session`,n,`push:${f9(e,t)}`).catch(e=>console.error(`could not show a notification`,e))}function uX(e,t){return Z().sessions.find(n=>n.machine===e&&n.id===t)}async function dX(e,t,n,r,i){if(iX()!==`granted`||!aX()||!T9(Z(),e).notifier)return;let a=uX(e,t);await(await navigator.serviceWorker.ready).showNotification(n,{body:r,tag:i,data:a===void 0?null:{kind:`session`,machine:e,project:a.projectId,sessionId:t}})}async function fX(e,t,n){iX()===`granted`&&aX()&&T9(Z(),n.machine).notifier&&await(await navigator.serviceWorker.ready).showNotification(e,{body:t,data:{kind:`terminal`,...n}})}function pX(){let e=Z().machines.filter(e=>Co(e.id)&&!e.notifier&&!rX.has(e.id)).map(e=>e.id);if(e.length!==0){for(let t of e)rX.add(t);mX().then(t=>Promise.all(e.map(e=>L(e,`notifications.claim`,{endpoint:t})))).catch(e=>console.error(`could not claim notifications`,e)).finally(()=>{for(let t of e)rX.delete(t)})}}async function mX(){if(hX()!==`supported`)return null;let e=await navigator.serviceWorker.getRegistration();if(e===void 0)return null;let t=await e.pushManager.getSubscription();return t===null?null:t.endpoint}function hX(){return window.isSecureContext?!(`Notification`in window)||!(`serviceWorker`in navigator)||!(`PushManager`in window)?gX()?`install`:`unsupported`:Notification.permission===`denied`?`denied`:`supported`:`insecure`}function gX(){return/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.userAgent.includes(`Mac`)&&navigator.maxTouchPoints>1}async function _X(){return await(await navigator.serviceWorker.ready).pushManager.getSubscription()!==null}async function vX(){return Notification.permission==="default"&&await Notification.requestPermission(),Notification.permission===`granted`&&(await xX(SX),!0)}function yX(){return xX(CX)}function bX(e){return xX(async()=>{if(hX()!==`supported`)return;let t=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!t)return;let n=await wX(),r=t.options.applicationServerKey;r!==null&&EX(r)===n.publicKey?await DX(e,t,n):await SX()})}function xX(e){let t=nX.then(e);return nX=t.catch(()=>void 0),t}async function SX(){await CX();let e=await wX(),t=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:e.publicKey});await Promise.all(TX().map(n=>DX(n,t,e)))}async function CX(){let e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();e&&(await Promise.all(TX().map(t=>L(t,`push.unsubscribe`,{endpoint:e.endpoint}))),await e.unsubscribe())}async function wX(){let e=await caches.open(`offsite-worker`),t=await e.match(`/push-keys`);if(t!==void 0)return await t.json();let n=await crypto.subtle.generateKey({name:`ECDSA`,namedCurve:`P-256`},!0,[`sign`,`verify`]),r=(await crypto.subtle.exportKey(`jwk`,n.privateKey)).d;if(r===void 0)throw Error(`the browser did not export the push key`);let i={publicKey:EX(await crypto.subtle.exportKey(`raw`,n.publicKey)),privateKey:r};return await e.put(`/push-keys`,new Response(JSON.stringify(i))),i}function TX(){return Z().machines.filter(e=>Co(e.id)).map(e=>e.id)}function EX(e){return btoa(String.fromCharCode(...new Uint8Array(e))).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/,``)}async function DX(e,t,n){await L(e,`push.subscribe`,{subscription:t.toJSON(),...n,machine:e})}var OX=new Map([[`denied`,`Blocked in the browser's site settings`],[`insecure`,`Needs https or localhost`],[`install`,`Add OffSite to the Home Screen first`],[`unsupported`,`Not supported in this browser`]]);function kX(e){let t=e.prefs.terminal,n=t.behavior;function r(r){L9({...e.prefs,terminal:{...t,behavior:{...n,...r}}})}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(XL,{title:`Notifications`,children:[(0,I.jsx)(ZL,{label:`Desktop notifications on this device`,children:(0,I.jsx)(AX,{})}),(0,I.jsx)(ZL,{label:`Push terminal alerts when no OffSite page is open`,children:(0,I.jsx)(jX,{})})]}),(0,I.jsxs)(XL,{title:`Terminal bell`,children:[(0,I.jsx)(ZL,{label:`Flash the screen on bell`,children:(0,I.jsx)(KL,{checked:n.bellFlash,onCheckedChange:e=>r({bellFlash:e})})}),(0,I.jsx)(ZL,{label:`Play a sound on bell`,children:(0,I.jsx)(KL,{checked:n.bellSound,onCheckedChange:e=>r({bellSound:e})})})]})]})}function AX(){let[e,t]=(0,F.useState)(iX),[n,r]=(0,F.useState)(aX);(0,F.useEffect)(()=>{let e=iX();if(e===`insecure`||e===`unsupported`)return;let n=new AbortController;return sX(n.signal,()=>t(iX())).catch(e=>console.error(`could not watch the notification permission`,e)),()=>n.abort()},[]);async function i(e){await oX(e),r(e),t(iX())}return(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[OX.has(e)&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:OX.get(e)}),(0,I.jsx)(KL,{checked:e===`granted`&&n,disabled:e!==`granted`&&e!=="default",onCheckedChange:e=>void i(e)})]})}function jX(){let[e,t]=(0,F.useState)(hX),[n,r]=(0,F.useState)(!1),[i,a]=(0,F.useState)(()=>hX()===`supported`),[o,s]=(0,F.useState)(null);(0,F.useEffect)(()=>{if(hX()!==`supported`)return;let e=!0;async function t(){try{let t=await _X();e&&r(t)}catch(e){console.error(`could not read the push subscription`,e)}e&&a(!1)}return t(),()=>{e=!1}},[]);async function c(e){a(!0),s(null);try{e?r(await vX()):(await yX(),r(!1))}catch(e){console.error(`could not change push notifications`,e),s(Oe(e))}t(hX()),a(!1)}return(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[o!==null&&(0,I.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[`Could not update: `,o]}),OX.has(e)&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:OX.get(e)}),(0,I.jsx)(KL,{checked:e===`supported`&&n,disabled:e!==`supported`||i,onCheckedChange:e=>void c(e)})]})}var MX={five_hour:`5h`,seven_day:`Week`,seven_day_opus:`Week (Opus)`,seven_day_sonnet:`Week (Sonnet)`};function NX(e){return MX[e.window]??e.window}function PX(e){let t=e.account,[n,r]=(0,F.useState)(null),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(null),c=n===null?null:n.models;(0,F.useEffect)(()=>{let n=!0;return r(null),a(null),L(e.machine,`capabilities`,{provider:t.provider,accountId:t.id,projectId:null}).then(e=>{n&&r(e)},e=>{n&&a(Oe(e))}),()=>{n=!1}},[e.machine,t.provider,t.id,t.configDir]);async function l(n){s(null);try{await L(e.machine,`accounts.update`,{id:t.id,name:t.name,color:t.color,configDir:t.configDir,enabled:t.enabled,hiddenModels:t.hiddenModels,...n})}catch(e){s(Oe(e))}}async function u(){s(null);try{await L(e.machine,`accounts.remove`,{id:t.id}),$({settingsAccount:null})}catch(e){s(Oe(e))}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(XL,{title:`Account`,children:[(0,I.jsx)(ZL,{label:`Name`,children:(0,I.jsx)(QL,{value:t.name,valid:e=>e.trim()!==``,onCommit:e=>void l({name:e})},t.name)}),(0,I.jsx)(ZL,{label:`Color`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`size-5 shrink-0 rounded-full`,style:{backgroundColor:t.color}}),(0,I.jsx)(QL,{className:`w-28 font-mono`,value:t.color,valid:e=>/^#[0-9a-f]{6}$/i.test(e),onCommit:e=>void l({color:e})},t.color)]})}),(0,I.jsx)(ZL,{label:`Config directory`,children:(0,I.jsx)(QL,{className:`w-72 font-mono`,value:t.configDir??``,placeholder:t.provider===`claude`?`~/.claude or empty for default`:`~/.codex or empty for default`,onCommit:e=>void l({configDir:e})},t.configDir??``)})]}),o!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-1 text-xs`,children:o}),(0,I.jsxs)(XL,{title:`Models`,note:`Overrides the provider settings`,children:[i!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:i}),i===null&&c===null&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-4 py-3 text-xs`,children:`Loading…`}),(c??[]).map(n=>{let r=e.settings[n.value]?.hidden??n.deprecated,i=t.hiddenModels[n.value],a=i??r;return(0,I.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 px-4 py-1.5`,children:[(0,I.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate text-sm`,a&&`text-muted-foreground`),children:n.name}),i!==void 0&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Override`}),(0,I.jsx)(KL,{size:`sm`,checked:!a,onCheckedChange:e=>{let i={...t.hiddenModels};!e===r?delete i[n.value]:i[n.value]=!e,l({hiddenModels:i})},"aria-label":`Show ${n.name}`})]},n.value)})]}),(0,I.jsxs)(LL,{children:[(0,I.jsx)(RL,{asChild:!0,children:(0,I.jsx)(x,{variant:`outline`,className:`text-destructive`,children:`Remove account`})}),(0,I.jsxs)(zL,{children:[(0,I.jsxs)(BL,{children:[(0,I.jsxs)(HL,{children:[`Remove `,t.name,`?`]}),(0,I.jsx)(UL,{children:`OffSite stops using this account. Its config directory and sessions stay untouched.`})]}),(0,I.jsxs)(VL,{children:[(0,I.jsx)(GL,{children:`Cancel`}),(0,I.jsx)(WL,{variant:`destructive`,onClick:()=>void u(),children:`Remove account`})]})]})]})]})}function FX(e){let[t,n]=(0,F.useState)(``),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(null);async function l(){o(!0),c(null);try{await L(e.machine,`accounts.add`,{provider:e.provider,name:t,configDir:r}),$({settingsAccount:null})}catch(e){c(Oe(e)),o(!1)}}return(0,I.jsxs)(`form`,{className:`space-y-5`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,I.jsxs)(XL,{title:`Account`,children:[(0,I.jsx)(ZL,{label:`Name`,children:(0,I.jsx)(wL,{className:`w-56`,value:t,onChange:e=>n(e.target.value),placeholder:`Work`})}),(0,I.jsx)(ZL,{label:`Config directory`,children:(0,I.jsx)(wL,{className:`w-72 font-mono`,value:r,onChange:e=>i(e.target.value),placeholder:e.provider===`claude`?`~/.claude or empty for default`:`~/.codex or empty for default`})})]}),s!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-1 text-xs`,children:s}),(0,I.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,I.jsx)(x,{type:`button`,variant:`ghost`,onClick:()=>$({settingsAccount:null}),children:`Cancel`}),(0,I.jsx)(x,{type:`submit`,disabled:a||t.trim()===``,children:`Add account`})]})]})}function IX(e){let t=e.config,n=t.enabledProviders[e.provider],r=e.provider===`claude`?e.claudeAccounts:e.provider===`codex`?e.codexAccounts:[],i=r.find(e=>e.valid),a=t.claudeBaseDir[e.platform]??e.defaultClaudeBaseDir;if(e.selected===`new`){if(e.provider===`opencode`)throw Error(`OpenCode accounts cannot be added`);return(0,I.jsx)(FX,{machine:e.machine,provider:e.provider})}if(e.selected!==null){let n=r.find(t=>t.id===e.selected);return n===void 0?(0,I.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This account no longer exists.`}):(0,I.jsx)(PX,{machine:e.machine,settings:t.models[e.provider],account:n})}return(0,I.jsxs)(I.Fragment,{children:[e.provider===`claude`&&(0,I.jsx)(`div`,{className:`divide-y overflow-hidden rounded-xl border`,children:(0,I.jsx)(ZL,{label:`Base directory`,children:(0,I.jsx)(QL,{className:`w-72 font-mono`,value:a,valid:e=>e.trim()!==``,onCommit:n=>H9(e.machine,{...t,claudeBaseDir:{...t.claudeBaseDir,[e.platform]:n}})},a)})}),(0,I.jsxs)(`div`,{className:P(`space-y-5 transition-opacity`,!n&&`opacity-50`),children:[e.provider!==`opencode`&&(0,I.jsx)(XL,{title:`Accounts`,children:(0,I.jsx)(RX,{machine:e.machine,accounts:r})}),n&&e.provider===`opencode`&&e.openCode.available&&(0,I.jsx)(LX,{machine:e.machine,config:t,composer:e.composer,provider:e.provider,accountId:null}),n&&e.provider!==`opencode`&&i!==void 0&&(0,I.jsx)(LX,{machine:e.machine,config:t,composer:e.composer,provider:e.provider,accountId:i.id})]})]})}function LX(e){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(null),a=e.config.models[e.provider],o=t===null?null:t.models,s=e.composer[e.provider],c=s.model??(t===null?null:t.defaultModel);(0,F.useEffect)(()=>{let t=!0;return n(null),i(null),L(e.machine,`capabilities`,{provider:e.provider,accountId:e.accountId,projectId:null}).then(e=>{t&&n(e)},e=>{t&&i(Oe(e))}),()=>{t=!1}},[e.machine,e.provider,e.accountId]);function l(t,n){H9(e.machine,{...e.config,models:{...e.config.models,[e.provider]:{...a,[t]:n}}})}return(0,I.jsxs)(XL,{title:`Models`,children:[o!==null&&(0,I.jsx)(ZL,{label:`Default model`,children:(0,I.jsxs)(TL,{value:c??void 0,onValueChange:t=>{let n=o?.find(e=>e.value===t)?.effort??null;W9(e.machine,{...e.composer,[e.provider]:{...s,model:t,...n===null?{}:{effort:n}}})},children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{placeholder:`Choose a model`})}),(0,I.jsx)(OL,{children:o.filter(e=>!(a[e.value]?.hidden??e.deprecated)||e.value===c).map(e=>(0,I.jsx)(kL,{value:e.value,children:e.name},e.value))})]})}),r!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:r}),r===null&&o===null&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-4 py-3 text-xs`,children:`Loading…`}),(o??[]).map(t=>{let n=a[t.value]??{hidden:t.deprecated,effort:t.effort};return(0,I.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 px-4 py-1.5`,children:[(0,I.jsxs)(`div`,{className:P(`min-w-0 flex-1 truncate text-sm`,n.hidden&&`text-muted-foreground`),children:[t.name,e.provider===`opencode`&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-2 text-xs`,children:t.description})]}),t.efforts.length>0&&(0,I.jsxs)(TL,{value:n.effort??t.effort??void 0,onValueChange:e=>l(t.value,{...n,effort:e}),children:[(0,I.jsx)(DL,{size:`sm`,className:`w-28`,children:(0,I.jsx)(EL,{placeholder:`Effort`})}),(0,I.jsx)(OL,{children:t.efforts.map(e=>(0,I.jsx)(kL,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,I.jsx)(KL,{size:`sm`,checked:!n.hidden,onCheckedChange:e=>l(t.value,{...n,hidden:!e}),"aria-label":`Show ${t.name}`})]},t.value)})]})}function RX(e){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(null);async function a(e){n(!0),i(null);try{await e()}catch(e){i(Oe(e))}finally{n(!1)}}return(0,I.jsxs)(I.Fragment,{children:[e.accounts.map(n=>(0,I.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:P(`min-w-0 flex-1`,!n.enabled&&`opacity-50`),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:P(`size-2 shrink-0 rounded-full`,!n.enabled&&`bg-muted-foreground/40`,n.enabled&&n.error!==null&&`bg-destructive`,n.enabled&&n.error===null&&!n.linked&&`bg-warning`,n.enabled&&n.error===null&&n.linked&&`bg-success`)}),(0,I.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n.name}),n.plan!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:n.plan})]}),n.error!==null&&(0,I.jsx)(`p`,{className:`text-destructive mt-1 truncate pl-4 text-xs`,children:n.error}),n.error===null&&!n.linked&&(0,I.jsx)(`p`,{className:`text-warning mt-1 truncate pl-4 text-xs`,children:`Not linked to shared threads · hidden in the composer`}),n.error===null&&n.linked&&n.limits.length>0&&(0,I.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-x-5 gap-y-1.5 pl-4`,children:n.limits.map(e=>(0,I.jsx)(zX,{limit:e},e.window))})]}),(0,I.jsx)(KL,{size:`sm`,checked:n.enabled,disabled:t,onCheckedChange:t=>void a(()=>L(e.machine,`accounts.update`,{id:n.id,name:n.name,color:n.color,configDir:n.configDir,enabled:t,hiddenModels:n.hiddenModels})),"aria-label":`Enable ${n.name}`}),(0,I.jsx)(x,{size:`icon-sm`,variant:`ghost-muted`,title:`Open account`,onClick:()=>$({settingsAccount:n.id}),children:(0,I.jsx)(w,{icon:Fg})})]},n.id)),(0,I.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted/50 hover:text-foreground flex w-full items-center gap-2 px-4 py-3 text-sm transition-colors`,onClick:()=>$({settingsAccount:`new`}),children:[(0,I.jsx)(w,{icon:Og,className:`size-4`}),`Add account`]}),r!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:r})]})}function zX(e){let t=e.limit,n=t.rejected?100:t.utilization===null?null:Math.min(100,Math.round(t.utilization*100));return n===null?null:(0,I.jsx)(M,{label:t.resetsAt===null?`Reset time unknown`:`Resets ${mw(t.resetsAt*1e3)}`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:NX(t)}),(0,I.jsx)(`div`,{className:`bg-foreground/10 h-1 w-16 overflow-hidden rounded-full`,children:(0,I.jsx)(`div`,{className:P(`h-full rounded-full`,t.rejected&&`bg-destructive`,!t.rejected&&n>=80&&`bg-warning`,!t.rejected&&n<80&&`bg-foreground/50`),style:{width:`${n}%`}})}),(0,I.jsxs)(`span`,{className:P(`tabular-nums`,t.rejected&&`text-destructive`,!t.rejected&&`text-muted-foreground`),children:[n,`%`]})]})})}var BX=Ee?`⌘`:`Ctrl+Shift`,VX=[[`Enter`,`Send, or queue or steer while the agent works`],[`${Te}+Enter`,`Send the other way while the agent works`],[`Shift+Enter`,`New line`],[`↑`,`Recall your last message`],[`Esc`,`Stop the agent`],[`/`,`Slash commands`],[`@`,`Mention a file`],[`${Te}+K`,`Search sessions and actions`],[`${Te}+N or ${Te}+T`,`New thread`],[Ee?"⌘+` or Ctrl+`":"Ctrl+`",`Toggle the terminal`],[`${Te}+B`,`Toggle the sidebar`],[`${Te}+J`,`Toggle the right panel`],[`${BX}+T`,`New terminal tab, in the terminal`],[`${BX}+W`,`Close the terminal tab`],[`${BX}+F`,`Find in the terminal`],[`Ctrl+Tab`,`Next terminal tab`],[`Ctrl+Shift+Tab`,`Previous terminal tab`]];function HX(){return(0,I.jsx)(XL,{title:`Keyboard shortcuts`,children:VX.map(([e,t])=>(0,I.jsx)(ZL,{label:t,children:(0,I.jsx)(`kbd`,{className:`bg-muted text-muted-foreground rounded px-1.5 py-0.5 font-sans text-xs`,children:e})},e))})}var UX=1048576;function WX(e){window.isSecureContext?navigator.clipboard.writeText(e).catch(e=>{console.warn(`could not copy to the clipboard`,e),Ro(`Could not copy to the clipboard`)}):console.warn(`copy from the terminal needs https or localhost`)}async function GX(e){if(!window.isSecureContext){console.warn(`programs can read the clipboard only over https or localhost`),Ro(`Programs can read the clipboard only over https or localhost`);return}let t;try{t=await navigator.clipboard.readText()}catch(e){console.warn(`could not read the clipboard`,e),Ro(`Could not read the clipboard`);return}new TextEncoder().encode(t).length>UX?(console.warn(`the clipboard is over 1 MiB, not replying`),Ro(`The clipboard is too large to share (over 1 MiB)`)):e(t)}var KX={macos:{label:`Ctrl+V`,ctrl:!0,alt:!1,data:``},linux:{label:`Ctrl+V`,ctrl:!0,alt:!1,data:``},windows:{label:`Alt+V`,ctrl:!1,alt:!0,data:`\x1Bv`}};function qX(e,t){let n=KX[t];return e.key.toLowerCase()===`v`&&e.ctrlKey===n.ctrl&&e.altKey===n.alt&&!e.shiftKey&&!e.metaKey}async function JX(e,t){let n=[];for(let e of await navigator.clipboard.read()){let t=e.types.find(e=>e.startsWith(`image/`));t&&n.push(await e.getType(t))}return n.length===0?(Ro(`No image in the clipboard`),!1):(await YX(e,t,n),!0)}async function YX(e,t,n){let r=[];for(let t of n){let n=await L(e,`terminal.paste`,{type:t.type,data:await PC(t)});r.push(/\s/.test(n)?`"${n}"`:n)}t.paste(r.join(` `))}function XX(e){console.error(`could not paste image`,e),Ro(`Could not paste the image`)}function ZX(e){let t=e.prefs.terminal,[n,r]=(0,F.useState)(!tR.some(e=>e.family===t.font.family));function i(t){L9({...e.prefs,terminal:t})}function a(e,n){i({...t,[e]:{...t[e],...n}})}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(XL,{title:`Font`,children:[(0,I.jsx)(ZL,{label:`Family`,children:(0,I.jsxs)(TL,{value:n?`custom`:t.font.family,onValueChange:e=>{r(e===`custom`),e!==`custom`&&a(`font`,{family:e})},children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[tR.map(e=>(0,I.jsx)(kL,{value:e.family,children:e.label},e.family)),(0,I.jsx)(kL,{value:`custom`,children:`Custom`})]})]})}),n&&(0,I.jsx)(ZL,{label:`Custom family`,children:(0,I.jsx)(QL,{placeholder:`Installed font name`,value:t.font.family,onCommit:e=>a(`font`,{family:e})})}),(0,I.jsx)(ZL,{label:`Size`,children:(0,I.jsx)($L,{value:t.font.size,step:.5,onCommit:e=>a(`font`,{size:e})})}),(0,I.jsx)(ZL,{label:`Line height`,children:(0,I.jsx)($L,{value:t.font.lineHeight,step:.05,onCommit:e=>a(`font`,{lineHeight:e})})}),(0,I.jsx)(ZL,{label:`Ligatures`,children:(0,I.jsx)(KL,{checked:t.font.ligatures,onCheckedChange:e=>a(`font`,{ligatures:e})})}),(0,I.jsx)(ZL,{label:`Bold text in bright colors`,children:(0,I.jsx)(KL,{checked:t.boldIsBright,onCheckedChange:e=>i({...t,boldIsBright:e})})})]}),(0,I.jsxs)(XL,{title:`Cursor`,children:[(0,I.jsx)(ZL,{label:`Style`,children:(0,I.jsxs)(TL,{value:t.cursor.style,onValueChange:e=>a(`cursor`,{style:e}),children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`block`,children:`Block`}),(0,I.jsx)(kL,{value:`bar`,children:`Bar`}),(0,I.jsx)(kL,{value:`underline`,children:`Underline`})]})]})}),(0,I.jsx)(ZL,{label:`Blink`,children:(0,I.jsx)(KL,{checked:t.cursor.blink,onCheckedChange:e=>a(`cursor`,{blink:e})})})]}),(0,I.jsx)(QX,{behavior:t.behavior,onChange:e=>a(`behavior`,e)}),(0,I.jsx)($X,{behavior:t.behavior,onChange:e=>a(`behavior`,e)}),(0,I.jsxs)(XL,{title:`Layout`,children:[[`top`,`right`,`bottom`,`left`].map(e=>(0,I.jsx)(ZL,{label:`Padding ${e}`,children:(0,I.jsx)($L,{value:t.padding[e],onCommit:t=>a(`padding`,{[e]:t})})},e)),(0,I.jsx)(ZL,{label:`Scrollback lines`,children:(0,I.jsx)($L,{value:t.scrollback,step:1e3,onCommit:e=>i({...t,scrollback:e})})})]})]})}function QX(e){return(0,I.jsxs)(XL,{title:`Behavior`,children:[(0,I.jsx)(ZL,{label:`Modernize Shift+Enter`,children:(0,I.jsx)(KL,{checked:e.behavior.modernizeShiftEnter,onCheckedChange:t=>e.onChange({modernizeShiftEnter:t})})}),(0,I.jsx)(ZL,{label:`${KX.linux.label} (${KX.windows.label} on Windows machines) pastes images from the browser clipboard`,children:(0,I.jsx)(KL,{checked:e.behavior.pasteBrowserImages,onCheckedChange:t=>e.onChange({pasteBrowserImages:t})})}),(0,I.jsx)(ZL,{label:`Capture browser shortcuts`,children:(0,I.jsx)(KL,{checked:e.behavior.captureShortcuts,onCheckedChange:t=>e.onChange({captureShortcuts:t})})}),(0,I.jsx)(ZL,{label:`Click moves the cursor in the command line`,children:(0,I.jsx)(KL,{checked:e.behavior.clickToMoveCursor,onCheckedChange:t=>e.onChange({clickToMoveCursor:t})})}),(0,I.jsx)(ZL,{label:`Ask before closing a tab that is running a program`,children:(0,I.jsx)(KL,{checked:e.behavior.confirmCloseBusyTab,onCheckedChange:t=>e.onChange({confirmCloseBusyTab:t})})})]})}function $X(e){return Ee?(0,I.jsx)(XL,{title:`Mac keys`,note:`Meta keeps that Option key from typing @, | and other symbols. Safari and Firefox use US key positions`,children:(0,I.jsx)(ZL,{label:`Use Option as Meta`,children:(0,I.jsxs)(TL,{value:e.behavior.optionAsMeta,onValueChange:t=>e.onChange({optionAsMeta:t}),children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`off`,children:`Off`}),(0,I.jsx)(kL,{value:`left`,children:`Left Option`}),(0,I.jsx)(kL,{value:`right`,children:`Right Option`}),(0,I.jsx)(kL,{value:`both`,children:`Both Options`})]})]})})}):null}var eZ=[`General`,`Terminal`,`Notifications`,`Shortcuts`,`Machines`],tZ=[`Machine`,`Claude`,`Codex`,`OpenCode`];function nZ(){let e=Q(e=>e.machines),t=Q(e=>e.settingsMachine===null?null:T9(e,e.settingsMachine)),n=Q(e=>e.settingsPage),r=sZ(n),i=Q(e=>r===null?null:e.settingsAccount),a=Q(e=>n===`Machines`?e.machines.find(t=>t.id===e.settingsEditedMachine)??null:null);return{machines:e,machine:t,config:t===null?null:t.config,system:t===null?null:t.system,page:n,provider:r,account:i,editedMachine:a,subpage:i!==null||a!==null,subpageTitle:i===`new`?`New account`:i===null?a?.name:[...t?.claudeAccounts??[],...t?.codexAccounts??[]].find(e=>e.id===i)?.name}}function rZ(){let e=Q(e=>e.settingsOpen),t=nZ(),n=t.page,r=t.machine;function i(e){return(0,I.jsx)(`button`,{className:P(`text-muted-foreground hover:bg-accent hover:text-foreground flex h-9 flex-none items-center rounded-md px-2 text-sm transition-colors`,e===n&&`bg-accent text-foreground`),onClick:()=>I9(e),children:(0,I.jsx)(iZ,{page:e})},e)}return(0,I.jsx)(_e,{open:e,onOpenChange:F9,children:(0,I.jsxs)(ae,{showCloseButton:!1,"aria-describedby":void 0,className:`flex h-[min(44rem,calc(100dvh-2rem))] flex-col gap-0 overflow-hidden p-0 sm:max-w-4xl sm:flex-row`,children:[(0,I.jsxs)(`nav`,{className:`flex flex-none gap-1 overflow-x-auto border-b p-3 sm:w-48 sm:flex-col sm:border-r sm:border-b-0`,children:[(0,I.jsx)(pe,{className:`hidden px-2 pt-1 pb-3 text-base font-semibold sm:block`,children:`Settings`}),eZ.map(i),(0,I.jsxs)(`div`,{className:`flex flex-none items-center gap-1 sm:mt-6 sm:flex-col sm:items-stretch`,children:[r!==null&&t.machines.length>1&&(0,I.jsxs)(TL,{value:r.id,onValueChange:e=>$({settingsMachine:e,settingsAccount:null}),children:[(0,I.jsx)(DL,{className:`mb-1 w-40 sm:w-full`,children:(0,I.jsx)(EL,{})}),(0,I.jsx)(OL,{children:t.machines.map(e=>(0,I.jsxs)(kL,{value:e.id,children:[(0,I.jsx)(w,{icon:Fv[e.icon]}),e.name]},e.id))})]}),r!==null&&t.machines.length===1&&(0,I.jsxs)(`p`,{className:`text-muted-foreground flex h-9 items-center gap-1.5 px-2 text-xs font-medium [&_svg]:size-4`,children:[(0,I.jsx)(w,{icon:Fv[r.icon]}),(0,I.jsx)(`span`,{className:`truncate`,children:r.name})]}),tZ.map(i)]})]}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 pt-4 pb-7`,children:[(0,I.jsxs)(`div`,{className:`mb-5 flex h-9 items-center`,children:[t.subpage&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground text-xl font-semibold tracking-tight transition-colors`,onClick:()=>$({settingsAccount:null,settingsEditedMachine:null}),children:n}),(0,I.jsx)(w,{icon:Fg,className:`text-muted-foreground mx-1.5 size-5`}),(0,I.jsx)(`h2`,{className:`truncate text-xl font-semibold tracking-tight`,children:t.subpageTitle})]}),!t.subpage&&(0,I.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:n===`Machine`?`General`:n}),(0,I.jsx)(aZ,{view:t,className:`ml-3`}),(0,I.jsx)(fe,{asChild:!0,children:(0,I.jsx)(x,{variant:`ghost`,size:`icon`,className:`-mr-2 ml-auto`,"aria-label":`Close settings`,children:(0,I.jsx)(w,{icon:Wg})})})]}),(0,I.jsx)(oZ,{view:t})]})]})})}function iZ(e){let t=sZ(e.page);return(0,I.jsxs)(I.Fragment,{children:[t!==null&&(0,I.jsx)(`span`,{className:`mr-2.5 flex size-4 items-center justify-center`,children:(0,I.jsx)(zv,{provider:t,className:P(t===`claude`&&`size-4`,t===`codex`&&`size-[19px] shrink-0`,t===`opencode`&&`h-3.5`)})}),e.page===`Machine`?`General`:e.page]})}function aZ(e){let t=e.view.machine,n=e.view.config,r=e.view.provider;return r===null||e.view.account!==null||t===null||n===null?null:(0,I.jsx)(KL,{className:e.className,checked:n.enabledProviders[r],onCheckedChange:e=>void H9(t.id,{...n,enabledProviders:{...n.enabledProviders,[r]:e}}),"aria-label":`Enable ${e.view.page}`})}function oZ(e){let t=Q(e=>e.prefs),n=e.view.page,r=e.view.machine,i=e.view.config,a=e.view.system,o=tZ.includes(n),[s,c]=(0,F.useState)(null),[l,u]=(0,F.useState)(0);return(0,I.jsxs)(I.Fragment,{children:[o&&r!==null&&r.configError!==null&&(0,I.jsxs)(`p`,{className:`text-destructive mb-5 text-sm whitespace-pre-wrap`,children:[`Not saved: `,r.configError]}),(0,I.jsxs)(`div`,{className:`w-full space-y-5`,children:[n===`General`&&(0,I.jsx)(Aae,{prefs:t,onRestore:()=>c(`browser`)}),n===`Machine`&&r!==null&&i!==null&&a!==null&&(0,I.jsx)(pR,{machine:r.id,config:i,platform:a.platform,defaultShell:a.defaultShell,claudeAccounts:r.claudeAccounts,codexAccounts:r.codexAccounts,openCode:r.openCode,onRestore:()=>c(`machine`)}),o&&r===null&&(0,I.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Add a machine to see its settings.`}),o&&r!==null&&(i===null||a===null)&&(0,I.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[r.name,` is not connected. Its settings show up once it is.`]}),n===`Terminal`&&(0,I.jsx)(ZX,{prefs:t}),n===`Notifications`&&(0,I.jsx)(kX,{prefs:t}),e.view.provider!==null&&r!==null&&i!==null&&r.composer!==null&&a!==null&&(0,I.jsx)(IX,{machine:r.id,config:i,composer:r.composer,platform:a.platform,defaultClaudeBaseDir:a.defaultClaudeBaseDir,provider:e.view.provider,claudeAccounts:r.claudeAccounts,codexAccounts:r.codexAccounts,openCode:r.openCode,selected:e.view.account},e.view.provider),n===`Machines`&&(0,I.jsx)(QY,{}),n===`Shortcuts`&&(0,I.jsx)(HX,{})]},l),(0,I.jsx)(LL,{open:s!==null,onOpenChange:e=>{e||c(null)},children:(0,I.jsxs)(zL,{children:[(0,I.jsxs)(BL,{children:[(0,I.jsx)(HL,{children:s===`browser`?`Restore browser defaults?`:`Restore machine defaults?`}),(0,I.jsx)(UL,{children:s===`browser`?`All settings of this browser go back to their defaults.`:`All settings of ${r?.name} go back to their defaults.`})]}),(0,I.jsxs)(VL,{children:[(0,I.jsx)(GL,{children:`Cancel`}),(0,I.jsx)(WL,{variant:`destructive`,onClick:()=>{if(u(l+1),s===`browser`)L9(YL);else{if(r===null||i===null||a===null)throw Error(`Restoring machine defaults needs a connected machine`);H9(r.id,{...a.defaults,claudeAccounts:i.claudeAccounts,codexAccounts:i.codexAccounts})}},children:`Restore defaults`})]})]})})]})}function sZ(e){return e===`Claude`?`claude`:e===`Codex`?`codex`:e===`OpenCode`?`opencode`:null}function cZ(){let e=Q(e=>e.settingsOpen),t=Q(e=>e.settingsListing),n=nZ(),r=n.machine;function i(){t?F9(!1):n.subpage?$({settingsAccount:null,settingsEditedMachine:null}):$({settingsListing:!0})}function a(e){return(0,I.jsxs)(`button`,{className:`active:bg-accent flex min-h-12 w-full items-center px-4 text-left text-sm font-medium`,onClick:()=>I9(e),children:[(0,I.jsx)(iZ,{page:e}),(0,I.jsx)(w,{icon:Fg,className:`text-muted-foreground ml-auto size-4`})]},e)}return(0,I.jsx)(N,{open:e,onOpenChange:F9,children:(0,I.jsx)(xe,{children:(0,I.jsxs)(de,{"aria-describedby":void 0,className:`bg-background text-foreground data-open:animate-in data-open:slide-in-from-right fixed inset-0 z-50 flex flex-col pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] text-sm duration-200 outline-none [--workspace-topbar-height:44px] motion-reduce:animate-none`,children:[(0,I.jsxs)(`header`,{className:`flex h-(--workspace-topbar-height) shrink-0 items-center gap-1.5 pr-3 pl-1`,children:[(0,I.jsx)(x,{variant:`ghost`,size:`icon`,"aria-label":`Back`,onClick:i,children:(0,I.jsx)(w,{icon:Pg,className:`text-foreground size-5`,strokeWidth:2})}),(0,I.jsxs)(we,{className:`min-w-0 flex-1 truncate font-medium`,children:[t&&`Settings`,!t&&n.subpage&&n.subpageTitle,!t&&!n.subpage&&n.page]}),!t&&(0,I.jsx)(aZ,{view:n,className:`shrink-0`})]}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 pt-2 pb-6`,children:[t&&(0,I.jsxs)(`div`,{className:`space-y-5`,children:[(0,I.jsx)(XL,{title:`This browser`,children:eZ.map(a)}),(0,I.jsxs)(XL,{title:`Machine`,children:[r!==null&&(0,I.jsxs)(ZL,{label:`Machine`,children:[n.machines.length>1&&(0,I.jsxs)(TL,{value:r.id,onValueChange:e=>$({settingsMachine:e,settingsAccount:null}),children:[(0,I.jsx)(DL,{className:`w-40`,children:(0,I.jsx)(EL,{})}),(0,I.jsx)(OL,{children:n.machines.map(e=>(0,I.jsxs)(kL,{value:e.id,children:[(0,I.jsx)(w,{icon:Fv[e.icon]}),e.name]},e.id))})]}),n.machines.length===1&&(0,I.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1.5 text-sm [&_svg]:size-4`,children:[(0,I.jsx)(w,{icon:Fv[r.icon]}),r.name]})]}),tZ.map(a)]})]}),!t&&(0,I.jsx)(oZ,{view:n})]})]})})})}function lZ(){return(0,I.jsx)(`div`,{className:`grid flex-1 place-items-center p-6`,children:(0,I.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,I.jsx)(`h1`,{className:`text-foreground text-center text-2xl font-normal tracking-tight sm:text-3xl`,children:`Connect a machine`}),(0,I.jsx)(`p`,{className:`text-muted-foreground mt-2 text-center text-sm`,children:`Run this on the computer you want to use, then open the pairing link it prints.`}),(0,I.jsx)(`pre`,{className:`bg-muted text-foreground mt-5 rounded-lg px-4 py-3 font-mono text-sm select-all`,children:`npx offsite serve`}),(0,I.jsx)(`p`,{className:`text-muted-foreground mt-8 mb-3 text-sm`,children:`Or connect it here.`}),(0,I.jsx)(YY,{actions:e=>(0,I.jsx)(x,{type:`submit`,className:`mt-4`,disabled:!e,children:`Connect`})})]})})}function uZ(){let e=Q(e=>e.paletteOpen),t=Q(e=>e.selection),n=Q(e=>e.sessions),r=Q(e=>e.machines),i=Q(e=>e.projects),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(0),l=(0,F.useRef)(null),u=a.toLowerCase().split(/\s+/).filter(Boolean),d=[...t===null?[]:[{key:`new`,label:`New thread`,detail:i.find(e=>e.machine===t.machine&&e.id===t.projectId)?.path??``,run:()=>WC({...t,sessionId:null})}],{key:`accounts`,label:`Manage accounts`,detail:``,run:()=>I9(C9[Z().settings.provider])},{key:`settings`,label:`Settings`,detail:`Theme, notifications, keyboard shortcuts`,run:()=>F9(!0)}],f=n.map(e=>({key:f9(e.machine,e.id),label:e.title,detail:`${e.status===`minimized`?`Minimized · `:``}${r.length>1?`${r.find(t=>t.id===e.machine)?.name??``}:`:``}${i.find(t=>t.machine===e.machine&&t.id===e.projectId)?.path??``}`,run:()=>WC({machine:e.machine,projectId:e.projectId,sessionId:e.id})})),p=[...d,...f].filter(e=>{let t=`${e.label} ${e.detail}`.toLowerCase();return u.every(e=>t.includes(e))}).slice(0,50),m=Math.min(s,p.length-1);(0,F.useLayoutEffect)(()=>{l.current?.querySelector(`[data-active="true"]`)?.scrollIntoView({block:`nearest`})},[m]);function h(e){P9(!1),e.run()}return(0,I.jsx)(_e,{open:e,onOpenChange:e=>{P9(e),o(``),c(0)},children:(0,I.jsxs)(ae,{showCloseButton:!1,className:`top-[20%] translate-y-0 gap-0 overflow-hidden p-0 sm:max-w-xl`,children:[(0,I.jsx)(pe,{className:`sr-only`,children:`Search threads`}),(0,I.jsxs)(`label`,{className:`flex items-center gap-2 border-b px-4`,children:[(0,I.jsx)(w,{icon:H_,className:`text-muted-foreground size-4 shrink-0`}),(0,I.jsx)(`input`,{value:a,onChange:e=>{o(e.target.value),c(0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;c((m+t+p.length)%p.length)}e.key===`Enter`&&m>=0&&(e.preventDefault(),h(p[m]))},placeholder:`Search threads and actions…`,className:`placeholder:text-placeholder/75 h-11 w-full bg-transparent text-sm outline-none`})]}),(0,I.jsxs)(`div`,{ref:l,className:`max-h-96 overflow-y-auto p-1`,children:[p.length===0&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-3 py-6 text-center text-xs`,children:`Nothing matches.`}),p.map((e,t)=>(0,I.jsxs)(`button`,{"data-active":t===m,className:P(`flex w-full cursor-pointer flex-col rounded-lg px-2.5 py-1.5 text-left`,t===m&&`bg-accent`),onMouseMove:()=>c(t),onClick:()=>h(e),children:[(0,I.jsx)(`span`,{className:`truncate text-sm`,children:e.label}),e.detail!==``&&(0,I.jsx)(`span`,{className:`text-secondary-label truncate text-xs`,children:e.detail})]},e.key))]})]})})}var dZ=`group/sidebar-row relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`;function fZ(e){let t=e.session,n=jv(t.machine,t.projectId),r=Q(e=>Fv[T9(e,t.machine).icon]),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(!1),u=(0,F.useRef)(null),d=e.activity?.waiting===!0,f=!d&&e.activity?.running===!0,p=Object.values(e.activity?.tasks??{}).includes(`running`),m=f||!d&&p,h=e.activity?.running===!0||p,g=!d&&!m&&e.unseen,_=!e.selected&&!d&&!g;function v(){nw(t.machine,t.id,e.scope)}function y(){h?l(!0):v()}let b=(0,I.jsx)(LL,{open:c,onOpenChange:l,children:(0,I.jsxs)(zL,{children:[(0,I.jsxs)(BL,{children:[(0,I.jsx)(HL,{children:`Stop running work?`}),(0,I.jsx)(UL,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,I.jsxs)(VL,{children:[(0,I.jsx)(GL,{children:`Cancel`}),(0,I.jsx)(WL,{variant:`destructive`,onClick:v,children:`Stop and Make Inactive`})]})]})}),x=e.saved&&(0,I.jsxs)(yC,{onOpenChange:()=>s(!1),children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground inline-flex h-5 cursor-pointer items-center rounded-md px-1.5`,title:`Thread actions`,onClick:e=>e.stopPropagation(),children:(0,I.jsx)(w,{icon:m_,className:`size-3.5`})})}),(0,I.jsxs)(SC,{align:`end`,className:`w-44`,onClick:e=>e.stopPropagation(),onCloseAutoFocus:e=>{u.current!==null&&(e.preventDefault(),u.current.focus(),u.current.select())},children:[(0,I.jsxs)(CC,{onSelect:()=>a(t.title),children:[(0,I.jsx)(w,{icon:M_}),`Rename`]}),(0,I.jsxs)(CC,{onSelect:()=>void tw(t.machine,t.id,{status:t.status===`pinned`?`active`:`pinned`}),children:[(0,I.jsx)(w,{icon:t.status===`pinned`?N_:P_}),t.status===`pinned`?`Unpin`:`Pin`]}),(0,I.jsxs)(CC,{onSelect:()=>void tw(t.machine,t.id,{status:t.status===`minimized`?`active`:`minimized`}),children:[(0,I.jsx)(w,{icon:t.status===`minimized`?T_:D_}),t.status===`minimized`?`Restore`:`Minimize`]}),t.status===`inactive`?(0,I.jsxs)(CC,{onSelect:()=>void tw(t.machine,t.id,{status:`active`}),children:[(0,I.jsx)(w,{icon:L_}),`Make active`]}):(0,I.jsxs)(CC,{onSelect:y,children:[(0,I.jsx)(w,{icon:I_}),`Make inactive`]}),(0,I.jsx)(OC,{}),(0,I.jsxs)(CC,{variant:`destructive`,title:`Also removes it from ${uw[t.provider]}`,onSelect:e=>{o?rw(t.machine,t.id):(e.preventDefault(),s(!0))},children:[(0,I.jsx)(w,{icon:d_}),o?`Click again to delete`:`Delete`]})]})]}),S=i===null?(0,I.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate text-sm`,_?`text-secondary-label font-normal`:`font-medium`,!_&&(e.unseen||d)&&`text-foreground`,!_&&!e.unseen&&!d&&`text-foreground/90`),children:t.title}):(0,I.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let n=i.trim();a(null),n!==``&&n!==t.title&&tw(t.machine,t.id,{title:n})},children:(0,I.jsx)(`input`,{ref:u,value:i,onChange:e=>a(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>a(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&a(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),C=P(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,_&&`text-sidebar-muted-foreground/75 hover:bg-sidebar-row-hover hover:text-sidebar-foreground`,!e.selected&&!_&&`text-sidebar-foreground hover:bg-sidebar-row-hover bg-transparent`);return e.slim?(0,I.jsxs)(`li`,{className:`list-none`,children:[(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,className:P(dZ,C,`flex h-9 items-center gap-2.5 px-2.5`),onClick:e.onSelect,onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:[(0,I.jsx)(`span`,{className:`flex shrink-0 items-center opacity-40 grayscale transition-opacity group-hover/sidebar-row:opacity-100 group-hover/sidebar-row:grayscale-0`,children:(0,I.jsx)(Lv,{machine:t.machine,projectId:t.projectId})}),S,(0,I.jsxs)(`span`,{className:`relative ml-auto flex h-6 min-w-8 shrink-0 items-center justify-end`,children:[(0,I.jsx)(`span`,{className:`text-secondary-label group-any-hover/sidebar-row:opacity-0 inline-flex justify-end text-xs tabular-nums transition-opacity`,children:fw(t.updatedAt)}),(0,I.jsx)(`span`,{className:`group-any-hover/sidebar-row:opacity-100 absolute inset-y-0 right-0 -mr-1 flex items-center opacity-0 transition-opacity has-[[data-state=open]]:opacity-100`,children:x})]})]}),b]}):(0,I.jsxs)(`li`,{className:`list-none py-0.5`,children:[(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,className:P(dZ,C,m&&!e.selected&&`opacity-70 transition-opacity focus-within:opacity-100 hover:opacity-100`),onClick:e.onSelect,onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:[(0,I.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,I.jsx)(Lv,{machine:t.machine,projectId:t.projectId,className:`size-5`}),S,t.status===`pinned`&&(0,I.jsx)(w,{icon:P_,className:`text-muted-foreground/65 size-3 shrink-0`}),m&&(0,I.jsx)(`span`,{title:f?`Working`:`Running in background`,className:P(`flex`,f?`text-info`:`text-muted-foreground`),children:(0,I.jsx)(w,{icon:e_,className:`size-4 shrink-0 animate-spin`})}),d&&(0,I.jsx)(`span`,{title:`Waiting for approval`,className:`text-warning-foreground flex`,children:(0,I.jsx)(w,{icon:Y_,className:`size-4 shrink-0`})}),g&&(0,I.jsx)(`span`,{title:`Done`,className:`text-success flex`,children:(0,I.jsx)(w,{icon:$g,className:`size-4 shrink-0`})})]}),(0,I.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsx)(w,{icon:r,className:`size-3 shrink-0`}),(0,I.jsxs)(`span`,{className:P(`min-w-0 flex-1 truncate`,_?`font-normal`:`font-medium`),children:[n,t.branch!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | ${t.branch}`})]}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:fw(t.updatedAt)})]})]}),e.saved&&(0,I.jsxs)(`div`,{className:P(`group-any-hover/sidebar-row:pointer-events-auto group-any-hover/sidebar-row:opacity-100 pointer-events-none absolute inset-y-0 right-0 flex w-20 flex-col items-end bg-linear-to-l from-50% to-transparent py-(--sidebar-content-inset) pr-1.5 opacity-0 transition-opacity has-[[data-state=open]]:pointer-events-auto has-[[data-state=open]]:opacity-100`,e.selected?`from-sidebar-row-active`:`from-sidebar-row-hover`),children:[(0,I.jsx)(`div`,{className:`flex h-6 items-center`,children:(0,I.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground inline-flex h-5 cursor-pointer items-center rounded-md px-1.5`,title:`Make inactive`,"aria-label":`Make inactive`,onClick:e=>{e.stopPropagation(),y()},children:(0,I.jsx)(w,{icon:I_,className:`size-3.5 scale-160`})})}),(0,I.jsx)(`div`,{className:`mt-1 flex h-5 items-center`,children:x})]})]}),b]})}function pZ(e){let t=jv(e.machine,e.projectId),n=Q(t=>Fv[T9(t,e.machine).icon]);return(0,I.jsx)(`li`,{className:`list-none py-0.5`,children:(0,I.jsx)(`div`,{role:`button`,tabIndex:0,className:P(dZ,`bg-sidebar-row-active text-sidebar-foreground`),onClick:e.onSelect,children:(0,I.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,I.jsx)(Lv,{machine:e.machine,projectId:e.projectId,className:`size-5`}),(0,I.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,I.jsx)(w,{icon:X_,className:`text-warning-foreground size-4 shrink-0`})]}),(0,I.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsx)(w,{icon:n,className:`size-3 shrink-0`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:[t,(0,I.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | Draft`})]}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`now`})]})]})})})}function mZ(e){return(0,I.jsxs)(yC,{children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsx)(`button`,{className:e.className,title:`Menu`,"aria-label":`Menu`,children:(0,I.jsx)(w,{icon:bee})})}),(0,I.jsxs)(SC,{align:`start`,className:`w-48`,children:[(0,I.jsx)(TC,{value:e.filter,children:[[`active`,L_],[`minimized`,D_],[`inactive`,I_]].map(([t,n])=>(0,I.jsxs)(EC,{value:t,className:`capitalize`,onSelect:()=>e.onFilter(t),children:[(0,I.jsx)(w,{icon:n}),t]},t))}),(0,I.jsx)(OC,{}),(0,I.jsxs)(CC,{onSelect:()=>F9(!0),children:[(0,I.jsx)(w,{icon:G_}),`Settings`]})]})]})}function hZ({...e}){return(0,I.jsx)(Ub,{"data-slot":`context-menu`,...e})}function gZ({className:e,...t}){return(0,I.jsx)(Gb,{"data-slot":`context-menu-trigger`,className:P(`select-none`,e),...t})}function _Z({className:e,...t}){return(0,I.jsx)(Kb,{children:(0,I.jsx)(Jb,{"data-slot":`context-menu-content`,className:P(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...t})})}function vZ({className:e,inset:t,variant:n=`default`,...r}){return(0,I.jsx)(Yb,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:P(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function yZ({className:e,children:t,checked:n,inset:r,...i}){return(0,I.jsxs)(Xb,{"data-slot":`context-menu-checkbox-item`,"data-inset":r,className:P(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...i,children:[(0,I.jsx)(`span`,{className:`pointer-events-none absolute right-2`,children:(0,I.jsx)(Zb,{children:(0,I.jsx)(w,{icon:Pee,strokeWidth:2})})}),t]})}function bZ({className:e,...t}){return(0,I.jsx)(Qb,{"data-slot":`context-menu-separator`,className:P(`-mx-1 my-1 h-px bg-border`,e),...t})}var xZ=`relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none touch-pan-y [-webkit-touch-callout:none] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`;function SZ(e){let t=e.session,n=jv(t.machine,t.projectId),r=Q(e=>Fv[T9(e,t.machine).icon]),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(0),f=(0,F.useRef)(null),p=(0,F.useRef)(null),m=(0,F.useRef)(!1),h=e.activity?.waiting===!0,g=!h&&e.activity?.running===!0,_=Object.values(e.activity?.tasks??{}).includes(`running`),v=g||!h&&_,y=e.activity?.running===!0||_,b=!h&&!v&&e.unseen,x=!e.selected&&!h&&!b,S=e.saved&&!e.slim&&(t.status===`active`||t.status===`pinned`);function C(){nw(t.machine,t.id,e.scope)}function T(){y?l(!0):C()}function E(e){let t=p.current;p.current=null,d(0),t!==null&&t.swiping&&(m.current=!0,e.clientX-t.x>e.currentTarget.offsetWidth*.4&&T())}let D=(0,I.jsx)(LL,{open:c,onOpenChange:l,children:(0,I.jsxs)(zL,{children:[(0,I.jsxs)(BL,{children:[(0,I.jsx)(HL,{children:`Stop running work?`}),(0,I.jsx)(UL,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,I.jsxs)(VL,{children:[(0,I.jsx)(GL,{children:`Cancel`}),(0,I.jsx)(WL,{variant:`destructive`,onClick:C,children:`Stop and Make Inactive`})]})]})}),O=(0,I.jsxs)(_Z,{className:`w-44`,onCloseAutoFocus:e=>{f.current!==null&&(e.preventDefault(),f.current.focus(),f.current.select())},children:[(0,I.jsxs)(vZ,{onSelect:()=>a(t.title),children:[(0,I.jsx)(w,{icon:M_}),`Rename`]}),(0,I.jsxs)(vZ,{onSelect:()=>void tw(t.machine,t.id,{status:t.status===`pinned`?`active`:`pinned`}),children:[(0,I.jsx)(w,{icon:t.status===`pinned`?N_:P_}),t.status===`pinned`?`Unpin`:`Pin`]}),(0,I.jsxs)(vZ,{onSelect:()=>void tw(t.machine,t.id,{status:t.status===`minimized`?`active`:`minimized`}),children:[(0,I.jsx)(w,{icon:t.status===`minimized`?T_:D_}),t.status===`minimized`?`Restore`:`Minimize`]}),t.status===`inactive`?(0,I.jsxs)(vZ,{onSelect:()=>void tw(t.machine,t.id,{status:`active`}),children:[(0,I.jsx)(w,{icon:L_}),`Make active`]}):(0,I.jsxs)(vZ,{onSelect:T,children:[(0,I.jsx)(w,{icon:I_}),`Make inactive`]}),(0,I.jsx)(bZ,{}),(0,I.jsxs)(vZ,{variant:`destructive`,title:`Also removes it from ${uw[t.provider]}`,onSelect:e=>{o?rw(t.machine,t.id):(e.preventDefault(),s(!0))},children:[(0,I.jsx)(w,{icon:d_}),o?`Tap again to delete`:`Delete`]})]}),k=i===null?(0,I.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate text-sm`,x?`text-secondary-label font-normal`:`font-medium`,!x&&(e.unseen||h)&&`text-foreground`,!x&&!e.unseen&&!h&&`text-foreground/90`),children:t.title}):(0,I.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let n=i.trim();a(null),n!==``&&n!==t.title&&tw(t.machine,t.id,{title:n})},children:(0,I.jsx)(`input`,{ref:f,value:i,onChange:e=>a(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>a(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&a(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),A=P(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,x&&`text-sidebar-muted-foreground/75`,!e.selected&&!x&&`text-sidebar-foreground bg-transparent`);return e.slim?(0,I.jsxs)(`li`,{className:`list-none`,children:[(0,I.jsxs)(hZ,{onOpenChange:()=>s(!1),children:[(0,I.jsx)(gZ,{asChild:!0,disabled:!e.saved,children:(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,className:P(xZ,A,`flex h-9 items-center gap-2.5 px-2.5`),onClick:e.onSelect,onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:[(0,I.jsx)(`span`,{className:`flex shrink-0 items-center opacity-40 grayscale`,children:(0,I.jsx)(Lv,{machine:t.machine,projectId:t.projectId})}),k,(0,I.jsx)(`span`,{className:`text-secondary-label ml-auto shrink-0 text-xs tabular-nums`,children:fw(t.updatedAt)})]})}),O]}),D]}):(0,I.jsxs)(`li`,{className:`relative list-none py-0.5`,children:[u>0&&(0,I.jsx)(`div`,{className:`bg-destructive absolute inset-x-0 inset-y-0.5 flex items-center rounded-md px-4 text-white`,children:(0,I.jsx)(w,{icon:I_,className:`size-6`})}),(0,I.jsxs)(hZ,{onOpenChange:()=>s(!1),children:[(0,I.jsx)(gZ,{asChild:!0,disabled:!e.saved,children:(0,I.jsx)(`div`,{role:`button`,tabIndex:0,className:P(xZ,A,v&&!e.selected&&`opacity-70`,u>0&&`bg-sidebar`),style:u>0?{transform:`translateX(${u}px)`}:void 0,onClick:()=>{m.current?m.current=!1:e.onSelect()},onPointerDown:e=>{S&&e.pointerType===`touch`&&(m.current=!1,p.current={x:e.clientX,y:e.clientY,swiping:!1})},onPointerMove:e=>{let t=p.current;if(t===null)return;let n=e.clientX-t.x,r=e.clientY-t.y;!t.swiping&&Math.abs(n)<10&&Math.abs(r)<10||(!t.swiping&&n<=Math.abs(r)?p.current=null:(t.swiping=!0,d(Math.max(0,n))))},onPointerUp:E,onPointerCancel:()=>{p.current=null,d(0)},onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:(0,I.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,I.jsx)(Lv,{machine:t.machine,projectId:t.projectId,className:`size-5`}),k,t.status===`pinned`&&(0,I.jsx)(w,{icon:P_,className:`text-muted-foreground/65 size-3 shrink-0`}),v&&(0,I.jsx)(`span`,{title:g?`Working`:`Running in background`,className:P(`flex`,g?`text-info`:`text-muted-foreground`),children:(0,I.jsx)(w,{icon:e_,className:`size-4 shrink-0 animate-spin`})}),h&&(0,I.jsx)(`span`,{title:`Waiting for approval`,className:`text-warning-foreground flex`,children:(0,I.jsx)(w,{icon:Y_,className:`size-4 shrink-0`})}),b&&(0,I.jsx)(`span`,{title:`Done`,className:`text-success flex`,children:(0,I.jsx)(w,{icon:$g,className:`size-4 shrink-0`})})]}),(0,I.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsx)(w,{icon:r,className:`size-3 shrink-0`}),(0,I.jsxs)(`span`,{className:P(`min-w-0 flex-1 truncate`,x?`font-normal`:`font-medium`),children:[n,t.branch!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | ${t.branch}`})]}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:fw(t.updatedAt)})]})]})})}),O]}),D]})}function CZ(e){let t=jv(e.machine,e.projectId),n=Q(t=>Fv[T9(t,e.machine).icon]);return(0,I.jsx)(`li`,{className:`list-none py-0.5`,children:(0,I.jsx)(`div`,{role:`button`,tabIndex:0,className:P(xZ,`bg-sidebar-row-active text-sidebar-foreground`),onClick:e.onSelect,children:(0,I.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,I.jsx)(Lv,{machine:e.machine,projectId:e.projectId,className:`size-5`}),(0,I.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,I.jsx)(w,{icon:X_,className:`text-warning-foreground size-4 shrink-0`})]}),(0,I.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsx)(w,{icon:n,className:`size-3 shrink-0`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:[t,(0,I.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | Draft`})]}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`now`})]})]})})})}function wZ({className:e,...t}){return(0,I.jsx)(wx,{"data-slot":`label`,className:P(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var TZ=/\.(png|jpe?g|gif|webp|svg)$/i;function EZ(e){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(null),s=t?.filter(e=>TZ.test(e)&&e.toLowerCase().includes(r.toLowerCase()));return(0,F.useEffect)(()=>{let t=!1;return(async()=>{try{let r=await L(e.machine,`files.list`,{projectId:e.projectId});t||n(r)}catch(e){t||o(Oe(e))}})(),()=>{t=!0}},[e.machine,e.projectId]),(0,I.jsx)(_e,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(ae,{className:`gap-0 overflow-hidden p-0 sm:max-w-lg`,showCloseButton:!1,"aria-describedby":void 0,children:[(0,I.jsx)(pe,{className:`sr-only`,children:`Pick icon`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 border-b p-1`,children:[(0,I.jsxs)(`label`,{className:`flex h-7 min-w-0 flex-1 items-center gap-2.5 px-2`,children:[(0,I.jsx)(w,{icon:H_,className:`text-muted-foreground size-4 flex-none`}),(0,I.jsx)(`input`,{className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none`,placeholder:`Search images in this project`,value:r,onChange:e=>i(e.target.value)})]}),(0,I.jsx)(fe,{asChild:!0,children:(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,children:(0,I.jsx)(w,{icon:Wg})})})]}),(0,I.jsxs)(`div`,{className:`h-72 overflow-y-auto p-1`,children:[s?.map(t=>(0,I.jsxs)(`button`,{className:`hover:bg-muted flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm transition-colors`,onClick:async()=>{try{let n=await L(e.machine,`files.read`,{projectId:e.projectId,path:t});n.kind===`image`?e.onPick(`data:${n.mediaType};base64,${n.data}`):n.kind===`large`?o(`${t} is too large`):o(`${t} is not an image`)}catch(e){o(Oe(e))}},children:[(0,I.jsx)(w,{icon:S_,className:`text-muted-foreground size-4 flex-none`}),(0,I.jsx)(`span`,{className:`truncate font-mono text-xs`,children:t})]},t)),s?.length===0&&(0,I.jsx)(`p`,{className:`text-muted-foreground grid h-full place-items-center text-sm`,children:r===``?`No images in this project`:`No matching images`})]}),a!==null&&(0,I.jsx)(`p`,{className:`text-destructive border-t px-3 py-2 text-sm break-all`,children:a})]})})}function DZ(e){let t=Q(e=>e.machines),[n,r]=(0,F.useState)(e.machine),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(()=>OZ(t.find(t=>t.id===e.machine))),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(!1),m=c.trim()===``?void 0:i?.listing,h=m?.directories.filter(e=>e.name.toLowerCase().includes(u.toLowerCase()));function g(e){l(e),d(``)}return(0,F.useEffect)(()=>{if(c.trim()===``)return;let e=!1,t=setTimeout(async()=>{try{let t=await L(n,`directories.list`,{path:c});if(e)return;a({path:c,listing:t}),s(null)}catch(t){if(e)return;a(null),s(Oe(t))}},150);return()=>{e=!0,clearTimeout(t)}},[n,c]),(0,I.jsx)(_e,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(ae,{className:`gap-0 overflow-hidden p-0 sm:max-w-lg`,showCloseButton:!1,"aria-describedby":void 0,children:[(0,I.jsx)(pe,{className:`sr-only`,children:`Add project`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 border-b p-1`,children:[(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Home folder`,onClick:()=>g(`~`),children:(0,I.jsx)(w,{icon:cee})}),(0,I.jsx)(`div`,{className:`bg-border mx-0.5 h-4 w-px`}),(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Parent folder`,disabled:m?.parent===void 0||m.parent===null,onClick:()=>{m?.parent!==void 0&&m.parent!==null&&g(m.parent)},children:(0,I.jsx)(w,{icon:Rg})}),(0,I.jsx)(`input`,{"aria-label":`Folder path`,className:`hover:bg-muted focus:bg-muted h-7 min-w-0 flex-1 rounded-md bg-transparent px-1.5 font-mono text-xs outline-none`,spellCheck:!1,value:c,onChange:e=>g(e.target.value)}),(0,I.jsx)(fe,{asChild:!0,children:(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,children:(0,I.jsx)(w,{icon:Wg})})})]}),(0,I.jsxs)(`label`,{className:`flex h-9 items-center gap-2.5 border-b px-3`,children:[(0,I.jsx)(w,{icon:H_,className:`text-muted-foreground size-4 flex-none`}),(0,I.jsx)(`input`,{className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none`,placeholder:`Search this folder`,value:u,onChange:e=>d(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`h-72 overflow-y-auto p-1`,children:[h?.map(e=>(0,I.jsxs)(`button`,{className:`hover:bg-muted flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm transition-colors`,onClick:()=>g(e.path),children:[(0,I.jsx)(w,{icon:v_,className:`text-muted-foreground size-4 flex-none`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),h?.length===0&&(0,I.jsx)(`p`,{className:`text-muted-foreground grid h-full place-items-center text-sm`,children:u===``?`No folders here`:`No matching folders`})]}),o!==null&&c.trim()!==``&&(0,I.jsx)(`p`,{className:`text-destructive border-t px-3 py-2 text-sm break-all`,children:o}),(0,I.jsxs)(ve,{className:`border-t p-3`,children:[t.length>1&&(0,I.jsxs)(TL,{value:n,onValueChange:e=>{r(e),a(null),g(OZ(t.find(t=>t.id===e)))},children:[(0,I.jsx)(DL,{className:`sm:mr-auto sm:w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsx)(OL,{children:t.map(e=>(0,I.jsx)(kL,{value:e.id,disabled:e.status!==`online`,children:e.name},e.id))})]}),(0,I.jsx)(x,{disabled:i?.path!==c||f,onClick:async()=>{if(i!==null&&i.path===c){p(!0);try{e.onAdd({...await Mv(n,i.listing.path),machine:n})}catch(e){s(Oe(e)),p(!1)}}},children:`Add project`})]})]})})}function OZ(e){return e===void 0||e.config===null||e.system===null?`~`:e.config.workingDir[e.system.platform]??`~`}function kZ(e){let t=e.project.path,[n,r]=(0,F.useState)(e.project.name),[i,a]=(0,F.useState)(e.project.logo),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(!1),m=(0,F.useRef)(null);return(0,I.jsx)(_e,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(ae,{className:`gap-0 overflow-hidden p-0 sm:max-w-md`,children:[(0,I.jsxs)(`form`,{className:`grid`,onSubmit:async t=>{t.preventDefault(),l(!0);try{await Nv(e.project.machine,e.project.id,{name:n,logo:i}),e.onClose()}catch(e){s(Oe(e)),l(!1)}},children:[(0,I.jsxs)(se,{className:`gap-1 px-6 pt-4 pr-12`,children:[(0,I.jsx)(pe,{className:`text-base`,children:`Edit project`}),(0,I.jsx)(ge,{className:`truncate font-mono text-xs`,title:t,children:t})]}),(0,I.jsxs)(`div`,{className:`grid gap-6 p-6`,children:[(0,I.jsxs)(`div`,{className:`grid gap-2.5`,children:[(0,I.jsx)(wZ,{children:`Icon`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,I.jsx)(Rv,{name:n.trim()===``?dw(t):n,logo:i,className:`ring-foreground/10 size-16 rounded-2xl ring-1 [&>img]:rounded-2xl [&>svg]:rounded-2xl`}),(0,I.jsxs)(`div`,{className:`grid gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,title:`Upload an image from this device`,onClick:()=>m.current?.click(),children:[(0,I.jsx)(w,{icon:Lee}),`Upload`]}),(0,I.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,title:`Choose an image from the project on the server`,onClick:()=>p(!0),children:[(0,I.jsx)(w,{icon:v_}),`Choose from project`]}),i!==null&&(0,I.jsx)(x,{type:`button`,variant:`ghost-muted`,size:`sm`,onClick:()=>a(null),children:`Remove`})]}),(0,I.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`PNG, JPG, GIF, WebP, SVG or ICO, up to 384 KB`})]})]}),(0,I.jsx)(`input`,{ref:m,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp,image/svg+xml,image/x-icon`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];e.target.value=``,t!==void 0&&a(`data:${t.type};base64,${await PC(t)}`)}})]}),(0,I.jsxs)(`div`,{className:`grid gap-2`,children:[(0,I.jsx)(wZ,{htmlFor:`project-name`,children:`Name`}),(0,I.jsx)(wL,{id:`project-name`,placeholder:dw(t),value:n,onChange:e=>r(e.target.value)})]}),o!==null&&(0,I.jsx)(`p`,{className:`text-destructive text-sm break-all`,children:o})]}),(0,I.jsxs)(ve,{className:`bg-muted/40 border-t px-6 py-4`,children:[(0,I.jsxs)(x,{type:`button`,variant:u?`destructive`:`ghost`,className:P(`sm:mr-auto`,!u&&`text-destructive hover:bg-destructive/10 hover:text-destructive`),title:`Its threads stay in their provider`,onClick:async()=>{if(!u)d(!0);else try{await Pv(e.project.machine,e.project.id),e.onRemoved()}catch(e){s(Oe(e))}},children:[(0,I.jsx)(w,{icon:d_,className:`text-current`}),u?`Click again to remove`:`Remove project`]}),(0,I.jsx)(x,{type:`button`,variant:`outline`,onClick:e.onClose,children:`Cancel`}),(0,I.jsx)(x,{type:`submit`,disabled:n.trim()===``||c,children:`Save`})]})]}),f&&(0,I.jsx)(EZ,{machine:e.project.machine,projectId:e.project.id,onClose:()=>p(!1),onPick:e=>{a(e),p(!1)}})]})})}function AZ(e){let t=Q(e=>e.machines),n=Q(e=>e.projects),r=Q(e=>e.sessions),i=Q(e=>e.unseen),[a,o]=(0,F.useState)(!1),s=t.map(e=>({machine:e,projects:n.filter(t=>t.machine===e.id).sort((e,t)=>e.name.localeCompare(t.name))})).filter(e=>e.projects.length>0),c=r.filter(e=>{let n=k9(t,e.machine,e.id);return n?.running===!0||n?.waiting===!0||Object.values(n?.tasks??{}).includes(`running`)||i.includes(f9(e.machine,e.id))});function l(e,t){return n.find(n=>n.machine===e&&n.id===t)}function u(e){return e.status===`online`?e.name:e.status===`unpaired`?`${e.name} · needs pairing`:`${e.name} · offline`}return(0,I.jsxs)(yC,{open:a,onOpenChange:o,children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`hover:bg-sidebar-row-hover data-[state=open]:bg-sidebar-row-hover -ml-1.5 flex h-7 min-w-0 cursor-pointer items-center gap-1.5 rounded-[var(--control-radius)] px-1.5 text-sm font-medium`,title:e.scope===null?`Inbox`:l(e.scope.machine,e.scope.projectId)?.path,children:[e.scope===null?(0,I.jsx)(w,{icon:C_,className:`size-4 shrink-0 text-(--sidebar-icon-color)`}):(0,I.jsx)(Lv,{machine:e.scope.machine,projectId:e.scope.projectId,className:`size-4 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.scope===null?`Inbox`:l(e.scope.machine,e.scope.projectId)?.name}),(0,I.jsx)(w,{icon:Yg,className:`text-sidebar-muted-foreground size-3.5 shrink-0`})]})}),(0,I.jsxs)(SC,{className:`w-64`,children:[(0,I.jsxs)(TC,{value:e.scope===null?``:f9(e.scope.machine,e.scope.projectId),children:[(0,I.jsxs)(EC,{value:``,className:`pr-9 pl-8 *:data-[slot=dropdown-menu-radio-item-indicator]:right-auto *:data-[slot=dropdown-menu-radio-item-indicator]:left-2`,onSelect:()=>e.onScope(null),children:[(0,I.jsx)(w,{icon:C_}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Inbox`}),c.length>0&&(0,I.jsx)(`span`,{className:`text-foreground grid h-4 min-w-4 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_22%,var(--background))] px-1 text-[10px] leading-none font-medium tabular-nums`,children:c.length})]}),s.length>0&&(0,I.jsx)(OC,{}),s.map(({machine:n,projects:r},i)=>(0,I.jsxs)(F.Fragment,{children:[i>0&&(0,I.jsx)(OC,{}),t.length>1&&(0,I.jsxs)(DC,{className:`text-2xs flex items-center gap-1 pl-5`,children:[(0,I.jsx)(w,{icon:Fv[n.icon],className:`size-3 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:u(n)})]}),r.map(t=>{let n=c.filter(e=>e.machine===t.machine&&e.projectId===t.id).length;return(0,I.jsxs)(EC,{value:f9(t.machine,t.id),title:t.path,className:`group/project pr-2 pl-8 *:data-[slot=dropdown-menu-radio-item-indicator]:right-auto *:data-[slot=dropdown-menu-radio-item-indicator]:left-2`,onSelect:()=>e.onScope({machine:t.machine,projectId:t.id}),onContextMenu:n=>{n.preventDefault(),o(!1),e.onEdit(t)},children:[(0,I.jsx)(Lv,{machine:t.machine,projectId:t.id,className:`size-5 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.name}),n>0&&(0,I.jsx)(`span`,{className:`text-foreground grid h-4 min-w-4 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_22%,var(--background))] px-1 text-[10px] leading-none font-medium tabular-nums`,children:n}),(0,I.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground hover:bg-foreground/10 -my-0.5 grid size-5 shrink-0 cursor-pointer place-items-center rounded-sm opacity-0 transition-opacity group-data-highlighted/project:opacity-100 pointer-coarse:opacity-100 [&_svg]:size-3.5`,title:`Configure project`,"aria-label":`Configure ${t.name}`,onClick:n=>{n.stopPropagation(),o(!1),e.onEdit(t)},children:(0,I.jsx)(w,{icon:G_})})]},f9(t.machine,t.id))})]},n.id))]}),(0,I.jsx)(OC,{}),(0,I.jsxs)(CC,{className:`pl-8`,onSelect:e.onAddProject,children:[(0,I.jsx)(w,{icon:Og}),`Add project…`]}),(0,I.jsxs)(CC,{className:`pl-8`,onSelect:e.onAddMachine,children:[(0,I.jsx)(w,{icon:s_}),`Add machine…`]})]})]})}var jZ=`text-sidebar-muted-foreground/80 hover:bg-sidebar-row-hover hover:text-sidebar-foreground flex shrink-0 cursor-pointer items-center justify-center rounded-[var(--control-radius)] [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-(--sidebar-icon-color) hover:[&>svg]:text-sidebar-foreground`;function MZ(e){let t=Q(e=>e.selection),n=Q(e=>e.machines),r=Q(e=>e.sessions),i=Q(e=>e.projects),a=Q(e=>e.settings.provider),o=Q(e=>e.unseen),s=Q(e=>e.error),[c,l]=Av(`sidebarScope`,null),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(null),[g,_]=(0,F.useState)(!1),[v,y]=(0,F.useState)(!1),[b,x]=(0,F.useState)(`active`),[S,C]=Av(`sidebarWidth`,240),T=r.filter(e=>c===null||e.machine===c.machine&&e.projectId===c.projectId).sort((e,t)=>t.updatedAt-e.updatedAt),E=[...T.filter(e=>e.status===`pinned`),...T.filter(e=>e.status===`active`)],D=T.filter(e=>e.status===`minimized`),O=T.filter(e=>e.status===`inactive`),k=t!==null&&t.sessionId!==null&&!r.some(e=>e.machine===t.machine&&e.id===t.sessionId)?{machine:t.machine,id:t.sessionId,provider:a,title:`New thread`,projectId:t.projectId,branch:null,updatedAt:Date.now(),status:`active`}:null,A=s!==null&&(0,I.jsxs)(sL,{onOpenChange:e=>!e&&rue(),children:[(0,I.jsx)(cL,{asChild:!0,children:(0,I.jsx)(`button`,{className:P(jZ,`[&>svg]:text-error hover:[&>svg]:text-error ml-auto size-7`),title:`Error`,"aria-label":`Error`,children:(0,I.jsx)(w,{icon:kg})})}),(0,I.jsx)(lL,{align:`end`,collisionPadding:12,className:`text-error-foreground max-w-[min(20rem,calc(100vw-2rem))] p-3 text-sm whitespace-pre-wrap`,children:s})]}),ee=e.mobile?CZ:pZ,j=c?.machine??t?.machine??n.at(0)?.id;function M(e,t,n){WC({machine:e,projectId:t,sessionId:n})}function te(){let e=c??t??ne();e===null?d(!0):M(e.machine,e.projectId,null)}function ne(){let e=localStorage.getItem(`lastProject`),t=e===null?null:JSON.parse(e),n=(t===null?void 0:i.find(e=>e.machine===t.machine&&e.id===t.projectId))??i.at(0);return n===void 0?null:{machine:n.machine,projectId:n.id}}Tv([`mod+n`,`mod+t`],te,{enableOnFormTags:!0,preventDefault:!0});function re(e){let t=e.clientX-S;De(e,e=>{let n=Math.min(480,Math.max(200,e.clientX-t));C(n)})}function ie(r,i){let a=e.mobile?SZ:fZ;return(0,I.jsx)(a,{session:r,slim:i,selected:t?.machine===r.machine&&t.sessionId===r.id,activity:k9(n,r.machine,r.id),unseen:o.includes(f9(r.machine,r.id)),saved:r!==k,scope:c,onSelect:()=>M(r.machine,r.projectId,r.id)},f9(r.machine,r.id))}function ae(e,t,n,r,i){return t.length===0?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`li`,{className:P(`mx-0.5 h-9 pt-2`,i&&`mt-auto`),children:(0,I.jsxs)(`button`,{"aria-expanded":n,className:`text-sidebar-muted-foreground/60 flex h-9 w-full cursor-pointer items-center gap-2 rounded-md px-2 text-left text-xs font-medium`,onClick:r,children:[(0,I.jsx)(`span`,{className:`shrink-0`,children:n?e:`${e} (${t.length})`}),(0,I.jsx)(`span`,{className:`bg-sidebar-border/60 h-px min-w-2 flex-1`}),(0,I.jsx)(w,{icon:Yg,className:P(`size-3 shrink-0 transition-transform`,!n&&`rotate-180`)})]})}),n&&t.map(e=>ie(e,e.status===`inactive`))]})}return(0,I.jsxs)(`aside`,{className:P(`bg-sidebar text-sidebar-foreground border-sidebar-border flex flex-none border-r select-none`,e.className),children:[(0,I.jsxs)(`div`,{className:P(`relative flex min-w-0 flex-col`,e.mobile&&`flex-1`),style:e.mobile?void 0:{width:S},children:[(0,I.jsxs)(`div`,{className:`flex h-(--workspace-topbar-height) shrink-0 items-center gap-2 px-3`,children:[e.mobile?(0,I.jsx)(mZ,{className:P(jZ,`size-7`),filter:b,onFilter:x}):(0,I.jsx)(`button`,{className:P(jZ,`size-7`),title:`Hide sidebar (${Te}+B)`,"aria-label":`Hide sidebar`,onClick:e.onHide,children:(0,I.jsx)(w,{icon:Dee})}),(0,I.jsx)(AZ,{scope:c,onScope:l,onEdit:h,onAddProject:()=>d(!0),onAddMachine:()=>p(!0)}),e.mobile&&A,(0,I.jsx)(`button`,{className:P(jZ,`size-7`,(!e.mobile||s===null)&&`ml-auto`),title:`Search (${Te}+K)`,"aria-label":`Search`,onClick:()=>P9(!0),children:(0,I.jsx)(w,{icon:H_})}),(0,I.jsx)(`button`,{className:P(jZ,`size-7`),title:`New thread (${Te}+N)`,onClick:te,children:(0,I.jsx)(w,{icon:X_})})]}),(0,I.jsx)(`nav`,{className:`flex min-h-0 flex-1 [scrollbar-width:none] flex-col overflow-y-auto px-(--sidebar-content-inset) pb-(--sidebar-content-inset)`,children:(0,I.jsxs)(`ul`,{className:`flex flex-1 flex-col gap-px`,children:[e.mobile&&b!==`active`&&(0,I.jsxs)(I.Fragment,{children:[(b===`minimized`?D:O).map(e=>ie(e,b===`inactive`)),(b===`minimized`?D:O).length===0&&(0,I.jsxs)(`li`,{className:`text-sidebar-muted-foreground/60 px-2.5 py-6 text-center text-xs`,children:[`No `,b,` threads`]})]}),(!e.mobile||b===`active`)&&(0,I.jsxs)(I.Fragment,{children:[t!==null&&t.sessionId===null&&(0,I.jsx)(ee,{machine:t.machine,projectId:t.projectId,onSelect:()=>M(t.machine,t.projectId,null)}),k!==null&&ie(k,!1),E.map(e=>ie(e,!1)),E.length===0&&k===null&&t?.sessionId!==null&&(0,I.jsx)(`li`,{className:`text-sidebar-muted-foreground/60 px-2.5 py-6 text-center text-xs`,children:`No threads yet`})]}),!e.mobile&&(0,I.jsxs)(I.Fragment,{children:[ae(`Minimized`,D,g,()=>_(!g),!0),ae(`Inactive`,O,v,()=>y(!v),D.length===0)]})]})}),!e.mobile&&(0,I.jsxs)(`div`,{className:`border-sidebar-border flex shrink-0 items-center gap-1 border-t p-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`button`,{className:P(jZ,`h-8 flex-1 justify-start gap-2 px-2.5 text-sm`),title:`Settings`,onClick:()=>F9(!0),children:[(0,I.jsx)(w,{icon:G_}),`Settings`]}),A]}),!e.mobile&&(0,I.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,className:`group absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize select-none`,onPointerDown:re,children:(0,I.jsx)(`span`,{className:`group-hover:bg-border group-active:bg-primary/60 pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 transition-colors`})})]}),u&&j===void 0&&(0,I.jsx)(XY,{onClose:()=>d(!1)}),u&&j!==void 0&&(0,I.jsx)(DZ,{machine:j,onClose:()=>d(!1),onAdd:e=>{d(!1),l({machine:e.machine,projectId:e.id}),M(e.machine,e.id,null)}}),f&&(0,I.jsx)(XY,{onClose:()=>p(!1)}),m!==null&&(0,I.jsx)(kZ,{project:m,onClose:()=>h(null),onRemoved:()=>{c?.machine===m.machine&&c.projectId===m.id&&l(null),h(null)}})]})}var NZ=`/assets/ghostty-vt-CQAu1Gs5.wasm`,PZ=Uint8Array,FZ=Uint16Array,IZ=Int32Array,LZ=new PZ([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),RZ=new PZ([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),zZ=new PZ([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),BZ=function(e,t){for(var n=new FZ(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new IZ(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},VZ=BZ(LZ,2),HZ=VZ.b,UZ=VZ.r;HZ[28]=258,UZ[258]=28;var WZ=BZ(RZ,0),GZ=WZ.b;WZ.r;for(var KZ=new FZ(32768),qZ=0;qZ<32768;++qZ){var JZ=(qZ&43690)>>1|(qZ&21845)<<1;JZ=(JZ&52428)>>2|(JZ&13107)<<2,JZ=(JZ&61680)>>4|(JZ&3855)<<4,KZ[qZ]=((JZ&65280)>>8|(JZ&255)<<8)>>1}for(var YZ=(function(e,t,n){for(var r=e.length,i=0,a=new FZ(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new FZ(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new FZ(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[KZ[d]>>c]=l}else for(s=new FZ(r),i=0;i<r;++i)e[i]&&(s[i]=KZ[o[e[i]-1]++]>>15-e[i]);return s}),XZ=new PZ(288),qZ=0;qZ<144;++qZ)XZ[qZ]=8;for(var qZ=144;qZ<256;++qZ)XZ[qZ]=9;for(var qZ=256;qZ<280;++qZ)XZ[qZ]=7;for(var qZ=280;qZ<288;++qZ)XZ[qZ]=8;for(var ZZ=new PZ(32),qZ=0;qZ<32;++qZ)ZZ[qZ]=5;var QZ=YZ(XZ,9,1),$Z=YZ(ZZ,5,1),eQ=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},tQ=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},nQ=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},rQ=function(e){return(e+7)/8|0},iQ=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new PZ(e.subarray(t,n))},aQ=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],oQ=function(e,t,n){var r=Error(t||aQ[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,oQ),!n)throw r;return r},sQ=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new PZ(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new PZ(i*3));var l=function(e){var t=n.length;if(e>t){var r=new PZ(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=tQ(e,d,1);var v=tQ(e,d+1,3);if(d+=3,!v){var y=rQ(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&oQ(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=QZ,m=$Z,h=9,g=5;else if(v==2){var S=tQ(e,d,31)+257,C=tQ(e,d+10,15)+4,w=S+tQ(e,d+5,31)+1;d+=14;for(var T=new PZ(w),E=new PZ(19),D=0;D<C;++D)E[zZ[D]]=tQ(e,d+D*3,7);d+=C*3;for(var O=eQ(E),k=(1<<O)-1,A=YZ(E,O,1),D=0;D<w;){var ee=A[tQ(e,d,k)];d+=ee&15;var y=ee>>4;if(y<16)T[D++]=y;else{var j=0,M=0;for(y==16?(M=3+tQ(e,d,3),d+=2,j=T[D-1]):y==17?(M=3+tQ(e,d,7),d+=3):y==18&&(M=11+tQ(e,d,127),d+=7);M--;)T[D++]=j}}var te=T.subarray(0,S),ne=T.subarray(S);h=eQ(te),g=eQ(ne),p=YZ(te,h,1),m=YZ(ne,g,1)}else oQ(1);if(d>_){c&&oQ(0);break}}s&&l(f+131072);for(var re=(1<<h)-1,ie=(1<<g)-1,ae=d;;ae=d){var j=p[nQ(e,d)&re],oe=j>>4;if(d+=j&15,d>_){c&&oQ(0);break}if(j||oQ(2),oe<256)n[f++]=oe;else if(oe==256){ae=d,p=null;break}else{var se=oe-254;if(oe>264){var D=oe-257,ce=LZ[D];se=tQ(e,d,(1<<ce)-1)+HZ[D],d+=ce}var le=m[nQ(e,d)&ie],ue=le>>4;le||oQ(3),d+=le&15;var ne=GZ[ue];if(ue>3){var ce=RZ[ue];ne+=nQ(e,d)&(1<<ce)-1,d+=ce}if(d>_){c&&oQ(0);break}s&&l(f+131072);var de=f+se;if(f<ne){var fe=a-ne,pe=Math.min(ne,de);for(fe+f<0&&oQ(3);f<pe;++f)n[f]=r[fe+f]}for(;f<de;++f)n[f]=n[f-ne]}}t.l=p,t.p=ae,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?iQ(n,0,f):n.subarray(0,f)},cQ=new PZ(0),lQ=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&oQ(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&oQ(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2},uQ=function(){function e(e,t){typeof e==`function`&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new PZ(32768),this.p=new PZ(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||oQ(5),this.d&&oQ(4),!this.p.length)this.p=e;else if(e.length){var t=new PZ(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=sQ(this.p,this.s,this.o);this.ondata(iQ(n,t,this.s.b),this.d),this.o=iQ(n,this.s.b-32768),this.s.b=this.o.length,this.p=iQ(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),dQ=function(){function e(e,t){uQ.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(uQ.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(lQ(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&oQ(6,`invalid zlib data`),this.p=this.p.subarray(0,-4)),uQ.prototype.c.call(this,t)},e}();function fQ(e,t){return sQ(e.subarray(lQ(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var pQ=typeof TextDecoder<`u`&&new TextDecoder;try{pQ.decode(cQ,{stream:!0})}catch{}function mQ(e,t=`utf8`){return new TextDecoder(t).decode(e)}var hQ=new TextEncoder;function gQ(e){return hQ.encode(e)}var _Q=8192,vQ=(()=>{let e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])})(),yQ={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array},bQ=class e{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=_Q,n={}){let r=!1;typeof t==`number`?t=new ArrayBuffer(t):(r=!0,this.lastWrittenByte=t.byteLength);let i=n.offset?n.offset>>>0:0,a=t.byteLength-i,o=i;(ArrayBuffer.isView(t)||t instanceof e)&&(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+i),t=t.buffer),this.lastWrittenByte=r?a:0,this.buffer=t,this.length=a,this.byteLength=a,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,a),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let e=this._marks.pop();if(e===void 0)throw Error(`Mark stack empty`);return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){let t=(this.offset+e)*2,n=new Uint8Array(t);n.set(new Uint8Array(this.buffer)),this.buffer=n.buffer,this.length=t,this.byteLength=t,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,`uint8`)}readArray(e,t){let n=yQ[t].BYTES_PER_ELEMENT*e,r=this.byteOffset+this.offset,i=this.buffer.slice(r,r+n);if(this.littleEndian===vQ&&t!==`uint8`&&t!==`int8`){let e=new Uint8Array(this.buffer.slice(r,r+n));e.reverse();let i=new yQ[t](e.buffer);return this.offset+=n,i.reverse(),i}let a=new yQ[t](i);return this.offset+=n,a}readInt16(){let e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){let e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){let e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){let e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){let e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){let e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){let e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){let e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t=``;for(let n=0;n<e;n++)t+=this.readChar();return t}readUtf8(e=1){return mQ(this.readBytes(e))}decodeText(e=1,t=`utf8`){return mQ(this.readBytes(e),t)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let t=0;t<e.length;t++)this._data.setUint8(this.offset++,e[t]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let t=0;t<e.length;t++)this.writeUint8(e.charCodeAt(t));return this}writeUtf8(e){return this.writeBytes(gQ(e))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}},xQ=[];for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;xQ[e]=t}var SQ=4294967295;function CQ(e,t,n){let r=e;for(let e=0;e<n;e++)r=xQ[(r^t[e])&255]^r>>>8;return r}function wQ(e,t){return(CQ(SQ,e,t)^SQ)>>>0}function TQ(e,t,n){let r=e.readUint32(),i=wQ(new Uint8Array(e.buffer,e.byteOffset+e.offset-t-4,t),t);if(i!==r)throw Error(`CRC mismatch for chunk ${n}. Expected ${r}, found ${i}`)}function EQ(e,t,n){for(let r=0;r<n;r++)t[r]=e[r]}function DQ(e,t,n,r){let i=0;for(;i<r;i++)t[i]=e[i];for(;i<n;i++)t[i]=e[i]+t[i-r]&255}function OQ(e,t,n,r){let i=0;if(n.length===0)for(;i<r;i++)t[i]=e[i];else for(;i<r;i++)t[i]=e[i]+n[i]&255}function kQ(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+(t[a-i]>>1)&255}else{for(;a<i;a++)t[a]=e[a]+(n[a]>>1)&255;for(;a<r;a++)t[a]=e[a]+(t[a-i]+n[a]>>1)&255}}function AQ(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+t[a-i]&255}else{for(;a<i;a++)t[a]=e[a]+n[a]&255;for(;a<r;a++)t[a]=e[a]+jQ(t[a-i],n[a],n[a-i])&255}}function jQ(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}function MQ(e,t,n,r,i,a){switch(e){case 0:EQ(t,n,i);break;case 1:DQ(t,n,i,a);break;case 2:OQ(t,n,r,i);break;case 3:kQ(t,n,r,i,a);break;case 4:AQ(t,n,r,i,a);break;default:throw Error(`Unsupported filter: ${e}`)}}var NQ=new Uint16Array([255]),PQ=new Uint8Array(NQ.buffer)[0]===255;function FQ(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],s=Math.ceil(a/8)*i,c=new Uint8Array(r*n*s),l=0;for(let e=0;e<7;e++){let i=o[e],a=Math.ceil((n-i.x)/i.xStep),u=Math.ceil((r-i.y)/i.yStep);if(a<=0||u<=0)continue;let d=a*s,f=new Uint8Array(d);for(let e=0;e<u;e++){let o=t[l++],u=t.subarray(l,l+d);l+=d;let p=new Uint8Array(d);MQ(o,u,p,f,d,s),f.set(p);for(let t=0;t<a;t++){let a=i.x+t*i.xStep,o=i.y+e*i.yStep;if(!(a>=n||o>=r))for(let e=0;e<s;e++)c[(o*n+a)*s+e]=p[t*s+e]}}}if(a===16){let e=new Uint16Array(c.buffer);if(PQ)for(let t=0;t<e.length;t++)e[t]=IQ(e[t]);return e}return c}function IQ(e){return(e&255)<<8|e>>8&255}var LQ=new Uint16Array([255]),RQ=new Uint8Array(LQ.buffer)[0]===255,zQ=new Uint8Array;function BQ(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=Math.ceil(a/8)*i,s=Math.ceil(a/8*i*n),c=new Uint8Array(r*s),l=zQ,u=0,d,f;for(let e=0;e<r;e++){switch(d=t.subarray(u+1,u+1+s),f=c.subarray(e*s,(e+1)*s),t[u]){case 0:EQ(d,f,s);break;case 1:DQ(d,f,s,o);break;case 2:OQ(d,f,l,s);break;case 3:kQ(d,f,l,s,o);break;case 4:AQ(d,f,l,s,o);break;default:throw Error(`Unsupported filter: ${t[u]}`)}l=f,u+=s+1}if(a===16){let e=new Uint16Array(c.buffer);if(RQ)for(let t=0;t<e.length;t++)e[t]=VQ(e[t]);return e}return c}function VQ(e){return(e&255)<<8|e>>8&255}var HQ=Uint8Array.of(137,80,78,71,13,10,26,10);function UQ(e){if(!WQ(e.readBytes(HQ.length)))throw Error(`wrong PNG signature`)}function WQ(e){if(e.length<HQ.length)return!1;for(let t=0;t<HQ.length;t++)if(e[t]!==HQ[t])return!1;return!0}var GQ=`tEXt`,KQ=0,qQ=new TextDecoder(`latin1`);function JQ(e){if(XQ(e),e.length===0||e.length>79)throw Error(`keyword length must be between 1 and 79`)}var YQ=/^[\u0000-\u00FF]*$/;function XQ(e){if(!YQ.test(e))throw Error(`invalid latin1 text`)}function ZQ(e,t,n){let r=QQ(t);e[r]=$Q(t,n-r.length-1)}function QQ(e){for(e.mark();e.readByte()!==KQ;);let t=e.offset;e.reset();let n=qQ.decode(e.readBytes(t-e.offset-1));return e.skip(1),JQ(n),n}function $Q(e,t){return qQ.decode(e.readBytes(t))}var e$={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},t$={UNKNOWN:-1,DEFLATE:0},n$={UNKNOWN:-1,ADAPTIVE:0},r$={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},i$={NONE:0,BACKGROUND:1,PREVIOUS:2},a$={SOURCE:0,OVER:1},o$=class extends bQ{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;_chunks;_inflatorResult;constructor(e,t={}){super(e);let{checkCrc:n=!1}=t;this._checkCrc=n,this._inflator=new dQ((e,t)=>{if(this._chunks.push(e),t){let e=this._chunks.reduce((e,t)=>e+t.length,0);this._inflatorResult=new Uint8Array(e);let t=0;for(let e of this._chunks)this._inflatorResult.set(e,t),t+=e.length;this._chunks=[]}}),this._chunks=[],this._png={width:-1,height:-1,channels:-1,data:new Uint8Array,depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array,this._compressionMethod=t$.UNKNOWN,this._filterMethod=n$.UNKNOWN,this._interlaceMethod=r$.UNKNOWN,this._colorType=e$.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this._inflatorResult=new Uint8Array,this.setBigEndian()}decode(){for(UQ(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeChunk(e,t)}return this._inflator.push(new Uint8Array,!0),this.decodeImage(),this._png}decodeApng(){for(UQ(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeApngChunk(e,t)}return this.decodeApngImage(),this._apng}decodeChunk(e,t){let n=this.offset;switch(t){case`IHDR`:this.decodeIHDR();break;case`PLTE`:this.decodePLTE(e);break;case`IDAT`:this.decodeIDAT(e);break;case`IEND`:this._end=!0;break;case`tRNS`:this.decodetRNS(e);break;case`iCCP`:this.decodeiCCP(e);break;case GQ:ZQ(this._png.text,this,e);break;case`pHYs`:this.decodepHYs();break;default:this.skip(e)}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?TQ(this,e+4,t):this.skip(4)}decodeApngChunk(e,t){let n=this.offset;switch(t!==`fdAT`&&t!==`IDAT`&&this._writingDataChunks&&this.pushDataToFrame(),t){case`acTL`:this.decodeACTL();break;case`fcTL`:this.decodeFCTL();break;case`fdAT`:this.decodeFDAT(e);break;default:this.decodeChunk(e,t),this.offset=n+e}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?TQ(this,e+4,t):this.skip(4)}decodeIHDR(){let e=this._png;e.width=this.readUint32(),e.height=this.readUint32(),e.depth=s$(this.readUint8());let t=this.readUint8();this._colorType=t;let n;switch(t){case e$.GREYSCALE:n=1;break;case e$.TRUECOLOUR:n=3;break;case e$.INDEXED_COLOUR:n=1;break;case e$.GREYSCALE_ALPHA:n=2;break;case e$.TRUECOLOUR_ALPHA:n=4;break;case e$.UNKNOWN:default:throw Error(`Unknown color type: ${t}`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==t$.DEFLATE)throw Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){let e={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array};this._frames.push(e)}decodePLTE(e){if(e%3!=0)throw RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);let t=e/3;this._hasPalette=!0;let n=[];this._palette=n;for(let e=0;e<t;e++)n.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;try{this._inflator.push(new Uint8Array(this.buffer,n,t),!1)}catch(e){throw Error(`Error while decompressing the data:`,{cause:e})}this.skip(e)}decodeFDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;n+=4,t-=4;try{this._inflator.push(new Uint8Array(this.buffer,n,t),!1)}catch(e){throw Error(`Error while decompressing the data:`,{cause:e})}this.skip(e)}decodetRNS(e){switch(this._colorType){case e$.GREYSCALE:case e$.TRUECOLOUR:if(e%2!=0)throw RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);if(e/2>this._png.width*this._png.height)throw Error(`tRNS chunk contains more alpha values than there are pixels (${e/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(e/2);for(let t=0;t<e/2;t++)this._transparency[t]=this.readUint16();break;case e$.INDEXED_COLOUR:{if(e>this._palette.length)throw Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);let t=0;for(;t<e;t++){let e=this.readByte();this._palette[t].push(e)}for(;t<this._palette.length;t++)this._palette[t].push(255);break}case e$.UNKNOWN:case e$.GREYSCALE_ALPHA:case e$.TRUECOLOUR_ALPHA:default:throw Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(e){let t=QQ(this),n=this.readUint8();if(n!==t$.DEFLATE)throw Error(`Unsupported iCCP compression method: ${n}`);let r=this.readBytes(e-t.length-2);this._png.iccEmbeddedProfile={name:t,profile:fQ(r)}}decodepHYs(){let e=this.readUint32(),t=this.readUint32(),n=this.readByte();this._png.resolution={x:e,y:t,unit:n}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let e=0;e<this._numberOfFrames;e++){let t={sequenceNumber:this._frames[e].sequenceNumber,delayNumber:this._frames[e].delayNumber,delayDenominator:this._frames[e].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},n=this._frames.at(e);if(n){if(n.data=BQ({data:n.data,width:n.width,height:n.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),e===0||n.xOffset===0&&n.yOffset===0&&n.width===this._png.width&&n.height===this._png.height)t.data=n.data;else{let r=this._apng.frames.at(e-1);this.disposeFrame(n,r,t),this.addFrameDataToCanvas(t,n)}this._apng.frames.push(t)}}return this._apng}disposeFrame(e,t,n){switch(e.disposeOp){case i$.NONE:break;case i$.BACKGROUND:for(let t=0;t<this._png.height;t++)for(let r=0;r<this._png.width;r++){let i=(t*e.width+r)*this._png.channels;for(let e=0;e<this._png.channels;e++)n.data[i+e]=0}break;case i$.PREVIOUS:n.data.set(t.data);break;default:throw Error(`Unknown disposeOp`)}}addFrameDataToCanvas(e,t){let n=1<<this._png.depth,r=(e,n)=>({index:((e+t.yOffset)*this._png.width+t.xOffset+n)*this._png.channels,frameIndex:(e*t.width+n)*this._png.channels});switch(t.blendOp){case a$.SOURCE:for(let n=0;n<t.height;n++)for(let i=0;i<t.width;i++){let{index:a,frameIndex:o}=r(n,i);for(let n=0;n<this._png.channels;n++)e.data[a+n]=t.data[o+n]}break;case a$.OVER:for(let i=0;i<t.height;i++)for(let a=0;a<t.width;a++){let{index:o,frameIndex:s}=r(i,a);for(let r=0;r<this._png.channels;r++){let i=t.data[s+this._png.channels-1]/n,a=r%(this._png.channels-1)==0?1:t.data[s+r],c=Math.floor(i*a+(1-i)*e.data[o+r]);e.data[o+r]+=c}}break;default:throw Error(`Unknown blendOp`)}}decodeImage(){let e=this._inflatorResult;if(this._filterMethod!==n$.ADAPTIVE)throw Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===r$.NO_INTERLACE)this._png.data=BQ({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===r$.ADAM7)this._png.data=FQ({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){this._inflator.push(new Uint8Array,!0);let e=this._inflatorResult,t=this._frames.at(-1);t?t.data=e:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:i$.NONE,blendOp:a$.SOURCE,data:e}),this._inflator=new dQ((e,t)=>{if(this._chunks.push(e),t){let e=this._chunks.reduce((e,t)=>e+t.length,0);this._inflatorResult=new Uint8Array(e);let t=0;for(let e of this._chunks)this._inflatorResult.set(e,t),t+=e.length;this._chunks=[]}}),this._chunks=[],this._writingDataChunks=!1}};function s$(e){if(e!==1&&e!==2&&e!==4&&e!==8&&e!==16)throw Error(`invalid bit depth: ${e}`);return e}function c$(e){let t=e.palette,n=e.depth;if(!t)throw Error(`Color palette is undefined.`);l$(e);let r=e.width*e.height,i=r*t[0].length,a=new Uint8Array(i),o=0,s=0,c=new Uint8Array(r),l=255;switch(n){case 1:l=128;break;case 2:l=192;break;case 4:l=240;break;case 8:l=255;break;default:throw Error(`Incorrect depth value`)}for(let t of e.data){let r=l,i=8;for(;r&&(i-=n,c[o++]=(t&r)>>i,r>>=n,o%e.width!==0););}if(e.palette)for(let t of c){let n=e.palette.at(t);if(!n)throw Error(`Incorrect index of palette color`);a.set(n,s),s+=n.length}return a}function l$(e){let t=e.depth<8?Math.ceil(e.width*e.depth/8)*e.height*e.channels:e.width*e.height*e.channels;if(e.data.length!==t)throw RangeError(`wrong data size. Found ${e.data.length}, expected ${t}`)}function u$(e,t){return new o$(e,t).decode()}var d$=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_FOREGROUND=e.DEFAULT_BACKGROUND=e.PALETTE_ANSI_256=e.PALETTE_VT340_GREY=e.PALETTE_VT340_COLOR=e.normalizeHLS=e.normalizeRGB=e.nearestColorIndex=e.fromRGBA8888=e.toRGBA8888=e.alpha=e.blue=e.green=e.red=e.BIG_ENDIAN=void 0,e.BIG_ENDIAN=new Uint8Array(new Uint32Array([4278190080]).buffer)[0]===255,e.BIG_ENDIAN&&console.warn(`BE platform detected. This version of node-sixel works only on LE properly.`);function t(e){return e&255}e.red=t;function n(e){return e>>>8&255}e.green=n;function r(e){return e>>>16&255}e.blue=r;function i(e){return e>>>24&255}e.alpha=i;function a(e,t,n,r=255){return((r&255)<<24|(n&255)<<16|(t&255)<<8|e&255)>>>0}e.toRGBA8888=a;function o(e){return[e&255,e>>8&255,e>>16&255,e>>>24]}e.fromRGBA8888=o;function s(e,i){let a=t(e),o=n(e),s=r(e),c=2**53-1,l=-1;for(let e=0;e<i.length;++e){let t=a-i[e][0],n=o-i[e][1],r=s-i[e][2],u=t*t+n*n+r*r;if(!u)return e;u<c&&(c=u,l=e)}return l}e.nearestColorIndex=s;function c(e,t,n){return Math.max(e,Math.min(n,t))}function l(e,t,n){return n<0&&(n+=1),n>1&&--n,n*6<1?t+(e-t)*6*n:n*2<1?e:n*3<2?t+(e-t)*(4-n*6):t}function u(e,t,n){if(!n){let e=Math.round(t*255);return a(e,e,e)}let r=t<.5?t*(1+n):t+n-t*n,i=2*t-r;return a(c(0,255,Math.round(l(r,i,e+1/3)*255)),c(0,255,Math.round(l(r,i,e)*255)),c(0,255,Math.round(l(r,i,e-1/3)*255)))}function d(e,t,n){return(4278190080|Math.round(n/100*255)<<16|Math.round(t/100*255)<<8|Math.round(e/100*255))>>>0}e.normalizeRGB=d;function f(e,t,n){return u((e+240)/360,t/100,n/100)}e.normalizeHLS=f,e.PALETTE_VT340_COLOR=new Uint32Array([d(0,0,0),d(20,20,80),d(80,13,13),d(20,80,20),d(80,20,80),d(20,80,80),d(80,80,20),d(53,53,53),d(26,26,26),d(33,33,60),d(60,26,26),d(33,60,33),d(60,33,60),d(33,60,60),d(60,60,33),d(80,80,80)]),e.PALETTE_VT340_GREY=new Uint32Array([d(0,0,0),d(13,13,13),d(26,26,26),d(40,40,40),d(6,6,6),d(20,20,20),d(33,33,33),d(46,46,46),d(0,0,0),d(13,13,13),d(26,26,26),d(40,40,40),d(6,6,6),d(20,20,20),d(33,33,33),d(46,46,46)]),e.PALETTE_ANSI_256=(()=>{let e=[a(0,0,0),a(205,0,0),a(0,205,0),a(205,205,0),a(0,0,238),a(205,0,205),a(0,250,205),a(229,229,229),a(127,127,127),a(255,0,0),a(0,255,0),a(255,255,0),a(92,92,255),a(255,0,255),a(0,255,255),a(255,255,255)],t=[0,95,135,175,215,255];for(let n=0;n<6;++n)for(let r=0;r<6;++r)for(let i=0;i<6;++i)e.push(a(t[n],t[r],t[i]));for(let t=8;t<=238;t+=10)e.push(a(t,t,t));return new Uint32Array(e)})(),e.DEFAULT_BACKGROUND=a(0,0,0,255),e.DEFAULT_FOREGROUND=a(255,255,255,255)})),f$=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LIMITS=void 0,e.LIMITS={CHUNK_SIZE:16384,PALETTE_SIZE:4096,MAX_WIDTH:16384,BYTES:`AGFzbQEAAAABJAdgAAF/YAJ/fwBgA39/fwF/YAF/AX9gAABgBH9/f38AYAF/AAIlAgNlbnYLaGFuZGxlX2JhbmQAAwNlbnYLbW9kZV9wYXJzZWQAAwMTEgQAAAAAAQQBAQUBAAACAgAGAwQFAXABBwcFBAEBBwcGCAF/AUGAihoLB9wBDgZtZW1vcnkCABFnZXRfc3RhdGVfYWRkcmVzcwADEWdldF9jaHVua19hZGRyZXNzAAQOZ2V0X3AwX2FkZHJlc3MABRNnZXRfcGFsZXR0ZV9hZGRyZXNzAAYEaW5pdAALBmRlY29kZQAMDWN1cnJlbnRfd2lkdGgADQ5jdXJyZW50X2hlaWdodAAOGV9faW5kaXJlY3RfZnVuY3Rpb25fdGFibGUBAAtfaW5pdGlhbGl6ZQACCXN0YWNrU2F2ZQARDHN0YWNrUmVzdG9yZQASCnN0YWNrQWxsb2MAEwkMAQBBAQsGCgcJDxACDAEBCq5UEgMAAQsFAEGgCAsGAEGQiQELBgBBsIkCCwUAQZAJC+okAQh/QeQIKAIAIQVB4AgoAgAhA0HoCCgCACEIIAFBkIkBaiIJQf8BOgAAIAAgAUgEQCAAQZCJAWohBgNAIAMhBCAGQQFqIQECQCAGLQAAQf8AcSIDQTBrQQlLBEAgASEGDAELQewIKAIAQQJ0QewIaiICKAIAIQADQCACIAMgAEEKbGpBMGsiADYCACABLQAAIQMgAUEBaiIGIQEgA0H/AHEiA0Ewa0EKSQ0ACwsCQAJAAkACQAJAAkACQAJ/AkACQCADQT9rIgBBP00EQCAERQ0BIARBIUYEQAJAQfAIKAIAIgFBASABGyIHIAhqIgFB1AgoAgAiA0gNACADQf//AEoNAANAIANBAnQiAkGgiQJqIgRBoAgpAwA3AwAgAkGoiQJqQaAIKQMANwMAIAJBsIkCakGgCCkDADcDACACQbiJAmpBoAgpAwA3AwAgAkHAiQJqQaAIKQMANwMAIAJByIkCakGgCCkDADcDACACQdCJAmpBoAgpAwA3AwAgAkHYiQJqQaAIKQMANwMAIAJB4IkCakGgCCkDADcDACACQeiJAmpBoAgpAwA3AwAgAkHwiQJqQaAIKQMANwMAIAJB+IkCakGgCCkDADcDACACQYCKAmpBoAgpAwA3AwAgAkGIigJqQaAIKQMANwMAIAJBkIoCakGgCCkDADcDACACQZiKAmpBoAgpAwA3AwAgAkGgigJqQaAIKQMANwMAIAJBqIoCakGgCCkDADcDACACQbCKAmpBoAgpAwA3AwAgAkG4igJqQaAIKQMANwMAIAJBwIoCakGgCCkDADcDACACQciKAmpBoAgpAwA3AwAgAkHQigJqQaAIKQMANwMAIAJB2IoCakGgCCkDADcDACACQeCKAmpBoAgpAwA3AwAgAkHoigJqQaAIKQMANwMAIAJB8IoCakGgCCkDADcDACACQfiKAmpBoAgpAwA3AwAgAkGAiwJqQaAIKQMANwMAIAJBiIsCakGgCCkDADcDACACQZCLAmpBoAgpAwA3AwAgAkGYiwJqQaAIKQMANwMAIAJBoIsCakGgCCkDADcDACACQaiLAmpBoAgpAwA3AwAgAkGwiwJqQaAIKQMANwMAIAJBuIsCakGgCCkDADcDACACQcCLAmpBoAgpAwA3AwAgAkHIiwJqQaAIKQMANwMAIAJB0IsCakGgCCkDADcDACACQdiLAmpBoAgpAwA3AwAgAkHgiwJqQaAIKQMANwMAIAJB6IsCakGgCCkDADcDACACQfCLAmpBoAgpAwA3AwAgAkH4iwJqQaAIKQMANwMAIAJBgIwCakGgCCkDADcDACACQYiMAmpBoAgpAwA3AwAgAkGQjAJqQaAIKQMANwMAIAJBmIwCakGgCCkDADcDACACQaCMAmpBoAgpAwA3AwAgAkGojAJqQaAIKQMANwMAIAJBsIwCakGgCCkDADcDACACQbiMAmpBoAgpAwA3AwAgAkHAjAJqQaAIKQMANwMAIAJByIwCakGgCCkDADcDACACQdCMAmpBoAgpAwA3AwAgAkHYjAJqQaAIKQMANwMAIAJB4IwCakGgCCkDADcDACACQeiMAmpBoAgpAwA3AwAgAkHwjAJqQaAIKQMANwMAIAJB+IwCakGgCCkDADcDACACQYCNAmpBoAgpAwA3AwAgAkGIjQJqQaAIKQMANwMAIAJBkI0CakGgCCkDADcDACACQZiNAmpBoAgpAwA3AwAgAkGwiQZqIARBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBEGABPwKAABB1AgoAgBBAnRB0IkOaiAEQYAE/AoAAEHUCCgCAEECdEHgiRJqIARBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBEGABPwKAABB1AhB1AgoAgAiAkGAAWoiAzYCACABIANIDQEgAkGA/wBIDQALCwJAIABFDQAgCEH//wBLDQBBgIABIAhrIAcgAUH//wBLGyECAkAgAEEBcUUNACACRQ0AIAhBAnRBoIkCaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBAnFFDQAgAkUNACAIQQJ0QbCJBmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsCQCAAQQRxRQ0AIAJFDQAgCEECdEHAiQpqIQMgAiEEIAJBB3EiBwRAA0AgAyAFNgIAIANBBGohAyAEQQFrIQQgB0EBayIHDQALCyACQQFrQQdJDQADQCADIAU2AhwgAyAFNgIYIAMgBTYCFCADIAU2AhAgAyAFNgIMIAMgBTYCCCADIAU2AgQgAyAFNgIAIANBIGohAyAEQQhrIgQNAAsLAkAgAEEIcUUNACACRQ0AIAhBAnRB0IkOaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBEHFFDQAgAkUNACAIQQJ0QeCJEmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsgAEEgcUUNACACRQ0AIAJBAWshByAIQQJ0QfCJFmohAyACQQdxIgQEQANAIAMgBTYCACADQQRqIQMgAkEBayECIARBAWsiBA0ACwsgB0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgAkEIayICDQALC0HcCEHcCCgCACAAcjYCACAGQQFqIgIgBi0AAEH/AHEiA0E/ayIAQT9LDQQaDAMLAkBB7AgoAgAiBEEBRgRAQfAIKAIAIgNBzAgoAgAiAUkNASADIAFwIQMMAQtB+AgoAgAhAkH0CCgCACEBAkACQCAEQQVHDQAgAUEBRw0AIAJB6QJODQQMAQsgAkHkAEoNA0H8CCgCAEHkAEoNA0GACSgCAEHkAEoNAwsCQCABRQ0AIAFBAkoNACACQfwIKAIAQYAJKAIAIAFBAnRBiAhqKAIAEQIAIQFB8AgoAgAiA0HMCCgCACICTwR/IAMgAnAFIAMLQQJ0QZAJaiABNgIAC0HwCCgCACIDQcwIKAIAIgFJDQAgAyABcCEDCyADQQJ0QZAJaigCACEFDAELIANB/QBxQSFHBEAgCCEBIAYhAgwECyAEQSNHDQQCQEHsCCgCACICQQFGBEBB8AgoAgAiAUHMCCgCACIASQ0BIAEgAHAhAQwBC0H4CCgCACEBQfQIKAIAIQACQAJAIAJBBUcNACAAQQFHDQAgAUHpAkgNAQwHCyABQeQASg0GQfwIKAIAQeQASg0GQYAJKAIAQeQASg0GCwJAIABFDQAgAEECSg0AIAFB/AgoAgBBgAkoAgAgAEECdEGICGooAgARAgAhAEHwCCgCACIBQcwIKAIAIgJPBH8gASACcAUgAQtBAnRBkAlqIAA2AgALQfAIKAIAIgFBzAgoAgAiAEkNACABIABwIQELIAFBAnRBkAlqKAIAIQUMBAsgCCEBIAYhAgtB1AgoAgAhBgNAAkAgASAGSA0AIAZB//8ASg0AIAZBAnQiBEGgiQJqIgZBoAgpAwA3AwAgBEGoiQJqQaAIKQMANwMAIARBsIkCakGgCCkDADcDACAEQbiJAmpBoAgpAwA3AwAgBEHAiQJqQaAIKQMANwMAIARByIkCakGgCCkDADcDACAEQdCJAmpBoAgpAwA3AwAgBEHYiQJqQaAIKQMANwMAIARB4IkCakGgCCkDADcDACAEQeiJAmpBoAgpAwA3AwAgBEHwiQJqQaAIKQMANwMAIARB+IkCakGgCCkDADcDACAEQYCKAmpBoAgpAwA3AwAgBEGIigJqQaAIKQMANwMAIARBkIoCakGgCCkDADcDACAEQZiKAmpBoAgpAwA3AwAgBEGgigJqQaAIKQMANwMAIARBqIoCakGgCCkDADcDACAEQbCKAmpBoAgpAwA3AwAgBEG4igJqQaAIKQMANwMAIARBwIoCakGgCCkDADcDACAEQciKAmpBoAgpAwA3AwAgBEHQigJqQaAIKQMANwMAIARB2IoCakGgCCkDADcDACAEQeCKAmpBoAgpAwA3AwAgBEHoigJqQaAIKQMANwMAIARB8IoCakGgCCkDADcDACAEQfiKAmpBoAgpAwA3AwAgBEGAiwJqQaAIKQMANwMAIARBiIsCakGgCCkDADcDACAEQZCLAmpBoAgpAwA3AwAgBEGYiwJqQaAIKQMANwMAIARBoIsCakGgCCkDADcDACAEQaiLAmpBoAgpAwA3AwAgBEGwiwJqQaAIKQMANwMAIARBuIsCakGgCCkDADcDACAEQcCLAmpBoAgpAwA3AwAgBEHIiwJqQaAIKQMANwMAIARB0IsCakGgCCkDADcDACAEQdiLAmpBoAgpAwA3AwAgBEHgiwJqQaAIKQMANwMAIARB6IsCakGgCCkDADcDACAEQfCLAmpBoAgpAwA3AwAgBEH4iwJqQaAIKQMANwMAIARBgIwCakGgCCkDADcDACAEQYiMAmpBoAgpAwA3AwAgBEGQjAJqQaAIKQMANwMAIARBmIwCakGgCCkDADcDACAEQaCMAmpBoAgpAwA3AwAgBEGojAJqQaAIKQMANwMAIARBsIwCakGgCCkDADcDACAEQbiMAmpBoAgpAwA3AwAgBEHAjAJqQaAIKQMANwMAIARByIwCakGgCCkDADcDACAEQdCMAmpBoAgpAwA3AwAgBEHYjAJqQaAIKQMANwMAIARB4IwCakGgCCkDADcDACAEQeiMAmpBoAgpAwA3AwAgBEHwjAJqQaAIKQMANwMAIARB+IwCakGgCCkDADcDACAEQYCNAmpBoAgpAwA3AwAgBEGIjQJqQaAIKQMANwMAIARBkI0CakGgCCkDADcDACAEQZiNAmpBoAgpAwA3AwAgBEGwiQZqIAZBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBkGABPwKAABB1AgoAgBBAnRB0IkOaiAGQYAE/AoAAEHUCCgCAEECdEHgiRJqIAZBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBkGABPwKAABB1AhB1AgoAgBBgAFqIgY2AgALIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiAFNgIAIABBAXZBAXEgAWxBAnRBsIkGaiAFNgIAIABBAnZBAXEgAWxBAnRBwIkKaiAFNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiAFNgIAIABBBHZBAXEgAWxBAnRB4IkSaiAFNgIAIABBBXYgAWxBAnRB8IkWaiAFNgIAQdQIKAIAIQYLIAFBAWohAUHcCEHcCCgCACAAcjYCACACLQAAIQAgAkEBaiIEIQIgAEH/AHEiA0E/ayIAQcAASQ0ACyAECyECQQAhBCACIQYgASEIIANB/QBxQSFGDQELIANBJGsOCgEDAwMDAwMDAwIDC0HsCEIBNwIADAQLQdgIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbNgIADAILQegIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbIgA2AgBB2AggADYCACAAQQRrEAAEQEHoCEEENgIAQdgIQQQ2AgBB0AhBATYCAA8LEAgMAQsCQCADQTtHDQBB7AgoAgAiAEEHSg0AQewIIABBAWo2AgAgAEECdEHwCGpBADYCAAsgAiEGIAQhAyABIQgMAQtBBCEIIAIhBiAEIQMLIAYgCUkNAAsLQeQIIAU2AgBB4AggAzYCAEHoCCAINgIAC9ELAgF+CH9B2AhCBDcDAEGojQJBoAgpAwAiADcDAEGgjQIgADcDAEGYjQIgADcDAEGQjQIgADcDAEGIjQIgADcDAEGAjQIgADcDAEH4jAIgADcDAEHwjAIgADcDAEHojAIgADcDAEHgjAIgADcDAEHYjAIgADcDAEHQjAIgADcDAEHIjAIgADcDAEHAjAIgADcDAEG4jAIgADcDAEGwjAIgADcDAEGojAIgADcDAEGgjAIgADcDAEGYjAIgADcDAEGQjAIgADcDAEGIjAIgADcDAEGAjAIgADcDAEH4iwIgADcDAEHwiwIgADcDAEHoiwIgADcDAEHgiwIgADcDAEHYiwIgADcDAEHQiwIgADcDAEHIiwIgADcDAEHAiwIgADcDAEG4iwIgADcDAEGwiwIgADcDAEGoiwIgADcDAEGgiwIgADcDAEGYiwIgADcDAEGQiwIgADcDAEGIiwIgADcDAEGAiwIgADcDAEH4igIgADcDAEHwigIgADcDAEHoigIgADcDAEHgigIgADcDAEHYigIgADcDAEHQigIgADcDAEHIigIgADcDAEHAigIgADcDAEG4igIgADcDAEGwigIgADcDAEGoigIgADcDAEGgigIgADcDAEGYigIgADcDAEGQigIgADcDAEGIigIgADcDAEGAigIgADcDAEH4iQIgADcDAEHwiQIgADcDAEHoiQIgADcDAEHgiQIgADcDAEHYiQIgADcDAEHQiQIgADcDAEHIiQIgADcDAEHAiQIgADcDAEG4iQIgADcDAEGwiQIgADcDAEGoCCgCACIEQf8AakGAAW0hCAJAIARBgQFIDQBBASEBIAhBAiAIQQJKG0EBayICQQFxIQMgBEGBAk4EQCACQX5xIQIDQCABQQl0IgdBEHJBoIkCakGwiQJBgAT8CgAAIAdBsI0CakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsLIANFDQAgAUEJdEEQckGgiQJqQbCJAkGABPwKAAALAkAgBEEBSA0AIAhBASAIQQFKGyIDQQFxIQUCQCADQQFrIgdFBEBBACEBDAELIANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQbCJBmpBsIkCQYAE/AoAACAGQZAEckGwiQZqQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACwsgBQRAIAFBCXRBEHJBsIkGakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEFIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiBkEQckHAiQpqQbCJAkGABPwKAAAgBkGQBHJBwIkKakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAFBEAgAUECdEHAiQpqQbCJAkGABPwKAAALIARBAUgNACADQQFxIQUgBwR/IANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQdCJDmpBsIkCQYAE/AoAACAGQZAEckHQiQ5qQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACyABQQd0QQRyBUEECyEBIAUEQCABQQJ0QdCJDmpBsIkCQYAE/AoAAAsgBEEBSA0AIANBAXEhBSAHBH8gA0H+////B3EhAkEAIQEDQCABQQl0IgZBEHJB4IkSakGwiQJBgAT8CgAAIAZBkARyQeCJEmpBsIkCQYAE/AoAACABQQJqIQEgAkECayICDQALIAFBB3RBBHIFQQQLIQEgBQRAIAFBAnRB4IkSakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEEIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiA0EQckHwiRZqQbCJAkGABPwKAAAgA0GQBHJB8IkWakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAERQ0AIAFBAnRB8IkWakGwiQJBgAT8CgAAC0HUCCAIQQd0QQRyNgIAC58TAgh/AX5B5AgoAgAhA0HgCCgCACECQegIKAIAIQcgAUGQiQFqIglB/wE6AAAgACABSARAIABBkIkBaiEIA0AgAiEEIAhBAWohAQJAIAgtAABB/wBxIgJBMGtBCUsEQCABIQgMAQtB7AgoAgBBAnRB7AhqIgUoAgAhAANAIAUgAiAAQQpsakEwayIANgIAIAEtAAAhAiABQQFqIgghASACQf8AcSICQTBrQQpJDQALCwJAAkACQAJAAkACQAJ/AkAgAkE/ayIAQT9NBEAgBEUNASAEQSFGBEBB8AgoAgAiAUEBIAEbIgQgB2ohAQJAIABFDQAgB0H//wBLDQBBgIABIAdrIAQgAUH//wBLGyEFAkAgAEEBcUUNACAHQQJ0QaCJAmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEECcUUNACAHQQJ0QbCJBmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEEcUUNACAHQQJ0QcCJCmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEIcUUNACAHQQJ0QdCJDmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEQcUUNACAHQQJ0QeCJEmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLIABBIHFFDQAgBUEBayEEIAdBAnRB8IkWaiEAIAVBB3EiAgRAA0AgACADNgIAIABBBGohACAFQQFrIQUgAkEBayICDQALCyAEQQdJDQADQCAAIAM2AhwgACADNgIYIAAgAzYCFCAAIAM2AhAgACADNgIMIAAgAzYCCCAAIAM2AgQgACADNgIAIABBIGohACAFQQhrIgUNAAsLIAhBAWoiBSAILQAAQf8AcSICQT9rIgBBP00NAxoMBAsCQEHsCCgCACIFQQFGBEBB8AgoAgAiAUHMCCgCACIESQ0BIAEgBHAhAQwBC0H4CCgCACEEQfQIKAIAIQECQAJAIAVBBUcNACABQQFHDQAgBEHpAk4NBAwBCyAEQeQASg0DQfwIKAIAQeQASg0DQYAJKAIAQeQASg0DCwJAIAFFDQAgAUECSg0AIARB/AgoAgBBgAkoAgAgAUECdEGICGooAgARAgAhBEHwCCgCACIBQcwIKAIAIgVPBH8gASAFcAUgAQtBAnRBkAlqIAQ2AgALQfAIKAIAIgFBzAgoAgAiBEkNACABIARwIQELIAFBAnRBkAlqKAIAIQMMAQsgAkH9AHFBIUcEQCAHIQEgAiEADAQLIARBI0cNBAJAQewIKAIAIgRBAUYEQEHwCCgCACIBQcwIKAIAIgBJDQEgASAAcCEBDAELQfgIKAIAIQFB9AgoAgAhAAJAAkAgBEEFRw0AIABBAUcNACABQekCSA0BDAcLIAFB5ABKDQZB/AgoAgBB5ABKDQZBgAkoAgBB5ABKDQYLAkAgAEUNACAAQQJKDQAgAUH8CCgCAEGACSgCACAAQQJ0QYgIaigCABECACEAQfAIKAIAIgFBzAgoAgAiBE8EfyABIARwBSABC0ECdEGQCWogADYCAAtB8AgoAgAiAUHMCCgCACIASQ0AIAEgAHAhAQsgAUECdEGQCWooAgAhAwwECyAHIQEgCAshBQNAIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiADNgIAIABBAXZBAXEgAWxBAnRBsIkGaiADNgIAIABBAnZBAXEgAWxBAnRBwIkKaiADNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiADNgIAIABBBHZBAXEgAWxBAnRB4IkSaiADNgIAIABBBXYgAWxBAnRB8IkWaiADNgIACyABQQFqIQEgBS0AACEAIAVBAWoiBCEFIABB/wBxIgJBP2siAEHAAEkNAAsgBCEFC0EAIQQgBSEIIAEhByACIQAgAkH9AHFBIUYNAQtBBCEHIAQhAiAAQSRrDgoDAgICAgICAgIBAgtB7AhCATcCAAwCC0GoCCgCAEEEaxAABEBB0AhBATYCAA8LAkBBqAgoAgAiBkEFSA0AQaAIKQMAIQogBkEDa0EBdiIBQQdxIQJBACEAIAFBAWtBB08EQCABQfj///8HcSEFA0AgAEEDdCIBQbCJAmogCjcDACABQQhyQbCJAmogCjcDACABQRByQbCJAmogCjcDACABQRhyQbCJAmogCjcDACABQSByQbCJAmogCjcDACABQShyQbCJAmogCjcDACABQTByQbCJAmogCjcDACABQThyQbCJAmogCjcDACAAQQhqIQAgBUEIayIFDQALCyACRQ0AA0AgAEEDdEGwiQJqIAo3AwAgAEEBaiEAIAJBAWsiAg0ACwtBwIkGQbCJAiAGQQJ0IgD8CgAAQdCJCkGwiQIgAPwKAABB4IkOQbCJAiAA/AoAAEHwiRJBsIkCIAD8CgAAQYCKFkGwiQIgAPwKAAAgBCECDAELAkAgAEE7Rw0AQewIKAIAIgBBB0oNAEHsCCAAQQFqNgIAIABBAnRB8AhqQQA2AgALIAEhBwsgCCAJSQ0ACwtB5AggAzYCAEHgCCACNgIAQegIIAc2AgAL4gcCBX8BfgJAQdAIAn8CQAJAIAAgAU4NACABQZCJAWohBiAAQZCJAWohBQNAIAUtAAAiA0H/AHEhAgJAAkACQAJAAkACQAJAQeAIKAIAIgRBIkcEQCAEDQcgAkEiRgRAQewIQgE3AgBB4AhBIjYCAAwICyACQT9rQcAASQ0GIANBIWsiAkEMTQ0BDAULAkAgAkEwayIEQQlNBEBB7AgoAgBBAnRB7AhqIgIgBCACKAIAQQpsajYCAAwBC0HsCCgCACEEIAJBO0YEQCAEQQdKDQFB7AggBEEBajYCACAEQQJ0QfAIakEANgIADAELIARBBEYEQEHECEECNgIAQbAIQfAIKQMANwMAQbgIQfgIKAIAIgI2AgBBvAhB/AgoAgAiBDYCAEHICEECQQFBwAgoAgAiAxs2AgBBrAggBEEAIAMbNgIAQagIIAJBgIABIAJBgIABSBtBBGpBACADGzYCAEHgCEEANgIADAoLIAJBP2tBwABJDQQLIANBIWsiAkEMTQ0BDAILQQEgAnRBjSBxRQ0DDAQLQQEgAnRBjSBxDQELIANBoQFrIgJBDEsNA0EBIAJ0QY0gcUUNAwtBxAhCgYCAgBA3AgBBsAhB8AgoAgBBAEHsCCgCACICQQBKGzYCAEG0CEH0CCgCAEEAIAJBAUobNgIAQbgIQfgIKAIAQQAgAkECShs2AgBB4AhBADYCAEG8CEEANgIADAQLIANBoQFrIgJBDEsNAUEBIAJ0QY0gcUUNAQtBxAhCgYCAgBA3AgBBsAhCADcDAEG4CEIANwMADAMLIAVBAWoiBSAGSQ0ACwsCQEHICCgCAA4DAwEAAQsCQEGoCCgCACIFQQVIDQBBoAgpAwAhByAFQQNrQQF2IgNBB3EhBEEAIQIgA0EBa0EHTwRAIANB+P///wdxIQYDQCACQQN0IgNBsIkCaiAHNwMAIANBCHJBsIkCaiAHNwMAIANBEHJBsIkCaiAHNwMAIANBGHJBsIkCaiAHNwMAIANBIHJBsIkCaiAHNwMAIANBKHJBsIkCaiAHNwMAIANBMHJBsIkCaiAHNwMAIANBOHJBsIkCaiAHNwMAIAJBCGohAiAGQQhrIgYNAAsLIARFDQADQCACQQN0QbCJAmogBzcDACACQQFqIQIgBEEBayIEDQALC0HAiQZBsIkCIAVBAnQiA/wKAABB0IkKQbCJAiAD/AoAAEHgiQ5BsIkCIAP8CgAAQfCJEkGwiQIgA/wKAABBgIoWQbCJAiAD/AoAAEECDAELEAhByAgoAgALEAEiAjYCACACDQAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLdABB6AhBBDYCAEHkCCAANgIAQewIQgE3AgBBxAhCADcCAEHACCADNgIAQdwIQgA3AgBBqAhCADcDAEGwCEIANwMAQbgIQgA3AwBBzAggAkGAICACQYAgSRs2AgBBoAggAa1CgYCAgBB+NwMAQdAIQQA2AgALIwBB0AgoAgBFBEAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLWgECfwJAAkACQEHICCgCAEEBaw4CAAECC0HYCEHoCCgCACIAQdgIKAIAIgEgACABShsiAEGAgAEgAEGAgAFIGyIANgIAIABBBGsPC0GoCCgCAEEEayEACyAAC0IBAX8Cf0EGQdwIKAIAIgBBIHENABpBBSAAQRBxDQAaQQQgAEEIcQ0AGkEDIABBBHENABpBAiAAQQFxIABBAnEbCwu9BQEFfQJ/IAJFBEAgAUH/AWxBMmpB5ABtIgBBCHQgAHIgAEEQdHIMAQsgArJDAADIQpUhBiAAQfABarJDAAC0Q5UhBQJ9IAGyQwAAyEKVIgNDAAAAP10EQCADIAZDAACAP5KUDAELIAYgA0MAAIA/IAaTlJILIQcgAyADkiEGAkAgBUOrqqo+kiIEQwAAAABdBEAgBEMAAIA/kiEEDAELIARDAACAP15FDQAgBEMAAIC/kiEECyAGIAeTIQMgBUMAAAAAXSEAAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQECQCAABEAgBUMAAIA/kiEEDAELIAUiBEMAAIA/XkUNACAFQwAAgL+SIQQLIAVDq6qqvpIiBUMAAAAAXSECAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQACQCACBEAgBUMAAIA/kiEFDAELIAVDAACAP15FDQAgBUMAAIC/kiEFCwJAIAVDq6oqPl0EQCADIAcgA5NDAADAQJQgBZSSIQcMAQsgBUMAAAA/XQ0AIAVDq6oqP11FBEAgAyEHDAELIAMgByADkyAFQwAAwMCUQwAAgECSlJIhBwsgAEEIdAJ/IAdDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALQRB0ciABcgtBgICAeHILNwAgAEH/AWxBMmpB5ABtIAFB/wFsQTJqQeQAbUEIdHIgAkH/AWxBMmpB5ABtQRB0ckGAgIB4cgsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwsYAQBBgAgLEQEAAAACAAAAAwAAAAQAAAAF`}})),p$=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.decodeAsync=e.decode=e.Decoder=e.DecoderAsync=void 0;var t=d$(),n=f$();function r(e){if(typeof Buffer<`u`)return Buffer.from(e,`base64`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<n.length;++e)n[e]=t.charCodeAt(e);return n}var i=r(n.LIMITS.BYTES),a,o=new Uint32Array,s=class{constructor(){this.bandHandler=e=>1,this.modeHandler=e=>1}handle_band(e){return this.bandHandler(e)}mode_parsed(e){return this.modeHandler(e)}},c={memoryLimit:134217728,sixelColor:t.DEFAULT_FOREGROUND,fillColor:t.DEFAULT_BACKGROUND,palette:t.PALETTE_VT340_COLOR,paletteLimit:n.LIMITS.PALETTE_SIZE,truncate:!0};function l(e){let t=new s,n={env:{handle_band:t.handle_band.bind(t),mode_parsed:t.mode_parsed.bind(t)}};return WebAssembly.instantiate(a||i,n).then(n=>(a||=n.module,new u(e,n.instance||n,t)))}e.DecoderAsync=l;var u=class{constructor(e,r,s){if(this._PIXEL_OFFSET=n.LIMITS.MAX_WIDTH+4,this._canvas=o,this._bandWidths=[],this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0,this._opts=Object.assign({},c,e),this._opts.paletteLimit>n.LIMITS.PALETTE_SIZE)throw Error(`DecoderOptions.paletteLimit must not exceed ${n.LIMITS.PALETTE_SIZE}`);if(r)s.bandHandler=this._handle_band.bind(this),s.modeHandler=this._initCanvas.bind(this);else{let e=a||=new WebAssembly.Module(i);r=new WebAssembly.Instance(e,{env:{handle_band:this._handle_band.bind(this),mode_parsed:this._initCanvas.bind(this)}})}this._instance=r,this._wasm=this._instance.exports,this._chunk=new Uint8Array(this._wasm.memory.buffer,this._wasm.get_chunk_address(),n.LIMITS.CHUNK_SIZE),this._states=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_state_address(),12),this._palette=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_palette_address(),n.LIMITS.PALETTE_SIZE),this._palette.set(this._opts.palette),this._pSrc=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_p0_address()),this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}get _fillColor(){return this._states[0]}get _truncate(){return this._states[8]}get _rasterWidth(){return this._states[6]}get _rasterHeight(){return this._states[7]}get _width(){return this._states[2]?this._states[2]-4:0}get _height(){return this._states[3]}get _level(){return this._states[9]}get _mode(){return this._states[10]}get _paletteLimit(){return this._states[11]}_initCanvas(e){if(e===2){let e=this.width*this.height;if(e>this._canvas.length){if(this._opts.memoryLimit&&e*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);this._canvas=new Uint32Array(e)}this._maxWidth=this._width}else if(e===1){if(this._level===2){let e=Math.min(this._rasterWidth,n.LIMITS.MAX_WIDTH)*this._rasterHeight;if(e>this._canvas.length){if(this._opts.memoryLimit&&e*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);this._canvas=new Uint32Array(e)}}else this._canvas.length<65536&&(this._canvas=new Uint32Array(65536))}return 0}_realloc(e,t){let n=e+t;if(n>this._canvas.length){if(this._opts.memoryLimit&&n*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);let e=new Uint32Array(Math.ceil(n/65536)*65536);e.set(this._canvas),this._canvas=e}}_handle_band(e){let t=this._PIXEL_OFFSET,n=this._lastOffset;if(this._mode===2){let r=this.height-this._currentHeight,i=0;for(;i<6&&r>0;)this._canvas.set(this._pSrc.subarray(t*i,t*i+e),n+e*i),i++,r--;this._lastOffset+=e*i,this._currentHeight+=i}else if(this._mode===1){this._realloc(n,e*6),this._maxWidth=Math.max(this._maxWidth,e),this._minWidth=Math.min(this._minWidth,e);for(let r=0;r<6;++r)this._canvas.set(this._pSrc.subarray(t*r,t*r+e),n+e*r);this._bandWidths.push(e),this._lastOffset+=e*6,this._currentHeight+=6}return 0}get width(){return this._mode===1?Math.max(this._maxWidth,this._wasm.current_width()):this._width}get height(){return this._mode===1?this._wasm.current_width()?this._bandWidths.length*6+this._wasm.current_height():this._bandWidths.length*6:this._height}get palette(){return this._palette.subarray(0,this._paletteLimit)}get memoryUsage(){return this._canvas.byteLength+this._wasm.memory.buffer.byteLength+8*this._bandWidths.length}get properties(){return{width:this.width,height:this.height,mode:this._mode,level:this._level,truncate:!!this._truncate,paletteLimit:this._paletteLimit,fillColor:this._fillColor,memUsage:this.memoryUsage,rasterAttributes:{numerator:this._states[4],denominator:this._states[5],width:this._rasterWidth,height:this._rasterHeight}}}init(e=this._opts.fillColor,t=this._opts.palette,r=this._opts.paletteLimit,i=this._opts.truncate){this._wasm.init(this._opts.sixelColor,e,r,+!!i),t&&this._palette.set(t.subarray(0,n.LIMITS.PALETTE_SIZE)),this._bandWidths.length=0,this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0}decode(e,t=0,r=e.length){let i=t;for(;i<r;){let t=Math.min(r-i,n.LIMITS.CHUNK_SIZE);this._chunk.set(e.subarray(i,i+=t)),this._wasm.decode(0,t)}}decodeString(e,t=0,r=e.length){let i=t;for(;i<r;){let t=Math.min(r-i,n.LIMITS.CHUNK_SIZE);for(let n=0,r=i;n<t;++n,++r)this._chunk[n]=e.charCodeAt(r);i+=t,this._wasm.decode(0,t)}}get data32(){if(this._mode===0||!this.width||!this.height)return o;let e=this._wasm.current_width();if(this._mode===2){let t=this.height-this._currentHeight;if(t>0){let n=this._PIXEL_OFFSET,r=this._lastOffset,i=0;for(;i<6&&t>0;)this._canvas.set(this._pSrc.subarray(n*i,n*i+e),r+e*i),i++,t--;t&&this._canvas.fill(this._fillColor,r+e*i)}return this._canvas.subarray(0,this.width*this.height)}if(this._mode===1){if(this._minWidth===this._maxWidth){let t=!1;if(e){if(e!==this._minWidth)t=!0;else{let t=this._PIXEL_OFFSET,n=this._lastOffset;this._realloc(n,e*6);for(let r=0;r<6;++r)this._canvas.set(this._pSrc.subarray(t*r,t*r+e),n+e*r)}}if(!t)return this._canvas.subarray(0,this.width*this.height)}let t=new Uint32Array(this.width*this.height);t.fill(this._fillColor);let n=0,r=0;for(let e=0;e<this._bandWidths.length;++e){let i=this._bandWidths[e];for(let e=0;e<6;++e)t.set(this._canvas.subarray(r,r+=i),n),n+=this.width}if(e){let r=this._PIXEL_OFFSET,i=this._wasm.current_height();for(let a=0;a<i;++a)t.set(this._pSrc.subarray(r*a,r*a+e),n+this.width*a)}return t}return o}get data8(){return new Uint8ClampedArray(this.data32.buffer,0,this.width*this.height*4)}release(){this._canvas=o,this._bandWidths.length=0,this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}};e.Decoder=u;function d(e,t){let n=new u(t);return n.init(),typeof e==`string`?n.decodeString(e):n.decode(e),{width:n.width,height:n.height,data32:n.data32,data8:n.data8}}e.decode=d;async function f(e,t){let n=await l(t);return n.init(),typeof e==`string`?n.decodeString(e):n.decode(e),{width:n.width,height:n.height,data32:n.data32,data8:n.data8}}e.decodeAsync=f})),m$=d$(),h$=p$(),g$=m$.PALETTE_ANSI_256.slice();g$.set(m$.PALETTE_VT340_COLOR);var _$=200,v$=new TextEncoder,y$=`offsite-image:`;async function b$(e){let t=await(0,h$.decodeAsync)(e,{fillColor:0,palette:g$});return!t.width||!t.height?null:createImageBitmap(new ImageData(new Uint8ClampedArray(t.data8),t.width,t.height))}function x$(e,t,n){return e===void 0||e===`auto`?0:e.endsWith(`%`)?parseInt(e.slice(0,-1))*t/100:e.endsWith(`px`)?parseInt(e.slice(0,-2)):parseInt(e)*n}async function S$(e,t){let n=e.indexOf(`:`);if(n===-1)return null;let r=new Map(e.slice(0,n).split(`;`).map(e=>{let t=e.indexOf(`=`);return[e.slice(0,t),e.slice(t+1)]}));if(r.get(`inline`)!==`1`)return null;let i=Uint8Array.from(atob(e.slice(n+1)),e=>e.charCodeAt(0)),a=await createImageBitmap(new Blob([i])),o=x$(r.get(`width`),t.width,t.cellWidth),s=x$(r.get(`height`),t.height,t.cellHeight),c=[a.width,a.height];if(!o&&!s){let e=Math.min(t.width/a.width,(t.height-t.cellHeight)/a.height);e<1&&(c=[a.width*e,a.height*e])}else c=o?r.get(`preserveAspectRatio`)!==`0`||!s?[o,a.height*o/a.width]:[o,s]:[a.width*s/a.height,s];let[l,u]=c.map(e=>Math.max(1,Math.floor(e*t.pixelRatio))),d=await createImageBitmap(a,{resizeWidth:l,resizeHeight:u});return a.close(),d}function C$(e){let t=u$(e),{width:n,height:r,depth:i,channels:a}=t,o=n*r,s=new Uint8Array(o*4);if(t.palette){let e=c$(t),i=t.palette[0].length;for(let t=0;t<o;t+=1)s.set(e.subarray(t*i,t*i+3),t*4),s[t*4+3]=i===4?e[t*i+3]:255;return{width:n,height:r,data:s}}let c=2**i-1,l=Math.ceil(n*i/8);function u(e){if(i>=8)return t.data[e];let r=e%n*i;return t.data[Math.floor(e/n)*l+(r>>3)]>>8-i-(r&7)&c}function d(e){return i===16?e>>8:i===8?e:Math.round(e*255/c)}let f=t.transparency;for(let e=0;e<o;e+=1){let t=e*4;if(a===1||a===2){let n=u(e*a);s.fill(d(n),t,t+3),s[t+3]=a===2?d(u(e*2+1)):f?.[0]===n?0:255}else if(a===3||a===4){let n=u(e*a),r=u(e*a+1),i=u(e*a+2);s[t]=d(n),s[t+1]=d(r),s[t+2]=d(i),s[t+3]=a===4?d(u(e*4+3)):f?.[0]===n&&f[1]===r&&f[2]===i?0:255}else throw Error(`unsupported PNG with ${a} channels`)}return{width:n,height:r,data:s}}var w$=class{core;images=[];nextImage=0;constructor(e){this.core=e}place(e,t,n){let r=`${y$}${this.nextImage++}`;this.core.write(v$.encode(`\x1b]8;;${r}\x1b\\ \x1b]8;;\x1b\\\b`));let i={ref:this.core.trackCursor(),marker:r,bitmap:e,width:e.width/t,height:e.height/t,alternate:this.core.isAlternateScreen()};if(this.images.push(i),this.images.length>_$){let e=this.images.shift();e&&this.remove(e)}let a=Math.ceil(i.height/n);a>1&&this.core.write(v$.encode(`\x1BD`.repeat(a-1)))}visible(e,t,n){if(this.images.length===0)return[];let r=this.core.isAlternateScreen(),i=[],a=[];for(let o of this.images){if(o.alternate!==r){a.push(o);continue}let s=this.core.trackedPoint(o.ref);if(s===null||this.core.trackedHyperlink(o.ref)!==o.marker){this.remove(o);continue}a.push(o);let c=s.y-e;c+Math.ceil(o.height/n)<=0||c>=t||i.push({bitmap:o.bitmap,width:o.width,height:o.height,x:s.x,y:c})}return this.images=a,i}clear(){for(let e of this.images)this.remove(e);this.images=[]}remove(e){this.core.untrack(e.ref),e.bitmap.close()}},T$=new Uint8Array([0,97,115,109,1,0,0,0,1,35,5,96,4,127,127,127,127,0,96,3,127,127,127,1,127,96,2,127,127,0,96,3,127,127,127,0,96,5,127,127,127,127,127,1,127,2,49,6,3,101,110,118,1,119,0,0,3,101,110,118,1,100,0,1,3,101,110,118,1,115,0,1,3,101,110,118,1,98,0,2,3,101,110,118,1,118,0,3,3,101,110,118,1,112,0,4,7,25,6,1,119,0,0,1,100,0,1,1,115,0,2,1,98,0,3,1,118,0,4,1,112,0,5]),E$={userdata:0,writePty:1,bell:2,xtversion:4,size:6,deviceAttributes:8},D$=1,O$=-3,k$={width:0,height:4,data:8,length:12},A$=new TextDecoder,j$=new TextEncoder,M$=class e{memory;layouts;exports;memoryView;hosts=new Map;nextHostId=1;callbacks={writePty:0,deviceAttributes:0,size:0,bell:0,xtversion:0};version={pointer:0,size:0};constructor(e){this.exports=e.exports;let t=e.exports.memory;if(!(t instanceof WebAssembly.Memory))throw Error(`libghostty-vt did not export its memory`);this.memory=t,this.memoryView=new DataView(t.buffer);let n=this.call(`ghostty_type_json`),r=new Uint8Array(t.buffer),i=n;for(;i<r.length&&r[i]!==0;)i+=1;this.layouts=JSON.parse(A$.decode(r.subarray(n,i)))}static async load(){let t=await fetch(NZ);if(!t.ok)throw Error(`could not load libghostty-vt (${t.status})`);let n=null,r=await WebAssembly.instantiate(await t.arrayBuffer(),{env:{log:(e,t)=>{n&&console.debug(`[libghostty-vt]`,A$.decode(new Uint8Array(n.buffer,e,t)))}}}),i=new e(r.instance);return n=i.memory,i.installCallbacks(),i}call(e,...t){let n=this.exports[e];if(typeof n!=`function`)throw Error(`libghostty-vt export is missing: ${e}`);return n(...t)}layout(e){let t=this.layouts[e];if(!t)throw Error(`libghostty-vt layout is missing: ${e}`);return t}field(e,t){let n=this.layout(e).fields[t];if(!n)throw Error(`libghostty-vt field is missing: ${e}.${t}`);return n}alloc(e){let t=this.call(`ghostty_wasm_alloc_u8_array`,e);if(t===0)throw Error(`libghostty-vt could not allocate ${e} bytes`);return new Uint8Array(this.memory.buffer,t,e).fill(0),t}free(e,t){e!==0&&this.call(`ghostty_wasm_free_u8_array`,e,t)}allocOpaque(){let e=this.call(`ghostty_wasm_alloc_opaque`);if(e===0)throw Error(`libghostty-vt could not allocate a pointer`);return new DataView(this.memory.buffer).setUint32(e,0,!0),e}freeOpaque(e){e!==0&&this.call(`ghostty_wasm_free_opaque`,e)}readPointer(e){return this.dataView().getUint32(e,!0)}check(e,t){if(t!==0)throw Error(`${e} failed with result ${t}`)}flag(e,t,n){let r=this.alloc(1),i=this.call(e,t,n,r),a=this.bytes(r,1)[0];return this.free(r,1),i===0&&a!==0}encodeOutput(e){let t=this.call(`ghostty_wasm_alloc_usize`),n=``,r=e(0,0,t),i=this.view(t,4).getUint32(0,!0);if(r===O$&&i>0){let r=this.alloc(i),a=e(r,i,t),o=this.view(t,4).getUint32(0,!0);a===0&&(n=A$.decode(this.bytes(r,o))),this.free(r,i)}return this.call(`ghostty_wasm_free_usize`,t),n}attachHost(e,t){let n=this.nextHostId++;this.hosts.set(n,t),this.call(`ghostty_terminal_set`,e,E$.userdata,n);for(let t of[[E$.writePty,this.callbacks.writePty],[E$.deviceAttributes,this.callbacks.deviceAttributes],[E$.size,this.callbacks.size],[E$.bell,this.callbacks.bell],[E$.xtversion,this.callbacks.xtversion]])this.call(`ghostty_terminal_set`,e,t[0],t[1]);return n}detachHost(e,t){this.call(`ghostty_terminal_set`,e,E$.xtversion,0),this.call(`ghostty_terminal_set`,e,E$.bell,0),this.call(`ghostty_terminal_set`,e,E$.size,0),this.call(`ghostty_terminal_set`,e,E$.deviceAttributes,0),this.call(`ghostty_terminal_set`,e,E$.writePty,0),this.call(`ghostty_terminal_set`,e,E$.userdata,0),this.hosts.delete(t)}view(e,t){return new DataView(this.memory.buffer,e,t)}bytes(e,t){return new Uint8Array(this.memory.buffer,e,t)}dataView(){return this.memoryView.buffer!==this.memory.buffer&&(this.memoryView=new DataView(this.memory.buffer)),this.memoryView}setField(e,t,n,r){let i=this.field(t,n),a=this.dataView(),o=e+i.offset;if(i.type===`bool`||i.type===`u8`)a.setUint8(o,r);else if(i.type===`u16`)a.setUint16(o,r,!0);else if(i.type===`i32`)a.setInt32(o,r,!0);else if(i.type===`u32`||i.type===`enum`)a.setUint32(o,r,!0);else if(i.type===`u64`)a.setBigUint64(o,BigInt(r),!0);else throw Error(`unsupported libghostty-vt field type ${i.type}`)}readField(e,t,n){let r=this.field(t,n),i=this.dataView(),a=e+r.offset;if(r.type===`bool`||r.type===`u8`)return i.getUint8(a);if(r.type===`u16`)return i.getUint16(a,!0);if(r.type===`i32`)return i.getInt32(a,!0);if(r.type===`u32`||r.type===`enum`)return i.getUint32(a,!0);if(r.type===`u64`)return Number(i.getBigUint64(a,!0));throw Error(`unsupported libghostty-vt field type ${r.type}`)}installCallbacks(){let e=new WebAssembly.Instance(new WebAssembly.Module(T$),{env:{w:(e,t,n,r)=>{let i=this.hosts.get(t);i&&r!==0&&i.write(A$.decode(new Uint8Array(this.memory.buffer,n,r)))},d:(e,t,n)=>this.hosts.has(t)?(this.writeDeviceAttributes(n),1):0,s:(e,t,n)=>{let r=this.hosts.get(t);if(!r)return 0;let i=r.size(),a=`GhosttySizeReportSize`;return this.setField(n,a,`rows`,i.rows),this.setField(n,a,`columns`,i.columns),this.setField(n,a,`cell_width`,i.cellWidth),this.setField(n,a,`cell_height`,i.cellHeight),1},b:(e,t)=>{this.hosts.get(t)?.bell()},v:(e,t,n)=>{let r=this.hosts.get(n);r&&this.writeVersion(e,r.version())},p:(e,t,n,r,i)=>this.decodePng(t,n,r,i)}}),t=this.exports.__indirect_function_table;if(!(t instanceof WebAssembly.Table))throw Error(`libghostty-vt did not expose its callback table`);let n=[`w`,`d`,`s`,`b`,`v`,`p`].map(n=>{let r=e.exports[n];if(typeof r!=`function`)throw Error(`libghostty-vt callback is missing: ${n}`);let i=t.length;return t.grow(1),t.set(i,r),i});if(this.callbacks={writePty:n[0],deviceAttributes:n[1],size:n[2],bell:n[3],xtversion:n[4]},this.call(`ghostty_sys_set`,D$,n[5])!==0)throw Error(`libghostty-vt did not accept the PNG decoder`)}decodePng(e,t,n,r){let i;try{i=C$(new Uint8Array(this.memory.buffer,t,n))}catch(e){return console.warn(`could not decode a kitty PNG image`,e),0}let a=this.call(`ghostty_alloc`,e,i.data.length);if(a===0)return 0;this.bytes(a,i.data.length).set(i.data);let o=this.dataView();return o.setUint32(r+k$.width,i.width,!0),o.setUint32(r+k$.height,i.height,!0),o.setUint32(r+k$.data,a,!0),o.setUint32(r+k$.length,i.data.length,!0),1}writeVersion(e,t){let n=j$.encode(t);this.free(this.version.pointer,this.version.size);let r=this.alloc(n.length);this.bytes(r,n.length).set(n),this.version={pointer:r,size:n.length},this.dataView().setUint32(e+this.field(`GhosttyString`,`ptr`).offset,r,!0),this.setField(e,`GhosttyString`,`len`,n.length)}writeDeviceAttributes(e){let t=e+this.field(`GhosttyDeviceAttributes`,`primary`).offset,n=e+this.field(`GhosttyDeviceAttributes`,`secondary`).offset,r=e+this.field(`GhosttyDeviceAttributes`,`tertiary`).offset,i=`GhosttyDeviceAttributesPrimary`,a=`GhosttyDeviceAttributesSecondary`,o=t+this.field(i,`features`).offset,s=this.dataView(),c=[4,22];c.forEach((e,t)=>s.setUint16(o+t*2,e,!0)),this.setField(t,i,`conformance_level`,62),this.setField(t,i,`num_features`,c.length),this.setField(n,a,`device_type`,0),this.setField(n,a,`firmware_version`,276),this.setField(n,a,`rom_cartridge`,0),this.setField(r,`GhosttyDeviceAttributesTertiary`,`unit_id`,0)}},N$=null;async function P$(){N$=await M$.load()}function F$(){if(!N$)throw Error(`libghostty-vt is not loaded`);return N$}var I$=new Map(`Unidentified.Backquote.Backslash.BracketLeft.BracketRight.Comma.Digit0.Digit1.Digit2.Digit3.Digit4.Digit5.Digit6.Digit7.Digit8.Digit9.Equal.IntlBackslash.IntlRo.IntlYen.KeyA.KeyB.KeyC.KeyD.KeyE.KeyF.KeyG.KeyH.KeyI.KeyJ.KeyK.KeyL.KeyM.KeyN.KeyO.KeyP.KeyQ.KeyR.KeyS.KeyT.KeyU.KeyV.KeyW.KeyX.KeyY.KeyZ.Minus.Period.Quote.Semicolon.Slash.AltLeft.AltRight.Backspace.CapsLock.ContextMenu.ControlLeft.ControlRight.Enter.MetaLeft.MetaRight.ShiftLeft.ShiftRight.Space.Tab.Convert.KanaMode.NonConvert.Delete.End.Help.Home.Insert.PageDown.PageUp.ArrowDown.ArrowLeft.ArrowRight.ArrowUp.NumLock.Numpad0.Numpad1.Numpad2.Numpad3.Numpad4.Numpad5.Numpad6.Numpad7.Numpad8.Numpad9.NumpadAdd.NumpadBackspace.NumpadClear.NumpadClearEntry.NumpadComma.NumpadDecimal.NumpadDivide.NumpadEnter.NumpadEqual.NumpadMemoryAdd.NumpadMemoryClear.NumpadMemoryRecall.NumpadMemoryStore.NumpadMemorySubtract.NumpadMultiply.NumpadParenLeft.NumpadParenRight.NumpadSubtract.NumpadSeparator.NumpadArrowUp.NumpadArrowDown.NumpadArrowRight.NumpadArrowLeft.NumpadBegin.NumpadHome.NumpadEnd.NumpadInsert.NumpadDelete.NumpadPageUp.NumpadPageDown.Escape.F1.F2.F3.F4.F5.F6.F7.F8.F9.F10.F11.F12.F13.F14.F15.F16.F17.F18.F19.F20.F21.F22.F23.F24.F25.Fn.FnLock.PrintScreen.ScrollLock.Pause.BrowserBack.BrowserFavorites.BrowserForward.BrowserHome.BrowserRefresh.BrowserSearch.BrowserStop.Eject.LaunchApp1.LaunchApp2.LaunchMail.MediaPlayPause.MediaSelect.MediaStop.MediaTrackNext.MediaTrackPrevious.Power.Sleep.AudioVolumeDown.AudioVolumeMute.AudioVolumeUp.WakeUp.Copy.Cut.Paste`.split(`.`).map((e,t)=>[e,t]));function L$(e){return I$.get(e)??0}var R$=new Map([[`!`,`1`],[`@`,`2`],[`#`,`3`],[`$`,`4`],[`%`,`5`],[`^`,`6`],[`&`,`7`],[`*`,`8`],[`(`,`9`],[`)`,`0`],[`~`,"`"],[`_`,`-`],[`+`,`=`],[`{`,`[`],[`}`,`]`],[`|`,`\\`],[`:`,`;`],[`"`,`'`],[`<`,`,`],[`>`,`.`],[`?`,`/`]]),z$;function B$(){return z$||(z$=globalThis.navigator?.keyboard?.getLayoutMap().catch(()=>void 0)??Promise.resolve(void 0),z$)}function V$(){return z$=void 0,B$()}function H$(e){return!e.shiftKey||e.ctrlKey||e.altKey||e.metaKey?0:+([...e.key].length===1)}function U$(e,t){if([...e.key].length!==1)return 0;let n=t?.get(e.code);if(n&&[...n].length===1)return n.codePointAt(0)??0;if(/^[A-Z]$/u.test(e.key))return e.key.charCodeAt(0)+32;if(e.shiftKey){let t=R$.get(e.key);if(t)return t.codePointAt(0)??0;let n=e.key.toLowerCase();return n!==e.key&&[...n].length===1?n.codePointAt(0)??0:0}return e.key.codePointAt(0)??0}var W$=new Map([[`Backquote`,"`"],[`Minus`,`-`],[`Equal`,`=`],[`BracketLeft`,`[`],[`BracketRight`,`]`],[`Backslash`,`\\`],[`Semicolon`,`;`],[`Quote`,`'`],[`Comma`,`,`],[`Period`,`.`],[`Slash`,`/`],[`Space`,` `]]),G$=[...`0123456789`].map(e=>[`Digit${e}`,e]),K$=new Map([...R$].map(e=>[e[1],e[0]]));function q$(e){return/^Key[A-Z]$/u.test(e)?e[3].toLowerCase():/^Digit[0-9]$/u.test(e)?e[5]:W$.get(e)}function J$(e){return[...W$,...G$].every(t=>t[0]===`Space`||e.get(t[0])===t[1])}function Y$(e,t){let n=t?.get(e.code),r=n&&[...n].length===1?n:q$(e.code);if(r===void 0)return[...e.key].length===1?null:e.key;if(!e.shiftKey)return r;let i=r.toUpperCase();return i!==r&&[...i].length===1?i:t===void 0||!J$(t)?null:K$.get(r)??r}var X$=new TextEncoder,Z$=new Map([[`[`,`\x1B`],[`m`,`\r`],[`i`,` `],[`@`,`\0`]]),Q$=class{runtime=F$();terminal;keyEncoderSlot;keyEncoder;keyEventSlot;keyEvent;mouseEncoderSlot;mouseEncoder;mouseEventSlot;mouseEvent;scratch;keyboardLayoutMap;constructor(e){let t=this.runtime;this.terminal=e,this.loadKeyboardLayout(B$()),this.keyEncoderSlot=t.allocOpaque(),t.check(`ghostty_key_encoder_new`,t.call(`ghostty_key_encoder_new`,0,this.keyEncoderSlot)),this.keyEncoder=t.readPointer(this.keyEncoderSlot),this.keyEventSlot=t.allocOpaque(),t.check(`ghostty_key_event_new`,t.call(`ghostty_key_event_new`,0,this.keyEventSlot)),this.keyEvent=t.readPointer(this.keyEventSlot),this.mouseEncoderSlot=t.allocOpaque(),t.check(`ghostty_mouse_encoder_new`,t.call(`ghostty_mouse_encoder_new`,0,this.mouseEncoderSlot)),this.mouseEncoder=t.readPointer(this.mouseEncoderSlot),this.mouseEventSlot=t.allocOpaque(),t.check(`ghostty_mouse_event_new`,t.call(`ghostty_mouse_event_new`,0,this.mouseEventSlot)),this.mouseEvent=t.readPointer(this.mouseEventSlot),this.scratch=t.alloc(1)}encodeKey(e,t=`press`,n=!1){let r=this.runtime,i=e.key.toLowerCase(),a=Z$.get(i);if(a!==void 0&&t===`press`&&e.ctrlKey&&!e.altKey&&!e.metaKey&&!(e.shiftKey&&/^[a-z]$/u.test(i))&&!r.flag(`ghostty_terminal_get`,this.terminal,8))return a;let o=n?this.metaText(e):null,s=o??e.key;if(o!==null&&t===`press`&&!e.ctrlKey&&[...s].length===1&&(s.codePointAt(0)??0)>127&&r.flag(`ghostty_terminal_mode_get`,this.terminal,1036)&&this.isLegacyKeyboard())return`\x1b${s}`;r.call(`ghostty_key_encoder_setopt_from_terminal`,this.keyEncoder,this.terminal),r.call(`ghostty_key_event_set_action`,this.keyEvent,t===`release`?0:e.repeat?2:1),r.call(`ghostty_key_event_set_key`,this.keyEvent,L$(e.code));let c=+!!e.shiftKey|(e.ctrlKey?2:0)|(e.altKey?4:0)|(e.metaKey?8:0)|(e.getModifierState(`CapsLock`)?16:0)|(e.getModifierState(`NumLock`)?32:0);r.call(`ghostty_key_event_set_mods`,this.keyEvent,c),r.call(`ghostty_key_event_set_consumed_mods`,this.keyEvent,H$(e)),r.call(`ghostty_key_event_set_composing`,this.keyEvent,+!!e.isComposing),r.call(`ghostty_key_event_set_unshifted_codepoint`,this.keyEvent,U$({code:e.code,key:s,shiftKey:e.shiftKey},this.keyboardLayoutMap));let l=X$.encode(s.length===1?s:``),u=l.length===0?0:r.alloc(l.length);u!==0&&r.bytes(u,l.length).set(l),r.call(`ghostty_key_event_set_utf8`,this.keyEvent,u,l.length);let d=r.encodeOutput((e,t,n)=>r.call(`ghostty_key_encoder_encode`,this.keyEncoder,this.keyEvent,e,t,n));return u!==0&&r.free(u,l.length),d}metaText(e){return Y$(e,this.keyboardLayoutMap)}refreshKeyboardLayout(){this.loadKeyboardLayout(V$())}encodePaste(e){let t=this.runtime,n=X$.encode(e);if(n.length===0)return``;let r=t.alloc(n.length);t.bytes(r,n.length).set(n);let i=+!!t.flag(`ghostty_terminal_mode_get`,this.terminal,2004),a=t.encodeOutput((e,a,o)=>t.call(`ghostty_paste_encode`,r,n.length,i,e,a,o));return t.free(r,n.length),a}encodeMouse(e){let t=this.runtime;t.call(`ghostty_mouse_encoder_setopt_from_terminal`,this.mouseEncoder,this.terminal);let n=t.layout(`GhosttyMouseEncoderSize`),r=t.alloc(n.size);for(let i of[[`size`,n.size],[`screen_width`,e.screenWidth],[`screen_height`,e.screenHeight],[`cell_width`,e.cellWidth],[`cell_height`,e.cellHeight],[`padding_top`,0],[`padding_bottom`,0],[`padding_right`,0],[`padding_left`,0]])t.setField(r,`GhosttyMouseEncoderSize`,i[0],Math.max(0,Math.round(i[1])));t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,2,r),t.free(r,n.size),t.bytes(this.scratch,1)[0]=+!!e.anyButtonPressed,t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,3,this.scratch),t.bytes(this.scratch,1)[0]=1,t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,4,this.scratch),t.call(`ghostty_mouse_event_set_action`,this.mouseEvent,{press:0,release:1,motion:2}[e.action]),e.button===null?t.call(`ghostty_mouse_event_clear_button`,this.mouseEvent):t.call(`ghostty_mouse_event_set_button`,this.mouseEvent,e.button),t.call(`ghostty_mouse_event_set_mods`,this.mouseEvent,e.mods);let i=t.layout(`GhosttyMousePosition`),a=t.alloc(i.size),o=t.view(a,i.size);return o.setFloat32(t.field(`GhosttyMousePosition`,`x`).offset,e.x,!0),o.setFloat32(t.field(`GhosttyMousePosition`,`y`).offset,e.y,!0),t.call(`ghostty_mouse_event_set_position`,this.mouseEvent,a),t.free(a,i.size),t.encodeOutput((e,n,r)=>t.call(`ghostty_mouse_encoder_encode`,this.mouseEncoder,this.mouseEvent,e,n,r))}dispose(){let e=this.runtime;e.call(`ghostty_mouse_event_free`,this.mouseEvent),e.call(`ghostty_mouse_encoder_free`,this.mouseEncoder),e.call(`ghostty_key_event_free`,this.keyEvent),e.call(`ghostty_key_encoder_free`,this.keyEncoder),e.free(this.scratch,1),e.freeOpaque(this.mouseEventSlot),e.freeOpaque(this.mouseEncoderSlot),e.freeOpaque(this.keyEventSlot),e.freeOpaque(this.keyEncoderSlot)}async loadKeyboardLayout(e){this.keyboardLayoutMap=await e}isLegacyKeyboard(){return this.encodeKey(new KeyboardEvent(`keydown`,{key:`Tab`,code:`Tab`,shiftKey:!0}))===`\x1B[Z`}},$$=26,e1=30,t1=1,n1={imageId:1,placementId:2,isVirtual:3,xOffset:4,yOffset:5,columns:10,rows:11,z:12},r1={width:3,height:4,format:5,data:7,length:8},i1={size:48,pixelWidth:4,pixelHeight:8,column:20,row:24,visible:28,sourceX:32,sourceY:36,sourceWidth:40,sourceHeight:44},a1=new Map([[0,3],[1,4],[3,2],[4,1]]),o1=new Map([773,781,782,784,786,829,830,831,838,842,843,844,848,849,850,855,859,867,868,869,870,871,872,873,874,875,876,877,878,879,1155,1156,1157,1158,1159,1426,1427,1428,1429,1431,1432,1433,1436,1437,1438,1439,1440,1441,1448,1449,1451,1452,1455,1476,1552,1553,1554,1555,1556,1557,1558,1559,1623,1624,1625,1626,1627,1629,1630,1750,1751,1752,1753,1754,1755,1756,1759,1760,1761,1762,1764,1767,1768,1771,1772,1840,1842,1843,1845,1846,1850,1853,1855,1856,1857,1859,1861,1863,1865,1866,2027,2028,2029,2030,2031,2032,2033,2035,2070,2071,2072,2073,2075,2076,2077,2078,2079,2080,2081,2082,2083,2085,2086,2087,2089,2090,2091,2092,2093,2385,2387,2388,3970,3971,3974,3975,4957,4958,4959,6109,6458,6679,6773,6774,6775,6776,6777,6778,6779,6780,7019,7021,7022,7023,7024,7025,7026,7027,7376,7377,7378,7386,7387,7392,7616,7617,7619,7620,7621,7622,7623,7624,7625,7627,7628,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,7643,7644,7645,7646,7647,7648,7649,7650,7651,7652,7653,7654,7678,8400,8401,8404,8405,8406,8407,8411,8412,8417,8423,8425,8432,11503,11504,11505,11744,11745,11746,11747,11748,11749,11750,11751,11752,11753,11754,11755,11756,11757,11758,11759,11760,11761,11762,11763,11764,11765,11766,11767,11768,11769,11770,11771,11772,11773,11774,11775,42607,42620,42621,42736,42737,43232,43233,43234,43235,43236,43237,43238,43239,43240,43241,43242,43243,43244,43245,43246,43247,43248,43249,43696,43698,43699,43703,43704,43710,43711,43713,65056,65057,65058,65059,65060,65061,65062,68111,68152,119173,119174,119175,119176,119177,119210,119211,119212,119213,119362,119363,119364].map((e,t)=>[e,t]));function s1(e,t,n){let r=Array.from(e).slice(1,4).map(e=>o1.get(e.codePointAt(0)??0)??null),i=r[2]??null;return{imageId:t,placementId:n,row:r[0]??null,column:r[1]??null,imageIdHigh:i!==null&&i<256?i:null}}function c1(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n].cells,i=null;for(let e=0;e<r.length;e+=1){let a=r[e].placeholder;i!==null&&a!==null&&a.imageId===i.imageId&&a.placementId===i.placementId&&(a.row===null||a.row===i.row)&&(a.column===null||a.column===i.column+i.width)&&(a.imageIdHigh===null||a.imageIdHigh===i.imageIdHigh)?i.width+=1:(i!==null&&t.push(l1(i)),i=a===null?null:{x:e,y:n,imageId:a.imageId,imageIdHigh:a.imageIdHigh,placementId:a.placementId,row:a.row??0,column:a.column??0,width:1})}i!==null&&t.push(l1(i))}return t}function l1(e){return{x:e.x,y:e.y,imageId:e.imageId+(e.imageIdHigh??0)*2**24,placementId:e.placementId,row:e.row,column:e.column,width:e.width}}function u1(e,t,n,r){let i=t.columns===0?Math.ceil(n.width/r.width):t.columns,a=t.rows===0?Math.ceil(n.height/r.height):t.rows,o=i*r.width,s=a*r.height,c=n.width*s>n.height*o,l=c?o/Math.max(n.width,1):s/Math.max(n.height,1),u=c?0:(o-n.width*l)/2/l,d=c?(s-n.height*l)/2/l:0,f=n.width+u*2,p=n.height+d*2,m={x:f*e.column/i,y:p*e.row/a,width:f*e.width/i,height:p/a},h=0,g=0,_=e.width*r.width,v=r.height;if(m.y<d){let e=d-m.y;m.height-=e,g=e,v-=e*l,m.y=0,m.height>n.height&&(m.height=n.height,v=n.height*l)}else m.y+m.height>p-d?(m.y-=d,m.height=p-d-m.y-d,v=m.height*l):m.y-=d;if(m.x<u){let e=u-m.x;m.width-=e,h=e,_-=e*l,m.x=0,m.width>n.width&&(m.width=n.width,_=n.width*l)}else m.x+m.width>f-u?(m.x-=u,m.width=f-u-m.x-u,_=m.width*l):m.x-=u;if(m.width<=0||m.height<=0)return null;let y={xOffset:Math.round(h*l),yOffset:Math.round(g*l),width:Math.round(_),height:Math.round(v),source:{x:Math.round(m.x),y:Math.round(m.y),width:Math.round(m.width),height:Math.round(m.height)}};return y.width===0||y.height===0?null:y}function d1(e){let t=F$(),n=t.alloc(16),r=t.call(`ghostty_terminal_get`,e,$$,n);return t.free(n,16),r===0}var f1=class{runtime=F$();terminal;iteratorSlot;info;scratch;tail=[0,0];commands=0;cachedCommands=0;bitmaps=new Map;constructor(e){let t=this.runtime;this.terminal=e,this.iteratorSlot=t.allocOpaque(),t.check(`ghostty_kitty_graphics_placement_iterator_new`,t.call(`ghostty_kitty_graphics_placement_iterator_new`,0,this.iteratorSlot)),this.info=t.alloc(i1.size),this.scratch=t.alloc(16)}note(e){let t=[...this.tail,...e.subarray(0,2)],n=t.some((e,n)=>e===27&&t[n+1]===95&&t[n+2]===71),r=e.indexOf(27);for(;!n&&r!==-1;)n=e[r+1]===95&&e[r+2]===71,r=e.indexOf(27,r+1);n&&(this.commands+=1),this.tail=[...this.tail,...e.subarray(-2)].slice(-2)}images(e,t){this.commands!==this.cachedCommands&&(this.cachedCommands=this.commands,this.bitmaps.clear());let n=new Map,r=this.placements(e,t).map(e=>{let t=n.get(e.key)??this.bitmaps.get(e.key)??h1(e.image);return n.set(e.key,t),{placement:e,bitmap:t}});return this.bitmaps=n,r}dispose(){let e=this.runtime;e.call(`ghostty_kitty_graphics_placement_iterator_free`,e.readPointer(this.iteratorSlot)),e.free(this.info,i1.size),e.free(this.scratch,16),e.freeOpaque(this.iteratorSlot),this.bitmaps.clear()}placements(e,t){let n=this.runtime;n.check(`ghostty_terminal_get`,n.call(`ghostty_terminal_get`,this.terminal,e1,this.scratch));let r=n.readPointer(this.scratch);n.check(`ghostty_kitty_graphics_get`,n.call(`ghostty_kitty_graphics_get`,r,t1,this.iteratorSlot));let i=n.readPointer(this.iteratorSlot),a=[],o=[];for(;n.call(`ghostty_kitty_graphics_placement_next`,i);){let e=this.placementU32(i,n1.imageId);if(this.placementData(i,n1.isVirtual).getUint8(0)){o.push({imageId:e,placementId:this.placementU32(i,n1.placementId),columns:this.placementU32(i,n1.columns),rows:this.placementU32(i,n1.rows)});continue}let t=n.call(`ghostty_kitty_graphics_image`,r,e);if(t===0)throw Error(`kitty placement points to missing image ${e}`);n.bytes(this.info,i1.size).fill(0);let s=n.view(this.info,i1.size);s.setUint32(0,i1.size,!0),n.check(`ghostty_kitty_graphics_placement_render_info`,n.call(`ghostty_kitty_graphics_placement_render_info`,i,t,this.terminal,this.info)),s.getUint8(i1.visible)!==0&&a.push({...this.image(t,e),z:this.placementData(i,n1.z).getInt32(0,!0),column:s.getInt32(i1.column,!0),row:s.getInt32(i1.row,!0),xOffset:this.placementU32(i,n1.xOffset),yOffset:this.placementU32(i,n1.yOffset),width:s.getUint32(i1.pixelWidth,!0),height:s.getUint32(i1.pixelHeight,!0),source:{x:s.getUint32(i1.sourceX,!0),y:s.getUint32(i1.sourceY,!0),width:s.getUint32(i1.sourceWidth,!0),height:s.getUint32(i1.sourceHeight,!0)}})}if(o.length===0)return a;for(let i of c1(e)){let e=o.find(e=>e.imageId===i.imageId&&(i.placementId===0||e.placementId===i.placementId));if(e===void 0)continue;let s=n.call(`ghostty_kitty_graphics_image`,r,i.imageId);if(s===0)continue;let c=this.image(s,i.imageId),l=u1(i,e,c.image,t);l!==null&&a.push({...c,...l,z:-1,column:i.x,row:i.y})}return a}image(e,t){let n=this.imageData(e,r1.data),r=this.imageData(e,r1.length);return{key:`${t}:${n}:${r}`,image:{width:this.imageData(e,r1.width),height:this.imageData(e,r1.height),format:this.imageData(e,r1.format),pixels:this.runtime.bytes(n,r)}}}placementData(e,t){return this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_kitty_graphics_placement_get`,this.runtime.call(`ghostty_kitty_graphics_placement_get`,e,t,this.scratch)),this.runtime.view(this.scratch,4)}placementU32(e,t){return this.placementData(e,t).getUint32(0,!0)}imageData(e,t){return this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_kitty_graphics_image_get`,this.runtime.call(`ghostty_kitty_graphics_image_get`,e,t,this.scratch)),this.runtime.view(this.scratch,4).getUint32(0,!0)}};function p1(e,t,n,r,i){let a=r.width/i.width,o=r.height/i.height;for(let i of t){let t=i.placement;m1(t.z)===n&&e.drawImage(i.bitmap,t.source.x,t.source.y,t.source.width,t.source.height,t.column*r.width+t.xOffset*a,t.row*r.height+t.yOffset*o,t.width*a,t.height*o)}}function m1(e){return e<-1073741824?`belowBackground`:e<0?`belowText`:`aboveText`}function h1(e){let t=a1.get(e.format);if(t===void 0)throw Error(`unsupported kitty image format ${e.format}`);let n=e.width*e.height,r=e.pixels,i=new Uint8ClampedArray(n*4);if(t===4)i.set(r.subarray(0,n*4));else for(let e=0;e<n;e+=1){let n=e*t,a=e*4;t===3?i.set(r.subarray(n,n+3),a):i.fill(r[n],a,a+3),i[a+3]=t===2?r[n+1]:255}let a=new OffscreenCanvas(e.width,e.height),o=a.getContext(`2d`);if(!o)throw Error(`could not create a canvas for a kitty image`);return o.putImageData(new ImageData(i,e.width,e.height),0,0),a}var g1=8,_1=16,v1=0,y1=1,b1=2,x1=8,S1={cols:1,rows:2,dirty:3,rowIterator:4,background:5,foreground:6,cursor:7,cursorHasValue:8,cursorStyle:10,cursorVisible:11,cursorBlinking:12,cursorInViewport:14,cursorX:15,cursorY:16},C1={dirty:1,raw:2,cells:3},w1={raw:1,style:2,graphemesLength:3,graphemes:4,background:5,foreground:6,selected:7},T1={keys:0,values:20,graphemesLength:40,selected:44,background:48,foreground:52,written:56,size:60},E1={narrow:0,wide:1,spacerTail:2},D1={r:229,g:231,b:235},O1={r:0,g:0,b:0};function k1(e,t){return Math.floor((e*155+t*100)/255)}function A1(e,t){return{r:k1(e.r,t.r),g:k1(e.g,t.g),b:k1(e.b,t.b)}}function j1(e,t){let n=``;for(let r=0;r<t;r+=4096){let i=Math.min(4096,t-r),a=Array(i);for(let t=0;t<i;t+=1)a[t]=e.getUint32((r+t)*4,!0);n+=String.fromCodePoint(...a)}return n}function M1(e,t){return{text:``,wide:0,foreground:e,background:t,bold:!1,italic:!1,invisible:!1,strikethrough:!1,overline:!1,underline:0,underlineColor:null,selected:!1,placeholder:null}}function N1(e,t){let n=e.dataView();return{r:n.getUint8(t),g:n.getUint8(t+1),b:n.getUint8(t+2)}}function P1(e,t){let n=e.alloc(768);e.call(`ghostty_terminal_get`,t,21,n);let r=e.bytes(n,768),i=Array.from({length:256},(e,t)=>({r:r[t*3],g:r[t*3+1],b:r[t*3+2]}));return e.free(n,768),i}function F1(e,t){let n=[],r=[];return e.cells.forEach((e,i)=>{if(e.wide!==2)for(let a of(e.text||` `).split(``))n.push(a),r.push({x:i,y:t})}),{text:n.join(``),points:r}}var I1=class{runtime=F$();stateSlot;state;rowIteratorSlot;rowCellsSlot;scratch;style;cellQuery;graphemes=0;graphemeCapacity=0;rows=[];palette=[];constructor(){let e=this.runtime;this.stateSlot=e.allocOpaque(),e.check(`ghostty_render_state_new`,e.call(`ghostty_render_state_new`,0,this.stateSlot)),this.state=e.readPointer(this.stateSlot),this.rowIteratorSlot=e.allocOpaque(),e.check(`ghostty_render_state_row_iterator_new`,e.call(`ghostty_render_state_row_iterator_new`,0,this.rowIteratorSlot)),this.rowCellsSlot=e.allocOpaque(),e.check(`ghostty_render_state_row_cells_new`,e.call(`ghostty_render_state_row_cells_new`,0,this.rowCellsSlot)),this.scratch=e.alloc(16),this.style=e.alloc(e.layout(`GhosttyStyle`).size),this.cellQuery=e.alloc(T1.size);let t=e.dataView();[[w1.style,this.style],[w1.graphemesLength,this.cellQuery+T1.graphemesLength],[w1.selected,this.cellQuery+T1.selected],[w1.background,this.cellQuery+T1.background],[w1.foreground,this.cellQuery+T1.foreground]].forEach((e,n)=>{t.setUint32(this.cellQuery+T1.keys+n*4,e[0],!0),t.setUint32(this.cellQuery+T1.values+n*4,e[1],!0)})}snapshot(e,t){let n=this.runtime;n.check(`ghostty_render_state_update`,n.call(`ghostty_render_state_update`,this.state,e));let r=this.getRender(S1.cols,2),i=this.getRender(S1.rows,2),a=this.getRender(S1.dirty,4),o=this.getColor(S1.foreground,D1),s=this.getColor(S1.background,O1),c=this.getRender(S1.cursorHasValue,1)===0?o:this.getColor(S1.cursor,o),l=this.getRender(S1.cursorInViewport,1)!==0,u=this.getRender(S1.cursorVisible,1)!==0&&l;(this.rows.length!==i||this.rows.some(e=>e.cells.length!==r))&&(this.rows=Array.from({length:i},()=>({cells:Array.from({length:r},()=>M1(o,s)),isWrapContinuation:!1,wrapsToNext:!1})));let d=new Set;if(a!==0){this.palette=P1(n,e),n.check(`ghostty_render_state_get`,n.call(`ghostty_render_state_get`,this.state,S1.rowIterator,this.rowIteratorSlot));let c=n.readPointer(this.rowIteratorSlot),l=0;for(;l<i&&n.call(`ghostty_render_state_row_iterator_next`,c)!==0;)(a===2||this.getRowFlag(c,C1.dirty))&&(this.rows[l]=this.readRow(c,r,o,s,t),d.add(l),n.bytes(this.scratch,1)[0]=0,n.call(`ghostty_render_state_row_set`,c,0,this.scratch)),l+=1;n.view(this.scratch,4).setUint32(0,0,!0),n.call(`ghostty_render_state_set`,this.state,0,this.scratch)}return{cols:r,rows:i,foreground:o,background:s,cursor:c,cursorX:l?this.getRender(S1.cursorX,2):-1,cursorY:l?this.getRender(S1.cursorY,2):-1,cursorVisible:u,cursorBlinking:this.getRender(S1.cursorBlinking,1)!==0,cursorStyle:this.getRender(S1.cursorStyle,4),dirtyRows:d,rowData:this.rows}}invalidate(){this.rows=[]}dispose(){let e=this.runtime,t=e.readPointer(this.rowCellsSlot);t&&e.call(`ghostty_render_state_row_cells_free`,t);let n=e.readPointer(this.rowIteratorSlot);n&&e.call(`ghostty_render_state_row_iterator_free`,n),e.call(`ghostty_render_state_free`,this.state),e.free(this.style,e.layout(`GhosttyStyle`).size),e.free(this.cellQuery,T1.size),e.free(this.scratch,16),e.free(this.graphemes,this.graphemeCapacity),e.freeOpaque(this.rowCellsSlot),e.freeOpaque(this.rowIteratorSlot),e.freeOpaque(this.stateSlot)}readRow(e,t,n,r,i){let a=this.runtime;a.check(`ghostty_render_state_row_get`,a.call(`ghostty_render_state_row_get`,e,C1.raw,this.scratch));let o=a.view(this.scratch,8).getBigUint64(0,!0);a.bytes(this.scratch+8,1)[0]=0,a.call(`ghostty_row_get`,o,2,this.scratch+8);let s=a.bytes(this.scratch+8,1)[0]!==0;a.bytes(this.scratch+8,1)[0]=0,a.call(`ghostty_row_get`,o,1,this.scratch+8);let c=a.bytes(this.scratch+8,1)[0]!==0;a.check(`ghostty_render_state_row_get`,a.call(`ghostty_render_state_row_get`,e,C1.cells,this.rowCellsSlot));let l=a.readPointer(this.rowCellsSlot),u=a.layout(`GhosttyStyle`),d=u.size,f=u.fields,p=[];for(;p.length<t&&a.call(`ghostty_render_state_row_cells_next`,l)!==0;){a.bytes(this.style,d).fill(0),a.setField(this.style,`GhosttyStyle`,`size`,d);let e=a.call(`ghostty_render_state_row_cells_get_multi`,l,5,this.cellQuery+T1.keys,this.cellQuery+T1.values,this.cellQuery+T1.written),t=a.dataView(),o=t.getUint32(this.cellQuery+T1.written,!0);o<3&&a.check(`ghostty_render_state_row_cells_get_multi`,e);let s=t.getUint32(this.cellQuery+T1.graphemesLength,!0),c=t.getUint8(this.cellQuery+T1.selected)!==0,u=o>=4?N1(a,this.cellQuery+T1.background):r,m=o===5?N1(a,this.cellQuery+T1.foreground):o===3?this.getCellColor(l,n):n,h=``;if(s>0){let e=s*4;if(e>this.graphemeCapacity){let t=Math.max(e,this.graphemeCapacity*2),n=a.alloc(t);a.free(this.graphemes,this.graphemeCapacity),this.graphemes=n,this.graphemeCapacity=t}a.call(`ghostty_render_state_row_cells_get`,l,w1.graphemes,this.graphemes)===0&&(h=j1(a.view(this.graphemes,e),s))}let g=0;if(h.length===0&&p.at(-1)?.text.length){a.call(`ghostty_render_state_row_cells_get`,l,w1.raw,this.scratch);let e=a.view(this.scratch,8).getBigUint64(0,!0);a.view(this.scratch+8,4).setUint32(0,0,!0),a.call(`ghostty_cell_get`,e,3,this.scratch+8),g=a.view(this.scratch+8,4).getUint32(0,!0)}let _=a.dataView(),v=e=>_.getUint8(this.style+f[e].offset)!==0,y=v(`bold`);if(i&&y&&_.getUint32(this.style+g1,!0)===y1){let e=_.getUint8(this.style+_1);e<8&&(m=this.palette[e+8]??m)}if(v(`inverse`)){let e=m;m=u,u=e}v(`faint`)&&(m=A1(m,u));let b=this.style+f.underline_color.offset,x=_.getUint32(b,!0),S=b+x1,C=null;h.codePointAt(0)===1109742&&(C=s1(h,this.colorId(this.style+g1),this.colorId(b)),h=``),p.push({text:h,wide:g,foreground:m,background:u,bold:y,italic:v(`italic`),invisible:v(`invisible`),strikethrough:v(`strikethrough`),overline:v(`overline`),underline:_.getInt32(this.style+f.underline.offset,!0),underlineColor:x===y1?this.palette[_.getUint8(S)]:x===b1?N1(a,S):null,selected:c,placeholder:C})}for(;p.length<t;)p.push(M1(n,r));return{cells:p,isWrapContinuation:s,wrapsToNext:c}}getRender(e,t){this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_render_state_get`,this.runtime.call(`ghostty_render_state_get`,this.state,e,this.scratch));let n=this.runtime.view(this.scratch,4);return t===1?n.getUint8(0):t===2?n.getUint16(0,!0):n.getUint32(0,!0)}getColor(e,t){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_get`,this.state,e,this.scratch)===0?N1(this.runtime,this.scratch):t}getRowFlag(e,t){return this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_render_state_row_get`,e,t,this.scratch)===0&&this.runtime.bytes(this.scratch,1)[0]!==0}getCellColor(e,t){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_row_cells_get`,e,w1.foreground,this.scratch)===0?N1(this.runtime,this.scratch):t}colorId(e){let t=this.runtime.dataView(),n=t.getUint32(e,!0);if(n===v1)return 0;if(n===y1)return t.getUint8(e+x1);if(n===b1){let t=N1(this.runtime,e+x1);return t.r<<16|t.g<<8|t.b}throw Error(`unknown style color tag ${n}`)}},L1=16,R1=589824,z1=381888,B1=5e7,V1=new TextDecoder;function H1(e){let t=[...e],n=[0,95,135,175,215,255];for(let e=16;e<232;e+=1){let r=e-16;t.push({r:n[Math.floor(r/36)],g:n[Math.floor(r/6)%6],b:n[r%6]})}for(let e=0;e<24;e+=1){let n=8+e*10;t.push({r:n,g:n,b:n})}return t}var U1=class{encoder;kitty;runtime=F$();terminalSlot;terminal;renderState;formatterSlot;formatter;scratch;point;scrollbar;host;hostId=0;sizeReport;disposed=!1;boldIsBright=!1;version=``;constructor(e,t,n,r,i){let a=this.runtime,o=a.layout(`GhosttyTerminalOptions`).size,s=a.alloc(o);a.setField(s,`GhosttyTerminalOptions`,`cols`,e),a.setField(s,`GhosttyTerminalOptions`,`rows`,t);let c=Math.floor(z1/(8*(e+1)));a.setField(s,`GhosttyTerminalOptions`,`max_scrollback`,n===0?0:Math.min((Math.ceil(n/c)+1)*R1,B1)),this.terminalSlot=a.allocOpaque();let l=a.call(`ghostty_terminal_new`,0,this.terminalSlot,s);if(a.free(s,o),a.check(`ghostty_terminal_new`,l),this.terminal=a.readPointer(this.terminalSlot),!d1(this.terminal))throw a.call(`ghostty_terminal_free`,this.terminal),a.freeOpaque(this.terminalSlot),Error(`libghostty-vt was built without kitty graphics, build it with scripts/build-ghostty-wasm.mts`);this.sizeReport={rows:t,columns:e,cellWidth:1,cellHeight:1},this.host={write:r,size:()=>this.sizeReport,bell:i,version:()=>this.version},this.hostId=a.attachHost(this.terminal,this.host),this.renderState=new I1,this.encoder=new Q$(this.terminal),this.kitty=new f1(this.terminal);let u=`GhosttyFormatterTerminalOptions`,d=a.layout(u),f=a.alloc(d.size),p=a.field(u,`extra`),m=a.field(`GhosttyFormatterTerminalExtra`,`screen`);a.setField(f,u,`size`,d.size),a.setField(f,u,`trim`,1),a.setField(f+p.offset,`GhosttyFormatterTerminalExtra`,`size`,p.size),a.setField(f+p.offset+m.offset,`GhosttyFormatterScreenExtra`,`size`,m.size),this.formatterSlot=a.allocOpaque();let h=a.call(`ghostty_formatter_terminal_new`,0,this.formatterSlot,this.terminal,f);a.free(f,d.size),a.check(`ghostty_formatter_terminal_new`,h),this.formatter=a.readPointer(this.formatterSlot),this.scratch=a.alloc(16),this.point=a.alloc(a.layout(`GhosttyPoint`).size),this.scrollbar=a.alloc(a.layout(`GhosttyTerminalScrollbar`).size)}write(e){if(e.length===0)return;this.kitty.note(e);let t=this.runtime.alloc(e.length);this.runtime.bytes(t,e.length).set(e),this.runtime.call(`ghostty_terminal_vt_write`,this.terminal,t,e.length),this.runtime.free(t,e.length)}setReplies(e){e&&this.hostId===0?this.hostId=this.runtime.attachHost(this.terminal,this.host):!e&&this.hostId!==0&&(this.runtime.detachHost(this.terminal,this.hostId),this.hostId=0)}reset(){this.runtime.call(`ghostty_terminal_reset`,this.terminal),this.renderState.invalidate()}resize(e,t,n,r,i){this.sizeReport={rows:t,columns:e,cellWidth:Math.max(1,Math.round(n*i)),cellHeight:Math.max(1,Math.round(r*i))},this.runtime.check(`ghostty_terminal_resize`,this.runtime.call(`ghostty_terminal_resize`,this.terminal,Math.max(1,Math.min(65535,e)),Math.max(1,Math.min(65535,t)),this.sizeReport.cellWidth,this.sizeReport.cellHeight))}setColors(e){let t=this.runtime.alloc(3);for(let n of[[11,e.foreground],[12,e.background],[13,e.cursor]]){let e=n[1];this.runtime.bytes(t,3).set([e.r,e.g,e.b]),this.runtime.call(`ghostty_terminal_set`,this.terminal,n[0],t)}this.runtime.free(t,3);let n=H1(e.palette),r=this.runtime.alloc(n.length*3);this.runtime.bytes(r,n.length*3).set(n.flatMap(e=>[e.r,e.g,e.b])),this.runtime.call(`ghostty_terminal_set`,this.terminal,14,r),this.runtime.free(r,n.length*3),this.renderState.invalidate()}setCursor(e,t){let n={bar:0,block:1,underline:2}[e];this.runtime.view(this.scratch,4).setUint32(0,n,!0),this.runtime.call(`ghostty_terminal_set`,this.terminal,22,this.scratch),this.runtime.bytes(this.scratch,1)[0]=+!!t,this.runtime.call(`ghostty_terminal_set`,this.terminal,23,this.scratch)}title(){if(this.runtime.bytes(this.scratch,8).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,12,this.scratch)!==0)return``;let e=this.runtime.view(this.scratch,8),t=e.getUint32(0,!0),n=e.getUint32(4,!0);return n===0?``:V1.decode(this.runtime.bytes(t,n))}screenText(){let e=this.runtime.alloc(8),t=this.runtime.call(`ghostty_formatter_format_alloc`,this.formatter,0,e,e+4),n=this.runtime.view(e,8),r=n.getUint32(0,!0),i=n.getUint32(4,!0);if(this.runtime.free(e,8),t!==0)return``;let a=V1.decode(this.runtime.bytes(r,i));return this.runtime.call(`ghostty_free`,0,r,i),a}scroll(e){let t=this.runtime.layout(`GhosttyTerminalScrollViewport`),n=this.runtime.alloc(t.size);this.runtime.setField(n,`GhosttyTerminalScrollViewport`,`tag`,2);let r=this.runtime.field(`GhosttyTerminalScrollViewport`,`value`);this.runtime.view(n+r.offset,r.size).setInt32(0,e,!0),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,n),this.runtime.free(n,t.size)}scrollToBottom(){let e=this.runtime.layout(`GhosttyTerminalScrollViewport`),t=this.runtime.alloc(e.size);this.runtime.setField(t,`GhosttyTerminalScrollViewport`,`tag`,1),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,t),this.runtime.free(t,e.size)}scrollbarState(){let e=this.runtime.layout(`GhosttyTerminalScrollbar`);return this.runtime.bytes(this.scrollbar,e.size).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,9,this.scrollbar)===0?{total:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`total`),offset:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`offset`),len:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`len`)}:null}isMouseTracking(){return this.flag(`ghostty_terminal_get`,11)}isMouseAnyEventTracking(){return this.flag(`ghostty_terminal_mode_get`,1003)}isFocusReporting(){return this.flag(`ghostty_terminal_mode_get`,1004)}isSynchronizedOutput(){return this.flag(`ghostty_terminal_mode_get`,2026)}endSynchronizedOutput(){this.runtime.check(`ghostty_terminal_mode_set`,this.runtime.call(`ghostty_terminal_mode_set`,this.terminal,2026,0))}currentColors(){return{foreground:this.terminalColor(18),background:this.terminalColor(19),cursor:this.terminalColor(20),palette:P1(this.runtime,this.terminal)}}isApplicationCursorKeys(){return this.flag(`ghostty_terminal_mode_get`,1)}isKittyKeyboard(){return this.flag(`ghostty_terminal_get`,8)}isAlternateScreen(){return this.runtime.dataView().setUint32(this.scratch,0,!0),this.runtime.call(`ghostty_terminal_get`,this.terminal,6,this.scratch)===0&&this.runtime.dataView().getUint32(this.scratch,!0)===1}setSelection(e,t){let n=this.runtime.layout(`GhosttyGridRef`).size,r=this.gridRef(e.x,e.y,2);try{let e=this.gridRef(t.x,t.y,2),i=this.runtime.layout(`GhosttySelection`),a=this.runtime.alloc(i.size);this.runtime.setField(a,`GhosttySelection`,`size`,i.size);let o=this.runtime.field(`GhosttySelection`,`start`),s=this.runtime.field(`GhosttySelection`,`end`);this.runtime.bytes(a+o.offset,o.size).set(this.runtime.bytes(r,o.size)),this.runtime.bytes(a+s.offset,s.size).set(this.runtime.bytes(e,s.size)),this.runtime.call(`ghostty_terminal_set`,this.terminal,21,a),this.runtime.free(e,n),this.runtime.free(a,i.size)}finally{this.runtime.free(r,n)}}selectWord(e){return this.selectAt(`GhosttyTerminalSelectWordOptions`,`ghostty_terminal_select_word`,e)}selectLine(e){return this.selectAt(`GhosttyTerminalSelectLineOptions`,`ghostty_terminal_select_line`,e)}clearSelection(){this.runtime.call(`ghostty_terminal_set`,this.terminal,21,0)}selectionText(){let e=this.runtime.alloc(L1),t=this.runtime.view(e,L1);t.setUint32(0,L1,!0),t.setUint8(8,1),t.setUint8(9,1);let n=this.runtime.encodeOutput((t,n,r)=>this.runtime.call(`ghostty_terminal_selection_format_buf`,this.terminal,e,t,n,r));return this.runtime.free(e,L1),n}hyperlinkAt(e,t){let n=this.gridRef(e,t,1),r=this.hyperlinkOf(n);return this.runtime.free(n,this.runtime.layout(`GhosttyGridRef`).size),r}toScreen(e){let t=this.gridRef(e.x,e.y,1),n=this.pointFromGridRef(t,2);return this.runtime.free(t,this.runtime.layout(`GhosttyGridRef`).size),n}trackCursor(){let e=this.runtime.allocOpaque(),t=this.runtime.call(`ghostty_terminal_grid_ref_track`,this.terminal,this.cursorPoint(),e),n=this.runtime.readPointer(e);return this.runtime.freeOpaque(e),this.runtime.check(`ghostty_terminal_grid_ref_track`,t),n}retrack(e){let t=this.runtime.call(`ghostty_tracked_grid_ref_set`,e,this.terminal,this.cursorPoint());this.runtime.check(`ghostty_tracked_grid_ref_set`,t)}trackedPoint(e){return this.runtime.call(`ghostty_tracked_grid_ref_point`,e,2,this.scratch)===0?{x:this.runtime.readField(this.scratch,`GhosttyPointCoordinate`,`x`),y:this.runtime.readField(this.scratch,`GhosttyPointCoordinate`,`y`)}:null}trackedHyperlink(e){let t=this.runtime.layout(`GhosttyGridRef`).size,n=this.runtime.alloc(t);this.runtime.setField(n,`GhosttyGridRef`,`size`,t);let r=this.runtime.call(`ghostty_tracked_grid_ref_snapshot`,e,n)===0?this.hyperlinkOf(n):null;return this.runtime.free(n,t),r}untrack(e){this.runtime.call(`ghostty_tracked_grid_ref_free`,e)}snapshot(){return this.renderState.snapshot(this.terminal,this.boldIsBright)}invalidate(){this.renderState.invalidate()}cellSize(){return{width:this.sizeReport.cellWidth,height:this.sizeReport.cellHeight}}dispose(){if(this.disposed)return;this.disposed=!0;let e=this.runtime;e.call(`ghostty_formatter_free`,this.formatter),this.encoder.dispose(),this.kitty.dispose(),this.renderState.dispose(),this.hostId!==0&&e.detachHost(this.terminal,this.hostId),e.call(`ghostty_terminal_free`,this.terminal),e.free(this.scrollbar,e.layout(`GhosttyTerminalScrollbar`).size),e.free(this.scratch,16),e.free(this.point,e.layout(`GhosttyPoint`).size),e.freeOpaque(this.formatterSlot),e.freeOpaque(this.terminalSlot)}hyperlinkOf(e){let t=this.runtime.encodeOutput((t,n,r)=>this.runtime.call(`ghostty_grid_ref_hyperlink_uri`,e,t,n,r));return t===``?null:t}cursorPosition(){this.runtime.dataView().setUint32(this.scratch,0,!0),this.runtime.call(`ghostty_terminal_get`,this.terminal,3,this.scratch),this.runtime.call(`ghostty_terminal_get`,this.terminal,4,this.scratch+2);let e=this.runtime.dataView();return{x:e.getUint16(this.scratch,!0),y:e.getUint16(this.scratch+2,!0)}}cursorPoint(){let e=this.cursorPosition();return this.fillPoint(this.point,e.x,e.y,0),this.point}fillPoint(e,t,n,r){this.runtime.setField(e,`GhosttyPoint`,`tag`,r);let i=this.runtime.field(`GhosttyPoint`,`value`),a=this.runtime.dataView();a.setUint16(e+i.offset,Math.max(0,t),!0),a.setUint32(e+i.offset+4,Math.max(0,n),!0)}gridRef(e,t,n){let r=this.runtime.alloc(this.runtime.layout(`GhosttyPoint`).size);this.fillPoint(r,e,t,n);let i=this.runtime.layout(`GhosttyGridRef`).size,a=this.runtime.alloc(i);this.runtime.setField(a,`GhosttyGridRef`,`size`,i);let o=this.runtime.call(`ghostty_terminal_grid_ref`,this.terminal,r,a);return this.runtime.free(r,this.runtime.layout(`GhosttyPoint`).size),o!==0&&(this.runtime.free(a,i),this.runtime.check(`ghostty_terminal_grid_ref`,o)),a}selectAt(e,t,n){let r=this.gridRef(n.x,n.y,2),i=this.runtime.layout(e),a=this.runtime.layout(`GhosttySelection`),o=this.runtime.alloc(i.size),s=this.runtime.alloc(a.size);this.runtime.setField(o,e,`size`,i.size);let c=this.runtime.field(e,`ref`);this.runtime.bytes(o+c.offset,c.size).set(this.runtime.bytes(r,c.size)),this.runtime.setField(s,`GhosttySelection`,`size`,a.size);let l=null;if(this.runtime.call(t,this.terminal,o,s)===0){let e=this.pointFromGridRef(s+this.runtime.field(`GhosttySelection`,`start`).offset,2),t=this.pointFromGridRef(s+this.runtime.field(`GhosttySelection`,`end`).offset,2);e&&t&&(l={start:e,end:t})}return this.runtime.free(s,a.size),this.runtime.free(r,this.runtime.layout(`GhosttyGridRef`).size),this.runtime.free(o,i.size),l}pointFromGridRef(e,t){let n=this.runtime.layout(`GhosttyPointCoordinate`),r=this.runtime.alloc(n.size),i=this.runtime.call(`ghostty_terminal_point_from_grid_ref`,this.terminal,e,t,r)===0?{x:this.runtime.readField(r,`GhosttyPointCoordinate`,`x`),y:this.runtime.readField(r,`GhosttyPointCoordinate`,`y`)}:null;return this.runtime.free(r,n.size),i}flag(e,t){return this.runtime.flag(e,this.terminal,t)}terminalColor(e){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.check(`ghostty_terminal_get`,this.runtime.call(`ghostty_terminal_get`,this.terminal,e,this.scratch)),N1(this.runtime,this.scratch)}};function W1(e,t){let n=[],r=e.toLowerCase(),i=t.toLowerCase(),a=r.indexOf(i);for(;a!==-1;)n.push(a),a=r.indexOf(i,a+i.length);return n}var G1=class{core;redraw;listeners=new Set;query=``;matches=[];activeMatch=-1;stale=!1;timer=null;constructor(e,t){this.core=e,this.redraw=t}find(e,t,n,r){let i=this.matches[this.activeMatch]??null;if(this.query=e,this.refresh(),this.matches.length===0)this.activeMatch=-1;else if(n||i===null){let e=i?.row??r,t=this.matches.findIndex(t=>t.row>=e);this.activeMatch=t===-1?this.matches.length-1:t}else{let e=this.matches.findIndex(e=>e.row===i.row&&e.index===i.index),n=e===-1?0:e,r=t?-1:1;this.activeMatch=(n+r+this.matches.length)%this.matches.length}return this.emit(),this.matches[this.activeMatch]??null}onResults(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}clear(){this.query=``,this.matches=[],this.activeMatch=-1}outputChanged(){this.query!==``&&(this.stale=!0,this.timer===null&&(this.timer=window.setTimeout(()=>{if(this.timer=null,!this.stale||this.query===``)return;let e=this.matches[this.activeMatch];this.refresh();let t=e?this.matches.findIndex(t=>t.row===e.row&&t.index===e.index):-1;this.activeMatch=t===-1?this.matches.length-1:t,this.emit(),this.redraw()},200)))}highlights(e,t){if(this.query===``)return[];let n=this.matches[this.activeMatch],r=[];return e.rowData.forEach((e,i)=>{let a=F1(e,i);W1(a.text,this.query).forEach((e,o)=>{let s=a.points[e],c=a.points[e+this.query.length-1];s&&c&&r.push({row:i,start:s.x,end:c.x+1,active:n?.row===t+i&&n.index===o})})}),r}dispose(){this.timer!==null&&window.clearTimeout(this.timer),this.timer=null}refresh(){this.stale=!1,this.matches=[],this.query!==``&&this.core.screenText().split(`
|
|
111
|
+
`).map((n,r)=>(0,I.jsxs)(`div`,{className:P(`px-2 whitespace-pre-wrap`,e.added&&`bg-diff-addition/10 text-diff-addition`,e.removed&&`bg-diff-deletion/10 text-diff-deletion`,!e.added&&!e.removed&&`text-muted-foreground`),children:[e.added?`+`:e.removed?`-`:` `,` `,n]},`${t}:${r}`)))})}function tL(e){return typeof e==`string`?e:``}function nL(e,t){return e.startsWith(t+`/`)?e.slice(t.length+1):e}var rL=`(Recommended)`;function iL(e){let t=e.options.map(e=>e.label).filter(e=>e.endsWith(rL));return e.multiSelect?t:t.slice(0,1)}function aL(e){return(0,I.jsxs)(`span`,{className:P(`mt-0.5 grid size-4 shrink-0 place-items-center border transition-colors`,e.multi?`rounded`:`rounded-full`,e.selected&&`border-primary bg-primary text-primary-foreground`,e.suggested&&`border-primary border-dashed`,!e.selected&&!e.suggested&&`border-muted-foreground/40`),children:[e.selected&&e.multi&&(0,I.jsx)(w,{icon:qg,strokeWidth:3,className:`size-3`}),e.selected&&!e.multi&&(0,I.jsx)(`span`,{className:`bg-primary-foreground size-1.5 rounded-full`})]})}function oL(e){let[t,n]=(0,F.useState)(Date.now);(0,F.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.ceil((e.at-t)/1e3));return(0,I.jsxs)(`span`,{className:`text-muted-foreground text-2xs mr-1 tabular-nums`,children:[e.label,` in`,` `,r<60?`${r}s`:`${Math.ceil(r/60)}m`]})}var $ie=`composer-glass relative mx-auto -mb-[calc(1rem+1px)] w-[calc(100%-2.75rem)] rounded-t-2xl border border-b-0 px-1 pt-1 pb-[calc(1rem+1px+0.25rem)] text-xs/4`;function eae(e){let t=e.request;if(t.kind===`question`)return(0,I.jsx)(tae,{machine:e.machine,request:t,draft:e.draft});let n=t.kind===`plan`,r=n?``:Xie(t.item,e.cwd);return(0,I.jsx)(`div`,{className:P($ie,`border-warning/28 bg-linear-to-b from-warning/8 to-warning/8`),children:(0,I.jsxs)(`div`,{className:`grid grid-cols-[1.5rem_minmax(0,1fr)_auto] items-start gap-x-2 gap-y-3 px-1 py-1`,children:[(0,I.jsx)(`span`,{className:`text-warning flex justify-center pt-0.5`,children:(0,I.jsx)(w,{icon:K_,className:`size-4`})}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,I.jsxs)(`span`,{className:`text-muted-foreground text-2xs flex w-full min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-warning shrink-0 font-medium`,children:n?`Ready to code?`:t.title}),e.count>1&&(0,I.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums`,children:[`1/`,e.count]})]}),r!==``&&(0,I.jsx)(`span`,{className:`text-foreground block max-h-20 w-full min-w-0 overflow-auto font-mono text-xs whitespace-pre`,children:r})]}),(0,I.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[t.autoResolve!==void 0&&(0,I.jsx)(oL,{label:t.autoResolve.decision===`allow`?`Approve`:`Decline`,at:t.autoResolve.at}),(0,I.jsx)(x,{size:`xs`,variant:`outline`,onClick:()=>ZC(t.id,`deny`,null),children:n?`Keep planning`:`Decline`}),t.kind===`approval`&&t.canAlwaysAllow&&(0,I.jsx)(x,{size:`xs`,variant:`outline`,onClick:()=>ZC(t.id,`always`,null),children:`Always`}),(0,I.jsx)(x,{size:`xs`,onClick:()=>ZC(t.id,`allow`,null),children:n?`Approve plan`:`Approve`})]}),n&&(0,I.jsx)(`div`,{className:`col-span-3 max-h-60 overflow-auto px-1 empty:hidden`,children:(0,I.jsx)(kI,{text:t.plan})}),t.kind===`approval`&&t.item.kind!==`command`&&(0,I.jsx)(`div`,{className:`col-span-3 max-h-60 overflow-auto px-1 empty:hidden`,children:(0,I.jsx)(ZI,{item:t.item})})]})})}function tae(e){let t=e.request.questions,[n,r]=(0,F.useState)(0),[i,a]=(0,F.useState)({}),[o,s]=(0,F.useState)({}),c=Object.fromEntries(t.map(e=>[e.question,[...i[e.question]??[],o[e.question]?.trim()??``].filter(e=>e!==``)])),l=Object.fromEntries(t.map(e=>[e.question,(c[e.question].length>0?c[e.question]:iL(e)).join(`, `)])),u=t[n],d=t.flatMap((e,t)=>c[e.question].length===0?[t]:[]),f=d.find(e=>e>n)??d[0];function p(e,c){let l=i[e.question]??[];e.multiSelect?a({...i,[e.question]:l.includes(c)?l.filter(e=>e!==c):[...l,c]}):(a({...i,[e.question]:[c]}),s({...o,[e.question]:``}),n<t.length-1&&r(n+1))}function m(e,t){s({...o,[e.question]:t}),!e.multiSelect&&t.trim()!==``&&a({...i,[e.question]:[]})}async function h(t,n){let r=sw(Z().items,[e.draft,...Object.values(o)]);for(let i of n)try{let n=await NC(e.machine,i),o=n;i.type.startsWith(`image/`)&&(r+=1,o=`[Image #${r}] (saved at ${n})`),s(e=>{let n=e[t.question]??``;return{...e,[t.question]:`${n}${/(^|\s)$/.test(n)?``:` `}${o}`}}),t.multiSelect||a(e=>({...e,[t.question]:[]}))}catch(e){R9(e)}}return(0,I.jsx)(`div`,{className:`composer-glass shadow-composer relative z-10 rounded-3xl border border-(--composer-outline)`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 p-2.5`,children:[(0,I.jsxs)(`div`,{role:`tabpanel`,className:`flex min-w-0 flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-start gap-1.5 pt-1 pr-1 pl-1.5`,children:[(0,I.jsx)(`span`,{className:`bg-primary/18 text-primary grid size-6 shrink-0 place-items-center rounded-md`,children:(0,I.jsx)(w,{icon:xee,className:`size-4`})}),(0,I.jsx)(`p`,{className:`text-foreground min-w-0 flex-1 pt-0.5 text-[15px] leading-5 font-medium`,children:u.question}),(0,I.jsx)(x,{size:`icon-xs`,variant:`ghost`,"aria-label":`Skip questions`,title:`Skip questions`,onClick:()=>ZC(e.request.id,`deny`,null),children:(0,I.jsx)(w,{icon:re})})]}),(0,I.jsxs)(`div`,{role:u.multiSelect?`group`:`radiogroup`,"aria-label":u.question,className:`flex max-h-[min(18rem,32dvh)] flex-col gap-0.5 overflow-y-auto`,children:[u.options.map(e=>{let t=i[u.question]?.includes(e.label)===!0,n=c[u.question].length===0&&iL(u).includes(e.label),r=e.label.endsWith(rL);return(0,I.jsxs)(`button`,{role:u.multiSelect?`checkbox`:`radio`,"aria-checked":t,className:P(`flex cursor-pointer items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors`,t?`bg-muted/70`:`hover:bg-muted/40`),onClick:()=>p(u,e.label),children:[(0,I.jsx)(aL,{multi:u.multiSelect,selected:t,suggested:n}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:`text-foreground text-sm`,children:r?e.label.slice(0,-13).trim():e.label}),r&&(0,I.jsx)(`span`,{className:`text-muted-foreground/70 text-[11px]`,children:`Recommended`})]}),e.description!==``&&(0,I.jsx)(`span`,{className:`text-secondary-label mt-0.5 block text-xs leading-4`,children:e.description})]})]},e.label)}),(0,I.jsxs)(`label`,{className:P(`flex cursor-text items-start gap-2.5 rounded-lg px-2.5 py-2 transition-colors`,(o[u.question]??``).trim()===``?`focus-within:bg-muted/40 hover:bg-muted/40`:`bg-muted/70`),children:[(0,I.jsx)(aL,{multi:u.multiSelect,selected:(o[u.question]??``).trim()!==``,suggested:!1}),(0,I.jsx)(`textarea`,{value:o[u.question]??``,rows:1,onChange:e=>m(u,e.target.value),onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);if(t!==``){e.preventDefault(),document.execCommand(`insertText`,!1,t);return}let n=[...e.clipboardData.files];n.length!==0&&(e.preventDefault(),h(u,n))},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),h(u,[...e.dataTransfer.files])},placeholder:`Something else…`,className:`placeholder:text-placeholder/75 [field-sizing:content] max-h-40 min-w-0 flex-1 resize-none bg-transparent text-sm leading-5 outline-none`})]})]})]},u.question),(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t.length>1&&(0,I.jsx)(`div`,{role:`tablist`,className:`flex min-w-0 [scrollbar-width:none] gap-1 overflow-x-auto`,children:t.map((e,t)=>(0,I.jsxs)(`button`,{role:`tab`,"aria-selected":t===n,className:P(`flex h-6 shrink-0 cursor-pointer items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,t===n?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`),onClick:()=>r(t),children:[c[e.question].length>0&&(0,I.jsx)(w,{icon:Jg,"aria-label":`Answered`,className:`text-success size-3.5`}),c[e.question].length===0&&l[e.question]!==``&&(0,I.jsx)(w,{icon:e_,"aria-label":`Using the recommended answer`,className:`text-primary size-3.5`}),l[e.question]===``&&(0,I.jsx)(w,{icon:oee,"aria-label":`Not answered`,className:`text-muted-foreground size-3.5`}),e.header]},e.question))}),(0,I.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5 pr-1`,children:[e.request.autoResolve!==void 0&&(0,I.jsx)(oL,{label:`Skip`,at:e.request.autoResolve.at}),(0,I.jsx)(x,{size:`xs`,variant:`outline`,onClick:()=>ZC(e.request.id,`allow`,{}),children:`Skip`}),(0,I.jsx)(x,{size:`xs`,variant:f===void 0?`default`:`outline`,onClick:()=>ZC(e.request.id,`allow`,Object.fromEntries(t.flatMap(e=>c[e.question].length===0?[]:[[e.question,c[e.question].join(`, `)]]))),children:`Submit`}),f!==void 0&&(0,I.jsx)(x,{size:`xs`,onClick:()=>{c[u.question].length===0&&a({...i,[u.question]:iL(u)}),r(f)},children:`Next`})]})]})]})})}function sL({...e}){return(0,I.jsx)(Fx,{"data-slot":`popover`,...e})}function cL({...e}){return(0,I.jsx)(Lx,{"data-slot":`popover-trigger`,...e})}function lL({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,I.jsx)(Vx,{children:(0,I.jsx)(Ux,{"data-slot":`popover-content`,sideOffset:n,align:t,className:P(`z-50 origin-(--radix-popover-content-transform-origin) overflow-hidden rounded-lg dropdown-glass text-popover-foreground shadow-[0_16px_40px_-18px_rgb(0_0_0/55%)] outline-none dark:shadow-[0_18px_44px_-18px_rgb(0_0_0/80%)] duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}var uL=`relative inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap rounded-(--control-radius) border border-transparent outline-none hover:bg-accent data-[state=open]:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-64 [&_svg]:pointer-events-none [&_svg]:shrink-0`,dL=`h-7 gap-1.5 px-1.5 text-sm sm:px-2.5 font-medium text-secondary-label hover:text-foreground [&_svg:not([class*=text-])]:text-muted-foreground [&_svg:not([class*=size-])]:size-4`;function nae(){let e=Q(e=>e.settings),t=Q(e=>e.capabilities)?.models.find(t=>t.value===e.model);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(rae,{}),(0,I.jsx)(`span`,{className:`bg-border mx-0.5 hidden h-4 w-px shrink-0 sm:block`}),t!==void 0&&t.efforts.length>0&&(0,I.jsx)(iae,{title:`Effort`,trigger:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(w,{icon:Bg}),(0,I.jsx)(`span`,{className:`capitalize`,children:e.effort??`Default`})]}),value:e.effort??`default`,options:[...e.provider===`opencode`?[{value:`default`,label:`Default`}]:[],...t.efforts.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))],onChange:e=>J9({effort:e==="default"?null:e})})]})}function rae(){let e=Q(e=>e.settings),t=Q(e=>e.selection),n=Q(e=>e.machines.find(t=>t.id===e.selection?.machine)),r=[...[...n?.claudeAccounts??[],...n?.codexAccounts??[]].filter(e=>e.valid).map(e=>({key:e.id,provider:e.provider,accountId:e.id,name:e.name,color:e.color,plan:e.plan,error:e.error})),...n?.openCode.available===!0?[{key:`opencode`,provider:`opencode`,accountId:null,name:`OpenCode`,color:null,plan:null,error:null}]:[]].filter(n=>t?.sessionId===null||n.provider===e.provider),i=e.provider===`opencode`?`opencode`:e.accountId,a=Q(e=>e.capabilities),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(i),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)({}),m=(0,F.useRef)(null),h=a?.models.find(t=>t.value===e.model)?.name??e.model??`Choose a model`,g=r.find(e=>e.key===i),_=c===null?[]:c===i?a?.models??null:f[c]??null,v=r.find(e=>e.key===c)?.provider,y=(_??[]).filter(e=>!e.hidden),b=y.length>=5,x=b?u.trim().toLowerCase():``,S=y.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(x));function C(e){if(s(e),e&&(l(i),d(``),t!==null))for(let e of r)e.key!==i&&e.error===null&&L(t.machine,`capabilities`,{provider:e.provider,accountId:e.accountId,projectId:t.projectId}).then(t=>p(n=>({...n,[e.key]:t.models})),R9)}function T(n,i){let a=r.find(e=>e.key===n);if(a===void 0||t===null)return;let o=a.provider,s={accountId:a.accountId,model:i.value,...i.effort===null?{}:{effort:i.effort}};o===e.provider?J9(s):J9({...q9(T9(Z(),t.machine).composer,o),...s})}return(0,I.jsxs)(sL,{open:o,onOpenChange:C,children:[(0,I.jsx)(cL,{asChild:!0,children:(0,I.jsxs)(`button`,{className:P(uL,dL),title:g===void 0?`Model`:`${g.name} · ${h}`,children:[(0,I.jsxs)(`span`,{className:`relative`,children:[(0,I.jsx)(zv,{provider:e.provider,className:`size-4`}),r.filter(t=>t.provider===e.provider).length>1&&g!==void 0&&(0,I.jsx)(`span`,{className:P(`pointer-events-none absolute -right-1 -bottom-1 flex h-3 min-w-3 items-center justify-center rounded-full border px-0.5 text-[8px] leading-none font-semibold shadow-sm`,g.color===null?`bg-card text-muted-foreground`:`border-card text-white`),style:g.color===null?void 0:{backgroundColor:g.color},children:g.name.charAt(0).toUpperCase()})]}),(0,I.jsx)(`span`,{className:`max-w-40 truncate`,children:h})]})}),(0,I.jsxs)(lL,{side:`top`,className:`flex max-h-86.5 w-screen max-w-90 flex-row`,onOpenAutoFocus:e=>{e.preventDefault(),m.current?.focus()},onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-composer]`)?.focus()},children:[r.length>1&&(0,I.jsxs)(`div`,{className:`bg-muted/30 flex w-11 shrink-0 [scrollbar-width:none] flex-col gap-1 overflow-y-auto p-1`,children:[r.map(t=>(0,I.jsxs)(`div`,{className:`relative w-full`,children:[t.key===c&&(0,I.jsx)(`div`,{className:`bg-primary pointer-events-none absolute top-1/2 -right-1 z-10 h-5 w-0.75 -translate-y-1/2 rounded-l-full`}),(0,I.jsx)(M,{side:`left`,label:t.error===null?[t.name,t.plan].filter(e=>e!==null).join(` · `):`${t.name} — ${t.error}`,children:(0,I.jsxs)(`button`,{className:P(`hover:bg-foreground/10 focus-visible:bg-foreground/10 relative flex aspect-square w-full cursor-pointer items-center justify-center rounded-md transition-colors focus-visible:outline-none`,t.error!==null&&`cursor-not-allowed opacity-50 hover:bg-transparent`),"aria-label":t.name,"aria-pressed":t.key===c,"aria-disabled":t.error!==null,onClick:()=>{if(t.error!==null)return;let n=f[t.key]?.find(t=>t.value===e.model);t.key!==i&&i!==null&&a!==null&&n!==void 0&&(p(e=>({...e,[i]:a.models})),T(t.key,n)),l(t.key)},children:[(0,I.jsx)(zv,{provider:t.provider,className:`size-5`}),r.filter(e=>e.provider===t.provider).length>1&&(0,I.jsx)(`span`,{className:P(`text-3xs pointer-events-none absolute right-0.5 bottom-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full border px-0.5 leading-none font-semibold shadow-sm`,t.color===null?`bg-card text-muted-foreground`:`border-card text-white`),style:t.color===null?void 0:{backgroundColor:t.color},children:t.name.charAt(0).toUpperCase()})]})})]},t.key)),(0,I.jsx)(M,{side:`left`,label:`Manage accounts`,children:(0,I.jsx)(`button`,{className:`text-muted-foreground hover:bg-foreground/10 hover:text-foreground focus-visible:bg-foreground/10 mt-auto flex aspect-square w-full shrink-0 cursor-pointer items-center justify-center rounded-md transition-colors focus-visible:outline-none`,"aria-label":`Manage accounts`,onClick:()=>{s(!1),I9(C9[e.provider])},children:(0,I.jsx)(w,{icon:Ree,className:`size-4.5`})})})]}),(0,I.jsxs)(`div`,{className:P(`bg-muted/40 flex min-h-0 min-w-0 flex-1 flex-col`,r.length>1&&`border-border/70 border-l`),children:[b&&(0,I.jsx)(`div`,{className:`shrink-0 px-3 pt-2.5`,children:(0,I.jsxs)(`div`,{className:`border-border/70 focus-within:border-ring relative border-b pb-1.5 transition-colors`,children:[(0,I.jsx)(w,{icon:H_,className:`text-muted-foreground/55 pointer-events-none absolute top-1.5 left-0 size-4`}),(0,I.jsx)(`input`,{ref:m,value:u,placeholder:`Search models...`,className:`placeholder:text-muted-foreground/70 h-6.5 w-full bg-transparent ps-5 text-sm outline-none`,onChange:e=>d(e.target.value),onKeyDown:e=>{if(e.key!==`Enter`||c===null)return;let t=S.at(0);t!==void 0&&(e.preventDefault(),T(c,t),s(!1))}})]})}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 py-1.5`,children:S.length===0?(0,I.jsx)(`p`,{className:`text-muted-foreground p-2 text-center text-sm`,children:_===null?`Loading models…`:`No models found`}):S.map(t=>(0,I.jsx)(`button`,{className:P(`hover:bg-accent hover:text-accent-foreground mb-0.5 flex min-h-8 w-full cursor-pointer flex-col justify-center rounded-sm px-2 py-1.5 text-left`,c===i&&t.value===e.model&&`text-foreground bg-foreground/[0.08]`),onClick:()=>{c!==null&&(T(c,t),s(!1))},children:(0,I.jsxs)(`span`,{className:`truncate text-sm leading-snug font-medium`,children:[t.name,v===`opencode`&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-2 text-xs font-normal`,children:t.description})]})},t.value))})]})]})]})}function iae(e){return(0,I.jsxs)(yC,{children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsx)(`button`,{className:P(uL,dL),title:e.title,children:e.trigger})}),(0,I.jsxs)(SC,{className:`w-72`,side:`top`,align:`start`,onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-composer]`)?.focus()},children:[(0,I.jsx)(DC,{children:e.title}),(0,I.jsx)(TC,{value:e.value,onValueChange:e.onChange,children:e.options.map(e=>(0,I.jsx)(EC,{value:e.value,children:e.label},e.value))})]})]})}function aae(e){let t=Q(e=>e.selection?.sessionId),n=Q(t=>E9(t,e.machine,e.projectId)),r=Q(e=>e.projects),i=Q(e=>e.machines);return(0,I.jsx)(`div`,{className:`absolute inset-x-0 bottom-full pb-4`,children:(0,I.jsxs)(`h1`,{className:`text-foreground w-full text-center text-2xl font-normal tracking-tight sm:text-3xl`,children:[`What should we build in`,` `,t===null?(0,I.jsxs)(yC,{children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`border-muted-foreground/35 hover:border-foreground/60 inline-flex max-w-64 cursor-pointer border-b border-dotted align-bottom outline-none`,title:n?.path,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:n?.name}),`?`]})}),(0,I.jsx)(SC,{className:`max-h-80 w-64`,onCloseAutoFocus:t=>{t.preventDefault(),e.onCloseMenu()},children:(0,I.jsx)(TC,{value:f9(e.machine,e.projectId),children:[...r].sort((e,t)=>i.findIndex(t=>t.id===e.machine)-i.findIndex(e=>e.id===t.machine)||e.name.localeCompare(t.name)).map(e=>(0,I.jsxs)(EC,{value:f9(e.machine,e.id),title:e.path,onSelect:()=>WC({machine:e.machine,projectId:e.id,sessionId:null}),children:[(0,I.jsx)(Lv,{machine:e.machine,projectId:e.id,className:`size-4 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.name,i.length>1&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-1.5 text-xs`,children:i.find(t=>t.id===e.machine)?.name})]})]},f9(e.machine,e.id)))})})]}):(0,I.jsx)(`span`,{className:`border-muted-foreground/35 inline-block max-w-64 truncate border-b border-dotted align-bottom`,title:n?.path,children:n?.name}),t!==null&&`?`]})})}function oae(){let e=Q(e=>e.queue);return(0,I.jsx)(`div`,{className:`composer-glass relative mx-auto -mb-[calc(1rem+1px)] w-[calc(100%-2.75rem)] rounded-t-2xl border border-b-0 border-(--composer-outline) px-1 pt-1 pb-[calc(1rem+1px+0.25rem)] text-xs/4`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`grid min-h-6 grid-cols-[1.5rem_minmax(0,1fr)_auto_auto] items-center gap-x-1`,children:[(0,I.jsx)(w,{icon:vee,className:`text-muted-foreground mx-auto size-3`}),(0,I.jsx)(`span`,{className:`text-secondary-label truncate`,children:e.prompt.text===``?`${e.prompt.images.length} image(s)`:e.prompt.text}),(0,I.jsx)(x,{variant:`ghost-muted`,size:`icon-xs`,title:`Send now`,onClick:()=>JC(e.id),children:(0,I.jsx)(w,{icon:Rg})}),(0,I.jsx)(x,{variant:`ghost-muted`,size:`icon-xs`,title:`Remove from queue`,onClick:()=>qC(e.id),children:(0,I.jsx)(w,{icon:re})})]},e.id))})}function sae(e){return(0,I.jsxs)(I.Fragment,{children:[e.running&&e.empty&&(0,I.jsx)(`button`,{className:`bg-destructive/90 shadow-destructive/24 hover:bg-destructive flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-full text-white shadow-xs transition-colors`,title:`Stop (Esc)`,"aria-label":`Stop generation`,onClick:e.onStop,children:(0,I.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,I.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})}),!(e.running&&e.empty)&&(0,I.jsx)(`button`,{className:`bg-message-action text-message-action-foreground shadow-message-action/24 hover:bg-message-action-hover relative flex size-9 items-center justify-center overflow-hidden rounded-full shadow-xs transition-all duration-150 hover:scale-105 enabled:cursor-pointer disabled:pointer-events-none disabled:opacity-64 disabled:shadow-none`,title:e.running&&e.delivery===`steer`?`Send now (Enter) · Queue (${Te}+Enter)`:e.running?`Queue (Enter) · Send now (${Te}+Enter)`:`Send (Enter)`,"aria-label":`Send message`,disabled:e.empty,onClick:t=>e.onSubmit(t.metaKey||t.ctrlKey),children:(0,I.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`M7 11.5V2.5M7 2.5L3 6.5M7 2.5L11 6.5`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})})]})}var cae=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],lae=5242880,fL=window.matchMedia(`(pointer: coarse)`);function pL(){let e=Q(e=>e.selection),t=Q(e=>e.loaded),n=Q(e=>e.items.length===0&&e.partial===``),r=Q(e=>e.requests),i=Q(e=>e.queue),a=Q(e=>e.draft),o=Q(e=>e.capabilities),s=Q(e=>e.settings.provider===`opencode`?e.machines.find(t=>t.id===e.selection?.machine)?.openCode.available!==!0:e.settings.accountId===null),[c,l]=(0,F.useState)(0),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(0),[m,h]=(0,F.useState)(!1),[g,_]=(0,F.useState)([]),v=(0,F.useRef)(null),y=(0,F.useRef)(null),b=e?.machine??``,S=e?.projectId??``,C=Q(e=>E9(e,b,S)),T=Q(e=>T9(e,b).status),E=Q(e=>T9(e,b).config?.delivery??null),D=f9(b,e?.sessionId??S),O=zs(D),k=O.text,A=O.images,[ee,j]=(0,F.useState)(k.length),M=Q(j9),te=t&&n&&!M,ne=r.at(0);(0,F.useEffect)(()=>{let e=v.current;e===null||fL.matches||(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[e]),(0,F.useEffect)(()=>{if(a===null)return;let e=cw(a);Bs(D,t=>({...t,...e})),j(e.text.length),N9(null),v.current?.focus()},[a,D]),(0,F.useEffect)(()=>{T===`online`&&L(b,`files.list`,{projectId:S}).then(_,R9)},[b,S,T]);let re=k.slice(0,ee),ie=/^\/\S*$/.exec(re)?.[0]??/(?:^|\s)(@\S*)$/.exec(re)?.[1]??null,ae=ie?.slice(1).toLowerCase()??``,oe=ie===null||m?[]:ie.startsWith(`/`)?(o?.commands??[]).filter(e=>e.name.toLowerCase().includes(ae)).sort((e,t)=>Number(!e.name.toLowerCase().startsWith(ae))-Number(!t.name.toLowerCase().startsWith(ae))).map(e=>({key:e.name,label:`/${e.name}${e.hint===``?``:` ${e.hint}`}`,description:e.description,insert:`/${e.name}`})):g.filter(e=>e.toLowerCase().includes(ae)).slice(0,50).map(e=>({key:e,label:e,description:``,insert:`@${e}`})),se=Math.min(f,oe.length-1),ce=k.trim()===``&&A.length===0||c>0||u||s;function le(e,t){Bs(D,t=>({...t,text:e,images:t.images.filter(t=>e.includes(`[Image #${t.number}]`))})),j(t),p(0),h(!1)}function ue(e){if(ie===null)return;let t=ee-ie.length,n=t+e.insert.length+1;le(`${k.slice(0,t)}${e.insert} ${k.slice(ee)}`,n),requestAnimationFrame(()=>v.current?.setSelectionRange(n,n))}async function de(e){if(!ce){d(!0);try{if(E===null)throw Error(`This machine is not connected`);await KC({text:k.trim(),images:A.map(e=>({mediaType:e.mediaType,data:e.data}))},e?E===`queue`?`steer`:`queue`:E),Bs(D,e=>({...e,text:``,images:[]})),j(0)}catch(e){R9(e)}finally{d(!1)}}}async function fe(e){let t=ee,n=/(^|\s)$/.test(k.slice(0,ee))?``:` `;for(let r of e)if(cae.includes(r.type)&&r.size<=lae){let e=await PC(r),i=sw(Z().items,[Hs(D).text])+1,a={number:i,mediaType:r.type,data:e},o=t,s=`${n}[Image #${i}] `;n=``,Bs(D,e=>({...e,text:`${e.text.slice(0,o)}${s}${e.text.slice(o)}`,images:[...e.images,a]})),t+=s.length,j(t),requestAnimationFrame(()=>v.current?.setSelectionRange(t,t))}else{l(e=>e+1);try{let e=await NC(b,r);Bs(D,t=>({...t,text:`${t.text}${/(^|\s)$/.test(t.text)?``:` `}@${e} `}))}catch(e){R9(e)}finally{l(e=>e-1)}}}return(0,I.jsx)(`div`,{className:P(`pointer-events-none z-20`,te?`absolute inset-0 flex items-center pb-3 sm:pb-4`:`relative shrink-0 before:absolute before:right-(--app-scrollbar-width) before:bottom-full before:left-0 before:h-8 before:bg-linear-to-t before:from-background before:to-transparent`),children:(0,I.jsxs)(FC,{width:`composer`,className:`pointer-events-auto relative z-10`,children:[te&&(0,I.jsx)(aae,{machine:b,projectId:S,onCloseMenu:()=>v.current?.focus()}),i.length>0&&oe.length===0&&(0,I.jsx)(oae,{}),ne!==void 0&&oe.length===0&&(0,I.jsx)(eae,{request:ne,machine:b,cwd:C?.path??``,count:r.length,draft:k},ne.id),oe.length>0&&(0,I.jsx)(lw,{items:oe,active:se,onHover:p,onPick:ue}),(0,I.jsxs)(`div`,{className:P(`composer-glass shadow-composer relative z-10 border border-(--composer-outline) transition-[border-color,box-shadow] duration-300 ease-out focus-within:border-[color-mix(in_srgb,var(--text)_16%,transparent)] focus-within:ring-4 focus-within:ring-[color-mix(in_srgb,var(--text)_4%,transparent)] dark:shadow-none`,te?`rounded-3xl`:`rounded-t-3xl border-b-0`,ne?.kind===`question`&&`hidden`),onMouseDown:e=>{e.target instanceof Element&&e.currentTarget.contains(e.target)&&(e.target.closest(`button, a, input, textarea`)||(e.preventDefault(),v.current?.focus()))},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),fe([...e.dataTransfer.files])},children:[(0,I.jsxs)(`div`,{className:P(`pb-2`,A.length>0&&`pt-3.5 sm:pt-4`),children:[A.length>0&&(0,I.jsx)(ow,{draftKey:D}),(0,I.jsx)(`textarea`,{ref:v,"data-composer":!0,rows:1,spellCheck:!1,autoCorrect:`off`,"data-gramm":`false`,"data-gramm_editor":`false`,"data-enable-grammarly":`false`,"data-lt-active":`false`,value:k,onChange:e=>le(e.target.value,e.target.selectionStart),onSelect:e=>j(e.currentTarget.selectionStart),onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);if(t!==``){e.preventDefault(),document.execCommand(`insertText`,!1,t);return}let n=[...e.clipboardData.files];n.length!==0&&(e.preventDefault(),fe(n))},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(oe.length>0){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;p((se+t+oe.length)%oe.length);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),ue(oe[se]);return}if(e.key===`Escape`){e.preventDefault(),h(!0);return}}if(e.key===`Enter`&&!e.shiftKey&&!fL.matches)e.preventDefault(),de(e.metaKey||e.ctrlKey);else if(e.key===`ArrowUp`&&k===``){let t=uae(Z().items);if(t===null)return;e.preventDefault(),le(t,t.length)}else e.key===`Escape`&&M&&YC()}},placeholder:s?`Add an account in Settings to start`:M&&E===`steer`?`Steer the agent… (${Te}+Enter to queue)`:M?`Queue a follow-up… (${Te}+Enter to send now)`:`Ask anything, @tag files/folders, or / for commands`,className:P(`placeholder:text-placeholder/75 block [field-sizing:content] w-full resize-none bg-transparent px-3 text-sm leading-relaxed outline-none sm:px-4`,A.length>0?`max-h-52 min-h-19.5`:`max-h-55.5 min-h-20 pt-3.5 sm:max-h-56 sm:pt-4 [@media(min-height:840px)]:min-h-23 sm:[@media(min-height:840px)]:min-h-23.5`)})]}),(0,I.jsxs)(`div`,{className:P(`flex min-w-0 items-center justify-between gap-2 px-3 sm:px-4`,te?`pb-3 sm:pb-4`:`pb-2.5 sm:pb-3.5`),children:[(0,I.jsx)(`div`,{className:`-m-1 -ms-3.5 flex min-w-0 flex-1 [scrollbar-width:none] items-center gap-1 overflow-x-auto p-1 ps-2`,children:(0,I.jsx)(nae,{})}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[(0,I.jsx)(`input`,{ref:y,type:`file`,multiple:!0,hidden:!0,onChange:e=>{fe([...e.target.files??[]]),e.target.value=``}}),c>0&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Uploading…`}),(0,I.jsx)(yw,{empty:ce,delivery:E,onSubmit:()=>void de(!0)}),(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,title:`Attach files`,"aria-label":`Attach files`,onClick:()=>y.current?.click(),children:(0,I.jsx)(w,{icon:A_})}),(0,I.jsx)(sae,{running:M,empty:ce,delivery:E,onSubmit:e=>void de(e),onStop:YC})]})]})]})]})})}function uae(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.kind===`user`&&n.parent===null&&n.format===`text`&&n.text!==``)return n.text}return null}var dae=window.matchMedia(`(pointer: coarse)`);function fae(e){let[t,n]=(0,F.useState)(!1),r=gL(e.repo);return(0,I.jsxs)(sL,{open:t,onOpenChange:n,children:[(0,I.jsx)(cL,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`text-muted-foreground hover:text-foreground hidden max-w-48 cursor-pointer items-center gap-1 text-xs sm:flex`,title:`Switch or create a branch`,children:[(0,I.jsx)(w,{icon:r===null?b_:r.icon,className:`size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.repo.branch??`detached`})]})}),(0,I.jsx)(lL,{align:`end`,className:`flex max-h-86.5 w-72 flex-col`,children:(0,I.jsx)(mL,{target:e,onClose:()=>n(!1)})})]})}function pae(e){return(0,I.jsx)(_e,{open:!0,onOpenChange:e.onClose,children:(0,I.jsxs)(ae,{showCloseButton:!1,"aria-describedby":void 0,className:`flex max-h-[min(30rem,calc(100dvh-2rem))] flex-col gap-0 p-0`,onOpenAutoFocus:e=>{dae.matches&&e.preventDefault()},children:[(0,I.jsx)(pe,{className:`sr-only`,children:`Switch branch`}),(0,I.jsx)(mL,{target:e,onClose:e.onClose})]})})}function mL(e){let t=e.target,n=t.machine,r=t.projectId,i=t.repo.path,a=t.onRefresh,[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(!1),g=gL(t.repo),_=u.trim(),v=(o??[]).filter(e=>e.toLowerCase().includes(_.toLowerCase())),y=(c??[]).filter(e=>e.toLowerCase().includes(_.toLowerCase())),b=(o??[]).includes(_);(0,F.useEffect)(()=>{L(n,`git.localBranches`,{projectId:r,repo:i}).then(s,R9),L(n,`git.fetch`,{projectId:r}).then(a,R9)},[n,r,i,a]);async function x(){h(!0);try{await L(n,`git.sync`,{projectId:r,repo:i}),e.onClose()}catch(e){R9(e)}finally{h(!1),a()}}async function S(t,o){p(!0);try{await L(n,`git.switch`,{projectId:r,repo:i,branch:t,create:o}),e.onClose()}catch(e){R9(e)}finally{p(!1),a()}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`shrink-0 px-3 pt-2.5`,children:(0,I.jsxs)(`div`,{className:`border-border/70 focus-within:border-ring relative border-b pb-1.5 transition-colors`,children:[(0,I.jsx)(w,{icon:H_,className:`text-muted-foreground/55 pointer-events-none absolute top-1.5 left-0 size-4`}),(0,I.jsx)(`input`,{value:u,placeholder:`Search or create a branch...`,disabled:f,className:`placeholder:text-muted-foreground/70 h-6.5 w-full bg-transparent ps-5 text-sm outline-none`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_!==``&&o!==null&&(e.preventDefault(),S(_,!b))}})]})}),g!==null&&(0,I.jsx)(`div`,{className:`border-border/70 shrink-0 border-b px-2 py-1.5`,children:(0,I.jsxs)(`button`,{disabled:m||f,className:`hover:bg-accent hover:text-accent-foreground flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,onClick:()=>void x(),children:[(0,I.jsx)(w,{icon:m?e_:g.icon,className:P(`size-3.5 shrink-0`,m&&`animate-spin`)}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g.label}),(0,I.jsx)(hL,{behind:t.repo.behind,ahead:t.repo.ahead})]})}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 py-1.5`,children:[o===null&&(0,I.jsx)(`p`,{className:`text-muted-foreground p-2 text-center text-sm`,children:`Loading branches…`}),o!==null&&v.length===0&&_===``&&(0,I.jsx)(`p`,{className:`text-muted-foreground p-2 text-center text-sm`,children:`No branches`}),v.map(n=>(0,I.jsxs)(`button`,{disabled:f,className:P(`hover:bg-accent hover:text-accent-foreground mb-0.5 flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,n===t.repo.branch&&`text-foreground bg-foreground/[0.08]`),onClick:()=>{n===t.repo.branch?e.onClose():S(n,!1)},children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),n===t.repo.branch&&(0,I.jsx)(w,{icon:qg,strokeWidth:2.25,className:`size-3.5 shrink-0`})]},n)),c!==null&&y.length>0&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-2 pt-2 pb-1 text-xs font-medium`,children:`Remote`}),y.map(e=>(0,I.jsx)(`button`,{disabled:f,className:`hover:bg-accent hover:text-accent-foreground mb-0.5 flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,onClick:()=>void S(e.slice(e.indexOf(`/`)+1),!1),children:(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})},e)),o!==null&&_!==``&&!b&&(0,I.jsxs)(`button`,{disabled:f,className:`hover:bg-accent hover:text-accent-foreground flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm disabled:cursor-default disabled:opacity-50`,onClick:()=>void S(_,!0),children:[(0,I.jsx)(w,{icon:E,className:`size-3.5 shrink-0`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`Create branch `,(0,I.jsx)(`span`,{className:`font-medium`,children:_})]})]})]}),(0,I.jsx)(`div`,{className:`border-border/70 shrink-0 border-t px-2 py-1.5`,children:(0,I.jsxs)(`button`,{className:`text-muted-foreground hover:bg-accent hover:text-accent-foreground flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm`,onClick:()=>{c===null?L(n,`git.remoteBranches`,{projectId:r,repo:i}).then(l,R9):l(null)},children:[(0,I.jsx)(w,{icon:r_,className:`size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c===null?`Show remote branches`:`Hide remote branches`})]})})]})}function hL(e){return(0,I.jsxs)(I.Fragment,{children:[e.behind>0&&(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`↓`,e.behind]}),e.ahead>0&&(0,I.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`↑`,e.ahead]})]})}function gL(e){return e.branch===null||!e.remote?null:e.upstream===null?{icon:i_,label:`Publish branch`}:e.behind>0&&e.ahead>0?{icon:jg,label:`Pull and push`}:e.behind>0?{icon:Ng,label:`Pull commits`}:e.ahead>0?{icon:Rg,label:`Push commits`}:null}var mae={working:e_,done:$g,failed:kg},_L=new Set,vL=null,yL=0;function bL(e){vL=e;for(let e of _L)e();e?.state===`done`&&setTimeout(()=>{vL?.id===e.id&&bL(null)},5e3)}function hae(e){return _L.add(e),()=>{_L.delete(e)}}function xL(e,t){yL+=1,bL(`url`in t?{id:yL,state:`done`,label:e,error:``,url:t.url}:{id:yL,state:`failed`,label:e,error:t.error,url:null})}async function SL(e){yL+=1;let t=yL;bL({id:t,state:`working`,label:e.labels.working,error:``,url:null});try{let n=await e.task();vL?.id===t&&bL({id:t,state:`done`,label:e.labels.done,error:``,url:n})}catch(n){vL?.id===t&&bL({id:t,state:`failed`,label:e.labels.failed,error:Oe(n),url:null})}finally{e.onRefresh()}}function CL(e,t,n,r){SL({labels:r?{working:`Committing and pushing…`,done:`Committed and pushed`,failed:`Commit and push failed`}:{working:`Committing…`,done:`Committed`,failed:`Commit failed`},task:async()=>(await L(e.machine,`git.commit`,{projectId:e.projectId,repo:t,message:n,push:r}),null),onRefresh:e.onRefresh})}function gae(e,t,n){SL({labels:{working:`Creating pull request…`,done:`Pull request created`,failed:`Couldn't create pull request`},task:async()=>(await L(e.machine,`git.createPullRequest`,{projectId:e.projectId,repo:t,base:n.base,head:n.head,title:n.title,body:n.body})).url,onRefresh:e.onRefresh})}function _ae(){let e=(0,F.useSyncExternalStore)(hae,()=>vL),[t,n]=(0,F.useState)(!1);return e===null?null:(0,I.jsxs)(`div`,{className:`bg-popover text-popover-foreground flex max-w-80 items-center gap-3 rounded-md border py-2 pr-2 pl-3 shadow-md`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,I.jsx)(w,{icon:mae[e.state],className:P(`size-4 shrink-0`,e.state===`working`&&`animate-spin`,e.state===`done`&&`text-success`,e.state===`failed`&&`text-destructive`)}),(0,I.jsx)(`span`,{className:`truncate`,children:e.label})]}),e.url!==null&&(0,I.jsx)(x,{asChild:!0,size:`xs`,variant:`outline`,children:(0,I.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open`})}),e.state===`failed`&&(0,I.jsx)(x,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>n(!0),children:`View`}),(0,I.jsx)(x,{type:`button`,size:`icon-micro`,variant:`ghost-muted`,"aria-label":`Dismiss`,onClick:()=>{n(!1),bL(null)},children:(0,I.jsx)(w,{icon:re,className:`size-3.5`})}),(0,I.jsx)(_e,{open:t&&e.state===`failed`,onOpenChange:n,children:(0,I.jsxs)(ae,{className:`sm:max-w-lg`,children:[(0,I.jsx)(se,{children:(0,I.jsx)(pe,{children:e.label})}),(0,I.jsx)(`pre`,{className:`bg-muted/50 max-h-[60vh] overflow-y-auto rounded-lg border p-3 font-mono text-xs break-words whitespace-pre-wrap`,children:e.error})]})})]})}function wL({className:e,type:t,...n}){return(0,I.jsx)(`input`,{type:t,"data-slot":`input`,className:P(`h-9 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-[color,background-color,border-color,box-shadow] duration-200 ease-out outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/33 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function TL({...e}){return(0,I.jsx)(mS,{"data-slot":`select`,...e})}function EL({...e}){return(0,I.jsx)(vS,{"data-slot":`select-value`,...e})}function DL({className:e,size:t=`default`,children:n,...r}){return(0,I.jsxs)(gS,{"data-slot":`select-trigger`,"data-size":t,className:P(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-[color,background-color,border-color,box-shadow] duration-200 ease-out outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/33 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,I.jsx)(yS,{asChild:!0,children:(0,I.jsx)(w,{icon:Q_,className:`text-muted-foreground pointer-events-none size-4`})})]})}function OL({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,I.jsx)(SS,{children:(0,I.jsxs)(wS,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:P(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,I.jsx)(vae,{}),(0,I.jsx)(IS,{"data-position":n,className:P(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,I.jsx)(yae,{})]})})}function kL({className:e,children:t,...n}){return(0,I.jsxs)(BS,{"data-slot":`select-item`,className:P(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,I.jsx)(WS,{children:(0,I.jsx)(w,{icon:qg,className:`pointer-events-none`})})}),(0,I.jsx)(HS,{children:t})]})}function vae({className:e,...t}){return(0,I.jsx)(KS,{"data-slot":`select-scroll-up-button`,className:P(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(w,{icon:Zg})})}function yae({className:e,...t}){return(0,I.jsx)(JS,{"data-slot":`select-scroll-down-button`,className:P(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(w,{icon:Yg})})}function AL(e){return e.target?.kind===`failed`?(0,I.jsx)(`span`,{className:`text-destructive truncate text-xs`,children:e.target.text}):(0,I.jsxs)(`span`,{className:`text-muted-foreground flex min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsxs)(`span`,{className:`truncate`,children:[e.head,` →`]}),(0,I.jsxs)(TL,{value:e.target?.base??``,disabled:e.target===void 0,onValueChange:e.onBase,children:[(0,I.jsx)(DL,{size:`sm`,className:`max-w-48`,children:(0,I.jsx)(EL,{placeholder:`Loading branches…`})}),(0,I.jsx)(OL,{children:(e.target?.branches??[]).map(e=>(0,I.jsx)(kL,{value:e,children:e},e))})]})]})}function bae(e){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 ps-6`,children:[(0,I.jsxs)(`span`,{className:`text-muted-foreground truncate text-xs`,children:[e.draft.head,` → `,e.draft.base]}),(0,I.jsx)(wL,{value:e.draft.title,onChange:t=>e.onChange({...e.draft,title:t.target.value})}),(0,I.jsx)(`textarea`,{value:e.draft.body,onChange:t=>e.onChange({...e.draft,body:t.target.value}),rows:8,className:`bg-background focus-visible:border-ring focus-visible:ring-ring/33 w-full resize-y rounded-lg border px-3 py-2 font-mono text-xs transition-[border-color,box-shadow] duration-200 ease-out outline-none focus-visible:ring-3`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[e.onSkip!==null&&(0,I.jsx)(x,{variant:`ghost`,size:`sm`,onClick:e.onSkip,children:`Skip`}),(0,I.jsx)(x,{variant:`outline`,size:`sm`,onClick:e.onRegenerate,children:`Regenerate`}),(0,I.jsx)(x,{size:`sm`,disabled:e.draft.title.trim()===``,onClick:e.onCreate,children:`Create PR`})]})]})}var xae={working:e_,review:t_,done:$g,failed:kg,skipped:Cee};function Sae(e){let t=Q(t=>E9(t,e.machine,e.projectId)?.name)??``,[n]=(0,F.useState)(()=>jL(e.repos,e.action)),[r,i]=(0,F.useState)(()=>n.map(e=>e.path)),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)({}),[l,u]=(0,F.useState)(null),d=n.filter(e=>r.includes(e.path)&&s[e.path]?.kind!==`failed`),f=e.action===`pullRequest`&&d.some(e=>s[e.path]===void 0),p=d.filter(e=>e.changed>0);(0,F.useEffect)(()=>{if(e.action===`pullRequest`)for(let t of n)L(e.machine,`git.branches`,{projectId:e.projectId,repo:t.path}).then(e=>c(n=>({...n,[t.path]:{kind:`ready`,...e}})),e=>c(n=>({...n,[t.path]:{kind:`failed`,text:Oe(e)}})))},[e.machine,e.projectId,e.action,n]);function m(e,t){u(n=>n?.map(n=>n.path===e?{...n,...t}:n)??null)}async function h(t,r){try{await r()}catch(r){if(n.length===1){e.onClose(),xL(`Pull request failed`,{error:Oe(r)});return}m(t,{state:`failed`,text:Oe(r),draft:null})}finally{e.onRefresh()}}function g(e,t){c(n=>{let r=n[e];return r?.kind===`ready`?{...n,[e]:{...r,base:t}}:n})}function _(e,t){u(d.map(t=>({path:t.path,state:`working`,text:e,url:null,draft:null})));for(let e of d)h(e.path,()=>t(e.path))}function v(t){if(n.length===1){e.onClose(),CL(e,n[0].path,a,t);return}let r=t?`Committed and pushed`:`Committed`;_(t?`Committing and pushing…`:`Committing…`,async n=>{await L(e.machine,`git.commit`,{projectId:e.projectId,repo:n,message:a,push:t}),m(n,{state:`done`,text:r})})}function y(){_(`Pushing…`,async t=>{await L(e.machine,`git.push`,{projectId:e.projectId,repo:t}),m(t,{state:`done`,text:`Pushed`})})}async function b(t,r,i){m(t,{state:`working`,text:r?`Committing local changes and writing pull request…`:`Writing pull request…`,draft:null});let a=await L(e.machine,`git.pullRequest`,{projectId:e.projectId,repo:t,base:i,commit:r});if(a.kind===`open`){if(n.length===1){e.onClose(),xL(`Pull request already open`,{url:a.url});return}m(t,{state:`done`,text:`A pull request is already open`,url:a.url})}else m(t,{state:`review`,text:`Review and create`,draft:{base:a.base,head:a.head,title:a.title,body:a.body}})}function S(e){_(`Starting…`,async t=>{let n=s[t];if(n?.kind!==`ready`)throw Error(`The branches are not loaded`);await b(t,e&&p.some(e=>e.path===t),n.base)})}function C(t,r){n.length===1?(e.onClose(),gae(e,t,r)):h(t,async()=>{m(t,{state:`working`,text:`Creating pull request…`,draft:null}),m(t,{state:`done`,text:`Created pull request`,url:(await L(e.machine,`git.createPullRequest`,{projectId:e.projectId,repo:t,base:r.base,head:r.head,title:r.title,body:r.body})).url})})}return(0,I.jsx)(_e,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(ae,{className:`top-[12vh] translate-y-0 sm:max-w-lg`,children:[(0,I.jsxs)(se,{children:[(0,I.jsxs)(pe,{children:[e.action===`commit`&&`Commit changes`,e.action===`push`&&`Push`,e.action===`pullRequest`&&`Create pull request`]}),(0,I.jsxs)(ge,{children:[e.action===`commit`&&(n.length===1?`Stages every change and commits it.`:`Stages every change in the selected repositories and commits it.`),e.action===`push`&&`Pushes the selected repositories to their remote.`,e.action===`pullRequest`&&`AI writes the title and description. You review them before the pull request is created.`]})]}),l===null&&(0,I.jsxs)(I.Fragment,{children:[n.length===1&&(0,I.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-1.5 text-xs`,children:[e.action===`pullRequest`?(0,I.jsx)(AL,{head:n[0].branch??`detached`,target:s[n[0].path],onBase:e=>g(n[0].path,e)}):n[0].branch??`detached`,(0,I.jsxs)(`span`,{className:`shrink-0`,children:[`· `,n[0].changed,` `,n[0].changed===1?`change`:`changes`]})]}),n.length>1&&(0,I.jsx)(`div`,{className:`flex max-h-60 flex-col gap-0.5 overflow-y-auto`,children:n.map(n=>(0,I.jsxs)(`label`,{className:`hover:bg-accent flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5`,children:[(0,I.jsx)(`input`,{type:`checkbox`,disabled:s[n.path]?.kind===`failed`,checked:r.includes(n.path)&&s[n.path]?.kind!==`failed`,onChange:e=>i(e.target.checked?[...r,n.path]:r.filter(e=>e!==n.path))}),(0,I.jsx)(`span`,{className:`truncate font-medium`,children:ML(n.path,t)}),e.action===`pullRequest`?(0,I.jsx)(AL,{head:n.branch??`detached`,target:s[n.path],onBase:e=>g(n.path,e)}):(0,I.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,children:n.branch??`detached`}),(0,I.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0 text-xs tabular-nums`,children:e.action===`push`?n.upstream===null?`not pushed yet`:`↑${n.ahead}`:n.changed>0&&`${n.changed} ${n.changed===1?`change`:`changes`}`})]},n.path))}),e.action===`commit`&&(0,I.jsx)(`textarea`,{value:a,onChange:e=>o(e.target.value),placeholder:`Leave empty to write the message with AI`,rows:5,className:`bg-background focus-visible:border-ring focus-visible:ring-ring/33 w-full resize-none rounded-lg border px-3 py-2 font-mono text-xs transition-[border-color,box-shadow] duration-200 ease-out outline-none focus-visible:ring-3`}),e.action===`pullRequest`&&p.length>0&&(0,I.jsxs)(`p`,{children:[`You have local changes`,n.length>1&&` in ${p.map(e=>ML(e.path,t)).join(`, `)}`,`. Do you want to commit and push them before creating the pull request?`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[e.action===`commit`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(x,{variant:`outline`,size:`sm`,disabled:d.length===0,onClick:()=>v(!1),children:`Commit`}),(0,I.jsx)(x,{size:`sm`,disabled:d.length===0,onClick:()=>v(!0),children:`Commit and Push`})]}),e.action===`push`&&(0,I.jsx)(x,{size:`sm`,disabled:d.length===0,onClick:y,children:`Push`}),e.action===`pullRequest`&&p.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(x,{variant:`outline`,size:`sm`,disabled:f,onClick:()=>S(!1),children:`Continue without them`}),(0,I.jsx)(x,{size:`sm`,disabled:f,onClick:()=>S(!0),children:`Commit and continue`})]}),e.action===`pullRequest`&&p.length===0&&(0,I.jsx)(x,{size:`sm`,disabled:f||d.length===0,onClick:()=>S(!1),children:`Create pull request`})]})]}),l!==null&&(0,I.jsx)(`div`,{className:`flex max-h-[60vh] flex-col gap-2 overflow-y-auto`,children:l.map(e=>{let r=e.draft;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(`span`,{className:`mt-0.5 flex size-4 shrink-0 overflow-hidden`,children:(0,I.jsx)(w,{icon:xae[e.state],className:P(`size-4`,e.state===`working`&&`animate-spin`,e.state===`review`&&`text-info`,e.state===`done`&&`text-success`,e.state===`failed`&&`text-destructive`,e.state===`skipped`&&`text-muted-foreground`)})}),(0,I.jsx)(`span`,{className:`shrink-0 font-medium`,children:ML(e.path,t)}),(0,I.jsxs)(`span`,{className:P(`min-w-0 text-xs leading-5 break-words whitespace-pre-wrap`,e.state===`failed`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.url!==null&&(0,I.jsxs)(I.Fragment,{children:[` `,(0,I.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline hover:underline-offset-2`,children:e.url})]})]})]}),e.state===`review`&&r!==null&&(0,I.jsx)(bae,{draft:r,onChange:t=>m(e.path,{draft:t}),onSkip:n.length===1?null:()=>m(e.path,{state:`skipped`,text:`Skipped`,draft:null}),onRegenerate:()=>void h(e.path,()=>b(e.path,!1,r.base)),onCreate:()=>C(e.path,r)})]},e.path)})})]})})}function jL(e,t){if(t===`commit`)return e.filter(e=>e.changed>0);if(t===`push`)return e.filter(e=>e.branch!==null&&(e.upstream===null||e.ahead>0));if(t===`pullRequest`)return e.filter(e=>e.branch!==null);throw Error(`Unknown git action ${String(t)}`)}function ML(e,t){return e===``?t:e}var Cae=3e3,wae=18e4;function NL(e,t,n){let[r,i]=(0,F.useState)(null),[a,o]=(0,F.useState)(0);(0,F.useEffect)(()=>{if(t===null)return;let n=f9(e,t),r={projectId:t},a=!0,o=!1,s=!1;async function c(){if(!o){o=!0;try{let t=await L(e,`git.status`,r);if(!a)return;s=!1,i(e=>e!==null&&e.key===n&&Cs(e.repos,t)?e:{key:n,repos:t})}catch(e){a&&!s&&(s=!0,R9(e))}finally{o=!1}}}function l(){document.hidden||c()}c();let u=window.setInterval(l,Cae);return window.addEventListener(`focus`,l),()=>{a=!1,window.clearInterval(u),window.removeEventListener(`focus`,l)}},[e,t,n,a]),(0,F.useEffect)(()=>{if(t===null)return;let n={projectId:t},r=!0,i=!1;async function a(){if(!document.hidden)try{await L(e,`git.fetch`,n),r&&(i=!1,o(e=>e+1))}catch(e){r&&!i&&(i=!0,R9(e))}}a();let s=window.setInterval(a,wae);return()=>{r=!1,window.clearInterval(s)}},[e,t]);let s=(0,F.useCallback)(()=>o(e=>e+1),[]);return{repos:r!==null&&t!==null&&r.key===f9(e,t)?r.repos:[],refresh:s}}function PL(e){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(!1),l=jL(e.repos,`push`),u=jL(e.repos,`commit`);function d(t){SL({labels:{working:`Pushing…`,done:`Pushed`,failed:`Push failed`},task:async()=>(await L(e.machine,`git.push`,{projectId:e.projectId,repo:t}),null),onRefresh:e.onRefresh})}async function f(){if(u.length===1)i(!1),CL(e,u[0].path,``,!1);else{c(!0);try{for(let t of u)await L(e.machine,`git.commit`,{projectId:e.projectId,repo:t.path,message:``,push:!1});i(!1)}catch(e){R9(e)}finally{c(!1),e.onRefresh()}}}return{target:e,action:t,setAction:n,menuOpen:r,setMenuOpen:i,branchRepo:a,setBranchRepo:o,committing:s,pushable:l,committable:u,push:d,yoloCommit:f}}function FL(e){let t=e.git,n=t.target.repos,r=n.reduce((e,t)=>e+t.ahead,0);return(0,I.jsxs)(I.Fragment,{children:[e.collapsed&&n.map(e=>(0,I.jsxs)(CC,{onSelect:()=>t.setBranchRepo(e.path),children:[(0,I.jsx)(w,{icon:b_}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.path===``?e.branch??`detached`:`${e.path}: ${e.branch??`detached`}`}),(0,I.jsx)(`span`,{className:`text-muted-foreground flex gap-1 text-xs`,children:(0,I.jsx)(hL,{behind:e.behind,ahead:e.ahead})})]},e.path)),e.collapsed&&(0,I.jsx)(OC,{}),e.collapsed&&(0,I.jsxs)(CC,{disabled:t.committable.length===0,onSelect:()=>t.setAction(`commit`),children:[(0,I.jsx)(w,{icon:x_}),`Commit…`]}),(0,I.jsxs)(CC,{disabled:t.pushable.length===0||t.committing,onSelect:()=>{t.pushable.length===1?t.push(t.pushable[0].path):t.setAction(`push`)},children:[(0,I.jsx)(w,{icon:i_}),t.pushable.length>1?`Just Push…`:`Just Push`,r>0&&(0,I.jsxs)(`span`,{className:`text-muted-foreground ml-auto text-xs tabular-nums`,children:[`↑`,r]})]}),(0,I.jsxs)(CC,{disabled:t.committable.length===0||t.committing,onSelect:e=>{e.preventDefault(),t.yoloCommit()},children:[(0,I.jsx)(w,{icon:t.committing?e_:x_,className:P(t.committing&&`animate-spin`)}),t.committing?`Committing…`:`Yolo Commit`]}),(0,I.jsx)(OC,{}),(0,I.jsxs)(CC,{disabled:jL(n,`pullRequest`).length===0,onSelect:()=>t.setAction(`pullRequest`),children:[(0,I.jsx)(w,{icon:ree}),`Create pull request…`]})]})}function IL(e){let t=e.git,n=t.target.repos.find(e=>e.path===t.branchRepo);return(0,I.jsxs)(I.Fragment,{children:[t.action!==null&&(0,I.jsx)(Sae,{machine:t.target.machine,projectId:t.target.projectId,action:t.action,repos:t.target.repos,onClose:()=>t.setAction(null),onRefresh:t.target.onRefresh}),t.branchRepo!==null&&n!==void 0&&(0,I.jsx)(pae,{machine:t.target.machine,projectId:t.target.projectId,repo:n,onRefresh:t.target.onRefresh,onClose:()=>t.setBranchRepo(null)})]})}function Tae(e){let t=PL(e),[n,r]=(0,F.useState)(!1),i=[...new Set(e.repos.map(e=>e.branch??`detached`))],a=e.repos.flatMap(e=>{let t=gL(e);return t===null?[]:[{repo:e,next:t}]}),o=e.repos.map(e=>e.path===``?e.branch??`detached`:`${e.path}: ${e.branch??`detached`}`).join(`
|
|
112
|
+
`),s=i.length===1?i[0]:`${i.length} branches`;async function c(t){r(!0);try{await L(e.machine,`git.sync`,{projectId:e.projectId,repo:t})}catch(e){R9(e)}finally{r(!1),e.onRefresh()}}return(0,I.jsxs)(`div`,{className:`flex w-fit items-center gap-3.5`,children:[e.repos.length===1&&(0,I.jsx)(fae,{machine:e.machine,projectId:e.projectId,repo:e.repos[0],onRefresh:e.onRefresh}),e.repos.length>1&&a.length===0&&(0,I.jsxs)(`span`,{className:`text-muted-foreground hidden max-w-48 items-center gap-1 text-xs sm:flex`,title:o,children:[(0,I.jsx)(w,{icon:b_,className:`size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:s})]}),e.repos.length>1&&a.length>0&&(0,I.jsxs)(yC,{children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`text-muted-foreground hover:text-foreground hidden max-w-48 cursor-pointer items-center gap-1 text-xs sm:flex`,title:o,children:[(0,I.jsx)(w,{icon:n?e_:a.length===1?a[0].next.icon:jg,className:P(`size-3.5 shrink-0`,n&&`animate-spin`)}),(0,I.jsx)(`span`,{className:`truncate`,children:s})]})}),(0,I.jsx)(SC,{align:`end`,className:`w-64`,children:a.map(e=>(0,I.jsxs)(CC,{disabled:n,onSelect:()=>void c(e.repo.path),children:[(0,I.jsx)(w,{icon:e.next.icon}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.next.label,` ·`,` `,e.repo.path===``?e.repo.branch:e.repo.path]}),(0,I.jsx)(`span`,{className:`text-muted-foreground flex gap-1 text-xs`,children:(0,I.jsx)(hL,{behind:e.repo.behind,ahead:e.repo.ahead})})]},e.repo.path))})]}),(0,I.jsxs)(`div`,{className:`flex w-fit`,children:[(0,I.jsxs)(x,{variant:`outline`,size:`xs`,className:`rounded-e-none border-e-0`,disabled:t.committable.length===0,onClick:()=>t.setAction(`commit`),children:[(0,I.jsx)(w,{icon:x_}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:`Commit`})]}),(0,I.jsxs)(yC,{open:t.menuOpen,onOpenChange:t.setMenuOpen,children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsx)(x,{variant:`outline`,size:`icon-xs`,className:`rounded-s-none`,"aria-label":`Git actions`,children:(0,I.jsx)(w,{icon:t.committing?e_:Yg,className:P(`size-4`,t.committing&&`animate-spin`)})})}),(0,I.jsx)(SC,{align:`end`,className:`w-56`,children:(0,I.jsx)(FL,{git:t,collapsed:!1})})]})]}),(0,I.jsx)(IL,{git:t})]})}function LL({...e}){return(0,I.jsx)(Kee,{"data-slot":`alert-dialog`,...e})}function RL({...e}){return(0,I.jsx)(qee,{"data-slot":`alert-dialog-trigger`,...e})}function Eae({...e}){return(0,I.jsx)(Jee,{"data-slot":`alert-dialog-portal`,...e})}function Dae({className:e,...t}){return(0,I.jsx)(Yee,{"data-slot":`alert-dialog-overlay`,className:P(`fixed inset-0 z-50 bg-background/80 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function zL({className:e,size:t=`default`,...n}){return(0,I.jsxs)(Eae,{children:[(0,I.jsx)(Dae,{}),(0,I.jsx)(Qee,{"data-slot":`alert-dialog-content`,"data-size":t,className:P(`group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-background p-4 text-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...n})]})}function BL({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:P(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function VL({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:P(`flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function HL({className:e,...t}){return(0,I.jsx)($ee,{"data-slot":`alert-dialog-title`,className:P(`text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function UL({className:e,...t}){return(0,I.jsx)(ete,{"data-slot":`alert-dialog-description`,className:P(`text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function WL({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,I.jsx)(x,{variant:t,size:n,asChild:!0,children:(0,I.jsx)(tte,{"data-slot":`alert-dialog-action`,className:P(e),...r})})}function GL({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,I.jsx)(x,{variant:t,size:n,asChild:!0,children:(0,I.jsx)(rte,{"data-slot":`alert-dialog-cancel`,className:P(e),...r})})}function KL({className:e,size:t=`default`,...n}){return(0,I.jsx)(fC,{"data-slot":`switch`,"data-size":t,className:P(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,I.jsx)(mC,{"data-slot":`switch-thumb`,className:`bg-background dark:data-checked:bg-primary-foreground dark:data-unchecked:bg-foreground pointer-events-none block rounded-full ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0`})})}var qL=Jh({theme:lh().refine(e=>dI.some(t=>t.id===e)).default(dI[0].id),terminal:Jh({font:Jh({family:lh().default(`FiraCode Nerd Font`),size:Fh().default(14),lineHeight:Fh().default(1.35),ligatures:zh().default(!0)}).prefault({}),cursor:Jh({style:ng([`block`,`bar`,`underline`]).default(`bar`),blink:zh().default(!0)}).prefault({}),padding:Jh({top:Fh().default(4),right:Fh().default(4),bottom:Fh().default(0),left:Fh().default(4)}).prefault({}),scrollback:Fh().default(1e3),boldIsBright:zh().default(!0),behavior:Jh({modernizeShiftEnter:zh().default(!0),pasteBrowserImages:zh().default(!0),captureShortcuts:zh().default(!0),bellFlash:zh().default(!0),bellSound:zh().default(!0),clickToMoveCursor:zh().default(!0),optionAsMeta:ng([`off`,`left`,`right`,`both`]).default(`off`),confirmCloseBusyTab:zh().default(!0)}).prefault({})}).prefault({}),diff:Jh({split:zh().default(!1),wrap:zh().default(!0),collapsed:zh().default(!1)}).prefault({}),rewind:ng([`all`,`chat`,`code`]).default(`chat`)}),JL=`prefs`,YL=qL.parse({});function Oae(){let e=localStorage.getItem(JL);if(e===null)return structuredClone(YL);let t=qL.safeParse(JSON.parse(e));return t.success?t.data:(console.warn(`invalid stored prefs, using the defaults:\n${bl(t.error)}`),structuredClone(YL))}function kae(e){localStorage.setItem(JL,JSON.stringify(e))}function XL(e){return(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`h2`,{className:`text-muted-foreground mb-2 px-1 text-xs font-medium`,children:[e.title,e.note&&(0,I.jsxs)(`span`,{className:`font-normal`,children:[` · `,e.note]})]}),(0,I.jsx)(`div`,{className:`@container divide-y overflow-hidden rounded-xl border`,children:e.children})]})}function ZL(e){return(0,I.jsxs)(`label`,{className:`flex min-h-13 flex-wrap items-center gap-x-4 gap-y-2 px-4 py-2.5`,children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 basis-40 text-sm font-medium`,children:e.label}),(0,I.jsx)(`div`,{className:`max-w-full shrink-0 @max-lg:has-[[data-slot=select-trigger],input:not([type=number])]:w-full @max-lg:has-[[data-slot=select-trigger],input:not([type=number])]:*:w-full @max-lg:**:data-[slot=select-trigger]:w-full`,children:e.children})]})}function QL(e){let[t,n]=(0,F.useState)(e.value);function r(){t!==e.value&&(e.valid&&!e.valid(t)?n(e.value):e.onCommit(t))}return(0,I.jsx)(wL,{className:P(`w-56`,e.className),type:e.type,min:e.type===`number`?0:void 0,step:e.step,placeholder:e.placeholder,value:t,onChange:e=>n(e.target.value),onBlur:r,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}})}function $L(e){return(0,I.jsx)(QL,{type:`number`,className:`w-24`,step:e.step??1,value:String(e.value),valid:e=>e!==``&&Number(e)>=0,onCommit:t=>e.onCommit(Number(t))},e.value)}function Aae(e){let t=e.prefs;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(XL,{title:`Appearance`,children:(0,I.jsx)(ZL,{label:`Theme`,children:(0,I.jsxs)(TL,{value:t.theme,onValueChange:e=>L9({...t,theme:e}),children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsx)(OL,{children:dI.map(e=>(0,I.jsx)(kL,{value:e.id,children:e.name},e.id))})]})})}),(0,I.jsx)(jae,{}),(0,I.jsx)(x,{variant:`outline`,onClick:e.onRestore,children:`Restore browser defaults`})]})}function jae(){let[e,t]=(0,F.useState)(`idle`),[n,r]=(0,F.useState)(null);async function i(){t(`checking`),r(null);try{let e=`serviceWorker`in navigator?await navigator.serviceWorker.getRegistration():void 0;if(e===void 0){location.reload();return}await e.update(),t(e.installing===null&&e.waiting===null?`current`:`updating`)}catch(e){console.error(`could not check for updates`,e),r(Oe(e)),t(`idle`)}}return(0,I.jsx)(XL,{title:`App`,children:(0,I.jsx)(ZL,{label:`Load the newest version of OffSite in this browser`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[n!==null&&(0,I.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[`Could not check: `,n]}),e===`current`&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Up to date`}),e===`updating`&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Updating, the page reloads when it's ready`}),(0,I.jsx)(x,{size:`sm`,variant:`outline`,disabled:e===`checking`||e===`updating`,onClick:()=>void i(),children:`Check for updates`})]})})})}function Mae(e){for(let t=0;t<e.length;t++){let n=e[t];if(!n.startsWith(`-`)&&!n.startsWith(`+`))return!1;let r=n.startsWith(`-`),i=n.slice(1);if(i===``||i===`-`)return!1;if(i.startsWith(`-`)){if(!eR(i.slice(1),r))return!1}else for(let n=0;n<i.length;n++){let a=i[n];if(a===`o`){let a=i.slice(n+1);if(a===``){if(t++,t===e.length)return!1;a=e[t]}if(!eR(a,r))return!1;break}if(a===`b`||a===`c`||r&&`dfnprvx`.includes(a)||!r&&a===`i`)return!1}}return!0}function eR(e,t){let n=e.toLowerCase().replace(/[-_]/g,``),r=t;return n.startsWith(`no`)&&(n=n.slice(2),r=!t),[`rcs`,`globalrcs`,`interactive`,`exec`].includes(n)?r:![`privileged`,`restricted`,`sourcetrace`,`verbose`,`xtrace`].includes(n)||!r}function Nae(e,t,n){if(t===`windows`)return`Not available on Windows`;if(e!==null&&/[\n"'\\$`;&|<>()*?[\]{}#!]/.test(e))return`Not available for commands with shell syntax`;let r=e===null?[n]:e.split(/[ \t]/).filter(e=>e!==``);if(r.length===0)return`Available for bash, zsh and fish`;let i=r[0],a=i.split(`/`).pop(),o=r.slice(1);return a===`bash`?t===`macos`&&(i===`/bin/bash`||!i.includes(`/`))?`Needs a newer bash than the one macOS includes`:o.every(e=>[`-l`,`--login`,`-i`].includes(e))?null:`Not available with these bash options`:a===`zsh`?Mae(o)?null:`Not available with these zsh options`:a===`fish`?o.every(e=>{if(e.startsWith(`--`)){let t=e.slice(2).split(`=`)[0];return t===``||![`command`,`no-config`,`no-execute`].some(e=>e.startsWith(t))}return!(e.startsWith(`-`)&&/[cNn]/.test(e))})?null:`Not available with these fish options`:`Available for bash, zsh and fish`}var Pae=`3.6.8`,Fae=`1.3.1`,tR=[{family:`FiraCode Nerd Font`,label:`Fira Code`},{family:`JetBrainsMono Nerd Font`,label:`JetBrains Mono`},{family:`CaskaydiaCove Nerd Font`,label:`Cascadia Code`},{family:`Hack Nerd Font`,label:`Hack`}],Iae=[{value:`macos`,label:`macOS`},{value:`linux`,label:`Linux`},{value:`windows`,label:`Windows`}];async function nR(e){let t=`${e.font.size}px ${e.font.family}`;await Promise.all([document.fonts.load(t),document.fonts.load(`bold ${t}`)]);let n=document.documentElement.style;n.setProperty(`--pad-top`,`${e.padding.top}px`),n.setProperty(`--pad-right`,`${e.padding.right}px`),n.setProperty(`--pad-bottom`,`${e.padding.bottom}px`),n.setProperty(`--pad-left`,`${e.padding.left}px`)}function Lae(e,t){let n=fI();return{fontFamily:e.font.family,fontSize:e.font.size,lineHeight:e.font.lineHeight,ligatures:e.font.ligatures,cursorStyle:e.cursor.style,cursorBlink:e.cursor.blink,scrollback:e.scrollback,boldIsBright:e.boldIsBright,colors:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorText:n.background,selectionBackground:n.selectionBackground,selectionForeground:n.foreground,palette:n.palette},version:Rae(t),clickToMoveCursor:e.behavior.clickToMoveCursor,optionAsMeta:e.behavior.optionAsMeta}}function Rae(e){if(e===`offsite`)return`offsite 0.0.0`;if(e===`ghostty`)return`ghostty ${Fae}`;if(e===`iterm2`)return`iTerm2 ${Pae}`;throw Error(`unknown terminal identity ${e}`)}var rR=[10,15,30,45,60,120,180,300,600,900,1800,3600];function zae(e){let t=e.config;function n(n){H9(e.machine,{...t,...n})}return(0,I.jsxs)(XL,{title:`Agents`,children:[(0,I.jsx)(ZL,{label:`Send while working`,children:(0,I.jsxs)(TL,{value:t.delivery,onValueChange:n=>{if(n!==`queue`&&n!==`steer`)throw Error(`Unknown delivery ${n}`);H9(e.machine,{...t,delivery:n})},children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`queue`,children:`Queue messages`}),(0,I.jsx)(kL,{value:`steer`,children:`Steer the agent`})]})]})}),(0,I.jsx)(ZL,{label:`Auto-skip questions`,children:(0,I.jsx)(iR,{value:t.autoSkipQuestionTimeout,onChange:e=>n({autoSkipQuestionTimeout:e})})}),(0,I.jsx)(ZL,{label:`Auto-resolve permissions`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.autoPermissionTimeout!==null&&(0,I.jsxs)(TL,{value:t.autoPermissionMode,onValueChange:e=>{if(e!==`allow`&&e!==`deny`)throw Error(`Unknown decision ${e}`);n({autoPermissionMode:e})},children:[(0,I.jsx)(DL,{className:`w-24`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`allow`,children:`Allow`}),(0,I.jsx)(kL,{value:`deny`,children:`Deny`})]})]}),(0,I.jsx)(iR,{value:t.autoPermissionTimeout,onChange:e=>n({autoPermissionTimeout:e})})]})})]})}function iR(e){let t=e.value===null||rR.includes(e.value)?rR:[...rR,e.value].sort((e,t)=>e-t);return(0,I.jsxs)(TL,{value:e.value===null?`off`:String(e.value),onValueChange:t=>e.onChange(t===`off`?null:Number(t)),children:[(0,I.jsx)(DL,{className:`w-40`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`off`,children:`Off`}),t.map(e=>(0,I.jsx)(kL,{value:String(e),children:e===3600?`After 1 hour`:e===60?`After 1 minute`:e%60==0?`After ${e/60} minutes`:`After ${e} seconds`},e))]})]})}function aR(e){let t=e.config.commitMessage,[n,r]=(0,F.useState)(null),[i,a]=(0,F.useState)(null);(0,F.useEffect)(()=>{if(t.provider===null)return;let n=!0;return r(null),a(null),L(e.machine,`capabilities`,{provider:t.provider,accountId:t.accountId,projectId:null}).then(e=>{n&&r(e.models)},e=>{n&&a(Oe(e))}),()=>{n=!1}},[e.machine,t.provider,t.accountId]);function o(t){H9(e.machine,{...e.config,commitMessage:t})}function s(t){if(t===`off`){o({provider:null,accountId:null,model:null});return}if(t===`opencode`){o({provider:`opencode`,accountId:null,model:null});return}let n=[...e.claudeAccounts,...e.codexAccounts].find(e=>e.id===t);if(n===void 0)throw Error(`That account was removed`);o({provider:n.provider,accountId:n.id,model:null})}return(0,I.jsxs)(XL,{title:`Commit messages and pull requests`,children:[(0,I.jsx)(ZL,{label:`Account`,children:(0,I.jsxs)(TL,{value:t.provider===null?`off`:t.provider===`opencode`?`opencode`:t.accountId??`off`,onValueChange:s,children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`off`,children:`Off`}),[...e.claudeAccounts,...e.codexAccounts].map(e=>(0,I.jsxs)(kL,{value:e.id,disabled:!e.valid,children:[(0,I.jsx)(zv,{provider:e.provider,className:`size-4`}),`${uw[e.provider]} · ${e.name}`]},e.id)),e.openCode.available&&(0,I.jsxs)(kL,{value:`opencode`,children:[(0,I.jsx)(zv,{provider:`opencode`,className:`size-4`}),uw.opencode]})]})]})}),t.provider!==null&&(0,I.jsx)(ZL,{label:`Model`,children:(0,I.jsxs)(TL,{value:t.model??void 0,disabled:n===null,onValueChange:e=>o({...t,model:e}),children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{placeholder:i===null?n===null?`Loading…`:`Choose a model`:`Unavailable`})}),(0,I.jsx)(OL,{children:(n??[]).map(e=>(0,I.jsx)(kL,{value:e.value,children:e.name},e.value))})]})}),i!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:i})]})}var oR={zsh:`M11.415 5.038a.58.58 0 0 0-.543.197L.135 18.021a.58.58 0 0 0 .071.814.58.58 0 0 0 .815-.07L11.757 5.979a.58.58 0 0 0-.07-.815.6.6 0 0 0-.272-.126m-8.113.317a3.133 3.133 0 0 0-3.12 3.12 3.13 3.13 0 0 0 3.12 3.119A3.133 3.133 0 0 0 6.42 8.475a3.13 3.13 0 0 0-3.119-3.119m0 1.806a1.3 1.3 0 0 1 1.314 1.313 1.3 1.3 0 0 1-1.314 1.312A1.3 1.3 0 0 1 1.99 8.475a1.3 1.3 0 0 1 1.312-1.314m5.253 5.253a3.13 3.13 0 0 0-3.119 3.119 3.13 3.13 0 0 0 3.12 3.118 3.133 3.133 0 0 0 3.118-3.12 3.133 3.133 0 0 0-3.119-3.118m0 1.805a1.3 1.3 0 0 1 1.313 1.314c0 .735-.577 1.312-1.312 1.312a1.3 1.3 0 0 1-1.314-1.312 1.3 1.3 0 0 1 1.313-1.314m7.201 3.276a.58.58 0 0 0-.578.578.58.58 0 0 0 .578.578h7.666a.58.58 0 0 0 .579-.578.58.58 0 0 0-.579-.578Z`,bash:`M21.038,4.9l-7.577-4.498C13.009,0.134,12.505,0,12,0c-0.505,0-1.009,0.134-1.462,0.403L2.961,4.9 C2.057,5.437,1.5,6.429,1.5,7.503v8.995c0,1.073,0.557,2.066,1.462,2.603l7.577,4.497C10.991,23.866,11.495,24,12,24 c0.505,0,1.009-0.134,1.461-0.402l7.577-4.497c0.904-0.537,1.462-1.529,1.462-2.603V7.503C22.5,6.429,21.943,5.437,21.038,4.9z M15.17,18.946l0.013,0.646c0.001,0.078-0.05,0.167-0.111,0.198l-0.383,0.22c-0.061,0.031-0.111-0.007-0.112-0.085L14.57,19.29 c-0.328,0.136-0.66,0.169-0.872,0.084c-0.04-0.016-0.057-0.075-0.041-0.142l0.139-0.584c0.011-0.046,0.036-0.092,0.069-0.121 c0.012-0.011,0.024-0.02,0.036-0.026c0.022-0.011,0.043-0.014,0.062-0.006c0.229,0.077,0.521,0.041,0.802-0.101 c0.357-0.181,0.596-0.545,0.592-0.907c-0.003-0.328-0.181-0.465-0.613-0.468c-0.55,0.001-1.064-0.107-1.072-0.917 c-0.007-0.667,0.34-1.361,0.889-1.8l-0.007-0.652c-0.001-0.08,0.048-0.168,0.111-0.2l0.37-0.236 c0.061-0.031,0.111,0.007,0.112,0.087l0.006,0.653c0.273-0.109,0.511-0.138,0.726-0.088c0.047,0.012,0.067,0.076,0.048,0.151 l-0.144,0.578c-0.011,0.044-0.036,0.088-0.065,0.116c-0.012,0.012-0.025,0.021-0.038,0.028c-0.019,0.01-0.038,0.013-0.057,0.009 c-0.098-0.022-0.332-0.073-0.699,0.113c-0.385,0.195-0.52,0.53-0.517,0.778c0.003,0.297,0.155,0.387,0.681,0.396 c0.7,0.012,1.003,0.318,1.01,1.023C16.105,17.747,15.736,18.491,15.17,18.946z M19.143,17.859c0,0.06-0.008,0.116-0.058,0.145 l-1.916,1.164c-0.05,0.029-0.09,0.004-0.09-0.056v-0.494c0-0.06,0.037-0.093,0.087-0.122l1.887-1.129 c0.05-0.029,0.09-0.004,0.09,0.056V17.859z M20.459,6.797l-7.168,4.427c-0.894,0.523-1.553,1.109-1.553,2.187v8.833 c0,0.645,0.26,1.063,0.66,1.184c-0.131,0.023-0.264,0.039-0.398,0.039c-0.42,0-0.833-0.114-1.197-0.33L3.226,18.64 c-0.741-0.44-1.201-1.261-1.201-2.142V7.503c0-0.881,0.46-1.702,1.201-2.142l7.577-4.498c0.363-0.216,0.777-0.33,1.197-0.33 c0.419,0,0.833,0.114,1.197,0.33l7.577,4.498c0.624,0.371,1.046,1.013,1.164,1.732C21.686,6.557,21.12,6.411,20.459,6.797z`,fish:`m19.164 9.228-3.016 2.688v.527l3.016 2.688v-1.228l-1.936-1.723 1.936-1.724V9.228m-6.658.046v1.208l1.905 1.696-1.905 1.695v1.209l2.968-2.645v-.518l-2.968-2.645M9.781 7.847a6.519 6.519 0 0 0-2.038-.335c-.672 0-1.349.112-2.03.335a9.23 9.23 0 0 0-2.088 1.017v.723c.69-.4 1.377-.7 2.06-.897a7.388 7.388 0 0 1 2.058-.296c.684 0 1.368.098 2.052.296a9.452 9.452 0 0 1 2.075.897v-.723a9.229 9.229 0 0 0-2.09-1.017m.014 7.78a7.371 7.371 0 0 1-2.052.296 7.388 7.388 0 0 1-2.057-.296 9.18 9.18 0 0 1-2.061-.897v.723a9.228 9.228 0 0 0 2.088 1.017 6.492 6.492 0 0 0 2.03.335c.678 0 1.357-.112 2.038-.335a9.227 9.227 0 0 0 2.089-1.017v-.723c-.7.4-1.391.7-2.075.897m.602-11.23h-.51L7.28 6.92h1.19l1.672-1.62 1.671 1.62h1.191l-2.607-2.525m-2.965 13.68v-.824H6.427v.825l.786 1.527h.614l-.395-1.527M4.127 10.95v1.216H5.13V10.95H4.127m-1.16-1.695L0 11.901v.518l2.967 2.645v-1.208L1.063 12.16l1.904-1.695V9.256m20.68 3.28c-.235-.3-.574-.509-1.017-.626.395-.103.696-.278.902-.525.206-.247.31-.556.31-.926 0-.546-.197-.984-.59-1.314-.393-.33-.919-.495-1.575-.495-.22 0-.473.025-.758.073-.284.048-.61.12-.974.217v.84c.314-.12.613-.21.9-.27a4.05 4.05 0 0 1 .832-.091c.403 0 .714.093.933.278.218.185.328.451.328.798 0 .328-.118.584-.353.768-.235.184-.562.276-.98.276h-.697v.75h.696c.458 0 .821.116 1.09.346.268.23.402.542.402.934 0 .425-.134.75-.402.976-.269.226-.653.339-1.153.339a3.55 3.55 0 0 1-.89-.117 4.395 4.395 0 0 1-.91-.358v.909a6.1 6.1 0 0 0 .95.249c.323.057.639.085.95.085.738 0 1.315-.177 1.733-.53.417-.355.626-.842.626-1.463 0-.449-.118-.823-.353-1.123`,powershell:`M23.181 2.974c.568 0 .923.463.792 1.035l-3.659 15.982c-.13.572-.697 1.035-1.265 1.035H.819c-.568 0-.923-.463-.792-1.035L3.686 4.009c.13-.572.697-1.035 1.265-1.035zm-8.375 9.346c.251-.394.227-.905-.09-1.243L9.122 5.125c-.38-.404-1.037-.407-1.466-.003-.429.402-.468 1.056-.088 1.46l4.662 4.96v.11l-7.42 5.374c-.45.327-.533.977-.187 1.453.346.476.991.597 1.44.27l8.229-5.91c.28-.196.438-.365.514-.52zm-2.796 4.399a.928.928 0 00-.934.923c0 .51.418.923.934.923h4.433a.928.928 0 00.934-.923.928.928 0 00-.934-.923z`,cmd:`M8.165 6V3h7.665v3H8.165zm-.5-3H1c-.55 0-1 .45-1 1v2h7.665V3zM23 3h-6.67v3H24V4c0-.55-.45-1-1-1zM0 6.5h24V20c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V6.5zM11.5 18c0 .3.2.5.5.5h8c.3 0 .5-.2.5-.5v-1.5c0-.3-.2-.5-.5-.5h-8c-.3 0-.5.2-.5.5V18zm-5.2-4.55l-3.1 3.1c-.25.25-.25.6 0 .8l.9.9c.25.25.6.25.8 0l4.4-4.4a.52.52 0 0 0 0-.8l-4.4-4.4c-.2-.2-.6-.2-.8 0l-.9.9c-.25.2-.25.55 0 .8l3.1 3.1z`},sR={zsh:`zsh`,bash:`bash`,fish:`fish`,pwsh:`powershell`,powershell:`powershell`,cmd:`cmd`},cR={macos:[`zsh`,`bash`,`fish`,`pwsh`],linux:[`bash`,`zsh`,`fish`,`pwsh`],windows:[`pwsh`,`powershell`,`cmd`]};function lR(e){let t=e.trim().split(/[\\/]/).pop()?.toLowerCase().replace(/\.exe$/,``);return t===void 0?void 0:sR[t]}function uR(e){return e.replace(/[\\/][^\\/]*$/,``)}function dR(e){return(0,I.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`size-4 flex-none`,fill:`currentColor`,children:(0,I.jsx)(`path`,{d:oR[e.logo]})})}function fR(e){let[t,n]=(0,F.useState)(e.value??``),[r,i]=(0,F.useState)(null),[a,o]=(0,F.useState)(null),s=lR(t),c=e.platform===e.device,l=c?r:cR[e.platform].map(e=>({name:e,path:null}));(0,F.useEffect)(()=>{c&&L(e.machine,`terminal.shells`,void 0).then(i,e=>o(Oe(e)))},[e.machine,c]);function u(t){n(t),t!==(e.value??``)&&e.onCommit(t===``?null:t)}return(0,I.jsxs)(`div`,{className:`relative w-56`,children:[s&&(0,I.jsx)(`span`,{className:`text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2`,children:(0,I.jsx)(dR,{logo:s})}),(0,I.jsx)(wL,{className:s?`pr-9 pl-8`:`pr-9`,placeholder:`System default`,value:t,onChange:e=>n(e.target.value),onBlur:()=>u(t),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}}),(0,I.jsxs)(yC,{children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsx)(x,{variant:`ghost`,size:`icon-xs`,"aria-label":`Known shells`,className:`text-muted-foreground absolute top-1/2 right-1.5 -translate-y-1/2`,children:(0,I.jsx)(w,{icon:Mg})})}),(0,I.jsxs)(SC,{align:`end`,className:`w-72`,children:[a&&(0,I.jsx)(`p`,{className:`text-destructive px-2 py-1.5 text-xs`,children:a}),l?.length===0&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-2 py-1.5 text-xs`,children:`No known shells found`}),l?.map(e=>(0,I.jsxs)(CC,{onSelect:()=>u(e.path??e.name),children:[(0,I.jsx)(dR,{logo:sR[e.name]}),e.name,e.path!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-auto min-w-0 truncate pl-3 text-xs [direction:rtl]`,title:e.path,children:(0,I.jsx)(`bdi`,{children:uR(e.path)})})]},e.path??e.name)),(0,I.jsx)(OC,{}),(0,I.jsx)(CC,{onSelect:()=>u(``),children:`System default`})]})]})]})}function pR(e){let t=e.config.workingDir[e.platform]??``;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(XL,{title:`Projects`,children:(0,I.jsx)(ZL,{label:`Working directory`,children:(0,I.jsx)(QL,{className:`w-72 font-mono`,value:t,placeholder:`Home folder`,onCommit:t=>H9(e.machine,{...e.config,workingDir:{...e.config.workingDir,[e.platform]:t.trim()===``?null:t.trim()}})},`${e.machine}-${t}`)})}),(0,I.jsx)(mR,{machine:e.machine,config:e.config,platform:e.platform,defaultShell:e.defaultShell},e.machine),(0,I.jsx)(zae,{machine:e.machine,config:e.config}),(0,I.jsx)(aR,{machine:e.machine,config:e.config,claudeAccounts:e.claudeAccounts,codexAccounts:e.codexAccounts,openCode:e.openCode},`git-${e.machine}`),(0,I.jsx)(x,{variant:`outline`,onClick:e.onRestore,children:`Restore machine defaults`})]})}function mR(e){let t=e.config.terminal,[n,r]=(0,F.useState)(e.platform),i=Nae(t.shell[e.platform],e.platform,e.defaultShell);function a(t){H9(e.machine,{...e.config,terminal:t})}return(0,I.jsxs)(XL,{title:`Shell`,note:`Applies to new terminals`,children:[(0,I.jsx)(ZL,{label:`Platform`,children:(0,I.jsxs)(TL,{value:n,onValueChange:e=>r(e),children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsx)(OL,{children:Iae.map(t=>(0,I.jsxs)(kL,{value:t.value,children:[t.label,t.value===e.platform&&(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`(this machine)`})]},t.value))})]})}),(0,I.jsx)(ZL,{label:`Command`,children:(0,I.jsx)(fR,{machine:e.machine,platform:n,device:e.platform,value:t.shell[n],onCommit:e=>a({...t,shell:{...t.shell,[n]:e}})},`${e.machine}-${n}-command`)}),(0,I.jsx)(ZL,{label:(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Shell integration`,(0,I.jsx)(M,{label:(0,I.jsxs)(`div`,{children:[`Tells the terminal where prompts and commands start and end.`,(0,I.jsxs)(`ul`,{className:`mt-1 list-disc pl-4`,children:[(0,I.jsx)(`li`,{children:`Click in the command line to move the cursor`}),(0,I.jsx)(`li`,{children:`Ignore clipboard reads once the command that asked has finished`})]})]}),children:(0,I.jsx)(`span`,{onClick:e=>e.preventDefault(),children:(0,I.jsx)(w,{icon:dee,"aria-label":`About shell integration`,className:`text-muted-foreground size-3.5`})})})]}),children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground max-w-32 text-right text-xs sm:max-w-none`,children:i}),(0,I.jsx)(KL,{checked:i===null&&t.behavior.shellIntegration,disabled:i!==null,onCheckedChange:e=>a({...t,behavior:{...t.behavior,shellIntegration:e}})})]})}),(0,I.jsx)(hR,{identity:t.behavior.terminalIdentity,onChange:e=>a({...t,behavior:{...t.behavior,terminalIdentity:e}})})]})}function hR(e){return(0,I.jsx)(ZL,{label:`Report the terminal as`,children:(0,I.jsxs)(TL,{value:e.identity,onValueChange:e.onChange,children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`offsite`,children:`OffSite`}),(0,I.jsx)(kL,{value:`ghostty`,children:`Ghostty`}),(0,I.jsx)(kL,{value:`iterm2`,children:`iTerm2`})]})]})})}var gR=(0,F.createContext)({});function _R(e){let t=(0,F.useRef)(null);return t.current===null&&(t.current=e()),t.current}var vR=typeof window<`u`?F.useLayoutEffect:F.useEffect,yR=(0,F.createContext)(null);function bR(e,t){e.indexOf(t)===-1&&e.push(t)}function xR(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}function SR([...e],t,n){let r=t<0?e.length+t:t;if(r>=0&&r<e.length){let r=n<0?e.length+n:n,[i]=e.splice(t,1);e.splice(r,0,i)}return e}var CR=(e,t,n)=>n>t?t:n<e?e:n,wR={},TR=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),ER=e=>typeof e==`object`&&!!e,DR=e=>/^0[^.\s]+$/u.test(e);function OR(e){let t;return()=>(t===void 0&&(t=e()),t)}var kR=e=>e,AR=(...e)=>e.reduce((e,t)=>n=>t(e(n))),jR=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},MR=class{constructor(){this.subscriptions=[]}add(e){return bR(this.subscriptions,e),()=>this.remove(e)}remove(e){xR(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}},NR=e=>e*1e3,PR=e=>e/1e3,FR=(e,t)=>t?1e3/t*e:0,IR=(e,t,n)=>e*(3*(1-e)*((1-e)*t+e*n)+e*e);function LR(e,t,n,r){return e===t&&n===r?kR:i=>{let a=0,o=1,s=i;for(let t=0;;t++){s>=a&&s<=o||(s=(a+o)/2);let r=IR(s,e,n)-i;if(r*r<1e-28||t===40)break;r>0?o=s:a=s,s-=r*1e-7/(IR(s+1e-7,e,n)-i-r)}return IR(s,t,r)}}var RR=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,zR=e=>t=>1-e(1-t),BR=LR(.33,1.53,.69,.99),VR=zR(BR),HR=RR(VR),UR=e=>e>=1?1:(e*=2)<1?.5*VR(e):.5*(2-2**(-10*(e-1))),WR=e=>1-Math.sin(Math.acos(e)),GR=zR(WR),KR=RR(WR),qR=LR(.42,0,1,1),JR=LR(0,0,.58,1),YR=LR(.42,0,.58,1),XR=e=>Array.isArray(e)&&typeof e[0]!=`number`,ZR=e=>Array.isArray(e)&&typeof e[0]==`number`,QR={linear:kR,easeIn:qR,easeInOut:YR,easeOut:JR,circIn:WR,circInOut:KR,circOut:GR,backIn:VR,backInOut:HR,backOut:BR,anticipate:UR},$R=e=>typeof e==`string`,ez=e=>{if(ZR(e)){e.length;let[t,n,r,i]=e;return LR(t,n,r,i)}return $R(e)?(QR[e],`${e}`,QR[e]):e},tz={delta:0,timestamp:0,isProcessing:!1},nz;function rz(){nz=void 0}var iz={now:()=>(nz===void 0&&iz.set(tz.isProcessing||wR.useManualTiming?tz.timestamp:performance.now()),nz),set:e=>{nz=e,queueMicrotask(rz)}},az=e=>Math.round(e*1e5)/1e5,oz=e=>t=>typeof t==`string`&&t.startsWith(e),sz=oz(`--`),cz=oz(`var(--`),lz=e=>cz(e)?uz.test(e.split(`/*`)[0].trim()):!1,uz=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function dz(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var fz={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},pz={...fz,transform:e=>CR(0,1,e)},mz={...fz,default:1},hz=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function gz(e){return e==null}var _z=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,vz=(e,t)=>n=>!!(typeof n==`string`&&_z.test(n)&&n.startsWith(e)||t&&!gz(n)&&Object.prototype.hasOwnProperty.call(n,t)),yz=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(hz);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},bz=e=>CR(0,255,e),xz={...fz,transform:e=>Math.round(bz(e))},Sz={test:vz(`rgb`,`red`),parse:yz(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+xz.transform(e)+`, `+xz.transform(t)+`, `+xz.transform(n)+`, `+az(pz.transform(r))+`)`};function Cz(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var wz={test:vz(`#`),parse:Cz,transform:Sz.transform},Tz=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Ez=Tz(`deg`),Dz=Tz(`%`),X=Tz(`px`),Oz=Tz(`vh`),kz=Tz(`vw`),Az={...Dz,parse:e=>Dz.parse(e)/100,transform:e=>Dz.transform(e*100)},jz={test:vz(`hsl`,`hue`),parse:yz(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+Dz.transform(az(t))+`, `+Dz.transform(az(n))+`, `+az(pz.transform(r))+`)`},Mz={test:e=>Sz.test(e)||wz.test(e)||jz.test(e),parse:e=>Sz.test(e)?Sz.parse(e):jz.test(e)?jz.parse(e):wz.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Sz.transform(e):jz.transform(e),getAnimatableNone:e=>{let t=Mz.parse(e);return t.alpha=0,Mz.transform(t)}},Nz=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,Pz=new RegExp(hz.source),Fz=new RegExp(Nz.source,`i`);function Iz(e){return isNaN(e)&&typeof e==`string`&&(Pz.test(e)||Fz.test(e))}var Lz=`number`,Rz=`color`,zz=`var`,Bz=`var(`,Vz="${}",Hz=/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 Uz(e){let t=e.toString();return Pz.test(t)||Fz.test(t)}function Wz(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(Hz,e=>(Mz.test(e)?(r.color.push(a),i.push(Rz),n.push(Mz.parse(e))):e.startsWith(Bz)?(r.var.push(a),i.push(zz),n.push(e)):(r.number.push(a),i.push(Lz),n.push(parseFloat(e))),++a,Vz)).split(Vz),indexes:r,types:i}}function Gz(e){return Wz(e).values}function Kz({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===Lz?az(r[a]):e===Rz?Mz.transform(r[a]):r[a]}return i}}function qz(e){return Kz(Wz(e))}var Jz=e=>typeof e==`number`?0:Mz.test(e)?Mz.getAnimatableNone(e):e,Yz=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:Jz(e);function Xz(e){let t=Wz(e);return Kz(t)(t.values.map((e,n)=>Yz(e,t.split[n])))}var Zz={test:Iz,parse:Gz,createTransformer:qz,getAnimatableNone:Xz};function Qz(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 $z({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=Qz(s,r,e+1/3),a=Qz(s,r,e),o=Qz(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function eB(e,t){return n=>n>0?t:e}var tB=(e,t,n)=>e+(t-e)*n,nB=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},rB=[wz,Sz,jz],iB=e=>rB.find(t=>t.test(e));function aB(e){let t=iB(e);if(!t)return`${e}`,!1;let n=t.parse(e);return t===jz&&(n=$z(n)),n}var oB=(e,t)=>{let n=aB(e),r=aB(t);if(!n||!r)return eB(e,t);let i={...n};return e=>(i.red=nB(n.red,r.red,e),i.green=nB(n.green,r.green,e),i.blue=nB(n.blue,r.blue,e),i.alpha=tB(n.alpha,r.alpha,e),Sz.transform(i))},sB=new Set([`none`,`hidden`]);function cB(e,t){return sB.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function lB(e,t){return n=>tB(e,t,n)}function uB(e){return typeof e==`number`?lB:typeof e==`string`?lz(e)?eB:Mz.test(e)?oB:mB:Array.isArray(e)?dB:typeof e==`object`?Mz.test(e)?oB:fB:eB}function dB(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>uB(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function fB(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=uB(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function pB(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 mB=(e,t)=>{let n=Zz.createTransformer(t),r=Wz(e),i=Wz(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?sB.has(e)&&!i.values.length||sB.has(t)&&!r.values.length?cB(e,t):AR(dB(pB(r,i),i.values),n):(`${e}${t}`,eB(e,t))},hB=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function gB(e,t){let n=hB.exec(e);if(!n)return;let r=hB.exec(t);if(!r||n[2]!==r[2])return;let i=n[2],a=parseFloat(n[1]),o=parseFloat(r[1]);return e=>az(tB(a,o,e))+i}function _B(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return tB(e,t,n);if(typeof e==`string`&&typeof t==`string`){let n=gB(e,t);if(n)return n}return uB(e)(e,t)}var vB=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function yB(e){let t=new Set,n=new Set,r=!1,i=!1,a=new Set,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(n.add(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var bB=40;function xB(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0,a=()=>r=!0,o=vB.reduce((e,t)=>(e[t]=yB(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=wR.useManualTiming,o=a?n.timestamp:performance.now();r=!1,a||(n.delta=i?1e3/60:Math.max(Math.min(o-n.timestamp,bB),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:vB.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<vB.length;t++)o[vB[t]].cancel(e)},state:n,steps:o}}var{schedule:SB,cancel:CB,steps:wB}=xB(typeof requestAnimationFrame<`u`?requestAnimationFrame:kR,!0,tz),TB=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>SB.update(t,e),stop:()=>CB(t),now:()=>tz.isProcessing?tz.timestamp:iz.now()}},EB=(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)})`},DB=2e4;function OB(e,t=50,n=DB,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 kB(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(OB(o),DB);return{type:`keyframes`,ease:e=>o.next(s*e).value/t,duration:PR(s)}}var AB={stiffness:100,damping:10,mass:1,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05},jB=e=>e<0?1/Math.max(1+e,AB.minDamping):Math.max(1-e,AB.minDamping);function MB(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 FB(e=>i*Math.exp(-r*e)-r*Math.exp(-i*e)-a,e=>Math.exp(-i*e)-Math.exp(-r*e),t)/t}function NB(e,t){return e*Math.sqrt(1-t*t)}var PB=12;function FB(e,t,n){let r=n;for(let n=1;n<PB;n++)r-=e(r)/t(r);return r}var IB=.001;function LB({duration:e=AB.duration,bounce:t=AB.bounce}){let n,r;AB.maxDuration;let i=jB(t);e=CR(AB.minDuration,AB.maxDuration,PR(e)),i<1?(n=t=>{let n=t*i,r=n*e,a=NB(t,i),o=Math.exp(-r);return IB-n/a*o},r=t=>{let r=t*i*e,a=i*i*t*t*e,o=Math.exp(-r),s=NB(t*t,i);return(-n(t)+IB>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=FB(n,r,a),s=o*MB(i,o*e),c=s*s;return{stiffness:c,damping:i*2*Math.sqrt(c),duration:NR(e)}}var RB=(e,t)=>(t?e>=0:e>0)&&e<1/0;function zB(e,t){if(RB(e,t))return e}function BB(e){let t=zB(e.stiffness),n=zB(e.damping,!0),r=zB(e.mass),i={...e,stiffness:t??AB.stiffness,damping:n??AB.damping,mass:r??AB.mass,isResolvedFromDuration:!1,isTimeDefined:(t??n??r)===void 0&&(e.duration!==void 0||e.bounce!==void 0)};if(i.isTimeDefined){if(e.visualDuration){let t=jB(e.bounce||0),n=2*Math.PI/(e.visualDuration*1.2)*MB(t,2*Math.PI/1.2);i.stiffness=n*n,i.damping=2*t*Math.sqrt(i.stiffness)}else Object.assign(i,LB(i)),i.isResolvedFromDuration=!0;(!RB(i.stiffness)||!RB(i.damping,!0))&&(i.stiffness=AB.stiffness,i.damping=AB.damping)}return i}function VB(e=AB.visualDuration,t=AB.bounce){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}=BB({...n}),f=e=>d?0:-PR(e),p=s/(2*Math.sqrt(o*c)),m=PR(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?AB.restSpeed.granular:AB.restSpeed.default),g.restDelta=n.restDelta||(e?AB.restDelta.granular:AB.restDelta.default)};_();let v,y,b;if(p<1){let e=NB(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=d?1/0:300/e,i=(e,t)=>Math.exp(t>r?-e*r-h*(t-r):-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=>NR(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=NR(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(OB(S),DB),t=EB(t=>S.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return S}VB.applyToOptions=e=>{let t=kB(e,100,VB);return e.ease=t.ease,e.duration=NR(t.duration),e.type=`keyframes`,e};function HB({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===void 0?g:o(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?_:_+t},b,x,S=e=>{p(f.value)&&(b=e,x=VB({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 UB(e,t,n){let r=[],i=n||wR.mix||_B,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=AR(Array.isArray(t)?t[n]||kR:t,a)),r.push(a)}return r}function WB(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,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=UB(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=jR(e[r],e[r+1],n);return s[r](i)};return n?t=>l(CR(e[0],e[a-1],t)):l}function GB(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=jR(0,t,r);e.push(tB(n,1,i))}}function KB(e){let t=[0];return GB(t,e.length-1),t}function qB(e,t){return e.map(e=>e*t)}function JB(e,t){return e.map(()=>t||YR).splice(0,e.length-1)}function YB({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=XR(r)?r.map(ez):ez(r)||YR,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:(wR.mix||_B)(n,r);return{calculatedDuration:e,next:t=>(a.value=o?o(i(e>0?CR(0,1,t/e):1)):r,a.done=t>=e,a)}}let o=WB(qB(n&&n.length===t.length?n:KB(t),e),t,{ease:Array.isArray(i)?i:JB(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var XB=5;function ZB(e,t,n){let r=Math.max(t-XB,0);return FR(n-e(r),t-r)}function QB(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):ZB(t=>e.next(t).value,t,e.next(t).value)}var $B=e=>e!==null;function eV(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter($B),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var tV={decay:HB,inertia:HB,tween:YB,keyframes:YB,spring:VB};function nV(e){typeof e.type==`string`&&(e.type=tV[e.type])}var rV=40,iV=(e,t)=>t-e>rV&&!wR.useManualTiming?t:e;function aV(e,t){return{kind:e,animation:t,timestamp:iz.now(),frameTimestamp:tz.timestamp,frameIsProcessing:tz.isProcessing}}function oV(e,t,n){let r=globalThis.__MOTION_INSPECT__;if(r)try{r({...aV(`animation-start`,e),options:n?{...t,...n}:t})}catch{}}function sV(e,t){let n=globalThis.__MOTION_INSPECT__;if(n)try{n({...aV(`layout-animation-start`,e),node:t})}catch{}}var cV=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)}},lV=e=>e/100,uV=e=>Math.round(e*1e4)/1e4,dV=class extends cV{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!==iz.now()&&this.tick(iz.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),oV(this,this.options)}initAnimation(){let{options:e}=this;nV(e);let{type:t=YB,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||YB;s!==YB&&typeof o[0]!=`number`&&(this.mixKeyframes=AR(lV,_B(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=OB(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.currentTime=this.holdTime===null?t:this.holdTime}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=iV(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&&i!==null&&(p=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let m=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&p);return m&&s!==HB&&(f.value=eV(o,this.options,l,this.speed)),c&&c(f.value),m&&this.finish(),f}at(e){return this.holdTime??uV((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!==HB?eV(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=CR(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}then(e,t){return this.finished.then(e,t)}get duration(){return PR(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+PR(e)}get time(){return PR(this.currentTime)}set time(e){e=NR(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 QB(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(iz.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=PR(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=TB,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(iz.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.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}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)}},fV=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function pV(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(hz)||[];if(!r)return e;let i=n.replace(r,``),a=+!!fV.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var mV=/\b([a-z-]*)\(.*?\)/gu,hV={...Zz,getAnimatableNone:e=>{let t=e.match(mV);return t?t.map(pV).join(` `):e}},gV={...Zz,getAnimatableNone:e=>{let t=Zz.parse(e);return Zz.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},_V={...fz,transform:Math.round},vV={borderWidth:X,borderTopWidth:X,borderRightWidth:X,borderBottomWidth:X,borderLeftWidth:X,borderRadius:X,borderTopLeftRadius:X,borderTopRightRadius:X,borderBottomRightRadius:X,borderBottomLeftRadius:X,width:X,maxWidth:X,height:X,maxHeight:X,top:X,right:X,bottom:X,left:X,inset:X,insetBlock:X,insetBlockStart:X,insetBlockEnd:X,insetInline:X,insetInlineStart:X,insetInlineEnd:X,padding:X,paddingTop:X,paddingRight:X,paddingBottom:X,paddingLeft:X,paddingBlock:X,paddingBlockStart:X,paddingBlockEnd:X,paddingInline:X,paddingInlineStart:X,paddingInlineEnd:X,margin:X,marginTop:X,marginRight:X,marginBottom:X,marginLeft:X,marginBlock:X,marginBlockStart:X,marginBlockEnd:X,marginInline:X,marginInlineStart:X,marginInlineEnd:X,fontSize:X,backgroundPositionX:X,backgroundPositionY:X,rotate:Ez,pathRotation:Ez,rotateX:Ez,rotateY:Ez,rotateZ:Ez,scale:mz,scaleX:mz,scaleY:mz,scaleZ:mz,skew:Ez,skewX:Ez,skewY:Ez,distance:X,translateX:X,translateY:X,translateZ:X,x:X,y:X,z:X,perspective:X,transformPerspective:X,opacity:pz,originX:Az,originY:Az,originZ:X,zIndex:_V,fillOpacity:pz,strokeOpacity:pz,numOctaves:_V},yV={...vV,color:Mz,backgroundColor:Mz,outlineColor:Mz,fill:Mz,stroke:Mz,borderColor:Mz,borderTopColor:Mz,borderRightColor:Mz,borderBottomColor:Mz,borderLeftColor:Mz,filter:hV,WebkitFilter:hV,mask:gV,WebkitMask:gV},bV=e=>yV[e],xV=new Set([hV,gV]);function SV(e,t){let n=bV(e);return xV.has(n)||(n=Zz),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function CV(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var wV=e=>e*180/Math.PI,TV=e=>DV(wV(Math.atan2(e[1],e[0]))),EV={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:TV,rotateZ:TV,skewX:e=>wV(Math.atan(e[1])),skewY:e=>wV(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},DV=e=>(e%=360,e<0&&(e+=360),e),OV=TV,kV=e=>Math.hypot(e[0],e[1]),AV=e=>Math.hypot(e[4],e[5]),jV={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:kV,scaleY:AV,scaleZ:e=>Math.hypot(e[8],e[9],e[10]),scale:e=>(kV(e)+AV(e))/2,rotateX:e=>DV(wV(Math.atan2(e[6],e[5]))),rotateY:e=>DV(wV(Math.atan2(-e[2],e[0]))),rotateZ:OV,rotate:OV,skewX:e=>wV(Math.atan(e[4])),skewY:e=>wV(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function MV(e){return+!!e.includes(`scale`)}function NV(e,t){if(!e||e===`none`)return MV(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=jV,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=EV,i=t}if(!i)return MV(t);let a=r[t],o=i[1].split(`,`).map(FV);return typeof a==`function`?a(o):o[a]}var PV=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return NV(n,t)};function FV(e){return parseFloat(e.trim())}var IV=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`scaleZ`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],LV=new Set([...IV,`pathRotation`]),RV=e=>e===fz||e===X,zV=new Set([`x`,`y`,`z`]),BV=IV.filter(e=>!zV.has(e));function VV(e){let t=[];return BV.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 HV=new Set([`bottom`,`right`]);function UV(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 WV={width:({width:e,paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r},i)=>UV(e,i,`x`,t,n,r),height:({height:e,paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r},i)=>UV(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:({transform:e})=>NV(e,`x`),y:({transform:e})=>NV(e,`y`)};WV.translateX=WV.x,WV.translateY=WV.y;var GV=new Set,KV=!1,qV=!1,JV=!1;function YV(){if(qV){let e=[],t=new Set,n=new Set;GV.forEach(r=>{r.needsMeasurement&&(e.push(r),t.add(r.element),HV.has(r.name)&&n.add(r.element))});let r=new Map;n.forEach(e=>{let t=VV(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)})}qV=!1,KV=!1,GV.forEach(e=>e.complete(JV)),GV.clear()}function XV(){GV.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(qV=!0)})}function ZV(){JV=!0,XV(),YV(),JV=!1}function QV(e,t,n){if(typeof e==`string`){if(TR(e)||DR(e))return parseFloat(e);if(!Zz.test(e)&&Zz.test(n))return SV(t,n)}return e??void 0}var $V=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?(GV.add(this),KV||(KV=!0,SB.read(XV),SB.resolveKeyframes(YV))):(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=QV(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])}CV(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),GV.delete(this)}cancel(){this.state===`scheduled`&&(GV.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},eH=e=>e.startsWith(`--`);function tH(e,t,n){eH(t)?e.style.setProperty(t,n):e.style[t]=n}var nH={};function rH(e,t){let n=OR(e);return()=>nH[t]??n()}var iH=rH(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),aH=rH(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),oH=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,sH={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:oH([0,.65,.55,1]),circOut:oH([.55,0,1,.45]),backIn:oH([.31,.01,.66,-.59]),backOut:oH([.33,1.53,.69,.99])};function cH(e,t){if(e)return typeof e==`function`?aH()?EB(e,t):`ease-out`:ZR(e)?oH(e):Array.isArray(e)?e.map(e=>cH(e,t)||sH.easeOut):sH[e]}function lH(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=cH(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 uH(e){return typeof e==`function`&&`applyToOptions`in e}function dH({type:e,...t}){return uH(e)&&aH()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var fH=class extends cV{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,e.type;let c=dH(e);this.animation=lH(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=eV(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),tH(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()},oV(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(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e!==`idle`&&e!==`finished`&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||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 PR(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+PR(e)}get time(){return PR(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=NR(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&&iH()?(this.animation.timeline=e,t?.(this.animation),kR):n(this)}},pH={anticipate:UR,backInOut:HR,circInOut:KR};function mH(e){return e in pH}function hH(e){typeof e.ease==`string`&&mH(e.ease)&&(e.ease=pH[e.ease])}var gH=class extends fH{constructor(e){hH(e),nV(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}elapsed(){return this.state===`running`?(iz.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 dV({...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?CR(0,10,a):0,s=this.sample(a);n&&r&&tH(n,r,s),t.setWithVelocity(this.sample(a-o*Math.sign(i)),s,o/Math.abs(i||1))}},_H=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Zz.test(e)||e===`0`)&&!e.startsWith(`url(`));function vH(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 yH(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=_H(i,t),s=_H(a,t);return!o||!s?(o!==s&&`${t}${i}${a}${o?a:i}`,!1):vH(e)||(n===`spring`||uH(n))&&r}function bH(e){e.duration=0,e.type=`keyframes`}var xH=new Set([`opacity`,`clipPath`,`filter`,`transform`,`backgroundColor`]),SH=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function CH(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&SH.test(e[t]))return!0;return!1}var wH=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),TH=OR(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function EH(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!n||!(xH.has(n)||wH.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 TH()&&(xH.has(n)||wH.has(n)&&CH(s))&&(n!==`transform`||!u)&&!l&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var DH=(e,t)=>t&&typeof e==`number`?t.transform(e):e,OH={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},kH=IV.length;function AH(e,t,n){let r=``,i=!0;for(let a=0;a<kH;a++){let o=IV[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=DH(s,vV[o]);if(!c){i=!1;let t=OH[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${DH(a,vV.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}var jH=new WeakMap,MH=200,NH=.001,PH=.1,FH=.001,IH=100,LH=e=>/^(linear|ease(In|Out|InOut))$/.test(e),RH=(e,t)=>e-t,zH=(e,t,n)=>{let r=[];for(let i=0;i<=n;i++)r.push(tB(e,t,i/n));return r},BH=e=>e.motionValue.owner,VH=e=>jH.get(e),HH=(e,t)=>e.latestValues?e.latestValues[t]:e.getValue(t)?.get(),UH=({name:e,motionValue:t})=>e&&IV.includes(e)&&t?.owner?.current instanceof HTMLElement&&TH()&&aH();function WH(e){let t=BH(e),{onUpdate:n,transformTemplate:r}=t.getProps();return!e.isHandoff&&!n&&!e.hasOnUpdate&&!r&&e.type!==`inertia`&&(HH(t,`transform`)||`none`)===`none`&&!HH(t,`pathRotation`)&&!t.projection?.isProjecting()}var GH=class extends dV{constructor(e){let t=BH(e).current,{driver:n=TB}=e,r=WH(e);e.driver=e=>{let r=n(e);return{js:r,now:r.now,start:(e=!0)=>{let n=VH(t);!n||n.isJS?r.start(e):n.schedule(!1,!e)},stop:()=>{r.stop();let e=VH(t);e?.schedule(!e.isFinishing)}}},super(e),this.canAccelerate=r;let{stop:i}=this;this.stop=()=>{this.isAccelerated()&&this.sync(),i()}}get group(){return VH(BH(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(iz.now()):void 0}tween(){let{keyframes:e,type:t,ease:n,times:r,repeat:i,delay:a=0}=this.options,o=ZR(n)?oH(n):LH(n)&&sH[n];if(o&&!i&&!r&&e.length===2&&t===YB&&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||YB)===YB?u||KB(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=iz.now();this.options.motionValue.setWithVelocity(this.sampleAt(e-10,!0),this.sampleAt(e,!0),10)}play(){this.isStopped||((this.group||KH(BH(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(iz.now())}get time(){return this.isAccelerated()?PR(CR(0,this.totalDuration,this.at(iz.now())-(this.options.delay||0))):super.time}set time(e){super.time=e}attachTimeline(e){return this.canAccelerate=!1,this.group?.demote(!0),super.attachTimeline(e)}};function KH(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/0,f=e=>{for(let t of n)if(t.name===e)return!0},p=(t,n)=>{let o={};for(let s of t===void 0?IV:a){let a=r.get(s),c=t===void 0?HH(e,s):a?a.sampleAt(n>t&&!a.timing()[1]?n:t):i[s];c!==void 0&&(o[s]=c)}return o},m=(e,t)=>{let n=``,r=p(e,t);for(let e in r)n+=(OH[e]||e)+`(`+DH(r[e],vV[e])+`) `;return n||`none`},h=(e=p())=>{t.style.transform=AH(e,{})},g=(e=!0)=>{e&&h(),s.forEach(({animation:e})=>e.cancel()),s=[]},_=(e,t,n=1/0)=>{let r={animation:e,offset:t,end:n};e.startTime=iz.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)),E.schedule(!1)}),e.oncancel=()=>s.includes(r)&&E.demote(),s.push(r)},v=(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]:[]},y=(e,t,n,r)=>{let i=Math.min(MH,Math.max(2,Math.ceil((n-t)/10)));if(r.length*4>i)return;let a=zH(t,n,i).concat(r).sort(RH),o=e=>jR(t,n,e),s,c;for(let t of e){let e=a.map(e=>t.numberAt(e)),[n]=e,r=e[e.length-1]-n,i=e.map(e=>r?(e-n)/r:e-n);if(!r){if(i.some(e=>!(Math.abs(e)<=NH)))return}else if(!s)s=i,c=e=>(t.numberAt(e)-n)/r;else if(i.some((e,t)=>!(Math.abs(e-s[t])<=NH)))return}if(!s||s.every((e,t)=>Math.abs(e-o(a[t]))<=NH))return`linear`;let l=[],u=(e,t=c(e))=>l.push(uV(t)+` `+uV(o(e)*100)+`%`);return s.forEach((e,t)=>{t&&Math.abs(e-s[t-1])>.2&&v(c,a[t-1],a[t]).forEach(e=>u(e)),u(a[t],e)}),`linear(`+l+`)`},b=(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`)?FH:PH))),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(...v(e=>r.numberAt(e),t,n));i.push(n)}},s=zH(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(RH))e>c&&o(c,e,0),c=e;return i.sort(RH)},x=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},S=(e,n,r,i={fill:`both`},a,o)=>{let s=e.flatMap(e=>e.boundaries(n,r)),c=o||y(e,n,r,s),l=c?[n,r]:b(e,n,r,s),u=l.map(e=>m(e,a)),d={transform:u};return c||(d.offset=l.map(e=>jR(n,r,e))),u.every(e=>e===u[0])&&(h(p(n,a)),d=null),t.animate(d,{...i,duration:r-n,easing:c||`linear`})},C=c=>{let l=c,u=0,d=0,f=[],p=[],m=new Set;r.clear(),o=new Map;for(let e of n){r.set(e.name,e);let[t,n]=e.timing(),i=t===1/0;if(o.set(e,[e.at(c),e.speed,i]),i)e.sync();else{if(e.speed<0)return;if(n){if(u){let e=(t-d)/n;if(Math.abs(n-u)>1||Math.abs(e-Math.round(e))*u>1)return}else u=n,d=t;p.push(e)}else m.add(t);f.push(e),l=Math.max(l,t)}}i={},a=IV.filter(t=>{if(r.has(t))return!0;let n=i[t]=HH(e,t);return n!==void 0&&parseFloat(n)!==+!!t.startsWith(`scale`)}),g(!1);let h=!u&&x(f);try{if(h&&h[1]>c){let[e,t,n]=h;_(S(f,e,t,void 0,void 0,n),e-c,t-e)}else l>c&&(_(S(f,c,l),0,l-c),m.forEach(e=>e<l-1&&_(t.animate(null,{duration:e-c}),0,e-c)));if(u){let e=d+Math.floor((l-d)/u)*u;_(S(p,e,e+u,{iterations:1/0,iterationStart:(l-e)/u,fill:`forwards`},l),l-c)}}catch{return}return s.length||g(),!0},w=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.playbackRate=r,n.startTime=e-o/r):(n.pause(),n.currentTime=o)}return!0},T=()=>{let r=iz.now();if(E.isJS||(E.isFinishing=!0,n.forEach(t=>{let[n,a]=t.timing();t.state===`running`&&t.speed>0&&!a&&n<=r+1&&(t.complete(),i[t.name]=HH(e,t.name),o.has(t)||(c=!0))}),E.isFinishing=!1),l=!1,n.forEach(({state:e},t)=>{(e===`idle`||e===`finished`)&&n.delete(t)}),!n.size){jH.delete(t),E.isJS||g();return}for(let e of n)if(!e.canAccelerate)return E.demote(!0);E.isJS&&(E.isJS=!1,c=!0,n.forEach(e=>e.js?.stop()));let a=c,s=u;if(c=u=!1,a||!w(r)){if(s){if(r-d<IH)return E.demote();d=r}if(!C(r))return E.demote()}},E={tracks:n,isJS:!1,isFinishing:!1,schedule(e,t){c||=e,u||=!!t,l||(l=!0,tz.isProcessing?SB.render(T,!1,!0):queueMicrotask(T))},check(){if(!E.isJS){for(let t in i)if(HH(e,t)!==i[t]&&!f(t))return E.schedule(!0,!0)}},demote(e){E.isJS||(n.forEach(t=>{t.isAccelerated()&&t.sync(),e||(t.canAccelerate=!1)}),E.isJS=!0,o=new Map,g(),n.forEach(e=>e.state===`running`&&e.js?.start()))}};return jH.set(t,E),E}var qH=class extends cV{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=iz.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||$V;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=iz.now();let u=!0;yH(e,i,a,o)||(u=!1,(wR.instantAnimations||!s)&&l?.(eV(e,n,t)),e[0]=e[e.length-1],bH(n),n.repeat=0);let{onComplete:d}=n;n.finalKeyframe=t,n.keyframes=e,n.onComplete=()=>{d?.(),this.notifyFinished()};let f=u&&!c&&EH(n),p=!f&&UH(n);r&&(f||p||this.resolvedAt!==this.createdAt)&&(n.startTime??=iV(this.createdAt,this.resolvedAt));let m;if(f){n.element=n.motionValue?.owner?.current;try{m=new gH(n)}catch{m=new dV(n)}}else m=p?new GH(n):new dV(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(),ZV()),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&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function JH(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 YH=30,XH=e=>!isNaN(parseFloat(e)),ZH={current:void 0},QH=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=iz.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.notifyChange(),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=iz.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=XH(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 MR)).add(t)}onChangeSubscribe(e){let{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new MR,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(){SB.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&&this.stopPassiveEffect()}dirty(){this.notifyChange()}notifyChange(){let{current:e,changeSubscriber:t}=this;t?t(e):this.events.change?.notify(e)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){ZH.current&&ZH.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=iz.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>YH)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,YH);return FR(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.clearAnimation(),t()}),n||(this.animation=r),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){this.animation=void 0}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function $H(e,t){return new QH(e,t)}function eU(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function tU(e,t){let n=e?.[t]??e?.default??e;return n===e?n:eU(n,e)}var nU={type:`spring`,stiffness:500,damping:25,restSpeed:10},rU=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),iU={type:`keyframes`,duration:.8},aU={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},oU=(e,{keyframes:t})=>t.length>2?iU:LV.has(e)?e.startsWith(`scale`)?rU(t[1]):nU:aU,sU=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function cU(e){for(let t in e)if(!sU.has(t))return!0;return!1}var lU=(e,t,n,r={},i,a)=>o=>{let s=tU(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=NR(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};cU(s)||Object.assign(u,oU(e,u)),u.duration&&=NR(u.duration),u.repeatDelay&&=NR(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(bH(u),u.delay===0&&(d=!0)),(wR.instantAnimations||wR.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,bH(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=eV(u.keyframes,s);if(e!==void 0){SB.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new dV(u):new qH(u)},uU=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function dU(e){let t=uU.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function fU(e,t,n=1){`${e}`;let[r,i]=dU(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return TR(e)?parseFloat(e):e}return lz(i)?fU(i,t,n+1):i}function pU(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function mU(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...pU(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function hU(e,t,n){return mU(e.getProps(),t,n,e)}var gU=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,_U=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...IV]),vU=e=>Array.isArray(e);function yU(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,$H(n))}function bU(e){return vU(e)?e[e.length-1]||0:e}function xU(e,t){let{transitionEnd:n={},transition:r={},...i}=hU(e,t)||{};i={...i,...n};for(let t in i)yU(e,t,bU(i[t]))}var SU=e=>!!(e&&e.getVelocity);function CU(e){return!!(SU(e)&&e.add)}function wU(e,t){let n=e.getValue(`willChange`);if(CU(n))return n.add(t);if(!n&&wR.WillChange){let n=new wR.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function TU(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var EU=`data-`+TU(`framerAppearId`);function DU(e){return e.props[EU]}var OU=typeof window<`u`;function kU({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function AU(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?eU(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.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&&kU(f,t))continue;let o={delay:n,...tU(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){SB.update(()=>r.set(i));continue}let p=!1;if(OU&&window.MotionHandoffAnimation){let n=DU(e);if(n){let e=window.MotionHandoffAnimation(n,t,SB);e!==null&&(o.startTime=e,p=!0)}}wU(e,t);let m=l??e.shouldReduceMotion;r.start(lU(t,r,i,m&&_U.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>SB.update(()=>{o&&xU(e,o)});d.length?Promise.all(d).then(t):t()}return d}function jU(e,t,n={}){let r=hU(e,t,gU(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?AU(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(jU(e,t,{...n,delay:r+(typeof o==`function`?0:o)+JH(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 MU(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>jU(e,t,n))):typeof t==`string`?jU(e,t,n):Promise.all(AU(e,hU(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var NU={test:e=>e===`auto`,parse:e=>e},PU=e=>t=>t.test(e),FU=[fz,X,Dz,Ez,kz,Oz,NU],IU=e=>FU.find(PU(e));function LU(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||DR(e)}var RU=new Set([`auto`,`none`,`0`]);function zU(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!RU.has(t)&&Uz(t)&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]!==i&&(e[r]=SV(n,i))}var BU=class extends $V{constructor(e,t,n,r,i){super(e,t,n,r,i,!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(dz(t?e[t]:r))return!1;return!0}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),lz(r))){let i=fU(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!_U.has(n)||e.length!==2)return;let[r,i]=e;if(typeof r==`number`&&typeof i==`number`)return;let a=IU(r),o=IU(i);if(dz(r)!==dz(i)&&WV[n])this.needsMeasurement=!0;else if(a!==o){if(RV(a)&&RV(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else WV[n]&&(this.needsMeasurement=!0)}}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||LU(e[t]))&&n.push(t);n.length&&zU(e,n,t)}measure(){let{element:e,name:t}=this;return WV[t](window.getComputedStyle(e.current),()=>e.measureViewportBox())}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!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||!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.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},VU=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function HU(e){return ER(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function UU(e){return ER(e)&&`ownerSVGElement`in e}function WU(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}function GU(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(LV.has(e))o=!0;else if(sz(e))i[e]=n;else{let t=DH(n,vV[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=AH(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 KU={offset:`stroke-dashoffset`,array:`stroke-dasharray`},qU={offset:`strokeDashoffset`,array:`strokeDasharray`};function JU(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?KU:qU;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var YU=[`transform`,`opacity`,`clipPath`,`filter`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function XU(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(GU(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 YU)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&&JU(d,i,a,o,!1)}function ZU({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function QU({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function $U(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 eW(e){return e===void 0||e===1}function tW({scale:e,scaleX:t,scaleY:n}){return!eW(e)||!eW(t)||!eW(n)}function nW(e){return tW(e)||rW(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function rW(e){return iW(e.x)||iW(e.y)}function iW(e){return e&&e!==`0%`}function aW(e,t,n){return n+t*(e-n)}function oW(e,t,n,r,i){return i!==void 0&&(e=aW(e,i,r)),aW(e,n,r)+t}function sW(e,t=0,n=1,r,i){e.min=oW(e.min,t,n,r,i),e.max=oW(e.max,t,n,r,i)}function cW(e,{x:t,y:n}){sW(e.x,t.translate,t.scale,t.originPoint),sW(e.y,n.translate,n.scale,n.originPoint)}var lW=.999999999999,uW=1.0000000000001;function dW(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;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(fW(e.x,-a.scroll.offset.x),fW(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,cW(e,o)),r&&nW(a.latestValues)&&hW(e,a.latestValues,a.layout?.layoutBox))}t.x<uW&&t.x>lW&&(t.x=1),t.y<uW&&t.y>lW&&(t.y=1)}function fW(e,t){e.min+=t,e.max+=t}function pW(e,t,n,r,i=.5){sW(e,t,n,tB(e.min,e.max,i),r)}function mW(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function hW(e,t,n){let r=n??e;pW(e.x,mW(t.x,r.x),t.scaleX,t.scale,t.originX),pW(e.y,mW(t.y,r.y),t.scaleY,t.scale,t.originY)}function gW(e,t){return ZU($U(e.getBoundingClientRect(),t))}function _W(e,t,n){let r=gW(e,n),{scroll:i}=t;return i&&(fW(r.x,i.offset.x),fW(r.y,i.offset.y)),r}var{schedule:vW,cancel:Bae}=xB(queueMicrotask,!1),yW={x:!1,y:!1};function bW(){return yW.x||yW.y}function xW(e){return e===`x`||e===`y`?yW[e]?null:(yW[e]=!0,()=>{yW[e]=!1}):yW.x||yW.y?null:(yW.x=yW.y=!0,()=>{yW.x=yW.y=!1})}function SW(e,t){let n=WU(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function CW(e){return!(e.pointerType===`touch`||bW())}function wW(e,t,n={}){let[r,i,a]=SW(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(!CW(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 TW=(e,t)=>t?e===t||TW(e,t.parentElement):!1,EW=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,DW=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function OW(e){return DW.has(e.tagName)||e.isContentEditable===!0}var kW=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function AW(e){return kW.has(e.tagName)||e.isContentEditable===!0}var jW=new WeakSet;function MW(e){return t=>{t.key===`Enter`&&e(t)}}function NW(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var PW=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=MW(()=>{if(jW.has(n))return;NW(n,`down`);let e=MW(()=>{NW(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>NW(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function FW(e){return EW(e)&&!bW()}var IW=new WeakSet;function LW(e,t,n={}){let[r,i,a]=SW(e,n),o=e=>{let r=e.currentTarget;if(!FW(e)||IW.has(e))return;jW.add(r),n.stopPropagation&&IW.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),jW.has(r)&&jW.delete(r),FW(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||TW(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),HU(e)&&(e.addEventListener(`focus`,e=>PW(e,i)),!OW(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}var RW=new WeakMap,zW,BW=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:UU(r)&&`getBBox`in r?r.getBBox()[t]:r[n],VW=BW(`inline`,`width`,`offsetWidth`),HW=BW(`block`,`height`,`offsetHeight`);function UW({target:e,borderBoxSize:t}){RW.get(e)?.forEach(n=>{n(e,{get width(){return VW(e,t)},get height(){return HW(e,t)}})})}function WW(e){e.forEach(UW)}function GW(){typeof ResizeObserver<`u`&&(zW=new ResizeObserver(WW))}function KW(e,t){zW||GW();let n=WU(e);return n.forEach(e=>{let n=RW.get(e);n||(n=new Set,RW.set(e,n)),n.add(t),zW?.observe(e)}),()=>{n.forEach(e=>{let n=RW.get(e);n?.delete(t),n?.size||zW?.unobserve(e)})}}var qW=new Set,JW;function YW(){JW=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};qW.forEach(t=>t(e))},window.addEventListener(`resize`,JW)}function XW(e){return qW.add(e),JW||YW(),()=>{qW.delete(e),!qW.size&&typeof JW==`function`&&(window.removeEventListener(`resize`,JW),JW=void 0)}}function ZW(e,t){return typeof e==`function`?XW(e):KW(e,t)}var QW={value:null,addProjectionMetrics:null};function $W(e){return UU(e)&&e.tagName===`svg`}function eG(...e){let t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],i=e[1+n],a=e[2+n],o=e[3+n],s=WB(i,a,o);return t?s(r):s}var tG=e=>typeof e==`number`?e:parseFloat(e),nG=()=>({translate:0,scale:1,origin:0,originPoint:0}),rG=()=>({x:nG(),y:nG()}),iG=()=>({min:0,max:0}),aG=()=>({x:iG(),y:iG()}),oG=new WeakMap;function sG(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function cG(e){return typeof e==`string`||Array.isArray(e)}var lG=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],uG=[`initial`,...lG];function dG(e){if(sG(e.animate))return!0;for(let t=0;t<uG.length;t++)if(cG(e[uG[t]]))return!0;return!1}function fG(e){return!!(dG(e)||e.variants)}function pG(e,t,n){for(let r in t){let i=t[r],a=n[r];if(SU(i))e.addValue(r,i);else if(SU(a))e.addValue(r,$H(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,$H(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var mG={current:null},hG={current:!1},gG=typeof window<`u`;function _G(){if(hG.current=!0,gG){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>mG.current=e.matches;e.addEventListener(`change`,t),t()}else mG.current=!1}}var vG=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],yG={};function bG(e){yG=e}function xG(){return yG}var SG=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=$V,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=iz.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,SB.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=dG(t),this.isVariantNode=fG(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&&SU(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,oG.set(e,this),this.projection&&!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:(hG.current||_G(),this.shouldReduceMotion=mG.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),CB(this.notifyUpdate),CB(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&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,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&xH.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new fH({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:NR(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=LV.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&SB.preRender(this.notifyUpdate),n&&(this.projection&&(this.projection.isTransformDirty=!0),jH.get(this.current)?.check()),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&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 yG){let t=yG[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):aG()}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)&&jH.get(this.current)?.demote(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<vG.length;t++){let n=vG[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=pG(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}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);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=$H(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`&&(TR(n)||DR(n))?n=parseFloat(n):typeof n!=`number`&&!Zz.test(n)&&Zz.test(t)&&(n=SV(e,t)),this.setBaseTarget(e,SU(n)?n.get():n)),SU(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return this.events[e]||(this.events[e]=new MR),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){vW.render(this.render)}},CG=class extends SG{constructor(){super(...arguments),this.KeyframeResolver=BU}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;SU(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},wG=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function TG(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])}var EG={};function DG(e,{layout:t,layoutId:n}){return LV.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!EG[e]||e===`opacity`)}function OG(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(SU(r[t])||i&&SU(i[t])||DG(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function kG(e){return window.getComputedStyle(e)}var AG=class extends CG{constructor(){super(...arguments),this.type=`html`,this.renderInstance=TG}mount(e){e.style,super.mount(e)}readValueFromInstance(e,t){if(LV.has(t))return this.projection?.isProjecting?MV(t):PV(e,t);{let n=kG(e),r=(sz(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return gW(e,t)}build(e,t,n){GU(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return OG(e,t,n)}},jG=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`]),MG=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function NG(e,t,n,r){TG(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(jG.has(n)?n:TU(n),t.attrs[n])}function PG(e,t,n){let r=OG(e,t,n);for(let n in e)if(n!==`children`&&(SU(e[n])||SU(t[n]))){let t=IV.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var FG=class extends CG{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=aG}getBaseTargetFromProps(e,t){return LV.has(t)?super.getBaseTargetFromProps(e,t)??MV(t):e[t]}getDefaultValue(e){return LV.has(e)?this.latestValues[e]??MV(e):void 0}readValueFromInstance(e,t){if(LV.has(t)){let e=bV(t);return e&&e.default||0}if(YU.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=jG.has(t)?t:TU(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return PG(e,t,n)}build(e,t,n){XU(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){NG(e,t,n,r)}mount(e){this.isSVGTag=MG(e.tagName),super.mount(e)}};function IG(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 LG=[...lG].reverse();function RG(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>MU(e,t,n))),n=BG(),r=!0,i=!1;function a(a){let{props:o,parent:s,manuallyAnimateOnMount:c}=e,l=r||i,u=[],d=new Set,f={},p=1/0,m=e;do m=m.props.inherit!==!1&&m.parent;while(m&&!m.isControllingVariants);if(LG.forEach((t,r)=>{let i=n[t],h=o[t],g=m&&m.props[t],_=h===void 0?cG(g)||g===!1?g:void 0:h,v=cG(_),y=t===a?i.isActive:null;y===!1&&(p=r);let b=v&&h===void 0&&!(l&&c);if(i.protectedKeys={...f},!i.isActive&&y===null||!_&&!i.prevProp||sG(_)||typeof _==`boolean`)return;if(t===`exit`&&i.isActive&&y!==!0){f={...f,...i.prevResolvedValues};return}let x=zG(i.prevProp,_),S=x||v&&(y&&!b||r>p),C=!1,w=Array.isArray(_)?_:[_],T={};if(y!==!1)for(let n of w){let{transition:r,transitionEnd:i,...a}=hU(e,n,gU(e,t))||{};T={...T,...a,...i}}let{prevResolvedValues:E}=i;for(let t in{...E,...T}){if(t in f)continue;let n=T[t],r=E[t],a=Array.isArray(n)&&Array.isArray(r)?!IG(n,r)||x:n!==r;if(a&&n==null)d.add(t);else if(a||n!==void 0&&d.has(t)){S=!0,d.delete(t)&&(C=!0),i.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)}else i.protectedKeys[t]=!0}if(i.prevProp=_,i.prevResolvedValues=T,i.isActive&&(f={...f,...T}),S&&(!(b&&x)||C))for(let n of w){let r={type:t};if(typeof n==`string`&&l&&c&&s?.enteringChildren){let t=hU(s,n)?.transition?.delayChildren;r.delay=JH(s.enteringChildren,e,t)}u.push({animation:n,options:r})}}),d.size){let{initial:t}=o,n={},r=typeof t!=`boolean`&&hU(e,Array.isArray(t)?t[0]:t,e.presenceContext?.custom);r&&r.transition&&(n.transition=r.transition),d.forEach(i=>{let a=e.getValue(i);a&&(a.liveStyle=!0);let s=r&&!Array.isArray(t)?r[i]:void 0,c=e.getBaseTargetFromProps(o,i);n[i]=(s===void 0?c!==void 0&&!SU(c)?c:e.initialValues[i]===void 0?e.baseTarget[i]:void 0:s)??null}),u.push({animation:n})}let h=l&&e.blockInitialAnimation||r&&!c&&(o.initial===!1||o.initial===o.animate);return r=i=!1,!h&&u.length?t(u):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=BG(),i=!0}}}function zG(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!IG(t,e):!1}function BG(){let e={};for(let t of lG)e[t]={isActive:t===`animate`,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}};return e}function VG(e,t){e.min=t.min,e.max=t.max}function HG(e,t){VG(e.x,t.x),VG(e.y,t.y)}function UG(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var WG=.9999,GG=1.0001,KG=-.01,qG=.01;function JG(e){return e.max-e.min}function YG(e,t,n){return Math.abs(e-t)<=n}function XG(e,t,n,r=.5){e.origin=r,e.originPoint=tB(t.min,t.max,e.origin),e.scale=JG(n)/JG(t),e.translate=tB(n.min,n.max,e.origin)-e.originPoint,(e.scale>=WG&&e.scale<=GG||isNaN(e.scale))&&(e.scale=1),(e.translate>=KG&&e.translate<=qG||isNaN(e.translate))&&(e.translate=0)}function ZG(e,t,n,r){XG(e.x,t.x,n.x,r?r.originX:void 0),XG(e.y,t.y,n.y,r?r.originY:void 0)}function QG(e,t,n,r=0){e.min=(r?tB(n.min,n.max,r):n.min)+t.min,e.max=e.min+JG(t)}function $G(e,t,n,r){QG(e.x,t.x,n.x,r?.x),QG(e.y,t.y,n.y,r?.y)}function eK(e,t,n,r=0){let i=r?tB(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+JG(t)}function tK(e,t,n,r){eK(e.x,t.x,n.x,r?.x),eK(e.y,t.y,n.y,r?.y)}function nK(e,t,n,r,i){return e-=t,e=aW(e,1/n,r),i!==void 0&&(e=aW(e,1/i,r)),e}function rK(e,t=0,n=1,r=.5,i,a=e,o=e){if(Dz.test(t)&&(t=parseFloat(t),t=tB(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=tB(a.min,a.max,r);e===a&&(s-=t),e.min=nK(e.min,t,n,s,i),e.max=nK(e.max,t,n,s,i)}function iK(e,t,[n,r,i],a,o){rK(e,t[n],t[r],t[i],t.scale,a,o)}var aK=[`x`,`scaleX`,`originX`],oK=[`y`,`scaleY`,`originY`];function sK(e,t,n,r){iK(e.x,t,aK,n?n.x:void 0,r?r.x:void 0),iK(e.y,t,oK,n?n.y:void 0,r?r.y:void 0)}function cK(e){return e.translate===0&&e.scale===1}function lK(e){return cK(e.x)&&cK(e.y)}function uK(e,t){return e.min===t.min&&e.max===t.max}function dK(e,t){return uK(e.x,t.x)&&uK(e.y,t.y)}function fK(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function pK(e,t){return fK(e.x,t.x)&&fK(e.y,t.y)}function mK(e){return JG(e.x)/JG(e.y)}function hK(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function gK(e){return[e(`x`),e(`y`)]}function _K(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var vK={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if(X.test(e))e=parseFloat(e);else return e}return`${_K(e,t.target.x)}% ${_K(e,t.target.y)}%`}},yK={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Zz.parse(e);if(i.length>5)return r;let a=Zz.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=tB(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 bK(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,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}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`}var xK=VU.length,SK=e=>typeof e==`number`||X.test(e);function CK(e,t,n,r,i,a){i?(e.opacity=tB(0,n.opacity??1,TK(r)),e.opacityExit=tB(t.opacity??1,0,EK(r))):a&&(e.opacity=tB(t.opacity??1,n.opacity??1,r));for(let i=0;i<xK;i++){let a=VU[i],o=wK(t,a),s=wK(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||SK(o)===SK(s)?(e[a]=Math.max(tB(tG(o),tG(s),r),0),(Dz.test(s)||Dz.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=tB(t.rotate||0,n.rotate||0,r))}function wK(e,t){return e[t]===void 0?e.borderRadius:e[t]}var TK=DK(0,.5,GR),EK=DK(.5,.95,kR);function DK(e,t,n){return r=>r<e?0:r>t?1:n(jR(e,t,r))}function OK(e,t,n){let r=SU(e)?e:$H(e);return r.start(lU(``,r,t,n)),r.animation}function kK(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var AK=(e,t)=>e.depth-t.depth,jK=class{constructor(){this.children=[],this.isDirty=!1}add(e){bR(this.children,e),this.isDirty=!0}remove(e){xR(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(AK),this.isDirty=!1,this.children.forEach(e)}};function MK(e,t){let n=iz.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(CB(r),e(a-t))};return SB.setup(r,!0),()=>CB(r)}function NK(e){return SU(e)?e.get():e}var PK=class{constructor(){this.members=[]}add(e){bR(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&&(xR(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(xR(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)}},FK={borderRadius:{...vK,applyTo:[...VU]},borderTopLeftRadius:vK,borderTopRightRadius:vK,borderBottomLeftRadius:vK,borderBottomRightRadius:vK,boxShadow:yK},IK={hasAnimatedSinceResize:!0,hasEverUpdated:!1};Object.assign(EG,{...FK,...EG});var LK={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},RK=[``,`X`,`Y`,`Z`],zK=1e3,BK=0;function VK(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}var HK=({instance:e})=>e&&jH.get(e)?.demote();function UK(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=DU(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,SB,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&UK(r)}function WK({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=BK++,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,QW.value&&(LK.nodes=LK.calculatedTargetDeltas=LK.calculatedProjections=0),this.nodes.forEach(qK),this.nodes.forEach(iq),this.nodes.forEach(aq),this.nodes.forEach(JK),QW.addProjectionMetrics&&QW.addProjectionMetrics(LK)},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 jK)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new MR),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=UU(t)&&!$W(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&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;SB.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=MK(i,250),IK.hasAnimatedSinceResize&&(IK.hasAnimatedSinceResize=!1,this.nodes.forEach(rq)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isAnimationBlocked){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||fq,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!pK(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...tU(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||rq(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),CB(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(oq),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&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&UK(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;HK(this),this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,HK(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(ZK),this.nodes.forEach(XK);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(QK);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(eq),this.nodes.forEach(tq),this.nodes.forEach(nq),this.nodes.forEach(GK),this.nodes.forEach(KK)):this.nodes.forEach(QK),this.clearAllSnapshots();let e=iz.now();tz.delta=CR(0,1e3/60,e-tz.timestamp),tz.timestamp=e,tz.isProcessing=!0,wB.update.process(tz),wB.preRender.process(tz),wB.render.process(tz),tz.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,vW.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(YK),this.sharedNodes.forEach(sq)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,SB.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){SB.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),this.snapshot&&!JG(this.snapshot.measuredBox.x)&&!JG(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||=aG(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout;e&&HK(this);let t=this.projectionDelta&&!lK(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||nW(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)),gq(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return aG();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(vq))){let{scroll:e}=this.root;e&&(fW(t.x,e.offset.x),fW(t.y,e.offset.y))}return t}removeElementScroll(e){let t=aG();if(HG(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&&HG(t,e),fW(t.x,i.offset.x),fW(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||aG();HG(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(fW(r.x,-n.scroll.offset.x),fW(r.y,-n.scroll.offset.y)),nW(n.latestValues)&&hW(r,n.latestValues,n.layout?.layoutBox)}return nW(this.latestValues)&&hW(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=aG();HG(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!nW(n.latestValues))continue;let r;n.instance&&(tW(n.latestValues)&&n.updateSnapshot(),r=aG(),HG(r,n.measurePageBox())),sK(t,n.latestValues,n.snapshot?.layoutBox,r)}return nW(this.latestValues)&&sK(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}}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!==tz.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=tz.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=aG(),this.targetWithTransforms=aG()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),$G(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):HG(this.target,this.layout.layoutBox),cW(this.target,this.targetDelta)):HG(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),QW.value&&LK.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||tW(this.parent.latestValues)||rW(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=aG(),this.relativeTargetOrigin=aG(),tK(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),HG(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===tz.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;HG(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;dW(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=aG());let{target:s}=e;s?(!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(UG(this.prevProjectionDelta.x,this.projectionDelta.x),UG(this.prevProjectionDelta.y,this.projectionDelta.y)),ZG(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!hK(this.projectionDelta.x,this.prevProjectionDelta.x)||!hK(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),QW.value&&LK.calculatedProjections++):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=rG(),this.projectionDelta=rG(),this.projectionDeltaWithTransform=rG()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=rG();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=aG(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!(!c||u||this.options.crossfade!==!0||this.path.some(dq));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=tB(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=tB(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(cq(o.x,e.x,n),cq(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(tK(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),uq(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&dK(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=aG(),HG(f,this.relativeTarget)),c&&(this.animationValues=a,CK(a,i,this.latestValues,n,d,u)),r&&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&&=(CB(this.pendingAnimation),void 0),this.pendingAnimation=SB.update(()=>{IK.hasAnimatedSinceResize=!0,this.motionValue||=$H(0),this.motionValue.jump(0,!1),this.currentAnimation=OK(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()}}),sV(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&&this.mixTargetDelta(zK),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&&_q(this.options.animationType,this.layout.layoutBox,n.layoutBox)){i=this.target||aG();let t=JG(this.layout.layoutBox.x);i.x.min=e.target.x.min,i.x.max=i.x.min+t;let n=JG(this.layout.layoutBox.y);i.y.min=e.target.y.min,i.y.max=i.y.min+n}HG(t,i),hW(t,r),ZG(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new PK),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&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}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&VK(`z`,e,r,this.animationValues);for(let t=0;t<RK.length;t++)VK(`rotate${RK[t]}`,e,r,this.animationValues),VK(`skew${RK[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=NK(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=NK(t?.pointerEvents)||``),this.hasProjected&&!nW(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=bK(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,e.opacity=r.animationValues?r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in EG){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=EG[t],c=a===`none`?i[t]:n(i[t],r);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=r===this?NK(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(XK),this.root.sharedNodes.clear()}}}function GK(e){e.updateLayout(),$K(e)}function KK(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;if(i===`size`)gK(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=JG(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;VG(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else _q(i,t.layoutBox,n)&&gK(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=JG(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=rG();ZG(o,n,t.layoutBox);let s=rG();a?ZG(s,e.applyTransform(r,!0),t.measuredBox):ZG(s,n,t.layoutBox);let c=!lK(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=aG();tK(s,t.layoutBox,i.layoutBox,o);let c=aG();tK(c,n,a.layoutBox,o),pK(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function qK(e){QW.value&&LK.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 JK(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function YK(e){e.clearSnapshot()}function XK(e){e.clearMeasurements()}function ZK(e){e.isLayoutDirty=!0,e.updateLayout()}function QK(e){e.isLayoutDirty=!1}function $K(e){let{snapshot:t,dragAncestor:n}=e,r=n?.layout;if(!t||!r||e.resumeFrom||e.isAnimationBlocked)return;let i=n.dragSnapshot;gK(e=>fW(t.layoutBox[e],r.layoutBox[e].min-i.layoutBox[e].min))}function eq(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.dragSnapshot||e.layout,e.isLayoutDirty=!0)}function tq(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function nq(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function rq(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function iq(e){e.resolveTargetDelta()}function aq(e){e.calcProjection()}function oq(e){e.resetSkewAndRotation()}function sq(e){e.removeLeadSnapshot()}function cq(e,t,n){e.translate=tB(t.translate,0,n),e.scale=tB(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function lq(e,t,n,r){e.min=tB(t.min,n.min,r),e.max=tB(t.max,n.max,r)}function uq(e,t,n,r){lq(e.x,t.x,n.x,r),lq(e.y,t.y,n.y,r)}function dq(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var fq={duration:.45,ease:[.4,0,.1,1]},pq=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),mq=pq(`applewebkit/`)&&!pq(`chrome/`)?Math.round:kR;function hq(e){e.min=mq(e.min),e.max=mq(e.max)}function gq(e){hq(e.x),hq(e.y)}function _q(e,t,n){return e===`position`||e===`preserve-aspect`&&!YG(mK(t),mK(n),.2)}function vq(e){return e!==e.root&&e.scroll?.wasRoot}var yq=WK({attachResizeListener:(e,t)=>kK(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),bq={current:void 0},xq=WK({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!bq.current){let e=new yq({});e.mount(window),e.setOptions({layoutScroll:!0}),bq.current=e}return bq.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),Sq=(0,F.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Cq(e=!0){let t=(0,F.useContext)(yR);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,F.useId)();(0,F.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,F.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var wq=(0,F.createContext)({strict:!1}),Tq={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],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`]},Eq=!1;function Dq(){if(Eq)return;let e={};for(let t in Tq)e[t]={isEnabled:e=>Tq[t].some(t=>!!e[t])};bG(e),Eq=!0}function Oq(){return Dq(),xG()}function kq(e){let t=Oq();for(let n in e)t[n]={...t[n],...e[n]};bG(t)}var Aq=(0,F.createContext)({});function jq(e,t){if(dG(e)){let{initial:t,animate:n}=e;return{initial:t===!1||cG(t)?t:void 0,animate:cG(n)?n:void 0}}return e.inherit===!1?{}:t}function Mq(e){let{initial:t,animate:n}=jq(e,(0,F.useContext)(Aq));return(0,F.useMemo)(()=>({initial:t,animate:n}),[Nq(t),Nq(n)])}function Nq(e){return Array.isArray(e)?e.join(` `):e}var Pq=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Fq(e,t,n){for(let r in t)!SU(t[r])&&!DG(r,n)&&(e[r]=t[r])}function Iq({transformTemplate:e},t){return(0,F.useMemo)(()=>{let n=Pq();return GU(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Lq(e,t){let n=e.style||{},r={};return Fq(r,n,e),Object.assign(r,Iq(e,t)),r}function Rq(e,t){let n={},r=Lq(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 zq=()=>({...Pq(),attrs:{}});function Bq(e,t,n,r){let i=(0,F.useMemo)(()=>{let n=zq();return XU(n,t,MG(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Fq(t,e.style,e),i.style={...t,...i.style}}return i}var Vq=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 Hq(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||Vq.has(e)}function Uq(e,t){return e.startsWith(`on`)?!Hq(e):t?.(e)??!Hq(e)}function Wq(e,t,n,r){let i={};for(let a in e)(a!==`values`||typeof e.values!=`object`)&&(SU(e[a])||(Uq(a,r)||n===!0&&Hq(a)||!t&&!Hq(a)||e.draggable&&a.startsWith(`onDrag`))&&(i[a]=e[a]));return i}var Gq=[`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 Kq(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(Gq.indexOf(e)>-1||/[A-Z]/u.test(e))}function qq(e,t,n,{latestValues:r},i,a=!1,o,s){let c=(o??Kq(e)?Bq:Rq)(t,r,i,e),l=Wq(t,typeof e==`string`,a,s),u=e===F.Fragment?{}:{...l,...c,ref:n},{children:d}=t,f=(0,F.useMemo)(()=>SU(d)?d.get():d,[d]);return(0,F.createElement)(e,{...u,children:f})}function Jq({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Yq(n,r,i,e),renderState:t()}}function Yq(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=NK(a[e]);let{initial:o,animate:s}=e,c=dG(e),l=fG(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`&&!sG(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=mU(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 Xq=e=>(t,n)=>{let r=(0,F.useContext)(Aq),i=(0,F.useContext)(yR),a=()=>Jq(e,t,r,i);return n?a():_R(a)},Zq=Xq({scrapeMotionValuesFromProps:OG,createRenderState:Pq}),Qq=Xq({scrapeMotionValuesFromProps:PG,createRenderState:zq}),$q=Symbol.for(`motionComponentSymbol`);function eJ(e,t,n){let r=(0,F.useRef)(n);(0,F.useInsertionEffect)(()=>{r.current=n});let i=(0,F.useRef)(null);return(0,F.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 tJ=(0,F.createContext)({});function nJ(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function rJ(e,t,n,r,i,a){let{visualElement:o}=(0,F.useContext)(Aq),s=(0,F.useContext)(wq),c=(0,F.useContext)(yR),l=(0,F.useContext)(Sq),u=l.reducedMotion,d=l.skipAnimations,f=(0,F.useRef)(null),p=(0,F.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,F.useContext)(tJ);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&iJ(f.current,n,i,h);let g=(0,F.useRef)(!1);(0,F.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[EU],v=(0,F.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return vR(()=>{p.current&&m&&(m.animationState?.animateChanges(),m.enteringChildren=void 0)},[]),vR(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,F.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function iJ(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:aJ(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&nJ(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function aJ(e){if(e)return e.options.allowProjection===!1?aJ(e.parent):e.projection}function oJ(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&kq(r);let a=n?n===`svg`:Kq(e),o=a?Qq:Zq;function s(n,s){let c,l={...(0,F.useContext)(Sq),...n,layoutId:sJ(n)},{isStatic:u,isValidProp:d}=l,f=Mq(n),p=o(n,u);if(!u&&typeof window<`u`){cJ(l,r);let t=lJ(l);c=t.MeasureLayout,f.visualElement=rJ(e,p,l,i,t.ProjectionNode,a)}return(0,I.jsxs)(Aq.Provider,{value:f,children:[c&&f.visualElement?(0,I.jsx)(c,{visualElement:f.visualElement,...l}):null,qq(e,n,eJ(p,f.visualElement,s),p,u,t,a,d)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,F.forwardRef)(s);return c[$q]=e,c}function sJ({layoutId:e}){let t=(0,F.useContext)(gR).id;return t&&e!==void 0?t+`-`+e:e}function cJ(e,t){(0,F.useContext)(wq).strict}function lJ(e){let{drag:t,layout:n}=Oq();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function uJ(e,t){if(typeof Proxy>`u`)return oJ;let n=new Map,r=(n,r)=>oJ(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,oJ(a,void 0,e,t)),n.get(a))})}var dJ=(e,t)=>t.isSVG??Kq(e)?new FG(t):new AG(t,{allowProjection:e!==F.Fragment}),fJ=class extends wG{constructor(e){super(e),e.animationState||=RG(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();sG(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},pJ=0,mJ={animation:{Feature:fJ},exit:{Feature:class extends wG{constructor(){super(...arguments),this.id=pJ++}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}=hU(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))}unmount(){}}}};function hJ(e){return{point:{x:e.pageX,y:e.pageY}}}var gJ=e=>t=>EW(t)&&e(t,hJ(t));function _J(e,t,n,r){return kK(e,t,gJ(n),r)}var vJ=({current:e})=>e?e.ownerDocument.defaultView:null,yJ=(e,t)=>Math.abs(e-t);function bJ(e,t){let n=yJ(e.x,t.x),r=yJ(e.y,t.y);return Math.sqrt(n**2+r**2)}var xJ=new Set([`auto`,`scroll`]),SJ=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.removeScrollListeners=null,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=CJ(this.lastRawMoveEventInfo,this.transformPagePoint));let e=TJ(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=bJ(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e;this.history.push({...r,timestamp:iz.now()});let{onStart:i,onMove:a}=this.handlers;t||(i&&i(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),a&&a(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=CJ(t,this.transformPagePoint),this.hasPendingMove=!0,SB.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&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=TJ(e.type===`pointercancel`?this.lastMoveEventInfo:CJ(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!EW(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=CJ(hJ(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=tz;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,TJ(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=AR(_J(this.contextWindow,`pointermove`,this.handlePointerMove,d),_J(this.contextWindow,`pointerup`,this.handlePointerUp,d),_J(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(xJ.has(e.overflowX)||xJ.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},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),SB.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),CB(this.updatePoint)}};function CJ(e,t){return t?{point:t(e.point)}:e}function wJ(e,t){return{x:e.x-t.x,y:e.y-t.y}}function TJ({point:e},t){return{point:e,delta:wJ(e,DJ(t)),offset:wJ(e,EJ(t)),velocity:OJ(t,.1)}}function EJ(e){return e[0]}function DJ(e){return e[e.length-1]}function OJ(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=DJ(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>NR(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>NR(t)*2&&(r=e[1]);let a=PR(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}function kJ(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?tB(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?tB(n,e,r.max):Math.min(e,n)),e}function AJ(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 jJ(e,{top:t,left:n,bottom:r,right:i}){return{x:AJ(e.x,n,i),y:AJ(e.y,t,r)}}function MJ(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 NJ(e,t){return{x:MJ(e.x,t.x),y:MJ(e.y,t.y)}}function PJ(e,t){let n=.5,r=JG(e),i=JG(t);return i>r?n=jR(t.min,t.max-r,e.min):r>i&&(n=jR(e.min,e.max-i,t.min)),CR(0,1,n)}function FJ(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 IJ=.35;function LJ(e=IJ){return e===!1?e=0:e===!0&&(e=IJ),{x:RJ(e,`left`,`right`),y:RJ(e,`top`,`bottom`)}}function RJ(e,t,n){return{min:zJ(e,t),max:zJ(e,n)}}function zJ(e,t){return typeof e==`number`?e:e[t]||0}var BJ=new WeakMap,VJ=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=aG(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(e),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=xW(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),gK(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Dz.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=JG(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&SB.update(()=>i(e,t),!1,!0),wU(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(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;r&&this.currentDirection===null?(this.currentDirection=GJ(o),this.currentDirection!==null&&i&&i(this.currentDirection)):(this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&SB.update(()=>a(e,t),!1,!0))},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new SJ(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:vJ(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&SB.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!WJ(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=kJ(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&nJ(e)?this.constraints||=this.resolveRefConstraints():this.constraints=e&&n?jJ(n.layoutBox,e):!1,this.elastic=LJ(t),r!==this.constraints&&!nJ(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&gK(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=FJ(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!nJ(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=_W(n,r.root,this.visualElement.getTransformPagePoint()),a=NJ(r.layout.layoutBox,i);if(t){let e=t(QU(a));this.hasMutatedConstraints=!!e,e&&(a=ZU(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=gK(o=>{if(!WJ(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return wU(this.visualElement,e),n.start(lU(e,n,0,t,this.visualElement,!1))}stopAnimation(){gK(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[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();gK(e=>{if(!WJ(e,n,this.currentDirection))return;let t=this.getAxisMotionValue(e),{min:r,max:o}=a[e];t.set((t.get()||0)+i[e]-tB(r,o,.5))})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!nJ(t)||!n||!this.constraints)return;this.stopAnimation();let r=this.constraints,i={x:0,y:0};gK(e=>{let t=this.getAxisMotionValue(e).get();i[e]=PJ({min:t,max:t},r[e])});let{transformTemplate:a}=this.visualElement.getProps();this.visualElement.current.style.transform=a?a({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),gK(t=>{let n=this.getAxisMotionValue(t);if(!WJ(t,e,null)||!n.get())return;let{min:r,max:a}=this.constraints[t];n.set(tB(r,a,i[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;BJ.set(this.visualElement,this);let e=this.visualElement.current,t=_J(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&AW(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();nJ(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=UJ(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),SB.read(r);let o=kK(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(gK(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=IJ,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function HJ(e){let t=!0;return()=>{t?t=!1:e()}}function UJ(e,t,n){let r=ZW(e,HJ(n)),i=ZW(t,HJ(n));return()=>{r(),i()}}function WJ(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function GJ(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var KJ=class extends wG{constructor(e){super(e),this.removeGroupControls=kR,this.removeListeners=kR,this.controls=new VJ(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||kR}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},qJ=e=>(t,n)=>{e&&SB.update(()=>e(t,n),!1,!0)},JJ=class extends wG{constructor(){super(...arguments),this.removePointerDownListener=kR}onPointerDown(e){this.session=new SJ(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:vJ(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:qJ(e),onStart:qJ(t),onMove:qJ(n),onEnd:(e,t)=>{delete this.session,r&&SB.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=_J(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},YJ=!1,XJ=class extends F.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),YJ&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),IK.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a&&(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),YJ=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||SB.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),vW.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;YJ=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function ZJ(e){let[t,n]=Cq(),r=(0,F.useContext)(gR);return(0,I.jsx)(XJ,{...e,layoutGroup:r,switchLayoutGroup:(0,F.useContext)(tJ),isPresent:t,safeToRemove:n})}var QJ={pan:{Feature:JJ},drag:{Feature:KJ,ProjectionNode:xq,MeasureLayout:ZJ}};function $J(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&SB.postRender(()=>i(t,hJ(t)))}var eY=class extends wG{mount(){let{current:e}=this.node;e&&(this.unmount=wW(e,(e,t)=>($J(this.node,t,`Start`),e=>$J(this.node,e,`End`))))}unmount(){}},tY=class extends wG{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=AR(kK(this.node.current,`focus`,()=>this.onFocus()),kK(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function nY(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&SB.postRender(()=>i(t,hJ(t)))}var rY=class extends wG{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=LW(e,(e,t)=>(nY(this.node,t,`Start`),(e,{success:t})=>nY(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},iY=new WeakMap,aY=new WeakMap,oY=e=>{let t=iY.get(e.target);t&&t(e)},sY=e=>{e.forEach(oY)};function cY({root:e,...t}){let n=e||document;aY.has(n)||aY.set(n,{});let r=aY.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(sY,{root:e,...t})),r[i]}function lY(e,t,n){let r=cY(t);return iY.set(e,n),r.observe(e),()=>{iY.delete(e),r.unobserve(e)}}var uY={some:0,all:1},dY=class extends wG{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:uY[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=lY(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(fY(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function fY({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var pY={inView:{Feature:dY},tap:{Feature:rY},focus:{Feature:tY},hover:{Feature:eY}},mY={layout:{ProjectionNode:xq,MeasureLayout:ZJ}},hY=uJ({...mJ,...pY,...QJ,...mY},dJ);function gY(e){let t=_R(()=>$H(e)),{isStatic:n}=(0,F.useContext)(Sq);if(n){let[,n]=(0,F.useState)(e);(0,F.useEffect)(()=>t.on(`change`,n),[])}return t}function _Y(e,t){let n=gY(t()),r=()=>n.set(t());return r(),vR(()=>{let t=()=>SB.preRender(r,!1,!0),n=e.map(e=>e.on(`change`,t));return r(),()=>{n.forEach(e=>e()),CB(r)}}),n}function vY(e){ZH.current=[],e();let t=_Y(ZH.current,e);return ZH.current=void 0,t}function yY(e,t,n,r){if(typeof e==`function`)return vY(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!=`function`)return xY(e,t,n,r);let i=typeof t==`function`?t:eG(t,n,r),a=Array.isArray(e)?bY(e,i):bY([e],([e])=>i(e)),o=Array.isArray(e)?void 0:e.accelerate;if(o&&!o.isTransformed&&typeof t!=`function`&&Array.isArray(n)&&r?.clamp!==!1){let e=r?.ease;a.accelerate={...o,times:[0,...t,1],keyframes:[n[0],...n,n[n.length-1]],isTransformed:!0,...e?{ease:Array.isArray(e)?[e[0],...e]:e}:{}}}return a}function bY(e,t){let n=_R(()=>[]);return _Y(e,()=>{n.length=0;let r=e.length;for(let t=0;t<r;t++)n[t]=e[t].get();return t(n)})}function xY(e,t,n,r){let i=_R(()=>Object.keys(n)),a=_R(()=>({}));for(let o of i)a[o]=yY(e,t,n[o],r);return a}var SY=class{constructor(){this.componentControls=new Set}subscribe(e){return this.componentControls.add(e),()=>this.componentControls.delete(e)}start(e,t){this.componentControls.forEach(n=>{n.start(e.nativeEvent||e,t)})}cancel(){this.componentControls.forEach(e=>{e.cancel()})}stop(){this.componentControls.forEach(e=>{e.stop()})}},CY=()=>new SY;function wY(){return _R(CY)}var TY=(0,F.createContext)(null);function EY(e,t,n,r,i,a=`ltr`){let o=e.findIndex(e=>e.value===t);if(o===-1)return e;if(i===`xy`){let{layout:t}=e[o],r={x:tB(t.x.min,t.x.max,.5)+n.x,y:tB(t.y.min,t.y.max,.5)+n.y},i=DY(e),s=i.find(t=>t.items.includes(e[o])),c=i.reduce((e,t)=>OY(r.y,t)<OY(r.y,e)?t:e);if(c!==s)return kY(e,o,r.x,c,a);let l=AY(r,t),u=-1,d=l;return e.forEach((e,t)=>{if(t===o)return;let n=AY(r,e.layout);n<d&&(u=t,d=n)}),u===-1?e:SR(e,o,o+Math.sign(u-o))}if(!r[i])return e;let s=r[i]>0?1:-1,c=e[o+s];if(!c)return e;let l=e[o].layout[i],u=c.layout[i],d=tB(u.min,u.max,.5);return s===1&&l.max+n[i]>d||s===-1&&l.min+n[i]<d?SR(e,o,o+s):e}function DY(e){let t=[];return e.forEach(e=>{let{min:n,max:r}=e.layout.y,i=t[t.length-1];!i||n>=i.max||r<=i.min?t.push({items:[e],min:n,max:r}):(i.items.push(e),i.min=Math.min(i.min,n),i.max=Math.max(i.max,r))}),t}function OY(e,t){return e<t.min?t.min-e:e>t.max?e-t.max:0}function kY(e,t,n,r,i){let a=e.filter((e,n)=>n!==t),o=r.items.find(e=>{let t=tB(e.layout.x.min,e.layout.x.max,.5);return i===`ltr`?n<t:n>t}),s=o?a.indexOf(o):a.indexOf(r.items[r.items.length-1])+1,c=[...a];return c.splice(s,0,e[t]),c.every((t,n)=>t===e[n])?e:c}function AY(e,t){let n=Math.max(t.x.min-e.x,0,e.x-t.x.max),r=Math.max(t.y.min-e.y,0,e.y-t.y.max);return n*n+r*r}var jY=(e,t)=>e.max<=t.min||t.max<=e.min;function MY(e){let t=!1,n=!1;for(let r=0;r<e.length;r++)for(let i=r+1;i<e.length;i++)if(t||=jY(e[r].x,e[i].x),n||=jY(e[r].y,e[i].y),t&&n)return`xy`;return t?`x`:`y`}function NY({children:e,as:t=`ul`,axis:n,onReorder:r,values:i,onPointerDownCapture:a,onClickCapture:o,...s},c){let l=_R(()=>hY[t]),u=(0,F.useRef)(new Map),[d,f]=(0,F.useState)(`y`),p=(0,F.useRef)(!1),m=(0,F.useRef)(!1),h=(0,F.useRef)(null),g=n||d,_=new Set(i);u.current.forEach((e,t)=>{_.has(t)||u.current.delete(t)});let v={axis:g,groupRef:h,hasReordered:m,registerItem:(e,t)=>{if(u.current.set(e,t),!n){let e=MY(i.flatMap(e=>{let t=u.current.get(e);return t?[t]:[]}));e!==d&&f(e)}},updateOrder:(e,t,n)=>{if(p.current)return;let a=i.flatMap(e=>{let t=u.current.get(e);return t?[{value:e,layout:t}]:[]}),o=h.current?.ownerDocument.defaultView?.getComputedStyle(h.current).direction===`rtl`?`rtl`:`ltr`,s=EY(a,e,t,n,g,o);if(a!==s){p.current=!0,m.current=!0;let e=[...i],t=a.map(({value:e})=>i.indexOf(e));s.forEach(({value:n},r)=>{e[t[r]]=n}),r(e)}}};(0,F.useEffect)(()=>{p.current=!1},[i]);let y=e=>{h.current=e,typeof c==`function`?c(e):c&&(c.current=e)},b={overflowAnchor:`none`,...s.style};return(0,I.jsx)(l,{...s,style:b,ref:y,onPointerDownCapture:e=>{m.current=!1,a?.(e)},onClickCapture:e=>{m.current&&e.detail&&(m.current=!1,e.stopPropagation(),e.preventDefault()),o?.(e)},ignoreStrict:!0,children:(0,I.jsx)(TY.Provider,{value:v,children:e})})}var PY=(0,F.forwardRef)(NY),FY=50,IY=25,LY=new Set([`auto`,`scroll`]),RY=new WeakMap,zY=new WeakMap,BY=null;function VY(){if(BY){let e=UY(BY,`y`);e&&(zY.delete(e),RY.delete(e));let t=UY(BY,`x`);t&&t!==e&&(zY.delete(t),RY.delete(t)),BY=null}}function HY(e,t){let n=getComputedStyle(e),r=t===`x`?n.overflowX:n.overflowY,i=e===document.body||e===document.documentElement;return LY.has(r)||i}function UY(e,t){let n=e?.parentElement;for(;n;){if(HY(n,t))return n;n=n.parentElement}return null}function WY(e,t,n){let r=t.getBoundingClientRect(),i=n===`x`?Math.max(0,r.left):Math.max(0,r.top),a=n===`x`?Math.min(window.innerWidth,r.right):Math.min(window.innerHeight,r.bottom),o=e-i,s=a-e;if(o<FY){let e=1-o/FY;return{amount:-25*e*e,edge:`start`}}if(s<FY){let e=1-s/FY;return{amount:IY*e*e,edge:`end`}}return{amount:0,edge:null}}function GY(e,t,n,r){if(!e)return;BY=e;let i=UY(e,n);if(!i)return;let{amount:a,edge:o}=WY(t-(n===`x`?window.scrollX:window.scrollY),i,n);if(o===null){zY.delete(i),RY.delete(i);return}let s=zY.get(i),c=i===document.body||i===document.documentElement;if(s!==o){if(!(o===`start`&&r<0||o===`end`&&r>0))return;zY.set(i,o);let e=n===`x`?i.scrollWidth-(c?window.innerWidth:i.clientWidth):i.scrollHeight-(c?window.innerHeight:i.clientHeight);RY.set(i,e)}if(a>0){let e=RY.get(i);if((n===`x`?c?window.scrollX:i.scrollLeft:c?window.scrollY:i.scrollTop)>=e)return}n===`x`?c?window.scrollBy({left:a}):i.scrollLeft+=a:c?window.scrollBy({top:a}):i.scrollTop+=a}function KY(e,t=0){return SU(e)?e:gY(t)}function qY({children:e,style:t={},value:n,as:r=`li`,onDrag:i,onDragEnd:a,layout:o=!0,...s},c){let l=_R(()=>hY[r]),u=(0,F.useContext)(TY),d={x:KY(t.x),y:KY(t.y)},f=yY([d.x,d.y],([e,t])=>e||t?1:`unset`),{axis:p,registerItem:m,updateOrder:h,groupRef:g,hasReordered:_}=u;return(0,I.jsx)(l,{drag:p===`xy`||p,...s,dragSnapToOrigin:!0,style:{...t,x:d.x,y:d.y,zIndex:f},layout:o,onDrag:(e,t)=>{let{velocity:r,point:a}=t,o={x:d.x.get(),y:d.y.get()};h(n,o,r);let s=p===`xy`?Math.abs(r.x)>Math.abs(r.y)?`x`:`y`:p;GY(g.current,a[s],s,r[s]),i&&i(e,t)},onDragEnd:(e,t)=>{_.current=!1,VY(),a&&a(e,t)},onLayoutMeasure:e=>{m(n,e)},ref:c,ignoreStrict:!0,children:e})}var JY=(0,F.forwardRef)(qY);function YY(e){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(``),[l,u]=(0,F.useState)(null);return(0,I.jsxs)(`form`,{className:`grid`,onSubmit:async n=>{n.preventDefault(),u(null);try{if(t)await h9(d9(a).address,s.trim()===``?null:s.trim());else{let e=d9(r);await h9(e.address,e.code)}e.onAdded?.()}catch(e){u(Oe(e))}},children:[(0,I.jsxs)(`div`,{className:P(`grid gap-2`,e.fieldsClassName),children:[t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(wL,{"aria-label":`Server URL`,placeholder:`Server URL, e.g. http://127.0.0.1:47841`,spellCheck:!1,autoComplete:`off`,value:a,onChange:e=>o(e.target.value)}),(0,I.jsx)(wL,{"aria-label":`Pairing code`,placeholder:`Pairing code, empty if auth is off`,spellCheck:!1,autoComplete:`off`,value:s,onChange:e=>c(e.target.value)})]}):(0,I.jsx)(wL,{"aria-label":`Pairing link`,placeholder:`Pairing link`,spellCheck:!1,autoComplete:`off`,value:r,onChange:e=>i(e.target.value)}),l!==null&&(0,I.jsx)(`p`,{className:`text-destructive text-sm break-all`,children:l}),(0,I.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground w-fit cursor-pointer text-xs`,onClick:()=>{n(!t),u(null)},children:t?`Paste a pairing link instead`:`Enter the server URL and code separately`})]}),e.actions(t?a.trim()!==``:r.trim()!==``)]})}function XY(e){return(0,I.jsx)(_e,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(ae,{className:`gap-0 overflow-hidden p-0 sm:max-w-md`,children:[(0,I.jsxs)(se,{className:`gap-1 px-6 pt-4 pr-12`,children:[(0,I.jsx)(pe,{className:`text-base`,children:`Add machine`}),(0,I.jsx)(ge,{children:`Paste the pairing link that OffSite printed when it started.`})]}),(0,I.jsx)(YY,{fieldsClassName:`p-6`,onAdded:e.onClose,actions:t=>(0,I.jsxs)(ve,{className:`bg-muted/40 border-t px-6 py-4`,children:[(0,I.jsx)(x,{type:`button`,variant:`outline`,onClick:e.onClose,children:`Cancel`}),(0,I.jsx)(x,{type:`submit`,disabled:!t,children:`Add machine`})]})})]})})}var ZY={connecting:`Connecting…`,online:`Online`,offline:`Offline`,unpaired:`Needs pairing`};function QY(){let e=Q(e=>e.machines),t=Q(e=>e.machines.find(t=>t.id===e.settingsEditedMachine)),[n,r]=(0,F.useState)(!1);return t===void 0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(XL,{title:`Machines`,note:`This browser connects to each one directly. The list stays in this browser`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`flex min-h-13 items-center gap-4 px-4 py-2.5`,children:[(0,I.jsx)(w,{icon:Fv[e.icon],className:`text-muted-foreground size-5 shrink-0`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name}),e.addresses.map(e=>(0,I.jsx)(`p`,{className:`text-muted-foreground truncate font-mono text-xs`,children:e},e)),e.providers.filter(e=>e.state===`error`).map(e=>(0,I.jsxs)(`p`,{className:`text-destructive truncate text-xs`,title:e.error??void 0,children:[uw[e.provider],` threads: `,e.error]},e.provider))]}),(0,I.jsxs)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:[ZY[e.status],e.status===`online`&&e.via!==null&&e.via!==e.addresses[0]&&` · via ${new URL(e.via).host}`]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,I.jsx)(x,{size:`icon-sm`,variant:`ghost`,title:`Reconnect, trying the first address first`,onClick:()=>b9(e.id),children:(0,I.jsx)(w,{icon:z_})}),(0,I.jsx)(x,{size:`icon-sm`,variant:`ghost-muted`,title:`Open machine`,onClick:()=>$({settingsEditedMachine:e.id}),children:(0,I.jsx)(w,{icon:Fg})})]})]},e.id))}),(0,I.jsx)(`div`,{className:`flex gap-2`,children:(0,I.jsx)(x,{variant:`outline`,size:`sm`,onClick:()=>r(!0),children:`Add machine…`})}),n&&(0,I.jsx)(XY,{onClose:()=>r(!1)})]}):(0,I.jsx)($Y,{machine:t})}function $Y(e){let t=e.machine,[n,r]=(0,F.useState)(!1),[i,a]=(0,F.useState)(``),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(null),u=c??t.addresses,d=(0,F.useRef)(null);(0,F.useEffect)(()=>{n&&d.current?.focus()},[n]);function f(e){s(null);try{return v9(t.id,{addresses:[...new Set(e.map(e=>d9(e).address))]}),!0}catch(e){return s(Oe(e)),!1}}async function p(e){s(null);let n=e.trim();if(n===``)return!0;try{let e=n.includes(`#`)?d9(n).code:n;if(e===null)throw Error(`That link has no pairing code`);return await g9(t.id,e),!0}catch(e){return s(Oe(e)),!1}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(XL,{title:`Machine`,children:[(0,I.jsx)(ZL,{label:`Name`,children:(0,I.jsx)(QL,{value:t.label??``,placeholder:t.hostname,onCommit:e=>v9(t.id,{label:e.trim()===``?null:e.trim()})},t.label)}),(0,I.jsxs)(`div`,{className:`flex min-h-13 items-center justify-between gap-4 px-4 py-2.5`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:`Icon`}),(0,I.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:Object.entries(Fv).map(e=>(0,I.jsx)(x,{size:`icon-sm`,variant:e[0]===t.icon?`default`:`ghost`,title:e[0],"aria-pressed":e[0]===t.icon,onClick:()=>v9(t.id,{icon:e[0]}),children:(0,I.jsx)(w,{icon:e[1]})},e[0]))})]})]}),(0,I.jsx)(XL,{title:`Pairing`,children:(0,I.jsxs)(`div`,{className:`flex min-h-13 items-center justify-between gap-4 px-4 py-2.5`,children:[t.pairedAt!==null&&t.status!==`unpaired`&&(0,I.jsx)(`span`,{className:`text-sm`,children:t.pairedAt===null?`Paired`:`Paired ${mw(t.pairedAt)}`}),(t.pairedAt===null||t.status===`unpaired`)&&(0,I.jsxs)(`form`,{className:`flex flex-1 items-center gap-3`,onSubmit:async e=>{e.preventDefault(),await p(i)&&a(``)},children:[(0,I.jsx)(wL,{className:`flex-1 font-mono`,placeholder:`Pairing link or code`,spellCheck:!1,autoComplete:`off`,value:i,onChange:e=>a(e.target.value)}),(0,I.jsxs)(x,{type:`submit`,variant:`outline`,className:`px-4`,disabled:i.trim()===``,children:[(0,I.jsx)(w,{icon:gee}),`Pair`]})]})]})}),(0,I.jsxs)(XL,{title:`Addresses`,note:`OffSite tries them in order whenever it reconnects`,children:[(0,I.jsx)(PY,{as:`div`,axis:`y`,className:`divide-y`,values:u,onReorder:l,children:u.map((e,t)=>(0,I.jsxs)(eX,{address:e,onDragEnd:()=>{c!==null&&f(c),l(null)},children:[(0,I.jsx)(QL,{className:`flex-1 font-mono`,value:e,onCommit:e=>f(u.map((n,r)=>r===t?e:n))}),(0,I.jsx)(x,{size:`icon-sm`,variant:`ghost`,title:`Remove address`,disabled:u.length===1,onClick:()=>f(u.filter((e,n)=>n!==t)),children:(0,I.jsx)(w,{icon:d_})})]},e))}),n&&(0,I.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,I.jsx)(wL,{ref:d,className:`font-mono`,placeholder:`http://192.168.1.10:47841`,spellCheck:!1,autoComplete:`off`,onBlur:e=>{let n=e.target.value.trim();(n===``||f([...t.addresses,n]))&&r(!1)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}})}),!n&&(0,I.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted/50 hover:text-foreground flex w-full items-center gap-2 px-4 py-3 text-sm transition-colors`,onClick:()=>r(!0),children:[(0,I.jsx)(w,{icon:Og,className:`size-4`}),`Add address`]})]}),o!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-1 text-xs break-all`,children:o}),(0,I.jsxs)(LL,{children:[(0,I.jsx)(RL,{asChild:!0,children:(0,I.jsx)(x,{variant:`outline`,className:`text-destructive`,children:`Remove machine`})}),(0,I.jsxs)(zL,{children:[(0,I.jsxs)(BL,{children:[(0,I.jsxs)(HL,{children:[`Remove `,t.name,`?`]}),(0,I.jsx)(UL,{children:`This browser forgets the machine. The machine and its threads stay untouched.`})]}),(0,I.jsxs)(VL,{children:[(0,I.jsx)(GL,{children:`Cancel`}),(0,I.jsx)(WL,{variant:`destructive`,onClick:()=>{$({settingsEditedMachine:null}),eue(t.id)},children:`Remove machine`})]})]})]})]})}function eX(e){let t=wY();return(0,I.jsxs)(JY,{as:`div`,value:e.address,dragListener:!1,dragControls:t,onDragEnd:e.onDragEnd,className:`bg-background relative flex items-center gap-3 px-4 py-2.5`,children:[(0,I.jsx)(`span`,{className:`text-muted-foreground hover:text-foreground cursor-grab touch-none active:cursor-grabbing`,title:`Drag to reorder`,onPointerDown:e=>t.start(e),children:(0,I.jsx)(w,{icon:p_,className:`size-4`})}),e.children]})}var tX=`notifications`,nX=Promise.resolve(),rX=new Set;function iX(){return window.isSecureContext?!(`Notification`in window)||!(`serviceWorker`in navigator)?`unsupported`:Notification.permission:`insecure`}function aX(){let e=localStorage.getItem(tX);if(e===null||e===`on`)return!0;if(e===`off`)return!1;throw Error(`unknown notification setting ${e}`)}async function oX(e){e&&Notification.permission==="default"&&await Notification.requestPermission(),localStorage.setItem(tX,e?`on`:`off`)}async function sX(e,t){(await navigator.permissions.query({name:`notifications`})).addEventListener(`change`,t,{signal:e})}function cX(e,t,n){if(document.hidden)for(let r of t){let t=uX(e,r);dX(e,r,`${t===void 0?`Agent`:uw[t.provider]} ${n}`,t?.title??`Session`,f9(e,r)).catch(e=>console.error(`could not show a notification`,e))}}function lX(e,t,n){dX(e,t,uX(e,t)?.title??`Session`,n,`push:${f9(e,t)}`).catch(e=>console.error(`could not show a notification`,e))}function uX(e,t){return Z().sessions.find(n=>n.machine===e&&n.id===t)}async function dX(e,t,n,r,i){if(iX()!==`granted`||!aX()||!T9(Z(),e).notifier)return;let a=uX(e,t);await(await navigator.serviceWorker.ready).showNotification(n,{body:r,tag:i,data:a===void 0?null:{kind:`session`,machine:e,project:a.projectId,sessionId:t}})}async function fX(e,t,n){iX()===`granted`&&aX()&&T9(Z(),n.machine).notifier&&await(await navigator.serviceWorker.ready).showNotification(e,{body:t,data:{kind:`terminal`,...n}})}function pX(){let e=Z().machines.filter(e=>Co(e.id)&&!e.notifier&&!rX.has(e.id)).map(e=>e.id);if(e.length!==0){for(let t of e)rX.add(t);mX().then(t=>Promise.all(e.map(e=>L(e,`notifications.claim`,{endpoint:t})))).catch(e=>console.error(`could not claim notifications`,e)).finally(()=>{for(let t of e)rX.delete(t)})}}async function mX(){if(hX()!==`supported`)return null;let e=await navigator.serviceWorker.getRegistration();if(e===void 0)return null;let t=await e.pushManager.getSubscription();return t===null?null:t.endpoint}function hX(){return window.isSecureContext?!(`Notification`in window)||!(`serviceWorker`in navigator)||!(`PushManager`in window)?gX()?`install`:`unsupported`:Notification.permission===`denied`?`denied`:`supported`:`insecure`}function gX(){return/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.userAgent.includes(`Mac`)&&navigator.maxTouchPoints>1}async function _X(){return await(await navigator.serviceWorker.ready).pushManager.getSubscription()!==null}async function vX(){return Notification.permission==="default"&&await Notification.requestPermission(),Notification.permission===`granted`&&(await xX(SX),!0)}function yX(){return xX(CX)}function bX(e){return xX(async()=>{if(hX()!==`supported`)return;let t=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!t)return;let n=await wX(),r=t.options.applicationServerKey;r!==null&&EX(r)===n.publicKey?await DX(e,t,n):await SX()})}function xX(e){let t=nX.then(e);return nX=t.catch(()=>void 0),t}async function SX(){await CX();let e=await wX(),t=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:e.publicKey});await Promise.all(TX().map(n=>DX(n,t,e)))}async function CX(){let e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();e&&(await Promise.all(TX().map(t=>L(t,`push.unsubscribe`,{endpoint:e.endpoint}))),await e.unsubscribe())}async function wX(){let e=await caches.open(`offsite-worker`),t=await e.match(`/push-keys`);if(t!==void 0)return await t.json();let n=await crypto.subtle.generateKey({name:`ECDSA`,namedCurve:`P-256`},!0,[`sign`,`verify`]),r=(await crypto.subtle.exportKey(`jwk`,n.privateKey)).d;if(r===void 0)throw Error(`the browser did not export the push key`);let i={publicKey:EX(await crypto.subtle.exportKey(`raw`,n.publicKey)),privateKey:r};return await e.put(`/push-keys`,new Response(JSON.stringify(i))),i}function TX(){return Z().machines.filter(e=>Co(e.id)).map(e=>e.id)}function EX(e){return btoa(String.fromCharCode(...new Uint8Array(e))).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/,``)}async function DX(e,t,n){await L(e,`push.subscribe`,{subscription:t.toJSON(),...n,machine:e})}var OX=new Map([[`denied`,`Blocked in the browser's site settings`],[`insecure`,`Needs https or localhost`],[`install`,`Add OffSite to the Home Screen first`],[`unsupported`,`Not supported in this browser`]]);function kX(e){let t=e.prefs.terminal,n=t.behavior;function r(r){L9({...e.prefs,terminal:{...t,behavior:{...n,...r}}})}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(XL,{title:`Notifications`,children:[(0,I.jsx)(ZL,{label:`Desktop notifications on this device`,children:(0,I.jsx)(AX,{})}),(0,I.jsx)(ZL,{label:`Push terminal alerts when no OffSite page is open`,children:(0,I.jsx)(jX,{})})]}),(0,I.jsxs)(XL,{title:`Terminal bell`,children:[(0,I.jsx)(ZL,{label:`Flash the screen on bell`,children:(0,I.jsx)(KL,{checked:n.bellFlash,onCheckedChange:e=>r({bellFlash:e})})}),(0,I.jsx)(ZL,{label:`Play a sound on bell`,children:(0,I.jsx)(KL,{checked:n.bellSound,onCheckedChange:e=>r({bellSound:e})})})]})]})}function AX(){let[e,t]=(0,F.useState)(iX),[n,r]=(0,F.useState)(aX);(0,F.useEffect)(()=>{let e=iX();if(e===`insecure`||e===`unsupported`)return;let n=new AbortController;return sX(n.signal,()=>t(iX())).catch(e=>console.error(`could not watch the notification permission`,e)),()=>n.abort()},[]);async function i(e){await oX(e),r(e),t(iX())}return(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[OX.has(e)&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:OX.get(e)}),(0,I.jsx)(KL,{checked:e===`granted`&&n,disabled:e!==`granted`&&e!=="default",onCheckedChange:e=>void i(e)})]})}function jX(){let[e,t]=(0,F.useState)(hX),[n,r]=(0,F.useState)(!1),[i,a]=(0,F.useState)(()=>hX()===`supported`),[o,s]=(0,F.useState)(null);(0,F.useEffect)(()=>{if(hX()!==`supported`)return;let e=!0;async function t(){try{let t=await _X();e&&r(t)}catch(e){console.error(`could not read the push subscription`,e)}e&&a(!1)}return t(),()=>{e=!1}},[]);async function c(e){a(!0),s(null);try{e?r(await vX()):(await yX(),r(!1))}catch(e){console.error(`could not change push notifications`,e),s(Oe(e))}t(hX()),a(!1)}return(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[o!==null&&(0,I.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[`Could not update: `,o]}),OX.has(e)&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:OX.get(e)}),(0,I.jsx)(KL,{checked:e===`supported`&&n,disabled:e!==`supported`||i,onCheckedChange:e=>void c(e)})]})}var MX={five_hour:`5h`,seven_day:`Week`,seven_day_opus:`Week (Opus)`,seven_day_sonnet:`Week (Sonnet)`};function NX(e){return MX[e.window]??e.window}function PX(e){let t=e.account,[n,r]=(0,F.useState)(null),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(null),c=n===null?null:n.models;(0,F.useEffect)(()=>{let n=!0;return r(null),a(null),L(e.machine,`capabilities`,{provider:t.provider,accountId:t.id,projectId:null}).then(e=>{n&&r(e)},e=>{n&&a(Oe(e))}),()=>{n=!1}},[e.machine,t.provider,t.id,t.configDir]);async function l(n){s(null);try{await L(e.machine,`accounts.update`,{id:t.id,name:t.name,color:t.color,configDir:t.configDir,enabled:t.enabled,hiddenModels:t.hiddenModels,...n})}catch(e){s(Oe(e))}}async function u(){s(null);try{await L(e.machine,`accounts.remove`,{id:t.id}),$({settingsAccount:null})}catch(e){s(Oe(e))}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(XL,{title:`Account`,children:[(0,I.jsx)(ZL,{label:`Name`,children:(0,I.jsx)(QL,{value:t.name,valid:e=>e.trim()!==``,onCommit:e=>void l({name:e})},t.name)}),(0,I.jsx)(ZL,{label:`Color`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.color!==null&&(0,I.jsx)(`span`,{className:`size-5 shrink-0 rounded-full`,style:{backgroundColor:t.color}}),(0,I.jsx)(QL,{className:`w-28 font-mono`,value:t.color??``,placeholder:`#3b82f6`,valid:e=>e===``||/^#[0-9a-f]{6}$/i.test(e),onCommit:e=>void l({color:e===``?null:e})},t.color??``)]})}),(0,I.jsx)(ZL,{label:`Config directory`,children:(0,I.jsx)(QL,{className:`w-72 font-mono`,value:t.configDir??``,placeholder:t.provider===`claude`?`~/.claude or empty for default`:`~/.codex or empty for default`,onCommit:e=>void l({configDir:e})},t.configDir??``)})]}),o!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-1 text-xs`,children:o}),(0,I.jsxs)(XL,{title:`Models`,note:`Overrides the provider settings`,children:[i!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:i}),i===null&&c===null&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-4 py-3 text-xs`,children:`Loading…`}),(c??[]).map(n=>{let r=e.settings[n.value]?.hidden??n.deprecated,i=t.hiddenModels[n.value],a=i??r;return(0,I.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 px-4 py-1.5`,children:[(0,I.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate text-sm`,a&&`text-muted-foreground`),children:n.name}),i!==void 0&&(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Override`}),(0,I.jsx)(KL,{size:`sm`,checked:!a,onCheckedChange:e=>{let i={...t.hiddenModels};!e===r?delete i[n.value]:i[n.value]=!e,l({hiddenModels:i})},"aria-label":`Show ${n.name}`})]},n.value)})]}),(0,I.jsxs)(LL,{children:[(0,I.jsx)(RL,{asChild:!0,children:(0,I.jsx)(x,{variant:`outline`,className:`text-destructive`,children:`Remove account`})}),(0,I.jsxs)(zL,{children:[(0,I.jsxs)(BL,{children:[(0,I.jsxs)(HL,{children:[`Remove `,t.name,`?`]}),(0,I.jsx)(UL,{children:`OffSite stops using this account. Its config directory and sessions stay untouched.`})]}),(0,I.jsxs)(VL,{children:[(0,I.jsx)(GL,{children:`Cancel`}),(0,I.jsx)(WL,{variant:`destructive`,onClick:()=>void u(),children:`Remove account`})]})]})]})]})}function FX(e){let[t,n]=(0,F.useState)(``),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(null);async function l(){o(!0),c(null);try{await L(e.machine,`accounts.add`,{provider:e.provider,name:t,configDir:r}),$({settingsAccount:null})}catch(e){c(Oe(e)),o(!1)}}return(0,I.jsxs)(`form`,{className:`space-y-5`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,I.jsxs)(XL,{title:`Account`,children:[(0,I.jsx)(ZL,{label:`Name`,children:(0,I.jsx)(wL,{className:`w-56`,value:t,onChange:e=>n(e.target.value),placeholder:`Work`})}),(0,I.jsx)(ZL,{label:`Config directory`,children:(0,I.jsx)(wL,{className:`w-72 font-mono`,value:r,onChange:e=>i(e.target.value),placeholder:e.provider===`claude`?`~/.claude or empty for default`:`~/.codex or empty for default`})})]}),s!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-1 text-xs`,children:s}),(0,I.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,I.jsx)(x,{type:`button`,variant:`ghost`,onClick:()=>$({settingsAccount:null}),children:`Cancel`}),(0,I.jsx)(x,{type:`submit`,disabled:a||t.trim()===``,children:`Add account`})]})]})}function IX(e){let t=e.config,n=t.enabledProviders[e.provider],r=e.provider===`claude`?e.claudeAccounts:e.provider===`codex`?e.codexAccounts:[],i=r.find(e=>e.valid),a=t.claudeBaseDir[e.platform]??e.defaultClaudeBaseDir;if(e.selected===`new`){if(e.provider===`opencode`)throw Error(`OpenCode accounts cannot be added`);return(0,I.jsx)(FX,{machine:e.machine,provider:e.provider})}if(e.selected!==null){let n=r.find(t=>t.id===e.selected);return n===void 0?(0,I.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This account no longer exists.`}):(0,I.jsx)(PX,{machine:e.machine,settings:t.models[e.provider],account:n})}return(0,I.jsxs)(I.Fragment,{children:[e.provider===`claude`&&(0,I.jsx)(`div`,{className:`divide-y overflow-hidden rounded-xl border`,children:(0,I.jsx)(ZL,{label:`Base directory`,children:(0,I.jsx)(QL,{className:`w-72 font-mono`,value:a,valid:e=>e.trim()!==``,onCommit:n=>H9(e.machine,{...t,claudeBaseDir:{...t.claudeBaseDir,[e.platform]:n}})},a)})}),(0,I.jsxs)(`div`,{className:P(`space-y-5 transition-opacity`,!n&&`opacity-50`),children:[e.provider!==`opencode`&&(0,I.jsx)(XL,{title:`Accounts`,children:(0,I.jsx)(RX,{machine:e.machine,accounts:r})}),n&&e.provider===`opencode`&&e.openCode.available&&(0,I.jsx)(LX,{machine:e.machine,config:t,composer:e.composer,provider:e.provider,accountId:null}),n&&e.provider!==`opencode`&&i!==void 0&&(0,I.jsx)(LX,{machine:e.machine,config:t,composer:e.composer,provider:e.provider,accountId:i.id})]})]})}function LX(e){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(null),a=e.config.models[e.provider],o=t===null?null:t.models,s=e.composer[e.provider],c=s.model??(t===null?null:t.defaultModel);(0,F.useEffect)(()=>{let t=!0;return n(null),i(null),L(e.machine,`capabilities`,{provider:e.provider,accountId:e.accountId,projectId:null}).then(e=>{t&&n(e)},e=>{t&&i(Oe(e))}),()=>{t=!1}},[e.machine,e.provider,e.accountId]);function l(t,n){H9(e.machine,{...e.config,models:{...e.config.models,[e.provider]:{...a,[t]:n}}})}return(0,I.jsxs)(XL,{title:`Models`,children:[o!==null&&(0,I.jsx)(ZL,{label:`Default model`,children:(0,I.jsxs)(TL,{value:c??void 0,onValueChange:t=>{let n=o?.find(e=>e.value===t)?.effort??null;W9(e.machine,{...e.composer,[e.provider]:{...s,model:t,...n===null?{}:{effort:n}}})},children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{placeholder:`Choose a model`})}),(0,I.jsx)(OL,{children:o.filter(e=>!(a[e.value]?.hidden??e.deprecated)||e.value===c).map(e=>(0,I.jsx)(kL,{value:e.value,children:e.name},e.value))})]})}),r!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:r}),r===null&&o===null&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-4 py-3 text-xs`,children:`Loading…`}),(o??[]).map(t=>{let n=a[t.value]??{hidden:t.deprecated,effort:t.effort};return(0,I.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 px-4 py-1.5`,children:[(0,I.jsxs)(`div`,{className:P(`min-w-0 flex-1 truncate text-sm`,n.hidden&&`text-muted-foreground`),children:[t.name,e.provider===`opencode`&&(0,I.jsx)(`span`,{className:`text-muted-foreground ml-2 text-xs`,children:t.description})]}),t.efforts.length>0&&(0,I.jsxs)(TL,{value:n.effort??t.effort??void 0,onValueChange:e=>l(t.value,{...n,effort:e}),children:[(0,I.jsx)(DL,{size:`sm`,className:`w-28`,children:(0,I.jsx)(EL,{placeholder:`Effort`})}),(0,I.jsx)(OL,{children:t.efforts.map(e=>(0,I.jsx)(kL,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,I.jsx)(KL,{size:`sm`,checked:!n.hidden,onCheckedChange:e=>l(t.value,{...n,hidden:!e}),"aria-label":`Show ${t.name}`})]},t.value)})]})}function RX(e){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(null);async function a(e){n(!0),i(null);try{await e()}catch(e){i(Oe(e))}finally{n(!1)}}return(0,I.jsxs)(I.Fragment,{children:[e.accounts.map(n=>(0,I.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:P(`min-w-0 flex-1`,!n.enabled&&`opacity-50`),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:P(`size-2 shrink-0 rounded-full`,!n.enabled&&`bg-muted-foreground/40`,n.enabled&&n.error!==null&&`bg-destructive`,n.enabled&&n.error===null&&!n.linked&&`bg-warning`,n.enabled&&n.error===null&&n.linked&&`bg-success`)}),(0,I.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n.name}),n.plan!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:n.plan})]}),n.error!==null&&(0,I.jsx)(`p`,{className:`text-destructive mt-1 truncate pl-4 text-xs`,children:n.error}),n.error===null&&!n.linked&&(0,I.jsx)(`p`,{className:`text-warning mt-1 truncate pl-4 text-xs`,children:`Not linked to shared threads · hidden in the composer`}),n.error===null&&n.linked&&n.limits.length>0&&(0,I.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-x-5 gap-y-1.5 pl-4`,children:n.limits.map(e=>(0,I.jsx)(zX,{limit:e},e.window))})]}),(0,I.jsx)(KL,{size:`sm`,checked:n.enabled,disabled:t,onCheckedChange:t=>void a(()=>L(e.machine,`accounts.update`,{id:n.id,name:n.name,color:n.color,configDir:n.configDir,enabled:t,hiddenModels:n.hiddenModels})),"aria-label":`Enable ${n.name}`}),(0,I.jsx)(x,{size:`icon-sm`,variant:`ghost-muted`,title:`Open account`,onClick:()=>$({settingsAccount:n.id}),children:(0,I.jsx)(w,{icon:Fg})})]},n.id)),(0,I.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted/50 hover:text-foreground flex w-full items-center gap-2 px-4 py-3 text-sm transition-colors`,onClick:()=>$({settingsAccount:`new`}),children:[(0,I.jsx)(w,{icon:Og,className:`size-4`}),`Add account`]}),r!==null&&(0,I.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:r})]})}function zX(e){let t=e.limit,n=t.rejected?100:t.utilization===null?null:Math.min(100,Math.round(t.utilization*100));return n===null?null:(0,I.jsx)(M,{label:t.resetsAt===null?`Reset time unknown`:`Resets ${mw(t.resetsAt*1e3)}`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:NX(t)}),(0,I.jsx)(`div`,{className:`bg-foreground/10 h-1 w-16 overflow-hidden rounded-full`,children:(0,I.jsx)(`div`,{className:P(`h-full rounded-full`,t.rejected&&`bg-destructive`,!t.rejected&&n>=80&&`bg-warning`,!t.rejected&&n<80&&`bg-foreground/50`),style:{width:`${n}%`}})}),(0,I.jsxs)(`span`,{className:P(`tabular-nums`,t.rejected&&`text-destructive`,!t.rejected&&`text-muted-foreground`),children:[n,`%`]})]})})}var BX=Ee?`⌘`:`Ctrl+Shift`,VX=[[`Enter`,`Send, or queue or steer while the agent works`],[`${Te}+Enter`,`Send the other way while the agent works`],[`Shift+Enter`,`New line`],[`↑`,`Recall your last message`],[`Esc`,`Stop the agent`],[`/`,`Slash commands`],[`@`,`Mention a file`],[`${Te}+K`,`Search sessions and actions`],[`${Te}+N or ${Te}+T`,`New thread`],[Ee?"⌘+` or Ctrl+`":"Ctrl+`",`Toggle the terminal`],[`${Te}+B`,`Toggle the sidebar`],[`${Te}+J`,`Toggle the right panel`],[`${BX}+T`,`New terminal tab, in the terminal`],[`${BX}+W`,`Close the terminal tab`],[`${BX}+F`,`Find in the terminal`],[`Ctrl+Tab`,`Next terminal tab`],[`Ctrl+Shift+Tab`,`Previous terminal tab`]];function HX(){return(0,I.jsx)(XL,{title:`Keyboard shortcuts`,children:VX.map(([e,t])=>(0,I.jsx)(ZL,{label:t,children:(0,I.jsx)(`kbd`,{className:`bg-muted text-muted-foreground rounded px-1.5 py-0.5 font-sans text-xs`,children:e})},e))})}var UX=1048576;function WX(e){window.isSecureContext?navigator.clipboard.writeText(e).catch(e=>{console.warn(`could not copy to the clipboard`,e),Ro(`Could not copy to the clipboard`)}):console.warn(`copy from the terminal needs https or localhost`)}async function GX(e){if(!window.isSecureContext){console.warn(`programs can read the clipboard only over https or localhost`),Ro(`Programs can read the clipboard only over https or localhost`);return}let t;try{t=await navigator.clipboard.readText()}catch(e){console.warn(`could not read the clipboard`,e),Ro(`Could not read the clipboard`);return}new TextEncoder().encode(t).length>UX?(console.warn(`the clipboard is over 1 MiB, not replying`),Ro(`The clipboard is too large to share (over 1 MiB)`)):e(t)}var KX={macos:{label:`Ctrl+V`,ctrl:!0,alt:!1,data:``},linux:{label:`Ctrl+V`,ctrl:!0,alt:!1,data:``},windows:{label:`Alt+V`,ctrl:!1,alt:!0,data:`\x1Bv`}};function qX(e,t){let n=KX[t];return e.key.toLowerCase()===`v`&&e.ctrlKey===n.ctrl&&e.altKey===n.alt&&!e.shiftKey&&!e.metaKey}async function JX(e,t){let n=[];for(let e of await navigator.clipboard.read()){let t=e.types.find(e=>e.startsWith(`image/`));t&&n.push(await e.getType(t))}return n.length===0?(Ro(`No image in the clipboard`),!1):(await YX(e,t,n),!0)}async function YX(e,t,n){let r=[];for(let t of n){let n=await L(e,`terminal.paste`,{type:t.type,data:await PC(t)});r.push(/\s/.test(n)?`"${n}"`:n)}t.paste(r.join(` `))}function XX(e){console.error(`could not paste image`,e),Ro(`Could not paste the image`)}function ZX(e){let t=e.prefs.terminal,[n,r]=(0,F.useState)(!tR.some(e=>e.family===t.font.family));function i(t){L9({...e.prefs,terminal:t})}function a(e,n){i({...t,[e]:{...t[e],...n}})}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(XL,{title:`Font`,children:[(0,I.jsx)(ZL,{label:`Family`,children:(0,I.jsxs)(TL,{value:n?`custom`:t.font.family,onValueChange:e=>{r(e===`custom`),e!==`custom`&&a(`font`,{family:e})},children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[tR.map(e=>(0,I.jsx)(kL,{value:e.family,children:e.label},e.family)),(0,I.jsx)(kL,{value:`custom`,children:`Custom`})]})]})}),n&&(0,I.jsx)(ZL,{label:`Custom family`,children:(0,I.jsx)(QL,{placeholder:`Installed font name`,value:t.font.family,onCommit:e=>a(`font`,{family:e})})}),(0,I.jsx)(ZL,{label:`Size`,children:(0,I.jsx)($L,{value:t.font.size,step:.5,onCommit:e=>a(`font`,{size:e})})}),(0,I.jsx)(ZL,{label:`Line height`,children:(0,I.jsx)($L,{value:t.font.lineHeight,step:.05,onCommit:e=>a(`font`,{lineHeight:e})})}),(0,I.jsx)(ZL,{label:`Ligatures`,children:(0,I.jsx)(KL,{checked:t.font.ligatures,onCheckedChange:e=>a(`font`,{ligatures:e})})}),(0,I.jsx)(ZL,{label:`Bold text in bright colors`,children:(0,I.jsx)(KL,{checked:t.boldIsBright,onCheckedChange:e=>i({...t,boldIsBright:e})})})]}),(0,I.jsxs)(XL,{title:`Cursor`,children:[(0,I.jsx)(ZL,{label:`Style`,children:(0,I.jsxs)(TL,{value:t.cursor.style,onValueChange:e=>a(`cursor`,{style:e}),children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`block`,children:`Block`}),(0,I.jsx)(kL,{value:`bar`,children:`Bar`}),(0,I.jsx)(kL,{value:`underline`,children:`Underline`})]})]})}),(0,I.jsx)(ZL,{label:`Blink`,children:(0,I.jsx)(KL,{checked:t.cursor.blink,onCheckedChange:e=>a(`cursor`,{blink:e})})})]}),(0,I.jsx)(QX,{behavior:t.behavior,onChange:e=>a(`behavior`,e)}),(0,I.jsx)($X,{behavior:t.behavior,onChange:e=>a(`behavior`,e)}),(0,I.jsxs)(XL,{title:`Layout`,children:[[`top`,`right`,`bottom`,`left`].map(e=>(0,I.jsx)(ZL,{label:`Padding ${e}`,children:(0,I.jsx)($L,{value:t.padding[e],onCommit:t=>a(`padding`,{[e]:t})})},e)),(0,I.jsx)(ZL,{label:`Scrollback lines`,children:(0,I.jsx)($L,{value:t.scrollback,step:1e3,onCommit:e=>i({...t,scrollback:e})})})]})]})}function QX(e){return(0,I.jsxs)(XL,{title:`Behavior`,children:[(0,I.jsx)(ZL,{label:`Modernize Shift+Enter`,children:(0,I.jsx)(KL,{checked:e.behavior.modernizeShiftEnter,onCheckedChange:t=>e.onChange({modernizeShiftEnter:t})})}),(0,I.jsx)(ZL,{label:`${KX.linux.label} (${KX.windows.label} on Windows machines) pastes images from the browser clipboard`,children:(0,I.jsx)(KL,{checked:e.behavior.pasteBrowserImages,onCheckedChange:t=>e.onChange({pasteBrowserImages:t})})}),(0,I.jsx)(ZL,{label:`Capture browser shortcuts`,children:(0,I.jsx)(KL,{checked:e.behavior.captureShortcuts,onCheckedChange:t=>e.onChange({captureShortcuts:t})})}),(0,I.jsx)(ZL,{label:`Click moves the cursor in the command line`,children:(0,I.jsx)(KL,{checked:e.behavior.clickToMoveCursor,onCheckedChange:t=>e.onChange({clickToMoveCursor:t})})}),(0,I.jsx)(ZL,{label:`Ask before closing a tab that is running a program`,children:(0,I.jsx)(KL,{checked:e.behavior.confirmCloseBusyTab,onCheckedChange:t=>e.onChange({confirmCloseBusyTab:t})})})]})}function $X(e){return Ee?(0,I.jsx)(XL,{title:`Mac keys`,note:`Meta keeps that Option key from typing @, | and other symbols. Safari and Firefox use US key positions`,children:(0,I.jsx)(ZL,{label:`Use Option as Meta`,children:(0,I.jsxs)(TL,{value:e.behavior.optionAsMeta,onValueChange:t=>e.onChange({optionAsMeta:t}),children:[(0,I.jsx)(DL,{className:`w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsxs)(OL,{children:[(0,I.jsx)(kL,{value:`off`,children:`Off`}),(0,I.jsx)(kL,{value:`left`,children:`Left Option`}),(0,I.jsx)(kL,{value:`right`,children:`Right Option`}),(0,I.jsx)(kL,{value:`both`,children:`Both Options`})]})]})})}):null}var eZ=[`General`,`Terminal`,`Notifications`,`Shortcuts`,`Machines`],tZ=[`Machine`,`Claude`,`Codex`,`OpenCode`];function nZ(){let e=Q(e=>e.machines),t=Q(e=>e.settingsMachine===null?null:T9(e,e.settingsMachine)),n=Q(e=>e.settingsPage),r=sZ(n),i=Q(e=>r===null?null:e.settingsAccount),a=Q(e=>n===`Machines`?e.machines.find(t=>t.id===e.settingsEditedMachine)??null:null);return{machines:e,machine:t,config:t===null?null:t.config,system:t===null?null:t.system,page:n,provider:r,account:i,editedMachine:a,subpage:i!==null||a!==null,subpageTitle:i===`new`?`New account`:i===null?a?.name:[...t?.claudeAccounts??[],...t?.codexAccounts??[]].find(e=>e.id===i)?.name}}function rZ(){let e=Q(e=>e.settingsOpen),t=nZ(),n=t.page,r=t.machine;function i(e){return(0,I.jsx)(`button`,{className:P(`text-muted-foreground hover:bg-accent hover:text-foreground flex h-9 flex-none items-center rounded-md px-2 text-sm transition-colors`,e===n&&`bg-accent text-foreground`),onClick:()=>I9(e),children:(0,I.jsx)(iZ,{page:e})},e)}return(0,I.jsx)(_e,{open:e,onOpenChange:F9,children:(0,I.jsxs)(ae,{showCloseButton:!1,"aria-describedby":void 0,className:`flex h-[min(44rem,calc(100dvh-2rem))] flex-col gap-0 overflow-hidden p-0 sm:max-w-4xl sm:flex-row`,children:[(0,I.jsxs)(`nav`,{className:`flex flex-none gap-1 overflow-x-auto border-b p-3 sm:w-48 sm:flex-col sm:border-r sm:border-b-0`,children:[(0,I.jsx)(pe,{className:`hidden px-2 pt-1 pb-3 text-base font-semibold sm:block`,children:`Settings`}),eZ.map(i),(0,I.jsxs)(`div`,{className:`flex flex-none items-center gap-1 sm:mt-6 sm:flex-col sm:items-stretch`,children:[r!==null&&t.machines.length>1&&(0,I.jsxs)(TL,{value:r.id,onValueChange:e=>$({settingsMachine:e,settingsAccount:null}),children:[(0,I.jsx)(DL,{className:`mb-1 w-40 sm:w-full`,children:(0,I.jsx)(EL,{})}),(0,I.jsx)(OL,{children:t.machines.map(e=>(0,I.jsxs)(kL,{value:e.id,children:[(0,I.jsx)(w,{icon:Fv[e.icon]}),e.name]},e.id))})]}),r!==null&&t.machines.length===1&&(0,I.jsxs)(`p`,{className:`text-muted-foreground flex h-9 items-center gap-1.5 px-2 text-xs font-medium [&_svg]:size-4`,children:[(0,I.jsx)(w,{icon:Fv[r.icon]}),(0,I.jsx)(`span`,{className:`truncate`,children:r.name})]}),tZ.map(i)]})]}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 pt-4 pb-7`,children:[(0,I.jsxs)(`div`,{className:`mb-5 flex h-9 items-center`,children:[t.subpage&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground text-xl font-semibold tracking-tight transition-colors`,onClick:()=>$({settingsAccount:null,settingsEditedMachine:null}),children:n}),(0,I.jsx)(w,{icon:Fg,className:`text-muted-foreground mx-1.5 size-5`}),(0,I.jsx)(`h2`,{className:`truncate text-xl font-semibold tracking-tight`,children:t.subpageTitle})]}),!t.subpage&&(0,I.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:n===`Machine`?`General`:n}),(0,I.jsx)(aZ,{view:t,className:`ml-3`}),(0,I.jsx)(fe,{asChild:!0,children:(0,I.jsx)(x,{variant:`ghost`,size:`icon`,className:`-mr-2 ml-auto`,"aria-label":`Close settings`,children:(0,I.jsx)(w,{icon:Wg})})})]}),(0,I.jsx)(oZ,{view:t})]})]})})}function iZ(e){let t=sZ(e.page);return(0,I.jsxs)(I.Fragment,{children:[t!==null&&(0,I.jsx)(`span`,{className:`mr-2.5 flex size-4 items-center justify-center`,children:(0,I.jsx)(zv,{provider:t,className:P(t===`claude`&&`size-4`,t===`codex`&&`size-[19px] shrink-0`,t===`opencode`&&`h-3.5`)})}),e.page===`Machine`?`General`:e.page]})}function aZ(e){let t=e.view.machine,n=e.view.config,r=e.view.provider;return r===null||e.view.account!==null||t===null||n===null?null:(0,I.jsx)(KL,{className:e.className,checked:n.enabledProviders[r],onCheckedChange:e=>void H9(t.id,{...n,enabledProviders:{...n.enabledProviders,[r]:e}}),"aria-label":`Enable ${e.view.page}`})}function oZ(e){let t=Q(e=>e.prefs),n=e.view.page,r=e.view.machine,i=e.view.config,a=e.view.system,o=tZ.includes(n),[s,c]=(0,F.useState)(null),[l,u]=(0,F.useState)(0);return(0,I.jsxs)(I.Fragment,{children:[o&&r!==null&&r.configError!==null&&(0,I.jsxs)(`p`,{className:`text-destructive mb-5 text-sm whitespace-pre-wrap`,children:[`Not saved: `,r.configError]}),(0,I.jsxs)(`div`,{className:`w-full space-y-5`,children:[n===`General`&&(0,I.jsx)(Aae,{prefs:t,onRestore:()=>c(`browser`)}),n===`Machine`&&r!==null&&i!==null&&a!==null&&(0,I.jsx)(pR,{machine:r.id,config:i,platform:a.platform,defaultShell:a.defaultShell,claudeAccounts:r.claudeAccounts,codexAccounts:r.codexAccounts,openCode:r.openCode,onRestore:()=>c(`machine`)}),o&&r===null&&(0,I.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Add a machine to see its settings.`}),o&&r!==null&&(i===null||a===null)&&(0,I.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[r.name,` is not connected. Its settings show up once it is.`]}),n===`Terminal`&&(0,I.jsx)(ZX,{prefs:t}),n===`Notifications`&&(0,I.jsx)(kX,{prefs:t}),e.view.provider!==null&&r!==null&&i!==null&&r.composer!==null&&a!==null&&(0,I.jsx)(IX,{machine:r.id,config:i,composer:r.composer,platform:a.platform,defaultClaudeBaseDir:a.defaultClaudeBaseDir,provider:e.view.provider,claudeAccounts:r.claudeAccounts,codexAccounts:r.codexAccounts,openCode:r.openCode,selected:e.view.account},e.view.provider),n===`Machines`&&(0,I.jsx)(QY,{}),n===`Shortcuts`&&(0,I.jsx)(HX,{})]},l),(0,I.jsx)(LL,{open:s!==null,onOpenChange:e=>{e||c(null)},children:(0,I.jsxs)(zL,{children:[(0,I.jsxs)(BL,{children:[(0,I.jsx)(HL,{children:s===`browser`?`Restore browser defaults?`:`Restore machine defaults?`}),(0,I.jsx)(UL,{children:s===`browser`?`All settings of this browser go back to their defaults.`:`All settings of ${r?.name} go back to their defaults.`})]}),(0,I.jsxs)(VL,{children:[(0,I.jsx)(GL,{children:`Cancel`}),(0,I.jsx)(WL,{variant:`destructive`,onClick:()=>{if(u(l+1),s===`browser`)L9(YL);else{if(r===null||i===null||a===null)throw Error(`Restoring machine defaults needs a connected machine`);H9(r.id,{...a.defaults,claudeAccounts:i.claudeAccounts,codexAccounts:i.codexAccounts})}},children:`Restore defaults`})]})]})})]})}function sZ(e){return e===`Claude`?`claude`:e===`Codex`?`codex`:e===`OpenCode`?`opencode`:null}function cZ(){let e=Q(e=>e.settingsOpen),t=Q(e=>e.settingsListing),n=nZ(),r=n.machine;function i(){t?F9(!1):n.subpage?$({settingsAccount:null,settingsEditedMachine:null}):$({settingsListing:!0})}function a(e){return(0,I.jsxs)(`button`,{className:`active:bg-accent flex min-h-12 w-full items-center px-4 text-left text-sm font-medium`,onClick:()=>I9(e),children:[(0,I.jsx)(iZ,{page:e}),(0,I.jsx)(w,{icon:Fg,className:`text-muted-foreground ml-auto size-4`})]},e)}return(0,I.jsx)(N,{open:e,onOpenChange:F9,children:(0,I.jsx)(xe,{children:(0,I.jsxs)(de,{"aria-describedby":void 0,className:`bg-background text-foreground data-open:animate-in data-open:slide-in-from-right fixed inset-0 z-50 flex flex-col pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] text-sm duration-200 outline-none [--workspace-topbar-height:44px] motion-reduce:animate-none`,children:[(0,I.jsxs)(`header`,{className:`flex h-(--workspace-topbar-height) shrink-0 items-center gap-1.5 pr-3 pl-1`,children:[(0,I.jsx)(x,{variant:`ghost`,size:`icon`,"aria-label":`Back`,onClick:i,children:(0,I.jsx)(w,{icon:Pg,className:`text-foreground size-5`,strokeWidth:2})}),(0,I.jsxs)(we,{className:`min-w-0 flex-1 truncate font-medium`,children:[t&&`Settings`,!t&&n.subpage&&n.subpageTitle,!t&&!n.subpage&&n.page]}),!t&&(0,I.jsx)(aZ,{view:n,className:`shrink-0`})]}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 pt-2 pb-6`,children:[t&&(0,I.jsxs)(`div`,{className:`space-y-5`,children:[(0,I.jsx)(XL,{title:`This browser`,children:eZ.map(a)}),(0,I.jsxs)(XL,{title:`Machine`,children:[r!==null&&(0,I.jsxs)(ZL,{label:`Machine`,children:[n.machines.length>1&&(0,I.jsxs)(TL,{value:r.id,onValueChange:e=>$({settingsMachine:e,settingsAccount:null}),children:[(0,I.jsx)(DL,{className:`w-40`,children:(0,I.jsx)(EL,{})}),(0,I.jsx)(OL,{children:n.machines.map(e=>(0,I.jsxs)(kL,{value:e.id,children:[(0,I.jsx)(w,{icon:Fv[e.icon]}),e.name]},e.id))})]}),n.machines.length===1&&(0,I.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1.5 text-sm [&_svg]:size-4`,children:[(0,I.jsx)(w,{icon:Fv[r.icon]}),r.name]})]}),tZ.map(a)]})]}),!t&&(0,I.jsx)(oZ,{view:n})]})]})})})}function lZ(){return(0,I.jsx)(`div`,{className:`grid flex-1 place-items-center p-6`,children:(0,I.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,I.jsx)(`h1`,{className:`text-foreground text-center text-2xl font-normal tracking-tight sm:text-3xl`,children:`Connect a machine`}),(0,I.jsx)(`p`,{className:`text-muted-foreground mt-2 text-center text-sm`,children:`Run this on the computer you want to use, then open the pairing link it prints.`}),(0,I.jsx)(`pre`,{className:`bg-muted text-foreground mt-5 rounded-lg px-4 py-3 font-mono text-sm select-all`,children:`npx offsite serve`}),(0,I.jsx)(`p`,{className:`text-muted-foreground mt-8 mb-3 text-sm`,children:`Or connect it here.`}),(0,I.jsx)(YY,{actions:e=>(0,I.jsx)(x,{type:`submit`,className:`mt-4`,disabled:!e,children:`Connect`})})]})})}function uZ(){let e=Q(e=>e.paletteOpen),t=Q(e=>e.selection),n=Q(e=>e.sessions),r=Q(e=>e.machines),i=Q(e=>e.projects),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(0),l=(0,F.useRef)(null),u=a.toLowerCase().split(/\s+/).filter(Boolean),d=[...t===null?[]:[{key:`new`,label:`New thread`,detail:i.find(e=>e.machine===t.machine&&e.id===t.projectId)?.path??``,run:()=>WC({...t,sessionId:null})}],{key:`accounts`,label:`Manage accounts`,detail:``,run:()=>I9(C9[Z().settings.provider])},{key:`settings`,label:`Settings`,detail:`Theme, notifications, keyboard shortcuts`,run:()=>F9(!0)}],f=n.map(e=>({key:f9(e.machine,e.id),label:e.title,detail:`${e.status===`minimized`?`Minimized · `:``}${r.length>1?`${r.find(t=>t.id===e.machine)?.name??``}:`:``}${i.find(t=>t.machine===e.machine&&t.id===e.projectId)?.path??``}`,run:()=>WC({machine:e.machine,projectId:e.projectId,sessionId:e.id})})),p=[...d,...f].filter(e=>{let t=`${e.label} ${e.detail}`.toLowerCase();return u.every(e=>t.includes(e))}).slice(0,50),m=Math.min(s,p.length-1);(0,F.useLayoutEffect)(()=>{l.current?.querySelector(`[data-active="true"]`)?.scrollIntoView({block:`nearest`})},[m]);function h(e){P9(!1),e.run()}return(0,I.jsx)(_e,{open:e,onOpenChange:e=>{P9(e),o(``),c(0)},children:(0,I.jsxs)(ae,{showCloseButton:!1,className:`top-[20%] translate-y-0 gap-0 overflow-hidden p-0 sm:max-w-xl`,children:[(0,I.jsx)(pe,{className:`sr-only`,children:`Search threads`}),(0,I.jsxs)(`label`,{className:`flex items-center gap-2 border-b px-4`,children:[(0,I.jsx)(w,{icon:H_,className:`text-muted-foreground size-4 shrink-0`}),(0,I.jsx)(`input`,{value:a,onChange:e=>{o(e.target.value),c(0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;c((m+t+p.length)%p.length)}e.key===`Enter`&&m>=0&&(e.preventDefault(),h(p[m]))},placeholder:`Search threads and actions…`,className:`placeholder:text-placeholder/75 h-11 w-full bg-transparent text-sm outline-none`})]}),(0,I.jsxs)(`div`,{ref:l,className:`max-h-96 overflow-y-auto p-1`,children:[p.length===0&&(0,I.jsx)(`p`,{className:`text-muted-foreground px-3 py-6 text-center text-xs`,children:`Nothing matches.`}),p.map((e,t)=>(0,I.jsxs)(`button`,{"data-active":t===m,className:P(`flex w-full cursor-pointer flex-col rounded-lg px-2.5 py-1.5 text-left`,t===m&&`bg-accent`),onMouseMove:()=>c(t),onClick:()=>h(e),children:[(0,I.jsx)(`span`,{className:`truncate text-sm`,children:e.label}),e.detail!==``&&(0,I.jsx)(`span`,{className:`text-secondary-label truncate text-xs`,children:e.detail})]},e.key))]})]})})}var dZ=`group/sidebar-row relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`;function fZ(e){let t=e.session,n=jv(t.machine,t.projectId),r=Q(e=>Fv[T9(e,t.machine).icon]),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(!1),u=(0,F.useRef)(null),d=e.activity?.waiting===!0,f=!d&&e.activity?.running===!0,p=Object.values(e.activity?.tasks??{}).includes(`running`),m=f||!d&&p,h=e.activity?.running===!0||p,g=!d&&!m&&e.unseen,_=!e.selected&&!d&&!g;function v(){nw(t.machine,t.id,e.scope)}function y(){h?l(!0):v()}let b=(0,I.jsx)(LL,{open:c,onOpenChange:l,children:(0,I.jsxs)(zL,{children:[(0,I.jsxs)(BL,{children:[(0,I.jsx)(HL,{children:`Stop running work?`}),(0,I.jsx)(UL,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,I.jsxs)(VL,{children:[(0,I.jsx)(GL,{children:`Cancel`}),(0,I.jsx)(WL,{variant:`destructive`,onClick:v,children:`Stop and Make Inactive`})]})]})}),x=e.saved&&(0,I.jsxs)(yC,{onOpenChange:()=>s(!1),children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground inline-flex h-5 cursor-pointer items-center rounded-md px-1.5`,title:`Thread actions`,onClick:e=>e.stopPropagation(),children:(0,I.jsx)(w,{icon:m_,className:`size-3.5`})})}),(0,I.jsxs)(SC,{align:`end`,className:`w-44`,onClick:e=>e.stopPropagation(),onCloseAutoFocus:e=>{u.current!==null&&(e.preventDefault(),u.current.focus(),u.current.select())},children:[(0,I.jsxs)(CC,{onSelect:()=>a(t.title),children:[(0,I.jsx)(w,{icon:M_}),`Rename`]}),(0,I.jsxs)(CC,{onSelect:()=>void tw(t.machine,t.id,{status:t.status===`pinned`?`active`:`pinned`}),children:[(0,I.jsx)(w,{icon:t.status===`pinned`?N_:P_}),t.status===`pinned`?`Unpin`:`Pin`]}),(0,I.jsxs)(CC,{onSelect:()=>void tw(t.machine,t.id,{status:t.status===`minimized`?`active`:`minimized`}),children:[(0,I.jsx)(w,{icon:t.status===`minimized`?T_:D_}),t.status===`minimized`?`Restore`:`Minimize`]}),t.status===`inactive`?(0,I.jsxs)(CC,{onSelect:()=>void tw(t.machine,t.id,{status:`active`}),children:[(0,I.jsx)(w,{icon:L_}),`Make active`]}):(0,I.jsxs)(CC,{onSelect:y,children:[(0,I.jsx)(w,{icon:I_}),`Make inactive`]}),(0,I.jsx)(OC,{}),(0,I.jsxs)(CC,{variant:`destructive`,title:`Also removes it from ${uw[t.provider]}`,onSelect:e=>{o?rw(t.machine,t.id):(e.preventDefault(),s(!0))},children:[(0,I.jsx)(w,{icon:d_}),o?`Click again to delete`:`Delete`]})]})]}),S=i===null?(0,I.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate text-sm`,_?`text-secondary-label font-normal`:`font-medium`,!_&&(e.unseen||d)&&`text-foreground`,!_&&!e.unseen&&!d&&`text-foreground/90`),children:t.title}):(0,I.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let n=i.trim();a(null),n!==``&&n!==t.title&&tw(t.machine,t.id,{title:n})},children:(0,I.jsx)(`input`,{ref:u,value:i,onChange:e=>a(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>a(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&a(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),C=P(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,_&&`text-sidebar-muted-foreground/75 hover:bg-sidebar-row-hover hover:text-sidebar-foreground`,!e.selected&&!_&&`text-sidebar-foreground hover:bg-sidebar-row-hover bg-transparent`);return e.slim?(0,I.jsxs)(`li`,{className:`list-none`,children:[(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,className:P(dZ,C,`flex h-9 items-center gap-2.5 px-2.5`),onClick:e.onSelect,onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:[(0,I.jsx)(`span`,{className:`flex shrink-0 items-center opacity-40 grayscale transition-opacity group-hover/sidebar-row:opacity-100 group-hover/sidebar-row:grayscale-0`,children:(0,I.jsx)(Lv,{machine:t.machine,projectId:t.projectId})}),S,(0,I.jsxs)(`span`,{className:`relative ml-auto flex h-6 min-w-8 shrink-0 items-center justify-end`,children:[(0,I.jsx)(`span`,{className:`text-secondary-label group-any-hover/sidebar-row:opacity-0 inline-flex justify-end text-xs tabular-nums transition-opacity`,children:fw(t.updatedAt)}),(0,I.jsx)(`span`,{className:`group-any-hover/sidebar-row:opacity-100 absolute inset-y-0 right-0 -mr-1 flex items-center opacity-0 transition-opacity has-[[data-state=open]]:opacity-100`,children:x})]})]}),b]}):(0,I.jsxs)(`li`,{className:`list-none py-0.5`,children:[(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,className:P(dZ,C,m&&!e.selected&&`opacity-70 transition-opacity focus-within:opacity-100 hover:opacity-100`),onClick:e.onSelect,onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:[(0,I.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,I.jsx)(Lv,{machine:t.machine,projectId:t.projectId,className:`size-5`}),S,t.status===`pinned`&&(0,I.jsx)(w,{icon:P_,className:`text-muted-foreground/65 size-3 shrink-0`}),m&&(0,I.jsx)(`span`,{title:f?`Working`:`Running in background`,className:P(`flex`,f?`text-info`:`text-muted-foreground`),children:(0,I.jsx)(w,{icon:e_,className:`size-4 shrink-0 animate-spin`})}),d&&(0,I.jsx)(`span`,{title:`Waiting for approval`,className:`text-warning-foreground flex`,children:(0,I.jsx)(w,{icon:Y_,className:`size-4 shrink-0`})}),g&&(0,I.jsx)(`span`,{title:`Done`,className:`text-success flex`,children:(0,I.jsx)(w,{icon:$g,className:`size-4 shrink-0`})})]}),(0,I.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsx)(w,{icon:r,className:`size-3 shrink-0`}),(0,I.jsxs)(`span`,{className:P(`min-w-0 flex-1 truncate`,_?`font-normal`:`font-medium`),children:[n,t.branch!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | ${t.branch}`})]}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:fw(t.updatedAt)})]})]}),e.saved&&(0,I.jsxs)(`div`,{className:P(`group-any-hover/sidebar-row:pointer-events-auto group-any-hover/sidebar-row:opacity-100 pointer-events-none absolute inset-y-0 right-0 flex w-20 flex-col items-end bg-linear-to-l from-50% to-transparent py-(--sidebar-content-inset) pr-1.5 opacity-0 transition-opacity has-[[data-state=open]]:pointer-events-auto has-[[data-state=open]]:opacity-100`,e.selected?`from-sidebar-row-active`:`from-sidebar-row-hover`),children:[(0,I.jsx)(`div`,{className:`flex h-6 items-center`,children:(0,I.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground inline-flex h-5 cursor-pointer items-center rounded-md px-1.5`,title:`Make inactive`,"aria-label":`Make inactive`,onClick:e=>{e.stopPropagation(),y()},children:(0,I.jsx)(w,{icon:I_,className:`size-3.5 scale-160`})})}),(0,I.jsx)(`div`,{className:`mt-1 flex h-5 items-center`,children:x})]})]}),b]})}function pZ(e){let t=jv(e.machine,e.projectId),n=Q(t=>Fv[T9(t,e.machine).icon]);return(0,I.jsx)(`li`,{className:`list-none py-0.5`,children:(0,I.jsx)(`div`,{role:`button`,tabIndex:0,className:P(dZ,`bg-sidebar-row-active text-sidebar-foreground`),onClick:e.onSelect,children:(0,I.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,I.jsx)(Lv,{machine:e.machine,projectId:e.projectId,className:`size-5`}),(0,I.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,I.jsx)(w,{icon:X_,className:`text-warning-foreground size-4 shrink-0`})]}),(0,I.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsx)(w,{icon:n,className:`size-3 shrink-0`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:[t,(0,I.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | Draft`})]}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`now`})]})]})})})}function mZ(e){return(0,I.jsxs)(yC,{children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsx)(`button`,{className:e.className,title:`Menu`,"aria-label":`Menu`,children:(0,I.jsx)(w,{icon:bee})})}),(0,I.jsxs)(SC,{align:`start`,className:`w-48`,children:[(0,I.jsx)(TC,{value:e.filter,children:[[`active`,L_],[`minimized`,D_],[`inactive`,I_]].map(([t,n])=>(0,I.jsxs)(EC,{value:t,className:`capitalize`,onSelect:()=>e.onFilter(t),children:[(0,I.jsx)(w,{icon:n}),t]},t))}),(0,I.jsx)(OC,{}),(0,I.jsxs)(CC,{onSelect:()=>F9(!0),children:[(0,I.jsx)(w,{icon:G_}),`Settings`]})]})]})}function hZ({...e}){return(0,I.jsx)(Ub,{"data-slot":`context-menu`,...e})}function gZ({className:e,...t}){return(0,I.jsx)(Gb,{"data-slot":`context-menu-trigger`,className:P(`select-none`,e),...t})}function _Z({className:e,...t}){return(0,I.jsx)(Kb,{children:(0,I.jsx)(Jb,{"data-slot":`context-menu-content`,className:P(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...t})})}function vZ({className:e,inset:t,variant:n=`default`,...r}){return(0,I.jsx)(Yb,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:P(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function yZ({className:e,children:t,checked:n,inset:r,...i}){return(0,I.jsxs)(Xb,{"data-slot":`context-menu-checkbox-item`,"data-inset":r,className:P(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...i,children:[(0,I.jsx)(`span`,{className:`pointer-events-none absolute right-2`,children:(0,I.jsx)(Zb,{children:(0,I.jsx)(w,{icon:Pee,strokeWidth:2})})}),t]})}function bZ({className:e,...t}){return(0,I.jsx)(Qb,{"data-slot":`context-menu-separator`,className:P(`-mx-1 my-1 h-px bg-border`,e),...t})}var xZ=`relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none touch-pan-y [-webkit-touch-callout:none] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`;function SZ(e){let t=e.session,n=jv(t.machine,t.projectId),r=Q(e=>Fv[T9(e,t.machine).icon]),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(0),f=(0,F.useRef)(null),p=(0,F.useRef)(null),m=(0,F.useRef)(!1),h=e.activity?.waiting===!0,g=!h&&e.activity?.running===!0,_=Object.values(e.activity?.tasks??{}).includes(`running`),v=g||!h&&_,y=e.activity?.running===!0||_,b=!h&&!v&&e.unseen,x=!e.selected&&!h&&!b,S=e.saved&&!e.slim&&(t.status===`active`||t.status===`pinned`);function C(){nw(t.machine,t.id,e.scope)}function T(){y?l(!0):C()}function E(e){let t=p.current;p.current=null,d(0),t!==null&&t.swiping&&(m.current=!0,e.clientX-t.x>e.currentTarget.offsetWidth*.4&&T())}let D=(0,I.jsx)(LL,{open:c,onOpenChange:l,children:(0,I.jsxs)(zL,{children:[(0,I.jsxs)(BL,{children:[(0,I.jsx)(HL,{children:`Stop running work?`}),(0,I.jsx)(UL,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,I.jsxs)(VL,{children:[(0,I.jsx)(GL,{children:`Cancel`}),(0,I.jsx)(WL,{variant:`destructive`,onClick:C,children:`Stop and Make Inactive`})]})]})}),O=(0,I.jsxs)(_Z,{className:`w-44`,onCloseAutoFocus:e=>{f.current!==null&&(e.preventDefault(),f.current.focus(),f.current.select())},children:[(0,I.jsxs)(vZ,{onSelect:()=>a(t.title),children:[(0,I.jsx)(w,{icon:M_}),`Rename`]}),(0,I.jsxs)(vZ,{onSelect:()=>void tw(t.machine,t.id,{status:t.status===`pinned`?`active`:`pinned`}),children:[(0,I.jsx)(w,{icon:t.status===`pinned`?N_:P_}),t.status===`pinned`?`Unpin`:`Pin`]}),(0,I.jsxs)(vZ,{onSelect:()=>void tw(t.machine,t.id,{status:t.status===`minimized`?`active`:`minimized`}),children:[(0,I.jsx)(w,{icon:t.status===`minimized`?T_:D_}),t.status===`minimized`?`Restore`:`Minimize`]}),t.status===`inactive`?(0,I.jsxs)(vZ,{onSelect:()=>void tw(t.machine,t.id,{status:`active`}),children:[(0,I.jsx)(w,{icon:L_}),`Make active`]}):(0,I.jsxs)(vZ,{onSelect:T,children:[(0,I.jsx)(w,{icon:I_}),`Make inactive`]}),(0,I.jsx)(bZ,{}),(0,I.jsxs)(vZ,{variant:`destructive`,title:`Also removes it from ${uw[t.provider]}`,onSelect:e=>{o?rw(t.machine,t.id):(e.preventDefault(),s(!0))},children:[(0,I.jsx)(w,{icon:d_}),o?`Tap again to delete`:`Delete`]})]}),k=i===null?(0,I.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate text-sm`,x?`text-secondary-label font-normal`:`font-medium`,!x&&(e.unseen||h)&&`text-foreground`,!x&&!e.unseen&&!h&&`text-foreground/90`),children:t.title}):(0,I.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let n=i.trim();a(null),n!==``&&n!==t.title&&tw(t.machine,t.id,{title:n})},children:(0,I.jsx)(`input`,{ref:f,value:i,onChange:e=>a(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>a(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&a(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),A=P(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,x&&`text-sidebar-muted-foreground/75`,!e.selected&&!x&&`text-sidebar-foreground bg-transparent`);return e.slim?(0,I.jsxs)(`li`,{className:`list-none`,children:[(0,I.jsxs)(hZ,{onOpenChange:()=>s(!1),children:[(0,I.jsx)(gZ,{asChild:!0,disabled:!e.saved,children:(0,I.jsxs)(`div`,{role:`button`,tabIndex:0,className:P(xZ,A,`flex h-9 items-center gap-2.5 px-2.5`),onClick:e.onSelect,onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:[(0,I.jsx)(`span`,{className:`flex shrink-0 items-center opacity-40 grayscale`,children:(0,I.jsx)(Lv,{machine:t.machine,projectId:t.projectId})}),k,(0,I.jsx)(`span`,{className:`text-secondary-label ml-auto shrink-0 text-xs tabular-nums`,children:fw(t.updatedAt)})]})}),O]}),D]}):(0,I.jsxs)(`li`,{className:`relative list-none py-0.5`,children:[u>0&&(0,I.jsx)(`div`,{className:`bg-destructive absolute inset-x-0 inset-y-0.5 flex items-center rounded-md px-4 text-white`,children:(0,I.jsx)(w,{icon:I_,className:`size-6`})}),(0,I.jsxs)(hZ,{onOpenChange:()=>s(!1),children:[(0,I.jsx)(gZ,{asChild:!0,disabled:!e.saved,children:(0,I.jsx)(`div`,{role:`button`,tabIndex:0,className:P(xZ,A,v&&!e.selected&&`opacity-70`,u>0&&`bg-sidebar`),style:u>0?{transform:`translateX(${u}px)`}:void 0,onClick:()=>{m.current?m.current=!1:e.onSelect()},onPointerDown:e=>{S&&e.pointerType===`touch`&&(m.current=!1,p.current={x:e.clientX,y:e.clientY,swiping:!1})},onPointerMove:e=>{let t=p.current;if(t===null)return;let n=e.clientX-t.x,r=e.clientY-t.y;!t.swiping&&Math.abs(n)<10&&Math.abs(r)<10||(!t.swiping&&n<=Math.abs(r)?p.current=null:(t.swiping=!0,d(Math.max(0,n))))},onPointerUp:E,onPointerCancel:()=>{p.current=null,d(0)},onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:(0,I.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,I.jsx)(Lv,{machine:t.machine,projectId:t.projectId,className:`size-5`}),k,t.status===`pinned`&&(0,I.jsx)(w,{icon:P_,className:`text-muted-foreground/65 size-3 shrink-0`}),v&&(0,I.jsx)(`span`,{title:g?`Working`:`Running in background`,className:P(`flex`,g?`text-info`:`text-muted-foreground`),children:(0,I.jsx)(w,{icon:e_,className:`size-4 shrink-0 animate-spin`})}),h&&(0,I.jsx)(`span`,{title:`Waiting for approval`,className:`text-warning-foreground flex`,children:(0,I.jsx)(w,{icon:Y_,className:`size-4 shrink-0`})}),b&&(0,I.jsx)(`span`,{title:`Done`,className:`text-success flex`,children:(0,I.jsx)(w,{icon:$g,className:`size-4 shrink-0`})})]}),(0,I.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsx)(w,{icon:r,className:`size-3 shrink-0`}),(0,I.jsxs)(`span`,{className:P(`min-w-0 flex-1 truncate`,x?`font-normal`:`font-medium`),children:[n,t.branch!==null&&(0,I.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | ${t.branch}`})]}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:fw(t.updatedAt)})]})]})})}),O]}),D]})}function CZ(e){let t=jv(e.machine,e.projectId),n=Q(t=>Fv[T9(t,e.machine).icon]);return(0,I.jsx)(`li`,{className:`list-none py-0.5`,children:(0,I.jsx)(`div`,{role:`button`,tabIndex:0,className:P(xZ,`bg-sidebar-row-active text-sidebar-foreground`),onClick:e.onSelect,children:(0,I.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,I.jsx)(Lv,{machine:e.machine,projectId:e.projectId,className:`size-5`}),(0,I.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,I.jsx)(w,{icon:X_,className:`text-warning-foreground size-4 shrink-0`})]}),(0,I.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,I.jsx)(w,{icon:n,className:`size-3 shrink-0`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:[t,(0,I.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | Draft`})]}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`now`})]})]})})})}function wZ({className:e,...t}){return(0,I.jsx)(wx,{"data-slot":`label`,className:P(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var TZ=/\.(png|jpe?g|gif|webp|svg)$/i;function EZ(e){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(null),s=t?.filter(e=>TZ.test(e)&&e.toLowerCase().includes(r.toLowerCase()));return(0,F.useEffect)(()=>{let t=!1;return(async()=>{try{let r=await L(e.machine,`files.list`,{projectId:e.projectId});t||n(r)}catch(e){t||o(Oe(e))}})(),()=>{t=!0}},[e.machine,e.projectId]),(0,I.jsx)(_e,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(ae,{className:`gap-0 overflow-hidden p-0 sm:max-w-lg`,showCloseButton:!1,"aria-describedby":void 0,children:[(0,I.jsx)(pe,{className:`sr-only`,children:`Pick icon`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 border-b p-1`,children:[(0,I.jsxs)(`label`,{className:`flex h-7 min-w-0 flex-1 items-center gap-2.5 px-2`,children:[(0,I.jsx)(w,{icon:H_,className:`text-muted-foreground size-4 flex-none`}),(0,I.jsx)(`input`,{className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none`,placeholder:`Search images in this project`,value:r,onChange:e=>i(e.target.value)})]}),(0,I.jsx)(fe,{asChild:!0,children:(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,children:(0,I.jsx)(w,{icon:Wg})})})]}),(0,I.jsxs)(`div`,{className:`h-72 overflow-y-auto p-1`,children:[s?.map(t=>(0,I.jsxs)(`button`,{className:`hover:bg-muted flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm transition-colors`,onClick:async()=>{try{let n=await L(e.machine,`files.read`,{projectId:e.projectId,path:t});n.kind===`image`?e.onPick(`data:${n.mediaType};base64,${n.data}`):n.kind===`large`?o(`${t} is too large`):o(`${t} is not an image`)}catch(e){o(Oe(e))}},children:[(0,I.jsx)(w,{icon:S_,className:`text-muted-foreground size-4 flex-none`}),(0,I.jsx)(`span`,{className:`truncate font-mono text-xs`,children:t})]},t)),s?.length===0&&(0,I.jsx)(`p`,{className:`text-muted-foreground grid h-full place-items-center text-sm`,children:r===``?`No images in this project`:`No matching images`})]}),a!==null&&(0,I.jsx)(`p`,{className:`text-destructive border-t px-3 py-2 text-sm break-all`,children:a})]})})}function DZ(e){let t=Q(e=>e.machines),[n,r]=(0,F.useState)(e.machine),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(()=>OZ(t.find(t=>t.id===e.machine))),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(!1),m=c.trim()===``?void 0:i?.listing,h=m?.directories.filter(e=>e.name.toLowerCase().includes(u.toLowerCase()));function g(e){l(e),d(``)}return(0,F.useEffect)(()=>{if(c.trim()===``)return;let e=!1,t=setTimeout(async()=>{try{let t=await L(n,`directories.list`,{path:c});if(e)return;a({path:c,listing:t}),s(null)}catch(t){if(e)return;a(null),s(Oe(t))}},150);return()=>{e=!0,clearTimeout(t)}},[n,c]),(0,I.jsx)(_e,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(ae,{className:`gap-0 overflow-hidden p-0 sm:max-w-lg`,showCloseButton:!1,"aria-describedby":void 0,children:[(0,I.jsx)(pe,{className:`sr-only`,children:`Add project`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 border-b p-1`,children:[(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Home folder`,onClick:()=>g(`~`),children:(0,I.jsx)(w,{icon:cee})}),(0,I.jsx)(`div`,{className:`bg-border mx-0.5 h-4 w-px`}),(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Parent folder`,disabled:m?.parent===void 0||m.parent===null,onClick:()=>{m?.parent!==void 0&&m.parent!==null&&g(m.parent)},children:(0,I.jsx)(w,{icon:Rg})}),(0,I.jsx)(`input`,{"aria-label":`Folder path`,className:`hover:bg-muted focus:bg-muted h-7 min-w-0 flex-1 rounded-md bg-transparent px-1.5 font-mono text-xs outline-none`,spellCheck:!1,value:c,onChange:e=>g(e.target.value)}),(0,I.jsx)(fe,{asChild:!0,children:(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,children:(0,I.jsx)(w,{icon:Wg})})})]}),(0,I.jsxs)(`label`,{className:`flex h-9 items-center gap-2.5 border-b px-3`,children:[(0,I.jsx)(w,{icon:H_,className:`text-muted-foreground size-4 flex-none`}),(0,I.jsx)(`input`,{className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none`,placeholder:`Search this folder`,value:u,onChange:e=>d(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`h-72 overflow-y-auto p-1`,children:[h?.map(e=>(0,I.jsxs)(`button`,{className:`hover:bg-muted flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm transition-colors`,onClick:()=>g(e.path),children:[(0,I.jsx)(w,{icon:v_,className:`text-muted-foreground size-4 flex-none`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),h?.length===0&&(0,I.jsx)(`p`,{className:`text-muted-foreground grid h-full place-items-center text-sm`,children:u===``?`No folders here`:`No matching folders`})]}),o!==null&&c.trim()!==``&&(0,I.jsx)(`p`,{className:`text-destructive border-t px-3 py-2 text-sm break-all`,children:o}),(0,I.jsxs)(ve,{className:`border-t p-3`,children:[t.length>1&&(0,I.jsxs)(TL,{value:n,onValueChange:e=>{r(e),a(null),g(OZ(t.find(t=>t.id===e)))},children:[(0,I.jsx)(DL,{className:`sm:mr-auto sm:w-56`,children:(0,I.jsx)(EL,{})}),(0,I.jsx)(OL,{children:t.map(e=>(0,I.jsx)(kL,{value:e.id,disabled:e.status!==`online`,children:e.name},e.id))})]}),(0,I.jsx)(x,{disabled:i?.path!==c||f,onClick:async()=>{if(i!==null&&i.path===c){p(!0);try{e.onAdd({...await Mv(n,i.listing.path),machine:n})}catch(e){s(Oe(e)),p(!1)}}},children:`Add project`})]})]})})}function OZ(e){return e===void 0||e.config===null||e.system===null?`~`:e.config.workingDir[e.system.platform]??`~`}function kZ(e){let t=e.project.path,[n,r]=(0,F.useState)(e.project.name),[i,a]=(0,F.useState)(e.project.logo),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(!1),m=(0,F.useRef)(null);return(0,I.jsx)(_e,{open:!0,onOpenChange:()=>e.onClose(),children:(0,I.jsxs)(ae,{className:`gap-0 overflow-hidden p-0 sm:max-w-md`,children:[(0,I.jsxs)(`form`,{className:`grid`,onSubmit:async t=>{t.preventDefault(),l(!0);try{await Nv(e.project.machine,e.project.id,{name:n,logo:i}),e.onClose()}catch(e){s(Oe(e)),l(!1)}},children:[(0,I.jsxs)(se,{className:`gap-1 px-6 pt-4 pr-12`,children:[(0,I.jsx)(pe,{className:`text-base`,children:`Edit project`}),(0,I.jsx)(ge,{className:`truncate font-mono text-xs`,title:t,children:t})]}),(0,I.jsxs)(`div`,{className:`grid gap-6 p-6`,children:[(0,I.jsxs)(`div`,{className:`grid gap-2.5`,children:[(0,I.jsx)(wZ,{children:`Icon`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,I.jsx)(Rv,{name:n.trim()===``?dw(t):n,logo:i,className:`ring-foreground/10 size-16 rounded-2xl ring-1 [&>img]:rounded-2xl [&>svg]:rounded-2xl`}),(0,I.jsxs)(`div`,{className:`grid gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,title:`Upload an image from this device`,onClick:()=>m.current?.click(),children:[(0,I.jsx)(w,{icon:Lee}),`Upload`]}),(0,I.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,title:`Choose an image from the project on the server`,onClick:()=>p(!0),children:[(0,I.jsx)(w,{icon:v_}),`Choose from project`]}),i!==null&&(0,I.jsx)(x,{type:`button`,variant:`ghost-muted`,size:`sm`,onClick:()=>a(null),children:`Remove`})]}),(0,I.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`PNG, JPG, GIF, WebP, SVG or ICO, up to 384 KB`})]})]}),(0,I.jsx)(`input`,{ref:m,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp,image/svg+xml,image/x-icon`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];e.target.value=``,t!==void 0&&a(`data:${t.type};base64,${await PC(t)}`)}})]}),(0,I.jsxs)(`div`,{className:`grid gap-2`,children:[(0,I.jsx)(wZ,{htmlFor:`project-name`,children:`Name`}),(0,I.jsx)(wL,{id:`project-name`,placeholder:dw(t),value:n,onChange:e=>r(e.target.value)})]}),o!==null&&(0,I.jsx)(`p`,{className:`text-destructive text-sm break-all`,children:o})]}),(0,I.jsxs)(ve,{className:`bg-muted/40 border-t px-6 py-4`,children:[(0,I.jsxs)(x,{type:`button`,variant:u?`destructive`:`ghost`,className:P(`sm:mr-auto`,!u&&`text-destructive hover:bg-destructive/10 hover:text-destructive`),title:`Its threads stay in their provider`,onClick:async()=>{if(!u)d(!0);else try{await Pv(e.project.machine,e.project.id),e.onRemoved()}catch(e){s(Oe(e))}},children:[(0,I.jsx)(w,{icon:d_,className:`text-current`}),u?`Click again to remove`:`Remove project`]}),(0,I.jsx)(x,{type:`button`,variant:`outline`,onClick:e.onClose,children:`Cancel`}),(0,I.jsx)(x,{type:`submit`,disabled:n.trim()===``||c,children:`Save`})]})]}),f&&(0,I.jsx)(EZ,{machine:e.project.machine,projectId:e.project.id,onClose:()=>p(!1),onPick:e=>{a(e),p(!1)}})]})})}function AZ(e){let t=Q(e=>e.machines),n=Q(e=>e.projects),r=Q(e=>e.sessions),i=Q(e=>e.unseen),[a,o]=(0,F.useState)(!1),s=t.map(e=>({machine:e,projects:n.filter(t=>t.machine===e.id).sort((e,t)=>e.name.localeCompare(t.name))})).filter(e=>e.projects.length>0),c=r.filter(e=>{let n=k9(t,e.machine,e.id);return n?.running===!0||n?.waiting===!0||Object.values(n?.tasks??{}).includes(`running`)||i.includes(f9(e.machine,e.id))});function l(e,t){return n.find(n=>n.machine===e&&n.id===t)}function u(e){return e.status===`online`?e.name:e.status===`unpaired`?`${e.name} · needs pairing`:`${e.name} · offline`}return(0,I.jsxs)(yC,{open:a,onOpenChange:o,children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsxs)(`button`,{className:`hover:bg-sidebar-row-hover data-[state=open]:bg-sidebar-row-hover -ml-1.5 flex h-7 min-w-0 cursor-pointer items-center gap-1.5 rounded-[var(--control-radius)] px-1.5 text-sm font-medium`,title:e.scope===null?`Inbox`:l(e.scope.machine,e.scope.projectId)?.path,children:[e.scope===null?(0,I.jsx)(w,{icon:C_,className:`size-4 shrink-0 text-(--sidebar-icon-color)`}):(0,I.jsx)(Lv,{machine:e.scope.machine,projectId:e.scope.projectId,className:`size-4 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.scope===null?`Inbox`:l(e.scope.machine,e.scope.projectId)?.name}),(0,I.jsx)(w,{icon:Yg,className:`text-sidebar-muted-foreground size-3.5 shrink-0`})]})}),(0,I.jsxs)(SC,{className:`w-64`,children:[(0,I.jsxs)(TC,{value:e.scope===null?``:f9(e.scope.machine,e.scope.projectId),children:[(0,I.jsxs)(EC,{value:``,className:`pr-9 pl-8 *:data-[slot=dropdown-menu-radio-item-indicator]:right-auto *:data-[slot=dropdown-menu-radio-item-indicator]:left-2`,onSelect:()=>e.onScope(null),children:[(0,I.jsx)(w,{icon:C_}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Inbox`}),c.length>0&&(0,I.jsx)(`span`,{className:`text-foreground grid h-4 min-w-4 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_22%,var(--background))] px-1 text-[10px] leading-none font-medium tabular-nums`,children:c.length})]}),s.length>0&&(0,I.jsx)(OC,{}),s.map(({machine:n,projects:r},i)=>(0,I.jsxs)(F.Fragment,{children:[i>0&&(0,I.jsx)(OC,{}),t.length>1&&(0,I.jsxs)(DC,{className:`text-2xs flex items-center gap-1 pl-5`,children:[(0,I.jsx)(w,{icon:Fv[n.icon],className:`size-3 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:u(n)})]}),r.map(t=>{let n=c.filter(e=>e.machine===t.machine&&e.projectId===t.id).length;return(0,I.jsxs)(EC,{value:f9(t.machine,t.id),title:t.path,className:`group/project pr-2 pl-8 *:data-[slot=dropdown-menu-radio-item-indicator]:right-auto *:data-[slot=dropdown-menu-radio-item-indicator]:left-2`,onSelect:()=>e.onScope({machine:t.machine,projectId:t.id}),onContextMenu:n=>{n.preventDefault(),o(!1),e.onEdit(t)},children:[(0,I.jsx)(Lv,{machine:t.machine,projectId:t.id,className:`size-5 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.name}),n>0&&(0,I.jsx)(`span`,{className:`text-foreground grid h-4 min-w-4 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_22%,var(--background))] px-1 text-[10px] leading-none font-medium tabular-nums`,children:n}),(0,I.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground hover:bg-foreground/10 -my-0.5 grid size-5 shrink-0 cursor-pointer place-items-center rounded-sm opacity-0 transition-opacity group-data-highlighted/project:opacity-100 pointer-coarse:opacity-100 [&_svg]:size-3.5`,title:`Configure project`,"aria-label":`Configure ${t.name}`,onClick:n=>{n.stopPropagation(),o(!1),e.onEdit(t)},children:(0,I.jsx)(w,{icon:G_})})]},f9(t.machine,t.id))})]},n.id))]}),(0,I.jsx)(OC,{}),(0,I.jsxs)(CC,{className:`pl-8`,onSelect:e.onAddProject,children:[(0,I.jsx)(w,{icon:Og}),`Add project…`]}),(0,I.jsxs)(CC,{className:`pl-8`,onSelect:e.onAddMachine,children:[(0,I.jsx)(w,{icon:s_}),`Add machine…`]})]})]})}var jZ=`text-sidebar-muted-foreground/80 hover:bg-sidebar-row-hover hover:text-sidebar-foreground flex shrink-0 cursor-pointer items-center justify-center rounded-[var(--control-radius)] [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-(--sidebar-icon-color) hover:[&>svg]:text-sidebar-foreground`;function MZ(e){let t=Q(e=>e.selection),n=Q(e=>e.machines),r=Q(e=>e.sessions),i=Q(e=>e.projects),a=Q(e=>e.settings.provider),o=Q(e=>e.unseen),s=Q(e=>e.error),[c,l]=Av(`sidebarScope`,null),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(null),[g,_]=(0,F.useState)(!1),[v,y]=(0,F.useState)(!1),[b,x]=(0,F.useState)(`active`),[S,C]=Av(`sidebarWidth`,240),T=r.filter(e=>c===null||e.machine===c.machine&&e.projectId===c.projectId).sort((e,t)=>t.updatedAt-e.updatedAt),E=[...T.filter(e=>e.status===`pinned`),...T.filter(e=>e.status===`active`)],D=T.filter(e=>e.status===`minimized`),O=T.filter(e=>e.status===`inactive`),k=t!==null&&t.sessionId!==null&&!r.some(e=>e.machine===t.machine&&e.id===t.sessionId)?{machine:t.machine,id:t.sessionId,provider:a,title:`New thread`,projectId:t.projectId,branch:null,updatedAt:Date.now(),status:`active`}:null,A=s!==null&&(0,I.jsxs)(sL,{onOpenChange:e=>!e&&rue(),children:[(0,I.jsx)(cL,{asChild:!0,children:(0,I.jsx)(`button`,{className:P(jZ,`[&>svg]:text-error hover:[&>svg]:text-error ml-auto size-7`),title:`Error`,"aria-label":`Error`,children:(0,I.jsx)(w,{icon:kg})})}),(0,I.jsx)(lL,{align:`end`,collisionPadding:12,className:`text-error-foreground max-w-[min(20rem,calc(100vw-2rem))] p-3 text-sm whitespace-pre-wrap`,children:s})]}),ee=e.mobile?CZ:pZ,j=c?.machine??t?.machine??n.at(0)?.id;function M(e,t,n){WC({machine:e,projectId:t,sessionId:n})}function te(){let e=c??t??ne();e===null?d(!0):M(e.machine,e.projectId,null)}function ne(){let e=localStorage.getItem(`lastProject`),t=e===null?null:JSON.parse(e),n=(t===null?void 0:i.find(e=>e.machine===t.machine&&e.id===t.projectId))??i.at(0);return n===void 0?null:{machine:n.machine,projectId:n.id}}Tv([`mod+n`,`mod+t`],te,{enableOnFormTags:!0,preventDefault:!0});function re(e){let t=e.clientX-S;De(e,e=>{let n=Math.min(480,Math.max(200,e.clientX-t));C(n)})}function ie(r,i){let a=e.mobile?SZ:fZ;return(0,I.jsx)(a,{session:r,slim:i,selected:t?.machine===r.machine&&t.sessionId===r.id,activity:k9(n,r.machine,r.id),unseen:o.includes(f9(r.machine,r.id)),saved:r!==k,scope:c,onSelect:()=>M(r.machine,r.projectId,r.id)},f9(r.machine,r.id))}function ae(e,t,n,r,i){return t.length===0?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`li`,{className:P(`mx-0.5 h-9 pt-2`,i&&`mt-auto`),children:(0,I.jsxs)(`button`,{"aria-expanded":n,className:`text-sidebar-muted-foreground/60 flex h-9 w-full cursor-pointer items-center gap-2 rounded-md px-2 text-left text-xs font-medium`,onClick:r,children:[(0,I.jsx)(`span`,{className:`shrink-0`,children:n?e:`${e} (${t.length})`}),(0,I.jsx)(`span`,{className:`bg-sidebar-border/60 h-px min-w-2 flex-1`}),(0,I.jsx)(w,{icon:Yg,className:P(`size-3 shrink-0 transition-transform`,!n&&`rotate-180`)})]})}),n&&t.map(e=>ie(e,e.status===`inactive`))]})}return(0,I.jsxs)(`aside`,{className:P(`bg-sidebar text-sidebar-foreground border-sidebar-border flex flex-none border-r select-none`,e.className),children:[(0,I.jsxs)(`div`,{className:P(`relative flex min-w-0 flex-col`,e.mobile&&`flex-1`),style:e.mobile?void 0:{width:S},children:[(0,I.jsxs)(`div`,{className:`flex h-(--workspace-topbar-height) shrink-0 items-center gap-2 px-3`,children:[e.mobile?(0,I.jsx)(mZ,{className:P(jZ,`size-7`),filter:b,onFilter:x}):(0,I.jsx)(`button`,{className:P(jZ,`size-7`),title:`Hide sidebar (${Te}+B)`,"aria-label":`Hide sidebar`,onClick:e.onHide,children:(0,I.jsx)(w,{icon:Dee})}),(0,I.jsx)(AZ,{scope:c,onScope:l,onEdit:h,onAddProject:()=>d(!0),onAddMachine:()=>p(!0)}),e.mobile&&A,(0,I.jsx)(`button`,{className:P(jZ,`size-7`,(!e.mobile||s===null)&&`ml-auto`),title:`Search (${Te}+K)`,"aria-label":`Search`,onClick:()=>P9(!0),children:(0,I.jsx)(w,{icon:H_})}),(0,I.jsx)(`button`,{className:P(jZ,`size-7`),title:`New thread (${Te}+N)`,onClick:te,children:(0,I.jsx)(w,{icon:X_})})]}),(0,I.jsx)(`nav`,{className:`flex min-h-0 flex-1 [scrollbar-width:none] flex-col overflow-y-auto px-(--sidebar-content-inset) pb-(--sidebar-content-inset)`,children:(0,I.jsxs)(`ul`,{className:`flex flex-1 flex-col gap-px`,children:[e.mobile&&b!==`active`&&(0,I.jsxs)(I.Fragment,{children:[(b===`minimized`?D:O).map(e=>ie(e,b===`inactive`)),(b===`minimized`?D:O).length===0&&(0,I.jsxs)(`li`,{className:`text-sidebar-muted-foreground/60 px-2.5 py-6 text-center text-xs`,children:[`No `,b,` threads`]})]}),(!e.mobile||b===`active`)&&(0,I.jsxs)(I.Fragment,{children:[t!==null&&t.sessionId===null&&(0,I.jsx)(ee,{machine:t.machine,projectId:t.projectId,onSelect:()=>M(t.machine,t.projectId,null)}),k!==null&&ie(k,!1),E.map(e=>ie(e,!1)),E.length===0&&k===null&&t?.sessionId!==null&&(0,I.jsx)(`li`,{className:`text-sidebar-muted-foreground/60 px-2.5 py-6 text-center text-xs`,children:`No threads yet`})]}),!e.mobile&&(0,I.jsxs)(I.Fragment,{children:[ae(`Minimized`,D,g,()=>_(!g),!0),ae(`Inactive`,O,v,()=>y(!v),D.length===0)]})]})}),!e.mobile&&(0,I.jsxs)(`div`,{className:`border-sidebar-border flex shrink-0 items-center gap-1 border-t p-(--sidebar-content-inset)`,children:[(0,I.jsxs)(`button`,{className:P(jZ,`h-8 flex-1 justify-start gap-2 px-2.5 text-sm`),title:`Settings`,onClick:()=>F9(!0),children:[(0,I.jsx)(w,{icon:G_}),`Settings`]}),A]}),!e.mobile&&(0,I.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,className:`group absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize select-none`,onPointerDown:re,children:(0,I.jsx)(`span`,{className:`group-hover:bg-border group-active:bg-primary/60 pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 transition-colors`})})]}),u&&j===void 0&&(0,I.jsx)(XY,{onClose:()=>d(!1)}),u&&j!==void 0&&(0,I.jsx)(DZ,{machine:j,onClose:()=>d(!1),onAdd:e=>{d(!1),l({machine:e.machine,projectId:e.id}),M(e.machine,e.id,null)}}),f&&(0,I.jsx)(XY,{onClose:()=>p(!1)}),m!==null&&(0,I.jsx)(kZ,{project:m,onClose:()=>h(null),onRemoved:()=>{c?.machine===m.machine&&c.projectId===m.id&&l(null),h(null)}})]})}var NZ=`/assets/ghostty-vt-CQAu1Gs5.wasm`,PZ=Uint8Array,FZ=Uint16Array,IZ=Int32Array,LZ=new PZ([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),RZ=new PZ([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),zZ=new PZ([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),BZ=function(e,t){for(var n=new FZ(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new IZ(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},VZ=BZ(LZ,2),HZ=VZ.b,UZ=VZ.r;HZ[28]=258,UZ[258]=28;var WZ=BZ(RZ,0),GZ=WZ.b;WZ.r;for(var KZ=new FZ(32768),qZ=0;qZ<32768;++qZ){var JZ=(qZ&43690)>>1|(qZ&21845)<<1;JZ=(JZ&52428)>>2|(JZ&13107)<<2,JZ=(JZ&61680)>>4|(JZ&3855)<<4,KZ[qZ]=((JZ&65280)>>8|(JZ&255)<<8)>>1}for(var YZ=(function(e,t,n){for(var r=e.length,i=0,a=new FZ(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new FZ(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new FZ(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[KZ[d]>>c]=l}else for(s=new FZ(r),i=0;i<r;++i)e[i]&&(s[i]=KZ[o[e[i]-1]++]>>15-e[i]);return s}),XZ=new PZ(288),qZ=0;qZ<144;++qZ)XZ[qZ]=8;for(var qZ=144;qZ<256;++qZ)XZ[qZ]=9;for(var qZ=256;qZ<280;++qZ)XZ[qZ]=7;for(var qZ=280;qZ<288;++qZ)XZ[qZ]=8;for(var ZZ=new PZ(32),qZ=0;qZ<32;++qZ)ZZ[qZ]=5;var QZ=YZ(XZ,9,1),$Z=YZ(ZZ,5,1),eQ=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},tQ=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},nQ=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},rQ=function(e){return(e+7)/8|0},iQ=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new PZ(e.subarray(t,n))},aQ=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],oQ=function(e,t,n){var r=Error(t||aQ[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,oQ),!n)throw r;return r},sQ=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new PZ(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new PZ(i*3));var l=function(e){var t=n.length;if(e>t){var r=new PZ(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=tQ(e,d,1);var v=tQ(e,d+1,3);if(d+=3,!v){var y=rQ(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&oQ(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=QZ,m=$Z,h=9,g=5;else if(v==2){var S=tQ(e,d,31)+257,C=tQ(e,d+10,15)+4,w=S+tQ(e,d+5,31)+1;d+=14;for(var T=new PZ(w),E=new PZ(19),D=0;D<C;++D)E[zZ[D]]=tQ(e,d+D*3,7);d+=C*3;for(var O=eQ(E),k=(1<<O)-1,A=YZ(E,O,1),D=0;D<w;){var ee=A[tQ(e,d,k)];d+=ee&15;var y=ee>>4;if(y<16)T[D++]=y;else{var j=0,M=0;for(y==16?(M=3+tQ(e,d,3),d+=2,j=T[D-1]):y==17?(M=3+tQ(e,d,7),d+=3):y==18&&(M=11+tQ(e,d,127),d+=7);M--;)T[D++]=j}}var te=T.subarray(0,S),ne=T.subarray(S);h=eQ(te),g=eQ(ne),p=YZ(te,h,1),m=YZ(ne,g,1)}else oQ(1);if(d>_){c&&oQ(0);break}}s&&l(f+131072);for(var re=(1<<h)-1,ie=(1<<g)-1,ae=d;;ae=d){var j=p[nQ(e,d)&re],oe=j>>4;if(d+=j&15,d>_){c&&oQ(0);break}if(j||oQ(2),oe<256)n[f++]=oe;else if(oe==256){ae=d,p=null;break}else{var se=oe-254;if(oe>264){var D=oe-257,ce=LZ[D];se=tQ(e,d,(1<<ce)-1)+HZ[D],d+=ce}var le=m[nQ(e,d)&ie],ue=le>>4;le||oQ(3),d+=le&15;var ne=GZ[ue];if(ue>3){var ce=RZ[ue];ne+=nQ(e,d)&(1<<ce)-1,d+=ce}if(d>_){c&&oQ(0);break}s&&l(f+131072);var de=f+se;if(f<ne){var fe=a-ne,pe=Math.min(ne,de);for(fe+f<0&&oQ(3);f<pe;++f)n[f]=r[fe+f]}for(;f<de;++f)n[f]=n[f-ne]}}t.l=p,t.p=ae,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?iQ(n,0,f):n.subarray(0,f)},cQ=new PZ(0),lQ=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&oQ(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&oQ(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2},uQ=function(){function e(e,t){typeof e==`function`&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new PZ(32768),this.p=new PZ(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||oQ(5),this.d&&oQ(4),!this.p.length)this.p=e;else if(e.length){var t=new PZ(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=sQ(this.p,this.s,this.o);this.ondata(iQ(n,t,this.s.b),this.d),this.o=iQ(n,this.s.b-32768),this.s.b=this.o.length,this.p=iQ(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),dQ=function(){function e(e,t){uQ.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(uQ.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(lQ(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&oQ(6,`invalid zlib data`),this.p=this.p.subarray(0,-4)),uQ.prototype.c.call(this,t)},e}();function fQ(e,t){return sQ(e.subarray(lQ(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var pQ=typeof TextDecoder<`u`&&new TextDecoder;try{pQ.decode(cQ,{stream:!0})}catch{}function mQ(e,t=`utf8`){return new TextDecoder(t).decode(e)}var hQ=new TextEncoder;function gQ(e){return hQ.encode(e)}var _Q=8192,vQ=(()=>{let e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])})(),yQ={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array},bQ=class e{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=_Q,n={}){let r=!1;typeof t==`number`?t=new ArrayBuffer(t):(r=!0,this.lastWrittenByte=t.byteLength);let i=n.offset?n.offset>>>0:0,a=t.byteLength-i,o=i;(ArrayBuffer.isView(t)||t instanceof e)&&(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+i),t=t.buffer),this.lastWrittenByte=r?a:0,this.buffer=t,this.length=a,this.byteLength=a,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,a),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let e=this._marks.pop();if(e===void 0)throw Error(`Mark stack empty`);return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){let t=(this.offset+e)*2,n=new Uint8Array(t);n.set(new Uint8Array(this.buffer)),this.buffer=n.buffer,this.length=t,this.byteLength=t,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,`uint8`)}readArray(e,t){let n=yQ[t].BYTES_PER_ELEMENT*e,r=this.byteOffset+this.offset,i=this.buffer.slice(r,r+n);if(this.littleEndian===vQ&&t!==`uint8`&&t!==`int8`){let e=new Uint8Array(this.buffer.slice(r,r+n));e.reverse();let i=new yQ[t](e.buffer);return this.offset+=n,i.reverse(),i}let a=new yQ[t](i);return this.offset+=n,a}readInt16(){let e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){let e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){let e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){let e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){let e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){let e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){let e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){let e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t=``;for(let n=0;n<e;n++)t+=this.readChar();return t}readUtf8(e=1){return mQ(this.readBytes(e))}decodeText(e=1,t=`utf8`){return mQ(this.readBytes(e),t)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let t=0;t<e.length;t++)this._data.setUint8(this.offset++,e[t]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let t=0;t<e.length;t++)this.writeUint8(e.charCodeAt(t));return this}writeUtf8(e){return this.writeBytes(gQ(e))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}},xQ=[];for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;xQ[e]=t}var SQ=4294967295;function CQ(e,t,n){let r=e;for(let e=0;e<n;e++)r=xQ[(r^t[e])&255]^r>>>8;return r}function wQ(e,t){return(CQ(SQ,e,t)^SQ)>>>0}function TQ(e,t,n){let r=e.readUint32(),i=wQ(new Uint8Array(e.buffer,e.byteOffset+e.offset-t-4,t),t);if(i!==r)throw Error(`CRC mismatch for chunk ${n}. Expected ${r}, found ${i}`)}function EQ(e,t,n){for(let r=0;r<n;r++)t[r]=e[r]}function DQ(e,t,n,r){let i=0;for(;i<r;i++)t[i]=e[i];for(;i<n;i++)t[i]=e[i]+t[i-r]&255}function OQ(e,t,n,r){let i=0;if(n.length===0)for(;i<r;i++)t[i]=e[i];else for(;i<r;i++)t[i]=e[i]+n[i]&255}function kQ(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+(t[a-i]>>1)&255}else{for(;a<i;a++)t[a]=e[a]+(n[a]>>1)&255;for(;a<r;a++)t[a]=e[a]+(t[a-i]+n[a]>>1)&255}}function AQ(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+t[a-i]&255}else{for(;a<i;a++)t[a]=e[a]+n[a]&255;for(;a<r;a++)t[a]=e[a]+jQ(t[a-i],n[a],n[a-i])&255}}function jQ(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}function MQ(e,t,n,r,i,a){switch(e){case 0:EQ(t,n,i);break;case 1:DQ(t,n,i,a);break;case 2:OQ(t,n,r,i);break;case 3:kQ(t,n,r,i,a);break;case 4:AQ(t,n,r,i,a);break;default:throw Error(`Unsupported filter: ${e}`)}}var NQ=new Uint16Array([255]),PQ=new Uint8Array(NQ.buffer)[0]===255;function FQ(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],s=Math.ceil(a/8)*i,c=new Uint8Array(r*n*s),l=0;for(let e=0;e<7;e++){let i=o[e],a=Math.ceil((n-i.x)/i.xStep),u=Math.ceil((r-i.y)/i.yStep);if(a<=0||u<=0)continue;let d=a*s,f=new Uint8Array(d);for(let e=0;e<u;e++){let o=t[l++],u=t.subarray(l,l+d);l+=d;let p=new Uint8Array(d);MQ(o,u,p,f,d,s),f.set(p);for(let t=0;t<a;t++){let a=i.x+t*i.xStep,o=i.y+e*i.yStep;if(!(a>=n||o>=r))for(let e=0;e<s;e++)c[(o*n+a)*s+e]=p[t*s+e]}}}if(a===16){let e=new Uint16Array(c.buffer);if(PQ)for(let t=0;t<e.length;t++)e[t]=IQ(e[t]);return e}return c}function IQ(e){return(e&255)<<8|e>>8&255}var LQ=new Uint16Array([255]),RQ=new Uint8Array(LQ.buffer)[0]===255,zQ=new Uint8Array;function BQ(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=Math.ceil(a/8)*i,s=Math.ceil(a/8*i*n),c=new Uint8Array(r*s),l=zQ,u=0,d,f;for(let e=0;e<r;e++){switch(d=t.subarray(u+1,u+1+s),f=c.subarray(e*s,(e+1)*s),t[u]){case 0:EQ(d,f,s);break;case 1:DQ(d,f,s,o);break;case 2:OQ(d,f,l,s);break;case 3:kQ(d,f,l,s,o);break;case 4:AQ(d,f,l,s,o);break;default:throw Error(`Unsupported filter: ${t[u]}`)}l=f,u+=s+1}if(a===16){let e=new Uint16Array(c.buffer);if(RQ)for(let t=0;t<e.length;t++)e[t]=VQ(e[t]);return e}return c}function VQ(e){return(e&255)<<8|e>>8&255}var HQ=Uint8Array.of(137,80,78,71,13,10,26,10);function UQ(e){if(!WQ(e.readBytes(HQ.length)))throw Error(`wrong PNG signature`)}function WQ(e){if(e.length<HQ.length)return!1;for(let t=0;t<HQ.length;t++)if(e[t]!==HQ[t])return!1;return!0}var GQ=`tEXt`,KQ=0,qQ=new TextDecoder(`latin1`);function JQ(e){if(XQ(e),e.length===0||e.length>79)throw Error(`keyword length must be between 1 and 79`)}var YQ=/^[\u0000-\u00FF]*$/;function XQ(e){if(!YQ.test(e))throw Error(`invalid latin1 text`)}function ZQ(e,t,n){let r=QQ(t);e[r]=$Q(t,n-r.length-1)}function QQ(e){for(e.mark();e.readByte()!==KQ;);let t=e.offset;e.reset();let n=qQ.decode(e.readBytes(t-e.offset-1));return e.skip(1),JQ(n),n}function $Q(e,t){return qQ.decode(e.readBytes(t))}var e$={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},t$={UNKNOWN:-1,DEFLATE:0},n$={UNKNOWN:-1,ADAPTIVE:0},r$={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},i$={NONE:0,BACKGROUND:1,PREVIOUS:2},a$={SOURCE:0,OVER:1},o$=class extends bQ{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;_chunks;_inflatorResult;constructor(e,t={}){super(e);let{checkCrc:n=!1}=t;this._checkCrc=n,this._inflator=new dQ((e,t)=>{if(this._chunks.push(e),t){let e=this._chunks.reduce((e,t)=>e+t.length,0);this._inflatorResult=new Uint8Array(e);let t=0;for(let e of this._chunks)this._inflatorResult.set(e,t),t+=e.length;this._chunks=[]}}),this._chunks=[],this._png={width:-1,height:-1,channels:-1,data:new Uint8Array,depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array,this._compressionMethod=t$.UNKNOWN,this._filterMethod=n$.UNKNOWN,this._interlaceMethod=r$.UNKNOWN,this._colorType=e$.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this._inflatorResult=new Uint8Array,this.setBigEndian()}decode(){for(UQ(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeChunk(e,t)}return this._inflator.push(new Uint8Array,!0),this.decodeImage(),this._png}decodeApng(){for(UQ(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeApngChunk(e,t)}return this.decodeApngImage(),this._apng}decodeChunk(e,t){let n=this.offset;switch(t){case`IHDR`:this.decodeIHDR();break;case`PLTE`:this.decodePLTE(e);break;case`IDAT`:this.decodeIDAT(e);break;case`IEND`:this._end=!0;break;case`tRNS`:this.decodetRNS(e);break;case`iCCP`:this.decodeiCCP(e);break;case GQ:ZQ(this._png.text,this,e);break;case`pHYs`:this.decodepHYs();break;default:this.skip(e)}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?TQ(this,e+4,t):this.skip(4)}decodeApngChunk(e,t){let n=this.offset;switch(t!==`fdAT`&&t!==`IDAT`&&this._writingDataChunks&&this.pushDataToFrame(),t){case`acTL`:this.decodeACTL();break;case`fcTL`:this.decodeFCTL();break;case`fdAT`:this.decodeFDAT(e);break;default:this.decodeChunk(e,t),this.offset=n+e}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?TQ(this,e+4,t):this.skip(4)}decodeIHDR(){let e=this._png;e.width=this.readUint32(),e.height=this.readUint32(),e.depth=s$(this.readUint8());let t=this.readUint8();this._colorType=t;let n;switch(t){case e$.GREYSCALE:n=1;break;case e$.TRUECOLOUR:n=3;break;case e$.INDEXED_COLOUR:n=1;break;case e$.GREYSCALE_ALPHA:n=2;break;case e$.TRUECOLOUR_ALPHA:n=4;break;case e$.UNKNOWN:default:throw Error(`Unknown color type: ${t}`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==t$.DEFLATE)throw Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){let e={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array};this._frames.push(e)}decodePLTE(e){if(e%3!=0)throw RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);let t=e/3;this._hasPalette=!0;let n=[];this._palette=n;for(let e=0;e<t;e++)n.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;try{this._inflator.push(new Uint8Array(this.buffer,n,t),!1)}catch(e){throw Error(`Error while decompressing the data:`,{cause:e})}this.skip(e)}decodeFDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;n+=4,t-=4;try{this._inflator.push(new Uint8Array(this.buffer,n,t),!1)}catch(e){throw Error(`Error while decompressing the data:`,{cause:e})}this.skip(e)}decodetRNS(e){switch(this._colorType){case e$.GREYSCALE:case e$.TRUECOLOUR:if(e%2!=0)throw RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);if(e/2>this._png.width*this._png.height)throw Error(`tRNS chunk contains more alpha values than there are pixels (${e/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(e/2);for(let t=0;t<e/2;t++)this._transparency[t]=this.readUint16();break;case e$.INDEXED_COLOUR:{if(e>this._palette.length)throw Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);let t=0;for(;t<e;t++){let e=this.readByte();this._palette[t].push(e)}for(;t<this._palette.length;t++)this._palette[t].push(255);break}case e$.UNKNOWN:case e$.GREYSCALE_ALPHA:case e$.TRUECOLOUR_ALPHA:default:throw Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(e){let t=QQ(this),n=this.readUint8();if(n!==t$.DEFLATE)throw Error(`Unsupported iCCP compression method: ${n}`);let r=this.readBytes(e-t.length-2);this._png.iccEmbeddedProfile={name:t,profile:fQ(r)}}decodepHYs(){let e=this.readUint32(),t=this.readUint32(),n=this.readByte();this._png.resolution={x:e,y:t,unit:n}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let e=0;e<this._numberOfFrames;e++){let t={sequenceNumber:this._frames[e].sequenceNumber,delayNumber:this._frames[e].delayNumber,delayDenominator:this._frames[e].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},n=this._frames.at(e);if(n){if(n.data=BQ({data:n.data,width:n.width,height:n.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),e===0||n.xOffset===0&&n.yOffset===0&&n.width===this._png.width&&n.height===this._png.height)t.data=n.data;else{let r=this._apng.frames.at(e-1);this.disposeFrame(n,r,t),this.addFrameDataToCanvas(t,n)}this._apng.frames.push(t)}}return this._apng}disposeFrame(e,t,n){switch(e.disposeOp){case i$.NONE:break;case i$.BACKGROUND:for(let t=0;t<this._png.height;t++)for(let r=0;r<this._png.width;r++){let i=(t*e.width+r)*this._png.channels;for(let e=0;e<this._png.channels;e++)n.data[i+e]=0}break;case i$.PREVIOUS:n.data.set(t.data);break;default:throw Error(`Unknown disposeOp`)}}addFrameDataToCanvas(e,t){let n=1<<this._png.depth,r=(e,n)=>({index:((e+t.yOffset)*this._png.width+t.xOffset+n)*this._png.channels,frameIndex:(e*t.width+n)*this._png.channels});switch(t.blendOp){case a$.SOURCE:for(let n=0;n<t.height;n++)for(let i=0;i<t.width;i++){let{index:a,frameIndex:o}=r(n,i);for(let n=0;n<this._png.channels;n++)e.data[a+n]=t.data[o+n]}break;case a$.OVER:for(let i=0;i<t.height;i++)for(let a=0;a<t.width;a++){let{index:o,frameIndex:s}=r(i,a);for(let r=0;r<this._png.channels;r++){let i=t.data[s+this._png.channels-1]/n,a=r%(this._png.channels-1)==0?1:t.data[s+r],c=Math.floor(i*a+(1-i)*e.data[o+r]);e.data[o+r]+=c}}break;default:throw Error(`Unknown blendOp`)}}decodeImage(){let e=this._inflatorResult;if(this._filterMethod!==n$.ADAPTIVE)throw Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===r$.NO_INTERLACE)this._png.data=BQ({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===r$.ADAM7)this._png.data=FQ({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){this._inflator.push(new Uint8Array,!0);let e=this._inflatorResult,t=this._frames.at(-1);t?t.data=e:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:i$.NONE,blendOp:a$.SOURCE,data:e}),this._inflator=new dQ((e,t)=>{if(this._chunks.push(e),t){let e=this._chunks.reduce((e,t)=>e+t.length,0);this._inflatorResult=new Uint8Array(e);let t=0;for(let e of this._chunks)this._inflatorResult.set(e,t),t+=e.length;this._chunks=[]}}),this._chunks=[],this._writingDataChunks=!1}};function s$(e){if(e!==1&&e!==2&&e!==4&&e!==8&&e!==16)throw Error(`invalid bit depth: ${e}`);return e}function c$(e){let t=e.palette,n=e.depth;if(!t)throw Error(`Color palette is undefined.`);l$(e);let r=e.width*e.height,i=r*t[0].length,a=new Uint8Array(i),o=0,s=0,c=new Uint8Array(r),l=255;switch(n){case 1:l=128;break;case 2:l=192;break;case 4:l=240;break;case 8:l=255;break;default:throw Error(`Incorrect depth value`)}for(let t of e.data){let r=l,i=8;for(;r&&(i-=n,c[o++]=(t&r)>>i,r>>=n,o%e.width!==0););}if(e.palette)for(let t of c){let n=e.palette.at(t);if(!n)throw Error(`Incorrect index of palette color`);a.set(n,s),s+=n.length}return a}function l$(e){let t=e.depth<8?Math.ceil(e.width*e.depth/8)*e.height*e.channels:e.width*e.height*e.channels;if(e.data.length!==t)throw RangeError(`wrong data size. Found ${e.data.length}, expected ${t}`)}function u$(e,t){return new o$(e,t).decode()}var d$=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_FOREGROUND=e.DEFAULT_BACKGROUND=e.PALETTE_ANSI_256=e.PALETTE_VT340_GREY=e.PALETTE_VT340_COLOR=e.normalizeHLS=e.normalizeRGB=e.nearestColorIndex=e.fromRGBA8888=e.toRGBA8888=e.alpha=e.blue=e.green=e.red=e.BIG_ENDIAN=void 0,e.BIG_ENDIAN=new Uint8Array(new Uint32Array([4278190080]).buffer)[0]===255,e.BIG_ENDIAN&&console.warn(`BE platform detected. This version of node-sixel works only on LE properly.`);function t(e){return e&255}e.red=t;function n(e){return e>>>8&255}e.green=n;function r(e){return e>>>16&255}e.blue=r;function i(e){return e>>>24&255}e.alpha=i;function a(e,t,n,r=255){return((r&255)<<24|(n&255)<<16|(t&255)<<8|e&255)>>>0}e.toRGBA8888=a;function o(e){return[e&255,e>>8&255,e>>16&255,e>>>24]}e.fromRGBA8888=o;function s(e,i){let a=t(e),o=n(e),s=r(e),c=2**53-1,l=-1;for(let e=0;e<i.length;++e){let t=a-i[e][0],n=o-i[e][1],r=s-i[e][2],u=t*t+n*n+r*r;if(!u)return e;u<c&&(c=u,l=e)}return l}e.nearestColorIndex=s;function c(e,t,n){return Math.max(e,Math.min(n,t))}function l(e,t,n){return n<0&&(n+=1),n>1&&--n,n*6<1?t+(e-t)*6*n:n*2<1?e:n*3<2?t+(e-t)*(4-n*6):t}function u(e,t,n){if(!n){let e=Math.round(t*255);return a(e,e,e)}let r=t<.5?t*(1+n):t+n-t*n,i=2*t-r;return a(c(0,255,Math.round(l(r,i,e+1/3)*255)),c(0,255,Math.round(l(r,i,e)*255)),c(0,255,Math.round(l(r,i,e-1/3)*255)))}function d(e,t,n){return(4278190080|Math.round(n/100*255)<<16|Math.round(t/100*255)<<8|Math.round(e/100*255))>>>0}e.normalizeRGB=d;function f(e,t,n){return u((e+240)/360,t/100,n/100)}e.normalizeHLS=f,e.PALETTE_VT340_COLOR=new Uint32Array([d(0,0,0),d(20,20,80),d(80,13,13),d(20,80,20),d(80,20,80),d(20,80,80),d(80,80,20),d(53,53,53),d(26,26,26),d(33,33,60),d(60,26,26),d(33,60,33),d(60,33,60),d(33,60,60),d(60,60,33),d(80,80,80)]),e.PALETTE_VT340_GREY=new Uint32Array([d(0,0,0),d(13,13,13),d(26,26,26),d(40,40,40),d(6,6,6),d(20,20,20),d(33,33,33),d(46,46,46),d(0,0,0),d(13,13,13),d(26,26,26),d(40,40,40),d(6,6,6),d(20,20,20),d(33,33,33),d(46,46,46)]),e.PALETTE_ANSI_256=(()=>{let e=[a(0,0,0),a(205,0,0),a(0,205,0),a(205,205,0),a(0,0,238),a(205,0,205),a(0,250,205),a(229,229,229),a(127,127,127),a(255,0,0),a(0,255,0),a(255,255,0),a(92,92,255),a(255,0,255),a(0,255,255),a(255,255,255)],t=[0,95,135,175,215,255];for(let n=0;n<6;++n)for(let r=0;r<6;++r)for(let i=0;i<6;++i)e.push(a(t[n],t[r],t[i]));for(let t=8;t<=238;t+=10)e.push(a(t,t,t));return new Uint32Array(e)})(),e.DEFAULT_BACKGROUND=a(0,0,0,255),e.DEFAULT_FOREGROUND=a(255,255,255,255)})),f$=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LIMITS=void 0,e.LIMITS={CHUNK_SIZE:16384,PALETTE_SIZE:4096,MAX_WIDTH:16384,BYTES:`AGFzbQEAAAABJAdgAAF/YAJ/fwBgA39/fwF/YAF/AX9gAABgBH9/f38AYAF/AAIlAgNlbnYLaGFuZGxlX2JhbmQAAwNlbnYLbW9kZV9wYXJzZWQAAwMTEgQAAAAAAQQBAQUBAAACAgAGAwQFAXABBwcFBAEBBwcGCAF/AUGAihoLB9wBDgZtZW1vcnkCABFnZXRfc3RhdGVfYWRkcmVzcwADEWdldF9jaHVua19hZGRyZXNzAAQOZ2V0X3AwX2FkZHJlc3MABRNnZXRfcGFsZXR0ZV9hZGRyZXNzAAYEaW5pdAALBmRlY29kZQAMDWN1cnJlbnRfd2lkdGgADQ5jdXJyZW50X2hlaWdodAAOGV9faW5kaXJlY3RfZnVuY3Rpb25fdGFibGUBAAtfaW5pdGlhbGl6ZQACCXN0YWNrU2F2ZQARDHN0YWNrUmVzdG9yZQASCnN0YWNrQWxsb2MAEwkMAQBBAQsGCgcJDxACDAEBCq5UEgMAAQsFAEGgCAsGAEGQiQELBgBBsIkCCwUAQZAJC+okAQh/QeQIKAIAIQVB4AgoAgAhA0HoCCgCACEIIAFBkIkBaiIJQf8BOgAAIAAgAUgEQCAAQZCJAWohBgNAIAMhBCAGQQFqIQECQCAGLQAAQf8AcSIDQTBrQQlLBEAgASEGDAELQewIKAIAQQJ0QewIaiICKAIAIQADQCACIAMgAEEKbGpBMGsiADYCACABLQAAIQMgAUEBaiIGIQEgA0H/AHEiA0Ewa0EKSQ0ACwsCQAJAAkACQAJAAkACQAJ/AkACQCADQT9rIgBBP00EQCAERQ0BIARBIUYEQAJAQfAIKAIAIgFBASABGyIHIAhqIgFB1AgoAgAiA0gNACADQf//AEoNAANAIANBAnQiAkGgiQJqIgRBoAgpAwA3AwAgAkGoiQJqQaAIKQMANwMAIAJBsIkCakGgCCkDADcDACACQbiJAmpBoAgpAwA3AwAgAkHAiQJqQaAIKQMANwMAIAJByIkCakGgCCkDADcDACACQdCJAmpBoAgpAwA3AwAgAkHYiQJqQaAIKQMANwMAIAJB4IkCakGgCCkDADcDACACQeiJAmpBoAgpAwA3AwAgAkHwiQJqQaAIKQMANwMAIAJB+IkCakGgCCkDADcDACACQYCKAmpBoAgpAwA3AwAgAkGIigJqQaAIKQMANwMAIAJBkIoCakGgCCkDADcDACACQZiKAmpBoAgpAwA3AwAgAkGgigJqQaAIKQMANwMAIAJBqIoCakGgCCkDADcDACACQbCKAmpBoAgpAwA3AwAgAkG4igJqQaAIKQMANwMAIAJBwIoCakGgCCkDADcDACACQciKAmpBoAgpAwA3AwAgAkHQigJqQaAIKQMANwMAIAJB2IoCakGgCCkDADcDACACQeCKAmpBoAgpAwA3AwAgAkHoigJqQaAIKQMANwMAIAJB8IoCakGgCCkDADcDACACQfiKAmpBoAgpAwA3AwAgAkGAiwJqQaAIKQMANwMAIAJBiIsCakGgCCkDADcDACACQZCLAmpBoAgpAwA3AwAgAkGYiwJqQaAIKQMANwMAIAJBoIsCakGgCCkDADcDACACQaiLAmpBoAgpAwA3AwAgAkGwiwJqQaAIKQMANwMAIAJBuIsCakGgCCkDADcDACACQcCLAmpBoAgpAwA3AwAgAkHIiwJqQaAIKQMANwMAIAJB0IsCakGgCCkDADcDACACQdiLAmpBoAgpAwA3AwAgAkHgiwJqQaAIKQMANwMAIAJB6IsCakGgCCkDADcDACACQfCLAmpBoAgpAwA3AwAgAkH4iwJqQaAIKQMANwMAIAJBgIwCakGgCCkDADcDACACQYiMAmpBoAgpAwA3AwAgAkGQjAJqQaAIKQMANwMAIAJBmIwCakGgCCkDADcDACACQaCMAmpBoAgpAwA3AwAgAkGojAJqQaAIKQMANwMAIAJBsIwCakGgCCkDADcDACACQbiMAmpBoAgpAwA3AwAgAkHAjAJqQaAIKQMANwMAIAJByIwCakGgCCkDADcDACACQdCMAmpBoAgpAwA3AwAgAkHYjAJqQaAIKQMANwMAIAJB4IwCakGgCCkDADcDACACQeiMAmpBoAgpAwA3AwAgAkHwjAJqQaAIKQMANwMAIAJB+IwCakGgCCkDADcDACACQYCNAmpBoAgpAwA3AwAgAkGIjQJqQaAIKQMANwMAIAJBkI0CakGgCCkDADcDACACQZiNAmpBoAgpAwA3AwAgAkGwiQZqIARBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBEGABPwKAABB1AgoAgBBAnRB0IkOaiAEQYAE/AoAAEHUCCgCAEECdEHgiRJqIARBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBEGABPwKAABB1AhB1AgoAgAiAkGAAWoiAzYCACABIANIDQEgAkGA/wBIDQALCwJAIABFDQAgCEH//wBLDQBBgIABIAhrIAcgAUH//wBLGyECAkAgAEEBcUUNACACRQ0AIAhBAnRBoIkCaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBAnFFDQAgAkUNACAIQQJ0QbCJBmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsCQCAAQQRxRQ0AIAJFDQAgCEECdEHAiQpqIQMgAiEEIAJBB3EiBwRAA0AgAyAFNgIAIANBBGohAyAEQQFrIQQgB0EBayIHDQALCyACQQFrQQdJDQADQCADIAU2AhwgAyAFNgIYIAMgBTYCFCADIAU2AhAgAyAFNgIMIAMgBTYCCCADIAU2AgQgAyAFNgIAIANBIGohAyAEQQhrIgQNAAsLAkAgAEEIcUUNACACRQ0AIAhBAnRB0IkOaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBEHFFDQAgAkUNACAIQQJ0QeCJEmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsgAEEgcUUNACACRQ0AIAJBAWshByAIQQJ0QfCJFmohAyACQQdxIgQEQANAIAMgBTYCACADQQRqIQMgAkEBayECIARBAWsiBA0ACwsgB0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgAkEIayICDQALC0HcCEHcCCgCACAAcjYCACAGQQFqIgIgBi0AAEH/AHEiA0E/ayIAQT9LDQQaDAMLAkBB7AgoAgAiBEEBRgRAQfAIKAIAIgNBzAgoAgAiAUkNASADIAFwIQMMAQtB+AgoAgAhAkH0CCgCACEBAkACQCAEQQVHDQAgAUEBRw0AIAJB6QJODQQMAQsgAkHkAEoNA0H8CCgCAEHkAEoNA0GACSgCAEHkAEoNAwsCQCABRQ0AIAFBAkoNACACQfwIKAIAQYAJKAIAIAFBAnRBiAhqKAIAEQIAIQFB8AgoAgAiA0HMCCgCACICTwR/IAMgAnAFIAMLQQJ0QZAJaiABNgIAC0HwCCgCACIDQcwIKAIAIgFJDQAgAyABcCEDCyADQQJ0QZAJaigCACEFDAELIANB/QBxQSFHBEAgCCEBIAYhAgwECyAEQSNHDQQCQEHsCCgCACICQQFGBEBB8AgoAgAiAUHMCCgCACIASQ0BIAEgAHAhAQwBC0H4CCgCACEBQfQIKAIAIQACQAJAIAJBBUcNACAAQQFHDQAgAUHpAkgNAQwHCyABQeQASg0GQfwIKAIAQeQASg0GQYAJKAIAQeQASg0GCwJAIABFDQAgAEECSg0AIAFB/AgoAgBBgAkoAgAgAEECdEGICGooAgARAgAhAEHwCCgCACIBQcwIKAIAIgJPBH8gASACcAUgAQtBAnRBkAlqIAA2AgALQfAIKAIAIgFBzAgoAgAiAEkNACABIABwIQELIAFBAnRBkAlqKAIAIQUMBAsgCCEBIAYhAgtB1AgoAgAhBgNAAkAgASAGSA0AIAZB//8ASg0AIAZBAnQiBEGgiQJqIgZBoAgpAwA3AwAgBEGoiQJqQaAIKQMANwMAIARBsIkCakGgCCkDADcDACAEQbiJAmpBoAgpAwA3AwAgBEHAiQJqQaAIKQMANwMAIARByIkCakGgCCkDADcDACAEQdCJAmpBoAgpAwA3AwAgBEHYiQJqQaAIKQMANwMAIARB4IkCakGgCCkDADcDACAEQeiJAmpBoAgpAwA3AwAgBEHwiQJqQaAIKQMANwMAIARB+IkCakGgCCkDADcDACAEQYCKAmpBoAgpAwA3AwAgBEGIigJqQaAIKQMANwMAIARBkIoCakGgCCkDADcDACAEQZiKAmpBoAgpAwA3AwAgBEGgigJqQaAIKQMANwMAIARBqIoCakGgCCkDADcDACAEQbCKAmpBoAgpAwA3AwAgBEG4igJqQaAIKQMANwMAIARBwIoCakGgCCkDADcDACAEQciKAmpBoAgpAwA3AwAgBEHQigJqQaAIKQMANwMAIARB2IoCakGgCCkDADcDACAEQeCKAmpBoAgpAwA3AwAgBEHoigJqQaAIKQMANwMAIARB8IoCakGgCCkDADcDACAEQfiKAmpBoAgpAwA3AwAgBEGAiwJqQaAIKQMANwMAIARBiIsCakGgCCkDADcDACAEQZCLAmpBoAgpAwA3AwAgBEGYiwJqQaAIKQMANwMAIARBoIsCakGgCCkDADcDACAEQaiLAmpBoAgpAwA3AwAgBEGwiwJqQaAIKQMANwMAIARBuIsCakGgCCkDADcDACAEQcCLAmpBoAgpAwA3AwAgBEHIiwJqQaAIKQMANwMAIARB0IsCakGgCCkDADcDACAEQdiLAmpBoAgpAwA3AwAgBEHgiwJqQaAIKQMANwMAIARB6IsCakGgCCkDADcDACAEQfCLAmpBoAgpAwA3AwAgBEH4iwJqQaAIKQMANwMAIARBgIwCakGgCCkDADcDACAEQYiMAmpBoAgpAwA3AwAgBEGQjAJqQaAIKQMANwMAIARBmIwCakGgCCkDADcDACAEQaCMAmpBoAgpAwA3AwAgBEGojAJqQaAIKQMANwMAIARBsIwCakGgCCkDADcDACAEQbiMAmpBoAgpAwA3AwAgBEHAjAJqQaAIKQMANwMAIARByIwCakGgCCkDADcDACAEQdCMAmpBoAgpAwA3AwAgBEHYjAJqQaAIKQMANwMAIARB4IwCakGgCCkDADcDACAEQeiMAmpBoAgpAwA3AwAgBEHwjAJqQaAIKQMANwMAIARB+IwCakGgCCkDADcDACAEQYCNAmpBoAgpAwA3AwAgBEGIjQJqQaAIKQMANwMAIARBkI0CakGgCCkDADcDACAEQZiNAmpBoAgpAwA3AwAgBEGwiQZqIAZBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBkGABPwKAABB1AgoAgBBAnRB0IkOaiAGQYAE/AoAAEHUCCgCAEECdEHgiRJqIAZBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBkGABPwKAABB1AhB1AgoAgBBgAFqIgY2AgALIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiAFNgIAIABBAXZBAXEgAWxBAnRBsIkGaiAFNgIAIABBAnZBAXEgAWxBAnRBwIkKaiAFNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiAFNgIAIABBBHZBAXEgAWxBAnRB4IkSaiAFNgIAIABBBXYgAWxBAnRB8IkWaiAFNgIAQdQIKAIAIQYLIAFBAWohAUHcCEHcCCgCACAAcjYCACACLQAAIQAgAkEBaiIEIQIgAEH/AHEiA0E/ayIAQcAASQ0ACyAECyECQQAhBCACIQYgASEIIANB/QBxQSFGDQELIANBJGsOCgEDAwMDAwMDAwIDC0HsCEIBNwIADAQLQdgIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbNgIADAILQegIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbIgA2AgBB2AggADYCACAAQQRrEAAEQEHoCEEENgIAQdgIQQQ2AgBB0AhBATYCAA8LEAgMAQsCQCADQTtHDQBB7AgoAgAiAEEHSg0AQewIIABBAWo2AgAgAEECdEHwCGpBADYCAAsgAiEGIAQhAyABIQgMAQtBBCEIIAIhBiAEIQMLIAYgCUkNAAsLQeQIIAU2AgBB4AggAzYCAEHoCCAINgIAC9ELAgF+CH9B2AhCBDcDAEGojQJBoAgpAwAiADcDAEGgjQIgADcDAEGYjQIgADcDAEGQjQIgADcDAEGIjQIgADcDAEGAjQIgADcDAEH4jAIgADcDAEHwjAIgADcDAEHojAIgADcDAEHgjAIgADcDAEHYjAIgADcDAEHQjAIgADcDAEHIjAIgADcDAEHAjAIgADcDAEG4jAIgADcDAEGwjAIgADcDAEGojAIgADcDAEGgjAIgADcDAEGYjAIgADcDAEGQjAIgADcDAEGIjAIgADcDAEGAjAIgADcDAEH4iwIgADcDAEHwiwIgADcDAEHoiwIgADcDAEHgiwIgADcDAEHYiwIgADcDAEHQiwIgADcDAEHIiwIgADcDAEHAiwIgADcDAEG4iwIgADcDAEGwiwIgADcDAEGoiwIgADcDAEGgiwIgADcDAEGYiwIgADcDAEGQiwIgADcDAEGIiwIgADcDAEGAiwIgADcDAEH4igIgADcDAEHwigIgADcDAEHoigIgADcDAEHgigIgADcDAEHYigIgADcDAEHQigIgADcDAEHIigIgADcDAEHAigIgADcDAEG4igIgADcDAEGwigIgADcDAEGoigIgADcDAEGgigIgADcDAEGYigIgADcDAEGQigIgADcDAEGIigIgADcDAEGAigIgADcDAEH4iQIgADcDAEHwiQIgADcDAEHoiQIgADcDAEHgiQIgADcDAEHYiQIgADcDAEHQiQIgADcDAEHIiQIgADcDAEHAiQIgADcDAEG4iQIgADcDAEGwiQIgADcDAEGoCCgCACIEQf8AakGAAW0hCAJAIARBgQFIDQBBASEBIAhBAiAIQQJKG0EBayICQQFxIQMgBEGBAk4EQCACQX5xIQIDQCABQQl0IgdBEHJBoIkCakGwiQJBgAT8CgAAIAdBsI0CakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsLIANFDQAgAUEJdEEQckGgiQJqQbCJAkGABPwKAAALAkAgBEEBSA0AIAhBASAIQQFKGyIDQQFxIQUCQCADQQFrIgdFBEBBACEBDAELIANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQbCJBmpBsIkCQYAE/AoAACAGQZAEckGwiQZqQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACwsgBQRAIAFBCXRBEHJBsIkGakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEFIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiBkEQckHAiQpqQbCJAkGABPwKAAAgBkGQBHJBwIkKakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAFBEAgAUECdEHAiQpqQbCJAkGABPwKAAALIARBAUgNACADQQFxIQUgBwR/IANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQdCJDmpBsIkCQYAE/AoAACAGQZAEckHQiQ5qQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACyABQQd0QQRyBUEECyEBIAUEQCABQQJ0QdCJDmpBsIkCQYAE/AoAAAsgBEEBSA0AIANBAXEhBSAHBH8gA0H+////B3EhAkEAIQEDQCABQQl0IgZBEHJB4IkSakGwiQJBgAT8CgAAIAZBkARyQeCJEmpBsIkCQYAE/AoAACABQQJqIQEgAkECayICDQALIAFBB3RBBHIFQQQLIQEgBQRAIAFBAnRB4IkSakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEEIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiA0EQckHwiRZqQbCJAkGABPwKAAAgA0GQBHJB8IkWakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAERQ0AIAFBAnRB8IkWakGwiQJBgAT8CgAAC0HUCCAIQQd0QQRyNgIAC58TAgh/AX5B5AgoAgAhA0HgCCgCACECQegIKAIAIQcgAUGQiQFqIglB/wE6AAAgACABSARAIABBkIkBaiEIA0AgAiEEIAhBAWohAQJAIAgtAABB/wBxIgJBMGtBCUsEQCABIQgMAQtB7AgoAgBBAnRB7AhqIgUoAgAhAANAIAUgAiAAQQpsakEwayIANgIAIAEtAAAhAiABQQFqIgghASACQf8AcSICQTBrQQpJDQALCwJAAkACQAJAAkACQAJ/AkAgAkE/ayIAQT9NBEAgBEUNASAEQSFGBEBB8AgoAgAiAUEBIAEbIgQgB2ohAQJAIABFDQAgB0H//wBLDQBBgIABIAdrIAQgAUH//wBLGyEFAkAgAEEBcUUNACAHQQJ0QaCJAmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEECcUUNACAHQQJ0QbCJBmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEEcUUNACAHQQJ0QcCJCmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEIcUUNACAHQQJ0QdCJDmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEQcUUNACAHQQJ0QeCJEmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLIABBIHFFDQAgBUEBayEEIAdBAnRB8IkWaiEAIAVBB3EiAgRAA0AgACADNgIAIABBBGohACAFQQFrIQUgAkEBayICDQALCyAEQQdJDQADQCAAIAM2AhwgACADNgIYIAAgAzYCFCAAIAM2AhAgACADNgIMIAAgAzYCCCAAIAM2AgQgACADNgIAIABBIGohACAFQQhrIgUNAAsLIAhBAWoiBSAILQAAQf8AcSICQT9rIgBBP00NAxoMBAsCQEHsCCgCACIFQQFGBEBB8AgoAgAiAUHMCCgCACIESQ0BIAEgBHAhAQwBC0H4CCgCACEEQfQIKAIAIQECQAJAIAVBBUcNACABQQFHDQAgBEHpAk4NBAwBCyAEQeQASg0DQfwIKAIAQeQASg0DQYAJKAIAQeQASg0DCwJAIAFFDQAgAUECSg0AIARB/AgoAgBBgAkoAgAgAUECdEGICGooAgARAgAhBEHwCCgCACIBQcwIKAIAIgVPBH8gASAFcAUgAQtBAnRBkAlqIAQ2AgALQfAIKAIAIgFBzAgoAgAiBEkNACABIARwIQELIAFBAnRBkAlqKAIAIQMMAQsgAkH9AHFBIUcEQCAHIQEgAiEADAQLIARBI0cNBAJAQewIKAIAIgRBAUYEQEHwCCgCACIBQcwIKAIAIgBJDQEgASAAcCEBDAELQfgIKAIAIQFB9AgoAgAhAAJAAkAgBEEFRw0AIABBAUcNACABQekCSA0BDAcLIAFB5ABKDQZB/AgoAgBB5ABKDQZBgAkoAgBB5ABKDQYLAkAgAEUNACAAQQJKDQAgAUH8CCgCAEGACSgCACAAQQJ0QYgIaigCABECACEAQfAIKAIAIgFBzAgoAgAiBE8EfyABIARwBSABC0ECdEGQCWogADYCAAtB8AgoAgAiAUHMCCgCACIASQ0AIAEgAHAhAQsgAUECdEGQCWooAgAhAwwECyAHIQEgCAshBQNAIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiADNgIAIABBAXZBAXEgAWxBAnRBsIkGaiADNgIAIABBAnZBAXEgAWxBAnRBwIkKaiADNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiADNgIAIABBBHZBAXEgAWxBAnRB4IkSaiADNgIAIABBBXYgAWxBAnRB8IkWaiADNgIACyABQQFqIQEgBS0AACEAIAVBAWoiBCEFIABB/wBxIgJBP2siAEHAAEkNAAsgBCEFC0EAIQQgBSEIIAEhByACIQAgAkH9AHFBIUYNAQtBBCEHIAQhAiAAQSRrDgoDAgICAgICAgIBAgtB7AhCATcCAAwCC0GoCCgCAEEEaxAABEBB0AhBATYCAA8LAkBBqAgoAgAiBkEFSA0AQaAIKQMAIQogBkEDa0EBdiIBQQdxIQJBACEAIAFBAWtBB08EQCABQfj///8HcSEFA0AgAEEDdCIBQbCJAmogCjcDACABQQhyQbCJAmogCjcDACABQRByQbCJAmogCjcDACABQRhyQbCJAmogCjcDACABQSByQbCJAmogCjcDACABQShyQbCJAmogCjcDACABQTByQbCJAmogCjcDACABQThyQbCJAmogCjcDACAAQQhqIQAgBUEIayIFDQALCyACRQ0AA0AgAEEDdEGwiQJqIAo3AwAgAEEBaiEAIAJBAWsiAg0ACwtBwIkGQbCJAiAGQQJ0IgD8CgAAQdCJCkGwiQIgAPwKAABB4IkOQbCJAiAA/AoAAEHwiRJBsIkCIAD8CgAAQYCKFkGwiQIgAPwKAAAgBCECDAELAkAgAEE7Rw0AQewIKAIAIgBBB0oNAEHsCCAAQQFqNgIAIABBAnRB8AhqQQA2AgALIAEhBwsgCCAJSQ0ACwtB5AggAzYCAEHgCCACNgIAQegIIAc2AgAL4gcCBX8BfgJAQdAIAn8CQAJAIAAgAU4NACABQZCJAWohBiAAQZCJAWohBQNAIAUtAAAiA0H/AHEhAgJAAkACQAJAAkACQAJAQeAIKAIAIgRBIkcEQCAEDQcgAkEiRgRAQewIQgE3AgBB4AhBIjYCAAwICyACQT9rQcAASQ0GIANBIWsiAkEMTQ0BDAULAkAgAkEwayIEQQlNBEBB7AgoAgBBAnRB7AhqIgIgBCACKAIAQQpsajYCAAwBC0HsCCgCACEEIAJBO0YEQCAEQQdKDQFB7AggBEEBajYCACAEQQJ0QfAIakEANgIADAELIARBBEYEQEHECEECNgIAQbAIQfAIKQMANwMAQbgIQfgIKAIAIgI2AgBBvAhB/AgoAgAiBDYCAEHICEECQQFBwAgoAgAiAxs2AgBBrAggBEEAIAMbNgIAQagIIAJBgIABIAJBgIABSBtBBGpBACADGzYCAEHgCEEANgIADAoLIAJBP2tBwABJDQQLIANBIWsiAkEMTQ0BDAILQQEgAnRBjSBxRQ0DDAQLQQEgAnRBjSBxDQELIANBoQFrIgJBDEsNA0EBIAJ0QY0gcUUNAwtBxAhCgYCAgBA3AgBBsAhB8AgoAgBBAEHsCCgCACICQQBKGzYCAEG0CEH0CCgCAEEAIAJBAUobNgIAQbgIQfgIKAIAQQAgAkECShs2AgBB4AhBADYCAEG8CEEANgIADAQLIANBoQFrIgJBDEsNAUEBIAJ0QY0gcUUNAQtBxAhCgYCAgBA3AgBBsAhCADcDAEG4CEIANwMADAMLIAVBAWoiBSAGSQ0ACwsCQEHICCgCAA4DAwEAAQsCQEGoCCgCACIFQQVIDQBBoAgpAwAhByAFQQNrQQF2IgNBB3EhBEEAIQIgA0EBa0EHTwRAIANB+P///wdxIQYDQCACQQN0IgNBsIkCaiAHNwMAIANBCHJBsIkCaiAHNwMAIANBEHJBsIkCaiAHNwMAIANBGHJBsIkCaiAHNwMAIANBIHJBsIkCaiAHNwMAIANBKHJBsIkCaiAHNwMAIANBMHJBsIkCaiAHNwMAIANBOHJBsIkCaiAHNwMAIAJBCGohAiAGQQhrIgYNAAsLIARFDQADQCACQQN0QbCJAmogBzcDACACQQFqIQIgBEEBayIEDQALC0HAiQZBsIkCIAVBAnQiA/wKAABB0IkKQbCJAiAD/AoAAEHgiQ5BsIkCIAP8CgAAQfCJEkGwiQIgA/wKAABBgIoWQbCJAiAD/AoAAEECDAELEAhByAgoAgALEAEiAjYCACACDQAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLdABB6AhBBDYCAEHkCCAANgIAQewIQgE3AgBBxAhCADcCAEHACCADNgIAQdwIQgA3AgBBqAhCADcDAEGwCEIANwMAQbgIQgA3AwBBzAggAkGAICACQYAgSRs2AgBBoAggAa1CgYCAgBB+NwMAQdAIQQA2AgALIwBB0AgoAgBFBEAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLWgECfwJAAkACQEHICCgCAEEBaw4CAAECC0HYCEHoCCgCACIAQdgIKAIAIgEgACABShsiAEGAgAEgAEGAgAFIGyIANgIAIABBBGsPC0GoCCgCAEEEayEACyAAC0IBAX8Cf0EGQdwIKAIAIgBBIHENABpBBSAAQRBxDQAaQQQgAEEIcQ0AGkEDIABBBHENABpBAiAAQQFxIABBAnEbCwu9BQEFfQJ/IAJFBEAgAUH/AWxBMmpB5ABtIgBBCHQgAHIgAEEQdHIMAQsgArJDAADIQpUhBiAAQfABarJDAAC0Q5UhBQJ9IAGyQwAAyEKVIgNDAAAAP10EQCADIAZDAACAP5KUDAELIAYgA0MAAIA/IAaTlJILIQcgAyADkiEGAkAgBUOrqqo+kiIEQwAAAABdBEAgBEMAAIA/kiEEDAELIARDAACAP15FDQAgBEMAAIC/kiEECyAGIAeTIQMgBUMAAAAAXSEAAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQECQCAABEAgBUMAAIA/kiEEDAELIAUiBEMAAIA/XkUNACAFQwAAgL+SIQQLIAVDq6qqvpIiBUMAAAAAXSECAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQACQCACBEAgBUMAAIA/kiEFDAELIAVDAACAP15FDQAgBUMAAIC/kiEFCwJAIAVDq6oqPl0EQCADIAcgA5NDAADAQJQgBZSSIQcMAQsgBUMAAAA/XQ0AIAVDq6oqP11FBEAgAyEHDAELIAMgByADkyAFQwAAwMCUQwAAgECSlJIhBwsgAEEIdAJ/IAdDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALQRB0ciABcgtBgICAeHILNwAgAEH/AWxBMmpB5ABtIAFB/wFsQTJqQeQAbUEIdHIgAkH/AWxBMmpB5ABtQRB0ckGAgIB4cgsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwsYAQBBgAgLEQEAAAACAAAAAwAAAAQAAAAF`}})),p$=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.decodeAsync=e.decode=e.Decoder=e.DecoderAsync=void 0;var t=d$(),n=f$();function r(e){if(typeof Buffer<`u`)return Buffer.from(e,`base64`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<n.length;++e)n[e]=t.charCodeAt(e);return n}var i=r(n.LIMITS.BYTES),a,o=new Uint32Array,s=class{constructor(){this.bandHandler=e=>1,this.modeHandler=e=>1}handle_band(e){return this.bandHandler(e)}mode_parsed(e){return this.modeHandler(e)}},c={memoryLimit:134217728,sixelColor:t.DEFAULT_FOREGROUND,fillColor:t.DEFAULT_BACKGROUND,palette:t.PALETTE_VT340_COLOR,paletteLimit:n.LIMITS.PALETTE_SIZE,truncate:!0};function l(e){let t=new s,n={env:{handle_band:t.handle_band.bind(t),mode_parsed:t.mode_parsed.bind(t)}};return WebAssembly.instantiate(a||i,n).then(n=>(a||=n.module,new u(e,n.instance||n,t)))}e.DecoderAsync=l;var u=class{constructor(e,r,s){if(this._PIXEL_OFFSET=n.LIMITS.MAX_WIDTH+4,this._canvas=o,this._bandWidths=[],this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0,this._opts=Object.assign({},c,e),this._opts.paletteLimit>n.LIMITS.PALETTE_SIZE)throw Error(`DecoderOptions.paletteLimit must not exceed ${n.LIMITS.PALETTE_SIZE}`);if(r)s.bandHandler=this._handle_band.bind(this),s.modeHandler=this._initCanvas.bind(this);else{let e=a||=new WebAssembly.Module(i);r=new WebAssembly.Instance(e,{env:{handle_band:this._handle_band.bind(this),mode_parsed:this._initCanvas.bind(this)}})}this._instance=r,this._wasm=this._instance.exports,this._chunk=new Uint8Array(this._wasm.memory.buffer,this._wasm.get_chunk_address(),n.LIMITS.CHUNK_SIZE),this._states=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_state_address(),12),this._palette=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_palette_address(),n.LIMITS.PALETTE_SIZE),this._palette.set(this._opts.palette),this._pSrc=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_p0_address()),this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}get _fillColor(){return this._states[0]}get _truncate(){return this._states[8]}get _rasterWidth(){return this._states[6]}get _rasterHeight(){return this._states[7]}get _width(){return this._states[2]?this._states[2]-4:0}get _height(){return this._states[3]}get _level(){return this._states[9]}get _mode(){return this._states[10]}get _paletteLimit(){return this._states[11]}_initCanvas(e){if(e===2){let e=this.width*this.height;if(e>this._canvas.length){if(this._opts.memoryLimit&&e*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);this._canvas=new Uint32Array(e)}this._maxWidth=this._width}else if(e===1){if(this._level===2){let e=Math.min(this._rasterWidth,n.LIMITS.MAX_WIDTH)*this._rasterHeight;if(e>this._canvas.length){if(this._opts.memoryLimit&&e*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);this._canvas=new Uint32Array(e)}}else this._canvas.length<65536&&(this._canvas=new Uint32Array(65536))}return 0}_realloc(e,t){let n=e+t;if(n>this._canvas.length){if(this._opts.memoryLimit&&n*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);let e=new Uint32Array(Math.ceil(n/65536)*65536);e.set(this._canvas),this._canvas=e}}_handle_band(e){let t=this._PIXEL_OFFSET,n=this._lastOffset;if(this._mode===2){let r=this.height-this._currentHeight,i=0;for(;i<6&&r>0;)this._canvas.set(this._pSrc.subarray(t*i,t*i+e),n+e*i),i++,r--;this._lastOffset+=e*i,this._currentHeight+=i}else if(this._mode===1){this._realloc(n,e*6),this._maxWidth=Math.max(this._maxWidth,e),this._minWidth=Math.min(this._minWidth,e);for(let r=0;r<6;++r)this._canvas.set(this._pSrc.subarray(t*r,t*r+e),n+e*r);this._bandWidths.push(e),this._lastOffset+=e*6,this._currentHeight+=6}return 0}get width(){return this._mode===1?Math.max(this._maxWidth,this._wasm.current_width()):this._width}get height(){return this._mode===1?this._wasm.current_width()?this._bandWidths.length*6+this._wasm.current_height():this._bandWidths.length*6:this._height}get palette(){return this._palette.subarray(0,this._paletteLimit)}get memoryUsage(){return this._canvas.byteLength+this._wasm.memory.buffer.byteLength+8*this._bandWidths.length}get properties(){return{width:this.width,height:this.height,mode:this._mode,level:this._level,truncate:!!this._truncate,paletteLimit:this._paletteLimit,fillColor:this._fillColor,memUsage:this.memoryUsage,rasterAttributes:{numerator:this._states[4],denominator:this._states[5],width:this._rasterWidth,height:this._rasterHeight}}}init(e=this._opts.fillColor,t=this._opts.palette,r=this._opts.paletteLimit,i=this._opts.truncate){this._wasm.init(this._opts.sixelColor,e,r,+!!i),t&&this._palette.set(t.subarray(0,n.LIMITS.PALETTE_SIZE)),this._bandWidths.length=0,this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0}decode(e,t=0,r=e.length){let i=t;for(;i<r;){let t=Math.min(r-i,n.LIMITS.CHUNK_SIZE);this._chunk.set(e.subarray(i,i+=t)),this._wasm.decode(0,t)}}decodeString(e,t=0,r=e.length){let i=t;for(;i<r;){let t=Math.min(r-i,n.LIMITS.CHUNK_SIZE);for(let n=0,r=i;n<t;++n,++r)this._chunk[n]=e.charCodeAt(r);i+=t,this._wasm.decode(0,t)}}get data32(){if(this._mode===0||!this.width||!this.height)return o;let e=this._wasm.current_width();if(this._mode===2){let t=this.height-this._currentHeight;if(t>0){let n=this._PIXEL_OFFSET,r=this._lastOffset,i=0;for(;i<6&&t>0;)this._canvas.set(this._pSrc.subarray(n*i,n*i+e),r+e*i),i++,t--;t&&this._canvas.fill(this._fillColor,r+e*i)}return this._canvas.subarray(0,this.width*this.height)}if(this._mode===1){if(this._minWidth===this._maxWidth){let t=!1;if(e){if(e!==this._minWidth)t=!0;else{let t=this._PIXEL_OFFSET,n=this._lastOffset;this._realloc(n,e*6);for(let r=0;r<6;++r)this._canvas.set(this._pSrc.subarray(t*r,t*r+e),n+e*r)}}if(!t)return this._canvas.subarray(0,this.width*this.height)}let t=new Uint32Array(this.width*this.height);t.fill(this._fillColor);let n=0,r=0;for(let e=0;e<this._bandWidths.length;++e){let i=this._bandWidths[e];for(let e=0;e<6;++e)t.set(this._canvas.subarray(r,r+=i),n),n+=this.width}if(e){let r=this._PIXEL_OFFSET,i=this._wasm.current_height();for(let a=0;a<i;++a)t.set(this._pSrc.subarray(r*a,r*a+e),n+this.width*a)}return t}return o}get data8(){return new Uint8ClampedArray(this.data32.buffer,0,this.width*this.height*4)}release(){this._canvas=o,this._bandWidths.length=0,this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}};e.Decoder=u;function d(e,t){let n=new u(t);return n.init(),typeof e==`string`?n.decodeString(e):n.decode(e),{width:n.width,height:n.height,data32:n.data32,data8:n.data8}}e.decode=d;async function f(e,t){let n=await l(t);return n.init(),typeof e==`string`?n.decodeString(e):n.decode(e),{width:n.width,height:n.height,data32:n.data32,data8:n.data8}}e.decodeAsync=f})),m$=d$(),h$=p$(),g$=m$.PALETTE_ANSI_256.slice();g$.set(m$.PALETTE_VT340_COLOR);var _$=200,v$=new TextEncoder,y$=`offsite-image:`;async function b$(e){let t=await(0,h$.decodeAsync)(e,{fillColor:0,palette:g$});return!t.width||!t.height?null:createImageBitmap(new ImageData(new Uint8ClampedArray(t.data8),t.width,t.height))}function x$(e,t,n){return e===void 0||e===`auto`?0:e.endsWith(`%`)?parseInt(e.slice(0,-1))*t/100:e.endsWith(`px`)?parseInt(e.slice(0,-2)):parseInt(e)*n}async function S$(e,t){let n=e.indexOf(`:`);if(n===-1)return null;let r=new Map(e.slice(0,n).split(`;`).map(e=>{let t=e.indexOf(`=`);return[e.slice(0,t),e.slice(t+1)]}));if(r.get(`inline`)!==`1`)return null;let i=Uint8Array.from(atob(e.slice(n+1)),e=>e.charCodeAt(0)),a=await createImageBitmap(new Blob([i])),o=x$(r.get(`width`),t.width,t.cellWidth),s=x$(r.get(`height`),t.height,t.cellHeight),c=[a.width,a.height];if(!o&&!s){let e=Math.min(t.width/a.width,(t.height-t.cellHeight)/a.height);e<1&&(c=[a.width*e,a.height*e])}else c=o?r.get(`preserveAspectRatio`)!==`0`||!s?[o,a.height*o/a.width]:[o,s]:[a.width*s/a.height,s];let[l,u]=c.map(e=>Math.max(1,Math.floor(e*t.pixelRatio))),d=await createImageBitmap(a,{resizeWidth:l,resizeHeight:u});return a.close(),d}function C$(e){let t=u$(e),{width:n,height:r,depth:i,channels:a}=t,o=n*r,s=new Uint8Array(o*4);if(t.palette){let e=c$(t),i=t.palette[0].length;for(let t=0;t<o;t+=1)s.set(e.subarray(t*i,t*i+3),t*4),s[t*4+3]=i===4?e[t*i+3]:255;return{width:n,height:r,data:s}}let c=2**i-1,l=Math.ceil(n*i/8);function u(e){if(i>=8)return t.data[e];let r=e%n*i;return t.data[Math.floor(e/n)*l+(r>>3)]>>8-i-(r&7)&c}function d(e){return i===16?e>>8:i===8?e:Math.round(e*255/c)}let f=t.transparency;for(let e=0;e<o;e+=1){let t=e*4;if(a===1||a===2){let n=u(e*a);s.fill(d(n),t,t+3),s[t+3]=a===2?d(u(e*2+1)):f?.[0]===n?0:255}else if(a===3||a===4){let n=u(e*a),r=u(e*a+1),i=u(e*a+2);s[t]=d(n),s[t+1]=d(r),s[t+2]=d(i),s[t+3]=a===4?d(u(e*4+3)):f?.[0]===n&&f[1]===r&&f[2]===i?0:255}else throw Error(`unsupported PNG with ${a} channels`)}return{width:n,height:r,data:s}}var w$=class{core;images=[];nextImage=0;constructor(e){this.core=e}place(e,t,n){let r=`${y$}${this.nextImage++}`;this.core.write(v$.encode(`\x1b]8;;${r}\x1b\\ \x1b]8;;\x1b\\\b`));let i={ref:this.core.trackCursor(),marker:r,bitmap:e,width:e.width/t,height:e.height/t,alternate:this.core.isAlternateScreen()};if(this.images.push(i),this.images.length>_$){let e=this.images.shift();e&&this.remove(e)}let a=Math.ceil(i.height/n);a>1&&this.core.write(v$.encode(`\x1BD`.repeat(a-1)))}visible(e,t,n){if(this.images.length===0)return[];let r=this.core.isAlternateScreen(),i=[],a=[];for(let o of this.images){if(o.alternate!==r){a.push(o);continue}let s=this.core.trackedPoint(o.ref);if(s===null||this.core.trackedHyperlink(o.ref)!==o.marker){this.remove(o);continue}a.push(o);let c=s.y-e;c+Math.ceil(o.height/n)<=0||c>=t||i.push({bitmap:o.bitmap,width:o.width,height:o.height,x:s.x,y:c})}return this.images=a,i}clear(){for(let e of this.images)this.remove(e);this.images=[]}remove(e){this.core.untrack(e.ref),e.bitmap.close()}},T$=new Uint8Array([0,97,115,109,1,0,0,0,1,35,5,96,4,127,127,127,127,0,96,3,127,127,127,1,127,96,2,127,127,0,96,3,127,127,127,0,96,5,127,127,127,127,127,1,127,2,49,6,3,101,110,118,1,119,0,0,3,101,110,118,1,100,0,1,3,101,110,118,1,115,0,1,3,101,110,118,1,98,0,2,3,101,110,118,1,118,0,3,3,101,110,118,1,112,0,4,7,25,6,1,119,0,0,1,100,0,1,1,115,0,2,1,98,0,3,1,118,0,4,1,112,0,5]),E$={userdata:0,writePty:1,bell:2,xtversion:4,size:6,deviceAttributes:8},D$=1,O$=-3,k$={width:0,height:4,data:8,length:12},A$=new TextDecoder,j$=new TextEncoder,M$=class e{memory;layouts;exports;memoryView;hosts=new Map;nextHostId=1;callbacks={writePty:0,deviceAttributes:0,size:0,bell:0,xtversion:0};version={pointer:0,size:0};constructor(e){this.exports=e.exports;let t=e.exports.memory;if(!(t instanceof WebAssembly.Memory))throw Error(`libghostty-vt did not export its memory`);this.memory=t,this.memoryView=new DataView(t.buffer);let n=this.call(`ghostty_type_json`),r=new Uint8Array(t.buffer),i=n;for(;i<r.length&&r[i]!==0;)i+=1;this.layouts=JSON.parse(A$.decode(r.subarray(n,i)))}static async load(){let t=await fetch(NZ);if(!t.ok)throw Error(`could not load libghostty-vt (${t.status})`);let n=null,r=await WebAssembly.instantiate(await t.arrayBuffer(),{env:{log:(e,t)=>{n&&console.debug(`[libghostty-vt]`,A$.decode(new Uint8Array(n.buffer,e,t)))}}}),i=new e(r.instance);return n=i.memory,i.installCallbacks(),i}call(e,...t){let n=this.exports[e];if(typeof n!=`function`)throw Error(`libghostty-vt export is missing: ${e}`);return n(...t)}layout(e){let t=this.layouts[e];if(!t)throw Error(`libghostty-vt layout is missing: ${e}`);return t}field(e,t){let n=this.layout(e).fields[t];if(!n)throw Error(`libghostty-vt field is missing: ${e}.${t}`);return n}alloc(e){let t=this.call(`ghostty_wasm_alloc_u8_array`,e);if(t===0)throw Error(`libghostty-vt could not allocate ${e} bytes`);return new Uint8Array(this.memory.buffer,t,e).fill(0),t}free(e,t){e!==0&&this.call(`ghostty_wasm_free_u8_array`,e,t)}allocOpaque(){let e=this.call(`ghostty_wasm_alloc_opaque`);if(e===0)throw Error(`libghostty-vt could not allocate a pointer`);return new DataView(this.memory.buffer).setUint32(e,0,!0),e}freeOpaque(e){e!==0&&this.call(`ghostty_wasm_free_opaque`,e)}readPointer(e){return this.dataView().getUint32(e,!0)}check(e,t){if(t!==0)throw Error(`${e} failed with result ${t}`)}flag(e,t,n){let r=this.alloc(1),i=this.call(e,t,n,r),a=this.bytes(r,1)[0];return this.free(r,1),i===0&&a!==0}encodeOutput(e){let t=this.call(`ghostty_wasm_alloc_usize`),n=``,r=e(0,0,t),i=this.view(t,4).getUint32(0,!0);if(r===O$&&i>0){let r=this.alloc(i),a=e(r,i,t),o=this.view(t,4).getUint32(0,!0);a===0&&(n=A$.decode(this.bytes(r,o))),this.free(r,i)}return this.call(`ghostty_wasm_free_usize`,t),n}attachHost(e,t){let n=this.nextHostId++;this.hosts.set(n,t),this.call(`ghostty_terminal_set`,e,E$.userdata,n);for(let t of[[E$.writePty,this.callbacks.writePty],[E$.deviceAttributes,this.callbacks.deviceAttributes],[E$.size,this.callbacks.size],[E$.bell,this.callbacks.bell],[E$.xtversion,this.callbacks.xtversion]])this.call(`ghostty_terminal_set`,e,t[0],t[1]);return n}detachHost(e,t){this.call(`ghostty_terminal_set`,e,E$.xtversion,0),this.call(`ghostty_terminal_set`,e,E$.bell,0),this.call(`ghostty_terminal_set`,e,E$.size,0),this.call(`ghostty_terminal_set`,e,E$.deviceAttributes,0),this.call(`ghostty_terminal_set`,e,E$.writePty,0),this.call(`ghostty_terminal_set`,e,E$.userdata,0),this.hosts.delete(t)}view(e,t){return new DataView(this.memory.buffer,e,t)}bytes(e,t){return new Uint8Array(this.memory.buffer,e,t)}dataView(){return this.memoryView.buffer!==this.memory.buffer&&(this.memoryView=new DataView(this.memory.buffer)),this.memoryView}setField(e,t,n,r){let i=this.field(t,n),a=this.dataView(),o=e+i.offset;if(i.type===`bool`||i.type===`u8`)a.setUint8(o,r);else if(i.type===`u16`)a.setUint16(o,r,!0);else if(i.type===`i32`)a.setInt32(o,r,!0);else if(i.type===`u32`||i.type===`enum`)a.setUint32(o,r,!0);else if(i.type===`u64`)a.setBigUint64(o,BigInt(r),!0);else throw Error(`unsupported libghostty-vt field type ${i.type}`)}readField(e,t,n){let r=this.field(t,n),i=this.dataView(),a=e+r.offset;if(r.type===`bool`||r.type===`u8`)return i.getUint8(a);if(r.type===`u16`)return i.getUint16(a,!0);if(r.type===`i32`)return i.getInt32(a,!0);if(r.type===`u32`||r.type===`enum`)return i.getUint32(a,!0);if(r.type===`u64`)return Number(i.getBigUint64(a,!0));throw Error(`unsupported libghostty-vt field type ${r.type}`)}installCallbacks(){let e=new WebAssembly.Instance(new WebAssembly.Module(T$),{env:{w:(e,t,n,r)=>{let i=this.hosts.get(t);i&&r!==0&&i.write(A$.decode(new Uint8Array(this.memory.buffer,n,r)))},d:(e,t,n)=>this.hosts.has(t)?(this.writeDeviceAttributes(n),1):0,s:(e,t,n)=>{let r=this.hosts.get(t);if(!r)return 0;let i=r.size(),a=`GhosttySizeReportSize`;return this.setField(n,a,`rows`,i.rows),this.setField(n,a,`columns`,i.columns),this.setField(n,a,`cell_width`,i.cellWidth),this.setField(n,a,`cell_height`,i.cellHeight),1},b:(e,t)=>{this.hosts.get(t)?.bell()},v:(e,t,n)=>{let r=this.hosts.get(n);r&&this.writeVersion(e,r.version())},p:(e,t,n,r,i)=>this.decodePng(t,n,r,i)}}),t=this.exports.__indirect_function_table;if(!(t instanceof WebAssembly.Table))throw Error(`libghostty-vt did not expose its callback table`);let n=[`w`,`d`,`s`,`b`,`v`,`p`].map(n=>{let r=e.exports[n];if(typeof r!=`function`)throw Error(`libghostty-vt callback is missing: ${n}`);let i=t.length;return t.grow(1),t.set(i,r),i});if(this.callbacks={writePty:n[0],deviceAttributes:n[1],size:n[2],bell:n[3],xtversion:n[4]},this.call(`ghostty_sys_set`,D$,n[5])!==0)throw Error(`libghostty-vt did not accept the PNG decoder`)}decodePng(e,t,n,r){let i;try{i=C$(new Uint8Array(this.memory.buffer,t,n))}catch(e){return console.warn(`could not decode a kitty PNG image`,e),0}let a=this.call(`ghostty_alloc`,e,i.data.length);if(a===0)return 0;this.bytes(a,i.data.length).set(i.data);let o=this.dataView();return o.setUint32(r+k$.width,i.width,!0),o.setUint32(r+k$.height,i.height,!0),o.setUint32(r+k$.data,a,!0),o.setUint32(r+k$.length,i.data.length,!0),1}writeVersion(e,t){let n=j$.encode(t);this.free(this.version.pointer,this.version.size);let r=this.alloc(n.length);this.bytes(r,n.length).set(n),this.version={pointer:r,size:n.length},this.dataView().setUint32(e+this.field(`GhosttyString`,`ptr`).offset,r,!0),this.setField(e,`GhosttyString`,`len`,n.length)}writeDeviceAttributes(e){let t=e+this.field(`GhosttyDeviceAttributes`,`primary`).offset,n=e+this.field(`GhosttyDeviceAttributes`,`secondary`).offset,r=e+this.field(`GhosttyDeviceAttributes`,`tertiary`).offset,i=`GhosttyDeviceAttributesPrimary`,a=`GhosttyDeviceAttributesSecondary`,o=t+this.field(i,`features`).offset,s=this.dataView(),c=[4,22];c.forEach((e,t)=>s.setUint16(o+t*2,e,!0)),this.setField(t,i,`conformance_level`,62),this.setField(t,i,`num_features`,c.length),this.setField(n,a,`device_type`,0),this.setField(n,a,`firmware_version`,276),this.setField(n,a,`rom_cartridge`,0),this.setField(r,`GhosttyDeviceAttributesTertiary`,`unit_id`,0)}},N$=null;async function P$(){N$=await M$.load()}function F$(){if(!N$)throw Error(`libghostty-vt is not loaded`);return N$}var I$=new Map(`Unidentified.Backquote.Backslash.BracketLeft.BracketRight.Comma.Digit0.Digit1.Digit2.Digit3.Digit4.Digit5.Digit6.Digit7.Digit8.Digit9.Equal.IntlBackslash.IntlRo.IntlYen.KeyA.KeyB.KeyC.KeyD.KeyE.KeyF.KeyG.KeyH.KeyI.KeyJ.KeyK.KeyL.KeyM.KeyN.KeyO.KeyP.KeyQ.KeyR.KeyS.KeyT.KeyU.KeyV.KeyW.KeyX.KeyY.KeyZ.Minus.Period.Quote.Semicolon.Slash.AltLeft.AltRight.Backspace.CapsLock.ContextMenu.ControlLeft.ControlRight.Enter.MetaLeft.MetaRight.ShiftLeft.ShiftRight.Space.Tab.Convert.KanaMode.NonConvert.Delete.End.Help.Home.Insert.PageDown.PageUp.ArrowDown.ArrowLeft.ArrowRight.ArrowUp.NumLock.Numpad0.Numpad1.Numpad2.Numpad3.Numpad4.Numpad5.Numpad6.Numpad7.Numpad8.Numpad9.NumpadAdd.NumpadBackspace.NumpadClear.NumpadClearEntry.NumpadComma.NumpadDecimal.NumpadDivide.NumpadEnter.NumpadEqual.NumpadMemoryAdd.NumpadMemoryClear.NumpadMemoryRecall.NumpadMemoryStore.NumpadMemorySubtract.NumpadMultiply.NumpadParenLeft.NumpadParenRight.NumpadSubtract.NumpadSeparator.NumpadArrowUp.NumpadArrowDown.NumpadArrowRight.NumpadArrowLeft.NumpadBegin.NumpadHome.NumpadEnd.NumpadInsert.NumpadDelete.NumpadPageUp.NumpadPageDown.Escape.F1.F2.F3.F4.F5.F6.F7.F8.F9.F10.F11.F12.F13.F14.F15.F16.F17.F18.F19.F20.F21.F22.F23.F24.F25.Fn.FnLock.PrintScreen.ScrollLock.Pause.BrowserBack.BrowserFavorites.BrowserForward.BrowserHome.BrowserRefresh.BrowserSearch.BrowserStop.Eject.LaunchApp1.LaunchApp2.LaunchMail.MediaPlayPause.MediaSelect.MediaStop.MediaTrackNext.MediaTrackPrevious.Power.Sleep.AudioVolumeDown.AudioVolumeMute.AudioVolumeUp.WakeUp.Copy.Cut.Paste`.split(`.`).map((e,t)=>[e,t]));function L$(e){return I$.get(e)??0}var R$=new Map([[`!`,`1`],[`@`,`2`],[`#`,`3`],[`$`,`4`],[`%`,`5`],[`^`,`6`],[`&`,`7`],[`*`,`8`],[`(`,`9`],[`)`,`0`],[`~`,"`"],[`_`,`-`],[`+`,`=`],[`{`,`[`],[`}`,`]`],[`|`,`\\`],[`:`,`;`],[`"`,`'`],[`<`,`,`],[`>`,`.`],[`?`,`/`]]),z$;function B$(){return z$||(z$=globalThis.navigator?.keyboard?.getLayoutMap().catch(()=>void 0)??Promise.resolve(void 0),z$)}function V$(){return z$=void 0,B$()}function H$(e){return!e.shiftKey||e.ctrlKey||e.altKey||e.metaKey?0:+([...e.key].length===1)}function U$(e,t){if([...e.key].length!==1)return 0;let n=t?.get(e.code);if(n&&[...n].length===1)return n.codePointAt(0)??0;if(/^[A-Z]$/u.test(e.key))return e.key.charCodeAt(0)+32;if(e.shiftKey){let t=R$.get(e.key);if(t)return t.codePointAt(0)??0;let n=e.key.toLowerCase();return n!==e.key&&[...n].length===1?n.codePointAt(0)??0:0}return e.key.codePointAt(0)??0}var W$=new Map([[`Backquote`,"`"],[`Minus`,`-`],[`Equal`,`=`],[`BracketLeft`,`[`],[`BracketRight`,`]`],[`Backslash`,`\\`],[`Semicolon`,`;`],[`Quote`,`'`],[`Comma`,`,`],[`Period`,`.`],[`Slash`,`/`],[`Space`,` `]]),G$=[...`0123456789`].map(e=>[`Digit${e}`,e]),K$=new Map([...R$].map(e=>[e[1],e[0]]));function q$(e){return/^Key[A-Z]$/u.test(e)?e[3].toLowerCase():/^Digit[0-9]$/u.test(e)?e[5]:W$.get(e)}function J$(e){return[...W$,...G$].every(t=>t[0]===`Space`||e.get(t[0])===t[1])}function Y$(e,t){let n=t?.get(e.code),r=n&&[...n].length===1?n:q$(e.code);if(r===void 0)return[...e.key].length===1?null:e.key;if(!e.shiftKey)return r;let i=r.toUpperCase();return i!==r&&[...i].length===1?i:t===void 0||!J$(t)?null:K$.get(r)??r}var X$=new TextEncoder,Z$=new Map([[`[`,`\x1B`],[`m`,`\r`],[`i`,` `],[`@`,`\0`]]),Q$=class{runtime=F$();terminal;keyEncoderSlot;keyEncoder;keyEventSlot;keyEvent;mouseEncoderSlot;mouseEncoder;mouseEventSlot;mouseEvent;scratch;keyboardLayoutMap;constructor(e){let t=this.runtime;this.terminal=e,this.loadKeyboardLayout(B$()),this.keyEncoderSlot=t.allocOpaque(),t.check(`ghostty_key_encoder_new`,t.call(`ghostty_key_encoder_new`,0,this.keyEncoderSlot)),this.keyEncoder=t.readPointer(this.keyEncoderSlot),this.keyEventSlot=t.allocOpaque(),t.check(`ghostty_key_event_new`,t.call(`ghostty_key_event_new`,0,this.keyEventSlot)),this.keyEvent=t.readPointer(this.keyEventSlot),this.mouseEncoderSlot=t.allocOpaque(),t.check(`ghostty_mouse_encoder_new`,t.call(`ghostty_mouse_encoder_new`,0,this.mouseEncoderSlot)),this.mouseEncoder=t.readPointer(this.mouseEncoderSlot),this.mouseEventSlot=t.allocOpaque(),t.check(`ghostty_mouse_event_new`,t.call(`ghostty_mouse_event_new`,0,this.mouseEventSlot)),this.mouseEvent=t.readPointer(this.mouseEventSlot),this.scratch=t.alloc(1)}encodeKey(e,t=`press`,n=!1){let r=this.runtime,i=e.key.toLowerCase(),a=Z$.get(i);if(a!==void 0&&t===`press`&&e.ctrlKey&&!e.altKey&&!e.metaKey&&!(e.shiftKey&&/^[a-z]$/u.test(i))&&!r.flag(`ghostty_terminal_get`,this.terminal,8))return a;let o=n?this.metaText(e):null,s=o??e.key;if(o!==null&&t===`press`&&!e.ctrlKey&&[...s].length===1&&(s.codePointAt(0)??0)>127&&r.flag(`ghostty_terminal_mode_get`,this.terminal,1036)&&this.isLegacyKeyboard())return`\x1b${s}`;r.call(`ghostty_key_encoder_setopt_from_terminal`,this.keyEncoder,this.terminal),r.call(`ghostty_key_event_set_action`,this.keyEvent,t===`release`?0:e.repeat?2:1),r.call(`ghostty_key_event_set_key`,this.keyEvent,L$(e.code));let c=+!!e.shiftKey|(e.ctrlKey?2:0)|(e.altKey?4:0)|(e.metaKey?8:0)|(e.getModifierState(`CapsLock`)?16:0)|(e.getModifierState(`NumLock`)?32:0);r.call(`ghostty_key_event_set_mods`,this.keyEvent,c),r.call(`ghostty_key_event_set_consumed_mods`,this.keyEvent,H$(e)),r.call(`ghostty_key_event_set_composing`,this.keyEvent,+!!e.isComposing),r.call(`ghostty_key_event_set_unshifted_codepoint`,this.keyEvent,U$({code:e.code,key:s,shiftKey:e.shiftKey},this.keyboardLayoutMap));let l=X$.encode(s.length===1?s:``),u=l.length===0?0:r.alloc(l.length);u!==0&&r.bytes(u,l.length).set(l),r.call(`ghostty_key_event_set_utf8`,this.keyEvent,u,l.length);let d=r.encodeOutput((e,t,n)=>r.call(`ghostty_key_encoder_encode`,this.keyEncoder,this.keyEvent,e,t,n));return u!==0&&r.free(u,l.length),d}metaText(e){return Y$(e,this.keyboardLayoutMap)}refreshKeyboardLayout(){this.loadKeyboardLayout(V$())}encodePaste(e){let t=this.runtime,n=X$.encode(e);if(n.length===0)return``;let r=t.alloc(n.length);t.bytes(r,n.length).set(n);let i=+!!t.flag(`ghostty_terminal_mode_get`,this.terminal,2004),a=t.encodeOutput((e,a,o)=>t.call(`ghostty_paste_encode`,r,n.length,i,e,a,o));return t.free(r,n.length),a}encodeMouse(e){let t=this.runtime;t.call(`ghostty_mouse_encoder_setopt_from_terminal`,this.mouseEncoder,this.terminal);let n=t.layout(`GhosttyMouseEncoderSize`),r=t.alloc(n.size);for(let i of[[`size`,n.size],[`screen_width`,e.screenWidth],[`screen_height`,e.screenHeight],[`cell_width`,e.cellWidth],[`cell_height`,e.cellHeight],[`padding_top`,0],[`padding_bottom`,0],[`padding_right`,0],[`padding_left`,0]])t.setField(r,`GhosttyMouseEncoderSize`,i[0],Math.max(0,Math.round(i[1])));t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,2,r),t.free(r,n.size),t.bytes(this.scratch,1)[0]=+!!e.anyButtonPressed,t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,3,this.scratch),t.bytes(this.scratch,1)[0]=1,t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,4,this.scratch),t.call(`ghostty_mouse_event_set_action`,this.mouseEvent,{press:0,release:1,motion:2}[e.action]),e.button===null?t.call(`ghostty_mouse_event_clear_button`,this.mouseEvent):t.call(`ghostty_mouse_event_set_button`,this.mouseEvent,e.button),t.call(`ghostty_mouse_event_set_mods`,this.mouseEvent,e.mods);let i=t.layout(`GhosttyMousePosition`),a=t.alloc(i.size),o=t.view(a,i.size);return o.setFloat32(t.field(`GhosttyMousePosition`,`x`).offset,e.x,!0),o.setFloat32(t.field(`GhosttyMousePosition`,`y`).offset,e.y,!0),t.call(`ghostty_mouse_event_set_position`,this.mouseEvent,a),t.free(a,i.size),t.encodeOutput((e,n,r)=>t.call(`ghostty_mouse_encoder_encode`,this.mouseEncoder,this.mouseEvent,e,n,r))}dispose(){let e=this.runtime;e.call(`ghostty_mouse_event_free`,this.mouseEvent),e.call(`ghostty_mouse_encoder_free`,this.mouseEncoder),e.call(`ghostty_key_event_free`,this.keyEvent),e.call(`ghostty_key_encoder_free`,this.keyEncoder),e.free(this.scratch,1),e.freeOpaque(this.mouseEventSlot),e.freeOpaque(this.mouseEncoderSlot),e.freeOpaque(this.keyEventSlot),e.freeOpaque(this.keyEncoderSlot)}async loadKeyboardLayout(e){this.keyboardLayoutMap=await e}isLegacyKeyboard(){return this.encodeKey(new KeyboardEvent(`keydown`,{key:`Tab`,code:`Tab`,shiftKey:!0}))===`\x1B[Z`}},$$=26,e1=30,t1=1,n1={imageId:1,placementId:2,isVirtual:3,xOffset:4,yOffset:5,columns:10,rows:11,z:12},r1={width:3,height:4,format:5,data:7,length:8},i1={size:48,pixelWidth:4,pixelHeight:8,column:20,row:24,visible:28,sourceX:32,sourceY:36,sourceWidth:40,sourceHeight:44},a1=new Map([[0,3],[1,4],[3,2],[4,1]]),o1=new Map([773,781,782,784,786,829,830,831,838,842,843,844,848,849,850,855,859,867,868,869,870,871,872,873,874,875,876,877,878,879,1155,1156,1157,1158,1159,1426,1427,1428,1429,1431,1432,1433,1436,1437,1438,1439,1440,1441,1448,1449,1451,1452,1455,1476,1552,1553,1554,1555,1556,1557,1558,1559,1623,1624,1625,1626,1627,1629,1630,1750,1751,1752,1753,1754,1755,1756,1759,1760,1761,1762,1764,1767,1768,1771,1772,1840,1842,1843,1845,1846,1850,1853,1855,1856,1857,1859,1861,1863,1865,1866,2027,2028,2029,2030,2031,2032,2033,2035,2070,2071,2072,2073,2075,2076,2077,2078,2079,2080,2081,2082,2083,2085,2086,2087,2089,2090,2091,2092,2093,2385,2387,2388,3970,3971,3974,3975,4957,4958,4959,6109,6458,6679,6773,6774,6775,6776,6777,6778,6779,6780,7019,7021,7022,7023,7024,7025,7026,7027,7376,7377,7378,7386,7387,7392,7616,7617,7619,7620,7621,7622,7623,7624,7625,7627,7628,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,7643,7644,7645,7646,7647,7648,7649,7650,7651,7652,7653,7654,7678,8400,8401,8404,8405,8406,8407,8411,8412,8417,8423,8425,8432,11503,11504,11505,11744,11745,11746,11747,11748,11749,11750,11751,11752,11753,11754,11755,11756,11757,11758,11759,11760,11761,11762,11763,11764,11765,11766,11767,11768,11769,11770,11771,11772,11773,11774,11775,42607,42620,42621,42736,42737,43232,43233,43234,43235,43236,43237,43238,43239,43240,43241,43242,43243,43244,43245,43246,43247,43248,43249,43696,43698,43699,43703,43704,43710,43711,43713,65056,65057,65058,65059,65060,65061,65062,68111,68152,119173,119174,119175,119176,119177,119210,119211,119212,119213,119362,119363,119364].map((e,t)=>[e,t]));function s1(e,t,n){let r=Array.from(e).slice(1,4).map(e=>o1.get(e.codePointAt(0)??0)??null),i=r[2]??null;return{imageId:t,placementId:n,row:r[0]??null,column:r[1]??null,imageIdHigh:i!==null&&i<256?i:null}}function c1(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n].cells,i=null;for(let e=0;e<r.length;e+=1){let a=r[e].placeholder;i!==null&&a!==null&&a.imageId===i.imageId&&a.placementId===i.placementId&&(a.row===null||a.row===i.row)&&(a.column===null||a.column===i.column+i.width)&&(a.imageIdHigh===null||a.imageIdHigh===i.imageIdHigh)?i.width+=1:(i!==null&&t.push(l1(i)),i=a===null?null:{x:e,y:n,imageId:a.imageId,imageIdHigh:a.imageIdHigh,placementId:a.placementId,row:a.row??0,column:a.column??0,width:1})}i!==null&&t.push(l1(i))}return t}function l1(e){return{x:e.x,y:e.y,imageId:e.imageId+(e.imageIdHigh??0)*2**24,placementId:e.placementId,row:e.row,column:e.column,width:e.width}}function u1(e,t,n,r){let i=t.columns===0?Math.ceil(n.width/r.width):t.columns,a=t.rows===0?Math.ceil(n.height/r.height):t.rows,o=i*r.width,s=a*r.height,c=n.width*s>n.height*o,l=c?o/Math.max(n.width,1):s/Math.max(n.height,1),u=c?0:(o-n.width*l)/2/l,d=c?(s-n.height*l)/2/l:0,f=n.width+u*2,p=n.height+d*2,m={x:f*e.column/i,y:p*e.row/a,width:f*e.width/i,height:p/a},h=0,g=0,_=e.width*r.width,v=r.height;if(m.y<d){let e=d-m.y;m.height-=e,g=e,v-=e*l,m.y=0,m.height>n.height&&(m.height=n.height,v=n.height*l)}else m.y+m.height>p-d?(m.y-=d,m.height=p-d-m.y-d,v=m.height*l):m.y-=d;if(m.x<u){let e=u-m.x;m.width-=e,h=e,_-=e*l,m.x=0,m.width>n.width&&(m.width=n.width,_=n.width*l)}else m.x+m.width>f-u?(m.x-=u,m.width=f-u-m.x-u,_=m.width*l):m.x-=u;if(m.width<=0||m.height<=0)return null;let y={xOffset:Math.round(h*l),yOffset:Math.round(g*l),width:Math.round(_),height:Math.round(v),source:{x:Math.round(m.x),y:Math.round(m.y),width:Math.round(m.width),height:Math.round(m.height)}};return y.width===0||y.height===0?null:y}function d1(e){let t=F$(),n=t.alloc(16),r=t.call(`ghostty_terminal_get`,e,$$,n);return t.free(n,16),r===0}var f1=class{runtime=F$();terminal;iteratorSlot;info;scratch;tail=[0,0];commands=0;cachedCommands=0;bitmaps=new Map;constructor(e){let t=this.runtime;this.terminal=e,this.iteratorSlot=t.allocOpaque(),t.check(`ghostty_kitty_graphics_placement_iterator_new`,t.call(`ghostty_kitty_graphics_placement_iterator_new`,0,this.iteratorSlot)),this.info=t.alloc(i1.size),this.scratch=t.alloc(16)}note(e){let t=[...this.tail,...e.subarray(0,2)],n=t.some((e,n)=>e===27&&t[n+1]===95&&t[n+2]===71),r=e.indexOf(27);for(;!n&&r!==-1;)n=e[r+1]===95&&e[r+2]===71,r=e.indexOf(27,r+1);n&&(this.commands+=1),this.tail=[...this.tail,...e.subarray(-2)].slice(-2)}images(e,t){this.commands!==this.cachedCommands&&(this.cachedCommands=this.commands,this.bitmaps.clear());let n=new Map,r=this.placements(e,t).map(e=>{let t=n.get(e.key)??this.bitmaps.get(e.key)??h1(e.image);return n.set(e.key,t),{placement:e,bitmap:t}});return this.bitmaps=n,r}dispose(){let e=this.runtime;e.call(`ghostty_kitty_graphics_placement_iterator_free`,e.readPointer(this.iteratorSlot)),e.free(this.info,i1.size),e.free(this.scratch,16),e.freeOpaque(this.iteratorSlot),this.bitmaps.clear()}placements(e,t){let n=this.runtime;n.check(`ghostty_terminal_get`,n.call(`ghostty_terminal_get`,this.terminal,e1,this.scratch));let r=n.readPointer(this.scratch);n.check(`ghostty_kitty_graphics_get`,n.call(`ghostty_kitty_graphics_get`,r,t1,this.iteratorSlot));let i=n.readPointer(this.iteratorSlot),a=[],o=[];for(;n.call(`ghostty_kitty_graphics_placement_next`,i);){let e=this.placementU32(i,n1.imageId);if(this.placementData(i,n1.isVirtual).getUint8(0)){o.push({imageId:e,placementId:this.placementU32(i,n1.placementId),columns:this.placementU32(i,n1.columns),rows:this.placementU32(i,n1.rows)});continue}let t=n.call(`ghostty_kitty_graphics_image`,r,e);if(t===0)throw Error(`kitty placement points to missing image ${e}`);n.bytes(this.info,i1.size).fill(0);let s=n.view(this.info,i1.size);s.setUint32(0,i1.size,!0),n.check(`ghostty_kitty_graphics_placement_render_info`,n.call(`ghostty_kitty_graphics_placement_render_info`,i,t,this.terminal,this.info)),s.getUint8(i1.visible)!==0&&a.push({...this.image(t,e),z:this.placementData(i,n1.z).getInt32(0,!0),column:s.getInt32(i1.column,!0),row:s.getInt32(i1.row,!0),xOffset:this.placementU32(i,n1.xOffset),yOffset:this.placementU32(i,n1.yOffset),width:s.getUint32(i1.pixelWidth,!0),height:s.getUint32(i1.pixelHeight,!0),source:{x:s.getUint32(i1.sourceX,!0),y:s.getUint32(i1.sourceY,!0),width:s.getUint32(i1.sourceWidth,!0),height:s.getUint32(i1.sourceHeight,!0)}})}if(o.length===0)return a;for(let i of c1(e)){let e=o.find(e=>e.imageId===i.imageId&&(i.placementId===0||e.placementId===i.placementId));if(e===void 0)continue;let s=n.call(`ghostty_kitty_graphics_image`,r,i.imageId);if(s===0)continue;let c=this.image(s,i.imageId),l=u1(i,e,c.image,t);l!==null&&a.push({...c,...l,z:-1,column:i.x,row:i.y})}return a}image(e,t){let n=this.imageData(e,r1.data),r=this.imageData(e,r1.length);return{key:`${t}:${n}:${r}`,image:{width:this.imageData(e,r1.width),height:this.imageData(e,r1.height),format:this.imageData(e,r1.format),pixels:this.runtime.bytes(n,r)}}}placementData(e,t){return this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_kitty_graphics_placement_get`,this.runtime.call(`ghostty_kitty_graphics_placement_get`,e,t,this.scratch)),this.runtime.view(this.scratch,4)}placementU32(e,t){return this.placementData(e,t).getUint32(0,!0)}imageData(e,t){return this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_kitty_graphics_image_get`,this.runtime.call(`ghostty_kitty_graphics_image_get`,e,t,this.scratch)),this.runtime.view(this.scratch,4).getUint32(0,!0)}};function p1(e,t,n,r,i){let a=r.width/i.width,o=r.height/i.height;for(let i of t){let t=i.placement;m1(t.z)===n&&e.drawImage(i.bitmap,t.source.x,t.source.y,t.source.width,t.source.height,t.column*r.width+t.xOffset*a,t.row*r.height+t.yOffset*o,t.width*a,t.height*o)}}function m1(e){return e<-1073741824?`belowBackground`:e<0?`belowText`:`aboveText`}function h1(e){let t=a1.get(e.format);if(t===void 0)throw Error(`unsupported kitty image format ${e.format}`);let n=e.width*e.height,r=e.pixels,i=new Uint8ClampedArray(n*4);if(t===4)i.set(r.subarray(0,n*4));else for(let e=0;e<n;e+=1){let n=e*t,a=e*4;t===3?i.set(r.subarray(n,n+3),a):i.fill(r[n],a,a+3),i[a+3]=t===2?r[n+1]:255}let a=new OffscreenCanvas(e.width,e.height),o=a.getContext(`2d`);if(!o)throw Error(`could not create a canvas for a kitty image`);return o.putImageData(new ImageData(i,e.width,e.height),0,0),a}var g1=8,_1=16,v1=0,y1=1,b1=2,x1=8,S1={cols:1,rows:2,dirty:3,rowIterator:4,background:5,foreground:6,cursor:7,cursorHasValue:8,cursorStyle:10,cursorVisible:11,cursorBlinking:12,cursorInViewport:14,cursorX:15,cursorY:16},C1={dirty:1,raw:2,cells:3},w1={raw:1,style:2,graphemesLength:3,graphemes:4,background:5,foreground:6,selected:7},T1={keys:0,values:20,graphemesLength:40,selected:44,background:48,foreground:52,written:56,size:60},E1={narrow:0,wide:1,spacerTail:2},D1={r:229,g:231,b:235},O1={r:0,g:0,b:0};function k1(e,t){return Math.floor((e*155+t*100)/255)}function A1(e,t){return{r:k1(e.r,t.r),g:k1(e.g,t.g),b:k1(e.b,t.b)}}function j1(e,t){let n=``;for(let r=0;r<t;r+=4096){let i=Math.min(4096,t-r),a=Array(i);for(let t=0;t<i;t+=1)a[t]=e.getUint32((r+t)*4,!0);n+=String.fromCodePoint(...a)}return n}function M1(e,t){return{text:``,wide:0,foreground:e,background:t,bold:!1,italic:!1,invisible:!1,strikethrough:!1,overline:!1,underline:0,underlineColor:null,selected:!1,placeholder:null}}function N1(e,t){let n=e.dataView();return{r:n.getUint8(t),g:n.getUint8(t+1),b:n.getUint8(t+2)}}function P1(e,t){let n=e.alloc(768);e.call(`ghostty_terminal_get`,t,21,n);let r=e.bytes(n,768),i=Array.from({length:256},(e,t)=>({r:r[t*3],g:r[t*3+1],b:r[t*3+2]}));return e.free(n,768),i}function F1(e,t){let n=[],r=[];return e.cells.forEach((e,i)=>{if(e.wide!==2)for(let a of(e.text||` `).split(``))n.push(a),r.push({x:i,y:t})}),{text:n.join(``),points:r}}var I1=class{runtime=F$();stateSlot;state;rowIteratorSlot;rowCellsSlot;scratch;style;cellQuery;graphemes=0;graphemeCapacity=0;rows=[];palette=[];constructor(){let e=this.runtime;this.stateSlot=e.allocOpaque(),e.check(`ghostty_render_state_new`,e.call(`ghostty_render_state_new`,0,this.stateSlot)),this.state=e.readPointer(this.stateSlot),this.rowIteratorSlot=e.allocOpaque(),e.check(`ghostty_render_state_row_iterator_new`,e.call(`ghostty_render_state_row_iterator_new`,0,this.rowIteratorSlot)),this.rowCellsSlot=e.allocOpaque(),e.check(`ghostty_render_state_row_cells_new`,e.call(`ghostty_render_state_row_cells_new`,0,this.rowCellsSlot)),this.scratch=e.alloc(16),this.style=e.alloc(e.layout(`GhosttyStyle`).size),this.cellQuery=e.alloc(T1.size);let t=e.dataView();[[w1.style,this.style],[w1.graphemesLength,this.cellQuery+T1.graphemesLength],[w1.selected,this.cellQuery+T1.selected],[w1.background,this.cellQuery+T1.background],[w1.foreground,this.cellQuery+T1.foreground]].forEach((e,n)=>{t.setUint32(this.cellQuery+T1.keys+n*4,e[0],!0),t.setUint32(this.cellQuery+T1.values+n*4,e[1],!0)})}snapshot(e,t){let n=this.runtime;n.check(`ghostty_render_state_update`,n.call(`ghostty_render_state_update`,this.state,e));let r=this.getRender(S1.cols,2),i=this.getRender(S1.rows,2),a=this.getRender(S1.dirty,4),o=this.getColor(S1.foreground,D1),s=this.getColor(S1.background,O1),c=this.getRender(S1.cursorHasValue,1)===0?o:this.getColor(S1.cursor,o),l=this.getRender(S1.cursorInViewport,1)!==0,u=this.getRender(S1.cursorVisible,1)!==0&&l;(this.rows.length!==i||this.rows.some(e=>e.cells.length!==r))&&(this.rows=Array.from({length:i},()=>({cells:Array.from({length:r},()=>M1(o,s)),isWrapContinuation:!1,wrapsToNext:!1})));let d=new Set;if(a!==0){this.palette=P1(n,e),n.check(`ghostty_render_state_get`,n.call(`ghostty_render_state_get`,this.state,S1.rowIterator,this.rowIteratorSlot));let c=n.readPointer(this.rowIteratorSlot),l=0;for(;l<i&&n.call(`ghostty_render_state_row_iterator_next`,c)!==0;)(a===2||this.getRowFlag(c,C1.dirty))&&(this.rows[l]=this.readRow(c,r,o,s,t),d.add(l),n.bytes(this.scratch,1)[0]=0,n.call(`ghostty_render_state_row_set`,c,0,this.scratch)),l+=1;n.view(this.scratch,4).setUint32(0,0,!0),n.call(`ghostty_render_state_set`,this.state,0,this.scratch)}return{cols:r,rows:i,foreground:o,background:s,cursor:c,cursorX:l?this.getRender(S1.cursorX,2):-1,cursorY:l?this.getRender(S1.cursorY,2):-1,cursorVisible:u,cursorBlinking:this.getRender(S1.cursorBlinking,1)!==0,cursorStyle:this.getRender(S1.cursorStyle,4),dirtyRows:d,rowData:this.rows}}invalidate(){this.rows=[]}dispose(){let e=this.runtime,t=e.readPointer(this.rowCellsSlot);t&&e.call(`ghostty_render_state_row_cells_free`,t);let n=e.readPointer(this.rowIteratorSlot);n&&e.call(`ghostty_render_state_row_iterator_free`,n),e.call(`ghostty_render_state_free`,this.state),e.free(this.style,e.layout(`GhosttyStyle`).size),e.free(this.cellQuery,T1.size),e.free(this.scratch,16),e.free(this.graphemes,this.graphemeCapacity),e.freeOpaque(this.rowCellsSlot),e.freeOpaque(this.rowIteratorSlot),e.freeOpaque(this.stateSlot)}readRow(e,t,n,r,i){let a=this.runtime;a.check(`ghostty_render_state_row_get`,a.call(`ghostty_render_state_row_get`,e,C1.raw,this.scratch));let o=a.view(this.scratch,8).getBigUint64(0,!0);a.bytes(this.scratch+8,1)[0]=0,a.call(`ghostty_row_get`,o,2,this.scratch+8);let s=a.bytes(this.scratch+8,1)[0]!==0;a.bytes(this.scratch+8,1)[0]=0,a.call(`ghostty_row_get`,o,1,this.scratch+8);let c=a.bytes(this.scratch+8,1)[0]!==0;a.check(`ghostty_render_state_row_get`,a.call(`ghostty_render_state_row_get`,e,C1.cells,this.rowCellsSlot));let l=a.readPointer(this.rowCellsSlot),u=a.layout(`GhosttyStyle`),d=u.size,f=u.fields,p=[];for(;p.length<t&&a.call(`ghostty_render_state_row_cells_next`,l)!==0;){a.bytes(this.style,d).fill(0),a.setField(this.style,`GhosttyStyle`,`size`,d);let e=a.call(`ghostty_render_state_row_cells_get_multi`,l,5,this.cellQuery+T1.keys,this.cellQuery+T1.values,this.cellQuery+T1.written),t=a.dataView(),o=t.getUint32(this.cellQuery+T1.written,!0);o<3&&a.check(`ghostty_render_state_row_cells_get_multi`,e);let s=t.getUint32(this.cellQuery+T1.graphemesLength,!0),c=t.getUint8(this.cellQuery+T1.selected)!==0,u=o>=4?N1(a,this.cellQuery+T1.background):r,m=o===5?N1(a,this.cellQuery+T1.foreground):o===3?this.getCellColor(l,n):n,h=``;if(s>0){let e=s*4;if(e>this.graphemeCapacity){let t=Math.max(e,this.graphemeCapacity*2),n=a.alloc(t);a.free(this.graphemes,this.graphemeCapacity),this.graphemes=n,this.graphemeCapacity=t}a.call(`ghostty_render_state_row_cells_get`,l,w1.graphemes,this.graphemes)===0&&(h=j1(a.view(this.graphemes,e),s))}let g=0;if(h.length===0&&p.at(-1)?.text.length){a.call(`ghostty_render_state_row_cells_get`,l,w1.raw,this.scratch);let e=a.view(this.scratch,8).getBigUint64(0,!0);a.view(this.scratch+8,4).setUint32(0,0,!0),a.call(`ghostty_cell_get`,e,3,this.scratch+8),g=a.view(this.scratch+8,4).getUint32(0,!0)}let _=a.dataView(),v=e=>_.getUint8(this.style+f[e].offset)!==0,y=v(`bold`);if(i&&y&&_.getUint32(this.style+g1,!0)===y1){let e=_.getUint8(this.style+_1);e<8&&(m=this.palette[e+8]??m)}if(v(`inverse`)){let e=m;m=u,u=e}v(`faint`)&&(m=A1(m,u));let b=this.style+f.underline_color.offset,x=_.getUint32(b,!0),S=b+x1,C=null;h.codePointAt(0)===1109742&&(C=s1(h,this.colorId(this.style+g1),this.colorId(b)),h=``),p.push({text:h,wide:g,foreground:m,background:u,bold:y,italic:v(`italic`),invisible:v(`invisible`),strikethrough:v(`strikethrough`),overline:v(`overline`),underline:_.getInt32(this.style+f.underline.offset,!0),underlineColor:x===y1?this.palette[_.getUint8(S)]:x===b1?N1(a,S):null,selected:c,placeholder:C})}for(;p.length<t;)p.push(M1(n,r));return{cells:p,isWrapContinuation:s,wrapsToNext:c}}getRender(e,t){this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_render_state_get`,this.runtime.call(`ghostty_render_state_get`,this.state,e,this.scratch));let n=this.runtime.view(this.scratch,4);return t===1?n.getUint8(0):t===2?n.getUint16(0,!0):n.getUint32(0,!0)}getColor(e,t){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_get`,this.state,e,this.scratch)===0?N1(this.runtime,this.scratch):t}getRowFlag(e,t){return this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_render_state_row_get`,e,t,this.scratch)===0&&this.runtime.bytes(this.scratch,1)[0]!==0}getCellColor(e,t){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_row_cells_get`,e,w1.foreground,this.scratch)===0?N1(this.runtime,this.scratch):t}colorId(e){let t=this.runtime.dataView(),n=t.getUint32(e,!0);if(n===v1)return 0;if(n===y1)return t.getUint8(e+x1);if(n===b1){let t=N1(this.runtime,e+x1);return t.r<<16|t.g<<8|t.b}throw Error(`unknown style color tag ${n}`)}},L1=16,R1=589824,z1=381888,B1=5e7,V1=new TextDecoder;function H1(e){let t=[...e],n=[0,95,135,175,215,255];for(let e=16;e<232;e+=1){let r=e-16;t.push({r:n[Math.floor(r/36)],g:n[Math.floor(r/6)%6],b:n[r%6]})}for(let e=0;e<24;e+=1){let n=8+e*10;t.push({r:n,g:n,b:n})}return t}var U1=class{encoder;kitty;runtime=F$();terminalSlot;terminal;renderState;formatterSlot;formatter;scratch;point;scrollbar;host;hostId=0;sizeReport;disposed=!1;boldIsBright=!1;version=``;constructor(e,t,n,r,i){let a=this.runtime,o=a.layout(`GhosttyTerminalOptions`).size,s=a.alloc(o);a.setField(s,`GhosttyTerminalOptions`,`cols`,e),a.setField(s,`GhosttyTerminalOptions`,`rows`,t);let c=Math.floor(z1/(8*(e+1)));a.setField(s,`GhosttyTerminalOptions`,`max_scrollback`,n===0?0:Math.min((Math.ceil(n/c)+1)*R1,B1)),this.terminalSlot=a.allocOpaque();let l=a.call(`ghostty_terminal_new`,0,this.terminalSlot,s);if(a.free(s,o),a.check(`ghostty_terminal_new`,l),this.terminal=a.readPointer(this.terminalSlot),!d1(this.terminal))throw a.call(`ghostty_terminal_free`,this.terminal),a.freeOpaque(this.terminalSlot),Error(`libghostty-vt was built without kitty graphics, build it with scripts/build-ghostty-wasm.mts`);this.sizeReport={rows:t,columns:e,cellWidth:1,cellHeight:1},this.host={write:r,size:()=>this.sizeReport,bell:i,version:()=>this.version},this.hostId=a.attachHost(this.terminal,this.host),this.renderState=new I1,this.encoder=new Q$(this.terminal),this.kitty=new f1(this.terminal);let u=`GhosttyFormatterTerminalOptions`,d=a.layout(u),f=a.alloc(d.size),p=a.field(u,`extra`),m=a.field(`GhosttyFormatterTerminalExtra`,`screen`);a.setField(f,u,`size`,d.size),a.setField(f,u,`trim`,1),a.setField(f+p.offset,`GhosttyFormatterTerminalExtra`,`size`,p.size),a.setField(f+p.offset+m.offset,`GhosttyFormatterScreenExtra`,`size`,m.size),this.formatterSlot=a.allocOpaque();let h=a.call(`ghostty_formatter_terminal_new`,0,this.formatterSlot,this.terminal,f);a.free(f,d.size),a.check(`ghostty_formatter_terminal_new`,h),this.formatter=a.readPointer(this.formatterSlot),this.scratch=a.alloc(16),this.point=a.alloc(a.layout(`GhosttyPoint`).size),this.scrollbar=a.alloc(a.layout(`GhosttyTerminalScrollbar`).size)}write(e){if(e.length===0)return;this.kitty.note(e);let t=this.runtime.alloc(e.length);this.runtime.bytes(t,e.length).set(e),this.runtime.call(`ghostty_terminal_vt_write`,this.terminal,t,e.length),this.runtime.free(t,e.length)}setReplies(e){e&&this.hostId===0?this.hostId=this.runtime.attachHost(this.terminal,this.host):!e&&this.hostId!==0&&(this.runtime.detachHost(this.terminal,this.hostId),this.hostId=0)}reset(){this.runtime.call(`ghostty_terminal_reset`,this.terminal),this.renderState.invalidate()}resize(e,t,n,r,i){this.sizeReport={rows:t,columns:e,cellWidth:Math.max(1,Math.round(n*i)),cellHeight:Math.max(1,Math.round(r*i))},this.runtime.check(`ghostty_terminal_resize`,this.runtime.call(`ghostty_terminal_resize`,this.terminal,Math.max(1,Math.min(65535,e)),Math.max(1,Math.min(65535,t)),this.sizeReport.cellWidth,this.sizeReport.cellHeight))}setColors(e){let t=this.runtime.alloc(3);for(let n of[[11,e.foreground],[12,e.background],[13,e.cursor]]){let e=n[1];this.runtime.bytes(t,3).set([e.r,e.g,e.b]),this.runtime.call(`ghostty_terminal_set`,this.terminal,n[0],t)}this.runtime.free(t,3);let n=H1(e.palette),r=this.runtime.alloc(n.length*3);this.runtime.bytes(r,n.length*3).set(n.flatMap(e=>[e.r,e.g,e.b])),this.runtime.call(`ghostty_terminal_set`,this.terminal,14,r),this.runtime.free(r,n.length*3),this.renderState.invalidate()}setCursor(e,t){let n={bar:0,block:1,underline:2}[e];this.runtime.view(this.scratch,4).setUint32(0,n,!0),this.runtime.call(`ghostty_terminal_set`,this.terminal,22,this.scratch),this.runtime.bytes(this.scratch,1)[0]=+!!t,this.runtime.call(`ghostty_terminal_set`,this.terminal,23,this.scratch)}title(){if(this.runtime.bytes(this.scratch,8).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,12,this.scratch)!==0)return``;let e=this.runtime.view(this.scratch,8),t=e.getUint32(0,!0),n=e.getUint32(4,!0);return n===0?``:V1.decode(this.runtime.bytes(t,n))}screenText(){let e=this.runtime.alloc(8),t=this.runtime.call(`ghostty_formatter_format_alloc`,this.formatter,0,e,e+4),n=this.runtime.view(e,8),r=n.getUint32(0,!0),i=n.getUint32(4,!0);if(this.runtime.free(e,8),t!==0)return``;let a=V1.decode(this.runtime.bytes(r,i));return this.runtime.call(`ghostty_free`,0,r,i),a}scroll(e){let t=this.runtime.layout(`GhosttyTerminalScrollViewport`),n=this.runtime.alloc(t.size);this.runtime.setField(n,`GhosttyTerminalScrollViewport`,`tag`,2);let r=this.runtime.field(`GhosttyTerminalScrollViewport`,`value`);this.runtime.view(n+r.offset,r.size).setInt32(0,e,!0),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,n),this.runtime.free(n,t.size)}scrollToBottom(){let e=this.runtime.layout(`GhosttyTerminalScrollViewport`),t=this.runtime.alloc(e.size);this.runtime.setField(t,`GhosttyTerminalScrollViewport`,`tag`,1),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,t),this.runtime.free(t,e.size)}scrollbarState(){let e=this.runtime.layout(`GhosttyTerminalScrollbar`);return this.runtime.bytes(this.scrollbar,e.size).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,9,this.scrollbar)===0?{total:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`total`),offset:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`offset`),len:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`len`)}:null}isMouseTracking(){return this.flag(`ghostty_terminal_get`,11)}isMouseAnyEventTracking(){return this.flag(`ghostty_terminal_mode_get`,1003)}isFocusReporting(){return this.flag(`ghostty_terminal_mode_get`,1004)}isSynchronizedOutput(){return this.flag(`ghostty_terminal_mode_get`,2026)}endSynchronizedOutput(){this.runtime.check(`ghostty_terminal_mode_set`,this.runtime.call(`ghostty_terminal_mode_set`,this.terminal,2026,0))}currentColors(){return{foreground:this.terminalColor(18),background:this.terminalColor(19),cursor:this.terminalColor(20),palette:P1(this.runtime,this.terminal)}}isApplicationCursorKeys(){return this.flag(`ghostty_terminal_mode_get`,1)}isKittyKeyboard(){return this.flag(`ghostty_terminal_get`,8)}isAlternateScreen(){return this.runtime.dataView().setUint32(this.scratch,0,!0),this.runtime.call(`ghostty_terminal_get`,this.terminal,6,this.scratch)===0&&this.runtime.dataView().getUint32(this.scratch,!0)===1}setSelection(e,t){let n=this.runtime.layout(`GhosttyGridRef`).size,r=this.gridRef(e.x,e.y,2);try{let e=this.gridRef(t.x,t.y,2),i=this.runtime.layout(`GhosttySelection`),a=this.runtime.alloc(i.size);this.runtime.setField(a,`GhosttySelection`,`size`,i.size);let o=this.runtime.field(`GhosttySelection`,`start`),s=this.runtime.field(`GhosttySelection`,`end`);this.runtime.bytes(a+o.offset,o.size).set(this.runtime.bytes(r,o.size)),this.runtime.bytes(a+s.offset,s.size).set(this.runtime.bytes(e,s.size)),this.runtime.call(`ghostty_terminal_set`,this.terminal,21,a),this.runtime.free(e,n),this.runtime.free(a,i.size)}finally{this.runtime.free(r,n)}}selectWord(e){return this.selectAt(`GhosttyTerminalSelectWordOptions`,`ghostty_terminal_select_word`,e)}selectLine(e){return this.selectAt(`GhosttyTerminalSelectLineOptions`,`ghostty_terminal_select_line`,e)}clearSelection(){this.runtime.call(`ghostty_terminal_set`,this.terminal,21,0)}selectionText(){let e=this.runtime.alloc(L1),t=this.runtime.view(e,L1);t.setUint32(0,L1,!0),t.setUint8(8,1),t.setUint8(9,1);let n=this.runtime.encodeOutput((t,n,r)=>this.runtime.call(`ghostty_terminal_selection_format_buf`,this.terminal,e,t,n,r));return this.runtime.free(e,L1),n}hyperlinkAt(e,t){let n=this.gridRef(e,t,1),r=this.hyperlinkOf(n);return this.runtime.free(n,this.runtime.layout(`GhosttyGridRef`).size),r}toScreen(e){let t=this.gridRef(e.x,e.y,1),n=this.pointFromGridRef(t,2);return this.runtime.free(t,this.runtime.layout(`GhosttyGridRef`).size),n}trackCursor(){let e=this.runtime.allocOpaque(),t=this.runtime.call(`ghostty_terminal_grid_ref_track`,this.terminal,this.cursorPoint(),e),n=this.runtime.readPointer(e);return this.runtime.freeOpaque(e),this.runtime.check(`ghostty_terminal_grid_ref_track`,t),n}retrack(e){let t=this.runtime.call(`ghostty_tracked_grid_ref_set`,e,this.terminal,this.cursorPoint());this.runtime.check(`ghostty_tracked_grid_ref_set`,t)}trackedPoint(e){return this.runtime.call(`ghostty_tracked_grid_ref_point`,e,2,this.scratch)===0?{x:this.runtime.readField(this.scratch,`GhosttyPointCoordinate`,`x`),y:this.runtime.readField(this.scratch,`GhosttyPointCoordinate`,`y`)}:null}trackedHyperlink(e){let t=this.runtime.layout(`GhosttyGridRef`).size,n=this.runtime.alloc(t);this.runtime.setField(n,`GhosttyGridRef`,`size`,t);let r=this.runtime.call(`ghostty_tracked_grid_ref_snapshot`,e,n)===0?this.hyperlinkOf(n):null;return this.runtime.free(n,t),r}untrack(e){this.runtime.call(`ghostty_tracked_grid_ref_free`,e)}snapshot(){return this.renderState.snapshot(this.terminal,this.boldIsBright)}invalidate(){this.renderState.invalidate()}cellSize(){return{width:this.sizeReport.cellWidth,height:this.sizeReport.cellHeight}}dispose(){if(this.disposed)return;this.disposed=!0;let e=this.runtime;e.call(`ghostty_formatter_free`,this.formatter),this.encoder.dispose(),this.kitty.dispose(),this.renderState.dispose(),this.hostId!==0&&e.detachHost(this.terminal,this.hostId),e.call(`ghostty_terminal_free`,this.terminal),e.free(this.scrollbar,e.layout(`GhosttyTerminalScrollbar`).size),e.free(this.scratch,16),e.free(this.point,e.layout(`GhosttyPoint`).size),e.freeOpaque(this.formatterSlot),e.freeOpaque(this.terminalSlot)}hyperlinkOf(e){let t=this.runtime.encodeOutput((t,n,r)=>this.runtime.call(`ghostty_grid_ref_hyperlink_uri`,e,t,n,r));return t===``?null:t}cursorPosition(){this.runtime.dataView().setUint32(this.scratch,0,!0),this.runtime.call(`ghostty_terminal_get`,this.terminal,3,this.scratch),this.runtime.call(`ghostty_terminal_get`,this.terminal,4,this.scratch+2);let e=this.runtime.dataView();return{x:e.getUint16(this.scratch,!0),y:e.getUint16(this.scratch+2,!0)}}cursorPoint(){let e=this.cursorPosition();return this.fillPoint(this.point,e.x,e.y,0),this.point}fillPoint(e,t,n,r){this.runtime.setField(e,`GhosttyPoint`,`tag`,r);let i=this.runtime.field(`GhosttyPoint`,`value`),a=this.runtime.dataView();a.setUint16(e+i.offset,Math.max(0,t),!0),a.setUint32(e+i.offset+4,Math.max(0,n),!0)}gridRef(e,t,n){let r=this.runtime.alloc(this.runtime.layout(`GhosttyPoint`).size);this.fillPoint(r,e,t,n);let i=this.runtime.layout(`GhosttyGridRef`).size,a=this.runtime.alloc(i);this.runtime.setField(a,`GhosttyGridRef`,`size`,i);let o=this.runtime.call(`ghostty_terminal_grid_ref`,this.terminal,r,a);return this.runtime.free(r,this.runtime.layout(`GhosttyPoint`).size),o!==0&&(this.runtime.free(a,i),this.runtime.check(`ghostty_terminal_grid_ref`,o)),a}selectAt(e,t,n){let r=this.gridRef(n.x,n.y,2),i=this.runtime.layout(e),a=this.runtime.layout(`GhosttySelection`),o=this.runtime.alloc(i.size),s=this.runtime.alloc(a.size);this.runtime.setField(o,e,`size`,i.size);let c=this.runtime.field(e,`ref`);this.runtime.bytes(o+c.offset,c.size).set(this.runtime.bytes(r,c.size)),this.runtime.setField(s,`GhosttySelection`,`size`,a.size);let l=null;if(this.runtime.call(t,this.terminal,o,s)===0){let e=this.pointFromGridRef(s+this.runtime.field(`GhosttySelection`,`start`).offset,2),t=this.pointFromGridRef(s+this.runtime.field(`GhosttySelection`,`end`).offset,2);e&&t&&(l={start:e,end:t})}return this.runtime.free(s,a.size),this.runtime.free(r,this.runtime.layout(`GhosttyGridRef`).size),this.runtime.free(o,i.size),l}pointFromGridRef(e,t){let n=this.runtime.layout(`GhosttyPointCoordinate`),r=this.runtime.alloc(n.size),i=this.runtime.call(`ghostty_terminal_point_from_grid_ref`,this.terminal,e,t,r)===0?{x:this.runtime.readField(r,`GhosttyPointCoordinate`,`x`),y:this.runtime.readField(r,`GhosttyPointCoordinate`,`y`)}:null;return this.runtime.free(r,n.size),i}flag(e,t){return this.runtime.flag(e,this.terminal,t)}terminalColor(e){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.check(`ghostty_terminal_get`,this.runtime.call(`ghostty_terminal_get`,this.terminal,e,this.scratch)),N1(this.runtime,this.scratch)}};function W1(e,t){let n=[],r=e.toLowerCase(),i=t.toLowerCase(),a=r.indexOf(i);for(;a!==-1;)n.push(a),a=r.indexOf(i,a+i.length);return n}var G1=class{core;redraw;listeners=new Set;query=``;matches=[];activeMatch=-1;stale=!1;timer=null;constructor(e,t){this.core=e,this.redraw=t}find(e,t,n,r){let i=this.matches[this.activeMatch]??null;if(this.query=e,this.refresh(),this.matches.length===0)this.activeMatch=-1;else if(n||i===null){let e=i?.row??r,t=this.matches.findIndex(t=>t.row>=e);this.activeMatch=t===-1?this.matches.length-1:t}else{let e=this.matches.findIndex(e=>e.row===i.row&&e.index===i.index),n=e===-1?0:e,r=t?-1:1;this.activeMatch=(n+r+this.matches.length)%this.matches.length}return this.emit(),this.matches[this.activeMatch]??null}onResults(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}clear(){this.query=``,this.matches=[],this.activeMatch=-1}outputChanged(){this.query!==``&&(this.stale=!0,this.timer===null&&(this.timer=window.setTimeout(()=>{if(this.timer=null,!this.stale||this.query===``)return;let e=this.matches[this.activeMatch];this.refresh();let t=e?this.matches.findIndex(t=>t.row===e.row&&t.index===e.index):-1;this.activeMatch=t===-1?this.matches.length-1:t,this.emit(),this.redraw()},200)))}highlights(e,t){if(this.query===``)return[];let n=this.matches[this.activeMatch],r=[];return e.rowData.forEach((e,i)=>{let a=F1(e,i);W1(a.text,this.query).forEach((e,o)=>{let s=a.points[e],c=a.points[e+this.query.length-1];s&&c&&r.push({row:i,start:s.x,end:c.x+1,active:n?.row===t+i&&n.index===o})})}),r}dispose(){this.timer!==null&&window.clearTimeout(this.timer),this.timer=null}refresh(){this.stale=!1,this.matches=[],this.query!==``&&this.core.screenText().split(`
|
|
113
113
|
`).forEach((e,t)=>{W1(e,this.query).forEach((e,n)=>this.matches.push({row:t,index:n}))})}emit(){let e={resultIndex:this.activeMatch,resultCount:this.matches.length};for(let t of this.listeners)t(e)}},K1=new TextDecoder;function q1(e){function t(e){return e.toString(16).padStart(2,`0`).repeat(2)}return`rgb:${t(e.r)}/${t(e.g)}/${t(e.b)}`}function J1(e){return Math.min(Math.max(e,0),100)}function Y1(e){return K1.decode(Uint8Array.from(atob(e),e=>e.charCodeAt(0)))}function X1(e){return e===``?`s0`:[...e].filter(e=>`cpqs01234567`.includes(e)).join(``)}function Z1(e){try{return Y1(e)}catch(e){return console.warn(`invalid clipboard sequence`,e),null}}function Q1(e,t,n){let r=Array.from(new TextEncoder().encode(e),e=>String.fromCharCode(e)).join(``);return`\x1b]52;${t};${btoa(r)}${n}`}function $1(e,t,n){let r=e===`10;?`?t.foreground:e===`11;?`?t.background:t.cursor;return`\x1b]${e.slice(0,2)};${q1(r)}${n}`}function e0(e,t,n){let r=e.split(`;`),i=[];for(let e=1;e+1<r.length;e+=2){if(r[e+1]!==`?`||!/^\d+$/.test(r[e]))continue;let a=t[Number(r[e])];a!==void 0&&i.push(`\x1b]4;${r[e]};${q1(a)}${n}`)}return i}function t0(e,t){let n=e.split(`;`);if(n.length>4)return null;let r=n[2]===void 0||n[2]===``?0:Number(n[2]),i=n[3]===void 0||n[3]===``?-1:Number(n[3]);return!Number.isInteger(r)||!Number.isInteger(i)?null:r===0?{state:r,value:0}:r===1?i<0?null:{state:r,value:J1(i)}:r===2||r===4?i<0?{state:r,value:t.value}:{state:r,value:J1(i||t.value)}:r===3?{state:r,value:t.value}:null}function n0(e,t){if(e.startsWith(`9;`)&&!/^9;\d+(;|$)/.test(e))return{title:``,body:K1.decode(t.subarray(2))};if(e.startsWith(`777;notify;`)){let e=K1.decode(t).split(`;`);return{title:e[2]??``,body:e.slice(3).join(`;`)}}return null}var r0=class{pending={id:``,title:``,body:``};add(e){let t=e.indexOf(`;`,3);if(t===-1)return null;let n=new Map;for(let r of e.slice(3,t).split(`:`)){let e=r.indexOf(`=`);e!==-1&&n.set(r.slice(0,e),r.slice(e+1))}let r=n.get(`p`)??`title`;if(r===`?`||r===`close`||r===`alive`)return null;let i=e.slice(t+1);if(n.get(`e`)===`1`)try{i=Y1(i)}catch(e){return console.warn(`invalid notification sequence`,e),null}let a=n.get(`i`)??``;if(a!==this.pending.id&&(this.pending={id:a,title:``,body:``}),r===`title`&&(this.pending.title+=i),r===`body`&&(this.pending.body+=i),n.get(`d`)===`0`)return null;let o=this.pending;return this.pending={id:``,title:``,body:``},o.title===``&&o.body===``?null:{title:o.title,body:o.body}}},i0=27,a0=7,o0=24,s0=26,c0=33554432,l0=class{state=`ground`;params=``;collecting=!1;chunks=[];size=0;reset(){this.state=`ground`,this.drop()}scan(e,t){let n=0;for(let r=0;r<e.length;r+=1){let i=e[r];if(i===o0||i===s0)this.state=`ground`,this.drop();else if(this.state===`ground`)i===i0&&(this.state=`escape`);else if(this.state===`escape`){if(this.params=``,i===93){this.state=`osc`,this.begin(),n=r+1;continue}if(i===80){this.state=`dcsHeader`;continue}this.state=i===i0?`escape`:`ground`}else if(this.state===`osc`){if(i===a0){if(this.state=`ground`,this.append(e,n,r),t({type:`osc`,data:this.take(),terminator:`\x07`},r+1))return r+1;continue}i===i0&&(this.state=`oscEscape`,this.append(e,n,r))}else if(this.state===`oscEscape`){if(i===92){if(this.state=`ground`,t({type:`osc`,data:this.take(),terminator:`\x1B\\`},r+1))return r+1;continue}this.drop(),this.state=`escape`,--r}else if(this.state===`dcsHeader`){if(i===i0){this.state=`dcsEscape`;continue}if(i>=32&&i<=63){this.params.length<16&&(this.params+=String.fromCharCode(i));continue}this.state=`dcs`,i===113&&/^[0-9;]*$/.test(this.params)&&(this.begin(),n=r+1)}else if(this.state===`dcs`)i===i0&&(this.state=`dcsEscape`,this.append(e,n,r));else if(i===92){if(this.state=`ground`,this.collecting&&t({type:`sixel`,data:this.take()},r+1))return r+1}else this.drop(),this.state=`escape`,--r}return(this.state===`osc`||this.state===`dcs`)&&this.append(e,n,e.length),e.length}begin(){this.collecting=!0,this.chunks=[],this.size=0}append(e,t,n){!this.collecting||n<=t||(this.size+n-t>c0?this.drop():(this.chunks.push(e.slice(t,n)),this.size+=n-t))}take(){let e=new Uint8Array(this.size),t=0;for(let n of this.chunks)e.set(n,t),t+=n.length;return this.drop(),e}drop(){this.collecting=!1,this.chunks=[],this.size=0}},u0=`0101.0202.1010.2020.........0110.0210.0120.0220.0011.0012.0021.0022.1100.1200.2100.2200.1001.1002.2001.2002.1110.1210.2110.1120.2120.2210.1220.2220.1011.1012.2011.1021.2021.2012.1022.2022.0111.0112.0211.0212.0121.0122.0221.0222.1101.1102.1201.1202.2101.2102.2201.2202.1111.1112.1211.1212.2111.1121.2121.2112.2211.1122.1221.2212.1222.2122.2221.2222`.split(`.`),d0=[`0001`,`1000`,`0100`,`0010`,`0002`,`2000`,`0200`,`0020`,`0201`,`1020`,`0102`,`2010`],f0=`0303.3030.0310.0130.0330.0013.0031.0033.1300.3100.3300.1003.3001.3003.1310.3130.3330.1013.3031.3033.0313.0131.0333.1303.3101.3303.1313.3131.3333`.split(`.`),p0=[0,0,4,4],m0=[4,0,4,4],h0=[0,4,4,4],g0=[4,4,4,4],_0=[[[0,0,8,4]],[[0,7,8,1]],[[0,6,8,2]],[[0,5,8,3]],[[0,4,8,4]],[[0,3,8,5]],[[0,2,8,6]],[[0,1,8,7]],[[0,0,8,8]],[[0,0,7,8]],[[0,0,6,8]],[[0,0,5,8]],[[0,0,4,8]],[[0,0,3,8]],[[0,0,2,8]],[[0,0,1,8]],[[4,0,4,8]],[],[],[],[[0,0,8,1]],[[7,0,1,8]],[h0],[g0],[p0],[p0,h0,g0],[p0,g0],[p0,m0,h0],[p0,m0,g0],[m0],[m0,h0],[m0,h0,g0]],v0={9617:.25,9618:.5,9619:.75},y0={9581:[1,1],9582:[-1,1],9583:[-1,-1],9584:[1,-1]};function b0(e){return e>=9472&&e<=9547?u0[e-9472]:e>=9552&&e<=9580?f0[e-9552]:e>=9588&&e<=9599?d0[e-9588]:``}function x0(e){if(e.length!==1)return!1;let t=e.charCodeAt(0);return b0(t)!==``||y0[t]!==void 0||t>=9600&&t<=9631}function S0(e){return Math.max(1,Math.round(e.height/20))}function C0(e,t,n){let[r,i,a,o]=t,s=S0(n),c=s*2,l=Math.floor(Math.max(0,n.height-s)/2),u=l+s,d=Math.floor(Math.max(0,n.height-c)/2),f=d+c,p=Math.max(0,l-s),m=u+s,h=Math.floor(Math.max(0,n.width-s)/2),g=h+s,_=Math.floor(Math.max(0,n.width-c)/2),v=_+c,y=Math.max(0,h-s),b=g+s;function x(t,r,i,a){e.fillRect(n.left+t,n.top+r,i-t,a-r)}let S=o===`2`||i===`2`?f:o!==i||a===r?o===`3`||i===`3`?m:u:o===`0`&&i===`0`?u:l,C=o===`2`||i===`2`?d:o!==i||r===a?o===`3`||i===`3`?p:l:o===`0`&&i===`0`?l:u,w=r===`2`||a===`2`?v:r!==a||o===i?r===`3`||a===`3`?b:g:r===`0`&&a===`0`?g:h,T=r===`2`||a===`2`?_:r!==a||i===o?r===`3`||a===`3`?y:h:r===`0`&&a===`0`?h:g;r===`1`&&x(h,0,g,S),r===`2`&&x(_,0,v,S),r===`3`&&(x(y,0,h,o===`3`?l:S),x(g,0,b,i===`3`?l:S)),i===`1`&&x(T,l,n.width,u),i===`2`&&x(T,d,n.width,f),i===`3`&&(x(r===`3`?g:T,p,n.width,l),x(a===`3`?g:T,u,n.width,m)),a===`1`&&x(h,C,g,n.height),a===`2`&&x(_,C,v,n.height),a===`3`&&(x(y,o===`3`?u:C,h,n.height),x(g,i===`3`?u:C,b,n.height)),o===`1`&&x(0,l,w,u),o===`2`&&x(0,d,w,f),o===`3`&&(x(0,p,r===`3`?h:w,l),x(0,u,a===`3`?h:w,m))}function w0(e,[t,n],r){let i=S0(r),a=r.left+Math.floor(Math.max(0,r.width-i)/2)+i/2,o=r.top+Math.floor(Math.max(0,r.height-i)/2)+i/2,s=t===1?r.left+r.width:r.left,c=n===1?r.top+r.height:r.top,l=Math.min(r.width,r.height)/2;e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=i,e.beginPath(),e.moveTo(a,c),e.arcTo(a,o,s,o,l),e.lineTo(s,o),e.stroke(),e.restore()}function T0(e,t,n,r){e.save(),e.setTransform(1,0,0,1,0,0),E0(e,t.charCodeAt(0),{left:Math.round(n.left*r),top:Math.round(n.top*r),width:Math.round((n.left+n.width)*r)-Math.round(n.left*r),height:Math.round((n.top+n.height)*r)-Math.round(n.top*r)}),e.restore()}function E0(e,t,n){let r=b0(t);if(r!==``){C0(e,r,n);return}let i=y0[t];if(i!==void 0){w0(e,i,n);return}let a=v0[t];if(a!==void 0)e.globalAlpha=a,e.fillRect(n.left,n.top,n.width,n.height);else for(let[r,i,a,o]of _0[t-9600]){let t=n.left+Math.round(n.width*r/8),s=n.top+Math.round(n.height*i/8);e.fillRect(t,s,n.left+Math.round(n.width*(r+a)/8)-t,n.top+Math.round(n.height*(i+o)/8)-s)}}function D0(e){return`rgb(${e.r}, ${e.g}, ${e.b})`}function O0(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b}function k0(e,t){return Math.round(e*t)/t}function A0(e,t,n,r){let i=k0(e*n.width,r);return{left:i,width:k0(t*n.width,r)-i}}function j0(e,t,n,r,i){let a=i-2,o=n+r;if(t===1)e.fillRect(n,a,r,1);else if(t===2)e.fillRect(n,a,r,1),e.fillRect(n,a-2,r,1);else if(t===3){function t(e){return a-1+Math.sin(e/3*Math.PI)*1.5}e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=1,e.beginPath(),e.moveTo(n,t(n));for(let r=Math.floor(n)+1;r<o;r+=1)e.lineTo(r,t(r));e.lineTo(o,t(o)),e.stroke(),e.restore()}else if(t===4)for(let t=Math.ceil(n/2)*2;t<o;t+=2)e.fillRect(t,a,1,1);else if(t===5)for(let t=Math.floor(n/5)*5;t<o;t+=5){let r=Math.max(t,n),i=Math.min(t+3,o);i>r&&e.fillRect(r,a,i-r,1)}else throw Error(`unknown underline style ${t}`)}function M0(e,t){return e.selected===t.selected&&O0(e.foreground,t.foreground)&&e.bold===t.bold&&e.italic===t.italic&&e.invisible===t.invisible}function N0(e,t){return`${e.italic?`italic`:`normal`} ${e.bold?700:400} ${t.fontSize}px ${t.fontFamily}`}function P0(e,t,n,r,i){e.font=`normal 400 ${t}px ${n}`;let a=e.measureText(`M`).width,o=e.measureText(`Mg`),s=o.fontBoundingBoxAscent||t,c=s+o.fontBoundingBoxDescent,l=Math.max(1,Math.round(c*r*i))/i;return{width:Math.max(1,Math.round(a*i))/i,height:l,baseline:k0((l-c)/2+s,i),faceWidth:a}}function F0(e){return/^[!-/:-@[-`{-~]$/.test(e)}function I0(e,t,n){return!(e===null||t<e.start.y||t>e.end.y||t===e.start.y&&n<e.start.x||t===e.end.y&&n>e.end.x)}function L0(e){let{context:t,snapshot:n,metrics:r,appearance:i,cursorOn:a,previousCursorY:o,pixelRatio:s}=e,c=e.forceFull?Array.from({length:n.rows},(e,t)=>t):[...n.dirtyRows];o!==null&&!c.includes(o)&&c.push(o),n.cursorVisible&&n.cursorY>=0&&!c.includes(n.cursorY)&&c.push(n.cursorY),e.forceFull&&(t.save(),t.resetTransform(),t.fillStyle=D0(n.background),t.fillRect(0,0,t.canvas.width,t.canvas.height),t.restore());function l(e){let t=e*r.height,n=k0(t,s);return{top:t,cellTop:n,cellHeight:k0(t+r.height,s)-n}}t.textBaseline=`alphabetic`;for(let e of c){if(!n.rowData[e])continue;let{cellTop:r,cellHeight:i}=l(e);t.fillStyle=D0(n.background),t.fillRect(0,r,t.canvas.width,i)}e.drawLayer(`belowBackground`);for(let a of c){let o=n.rowData[a];if(!o)continue;let{cellTop:c,cellHeight:u}=l(a),d=0;for(;d<o.cells.length;){let e=o.cells[d],a=d+1;for(;a<o.cells.length&&o.cells[a].selected===e.selected&&O0(o.cells[a].background,e.background);)a+=1;let{left:l,width:f}=A0(d,a,r,s);e.selected?(t.fillStyle=i.selectionBackground,t.fillRect(l,c,f,u)):O0(e.background,n.background)||(t.fillStyle=D0(e.background),t.fillRect(l,c,f,u)),d=a}for(let n of e.highlights){if(n.row!==a)continue;let{left:e,width:o}=A0(n.start,n.end,r,s);t.fillStyle=i.matchBackground,t.fillRect(e,c,o,u),n.active&&(t.strokeStyle=i.activeMatchBorder,t.strokeRect(e+.5,c+.5,o-1,u-1))}}e.drawLayer(`belowText`);for(let a of c){let o=n.rowData[a];if(!o)continue;let{top:c,cellTop:u,cellHeight:d}=l(a);t.save(),t.beginPath(),t.rect(0,u,t.canvas.width,d),t.clip();for(let e=0;e<o.cells.length;e+=1){let n=o.cells[e];if(n.invisible||n.text.trim().length===0)continue;t.fillStyle=n.selected?i.selectionForeground:D0(n.foreground);let a=e*r.width;if(x0(n.text)){T0(t,n.text,{left:a,top:c,width:r.width,height:r.height},s);continue}t.font=N0(n,i);let l=a+(r.width-r.faceWidth)/2,u=e,d=e+1;if(i.ligatures&&F0(n.text)){for(;u>e-3&&u>0&&F0(o.cells[u-1].text)&&M0(o.cells[u-1],n);)--u;for(;d<e+4&&d<o.cells.length&&F0(o.cells[d].text)&&M0(o.cells[d],n);)d+=1}d-u===1?t.fillText(n.text,l,c+r.baseline):(t.save(),t.beginPath(),t.rect(a,c,r.width,r.height),t.clip(),t.fillText(o.cells.slice(u,d).map(e=>e.text).join(``),l-(e-u)*r.faceWidth,c+r.baseline),t.restore())}t.restore();for(let n=0;n<o.cells.length;n+=1){let i=o.cells[n],l=I0(e.hoveredLink,a,n);if(i.underline===0&&!i.strikethrough&&!i.overline&&!l)continue;let{left:f,width:p}=A0(n,n+1,r,s),m=u+d;t.fillStyle=D0(i.foreground),i.strikethrough&&t.fillRect(f,c+Math.floor(r.height*.55),p,1),i.overline&&t.fillRect(f,u+1,p,1),i.underline===0?l&&j0(t,1,f,p,m):(i.underlineColor!==null&&(t.fillStyle=D0(i.underlineColor)),j0(t,i.underline,f,p,m))}}if(!a||!n.cursorVisible||n.cursorX<0||n.cursorY<0)return;let u=n.cursorY*r.height,d=k0(u,s),f=k0(u+r.height,s)-d,p=n.rowData[n.cursorY]?.cells,m=p?.[n.cursorX],h=p?.[n.cursorX+1]?.wide===E1.spacerTail?2:1,{left:g,width:_}=A0(n.cursorX,n.cursorX+h,r,s);t.fillStyle=D0(n.cursor),t.strokeStyle=D0(n.cursor),!e.focused||n.cursorStyle===3?t.strokeRect(g+.5,d+.5,_-1,f-1):n.cursorStyle===0?t.fillRect(g,d,1,f):n.cursorStyle===2?t.fillRect(g,d+f-2,_,2):(t.fillRect(g,d,_,f),m?.text&&(t.fillStyle=i.cursorText,x0(m.text)?T0(t,m.text,{left:n.cursorX*r.width,top:u,width:r.width,height:r.height},s):(t.font=N0(m,i),t.fillText(m.text,n.cursorX*r.width+(r.width-r.faceWidth)/2,u+r.baseline))))}var R0=navigator.userAgent.includes(`Mac`),z0=500,B0=/https?:\/\/[^\s"'`<>]+/g;function V0(e){return e===0?1:e===1?3:e===2?2:null}function H0(e,t){let n=Math.max(0,e.total-e.len);if(t<=0||e.len<=0||n===0)return null;let r=Math.min(t,Math.max(20,t*e.len/e.total)),i=t-r;return{thumbHeight:r,thumbTop:i*(Math.min(e.offset,n)/n),travel:i,maxOffset:n}}var U0=class{hoveredLink=null;context;linkPointer=null;mousePointer=null;mouseButton=null;lastMotion=``;selectionPointer=null;selectionMode=`cell`;selectionAnchor=null;selectionBase=null;selectionMoved=!1;selectionScroll=null;selectionScrollDelta=0;selectionClient=null;clickMove=null;clicks={count:0,time:0,x:0,y:0};touch=null;wheelRemainder=0;scrollbarDrag=null;constructor(e){this.context=e;let t=e.canvas,n=e.scrollbar;t.addEventListener(`pointerdown`,this.onPointerDown),t.addEventListener(`pointermove`,this.onPointerMove),t.addEventListener(`pointerup`,this.onPointerUp),t.addEventListener(`pointercancel`,this.onPointerUp),t.addEventListener(`pointerleave`,this.onPointerLeave),t.addEventListener(`wheel`,this.onWheel,{passive:!1}),t.addEventListener(`mousedown`,this.onMouseDown),n.addEventListener(`pointerdown`,this.onScrollbarDown),n.addEventListener(`pointermove`,this.onScrollbarMove),n.addEventListener(`pointerup`,this.onScrollbarUp),n.addEventListener(`pointercancel`,this.onScrollbarUp)}updateScrollbar(e){let t=this.context.core.scrollbarState(),n=t===null?null:H0(t,e);this.context.scrollbar.hidden=n===null,n!==null&&(this.context.thumb.style.height=`${n.thumbHeight}px`,this.context.thumb.style.transform=`translateY(${n.thumbTop}px)`)}dispose(){this.setSelectionScroll(0)}scrollRows(e,t){let n=this.context.core,r=this.wheelRemainder+e/this.context.view().metrics.height,i=Math.trunc(r);if(this.wheelRemainder=r-i,i!==0){if(this.reportsMouse(t))for(let e=0;e<Math.abs(i);e+=1)this.sendMouse(`press`,i<0?4:5,t);else if(n.isAlternateScreen()){let e=(n.isApplicationCursorKeys()?`\x1BO`:`\x1B[`)+(i<0?`A`:`B`);this.context.onData(e.repeat(Math.abs(i)))}else this.context.scrollViewport(i)}}cellAt(e,t){let n=this.context.view(),r=this.context.canvas.getBoundingClientRect();return{x:Math.max(0,Math.min(n.cols-1,Math.floor((e-r.left)/n.metrics.width))),y:Math.max(0,Math.min(n.rows-1,Math.floor((t-r.top)/n.metrics.height)))}}reportsMouse(e){return this.context.core.isMouseTracking()&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey}sendMouse(e,t,n){let r=this.context.view(),i=this.context.canvas.getBoundingClientRect(),a=window.devicePixelRatio||1,o=this.context.core.encoder.encodeMouse({action:e,button:t,mods:+!!n.shiftKey|(n.ctrlKey?2:0)|(n.altKey?4:0)|(n.metaKey?8:0),x:Math.max(0,n.clientX-i.left)*a,y:Math.max(0,n.clientY-i.top)*a,screenWidth:r.cols*r.metrics.width*a,screenHeight:r.rows*r.metrics.height*a,cellWidth:r.metrics.width*a,cellHeight:r.metrics.height*a,anyButtonPressed:n.buttons!==0});if(o.length!==0){if(e===`motion`){if(o===this.lastMotion)return;this.lastMotion=o}else this.lastMotion=``;this.context.onData(o)}}linkAt(e,t){let n=this.context.view(),r=this.context.core,i=n.snapshot;if(!i)return null;let a=this.context.canvas.getBoundingClientRect(),o=e-a.left,s=t-a.top;if(o<0||s<0||o>=n.cols*n.metrics.width||s>=n.rows*n.metrics.height)return null;let c={x:Math.floor(o/n.metrics.width),y:Math.floor(s/n.metrics.height)},l=r.hyperlinkAt(c.x,c.y);if(l!==null){if(l.startsWith(`offsite-image:`))return null;let e=c.x,t=c.x;for(;e>0&&r.hyperlinkAt(e-1,c.y)===l;)--e;for(;t<n.cols-1&&r.hyperlinkAt(t+1,c.y)===l;)t+=1;return{uri:l,range:{start:{x:e,y:c.y},end:{x:t,y:c.y}}}}let u=c.y;for(;u>0&&i.rowData[u]?.isWrapContinuation;)--u;let d=c.y;for(;d<i.rows-1&&i.rowData[d]?.wrapsToNext;)d+=1;let f=``,p=[];for(let e=u;e<=d;e+=1){let t=i.rowData[e];if(!t)break;let n=F1(t,e);f+=n.text,p.push(...n.points)}for(let e of f.matchAll(B0)){let t=e[0].replace(/[.,;:!?)\]}'"]+$/,``),n=p[e.index],r=p[e.index+t.length-1];if(!n||!r)continue;let i={start:n,end:r};if(I0(i,c.y,c.x))return{uri:t,range:i}}return null}setHoveredLink(e){let t=this.hoveredLink;this.context.canvas.style.cursor=e?`pointer`:``,(t?.uri!==e?.uri||t?.range.start.x!==e?.range.start.x||t?.range.start.y!==e?.range.start.y)&&(this.hoveredLink=e,this.context.redraw())}beginSelection(e,t){let n=this.context.core,r=this.cellAt(e.clientX,e.clientY),i=n.toScreen(r);if(!i)return;this.selectionMoved=!1,this.selectionMode=t>=3?`line`:t===2?`word`:`cell`;let a=this.selectionMode===`line`?n.selectLine(i):this.selectionMode===`word`?n.selectWord(i):null;this.selectionAnchor=a?a.start:i,this.selectionBase=a,a?n.setSelection(a.start,a.end):(this.selectionMode=`cell`,n.setSelection(i,i)),this.context.redraw()}extendSelection(e,t){let n=this.context.core,r=this.selectionAnchor;if(!r)return;let i=this.cellAt(e,t),a=n.toScreen(i);if(!a)return;this.selectionMoved=!0;let o=this.selectionBase;if(o===null)n.setSelection(r,a);else{let e=this.selectionMode===`line`?n.selectLine(a):n.selectWord(a),t=a.y<o.start.y||a.y===o.start.y&&a.x<o.start.x;n.setSelection(t?o.end:o.start,e?t?e.start:e.end:a)}this.context.redraw()}setSelectionScroll(e){this.selectionScrollDelta=e,e===0?(this.selectionScroll!==null&&window.clearInterval(this.selectionScroll),this.selectionScroll=null):this.selectionScroll===null&&(this.selectionScroll=window.setInterval(()=>{this.context.scrollViewport(this.selectionScrollDelta);let e=this.selectionClient;e&&this.extendSelection(e.x,e.y)},80))}dragScrollbar(e){let t=this.context.core.scrollbarState(),n=this.scrollbarDrag;if(t===null||n===null)return;let r=this.context.scrollbar.getBoundingClientRect(),i=H0(t,r.height);if(i===null||i.travel===0)return;let a=Math.max(0,Math.min(e-r.top-n.offset,i.travel)),o=Math.round(a/i.travel*i.maxOffset);this.context.scrollViewport(o-t.offset)}onPointerDown=e=>{let t=this.context.canvas;if(this.context.focus(),e.pointerType===`touch`){this.touch={id:e.pointerId,y:e.clientY,moved:!1},t.setPointerCapture(e.pointerId);return}if(this.reportsMouse(e)){let n=V0(e.button);if(n===null)return;e.preventDefault(),this.mousePointer=e.pointerId,this.mouseButton=n,this.sendMouse(`press`,n,e),t.setPointerCapture(e.pointerId);return}if(e.button!==0)return;if(this.linkAt(e.clientX,e.clientY)&&(R0?e.metaKey:e.ctrlKey)){e.preventDefault(),this.linkPointer=e.pointerId;return}let n=e.timeStamp-this.clicks.time<=z0&&Math.hypot(e.clientX-this.clicks.x,e.clientY-this.clicks.y)<=4;this.clicks={count:n?this.clicks.count>=3?1:this.clicks.count+1:1,time:e.timeStamp,x:e.clientX,y:e.clientY},this.clickMove=!e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this.context.view().clickToMoveCursor&&this.clicks.count===1?this.cellAt(e.clientX,e.clientY):null,this.selectionPointer=e.pointerId,this.beginSelection(e,this.clicks.count),t.setPointerCapture(e.pointerId)};onPointerMove=e=>{let t=this.touch;if(t?.id===e.pointerId){let n=t.y-e.clientY;if(Math.abs(n)<1)return;t.y=e.clientY,t.moved=!0,this.scrollRows(n,e)}else if(this.mousePointer===e.pointerId||this.context.core.isMouseAnyEventTracking()&&this.reportsMouse(e)){let t=e.buttons,n=t&1?1:t&4?3:t&2?2:null;this.sendMouse(`motion`,n,e)}else if(this.selectionPointer===e.pointerId){let t=this.cellAt(e.clientX,e.clientY);this.clickMove!==null&&(t.x!==this.clickMove.x||t.y!==this.clickMove.y)&&(this.clickMove=null),this.selectionClient={x:e.clientX,y:e.clientY};let n=this.context.canvas.getBoundingClientRect();this.setSelectionScroll(e.clientY<n.top?-1:+(e.clientY>n.bottom)),this.extendSelection(e.clientX,e.clientY)}else this.setHoveredLink(this.linkAt(e.clientX,e.clientY))};onPointerUp=e=>{let t=this.context.canvas;if(t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),this.touch?.id===e.pointerId)this.touch=null;else if(this.linkPointer===e.pointerId){this.linkPointer=null;let t=this.linkAt(e.clientX,e.clientY);t&&e.type===`pointerup`&&this.context.onLink(t.uri,e)}else if(this.mousePointer===e.pointerId)this.sendMouse(`release`,this.mouseButton,e),this.mousePointer=null,this.mouseButton=null;else if(this.selectionPointer===e.pointerId){this.selectionPointer=null,this.setSelectionScroll(0),!this.selectionMoved&&this.selectionMode===`cell`&&(this.context.core.clearSelection(),this.selectionAnchor=null,this.context.redraw());let t=this.clickMove;this.clickMove=null,t!==null&&e.type===`pointerup`&&this.context.moveCursorTo(t)}};onPointerLeave=()=>{this.lastMotion=``,this.setHoveredLink(null)};onWheel=e=>{if(e.deltaY===0)return;e.preventDefault();let t=this.context.view(),n=e.deltaMode===1?e.deltaY*t.metrics.height:e.deltaMode===2?e.deltaY*t.rows*t.metrics.height:e.deltaY;this.scrollRows(n,e)};onMouseDown=e=>{e.button===0&&e.preventDefault(),this.context.focus()};onScrollbarDown=e=>{let t=this.context.core.scrollbarState();if(e.button!==0||t===null)return;let n=this.context.scrollbar,r=n.getBoundingClientRect(),i=H0(t,r.height);i!==null&&(e.preventDefault(),e.stopPropagation(),this.scrollbarDrag={id:e.pointerId,offset:e.target===this.context.thumb?e.clientY-r.top-i.thumbTop:i.thumbHeight/2},n.setPointerCapture(e.pointerId),this.dragScrollbar(e.clientY))};onScrollbarMove=e=>{this.scrollbarDrag?.id===e.pointerId&&(e.preventDefault(),this.dragScrollbar(e.clientY))};onScrollbarUp=e=>{if(this.scrollbarDrag?.id!==e.pointerId)return;this.scrollbarDrag=null;let t=this.context.scrollbar;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}},W0=[`\r`,`
|
|
114
114
|
`,``,``,``,``,`\x1B[99;5u`,`\x1B[100;5u`,`\x1B[111;5u`,`\x1B[122;5u`];function G0(e,t){return e.y<t.y||e.y===t.y&&e.x<t.x}var K0=class{shell=`unknown`;generation=0;core;native=!1;input=!1;clickEvents=!1;inputRef=null;constructor(e){this.core=e}mark(e,t){let n=e.startsWith(`133;`),r=n?4:5;if(e.length>r+1&&e[r+1]!==`;`)return;let i=e.charAt(r);if(!this.core.isAlternateScreen()){if(i===`A`){let r=e.split(`;`);if(r.includes(`k=s`)||r.includes(`k=c`))return;let i=n&&r.includes(`click_events=1`),a=this.shell===`prompt`,o=a&&!this.input&&this.native!==n;if(this.shell=`prompt`,this.native=n,t&&this.trackInput(),o){this.clickEvents=this.clickEvents||i;return}if(this.input=!1,this.clickEvents=i,a)return;this.generation+=1}else if(i===`B`)this.shell=`prompt`,this.input=!0,t&&this.trackInput();else if(i===`C`)this.shell=`command`;else if(i===`D`){if(this.shell===`prompt`&&!this.input)return;this.shell=`unknown`}}}beforeInput(e){this.shell===`prompt`&&W0.some(t=>e.includes(t))&&(this.shell=`unknown`)}reset(){this.release(),this.shell=`unknown`,this.input=!1,this.clickEvents=!1}release(){this.inputRef!==null&&this.core.untrack(this.inputRef),this.inputRef=null}moveCursorInput(e,t,n){if(this.shell!==`prompt`||this.inputRef===null||t===null||t.cursorX<0||t.cursorY<0||this.core.isAlternateScreen()||this.core.isMouseTracking())return null;let r=this.core.trackedPoint(this.inputRef);if(r===null)return null;let i={x:r.x,y:r.y-n};if(G0(e,i))return null;if(this.clickEvents){let t=this.core.scrollbarState();if(t===null)return null;let r=e.y+n-(t.total-t.len);return r<0?null:`\x1b[<0;${e.x+1};${r+1}M`}if(!this.input)return null;let a={x:e.x,y:e.y};a.x>0&&t.rowData[a.y]?.cells[a.x]?.wide===E1.spacerTail&&--a.x;let o={x:t.cursorX,y:t.cursorY};if(G0(a,i)||G0(o,i))return null;let s=G0(a,o),c=s?a:o,l=s?o:a,u=0;for(let e=c.y;e<=l.y;e+=1){let n=t.rowData[e];if(n===void 0)return null;let r=e===l.y?l.x:n.cells.length;for(let t=e===c.y?c.x:0;t<r;t+=1)n.cells[t].text!==``&&(u+=1);if(e<l.y&&!n.wrapsToNext){if(s)return null;break}}let d=s?`ArrowLeft`:`ArrowRight`,f=this.core.encoder.encodeKey(new KeyboardEvent(`keydown`,{key:d,code:d}));return u>0?f.repeat(u):``}trackInput(){this.inputRef===null?this.inputRef=this.core.trackCursor():this.core.retrack(this.inputRef)}},q0=navigator.userAgent.includes(`Mac`),J0=600,Y0=1e3,X0=1e4,Z0=new TextDecoder(`latin1`),Q0=new TextDecoder;function $0(e){let t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!t)throw Error(`unsupported color ${e}`);return{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}}function e2(e){return[...e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0).map(e=>/^(['"]).*\1$/.test(e)||/^[a-zA-Z][a-zA-Z0-9-]*$/.test(e)?e:`"${e.replaceAll(`"`,``)}"`),`monospace`].join(`, `)}async function t2(e){try{(await e)?.close()}catch(e){console.warn(`could not decode image`,e)}}var n2=class{element;cols=80;rows=24;canvas;input;context;core;scanner=new l0;handlers;observer;prompt;search;images;pointer;notifications=new r0;options;appearance;metrics;snapshot=null;sized=!1;fitted=!1;frame=0;forceFull=!0;renderFailed=!1;cursorOn=!0;cursorTimer=null;syncTimer=null;renderedCursorY=null;focused=!1;composing=!1;suppressedKeys=new Set;heldOptionKeys=new Set;backlog=[];blocked=!1;epoch=0;title=``;progress={state:0,value:0};disposed=!1;constructor(e,t){this.options=e,this.handlers=t,this.element=document.createElement(`div`),this.element.className=`relative h-full overflow-hidden`,this.canvas=document.createElement(`canvas`),this.canvas.className=`absolute top-0 left-0 cursor-text touch-none`,this.input=document.createElement(`textarea`),this.input.setAttribute(`aria-label`,`Terminal input`),this.input.autocapitalize=`off`,this.input.autocomplete=`off`,this.input.spellcheck=!1,this.input.style.cssText=`position:absolute;left:0;top:0;width:1px;height:1px;opacity:0;padding:0;border:0;resize:none;pointer-events:none;`;let n=document.createElement(`div`);n.className=`absolute top-0 right-0 bottom-0 w-2 cursor-default touch-none`,n.hidden=!0;let r=document.createElement(`div`);r.className=`bg-foreground/15 hover:bg-foreground/30 absolute inset-x-0.5 top-0 rounded-full`,n.append(r),this.element.append(this.canvas,this.input,n);let i=this.canvas.getContext(`2d`,{alpha:!1});if(!i)throw Error(`canvas 2d is unavailable`);this.context=i,this.appearance=this.appearanceFor(e),this.metrics=this.measure(),this.core=new U1(Math.max(1,Math.floor(window.innerWidth/this.metrics.width)),this.rows,e.scrollback,t.onReply,t.onBell),this.prompt=new K0(this.core),this.search=new G1(this.core,()=>this.redraw()),this.images=new w$(this.core),this.pointer=new U0({canvas:this.canvas,scrollbar:n,thumb:r,core:this.core,view:()=>({cols:this.cols,rows:this.rows,metrics:this.metrics,snapshot:this.snapshot,clickToMoveCursor:this.options.clickToMoveCursor}),focus:()=>this.focus(),redraw:()=>this.redraw(),scrollViewport:e=>this.scrollViewport(e),moveCursorTo:e=>this.moveCursorTo(e),onData:t.onData,onLink:t.onLink}),this.applyTerminalOptions(),this.resizeCore(),this.installEvents(),this.observer=new ResizeObserver(()=>this.fit()),this.observer.observe(this.element)}setOptions(e){this.options=e,this.appearance=this.appearanceFor(e),this.metrics=this.measure(),e.clickToMoveCursor||this.prompt.release(),this.applyTerminalOptions(),this.resizeCore(),this.forceFull=!0,this.fit(),this.requestRender()}write(e,t){this.disposed||(this.backlog.push({data:e,replay:t}),this.blocked||this.drain())}reset(){this.epoch+=1,this.backlog=[],this.blocked=!1,this.scanner.reset(),this.prompt.reset(),this.core.reset(),this.applyTerminalOptions(),this.images.clear(),this.core.clearSelection(),this.redraw()}focus(){this.input.focus({preventScroll:!0})}isKittyKeyboard(){return this.core.isKittyKeyboard()}paste(e){let t=this.core.encoder.encodePaste(e);t.length>0&&this.sendInput(t)}presize(e,t){this.fitted||e===this.cols&&t===this.rows||(this.cols=e,this.rows=t,this.resizeCore())}fit(){if(this.disposed)return;let e=this.element.clientWidth,t=this.element.clientHeight;if(e===0||t===0){this.sized=!1;return}this.sized=!0,this.fitted=!0;let n=window.devicePixelRatio||1,r=Math.round(e*n),i=Math.round(t*n);(this.canvas.width!==r||this.canvas.height!==i)&&(this.canvas.width=r,this.canvas.height=i,this.canvas.style.width=`${e}px`,this.canvas.style.height=`${t}px`,this.context.setTransform(n,0,0,n,0,0),this.metrics=this.measure(),this.resizeCore(),this.forceFull=!0);let a=Math.max(1,Math.floor(e/this.metrics.width)),o=Math.max(1,Math.floor(t/this.metrics.height));(a!==this.cols||o!==this.rows)&&(this.cols=a,this.rows=o,this.resizeCore(),this.forceFull=!0,this.handlers.onResize(a,o)),this.renderFrame()}find(e,t,n){let r=this.viewportTop(),i=this.search.find(e,t,n,r);i!==null&&(i.row<r||i.row>=r+this.rows)&&this.scrollViewport(i.row-r-Math.floor(this.rows/2)),this.redraw()}onFindResults(e){return this.search.onResults(e)}clearFind(){this.search.clear(),this.redraw()}replyClipboard(e,t){t.epoch!==this.epoch||t.generation!==this.prompt.generation||t.atPrompt&&this.prompt.shell!==`prompt`||this.handlers.onReply(Q1(e,t.selection,t.terminator))}beforeInput(e){this.prompt.beforeInput(e)}dispose(){this.disposed||(this.disposed=!0,this.observer.disconnect(),this.cancelRender(),this.pointer.dispose(),this.search.dispose(),window.removeEventListener(`focus`,this.onWindowFocus),document.removeEventListener(`visibilitychange`,this.onVisibilityChange),this.images.clear(),this.prompt.release(),this.core.dispose(),this.element.remove())}redraw(){this.forceFull=!0,this.requestRender()}resizeCore(){this.core.resize(this.cols,this.rows,this.metrics.width,this.metrics.height,window.devicePixelRatio||1)}appearanceFor(e){let t=e.colors;return{fontSize:e.fontSize,fontFamily:e2(e.fontFamily),ligatures:e.ligatures,cursorText:t.cursorText,selectionBackground:t.selectionBackground,selectionForeground:t.selectionForeground,matchBackground:t.palette[8],activeMatchBorder:t.palette[3]}}measure(){return P0(this.context,this.options.fontSize,this.appearance.fontFamily,this.options.lineHeight,window.devicePixelRatio||1)}applyTerminalOptions(){let e=this.options.colors;this.core.setColors({foreground:$0(e.foreground),background:$0(e.background),cursor:$0(e.cursor),palette:e.palette.map($0)}),this.core.setCursor(this.options.cursorStyle,this.options.cursorBlink),this.core.boldIsBright=this.options.boldIsBright,this.core.version=this.options.version,this.core.invalidate()}drain(){for(;!this.blocked&&this.backlog.length>0;){let e=this.backlog.shift();e&&this.process(e)}let e=this.core.title();e!==this.title&&(this.title=e,this.handlers.onTitle(e)),this.search.outputChanged(),this.cursorOn=!0,this.requestRender()}process(e){let t=e.data,n=e.replay;this.core.setReplies(!n);let r=0,i=this.scanner.scan(t,(e,i)=>(this.core.write(t.subarray(r,i)),r=i,this.handleOutput(e,n)));this.core.write(t.subarray(r,i)),i<t.length&&this.backlog.unshift({data:t.subarray(i),replay:n})}handleOutput(e,t){if(e.type===`sixel`)return this.decodeImage(b$(e.data));let n=Z0.decode(e.data);if(n.startsWith(`1337;File=`))return this.decodeImage(S$(n.slice(10),{cellWidth:this.metrics.width,cellHeight:this.metrics.height,width:this.cols*this.metrics.width,height:this.rows*this.metrics.height,pixelRatio:window.devicePixelRatio||1}));if(n.startsWith(`133;`)||n.startsWith(`6973;`))return this.prompt.mark(n,this.options.clickToMoveCursor),!1;if(n.startsWith(`52;`)){let r=n.split(`;`),i=r[2];if(t||i===void 0)return!1;if(i===`?`)return this.handlers.onClipboardRead({selection:X1(r[1]),terminator:e.terminator,generation:this.prompt.generation,epoch:this.epoch,atPrompt:this.prompt.shell===`prompt`}),!1;let a=Z1(i);return a!==null&&this.handlers.onClipboard(a),!1}if(n===`10;?`||n===`11;?`||n===`12;?`)return t||this.handlers.onReply($1(n,this.core.currentColors(),e.terminator)),!1;if(n.startsWith(`4;`)){if(!t)for(let t of e0(n,this.core.currentColors().palette,e.terminator))this.handlers.onReply(t);return!1}if(n===`9;4`||n.startsWith(`9;4;`)){let e=t0(n,this.progress);return e!==null&&(this.progress=e,this.handlers.onProgress(e)),!1}if(t)return!1;let r=n.startsWith(`99;`)?this.notifications.add(Q0.decode(e.data)):n0(n,e.data);return r!==null&&this.handlers.onNotify(r.title,r.body),!1}decodeImage(e){return this.blocked=!0,this.placeImage(e,this.epoch,window.devicePixelRatio||1),!0}async placeImage(e,t,n){let r=0,i=new Promise(e=>{r=window.setTimeout(()=>e(`timeout`),X0)});try{let r=await Promise.race([e,i]);r===`timeout`?(console.warn(`image decoding took too long, skipping the image`),t2(e)):r!==null&&(t===this.epoch&&!this.disposed?this.images.place(r,n,this.metrics.height):r.close())}catch(e){console.warn(`could not decode image`,e)}window.clearTimeout(r),!(t!==this.epoch||this.disposed)&&(this.blocked=!1,this.drain())}moveCursorTo(e){if(!this.options.clickToMoveCursor)return;let t=this.prompt.moveCursorInput(e,this.snapshot,this.viewportTop());t!==null&&(t!==``&&this.sendInput(t),this.core.clearSelection(),this.redraw())}sendInput(e){this.prompt.beforeInput(e),this.core.scrollbarState()?.offset!==this.maxOffset()&&(this.core.scrollToBottom(),this.redraw()),this.handlers.onData(e)}maxOffset(){let e=this.core.scrollbarState();return e?Math.max(0,e.total-e.len):0}viewportTop(){return this.core.toScreen({x:0,y:0})?.y??0}scrollViewport(e){let t=this.core.scrollbarState(),n=Math.trunc(e);if(t!==null){let e=Math.max(0,t.total-t.len);n=Math.max(0,Math.min(t.offset+n,e))-t.offset}n!==0&&(this.core.scroll(n),this.redraw())}requestRender(){!this.disposed&&this.sized&&this.frame===0&&(this.frame=window.requestAnimationFrame(()=>{this.frame=0,this.renderFrame()}))}cancelRender(){this.frame!==0&&window.cancelAnimationFrame(this.frame),this.frame=0,this.cursorTimer!==null&&window.clearTimeout(this.cursorTimer),this.cursorTimer=null,this.syncTimer!==null&&window.clearTimeout(this.syncTimer),this.syncTimer=null}renderFrame(){if(!this.disposed&&this.sized&&this.element.isConnected){this.frame!==0&&window.cancelAnimationFrame(this.frame),this.frame=0;try{this.draw(),this.renderFailed=!1}catch(e){this.renderFailed||console.error(`could not draw the terminal`,e),this.renderFailed=!0}}}draw(){if(this.core.isSynchronizedOutput()){this.syncTimer===null&&(this.syncTimer=window.setTimeout(()=>{this.syncTimer=null,this.core.endSynchronizedOutput(),this.requestRender()},Y0));return}this.syncTimer!==null&&window.clearTimeout(this.syncTimer),this.syncTimer=null;let e=this.core.snapshot();this.snapshot=e;let t=this.focused&&e.cursorBlinking&&e.cursorVisible;t||(this.cursorOn=!0);let n=this.viewportTop(),r=this.images.visible(n,this.rows,this.metrics.height),i=this.core.cellSize(),a=this.core.kitty.images(e.rowData,i);L0({context:this.context,snapshot:e,metrics:this.metrics,appearance:this.appearance,forceFull:this.forceFull||r.length>0||a.length>0,cursorOn:this.cursorOn,previousCursorY:this.renderedCursorY,focused:this.focused,hoveredLink:this.pointer.hoveredLink?.range??null,highlights:this.search.highlights(e,n),pixelRatio:window.devicePixelRatio||1,drawLayer:e=>p1(this.context,a,e,this.metrics,i)}),p1(this.context,a,`aboveText`,this.metrics,i);for(let e of r)this.context.drawImage(e.bitmap,e.x*this.metrics.width,e.y*this.metrics.height,e.width,e.height);this.forceFull=r.length>0||a.length>0,this.renderedCursorY=this.cursorOn&&e.cursorVisible&&e.cursorY>=0?e.cursorY:null,e.cursorX>=0&&e.cursorY>=0&&(this.input.style.left=`${e.cursorX*this.metrics.width}px`,this.input.style.top=`${e.cursorY*this.metrics.height}px`),this.pointer.updateScrollbar(this.element.clientHeight),this.cursorTimer!==null&&window.clearTimeout(this.cursorTimer),this.cursorTimer=null,t&&(this.cursorTimer=window.setTimeout(()=>{this.cursorTimer=null,this.cursorOn=!this.cursorOn,this.requestRender()},J0))}copySelection(){let e=this.core.selectionText();e.length!==0&&(window.isSecureContext?navigator.clipboard.writeText(e):console.warn(`copy from the terminal needs https or localhost`))}optionIsMeta(e){if(!q0||!e.altKey||e.metaKey)return!1;let t=this.options.optionAsMeta;if(t===`off`)return!1;if(t===`both`)return!0;if(t===`left`)return this.heldOptionKeys.has(`AltLeft`);if(t===`right`)return this.heldOptionKeys.has(`AltRight`);throw Error(`unknown option as meta mode ${t}`)}onKeyDown=e=>{if((e.code===`AltLeft`||e.code===`AltRight`)&&this.heldOptionKeys.add(e.code),!this.handlers.beforeKey(e)){this.suppressedKeys.add(e.code);return}let t=this.optionIsMeta(e),n=t&&this.core.encoder.metaText(e)!==null;if(e.isComposing||this.composing||!n&&(e.key===`Process`||e.keyCode===229)||q0&&this.options.optionAsMeta!==`off`&&!t&&e.altKey&&!e.ctrlKey&&!e.metaKey&&([...e.key].length===1||e.key===`Dead`)||!n&&e.getModifierState(`AltGraph`)&&[...e.key].length===1){this.suppressedKeys.add(e.code);return}let r=e.key.toLowerCase();if(q0?e.metaKey&&r===`c`:e.ctrlKey&&e.shiftKey&&r===`c`||e.ctrlKey&&!e.shiftKey&&r===`insert`){this.copySelection(),e.preventDefault(),this.suppressedKeys.add(e.code);return}if((q0?e.metaKey&&r===`v`:e.ctrlKey&&e.shiftKey&&r===`v`||e.shiftKey&&!e.ctrlKey&&r===`insert`)||q0&&e.metaKey&&r===`q`){this.suppressedKeys.add(e.code);return}let i=this.core.encoder.encodeKey(e,`press`,n);i.length!==0&&(this.suppressedKeys.delete(e.code),e.preventDefault(),e.stopPropagation(),this.core.selectionText().length>0&&!e.shiftKey&&(this.core.clearSelection(),this.forceFull=!0),this.sendInput(i))};onKeyUp=e=>{if(this.heldOptionKeys.delete(e.code),this.suppressedKeys.delete(e.code)||e.isComposing||this.composing)return;let t=this.core.encoder.encodeKey(e,`release`,this.optionIsMeta(e));t.length!==0&&(e.preventDefault(),this.handlers.onData(t))};onInput=e=>{let t=e;if(this.composing||t.isComposing)return;let n=this.input.value||t.data||``;this.input.value=``,n.length>0&&this.sendInput(n)};onCompositionStart=()=>{this.composing=!0};onCompositionEnd=e=>{this.composing=!1;let t=this.input.value||e.data;this.input.value=``,t.length>0&&this.sendInput(t)};onPaste=e=>{e.preventDefault();let t=e.clipboardData?.getData(`text/plain`)??``;t.length>0&&this.paste(t)};onCopy=e=>{let t=this.core.selectionText();t.length!==0&&e.clipboardData&&(e.preventDefault(),e.clipboardData.setData(`text/plain`,t))};onWindowFocus=()=>{q0&&this.options.optionAsMeta!==`off`&&this.core.encoder.refreshKeyboardLayout()};onContextRestored=()=>{let e=window.devicePixelRatio||1;this.context.setTransform(e,0,0,e,0,0),this.redraw()};onVisibilityChange=()=>{document.visibilityState===`visible`&&this.redraw()};onFocus=()=>{this.focused=!0,this.cursorOn=!0,this.requestRender(),!this.disposed&&this.core.isFocusReporting()&&this.handlers.onReply(`\x1B[I`)};onBlur=()=>{this.focused=!1,this.heldOptionKeys.clear(),this.cursorOn=!0,this.requestRender(),!this.disposed&&this.core.isFocusReporting()&&this.handlers.onReply(`\x1B[O`)};installEvents(){this.input.addEventListener(`keydown`,this.onKeyDown),this.input.addEventListener(`keyup`,this.onKeyUp),this.input.addEventListener(`input`,this.onInput),this.input.addEventListener(`compositionstart`,this.onCompositionStart),this.input.addEventListener(`compositionend`,this.onCompositionEnd),this.input.addEventListener(`paste`,this.onPaste),this.input.addEventListener(`copy`,this.onCopy),this.input.addEventListener(`focus`,this.onFocus),this.input.addEventListener(`blur`,this.onBlur),this.canvas.addEventListener(`contextrestored`,this.onContextRestored),window.addEventListener(`focus`,this.onWindowFocus),document.addEventListener(`visibilitychange`,this.onVisibilityChange)}};function r2(e){return e.key===`Enter`&&e.shiftKey&&!e.ctrlKey&&!e.altKey&&!e.metaKey}function i2(e){let t=new n2(v2(),{onData:t=>{x2().status===`active`&&j2(e,a2(t))},onReply:t=>{t===`\x1B[I`||t===`\x1B[O`?j2(e,t):M2(e,t)},onResize:(t,n)=>A2({type:`resize`,id:e,cols:t,rows:n}),onTitle:t=>S2({titles:{...x2().titles,[e]:t}}),onProgress:t=>S2({progress:{...x2().progress,[e]:t}}),onBell:()=>{let n=C2().behavior;n.bellSound&&i4(),n.bellFlash&&t.element.isConnected&&!document.hidden&&t.element.animate([{opacity:.4},{opacity:1}],{duration:200,easing:`ease-out`}),t4(e)},onNotify:(t,n)=>n4(e,t,n),onClipboard:WX,onClipboardRead:n=>{$2(e)&&GX(e=>t.replyClipboard(e,n))},onLink:e=>{e.startsWith(`file:`)?BC(e):window.open(e,`_blank`,`noopener`)},beforeKey:n=>{if(n.type!==`keydown`)return!0;let r=C2(),i=T9(Z(),y2()).system;if(i===null)throw Error(`the terminal machine is not connected`);let a=i.platform;if(x2().status===`active`&&r.behavior.modernizeShiftEnter&&r2(n)&&!t.isKittyKeyboard())return n.preventDefault(),t.beforeInput(`\x1B\r`),j2(e,`\x1B\r`),!1;if(x2().status===`active`&&r.behavior.pasteBrowserImages&&window.isSecureContext&&qX(n,a)){n.preventDefault();let r=KX[a].data;return t.beforeInput(r),JX(y2(),t).then(t=>{t||j2(e,r)}).catch(t=>{XX(t),j2(e,r)}),!1}return!B2(n)||(n.preventDefault(),S2({finding:e}),document.querySelector(`[data-find]`)?.select(),!1)}});return t.element.addEventListener(`paste`,e=>{if(!e.clipboardData||e.clipboardData.getData(`text/plain`)!==``)return;let n=[...e.clipboardData.files].filter(e=>e.type.startsWith(`image/`));n.length!==0&&(e.preventDefault(),e.stopPropagation(),YX(y2(),t,n).catch(XX))},!0),t}function a2(e){if(!x2().ctrl||(S2({ctrl:!1}),e.length!==1))return e;let t=e.toUpperCase().charCodeAt(0);return t>=64&&t<=95?String.fromCharCode(t-64):e}function o2(){return{titles:{},progress:{},alerts:[],finding:null,quiet:[]}}var s2=new TextEncoder,c2=new Map,l2=new Set,u2=new Set,d2={status:`connecting`,failure:null,loaded:!1,open:!1,instance:null,layout:{},ctrl:!1,...o2()},f2=null,p2=null,m2=!1;async function h2(){O2(),c9.history.subscribe(O2);try{await Promise.all([P$(),nR(C2())]),S2({loaded:!0})}catch(e){console.error(`could not start the terminal`,e),S2({failure:Oe(e)});return}So({close:e=>{e===p2&&S2({status:`connecting`})},terminal:(e,t)=>{e===p2&&(R2(t),u4())},frame:(e,t)=>{e===p2&&L2(t)}}),g2(),document.addEventListener(`visibilitychange`,()=>S2({})),window.addEventListener(`focus`,()=>{S2({}),f2!==null&&V2(f2,H2(f2))}),window.addEventListener(`blur`,()=>S2({})),`serviceWorker`in navigator&&navigator.serviceWorker.addEventListener(`message`,e=>{e.data.type===`select`&&k2(e.data.machine,e.data.project,e.data.tabId)});let e=Z().prefs,t=_2();nue(()=>{g2();let n=Z().prefs,r=_2(),i=n.theme!==e.theme||n.terminal!==e.terminal||r!==t;e=n,t=r,i&&W2()}),G2()}function g2(){let e=Z().selection?.machine??null;if(e!==p2&&(p2!==null&&m2&&A2({type:`detach`}),z2({}),l2.clear(),p2=e,m2=!1,S2({status:`connecting`,instance:null,layout:{},...o2()})),p2===null)return;let t=T9(Z(),p2).status===`online`;t&&!m2&&(m2=!0,A2({type:`attach`})),t||(m2=!1)}function _2(){return p2===null?null:T9(Z(),p2).config?.terminal.behavior.terminalIdentity??null}function v2(){if(p2===null)throw Error(`the terminal has no machine`);let e=T9(Z(),p2);if(e.config===null||e.system===null)throw Error(`${e.name} is not connected`);return Lae(C2(),e.config.terminal.behavior.terminalIdentity)}function y2(){if(p2===null)throw Error(`the terminal has no machine`);return p2}function b2(e){return u2.add(e),()=>{u2.delete(e)}}function x2(){return d2}function S2(e){d2={...d2,...e},d2={...d2,...a4(e=>c2.has(e))},o4();for(let e of u2)e()}function C2(){return Z().prefs.terminal}function w2(){let e=Z().selection?.projectId;return e===void 0?null:{projectId:e,project:d2.layout[e]??null}}function T2(e){for(let[t,n]of Object.entries(d2.layout))if(n.tabs.some(t=>t.id===e))return{projectId:t,project:n};return null}function E2(e){return(e.customName??d2.titles[e.id])||`Terminal`}function D2(e){e?RC({bottom:`terminal`}):VC(`overlay`,()=>RC({bottom:void 0}))}function O2(){let e=IC().bottom===`terminal`;e!==d2.open&&S2({open:e})}function k2(e,t,n){let r=Z().selection;(r?.machine!==e||r.projectId!==t)&&WC({machine:e,projectId:t,sessionId:null}),D2(!0),A2({type:`select`,projectId:t,tabId:n})}function A2(e){p2!==null&&Co(p2)&&L(p2,`terminal`,e).catch(e=>console.error(`terminal request failed`,e))}function j2(e,t){p2!==null&&To(p2,0,e,typeof t==`string`?s2.encode(t):t)}function M2(e,t){p2!==null&&To(p2,1,e,s2.encode(t))}function N2(e,t,n,r){H2(e).find(t,n,r)}function P2(e,t){return H2(e).onFindResults(t)}function F2(e){let t=H2(e);t.clearFind(),S2({finding:null}),t.focus()}function I2(){S2({ctrl:!d2.ctrl})}function L2(e){let t=c2.get(e.id);if(!t)return;let n=e.kind===3,r=n&&l2.delete(e.id);r&&t.reset(),t.write(e.data,n),r&&l2.size===0&&S2({status:`active`}),n||f4(e.id),u4()}function R2(e){let t=e.type===`active`&&e.instance!==d2.instance;if(t&&z2({}),z2(e.layout),e.type===`active`){l2.clear(),c2.forEach((e,t)=>{l2.add(t),e.element.isConnected&&V2(t,e)}),S2({...t&&{instance:e.instance,...o2()},status:l2.size===0?`active`:`connecting`,layout:e.layout});return}for(let e of l2)c2.has(e)||l2.delete(e);let n=Z().selection?.projectId,r=n!==void 0&&(d2.layout[n]?.tabs.length??0)>0&&e.layout[n]?.tabs.length===0;S2({status:l2.size===0?`active`:`connecting`,layout:e.layout}),r&&d2.open&&D2(!1)}function z2(e){let t=new Set(Object.values(e).flatMap(e=>e.tabs.map(e=>e.id)));c2.forEach((e,n)=>{t.has(n)||(e.dispose(),c2.delete(n),p4(n))});for(let e of t)c2.has(e)||c2.set(e,i2(e))}function B2(e){return e.key.toLowerCase()===`f`?Ee?e.metaKey&&!e.ctrlKey&&!e.altKey:e.ctrlKey&&e.shiftKey&&!e.altKey&&!e.metaKey:!1}function V2(e,t){A2({type:`resize`,id:e,cols:t.cols,rows:t.rows})}function H2(e){let t=c2.get(e);if(!t)throw Error(`terminal ${e} does not exist`);return t}function U2(e,t){let n=H2(e);t.append(n.element),n.fit();for(let e of c2.values())e.presize(n.cols,n.rows);return f2=e,V2(e,n),n.focus(),()=>{n.element.remove(),f2===e&&(f2=null)}}async function W2(){if(await nR(C2()),c2.size>0){let e=v2();for(let t of c2.values())t.setOptions(e)}S2({})}function G2(){let e=IC(),t=e.machine,n=e.project,r=e.terminal;if(t===void 0||n===void 0||r===void 0)return;RC({terminal:void 0});let i=b2(()=>{d2.status===`active`&&p2===t&&(i(),k2(t,n,Number(r)))})}var K2=new Map,q2=new Map,J2=new Map,Y2=new Set,X2=null,Z2=0,Q2=!1;function $2(e){return x2().open&&w2()?.project?.activeTab===e&&!document.hidden&&document.hasFocus()}function e4(e){if($2(e))return!1;let t=x2();return t.alerts.includes(e)||S2({alerts:[...t.alerts,e]}),!0}function t4(e){if(!e4(e)||q2.has(e))return;let t=K2.get(e);t!==void 0&&performance.now()-t<5e3||q2.set(e,window.setTimeout(()=>{q2.delete(e),!$2(e)&&(K2.set(e,performance.now()),r4(e,``,`Bell`))},500))}function n4(e,t,n){e4(e)&&(window.clearTimeout(q2.get(e)),q2.delete(e),K2.set(e,performance.now()),r4(e,t,n))}function r4(e,t,n){let r=T2(e),i=r?.project.tabs.find(t=>t.id===e);r&&i&&fX(t||E2(i),n,{machine:y2(),project:r.projectId,tabId:e}).catch(e=>console.error(`could not show a notification`,e))}function i4(){let e=performance.now();if(e-Z2<150)return;Z2=e,X2??=new AudioContext,X2.state===`suspended`&&X2.resume();let t=X2.createOscillator(),n=X2.createGain(),r=X2.currentTime;t.frequency.value=880,n.gain.setValueAtTime(.1,r),n.gain.exponentialRampToValueAtTime(.001,r+.15),t.connect(n).connect(X2.destination),t.start(r),t.stop(r+.15)}function a4(e){let t=x2();return{alerts:t.alerts.filter(t=>e(t)&&!$2(t)),quiet:t.quiet.filter(e)}}function o4(){let e=x2().status===`active`;if(e&&!Q2)for(let e of J2.keys())s4(e);Q2=e}function s4(e){window.clearTimeout(J2.get(e)),Y2.delete(e);let t=Date.now();J2.set(e,window.setTimeout(()=>{x2().status===`active`&&(Date.now()-t>15e3?s4(e):(Y2.add(e),c4()))},1e4))}async function c4(){await Eo(y2())&&u4()}function l4(e){J2.delete(e),Y2.delete(e),e4(e)&&r4(e,``,`No output for 10 seconds`)}function u4(){if(x2().status===`active`)for(let e of Y2)l4(e)}function d4(e){let t=x2();t.quiet.includes(e)?(window.clearTimeout(J2.get(e)),J2.delete(e),Y2.delete(e),S2({quiet:t.quiet.filter(t=>t!==e)})):S2({quiet:[...t.quiet,e]})}function f4(e){x2().quiet.includes(e)&&s4(e)}function p4(e){window.clearTimeout(q2.get(e)),q2.delete(e),K2.delete(e),window.clearTimeout(J2.get(e)),J2.delete(e),Y2.delete(e)}var m4=null,h4=new Set,g4=new Set;function _4(e){return g4.add(e),()=>{g4.delete(e)}}function v4(){return m4}function y4(){m4!==null&&b4({open:!1,closing:m4.closing})}function b4(e){m4=e;for(let e of g4)e()}function x4(){return document.querySelector(`[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)!==null}function S4(e){return T2(e)?.project.tabs.find(t=>t.id===e)}async function C4(e){try{let t=await Promise.race([L(y2(),`terminal.busy`,{id:e}),new Promise((e,t)=>window.setTimeout(()=>t(Error(`timed out`)),5e3))]);return`error`in t?(console.error(`could not check whether tab ${e} is running a program`,t.error),{checked:!1}):{checked:!0,program:t.program}}catch(e){return console.error(`could not check whether a program is running`,e),{checked:!1}}}async function w4(e){if(!C2().behavior.confirmCloseBusyTab){A2({type:`closeTab`,id:e});return}if(!S4(e)||h4.has(e))return;h4.add(e);let t=await C4(e);if(h4.delete(e),t.checked&&t.program===null){A2({type:`closeTab`,id:e});return}let n=S4(e);n&&!x4()&&b4({open:!0,closing:{id:e,name:E2(n),program:t.checked?t.program:null}})}var T4=Ee?`meta+t`:`ctrl+shift+t`,E4=Ee?`meta+w`:`ctrl+shift+w`,D4=`ctrl+tab`,O4=`ctrl+shift+tab`;function k4(){let e=w2()?.project;x2().open&&e&&e.activeTab!==null&&H2(e.activeTab).focus()}function A4(){return Tv([T4,E4,D4,O4],(e,t)=>{e.preventDefault(),e.stopPropagation();let n=w2();if(n===null)return;if(t.hotkey===T4){A2({type:`createTab`,projectId:n.projectId});return}let r=n.project;if(r===null||r.activeTab===null)return;if(t.hotkey===E4){w4(r.activeTab);return}let i;if(t.hotkey===D4)i=1;else if(t.hotkey===O4)i=-1;else throw Error(`unknown terminal shortcut ${t.hotkey}`);let a=r.tabs.filter(e=>!e.minimized),o=a[(a.findIndex(e=>e.id===r.activeTab)+i+a.length)%a.length];o&&A2({type:`select`,projectId:n.projectId,tabId:o.id})},{enabled:()=>C2().behavior.captureShortcuts,enableOnFormTags:!0,eventListenerOptions:{capture:!0}})}function j4(e){let[t,n]=(0,F.useState)(e.name);return(0,I.jsx)(_e,{open:!0,onOpenChange:t=>{t||e.onDone()},children:(0,I.jsx)(ae,{onCloseAutoFocus:N4,children:(0,I.jsxs)(`form`,{className:`grid gap-4`,onSubmit:n=>{n.preventDefault(),A2({type:`renameTab`,id:e.id,name:t.trim()}),e.onDone()},children:[(0,I.jsx)(se,{children:(0,I.jsx)(pe,{children:`Rename tab`})}),(0,I.jsx)(wL,{"aria-label":`Name`,placeholder:`Use terminal title`,value:t,onChange:e=>n(e.target.value)}),(0,I.jsxs)(ve,{children:[(0,I.jsx)(x,{type:`button`,variant:`outline`,onClick:e.onDone,children:`Cancel`}),(0,I.jsx)(x,{type:`submit`,children:`Rename`})]})]})})})}function M4(){let e=(0,F.useSyncExternalStore)(_4,v4),t=(0,F.useRef)(null);if(e===null)return null;let n=e.closing;return(0,I.jsx)(LL,{open:e.open,onOpenChange:e=>{e||y4()},children:(0,I.jsxs)(zL,{onOpenAutoFocus:e=>{e.preventDefault(),t.current?.focus()},onCloseAutoFocus:N4,children:[(0,I.jsxs)(BL,{children:[(0,I.jsxs)(HL,{children:[`Close “`,n.name,`”?`]}),(0,I.jsx)(UL,{children:n.program===null?`OffSite couldn’t check whether a program is still running.`:`${n.program} is still running.`})]}),(0,I.jsxs)(VL,{children:[(0,I.jsx)(GL,{children:`Cancel`}),(0,I.jsx)(WL,{ref:t,variant:`destructive`,onClick:()=>A2({type:`closeTab`,id:n.id}),children:`Close`})]})]})})}function N4(e){e.preventDefault();let t=document.querySelector(`[role="dialog"], [role="alertdialog"]`);t===null?k4():t.focus()}function P4(e){let t=(0,F.useRef)(null),[n,r]=(0,F.useState)(``),[i,a]=(0,F.useState)({resultIndex:-1,resultCount:0});(0,F.useEffect)(()=>P2(e.id,a),[e.id]),(0,F.useEffect)(()=>t.current?.focus(),[]);function o(t,n,i){r(t),N2(e.id,t,n,i)}return(0,I.jsxs)(`div`,{className:`bg-card absolute top-2 right-4 z-10 flex items-center gap-1 rounded-lg border p-1 shadow-lg`,children:[(0,I.jsx)(wL,{ref:t,"data-find":!0,className:`h-7 w-52`,placeholder:`Find`,value:n,onChange:e=>o(e.target.value,!1,!0),onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),F2(e.id)):t.key===`Enter`?(t.preventDefault(),o(n,t.shiftKey,!1)):B2(t.nativeEvent)&&(t.preventDefault(),t.currentTarget.select())}}),(0,I.jsx)(`span`,{className:`text-muted-foreground w-16 text-center text-xs tabular-nums`,children:n===``?``:i.resultCount===0?`No results`:`${i.resultIndex+1} of ${i.resultCount}`}),(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Previous match`,onClick:()=>o(n,!0,!1),children:(0,I.jsx)(w,{icon:Lg})}),(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Next match`,onClick:()=>o(n,!1,!1),children:(0,I.jsx)(w,{icon:Mg})}),(0,I.jsx)(x,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close find`,onClick:()=>F2(e.id),children:(0,I.jsx)(w,{icon:Wg})})]})}var F4=[{label:`Esc`,sequence:`\x1B`},{label:`Tab`,sequence:` `},{label:`↑`,sequence:`\x1B[A`},{label:`↓`,sequence:`\x1B[B`},{label:`←`,sequence:`\x1B[D`},{label:`→`,sequence:`\x1B[C`}];function I4(e){let t=(0,F.useSyncExternalStore)(b2,x2),[n,r]=(0,F.useState)(null),i=t.status===`active`,a=t.layout[e.projectId],o=a?.activeTab??null,s=a?.tabs.filter(e=>!e.minimized)??[],c=a?.tabs.filter(e=>e.minimized)??[],l=A4();return(0,F.useEffect)(()=>{i&&A2({type:`select`,projectId:e.projectId,tabId:null})},[e.projectId,i]),t.loaded?(0,I.jsxs)(`div`,{ref:l,className:`flex h-full flex-col text-sm`,children:[(0,I.jsxs)(`header`,{className:P(`flex h-9 flex-none select-none`,s.length===1?`bg-background`:`bg-sidebar`),children:[c.length>0&&(0,I.jsx)(z4,{projectId:e.projectId,tabs:c,alerts:t.alerts,bordered:s.length>1}),(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1 [scrollbar-width:none] overflow-x-auto`,children:s.map(n=>(0,I.jsx)(R4,{tabId:n.id,onMinimize:s.length>1?()=>A2({type:`minimizeTab`,id:n.id}):void 0,onRename:()=>r({id:n.id,name:n.customName??``}),children:(0,I.jsxs)(`div`,{className:P(`group/tab text-muted-foreground hover:text-foreground relative flex min-w-28 flex-1 items-center justify-center border-r border-b px-7 text-xs transition-colors last:border-r-0`,n.id===o&&`bg-background text-foreground border-b-transparent`),onMouseDown:e=>e.preventDefault(),onClick:()=>A2({type:`select`,projectId:e.projectId,tabId:n.id}),children:[(0,I.jsx)(`span`,{className:`truncate`,children:E2(n)}),(0,I.jsx)(B4,{id:n.id,className:`ml-1.5 size-1.5 flex-none rounded-full`}),(0,I.jsx)(H4,{progress:t.progress[n.id]}),(0,I.jsx)(`button`,{className:P(`text-muted-foreground hover:bg-accent hover:text-foreground absolute left-1.5 grid size-4.5 place-items-center rounded opacity-0 transition-opacity group-hover/tab:opacity-100`,n.id===o&&`pointer-coarse:opacity-100`),"aria-label":`Close tab`,onClick:e=>{e.stopPropagation(),w4(n.id)},children:(0,I.jsx)(w,{icon:Wg,className:`size-3`})})]})},n.id))}),(0,I.jsx)(`button`,{className:P(`text-muted-foreground hover:text-foreground grid w-8 flex-none place-items-center transition-colors`,s.length>1&&`border-b border-l`),"aria-label":`New tab`,title:`New tab`,onClick:()=>A2({type:`createTab`,projectId:e.projectId}),children:(0,I.jsx)(w,{icon:Og,className:`size-4`})})]}),(0,I.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[o!==null&&(0,I.jsx)(L4,{id:o},`${t.instance}-${o}`),o!==null&&t.finding===o&&(0,I.jsx)(P4,{id:o},o),!i&&(0,I.jsx)(`div`,{className:`bg-background/80 animate-in fade-in absolute inset-0 z-20 grid place-items-center p-6 text-center backdrop-blur-md duration-200`,children:(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`border-foreground/15 border-t-foreground/70 size-6 animate-spin rounded-full border-[3px]`}),(0,I.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Connecting. Your terminals keep running while you wait.`})]})})]}),o!==null&&(0,I.jsxs)(`div`,{className:`bg-card hidden flex-none gap-1.5 overflow-x-auto border-t p-1.5 pointer-coarse:flex`,children:[F4.map(e=>(0,I.jsx)(x,{variant:`secondary`,className:`min-w-11`,onPointerDown:e=>e.preventDefault(),onClick:()=>j2(o,e.sequence),children:e.label},e.label)),(0,I.jsx)(x,{variant:t.ctrl?`default`:`secondary`,className:`min-w-11`,onPointerDown:e=>e.preventDefault(),onClick:I2,children:`Ctrl`})]}),n!==null&&(0,I.jsx)(j4,{id:n.id,name:n.name,onDone:()=>r(null)},n.id),(0,I.jsx)(M4,{})]}):(0,I.jsx)(`div`,{className:`text-muted-foreground grid h-full place-items-center p-4 text-xs whitespace-pre-wrap`,children:t.failure===null?`Starting the terminal…`:`The terminal could not start: ${t.failure}`})}function L4(e){let t=(0,F.useRef)(null);return(0,F.useEffect)(()=>{if(!t.current)throw Error(`terminal container missing`);return U2(e.id,t.current)},[e.id]),(0,I.jsx)(`div`,{className:`bg-background absolute inset-0 pt-(--pad-top) pr-(--pad-right) pb-(--pad-bottom) pl-(--pad-left)`,ref:t})}function R4(e){return(0,I.jsxs)(hZ,{children:[(0,I.jsx)(gZ,{asChild:!0,children:e.children}),(0,I.jsxs)(_Z,{children:[(0,I.jsxs)(vZ,{onSelect:e.onRename,children:[(0,I.jsx)(w,{icon:j_}),`Rename`]}),e.onMinimize&&(0,I.jsxs)(vZ,{onSelect:e.onMinimize,children:[(0,I.jsx)(w,{icon:O}),`Minimize`]}),(0,I.jsxs)(yZ,{checked:x2().quiet.includes(e.tabId),onCheckedChange:()=>d4(e.tabId),children:[(0,I.jsx)(w,{icon:Tee}),`Notify when quiet for 10s`]}),(0,I.jsxs)(vZ,{variant:`destructive`,onSelect:()=>void w4(e.tabId),children:[(0,I.jsx)(w,{icon:d_}),`Close tab`]})]})]})}function z4(e){return(0,I.jsxs)(yC,{children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsxs)(`button`,{className:P(`text-muted-foreground hover:text-foreground flex flex-none items-center gap-1 px-2.5 transition-colors`,e.bordered&&`border-r border-b`),"aria-label":`Minimized tabs`,title:`Minimized tabs`,children:[(0,I.jsx)(w,{icon:pee,className:`size-4`}),(0,I.jsx)(V4,{count:e.tabs.length,alert:e.tabs.some(t=>e.alerts.includes(t.id))})]})}),(0,I.jsx)(SC,{align:`start`,children:e.tabs.map(t=>(0,I.jsxs)(CC,{onSelect:()=>A2({type:`select`,projectId:e.projectId,tabId:t.id}),children:[(0,I.jsx)(`span`,{className:`max-w-80 truncate`,children:E2(t)}),(0,I.jsx)(B4,{id:t.id,className:`size-1.5 flex-none rounded-full`})]},t.id))})]})}function B4(e){return x2().alerts.includes(e.id)?(0,I.jsx)(`span`,{className:P(`bg-primary`,e.className)}):null}function V4(e){return(0,I.jsx)(`span`,{className:P(`grid h-3.5 min-w-3.5 place-items-center rounded-full px-1 text-[9px] leading-none font-medium tabular-nums`,e.alert?`bg-primary text-primary-foreground`:`text-foreground bg-[color-mix(in_srgb,var(--text)_22%,var(--bg))]`),children:e.count})}function H4(e){let t=e.progress;return!t||t.state===0?null:t.state===3?(0,I.jsx)(`span`,{className:`bg-primary absolute inset-x-0 bottom-0 h-0.5 animate-pulse`}):(0,I.jsx)(`span`,{className:P(`absolute bottom-0 left-0 h-0.5 transition-[width]`,t.state===1&&`bg-primary`,t.state===2&&`bg-destructive`,t.state===4&&`bg-yellow-500`),style:{width:`${t.state!==1&&t.value===0?100:t.value}%`}})}var U4={running:`Running`,completed:`Done`,failed:`Failed`,stopped:`Stopped`};function W4(e,t){return{agents:e.flatMap(e=>e.kind===`subagent`?[{item:e,agentId:e.agentId,status:K4(e.status,e.agentId,t)}]:[]),tasks:e.flatMap(e=>e.kind===`command`&&e.background!==null?[{item:e,taskId:e.background.taskId,path:e.background.outputPath,events:e.background.events,status:K4(e.status,e.background.taskId,t)}]:[])}}function G4(e){return e.description===``?e.command:e.description}function K4(e,t,n){let r=t===null?void 0:n?.tasks[t];return r===void 0?e===`running`?t===null&&n?.running===!0?`Running`:`Stopped`:U4[e]:U4[r]}function q4(e){return(0,I.jsx)(`span`,{className:P(e.active&&`text-shimmer`),children:e.text})}function J4(e){return(0,I.jsxs)(`span`,{className:P(`flex min-w-0 items-baseline overflow-hidden text-[13px] leading-4 tracking-[-0.04px]`,e.grouped?`gap-1.5`:`gap-2`),children:[(0,I.jsx)(`span`,{className:P(`text-foreground shrink-0`,e.grouped?`font-normal`:`font-medium`),children:(0,I.jsx)(q4,{text:e.title,active:e.pending})}),e.subtitle!==void 0&&e.subtitle!==``&&(0,I.jsx)(`span`,{className:P(`min-w-0 truncate tabular-nums`,e.grouped?`text-muted-foreground/70`:`text-muted-foreground`),children:e.subtitle}),e.args?.map(t=>(0,I.jsx)(`span`,{className:P(`min-w-0 truncate tabular-nums`,e.grouped?`text-muted-foreground/70`:`text-muted-foreground`),children:t},t))]})}function Y4(e){return(0,I.jsx)(`span`,{"aria-hidden":!0,className:P(`text-muted-foreground/70 flex size-6 shrink-0 items-center justify-center transition-opacity`,e.open?`opacity-100`:`opacity-0 group-hover/tool:opacity-100`,e.className),children:(0,I.jsx)(w,{icon:Mg,strokeWidth:2.5,className:P(`size-3.5 transition-transform`,!e.open&&`-rotate-90`)})})}function X4(e){let t=e.onToggle,n=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`flex max-w-[calc(100%-24px)] min-w-0 items-center`,children:(0,I.jsx)(J4,{title:e.title,subtitle:e.subtitle,args:e.args,pending:e.pending,grouped:e.grouped})}),t!==null&&(0,I.jsx)(Y4,{open:e.open})]});return(0,I.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col`,children:[t===null?(0,I.jsx)(`div`,{className:P(`flex w-full items-center select-none`,e.grouped?`min-h-7`:`min-h-9`),children:n}):(0,I.jsx)(`button`,{type:`button`,"aria-expanded":e.open,onClick:t,className:P(`group/tool focus-visible:ring-ring/70 flex w-full cursor-pointer items-center rounded-md text-left select-none focus-visible:ring-2 focus-visible:outline-none`,e.grouped?`h-7`:`h-9`),children:n}),e.open&&e.children!==void 0&&(0,I.jsx)(`div`,{className:P(`min-w-0 pt-1`,e.rail!==!1&&`ps-3`),children:e.children})]})}var Z4=new Map([[`build`,`text-blue-400`],[`explore`,`text-yellow-400`],[`plan`,`text-pink-400`],[`review`,`text-green-400`],[`writer`,`text-purple-400`]]),Q4=new Map([[`Running`,`Launched agent`],[`Done`,`Agent finished`],[`Failed`,`Agent failed`],[`Stopped`,`Agent stopped`]]),$4=new Map([[`Running`,`Started in background`],[`Done`,`Background task finished`],[`Failed`,`Background task failed`],[`Stopped`,`Background task stopped`]]),e3=[`text-sky-400`,`text-amber-400`,`text-fuchsia-400`,`text-emerald-400`,`text-violet-400`,`text-cyan-400`,`text-orange-400`,`text-teal-400`,`text-rose-400`,`text-indigo-400`,`text-lime-400`,`text-red-400`];function t3(e){let t=e.agent,n=t.toLowerCase(),r=0;for(let e of n)r=r*31+e.charCodeAt(0)>>>0;return{name:t[0].toUpperCase()+t.slice(1),description:e.description,tone:Z4.get(n)??e3[r%e3.length]}}function n3(e){return(0,I.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,className:P(`size-4 shrink-0`,e.className),children:[(0,I.jsx)(`path`,{d:`M4 4.5C4 4.22386 4.22386 4 4.5 4H11.5C11.7761 4 12 4.22386 12 4.5V11.5C12 11.7761 11.7761 12 11.5 12H4.5C4.22386 12 4 11.7761 4 11.5V4.5Z`,fill:`currentColor`}),(0,I.jsx)(`path`,{d:`M14.5 1C14.7761 1 15 1.22386 15 1.5V14.5C15 14.7761 14.7761 15 14.5 15H1.5C1.22386 15 1 14.7761 1 14.5V1.5C1 1.22386 1.22386 1 1.5 1H14.5ZM2 14H14V2H2V14Z`,fill:`currentColor`})]})}function r3(e){return(0,I.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":!0,className:P(`size-4 shrink-0`,e.className),children:Array.from({length:25},(e,t)=>(0,I.jsx)(`rect`,{x:1+t%5*3,y:1+Math.floor(t/5)*3,width:2,height:2,fill:`currentColor`,className:`agent-dot`,style:{animationDelay:`${(t%5+Math.floor(t/5))*90}ms`}},t))})}function i3(e){let t=e.item;if(t.kind===`agent_message`){let n=t.target;return(0,I.jsx)(a3,{label:`Messaged agent`,detail:t.summary,pending:e.sending,onOpen:n===null?null:()=>e.onOpen(n)})}if(t.kind===`command`){let n=e.tasks.find(e=>e.item.id===t.id);if(n===void 0)throw Error(`Task ${t.id} is missing from the thread`);return(0,I.jsx)(a3,{label:$4.get(n.status)??`Background task ${n.status.toLowerCase()}`,detail:G4(n.item),pending:n.status===`Running`,onOpen:()=>e.onOpen(t.id)})}let n=e.agents.find(e=>e.item.id===t.id);if(n===void 0)throw Error(`Agent ${t.id} is missing from the thread`);return(0,I.jsx)(a3,{label:Q4.get(n.status)??`Agent ${n.status.toLowerCase()}`,detail:t.description,pending:n.status===`Running`,onOpen:()=>e.onOpen(t.id)})}function a3(e){let t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:(0,I.jsx)(q4,{text:e.detail===``?e.label:`${e.label}:`,active:e.pending})}),e.detail!==``&&(0,I.jsx)(`span`,{className:`text-foreground min-w-0 truncate`,children:e.detail})]});return e.onOpen===null?(0,I.jsx)(`div`,{className:`flex min-h-7 min-w-0 items-center gap-1 text-[13px] leading-4 tracking-[-0.04px] select-none`,children:t}):(0,I.jsxs)(`button`,{type:`button`,title:`Open in Tasks panel`,onClick:e.onOpen,className:`group/agent focus-visible:ring-ring/70 flex min-h-7 w-fit max-w-full cursor-pointer items-center gap-1 rounded-md text-left text-[13px] leading-4 tracking-[-0.04px] select-none focus-visible:ring-2 focus-visible:outline-none`,children:[t,(0,I.jsx)(`span`,{className:`text-muted-foreground/70 flex shrink-0 opacity-0 transition-opacity group-hover/agent:opacity-100 group-focus-visible/agent:opacity-100 pointer-coarse:opacity-100`,children:(0,I.jsx)(w,{icon:Fg,className:`size-3.5`})})]})}function o3(e){let t={name:``,path:``,stat:{added:0,removed:0},directories:new Map,files:[]};for(let[n,r]of e){let e=n.replaceAll(`\\`,`/`).split(`/`).filter(e=>e!==``),i=e.at(-1);if(i===void 0)continue;let a=[t],o=t;for(let t of e.slice(0,-1)){let e=o.directories.get(t)??{name:t,path:o.path===``?t:`${o.path}/${t}`,stat:{added:0,removed:0},directories:new Map,files:[]};o.directories.set(t,e),o=e,a.push(o)}o.files.push({kind:`file`,name:i,path:e.join(`/`),stat:r});for(let e of a)e.stat.added+=r.added,e.stat.removed+=r.removed}return c3(t)}function s3(e,t){return e.name.localeCompare(t.name,void 0,{numeric:!0,sensitivity:`base`})}function c3(e){return[...[...e.directories.values()].sort(s3).map(e=>l3({kind:`directory`,name:e.name,path:e.path,stat:{...e.stat},children:c3(e)})),...[...e.files].sort(s3)]}function l3(e){let t=e;for(;t.children.length===1&&t.children[0].kind===`directory`;){let e=t.children[0];t={kind:`directory`,name:`${t.name}/${e.name}`,path:e.path,stat:e.stat,children:e.children}}return t}function u3(e){let[t,n]=(0,F.useState)(!1),r=[...e.files],i=Wo(r,e=>e[1].added),a=Wo(r,e=>e[1].removed),o=r.some(([e])=>/[/\\]/.test(e)),s=t?`Collapse all folders`:`Expand all folders`;return(0,I.jsxs)(`div`,{className:`bg-secondary dark:bg-input/20 @container/changed-files mt-4 rounded-lg`,children:[(0,I.jsxs)(`div`,{className:`bg-secondary dark:bg-background dark:from-input/20 dark:to-input/20 sticky top-2 z-10 flex items-center justify-between gap-2 rounded-t-lg px-3 py-2 dark:bg-linear-to-b`,children:[(0,I.jsxs)(`div`,{className:`text-foreground flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs font-medium`,children:[(0,I.jsxs)(`span`,{children:[r.length,` changed file`,r.length===1?``:`s`]}),(i>0||a>0)&&(0,I.jsx)(f3,{added:i,removed:a,layout:`inline`,className:`text-xs leading-4`})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[o&&(0,I.jsx)(M,{label:s,children:(0,I.jsx)(x,{type:`button`,size:`icon-xs`,variant:`ghost-muted`,"aria-label":s,onClick:()=>n(!t),children:(0,I.jsx)(w,{icon:t?Qg:Q_,className:`size-3`})})}),(0,I.jsx)(M,{label:`Open the full diff`,children:(0,I.jsxs)(x,{type:`button`,size:`xs`,variant:`ghost-muted`,"aria-label":`Open diff`,onClick:e.onOpenDiff,children:[(0,I.jsx)(w,{icon:g_,className:`size-3`}),(0,I.jsx)(`span`,{className:`hidden @[24rem]/changed-files:inline`,children:`Open diff`})]})})]})]}),(0,I.jsx)(d3,{files:e.files,allExpanded:t,onOpenDiff:e.onOpenDiff},String(t))]})}function d3(e){let[t,n]=(0,F.useState)({}),r=o3(e.files),i=r.some(e=>e.kind===`directory`),a=`group hover:bg-accent/60 focus-visible:ring-ring focus-visible:ring-offset-background flex w-full items-center gap-2 rounded-md py-1.5 pr-2 text-left transition-colors focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none focus-visible:ring-inset`;function o(r,s){let c=`${8+s*14}px`;if(r.kind===`directory`){let i=t[r.path]??e.allExpanded;return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":i,className:a,style:{paddingLeft:c},onClick:()=>n({...t,[r.path]:!i}),children:[(0,I.jsx)(w,{icon:Xg,"aria-hidden":!0,className:P(`text-muted-foreground/70 group-hover:text-foreground/80 size-3.5 shrink-0 transition-transform`,i&&`rotate-90`)}),(0,I.jsx)(w,{icon:i?v_:y_,className:`text-muted-foreground/75 size-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`text-2xs text-muted-foreground/90 group-hover:text-foreground/90 truncate font-mono`,children:r.name}),(r.stat.added>0||r.stat.removed>0)&&(0,I.jsx)(`span`,{className:`text-3xs ml-auto shrink-0 font-mono tabular-nums`,children:(0,I.jsx)(f3,{added:r.stat.added,removed:r.stat.removed,layout:`aligned`})})]}),i&&(0,I.jsx)(`div`,{children:r.children.map(e=>o(e,s+1))})]},`dir:${r.path}`)}return(0,I.jsxs)(`button`,{type:`button`,className:a,style:{paddingLeft:c},onClick:e.onOpenDiff,children:[(i||s>0)&&(0,I.jsx)(`span`,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,I.jsx)(be,{path:r.path,className:`text-muted-foreground/70 size-3.5`}),(0,I.jsx)(`span`,{className:`text-foreground/85 group-hover:text-foreground flex min-w-0 font-mono text-xs`,children:(0,I.jsx)(`span`,{className:`truncate`,children:r.name})}),(0,I.jsx)(`span`,{className:`text-3xs ml-auto shrink-0 font-mono tabular-nums`,children:(0,I.jsx)(f3,{added:r.stat.added,removed:r.stat.removed,layout:`aligned`})})]},`file:${r.path}`)}return(0,I.jsx)(`div`,{className:`p-2`,children:r.map(e=>o(e,0))})}function f3(e){return(0,I.jsxs)(`span`,{role:`group`,"aria-label":`${e.added} additions, ${e.removed} deletions`,className:P(e.layout===`inline`?`inline-flex items-center gap-1 align-middle tabular-nums`:`inline-grid grid-cols-[4ch_4ch] gap-2 text-right align-middle tabular-nums`,e.className),children:[(0,I.jsxs)(`span`,{"aria-hidden":!0,className:`text-diff-addition font-mono`,children:[`+`,hw(e.added)]}),(0,I.jsxs)(`span`,{"aria-hidden":!0,className:`text-diff-deletion font-mono`,children:[`-`,hw(e.removed)]})]})}function p3(e){let[t,n]=(0,F.useState)(!1),r=gI(),i=e.plan,a=m3(i),o=i.length>900||i.split(`
|
|
115
115
|
`).length>20,s=o&&!t,c=`${i.trimEnd()}\n`;return(0,I.jsxs)(`div`,{className:`border-border/80 bg-card/70 rounded-3xl border p-4 sm:p-5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`bg-secondary text-secondary-foreground relative inline-flex h-5.5 min-w-5.5 shrink-0 items-center justify-center gap-1 rounded-sm border border-transparent px-[calc(--spacing(1)-1px)] text-sm font-medium whitespace-nowrap sm:h-4.5 sm:min-w-4.5 sm:text-xs`,children:`Plan`}),(0,I.jsx)(`h3`,{className:`text-foreground truncate text-sm font-medium`,children:a??`Proposed plan`})]}),(0,I.jsxs)(yC,{children:[(0,I.jsx)(xC,{asChild:!0,children:(0,I.jsx)(x,{"aria-label":`Plan actions`,size:`icon-xs`,variant:`outline`,children:(0,I.jsx)(w,{icon:O_,className:`size-4`})})}),(0,I.jsxs)(SC,{align:`end`,children:[(0,I.jsx)(CC,{onSelect:e=>{e.preventDefault(),r.copy(c)},children:r.copied?`Copied!`:`Copy to clipboard`}),(0,I.jsx)(CC,{onSelect:()=>{let e=URL.createObjectURL(new Blob([c],{type:`text/markdown;charset=utf-8`})),t=document.createElement(`a`);t.href=e,t.download=`${_3(a??`plan`)}.md`,t.click(),setTimeout(()=>URL.revokeObjectURL(e),0)},children:`Download as markdown`})]})]})]}),(0,I.jsxs)(`div`,{className:`mt-4`,children:[(0,I.jsxs)(`div`,{className:P(`relative`,s&&`max-h-104 overflow-hidden`),children:[(0,I.jsx)(kI,{text:s?g3(i):h3(i)}),s&&(0,I.jsx)(`div`,{className:`from-card/95 via-card/80 pointer-events-none absolute inset-x-0 bottom-0 h-24 bg-linear-to-t to-transparent`})]}),o&&(0,I.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,I.jsx)(x,{size:`sm`,variant:`outline`,onClick:()=>n(!t),children:t?`Collapse plan`:`Expand plan`})})]})]})}function m3(e){let t=/^\s{0,3}#{1,6}\s+(.+)$/m.exec(e)?.[1]?.trim();return t===void 0||t===``?null:t}function h3(e){let t=e.trimEnd().split(/\r?\n/),n=/^\s{0,3}#{1,6}\s+/.test(t[0]??``)?t.slice(1):t;for(;n[0]?.trim()===``;)n.shift();if(/^\s{0,3}#{1,6}\s+(.+)$/.exec(n[0]??``)?.[1]?.trim().toLowerCase()===`summary`)for(n.shift();n[0]?.trim()===``;)n.shift();return n.join(`
|