runcastle 1.6.2 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/bin/runcastle.js +13202 -61413
- package/drizzle/0057_jazzy_lila_cheney.sql +1 -0
- package/drizzle/0058_test_note_open_only.sql +9 -0
- package/drizzle/0059_milky_black_knight.sql +17 -0
- package/drizzle/0060_drop_prepare_sessions.sql +6 -0
- package/drizzle/0061_events_type_index.sql +4 -0
- package/drizzle/0062_workers.sql +30 -0
- package/drizzle/0063_worker_dev_server.sql +1 -0
- package/drizzle/0064_worker_tokens.sql +1 -0
- package/drizzle/0065_review_workers.sql +28 -0
- package/drizzle/0066_drive_workers.sql +39 -0
- package/drizzle/meta/0057_snapshot.json +1351 -0
- package/drizzle/meta/0059_snapshot.json +1461 -0
- package/drizzle/meta/0062_snapshot.json +1654 -0
- package/drizzle/meta/0063_snapshot.json +1662 -0
- package/drizzle/meta/0064_snapshot.json +1669 -0
- package/drizzle/meta/0065_snapshot.json +1690 -0
- package/drizzle/meta/0066_snapshot.json +1704 -0
- package/drizzle/meta/_journal.json +70 -0
- package/index.js +12480 -60694
- package/package.json +2 -3
- package/skills/packs/README.md +11 -15
- package/skills/packs/runcastle/.claude-plugin/plugin.json +1 -1
- package/skills/packs/runcastle/skills/code-review/SKILL.md +3 -3
- package/skills/packs/runcastle/skills/feature/SKILL.md +37 -18
- package/skills/packs/runcastle/skills/feature/references/design.md +102 -127
- package/skills/packs/runcastle/skills/feature/references/grilling.md +9 -3
- package/skills/packs/runcastle/skills/feature/references/planning-alone.md +69 -38
- package/skills/packs/runcastle/skills/feature/references/preview-starter.html +22 -20
- package/skills/packs/runcastle/skills/feature/references/preview.md +45 -27
- package/skills/packs/runcastle/skills/feature/references/spec.md +1 -1
- package/skills/packs/runcastle/skills/feature/references/workers.md +144 -0
- package/skills/packs/runcastle/skills/project/SKILL.md +64 -201
- package/skills/packs/runcastle/skills/project/references/charter.md +3 -3
- package/skills/packs/runcastle/skills/project/references/health-sweeps.md +3 -3
- package/skills/packs/runcastle/skills/project/references/intake.md +139 -0
- package/skills/packs/runcastle/skills/{prepare/references/recipes.md → project/references/preparation-recipes.md} +2 -2
- package/skills/packs/runcastle/skills/project/references/preparation.md +176 -0
- package/skills/packs/runcastle/skills/project/references/routing.md +39 -0
- package/skills/packs/runcastle/skills/project/references/triage.md +3 -3
- package/skills/packs/runcastle/skills/qa/SKILL.md +5 -7
- package/skills/review/review-drive.md +33 -0
- package/skills/review/review-gates.md +22 -0
- package/skills/review/review.md +61 -0
- package/skills/review/verify.md +31 -0
- package/web/assets/index-C0TYj0Ka.css +1 -0
- package/web/assets/index-C6JVtDiw.js +193 -0
- package/web/index.html +3 -3
- package/web/manifest.webmanifest +2 -2
- package/web/sw.js +4 -4
- package/skills/burner/implement-ticket.md +0 -118
- package/skills/burner/resolve-conflict.md +0 -78
- package/skills/burner/review-ticket.md +0 -268
- package/skills/burner/verify-fixes.md +0 -59
- package/skills/packs/runcastle/skills/feature/references/rounds.md +0 -97
- package/skills/packs/runcastle/skills/feature/references/tickets.md +0 -231
- package/skills/packs/runcastle/skills/prepare/SKILL.md +0 -148
- package/web/assets/index-CHxfwKvB.js +0 -193
- package/web/assets/index-CVCnjOHN.css +0 -1
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},d=new class extends u{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},f={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},p=new class{#e=f;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function m(e){setTimeout(e,0)}var h=typeof window>`u`||`Deno`in globalThis;function g(){}function _(e,t){return typeof e==`function`?e(t):e}function v(e){return typeof e==`number`&&e>=0&&e!==1/0}function y(e,t){return Math.max(e+(t||0)-Date.now(),0)}function b(e,t){return typeof e==`function`?e(t):e}function x(e,t){return typeof e==`function`?e(t):e}function S(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==w(o,t.options))return!1}else if(!E(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function C(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(T(t.options.mutationKey)!==T(a))return!1}else if(!E(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function w(e,t){return(t?.queryKeyHashFn||T)(e)}function T(e){return JSON.stringify(e,(e,t)=>A(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function E(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>E(e[n],t[n])):!1}var D=Object.prototype.hasOwnProperty;function O(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ee(e)&&ee(t);if(!r&&!(A(e)&&A(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:D.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=O(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function k(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ee(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function A(e){if(!j(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!j(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function j(e){return Object.prototype.toString.call(e)===`[object Object]`}function M(e){return new Promise(t=>{p.setTimeout(t,e)})}function N(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:O(e,t)}function te(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function ne(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var re=Symbol();function ie(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===re?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ae(e,t){return typeof e==`function`?e(...t):!!e}function P(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var oe=(()=>{let e=()=>h;return{isServer(){return e()},setIsServer(t){e=t}}})();function se(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var ce=m;function le(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=ce,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var ue=le(),de=new class extends u{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function fe(e){return Math.min(1e3*2**e,3e4)}function pe(e){return(e??`online`)!==`online`||de.isOnline()}var me=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function he(e){let t=!1,n=0,r,i=se(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new me(t);p(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>d.isFocused()&&(e.networkMode===`always`||de.isOnline())&&e.canRun(),u=()=>pe(e.networkMode)&&e.canRun(),f=e=>{a()||(r?.(),i.resolve(e))},p=e=>{a()||(r?.(),i.reject(e))},m=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),h=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(f).catch(r=>{if(a())return;let i=e.retry??(oe.isServer()?0:3),o=e.retryDelay??fe,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){p(r);return}n++,e.onFail?.(n,r),M(s).then(()=>l()?void 0:m()).then(()=>{t?p(r):h()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?h():m().then(h),i)}}var ge=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),v(this.gcTime)&&(this.#e=p.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(oe.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(p.clearTimeout(this.#e),this.#e=void 0)}};function _e(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{P(e,()=>t.signal,()=>n=!0)},u=ie(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?ne:te;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?ye:ve,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:ve(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function ve(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ye(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function be(e,t){return t?ve(e,t)!=null:!1}function xe(e,t){return!t||!e.getPreviousPageParam?!1:ye(e,t)!=null}var Se=class extends ge{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Te(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Te(this.options);e.data!==void 0&&(this.setState(we(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=N(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(g).catch(g):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>x(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===re||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>b(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!y(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=ie(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?_e(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=he({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof me&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof me){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Ce(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...we(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),ue.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Ce(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:pe(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function we(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Te(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Ee=class extends u{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=se(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Oe(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ke(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ke(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof x(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!k(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ae(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||x(this.options.enabled,this.#t)!==x(t.enabled,this.#t)||b(this.options.staleTime,this.#t)!==b(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||x(this.options.enabled,this.#t)!==x(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Me(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(g)),t}#g(){this.#b();let e=b(this.options.staleTime,this.#t);if(oe.isServer()||this.#r.isStale||!v(e))return;let t=y(this.#r.dataUpdatedAt,e)+1;this.#d=p.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(oe.isServer()||x(this.options.enabled,this.#t)===!1||!v(this.#p)||this.#p===0)&&(this.#f=p.setInterval(()=>{(this.options.refetchIntervalInBackground||d.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(p.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(p.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Oe(e,t),o=i&&Ae(e,n,t,r);(a||o)&&(l={...l,...Ce(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=N(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=N(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,S={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:je(e,t),refetch:this.refetch,promise:this.#o,isEnabled:x(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=S.data!==void 0,r=S.status===`error`&&!t,i=e=>{r?e.reject(S.error):t&&e.resolve(S.data)},a=()=>{let e=this.#o=S.promise=se();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||S.data!==o.value)&&a();break;case`rejected`:(!r||S.error!==o.reason)&&a();break}}return S}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!k(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){ue.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function De(e,t){return x(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&x(t.retryOnMount,e)===!1)}function Oe(e,t){return De(e,t)||e.state.data!==void 0&&ke(e,t,t.refetchOnMount)}function ke(e,t,n){if(x(t.enabled,e)!==!1&&b(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&je(e,t)}return!1}function Ae(e,t,n,r){return(e!==t||x(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&je(e,n)}function je(e,t){return x(t.enabled,e)!==!1&&e.isStaleByTime(b(t.staleTime,e))}function Me(e,t){return!k(e.getCurrentResult(),t)}var Ne=class extends Ee{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:be(t,n.data),hasPreviousPage:xe(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},Pe=class extends ge{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Fe(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=he({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),ue.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Fe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Ie=class extends u{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Pe({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Le(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Le(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Le(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Le(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){ue.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>C(t,e))}findAll(e={}){return this.getAll().filter(t=>C(e,t))}notify(e){ue.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return ue.batch(()=>Promise.all(e.map(e=>e.continue().catch(g))))}};function Le(e){return e.options.scope?.id}var Re=class extends u{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),k(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&T(t.mutationKey)!==T(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Fe();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){ue.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function ze(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Be(e,t,n){let r=e.slice(0);return r[t]=n,r}var Ve=class extends u{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,ue.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!k(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(ze(e,n).forEach(e=>{e.destroy()}),ze(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=O(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new Ee(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Be(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&ue.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},He=class extends u{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??w(r,t),a=this.get(i);return a||(a=new Se({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){ue.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>S(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>S(e,t)):t}notify(e){ue.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ue.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ue.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Ue=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new He,this.#t=e.mutationCache||new Ie,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=d.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=de.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(b(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=_(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return ue.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;ue.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return ue.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=ue.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(g).catch(g)}invalidateQueries(e,t={}){return ue.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=ue.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(g)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(g)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(b(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(g).catch(g)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(g).catch(g)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return de.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(T(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{E(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(T(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{E(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=w(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===re&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},We=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ee=/\/+/g;function A(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function j(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function M(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,M(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+A(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(ee,`$&/`)+`/`),M(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ee,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+A(a,u),c+=M(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+A(a,u++),c+=M(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return M(j(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function N(e,t,n){if(e==null)return e;var r=[],i=0;return M(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function te(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var ne=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},re={map:N,forEach:function(e,t,n){N(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return N(e,function(){t++}),t},toArray:function(e){return N(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=re,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:te}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,ne)}catch(e){ne(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.7`})),Ge=o(((e,t)=>{t.exports=We()})),Ke=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),qe=o(((e,t)=>{t.exports=Ke()})),F=l(Ge(),1),I=qe(),Je=F.createContext(void 0),Ye=e=>{let t=F.useContext(Je);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Xe=({client:e,children:t})=>(F.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,I.jsx)(Je.Provider,{value:e,children:t})),Ze=F.createContext(!1),Qe=()=>F.useContext(Ze);Ze.Provider;function $e(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var et=F.createContext($e()),tt=()=>F.useContext(et),nt=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?ae(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},rt=e=>{F.useEffect(()=>{e.clearReset()},[e])},it=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||ae(n,[e.error,r])),at=(e,t)=>t.state.data===void 0,ot=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},st=(e,t)=>e.isLoading&&e.isFetching&&!t,ct=(e,t)=>e?.suspense&&t.isPending,lt=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function ut({queries:e,...t},n){let r=Ye(n),i=Qe(),a=tt(),o=F.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{ot(e);let t=r.getQueryCache().get(e.queryHash);nt(e,a,t)}),rt(a);let[s]=F.useState(()=>new Ve(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;F.useSyncExternalStore(F.useCallback(e=>d?s.subscribe(ue.batchCalls(e)):g,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),F.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>ct(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&ct(n,e)?lt(n,new Ee(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&it({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}function dt(e,t,n){let r=Qe(),i=tt(),a=Ye(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,ot(o),nt(o,i,s),rt(i);let l=!a.getQueryCache().get(o.queryHash),[u]=F.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(F.useSyncExternalStore(F.useCallback(e=>{let t=f?u.subscribe(ue.batchCalls(e)):g;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),F.useEffect(()=>{u.setOptions(o)},[o,u]),ct(o,d))throw lt(o,u,i);if(it({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!oe.isServer()&&st(d,r)&&(l?lt(o,u,i):s?.promise)?.catch(g).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function ft(e,t){return dt(e,Ee,t)}function pt(e,t){return dt({...e,enabled:!0,suspense:!0,throwOnError:at,placeholderData:void 0},Ee,t)}function mt(e,t){return dt({...e,enabled:!0,suspense:!0,throwOnError:at},Ne,t)}function ht(e,t){return ut({...e,queries:e.queries.map(e=>({...e,suspense:!0,throwOnError:at,enabled:!0,placeholderData:void 0}))},t)}function gt(e,t){let n=Ye(t);n.getQueryState(e.queryKey)||n.prefetchQuery(e)}function _t(e,t){let n=Ye(t);n.getQueryState(e.queryKey)||n.prefetchInfiniteQuery(e)}function vt(e){return e}function yt(e){return e}function bt(e,t){let n=Ye(t),[r]=F.useState(()=>new Re(n,e));F.useEffect(()=>{r.setOptions(e)},[r,e]);let i=F.useSyncExternalStore(F.useCallback(e=>r.subscribe(ue.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=F.useCallback((e,t)=>{r.mutate(e,t).catch(g)},[r]);if(i.error&&ae(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function xt(e,t){return dt(e,Ne,t)}var St=o((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&&A(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&&A(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,ee=k.port2;k.port1.onmessage=D,O=function(){ee.postMessage(null)}}else O=function(){_(D,0)};function A(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,A(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}}}})),Ct=o(((e,t)=>{t.exports=St()})),wt=o((e=>{var t=Ge();function n(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 r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.7`})),Tt=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=wt()})),Et=o((e=>{var t=Ct(),n=Ge(),r=Tt();function i(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 a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(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 c(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 l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var ee=Symbol.for(`react.client.reference`);function A(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ee?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?A(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return A(e(t))}catch{}}return null}var j=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te={pending:!1,data:null,method:null,action:null},ne=[],re=-1;function ie(e){return{current:e}}function ae(e){0>re||(e.current=ne[re],ne[re]=null,re--)}function P(e,t){re++,ne[re]=e.current,e.current=t}var oe=ie(null),se=ie(null),ce=ie(null),le=ie(null);function ue(e,t){switch(P(ce,t),P(se,e),P(oe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Zd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Zd(t),e=Qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ae(oe),P(oe,e)}function de(){ae(oe),ae(se),ae(ce)}function fe(e){e.memoizedState!==null&&P(le,e);var t=oe.current,n=Qd(t,e.type);t!==n&&(P(se,e),P(oe,n))}function pe(e){se.current===e&&(ae(oe),ae(se)),le.current===e&&(ae(le),sp._currentValue=te)}var me,he;function ge(e){if(me===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);me=t&&t[1]||``,he=-1<e.stack.indexOf(`
|
|
2
|
-
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
3
|
-
`+me+e+he}var _e=!1;function ve(e,t){if(!e||_e)return``;_e=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
4
|
-
`),l=s.split(`
|
|
5
|
-
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
6
|
-
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{_e=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ge(n):``}function ye(e,t){switch(e.tag){case 26:case 27:case 5:return ge(e.type);case 16:return ge(`Lazy`);case 13:return e.child!==t&&t!==null?ge(`Suspense Fallback`):ge(`Suspense`);case 19:return ge(`SuspenseList`);case 0:case 15:return ve(e.type,!1);case 11:return ve(e.type.render,!1);case 1:return ve(e.type,!0);case 31:return ge(`Activity`);default:return``}}function be(e){try{var t=``,n=null;do t+=ye(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
7
|
-
Error generating stack: `+e.message+`
|
|
8
|
-
`+e.stack}}var xe=Object.prototype.hasOwnProperty,Se=t.unstable_scheduleCallback,Ce=t.unstable_cancelCallback,we=t.unstable_shouldYield,Te=t.unstable_requestPaint,Ee=t.unstable_now,De=t.unstable_getCurrentPriorityLevel,Oe=t.unstable_ImmediatePriority,ke=t.unstable_UserBlockingPriority,Ae=t.unstable_NormalPriority,je=t.unstable_LowPriority,Me=t.unstable_IdlePriority,Ne=t.log,Pe=t.unstable_setDisableYieldValue,Fe=null,Ie=null;function Le(e){if(typeof Ne==`function`&&Pe(e),Ie&&typeof Ie.setStrictMode==`function`)try{Ie.setStrictMode(Fe,e)}catch{}}var Re=Math.clz32?Math.clz32:Ve,ze=Math.log,Be=Math.LN2;function Ve(e){return e>>>=0,e===0?32:31-(ze(e)/Be|0)|0}var He=256,Ue=262144,We=4194304;function Ke(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function qe(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Ke(n))):i=Ke(o):i=Ke(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ke(n))):i=Ke(o)):i=Ke(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function F(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function I(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Je(){var e=We;return We<<=1,!(We&62914560)&&(We=4194304),e}function Ye(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Xe(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ze(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Re(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&Qe(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Qe(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Re(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function $e(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Re(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function et(e,t){var n=t&-t;return n=n&42?1:tt(n),(n&(e.suspendedLanes|t))===0?n:0}function tt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function nt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function rt(){var e=N.p;return e===0?(e=window.event,e===void 0?32:Cp(e.type)):e}function it(e,t){var n=N.p;try{return N.p=e,t()}finally{N.p=n}}var at=Math.random().toString(36).slice(2),ot=`__reactFiber$`+at,st=`__reactProps$`+at,ct=`__reactContainer$`+at,lt=`__reactEvents$`+at,ut=`__reactListeners$`+at,dt=`__reactHandles$`+at,ft=`__reactResources$`+at,pt=`__reactMarker$`+at;function mt(e){delete e[ot],delete e[st],delete e[lt],delete e[ut],delete e[dt]}function ht(e){var t=e[ot];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ct]||n[ot]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=xf(e);e!==null;){if(n=e[ot])return n;e=xf(e)}return t}e=n,n=e.parentNode}return null}function gt(e){if(e=e[ot]||e[ct]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function _t(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function vt(e){var t=e[ft];return t||=e[ft]={hoistableStyles:new Map,hoistableScripts:new Map},t}function yt(e){e[pt]=!0}var bt=new Set,xt={};function St(e,t){wt(e,t),wt(e+`Capture`,t)}function wt(e,t){for(xt[e]=t,e=0;e<t.length;e++)bt.add(t[e])}var Et=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Dt={},Ot={};function kt(e){return xe.call(Ot,e)?!0:xe.call(Dt,e)?!1:Et.test(e)?Ot[e]=!0:(Dt[e]=!0,!1)}function At(e,t,n){if(kt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function jt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function Mt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Nt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Pt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Ft(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function It(e){if(!e._valueTracker){var t=Pt(e)?`checked`:`value`;e._valueTracker=Ft(e,t,``+e[t])}}function Lt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Pt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function Rt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var zt=/[\n"\\]/g;function Bt(e){return e.replace(zt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Vt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Nt(t)):e.value!==``+Nt(t)&&(e.value=``+Nt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Ut(e,o,Nt(n)):Ut(e,o,Nt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Nt(s):e.removeAttribute(`name`)}function Ht(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){It(e);return}n=n==null?``:``+Nt(n),t=t==null?n:``+Nt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),It(e)}function Ut(e,t,n){t===`number`&&Rt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Wt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Nt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Gt(e,t,n){if(t!=null&&(t=``+Nt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Nt(n)}function Kt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(j(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Nt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),It(e)}function qt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Jt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Yt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Jt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Xt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Yt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Yt(e,o,t[o])}function Zt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Qt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),$t=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function en(e){return $t.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function tn(){}var nn=null;function rn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var an=null,on=null;function sn(e){var t=gt(e);if(t&&(e=t.stateNode)){var n=e[st]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Vt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Bt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[st]||null;if(!a)throw Error(i(90));Vt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Lt(r)}break a;case`textarea`:Gt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Wt(e,!!n.multiple,t,!1)}}}var cn=!1;function ln(e,t,n){if(cn)return e(t,n);cn=!0;try{return e(t)}finally{if(cn=!1,(an!==null||on!==null)&&(Du(),an&&(t=an,e=on,on=an=null,sn(t),e)))for(t=0;t<e.length;t++)sn(e[t])}}function un(e,t){var n=e.stateNode;if(n===null)return null;var r=n[st]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var dn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),fn=!1;if(dn)try{var pn={};Object.defineProperty(pn,"passive",{get:function(){fn=!0}}),window.addEventListener(`test`,pn,pn),window.removeEventListener(`test`,pn,pn)}catch{fn=!1}var mn=null,hn=null,gn=null;function _n(){if(gn)return gn;var e,t=hn,n=t.length,r,i=`value`in mn?mn.value:mn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return gn=i.slice(e,1<r?1-r:void 0)}function vn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function yn(){return!0}function bn(){return!1}function xn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?yn:bn,this.isPropagationStopped=bn,this}return f(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=yn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=yn)},persist:function(){},isPersistent:yn}),t}var Sn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Cn=xn(Sn),wn=f({},Sn,{view:0,detail:0}),Tn=xn(wn),En,Dn,On,kn=f({},wn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Bn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==On&&(On&&e.type===`mousemove`?(En=e.screenX-On.screenX,Dn=e.screenY-On.screenY):Dn=En=0,On=e),En)},movementY:function(e){return`movementY`in e?e.movementY:Dn}}),An=xn(kn),jn=xn(f({},kn,{dataTransfer:0})),Mn=xn(f({},wn,{relatedTarget:0})),Nn=xn(f({},Sn,{animationName:0,elapsedTime:0,pseudoElement:0})),Pn=xn(f({},Sn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Fn=xn(f({},Sn,{data:0})),In={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Ln={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},Rn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function zn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Rn[e])?!!t[e]:!1}function Bn(){return zn}var Vn=xn(f({},wn,{key:function(e){if(e.key){var t=In[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=vn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Ln[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Bn,charCode:function(e){return e.type===`keypress`?vn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?vn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Hn=xn(f({},kn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Un=xn(f({},wn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Bn})),Wn=xn(f({},Sn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Gn=xn(f({},kn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Kn=xn(f({},Sn,{newState:0,oldState:0})),qn=[9,13,27,32],Jn=dn&&`CompositionEvent`in window,Yn=null;dn&&`documentMode`in document&&(Yn=document.documentMode);var Xn=dn&&`TextEvent`in window&&!Yn,Zn=dn&&(!Jn||Yn&&8<Yn&&11>=Yn),Qn=` `,$n=!1;function er(e,t){switch(e){case`keyup`:return qn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function tr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var nr=!1;function rr(e,t){switch(e){case`compositionend`:return tr(t);case`keypress`:return t.which===32?($n=!0,Qn):null;case`textInput`:return e=t.data,e===Qn&&$n?null:e;default:return null}}function ir(e,t){if(nr)return e===`compositionend`||!Jn&&er(e,t)?(e=_n(),gn=hn=mn=null,nr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Zn&&t.locale!==`ko`?null:t.data;default:return null}}var ar={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function or(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!ar[e.type]:t===`textarea`}function sr(e,t,n,r){an?on?on.push(r):on=[r]:an=r,t=Fd(t,`onChange`),0<t.length&&(n=new Cn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var cr=null,lr=null;function ur(e){Dd(e,0)}function dr(e){if(Lt(_t(e)))return e}function fr(e,t){if(e===`change`)return t}var pr=!1;if(dn){var mr;if(dn){var hr=`oninput`in document;if(!hr){var gr=document.createElement(`div`);gr.setAttribute(`oninput`,`return;`),hr=typeof gr.oninput==`function`}mr=hr}else mr=!1;pr=mr&&(!document.documentMode||9<document.documentMode)}function _r(){cr&&(cr.detachEvent(`onpropertychange`,vr),lr=cr=null)}function vr(e){if(e.propertyName===`value`&&dr(lr)){var t=[];sr(t,lr,e,rn(e)),ln(ur,t)}}function yr(e,t,n){e===`focusin`?(_r(),cr=t,lr=n,cr.attachEvent(`onpropertychange`,vr)):e===`focusout`&&_r()}function br(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return dr(lr)}function xr(e,t){if(e===`click`)return dr(t)}function Sr(e,t){if(e===`input`||e===`change`)return dr(t)}function Cr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var wr=typeof Object.is==`function`?Object.is:Cr;function Tr(e,t){if(wr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!xe.call(t,i)||!wr(e[i],t[i]))return!1}return!0}function Er(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Dr(e,t){var n=Er(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Er(n)}}function Or(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Or(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function kr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Rt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Rt(e.document)}return t}function Ar(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var jr=dn&&`documentMode`in document&&11>=document.documentMode,Mr=null,Nr=null,Pr=null,Fr=!1;function Ir(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Fr||Mr==null||Mr!==Rt(r)||(r=Mr,`selectionStart`in r&&Ar(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Pr&&Tr(Pr,r)||(Pr=r,r=Fd(Nr,`onSelect`),0<r.length&&(t=new Cn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Mr)))}function Lr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Rr={animationend:Lr(`Animation`,`AnimationEnd`),animationiteration:Lr(`Animation`,`AnimationIteration`),animationstart:Lr(`Animation`,`AnimationStart`),transitionrun:Lr(`Transition`,`TransitionRun`),transitionstart:Lr(`Transition`,`TransitionStart`),transitioncancel:Lr(`Transition`,`TransitionCancel`),transitionend:Lr(`Transition`,`TransitionEnd`)},zr={},Br={};dn&&(Br=document.createElement(`div`).style,`AnimationEvent`in window||(delete Rr.animationend.animation,delete Rr.animationiteration.animation,delete Rr.animationstart.animation),`TransitionEvent`in window||delete Rr.transitionend.transition);function Vr(e){if(zr[e])return zr[e];if(!Rr[e])return e;var t=Rr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Br)return zr[e]=t[n];return e}var Hr=Vr(`animationend`),Ur=Vr(`animationiteration`),Wr=Vr(`animationstart`),Gr=Vr(`transitionrun`),Kr=Vr(`transitionstart`),qr=Vr(`transitioncancel`),Jr=Vr(`transitionend`),Yr=new Map,Xr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Xr.push(`scrollEnd`);function Zr(e,t){Yr.set(e,t),St(t,[e])}var Qr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},$r=[],ei=0,ti=0;function ni(){for(var e=ei,t=ti=ei=0;t<e;){var n=$r[t];$r[t++]=null;var r=$r[t];$r[t++]=null;var i=$r[t];$r[t++]=null;var a=$r[t];if($r[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&L(n,i,a)}}function ri(e,t,n,r){$r[ei++]=e,$r[ei++]=t,$r[ei++]=n,$r[ei++]=r,ti|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function ii(e,t,n,r){return ri(e,t,n,r),oi(e)}function ai(e,t){return ri(e,null,null,t),oi(e)}function L(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Re(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function oi(e){if(50<yu)throw yu=0,bu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var si={};function ci(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function li(e,t,n,r){return new ci(e,t,n,r)}function R(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ui(e,t){var n=e.alternate;return n===null?(n=li(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function di(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function fi(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)R(e)&&(s=1);else if(typeof e==`string`)s=Qf(e,n,oe.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case E:return e=li(31,n,t,a),e.elementType=E,e.lanes=o,e;case g:return pi(n.children,a,o,t);case _:s=8,a|=24;break;case v:return e=li(12,n,t,a|2),e.elementType=v,e.lanes=o,e;case S:return e=li(13,n,t,a),e.elementType=S,e.lanes=o,e;case C:return e=li(19,n,t,a),e.elementType=C,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case b:s=10;break a;case y:s=9;break a;case x:s=11;break a;case w:s=14;break a;case T:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=li(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function pi(e,t,n,r){return e=li(7,e,r,t),e.lanes=n,e}function z(e,t,n){return e=li(6,e,null,t),e.lanes=n,e}function mi(e){var t=li(18,null,null,0);return t.stateNode=e,t}function hi(e,t,n){return t=li(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var gi=new WeakMap;function _i(e,t){if(typeof e==`object`&&e){var n=gi.get(e);return n===void 0?(t={value:e,source:t,stack:be(t)},gi.set(e,t),t):n}return{value:e,source:t,stack:be(t)}}var vi=[],yi=0,bi=null,xi=0,Si=[],Ci=0,wi=null,Ti=1,Ei=``;function Di(e,t){vi[yi++]=xi,vi[yi++]=bi,bi=e,xi=t}function Oi(e,t,n){Si[Ci++]=Ti,Si[Ci++]=Ei,Si[Ci++]=wi,wi=e;var r=Ti;e=Ei;var i=32-Re(r)-1;r&=~(1<<i),n+=1;var a=32-Re(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Ti=1<<32-Re(t)+i|n<<i|r,Ei=a+e}else Ti=1<<a|n<<i|r,Ei=e}function ki(e){e.return!==null&&(Di(e,1),Oi(e,1,0))}function Ai(e){for(;e===bi;)bi=vi[--yi],vi[yi]=null,xi=vi[--yi],vi[yi]=null;for(;e===wi;)wi=Si[--Ci],Si[Ci]=null,Ei=Si[--Ci],Si[Ci]=null,Ti=Si[--Ci],Si[Ci]=null}function ji(e,t){Si[Ci++]=Ti,Si[Ci++]=Ei,Si[Ci++]=wi,Ti=t.id,Ei=t.overflow,wi=e}var Mi=null,Ni=null,Pi=!1,Fi=null,Ii=!1,Li=Error(i(519));function B(e){throw Ui(_i(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Li}function Ri(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[ot]=e,t[st]=r,n){case`dialog`:Od(`cancel`,t),Od(`close`,t);break;case`iframe`:case`object`:case`embed`:Od(`load`,t);break;case`video`:case`audio`:for(n=0;n<Td.length;n++)Od(Td[n],t);break;case`source`:Od(`error`,t);break;case`img`:case`image`:case`link`:Od(`error`,t),Od(`load`,t);break;case`details`:Od(`toggle`,t);break;case`input`:Od(`invalid`,t),Ht(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Od(`invalid`,t);break;case`textarea`:Od(`invalid`,t),Kt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Vd(t.textContent,n)?(r.popover!=null&&(Od(`beforetoggle`,t),Od(`toggle`,t)),r.onScroll!=null&&Od(`scroll`,t),r.onScrollEnd!=null&&Od(`scrollend`,t),r.onClick!=null&&(t.onclick=tn),t=!0):t=!1,t||B(e,!0)}function zi(e){for(Mi=e.return;Mi;)switch(Mi.tag){case 5:case 31:case 13:Ii=!1;return;case 27:case 3:Ii=!0;return;default:Mi=Mi.return}}function Bi(e){if(e!==Mi)return!1;if(!Pi)return zi(e),Pi=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||$d(e.type,e.memoizedProps)),n=!n),n&&Ni&&B(e),zi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ni=bf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ni=bf(e)}else t===27?(t=Ni,cf(e.type)?(e=yf,yf=null,Ni=e):Ni=t):Ni=Mi?vf(e.stateNode.nextSibling):null;return!0}function Vi(){Ni=Mi=null,Pi=!1}function Hi(){var e=Fi;return e!==null&&(ou===null?ou=e:ou.push.apply(ou,e),Fi=null),e}function Ui(e){Fi===null?Fi=[e]:Fi.push(e)}var Wi=ie(null),Gi=null,Ki=null;function qi(e,t,n){P(Wi,t._currentValue),t._currentValue=n}function Ji(e){e._currentValue=Wi.current,ae(Wi)}function Yi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Xi(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Yi(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Yi(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Zi(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;wr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===le.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[sp]:e.push(sp))}a=a.return}e!==null&&Xi(t,e,n,r),t.flags|=262144}function Qi(e){for(e=e.firstContext;e!==null;){if(!wr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function $i(e){Gi=e,Ki=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ea(e){return na(Gi,e)}function ta(e,t){return Gi===null&&$i(e),na(e,t)}function na(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Ki===null){if(e===null)throw Error(i(308));Ki=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ki=Ki.next=t;return n}var ra=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ia=t.unstable_scheduleCallback,aa=t.unstable_NormalPriority,oa={$$typeof:b,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function sa(){return{controller:new ra,data:new Map,refCount:0}}function ca(e){e.refCount--,e.refCount===0&&ia(aa,function(){e.controller.abort()})}var la=null,ua=0,da=0,fa=null;function pa(e,t){if(la===null){var n=la=[];ua=0,da=yd(),fa={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ua++,t.then(ma,ma),t}function ma(){if(--ua===0&&la!==null){fa!==null&&(fa.status=`fulfilled`);var e=la;la=null,da=0,fa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ha(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var ga=M.S;M.S=function(e,t){lu=Ee(),typeof t==`object`&&t&&typeof t.then==`function`&&pa(e,t),ga!==null&&ga(e,t)};var _a=ie(null);function va(){var e=_a.current;return e===null?Gl.pooledCache:e}function ya(e,t){t===null?P(_a,_a.current):P(_a,t.pool)}function ba(){var e=va();return e===null?null:{parent:oa._currentValue,pool:e}}var xa=Error(i(460)),Sa=Error(i(474)),Ca=Error(i(542)),wa={then:function(){}};function Ta(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Ea(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(tn,tn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Aa(e),e;default:if(typeof t.status==`string`)t.then(tn,tn);else{if(e=Gl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Aa(e),e}throw Oa=t,xa}}function Da(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Oa=e,xa):e}}var Oa=null;function ka(){if(Oa===null)throw Error(i(459));var e=Oa;return Oa=null,e}function Aa(e){if(e===xa||e===Ca)throw Error(i(483))}var ja=null,Ma=0;function Na(e){var t=Ma;return Ma+=1,ja===null&&(ja=[]),Ea(ja,e,t)}function Pa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Fa(e,t){throw t.$$typeof===p?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ia(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=ui(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=z(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===g?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===T&&Da(i)===t.type)?(t=a(t,n.props),Pa(t,n),t.return=e,t):(t=fi(n.type,n.key,n.props,null,e.mode,r),Pa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=hi(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=pi(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=z(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case m:return n=fi(t.type,t.key,t.props,null,e.mode,n),Pa(n,t),n.return=e,n;case h:return t=hi(t,e.mode,n),t.return=e,t;case T:return t=Da(t),f(e,t,n)}if(j(t)||k(t))return t=pi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Na(t),n);if(t.$$typeof===b)return f(e,ta(e,t),n);Fa(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case m:return n.key===i?l(e,t,n,r):null;case h:return n.key===i?u(e,t,n,r):null;case T:return n=Da(n),p(e,t,n,r)}if(j(n)||k(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Na(n),r);if(n.$$typeof===b)return p(e,t,ta(e,n),r);Fa(e,n)}return null}function _(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case m:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case h:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case T:return r=Da(r),_(e,t,n,r,i)}if(j(r)||k(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return _(e,t,n,Na(r),i);if(r.$$typeof===b)return _(e,t,n,ta(t,r),i);Fa(t,r)}return null}function v(i,a,s,c){for(var l=null,u=null,d=a,m=a=0,h=null;d!==null&&m<s.length;m++){d.index>m?(h=d,d=null):h=d.sibling;var g=p(i,d,s[m],c);if(g===null){d===null&&(d=h);break}e&&d&&g.alternate===null&&t(i,d),a=o(g,a,m),u===null?l=g:u.sibling=g,u=g,d=h}if(m===s.length)return n(i,d),Pi&&Di(i,m),l;if(d===null){for(;m<s.length;m++)d=f(i,s[m],c),d!==null&&(a=o(d,a,m),u===null?l=d:u.sibling=d,u=d);return Pi&&Di(i,m),l}for(d=r(d);m<s.length;m++)h=_(d,i,m,s[m],c),h!==null&&(e&&h.alternate!==null&&d.delete(h.key===null?m:h.key),a=o(h,a,m),u===null?l=h:u.sibling=h,u=h);return e&&d.forEach(function(e){return t(i,e)}),Pi&&Di(i,m),l}function y(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,m=s,h=s=0,g=null,v=c.next();m!==null&&!v.done;h++,v=c.next()){m.index>h?(g=m,m=null):g=m.sibling;var y=p(a,m,v.value,l);if(y===null){m===null&&(m=g);break}e&&m&&y.alternate===null&&t(a,m),s=o(y,s,h),d===null?u=y:d.sibling=y,d=y,m=g}if(v.done)return n(a,m),Pi&&Di(a,h),u;if(m===null){for(;!v.done;h++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return Pi&&Di(a,h),u}for(m=r(m);!v.done;h++,v=c.next())v=_(m,a,h,v.value,l),v!==null&&(e&&v.alternate!==null&&m.delete(v.key===null?h:v.key),s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return e&&m.forEach(function(e){return t(a,e)}),Pi&&Di(a,h),u}function x(e,r,o,c){if(typeof o==`object`&&o&&o.type===g&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case m:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===g){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===T&&Da(l)===r.type){n(e,r.sibling),c=a(r,o.props),Pa(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===g?(c=pi(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=fi(o.type,o.key,o.props,null,e.mode,c),Pa(c,o),c.return=e,e=c)}return s(e);case h:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=hi(o,e.mode,c),c.return=e,e=c}return s(e);case T:return o=Da(o),x(e,r,o,c)}if(j(o))return v(e,r,o,c);if(k(o)){if(l=k(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),y(e,r,o,c)}if(typeof o.then==`function`)return x(e,r,Na(o),c);if(o.$$typeof===b)return x(e,r,ta(e,o),c);Fa(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=z(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ma=0;var i=x(e,t,n,r);return ja=null,i}catch(t){if(t===xa||t===Ca)throw t;var a=li(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var La=Ia(!0),Ra=Ia(!1),za=!1;function Ba(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Va(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ha(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ua(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Wl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=oi(e),L(e,null,n),t}return ri(e,r,t,n),oi(e)}function Wa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,$e(e,n)}}function Ga(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ka=!1;function qa(){if(Ka){var e=fa;if(e!==null)throw e}}function Ja(e,t,n,r){Ka=!1;var i=e.updateQueue;za=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var p=s.lane&-536870913,m=p!==s.lane;if(m?(Kl&p)===p:(r&p)===p){p!==0&&p===da&&(Ka=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;p=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,p);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,p=typeof h==`function`?h.call(_,d,p):h,p==null)break a;d=f({},d,p);break a;case 2:za=!0}}p=s.callback,p!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[p]:m.push(p))}else m={lane:p,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=p;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),eu|=o,e.lanes=o,e.memoizedState=d}}function Ya(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Xa(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ya(n[e],t)}var Za=ie(null),Qa=ie(0);function $a(e,t){e=Ql,P(Qa,e),P(Za,t),Ql=e|t.baseLanes}function eo(){P(Qa,Ql),P(Za,Za.current)}function to(){Ql=Qa.current,ae(Za),ae(Qa)}var no=ie(null),ro=null;function io(e){var t=e.alternate;P(lo,lo.current&1),P(no,e),ro===null&&(t===null||Za.current!==null||t.memoizedState!==null)&&(ro=e)}function ao(e){P(lo,lo.current),P(no,e),ro===null&&(ro=e)}function oo(e){e.tag===22?(P(lo,lo.current),P(no,e),ro===null&&(ro=e)):so(e)}function so(){P(lo,lo.current),P(no,no.current)}function co(e){ae(no),ro===e&&(ro=null),ae(lo)}var lo=ie(0);function uo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||hf(n)||gf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var fo=0,po=null,mo=null,ho=null,go=!1,_o=!1,vo=!1,yo=0,bo=0,xo=null,So=0;function Co(){throw Error(i(321))}function wo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!wr(e[n],t[n]))return!1;return!0}function To(e,t,n,r,i,a){return fo=a,po=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,M.H=e===null||e.memoizedState===null?Hs:Us,vo=!1,a=n(r,i),vo=!1,_o&&(a=Do(t,n,r,i)),Eo(e),a}function Eo(e){M.H=Vs;var t=mo!==null&&mo.next!==null;if(fo=0,ho=mo=po=null,go=!1,bo=0,xo=null,t)throw Error(i(300));e===null||oc||(e=e.dependencies,e!==null&&Qi(e)&&(oc=!0))}function Do(e,t,n,r){po=e;var a=0;do{if(_o&&(xo=null),bo=0,_o=!1,25<=a)throw Error(i(301));if(a+=1,ho=mo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}M.H=Ws,o=t(n,r)}while(_o);return o}function Oo(){var e=M.H,t=e.useState()[0];return t=typeof t.then==`function`?Fo(t):t,e=e.useState()[0],(mo===null?null:mo.memoizedState)!==e&&(po.flags|=1024),t}function ko(){var e=yo!==0;return yo=0,e}function Ao(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function jo(e){if(go){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}go=!1}fo=0,ho=mo=po=null,_o=!1,bo=yo=0,xo=null}function Mo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ho===null?po.memoizedState=ho=e:ho=ho.next=e,ho}function No(){if(mo===null){var e=po.alternate;e=e===null?null:e.memoizedState}else e=mo.next;var t=ho===null?po.memoizedState:ho.next;if(t!==null)ho=t,mo=e;else{if(e===null)throw po.alternate===null?Error(i(467)):Error(i(310));mo=e,e={memoizedState:mo.memoizedState,baseState:mo.baseState,baseQueue:mo.baseQueue,queue:mo.queue,next:null},ho===null?po.memoizedState=ho=e:ho=ho.next=e}return ho}function Po(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Fo(e){var t=bo;return bo+=1,xo===null&&(xo=[]),e=Ea(xo,e,t),t=po,(ho===null?t.memoizedState:ho.next)===null&&(t=t.alternate,M.H=t===null||t.memoizedState===null?Hs:Us),e}function Io(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Fo(e);if(e.$$typeof===b)return ea(e)}throw Error(i(438,String(e)))}function Lo(e){var t=null,n=po.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=po.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Po(),po.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=D;return t.index++,n}function Ro(e,t){return typeof t==`function`?t(e):t}function zo(e){return Bo(No(),mo,e)}function Bo(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(fo&f)===f:(Kl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===da&&(d=!0);else if((fo&p)===p){u=u.next,p===da&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,po.lanes|=p,eu|=p;f=u.action,vo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,po.lanes|=f,eu|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!wr(o,e.memoizedState)&&(oc=!0,d&&(n=fa,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Vo(e){var t=No(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);wr(o,t.memoizedState)||(oc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Ho(e,t,n){var r=po,a=No(),o=Pi;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!wr((mo||a).memoizedState,n);if(s&&(a.memoizedState=n,oc=!0),a=a.queue,ps(Go.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||ho!==null&&ho.memoizedState.tag&1){if(r.flags|=2048,cs(9,{destroy:void 0},Wo.bind(null,r,a,n,t),null),Gl===null)throw Error(i(349));o||fo&127||Uo(r,t,n)}return n}function Uo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=po.updateQueue,t===null?(t=Po(),po.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Wo(e,t,n,r){t.value=n,t.getSnapshot=r,Ko(t)&&qo(e)}function Go(e,t,n){return n(function(){Ko(t)&&qo(e)})}function Ko(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!wr(e,n)}catch{return!0}}function qo(e){var t=ai(e,2);t!==null&&Cu(t,e,2)}function Jo(e){var t=Mo();if(typeof e==`function`){var n=e;if(e=n(),vo){Le(!0);try{n()}finally{Le(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ro,lastRenderedState:e},t}function Yo(e,t,n,r){return e.baseState=n,Bo(e,mo,typeof r==`function`?r:Ro)}function Xo(e,t,n,r,a){if(Rs(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};M.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Zo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Zo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=M.T,o={};M.T=o;try{var s=n(i,r),c=M.S;c!==null&&c(o,s),Qo(e,t,s)}catch(n){es(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),M.T=a}}else try{a=n(i,r),Qo(e,t,a)}catch(n){es(e,t,n)}}function Qo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){$o(e,t,n)},function(n){return es(e,t,n)}):$o(e,t,n)}function $o(e,t,n){t.status=`fulfilled`,t.value=n,ts(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Zo(e,n)))}function es(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,ts(t),t=t.next;while(t!==r)}e.action=null}function ts(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function ns(e,t){return t}function rs(e,t){if(Pi){var n=Gl.formState;if(n!==null){a:{var r=po;if(Pi){if(Ni){b:{for(var i=Ni,a=Ii;i.nodeType!==8;){if(!a){i=null;break b}if(i=vf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Ni=vf(i.nextSibling),r=i.data===`F!`;break a}}B(r)}r=!1}r&&(t=n[0])}}return n=Mo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ns,lastRenderedState:t},n.queue=r,n=Fs.bind(null,po,r),r.dispatch=n,r=Jo(!1),a=Ls.bind(null,po,!1,r.queue),r=Mo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Xo.bind(null,po,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function is(e){return as(No(),mo,e)}function as(e,t,n){if(t=Bo(e,t,ns)[0],e=zo(Ro)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Fo(t)}catch(e){throw e===xa?Ca:e}else r=t;t=No();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(po.flags|=2048,cs(9,{destroy:void 0},os.bind(null,i,n),null)),[r,a,e]}function os(e,t){e.action=t}function ss(e){var t=No(),n=mo;if(n!==null)return as(t,n,e);No(),t=t.memoizedState,n=No();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function cs(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=po.updateQueue,t===null&&(t=Po(),po.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function ls(){return No().memoizedState}function us(e,t,n,r){var i=Mo();po.flags|=e,i.memoizedState=cs(1|t,{destroy:void 0},n,r===void 0?null:r)}function ds(e,t,n,r){var i=No();r=r===void 0?null:r;var a=i.memoizedState.inst;mo!==null&&r!==null&&wo(r,mo.memoizedState.deps)?i.memoizedState=cs(t,a,n,r):(po.flags|=e,i.memoizedState=cs(1|t,a,n,r))}function fs(e,t){us(8390656,8,e,t)}function ps(e,t){ds(2048,8,e,t)}function ms(e){po.flags|=4;var t=po.updateQueue;if(t===null)t=Po(),po.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function hs(e){var t=No().memoizedState;return ms({ref:t,nextImpl:e}),function(){if(Wl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function gs(e,t){return ds(4,2,e,t)}function _s(e,t){return ds(4,4,e,t)}function vs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ys(e,t,n){n=n==null?null:n.concat([e]),ds(4,4,vs.bind(null,t,e),n)}function bs(){}function xs(e,t){var n=No();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&wo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Ss(e,t){var n=No();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&wo(t,r[1]))return r[0];if(r=e(),vo){Le(!0);try{e()}finally{Le(!1)}}return n.memoizedState=[r,t],r}function Cs(e,t,n){return n===void 0||fo&1073741824&&!(Kl&261930)?e.memoizedState=t:(e.memoizedState=n,e=Su(),po.lanes|=e,eu|=e,n)}function ws(e,t,n,r){return wr(n,t)?n:Za.current===null?!(fo&42)||fo&1073741824&&!(Kl&261930)?(oc=!0,e.memoizedState=n):(e=Su(),po.lanes|=e,eu|=e,t):(e=Cs(e,n,r),wr(e,t)||(oc=!0),e)}function Ts(e,t,n,r,i){var a=N.p;N.p=a!==0&&8>a?a:8;var o=M.T,s={};M.T=s,Ls(e,!1,t,n);try{var c=i(),l=M.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Is(e,t,ha(c,r),xu(e)):Is(e,t,r,xu(e))}catch(n){Is(e,t,{then:function(){},status:`rejected`,reason:n},xu())}finally{N.p=a,o!==null&&s.types!==null&&(o.types=s.types),M.T=o}}function Es(){}function Ds(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Os(e).queue;Ts(e,a,t,te,n===null?Es:function(){return ks(e),n(r)})}function Os(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:te,baseState:te,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ro,lastRenderedState:te},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ro,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ks(e){var t=Os(e);t.next===null&&(t=e.alternate.memoizedState),Is(e,t.next.queue,{},xu())}function As(){return ea(sp)}function js(){return No().memoizedState}function Ms(){return No().memoizedState}function Ns(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=xu();e=Ha(n);var r=Ua(t,e,n);r!==null&&(Cu(r,t,n),Wa(r,t,n)),t={cache:sa()},e.payload=t;return}t=t.return}}function Ps(e,t,n){var r=xu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Rs(e)?zs(t,n):(n=ii(e,t,n,r),n!==null&&(Cu(n,e,r),Bs(n,t,r)))}function Fs(e,t,n){Is(e,t,n,xu())}function Is(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Rs(e))zs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,wr(s,o))return ri(e,t,i,0),Gl===null&&ni(),!1}catch{}if(n=ii(e,t,i,r),n!==null)return Cu(n,e,r),Bs(n,t,r),!0}return!1}function Ls(e,t,n,r){if(r={lane:2,revertLane:yd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Rs(e)){if(t)throw Error(i(479))}else t=ii(e,n,r,2),t!==null&&Cu(t,e,2)}function Rs(e){var t=e.alternate;return e===po||t!==null&&t===po}function zs(e,t){_o=go=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Bs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,$e(e,n)}}var Vs={readContext:ea,use:Io,useCallback:Co,useContext:Co,useEffect:Co,useImperativeHandle:Co,useLayoutEffect:Co,useInsertionEffect:Co,useMemo:Co,useReducer:Co,useRef:Co,useState:Co,useDebugValue:Co,useDeferredValue:Co,useTransition:Co,useSyncExternalStore:Co,useId:Co,useHostTransitionStatus:Co,useFormState:Co,useActionState:Co,useOptimistic:Co,useMemoCache:Co,useCacheRefresh:Co};Vs.useEffectEvent=Co;var Hs={readContext:ea,use:Io,useCallback:function(e,t){return Mo().memoizedState=[e,t===void 0?null:t],e},useContext:ea,useEffect:fs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),us(4194308,4,vs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return us(4194308,4,e,t)},useInsertionEffect:function(e,t){us(4,2,e,t)},useMemo:function(e,t){var n=Mo();t=t===void 0?null:t;var r=e();if(vo){Le(!0);try{e()}finally{Le(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Mo();if(n!==void 0){var i=n(t);if(vo){Le(!0);try{n(t)}finally{Le(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ps.bind(null,po,e),[r.memoizedState,e]},useRef:function(e){var t=Mo();return e={current:e},t.memoizedState=e},useState:function(e){e=Jo(e);var t=e.queue,n=Fs.bind(null,po,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:bs,useDeferredValue:function(e,t){return Cs(Mo(),e,t)},useTransition:function(){var e=Jo(!1);return e=Ts.bind(null,po,e.queue,!0,!1),Mo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=po,a=Mo();if(Pi){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Gl===null)throw Error(i(349));Kl&127||Uo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,fs(Go.bind(null,r,o,e),[e]),r.flags|=2048,cs(9,{destroy:void 0},Wo.bind(null,r,o,n,t),null),n},useId:function(){var e=Mo(),t=Gl.identifierPrefix;if(Pi){var n=Ei,r=Ti;n=(r&~(1<<32-Re(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=yo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=So++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:As,useFormState:rs,useActionState:rs,useOptimistic:function(e){var t=Mo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Ls.bind(null,po,!0,n),n.dispatch=t,[e,t]},useMemoCache:Lo,useCacheRefresh:function(){return Mo().memoizedState=Ns.bind(null,po)},useEffectEvent:function(e){var t=Mo(),n={impl:e};return t.memoizedState=n,function(){if(Wl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Us={readContext:ea,use:Io,useCallback:xs,useContext:ea,useEffect:ps,useImperativeHandle:ys,useInsertionEffect:gs,useLayoutEffect:_s,useMemo:Ss,useReducer:zo,useRef:ls,useState:function(){return zo(Ro)},useDebugValue:bs,useDeferredValue:function(e,t){return ws(No(),mo.memoizedState,e,t)},useTransition:function(){var e=zo(Ro)[0],t=No().memoizedState;return[typeof e==`boolean`?e:Fo(e),t]},useSyncExternalStore:Ho,useId:js,useHostTransitionStatus:As,useFormState:is,useActionState:is,useOptimistic:function(e,t){return Yo(No(),mo,e,t)},useMemoCache:Lo,useCacheRefresh:Ms};Us.useEffectEvent=hs;var Ws={readContext:ea,use:Io,useCallback:xs,useContext:ea,useEffect:ps,useImperativeHandle:ys,useInsertionEffect:gs,useLayoutEffect:_s,useMemo:Ss,useReducer:Vo,useRef:ls,useState:function(){return Vo(Ro)},useDebugValue:bs,useDeferredValue:function(e,t){var n=No();return mo===null?Cs(n,e,t):ws(n,mo.memoizedState,e,t)},useTransition:function(){var e=Vo(Ro)[0],t=No().memoizedState;return[typeof e==`boolean`?e:Fo(e),t]},useSyncExternalStore:Ho,useId:js,useHostTransitionStatus:As,useFormState:ss,useActionState:ss,useOptimistic:function(e,t){var n=No();return mo===null?(n.baseState=e,[e,n.queue.dispatch]):Yo(n,mo,e,t)},useMemoCache:Lo,useCacheRefresh:Ms};Ws.useEffectEvent=hs;function Gs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:f({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ks={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=xu(),i=Ha(r);i.payload=t,n!=null&&(i.callback=n),t=Ua(e,i,r),t!==null&&(Cu(t,e,r),Wa(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=xu(),i=Ha(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ua(e,i,r),t!==null&&(Cu(t,e,r),Wa(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=xu(),r=Ha(n);r.tag=2,t!=null&&(r.callback=t),t=Ua(e,r,n),t!==null&&(Cu(t,e,n),Wa(t,e,n))}};function qs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Tr(n,r)||!Tr(i,a):!0}function Js(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Ks.enqueueReplaceState(t,t.state,null)}function Ys(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=f({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Xs(e){Qr(e)}function Zs(e){console.error(e)}function Qs(e){Qr(e)}function $s(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function ec(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function tc(e,t,n){return n=Ha(n),n.tag=3,n.payload={element:null},n.callback=function(){$s(e,t)},n}function nc(e){return e=Ha(e),e.tag=3,e}function rc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){ec(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){ec(t,n,r),typeof i!=`function`&&(fu===null?fu=new Set([this]):fu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function ic(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Zi(t,n,a,!0),n=no.current,n!==null){switch(n.tag){case 31:case 13:return ro===null?Pu():n.alternate===null&&$l===0&&($l=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===wa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),$u(e,r,a)),!1;case 22:return n.flags|=65536,r===wa?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),$u(e,r,a)),!1}throw Error(i(435,n.tag))}return $u(e,r,a),Pu(),!1}if(Pi)return t=no.current,t===null?(r!==Li&&(t=Error(i(423),{cause:r}),Ui(_i(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=_i(r,n),a=tc(e.stateNode,r,a),Ga(e,a),$l!==4&&($l=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Li&&(e=Error(i(422),{cause:r}),Ui(_i(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=_i(o,n),au===null?au=[o]:au.push(o),$l!==4&&($l=2),t===null)return!0;r=_i(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=tc(n.stateNode,r,e),Ga(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(fu===null||!fu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=nc(a),rc(a,e,n,r),Ga(n,a),!1}n=n.return}while(n!==null);return!1}var ac=Error(i(461)),oc=!1;function sc(e,t,n,r){t.child=e===null?Ra(t,null,n,r):La(t,e.child,n,r)}function cc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return $i(t),r=To(e,t,n,o,a,i),s=ko(),e!==null&&!oc?(Ao(e,t,i),Mc(e,t,i)):(Pi&&s&&ki(t),t.flags|=1,sc(e,t,r,i),t.child)}function lc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!R(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,uc(e,t,a,r,i)):(e=fi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Nc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Tr:n,n(o,r)&&e.ref===t.ref)return Mc(e,t,i)}return t.flags|=1,e=ui(a,r),e.ref=t.ref,e.return=t,t.child=e}function uc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Tr(a,r)&&e.ref===t.ref)if(oc=!1,t.pendingProps=r=a,Nc(e,i))e.flags&131072&&(oc=!0);else return t.lanes=e.lanes,Mc(e,t,i)}return vc(e,t,n,r,i)}function dc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return pc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ya(t,a===null?null:a.cachePool),a===null?eo():$a(t,a),oo(t);else return r=t.lanes=536870912,pc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ya(t,null),eo(),so(t)):(ya(t,a.cachePool),$a(t,a),so(t),t.memoizedState=null);return sc(e,t,i,n),t.child}function fc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function pc(e,t,n,r,i){var a=va();return a=a===null?null:{parent:oa._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ya(t,null),eo(),oo(t),e!==null&&Zi(e,t,r,!0),t.childLanes=i,null}function mc(e,t){return t=Dc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function hc(e,t,n){return La(t,e.child,null,n),e=mc(t,t.pendingProps),e.flags|=2,co(t),t.memoizedState=null,e}function gc(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Pi){if(r.mode===`hidden`)return e=mc(t,r),t.lanes=536870912,fc(null,e);if(ao(t),(e=Ni)?(e=mf(e,Ii),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:wi===null?null:{id:Ti,overflow:Ei},retryLane:536870912,hydrationErrors:null},n=mi(e),n.return=t,t.child=n,Mi=t,Ni=null)):e=null,e===null)throw B(t);return t.lanes=536870912,null}return mc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(ao(t),a)if(t.flags&256)t.flags&=-257,t=hc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(oc||Zi(e,t,n,!1),a=(n&e.childLanes)!==0,oc||a){if(r=Gl,r!==null&&(s=et(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,ai(e,s),Cu(r,e,s),ac;Pu(),t=hc(e,t,n)}else e=o.treeContext,Ni=vf(s.nextSibling),Mi=t,Pi=!0,Fi=null,Ii=!1,e!==null&&ji(t,e),t=mc(t,r),t.flags|=4096;return t}return e=ui(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function _c(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function vc(e,t,n,r,i){return $i(t),n=To(e,t,n,r,void 0,i),r=ko(),e!==null&&!oc?(Ao(e,t,i),Mc(e,t,i)):(Pi&&r&&ki(t),t.flags|=1,sc(e,t,n,i),t.child)}function yc(e,t,n,r,i,a){return $i(t),t.updateQueue=null,n=Do(t,r,n,i),Eo(e),r=ko(),e!==null&&!oc?(Ao(e,t,a),Mc(e,t,a)):(Pi&&r&&ki(t),t.flags|=1,sc(e,t,n,a),t.child)}function bc(e,t,n,r,i){if($i(t),t.stateNode===null){var a=si,o=n.contextType;typeof o==`object`&&o&&(a=ea(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Ks,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Ba(t),o=n.contextType,a.context=typeof o==`object`&&o?ea(o):si,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Gs(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Ks.enqueueReplaceState(a,a.state,null),Ja(t,r,a,i),qa(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Ys(n,s);a.props=c;var l=a.context,u=n.contextType;o=si,typeof u==`object`&&u&&(o=ea(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Js(t,a,r,o),za=!1;var f=t.memoizedState;a.state=f,Ja(t,r,a,i),qa(),l=t.memoizedState,s||f!==l||za?(typeof d==`function`&&(Gs(t,n,d,r),l=t.memoizedState),(c=za||qs(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Va(e,t),o=t.memoizedProps,u=Ys(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=si,typeof l==`object`&&l&&(c=ea(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Js(t,a,r,c),za=!1,f=t.memoizedState,a.state=f,Ja(t,r,a,i),qa();var p=t.memoizedState;o!==d||f!==p||za||e!==null&&e.dependencies!==null&&Qi(e.dependencies)?(typeof s==`function`&&(Gs(t,n,s,r),p=t.memoizedState),(u=za||qs(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Qi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,_c(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=La(t,e.child,null,i),t.child=La(t,null,n,i)):sc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Mc(e,t,i),e}function xc(e,t,n,r){return Vi(),t.flags|=256,sc(e,t,n,r),t.child}var Sc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Cc(e){return{baseLanes:e,cachePool:ba()}}function wc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=ru),e}function Tc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(lo.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Pi){if(a?io(t):so(t),(e=Ni)?(e=mf(e,Ii),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:wi===null?null:{id:Ti,overflow:Ei},retryLane:536870912,hydrationErrors:null},n=mi(e),n.return=t,t.child=n,Mi=t,Ni=null)):e=null,e===null)throw B(t);return gf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(so(t),a=t.mode,c=Dc({mode:`hidden`,children:c},a),r=pi(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=Cc(n),r.childLanes=wc(e,s,n),t.memoizedState=Sc,fc(null,r)):(io(t),Ec(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(io(t),t.flags&=-257,t=Oc(e,t,n)):t.memoizedState===null?(so(t),c=r.fallback,a=t.mode,r=Dc({mode:`visible`,children:r.children},a),c=pi(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,La(t,e.child,null,n),r=t.child,r.memoizedState=Cc(n),r.childLanes=wc(e,s,n),t.memoizedState=Sc,t=fc(null,r)):(so(t),t.child=e.child,t.flags|=128,t=null);else if(io(t),gf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Ui({value:r,source:null,stack:null}),t=Oc(e,t,n)}else if(oc||Zi(e,t,n,!1),s=(n&e.childLanes)!==0,oc||s){if(s=Gl,s!==null&&(r=et(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,ai(e,r),Cu(s,e,r),ac;hf(c)||Pu(),t=Oc(e,t,n)}else hf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Ni=vf(c.nextSibling),Mi=t,Pi=!0,Fi=null,Ii=!1,e!==null&&ji(t,e),t=Ec(t,r.children),t.flags|=4096);return t}return a?(so(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=ui(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=pi(c,a,n,null),c.flags|=2):c=ui(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,fc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=Cc(n):(a=c.cachePool,a===null?a=ba():(l=oa._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=wc(e,s,n),t.memoizedState=Sc,fc(e.child,r)):(io(t),n=e.child,e=n.sibling,n=ui(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function Ec(e,t){return t=Dc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Dc(e,t){return e=li(22,e,null,t),e.lanes=0,e}function Oc(e,t,n){return La(t,e.child,null,n),e=Ec(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function kc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Yi(e.return,t,n)}function Ac(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function jc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=lo.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,P(lo,o),sc(e,t,r,n),r=Pi?xi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&kc(e,n,t);else if(e.tag===19)kc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&uo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Ac(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&uo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Ac(t,!0,n,null,a,r);break;case`together`:Ac(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Mc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),eu|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Zi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=ui(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ui(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Nc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Qi(e))):!0}function Pc(e,t,n){switch(t.tag){case 3:ue(t,t.stateNode.containerInfo),qi(t,oa,e.memoizedState.cache),Vi();break;case 27:case 5:fe(t);break;case 4:ue(t,t.stateNode.containerInfo);break;case 10:qi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,ao(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(io(t),e=Mc(e,t,n),e===null?null:e.sibling):Tc(e,t,n):(io(t),t.flags|=128,null);io(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Zi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return jc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),P(lo,lo.current),r)break;return null;case 22:return t.lanes=0,dc(e,t,n,t.pendingProps);case 24:qi(t,oa,e.memoizedState.cache)}return Mc(e,t,n)}function Fc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)oc=!0;else{if(!Nc(e,n)&&!(t.flags&128))return oc=!1,Pc(e,t,n);oc=!!(e.flags&131072)}else oc=!1,Pi&&t.flags&1048576&&Oi(t,xi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Da(t.elementType),t.type=e,typeof e==`function`)R(e)?(r=Ys(e,r),t.tag=1,t=bc(null,t,e,r,n)):(t.tag=0,t=vc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===x){t.tag=11,t=cc(null,t,e,r,n);break a}else if(a===w){t.tag=14,t=lc(null,t,e,r,n);break a}}throw t=A(e)||e,Error(i(306,t,``))}}return t;case 0:return vc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Ys(r,t.pendingProps),bc(e,t,r,a,n);case 3:a:{if(ue(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Va(e,t),Ja(t,r,null,n);var s=t.memoizedState;if(r=s.cache,qi(t,oa,r),r!==o.cache&&Xi(t,[oa],n,!0),qa(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=xc(e,t,r,n);break a}else if(r!==a){a=_i(Error(i(424)),t),Ui(a),t=xc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Ni=vf(e.firstChild),Mi=t,Pi=!0,Fi=null,Ii=!0,n=Ra(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Vi(),r===a){t=Mc(e,t,n);break a}sc(e,t,r,n)}t=t.child}return t;case 26:return _c(e,t),e===null?(n=Rf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Pi||(n=t.type,e=t.pendingProps,r=Xd(ce.current).createElement(n),r[ot]=t,r[st]=e,Wd(r,n,e),yt(r),t.stateNode=r):t.memoizedState=Rf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return fe(t),e===null&&Pi&&(r=t.stateNode=Sf(t.type,t.pendingProps,ce.current),Mi=t,Ii=!0,a=Ni,cf(t.type)?(yf=a,Ni=vf(r.firstChild)):Ni=a),sc(e,t,t.pendingProps.children,n),_c(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Pi&&((a=r=Ni)&&(r=ff(r,t.type,t.pendingProps,Ii),r===null?a=!1:(t.stateNode=r,Mi=t,Ni=vf(r.firstChild),Ii=!1,a=!0)),a||B(t)),fe(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,$d(a,o)?r=null:s!==null&&$d(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=To(e,t,Oo,null,null,n),sp._currentValue=a),_c(e,t),sc(e,t,r,n),t.child;case 6:return e===null&&Pi&&((e=n=Ni)&&(n=pf(n,t.pendingProps,Ii),n===null?e=!1:(t.stateNode=n,Mi=t,Ni=null,e=!0)),e||B(t)),null;case 13:return Tc(e,t,n);case 4:return ue(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=La(t,null,r,n):sc(e,t,r,n),t.child;case 11:return cc(e,t,t.type,t.pendingProps,n);case 7:return sc(e,t,t.pendingProps,n),t.child;case 8:return sc(e,t,t.pendingProps.children,n),t.child;case 12:return sc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,qi(t,t.type,r.value),sc(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,$i(t),a=ea(a),r=r(a),t.flags|=1,sc(e,t,r,n),t.child;case 14:return lc(e,t,t.type,t.pendingProps,n);case 15:return uc(e,t,t.type,t.pendingProps,n);case 19:return jc(e,t,n);case 31:return gc(e,t,n);case 22:return dc(e,t,n,t.pendingProps);case 24:return $i(t),r=ea(oa),e===null?(a=va(),a===null&&(a=Gl,o=sa(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Ba(t),qi(t,oa,a)):((e.lanes&n)!==0&&(Va(e,t),Ja(t,null,null,n),qa()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,qi(t,oa,r),r!==a.cache&&Xi(t,[oa],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),qi(t,oa,r))),sc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Ic(e){e.flags|=4}function Lc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(ju())e.flags|=8192;else throw Oa=wa,Sa}else e.flags&=-16777217}function Rc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!$f(t))if(ju())e.flags|=8192;else throw Oa=wa,Sa}function zc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Je(),e.lanes|=t,iu|=t)}function Bc(e,t){if(!Pi)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Vc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Hc(e,t,n){var r=t.pendingProps;switch(Ai(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Vc(t),null;case 1:return Vc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Ji(oa),de(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Bi(t)?Ic(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Hi())),Vc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Ic(t),o===null?(Vc(t),Lc(t,a,null,r,n)):(Vc(t),Rc(t,o))):o?o===e.memoizedState?(Vc(t),t.flags&=-16777217):(Ic(t),Vc(t),Rc(t,o)):(e=e.memoizedProps,e!==r&&Ic(t),Vc(t),Lc(t,a,e,r,n)),null;case 27:if(pe(t),n=ce.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Ic(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Vc(t),null}e=oe.current,Bi(t)?Ri(t,e):(e=Sf(a,r,n),t.stateNode=e,Ic(t))}return Vc(t),null;case 5:if(pe(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Ic(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Vc(t),null}if(o=oe.current,Bi(t))Ri(t,o);else{var s=Xd(ce.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[ot]=t,o[st]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Wd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Ic(t)}}return Vc(t),Lc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Ic(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ce.current,Bi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Mi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[ot]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Vd(e.nodeValue,n)),e||B(t,!0)}else e=Xd(e).createTextNode(r),e[ot]=t,t.stateNode=e}return Vc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Bi(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[ot]=t}else Vi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Vc(t),e=!1}else n=Hi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(co(t),t):(co(t),null);if(t.flags&128)throw Error(i(558))}return Vc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Bi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[ot]=t}else Vi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Vc(t),a=!1}else a=Hi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(co(t),t):(co(t),null)}return co(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),zc(t,t.updateQueue),Vc(t),null);case 4:return de(),e===null&&jd(t.stateNode.containerInfo),Vc(t),null;case 10:return Ji(t.type),Vc(t),null;case 19:if(ae(lo),r=t.memoizedState,r===null)return Vc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Bc(r,!1);else{if($l!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=uo(e),o!==null){for(t.flags|=128,Bc(r,!1),e=o.updateQueue,t.updateQueue=e,zc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)di(n,e),n=n.sibling;return P(lo,lo.current&1|2),Pi&&Di(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ee()>uu&&(t.flags|=128,a=!0,Bc(r,!1),t.lanes=4194304)}else{if(!a)if(e=uo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,zc(t,e),Bc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Pi)return Vc(t),null}else 2*Ee()-r.renderingStartTime>uu&&n!==536870912&&(t.flags|=128,a=!0,Bc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Vc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ee(),e.sibling=null,n=lo.current,P(lo,a?n&1|2:n&1),Pi&&Di(t,r.treeForkCount),e);case 22:case 23:return co(t),to(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Vc(t),t.subtreeFlags&6&&(t.flags|=8192)):Vc(t),n=t.updateQueue,n!==null&&zc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&ae(_a),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ji(oa),Vc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Uc(e,t){switch(Ai(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ji(oa),de(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return pe(t),null;case 31:if(t.memoizedState!==null){if(co(t),t.alternate===null)throw Error(i(340));Vi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(co(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Vi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ae(lo),null;case 4:return de(),null;case 10:return Ji(t.type),null;case 22:case 23:return co(t),to(),e!==null&&ae(_a),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ji(oa),null;case 25:return null;default:return null}}function Wc(e,t){switch(Ai(t),t.tag){case 3:Ji(oa),de();break;case 26:case 27:case 5:pe(t);break;case 4:de();break;case 31:t.memoizedState!==null&&co(t);break;case 13:co(t);break;case 19:ae(lo);break;case 10:Ji(t.type);break;case 22:case 23:co(t),to(),e!==null&&ae(_a);break;case 24:Ji(oa)}}function Gc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Qu(t,t.return,e)}}function Kc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Qu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Qu(t,t.return,e)}}function qc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Xa(t,n)}catch(t){Qu(e,e.return,t)}}}function Jc(e,t,n){n.props=Ys(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Qu(e,t,n)}}function Yc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Qu(e,t,n)}}function Xc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Qu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Qu(e,t,n)}else n.current=null}function Zc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Qu(e,e.return,t)}}function Qc(e,t,n){try{var r=e.stateNode;Gd(r,e.type,n,t),r[st]=t}catch(t){Qu(e,e.return,t)}}function $c(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&cf(e.type)||e.tag===4}function el(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||$c(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&cf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function tl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=tn));else if(r!==4&&(r===27&&cf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(tl(e,t,n),e=e.sibling;e!==null;)tl(e,t,n),e=e.sibling}function nl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&cf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(nl(e,t,n),e=e.sibling;e!==null;)nl(e,t,n),e=e.sibling}function rl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Wd(t,r,n),t[ot]=e,t[st]=n}catch(t){Qu(e,e.return,t)}}var il=!1,al=!1,ol=!1,sl=typeof WeakSet==`function`?WeakSet:Set,cl=null;function ll(e,t){if(e=e.containerInfo,Jd=gp,e=kr(e),Ar(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Yd={focusedElem:e,selectionRange:n},gp=!1,cl=t;cl!==null;)if(t=cl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,cl=e;else for(;cl!==null;){switch(t=cl,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Ys(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Qu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)df(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:df(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,cl=e;break}cl=t.return}}function ul(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Tl(e,n),r&4&&Gc(5,n);break;case 1:if(Tl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Qu(n,n.return,e)}else{var i=Ys(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Qu(n,n.return,e)}}r&64&&qc(n),r&512&&Yc(n,n.return);break;case 3:if(Tl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Xa(e,t)}catch(e){Qu(n,n.return,e)}}break;case 27:t===null&&r&4&&rl(n);case 26:case 5:Tl(e,n),t===null&&r&4&&Zc(n),r&512&&Yc(n,n.return);break;case 12:Tl(e,n);break;case 31:Tl(e,n),r&4&&gl(e,n);break;case 13:Tl(e,n),r&4&&_l(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=nd.bind(null,n),_f(e,n))));break;case 22:if(r=n.memoizedState!==null||il,!r){t=t!==null&&t.memoizedState!==null||al,i=il;var a=al;il=r,(al=t)&&!a?Dl(e,n,(n.subtreeFlags&8772)!=0):Tl(e,n),il=i,al=a}break;case 30:break;default:Tl(e,n)}}function dl(e){var t=e.alternate;t!==null&&(e.alternate=null,dl(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&mt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var fl=null,pl=!1;function ml(e,t,n){for(n=n.child;n!==null;)hl(e,t,n),n=n.sibling}function hl(e,t,n){if(Ie&&typeof Ie.onCommitFiberUnmount==`function`)try{Ie.onCommitFiberUnmount(Fe,n)}catch{}switch(n.tag){case 26:al||Xc(n,t),ml(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:al||Xc(n,t);var r=fl,i=pl;cf(n.type)&&(fl=n.stateNode,pl=!1),ml(e,t,n),Cf(n.stateNode),fl=r,pl=i;break;case 5:al||Xc(n,t);case 6:if(r=fl,i=pl,fl=null,ml(e,t,n),fl=r,pl=i,fl!==null)if(pl)try{(fl.nodeType===9?fl.body:fl.nodeName===`HTML`?fl.ownerDocument.body:fl).removeChild(n.stateNode)}catch(e){Qu(n,t,e)}else try{fl.removeChild(n.stateNode)}catch(e){Qu(n,t,e)}break;case 18:fl!==null&&(pl?(e=fl,lf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Vp(e)):lf(fl,n.stateNode));break;case 4:r=fl,i=pl,fl=n.stateNode.containerInfo,pl=!0,ml(e,t,n),fl=r,pl=i;break;case 0:case 11:case 14:case 15:Kc(2,n,t),al||Kc(4,n,t),ml(e,t,n);break;case 1:al||(Xc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Jc(n,t,r)),ml(e,t,n);break;case 21:ml(e,t,n);break;case 22:al=(r=al)||n.memoizedState!==null,ml(e,t,n),al=r;break;default:ml(e,t,n)}}function gl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Vp(e)}catch(e){Qu(t,t.return,e)}}}function _l(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Vp(e)}catch(e){Qu(t,t.return,e)}}function vl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new sl),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new sl),t;default:throw Error(i(435,e.tag))}}function yl(e,t){var n=vl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=rd.bind(null,e,t);t.then(r,r)}})}function bl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(cf(c.type)){fl=c.stateNode,pl=!1;break a}break;case 5:fl=c.stateNode,pl=!1;break a;case 3:case 4:fl=c.stateNode.containerInfo,pl=!0;break a}c=c.return}if(fl===null)throw Error(i(160));hl(o,s,a),fl=null,pl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Sl(t,e),t=t.sibling}var xl=null;function Sl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:bl(t,e),Cl(e),r&4&&(Kc(3,e,e.return),Gc(3,e),Kc(5,e,e.return));break;case 1:bl(t,e),Cl(e),r&512&&(al||n===null||Xc(n,n.return)),r&64&&il&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=xl;if(bl(t,e),Cl(e),r&512&&(al||n===null||Xc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[pt]||o[ot]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Wd(o,r,n),o[ot]=e,yt(o),r=o;break a;case`link`:var s=Xf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Wd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Xf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Wd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[ot]=e,yt(o),r=o}e.stateNode=r}else Zf(a,e.type,e.stateNode);else e.stateNode=Gf(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Qc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Zf(a,e.type,e.stateNode):Gf(a,r,e.memoizedProps))}break;case 27:bl(t,e),Cl(e),r&512&&(al||n===null||Xc(n,n.return)),n!==null&&r&4&&Qc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(bl(t,e),Cl(e),r&512&&(al||n===null||Xc(n,n.return)),e.flags&32){a=e.stateNode;try{qt(a,``)}catch(t){Qu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Qc(e,a,n===null?a:n.memoizedProps)),r&1024&&(ol=!0);break;case 6:if(bl(t,e),Cl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Qu(e,e.return,t)}}break;case 3:if(Yf=null,a=xl,xl=Tf(t.containerInfo),bl(t,e),xl=a,Cl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Vp(t.containerInfo)}catch(t){Qu(e,e.return,t)}ol&&(ol=!1,wl(e));break;case 4:r=xl,xl=Tf(e.stateNode.containerInfo),bl(t,e),Cl(e),xl=r;break;case 12:bl(t,e),Cl(e);break;case 31:bl(t,e),Cl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,yl(e,r)));break;case 13:bl(t,e),Cl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(cu=Ee()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,yl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=il,d=al;if(il=u||a,al=d||l,bl(t,e),al=d,il=u,Cl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||il||al||El(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Qu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Qu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?uf(m,!0):uf(l.stateNode,!1)}catch(e){Qu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,yl(e,n))));break;case 19:bl(t,e),Cl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,yl(e,r)));break;case 30:break;case 21:break;default:bl(t,e),Cl(e)}}function Cl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if($c(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;nl(e,el(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(qt(o,``),n.flags&=-33),nl(e,el(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;tl(e,el(e),s);break;default:throw Error(i(161))}}catch(t){Qu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function wl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;wl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Tl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)ul(e,t.alternate,t),t=t.sibling}function El(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Kc(4,t,t.return),El(t);break;case 1:Xc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Jc(t,t.return,n),El(t);break;case 27:Cf(t.stateNode);case 26:case 5:Xc(t,t.return),El(t);break;case 22:t.memoizedState===null&&El(t);break;case 30:El(t);break;default:El(t)}e=e.sibling}}function Dl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:Dl(i,a,n),Gc(4,a);break;case 1:if(Dl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Qu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ya(c[i],s)}catch(e){Qu(r,r.return,e)}}n&&o&64&&qc(a),Yc(a,a.return);break;case 27:rl(a);case 26:case 5:Dl(i,a,n),n&&r===null&&o&4&&Zc(a),Yc(a,a.return);break;case 12:Dl(i,a,n);break;case 31:Dl(i,a,n),n&&o&4&&gl(i,a);break;case 13:Dl(i,a,n),n&&o&4&&_l(i,a);break;case 22:a.memoizedState===null&&Dl(i,a,n),Yc(a,a.return);break;case 30:break;default:Dl(i,a,n)}t=t.sibling}}function Ol(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&ca(n))}function kl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ca(e))}function Al(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)jl(e,t,n,r),t=t.sibling}function jl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Al(e,t,n,r),i&2048&&Gc(9,t);break;case 1:Al(e,t,n,r);break;case 3:Al(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ca(e)));break;case 12:if(i&2048){Al(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Qu(t,t.return,e)}}else Al(e,t,n,r);break;case 31:Al(e,t,n,r);break;case 13:Al(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?Al(e,t,n,r):(a._visibility|=2,Ml(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?Al(e,t,n,r):Nl(e,t),i&2048&&Ol(o,t);break;case 24:Al(e,t,n,r),i&2048&&kl(t.alternate,t);break;default:Al(e,t,n,r)}}function Ml(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Ml(a,o,s,c,i),Gc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Ml(a,o,s,c,i)):u._visibility&2?Ml(a,o,s,c,i):Nl(a,o),i&&l&2048&&Ol(o.alternate,o);break;case 24:Ml(a,o,s,c,i),i&&l&2048&&kl(o.alternate,o);break;default:Ml(a,o,s,c,i)}t=t.sibling}}function Nl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Nl(n,r),i&2048&&Ol(r.alternate,r);break;case 24:Nl(n,r),i&2048&&kl(r.alternate,r);break;default:Nl(n,r)}t=t.sibling}}var Pl=8192;function Fl(e,t,n){if(e.subtreeFlags&Pl)for(e=e.child;e!==null;)Il(e,t,n),e=e.sibling}function Il(e,t,n){switch(e.tag){case 26:Fl(e,t,n),e.flags&Pl&&e.memoizedState!==null&&ep(n,xl,e.memoizedState,e.memoizedProps);break;case 5:Fl(e,t,n);break;case 3:case 4:var r=xl;xl=Tf(e.stateNode.containerInfo),Fl(e,t,n),xl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Pl,Pl=16777216,Fl(e,t,n),Pl=r):Fl(e,t,n));break;default:Fl(e,t,n)}}function Ll(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Rl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];cl=r,Vl(r,e)}Ll(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)zl(e),e=e.sibling}function zl(e){switch(e.tag){case 0:case 11:case 15:Rl(e),e.flags&2048&&Kc(9,e,e.return);break;case 3:Rl(e);break;case 12:Rl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Bl(e)):Rl(e);break;default:Rl(e)}}function Bl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];cl=r,Vl(r,e)}Ll(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Kc(8,t,t.return),Bl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Bl(t));break;default:Bl(t)}e=e.sibling}}function Vl(e,t){for(;cl!==null;){var n=cl;switch(n.tag){case 0:case 11:case 15:Kc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:ca(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,cl=r;else a:for(n=e;cl!==null;){r=cl;var i=r.sibling,a=r.return;if(dl(r),r===n){cl=null;break a}if(i!==null){i.return=a,cl=i;break a}cl=a}}}var Hl={getCacheForType:function(e){var t=ea(oa),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return ea(oa).controller.signal}},Ul=typeof WeakMap==`function`?WeakMap:Map,Wl=0,Gl=null,V=null,Kl=0,ql=0,Jl=null,Yl=!1,Xl=!1,Zl=!1,Ql=0,$l=0,eu=0,tu=0,nu=0,ru=0,iu=0,au=null,ou=null,su=!1,cu=0,lu=0,uu=1/0,du=null,fu=null,H=0,pu=null,mu=null,hu=0,gu=0,_u=null,vu=null,yu=0,bu=null;function xu(){return Wl&2&&Kl!==0?Kl&-Kl:M.T===null?rt():yd()}function Su(){if(ru===0)if(!(Kl&536870912)||Pi){var e=Ue;Ue<<=1,!(Ue&3932160)&&(Ue=262144),ru=e}else ru=536870912;return e=no.current,e!==null&&(e.flags|=32),ru}function Cu(e,t,n){(e===Gl&&(ql===2||ql===9)||e.cancelPendingCommit!==null)&&(ku(e,0),Eu(e,Kl,ru,!1)),Xe(e,n),(!(Wl&2)||e!==Gl)&&(e===Gl&&(!(Wl&2)&&(tu|=n),$l===4&&Eu(e,Kl,ru,!1)),dd(e))}function wu(e,t,n){if(Wl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||F(e,t),a=r?Lu(e,t):Fu(e,t,!0),o=r;do{if(a===0){Xl&&!r&&Eu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!U(n)){a=Fu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=au;var l=c.current.memoizedState.isDehydrated;if(l&&(ku(c,s).flags|=256),s=Fu(c,s,!1),s!==2){if(Zl&&!l){c.errorRecoveryDisabledLanes|=o,tu|=o,a=4;break a}o=ou,ou=a,o!==null&&(ou===null?ou=o:ou.push.apply(ou,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){ku(e,0),Eu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:Eu(r,t,ru,!Yl);break a;case 2:ou=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=cu+300-Ee(),10<a)){if(Eu(r,t,ru,!Yl),qe(r,0,!0)!==0)break a;hu=t,r.timeoutHandle=nf(Tu.bind(null,r,n,ou,du,su,t,ru,tu,iu,Yl,o,`Throttled`,-0,0),a);break a}Tu(r,n,ou,du,su,t,ru,tu,iu,Yl,o,null,-0,0)}}break}while(1);dd(e)}function Tu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:tn},Il(t,a,d);var m=(a&62914560)===a?cu-Ee():(a&4194048)===a?lu-Ee():0;if(m=np(d,m),m!==null){hu=a,e.cancelPendingCommit=m(Wu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),Eu(e,a,o,!l);return}}Wu(e,t,a,n,r,i,o,s,c)}function U(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!wr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Eu(e,t,n,r){t&=~nu,t&=~tu,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Re(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&Qe(e,n,t)}function Du(){return Wl&6?!0:(fd(0,!1),!1)}function Ou(){if(V!==null){if(ql===0)var e=V.return;else e=V,Ki=Gi=null,jo(e),ja=null,Ma=0,e=V;for(;e!==null;)Wc(e.alternate,e),e=e.return;V=null}}function ku(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,rf(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),hu=0,Ou(),Gl=e,V=n=ui(e.current,null),Kl=t,ql=0,Jl=null,Yl=!1,Xl=F(e,t),Zl=!1,iu=ru=nu=tu=eu=$l=0,ou=au=null,su=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Re(r),a=1<<i;t|=e[i],r&=~a}return Ql=t,ni(),n}function Au(e,t){po=null,M.H=Vs,t===xa||t===Ca?(t=ka(),ql=3):t===Sa?(t=ka(),ql=4):ql=t===ac?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Jl=t,V===null&&($l=1,$s(e,_i(t,e.current)))}function ju(){var e=no.current;return e===null?!0:(Kl&4194048)===Kl?ro===null:(Kl&62914560)===Kl||Kl&536870912?e===ro:!1}function Mu(){var e=M.H;return M.H=Vs,e===null?Vs:e}function Nu(){var e=M.A;return M.A=Hl,e}function Pu(){$l=4,Yl||(Kl&4194048)!==Kl&&no.current!==null||(Xl=!0),!(eu&134217727)&&!(tu&134217727)||Gl===null||Eu(Gl,Kl,ru,!1)}function Fu(e,t,n){var r=Wl;Wl|=2;var i=Mu(),a=Nu();(Gl!==e||Kl!==t)&&(du=null,ku(e,t)),t=!1;var o=$l;a:do try{if(ql!==0&&V!==null){var s=V,c=Jl;switch(ql){case 8:Ou(),o=6;break a;case 3:case 2:case 9:case 6:no.current===null&&(t=!0);var l=ql;if(ql=0,Jl=null,Vu(e,s,c,l),n&&Xl){o=0;break a}break;default:l=ql,ql=0,Jl=null,Vu(e,s,c,l)}}Iu(),o=$l;break}catch(t){Au(e,t)}while(1);return t&&e.shellSuspendCounter++,Ki=Gi=null,Wl=r,M.H=i,M.A=a,V===null&&(Gl=null,Kl=0,ni()),o}function Iu(){for(;V!==null;)zu(V)}function Lu(e,t){var n=Wl;Wl|=2;var r=Mu(),a=Nu();Gl!==e||Kl!==t?(du=null,uu=Ee()+500,ku(e,t)):Xl=F(e,t);a:do try{if(ql!==0&&V!==null){t=V;var o=Jl;b:switch(ql){case 1:ql=0,Jl=null,Vu(e,t,o,1);break;case 2:case 9:if(Ta(o)){ql=0,Jl=null,Bu(t);break}t=function(){ql!==2&&ql!==9||Gl!==e||(ql=7),dd(e)},o.then(t,t);break a;case 3:ql=7;break a;case 4:ql=5;break a;case 7:Ta(o)?(ql=0,Jl=null,Bu(t)):(ql=0,Jl=null,Vu(e,t,o,7));break;case 5:var s=null;switch(V.tag){case 26:s=V.memoizedState;case 5:case 27:var c=V;if(s?$f(s):c.stateNode.complete){ql=0,Jl=null;var l=c.sibling;if(l!==null)V=l;else{var u=c.return;u===null?V=null:(V=u,Hu(u))}break b}}ql=0,Jl=null,Vu(e,t,o,5);break;case 6:ql=0,Jl=null,Vu(e,t,o,6);break;case 8:Ou(),$l=6;break a;default:throw Error(i(462))}}Ru();break}catch(t){Au(e,t)}while(1);return Ki=Gi=null,M.H=r,M.A=a,Wl=n,V===null?(Gl=null,Kl=0,ni(),$l):0}function Ru(){for(;V!==null&&!we();)zu(V)}function zu(e){var t=Fc(e.alternate,e,Ql);e.memoizedProps=e.pendingProps,t===null?Hu(e):V=t}function Bu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=yc(n,t,t.pendingProps,t.type,void 0,Kl);break;case 11:t=yc(n,t,t.pendingProps,t.type.render,t.ref,Kl);break;case 5:jo(t);default:Wc(n,t),t=V=di(t,Ql),t=Fc(n,t,Ql)}e.memoizedProps=e.pendingProps,t===null?Hu(e):V=t}function Vu(e,t,n,r){Ki=Gi=null,jo(t),ja=null,Ma=0;var i=t.return;try{if(ic(e,i,t,n,Kl)){$l=1,$s(e,_i(n,e.current)),V=null;return}}catch(t){if(i!==null)throw V=i,t;$l=1,$s(e,_i(n,e.current)),V=null;return}t.flags&32768?(Pi||r===1?e=!0:Xl||Kl&536870912?e=!1:(Yl=e=!0,(r===2||r===9||r===3||r===6)&&(r=no.current,r!==null&&r.tag===13&&(r.flags|=16384))),Uu(t,e)):Hu(t)}function Hu(e){var t=e;do{if(t.flags&32768){Uu(t,Yl);return}e=t.return;var n=Hc(t.alternate,t,Ql);if(n!==null){V=n;return}if(t=t.sibling,t!==null){V=t;return}V=t=e}while(t!==null);$l===0&&($l=5)}function Uu(e,t){do{var n=Uc(e.alternate,e);if(n!==null){n.flags&=32767,V=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){V=e;return}V=e=n}while(e!==null);$l=6,V=null}function Wu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Yu();while(H!==0);if(Wl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=ti,Ze(e,n,o,s,c,l),e===Gl&&(V=Gl=null,Kl=0),mu=t,pu=e,hu=n,gu=o,_u=a,vu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,id(Ae,function(){return Xu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=M.T,M.T=null,a=N.p,N.p=2,s=Wl,Wl|=4;try{ll(e,t,n)}finally{Wl=s,N.p=a,M.T=r}}H=1,Gu(),Ku(),qu()}}function Gu(){if(H===1){H=0;var e=pu,t=mu,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=M.T,M.T=null;var r=N.p;N.p=2;var i=Wl;Wl|=4;try{Sl(t,e);var a=Yd,o=kr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&Or(s.ownerDocument.documentElement,s)){if(c!==null&&Ar(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Dr(s,h),v=Dr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}gp=!!Jd,Yd=Jd=null}finally{Wl=i,N.p=r,M.T=n}}e.current=t,H=2}}function Ku(){if(H===2){H=0;var e=pu,t=mu,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=M.T,M.T=null;var r=N.p;N.p=2;var i=Wl;Wl|=4;try{ul(e,t.alternate,t)}finally{Wl=i,N.p=r,M.T=n}}H=3}}function qu(){if(H===4||H===3){H=0,Te();var e=pu,t=mu,n=hu,r=vu;t.subtreeFlags&10256||t.flags&10256?H=5:(H=0,mu=pu=null,Ju(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(fu=null),nt(n),t=t.stateNode,Ie&&typeof Ie.onCommitFiberRoot==`function`)try{Ie.onCommitFiberRoot(Fe,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=M.T,i=N.p,N.p=2,M.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{M.T=t,N.p=i}}hu&3&&Yu(),dd(e),i=e.pendingLanes,n&261930&&i&42?e===bu?yu++:(yu=0,bu=e):yu=0,fd(0,!1)}}function Ju(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,ca(t)))}function Yu(){return Gu(),Ku(),qu(),Xu()}function Xu(){if(H!==5)return!1;var e=pu,t=gu;gu=0;var n=nt(hu),r=M.T,a=N.p;try{N.p=32>n?32:n,M.T=null,n=_u,_u=null;var o=pu,s=hu;if(H=0,mu=pu=null,hu=0,Wl&6)throw Error(i(331));var c=Wl;if(Wl|=4,zl(o.current),jl(o,o.current,s,n),Wl=c,fd(0,!1),Ie&&typeof Ie.onPostCommitFiberRoot==`function`)try{Ie.onPostCommitFiberRoot(Fe,o)}catch{}return!0}finally{N.p=a,M.T=r,Ju(e,t)}}function Zu(e,t,n){t=_i(n,t),t=tc(e.stateNode,t,2),e=Ua(e,t,2),e!==null&&(Xe(e,2),dd(e))}function Qu(e,t,n){if(e.tag===3)Zu(e,e,n);else for(;t!==null;){if(t.tag===3){Zu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(fu===null||!fu.has(r))){e=_i(n,e),n=nc(2),r=Ua(t,n,2),r!==null&&(rc(n,r,t,e),Xe(r,2),dd(r));break}}t=t.return}}function $u(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ul;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Zl=!0,i.add(n),e=ed.bind(null,e,t,n),t.then(e,e))}function ed(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Gl===e&&(Kl&n)===n&&($l===4||$l===3&&(Kl&62914560)===Kl&&300>Ee()-cu?!(Wl&2)&&ku(e,0):nu|=n,iu===Kl&&(iu=0)),dd(e)}function td(e,t){t===0&&(t=Je()),e=ai(e,t),e!==null&&(Xe(e,t),dd(e))}function nd(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),td(e,n)}function rd(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),td(e,n)}function id(e,t){return Se(e,t)}var ad=null,od=null,sd=!1,cd=!1,ld=!1,ud=0;function dd(e){e!==od&&e.next===null&&(od===null?ad=od=e:od=od.next=e),cd=!0,sd||(sd=!0,vd())}function fd(e,t){if(!ld&&cd){ld=!0;do for(var n=!1,r=ad;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Re(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,_d(r,a))}else a=Kl,a=qe(r,r===Gl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||F(r,a)||(n=!0,_d(r,a));r=r.next}while(n);ld=!1}}function pd(){md()}function md(){cd=sd=!1;var e=0;ud!==0&&tf()&&(e=ud);for(var t=Ee(),n=null,r=ad;r!==null;){var i=r.next,a=hd(r,t);a===0?(r.next=null,n===null?ad=i:n.next=i,i===null&&(od=n)):(n=r,(e!==0||a&3)&&(cd=!0)),r=i}H!==0&&H!==5||fd(e,!1),ud!==0&&(ud=0)}function hd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Re(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=I(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Gl,n=Kl,n=qe(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(ql===2||ql===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Ce(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||F(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Ce(r),nt(n)){case 2:case 8:n=ke;break;case 32:n=Ae;break;case 268435456:n=Me;break;default:n=Ae}return r=gd.bind(null,e),n=Se(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Ce(r),e.callbackPriority=2,e.callbackNode=null,2}function gd(e,t){if(H!==0&&H!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Yu()&&e.callbackNode!==n)return null;var r=Kl;return r=qe(e,e===Gl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(wu(e,r,t),hd(e,Ee()),e.callbackNode!=null&&e.callbackNode===n?gd.bind(null,e):null)}function _d(e,t){if(Yu())return null;wu(e,t,!0)}function vd(){of(function(){Wl&6?Se(Oe,pd):md()})}function yd(){if(ud===0){var e=da;e===0&&(e=He,He<<=1,!(He&261888)&&(He=256)),ud=e}return ud}function bd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:en(``+e)}function xd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function Sd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=bd((i[st]||null).action),o=r.submitter;o&&(t=(t=o[st]||null)?bd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Cn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(ud!==0){var e=o?xd(i,o):new FormData(i);Ds(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?xd(i,o):new FormData(i),Ds(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Cd=0;Cd<Xr.length;Cd++){var wd=Xr[Cd];Zr(wd.toLowerCase(),`on`+(wd[0].toUpperCase()+wd.slice(1)))}Zr(Hr,`onAnimationEnd`),Zr(Ur,`onAnimationIteration`),Zr(Wr,`onAnimationStart`),Zr(`dblclick`,`onDoubleClick`),Zr(`focusin`,`onFocus`),Zr(`focusout`,`onBlur`),Zr(Gr,`onTransitionRun`),Zr(Kr,`onTransitionStart`),Zr(qr,`onTransitionCancel`),Zr(Jr,`onTransitionEnd`),wt(`onMouseEnter`,[`mouseout`,`mouseover`]),wt(`onMouseLeave`,[`mouseout`,`mouseover`]),wt(`onPointerEnter`,[`pointerout`,`pointerover`]),wt(`onPointerLeave`,[`pointerout`,`pointerover`]),St(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),St(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),St(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),St(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),St(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),St(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Td=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Ed=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Td));function Dd(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Qr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Qr(e)}i.currentTarget=null,a=c}}}}function Od(e,t){var n=t[lt];n===void 0&&(n=t[lt]=new Set);var r=e+`__bubble`;n.has(r)||(Md(t,e,2,!1),n.add(r))}function kd(e,t,n){var r=0;t&&(r|=4),Md(n,e,r,t)}var Ad=`_reactListening`+Math.random().toString(36).slice(2);function jd(e){if(!e[Ad]){e[Ad]=!0,bt.forEach(function(t){t!==`selectionchange`&&(Ed.has(t)||kd(t,!1,e),kd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ad]||(t[Ad]=!0,kd(`selectionchange`,!1,t))}}function Md(e,t,n,r){switch(Cp(t)){case 2:var i=_p;break;case 8:i=vp;break;default:i=yp}n=i.bind(null,t,n,e),i=void 0,!fn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Nd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=ht(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}ln(function(){var r=a,i=rn(n),s=[];a:{var c=Yr.get(e);if(c!==void 0){var l=Cn,u=e;switch(e){case`keypress`:if(vn(n)===0)break a;case`keydown`:case`keyup`:l=Vn;break;case`focusin`:u=`focus`,l=Mn;break;case`focusout`:u=`blur`,l=Mn;break;case`beforeblur`:case`afterblur`:l=Mn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=An;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=jn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Un;break;case Hr:case Ur:case Wr:l=Nn;break;case Jr:l=Wn;break;case`scroll`:case`scrollend`:l=Tn;break;case`wheel`:l=Gn;break;case`copy`:case`cut`:case`paste`:l=Pn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Hn;break;case`toggle`:case`beforetoggle`:l=Kn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=un(m,p),g!=null&&d.push(Pd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==nn&&(u=n.relatedTarget||n.fromElement)&&(ht(u)||u[ct]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?ht(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=An,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Hn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:_t(l),h=u==null?c:_t(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,ht(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Id,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Ld(s,c,l,d,!1),u!==null&&f!==null&&Ld(s,f,u,d,!0)}}a:{if(c=r?_t(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=fr;else if(or(c))if(pr)v=Sr;else{v=br;var y=yr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Zt(r.elementType)&&(v=fr):v=xr;if(v&&=v(e,r)){sr(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Ut(c,`number`,c.value)}switch(y=r?_t(r):window,e){case`focusin`:(or(y)||y.contentEditable===`true`)&&(Mr=y,Nr=r,Pr=null);break;case`focusout`:Pr=Nr=Mr=null;break;case`mousedown`:Fr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Fr=!1,Ir(s,n,i);break;case`selectionchange`:if(jr)break;case`keydown`:case`keyup`:Ir(s,n,i)}var b;if(Jn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else nr?er(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Zn&&n.locale!==`ko`&&(nr||x!==`onCompositionStart`?x===`onCompositionEnd`&&nr&&(b=_n()):(mn=i,hn=`value`in mn?mn.value:mn.textContent,nr=!0)),y=Fd(r,x),0<y.length&&(x=new Fn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=tr(n),b!==null&&(x.data=b)))),(b=Xn?rr(e,n):ir(e,n))&&(x=Fd(r,`onBeforeInput`),0<x.length&&(y=new Fn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),Sd(s,e,r,n,i)}Dd(s,t)})}function Pd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Fd(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=un(e,n),i!=null&&r.unshift(Pd(e,i,a)),i=un(e,t),i!=null&&r.push(Pd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Id(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Ld(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=un(n,a),l!=null&&o.unshift(Pd(n,l,c))):i||(l=un(n,a),l!=null&&o.push(Pd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Rd=/\r\n?/g,zd=/\u0000|\uFFFD/g;function Bd(e){return(typeof e==`string`?e:``+e).replace(Rd,`
|
|
9
|
-
`).replace(zd,``)}function Vd(e,t){return t=Bd(t),Bd(e)===t}function Hd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||qt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&qt(e,``+r);break;case`className`:jt(e,`class`,r);break;case`tabIndex`:jt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:jt(e,n,r);break;case`style`:Xt(e,r,o);break;case`data`:if(t!==`object`){jt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=en(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Hd(e,t,`name`,a.name,a,null),Hd(e,t,`formEncType`,a.formEncType,a,null),Hd(e,t,`formMethod`,a.formMethod,a,null),Hd(e,t,`formTarget`,a.formTarget,a,null)):(Hd(e,t,`encType`,a.encType,a,null),Hd(e,t,`method`,a.method,a,null),Hd(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=en(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=tn);break;case`onScroll`:r!=null&&Od(`scroll`,e);break;case`onScrollEnd`:r!=null&&Od(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=en(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Od(`beforetoggle`,e),Od(`toggle`,e),At(e,`popover`,r);break;case`xlinkActuate`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Mt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Mt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Mt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:At(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Qt.get(n)||n,At(e,n,r))}}function Ud(e,t,n,r,a,o){switch(n){case`style`:Xt(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?qt(e,r):(typeof r==`number`||typeof r==`bigint`)&&qt(e,``+r);break;case`onScroll`:r!=null&&Od(`scroll`,e);break;case`onScrollEnd`:r!=null&&Od(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=tn);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!xt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[st]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):At(e,n,r)}}}function Wd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Od(`error`,e),Od(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Hd(e,t,o,s,n,null)}}a&&Hd(e,t,`srcSet`,n.srcSet,n,null),r&&Hd(e,t,`src`,n.src,n,null);return;case`input`:Od(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Hd(e,t,r,d,n,null)}}Ht(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Od(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Hd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Wt(e,!!r,n,!0):Wt(e,!!r,t,!1);return;case`textarea`:for(s in Od(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Hd(e,t,s,c,n,null)}Kt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Hd(e,t,l,r,n,null)}return;case`dialog`:Od(`beforetoggle`,e),Od(`toggle`,e),Od(`cancel`,e),Od(`close`,e);break;case`iframe`:case`object`:Od(`load`,e);break;case`video`:case`audio`:for(r=0;r<Td.length;r++)Od(Td[r],e);break;case`image`:Od(`error`,e),Od(`load`,e);break;case`details`:Od(`toggle`,e);break;case`embed`:case`source`:case`link`:Od(`error`,e),Od(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Hd(e,t,u,r,n,null)}return;default:if(Zt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Ud(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Hd(e,t,c,r,n,null))}function Gd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Hd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Hd(e,t,p,m,r,f)}}Vt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Hd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Hd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Wt(e,!!n,n?[]:``,!1):Wt(e,!!n,t,!0)):Wt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Hd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Hd(e,t,s,a,r,o)}Gt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Hd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Hd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Hd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Hd(e,t,u,p,r,m)}return;default:if(Zt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Ud(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Ud(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Hd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Hd(e,t,f,p,r,m)}function Kd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function qd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Kd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Kd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Jd=null,Yd=null;function Xd(e){return e.nodeType===9?e:e.ownerDocument}function Zd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Qd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function $d(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var ef=null;function tf(){var e=window.event;return e&&e.type===`popstate`?e===ef?!1:(ef=e,!0):(ef=null,!1)}var nf=typeof setTimeout==`function`?setTimeout:void 0,rf=typeof clearTimeout==`function`?clearTimeout:void 0,af=typeof Promise==`function`?Promise:void 0,of=typeof queueMicrotask==`function`?queueMicrotask:af===void 0?nf:function(e){return af.resolve(null).then(e).catch(sf)};function sf(e){setTimeout(function(){throw e})}function cf(e){return e===`head`}function lf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Vp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)Cf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Cf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[pt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&Cf(e.ownerDocument.body);n=i}while(n);Vp(t)}function uf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function df(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:df(n),mt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function ff(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[pt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=vf(e.nextSibling),e===null)break}return null}function pf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=vf(e.nextSibling),e===null))return null;return e}function mf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=vf(e.nextSibling),e===null))return null;return e}function hf(e){return e.data===`$?`||e.data===`$~`}function gf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function _f(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function vf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var yf=null;function bf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return vf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function xf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function Sf(e,t,n){switch(t=Xd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Cf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);mt(e)}var W=new Map,wf=new Set;function Tf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Ef=N.d;N.d={f:Df,r:Of,D:jf,C:Mf,L:Nf,m:Pf,X:If,S:Ff,M:Lf};function Df(){var e=Ef.f(),t=Du();return e||t}function Of(e){var t=gt(e);t!==null&&t.tag===5&&t.type===`form`?ks(t):Ef.r(e)}var kf=typeof document>`u`?null:document;function Af(e,t,n){var r=kf;if(r&&typeof t==`string`&&t){var i=Bt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),wf.has(i)||(wf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Wd(t,`link`,e),yt(t),r.head.appendChild(t)))}}function jf(e){Ef.D(e),Af(`dns-prefetch`,e,null)}function Mf(e,t){Ef.C(e,t),Af(`preconnect`,e,t)}function Nf(e,t,n){Ef.L(e,t,n);var r=kf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Bt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Bt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Bt(n.imageSizes)+`"]`)):i+=`[href="`+Bt(e)+`"]`;var a=i;switch(t){case`style`:a=zf(e);break;case`script`:a=Uf(e)}W.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),W.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Bf(a))||t===`script`&&r.querySelector(Wf(a))||(t=r.createElement(`link`),Wd(t,`link`,e),yt(t),r.head.appendChild(t)))}}function Pf(e,t){Ef.m(e,t);var n=kf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Bt(r)+`"][href="`+Bt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Uf(e)}if(!W.has(a)&&(e=f({rel:`modulepreload`,href:e},t),W.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Wf(a)))return}r=n.createElement(`link`),Wd(r,`link`,e),yt(r),n.head.appendChild(r)}}}function Ff(e,t,n){Ef.S(e,t,n);var r=kf;if(r&&e){var i=vt(r).hoistableStyles,a=zf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Bf(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=W.get(a))&&qf(e,n);var c=o=r.createElement(`link`);yt(c),Wd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Kf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function If(e,t){Ef.X(e,t);var n=kf;if(n&&e){var r=vt(n).hoistableScripts,i=Uf(e),a=r.get(i);a||(a=n.querySelector(Wf(i)),a||(e=f({src:e,async:!0},t),(t=W.get(i))&&Jf(e,t),a=n.createElement(`script`),yt(a),Wd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Lf(e,t){Ef.M(e,t);var n=kf;if(n&&e){var r=vt(n).hoistableScripts,i=Uf(e),a=r.get(i);a||(a=n.querySelector(Wf(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=W.get(i))&&Jf(e,t),a=n.createElement(`script`),yt(a),Wd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Rf(e,t,n,r){var a=(a=ce.current)?Tf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=zf(n.href),n=vt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=zf(n.href);var o=vt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Bf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),W.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},W.set(e,n),o||Hf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Uf(n),n=vt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function zf(e){return`href="`+Bt(e)+`"`}function Bf(e){return`link[rel="stylesheet"][`+e+`]`}function Vf(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function Hf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Wd(t,`link`,n),yt(t),e.head.appendChild(t))}function Uf(e){return`[src="`+Bt(e)+`"]`}function Wf(e){return`script[async]`+e}function Gf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Bt(n.href)+`"]`);if(r)return t.instance=r,yt(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),yt(r),Wd(r,`style`,a),Kf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=zf(n.href);var o=e.querySelector(Bf(a));if(o)return t.state.loading|=4,t.instance=o,yt(o),o;r=Vf(n),(a=W.get(a))&&qf(r,a),o=(e.ownerDocument||e).createElement(`link`),yt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Wd(o,`link`,r),t.state.loading|=4,Kf(o,n.precedence,e),t.instance=o;case`script`:return o=Uf(n.src),(a=e.querySelector(Wf(o)))?(t.instance=a,yt(a),a):(r=n,(a=W.get(o))&&(r=f({},n),Jf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),yt(a),Wd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Kf(r,n.precedence,e));return t.instance}function Kf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function qf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Jf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Yf=null;function Xf(e,t,n){if(Yf===null){var r=new Map,i=Yf=new Map;i.set(n,r)}else i=Yf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[pt]||a[ot]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Zf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Qf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function $f(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function ep(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=zf(r.href),a=t.querySelector(Bf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=rp.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,yt(a);return}a=t.ownerDocument||t,r=Vf(r),(i=W.get(i))&&qf(r,i),a=a.createElement(`link`),yt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Wd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=rp.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var tp=0;function np(e,t){return e.stylesheets&&e.count===0&&ap(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ap(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&tp===0&&(tp=62500*qd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ap(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>tp?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function rp(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ap(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var ip=null;function ap(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ip=new Map,t.forEach(op,e),ip=null,rp.call(e))}function op(e,t){if(!(t.state.loading&4)){var n=ip.get(e);if(n)var r=n.get(null);else{n=new Map,ip.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=rp.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var sp={$$typeof:b,Provider:null,Consumer:null,_currentValue:te,_currentValue2:te,_threadCount:0};function cp(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ye(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ye(0),this.hiddenUpdates=Ye(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function lp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new cp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=li(3,null,null,t),e.current=a,a.stateNode=e,t=sa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Ba(a),e}function up(e){return e?(e=si,e):si}function dp(e,t,n,r,i,a){i=up(i),r.context===null?r.context=i:r.pendingContext=i,r=Ha(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ua(e,r,t),n!==null&&(Cu(n,e,t),Wa(n,e,t))}function fp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function pp(e,t){fp(e,t),(e=e.alternate)&&fp(e,t)}function mp(e){if(e.tag===13||e.tag===31){var t=ai(e,67108864);t!==null&&Cu(t,e,67108864),pp(e,67108864)}}function hp(e){if(e.tag===13||e.tag===31){var t=xu();t=tt(t);var n=ai(e,t);n!==null&&Cu(n,e,t),pp(e,t)}}var gp=!0;function _p(e,t,n,r){var i=M.T;M.T=null;var a=N.p;try{N.p=2,yp(e,t,n,r)}finally{N.p=a,M.T=i}}function vp(e,t,n,r){var i=M.T;M.T=null;var a=N.p;try{N.p=8,yp(e,t,n,r)}finally{N.p=a,M.T=i}}function yp(e,t,n,r){if(gp){var i=bp(r);if(i===null)Nd(e,t,r,xp,n),Mp(e,r);else if(Pp(i,e,t,n,r))r.stopPropagation();else if(Mp(e,r),t&4&&-1<jp.indexOf(e)){for(;i!==null;){var a=gt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ke(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Re(o);s.entanglements[1]|=c,o&=~c}dd(a),!(Wl&6)&&(uu=Ee()+500,fd(0,!1))}}break;case 31:case 13:s=ai(a,2),s!==null&&Cu(s,a,2),Du(),pp(a,2)}if(a=bp(r),a===null&&Nd(e,t,r,xp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Nd(e,t,r,null,n)}}function bp(e){return e=rn(e),Sp(e)}var xp=null;function Sp(e){if(xp=null,e=ht(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return xp=e,null}function Cp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(De()){case Oe:return 2;case ke:return 8;case Ae:case je:return 32;case Me:return 268435456;default:return 32}default:return 32}}var wp=!1,Tp=null,Ep=null,Dp=null,Op=new Map,kp=new Map,Ap=[],jp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Mp(e,t){switch(e){case`focusin`:case`focusout`:Tp=null;break;case`dragenter`:case`dragleave`:Ep=null;break;case`mouseover`:case`mouseout`:Dp=null;break;case`pointerover`:case`pointerout`:Op.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:kp.delete(t.pointerId)}}function Np(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=gt(t),t!==null&&mp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Pp(e,t,n,r,i){switch(t){case`focusin`:return Tp=Np(Tp,e,t,n,r,i),!0;case`dragenter`:return Ep=Np(Ep,e,t,n,r,i),!0;case`mouseover`:return Dp=Np(Dp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Op.set(a,Np(Op.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,kp.set(a,Np(kp.get(a)||null,e,t,n,r,i)),!0}return!1}function Fp(e){var t=ht(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,it(e.priority,function(){hp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,it(e.priority,function(){hp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ip(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=bp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);nn=r,n.target.dispatchEvent(r),nn=null}else return t=gt(n),t!==null&&mp(t),e.blockedOn=n,!1;t.shift()}return!0}function Lp(e,t,n){Ip(e)&&n.delete(t)}function Rp(){wp=!1,Tp!==null&&Ip(Tp)&&(Tp=null),Ep!==null&&Ip(Ep)&&(Ep=null),Dp!==null&&Ip(Dp)&&(Dp=null),Op.forEach(Lp),kp.forEach(Lp)}function zp(e,n){e.blockedOn===n&&(e.blockedOn=null,wp||(wp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Rp)))}var G=null;function Bp(e){G!==e&&(G=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){G===e&&(G=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Sp(r||n)===null)continue;break}var a=gt(n);a!==null&&(e.splice(t,3),t-=3,Ds(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Vp(e){function t(t){return zp(t,e)}Tp!==null&&zp(Tp,e),Ep!==null&&zp(Ep,e),Dp!==null&&zp(Dp,e),Op.forEach(t),kp.forEach(t);for(var n=0;n<Ap.length;n++){var r=Ap[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Ap.length&&(n=Ap[0],n.blockedOn===null);)Fp(n),n.blockedOn===null&&Ap.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[st]||null;if(typeof a==`function`)o||Bp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[st]||null)s=o.formAction;else if(Sp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Bp(n)}}}function Hp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Up(e){this._internalRoot=e}Wp.prototype.render=Up.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;dp(n,xu(),e,t,null,null)},Wp.prototype.unmount=Up.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;dp(e.current,2,null,e,null,null),Du(),t[ct]=null}};function Wp(e){this._internalRoot=e}Wp.prototype.unstable_scheduleHydration=function(e){if(e){var t=rt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ap.length&&t!==0&&t<Ap[n].priority;n++);Ap.splice(n,0,e),n===0&&Fp(e)}};var Gp=n.version;if(Gp!==`19.2.7`)throw Error(i(527,Gp,`19.2.7`));N.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var Kp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:M,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var qp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!qp.isDisabled&&qp.supportsFiber)try{Fe=qp.inject(Kp),Ie=qp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Xs,s=Zs,c=Qs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=lp(e,1,!1,null,null,n,r,null,o,s,c,Hp),e[ct]=t.current,jd(e),new Up(t)}})),Dt=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Et()}))(),Ot=Object.create,kt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,jt=Object.getOwnPropertyNames,Mt=Object.getPrototypeOf,Nt=Object.prototype.hasOwnProperty,Pt=(e,t)=>function(){return t||(0,e[jt(e)[0]])((t={exports:{}}).exports,t),t.exports},Ft=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=jt(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Nt.call(e,s)&&s!==n&&kt(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=At(t,s))||r.enumerable});return e},It=(e,t,n)=>(n=e==null?{}:Ot(Mt(e)),Ft(t||!e||!e.__esModule?kt(n,`default`,{value:e,enumerable:!0}):n,e)),Lt=Pt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(e){"@babel/helpers - typeof";return t.exports=n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t.exports.__esModule=!0,t.exports.default=t.exports,n(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),Rt=Pt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=Lt().default;function r(e,t){if(n(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||`default`);if(n(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),zt=Pt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=Lt().default,r=Rt();function i(e){var t=r(e,`string`);return n(t)==`symbol`?t:t+``}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),Bt=Pt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=zt();function r(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),Vt=Pt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=Bt();function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]==null?{}:arguments[t];t%2?r(Object(i),!0).forEach(function(t){n(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}});function Ht(e){let t={subscribe(t){let n=null,r=!1,i=!1,a=!1;function o(){if(n===null){a=!0;return}i||(i=!0,typeof n==`function`?n():n&&n.unsubscribe())}return n=e({next(e){var n;r||(n=t.next)==null||n.call(t,e)},error(e){var n;r||(r=!0,(n=t.error)==null||n.call(t,e),o())},complete(){var e;r||(r=!0,(e=t.complete)==null||e.call(t),o())}}),a&&o(),{unsubscribe:o}},pipe(...e){return e.reduce(Ut,t)}};return t}function Ut(e,t){return t(e)}function Wt(e){let t=new AbortController;return new Promise((n,r)=>{let i=!1;function a(){i||(i=!0,o.unsubscribe())}t.signal.addEventListener(`abort`,()=>{r(t.signal.reason)});let o=e.subscribe({next(e){i=!0,n(e),a()},error(e){r(e)},complete(){t.abort(),a()}})})}function Gt(e){return e=>{let t=0,n=null,r=[];function i(){n||=e.subscribe({next(e){for(let n of r){var t;(t=n.next)==null||t.call(n,e)}},error(e){for(let n of r){var t;(t=n.error)==null||t.call(n,e)}},complete(){for(let t of r){var e;(e=t.complete)==null||e.call(t)}}})}function a(){if(t===0&&n){let e=n;n=null,e.unsubscribe()}}return Ht(e=>(t++,r.push(e),i(),{unsubscribe(){t--,a();let n=r.findIndex(t=>t===e);n>-1&&r.splice(n,1)}}))}}function Kt(e){let t=e,n=[],r=e=>{t!==void 0&&e.next(t),n.push(e)},i=e=>{n.splice(n.indexOf(e),1)},a=Ht(e=>(r(e),()=>{i(e)}));return a.next=e=>{if(t!==e){t=e;for(let t of n)t.next(e)}},a.get=()=>t,a}function qt(e){return Ht(t=>{function n(t=0,r=e.op){let i=e.links[t];if(!i)throw Error(`No more links to execute - did you forget to add an ending link?`);return i({op:r,next(e){return n(t+1,e)}})}return n().subscribe(t)})}function Jt(e){return Array.isArray(e)?e:[e]}function Yt(e){return t=>{let n=Jt(e.true).map(e=>e(t)),r=Jt(e.false).map(e=>e(t));return t=>Ht(i=>{let a=e.condition(t.op)?n:r;return qt({op:t.op,links:a}).subscribe(i)})}}function Xt(e){return!!e&&!Array.isArray(e)&&typeof e==`object`}function Zt(){return Object.create(null)}var Qt=typeof Symbol==`function`&&!!Symbol.asyncIterator;function $t(e){return Qt&&Xt(e)&&Symbol.asyncIterator in e}var en={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,BAD_GATEWAY:-32603,SERVICE_UNAVAILABLE:-32603,GATEWAY_TIMEOUT:-32603,UNAUTHORIZED:-32001,PAYMENT_REQUIRED:-32002,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNSUPPORTED_MEDIA_TYPE:-32015,UNPROCESSABLE_CONTENT:-32022,PRECONDITION_REQUIRED:-32028,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099};en.BAD_GATEWAY,en.SERVICE_UNAVAILABLE,en.GATEWAY_TIMEOUT,en.INTERNAL_SERVER_ERROR;var tn=Object.create,nn=Object.defineProperty,rn=Object.getOwnPropertyDescriptor,an=Object.getOwnPropertyNames,on=Object.getPrototypeOf,sn=Object.prototype.hasOwnProperty,cn=(e,t)=>function(){return t||(0,e[an(e)[0]])((t={exports:{}}).exports,t),t.exports},ln=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=an(t),a=0,o=i.length,s;a<o;a++)s=i[a],!sn.call(e,s)&&s!==n&&nn(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=rn(t,s))||r.enumerable});return e},un=(e,t,n)=>(n=e==null?{}:tn(on(e)),ln(t||!e||!e.__esModule?nn(n,`default`,{value:e,enumerable:!0}):n,e)),dn=()=>{},fn=e=>{Object.freeze&&Object.freeze(e)};function pn(e,t,n){let r=t.join(`.`);return n[r]??(n[r]=new Proxy(dn,{get(r,i){if(!(typeof i!=`string`||i===`then`))return pn(e,[...t,i],n)},apply(n,r,i){let a=t[t.length-1];if(a===`valueOf`||a===`toString`||a===`toJSON`)return`tRPC.proxy(${t.slice(0,-1).join(`.`)})`;let o={args:i,path:t};return a===`call`?o={args:i.length>=2?[i[1]]:[],path:t.slice(0,-1)}:a===`apply`&&(o={args:i.length>=2?i[1]:[],path:t.slice(0,-1)}),fn(o.args),fn(o.path),e(o)}})),n[r]}var mn=e=>pn(e,[],Zt()),hn=e=>new Proxy(dn,{get(t,n){if(n!==`then`)return e(n)}}),gn=cn({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(e){"@babel/helpers - typeof";return t.exports=n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t.exports.__esModule=!0,t.exports.default=t.exports,n(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),_n=cn({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=gn().default;function r(e,t){if(n(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||`default`);if(n(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),vn=cn({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=gn().default,r=_n();function i(e){var t=r(e,`string`);return n(t)==`symbol`?t:t+``}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),yn=cn({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=vn();function r(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),bn=cn({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=yn();function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]==null?{}:arguments[t];t%2?r(Object(i),!0).forEach(function(t){n(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}});un(bn(),1),un(yn(),1);var xn=un(bn(),1);function Sn(e,t){if(`error`in e){let n=t.deserialize(e.error);return{ok:!1,error:(0,xn.default)((0,xn.default)({},e),{},{error:n})}}return{ok:!0,result:(0,xn.default)((0,xn.default)({},e.result),(!e.result.type||e.result.type===`data`)&&{type:`data`,data:t.deserialize(e.result.data)})}}var Cn=class extends Error{constructor(){super(`Unable to transform response from server`)}};function wn(e,t){let n;try{n=Sn(e,t)}catch{throw new Cn}if(!n.ok&&(!Xt(n.error.error)||typeof n.error.error.code!=`number`)||n.ok&&!Xt(n.result))throw new Cn;return n}un(bn(),1);var Tn=It(Bt(),1),En=It(Vt(),1);function Dn(e){return e instanceof An}function On(e){return Xt(e)&&Xt(e.error)&&typeof e.error.code==`number`&&typeof e.error.message==`string`}function kn(e,t){return typeof e==`string`?e:Xt(e)&&typeof e.message==`string`?e.message:t}var An=class e extends Error{constructor(t,n){var r,i;let a=n?.cause;super(t,{cause:a}),(0,Tn.default)(this,`cause`,void 0),(0,Tn.default)(this,`shape`,void 0),(0,Tn.default)(this,`data`,void 0),(0,Tn.default)(this,`meta`,void 0),this.meta=n?.meta,this.cause=a,this.shape=n==null||(r=n.result)==null?void 0:r.error,this.data=n==null||(i=n.result)==null?void 0:i.error.data,this.name=`TRPCClientError`,Object.setPrototypeOf(this,e.prototype)}static from(t,n={}){let r=t;return Dn(r)?(n.meta&&(r.meta=(0,En.default)((0,En.default)({},r.meta),n.meta)),r):On(r)?new e(r.error.message,(0,En.default)((0,En.default)({},n),{},{result:r,cause:n.cause})):new e(kn(r,`Unknown error`),(0,En.default)((0,En.default)({},n),{},{cause:r}))}};function jn(e){let t=e;return t?`input`in t?t:{input:t,output:t}:{input:{serialize:e=>e,deserialize:e=>e},output:{serialize:e=>e,deserialize:e=>e}}}var Mn=e=>typeof e==`function`;function Nn(e){if(e)return e;if(typeof window<`u`&&Mn(window.fetch))return window.fetch;if(typeof globalThis<`u`&&Mn(globalThis.fetch))return globalThis.fetch;throw Error(`No fetch implementation found`)}var Pn=It(Vt());function Fn(e){return{url:e.url.toString(),fetch:e.fetch,transformer:jn(e.transformer),methodOverride:e.methodOverride}}function In(e){let t={};for(let n=0;n<e.length;n++)t[n]=e[n];return t}var Ln={query:`GET`,mutation:`POST`,subscription:`PATCH`};function Rn(e){return`input`in e?e.transformer.input.serialize(e.input):In(e.inputs.map(t=>e.transformer.input.serialize(t)))}var zn=e=>{let t=e.url.split(`?`),n=t[0].replace(/\/$/,``)+`/`+e.path,r=[];if(t[1]&&r.push(t[1]),`inputs`in e&&r.push(`batch=1`),e.type===`query`||e.type===`subscription`){let t=Rn(e);t!==void 0&&e.methodOverride!==`POST`&&r.push(`input=${encodeURIComponent(JSON.stringify(t))}`)}return r.length&&(n+=`?`+r.join(`&`)),n},Bn=e=>{if(e.type===`query`&&e.methodOverride!==`POST`)return;let t=Rn(e);return t===void 0?void 0:JSON.stringify(t)},Vn=e=>Gn((0,Pn.default)((0,Pn.default)({},e),{},{contentTypeHeader:`application/json`,getUrl:zn,getBody:Bn})),Hn=class extends Error{constructor(){let e=`AbortError`;super(e),this.name=e,this.message=e}},Un=e=>{var t;if(e?.aborted)throw(t=e.throwIfAborted)==null||t.call(e),typeof DOMException<`u`?new DOMException(`AbortError`,`AbortError`):new Hn};async function Wn(e){Un(e.signal);let t=e.getUrl(e),n=e.getBody(e),r=e.methodOverride??Ln[e.type],i=await(async()=>{let t=await e.headers();return Symbol.iterator in t?Object.fromEntries(t):t})(),a=(0,Pn.default)((0,Pn.default)((0,Pn.default)({},e.contentTypeHeader&&r!==`GET`?{"content-type":e.contentTypeHeader}:{}),e.trpcAcceptHeader?{[e.trpcAcceptHeaderKey??`trpc-accept`]:e.trpcAcceptHeader}:void 0),i);return Nn(e.fetch)(t,{method:r,signal:e.signal,body:n,headers:a})}async function Gn(e){let t={},n=await Wn(e);t.response=n;let r=await n.json();return t.responseJSON=r,{json:r,meta:t}}function Kn(e){return e instanceof Uint8Array||e instanceof Blob}function qn(e){return e instanceof FormData}var Jn=It(Vt(),1),Yn=e=>{if(`input`in e){let{input:t}=e;if(qn(t)){if(e.type!==`mutation`&&e.methodOverride!==`POST`)throw Error(`FormData is only supported for mutations`);return Gn((0,Jn.default)((0,Jn.default)({},e),{},{contentTypeHeader:void 0,getUrl:zn,getBody:()=>t}))}if(Kn(t)){if(e.type!==`mutation`&&e.methodOverride!==`POST`)throw Error(`Octet type input is only supported for mutations`);return Gn((0,Jn.default)((0,Jn.default)({},e),{},{contentTypeHeader:`application/octet-stream`,getUrl:zn,getBody:()=>t}))}}return Vn(e)};function Xn(e){let t=Fn(e);return()=>n=>{let{op:r}=n;return Ht(n=>{let{path:i,input:a,type:o}=r;if(o===`subscription`)throw Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");let s=Yn((0,Jn.default)((0,Jn.default)({},t),{},{type:o,path:i,input:a,signal:r.signal,headers(){return e.headers?typeof e.headers==`function`?e.headers({op:r}):e.headers:{}}})),c;return s.then(e=>{c=e.meta;let r=wn(e.json,t.transformer.output);if(!r.ok){n.error(An.from(r.error,{meta:c}));return}n.next({context:e.meta,result:r.result}),n.complete()}).catch(e=>{n.error(An.from(e,{meta:c}))}),()=>{}})}}var Zn=()=>{throw Error(`Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new`)};function Qn(e){let t=null,n=null,r=()=>{clearTimeout(n),n=null,t=null};function i(t){let n=[[]],r=0;for(;;){let o=t[r];if(!o)break;let s=n[n.length-1];if(o.aborted){var i;(i=o.reject)==null||i.call(o,Error(`Aborted`)),r++;continue}if(e.validate(s.concat(o).map(e=>e.key))){s.push(o),r++;continue}if(s.length===0){var a;(a=o.reject)==null||a.call(o,Error(`Input is too big for a single dispatch`)),r++;continue}n.push([])}return n}function a(){let n=i(t);r();for(let t of n){if(!t.length)continue;let n={items:t};for(let e of t)e.batch=n;e.fetch(n.items.map(e=>e.key)).then(async e=>{await Promise.all(e.map(async(e,t)=>{let r=n.items[t];try{var i;let t=await Promise.resolve(e);(i=r.resolve)==null||i.call(r,t)}catch(e){var a;(a=r.reject)==null||a.call(r,e)}r.batch=null,r.reject=null,r.resolve=null}));for(let e of n.items){var t;(t=e.reject)==null||t.call(e,Error(`Missing result`)),e.batch=null}}).catch(e=>{for(let r of n.items){var t;(t=r.reject)==null||t.call(r,e),r.batch=null}})}}function o(e){let r={aborted:!1,key:e,batch:null,resolve:Zn,reject:Zn},i=new Promise((e,n)=>{r.reject=n,r.resolve=e,t??=[],t.push(r)});return n??=setTimeout(a),i}return{load:o}}function $n(...e){let t=new AbortController,n=e.length,r=0,i=()=>{++r===n&&t.abort()};for(let t of e)t?.aborted?i():t?.addEventListener(`abort`,i,{once:!0});return t.signal}var er=It(Vt(),1);function tr(e){let t=Fn(e),n=e.maxURLLength??1/0,r=e.maxItems??1/0;return()=>{let i=i=>({validate(e){if(n===1/0&&r===1/0)return!0;if(e.length>r)return!1;let a=e.map(e=>e.path).join(`,`),o=e.map(e=>e.input);return zn((0,er.default)((0,er.default)({},t),{},{type:i,path:a,inputs:o,signal:null})).length<=n},async fetch(n){let r=n.map(e=>e.path).join(`,`),a=n.map(e=>e.input),o=$n(...n.map(e=>e.signal)),s=await Vn((0,er.default)((0,er.default)({},t),{},{path:r,inputs:a,type:i,headers(){return e.headers?typeof e.headers==`function`?e.headers({opList:n}):e.headers:{}},signal:o}));return(Array.isArray(s.json)?s.json:n.map(()=>s.json)).map(e=>({meta:s.meta,json:e}))}}),a={query:Qn(i(`query`)),mutation:Qn(i(`mutation`))};return({op:e})=>Ht(n=>{if(e.type===`subscription`)throw Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");let r=a[e.type].load(e),i;return r.then(e=>{i=e;let r=wn(e.json,t.transformer.output);if(!r.ok){n.error(An.from(r.error,{meta:e.meta}));return}n.next({context:e.meta,result:r.result}),n.complete()}).catch(e=>{n.error(An.from(e,{meta:i?.meta}))}),()=>{}})}}It(Vt(),1);var nr=(e,...t)=>typeof e==`function`?e(...t):e;It(Bt(),1);function rr(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}async function ir(e){let t=await nr(e.url);return e.connectionParams?t+`${t.includes(`?`)?`&`:`?`}connectionParams=1`:t}async function ar(e,t){let n={method:`connectionParams`,data:await nr(e)};return t.encode(n)}It(Bt(),1);var or=It(Bt(),1);function sr(e){let{promise:t,resolve:n,reject:r}=rr();return e.addEventListener(`open`,()=>{e.removeEventListener(`error`,r),n()}),e.addEventListener(`error`,r),t}function cr(e,{intervalMs:t,pongTimeoutMs:n}){let r,i;function a(){r=setTimeout(()=>{e.send(`PING`),i=setTimeout(()=>{e.close()},n)},t)}function o(){clearTimeout(r),a()}function s(){clearTimeout(i),o()}e.addEventListener(`open`,a),e.addEventListener(`message`,({data:e})=>{clearTimeout(r),a(),e===`PONG`&&s()}),e.addEventListener(`close`,()=>{clearTimeout(r),clearTimeout(i)})}var lr=class e{constructor(t){if((0,or.default)(this,`id`,++e.connectCount),(0,or.default)(this,`WebSocketPonyfill`,void 0),(0,or.default)(this,`urlOptions`,void 0),(0,or.default)(this,`keepAliveOpts`,void 0),(0,or.default)(this,`encoder`,void 0),(0,or.default)(this,`wsObservable`,Kt(null)),(0,or.default)(this,`openPromise`,null),this.WebSocketPonyfill=t.WebSocketPonyfill??WebSocket,!this.WebSocketPonyfill)throw Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=t.urlOptions,this.keepAliveOpts=t.keepAlive,this.encoder=t.encoder}get ws(){return this.wsObservable.get()}set ws(e){this.wsObservable.next(e)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){var t=this;if(t.openPromise)return t.openPromise;t.id=++e.connectCount,t.openPromise=ir(t.urlOptions).then(e=>new t.WebSocketPonyfill(e)).then(async e=>{t.ws=e,e.binaryType=`arraybuffer`,e.addEventListener(`message`,function({data:e}){e===`PING`&&this.send(`PONG`)}),t.keepAliveOpts.enabled&&cr(e,t.keepAliveOpts),e.addEventListener(`close`,()=>{t.ws===e&&(t.ws=null)}),await sr(e),t.urlOptions.connectionParams&&e.send(await ar(t.urlOptions.connectionParams,t.encoder))});try{await t.openPromise}finally{t.openPromise=null}}async close(){var e=this;try{await e.openPromise}finally{var t;(t=e.ws)==null||t.close()}}};(0,or.default)(lr,`connectCount`,0),It(Bt(),1),It(Vt(),1);var ur=It(Bt(),1),dr=It(Vt(),1),fr=class{constructor(e){(0,ur.default)(this,`links`,void 0),(0,ur.default)(this,`runtime`,void 0),(0,ur.default)(this,`requestId`,void 0),this.requestId=0,this.runtime={},this.links=e.links.map(e=>e(this.runtime))}$request(e){return qt({links:this.links,op:(0,dr.default)((0,dr.default)({},e),{},{context:e.context??{},id:++this.requestId})}).pipe(Gt())}async requestAsPromise(e){var t=this;try{return(await Wt(t.$request(e))).result.data}catch(e){throw An.from(e)}}query(e,t,n){return this.requestAsPromise({type:`query`,path:e,input:t,context:n?.context,signal:n?.signal})}mutation(e,t,n){return this.requestAsPromise({type:`mutation`,path:e,input:t,context:n?.context,signal:n?.signal})}subscription(e,t,n){return this.$request({type:`subscription`,path:e,input:t,context:n.context,signal:n.signal}).subscribe({next(e){switch(e.result.type){case`state`:var t;(t=n.onConnectionStateChange)==null||t.call(n,e.result);break;case`started`:var r;(r=n.onStarted)==null||r.call(n,{context:e.context});break;case`stopped`:var i;(i=n.onStopped)==null||i.call(n);break;case`data`:case void 0:var a;(a=n.onData)==null||a.call(n,e.result.data);break}},error(e){var t;(t=n.onError)==null||t.call(n,e)},complete(){var e;(e=n.onComplete)==null||e.call(n)}})}},pr=Symbol.for(`trpc_untypedClient`),mr={query:`query`,mutate:`mutation`,subscribe:`subscription`},hr=e=>mr[e];function gr(e){let t=mn(({path:t,args:n})=>{let r=[...t],i=hr(r.pop()),a=r.join(`.`);return e[i](a,...n)});return hn(n=>n===pr?e:t[n])}function _r(e){return gr(new fr(e))}function vr(e){return e[pr]}It(Vt(),1),It(Vt(),1),It(Pt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function n(e){var t,n,i,a=2;for(typeof Symbol<`u`&&(n=Symbol.asyncIterator,i=Symbol.iterator);a--;){if(n&&(t=e[n])!=null)return t.call(e);if(i&&(t=e[i])!=null)return new r(t.call(e));n=`@@asyncIterator`,i=`@@iterator`}throw TypeError(`Object is not async iterable`)}function r(e){function t(e){if(Object(e)!==e)return Promise.reject(TypeError(e+` is not an object.`));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return r=function(e){this.s=e,this.n=e.next},r.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var n=this.s.return;return n===void 0?Promise.resolve({value:e,done:!0}):t(n.apply(this.s,arguments))},throw:function(e){var n=this.s.return;return n===void 0?Promise.reject(e):t(n.apply(this.s,arguments))}},new r(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}})(),1),It(Vt(),1);var yr=Pt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e,t){function n(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),br=Pt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e,t){function n(e,t){this.v=e,this.k=t}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),xr=Pt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e,t){var n=br();function r(e){return new n(e,0)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),Sr=Pt({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e,t){var n=br();function r(e){return function(){return new i(e.apply(this,arguments))}}function i(e){var t,r;function i(t,r){try{var o=e[t](r),s=o.value,c=s instanceof n;Promise.resolve(c?s.v:s).then(function(n){if(c){var r=t===`return`?`return`:`next`;if(!s.k||n.done)return i(r,n);n=e[r](n).value}a(o.done?`return`:`normal`,n)},function(e){i(`throw`,e)})}catch(e){a(`throw`,e)}}function a(e,n){switch(e){case`return`:t.resolve({value:n,done:!0});break;case`throw`:t.reject(n);break;default:t.resolve({value:n,done:!1})}(t=t.next)?i(t.key,t.arg):r=null}this._invoke=function(e,n){return new Promise(function(a,o){var s={key:e,arg:n,resolve:a,reject:o,next:null};r?r=r.next=s:(t=r=s,i(e,n))})},typeof e.return!=`function`&&(this.return=void 0)}i.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},i.prototype.next=function(e){return this._invoke(`next`,e)},i.prototype.throw=function(e){return this._invoke(`throw`,e)},i.prototype.return=function(e){return this._invoke(`return`,e)},t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}});It(yr(),1),It(xr(),1),It(Sr(),1),It(Vt(),1);var Cr=Object.create,wr=Object.defineProperty,Tr=Object.getOwnPropertyDescriptor,Er=Object.getOwnPropertyNames,Dr=Object.getPrototypeOf,Or=Object.prototype.hasOwnProperty,kr=(e,t)=>function(){return t||(0,e[Er(e)[0]])((t={exports:{}}).exports,t),t.exports},Ar=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Er(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Or.call(e,s)&&s!==n&&wr(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Tr(t,s))||r.enumerable});return e},jr=(e,t,n)=>(n=e==null?{}:Cr(Dr(e)),Ar(t||!e||!e.__esModule?wr(n,`default`,{value:e,enumerable:!0}):n,e)),Mr=kr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js"(e,t){function n(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),Nr=kr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js"(e,t){var n=Mr();function r(e,t){if(e==null)return{};var r,i,a=n(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),Pr=kr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(e){"@babel/helpers - typeof";return t.exports=n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t.exports.__esModule=!0,t.exports.default=t.exports,n(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),Fr=kr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=Pr().default;function r(e,t){if(n(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||`default`);if(n(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),Ir=kr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=Pr().default,r=Fr();function i(e){var t=r(e,`string`);return n(t)==`symbol`?t:t+``}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),Lr=kr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=Ir();function r(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),Rr=kr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=Lr();function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]==null?{}:arguments[t];t%2?r(Object(i),!0).forEach(function(t){n(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),zr=jr(Nr(),1),Br=jr(Rr(),1),Vr=[`cursor`,`direction`];function Hr(e,t,n){let r=e.flatMap(e=>e.split(`.`));if(!t&&(!n||n===`any`))return r.length?[r]:[];if(n===`infinite`&&Xt(t)&&(`direction`in t||`cursor`in t)){let{cursor:e,direction:n}=t;return[r,{input:(0,zr.default)(t,Vr),type:`infinite`}]}return[r,(0,Br.default)((0,Br.default)({},t!==void 0&&t!==re&&{input:t}),n&&n!==`any`&&{type:n})]}function Ur(e){return Hr(e,void 0,`any`)}function Wr(e){return mn(({path:t,args:n})=>{let r=[...t],i=r.pop();if(i===`useMutation`)return e[i](r,...n);if(i===`_def`)return{path:r};let[a,...o]=n,s=o[0]??{};return e[i](r,a,s)})}var Gr=[`client`,`ssrContext`,`ssrState`,`abortOnUnmount`],Kr=F.createContext?.call(F,null),qr=e=>{switch(e){case`queryOptions`:case`fetch`:case`ensureData`:case`prefetch`:case`getData`:case`setData`:case`setQueriesData`:return`query`;case`infiniteQueryOptions`:case`fetchInfinite`:case`prefetchInfinite`:case`getInfiniteData`:case`setInfiniteData`:return`infinite`;case`setMutationDefaults`:case`getMutationDefaults`:case`isMutating`:case`cancel`:case`invalidate`:case`refetch`:case`reset`:return`any`}};function Jr(e){return mn(t=>{let n=[...t.path],r=n.pop(),i=[...t.args],a=i.shift(),o=Hr(n,a,qr(r));return{infiniteQueryOptions:()=>e.infiniteQueryOptions(n,o,i[0]),queryOptions:()=>e.queryOptions(n,o,...i),fetch:()=>e.fetchQuery(o,...i),fetchInfinite:()=>e.fetchInfiniteQuery(o,i[0]),prefetch:()=>e.prefetchQuery(o,...i),prefetchInfinite:()=>e.prefetchInfiniteQuery(o,i[0]),ensureData:()=>e.ensureQueryData(o,...i),invalidate:()=>e.invalidateQueries(o,...i),reset:()=>e.resetQueries(o,...i),refetch:()=>e.refetchQueries(o,...i),cancel:()=>e.cancelQuery(o,...i),setData:()=>{e.setQueryData(o,i[0],i[1])},setQueriesData:()=>e.setQueriesData(o,i[0],i[1],i[2]),setInfiniteData:()=>{e.setInfiniteQueryData(o,i[0],i[1])},getData:()=>e.getQueryData(o),getInfiniteData:()=>e.getInfiniteQueryData(o),setMutationDefaults:()=>e.setMutationDefaults(Ur(n),a),getMutationDefaults:()=>e.getMutationDefaults(Ur(n)),isMutating:()=>e.isMutating({mutationKey:Ur(n)})}[r]()})}function Yr(e){let t=gr(e.client),n=Jr(e);return hn(r=>{let i=r;return i===`client`?t:Gr.includes(i)?e[i]:n[r]})}var Xr=jr(Rr(),1);function Zr(e){let t=e instanceof fr?e:vr(e);return mn(e=>{let n=e.path,r=n.join(`.`),[i,a]=e.args;return(0,Xr.default)({queryKey:Hr(n,i,`query`),queryFn:()=>t.query(r,i,a?.trpc)},a)})}var Qr=jr(Rr(),1);function $r(e,t,n){let r=e[0],i=e[1]?.input;return n&&(i=(0,Qr.default)((0,Qr.default)((0,Qr.default)({},i??{}),n.pageParam?{cursor:n.pageParam}:{}),{},{direction:n.direction})),[r.join(`.`),i,t?.trpc]}var ei=jr(kr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function n(e){var t,n,i,a=2;for(typeof Symbol<`u`&&(n=Symbol.asyncIterator,i=Symbol.iterator);a--;){if(n&&(t=e[n])!=null)return t.call(e);if(i&&(t=e[i])!=null)return new r(t.call(e));n=`@@asyncIterator`,i=`@@iterator`}throw TypeError(`Object is not async iterable`)}function r(e){function t(e){if(Object(e)!==e)return Promise.reject(TypeError(e+` is not an object.`));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return r=function(e){this.s=e,this.n=e.next},r.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var n=this.s.return;return n===void 0?Promise.resolve({value:e,done:!0}):t(n.apply(this.s,arguments))},throw:function(e){var n=this.s.return;return n===void 0?Promise.reject(e):t(n.apply(this.s,arguments))}},new r(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}})(),1);function ti(e){return{path:e.path.join(`.`)}}function ni(e){let t=ti(e);return F.useMemo(()=>t,[t])}async function ri(e,t,n){let r=t.getQueryCache().build(t,{queryKey:n});r.setState({data:[],status:`success`});let i=[];var a=!1,o=!1,s;try{for(var c=(0,ei.default)(e),l;a=!(l=await c.next()).done;a=!1){let e=l.value;i.push(e),r.setState({data:[...i]})}}catch(e){o=!0,s=e}finally{try{a&&c.return!=null&&await c.return()}finally{if(o)throw s}}return i}var ii=jr(Rr(),1);function ai(e){let{client:t,queryClient:n}=e,r=t instanceof fr?t:vr(t);return{infiniteQueryOptions:(e,t,n)=>{let i=t[1]?.input===re;return Object.assign(yt((0,ii.default)((0,ii.default)({},n),{},{initialData:n?.initialData,queryKey:t,queryFn:i?re:async e=>{var i;let a=(0,ii.default)((0,ii.default)({},n),{},{trpc:(0,ii.default)((0,ii.default)({},n?.trpc),!(n==null||(i=n.trpc)==null)&&i.abortOnUnmount?{signal:e.signal}:{signal:null})});return await r.query(...$r(t,a,{direction:e.direction,pageParam:e.pageParam}))},initialPageParam:n?.initialCursor??null})),{trpc:ti({path:e})})},queryOptions:(e,t,i)=>{let a=t[1]?.input===re;return Object.assign(vt((0,ii.default)((0,ii.default)({},i),{},{initialData:i?.initialData,queryKey:t,queryFn:a?re:async e=>{var a;let o=(0,ii.default)((0,ii.default)({},i),{},{trpc:(0,ii.default)((0,ii.default)({},i?.trpc),!(i==null||(a=i.trpc)==null)&&a.abortOnUnmount?{signal:e.signal}:{signal:null})}),s=await r.query(...$r(t,o));return $t(s)?ri(s,n,t):s}})),{trpc:ti({path:e})})},fetchQuery:(e,t)=>n.fetchQuery((0,ii.default)((0,ii.default)({},t),{},{queryKey:e,queryFn:()=>r.query(...$r(e,t))})),fetchInfiniteQuery:(e,t)=>n.fetchInfiniteQuery((0,ii.default)((0,ii.default)({},t),{},{queryKey:e,queryFn:({pageParam:n,direction:i})=>r.query(...$r(e,t,{pageParam:n,direction:i})),initialPageParam:t?.initialCursor??null})),prefetchQuery:(e,t)=>n.prefetchQuery((0,ii.default)((0,ii.default)({},t),{},{queryKey:e,queryFn:()=>r.query(...$r(e,t))})),prefetchInfiniteQuery:(e,t)=>n.prefetchInfiniteQuery((0,ii.default)((0,ii.default)({},t),{},{queryKey:e,queryFn:({pageParam:n,direction:i})=>r.query(...$r(e,t,{pageParam:n,direction:i})),initialPageParam:t?.initialCursor??null})),ensureQueryData:(e,t)=>n.ensureQueryData((0,ii.default)((0,ii.default)({},t),{},{queryKey:e,queryFn:()=>r.query(...$r(e,t))})),invalidateQueries:(e,t,r)=>n.invalidateQueries((0,ii.default)((0,ii.default)({},t),{},{queryKey:e}),r),resetQueries:(e,t,r)=>n.resetQueries((0,ii.default)((0,ii.default)({},t),{},{queryKey:e}),r),refetchQueries:(e,t,r)=>n.refetchQueries((0,ii.default)((0,ii.default)({},t),{},{queryKey:e}),r),cancelQuery:(e,t)=>n.cancelQueries({queryKey:e},t),setQueryData:(e,t,r)=>n.setQueryData(e,t,r),setQueriesData:(e,t,r,i)=>n.setQueriesData((0,ii.default)((0,ii.default)({},t),{},{queryKey:e}),r,i),getQueryData:e=>n.getQueryData(e),setInfiniteQueryData:(e,t,r)=>n.setQueryData(e,t,r),getInfiniteQueryData:e=>n.getQueryData(e),setMutationDefaults:(t,i)=>{let a=t[0];return n.setMutationDefaults(t,typeof i==`function`?i({canonicalMutationFn:t=>r.mutation(...$r([a,{input:t}],e))}):i)},getMutationDefaults:e=>n.getMutationDefaults(e),isMutating:e=>n.isMutating((0,ii.default)((0,ii.default)({},e),{},{exact:!0}))}}var L=jr(Rr()),oi=(e,t)=>new Proxy(e,{get(e,n){return t(n),e[n]}});function si(e){var t;let n=(e==null||(t=e.overrides)==null||(t=t.useMutation)==null?void 0:t.onSuccess)??(e=>e.originalFn()),r=e?.context??Kr,i=_r,a=e=>{let{abortOnUnmount:t=!1,queryClient:n,ssrContext:i}=e,[a,o]=F.useState(e.ssrState??!1),s=e.client instanceof fr?e.client:vr(e.client),c=F.useMemo(()=>ai({client:s,queryClient:n}),[s,n]),l=F.useMemo(()=>(0,L.default)({abortOnUnmount:t,queryClient:n,client:s,ssrContext:i??null,ssrState:a},c),[t,s,c,n,i,a]);return F.useEffect(()=>{o(e=>e?`mounted`:!1)},[]),(0,I.jsx)(r.Provider,{value:l,children:e.children})};function o(){let e=F.useContext(r);if(!e)throw Error("Unable to find tRPC Context. Did you forget to wrap your App inside `withTRPC` HoC?");return e}function s(e,t){let{queryClient:n,ssrState:r}=o();return r&&r!==`mounted`&&n.getQueryCache().find({queryKey:e})?.state.status===`error`?(0,L.default)({retryOnMount:!1},t):t}function c(t,n,r){var i,a;let{abortOnUnmount:c,client:l,ssrState:u,queryClient:d,prefetchQuery:f}=o(),p=Hr(t,n,`query`),m=d.getQueryDefaults(p),h=n===re;typeof window>`u`&&u===`prepass`&&(r==null||(i=r.trpc)==null?void 0:i.ssr)!==!1&&(r?.enabled??m?.enabled)!==!1&&!h&&!d.getQueryCache().find({queryKey:p})&&f(p,r);let g=s(p,(0,L.default)((0,L.default)({},m),r)),_=(r==null||(a=r.trpc)==null?void 0:a.abortOnUnmount)??e?.abortOnUnmount??c,v=ft((0,L.default)((0,L.default)({},g),{},{queryKey:p,queryFn:h?n:async e=>{let t=(0,L.default)((0,L.default)({},g),{},{trpc:(0,L.default)((0,L.default)({},g?.trpc),_?{signal:e.signal}:{signal:null})}),n=await l.query(...$r(p,t));return $t(n)?ri(n,d,p):n}}),d);return v.trpc=ni({path:t}),v}function l(t,n,r){var i;let a=o(),s=Hr(t,n,`query`),c=n===re,l=(r==null||(i=r.trpc)==null?void 0:i.abortOnUnmount)??e?.abortOnUnmount??a.abortOnUnmount;gt((0,L.default)((0,L.default)({},r),{},{queryKey:s,queryFn:c?n:e=>{let t={trpc:(0,L.default)((0,L.default)({},r?.trpc),l?{signal:e.signal}:{})};return a.client.query(...$r(s,t))}}))}function u(t,n,r){var i;let a=o(),s=Hr(t,n,`query`),c=(r==null||(i=r.trpc)==null?void 0:i.abortOnUnmount)??e?.abortOnUnmount??a.abortOnUnmount,l=pt((0,L.default)((0,L.default)({},r),{},{queryKey:s,queryFn:e=>{let t=(0,L.default)((0,L.default)({},r),{},{trpc:(0,L.default)((0,L.default)({},r?.trpc),c?{signal:e.signal}:{signal:null})});return a.client.query(...$r(s,t))}}),a.queryClient);return l.trpc=ni({path:t}),[l.data,l]}function d(e,t){let{client:r,queryClient:i}=o(),a=Ur(e),s=i.defaultMutationOptions(i.getMutationDefaults(a)),c=bt((0,L.default)((0,L.default)({},t),{},{mutationKey:a,mutationFn:n=>r.mutation(...$r([e,{input:n}],t)),onSuccess(...e){return n({originalFn:()=>{var n,r;return(t==null||(n=t.onSuccess)==null?void 0:n.call(t,...e))??(s==null||(r=s.onSuccess)==null?void 0:r.call(s,...e))},queryClient:i,meta:t?.meta??s?.meta??{}})}}),i);return c.trpc=ni({path:e}),c}let f={data:void 0,error:null,status:`idle`},p={data:void 0,error:null,status:`connecting`};function m(e,t,n){let r=n?.enabled??t!==re,i=T(Hr(e,t,`any`)),{client:a}=o(),s=F.useRef(n);F.useEffect(()=>{s.current=n});let[c]=F.useState(new Set([])),l=F.useCallback(e=>{c.add(e)},[c]),u=F.useRef(null),d=F.useCallback(e=>{let t=h.current,n=h.current=e(t),r=!1;for(let e of c)if(t[e]!==n[e]){r=!0;break}r&&_(oi(n,l))},[l,c]),m=F.useCallback(()=>{var n;if((n=u.current)==null||n.unsubscribe(),!r){d(()=>(0,L.default)((0,L.default)({},f),{},{reset:m}));return}d(()=>(0,L.default)((0,L.default)({},p),{},{reset:m}));let i=a.subscription(e.join(`.`),t??void 0,{onStarted:()=>{var e,t;(e=(t=s.current).onStarted)==null||e.call(t),d(e=>(0,L.default)((0,L.default)({},e),{},{status:`pending`,error:null}))},onData:e=>{var t,n;(t=(n=s.current).onData)==null||t.call(n,e),d(t=>(0,L.default)((0,L.default)({},t),{},{status:`pending`,data:e,error:null}))},onError:e=>{var t,n;(t=(n=s.current).onError)==null||t.call(n,e),d(t=>(0,L.default)((0,L.default)({},t),{},{status:`error`,error:e}))},onConnectionStateChange:e=>{d(t=>{switch(e.state){case`idle`:return(0,L.default)((0,L.default)({},t),{},{status:e.state,error:null,data:void 0});case`connecting`:return(0,L.default)((0,L.default)({},t),{},{error:e.error,status:e.state});case`pending`:return t}})},onComplete:()=>{var e,t;(e=(t=s.current).onComplete)==null||e.call(t),d(e=>(0,L.default)((0,L.default)({},e),{},{status:`idle`,error:null,data:void 0}))}});u.current=i},[a,i,r,d]);F.useEffect(()=>(m(),()=>{var e;(e=u.current)==null||e.unsubscribe()}),[m]);let h=F.useRef(r?(0,L.default)((0,L.default)({},p),{},{reset:m}):(0,L.default)((0,L.default)({},f),{},{reset:m})),[g,_]=F.useState(oi(h.current,l));return g}function h(e,t,n){var r,i;let{client:a,ssrState:c,prefetchInfiniteQuery:l,queryClient:u,abortOnUnmount:d}=o(),f=Hr(e,t,`infinite`),p=u.getQueryDefaults(f),m=t===re;typeof window>`u`&&c===`prepass`&&(n==null||(r=n.trpc)==null?void 0:r.ssr)!==!1&&(n?.enabled??p?.enabled)!==!1&&!m&&!u.getQueryCache().find({queryKey:f})&&l(f,(0,L.default)((0,L.default)({},p),n));let h=s(f,(0,L.default)((0,L.default)({},p),n)),g=(n==null||(i=n.trpc)==null?void 0:i.abortOnUnmount)??d,_=xt((0,L.default)((0,L.default)({},h),{},{initialPageParam:n.initialCursor??null,persister:n.persister,queryKey:f,queryFn:m?t:e=>{let t=(0,L.default)((0,L.default)({},h),{},{trpc:(0,L.default)((0,L.default)({},h?.trpc),g?{signal:e.signal}:{signal:null})});return a.query(...$r(f,t,{pageParam:e.pageParam??n.initialCursor,direction:e.direction}))}}),u);return _.trpc=ni({path:e}),_}function g(e,t,n){var r;let i=o(),a=Hr(e,t,`infinite`),c=i.queryClient.getQueryDefaults(a),l=t===re,u=s(a,(0,L.default)((0,L.default)({},c),n)),d=(n==null||(r=n.trpc)==null?void 0:r.abortOnUnmount)??i.abortOnUnmount;_t((0,L.default)((0,L.default)({},n),{},{initialPageParam:n.initialCursor??null,queryKey:a,queryFn:l?t:e=>{let t=(0,L.default)((0,L.default)({},u),{},{trpc:(0,L.default)((0,L.default)({},u?.trpc),d?{signal:e.signal}:{})});return i.client.query(...$r(a,t,{pageParam:e.pageParam??n.initialCursor,direction:e.direction}))}}))}function _(e,t,n){var r;let i=o(),a=Hr(e,t,`infinite`),c=i.queryClient.getQueryDefaults(a),l=s(a,(0,L.default)((0,L.default)({},c),n)),u=(n==null||(r=n.trpc)==null?void 0:r.abortOnUnmount)??i.abortOnUnmount,d=mt((0,L.default)((0,L.default)({},n),{},{initialPageParam:n.initialCursor??null,queryKey:a,queryFn:e=>{let t=(0,L.default)((0,L.default)({},l),{},{trpc:(0,L.default)((0,L.default)({},l?.trpc),u?{signal:e.signal}:{})});return i.client.query(...$r(a,t,{pageParam:e.pageParam??n.initialCursor,direction:e.direction}))}}),i.queryClient);return d.trpc=ni({path:e}),[d.data,d]}return{Provider:a,createClient:i,useContext:o,useUtils:o,useQuery:c,usePrefetchQuery:l,useSuspenseQuery:u,useQueries:(e,t)=>{let{ssrState:n,queryClient:r,prefetchQuery:i,client:a}=o(),s=e(Zr(a));if(typeof window>`u`&&n===`prepass`)for(let e of s){let t=e;t.trpc?.ssr!==!1&&!r.getQueryCache().find({queryKey:t.queryKey})&&i(t.queryKey,t)}return ut({queries:s.map(e=>(0,L.default)((0,L.default)({},e),{},{queryKey:e.queryKey})),combine:t?.combine},r)},useSuspenseQueries:e=>{let{queryClient:t,client:n}=o(),r=ht({queries:e(Zr(n)).map(e=>(0,L.default)((0,L.default)({},e),{},{queryFn:e.queryFn,queryKey:e.queryKey}))},t);return[r.map(e=>e.data),r]},useMutation:d,useSubscription:m,useInfiniteQuery:h,usePrefetchInfiniteQuery:g,useSuspenseInfiniteQuery:_}}function ci(e){let t=Wr(e);return hn(n=>n===`useContext`||n===`useUtils`?()=>{let t=e.useUtils();return F.useMemo(()=>Yr(t),[t])}:e.hasOwnProperty(n)?e[n]:t[n])}function li(e){return ci(si(e))}var R=li(),ui=new Set([`setup.doctor`,`system.checkUpdate`,`system.burnCache.status`,`project.branches`,`project.sessionBranch`,`project.prep`,`feature.mergeDelta`,`feature.commitCount`,`thread.usage`,`thread.models`,`thread.events`,`thread.list`]);function di(e,t){let n={url:e,...t?{fetch:t}:{}};return[Yt({condition:e=>ui.has(e.path),true:Xn(n),false:tr(n)})]}var fi=`preview.html`,pi;function z(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var mi=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},hi=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(pi=globalThis).__zod_globalConfig??(pi.__zod_globalConfig={});var gi=globalThis.__zod_globalConfig;function _i(e){return e&&Object.assign(gi,e),gi}function vi(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function yi(e,t){return typeof t==`bigint`?t.toString():t}function bi(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function xi(e){return e==null}function Si(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Ci(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var wi=Symbol(`evaluating`);function Ti(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==wi)return r===void 0&&(r=wi,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ei(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Di(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Oi(e){return JSON.stringify(e)}function ki(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Ai=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ji(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Mi=bi(()=>{if(gi.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Ni(e){if(ji(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(ji(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Pi(e){return Ni(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Fi=new Set([`string`,`number`,`symbol`]);function Ii(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Li(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function B(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ri(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var zi={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Bi(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Li(e,Di(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Ei(this,`shape`,e),e},checks:[]}))}function Vi(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Li(e,Di(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Ei(this,`shape`,r),r},checks:[]}))}function Hi(e,t){if(!Ni(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Li(e,Di(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Ei(this,`shape`,n),n}}))}function Ui(e,t){if(!Ni(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Li(e,Di(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Ei(this,`shape`,n),n}}))}function Wi(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Li(e,Di(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Ei(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Gi(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Li(t,Di(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Ei(this,`shape`,i),i},checks:[]}))}function Ki(e,t,n){return Li(t,Di(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Ei(this,`shape`,i),i}}))}function qi(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ji(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Yi(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Xi(e){return typeof e==`string`?e:e?.message}function Zi(e,t,n){let r=e.message?e.message:Xi(e.inst?._zod.def?.error?.(e))??Xi(t?.error?.(e))??Xi(n.customError?.(e))??Xi(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Qi(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function $i(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var ea=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,yi,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ta=z(`$ZodError`,ea),na=z(`$ZodError`,ea,{Parent:Error});function ra(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function ia(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var aa=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new mi;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Zi(e,a,_i())));throw Ai(t,i?.callee),t}return o.value},oa=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Zi(e,a,_i())));throw Ai(t,i?.callee),t}return o.value},sa=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new mi;return a.issues.length?{success:!1,error:new(e??ta)(a.issues.map(e=>Zi(e,i,_i())))}:{success:!0,data:a.value}},ca=sa(na),la=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Zi(e,i,_i())))}:{success:!0,data:a.value}},ua=la(na),da=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return aa(e)(t,n,i)},fa=e=>(t,n,r)=>aa(e)(t,n,r),pa=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return oa(e)(t,n,i)},ma=e=>async(t,n,r)=>oa(e)(t,n,r),ha=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return sa(e)(t,n,i)},ga=e=>(t,n,r)=>sa(e)(t,n,r),_a=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return la(e)(t,n,i)},va=e=>async(t,n,r)=>la(e)(t,n,r),ya=/^[cC][0-9a-z]{6,}$/,ba=/^[0-9a-z]+$/,xa=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Sa=/^[0-9a-vA-V]{20}$/,Ca=/^[A-Za-z0-9]{27}$/,wa=/^[a-zA-Z0-9_-]{21}$/,Ta=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ea=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Da=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Oa=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ka=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Aa(){return new RegExp(ka,`u`)}var ja=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ma=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Na=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Pa=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Fa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ia=/^[A-Za-z0-9_-]*$/,La=/^https?$/,Ra=/^\+[1-9]\d{6,14}$/,za=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Ba=RegExp(`^${za}$`);function Va(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ha(e){return RegExp(`^${Va(e)}$`)}function Ua(e){let t=Va({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${za}T(?:${r})$`)}var Wa=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Ga=/^-?\d+$/,Ka=/^-?\d+(?:\.\d+)?$/,qa=/^(?:true|false)$/i,Ja=/^null$/i,Ya=/^[^A-Z]*$/,Xa=/^[^a-z]*$/,Za=z(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Qa={number:`number`,bigint:`bigint`,object:`date`},$a=z(`$ZodCheckLessThan`,(e,t)=>{Za.init(e,t);let n=Qa[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),eo=z(`$ZodCheckGreaterThan`,(e,t)=>{Za.init(e,t);let n=Qa[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),to=z(`$ZodCheckMultipleOf`,(e,t)=>{Za.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Ci(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),no=z(`$ZodCheckNumberFormat`,(e,t)=>{Za.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=zi[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Ga)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),ro=z(`$ZodCheckMaxLength`,(e,t)=>{var n;Za.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!xi(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Qi(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),io=z(`$ZodCheckMinLength`,(e,t)=>{var n;Za.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!xi(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Qi(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ao=z(`$ZodCheckLengthEquals`,(e,t)=>{var n;Za.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!xi(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Qi(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),oo=z(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Za.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),so=z(`$ZodCheckRegex`,(e,t)=>{oo.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),co=z(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Ya,oo.init(e,t)}),lo=z(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Xa,oo.init(e,t)}),uo=z(`$ZodCheckIncludes`,(e,t)=>{Za.init(e,t);let n=Ii(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),fo=z(`$ZodCheckStartsWith`,(e,t)=>{Za.init(e,t);let n=RegExp(`^${Ii(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),po=z(`$ZodCheckEndsWith`,(e,t)=>{Za.init(e,t);let n=RegExp(`.*${Ii(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),mo=z(`$ZodCheckOverwrite`,(e,t)=>{Za.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),ho=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
10
|
-
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
11
|
-
`))}},go={major:4,minor:4,patch:3},_o=z(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=go;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=qi(e),i;for(let a of t){if(a._zod.def.when){if(Ji(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new mi;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=qi(e,t))});else{if(e.issues.length===t)continue;r||=qi(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(qi(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new mi;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new mi;return o.then(e=>t(e,r,a))}return t(o,r,a)}}Ti(e,`~standard`,()=>({validate:t=>{try{let n=ca(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return ua(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),vo=z(`$ZodString`,(e,t)=>{_o.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Wa(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),yo=z(`$ZodStringFormat`,(e,t)=>{oo.init(e,t),vo.init(e,t)}),bo=z(`$ZodGUID`,(e,t)=>{t.pattern??=Ea,yo.init(e,t)}),xo=z(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Da(e)}else t.pattern??=Da();yo.init(e,t)}),So=z(`$ZodEmail`,(e,t)=>{t.pattern??=Oa,yo.init(e,t)}),Co=z(`$ZodURL`,(e,t)=>{yo.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===La.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),wo=z(`$ZodEmoji`,(e,t)=>{t.pattern??=Aa(),yo.init(e,t)}),To=z(`$ZodNanoID`,(e,t)=>{t.pattern??=wa,yo.init(e,t)}),Eo=z(`$ZodCUID`,(e,t)=>{t.pattern??=ya,yo.init(e,t)}),Do=z(`$ZodCUID2`,(e,t)=>{t.pattern??=ba,yo.init(e,t)}),Oo=z(`$ZodULID`,(e,t)=>{t.pattern??=xa,yo.init(e,t)}),ko=z(`$ZodXID`,(e,t)=>{t.pattern??=Sa,yo.init(e,t)}),Ao=z(`$ZodKSUID`,(e,t)=>{t.pattern??=Ca,yo.init(e,t)}),jo=z(`$ZodISODateTime`,(e,t)=>{t.pattern??=Ua(t),yo.init(e,t)}),Mo=z(`$ZodISODate`,(e,t)=>{t.pattern??=Ba,yo.init(e,t)}),No=z(`$ZodISOTime`,(e,t)=>{t.pattern??=Ha(t),yo.init(e,t)}),Po=z(`$ZodISODuration`,(e,t)=>{t.pattern??=Ta,yo.init(e,t)}),Fo=z(`$ZodIPv4`,(e,t)=>{t.pattern??=ja,yo.init(e,t),e._zod.bag.format=`ipv4`}),Io=z(`$ZodIPv6`,(e,t)=>{t.pattern??=Ma,yo.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Lo=z(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Na,yo.init(e,t)}),Ro=z(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Pa,yo.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function zo(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Bo=z(`$ZodBase64`,(e,t)=>{t.pattern??=Fa,yo.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{zo(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Vo(e){if(!Ia.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return zo(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Ho=z(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ia,yo.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Vo(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Uo=z(`$ZodE164`,(e,t)=>{t.pattern??=Ra,yo.init(e,t)});function Wo(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Go=z(`$ZodJWT`,(e,t)=>{yo.init(e,t),e._zod.check=n=>{Wo(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Ko=z(`$ZodNumber`,(e,t)=>{_o.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ka,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),qo=z(`$ZodNumberFormat`,(e,t)=>{no.init(e,t),Ko.init(e,t)}),Jo=z(`$ZodBoolean`,(e,t)=>{_o.init(e,t),e._zod.pattern=qa,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Yo=z(`$ZodNull`,(e,t)=>{_o.init(e,t),e._zod.pattern=Ja,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Xo=z(`$ZodUnknown`,(e,t)=>{_o.init(e,t),e._zod.parse=e=>e}),Zo=z(`$ZodNever`,(e,t)=>{_o.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Qo(e,t,n){e.issues.length&&t.issues.push(...Yi(n,e.issues)),t.value[n]=e.value}var $o=z(`$ZodArray`,(e,t)=>{_o.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Qo(t,n,e))):Qo(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function es(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...Yi(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function ts(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Ri(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function ns(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>es(e,n,i,t,u,d))):es(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var rs=z(`$ZodObject`,(e,t)=>{if(_o.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=bi(()=>ts(t));Ti(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=ji,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>es(n,t,e,s,r,i))):es(a,t,e,s,r,i)}return i?ns(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),is=z(`$ZodObjectJIT`,(e,t)=>{rs.init(e,t);let n=e._zod.parse,r=bi(()=>ts(t)),i=e=>{let t=new ho([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Oi(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Oi(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
12
|
-
if (${n}.issues.length) {
|
|
13
|
-
if (${o} in input) {
|
|
14
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
15
|
-
...iss,
|
|
16
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
17
|
-
})));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (${n}.value === undefined) {
|
|
22
|
-
if (${o} in input) {
|
|
23
|
-
newResult[${o}] = undefined;
|
|
24
|
-
}
|
|
25
|
-
} else {
|
|
26
|
-
newResult[${o}] = ${n}.value;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
`):c?t.write(`
|
|
30
|
-
if (${n}.issues.length) {
|
|
31
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
32
|
-
...iss,
|
|
33
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
34
|
-
})));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (${n}.value === undefined) {
|
|
38
|
-
if (${o} in input) {
|
|
39
|
-
newResult[${o}] = undefined;
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
newResult[${o}] = ${n}.value;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
`):t.write(`
|
|
46
|
-
const ${n}_present = ${o} in input;
|
|
47
|
-
if (${n}.issues.length) {
|
|
48
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
49
|
-
...iss,
|
|
50
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
51
|
-
})));
|
|
52
|
-
}
|
|
53
|
-
if (!${n}_present && !${n}.issues.length) {
|
|
54
|
-
payload.issues.push({
|
|
55
|
-
code: "invalid_type",
|
|
56
|
-
expected: "nonoptional",
|
|
57
|
-
input: undefined,
|
|
58
|
-
path: [${o}]
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (${n}_present) {
|
|
63
|
-
if (${n}.value === undefined) {
|
|
64
|
-
newResult[${o}] = undefined;
|
|
65
|
-
} else {
|
|
66
|
-
newResult[${o}] = ${n}.value;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=ji,s=!gi.jitless,c=s&&Mi.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?ns([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function as(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!qi(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Zi(e,r,_i())))}),t)}var os=z(`$ZodUnion`,(e,t)=>{_o.init(e,t),Ti(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),Ti(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Ti(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Ti(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Si(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>as(t,r,e,i)):as(o,r,e,i)}}),ss=z(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,os.init(e,t);let n=e._zod.parse;Ti(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=bi(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!ji(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),cs=z(`$ZodIntersection`,(e,t)=>{_o.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>us(e,t,n)):us(e,i,a)}});function ls(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ni(e)&&Ni(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=ls(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=ls(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function us(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),qi(e))return e;let o=ls(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var ds=z(`$ZodTuple`,(e,t)=>{_o.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=fs(n,`optin`),c=fs(n,`optout`);if(!t.rest){if(a.length<s)return r.issues.push({code:`too_small`,minimum:s,inclusive:!0,input:a,inst:e,origin:`array`}),r;a.length>n.length&&r.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:a,inst:e,origin:`array`})}let l=Array(n.length);for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:a[e],issues:[]},i);t instanceof Promise?o.push(t.then(t=>{l[e]=t})):l[e]=t}if(t.rest){let e=n.length-1,s=a.slice(n.length);for(let n of s){e++;let a=t.rest._zod.run({value:n,issues:[]},i);a instanceof Promise?o.push(a.then(t=>ps(t,r,e))):ps(a,r,e)}}return o.length?Promise.all(o).then(()=>ms(l,r,n,a,c)):ms(l,r,n,a,c)}});function fs(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]._zod[t]!==`optional`)return n+1;return 0}function ps(e,t,n){e.issues.length&&t.issues.push(...Yi(n,e.issues)),t.value[n]=e.value}function ms(e,t,n,r,i){for(let a=0;a<n.length;a++){let n=e[a],o=a<r.length;if(n.issues.length){if(!o&&a>=i){t.value.length=a;break}t.issues.push(...Yi(a,n.issues))}t.value[a]=n.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}var hs=z(`$ZodRecord`,(e,t)=>{_o.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Ni(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>Zi(e,r,_i())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...Yi(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Yi(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Ka.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Zi(e,r,_i())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Yi(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Yi(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),gs=z(`$ZodEnum`,(e,t)=>{_o.init(e,t);let n=vi(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Fi.has(typeof e)).map(e=>typeof e==`string`?Ii(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),_s=z(`$ZodLiteral`,(e,t)=>{if(_o.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Ii(e):e?Ii(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),vs=z(`$ZodTransform`,(e,t)=>{_o.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new hi(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new mi;return n.value=i,n.fallback=!0,n}});function ys(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var bs=z(`$ZodOptional`,(e,t)=>{_o.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,Ti(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ti(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Si(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>ys(e,r)):ys(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),xs=z(`$ZodExactOptional`,(e,t)=>{bs.init(e,t),Ti(e._zod,`values`,()=>t.innerType._zod.values),Ti(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ss=z(`$ZodNullable`,(e,t)=>{_o.init(e,t),Ti(e._zod,`optin`,()=>t.innerType._zod.optin),Ti(e._zod,`optout`,()=>t.innerType._zod.optout),Ti(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Si(e.source)}|null)$`):void 0}),Ti(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Cs=z(`$ZodDefault`,(e,t)=>{_o.init(e,t),e._zod.optin=`optional`,Ti(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>ws(e,t)):ws(r,t)}});function ws(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ts=z(`$ZodPrefault`,(e,t)=>{_o.init(e,t),e._zod.optin=`optional`,Ti(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Es=z(`$ZodNonOptional`,(e,t)=>{_o.init(e,t),Ti(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ds(t,e)):Ds(i,e)}});function Ds(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Os=z(`$ZodCatch`,(e,t)=>{_o.init(e,t),e._zod.optin=`optional`,Ti(e._zod,`optout`,()=>t.innerType._zod.optout),Ti(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Zi(e,n,_i()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Zi(e,n,_i()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),ks=z(`$ZodPipe`,(e,t)=>{_o.init(e,t),Ti(e._zod,`values`,()=>t.in._zod.values),Ti(e._zod,`optin`,()=>t.in._zod.optin),Ti(e._zod,`optout`,()=>t.out._zod.optout),Ti(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>As(e,t.in,n)):As(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>As(e,t.out,n)):As(r,t.out,n)}});function As(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var js=z(`$ZodPreprocess`,(e,t)=>{ks.init(e,t)}),Ms=z(`$ZodReadonly`,(e,t)=>{_o.init(e,t),Ti(e._zod,`propValues`,()=>t.innerType._zod.propValues),Ti(e._zod,`values`,()=>t.innerType._zod.values),Ti(e._zod,`optin`,()=>t.innerType?._zod?.optin),Ti(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ns):Ns(r)}});function Ns(e){return e.value=Object.freeze(e.value),e}var Ps=z(`$ZodCustom`,(e,t)=>{Za.init(e,t),_o.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Fs(t,n,r,e));Fs(i,n,r,e)}});function Fs(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push($i(e))}}var Is,Ls=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Rs(){return new Ls}(Is=globalThis).__zod_globalRegistry??(Is.__zod_globalRegistry=Rs());var zs=globalThis.__zod_globalRegistry;function Bs(e,t){return new e({type:`string`,...B(t)})}function Vs(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...B(t)})}function Hs(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...B(t)})}function Us(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...B(t)})}function Ws(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...B(t)})}function Gs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...B(t)})}function Ks(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...B(t)})}function qs(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...B(t)})}function Js(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...B(t)})}function Ys(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...B(t)})}function Xs(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...B(t)})}function Zs(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...B(t)})}function Qs(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...B(t)})}function $s(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...B(t)})}function ec(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...B(t)})}function tc(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...B(t)})}function nc(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...B(t)})}function rc(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...B(t)})}function ic(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...B(t)})}function ac(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...B(t)})}function oc(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...B(t)})}function sc(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...B(t)})}function cc(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...B(t)})}function lc(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...B(t)})}function uc(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...B(t)})}function dc(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...B(t)})}function fc(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...B(t)})}function pc(e,t){return new e({type:`number`,checks:[],...B(t)})}function mc(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...B(t)})}function hc(e,t){return new e({type:`boolean`,...B(t)})}function gc(e,t){return new e({type:`null`,...B(t)})}function _c(e){return new e({type:`unknown`})}function vc(e,t){return new e({type:`never`,...B(t)})}function yc(e,t){return new $a({check:`less_than`,...B(t),value:e,inclusive:!1})}function bc(e,t){return new $a({check:`less_than`,...B(t),value:e,inclusive:!0})}function xc(e,t){return new eo({check:`greater_than`,...B(t),value:e,inclusive:!1})}function Sc(e,t){return new eo({check:`greater_than`,...B(t),value:e,inclusive:!0})}function Cc(e,t){return new to({check:`multiple_of`,...B(t),value:e})}function wc(e,t){return new ro({check:`max_length`,...B(t),maximum:e})}function Tc(e,t){return new io({check:`min_length`,...B(t),minimum:e})}function Ec(e,t){return new ao({check:`length_equals`,...B(t),length:e})}function Dc(e,t){return new so({check:`string_format`,format:`regex`,...B(t),pattern:e})}function Oc(e){return new co({check:`string_format`,format:`lowercase`,...B(e)})}function kc(e){return new lo({check:`string_format`,format:`uppercase`,...B(e)})}function Ac(e,t){return new uo({check:`string_format`,format:`includes`,...B(t),includes:e})}function jc(e,t){return new fo({check:`string_format`,format:`starts_with`,...B(t),prefix:e})}function Mc(e,t){return new po({check:`string_format`,format:`ends_with`,...B(t),suffix:e})}function Nc(e){return new mo({check:`overwrite`,tx:e})}function Pc(e){return Nc(t=>t.normalize(e))}function Fc(){return Nc(e=>e.trim())}function Ic(){return Nc(e=>e.toLowerCase())}function Lc(){return Nc(e=>e.toUpperCase())}function Rc(){return Nc(e=>ki(e))}function zc(e,t,n){return new e({type:`array`,element:t,...B(n)})}function Bc(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...B(n)})}function Vc(e,t){let n=Hc(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push($i(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push($i(r))}},e(t.value,t)),t);return n}function Hc(e,t){let n=new Za({check:`custom`,...B(t)});return n._zod.check=e,n}function Uc(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??zs,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Wc(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Wc(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&qc(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Gc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
71
|
-
|
|
72
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Kc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Yc(t,`input`,e.processors),output:Yc(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function qc(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return qc(r.element,n);if(r.type===`set`)return qc(r.valueType,n);if(r.type===`lazy`)return qc(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return qc(r.innerType,n);if(r.type===`intersection`)return qc(r.left,n)||qc(r.right,n);if(r.type===`record`||r.type===`map`)return qc(r.keyType,n)||qc(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:qc(r.in,n)||qc(r.out,n);if(r.type===`object`){for(let e in r.shape)if(qc(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(qc(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(qc(e,n))return!0;return!!(r.rest&&qc(r.rest,n))}return!1}var Jc=(e,t={})=>n=>{let r=Uc({...n,processors:t});return Wc(e,r),Gc(r,e),Kc(r,e)},Yc=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Uc({...i??{},target:a,io:t,processors:n});return Wc(e,o),Gc(o,e),Kc(o,e)},Xc={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Zc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Xc[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Qc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},$c=(e,t,n,r)=>{n.type=`boolean`},el=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},tl=(e,t,n,r)=>{n.not={}},nl=(e,t,n,r)=>{let i=e._zod.def,a=vi(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},rl=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},il=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},al=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ol=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Wc(a.element,t,{...r,path:[...r.path,`items`]})},sl=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Wc(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Wc(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},cl=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Wc(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ll=(e,t,n,r)=>{let i=e._zod.def,a=Wc(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Wc(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},ul=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Wc(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Wc(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},dl=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Wc(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Wc(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Wc(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},fl=(e,t,n,r)=>{let i=e._zod.def,a=Wc(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},pl=(e,t,n,r)=>{let i=e._zod.def;Wc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ml=(e,t,n,r)=>{let i=e._zod.def;Wc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},hl=(e,t,n,r)=>{let i=e._zod.def;Wc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},gl=(e,t,n,r)=>{let i=e._zod.def;Wc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},_l=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Wc(o,t,r);let s=t.seen.get(e);s.ref=o},vl=(e,t,n,r)=>{let i=e._zod.def;Wc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},yl=(e,t,n,r)=>{let i=e._zod.def;Wc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},bl=z(`ZodISODateTime`,(e,t)=>{jo.init(e,t),Kl.init(e,t)});function xl(e){return lc(bl,e)}var Sl=z(`ZodISODate`,(e,t)=>{Mo.init(e,t),Kl.init(e,t)});function Cl(e){return uc(Sl,e)}var wl=z(`ZodISOTime`,(e,t)=>{No.init(e,t),Kl.init(e,t)});function Tl(e){return dc(wl,e)}var El=z(`ZodISODuration`,(e,t)=>{Po.init(e,t),Kl.init(e,t)});function Dl(e){return fc(El,e)}var Ol=z(`ZodError`,(e,t)=>{ta.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>ia(e,t)},flatten:{value:t=>ra(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,yi,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,yi,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),kl=aa(Ol),Al=oa(Ol),jl=sa(Ol),Ml=la(Ol),Nl=da(Ol),Pl=fa(Ol),Fl=pa(Ol),Il=ma(Ol),Ll=ha(Ol),Rl=ga(Ol),zl=_a(Ol),Bl=va(Ol),Vl=new WeakMap;function Hl(e,t,n){let r=Object.getPrototypeOf(e),i=Vl.get(r);if(i||(i=new Set,Vl.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Ul=z(`ZodType`,(e,t)=>(_o.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Yc(e,`input`),output:Yc(e,`output`)}}),e.toJSONSchema=Jc(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>kl(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>jl(e,t,n),e.parseAsync=async(t,n)=>Al(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ml(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Nl(e,t,n),e.decode=(t,n)=>Pl(e,t,n),e.encodeAsync=async(t,n)=>Fl(e,t,n),e.decodeAsync=async(t,n)=>Il(e,t,n),e.safeEncode=(t,n)=>Ll(e,t,n),e.safeDecode=(t,n)=>Rl(e,t,n),e.safeEncodeAsync=async(t,n)=>zl(e,t,n),e.safeDecodeAsync=async(t,n)=>Bl(e,t,n),Hl(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Di(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Li(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ld(e,t))},superRefine(e,t){return this.check(ud(e,t))},overwrite(e){return this.check(Nc(e))},optional(){return Wu(this)},exactOptional(){return Ku(this)},nullable(){return Ju(this)},nullish(){return Wu(Ju(this))},nonoptional(e){return ed(this,e)},array(){return wu(this)},or(e){return Du([this,e])},and(e){return ju(this,e)},transform(e){return id(this,Hu(e))},default(e){return Xu(this,e)},prefault(e){return Qu(this,e)},catch(e){return nd(this,e)},pipe(e){return id(this,e)},readonly(){return sd(this)},describe(e){let t=this.clone();return zs.add(t,{description:e}),t},meta(...e){if(e.length===0)return zs.get(this);let t=this.clone();return zs.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return zs.get(e)?.description},configurable:!0}),e)),Wl=z(`_ZodString`,(e,t)=>{vo.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zc(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Hl(e,`_ZodString`,{regex(...e){return this.check(Dc(...e))},includes(...e){return this.check(Ac(...e))},startsWith(...e){return this.check(jc(...e))},endsWith(...e){return this.check(Mc(...e))},min(...e){return this.check(Tc(...e))},max(...e){return this.check(wc(...e))},length(...e){return this.check(Ec(...e))},nonempty(...e){return this.check(Tc(1,...e))},lowercase(e){return this.check(Oc(e))},uppercase(e){return this.check(kc(e))},trim(){return this.check(Fc())},normalize(...e){return this.check(Pc(...e))},toLowerCase(){return this.check(Ic())},toUpperCase(){return this.check(Lc())},slugify(){return this.check(Rc())}})}),Gl=z(`ZodString`,(e,t)=>{vo.init(e,t),Wl.init(e,t),e.email=t=>e.check(Vs(ql,t)),e.url=t=>e.check(qs(Xl,t)),e.jwt=t=>e.check(cc(du,t)),e.emoji=t=>e.check(Js(Zl,t)),e.guid=t=>e.check(Hs(Jl,t)),e.uuid=t=>e.check(Us(Yl,t)),e.uuidv4=t=>e.check(Ws(Yl,t)),e.uuidv6=t=>e.check(Gs(Yl,t)),e.uuidv7=t=>e.check(Ks(Yl,t)),e.nanoid=t=>e.check(Ys(Ql,t)),e.guid=t=>e.check(Hs(Jl,t)),e.cuid=t=>e.check(Xs($l,t)),e.cuid2=t=>e.check(Zs(eu,t)),e.ulid=t=>e.check(Qs(tu,t)),e.base64=t=>e.check(ac(cu,t)),e.base64url=t=>e.check(oc(lu,t)),e.xid=t=>e.check($s(nu,t)),e.ksuid=t=>e.check(ec(ru,t)),e.ipv4=t=>e.check(tc(iu,t)),e.ipv6=t=>e.check(nc(au,t)),e.cidrv4=t=>e.check(rc(ou,t)),e.cidrv6=t=>e.check(ic(su,t)),e.e164=t=>e.check(sc(uu,t)),e.datetime=t=>e.check(xl(t)),e.date=t=>e.check(Cl(t)),e.time=t=>e.check(Tl(t)),e.duration=t=>e.check(Dl(t))});function V(e){return Bs(Gl,e)}var Kl=z(`ZodStringFormat`,(e,t)=>{yo.init(e,t),Wl.init(e,t)}),ql=z(`ZodEmail`,(e,t)=>{So.init(e,t),Kl.init(e,t)}),Jl=z(`ZodGUID`,(e,t)=>{bo.init(e,t),Kl.init(e,t)}),Yl=z(`ZodUUID`,(e,t)=>{xo.init(e,t),Kl.init(e,t)}),Xl=z(`ZodURL`,(e,t)=>{Co.init(e,t),Kl.init(e,t)}),Zl=z(`ZodEmoji`,(e,t)=>{wo.init(e,t),Kl.init(e,t)}),Ql=z(`ZodNanoID`,(e,t)=>{To.init(e,t),Kl.init(e,t)}),$l=z(`ZodCUID`,(e,t)=>{Eo.init(e,t),Kl.init(e,t)}),eu=z(`ZodCUID2`,(e,t)=>{Do.init(e,t),Kl.init(e,t)}),tu=z(`ZodULID`,(e,t)=>{Oo.init(e,t),Kl.init(e,t)}),nu=z(`ZodXID`,(e,t)=>{ko.init(e,t),Kl.init(e,t)}),ru=z(`ZodKSUID`,(e,t)=>{Ao.init(e,t),Kl.init(e,t)}),iu=z(`ZodIPv4`,(e,t)=>{Fo.init(e,t),Kl.init(e,t)}),au=z(`ZodIPv6`,(e,t)=>{Io.init(e,t),Kl.init(e,t)}),ou=z(`ZodCIDRv4`,(e,t)=>{Lo.init(e,t),Kl.init(e,t)}),su=z(`ZodCIDRv6`,(e,t)=>{Ro.init(e,t),Kl.init(e,t)}),cu=z(`ZodBase64`,(e,t)=>{Bo.init(e,t),Kl.init(e,t)}),lu=z(`ZodBase64URL`,(e,t)=>{Ho.init(e,t),Kl.init(e,t)}),uu=z(`ZodE164`,(e,t)=>{Uo.init(e,t),Kl.init(e,t)}),du=z(`ZodJWT`,(e,t)=>{Go.init(e,t),Kl.init(e,t)}),fu=z(`ZodNumber`,(e,t)=>{Ko.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qc(e,t,n,r),Hl(e,`ZodNumber`,{gt(e,t){return this.check(xc(e,t))},gte(e,t){return this.check(Sc(e,t))},min(e,t){return this.check(Sc(e,t))},lt(e,t){return this.check(yc(e,t))},lte(e,t){return this.check(bc(e,t))},max(e,t){return this.check(bc(e,t))},int(e){return this.check(mu(e))},safe(e){return this.check(mu(e))},positive(e){return this.check(xc(0,e))},nonnegative(e){return this.check(Sc(0,e))},negative(e){return this.check(yc(0,e))},nonpositive(e){return this.check(bc(0,e))},multipleOf(e,t){return this.check(Cc(e,t))},step(e,t){return this.check(Cc(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function H(e){return pc(fu,e)}var pu=z(`ZodNumberFormat`,(e,t)=>{qo.init(e,t),fu.init(e,t)});function mu(e){return mc(pu,e)}var hu=z(`ZodBoolean`,(e,t)=>{Jo.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$c(e,t,n,r)});function gu(e){return hc(hu,e)}var _u=z(`ZodNull`,(e,t)=>{Yo.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>el(e,t,n,r)});function vu(e){return gc(_u,e)}var yu=z(`ZodUnknown`,(e,t)=>{Xo.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function bu(){return _c(yu)}var xu=z(`ZodNever`,(e,t)=>{Zo.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tl(e,t,n,r)});function Su(e){return vc(xu,e)}var Cu=z(`ZodArray`,(e,t)=>{$o.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ol(e,t,n,r),e.element=t.element,Hl(e,`ZodArray`,{min(e,t){return this.check(Tc(e,t))},nonempty(e){return this.check(Tc(1,e))},max(e,t){return this.check(wc(e,t))},length(e,t){return this.check(Ec(e,t))},unwrap(){return this.element}})});function wu(e,t){return zc(Cu,e,t)}var Tu=z(`ZodObject`,(e,t)=>{is.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sl(e,t,n,r),Ti(e,`shape`,()=>t.shape),Hl(e,`ZodObject`,{keyof(){return Ru(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:bu()})},loose(){return this.clone({...this._zod.def,catchall:bu()})},strict(){return this.clone({...this._zod.def,catchall:Su()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Hi(this,e)},safeExtend(e){return Ui(this,e)},merge(e){return Wi(this,e)},pick(e){return Bi(this,e)},omit(e){return Vi(this,e)},partial(...e){return Gi(Uu,this,e[0])},required(...e){return Ki($u,this,e[0])}})});function U(e,t){return new Tu({type:`object`,shape:e??{},...B(t)})}var Eu=z(`ZodUnion`,(e,t)=>{os.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cl(e,t,n,r),e.options=t.options});function Du(e,t){return new Eu({type:`union`,options:e,...B(t)})}var Ou=z(`ZodDiscriminatedUnion`,(e,t)=>{Eu.init(e,t),ss.init(e,t)});function ku(e,t,n){return new Ou({type:`union`,options:t,discriminator:e,...B(n)})}var Au=z(`ZodIntersection`,(e,t)=>{cs.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(e,t,n,r)});function ju(e,t){return new Au({type:`intersection`,left:e,right:t})}var Mu=z(`ZodTuple`,(e,t)=>{ds.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ul(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function Nu(e,t,n){let r=t instanceof _o;return new Mu({type:`tuple`,items:e,rest:r?t:null,...B(r?n:t)})}var Pu=z(`ZodRecord`,(e,t)=>{hs.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dl(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Fu(e,t,n){return!t||!t._zod?new Pu({type:`record`,keyType:V(),valueType:e,...B(t)}):new Pu({type:`record`,keyType:e,valueType:t,...B(n)})}function Iu(e,t,n){let r=Li(e);return r._zod.values=void 0,new Pu({type:`record`,keyType:r,valueType:t,...B(n)})}var Lu=z(`ZodEnum`,(e,t)=>{gs.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nl(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Lu({...t,checks:[],...B(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Lu({...t,checks:[],...B(r),entries:i})}});function Ru(e,t){return new Lu({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...B(t)})}var zu=z(`ZodLiteral`,(e,t)=>{_s.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rl(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Bu(e,t){return new zu({type:`literal`,values:Array.isArray(e)?e:[e],...B(t)})}var Vu=z(`ZodTransform`,(e,t)=>{vs.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>al(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new hi(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push($i(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push($i(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Hu(e){return new Vu({type:`transform`,transform:e})}var Uu=z(`ZodOptional`,(e,t)=>{bs.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wu(e){return new Uu({type:`optional`,innerType:e})}var Gu=z(`ZodExactOptional`,(e,t)=>{xs.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ku(e){return new Gu({type:`optional`,innerType:e})}var qu=z(`ZodNullable`,(e,t)=>{Ss.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ju(e){return new qu({type:`nullable`,innerType:e})}var Yu=z(`ZodDefault`,(e,t)=>{Cs.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ml(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Xu(e,t){return new Yu({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Pi(t)}})}var Zu=z(`ZodPrefault`,(e,t)=>{Ts.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qu(e,t){return new Zu({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Pi(t)}})}var $u=z(`ZodNonOptional`,(e,t)=>{Es.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ed(e,t){return new $u({type:`nonoptional`,innerType:e,...B(t)})}var td=z(`ZodCatch`,(e,t)=>{Os.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function nd(e,t){return new td({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var rd=z(`ZodPipe`,(e,t)=>{ks.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_l(e,t,n,r),e.in=t.in,e.out=t.out});function id(e,t){return new rd({type:`pipe`,in:e,out:t})}var ad=z(`ZodPreprocess`,(e,t)=>{rd.init(e,t),js.init(e,t)}),od=z(`ZodReadonly`,(e,t)=>{Ms.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sd(e){return new od({type:`readonly`,innerType:e})}var cd=z(`ZodCustom`,(e,t)=>{Ps.init(e,t),Ul.init(e,t),e._zod.processJSONSchema=(t,n,r)=>il(e,t,n,r)});function ld(e,t={}){return Bc(cd,e,t)}function ud(e,t){return Vc(e,t)}function dd(e,t){return new ad({type:`pipe`,in:Hu(e),out:t})}var fd=[`chat`,`implement`,`review`,`prepare`,`project`,`smoke`],pd=Ru(fd),md=[`claude-code`,`codex`],hd=Ru(md),gd=`claude-code`,_d=U({id:V().min(1),runtime:hd,note:V().optional()}),vd={"claude-code":{flagship:`claude-opus-5`,smoke:`claude-haiku-4-5`},codex:{flagship:`gpt-5.6-sol`,smoke:`gpt-5.6-luna`}},yd=[{id:`claude-opus-5`,runtime:`claude-code`},{id:`claude-opus-5[1m]`,runtime:`claude-code`},{id:`claude-sonnet-5`,runtime:`claude-code`},{id:`claude-sonnet-5[1m]`,runtime:`claude-code`},{id:`claude-fable-5`,runtime:`claude-code`},{id:`claude-fable-5[1m]`,runtime:`claude-code`},{id:`claude-opus-4-8`,runtime:`claude-code`},{id:`claude-haiku-4-5`,runtime:`claude-code`},{id:`gpt-5.6-sol`,runtime:`codex`},{id:`gpt-5.6-terra`,runtime:`codex`},{id:`gpt-5.6-luna`,runtime:`codex`}],bd=vd[gd].smoke,xd=[`waypoint`,`converge`,`research`];dd(e=>{if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={...e},n=typeof t.stepModels==`object`&&t.stepModels!==null&&!Array.isArray(t.stepModels)?{...t.stepModels}:void 0;if(n){for(let e of xd)delete n[e];t.stepModels=n}let r=t.smokeModel;return typeof r==`string`&&r.length>0&&n?.smoke===void 0&&(t.stepModels={...n,smoke:r}),delete t.smokeModel,t},U({serverPort:H().default(4512),model:V().default(vd[gd].flagship),stepModels:Iu(pd,V()).default({smoke:bd}),models:wu(_d).default([]),sandbox:Ru([`docker`,`podman`,`noSandbox`]).default(`docker`),sessionMcp:Ru([`inherit`,`runcastleOnly`]).default(`inherit`),sandboxImage:V().optional(),burnConcurrency:H().int().min(1).max(8).default(3),burnCpus:H().positive().max(256).optional(),burnGuard:gu().default(!0),burnMaxIterations:H().int().min(1).max(10).default(3),burnAttempts:H().int().min(1).max(5).default(3),burnConflictAttempts:H().int().min(0).max(3).default(2),setupCommand:V().optional(),verifyCommands:V().optional(),knownFailures:V().optional(),burnWorkspace:Ru([`auto`,`mounted`,`isolated`]).default(`auto`),burnCache:Ru([`volume`,`off`]).default(`volume`)}));function Sd(e,t){let n=new Map(t.map(e=>[e.id,e])),r=e.map(e=>n.get(e.id)??e),i=new Set(e.map(e=>e.id));return[...r,...t.filter(e=>!i.has(e.id))]}function Cd(e){return Sd(Sd(yd,e.discovered??[]),e.models??[])}function wd(e){return md.flatMap(t=>e.sources[t].models.map(({id:e})=>({id:e,runtime:t})))}function Td(e,t){return Cd(t).find(t=>t.id===e)??{id:e,runtime:`claude-code`}}var Ed=Ru([`passed`,`failed`,`couldnt_run`]),Dd=U({command:V(),outcome:Ed,exitCode:H().nullable(),reason:V().optional(),log:V()}),Od=ku(`status`,[U({status:Bu(`none_configured`)}),U({status:Bu(`couldnt_run`),commit:V(),reason:V(),log:V().nullable()}),U({status:Bu(`ran`),commit:V(),commands:wu(Dd),reusedFrom:U({kind:Ru([`round`,`review`]),id:V()}).optional()})]),kd=Ru([`pending`,`burning`,`done`,`failed`,`cancelled`]),Ad=Ru([`chat`,`prepare`,`project`,`drive-fix`,`scenario`,`side`]),jd=Ru([`resolve-conflict`,`start-lap`,`self-plan`,`relay`,`lead-wake`,`scenario-setup`]),Md=U({mergeFrom:V(),mergeInto:V()}),Nd=Ru([`running`,`succeeded`,`failed`,`cancelled`]),Pd=Ru([`draft`,`active`,`shipped`,`archived`]),Fd=Ru([`launching`,`live`,`ended`]),Id=Ru([`implementation`,`review`]),Ld=Ru([`defect`,`observation`]),Rd=Ru([`high`,`medium`,`low`]),zd=Ru([`open`,`fixing`,`fixed`,`failed`,`dismissed`]),Bd=Ru([`over-cap`,`fix-failed`,`verification`]),Vd=Ru([`fix-ticket`,`session`]);U({kind:Ld,severity:Rd,title:V().min(1),location:V().min(1),citation:V().min(1),detail:V().min(1),reproStep:V().optional()}).superRefine((e,t)=>{e.kind===`defect`&&!e.reproStep?.trim()&&t.addIssue({code:`custom`,path:[`reproStep`],message:`defects require a repro step`})}).safeExtend({id:V(),featureId:V(),reviewTicketId:V(),reproStep:V(),status:zd,openReason:Bd.nullable(),failureReason:V().nullable(),fixTicketId:V().nullable(),resolvedBy:Vd.nullable(),resolutionNote:V().nullable(),createdAt:H()}),U({title:V(),goal:V(),context:V(),acceptanceCriteria:wu(V()),seams:wu(V()),blockedBy:wu(H()),kind:Id.default(`implementation`),passKind:Ru([`review`,`verification`]).default(`review`),model:V().optional(),originFindingId:V().optional()}).extend({id:V(),featureId:V(),seq:H(),status:kd,commits:wu(V()),reviewedCommit:V().nullable().default(null),reviewMode:Ru([`drive`,`gates`]).nullable().optional(),reviewVerdict:Ru([`verified`,`unverified`]).nullable().optional(),reviewVerdictReason:V().nullable().optional(),reviewGateRun:Od.nullable().optional(),completedAt:H().nullable().default(null),error:V().optional(),attemptBranch:V().optional(),conflictFiles:wu(V()).optional(),digest:V().optional()});var Hd=Ru([`open`,`done`,`promoted`,`carried`]),Ud=Ru([`human`,`agent`]);U({id:V(),featureId:V(),text:V(),status:Hd,author:Ud.default(`human`),ticketId:V().optional(),reviewTicketId:V().optional(),videoTimestamp:H().optional(),screenshotUrl:V().optional(),sentAt:H().optional(),createdAt:H(),updatedAt:H()});var Wd=Ru([`open`,`triaged`]);U({id:V(),projectId:V(),text:V(),status:Wd,outcome:V().optional(),featureId:V().optional(),screenshotUrl:V().optional(),driveBranch:V().optional(),driveCommit:V().optional(),createdAt:H(),updatedAt:H()});var Gd=[`setupCommand`,`verifyCommands`,`knownFailures`,`devCommand`,`driveSetupCommand`,`driveStopCommand`,`dbResetCommand`,`driveInstructions`];Ru(Gd);var Kd=Ru([...Gd,`sandboxImage`]),qd=[`devCommand`,`driveSetupCommand`,`driveStopCommand`],Jd=Ru([`prep`,`human`,`session`,`build`]),Yd=`runcastle:`;V().min(1,`a project needs a name`).max(80,`a project name can be at most 80 characters`),U({id:V(),name:V(),repoPath:V(),sessionBranch:V().optional(),devCommand:V().optional(),model:V().optional(),sandboxImage:V().optional(),setupCommand:V().optional(),verifyCommands:V().optional(),knownFailures:V().optional(),dbResetCommand:V().optional(),driveSetupCommand:V().optional(),driveStopCommand:V().optional(),driveInstructions:V().optional(),scenarioRunner:V().optional(),docsCommitPrefix:V().optional(),closedAt:H().optional()}),U({key:Kd,source:Jd,evidence:V().optional(),establishedAt:H(),establishedSha:V().optional(),staleCommits:H().optional(),verifiedAt:H().optional(),verifiedSha:V().optional()}),U({id:V(),projectId:V(),slug:V(),title:V(),oneLiner:V(),brief:V().optional(),branch:V(),baseBranch:V().optional(),status:Pd,createdAt:H(),upNext:gu().default(!1),heldBy:V().optional(),stoppedAt:H().nullable().default(null),waitingReason:V().nullable().default(null),lastHumanMessageAt:H().nullable().default(null),lastDispatchAt:H().nullable().default(null)}),U({id:V(),featureId:V(),runId:V().nullable(),scenario:V(),createdAt:H()});var Xd=U({ok:gu(),failed:wu(V())});U({round:H(),runId:V(),status:Nd,ticketSeqs:wu(H()),landed:wu(H()),failed:wu(H()),gates:Xd.nullable(),startedAt:H(),finishedAt:H().nullable()}),U({id:V(),featureId:V().optional(),projectId:V().optional(),kind:Ad,purpose:jd.optional(),purposeData:Md.optional(),ccSessionId:V().optional(),transcriptPath:V().optional(),status:Fd,awaitingInput:gu(),headless:gu().optional(),worktreePath:V(),model:V().optional(),runtime:hd.optional(),title:V().nullable().optional(),transcriptMissing:gu().optional(),createdAt:H().optional(),endedAt:H().optional(),openedBeside:V().optional()}),U({id:V(),featureId:V(),workflow:V(),status:Nd,startedAt:H(),endedAt:H().optional(),summary:V().optional(),digest:V().optional(),gates:Od.optional()});var Zd=Ru([`env`,`project`,`file`,`default`]),Qd=Ru([`global`,`project`]),$d=U({key:V(),value:bu(),source:Zd,editable:gu(),restartRequired:gu(),scope:Qd}),ef=U({id:V().min(1),runtime:hd,displayName:V().optional(),description:V().optional(),retirement:U({at:V(),replacement:V()}).optional()}),tf=U({sources:Fu(hd,U({status:Ru([`never`,`ok`,`failed`]),lastSuccessAt:H().optional(),lastAttemptAt:H().optional(),error:V().optional(),models:wu(ef),newIds:wu(V()),knownIds:wu(V()).default([])}))}),nf=()=>({status:`never`,models:[],newIds:[],knownIds:[]}),rf={sources:{"claude-code":nf(),codex:nf()}};U({projectId:V().optional(),fields:wu($d),discovery:tf}),U({projectId:V().optional(),key:V(),value:Du([V(),H(),gu(),wu(_d),vu()])}),U({id:H(),projectId:V(),featureId:V().optional(),runId:V().optional(),ticketId:V().optional(),ts:H(),type:V(),message:V(),data:bu().optional()});var af=U({sessionId:V().optional(),exitCode:H().nullable(),tail:V(),messages:H()});Ru([`idle`,`starting`,`serving`,`bare-checkout`,`setup-failed`,`review-agent-driving`]),U({file:V(),group:V().optional(),name:V(),own:gu(),hasCall:gu()});var of=U({method:V().min(1),url:V(),headers:wu(Nu([V(),V()])),body:V().optional()}),sf=U({reason:Ru([`exit`,`no-entry-url`,`timeout`,`no-runner`]),exitCode:H().nullable().optional(),outputTail:V()});U({file:V(),name:V(),status:Ru([`running`,`landed`,`failed`]),output:V().optional(),entryUrl:V().optional(),landingId:V().optional(),failure:sf.optional(),token:V().optional(),run:V().optional(),call:of.optional(),callError:V().optional()});function cf(e){let t=null;for(let n of e)if(n.type===`merge.conflict`){let e=n.data??{};t={base:typeof e.base==`string`?e.base:``,files:Array.isArray(e.files)?e.files.filter(e=>typeof e==`string`):[],at:n.ts}}else[`burn.started`,`merge.resolved`,`feature.shipped`].includes(n.type)&&(t=null);return t}var lf=`/api/reviews`,uf=`/:featureId`,df=`/ticket/:ticketId/package.json`;function ff(e){return`${lf}${df.replace(`:ticketId`,encodeURIComponent(e))}`}function pf(e){return`${lf}${uf.replace(`:featureId`,encodeURIComponent(e))}`}var mf=`/note/:noteId/screenshot`;`${mf}`;function hf(e,t){return`${lf}${e.replace(`:noteId`,encodeURIComponent(t))}`}function gf(e){return hf(mf,e)}var _f=`/project-note/:noteId/screenshot`;`${_f}`;function vf(e){return hf(_f,e)}function yf(e){if(!Number.isFinite(e)||e<0)return`--:--`;let t=Math.floor(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=n>0?String(r).padStart(2,`0`):String(r);return`${n>0?`${n}:`:``}${a}:${String(i).padStart(2,`0`)}`}function bf(e,t){if(e.status!==`draft`)return null;let n=t.filter(e=>!e.satisfied);return e.upNext?n.length>0&&n.every(e=>e.status!==`archived`)?`upNext`:`stuck`:n.length>0?`blocked`:t.length>0?`readyToStart`:`backlog`}function xf(e){let t=e.find(e=>!e.satisfied&&e.status===`archived`);return t?`${t.slug} was archived — remove it or move this to the backlog`:`nothing left to wait on — start it or move it to the backlog`}function Sf(e){return e.filter(e=>!e.satisfied&&e.status===`draft`&&!e.upNext)}function Cf(e){return e.status===`shipped`}var W=Symbol.for(`drizzle:entityKind`);function wf(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,W))throw Error(`Class "${t.name??`<unknown>`}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(e).constructor;if(n)for(;n;){if(W in n&&n[W]===t[W])return!0;n=Object.getPrototypeOf(n)}return!1}var Tf=class{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[W]=`Column`;name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!==`byDefault`}},Ef=class{static[W]=`ColumnBuilder`;config;constructor(e,t,n){this.config={name:e,keyAsName:e===``,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){this.config.name===``&&(this.config.name=e)}},Df=Symbol.for(`drizzle:Name`),Of=Symbol.for(`drizzle:isPgEnum`);function kf(e){return!!e&&typeof e==`function`&&Of in e&&e[Of]===!0}var Af=class{static[W]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},jf={startActiveSpan(e,t){return t()}},Mf=Symbol.for(`drizzle:ViewBaseConfig`),Nf=Symbol.for(`drizzle:Schema`),Pf=Symbol.for(`drizzle:Columns`),Ff=Symbol.for(`drizzle:ExtraConfigColumns`),If=Symbol.for(`drizzle:OriginalName`),Lf=Symbol.for(`drizzle:BaseName`),Rf=Symbol.for(`drizzle:IsAlias`),zf=Symbol.for(`drizzle:ExtraConfigBuilder`),Bf=Symbol.for(`drizzle:IsDrizzleTable`),Vf=class{static[W]=`Table`;static Symbol={Name:Df,Schema:Nf,OriginalName:If,Columns:Pf,ExtraConfigColumns:Ff,BaseName:Lf,IsAlias:Rf,ExtraConfigBuilder:zf};[Df];[If];[Nf];[Pf];[Ff];[Lf];[Rf]=!1;[Bf]=!0;[zf]=void 0;constructor(e,t,n){this[Df]=this[If]=e,this[Nf]=t,this[Lf]=n}};function Hf(e){return e!=null&&typeof e.getSQL==`function`}function Uf(e){let t={sql:``,params:[]};for(let n of e)t.sql+=n.sql,t.params.push(...n.params),n.typings?.length&&(t.typings||=[],t.typings.push(...n.typings));return t}var Wf=class{static[W]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new Gf([this])}},Gf=class e{constructor(e){this.queryChunks=e;for(let t of e)if(wf(t,Vf)){let e=t[Vf.Symbol.Schema];this.usedTables.push(e===void 0?t[Vf.Symbol.Name]:e+`.`+t[Vf.Symbol.Name])}}static[W]=`SQL`;decoder=qf;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return jf.startActiveSpan(`drizzle.buildSQL`,t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(t,n){let r=Object.assign({},n,{inlineParams:n.inlineParams||this.shouldInlineParams,paramStartIndex:n.paramStartIndex||{value:0}}),{casing:i,escapeName:a,escapeParam:o,prepareTyping:s,inlineParams:c,paramStartIndex:l}=r;return Uf(t.map(t=>{if(wf(t,Wf))return{sql:t.value.join(``),params:[]};if(wf(t,Kf))return{sql:a(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new Wf(`(`)];for(let[n,r]of t.entries())e.push(r),n<t.length-1&&e.push(new Wf(`, `));return e.push(new Wf(`)`)),this.buildQueryFromSourceParams(e,r)}if(wf(t,e))return this.buildQueryFromSourceParams(t.queryChunks,{...r,inlineParams:c||t.shouldInlineParams});if(wf(t,Vf)){let e=t[Vf.Symbol.Schema],n=t[Vf.Symbol.Name];return{sql:e===void 0||t[Rf]?a(n):a(e)+`.`+a(n),params:[]}}if(wf(t,Tf)){let e=i.getColumnCasing(t);if(n.invokeSource===`indexes`)return{sql:a(e),params:[]};let r=t.table[Vf.Symbol.Schema];return{sql:t.table[Rf]||r===void 0?a(t.table[Vf.Symbol.Name])+`.`+a(e):a(r)+`.`+a(t.table[Vf.Symbol.Name])+`.`+a(e),params:[]}}if(wf(t,$f)){let e=t[Mf].schema,n=t[Mf].name;return{sql:e===void 0||t[Mf].isAlias?a(n):a(e)+`.`+a(n),params:[]}}if(wf(t,Yf)){if(wf(t.value,Zf))return{sql:o(l.value++,t),params:[t],typings:[`none`]};let n=t.value===null?null:t.encoder.mapToDriverValue(t.value);if(wf(n,e))return this.buildQueryFromSourceParams([n],r);if(c)return{sql:this.mapInlineParam(n,r),params:[]};let i=[`none`];return s&&(i=[s(t.encoder)]),{sql:o(l.value++,n),params:[n],typings:i}}return wf(t,Zf)?{sql:o(l.value++,t),params:[t],typings:[`none`]}:wf(t,e.Aliased)&&t.fieldAlias!==void 0?{sql:a(t.fieldAlias),params:[]}:wf(t,Af)?t._.isWith?{sql:a(t._.alias),params:[]}:this.buildQueryFromSourceParams([new Wf(`(`),t._.sql,new Wf(`) `),new Kf(t._.alias)],r):kf(t)?t.schema?{sql:a(t.schema)+`.`+a(t.enumName),params:[]}:{sql:a(t.enumName),params:[]}:Hf(t)?t.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([t.getSQL()],r):this.buildQueryFromSourceParams([new Wf(`(`),t.getSQL(),new Wf(`)`)],r):c?{sql:this.mapInlineParam(t,r),params:[]}:{sql:o(l.value++,t),params:[t],typings:[`none`]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return`null`;if(typeof e==`number`||typeof e==`boolean`)return e.toString();if(typeof e==`string`)return t(e);if(typeof e==`object`){let n=e.toString();return t(n===`[object Object]`?JSON.stringify(e):n)}throw Error(`Unexpected param value: `+e)}getSQL(){return this}as(t){return t===void 0?this:new e.Aliased(this,t)}mapWith(e){return this.decoder=typeof e==`function`?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}},Kf=class{constructor(e){this.value=e}static[W]=`Name`;brand;getSQL(){return new Gf([this])}},qf={mapFromDriverValue:e=>e},Jf={mapToDriverValue:e=>e};({...qf,...Jf});var Yf=class{constructor(e,t=Jf){this.value=e,this.encoder=t}static[W]=`Param`;brand;getSQL(){return new Gf([this])}};function Xf(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new Wf(e[0]));for(let[r,i]of t.entries())n.push(i,new Wf(e[r+1]));return new Gf(n)}(e=>{function t(){return new Gf([])}e.empty=t;function n(e){return new Gf(e)}e.fromList=n;function r(e){return new Gf([new Wf(e)])}e.raw=r;function i(e,t){let n=[];for(let[r,i]of e.entries())r>0&&t!==void 0&&n.push(t),n.push(i);return new Gf(n)}e.join=i;function a(e){return new Kf(e)}e.identifier=a;function o(e){return new Zf(e)}e.placeholder=o;function s(e,t){return new Yf(e,t)}e.param=s})(Xf||={}),(e=>{class t{constructor(e,t){this.sql=e,this.fieldAlias=t}static[W]=`SQL.Aliased`;isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(Gf||={});var Zf=class{constructor(e){this.name=e}static[W]=`Placeholder`;getSQL(){return new Gf([this])}},Qf=Symbol.for(`drizzle:IsDrizzleView`),$f=class{static[W]=`View`;[Mf];[Qf]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[Mf]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new Gf([this])}};Tf.prototype.getSQL=function(){return new Gf([this])},Vf.prototype.getSQL=function(){return new Gf([this])},Af.prototype.getSQL=function(){return new Gf([this])};function ep(e,t){return{name:typeof e==`string`&&e.length>0?e:``,config:typeof e==`object`?e:t}}var tp=typeof TextDecoder>`u`?null:new TextDecoder,np=class{static[W]=`SQLiteForeignKeyBuilder`;reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:t,columns:n,foreignColumns:r}=e();return{name:t,columns:n,foreignTable:r[0].table,foreignColumns:r}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new rp(e,this)}},rp=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[W]=`SQLiteForeignKey`;reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map(e=>e.name),i=n.map(e=>e.name),a=[this.table[Df],...r,n[0].table[Df],...i];return e??`${a.join(`_`)}_fk`}};function ip(e,t){return`${e[Df]}_${t.join(`_`)}_unique`}var ap=class extends Ef{static[W]=`SQLiteColumnBuilder`;foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:`always`,mode:t?.mode??`virtual`},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>((n,r)=>{let i=new np(()=>{let t=n();return{columns:[e],foreignColumns:[t]}});return r.onUpdate&&i.onUpdate(r.onUpdate),r.onDelete&&i.onDelete(r.onDelete),i.build(t)})(n,r))}},op=class extends Tf{constructor(e,t){t.uniqueName||=ip(e,[t.name]),super(e,t),this.table=e}static[W]=`SQLiteColumn`},sp=class extends ap{static[W]=`SQLiteBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteBigInt`)}build(e){return new cp(e,this.config)}},cp=class extends op{static[W]=`SQLiteBigInt`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString(`utf8`))}return BigInt(tp.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}},lp=class extends ap{static[W]=`SQLiteBlobJsonBuilder`;constructor(e){super(e,`json`,`SQLiteBlobJson`)}build(e){return new up(e,this.config)}},up=class extends op{static[W]=`SQLiteBlobJson`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString(`utf8`))}return JSON.parse(tp.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}},dp=class extends ap{static[W]=`SQLiteBlobBufferBuilder`;constructor(e){super(e,`buffer`,`SQLiteBlobBuffer`)}build(e){return new fp(e,this.config)}},fp=class extends op{static[W]=`SQLiteBlobBuffer`;mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return`blob`}};function pp(e,t){let{name:n,config:r}=ep(e,t);return r?.mode===`json`?new lp(n):r?.mode===`bigint`?new sp(n):new dp(n)}var mp=class extends ap{static[W]=`SQLiteCustomColumnBuilder`;constructor(e,t,n){super(e,`custom`,`SQLiteCustomColumn`),this.config.fieldConfig=t,this.config.customTypeParams=n}build(e){return new hp(e,this.config)}},hp=class extends op{static[W]=`SQLiteCustomColumn`;sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom==`function`?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo==`function`?this.mapTo(e):e}};function gp(e){return(t,n)=>{let{name:r,config:i}=ep(t,n);return new mp(r,i,e)}}var _p=class extends ap{static[W]=`SQLiteBaseIntegerBuilder`;constructor(e,t,n){super(e,t,n),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}},vp=class extends op{static[W]=`SQLiteBaseInteger`;autoIncrement=this.config.autoIncrement;getSQLType(){return`integer`}},yp=class extends _p{static[W]=`SQLiteIntegerBuilder`;constructor(e){super(e,`number`,`SQLiteInteger`)}build(e){return new bp(e,this.config)}},bp=class extends vp{static[W]=`SQLiteInteger`},xp=class extends _p{static[W]=`SQLiteTimestampBuilder`;constructor(e,t){super(e,`date`,`SQLiteTimestamp`),this.config.mode=t}defaultNow(){return this.default(Xf`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new Sp(e,this.config)}},Sp=class extends vp{static[W]=`SQLiteTimestamp`;mode=this.config.mode;mapFromDriverValue(e){return this.config.mode===`timestamp`?new Date(e*1e3):new Date(e)}mapToDriverValue(e){let t=e.getTime();return this.config.mode===`timestamp`?Math.floor(t/1e3):t}},Cp=class extends _p{static[W]=`SQLiteBooleanBuilder`;constructor(e,t){super(e,`boolean`,`SQLiteBoolean`),this.config.mode=t}build(e){return new wp(e,this.config)}},wp=class extends vp{static[W]=`SQLiteBoolean`;mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return+!!e}};function Tp(e,t){let{name:n,config:r}=ep(e,t);return r?.mode===`timestamp`||r?.mode===`timestamp_ms`?new xp(n,r.mode):r?.mode===`boolean`?new Cp(n,r.mode):new yp(n)}var Ep=class extends ap{static[W]=`SQLiteNumericBuilder`;constructor(e){super(e,`string`,`SQLiteNumeric`)}build(e){return new Dp(e,this.config)}},Dp=class extends op{static[W]=`SQLiteNumeric`;mapFromDriverValue(e){return typeof e==`string`?e:String(e)}getSQLType(){return`numeric`}},Op=class extends ap{static[W]=`SQLiteNumericNumberBuilder`;constructor(e){super(e,`number`,`SQLiteNumericNumber`)}build(e){return new kp(e,this.config)}},kp=class extends op{static[W]=`SQLiteNumericNumber`;mapFromDriverValue(e){return typeof e==`number`?e:Number(e)}mapToDriverValue=String;getSQLType(){return`numeric`}},Ap=class extends ap{static[W]=`SQLiteNumericBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteNumericBigInt`)}build(e){return new jp(e,this.config)}},jp=class extends op{static[W]=`SQLiteNumericBigInt`;mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return`numeric`}};function Mp(e,t){let{name:n,config:r}=ep(e,t),i=r?.mode;return i===`number`?new Op(n):i===`bigint`?new Ap(n):new Ep(n)}var Np=class extends ap{static[W]=`SQLiteRealBuilder`;constructor(e){super(e,`number`,`SQLiteReal`)}build(e){return new Pp(e,this.config)}},Pp=class extends op{static[W]=`SQLiteReal`;getSQLType(){return`real`}};function Fp(e){return new Np(e??``)}var Ip=class extends ap{static[W]=`SQLiteTextBuilder`;constructor(e,t){super(e,`string`,`SQLiteText`),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new Lp(e,this.config)}},Lp=class extends op{static[W]=`SQLiteText`;enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:``}`}},Rp=class extends ap{static[W]=`SQLiteTextJsonBuilder`;constructor(e){super(e,`json`,`SQLiteTextJson`)}build(e){return new zp(e,this.config)}},zp=class extends op{static[W]=`SQLiteTextJson`;getSQLType(){return`text`}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}};function G(e,t={}){let{name:n,config:r}=ep(e,t);return r.mode===`json`?new Rp(n):new Ip(n,r)}function Bp(){return{blob:pp,customType:gp,integer:Tp,numeric:Mp,real:Fp,text:G}}var Vp=Symbol.for(`drizzle:SQLiteInlineForeignKeys`),Hp=class extends Vf{static[W]=`SQLiteTable`;static Symbol=Object.assign({},Vf.Symbol,{InlineForeignKeys:Vp});[Vf.Symbol.Columns];[Vp]=[];[Vf.Symbol.ExtraConfigBuilder]=void 0};function Up(e,t,n,r,i=e){let a=new Hp(e,r,i),o=typeof t==`function`?t(Bp()):t,s=Object.fromEntries(Object.entries(o).map(([e,t])=>{let n=t;n.setName(e);let r=n.build(a);return a[Vp].push(...n.buildForeignKeys(r,a)),[e,r]})),c=Object.assign(a,s);return c[Vf.Symbol.Columns]=s,c[Vf.Symbol.ExtraConfigColumns]=s,n&&(c[Hp.Symbol.ExtraConfigBuilder]=n),c}var Wp=(e,t,n)=>Up(e,t,n),Gp=class{constructor(e,t){this.name=e,this.unique=t}static[W]=`SQLiteIndexBuilderOn`;on(...e){return new Kp(this.name,e,this.unique)}},Kp=class{static[W]=`SQLiteIndexBuilder`;config;constructor(e,t,n){this.config={name:e,columns:t,unique:n,where:void 0}}where(e){return this.config.where=e,this}build(e){return new qp(this.config,e)}},qp=class{static[W]=`SQLiteIndex`;config;constructor(e,t){this.config={...e,table:t}}};function Jp(e){return new Gp(e,!1)}function Yp(...e){return e[0].columns?new Xp(e[0].columns,e[0].name):new Xp(e)}var Xp=class{static[W]=`SQLitePrimaryKeyBuilder`;columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new Zp(e,this.columns,this.name)}},Zp=class{constructor(e,t,n){this.table=e,this.columns=t,this.name=n}static[W]=`SQLitePrimaryKey`;columns;name;getName(){return this.name??`${this.table[Hp.Symbol.Name]}_${this.columns.map(e=>e.name).join(`_`)}_pk`}};Wp(`projects`,{id:G(`id`).primaryKey(),name:G(`name`).notNull(),repoPath:G(`repo_path`).notNull(),sessionBranch:G(`session_branch`),devCommand:G(`dev_command`),model:G(`model`),sandbox:G(`sandbox`),sandboxImage:G(`sandbox_image`),closedAt:Tp(`closed_at`),setupCommand:G(`setup_command`),verifyCommands:G(`verify_commands`),knownFailures:G(`known_failures`),dbResetCommand:G(`db_reset_command`),driveInstructions:G(`drive_instructions`),driveSetupCommand:G(`drive_setup_command`),driveStopCommand:G(`drive_stop_command`),scenarioRunner:G(`scenario_runner`),docsCommitPrefix:G(`docs_commit_prefix`)}),Wp(`project_findings`,{projectId:G(`project_id`).notNull(),key:G(`key`).notNull(),source:G(`source`).notNull().$type(),evidence:G(`evidence`),establishedAt:Tp(`established_at`).notNull(),establishedSha:G(`established_sha`),verifiedAt:Tp(`verified_at`),verifiedSha:G(`verified_sha`)},e=>[Yp({columns:[e.projectId,e.key]})]);var Qp=Wp(`features`,{id:G(`id`).primaryKey(),projectId:G(`project_id`).notNull(),slug:G(`slug`).notNull(),title:G(`title`).notNull(),oneLiner:G(`one_liner`).notNull(),brief:G(`brief`),branch:G(`branch`).notNull(),baseBranch:G(`base_branch`),status:G(`status`).notNull().$type(),createdAt:Tp(`created_at`).notNull(),upNext:Tp(`up_next`,{mode:`boolean`}).notNull().default(!1),heldBy:G(`held_by`),stoppedAt:Tp(`stopped_at`),waitingReason:G(`waiting_reason`),lastHumanMessageAt:Tp(`last_human_message_at`),lastDispatchAt:Tp(`last_dispatch_at`)});Wp(`ready_declarations`,{id:G(`id`).primaryKey(),featureId:G(`feature_id`).notNull(),runId:G(`run_id`),scenario:G(`scenario`).notNull(),createdAt:Tp(`created_at`).notNull()}),Wp(`feature_dependencies`,{dependentId:G(`dependent_id`).notNull().references(()=>Qp.id,{onDelete:`cascade`}),dependencyId:G(`dependency_id`).notNull().references(()=>Qp.id,{onDelete:`cascade`}),createdAt:Tp(`created_at`).notNull()},e=>[Yp({columns:[e.dependentId,e.dependencyId]})]),Wp(`sessions`,{id:G(`id`).primaryKey(),featureId:G(`feature_id`),projectId:G(`project_id`),kind:G(`kind`).notNull().$type(),purpose:G(`purpose`).$type(),purposeData:G(`purpose_data`,{mode:`json`}).$type(),ccSessionId:G(`cc_session_id`),transcriptPath:G(`transcript_path`),status:G(`status`).notNull().$type(),awaitingInput:Tp(`awaiting_input`,{mode:`boolean`}).notNull().default(!1),headless:Tp(`headless`,{mode:`boolean`}).notNull().default(!1),worktreePath:G(`worktree_path`).notNull(),model:G(`model`),runtime:G(`runtime`).$type(),title:G(`title`),createdAt:Tp(`created_at`),endedAt:Tp(`ended_at`),tokens:Tp(`tokens`),tokenBreakdown:G(`token_breakdown`,{mode:`json`}).$type(),openedBeside:G(`opened_beside`)}),Wp(`tickets`,{id:G(`id`).primaryKey(),featureId:G(`feature_id`).notNull(),seq:Tp(`seq`).notNull(),title:G(`title`).notNull(),goal:G(`goal`).notNull(),context:G(`context`).notNull(),acceptanceCriteria:G(`acceptance_criteria`,{mode:`json`}).notNull().$type(),seams:G(`seams`,{mode:`json`}).notNull().$type(),blockedBy:G(`blocked_by`,{mode:`json`}).notNull().$type(),kind:G(`kind`).notNull().$type().default(`implementation`),passKind:G(`pass_kind`).notNull().$type().default(`review`),reviewedCommit:G(`reviewed_commit`),reviewMode:G(`review_mode`).$type(),reviewVerdict:G(`review_verdict`).$type(),reviewVerdictReason:G(`review_verdict_reason`),reviewGateRun:G(`review_gate_run`,{mode:`json`}).$type(),completedAt:Tp(`completed_at`),model:G(`model`),status:G(`status`).notNull().$type(),commits:G(`commits`,{mode:`json`}).notNull().$type(),error:G(`error`),attemptBranch:G(`attempt_branch`),conflictFiles:G(`conflict_files`,{mode:`json`}).$type(),digest:G(`digest`),originFindingId:G(`origin_finding_id`),tokens:Tp(`tokens`),tokenBreakdown:G(`token_breakdown`,{mode:`json`}).$type()}),Wp(`review_findings`,{id:G(`id`).primaryKey(),featureId:G(`feature_id`).notNull(),reviewTicketId:G(`review_ticket_id`).notNull(),kind:G(`kind`).notNull().$type(),severity:G(`severity`).notNull().$type(),title:G(`title`).notNull(),location:G(`location`).notNull(),citation:G(`citation`).notNull(),detail:G(`detail`).notNull(),reproStep:G(`repro_step`).notNull(),status:G(`status`).notNull().$type(),openReason:G(`open_reason`).$type(),failureReason:G(`failure_reason`),fixTicketId:G(`fix_ticket_id`),resolvedBy:G(`resolved_by`).$type(),resolutionNote:G(`resolution_note`),createdAt:Tp(`created_at`).notNull()}),Wp(`test_notes`,{id:G(`id`).primaryKey(),featureId:G(`feature_id`).notNull(),text:G(`text`).notNull(),status:G(`status`).notNull().$type(),author:G(`author`).notNull().$type().default(`human`),ticketId:G(`ticket_id`),reviewTicketId:G(`review_ticket_id`),videoTimestamp:Fp(`video_timestamp`),sentAt:Tp(`sent_at`),createdAt:Tp(`created_at`).notNull(),updatedAt:Tp(`updated_at`).notNull()}),Wp(`project_notes`,{id:G(`id`).primaryKey(),projectId:G(`project_id`).notNull(),text:G(`text`).notNull(),status:G(`status`).notNull().$type(),outcome:G(`outcome`),featureId:G(`feature_id`),driveBranch:G(`drive_branch`),driveCommit:G(`drive_commit`),createdAt:Tp(`created_at`).notNull(),updatedAt:Tp(`updated_at`).notNull()}),Wp(`runs`,{id:G(`id`).primaryKey(),featureId:G(`feature_id`).notNull(),workflow:G(`workflow`).notNull(),status:G(`status`).notNull().$type(),startedAt:Tp(`started_at`).notNull(),endedAt:Tp(`ended_at`),summary:G(`summary`),digest:G(`digest`),gates:G(`gates`,{mode:`json`}).$type()}),Wp(`events`,{id:Tp(`id`).primaryKey({autoIncrement:!0}),projectId:G(`project_id`).notNull(),featureId:G(`feature_id`),runId:G(`run_id`),ticketId:G(`ticket_id`),ts:Tp(`ts`).notNull(),type:G(`type`).notNull(),message:G(`message`).notNull(),data:G(`data`,{mode:`json`})},e=>[Jp(`events_project_id_id_idx`).on(e.projectId,e.id),Jp(`events_feature_id_id_idx`).on(e.featureId,e.id)]),Wp(`push_subscriptions`,{endpoint:G(`endpoint`).primaryKey(),p256dh:G(`p256dh`).notNull(),auth:G(`auth`).notNull(),createdAt:Tp(`created_at`).notNull()}),Wp(`push_keys`,{id:Tp(`id`).primaryKey(),publicKey:G(`public_key`).notNull(),privateKey:G(`private_key`).notNull()});var $p=Ru([`read`,`edit`,`delete`,`move`,`search`,`execute`,`think`,`fetch`,`other`]),em=Ru([`pending`,`in_progress`,`completed`,`failed`]),tm=U({op:Ru([` `,`+`,`-`]),text:V()}),nm=U({id:V(),kind:$p,title:V(),status:em,output:V().optional(),diff:U({path:V(),lines:wu(tm)}).optional()}),rm=U({path:V(),added:H().int().nonnegative(),removed:H().int().nonnegative(),lines:wu(tm)}),im=U({id:V(),src:V(),name:V()}),eee=Ru([`image`,`markdown`,`html`,`text`,`browser`,`download`]),tee=U({id:V(),src:V(),name:V(),path:V(),size:H().int().nonnegative(),as:eee,caption:V().optional()}),nee=U({label:V(),description:V().optional()}),am=U({header:V(),question:V(),options:wu(nee),multiSelect:gu().optional()}),om={key:V(),title:V(),description:V().optional(),required:gu().optional()},sm=ku(`type`,[U({...om,type:Bu(`string`),format:Ru([`email`,`uri`,`date`]).optional(),default:V().optional()}),U({...om,type:Bu(`number`),integer:gu().optional(),default:H().optional()}),U({...om,type:Bu(`boolean`),default:gu().optional()}),U({...om,type:Bu(`enum`),options:wu(U({value:V(),label:V()})),default:V().optional()})]),cm=Fu(V(),Du([V(),H(),gu()])),lm=ku(`kind`,[U({kind:Bu(`approval`),id:V(),call:nm}),U({kind:Bu(`question`),id:V(),questions:wu(am)}),U({kind:Bu(`form`),id:V(),server:V().optional(),message:V(),fields:wu(sm)}),U({kind:Bu(`link`),id:V(),server:V().optional(),message:V(),url:V()})]);ku(`kind`,[U({kind:Bu(`approval`),choice:Ru([`allow`,`always`,`deny`]),instead:V().optional()}),U({kind:Bu(`question`),answers:Fu(V(),V())}),U({kind:Bu(`form`),values:cm}),U({kind:Bu(`link`),done:Bu(!0)}),U({kind:Bu(`decline`)})]);var um=U({name:V(),description:V()}),dm=U({content:V(),status:Ru([`pending`,`in_progress`,`completed`])}),fm=U({id:V(),title:V(),startedAt:H()}),pm=Ru([`low`,`medium`,`high`,`max`]),mm=U({used:H().nonnegative(),size:H().positive(),costUsd:H().nonnegative().optional()}),hm=/^\d+(?:\.\d+)*$/;function gm(e){let t=e.split(/\s+/).filter(Boolean),n=t.findIndex(e=>hm.test(e));if(n<0)return{family:t[0]??e,version:[]};let r=t[n].split(`.`).map(Number);return{family:n>0?t.slice(0,n).join(` `):`GPT-${r[0]}`,version:r}}var _m=Ru([`end_turn`,`max_tokens`,`max_turn_requests`,`refusal`,`cancelled`,`error`]),vm=`Interrupted — runcastle restarted`,ym=ku(`type`,[U({type:Bu(`prompt`),id:V(),text:V(),images:wu(im).optional(),source:Ru([`human`,`runcastle`]),steered:gu().optional(),hidden:gu().optional()}),U({type:Bu(`process`),state:Ru([`starting`,`running`,`stopped`]),error:V().optional(),restarted:Bu(!0).optional()}),U({type:Bu(`turn_started`),source:Bu(`agent`).optional()}),U({type:Bu(`turn_ended`),reason:_m,files:wu(rm).optional(),error:V().optional()}),U({type:Bu(`agent_text`),messageId:V(),text:V()}),U({type:Bu(`thought`),thoughtId:V(),text:V()}),U({type:Bu(`tool`),call:nm.partial().required({id:!0}),parentId:V().optional(),outputAppend:V().optional()}),U({type:Bu(`subagent`),id:V(),title:V().optional(),status:em.optional()}),U({type:Bu(`plan`),entries:wu(dm)}),U({type:Bu(`tasks`),tasks:wu(fm),agents:H().int().nonnegative().optional()}),U({type:Bu(`ask`),ask:lm}),U({type:Bu(`ask_resolved`),id:V(),lines:wu(U({what:V(),answer:V(),denied:gu().optional()}))}),U({type:Bu(`usage`),context:mm}),U({type:Bu(`model`),model:V(),label:V(),effort:pm.optional(),fast:gu().optional(),picked:gu().optional()}),U({type:Bu(`commands`),commands:wu(um)}),U({type:Bu(`compacted`)}),U({type:Bu(`title`),title:V(),renamed:gu().optional()}),U({type:Bu(`branched`),from:V()}),U({type:Bu(`suggestion`),text:V().nullable()}),U({type:Bu(`rewound`),toPromptId:V()}),U({type:Bu(`file_shown`),file:tee}),U({type:Bu(`review_package`),ticketId:V()}),U({type:Bu(`error`),message:V()}),U({type:Bu(`notice`),text:V()}),U({type:Bu(`briefed`)})]);ju(U({i:H().int().nonnegative(),at:H()}),ym);var bm={items:[],state:`idle`,plan:[],tasks:[],commands:[],process:`stopped`,cursor:-1};function xm(e){let t=new Set;return e.forEach((n,r)=>{if(n.type!==`rewound`)return;let i=e.findIndex((e,t)=>t<r&&e.type===`prompt`&&e.id===n.toPromptId);if(!(i<0))for(let e=i;e<r;e++)t.add(e)}),e.filter((e,n)=>!t.has(n)&&e.type!==`rewound`)}var Sm={kind:`other`,title:``,status:`pending`};function Cm(e){let t=xm(e),n=[],r={...bm,items:n,plan:[],tasks:[],commands:[]};r.cursor=e.length?e[e.length-1].i:-1;let i=null,a=new Set,o=new Set,s=-1,c=-1,l=-1,u,d=null,f=!1,p,m=0,h,g=!1,_=(e,t)=>{if(!i)return;let r=i.segments,a=r.length-1;for(;a>=0&&r[a].kind===`text`&&!r[a].text.trim();)a--;let o=a>=0&&r[a].kind===`text`?r[a]:null,u=(o?r.slice(0,a):r.slice(0,a+1)).map(e=>{switch(e.kind){case`text`:return e.text.trim()?{kind:`narration`,id:e.id,text:e.text}:null;case`thought`:return{kind:`thought`,id:e.id,text:e.text,seconds:Math.max(1,Math.round((e.to-e.from)/1e3))};case`tools`:case`subagent`:return e;case`answered`:return null}}).filter(e=>e!==null),d=Math.max(0,Math.round(((t??i.startedAt)-i.startedAt)/1e3)),f=u.length?{kind:`work`,id:`work:${i.id}`,steps:u,seconds:d,...e?{live:e}:{}}:null,p=o?{kind:`agent`,id:o.id,text:o.text,...i.model?{model:i.model}:{}}:null;f?s<0?(s=l>=0?l:c>=0?c:n.length,n.splice(s,0,f),c>=0&&c++,l>=0&&l++):n[s]=f:s>=0&&(n.splice(s,1),c>s&&c--,l>s&&l--,s=-1),p?c<0?(c=n.length,n.push(p)):n[c]=p:c>=0&&(n.splice(c,1),c=-1)},v=e=>(i||(i={id:String(e.i),startedAt:e.at,segments:[],subagents:new Map,calls:new Map,model:r.model?.label,started:e.type===`turn_started`},s=-1,c=-1,l=-1,r.turnStartedAt=e.at),i),y=(e,t,a,o)=>{if(i){for(let e of i.calls.values())(e.status===`in_progress`||e.status===`pending`)&&(e.status=t===`end_turn`?`completed`:`failed`);for(let e of i.subagents.values())(e.status===`in_progress`||e.status===`pending`)&&(e.status=t===`end_turn`?`completed`:`failed`);_(!1,e.at)}if(a?.length&&n.push({kind:`changes`,id:`changes:${e.i}`,files:a}),t===`cancelled`&&n.push({kind:`stopped`,id:`stopped:${e.i}`}),t===`restarted`&&n.push({kind:`notice`,id:`notice:${e.i}`,text:vm}),t===`error`||t===`refusal`||t===`max_tokens`||t===`max_turn_requests`){let r=o??(t===`refusal`?`The model declined to continue.`:t===`error`?`The turn failed.`:`The turn hit its limit and stopped.`);n.push({kind:`error`,id:`error:${e.i}`,message:r})}i=null,l=-1,u=void 0,r.turnStartedAt=void 0},b=e=>{i&&(_(!1,e.at),i.id=String(e.i),i.startedAt=e.at,i.segments=[],s=-1,c=-1,l=-1)},x=(e,t,n,r)=>{e.calls.set(n.id,n),o.add(n.id);let i=r?e.subagents.get(r):void 0;if(i)i.calls.push(n);else{let r=e.segments[e.segments.length-1];r?.kind===`tools`?r.calls.push(n):e.segments.push({kind:`tools`,id:`tools:${t.i}`,calls:[n]})}};for(let e of t)switch(e.type){case`prompt`:{if(f=!1,e.hidden){i&&b(e);break}let t={kind:`user`,id:e.id,text:e.text,...e.images?.length?{images:e.images}:{},...e.steered?{steered:!0}:{},...e.source===`runcastle`?{from:`runcastle`}:{}};r.process!==`running`&&!e.steered&&(d&&delete d.starting,t.starting=!0,d=t),i?b(e):(s=-1,c=-1),n.push(t),r.suggestion=void 0;break}case`process`:r.process=e.state,e.state!==`running`&&(g=!0),e.state!==`starting`&&d&&(delete d.starting,d=null),e.state===`stopped`&&(i&&y(e,e.error?`error`:e.restarted?`restarted`:`cancelled`,void 0,e.error),e.error&&!n.some(t=>t.id===`error:${e.i}`)&&n.push({kind:`error`,id:`error:${e.i}`,message:e.error}),u=void 0,r.tasks=[]);break;case`turn_started`:d&&=(delete d.starting,null),i&&y(e,`end_turn`),v(e);break;case`turn_ended`:y(e,e.reason,e.files,e.error);break;case`agent_text`:{let t=v(e),n=t.segments[t.segments.length-1];n?.kind===`text`&&n.id===e.messageId?n.text+=e.text:t.segments.push({kind:`text`,id:e.messageId,text:e.text}),_(!0);break}case`thought`:{let t=v(e),n=t.segments[t.segments.length-1];n?.kind===`thought`&&n.id===e.thoughtId?(n.text+=e.text,n.to=e.at):t.segments.push({kind:`thought`,id:e.thoughtId,text:e.text,from:e.at,to:e.at}),_(!0);break}case`tool`:{if(!e.call.title&&o.has(e.call.id)&&!i?.calls.has(e.call.id))break;let t=v(e),n=t.calls.get(e.call.id);if(n?Object.assign(n,Object.fromEntries(Object.entries(e.call).filter(([,e])=>e!==void 0&&e!==``))):x(t,e,{...Sm,...e.call,id:e.call.id},e.parentId),e.outputAppend){let n=t.calls.get(e.call.id);n.output=(n.output??``)+e.outputAppend}_(!0);break}case`subagent`:{let t=i?.subagents.get(e.id);if(t)e.title!==void 0&&(t.title=e.title),e.status!==void 0&&(t.status=e.status);else{if(!(e.status===`in_progress`||e.status===`pending`)&&(a.has(e.id)||!e.title))break;let t=v(e),n={kind:`subagent`,id:e.id,title:e.title??`Subagent`,status:e.status??`in_progress`,calls:[]};a.add(e.id),t.subagents.set(e.id,n),t.segments.push(n)}_(!0);break}case`plan`:r.plan=e.entries;break;case`tasks`:r.tasks=e.tasks;break;case`ask`:{if(u=e.ask,e.ask.kind!==`approval`)break;let t=v(e),n=t.calls.get(e.ask.call.id);n?n.title||=e.ask.call.title:x(t,e,{...e.ask.call}),_(!0);break}case`ask_resolved`:{let t=u?.id===e.id?u:void 0;if(t&&(u=void 0),i){let n=i;if(t?.kind===`approval`&&e.lines.some(e=>e.denied)){let e=n.calls.get(t.call.id);e&&(e.status===`pending`||e.status===`in_progress`)&&(e.status=`failed`)}n.segments.push({kind:`answered`}),_(!0)}e.lines.forEach((t,r)=>n.push({kind:`answered`,id:`answered:${e.i}:${r}`,what:t.what,answer:t.answer,...t.denied?{denied:!0}:{}}));break}case`usage`:{e.context.costUsd!==void 0&&(g&&h!==void 0&&e.context.costUsd<h&&(m+=h),h=e.context.costUsd,g=!1);let t=h===void 0?void 0:m+h;r.context={...e.context,...t===void 0?{}:{costUsd:t}};break}case`model`:{let t=n.at(-1)?.kind===`model`;t&&n.pop();let i=t?p:r.model;if(t||(p=r.model),i&&i.id!==e.model){let t=!!i.effort&&!!e.effort&&i.effort!==e.effort;n.push({kind:`model`,id:`model:${e.i}`,model:e.label,...t?{effort:e.effort}:{}})}r.model={id:e.model,label:e.label,...e.effort?{effort:e.effort}:{},...e.fast===void 0?{}:{fast:e.fast}};break}case`commands`:r.commands=e.commands;break;case`compacted`:f||n.push({kind:`compacted`,id:`compacted:${e.i}`}),f=!0;break;case`notice`:n.push({kind:`notice`,id:`notice:${e.i}`,text:e.text});break;case`file_shown`:{let t=i;t&&(t.segments.push({kind:`answered`}),_(!0));let r=l>=0?n[l]:void 0;r?.kind===`shown`?r.files.push(e.file):(n.push({kind:`shown`,id:`shown:${e.i}`,files:[e.file]}),t&&(l=n.length-1));break}case`review_package`:{let t=i;t&&(t.segments.push({kind:`answered`}),_(!0)),n.push({kind:`review_package`,id:`review_package:${e.i}`,ticketId:e.ticketId}),t&&(l=n.length-1);break}case`title`:r.title=e.title;break;case`suggestion`:r.suggestion=e.text??void 0;break;case`error`:n.push({kind:`error`,id:`error:${e.i}`,message:e.message});break;case`rewound`:case`briefed`:case`branched`:break}let S=i;if(S&&!S.started){let e=u;y(t[t.length-1],`end_turn`),u=e}return r.ask=u,r.state=u?`waiting`:i?`working`:`idle`,r.state===`idle`&&(r.plan=[]),r}var wm=1e3,ree=wm/2-1;function Tm(e,t){if(t===0)return!0;let n=e[t-1];return/[\s/\\._\-:@]/.test(n)?!0:/[a-z0-9]/.test(n)&&/[A-Z]/.test(e[t])}function Em(e,t){let n=t.toLowerCase();if(!n)return 0;let r=e.toLowerCase();if(r.startsWith(n))return 4*wm;for(let t=r.indexOf(n);t>=0;t=r.indexOf(n,t+1))if(Tm(e,t))return 3*wm;if(r.includes(n))return 2*wm;let i=iee(e,r,n);return i===null?null:wm+Math.min(i,ree)}function iee(e,t,n){let r=[];for(let i=0;i<n.length;i++){let a=Array(t.length).fill(-1),o=i===0?0:-1;for(let s=0;s<t.length;s++){if(t[s]===n[i]){let t=Tm(e,s)?10:0,n=i>0&&s>0&&r[s-1]!==-1?r[s-1]+10:-1,c=Math.max(o,n);c!==-1&&(a[s]=c+t)}i>0&&r[s]!==-1&&(o=Math.max(o,r[s]))}r=a}let i=Math.max(-1,...r);return i===-1?null:i}function Dm(e,t,n,r=1/0){return e.flatMap(e=>{let r=t(e);return r===null?[]:[{item:e,s:r,l:n(e)}]}).sort((e,t)=>t.s-e.s||e.l.length-t.l.length||e.l.localeCompare(t.l)).slice(0,r).map(e=>e.item)}function aee(e,t){let n=Em(e,t),r=Em(e.slice(Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`))+1),t);return r===null?n:Math.max(n??0,r+wm/2)}function Om(e,t,n=1/0){return Dm(e,e=>aee(e,t),e=>e,n)}function km(e,t,n,r=1/0){return Dm(e,e=>Em(t(e),n),t,r)}var Am={setupCommand:`Setup`,verifyCommands:`Verify`,knownFailures:`Known failing tests`,devCommand:`Dev server`,dbResetCommand:`Reset dev database`,driveSetupCommand:`Before a test drive`,driveStopCommand:`After a test drive`,driveInstructions:`How to drive this app`,sandboxImage:`Sandbox image`},jm=new Set([`devCommand`,`dbResetCommand`,`driveSetupCommand`,`driveStopCommand`]);function Mm(e,t=Date.now()){let n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return`just now`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<36?`${i}h ago`:`${Math.round(i/24)}d ago`}function Nm(e){return qd.includes(e)}function Pm(e){return`${Im(e)}${Fm(e)}`}function Fm(e){return Nm(e.key)?e.verifiedAt===void 0?` Unverified — never proven by a dry run.`:` Verified ${Mm(e.verifiedAt)} by a dry run.`:``}function Im(e){if(e.source===`human`)return`You set this ${Mm(e.establishedAt)}.`;let t=e.source===`build`?`Built by runcastle from the repo Dockerfile`:e.source===`session`?`Established in a conversation on this machine`:jm.has(e.key)?`Proposed by preparation from config (not executed)`:`Established by preparation`,n=Mm(e.establishedAt);return e.staleCommits===void 0?`${t} ${n}${e.establishedSha?` — age against main unknown`:``}.`:e.staleCommits===0?`${t} ${n} — main has not moved since.`:`${t} ${n} — main has moved ${e.staleCommits} commit${e.staleCommits===1?``:`s`} since.`}function Lm(e){return e.source!==`human`&&(e.staleCommits??0)>=100}function Rm(e){return e.source===`human`?{label:`Yours`,title:`You set this by hand — preparation will never overwrite it`}:e.source===`build`?{label:`Built`,title:`Built by runcastle from this repo's own Dockerfile`}:e.source===`session`?{label:`Verified`,title:`Established in a conversation on your own machine`}:jm.has(e.key)?{label:`Proposed`,title:`Read from config by an older automatic run, not executed`}:{label:`Measured`,title:`Measured by an older automatic run, in a sandbox`}}var zm={serverPort:`RUNCASTLE_SERVER_PORT`,model:`RUNCASTLE_MODEL`,sandbox:`RUNCASTLE_SANDBOX`,sandboxImage:`RUNCASTLE_SANDBOX_IMAGE`,sessionMcp:`RUNCASTLE_SESSION_MCP`,burnConcurrency:`RUNCASTLE_BURN_CONCURRENCY`,burnMaxIterations:`RUNCASTLE_BURN_MAX_ITERATIONS`,burnAttempts:`RUNCASTLE_BURN_ATTEMPTS`,burnConflictAttempts:`RUNCASTLE_BURN_CONFLICT_ATTEMPTS`,burnCpus:`RUNCASTLE_BURN_CPUS`,setupCommand:`RUNCASTLE_SETUP_COMMAND`,verifyCommands:`RUNCASTLE_VERIFY_COMMANDS`,knownFailures:`RUNCASTLE_KNOWN_FAILURES`},Bm={"claude-code":`Claude Code`,codex:`Codex`},Vm={general:[`server`,`sessions`],models:[`default`],burns:[`width`],project:[`model`,`commands`,`chat`]};function Hm(e){let t=e?.fields.find(e=>e.key===`models`)?.value;return Array.isArray(t)?t.flatMap(e=>{let t=_d.safeParse(e);return t.success?[t.data]:[]}):[]}function Um(e){return Cd({discovered:wd(e?.discovery??rf),models:Hm(e)})}function Wm(e){return md.map(t=>({runtime:t,label:Bm[t],entries:e.filter(e=>e.runtime===t)})).filter(e=>e.entries.length>0)}function Gm(e,t,n){let r=e.trim();if(r===``)return{error:`Enter a model id.`};if(!md.includes(t))return{error:`Choose which runtime this model runs on.`};let i=n.trim();return{entry:{id:r,runtime:t,...i?{note:i}:{}}}}var Km=`stepModels.`;function qm(e){return e.startsWith(Km)}function Jm(e){return e.slice(11)}var Ym=[{step:`chat`,label:`Chat`,group:`sessions`,description:`The feature conversation`},{step:`project`,label:`Project chat`,group:`sessions`,description:`The project-level conversation`},{step:`implement`,label:`Implement`,group:`unattended`,description:`Works a ticket in the sandbox`},{step:`review`,label:`Review`,group:`unattended`,description:`Reads the finished branch`},{step:`prepare`,label:`Prepare`,group:`unattended`,description:`Measures setup, verify and baseline`},{step:`smoke`,label:`Smoke`,group:`unattended`,description:`Cheap scripted end-to-end check`}],Xm=Object.fromEntries(Ym.map(e=>[e.step,e.label]));function Zm(e){return`${Km}${e}`}fd.map(Zm);var Qm={serverPort:{label:`Server port`,tooltip:`The port the runcastle server listens on. Changing it takes effect at the next server restart.`,control:`number`,page:`general`,group:`server`},model:{label:`Default model`,tooltip:`Runs every step that has no model of its own below — and every project that has not set one.`,control:`select`,page:`models`,group:`default`},sandbox:{label:`Sandbox`,tooltip:`Where launched sessions and workers run. A Docker container isolates them from this machine; “no sandbox” runs them directly on it.`,control:`select`,page:`general`,group:`sessions`,options:[`docker`,`noSandbox`],optionLabels:{docker:`Docker container (isolated)`,noSandbox:`No sandbox — run directly on this machine`}},sandboxImage:{label:`Sandbox image`,tooltip:`The Docker image sessions and workers are sandboxed in. Leave blank to use sandcastle:runcastle, which the first round builds if it is not there.`,control:`text`,page:`general`,group:`sessions`,placeholder:`sandcastle:runcastle`},sessionMcp:{label:`MCP servers in sessions`,tooltip:`Inherit mine — sessions see your own MCP servers (user, project and plugin) alongside runcastle’s. runcastle only — sessions see runcastle’s server and nothing else; use it for a reproducible tool surface or to keep a heavy personal MCP set out of the context window.`,control:`select`,page:`general`,group:`sessions`,options:[`inherit`,`runcastleOnly`],optionLabels:{inherit:`Inherit mine — my servers alongside runcastle’s`,runcastleOnly:`runcastle only — nothing else`}},burnConcurrency:{label:`Concurrency`,tooltip:`Tickets a round works in parallel (1–8). Each is a full worker with its own container, sizing its install and test workers from the whole core count — lower it if suites die under load.`,control:`number`,page:`burns`,group:`width`,unit:`tickets at once`},burnMaxIterations:{label:`Iterations per attempt`,tooltip:`Turns one healthy worker may take before it is stopped (1–10). A ticket that finishes early stops the loop itself.`,control:`number`,page:`burns`,group:`width`,shortHelp:`Distinct from attempts: an attempt restarts an agent that crashed.`,unit:`turns`},burnAttempts:{label:`Attempts per ticket`,tooltip:`Fresh agent attempts per ticket per run (1–5). A transient crash — API drop, network, rate limit — retries with committed work preserved; auth errors and conflicts never retry.`,control:`number`,page:`burns`,group:`width`,unit:`attempts`},burnConflictAttempts:{label:`Conflict resolver passes`,tooltip:`Agent passes spent resolving a ticket’s landing conflict before asking you (0–3). 0 sends every conflict straight to you.`,control:`number`,page:`burns`,group:`width`,unit:`passes before asking you`},burnCpus:{label:`CPU limit per worker`,tooltip:`CPU ceiling per worker container (--cpus). Blank leaves it unconstrained. Roughly cores ÷ concurrency keeps parallel tickets from oversubscribing the machine.`,control:`number`,page:`burns`,group:`width`,placeholder:`unlimited`,unit:`cores · e.g. 4 on a 12-thread box at width 3`},setupCommand:{label:`Setup`,tooltip:`Takes a clean checkout to a buildable state inside the worker sandbox — dependency install plus any codegen. Blank auto-detects from the lockfile.`,control:`text`,page:`project`,group:`commands`,placeholder:`e.g. pnpm install --frozen-lockfile && pnpm prisma:generate`},verifyCommands:{label:`Verify`,tooltip:`The exact typecheck / test / lint commands, one per line. Every worker is told to run them, and runcastle runs them itself at the end of every round and hands the results to the agent.`,control:`textarea`,page:`project`,group:`commands`,placeholder:`one per line, e.g.
|
|
73
|
-
pnpm --filter @acme/web test`},knownFailures:{label:`Known failing tests`,tooltip:`Tests already red on main — a count plus suite names is enough. Saves every worker a full pre-work run to establish its own baseline.`,control:`textarea`,page:`project`,group:`commands`,placeholder:`e.g. 2 failing: dev-pane.test.ts (Windows only)`},devCommand:{label:`Dev server`,tooltip:`Starts this project’s dev server for a test drive. The URL it prints becomes the “Open app” link.`,control:`text`,page:`project`,group:`commands`,placeholder:`e.g. pnpm dev`},driveSetupCommand:{label:`Before a test drive`,tooltip:`Runs on your machine before the dev server starts a test drive — bring up services, apply schema. A failure is reported, never fatal.`,control:`text`,page:`project`,group:`commands`,placeholder:`e.g. docker compose up -d && pnpm db:migrate`},driveStopCommand:{label:`After a test drive`,tooltip:`Runs when a test drive stops, while the feature branch is still checked out — stop services, drop the branch database.`,control:`text`,page:`project`,group:`commands`,placeholder:`e.g. docker compose down`},scenarioRunner:{label:`Scenario runner`,tooltip:`Runs one drive scenario. {file} is the scenario’s path under .runcastle/scenarios/.`,control:`text`,page:`project`,group:`commands`,placeholder:`e.g. bun {file}`},dbResetCommand:{label:`Reset dev database`,tooltip:`Rebuilds the dev database from the migrations in the working tree. Offered — never run automatically — after a test drive whose branch carried migrations this one does not have.`,control:`text`,page:`project`,group:`commands`,placeholder:`e.g. pnpm db:reset`},driveInstructions:{label:`How to drive this app`,tooltip:`How to exercise this app once it is up: the sample project or scratch data a driver should use and may change, how to reach the states worth reviewing, and what to leave alone. Written by preparation, edited here, and injected verbatim into every drive-mode review and verification prompt.`,control:`textarea`,page:`project`,group:`commands`,shortHelp:`Applies inside the app under test only — it changes no review rule and permits no edit to the repo under review.`,placeholder:`e.g. drive the sample project at ./examples/demo — change anything inside it freely`},docsCommitPrefix:{label:`Docs commit prefix`,tooltip:`Prefix for checkpoint commits runcastle creates from feature docs. Use a form accepted by this repository’s commit message policy.`,control:`text`,page:`project`,group:`chat`,placeholder:Yd},sessionBranch:{label:`Commits land on`,tooltip:`The branch the project chat’s commits (charter, ADRs) land on when its terminal closes. Blank uses the repo’s detected main line; a pick takes effect at the next chat you open.`,control:`text`,page:`project`,group:`chat`,placeholder:`main (detected)`}},$m=Object.keys(Qm),eh={model:{label:`Model`,tooltip:`A model set here runs every step of this project — it beats the global default and the per-step models.`,page:`project`,group:`model`},sandbox:{page:`project`,group:`model`},sandboxImage:{tooltip:`The Docker image THIS project’s sessions and workers are sandboxed in — where a repo needs a toolchain the stock image has none of. Blank inherits the machine-wide image.`,page:`project`,group:`model`}},th=new Set([`model`,`sandbox`,`sandboxImage`,`setupCommand`,`verifyCommands`,`knownFailures`]);function nh(e,t=`global`){if(qm(e)){let t=Jm(e),n=Xm[t]??t;return{label:n,tooltip:`Model for the ${n} step.`,control:`select`,page:`models`,group:`default`}}let n=Qm[e]??{label:e,tooltip:``,control:`text`,page:`general`,group:`server`};return t===`project`?{...n,...eh[e]}:n}function rh(e){return e==null?``:String(e)}function ih(e,t){let n=t.trim();if(e===`textarea`&&n===``)return{value:null};if(e!==`number`)return{value:n};if(n===``)return{value:null};let r=Number(n);return Number.isFinite(r)?{value:r}:{error:`Enter a number, or leave it blank to unset it.`}}function ah(e){return e===`model`||qm(e)}function oh(e,t){if(t.unit!==void 0)return e.key!==`burnConcurrency`||e.source!=="default"?t.unit:`${t.unit} · default on this machine: ${rh(e.value)}`}function sh(e){if(e.scope!==`project`)return e.key===`burnConcurrency`&&e.source==="default"&&rh(e.value)||void 0;if(th.has(e.key)&&!(e.source!==`file`&&e.source!=="default"))return rh(e.value)||void 0}var ch=new Set([`sandboxImage`]);function lh(e){return e.scope===`global`&&e.source===`file`&&ch.has(e.key)}function uh(e){if(e.source===`env`)return`env`;if(!(e.scope!==`project`||!th.has(e.key)))return e.source===`project`?`project`:`global`}function dh(e){let t=[e.source===`human`?`You`:e.source===`session`?`Set in a session`:e.source===`build`?`Built by runcastle`:`Prepared`,Mm(e.establishedAt)];e.source!==`human`&&e.staleCommits&&t.push(`main +${e.staleCommits}`);let n=Nm(e.key)?e.verifiedAt===void 0?`unverified`:`verified by a dry run ${Mm(e.verifiedAt)}`:null;return n&&t.push(n),{text:t.join(` · `),tone:Lm(e)?`warn`:n===`unverified`?`muted`:`ok`,...e.evidence?{evidence:e.evidence}:{}}}function fh(e,t,n=yd){let r=nh(e.key,e.scope),i=ah(e.key),a=!e.editable,o=e.source===`project`,s=null;e.source===`env`?s=`Set by ${zm[e.key]??`the environment`}`:t&&o?s=Pm(t):e.scope===`project`&&(s=o?`Overridden for this project`:`Inherited from global`);let c=oh(e,r),l=sh(e),u=uh(e);return{key:e.key,label:r.label,...r.tag?{tag:r.tag}:{},tooltip:r.tooltip,...r.shortHelp?{shortHelp:r.shortHelp}:{},placeholder:r.placeholder??``,...c?{unit:c}:{},page:r.page,group:r.group,value:rh(e.value),control:r.control,options:i?n.map(e=>e.id):r.options??[],modelGroups:i?Wm(n):[],optionLabels:r.optionLabels??{},readOnly:a,restartRequired:e.restartRequired,overridden:o,source:e.source,note:s,...l?{ghostValue:l}:{},...u?{sourceChip:u}:{},clearable:lh(e),...t?{provenanceChip:dh(t)}:{},...t?.evidence?{evidence:t.evidence}:{},stale:t?Lm(t):!1,allowCustom:i}}function ph(e){return!qm(e)&&e!==`models`}function mh(e,t,n=[]){let r=new Map(n.map(e=>[e.key,e])),i=Um(e),a=Vm[t];return e.fields.filter(e=>ph(e.key)?t===`project`?e.scope===`project`:e.scope!==`project`&&nh(e.key).page===t:!1).map(e=>fh(e,r.get(e.key),i)).sort((e,t)=>a.indexOf(e.group)-a.indexOf(t.group)||$m.indexOf(e.key)-$m.indexOf(t.key))}function hh(e,t){let n=t=>e?.fields.find(e=>e.key===t),r=n(`model`),i=n(`${Km}${t}`),a=(r?.source===`project`?r:void 0)??(i?.source===`file`?i:void 0)??r;return typeof a?.value==`string`?a.value:void 0}function gh(e){return rh(e.fields.find(e=>e.key===`model`)?.value)}function _h(e,t){let n=e.fields.find(e=>e.key===`${Km}${t}`);return n?.source===`file`&&typeof n.value==`string`&&n.value!==``?n.value:null}var vh={"claude-code":`Claude`,codex:`Codex`};function yh(e){return e.discovery??rf}function oee(e){let t=md.filter(t=>e[t].status===`ok`);return t.length===0?null:t.length===1?t[0]:gd}function bh(e){let t=gh(e),n=new Map(fd.map(n=>[n,_h(e,n)??t])),r=new Set(yd.map(e=>e.id)),{sources:i}=yh(e),a=new Map(md.flatMap(e=>i[e].models.map(t=>[t.id,{model:t,runtime:e}]))),o=Um(e),s=new Set(o.map(e=>e.id)),c=oee(i),l=new Set([t,...n.values()].filter(e=>e!==``&&!s.has(e)));return[...o,...[...l].map(e=>({id:e,runtime:c??`claude-code`}))].map(e=>{let o=e.note??``,s=fd.filter(t=>n.get(t)===e.id),c=e.id===t,u=a.get(e.id),d=!r.has(e.id)&&!u&&!l.has(e.id),f=c||s.length>0||o!==``;return{id:e.id,runtime:e.runtime,displayName:u?.model.displayName??null,note:o,usedFor:s,isDefault:c,custom:d,discovered:u!==void 0,isNew:u!==void 0&&i[u.runtime].newIds.includes(e.id),noLongerOffered:f&&!u&&(r.has(e.id)||l.has(e.id)||i[e.runtime].knownIds.includes(e.id))&&i[e.runtime].status===`ok`?e.runtime:null,retirement:u?.model.retirement??null}})}function xh(e){return e.filter(e=>e.isDefault||e.usedFor.length>0||e.note!==``||e.custom||e.isNew)}function Sh(e){return e.length-xh(e).length}function Ch(e,t=Date.now()){let{sources:n}=yh(e);return md.map(e=>{let r=n[e],i=vh[e],a=r.lastSuccessAt;if(r.status===`never`)return{runtime:e,text:`${i}: not run yet`,failed:!1};if(r.status===`failed`){let n=a===void 0?``:` (last good ${Mm(a,t)})`;return{runtime:e,text:`${i}: failed — ${r.error??`unknown error`}${n}`,failed:!0}}let o=r.models.length,s=a===void 0?``:` · ${Mm(a,t)}`;return{runtime:e,text:`${i}: ${o} ${o===1?`model`:`models`}${s}`,failed:!1}})}function wh(e){let t={discovered:wd(yh(e)),models:Hm(e)},n=gh(e);return Ym.map(r=>{let i=_h(e,r.step),a=i??n;return{...r,value:i,effectiveModel:a,effectiveRuntime:Td(a,t).runtime}})}function Th(e){let t=e?.fields.find(e=>e.key===`model`);return t?.source===`project`&&rh(t.value)||null}function Eh(e){return[e.label,e.key,e.tooltip]}function Dh(e,t){let n=mh(e,t).map(e=>({id:e.key,page:t,terms:Eh(e)}));return t===`models`?[...n,...bh(e).map(e=>({id:e.id,page:t,terms:[e.id,e.note,Bm[e.runtime]]})),...wh(e).map(e=>({id:Zm(e.step),page:t,terms:[e.label,e.description,e.step]}))]:n}function Oh(e,t){let n={general:0,models:0,burns:0,project:0},r=e.trim().toLowerCase();if(r===``)return{counts:n,matches:new Set(t.map(e=>e.id))};let i=new Set;for(let e of t)e.terms.some(e=>e.toLowerCase().includes(r))&&(i.add(e.id),n[e.page]+=1);return{counts:n,matches:i}}function kh(e){return Ah.test(e)?{page:`burns`,field:`sandcastle-image`}:null}var Ah=/Settings\s*→\s*(?:Workers|AFK burns|Burns)/i;function jh(e){let t=Ah.exec(e),n=kh(e);return!t||!n?null:{before:e.slice(0,t.index),phrase:t[0],after:e.slice(t.index+t[0].length),location:n}}var Mh=[{key:`identity`,label:`Git identity`},{key:`runtimes`,label:`Coding agents`},{key:`afk`,label:`Unattended workers`},{key:`project`,label:`First project`}];function Nh(e){return e?.status===`ok`?`runtimes`:`identity`}function Ph(e){return Mh[Mh.findIndex(t=>t.key===e)+1]?.key}function Fh(e,t){if(e!==Nh(t))return Mh[Mh.findIndex(t=>t.key===e)-1]?.key}var Ih={"claude-code":{kind:`claude-login`,command:`claude auth login`},codex:{kind:`codex-login`,command:`codex login`}};function Lh(e){return md.map(t=>{let n=n=>e.find(e=>e.runtime===t&&e.check===n),r=n(`binary`),i=r?.status===`ok`,a=n(`auth`)?.status===`ok`,o=t===`codex`?a:n(`afk-key`)?.status===`ok`;return{runtime:t,label:Bm[t],installed:i,authed:a,afkReady:o,talkReady:i&&(a||o),detail:r?.detail??`not checked`,...i||!r?.fix?{}:{installFix:r.fix}}})}function Rh(e){return e.filter(e=>e.talkReady).map(e=>e.runtime)}function zh(e){return e.find(e=>e.id===`git-identity`)?.status===`ok`&&Rh(Lh(e)).length>0}function Bh(e){return e?.status===`ok`?`detected from git config: ${e.detail}`:void 0}function Vh(e,t){let n=Mh.findIndex(t=>t.key===e),r=Bh(t);return Mh.map((e,t)=>e.key===`identity`&&t<n&&r?{...e,state:`passed`,detected:r}:{...e,state:t<n?`done`:t===n?`current`:`todo`})}var Hh=`review-artifacts`;function Uh(e,t=!0){return ft({enabled:t,queryKey:[Hh,e],queryFn:async()=>{let t=await fetch(pf(e));if(!t.ok)throw Error(`review artifacts: ${t.status}`);return await t.json()}})}function Wh(e){if(!e)return null;for(let t of Array.from(e.files))if(t.type.startsWith(`image/`))return t;for(let t of Array.from(e.items)){if(t.kind!==`file`||!t.type.startsWith(`image/`))continue;let e=t.getAsFile();if(e)return e}return null}async function Gh(e){if(e.type===`image/png`)return e;let t=await createImageBitmap(e),n=document.createElement(`canvas`);n.width=t.width,n.height=t.height;let r=n.getContext(`2d`);if(!r)throw Error(`this browser offered no 2d canvas to convert the image with`);return r.drawImage(t,0,0),t.close(),await new Promise((e,t)=>{n.toBlob(n=>{n?e(n):t(Error(`the browser produced no PNG from that image`))},`image/png`)})}async function Kh(e,t){let n=await fetch(gf(e),{method:`POST`,headers:{"content-type":`image/png`},body:t});if(!n.ok)throw Error(`screenshot upload: ${n.status}`)}function qh(e){return ft({queryKey:[Hh,`package`,e],queryFn:async()=>{let t=await fetch(ff(e));if(t.status===404)return null;if(!t.ok)throw Error(`review package ${t.status}`);return await t.json()}})}var Jh=`connecting`,Yh=new Set;function Xh(e){if(e!==Jh){Jh=e;for(let e of Yh)e()}}function Zh(e){return Yh.add(e),()=>Yh.delete(e)}function Qh(){return(0,F.useSyncExternalStore)(Zh,()=>Jh)}var $h=3e4,eg=1500;function tg(e=eg){return ng(Qh(),e)}function ng(e,t=eg){return e===`live`?$h:t}var rg=5e3,ig=1e4;function ag(e,t){let n=!1,r=!1,i=()=>{if(n){r=!0;return}let a=e();if(!a)return;n=!0;let o,s=new Promise(e=>{o=setTimeout(e,ig)});Promise.race([a.catch(()=>{}),s]).then(()=>{clearTimeout(o),n=!1,r&&!t()&&(r=!1,i())})};return i}function og(e){let t=null,n=null,r=Date.now(),i=!1,a=()=>i,o=ag(e.resyncAll,a),s=ag(e.resyncThreadLists,a),c=new Map,l=t=>{let n=c.get(t);n||(n=ag(()=>e.resyncThread(t),a),c.set(t,n)),n()},u=()=>{n?.(),n=null,t?.close(),t=null},d=()=>{if(i)return;u(),Xh(`connecting`),r=Date.now();let a=new EventSource(`/api/stream`);t=a;let c=()=>{r=Date.now(),Xh(`live`),o(),e.resyncTranscript()},d=t=>{r=Date.now(),Xh(`live`);let n;try{n=JSON.parse(t.data)}catch{o();return}n.kind===`transcript`?e.resyncTranscript():n.kind===`thread`?(l(n.threadId),s()):o()},f=()=>{r=Date.now()},p=()=>{Xh(a.readyState===EventSource.CLOSED?`offline`:`connecting`)};a.addEventListener(`ready`,c),a.addEventListener(`live`,d),a.addEventListener(`ping`,f),a.addEventListener(`error`,p),n=()=>{a.removeEventListener(`ready`,c),a.removeEventListener(`live`,d),a.removeEventListener(`ping`,f),a.removeEventListener(`error`,p)}},f=()=>{i||Date.now()-r<=35e3||d()},p=setInterval(f,rg),m=()=>{document.visibilityState===`visible`&&f()};return window.addEventListener(`focus`,f),window.addEventListener(`online`,f),document.addEventListener(`visibilitychange`,m),d(),()=>{i=!0,clearInterval(p),window.removeEventListener(`focus`,f),window.removeEventListener(`online`,f),document.removeEventListener(`visibilitychange`,m),u(),Xh(`connecting`)}}function sg(){let e=R.useUtils(),t=Ye(),n=Qh(),r=(0,F.useRef)(e);return r.current=e,(0,F.useEffect)(()=>og({resyncAll:()=>{let e=r.current,n=[];return n.push(e.events.invalidate()),n.push(e.feature.list.invalidate()),n.push(e.feature.get.invalidate()),n.push(e.feature.driveInfo.invalidate()),n.push(e.feature.rounds.invalidate()),n.push(e.feature.readyDeclarations.invalidate()),n.push(e.feature.sessions.invalidate()),n.push(e.thread.list.invalidate()),n.push(e.feature.driveScenarios.invalidate()),n.push(e.notes.invalidate()),n.push(e.projectNotes.invalidate()),n.push(e.findings.invalidate()),n.push(e.project.prep.invalidate()),n.push(e.run.get.invalidate()),n.push(e.run.listByFeature.invalidate()),n.push(e.project.list.invalidate()),n.push(e.docs.invalidate()),n.push(e.settings.get.invalidate()),n.push(e.setup.imageBuildTarget.invalidate()),n.push(e.project.sessionBranch.invalidate()),n.push(e.feature.commitCount.invalidate()),n.push(e.feature.mergeDelta.invalidate()),n.push(e.project.prepSession.invalidate()),n.push(e.project.projectSession.invalidate()),n.push(e.project.conversations.invalidate()),n.push(e.design.status.invalidate()),n.push(t.invalidateQueries({queryKey:[Hh]})),Promise.allSettled(n)},resyncTranscript:()=>{r.current.run.agentTranscript.invalidate()},resyncThread:e=>r.current.thread.events.invalidate({threadId:e}),resyncThreadLists:()=>r.current.thread.list.invalidate()}),[]),n}function cg(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function lg(e){return new Date(e).toLocaleString()}var ug=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})/g;function dg(e,t=lg){return e.replace(ug,e=>{let n=Date.parse(e);return Number.isNaN(n)?e:t(n)})}function fg(e){return e.slice(0,7)}var pg=[`B`,`kB`,`MB`,`GB`,`TB`];function mg(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=Math.min(Math.floor(Math.log10(e)/3),pg.length-1),n=e/1e3**t;return`${n.toFixed(+(t>0&&n<10))} ${pg[t]}`}function hg(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<5)return`now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function gg(e,t=Date.now()){let n=hg(e,t);return n===`now`?`just now`:`${n} ago`}function _g(e,t){let n=Math.max(0,Math.floor((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60;return r>0?`${r}h ${String(i).padStart(2,`0`)}m`:i>0?`${i}m ${String(a).padStart(2,`0`)}s`:`${a}s`}function vg(e){return e.filter(e=>!e.satisfied)}function yg(e){return e.satisfied?`merged`:e.status===`archived`?`archived`:e.status===`draft`?`draft`:`in progress`}function bg(e){return vg(e).map(e=>`${e.slug} (${yg(e)})`).join(`, `)}function xg(e){let t=vg(e).map(e=>e.slug),n=t.length===1?`starts by itself when ${t[0]} ships`:`starts by itself when these ship: ${t.join(`, `)}`,r=Sf(e).map(e=>e.slug);return r.length>0?`${n} — won't start until you start ${r.join(`, `)}`:n}function Sg(e){let t=vg(e);return t.length===0?null:`Waits on ${t.map(e=>e.status===`archived`?`${e.slug} (archived — remove it to start)`:`${e.slug} (${yg(e)})`).join(`, `)}`}function Cg(e,t,n){let r=new Set(n.map(e=>e.featureId));return e.filter(e=>e.projectId===t.projectId&&e.id!==t.id&&!r.has(e.id)&&!Cf(e))}var wg=e=>bf(e,e.dependsOn),Tg=`ready to test`;function Eg(e){return!!e.liveSession&&!e.liveSession.awaitingInput||e.leadInBackground}function Dg(e){return e.status===`draft`?wg(e)===`stuck`?{kind:`stuck`,label:e.upNextProblem??xf(e.dependsOn)}:null:e.status===`shipped`||e.status===`archived`||e.activeRun||e.liveSession&&!e.liveSession.awaitingInput?null:e.waitingReason?{kind:`waiting`,label:e.waitingReason}:e.leadAwaitsHuman?{kind:`input`,label:`the lead waits on your answer`}:null}function Og(e){let{total:t,done:n,cancelled:r}=e.ticketCounts,i=t-r;return i>0?n/i:0}function kg(e){return e.status===`draft`?`draft`:e.status===`shipped`?`shipped`:`active`}function Ag(e,t=Date.now()){let n=Dg(e);if(n)return{kind:`needsMe`,text:`Needs you`,title:n.label,needs:n.kind};if(e.activeRun)return{kind:`working`,text:`Working`,title:`agent working`};if(Eg(e))return{kind:`working`,text:`Working`,title:`the agent is working in the session`};if(e.status===`shipped`)return{kind:`shipped`,text:``,title:`shipped`};let r=wg(e);if(r){let t=vg(e.dependsOn),n=e=>t.length===1?`${e} ${t[0].slug}`:`${e} ${t.length}`;return r===`upNext`?{kind:`draft`,text:n(`After`),title:xg(e.dependsOn)}:r===`blocked`?{kind:`draft`,text:n(`Blocked by`),title:`blocked by ${bg(e.dependsOn)}`}:r===`readyToStart`?{kind:`draft`,text:`Ready to start`,title:`everything it waited on shipped — click Start to cut its branch`}:{kind:`draft`,text:`In the backlog`,title:`parked — click Start to cut its branch`}}let i=hg(e.lastActivityAt,t);return{kind:`age`,text:i,title:`last activity ${i===`now`?`just now`:`${i} ago`}`}}function jg(e){let{total:t,done:n,cancelled:r}=e.ticketCounts,i=t-r;return i>0?`${n}/${i}`:null}function Mg(e,t){return[...e].map((e,t)=>({f:e,i:t})).sort((e,n)=>t(e.f)-t(n.f)||e.i-n.i).map(e=>e.f)}var Ng={readyToStart:0,backlog:1,blocked:2},Pg=e=>{let t=wg(e);return(t&&Ng[t])??0};function Fg(e){if(e.length!==0)return[...e].sort((e,t)=>t.startedAt-e.startedAt)[0]}function Ig(e){if(e.status===`archived`)return`archived`;if(e.status===`shipped`)return`shipped`;let t=wg(e);return t===`upNext`?`upNext`:t===`stuck`?`needsYou`:t?`drafts`:e.activeRun?`agentWorking`:Dg(e)?`needsYou`:Eg(e)?`agentWorking`:`inProgress`}function Lg(e,t={}){let n={needsYou:[],agentWorking:[],inProgress:[],upNext:[],drafts:[],shipped:[],archived:[]};for(let t of e)n[Ig(t)].push(t);n.drafts=Mg(n.drafts,Pg);let r=[{key:`needsYou`,label:`Needs you`},{key:`agentWorking`,label:`Agent working`},{key:`inProgress`,label:`In progress`},{key:`upNext`,label:`Up next`},{key:`drafts`,label:`Backlog`},{key:`shipped`,label:`Shipped`}];return t.showArchived&&r.push({key:`archived`,label:`Archived`}),r.map(({key:e,label:t})=>({key:e,label:t,features:n[e]})).filter(e=>e.features.length>0)}function Rg(e,t={}){let n=Lg(e,t);return{inbox:n.find(e=>e.key===`needsYou`)?.features??[],lanes:n.filter(e=>e.key!==`needsYou`)}}var zg=[`needsYou`,`agentWorking`,`inProgress`];function Bg(e){for(let t of zg){let n=e.find(e=>Ig(e)===t);if(n)return n}return null}function Vg(e){return e.length===0?{view:`open`,projectId:null}:e.length===1?{view:`project`,projectId:e[0].id}:{view:`home`,projectId:null}}function Hg(e,t,n){return n?t?.view===`project`&&e.some(e=>e.id===t.projectId)?{view:`project`,projectId:t.projectId}:t?.view===`home`&&e.length>0?{view:`home`,projectId:null}:Vg(e):{view:`setup`,projectId:null}}function Ug(e,t,n,r){let i=t&&t.kind!==`home`?t.projectId:null;return r&&i&&e.some(e=>e.id===i)?{view:`project`,projectId:i}:Hg(e,n,r)}function Wg(e,t){return(e.view===`project`?!t.some(t=>t.id===e.projectId):e.view===`home`&&t.length===0)?Vg(t):null}function see(e){return Dg(e)!==null}function cee(e){let t=e.filter(e=>e.activeRun).length,n=e.filter(see).length,r=e.filter(e=>e.status===`shipped`).length,i=e.length;return{total:i,needsYou:n,activeRuns:t,shipped:r,health:i===0?`empty`:n>0?`attention`:t>0?`working`:`steady`}}function lee(e){let t=Gg(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<0?t:t.slice(n+1)}function Gg(e){return e.replace(/[\\/]+$/,``)}var uee=/does not exist|cannot read/i;function dee(e,t){let n=e?.trim()||void 0;return!n||!t||!uee.test(t)?{dir:n,keepTyped:!1}:{dir:fee(n),keepTyped:!0}}function fee(e){let t=Gg(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));if(n<=0)return;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?`${r}\\`:/^[\\/]+$/.test(r)?void 0:r}var pee=[{match:/path does not exist: (.*)$/i,message:`Path does not exist`,hint:`Check the path, or pick a folder from the rail.`},{match:/cannot read (?:path|directory): (.*?)(?: \(.*\))?$/i,message:`Cannot read that folder`,hint:`It may need permissions this machine does not have.`},{match:/path is not absolute: (.*)$/i,message:`Enter an absolute path`,hint:`A path from the root of the machine runcastle runs on.`}];function Kg(e){for(let t of pee){let n=t.match.exec(e);if(n)return{message:t.message,hint:t.hint,path:n[1].trim()||null}}return{message:e,hint:null,path:null}}function mee(e,t){let n=t.trim()||null;if(/not a git repository/i.test(e))return{message:`Not a git repository`,hint:`runcastle tracks work as branches, so it needs a git repository. Initialize one here, or pick a folder that already is one.`,path:n,offer:`init-repo`};let r=/does not exist/i.test(e);return r||/cannot read/i.test(e)?{message:r?`Path does not exist`:`Cannot read that path`,hint:`Check the path, or use Browse… to find the folder.`,path:n}:{message:e,hint:null,path:null}}var qg=[`plan`,`work`,`details`,`design`,`drive`];function Jg(e){return qg.includes(e)}var hee={body:`work`,preview:`plan`,review:`work`};function Yg(e){return Jg(e)?e:hee[e]??null}var gee={testDrive:`drive`},_ee=[`decisions.md`,`spec.md`];function vee(e){return!!e.preview||e.docs.some(e=>_ee.some(t=>e.relPath.endsWith(t)))}function yee(e){if(e.isDraft)return[];let t={plan:e.hasPlan,work:e.hasTickets,details:!0,design:e.designRunning,drive:e.driveActive};return qg.filter(e=>t[e])}function Xg(e){return e.filter(e=>e!==`drive`)}function bee({driveActive:e,hasNotes:t}){return[...e?[`drive`]:[],...t?[`details`]:[]]}function Zg(e){return e===`details`?`Notes`:$g[e]}function Qg(e,t){if(e.type!==`panel.show`||e.featureId!==t)return null;let n=e.data??{},r=typeof n.view==`string`?Yg(n.view):null;return r?{view:r,...typeof n.path==`string`?{path:n.path}:{},...typeof n.width==`number`&&Number.isInteger(n.width)&&n.width>0?{width:n.width}:{}}:null}var $g={plan:`Plan`,work:`Tickets`,design:`Design`,drive:`Drive`,details:`Details`},e_=.5,t_={view:null,share:e_,collapsed:!1};function n_(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):e_}function r_(e,t){switch(t.type){case`open`:{let n=a_(e,t.view,t.origin,t.path);if(t.view!==`design`)return n;let{width:r,...i}=n;return t.width===void 0?i:{...i,width:t.width}}case`follow`:return a_(e,gee[t.click],`runcastle`);case`switch`:return a_(i_(e),t.view,`human`);case`close`:{let{path:t,width:n,origin:r,doc:i,...a}=e,o=e.view??e.last;return{...a,view:null,collapsed:!1,...o?{last:o}:{}}}case`setWidth`:return{...e,share:n_(t.share)};case`toggleFull`:return{...e,share:e.share>=1?e_:1,collapsed:!1};case`collapse`:return e.view?{...e,collapsed:!0}:e;case`expand`:return{...e,collapsed:!1};case`toggle`:{if(e.view)return r_(e,{type:`close`});let n=e.last&&t.views.includes(e.last)?e.last:t.views[0];return n?a_(e,n,`human`):e}case`openDoc`:return e.view?{...e,doc:t.doc,collapsed:!1}:e;case`closeDoc`:return i_(e)}}function i_(e){let{doc:t,...n}=e;return n}function a_(e,t,n,r){return{...t===e.view?e:i_(e),view:t,last:t,origin:n,collapsed:!1,...t===`design`&&r!==void 0?{path:r}:{}}}function o_(e){return e===`chat`||e!==`work`&&Jg(e)}function s_(e){return e===null?null:e===`tickets`||e===`overview`?`work`:e===`chat`?e:Yg(e)}function c_(e){return e.view??`work`}function l_(e){return e.kind===`home`?null:e.projectId}function u_(e){return e.namesWork?`work`:e.view}function d_(e,t){return!e||e.kind!==t.kind||l_(e)!==l_(t)?!1:e.kind!==`feature`||t.kind===`feature`&&e.featureSlug===t.featureSlug}function f_(e){if(e.kind===`home`)return`/`;let t=`/p/${encodeURIComponent(e.projectId)}`;switch(e.kind){case`project`:return t;case`chat`:return`${t}/chat`;case`conversations`:return`${t}/conversations`;case`prepare`:return`${t}/prepare`;case`feature`:{let n=`${t}/f/${encodeURIComponent(e.featureSlug)}`;return e.view?`${n}/${e.view}`:n}}}function p_(e){try{return e.split(`/`).filter(e=>e.length>0).map(decodeURIComponent)}catch{return null}}function m_(e){let t=p_(e);if(!t)return null;if(t.length===0)return{kind:`home`};if(t[0]!==`p`)return null;let n=t[1];if(!n)return null;if(t.length===2)return{kind:`project`,projectId:n};if(t.length===3&&t[2]===`chat`)return{kind:`chat`,projectId:n};if(t.length===3&&t[2]===`conversations`)return{kind:`conversations`,projectId:n};if(t.length===3&&t[2]===`prepare`)return{kind:`prepare`,projectId:n};if(t.length===4&&t[2]===`f`&&t[3])return{kind:`feature`,projectId:n,featureSlug:t[3]};let r=t[4];if(t.length===5&&t[2]===`f`&&t[3]&&r&&o_(r))return{kind:`feature`,projectId:n,featureSlug:t[3],view:r};let i=t[3],a=t.length===5&&t[2]===`f`&&i&&r?s_(r):null;return i&&a===`work`?{kind:`feature`,projectId:n,featureSlug:i,namesWork:!0}:i&&a===`plan`?{kind:`feature`,projectId:n,featureSlug:i,view:a}:null}function h_(e,t){return!e||e.kind===`home`||e.kind===`project`?null:e.projectId===t?e:null}function g_(e){let{projectId:t,featureView:n=`work`}=e;if(e.preparing)return{kind:`prepare`,projectId:t};if(e.projectSelected)return{kind:e.conversations?`conversations`:`chat`,projectId:t};if(e.featureSlug){let r={kind:`feature`,projectId:t,featureSlug:e.featureSlug};return n===`work`?r:{...r,view:n}}return{kind:`project`,projectId:t}}function __(){return typeof window>`u`?`/`:window.location.pathname}var v_={runcastle:!0};function y_(e){typeof window>`u`||__()===e||window.history.pushState(v_,``,e)}function b_(e){window.history.state?.runcastle?window.history.back():e()}function x_(e){typeof window>`u`||__()===e||window.history.replaceState(null,``,e)}var S_=`thread`;function C_(){return typeof window>`u`?null:new URLSearchParams(window.location.search).get(S_)}var w_=(0,F.createContext)(!0);function T_(e,t){let n=(0,F.useContext)(w_),[r,i]=(0,F.useState)(()=>n?C_():void 0),[a,o]=(0,F.useState)(e);r===void 0&&n?i(C_()):typeof r==`string`&&t&&(i(null),t(r)&&o(r));let s=(0,F.useCallback)(e=>{i(null),o(e)},[]),c=typeof r==`string`?r:null;return{front:c===null?a:e,pick:s,pending:c}}function E_(e){let t=(0,F.useContext)(w_);(0,F.useEffect)(()=>{if(e===void 0||!t)return;let n=setTimeout(()=>{if(C_()===e)return;let t=e?`?${new URLSearchParams({[S_]:e})}`:``;window.history.replaceState(window.history.state,``,`${__()}${t}`)},0);return()=>clearTimeout(n)},[e,t])}function D_(e,t){let n=e?f_(e):null,r=(0,F.useRef)(!1);(0,F.useEffect)(()=>{if(n===null){r.current=!1;return}if(__()!==n)if(r.current)window.history.pushState(v_,``,n);else{let t=e&&d_(m_(__()),e)?window.location.search:``;window.history.replaceState(null,``,`${n}${t}`)}r.current=!0},[n]);let i=(0,F.useRef)(t);(0,F.useEffect)(()=>{i.current=t}),(0,F.useEffect)(()=>{let e=()=>i.current(m_(__()));return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[])}var O_=`runcastle.project.v1`;function k_(){let e;try{e=localStorage.getItem(O_)}catch{return null}if(!e)return null;try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t;return n.view===`home`?{view:`home`}:n.view===`project`&&typeof n.projectId==`string`?{view:`project`,projectId:n.projectId}:null}catch{return null}}var A_=`runcastle.setupComplete.v1`;function j_(){try{return localStorage.getItem(A_)===`true`}catch{return!1}}function M_(e){try{localStorage.setItem(A_,String(e))}catch{}}function N_(e){try{localStorage.setItem(O_,JSON.stringify(e))}catch{}}function P_(){let e=R.project.list.useQuery(void 0,{refetchInterval:tg(5e3)}),t=e.data,n=R.setup.doctor.useQuery(void 0,{refetchOnWindowFocus:!1,retry:!1,retryOnMount:!1}),[r]=(0,F.useState)(k_),[i]=(0,F.useState)(()=>m_(__())),[a,o]=(0,F.useState)(null),s=(0,F.useRef)(null),[c]=(0,F.useState)(j_),l=!n.data||zh(n.data.results),u=(0,F.useRef)(!1),d=(0,F.useRef)(!1);!s.current&&t&&(!n.isLoading||c)?(s.current=Ug(t,i,r,l),u.current=n.isLoading):u.current&&t&&!n.isLoading&&(u.current=!1,!l&&a===null&&(s.current=Ug(t,i,r,!1),d.current=!1)),(0,F.useEffect)(()=>{n.data&&M_(zh(n.data.results))},[n.data]);let f=a??s.current,p=f?.view??`home`,m=f?.projectId??null;(0,F.useEffect)(()=>{if(!t||!f)return;let e=Wg(f,t);e&&(d.current=!1,o(e))},[t,f]),(0,F.useEffect)(()=>{d.current||!f||(d.current=!0,f.view===`project`&&f.projectId?l_(m_(__())??{kind:`home`})!==f.projectId&&x_(f_({kind:`project`,projectId:f.projectId})):x_(`/`))},[f]),(0,F.useEffect)(()=>{let e=()=>{let e=l_(m_(__())??{kind:`home`});o(e?{view:`project`,projectId:e}:{view:`home`,projectId:null})};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let h=(0,F.useCallback)(()=>{o({view:`home`,projectId:null}),N_({view:`home`}),y_(`/`)},[]),g=(0,F.useCallback)(e=>{o({view:`project`,projectId:e}),N_({view:`project`,projectId:e}),y_(f_({kind:`project`,projectId:e}))},[]),_=(0,F.useCallback)(()=>o({view:`open`,projectId:m}),[m]),v=(0,F.useCallback)(()=>{p===`open`&&o(m?{view:`project`,projectId:m}:{view:`home`,projectId:null})},[p,m]),y=t?.find(e=>e.id===m),b=n.refetch,x=(0,F.useCallback)(()=>{b()},[b]);return{projects:t,loading:e.isLoading||n.isLoading&&!c,doctorError:n.error?.message??null,recheckDoctor:x,view:p,currentProjectId:m,currentProject:y,goHome:h,enterProject:g,showOpen:_,cancelOpen:v}}var F_=`runcastle.selected.v1`,I_=`runcastle.preparing.v1`,L_=`runcastle.guidance`,R_=`runcastle.feature.tab`;function z_(e){return`${F_}:${e}`}function B_(e){return`${I_}:${e}`}function V_(e){return`${R_}:${e}`}function H_({stored:e,isDraft:t}){return t?`work`:s_(e)??`chat`}function U_(e,t){return H_({stored:W_(V_(e)),isDraft:t?.status===`draft`})}function W_(e){try{return localStorage.getItem(e)}catch{return null}}function G_(e,t){try{localStorage.setItem(e,t)}catch{}}function K_(e){try{localStorage.removeItem(e)}catch{}}function q_(e){let t=z_(e),n=B_(e),[r,i]=(0,F.useState)(()=>W_(t)),[a,o]=(0,F.useState)(()=>{let e=W_(t);return e&&s_(W_(V_(e)))||`chat`}),[s,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(()=>W_(n)===`1`),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(!1),[h,g]=(0,F.useState)(!1),[_,v]=(0,F.useState)(null),[y,b]=(0,F.useState)(()=>W_(L_)!==`0`);(0,F.useEffect)(()=>{r?G_(t,r):K_(t)},[r,t]),(0,F.useEffect)(()=>{G_(n,l?`1`:`0`)},[l,n]),(0,F.useEffect)(()=>{G_(L_,y?`1`:`0`)},[y]);let x=(0,F.useCallback)((e,t=`chat`)=>{i(e),o(t),e&&G_(V_(e),t),c(!1),u(!1),f(!1),m(!1),g(!1)},[]),S=(0,F.useCallback)(()=>{f(!0),m(!1),c(!1),u(!1),g(!1)},[]),C=(0,F.useCallback)(()=>{f(!0),c(!1),u(!1),g(!1)},[]),w=(0,F.useCallback)(()=>{f(!0),m(!0),c(!1),u(!1),g(!1)},[]),T=(0,F.useCallback)(e=>{o(e),r&&G_(V_(r),e)},[r]),E=(0,F.useCallback)(()=>{c(!0),u(!1),f(!1),m(!1),g(!1)},[]),D=(0,F.useCallback)(()=>{u(!0),c(!1),f(!1),m(!1),g(!1)},[]),O=(0,F.useCallback)((e={page:`general`})=>{v(e),g(!1)},[]),k=(0,F.useCallback)(()=>v(null),[]);return{selectedFeatureId:r,projectSelected:d,conversations:p,featureView:a,creating:s,preparing:l,cmdkOpen:h,settings:_,guidance:y,select:x,selectView:T,selectProject:S,showProject:C,openConversations:w,startDraft:E,startPreparation:D,cancelCreate:(0,F.useCallback)(()=>c(!1),[]),closePreparation:(0,F.useCallback)(()=>u(!1),[]),setCmdk:g,openSettings:O,closeSettings:k,toggleGuidance:(0,F.useCallback)(()=>b(e=>!e),[])}}function J_(e){return e.branches.includes(e.current)?e.current:e.branches.includes(e.detected)?e.detected:``}function Y_(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40)}function X_(e,t){let n=Y_(e);if(n===``)return null;let r=t.find(e=>e.slug===n);if(!r)return null;let i=r.status===`shipped`?`was already shipped`:`already exists`;return`“${r.title}” ${i} on feature/${r.slug}. Creating this makes a second feature and a second branch.`}function Z_(e){return e.split(/\r?\n/).filter(e=>e.startsWith(`## `)).length}function Q_(e,t,n){return`Proceed with your task: RESOLVE A MERGE CONFLICT. Merging ${e} into ${t} conflicts on: ${n.length?n.join(`, `):`(run git status to see the conflicts)`}. Your working directory IS the talk worktree, already checked out on ${t}. Run \`git merge ${e}\`, then resolve every conflict using this feature’s spec.md and decisions.md for intent. ${$_} Then commit the merge. Do NOT push. When the merge commit is in, tell me to click “Merge & ship” again for a clean retry — ${ev}`}var $_="Verify without dependencies — package installs are blocked in this worktree: run `git diff --check` and grep for leftover `<<<<<<<` / `>>>>>>>` markers, re-read each resolved hunk against both sides, and confirm every import and symbol the merged code uses exists on the merged side.",ev=`and that I can test-drive the branch first (it runs in the main checkout, with dependencies) for a real run.`;function tv(e){let t=e.files.length?e.files.join(`, `):`(run git status after the merge to see them)`;return`Proceed with your task: RESOLVE A MERGE CONFLICT. Ticket #${e.seq} (“${e.title}”) is fully implemented on branch ${e.branch}, but landing it on ${e.featureBranch} conflicts on: ${t}. Your working directory IS the talk worktree, already checked out on ${e.featureBranch}. Run \`git merge ${e.branch}\`, read both sides before resolving (the ticket's work on one side, the sibling tickets that landed first on the other), and resolve by intent using this feature's spec.md and decisions.md — keep BOTH sides working. ${$_} Then commit the merge. Do NOT push. When the merge commit is in, retry the ticket with dispatch_round({ seqs: [${e.seq}] }) so runcastle records it as landed, then tell me it is in — ${ev}`}var nv=`One terminal per feature — your live session will be closed to open the resolve session.`,rv=[`burn.started`,`merge.resolved`,`feature.shipped`];function iv(e){let t=!1,n=!1;for(let r of e)r.type===`merge.conflict`?(t=!0,n=!1):r.type===`merge.resolved`?n=t:rv.includes(r.type)&&(t=!1,n=!1);return n}function av(e){let t=e.data?.sessionId;return typeof t==`string`?t:void 0}function ov(e,t){let n=new Set(t.filter(e=>e.purpose===`resolve-conflict`).map(e=>e.id)),r=!1;for(let t of e)if(t.type===`merge.conflict`||rv.includes(t.type))r=!1;else if(t.type===`session.ended`||t.type===`session.reconciled`){let e=av(t);e&&n.has(e)&&(r=!0)}return r}function sv(e){return[...e].reverse().find(e=>e.type===`testdrive.started`)?.ts??null}function cv(e,t){return e===null?{value:`Not run`,tone:`idle`}:t.some(t=>t.kind!==`review`&&t.status===`done`&&(t.completedAt??0)>e)?{value:`Taken`,sub:`not since`,tone:`warn`}:{value:`Taken`,tone:`ok`}}function lv(e){if(typeof e!=`object`||!e)return;let t=e.wallMs;return typeof t==`number`&&Number.isFinite(t)&&t>=0?t:void 0}function uv(e){let t=new Map,n=new Map;for(let r of e){if(!r.ticketId)continue;if(r.type===`ticket.timing`){let e=lv(r.data);e!==void 0&&n.set(r.ticketId,e)}let e=t.get(r.ticketId);e?(e.min=Math.min(e.min,r.ts),e.max=Math.max(e.max,r.ts)):t.set(r.ticketId,{min:r.ts,max:r.ts})}let r=new Map(n);for(let[e,n]of t)!r.has(e)&&n.max>n.min&&r.set(e,n.max-n.min);return r}function dv(e){return e.status===`launching`||e.status===`live`}function fv(e){return e.find(e=>dv(e)&&e.kind!==`scenario`&&e.kind!==`side`)}var pv={label:`Chat`,kind:`chat`},mv={label:`Plan it yourself`,kind:`selfPlan`},hv={loading:`Loading the branch list…`,unpicked:`pick a branch first`},gv={label:`Move to backlog`,kind:`moveToBacklog`};function _v(e){return!!e&&e.includes(`merged into different branches`)}function vv(e){let t=e.map(e=>e.slug);return t.length<2?t[0]??``:`${t.slice(0,-1).join(`, `)} and ${t.at(-1)}`}function yv(e){return`${vv(e)} ${e.length===1?`ships`:`ship`}`}function bv({full:e,ctx:t}){let n=Sg(e.dependsOn)??(t.draftBaseMissing?hv[t.draftBaseMissing]:null),r=n?{disabled:n}:{},i={label:`Start`,kind:`startDraft`,...r},a={...mv,...r},o=vg(e.dependsOn);switch(bf(e.feature,e.dependsOn)){case`blocked`:{let e=`Start when ready: starts by itself when ${yv(o)}; it can't be undone.`;return{kick:`NEXT STEP`,title:`Start this feature`,desc:`In the backlog. You can make it start by itself instead, as soon as what it waits on ships.`,primary:i,secondary:[a,{label:`Start when ready`,kind:`markUpNext`,hint:e}],busy:!1,note:e}}case`upNext`:{let t=Sf(e.dependsOn);return{kick:`UP NEXT`,...t.length>0?{title:`Won't start until you start ${vv(t)}`,desc:`${vv(t)} ${t.length===1?`is`:`are`} in the backlog, so nothing will move ${t.length===1?`it`:`them`}. It starts by itself once ${o.length===1?`${vv(o)} has shipped`:`${vv(o)} have all shipped`}.`}:{title:`Starts by itself when ${yv(o)}`,desc:`Its branch will be cut from the branch ${o.length===1?`${vv(o)} merges`:`they merge`} into. Nothing launches and no tokens are spent.`},secondary:[gv],busy:!1}}case`stuck`:return{alert:!0,kick:`NEXT STEP`,title:`Didn't start by itself`,desc:xv(e.upNextProblem??xf(e.dependsOn),e.dependsOn),primary:i,secondary:[a,gv],busy:!1};default:return{kick:`NEXT STEP`,title:`Start this feature`,desc:`In the backlog — Start cuts its branch, writes the brief, and opens the grill with you. Plan it yourself makes the plan without you.`,primary:i,secondary:[a],busy:!1}}}function xv(e,t){let n=e.replace(/^(?:didn't|couldn't) start by itself:\s*/i,``);return t.some(e=>n.startsWith(`${e.slug} `))?n:n.charAt(0).toUpperCase()+n.slice(1)}function Sv(e){let t=[...e.filter(e=>e.kind===`chat`)].reverse();return t.find(e=>e.status!==`ended`)??t[0]}function Cv(e){return e.kind===`chat`&&e.purpose===`self-plan`}function wv(e){let t=[...e].reverse().find(e=>e.type===`feature.shipped`);return t?t.ts:null}function Tv(e){let t=fv(e);return!t||Cv(t)?null:{sessionId:t.id,text:`${Ev(t)} live`}}function Ev(e){switch(e.kind){case`chat`:return`Agent`;case`drive-fix`:return`Drive fix`;case`prepare`:return`Preparation`;case`project`:return`Project`;case`scenario`:return`Scenario`;case`side`:return`Side session`}}function Dv(e){let{live:t}=e;return!t||!Cv(t)?null:{kick:`PLANNING ITSELF`,title:`Planning itself`,desc:`Planning by itself — open the thread to watch; the plan appears below as it is written.`,primary:{label:`Stop`,kind:`stopSelfPlan`},secondary:[],busy:!0}}var Ov={kick:`NEXT STEP`,secondary:[],busy:!1};function kv(e,t){let{feature:n,sessions:r}=e,i={full:e,ctx:t,live:fv(r)};return n.status===`draft`?bv(i):n.status===`archived`?{kick:`ARCHIVED`,title:`Feature archived`,desc:`This feature is archived and out of the pipeline. Unarchive it to pick the work back up.`,primary:{label:`Unarchive`,kind:`unarchive`},secondary:[],busy:!1}:Dv(i)??Ov}var Av=[`planning`,`building`,`review`,`shipped`],jv={planning:`Shape the feature, write its spec, and emit tickets`,building:`Agents implement each ticket in a sandbox`,review:`Test-drive the branch, plan more work, or merge`,shipped:`Merged to main`};function Mv(e){return e?.devUrl?e.devReady?{url:e.devUrl,state:`ready`}:{url:e.devUrl,state:e.devReadyTimedOut?`timedOut`:`starting`}:null}function Nv(e){return e.state===`timedOut`?`${e.url} — not answering`:`starting… ${e.url}`}function Pv(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function Fv(e,t={}){let n=e?.hookFailure;return n?{command:n.command,outcome:n.timedOut?`timed out`:`exited ${n.exitCode??`without a code`}`,output:n.output,canFix:!t.sessionLive}:null}var Iv=[`ticket.retry`,`burn.started`,`feature.shipped`];function Lv(e,t=[],n){let r=null;for(let t of e)if(t.type===`reviewdrive.denied`){let e=t.data??{};r={eventId:t.id,dirtyFiles:Array.isArray(e.dirtyFiles)?e.dirtyFiles.filter(e=>typeof e==`string`):[],message:t.message,at:t.ts}}else Iv.includes(t.type)&&(r=null);return!r||r.eventId===n||r.at<Math.max(...t.map(e=>e.startedAt),-1/0)?null:r}var Rv=e=>({showDevChip:e,showBranch:e,showOutput:e}),zv={idle:{barTitle:`Review the build`,barDesc:`Open the app when you are ready to test it.`,primary:`start`,stageKind:`player`,footer:Rv(!1)},starting:{barTitle:`Starting the test drive`,barDesc:`Preparing the branch and development server.`,primary:`stop`,stageKind:`starting`,footer:Rv(!0)},serving:{barTitle:`Test-driving the branch — merge when it looks right`,barDesc:`The development server is ready.`,primary:`stop`,stageKind:`panel`,footer:Rv(!0)},"bare-checkout":{barTitle:`Branch checked out for inspection`,barDesc:`Branch checked out — nothing started. This project has no dev command · Set one in Settings`,primary:`stop`,stageKind:`bare`,footer:Rv(!0)},"setup-failed":{barTitle:`Drive setup failed — fix it or stop the drive`,barDesc:`The project setup command did not complete.`,primary:`fixDrive`,stageKind:`failed`,footer:Rv(!0)},"review-agent-driving":{barTitle:`Review agent driving`,barDesc:`review agent driving — notes land below as it finds things`,primary:`stop`,stageKind:`agent`,footer:Rv(!0)}};function Bv(e,t={}){return zv[e]}function Vv(e,t){if(!t)return;let n=[...e].reverse().find(e=>e.runId===t&&(e.type===`burn.image_build_started`||e.type===`burn.image_built`||e.type===`burn.image_build_failed`));if(n?.type!==`burn.image_build_started`)return;let{need:r}=n.data??{};return r===`missing`||r===`unadopted`?`Building the sandbox image · first time only, a few minutes`:`Rebuilding the sandbox image · a few minutes`}var Hv=e=>e.error?.toLowerCase().startsWith(`stopped`)||e.orphaned||e.error?.toLowerCase().includes(`orphaned`),Uv=(e=``)=>/\b(?:git|docker|podman|mount|sandbox)\b/i.test(e);function Wv(e){return e.status===`cancelled`?`waived`:e.status===`failed`?Hv(e)?`stopped`:e.hadOutput===!1&&Uv(e.error??``)?`launch-failed`:`failed`:e.status===`done`?`done`:e.status===`burning`||e.status===`running`?`burning`:`pending`}var Gv=/<promise>\s*COMPLETE\s*<\/promise>/i,Kv=new RegExp(Gv,`gi`);function qv(e){return e.replace(Kv,``).replace(/\n{3,}/g,`
|
|
74
|
-
|
|
75
|
-
`).trim()}function Jv(e){return Gv.test(e)}function Yv(e){return e.replace(/^.*?(?:\/|\\)repo(?:\/|\\)/,``)}var Xv=/[^\s"'`,)]*[/\\]repo[/\\][^\s"'`,)]*/g;function Zv(e){return e.replace(Xv,Yv)}function Qv(e){let t=[];for(let n of e){if(n.kind===`tool`){t.push({kind:`tool`,name:n.name??`tool`,args:$v(n.text)});continue}let e=t[t.length-1];e&&e.kind===`text`?e.text+=n.text:t.push({kind:`text`,text:n.text})}let n=!1;return{blocks:t.map(e=>e.kind===`text`?(Jv(e.text)&&(n=!0),{...e,text:qv(e.text)}):e).filter(e=>e.kind!==`text`||e.text.length>0),completed:n}}function $v(e){let t=Zv(e.replace(/\s+/g,` `).trim());return t.length>300?`${t.slice(0,300)}…`:t}function ey(e){let t=new Map;for(let n of e){if(!n.ticketId)continue;let e=t.get(n.ticketId),r=n.type===`burn.text`||n.type===`burn.tool`;e?r&&(e.hadOutput=!0):t.set(n.ticketId,{hadOutput:r,startedAt:n.ts})}return t}function ty(e){return[...e].sort((e,t)=>(e.completedAt??-1/0)-(t.completedAt??-1/0)||e.seq-t.seq).at(-1)}function ny(e,t){return ty(e.filter(e=>{if(e.completedAt!==null)return!0;let n=t.find(t=>t.id===e.ticketId)?.status;return n===`done`||n===`failed`}))??null}function ry(e,t,n){if(n?.state===`running`)return{tone:`verifying`,text:`Verification running — evidence below predates it`};if(n?.state===`failed`){let e=n.reason?.trim();return{tone:`failed`,text:`verification could not run${e?`: ${e}`:``}`}}return e?t.landedSince===0?{tone:`fresh`,text:`Reviewed ✓ · this build`}:{tone:`stale`,text:`Reviewed earlier · ${t.landedSince} tickets landed since — evidence may be outdated`}:{tone:`none`,text:`no review yet`}}function iy(e){let t=e.filter(e=>e.kind===`review`&&e.passKind===`verification`).at(-1);if(t){if(t.status===`failed`)return{state:`failed`,...t.error?{reason:t.error}:{}};if(!(t.status===`done`||t.status===`cancelled`))return{state:`running`}}}function ay(e){let[t]=(e??``).trim().split(`
|
|
76
|
-
`);return t?.trim()||null}function oy(e,t){if(!e)return{kind:`none`};let n=t.find(t=>t.id===e.ticketId);if(n?.status===`failed`)return{kind:`could-not-run`};if(e.reviewVerdict===`verified`)return{kind:`verified`,mode:e.reviewMode};if(e.reviewVerdict===`unverified`){let t=ay(n?.digest),r=e.reviewVerdictReason?.trim()||null;return{kind:`unverified`,line:t,reason:t&&r&&t.includes(r)?null:r}}return{kind:`none`}}function sy(e){let t=cy(e);return t.kind===`unverified`?t:null}function cy(e){let t=e.tickets??[];return oy(ny(e.passes??[],t),t)}var ly=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function uy(e){let t=e.filter(e=>e.kind!==`review`&&e.status!==`cancelled`);return{done:t.filter(e=>e.status===`done`).length,total:t.length}}function dy(e){let t=e.filter(e=>e.status!==`cancelled`);return t.length===0?0:t.filter(e=>e.status===`done`).length/t.length}function fy({done:e,total:t}){return`${e} of ${t} ${t===1?`ticket`:`tickets`} done`}function py(e,t){let n=e.model?.trim();if(!n)return null;let{runtime:r}=Td(n,{discovered:[],models:t});return{id:n,runtime:r,runtimeLabel:Bm[r]}}function my(e){return e.docs.find(e=>e.relPath.endsWith(`spec.md`))?.relPath}function hy(e){return e&&gy(e)[`Later laps`]?.trim()||null}function gy(e){let t={},n=null,r=[],i=()=>{n!==null&&(t[n]=r.join(`
|
|
77
|
-
`)),r.length=0};for(let t of e.split(`
|
|
78
|
-
`)){let e=t.match(/^##\s+(.+?)\s*$/);e?(i(),n=e[1]):n!==null&&r.push(t)}return i(),t}var _y=180;function vy(e){let t=e.replace(/\s+/g,` `).trim();return t.length>_y?`${t.slice(0,_y).trimEnd()}…`:t}function yy(e){let t=`what lands`;if(e?.commits===void 0)return{key:t,value:`scale unknown`,tone:`warn`};let n=e.files===void 0?[]:[ly(e.files,`file`)];return{key:t,value:[ly(e.commits,`commit`),...n].join(` · `),tone:e.commits>0?`ok`:`warn`}}function by(e){let t=e.filter(e=>e.kind!==`review`);if(t.length===0)return{key:`run`,value:`no tickets burned`,tone:`warn`};let n=t.filter(e=>e.status===`done`).length,r=t.filter(e=>e.status===`cancelled`).length,i=t.filter(e=>e.status===`failed`).length,a=[`${n}/${t.length} tickets done`];return r>0&&a.push(`${r} waived`),i>0&&a.push(`${i} failed`),{key:`run`,value:a.join(` · `),tone:n===t.length?`ok`:`warn`}}function xy(e){switch(e.tone){case`fresh`:return null;case`none`:return`No review has run on this branch — nothing was checked for you.`;case`verifying`:return`A verification pass is still running — this summary predates it.`;case`failed`:return`The review evidence is not fresh: ${e.text}.`;case`stale`:return`${e.text}.`}}function Sy(e){let t=e.tickets??[],n=cv(e.drivenAt,t),r={key:`test drive`,value:n.sub?`${n.value} · ${n.sub}`:n.value,tone:n.tone===`ok`?`ok`:`warn`},i={key:`review`,value:e.freshness.text,tone:e.freshness.tone===`fresh`?`ok`:`warn`},a=[];e.burning&&a.push(`A round is running — work landing after this merge stays unshipped on the branch.`),e.projectDrive&&a.push(`${Pv(e.projectDrive.holderLabel)} is running on your checkout — merging stops it.`);let o=e.openNotes??0;o>0&&a.push(`${ly(o,`open test-drive note`)}.`);let s=t.filter(e=>e.kind!==`review`&&e.status===`cancelled`).length;s>0&&a.push(`${ly(s,`ticket`)} waived — set aside unfinished, not delivered.`);let c=t.filter(e=>e.kind!==`review`&&e.status===`pending`).length;c>0&&a.push(`${ly(c,`unburned ticket`)} — merging leaves them behind.`);let l=xy(e.freshness);return l&&a.push(l),e.laterLaps&&a.push(`The spec still lists deferred scope: ${vy(e.laterLaps)}`),{conflictRow:e.conflict?`⚠ A merge conflict is standing (${e.conflict.files.join(`, `)||e.conflict.base}) — this merge will fail unless it’s been resolved.`:null,rows:[yy(e.delta),by(t),r,i],warnings:a,next:`Merges ${e.branch} into ${e.base??`its base branch`}, writes the outcome doc, and moves the feature to Shipped.`}}function Cy(e){return!e||!dv(e)?`none`:e.status===`launching`?`launching`:`live`}function wy(e,t){if(!e)return null;let n=e.stored?t&&!t.includes(e.stored)?`vanished`:`picked`:`detected`;return{value:e.effective,origin:n}}function Ty(e){return e.creating?`create`:e.preparing?`prepare`:e.projectSelected?`project`:e.selectedFeatureId?`feature`:e.featureCount===0&&!e.prepared&&!e.empty?`prepare`:`project`}var Ey=`preparation prepare re-prepare reprepare redo re-run rerun again findings evidence stale project commands baseline secrets database`,Dy=`orchestrator project chat talk ask conversation conversations idea intake discuss advice new chat`;function Oy(e,t){return t===``||e.includes(t)}function ky(e){return Oy(Ey,e)}function Ay(e){return Oy(Dy,e)}function jy(e){if(!e)return null;let{prepared:t,pendingCount:n,staleCount:r}=e;return t?{variant:`done`,count:n,stale:r,label:`Re-prepare the project`,badge:r>0?`${r} stale`:null,title:r>0?`${r} established fact${r===1?` has`:`s have`} not been re-measured in a long time`:`See what was established about this repo, or establish it again`}:{variant:`todo`,count:n,stale:r,label:`Prepare this project`,badge:n>0?`${n} to establish`:null,title:`${n} repo fact${n===1?``:`s`} nobody has established yet — how to install, how to verify, what is already red`}}function K({size:e=16,...t}){return{width:e,height:e,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,...t}}function My(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.5`}),(0,I.jsx)(`path`,{d:`M10.5 10.5 L14 14`})]})}function Ny(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M6.28 3.52L6.43 1.69A6.5 6.5 0 0 1 9.57 1.69L9.72 3.52A4.8 4.8 0 0 1 11.02 4.27L12.68 3.48A6.5 6.5 0 0 1 14.25 6.21L12.74 7.25A4.8 4.8 0 0 1 12.74 8.75L14.25 9.79A6.5 6.5 0 0 1 12.68 12.52L11.02 11.73A4.8 4.8 0 0 1 9.72 12.48L9.57 14.31A6.5 6.5 0 0 1 6.43 14.31L6.28 12.48A4.8 4.8 0 0 1 4.98 11.73L3.32 12.52A6.5 6.5 0 0 1 1.75 9.79L3.26 8.75A4.8 4.8 0 0 1 3.26 7.25L1.75 6.21A6.5 6.5 0 0 1 3.32 3.48L4.98 4.27A4.8 4.8 0 0 1 6.28 3.52Z`}),(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`2`})]})}function Py(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`rect`,{x:`1.8`,y:`2.8`,width:`12.4`,height:`10.4`,rx:`1.6`}),(0,I.jsx)(`path`,{d:`M10.2 2.8v10.4`})]})}function Fy(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`circle`,{cx:`4.5`,cy:`3.8`,r:`1.7`}),(0,I.jsx)(`circle`,{cx:`4.5`,cy:`12.2`,r:`1.7`}),(0,I.jsx)(`circle`,{cx:`11.5`,cy:`5`,r:`1.7`}),(0,I.jsx)(`path`,{d:`M4.5 5.5v5M11.5 6.7c0 2.6-3 3-5.4 3.6`})]})}function Iy(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M8 2a4 4 0 0 0-4 4v2.6L2.8 11h10.4L12 8.6V6a4 4 0 0 0-4-4Z`}),(0,I.jsx)(`path`,{d:`M6.5 13.4a1.6 1.6 0 0 0 3 0`})]})}function Ly(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M5.2 3.2A4 4 0 0 1 12 6v2.6L13.2 11H6.5M4 6.5V8.6L2.8 11h2.4`}),(0,I.jsx)(`path`,{d:`M6.5 13.4a1.6 1.6 0 0 0 3 0`}),(0,I.jsx)(`path`,{d:`M2 2l12 12`})]})}function Ry(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M8 3.2v9.6M3.2 8h9.6`})})}function zy(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`m3 8.4 3.2 3.2L13 5`})})}function By(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`m4 4 8 8M12 4l-8 8`})})}function Vy(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M3 4.5h10M6.5 4.5V3h3v1.5M4.5 4.5l.6 8.5h5.8l.6-8.5`})})}function Hy(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M5 6h5a3 3 0 0 1 0 6H7`}),(0,I.jsx)(`path`,{d:`M7 3.5 4.5 6 7 8.5`})]})}function Uy(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`m4 6 4 4 4-4`})})}function Wy(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`m6 4 4 4-4 4`})})}function Gy(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`circle`,{cx:`3.2`,cy:`8`,r:`1.1`,fill:`currentColor`,stroke:`none`}),(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.1`,fill:`currentColor`,stroke:`none`}),(0,I.jsx)(`circle`,{cx:`12.8`,cy:`8`,r:`1.1`,fill:`currentColor`,stroke:`none`})]})}function Ky(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`rect`,{x:`1.8`,y:`2.8`,width:`12.4`,height:`10.4`,rx:`1.6`}),(0,I.jsx)(`path`,{d:`m4.5 6.2 2.3 2-2.3 2M8.5 10.4h3`})]})}function qy(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M2 4.4a1.6 1.6 0 0 1 1.6-1.6h8.8A1.6 1.6 0 0 1 14 4.4v5.2a1.6 1.6 0 0 1-1.6 1.6H6.4L3.2 14v-2.8A1.6 1.6 0 0 1 2 9.6z`})})}function Jy(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M4 1.8h5.2L13 5.6v8.6H4z`}),(0,I.jsx)(`path`,{d:`M9 2v3.8h3.8M6 8.4h4M6 10.8h4`})]})}function Yy(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M10.6 2.4a1.7 1.7 0 0 1 2.4 2.4L5.5 12.3 2.4 13.1l.8-3.1z`}),(0,I.jsx)(`path`,{d:`M9.4 3.6l2.4 2.4`})]})}function Xy(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M1.8 8h2.6l1.8-4.4 2.8 8.8L10.8 8h3.4`})})}function Zy(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M4 4.5 6.5 7M12 4.5 9.5 7M8 10.5v2.25`,opacity:.7}),(0,I.jsx)(`circle`,{cx:`8`,cy:`8.5`,r:`2`}),(0,I.jsx)(`circle`,{"data-node":!0,cx:`3`,cy:`3.5`,r:`1.25`}),(0,I.jsx)(`circle`,{"data-node":!0,cx:`13`,cy:`3.5`,r:`1.25`}),(0,I.jsx)(`circle`,{"data-node":!0,cx:`8`,cy:`14`,r:`1.25`})]})}function Qy(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M1.8 4.2c0-.8.6-1.4 1.4-1.4h3l1.4 1.7h5.2c.8 0 1.4.6 1.4 1.4v6.5c0 .8-.6 1.4-1.4 1.4H3.2c-.8 0-1.4-.6-1.4-1.4z`})})}function $y(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M8 1.6l5.4 3v6.8L8 14.4l-5.4-3V4.6z`}),(0,I.jsx)(`path`,{d:`M8 7.6l5.4-3M8 7.6L2.6 4.6M8 7.6v6.8`})]})}function eb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M8 14.4c2.7 0 4.7-2 4.7-4.7 0-2-1.3-3.4-2-4.7-.7 1.3-1.3 2-2 2 0-2-.7-4-2.7-5.4 0 2.7-2.7 4-2.7 8.1 0 2.7 2 4.7 4.7 4.7z`})})}function tb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`rect`,{x:`3.4`,y:`7.2`,width:`9.2`,height:`6.6`,rx:`1.3`}),(0,I.jsx)(`path`,{d:`M5.6 7.2V5a2.4 2.4 0 0 1 4.8 0v2.2`})]})}function nb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M2.5 8h11M9.5 4l4 4-4 4`})})}function rb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M14 2 7.2 8.8M14 2 9.6 14l-2.4-5.2L2 6.4z`})})}function ib(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M5 3.2v9.6L13 8z`,fill:`currentColor`,stroke:`none`})})}function ab(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`rect`,{x:`4`,y:`4`,width:`8`,height:`8`,rx:`1.2`,fill:`currentColor`,stroke:`none`})})}function ob(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M8 1.8 13 3.6v4.2c0 3.2-2.1 5.3-5 6.4-2.9-1.1-5-3.2-5-6.4V3.6z`})})}function sb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M8 1.8 9.4 6l4.2 1.4L9.4 8.8 8 13 6.6 8.8 2.4 7.4 6.6 6z`})})}function cb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M8 2.4v11.2M3.2 5.2l9.6 5.6M12.8 5.2l-9.6 5.6`})})}function lb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M5.6 4.8 2.4 8l3.2 3.2M10.4 4.8 13.6 8l-3.2 3.2`})})}function ub(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M1.8 9.2 3.5 3.6c.2-.5.6-.8 1.1-.8h6.8c.5 0 .9.3 1.1.8l1.7 5.6v3.4c0 .7-.5 1.2-1.2 1.2H3c-.7 0-1.2-.5-1.2-1.2z`}),(0,I.jsx)(`path`,{d:`M1.8 9.2h3.4l1 1.8h3.6l1-1.8h3.4`})]})}function db(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`rect`,{x:`1.8`,y:`2.8`,width:`12.4`,height:`3.2`,rx:`1`}),(0,I.jsx)(`path`,{d:`M3 6v6.2c0 .7.5 1.2 1.2 1.2h7.6c.7 0 1.2-.5 1.2-1.2V6M6.5 8.8h3`})]})}function fb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`rect`,{x:`1.8`,y:`2.8`,width:`12.4`,height:`10.4`,rx:`1.6`}),(0,I.jsx)(`path`,{d:`M5.8 2.8v10.4`})]})}function pb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`circle`,{cx:`4.5`,cy:`3.8`,r:`1.7`}),(0,I.jsx)(`circle`,{cx:`4.5`,cy:`12.2`,r:`1.7`}),(0,I.jsx)(`circle`,{cx:`11.5`,cy:`9.6`,r:`1.7`}),(0,I.jsx)(`path`,{d:`M4.5 5.5v5M4.5 5.5c0 2.6 2.4 4.1 5.3 4.1`})]})}function mb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M9.5 2.5h4v4M13.5 2.5 7.5 8.5`}),(0,I.jsx)(`path`,{d:`M12 9.5v3a1.5 1.5 0 0 1-1.5 1.5h-7A1.5 1.5 0 0 1 2 12.5v-7A1.5 1.5 0 0 1 3.5 4h3`})]})}function hb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`rect`,{x:`5.5`,y:`5.5`,width:`8.5`,height:`8.5`,rx:`1.5`}),(0,I.jsx)(`path`,{d:`M10.5 5.5v-2A1.5 1.5 0 0 0 9 2H3.5A1.5 1.5 0 0 0 2 3.5V9a1.5 1.5 0 0 0 1.5 1.5h2`})]})}function gb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`2.8`}),(0,I.jsx)(`path`,{d:`M8 1.5v1.3M8 13.2v1.3M1.5 8h1.3M13.2 8h1.3M3.4 3.4l.9.9M11.7 11.7l.9.9M12.6 3.4l-.9.9M4.3 11.7l-.9.9`})]})}function _b(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M13.5 9.6A5.8 5.8 0 0 1 6.4 2.5a5.8 5.8 0 1 0 7.1 7.1z`})})}function vb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`rect`,{x:`1.8`,y:`2.5`,width:`12.4`,height:`8.5`,rx:`1.4`}),(0,I.jsx)(`path`,{d:`M5.5 14h5M8 11v3`})]})}function yb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M2.5 7 8 2.5 13.5 7v5.8c0 .7-.5 1.2-1.2 1.2H3.7c-.7 0-1.2-.5-1.2-1.2z`}),(0,I.jsx)(`path`,{d:`M6.3 14v-3.8h3.4V14`})]})}function bb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M5.8 4h7.7M5.8 8h7.7M5.8 12h7.7`}),(0,I.jsx)(`circle`,{cx:`2.8`,cy:`4`,r:`.9`,fill:`currentColor`,stroke:`none`}),(0,I.jsx)(`circle`,{cx:`2.8`,cy:`8`,r:`.9`,fill:`currentColor`,stroke:`none`}),(0,I.jsx)(`circle`,{cx:`2.8`,cy:`12`,r:`.9`,fill:`currentColor`,stroke:`none`})]})}function xb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`}),(0,I.jsx)(`path`,{d:`M8 4.8V8l2.2 1.4`})]})}function Sb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M7.1 2.8a1 1 0 0 1 1.8 0l5.4 9.6a1 1 0 0 1-.9 1.5H2.6a1 1 0 0 1-.9-1.5z`}),(0,I.jsx)(`path`,{d:`M8 6.4v3`}),(0,I.jsx)(`circle`,{cx:`8`,cy:`11.5`,r:`.85`,fill:`currentColor`,stroke:`none`})]})}function Cb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`}),(0,I.jsx)(`path`,{d:`M8 7.4V11`}),(0,I.jsx)(`circle`,{cx:`8`,cy:`5.1`,r:`.85`,fill:`currentColor`,stroke:`none`})]})}function wb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M13.5 8h-11M6.5 4l-4 4 4 4`})})}function Tb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`m4 10 4-4 4 4`})})}function Eb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M1.5 8S3.9 3.5 8 3.5 14.5 8 14.5 8 12.1 12.5 8 12.5 1.5 8 1.5 8z`}),(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`2`})]})}function Db(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M13.2 6.4A5.3 5.3 0 0 0 3.4 5.1M2.8 9.6a5.3 5.3 0 0 0 9.8 1.3`}),(0,I.jsx)(`path`,{d:`M13.5 2.8v3.7H9.8M2.5 13.2V9.5h3.7`})]})}function Ob(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`circle`,{cx:`8`,cy:`5.5`,r:`2.7`}),(0,I.jsx)(`path`,{d:`M2.8 13.8c.6-2.6 2.8-4.2 5.2-4.2s4.6 1.6 5.2 4.2`})]})}function kb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`3`,fill:`currentColor`,stroke:`none`})})}function Ab(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`rect`,{x:`4`,y:`3.5`,width:`2.5`,height:`9`,rx:`0.8`,fill:`currentColor`,stroke:`none`}),(0,I.jsx)(`rect`,{x:`9.5`,y:`3.5`,width:`2.5`,height:`9`,rx:`0.8`,fill:`currentColor`,stroke:`none`})]})}function jb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M9.5 2.5h4v4M6.5 13.5h-4v-4M13.5 2.5 9.5 6.5M2.5 13.5l4-4`})})}function Mb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M13.5 6.5h-4v-4M2.5 9.5h4v4M9.5 6.5l4-4M6.5 9.5l-4 4`})})}function Nb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M8 2.5v7.5M4.800 7 8 10.200 11.200 7M3 13.500h10`})})}function Pb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`rect`,{x:`2.5`,y:`3`,width:`11`,height:`10`,rx:`1.5`}),(0,I.jsx)(`circle`,{cx:`6`,cy:`6.5`,r:`1`}),(0,I.jsx)(`path`,{d:`m3 12 3.5-3.5 2.5 2.5 1.5-1.5L13 12`})]})}function Fb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M12.5 7.5 7.75 12.25a2.75 2.75 0 0 1-3.9-3.9l5.3-5.3a1.85 1.85 0 0 1 2.6 2.6l-5.15 5.15a.9.9 0 0 1-1.3-1.3L9.75 5`})})}function Ib(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`circle`,{cx:`4.5`,cy:`3.5`,r:`1.5`}),(0,I.jsx)(`circle`,{cx:`4.5`,cy:`12.5`,r:`1.5`}),(0,I.jsx)(`circle`,{cx:`11.5`,cy:`6`,r:`1.5`}),(0,I.jsx)(`path`,{d:`M4.5 5v6M11.5 7.5c0 2-2 2.5-4 3l-1.6.6`})]})}function Lb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M2.5 13.5c2-1 3-3.5 5-3.5s2 2 4 1.5 2.5-3 2.5-3`})})}function Rb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M3 13 13 3M7 3h6v6`})})}function zb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`rect`,{x:`2.5`,y:`4`,width:`11`,height:`8`,rx:`1`})})}function Bb(e){return(0,I.jsxs)(`svg`,{...K(e),children:[(0,I.jsx)(`path`,{d:`M11 6H6a3 3 0 0 0 0 6h3`}),(0,I.jsx)(`path`,{d:`M9 3.5 11.5 6 9 8.5`})]})}function Vb(e){return(0,I.jsx)(`svg`,{...K(e),children:(0,I.jsx)(`path`,{d:`M2.5 5V3.5a1 1 0 0 1 1-1H5M11 2.5h1.5a1 1 0 0 1 1 1V5M13.5 11v1.5a1 1 0 0 1-1 1H11M5 13.5H3.5a1 1 0 0 1-1-1V11`})})}var Hb={draft:`text-phase-draft`,ideation:`text-phase-ideation`,spec:`text-phase-spec`,planning:`text-phase-planning`,tickets:`text-phase-tickets`,implementation:`text-phase-implementation`,building:`text-phase-building`,review:`text-phase-review`,shipped:`text-phase-shipped`},Ub={draft:`Backlog`,ideation:`Ideation`,spec:`Spec`,planning:`Planning`,tickets:`Tickets`,implementation:`Build`,building:`Build`,review:`Review`,shipped:`Shipped`},Wb={draft:0,ideation:0,spec:25,planning:25,tickets:50,implementation:75,building:75,review:0,shipped:100},Gb=`var(--dur-3) var(--ease-app)`;function Kb({phase:e,size:t=16,label:n,className:r}){let i=`phase-check-${(0,F.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,a=Wb[e];return(0,I.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,role:n===``?void 0:`img`,"aria-label":n===``?void 0:n??Ub[e],"aria-hidden":n===``||void 0,"data-phase":e,className:[`inline-block shrink-0 transition-colors duration-(--dur-3) ease-app`,Hb[e],r].filter(Boolean).join(` `),children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`mask`,{id:i,children:[(0,I.jsx)(`rect`,{width:`16`,height:`16`,fill:`white`}),(0,I.jsx)(`path`,{d:`M5.2 8.2 7 10l3.8-3.8`,fill:`none`,stroke:`black`,strokeWidth:1.6,strokeLinecap:`round`,strokeLinejoin:`round`})]})}),(0,I.jsxs)(`g`,{mask:e===`shipped`?`url(#`+i+`)`:void 0,children:[(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,strokeDasharray:e===`draft`?`2.2 2.2`:void 0}),(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`2`,strokeWidth:4,pathLength:100,transform:`rotate(-90 8 8)`,style:{strokeDasharray:`${a} 100`,transition:`stroke-dasharray ${Gb}`}}),(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`2.5`,fill:`currentColor`,stroke:`none`,style:{opacity:+(e===`review`),transition:`opacity ${Gb}`}}),(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`7`,fill:`currentColor`,stroke:`none`,style:{opacity:+(e===`shipped`),transition:`opacity ${Gb}`}})]})]})}var qb={draft:`text-phase-draft`,active:`text-text-tertiary`,shipped:`text-phase-shipped`};function Jb({state:e,progress:t=0,size:n=16,label:r,className:i}){let a=`progress-check-${(0,F.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,o=e===`active`?Math.round(Math.min(1,Math.max(0,t))*100):0,s=e===`draft`?`Backlog`:e===`shipped`?`Shipped`:`${o}% landed`;return(0,I.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,role:r===``?void 0:`img`,"aria-label":r===``?void 0:r??s,"aria-hidden":r===``||void 0,className:[`inline-block shrink-0 transition-colors duration-(--dur-3) ease-app`,qb[e],i].filter(Boolean).join(` `),children:[(0,I.jsx)(`defs`,{children:(0,I.jsxs)(`mask`,{id:a,children:[(0,I.jsx)(`rect`,{width:`16`,height:`16`,fill:`white`}),(0,I.jsx)(`path`,{d:`M5.2 8.2 7 10l3.8-3.8`,fill:`none`,stroke:`black`,strokeWidth:1.6,strokeLinecap:`round`,strokeLinejoin:`round`})]})}),(0,I.jsxs)(`g`,{mask:e===`shipped`?`url(#`+a+`)`:void 0,children:[(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,strokeDasharray:e===`draft`?`2.2 2.2`:void 0}),(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`2`,strokeWidth:4,pathLength:100,transform:`rotate(-90 8 8)`,style:{strokeDasharray:`${o} 100`,transition:`stroke-dasharray ${Gb}`}}),(0,I.jsx)(`circle`,{cx:`8`,cy:`8`,r:`7`,fill:`currentColor`,stroke:`none`,style:{opacity:+(e===`shipped`),transition:`opacity ${Gb}`}})]})]})}var Yb=`M4 29 V6 H10 V11 H13 V6 H19 V11 H22 V6 H28 V29 H4 Z M12.5 15 L21.5 20 L12.5 25 Z`;function Xb({size:e=16,variant:t=`mono`,...n}){let r=t===`solid`?`var(--color-text)`:t===`mono`?`currentColor`:t===`ink`?`var(--color-on-primary)`:`none`;return(0,I.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 32 32`,fill:`none`,"aria-hidden":!0,...n,children:(0,I.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:Yb,fill:r,stroke:t===`outline`?`var(--color-border-strong)`:`none`,strokeWidth:t===`outline`?1.5:0,strokeLinejoin:`miter`})})}var Zb=(0,F.createContext)(null),Qb=`flex cursor-pointer items-start gap-2.5 animate-toast-in rounded-lg bg-surface-raised px-3 py-2.5 text-sm break-words text-text shadow-popover`,$b={error:(0,I.jsx)(Sb,{size:16,className:`mt-0.5 shrink-0 text-danger`}),success:(0,I.jsx)(zy,{size:16,className:`mt-0.5 shrink-0 text-success`}),info:(0,I.jsx)(Cb,{size:16,className:`mt-0.5 shrink-0 text-icon`})},ex=null;function tx(e,t=`error`){ex?.(e,t)}function nx({children:e}){let[t,n]=(0,F.useState)([]),r=(0,F.useCallback)((e,t=`error`)=>{let r=Date.now()+Math.random();n(n=>[...n,{id:r,kind:t,message:e}]),setTimeout(()=>n(e=>e.filter(e=>e.id!==r)),6e3)},[]);return(0,F.useEffect)(()=>(ex=r,()=>{ex===r&&(ex=null)}),[r]),(0,I.jsxs)(Zb.Provider,{value:{push:r},children:[e,(0,I.jsx)(`div`,{className:`fixed right-4 bottom-4 z-[400] flex max-w-95 flex-col items-end gap-2`,role:`status`,"aria-live":`polite`,children:t.map(e=>(0,I.jsxs)(`div`,{"data-kind":e.kind,className:Qb,onClick:()=>n(t=>t.filter(t=>t.id!==e.id)),children:[$b[e.kind],(0,I.jsx)(`span`,{className:`min-w-0`,children:e.message})]},e.id))})]})}function rx(){let e=(0,F.useContext)(Zb);if(!e)throw Error(`useToast used outside ToastProvider`);return e}function ix(e){let t=R.useUtils(),n=rx(),r=R.project.projectSession.useQuery({projectId:e},{refetchInterval:tg()}),i=R.project.talkToProject.useMutation({onSuccess:()=>{t.project.projectSession.invalidate(),t.thread.list.invalidate({projectId:e})},onError:e=>n.push(e.message)}),a=r.data??null;return{session:a,state:Cy(a),triage:t=>{i.isPending||i.mutate({projectId:e,purpose:`triage`},{onSuccess:({sessionId:e})=>t(e)})},triaging:i.isPending}}async function ax(e,t){let n=await fetch(vf(e),{method:`POST`,headers:{"content-type":`image/png`},body:t});if(!n.ok)throw Error(`screenshot upload: ${n.status}`)}function ox(e){return(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`j`}var sx=`project-drive`;function cx(e,t){return!!(e?.projectDrive&&e.projectId===t)}function lx({empty:e,setupCommand:t,devCommand:n,drive:r,projectId:i}){return e?{state:`hidden`}:cx(r,i)?{state:`running`}:!t?.trim()&&!n?.trim()?{state:`prepare`}:r?{state:`blocked`,reason:`${Pv(r.holderLabel)} is running`}:{state:`ready`}}function ux(e,t){let n=e.filter(e=>e.status===`open`).sort((e,t)=>t.createdAt-e.createdAt);return t===void 0?{thisDrive:[],alreadyOpen:n}:{thisDrive:n.filter(e=>e.createdAt>=t),alreadyOpen:n.filter(e=>e.createdAt<t)}}function dx(e){return e.driveBranch?{label:`drive · ${e.driveBranch}`,title:e.driveCommit?`noted while driving ${e.driveBranch} @ ${e.driveCommit}`:`noted while driving ${e.driveBranch}`}:null}var fx=(0,F.createContext)(()=>{}),px=fx.Provider;function mx(e,t){return t.featureId===e?t.view:`chat`}function hx(e){let t=(0,F.useContext)(fx);return(0,F.useCallback)(()=>t(e),[t,e])}function gx(e){return`Scenario chat · ${e.kind===`fix`?`Fix ${e.name}`:`New scenario`}`}var _x=`New chat`,vx=`unstarted`;function yx(e,t){return[...e].filter(e=>e.role===t).sort((e,t)=>t.updatedAt-e.updatedAt)[0]?.id??null}function bx(e,t,n,r=Date.now()){return{id:e,title:t,role:n,state:`idle`,createdAt:r,updatedAt:r,runtime:`claude-code`}}function xx(e,t){return[...e,...t.filter(t=>!e.some(e=>e.id===t.id))]}var Sx=(0,F.createContext)(null),Cx=(0,F.createContext)(()=>{});function wx({children:e}){let[t,n]=(0,F.useState)(null);return(0,I.jsx)(Cx.Provider,{value:n,children:(0,I.jsx)(Sx.Provider,{value:t,children:e})})}function Tx(e){let t=(0,F.useContext)(Cx);(0,F.useEffect)(()=>{t(e)}),(0,F.useEffect)(()=>()=>t(null),[t])}function Ex(){return(0,F.useContext)(Sx)}function Dx(e){return[...e].sort((e,t)=>{let n=Number(t.role===`main`)-Number(e.role===`main`);return n===0?t.createdAt-e.createdAt:n})}function Ox(e,t){return t.filter(t=>t.heldBy===e&&(t.status===`active`||t.status===`draft`&&t.upNext))}function kx(e,{current:t,features:n,now:r}){return e.state!==`idle`||e.id===t||Ox(e.id,n).length>0||e.lastHumanAt!==void 0&&r-e.lastHumanAt<864e5}function Ax(e,t,n){if(!e.some(e=>e.role===`project`))return{kind:`none`};let r=yx(e.filter(e=>kx(e,{current:null,features:t,now:n})),`project`);return r?{kind:`chat`,threadId:r}:{kind:`conversations`}}function jx(e,t){return e.status===`shipped`||!e.heldBy?null:t.find(t=>t.id===e.heldBy)??null}var Mx=`runcastle.sidebar.foldedThreads`;function Nx(e){return`featureId`in e?e.featureId:`orchestrator:${e.projectId}`}function Px(){try{let e=JSON.parse(localStorage.getItem(Mx)??`[]`);return new Set(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])}catch{return new Set}}function Fx(){let[e,t]=(0,F.useState)(Px);return{folded:t=>e.has(t),toggle:(0,F.useCallback)(e=>{t(t=>{let n=new Set(t);n.delete(e)||n.add(e);try{localStorage.setItem(Mx,JSON.stringify([...n]))}catch{}return n})},[])}}var Ix=`(max-width: 767px), (max-height: 499px)`;function Lx(){try{return globalThis.matchMedia?.(Ix)}catch{return}}function Rx(e){let t=Lx();return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)}function zx(){return(0,F.useSyncExternalStore)(Rx,()=>Lx()?.matches??!1,()=>!1)}var Bx=l(Tt(),1);function q(...e){return e.filter(Boolean).join(` `)}var Vx=`z-[300] overflow-y-auto overscroll-contain rounded-lg bg-surface-raised text-sm text-text shadow-popover animate-pop-in`,Hx=`[scrollbar-width:thin]`,Ux=`flex min-h-(--menu-item-h) w-full min-w-0 cursor-pointer items-center gap-2.5 rounded-md px-2.5 py-1 text-left text-md transition-colors duration-(--dur-1) ease-app select-none [&_svg]:shrink-0 data-[disabled='']:cursor-not-allowed data-[disabled='']:opacity-50 data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50`,Wx=`text-text [&_svg]:text-icon hover:bg-surface-hover data-highlighted:bg-surface-hover data-[selected=true]:bg-surface-hover`,Gx=`text-danger-text [&_svg]:text-danger hover:bg-danger-subtle data-highlighted:bg-danger-subtle`,Kx=`block px-2.5 pt-2 pb-1 font-sans text-xs font-medium text-text-tertiary`,qx=`-mx-1 my-1 h-px bg-border-subtle`,Jx={dropdown:`max-h-[min(var(--radix-dropdown-menu-content-available-height),var(--menu-max-h))]`,select:`max-h-[min(var(--radix-select-content-available-height),var(--menu-max-h))]`,combobox:`max-h-(--menu-max-h)`};function Yx({children:e,className:t}){return(0,I.jsx)(`kbd`,{className:q(`inline-flex h-4.5 min-w-4.5 shrink-0 items-center justify-center rounded-sm border border-border px-1`,`font-sans text-[11px] leading-none font-medium text-text-tertiary`,t),children:e})}var Xx=Object.defineProperty,Zx=(e,t)=>Xx(e,`name`,{value:t,configurable:!0}),Qx=!!(typeof window<`u`&&window.document&&window.document.createElement);function $x(e,t,{checkForDefaultPrevented:n=!0}={}){return Zx(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}Zx($x,`composeEventHandlers`);function eS(e){if(!Qx)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}Zx(eS,`getOwnerWindow`);function tS(e){if(!Qx)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}Zx(tS,`getOwnerDocument`);function nS(e,t=!1){let{activeElement:n}=tS(e);if(!n?.nodeName)return null;if(rS(n)&&n.contentDocument)return nS(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=tS(n).getElementById(e);if(t)return t}}return n}Zx(nS,`getActiveElement`);function rS(e){return e.tagName===`IFRAME`}Zx(rS,`isFrame`);var iS=Object.defineProperty,aS=(e,t)=>iS(e,`name`,{value:t,configurable:!0});function oS(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}aS(oS,`setRef`);function sS(...e){return t=>{let n=!1,r=e.map(e=>{let r=oS(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():oS(e[t],null)}}}}aS(sS,`composeRefs`);function cS(...e){return F.useCallback(sS(...e),e)}aS(cS,`useComposedRefs`);var lS=Object.defineProperty,uS=(e,t)=>lS(e,`name`,{value:t,configurable:!0});function dS(e,t){let n=F.createContext(t);n.displayName=e+`Context`;let r=uS(e=>{let{children:t,...r}=e,i=F.useMemo(()=>r,Object.values(r));return(0,I.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=F.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return uS(i,`useContext`),[r,i]}uS(dS,`createContext`);function fS(e,t=[]){let n=[];function r(t,r){let i=F.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=uS(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=F.useMemo(()=>o,Object.values(o));return(0,I.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=F.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return uS(s,`useContext`),[o,s]}uS(r,`createContext`);let i=uS(()=>{let t=n.map(e=>F.createContext(e));return uS(function(n){let r=n?.[e]||t;return F.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,pS(i,...t)]}uS(fS,`createContextScope`);function pS(...e){let t=e[0];if(e.length===1)return t;let n=uS(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return uS(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return F.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}uS(pS,`composeContextScopes`);var mS=Object.defineProperty,hS=(e,t)=>mS(e,`name`,{value:t,configurable:!0});function gS(e){let t=F.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];wS(r)&&typeof OS==`function`&&(r=OS(r._payload)),F.Children.forEach(r,e=>{if(SS(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;wS(n)&&typeof OS==`function`&&(n=OS(n._payload)),a=yS(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=F.cloneElement(a,void 0,s):!o&&F.Children.count(r)===1&&F.isValidElement(r)&&(a=r);let c=a?xS(a):void 0,l=cS(n,c);if(!a){if(r||r===0)throw Error(o?DS(e):ES(e));return r}let u=bS(i,a.props??{});return a.type!==F.Fragment&&(u.ref=n?l:c),F.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}hS(gS,`createSlot`);var _S=Symbol.for(`radix.slottable`);function vS(e){let t=hS(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=_S,t}hS(vS,`createSlottable`);var yS=hS((e,t)=>{if(`child`in e.props){let t=e.props.child;return F.isValidElement(t)?F.cloneElement(t,void 0,e.props.children(t.props.children)):null}return F.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function bS(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}hS(bS,`mergeProps`);function xS(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}hS(xS,`getElementRef`);function SS(e){return F.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===_S}hS(SS,`isSlottable`);var CS=Symbol.for(`react.lazy`);function wS(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===CS&&`_payload`in e&&TS(e._payload)}hS(wS,`isLazyComponent`);function TS(e){return typeof e==`object`&&!!e&&`then`in e}hS(TS,`isPromiseLike`);var ES=hS(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),DS=hS(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),OS=F.use,kS=Object.defineProperty,AS=(e,t)=>kS(e,`name`,{value:t,configurable:!0}),jS=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=gS(`Primitive.${t}`),r=F.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,I.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function MS(e,t){e&&Bx.flushSync(()=>e.dispatchEvent(t))}AS(MS,`dispatchDiscreteCustomEvent`);var NS=Object.defineProperty,PS=(e,t)=>NS(e,`name`,{value:t,configurable:!0});function FS(e){let t=F.useRef(e);return F.useEffect(()=>{t.current=e}),F.useMemo(()=>((...e)=>t.current?.(...e)),[])}PS(FS,`useCallbackRef`);var IS=Object.defineProperty,LS=(e,t)=>IS(e,`name`,{value:t,configurable:!0}),RS=`dismissableLayer.update`,zS=`dismissableLayer.pointerDownOutside`,BS=`dismissableLayer.focusOutside`,VS,HS=F.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),US=F.forwardRef(LS(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=F.useContext(HS),[d,f]=F.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=F.useState({}),h=cS(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,y=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,S=F.useRef(!1),C=KS(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:F.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return x&&!t},[u.branches,x])}),w=qS(e=>{if(r&&S.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),T=d?y===g.length-1:!1,E=FS(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return F.useEffect(()=>{if(T)return p.addEventListener(`keydown`,E,{capture:!0}),()=>p.removeEventListener(`keydown`,E,{capture:!0})},[p,T,E]),F.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(VS=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),JS(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=VS))}},[d,p,n,u]),F.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),JS())},[d,u]),F.useEffect(()=>{let e=LS(()=>m({}),`handleUpdate`);return document.addEventListener(RS,e),()=>document.removeEventListener(RS,e)},[]),(0,I.jsx)(jS.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:$x(e.onFocusCapture,w.onFocusCapture),onBlurCapture:$x(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:$x(e.onPointerDownCapture,C.onPointerDownCapture)})},`DismissableLayer`));function WS(){let e=F.useContext(HS),[t,n]=F.useState(null);return F.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}LS(WS,`useDismissableLayerSurface`);var GS=LS(()=>!0,`IS_TRUE`);function KS(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=GS}=t,s=FS(e),c=F.useRef(!1),l=F.useRef(!1),u=F.useRef(new Map),d=F.useRef(()=>{});return F.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}LS(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}LS(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}LS(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}LS(p,`handleInteractionBubble`);let m=LS(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||YS(zS,s,p,{discrete:!0})};if(LS(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:LS(()=>c.current=!0,`onPointerDownCapture`)}}LS(KS,`usePointerDownOutside`);function qS(e,t=globalThis?.document){let n=FS(e),r=F.useRef(!1);return F.useEffect(()=>{let e=LS(e=>{e.target&&!r.current&&YS(BS,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:LS(()=>r.current=!0,`onFocusCapture`),onBlurCapture:LS(()=>r.current=!1,`onBlurCapture`)}}LS(qS,`useFocusOutside`);function JS(){let e=new CustomEvent(RS);document.dispatchEvent(e)}LS(JS,`dispatchUpdate`);function YS(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?MS(i,a):i.dispatchEvent(a)}LS(YS,`handleAndDispatchCustomEvent`);var XS=globalThis?.document?F.useLayoutEffect:()=>{},ZS=Object.defineProperty,QS=(e,t)=>ZS(e,`name`,{value:t,configurable:!0}),$S=F.useId||(()=>void 0),eC=0;function tC(e){let[t,n]=F.useState($S());return XS(()=>{e||n(e=>e??String(eC++))},[e]),e||(t?`radix-${t}`:``)}QS(tC,`useId`);var nC=[`top`,`right`,`bottom`,`left`],rC=Math.min,iC=Math.max,aC=Math.round,oC=Math.floor,sC=e=>({x:e,y:e}),cC={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function lC(e,t,n){return iC(e,rC(t,n))}function uC(e,t){return typeof e==`function`?e(t):e}function dC(e){return e.split(`-`)[0]}function fC(e){return e.split(`-`)[1]}function pC(e){return e===`x`?`y`:`x`}function mC(e){return e===`y`?`height`:`width`}function hC(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function gC(e){return pC(hC(e))}function _C(e,t,n){n===void 0&&(n=!1);let r=fC(e),i=gC(e),a=mC(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=EC(o)),[o,EC(o)]}function vC(e){let t=EC(e);return[yC(e),t,yC(t)]}function yC(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var bC=[`left`,`right`],xC=[`right`,`left`],SC=[`top`,`bottom`],CC=[`bottom`,`top`];function wC(e,t,n){switch(e){case`top`:case`bottom`:return n?t?xC:bC:t?bC:xC;case`left`:case`right`:return t?SC:CC;default:return[]}}function TC(e,t,n,r){let i=fC(e),a=wC(dC(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(yC)))),a}function EC(e){let t=dC(e);return cC[t]+e.slice(t.length)}function DC(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function OC(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:DC(e)}function kC(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function AC(e,t,n){let{reference:r,floating:i}=e,a=hC(t),o=gC(t),s=mC(o),c=dC(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=fC(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function jC(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=uC(t,e),p=OC(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=kC(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=kC(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var MC=50,NC=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:jC},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=AC(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<MC&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=AC(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},PC=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=uC(e,t)||{};if(l==null)return{};let d=OC(u),f={x:n,y:r},p=gC(i),m=mC(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=rC(d[_],T),D=rC(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,ee=lC(E,k,O),A=!c.arrow&&fC(i)!=null&&k!==ee&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,j=A?k<E?k-E:k-O:0;return{[p]:f[p]+j,data:{[p]:ee,centerOffset:k-ee-j,...A&&{alignmentOffset:j}},reset:A}}}),FC=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=uC(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=dC(r),_=hC(o),v=dC(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[EC(o)]:vC(o)),x=p!==`none`;!d&&x&&b.push(...TC(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=_C(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==hC(t))||T.every(e=>hC(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=hC(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function IC(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function LC(e){return nC.some(t=>e[t]>=0)}var RC=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=uC(e,t);switch(i){case`referenceHidden`:{let e=IC(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:LC(e)}}}case`escaped`:{let e=IC(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:LC(e)}}}default:return{}}}}},zC=new Set([`left`,`top`]);async function BC(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=dC(n),s=fC(n),c=hC(n)===`y`,l=zC.has(o)?-1:1,u=a&&c?-1:1,d=uC(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var VC=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await BC(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},HC=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=uC(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=hC(i),p=pC(f),m=u[p],h=u[f],g=(e,t)=>lC(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},UC=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=uC(e,t),u={x:n,y:r},d=hC(i),f=pC(d),p=u[f],m=u[d],h=uC(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=zC.has(dC(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},WC=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=uC(e,t),c=await i.detectOverflow(t,s),l=dC(n),u=fC(n),d=hC(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=rC(p-c[m],g),y=rC(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*iC(c.left,c.right):S=p-2*iC(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function GC(){return typeof window<`u`}function KC(e){return YC(e)?(e.nodeName||``).toLowerCase():`#document`}function qC(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function JC(e){return((YC(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function YC(e){return GC()?e instanceof Node||e instanceof qC(e).Node:!1}function XC(e){return GC()?e instanceof Element||e instanceof qC(e).Element:!1}function ZC(e){return GC()?e instanceof HTMLElement||e instanceof qC(e).HTMLElement:!1}function QC(e){return!GC()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof qC(e).ShadowRoot}function $C(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=uw(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ew(e){return/^(table|td|th)$/.test(KC(e))}function tw(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var nw=/transform|translate|scale|rotate|perspective|filter/,rw=/paint|layout|strict|content/,iw=e=>!!e&&e!==`none`,aw;function ow(e){let t=XC(e)?uw(e):e;return iw(t.transform)||iw(t.translate)||iw(t.scale)||iw(t.rotate)||iw(t.perspective)||!cw()&&(iw(t.backdropFilter)||iw(t.filter))||nw.test(t.willChange||``)||rw.test(t.contain||``)}function sw(e){let t=fw(e);for(;ZC(t)&&!lw(t);){if(ow(t))return t;if(tw(t))return null;t=fw(t)}return null}function cw(){return aw??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),aw}function lw(e){return/^(html|body|#document)$/.test(KC(e))}function uw(e){return qC(e).getComputedStyle(e)}function dw(e){return XC(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function fw(e){if(KC(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||QC(e)&&e.host||JC(e);return QC(t)?t.host:t}function pw(e){let t=fw(e);return lw(t)?(e.ownerDocument||e).body:ZC(t)&&$C(t)?t:pw(t)}function mw(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=pw(e),i=r===e.ownerDocument?.body,a=qC(r);if(i){let e=hw(a);return t.concat(a,a.visualViewport||[],$C(r)?r:[],e&&n?mw(e):[])}else return t.concat(r,mw(r,[],n))}function hw(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function gw(e){let t=uw(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ZC(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=aC(n)!==a||aC(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function _w(e){return XC(e)?e:e.contextElement}function vw(e){let t=_w(e);if(!ZC(t))return sC(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=gw(t),o=(a?aC(n.width):n.width)/r,s=(a?aC(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var yw=sC(0);function bw(e){let t=qC(e);return!cw()||!t.visualViewport?yw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function xw(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===qC(e)}function Sw(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=_w(e),o=sC(1);t&&(r?XC(r)&&(o=vw(r)):o=vw(e));let s=xw(a,n,r)?bw(a):sC(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=qC(a),t=XC(r)?qC(r):r,n=e,i=hw(n);for(;i&&t!==n;){let e=vw(i),t=i.getBoundingClientRect(),r=uw(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=qC(i),i=hw(n)}}return kC({width:u,height:d,x:c,y:l})}function Cw(e,t){let n=dw(e).scrollLeft;return t?t.left+n:Sw(JC(e)).left+n}function ww(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Cw(e,n),y:n.top+t.scrollTop}}function Tw(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=JC(r),s=t?tw(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=sC(1),u=sC(0),d=ZC(r);if((d||!a)&&((KC(r)!==`body`||$C(o))&&(c=dw(r)),d)){let e=Sw(r);l=vw(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?ww(o,c):sC(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Ew(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Dw(e){let t=dw(e),n=e.ownerDocument.body,r=iC(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=iC(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Cw(e),o=-t.scrollTop;return uw(n).direction===`rtl`&&(a+=iC(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Ow=25;function kw(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=qC(e),a=JC(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!cw()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Cw(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=Ow&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Aw(e,t){let n=Sw(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=vw(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function jw(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=kw(e,n,t);else if(t===`document`)r=Dw(JC(e));else if(XC(t))r=Aw(t,n);else{let n=bw(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return kC(r)}function Mw(e,t){let n=t.get(e);if(n)return n;let r=mw(e,[],!1).filter(e=>XC(e)&&KC(e)!==`body`),i=null,a=uw(e).position===`fixed`,o=a?fw(e):e;for(;XC(o)&&!lw(o);){let e=uw(o),t=ow(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=fw(o)}return t.set(e,r),r}function Nw(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?tw(t)?[]:Mw(t,this._c):[].concat(n),r],o=jw(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=jw(t,a[e],i);s=iC(n.top,s),c=rC(n.right,c),l=rC(n.bottom,l),u=iC(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Pw(e){let{width:t,height:n}=gw(e);return{width:t,height:n}}function Fw(e,t,n){let r=ZC(t),i=JC(t),a=n===`fixed`,o=Sw(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=sC(0);if((r||!a)&&((KC(t)!==`body`||$C(i))&&(s=dw(t)),r)){let e=Sw(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Cw(i));let l=i&&!r&&!a?ww(i,s):sC(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Iw(e){return uw(e).position===`static`}function Lw(e,t){if(!ZC(e)||uw(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return JC(e)===n&&(n=n.ownerDocument.body),n}function Rw(e,t){let n=qC(e);if(tw(e))return n;if(!ZC(e)){let t=fw(e);for(;t&&!lw(t);){if(XC(t)&&!Iw(t))return t;t=fw(t)}return n}let r=Lw(e,t);for(;r&&ew(r)&&Iw(r);)r=Lw(r,t);return r&&lw(r)&&Iw(r)&&!ow(r)?n:r||sw(e)||n}var zw=async function(e){let t=this.getOffsetParent||Rw,n=this.getDimensions,r=await n(e.floating);return{reference:Fw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Bw(e){return uw(e).direction===`rtl`}var Vw={convertOffsetParentRelativeRectToViewportRelativeRect:Tw,getDocumentElement:JC,getClippingRect:Nw,getOffsetParent:Rw,getElementRects:zw,getClientRects:Ew,getDimensions:Pw,getScale:vw,isElement:XC,isRTL:Bw};function Hw(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Uw(e,t,n){let r=null,i,a=JC(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=oC(d),h=oC(a.clientWidth-(u+f)),g=oC(a.clientHeight-(d+p)),_=oC(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:iC(0,rC(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Hw(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=qC(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Ww(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=_w(e),u=i||a?[...l?mw(l):[],...t?mw(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Uw(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Sw(e):null;c&&g();function g(){let t=Sw(e);h&&!Hw(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Gw=VC,Kw=HC,qw=FC,Jw=WC,Yw=RC,Xw=PC,Zw=UC,Qw=(e,t,n)=>{let r=new Map,i=n??{},a={...Vw,...i.platform,_c:r};return NC(e,t,{...i,platform:a})},$w=typeof document<`u`?F.useLayoutEffect:function(){};function eT(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!eT(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!eT(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function tT(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function nT(e,t){let n=tT(e);return Math.round(t*n)/n}function rT(e){let t=F.useRef(e);return $w(()=>{t.current=e}),t}function iT(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=F.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=F.useState(r);eT(f,r)||p(r);let[m,h]=F.useState(null),[g,_]=F.useState(null),v=F.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=F.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=F.useRef(null),C=F.useRef(null),w=F.useRef(u),T=c!=null,E=rT(c),D=rT(i),O=rT(l),k=F.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Qw(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};ee.current&&!eT(w.current,t)&&(w.current=t,Bx.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);$w(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let ee=F.useRef(!1);$w(()=>(ee.current=!0,()=>{ee.current=!1}),[]),$w(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let A=F.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),j=F.useMemo(()=>({reference:b,floating:x}),[b,x]),M=F.useMemo(()=>{let e={position:n,left:0,top:0};if(!j.floating)return e;let t=nT(j.floating,u.x),r=nT(j.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...tT(j.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,j.floating,u.x,u.y]);return F.useMemo(()=>({...u,update:k,refs:A,elements:j,floatingStyles:M}),[u,k,A,j,M])}var aT=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Xw({element:r.current,padding:i}).fn(n):r?Xw({element:r,padding:i}).fn(n):{}}}},oT=(e,t)=>{let n=Gw(e);return{name:n.name,fn:n.fn,options:[e,t]}},sT=(e,t)=>{let n=Kw(e);return{name:n.name,fn:n.fn,options:[e,t]}},cT=(e,t)=>({fn:Zw(e).fn,options:[e,t]}),lT=(e,t)=>{let n=qw(e);return{name:n.name,fn:n.fn,options:[e,t]}},uT=(e,t)=>{let n=Jw(e);return{name:n.name,fn:n.fn,options:[e,t]}},dT=(e,t)=>{let n=Yw(e);return{name:n.name,fn:n.fn,options:[e,t]}},fT=(e,t)=>{let n=aT(e);return{name:n.name,fn:n.fn,options:[e,t]}},pT=Object.defineProperty,mT=(e,t)=>pT(e,`name`,{value:t,configurable:!0});function hT(e){let[t,n]=F.useState(void 0);return XS(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}mT(hT,`useSize`);var gT=Object.defineProperty,_T=(e,t)=>gT(e,`name`,{value:t,configurable:!0}),vT=`Popper`,[yT,bT]=fS(vT),[xT,ST]=yT(vT),CT=_T(e=>{let{__scopePopper:t,children:n}=e,[r,i]=F.useState(null),[a,o]=F.useState(void 0);return(0,I.jsx)(xT,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),wT=`PopperAnchor`,TT=F.forwardRef(_T(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=ST(wT,n),o=F.useRef(null),s=a.onAnchorChange,c=cS(t,F.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=F.useRef(null);F.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&jT(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,I.jsx)(jS.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),ET=`PopperContent`,[DT,xee]=yT(ET),OT=F.forwardRef(_T(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=ST(ET,n),[_,v]=F.useState(null),y=cS(t,v),[b,x]=F.useState(null),S=hT(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(kT),altBoundary:O},{refs:ee,floatingStyles:A,placement:j,isPositioned:M,middlewareData:N}=iT({strategy:`fixed`,placement:T,whileElementsMounted:_T((...e)=>Ww(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[oT({mainAxis:i+w,alignmentAxis:o}),c&&sT({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?cT():void 0,...k}),c&&lT({...k}),uT({...k,apply:_T(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),b&&fT({element:b,padding:s}),AT({arrowWidth:C,arrowHeight:w}),f&&dT({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),te=g.setPlacementState;XS(()=>(te(j),()=>{te(void 0)}),[j,te]);let[ne,re]=jT(j),ie=FS(m);XS(()=>{M&&ie?.()},[M,ie]);let ae=N.arrow?.x,P=N.arrow?.y,oe=N.arrow?.centerOffset!==0,[se,ce]=F.useState();return XS(()=>{_&&ce(window.getComputedStyle(_).zIndex)},[_]),(0,I.jsx)(`div`,{ref:ee.setFloating,"data-radix-popper-content-wrapper":``,style:{...A,transform:M?A.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:se,"--radix-popper-transform-origin":[N.transformOrigin?.x,N.transformOrigin?.y].join(` `),...N.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,I.jsx)(DT,{scope:n,placedSide:ne,placedAlign:re,onArrowChange:x,arrowX:ae,arrowY:P,shouldHideArrow:oe,children:(0,I.jsx)(jS.div,{"data-side":ne,"data-align":re,...h,ref:y,style:{...h.style,animation:M?h.style?.animation:`none`}})})})},`PopperContent`));function kT(e){return e!==null}_T(kT,`isNotNull`);var AT=_T(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=jT(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function jT(e){let[t,n=`center`]=e.split(`-`);return[t,n]}_T(jT,`getSideAndAlignFromPlacement`);var MT=CT,NT=TT,PT=OT,FT=Object.defineProperty,IT=F.forwardRef(((e,t)=>FT(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=F.useState(!1);XS(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Bx.createPortal((0,I.jsx)(jS.div,{...r,ref:t}),o):null},`Portal`)),LT=Object.defineProperty,RT=(e,t)=>LT(e,`name`,{value:t,configurable:!0});function zT(e,t){return F.useReducer((e,n)=>t[e][n]??e,e)}RT(zT,`useStateMachine`);var BT=RT(e=>{let{present:t,children:n}=e,r=VT(t),i=typeof n==`function`?n({present:r.isPresent}):F.Children.only(n),a=UT(r.ref,GT(i));return typeof n==`function`||r.isPresent?F.cloneElement(i,{ref:a}):null},`Presence`);function VT(e){let[t,n]=F.useState(),r=F.useRef(null),i=F.useRef(e),a=F.useRef(`none`),o=F.useRef(void 0),[s,c]=zT(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return F.useEffect(()=>{s===`mounted`?(a.current=o.current??WT(r.current),o.current=void 0):a.current=`none`},[s]),XS(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=WT(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),XS(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=RT(a=>{let o=WT(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=RT(e=>{e.target===t&&(a.current=WT(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:F.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=WT(t)}else r.current=null;n(e)},[])}}RT(VT,`usePresence`);function HT(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}RT(HT,`setRef`);function UT(...e){let t=F.useRef(e);return t.current=e,F.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=HT(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():HT(n[e],null)}}},[])}RT(UT,`useStableComposedRefs`);function WT(e){return e?.animationName||`none`}RT(WT,`getAnimationName`);function GT(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}RT(GT,`getElementRef`);var KT=Object.defineProperty,qT=(e,t)=>KT(e,`name`,{value:t,configurable:!0}),JT=F.useEffectEvent,YT=F.useInsertionEffect;function XT(e){if(typeof JT==`function`)return JT(e);let t=F.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof YT==`function`?YT(()=>{t.current=e}):XS(()=>{t.current=e}),F.useMemo(()=>((...e)=>t.current?.(...e)),[])}qT(XT,`useEffectEvent`);var ZT=Object.defineProperty,QT=(e,t)=>ZT(e,`name`,{value:t,configurable:!0}),$T=F.useInsertionEffect||XS;function eE({prop:e,defaultProp:t,onChange:n=QT(()=>{},`onChange`),caller:r}){let[i,a,o]=tE({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,F.useCallback(t=>{if(s){let n=nE(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}QT(eE,`useControllableState`);function tE({defaultProp:e,onChange:t}){let[n,r]=F.useState(e),i=F.useRef(n),a=F.useRef(t);return $T(()=>{a.current=t},[t]),F.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}QT(tE,`useUncontrolledState`);function nE(e){return typeof e==`function`}QT(nE,`isFunction`);var rE=Symbol(`RADIX:SYNC_STATE`);function See(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=XT(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=F.useReducer((t,n)=>{if(n.type===rE)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=F.useRef(p);F.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=F.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return F.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:rE,state:i})},[i,d.state,c]),[h,f]}QT(See,`useControllableStateReducer`);var Cee=Object.defineProperty,wee=(e,t)=>Cee(e,`name`,{value:t,configurable:!0}),iE=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Tee=F.forwardRef(wee(function(e,t){return(0,I.jsx)(jS.span,{...e,ref:t,style:{...iE,...e.style}})},`VisuallyHidden`)),Eee=Object.defineProperty,aE=(e,t)=>Eee(e,`name`,{value:t,configurable:!0}),[oE,Dee]=fS(`Tooltip`,[bT]),sE=bT(),Oee=`TooltipProvider`,kee=700,cE=`tooltip.open`,[Aee,lE]=oE(Oee),jee=aE(e=>{let{__scopeTooltip:t,delayDuration:n=kee,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=F.useRef(!0),s=F.useRef(!1),c=F.useRef(0);return F.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,I.jsx)(Aee,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:F.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:F.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:F.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),uE=`Tooltip`,[Mee,dE]=oE(uE),Nee=aE(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=lE(uE,e.__scopeTooltip),l=sE(t),[u,d]=F.useState(null),[f,p]=F.useState(void 0),m=tC(),h=F.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=F.useRef(!1),[y,b]=eE({prop:r,defaultProp:i??!1,onChange:aE(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(cE))):c.onClose(),a?.(e)},`onChange`),caller:uE}),x=F.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),S=F.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),C=F.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=F.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},_)},[_,b]);F.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let T=f??m;return(0,I.jsx)(MT,{...l,children:(0,I.jsx)(Mee,{scope:t,contentId:T,setContentId:p,open:y,stateAttribute:x,trigger:u,onTriggerChange:d,onTriggerEnter:F.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:F.useCallback(()=>{g?C():(window.clearTimeout(h.current),h.current=0)},[C,g]),onOpen:S,onClose:C,disableHoverableContent:g,children:n})})},`Tooltip`),fE=`TooltipTrigger`,Pee=F.forwardRef(aE(function(e,t){let{__scopeTooltip:n,...r}=e,i=dE(fE,n),a=lE(fE,n),o=sE(n),s=cS(t,F.useRef(null),i.onTriggerChange),c=F.useRef(!1),l=F.useRef(!1),u=F.useCallback(()=>c.current=!1,[]);return F.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,I.jsx)(NT,{asChild:!0,...o,children:(0,I.jsx)(jS.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:$x(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:$x(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:$x(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:$x(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:$x(e.onBlur,i.onClose),onClick:$x(e.onClick,i.onClose)})})},`TooltipTrigger`)),pE=`TooltipPortal`,[Fee,Iee]=oE(pE,{forceMount:void 0}),Lee=aE(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=dE(pE,t);return(0,I.jsx)(Fee,{scope:t,forceMount:n,children:(0,I.jsx)(BT,{present:n||a.open,children:(0,I.jsx)(IT,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),mE=`TooltipContent`,Ree=F.forwardRef(aE(function(e,t){let n=Iee(mE,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=dE(mE,e.__scopeTooltip);return(0,I.jsx)(BT,{present:r||o.open,children:o.disableHoverableContent?(0,I.jsx)(hE,{side:i,...a,ref:t}):(0,I.jsx)(zee,{side:i,...a,ref:t})})},`TooltipContent`)),zee=F.forwardRef(aE(function(e,t){let n=dE(mE,e.__scopeTooltip),r=lE(mE,e.__scopeTooltip),i=F.useRef(null),a=cS(t,i),[o,s]=F.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=F.useCallback(()=>{s(null),d(!1)},[d]),p=F.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=_E(r,gE(r,n.getBoundingClientRect())),a=vE(t.getBoundingClientRect()),o=bE([...i,...a]);s(o),d(!0)},[d]);return F.useEffect(()=>()=>f(),[f]),F.useEffect(()=>{if(c&&u){let e=aE(e=>p(e,u),`handleTriggerLeave`),t=aE(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),F.useEffect(()=>{if(o){let e=aE(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!yE(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,I.jsx)(hE,{...e,ref:a})},`TooltipContentHoverable`)),Bee=vS(`TooltipContent`),hE=F.forwardRef(aE(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=dE(mE,n),u=sE(n),{onClose:d}=l;F.useEffect(()=>(document.addEventListener(cE,d),()=>document.removeEventListener(cE,d)),[d]),F.useEffect(()=>{if(l.trigger){let e=aE(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return XS(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,I.jsx)(US,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,I.jsxs)(PT,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,I.jsx)(Bee,{children:r}),i?(0,I.jsx)(Tee,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`));function gE(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}aE(gE,`getExitSideFromRect`);function _E(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}aE(_E,`getPaddedExitPoints`);function vE(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}aE(vE,`getPointsFromRect`);function yE(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}aE(yE,`isPointInPolygon`);function bE(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),xE(t)}aE(bE,`getHull`);function xE(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}aE(xE,`getHullPresorted`);var Vee=jee,SE=Nee,CE=Pee,wE=Lee,TE=Ree,EE=(0,F.createContext)(!1);function DE({children:e}){return(0,I.jsx)(Vee,{delayDuration:400,skipDelayDuration:300,children:(0,I.jsx)(EE.Provider,{value:!0,children:e})})}function OE({label:e,kbd:t,side:n=`top`,align:r=`center`,disabled:i=!1,leaves:a=!1,children:o}){let s=(0,F.useContext)(EE);if(i||e==null||e===``)return o;let c=(0,I.jsxs)(SE,{disableHoverableContent:a,children:[(0,I.jsx)(CE,{asChild:!0,children:o}),(0,I.jsx)(wE,{children:(0,I.jsxs)(TE,{side:n,align:r,sideOffset:6,collisionPadding:8,className:q(`z-[400] flex max-w-72 items-center gap-2 rounded-md bg-surface-raised px-2 py-1`,`text-xs text-text shadow-popover select-none animate-pop-in`),children:[e,t&&(0,I.jsx)(`span`,{className:`font-sans text-xs text-text-tertiary`,children:t})]})})]});return s?c:(0,I.jsx)(DE,{children:c})}var kE={primary:`primary`,secondary:`secondary`,ghost:`ghost`,danger:`danger`,"danger-ghost":`danger-ghost`,solid:`primary`,accent:`secondary`},AE={sm:`sm`,md:`md`,lg:`lg`,touch:`touch`,xs:`sm`},jE=`inline-flex shrink-0 items-center justify-center gap-1.5 whitespace-nowrap border font-medium select-none transition-[color,background-color,border-color,transform] duration-(--dur-1) ease-app enabled:active:translate-y-px disabled:cursor-not-allowed`,ME={none:`rounded-md`,start:`rounded-l-md`,end:`rounded-r-md`},NE={sm:`h-(--control-sm) px-2 text-xs`,md:`h-(--control-h) px-3 text-sm`,lg:`h-(--control-lg) px-4 text-sm`,touch:`h-10 px-4 text-sm`},PE={primary:`border-transparent bg-primary text-on-primary enabled:hover:bg-primary-hover disabled:bg-surface-selected disabled:text-text-disabled`,secondary:`border-border bg-transparent text-text enabled:hover:border-border-strong enabled:hover:bg-surface-hover disabled:border-border-subtle disabled:text-text-disabled`,ghost:`border-transparent bg-transparent text-text-secondary enabled:hover:bg-surface-hover enabled:hover:text-text aria-pressed:bg-surface-selected aria-pressed:text-text aria-expanded:bg-surface-selected aria-expanded:text-text disabled:text-text-disabled`,danger:`border-border bg-transparent text-danger-text [&_svg]:text-danger enabled:hover:border-danger-subtle enabled:hover:bg-danger-subtle disabled:border-border-subtle disabled:text-text-disabled disabled:[&_svg]:text-text-disabled`,"danger-ghost":`border-transparent bg-transparent text-danger-text [&_svg]:text-danger enabled:hover:bg-danger-subtle aria-expanded:bg-danger-subtle disabled:text-text-disabled disabled:[&_svg]:text-text-disabled`},FE={sm:`inline-flex shrink-0 opacity-85 [&>svg]:size-3.5`,md:`inline-flex shrink-0 opacity-85 [&>svg]:size-4`,lg:`inline-flex shrink-0 opacity-85 [&>svg]:size-4`,touch:`inline-flex shrink-0 opacity-85 [&>svg]:size-4`},IE=`border-transparent text-on-primary opacity-60`;function J({variant:e=`secondary`,size:t=`md`,type:n=`button`,icon:r,kbd:i,loading:a=!1,attached:o=`none`,disabled:s,className:c,children:l,...u}){let d=kE[e],f=AE[t],p=a&&!r;return(0,I.jsxs)(`button`,{type:n,disabled:s||a,"aria-busy":a||void 0,"data-variant":d,className:q(jE,ME[o],NE[f],PE[d],c),...u,children:[r!==void 0&&(a?(0,I.jsx)(UE,{size:f===`sm`?`sm`:`md`,tone:`current`}):(0,I.jsx)(`span`,{className:FE[f],children:r})),p?(0,I.jsxs)(`span`,{className:`inline-grid place-items-center`,children:[(0,I.jsx)(`span`,{className:`invisible col-start-1 row-start-1 inline-flex items-center gap-1.5`,children:l}),(0,I.jsx)(`span`,{className:`col-start-1 row-start-1 inline-flex`,children:(0,I.jsx)(UE,{size:f===`sm`?`sm`:`md`,tone:`current`})})]}):l,i&&(0,I.jsx)(Yx,{className:q(`ml-0.5`,d===`primary`&&IE),children:i})]})}var LE=`border-transparent bg-transparent text-icon enabled:hover:bg-surface-hover enabled:hover:text-text aria-pressed:bg-surface-selected aria-pressed:text-text aria-expanded:bg-surface-selected aria-expanded:text-text disabled:text-text-disabled`,RE=`border-transparent bg-transparent text-icon enabled:hover:bg-danger-subtle enabled:hover:text-danger aria-expanded:bg-danger-subtle aria-expanded:text-danger disabled:text-text-disabled`,zE={sm:`size-(--control-sm) [&>svg]:size-3.5`,md:`size-(--control-h) [&>svg]:size-4`,lg:`size-(--control-lg) [&>svg]:size-4`,touch:`size-10 [&>svg]:size-4`},BE=`pointer-events-none absolute -top-0.5 -right-0.5 grid h-3.5 min-w-3.5 place-items-center rounded-full bg-text-tertiary px-1 text-[10px] leading-none font-semibold text-surface tabular-nums animate-pop-in`;function Y({label:e,icon:t,children:n,size:r=`md`,variant:i=`ghost`,active:a,kbd:o,tooltipSide:s,type:c=`button`,href:l,target:u,rel:d,badge:f,className:p,...m}){let h=kE[i],g=AE[r],_=typeof f==`number`&&f>0?f>99?`99+`:String(f):null,v=q(jE,ME.none,`p-0`,_&&`relative`,zE[g],h===`ghost`?LE:h===`danger-ghost`?RE:PE[h],p),y=_?`${e} (${_})`:e,b=(0,I.jsxs)(I.Fragment,{children:[t??n,_&&(0,I.jsx)(`span`,{"aria-hidden":`true`,className:BE,children:_})]});return l===void 0?(0,I.jsx)(OE,{label:e,kbd:o,side:s,children:(0,I.jsx)(`button`,{type:c,"aria-label":y,"aria-pressed":a,className:v,...m,children:b})}):(0,I.jsx)(OE,{label:e,kbd:o,side:s,children:(0,I.jsx)(`a`,{href:l,target:u,rel:d??(u===`_blank`?`noreferrer noopener`:void 0),"aria-label":y,className:q(v,`no-underline hover:bg-surface-hover hover:text-text`),ref:m.ref,onClick:m.onClick,children:b})})}var VE={sm:`size-3`,md:`size-3.5`},HE={quiet:`border-text-tertiary`,work:`border-text-tertiary`,accent:`border-text-tertiary`,current:`border-current`};function UE({size:e=`md`,tone:t=`quiet`,className:n}){return(0,I.jsx)(`span`,{"aria-hidden":`true`,"data-progress":``,className:q(`inline-block shrink-0 animate-spin rounded-full border-[1.5px] border-t-transparent`,VE[e],HE[t],n)})}var WE=`border-0 bg-transparent`,GE=`cursor-pointer text-accent-text no-underline decoration-accent-text/50 underline-offset-2 transition-colors duration-(--dur-1) ease-app hover:underline hover:decoration-accent-text`,KE=1,qE=.9,JE=.8,YE=.17,XE=.1,ZE=.999,QE=.9999,$E=.99,eD=/[\\\/_+.#"@\[\(\{&]/,tD=/[\\\/_+.#"@\[\(\{&]/g,nD=/[\s-]/,rD=/[\s-]/g;function iD(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?KE:$E;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=iD(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=KE:eD.test(e.charAt(l-1))?(d*=JE,p=e.slice(i,l-1).match(tD),p&&i>0&&(d*=ZE**+p.length)):nD.test(e.charAt(l-1))?(d*=qE,m=e.slice(i,l-1).match(rD),m&&i>0&&(d*=ZE**+m.length)):(d*=YE,i>0&&(d*=ZE**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=QE)),(d<XE&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=iD(e,t,n,r,l+1,a+2,o),f*XE>d&&(d=f*XE)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function aD(e){return e.toLowerCase().replace(rD,` `)}function oD(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,iD(e,t,aD(e),aD(t),0,0,{})}var sD=Object.defineProperty,cD=(e,t)=>sD(e,`name`,{value:t,configurable:!0}),lD=`focusScope.autoFocusOnMount`,uD=`focusScope.autoFocusOnUnmount`,dD={bubbles:!1,cancelable:!0},fD=F.forwardRef(cD(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=F.useState(null),l=FS(i),u=FS(a),d=F.useRef(null),f=cS(t,c),p=F.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;F.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:yD(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||yD(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&yD(s)};cD(e,`handleFocusIn`),cD(t,`handleFocusOut`),cD(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),F.useEffect(()=>{if(s){bD.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(lD,dD);s.addEventListener(lD,l),s.dispatchEvent(t),t.defaultPrevented||(pD(CD(hD(s)),{select:!0}),document.activeElement===e&&yD(s))}return()=>{s.removeEventListener(lD,l),setTimeout(()=>{let t=new CustomEvent(uD,dD);s.addEventListener(uD,u),s.dispatchEvent(t),t.defaultPrevented||yD(e??document.body,{select:!0}),s.removeEventListener(uD,u),bD.remove(p)},0)}}},[s,l,u,p]);let m=F.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=mD(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&yD(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&yD(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,I.jsx)(jS.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})},`FocusScope`));function pD(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(yD(r,{select:t}),document.activeElement!==n)return}cD(pD,`focusFirst`);function mD(e){let t=hD(e);return[gD(t,e),gD(t.reverse(),e)]}cD(mD,`getTabbableEdges`);function hD(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:cD(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}cD(hD,`getTabbableCandidates`);function gD(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):_D(r,{upTo:t})))return r}cD(gD,`findVisible`);function _D(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}cD(_D,`isHidden`);function vD(e){return e instanceof HTMLInputElement&&`select`in e}cD(vD,`isSelectableInput`);function yD(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&vD(e)&&t&&e.select()}}cD(yD,`focus`);var bD=xD();function xD(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=SD(e,t),e.unshift(t)},remove(t){e=SD(e,t),e[0]?.resume()}}}cD(xD,`createFocusScopesStack`);function SD(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}cD(SD,`arrayRemove`);function CD(e){return e.filter(e=>e.tagName!==`A`)}cD(CD,`removeLinks`);var wD=Object.defineProperty,TD=(e,t)=>wD(e,`name`,{value:t,configurable:!0}),ED=0,DD=null;function OD(e){return kD(),e.children}TD(OD,`FocusGuards`);function kD(){F.useEffect(()=>{DD||={start:AD(),end:AD()};let{start:e,end:t}=DD;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),ED++,()=>{ED===1&&(DD?.start.remove(),DD?.end.remove(),DD=null),ED=Math.max(0,ED-1)}},[])}TD(kD,`useFocusGuards`);function AD(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}TD(AD,`createFocusGuard`);var jD=function(){return jD=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},jD.apply(this,arguments)};function MD(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function ND(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var PD=`right-scroll-bar-position`,FD=`width-before-scroll-bar`,ID=`with-scroll-bars-hidden`,LD=`--removed-body-scroll-bar-size`;function RD(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function zD(e,t){var n=(0,F.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var BD=typeof window<`u`?F.useLayoutEffect:F.useEffect,VD=new WeakMap;function HD(e,t){var n=zD(t||null,function(t){return e.forEach(function(e){return RD(e,t)})});return BD(function(){var t=VD.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||RD(e,null)}),i.forEach(function(e){r.has(e)||RD(e,a)})}VD.set(n,e)},[e]),n}function UD(e){return e}function WD(e,t){t===void 0&&(t=UD);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function GD(e){e===void 0&&(e={});var t=WD(null);return t.options=jD({async:!0,ssr:!1},e),t}var KD=function(e){var t=e.sideCar,n=MD(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return F.createElement(r,jD({},n))};KD.isSideCarExport=!0;function qD(e,t){return e.useMedium(t),KD}var JD=GD(),YD=function(){},XD=F.forwardRef(function(e,t){var n=F.useRef(null),r=F.useState({onScrollCapture:YD,onWheelCapture:YD,onTouchMoveCapture:YD}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=MD(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=HD([n,t]),C=jD(jD({},b),i);return F.createElement(F.Fragment,null,u&&F.createElement(x,{sideCar:JD,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?F.cloneElement(F.Children.only(s),jD(jD({},C),{ref:S})):F.createElement(v,jD({},C,{className:c,ref:S}),s))});XD.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},XD.classNames={fullWidth:FD,zeroRight:PD};var ZD,QD=function(){if(ZD)return ZD;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function $D(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=QD();return t&&e.setAttribute(`nonce`,t),e}function eO(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function tO(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var nO=function(){var e=0,t=null;return{add:function(n){e==0&&(t=$D())&&(eO(t,n),tO(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},rO=function(){var e=nO();return function(t,n){F.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},iO=function(){var e=rO();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},aO={left:0,top:0,right:0,gap:0},oO=function(e){return parseInt(e||``,10)||0},sO=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[oO(n),oO(r),oO(i)]},cO=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return aO;var t=sO(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},lO=iO(),uO=`data-scroll-locked`,dO=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
79
|
-
.${ID} {
|
|
80
|
-
overflow: hidden ${r};
|
|
81
|
-
padding-right: ${s}px ${r};
|
|
82
|
-
}
|
|
83
|
-
body[${uO}] {
|
|
84
|
-
overflow: hidden ${r};
|
|
85
|
-
overscroll-behavior: contain;
|
|
86
|
-
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
87
|
-
padding-left: ${i}px;
|
|
88
|
-
padding-top: ${a}px;
|
|
89
|
-
padding-right: ${o}px;
|
|
90
|
-
margin-left:0;
|
|
91
|
-
margin-top:0;
|
|
92
|
-
margin-right: ${s}px ${r};
|
|
93
|
-
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.${PD} {
|
|
97
|
-
right: ${s}px ${r};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.${FD} {
|
|
101
|
-
margin-right: ${s}px ${r};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.${PD} .${PD} {
|
|
105
|
-
right: 0 ${r};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.${FD} .${FD} {
|
|
109
|
-
margin-right: 0 ${r};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
body[${uO}] {
|
|
113
|
-
${LD}: ${s}px;
|
|
114
|
-
}
|
|
115
|
-
`},fO=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},pO=function(){F.useEffect(function(){return document.body.setAttribute(uO,(fO()+1).toString()),function(){var e=fO()-1;e<=0?document.body.removeAttribute(uO):document.body.setAttribute(uO,e.toString())}},[])},mO=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;pO();var a=F.useMemo(function(){return cO(i)},[i]);return F.createElement(lO,{styles:dO(a,!t,i,n?``:`!important`)})},hO=!1;if(typeof window<`u`)try{var gO=Object.defineProperty({},"passive",{get:function(){return hO=!0,!0}});window.addEventListener(`test`,gO,gO),window.removeEventListener(`test`,gO,gO)}catch{hO=!1}var _O=hO?{passive:!1}:!1,vO=function(e){return e.tagName===`TEXTAREA`},yO=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!vO(e)&&n[t]===`visible`)},bO=function(e){return yO(e,`overflowY`)},xO=function(e){return yO(e,`overflowX`)},SO=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),TO(e,r)){var i=EO(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},CO=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},wO=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},TO=function(e,t){return e===`v`?bO(t):xO(t)},EO=function(e,t){return e===`v`?CO(t):wO(t)},DO=function(e,t){return e===`h`&&t===`rtl`?-1:1},OO=function(e,t,n,r,i){var a=DO(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=EO(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&TO(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},kO=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},AO=function(e){return[e.deltaX,e.deltaY]},jO=function(e){return e&&`current`in e?e.current:e},MO=function(e,t){return e[0]===t[0]&&e[1]===t[1]},NO=function(e){return`
|
|
116
|
-
.block-interactivity-${e} {pointer-events: none;}
|
|
117
|
-
.allow-interactivity-${e} {pointer-events: all;}
|
|
118
|
-
`},PO=0,FO=[];function IO(e){var t=F.useRef([]),n=F.useRef([0,0]),r=F.useRef(),i=F.useState(PO++)[0],a=F.useState(iO)[0],o=F.useRef(e);F.useEffect(function(){o.current=e},[e]),F.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=ND([e.lockRef.current],(e.shards||[]).map(jO),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=F.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=kO(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=SO(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=SO(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return OO(h,t,e,h===`h`?s:c,!0)},[]),c=F.useCallback(function(e){var n=e;if(!(!FO.length||FO[FO.length-1]!==a)){var r=`deltaY`in n?AO(n):kO(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&MO(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(jO).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=F.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:LO(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=F.useCallback(function(e){n.current=kO(e),r.current=void 0},[]),d=F.useCallback(function(t){l(t.type,AO(t),t.target,s(t,e.lockRef.current))},[]),f=F.useCallback(function(t){l(t.type,kO(t),t.target,s(t,e.lockRef.current))},[]);F.useEffect(function(){return FO.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,_O),document.addEventListener(`touchmove`,c,_O),document.addEventListener(`touchstart`,u,_O),function(){FO=FO.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,_O),document.removeEventListener(`touchmove`,c,_O),document.removeEventListener(`touchstart`,u,_O)}},[]);var p=e.removeScrollBar,m=e.inert;return F.createElement(F.Fragment,null,m?F.createElement(a,{styles:NO(i)}):null,p?F.createElement(mO,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function LO(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var RO=qD(JD,IO),zO=F.forwardRef(function(e,t){return F.createElement(XD,jD({},e,{ref:t,sideCar:RO}))});zO.classNames=XD.classNames;var BO=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},VO=new WeakMap,HO=new WeakMap,UO={},WO=0,GO=function(e){return e&&(e.host||GO(e.parentNode))},KO=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=GO(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},qO=function(e,t,n,r){var i=KO(t,Array.isArray(e)?e:[e]);UO[n]||(UO[n]=new WeakMap);var a=UO[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(VO.get(e)||0)+1,l=(a.get(e)||0)+1;VO.set(e,c),a.set(e,l),o.push(e),c===1&&i&&HO.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),WO++,function(){o.forEach(function(e){var t=VO.get(e)-1,i=a.get(e)-1;VO.set(e,t),a.set(e,i),t||(HO.has(e)||e.removeAttribute(r),HO.delete(e)),i||e.removeAttribute(n)}),WO--,WO||(VO=new WeakMap,VO=new WeakMap,HO=new WeakMap,UO={})}},JO=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||BO(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),qO(r,i,n,`aria-hidden`)):function(){return null}},YO=Object.defineProperty,XO=(e,t)=>YO(e,`name`,{value:t,configurable:!0}),ZO=`Dialog`,[QO,Hee]=fS(ZO),[$O,ek]=QO(ZO),tk=XO(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=F.useRef(null),c=F.useRef(null),[l,u]=eE({prop:r,defaultProp:i??!1,onChange:a,caller:ZO}),[d,f]=F.useState(0),[p,m]=F.useState(0);return(0,I.jsx)($O,{scope:t,triggerRef:s,contentRef:c,contentId:tC(),titleId:tC(),descriptionId:tC(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:F.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),nk=`DialogPortal`,[rk,ik]=QO(nk,{forceMount:void 0}),ak=XO(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=ek(nk,t);return(0,I.jsx)(rk,{scope:t,forceMount:n,children:F.Children.map(r,e=>(0,I.jsx)(BT,{present:n||a.open,children:(0,I.jsx)(IT,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),ok=`DialogOverlay`,sk=F.forwardRef(XO(function(e,t){let n=ik(ok,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ek(ok,e.__scopeDialog);return a.modal?(0,I.jsx)(BT,{present:r||a.open,children:(0,I.jsx)(lk,{...i,ref:t})}):null},`DialogOverlay`)),ck=gS(`DialogOverlay.RemoveScroll`),lk=F.forwardRef(XO(function(e,t){let{__scopeDialog:n,...r}=e,i=ek(ok,n),a=cS(t,WS());return(0,I.jsx)(zO,{as:ck,allowPinchZoom:!0,shards:[i.contentRef],children:(0,I.jsx)(jS.div,{"data-state":hk(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),uk=`DialogContent`,dk=F.forwardRef(XO(function(e,t){let n=ik(uk,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ek(uk,e.__scopeDialog);return(0,I.jsx)(BT,{present:r||a.open,children:a.modal?(0,I.jsx)(fk,{...i,ref:t}):(0,I.jsx)(pk,{...i,ref:t})})},`DialogContent`)),fk=F.forwardRef(XO(function(e,t){let n=ek(uk,e.__scopeDialog),r=F.useRef(null),i=cS(t,n.contentRef,r);return F.useEffect(()=>{let e=r.current;if(e)return JO(e)},[]),(0,I.jsx)(mk,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:$x(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:$x(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:$x(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),pk=F.forwardRef(XO(function(e,t){let n=ek(uk,e.__scopeDialog),r=F.useRef(!1),i=F.useRef(!1);return(0,I.jsx)(mk,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),mk=F.forwardRef(XO(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=ek(uk,n);return kD(),(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(fD,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,I.jsx)(US,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":hk(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`));function hk(e){return e?`open`:`closed`}XO(hk,`getState`);var gk=`[cmdk-group=""]`,_k=`[cmdk-group-items=""]`,vk=`[cmdk-group-heading=""]`,yk=`[cmdk-item=""]`,bk=`${yk}:not([aria-disabled="true"])`,xk=`cmdk-item-select`,Sk=`data-value`,Ck=(e,t,n)=>oD(e,t,n),wk=F.createContext(void 0),Tk=()=>F.useContext(wk),Ek=F.createContext(void 0),Dk=()=>F.useContext(Ek),Ok=F.createContext(void 0),kk=F.forwardRef((e,t)=>{let n=Uk(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Uk(()=>new Set),i=Uk(()=>new Map),a=Uk(()=>new Map),o=Uk(()=>new Set),s=Vk(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=tC(),y=tC(),b=tC(),x=F.useRef(null),S=Kk();Hk(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Hk(()=>{S(6,k)},[]);let C=F.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=ee()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=F.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=ee();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??Ck;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;A().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(_k);t?t.appendChild(e.parentElement===t?e:e.closest(`${_k} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${_k} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${gk}[${Sk}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=A().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Sk);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=ee();t&&(t.parentElement?.firstChild===t&&((e=t.closest(gk)?.querySelector(vk))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function ee(){return x.current?.querySelector(`${yk}[aria-selected="true"]`)}function A(){return Array.from(x.current?.querySelectorAll(bk)||[])}function j(e){let t=A()[e];t&&C.setState(`value`,t.getAttribute(Sk))}function M(e){var t;let n=ee(),r=A(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(Sk))}function N(e){let t=ee()?.closest(gk),n;for(;t&&!n;)t=e>0?zk(t,gk):Bk(t,gk),n=t?.querySelector(bk);n?C.setState(`value`,n.getAttribute(Sk)):M(e)}let te=()=>j(A().length-1),ne=e=>{e.preventDefault(),e.metaKey?te():e.altKey?N(1):M(1)},re=e=>{e.preventDefault(),e.metaKey?j(0):e.altKey?N(-1):M(-1)};return F.createElement(jS.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&ne(e);break;case`ArrowDown`:ne(e);break;case`p`:case`k`:g&&e.ctrlKey&&re(e);break;case`ArrowUp`:re(e);break;case`Home`:e.preventDefault(),j(0);break;case`End`:e.preventDefault(),te();break;case`Enter`:{e.preventDefault();let t=ee();if(t){let e=new Event(xk);t.dispatchEvent(e)}}}}},F.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Yk},c),Jk(e,e=>F.createElement(Ek.Provider,{value:C},F.createElement(wk.Provider,{value:w},e))))}),Ak=F.forwardRef((e,t)=>{let n=tC(),r=F.useRef(null),i=F.useContext(Ok),a=Tk(),o=Vk(e),s=o.current?.forceMount??i?.forceMount;Hk(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Gk(n,r,[e.value,e.children,r],e.keywords),l=Dk(),u=Wk(e=>e.value&&e.value===c.current),d=Wk(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);F.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(xk,f),()=>t.removeEventListener(xk,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return F.createElement(jS.div,{ref:sS(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),jk=F.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=tC(),s=F.useRef(null),c=F.useRef(null),l=tC(),u=Tk(),d=Wk(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Hk(()=>u.group(o),[]),Gk(o,s,[e.value,e.heading,c]);let f=F.useMemo(()=>({id:o,forceMount:i}),[i]);return F.createElement(jS.div,{ref:sS(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&F.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Jk(e,e=>F.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},F.createElement(Ok.Provider,{value:f},e))))}),Mk=F.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=F.useRef(null),a=Wk(e=>!e.search);return!n&&!a?null:F.createElement(jS.div,{ref:sS(i,t),...r,"cmdk-separator":``,role:`separator`})}),Nk=F.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=Dk(),o=Wk(e=>e.search),s=Wk(e=>e.selectedItemId),c=Tk();return F.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),F.createElement(jS.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Pk=F.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=F.useRef(null),o=F.useRef(null),s=Wk(e=>e.selectedItemId),c=Tk();return F.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),F.createElement(jS.div,{ref:sS(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Jk(e,e=>F.createElement(`div`,{ref:sS(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Fk=F.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return F.createElement(tk,{open:n,onOpenChange:r},F.createElement(ak,{container:o},F.createElement(sk,{"cmdk-overlay":``,className:i}),F.createElement(dk,{"aria-label":e.label,"cmdk-dialog":``,className:a},F.createElement(kk,{ref:t,...s}))))}),Ik=F.forwardRef((e,t)=>Wk(e=>e.filtered.count===0)?F.createElement(jS.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Lk=F.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return F.createElement(jS.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Jk(e,e=>F.createElement(`div`,{"aria-hidden":!0},e)))}),Rk=Object.assign(kk,{List:Pk,Item:Ak,Input:Nk,Group:jk,Separator:Mk,Dialog:Fk,Empty:Ik,Loading:Lk});function zk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Bk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Vk(e){let t=F.useRef(e);return Hk(()=>{t.current=e}),t}var Hk=typeof window>`u`?F.useEffect:F.useLayoutEffect;function Uk(e){let t=F.useRef();return t.current===void 0&&(t.current=e()),t}function Wk(e){let t=Dk(),n=()=>e(t.snapshot());return F.useSyncExternalStore(t.subscribe,n,n)}function Gk(e,t,n,r=[]){let i=F.useRef(),a=Tk();return Hk(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(Sk,s),i.current=s}),i}var Kk=()=>{let[e,t]=F.useState(),n=Uk(()=>new Map);return Hk(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function qk(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Jk({asChild:e,children:t},n){return e&&F.isValidElement(t)?F.cloneElement(qk(t),{ref:t.ref},n(t.props.children)):n(t)}var Yk={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},Xk=Object.defineProperty,Zk=(e,t)=>Xk(e,`name`,{value:t,configurable:!0}),Qk=`Popover`,[$k,Uee]=fS(Qk,[bT]),eA=bT(),[tA,nA]=$k(Qk),rA=Zk(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=eA(t),c=F.useRef(null),[l,u]=F.useState(!1),[d,f]=eE({prop:r,defaultProp:i??!1,onChange:a,caller:Qk});return(0,I.jsx)(MT,{...s,children:(0,I.jsx)(tA,{scope:t,contentId:tC(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:F.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:F.useCallback(()=>u(!0),[]),onCustomAnchorRemove:F.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),iA=`PopoverTrigger`,aA=F.forwardRef(Zk(function(e,t){let{__scopePopover:n,...r}=e,i=nA(iA,n),a=eA(n),o=cS(t,i.triggerRef),s=(0,I.jsx)(jS.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":gA(i.open),...r,ref:o,onClick:$x(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,I.jsx)(NT,{asChild:!0,...a,children:s})},`PopoverTrigger`)),oA=`PopoverPortal`,[sA,cA]=$k(oA,{forceMount:void 0}),lA=Zk(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=nA(oA,t);return(0,I.jsx)(sA,{scope:t,forceMount:n,children:(0,I.jsx)(BT,{present:n||a.open,children:(0,I.jsx)(IT,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),uA=`PopoverContent`,dA=F.forwardRef(Zk(function(e,t){let n=cA(uA,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=nA(uA,e.__scopePopover);return(0,I.jsx)(BT,{present:r||a.open,children:a.modal?(0,I.jsx)(pA,{...i,ref:t}):(0,I.jsx)(mA,{...i,ref:t})})},`PopoverContent`)),fA=gS(`PopoverContent.RemoveScroll`),pA=F.forwardRef(Zk(function(e,t){let n=nA(uA,e.__scopePopover),r=F.useRef(null),i=cS(t,r),a=F.useRef(!1);return F.useEffect(()=>{let e=r.current;if(e)return JO(e)},[]),(0,I.jsx)(zO,{as:fA,allowPinchZoom:!0,children:(0,I.jsx)(hA,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:$x(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:$x(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:$x(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),mA=F.forwardRef(Zk(function(e,t){let n=nA(uA,e.__scopePopover),r=F.useRef(!1),i=F.useRef(!1);return(0,I.jsx)(hA,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),hA=F.forwardRef(Zk(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=nA(uA,n),p=eA(n);return kD(),(0,I.jsx)(fD,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,I.jsx)(US,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,I.jsx)(PT,{"data-state":gA(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`));function gA(e){return e?`open`:`closed`}Zk(gA,`getState`);var _A=rA,vA=aA,yA=lA,bA=dA,xA=_A,SA=vA;function CA({className:e,align:t=`start`,sideOffset:n=4,collisionPadding:r=8,...i}){return(0,I.jsx)(yA,{children:(0,I.jsx)(bA,{align:t,sideOffset:n,collisionPadding:r,className:q(Vx,`max-h-(--radix-popover-content-available-height) min-w-32 p-1`,e),...i})})}var wA=(0,F.createContext)(()=>{});function TA({open:e,defaultOpen:t=!1,onOpenChange:n,children:r,...i}){let[a,o]=(0,F.useState)(t),s=t=>{e===void 0&&o(t),n?.(t)};return(0,I.jsx)(xA,{open:e??a,onOpenChange:s,...i,children:(0,I.jsx)(wA.Provider,{value:()=>s(!1),children:r})})}var EA=SA;function DA({className:e,loop:t=!0,onEscapeKeyDown:n,children:r,...i}){return(0,I.jsx)(CA,{className:q(`flex max-w-(--radix-popover-content-available-width) min-w-56 flex-col p-0`,e),onEscapeKeyDown:e=>{n?.(e),e.stopPropagation()},...i,children:(0,I.jsx)(Rk,{loop:t,className:`flex min-h-0 flex-col`,children:r})})}function OA({className:e,...t}){return(0,I.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-2 border-b border-border-subtle px-3 text-icon`,children:[(0,I.jsx)(My,{size:14,className:`shrink-0`}),(0,I.jsx)(Nk,{className:q(`min-w-0 flex-1 appearance-none border-0 bg-transparent p-0 font-sans text-md text-text outline-none placeholder:text-text-tertiary`,e),...t})]})}function kA({className:e,...t}){return(0,I.jsx)(Pk,{className:q(Jx.combobox,Hx,`overflow-y-auto overscroll-contain p-1`,e),...t})}function AA({className:e,...t}){return(0,I.jsx)(Ik,{className:q(`px-2 py-1.5 text-sm text-text-tertiary`,e),...t})}var jA=Kx;function MA({heading:e,...t}){return(0,I.jsx)(jk,{heading:e===void 0?void 0:(0,I.jsx)(`span`,{className:jA,children:e}),...t})}var NA=q(Ux,Wx,`justify-between gap-3 aria-[current=true]:font-medium`);function PA({className:e,children:t,...n}){return(0,I.jsx)(Ak,{className:q(Ux,Wx,e),onMouseDown:e=>e.preventDefault(),...n,children:(0,I.jsx)(`span`,{className:`flex min-w-0 items-center gap-2 text-text-tertiary`,children:t})})}function FA({className:e,children:t,current:n=!1,onSelect:r,...i}){let a=(0,F.useContext)(wA);return(0,I.jsxs)(Ak,{"aria-current":n||void 0,className:q(NA,e),onSelect:e=>{r?.(e),a()},...i,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),n&&(0,I.jsx)(zy,{size:14,className:`shrink-0 text-text!`})]})}var IA={success:`bg-success`,warning:`bg-warning`,danger:`bg-danger`,accent:`bg-accent`,live:`bg-accent animate-breathe shadow-[0_0_0_3px_var(--color-accent-subtle)]`,neutral:`bg-icon`},LA={success:`text-success`,warning:`text-warning`,danger:`text-danger`,accent:`text-accent`,live:`text-accent`,neutral:`text-icon`};function RA({tone:e=`neutral`,label:t,className:n}){return(0,I.jsx)(`span`,{role:t?`img`:void 0,"aria-label":t,"aria-hidden":!t||void 0,title:t,className:q(`inline-block size-1.5 shrink-0 rounded-full`,IA[e],n)})}var zA={xs:{text:`text-xs`,box:`size-3.5 [&>svg]:size-3.5`},sm:{text:`text-sm`,box:`size-4 [&>svg]:size-4`}};function BA({tone:e=`neutral`,icon:t,phase:n,spinning:r=!1,size:i=`xs`,strong:a=!1,title:o,className:s,children:c}){let l=zA[i],u=r?(0,I.jsx)(UE,{size:`sm`}):n?(0,I.jsx)(Kb,{phase:n,size:i===`xs`?14:16,label:``}):t?(0,I.jsx)(`span`,{className:q(`inline-flex`,LA[e]),children:t}):(0,I.jsx)(RA,{tone:e});return(0,I.jsxs)(`span`,{title:o,className:q(`inline-flex min-w-0 items-center gap-1.5 whitespace-nowrap`,l.text,a?`font-medium text-text`:`text-text-secondary`,s),children:[(0,I.jsx)(`span`,{"aria-hidden":!0,className:q(`inline-flex shrink-0 items-center justify-center`,l.box),children:u}),(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:c})]})}function VA({className:e,children:t}){return(0,I.jsx)(`span`,{className:q(`inline-flex shrink-0 items-center rounded-sm bg-accent-subtle px-1.5 text-xs font-medium whitespace-nowrap text-accent-text`,e),children:t})}var HA={ok:`success`,warn:`warning`,danger:`danger`,idle:`neutral`};function UA({row:e}){return(0,I.jsxs)(`div`,{className:`flex min-h-7 items-center gap-2 text-sm`,children:[(0,I.jsx)(`span`,{className:`w-28 shrink-0 text-text-tertiary first-letter:uppercase`,children:e.key}),(0,I.jsx)(`span`,{className:`inline-flex size-4 shrink-0 items-center justify-center`,children:(0,I.jsx)(RA,{tone:HA[e.tone]})}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-text`,children:e.value})]})}function WA({children:e,count:t,action:n,className:r,id:i}){return(0,I.jsxs)(`div`,{id:i,className:q(`flex h-7 min-w-0 items-center gap-2 text-xs font-medium text-text-tertiary`,r),children:[(0,I.jsx)(`span`,{className:`truncate`,children:e}),t!=null&&(0,I.jsx)(`span`,{className:`font-normal text-text-tertiary tabular-nums`,children:t}),n&&(0,I.jsx)(`span`,{className:`ml-auto flex shrink-0 items-center`,children:n})]})}function GA({children:e}){return(0,I.jsx)(`span`,{className:`inline-flex min-h-4 min-w-4 shrink-0 items-center justify-center`,children:e})}function KA({href:e,onClick:t,current:n,title:r,label:i,expanded:a,className:o,children:s}){return e===void 0?(0,I.jsx)(`button`,{type:`button`,onClick:t,"aria-current":n?`page`:void 0,"aria-label":i,"aria-expanded":a,title:r,className:o,children:s}):(0,I.jsx)(`a`,{href:e,onClick:t,"aria-current":n?`page`:void 0,"aria-label":i,title:r,className:q(o,`no-underline`),children:s})}function qA({icon:e,phase:t,label:n,meta:r,dot:i,active:a=!1,href:o,onClick:s,actions:c,onContextMenu:l,onDoubleClick:u,tone:d=`default`,title:f,className:p}){let m=d===`quiet`,h=r!=null,g=t?(0,I.jsx)(Kb,{phase:t}):e?(0,I.jsx)(`span`,{className:q(`inline-flex [&>svg]:size-4`,a?`text-text`:`text-icon group-hover/nav:text-text`),children:e}):null;return(0,I.jsxs)(`div`,{onContextMenu:l,onDoubleClick:u,className:q(`group/nav relative flex min-w-0 shrink-0 items-center rounded-lg`,`transition-colors duration-(--dur-1) ease-app`,m?`h-7`:`h-(--row-h)`,a?`card text-text`:m?`text-text-tertiary hover:bg-surface-hover hover:text-text-secondary`:`text-text-secondary hover:bg-surface-hover hover:text-text`,p),children:[(0,I.jsxs)(KA,{href:o,onClick:s,current:a,title:f??(typeof n==`string`?n:void 0),className:q(`flex h-full min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-[inherit] pr-3 text-left text-inherit`,m?`pl-8.5 text-xs`:`pl-2.5 text-md`,a&&`font-medium`),children:[g&&(0,I.jsx)(GA,{children:g}),(0,I.jsx)(`span`,{className:`min-w-0 flex-auto truncate`,children:n}),(i||h)&&(0,I.jsxs)(`span`,{className:q(`flex min-w-0 items-center gap-2`,c!=null&&`transition-opacity duration-(--dur-1) group-focus-within/nav:opacity-0 group-hover/nav:opacity-0 group-has-[[aria-expanded=true]]/nav:opacity-0`),children:[i&&(0,I.jsx)(RA,{tone:i}),h&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-xs font-normal text-text-tertiary tabular-nums`,children:r})]})]}),c&&(0,I.jsx)(`span`,{className:q(`absolute top-1/2 right-1 flex -translate-y-1/2 items-center gap-0.5`,`opacity-0 transition-opacity duration-(--dur-1) group-focus-within/nav:opacity-100 group-hover/nav:opacity-100`,`has-[[aria-expanded=true]]:opacity-100`),children:c})]})}function JA({leading:e,title:t,subtitle:n,description:r,wrap:i=!1,meta:a,onClick:o,href:s,tooltip:c,label:l,expanded:u,control:d,actions:f,actionsOverlay:p=!1,active:m=!1,index:h,animate:g=!1,as:_=`div`,className:v}){let y=o!==void 0||s!==void 0,b=h!==void 0&&h<8,x=i||r!==void 0,S=a!=null,C=p&&!!f,w=S&&(0,I.jsx)(`span`,{className:q(`shrink-0 text-xs text-text-tertiary tabular-nums`,i&&`mt-0.5 self-start`,C&&`transition-opacity duration-(--dur-1) group-focus-within/row:opacity-0 group-hover/row:opacity-0`),children:a}),T=(0,I.jsxs)(I.Fragment,{children:[e&&(0,I.jsx)(`span`,{className:q(`inline-flex shrink-0`,x&&`mt-0.5 self-start`),children:(0,I.jsx)(GA,{children:(0,I.jsx)(`span`,{className:`inline-flex text-icon [&>svg]:size-4`,children:e})})}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsxs)(`span`,{className:i?`min-w-0 text-pretty wrap-anywhere`:`min-w-0 truncate`,children:[t,n&&(0,I.jsx)(`span`,{className:`ml-2 text-text-tertiary`,children:n})]}),r!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-xs text-text-tertiary`,children:r})]}),!d&&w]}),E=q(`flex min-h-(--list-row-h) min-w-0 flex-1 gap-3 rounded-[inherit] px-3 text-left text-md text-text`,i?`items-start`:`items-center`,x&&`py-2.5`);return(0,I.jsxs)(_,{"data-list-row":``,style:b?{"--i":h}:void 0,className:q(`group/row relative flex min-w-0 items-center rounded-lg transition-colors duration-(--dur-1) ease-app`,`list-none`,m?`card`:y&&`hover:bg-surface-hover`,(b||g)&&`animate-rise-in`,b&&`[animation-delay:calc(var(--i)*20ms)]`,v),children:[y?(0,I.jsx)(KA,{href:s,onClick:o,current:m,title:c,label:l,expanded:u,className:q(E,`cursor-pointer`),children:T}):(0,I.jsx)(`div`,{className:E,children:T}),d&&(0,I.jsx)(`span`,{className:`flex min-w-0 shrink items-center`,children:d}),d&&S&&(0,I.jsx)(`span`,{className:`flex shrink-0 items-center pr-3 pl-3`,children:w}),f&&(0,I.jsx)(`span`,{className:q(`flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity duration-(--dur-1)`,`group-focus-within/row:opacity-100 group-hover/row:opacity-100 has-[[aria-expanded=true]]:opacity-100`,C?q(`absolute right-2 rounded-md bg-inherit pl-1`,i?`top-1.5`:`top-1/2 -translate-y-1/2`):`mr-2`),children:f})]})}function YA({divided:e=!1,label:t,className:n,children:r}){return(0,I.jsx)(`div`,{"aria-label":t,className:q(`flex flex-col`,e&&`[&>[data-list-row]]:rounded-none [&>[data-list-row]]:border-b [&>[data-list-row]]:border-border-subtle [&>[data-list-row]:last-child]:border-b-0`,n),children:r})}function XA({items:e,className:t}){return(0,I.jsx)(`dl`,{className:q(`m-0 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-6 gap-y-1.5 text-sm`,t),children:e.map((e,t)=>{let n=e.leading??(e.phase?(0,I.jsx)(Kb,{phase:e.phase,size:14,label:``}):e.tone?(0,I.jsx)(RA,{tone:e.tone}):null);return(0,I.jsxs)(`div`,{className:`contents`,children:[(0,I.jsx)(`dt`,{className:`flex min-h-6 items-center text-text-tertiary`,children:e.label}),(0,I.jsxs)(`dd`,{className:`m-0 flex min-h-6 min-w-0 items-center gap-2 text-text`,children:[n&&(0,I.jsx)(`span`,{className:`inline-flex size-4 shrink-0 items-center justify-center text-icon [&>svg]:size-3.5`,children:n}),(0,I.jsx)(`span`,{className:q(`min-w-0`,e.mono?`truncate font-mono text-xs text-text-secondary`:`font-medium`),children:e.value}),e.sub&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-text-tertiary`,children:e.sub})]})]},t)})})}function ZA({items:e,className:t}){return(0,I.jsx)(`div`,{className:q(`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-text-tertiary`,t),children:e.map((e,t)=>{if(!e)return null;let n=e.phase?(0,I.jsx)(Kb,{phase:e.phase,size:14,label:``}):e.tone?(0,I.jsx)(RA,{tone:e.tone}):e.icon?(0,I.jsx)(`span`,{className:q(`inline-flex [&>svg]:size-3.5`,LA.neutral),children:e.icon}):null;return(0,I.jsxs)(`span`,{title:e.title,className:`inline-flex min-w-0 items-center gap-1.5`,children:[n,e.strong!==void 0&&(0,I.jsx)(`span`,{className:`font-medium text-text-secondary`,children:e.strong}),e.text!==void 0&&(0,I.jsx)(`span`,{className:q(`min-w-0 truncate`,e.mono&&`font-mono`),children:e.text})]},t)})})}var QA=Object.defineProperty,$A=(e,t)=>QA(e,`name`,{value:t,configurable:!0});function ej(e){let t=e+`CollectionProvider`,[n,r]=fS(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=$A(e=>{let{scope:t,children:n}=e,r=F.useRef(null),a=F.useRef(new Map).current;return(0,I.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=gS(s),l=F.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=cS(t,a(s,n).collectionRef);return(0,I.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=gS(u),p=F.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=F.useRef(null),s=cS(t,o),c=a(u,n);return F.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,I.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return F.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return $A(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}$A(ej,`createCollection`);var tj=new WeakMap,nj=class e extends Map{static{$A(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],tj.set(this,!0)}set(e,t){return tj.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=aj(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=rj(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=rj(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return rj(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function rj(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=ij(e,t);return n===-1?void 0:e[n]}$A(rj,`at`);function ij(e,t){let n=e.length,r=aj(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}$A(ij,`toSafeIndex`);function aj(e){return e!==e||e===0?0:Math.trunc(e)}$A(aj,`toSafeInteger`);function oj(e){let t=e+`CollectionProvider`,[n,r]=fS(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new nj,setItemMap:$A(()=>void 0,`setItemMap`)}),o=$A(({state:e,...t})=>e?(0,I.jsx)(c,{...t,state:e}):(0,I.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=$A(e=>{let t=h();return(0,I.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=$A(e=>{let{scope:t,children:n,state:r}=e,a=F.useRef(null),[o,s]=F.useState(null),c=cS(a,s),[l,u]=r;return F.useEffect(()=>{if(!o)return;let e=uj(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,I.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=gS(l),d=F.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=cS(t,a(l,n).collectionRef);return(0,I.jsx)(u,{ref:i,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=gS(f),m=F.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=F.useRef(null),[s,c]=F.useState(null),l=cS(t,o,c),{setItemMap:u}=a(f,n),d=F.useRef(i);sj(d.current,i)||(d.current=i);let m=d.current;return F.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(lj):(t.set(s,{...e,element:s}),t.toSorted(lj)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new nj(e)))}},[s,m,u]),(0,I.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return F.useState(new nj)}$A(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return $A(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}$A(oj,`createCollection`);function sj(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}$A(sj,`shallowEqual`);function cj(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}$A(cj,`isElementPreceding`);function lj(e,t){return!e[1].element||!t[1].element?0:cj(e[1].element,t[1].element)?-1:1}$A(lj,`sortByDocumentPosition`);function uj(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}$A(uj,`getChildListObserver`);var dj=Object.defineProperty,fj=(e,t)=>dj(e,`name`,{value:t,configurable:!0}),pj=F.createContext(void 0);function mj(e){let t=F.useContext(pj);return e||t||`ltr`}fj(mj,`useDirection`);var hj=Object.defineProperty,gj=(e,t)=>hj(e,`name`,{value:t,configurable:!0}),_j=!1;function vj(){let[e,t]=F.useState(_j);return F.useEffect(()=>{_j||(_j=!0,t(!0))},[]),e}gj(vj,`useIsHydrated`);var yj=F.useSyncExternalStore;function bj(){return()=>{}}gj(bj,`subscribe`);function xj(){return yj(bj,()=>!0,()=>!1)}gj(xj,`useIsHydratedModern`);var Sj=typeof yj==`function`?xj:vj,Cj=Object.defineProperty,wj=(e,t)=>Cj(e,`name`,{value:t,configurable:!0}),Tj=`rovingFocusGroup.onEntryFocus`,Ej={bubbles:!1,cancelable:!0},Dj=`RovingFocusGroup`,[Oj,kj,Aj]=ej(Dj),[jj,Mj]=fS(Dj,[Aj]),[Nj,Pj]=jj(Dj),Fj=F.forwardRef(wj(function(e,t){return(0,I.jsx)(Oj.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,I.jsx)(Oj.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,I.jsx)(Ij,{...e,ref:t})})})},`RovingFocusGroup`)),Ij=F.forwardRef(wj(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=F.useRef(null),p=cS(t,f),m=mj(a),[h,g]=eE({prop:o,defaultProp:s??null,onChange:c,caller:Dj}),[_,v]=F.useState(!1),y=FS(l),b=kj(n),x=F.useRef(!1),[S,C]=F.useState(0);return F.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Tj,y),()=>e.removeEventListener(Tj,y)},[y]),(0,I.jsx)(Nj,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:F.useCallback(e=>g(e),[g]),onItemShiftTab:F.useCallback(()=>v(!0),[]),onFocusableItemAdd:F.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:F.useCallback(()=>C(e=>e-1),[]),children:(0,I.jsx)(jS.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:$x(e.onMouseDown,()=>{x.current=!0}),onFocus:$x(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Tj,Ej);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);Hj([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:$x(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),Lj=`RovingFocusGroupItem`,Rj=F.forwardRef(wj(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=tC(),l=a||c,u=Pj(Lj,n),d=u.currentTabStopId===l,f=kj(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=Sj();return XS(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),F.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,I.jsx)(Oj.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,I.jsx)(jS.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:$x(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:$x(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:$x(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Vj(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Uj(n,r+1):n.slice(r+1)}setTimeout(()=>Hj(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),zj={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Bj(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}wj(Bj,`getDirectionAwareKey`);function Vj(e,t,n){let r=Bj(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return zj[r]}wj(Vj,`getFocusIntent`);function Hj(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}wj(Hj,`focusFirst`);function Uj(e,t){return e.map((n,r)=>e[(t+r)%e.length])}wj(Uj,`wrapArray`);var Wj=Fj,Gj=Rj,Kj=Object.defineProperty,qj=(e,t)=>Kj(e,`name`,{value:t,configurable:!0}),Jj=[`Enter`,` `],Yj=[`ArrowDown`,`PageUp`,`Home`],Xj=[`ArrowUp`,`PageDown`,`End`],Zj=[...Yj,...Xj];[...Jj],[...Jj];var Qj=`Menu`,[$j,eM,tM]=ej(Qj),[nM,rM]=fS(Qj,[tM,bT,Mj]),iM=bT(),aM=Mj(),[oM,sM]=nM(Qj),[cM,lM]=nM(Qj),uM=qj(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=iM(t),[c,l]=F.useState(null),u=F.useRef(!1),d=FS(a),f=mj(i);return F.useEffect(()=>{let e=qj(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=qj(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),F.useEffect(()=>{if(!n)return;let e=qj(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,I.jsx)(MT,{...s,children:(0,I.jsx)(oM,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,I.jsx)(cM,{scope:t,onClose:F.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),dM=F.forwardRef(qj(function(e,t){let{__scopeMenu:n,...r}=e,i=iM(n);return(0,I.jsx)(NT,{...i,...r,ref:t})},`MenuAnchor`)),fM=`MenuPortal`,[pM,mM]=nM(fM,{forceMount:void 0}),hM=qj(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=sM(fM,t);return(0,I.jsx)(pM,{scope:t,forceMount:n,children:(0,I.jsx)(BT,{present:n||a.open,children:(0,I.jsx)(IT,{asChild:!0,container:i,children:r})})})},`MenuPortal`),gM=`MenuContent`,[_M,vM]=nM(gM),yM=F.forwardRef(qj(function(e,t){let n=mM(gM,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=sM(gM,e.__scopeMenu),o=lM(gM,e.__scopeMenu);return(0,I.jsx)($j.Provider,{scope:e.__scopeMenu,children:(0,I.jsx)(BT,{present:r||a.open,children:(0,I.jsx)($j.Slot,{scope:e.__scopeMenu,children:o.modal?(0,I.jsx)(bM,{...i,ref:t}):(0,I.jsx)(xM,{...i,ref:t})})})})},`MenuContent`)),bM=F.forwardRef(qj(function(e,t){let n=sM(gM,e.__scopeMenu),r=F.useRef(null),i=cS(t,r);return F.useEffect(()=>{let e=r.current;if(e)return JO(e)},[]),(0,I.jsx)(CM,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:$x(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),xM=F.forwardRef(qj(function(e,t){let n=sM(gM,e.__scopeMenu);return(0,I.jsx)(CM,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),SM=gS(`MenuContent.ScrollLock`),CM=F.forwardRef(qj(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=sM(gM,n),_=lM(gM,n),v=iM(n),y=aM(n),b=eM(n),[x,S]=F.useState(null),C=F.useRef(null),w=cS(t,C,g.onContentChange),T=F.useRef(0),E=F.useRef(``),D=F.useRef(0),O=F.useRef(null),k=F.useRef(`right`),ee=F.useRef(0),A=m?zO:F.Fragment,j=m?{as:SM,allowPinchZoom:!0}:void 0,M=qj(e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=FM(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;qj((function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);F.useEffect(()=>()=>window.clearTimeout(T.current),[]),kD();let N=F.useCallback(e=>k.current===O.current?.side&&LM(e,O.current?.area),[]);return(0,I.jsx)(_M,{scope:n,searchRef:E,onItemEnter:F.useCallback(e=>{N(e)&&e.preventDefault()},[N]),onItemLeave:F.useCallback(e=>{N(e)||(C.current?.focus(),S(null))},[N]),onTriggerLeave:F.useCallback(e=>{N(e)&&e.preventDefault()},[N]),pointerGraceTimerRef:D,onPointerGraceIntentChange:F.useCallback(e=>{O.current=e},[]),children:(0,I.jsx)(A,{...j,children:(0,I.jsx)(fD,{asChild:!0,trapped:i,onMountAutoFocus:$x(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,I.jsx)(US,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,I.jsx)(Wj,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:$x(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,I.jsx)(PT,{role:`menu`,"aria-orientation":`vertical`,"data-state":AM(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:$x(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&M(e.key));let i=C.current;if(e.target!==i||!Zj.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);Xj.includes(e.key)&&a.reverse(),NM(a)}),onBlur:$x(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:$x(e.onPointerMove,RM(e=>{let t=e.target,n=ee.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>ee.current?`right`:`left`;k.current=t,ee.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),wM=F.forwardRef(qj(function(e,t){let{__scopeMenu:n,...r}=e;return(0,I.jsx)(jS.div,{...r,ref:t})},`MenuLabel`)),TM=`MenuItem`,EM=`menu.itemSelect`,DM=F.forwardRef(qj(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=F.useRef(null),o=lM(TM,e.__scopeMenu),s=vM(TM,e.__scopeMenu),c=cS(t,a),l=F.useRef(!1),u=qj(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(EM,{bubbles:!0,cancelable:!0});e.addEventListener(EM,e=>r?.(e),{once:!0}),MS(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,I.jsx)(OM,{...i,ref:c,disabled:n,onClick:$x(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:$x(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:$x(e.onKeyDown,e=>{n||e.target!==e.currentTarget||s.searchRef.current!==``&&e.key===` `||Jj.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),OM=F.forwardRef(qj(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=vM(TM,n),s=aM(n),c=F.useRef(null),l=cS(t,c),[u,d]=F.useState(!1),[f,p]=F.useState(``);return F.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,I.jsx)($j.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,I.jsx)(Gj,{asChild:!0,...s,focusable:!r,children:(0,I.jsx)(jS.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:$x(e.onPointerMove,RM(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:$x(e.onPointerLeave,RM(e=>o.onItemLeave(e))),onFocus:$x(e.onFocus,()=>d(!0)),onBlur:$x(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[Wee,Gee]=nM(`MenuRadioGroup`,{value:void 0,onValueChange:qj(()=>{},`onValueChange`)}),[Kee,qee]=nM(`MenuItemIndicator`,{checked:!1}),kM=F.forwardRef(qj(function(e,t){let{__scopeMenu:n,...r}=e;return(0,I.jsx)(jS.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[Jee,Yee]=nM(`MenuSub`);function AM(e){return e?`open`:`closed`}qj(AM,`getOpenState`);function jM(e){return e===`indeterminate`}qj(jM,`isIndeterminate`);function MM(e){return jM(e)?`indeterminate`:e?`checked`:`unchecked`}qj(MM,`getCheckedState`);function NM(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}qj(NM,`focusFirst`);function PM(e,t){return e.map((n,r)=>e[(t+r)%e.length])}qj(PM,`wrapArray`);function FM(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=PM(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}qj(FM,`getNextMatch`);function IM(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}qj(IM,`isPointInPolygon`);function LM(e,t){return t?IM({x:e.clientX,y:e.clientY},t):!1}qj(LM,`isPointerInGraceArea`);function RM(e){return t=>t.pointerType===`mouse`?e(t):void 0}qj(RM,`whenMouse`);var zM=uM,BM=dM,VM=hM,HM=yM,Xee=wM,UM=DM,WM=kM,GM=Object.defineProperty,KM=(e,t)=>GM(e,`name`,{value:t,configurable:!0}),qM=`DropdownMenu`,[JM,Zee]=fS(qM,[rM]),YM=rM(),[XM,ZM]=JM(qM),QM=KM(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=YM(t),l=F.useRef(null),[u,d]=eE({prop:i,defaultProp:a??!1,onChange:o,caller:qM});return(0,I.jsx)(XM,{scope:t,triggerId:tC(),triggerRef:l,contentId:tC(),open:u,onOpenChange:d,onOpenToggle:F.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,I.jsx)(zM,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),$M=`DropdownMenuTrigger`,eN=F.forwardRef(KM(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ZM($M,n),o=YM(n),s=cS(t,a.triggerRef);return(0,I.jsx)(BM,{asChild:!0,...o,children:(0,I.jsx)(jS.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:$x(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:$x(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),tN=KM(e=>{let{__scopeDropdownMenu:t,...n}=e,r=YM(t);return(0,I.jsx)(VM,{...r,...n})},`DropdownMenuPortal`),nN=`DropdownMenuContent`,rN=F.forwardRef(KM(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ZM(nN,n),a=YM(n),o=F.useRef(!1);return(0,I.jsx)(HM,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:$x(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:$x(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),iN=F.forwardRef(KM(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=YM(n);return(0,I.jsx)(Xee,{...i,...r,ref:t})},`DropdownMenuLabel`)),aN=F.forwardRef(KM(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=YM(n);return(0,I.jsx)(UM,{...i,...r,ref:t})},`DropdownMenuItem`)),oN=F.forwardRef(KM(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=YM(n);return(0,I.jsx)(WM,{...i,...r,ref:t})},`DropdownMenuSeparator`)),sN=QM,cN=eN,lN=tN,uN=rN,dN=iN,fN=aN,pN=oN;function mN({modal:e=!1,...t}){return(0,I.jsx)(sN,{modal:e,...t})}var hN=cN;function gN({className:e,align:t=`start`,sideOffset:n=4,collisionPadding:r=8,onEscapeKeyDown:i,...a}){return(0,I.jsx)(lN,{children:(0,I.jsx)(uN,{align:t,sideOffset:n,collisionPadding:r,onEscapeKeyDown:e=>{i?.(e),e.stopPropagation()},className:q(Vx,Jx.dropdown,Hx,`min-w-48 p-1`,e),...a})})}function _N({className:e,tone:t=`default`,icon:n,kbd:r,children:i,...a}){return(0,I.jsxs)(fN,{className:q(Ux,t===`danger`?Gx:Wx,e),...a,children:[n,r?(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i}):i,r&&(0,I.jsx)(Yx,{className:`ml-auto`,children:r})]})}function vN({className:e,...t}){return(0,I.jsx)(dN,{className:q(Kx,e),...t})}function yN({className:e,...t}){return(0,I.jsx)(pN,{className:q(qx,e),...t})}function bN({variant:e=`secondary`,size:t=`md`,icon:n,disabled:r=!1,loading:i=!1,title:a,onClick:o,menu:s,picker:c,menuLabel:l,className:u,children:d}){let f=(0,I.jsx)(J,{variant:e,size:t,attached:`end`,"aria-label":l,title:l,disabled:r||i,icon:(0,I.jsx)(Uy,{})});return(0,I.jsxs)(`span`,{className:q(`inline-flex shrink-0 items-stretch gap-px`,u),children:[(0,I.jsx)(J,{variant:e,size:t,icon:n,attached:`start`,loading:i,disabled:r,title:a,onClick:o,children:d}),c?(0,I.jsxs)(TA,{children:[(0,I.jsx)(EA,{asChild:!0,children:f}),c]}):(0,I.jsxs)(mN,{children:[(0,I.jsx)(hN,{asChild:!0,children:f}),(0,I.jsx)(gN,{align:`end`,children:s})]})]})}var xN={sm:`h-(--control-sm) px-2 text-sm`,md:`h-(--control-h) px-3 text-sm`};function SN({items:e,value:t,onChange:n,size:r=`md`,label:i,className:a}){let o=(0,F.useRef)([]),s=e.map((e,t)=>e.disabled?-1:t).filter(e=>e>=0);return(0,I.jsx)(`div`,{role:`tablist`,"aria-label":i,onKeyDown:r=>{let i=e.findIndex(e=>e.id===t),a=s.indexOf(i),c;if(r.key===`ArrowRight`?c=s[(a+1)%s.length]:r.key===`ArrowLeft`?c=s[(a-1+s.length)%s.length]:r.key===`Home`?c=s[0]:r.key===`End`&&(c=s[s.length-1]),c===void 0)return;r.preventDefault();let l=e[c];l&&(n(l.id),o.current[c]?.focus())},className:q(`flex items-center gap-0.5`,a),children:e.map((e,i)=>{let a=e.id===t,s=(0,I.jsxs)(`button`,{ref:e=>{o.current[i]=e},type:`button`,role:`tab`,"aria-selected":a,"aria-controls":e.panelId,tabIndex:a?0:-1,disabled:e.disabled,onClick:()=>n(e.id),className:q(`inline-flex shrink-0 cursor-pointer items-center gap-1.5 rounded-lg font-medium whitespace-nowrap`,`transition-colors duration-(--dur-1) ease-app disabled:cursor-not-allowed disabled:text-text-disabled`,xN[r],a?`card text-text`:`text-text-tertiary enabled:hover:bg-surface-hover enabled:hover:text-text`),children:[e.icon&&(0,I.jsx)(`span`,{className:q(`inline-flex [&>svg]:size-3.5`,a?`text-text`:`text-icon`),children:e.icon}),e.label,e.count!==void 0&&e.count!==null&&(0,I.jsx)(`span`,{className:`text-xs font-normal text-text-tertiary tabular-nums`,children:e.count})]},e.id);return e.tooltip?(0,I.jsx)(OE,{label:e.tooltip,children:s},e.id):s})})}var CN=`h-(--control-h) w-full min-w-0 rounded-md border border-border bg-surface-inset px-2.5 text-sm text-text transition-colors duration-(--dur-1) ease-app placeholder:text-text-tertiary hover:border-border-strong focus:border-accent disabled:cursor-not-allowed disabled:text-text-disabled aria-invalid:border-danger`,wN=`flex min-w-0 items-center gap-2 rounded-md border border-border bg-surface-inset pr-1.5 pl-2.5 cursor-text transition-colors duration-(--dur-1) ease-app hover:border-border-strong focus-within:border-accent focus-within:outline-2 focus-within:-outline-offset-1 focus-within:outline-focus-ring has-[input:disabled]:cursor-not-allowed has-[input[aria-invalid=true]]:border-danger`,TN={md:`h-(--control-h)`,lg:`h-(--control-lg)`};function EN({icon:e,kbd:t,size:n=`md`,mono:r=!1,invalid:i,className:a,inputClassName:o,trailing:s,type:c=`text`,...l}){return(0,I.jsxs)(`div`,{className:q(wN,TN[n],a),children:[e&&(0,I.jsx)(`span`,{className:`inline-flex shrink-0 text-icon [&>svg]:size-3.5`,children:e}),(0,I.jsx)(`input`,{type:c,"data-field-input":``,"aria-invalid":i||void 0,className:q(`h-full min-w-0 flex-1 appearance-none border-0 bg-transparent p-0 text-text outline-none`,`placeholder:text-text-tertiary disabled:cursor-not-allowed disabled:text-text-disabled`,r?`font-mono text-xs`:`font-sans text-sm`,o),...l}),s,t&&(0,I.jsx)(Yx,{children:t})]})}function DN({size:e=`lg`,placeholder:t=`Search`,...n}){return(0,I.jsx)(EN,{icon:(0,I.jsx)(My,{}),size:e,placeholder:t,"aria-label":n[`aria-label`]??t,...n})}function ON({mono:e=!1,invalid:t,className:n,rows:r=4,...i}){return(0,I.jsx)(`textarea`,{rows:r,"aria-invalid":t||void 0,className:q(`block w-full min-w-0 resize-y rounded-md border border-border bg-surface-inset px-2.5 py-1.5`,`text-text transition-colors duration-(--dur-1) ease-app`,`placeholder:text-text-tertiary hover:border-border-strong focus:border-accent`,`disabled:cursor-not-allowed disabled:text-text-disabled aria-invalid:border-danger`,e?`font-mono text-xs leading-[18px]`:`font-sans text-sm`,n),...i})}function kN({label:e,labelAside:t,help:n,error:r,htmlFor:i,layout:a=`flex flex-col gap-1.5`,children:o}){let s=(0,F.useId)(),c=(0,F.isValidElement)(o)?o:null,l=c?.props.id??i??s,u=`${l}-help`,d=`${l}-error`,f=q(n?u:null,r?d:null)||void 0,p=(0,I.jsx)(`label`,{className:`text-sm font-medium text-text-secondary`,htmlFor:l,children:e});return(0,I.jsxs)(`div`,{className:a,children:[t?(0,I.jsxs)(`div`,{className:`flex min-h-(--control-h) items-center gap-1.5`,children:[p,t]}):p,c?(0,F.cloneElement)(c,{id:l,"aria-describedby":q(c.props[`aria-describedby`],f)||void 0}):o,n&&(0,I.jsx)(`div`,{id:u,className:`text-xs text-text-tertiary`,children:n}),r&&(0,I.jsx)(`div`,{id:d,role:`alert`,className:`text-xs text-danger-text`,children:r})]})}function AN({items:e,className:t,trail:n}){return(0,I.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:q(`flex min-w-0 items-center`,t),children:(0,I.jsx)(`ol`,{className:`m-0 flex min-w-0 list-none items-center gap-1 p-0 text-sm`,children:e.map((t,r)=>{let i=r===e.length-1,a=n&&e.length>1,o=a?r===e.length-2:i,s=(0,I.jsxs)(I.Fragment,{children:[t.icon&&(0,I.jsx)(`span`,{className:`inline-flex shrink-0 text-icon [&>svg]:size-3.5`,children:t.icon}),(0,I.jsx)(`span`,{className:q(`truncate`,t.mono&&`font-mono text-xs`),children:t.label})]}),c=q(`inline-flex min-w-0 items-center gap-1.5 rounded-md px-1 py-0.5`,o?`font-medium text-text`:a&&i?`text-text-secondary`:`text-text-tertiary`,!i&&`shrink-0`);return(0,I.jsxs)(`li`,{className:q(`flex min-w-0 items-center gap-1`,!i&&`shrink-0`),children:[i?(0,I.jsx)(`span`,{"aria-current":`page`,className:c,children:s}):t.href===void 0?t.onClick?(0,I.jsx)(`button`,{type:`button`,onClick:t.onClick,className:q(c,`cursor-pointer hover:text-text`),children:s}):(0,I.jsx)(`span`,{className:c,children:s}):(0,I.jsx)(`a`,{href:t.href,onClick:t.onClick,className:q(c,`no-underline hover:text-text`),children:s}),!i&&(0,I.jsx)(Wy,{size:12,className:`shrink-0 text-text-disabled`})]},r)})})})}var jN=(0,F.createContext)(null);function MN({leading:e,crumbs:t,trail:n,status:r,tabs:i,actions:a,className:o}){let s=(0,F.useContext)(jN);return(0,I.jsxs)(`header`,{className:q(`flex h-(--topbar-h) shrink-0 items-center gap-3 border-b border-border-subtle pr-3`,s?`pl-2`:`pl-4`,o),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[s,e,t&&(0,I.jsx)(AN,{items:t,trail:n,className:r?`shrink-0 max-w-[60%]`:void 0}),r&&(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:r})]}),i&&(0,I.jsx)(`div`,{className:`flex shrink-0 items-center`,children:i}),a&&(0,I.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:a})]})}var NN={default:`max-w-(--content-max)`,wide:`max-w-(--content-wide)`};function PN({width:e=`default`,routeKey:t,className:n,children:r}){return(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,I.jsx)(`div`,{className:q(`mx-auto w-full px-8 pt-12 pb-16 animate-rise-in`,NN[e],n),children:r},t)})}function FN({title:e,meta:t,actions:n,className:r,children:i}){return(0,I.jsxs)(`header`,{className:q(`flex flex-col`,r),children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,I.jsx)(`h1`,{className:`m-0 min-w-0 flex-1 text-xl font-semibold text-pretty text-text`,children:e}),n&&(0,I.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:n})]}),t!=null&&(0,I.jsx)(`div`,{className:`mt-2`,children:Array.isArray(t)?(0,I.jsx)(ZA,{items:t}):t}),i&&(0,I.jsx)(`div`,{className:`mt-5`,children:i})]})}function IN({title:e,action:t,id:n,className:r,children:i}){return(0,I.jsxs)(`section`,{id:n,className:q(`mt-10 first:mt-0`,r),children:[(e||t)&&(0,I.jsxs)(`div`,{className:`mb-3 flex min-h-7 items-center gap-3`,children:[e&&(0,I.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 text-lg font-semibold text-text`,children:e}),t&&(0,I.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:t})]}),i]})}function LN({title:e,label:t,onClose:n,actions:r,className:i,bodyClassName:a,children:o}){return(0,I.jsxs)(`aside`,{"aria-label":t??(typeof e==`string`?e:void 0),className:q(`flex h-full w-(--aside-w) min-w-0 shrink-0 flex-col border-l border-border bg-surface animate-slide-in-right`,i),children:[(0,I.jsxs)(`div`,{className:`flex h-(--topbar-h) shrink-0 items-center gap-2 border-b border-border-subtle pr-2 pl-4`,children:[(0,I.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-text`,children:e}),r,(0,I.jsx)(Y,{label:`Close`,size:`sm`,icon:(0,I.jsx)(By,{}),onClick:n})]}),(0,I.jsx)(`div`,{className:q(`min-h-0 flex-1 overflow-y-auto`,a),children:o})]})}function RN({aside:e,className:t,asideClassName:n,children:r}){let i=!(e==null||e===!1);return(0,I.jsxs)(`div`,{className:`@container relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,I.jsx)(`div`,{className:q(`flex min-h-0 min-w-0 flex-1 flex-col`,t),children:r}),i&&(0,I.jsx)(`div`,{className:q(`flex h-full shrink-0 @max-4xl:absolute @max-4xl:inset-y-0 @max-4xl:right-0 @max-4xl:z-20 @max-4xl:h-auto @max-4xl:shadow-dialog`,n),children:e})]})}var zN={sm:`h-(--control-sm) text-xs`,md:`h-(--control-h) text-sm`};function BN({items:e,value:t,onChange:n,label:r,size:i=`md`,id:a,className:o}){let s=(0,F.useRef)([]),c=Math.max(0,e.findIndex(e=>e.value===t)),l=(t,r)=>{let i=e.map((e,t)=>e.disabled?-1:t).filter(e=>e>=0);if(i.length===0)return;let a;a=r===`first`?i[0]:r===`last`?i[i.length-1]:i[(i.indexOf(t)+r+i.length)%i.length],s.current[a]?.focus(),n(e[a].value)},u=(e,t)=>{let n=e.key===`ArrowRight`||e.key===`ArrowDown`?1:e.key===`ArrowLeft`||e.key===`ArrowUp`?-1:e.key===`Home`?`first`:e.key===`End`?`last`:null;n!==null&&(e.preventDefault(),l(t,n))};return(0,I.jsx)(`div`,{id:a,role:`radiogroup`,"aria-label":r,className:q(`inline-flex rounded-md border border-border bg-surface-inset p-0.5`,o),children:(0,I.jsxs)(`div`,{className:`relative grid w-full`,style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,"data-segment-thumb":``,className:`pointer-events-none absolute inset-y-0 left-0 rounded-[5px] bg-surface-selected shadow-popover transition-transform duration-(--dur-2) ease-out-app`,style:{width:`${100/e.length}%`,transform:`translateX(${c*100}%)`}}),e.map((e,t)=>{let r=t===c;return(0,I.jsxs)(`button`,{ref:e=>{s.current[t]=e},type:`button`,role:`radio`,"aria-checked":r,tabIndex:r?0:-1,disabled:e.disabled,onClick:()=>n(e.value),onKeyDown:e=>u(e,t),className:q(`relative inline-flex min-w-0 cursor-pointer items-center justify-center gap-1.5 rounded-[5px] px-2.5 font-medium`,`transition-colors duration-(--dur-1) ease-app disabled:cursor-not-allowed disabled:text-text-disabled`,zN[i],r?`text-text`:`text-text-tertiary enabled:hover:text-text-secondary`),children:[e.icon&&(0,I.jsx)(`span`,{className:q(`inline-flex shrink-0 [&>svg]:size-3.5`,r?`text-text`:`text-icon`),children:e.icon}),(0,I.jsx)(`span`,{className:`truncate`,children:e.label})]},e.value)})]})})}var VN=`peer col-start-1 row-start-1 m-0 size-3.5 cursor-pointer appearance-none rounded-sm border border-border-strong bg-surface-inset transition-colors duration-(--dur-1) ease-app hover:border-text-tertiary checked:border-primary checked:bg-primary checked:hover:bg-primary-hover focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring disabled:cursor-not-allowed disabled:border-border disabled:checked:bg-text-disabled`;function HN({checked:e,onChange:t,label:n,disabled:r,size:i=`sm`,id:a,className:o,"aria-label":s}){return(0,I.jsxs)(`label`,{className:q(`inline-flex cursor-pointer items-center gap-2 select-none`,i===`sm`?`text-xs`:`text-sm`,r?`cursor-not-allowed text-text-disabled`:`text-text-secondary hover:text-text`,o),children:[(0,I.jsxs)(`span`,{className:`grid shrink-0 place-items-center`,children:[(0,I.jsx)(`input`,{id:a,type:`checkbox`,className:VN,checked:e,disabled:r,"aria-label":s,onChange:e=>t(e.target.checked)}),(0,I.jsx)(zy,{size:12,strokeWidth:2,className:`pointer-events-none col-start-1 row-start-1 text-on-primary opacity-0 transition-opacity duration-(--dur-1) peer-checked:opacity-100`})]}),n]})}function UN({checked:e,onChange:t,label:n,disabled:r,id:i,className:a,"aria-label":o}){let s=(0,I.jsx)(`button`,{id:i,type:`button`,role:`switch`,"aria-checked":e,"aria-label":o,disabled:r,onClick:()=>t(!e),className:q(`inline-flex h-4 w-7 shrink-0 cursor-pointer items-center rounded-full border p-px`,`transition-colors duration-(--dur-2) ease-app disabled:cursor-not-allowed disabled:opacity-50`,e?`border-primary bg-primary`:`border-border-strong bg-surface-inset enabled:hover:border-text-tertiary`),children:(0,I.jsx)(`span`,{"aria-hidden":`true`,className:q(`size-3 rounded-full transition-transform duration-(--dur-2) ease-out-app`,e?`translate-x-3 bg-on-primary`:`translate-x-0 bg-text-tertiary`)})});return n===void 0?(0,I.jsx)(`span`,{className:a,children:s}):(0,I.jsxs)(`label`,{className:q(`inline-flex cursor-pointer items-center gap-2 text-sm text-text-secondary select-none`,a),children:[s,n]})}function WN({label:e,className:t,children:n}){let r=(0,I.jsx)(`div`,{"aria-hidden":`true`,"data-progress":``,className:`animate-breathe`,children:n});return e===void 0?(0,I.jsx)(`div`,{className:q(KN,t),children:r}):(0,I.jsxs)(`div`,{role:`status`,className:q(KN,t),children:[(0,I.jsx)(`span`,{className:`sr-only`,children:e}),r]})}function GN({className:e}){return(0,I.jsx)(`span`,{className:q(`block shrink-0 rounded-sm bg-surface-selected`,e)})}var KN=`animate-fade-in [animation-delay:300ms]`;function qN({open:e,onClose:t,title:n,label:r,children:i}){return(0,I.jsxs)(aP,{open:e,onClose:t,size:`sheet`,label:n??r,children:[(0,I.jsx)(`span`,{"aria-hidden":!0,className:`mx-auto mt-2 mb-1 h-1 w-9 shrink-0 rounded-full bg-border-strong`}),n&&(0,I.jsx)(`div`,{className:`px-4 py-2 text-xs font-medium text-text-tertiary`,children:n}),(0,I.jsx)(`div`,{className:`min-h-0 overflow-y-auto`,children:i})]})}function JN({icon:e,label:t,hint:n,current:r=!1,onClick:i}){return(0,I.jsxs)(`button`,{type:`button`,onClick:i,"aria-current":r||void 0,className:`flex min-h-13 w-full cursor-pointer items-center gap-3 px-4 py-2 text-left active:bg-surface-hover`,children:[(0,I.jsx)(`span`,{className:`inline-flex shrink-0 text-icon [&>svg]:size-5`,children:e}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block truncate text-base text-text`,children:t}),n&&(0,I.jsx)(`span`,{className:`block truncate text-xs text-text-tertiary`,children:n})]})]})}function YN({children:e}){return(0,I.jsx)(`div`,{className:`py-0.5 text-xs text-text-tertiary`,children:e})}function XN({icon:e,title:t,hint:n,action:r,compact:i,className:a}){return(0,I.jsxs)(`div`,{className:q(`flex flex-col items-center justify-center gap-1.5 text-center`,i?`px-6 py-8`:`px-6 py-12`,a),children:[e&&(0,I.jsx)(`div`,{className:`mb-1.5 inline-flex text-text-tertiary [&>svg]:size-5`,children:e}),(0,I.jsx)(`div`,{className:`text-base leading-5 font-medium text-text`,children:t}),n&&(0,I.jsx)(`div`,{className:`max-w-80 text-sm text-pretty text-text-tertiary`,children:n}),r&&(0,I.jsx)(`div`,{className:`mt-3`,children:r})]})}var ZN={md:`h-10 items-center gap-2 text-sm font-medium text-text-secondary hover:text-text`,sm:`min-h-6 items-start gap-1.5 py-1 text-xs text-text-tertiary hover:text-text-secondary`},QN={md:`pb-4 pl-6 text-sm text-text-secondary`,sm:`pt-0.5 pb-2 pl-4.5 text-xs text-text-secondary`};function $N({title:e,icon:t,aside:n,defaultOpen:r=!1,bare:i=!1,size:a=`md`,index:o,animate:s=!1,onToggle:c,className:l,bodyClassName:u,children:d}){let[f]=(0,F.useState)(r),p=o!==void 0&&o<8;return(0,I.jsxs)(`details`,{"data-disclosure":``,open:f,onToggle:c&&(e=>c(e.currentTarget.open)),style:p?{"--i":o}:void 0,className:q(`group/disclosure min-w-0`,a===`md`&&!i&&`border-t border-border-subtle`,(p||s)&&`animate-rise-in`,p&&`[animation-delay:calc(var(--i)*20ms)]`,l),children:[(0,I.jsxs)(`summary`,{className:q(`flex cursor-pointer list-none rounded-md`,`transition-colors duration-(--dur-1) ease-app select-none [&::-webkit-details-marker]:hidden`,ZN[a]),children:[(0,I.jsx)(Wy,{size:a===`sm`?12:14,className:q(`shrink-0 text-icon transition-transform duration-(--dur-2) ease-app group-open/disclosure:rotate-90`,a===`sm`&&`mt-0.5`)}),t&&(0,I.jsx)(`span`,{className:`inline-flex shrink-0 text-icon [&>svg]:size-3.5`,children:t}),(0,I.jsx)(`span`,{className:q(`min-w-0 flex-1`,a===`md`&&`truncate`),children:e}),n&&(0,I.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-text-tertiary`,children:n})]}),(0,I.jsx)(`div`,{className:q(QN[a],u),children:d})]})}function eP({message:e,path:t,hint:n,action:r,id:i}){return(0,I.jsxs)(`div`,{className:`rounded-md bg-danger-subtle px-3 py-2.5`,id:i,role:`alert`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium text-danger-text`,children:e}),t&&(0,I.jsx)(`div`,{className:`mt-1 truncate text-left font-mono text-xs text-text-tertiary`,dir:`rtl`,title:t,children:(0,I.jsx)(`bdi`,{children:t})}),n&&(0,I.jsx)(`p`,{className:`mt-1.5 mb-0 text-sm text-text-secondary`,children:n}),r&&(0,I.jsx)(`div`,{className:`mt-2.5`,children:r})]})}var tP={centred:`items-start justify-center px-4 pb-4`,foot:`items-end justify-center`},nP={card:`rounded-lg shadow-dialog animate-dialog-in`,sheet:`flex max-h-[70%] flex-col rounded-t-lg border-t border-border pb-[calc(0.75rem+env(safe-area-inset-bottom))] animate-rise-in`},rP={sm:`max-w-[460px]`,md:`max-w-[620px]`,lg:`max-w-[780px]`,xl:`max-w-[940px]`,palette:`max-w-[560px]`,full:`max-w-[min(1400px,96vw)]`,sheet:``},iP={dim:`bg-scrim animate-backdrop-in`,light:`bg-scrim/40 animate-backdrop-in`,none:`pointer-events-none bg-transparent`};function aP({open:e,onClose:t,size:n=`md`,scrim:r=`dim`,label:i,labelledBy:a,dirty:o=!1,discardPrompt:s=`Discard what you have typed?`,initialFocusRef:c,returnFocusRef:l,inline:u=!1,backdropClassName:d,className:f,children:p}){let[m,h]=(0,F.useState)(!1),g=(0,F.useRef)(null),_=zx(),v=n===`full`&&!u&&_;if((0,F.useEffect)(()=>{if(!e)return;let t=l?.current??document.activeElement,n=g.current;return n&&!n.contains(document.activeElement)&&(c?.current??n).focus(),()=>{let e=document.activeElement;if(!(e===null||e===document.body||!e.isConnected||n?.contains(e)))return;let r=t instanceof HTMLElement&&t.isConnected?t:l?.current;r?.isConnected&&(r.focus(),queueMicrotask(()=>{let e=document.activeElement,t=r.isConnected?r:l?.current;t?.isConnected&&(e===null||e===document.body)&&t.focus()}))}},[e]),(0,F.useEffect)(()=>{if(!e)return;let n=e=>{if(e.key!==`Escape`)return;let n=document.activeElement;(n===null||n===document.body||g.current?.contains(n))&&(m?h(!1):o?h(!0):t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,m,o,t]),!e)return null;let y=n===`sheet`,b=()=>{o?h(!0):t()},x=(0,I.jsx)(`div`,{className:q(u?`flex flex-1 items-center justify-center p-6`:q(`fixed inset-0 z-[200] flex`,y?tP.foot:v?`items-start justify-center`:tP.centred,!y&&!v&&(n===`palette`?`pt-[12vh]`:`pt-[8vh]`),iP[r]),d),onMouseDown:e=>{e.target===e.currentTarget&&(e.preventDefault(),b())},children:(0,I.jsxs)(`div`,{ref:g,role:`dialog`,"aria-modal":!u||void 0,"aria-label":i,"aria-labelledby":a,tabIndex:-1,className:q(`w-full bg-surface-raised text-sm text-text`,y?nP.sheet:v?`shadow-dialog animate-dialog-in`:nP.card,r===`none`&&`pointer-events-auto`,v?`min-h-dvh`:rP[n],f),children:[typeof p==`function`?p(b):p,m&&(0,I.jsxs)(`div`,{className:`card m-4 flex items-center gap-2 rounded-md px-3 py-2 animate-fade-in`,role:`alert`,children:[(0,I.jsx)(`span`,{className:`flex-1 text-sm text-text`,children:s}),(0,I.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>h(!1),children:`Keep editing`}),(0,I.jsx)(J,{variant:`danger`,size:`sm`,onClick:t,children:`Discard`})]})]})});return u?x:(0,Bx.createPortal)(x,document.body)}function oP({title:e,description:t,onClose:n,id:r,className:i}){return(0,I.jsxs)(`div`,{className:q(`flex items-start gap-3 px-6 pt-5 pb-4`,i),children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{id:r,className:`m-0 text-lg font-semibold text-text`,children:e}),t&&(0,I.jsx)(`p`,{className:`mt-1 mb-0 text-sm text-text-secondary`,children:t})]}),n&&(0,I.jsx)(Y,{label:`Close`,size:`sm`,icon:(0,I.jsx)(By,{}),onClick:n,className:`-mr-1`})]})}function sP({className:e,children:t}){return(0,I.jsx)(`div`,{className:q(`px-6 pb-5`,e),children:t})}function cP({start:e,className:t,children:n}){return(0,I.jsxs)(`div`,{className:q(`flex items-center gap-2 px-6 pt-1 pb-5`,t),children:[e&&(0,I.jsx)(`div`,{className:`mr-auto flex min-w-0 items-center gap-2 text-xs text-text-tertiary`,children:e}),(0,I.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:n})]})}var lP=/^(?:runcastle\/|worktree-|afk\/)/,uP=`inline-flex h-(--control-h) min-w-0 items-center gap-1.5 rounded-md border px-2 text-sm transition-colors duration-(--dur-1) ease-app disabled:cursor-not-allowed disabled:text-text-disabled`;function dP({prefix:e,value:t,branches:n,detected:r,onPick:i,missing:a=!1,disabled:o=!1,className:s}){let c=(n??[]).filter(e=>!lP.test(e)),l=r&&c.includes(r)?r:null,u=c.filter(e=>e!==l),d=e=>(0,I.jsx)(FA,{value:e,current:e===t,onSelect:()=>i(e),children:e},e);return(0,I.jsxs)(TA,{children:[(0,I.jsxs)(EA,{disabled:o||!n,className:q(uP,a?`border-transparent text-warning-text`:`border-transparent text-text-secondary enabled:hover:bg-surface-hover enabled:hover:text-text`,s),children:[(0,I.jsxs)(`span`,{className:`truncate`,children:[e,` `,t??`…`]}),(0,I.jsx)(Uy,{size:12,className:`shrink-0 text-icon`})]}),(0,I.jsxs)(DA,{align:`end`,children:[(0,I.jsx)(OA,{placeholder:`Find a branch…`}),(0,I.jsxs)(kA,{label:`${e} branch`,className:`font-mono text-xs`,children:[(0,I.jsx)(AA,{children:c.length===0?`No branches to land on`:`No branch matches`}),l?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(MA,{heading:`Detected main line`,children:d(l)}),u.length>0&&(0,I.jsx)(MA,{heading:`Other local branches`,children:u.map(d)})]}):u.map(d)]})]})]})}var fP={md:`h-[54px] w-24 rounded-md`,sm:`h-[26px] w-10 rounded-sm cursor-zoom-in`};function pP({url:e,onOpen:t,size:n=`md`}){return e?(0,I.jsx)(`button`,{type:`button`,className:q(`shrink-0 cursor-pointer overflow-hidden border border-border bg-surface-inset p-0`,`transition-colors duration-(--dur-1) ease-app hover:border-border-strong`,fP[n]),title:`see the whole picture`,onClick:()=>t(e),children:(0,I.jsx)(`img`,{src:e,alt:`the picture attached to this note`,className:`h-full w-full object-cover`})}):null}function mP(e,t){return Number.isFinite(t)?Math.min(e.max,Math.max(e.min,Math.round(t))):e.default}function hP(e){let t=null;try{t=localStorage.getItem(e.key)}catch{return e.default}if(t===null)return e.default;let n=Number(t);return Number.isFinite(n)?mP(e,n):e.default}function gP(e,t){try{localStorage.setItem(e.key,String(t))}catch{}}function _P(e){let[t,n]=(0,F.useState)(()=>hP(e));return(0,F.useEffect)(()=>{gP(e,t)},[e,t]),{width:t,setWidth:(0,F.useCallback)(t=>n(mP(e,t)),[e])}}var vP={key:`runcastle.sidebar.w`,min:220,max:420,default:248};function yP(e){return mP(vP,e)}function bP(){return _P(vP)}function xP(e,t=``){return/mac|iphone|ipad|ipod/i.test(e)||/mac os x/i.test(t)}function SP(e,t=``){return/win/i.test(e)||/windows/i.test(t)}function CP(e,t,n=``){return xP(t,n)?`⌘${e}`:`Ctrl+${e}`}function wP(e,t=``){return SP(e,t)?`C:\\Users\\you\\code\\your-repo`:`/path/to/your/repo`}function TP(e,t,n=``){let r=e.trim();return SP(t,n)?/^[A-Za-z]:[\\/]/.test(r)||/^\\\\/.test(r):r.startsWith(`/`)}function EP(){return typeof navigator>`u`?{platform:``,userAgent:``}:{platform:navigator.platform??``,userAgent:navigator.userAgent??``}}function DP(e){let t=EP();return CP(e,t.platform,t.userAgent)}function OP(){let e=EP();return wP(e.platform,e.userAgent)}function kP(e){let t=EP();return TP(e,t.platform,t.userAgent)}var AP=`docker`,jP={"claude-code":`Claude`,codex:`Codex`};function MP(e){return e?jP[e]:`the agent`}var NP=`Notify me when agents finish a run`,PP=`stop timed out — the process may still be running`,FP=`Workers run a round’s tickets in containers, unattended, and you read the result when you are back.`;function IP(e){return e.permission===`denied`?{state:`blocked`,label:`notify blocked`,title:`Your browser has blocked notifications for runcastle. Allow them in site settings (the icon beside the address bar), then click again.`}:e.enabled?{state:`on`,label:`notify on`,title:`Desktop notifications on — click to turn them off`}:{state:`off`,label:`notify off`,title:NP}}function LP(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.status!=`string`||typeof t.summary!=`string`||t.status!==`succeeded`&&t.status!==`failed`&&t.status!==`cancelled`?null:{status:t.status,summary:t.summary}}function RP(e){let t=e.split(`
|
|
119
|
-
`)[0].trim();return t.length>140?`${t.slice(0,139)}…`:t}function zP(e,t){if(e.type!==`run.finished`)return null;let n=LP(e.data);if(!n)return null;let r=t??`your feature`;return n.status===`succeeded`?{title:`Round finished — the agent is checking it`,body:r}:n.status===`failed`?{title:`Round failed`,body:`${r}: ${RP(n.summary)}`}:null}var BP=`runcastle:notifications`,VP=typeof Notification<`u`;function HP(){try{return localStorage.getItem(BP)===`on`}catch{return!1}}function UP(e){try{localStorage.setItem(BP,e?`on`:`off`)}catch{}}function WP({title:e,body:t}){try{let n=new Notification(e,{body:t});n.onclick=()=>{window.focus(),n.close()}}catch{}}function GP(e,t){let[n,r]=(0,F.useState)(()=>VP&&HP()),[i,a]=(0,F.useState)(()=>VP?Notification.permission:`default`),[o,s]=(0,F.useState)(void 0),c=(0,F.useRef)(!1),l=(0,F.useRef)(new Map);l.current=new Map(t.map(e=>[e.id,e.title]));let u=R.events.listByProject.useQuery({projectId:e,afterId:o},{refetchInterval:tg(),enabled:VP&&n});return(0,F.useEffect)(()=>{let e=u.data;if(!e||e.length===0)return;let t=e[e.length-1].id,n=document.hidden||!document.hasFocus();if(c.current&&Notification.permission===`granted`&&n)for(let t of e){let e=zP(t,t.featureId?l.current.get(t.featureId):void 0);e&&WP(e)}c.current=!0,s(t)},[u.data]),{supported:VP,enabled:n,permission:i,toggle:(0,F.useCallback)(()=>{if(VP){if(Notification.permission===`denied`){a(`denied`);return}if(n){r(!1),UP(!1);return}c.current=!1,s(void 0),r(!0),UP(!0),Notification.permission==="default"&&Notification.requestPermission().then(e=>{a(e),e!==`granted`&&(r(!1),UP(!1))})}},[n])}}var KP=`runcastle.theme`,qP=`dark`,JP=`(prefers-color-scheme: light)`;function YP(e){return e===`dark`||e===`light`||e===`system`}function XP(){try{let e=globalThis.localStorage?.getItem(KP);return YP(e)?e:qP}catch{return qP}}function ZP(){try{return globalThis.matchMedia?.(JP).matches?`light`:`dark`}catch{return`dark`}}function QP(e){return e===`system`?ZP():e}var $P=qP,eF=new Set,tF=null;function nF(){if(typeof document>`u`)return;let e=document.documentElement,t=QP($P);if(e.dataset.theme===t)return;let n=e.dataset.theme!==void 0;if(n&&e.setAttribute(`data-theme-switching`,``),e.dataset.theme=t,n){let t=()=>e.removeAttribute(`data-theme-switching`);typeof requestAnimationFrame==`function`?requestAnimationFrame(()=>requestAnimationFrame(t)):t()}}function rF(){for(let e of eF)e()}function iF(e){if(!e){tF?.(),tF=null;return}if(tF)return;let t;try{t=globalThis.matchMedia?.(JP)}catch{t=void 0}if(!t)return;let n=()=>{nF(),rF()};t.addEventListener(`change`,n),tF=()=>t.removeEventListener(`change`,n)}function aF(){return $P=XP(),nF(),iF($P===`system`),$P}function oF(e){$P=e;try{globalThis.localStorage?.setItem(KP,e)}catch{}nF(),iF(e===`system`),rF()}function sF(e){return eF.add(e),()=>eF.delete(e)}var cF=()=>`${$P}:${QP($P)}`,lF=()=>`${qP}:${qP}`;function uF(){let[e,t]=(0,F.useSyncExternalStore)(sF,cF,lF).split(`:`);return{preference:e,resolved:t,setPreference:oF,toggle:(0,F.useCallback)(()=>{oF(QP($P)===`dark`?`light`:`dark`)},[])}}var dF=`runcastle.thread.attachments`,fF=`pending`,pF=[],mF=new Map,hF=new Map,gF=new Set,_F=0,vF;function yF(){return vF??=new Promise(e=>{try{let t=indexedDB.open(dF,1);t.onupgradeneeded=()=>t.result.createObjectStore(fF),t.onsuccess=()=>e(t.result),t.onerror=()=>e(null)}catch{e(null)}}),vF}async function bF(e){let t=await yF();return t?new Promise(n=>{let r=t.transaction(fF).objectStore(fF).get(e);r.onsuccess=()=>n(r.result??[]),r.onerror=()=>n([])}):[]}async function xF(e,t){let n=await yF();if(n)try{let r=n.transaction(fF,`readwrite`).objectStore(fF);t.length?r.put(t.map(({name:e,file:t})=>({name:e,file:t})),e):r.delete(e)}catch{}}function SF(e,t){t.length?mF.set(e,t):mF.delete(e);for(let e of[...gF])e()}function CF(e,t){return{id:`att${Date.now().toString(36)}${++_F}`,name:t,src:URL.createObjectURL(e),file:e}}function wF(e){return mF.get(e)??pF}function TF(e){return gF.add(e),()=>gF.delete(e)}function EF(e){let t=hF.get(e);return t||(t=bF(e).then(t=>{t.length&&SF(e,[...t.map(e=>CF(e.file,e.name)),...wF(e)])}),hF.set(e,t)),t}function DF(e,t){SF(e,t(wF(e))),EF(e).then(()=>xF(e,wF(e)))}async function OF(e,t){await Promise.all([EF(e),EF(t)]);let n=wF(e);n.length!==0&&(DF(t,e=>[...e,...n]),DF(e,()=>[]))}var kF=e=>[`runcastle.thread.log`,e],AF=`Could not reach the server — this may be out of date`,jF=2e3,MF=`runcastle.thread.draft:`,NF=/(?:^|\s)@(\S*)$/;function PF(e){try{return localStorage.getItem(MF+e)??``}catch{return``}}function FF(e,t){try{t?localStorage.setItem(MF+e,t):localStorage.removeItem(MF+e)}catch{}}async function IF(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}var LF=0;function RF(e,t){let n=e.findIndex(e=>e.id===t);for(let t=n;t>=0;t--){let n=e[t];if(n.kind===`user`)return n.id}}function zF({threadId:e,draftKey:t,start:n,onStarted:r,startsAs:i}){let a=rx(),o=R.useUtils(),s=tg(),c=e??``,l=!!e,u=Ye(),[d,f]=(0,F.useState)({threadId:e,log:null}),p=e?u.getQueryData(kF(e))??null:null,m=d.threadId===e&&d.log?d.log:p,h=m?.length?m[m.length-1].i:void 0,g=R.thread.events.useQuery({threadId:c,...h===void 0?{}:{after:h}},{enabled:l,staleTime:1/0,refetchOnWindowFocus:`always`,refetchOnReconnect:`always`,refetchInterval:s}),_=g.data?.events,v=(0,F.useCallback)((e,t,n)=>{let r=u.getQueryData(kF(e))??n??void 0,i=r?.length?r[r.length-1].i:-1,a=t.filter(e=>e.i>i);if(a.length===0&&r)return;let s=[...r??[],...a];u.setQueryData(kF(e),s),s.length&&o.thread.events.setData({threadId:e,after:s[s.length-1].i},{events:[]}),f({threadId:e,log:s})},[o,u]);(0,F.useEffect)(()=>{_&&e&&v(e,_,m)},[_,e,m,v]);let[y,b]=(0,F.useState)(null);(0,F.useEffect)(()=>{if(!e)return;let t=!1,n,r=u.getQueryData(kF(e)),i=r?.length?{threadId:e,after:r[r.length-1].i}:{threadId:e},a=()=>{o.thread.events.fetch(i,{staleTime:0}).then(n=>{t||(v(e,n.events,r),b(e))},()=>{t||(r?.length?b(e):n=setTimeout(a,jF))})};return a(),()=>{t=!0,clearTimeout(n)}},[e,o,u,v]);let x=(0,F.useMemo)(()=>e&&m?Cm(m):bm,[e,m]),S=l&&y===e,C=l&&!S,w=S&&g.isError&&!!m?.length,[T,E]=(0,F.useState)([]),D=T.filter(t=>t.threadId===e?!m||!m.some(e=>e.type===`prompt`&&(t.promptId?e.id===t.promptId:e.source===`human`&&e.i>t.after&&e.text===t.text)):!1),O=(0,F.useMemo)(()=>{let e=S||!l?x:bm,t=e.state===`working`,n=D.map(n=>({kind:`user`,id:n.localId,text:n.text,...n.images.length?{images:n.images}:{},...t?{steered:!0}:e.process===`running`?{}:{starting:!0}}));return w&&n.push({kind:`notice`,id:`out-of-date`,text:AF}),n.length?{...e,items:[...e.items,...n]}:e},[x,S,l,w,D]),k=e??t??`new`,[ee,A]=(0,F.useState)(()=>({at:k,text:PF(k)})),j=ee.at===k?ee.text:PF(k),M=(0,F.useCallback)(e=>{A({at:k,text:e}),FF(k,e)},[k]),N=()=>wF(k),te=(0,F.useSyncExternalStore)(TF,N,N);(0,F.useEffect)(()=>void EF(k),[k]);let ne=(0,F.useCallback)(e=>{DF(k,t=>[...t,...e.map(e=>CF(e,e.name||`image.png`))])},[k]),re=(0,F.useCallback)(e=>{DF(k,t=>t.filter(t=>t.id!==e))},[k]),ie=i?t:void 0;(0,F.useEffect)(()=>{if(!e||!ie)return;let t=PF(ie);if(t){let n=PF(e),r=n?`${n}\n\n${t}`:t;FF(ie,``),FF(e,r),A({at:e,text:r})}OF(ie,e)},[e,ie]);let[ae,P]=(0,F.useState)({threadId:e}),oe=ae.threadId===e?ae:{threadId:e},se=R.thread.models.useQuery(e?{threadId:e}:i??{threadId:``},{enabled:l||!!i}),ce=se.data?.models.length?se.data.models:x.model?[{id:x.model.id,label:x.model.label}]:[],le=x.process===`running`,ue=e=>e!==void 0&&ce.some(t=>t.id===e)?e:void 0,de=ue(oe.model)??(le?ue(x.model?.id):void 0)??se.data?.current??oe.model??x.model?.id??void 0,fe=oe.effort??(le?x.model?.effort:se.data?.effort),pe=oe.fast??(le?x.model?.fast:se.data?.fast)??!1;(0,F.useEffect)(()=>{e&&o.thread.models.invalidate({threadId:e})},[e,x.process,o]);let me=R.thread.setModel.useMutation({onSuccess:(e,t)=>{P(e=>e.threadId===t.threadId&&e.model===t.model?{...e,model:void 0}:e),o.thread.models.invalidate({threadId:t.threadId})},onError:()=>void 0}),he=t=>{let n={...oe,...t,threadId:e},r=ce.find(e=>e.id===n.model)?.efforts;t.model&&n.effort&&r&&!r.includes(n.effort)&&delete n.effort,P(n);let i=n.model??de;e&&i&&me.mutate({threadId:e,model:i,...n.effort?{effort:n.effort}:{},...n.fast===void 0?{}:{fast:n.fast}})},ge=R.thread.send.useMutation(),_e=async()=>{let t=j.trim(),i=te;if(!t&&i.length===0)return;let o={localId:`local${++LF}`,threadId:e,text:t,images:i.map(({id:e,name:t,src:n})=>({id:e,name:t,src:n})),after:h??-1};E(e=>[...e,o]),M(``),DF(k,()=>[]);let s=e;try{let e=await Promise.all(i.map(async e=>({name:e.name,mimeType:e.file.type||`image/png`,data:await IF(e.file)})));if(!s){if(!n)throw Error(`this chat cannot be started from here`);s=await n();let e=s;E(t=>t.map(t=>t.localId===o.localId?{...t,threadId:e}:t)),r?.(e)}let{promptId:a}=await ge.mutateAsync({threadId:s,text:t,...e.length?{images:e}:{},...oe.model===void 0?{}:{model:oe.model},...oe.effort===void 0?{}:{effort:oe.effort},...oe.fast===void 0?{}:{fast:oe.fast}});E(e=>e.map(e=>e.localId===o.localId?{...e,promptId:a}:e))}catch(e){E(e=>e.filter(e=>e.localId!==o.localId));let n=s??k;A(e=>e.text?e:{at:n,text:t}),FF(n,t),DF(n,e=>[...i,...e]),a.push(e instanceof Error?e.message:`the message could not be sent`)}},ve=()=>[...(S?O:x).items].reverse().find(e=>e.kind===`user`&&!e.from)?.text,ye=e=>a.push(e.message),be=R.thread.stop.useMutation({onError:ye}),xe=R.thread.answer.useMutation({onError:ye}),Se=R.thread.compact.useMutation({onError:ye}),Ce={onError:()=>void 0},we=R.thread.edit.useMutation(Ce),Te=R.thread.branch.useMutation(Ce),Ee=R.thread.usage.useQuery({threadId:c},{enabled:l}),De=Ee.refetch,Oe=(0,F.useRef)(!1);(0,F.useEffect)(()=>{let e=x.state===`working`;Oe.current&&!e&&l&&De(),Oe.current=e},[x.state,l,De]);let ke=NF.exec(j)?.[1],Ae=R.thread.files.useQuery({threadId:c,query:ke??``,limit:8},{enabled:l&&ke!==void 0});return{view:O,loading:C,draft:j,setDraft:M,attachments:te,attach:ne,removeAttachment:re,send:_e,recall:ve,stop:()=>{e&&be.mutate({threadId:e})},answer:(t,n)=>{e&&xe.mutate({threadId:e,askId:t.id,answer:n})},runtime:se.data?.runtime,models:ce,model:de,effort:fe,chooseModel:e=>he({model:e}),chooseEffort:e=>he({effort:e}),fast:pe,chooseFast:e=>he({fast:e}),compact:()=>{e&&Se.mutate({threadId:e})},usage:Ee.data,refreshUsage:()=>{l&&De()},files:Ae.data??[],edit:(t,n,r)=>{e&&we.mutate({threadId:e,promptId:t,text:n,undoFiles:r})},branch:async t=>{if(e)try{return(await Te.mutateAsync({threadId:e,promptId:t})).threadId}catch{return}}}}function BF(e){return`${e.replace(/[\\/:*?"<>|\u0000-\u001f]+/g,` `).replace(/\s+/g,` `).trim().slice(0,120)||`Thread`}.md`}function VF(){let e=rx(),t=R.useUtils(),n=R.thread.rename.useMutation({onSuccess:()=>void t.thread.list.invalidate(),onError:t=>e.push(t.message)}),r=async(n,r)=>{try{let{markdown:e}=await t.thread.export.fetch({threadId:n},{staleTime:0}),i=URL.createObjectURL(new Blob([e],{type:`text/markdown`})),a=document.createElement(`a`);a.href=i,a.download=BF(r),a.click(),URL.revokeObjectURL(i)}catch(t){e.push(t instanceof Error?t.message:`the thread could not be exported`)}};return{rename:(e,t)=>n.mutate({threadId:e,title:t}),exportMarkdown:(e,t)=>void r(e,t)}}function HF(e,t){navigator.clipboard.writeText(e).then(()=>t.push(`copied ${e}`,`info`)).catch(()=>t.push(`copy failed`))}function UF({width:e,side:t,label:n,clamp:r,onResize:i}){let[a,o]=(0,F.useState)(!1),s=(0,F.useRef)({x:0,width:e});return(0,F.useEffect)(()=>{if(!a)return;let e=e=>{let n=e.clientX-s.current.x;i(r(s.current.width+(t===`left`?n:-n)))},n=()=>o(!1),c=document.body.style.userSelect;return document.body.style.userSelect=`none`,document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,n),()=>{document.body.style.userSelect=c,document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,n)}},[r,a,i,t]),(0,I.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":n,title:`Drag to resize`,className:`absolute top-0 z-10 h-full w-1.5 cursor-col-resize transition-colors duration-(--dur-1) ease-app hover:bg-border-strong ${t===`left`?`-right-[3px]`:`-left-[3px]`} ${a?`bg-border-strong`:``}`,onMouseDown:t=>{t.preventDefault(),s.current={x:t.clientX,width:e},o(!0)}})}function WF({title:e,slug:t,busy:n,onConfirm:r,onCancel:i,returnFocusRef:a}){let[o,s]=(0,F.useState)(``),c=o.trim()===t;return(0,I.jsxs)(aP,{open:!0,onClose:i,returnFocusRef:a,labelledBy:`delete-feature-title`,size:`sm`,children:[(0,I.jsx)(oP,{id:`delete-feature-title`,title:`Delete feature`,onClose:i}),(0,I.jsxs)(sP,{className:`flex flex-col gap-5`,children:[(0,I.jsxs)(`p`,{className:`m-0 text-sm text-pretty text-text-secondary`,children:[`Permanently delete `,(0,I.jsx)(`strong`,{className:`font-medium text-text`,children:e}),`? Its worktree, branches, running agent and all runcastle data go with it; committed docs stay in git history.`,` `,(0,I.jsx)(`strong`,{className:`font-medium text-text`,children:`This cannot be undone.`})]}),(0,I.jsx)(kN,{label:(0,I.jsxs)(I.Fragment,{children:[`Type `,(0,I.jsx)(`code`,{className:`font-mono text-xs text-text`,children:t}),` to confirm`]}),children:(0,I.jsx)(EN,{mono:!0,value:o,onChange:e=>s(e.target.value),autoFocus:!0,spellCheck:!1,autoComplete:`off`,placeholder:t})})]}),(0,I.jsxs)(cP,{children:[(0,I.jsx)(J,{variant:`ghost`,onClick:i,disabled:n,children:`Cancel`}),(0,I.jsx)(J,{variant:`danger`,icon:(0,I.jsx)(Vy,{}),onClick:r,disabled:!c||n,children:n?`Deleting…`:`Delete feature`})]})]})}var GF=`group flex h-8 min-w-0 cursor-pointer items-center gap-2 rounded-md border border-transparent bg-transparent pr-1.5 pl-2 text-text transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover aria-expanded:bg-surface-selected`,KF=`text-sm`;function qF({nav:e}){let t=e.projects??[],n=e.currentProject?.name??`runcastle`;return(0,I.jsxs)(mN,{children:[(0,I.jsxs)(hN,{className:GF,"aria-label":`${n} — switch project`,children:[(0,I.jsx)(Xb,{size:16,className:`shrink-0`}),(0,I.jsx)(`span`,{className:`max-w-56 min-w-0 truncate text-sm font-semibold`,title:n,children:n}),(0,I.jsx)(Uy,{size:14,className:`shrink-0 text-icon transition-transform duration-(--dur-2) ease-app group-aria-expanded:rotate-180`})]}),(0,I.jsxs)(gN,{className:`w-64`,children:[(0,I.jsx)(vN,{children:`Projects`}),t.map(n=>{let r=n.id===e.currentProjectId,i=lee(n.repoPath),a=i!==n.name||t.some(e=>e.id!==n.id&&e.name===n.name);return(0,I.jsxs)(_N,{className:KF,icon:(0,I.jsx)(Qy,{}),"aria-current":r?`true`:void 0,onSelect:()=>e.enterProject(n.id),children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block truncate`,children:n.name}),a&&(0,I.jsx)(`span`,{className:`block truncate font-mono text-xs text-text-tertiary`,children:i})]}),r&&(0,I.jsx)(zy,{size:14,className:`text-text`})]},n.id)}),(0,I.jsx)(yN,{}),(0,I.jsx)(_N,{className:KF,icon:(0,I.jsx)(yb,{}),onSelect:()=>e.goHome(),children:(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`All projects`})}),(0,I.jsx)(_N,{className:KF,icon:(0,I.jsx)(Ry,{}),onSelect:()=>e.showOpen(),children:(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Open a project…`})})]})]})}var JF=`runcastle.sidebar.collapsed`,YF=220/2;function XF(){try{return localStorage.getItem(JF)===`1`}catch{return!1}}function ZF(e){try{localStorage.setItem(JF,e?`1`:`0`)}catch{}}var QF=(0,F.createContext)(null);function $F(e){return e instanceof Element&&e.closest(`.xterm`)!==null}function eI({notices:e,children:t}){let{width:n,setWidth:r}=bP(),[i,a]=(0,F.useState)(XF),o=(0,F.useCallback)(()=>{a(e=>(ZF(!e),!e))},[]),s=(0,F.useCallback)(()=>{ZF(!0),a(!0)},[]),c=zx();(0,F.useEffect)(()=>{if(c)return;let e=e=>{e.defaultPrevented||e.altKey||e.shiftKey||!(e.metaKey||e.ctrlKey)||e.key.toLowerCase()!==`b`||$F(e.target)||(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o,c]);let l=(0,F.useMemo)(()=>({width:n,setWidth:r,closed:i,toggleSidebar:o,closeSidebar:s,notices:e??null}),[n,r,i,o,s,e]);return(0,I.jsx)(QF.Provider,{value:l,children:t})}function tI(){return(0,F.useContext)(QF)??{width:yP(NaN),setWidth:()=>void 0,closed:!1,toggleSidebar:()=>void 0,closeSidebar:()=>void 0,notices:null}}function nI(){let{toggleSidebar:e}=tI();return(0,I.jsx)(Y,{label:`Hide sidebar`,kbd:DP(`B`),size:`sm`,icon:(0,I.jsx)(fb,{}),tooltipSide:`bottom`,onClick:e})}function rI({onClick:e}){return(0,I.jsx)(Y,{label:`Show sidebar`,kbd:DP(`B`),size:`sm`,icon:(0,I.jsx)(fb,{}),tooltipSide:`bottom`,onClick:e})}var iI=e=>Math.min(e,420);function aI({sidebar:e,phoneShows:t=`page`,children:n}){return zx()?(0,I.jsx)(oI,{list:e!==void 0&&t===`list`?e:null,children:n}):(0,I.jsx)(sI,{sidebar:e,children:n})}function oI({list:e,children:t}){let{notices:n}=tI();return(0,I.jsx)(`div`,{className:`flex h-full min-h-0 flex-col bg-canvas pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)] pb-[env(safe-area-inset-bottom)] pl-[env(safe-area-inset-left)] text-text`,children:e===null?(0,I.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface`,children:[n,(0,I.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:t})]}):(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:e})})}function sI({sidebar:e,children:t}){let{width:n,setWidth:r,closed:i,toggleSidebar:a,closeSidebar:o,notices:s}=tI(),[c,l]=(0,F.useState)(!1),u=(0,F.useRef)(null);(0,F.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]);let d=e=>{if(e<YF){l(!1),o();return}l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),160),r(e)},f=e!==void 0,p=f&&i?(0,I.jsx)(rI,{onClick:a}):null;return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 bg-canvas text-text`,style:{"--sidebar-w":`${n}px`},children:[f&&(0,I.jsxs)(`div`,{"data-sidebar":i?`closed`:`open`,className:q(`relative h-full shrink-0 overflow-hidden`,!c&&`transition-[width] duration-(--dur-3) ease-out-app motion-reduce:transition-none`),style:{width:i?0:n},children:[(0,I.jsx)(`div`,{inert:i,"aria-hidden":i||void 0,className:q(`absolute inset-y-0 left-0 flex w-(--sidebar-w) flex-col`,`transition-opacity duration-(--dur-2) ease-app`,i?`pointer-events-none opacity-0`:`opacity-100`),children:e}),!i&&(0,I.jsx)(UF,{width:n,side:`left`,label:`Resize the sidebar`,clamp:iI,onResize:d})]}),(0,I.jsxs)(`main`,{className:q(`my-2 mr-2 flex min-w-0 flex-1 flex-col overflow-hidden rounded-lg border border-border bg-surface`,(!f||i)&&`ml-2`),children:[s,(0,I.jsx)(jN.Provider,{value:p,children:(0,I.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:t})})]})]})}function cI({nav:e,onNewChat:t,onOpenNote:n}){let[r,i]=(0,F.useState)(!1),a=e=>()=>{i(!1),e()};return(0,I.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-1 px-1`,children:[(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1`,children:(0,I.jsx)(qF,{nav:e})}),(0,I.jsx)(Y,{label:`New`,size:`lg`,icon:(0,I.jsx)(Ry,{}),onClick:()=>i(!0)}),(0,I.jsxs)(qN,{open:r,onClose:()=>i(!1),label:`New`,children:[(0,I.jsx)(JN,{icon:(0,I.jsx)(qy,{}),label:`New chat`,hint:`Talk to the Orchestrator`,onClick:a(t)}),n&&(0,I.jsx)(JN,{icon:(0,I.jsx)(Yy,{}),label:`Jot a note`,hint:`What you just noticed — triage it later`,onClick:a(n)})]})]})}function lI({failed:e,readAt:t}){return Qh()===`offline`||e?(0,I.jsxs)(`div`,{role:`status`,className:`mx-1 mt-1 flex items-start gap-2.5 rounded-lg bg-danger-subtle px-3 py-2.5`,children:[(0,I.jsx)(`span`,{className:`mt-1.5`,children:(0,I.jsx)(RA,{tone:`danger`})}),(0,I.jsxs)(`span`,{className:`min-w-0 text-sm text-text`,children:[`Can’t reach your computer. It may be asleep, or Tailscale is off on this phone.`,t>0&&` This list is from ${gg(t)}.`]})]}):null}var uI=`/sw.js`;function dI(){return/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1}function fI(){return window.location.protocol===`https:`}function pI(){return fI()&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window}function mI(){!fI()||!(`serviceWorker`in navigator)||navigator.serviceWorker.register(uI).catch(()=>void 0)}async function hI(){return await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription()??null}async function gI(){return pI()?Notification.permission===`denied`?`blocked`:await hI()?`on`:`off`:fI()&&dI()?`home-screen`:`unsupported`}function _I(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`);return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}function vI(e){let{endpoint:t,keys:n}=e.toJSON();if(!t||!n?.p256dh||!n.auth)throw Error(`The browser gave an incomplete subscription.`);return{endpoint:t,keys:{p256dh:n.p256dh,auth:n.auth}}}async function yI(e){if(await Notification.requestPermission()!==`granted`)return null;let t=await navigator.serviceWorker.register(uI);return await navigator.serviceWorker.ready,vI(await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:_I(e)}))}async function bI(){let e=await hI();return e?(await e.unsubscribe(),e.endpoint):null}var xI={off:`When an agent needs you`,on:`On for this phone`,blocked:`Blocked. Allow notifications for this site in your phone’s settings.`,"home-screen":`Add Runcastle to your Home Screen first, then open it from there.`,unsupported:`Open Runcastle through your phone link, in a browser that supports this.`};function SI({projectId:e}){let[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(null),[a,o]=(0,F.useState)(!1),s=R.push.publicKey.useQuery(void 0,{enabled:t===`off`}),c=R.push.subscribe.useMutation(),l=R.push.unsubscribe.useMutation();(0,F.useEffect)(()=>{let e=!0;return gI().then(t=>{e&&n(t)}),()=>{e=!1}},[]);let u=async()=>{if(!s.data)return;let t=await yI(s.data);if(t)try{await c.mutateAsync({projectId:e,subscription:t})}catch(e){throw await bI(),e}},d=async()=>{let t=await bI();t&&await l.mutateAsync({projectId:e,endpoint:t})},f=async e=>{o(!0),i(null);try{await(e?u():d())}catch(e){i(e instanceof Error?e.message:`That did not work. Try again.`)}n(await gI()),o(!1)};if(!t)return null;let p=t===`off`||t===`on`;return(0,I.jsxs)(`div`,{className:`flex min-h-13 shrink-0 items-center gap-3 border-t border-border-subtle px-2.5 py-2 pb-[max(0.5rem,env(safe-area-inset-bottom))]`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`text-sm text-text`,children:`Notifications`}),(0,I.jsx)(`div`,{role:`status`,className:r?`text-xs text-pretty text-danger`:`text-xs text-pretty text-text-tertiary`,children:r??xI[t]})]}),p&&(0,I.jsx)(UN,{"aria-label":`Notifications`,checked:t===`on`,disabled:a||t===`off`&&!s.data,onChange:e=>void f(e)})]})}function CI(e,t=Date.now()){if(!(e>0))return``;let n=Math.round((t-e)/6e4);if(n<1)return`now`;if(n<60)return`${n}m`;let r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}function wI({state:e}){return e===`working`?(0,I.jsx)(UE,{size:`sm`}):e===`waiting`?(0,I.jsx)(RA,{tone:`warning`,label:`Waiting for you`}):null}function TI(e,t,n){return e===`waiting`?`waiting for you`:e===`working`?`working`:CI(t,n)}var EI={"copy-link":(0,I.jsx)(hb,{}),"copy-branch":(0,I.jsx)(Fy,{}),archive:(0,I.jsx)(db,{}),unarchive:(0,I.jsx)(db,{}),rename:(0,I.jsx)(Yy,{}),delete:(0,I.jsx)(Vy,{}),remove:(0,I.jsx)(Vy,{})};function DI({actions:e,label:t=`Feature actions`,size:n=`sm`,align:r=`end`}){let i=(0,F.useRef)(null);if(e.length===0)return null;let a=e.filter(e=>!e.danger),o=e.filter(e=>e.danger),s=e=>[(0,I.jsx)(_N,{className:`text-sm`,tone:e.danger?`danger`:`default`,icon:e.icon??EI[e.key],kbd:e.kbd,disabled:!!e.disabled,title:e.disabled??e.hint,onSelect:()=>{i.current?.focus(),e.onSelect(i)},children:e.label},e.key),e.ruleAfter?(0,I.jsx)(yN,{},`${e.key}-rule`):null];return(0,I.jsxs)(mN,{children:[(0,I.jsx)(hN,{asChild:!0,children:(0,I.jsx)(Y,{ref:i,label:t,size:n,icon:(0,I.jsx)(Gy,{}),className:`shrink-0`,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation()})}),(0,I.jsxs)(gN,{align:r,className:`font-sans`,onCloseAutoFocus:e=>{let t=document.activeElement;t&&t!==document.body&&t!==i.current&&e.preventDefault()},children:[a.map(s),a.length>0&&o.length>0&&(0,I.jsx)(yN,{}),o.map(s)]})]})}var OI=`hover:bg-surface-hover`,kI=`card rounded-lg`;function AI({f:e,size:t,label:n}){return(0,I.jsx)(Jb,{state:kg(e),progress:Og(e),size:t,label:n})}function jI(e){return e.charAt(0).toUpperCase()+e.slice(1)}function MI(e){let t=Ig(e),n=jg(e);if(t===`needsYou`){if(e.status===`draft`)return`Won't start by itself`;let t=Dg(e);return t?.kind===`waiting`?t.label===`ready to test`?`Ready to test`:jI(t.label):`Waiting on you`}return t===`agentWorking`?e.activeRun?`Working${n?` · ${n}`:``}`:`Agent working`:e.status===`draft`?Ag(e).text:e.status===`shipped`?`Shipped`:e.status===`archived`?`Archived`:`In progress`}function NI(e){return Ig(e)===`needsYou`?`warning`:void 0}function PI(e){let t=e.currentTarget.querySelector(`[aria-haspopup="menu"]`);t&&(e.preventDefault(),t.dispatchEvent(new PointerEvent(`pointerdown`,{bubbles:!0,cancelable:!0,button:0})))}var FI=`opacity-0 group-hover/nav:opacity-100 group-has-[:focus-visible]/nav:opacity-100`,II=`group-hover/nav:opacity-0 group-has-[:focus-visible]/nav:opacity-0`;function LI({folded:e,onToggle:t,what:n}){return(0,I.jsx)(`span`,{"data-fold-toggle":``,className:`inline-flex`,children:(0,I.jsx)(Y,{size:`sm`,label:e?`Show ${n}`:`Hide ${n}`,icon:(0,I.jsx)(Wy,{className:q(`transition-transform duration-(--dur-2) ease-app`,!e&&`rotate-90`)}),onClick:t})})}function RI({title:e,tooltip:t,glyph:n,words:r,wordsClassName:i,aside:a,dot:o,quiet:s=!1,active:c=!1,flat:l=!1,nested:u=!1,onClick:d,actions:f,toggle:p}){return(0,I.jsxs)(`div`,{className:q(`group/nav relative shrink-0 transition-colors duration-(--dur-1) ease-app`,u?`rounded-md`:`rounded-lg`,c&&!l?kI:OI),onContextMenu:f?PI:void 0,children:[(0,I.jsxs)(`button`,{type:`button`,title:t??e,"aria-current":c?`page`:void 0,onClick:d,className:`flex w-full cursor-pointer flex-col gap-0.5 rounded-[inherit] px-2.5 py-2 text-left`,children:[(0,I.jsxs)(`span`,{className:q(`flex min-w-0 items-center gap-2`,p!==void 0&&`pr-6`),children:[(0,I.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-md`,c?`font-medium text-text`:s?`text-text-secondary`:`text-text`),children:e}),o&&(0,I.jsx)(`span`,{className:q(`transition-opacity duration-(--dur-1)`,II),children:(0,I.jsx)(RA,{tone:o})})]}),(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-text-tertiary`,children:[n,(0,I.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate`,i),children:r}),a!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:a})]})]}),f&&(0,I.jsx)(`span`,{"data-row-actions":``,className:q(`absolute top-1.5 flex items-center transition-opacity duration-(--dur-1)`,p===void 0?`right-1`:`right-7`,FI),children:f}),p!==void 0&&(0,I.jsx)(`span`,{className:`absolute top-1.5 right-1`,children:p})]})}function zI({onClick:e}){return(0,I.jsx)(`span`,{"data-new-thread":``,className:`inline-flex`,children:(0,I.jsx)(Y,{size:`sm`,label:`New thread`,icon:(0,I.jsx)(Ry,{}),onClick:e})})}function BI({f:e,active:t,onSelect:n,actions:r,nested:i=!1,onNewThread:a,threads:o,folded:s=!1,onToggleThreads:c}){let l=s?void 0:o,u=Ig(e),d=u===`needsYou`?Dg(e):null,f=MI(e),p=r.length>0?(0,I.jsx)(DI,{actions:r}):void 0,m=(0,I.jsx)(RI,{title:e.title,tooltip:d?`${e.title} — ${d.label}`:e.status===`draft`?`${e.title} — ${Ag(e).title}`:e.title,glyph:(0,I.jsx)(AI,{f:e,size:12}),words:f,wordsClassName:q(u===`agentWorking`&&`text-shimmer`,d&&(d.kind===`stuck`?`text-danger-text`:`text-text-secondary`)),aside:hg(e.lastActivityAt),dot:NI(e),quiet:e.status===`draft`||e.status===`shipped`||e.status===`archived`,active:t,flat:l!==void 0,nested:i||l!==void 0,onClick:()=>n(e.id),actions:a||p?(0,I.jsxs)(I.Fragment,{children:[a&&(0,I.jsx)(zI,{onClick:a}),p]}):void 0,toggle:o!==void 0&&c?(0,I.jsx)(LI,{folded:s,onToggle:c,what:`threads`}):void 0});return l===void 0?m:(0,I.jsxs)(`div`,{"data-open-feature":``,className:q(kI,i&&`rounded-md`,`flex shrink-0 flex-col p-1`),children:[m,l]})}function VI({label:e,badge:t,title:n,active:r,onClick:i}){return(0,I.jsx)(RI,{title:e,tooltip:n,glyph:(0,I.jsx)(ob,{size:12,className:`shrink-0 text-icon`}),words:t??`Not prepared yet`,wordsClassName:`text-text-secondary`,dot:`warning`,active:r,onClick:i})}function HI({n:e}){return(0,I.jsx)(`span`,{className:`inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-fill-well px-1.5 text-xs text-text-secondary tabular-nums`,children:e})}function UI({icon:e,label:t,count:n,open:r,onToggle:i,live:a=!1}){return(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:i,className:q(`group/head flex h-10 w-full shrink-0 cursor-pointer items-center gap-3 rounded-lg px-2.5 text-left transition-colors duration-(--dur-1) ease-app`,OI),children:[(0,I.jsx)(`span`,{className:q(`inline-flex shrink-0 [&>svg]:size-4`,a?`text-accent-text`:`text-icon`),children:e}),(0,I.jsx)(`span`,{className:q(`text-md`,a?`font-medium text-text`:`text-text-secondary group-hover/head:text-text`),children:t}),(0,I.jsx)(HI,{n}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(Wy,{size:14,className:q(`text-icon transition-transform duration-(--dur-2) ease-app`,r&&`rotate-90`)})]})}function WI({icon:e,label:t,features:n,renderRow:r,cap:i,defaultOpen:a=!1,open:o,onOpenChange:s}){let[c,l]=(0,F.useState)(a),[u,d]=(0,F.useState)(!1),f=o??c;if(n.length===0)return null;let p=()=>{l(!f),s?.(!f)},m=i!==void 0&&!u?n.slice(0,i):n,h=n.length-m.length;return(0,I.jsxs)(`section`,{"aria-label":t,className:`flex flex-col gap-1 py-1`,children:[(0,I.jsx)(UI,{icon:e,label:t,count:n.length,open:f,onToggle:p}),f&&(0,I.jsxs)(`div`,{className:`flex animate-rise-in flex-col gap-1 pb-1`,children:[m.map(r),h>0&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`flex h-8 cursor-pointer items-center gap-1.5 rounded-lg px-2.5 text-left text-xs text-text-tertiary transition-colors duration-(--dur-1) ease-app hover:text-text-secondary`,children:[(0,I.jsx)(Uy,{size:12,className:`text-icon`}),`Show `,h,` more`]})]})]})}function Qee({features:e,renderRow:t}){let[n,r]=(0,F.useState)(!0);return e.length===0?null:(0,I.jsxs)(`section`,{"aria-label":`Working`,className:`flex flex-col gap-1`,children:[(0,I.jsx)(UI,{icon:(0,I.jsx)(Xy,{}),label:`Working`,count:e.length,open:n,onToggle:()=>r(e=>!e),live:!0}),n&&(0,I.jsx)(`div`,{className:q(`card rounded-lg`,`orbit-light relative flex animate-rise-in flex-col p-1`),children:e.map((e,n)=>(0,I.jsxs)(F.Fragment,{children:[n>0&&(0,I.jsx)(`span`,{"aria-hidden":!0,className:`mx-2.5 h-px bg-border-subtle`}),t(e,!0)]},e.id))})]})}function $ee(e,t,n=5){let r=e.filter((e,r)=>r<n||e.id===t||e.state!==`idle`);return{shown:r,hidden:e.length-r.length}}function GI({state:e}){return(0,I.jsx)(`span`,{className:`inline-flex size-4 shrink-0 items-center justify-center text-icon`,children:e===`idle`?(0,I.jsx)(qy,{size:14}):(0,I.jsx)(wI,{state:e})})}function ete({features:e}){let t=e.length;return(0,I.jsxs)(`span`,{role:`img`,"aria-label":`Holds ${t} ${t===1?`feature`:`features`}`,className:`inline-flex items-center gap-0.5`,children:[e.slice(0,3).map(e=>(0,I.jsx)(AI,{f:e,size:12,label:``},e.id)),t>3&&(0,I.jsxs)(`span`,{className:`ml-0.5`,children:[`+`,t-3]})]})}function tte({features:e}){return(0,I.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 py-0.5`,children:e.map(e=>(0,I.jsxs)(`li`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(AI,{f:e,size:12,label:``}),(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]},e.id))})}function nte({thread:e,active:t,onOpen:n,actions:r,mark:i,tip:a}){let o=i===null,s=(0,I.jsxs)(`button`,{type:`button`,title:a?void 0:e.title,"aria-current":t?`page`:void 0,onClick:()=>n(e.id),className:`flex h-8 w-full cursor-pointer items-center gap-2 rounded-[inherit] px-2.5 text-left`,children:[(0,I.jsx)(GI,{state:e.state}),(0,I.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-md`,t?`font-medium text-text`:e.state===`waiting`?`text-text`:`text-text-secondary`),children:e.title}),(0,I.jsx)(`span`,{className:q(`inline-flex shrink-0 items-center text-xs text-text-tertiary tabular-nums transition-opacity duration-(--dur-1)`,r.length>0&&`group-hover/thread:opacity-0 group-has-[:focus-visible]/thread:opacity-0`,o&&r.length>0&&`group-hover/thread:w-5 group-has-[:focus-visible]/thread:w-5`),children:i===void 0?e.updatedAt>0&&hg(e.updatedAt):i})]});return(0,I.jsxs)(`div`,{className:q(`group/thread relative shrink-0 rounded-md transition-colors duration-(--dur-1) ease-app`,t?`card`:OI),onContextMenu:r.length>0?PI:void 0,children:[a?(0,I.jsx)(OE,{label:a,side:`right`,align:`start`,leaves:!0,children:s}):s,r.length>0&&(0,I.jsx)(`span`,{className:`absolute top-1/2 right-1 -translate-y-1/2 opacity-0 transition-opacity duration-(--dur-1) group-hover/thread:opacity-100 group-has-[:focus-visible]/thread:opacity-100`,children:(0,I.jsx)(DI,{actions:r,label:`Thread actions`})})]})}function KI({label:e,icon:t,onClick:n}){return(0,I.jsxs)(`button`,{type:`button`,onClick:n,className:`flex h-7 w-full cursor-pointer items-center gap-2 rounded-md px-2.5 text-left text-xs text-text-tertiary transition-colors duration-(--dur-1) ease-app hover:text-text-secondary`,children:[(0,I.jsx)(`span`,{className:`inline-flex size-4 shrink-0 items-center justify-center text-icon`,children:t}),e]})}function qI({threads:e,current:t,onOpen:n,actionsFor:r,more:i,label:a=`Threads`,keep:o,markFor:s,tipFor:c}){let[l,u]=(0,F.useState)(!1),d=o?e.filter(o):null,{shown:f,hidden:p}=d?{shown:d,hidden:e.length-d.length}:l?{shown:[...e],hidden:0}:$ee(e,t);return(0,I.jsxs)(`ul`,{"aria-label":a,className:`m-0 flex animate-rise-in list-none flex-col gap-px p-0`,children:[f.map((e,i)=>(0,I.jsxs)(`li`,{className:`flex flex-col gap-px`,children:[i>0&&(0,I.jsx)(`span`,{"aria-hidden":!0,className:`mr-2.5 ml-[34px] h-px bg-border-subtle`}),(0,I.jsx)(nte,{thread:e,active:e.id===t,onOpen:n,actions:r(e),mark:s?.(e),tip:c?.(e)})]},e.id)),p>0&&(0,I.jsx)(`li`,{children:i?(0,I.jsx)(KI,{label:`All ${e.length} conversations`,icon:(0,I.jsx)(nb,{size:12}),onClick:i}):(0,I.jsx)(KI,{label:`Show ${p} more`,icon:(0,I.jsx)(Uy,{size:12}),onClick:()=>u(!0)})})]})}function rte({status:e,state:t,active:n,onOpen:r,actions:i,title:a,onNewThread:o,threads:s,folded:c=!1,onToggleThreads:l}){let u=s!==void 0&&l!==void 0,d=c?void 0:s;return(0,I.jsxs)(`div`,{className:q(`relative isolate shrink-0 overflow-hidden rounded-lg ring-1 ring-inset`,`bg-[linear-gradient(100deg,color-mix(in_oklab,var(--color-accent)_16%,var(--color-canvas)),color-mix(in_oklab,var(--color-accent)_5%,var(--color-canvas))_70%)]`,`shadow-[inset_0_1px_0_color-mix(in_oklab,var(--color-text)_7%,transparent)]`,n?`ring-[color-mix(in_oklab,var(--color-accent)_55%,transparent)]`:`ring-[color-mix(in_oklab,var(--color-accent)_28%,transparent)]`),children:[(0,I.jsxs)(`div`,{className:`orchestrator-beat group/nav relative isolate overflow-hidden`,onContextMenu:i.length>0?PI:void 0,children:[(0,I.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 right-0 -z-10 w-2/3 [background-image:linear-gradient(to_right,color-mix(in_oklab,var(--color-accent)_14%,transparent)_1px,transparent_1px),linear-gradient(to_bottom,color-mix(in_oklab,var(--color-accent)_14%,transparent)_1px,transparent_1px)] [background-size:12px_12px] [mask-image:linear-gradient(to_left,black,transparent)]`}),(0,I.jsx)(`span`,{"aria-hidden":!0,"data-sheen":!0,className:`pointer-events-none absolute inset-y-0 left-0 -z-10 w-1/2 -translate-x-[120%] bg-[linear-gradient(100deg,transparent,color-mix(in_oklab,var(--color-text)_7%,transparent),transparent)]`}),(0,I.jsxs)(`button`,{type:`button`,onClick:r,title:a,"aria-current":n?`page`:void 0,className:q(`flex w-full cursor-pointer items-center gap-3 py-2.5 pl-2.5 text-left`,u?`pr-9`:`pr-2.5`),children:[(0,I.jsx)(YI,{}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,I.jsx)(`span`,{className:`truncate text-md font-semibold tracking-tight text-text`,children:`Orchestrator`}),(0,I.jsx)(`span`,{className:`truncate text-xs text-[color-mix(in_oklab,var(--color-accent-text)_70%,var(--color-text-tertiary))]`,children:e})]}),(0,I.jsxs)(`span`,{className:q(`flex items-center gap-2 transition-opacity duration-(--dur-1)`,II),children:[(0,I.jsx)(wI,{state:t}),!u&&(0,I.jsx)(Wy,{size:14,className:`text-icon`})]})]}),(i.length>0||o)&&(0,I.jsxs)(`span`,{"data-row-actions":``,className:q(`absolute top-1/2 flex -translate-y-1/2 items-center transition-opacity duration-(--dur-1)`,u?`right-8`:`right-1.5`,FI),children:[o&&(0,I.jsx)(zI,{onClick:o}),(0,I.jsx)(DI,{actions:i,label:`Project actions`})]}),u&&l&&(0,I.jsx)(`span`,{className:`absolute top-1/2 right-1.5 -translate-y-1/2`,children:(0,I.jsx)(LI,{folded:c,onToggle:l,what:`conversations`})})]}),d!==void 0&&(0,I.jsx)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--color-accent)_22%,transparent)] p-1`,children:d})]})}function JI({label:e,detail:t,title:n,onOpen:r,onStop:i,stopping:a=!1}){return(0,I.jsxs)(`div`,{className:q(kI,`group/nav relative shrink-0`),children:[(0,I.jsxs)(`button`,{type:`button`,onClick:r,title:n,className:`flex w-full cursor-pointer items-center gap-3 rounded-[inherit] px-2.5 py-2 text-left`,children:[(0,I.jsx)(`span`,{className:`inline-flex size-8 shrink-0 items-center justify-center rounded-full bg-[color-mix(in_oklab,var(--color-accent)_14%,transparent)] text-accent-text`,children:(0,I.jsx)(ib,{size:14})}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,I.jsx)(`span`,{className:`truncate text-md text-text`,children:e}),(0,I.jsx)(`span`,{className:`truncate text-xs text-text-tertiary`,children:t})]}),(0,I.jsx)(`span`,{className:q(`transition-opacity duration-(--dur-1)`,i&&II),children:(0,I.jsx)(RA,{tone:`live`})})]}),i&&(0,I.jsx)(`span`,{className:q(`absolute top-1/2 right-1.5 -translate-y-1/2 transition-opacity duration-(--dur-1)`,FI),children:(0,I.jsx)(Y,{size:`sm`,label:`Stop the ${e.toLowerCase()}`,icon:(0,I.jsx)(ab,{}),disabled:a,onClick:i})})]})}var ite={on:`Notifications on — turn off`,off:`Notifications off — turn on`,blocked:`Notifications blocked by the browser`};function ate({healthTone:e,healthTip:t,sandbox:n,notify:r,theme:i,onToggleTheme:a,onOpenSettings:o}){return(0,I.jsxs)(`div`,{className:`flex h-8 items-center gap-0.5 pl-0.5`,children:[o&&(0,I.jsx)(Y,{size:`sm`,label:`Settings`,icon:(0,I.jsx)(Ny,{}),onClick:o}),(0,I.jsx)(Y,{size:`sm`,label:`Switch to ${i===`dark`?`light`:`dark`} theme`,icon:i===`dark`?(0,I.jsx)(gb,{}):(0,I.jsx)(_b,{}),onClick:a}),r&&(0,I.jsx)(Y,{size:`sm`,label:r.state===`blocked`?r.title:ite[r.state],icon:r.state===`on`?(0,I.jsx)(Iy,{}):(0,I.jsx)(Ly,{}),active:r.state===`on`,onClick:r.onToggle}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(OE,{label:`${t} · agents run sandboxed via ${n}`,children:(0,I.jsxs)(`span`,{tabIndex:0,className:`mr-2 inline-flex items-center gap-1.5 rounded-sm`,"data-health-tone":e,children:[(0,I.jsx)($y,{size:14,className:`text-icon`}),(0,I.jsx)(RA,{tone:e})]})})]})}var ote=(()=>{let e=new Map;for(let t=8/2;t<256;t+=8)for(let n=8/2;n<640;n+=8){let r=Math.round(11*(1-Math.hypot((n-640/2)/368,t/294.4)))/10;r>=.2&&e.set(r,`${e.get(r)??``}M${n} ${t}h0`)}let t=`<svg xmlns='http://www.w3.org/2000/svg' width='640' height='256' stroke='black' stroke-linecap='round'>${[...e].map(([e,t])=>`<path d='${t}' stroke-width='${(2*e).toFixed(1)}'/>`).join(``)}</svg>`;return`url("data:image/svg+xml,${encodeURIComponent(t)}")`})();function YI({large:e=!1}){return(0,I.jsx)(XI,{large:e,children:(0,I.jsx)(Zy,{size:e?26:18})})}function XI({large:e=!1,className:t,children:n}){return(0,I.jsx)(`span`,{className:q(`inline-flex shrink-0 items-center justify-center bg-[color-mix(in_oklab,var(--color-accent)_18%,transparent)] text-accent-text shadow-[inset_0_1px_0_color-mix(in_oklab,var(--color-text)_12%,transparent)] ring-1 ring-[color-mix(in_oklab,var(--color-accent)_35%,transparent)] ring-inset`,e?`size-14 rounded-lg`:`size-9 rounded-md`,t),children:n})}function ZI(){return(0,I.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 -z-10 h-64 overflow-hidden`,children:(0,I.jsx)(`div`,{className:`absolute top-0 left-1/2 h-64 w-[640px] -translate-x-1/2 bg-[color-mix(in_oklab,var(--color-text)_6%,transparent)]`,style:{maskImage:ote}})})}function ste({title:e,onClose:t,onSave:n}){let[r,i]=(0,F.useState)(e),a=r.trim(),o=()=>{a&&a!==e?n(a):t()};return(0,I.jsx)(aP,{open:!0,onClose:t,size:`sm`,labelledBy:`rename-thread-title`,children:(0,I.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),o()},children:[(0,I.jsx)(oP,{id:`rename-thread-title`,title:`Rename thread`}),(0,I.jsx)(sP,{children:(0,I.jsx)(EN,{"aria-label":`Thread name`,value:r,onChange:e=>i(e.target.value),maxLength:200,autoFocus:!0})}),(0,I.jsxs)(cP,{children:[(0,I.jsx)(J,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,I.jsx)(J,{type:`submit`,variant:`primary`,disabled:!a,children:`Rename`})]})]})})}var QI=`runcastle.sidebar.showArchived`;function cte(){try{return localStorage.getItem(QI)===`1`}catch{return!1}}function $I(e){return[...e].sort((e,t)=>t.lastActivityAt-e.lastActivityAt)}var lte={waiting:`Waiting for you`,working:`Working`,idle:`Plan, cut and ask`};function ute(e){return e.some(e=>e.state===`waiting`)?`waiting`:e.some(e=>e.state===`working`)?`working`:`idle`}var dte=`Your project's orchestrator: it plans, starts, messages and merges features when you ask, and edits this repo and runs commands without asking.`;function fte(e){let{projectId:t,nav:n,view:r,selectedFeatureId:i,onSelect:a,onSelectProject:o,onNewChat:s,onDraft:c,onOpenPreparation:l,onOpenNote:u,onOpenCmdk:d}=e,f=R.useUtils(),p=rx(),m=zx(),[h,g]=(0,F.useState)(cte),[_,v]=(0,F.useState)(null),y=R.feature.list.useQuery({projectId:t},{refetchInterval:tg()}),b=R.project.prep.useQuery({projectId:t}),x=jy(b.data&&{prepared:b.data.prepared,pendingCount:b.data.pendingKeys.length,staleCount:b.data.findings.filter(Lm).length}),S=R.projectNotes.openCount.useQuery({projectId:t}).data??0,C=ute(R.thread.list.useQuery({projectId:t},{refetchInterval:tg()}).data??[]),w=y.data??[],{inbox:T,lanes:E}=Rg(w),D=e=>E.find(t=>t.key===e)?.features??[],O=D(`inProgress`),k=D(`agentWorking`),ee=w.filter(e=>e.status===`archived`),A=()=>void f.feature.list.invalidate(),j=R.feature.archive.useMutation({onSuccess:A,onError:e=>p.push(e.message)}),M=R.feature.unarchive.useMutation({onSuccess:A,onError:e=>p.push(e.message)}),N=R.feature.delete.useMutation({onSuccess:(e,t)=>{A(),t.featureId===i&&(a(null),o()),v(null)},onError:e=>p.push(e.message)}),te=e=>{g(e);try{localStorage.setItem(QI,e?`1`:`0`)}catch{}},ne=e=>{let n=[{key:`copy-link`,label:`Copy link`,onSelect:()=>HF(window.location.origin+f_({kind:`feature`,projectId:t,featureSlug:e.slug}),p)}];return e.status===`archived`?n.push({key:`unarchive`,label:`Unarchive`,onSelect:()=>M.mutate({featureId:e.id})}):e.status!==`draft`&&n.push({key:`archive`,label:`Archive`,onSelect:()=>j.mutate({featureId:e.id})}),e.status!==`shipped`&&n.push({key:`delete`,label:`Delete…`,danger:!0,onSelect:t=>v({feature:e,returnFocusRef:t})}),n},re=Ex(),ie=Fx(),ae=VF(),[P,oe]=(0,F.useState)(null),se=e=>e.id===`unstarted`?[]:[{key:`rename`,label:`Rename…`,onSelect:()=>oe({threadId:e.id,title:e.title})},{key:`export`,label:`Export as Markdown`,icon:(0,I.jsx)(Jy,{}),onSelect:()=>ae.exportMarkdown(e.id,e.title)},...re?.errand?.threadId===e.id?[{key:`close-errand`,label:`Close the scenario chat`,icon:(0,I.jsx)(By,{}),onSelect:re.errand.close}]:[]],ce=r===`feature`&&re&&`featureId`in re.scope&&re.scope.featureId===i?re:null,le=r===`project`&&re&&`projectId`in re.scope?re:null,ue=e=>{let t=Ox(e.id,w);return[...t.map((e,n)=>({key:`open-${e.id}`,label:e.title,icon:(0,I.jsx)(AI,{f:e,size:14,label:``}),ruleAfter:n===t.length-1,onSelect:()=>a(e.id)})),...se(e)]},de=(e,t=!1)=>{if(m)return(0,I.jsx)(BI,{f:e,active:!1,onSelect:a,actions:[],nested:t},e.id);let n=e.id===i&&r===`feature`,o=n&&ce?ce:null,s=o?Dx(o.threads):[],c=o&&s.length>1?(0,I.jsx)(qI,{threads:s,current:o.current,onOpen:o.pick,actionsFor:se}):void 0,l=o?Nx(o.scope):``,u=o&&s.length===1&&s[0].id!==`unstarted`?s[0]:null,d=u?[{key:`rename-chat`,label:`Rename the chat…`,icon:(0,I.jsx)(Yy,{}),onSelect:()=>oe({threadId:u.id,title:u.title})},{key:`export-chat`,label:`Export the chat as Markdown`,icon:(0,I.jsx)(Jy,{}),onSelect:()=>ae.exportMarkdown(u.id,u.title)}]:[];return(0,I.jsx)(BI,{f:e,active:n,onSelect:e=>{let t=o&&s.find(e=>e.role===`main`);t&&o.pick(t.id),(!t||t.id===`unstarted`)&&a(e)},actions:[...ne(e),...d],nested:t,...o?{onNewThread:o.newThread}:{},threads:c,folded:ie.folded(l),onToggleThreads:()=>ie.toggle(l)},e.id)},fe=le?Nx(le.scope):``,pe=S>0?` · ${S} note${S===1?``:`s`}`:``,me=x?.variant===`done`?[{key:`reprepare`,label:x.badge?`Re-prepare the project (${x.badge})`:`Re-prepare the project`,hint:x.title,onSelect:l}]:[],he=x?.variant===`todo`&&!m,ge=w.length>0&&!he&&T.length+O.length+k.length===0;return(0,I.jsxs)(`nav`,{"aria-label":`Project`,className:`relative isolate flex h-full min-h-0 flex-col p-2`,children:[(0,I.jsx)(ZI,{}),m?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(cI,{nav:n,onNewChat:s,...u?{onOpenNote:u}:{}}),(0,I.jsx)(lI,{failed:y.isError,readAt:y.dataUpdatedAt})]}):(0,I.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-0.5`,children:[(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1`,children:(0,I.jsx)(qF,{nav:n})}),(0,I.jsx)(Y,{label:`Search or jump to`,kbd:DP(`K`),size:`sm`,icon:(0,I.jsx)(My,{}),tooltipSide:`bottom`,onClick:d}),(0,I.jsx)(pte,{onNewChat:s,onDraft:c,onOpenNote:u}),(0,I.jsx)(nI,{})]}),(0,I.jsx)(`div`,{className:m?`mt-2`:`mt-3`,children:(0,I.jsx)(rte,{status:`${lte[C]}${pe}`,state:C,active:r===`project`&&!m,onOpen:o,actions:m?[]:me,title:dte,...le&&!m?{onNewThread:le.newThread,threads:(0,I.jsx)(qI,{label:`Conversations`,threads:Dx(le.threads),current:le.current,onOpen:le.pick,actionsFor:ue,keep:e=>e.id===le.errand?.threadId||kx(e,{current:le.current,features:w,now:Date.now()}),markFor:e=>{let t=Ox(e.id,w);return t.length>0?(0,I.jsx)(ete,{features:t}):null},tipFor:e=>{let t=Ox(e.id,w);return t.length>0?(0,I.jsx)(tte,{features:t}):void 0},...le.allConversations?{more:le.allConversations}:{}}),folded:ie.folded(fe),onToggleThreads:()=>ie.toggle(fe)}:{}})}),(0,I.jsxs)(`div`,{className:`-mx-2 mt-4 flex min-h-0 flex-1 flex-col gap-5 overflow-x-hidden overflow-y-auto px-2 pt-px pb-2 [scrollbar-color:var(--color-border)_transparent] [scrollbar-width:thin]`,children:[y.isLoading&&(0,I.jsx)(hte,{}),ge&&(0,I.jsx)(qA,{tone:`quiet`,label:`Nothing in motion`}),(he||T.length+O.length>0)&&(0,I.jsxs)(`section`,{"aria-label":`Needs you`,className:`flex flex-col gap-1`,children:[he&&(0,I.jsx)(VI,{label:x.label,badge:x.badge,title:x.title,active:r===`prepare`,onClick:l}),T.map(e=>de(e)),O.map(e=>de(e))]}),y.data&&y.data.length===0&&(0,I.jsx)(`div`,{className:`px-2.5 py-2 text-xs text-pretty text-text-tertiary`,children:`No features yet. Start a chat to cut the first one.`}),(0,I.jsx)(Qee,{features:k,renderRow:de}),(0,I.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-subtle`,children:[(0,I.jsx)(WI,{icon:(0,I.jsx)(xb,{}),label:`Up next`,features:D(`upNext`),renderRow:e=>de(e),defaultOpen:!0}),(0,I.jsx)(WI,{icon:(0,I.jsx)(bb,{}),label:`Backlog`,features:D(`drafts`),renderRow:e=>de(e)}),(0,I.jsx)(WI,{icon:(0,I.jsx)(pb,{}),label:`Shipped`,features:$I(D(`shipped`)),renderRow:e=>de(e),cap:5}),(0,I.jsx)(WI,{icon:(0,I.jsx)(db,{}),label:`Archived`,features:$I(ee),renderRow:e=>de(e),open:h,onOpenChange:te})]})]}),m?(0,I.jsx)(SI,{projectId:t}):(0,I.jsx)(vte,{...e}),_&&(0,I.jsx)(WF,{title:_.feature.title,slug:_.feature.slug,busy:N.isPending,onConfirm:()=>N.mutate({featureId:_.feature.id}),onCancel:()=>v(null),returnFocusRef:_.returnFocusRef}),P&&(0,I.jsx)(ste,{title:P.title,onClose:()=>oe(null),onSave:e=>{ae.rename(P.threadId,e),oe(null)}})]})}function pte({onNewChat:e,onDraft:t,onOpenNote:n}){return(0,I.jsxs)(mN,{children:[(0,I.jsx)(hN,{asChild:!0,children:(0,I.jsx)(Y,{label:`Create`,size:`sm`,icon:(0,I.jsx)(Yy,{}),tooltipSide:`bottom`})}),(0,I.jsxs)(gN,{align:`end`,className:`w-72`,children:[(0,I.jsx)(eL,{icon:(0,I.jsx)(qy,{}),label:`New chat`,hint:`A conversation with the feature's agent — it plans the work, builds it and runs rounds when you say yes`,onSelect:e}),(0,I.jsx)(eL,{icon:(0,I.jsx)(Jy,{}),label:`Add to backlog`,hint:`Write an idea down now, work it out later`,onSelect:t}),n&&(0,I.jsx)(eL,{icon:(0,I.jsx)(Yy,{}),label:`Jot a note`,hint:`What you just noticed — triage it later`,kbd:DP(`J`),onSelect:n})]})]})}function eL({icon:e,label:t,hint:n,kbd:r,onSelect:i}){return(0,I.jsxs)(_N,{className:`items-start py-1.5 [&>svg]:mt-0.5`,icon:e,onSelect:i,children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block`,children:t}),(0,I.jsx)(`span`,{className:`block text-xs text-pretty text-text-tertiary`,children:n})]}),r&&(0,I.jsx)(Yx,{className:`mt-0.5`,children:r})]})}var mte=[`w-32`,`w-24`,`w-36`,`w-28`];function hte(){return(0,I.jsx)(WN,{label:`Loading features…`,children:(0,I.jsx)(`div`,{className:`flex flex-col gap-1`,children:mte.map((e,t)=>(0,I.jsxs)(`div`,{className:`flex h-13 flex-col justify-center gap-2 rounded-lg px-2.5`,"data-skeleton":`feature-row`,children:[(0,I.jsx)(GN,{className:q(`h-2.5`,e)}),(0,I.jsx)(GN,{className:`h-2 w-16`})]},t))})})}function gte(){return typeof window>`u`?`this machine`:window.location.origin}var _te={connecting:`neutral`,ok:`success`,reconnecting:`warning`,down:`danger`};function tL({health:e,origin:t,sandbox:n,notify:r,theme:i,onToggleTheme:a,onOpenSettings:o,rows:s}){let c=e===`ok`?`Server ok — live updates streaming from ${t}/api`:e===`connecting`?`Connecting to the runcastle API at ${t}/api`:e===`reconnecting`?`Live updates paused — reconnecting, and polling meanwhile`:`The runcastle API at ${t}/api is not answering`;return(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 pt-2`,children:[s,(0,I.jsx)(ate,{healthTone:_te[e],healthTip:c,sandbox:n,notify:r,theme:i,onToggleTheme:a,onOpenSettings:o})]})}function vte({projectId:e,onSelect:t,onOpenSettings:n,projectDriveBranch:r=null,onOpenProjectDrive:i,onOpenFeatureDrive:a,driving:o=null,onDriveChange:s}){let c=rx(),l=R.useUtils(),u=Qh(),d=uF(),f=R.feature.list.useQuery({projectId:e},{refetchInterval:tg()}),p=!f.isError&&f.data!==void 0,m=GP(e,f.data??[]),h=IP(m),g=R.feature.testDrive.useMutation({onSuccess:()=>{s?.(null),o&&l.feature.get.invalidate({id:o.featureId}),l.feature.list.invalidate()},onError:e=>c.push(e.message)}),_=o?f.data?.find(e=>e.id===o.featureId)?.title:void 0,v=(0,I.jsxs)(I.Fragment,{children:[r!==null&&(0,I.jsx)(JI,{label:`Project drive`,detail:(0,I.jsx)(`span`,{className:`font-mono`,children:r}),title:`A project drive is live on ${r} — back to it`,onOpen:i}),o&&(0,I.jsx)(JI,{label:`Test drive`,detail:_??(0,I.jsx)(`span`,{className:`font-mono`,children:o.branch}),title:`Driving ${o.branch} — back to the drive`,onOpen:()=>(a??t)(o.featureId),onStop:()=>g.mutate({featureId:o.featureId,action:`stop`}),stopping:g.isPending})]});return(0,I.jsx)(tL,{health:f.isError?`down`:p?u===`live`?`ok`:u===`connecting`?`connecting`:`reconnecting`:`connecting`,origin:gte(),sandbox:AP,notify:m.supported?{...h,onToggle:m.toggle}:null,theme:d.resolved,onToggleTheme:d.toggle,onOpenSettings:n,rows:v})}function nL(e){let[t,n]=(0,F.useState)([]),r=t.length?t[t.length-1].id:void 0,i=R.events.list.useQuery({featureId:e,afterId:r},{refetchInterval:tg()});return(0,F.useEffect)(()=>{let e=i.data;!e||e.length===0||n(t=>{let n=new Set(t.map(e=>e.id)),r=e.filter(e=>!n.has(e.id));return r.length===0?t:[...t,...r].sort((e,t)=>e.id-t.id)})},[i.data]),t}var rL=(0,F.createContext)(null);function yte({open:e,children:t}){return(0,I.jsx)(rL.Provider,{value:e,children:t})}function bte(){return(0,F.useContext)(rL)}function iL({location:e,children:t}){let n=(0,F.useContext)(rL);return n?(0,I.jsx)(`button`,{type:`button`,className:GE,onClick:t=>{t.stopPropagation(),n(e)},children:t}):(0,I.jsx)(I.Fragment,{children:t})}function xte({text:e}){let t=(0,F.useContext)(rL),n=jh(e);return!t||!n?(0,I.jsx)(I.Fragment,{children:e}):(0,I.jsxs)(I.Fragment,{children:[n.before,(0,I.jsx)(iL,{location:n.location,children:n.phrase}),n.after]})}function Ste(e,t){let n=R.useUtils(),r=rx(),i=e=>r.push(e.message),a=()=>{n.feature.get.invalidate({id:e}),n.feature.list.invalidate(),n.events.invalidate()},o=R.feature.endSession.useMutation({onError:i}),s=hx(e),c=R.feature.launchSession.useMutation({onSuccess:()=>{a(),s()},onError:i});return{pending:o.isPending||c.isPending,resolve:async(n,r)=>{if(r){try{await o.mutateAsync({sessionId:r})}catch{return}a()}c.mutate({featureId:e,kind:`chat`,kickoffLine:Q_(n.base,t,n.files),purpose:`resolve-conflict`,purposeData:{mergeFrom:n.base,mergeInto:t}})}}}function Cte({title:e,branch:t,base:n,summary:r,busy:i,resolving:a,onConfirm:o,onResolve:s,onCancel:c}){return(0,I.jsx)(aP,{open:!0,onClose:c,labelledBy:`merge-feature-title`,size:r.conflictRow&&s?`md`:`sm`,className:`flex max-h-[82vh] flex-col overflow-hidden`,children:(0,I.jsx)(Tte,{title:e,branch:t,base:n,summary:r,busy:i,resolving:a,onConfirm:o,onResolve:s,onCancel:c})})}function wte({warnings:e}){return e.length===0?null:(0,I.jsx)(`ul`,{"aria-label":`Warnings`,className:`m-0 flex list-none flex-col gap-2 p-0 text-sm text-text-secondary [&>li]:relative [&>li]:pl-6`,children:e.map(e=>(0,I.jsxs)(`li`,{children:[(0,I.jsx)(Sb,{size:16,className:`absolute top-0.5 left-0 text-warning`}),e]},e))})}function Tte({title:e,branch:t,base:n,summary:r,busy:i,resolving:a,onConfirm:o,onResolve:s,onCancel:c}){let l=!!r.conflictRow&&!!s;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(oP,{id:`merge-feature-title`,title:`Merge & ship`,onClose:c,description:(0,I.jsxs)(I.Fragment,{children:[`Merge `,(0,I.jsx)(`span`,{className:`font-medium text-text`,children:e}),` from`,` `,(0,I.jsx)(`code`,{className:`font-mono text-xs`,children:t}),n?(0,I.jsxs)(I.Fragment,{children:[` `,`into `,(0,I.jsx)(`code`,{className:`font-mono text-xs`,children:n})]}):null,`? This ships the feature.`]})}),(0,I.jsxs)(sP,{className:`flex min-h-0 flex-col gap-5 overflow-y-auto`,children:[(0,I.jsxs)(`section`,{children:[(0,I.jsx)(WA,{children:`What lands`}),r.conflictRow&&(0,I.jsx)(`div`,{className:`mt-1 mb-2`,children:(0,I.jsx)(eP,{message:r.conflictRow})}),r.rows.map(e=>(0,I.jsx)(UA,{row:e},e.key))]}),(0,I.jsx)(wte,{warnings:r.warnings}),(0,I.jsx)(`p`,{className:`m-0 text-sm text-text-tertiary`,children:r.next}),l&&(0,I.jsx)(`p`,{className:`m-0 text-sm text-text-tertiary`,children:`Nothing here is disabled — if you resolved it by hand, retry lands it.`})]}),(0,I.jsxs)(cP,{className:`border-t border-border-subtle pt-4`,children:[(0,I.jsx)(J,{variant:`ghost`,onClick:c,disabled:i,children:`Cancel`}),l?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(J,{variant:`secondary`,icon:(0,I.jsx)(Db,{}),onClick:o,disabled:i,children:i?`Merging…`:`Retry merge anyway`}),(0,I.jsx)(J,{variant:`primary`,icon:(0,I.jsx)(Sb,{}),onClick:s,disabled:a,children:`Resolve the merge conflict`})]}):(0,I.jsx)(J,{variant:`primary`,icon:(0,I.jsx)(pb,{}),onClick:o,disabled:i,children:i?`Merging…`:`Merge & ship`})]})]})}function Ete(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Dte=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ote=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,kte={};function aL(e,t){return((t||kte).jsx?Ote:Dte).test(e)}var Ate=/[ \t\n\f\r]/g;function jte(e){return typeof e==`object`?e.type===`text`&&oL(e.value):oL(e)}function oL(e){return e.replace(Ate,``)===``}var sL=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};sL.prototype.normal={},sL.prototype.property={},sL.prototype.space=void 0;function cL(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new sL(n,r,t)}function lL(e){return e.toLowerCase()}var uL=class{constructor(e,t){this.attribute=t,this.property=e}};uL.prototype.attribute=``,uL.prototype.booleanish=!1,uL.prototype.boolean=!1,uL.prototype.commaOrSpaceSeparated=!1,uL.prototype.commaSeparated=!1,uL.prototype.defined=!1,uL.prototype.mustUseProperty=!1,uL.prototype.number=!1,uL.prototype.overloadedBoolean=!1,uL.prototype.property=``,uL.prototype.spaceSeparated=!1,uL.prototype.space=void 0;var dL=s({boolean:()=>fL,booleanish:()=>pL,commaOrSpaceSeparated:()=>_L,commaSeparated:()=>gL,number:()=>X,overloadedBoolean:()=>mL,spaceSeparated:()=>hL}),Mte=0,fL=vL(),pL=vL(),mL=vL(),X=vL(),hL=vL(),gL=vL(),_L=vL();function vL(){return 2**++Mte}var yL=Object.keys(dL),bL=class extends uL{constructor(e,t,n,r){let i=-1;if(super(e,t),xL(this,`space`,r),typeof n==`number`)for(;++i<yL.length;){let e=yL[i];xL(this,yL[i],(n&dL[e])===dL[e])}}};bL.prototype.defined=!0;function xL(e,t,n){n&&(e[t]=n)}function SL(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new bL(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[lL(r)]=r,n[lL(a.attribute)]=r}return new sL(t,n,e.space)}var CL=SL({properties:{ariaActiveDescendant:null,ariaAtomic:pL,ariaAutoComplete:null,ariaBusy:pL,ariaChecked:pL,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:hL,ariaCurrent:null,ariaDescribedBy:hL,ariaDetails:null,ariaDisabled:pL,ariaDropEffect:hL,ariaErrorMessage:null,ariaExpanded:pL,ariaFlowTo:hL,ariaGrabbed:pL,ariaHasPopup:null,ariaHidden:pL,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:hL,ariaLevel:X,ariaLive:null,ariaModal:pL,ariaMultiLine:pL,ariaMultiSelectable:pL,ariaOrientation:null,ariaOwns:hL,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:pL,ariaReadOnly:pL,ariaRelevant:null,ariaRequired:pL,ariaRoleDescription:hL,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:pL,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function wL(e,t){return t in e?e[t]:t}function TL(e,t){return wL(e,t.toLowerCase())}var Nte=SL({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:gL,acceptCharset:hL,accessKey:hL,action:null,allow:null,allowFullScreen:fL,allowPaymentRequest:fL,allowUserMedia:fL,alpha:fL,alt:null,as:null,async:fL,autoCapitalize:null,autoComplete:hL,autoFocus:fL,autoPlay:fL,blocking:hL,capture:null,charSet:null,checked:fL,cite:null,className:hL,closedBy:null,colorSpace:null,cols:X,colSpan:X,command:null,commandFor:null,content:null,contentEditable:pL,controls:fL,controlsList:hL,coords:X|gL,crossOrigin:null,data:null,dateTime:null,decoding:null,default:fL,defer:fL,dir:null,dirName:null,disabled:fL,download:mL,draggable:pL,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:fL,formTarget:null,headers:hL,height:X,hidden:mL,high:X,href:null,hrefLang:null,htmlFor:hL,httpEquiv:hL,id:null,imageSizes:null,imageSrcSet:null,inert:fL,inputMode:null,integrity:null,is:null,isMap:fL,itemId:null,itemProp:hL,itemRef:hL,itemScope:fL,itemType:hL,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:fL,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:fL,muted:fL,name:null,nonce:null,noModule:fL,noValidate:fL,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:fL,optimum:X,pattern:null,ping:hL,placeholder:null,playsInline:fL,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:fL,referrerPolicy:null,rel:hL,required:fL,reversed:fL,rows:X,rowSpan:X,sandbox:hL,scope:null,scoped:fL,seamless:fL,selected:fL,shadowRootClonable:fL,shadowRootCustomElementRegistry:fL,shadowRootDelegatesFocus:fL,shadowRootMode:null,shadowRootSerializable:fL,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:pL,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:fL,useMap:null,value:pL,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:hL,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:fL,declare:fL,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:fL,noHref:fL,noShade:fL,noWrap:fL,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:pL,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:fL,disablePictureInPicture:fL,disableRemotePlayback:fL,exportParts:gL,part:hL,prefix:null,property:null,results:X,security:null,unselectable:null},space:`html`,transform:TL}),Pte=SL({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:_L,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:hL,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:fL,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:gL,g2:gL,glyphName:gL,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:_L,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:X,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:hL,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:_L,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:_L,rev:_L,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:_L,requiredFeatures:_L,requiredFonts:_L,requiredFormats:_L,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:_L,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:_L,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:_L,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:wL}),EL=SL({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),DL=SL({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:TL}),OL=SL({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Fte={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},Ite=/[A-Z]/g,kL=/-[a-z]/g,Lte=/^data[-\w.:]+$/i;function AL(e,t){let n=lL(t),r=t,i=uL;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Lte.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(kL,ML);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!kL.test(e)){let n=e.replace(Ite,jL);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=bL}return new i(r,t)}function jL(e){return`-`+e.toLowerCase()}function ML(e){return e.charAt(1).toUpperCase()}var NL=cL([CL,Nte,EL,DL,OL],`html`),PL=cL([CL,Pte,EL,DL,OL],`svg`);function FL(e){return e.join(` `).trim()}var IL=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
120
|
-
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(!(e.charAt(0)!=`/`||e.charAt(1)!=`*`)){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),LL=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(IL());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),RL=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),zL=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(LL()),r=RL();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),BL=HL(`end`),VL=HL(`start`);function HL(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function UL(e){let t=VL(e),n=BL(e);if(t&&n)return{start:t,end:n}}function WL(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?KL(e.position):`start`in e||`end`in e?KL(e):`line`in e||`column`in e?GL(e):``}function GL(e){return qL(e&&e.line)+`:`+qL(e&&e.column)}function KL(e){return GL(e&&e.start)+`-`+GL(e&&e.end)}function qL(e){return e&&typeof e==`number`?e:1}var JL=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=WL(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};JL.prototype.file=``,JL.prototype.name=``,JL.prototype.reason=``,JL.prototype.message=``,JL.prototype.stack=``,JL.prototype.column=void 0,JL.prototype.line=void 0,JL.prototype.ancestors=void 0,JL.prototype.cause=void 0,JL.prototype.fatal=void 0,JL.prototype.place=void 0,JL.prototype.ruleId=void 0,JL.prototype.source=void 0;var YL=l(zL(),1),XL={}.hasOwnProperty,ZL=new Map,QL=/[A-Z]/g,$L=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),eR=new Set([`td`,`th`]);function tR(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=fR(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=dR(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?PL:NL,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=nR(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function nR(e,t,n){if(t.type===`element`)return rR(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return iR(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return oR(e,t,n);if(t.type===`mdxjsEsm`)return aR(e,t);if(t.type===`root`)return sR(e,t,n);if(t.type===`text`)return cR(e,t)}function rR(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=PL,e.schema=i),e.ancestors.push(t);let a=vR(e,t.tagName,!1),o=pR(e,t),s=hR(e,t);return $L.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!jte(e)})),lR(e,o,a,t),uR(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function iR(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}yR(e,t.position)}function aR(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);yR(e,t.position)}function oR(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=PL,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:vR(e,t.name,!0),o=mR(e,t),s=hR(e,t);return lR(e,o,a,t),uR(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function sR(e,t,n){let r={};return uR(r,hR(e,t)),e.create(t,e.Fragment,r,n)}function cR(e,t){return t.value}function lR(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function uR(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function dR(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function fR(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=VL(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function pR(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&XL.call(t.properties,i)){let a=gR(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&eR.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function mR(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else yR(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else yR(e,t.position);else a=r.value===null||r.value;n[i]=a}return n}function hR(e,t){let n=[],r=-1,i=e.passKeys?new Map:ZL;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=nR(e,a,o);s!==void 0&&n.push(s)}return n}function gR(e,t,n){let r=AL(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Ete(n):FL(n)),r.property===`style`){let t=typeof n==`object`?n:_R(e,String(n));return e.stylePropertyNameCase===`css`&&(t=bR(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Fte[r.property]||r.property:r.attribute,n]}}function _R(e,t){try{return(0,YL.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new JL("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute`,r}}function vR(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=aL(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=aL(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return XL.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);yR(e)}function yR(e,t){let n=new JL("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater`,n}function bR(e){let t={},n;for(n in e)XL.call(e,n)&&(t[xR(n)]=e[n]);return t}function xR(e){let t=e.replace(QL,SR);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function SR(e){return`-`+e.toLowerCase()}var CR={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},wR={};function TR(e,t){let n=t||wR;return ER(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function ER(e,t,n){if(OR(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return DR(e.children,t,n)}return Array.isArray(e)?DR(e,t,n):``}function DR(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=ER(e[i],t,n);return r.join(``)}function OR(e){return!!(e&&typeof e==`object`)}var kR=document.createElement(`i`);function AR(e){let t=`&`+e+`;`;kR.innerHTML=t;let n=kR.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function jR(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function MR(e,t){return e.length>0?(jR(e,e.length,0,t),e):t}var NR={}.hasOwnProperty;function PR(e){let t={},n=-1;for(;++n<e.length;)FR(t,e[n]);return t}function FR(e,t){let n;for(n in t){let r=(NR.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){NR.call(r,a)||(r[a]=[]);let e=i[a];IR(r[a],Array.isArray(e)?e:e?[e]:[])}}}function IR(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);jR(e,0,0,r)}function LR(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function RR(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var zR=ZR(/[A-Za-z]/),BR=ZR(/[\dA-Za-z]/),VR=ZR(/[#-'*+\--9=?A-Z^-~]/);function HR(e){return e!==null&&(e<32||e===127)}var UR=ZR(/\d/),WR=ZR(/[\dA-Fa-f]/),GR=ZR(/[!-/:-@[-`{-~]/);function KR(e){return e!==null&&e<-2}function qR(e){return e!==null&&(e<0||e===32)}function JR(e){return e===-2||e===-1||e===32}var YR=ZR(/\p{P}|\p{S}/u),XR=ZR(/\s/);function ZR(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function QR(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&BR(e.charCodeAt(n+1))&&BR(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function $R(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return JR(r)?(e.enter(n),s(r)):t(r)}function s(r){return JR(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var ez={tokenize:tz};function tz(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),$R(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return KR(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var nz={tokenize:iz},rz={tokenize:az};function iz(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return jR(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(rz,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(rz,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return KR(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;jR(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function az(e,t,n){return $R(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function oz(e){if(e===null||qR(e)||XR(e))return 1;if(YR(e))return 2}function sz(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var cz={name:`attention`,resolveAll:lz,tokenize:uz};function lz(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};dz(d,-c),dz(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=MR(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=MR(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=MR(l,sz(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=MR(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=MR(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,jR(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function uz(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=oz(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=oz(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function dz(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var fz={name:`autolink`,tokenize:pz};function pz(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return zR(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||BR(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||BR(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||HR(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):VR(t)?(e.consume(t),l):n(t)}function u(e){return BR(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||BR(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var mz={partial:!0,tokenize:hz};function hz(e,t,n){return r;function r(t){return JR(t)?$R(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||KR(e)?t(e):n(e)}}var gz={continuation:{tokenize:vz},exit:yz,name:`blockQuote`,tokenize:_z};function _z(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return JR(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function vz(e,t,n){let r=this;return i;function i(t){return JR(t)?$R(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(gz,t,n)(r)}}function yz(e){e.exit(`blockQuote`)}var bz={name:`characterEscape`,tokenize:xz};function xz(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return GR(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var Sz={name:`characterReference`,tokenize:Cz};function Cz(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=BR,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=WR,u):(e.enter(`characterReferenceValue`),a=7,o=UR,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===BR&&!AR(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var wz={partial:!0,tokenize:Dz},Tz={concrete:!0,name:`codeFenced`,tokenize:Ez};function Ez(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),JR(t)?$R(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||KR(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(wz,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||KR(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):JR(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),$R(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||KR(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||KR(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&JR(t)?$R(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||KR(t)?e.check(wz,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||KR(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),JR(t)?$R(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),JR(t)?$R(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||KR(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function Dz(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var Oz={name:`codeIndented`,tokenize:Az},kz={partial:!0,tokenize:jz};function Az(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),$R(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):KR(t)?e.attempt(kz,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||KR(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function jz(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):KR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):$R(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):KR(e)?i(e):n(e)}}var Mz={name:`codeText`,previous:Pz,resolve:Nz,tokenize:Fz};function Nz(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Pz(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function Fz(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):KR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||KR(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var Iz=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Lz(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Lz(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Lz(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);Lz(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Lz(this.left,t.reverse())}}};function Lz(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Rz(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Iz(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,zz(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return jR(e,0,1/0,u.slice(0)),!l}function zz(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Bz={resolve:Hz,tokenize:Uz},Vz={partial:!0,tokenize:Wz};function Hz(e){return Rz(e),e}function Uz(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):KR(t)?e.check(Vz,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Wz(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),$R(e,a,`linePrefix`)}function a(i){if(i===null||KR(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Gz(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||HR(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||KR(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||qR(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||HR(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Kz(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):KR(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||KR(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!JR(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function qz(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):KR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),$R(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||KR(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Jz(e,t){let n;return r;function r(i){return KR(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):JR(i)?$R(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Yz={name:`definition`,tokenize:Zz},Xz={partial:!0,tokenize:Qz};function Zz(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Kz.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=RR(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return qR(t)?Jz(e,l)(t):l(t)}function l(t){return Gz(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Xz,d,d)(t)}function d(t){return JR(t)?$R(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||KR(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Qz(e,t,n){return r;function r(t){return qR(t)?Jz(e,i)(t):n(t)}function i(t){return qz(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return JR(t)?$R(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||KR(e)?t(e):n(e)}}var $z={name:`hardBreakEscape`,tokenize:eB};function eB(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return KR(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var tB={name:`headingAtx`,resolve:nB,tokenize:rB};function nB(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},jR(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function rB(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||qR(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||KR(n)?(e.exit(`atxHeading`),t(n)):JR(n)?$R(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||qR(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var iB=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),aB=[`pre`,`script`,`style`,`textarea`],oB={concrete:!0,name:`htmlFlow`,resolveTo:lB,tokenize:uB},sB={partial:!0,tokenize:fB},cB={partial:!0,tokenize:dB};function lB(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function uB(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:ne):zR(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):zR(a)?(e.consume(a),i=4,r.interrupt?t:ne):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:ne):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return zR(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||qR(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&aB.includes(l)?(i=1,r.interrupt?t(s):O(s)):iB.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||BR(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return JR(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||zR(t)?(e.consume(t),b):JR(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||BR(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):JR(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):JR(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||KR(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||qR(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||JR(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||KR(t)?O(t):JR(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),j):t===60&&i===1?(e.consume(t),M):t===62&&i===4?(e.consume(t),re):t===63&&i===3?(e.consume(t),ne):t===93&&i===5?(e.consume(t),te):KR(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(sB,ie,k)(t)):t===null||KR(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(cB,ee,ie)(t)}function ee(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),A}function A(t){return t===null||KR(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function j(t){return t===45?(e.consume(t),ne):O(t)}function M(t){return t===47?(e.consume(t),o=``,N):O(t)}function N(t){if(t===62){let n=o.toLowerCase();return aB.includes(n)?(e.consume(t),re):O(t)}return zR(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),N):O(t)}function te(t){return t===93?(e.consume(t),ne):O(t)}function ne(t){return t===62?(e.consume(t),re):t===45&&i===2?(e.consume(t),ne):O(t)}function re(t){return t===null||KR(t)?(e.exit(`htmlFlowData`),ie(t)):(e.consume(t),re)}function ie(n){return e.exit(`htmlFlow`),t(n)}}function dB(e,t,n){let r=this;return i;function i(t){return KR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function fB(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(mz,t,n)}}var pB={name:`htmlText`,tokenize:mB};function mB(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):zR(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):zR(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):KR(t)?(o=d,M(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?j(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):KR(t)?(o=h,M(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?j(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?j(t):KR(t)?(o=v,M(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):KR(t)?(o=y,M(t)):(e.consume(t),y)}function b(e){return e===62?j(e):y(e)}function x(t){return zR(t)?(e.consume(t),S):n(t)}function S(t){return t===45||BR(t)?(e.consume(t),S):C(t)}function C(t){return KR(t)?(o=C,M(t)):JR(t)?(e.consume(t),C):j(t)}function w(t){return t===45||BR(t)?(e.consume(t),w):t===47||t===62||qR(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),j):t===58||t===95||zR(t)?(e.consume(t),E):KR(t)?(o=T,M(t)):JR(t)?(e.consume(t),T):j(t)}function E(t){return t===45||t===46||t===58||t===95||BR(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):KR(t)?(o=D,M(t)):JR(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):KR(t)?(o=O,M(t)):JR(t)?(e.consume(t),O):(e.consume(t),ee)}function k(t){return t===i?(e.consume(t),i=void 0,A):t===null?n(t):KR(t)?(o=k,M(t)):(e.consume(t),k)}function ee(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||qR(t)?T(t):(e.consume(t),ee)}function A(e){return e===47||e===62||qR(e)?T(e):n(e)}function j(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function M(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),N}function N(t){return JR(t)?$R(e,te,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):te(t)}function te(t){return e.enter(`htmlTextData`),o(t)}}var hB={name:`labelEnd`,resolveAll:yB,resolveTo:bB,tokenize:xB},gB={tokenize:SB},_B={tokenize:CB},vB={tokenize:wB};function yB(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&jR(e,0,e.length,n),e}function bB(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=MR(s,e.slice(a+1,a+r+3)),s=MR(s,[[`enter`,u,t]]),s=MR(s,sz(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=MR(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=MR(s,e.slice(o+1)),s=MR(s,[[`exit`,c,t]]),jR(e,a,e.length,s),e}function xB(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(RR(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(gB,u,o?u:d)(t):t===91?e.attempt(_B,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(vB,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function SB(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return qR(t)?Jz(e,a)(t):a(t)}function a(t){return t===41?u(t):Gz(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return qR(t)?Jz(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?qz(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return qR(t)?Jz(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function CB(e,t,n){let r=this;return i;function i(t){return Kz.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(RR(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function wB(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var TB={name:`labelStartImage`,resolveAll:hB.resolveAll,tokenize:EB};function EB(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var DB={name:`labelStartLink`,resolveAll:hB.resolveAll,tokenize:OB};function OB(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var kB={name:`lineEnding`,tokenize:AB};function AB(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),$R(e,t,`linePrefix`)}}var jB={name:`thematicBreak`,tokenize:MB};function MB(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||KR(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),JR(t)?$R(e,s,`whitespace`)(t):s(t))}}var NB={continuation:{tokenize:LB},exit:zB,name:`list`,tokenize:IB},PB={partial:!0,tokenize:BB},FB={partial:!0,tokenize:RB};function IB(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:UR(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(jB,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return UR(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(mz,r.interrupt?n:u,e.attempt(PB,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return JR(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function LB(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(mz,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,$R(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!JR(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(FB,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,$R(e,e.attempt(NB,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function RB(e,t,n){let r=this;return $R(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function zB(e){e.exit(this.containerState.type)}function BB(e,t,n){let r=this;return $R(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!JR(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var VB={name:`setextUnderline`,resolveTo:HB,tokenize:UB};function HB(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function UB(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),JR(t)?$R(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||KR(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var WB={tokenize:GB};function GB(e){let t=this,n=e.attempt(mz,r,e.attempt(this.parser.constructs.flowInitial,i,$R(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Bz,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var KB={resolveAll:XB()},qB=YB(`string`),JB=YB(`text`);function YB(e){return{resolveAll:XB(e===`text`?ZB:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function XB(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function ZB(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var QB=s({attentionMarkers:()=>oV,contentInitial:()=>eV,disable:()=>sV,document:()=>$B,flow:()=>nV,flowInitial:()=>tV,insideSpan:()=>aV,string:()=>rV,text:()=>iV}),$B={42:NB,43:NB,45:NB,48:NB,49:NB,50:NB,51:NB,52:NB,53:NB,54:NB,55:NB,56:NB,57:NB,62:gz},eV={91:Yz},tV={[-2]:Oz,[-1]:Oz,32:Oz},nV={35:tB,42:jB,45:[VB,jB],60:oB,61:VB,95:jB,96:Tz,126:Tz},rV={38:Sz,92:bz},iV={[-5]:kB,[-4]:kB,[-3]:kB,33:TB,38:Sz,42:cz,60:[fz,pB],91:DB,92:[$z,bz],93:hB,95:cz,96:Mz},aV={null:[cz,KB]},oV={null:[42,95]},sV={null:[]};function cV(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=MR(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=sz(a,l.events,l),l.events):[]}function f(e,t){return uV(p(e),t)}function p(e){return lV(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){KR(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&jR(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function lV(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function uV(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
121
|
-
`;break;case-3:o=`\r
|
|
122
|
-
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function dV(e){let t={constructs:PR([QB,...(e||{}).extensions||[]]),content:n(ez),defined:[],document:n(nz),flow:n(WB),lazy:{},string:n(qB),text:n(JB)};return t;function n(e){return n;function n(n){return cV(t,e,n)}}}function fV(e){for(;!Rz(e););return e}var pV=/[\0\t\n\r]/g;function mV(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(pV.lastIndex=u,c=pV.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var hV=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function gV(e){return e.replace(hV,_V)}function _V(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return LR(n.slice(t?2:1),t?16:10)}return AR(n)||e}var vV={}.hasOwnProperty;function yV(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),bV(n)(fV(dV(n).document().write(mV()(e,t,!0))))}function bV(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(be),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ge),blockQuote:a(de),characterEscape:T,characterReference:T,codeFenced:a(fe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(fe,o),codeText:a(pe,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(me),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(he),hardBreakEscape:a(_e),hardBreakTrailing:a(_e),htmlFlow:a(ve,o),htmlFlowData:T,htmlText:a(ve,o),htmlTextData:T,image:a(ye),label:o,link:a(be),listItem:a(Se),listItemValue:f,listOrdered:a(xe,d),listUnordered:a(xe),paragraph:a(Ce),reference:ae,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ge),strong:a(we),thematicBreak:a(Ee)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:ue,autolinkProtocol:le,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:oe,characterReferenceMarkerNumeric:oe,characterReferenceValue:se,characterReference:ce,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(A),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(ee),htmlTextData:E,image:c(M),label:te,labelText:N,lineEnding:D,link:c(j),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:P,resourceDestinationString:ne,resourceTitleString:re,resource:ie,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};SV(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];vV.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||wV).call(a,void 0,e[0])}for(r.position={start:xV(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:xV(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:xV(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||wV).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+WL({start:e.start,end:e.end})+`): it’s not open`);n.position.end=xV(e.end)}function u(){return TR(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=RR(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Te(),n.position={start:xV(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=xV(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=xV(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ee(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=gV(t),n.identifier=RR(t).toLowerCase()}function te(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function ne(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ie(){this.data.inReference=void 0}function ae(){this.data.referenceType=`collapsed`}function P(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=RR(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function oe(e){this.data.characterReferenceType=e.type}function se(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=LR(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=AR(t);let i=this.stack[this.stack.length-1];i.value+=r}function ce(e){let t=this.stack.pop();t.position.end=xV(e.end)}function le(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ue(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function de(){return{type:`blockquote`,children:[]}}function fe(){return{type:`code`,lang:null,meta:null,value:``}}function pe(){return{type:`inlineCode`,value:``}}function me(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function he(){return{type:`emphasis`,children:[]}}function ge(){return{type:`heading`,depth:0,children:[]}}function _e(){return{type:`break`}}function ve(){return{type:`html`,value:``}}function ye(){return{type:`image`,title:null,url:``,alt:null}}function be(){return{type:`link`,title:null,url:``,children:[]}}function xe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Se(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Ce(){return{type:`paragraph`,children:[]}}function we(){return{type:`strong`,children:[]}}function Te(){return{type:`text`,value:``}}function Ee(){return{type:`thematicBreak`}}}function xV(e){return{line:e.line,column:e.column,offset:e.offset}}function SV(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?SV(e,r):CV(e,r)}}function CV(e,t){let n;for(n in t)if(vV.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function wV(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+WL({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+WL({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+WL({start:t.start,end:t.end})+`) is still open`)}function TV(e){let t=this;t.parser=n;function n(n){return yV(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function EV(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function DV(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
123
|
-
`}]}function OV(e,t){let n=t.value?t.value+`
|
|
124
|
-
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function kV(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function AV(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function jV(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=QR(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function MV(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function NV(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function PV(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function FV(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return PV(e,t);let i={src:QR(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function IV(e,t){let n={src:QR(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function LV(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function RV(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return PV(e,t);let i={href:QR(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function zV(e,t){let n={href:QR(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function BV(e,t,n){let r=e.all(t),i=n?VV(n):HV(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
125
|
-
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
126
|
-
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function VV(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=HV(n[r])}return t}function HV(e){return e.spread??e.children.length>1}function UV(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function WV(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function GV(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function KV(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qV(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=VL(t.children[1]),o=BL(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function JV(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function YV(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var XV=9,ZV=32;function QV(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push($V(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push($V(t.slice(i),i>0,!1)),a.join(``)}function $V(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===XV||t===ZV;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===XV||t===ZV;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function eH(e,t){let n={type:`text`,value:QV(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function tH(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var nH={blockquote:EV,break:DV,code:OV,delete:kV,emphasis:AV,footnoteReference:jV,heading:MV,html:NV,imageReference:FV,image:IV,inlineCode:LV,linkReference:RV,link:zV,listItem:BV,list:UV,paragraph:WV,root:GV,strong:KV,table:qV,tableCell:YV,tableRow:JV,text:eH,thematicBreak:tH,toml:rH,yaml:rH,definition:rH,footnoteDefinition:rH};function rH(){}var iH=typeof self==`object`?self:globalThis,aH=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new iH[e](t)},oH=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof iH[e]==`function`?aH(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(aH(a,o),i)};return r},sH=e=>oH(new Map,e)(0),cH=``,{toString:lH}={},{keys:uH}=Object,dH=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=lH.call(e).slice(8,-1);switch(n){case`Array`:return[1,cH];case`Object`:return[2,cH];case`Date`:return[3,cH];case`RegExp`:return[4,cH];case`Map`:return[5,cH];case`Set`:return[6,cH];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},fH=([e,t])=>e===0&&(t===`function`||t===`symbol`),pH=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=dH(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of uH(r))(e||!fH(dH(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,isNaN(r.getTime())?cH:r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(fH(dH(n))||fH(dH(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!fH(dH(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},mH=(e,{json:t,lossy:n}={})=>{let r=[];return pH(!(t||n),!!t,new Map,r)(e),r},hH=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?sH(mH(e,t)):structuredClone(e):(e,t)=>sH(mH(e,t));function gH(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function _H(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function vH(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||gH,r=e.options.footnoteBackLabel||_H,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=QR(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...hH(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
127
|
-
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
128
|
-
`}]}}var yH=(function(e){if(e==null)return wH;if(typeof e==`function`)return CH(e);if(typeof e==`object`)return Array.isArray(e)?bH(e):xH(e);if(typeof e==`string`)return SH(e);throw Error(`Expected function, string, or object as test`)});function bH(e){let t=[],n=-1;for(;++n<e.length;)t[n]=yH(e[n]);return CH(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function xH(e){let t=e;return CH(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function SH(e){return CH(t);function t(t){return t&&t.type===e}}function CH(e){return t;function t(t,n,r){return!!(TH(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function wH(){return!0}function TH(e){return typeof e==`object`&&!!e&&`type`in e}function EH(e){return e}var DH=[];function OH(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=yH(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+EH(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=DH,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=kH(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function kH(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?DH:[e]}function AH(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),OH(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var jH={}.hasOwnProperty,MH={};function NH(e,t){let n=t||MH,r=new Map,i=new Map,a={all:s,applyData:FH,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...nH,...n.handlers},one:o,options:n,patch:PH,wrap:LH};return AH(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(jH.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=hH(n);return r.children=a.all(e),r}return hH(e)}return(a.options.unknownHandler||IH)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=RH(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=RH(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function PH(e,t){e.position&&(t.position=UL(e))}function FH(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,hH(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function IH(e,t){let n=t.data||{},r=`value`in t&&!(jH.call(n,`hProperties`)||jH.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function LH(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
129
|
-
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
130
|
-
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
131
|
-
`}),n}function RH(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function zH(e,t){let n=NH(e,t),r=n.one(e,void 0),i=vH(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
132
|
-
`},i)),a}function BH(e,t){return e&&`run`in e?async function(n,r){let i=zH(n,{file:r,...t});await e.run(i,r)}:function(n,r){return zH(n,{file:r,...e||t})}}function VH(e){if(e)throw e}var HH=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function UH(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function WH(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?GH(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function GH(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var KH={basename:qH,dirname:JH,extname:YH,join:XH,sep:`/`};function qH(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);$H(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function JH(e){if($H(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function YH(e){$H(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function XH(...e){let t=-1,n;for(;++t<e.length;)$H(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:ZH(n)}function ZH(e){$H(e);let t=e.codePointAt(0)===47,n=QH(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function QH(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function $H(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var eU={cwd:tU};function tU(){return`/`}function nU(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function rU(e){if(typeof e==`string`)e=new URL(e);else if(!nU(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return iU(e)}function iU(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var aU=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],oU=class{constructor(e){let t;t=e?nU(e)?{path:e}:typeof e==`string`||uU(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:eU.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<aU.length;){let e=aU[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)aU.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?KH.basename(this.path):void 0}set basename(e){cU(e,`basename`),sU(e,`basename`),this.path=KH.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?KH.dirname(this.path):void 0}set dirname(e){lU(this.basename,`dirname`),this.path=KH.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?KH.extname(this.path):void 0}set extname(e){if(sU(e,`extname`),lU(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=KH.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){nU(e)&&(e=rU(e)),cU(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?KH.basename(this.path,this.extname):void 0}set stem(e){cU(e,`stem`),sU(e,`stem`),this.path=KH.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new JL(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function sU(e,t){if(e&&e.includes(KH.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+KH.sep+"`")}function cU(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function lU(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function uU(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var dU=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),fU=l(HH(),1),pU={}.hasOwnProperty,mU=new class e extends dU{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=WH()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,fU.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(_U(`data`,this.frozen),this.namespace[e]=t,this):pU.call(this.namespace,e)&&this.namespace[e]||void 0:e?(_U(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=bU(e),n=this.parser||this.Parser;return hU(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),hU(`process`,this.parser||this.Parser),gU(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=bU(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);SU(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),hU(`processSync`,this.parser||this.Parser),gU(`processSync`,this.compiler||this.Compiler),this.process(e,r),yU(`processSync`,`process`,t),n;function r(e,r){t=!0,VH(e),n=r}}run(e,t,n){vU(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=bU(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),yU(`runSync`,`run`,n),r;function i(e,t){VH(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=bU(t),r=this.compiler||this.Compiler;return gU(`stringify`,r),vU(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(_U(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,fU.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];UH(o)&&UH(r)&&(r=(0,fU.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function hU(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function gU(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function _U(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function vU(e){if(!UH(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function yU(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function bU(e){return xU(e)?e:new oU(e)}function xU(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function SU(e){return typeof e==`string`||CU(e)}function CU(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var wU=[],TU={allowDangerousHtml:!0},EU=/^(https?|ircs?|mailto|xmpp)$/i,DU=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function OU(e){let t=kU(e),n=AU(e);return jU(t.runSync(t.parse(n),n),e)}function kU(e){let t=e.rehypePlugins||wU,n=e.remarkPlugins||wU,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...TU}:TU;return mU().use(TV).use(n).use(BH,r).use(t)}function AU(e){let t=e.children||``,n=new oU;return typeof t==`string`?n.value=t:``+t,n}function jU(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||MU;for(let e of DU)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return AH(e,l),tR(e,{Fragment:I.Fragment,components:i,ignoreInvalidStyle:!0,jsx:I.jsx,jsxs:I.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in CR)if(Object.hasOwn(CR,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=CR[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function MU(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||EU.test(e.slice(0,t))?e:``}function NU(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function PU(e,t,n){let r=yH((n||{}).ignore||[]),i=FU(t),a=-1;for(;++a<i.length;)OH(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function FU(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([IU(e[0]),LU(e[1])])}return t}function IU(e){return typeof e==`string`?new RegExp(NU(e),`g`):e}function LU(e){return typeof e==`function`?e:function(){return e}}function RU(e){PU(e,[/\r?\n|\r/g,zU])}function zU(){return{type:`break`}}function BU(){return function(e){RU(e)}}function VU(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}var HU=`phrasing`,UU=[`autolink`,`link`,`image`,`label`];function WU(){return{transforms:[QU],enter:{literalAutolink:KU,literalAutolinkEmail:qU,literalAutolinkHttp:qU,literalAutolinkWww:qU},exit:{literalAutolink:ZU,literalAutolinkEmail:XU,literalAutolinkHttp:JU,literalAutolinkWww:YU}}}function GU(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:HU,notInConstruct:UU},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:HU,notInConstruct:UU},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:HU,notInConstruct:UU}]}}function KU(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function qU(e){this.config.enter.autolinkProtocol.call(this,e)}function JU(e){this.config.exit.autolinkProtocol.call(this,e)}function YU(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function XU(e){this.config.exit.autolinkEmail.call(this,e)}function ZU(e){this.exit(e)}function QU(e){PU(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,$U],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,eW]],{ignore:[`link`,`linkReference`]})}function $U(e,t,n,r,i){let a=``;if(!rW(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!tW(n)))return!1;let o=nW(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function eW(e,t,n,r){return!rW(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function tW(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function nW(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=VU(e,`(`),a=VU(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function rW(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||XR(n)||YR(n))&&(!t||n!==47)}pW.peek=fW;function iW(){this.buffer()}function aW(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function oW(){this.buffer()}function sW(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function cW(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=RR(this.sliceSerialize(e)).toLowerCase(),n.label=t}function lW(e){this.exit(e)}function uW(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=RR(this.sliceSerialize(e)).toLowerCase(),n.label=t}function dW(e){this.exit(e)}function fW(){return`[`}function pW(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function mW(){return{enter:{gfmFootnoteCallString:iW,gfmFootnoteCall:aW,gfmFootnoteDefinitionLabelString:oW,gfmFootnoteDefinition:sW},exit:{gfmFootnoteCallString:cW,gfmFootnoteCall:lW,gfmFootnoteDefinitionLabelString:uW,gfmFootnoteDefinition:dW}}}function hW(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:pW},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
133
|
-
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?_W:gW))),s(),o}}function gW(e,t,n){return t===0?e:_W(e,t,n)}function _W(e,t,n){return(n?``:` `)+e}var vW=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];CW.peek=wW;function yW(){return{canContainEols:[`delete`],enter:{strikethrough:xW},exit:{strikethrough:SW}}}function bW(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:vW}],handlers:{delete:CW}}}function xW(e){this.enter({type:`delete`,children:[]},e)}function SW(e){this.exit(e)}function CW(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function wW(){return`~`}function TW(e){return e.length}function EW(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||TW,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=DW(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=OW(r[d]);else{let e=OW(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
134
|
-
`)}function DW(e){return e==null?``:String(e)}function OW(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function kW(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),AW);return i(),o}function AW(e,t,n){return`>`+(n?``:` `)+e}function jW(e,t){return MW(e,t.inConstruct,!0)&&!MW(e,t.notInConstruct,!1)}function MW(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function NW(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
135
|
-
`&&jW(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
136
|
-
`}function PW(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function FW(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function IW(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function LW(e,t,n,r){let i=IW(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(FW(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,RW);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(PW(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
|
|
137
|
-
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
138
|
-
`),a&&(u+=s.move(a+`
|
|
139
|
-
`)),u+=s.move(c),l(),u}function RW(e,t,n){return(n?``:` `)+e}function zW(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function BW(e,t,n,r){let i=zW(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\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?` `:`
|
|
140
|
-
`,...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()),o(),l}function VW(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function HW(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function UW(e,t,n){let r=oz(e),i=oz(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}WW.peek=GW;function WW(e,t,n,r){let i=VW(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=UW(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=HW(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=UW(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+HW(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function GW(e,t,n){return n.options.emphasis||`*`}function KW(e,t){let n=!1;return AH(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&TR(e)&&(t.options.setext||n))}function qW(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(KW(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
141
|
-
`,after:`
|
|
142
|
-
`});return r(),t(),o+`
|
|
143
|
-
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
144
|
-
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
145
|
-
`,...a.current()});return/^[\t ]/.test(l)&&(l=HW(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}JW.peek=YW;function JW(e){return e.value||``}function YW(){return`<`}XW.peek=ZW;function XW(e,t,n,r){let i=zW(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 ZW(){return`!`}QW.peek=$W;function QW(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=[],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 $W(){return`!`}eG.peek=tG;function eG(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)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 tG(){return"`"}function nG(e,t){let n=TR(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))}rG.peek=iG;function rG(e,t,n,r){let i=zW(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(nG(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let 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 iG(e,t,n){return nG(e,n)?`<`:`[`}aG.peek=oG;function aG(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=[],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 oG(){return`[`}function sG(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 cG(e){let t=sG(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 lG(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function uG(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 dG(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?lG(n):sG(n),s=e.ordered?o===`.`?`)`:`.`:cG(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),uG(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 fG(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 pG(e,t,n,r){let i=fG(n),a=n.bulletCurrent||sG(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 mG(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var hG=yH([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function gG(e,t,n,r){return(e.children.some(function(e){return hG(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function _G(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}vG.peek=yG;function vG(e,t,n,r){let i=_G(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=UW(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=HW(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=UW(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+HW(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function yG(e,t,n){return n.options.strong||`*`}function bG(e,t,n,r){return n.safe(e.value,r)}function xG(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 SG(e,t,n){let r=(uG(n)+(n.options.ruleSpaces?` `:``)).repeat(xG(n));return n.options.ruleSpaces?r.slice(0,-1):r}var CG={blockquote:kW,break:NW,code:LW,definition:BW,emphasis:WW,hardBreak:NW,heading:qW,html:JW,image:XW,imageReference:QW,inlineCode:eG,link:rG,linkReference:aG,list:dG,listItem:pG,paragraph:mG,root:gG,strong:vG,text:bG,thematicBreak:SG};function wG(){return{enter:{table:TG,tableData:kG,tableHeader:kG,tableRow:DG},exit:{codeText:AG,table:EG,tableData:OG,tableHeader:OG,tableRow:OG}}}function TG(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 EG(e){this.exit(e),this.data.inTable=void 0}function DG(e){this.enter({type:`tableRow`,children:[]},e)}function OG(e){this.exit(e)}function kG(e){this.enter({type:`tableCell`,children:[]},e)}function AG(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,jG));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function jG(e,t){return t===`|`?t:e}function MG(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
146
|
-
`,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(`
|
|
147
|
-
`))}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 EW(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=CG.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function NG(){return{exit:{taskListCheckValueChecked:FG,taskListCheckValueUnchecked:FG,paragraph:IG}}}function PG(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:LG}}}function FG(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function IG(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 LG(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=CG.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 RG(){return[WU(),mW(),yW(),wG(),NG()]}function zG(e){return{extensions:[GU(),hW(e),bW(),MG(e),PG()]}}var BG={tokenize:eK,partial:!0},VG={tokenize:tK,partial:!0},HG={tokenize:nK,partial:!0},UG={tokenize:rK,partial:!0},WG={tokenize:iK,partial:!0},GG={name:`wwwAutolink`,tokenize:QG,previous:aK},KG={name:`protocolAutolink`,tokenize:$G,previous:oK},qG={name:`emailAutolink`,tokenize:ZG,previous:sK},JG={};function YG(){return{text:JG}}for(var XG=48;XG<123;)JG[XG]=qG,XG++,XG===58?XG=65:XG===91&&(XG=97);JG[43]=qG,JG[45]=qG,JG[46]=qG,JG[95]=qG,JG[72]=[qG,KG],JG[104]=[qG,KG],JG[87]=[qG,GG],JG[119]=[qG,GG];function ZG(e,t,n){let r=this,i,a;return o;function o(t){return!cK(t)||!sK.call(r,r.previous)||lK(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return cK(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(WG,u,l)(t):t===45||t===95||BR(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&&zR(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function QG(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!aK.call(r,r.previous)||lK(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(BG,e.attempt(VG,e.attempt(HG,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function $G(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&oK.call(r,r.previous)&&!lK(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(zR(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||HR(t)||qR(t)||XR(t)||YR(t)?n(t):e.attempt(VG,e.attempt(HG,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function eK(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 tK(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(UG,c,s)(t):t===null||qR(t)||XR(t)||t!==45&&YR(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 nK(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(UG,t,a)(o):o===null||qR(o)||XR(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function rK(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||qR(o)||XR(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||qR(e)||XR(e)?t(e):r(e)}function a(e){return zR(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):zR(t)?(e.consume(t),o):n(t)}}function iK(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return BR(e)?n(e):t(e)}}function aK(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||qR(e)}function oK(e){return!zR(e)}function sK(e){return!(e===47||cK(e))}function cK(e){return e===43||e===45||e===46||e===95||BR(e)}function lK(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 uK={tokenize:vK,partial:!0};function dK(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:hK,continuation:{tokenize:gK},exit:_K}},text:{91:{name:`gfmFootnoteCall`,tokenize:mK},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:fK,resolveTo:pK}}}}function fK(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=RR(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 pK(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 mK(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||qR(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(RR(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return qR(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 hK(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||qR(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=RR(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return qR(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),$R(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function gK(e,t,n){return e.check(mz,t,e.attempt(uK,t,n))}function _K(e){e.exit(`gfmFootnoteDefinition`)}function vK(e,t,n){let r=this;return $R(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 yK(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&&jR(o,o.length,0,sz(s,e.slice(r+1,n),t)),jR(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),jR(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=oz(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=oz(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var bK=class{constructor(){this.map=[]}add(e,t,n){xK(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}};function xK(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function SK(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 CK(){return{flow:{null:{name:`table`,tokenize:wK,resolveAll:TK}}}}function wK(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 e=r.events[t][1].type;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?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):KR(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):JR(t)?$R(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||qR(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,JR(t)?$R(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 JR(t)?$R(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||KR(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 JR(t)?$R(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||KR(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||KR(n)?(e.exit(`tableRow`),t(n)):JR(n)?$R(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||qR(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 TK(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 bK;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(DK(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=EK(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=EK(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=EK(f,t,o,i,n,d)):(o[0]=o[1],d=EK(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&DK(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=SK(t.events,n))}return e}function EK(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},OK(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=OK(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=OK(t.events,n[2]),a=OK(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({},OK(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function DK(e,t,n,r,i){let a=[],o=OK(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 OK(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var kK={name:`tasklistCheck`,tokenize:jK};function AK(){return{text:{91:kK}}}function jK(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 qR(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 KR(r)?t(r):JR(r)?e.check({tokenize:MK},t,n)(r):n(r)}}function MK(e,t,n){return $R(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function NK(e){return PR([YG(),dK(),yK(e),CK(),AK()])}var PK={};function FK(e){let t=this,n=e||PK,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(NK(n)),a.push(RG()),o.push(zG(n))}var IK={root:`font-sans whitespace-normal text-pretty wrap-anywhere [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,h1:`mt-6 mb-2 text-[1.3em] leading-tight font-semibold tracking-tight text-text`,h2:`mt-6 mb-2 text-[1.12em] leading-snug font-semibold text-text`,h3:`mt-5 mb-1.5 text-[1em] font-semibold text-text`,h4:`mt-4 mb-1 text-[1em] font-medium text-text`,p:`mt-0 mb-2.5`,list:`mt-0 mb-2.5 list-disc pl-5`,orderedList:`mt-0 mb-2.5 list-decimal pl-5`,taskList:`mt-0 mb-2.5 list-none pl-0.5`,li:`mb-1 pl-0.5 marker:text-text-tertiary [&>ol]:mt-1 [&>ol]:mb-0 [&>p]:mb-1 [&>ul]:mt-1 [&>ul]:mb-0`,checkbox:`mr-2 align-[-1px] accent-accent`,strong:`font-semibold text-text`,em:`italic`,a:GE,code:`rounded-sm border border-border-subtle bg-surface-inset px-1 py-px font-mono text-[0.88em] text-text`,pre:`mt-0 mb-3 overflow-x-auto rounded-md bg-surface-inset px-3 py-2.5 font-mono text-xs leading-[18px] [&>code]:bg-transparent [&>code]:p-0 [&>code]:text-[1em] [&>code]:text-text-secondary [&>code]:border-0`,blockquote:`mx-0 mt-0 mb-2.5 border-l-2 border-border-strong pl-3 text-text-tertiary`,tableScroll:`mt-0 mb-3 overflow-x-auto`,table:`w-full border-collapse text-[0.93em]`,th:`border-b border-border px-2 py-1.5 text-left font-medium wrap-normal text-text-tertiary first:pl-0`,td:`border-b border-border-subtle px-2 py-1.5 text-left align-top wrap-normal first:pl-0`,hr:`my-5 border-0 border-t border-border-subtle`},LK={sm:`text-sm`,base:`text-base`},RK={primary:`text-text`,secondary:`text-text-secondary`,tertiary:`text-text-tertiary`},zK=`contains-task-list`,BK={h1:({node:e,...t})=>(0,I.jsx)(`h1`,{className:IK.h1,...t}),h2:({node:e,...t})=>(0,I.jsx)(`h2`,{className:IK.h2,...t}),h3:({node:e,...t})=>(0,I.jsx)(`h3`,{className:IK.h3,...t}),h4:({node:e,...t})=>(0,I.jsx)(`h4`,{className:IK.h4,...t}),p:({node:e,...t})=>(0,I.jsx)(`p`,{className:IK.p,...t}),ul:({node:e,className:t,...n})=>(0,I.jsx)(`ul`,{className:t?.includes(zK)?IK.taskList:IK.list,...n}),ol:({node:e,className:t,...n})=>(0,I.jsx)(`ol`,{className:t?.includes(zK)?IK.taskList:IK.orderedList,...n}),li:({node:e,...t})=>(0,I.jsx)(`li`,{className:IK.li,...t}),input:({node:e,...t})=>(0,I.jsx)(`input`,{className:IK.checkbox,...t}),strong:({node:e,...t})=>(0,I.jsx)(`strong`,{className:IK.strong,...t}),em:({node:e,...t})=>(0,I.jsx)(`em`,{className:IK.em,...t}),a:({node:e,...t})=>(0,I.jsx)(`a`,{className:IK.a,...t}),code:({node:e,className:t,...n})=>(0,I.jsx)(`code`,{className:IK.code,...n}),pre:({node:e,...t})=>(0,I.jsx)(`pre`,{className:IK.pre,...t}),blockquote:({node:e,...t})=>(0,I.jsx)(`blockquote`,{className:IK.blockquote,...t}),table:({node:e,...t})=>(0,I.jsx)(`div`,{className:IK.tableScroll,children:(0,I.jsx)(`table`,{className:IK.table,...t})}),th:({node:e,...t})=>(0,I.jsx)(`th`,{className:IK.th,...t}),td:({node:e,...t})=>(0,I.jsx)(`td`,{className:IK.td,...t}),hr:({node:e,...t})=>(0,I.jsx)(`hr`,{className:IK.hr,...t})};function VK({source:e,className:t,size:n=`sm`,tone:r=`secondary`,breaks:i=!1}){let a=`${IK.root} ${LK[n]} ${RK[r]}`;return(0,I.jsx)(`div`,{className:t?`${a} ${t}`:a,children:(0,I.jsx)(OU,{remarkPlugins:i?[FK,BU]:[FK],components:BK,children:e})})}function HK({full:e}){let{feature:t}=e,n=zx();return(0,I.jsxs)(I.Fragment,{children:[t.oneLiner&&(0,I.jsx)(`p`,{className:`mt-0 mb-10 text-base text-pretty text-text-secondary`,children:t.oneLiner}),(0,I.jsx)(IN,{title:`Notes`,children:t.brief?(0,I.jsx)(VK,{source:t.brief,size:`base`}):(0,I.jsx)(`p`,{className:`m-0 text-sm text-text-tertiary`,children:n?`No notes.`:`No notes. Start writes the brief from whatever is parked here.`})}),n&&(0,I.jsx)(`p`,{className:`mt-10 mb-0 text-sm text-text-tertiary`,children:`Ask the Orchestrator to start this.`})]})}function UK(e,t,{live:n=!0}={}){let r=tg(),i=R.docs.read.useQuery({featureId:e,relPath:t??``},{enabled:!!t,...n?{refetchInterval:r}:{}});return{content:t?i.data?.content:void 0,loading:!!t&&i.isLoading,failed:!!t&&!!i.error}}function WK({children:e,aside:t,className:n}){return(0,I.jsxs)(`div`,{className:q(`flex h-10 shrink-0 items-center gap-2 px-4`,n),children:[(0,I.jsx)(`div`,{className:`flex min-w-0 items-center gap-1`,children:e}),(0,I.jsx)(`span`,{className:`flex-1`}),t&&(0,I.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 text-xs text-text-tertiary`,children:t})]})}function GK({featureId:e,relPath:t,live:n=!0,empty:r,children:i}){let a=UK(e,t,{live:n}),o=t?.split(/[\\/]/).pop();return(0,I.jsxs)(`div`,{className:`mx-auto w-full max-w-[680px] px-6 pt-4 pb-12`,children:[i,a.failed?(0,I.jsxs)(YN,{children:[`Could not read `,t,`.`]}):a.content?(0,I.jsx)(VK,{source:dg(a.content),size:`base`}):(a.loading||a.content===void 0)&&t?(0,I.jsx)(qK,{label:`Loading ${o}…`}):r]})}var KK=[[`w-full`,`w-11/12`,`w-4/5`,`w-2/3`],[`w-full`,`w-5/6`,`w-1/2`]];function qK({label:e}){return(0,I.jsxs)(WN,{label:e,children:[(0,I.jsx)(`div`,{className:`flex h-6 items-center`,children:(0,I.jsx)(GN,{className:`h-3.5 w-1/3`})}),KK.map((e,t)=>(0,I.jsx)(`div`,{className:`mt-3`,"data-skeleton":`paragraph`,children:e.map((e,t)=>(0,I.jsx)(`div`,{className:`flex h-5 items-center`,children:(0,I.jsx)(GN,{className:q(`h-2.5`,e)})},t))},t))]})}function JK({featureId:e,doc:t,backLabel:n,onBack:r}){let[i,a]=(0,F.useState)(!1),o=zx(),s=t.title||t.relPath.split(/[\\/]/).pop()||t.relPath,c=(0,I.jsxs)(`p`,{className:`m-0 mb-6 flex min-w-0 items-center gap-2 text-xs text-text-tertiary`,children:[(0,I.jsx)(`span`,{className:`truncate font-mono`,title:t.relPath,children:t.relPath}),t.updatedAt!==void 0&&(0,I.jsxs)(`span`,{className:`shrink-0`,children:[`· `,gg(t.updatedAt)]})]});return(0,I.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[(0,I.jsxs)(WK,{className:`sticky top-0 z-10 bg-surface`,aside:!o&&(0,I.jsx)(Y,{label:`Open full window`,size:`sm`,icon:(0,I.jsx)(jb,{}),onClick:()=>a(!0)}),children:[(0,I.jsx)(J,{variant:`ghost`,size:`sm`,icon:(0,I.jsx)(wb,{}),onClick:r,className:`-ml-2 shrink-0`,children:n}),(0,I.jsx)(Wy,{size:12,className:`shrink-0 text-text-disabled`}),(0,I.jsx)(`h2`,{className:`m-0 min-w-0 truncate pl-1 text-sm font-medium text-text`,children:s})]}),(0,I.jsx)(GK,{featureId:e,relPath:t.relPath,children:c}),(0,I.jsxs)(aP,{open:i,onClose:()=>a(!1),labelledBy:`doc-full-title`,size:`full`,className:`flex h-[86vh] flex-col overflow-hidden`,children:[(0,I.jsxs)(`div`,{className:`flex h-(--topbar-h) shrink-0 items-center gap-2 border-b border-border-subtle pr-2 pl-5`,children:[(0,I.jsx)(Jy,{size:16,className:`shrink-0 text-icon`}),(0,I.jsx)(`h2`,{id:`doc-full-title`,className:`m-0 min-w-0 truncate text-sm font-medium text-text`,children:s}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-text-tertiary`,children:t.relPath}),(0,I.jsx)(Y,{label:`Close`,size:`sm`,icon:(0,I.jsx)(By,{}),onClick:()=>a(!1)})]}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,I.jsx)(GK,{featureId:e,relPath:t.relPath})})]})]})}var YK=`allow-scripts`,XK=`default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:; font-src data:; media-src data:; base-uri 'none'; form-action 'none'`,ZK=`runcastle:preview-escape`;function QK(e){if(typeof e!=`object`||!e)return null;let{type:t,path:n}=e;return t!==`runcastle:open-design`||typeof n!=`string`||!n.startsWith(`/`)?null:n}var $K=/^?\s*<!doctype[^>]*>/i;function eq(e,t){let n=`<meta http-equiv="Content-Security-Policy" content="${XK}"><script>document.documentElement.setAttribute('data-theme','${t}')<\/script><script>addEventListener('keydown',function(e){if(e.key==='Escape'&&!e.defaultPrevented)parent.postMessage('${ZK}','*')})<\/script>`,r=$K.exec(e);if(!r)return`<!doctype html>${n}${e}`;let i=r[0].length;return e.slice(0,i)+n+e.slice(i)}function tq({featureId:e,preview:t,live:n=!0,fullWindow:r=!1,onFullWindow:i=()=>{},onOpenDesign:a}){let o=UK(e,t.relPath,{live:n}),{resolved:s}=uF(),c=o.content===void 0?void 0:eq(o.content,s),l=t.updatedAt===void 0?null:`updated ${gg(t.updatedAt)}`;return(0,I.jsxs)(I.Fragment,{children:[o.failed?(0,I.jsx)(`div`,{className:`px-6 pt-4`,children:(0,I.jsxs)(YN,{children:[`Could not read `,t.relPath,`.`]})}):c===void 0?(0,I.jsxs)(WN,{label:`Loading the preview`,className:`min-h-0 flex-1 px-6 pt-6`,children:[(0,I.jsx)(GN,{className:`h-4 w-1/2`}),(0,I.jsx)(GN,{className:`mt-3 h-3 w-2/3`})]}):(0,I.jsx)(nq,{srcDoc:c,onOpenDesign:a,className:`min-h-0 w-full flex-1 border-t border-border-subtle`}),(0,I.jsxs)(aP,{open:r,onClose:()=>i(!1),labelledBy:`preview-full-title`,size:`full`,className:`flex h-[86vh] flex-col overflow-hidden`,children:[(0,I.jsxs)(`div`,{className:`flex h-(--topbar-h) shrink-0 items-center gap-2 border-b border-border-subtle pr-2 pl-5`,children:[(0,I.jsx)(`h2`,{id:`preview-full-title`,className:`m-0 text-sm font-medium text-text`,children:`Preview`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-text-tertiary`,children:l}),(0,I.jsx)(Y,{label:`Close`,size:`sm`,icon:(0,I.jsx)(By,{}),onClick:()=>i(!1)})]}),c!==void 0&&(0,I.jsx)(nq,{srcDoc:c,onEscape:()=>i(!1),onOpenDesign:a&&(e=>{i(!1),a(e)}),className:`min-h-0 w-full flex-1 border-0`})]})]})}function nq({srcDoc:e,onEscape:t,onOpenDesign:n,className:r}){let[i,a]=(0,F.useState)(0),o=(0,F.useRef)(null);(0,F.useEffect)(()=>{if(!t&&!n)return;let e=e=>{if(e.source!==o.current?.contentWindow)return;e.data===`runcastle:preview-escape`&&t?.();let r=QK(e.data);r!==null&&n?.(r)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[t,n]);let s=(0,F.useRef)({srcDoc:e,generation:i,count:0});return(0,I.jsx)(`iframe`,{ref:o,title:`Preview`,sandbox:YK,srcDoc:e,onLoad:()=>{let t=s.current;if(t.srcDoc!==e||t.generation!==i){s.current={srcDoc:e,generation:i,count:1};return}t.count+=1,t.count>1&&a(e=>e+1)},className:q(`block bg-surface-inset`,r)},i)}function rq({full:e,onOpenDesign:t}){let n=e.docs.find(e=>e.relPath.endsWith(`decisions.md`)),r=e.docs.find(e=>e.relPath.endsWith(`spec.md`)),i=e.preview?`preview`:r?`spec`:`decisions`,[a,o]=(0,F.useState)(i),[s,c]=(0,F.useState)(!1),l=zx(),u=Z_(UK(e.feature.id,n?.relPath).content??``),d=iq(e.feature.id,r?.relPath),f=[...e.preview?[{id:`preview`,label:`Preview`,icon:(0,I.jsx)(Eb,{})}]:[],{id:`decisions`,label:`Decisions`,icon:(0,I.jsx)(bb,{}),...u>0?{count:u}:{}},{id:`spec`,label:`Spec`,icon:(0,I.jsx)(Jy,{})}],p=a===`preview`&&!e.preview?i:a,m=p===`decisions`?n:p===`spec`?r:void 0,h=p===`preview`?e.preview?.updatedAt:m?.updatedAt;return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,I.jsx)(WK,{className:`sticky top-0 z-10 bg-surface`,aside:(0,I.jsxs)(I.Fragment,{children:[p===`spec`&&d&&(0,I.jsx)(BA,{tone:`live`,className:`mr-1 animate-fade-in`,children:`Updating`}),h!==void 0&&(0,I.jsxs)(`span`,{className:`mr-1`,children:[`updated `,gg(h)]}),p===`preview`&&!l&&(0,I.jsx)(Y,{label:`Open full window`,size:`sm`,icon:(0,I.jsx)(jb,{}),onClick:()=>c(!0)})]}),children:(0,I.jsx)(SN,{items:f,value:p,onChange:o,size:`sm`,label:`Plan`,className:`-ml-1`})}),p===`preview`&&e.preview?(0,I.jsx)(tq,{featureId:e.feature.id,preview:e.preview,fullWindow:s,onFullWindow:c,onOpenDesign:t}):(0,I.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,I.jsx)(GK,{featureId:e.feature.id,relPath:m?.relPath,empty:(0,I.jsx)(aq,{part:p===`spec`?`spec`:`decisions`})})})]})}function iq(e,t){let n=UK(e,t),r=(0,F.useRef)(void 0),[i,a]=(0,F.useState)(!1);return(0,F.useEffect)(()=>{if(n.content===void 0)return;let e=r.current!==void 0&&r.current!==n.content;if(r.current=n.content,!e)return;a(!0);let t=window.setTimeout(()=>a(!1),3e3);return()=>window.clearTimeout(t)},[n.content]),i}function aq({part:e}){return(0,I.jsx)(XN,{compact:!0,icon:(0,I.jsx)(Jy,{}),title:e===`decisions`?`No decisions yet`:`No spec yet`,hint:e===`decisions`?`They land here one by one as the agent settles them with you.`:`The agent writes the spec once the decisions settle. It appears here as it is written.`})}var oq=class extends F.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[runcastle] boundary caught`,e,t)}render(){return this.state.error?this.props.fallback?this.props.fallback(this.state.error):(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,I.jsxs)(`span`,{className:`font-mono text-xs text-text-tertiary`,children:[this.props.label??`component`,` failed: `,this.state.error.message]})}):this.props.children}};function sq(e){let t=e;return t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable===!0}function cq(e,t){let n=e?.expanded??!1,r=e?.set;(0,F.useEffect)(()=>{if(!t||!r)return;let e=e=>{sq(e.target)||e.metaKey||e.ctrlKey||e.altKey||(e.key===`f`||e.key===`F`?(e.preventDefault(),r(!n)):e.key===`Escape`&&n&&(e.preventDefault(),r(!1)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n,r])}var lq=`#F85149`;function uq(e,t,n=1){e.lineWidth=6*n,e.lineCap=`round`,e.lineJoin=`round`,e.strokeStyle=lq;for(let r of t){let[t,...i]=r.points;if(!t)continue;let a=r.points.at(-1)??t;if(e.beginPath(),r.tool===`rect`){let n={x:Math.min(t.x,a.x),y:Math.min(t.y,a.y),width:Math.abs(a.x-t.x),height:Math.abs(a.y-t.y)};e.rect(n.x,n.y,n.width,n.height)}else{e.moveTo(t.x,t.y),i.length===0&&e.lineTo(t.x,t.y);for(let t of i)e.lineTo(t.x,t.y);if(r.tool===`arrow`&&i.length>0){let r=Math.atan2(a.y-t.y,a.x-t.x),i=12*n;e.lineTo(a.x-i*Math.cos(r-Math.PI/6),a.y-i*Math.sin(r-Math.PI/6)),e.moveTo(a.x,a.y),e.lineTo(a.x-i*Math.cos(r+Math.PI/6),a.y-i*Math.sin(r+Math.PI/6))}}e.stroke()}}function dq(e,t,n=1){let r=e.filter(e=>e.reviewTicketId===t&&e.videoTimestamp!=null).sort((e,t)=>e.videoTimestamp-t.videoTimestamp),i=[];for(let e of r){let t=e.videoTimestamp,r=i.at(-1);r&&t-r.at<=n?r.noteIds.push(e.id):i.push({at:t,noteIds:[e.id]})}return i}function fq(e){if(Number.isFinite(e.duration)&&e.duration>0)return e.duration;let{seekable:t}=e;return t.length>0?t.end(t.length-1):0}function pq(e,t){return t.annotating||!Number.isFinite(e)||t.playable<=0?null:Math.min(Math.max(e,0),t.playable)}function mq(e,t,n){return e.width<=0||e.height<=0?{x:0,y:0}:{x:(n.x-e.left)/e.width*t.width,y:(n.y-e.top)/e.height*t.height}}async function hq(e,t,n,r=1){e.width=t.videoWidth,e.height=t.videoHeight;let i=e.getContext(`2d`);if(!i)throw Error(`this browser offered no 2d canvas to capture the frame with`);return i.drawImage(t,0,0,e.width,e.height),uq(i,n,r),await new Promise((t,n)=>{e.toBlob(e=>{e?t(e):n(Error(`the browser produced no PNG from the annotated frame`))},`image/png`)})}async function gq(e){let t=await e.createNote();try{return await e.uploadScreenshot(t.id),{note:t}}catch(e){return{note:t,uploadError:e instanceof Error?e.message:String(e)}}}var _q=(e=`pen`)=>({tool:e,shapes:[],redo:[],text:``});function vq(e,t){return{...e,shapes:[...e.shapes,{tool:e.tool,points:[t]}],redo:[]}}function yq(e,t){if(e.shapes.length===0)return e;let n=e.shapes.slice(),r=n[n.length-1];return n[n.length-1]={...r,points:[...r.points,t]},{...e,shapes:n}}function bq(e){return e}function xq(e){let t=e.shapes.at(-1);return t?{...e,shapes:e.shapes.slice(0,-1),redo:[...e.redo,t]}:e}function Sq(e){let t=e.redo.at(-1);return t?{...e,shapes:[...e.shapes,t],redo:e.redo.slice(0,-1)}:e}var Cq=e=>({...e,shapes:[],redo:[]}),wq=(e,t)=>({...e,tool:t}),Tq=(e,t)=>({...e,text:t}),Eq=e=>e.shapes.length>0||e.text.trim().length>0,Dq=Eq;function Oq(e,t){switch(t.kind){case`begin`:return vq(e,t.point);case`extend`:return yq(e,t.point);case`commit`:return bq(e);case`undo`:return xq(e);case`redo`:return Sq(e);case`clear`:return Cq(e);case`tool`:return wq(e,t.tool);case`text`:return Tq(e,t.text)}}var kq=[{tool:`pen`,label:`Pen`,key:`P`,icon:(0,I.jsx)(Lb,{})},{tool:`arrow`,label:`Arrow`,key:`A`,icon:(0,I.jsx)(Rb,{})},{tool:`rect`,label:`Rect`,key:`R`,icon:(0,I.jsx)(zb,{})}],Aq=`pointer-events-auto flex items-center gap-0.5 rounded-lg bg-surface-raised p-1 shadow-popover`,jq={p:`pen`,a:`arrow`,r:`rect`};function Mq({video:e,timestamp:t,onSave:n,onCancel:r}){let[i,a]=(0,F.useReducer)(Oq,void 0,()=>_q()),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(null),f=(0,F.useRef)(null),p=(0,F.useRef)(!1),m=e=>{let t=e.getBoundingClientRect();return t.width>0?e.width/t.width:1};(0,F.useEffect)(()=>{let t=f.current;if(!t)return;t.width!==e.videoWidth&&(t.width=e.videoWidth),t.height!==e.videoHeight&&(t.height=e.videoHeight);let n=t.getContext(`2d`);n&&(n.clearRect(0,0,t.width,t.height),uq(n,i.shapes,m(t)))},[i.shapes,e]);let h=e=>{let t=f.current;return t?mq(t.getBoundingClientRect(),{width:t.width,height:t.height},{x:e.clientX,y:e.clientY}):null},g=e=>{let t=h(e);t&&(f.current?.setPointerCapture?.(e.pointerId),p.current=!0,a({kind:`begin`,point:t}))},_=e=>{if(!p.current)return;let t=h(e);t&&a({kind:`extend`,point:t})},v=e=>{if(!p.current)return;p.current=!1;let t=f.current;t?.hasPointerCapture?.(e.pointerId)&&t.releasePointerCapture(e.pointerId),a({kind:`commit`})},y=()=>{Dq(i)?l(!0):r()},b=async()=>{let t=f.current;if(!(!Eq(i)||o||!t)){s(!0),d(null);try{await n(await hq(document.createElement(`canvas`),e,i.shapes,m(t)),i.text.trim())}catch(e){d(e instanceof Error?e.message:`the annotated frame could not be saved`)}finally{s(!1)}}};return(0,F.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),c?l(!1):y();return}let t=e.target;if(t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable===!0||e.metaKey||e.ctrlKey||e.altKey)return;let n=jq[e.key.toLowerCase()];n&&(e.preventDefault(),a({kind:`tool`,tool:n}))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c,i,r]),(0,I.jsxs)(`div`,{className:`absolute inset-0 z-20`,"data-testid":`annotation-overlay`,children:[(0,I.jsx)(`canvas`,{ref:f,"aria-label":`draw on this frame`,className:`absolute inset-0 h-full w-full cursor-crosshair touch-none`,onPointerDown:g,onPointerMove:_,onPointerUp:v,onPointerCancel:v}),(0,I.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 top-0 flex flex-wrap items-center gap-2 p-3 animate-fade-in`,children:[(0,I.jsxs)(`div`,{className:Aq,children:[kq.map(({tool:e,label:t,key:n,icon:r})=>(0,I.jsx)(Y,{label:t,kbd:n,icon:r,active:i.tool===e,tooltipSide:`bottom`,onClick:()=>a({kind:`tool`,tool:e})},e)),(0,I.jsx)(`span`,{"aria-hidden":!0,className:`mx-1 h-4 w-px bg-border`}),(0,I.jsx)(Y,{label:`Undo`,icon:(0,I.jsx)(Hy,{}),tooltipSide:`bottom`,disabled:i.shapes.length===0,onClick:()=>a({kind:`undo`})}),(0,I.jsx)(Y,{label:`Redo`,icon:(0,I.jsx)(Bb,{}),tooltipSide:`bottom`,disabled:i.redo.length===0,onClick:()=>a({kind:`redo`})}),(0,I.jsx)(Y,{label:`Clear`,icon:(0,I.jsx)(Vy,{}),tooltipSide:`bottom`,disabled:i.shapes.length===0,onClick:()=>a({kind:`clear`})})]}),(0,I.jsx)(`span`,{className:`pointer-events-none rounded-md bg-surface-raised px-2 py-1 font-mono text-xs text-text-secondary tabular-nums shadow-popover`,children:yf(t)})]}),(0,I.jsxs)(`div`,{className:`absolute inset-x-3 bottom-3 flex flex-col gap-2 rounded-lg bg-surface-raised p-2 shadow-popover animate-rise-in`,children:[u&&(0,I.jsx)(`p`,{className:`m-0 px-1 text-sm text-danger-text`,role:`alert`,children:u}),(0,I.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,I.jsx)(ON,{rows:2,"aria-label":`what’s wrong in this frame?`,className:`min-w-0 flex-1 resize-none`,placeholder:`What’s wrong in this frame? A drawing alone saves too.`,value:i.text,autoFocus:!0,onChange:e=>a({kind:`text`,text:e.target.value}),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||(e.preventDefault(),b())}}),(0,I.jsx)(J,{variant:`ghost`,onClick:y,children:`Cancel`}),(0,I.jsx)(J,{variant:`primary`,loading:o,disabled:!Eq(i),onClick:()=>void b(),children:o?`Saving…`:`Save note`})]})]}),(0,I.jsxs)(aP,{open:c,onClose:()=>l(!1),size:`sm`,label:`Discard this annotation?`,children:[(0,I.jsx)(oP,{title:`Discard this annotation?`,description:`The drawing and the words go with it.`}),(0,I.jsxs)(cP,{children:[(0,I.jsx)(J,{variant:`ghost`,onClick:()=>l(!1),children:`Keep editing`}),(0,I.jsx)(J,{variant:`danger`,onClick:r,children:`Discard`})]})]})]})}var Nq=[.5,.75,1,1.25,1.5,1.75,2],Pq=1.5,Fq=5,Iq=1/30;function Lq(e,t){let n=Nq.indexOf(e);return Nq[((n===-1?Nq.indexOf(Pq):n)+t+Nq.length)%Nq.length]}function Rq({url:e,featureId:t,ticketId:n,passKind:r,readonly:i,frameClassName:a,expand:o,markers:s=[],onMarkerClick:c,onAnnotationSaved:l,onDuration:u,handleRef:d}){let f=R.useUtils(),p=rx(),m=(0,F.useRef)(null),[h,g]=(0,F.useState)(!1),[_,v]=(0,F.useState)(0),[y,b]=(0,F.useState)(0),[x,S]=(0,F.useState)(Pq),[C,w]=(0,F.useState)(`loading`),[T,E]=(0,F.useState)(null),[D,O]=(0,F.useState)(!1),[k,ee]=(0,F.useState)(null),A=R.notes.add.useMutation({onError:e=>p.push(e.message)});(0,F.useEffect)(()=>{let t=!0;return fetch(e,{method:`HEAD`}).then(e=>{let n=Number(e.headers.get(`content-length`));t&&Number.isFinite(n)&&n>0&&E(n)}).catch(()=>void 0),()=>{t=!1}},[e]);let j=(0,F.useCallback)(e=>{let t=m.current;if(!t)return;let n=pq(e,{playable:fq(t),annotating:D});n!==null&&(t.currentTime=n,v(n))},[D]),M=(0,F.useCallback)(e=>{m.current?.pause(),j(e)},[j]);(0,F.useEffect)(()=>{if(d)return d.current={seek:M,pause:()=>m.current?.pause(),getTicketId:()=>n},()=>{d.current=null}},[d,M,n]);let N=(0,F.useCallback)(()=>{let e=m.current;!e||D||C!==`ready`||(e.paused?e.play().catch(()=>p.push(`the browser refused to play this recording`)):e.pause())},[D,C,p]),te=(0,F.useCallback)(e=>{let t=m.current;t&&j(t.currentTime+e)},[j]),ne=(0,F.useCallback)(e=>{let t=m.current;t?.paused&&j(t.currentTime+e)},[j]),re=(0,F.useCallback)(e=>{S(e);let t=m.current;t&&(t.playbackRate=e)},[]),ie=()=>{C===`ready`&&(m.current?.pause(),O(!0))};cq(o,!D),(0,F.useEffect)(()=>{if(D)return;let e=e=>{if(sq(e.target)||e.metaKey||e.ctrlKey||e.altKey)return;let t=()=>e.preventDefault();switch(e.key){case` `:case`k`:case`K`:return t(),N();case`j`:case`J`:case`ArrowLeft`:return t(),te(-5);case`l`:case`L`:case`ArrowRight`:return t(),te(Fq);case`,`:return t(),ne(-.03333333333333333);case`.`:return t(),ne(Iq);case`<`:return t(),re(Lq(x,-1));case`>`:return t(),re(Lq(x,1))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[D,N,te,ne,re,x]);let ae=()=>{w(`loading`),m.current?.load()},P=async(e,r)=>{let i=m.current;if(!i)return;let a=i.currentTime,o=await gq({createNote:()=>A.mutateAsync({featureId:t,text:r||`Annotated ${yf(a)}`,videoTimestamp:a,reviewTicketId:n}),uploadScreenshot:t=>Kh(t,e)});f.notes.list.invalidate({featureId:t}),o.uploadError&&p.push(`the note was saved, but its annotated frame was not: ${o.uploadError}`),O(!1),l?.(o.note.id)},oe=e=>{let t=fq(e);b(t),u?.(t)},se=y>0&&!D&&C===`ready`,ce=T===null?`Loading the recording`:`Loading the recording — ${mg(T)}`;return(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 animate-fade-in`,children:[(0,I.jsxs)(`div`,{className:a,children:[(0,I.jsx)(`video`,{ref:m,className:`min-h-0 w-full flex-1 cursor-pointer object-contain`,src:e,preload:`metadata`,"aria-label":r===`verification`?`verification walkthrough`:`review walkthrough`,onClick:N,onLoadedMetadata:e=>{let t=e.currentTarget;oe(t),t.playbackRate=x,t.currentTime===0&&(t.currentTime=.01)},onDurationChange:e=>oe(e.currentTarget),onProgress:e=>oe(e.currentTarget),onCanPlay:()=>w(e=>e===`error`?e:`ready`),onError:()=>w(`error`),onTimeUpdate:e=>v(e.currentTarget.currentTime),onPlay:()=>g(!0),onPause:()=>g(!1),onEnded:()=>g(!1)}),C===`loading`&&(0,I.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 bg-surface-inset/70 animate-fade-in`,children:[(0,I.jsx)(UE,{}),(0,I.jsx)(`span`,{className:`text-sm text-text-secondary`,children:ce})]}),C===`error`&&(0,I.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-1.5 bg-surface-inset px-6 text-center animate-fade-in`,role:`alert`,children:[(0,I.jsx)(`span`,{className:`text-base font-medium text-text`,children:`This recording can’t be played`}),(0,I.jsx)(`span`,{className:`text-sm text-text-tertiary`,children:`The file may be corrupt.`}),(0,I.jsx)(`code`,{className:`max-w-full truncate font-mono text-xs text-text-tertiary`,children:e}),(0,I.jsx)(J,{className:`mt-2`,icon:(0,I.jsx)(Db,{}),onClick:ae,children:`Retry`})]}),D&&m.current&&(0,I.jsx)(Mq,{video:m.current,timestamp:_,onSave:P,onCancel:()=>O(!1)})]}),(0,I.jsxs)(`div`,{className:`flex h-(--control-lg) items-center gap-3`,children:[(0,I.jsx)(Y,{label:h?`pause`:`play`,kbd:`K`,icon:h?(0,I.jsx)(Ab,{}):(0,I.jsx)(ib,{}),disabled:D||C!==`ready`,onClick:N}),(0,I.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-text-secondary tabular-nums`,children:yf(_)}),(0,I.jsxs)(`div`,{className:`relative flex h-full flex-1 items-center`,onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();t.width<=0||y<=0||ee((e.clientX-t.left)/t.width*y)},onMouseLeave:()=>ee(null),children:[(0,I.jsx)(`input`,{type:`range`,className:`h-1 w-full cursor-pointer accent-accent disabled:cursor-default disabled:opacity-50`,min:0,step:1,max:y||1,value:Math.min(_,y||1),disabled:!se,"aria-label":`scrub the walkthrough`,onChange:e=>j(Number(e.target.value))}),k!==null&&(0,I.jsx)(`span`,{className:`pointer-events-none absolute -top-5 -translate-x-1/2 rounded-sm bg-surface-raised px-1.5 font-mono text-xs text-text-secondary tabular-nums shadow-popover`,style:{left:`${Math.min(100,Math.max(0,k/(y||1)*100))}%`},children:yf(k)}),y>0&&s.map(e=>(0,I.jsx)(`button`,{type:`button`,className:e.noteIds.length>1?`absolute top-1/2 flex size-4 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full bg-accent-fill text-xs leading-none text-on-primary transition-transform duration-(--dur-1) ease-app hover:scale-110`:`absolute top-1/2 size-2.5 -translate-x-1/2 -translate-y-1/2 cursor-pointer rounded-full bg-accent ring-2 ring-surface transition-transform duration-(--dur-1) ease-app hover:scale-125`,style:{left:`${Math.min(100,e.at/y*100)}%`},"aria-label":`${e.noteIds.length} note${e.noteIds.length>1?`s`:``} at ${yf(e.at)}`,title:`${e.noteIds.length} note${e.noteIds.length>1?`s`:``} at ${yf(e.at)}`,onClick:()=>{M(e.at),c?.(e.noteIds)},children:e.noteIds.length>1?e.noteIds.length:``},e.at))]}),(0,I.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-text-tertiary tabular-nums`,children:yf(y)}),(0,I.jsxs)(J,{size:`sm`,variant:`ghost`,className:`font-mono tabular-nums`,"aria-label":`playback speed ${x}×`,title:`Playback speed (< and >)`,onClick:()=>re(Lq(x,1)),children:[x,`×`]}),!i&&!D&&(0,I.jsx)(J,{size:`sm`,icon:(0,I.jsx)(Yy,{}),onClick:ie,children:`Annotate`})]})]})}function zq(e){return`relative flex w-full flex-col overflow-hidden rounded-md bg-surface-inset ${e?`min-h-0 flex-1`:`aspect-video max-h-[calc(100vh-320px)]`}`}function Bq(e,t,n){let r=[e.passKind===`verification`?`Verification walkthrough`:`Walkthrough`];return t!==null&&t>0&&r.push(yf(t)),e.passKind===`verification`&&n!==null&&n>0&&r.push(`confirms ${n} fix${n===1?``:`es`}`),r.push(e.landedSince===0?`this build`:`reviewed ${e.reviewedCommit?e.reviewedCommit.slice(0,7):`an earlier build`}`),r.join(` · `)}function Vq({featureId:e,recordings:t,picked:n=null,notes:r,readonly:i,expand:a,handleRef:o,onStageRecording:s,onMarkerClick:c,onAnnotationSaved:l}){let[u,d]=(0,F.useState)(null),f=ty(t),p=t.find(e=>e.ticketId===n)??f;(0,F.useEffect)(()=>d(null),[p?.ticketId]);let m=p?t.indexOf(p):-1,h=m>0?t[m-1]:void 0,g=p&&h?h.landedSince-p.landedSince:null,_=p?.videoUrl?p.ticketId:null;(0,F.useEffect)(()=>{s?.(_?{ticketId:_}:null)},[s,_]),cq(a,!_);let v=a?.expanded??!1;return(0,I.jsxs)(`section`,{id:`evidence-stage`,className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,I.jsxs)(`header`,{className:`flex min-h-7 flex-wrap items-center gap-x-4 gap-y-2`,children:[p&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-sm text-text-secondary`,title:p.passKind===`verification`?`the fix count is derived from what landed between the two passes`:void 0,children:Bq(p,u,g)}),a&&(0,I.jsx)(Y,{className:`ml-auto`,label:v?`Collapse`:`Expand`,kbd:`F`,icon:v?(0,I.jsx)(Mb,{}):(0,I.jsx)(jb,{}),active:v,onClick:()=>a.set(!v)})]}),p?.videoUrl&&(0,I.jsx)(Rq,{url:p.videoUrl,featureId:e,ticketId:p.ticketId,passKind:p.passKind,readonly:i,frameClassName:zq(v),expand:a,markers:dq(r,p.ticketId),onMarkerClick:c,onAnnotationSaved:l,onDuration:d,handleRef:o},p.ticketId)]})}var Hq=`rounded-lg bg-surface-raised shadow-popover`,Uq=`rounded-lg bg-fill-well shadow-[inset_0_1px_0_color-mix(in_oklab,var(--color-text)_5%,transparent),inset_0_0_0_1px_var(--color-border-subtle)]`,Wq=`rounded-md bg-surface-inset ring-1 ring-inset ring-border-subtle`,Gq=(e,t)=>e?`${e} ${t}${e===1?``:`s`}`:null;function Kq(e){return e.groups.flatMap(e=>e.shots)}function qq(e){return[Gq(e.filter(e=>e.kind===`defect`).length,`defect`),Gq(e.filter(e=>e.kind===`observation`).length,`observation`)].filter(Boolean).join(`, `)}function Jq(e){return[Gq(Kq(e).length,`screenshot`),e.hasWalkthrough?`walkthrough`:null,Gq(e.groups.flatMap(e=>e.calls).length,`call`),Gq(e.findings.filter(e=>e.kind===`defect`).length,`defect`)].filter(Boolean).join(` · `)}function Yq(e){return e.commitsSince===null?null:e.commitsSince===0?`This build`:`${Gq(e.commitsSince,`commit`)} behind`}function Xq(e){let t=[];e.hasWalkthrough&&t.push({id:`video`,kind:`video`,group:null,title:`Walkthrough`}),e.findings.length>0&&t.push({id:`findings`,kind:`findings`,group:null,title:`Findings`,findings:e.findings});for(let n of e.groups){for(let e of n.shots)t.push({id:e.id,kind:`shot`,group:n.name,title:e.caption,shot:e});for(let e of n.calls)t.push({id:e.id,kind:`call`,group:n.name,title:`${e.method} ${e.url}`,call:e})}return t}function Zq(e){return e.find(e=>e.kind===`shot`)??e[0]}function Qq({src:e,alt:t,className:n}){return(0,I.jsx)(`img`,{src:e,alt:t,className:q(`block aspect-[16/10] w-full bg-surface-inset object-cover object-top`,n)})}function $q({poster:e,className:t}){return(0,I.jsxs)(`span`,{className:q(`relative block`,t),children:[e?(0,I.jsx)(Qq,{src:e,alt:``}):(0,I.jsx)(`span`,{className:`block aspect-[16/10] w-full bg-surface-inset`}),(0,I.jsx)(`span`,{className:`absolute inset-0 grid place-items-center bg-[color-mix(in_oklab,black_35%,transparent)]`,children:(0,I.jsx)(ib,{size:18,className:`text-white`})})]})}var eJ=6;function tJ({pack:e,onOpen:t}){let n=Kq(e),r=e.hasWalkthrough?eJ-1:eJ,i=Math.max(0,n.length-r),a=Yq(e);return(0,I.jsxs)(`button`,{type:`button`,"aria-label":`Open the review package`,onClick:t,className:q(Uq,`flex w-full max-w-[520px] min-w-0 cursor-pointer flex-col gap-2.5 p-3 text-left transition-colors duration-(--dur-1) hover:bg-surface-hover`),children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(Eb,{size:16,className:`shrink-0 text-accent`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-md font-medium text-text`,children:`Review package`}),a&&(0,I.jsx)(`span`,{className:`shrink-0 text-xs text-text-tertiary`,children:a})]}),(0,I.jsx)(`span`,{className:`text-sm text-text-secondary`,children:e.verdict}),(n.length>0||e.hasWalkthrough)&&(0,I.jsxs)(`span`,{className:`grid grid-cols-3 gap-1 overflow-hidden rounded-md`,children:[e.hasWalkthrough&&(0,I.jsx)($q,{poster:n[0]?.src}),n.slice(0,r).map((e,t)=>(0,I.jsxs)(`span`,{className:`relative block`,children:[(0,I.jsx)(Qq,{src:e.src,alt:e.caption}),i>0&&t===r-1&&(0,I.jsxs)(`span`,{className:`absolute inset-0 grid place-items-center bg-[color-mix(in_oklab,black_55%,transparent)] text-sm font-medium text-white`,children:[`+`,i]})]},e.id))]}),(0,I.jsx)(`span`,{className:`text-xs text-text-tertiary`,children:[Jq(e),e.empty].filter(Boolean).join(` · `)})]})}function nJ(e){let t=e.own.filter(e=>e.hasCall);return{...e,own:t,others:e.others.filter(e=>e.hasCall),defaultScenario:t[0]??null}}function rJ(e){return[...e.own,...e.others].some(e=>e.hasCall)}var iJ=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`HEAD`,`OPTIONS`];function aJ(e){return iJ.includes(e)?[...iJ]:[...iJ,e]}function oJ(e){return{method:e.method,url:e.url,headers:e.headers.map(([e,t])=>({name:e,value:t})),body:e.body??``}}function sJ(e){return{method:e.method,url:e.url.trim(),headers:e.headers.filter(e=>e.name.trim()!==``).map(e=>[e.name.trim(),e.value]),...e.body===``?{}:{body:e.body}}}function cJ(e){return e>=200&&e<300?`success`:e>=400&&e<500?`warning`:e>=500?`danger`:`neutral`}function lJ(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}var uJ=Object.defineProperty,dJ=(e,t)=>uJ(e,`name`,{value:t,configurable:!0});function fJ(e,[t,n]){return Math.min(n,Math.max(t,e))}dJ(fJ,`clamp`);var pJ=Object.defineProperty,mJ=(e,t)=>pJ(e,`name`,{value:t,configurable:!0});function hJ(e){let t=F.useRef({value:e,previous:e});return F.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}mJ(hJ,`usePrevious`);var gJ=Object.defineProperty,_J=(e,t)=>gJ(e,`name`,{value:t,configurable:!0}),vJ=[` `,`Enter`,`ArrowUp`,`ArrowDown`],yJ=[` `,`Enter`],bJ=`Select`,[xJ,SJ,CJ]=ej(bJ),[wJ,Rte]=fS(bJ,[CJ,bT]),TJ=bT(),[EJ,DJ]=wJ(bJ),[OJ,kJ]=wJ(bJ);function AJ(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=TJ(t),[_,v]=F.useState(null),[y,b]=F.useState(null),[x,S]=F.useState(!1),C=mj(l),[w,T]=eE({prop:r,defaultProp:i??!1,onChange:a,caller:bJ}),[E,D]=eE({prop:o,defaultProp:s,onChange:c,caller:bJ}),O=F.useRef(null),k=F.useRef(E);F.useEffect(()=>{let e=m?_?.ownerDocument.getElementById(m):_?.form;if(e instanceof HTMLFormElement){let t=_J(()=>D(k.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[m,_,D]);let ee=!_||!!m||!!_.closest(`form`),[A,j]=F.useState(new Set),M=tC(),N=Array.from(A).map(e=>e.props.value).join(`;`),te=F.useCallback(e=>{j(t=>new Set(t).add(e))},[]),ne=F.useCallback(e=>{j(t=>{let n=new Set(t);return n.delete(e),n})},[]),re={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:M,value:E,onValueChange:D,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:O,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:A,nativeSelectKey:N,isFormControl:ee};return(0,I.jsx)(MT,{...g,children:(0,I.jsx)(EJ,{scope:t,...re,children:(0,I.jsx)(xJ.Provider,{scope:t,children:(0,I.jsx)(OJ,{scope:t,onNativeOptionAdd:te,onNativeOptionRemove:ne,children:hY(h)?h(re):n})})})})}_J(AJ,`SelectProvider`);var jJ=_J(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,I.jsx)(AJ,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,I.jsxs)(I.Fragment,{children:[n,e?(0,I.jsx)(mY,{__scopeSelect:t}):null]})})},`Select`),MJ=`SelectTrigger`,NJ=F.forwardRef(_J(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=TJ(n),o=DJ(MJ,n),s=o.disabled||r,c=cS(t,o.onTriggerChange),l=SJ(n),u=F.useRef(`touch`),[d,f,p]=_Y(e=>{let t=l().filter(e=>!e.disabled),n=vY(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=_J(e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,I.jsx)(NT,{asChild:!0,...a,children:(0,I.jsx)(jS.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":gY(o.value)?``:void 0,...i,ref:c,onClick:$x(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:$x(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:$x(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&vJ.includes(e.key)&&(m(),e.preventDefault())})})})},`SelectTrigger`)),PJ=`SelectValue`,FJ=F.forwardRef(_J(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=DJ(PJ,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=cS(t,c.onValueNodeChange);XS(()=>{l(u)},[l,u]);let f=gY(c.value);return(0,I.jsx)(jS.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,I.jsx)(F.Fragment,{children:f?o:a},f?`placeholder`:`value`)})},`SelectValue`)),IJ=F.forwardRef(_J(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(jS.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[LJ,RJ]=wJ(`SelectPortal`,{forceMount:void 0}),zJ=_J(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,I.jsx)(LJ,{scope:e.__scopeSelect,forceMount:n,children:(0,I.jsx)(IT,{asChild:!0,...r})})},`SelectPortal`),BJ=`SelectContent`,VJ=F.forwardRef(_J(function(e,t){let n=RJ(BJ,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=DJ(BJ,e.__scopeSelect),[o,s]=F.useState();return XS(()=>{s(new DocumentFragment)},[]),(0,I.jsx)(BT,{present:r||a.open,children:({present:e})=>e?(0,I.jsx)(qJ,{...i,ref:t}):(0,I.jsx)(HJ,{...i,fragment:o})})},`SelectContent`)),HJ=F.forwardRef(_J(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?Bx.createPortal((0,I.jsx)(WJ,{scope:n,children:(0,I.jsx)(xJ.Slot,{scope:n,children:(0,I.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),UJ=10,[WJ,GJ]=wJ(BJ),KJ=gS(`SelectContent.RemoveScroll`),qJ=F.forwardRef(_J(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=DJ(BJ,n),[y,b]=F.useState(null),[x,S]=F.useState(null),C=cS(t,b),[w,T]=F.useState(null),[E,D]=F.useState(null),O=SJ(n),[k,ee]=F.useState(!1),A=F.useRef(!1);F.useEffect(()=>{if(y)return JO(y)},[y]),kD();let j=F.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),M=F.useCallback(()=>j([w,y]),[j,w,y]);F.useEffect(()=>{k&&M()},[k,M]);let{onOpenChange:N,triggerPointerDownPosRef:te}=v;F.useEffect(()=>{if(y){let e={x:0,y:0},t=_J(t=>{e={x:Math.abs(Math.round(t.pageX)-(te.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(te.current?.y??0))}},`handlePointerMove`),n=_J(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(y)||N(!1),document.removeEventListener(`pointermove`,t),te.current=null},`handlePointerUp`);return te.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,N,te]),F.useEffect(()=>{let e=_J(()=>N(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[N]);let[ne,re]=_Y(e=>{let t=O().filter(e=>!e.disabled),n=vY(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ie=F.useCallback((e,t,n)=>{let r=!A.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(A.current=!0))},[v.value]),ae=F.useCallback(()=>y?.focus(),[y]),P=F.useCallback((e,t,n)=>{let r=!A.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),oe=r===`popper`?YJ:JJ,se=oe===YJ?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,I.jsx)(WJ,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:ie,selectedItem:w,onItemLeave:ae,itemTextRefCallback:P,focusSelectedItem:M,selectedItemText:E,position:r,isPositioned:k,searchRef:ne,children:(0,I.jsx)(zO,{as:KJ,allowPinchZoom:!0,children:(0,I.jsx)(fD,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:$x(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(US,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,I.jsx)(oe,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...se,onPlaced:()=>ee(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:$x(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&re(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>j(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),JJ=F.forwardRef(_J(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=DJ(BJ,n),o=GJ(BJ,n),[s,c]=F.useState(null),[l,u]=F.useState(null),d=cS(t,u),f=SJ(n),p=F.useRef(!1),m=F.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=F.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-UJ,d=fJ(a,[UJ,Math.max(UJ,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-UJ,d=fJ(a,[UJ,Math.max(UJ,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-UJ*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-UJ,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,ee=m+v+k,A=x-ee;if(ee<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=ee+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+A;s.style.height=t+`px`,h.scrollTop=ee-E+h.offsetTop}s.style.margin=`${UJ}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);XS(()=>y(),[y]);let[b,x]=F.useState();return XS(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,I.jsx)(XJ,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:F.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,I.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,I.jsx)(jS.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),YJ=F.forwardRef(_J(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=UJ,...a}=e,o=TJ(n);return(0,I.jsx)(PT,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[XJ,ZJ]=wJ(BJ,{}),QJ=`SelectViewport`,$J=F.forwardRef(_J(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=GJ(QJ,n),o=ZJ(QJ,n),s=cS(t,a.onViewportChange),c=F.useRef(0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,I.jsx)(xJ.Slot,{scope:n,children:(0,I.jsx)(jS.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:$x(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-UJ*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[eY,tY]=wJ(`SelectGroup`),nY=F.forwardRef(_J(function(e,t){let{__scopeSelect:n,...r}=e,i=tC();return(0,I.jsx)(eY,{scope:n,id:i,children:(0,I.jsx)(jS.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})},`SelectGroup`)),rY=`SelectLabel`,iY=F.forwardRef(_J(function(e,t){let{__scopeSelect:n,...r}=e,i=tY(rY,n);return(0,I.jsx)(jS.div,{id:i.id,...r,ref:t})},`SelectLabel`)),aY=`SelectItem`,[oY,sY]=wJ(aY),cY=F.forwardRef(_J(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=DJ(aY,n),c=GJ(aY,n),l=s.value===r,[u,d]=F.useState(a??``),[f,p]=F.useState(!1),m=cS(t,FS(e=>c.itemRefCallback?.(e,r,i))),h=tC(),g=F.useRef(`touch`),_=_J(()=>{i||(s.onValueChange(r),s.onOpenChange(!1))},`handleSelect`);return(0,I.jsx)(oY,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:F.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(xJ.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,I.jsx)(jS.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:$x(o.onFocus,()=>p(!0)),onBlur:$x(o.onBlur,()=>p(!1)),onClick:$x(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:$x(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:$x(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:$x(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:$x(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:$x(o.onKeyDown,e=>{i||e.target!==e.currentTarget||c.searchRef?.current!==``&&e.key===` `||(yJ.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),lY=`SelectItemText`,uY=F.forwardRef(_J(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=DJ(lY,n),s=GJ(lY,n),c=sY(lY,n),l=kJ(lY,n),[u,d]=F.useState(null),f=FS(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=cS(t,d,c.onItemTextChange,f),m=u?.textContent,h=F.useMemo(()=>(0,I.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return XS(()=>(g(h),()=>_(h)),[g,_,h]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(jS.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!gY(o.value)?Bx.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),dY=`SelectItemIndicator`,fY=F.forwardRef(_J(function(e,t){let{__scopeSelect:n,...r}=e;return sY(dY,n).isSelected?(0,I.jsx)(jS.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),pY=`SelectBubbleInput`,mY=F.forwardRef(_J(function({__scopeSelect:e,...t},n){let r=DJ(pY,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u}=r,{nativeOptions:d,nativeSelectKey:f}=r,p=F.useRef(null),m=cS(n,p),h=i??``,g=hJ(h),_=Array.from(d).some(e=>(e.props.value??``)===``);return F.useEffect(()=>{let e=p.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(g!==h&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,h),e.dispatchEvent(t)}},[g,h]),(0,I.jsxs)(jS.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>a(e.target.value),...t,style:{...iE,...t.style},ref:m,defaultValue:h,children:[gY(i)&&!_?(0,I.jsx)(`option`,{value:``}):null,Array.from(d)]},f)},`SelectBubbleInput`));function hY(e){return typeof e==`function`}_J(hY,`isFunction`);function gY(e){return e===``||e===void 0}_J(gY,`shouldShowPlaceholder`);function _Y(e){let t=FS(e),n=F.useRef(``),r=F.useRef(0),i=F.useCallback(e=>{let i=n.current+e;t(i),_J((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=F.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return F.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}_J(_Y,`useTypeaheadSearch`);function vY(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=yY(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}_J(vY,`findNextItem`);function yY(e,t){return e.map((n,r)=>e[(t+r)%e.length])}_J(yY,`wrapArray`);var bY=`\0empty`,xY=e=>e===``?bY:e,SY=e=>e===bY?``:e;function CY({value:e,defaultValue:t,onValueChange:n,...r}){return(0,I.jsx)(jJ,{value:e===void 0?void 0:xY(e),defaultValue:t===void 0?void 0:xY(t),onValueChange:n&&(e=>n(SY(e))),...r})}var wY=`inline-flex min-w-0 cursor-pointer items-center justify-between gap-1.5 text-left`,TY=`h-(--control-h) rounded-md border border-border bg-surface-inset px-2.5 text-sm text-text transition-colors duration-(--dur-1) ease-app hover:border-border-strong data-[state=open]:border-accent data-placeholder:text-text-tertiary disabled:cursor-not-allowed disabled:text-text-disabled`,EY=`h-(--control-sm) rounded-md px-1.5 text-xs text-text-tertiary transition-colors duration-(--dur-1) ease-app enabled:hover:bg-surface-hover enabled:hover:text-text data-[state=open]:bg-surface-selected data-[state=open]:text-text disabled:cursor-not-allowed disabled:text-text-disabled`,DY=`h-(--control-h) max-w-80 min-w-0 rounded-md px-2.5 text-sm font-medium transition-colors duration-(--dur-1) ease-app enabled:hover:bg-surface-hover data-[state=open]:bg-surface-selected disabled:cursor-not-allowed disabled:text-text-disabled`;function OY({className:e,children:t,...n}){return(0,I.jsxs)(NJ,{className:q(wY,e),...n,children:[t,(0,I.jsx)(IJ,{className:`shrink-0 text-icon`,children:(0,I.jsx)(Uy,{size:14})})]})}function kY({className:e,...t}){return(0,I.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-left`,e),children:(0,I.jsx)(FJ,{...t})})}function AY({className:e,position:t=`popper`,sideOffset:n=4,collisionPadding:r=8,onEscapeKeyDown:i,children:a,...o}){return(0,I.jsx)(zJ,{children:(0,I.jsx)(VJ,{position:t,sideOffset:n,collisionPadding:r,onEscapeKeyDown:e=>{i?.(e),e.stopPropagation()},className:q(Vx,Jx.select,`min-w-32`,e),...o,children:(0,I.jsx)($J,{className:q(`w-full min-w-(--radix-select-trigger-width) p-1`,Hx),children:a})})})}var jY=nY;function MY({className:e,...t}){return(0,I.jsx)(iY,{className:q(Kx,e),...t})}var NY=q(Ux,Wx,`justify-between gap-3 data-[state=checked]:font-medium`);function PY({className:e,children:t,value:n,...r}){return(0,I.jsxs)(cY,{value:xY(n),className:q(NY,e),...r,children:[(0,I.jsx)(uY,{children:t}),(0,I.jsx)(fY,{className:`inline-flex shrink-0 items-center`,children:(0,I.jsx)(zy,{size:14,className:`text-text!`})})]})}function FY({projectId:e,calls:t,scenario:n,strip:r,onRun:i}){let a=rx(),[o,s]=(0,F.useState)(null),c=o??(n?.call?n.file:null),l=n&&n.file===c?n:void 0,u=l?.status===`landed`?l.landingId:void 0,[d,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(null),h=u&&l?.call?d?.landingId===u?d.form:oJ(l.call):null,g=u&&p?.landingId===u?p.res:null,_=e=>u&&f({landingId:u,form:e}),v=R.feature.sendCall.useMutation({onError:e=>a.push(e.message)}),y=()=>{!h||!u||v.mutate({projectId:e,request:sJ(h)},{onSuccess:e=>m({landingId:u,res:e})})},b=e=>{s(e),i(e)};return(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-auto bg-surface-inset p-4 md:flex-row md:overflow-hidden`,children:[(0,I.jsxs)(`nav`,{"aria-label":`Calls`,className:`flex shrink-0 flex-col gap-3 md:w-60 md:overflow-auto`,children:[(0,I.jsx)(IY,{title:`This feature`,entries:t.own,current:c,onPick:b}),(0,I.jsx)(IY,{title:t.othersLabel,entries:t.others,current:c,onPick:b})]}),(0,I.jsxs)(`section`,{"aria-label":`Request`,className:`flex min-w-0 flex-1 flex-col gap-3 md:overflow-auto`,children:[!c&&(0,I.jsx)(`p`,{className:`m-0 text-sm text-text-tertiary`,children:`Pick a call to seed its state and fill its request.`}),l&&l.status!==`landed`&&r,l?.status===`landed`&&l.callError&&(0,I.jsxs)(`p`,{className:`m-0 rounded-md bg-danger-subtle px-3 py-2 text-sm text-danger-text`,role:`alert`,children:[`Couldn’t read the call: `,l.callError]}),h&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(LY,{form:h,onChange:_}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(J,{variant:`primary`,size:`sm`,icon:(0,I.jsx)(ib,{}),loading:v.isPending,onClick:y,children:g?`Send again`:`Try it`}),(0,I.jsx)(J,{size:`sm`,variant:`ghost`,icon:(0,I.jsx)(Db,{}),onClick:()=>c&&i(c),children:`Re-run scenario`})]}),g&&(0,I.jsx)(RY,{result:g})]})]})]})}function IY({title:e,entries:t,current:n,onPick:r}){return t.length===0?null:(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsx)(WA,{children:e}),(0,I.jsx)(YA,{children:t.map(e=>(0,I.jsx)(JA,{title:e.name,meta:e.group,tooltip:e.file,active:e.file===n,onClick:()=>r(e.file)},e.file))})]})}function LY({form:e,onChange:t}){let n=(n,r)=>t({...e,headers:e.headers.map((e,t)=>t===n?{...e,...r}:e)});return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(CY,{value:e.method,onValueChange:n=>t({...e,method:n}),children:[(0,I.jsx)(OY,{"aria-label":`Method`,className:q(TY,`w-28 shrink-0 font-mono`),children:(0,I.jsx)(kY,{children:e.method})}),(0,I.jsx)(AY,{className:`font-mono`,children:aJ(e.method).map(e=>(0,I.jsx)(PY,{value:e,children:e},e))})]}),(0,I.jsx)(EN,{mono:!0,"aria-label":`URL`,className:`min-w-0 flex-1`,value:e.url,onChange:n=>t({...e,url:n.target.value})})]}),(0,I.jsx)(WA,{action:(0,I.jsx)(J,{size:`sm`,variant:`ghost`,icon:(0,I.jsx)(Ry,{}),onClick:()=>t({...e,headers:[...e.headers,{name:``,value:``}]}),children:`Add header`}),children:`Headers`}),e.headers.map((r,i)=>(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(EN,{mono:!0,"aria-label":`Header ${i+1} name`,className:`w-2/5 min-w-0`,value:r.name,onChange:e=>n(i,{name:e.target.value})}),(0,I.jsx)(EN,{mono:!0,"aria-label":`Header ${i+1} value`,className:`min-w-0 flex-1`,value:r.value,onChange:e=>n(i,{value:e.target.value})}),(0,I.jsx)(Y,{size:`sm`,label:`Remove header`,icon:(0,I.jsx)(By,{}),onClick:()=>t({...e,headers:e.headers.filter((e,t)=>t!==i)})})]},i)),(0,I.jsx)(WA,{children:`Body`}),(0,I.jsx)(ON,{mono:!0,rows:6,"aria-label":`Body`,value:e.body,onChange:n=>t({...e,body:n.target.value})})]})}function RY({result:e}){return e.ok?(0,I.jsxs)(`div`,{"aria-label":`Response`,role:`region`,className:`flex flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(BA,{size:`sm`,strong:!0,tone:cJ(e.status),children:`${e.status} ${e.statusText}`.trim()}),(0,I.jsxs)(`span`,{className:`text-xs text-text-tertiary tabular-nums`,children:[e.durationMs,` ms`]})]}),(0,I.jsx)($N,{size:`sm`,title:`Headers (${e.headers.length})`,children:(0,I.jsx)(`dl`,{className:`m-0 grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 font-mono text-xs`,children:e.headers.map(([e,t],n)=>(0,I.jsxs)(`div`,{className:`contents`,children:[(0,I.jsx)(`dt`,{className:`text-text-tertiary`,children:e}),(0,I.jsx)(`dd`,{className:`m-0 break-all text-text-secondary`,children:t})]},n))})}),(0,I.jsx)(`pre`,{className:`m-0 max-h-96 overflow-auto rounded-md bg-surface px-2 py-1.5 font-mono text-xs whitespace-pre-wrap text-text`,children:lJ(e.body)}),e.truncated&&(0,I.jsx)(`span`,{className:`text-xs text-warning-text`,children:`Truncated at 256 KB`})]}):(0,I.jsxs)(`p`,{className:`m-0 rounded-md bg-danger-subtle px-3 py-2 text-sm text-danger-text`,role:`alert`,children:[`Couldn’t send: `,e.error]})}function zY({call:e,defaultOpen:t=!1}){let{result:n}=e;return(0,I.jsx)($N,{size:`sm`,defaultOpen:t,aside:n.ok?`${n.durationMs} ms`:void 0,title:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[n.ok?(0,I.jsx)(BA,{size:`sm`,strong:!0,tone:cJ(n.status),children:String(n.status)}):(0,I.jsx)(BA,{size:`sm`,strong:!0,tone:`danger`,children:`Couldn’t send`}),(0,I.jsxs)(`span`,{className:`min-w-0 truncate font-mono text-xs text-text-secondary`,children:[e.method,` `,e.url]})]}),children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsx)(`h6`,{className:`m-0 text-xs font-medium text-text-tertiary`,children:`Sent`}),(0,I.jsx)($N,{size:`sm`,title:`Headers (${e.headers.length})`,children:(0,I.jsx)(`dl`,{className:`m-0 grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 font-mono text-xs`,children:e.headers.map(([e,t],n)=>(0,I.jsxs)(`div`,{className:`contents`,children:[(0,I.jsx)(`dt`,{className:`text-text-tertiary`,children:e}),(0,I.jsx)(`dd`,{className:`m-0 break-all text-text-secondary`,children:t})]},n))})}),e.body&&(0,I.jsx)(`pre`,{className:`m-0 max-h-48 overflow-auto rounded-md bg-surface px-2 py-1.5 font-mono text-xs whitespace-pre-wrap text-text`,children:e.body})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsx)(`h6`,{className:`m-0 text-xs font-medium text-text-tertiary`,children:`Answered`}),(0,I.jsx)(RY,{result:n})]})]})})}function BY({finding:e}){let t=e.kind===`defect`;return(0,I.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,I.jsxs)(`h4`,{className:q(`m-0 flex items-start gap-2 text-base font-medium`,t?`text-text`:`text-text-secondary`),children:[(0,I.jsx)(Sb,{size:16,className:q(`mt-0.5 shrink-0`,t?`text-warning`:`text-icon`)}),(0,I.jsx)(`span`,{className:`min-w-0`,children:e.title})]}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 pl-6`,children:[(0,I.jsx)(`p`,{className:`m-0 text-sm whitespace-pre-wrap text-text-secondary`,children:e.detail}),(0,I.jsxs)(`dl`,{className:`m-0 grid min-w-0 grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm`,children:[(0,I.jsx)(`dt`,{className:`text-text-tertiary`,children:`Where`}),(0,I.jsx)(`dd`,{className:`m-0 min-w-0 break-words text-text-secondary`,children:e.location}),e.reproStep&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`dt`,{className:`text-text-tertiary`,children:`To see it`}),(0,I.jsx)(`dd`,{className:`m-0 min-w-0 break-words whitespace-pre-wrap text-text-secondary`,children:e.reproStep})]}),(0,I.jsx)(`dt`,{className:`text-text-tertiary`,children:`Cites`}),(0,I.jsx)(`dd`,{className:`m-0 min-w-0 break-words text-text-tertiary`,children:e.citation})]})]})]})}function VY({findings:e}){let t=e.filter(e=>e.kind===`defect`),n=e.filter(e=>e.kind===`observation`);return(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,I.jsx)(`div`,{className:`mx-auto flex w-full max-w-[680px] min-w-0 flex-col gap-8 px-5 py-6`,children:[{title:`Defects`,list:t},{title:`Observations`,list:n}].map(({title:e,list:t})=>t.length>0&&(0,I.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-5`,children:[(0,I.jsx)(`h3`,{className:`m-0 text-lg font-semibold text-text`,children:e}),t.map(e=>(0,I.jsx)(BY,{finding:e},e.id))]},e))})})}function HY({stop:e,walkthrough:t}){switch(e.kind){case`video`:return(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-inset p-3`,children:t});case`findings`:return(0,I.jsx)(VY,{findings:e.findings});case`shot`:return(0,I.jsx)(`div`,{className:`min-h-0 flex-1 bg-surface-inset p-3`,children:(0,I.jsx)(`img`,{src:e.shot.src,alt:e.shot.caption,className:`block h-full w-full object-contain`})});case`call`:return(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-5`,children:(0,I.jsx)(zY,{call:e.call,defaultOpen:!0})})}}function UY({stop:e,poster:t}){if(e.kind===`shot`)return(0,I.jsx)(Qq,{src:e.shot.src,alt:``});if(e.kind===`video`)return(0,I.jsx)($q,{poster:t});let n=`grid aspect-[16/10] w-full place-items-center bg-surface-inset`;return e.kind===`findings`?(0,I.jsx)(`span`,{className:n,children:(0,I.jsx)(Sb,{size:14,className:e.findings.some(e=>e.kind===`defect`)?`text-warning`:`text-icon`})}):(0,I.jsx)(`span`,{className:q(n,`font-mono text-xs text-text-secondary`),children:e.call.result.ok?e.call.result.status:`—`})}function WY({stop:e,poster:t,active:n,onPick:r}){let i=(0,F.useRef)(null);return(0,F.useEffect)(()=>{let e=i.current?.closest(`aside`);!n||!e||getComputedStyle(e).overflowY===`visible`||i.current?.scrollIntoView?.({block:`nearest`})},[n]),(0,I.jsxs)(`button`,{ref:i,type:`button`,"aria-current":n,onClick:r,className:q(`flex w-full min-w-0 cursor-pointer items-center gap-2.5 rounded-md p-1.5 text-left transition-colors duration-(--dur-1)`,n?`card`:`hover:bg-surface-hover`),children:[(0,I.jsx)(`span`,{className:`w-14 shrink-0 overflow-hidden rounded-sm`,children:(0,I.jsx)(UY,{stop:e,poster:t})}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(`span`,{className:q(`line-clamp-2 min-w-0 text-xs`,n?`text-text`:`text-text-secondary`,e.kind===`call`&&`font-mono`),children:e.title}),e.kind===`findings`&&(0,I.jsx)(`span`,{className:`text-xs text-text-tertiary`,children:qq(e.findings)})]})]})}function GY({pack:e}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`m-0 px-1.5 text-sm text-text`,children:e.verdict}),e.empty&&(0,I.jsx)(`p`,{className:`m-0 px-1.5 text-sm text-text-tertiary`,children:e.empty})]})}function KY({pack:e}){return e.account?(0,I.jsx)($N,{size:`sm`,title:`The review’s full account`,className:`px-1.5`,children:(0,I.jsx)(VK,{source:e.account})}):null}function qY({pack:e,walkthrough:t}){let n=Xq(e),[r,i]=(0,F.useState)(Zq(n)?.id),a=Math.max(0,n.findIndex(e=>e.id===r)),o=n[a],s=e=>{let t=n[a+e];t&&i(t.id)};(0,F.useEffect)(()=>{let e=e=>{e.target instanceof HTMLMediaElement||((e.key===`ArrowRight`||e.key===`ArrowDown`)&&s(1),(e.key===`ArrowLeft`||e.key===`ArrowUp`)&&s(-1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let c=zx()?`touch`:`sm`;if(!o)return(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,I.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[680px] min-w-0 flex-col gap-4 px-3.5 py-6`,children:[(0,I.jsx)(GY,{pack:e}),(0,I.jsx)(KY,{pack:e})]})});let l=Kq(e)[0]?.src,u=[];for(let e of n)u.includes(e.group)||u.push(e.group);return(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-auto md:flex-row md:overflow-hidden`,children:[(0,I.jsxs)(`section`,{"aria-label":`In front`,className:q(o.kind===`shot`||o.kind===`video`?`h-[58dvh]`:``,`flex shrink-0 flex-col border-b border-border-subtle md:h-auto md:min-w-0 md:flex-1 md:shrink md:border-r md:border-b-0`),children:[(0,I.jsx)(HY,{stop:o,walkthrough:t},o.id),(0,I.jsxs)(`div`,{className:`flex min-h-11 shrink-0 items-center gap-2 border-t border-border-subtle py-1 pr-2 pl-5`,children:[(0,I.jsx)(`p`,{className:`m-0 min-w-0 flex-1 text-sm text-text-secondary`,children:o.title}),(0,I.jsxs)(`span`,{className:`shrink-0 text-xs text-text-tertiary tabular-nums`,children:[a+1,` of `,n.length]}),(0,I.jsx)(Y,{label:`Previous`,size:c,disabled:a===0,icon:(0,I.jsx)(Wy,{className:`rotate-180`}),onClick:()=>s(-1)}),(0,I.jsx)(Y,{label:`Next`,size:c,disabled:a===n.length-1,icon:(0,I.jsx)(Wy,{}),onClick:()=>s(1)})]})]}),(0,I.jsxs)(`aside`,{"aria-label":`In this package`,className:`flex min-w-0 shrink-0 flex-col gap-4 p-3 md:w-[320px] md:overflow-auto`,children:[(0,I.jsx)(GY,{pack:e}),u.map(e=>(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[e&&(0,I.jsx)(`h3`,{className:`m-0 px-1.5 pb-1 text-xs font-medium text-text-tertiary`,children:e}),n.filter(t=>t.group===e).map(e=>(0,I.jsx)(WY,{stop:e,poster:l,active:e.id===o.id,onPick:()=>i(e.id)},e.id))]},e??`first`)),e.groups.filter(e=>e.failure).map(e=>(0,I.jsxs)(`p`,{className:`m-0 flex items-start gap-1.5 px-1.5 text-xs text-danger-text`,children:[(0,I.jsx)(Sb,{size:12,className:`mt-0.5 shrink-0 text-danger`}),(0,I.jsxs)(`span`,{className:`min-w-0`,children:[e.name,` did not land: `,e.failure]})]},e.id)),(0,I.jsx)(KY,{pack:e})]})]})}function JY({pack:e,walkthrough:t,onClose:n}){let r=zx(),i=Yq(e),a=[e.round===null?`Ticket #${e.seq}`:`Round ${e.round}`,i?.toLowerCase()].filter(Boolean).join(`, `);return(0,I.jsxs)(aP,{open:!0,onClose:n,labelledBy:`package-title`,size:`full`,className:`flex h-[88dvh] flex-col overflow-hidden`,children:[(0,I.jsxs)(`div`,{className:`flex h-(--topbar-h) shrink-0 items-center gap-2 border-b border-border-subtle pr-2 pl-5`,children:[(0,I.jsx)(Eb,{size:16,className:`shrink-0 text-accent`}),(0,I.jsx)(`h2`,{id:`package-title`,className:`m-0 min-w-0 truncate text-sm font-medium text-text`,children:e.passKind===`verification`?`Verification package`:`Review package`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-text-tertiary`,children:a}),(0,I.jsx)(Y,{label:`Close`,size:r?`touch`:`sm`,icon:(0,I.jsx)(By,{}),onClick:n})]}),(0,I.jsx)(qY,{pack:e,walkthrough:t})]})}function YY({pack:e,onClose:t}){let n=Uh(e.featureId,e.hasWalkthrough).data?.find(t=>t.ticketId===e.ticketId&&t.videoUrl);return(0,I.jsx)(JY,{pack:e,onClose:t,walkthrough:n&&(0,I.jsx)(Vq,{featureId:e.featureId,recordings:[n],notes:[],readonly:!0})})}function XY({ticketId:e,onClose:t}){let{data:n}=qh(e);return n?(0,I.jsx)(YY,{pack:n,onClose:t}):null}function ZY({ticketId:e}){let{data:t}=qh(e),[n,r]=(0,F.useState)(!1);return t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(tJ,{pack:t,onOpen:()=>r(!0)}),n&&(0,I.jsx)(YY,{pack:t,onClose:()=>r(!1)})]}):null}var QY={"claude-code":cb,codex:lb};function $Y({ticketId:e,bootEvents:t,runtime:n,poll:r=!0}){let{chunks:i,live:a,trimmed:o}=nX(e,r),s=(0,F.useRef)(null),[c,l]=(0,F.useState)(!0),{blocks:u,completed:d}=(0,F.useMemo)(()=>Qv(i),[i]);(0,F.useEffect)(()=>{if(!c)return;let e=s.current;e&&(e.scrollTop=e.scrollHeight)},[u,a,c]);let f=()=>{let e=s.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<24;l(t)},p=n?QY[n]:null,m=u.length>0||a;return(0,I.jsxs)(`div`,{className:`relative max-h-120 overflow-y-auto rounded-md bg-surface-inset px-4 py-3`,ref:s,onScroll:f,children:[o&&(0,I.jsx)(`div`,{className:`pb-2 text-center text-xs text-text-tertiary`,children:`Earlier output trimmed`}),!m&&(0,I.jsx)(YN,{children:`No agent output captured — transcripts are held in server memory for the current burn; older runs keep only the event timeline.`}),m&&(0,I.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-xs font-medium text-text-secondary`,children:[p&&(0,I.jsx)(p,{size:14,className:`shrink-0 text-icon`}),n?MP(n):`Agent`]}),u.length===0&&a&&(0,I.jsx)(tX,{events:t}),u.length>0&&(0,I.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:u.map((e,t)=>(0,I.jsx)(eX,{block:e},t))}),d&&(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(BA,{tone:`success`,icon:(0,I.jsx)(zy,{}),children:`Agent reported complete`})}),a&&(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(BA,{tone:`live`,children:`Running…`})}),!c&&(0,I.jsx)(`div`,{className:`pointer-events-none sticky bottom-0 flex justify-end`,children:(0,I.jsx)(`span`,{className:`pointer-events-auto rounded-md bg-surface-raised shadow-popover animate-fade-in`,children:(0,I.jsx)(J,{size:`sm`,icon:(0,I.jsx)(Uy,{}),onClick:()=>l(!0),children:`Follow`})})})]})}function eX({block:e}){return e.kind===`text`?(0,I.jsx)(`div`,{className:`py-1 animate-rise-in`,children:(0,I.jsx)(VK,{source:e.text,size:`base`,tone:`primary`})}):(0,I.jsx)($N,{size:`sm`,animate:!0,title:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,title:e.args||void 0,children:[(0,I.jsx)(`span`,{className:`shrink-0 font-medium text-text-secondary`,children:e.name}),e.args&&(0,I.jsx)(`span`,{className:`min-w-0 truncate font-mono text-text-tertiary`,children:e.args})]}),bodyClassName:`pb-1`,children:e.args&&(0,I.jsx)(`pre`,{className:`m-0 font-mono text-xs break-words whitespace-pre-wrap text-text-tertiary`,children:e.args})})}function tX({events:e}){return e.length===0?(0,I.jsx)(YN,{children:`Starting the container…`}):(0,I.jsx)(`div`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`flex gap-3 text-xs animate-rise-in`,children:[(0,I.jsx)(`span`,{className:`shrink-0 text-text-tertiary tabular-nums`,children:cg(e.ts)}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-text-secondary`,children:e.message})]},e.id))})}function nX(e,t){let[n,r]=(0,F.useState)([]),[i,a]=(0,F.useState)(!1),[o,s]=(0,F.useState)(!1),c=n.length>0?n[n.length-1].i:void 0,l=tg(1e3),u=R.run.agentTranscript.useQuery({ticketId:e,after:c},{refetchInterval:t?l:!1});return(0,F.useEffect)(()=>{let e=u.data;e&&(a(e.live),s(e.firstIndex>0),r(t=>{let n=t.length>0?t[t.length-1].i:-1;if(e.nextIndex<=n)return[];if(e.chunks.length===0)return t;let r=e.chunks.filter(e=>e.i>n);return r.length===0?t:[...t,...r]}))},[u.data]),{chunks:n,live:i,trimmed:o}}function rX(e){return/\bimplementer[- ]only\b/i.test(e?.note??``)}function iX({value:e,roster:t,onChange:n,disabled:r=!1,label:i,ticketKind:a}){let o=t.find(t=>t.id===e),s=a===`review`&&rX(o),c=i??(o?`${o.id} · ${Bm[o.runtime]}`:e||`default model`),l=i??`Ticket model`;return(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col items-end gap-1`,children:[(0,I.jsxs)(CY,{value:e,onValueChange:n,children:[(0,I.jsx)(OY,{"aria-label":l,disabled:r,className:q(EY,`max-w-64 font-mono`),children:(0,I.jsx)(kY,{children:c})}),(0,I.jsxs)(AY,{"aria-label":l,className:`min-w-64 font-mono text-xs`,children:[(0,I.jsx)(PY,{value:``,children:`default (project model)`}),Wm(t).map(e=>(0,I.jsxs)(jY,{children:[(0,I.jsx)(MY,{children:e.label}),e.entries.map(e=>(0,I.jsxs)(PY,{value:e.id,children:[e.note?`${e.id} — ${e.note}`:e.id,a===`review`&&rX(e)?` — not recommended for review`:``]},e.id))]},e.runtime))]})]}),s&&(0,I.jsx)(`span`,{className:`text-xs text-warning-text`,children:`Implementer-only model — not recommended for review tickets`})]})}function aX({ticket:e,busy:t,onCancel:n,onSave:r}){let[i,a]=(0,F.useState)(e.title),[o,s]=(0,F.useState)(e.goal),[c,l]=(0,F.useState)(e.context),[u,d]=(0,F.useState)(e.acceptanceCriteria.join(`
|
|
148
|
-
`)),f=u.split(`
|
|
149
|
-
`).map(e=>e.trim()).filter(Boolean),p=!!i.trim()&&!!o.trim()&&f.length>0;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-4 pt-1 pr-3 pb-5 pl-10 animate-fade-in`,children:[(0,I.jsx)(kN,{label:`Title`,children:(0,I.jsx)(EN,{value:i,onChange:e=>a(e.target.value)})}),(0,I.jsx)(kN,{label:`Goal`,children:(0,I.jsx)(ON,{rows:3,value:o,onChange:e=>s(e.target.value)})}),(0,I.jsx)(kN,{label:`Context`,children:(0,I.jsx)(ON,{rows:3,value:c,onChange:e=>l(e.target.value)})}),(0,I.jsx)(kN,{label:`Acceptance`,help:`One criterion per line.`,children:(0,I.jsx)(ON,{rows:3,value:u,onChange:e=>d(e.target.value)})}),(0,I.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,I.jsx)(J,{variant:`ghost`,onClick:n,disabled:t,children:`Cancel`}),(0,I.jsx)(J,{variant:`primary`,icon:(0,I.jsx)(zy,{}),disabled:!p||t,onClick:()=>r({title:i.trim(),goal:o.trim(),context:c.trim(),acceptanceCriteria:f}),children:t?`Saving…`:`Save ticket`})]})]})}function oX({featureId:e,onOpenDoc:t}){let n=zx(),r=tg(),i=rx(),a=R.useUtils(),o=R.feature.get.useQuery({id:e},{refetchInterval:r}),s=R.feature.rounds.useQuery({featureId:e},{refetchInterval:r}),c=o.data?.feature.projectId,l=R.settings.get.useQuery({projectId:c??``},{enabled:!!c}),u=nL(e),d=(0,F.useMemo)(()=>sX(u),[u]),f=(0,F.useMemo)(()=>uv(d),[d]),p=(0,F.useMemo)(()=>ey(d),[d]),m=Um(l.data),h=hh(l.data,`implement`),g={onSuccess:()=>a.feature.get.invalidate({id:e}),onError:e=>i.push(e.message)},_=R.ticket.edit.useMutation(g),v=R.ticket.stop.useMutation(g),y=R.ticket.cancel.useMutation(g),b=hx(e),x=R.feature.launchSession.useMutation({...g,onSuccess:()=>{g.onSuccess(),b()}}),S=_.isPending||v.isPending||y.isPending||x.isPending;if(!o.data)return null;let C=o.data.feature,w=o.data.tickets;if(w.length===0)return(0,I.jsx)(XN,{compact:!0,icon:(0,I.jsx)($y,{}),title:`No tickets yet`,hint:`The agent breaks the work into tickets when it is worth handing to workers. They appear here.`});let{folded:T,current:E}=cX(w,s.data??[]),D=w.filter(e=>e.status===`pending`),O=o.data.runs.find(e=>e.status===`running`),k=Vv(u,O?.id),ee=!!O||o.data.sessions.some(dv),A=e=>{e.swept?i.push(`no live agent — the lane was orphaned; marked failed`,`info`):e.stopped?e.confirmed||i.push(PP):i.push(`no live agent for this ticket (already finishing?)`,`info`)},j={roster:m,busy:S,terminalBlocked:ee,featureBranch:C.branch,stopping:v.isPending?v.variables?.ticketId:void 0,cancelling:y.isPending?y.variables?.ticketId:void 0,stop:e=>v.mutate({ticketId:e.id},{onSuccess:A}),setModel:(e,t)=>_.mutate({ticketId:e.id,model:t}),save:async(e,t)=>{await _.mutateAsync({ticketId:e.id,...t}),i.push(`ticket updated`,`success`)},cancel:e=>y.mutate({ticketId:e.id},{onSuccess:e=>{i.push(`ticket cancelled`,`success`),e.confirmed||i.push(PP)}}),resolveInTerminal:(t,n)=>x.mutate({featureId:e,kind:`chat`,kickoffLine:tv({seq:t.seq,title:t.title,branch:t.attemptBranch??``,featureBranch:C.branch,files:n}),purpose:`resolve-conflict`,purposeData:{mergeFrom:t.attemptBranch??``,mergeInto:C.branch}}),copySha:e=>navigator.clipboard?.writeText(e).then(()=>i.push(`copied ${fg(e)}`,`info`),()=>i.push(`copy failed`)),facts:p,durations:f,bootEvents:e=>d.filter(t=>t.ticketId===e.id),runtime:e=>(py(e,m)??py({model:hh(l.data,e.kind===`review`?`review`:`implement`)},m))?.runtime},M=async t=>{try{for(let e of D)await a.client.ticket.edit.mutate({ticketId:e.id,model:t});await a.feature.get.invalidate({id:e}),i.push(`${D.length} tickets set to ${t||`the default model`}`,`success`)}catch(e){i.push(e instanceof Error?e.message:`could not update ticket models`)}};return(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[T.length>0&&(0,I.jsx)(`div`,{className:`-mx-2.5 mb-6 flex flex-col`,children:T.map(e=>(0,I.jsx)(dX,{round:e.round,tickets:e.tickets,controls:j},e.round.round))}),(0,I.jsxs)(`div`,{className:`mb-2 flex min-h-7 items-center gap-2`,children:[(0,I.jsx)(`h2`,{className:`m-0 text-sm font-medium text-text`,children:E.round?`Round ${E.round.round}`:E.number>1?`Round ${E.number}`:`Round 1`}),(0,I.jsx)(`span`,{className:q(`min-w-0 truncate text-xs`,E.running?`text-shimmer text-text-secondary`:`text-text-tertiary`),children:k??lX(E)}),(0,I.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[O&&(0,I.jsx)(`span`,{className:`text-xs text-text-tertiary tabular-nums`,children:_g(O.startedAt,Date.now())}),!n&&(0,I.jsx)(gX,{roster:m,defaultModel:h,waiting:D.length,onModel:e=>void M(e),docs:o.data.docs,onOpenDoc:t})]})]}),(0,I.jsx)(`div`,{className:`-mx-2.5 flex flex-col gap-0.5`,children:E.tickets.map((e,t)=>(0,I.jsx)(pX,{ticket:e,index:t,tickets:w,controls:j},e.id))})]})}function sX(e){let t=new Map;for(let n of e)n.ticketId&&n.runId&&t.set(n.ticketId,n.runId);return e.filter(e=>e.ticketId!==void 0&&e.runId!==void 0&&t.get(e.ticketId)===e.runId)}function cX(e,t){let n=[...t].sort((e,t)=>e.round-t.round),r=new Set(n.flatMap(e=>e.ticketSeqs)),i=t=>e.filter(e=>t.ticketSeqs.includes(e.seq)),a=e.filter(e=>!r.has(e.seq)&&e.status!==`cancelled`),o=n.find(e=>e.status===`running`),s=n[n.length-1],c=o?{round:o,number:o.round,running:!0,tickets:i(o)}:a.length>0||!s?{round:null,number:(s?.round??0)+1,running:!1,tickets:a}:{round:s,number:s.round,running:!1,tickets:i(s)};return{folded:n.filter(e=>e!==c.round).map(e=>({round:e,tickets:i(e)})),current:c}}function lX(e){let t=e.tickets.filter(e=>e.kind!==`review`),n=t.filter(e=>e.status===`done`).length;return e.running?`Running · ${n} of ${t.length} landed`:e.round?uX(e.round,e.tickets):`${t.length} ${t.length===1?`ticket waits`:`tickets wait`} to run`}function uX(e,t){let n=t.filter(e=>e.kind!==`review`),r=[`${e.landed.filter(e=>n.some(t=>t.seq===e)).length} of ${n.length} landed`];return e.failed.length&&r.push(`${e.failed.length} failed`),e.gates&&r.push(e.gates.ok?`checks passed`:`checks failed`),r.join(` · `)}function dX({round:e,tickets:t,controls:n}){let[r,i]=(0,F.useState)(!1),a=e.finishedAt?_g(e.startedAt,e.finishedAt):null;return(0,I.jsxs)(`div`,{className:q(`rounded-lg transition-colors duration-(--dur-1) ease-app`,r&&`card`),children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:()=>i(!r),className:q(`flex h-9 w-full cursor-pointer items-center gap-2 rounded-[inherit] px-2.5 text-left`,!r&&`hover:bg-surface-hover`),children:[(0,I.jsx)(Wy,{size:12,className:q(`shrink-0 text-icon transition-transform duration-(--dur-2) ease-app`,r&&`rotate-90`)}),(0,I.jsxs)(`span`,{className:`shrink-0 text-sm font-medium text-text-secondary`,children:[`Round `,e.round]}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-xs text-text-tertiary`,children:uX(e,t)}),a&&(0,I.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-text-tertiary tabular-nums`,children:a})]}),r&&(0,I.jsx)(`div`,{className:`flex flex-col gap-0.5 p-1 pt-0 animate-fade-in`,children:t.map(e=>(0,I.jsx)(pX,{ticket:e,tickets:t,controls:n,nested:!0},e.id))})]})}var fX={pending:{glyph:(0,I.jsx)(`span`,{className:`size-2.5 rounded-full border border-dashed border-text-tertiary`}),word:`Waiting`},burning:{glyph:(0,I.jsx)(UE,{size:`sm`}),word:`Running`},done:{glyph:(0,I.jsx)(zy,{size:12,className:`text-success`}),word:`Landed`},failed:{glyph:(0,I.jsx)(Sb,{size:12,className:`text-danger`}),word:`Failed`,tone:`text-danger-text`},"launch-failed":{glyph:(0,I.jsx)(Sb,{size:12,className:`text-danger`}),word:`Could not start`,tone:`text-danger-text`},stopped:{glyph:(0,I.jsx)(ab,{size:12,className:`text-warning`}),word:`Stopped`,tone:`text-warning-text`},waived:{glyph:(0,I.jsx)(By,{size:12,className:`text-text-disabled`}),word:`Set aside`}};function pX({ticket:e,index:t,tickets:n,controls:r,nested:i=!1}){let[a,o]=(0,F.useState)(!1),s=r.facts.get(e.id),c=r.durations.get(e.id),l=Wv({...e,hadOutput:s?.hadOutput}),u=l===`pending`?e.blockedBy.filter(e=>n.find(t=>t.seq===e)?.status!==`done`):[],d=fX[l],f=py(e,r.roster),p=e.kind===`review`,m=[p&&l===`pending`?`Review · waits for the work`:p&&l===`done`?`Reviewed`:u.length?`Waits on #${u.join(`, #`)}`:d.word,l===`burning`&&s?_g(s.startedAt,Date.now()):null,l===`done`&&!p&&e.commits[0]?fg(e.commits[0]):null,l===`done`&&c?`${Math.round(c/6e4)}m`:null,!a&&(l===`failed`||l===`launch-failed`)&&e.error?e.error.split(`
|
|
150
|
-
`)[0]:null].filter(Boolean).join(` · `),h=t!==void 0&&t<8;return(0,I.jsxs)(`article`,{"data-ticket-state":l,style:h?{"--i":t}:void 0,className:q(`group/ticket relative transition-colors duration-(--dur-1) ease-app`,i?`rounded-md`:`rounded-lg`,a?`card`:`hover:bg-surface-hover`,h&&`animate-rise-in [animation-delay:calc(var(--i)*20ms)] [animation-fill-mode:both]`),children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(!a),className:`flex w-full cursor-pointer flex-col gap-0.5 rounded-[inherit] px-2.5 py-2 text-left`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsxs)(`span`,{className:`w-6 shrink-0 text-xs text-text-tertiary tabular-nums`,children:[`#`,e.seq]}),(0,I.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-md`,l===`waived`?`text-text-tertiary line-through`:a?`font-medium text-text`:`text-text`),children:e.title}),p&&(0,I.jsx)(Eb,{size:14,className:`shrink-0 text-icon`,"aria-label":`Review`})]}),(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 pl-8 text-xs text-text-tertiary`,children:[(0,I.jsx)(`span`,{className:`inline-flex size-3 shrink-0 items-center justify-center`,children:d.glyph}),(0,I.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate`,l===`burning`&&`text-shimmer`,d.tone),children:m}),f&&(0,I.jsx)(`span`,{className:`shrink-0 font-mono`,children:f.id})]})]}),a&&(0,I.jsx)(hX,{ticket:e,state:l,controls:r})]})}function mX({title:e,children:t}){return(0,I.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,I.jsx)(`h4`,{className:`m-0 text-xs font-medium text-text-tertiary`,children:e}),t]})}function hX({ticket:e,state:t,controls:n}){let[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(!1),l=zx(),u=!l&&(e.status===`pending`||e.status===`failed`),d=e.status===`failed`?e.conflictFiles:void 0,{busy:f}=n,p=e.kind===`review`&&t!==`pending`&&t!==`burning`&&t!==`waived`,[m,h]=(0,F.useState)(!1);return r?(0,I.jsx)(aX,{ticket:e,busy:a,onCancel:()=>i(!1),onSave:t=>{o(!0),n.save(e,t).then(()=>i(!1),()=>void 0).finally(()=>o(!1))}}):(0,I.jsxs)(`div`,{className:`flex flex-col gap-4 pt-1 pr-3 pb-4 pl-10.5 animate-fade-in`,children:[s?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md bg-danger-subtle px-3 py-2 text-sm text-text-secondary`,children:[(0,I.jsxs)(`span`,{className:`mr-auto`,children:[`Cancel #`,e.seq,`? Tickets that depend on it treat it as done. Its text stays in the list.`]}),(0,I.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>c(!1),children:`Keep it`}),(0,I.jsx)(J,{size:`sm`,variant:`danger`,disabled:f,onClick:()=>{n.cancel(e),c(!1)},children:`Cancel`})]}):(0,I.jsxs)(`div`,{className:`-ml-2 flex flex-wrap items-center gap-1`,children:[t===`burning`&&!l&&(0,I.jsx)(J,{size:`sm`,variant:`danger-ghost`,icon:(0,I.jsx)(ab,{}),loading:n.stopping===e.id,disabled:f,onClick:()=>n.stop(e),children:n.stopping===e.id?`Stopping…`:`Stop`}),d&&!l&&(0,I.jsx)(J,{size:`sm`,variant:`ghost`,icon:(0,I.jsx)(Ky,{}),disabled:f||n.terminalBlocked,title:n.terminalBlocked?`available once this run finishes and no terminal is open`:`open a terminal on the feature branch, briefed with this ticket and its conflicting files, and resolve it yourself`,onClick:()=>n.resolveInTerminal(e,d),children:`Resolve in terminal`}),p&&(0,I.jsx)(J,{size:`sm`,variant:`ghost`,icon:(0,I.jsx)(Eb,{}),onClick:()=>h(!0),children:`Open review package`}),u&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(iX,{value:e.model??``,roster:n.roster,ticketKind:e.kind,disabled:f,onChange:t=>n.setModel(e,t)}),(0,I.jsx)(J,{size:`sm`,variant:`ghost`,icon:(0,I.jsx)(Yy,{}),disabled:f,onClick:()=>i(!0),children:`Edit`})]}),u&&(0,I.jsx)(J,{size:`sm`,variant:`ghost`,icon:(0,I.jsx)(By,{}),loading:n.cancelling===e.id,disabled:f,onClick:()=>c(!0),children:`Cancel`})]}),d&&(0,I.jsxs)(mX,{title:`Merge conflict`,children:[(0,I.jsxs)(`p`,{className:`m-0 text-sm text-text-secondary`,children:[`The work is committed but could not land on`,` `,(0,I.jsx)(`code`,{className:`font-mono text-xs text-text`,children:n.featureBranch})]}),d.length>0&&(0,I.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-0.5 p-0`,children:d.map(e=>(0,I.jsx)(`li`,{className:`truncate font-mono text-xs text-text-secondary`,title:e,children:e},e))})]}),(t===`failed`||t===`launch-failed`||t===`stopped`)&&e.error&&(0,I.jsx)(mX,{title:`What went wrong`,children:(0,I.jsx)(`p`,{className:`m-0 text-sm whitespace-pre-wrap text-text-secondary`,children:(0,I.jsx)(xte,{text:e.error})})}),e.goal&&(0,I.jsx)(mX,{title:`Goal`,children:(0,I.jsx)(VK,{source:e.goal})}),e.acceptanceCriteria.length>0&&(0,I.jsx)(mX,{title:`Done when`,children:(0,I.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-5 text-sm text-text-secondary marker:text-text-tertiary`,children:e.acceptanceCriteria.map((e,t)=>(0,I.jsx)(`li`,{children:e},t))})}),t===`done`&&e.kind!==`review`&&e.commits.length>0&&(0,I.jsx)(mX,{title:`Commits`,children:(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.commits.map(e=>(0,I.jsx)(`button`,{type:`button`,title:`Copy the full SHA`,className:`cursor-pointer rounded-sm bg-surface-inset px-1.5 py-0.5 font-mono text-xs text-text-secondary transition-colors duration-(--dur-1) hover:text-text`,onClick:()=>n.copySha(e),children:fg(e)},e))})}),t===`burning`?(0,I.jsx)(mX,{title:`Live log`,children:(0,I.jsx)(oq,{label:`agent transcript`,children:(0,I.jsx)($Y,{ticketId:e.id,bootEvents:n.bootEvents(e),runtime:n.runtime(e)})})}):e.digest&&e.kind!==`review`?(0,I.jsx)(mX,{title:`What the worker said`,children:(0,I.jsx)(VK,{source:e.digest})}):null,m&&(0,I.jsx)(XY,{ticketId:e.id,onClose:()=>h(!1)})]})}function gX({roster:e,defaultModel:t,waiting:n,onModel:r,docs:i,onOpenDoc:a}){return(0,I.jsxs)(mN,{children:[(0,I.jsx)(hN,{asChild:!0,children:(0,I.jsx)(Y,{label:`Ticket list options`,size:`sm`,icon:(0,I.jsx)(Gy,{})})}),(0,I.jsxs)(gN,{align:`end`,className:`min-w-64`,children:[(0,I.jsxs)(vN,{children:[`Sandbox `,AP,` · default model `,(0,I.jsx)(`span`,{className:`font-mono`,children:t??`unset`})]}),n>0&&e.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(yN,{}),(0,I.jsx)(vN,{children:`Run every waiting ticket on`}),e.map(e=>(0,I.jsx)(_N,{icon:(0,I.jsx)($y,{}),onSelect:()=>r(e.id),children:(0,I.jsx)(`span`,{className:`font-mono`,children:e.id})},e.id))]}),i.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(yN,{}),(0,I.jsx)(vN,{children:`Docs`}),i.map(e=>(0,I.jsx)(_N,{icon:(0,I.jsx)(Jy,{}),onSelect:()=>a(e.relPath),children:e.title||e.relPath.split(/[\\/]/).pop()},e.relPath))]})]})]})}function _X(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function vX(e,t,n,r){let i=r>0&&n>0?n/r:1;return{x:Math.round((e.x+t.left)*i),y:Math.round((e.y+t.top)*i),width:Math.round(e.width*i),height:Math.round(e.height*i)}}function yX(e){return e.width>=8&&e.height>=8}function bX(e){return e?typeof e.mediaDevices?.getDisplayMedia==`function`&&`userAgentData`in e:!1}var xX=[{width:1440,name:`Desktop`},{width:1280,name:`Laptop`},{width:768,name:`Tablet`},{width:390,name:`Mobile`},{width:`fit`,name:`Fit`}],SX=1440,CX=`runcastle.preview.width`;function wX(e,t){if(e===`fit`)return{width:t.width,height:t.height,scale:1,left:0};let n=t.width>0?Math.min(1,t.width/e):1;return{width:e,height:t.height/n,scale:n,left:Math.max(0,(t.width-e)/2)}}function TX(e,t){return e===`fit`?`Fit`:`${e} · ${Math.round(t*100)}%`}function EX(e){if(e===`fit`)return`fit`;let t=typeof e==`string`&&e.trim()!==``?Number(e):e;return typeof t==`number`&&Number.isInteger(t)&&t>0?t:null}function DX(){try{return EX(localStorage.getItem(`runcastle.preview.width`))??1440}catch{return SX}}function OX(e){try{localStorage.setItem(CX,String(e))}catch{}}function kX({width:e,scale:t,onPick:n}){let r=xX.some(t=>t.width===e)?xX:[{width:e,name:`Asked for`},...xX];return(0,I.jsxs)(CY,{value:String(e),onValueChange:e=>{let t=EX(e);t!==null&&n(t)},children:[(0,I.jsx)(OY,{"aria-label":`Screen width`,className:q(EY,`tabular-nums`),children:(0,I.jsx)(kY,{children:TX(e,t)})}),(0,I.jsx)(AY,{align:`start`,"aria-label":`Screen width`,children:r.map(e=>(0,I.jsx)(PY,{value:String(e.width),children:e.width===`fit`?e.name:`${e.name} ${e.width}`},e.width))})]})}var AX=6e3,jX=120;function MX(e){return new Promise(t=>{if(typeof e.requestVideoFrameCallback==`function`){e.requestVideoFrameCallback(()=>t());return}setTimeout(t,jX)})}var NX={note:{frameTitle:`the app on this branch`,open:`Open app`,cannotCapture:`This browser can’t capture its own tab — paste a screenshot into a note instead`,cannotEmbed:`Can’t embed? Open the app and paste a screenshot into a note.`},chat:{frameTitle:`the design preview`,open:`Open in a new tab`,cannotCapture:`This browser can’t capture its own tab — tell the chat instead`,cannotEmbed:`Can’t embed? Open it in a new tab.`}};function PX(e,t){let[n,r]=(0,F.useState)(()=>e??DX());(0,F.useEffect)(()=>{e!==void 0&&r(e)},[e]);let i=e=>{r(e),OX(e)},[a,o]=(0,F.useState)({width:0,height:0});return(0,F.useEffect)(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(([e])=>{e&&o({width:e.contentRect.width,height:e.contentRect.height})});return n.observe(e),()=>n.disconnect()},[t]),{chosen:n,pick:i,size:wX(n,a)}}function FX({url:e,agentDriving:t=!1,frameKey:n=``,leading:r,toolbar:i,trailing:a,strip:o,cover:s,footer:c,width:l,onCapture:u,copy:d=`note`}){let f=rx(),p=NX[d],m=(0,F.useRef)(null),h=PX(l,m),g=(0,F.useRef)(null),_=(0,F.useRef)(null),[v]=(0,F.useState)(()=>!!u&&bX(typeof navigator>`u`?void 0:navigator)),[y,b]=(0,F.useState)(!1),[x,S]=(0,F.useState)(!1),[C,w]=(0,F.useState)(null),T=(0,F.useRef)(null),[E,D]=(0,F.useState)(!1),[O,k]=(0,F.useState)(!1),[ee,A]=(0,F.useState)(0);(0,F.useEffect)(()=>{D(!1),k(!1);let e=setTimeout(()=>k(!0),AX);return()=>clearTimeout(e)},[e,n,ee]),(0,F.useEffect)(()=>()=>{_.current?.getTracks().forEach(e=>e.stop()),_.current=null},[]);let j=async()=>{if(!_.current){b(!0);try{let e=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:`browser`},audio:!1,preferCurrentTab:!0,selfBrowserSurface:`include`});_.current=e,e.getVideoTracks().forEach(t=>{t.addEventListener(`ended`,()=>{_.current===e&&(_.current=null)})});let t=g.current;t&&(t.srcObject=e,await t.play())}catch(e){f.push(e instanceof Error&&e.name===`NotAllowedError`?`tab sharing was declined — nothing to capture from`:`tab capture failed: ${e instanceof Error?e.message:String(e)}`);return}finally{b(!1)}}S(!0)},M=async e=>{let t=m.current,n=g.current;if(!t||!n)return;if(await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame),await MX(n),!n.videoWidth){f.push(`the tab is no longer being shared — click Select area again`),_.current=null;return}let r=vX(e,t.getBoundingClientRect(),n.videoWidth,window.innerWidth),i=document.createElement(`canvas`);i.width=r.width,i.height=r.height;let a=i.getContext(`2d`);if(!a)return;a.drawImage(n,r.x,r.y,r.width,r.height,0,0,r.width,r.height);let o=await new Promise(e=>i.toBlob(e,`image/png`));if(!o){f.push(`the selected region could not be turned into a picture`);return}u?.(o)},N=e=>{let t=m.current?.getBoundingClientRect();t&&(T.current={x:e.clientX-t.left,y:e.clientY-t.top},e.currentTarget.setPointerCapture?.(e.pointerId))},te=e=>{let t=m.current?.getBoundingClientRect();!T.current||!t||w(_X(T.current,{x:e.clientX-t.left,y:e.clientY-t.top}))},ne=e=>{let t=m.current?.getBoundingClientRect(),n=T.current;if(T.current=null,!n||!t)return;let r=_X(n,{x:e.clientX-t.left,y:e.clientY-t.top});S(!1),w(null),yX(r)&&M(r)},re=`min-w-0 truncate px-1.5 text-xs text-text-tertiary`;return(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,I.jsxs)(`div`,{role:`toolbar`,"aria-label":`Page controls`,className:`flex h-(--topbar-h) shrink-0 items-center gap-1 border-b border-border-subtle px-2`,children:[r,i&&(0,I.jsx)(`div`,{className:`flex min-w-0 shrink items-center gap-1`,children:i}),t&&(0,I.jsx)(`span`,{className:`min-w-0 truncate px-1.5`,children:(0,I.jsx)(BA,{tone:`live`,children:`Review agent driving`})}),!s&&u&&!v&&(0,I.jsx)(`span`,{className:re,children:p.cannotCapture}),!s&&!E&&O&&(0,I.jsx)(`span`,{className:re,children:p.cannotEmbed}),(0,I.jsx)(`span`,{className:`flex-1`}),!s&&(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[v?(0,I.jsx)(Y,{label:y?`Sharing…`:x?`Drag a region`:`Select area`,icon:(0,I.jsx)(Vb,{}),active:x,disabled:y,tooltipSide:`bottom`,onClick:()=>void j()}):null,(0,I.jsx)(Y,{label:`Reload`,icon:(0,I.jsx)(Db,{}),tooltipSide:`bottom`,onClick:()=>A(e=>e+1)}),(0,I.jsx)(kX,{width:h.chosen,scale:h.size.scale,onPick:h.pick}),(0,I.jsx)(Y,{label:p.open,href:e,target:`_blank`,icon:(0,I.jsx)(mb,{}),tooltipSide:`bottom`})]}),a]}),o,s,(0,I.jsxs)(`div`,{ref:m,className:q(`relative min-h-0 flex-1 flex-col overflow-hidden bg-surface-inset`,s?`hidden`:`flex`),children:[(0,I.jsx)(`iframe`,{className:h.chosen===`fit`?`min-h-0 flex-1 border-0`:`absolute top-0 origin-top-left border-0`,style:h.chosen===`fit`?void 0:{left:h.size.left,width:h.size.width,height:h.size.height,transform:`scale(${h.size.scale})`},src:e,title:p.frameTitle,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,onLoad:()=>D(!0)},`${n}:${ee}`),x&&(0,I.jsx)(`div`,{className:`absolute inset-0 z-10 cursor-crosshair touch-none bg-scrim/20 animate-fade-in`,"aria-label":`drag over the part of the app that needs fixing`,onPointerDown:N,onPointerMove:te,onPointerUp:ne,onPointerCancel:ne,children:C&&(0,I.jsx)(`div`,{className:`absolute rounded-sm border-2 border-accent bg-accent-subtle/40`,style:{left:C.x,top:C.y,width:C.width,height:C.height}})}),v&&(0,I.jsx)(`video`,{ref:g,muted:!0,playsInline:!0,className:`hidden`})]}),c]})}var IX=2,LX=1,RX=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(IX,Math.floor(u/e.css.cell.width)),rows:Math.max(LX,Math.floor(l/e.css.cell.height))}}},zX=Object.defineProperty,BX=Object.getOwnPropertyDescriptor,VX=(e,t)=>{for(var n in t)zX(e,n,{get:t[n],enumerable:!0})},HX=(e,t,n,r)=>{for(var i=r>1?void 0:r?BX(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&zX(t,n,i),i},Z=(e,t)=>(n,r)=>t(n,r,e),UX=`Terminal input`,WX={get:()=>UX,set:e=>UX=e},GX=`Too much output to announce, navigate to rows manually to read`,KX={get:()=>GX,set:e=>GX=e};function qX(e){return e.replace(/\r?\n/g,`\r`)}function JX(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function YX(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function XX(e,t,n,r){e.stopPropagation(),e.clipboardData&&ZX(e.clipboardData.getData(`text/plain`),t,n,r)}function ZX(e,t,n,r){e=qX(e),e=JX(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function QX(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function $X(e,t,n,r,i){QX(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function eZ(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function tZ(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var nZ=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},rZ=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},iZ=``,aZ=` `,oZ=class e{constructor(){this.fg=0,this.bg=0,this.extended=new sZ}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},sZ=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},cZ=class e extends oZ{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new sZ,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?eZ(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},lZ=`di$target`,uZ=`di$dependencies`,dZ=new Map;function fZ(e){return e[uZ]||[]}function pZ(e){if(dZ.has(e))return dZ.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);mZ(t,e,r)};return t._id=e,dZ.set(e,t),t}function mZ(e,t,n){t[lZ]===t?t[uZ].push({id:e,index:n}):(t[uZ]=[{id:e,index:n}],t[lZ]=t)}var hZ=pZ(`BufferService`),gZ=pZ(`CoreMouseService`),_Z=pZ(`CoreService`),vZ=pZ(`CharsetService`),yZ=pZ(`InstantiationService`),bZ=pZ(`LogService`),xZ=pZ(`OptionsService`),SZ=pZ(`OscLinkService`),CZ=pZ(`UnicodeService`),wZ=pZ(`DecorationService`),TZ=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new cZ,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):EZ(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};TZ=HX([Z(0,hZ),Z(1,xZ),Z(2,SZ)],TZ);function EZ(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
151
|
-
|
|
152
|
-
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var DZ=pZ(`CharSizeService`),OZ=pZ(`CoreBrowserService`),kZ=pZ(`MouseService`),AZ=pZ(`RenderService`),jZ=pZ(`SelectionService`),MZ=pZ(`CharacterJoinerService`),NZ=pZ(`ThemeService`),PZ=pZ(`LinkProviderService`),FZ=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?VZ.isErrorNoTelemetry(e)?new VZ(e.message+`
|
|
153
|
-
|
|
154
|
-
`+e.stack):Error(e.message+`
|
|
155
|
-
|
|
156
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function IZ(e){RZ(e)||FZ.onUnexpectedError(e)}var LZ=`Canceled`;function RZ(e){return e instanceof zZ||e instanceof Error&&e.name===LZ&&e.message===LZ}var zZ=class extends Error{constructor(){super(LZ),this.name=this.message}};function BZ(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var VZ=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},HZ=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function UZ(e,t,n=0,r=e.length){let i=n,a=r;for(;i<a;){let n=Math.floor((i+a)/2);t(e[n])?i=n+1:a=n}return i-1}var WZ=class e{constructor(e){this._array=e,this._findLastMonotonousLastIdx=0}findLastMonotonous(t){if(e.assertInvariants){if(this._prevFindLastPredicate){for(let e of this._array)if(this._prevFindLastPredicate(e)&&!t(e))throw Error(`MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.`)}this._prevFindLastPredicate=t}let n=UZ(this._array,t,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=n+1,n===-1?void 0:this._array[n]}};WZ.assertInvariants=!1;function GZ(e,t=0){return e[e.length-(1+t)]}var KZ;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(KZ||={});function qZ(e,t){return(n,r)=>t(e(n),e(r))}var JZ=(e,t)=>e-t,YZ=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>e(n)?(t=n,!1):!0),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||KZ.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};YZ.empty=new YZ(e=>{});function XZ(e,t){let n=Object.create(null);for(let r of e){let e=t(r),i=n[e];i||=n[e]=[],i.push(r)}return n}var ZZ=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){return this.map.get(e)||new Set}};function QZ(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var $Z;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})($Z||={});var eQ=null,tQ=class e{constructor(){this.livingDisposables=new Map}getDisposableData(t){let n=this.livingDisposables.get(t);return n||(n={parent:null,source:null,isSingleton:!1,value:t,idx:e.idx++},this.livingDisposables.set(t,n)),n}trackDisposable(e){let t=this.getDisposableData(e);t.source||=Error().stack}setParent(e,t){let n=this.getDisposableData(e);n.parent=t}markAsDisposed(e){this.livingDisposables.delete(e)}markAsSingleton(e){this.getDisposableData(e).isSingleton=!0}getRootParent(e,t){let n=t.get(e);if(n)return n;let r=e.parent?this.getRootParent(this.getDisposableData(e.parent),t):e;return t.set(e,r),r}getTrackedDisposables(){let e=new Map;return[...this.livingDisposables.entries()].filter(([,t])=>t.source!==null&&!this.getRootParent(t,e).isSingleton).flatMap(([e])=>e)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let e=new Map,t=[...this.livingDisposables.values()].filter(t=>t.source!==null&&!this.getRootParent(t,e).isSingleton);if(t.length===0)return;let r=new Set(t.map(e=>e.value));if(n=t.filter(e=>!(e.parent&&r.has(e.parent))),n.length===0)throw Error(`There are cyclic diposable chains!`)}if(!n)return;function r(e){function t(e,t){for(;e.length>0&&t.some(t=>typeof t==`string`?t===e[0]:e[0].match(t));)e.shift()}let n=e.source.split(`
|
|
157
|
-
`).map(e=>e.trim().replace(`at `,``)).filter(e=>e!==``);return t(n,[`Error`,/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),n.reverse()}let i=new ZZ;for(let e of n){let t=r(e);for(let n=0;n<=t.length;n++)i.add(t.slice(0,n).join(`
|
|
158
|
-
`),e)}n.sort(qZ(e=>e.idx,JZ));let a=``,o=0;for(let t of n.slice(0,e)){o++;let e=r(t),s=[];for(let t=0;t<e.length;t++){let a=e[t];a=`(shared with ${i.get(e.slice(0,t+1).join(`
|
|
159
|
-
`)).size}/${n.length} leaks) at ${a}`;let o=XZ([...i.get(e.slice(0,t).join(`
|
|
160
|
-
`))].map(e=>r(e)[t]),e=>e);delete o[e[t]];for(let[e,t]of Object.entries(o))s.unshift(` - stacktraces of ${t.length} other leaks continue with ${e}`);s.unshift(a)}a+=`
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
==================== Leaking disposable ${o}/${n.length}: ${t.value.constructor.name} ====================
|
|
164
|
-
${s.join(`
|
|
165
|
-
`)}
|
|
166
|
-
============================================================
|
|
167
|
-
|
|
168
|
-
`}return n.length>e&&(a+=`
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
... and ${n.length-e} more leaking disposables
|
|
172
|
-
|
|
173
|
-
`),{leaks:n,details:a}}};tQ.idx=0;function nQ(e){return eQ?.trackDisposable(e),e}function rQ(e){eQ?.markAsDisposed(e)}function iQ(e,t){eQ?.setParent(e,t)}function aQ(e){return eQ?.markAsSingleton(e),e}function oQ(e){if($Z.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function sQ(...e){return cQ(()=>oQ(e))}function cQ(e){let t=nQ({dispose:QZ(()=>{rQ(t),e()})});return t}var lQ=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,nQ(this)}dispose(){this._isDisposed||(rQ(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{oQ(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return iQ(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),iQ(e,null))}};lQ.DISABLE_DISPOSED_WARNING=!1;var uQ=lQ,dQ=class{constructor(){this._store=new uQ,nQ(this),iQ(this._store,this)}dispose(){rQ(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};dQ.None=Object.freeze({dispose(){}});var fQ=class{constructor(){this._isDisposed=!1,nQ(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&iQ(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,rQ(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&iQ(e,null),e}},pQ=typeof window==`object`?window:globalThis,mQ=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};mQ.Undefined=new mQ(void 0);var hQ=mQ,gQ=class{constructor(){this._first=hQ.Undefined,this._last=hQ.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===hQ.Undefined}clear(){let e=this._first;for(;e!==hQ.Undefined;){let t=e.next;e.prev=hQ.Undefined,e.next=hQ.Undefined,e=t}this._first=hQ.Undefined,this._last=hQ.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new hQ(e);if(this._first===hQ.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==hQ.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==hQ.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==hQ.Undefined&&e.next!==hQ.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===hQ.Undefined&&e.next===hQ.Undefined?(this._first=hQ.Undefined,this._last=hQ.Undefined):e.next===hQ.Undefined?(this._last=this._last.prev,this._last.next=hQ.Undefined):e.prev===hQ.Undefined&&(this._first=this._first.next,this._first.prev=hQ.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==hQ.Undefined;)yield e.element,e=e.next}},_Q=globalThis.performance&&typeof globalThis.performance.now==`function`,vQ=class e{static create(t){return new e(t)}constructor(e){this._now=_Q&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},yQ;(e=>{e.None=()=>dQ.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(sQ(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new Q({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new Q({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Q({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new Q;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Q(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof uQ?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(yQ||={});var bQ=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new vQ,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};bQ.all=new Set,bQ._idPool=0;var xQ=bQ,SQ=-1,CQ=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new EQ(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};CQ._idPool=1;var wQ=CQ,TQ=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
174
|
-
`).slice(2).join(`
|
|
175
|
-
`))}},EQ=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},DQ=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},OQ=0,kQ=class{constructor(e){this.value=e,this.id=OQ++}},AQ=2,jQ,Q=class{constructor(e){this._size=0,this._options=e,this._leakageMon=SQ>0||this._options?.leakWarningThreshold?new wQ(e?.onListenerError??IZ,this._options?.leakWarningThreshold??SQ):void 0,this._perfMon=this._options?._profName?new xQ(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new DQ(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||IZ)(n),dQ.None}if(this._disposed)return dQ.None;t&&(e=e.bind(t));let r=new kQ(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=TQ.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof kQ?(this._deliveryQueue??=new MQ,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=cQ(()=>{jQ?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof uQ?n.add(a):Array.isArray(n)&&n.push(a),jQ){let e=Error().stack.split(`
|
|
176
|
-
`).slice(2,3).join(`
|
|
177
|
-
`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);jQ.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*AQ<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||IZ;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof kQ)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},MQ=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},NQ=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Q,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};NQ.INSTANCE=new NQ;var PQ=NQ;function FQ(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}PQ.INSTANCE.onDidChangeZoomLevel;function IQ(e){return PQ.INSTANCE.getZoomFactor(e)}PQ.INSTANCE.onDidChangeFullscreen;var LQ=typeof navigator==`object`?navigator.userAgent:``,RQ=LQ.indexOf(`Firefox`)>=0,zQ=LQ.indexOf(`AppleWebKit`)>=0,BQ=LQ.indexOf(`Chrome`)>=0,VQ=!BQ&&LQ.indexOf(`Safari`)>=0;LQ.indexOf(`Electron/`),LQ.indexOf(`Android`);var HQ=!1;if(typeof pQ.matchMedia==`function`){let e=pQ.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=pQ.matchMedia(`(display-mode: fullscreen)`);HQ=e.matches,FQ(pQ,e,({matches:e})=>{HQ&&t.matches||(HQ=e)})}function UQ(){return HQ}var WQ=`en`,GQ=!1,KQ=!1,qQ=!1,JQ=!1,YQ=!1,XQ=WQ,ZQ,QQ=globalThis,$Q;typeof QQ.vscode<`u`&&typeof QQ.vscode.process<`u`?$Q=QQ.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&($Q=process);var e$=typeof $Q?.versions?.electron==`string`&&$Q?.type===`renderer`;if(typeof $Q==`object`){GQ=$Q.platform===`win32`,KQ=$Q.platform===`darwin`,qQ=$Q.platform===`linux`,qQ&&$Q.env.SNAP&&$Q.env.SNAP_REVISION,$Q.env.CI||$Q.env.BUILD_ARTIFACTSTAGINGDIRECTORY,XQ=WQ;let e=$Q.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,XQ=t.resolvedLanguage||WQ,t.languagePack?.translationsConfigFile}catch{}JQ=!0}else typeof navigator==`object`&&!e$?(ZQ=navigator.userAgent,GQ=ZQ.indexOf(`Windows`)>=0,KQ=ZQ.indexOf(`Macintosh`)>=0,(ZQ.indexOf(`Macintosh`)>=0||ZQ.indexOf(`iPad`)>=0||ZQ.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,qQ=ZQ.indexOf(`Linux`)>=0,ZQ?.indexOf(`Mobi`),YQ=!0,XQ=globalThis._VSCODE_NLS_LANGUAGE||WQ,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var t$=GQ,n$=KQ,r$=qQ,i$=JQ;YQ&&typeof QQ.importScripts==`function`&&QQ.origin;var a$=ZQ,o$=XQ,s$;(e=>{function t(){return o$}e.value=t;function n(){return o$.length===2?o$===`en`:o$.length>=3&&o$[0]===`e`&&o$[1]===`n`&&o$[2]===`-`}e.isDefaultVariant=n;function r(){return o$===`en`}e.isDefault=r})(s$||={});var c$=typeof QQ.postMessage==`function`&&!QQ.importScripts;(()=>{if(c$){let e=[];QQ.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),QQ.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var l$=!!(a$&&a$.indexOf(`Chrome`)>=0);a$&&a$.indexOf(`Firefox`),!l$&&a$&&a$.indexOf(`Safari`),a$&&a$.indexOf(`Edg/`),a$&&a$.indexOf(`Android`);var u$=typeof navigator==`object`?navigator:{};i$||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||u$&&u$.clipboard&&u$.clipboard.writeText,i$||u$&&u$.clipboard&&u$.clipboard.readText,i$||UQ()||u$.keyboard,`ontouchstart`in pQ||u$.maxTouchPoints,pQ.PointerEvent&&(`ontouchstart`in pQ||navigator.maxTouchPoints);var d$=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},f$=new d$,p$=new d$,m$=new d$,h$=Array(230),g$;(e=>{function t(e){return f$.keyCodeToStr(e)}e.toString=t;function n(e){return f$.strToKeyCode(e)}e.fromString=n;function r(e){return p$.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return m$.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return p$.strToKeyCode(e)||m$.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return f$.keyCodeToStr(e)}e.toElectronAccelerator=o})(g$||={});var _$=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new v$([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},v$=class{constructor(e){if(e.length===0)throw BZ(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function y$(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return g$.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(RQ)switch(t){case 59:return 85;case 60:if(r$)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(n$)return 57;break}else if(zQ&&(n$&&t===93||!n$&&t===92))return 57;return h$[t]||0}var b$=n$?256:2048,x$=512,S$=1024,C$=n$?2048:256,w$=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=y$(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=b$),this.altKey&&(t|=x$),this.shiftKey&&(t|=S$),this.metaKey&&(t|=C$),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new _$(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},T$=new WeakMap;function E$(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var D$=class{static getSameOriginWindowChain(e){let t=T$.get(e);if(!t){t=[],T$.set(e,t);let n=e,r;do r=E$(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},O$=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=D$.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},k$=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(BQ){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)r?this.deltaY=t.wheelDeltaY/(120*i):this.deltaY=t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?RQ&&!n$?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)VQ&&t$?this.deltaX=-(t.wheelDeltaX/120):r?this.deltaX=t.wheelDeltaX/(120*i):this.deltaX=t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?RQ&&!n$?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*i):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},A$=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),j$;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof M$?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:yQ.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:A$})})(j$||={});var M$=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?A$:(this._emitter||=new Q,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},N$=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new HZ(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new HZ(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},P$=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new HZ(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=cQ(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var F$;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(F$||={});var I$=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Q,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await yQ.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};I$.EMPTY=I$.fromArray([]);function L$(e){return 55296<=e&&e<=56319}function R$(e){return 56320<=e&&e<=57343}function z$(e,t){return(e-55296<<10)+(t-56320)+65536}function B$(e){return V$(e,0)}function V$(e,t){switch(typeof e){case`object`:return e===null?H$(349,t):Array.isArray(e)?G$(e,t):K$(e,t);case`string`:return W$(e,t);case`boolean`:return U$(e,t);case`number`:return H$(e,t);case`undefined`:return H$(937,t);default:return H$(617,t)}}function H$(e,t){return(t<<5)-t+e|0}function U$(e,t){return H$(e?433:863,t)}function W$(e,t){t=H$(149417,t);for(let n=0,r=e.length;n<r;n++)t=H$(e.charCodeAt(n),t);return t}function G$(e,t){return t=H$(104579,t),e.reduce((e,t)=>V$(t,e),t)}function K$(e,t){return t=H$(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=W$(n,t),V$(e[n],t)),t)}function q$(e,t,n=32){let r=n-t,i=~((1<<r)-1);return(e<<t|(i&e)>>>r)>>>0}function J$(e,t=0,n=e.byteLength,r=0){for(let i=0;i<n;i++)e[t+i]=r}function Y$(e,t,n=`0`){for(;e.length<t;)e=n+e;return e}function X$(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``):Y$((e>>>0).toString(16),t/4)}var Z$=class e{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(e){let t=e.length;if(t===0)return;let n=this._buff,r=this._buffLen,i=this._leftoverHighSurrogate,a,o;for(i===0?(a=e.charCodeAt(0),o=0):(a=i,o=-1,i=0);;){let s=a;if(L$(a))if(o+1<t){let t=e.charCodeAt(o+1);R$(t)?(o++,s=z$(a,t)):s=65533}else{i=a;break}else R$(a)&&(s=65533);if(r=this._push(n,r,s),o++,o<t)a=e.charCodeAt(o);else break}this._buffLen=r,this._leftoverHighSurrogate=i}_push(e,t,n){return n<128?e[t++]=n:n<2048?(e[t++]=192|(n&1984)>>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),X$(this._h0)+X$(this._h1)+X$(this._h2)+X$(this._h3)+X$(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,J$(this._buff,this._buffLen),this._buffLen>56&&(this._step(),J$(this._buff));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let t=e._bigBlock32,n=this._buffDV;for(let e=0;e<64;e+=4)t.setUint32(e,n.getUint32(e,!1),!1);for(let e=64;e<320;e+=4)t.setUint32(e,q$(t.getUint32(e-12,!1)^t.getUint32(e-32,!1)^t.getUint32(e-56,!1)^t.getUint32(e-64,!1),1),!1);let r=this._h0,i=this._h1,a=this._h2,o=this._h3,s=this._h4,c,l,u;for(let e=0;e<80;e++)e<20?(c=i&a|~i&o,l=1518500249):e<40?(c=i^a^o,l=1859775393):e<60?(c=i&a|i&o|a&o,l=2400959708):(c=i^a^o,l=3395469782),u=q$(r,5)+c+s+l+t.getUint32(e*4,!1)&4294967295,s=o,o=a,a=q$(i,30),i=r,r=u;this._h0=this._h0+r&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+a&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+s&4294967295}};Z$._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:zte,getWindow:Q$,getDocument:Bte,getWindows:Vte,getWindowsCount:Hte,getWindowId:$$,getWindowById:Ute,hasWindow:Wte,onDidRegisterWindow:e1,onWillUnregisterWindow:Gte,onDidUnregisterWindow:Kte}=function(){let e=new Map,t={window:pQ,disposables:new uQ};e.set(pQ.vscodeWindowId,t);let n=new Q,r=new Q,i=new Q;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return dQ.None;let a=new uQ,o={window:t,disposables:a.add(new uQ)};return e.set(t.vscodeWindowId,o),a.add(cQ(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(n1(t,d1.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:pQ},getDocument(e){return Q$(e).document}}}(),t1=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function n1(e,t,n,r){return new t1(e,t,n,r)}function r1(e,t){return function(n){return t(new O$(e,n))}}function i1(e){return function(t){return e(new w$(t))}}var a1=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=r1(Q$(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=i1(n)),n1(e,t,i,r)},o1,s1=class extends P${constructor(e){super(),this.defaultTarget=e&&Q$(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},c1=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){IZ(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(c1.sort),a.shift().execute();r.set(i,!1)};o1=(t,r,a=0)=>{let o=$$(t),s=new c1(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var l1=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};l1.None=new l1(0,0);function u1(e){let t=e.getBoundingClientRect(),n=Q$(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=B$(n),a=r.get(i);if(a)a.users+=1;else{let o=new Q,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(cQ(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var d1={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:zQ?`webkitAnimationStart`:`animationstart`,ANIMATION_END:zQ?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:zQ?`webkitAnimationIteration`:`animationiteration`},f1=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function p1(e,t,n,...r){let i=f1.exec(t);if(!i)throw Error(`Bad use of emmet`);let a=i[1]||`div`,o;return o=e===`http://www.w3.org/1999/xhtml`?document.createElement(a):document.createElementNS(e,a),i[3]&&(o.id=i[3]),i[4]&&(o.className=i[4].replace(/\./g,` `).trim()),n&&Object.entries(n).forEach(([e,t])=>{typeof t>`u`||(/^on\w+$/.test(e)?o[e]=t:e===`selected`?t&&o.setAttribute(e,`true`):o.setAttribute(e,t))}),o.append(...r),o}function m1(e,t,...n){return p1(`http://www.w3.org/1999/xhtml`,e,t,...n)}m1.SVG=function(e,t,...n){return p1(`http://www.w3.org/2000/svg`,e,t,...n)};var h1=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=g1(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=g1(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=g1(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=g1(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=g1(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=g1(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=g1(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=g1(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=g1(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=g1(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=g1(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=g1(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=g1(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=g1(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function g1(e){return typeof e==`number`?`${e}px`:e}function _1(e){return new h1(e)}var v1=class{constructor(){this._hooks=new uQ,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(cQ(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=Q$(e)}this._hooks.add(n1(a,d1.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(n1(a,d1.POINTER_UP,e=>this.stopMonitoring(!0)))}};function y1(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var b1;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(b1||={});var x1=class e extends dQ{constructor(){super(),this.dispatched=!1,this.targets=new gQ,this.ignoreTargets=new gQ,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(yQ.runAndSubscribe(e1,({window:e,disposables:t})=>{t.add(n1(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(n1(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(n1(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:pQ,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=aQ(new e),cQ(e.INSTANCE.targets.push(t))):dQ.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=aQ(new e),cQ(e.INSTANCE.ignoreTargets.push(t))):dQ.None}static isTouchDevice(){return`ontouchstart`in pQ||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(b1.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-GZ(s.rollingPageX))<30&&Math.abs(s.initialPageY-GZ(s.rollingPageY))<30){let e=this.newGestureEvent(b1.Tap,s.initialTarget);e.pageX=GZ(s.rollingPageX),e.pageY=GZ(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-GZ(s.rollingPageX))<30&&Math.abs(s.initialPageY-GZ(s.rollingPageY))<30){let e=this.newGestureEvent(b1.Contextmenu,s.initialTarget);e.pageX=GZ(s.rollingPageX),e.pageY=GZ(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=GZ(s.rollingPageX),n=GZ(s.rollingPageY),i=GZ(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(b1.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===b1.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===b1.Change||t.type===b1.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=o1(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(b1.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(b1.Change,i.initialTarget);a.translationX=r.pageX-GZ(i.rollingPageX),a.translationY=r.pageY-GZ(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};x1.SCROLL_FRICTION=-.005,x1.HOLD_DELAY=700,x1.CLEAR_TAP_COUNT_TIME=400,HX([y1],x1,`isTouchDevice`,1);var S1=x1,C1=class extends dQ{onclick(e,t){this._register(n1(e,d1.CLICK,n=>t(new O$(Q$(e),n))))}onmousedown(e,t){this._register(n1(e,d1.MOUSE_DOWN,n=>t(new O$(Q$(e),n))))}onmouseover(e,t){this._register(n1(e,d1.MOUSE_OVER,n=>t(new O$(Q$(e),n))))}onmouseleave(e,t){this._register(n1(e,d1.MOUSE_LEAVE,n=>t(new O$(Q$(e),n))))}onkeydown(e,t){this._register(n1(e,d1.KEY_DOWN,e=>t(new w$(e))))}onkeyup(e,t){this._register(n1(e,d1.KEY_UP,e=>t(new w$(e))))}oninput(e,t){this._register(n1(e,d1.INPUT,t))}onblur(e,t){this._register(n1(e,d1.BLUR,t))}onfocus(e,t){this._register(n1(e,d1.FOCUS,t))}onchange(e,t){this._register(n1(e,d1.CHANGE,t))}ignoreGesture(e){return S1.ignoreTarget(e)}},w1=11,T1=class extends C1{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=w1+`px`,this.domNode.style.height=w1+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new v1),this._register(a1(this.bgDomNode,d1.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(a1(this.domNode,d1.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new s1),this._pointerdownScheduleRepeatTimer=this._register(new N$)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Q$(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},E1=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},D1=class extends dQ{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new E1(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new j1(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=j1.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},O1=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function k1(e,t){let n=t-e;return function(t){return e+n*N1(t)}}function A1(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var j1=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),A1(k1(e,r),k1(i,t),.33)}return k1(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new O1(this.scrollLeft(t),this.scrollTop(t),!1):new O1(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){r+=10;let i=Date.now()-10;return new e(t,n,i,r)}};function M1(e){return e**3}function N1(e){return 1-M1(1-e)}var P1=class extends dQ{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new N$)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3||this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},F1=140,I1=class extends C1{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new P1(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new v1),this._shouldRender=!0,this.domNode=_1(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(n1(this.domNode.domNode,d1.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new T1(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=_1(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(n1(this.slider.domNode,d1.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=u1(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(t$&&a>F1){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},L1=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize===t?!1:(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize===t?!1:(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition===t?!1:(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},R1=class extends I1{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new L1(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},z1=class extends I1{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new L1(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},B1=500,V1=50,H1=!0,U1=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},W1=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(!0);return t<=.5}acceptStandardWheelEvent(e){if(BQ){let t=IQ(Q$(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new U1(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};W1.INSTANCE=new W1;var G1=W1,K1=class extends C1{constructor(e,t,n){super(),this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Q),this.onWillScroll=this._onWillScroll.event,this._options=J1(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new z1(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new R1(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=_1(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=_1(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=_1(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new N$),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=oQ(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,n$&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new k$(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=oQ(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(n1(this._listenOnDomNode,d1.MOUSE_WHEEL,e=>{this._onMouseWheel(new k$(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=G1.INSTANCE;H1&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!n$&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=V1*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=V1*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(H1&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),B1)}},q1=class extends K1{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function J1(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`&&e.horizontalHasArrows,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,n$&&(t.className+=` mac`),t}var Y1=class extends dQ{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new D1({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>o1(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new q1(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(yQ.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(cQ(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(cQ(()=>this._styleElement.remove())),this._register(yQ.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
|
|
178
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Y1=HX([Z(2,hZ),Z(3,OZ),Z(4,gZ),Z(5,NZ),Z(6,xZ),Z(7,AZ)],Y1);var X1=class extends dQ{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(cQ(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};X1=HX([Z(1,hZ),Z(2,OZ),Z(3,wZ),Z(4,AZ)],X1);var Z1=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Q1={full:0,left:0,center:0,right:0},$1={full:0,left:0,center:0,right:0},e0={full:0,left:0,center:0,right:0},t0=class extends dQ{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new Z1,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(cQ(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);$1.full=this._canvas.width,$1.left=e,$1.center=t,$1.right=e,this._refreshDrawHeightConstants(),e0.full=1,e0.left=1,e0.center=1+$1.left,e0.right=1+$1.left+$1.center}_refreshDrawHeightConstants(){Q1.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Q1.left=t,Q1.center=t,Q1.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Q1.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Q1.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Q1.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Q1.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(e0[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Q1[e.position||`full`]/2),$1[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Q1[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};t0=HX([Z(2,hZ),Z(3,wZ),Z(4,AZ),Z(5,xZ),Z(6,NZ),Z(7,OZ)],t0);var $;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
|
|
179
|
-
`,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))($||={});var n0;(e=>(e.PAD=``,e.HOP=``,e.BPH=``,e.NBH=``,e.IND=``,e.NEL=`
`,e.SSA=``,e.ESA=``,e.HTS=``,e.HTJ=``,e.VTS=``,e.PLD=``,e.PLU=``,e.RI=``,e.SS2=``,e.SS3=``,e.DCS=``,e.PU1=``,e.PU2=``,e.STS=``,e.CCH=``,e.MW=``,e.SPA=``,e.EPA=``,e.SOS=``,e.SGCI=``,e.SCI=``,e.CSI=``,e.ST=``,e.OSC=``,e.PM=``,e.APC=``))(n0||={});var r0;(e=>e.ST=`${$.ESC}\\`)(r0||={});var i0=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${$.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};i0=HX([Z(2,hZ),Z(3,xZ),Z(4,_Z),Z(5,AZ)],i0);var a0=0,o0=0,s0=0,c0=0,l0={css:`#00000000`,rgba:0},u0;(e=>{function t(e,t,n,r){return r===void 0?`#${h0(e)}${h0(t)}${h0(n)}`:`#${h0(e)}${h0(t)}${h0(n)}${h0(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(u0||={});var d0;(e=>{function t(e,t){if(c0=(t.rgba&255)/255,c0===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return a0=a+Math.round((n-a)*c0),o0=o+Math.round((r-o)*c0),s0=s+Math.round((i-s)*c0),{css:u0.toCss(a0,o0,s0),rgba:u0.toRgba(a0,o0,s0)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=m0.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return u0.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[a0,o0,s0]=m0.toChannels(t),{css:u0.toCss(a0,o0,s0),rgba:t}}e.opaque=i;function a(e,t){return c0=Math.round(t*255),[a0,o0,s0]=m0.toChannels(e.rgba),{css:u0.toCss(a0,o0,s0,c0),rgba:u0.toRgba(a0,o0,s0,c0)}}e.opacity=a;function o(e,t){return c0=e.rgba&255,a(e,c0*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(d0||={});var f0;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return a0=parseInt(e.slice(1,2).repeat(2),16),o0=parseInt(e.slice(2,3).repeat(2),16),s0=parseInt(e.slice(3,4).repeat(2),16),u0.toColor(a0,o0,s0);case 5:return a0=parseInt(e.slice(1,2).repeat(2),16),o0=parseInt(e.slice(2,3).repeat(2),16),s0=parseInt(e.slice(3,4).repeat(2),16),c0=parseInt(e.slice(4,5).repeat(2),16),u0.toColor(a0,o0,s0,c0);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return a0=parseInt(r[1]),o0=parseInt(r[2]),s0=parseInt(r[3]),c0=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),u0.toColor(a0,o0,s0,c0);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[a0,o0,s0,c0]=t.getImageData(0,0,1,1).data,c0!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:u0.toRgba(a0,o0,s0,c0),css:e}}e.toColor=r})(f0||={});var p0;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(p0||={});var m0;(e=>{function t(e,t){if(c0=(t&255)/255,c0===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return a0=a+Math.round((n-a)*c0),o0=o+Math.round((r-o)*c0),s0=s+Math.round((i-s)*c0),u0.toRgba(a0,o0,s0)}e.blend=t;function n(e,t,n){let a=p0.relativeLuminance(e>>8),o=p0.relativeLuminance(t>>8);if(g0(a,o)<n){if(o<a){let o=r(e,t,n),s=g0(a,p0.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>g0(a,p0.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=g0(a,p0.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>g0(a,p0.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=g0(p0.relativeLuminance2(o,s,c),p0.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=g0(p0.relativeLuminance2(o,s,c),p0.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=g0(p0.relativeLuminance2(o,s,c),p0.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=g0(p0.relativeLuminance2(o,s,c),p0.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(m0||={});function h0(e){let t=e.toString(16);return t.length<2?`0`+t:t}function g0(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var _0=class extends oZ{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},v0=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new cZ}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||aZ.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)v0._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||aZ.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};v0=HX([Z(0,hZ)],v0);function y0(e){return 57508<=e&&e<=57558}function b0(e){return 9472<=e&&e<=9631}function x0(e){return y0(e)||b0(e)}function S0(){return{css:{canvas:C0(),cell:C0()},device:{canvas:C0(),cell:C0(),char:{width:0,height:0,left:0,top:0}}}}function C0(){return{width:0,height:0}}var w0=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new cZ,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let ee=!1,A=k>=E,j=k,M=this._workCell;if(f.length>0&&k===f[0][0]&&A){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)A&&=i===this._isCellInSelection(v,t);A&&=!n||a<r[0]||a>=r[1],A?(ee=!0,M=new _0(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),j=r[1]-1,m=M.getWidth()):E=r[1]}let N=this._isCellInSelection(k,t),te=n&&k===a,ne=O&&k>=l&&k<=u,re=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{re=!0});let ie=M.getChars()||aZ;if(ie===` `&&(M.isUnderline()||M.isOverline())&&(ie=`\xA0`),T=m*s-c.get(ie,M.isBold(),M.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(N&&w||!N&&!w&&M.bg===y)&&(N&&w&&p.selectionForeground||M.fg===b)&&M.extended.ext===x&&ne===S&&T===C&&!te&&!ee&&!re&&A){M.isInvisible()?_+=aZ:_+=ie,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=M.bg,b=M.fg,x=M.extended.ext,S=ne,C=T,w=N,ee&&a>=k&&a<=j&&(a=k),!this._coreService.isCursorHidden&&te&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`);break;default:break}}if(M.isBold()&&D.push(`xterm-bold`),M.isItalic()&&D.push(`xterm-italic`),M.isDim()&&D.push(`xterm-dim`),_=M.isInvisible()?aZ:M.getChars()||aZ,M.isUnderline()&&(D.push(`xterm-underline-${M.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!M.isUnderlineColorDefault()))if(M.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${oZ.toColorRGB(M.getUnderlineColor()).join(`,`)})`;else{let e=M.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&M.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}M.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),M.isStrikethrough()&&D.push(`xterm-strikethrough`),ne&&(h.style.textDecoration=`underline`);let ae=M.getFgColor(),P=M.getFgColorMode(),oe=M.getBgColor(),se=M.getBgColorMode(),ce=!!M.isInverse();if(ce){let e=ae;ae=oe,oe=e;let t=P;P=se,se=t}let le,ue,de=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&de||(e.backgroundColorRGB&&(se=50331648,oe=e.backgroundColorRGB.rgba>>8&16777215,le=e.backgroundColorRGB),e.foregroundColorRGB&&(P=50331648,ae=e.foregroundColorRGB.rgba>>8&16777215,ue=e.foregroundColorRGB),de=e.options.layer===`top`)}),!de&&N&&(le=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,oe=le.rgba>>8&16777215,se=50331648,de=!0,p.selectionForeground&&(P=50331648,ae=p.selectionForeground.rgba>>8&16777215,ue=p.selectionForeground)),de&&D.push(`xterm-decoration-top`);let fe;switch(se){case 16777216:case 33554432:fe=p.ansi[oe],D.push(`xterm-bg-${oe}`);break;case 50331648:fe=u0.toColor(oe>>16,oe>>8&255,oe&255),this._addStyle(h,`background-color:#${T0((oe>>>0).toString(16),`0`,6)}`);break;default:ce?(fe=p.foreground,D.push(`xterm-bg-257`)):fe=p.background}switch(le||M.isDim()&&(le=d0.multiplyOpacity(fe,.5)),P){case 16777216:case 33554432:M.isBold()&&ae<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ae+=8),this._applyMinimumContrast(h,fe,p.ansi[ae],M,le,void 0)||D.push(`xterm-fg-${ae}`);break;case 50331648:let e=u0.toColor(ae>>16&255,ae>>8&255,ae&255);this._applyMinimumContrast(h,fe,e,M,le,ue)||this._addStyle(h,`color:#${T0(ae.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,fe,p.foreground,M,le,ue)||ce&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!te&&!ee&&!re&&A?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=j}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||x0(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=d0.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};w0=HX([Z(1,MZ),Z(2,xZ),Z(3,OZ),Z(4,_Z),Z(5,wZ),Z(6,NZ)],w0);function T0(e,t,n){for(;e.length<n;)e=t+e;return e}var E0=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},D0=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function O0(){return new D0}var k0=`xterm-dom-renderer-owner-`,A0=`xterm-rows`,j0=`xterm-fg-`,M0=`xterm-bg-`,N0=`xterm-focus`,P0=`xterm-selection`,F0=1,I0=class extends dQ{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=F0++,this._rowElements=[],this._selectionRenderModel=O0(),this.onRequestRedraw=this._register(new Q).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(A0),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(P0),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=S0(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(w0,document),this._element.classList.add(k0+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(cQ(()=>{this._element.classList.remove(k0+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new E0(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${A0} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${A0} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${A0} .xterm-dim { color: ${d0.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${A0}.${N0} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${A0}.${N0} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${A0}.${N0} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${A0} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${A0} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${A0} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${A0} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${A0} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${P0} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${P0} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${P0} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${j0}${n} { color: ${r.css}; }${this._terminalSelector} .${j0}${n}.xterm-dim { color: ${d0.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${M0}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${j0}257 { color: ${d0.opaque(e.background).css}; }${this._terminalSelector} .${j0}257.xterm-dim { color: ${d0.multiplyOpacity(d0.opaque(e.background),.5).css}; }${this._terminalSelector} .${M0}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(N0),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(N0),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${k0}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};I0=HX([Z(7,yZ),Z(8,DZ),Z(9,xZ),Z(10,hZ),Z(11,_Z),Z(12,OZ),Z(13,NZ)],I0);var L0=class extends dQ{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new B0(this._optionsService))}catch{this._measureStrategy=this._register(new z0(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};L0=HX([Z(2,xZ)],L0);var R0=class extends dQ{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},z0=class extends R0{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},B0=class extends R0{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},V0=class extends dQ{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new H0(this._window)),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(yQ.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(n1(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(n1(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},H0=class extends dQ{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new fQ),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(cQ(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=n1(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},U0=class extends dQ{constructor(){super(),this.linkProviders=[],this._register(cQ(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function W0(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function G0(e,t,n,r,i,a,o,s,c){if(!a)return;let l=W0(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var K0=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return G0(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=W0(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};K0=HX([Z(0,AZ),Z(1,DZ)],K0);var q0=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},J0={};VX(J0,{getSafariVersion:()=>t2,isChromeOS:()=>s2,isFirefox:()=>Q0,isIpad:()=>r2,isIphone:()=>i2,isLegacyEdge:()=>$0,isLinux:()=>o2,isMac:()=>n2,isNode:()=>Y0,isSafari:()=>e2,isWindows:()=>a2});var Y0=typeof process<`u`&&`title`in process,X0=Y0?`node`:navigator.userAgent,Z0=Y0?`node`:navigator.platform,Q0=X0.includes(`Firefox`),$0=X0.includes(`Edge`),e2=/^((?!chrome|android).)*safari/i.test(X0);function t2(){if(!e2)return 0;let e=X0.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var n2=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(Z0),r2=Z0===`iPad`,i2=Z0===`iPhone`,a2=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(Z0),o2=Z0.indexOf(`Linux`)>=0,s2=/\bCrOS\b/.test(X0),c2=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},l2=class extends c2{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},u2=class extends c2{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},d2=!Y0&&`requestIdleCallback`in window?u2:l2,f2=class{constructor(){this._queue=new d2}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},p2=class extends dQ{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new fQ),this._pausedResizeTask=new f2,this._observerDisposable=this._register(new fQ),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new q0((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new m2(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(cQ(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=cQ(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};p2=HX([Z(2,xZ),Z(3,DZ),Z(4,_Z),Z(5,wZ),Z(6,hZ),Z(7,OZ),Z(8,NZ)],p2);var m2=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function h2(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return v2(i,a,e,t,n,r)+y2(a,t,n,r)+b2(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,D2(Math.abs(i-e),E2(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return D2(_2(a>t?e:i,n)+(s-1)*n.cols+1+g2(a>t?i:e,n),E2(o,r))}function g2(e,t){return e-1}function _2(e,t){return t.cols-e}function v2(e,t,n,r,i,a){return y2(t,r,i,a).length===0?``:D2(T2(e,t,e,t-S2(t,i),!1,i).length,E2(`D`,a))}function y2(e,t,n,r){let i=e-S2(e,n),a=t-S2(t,n);return D2(Math.abs(i-a)-x2(e,t,n),E2(w2(e,t),r))}function b2(e,t,n,r,i,a){let o;o=y2(t,r,i,a).length>0?r-S2(r,i):t;let s=r,c=C2(e,t,n,r,i,a);return D2(T2(e,o,n,s,c===`C`,i).length,E2(c,a))}function x2(e,t,n){let r=0,i=e-S2(e,n),a=t-S2(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=w2(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function S2(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function C2(e,t,n,r,i,a){let o;return o=y2(n,r,i,a).length>0?r-S2(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function w2(e,t){return e>t?`A`:`B`}function T2(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function E2(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function D2(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var O2=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function k2(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var A2=50,j2=15,M2=50,N2=500,P2=RegExp(`\xA0`,`g`),F2=class extends dQ{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new cZ,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new O2(this._bufferService),this._activeSelectionMode=0,this._register(cQ(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(P2,` `)).join(a2?`\r
|
|
180
|
-
`:`
|
|
181
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),o2&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=k2(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=W0(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-A2),A2),t/=A2,t/Math.abs(t)+Math.round(t*(j2-1)))}shouldForceSelection(e){return n2?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),M2)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(n2&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<N2&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=h2(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(!(!t&&o.slice(s,c).trim()===``)){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=k2(n,this._bufferService.cols)}};F2=HX([Z(3,hZ),Z(4,_Z),Z(5,kZ),Z(6,xZ),Z(7,AZ),Z(8,OZ)],F2);var I2=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},L2=class{constructor(){this._color=new I2,this._css=new I2}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},R2=Object.freeze((()=>{let e=[f0.toColor(`#2e3436`),f0.toColor(`#cc0000`),f0.toColor(`#4e9a06`),f0.toColor(`#c4a000`),f0.toColor(`#3465a4`),f0.toColor(`#75507b`),f0.toColor(`#06989a`),f0.toColor(`#d3d7cf`),f0.toColor(`#555753`),f0.toColor(`#ef2929`),f0.toColor(`#8ae234`),f0.toColor(`#fce94f`),f0.toColor(`#729fcf`),f0.toColor(`#ad7fa8`),f0.toColor(`#34e2e2`),f0.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:u0.toCss(r,i,a),rgba:u0.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:u0.toCss(n,n,n),rgba:u0.toRgba(n,n,n)})}return e})()),z2=f0.toColor(`#ffffff`),B2=f0.toColor(`#000000`),V2=f0.toColor(`#ffffff`),H2=B2,U2={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},W2=z2,G2=class extends dQ{constructor(e){super(),this._optionsService=e,this._contrastCache=new L2,this._halfContrastCache=new L2,this._onChangeColors=this._register(new Q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:z2,background:B2,cursor:V2,cursorAccent:H2,selectionForeground:void 0,selectionBackgroundTransparent:U2,selectionBackgroundOpaque:d0.blend(B2,U2),selectionInactiveBackgroundTransparent:U2,selectionInactiveBackgroundOpaque:d0.blend(B2,U2),scrollbarSliderBackground:d0.opacity(z2,.2),scrollbarSliderHoverBackground:d0.opacity(z2,.4),scrollbarSliderActiveBackground:d0.opacity(z2,.5),overviewRulerBorder:z2,ansi:R2.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=K2(e.foreground,z2),t.background=K2(e.background,B2),t.cursor=d0.blend(t.background,K2(e.cursor,V2)),t.cursorAccent=d0.blend(t.background,K2(e.cursorAccent,H2)),t.selectionBackgroundTransparent=K2(e.selectionBackground,U2),t.selectionBackgroundOpaque=d0.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=K2(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=d0.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?K2(e.selectionForeground,l0):void 0,t.selectionForeground===l0&&(t.selectionForeground=void 0),d0.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=d0.opacity(t.selectionBackgroundTransparent,.3)),d0.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=d0.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=K2(e.scrollbarSliderBackground,d0.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=K2(e.scrollbarSliderHoverBackground,d0.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=K2(e.scrollbarSliderActiveBackground,d0.opacity(t.foreground,.5)),t.overviewRulerBorder=K2(e.overviewRulerBorder,W2),t.ansi=R2.slice(),t.ansi[0]=K2(e.black,R2[0]),t.ansi[1]=K2(e.red,R2[1]),t.ansi[2]=K2(e.green,R2[2]),t.ansi[3]=K2(e.yellow,R2[3]),t.ansi[4]=K2(e.blue,R2[4]),t.ansi[5]=K2(e.magenta,R2[5]),t.ansi[6]=K2(e.cyan,R2[6]),t.ansi[7]=K2(e.white,R2[7]),t.ansi[8]=K2(e.brightBlack,R2[8]),t.ansi[9]=K2(e.brightRed,R2[9]),t.ansi[10]=K2(e.brightGreen,R2[10]),t.ansi[11]=K2(e.brightYellow,R2[11]),t.ansi[12]=K2(e.brightBlue,R2[12]),t.ansi[13]=K2(e.brightMagenta,R2[13]),t.ansi[14]=K2(e.brightCyan,R2[14]),t.ansi[15]=K2(e.brightWhite,R2[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=K2(e.extendedAnsi[r],R2[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};G2=HX([Z(0,xZ)],G2);function K2(e,t){if(e!==void 0)try{return f0.toColor(e)}catch{}return t}var q2=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},J2=class{constructor(){this._services=new q2,this._services.set(yZ,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=fZ(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},Y2={trace:0,debug:1,info:2,warn:3,error:4,off:5},X2=`xterm.js: `,Z2=class extends dQ{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),Q2=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Y2[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:X2)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};Z2=HX([Z(0,xZ)],Z2);var Q2,$2=class extends dQ{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Q),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},e4=3,t4=Object.freeze(new oZ),n4=0,r4=2,i4=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*e4);let r=t||cZ.fromCharData([0,iZ,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*e4+0],n=t&2097151;return[this._data[e*e4+1],t&2097152?this._combined[e]:n?eZ(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*e4+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*e4+0]=e|2097152|t[2]<<22):this._data[e*e4+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*e4+0]>>22}hasWidth(e){return this._data[e*e4+0]&12582912}getFg(e){return this._data[e*e4+1]}getBg(e){return this._data[e*e4+2]}hasContent(e){return this._data[e*e4+0]&4194303}getCodePoint(e){let t=this._data[e*e4+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*e4+0]&2097152}getString(e){let t=this._data[e*e4+0];return t&2097152?this._combined[e]:t&2097151?eZ(t&2097151):``}isProtected(e){return this._data[e*e4+2]&536870912}loadCell(e,t){return n4=e*e4,t.content=this._data[n4+0],t.fg=this._data[n4+1],t.bg=this._data[n4+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*e4+0]=t.content,this._data[e*e4+1]=t.fg,this._data[e*e4+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*e4+0]=t|n<<22,this._data[e*e4+1]=r.fg,this._data[e*e4+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*e4+0];r&2097152?this._combined[e]+=eZ(t):r&2097151?(this._combined[e]=eZ(r&2097151)+eZ(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*e4+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new cZ;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new cZ;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*r4<this._data.buffer.byteLength;let n=e*e4;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*r4<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*r4<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*e4+0]&4194303)return e+(this._data[e*e4+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*e4+0]&4194303||this._data[e*e4+2]&50331648)return e+(this._data[e*e4+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<e4;e++)this._data[(n+i)*e4+e]=a[(t+i)*e4+e];a[(t+i)*e4+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<e4;e++)this._data[(n+i)*e4+e]=a[(t+i)*e4+e];a[(t+i)*e4+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*e4+0],n=e&2097151,a=e&2097152?this._combined[t]:n?eZ(n):aZ;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function a4(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=l4(u,d,t),p=1,m=0;for(;p<u.length;){let e=l4(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function o4(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function s4(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function c4(e,t,n){let r=[],i=e.map((n,r)=>l4(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=l4(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function l4(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var u4=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),oQ(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};u4._nextId=1;var d4=u4,f4={},p4=f4.B;f4[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:``,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},f4.A={"#":`£`},f4.B=void 0,f4[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},f4.C=f4[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},f4.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},f4.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},f4.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},f4.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},f4.E=f4[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},f4.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},f4.H=f4[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},f4[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var m4=4294967295,h4=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=t4.clone(),this.savedCharset=p4,this.markers=[],this._nullCell=cZ.fromCharData([0,iZ,1,0]),this._whitespaceCell=cZ.fromCharData([0,aZ,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new d2,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new $2(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new sZ),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new sZ),this._whitespaceCell}getBlankLine(e,t){return new i4(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>m4?m4:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=t4);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new $2(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(t4),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new i4(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new i4(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=a4(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(t4),n);if(r.length>0){let n=o4(this.lines,r);s4(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(t4),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new i4(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(t4),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=c4(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(t4,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=l4(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new d4(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},g4=class extends dQ{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Q),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new h4(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new h4(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},_4=2,v4=1,y4=class extends dQ{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,_4),this.rows=Math.max(e.rawOptions.rows||0,v4),this.buffers=this._register(new g4(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};y4=HX([Z(0,xZ)],y4);var b4={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:n2,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},x4=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],S4=class extends dQ{constructor(e){super(),this._onOptionChange=this._register(new Q),this.onOptionChange=this._onOptionChange.event;let t={...b4};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(cQ(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in b4))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in b4))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=b4[e],!C4(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=b4[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=x4.includes(t)?t:b4[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={};break}return t}};function C4(e){return e===`block`||e===`underline`||e===`bar`}function w4(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&w4(e[r],t-1);return n}var T4=Object.freeze({insertMode:!1}),E4=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),D4=class extends dQ{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Q),this.onData=this._onData.event,this._onUserInput=this._register(new Q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=w4(T4),this.decPrivateModes=w4(E4)}reset(){this.modes=w4(T4),this.decPrivateModes=w4(E4)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};D4=HX([Z(0,hZ),Z(1,bZ),Z(2,xZ)],D4);var O4={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function k4(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var A4=String.fromCharCode,j4={DEFAULT:e=>{let t=[k4(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${A4(t[0])}${A4(t[1])}${A4(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${k4(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${k4(e,!0)};${e.x};${e.y}${t}`}},M4=class extends dQ{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Q),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(O4))this.addProtocol(e,O4[e]);for(let e of Object.keys(j4))this.addEncoding(e,j4[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};M4=HX([Z(0,hZ),Z(1,_Z),Z(2,xZ)],M4);var N4=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],P4=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],F4;function I4(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var L4=class{constructor(){if(this.version=`6`,!F4){F4=new Uint8Array(65536),F4.fill(1),F4[0]=0,F4.fill(0,1,32),F4.fill(0,127,160),F4.fill(2,4352,4448),F4[9001]=2,F4[9002]=2,F4.fill(2,11904,42192),F4[12351]=1,F4.fill(2,44032,55204),F4.fill(2,63744,64256),F4.fill(2,65040,65050),F4.fill(2,65072,65136),F4.fill(2,65280,65377),F4.fill(2,65504,65511);for(let e=0;e<N4.length;++e)F4.fill(0,N4[e][0],N4[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?F4[e]:I4(e,P4)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=R4.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return R4.createPropertyValue(0,n,r)}},R4=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Q,this.onChange=this._onChange.event;let e=new L4;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},z4=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function B4(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var V4=2147483647,H4=256,U4=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>H4)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>V4?V4:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>V4?V4:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,V4):e}},W4=[],G4=class{constructor(){this._state=0,this._active=W4,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=W4}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=W4,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||W4,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,tZ(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=W4,this._id=-1,this._state=0}}},K4=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=tZ(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},q4=[],J4=class{constructor(){this._handlers=Object.create(null),this._active=q4,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=q4}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=q4,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||q4,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,tZ(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=q4,this._ident=0}},Y4=new U4;Y4.addParam(0);var X4=class{constructor(e){this._handler=e,this._data=``,this._params=Y4,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Y4,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=tZ(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=Y4,this._data=``,this._hitLimit=!1,e));return this._params=Y4,this._data=``,this._hitLimit=!1,t}},Z4=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},Q4=160,$4=function(){let e=new Z4(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Q4,0,2,0),e.add(Q4,8,5,8),e.add(Q4,6,0,6),e.add(Q4,11,0,11),e.add(Q4,13,13,13),e}(),e3=class extends dQ{constructor(e=$4){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new U4,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(cQ(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new G4),this._dcsParser=this._register(new J4),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:Q4)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<Q4){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<Q4){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<Q4){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<Q4){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<Q4){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<Q4){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},t3=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,n3=/^[\da-f]+$/;function r3(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=t3.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),n3.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function i3(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function a3(e,t=16){let[n,r,i]=e;return`rgb:${i3(n,t)}/${i3(r,t)}/${i3(i,t)}`}var o3={"(":0,")":1,"*":2,"+":3,"-":1,".":2},s3=131072,c3=10;function l3(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var u3=5e3,d3=0,f3=class extends dQ{constructor(e,t,n,r,i,a,o,s,c=new e3){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new nZ,this._utf8Decoder=new rZ,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=t4.clone(),this._eraseAttrDataInternal=t4.clone(),this._onRequestBell=this._register(new Q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Q),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new p3(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(n0.IND,()=>this.index()),this._parser.setExecuteHandler(n0.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(n0.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new K4(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new K4(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new K4(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new K4(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new K4(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new K4(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new K4(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new K4(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new K4(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new K4(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new K4(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new K4(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in f4)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new X4((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),u3))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${u3} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>s3&&(a=this._parseStack.position+s3)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<s3&&(this._parseBuffer=new Uint32Array(Math.min(e.length,s3))),o||this._dirtyRowTracker.clearRange(),e.length>s3)for(let t=a;t<e.length;t+=s3){let a=t+s3<e.length?t+s3:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=R4.extractWidth(t);let n=R4.extractShouldJoin(t),m=n?R4.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(eZ(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof i4&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!l3(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new X4(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new K4(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(t4));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=R4.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,p4),this._charsetService.setgCharset(1,p4),this._charsetService.setgCharset(2,p4),this._charsetService.setgCharset(3,p4);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=oZ.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=t4.fg,e.bg=t4.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=t4.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=t4.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=t4.fg&16777215,r.bg&=-67108864,r.bg|=t4.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=t4.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`;break}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!l3(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>c3&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>c3&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(m3(n))if(r===`?`)t.push({type:0,index:n});else{let e=r3(r);e&&t.push({type:1,index:n,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=r3(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);m3(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,p4),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(o3[e[0]],f4[e[1]]||p4),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=t4.clone(),this._eraseAttrDataInternal=t4.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new cZ;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},p3=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(d3=e,e=t,t=d3),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};p3=HX([Z(0,hZ)],p3);function m3(e){return 0<=e&&e<256}var h3=5e7,g3=12,_3=50,v3=class extends dQ{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>h3)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=g3?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=g3)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>_3&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},y3=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};y3=HX([Z(0,hZ)],y3);var b3=!1,x3=class extends dQ{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new fQ),this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onData=this._register(new Q),this.onData=this._onData.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Q),this._instantiationService=new J2,this.optionsService=this._register(new S4(e)),this._instantiationService.setService(xZ,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(y4)),this._instantiationService.setService(hZ,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Z2)),this._instantiationService.setService(bZ,this._logService),this.coreService=this._register(this._instantiationService.createInstance(D4)),this._instantiationService.setService(_Z,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(M4)),this._instantiationService.setService(gZ,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(R4)),this._instantiationService.setService(CZ,this.unicodeService),this._charsetService=this._instantiationService.createInstance(z4),this._instantiationService.setService(vZ,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(y3),this._instantiationService.setService(SZ,this._oscLinkService),this._inputHandler=this._register(new f3(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(yQ.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(yQ.forward(this._bufferService.onResize,this._onResize)),this._register(yQ.forward(this.coreService.onData,this._onData)),this._register(yQ.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new v3((e,t)=>this._inputHandler.parse(e,t))),this._register(yQ.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Q),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!b3&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),b3=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,_4),t=Math.max(t,v4),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(B4.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(B4(this._bufferService),!1))),this._windowsWrappingHeuristics.value=cQ(()=>{for(let t of e)t.dispose()})}}},S3={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function C3(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?t?i.key=$.ESC+`OA`:i.key=$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?t?i.key=$.ESC+`OD`:i.key=$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?t?i.key=$.ESC+`OC`:i.key=$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(t?i.key=$.ESC+`OB`:i.key=$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`D`:t?i.key=$.ESC+`OD`:i.key=$.ESC+`[D`;break;case 39:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`C`:t?i.key=$.ESC+`OC`:i.key=$.ESC+`[C`;break;case 38:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`A`:t?i.key=$.ESC+`OA`:i.key=$.ESC+`[A`;break;case 40:if(e.metaKey)break;a?i.key=$.ESC+`[1;`+(a+1)+`B`:t?i.key=$.ESC+`OB`:i.key=$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:a?i.key=$.ESC+`[3;`+(a+1)+`~`:i.key=$.ESC+`[3~`;break;case 36:a?i.key=$.ESC+`[1;`+(a+1)+`H`:t?i.key=$.ESC+`OH`:i.key=$.ESC+`[H`;break;case 35:a?i.key=$.ESC+`[1;`+(a+1)+`F`:t?i.key=$.ESC+`OF`:i.key=$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=$.ESC+`[5;`+(a+1)+`~`:i.key=$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=$.ESC+`[6;`+(a+1)+`~`:i.key=$.ESC+`[6~`;break;case 112:a?i.key=$.ESC+`[1;`+(a+1)+`P`:i.key=$.ESC+`OP`;break;case 113:a?i.key=$.ESC+`[1;`+(a+1)+`Q`:i.key=$.ESC+`OQ`;break;case 114:a?i.key=$.ESC+`[1;`+(a+1)+`R`:i.key=$.ESC+`OR`;break;case 115:a?i.key=$.ESC+`[1;`+(a+1)+`S`:i.key=$.ESC+`OS`;break;case 116:a?i.key=$.ESC+`[15;`+(a+1)+`~`:i.key=$.ESC+`[15~`;break;case 117:a?i.key=$.ESC+`[17;`+(a+1)+`~`:i.key=$.ESC+`[17~`;break;case 118:a?i.key=$.ESC+`[18;`+(a+1)+`~`:i.key=$.ESC+`[18~`;break;case 119:a?i.key=$.ESC+`[19;`+(a+1)+`~`:i.key=$.ESC+`[19~`;break;case 120:a?i.key=$.ESC+`[20;`+(a+1)+`~`:i.key=$.ESC+`[20~`;break;case 121:a?i.key=$.ESC+`[21;`+(a+1)+`~`:i.key=$.ESC+`[21~`;break;case 122:a?i.key=$.ESC+`[23;`+(a+1)+`~`:i.key=$.ESC+`[23~`;break;case 123:a?i.key=$.ESC+`[24;`+(a+1)+`~`:i.key=$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=S3[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL));break}return i}var w3=0,T3=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new d2,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new d2,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(w3=this._search(t),w3===-1)||this._getKey(this._array[w3])!==t)return!1;do if(this._array[w3]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(w3),!0;while(++w3<this._array.length&&this._getKey(this._array[w3])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(w3=this._search(e),!(w3<0||w3>=this._array.length)&&this._getKey(this._array[w3])===e))do yield this._array[w3];while(++w3<this._array.length&&this._getKey(this._array[w3])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(w3=this._search(e),!(w3<0||w3>=this._array.length)&&this._getKey(this._array[w3])===e))do t(this._array[w3]);while(++w3<this._array.length&&this._getKey(this._array[w3])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},E3=0,D3=0,O3=class extends dQ{constructor(){super(),this._decorations=new T3(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(cQ(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new k3(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{E3=t.options.x??0,D3=E3+(t.options.width??1),e>=E3&&e<D3&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},k3=class extends uQ{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Q),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=f0.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=f0.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},A3=1e3,j3=class{constructor(e,t=A3){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},M3=20,N3=class extends dQ{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new j3(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
182
|
-
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(n1(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(cQ(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<M3+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
183
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===M3+1&&(this._liveRegion.textContent+=KX.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};N3=HX([Z(1,yZ),Z(2,OZ),Z(3,AZ)],N3);var P3=class extends dQ{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(cQ(()=>{oQ(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(n1(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(n1(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(n1(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(n1(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&F3(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,oQ(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};P3=HX([Z(1,kZ),Z(2,AZ),Z(3,hZ),Z(4,PZ)],P3);function F3(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var I3=class extends x3{constructor(e={}){super(e),this._linkifier=this._register(new fQ),this.browser=J0,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new fQ),this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Q),this.onKey=this._onKey.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Q),this.onBell=this._onBell.event,this._onFocus=this._register(new Q),this._onBlur=this._register(new Q),this._onA11yCharEmitter=this._register(new Q),this._onA11yTabEmitter=this._register(new Q),this._onWillOpen=this._register(new Q),this._setup(),this._decorationService=this._instantiationService.createInstance(O3),this._instantiationService.setService(wZ,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(U0),this._instantiationService.setService(PZ,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(TZ)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(yQ.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(yQ.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(yQ.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(yQ.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(cQ(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=d0.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${a3(r)}${r0.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=u0.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=u0.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(N3,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(n1(this.element,`copy`,e=>{this.hasSelection()&&YX(e,this._selectionService)}));let e=e=>XX(e,this.textarea,this.coreService,this.optionsService);this._register(n1(this.textarea,`paste`,e)),this._register(n1(this.element,`paste`,e)),Q0?this._register(n1(this.element,`mousedown`,e=>{e.button===2&&$X(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(n1(this.element,`contextmenu`,e=>{$X(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),o2&&this._register(n1(this.element,`auxclick`,e=>{e.button===1&&QX(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(n1(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(n1(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(n1(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(n1(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(n1(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(n1(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(n1(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(n1(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,WX.get()),s2||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(V0,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(OZ,this._coreBrowserService),this._register(n1(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(n1(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(L0,this._document,this._helperContainer),this._instantiationService.setService(DZ,this._charSizeService),this._themeService=this._instantiationService.createInstance(G2),this._instantiationService.setService(NZ,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(v0),this._instantiationService.setService(MZ,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(p2,this.rows,this.screenElement)),this._instantiationService.setService(AZ,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(i0,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(K0),this._instantiationService.setService(kZ,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(P3,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Y1,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(F2,this.element,this.screenElement,r)),this._instantiationService.setService(jZ,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(yQ.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(X1,this.screenElement)),this._register(n1(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(N3,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(t0,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(t0,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(I0,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(n1(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(n1(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){ZX(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=C3(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(L3(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(t4));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function L3(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var R3=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},z3=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new cZ)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},B3=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new z3(t)}getNullCell(){return new cZ}},V3=class extends dQ{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Q),this.onBufferChange=this._onBufferChange.event,this._normal=new B3(this._core.buffers.normal,`normal`),this._alternate=new B3(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},H3=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},U3=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},W3=[`cols`,`rows`],G3=0,K3=class extends dQ{constructor(e){super(),this._core=this._register(new I3(e)),this._addonManager=this._register(new R3),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(W3.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new H3(this._core),this._parser}get unicode(){return this._checkProposedApi(),new U3(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new V3(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`;break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
184
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return WX.get()},set promptLabel(e){WX.set(e)},get tooMuchOutput(){return KX.get()},set tooMuchOutput(e){KX.set(e)}}}_verifyIntegers(...e){for(G3 of e)if(G3===1/0||isNaN(G3)||G3%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(G3 of e)if(G3&&(G3===1/0||isNaN(G3)||G3%1!=0||G3<0))throw Error(`This API only accepts positive integers`)}},q3=250,J3=5e3,Y3=8e3,X3=3e3;function Z3(e){return`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}`}function Q3(){return Z3(window.location)}var $3=class{opts;ws=null;backoff=q3;reconnectTimer=null;connectTimer=null;stallTimer=null;disposed=!1;ended=!1;receivedData=!1;url;constructor(e){this.opts=e;let t=e.wsBase??Q3();this.url=`${t.replace(/\/$/,``)}/ws/terminal/${encodeURIComponent(e.sessionId)}`}connect(){if(this.disposed||this.ended)return;this.clearTimer(),this.opts.onStatus(this.backoff===q3?`connecting`:`reconnecting`);let e=new WebSocket(this.url);e.binaryType=`arraybuffer`,this.ws=e,this.connectTimer=setTimeout(()=>{e.readyState===WebSocket.CONNECTING&&this.forceClose(e)},Y3),e.onopen=()=>{this.clearConnectTimer(),this.receivedData&&(this.receivedData=!1,this.opts.onReset?.())},e.onmessage=e=>{typeof e.data==`string`?this.handleControl(e.data):(this.receivedData=!0,this.opts.onData(new Uint8Array(e.data)))},e.onclose=()=>{this.ws=null,this.clearConnectTimer(),this.clearStallTimer(),!(this.disposed||this.ended)&&(this.opts.onStatus(`reconnecting`),this.scheduleReconnect())},e.onerror=()=>{this.forceClose(e)}}send(e){this.ws&&this.ws.readyState===WebSocket.OPEN&&(this.ws.send(new TextEncoder().encode(e)),this.watchForStall())}resize(e,t){this.ws&&this.ws.readyState===WebSocket.OPEN&&(this.ws.send(JSON.stringify({t:`resize`,cols:e,rows:t})),this.watchForStall())}dispose(){if(this.disposed=!0,this.clearTimer(),this.clearConnectTimer(),this.clearStallTimer(),this.ws){this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.onmessage=null;try{this.ws.close()}catch{}this.ws=null}}handleControl(e){let t;try{t=JSON.parse(e)}catch{return}t.t===`status`&&(t.status===`live`?(this.backoff=q3,this.opts.onStatus(`live`)):t.status===`ended`&&(this.ended=!0,this.opts.onStatus(`ended`)))}watchForStall(){this.stallTimer===null&&(this.stallTimer=setTimeout(()=>{this.stallTimer=null;let e=this.ws;!e||e.readyState!==WebSocket.OPEN||e.bufferedAmount>0&&this.forceClose(e)},X3))}forceClose(e){try{e.close()}catch{}if(this.ws===e&&e.readyState===WebSocket.CLOSED){if(e.onclose=null,this.ws=null,this.disposed||this.ended)return;this.opts.onStatus(`reconnecting`),this.scheduleReconnect()}}scheduleReconnect(){this.clearTimer();let e=this.backoff;this.backoff=Math.min(this.backoff*2,J3),this.reconnectTimer=setTimeout(()=>this.connect(),e)}clearTimer(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}clearConnectTimer(){this.connectTimer!==null&&(clearTimeout(this.connectTimer),this.connectTimer=null)}clearStallTimer(){this.stallTimer!==null&&(clearTimeout(this.stallTimer),this.stallTimer=null)}},e6={dark:{"--color-surface-inset":`#0c0e14`,"--color-text":`#eceef4`,"--color-accent":`#4f8ef7`,"--color-accent-subtle":`#16213a`,"--color-border-strong":`#333a4d`,"--color-danger-text":`#f06363`,"--color-success-text":`#46b67a`,"--color-warning-text":`#e2a53b`,"--color-accent-text":`#7aaafa`},light:{"--color-surface-inset":`#f4f6f9`,"--color-text":`#161a24`,"--color-accent":`#3a7ef0`,"--color-accent-subtle":`#ecf2fe`,"--color-border-strong":`#cdd2de`,"--color-danger-text":`#c42828`,"--color-success-text":`#137745`,"--color-warning-text":`#9c5600`,"--color-accent-text":`#2361d4`}},t6={dark:`--color-accent`,light:`--color-accent-text`},n6={dark:{black:`#2a2a2f`,magenta:`#c68af0`,cyan:`#56c2d6`,white:`#d4d4d8`,brightBlack:`#6b6b74`,brightRed:`#ff8a8a`,brightGreen:`#72d49c`,brightYellow:`#f2c46e`,brightMagenta:`#d9a9f7`,brightCyan:`#86dbe8`,brightWhite:`#fafafa`},light:{black:`#18181b`,magenta:`#9337be`,cyan:`#0e7488`,white:`#52525b`,brightBlack:`#71717a`,brightRed:`#d63a3a`,brightGreen:`#1f9a5a`,brightYellow:`#b57308`,brightMagenta:`#a64ccf`,brightCyan:`#128399`,brightWhite:`#27272a`}};function r6(e){let t=typeof document>`u`?null:getComputedStyle(document.documentElement);return n=>t?.getPropertyValue(n).trim()||e6[e][n]||``}function i6(e,t=r6(e)){let n=t(`--color-surface-inset`);return{background:n,foreground:t(`--color-text`),cursor:t(`--color-accent`),cursorAccent:n,selectionBackground:t(`--color-accent-subtle`),selectionInactiveBackground:t(`--color-border-strong`),red:t(`--color-danger-text`),green:t(`--color-success-text`),yellow:t(`--color-warning-text`),blue:t(t6[e]),brightBlue:t(`--color-accent-text`),...n6[e]}}function a6(e){return e.key===`v`||e.key===`V`||e.code===`KeyV`}function o6(e){let t=e.type===`keydown`;if(!t&&e.type!==`keypress`)return{intercept:!1};if(e.key===`Enter`&&(e.shiftKey||e.ctrlKey))return{intercept:!0,bytes:t?`\x1B\r`:``};if(ox(e))return{intercept:!0,bytes:``};if(a6(e)&&!e.shiftKey&&!e.metaKey){if(e.ctrlKey&&!e.altKey)return{intercept:!0,bytes:``};if(e.altKey&&!e.ctrlKey)return{intercept:!0,bytes:t?`\x1Bv`:``}}return{intercept:!1}}var s6=`"Geist Mono Variable", "Cascadia Code", Consolas, monospace`;function c6({sessionId:e,wsBase:t,onEnded:n}){let r=(0,F.useRef)(null),[i,a]=(0,F.useState)(`connecting`),o=(0,F.useRef)(n);o.current=n;let{resolved:s}=uF(),c=(0,F.useRef)(s);c.current=s;let l=(0,F.useRef)(null);(0,F.useEffect)(()=>{let e=l.current;e&&(e.options.theme=i6(s))},[s]),(0,F.useEffect)(()=>{let n=r.current;if(!n)return;let i=new K3({theme:i6(c.current),fontFamily:s6,fontSize:12.5,lineHeight:1.2,cursorBlink:!0,allowProposedApi:!0,scrollback:5e3});l.current=i;let s=new RX;i.loadAddon(s),i.open(n);let u=()=>n.clientWidth>0&&n.clientHeight>0,d=()=>{if(u())try{s.fit()}catch{}};d();let f=requestAnimationFrame(d),p=!1;typeof document<`u`&&document.fonts?.check?.(`12px ${s6}`)||document.fonts?.load(`12px ${s6}`).then(()=>{p||(i.options.fontFamily=`monospace`,i.options.fontFamily=s6,d())});let m;m=new $3({sessionId:e,wsBase:t,onData:e=>i.write(e),onReset:()=>i.reset(),onStatus:e=>{a(e),e===`live`&&u()&&m.resize(i.cols,i.rows),e===`ended`&&o.current?.()}});let h=i.onData(e=>m.send(e)),g=i.onResize(({cols:e,rows:t})=>m.resize(e,t));i.attachCustomKeyEventHandler(e=>{let t=o6(e);return t.intercept?(t.bytes&&m.send(t.bytes),!1):!0}),m.connect();let _=new ResizeObserver(()=>d());return _.observe(n),()=>{p=!0,l.current=null,cancelAnimationFrame(f),_.disconnect(),h.dispose(),g.dispose(),m.dispose(),i.dispose()}},[e,t]);let u=i===`connecting`?{text:`Connecting…`,tone:`dim`}:i===`reconnecting`?{text:`Disconnected — reconnecting… keystrokes are dropped until the stream is back`,tone:`down`}:i===`ended`?{text:`Session stream ended — relaunch or end the session above`,tone:`dim`}:null;return(0,I.jsxs)(`div`,{className:q(`relative box-border h-full w-full overflow-hidden bg-surface-inset pt-2 pr-0.5 pb-1.5 pl-2.5`,`[&_.xterm-viewport]:bg-transparent!`),children:[(0,I.jsx)(`div`,{ref:r,className:`h-full w-full`,"data-session-id":e}),u&&(0,I.jsx)(`div`,{role:`status`,className:q(`pointer-events-none absolute inset-x-0 top-0 px-2.5 py-1 text-xs animate-fade-in`,u.tone===`down`?`bg-danger-subtle text-danger-text`:`border-b border-border-subtle bg-surface-inset text-text-tertiary`),children:u.text})]})}var l6=new Map,u6=new Map;function d6(e){return`feature:${e}:main`}function f6(e,t){if(t.length!==0){l6.set(e,[...l6.get(e)??[],...t]);for(let t of[...u6.get(e)??[]])t()}}function p6(e){let t=l6.get(e)??[];return l6.delete(e),t}function m6(e,t){let n=u6.get(e)??new Set;return n.add(t),u6.set(e,n),()=>{n.delete(t),n.size===0&&u6.delete(e)}}var h6=6e4;function g6(e,t){return t?`${e.replace(/\/+$/,``)}${t}`:e}function _6(e,t,n=!0){let r=R.design.status.useQuery({featureId:e},{enabled:n&&!t});return t??r.data?.lastPath}function v6(e,t){let n=rx(),r=R.useUtils(),i=R.design.status.useQuery({featureId:e},{refetchInterval:tg()}),a=R.design.start.useMutation({onError:e=>n.push(e.message),onSettled:()=>r.design.status.invalidate({featureId:e})}),{mutate:o}=R.design.heartbeat.useMutation(),{mutate:s}=R.design.showPath.useMutation({onSuccess:()=>r.design.status.invalidate({featureId:e})}),c=R.design.restart.useMutation({onError:e=>n.push(e.message),onSettled:()=>r.design.status.invalidate({featureId:e})}),{mutate:l}=a,{mutate:u}=c,d=t??i.data?.lastPath;(0,F.useEffect)(()=>{t&&s({featureId:e,path:t})},[t,e,s]);let f=i.data?.running===!0,p=i.data?.hasRecordedCommand===!0,[m,h]=(0,F.useState)(!1),g=i.data!==void 0;return(0,F.useEffect)(()=>{f&&h(!0)},[f]),(0,F.useEffect)(()=>{!g||f||m||!p||(h(!0),l({featureId:e}))},[g,f,m,p,l,e]),(0,F.useEffect)(()=>{if(!f)return;let t=()=>{document.visibilityState===`visible`&&o({featureId:e})};t();let n=setInterval(t,h6);return()=>clearInterval(n)},[f,o,e]),{status:i.data,url:f?i.data?.url:void 0,shownPath:d,seen:m,start:a,restart:c,startServer:()=>l({featureId:e}),restartServer:t=>u({featureId:e},t?{onSuccess:t}:{})}}function y6({featureId:e,path:t,width:n}){let r=v6(e,t),{shownPath:i}=r,[a,o]=(0,F.useState)(0),s=()=>o(e=>e+1),[c,l]=(0,F.useState)(!1),u=()=>r.restartServer(s);if(r.url){let t=r.status?.paneId,o=(0,I.jsxs)(mN,{children:[(0,I.jsx)(hN,{asChild:!0,children:(0,I.jsx)(Y,{label:`Design server`,icon:(0,I.jsx)(Gy,{}),tooltipSide:`bottom`})}),(0,I.jsxs)(gN,{align:`end`,children:[(0,I.jsx)(_N,{icon:(0,I.jsx)(Db,{}),onSelect:u,children:`Restart server`}),t&&(0,I.jsx)(_N,{icon:(0,I.jsx)(Ky,{}),onSelect:()=>l(e=>!e),children:c?`Hide output`:`Show output`})]})]});return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,I.jsx)(FX,{copy:`chat`,onCapture:t=>f6(d6(e),[new File([t],`selection.png`,{type:`image/png`})]),frameKey:String(a),url:g6(r.url,i),leading:(0,I.jsx)(Y,{label:`Back to ${i??`/`}`,icon:(0,I.jsx)(wb,{}),tooltipSide:`bottom`,onClick:s}),trailing:o,...n===void 0?{}:{width:n}}),c&&t&&(0,I.jsx)(`div`,{className:`relative h-60 min-h-40 shrink-0 overflow-hidden border-t border-border-subtle bg-surface-inset animate-rise-in`,children:(0,I.jsx)(oq,{label:`design server output`,children:(0,I.jsx)(c6,{sessionId:t})})})]})}return(0,I.jsx)(b6,{server:r,onRestart:u})}function b6({server:e,onRestart:t}){let{status:n,start:r,restart:i,seen:a,startServer:o}=e;if(!n||r.isPending||i.isPending){let e=r.isPending||i.isPending;return(0,I.jsxs)(`div`,{className:`flex items-center justify-center gap-2 px-6 py-12`,children:[e&&(0,I.jsx)(UE,{size:`sm`}),(0,I.jsx)(YN,{children:e?`Starting the design server…`:`Looking for the design server…`})]})}let{hasRecordedCommand:s,lastError:c}=n,l=s?(0,I.jsx)(J,{onClick:o,children:`Start it again`}):void 0;return c!==void 0&&!r.isError?(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-16`,children:[(0,I.jsx)(XN,{className:`py-0`,icon:(0,I.jsx)(Lb,{}),title:`The design server stopped`,hint:`It exited on its own. What it printed last:`,action:s?(0,I.jsx)(J,{onClick:t,children:`Restart server`}):void 0}),(0,I.jsx)(`pre`,{className:`m-0 max-h-60 w-full max-w-160 overflow-auto rounded-md bg-surface-inset px-3 py-2.5 font-mono text-xs whitespace-pre-wrap text-text-secondary`,children:c})]}):r.isError?(0,I.jsx)(XN,{className:`py-16`,icon:(0,I.jsx)(Lb,{}),title:`The design server didn’t start`,hint:r.error.message,action:l}):a?(0,I.jsx)(XN,{className:`py-16`,icon:(0,I.jsx)(Lb,{}),title:`The design server stopped`,hint:`It stops after 30 minutes out of sight, or when the chat ends.`,action:l}):(0,I.jsx)(XN,{className:`py-16`,icon:(0,I.jsx)(Lb,{}),title:`No design server yet`,hint:`Ask the chat to show you a design. It starts the server.`})}var x6=140,S6=64;function C6(e){return e.replace(/```[^\n]*\n?/g,``).replace(/^\s{0,3}#{1,6}\s+/gm,``).replace(/^\s{0,3}>\s?/gm,``).replace(/^\s*[-*+]\s+/gm,``).replace(/^\s*\d+\.\s+/gm,``).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/(\*\*|__)(.+?)\1/g,`$2`).replace(/~~(.+?)~~/g,`$1`).replace(/(^|[\s(])[*_](\S(?:.*?\S)?)[*_]($|[\s.,;:)!?])/g,`$1$2$3`).replace(/`([^`]+)`/g,`$1`).trim()}function w6(e){for(let t of e.split(`
|
|
185
|
-
`)){let e=t.trim();if(e!==``)return e}return``}function T6(e,t){return e.length>t?`${e.slice(0,t-1).trimEnd()}…`:e}function E6(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.name!=`string`||t.name===``?null:{name:t.name,args:typeof t.args==`string`?t.args:``}}function D6(e){return e.endsWith(`.tool`)}function O6(e){let t=e.replace(/[._]+/g,` `).trim();return t===``?``:`${t[0].toUpperCase()}${t.slice(1)}`}function k6(e,t){if(!t.startsWith(e))return null;let n=t.slice(e.length).replace(/^[\s:;,—–-]+/,``).trim().replace(/^\((.*)\)$/s,`$1`).trim(),r=O6(e);return n===``?r:`${r} — ${n}`}function A6(e){return typeof e==`object`&&e?e:null}function j6(e){return typeof e==`string`&&e!==``?e:null}function M6(e){if(e.type!==`session.self_plan_ended`)return null;let t=A6(e.data)?.complete;return typeof t==`boolean`?t:null}var N6={"session.self_plan_ended":`self-planning run`};function P6(e){return N6[e]??e.replace(/_/g,` `).replace(`.`,` · `)}function F6(e){let t=M6(e);if(t!==null)return t?`Planned without you — the plan is finished`:`Planning without you stopped before the plan was complete`;if(e.type!==`feature.created`)return null;let n=A6(e.data),r=j6(n?.branch);if(!n||!r)return null;if(n.draft===!0)return`Feature added to the backlog — ${r} is not cut yet`;if(n.branchReady!==!0)return`Feature created — branch ${r} is still being cut`;let i=j6(n.baseBranch);return i?`Feature created on branch ${r}, from ${i}`:`Feature created on branch ${r}`}function I6(e){if(D6(e.type)){let t=E6(e.data);if(!t){let t=w6(e.message);return{summary:T6(t,x6)||O6(e.type),detail:e.message.trim()===t?null:e.message.trim()}}let n=T6(w6(t.args),S6);return{summary:n?`${t.name} — ${n}`:`${t.name}`,detail:t.args.trim()===``?null:t.args.trim()}}let t=C6(e.message),n=F6(e)??k6(e.type,t)??t,r=T6(w6(n),x6),i=n===r?null:n;return{summary:r||O6(e.type),detail:i}}function L6(e){return e===`lap.started`}function R6(e){if(e.type!==`run.finished`||typeof e.data!=`object`||e.data===null)return null;let t=e.data.status;return t===`succeeded`||t===`failed`||t===`cancelled`?t:null}function z6(e){let t=R6(e);if(t)return t===`succeeded`?`ok`:`error`;let n=M6(e);if(n!==null)return n?`ok`:`error`;let r=e.type;return r===`merge.conflict.resolved`?`ok`:r===`merge.conflict.resolving`?`active`:/(error|fail|conflict|cancel|stopped|timeout)/i.test(r)?`error`:/(done|succeed|finished|shipped|merged)/i.test(r)?`ok`:/(start|burn|launch|advance|running|retry|resum)/i.test(r)?`active`:`info`}var B6={error:`danger`,ok:`success`,active:`accent`,info:`neutral`};function V6({events:e}){let t=e.slice(-50).reverse();return t.length===0?(0,I.jsx)(XN,{compact:!0,icon:(0,I.jsx)(Xy,{}),title:`Nothing yet`,hint:`Everything that happens to this feature shows up here.`}):(0,I.jsx)(`div`,{className:`flex flex-col`,children:t.map(e=>L6(e.type)?(0,I.jsx)(H6,{event:e},e.id):(0,I.jsx)(U6,{event:e},e.id))})}function H6({event:e}){return(0,I.jsxs)(`div`,{className:`my-2 flex items-center gap-2 text-xs font-medium text-accent-text`,role:`separator`,children:[(0,I.jsx)(`span`,{className:`first-letter:uppercase`,children:I6(e).summary}),(0,I.jsx)(`span`,{className:`h-px flex-1 bg-border-subtle`}),(0,I.jsx)(`span`,{className:`font-normal text-text-tertiary tabular-nums`,children:hg(e.ts)})]})}function U6({event:e}){let[t,n]=(0,F.useState)(!1),r=I6(e);return(0,I.jsxs)(`div`,{className:`flex gap-3 py-2`,children:[(0,I.jsx)(`span`,{className:`flex h-5 w-1.5 shrink-0 items-center`,children:(0,I.jsx)(RA,{tone:B6[z6(e)]})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r.detail?(0,I.jsxs)(`button`,{type:`button`,className:`group/ev m-0 flex w-full cursor-pointer items-start gap-1 bg-transparent p-0 text-left text-sm text-text-secondary transition-colors duration-(--dur-1) ease-app hover:text-text`,"aria-expanded":t,title:t?`Show less`:`Show the whole event`,onClick:()=>n(e=>!e),children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1`,children:r.summary}),(0,I.jsx)(Wy,{size:14,"aria-hidden":`true`,className:q(`mt-0.5 shrink-0 text-icon transition-transform duration-(--dur-2) ease-app`,t&&`rotate-90`)})]}):(0,I.jsx)(`div`,{className:`text-sm text-text-secondary`,children:r.summary}),t&&r.detail&&(0,I.jsx)(`pre`,{className:`m-0 mt-2 max-h-[260px] overflow-auto rounded-md bg-surface-inset px-2.5 py-2 font-mono text-xs break-words whitespace-pre-wrap text-text-secondary animate-fade-in`,children:r.detail}),(0,I.jsxs)(`div`,{className:`mt-0.5 flex items-baseline gap-2 text-xs text-text-tertiary`,children:[(0,I.jsx)(`span`,{className:`truncate`,children:P6(e.type)}),(0,I.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums`,children:hg(e.ts)})]})]})]})}var W6=[`outcome.md`,`brief.md`,`decisions.md`,`spec.md`];function G6(e){return e.split(/[\\/]/).pop()??e}function K6(e){return e.split(/[\\/]/).slice(0,-1).join(`/`)}function q6({docs:e,onOpen:t}){let n=e=>{let t=W6.indexOf(e.relPath);return t===-1?W6.length:t},r=[...e].sort((e,t)=>n(e)-n(t)||e.relPath.localeCompare(t.relPath));return(0,I.jsx)(IN,{title:`Docs`,children:e.length===0?(0,I.jsx)(XN,{compact:!0,icon:(0,I.jsx)(Jy,{}),title:`No docs yet`,hint:`The brief, the decisions and the spec collect here as the agent writes them.`}):(0,I.jsx)(YA,{label:`Feature docs`,className:`-mx-3`,children:r.map((e,n)=>{let i=K6(e.relPath),a=e.title||G6(e.relPath),o=r.some(t=>t!==e&&(t.title||G6(t.relPath))===a)?e.relPath:i;return(0,I.jsx)(JA,{index:n,leading:(0,I.jsx)(Jy,{}),title:a,...o?{description:o}:{},tooltip:e.relPath,meta:e.updatedAt===void 0?void 0:gg(e.updatedAt),onClick:()=>t(e)},e.relPath)})})})}function J6({featureId:e,facts:t,onOpenDoc:n}){let r=R.feature.get.useQuery({id:e},{refetchInterval:tg()}),i=nL(e);return(0,I.jsxs)(`div`,{className:`flex flex-col px-6 pt-5 pb-10`,children:[t,r.isLoading?(0,I.jsx)(X6,{}):r.data?(0,I.jsx)(q6,{docs:r.data.docs,onOpen:e=>n(e.relPath)}):(0,I.jsx)(YN,{children:r.error?.message??`Could not load the details`}),(0,I.jsx)($N,{className:`mt-10`,title:`Activity`,icon:(0,I.jsx)(Xy,{}),aside:i.length>0?String(Math.min(i.length,50)):void 0,children:(0,I.jsx)(V6,{events:i})})]})}var Y6=[`w-28`,`w-20`,`w-32`];function X6(){return(0,I.jsx)(WN,{label:`Loading the details…`,children:(0,I.jsx)(`div`,{className:`-mx-2 flex flex-col`,children:Y6.map((e,t)=>(0,I.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 px-3`,"data-skeleton":`doc-row`,children:[(0,I.jsx)(GN,{className:`size-4`}),(0,I.jsx)(GN,{className:q(`h-3`,e)}),(0,I.jsx)(GN,{className:`ml-auto h-2.5 w-12`})]},t))})})}function Z6(e){return e.satisfied?`success`:e.status===`archived`||e.status===`draft`?`neutral`:`accent`}function Q6({feature:e,when:t,dependsOn:n,blocks:r}){let i=rx();return(0,I.jsx)(XA,{items:[{label:`Branch`,leading:(0,I.jsx)(Fy,{}),value:(0,I.jsx)(`button`,{type:`button`,title:`Copy branch name`,onClick:()=>HF(e.branch,i),className:q(`max-w-full cursor-pointer truncate rounded-sm font-mono text-xs text-text-secondary`,`transition-colors duration-(--dur-1) ease-app hover:text-text`),children:e.branch})},{label:t.label,value:t.value},...n.map((e,t)=>({label:t===0?`Waits on`:``,tone:Z6(e),value:e.title,sub:yg(e)})),...r.map((e,t)=>({label:t===0?`Waited on by`:``,value:e.title,sub:e.upNext?`starts when this ships`:`in the backlog`}))]})}function $6(e){return e.filter(e=>e.author===`human`&&e.sentAt===void 0&&e.status!==`promoted`)}var e8=`While this drive runs, the agent can’t start a round or land its own edits.`;function t8({featureId:e,driving:t,stopping:n,onStop:r}){let i=R.useUtils(),a=rx(),o=R.notes.list.useQuery({featureId:e}),s=R.notes.send.useMutation({onSuccess:()=>{i.notes.list.invalidate({featureId:e}),i.notes.delivery.invalidate({featureId:e})},onError:e=>a.push(e.message)}),c=$6(o.data??[]).length;return!t&&c===0?null:(0,I.jsxs)(`div`,{className:`flex items-center gap-3 px-1 text-sm text-text-secondary`,children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 text-pretty`,children:t?e8:`${c} ${c===1?`note`:`notes`} not sent yet`}),t?(0,I.jsx)(J,{size:`sm`,icon:(0,I.jsx)(ab,{}),loading:n,onClick:r,children:`Stop drive`}):(0,I.jsx)(J,{size:`sm`,icon:(0,I.jsx)(rb,{}),loading:s.isPending,onClick:()=>s.mutate({featureId:e}),children:`Send to the agent`})]})}var n8={read:Jy,edit:Yy,delete:Vy,move:nb,search:My,execute:Ky,think:sb,fetch:mb,other:$y},r8={read:[`Read`,`Reading`],edit:[`Edited`,`Editing`],delete:[`Deleted`,`Deleting`],move:[`Moved`,`Moving`],search:[`Searched`,`Searching`],execute:[`Ran`,`Running`],think:[`Thought`,`Thinking`],fetch:[`Fetched`,`Fetching`],other:[`Used`,`Using`]},i8={Read:[`Read`,`Reading`],Write:[`Wrote`,`Writing`],Edit:[`Edited`,`Editing`],Delete:[`Deleted`,`Deleting`],Move:[`Moved`,`Moving`],Fetch:[`Fetched`,`Fetching`],Search:[`Searched`,`Searching`],Run:[`Ran`,`Running`],List:[`Listed`,`Listing`],View:[`Viewed`,`Viewing`],Open:[`Opened`,`Opening`],Find:[`Searched`,`Searching`],Compact:[`Compacted`,`Compacting`]},a8=new Map(Object.values(i8).map(e=>[e[1],e])),o8=/^(Load skill|Create task|Update task|List tasks|Get task|Approve Plan|Exited Plan Mode|Asking for|Preparing file|Edit notebook|Terminal|Image generation|(Start|Interact with|Interrupt|Complete) subagent)\b/,s8=/^mcp__(.+)__([^_].*)$|^mcp\.(.+)\.([^.]+)$/,c8=/^Web search(?::\s*(.*))?$/,l8=`Guardian Review`,u8=e=>e.title===l8&&e.status===`completed`,d8=/^("[^"]+"|\S+)\s+(?:-(?:NoLogo|NoProfile|NonInteractive)\s+)*(?:-Command|-c|-lc|\/c)\s+([\s\S]+)$/i,f8=new Set([`pwsh`,`powershell`,`cmd`,`bash`,`zsh`,`sh`]);function p8(e){let t=d8.exec(e.trim()),n=t?.[1].replace(/"/g,``).split(/[\\/]/).pop()?.replace(/\.exe$/i,``).toLowerCase();if(!t||!n||!f8.has(n))return e;let r=t[2].trim();return/^(['"])[\s\S]*\1$/.test(r)?r.slice(1,-1):r}var m8=e=>e.replace(/[_-]+/g,` `).trim();function h8(e,t){let n=+!!t;if(e.title===l8)return{target:t?`Checking with Codex's reviewer`:e.status===`failed`?`Stopped by Codex's reviewer`:`Checked by Codex's reviewer`,mono:!1};e.kind===`execute`&&(e={...e,title:p8(e.title)});let r=s8.exec(e.title);if(r){let[e,t]=r[1]===void 0?[r[3],r[4]]:[r[1],r[2]];return{target:`${m8(e.replace(/^plugin_/,``))}: ${m8(t)}`,mono:!1}}if(o8.test(e.title))return{target:e.title,mono:!1};let i=c8.exec(e.title);if(i)return{verb:t?`Searching the web`:`Searched the web`,target:i[1]??``,mono:!1};let[a,...o]=e.title.split(` `),s=i8[a]??a8.get(a);return s?{verb:s[n],target:o.join(` `),mono:!0}:/^[A-Z][A-Za-z]+$/.test(e.title)?{verb:r8[e.kind][n],target:e.title.replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase(),mono:!1}:{verb:r8[e.kind][n],target:e.title,mono:!0}}function g8(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);return t<60?`${t}m ${e%60}s`:`${Math.floor(t/60)}h ${t%60}m`}function _8({head:e,open:t,onToggle:n,children:r}){return(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:n,className:q(WE,`group/fold -mx-2 flex h-7 min-w-0 cursor-pointer items-center gap-1.5 self-start rounded-md px-2 text-sm`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`,`text-text-tertiary hover:text-text-secondary`),children:[e,(0,I.jsx)(Wy,{size:13,className:q(`shrink-0 text-icon opacity-60 transition-transform duration-(--dur-2) ease-app group-hover/fold:opacity-100`,t&&`rotate-90`)})]}),t&&(0,I.jsx)(`div`,{className:`mt-1 flex min-w-0 flex-col gap-1.5 animate-fade-in`,children:r})]})}function v8({steps:e,seconds:t,live:n}){let[r,i]=(0,F.useState)(!1);return n?(0,I.jsx)(y8,{steps:e}):(0,I.jsx)(_8,{open:r,onToggle:()=>i(!r),head:(0,I.jsxs)(`span`,{children:[`Worked for `,g8(t)]}),children:(0,I.jsx)(`div`,{className:`border-l border-border-subtle pl-4`,children:(0,I.jsx)(y8,{steps:e})})})}function y8({steps:e}){return(0,I.jsx)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:e.map(e=>{switch(e.kind){case`tools`:return(0,I.jsx)(A8,{calls:e.calls},e.id);case`thought`:return(0,I.jsx)(b8,{seconds:e.seconds,text:e.text},e.id);case`narration`:return(0,I.jsx)(VK,{source:e.text,size:`sm`,tone:`secondary`,className:`my-1.5`,breaks:!0},e.id);case`subagent`:return(0,I.jsx)(x8,{title:e.title,status:e.status,calls:e.calls},e.id)}})})}function b8({seconds:e,text:t}){let[n,r]=(0,F.useState)(!1);return(0,I.jsx)(_8,{open:n,onToggle:()=>r(!n),head:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(sb,{size:14,className:`shrink-0 text-icon`}),(0,I.jsxs)(`span`,{children:[`Thought for `,g8(e)]})]}),children:(0,I.jsx)(`p`,{className:`m-0 border-l border-border-subtle pl-4 text-sm leading-[22px] text-text-tertiary italic`,children:t})})}function x8({title:e,status:t,calls:n}){let[r,i]=(0,F.useState)(!1),a=t===`in_progress`||t===`pending`,o=n.filter(e=>!u8(e)),s=a?o.findLast(e=>e.status===`in_progress`||e.status===`pending`):void 0;return(0,I.jsxs)(`div`,{className:q(Uq,`my-1.5 flex min-w-0 flex-col overflow-hidden`),children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:()=>i(!r),className:q(WE,`group/fold flex h-10 min-w-0 cursor-pointer items-center gap-2 px-3 text-left text-sm`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`),children:[a&&!s?(0,I.jsx)(UE,{size:`sm`}):(0,I.jsx)(Zy,{size:14,className:`shrink-0 text-icon`}),(0,I.jsx)(`span`,{className:`shrink-0 text-text-tertiary`,children:`Subagent`}),(0,I.jsx)(`span`,{className:q(`min-w-0 truncate`,a?`text-shimmer`:`text-text-secondary`),children:e}),(0,I.jsxs)(`span`,{className:`ml-auto shrink-0 text-xs tabular-nums text-text-tertiary`,children:[o.length,` `,o.length===1?`call`:`calls`]}),(0,I.jsx)(Wy,{size:13,className:q(`shrink-0 text-icon transition-transform duration-(--dur-2) ease-app`,r&&`rotate-90`)})]}),r?(0,I.jsx)(`div`,{className:`border-t border-border-subtle px-3 py-1.5 animate-fade-in`,children:(0,I.jsx)(A8,{calls:n})}):s&&(0,I.jsx)(`ol`,{className:`m-0 list-none border-t border-border-subtle px-3 py-0.5`,children:(0,I.jsx)(j8,{call:s})})]})}var S8={read:`explore`,search:`explore`,fetch:`explore`,edit:`change`,delete:`change`,move:`change`,execute:`run`};function C8(e){if(!(s8.test(e.title)||o8.test(e.title)||c8.test(e.title)||e.title===l8))return S8[e.kind]}function w8(e){let t=[];for(let n of e.filter(e=>!u8(e))){let e=C8(n),r=t.at(-1);e&&r?.kind===`group`&&r.family===e?r.calls.push(n):e&&r?.kind===`one`&&C8(r.call)===e?t[t.length-1]={kind:`group`,family:e,calls:[r.call,n]}:t.push({kind:`one`,call:n})}return t}var T8={read:[`Read`,`Reading`,`file`,`files`],search:[`Searched for`,`Searching for`,`pattern`,`patterns`],fetch:[`Fetched`,`Fetching`,`page`,`pages`],edit:[`Edited`,`Editing`,`file`,`files`],delete:[`Deleted`,`Deleting`,`file`,`files`],move:[`Moved`,`Moving`,`file`,`files`],execute:[`Ran`,`Running`,`command`,`commands`]},E8=e=>e.status===`in_progress`||e.status===`pending`;function D8(e){return[...new Set(e.map(e=>e.kind))].map((t,n)=>{let r=T8[t],i=e.filter(e=>e.kind===t);if(!r)return``;let a=r[2]===`file`?new Set(i.map(e=>e.diff?.path??h8(e,!1).target.replace(/\s+\(\d+\s*-\s*\d+\)$/,``))).size:i.length,o=`${i.some(E8)?r[1]:r[0]} ${a} ${a===1?r[2]:r[3]}`;return n===0?o:o.charAt(0).toLowerCase()+o.slice(1)}).filter(Boolean).join(`, `)}var O8={explore:My,change:Yy,run:Ky};function k8({family:e,calls:t}){let[n,r]=(0,F.useState)(!1),i=O8[e],a=t.findLast(E8),o=t.filter(e=>e.status===`failed`).length,s=t.flatMap(e=>e.diff?.lines??[]);return(0,I.jsxs)(`li`,{className:`flex min-w-0 flex-col animate-fade-in`,children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(!n),className:q(WE,`group/call -mx-2 flex h-7 min-w-0 cursor-pointer items-center gap-2 rounded-md px-2 text-left text-sm`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`),children:[a?(0,I.jsx)(UE,{size:`sm`}):(0,I.jsx)(i,{size:14,className:`shrink-0 text-icon`}),(0,I.jsx)(`span`,{className:q(`shrink-0`,a?`text-shimmer`:`text-text-tertiary`),children:D8(t)}),a&&(0,I.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-text-secondary`,children:h8(a,!0).target}),e===`change`&&s.length>0&&(0,I.jsx)(M8,{added:s.filter(e=>e.op===`+`).length,removed:s.filter(e=>e.op===`-`).length}),o>0&&(0,I.jsxs)(`span`,{className:`shrink-0 text-danger-text`,children:[`· `,o,` failed`]}),(0,I.jsx)(Wy,{size:13,className:q(`shrink-0 text-icon opacity-60 transition-all duration-(--dur-2) ease-app group-hover/call:opacity-100`,n&&`rotate-90 opacity-100`)})]}),n&&(0,I.jsx)(`ol`,{className:`m-0 mt-0.5 mb-1 flex list-none flex-col border-l border-border-subtle p-0 pl-4 animate-fade-in`,children:t.map(e=>(0,I.jsx)(j8,{call:e},e.id))})]})}function A8({calls:e}){let t=w8(e);return t.length===0?null:(0,I.jsx)(`ol`,{className:`m-0 flex list-none flex-col p-0`,children:t.map(e=>e.kind===`one`?(0,I.jsx)(j8,{call:e.call},e.call.id):(0,I.jsx)(k8,{family:e.family,calls:e.calls},e.calls[0].id))})}function j8({call:e}){let[t,n]=(0,F.useState)(!1),r=n8[e.kind],i=e.status===`in_progress`||e.status===`pending`,a=e.status===`failed`,o=!!e.output||!!e.diff,s=e.diff?.lines.filter(e=>e.op===`+`).length??0,c=e.diff?.lines.filter(e=>e.op===`-`).length??0,l=h8(e,i),u=(0,I.jsxs)(I.Fragment,{children:[i?(0,I.jsx)(UE,{size:`sm`}):a?(0,I.jsx)(Sb,{size:14,className:`shrink-0 text-danger`}):(0,I.jsx)(r,{size:14,className:`shrink-0 text-icon`}),l.verb&&(0,I.jsx)(`span`,{className:q(`shrink-0 text-sm`,i?`text-shimmer`:a?`text-danger-text`:`text-text-tertiary`),children:l.verb}),l.target&&(0,I.jsx)(`span`,{className:q(`min-w-0 truncate`,l.mono?`font-mono text-xs`:`text-sm`,a?`text-danger-text`:l.verb?`text-text-secondary`:i?`text-shimmer`:`text-text-tertiary`),children:l.target}),e.diff&&(0,I.jsx)(M8,{added:s,removed:c}),o&&(0,I.jsx)(Wy,{size:13,className:q(`shrink-0 text-icon opacity-0 transition-all duration-(--dur-2) ease-app group-hover/call:opacity-100`,t&&`rotate-90 opacity-100`)})]});return(0,I.jsxs)(`li`,{className:`flex min-w-0 flex-col animate-fade-in`,children:[o?(0,I.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(!t),className:q(WE,`group/call -mx-2 flex h-7 min-w-0 cursor-pointer items-center gap-2 rounded-md px-2 text-left`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`),children:u}):(0,I.jsx)(`div`,{className:`flex h-7 min-w-0 items-center gap-2`,children:u}),t&&e.diff&&(0,I.jsx)(I8,{lines:e.diff.lines}),t&&e.output&&(0,I.jsx)(N8,{text:e.output})]})}function M8({added:e,removed:t}){return(0,I.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,I.jsxs)(`span`,{className:`text-success-text`,children:[`+`,e]}),` `,(0,I.jsxs)(`span`,{className:`text-danger-text`,children:[`−`,t]})]})}function N8({text:e}){return(0,I.jsx)(`pre`,{className:q(Wq,`m-0 mt-1 mb-2 max-h-64 overflow-auto px-3 py-2 font-mono text-xs leading-[18px] whitespace-pre-wrap text-text-secondary`),children:e})}var P8={" ":`text-text-tertiary`,"+":`bg-[color-mix(in_oklab,var(--color-success)_12%,transparent)] text-text`,"-":`bg-[color-mix(in_oklab,var(--color-danger)_12%,transparent)] text-text-secondary`},F8={" ":`border-transparent`,"+":`border-success`,"-":`border-danger`};function I8({lines:e}){return(0,I.jsx)(`div`,{className:q(Wq,`mt-1 mb-2 max-h-80 overflow-auto py-1.5 font-mono text-xs leading-[20px]`),children:e.map((e,t)=>(0,I.jsxs)(`div`,{className:q(`flex min-w-max border-l-2 pr-3 pl-2.5`,P8[e.op],F8[e.op]),children:[(0,I.jsx)(`span`,{className:`w-4 shrink-0 select-none text-text-tertiary`,children:e.op===` `?``:e.op===`-`?`−`:`+`}),(0,I.jsx)(`span`,{className:`whitespace-pre`,children:e.text||` `})]},t))})}function L8({path:e}){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`))+1;return(0,I.jsxs)(`span`,{title:e,className:`flex min-w-0 flex-1 font-mono text-xs`,children:[t>0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-text-tertiary [direction:rtl]`,children:(0,I.jsx)(`bdi`,{children:e.slice(0,t)})}),(0,I.jsx)(`span`,{className:`shrink-0 text-text-secondary`,children:e.slice(t)})]})}function R8({files:e}){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(null),a=e.reduce((e,t)=>e+t.added,0),o=e.reduce((e,t)=>e+t.removed,0);return(0,I.jsxs)(`div`,{className:q(Uq,`flex flex-col overflow-hidden`),children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(!t),className:q(WE,`flex h-10 cursor-pointer items-center gap-2 px-3 text-left text-sm text-text-secondary`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`),children:[(0,I.jsx)(Wy,{size:14,className:q(`shrink-0 text-icon transition-transform duration-(--dur-2) ease-app`,t&&`rotate-90`)}),(0,I.jsxs)(`span`,{children:[e.length,` changed `,e.length===1?`file`:`files`]}),(0,I.jsx)(M8,{added:a,removed:o})]}),t&&(0,I.jsx)(`ul`,{className:`m-0 flex list-none flex-col border-t border-border-subtle p-1 animate-fade-in`,children:e.map(e=>(0,I.jsxs)(`li`,{className:`flex min-w-0 flex-col`,children:[(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":r===e.path,onClick:()=>i(r===e.path?null:e.path),className:q(`border-0 bg-transparent`,`flex h-8 min-w-0 cursor-pointer items-center gap-2 rounded-md px-2 text-left`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`),children:[(0,I.jsx)(Jy,{size:14,className:`shrink-0 text-icon`}),(0,I.jsx)(L8,{path:e.path}),(0,I.jsx)(M8,{added:e.added,removed:e.removed})]}),r===e.path&&(0,I.jsx)(`div`,{className:`px-1`,children:(0,I.jsx)(I8,{lines:e.lines})})]},e.path))})]})}var z8=`${Hq} relative flex flex-col animate-rise-in`,B8=`max-h-[75dvh]`,V8=`min-h-0 overflow-y-auto`;function H8({n:e,on:t,label:n,description:r,multi:i,onPick:a}){let o=zx();return(0,I.jsxs)(`button`,{type:`button`,role:i?`checkbox`:`radio`,"aria-checked":t,onClick:a,className:q(WE,`group/choice flex w-full min-w-0 cursor-pointer items-start gap-3 rounded-md px-2.5 text-left`,o?`min-h-11 py-3`:`py-1.5`,`transition-colors duration-(--dur-1) ease-app`,t?`bg-surface-selected`:`hover:bg-surface-hover`),children:[(0,I.jsx)(`span`,{"aria-hidden":!0,className:q(`mt-px grid size-5 shrink-0 place-items-center rounded-sm font-mono text-xs tabular-nums transition-colors duration-(--dur-1) ease-app`,t?`bg-accent text-on-primary`:`bg-surface-inset text-text-tertiary ring-1 ring-inset ring-border-subtle group-hover/choice:text-text-secondary`),children:t&&i?(0,I.jsx)(zy,{size:11}):e}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-text`,children:n}),r&&(0,I.jsx)(`span`,{className:`text-sm text-text-secondary`,children:r})]})]})}function U8({n:e,value:t,onChange:n,placeholder:r,focused:i,onEnter:a}){let o=(0,F.useRef)(null);(0,F.useEffect)(()=>{i&&o.current?.focus()},[i]);let s=t.trim()!==``,c=zx();return(0,I.jsxs)(`label`,{className:q(`flex min-w-0 cursor-text items-center gap-3 rounded-md px-2.5 transition-colors duration-(--dur-1) ease-app`,c?`min-h-11 py-2`:`py-1.5`,s?`bg-surface-selected`:`hover:bg-surface-hover`),children:[(0,I.jsx)(`span`,{"aria-hidden":!0,className:q(`grid size-5 shrink-0 place-items-center rounded-sm font-mono text-xs tabular-nums`,s?`bg-accent text-on-primary`:`bg-surface-inset text-text-tertiary ring-1 ring-inset ring-border-subtle`),children:e}),(0,I.jsx)(`input`,{ref:o,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&s&&a?.()},placeholder:r,className:q(`h-7 min-w-0 flex-1 border-0 bg-transparent p-0 font-sans text-text outline-none placeholder:text-text-tertiary`,c?`text-lg`:`text-sm`)})]})}function W8({left:e,keys:t,children:n}){let r=zx();return(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-border-subtle px-3 py-2`,children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-text-tertiary`,children:[e,e&&!r&&` · `,!r&&t]}),n]})}function G8({questions:e,onAnswer:t}){let[n,r]=(0,F.useState)(0),[i,a]=(0,F.useState)({}),[o,s]=(0,F.useState)({}),c=(0,F.useRef)(null),l=zx(),u=e.length>1&&n===e.length,d=e[Math.min(n,e.length-1)];(0,F.useEffect)(()=>c.current?.focus(),[n]);let f=e=>{let t=[...i[e]??[]],n=o[e]?.trim();return n&&t.push(n),t.join(`, `)},p=()=>Object.fromEntries(e.map((e,t)=>[e.question,f(t)])),m=(i=n)=>{e.length===1?t(p()):r(i+1)},h=(n,o)=>{let c=e[n].multiSelect,l=i[n]??[],u=c?l.includes(o)?l.filter(e=>e!==o):[...l,o]:[o];a(e=>({...e,[n]:u})),c||(s(e=>({...e,[n]:``})),e.length===1?t({[e[0].question]:o}):window.setTimeout(()=>r(n+1),140))};return(0,I.jsxs)(`div`,{ref:c,tabIndex:-1,onKeyDown:e=>{if(u){e.key===`Enter`&&t(p()),(e.key===`ArrowLeft`||e.key===`Backspace`)&&r(n-1);return}let i=Number(e.key);i>=1&&i<=d.options.length&&h(n,d.options[i-1].label),e.key===`Enter`&&f(n)&&m(),e.key===`ArrowLeft`&&n>0&&r(n-1)},role:`group`,"aria-label":`The agent asks`,className:q(z8,`outline-none`,l&&B8),children:[e.length>1&&(0,I.jsx)(`div`,{className:`flex items-center gap-1 px-4 pt-3`,"aria-hidden":!0,children:[...e.map((e,t)=>t===n?`now`:f(t)?`done`:`todo`),u?`now`:`todo`].map((e,t)=>(0,I.jsx)(`span`,{className:q(`h-0.75 min-w-0 flex-1 basis-0 rounded-full transition-colors duration-(--dur-2) ease-app`,e===`now`?`bg-accent`:e===`done`?`bg-text-tertiary`:`bg-border-strong`)},t))}),u?(0,I.jsxs)(`div`,{className:q(`flex flex-col gap-1 px-2 pt-3 pb-2 animate-fade-in`,V8),children:[(0,I.jsx)(`p`,{className:`m-0 mb-1 px-2 text-base font-medium text-text`,children:`Check your answers`}),e.map((e,t)=>(0,I.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:q(WE,`group/sum flex min-w-0 cursor-pointer items-baseline gap-3 rounded-md px-2 py-1.5 text-left`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`),children:[(0,I.jsx)(`span`,{className:`w-28 shrink-0 truncate text-sm text-text-tertiary`,children:e.header}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 text-sm text-text`,children:f(t)}),(0,I.jsx)(`span`,{className:`shrink-0 text-xs text-text-tertiary opacity-0 group-hover/sum:opacity-100`,children:`Change`})]},e.question))]},`summary`):(0,I.jsxs)(`div`,{className:q(`flex flex-col gap-1 px-2 pt-3 pb-2 animate-fade-in`,V8),children:[(0,I.jsxs)(`div`,{className:`mb-1 flex flex-col gap-0.5 px-2`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-medium text-text-tertiary`,children:[(0,I.jsx)(sb,{size:12,className:`text-icon`}),d.header,e.length>1&&(0,I.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,n+1,` of `,e.length]}),d.multiSelect&&(0,I.jsx)(`span`,{children:` · pick any`})]}),(0,I.jsx)(`span`,{className:`text-base text-text`,children:d.question})]}),d.options.map((e,t)=>(0,I.jsx)(H8,{n:t+1,on:(i[n]??[]).includes(e.label),label:e.label,description:e.description,multi:d.multiSelect,onPick:()=>h(n,e.label)},e.label)),(0,I.jsx)(U8,{n:d.options.length+1,value:o[n]??``,onChange:e=>{s(t=>({...t,[n]:e})),!d.multiSelect&&e&&a(e=>({...e,[n]:[]}))},placeholder:`Other — type your own answer`,onEnter:()=>m()})]},n),(0,I.jsxs)(W8,{keys:u?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Yx,{children:`Enter`}),` to send`]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Yx,{children:`1`}),`–`,(0,I.jsx)(Yx,{children:String(d.options.length)}),` to pick · `,(0,I.jsx)(Yx,{children:`Enter`}),` to go on`]}),children:[n>0&&(0,I.jsx)(J,{variant:`ghost`,size:`sm`,icon:(0,I.jsx)(wb,{}),onClick:()=>r(n-1),children:`Back`}),u?(0,I.jsx)(J,{variant:`primary`,size:`sm`,icon:(0,I.jsx)(zy,{}),onClick:()=>t(p()),children:`Send answers`}):(d.multiSelect||(o[n]??``).trim()!==``||e.length>1)&&(0,I.jsx)(J,{variant:f(n)?`primary`:`secondary`,size:`sm`,icon:e.length===1?(0,I.jsx)(zy,{}):(0,I.jsx)(nb,{}),disabled:!f(n),onClick:()=>m(),children:e.length===1?`Send`:`Next`})]})]})}function K8({call:e,onAnswer:t}){let[n,r]=(0,F.useState)(``),i=(0,F.useRef)(null),a=zx();(0,F.useEffect)(()=>i.current?.focus(),[]);let o=e.kind===`execute`?`Run this command?`:e.kind===`edit`?`Make this edit to ${e.diff?.path??`the file`}?`:e.kind===`fetch`?`Fetch this page?`:`Use this tool?`,s=e.title.split(/\s+/).slice(0,2).join(` `);return(0,I.jsxs)(`div`,{ref:i,tabIndex:-1,onKeyDown:e=>{e.key===`1`&&t(`allow`),e.key===`2`&&t(`always`),e.key===`Escape`&&t(`deny`)},role:`group`,"aria-label":`The agent asks to`,className:q(z8,`outline-none`,a&&B8),children:[(0,I.jsxs)(`div`,{className:q(`flex flex-col`,V8),children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 px-4 pt-3`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium text-text`,children:[(0,I.jsx)(ob,{size:15,className:`shrink-0 text-warning`}),o]}),e.diff?(0,I.jsx)(I8,{lines:e.diff.lines}):(0,I.jsxs)(`pre`,{className:`m-0 overflow-x-auto rounded-md bg-surface-inset px-3 py-2 font-mono text-xs leading-[20px] whitespace-pre-wrap text-text ring-1 ring-inset ring-border-subtle`,children:[e.kind===`execute`&&(0,I.jsx)(`span`,{className:`text-text-tertiary select-none`,children:`$ `}),e.title]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-2 pt-2 pb-2`,children:[(0,I.jsx)(H8,{n:1,on:!1,label:`Yes`,onPick:()=>t(`allow`)}),(0,I.jsx)(H8,{n:2,on:!1,label:e.kind===`edit`?`Yes, and allow edits for the rest of this thread`:(0,I.jsxs)(I.Fragment,{children:[`Yes, and don’t ask again for `,(0,I.jsx)(`span`,{className:`font-mono text-xs`,children:s}),` in this project`]}),onPick:()=>t(`always`)}),(0,I.jsx)(U8,{n:3,value:n,onChange:r,placeholder:`No, and tell the agent what to do instead`,onEnter:()=>t(`deny`,n)})]})]}),(0,I.jsx)(W8,{keys:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Yx,{children:`1`}),` `,(0,I.jsx)(Yx,{children:`2`}),` to answer · `,(0,I.jsx)(Yx,{children:`Esc`}),` to deny`]}),children:(0,I.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>t(`deny`,n||void 0),children:`Deny`})})]})}function q8({server:e,icon:t,message:n}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-4 pt-3`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-medium text-text-tertiary`,children:[t,e??`An MCP server`,` asks`]}),(0,I.jsx)(`span`,{className:`text-base text-text`,children:n})]})}var J8=e=>Object.fromEntries(e.map(e=>[e.key,e.type===`boolean`?e.default??!1:e.default===void 0?``:String(e.default)]));function Y8(e,t){if(typeof t!=`boolean`){if(!t.trim())return e.required?`Required`:void 0;if(e.type===`number`&&(!Number.isFinite(Number(t))||e.integer&&!Number.isInteger(Number(t))))return e.integer?`A whole number`:`A number`}}var X8={email:`email`,uri:`url`,date:`date`};function Z8({server:e,message:t,fields:n,onSubmit:r,onDecline:i}){let[a,o]=(0,F.useState)(()=>J8(n)),[s,c]=(0,F.useState)(!1),l=(0,F.useRef)(null),u=zx();(0,F.useEffect)(()=>l.current?.focus(),[]);let d=(e,t)=>o(n=>({...n,[e]:t})),f=()=>{if(c(!0),n.some(e=>Y8(e,a[e.key])))return;let e={};for(let t of n){let n=a[t.key];typeof n==`boolean`?e[t.key]=n:n.trim()&&(e[t.key]=t.type===`number`?Number(n):n)}r(e)},p=(e,t)=>{let n=a[e.key];switch(e.type){case`boolean`:return(0,I.jsx)(HN,{size:`md`,checked:n===!0,onChange:t=>d(e.key,t),label:e.title});case`enum`:return(0,I.jsx)(`div`,{role:`radiogroup`,"aria-label":e.title,className:`-mx-2.5 flex flex-col gap-0.5`,children:e.options.map((t,r)=>(0,I.jsx)(H8,{n:r+1,on:n===t.value,label:t.label,onPick:()=>d(e.key,t.value)},t.value))});default:return(0,I.jsx)(EN,{type:e.type===`number`?`number`:e.format?X8[e.format]:`text`,...e.type===`number`&&e.integer?{step:1}:{},value:typeof n==`string`?n:``,onChange:t=>d(e.key,t.target.value),invalid:t,required:e.required})}};return(0,I.jsxs)(`form`,{ref:l,tabIndex:-1,noValidate:!0,"aria-label":`An MCP server asks`,onKeyDown:e=>{e.key===`Escape`&&i()},onSubmit:e=>{e.preventDefault(),f()},className:q(z8,`outline-none`,u&&B8),children:[(0,I.jsx)(q8,{server:e,icon:(0,I.jsx)($y,{size:12,className:`text-icon`}),message:t}),(0,I.jsx)(`div`,{className:q(`flex max-h-80 flex-col gap-3 px-4 pt-3 pb-3`,V8),children:n.map(e=>{let t=s?Y8(e,a[e.key]):void 0;return e.type===`boolean`?(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[p(e,!1),e.description&&(0,I.jsx)(`span`,{className:`text-xs text-text-tertiary`,children:e.description})]},e.key):(0,I.jsx)(kN,{label:(0,I.jsxs)(I.Fragment,{children:[e.title,e.required&&(0,I.jsx)(`span`,{className:`text-text-tertiary`,children:` · required`})]}),...e.description?{help:e.description}:{},...t?{error:t}:{},children:p(e,t!==void 0)},e.key)})}),(0,I.jsxs)(W8,{keys:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Yx,{children:`Enter`}),` to submit · `,(0,I.jsx)(Yx,{children:`Esc`}),` to decline`]}),children:[(0,I.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,children:`Decline`}),(0,I.jsx)(J,{type:`submit`,variant:`primary`,size:`sm`,icon:(0,I.jsx)(zy,{}),children:`Submit`})]})]})}function Q8({server:e,message:t,url:n,onDone:r,onDecline:i}){let a=(0,F.useRef)(null);return(0,F.useEffect)(()=>a.current?.focus(),[]),(0,I.jsxs)(`div`,{ref:a,tabIndex:-1,onKeyDown:e=>{e.key===`Escape`&&i()},role:`group`,"aria-label":`An MCP server asks`,className:q(z8,`outline-none`),children:[(0,I.jsx)(q8,{server:e,icon:(0,I.jsx)($y,{size:12,className:`text-icon`}),message:t}),(0,I.jsx)(`div`,{className:`px-4 pt-2 pb-3`,children:(0,I.jsxs)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:q(GE,`flex min-w-0 items-center gap-2 rounded-md bg-surface-inset px-3 py-2 font-mono text-xs ring-1 ring-inset ring-border-subtle`),children:[(0,I.jsx)(mb,{size:13,className:`shrink-0`}),(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:n})]})}),(0,I.jsxs)(W8,{left:`Open it, then say when you are done`,keys:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Yx,{children:`Esc`}),` to decline`]}),children:[(0,I.jsx)(J,{variant:`ghost`,size:`sm`,onClick:i,children:`Decline`}),(0,I.jsx)(J,{variant:`primary`,size:`sm`,icon:(0,I.jsx)(zy,{}),onClick:r,children:`Done`})]})]})}var $8=280;function e5({value:e,onChange:t,attachments:n=[],onAttach:r,onRemoveAttachment:i,commands:a=[],files:o=[],state:s,onSend:c,onStop:l,onRecall:u,suggestion:d,placeholder:f,autoFocus:p,top:m,footer:h,meter:g,workingSince:_,label:v=`Message`,sendLabel:y=`Send`,sendIcon:b=(0,I.jsx)(rb,{}),multiple:x=!0,inputRef:S}){let C=zx(),w=C?void 0:d,T=(0,F.useRef)(null),E=S??T,D=(0,F.useRef)(null),[O,k]=(0,F.useState)(0),ee=/(?:^|\s)\/(\S*)$/.exec(e),A=/(?:^|\s)@(\S*)$/.exec(e),j=ee?{kind:`command`,query:ee[1],items:km(a,e=>e.name,ee[1])}:A?{kind:`file`,query:A[1],items:Om(o,A[1],8)}:null,M=!!j&&j.items.length>0,N=j?.items.length??0;(0,F.useEffect)(()=>k(0),[j?.kind,j?.query]),(0,F.useLayoutEffect)(()=>{let e=E.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,$8)}px`)},[e]);let te=e.trim()!==``||n.length>0,ne=s===`working`,re=ne?C?`Steer the agent`:`Steer the agent — this joins the running turn`:f??(C?`Message the agent`:`Message the agent — / for commands, @ for files`),ie=C?`touch`:`md`,ae=n=>{if(!j)return;let r=e.slice(0,e.length-j.query.length);t(j.kind===`command`?`${r}${j.items[n].name} `:`${r}${j.items[n]} `),E.current?.focus()},P=n=>{if(M){if(n.key===`ArrowDown`||n.key===`ArrowUp`){n.preventDefault(),k(e=>(e+(n.key===`ArrowDown`?1:-1)+N)%N);return}if(n.key===`Tab`||n.key===`Enter`&&!n.shiftKey){n.preventDefault(),ae(O);return}if(n.key===`Escape`){n.preventDefault(),t(e.replace(/[/@]\S*$/,``));return}}if(n.key===`Tab`&&!e&&w){n.preventDefault(),t(w);return}if(n.key===`ArrowUp`&&!e){let e=u?.();e&&(n.preventDefault(),t(e));return}if(n.key===`Enter`&&!n.shiftKey&&!n.nativeEvent.isComposing&&!C){n.preventDefault(),te&&c();return}n.key===`Escape`&&ne&&(n.preventDefault(),l?.())},oe=e=>{let t=[...e??[]].filter(e=>e.type.startsWith(`image/`));return t.length===0?!1:(r?.(t),!0)};return(0,I.jsx)(`div`,{className:`flex flex-col`,children:(0,I.jsxs)(`div`,{className:q(z8,`animate-none`,ne&&`orbit-light`),children:[m,M&&j&&(0,I.jsx)(`ul`,{role:`listbox`,"aria-label":j.kind===`command`?`Commands`:`Files`,className:`m-0 flex max-h-64 list-none flex-col overflow-y-auto border-b border-border-subtle p-1 [scrollbar-width:thin] [scrollbar-color:var(--color-border-strong)_transparent] animate-fade-in`,children:j.items.map((e,t)=>{let n=typeof e==`string`?e:`/${e.name}`;return(0,I.jsx)(`li`,{role:`option`,"aria-selected":t===O,children:(0,I.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>ae(t),onMouseEnter:()=>k(t),className:q(`border-0 bg-transparent`,`flex w-full min-w-0 cursor-pointer items-center gap-3 rounded-md px-2 text-left text-sm`,C?`h-11`:`h-8`,t===O?`bg-surface-hover`:``),children:[typeof e==`string`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Jy,{size:14,className:`shrink-0 text-icon`}),(0,I.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-text`,children:e})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-text`,children:n}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-text-tertiary`,children:e.description})]}),t===O&&!C&&(0,I.jsx)(Yx,{className:`ml-auto`,children:`Tab`})]})},n)})}),n.length>0&&(0,I.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,children:n.map(e=>(0,I.jsxs)(`div`,{className:q(`rounded-md bg-surface-inset ring-1 ring-inset ring-border-subtle`,`group relative size-16 overflow-hidden animate-pop-in`),children:[(0,I.jsx)(`img`,{src:e.src,alt:e.name,className:`size-full object-cover`}),(0,I.jsx)(Y,{label:`Remove image`,icon:(0,I.jsx)(By,{size:12}),size:`sm`,variant:`secondary`,onClick:()=>i?.(e.id),className:q(`absolute top-1 right-1`,!C&&`opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100`)})]},e.id))}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(`textarea`,{ref:E,rows:2,value:e,autoFocus:p,onChange:e=>t(e.target.value),onKeyDown:P,onPaste:e=>{oe(e.clipboardData.files)&&e.preventDefault()},placeholder:w?``:re,"aria-label":v,className:q(`block w-full resize-none border-0 bg-transparent px-4 pt-3.5 pb-1 font-sans text-text outline-none placeholder:text-text-tertiary`,C?`text-lg`:`text-base`)}),w&&!e&&(0,I.jsxs)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute top-3.5 right-4 left-4 flex items-center gap-2 truncate text-base text-text-tertiary`,children:[(0,I.jsx)(`span`,{className:`truncate`,children:w}),(0,I.jsx)(Yx,{children:`Tab`})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1 px-2 pt-1 pb-2`,children:[h,(0,I.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[ne?(0,I.jsx)(t5,{since:_}):g,(0,I.jsx)(Y,{label:`Attach images`,icon:(0,I.jsx)(Fb,{}),size:ie,onClick:()=>D.current?.click()}),(0,I.jsx)(`input`,{ref:D,type:`file`,accept:`image/*`,multiple:x,hidden:!0,onChange:e=>{oe(e.target.files),e.target.value=``}}),ne&&(0,I.jsx)(Y,{label:`Stop`,...C?{}:{kbd:`Esc`},icon:(0,I.jsx)(ab,{}),size:ie,variant:`secondary`,onClick:l}),(0,I.jsx)(Y,{label:ne?`Send into the running turn`:y,...C?{}:{kbd:`Enter`},icon:b,size:ie,variant:te?`primary`:`ghost`,disabled:!te,onClick:c})]})]})]})})}function t5({since:e}){let[t,n]=(0,F.useState)(()=>Date.now());(0,F.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=e?Math.max(0,Math.round((t-e)/1e3)):null;return(0,I.jsxs)(`span`,{role:`status`,className:`flex items-center gap-1.5 px-1.5 text-xs text-text-tertiary`,children:[(0,I.jsx)(`span`,{className:`text-shimmer`,children:`Working`}),r!==null&&(0,I.jsx)(`span`,{className:`tabular-nums`,children:r>=60?`${Math.floor(r/60)}m ${r%60}s`:`${r}s`})]})}function n5({url:e,onClose:t}){return(0,I.jsx)(aP,{open:!!e,onClose:t,size:`xl`,label:`the note’s picture`,className:`overflow-hidden`,children:(0,I.jsxs)(`div`,{className:`relative flex flex-col p-2`,children:[(0,I.jsx)(`img`,{src:e??``,alt:`the picture attached to this note`,className:`block max-h-[80vh] w-full rounded-md bg-surface-inset object-contain`}),(0,I.jsx)(`span`,{className:`absolute top-4 right-4 rounded-md bg-surface-raised shadow-popover`,children:(0,I.jsx)(Y,{label:`Close`,size:`sm`,icon:(0,I.jsx)(By,{}),onClick:t})})]})})}function r5({onEdit:e,onDelete:t}){return(0,I.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5 opacity-50 transition-opacity duration-(--dur-1) group-focus-within/note:opacity-100 group-hover/note:opacity-100`,children:[(0,I.jsx)(Y,{size:`sm`,label:`Edit note`,icon:(0,I.jsx)(Yy,{}),onClick:e}),(0,I.jsx)(Y,{size:`sm`,label:`Delete note`,icon:(0,I.jsx)(Vy,{}),variant:`danger-ghost`,onClick:t})]})}function i5({note:e,onPicture:t,onSave:n,onCancel:r}){let[i,a]=(0,F.useState)(e.text),o=(0,F.useRef)(null),s=()=>{i.trim()&&n(i.trim())};return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(ON,{rows:3,"aria-label":`Edit note`,value:i,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),r()):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),s())}}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(`input`,{ref:o,type:`file`,accept:`image/*`,hidden:!0,onChange:e=>{let n=e.target.files?.[0];n&&t(n),e.target.value=``}}),(0,I.jsx)(J,{size:`sm`,variant:`ghost`,icon:(0,I.jsx)(Pb,{}),onClick:()=>o.current?.click(),children:e.picture?`Replace picture`:`Add picture`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(J,{size:`sm`,variant:`ghost`,onClick:r,children:`Cancel`}),(0,I.jsx)(J,{size:`sm`,icon:(0,I.jsx)(zy,{}),disabled:!i.trim(),onClick:s,children:`Save`})]})]})}function a5({note:e,readonly:t=!1,...n}){let[r,i]=(0,F.useState)(`rest`);return(0,I.jsxs)(`li`,{className:`group/note m-0 flex list-none flex-col gap-2 px-4 py-3 animate-rise-in`,children:[e.picture&&(0,I.jsx)(`button`,{type:`button`,"aria-label":`Open the picture`,onClick:()=>n.onOpenPicture(e.picture??``),className:`block w-full cursor-zoom-in overflow-hidden rounded-md border-0 bg-surface-inset p-0`,children:(0,I.jsx)(`img`,{src:e.picture,alt:``,className:`block max-h-44 w-full object-cover object-top`})}),r===`edit`?(0,I.jsx)(i5,{note:e,onPicture:t=>n.onPicture(e.id,t),onCancel:()=>i(`rest`),onSave:t=>{n.onEdit(e.id,t),i(`rest`)}}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:q(`m-0 text-md text-pretty whitespace-pre-wrap`,t?`text-text-secondary`:`text-text`),children:e.text}),(0,I.jsx)(`div`,{className:`flex h-6 items-center gap-2 text-xs text-text-tertiary`,children:r===`delete`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`Delete this note`,e.picture?` and its picture`:``,`?`]}),(0,I.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>i(`rest`),children:`Keep`}),(0,I.jsx)(J,{size:`sm`,variant:`danger`,icon:(0,I.jsx)(Vy,{}),onClick:()=>n.onDelete(e.id),children:`Delete`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.saving?`Saving…`:e.when}),!t&&!e.saving&&(0,I.jsx)(r5,{onEdit:()=>i(`edit`),onDelete:()=>i(`delete`)})]})})]})]})}var o5=`m-0 flex flex-col divide-y divide-border-subtle p-0`;function s5({notes:e,earlier:t,sent:n=[],foot:r,...i}){let a=e.length===0&&n.length===0&&!t?.notes.length;return(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto [scrollbar-color:var(--color-border)_transparent] [scrollbar-width:thin]`,children:[n.length>0&&(0,I.jsx)(`div`,{className:`px-4 pt-2`,children:(0,I.jsx)($N,{size:`sm`,title:`${n.length} sent to the agent`,children:(0,I.jsx)(`ul`,{className:q(o5,`-mx-4`),children:n.map(e=>(0,I.jsx)(a5,{note:e,readonly:!0,...i},e.id))})})}),t&&t.notes.length>0&&(0,I.jsxs)(`section`,{"aria-label":t.title,children:[(0,I.jsx)(WA,{className:`px-4 pt-3`,children:t.title}),(0,I.jsx)(`ul`,{className:o5,children:t.notes.map(e=>(0,I.jsx)(a5,{note:e,...i},e.id))})]}),a?(0,I.jsx)(XN,{className:`h-full`,icon:(0,I.jsx)(ub,{}),title:`Nothing noted yet`,hint:`Select an area of the app, paste a screenshot, or just type.`}):(0,I.jsxs)(`section`,{"aria-label":`This drive`,children:[!!t?.notes.length&&(0,I.jsx)(WA,{className:`px-4 pt-3`,children:`This drive`}),(0,I.jsx)(`ul`,{className:o5,children:e.map(e=>(0,I.jsx)(a5,{note:e,...i},e.id))})]})]}),(0,I.jsx)(`div`,{className:`flex shrink-0 flex-col gap-2 p-3`,children:r})]})}function c5({count:e,onSend:t,primary:n=!0}){return e===0?null:(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-text-secondary`,children:[e,` `,e===1?`note`:`notes`,` ready`]}),(0,I.jsx)(J,{size:`sm`,variant:n?`primary`:`secondary`,icon:(0,I.jsx)(rb,{}),onClick:t,children:`Send to the agent`})]})}var l5=`Screenshot from the test drive`;function u5({title:e,store:t,hidden:n=!1,stopping:r,onBack:i,onStop:a,stage:o}){let s=rx(),c=(0,F.useContext)(jN),[l,u]=(0,F.useState)(!0),[d,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(``),[h,g]=(0,F.useState)(null),[_,v]=(0,F.useState)([]),y=(0,F.useRef)(null),b=e=>{g({png:e,src:URL.createObjectURL(e)}),u(!0),setTimeout(()=>y.current?.focus(),0)},x=e=>{Gh(e).then(b).catch(e=>s.push(e instanceof Error?e.message:`that image could not be read`))},S=()=>{let e=p.trim()||l5,n=h?.png??null,r=`saving-${Date.now()}`;v(t=>[...t,{id:r,text:e,when:`now`,saving:!0,...h?{picture:h.src}:{}}]),m(``),g(null),t.add(e,n).catch(t=>{m(e===l5?``:e),n&&b(n),s.push(t instanceof Error?t.message:`the note could not be saved`)}).finally(()=>v(e=>e.filter(e=>e.id!==r)))},C=(0,I.jsxs)(I.Fragment,{children:[c,(0,I.jsx)(Y,{label:`Back to the chat`,icon:(0,I.jsx)(wb,{}),tooltipSide:`bottom`,onClick:i}),(0,I.jsx)(`span`,{className:`min-w-0 shrink-[2] truncate px-1 text-sm text-text-secondary`,children:e}),(0,I.jsx)(`span`,{className:`mx-1 h-4 w-px shrink-0 bg-border-subtle`})]}),w=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`mx-1 h-4 w-px shrink-0 bg-border-subtle`}),(0,I.jsx)(J,{size:`sm`,icon:(0,I.jsx)(ab,{}),loading:r,onClick:a,children:`Stop drive`}),(0,I.jsx)(Y,{label:l?`Hide notes`:`Show notes`,icon:(0,I.jsx)(Py,{}),active:l,tooltipSide:`bottom`,onClick:()=>u(e=>!e)})]});return(0,I.jsxs)(`div`,{className:q(`min-h-0 min-w-0 flex-1 animate-fade-in`,n?`hidden`:`flex`),"data-drive-page":!0,children:[(0,I.jsx)(RN,{asideClassName:`@max-4xl:top-(--topbar-h)`,aside:l&&(0,I.jsx)(LN,{title:`Notes`,onClose:()=>u(!1),bodyClassName:`flex flex-col`,children:(0,I.jsx)(s5,{notes:[...t.notes,..._],earlier:t.earlier,sent:t.sent,onOpenPicture:f,onEdit:t.onEdit,onDelete:t.onDelete,onPicture:t.onPicture,foot:(0,I.jsxs)(I.Fragment,{children:[t.send&&(0,I.jsx)(c5,{count:t.send.count,onSend:t.send.run,primary:!p.trim()&&!h}),(0,I.jsx)(e5,{value:p,onChange:m,attachments:h?[{id:`staged`,name:`the picture this note will carry`,src:h.src}]:[],onAttach:e=>{e[0]&&x(e[0])},onRemoveAttachment:()=>g(null),state:`idle`,inputRef:y,multiple:!1,label:`Note`,sendLabel:`Add note`,sendIcon:(0,I.jsx)(Ry,{}),placeholder:`What did you just notice?`,onSend:S})]})})}),children:o({leading:C,trailing:w,onCapture:b})}),(0,I.jsx)(n5,{url:d,onClose:()=>f(null)})]})}var d5=(e,t)=>e.file<t.file?-1:+(e.file>t.file);function f5(e,{withOwnSection:t,runnerConfigured:n}){if(!n)return{own:[],others:[],othersLabel:`Scenarios`,defaultScenario:null};let r=t?e.filter(e=>e.own).sort(d5):[];return{own:r,others:e.filter(e=>!r.includes(e)).sort((e,t)=>{if(!e.group!=!t.group)return e.group?-1:1;let n=(e.group??``).localeCompare(t.group??``);return n===0?d5(e,t):n}),othersLabel:t?`Other scenarios`:`Scenarios`,defaultScenario:r[0]??null}}function p5(e){let t=[];e.own.length>0&&t.push({heading:`This feature`,entries:e.own});for(let n of e.others){let r=n.group??(t.length>0?`Other`:e.othersLabel),i=t[t.length-1];i&&i.heading===r&&i.heading!==`This feature`?i.entries.push(n):t.push({heading:r,entries:[n]})}return t}function m5(e,t){return e?`Test drive · ${e.name}`:t}function h5(e,t){return t?.status===`landed`&&t.entryUrl?{url:t.entryUrl,key:t.landingId??t.entryUrl}:{url:e,key:`plain`}}function g5({scenario:e,scenarios:t,dismissed:n}){return!n&&!e&&t!==void 0&&t.length===0}function _5(e){let t=e.failure,n=t?t.reason===`exit`?typeof t.exitCode==`number`?`exit ${t.exitCode}`:`exited without a code`:t.reason===`no-entry-url`?`printed no ENTRY_URL`:t.reason===`timeout`?`timed out after 2 min`:`no scenario runner set`:`failed`;return`Scenario “${e.name}” failed: ${n}`}var v5=(0,F.createContext)(null);function y5(){return(0,F.useContext)(v5)}function b5(e,t){let[n,r]=(0,F.useState)(null),[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)({kind:`new`}),c=n??e??null,l=(0,F.useRef)(t);l.current=t;let u=(0,F.useCallback)(e=>s(e),[]),d=(0,F.useCallback)(e=>{r(e),a(null),l.current(e)},[]);return(0,F.useMemo)(()=>({sessionId:c,errand:o,listed:!!c&&c!==i,begin:u,opened:d,close:()=>a(c)}),[c,o,i,u,d])}function x5(e){return e.kind===`new`?`Describe the state you want to land in`:`Fix the scenario that failed`}function S5({menu:e,current:t,onPick:n,onNew:r,align:i=`start`}){let a=p5(e),o=e.own.length+e.others.length;return(0,I.jsxs)(DA,{align:i,className:`w-80`,children:[o>8&&(0,I.jsx)(OA,{placeholder:`Search ${o} scenarios`}),(0,I.jsxs)(kA,{label:`Scenarios`,children:[(0,I.jsx)(AA,{children:`No scenario matches`}),a.map(e=>(0,I.jsx)(MA,{heading:e.heading,children:e.entries.map(e=>(0,I.jsxs)(FA,{value:`${e.name} ${e.group??``} ${e.file}`,title:e.file,current:t===e.file,onSelect:()=>n(e.file),children:[e.name,e.hasCall&&(0,I.jsx)(`span`,{className:`ml-2 text-xs text-text-tertiary`,children:`API`})]},e.file))},e.heading)),(0,I.jsxs)(MA,{children:[o>0&&(0,I.jsx)(`div`,{className:`-mx-1 my-1 h-px bg-border-subtle`,role:`separator`}),(0,I.jsx)(FA,{value:`Blank app`,current:t===null,onSelect:()=>n(null),children:`Blank app`}),r&&(0,I.jsx)(FA,{value:`New scenario`,onSelect:r,children:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Ry,{size:14,className:`text-icon`}),`New scenario`]})})]})]})]})}function C5({scenario:e}){return e?.status===`running`?(0,I.jsx)(UE,{size:`sm`}):e?.status===`failed`?(0,I.jsx)(RA,{tone:`danger`,label:`failed`}):e?.status===`landed`?(0,I.jsx)(RA,{tone:`success`,label:`landed`}):(0,I.jsx)(RA,{tone:`neutral`})}function w5({menu:e,scenario:t,blank:n,onPick:r,onNew:i}){let a=t&&!n?t:void 0;return(0,I.jsxs)(TA,{children:[(0,I.jsx)(EA,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,"data-scenario-trigger":``,title:a?`Scenario: ${a.name} — ${a.file}`:`Land on a scenario, or write a new one`,className:q(WE,DY,`flex items-center gap-2`),children:[(0,I.jsx)(`span`,{className:`flex size-3.5 shrink-0 items-center justify-center`,children:(0,I.jsx)(C5,{scenario:a})}),(0,I.jsx)(`span`,{className:q(`min-w-0 truncate`,a?`text-text`:`text-text-secondary`),children:a?a.name:`Blank app`}),(0,I.jsx)(Uy,{size:14,className:`shrink-0 text-icon`})]})}),(0,I.jsx)(S5,{menu:e,current:a?a.file:null,onPick:r,onNew:i})]})}function T5({projectId:e,featureId:t,drive:n,leading:r,trailing:i,footer:a,onCapture:o,onToChat:s}){let c=rx(),l=R.useUtils(),u=R.feature.driveScenarios.useQuery(t?{projectId:e,featureId:t}:{projectId:e}),d=f5(u.data?.scenarios??[],{withOwnSection:!!t,runnerConfigured:u.data?.runnerConfigured??!1}),f=()=>void l.feature.driveInfo.invalidate(),p=R.feature.runScenario.useMutation({onSuccess:e=>{f(),e.ok||c.push(e.denied)},onError:e=>c.push(e.message)}),m=y5(),h=R.feature.openScenarioChat.useMutation({onSuccess:e=>{f(),m?.opened(e.sessionId),s?.()},onError:e=>c.push(e.message)}),[g,_]=(0,F.useState)(null),[v,y]=(0,F.useState)(`app`),[b,x]=(0,F.useState)(null),S=n.scenario,C=!!S?.landingId&&S.landingId===g,w=C?{url:n.devUrl,key:`plain`}:h5(n.devUrl,S),T=rJ(d),E=T&&v===`api`,D=n.branch??n.devUrl,O=g5({scenario:S,scenarios:u.data?.scenarios,dismissed:b===D}),k=t=>{t?p.mutate({projectId:e,file:t}):_(S?.landingId??null)},ee=()=>{m?.begin({kind:`new`}),h.mutate({projectId:e})},A=t=>{m?.begin({kind:`fix`,name:t.name}),h.mutate({projectId:e,fixFile:t.file})},j=S?.status===`running`?(0,I.jsx)(E5,{scenario:S}):S?.status===`failed`?(0,I.jsx)(D5,{scenario:S,fixing:h.isPending,onFix:()=>A(S)}):null,M=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(w5,{menu:d,scenario:S,blank:C,onPick:k,onNew:ee}),T&&(0,I.jsx)(BN,{size:`sm`,label:`Drive view`,className:`w-24`,items:[{value:`app`,label:`App`},{value:`api`,label:`API`}],value:E?`api`:`app`,onChange:y})]}),N=(0,I.jsxs)(I.Fragment,{children:[!E&&j,O&&(0,I.jsxs)(`p`,{className:`m-0 flex shrink-0 items-center gap-2 border-b border-border-subtle py-1 pr-1.5 pl-4 text-xs text-text-tertiary`,children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`Setting this up by hand every time?`,` `,(0,I.jsx)(`button`,{type:`button`,className:q(`cursor-pointer text-accent-text no-underline decoration-accent-text/50 underline-offset-2 transition-colors duration-(--dur-1) ease-app hover:underline hover:decoration-accent-text`,`font-medium`),onClick:ee,children:`Make it a scenario.`})]}),(0,I.jsx)(Y,{size:`sm`,label:`Hide this hint`,icon:(0,I.jsx)(By,{}),onClick:()=>x(D)})]})]});return(0,I.jsx)(FX,{url:w.url,frameKey:w.key,leading:r,toolbar:M,trailing:i,strip:N,footer:a,onCapture:o,cover:E&&(0,I.jsx)(FY,{projectId:e,calls:nJ(d),scenario:S,strip:j,onRun:k})})}function E5({scenario:e}){return(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 border-b border-border-subtle px-4 py-2.5`,role:`status`,children:[(0,I.jsxs)(BA,{spinning:!0,size:`sm`,children:[`Running `,e.name,`…`]}),e.output&&(0,I.jsx)(`pre`,{className:`m-0 max-h-24 overflow-auto font-mono text-xs whitespace-pre-wrap text-text-tertiary`,children:e.output})]})}function D5({scenario:e,fixing:t=!1,onFix:n}){return(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-border-subtle bg-danger-subtle px-4 py-3 text-sm`,role:`alert`,children:[(0,I.jsx)(`span`,{className:`font-medium text-danger-text`,children:_5(e)}),e.failure?.outputTail&&(0,I.jsx)(`pre`,{className:`m-0 max-h-40 overflow-auto rounded-md bg-surface-inset px-2.5 py-2 font-mono text-xs whitespace-pre-wrap text-text-secondary`,children:e.failure.outputTail}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(J,{size:`sm`,variant:`primary`,icon:(0,I.jsx)(Ky,{}),loading:t,onClick:n,children:`Fix it`}),(0,I.jsx)(`span`,{className:`text-xs text-text-tertiary`,children:`Opens the scenario chat with this file and its output`})]})]})}function O5({featureId:e,failure:t,onToChat:n}){let r=R.useUtils(),i=rx(),a=hx(e),o=R.feature.fixDrive.useMutation({onSuccess:()=>{r.feature.get.invalidate({id:e}),r.events.invalidate(),a(),n?.()},onError:e=>i.push(e.message)});return(0,I.jsx)(k5,{failure:t,explanation:(0,I.jsxs)(I.Fragment,{children:[`The branch is checked out, but `,(0,I.jsx)(`code`,{className:`font-mono`,children:t.command}),` `,t.outcome,` — so whatever it was meant to bring up is probably not running. An agent can read this failure on your machine, repair the environment and retry the drive.`]}),children:t.canFix&&(0,I.jsx)(J,{className:`self-start`,icon:(0,I.jsx)(Db,{}),loading:o.isPending,onClick:()=>o.mutate({featureId:e}),children:`Fix drive`})})}function k5({failure:e,explanation:t,children:n}){return(0,I.jsxs)(`div`,{className:`flex w-full max-w-[64ch] flex-col gap-3 self-center`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(BA,{tone:`danger`,icon:(0,I.jsx)(Sb,{}),size:`sm`,strong:!0,children:`Drive setup failed`}),(0,I.jsx)(`div`,{className:`text-sm text-pretty text-text-secondary`,children:t})]}),e.output&&(0,I.jsx)($N,{title:`What the command printed`,icon:(0,I.jsx)(Ky,{}),children:(0,I.jsx)(`pre`,{className:`m-0 max-h-55 overflow-auto rounded-md bg-surface-inset px-3 py-2.5 font-mono text-xs whitespace-pre-wrap text-text-secondary`,children:e.output})}),n]})}function A5({branch:e,drive:t,where:n}){let[r,i]=(0,F.useState)(!1),a=Mv(t);return(0,I.jsxs)(I.Fragment,{children:[r&&t?.devPaneId&&(0,I.jsx)(`div`,{className:`relative h-60 shrink-0 overflow-hidden border-t border-border-subtle bg-surface-inset animate-fade-in`,children:(0,I.jsx)(oq,{label:`dev terminal`,children:(0,I.jsx)(c6,{sessionId:t.devPaneId})})}),(0,I.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-3 overflow-hidden border-t border-border-subtle px-3 text-xs text-text-tertiary`,children:[t?.devPaneId&&(0,I.jsx)(`span`,{className:`shrink-0`,children:(0,I.jsx)(BA,{tone:`live`,children:`Dev server`})}),(0,I.jsx)(`span`,{className:`max-w-48 shrink-0 truncate font-mono`,title:e,children:e}),a&&(0,I.jsx)(`span`,{className:`min-w-0 shrink-[2] truncate font-mono`,title:a.state===`ready`?a.url:void 0,children:a.state===`ready`?a.url:Nv(a)}),n&&(0,I.jsx)(`span`,{className:`min-w-0 shrink-[3] truncate font-mono`,title:n.title,children:n.text}),(0,I.jsx)(`span`,{className:`flex-1`}),t?.devPaneId&&(0,I.jsx)(J,{size:`sm`,variant:`ghost`,icon:(0,I.jsx)(Ky,{}),"aria-expanded":r,onClick:()=>i(e=>!e),children:r?`Hide output`:`Output`})]})]})}function j5({state:e,leading:t,trailing:n,footer:r,children:i}){return(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,I.jsxs)(`div`,{className:`flex h-(--topbar-h) shrink-0 items-center gap-1 border-b border-border-subtle px-2`,children:[t,(0,I.jsx)(`span`,{className:`min-w-0 truncate px-1.5`,children:e}),(0,I.jsx)(`span`,{className:`flex-1`}),n]}),(0,I.jsx)(`div`,{className:`flex min-h-65 flex-1 flex-col items-center justify-center overflow-auto bg-surface-inset px-8 py-10`,children:i}),r]})}function M5({projectId:e,featureId:t,branch:n,driveState:r,drive:i,dryRun:a=!1,failure:o,failureExit:s,where:c,leading:l,trailing:u,onCapture:d,onToChat:f}){let p=(0,I.jsx)(A5,{branch:i?.branch??n,drive:i,where:c}),m=(e,t,n=!0)=>(0,I.jsx)(j5,{state:e,leading:l,trailing:u,footer:n?p:void 0,children:t});if(r===`idle`)return a?m((0,I.jsx)(BA,{tone:`neutral`,children:`Drive held`}),(0,I.jsx)(XN,{icon:(0,I.jsx)(ob,{}),title:`A preparation dry run is holding the drive`,hint:(0,I.jsx)(I.Fragment,{children:`It is proving this project’s drive commands on your machine. Stop it from Preparation, and this branch can take the wheel.`})}),!1):m((0,I.jsx)(BA,{spinning:!0,children:`Starting`}),(0,I.jsx)(XN,{icon:(0,I.jsx)(UE,{}),title:`Starting the test drive`,hint:(0,I.jsx)(I.Fragment,{children:`Checking the branch out.`})}),!1);switch(Bv(r).stageKind){case`starting`:return m((0,I.jsx)(BA,{spinning:!0,children:`Starting`}),(0,I.jsx)(XN,{icon:(0,I.jsx)(UE,{}),title:`Starting the dev server`,hint:(0,I.jsx)(I.Fragment,{children:`The branch is checked out and the project’s dev command is running. The app appears here as soon as it answers; its output is under the window.`})}));case`failed`:return m((0,I.jsx)(BA,{tone:`danger`,children:`Setup failed`}),o?s?s(o):t?(0,I.jsx)(O5,{featureId:t,failure:o,onToChat:f}):null:(0,I.jsx)(XN,{icon:(0,I.jsx)(Ky,{}),title:`The drive’s setup command failed`,hint:(0,I.jsx)(I.Fragment,{children:`Its output is in the timeline.`})}));case`bare`:return m((0,I.jsx)(BA,{tone:`neutral`,children:`Nothing started`}),(0,I.jsx)(XN,{icon:(0,I.jsx)(Ky,{}),title:`Branch checked out, nothing started`,hint:(0,I.jsxs)(I.Fragment,{children:[`This project has no dev command.`,` `,` `,(0,I.jsx)(iL,{location:{page:`project`,field:`devCommand`},children:`Set one in Settings`}),` `,` and the next drive boots the app right here.`]})}));case`agent`:if(t)return i?.devUrl?(0,I.jsx)(FX,{url:i.devUrl,agentDriving:!0,leading:l,trailing:u,footer:p,onCapture:d}):m((0,I.jsx)(BA,{tone:`live`,children:`Review agent driving`}),(0,I.jsx)(XN,{icon:(0,I.jsx)(xb,{}),title:`No dev server answered`,hint:(0,I.jsx)(I.Fragment,{children:`The review agent is driving this branch. Its notes land as it finds things.`})}));break}return i?.devUrl?(0,I.jsx)(T5,{projectId:e,featureId:t,drive:{...i,devUrl:i.devUrl},leading:l,trailing:u,footer:p,onCapture:d,onToChat:f}):m((0,I.jsx)(BA,{tone:`live`,children:`Running`}),(0,I.jsx)(XN,{icon:(0,I.jsx)(xb,{}),title:`Waiting for an address`,hint:(0,I.jsx)(I.Fragment,{children:`The dev server is up but has not printed an address yet. Its output is under the window.`})}))}var N5=e=>[...e].sort((e,t)=>e.createdAt-t.createdAt);function P5(e){return{id:e.id,text:e.text,when:hg(e.createdAt),...e.screenshotUrl?{picture:e.screenshotUrl}:{}}}function F5(e){let t=N5(e).filter(e=>e.author===`human`&&(e.status===`open`||e.status===`carried`));return{open:t.filter(e=>e.sentAt===void 0),sent:t.filter(e=>e.sentAt!==void 0)}}function I5(e,t){let n=R.useUtils(),r=rx(),i=R.notes.list.useQuery({featureId:e}),a=()=>n.notes.list.invalidate({featureId:e}),o=e=>r.push(e.message),s=R.notes.add.useMutation(),c=R.notes.edit.useMutation({onSuccess:a,onError:o}),l=R.notes.remove.useMutation({onSuccess:a,onError:o}),u=R.notes.send.useMutation({onSuccess:()=>{a(),n.notes.delivery.invalidate({featureId:e})},onError:o}),d=i.data??[],{open:f,sent:p}=F5(d);return{notes:f.map(P5),sent:p.map(P5),send:{count:$6(d).length,run:()=>{u.mutate({featureId:e}),t()}},add:async(t,n)=>{let i=await s.mutateAsync({featureId:e,text:t});n&&await Kh(i.id,n).catch(e=>r.push(`the note was saved, but its picture was not: ${e instanceof Error?e.message:String(e)}`)),await a()},onEdit:(e,t)=>c.mutate({noteId:e,text:t}),onDelete:e=>l.mutate({noteId:e}),onPicture:(e,t)=>{Gh(t).then(t=>Kh(e,t)).then(a).catch(e=>r.push(e instanceof Error?e.message:`that picture could not be attached`))}}}function L5(e,t){let n=R.useUtils(),r=rx(),i=R.projectNotes.list.useQuery({projectId:e},{refetchInterval:tg()}),a=()=>n.projectNotes.invalidate(),o=e=>r.push(e.message),s=R.projectNotes.add.useMutation(),c=R.projectNotes.edit.useMutation({onSuccess:a,onError:o}),l=R.projectNotes.delete.useMutation({onSuccess:a,onError:o}),{thisDrive:u,alreadyOpen:d}=ux(i.data??[],t);return{notes:N5(u).map(P5),earlier:{title:`Already open`,notes:N5(d).map(P5)},add:async(t,n)=>{let i=await s.mutateAsync({projectId:e,text:t});n&&await ax(i.id,n).catch(e=>r.push(`the note was saved, but its picture was not: ${e instanceof Error?e.message:String(e)}`)),await a()},onEdit:(e,t)=>c.mutate({noteId:e,text:t}),onDelete:e=>l.mutate({noteId:e}),onPicture:(e,t)=>{Gh(t).then(t=>ax(e,t)).then(a).catch(e=>r.push(e instanceof Error?e.message:`that picture could not be attached`))}}}function R5({full:e,hidden:t,stopping:n,onBack:r,onStop:i}){let{feature:a}=e,o=R.feature.driveInfo.useQuery({projectId:a.projectId},{refetchInterval:tg()}),s=o.data?.featureId===a.id?o.data:void 0,c=I5(a.id,r);return(0,I.jsx)(u5,{title:a.title,store:c,hidden:t,stopping:n,onBack:r,onStop:i,stage:t=>(0,I.jsx)(M5,{projectId:a.projectId,featureId:a.id,branch:a.branch,driveState:s?.state??`idle`,drive:s,dryRun:o.data?.dryRun??!1,failure:Fv(s,{sessionLive:!!Tv(e.sessions)}),onToChat:r,...t})})}var z5=5e3,B5=new Set([`tickets.stored`,`ticket.edited`,`ticket.cancelled`]),V5=/^ticket (\d+) failed(?::\s*(.*))?$/s,H5=/(\d+)\/(\d+) tickets done/;function U5(e,t=[]){let n=t=>({...t,count:1,eventId:e.id});if(e.type===`docs.changed`){let t=W5(e),r=e=>t.some(t=>t===e||t.endsWith(`/${e}`));return r(`preview.html`)?n({kind:`preview`,hue:`planning`,title:`Preview ready`,subtitle:fi,actionLabel:`View preview`,target:`plan`}):r(`spec.md`)?n({kind:`spec`,hue:`planning`,title:`Spec written`,subtitle:`spec.md`,actionLabel:`View spec`,target:`plan`}):null}if(B5.has(e.type))return n({kind:`tickets`,hue:`tickets`,title:`Tickets updated`,subtitle:e.message,actionLabel:`View tickets`,target:`work`});if(e.type===`ticket.failed`){let t=V5.exec(e.message);return n({kind:`ticket-failed`,hue:`danger`,title:t?`Ticket #${t[1]} failed`:`Ticket failed`,subtitle:t?.[2]?.trim()||e.message,actionLabel:`View run`,target:`work`})}if(e.type===`run.finished`){let t=e.data??{},r=t.status!==`succeeded`,i=typeof t.summary==`string`?t.summary:e.message,a=H5.exec(i);return n({kind:`run`,hue:r?`danger`:`building`,title:r?`Run finished with failures`:`Run finished`,subtitle:a?`${a[1]} of ${a[2]} landed`:i,actionLabel:`View run`,target:`work`})}if(e.type===`ticket.done`){let r=t.find(t=>t.id===e.ticketId);return r?.kind!==`review`||r.passKind===`verification`?null:n({kind:`review`,hue:`review`,title:`Review ready`,subtitle:r.title,actionLabel:`View review`,target:`work`})}if(e.type===`testdrive.url`){let t=e.data??{};return n({kind:`drive`,hue:`review`,title:`Test drive running`,subtitle:typeof t.url==`string`?t.url:e.message,actionLabel:`Open`,target:`drive`,expiresAfterMs:z5})}return null}function W5(e){let t=e.data?.files;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function G5(e,t){switch(t.type){case`push`:{let n=e.find(e=>e.kind===t.notice.kind);return[n?{...t.notice,count:n.count+t.notice.count}:t.notice,...e.filter(e=>e.kind!==t.notice.kind)].slice(0,4)}case`dismiss`:case`act`:return e.filter(e=>e.kind!==t.kind)}}var K5={planning:`text-phase-planning`,tickets:`text-phase-tickets`,building:`text-phase-building`,review:`text-phase-review`,danger:`text-danger`};function q5(e){return e===`danger`?(0,I.jsx)(Sb,{size:16}):(0,I.jsx)(Kb,{phase:e,label:``})}var J5=`border-b border-border-subtle`;function Y5({notices:e,standing:t=[],onAct:n,onDismiss:r}){let[i,a]=(0,F.useState)(!1);if(e.length===0&&t.length===0)return null;let[o,...s]=e;return(0,I.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-label":`Chat notifications`,className:q(Hq,`flex flex-col overflow-hidden animate-rise-in`),children:[t.map((e,n)=>(0,I.jsx)(Z5,{hue:e.hue,title:e.title,subtitle:e.subtitle,...e.tooltip?{tooltip:e.tooltip}:{},...e.action?{action:e.action}:{},...e.onDismiss?{onDismiss:e.onDismiss}:{},...o||n<t.length-1?{className:J5}:{}},e.key)),i&&[...s].reverse().map(e=>(0,I.jsx)(X5,{notice:e,onAct:n,onDismiss:r,className:J5},`${e.kind}-${e.eventId}`)),o&&(0,I.jsx)(X5,{notice:o,onAct:n,onDismiss:r,aside:s.length>0&&(0,I.jsx)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>a(!i),className:q(`border-0 bg-transparent`,`h-6 shrink-0 cursor-pointer rounded-md px-1.5 text-xs tabular-nums text-text-tertiary`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover hover:text-text-secondary`),children:i?`Show less`:`+${s.length} more`})},`${o.kind}-${o.eventId}`)]})}function X5({notice:e,onAct:t,onDismiss:n,aside:r,className:i}){return(0,I.jsx)(Z5,{hue:e.hue,title:e.title,count:e.count,subtitle:e.subtitle,aside:r,action:{label:e.actionLabel,onClick:()=>t(e.kind)},onDismiss:()=>n(e.kind),...i?{className:i}:{}})}function Z5({hue:e,title:t,count:n=1,subtitle:r,tooltip:i,aside:a,action:o,onDismiss:s,className:c}){return(0,I.jsxs)(`article`,{"data-hue":e,title:i,className:q(`flex h-11 min-w-0 items-center gap-2.5 pr-2 pl-3.5 text-sm animate-fade-in`,c),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,className:q(`grid shrink-0 place-items-center`,K5[e]),children:q5(e)}),(0,I.jsx)(`span`,{className:`shrink-0 font-medium text-text`,children:t}),n>1&&(0,I.jsxs)(`span`,{"aria-label":`${n} times`,className:`shrink-0 text-xs tabular-nums text-text-tertiary`,children:[`×`,n]}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-text-secondary`,children:r}),a,o&&(0,I.jsx)(J,{size:`sm`,disabled:o.disabled,onClick:o.onClick,className:`shrink-0`,children:o.label}),s&&(0,I.jsx)(Y,{label:`Dismiss`,size:`sm`,icon:(0,I.jsx)(By,{size:12}),onClick:s})]})}function Q5({events:e,tickets:t,standing:n=[],active:r,onView:i,readyToTest:a=!1}){let[o,s]=(0,F.useReducer)(G5,[]),c=zx(),l=c?o.filter(e=>e.target!==`drive`):o,u=(0,F.useRef)(null),d=(0,F.useRef)(0);return(0,F.useEffect)(()=>{if(!r){u.current=null;return}let n=u.current??=Date.now();for(let r of e){if(r.id<=d.current||(d.current=r.id,r.ts<n))continue;let e=U5(r,t);e&&s({type:`push`,notice:e})}},[r,e,t]),(0,F.useEffect)(()=>{let e=o.flatMap(e=>e.expiresAfterMs===void 0?[]:[setTimeout(()=>s({type:`dismiss`,kind:e.kind}),e.expiresAfterMs)]);return()=>e.forEach(clearTimeout)},[o]),(0,I.jsxs)(I.Fragment,{children:[c&&a&&(0,I.jsx)(`p`,{className:`m-0 mb-1.5 px-3 text-xs text-text-tertiary`,children:`Ready to test. The test drive is on your computer; you can still talk here.`}),(0,I.jsx)(Y5,{notices:l,standing:n,onAct:e=>{let t=o.find(t=>t.kind===e);s({type:`act`,kind:e}),t&&i(t.target)},onDismiss:e=>s({type:`dismiss`,kind:e})})]})}var $5=1e6;function e7(e){return`${e.src}?download=${encodeURIComponent(e.name)}`}function t7(e,t){let[n,r]=(0,F.useState)({state:`loading`});return(0,F.useEffect)(()=>{if(!t)return;let n=!0;r({state:`loading`});let i=e.size>$5?{headers:{Range:`bytes=0-${$5-1}`}}:void 0;return fetch(e.src,i).then(e=>{if(!e.ok)throw Error(String(e.status));return e.text()}).then(e=>n&&r({state:`read`,text:e})).catch(()=>n&&r({state:`failed`})),()=>{n=!1}},[e.src,e.size,t]),n}function n7({file:e,read:t,children:n}){return t.state===`failed`?(0,I.jsx)(`div`,{className:`px-6 pt-4`,children:(0,I.jsxs)(YN,{children:[`Could not read `,e.name,`.`]})}):t.state===`loading`?(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[680px] px-6 pt-4`,children:(0,I.jsx)(qK,{label:`Loading ${e.name}…`})}):(0,I.jsx)(I.Fragment,{children:n(t.text)})}function r7({file:e}){let{resolved:t}=uF(),n=t7(e,e.as!==`image`),r=e.size>$5&&(0,I.jsxs)(`p`,{className:`m-0 mb-3 text-xs text-text-tertiary`,children:[`Showing the first `,mg($5),` of `,mg(e.size),`. Download it for the rest.`]});switch(e.as){case`image`:return(0,I.jsx)(`div`,{className:`min-h-0 flex-1 bg-surface-inset p-3`,children:(0,I.jsx)(`img`,{src:e.src,alt:e.caption??e.name,className:`block h-full w-full object-contain`})});case`html`:return(0,I.jsx)(n7,{file:e,read:n,children:e=>(0,I.jsx)(nq,{srcDoc:eq(e,t),className:`min-h-0 w-full flex-1`})});case`markdown`:return(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,I.jsxs)(`div`,{className:`mx-auto w-full max-w-[680px] px-6 pt-4 pb-12`,children:[r,(0,I.jsx)(n7,{file:e,read:n,children:e=>(0,I.jsx)(VK,{source:e,size:`base`})})]})});default:return(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto bg-surface-inset px-5 py-4`,children:[r,(0,I.jsx)(n7,{file:e,read:n,children:e=>(0,I.jsx)(`pre`,{className:`m-0 font-mono text-xs break-words whitespace-pre-wrap text-text-secondary`,children:e})})]})}}function i7({file:e,onClose:t}){let n=zx()?`touch`:`sm`;return(0,I.jsxs)(aP,{open:!0,onClose:t,labelledBy:`shown-file-title`,size:`full`,className:`flex h-[86vh] flex-col overflow-hidden`,children:[(0,I.jsxs)(`div`,{className:`flex h-(--topbar-h) shrink-0 items-center gap-2 border-b border-border-subtle pr-2 pl-5`,children:[e.as===`image`?(0,I.jsx)(Pb,{size:16,className:`shrink-0 text-icon`}):(0,I.jsx)(Jy,{size:16,className:`shrink-0 text-icon`}),(0,I.jsx)(`h2`,{id:`shown-file-title`,className:`m-0 max-w-[50%] shrink-0 truncate text-sm font-medium text-text`,children:e.name}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-text-tertiary`,title:e.path,children:e.path}),(0,I.jsx)(Y,{label:`Download`,size:n,icon:(0,I.jsx)(Nb,{}),href:e7(e)}),(0,I.jsx)(Y,{label:`Close`,size:n,icon:(0,I.jsx)(By,{}),onClick:t})]}),e.caption&&(0,I.jsx)(`p`,{className:`m-0 shrink-0 border-b border-border-subtle px-5 py-2 text-sm text-text-secondary`,children:e.caption}),(0,I.jsx)(r7,{file:e})]})}var a7=4,o7=1e7;function s7(e){return e.as===`image`&&e.size<=o7}function c7(e){if(e.as===`markdown`)return`Markdown`;if(e.as===`html`)return`HTML`;let t=e.name.lastIndexOf(`.`),n=t>0?e.name.slice(t+1):``;return n.length>0&&n.length<=5?n.toUpperCase():e.as===`text`?`Text`:`File`}function l7({file:e,onOpen:t}){return(0,I.jsxs)(`figure`,{className:`m-0 flex min-w-0 flex-col items-start gap-1.5`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Open ${e.name}`,className:`block max-w-full cursor-zoom-in rounded-lg`,children:(0,I.jsx)(`img`,{src:e.src,alt:e.caption??e.name,className:`block max-h-[420px] max-w-full rounded-lg bg-surface-inset object-contain ring-1 ring-border-subtle`})}),e.caption&&(0,I.jsx)(`figcaption`,{className:`text-sm text-text-secondary`,children:e.caption})]})}function u7({file:e,onOpen:t}){let n=e.as!==`browser`&&e.as!==`download`,r=n?(0,I.jsx)(Wy,{}):e.as===`browser`?(0,I.jsx)(mb,{}):(0,I.jsx)(Nb,{});return(0,I.jsx)(`div`,{className:q(Uq,`overflow-hidden`),children:(0,I.jsx)(JA,{leading:e.as===`image`?(0,I.jsx)(Pb,{}):(0,I.jsx)(Jy,{}),title:e.name,description:e.caption??`${c7(e)} · ${mg(e.size)}`,meta:(0,I.jsx)(`span`,{className:`inline-flex text-icon`,children:r}),label:`${n?`Open`:e.as===`browser`?`Open in a new tab:`:`Download`} ${e.name}`,onClick:t})})}function d7(e){let t=[];for(let n of e){let e=s7(n),r=t.at(-1);r?.images===e?r.files.push(n):t.push({images:e,files:[n]})}return t}function f7({files:e}){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(null),a=t?0:Math.max(0,e.length-a7),o=e=>{e.as===`browser`?window.open(e.src,`_blank`,`noopener`):e.as===`download`?window.location.assign(e7(e)):i(e)};return(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 animate-fade-in`,children:[d7(a?e.slice(0,a7):e).map(e=>e.images?(0,I.jsx)(`div`,{className:`grid min-w-0 grid-cols-1 gap-3`,children:e.files.map(e=>(0,I.jsx)(l7,{file:e,onOpen:()=>o(e)},e.id))},e.files[0].id):(0,I.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:e.files.map(e=>(0,I.jsx)(u7,{file:e,onOpen:()=>o(e)},e.id))},e.files[0].id)),a>0&&(0,I.jsxs)(J,{variant:`ghost`,size:`sm`,icon:(0,I.jsx)(Uy,{}),onClick:()=>n(!0),className:`-ml-2 self-start`,children:[`Show `,a,` more`]}),r&&(0,I.jsx)(i7,{file:r,onClose:()=>i(null)})]})}function p7({items:e,state:t,emptyHint:n,empty:r,loading:i,actions:a,onDropImages:o,footer:s}){let c=(0,F.useRef)(null),l=(0,F.useRef)(null),u=(0,F.useRef)(null),[d,f]=(0,F.useState)(!0),[p,m]=(0,F.useState)(160),[h,g]=(0,F.useState)(0),[_,v]=(0,F.useState)(!1);(0,F.useLayoutEffect)(()=>{let e=l.current,t=c.current;if(!e||!t)return;let n=new ResizeObserver(()=>{m(e.offsetHeight),g(t.offsetWidth-t.clientWidth)});return n.observe(e),n.observe(t),()=>n.disconnect()},[]);let y=(0,F.useRef)(0),b=e=>{e.scrollTop=e.scrollHeight,y.current=e.scrollTop};(0,F.useEffect)(()=>{let e=c.current;e&&d&&b(e)},[e,t,d,p]);let x=(0,F.useRef)(d);x.current=d,(0,F.useLayoutEffect)(()=>{let e=c.current,t=u.current;if(!e||!t)return;let n=()=>{x.current&&b(e)},r=new ResizeObserver(n);return r.observe(t),e.addEventListener(`load`,n,!0),()=>{r.disconnect(),e.removeEventListener(`load`,n,!0)}},[]);let S=()=>{let e=c.current;if(!e)return;let t=e.scrollTop<y.current;y.current=e.scrollTop,e.scrollHeight-e.scrollTop-e.clientHeight<32?f(!0):t&&f(!1)},C=e=>[...e.dataTransfer.items].some(e=>e.type.startsWith(`image/`));return(0,I.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,onDragOver:e=>{!o||!C(e)||(e.preventDefault(),v(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||v(!1)},onDrop:e=>{v(!1);let t=[...e.dataTransfer.files].filter(e=>e.type.startsWith(`image/`));t.length&&o&&(e.preventDefault(),o(t))},children:[(0,I.jsx)(`div`,{ref:c,onScroll:S,className:`min-h-0 flex-1 overflow-y-auto px-6 [scrollbar-gutter:stable] [scrollbar-width:thin] [scrollbar-color:var(--color-border-strong)_transparent]`,children:(0,I.jsx)(`div`,{ref:u,className:`mx-auto flex w-full max-w-(--content-max) flex-col pt-8`,style:{paddingBottom:p+56},children:e.length===0&&i?(0,I.jsxs)(`p`,{role:`status`,className:`m-0 flex animate-fade-in items-center justify-center gap-2 pt-[12vh] text-sm text-text-tertiary [animation-delay:var(--dur-3)]`,children:[(0,I.jsx)(UE,{}),`Loading the thread…`]}):e.length===0?(0,I.jsx)(`div`,{className:`pt-[12vh]`,children:r??(0,I.jsx)(XN,{icon:(0,I.jsx)(qy,{}),title:`New thread`,hint:n})}):e.map((n,r)=>{if(n.kind===`changes`&&e[r-1]?.kind===`agent`)return null;let i=e[r+1];return(0,I.jsx)(`div`,{className:q(`flex min-w-0 flex-col`,r>0&&(h7(n)?`mt-10`:`mt-3`)),children:(0,I.jsx)(m7,{item:n,actions:a,locked:t!==`idle`,...n.kind===`agent`&&i?.kind===`changes`?{changes:i.files}:{}})},n.id)})})}),(0,I.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 h-6 bg-[linear-gradient(to_bottom,var(--color-surface),transparent)]`,style:{right:h}}),(0,I.jsxs)(`div`,{ref:l,className:`pointer-events-none absolute inset-x-0 bottom-0 pb-4 pl-6`,style:{paddingRight:24+h},children:[(0,I.jsx)(`div`,{className:`absolute inset-x-0 -top-6 bottom-0 bg-[linear-gradient(to_bottom,transparent,var(--color-surface)_24px)]`}),(0,I.jsxs)(`div`,{className:`pointer-events-auto relative mx-auto w-full max-w-(--content-max)`,children:[!d&&(0,I.jsx)(Y,{label:`Jump to the newest`,icon:(0,I.jsx)(Uy,{}),variant:`secondary`,onClick:()=>c.current?.scrollTo({top:c.current.scrollHeight,behavior:`smooth`}),className:`absolute -top-11 left-1/2 -translate-x-1/2 animate-pop-in`}),s]})]}),_&&(0,I.jsx)(`div`,{className:`pointer-events-none absolute inset-3 z-10 grid place-items-center rounded-lg border-2 border-dashed border-accent bg-[color-mix(in_oklab,var(--color-accent)_8%,transparent)] animate-fade-in`,children:(0,I.jsxs)(`span`,{className:`flex items-center gap-2 rounded-md bg-surface-raised px-3 py-2 text-sm text-text shadow-popover`,children:[(0,I.jsx)(Pb,{size:16,className:`text-accent`}),`Drop to attach to your message`]})})]})}function m7({item:e,actions:t,locked:n,changes:r}){switch(e.kind){case`user`:return e.from===`runcastle`?(0,I.jsx)(w7,{text:e.text}):(0,I.jsx)(y7,{item:e,actions:t,locked:n});case`work`:return(0,I.jsx)(v8,{steps:e.steps,seconds:e.seconds,live:e.live});case`agent`:return(0,I.jsx)(b7,{item:e,actions:t,...r?{changes:r}:{}});case`changes`:return(0,I.jsx)(R8,{files:e.files});case`shown`:return(0,I.jsx)(f7,{files:e.files});case`review_package`:return(0,I.jsx)(ZY,{ticketId:e.ticketId});case`answered`:return(0,I.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-1.5 text-sm text-text-tertiary`,children:[e.denied?(0,I.jsx)(By,{size:14,className:`shrink-0 text-icon`}):(0,I.jsx)(zy,{size:14,className:`shrink-0 text-icon`}),(0,I.jsx)(`span`,{className:`shrink-0`,children:e.what}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-text-secondary`,children:e.answer})]});case`stopped`:return(0,I.jsxs)(`p`,{className:`m-0 flex items-center gap-1.5 text-sm text-text-tertiary`,children:[(0,I.jsx)(ab,{size:13,className:`shrink-0 text-icon`}),`Stopped by you`]});case`compacted`:return(0,I.jsx)(g7,{children:`Conversation compacted — earlier turns are summarised for the agent`});case`model`:return(0,I.jsxs)(g7,{children:[`Now on `,e.model,e.effort&&` · ${e.effort.charAt(0).toUpperCase()}${e.effort.slice(1)} effort`]});case`error`:return(0,I.jsx)(T7,{children:e.message});case`notice`:return(0,I.jsx)(g7,{children:e.text})}}function h7(e){return e.kind===`user`||e.kind===`compacted`||e.kind===`model`||e.kind===`notice`}function g7({children:e}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-text-tertiary`,children:[(0,I.jsx)(`span`,{className:`h-px flex-1 bg-border-subtle`}),e,(0,I.jsx)(`span`,{className:`h-px flex-1 bg-border-subtle`})]})}function _7({align:e,children:t}){return zx()?null:(0,I.jsx)(`div`,{className:q(`absolute z-1 flex gap-0.5 opacity-0 transition-opacity duration-(--dur-1) ease-app`,`group-hover/msg:opacity-100 group-focus-within/msg:opacity-100`,e===`beside`?`right-full bottom-1.5 pr-1.5`:`top-full -left-1.5 pt-2`),children:t})}function v7({text:e}){let[t,n]=(0,F.useState)(!1);return(0,I.jsx)(Y,{label:t?`Copied`:`Copy`,icon:t?(0,I.jsx)(zy,{}):(0,I.jsx)(hb,{}),size:`sm`,onClick:()=>{navigator.clipboard?.writeText(e),n(!0),window.setTimeout(()=>n(!1),1200)}})}function y7({item:e,actions:t,locked:n}){let[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(e.text),[s,c]=(0,F.useState)(!0);if(r)return(0,I.jsxs)(`div`,{className:q(Hq,`ml-auto flex w-full max-w-[85%] flex-col gap-2 p-3 animate-pop-in`),children:[(0,I.jsx)(`textarea`,{autoFocus:!0,value:a,onChange:e=>o(e.target.value),rows:Math.min(8,a.split(`
|
|
186
|
-
`).length+1),className:`w-full resize-none border-0 bg-transparent font-sans text-base text-text outline-none`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border-subtle pt-2`,children:[(0,I.jsx)(`span`,{className:`text-xs text-text-tertiary`,children:`Rewinds the thread to here and sends this instead.`}),t?.canUndoFiles&&(0,I.jsx)(HN,{checked:s,onChange:c,label:`Also undo the agent’s file edits since — changes made by shell commands stay`}),(0,I.jsxs)(`span`,{className:`ml-auto flex gap-1.5`,children:[(0,I.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>i(!1),children:`Cancel`}),(0,I.jsx)(J,{size:`sm`,variant:`primary`,disabled:!a.trim(),onClick:()=>{i(!1),t?.onEdit?.(e.id,a,s)},children:`Rewind and send`})]})]})]});let l=!e.starting&&!e.steered&&(0,I.jsxs)(_7,{align:`beside`,children:[(0,I.jsx)(v7,{text:e.text}),t?.onBranch&&(0,I.jsx)(Y,{label:`Branch into a new thread from here`,icon:(0,I.jsx)(Ib,{}),size:`sm`,onClick:()=>t.onBranch?.(e.id)}),t?.onEdit&&(0,I.jsx)(Y,{label:n?`Edit — stop the turn first`:`Edit and rewind to here`,icon:(0,I.jsx)(Yy,{}),size:`sm`,disabled:n,onClick:()=>i(!0)})]});return(0,I.jsxs)(`div`,{className:`group/msg flex flex-col items-end gap-1.5 animate-rise-in`,children:[e.images&&e.images.length>0&&(0,I.jsxs)(`div`,{className:`relative flex flex-wrap justify-end gap-2`,children:[e.images.map(e=>(0,I.jsx)(`img`,{src:e.src,alt:e.name,className:`max-h-44 max-w-64 rounded-lg object-cover ring-1 ring-border-subtle`},e.id)),!e.text&&l]}),e.text&&(0,I.jsxs)(`div`,{className:`relative max-w-[85%]`,children:[(0,I.jsx)(`div`,{className:q(`rounded-lg bg-fill-well shadow-[inset_0_1px_0_color-mix(in_oklab,var(--color-text)_5%,transparent),inset_0_0_0_1px_var(--color-border-subtle)]`,`px-3.5 py-2.5 text-base break-words whitespace-pre-wrap text-text`),children:e.text}),l]}),e.starting?(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-text-tertiary`,children:[(0,I.jsx)(UE,{size:`sm`}),(0,I.jsx)(`span`,{className:`text-shimmer`,children:`Starting the agent…`})]}):e.steered&&(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-text-tertiary`,children:[(0,I.jsx)(nb,{size:12,className:`text-icon`}),`Sent into the running turn`]})]})}function b7({item:e,actions:t,changes:n}){return(0,I.jsxs)(`div`,{className:`group/msg relative flex flex-col gap-3 animate-fade-in`,children:[(0,I.jsx)(VK,{source:e.text,size:`base`,tone:`primary`,breaks:!0}),n&&(0,I.jsx)(R8,{files:n}),(0,I.jsxs)(_7,{align:`start`,children:[(0,I.jsx)(v7,{text:e.text}),t?.onBranch&&(0,I.jsx)(Y,{label:`Branch into a new thread from here`,icon:(0,I.jsx)(Ib,{}),size:`sm`,onClick:()=>t.onBranch?.(e.id)}),e.model&&(0,I.jsx)(`span`,{className:`self-center pl-1 text-xs text-text-tertiary`,children:e.model})]})]})}var x7=/^\s*\[runcastle\]\s*/gm,S7=140;function C7(e){let t=e.split(`
|
|
187
|
-
`,1)[0].trim(),n=/^.+?[.!?](?=\s|$)/.exec(t)?.[0]??t,r=n.lastIndexOf(` `,S7),i=n.length<=S7?n:`${n.slice(0,r>0?r:S7).replace(/[\s,;:]+$/,``)}…`;return{head:i,rest:i!==e.trim()}}function w7({text:e}){let t=e.replace(x7,``),{head:n,rest:r}=C7(t),[i,a]=(0,F.useState)(!1);return(0,I.jsxs)(`p`,{className:q(`m-0 flex min-w-0 gap-2 text-sm text-text-tertiary`,i?`items-start`:`items-center`),children:[(0,I.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center rounded-sm bg-accent-subtle text-accent-text`,children:(0,I.jsx)(Zy,{size:12})}),(0,I.jsxs)(`span`,{className:q(`min-w-0`,i&&`whitespace-pre-wrap break-words`),children:[(0,I.jsx)(`span`,{className:`font-medium text-text-secondary`,children:`Runcastle`}),` · `,i?t:n,r&&(0,I.jsxs)(I.Fragment,{children:[` `,(0,I.jsx)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`cursor-pointer whitespace-nowrap text-text-tertiary underline-offset-2 hover:text-text-secondary hover:underline`,children:i?`Show less`:`Show more`})]})]})]})}function T7({children:e,action:t}){return(0,I.jsxs)(`div`,{className:`flex items-start gap-2 text-sm text-danger-text`,children:[(0,I.jsx)(Sb,{size:15,className:`mt-0.5 shrink-0 text-danger`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 wrap-anywhere`,children:e}),t]})}var E7=[`Fable`,`Opus`,`Sonnet`,`Haiku`];function qte(e,t){let n=e?.efforts??[];if(n.length){for(let r of[t,e?.defaultEffort])if(r&&n.includes(r))return r;return`default`}}function D7(e,t){for(let n=0;n<Math.max(e.length,t.length);n++){let r=(t[n]??0)-(e[n]??0);if(r)return r}return 0}function Jte(e){let t=new Map;for(let n of e){let{family:e,version:r}=gm(n.label);t.set(e,[...t.get(e)??[],{model:n,version:r}])}let n=e=>{let t=E7.indexOf(e);return t<0?E7.length:t};return[...t.entries()].map(([e,t],n)=>({family:e,members:t,at:n})).sort((e,t)=>n(e.family)-n(t.family)||e.at-t.at).map(({family:e,members:t})=>{let n=[...t].sort((e,t)=>D7(e.version,t.version)),r=n[0].version;return{family:e,latest:n.filter(e=>D7(e.version,r)===0).map(e=>e.model),older:n.filter(e=>D7(e.version,r)!==0).map(e=>e.model)}})}var Yte={low:`Low`,medium:`Medium`,high:`High`,max:`Max`},O7=q(WE,`flex h-7 min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-2 text-sm text-text-secondary`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover hover:text-text data-[state=open]:bg-surface-hover data-[state=open]:text-text`);function Xte({runtime:e,models:t,model:n,onModel:r}){let i=e===`codex`?lb:cb,[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(!1),l=Jte(t),u=l.flatMap(e=>e.older),d=s||a!==``||u.some(e=>e.id===n),f=e=>(0,I.jsx)(FA,{value:e.id,keywords:[e.label,gm(e.label).family],current:e.id===n,onSelect:()=>r(e.id),children:(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-col py-0.5`,children:[(0,I.jsx)(`span`,{className:`truncate`,children:e.label}),e.note&&(0,I.jsx)(`span`,{className:`truncate text-xs text-text-tertiary`,children:e.note})]})},e.id);return(0,I.jsxs)(TA,{onOpenChange:e=>{e||(o(``),c(!1))},children:[(0,I.jsxs)(EA,{"aria-label":`Model`,className:O7,children:[(0,I.jsx)(i,{size:14,className:`shrink-0 text-icon`}),(0,I.jsx)(`span`,{className:`truncate`,children:t.find(e=>e.id===n)?.label??n}),(0,I.jsx)(Uy,{size:13,className:`shrink-0 text-icon`})]}),(0,I.jsxs)(DA,{side:`top`,align:`start`,className:`w-80`,children:[(0,I.jsx)(OA,{placeholder:`Search models`,"aria-label":`Search models`,value:a,onValueChange:o}),(0,I.jsxs)(kA,{label:`Models`,className:`max-h-80`,children:[(0,I.jsx)(AA,{children:`No model matches.`}),l.map(e=>(0,I.jsx)(MA,{heading:e.family,children:e.latest.map(f)},e.family)),u.length>0&&(d?(0,I.jsx)(MA,{heading:`Older models`,children:u.map(f)}):(0,I.jsxs)(PA,{value:`Older models`,onSelect:()=>c(!0),children:[(0,I.jsx)(Wy,{size:13}),`Older models`,(0,I.jsx)(`span`,{className:`tabular-nums`,children:u.length})]}))]})]})]})}function Zte({runtime:e,models:t,model:n,onModel:r,effort:i,onEffort:a,fast:o,onFast:s}){let c=t.find(e=>e.id===n),l=qte(c,i);return(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-0.5`,children:[(0,I.jsx)(Xte,{runtime:e,models:t,model:n,onModel:r}),l&&(0,I.jsx)(Qte,{efforts:c?.efforts??[],effort:l,onEffort:a}),c?.fast&&(0,I.jsx)($te,{fast:o,onFast:s})]})}function Qte({efforts:e,effort:t,onEffort:n}){let r=zx();return(0,I.jsxs)(CY,{value:t,onValueChange:e=>e!=="default"&&n(e),children:[(0,I.jsxs)(OY,{"aria-label":`Effort`,className:O7,children:[!r&&(0,I.jsx)(`span`,{className:`text-text-tertiary`,children:`Effort`}),(0,I.jsx)(kY,{})]}),(0,I.jsxs)(AY,{side:`top`,align:`start`,children:[t==="default"&&(0,I.jsx)(PY,{value:`default`,children:`Default`}),e.map(e=>(0,I.jsx)(PY,{value:e,children:Yte[e]},e))]})]})}function $te({fast:e,onFast:t}){return(0,I.jsx)(Y,{label:`Fast mode`,icon:(0,I.jsx)(eb,{size:14}),active:e,onClick:()=>t(!e)})}function k7({percent:e}){return(0,I.jsx)(`span`,{className:`block h-1 w-full overflow-hidden rounded-full bg-border`,children:(0,I.jsx)(`span`,{className:q(`block h-full rounded-full`,e>=85?`bg-danger`:e>=65?`bg-warning`:`bg-text-secondary`),style:{width:`${Math.min(100,e)}%`}})})}var A7=e=>e>=1e3?`${Math.round(e/1e3)}k`:String(e);function ene({context:e,limits:t,plan:n,onCompact:r,onOpen:i}){let a=Math.round(e.used/e.size*100);return(0,I.jsxs)(xA,{onOpenChange:e=>e&&i?.(),children:[(0,I.jsxs)(SA,{"aria-label":`Context ${a}% used`,className:q(WE,`flex h-7 cursor-pointer items-center gap-1.5 rounded-md px-1.5 text-xs tabular-nums text-text-tertiary`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover hover:text-text-secondary data-[state=open]:bg-surface-hover`),children:[(0,I.jsx)(`span`,{className:`block w-5`,children:(0,I.jsx)(k7,{percent:a})}),(0,I.jsxs)(`span`,{children:[a,`%`]})]}),(0,I.jsx)(CA,{side:`top`,align:`end`,className:`w-72 p-3`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,I.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline justify-between text-sm`,children:[(0,I.jsx)(`span`,{className:`font-medium text-text`,children:`Context`}),(0,I.jsxs)(`span`,{className:`text-xs tabular-nums text-text-tertiary`,children:[A7(e.used),` of `,A7(e.size),` · `,a,`%`]})]}),(0,I.jsx)(k7,{percent:a}),e.costUsd!==void 0&&(0,I.jsxs)(`span`,{className:`text-xs tabular-nums text-text-tertiary`,children:[`This thread so far: $`,e.costUsd.toFixed(2)]})]}),t.length>0&&(0,I.jsxs)(`section`,{className:`flex flex-col gap-2 border-t border-border-subtle pt-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline justify-between text-sm`,children:[(0,I.jsx)(`span`,{className:`font-medium text-text`,children:`Usage limits`}),n&&(0,I.jsx)(`span`,{className:`text-xs text-text-tertiary`,children:n})]}),t.map(e=>(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline justify-between text-xs`,children:[(0,I.jsx)(`span`,{className:`text-text-secondary`,children:e.label}),(0,I.jsxs)(`span`,{className:`tabular-nums text-text-tertiary`,children:[e.percent,`% · resets `,e.resets]})]}),(0,I.jsx)(k7,{percent:e.percent})]},e.label))]}),(0,I.jsx)(J,{size:`sm`,onClick:r,className:`self-start`,children:`Compact now`})]})})]})}function tne({plan:e,tasks:t,onStopTask:n}){let[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(()=>Date.now()),s=t.length>0;(0,F.useEffect)(()=>{if(!s)return;o(Date.now());let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[s]);let c=e.filter(e=>e.status===`completed`).length,l=e.find(e=>e.status===`in_progress`);return e.length===0&&t.length===0?null:(0,I.jsxs)(`div`,{className:`flex flex-col overflow-hidden rounded-t-lg border-b border-border-subtle text-sm animate-fade-in`,children:[e.length>0&&(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:()=>i(!r),className:q(`border-0 bg-transparent`,`flex h-9 min-w-0 cursor-pointer items-center gap-2 px-4 text-left transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`),children:[(0,I.jsxs)(`span`,{className:`shrink-0 text-xs tabular-nums text-text-tertiary`,children:[c,` of `,e.length]}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-text-secondary`,children:l?.content??`All steps done`}),r?(0,I.jsx)(Uy,{size:14,className:`text-icon`}):(0,I.jsx)(Tb,{size:14,className:`text-icon`})]}),r&&(0,I.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-0.5 px-4 pb-2 animate-fade-in`,children:e.map(e=>(0,I.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 py-0.5`,children:[e.status===`completed`?(0,I.jsx)(zy,{size:13,className:`shrink-0 text-success`}):e.status===`in_progress`?(0,I.jsx)(UE,{size:`sm`}):(0,I.jsx)(kb,{size:13,className:`shrink-0 text-text-disabled`}),(0,I.jsx)(`span`,{className:q(`min-w-0 truncate`,e.status===`completed`?`text-text-tertiary line-through`:e.status===`in_progress`?`text-text`:`text-text-secondary`),children:e.content})]},e.content))}),t.map(e=>(0,I.jsxs)(`div`,{className:`flex h-9 min-w-0 items-center gap-2 border-t border-border-subtle pr-2 pl-4 first:border-t-0`,children:[(0,I.jsx)(Ky,{size:13,className:`shrink-0 text-icon`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-text-secondary`,children:e.title}),(0,I.jsxs)(`span`,{className:`shrink-0 text-xs tabular-nums text-text-tertiary`,children:[`running `,g8(Math.max(0,Math.round((a-e.startedAt)/1e3)))]}),n&&(0,I.jsx)(Y,{label:`Stop this command`,icon:(0,I.jsx)(ab,{size:12}),size:`sm`,onClick:()=>n(e.id)})]},e.id))]})}function j7({label:e=`Chat`}){return(0,I.jsxs)(`section`,{"aria-label":e,"aria-busy":`true`,"data-thread-column":``,className:`flex min-h-0 min-w-0 flex-1 items-center justify-center gap-2 bg-surface text-sm text-text-tertiary`,children:[(0,I.jsx)(UE,{}),` Opening the thread…`]})}function M7({threadId:e,runtime:t,start:n,startsAs:r,onStarted:i,onOpenThread:a,draftKey:o,inbox:s,emptyHint:c,empty:l,meta:u,startMeta:d,notices:f,label:p=`Chat`,children:m}){let h=zF({threadId:e,draftKey:o,start:n,onStarted:i,...r?{startsAs:r}:{}}),g=(0,F.useRef)(null),{view:_}=h,v=h.runtime??t??`claude-code`,y=h.attach;(0,F.useEffect)(()=>{if(!s)return;let e=()=>{let e=p6(s);e.length!==0&&(y(e),requestAnimationFrame(()=>g.current?.querySelector(`textarea[aria-label="Message"]`)?.focus()))};return e(),m6(s,e)},[s,y]);let b=zx(),x=_.ask,S=b?null:d&&!h.loading&&_.items.length===0?d:u,C=()=>x&&h.answer(x,{kind:`decline`}),w=x?x.kind===`approval`?(0,I.jsx)(K8,{call:x.call,onAnswer:(e,t)=>h.answer(x,{kind:`approval`,choice:e,...t?{instead:t}:{}})},x.id):x.kind===`question`?(0,I.jsx)(G8,{questions:x.questions,onAnswer:e=>h.answer(x,{kind:`question`,answers:e})},x.id):x.kind===`form`?(0,I.jsx)(Z8,{...x.server?{server:x.server}:{},message:x.message,fields:x.fields,onSubmit:e=>h.answer(x,{kind:`form`,values:e}),onDecline:C},x.id):(0,I.jsx)(Q8,{...x.server?{server:x.server}:{},message:x.message,url:x.url,onDone:()=>h.answer(x,{kind:`link`,done:!0}),onDecline:C},x.id):(0,I.jsx)(e5,{value:h.draft,onChange:h.setDraft,attachments:h.attachments,onAttach:h.attach,onRemoveAttachment:h.removeAttachment,commands:_.commands,files:h.files,state:_.state,onSend:()=>void h.send(),onStop:h.stop,onRecall:h.recall,..._.suggestion?{suggestion:_.suggestion}:{},top:(0,I.jsx)(tne,{plan:_.plan,tasks:_.tasks}),..._.turnStartedAt?{workingSince:_.turnStartedAt}:{},meter:!b&&_.context&&(0,I.jsx)(ene,{context:_.context,limits:h.usage?.limits??[],...h.usage?.plan?{plan:h.usage.plan}:{},onCompact:h.compact,onOpen:h.refreshUsage}),footer:h.model&&!(b&&_.state===`working`)&&(0,I.jsx)(Zte,{runtime:v,models:h.models,model:h.model,onModel:h.chooseModel,effort:h.effort,onEffort:h.chooseEffort,fast:h.fast,onFast:h.chooseFast})}),T=async e=>{let t=RF(_.items,e),n=t&&await h.branch(t);n&&a?.(n)};return(0,I.jsxs)(`section`,{ref:g,"aria-label":p,"data-thread-column":``,className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface`,children:[f&&(0,I.jsx)(`div`,{className:`flex flex-none flex-col gap-2 px-4 pt-2 empty:hidden`,children:f}),(0,I.jsx)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:(0,I.jsx)(p7,{items:_.items,state:_.state,actions:{onEdit:h.edit,onBranch:e=>void T(e),canUndoFiles:v===`claude-code`},onDropImages:h.attach,emptyHint:c,...l?{empty:l}:{},loading:h.loading,footer:(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[m&&(0,I.jsx)(`div`,{className:`mb-0.5 empty:hidden`,children:m}),w,!x&&S&&(0,I.jsx)(`span`,{className:`px-4 text-xs text-text-tertiary`,children:S})]})})})]})}var nne=`One chat per feature — it knows the state, answers questions, and plans and runs the rounds that build it.`,rne=`A fresh conversation on this feature, beside the feature chat. It knows the feature, its docs and its tickets.`,ine=e=>(document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e));function ane({feature:e,sessions:t,tickets:n,runs:r,docs:i}){let a=t.length===0&&n.length===0&&r.length===0;return e.status===`active`&&a&&i.some(e=>e.relPath===`brief.md`)}function one({full:e,column:t,events:n,alerts:r,standing:i,hidden:a,holdStart:o,start:s,onView:c}){let{inFront:l,main:u,scenario:d}=t,f=l===u,p=l!==null&&l===d.sessionId,m=t.threads.find(e=>e.id===t.current),h=rx(),g=(0,F.useSyncExternalStore)(ine,()=>document.visibilityState===`visible`,()=>!0),_=(0,F.useRef)(null),v=(0,F.useRef)(!1),y=e=>_.current??=s({holdOpening:e}).finally(()=>{_.current=null}),b=()=>(v.current=_.current!==null,y(!0)),x=(0,F.useRef)(!1),S=!a&&!t.pending&&g&&f&&!o&&t.listRead&&t.main===null&&ane(e);return(0,F.useEffect)(()=>{!S||x.current||(x.current=!0,y(!1).then(e=>t.started(e,{stayOnPicked:!0}),e=>{v.current||h.push(e instanceof Error?e.message:`the chat could not be started`)}))},[S]),a?null:t.pending?(0,I.jsx)(j7,{label:`Thread`}):(0,I.jsx)(M7,{label:f?`Agent`:p?`Scenario chat`:`Thread`,threadId:l,...m?{runtime:m.runtime}:{},...f?{start:b,startsAs:{featureId:e.feature.id},onStarted:t.started,inbox:d6(e.feature.id)}:{},draftKey:`feature:${e.feature.id}:main`,onOpenThread:t.pick,emptyHint:f?nne:p?x5(d.errand):rne,...p?{}:{meta:`Feature worktree · ${e.feature.branch}`},notices:r,children:(0,I.jsx)(Q5,{events:n,tickets:e.tickets,standing:i,active:!0,onView:c,readyToTest:e.feature.waitingReason===Tg})},f?`main`:l)}var sne=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function cne(e,t){if(e.shipped)return[];let n=[],{conflict:r}=e;if(r){let i=r.files.length>0?`${sne(r.files.length,`file`)} · `:``,a=[...r.files,...e.resolveEnded?[`The resolve session ended but the merge hasn’t landed — resolve by hand or retry.`]:[],...e.liveSessionId?[nv]:[]].join(`
|
|
188
|
-
`);n.push({key:`conflict`,hue:`danger`,title:`Merge conflict`,subtitle:`${i}${r.base} into ${e.branch}`,...a?{tooltip:a}:{},action:{label:e.liveSessionId?`End session & resolve`:`Resolve with agent`,onClick:t.resolve,disabled:t.resolving}})}else e.conflictResolved&&n.push({key:`conflict-resolved`,hue:`review`,title:`Conflict resolved`,subtitle:`ready to merge`});let{denial:i}=e;i&&n.push({key:`denial-${i.eventId}`,hue:`review`,title:`Review couldn’t drive`,subtitle:`uncommitted changes — commit or discard them, then ask the agent for another review`,tooltip:[i.message,...i.dirtyFiles].join(`
|
|
189
|
-
`),onDismiss:t.dismissDenial});let{unverified:a}=e;if(a){let e=[a.line,a.reason].filter(Boolean).join(`
|
|
190
|
-
`);n.push({key:`unverified`,hue:`review`,title:`Nothing verified`,subtitle:`ask the agent for another review, or drive it yourself`,...e?{tooltip:e}:{}})}return e.blockingDrive&&n.push({key:`project-drive`,hue:`review`,title:`${Pv(e.blockingDrive.holderLabel)} is running`,subtitle:`it holds the drive slot`,action:{label:t.stopping?`Stopping…`:`Stop it`,onClick:t.stopDrive,disabled:t.stopping}}),n}function lne({full:e,events:t,conflict:n,drive:r,driveUp:i,resolveConflict:a}){let o=R.useUtils(),s=rx(),c=e?.feature.id??``,l=e?.feature.status===`shipped`,u=Uh(c,!!e?.tickets.some(e=>e.kind===`review`)&&!l),[d,f]=(0,F.useState)(null),p=R.project.testDrive.useMutation({onSuccess:()=>void o.feature.driveInfo.invalidate(),onError:e=>s.push(e.message)});if(!e)return[];let{feature:m}=e,h=r&&r.featureId!==m.id?r:void 0,g=h?.projectDrive&&h.projectId?h.projectId:void 0,_=Tv(e.sessions)?.sessionId??null,v=Lv(t,e.runs,d);return cne({shipped:l,branch:m.branch,conflict:n,conflictResolved:!n&&iv(t),resolveEnded:ov(t,e.sessions),liveSessionId:_,denial:v,unverified:sy({passes:u.data??[],tickets:e.tickets}),blockingDrive:!i&&h&&g?{holderLabel:h.holderLabel}:null},{resolve:()=>{n&&a.resolve(n,_??void 0)},resolving:a.pending,dismissDenial:()=>f(v?.eventId??null),stopDrive:()=>{g&&p.mutate({projectId:g,action:`stop`})},stopping:p.isPending})}function une({featureId:e,sessions:t,driveSessionId:n}){let r=rx(),i=R.useUtils(),a=R.thread.list.useQuery({featureId:e},{refetchInterval:tg()}),o=a.data??[],[s,c]=(0,F.useState)(null),l=yx(o,`main`)??s??Sv(t)?.id??null,{front:u,pick:d,pending:f}=T_(null,a.data?e=>e===l||e===n||o.some(t=>t.id===e):null),p=b5(n,d),m=u!==null&&u===p.sessionId&&!p.listed,h=u!==null&&!m?u:l;E_(f?void 0:h),(0,F.useEffect)(()=>m6(d6(e),()=>d(null)),[e]);let g=R.thread.new.useMutation({onSuccess:({threadId:t})=>{d(t),i.thread.list.invalidate({featureId:e})},onError:e=>r.push(e.message)});return{scenario:p,threads:xx(o,[bx(l??`unstarted`,_x,`main`),...h&&h!==l?[h===p.sessionId?bx(h,gx(p.errand),`scenario`):bx(h,_x,`side`)]:[]]),main:l,listRead:a.data!==void 0,mainState:o.find(e=>e.id===l)?.state,inFront:h,pending:f!==null,current:h??`unstarted`,pick:e=>d(e===`unstarted`||e===l?null:e),newThread:()=>g.mutate({featureId:e}),started:(t,n)=>{c(t),n?.stayOnPicked||d(null),i.thread.list.invalidate({featureId:e})}}}var N7={plan:(0,I.jsx)(Jy,{}),work:(0,I.jsx)(bb,{}),design:(0,I.jsx)(Lb,{}),drive:(0,I.jsx)(ib,{}),details:(0,I.jsx)(Cb,{})},P7={key:`runcastle.feature.panel`,min:0,max:1e3,default:500};function F7(e,t){let{width:n,setWidth:r}=_P(P7),[i,a]=(0,F.useState)({collapsed:t_.collapsed}),{reading:o,...s}=i,c={...s,view:e,share:n/P7.max,...o&&o.view===e?{doc:o.doc}:{}};(0,F.useEffect)(()=>{o&&o.view!==e&&a(({reading:e,...t})=>t)},[o,e]);let l=(0,F.useRef)({state:c,onViewChange:t});return l.current={state:c,onViewChange:t},{state:c,dispatch:(0,F.useCallback)(e=>{let t=l.current.state,{view:n,share:i,path:o,origin:s,collapsed:c,last:u,doc:d}=r_(t,e);a({collapsed:c,...o===void 0?{}:{path:o},...s?{origin:s}:{},...u?{last:u}:{},...d&&n?{reading:{doc:d,view:n}}:{}}),i!==t.share&&r(i*P7.max),n!==t.view&&l.current.onViewChange(n??`chat`)},[r])}}var dne=`@max-[1100px]:absolute @max-[1100px]:inset-y-0 @max-[1100px]:right-0 @max-[1100px]:z-20 @max-[1100px]:shadow-dialog`;function I7({chat:e,panel:t,share:n,collapsed:r,strip:i,onResize:a,onToggleFull:o}){let s=(0,F.useRef)(null);return(0,I.jsxs)(`div`,{ref:s,className:`@container relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,I.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:e}),!(t==null||t===!1)&&(r?(0,I.jsx)(`div`,{className:`flex w-10 shrink-0 flex-col items-center gap-1 border-l border-border bg-surface py-2`,children:i}):(0,I.jsxs)(`div`,{"data-panel":!0,style:{width:`${n*100}%`},className:q(`relative flex min-h-0 min-w-0 shrink-0 flex-col border-l border-border bg-surface`,dne),children:[(0,I.jsx)(fne,{share:n,row:s,onResize:a,onToggleFull:o}),t]}))]})}function fne({share:e,row:t,onResize:n,onToggleFull:r}){let[i,a]=(0,F.useState)(!1),o=(0,F.useRef)({x:0,share:e,width:0});return(0,F.useEffect)(()=>{if(!i)return;let e=e=>{let{x:t,share:r,width:i}=o.current;i>0&&n(r+(t-e.clientX)/i)},t=()=>a(!1),r=document.body.style.userSelect;return document.body.style.userSelect=`none`,document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.body.style.userSelect=r,document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[i,n]),(0,I.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the panel`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(e*100),title:`Drag to resize · double-click: half or full`,className:q(`absolute top-0 -left-[3px] z-10 h-full w-1.5 cursor-col-resize transition-colors duration-(--dur-1) ease-app hover:bg-border-strong`,i&&`bg-border-strong`),onMouseDown:n=>{n.preventDefault(),o.current={x:n.clientX,share:e,width:t.current?.getBoundingClientRect().width??0},a(!0)},onDoubleClick:r})}function L7({view:e,views:t,label:n,path:r,onSwitch:i,onCollapse:a,onClose:o,children:s}){return(0,I.jsxs)(`section`,{"aria-label":n(e),className:`@container/panel flex min-h-0 min-w-0 flex-1 flex-col animate-fade-in`,children:[(0,I.jsxs)(`div`,{className:`flex h-(--topbar-h) shrink-0 items-center gap-2 border-b border-border-subtle pr-2 pl-3`,children:[(0,I.jsx)(SN,{items:t.map(t=>({id:t,label:(0,I.jsx)(`span`,{className:q(t!==e&&`@max-[520px]/panel:sr-only`),children:n(t)}),icon:N7[t],...t===e?{}:{tooltip:n(t)}})),value:e,onChange:i,label:`Panel views`,className:`-ml-1 min-w-0`}),e===`design`&&r&&(0,I.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-text-tertiary`,children:r}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(Y,{label:`Fold the panel`,size:`sm`,icon:(0,I.jsx)(Wy,{}),onClick:a}),(0,I.jsx)(Y,{label:`Close the panel`,size:`sm`,icon:(0,I.jsx)(By,{}),onClick:o})]}),(0,I.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:s})]})}function R7({label:e,onExpand:t,onClose:n}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Y,{label:`Unfold ${e.toLowerCase()}`,size:`sm`,icon:(0,I.jsx)(wb,{}),onClick:t}),(0,I.jsx)(Y,{label:`Close the panel`,size:`sm`,icon:(0,I.jsx)(By,{}),onClick:n})]})}function z7({open:e,views:t,badge:n,onToggle:r}){return t.length===0?null:(0,I.jsx)(Y,{label:e?`Hide the panel`:`Show the panel`,icon:(0,I.jsx)(Py,{}),active:e,...n?{badge:n}:{},onClick:r})}var B7={startDraft:(0,I.jsx)(ib,{}),markUpNext:(0,I.jsx)(xb,{}),moveToBacklog:(0,I.jsx)(ub,{}),chat:(0,I.jsx)(qy,{}),selfPlan:(0,I.jsx)(sb,{}),stopSelfPlan:(0,I.jsx)(ab,{}),stopAgent:(0,I.jsx)(ab,{}),openBurnSettings:(0,I.jsx)(Ny,{}),testDriveStart:(0,I.jsx)(ib,{}),testDriveStop:(0,I.jsx)(ab,{}),fixDrive:(0,I.jsx)(Ky,{}),merge:(0,I.jsx)(pb,{}),resolveConflict:(0,I.jsx)(Sb,{}),unarchive:(0,I.jsx)(db,{})},pne={danger:`danger`,note:`neutral`,clear:`success`};function mne(e){return/[.!?…:]$/.test(e)?e:`${e}.`}function hne({ns:e,guidance:t,busy:n,onAction:r,draftBranch:i,split:a}){let o=e.secondary,s=[...o,e.primary].filter(e=>!!e?.disabled),c=!!e.primary||o.length>0,l=o.length>2?o.slice(0,2):o,u=o.length>2?o.slice(2):[];if(zx()||!c&&!e.busy&&!e.alert&&!e.counts&&!e.note)return null;let d=e=>a?.kind===e.kind?a.label:e.label,f=(e,t,i,o)=>a?.kind===e.kind?(0,I.jsx)(bN,{variant:t,icon:B7[e.kind],disabled:n||!!e.disabled,title:e.disabled??e.hint,onClick:()=>r(e.kind),picker:a.picker,menuLabel:a.menuLabel,children:i},o):(0,I.jsx)(J,{variant:t,icon:B7[e.kind],disabled:n||!!e.disabled,title:e.disabled??e.hint,onClick:()=>r(e.kind),children:i},o),p=e.title??(t?void 0:e.desc),m=t&&e.desc&&e.desc!==p?e.desc:void 0;return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-3 animate-fade-in`,role:e.alert?`alert`:void 0,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 basis-80 text-sm text-text-secondary`,children:[(p||m)&&(0,I.jsxs)(`p`,{className:`m-0 text-pretty`,children:[e.busy?(0,I.jsx)(UE,{size:`sm`,className:`mr-2 inline-block align-[-2px]`}):e.alert?(0,I.jsx)(RA,{tone:`warning`,className:`mr-2 align-middle`}):null,p&&(0,I.jsx)(`span`,{className:`font-medium text-text`,children:m?mne(p):p}),p&&m&&` `,m]}),e.counts&&(0,I.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1`,children:[e.counts.pills.map(e=>(0,I.jsx)(BA,{tone:pne[e.tone],size:`sm`,children:e.label},e.label)),e.counts.trailing&&(0,I.jsx)(`span`,{className:`text-sm text-text-tertiary`,children:e.counts.trailing})]}),e.note&&(0,I.jsx)(`p`,{className:`mt-1.5 mb-0 text-xs text-text-tertiary first-letter:uppercase`,role:`note`,children:e.note})]}),c&&(0,I.jsxs)(`div`,{className:`ml-auto flex min-w-0 flex-col items-end gap-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2`,children:[l.map((e,t)=>f(e,`ghost`,d(e),t)),u.length>0&&(0,I.jsxs)(mN,{children:[(0,I.jsx)(hN,{asChild:!0,children:(0,I.jsx)(Y,{label:`More actions`,icon:(0,I.jsx)(Gy,{}),disabled:n})}),(0,I.jsx)(gN,{align:`end`,children:u.map(e=>(0,I.jsx)(_N,{icon:B7[e.kind],disabled:!!e.disabled,title:e.disabled??e.hint,onSelect:()=>r(e.kind),children:d(e)},e.kind))})]}),e.primary&&(0,I.jsxs)(I.Fragment,{children:[i&&(0,I.jsx)(dP,{prefix:`from`,value:i.value,branches:i.branches,detected:i.detected,missing:i.missing,onPick:i.onPick}),f(e.primary,e.primary.danger?`danger`:`primary`,n?`Working…`:d(e.primary))]})]}),s.map(e=>(0,I.jsxs)(`div`,{className:q(`flex flex-wrap items-center justify-end gap-2 text-right text-xs`,i&&e.kind===`startDraft`&&i.missing?`text-warning-text`:`text-text-tertiary`),children:[(0,I.jsx)(`span`,{children:e.disabled}),e.escape&&(0,I.jsx)(J,{size:`sm`,variant:`secondary`,icon:B7[e.escape.kind],onClick:()=>r(e.escape.kind),disabled:n,children:e.escape.label})]},e.kind))]})]},`${e.title??``}|${e.primary?.kind??``}`)}function gne({action:e,busy:t,onAction:n,split:r}){let i={size:`sm`,variant:e.danger?`danger`:e.kind===`merge`?`secondary`:`primary`,icon:B7[e.kind],disabled:t||!!e.disabled,title:e.disabled??e.hint,onClick:()=>n(e.kind)};return r?.kind===e.kind?(0,I.jsx)(bN,{...i,picker:r.picker,menuLabel:r.menuLabel,children:r.label}):(0,I.jsx)(J,{...i,children:e.label})}function _ne(e,t,n){let r=(0,F.useRef)(null),i=(0,F.useRef)(n);i.current=n,(0,F.useEffect)(()=>{let n=e[e.length-1];if(!n)return;let a=r.current;if(r.current=n.id,a!==null)for(let n of e){if(n.id<=a)continue;let e=Qg(n,t);e&&i.current(e)}},[e,t])}var V7=`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-text-tertiary`;function vne(e){return e.satisfied?`success`:e.status===`archived`||e.status===`draft`?`neutral`:`accent`}function H7({dep:e,onRemove:t}){return(0,I.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`truncate text-sm text-text`,children:e.title}),(0,I.jsx)(BA,{tone:vne(e),...e.satisfied?{icon:(0,I.jsx)(zy,{size:12})}:{},title:e.slug,children:yg(e)}),t&&(0,I.jsx)(Y,{label:`Stop waiting on ${e.slug}`,size:`sm`,icon:(0,I.jsx)(By,{}),onClick:t})]})}function yne({isDraft:e,dependsOn:t,candidates:n,onChange:r}){let[i,a]=(0,F.useState)(null),[o,s]=(0,F.useState)(!1),c=zx();if(!e||c)return t.length===0?null:(0,I.jsxs)(`p`,{className:V7,children:[(0,I.jsx)(`span`,{children:e?`Waits on:`:`Waited on:`}),t.map(e=>(0,I.jsx)(H7,{dep:e},e.featureId))]});let l=t.map(e=>e.featureId),u=e=>{a(null),s(!0),r(e).catch(e=>a(C6(e instanceof Error?e.message:String(e)))).finally(()=>s(!1))};return(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsxs)(`div`,{className:V7,children:[(0,I.jsx)(`span`,{children:`Waits on`}),t.length===0&&(0,I.jsx)(`span`,{children:`nothing`}),t.map(e=>(0,I.jsx)(H7,{dep:e,...e.satisfied?{}:{onRemove:()=>u(l.filter(t=>t!==e.featureId))}},e.featureId)),(0,I.jsxs)(TA,{children:[(0,I.jsx)(EA,{asChild:!0,children:(0,I.jsx)(J,{variant:`ghost`,size:`sm`,icon:(0,I.jsx)(Ry,{}),loading:o,children:`Add`})}),(0,I.jsxs)(DA,{align:`start`,children:[(0,I.jsx)(OA,{placeholder:`Find a feature…`}),(0,I.jsxs)(kA,{label:`Features to wait on`,children:[(0,I.jsx)(AA,{children:`No unmerged feature to wait on`}),n.map(e=>(0,I.jsx)(FA,{value:`${e.title} ${e.slug}`,onSelect:()=>u([...l,e.id]),children:e.title},e.id))]})]})]})]}),i&&(0,I.jsx)(`p`,{className:`m-0 text-xs text-danger-text`,role:`alert`,children:i})]})}function U7({label:e,projectId:t,blocks:n,alsoWaitsOn:r}){return n.length===0?null:(0,I.jsxs)(`p`,{className:V7,children:[(0,I.jsx)(`span`,{children:e}),n.map((e,i)=>{let a=r?.(e)??[];return(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`a`,{className:q(GE,`font-mono`),href:f_({kind:`feature`,projectId:t,featureSlug:e.slug}),title:e.title,children:e.slug}),a.length>0&&` (also waits on ${a.join(`, `)})`,i<n.length-1&&`,`]},e.featureId)})]})}function bne({projectId:e,featureId:t,blocks:n,features:r=[]}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(U7,{label:`Starts when this ships:`,projectId:e,blocks:n.filter(e=>e.upNext),alsoWaitsOn:e=>(r.find(t=>t.id===e.featureId)?.dependsOn??[]).filter(e=>!e.satisfied&&e.featureId!==t).map(e=>e.slug)}),(0,I.jsx)(U7,{label:`Blocks:`,projectId:e,blocks:n.filter(e=>!e.upNext)})]})}function xne({feature:e,isDraft:t,facts:n=[],className:r,children:i}){let a=rx(),o=(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1.5`,children:[!t&&e.branch&&(0,I.jsxs)(`button`,{type:`button`,className:q(`inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1.5 rounded-sm bg-transparent p-0`,`font-mono text-xs text-text-tertiary transition-colors duration-(--dur-1) ease-app hover:text-text`),title:`Copy branch name`,onClick:()=>HF(e.branch,a),children:[(0,I.jsx)(Fy,{size:14,className:`shrink-0 text-icon`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.branch})]}),(0,I.jsx)(ZA,{items:n})]});return(0,I.jsx)(FN,{title:e.title,meta:o,className:r,children:i&&(0,I.jsx)(`div`,{className:`flex flex-col gap-5`,children:i})})}var Sne=[[`w-12`,`w-40`],[`w-12`,`w-32`],[`w-16`,`w-24`]];function Cne(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(MN,{leading:(0,I.jsx)(WN,{children:(0,I.jsx)(GN,{className:`h-3 w-40`})})}),(0,I.jsx)(PN,{children:(0,I.jsxs)(WN,{label:`Loading feature…`,children:[(0,I.jsx)(`div`,{className:`flex h-7 items-center`,"data-skeleton":`title`,children:(0,I.jsx)(GN,{className:`h-5 w-2/5`})}),(0,I.jsxs)(`div`,{className:`mt-2 flex h-4 items-center gap-1.5`,"data-skeleton":`branch`,children:[(0,I.jsx)(GN,{className:`size-3.5`}),(0,I.jsx)(GN,{className:`h-2.5 w-64`})]}),(0,I.jsx)(`div`,{className:`mt-5 -ml-2 flex items-center gap-x-0.5`,children:Av.map((e,t)=>(0,I.jsxs)(`div`,{className:`flex items-center gap-x-0.5`,children:[t>0&&(0,I.jsx)(`span`,{className:`mx-0.5 h-px w-3 bg-border-subtle`}),(0,I.jsxs)(`div`,{className:`flex h-(--control-sm) items-center gap-1.5 px-2`,"data-skeleton":`step`,children:[(0,I.jsx)(GN,{className:`size-3.5 rounded-full`}),(0,I.jsx)(GN,{className:`h-2.5 w-14`})]})]},e))}),(0,I.jsx)(`div`,{className:`mt-10 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-6 gap-y-1.5`,children:Sne.map(([e,t],n)=>(0,I.jsxs)(`div`,{className:`contents`,"data-skeleton":`row`,children:[(0,I.jsx)(`div`,{className:`flex min-h-6 items-center`,children:(0,I.jsx)(GN,{className:q(`h-3`,e)})}),(0,I.jsx)(`div`,{className:`flex min-h-6 items-center`,children:(0,I.jsx)(GN,{className:q(`h-3`,t)})})]},n))})]})})]})}var wne={talking:`neutral`,working:`live`,waiting:`warning`,ready:`accent`,merged:`success`};function Tne({status:e}){return(0,I.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-2 text-sm text-text-tertiary`,role:`status`,children:[(0,I.jsx)(RA,{tone:wne[e.kind]}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-text-secondary`,children:e.label}),e.why&&(0,I.jsxs)(`span`,{className:`min-w-0 shrink-[100] truncate`,children:[`· `,e.why]})]})}function Ene({open:e,busy:t=!1,onStop:n,onClose:r}){return(0,I.jsxs)(aP,{open:e,onClose:r,size:`sm`,label:`Stop the agent?`,children:[(0,I.jsx)(oP,{title:`Stop the agent?`,description:`The running round stops — work that already landed stays — and nothing new starts until you reply to the agent.`}),(0,I.jsxs)(cP,{children:[(0,I.jsx)(J,{variant:`ghost`,onClick:r,children:`Keep going`}),(0,I.jsx)(J,{variant:`danger`,icon:(0,I.jsx)(ab,{}),disabled:t,onClick:()=>{r(),n()},children:`Stop`})]})]})}var Dne={danger:`bg-danger-subtle px-3 py-2.5`,accent:`bg-accent-subtle px-3 py-2.5`,warning:`py-1`,quiet:`py-1`},One={danger:`text-danger`,accent:`text-warning`,warning:`text-warning`,quiet:`text-icon`};function kne({tone:e,icon:t,title:n,meta:r,children:i,actions:a,role:o=`alert`,className:s}){let c=t??(e===`quiet`?(0,I.jsx)(Cb,{}):(0,I.jsx)(Sb,{}));return(0,I.jsxs)(`div`,{role:o,className:q(`flex items-start gap-3 rounded-md text-sm animate-rise-in`,Dne[e],s),children:[(0,I.jsx)(`span`,{"aria-hidden":!0,className:q(`mt-0.5 inline-flex size-4 shrink-0 items-center justify-center [&>svg]:size-4`,One[e]),children:c}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-5 flex-wrap items-baseline gap-x-2`,children:[(0,I.jsx)(`span`,{className:`font-medium text-text`,children:n}),r&&(0,I.jsx)(`span`,{className:`text-xs text-text-tertiary`,children:r})]}),i&&(0,I.jsx)(`div`,{className:`text-sm text-pretty text-text-secondary`,children:i})]}),a&&(0,I.jsx)(`div`,{className:`-my-0.5 flex shrink-0 items-center gap-1.5`,children:a})]})}function Ane({missing:e}){return e.length===0?null:(0,I.jsx)(kne,{tone:`warning`,role:`status`,title:(0,I.jsxs)(`span`,{title:e.map(e=>e.reason).join(`; `),children:[`Walkthrough videos off on this machine: `,e.map(e=>e.notice).join(`; `)]})})}var jne=6e4;function Mne(e,t){return e===void 0?!!t&&!t.awaitingInput:e===`working`}function Nne(e){let t={};for(let n of e)if(n.type===`lead.message_queued`)t.pendingSince=n.ts;else if(n.type===`lead.wake_failed`){let e=af.safeParse(n.data);t.failed={at:n.ts,exitCode:e.success?e.data.exitCode:null}}return t}var Pne=`Talking with you`;function Fne(e){return e===null?`the agent’s run failed`:`the agent’s run failed (exit ${e})`}function Ine(e){let t=W7(e),n=Lne(e,t);return n?{...t,primary:n}:t}function Lne(e,t){if(t.kind!==`merged`){if(e.driving)return`testDriveStop`;if(e.rounds.at(-1)?.status===`running`)return`stop`;if(e.selfPlanning)return`stopSelfPlan`;if(t.kind===`ready`)return`testDriveStart`}}function W7(e){let{feature:t,rounds:n,declarations:r,agentWorking:i}=e;if(t.status===`shipped`)return{kind:`merged`,label:`Merged`};let a=n.at(-1),o=()=>a?{kind:`working`,label:`Working · Round ${a.round}`,round:a.round}:{kind:`working`,label:`Working`};if(a?.status===`running`)return o();if(e.selfPlanning)return{kind:`working`,label:`Planning by itself`};let s=r.at(-1);if(s&&!i&&(!a||s.createdAt>a.startedAt))return{kind:`ready`,label:`Ready for you`,why:`Test drive ▸ ${s.scenario}`,scenario:s.scenario};if(t.waitingReason){let e={kind:`waiting`,label:`Waiting for you`,why:t.waitingReason};return t.waitingReason===`planning stopped`?{...e,primary:`chat`}:e}let c=e.leadWake?.pendingSince,l=e.leadWake?.failed,u=!!l&&l.at>=(c??-1/0),d=!e.agentStateKnown&&c!==void 0&&!u&&e.now-c<6e4;return i||d?o():l&&u&&l.at>(a?.startedAt??-1/0)?{kind:`waiting`,label:`Waiting for you`,why:Fne(l.exitCode),primary:`chat`}:e.leadAwaitsHuman?{kind:`waiting`,label:`Waiting for you`}:{kind:`talking`,label:Pne}}var Rne={testDriveStart:{label:`Start test drive`,kind:`testDriveStart`},testDriveStop:{label:`Stop drive`,kind:`testDriveStop`},stop:{label:`Stop`,kind:`stopAgent`,danger:!0},stopSelfPlan:{label:`Stop`,kind:`stopSelfPlan`,danger:!0},chat:pv},zne={label:`Merge & ship`,kind:`merge`},Bne=[`chat`];function Vne(e,t){let n=[...e.primary?[e.primary]:[],...e.secondary],r=e=>n.find(t=>t.kind===e),i=t.primary?Rne[t.primary]:void 0,a=i?{...r(i.kind),...i}:void 0,o=t.kind===`merged`?[]:[r(`merge`)??zne],s=n.filter(e=>e.kind!==`merge`&&e.kind!==a?.kind&&!Bne.includes(e.kind)),{primary:c,...l}=e;return{...l,...a?{primary:a}:{},secondary:[...o,...s]}}function Hne(e,t){let n=Vne(e,t),r=[e.primary,...e.secondary].some(e=>e?.kind===`merge`),i=n.primary??(r?n.secondary.find(e=>e.kind===`merge`):void 0);return{...i?{action:i}:{},overflow:n.secondary.filter(e=>e!==i)}}var Une=8e3;function Wne(e){return Gne(nL(e))}function Gne(e){let[t,n]=(0,F.useState)(null),r=(0,F.useRef)(null);return(0,F.useEffect)(()=>{if(e.length===0)return;let t=e[e.length-1].id;if(r.current===null){r.current=t;return}let i=r.current;r.current=t;let a=e.filter(e=>e.id>i&&e.type===`session.resume_failed`),o=a[a.length-1];o&&n({message:o.message||`session resume failed — relaunch to continue`,sticky:Kne(o)})},[e]),(0,F.useEffect)(()=>{if(!t||t.sticky)return;let e=setTimeout(()=>n(null),Une);return()=>clearTimeout(e)},[t]),{message:t?.message??null,dismiss:()=>n(null)}}function Kne(e){let t=e.data;return typeof t==`object`&&!!t&&`backgroundSessionId`in t}function G7({title:e,status:t,views:n=[],onView:r,onBack:i}){let[a,o]=(0,F.useState)(null),s=Ex(),c=s?Dx(s.threads):[],l=c.length>0,u=()=>o(null),d=e=>()=>{u(),e()},f=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,I.jsx)(`span`,{className:`truncate text-md font-medium text-text`,children:e}),l&&(0,I.jsx)(Uy,{size:14,className:`shrink-0 text-icon`})]}),t&&(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-text-tertiary`,children:[t.tone===`waiting`&&(0,I.jsx)(RA,{tone:`warning`}),(0,I.jsx)(`span`,{className:q(`truncate`,t.tone===`working`&&`text-shimmer`),children:t.words})]})]});return(0,I.jsxs)(`header`,{className:`flex h-13 shrink-0 items-center gap-1 border-b border-border-subtle bg-surface px-1.5`,children:[(0,I.jsx)(Y,{label:`Back to the list`,size:`lg`,icon:(0,I.jsx)(wb,{}),onClick:i}),l?(0,I.jsx)(`button`,{type:`button`,"aria-label":`${e} — switch thread`,onClick:()=>o(`threads`),className:`flex min-w-0 flex-1 cursor-pointer flex-col px-1 text-left`,children:f}):(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col px-1`,children:f}),n.length>0&&(0,I.jsx)(Y,{label:`More`,size:`lg`,icon:(0,I.jsx)(Gy,{}),onClick:()=>o(`views`)}),s&&(0,I.jsxs)(qN,{open:a===`threads`,onClose:u,title:`Threads`,children:[c.map(e=>(0,I.jsx)(JN,{icon:(0,I.jsx)(GI,{state:e.state}),label:e.title,current:e.id===s.current,onClick:d(()=>s.pick(e.id))},e.id)),(0,I.jsx)(JN,{icon:(0,I.jsx)(Ry,{}),label:`New thread`,onClick:d(s.newThread)})]}),(0,I.jsx)(qN,{open:a===`views`,onClose:u,label:`Views`,children:n.map(e=>(0,I.jsx)(JN,{icon:N7[e.view],label:e.label,...e.hint?{hint:e.hint}:{},onClick:d(()=>r?.(e.view))},e.view))})]})}function K7({title:e,sub:t,onBack:n,trailing:r,children:i}){return(0,I.jsxs)(`section`,{"aria-label":e,className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface`,children:[(0,I.jsxs)(`header`,{className:`flex h-13 shrink-0 items-center gap-1 border-b border-border-subtle bg-surface px-1.5`,children:[(0,I.jsx)(Y,{label:`Back to the chat`,size:`lg`,icon:(0,I.jsx)(wb,{}),onClick:n}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col px-1`,children:[(0,I.jsx)(`span`,{className:`truncate text-md font-medium text-text`,children:e}),t&&(0,I.jsx)(`span`,{className:`truncate text-xs text-text-tertiary`,children:t})]}),r]}),(0,I.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto`,children:i})]})}function qne(e,t,n,r,i){return r&&new URL(r).hostname===i?`${r}/__runcastle/open/${encodeURIComponent(n)}?path=${encodeURIComponent(t??`/`)}`:g6(e,t)}function Jne({featureId:e,path:t,width:n,title:r,sub:i,onBack:a}){let o=v6(e,t),s=R.phoneLink.status.useQuery(void 0,{refetchOnWindowFocus:!1}),[c,l]=(0,F.useState)(!0),u=(0,F.useRef)(null),[d,f]=(0,F.useState)({width:0,height:0});(0,F.useEffect)(()=>{let e=u.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(([e])=>{e&&f({width:e.contentRect.width,height:e.contentRect.height})});return t.observe(e),()=>t.disconnect()},[o.url]);let p=wX(c?n??1440:`fit`,d);return(0,I.jsx)(K7,{title:r,...i?{sub:i}:{},onBack:a,trailing:o.url&&(0,I.jsx)(J,{variant:`ghost`,onClick:()=>l(!c),"aria-label":c?`Show at the phone’s width`:`Show at desktop width`,children:c?`Desktop`:`Phone`}),children:o.url?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{ref:u,className:`relative min-h-0 flex-1 overflow-hidden bg-surface-inset`,children:(0,I.jsx)(`iframe`,{title:`The design`,src:qne(o.url,o.shownPath,e,s.data?.designUrl,window.location.hostname),className:`absolute top-0 left-0 origin-top-left border-0 bg-surface`,style:{width:p.width,height:p.height,transform:`scale(${p.scale})`}})}),(0,I.jsx)(`p`,{className:`m-0 shrink-0 border-t border-border-subtle bg-surface px-4 py-2.5 text-xs text-text-tertiary`,children:`Tap around it. Say what to change in the chat.`})]}):(0,I.jsx)(b6,{server:o,onRestart:()=>o.restartServer()})})}var q7=[`plan`,`work`,`design`];function Yne(e){return e&&q7.includes(e)?e:null}function Xne(e,t){let n={plan:`Decisions and spec, to read`,work:fy(uy(t)),design:`Running now`};return e.filter(e=>q7.includes(e)).map(e=>({view:e,label:$g[e],...n[e]?{hint:n[e]}:{}}))}function Zne(e){if(!e)return;let t=e.kind===`waiting`||e.kind===`ready`?`waiting`:e.kind===`working`?`working`:`quiet`;return{words:e.label,tone:t}}function Qne(e){if(e===`waiting`)return{words:`Waiting for you`,tone:`waiting`};if(e===`working`)return{words:`Working`,tone:`working`}}function $ne({tag:e,details:t,children:n}){let r=rx();return(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md bg-danger-subtle px-4 py-3`,role:`alert`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-danger-text`,children:[(0,I.jsx)(Sb,{size:16,className:`shrink-0 text-danger`}),e]}),(0,I.jsx)(`p`,{className:`m-0 text-sm text-text-secondary`,children:n}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-text-tertiary`,title:t,children:t}),(0,I.jsx)(J,{variant:`ghost`,size:`sm`,icon:(0,I.jsx)(hb,{}),onClick:()=>HF(t,r),children:`Copy details`})]})]})}function ere({crumb:e,children:t}){return(0,I.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface`,children:[(0,I.jsx)(MN,{crumbs:[{label:e,icon:(0,I.jsx)(Sb,{})}]}),(0,I.jsx)(PN,{children:t})]})}function tre({featureId:e,error:t}){return(0,I.jsx)(ere,{crumb:`Feature`,children:(0,I.jsx)($ne,{tag:`Broken`,details:`feature ${e} — ${t.name}: ${t.message}`,children:`This feature couldn't be rendered. Everything else still works.`})})}var J7=`flex h-full min-h-0 min-w-0 flex-1 flex-col bg-surface`;function nre(e){let[,t]=(0,F.useReducer)(e=>e+1,0);return(0,F.useEffect)(()=>{if(e===void 0)return;let n=e-Date.now();if(n<=0)return;let r=setTimeout(t,n);return()=>clearTimeout(r)},[e]),Date.now()}function rre({featureId:e,view:t,onViewChange:n,guidance:r,driving:i,landedOn:a=!1,onDriveChange:o,onOpenThread:s,onDeleted:c,onBackToList:l}){let u=zx(),d=R.useUtils(),f=rx(),p=bte(),m=R.feature.get.useQuery({id:e},{refetchInterval:tg()}),h=Wne(e),g=nL(e),_=cf(g),v=sv(g),y=Nne(g),b=nre(y.pendingSince===void 0?void 0:y.pendingSince+jne),x=tg(),[S,C]=(0,F.useState)(!1),w=R.feature.mergeDelta.useQuery({featureId:e},{refetchInterval:tg(5e3),enabled:S}),T=R.notes.list.useQuery({featureId:e},{enabled:S}),E=T.data?T.data.filter(e=>e.status===`open`).length:void 0,D=ny(Uh(e,S).data??[],m.data?.tickets??[]),O=ry(D,{landedSince:D?.landedSince??0},iy(m.data?.tickets??[])),k=m.data?my(m.data):void 0,ee=hy(R.docs.read.useQuery({featureId:e,relPath:k??`spec.md`},{enabled:S&&!!k}).data?.content),A=m.data?.feature.projectId,j=R.thread.list.useQuery({projectId:A??``},{enabled:!!A,refetchInterval:x}),M=R.feature.driveInfo.useQuery({projectId:A??``},{enabled:!!A,refetchInterval:x}),N=R.feature.rounds.useQuery({featureId:e},{refetchInterval:x}),te=R.feature.readyDeclarations.useQuery({featureId:e},{refetchInterval:x}),ne=(te.data?.length??0)>0,re=R.feature.driveScenarios.useQuery({projectId:A??``,featureId:e},{enabled:!!A&&ne,refetchInterval:tg(5e3)}),ie=f5(re.data?.scenarios??[],{withOwnSection:!0,runnerConfigured:re.data?.runnerConfigured??!1}),ae=R.project.drivePrerequisites.useQuery({projectId:A??``},{enabled:!!A}),P=m.data?.feature.status===`draft`,oe=m.data?.feature.status===`shipped`,se=R.project.branches.useQuery({projectId:A??``},{enabled:!!A&&P}),[ce,le]=(0,F.useState)(null),ue=_v(m.data?.upNextProblem??null),de=(ce?.featureId===e?ce.base:``)||(se.data&&!ue?J_(se.data):``),fe=!P||de?void 0:se.data?`unpicked`:`loading`,pe=R.design.status.useQuery({featureId:e},{enabled:!!m.data&&!P,refetchInterval:x}),me=i?.featureId===e,[he,ge]=(0,F.useState)(!1),_e=t===`chat`?null:t,ve=!!m.data&&!P&&!oe,ye=me||he||M.data?.featureId===e&&M.data.state!==`idle`,be=m.data?yee({isDraft:P,hasPlan:vee(m.data),hasTickets:m.data.tickets.length>0,shipped:oe,designRunning:!!pe.data?.running||ve&&_e===`design`,driveActive:ye}):[],xe=F7(_e&&be.includes(_e)?_e:null,n),Se=Xg(be);_ne(g,e,e=>{(be.includes(e.view)||e.view===`work`&&m.data&&!P||e.view===`design`&&ve)&&xe.state.view!==`drive`&&xe.dispatch({type:`open`,...e,origin:`agent`})});let Ce=_6(e,xe.state.path,xe.state.view===`design`),we=une({featureId:e,sessions:m.data?.sessions??[],driveSessionId:M.data?.featureId===e?M.data.scenarioSessionId:void 0});Tx(P||!m.data?null:{scope:{featureId:e},threads:we.threads,current:we.current,pick:we.pick,newThread:we.newThread,...we.scenario.sessionId&&we.scenario.listed?{errand:{threadId:we.scenario.sessionId,close:we.scenario.close}}:{}});let Te=we.threads.find(e=>e.id===we.current)?.title,Ee=()=>Promise.all([d.feature.get.invalidate({id:e}),d.feature.list.invalidate(),d.events.invalidate()]),De=()=>{Ee()},Oe=hx(e),ke=()=>{De(),Oe()},Ae=R.feature.launchSession.useMutation({onSuccess:ke,onError:e=>f.push(e.message)}),je=R.feature.launchSession.useMutation({onSuccess:De,onError:()=>void 0}),[Me,Ne]=(0,F.useState)(!1),Pe=R.feature.stop.useMutation({onSuccess:()=>{De(),d.feature.rounds.invalidate({featureId:e}),f.push(`stopped — nothing new starts until you reply to the agent`,`info`)},onError:e=>f.push(e.message)}),Fe=R.feature.endSession.useMutation({onError:e=>f.push(e.message)}),Ie=R.feature.fixDrive.useMutation({onSuccess:ke,onError:e=>f.push(e.message)}),Le=R.feature.testDrive.useMutation({onSuccess:(e,t)=>{if(De(),e.hookFailure){let t=e.hookFailure;f.push(`${t.phase===`setup`?`Test drive setup`:`Test drive teardown`} failed: ${t.command}${t.timedOut?` (timed out)`:``} — see the timeline for its output`)}e.dbDrift&&f.push(e.dbDrift.resetCommand?`Migrations differ between the branches — your dev database may be ahead. Rebuild it with: ${e.dbDrift.resetCommand}`:`Migrations differ between the branches — your dev database may be ahead. Set a database reset command in settings for a one-line fix here.`,`info`),e.carriedChanges?.length&&f.push(`${e.carriedChanges.length} uncommitted file(s) came back with you onto ${e.branch}`,`info`)},onError:e=>f.push(e.message)}),Re=R.feature.merge.useMutation({onSettled:De,onError:e=>f.push(e.message)}),ze=R.feature.unarchive.useMutation({onSuccess:()=>{De(),f.push(`feature unarchived`,`success`)},onError:e=>f.push(e.message)}),Be=!!m.data?.blocks.some(e=>e.upNext),Ve=R.feature.list.useQuery({projectId:A??``},{enabled:!!A&&(P||Be)}),He=R.feature.setDependencies.useMutation({onSuccess:De,onError:()=>void 0}),Ue=R.feature.setUpNext.useMutation({onSuccess:De,onError:e=>f.push(e.message)}),We=R.feature.start.useMutation({onSuccess:(e,t)=>{De(),Ae.mutate({featureId:t.featureId,kind:`chat`})},onError:e=>f.push(e.message)}),Ge=R.feature.launchSession.useMutation({onSuccess:Ee,onError:e=>f.push(e.message)}),Ke=R.feature.start.useMutation({onSuccess:(e,t)=>{De(),Ge.mutate({featureId:t.featureId,kind:`chat`,purpose:`self-plan`})},onError:e=>f.push(e.message)}),qe=Ste(e,m.data?.feature.branch??``),Je=lne({full:m.data,events:g,conflict:_,drive:M.data,driveUp:ye,resolveConflict:qe}),[Ye,Xe]=(0,F.useState)(null),Ze=R.feature.archive.useMutation({onSuccess:()=>{De(),f.push(`feature archived`,`success`)},onError:e=>f.push(e.message)}),Qe=R.feature.delete.useMutation({onSuccess:()=>{d.feature.list.invalidate(),Xe(null),c?.()},onError:e=>f.push(e.message)});if(m.isLoading)return(0,I.jsx)(`section`,{className:J7,children:(0,I.jsx)(Cne,{})});if(!m.data)return(0,I.jsxs)(`section`,{className:J7,children:[(0,I.jsx)(MN,{}),(0,I.jsx)(PN,{children:(0,I.jsxs)(YN,{children:[`Could not load the feature`,m.error?`: ${m.error.message}`:``]})})]});let $e=!!m.error,et=m.data,tt=et.feature,nt=s?jx(tt,j.data??[]):null,rt=P?void 0:Te,it=Fg(et.runs),at=kv(et,{...fe?{draftBaseMissing:fe}:{}}),ot=fv(et.sessions),st=We.isPending||Ae.isPending||Ke.isPending||Ge.isPending||Le.isPending||Re.isPending||Ie.isPending||ze.isPending||Ue.isPending||Fe.isPending||qe.pending,ct=async()=>{if(!ot)return!0;try{await Fe.mutateAsync({sessionId:ot.id})}catch{return!1}return De(),!0},lt=()=>Oe(),ut=t=>{ge(!0),xe.dispatch({type:`follow`,click:`testDrive`}),Le.mutate({featureId:e,action:`start`,...t?{scenario:t}:{}},{onSuccess:t=>{De(),t.ok&&t.branch?o({featureId:e,branch:t.branch}):t.ok||(f.push(t.deniedReason??`test drive denied`),xe.dispatch({type:`close`}))},onError:()=>xe.dispatch({type:`close`}),onSettled:()=>ge(!1)})},dt=t=>{switch(t){case`startDraft`:We.mutate({featureId:e,baseBranch:de});break;case`markUpNext`:Ue.mutate({featureId:e,upNext:!0});break;case`moveToBacklog`:Ue.mutate({featureId:e,upNext:!1});break;case`chat`:lt();break;case`selfPlan`:P?Ke.mutate({featureId:e,baseBranch:de}):Ge.mutate({featureId:e,kind:`chat`,purpose:`self-plan`});break;case`stopSelfPlan`:ot&&Cv(ot)&&ct();break;case`stopAgent`:Ne(!0);break;case`openBurnSettings`:{let e=it?.summary?kh(it.summary):null;e&&p?.(e);break}case`unarchive`:ze.mutate({featureId:e});break;case`testDriveStart`:ut(ie.defaultScenario?.file??null);break;case`testDriveStop`:Le.mutate({featureId:e,action:`stop`},{onSuccess:()=>{De(),o(null),xe.state.view===`drive`&&xe.dispatch({type:`close`})}});break;case`fixDrive`:Ie.mutate({featureId:e});break;case`merge`:C(!0);break;case`resolveConflict`:_&&qe.resolve(_,ot?.id);break;default:}},ft=()=>{Re.mutate({featureId:e},{onSuccess:e=>{if(De(),C(!1),e.ok)o(null),f.push(`merged — feature shipped`,`success`);else if(e.conflict){let t=e.files.length;f.push(t>0?`merge conflict in ${t} file${t===1?``:`s`} — resolve below and retry`:`merge conflict — resolve below and retry`)}}})},pt=xe.state.view,mt=e=>$g[e],ht=oe?wv([...g]):null,gt=[P?{phase:`draft`,text:`Added to backlog ${gg(tt.createdAt)}`}:ht?{tone:`success`,text:`Merged ${gg(ht)}`}:{text:`Started ${gg(tt.createdAt)}`},tt.status===`archived`&&{tone:`neutral`,text:`Archived`}].filter(e=>!!e),_t=[{key:`copy-link`,label:`Copy link`,onSelect:()=>HF(window.location.origin+f_({kind:`feature`,projectId:tt.projectId,featureSlug:tt.slug}),f)},...!P&&tt.branch?[{key:`copy-branch`,label:`Copy branch name`,onSelect:()=>HF(tt.branch,f)}]:[],...tt.status===`archived`?[{key:`unarchive`,label:`Unarchive`,onSelect:()=>ze.mutate({featureId:e})}]:tt.status===`draft`?[]:[{key:`archive`,label:`Archive`,onSelect:()=>Ze.mutate({featureId:e})}],...c&&tt.status!==`shipped`?[{key:`delete`,label:`Delete…`,danger:!0,onSelect:e=>Xe(e)}]:[]],vt=P?void 0:Ine({feature:tt,rounds:N.data??[],declarations:te.data??[],agentWorking:Mne(we.mainState,ot),agentStateKnown:we.mainState!==void 0,leadAwaitsHuman:et.leadAwaitsHuman,driving:me,selfPlanning:!!ot&&Cv(ot)||Ke.isPending||Ge.isPending,leadWake:y,now:b}),yt=st||Pe.isPending,bt=he||Le.isPending&&Le.variables?.action===`stop`,xt={kind:`testDriveStart`,label:m5(ie.defaultScenario,`Start test drive`),menuLabel:`Choose a scenario`,picker:(0,I.jsx)(S5,{menu:ie,onPick:ut,align:`end`})},St=vt?Hne(at,vt):{overflow:[]},Ct=P&&(0,I.jsx)(hne,{ns:at,guidance:r,busy:yt,onAction:dt,split:xt,draftBranch:{branches:se.data?.branches,value:de||null,detected:se.data?.detected,missing:fe===`unpicked`,onPick:t=>le({featureId:e,base:t})}}),wt=h.message&&(0,I.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md bg-danger-subtle px-3 py-2 text-sm text-danger-text`,role:`alert`,children:[(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:`Resume failed.`}),` `,h.message]}),(0,I.jsx)(Y,{label:`Dismiss`,size:`sm`,icon:(0,I.jsx)(By,{}),onClick:h.dismiss})]}),Tt=(0,I.jsxs)(I.Fragment,{children:[wt,vt?.primary===`testDriveStart`&&(0,I.jsx)(Ane,{missing:ae.data?.missing??[]}),!oe&&(0,I.jsx)(t8,{featureId:e,driving:me,stopping:bt,onStop:()=>dt(`testDriveStop`)})]}),Et=(0,I.jsxs)(xne,{feature:tt,isDraft:P,facts:gt,children:[P&&wt,(0,I.jsx)(yne,{isDraft:P,dependsOn:et.dependsOn,candidates:Cg(Ve.data??[],tt,et.dependsOn),onChange:t=>He.mutateAsync({featureId:e,dependsOn:t})}),(0,I.jsx)(bne,{projectId:tt.projectId,featureId:tt.id,blocks:et.blocks,features:Ve.data??[]}),Ct]}),Dt=(t,n)=>{let r=`${e}:${t}`;return t===`plan`?(0,I.jsx)(`div`,{className:`h-full min-h-0 animate-rise-in`,children:n},r):(0,I.jsx)(`div`,{className:`px-6 pt-5 pb-10 animate-rise-in`,children:n},r)},Ot=(0,I.jsx)(Q6,{feature:tt,when:ht?{label:`Merged`,value:gg(ht)}:{label:`Started`,value:gg(tt.createdAt)},dependsOn:et.dependsOn,blocks:et.blocks}),kt=e=>xe.dispatch({type:`openDoc`,doc:e}),At=xe.state.doc?et.docs.find(e=>e.relPath===xe.state.doc):void 0,jt=t=>{if(At)return(0,I.jsx)(JK,{featureId:e,doc:At,backLabel:mt(t),onBack:()=>xe.dispatch({type:`closeDoc`})},`${e}:${t}:${At.relPath}`);switch(t){case`plan`:return Dt(t,(0,I.jsx)(rq,{full:et,onOpenDesign:e=>{ve&&xe.dispatch({type:`open`,view:`design`,path:e,origin:`human`})}}));case`work`:return Dt(t,(0,I.jsx)(oX,{featureId:e,onOpenDoc:kt}));case`design`:return(0,I.jsx)(y6,{featureId:e,...xe.state.path?{path:xe.state.path}:{},...xe.state.width===void 0?{}:{width:xe.state.width}});case`drive`:return null;case`details`:return(0,I.jsx)(J6,{featureId:e,facts:Ot,onOpenDoc:kt})}},Mt=u?Yne(pt):null,Nt=!u&&!!pt&&!xe.state.collapsed&&xe.state.share>=1,Pt=pt===`drive`&&!u,Ft=be.includes(`drive`)&&!u,It=St.overflow.map(e=>({key:`next-${e.kind}`,label:e.kind===xt.kind?xt.label:e.label,icon:B7[e.kind],...e.disabled?{disabled:e.disabled}:{},...e.hint?{hint:e.hint}:{},onSelect:()=>dt(e.kind)}));return(0,I.jsxs)(`section`,{className:q(J7,`overflow-clip`),"aria-label":tt.title,children:[Ft&&(0,I.jsx)(v5.Provider,{value:we.scenario,children:(0,I.jsx)(R5,{full:et,hidden:!Pt,stopping:bt,onBack:()=>xe.dispatch({type:`close`}),onStop:()=>dt(`testDriveStop`)})}),Mt===`design`&&!At?(0,I.jsx)(Jne,{featureId:e,...xe.state.path?{path:xe.state.path}:{},...xe.state.width===void 0?{}:{width:xe.state.width},title:mt(Mt),sub:tt.title,onBack:()=>xe.dispatch({type:`close`})}):Mt&&(0,I.jsx)(K7,{title:mt(Mt),sub:tt.title,onBack:()=>b_(()=>xe.dispatch({type:`close`})),children:jt(Mt)}),(0,I.jsxs)(`div`,{className:Pt||Mt?`hidden`:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[u?(0,I.jsx)(G7,{title:tt.title,status:Zne(vt),views:Xne(Se,et.tickets),onView:e=>xe.dispatch({type:`open`,view:e,origin:`human`}),onBack:()=>b_(()=>l?.())}):(0,I.jsx)(MN,{crumbs:[...nt?[{label:(0,I.jsx)(`span`,{className:`block max-w-44 truncate`,title:`Held by the thread "${nt.title}"`,children:nt.title}),icon:(0,I.jsx)(Zy,{size:14}),onClick:()=>s?.(nt.id)}]:[],{label:tt.title,icon:(0,I.jsx)(Jb,{state:P?`draft`:oe?`shipped`:`active`,progress:dy(et.tickets),size:14,label:``})},...rt?[{label:rt}]:[]],trail:!!rt,status:vt&&(0,I.jsx)(Tne,{status:vt}),actions:(0,I.jsxs)(I.Fragment,{children:[$e&&(0,I.jsx)(BA,{tone:`warning`,className:`mr-2`,title:`The server is unreachable — retrying`,children:`Offline, retrying`}),St.action&&(0,I.jsx)(`span`,{className:`mr-1 flex`,children:St.action.kind===`testDriveStop`&&be.includes(`drive`)?(0,I.jsx)(J,{size:`sm`,variant:`primary`,icon:(0,I.jsx)(ib,{}),onClick:()=>xe.dispatch({type:`open`,view:`drive`,origin:`human`}),children:`Back to the drive`}):(0,I.jsx)(gne,{action:St.action,busy:yt,onAction:dt,split:xt})}),(0,I.jsx)(DI,{actions:[...It,..._t],size:`md`}),(0,I.jsx)(z7,{open:!!pt,views:Se,onToggle:()=>xe.dispatch({type:`toggle`,views:Se})})]})}),P?(0,I.jsxs)(PN,{routeKey:`${e}:draft`,children:[Et,(0,I.jsx)(`div`,{className:`mt-10`,children:(0,I.jsx)(HK,{full:et})})]}):(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(v5.Provider,{value:we.scenario,children:(0,I.jsx)(I7,{chat:(0,I.jsx)(one,{full:et,column:we,events:g,alerts:Tt,standing:Je,hidden:Nt,holdStart:a||We.isPending||Ke.isPending||Ge.isPending,start:async({holdOpening:t})=>(await je.mutateAsync({featureId:e,kind:`chat`,holdOpening:t})).sessionId,onView:e=>{be.includes(e)&&xe.dispatch({type:`open`,view:e,origin:`human`})}}),panel:pt&&pt!==`drive`&&!u&&(0,I.jsx)(L7,{view:pt,views:Se,label:mt,path:Ce,onSwitch:e=>xe.dispatch({type:`switch`,view:e}),onCollapse:()=>xe.dispatch({type:`collapse`}),onClose:()=>xe.dispatch({type:`close`}),children:jt(pt)}),share:xe.state.share,collapsed:xe.state.collapsed,strip:pt&&(0,I.jsx)(R7,{label:mt(pt),onExpand:()=>xe.dispatch({type:`expand`}),onClose:()=>xe.dispatch({type:`close`})}),onResize:e=>xe.dispatch({type:`setWidth`,share:e}),onToggleFull:()=>xe.dispatch({type:`toggleFull`})})})})]}),(0,I.jsx)(Ene,{open:Me,busy:Pe.isPending,onStop:()=>Pe.mutate({featureId:e}),onClose:()=>Ne(!1)}),S&&(0,I.jsx)(Cte,{title:tt.title,branch:tt.branch,base:w.data?.base,summary:Sy({branch:tt.branch,...w.data?.base?{base:w.data.base}:{},...w.data?{delta:w.data}:{},tickets:et.tickets,drivenAt:v,openNotes:E,...M.data?.projectDrive?{projectDrive:{holderLabel:M.data.holderLabel}}:{},freshness:O,conflict:_,laterLaps:ee,burning:it?.status===`running`}),busy:Re.isPending,resolving:qe.pending,onConfirm:ft,onResolve:_?()=>void qe.resolve(_,ot?.id??void 0):void 0,onCancel:()=>C(!1)}),Ye&&(0,I.jsx)(WF,{title:tt.title,slug:tt.slug,busy:Qe.isPending,onConfirm:()=>Qe.mutate({featureId:e}),onCancel:()=>Xe(null),returnFocusRef:Ye})]})}function ire(e){let t=R.useUtils(),n=rx(),r=R.project.sessionBranch.useQuery({projectId:e}),i=R.project.branches.useQuery({projectId:e,includeFeatureBranches:!0}),a=wy(r.data,i.data?.branches),o=R.settings.update.useMutation({onSuccess:()=>{t.project.sessionBranch.invalidate(),t.settings.get.invalidate()},onError:e=>n.push(e.message)});return{value:a?.value??null,branches:i.data?.branches,detected:r.data?.detected,missing:a?.origin===`vanished`,pick:t=>o.mutate({projectId:e,key:`sessionBranch`,value:t}),picking:o.isPending}}var are=[`Active`,`Today`,`Yesterday`,`This week`,`This month`,`Earlier`];function ore(e,t){if(e.state!==`idle`)return`Active`;let n=new Date(t),r=e=>new Date(n.getFullYear(),n.getMonth(),n.getDate()-e).getTime();return e.updatedAt>=r(0)?`Today`:e.updatedAt>=r(1)?`Yesterday`:e.updatedAt>=r(7)?`This week`:e.updatedAt>=r(30)?`This month`:`Earlier`}function Y7(e){return e.state===`waiting`?0:e.state===`working`?1:2}function sre(e,t){let n=t?e.toLowerCase().indexOf(t.toLowerCase()):-1;return n<0?e:(0,I.jsxs)(I.Fragment,{children:[e.slice(0,n),(0,I.jsx)(`mark`,{className:`rounded-sm bg-accent-subtle text-accent-text`,children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}function cre({thread:e,now:t,query:n,onOpen:r}){let{state:i}=e;return(0,I.jsxs)(`button`,{type:`button`,title:e.title,onClick:()=>r(e.id),className:`group/row flex h-10 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`,children:[(0,I.jsx)(GI,{state:i}),(0,I.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-md transition-colors duration-(--dur-1)`,i===`idle`?`text-text-secondary group-hover/row:text-text`:`text-text`),children:sre(e.title,n)}),(0,I.jsx)(`span`,{className:q(`shrink-0 text-xs tabular-nums`,i===`working`?`text-shimmer`:i===`waiting`?`text-warning-text`:`text-text-tertiary`),children:TI(i,e.updatedAt,t)})]})}function lre({threads:e,pending:t=!1,onOpen:n,now:r}){let[i,a]=(0,F.useState)(``),o=r??Date.now(),s=i.trim(),c=new Map,l=[...e].filter(e=>!s||e.title.toLowerCase().includes(s.toLowerCase())).sort((e,t)=>Y7(e)-Y7(t)||t.updatedAt-e.updatedAt);for(let e of l){let t=ore(e,o);c.set(t,[...c.get(t)??[],e])}let u=are.flatMap(e=>c.has(e)?[{group:e,rows:c.get(e)}]:[]),d=e.filter(e=>e.state===`waiting`).length,f=e.filter(e=>e.state===`working`).length;return(0,I.jsx)(`div`,{className:`@container flex min-h-0 flex-1 flex-col`,children:(0,I.jsxs)(PN,{routeKey:`conversations`,className:`relative isolate`,children:[(0,I.jsx)(ZI,{}),(0,I.jsx)(FN,{title:`Conversations`,meta:t?void 0:[{text:`${e.length} ${e.length===1?`conversation`:`conversations`}`},d>0?{tone:`warning`,text:`${d} waiting for you`}:null,f>0?{tone:`live`,text:`${f} working`}:null],actions:(0,I.jsx)(EN,{icon:(0,I.jsx)(My,{}),placeholder:`Filter`,"aria-label":`Filter conversations`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Escape`&&a(``)},className:`w-50`})}),t?(0,I.jsx)(WN,{label:`Loading conversations`,className:`mt-8`,children:(0,I.jsx)(`div`,{className:`flex flex-col gap-4 px-2.5`,children:[0,1,2,3,4].map(e=>(0,I.jsx)(GN,{className:`h-4 w-3/4 rounded-sm`},e))})}):e.length===0?(0,I.jsx)(XN,{icon:(0,I.jsx)(qy,{}),title:`No conversations yet`,hint:`A new chat starts from the Orchestrator.`,className:`mt-12`}):u.length===0?(0,I.jsx)(XN,{compact:!0,icon:(0,I.jsx)(My,{}),title:`No conversation matches`,hint:`Nothing titled “${s}”.`,className:`mt-8`}):(0,I.jsx)(`div`,{className:`mt-8 flex flex-col gap-7`,children:u.map(({group:e,rows:t},r)=>{let i=e===`Active`;return(0,I.jsxs)(`section`,{"aria-label":e,style:{"--i":r},className:q(`grid animate-rise-in grid-cols-1 gap-1 [animation-delay:calc(var(--i)*40ms)] @min-[1000px]:-ml-30 @min-[1000px]:grid-cols-[120px_minmax(0,1fr)] @min-[1000px]:gap-0`,!i&&`border-t border-border-subtle pt-2`),children:[(0,I.jsx)(`h2`,{className:q(`m-0 self-start px-2.5 text-xs font-medium @min-[1000px]:sticky @min-[1000px]:top-4 @min-[1000px]:px-0 @min-[1000px]:leading-10`,i?`text-text-secondary`:`text-text-tertiary`),children:e}),(0,I.jsx)(`div`,{className:q(`flex min-w-0 flex-col`,i&&`card relative rounded-lg p-1`,i&&f>0&&`orbit-light`),children:t.map((e,t)=>(0,I.jsxs)(F.Fragment,{children:[t>0&&(0,I.jsx)(`span`,{"aria-hidden":!0,className:`mr-2.5 ml-9 h-px bg-border-subtle`}),(0,I.jsx)(cre,{thread:e,now:o,query:s,onOpen:n})]},e.id))})]},e)})})]})})}function X7({lead:e,when:t,actions:n,className:r,children:i}){return(0,I.jsx)(JA,{as:`li`,animate:!0,wrap:!0,leading:e,title:(0,I.jsx)(`span`,{className:`flex flex-col`,children:i}),meta:t,actions:n,actionsOverlay:!0,className:q(`focus-within:bg-surface-hover hover:bg-surface-hover`,r)})}function ure(){return(0,I.jsx)(`span`,{className:`grid w-10 place-items-center`,"aria-hidden":!0,children:(0,I.jsx)(`i`,{className:`size-1.5 rounded-full bg-text-disabled`})})}function Z7({note:e}){let t=dx(e);return t?(0,I.jsx)(`span`,{className:`mt-0.5 font-mono text-xs text-text-tertiary`,title:t.title,children:t.label}):null}function dre({projectId:e,onTriage:t,triaging:n,reveal:r=!1,onRevealed:i}){let a=R.useUtils(),o=rx(),s=R.projectNotes.list.useQuery({projectId:e},{refetchInterval:tg()}),c=R.feature.list.useQuery({projectId:e},{refetchInterval:tg()}),[l,u]=(0,F.useState)(null),[d,f]=(0,F.useState)(``),[p,m]=(0,F.useState)(null),h=e=>o.push(e.message),g=()=>void a.projectNotes.invalidate(),_=R.projectNotes.edit.useMutation({onSuccess:()=>{g(),u(null)},onError:h}),v=R.projectNotes.delete.useMutation({onSuccess:g,onError:h}),y=R.projectNotes.dismiss.useMutation({onSuccess:g,onError:h}),b=R.projectNotes.reopen.useMutation({onSuccess:g,onError:h}),x=s.data??[],S=_.isPending||v.isPending||y.isPending||b.isPending,C=Q7(x.filter(e=>e.status===`open`)),w=Q7(x.filter(e=>e.status===`triaged`)),T=(0,F.useRef)(null),E=x.length>0;if((0,F.useEffect)(()=>{!r||!T.current||(T.current.scrollIntoView?.({block:`center`}),i?.())},[r,E,i]),!E)return null;let D=e=>{d.trim()&&!_.isPending&&_.mutate({noteId:e,text:d})},O=e=>e.screenshotUrl?(0,I.jsx)(pP,{size:`sm`,url:e.screenshotUrl,onOpen:m}):(0,I.jsx)(ure,{});return(0,I.jsxs)(`section`,{ref:T,"aria-label":`Notes`,className:`flex flex-col`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3 px-4 pt-3 pb-2`,children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 text-xs text-pretty text-text-tertiary`,children:`Grouped, questioned and routed in a triage chat.`}),(0,I.jsx)(J,{size:`sm`,icon:(0,I.jsx)(sb,{}),className:`shrink-0`,loading:n,disabled:C.length===0||n,title:C.length===0?`nothing is open to triage`:void 0,onClick:t,children:`Triage ${C.length}`})]}),C.length===0?(0,I.jsx)(XN,{compact:!0,icon:(0,I.jsx)(ub,{}),title:`No open notes`,hint:`Every note has been triaged.`}):(0,I.jsx)(`ul`,{className:fre,children:C.map(e=>(0,I.jsx)(X7,{lead:O(e),when:hg(e.createdAt),actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Y,{size:`sm`,label:`Edit`,icon:(0,I.jsx)(Yy,{}),onClick:()=>{u(e.id),f(e.text)}}),(0,I.jsx)(Y,{size:`sm`,label:`Dismiss`,icon:(0,I.jsx)(zy,{}),disabled:S,onClick:()=>y.mutate({noteId:e.id})}),(0,I.jsx)(Y,{size:`sm`,label:`Delete`,icon:(0,I.jsx)(Vy,{}),variant:`danger-ghost`,disabled:S,onClick:()=>v.mutate({noteId:e.id})})]}),children:l===e.id?(0,I.jsx)(`input`,{"aria-label":`edit this note`,className:CN,value:d,autoFocus:!0,onChange:e=>f(e.target.value),onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),u(null)):t.key===`Enter`&&(t.preventDefault(),D(e.id))}}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-text`,children:e.text}),(0,I.jsx)(Z7,{note:e})]})},e.id))}),w.length>0&&(0,I.jsx)($N,{title:`${w.length} triaged`,className:`mx-4 mt-2`,children:(0,I.jsx)(`ul`,{className:`m-0 flex list-none flex-col p-0`,children:w.map(t=>(0,I.jsxs)(X7,{lead:t.screenshotUrl?O(t):null,actions:(0,I.jsx)(Y,{size:`sm`,label:`Reopen`,icon:(0,I.jsx)(Hy,{}),disabled:S,onClick:()=>b.mutate({noteId:t.id})}),children:[(0,I.jsx)(`span`,{className:`text-text-secondary`,children:t.text}),(0,I.jsx)(Z7,{note:t}),(0,I.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-baseline gap-x-2 text-xs text-text-tertiary`,children:[(0,I.jsx)(`span`,{children:t.outcome}),(0,I.jsx)(pre,{projectId:e,feature:c.data?.find(e=>e.id===t.featureId)})]})]},t.id))})}),(0,I.jsx)(n5,{url:p,onClose:()=>m(null)})]})}var fre=`m-0 flex list-none flex-col px-1 py-1`;function Q7(e){return[...e].sort((e,t)=>t.createdAt-e.createdAt)}function pre({projectId:e,feature:t}){return t?(0,I.jsx)(`a`,{className:GE,href:f_({kind:`feature`,projectId:e,featureSlug:t.slug}),children:t.title}):null}function $7({threadId:e,runtime:t,start:n,startsAs:r,onStarted:i,onOpenThread:a,landing:o}){return(0,I.jsx)(M7,{label:`Project chat`,threadId:e,...t?{runtime:t}:{},...n?{start:n}:{},...r?{startsAs:r,draftKey:`project:${r.projectId}:new`}:{},...i?{onStarted:i}:{},onOpenThread:a,empty:(0,I.jsx)(mre,{}),...o.value?{meta:`Lands on ${o.value}`}:{},startMeta:(0,I.jsx)(dP,{prefix:`Lands on`,className:`-ml-2`,value:o.value,branches:o.branches,detected:o.detected,missing:o.missing,disabled:o.picking,onPick:o.pick})})}function mre(){return(0,I.jsxs)(`div`,{className:`flex animate-rise-in flex-col items-center gap-4 text-center`,children:[(0,I.jsx)(YI,{large:!0}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(`h2`,{className:`m-0 text-xl font-semibold tracking-tight text-text`,children:`What are we building?`}),(0,I.jsx)(`p`,{className:`m-0 max-w-[44ch] text-sm text-pretty text-text-tertiary`,children:`Bring a raw idea. The Orchestrator checks it against what’s built and cuts it into features.`})]})]})}function hre({card:e,starting:t,scenarios:n,onStart:r,onPrepare:i,onReturn:a}){return e.state===`prepare`?(0,I.jsx)(J,{size:`sm`,variant:`ghost`,icon:(0,I.jsx)(ob,{}),className:`mr-1`,title:`No setup or dev command yet`,onClick:i,children:`Prepare drive`}):e.state===`running`?(0,I.jsx)(J,{size:`sm`,variant:`ghost`,icon:(0,I.jsx)(nb,{}),className:`mr-1`,onClick:a,children:`Back to the drive`}):e.state===`hidden`?null:(0,I.jsx)(bN,{size:`sm`,variant:`ghost`,icon:(0,I.jsx)(ib,{}),className:`mr-1`,loading:t,disabled:e.state===`blocked`,title:e.state===`blocked`?e.reason:`Run everything that has shipped and jot what you notice`,onClick:()=>r(null),menuLabel:`Choose a scenario`,picker:(0,I.jsx)(S5,{menu:n,onPick:r,align:`end`}),children:`Test drive`})}function gre({projectId:e,repoPath:t,drive:n,hidden:r,onBack:i,onStop:a,stopping:o,onOpenPreparation:s}){let c=L5(e,n.startedAt),l=`${t??``}${n.commit?` @ ${n.commit}`:``}`,u={text:l,title:`${l} · runs as ${sx}`};return(0,I.jsx)(u5,{title:(0,I.jsxs)(I.Fragment,{children:[`Driving `,(0,I.jsx)(`span`,{className:`font-mono text-text`,children:n.branch})]}),store:c,hidden:r,stopping:o,onBack:i,onStop:a,stage:t=>(0,I.jsx)(M5,{projectId:e,branch:n.branch,driveState:n.state,drive:n,failure:Fv(n),where:u,onToChat:i,failureExit:e=>(0,I.jsx)(k5,{failure:e,explanation:(0,I.jsxs)(I.Fragment,{children:[`Your checkout is as it was, but `,(0,I.jsx)(`code`,{className:`font-mono text-xs`,children:e.command}),` `,e.outcome,` — so whatever it was meant to bring up is probably not running. Preparation is where this project’s drive commands are repaired and proven.`]}),children:(0,I.jsx)(J,{className:`self-start`,icon:(0,I.jsx)(ob,{}),onClick:s,children:`Open preparation`})}),...t})})}function _re(e){let t=R.useUtils(),n=rx(),r=R.feature.driveInfo.useQuery({projectId:e},{refetchInterval:tg()}),i=R.project.testDrive.useMutation({onSuccess:()=>void t.feature.driveInfo.invalidate(),onError:e=>n.push(e.message)}),a=r.data??null,o=(t,r,a,o)=>i.mutate({projectId:e,action:t,...a?{scenario:a}:{}},{onSuccess:e=>{e.ok?r?.():(n.push(e.deniedReason??`the drive could not ${t}`),o?.())},onError:()=>o?.()});return{slot:a,drive:cx(a,e)?a:null,start:(e,t)=>o(`start`,void 0,e,t),stop:e=>o(`stop`,e),starting:i.isPending&&i.variables?.action===`start`,stopping:i.isPending&&i.variables?.action===`stop`}}var e9=`new`;function vre({projectId:e,talk:t,newChatRequest:n=0,onConsumeNewChatRequest:r,inboxRequest:i=0,onConsumeInboxRequest:a,empty:o=!1,conversations:s=!1,threadRequest:c=null,onConsumeThreadRequest:l,onOpenConversations:u,onCloseConversations:d,onOpenPreparation:f,driveRequest:p=0,onConsumeDriveRequest:m,onBackToList:h}){let g=zx(),_=R.useUtils(),v=R.project.list.useQuery().data?.find(t=>t.id===e),y=ire(e),b=R.project.branches.useQuery({projectId:e,includeFeatureBranches:!0}),x=_re(e),S=x.drive,C=R.feature.driveScenarios.useQuery({projectId:e}),w=f5(C.data?.scenarios??[],{withOwnSection:!1,runnerConfigured:(C.data?.runnerConfigured??!1)&&!!v?.devCommand?.trim()}),T=R.thread.list.useQuery({projectId:e},{refetchInterval:tg()}),E=T.data??[],D=R.feature.list.useQuery({projectId:e},{refetchInterval:tg()}),O=t.session?.id??null,{front:k,pick:ee,pending:A}=T_(void 0,T.data?e=>e===O||e===S?.scenarioSessionId||E.some(t=>t.id===e):null),j=R.projectNotes.list.useQuery({projectId:e},{refetchInterval:tg()}),M=b5(S?.scenarioSessionId,e=>pe(e)),N=rx(),te=!!k&&k===M.sessionId&&!M.listed,ne=A!==null,[re,ie]=(0,F.useState)(!1),ae=!ne&&!c&&!re&&!!T.data&&(D.data!==void 0||D.isError)&&(k===void 0||te),P=ae?Ax(E,D.data??[],Date.now()):null,oe=P?.kind===`chat`?P.threadId:P?.kind===`none`?O:null;ae&&(oe!==null||te)&&ee(oe??void 0),P?.kind===`conversations`&&ie(!0);let se=ne||te?null:k??null,ce=P?.kind===`none`&&!oe,le=s||re;E_(ne?void 0:le?null:se);let[ue,de]=(0,F.useState)(null),fe=xx(E,se?[se===M.sessionId?bx(se,gx(M.errand),`scenario`):bx(se,_x,`project`)]:ce?[bx(vx,_x,`project`)]:[]),pe=e=>{ee(e),ie(!1),s&&d?.()},me=e=>fe.find(t=>t.id===e)?.runtime,he=R.thread.new.useMutation({onSuccess:({threadId:t})=>{pe(t),_.thread.list.invalidate({projectId:e})},onError:e=>N.push(e.message)}),ge=()=>he.mutate({projectId:e}),_e=R.thread.new.useMutation(),ve=(0,F.useRef)(ge);ve.current=ge;let ye=(j.data??[]).filter(e=>e.status===`open`).length,be=(j.data??[]).length>0,xe=bee({driveActive:!!S||x.starting,hasNotes:be}),[Se,Ce]=(0,F.useState)(null),we=F7(Se&&xe.includes(Se)?Se:null,e=>Ce(e===`chat`?null:e)),Te=Xg(xe),Ee=we.state.view,De=e=>we.dispatch({type:`open`,view:e,origin:`human`});(0,F.useEffect)(()=>{n<=0||(ve.current(),r?.())},[n,r]),(0,F.useEffect)(()=>{c&&(ee(c),ie(!1),l?.())},[c,l,ee]),(0,F.useEffect)(()=>{i>0&&Ce(`details`)},[i]),(0,F.useEffect)(()=>{p>0&&(Ce(`drive`),m?.())},[p,m]);let Oe=lx({empty:o||!v,setupCommand:v?.driveSetupCommand,devCommand:v?.devCommand,drive:x.slot,projectId:e}),ke=(e=null)=>{we.dispatch({type:`follow`,click:`testDrive`}),x.start(e,()=>we.dispatch({type:`close`}))},Ae=!g&&!!Ee&&!we.state.collapsed&&we.state.share>=1,je=Ee===`drive`&&!g,Me=g?null:S??(x.starting?{state:`idle`,branch:b.data?.current??``,holderLabel:``,devReady:!1,devConfigured:!0}:null),Ne=!!M.sessionId&&se===M.sessionId;Tx({scope:{projectId:e},threads:fe,current:le?null:se??(ce?`unstarted`:null),pick:e=>{e===`unstarted`?s&&d?.():pe(e)},newThread:ge,...M.sessionId&&M.listed?{errand:{threadId:M.sessionId,close:M.close}}:{},...u?{allConversations:u}:{}});let Pe=se?fe.find(e=>e.id===se)?.title:ce?_x:void 0,Fe=n=>{switch(n){case`details`:return(0,I.jsx)(`div`,{className:`px-6 py-5`,children:(0,I.jsx)(dre,{projectId:e,triaging:t.triaging,reveal:i>0,onRevealed:a,onTriage:()=>t.triage(pe)})});default:return null}};return(0,I.jsxs)(`section`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,children:[Me&&(0,I.jsx)(v5.Provider,{value:M,children:(0,I.jsx)(gre,{projectId:e,repoPath:v?.repoPath,drive:Me,hidden:!je,onBack:()=>we.dispatch({type:`close`}),onStop:()=>x.stop(()=>we.dispatch(be?{type:`switch`,view:`details`}:{type:`close`})),stopping:x.stopping||x.starting,onOpenPreparation:()=>f?.()})}),(0,I.jsxs)(`div`,{className:je?`hidden`:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[g?(0,I.jsx)(G7,{title:`Orchestrator`,status:Qne(fe.find(e=>e.id===se)?.state),onBack:()=>b_(()=>h?.())}):(0,I.jsx)(MN,{crumbs:[{label:`Orchestrator`,icon:(0,I.jsx)(Zy,{size:14}),...le?{onClick:()=>{ie(!1),d?.()}}:{}},...le?[{label:`Conversations`}]:Pe?[{label:Pe}]:[]],trail:!0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(hre,{card:Oe,starting:x.starting,scenarios:w,onStart:ke,onPrepare:()=>f?.(),onReturn:()=>De(`drive`)}),(0,I.jsx)(z7,{open:!!Ee,views:Te,badge:ye,onToggle:()=>we.dispatch({type:`toggle`,views:Te})})]})}),(0,I.jsx)(v5.Provider,{value:M,children:(0,I.jsx)(I7,{chat:(0,I.jsxs)(I.Fragment,{children:[le&&!Ae&&(0,I.jsx)(lre,{threads:E,pending:T.isPending,onOpen:pe}),!le&&ne&&!Ae&&(0,I.jsx)(j7,{}),!le&&se&&!Ae&&(Ne?(0,I.jsx)(M7,{label:`Scenario chat`,threadId:se,onOpenThread:pe,emptyHint:x5(M.errand)},se):(0,I.jsx)($7,{threadId:se,...me(se)?{runtime:me(se)}:{},onOpenThread:pe,landing:y},se===ue?e9:se)),!le&&ce&&!Ae&&(0,I.jsx)($7,{threadId:null,start:async()=>(await _e.mutateAsync({projectId:e})).threadId,startsAs:{projectId:e,kind:`project`},onStarted:e=>{de(e),pe(e)},onOpenThread:pe,landing:y},e9)]}),panel:Ee&&Ee!==`drive`&&!g&&(0,I.jsx)(L7,{view:Ee,views:Te,label:Zg,onSwitch:e=>we.dispatch({type:`switch`,view:e}),onCollapse:()=>we.dispatch({type:`collapse`}),onClose:()=>we.dispatch({type:`close`}),children:Fe(Ee)}),share:we.state.share,collapsed:we.state.collapsed,strip:Ee&&(0,I.jsx)(R7,{label:Zg(Ee),onExpand:()=>we.dispatch({type:`expand`}),onClose:()=>we.dispatch({type:`close`})}),onResize:e=>we.dispatch({type:`setWidth`,share:e}),onToggleFull:()=>we.dispatch({type:`toggleFull`})})})]})]})}function yre({dirty:e,onDismiss:t,children:n}){return(0,I.jsx)(aP,{open:!0,onClose:t,dirty:e,inline:!0,labelledBy:`park-draft-title`,backdropClassName:`min-h-0 overflow-y-auto bg-surface`,className:`max-w-[560px]`,children:n})}function bre({title:e,slug:t,oneLiner:n,notes:r,duplicate:i,busy:a,ready:o,onTitleChange:s,onOneLinerChange:c,onNotesChange:l,onSubmit:u,onCancel:d}){let f=()=>u(r.trim()||void 0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(oP,{id:`park-draft-title`,title:`Add to backlog`,description:`Write it down now, work it out later. Nothing is cut until you Start it.`,onClose:d}),(0,I.jsxs)(sP,{className:`flex flex-col gap-4 pt-1`,children:[(0,I.jsx)(kN,{label:`Title`,error:i,children:(0,I.jsx)(EN,{value:e,onChange:e=>s(e.target.value),placeholder:`e.g. Slack alerts on failed runs`,autoFocus:!0,invalid:!!i,onKeyDown:e=>{e.key===`Enter`&&f()}})}),(0,I.jsx)(kN,{label:`One-liner (optional)`,children:(0,I.jsx)(EN,{value:n,onChange:e=>c(e.target.value),placeholder:`What and why, in a sentence`,onKeyDown:e=>{e.key===`Enter`&&f()}})}),(0,I.jsx)(kN,{label:`Notes (optional — becomes the brief)`,children:(0,I.jsx)(ON,{rows:5,value:r,onChange:e=>l(e.target.value),placeholder:`Anything Start should know`})})]}),(0,I.jsxs)(cP,{start:(0,I.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(Fy,{size:14,className:`shrink-0 text-icon`}),(0,I.jsxs)(`span`,{className:`truncate font-mono`,children:[`feature/`,t||`…`,` · backlog`]})]}),children:[(0,I.jsx)(J,{variant:`ghost`,onClick:d,disabled:a,children:`Cancel`}),(0,I.jsx)(J,{variant:`primary`,icon:(0,I.jsx)(Jy,{}),onClick:f,disabled:!o||a,children:a?`Adding…`:`Add to backlog`})]})]})}function xre({projectId:e,onCancel:t,onCreated:n}){let[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(``),l=R.useUtils(),u=rx(),d=X_(r,R.feature.list.useQuery({projectId:e},{refetchInterval:tg()}).data??[]),f=async e=>{await l.feature.list.invalidate(),n(e)},p=R.feature.create.useMutation({onSuccess:e=>void f(e.id),onError:e=>u.push(e.message)}),m=p.isPending,h=!!r.trim(),g=!!r.trim()||!!a.trim()||!!s.trim(),_=t=>{!h||m||p.mutate({projectId:e,title:r.trim(),oneLiner:a.trim(),draft:!0,...t?{brief:t}:{}})};return(0,I.jsx)(yre,{dirty:g,onDismiss:t,children:e=>(0,I.jsx)(bre,{title:r,slug:Y_(r),oneLiner:a,notes:s,duplicate:d,busy:m,ready:h,onTitleChange:i,onOneLinerChange:o,onNotesChange:c,onSubmit:_,onCancel:e})})}function t9(){return(0,I.jsx)(XN,{icon:(0,I.jsx)(vb,{}),title:`Set this up on your computer.`,className:`min-h-0 flex-1`})}var n9=`Repo facts an agent establishes once — how to install, how to verify, what is already red — so no burn agent re-derives them per ticket.`;function Sre({projectId:e,onClose:t}){let n=R.useUtils(),r=rx(),i=tg(),a=R.project.list.useQuery().data?.find(t=>t.id===e),o=R.project.prep.useQuery({projectId:e},{refetchInterval:tg(3e3)}),s=R.thread.list.useQuery({projectId:e},{refetchInterval:i}).data??[],c=R.project.prepSession.useQuery({projectId:e},{refetchInterval:i}),[l,u]=(0,F.useState)(null),d=yx(s,`prepare`)??l??c.data?.id??null,f=R.project.talkToPrep.useMutation({onSuccess:()=>void n.project.prepSession.invalidate(),onError:()=>void 0}),p=R.project.dryRunStop.useMutation({onSuccess:()=>{n.project.prep.invalidate(),n.feature.driveInfo.invalidate()},onError:e=>r.push(e.message)}),m=o.data,h=m?.findings??[],g=m?.pendingKeys??[],_=h.filter(Lm).length,[v,y]=(0,F.useState)(!0),b=h.length>0||g.length>0;return zx()?(0,I.jsx)(`section`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,children:(0,I.jsx)(t9,{})}):(0,I.jsxs)(`section`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(MN,{crumbs:[{label:a?.name??`This project`,icon:(0,I.jsx)(Qy,{}),...t?{onClick:t}:{}},{label:`Preparation`,icon:(0,I.jsx)(ob,{})}],actions:b?(0,I.jsx)(Y,{label:v?`Hide what is established`:`Show what is established`,icon:(0,I.jsx)(Py,{}),active:v,onClick:()=>y(e=>!e)}):void 0}),m?.dryRun&&(0,I.jsx)(Ere,{open:Mv(m.dryRun),stopping:p.isPending,onStop:()=>p.mutate({projectId:e})}),(0,I.jsx)(RN,{aside:v&&b&&(0,I.jsx)(LN,{title:m?.prepared?`Established`:`To establish`,onClose:()=>y(!1),bodyClassName:`px-4 py-3`,children:(0,I.jsx)(Tre,{pending:g,findings:h,staleCount:_})}),children:(0,I.jsx)(M7,{label:`Preparation chat`,threadId:d,start:async()=>(await f.mutateAsync({projectId:e,holdOpening:!0})).sessionId,startsAs:{projectId:e,kind:`prepare`},onStarted:t=>{u(t),n.thread.list.invalidate({projectId:e})},draftKey:`prepare:${e}`,emptyHint:Cre(m?.prepared??!1),...m?{meta:wre(m)}:{}},`prepare`)})]})}function Cre(e){return e?`${n9} Repo facts drift; re-preparing measures them again with you there — values you typed by hand are never overwritten.`:`${n9} The agent works in your own checkout — it runs this repo's commands, records the answers, and asks you the ones only you know.`}function wre(e){return e.prepared?e.preparedAt===null?`Prepared`:`Prepared ${Mm(e.preparedAt)}`:e.pendingKeys.length>0?`${e.pendingKeys.length} to establish`:`Preparing`}function Tre({pending:e,findings:t,staleCount:n}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.length>0&&(0,I.jsx)(YA,{divided:!0,label:`To establish`,children:e.map((e,t)=>(0,I.jsx)(JA,{index:t,leading:(0,I.jsx)(kb,{}),title:Am[e]??e,meta:`Not yet`},e))}),n>0&&(0,I.jsx)(Dre,{count:n}),t.length>0&&(0,I.jsx)(Ore,{findings:t})]})}function Ere({open:e,stopping:t,onStop:n}){return(0,I.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-3 border-b border-border-subtle px-4 animate-fade-in`,children:[(0,I.jsx)(BA,{tone:`live`,size:`sm`,strong:!0,children:`Preparation dry run in progress`}),e&&(e.state===`ready`?(0,I.jsxs)(`a`,{className:q(`cursor-pointer text-accent-text no-underline decoration-accent-text/50 underline-offset-2 transition-colors duration-(--dur-1) ease-app hover:underline hover:decoration-accent-text`,`inline-flex min-w-0 items-center gap-1 truncate font-mono text-xs`),href:e.url,target:`_blank`,rel:`noreferrer`,children:[e.url,(0,I.jsx)(mb,{size:12,className:`shrink-0`})]}):(0,I.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-text-tertiary`,children:Nv(e)})),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(J,{variant:`ghost`,size:`sm`,icon:(0,I.jsx)(ab,{}),loading:t,disabled:t,onClick:n,children:`Stop`})]})}function Dre({count:e}){return(0,I.jsxs)(`div`,{className:`mb-4 flex max-w-[64ch] items-start gap-2 text-sm text-pretty text-text-secondary`,children:[(0,I.jsx)(Sb,{size:16,className:`mt-0.5 shrink-0 text-warning`}),(0,I.jsxs)(`span`,{children:[e,` finding`,e===1?` has`:`s have`,` not been re-measured in a long time. A stale test baseline is worse than none — agents trust it and file their own breakage under “already red on main”.`]})]})}function Ore({findings:e}){return(0,I.jsx)(`div`,{className:`flex flex-col [&>details:last-child]:border-b [&>details:last-child]:border-border-subtle`,children:e.map((e,t)=>(0,I.jsx)(kre,{finding:e,label:Am[e.key]??e.key,index:t},e.key))})}function kre({finding:e,label:t,index:n}){let[r,i]=(0,F.useState)(!1),a=Rm(e),o=Lm(e);return(0,I.jsx)($N,{title:t,index:n,aside:(0,I.jsxs)(`span`,{className:`flex items-center gap-4`,children:[o&&(0,I.jsx)(BA,{tone:`warning`,children:`Stale`}),(0,I.jsx)(Are,{finding:e}),(0,I.jsx)(BA,{title:a.title,children:a.label})]}),children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`div`,{className:q(`text-xs`,o?`text-warning-text`:`text-text-tertiary`),children:Pm(e)}),e.evidence&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`rounded-md border border-border-subtle bg-surface-inset px-3 py-2`,children:(0,I.jsx)(`div`,{className:q(`font-mono text-xs leading-[1.5] break-words whitespace-pre-wrap text-text-secondary`,!r&&`line-clamp-3`),children:e.evidence})}),(0,I.jsx)(J,{variant:`ghost`,size:`sm`,className:`-ml-2 self-start`,onClick:()=>i(e=>!e),"aria-expanded":r,"aria-label":`${r?`Collapse`:`Show full`} evidence for ${t}`,children:r?`Show less`:`Show full evidence`})]})]})})}function Are({finding:e}){return Nm(e.key)?e.verifiedAt===void 0?(0,I.jsx)(BA,{tone:`warning`,title:`No dry run has ever proven this value — a drive that depends on it may fall over`,children:`Unproven`}):(0,I.jsxs)(BA,{tone:`success`,icon:(0,I.jsx)(zy,{size:14}),title:`A preparation dry run ran this value on the real drive machinery and it worked`,children:[`Proven `,Mm(e.verifiedAt)]}):null}var r9=(e,t)=>e===``||t.includes(e);function jre(e){let{open:t,onClose:n,features:r,selectedFeatureId:i,onSelect:a,onOpenSettings:o,onOpenPreparation:s,onOpenProjectChat:c,onOpenNote:l,onToggleSidebar:u,onToggleDetails:d,nav:f}=e,p=uF(),[m,h]=(0,F.useState)(``),[g,_]=(0,F.useState)(0),v=(0,F.useRef)(null),y=(0,F.useRef)([]);(0,F.useEffect)(()=>{if(!t)return;h(``),_(0),v.current?.focus();let e=requestAnimationFrame(()=>v.current?.focus());return()=>cancelAnimationFrame(e)},[t]),(0,F.useEffect)(()=>{if(!t)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n]),(0,F.useEffect)(()=>{_(0)},[m]);let b=m.trim().toLowerCase(),x=(0,F.useMemo)(()=>b===``?r:r.filter(e=>e.slug.toLowerCase().includes(b)||e.title.toLowerCase().includes(b)),[r,b]),S=(0,F.useMemo)(()=>(f.projects??[]).filter(e=>e.id!==f.currentProjectId),[f.projects,f.currentProjectId]),C=(0,F.useMemo)(()=>b===``?S:S.filter(e=>e.name.toLowerCase().includes(b)),[S,b]),w=(0,F.useMemo)(()=>{let e=p.resolved===`dark`?`light`:`dark`;return[{kind:`projectChat`,shows:Ay(b),glyph:(0,I.jsx)(Zy,{}),label:`Orchestrator`,run:c},{kind:`newNote`,shows:r9(b,`new note jot capture`),glyph:(0,I.jsx)(Yy,{}),label:`New note`,kbd:DP(`J`),run:l},{kind:`preparation`,shows:ky(b),glyph:(0,I.jsx)(ob,{}),label:`Preparation`,run:s},{kind:`settings`,shows:r9(b,`settings preferences`),glyph:(0,I.jsx)(Ny,{}),label:`Settings`,run:o},{kind:`theme`,shows:r9(b,`toggle theme dark light appearance ${e}`),glyph:p.resolved===`dark`?(0,I.jsx)(gb,{}):(0,I.jsx)(_b,{}),label:`Switch to ${e} theme`,run:p.toggle},...u?[{kind:`sidebar`,shows:r9(b,`toggle sidebar hide show collapse expand`),glyph:(0,I.jsx)(fb,{}),label:`Toggle sidebar`,kbd:DP(`B`),run:u}]:[],...d?[{kind:`details`,shows:r9(b,`toggle details panel inspector hide show`),glyph:(0,I.jsx)(Py,{}),label:`Toggle details panel`,run:d}]:[],{kind:`home`,shows:r9(b,`all projects home`),glyph:(0,I.jsx)(Qy,{}),label:`All projects`,run:f.goHome},{kind:`openProject`,shows:r9(b,`open a project`),glyph:(0,I.jsx)(Ry,{}),label:`Open a project…`,run:f.showOpen}].filter(e=>e.shows)},[b,p.resolved,p.toggle,c,l,o,s,u,d,f]),T=(0,F.useMemo)(()=>{let e=x.map(e=>({kind:`feature`,feature:e}));for(let t of C)e.push({kind:`project`,id:t.id,name:t.name});for(let t of w)e.push({kind:`action`,action:t});return e},[x,C,w]);if(!t)return null;let E=e=>{if(T.length===0)return;let t=(g+e+T.length)%T.length;_(t),y.current[t]?.scrollIntoView({block:`nearest`})},D=e=>{let t=T[e];if(t){switch(t.kind){case`feature`:a(t.feature.id);break;case`project`:f.enterProject(t.id);break;case`action`:t.action.run();break}n()}},O=e=>{e.key===`ArrowDown`?(e.preventDefault(),E(1)):e.key===`ArrowUp`?(e.preventDefault(),E(-1)):e.key===`Enter`?(e.preventDefault(),D(g)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=x.length,ee=k+C.length,A=(e,t,n,r,i,a)=>(0,I.jsxs)(`div`,{ref:t=>{y.current[e]=t},role:`option`,"aria-selected":e===g,"data-selected":e===g,className:q(Ux,Wx,`min-h-8 hover:bg-transparent`),onMouseMove:()=>e!==g&&_(e),onClick:()=>D(e),children:[(0,I.jsx)(`span`,{className:`inline-flex size-4 shrink-0 items-center justify-center [&>svg]:size-4`,children:n}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:r}),i]},t),j=e=>(0,I.jsx)(`div`,{className:q(Kx,`pt-2.5`),children:e});return(0,I.jsx)(`div`,{className:`fixed inset-0 z-[300] flex animate-backdrop-in items-start justify-center bg-scrim px-4 pt-[12vh] pb-4`,onMouseDown:e=>{e.target===e.currentTarget&&n()},children:(0,I.jsxs)(`div`,{role:`dialog`,"aria-label":`Command palette`,className:`flex max-h-[min(520px,76vh)] w-full max-w-[560px] animate-dialog-in flex-col overflow-hidden rounded-lg bg-surface-raised text-text shadow-dialog`,children:[(0,I.jsxs)(`div`,{className:`flex h-13 shrink-0 items-center gap-3 border-b border-border-subtle px-4`,children:[(0,I.jsx)(My,{size:16,className:`shrink-0 text-icon`}),(0,I.jsx)(`input`,{ref:v,className:`h-full min-w-0 flex-1 border-0 bg-transparent p-0 font-sans text-base text-text outline-none placeholder:text-text-tertiary`,placeholder:`Search features, projects, or jump to…`,value:m,onChange:e=>h(e.target.value),onKeyDown:O,"aria-label":`Search features, projects, or jump to`})]}),(0,I.jsxs)(`div`,{role:`listbox`,"aria-label":`Results`,className:`min-h-0 flex-1 overflow-y-auto p-1.5 [scrollbar-width:thin]`,children:[x.length>0&&j(`Features`),x.map((e,t)=>A(t,e.id,(0,I.jsx)(AI,{f:e,label:``}),e.title,(0,I.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-text-tertiary`,children:[e.id===i&&(0,I.jsx)(`span`,{className:`text-text-secondary`,children:`Current`}),(0,I.jsx)(`span`,{children:MI(e)})]}),e.title)),C.length>0&&j(`Projects`),C.map((e,t)=>A(k+t,e.id,(0,I.jsx)(Qy,{className:`text-icon`}),e.name,(0,I.jsx)(`span`,{className:`shrink-0 text-xs text-text-tertiary`,children:`Switch`}),e.name)),w.length>0&&j(`Actions`),w.map((e,t)=>A(ee+t,e.kind,e.glyph,e.label,e.kbd?(0,I.jsx)(Yx,{children:e.kbd}):null,e.label)),T.length===0&&(0,I.jsx)(XN,{compact:!0,icon:(0,I.jsx)(My,{}),title:`No matches`})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4 border-t border-border-subtle px-4 py-2 text-xs text-text-tertiary`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(Yx,{children:`↑`}),(0,I.jsx)(Yx,{children:`↓`}),` to move`]}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(Yx,{children:`Enter`}),` to open`]}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(Yx,{children:`Esc`}),` to close`]})]})]})})}var Mre=1500,Nre=`flex h-13 items-center gap-3 px-4`,i9=160;function Pre(e){let t=e.style.height;e.style.height=`auto`;let n=e.scrollHeight;e.style.height=t,e.offsetHeight,e.style.height=`${Math.min(n,i9)}px`,e.style.overflowY=n>i9?`auto`:`hidden`}function Fre({projectId:e,projectName:t,open:n,openRequest:r=0,onClose:i,onOpenInbox:a}){let o=R.useUtils(),s=rx(),c=zx(),[l,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(!1),[h,g]=(0,F.useState)(!1),_=(0,F.useRef)(null),v=(0,F.useRef)(0),y=()=>{u(``),f(null),m(!1),g(!1)},[b,x]=(0,F.useState)(n);n!==b&&(x(n),v.current+=1,n&&y());let[S,C]=(0,F.useState)(r);r!==S&&(C(r),n&&h&&y()),(0,F.useEffect)(()=>{n&&_.current?.focus()},[r]),(0,F.useLayoutEffect)(()=>{_.current&&Pre(_.current)},[l,n,h]);let w=R.projectNotes.add.useMutation(),T=R.projectNotes.openCount.useQuery({projectId:e},{enabled:n}),E=(0,F.useRef)(null);(0,F.useEffect)(()=>{E.current=d?.preview??null},[d]),(0,F.useEffect)(()=>{if(n)return()=>{E.current&&URL.revokeObjectURL(E.current)}},[n]);let D=(0,F.useRef)(i);D.current=i,(0,F.useEffect)(()=>{if(!h)return;let e=setTimeout(()=>D.current(),Mre);return()=>clearTimeout(e)},[h]);let O=async e=>{try{let t=await Gh(e),n={png:t,preview:URL.createObjectURL(t)};f(e=>(e&&URL.revokeObjectURL(e.preview),n))}catch(e){s.push(e instanceof Error?e.message:`that image could not be read`)}},k=()=>{f(e=>(e&&URL.revokeObjectURL(e.preview),null)),_.current?.focus()},ee=e=>{let t=Wh(e.clipboardData);t&&(e.preventDefault(),O(t))},A=async()=>{if(!l.trim()||p)return;let t=v.current,n=()=>v.current===t;m(!0);try{let t=await w.mutateAsync({projectId:e,text:l});if(d)try{await ax(t.id,d.png)}catch(e){s.push(`the note was saved, but its picture was not: ${e instanceof Error?e.message:String(e)}`)}o.projectNotes.openCount.setData({projectId:e},e=>e===void 0?e:e+1),o.projectNotes.invalidate(),n()&&g(!0)}catch(e){s.push(e instanceof Error?e.message:`the note could not be saved`)}finally{n()&&m(!1)}};return(0,I.jsx)(aP,{open:n,onClose:i,size:`palette`,scrim:h?`none`:`light`,className:`overflow-hidden`,label:`Jot a note`,initialFocusRef:_,children:h?(0,I.jsxs)(`div`,{className:q(Nre,`text-sm animate-fade-in`),role:`status`,children:[(0,I.jsx)(`span`,{className:`flex shrink-0 items-center text-success`,children:(0,I.jsx)(zy,{size:16})}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-text-secondary`,children:[`Noted in `,(0,I.jsx)(`span`,{className:`font-medium text-text`,children:t}),T.data!==void 0&&(0,I.jsxs)(I.Fragment,{children:[` · `,T.data,` open`]})]}),!c&&(0,I.jsx)(`button`,{className:q(`cursor-pointer text-accent-text no-underline decoration-accent-text/50 underline-offset-2 transition-colors duration-(--dur-1) ease-app hover:underline hover:decoration-accent-text`,`text-sm`),onClick:()=>{a(),i()},title:`Read the pile on the project workspace`,children:`View`})]}):(0,I.jsxs)(`div`,{onPaste:ee,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-border-subtle px-4`,children:[(0,I.jsx)(`span`,{className:`flex h-13 shrink-0 items-center text-icon`,children:(0,I.jsx)(Yy,{size:16})}),(0,I.jsx)(`textarea`,{ref:_,rows:1,className:q(`box-border block min-w-0 flex-1 resize-none border-0 bg-transparent px-0 py-3.75 font-sans text-text outline-none transition-[height] duration-(--dur-2) ease-app placeholder:text-text-tertiary`,c?`text-[16px]`:`text-base`),autoComplete:`off`,"aria-label":`what did you just notice?`,placeholder:`What did you just notice?`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{c||e.key!==`Enter`||e.shiftKey||(e.preventDefault(),A())}})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-4 py-2 text-xs text-text-tertiary`,children:[d?(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-text-secondary animate-fade-in`,children:[(0,I.jsx)(`img`,{src:d.preview,alt:`the picture this note will carry`,className:`h-5 w-8 rounded-sm bg-surface-inset object-cover`}),`Screenshot`,(0,I.jsx)(Y,{size:`sm`,label:`Remove the picture`,icon:(0,I.jsx)(By,{}),onClick:k})]}):c?null:(0,I.jsx)(`span`,{children:`Paste a screenshot`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsxs)(`span`,{children:[`to `,(0,I.jsx)(`span`,{className:`font-medium text-text-secondary`,children:t})]}),c?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(J,{size:`touch`,variant:`ghost`,onClick:i,children:`Close`}),(0,I.jsx)(J,{size:`touch`,variant:`primary`,loading:p,disabled:!l.trim(),onClick:()=>void A(),children:`Save`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(Yx,{children:`↵`}),` save`]}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(Yx,{children:`⇧↵`}),` new line`]}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(Yx,{children:`esc`}),` close`]})]})]})]})})}var a9={"claude-code":{check:`afk-key`,kind:`token`},codex:{check:`auth`,kind:`sign-in`}};function Ire(e){return md.flatMap(t=>{let{check:n,kind:r}=a9[t],i=e.find(e=>e.runtime===t&&e.check===n);return i?[{runtime:t,kind:r,probe:i}]:[]})}function o9(e){return`${a9[e].check}-${e}`}function Lre(e){let t=Bm[e],n=a9[e].kind===`token`;return{field:o9(e),label:n?`${t} token`:t,reason:n?`workers on ${t} need a token`:`sign in to ${t}`,terms:n?[t,`token`,`AFK credential`]:[t,`sign in`,`login`]}}var s9=[{field:`container-runtime`,label:`Container runtime`,reason:`no container runtime on this machine`,terms:[`Container runtime`,`Docker`,`Podman`]},{field:`sandcastle-image`,label:`Sandcastle image`,reason:`the sandcastle image needs building`,terms:[`Sandcastle image`,`build`,`rebuild`]},...md.map(Lre),{field:`burn-cache`,label:`Worker cache`,terms:[`Worker cache`,`Burn cache`,`volume`,`clear`]}];function Rre(e){let t=e.find(e=>!e.ok);return t?{count:`${e.filter(e=>e.ok).length} of ${e.length}`,text:`ready — ${t.reason}`}:{count:null,text:`Ready for unattended workers`}}var c9=[{page:`general`,label:`General`,Icon:Ny},{page:`models`,label:`Models`,Icon:$y},{page:`burns`,label:`Workers`,Icon:eb},{page:`project`,label:`This project`,Icon:Qy}];function zre({page:e,filter:t,filterRef:n,projectName:r,onFilter:i,onSelect:a}){let o=t.query.trim()!==``;return(0,I.jsxs)(`nav`,{"aria-label":`Settings pages`,className:`flex min-h-0 flex-col gap-0.5 border-r border-border-subtle bg-canvas px-2 pt-4 pb-3`,children:[(0,I.jsx)(`div`,{className:`mb-2 px-2.5 text-sm font-medium text-text`,children:`Settings`}),(0,I.jsx)(DN,{ref:n,size:`md`,"aria-label":`Filter settings`,placeholder:`Filter`,kbd:`Ctrl F`,autoComplete:`off`,value:t.query,onChange:e=>i(e.target.value),className:`mb-3`}),c9.map(({page:n,label:r,Icon:i})=>(0,I.jsx)(qA,{label:r,icon:(0,I.jsx)(i,{}),active:n===e,onClick:()=>a(n),meta:o?t.counts[n]||``:void 0},n)),(0,I.jsx)(`div`,{className:`flex-1`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 px-2.5 pt-3`,children:[(0,I.jsx)(`span`,{className:`text-xs text-text-tertiary`,children:`This project is`}),(0,I.jsx)(`span`,{className:`truncate text-xs text-text-secondary`,title:r,children:r})]})]})}var l9=function(e,t){let n=e,r=d9[t],i=null,a=0,o=null,s=[],c={},l=function(e,t){a=n*4+17,i=function(e){let t=Array(e);for(let n=0;n<e;n+=1){t[n]=Array(e);for(let r=0;r<e;r+=1)t[n][r]=null}return t}(a),u(0,0),u(a-7,0),u(0,a-7),p(),f(),h(e,t),n>=7&&m(e),o??=v(n,r,s),g(o,t)},u=function(e,t){for(let n=-1;n<=7;n+=1)if(!(e+n<=-1||a<=e+n))for(let r=-1;r<=7;r+=1)t+r<=-1||a<=t+r||(0<=n&&n<=6&&(r==0||r==6)||0<=r&&r<=6&&(n==0||n==6)||2<=n&&n<=4&&2<=r&&r<=4?i[e+n][t+r]=!0:i[e+n][t+r]=!1)},d=function(){let e=0,t=0;for(let n=0;n<8;n+=1){l(!0,n);let r=p9.getLostPoint(c);(n==0||e>r)&&(e=r,t=n)}return t},f=function(){for(let e=8;e<a-8;e+=1)i[e][6]??(i[e][6]=e%2==0);for(let e=8;e<a-8;e+=1)i[6][e]??(i[6][e]=e%2==0)},p=function(){let e=p9.getPatternPosition(n);for(let t=0;t<e.length;t+=1)for(let n=0;n<e.length;n+=1){let r=e[t],a=e[n];if(i[r][a]==null)for(let e=-2;e<=2;e+=1)for(let t=-2;t<=2;t+=1)e==-2||e==2||t==-2||t==2||e==0&&t==0?i[r+e][a+t]=!0:i[r+e][a+t]=!1}},m=function(e){let t=p9.getBCHTypeNumber(n);for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[Math.floor(n/3)][n%3+a-8-3]=r}for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[n%3+a-8-3][Math.floor(n/3)]=r}},h=function(e,t){let n=r<<3|t,o=p9.getBCHTypeInfo(n);for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<6?i[t][8]=n:t<8?i[t+1][8]=n:i[a-15+t][8]=n}for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<8?i[8][a-t-1]=n:t<9?i[8][15-t-1+1]=n:i[8][15-t-1]=n}i[a-8][8]=!e},g=function(e,t){let n=-1,r=a-1,o=7,s=0,c=p9.getMaskFunction(t);for(let t=a-1;t>0;t-=2)for(t==6&&--t;;){for(let n=0;n<2;n+=1)if(i[r][t-n]==null){let a=!1;s<e.length&&(a=(e[s]>>>o&1)==1),c(r,t-n)&&(a=!a),i[r][t-n]=a,--o,o==-1&&(s+=1,o=7)}if(r+=n,r<0||a<=r){r-=n,n=-n;break}}},_=function(e,t){let n=0,r=0,i=0,a=Array(t.length),o=Array(t.length);for(let s=0;s<t.length;s+=1){let c=t[s].dataCount,l=t[s].totalCount-c;r=Math.max(r,c),i=Math.max(i,l),a[s]=Array(c);for(let t=0;t<a[s].length;t+=1)a[s][t]=255&e.getBuffer()[t+n];n+=c;let u=p9.getErrorCorrectPolynomial(l),d=h9(a[s],u.getLength()-1).mod(u);o[s]=Array(u.getLength()-1);for(let e=0;e<o[s].length;e+=1){let t=e+d.getLength()-o[s].length;o[s][e]=t>=0?d.getAt(t):0}}let s=0;for(let e=0;e<t.length;e+=1)s+=t[e].totalCount;let c=Array(s),l=0;for(let e=0;e<r;e+=1)for(let n=0;n<t.length;n+=1)e<a[n].length&&(c[l]=a[n][e],l+=1);for(let e=0;e<i;e+=1)for(let n=0;n<t.length;n+=1)e<o[n].length&&(c[l]=o[n][e],l+=1);return c},v=function(e,t,n){let r=g9.getRSBlocks(e,t),i=_9();for(let t=0;t<n.length;t+=1){let r=n[t];i.put(r.getMode(),4),i.put(r.getLength(),p9.getLengthInBits(r.getMode(),e)),r.write(i)}let a=0;for(let e=0;e<r.length;e+=1)a+=r[e].dataCount;if(i.getLengthInBits()>a*8)throw`code length overflow. (`+i.getLengthInBits()+`>`+a*8+`)`;for(i.getLengthInBits()+4<=a*8&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=a*8||(i.put(236,8),i.getLengthInBits()>=a*8));)i.put(17,8);return _(i,r)};c.addData=function(e,t){t||=`Byte`;let n=null;switch(t){case`Numeric`:n=Bre(e);break;case`Alphanumeric`:n=Vre(e);break;case`Byte`:n=Hre(e);break;case`Kanji`:n=Ure(e);break;default:throw`mode:`+t}s.push(n),o=null},c.isDark=function(e,t){if(e<0||a<=e||t<0||a<=t)throw e+`,`+t;return i[e][t]},c.getModuleCount=function(){return a},c.make=function(){if(n<1){let e=1;for(;e<40;e++){let t=g9.getRSBlocks(e,r),n=_9();for(let t=0;t<s.length;t++){let r=s[t];n.put(r.getMode(),4),n.put(r.getLength(),p9.getLengthInBits(r.getMode(),e)),r.write(n)}let i=0;for(let e=0;e<t.length;e++)i+=t[e].dataCount;if(n.getLengthInBits()<=i*8)break}n=e}l(!1,d())},c.createTableTag=function(e,t){e||=2,t=t===void 0?e*4:t;let n=``;n+=`<table style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: `+t+`px;`,n+=`">`,n+=`<tbody>`;for(let t=0;t<c.getModuleCount();t+=1){n+=`<tr>`;for(let r=0;r<c.getModuleCount();r+=1)n+=`<td style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: 0px;`,n+=` width: `+e+`px;`,n+=` height: `+e+`px;`,n+=` background-color: `,n+=c.isDark(t,r)?`#000000`:`#ffffff`,n+=`;`,n+=`"/>`;n+=`</tr>`}return n+=`</tbody>`,n+=`</table>`,n},c.createSvgTag=function(e,t,n,r){let i={};typeof arguments[0]==`object`&&(i=arguments[0],e=i.cellSize,t=i.margin,n=i.alt,r=i.title),e||=2,t=t===void 0?e*4:t,n=typeof n==`string`?{text:n}:n||{},n.text=n.text||null,n.id=n.text?n.id||`qrcode-description`:null,r=typeof r==`string`?{text:r}:r||{},r.text=r.text||null,r.id=r.text?r.id||`qrcode-title`:null;let a=c.getModuleCount()*e+t*2,o,s,l,u,d=``,f;for(f=`l`+e+`,0 0,`+e+` -`+e+`,0 0,-`+e+`z `,d+=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg"`,d+=i.scalable?``:` width="`+a+`px" height="`+a+`px"`,d+=` viewBox="0 0 `+a+` `+a+`" `,d+=` preserveAspectRatio="xMinYMin meet"`,d+=r.text||n.text?` role="img" aria-labelledby="`+y([r.id,n.id].join(` `).trim())+`"`:``,d+=`>`,d+=r.text?`<title id="`+y(r.id)+`">`+y(r.text)+`</title>`:``,d+=n.text?`<description id="`+y(n.id)+`">`+y(n.text)+`</description>`:``,d+=`<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>`,d+=`<path d="`,l=0;l<c.getModuleCount();l+=1)for(u=l*e+t,o=0;o<c.getModuleCount();o+=1)c.isDark(l,o)&&(s=o*e+t,d+=`M`+s+`,`+u+f);return d+=`" stroke="transparent" fill="black"/>`,d+=`</svg>`,d},c.createDataURL=function(e,t){e||=2,t=t===void 0?e*4:t;let n=c.getModuleCount()*e+t*2,r=t,i=n-t;return qre(n,n,function(t,n){if(r<=t&&t<i&&r<=n&&n<i){let i=Math.floor((t-r)/e),a=Math.floor((n-r)/e);return+!c.isDark(a,i)}else return 1})},c.createImgTag=function(e,t,n){e||=2,t=t===void 0?e*4:t;let r=c.getModuleCount()*e+t*2,i=``;return i+=`<img`,i+=` src="`,i+=c.createDataURL(e,t),i+=`"`,i+=` width="`,i+=r,i+=`"`,i+=` height="`,i+=r,i+=`"`,n&&(i+=` alt="`,i+=y(n),i+=`"`),i+=`/>`,i};let y=function(e){let t=``;for(let n=0;n<e.length;n+=1){let r=e.charAt(n);switch(r){case`<`:t+=`<`;break;case`>`:t+=`>`;break;case`&`:t+=`&`;break;case`"`:t+=`"`;break;default:t+=r;break}}return t},b=function(e){e=e===void 0?2:e;let t=c.getModuleCount()*1+e*2,n=e,r=t-e,i,a,o,s,l,u={"██":`█`,"█ ":`▀`," █":`▄`," ":` `},d={"██":`▀`,"█ ":`▀`," █":` `," ":` `},f=``;for(i=0;i<t;i+=2){for(o=Math.floor((i-n)/1),s=Math.floor((i+1-n)/1),a=0;a<t;a+=1)l=`█`,n<=a&&a<r&&n<=i&&i<r&&c.isDark(o,Math.floor((a-n)/1))&&(l=` `),n<=a&&a<r&&n<=i+1&&i+1<r&&c.isDark(s,Math.floor((a-n)/1))?l+=` `:l+=`█`,f+=e<1&&i+1>=r?d[l]:u[l];f+=`
|
|
191
|
-
`}return t%2&&e>0?f.substring(0,f.length-t-1)+Array(t+1).join(`▀`):f.substring(0,f.length-1)};return c.createASCII=function(e,t){if(e||=1,e<2)return b(t);--e,t=t===void 0?e*2:t;let n=c.getModuleCount()*e+t*2,r=t,i=n-t,a,o,s,l,u=Array(e+1).join(`██`),d=Array(e+1).join(` `),f=``,p=``;for(a=0;a<n;a+=1){for(s=Math.floor((a-r)/e),p=``,o=0;o<n;o+=1)l=1,r<=o&&o<i&&r<=a&&a<i&&c.isDark(s,Math.floor((o-r)/e))&&(l=0),p+=l?u:d;for(s=0;s<e;s+=1)f+=p+`
|
|
192
|
-
`}return f.substring(0,f.length-1)},c.renderTo2dContext=function(e,t){t||=2;let n=c.getModuleCount();for(let r=0;r<n;r++)for(let i=0;i<n;i++)e.fillStyle=c.isDark(r,i)?`black`:`white`,e.fillRect(i*t,r*t,t,t)},c};l9.stringToBytes=function(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);t.push(r&255)}return t},l9.createStringToBytes=function(e,t){let n=function(){let n=Gre(e),r=function(){let e=n.read();if(e==-1)throw`eof`;return e},i=0,a={};for(;;){let e=n.read();if(e==-1)break;let t=r(),o=r(),s=r(),c=String.fromCharCode(e<<8|t);a[c]=o<<8|s,i+=1}if(i!=t)throw i+` != `+t;return a}();return function(e){let t=[];for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);if(i<128)t.push(i);else{let i=n[e.charAt(r)];typeof i==`number`?(i&255)==i?t.push(i):(t.push(i>>>8),t.push(i&255)):t.push(63)}}return t}};var u9={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},d9={L:1,M:0,Q:3,H:2},f9={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},p9=function(){let e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,n=7973,r={},i=function(e){let t=0;for(;e!=0;)t+=1,e>>>=1;return t};return r.getBCHTypeInfo=function(e){let n=e<<10;for(;i(n)-i(t)>=0;)n^=t<<i(n)-i(t);return(e<<10|n)^21522},r.getBCHTypeNumber=function(e){let t=e<<12;for(;i(t)-i(n)>=0;)t^=n<<i(t)-i(n);return e<<12|t},r.getPatternPosition=function(t){return e[t-1]},r.getMaskFunction=function(e){switch(e){case f9.PATTERN000:return function(e,t){return(e+t)%2==0};case f9.PATTERN001:return function(e,t){return e%2==0};case f9.PATTERN010:return function(e,t){return t%3==0};case f9.PATTERN011:return function(e,t){return(e+t)%3==0};case f9.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case f9.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case f9.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case f9.PATTERN111:return function(e,t){return(e*t%3+(e+t)%2)%2==0};default:throw`bad maskPattern:`+e}},r.getErrorCorrectPolynomial=function(e){let t=h9([1],0);for(let n=0;n<e;n+=1)t=t.multiply(h9([1,m9.gexp(n)],0));return t},r.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case u9.MODE_NUMBER:return 10;case u9.MODE_ALPHA_NUM:return 9;case u9.MODE_8BIT_BYTE:return 8;case u9.MODE_KANJI:return 8;default:throw`mode:`+e}else if(t<27)switch(e){case u9.MODE_NUMBER:return 12;case u9.MODE_ALPHA_NUM:return 11;case u9.MODE_8BIT_BYTE:return 16;case u9.MODE_KANJI:return 10;default:throw`mode:`+e}else if(t<41)switch(e){case u9.MODE_NUMBER:return 14;case u9.MODE_ALPHA_NUM:return 13;case u9.MODE_8BIT_BYTE:return 16;case u9.MODE_KANJI:return 12;default:throw`mode:`+e}else throw`type:`+t},r.getLostPoint=function(e){let t=e.getModuleCount(),n=0;for(let r=0;r<t;r+=1)for(let i=0;i<t;i+=1){let a=0,o=e.isDark(r,i);for(let n=-1;n<=1;n+=1)if(!(r+n<0||t<=r+n))for(let s=-1;s<=1;s+=1)i+s<0||t<=i+s||n==0&&s==0||o==e.isDark(r+n,i+s)&&(a+=1);a>5&&(n+=3+a-5)}for(let r=0;r<t-1;r+=1)for(let i=0;i<t-1;i+=1){let t=0;e.isDark(r,i)&&(t+=1),e.isDark(r+1,i)&&(t+=1),e.isDark(r,i+1)&&(t+=1),e.isDark(r+1,i+1)&&(t+=1),(t==0||t==4)&&(n+=3)}for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(r,i)&&!e.isDark(r,i+1)&&e.isDark(r,i+2)&&e.isDark(r,i+3)&&e.isDark(r,i+4)&&!e.isDark(r,i+5)&&e.isDark(r,i+6)&&(n+=40);for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(i,r)&&!e.isDark(i+1,r)&&e.isDark(i+2,r)&&e.isDark(i+3,r)&&e.isDark(i+4,r)&&!e.isDark(i+5,r)&&e.isDark(i+6,r)&&(n+=40);let r=0;for(let n=0;n<t;n+=1)for(let i=0;i<t;i+=1)e.isDark(i,n)&&(r+=1);let i=Math.abs(100*r/t/t-50)/5;return n+=i*10,n},r}(),m9=function(){let e=Array(256),t=Array(256);for(let t=0;t<8;t+=1)e[t]=1<<t;for(let t=8;t<256;t+=1)e[t]=e[t-4]^e[t-5]^e[t-6]^e[t-8];for(let n=0;n<255;n+=1)t[e[n]]=n;let n={};return n.glog=function(e){if(e<1)throw`glog(`+e+`)`;return t[e]},n.gexp=function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return e[t]},n}(),h9=function(e,t){if(e.length===void 0)throw e.length+`/`+t;let n=function(){let n=0;for(;n<e.length&&e[n]==0;)n+=1;let r=Array(e.length-n+t);for(let t=0;t<e.length-n;t+=1)r[t]=e[t+n];return r}(),r={};return r.getAt=function(e){return n[e]},r.getLength=function(){return n.length},r.multiply=function(e){let t=Array(r.getLength()+e.getLength()-1);for(let n=0;n<r.getLength();n+=1)for(let i=0;i<e.getLength();i+=1)t[n+i]^=m9.gexp(m9.glog(r.getAt(n))+m9.glog(e.getAt(i)));return h9(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;let t=m9.glog(r.getAt(0))-m9.glog(e.getAt(0)),n=Array(r.getLength());for(let e=0;e<r.getLength();e+=1)n[e]=r.getAt(e);for(let r=0;r<e.getLength();r+=1)n[r]^=m9.gexp(m9.glog(e.getAt(r))+t);return h9(n,0).mod(e)},r},g9=function(){let e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(e,t){let n={};return n.totalCount=e,n.dataCount=t,n},n={},r=function(t,n){switch(n){case d9.L:return e[(t-1)*4+0];case d9.M:return e[(t-1)*4+1];case d9.Q:return e[(t-1)*4+2];case d9.H:return e[(t-1)*4+3];default:return}};return n.getRSBlocks=function(e,n){let i=r(e,n);if(i===void 0)throw`bad rs block @ typeNumber:`+e+`/errorCorrectionLevel:`+n;let a=i.length/3,o=[];for(let e=0;e<a;e+=1){let n=i[e*3+0],r=i[e*3+1],a=i[e*3+2];for(let e=0;e<n;e+=1)o.push(t(r,a))}return o},n}(),_9=function(){let e=[],t=0,n={};return n.getBuffer=function(){return e},n.getAt=function(t){let n=Math.floor(t/8);return(e[n]>>>7-t%8&1)==1},n.put=function(e,t){for(let r=0;r<t;r+=1)n.putBit((e>>>t-r-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(n){let r=Math.floor(t/8);e.length<=r&&e.push(0),n&&(e[r]|=128>>>t%8),t+=1},n},Bre=function(e){let t=u9.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+2<t.length;)e.put(i(t.substring(r,r+3)),10),r+=3;r<t.length&&(t.length-r==1?e.put(i(t.substring(r,r+1)),4):t.length-r==2&&e.put(i(t.substring(r,r+2)),7))};let i=function(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*10+a(e.charAt(n));return t},a=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;throw`illegal char :`+e};return r},Vre=function(e){let t=u9.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+1<t.length;)e.put(i(t.charAt(r))*45+i(t.charAt(r+1)),11),r+=2;r<t.length&&e.put(i(t.charAt(r)),6)};let i=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;if(`A`<=e&&e<=`Z`)return e.charCodeAt(0)-65+10;switch(e){case` `:return 36;case`$`:return 37;case`%`:return 38;case`*`:return 39;case`+`:return 40;case`-`:return 41;case`.`:return 42;case`/`:return 43;case`:`:return 44;default:throw`illegal char :`+e}};return r},Hre=function(e){let t=u9.MODE_8BIT_BYTE,n=l9.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){for(let t=0;t<n.length;t+=1)e.put(n[t],8)},r},Ure=function(e){let t=u9.MODE_KANJI,n=l9.stringToBytes;(function(e,t){let r=n(e);if(r.length!=2||(r[0]<<8|r[1])!=t)throw`sjis not supported.`})(`友`,38726);let r=n(e),i={};return i.getMode=function(){return t},i.getLength=function(e){return~~(r.length/2)},i.write=function(e){let t=r,n=0;for(;n+1<t.length;){let r=(255&t[n])<<8|255&t[n+1];if(33088<=r&&r<=40956)r-=33088;else if(57408<=r&&r<=60351)r-=49472;else throw`illegal char at `+(n+1)+`/`+r;r=(r>>>8&255)*192+(r&255),e.put(r,13),n+=2}if(n<t.length)throw`illegal char at `+(n+1)},i},v9=function(){let e=[],t={};return t.writeByte=function(t){e.push(t&255)},t.writeShort=function(e){t.writeByte(e),t.writeByte(e>>>8)},t.writeBytes=function(e,n,r){n||=0,r||=e.length;for(let i=0;i<r;i+=1)t.writeByte(e[i+n])},t.writeString=function(e){for(let n=0;n<e.length;n+=1)t.writeByte(e.charCodeAt(n))},t.toByteArray=function(){return e},t.toString=function(){let t=``;t+=`[`;for(let n=0;n<e.length;n+=1)n>0&&(t+=`,`),t+=e[n];return t+=`]`,t},t},Wre=function(){let e=0,t=0,n=0,r=``,i={},a=function(e){r+=String.fromCharCode(o(e&63))},o=function(e){if(e<0)throw`n:`+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw`n:`+e};return i.writeByte=function(r){for(e=e<<8|r&255,t+=8,n+=1;t>=6;)a(e>>>t-6),t-=6},i.flush=function(){if(t>0&&(a(e<<6-t),e=0,t=0),n%3!=0){let e=3-n%3;for(let t=0;t<e;t+=1)r+=`=`}},i.toString=function(){return r},i},Gre=function(e){let t=e,n=0,r=0,i=0,a={};a.read=function(){for(;i<8;){if(n>=t.length){if(i==0)return-1;throw`unexpected end of file./`+i}let e=t.charAt(n);if(n+=1,e==`=`)return i=0,-1;e.match(/^\s$/)||(r=r<<6|o(e.charCodeAt(0)),i+=6)}let e=r>>>i-8&255;return i-=8,e};let o=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw`c:`+e};return a},Kre=function(e,t){let n=e,r=t,i=Array(e*t),a={};a.setPixel=function(e,t,r){i[t*n+e]=r},a.write=function(e){e.writeString(`GIF87a`),e.writeShort(n),e.writeShort(r),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeString(`,`),e.writeShort(0),e.writeShort(0),e.writeShort(n),e.writeShort(r),e.writeByte(0);let t=s(2);e.writeByte(2);let i=0;for(;t.length-i>255;)e.writeByte(255),e.writeBytes(t,i,255),i+=255;e.writeByte(t.length-i),e.writeBytes(t,i,t.length-i),e.writeByte(0),e.writeString(`;`)};let o=function(e){let t=e,n=0,r=0,i={};return i.write=function(e,i){if(e>>>i)throw`length over`;for(;n+i>=8;)t.writeByte(255&(e<<n|r)),i-=8-n,e>>>=8-n,r=0,n=0;r=e<<n|r,n+=i},i.flush=function(){n>0&&t.writeByte(r)},i},s=function(e){let t=1<<e,n=(1<<e)+1,r=e+1,a=c();for(let e=0;e<t;e+=1)a.add(String.fromCharCode(e));a.add(String.fromCharCode(t)),a.add(String.fromCharCode(n));let s=v9(),l=o(s);l.write(t,r);let u=0,d=String.fromCharCode(i[u]);for(u+=1;u<i.length;){let e=String.fromCharCode(i[u]);u+=1,a.contains(d+e)?d+=e:(l.write(a.indexOf(d),r),a.size()<4095&&(a.size()==1<<r&&(r+=1),a.add(d+e)),d=e)}return l.write(a.indexOf(d),r),l.write(n,r),l.flush(),s.toByteArray()},c=function(){let e={},t=0,n={};return n.add=function(r){if(n.contains(r))throw`dup key:`+r;e[r]=t,t+=1},n.size=function(){return t},n.indexOf=function(t){return e[t]},n.contains=function(t){return e[t]!==void 0},n};return a},qre=function(e,t,n){let r=Kre(e,t);for(let i=0;i<t;i+=1)for(let t=0;t<e;t+=1)r.setPixel(t,i,n(t,i));let i=v9();r.write(i);let a=Wre(),o=i.toByteArray();for(let e=0;e<o.length;e+=1)a.writeByte(o[e]);return a.flush(),`data:image/gif;base64,`+a};l9.stringToBytes;var Jre=1500;function y9(e){let t=(0,F.useRef)(null),[n,r]=(0,F.useState)(!1);return(0,F.useEffect)(()=>{if(!e)return;t.current?.scrollIntoView?.({block:`center`}),r(!0);let n=setTimeout(()=>r(!1),Jre);return()=>clearTimeout(n)},[e]),{ref:t,flash:n}}function b9(e,t){return e.query.trim()===``||e.matches.has(t)}var Yre=1400;function x9({title:e,rows:t,projectId:n,filter:r,highlightField:i,onOpenEvidence:a,evidence:o}){let s=t.filter(e=>b9(r,e.key));return s.length===0?null:(0,I.jsx)(C9,{title:e,children:s.map(e=>(0,I.jsx)(Xre,{row:e,projectId:n,highlight:i===e.key,...a&&e.provenanceChip?.evidence?{onOpenEvidence:()=>a(e.key)}:{},...o?{evidence:o(e)}:{}},e.key))})}function S9({groups:e,className:t}){return(0,I.jsx)(WN,{label:`Loading settings…`,className:t,children:e.map((e,t)=>(0,I.jsxs)(`div`,{className:`mt-9 first:mt-0`,children:[(0,I.jsx)(`div`,{className:`flex min-h-7 items-center border-b border-border-subtle pb-2`,children:(0,I.jsx)(GN,{className:`h-3 w-16`})}),e.map((e,t)=>(0,I.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_minmax(0,300px)] items-start gap-x-8 border-b border-border-subtle py-4 last:border-b-0`,"data-skeleton":`setting-row`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 pt-1`,children:[(0,I.jsx)(GN,{className:q(`h-3`,e)}),(0,I.jsx)(GN,{className:`h-2.5 w-4/5`})]}),(0,I.jsx)(GN,{className:`h-(--control-h) w-full rounded-md`})]},t))]},t))})}function C9({title:e,action:t,description:n,children:r}){return(0,I.jsxs)(`section`,{className:`mt-9 first:mt-0`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-7 items-center gap-3 border-b border-border-subtle pb-2`,children:[(0,I.jsx)(`h3`,{className:`m-0 min-w-0 flex-1 text-sm font-medium text-text`,children:e}),t&&(0,I.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:t})]}),n&&(0,I.jsx)(`div`,{className:`mt-2.5 text-xs text-pretty text-text-tertiary`,children:n}),(0,I.jsx)(`div`,{children:r})]})}function w9({label:e,htmlFor:t,description:n,descriptionId:r,aside:i,control:a,below:o,stacked:s=!1,flash:c=!1,rowRef:l}){return(0,I.jsxs)(`div`,{ref:l,className:q(`border-b border-border-subtle py-4 last:border-b-0`,`transition-[outline-color] duration-(--dur-3) ease-app`,s?`flex flex-col gap-2.5`:`grid grid-cols-[minmax(0,1fr)_minmax(0,300px)] items-start gap-x-8 gap-y-1.5`,c&&`rounded-md outline-2 outline-offset-4 outline-accent`),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 pt-1`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-5 items-center gap-2`,children:[(0,I.jsx)(`label`,{htmlFor:t,className:`text-sm font-medium text-text`,children:e}),i]}),n&&(0,I.jsx)(`p`,{id:r,className:`m-0 text-xs text-pretty text-text-tertiary`,children:n})]}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[a,o]})]})}function Xre({row:e,projectId:t,highlight:n,onOpenEvidence:r,evidence:i}){let a=R.useUtils(),o=e.ghostValue?``:e.value,[s,c]=(0,F.useState)(o),[l,u]=(0,F.useState)(null),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(!1),{ref:h,flash:g}=y9(n),_=(0,F.useRef)(void 0);(0,F.useEffect)(()=>c(o),[o]),(0,F.useEffect)(()=>()=>clearTimeout(_.current),[]);let v=R.settings.update.useMutation({onSuccess:()=>{u(null),f(!0),clearTimeout(_.current),_.current=setTimeout(()=>f(!1),Yre),e.restartRequired&&m(!0),a.settings.get.invalidate(),a.project.prep.invalidate()},onError:e=>{c(o),u(e.message)}}),y=e=>{c(e),l&&u(null)},b=n=>{u(null),v.mutate({...t?{projectId:t}:{},key:e.key,value:n})},x=t=>{if(t.trim()===o.trim())return;let n=ih(e.control,t);if(`error`in n){u(n.error);return}b(n.value)},S=()=>b(null),C=`set-${t?`project`:`global`}-${e.key}`,w=`${C}-help`,T=`${C}-error`,E=`${C}-about`,D=q(E,e.shortHelp?w:null,l?T:null)||void 0,O=e.sourceChip||e.clearable||e.provenanceChip;return(0,I.jsx)(w9,{rowRef:h,flash:g,stacked:e.control===`textarea`,label:e.label,htmlFor:C,description:e.tooltip||void 0,descriptionId:E,aside:(e.tag||d)&&(0,I.jsxs)(I.Fragment,{children:[e.tag&&(0,I.jsx)(VA,{children:e.tag}),d&&(0,I.jsx)(T9,{})]}),control:(0,I.jsx)(Zre,{id:C,describedBy:D,row:e,draft:s,disabled:v.isPending,onDraft:y,onCommit:x,onToggle:e=>{y(String(e)),b(e)},onRevert:()=>c(o)}),below:(0,I.jsxs)(I.Fragment,{children:[e.shortHelp&&(0,I.jsx)(`div`,{id:w,className:`text-xs text-text-tertiary`,children:e.shortHelp}),O&&(0,I.jsxs)(`div`,{className:`flex min-h-5 flex-wrap items-center gap-x-3 gap-y-1`,children:[e.sourceChip&&(0,I.jsx)($re,{kind:e.sourceChip,envVar:zm[e.key]}),e.sourceChip===`project`&&(0,I.jsx)(J,{variant:`ghost`,size:`sm`,onClick:S,className:`-ml-1.5`,children:`Use global`}),e.clearable&&(0,I.jsx)(J,{variant:`ghost`,size:`sm`,onClick:S,className:`-ml-1.5`,children:`Clear`}),e.provenanceChip&&(0,I.jsxs)(`div`,{className:`relative flex min-w-0`,children:[(0,I.jsx)(tie,{chip:e.provenanceChip,onOpenEvidence:r}),i]}),e.stale&&(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-warning-text`,title:`Measured a long time ago — “Re-prepare the project”, at the foot of the features rail, refreshes it`,children:[(0,I.jsx)(RA,{tone:`warning`}),`Stale`]})]}),p&&(0,I.jsx)(`div`,{className:`text-xs text-warning-text`,children:`Restart the server to apply`}),l&&(0,I.jsx)(`div`,{id:T,role:`alert`,className:`text-xs text-danger-text`,children:l})]})})}function T9(){return(0,I.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-text-tertiary animate-fade-in`,children:[(0,I.jsx)(zy,{size:12,className:`text-success`}),`Saved`]})}function Zre({id:e,describedBy:t,row:n,draft:r,disabled:i,onDraft:a,onCommit:o,onToggle:s,onRevert:c}){let l={id:e,"aria-describedby":t,disabled:i},u=e=>{e.key===`Escape`&&(c(),e.currentTarget.blur())},d=e=>{e.key===`Enter`&&e.currentTarget.blur(),u(e)},f=n.unit?(0,I.jsx)(`span`,{className:`min-w-0 text-xs text-pretty text-text-tertiary`,children:n.unit}):void 0;if(n.readOnly)return(0,I.jsx)(EN,{...l,disabled:!0,readOnly:!0,mono:n.control!==`select`,icon:(0,I.jsx)(tb,{}),className:`w-full`,inputClassName:n.control===`number`?`tabular-nums`:void 0,value:n.optionLabels[n.value]??n.value});if(n.control===`switch`)return(0,I.jsx)(UN,{id:e,checked:r===`true`,disabled:i,onChange:s,className:`flex min-h-(--control-h) items-center`});if(n.control===`select`)return(0,I.jsxs)(CY,{value:r,onValueChange:e=>{a(e),o(e)},children:[(0,I.jsx)(OY,{...l,className:q(TY,`w-full`),children:(0,I.jsx)(kY,{})}),(0,I.jsxs)(AY,{children:[n.ghostValue&&(0,I.jsxs)(PY,{value:``,children:[`Use global (`,n.optionLabels[n.ghostValue]??n.ghostValue,`)`]}),n.modelGroups.length>0?n.modelGroups.map(e=>(0,I.jsxs)(jY,{children:[(0,I.jsx)(MY,{children:e.label}),e.entries.map(e=>(0,I.jsx)(PY,{value:e.id,title:e.note,children:e.note?`${e.id} — ${e.note}`:e.id},e.id))]},e.runtime)):n.options.map(e=>(0,I.jsx)(PY,{value:e,children:n.optionLabels[e]??e},e))]})]});if(n.control===`textarea`)return(0,I.jsx)(ON,{...l,mono:!0,rows:3,placeholder:n.ghostValue??n.placeholder,value:r,onChange:e=>a(e.target.value),onBlur:e=>o(e.target.value),onKeyDown:u});let p=(0,I.jsx)(EN,{...l,type:n.control===`number`?`number`:`text`,mono:!0,className:n.control===`number`?`w-24 shrink-0`:`w-full`,inputClassName:n.control===`number`?`tabular-nums`:void 0,placeholder:n.ghostValue??n.placeholder,value:r,onChange:e=>a(e.target.value),onBlur:e=>o(e.target.value),onKeyDown:d});return f?(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[p,f]}):p}var Qre={global:{text:`Global`,tone:`neutral`,word:`text-text-tertiary`},project:{text:`This project`,tone:`accent`,word:`text-text-secondary`},env:{text:`Env`,tone:`neutral`,word:`text-text-tertiary`}};function $re({kind:e,envVar:t}){let n=Qre[e];return(0,I.jsxs)(`span`,{className:q(`inline-flex shrink-0 items-center gap-1.5 text-xs`,n.word),...e===`env`&&t?{title:`Set by ${t}`}:{},children:[e===`env`?(0,I.jsx)(tb,{size:12,className:`text-icon`}):(0,I.jsx)(RA,{tone:n.tone}),(0,I.jsx)(`span`,{children:n.text})]})}var eie={ok:`success`,muted:`neutral`,warn:`warning`};function tie({chip:e,onOpenEvidence:t}){let n=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(RA,{tone:eie[e.tone]}),(0,I.jsx)(`span`,{className:`truncate`,children:e.text})]}),r=e.tone===`warn`?`text-warning-text`:`text-text-secondary`;return t?(0,I.jsx)(`button`,{type:`button`,onClick:t,className:q(`-mx-1.5 inline-flex h-6 min-w-0 cursor-pointer items-center gap-1.5 rounded-md border-0 bg-transparent px-1.5 text-xs`,`underline decoration-border-strong decoration-dotted underline-offset-4`,`transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover hover:text-text`,r),children:n}):(0,I.jsx)(`span`,{className:q(`inline-flex min-w-0 items-center gap-1.5 text-xs`,r),children:n})}var nie={id:`phone-link`,page:`general`,terms:[`On your phone`,`Phone`,`Mobile`,`Tailscale`,`QR code`,`Private link`]};function rie({projectId:e,filter:t}){let n=R.useUtils(),r=R.phoneLink.status.useQuery(void 0,{refetchOnWindowFocus:!1}),i={onSuccess:e=>n.phoneLink.status.setData(void 0,e)},a=R.phoneLink.turnOn.useMutation(i),o=R.phoneLink.turnOff.useMutation(i);if(!b9(t,`phone-link`))return null;let s=r.data,c=a.isPending||o.isPending;return(0,I.jsxs)(C9,{title:`On your phone`,children:[r.isLoading&&(0,I.jsx)(YN,{children:`Checking Tailscale…`}),r.error&&(0,I.jsxs)(YN,{children:[`Could not check Tailscale: `,r.error.message]}),s?.tailscale===`missing`&&(0,I.jsx)(w9,{label:`Tailscale is not installed`,description:`The phone reaches runcastle through your own Tailscale network.`,control:(0,I.jsx)(`a`,{href:`https://tailscale.com/download`,target:`_blank`,rel:`noreferrer noopener`,className:`cursor-pointer text-accent-text no-underline decoration-accent-text/50 underline-offset-2 transition-colors duration-(--dur-1) ease-app hover:underline hover:decoration-accent-text`,children:`Get Tailscale`})}),s?.tailscale===`stopped`&&(0,I.jsx)(w9,{label:`Tailscale is not running`,description:`Start Tailscale on this computer and sign in, then come back here.`,control:null}),s?.tailscale===`running`&&!s.on&&(0,I.jsx)(w9,{label:`Private link`,description:`Only your own Tailscale devices can reach it.`,control:(0,I.jsx)(J,{variant:`primary`,loading:a.isPending,disabled:c,onClick:()=>a.mutate({projectId:e}),className:`self-start`,children:`Turn on`})}),s?.tailscale===`running`&&s.on&&s.url&&(0,I.jsx)(iie,{url:s.url,busy:c,turningOff:o.isPending,onTurnOff:()=>o.mutate({projectId:e})}),s?.on&&(0,I.jsx)(YN,{children:`Turn on notifications from your phone: it’s the last row of the feature list.`}),s?.error&&(0,I.jsx)(aie,{error:s.error,commands:s.commands})]})}function iie({url:e,busy:t,turningOff:n,onTurnOff:r}){let i=rx();return(0,I.jsx)(w9,{stacked:!0,label:`Private link`,description:`Install Tailscale on your phone, sign in, then scan this. Add it to your home screen from the browser's menu.`,control:(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start gap-6`,children:[(0,I.jsx)(oie,{text:e}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-3`,children:[(0,I.jsxs)(`span`,{className:`inline-flex max-w-full min-w-0 items-center gap-1 rounded-md bg-surface-inset py-0.5 pr-0.5 pl-2`,children:[(0,I.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-text-secondary`,title:e,children:e}),(0,I.jsx)(Y,{label:`Copy`,size:`sm`,icon:(0,I.jsx)(hb,{}),onClick:()=>HF(e,i)})]}),(0,I.jsx)(J,{loading:n,disabled:t,onClick:r,children:`Turn off`})]})]})})}function aie({error:e,commands:t}){let n=rx(),r=t.join(`
|
|
193
|
-
`);return(0,I.jsx)(w9,{stacked:!0,label:`Could not change the link`,description:(0,I.jsx)(`span`,{className:`whitespace-pre-wrap text-danger-text`,children:e}),control:(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(`span`,{className:`text-xs text-text-tertiary`,children:`Run these on this computer instead:`}),(0,I.jsxs)(`div`,{className:`flex items-start gap-1 rounded-md bg-surface-inset py-1.5 pr-1 pl-3`,children:[(0,I.jsx)(`pre`,{className:`m-0 min-w-0 flex-1 overflow-x-auto font-mono text-xs text-text-secondary`,children:r}),(0,I.jsx)(Y,{label:`Copy`,size:`sm`,icon:(0,I.jsx)(hb,{}),onClick:()=>HF(r,n)})]})]})})}var E9=4;function oie({text:e}){let t=l9(0,`M`);t.addData(e),t.make();let n=t.getModuleCount(),r=``;for(let e=0;e<n;e++)for(let i=0;i<n;i++)t.isDark(e,i)&&(r+=`M${i+E9},${e+E9}h1v1h-1z`);let i=n+E9*2;return(0,I.jsxs)(`svg`,{role:`img`,"aria-label":`QR code for ${e}`,viewBox:`0 0 ${i} ${i}`,width:180,height:180,shapeRendering:`crispEdges`,className:`shrink-0 rounded-md`,children:[(0,I.jsx)(`rect`,{width:i,height:i,fill:`#fff`}),(0,I.jsx)(`path`,{d:r,fill:`#000`})]})}var sie=`theme`,cie=[{value:`dark`,label:`Dark`,icon:(0,I.jsx)(_b,{size:14})},{value:`light`,label:`Light`,icon:(0,I.jsx)(gb,{size:14})},{value:`system`,label:`System`,icon:(0,I.jsx)(vb,{size:14})}];function lie({globals:e,projectId:t,filter:n,highlightField:r}){let i=(0,I.jsxs)(I.Fragment,{children:[b9(n,`theme`)&&(0,I.jsx)(C9,{title:`Appearance`,children:(0,I.jsx)(die,{})}),(0,I.jsx)(rie,{projectId:t,filter:n})]});if(e.isLoading)return(0,I.jsxs)(I.Fragment,{children:[i,(0,I.jsx)(S9,{groups:uie,className:`mt-9`})]});if(e.error)return(0,I.jsxs)(I.Fragment,{children:[i,(0,I.jsxs)(YN,{children:[`Could not load settings: `,e.error.message]})]});if(!e.data)return(0,I.jsx)(I.Fragment,{children:i});let a=mh(e.data,`general`),o=e=>a.filter(t=>t.group===e);return(0,I.jsxs)(I.Fragment,{children:[i,(0,I.jsx)(x9,{title:`Server`,rows:o(`server`),filter:n,highlightField:r}),(0,I.jsx)(x9,{title:`Sessions`,rows:o(`sessions`),filter:n,highlightField:r})]})}var uie=[[`w-20`,`w-28`],[`w-24`,`w-32`,`w-20`]];function die(){let{preference:e,setPreference:t}=uF();return(0,I.jsx)(w9,{label:`Theme`,description:`Dark is the default; System follows your operating system as it changes.`,control:(0,I.jsx)(BN,{id:`settings-theme`,label:`Theme`,items:cie.map(e=>({value:e.value,label:e.label,icon:e.icon})),value:e,onChange:t,className:`w-full`})})}var D9=`grid grid-cols-[minmax(0,1.5fr)_minmax(0,1.3fr)_minmax(0,0.8fr)_88px_24px] items-center gap-3`,O9=`min-h-8 border-b border-border-subtle px-2 text-xs font-medium text-text-tertiary`,fie=e=>`models:${e}`,k9=`models:new`,A9=`opacity-0 transition-opacity duration-(--dur-1) group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100`;function pie({rows:e,stepLabels:t,customModels:n,filter:r,writes:i}){let[a,o]=(0,F.useState)(!1),s=r.query.trim()!==``,c=(a||s?e:xh(e)).filter(e=>b9(r,e.id)),l=a||s?0:Sh(e);return(0,I.jsxs)(`div`,{className:`mt-3`,children:[(0,I.jsxs)(`div`,{className:q(D9,O9),children:[(0,I.jsx)(`span`,{children:`Model`}),(0,I.jsx)(`span`,{children:`Use-case note`}),(0,I.jsx)(`span`,{children:`Used for`}),(0,I.jsx)(`span`,{children:`Default`}),(0,I.jsx)(`span`,{})]}),c.map((e,r)=>(0,I.jsx)(mie,{index:r,row:e,stepLabels:t,customModels:n,writes:i},e.id)),l>0&&(0,I.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 border-b border-border-subtle px-2 text-xs text-text-tertiary`,children:[l,` more `,l===1?`model`:`models`,` nobody uses`,(0,I.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>o(!0),children:`Show all`})]}),!s&&(0,I.jsx)(_ie,{customModels:n,writes:i})]})}function mie({row:e,index:t,stepLabels:n,customModels:r,writes:i}){let a=fie(e.id),o=e.usedFor.map(e=>n.get(e)??e).join(`, `),s=t=>{let n=t.trim(),o=n===``&&!e.custom?r.filter(t=>t.id!==e.id):Sd(r,[{id:e.id,runtime:e.runtime,...n?{note:n}:{}}]);i.save(a,`models`,o)},c=()=>{if(e.isDefault){i.refuse(a,`${e.id} is the default model — make another model the default first.`);return}if(e.usedFor.length>0){i.refuse(a,`${e.id} runs ${o} — reset those steps first.`);return}i.save(a,`models`,r.filter(t=>t.id!==e.id))},l=t<8;return(0,I.jsxs)(`div`,{className:q(`group border-b border-border-subtle transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`,l&&`animate-rise-in`),style:l?{animationDelay:`${t*20}ms`}:void 0,children:[(0,I.jsxs)(`div`,{className:q(D9,`min-h-10 px-2 text-sm`),children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(M9,{runtime:e.runtime}),(0,I.jsx)(`span`,{className:`truncate text-text`,title:e.displayName?`${e.displayName} — ${e.id}`:e.id,children:e.id}),e.isNew&&(0,I.jsx)(BA,{tone:`accent`,className:`shrink-0`,children:`New`})]}),(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(gie,{row:e,onCommit:s}),i.saved===a&&(0,I.jsx)(T9,{})]}),(0,I.jsxs)(`span`,{className:`truncate text-xs text-text-tertiary`,title:o||void 0,children:[e.isDefault&&(0,I.jsx)(`span`,{className:`text-text-secondary`,children:`Default`}),e.isDefault&&o!==``&&`, `,o===``?e.isDefault?``:`—`:o]}),e.isDefault?(0,I.jsx)(`span`,{"data-default-mark":``,className:`inline-flex`,children:(0,I.jsx)(BA,{strong:!0,icon:(0,I.jsx)(zy,{}),children:`Default`})}):(0,I.jsx)(J,{variant:`ghost`,size:`sm`,"aria-label":`Make ${e.id} the default`,onClick:()=>i.save(a,`model`,e.id),className:q(`-ml-2 justify-self-start`,A9),children:`Make default`}),e.custom?(0,I.jsx)(Y,{label:`Remove ${e.id}`,size:`sm`,icon:(0,I.jsx)(Vy,{}),onClick:c,variant:`danger-ghost`,className:A9}):(0,I.jsx)(`span`,{})]}),(0,I.jsx)(hie,{row:e}),(0,I.jsx)(j9,{writes:i,cell:a})]})}function hie({row:e}){return!e.noLongerOffered&&!e.retirement?null:(0,I.jsxs)(`p`,{className:`m-0 flex flex-wrap gap-x-4 pr-2 pb-2.5 pl-8 text-xs text-warning-text`,children:[e.noLongerOffered&&(0,I.jsxs)(`span`,{children:[`no longer offered by `,vh[e.noLongerOffered]]}),e.retirement&&(0,I.jsxs)(`span`,{children:[`retires `,e.retirement.at,` → `,e.retirement.replacement]})]})}function gie({row:e,onCommit:t}){let[n,r]=(0,F.useState)(e.note);return(0,F.useEffect)(()=>r(e.note),[e.note]),(0,I.jsx)(`input`,{type:`text`,"aria-label":`Note for ${e.id}`,placeholder:e.isDefault?`e.g. UI/UX work, design-heavy tickets`:`Add a note`,className:q(`-ml-2 h-7 min-w-0 flex-1 rounded-md border border-transparent bg-transparent px-2 text-sm text-text`,`transition-colors duration-(--dur-1) ease-app placeholder:text-text-disabled`,`hover:border-border focus:border-accent focus:bg-surface-inset`),value:n,onChange:e=>r(e.target.value),onBlur:()=>n.trim()!==e.note.trim()&&t(n),onKeyDown:e=>e.key===`Enter`&&e.currentTarget.blur()})}function _ie({customModels:e,writes:t}){let[n,r]=(0,F.useState)(``),[i,a]=(0,F.useState)(``),[o,s]=(0,F.useState)(``),c=()=>{let c=Gm(n,i,o);if(`error`in c){t.refuse(k9,c.error);return}t.save(k9,`models`,Sd(e,[c.entry])),r(``),a(``),s(``)},l=e=>{e.key===`Enter`&&c()};return(0,I.jsxs)(`div`,{className:`pt-3`,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_132px_minmax(0,1.2fr)_auto] items-center gap-2`,children:[(0,I.jsx)(EN,{mono:!0,"aria-label":`New model id`,placeholder:`Model id, e.g. claude-opus-5[1m]`,value:n,onChange:e=>r(e.target.value),onKeyDown:l}),(0,I.jsxs)(CY,{value:i,onValueChange:a,children:[(0,I.jsx)(OY,{"aria-label":`Runtime (required)`,className:q(TY,`w-full`,i===``&&`text-text-tertiary`),children:(0,I.jsx)(kY,{})}),(0,I.jsxs)(AY,{children:[(0,I.jsx)(PY,{value:``,children:`Runs on…`}),md.map(e=>(0,I.jsx)(PY,{value:e,children:Bm[e]},e))]})]}),(0,I.jsx)(EN,{"aria-label":`New model note`,placeholder:`Use-case note (optional)`,value:o,onChange:e=>s(e.target.value),onKeyDown:l}),(0,I.jsx)(J,{icon:(0,I.jsx)(Ry,{}),onClick:c,children:`Add model`})]}),(0,I.jsx)(j9,{writes:t,cell:k9,className:`pt-1.5`})]})}function j9({writes:e,cell:t,className:n=`pr-2 pb-2.5 pl-8`}){return e.error?.cell===t?(0,I.jsx)(`p`,{role:`alert`,className:q(`m-0 text-xs text-danger-text`,n),children:e.error.message}):null}function M9({runtime:e}){let t=e===`codex`?lb:cb;return(0,I.jsx)(`span`,{role:`img`,"aria-label":Bm[e],title:Bm[e],className:`inline-flex size-4 shrink-0 items-center justify-center text-icon`,children:(0,I.jsx)(t,{size:14})})}function N9({groups:e}){return(0,I.jsx)(I.Fragment,{children:e.map(e=>(0,I.jsxs)(jY,{children:[(0,I.jsx)(MY,{children:e.label}),e.entries.map(e=>(0,I.jsx)(PY,{value:e.id,title:e.note,children:e.note?`${e.id} — ${e.note}`:e.id},e.id))]},e.runtime))})}var vie=[{group:`sessions`,title:`Sessions`,caption:`Interactive — you are in the terminal`},{group:`unattended`,title:`Unattended`,caption:`Workers and scripted runs`}],P9=`grid grid-cols-[minmax(0,1fr)_260px_24px] items-center gap-3`;function yie({rows:e,groups:t,defaultModel:n,projectModel:r,filter:i,writes:a}){return(0,I.jsxs)(I.Fragment,{children:[r&&(0,I.jsxs)(`p`,{className:`m-0 mt-3 flex items-center gap-2 text-xs text-text-secondary`,children:[(0,I.jsx)(RA,{tone:`warning`}),(0,I.jsxs)(`span`,{children:[`This project runs everything on `,(0,I.jsx)(`span`,{className:`font-mono`,children:r}),` — these apply to other projects.`]})]}),vie.map(({group:r,title:o,caption:s})=>{let c=e.filter(e=>e.group===r&&b9(i,Zm(e.step)));return c.length===0?null:(0,I.jsxs)(F.Fragment,{children:[(0,I.jsxs)(`div`,{className:q(P9,O9,`mt-4`),children:[(0,I.jsxs)(`span`,{children:[o,(0,I.jsx)(`span`,{className:`ml-2 font-normal text-text-disabled`,children:s})]}),(0,I.jsx)(`span`,{children:`Model`}),(0,I.jsx)(`span`,{})]}),c.map(e=>(0,I.jsx)(bie,{row:e,groups:t,defaultModel:n,writes:a},e.step))]},r)})]})}function bie({row:e,groups:t,defaultModel:n,writes:r}){let i=Zm(e.step),a=e.value!==null;return(0,I.jsxs)(`div`,{className:`group border-b border-border-subtle transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover`,children:[(0,I.jsxs)(`div`,{className:q(P9,`min-h-12 px-2 py-1.5`),children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2 text-sm text-text`,children:[e.label,r.saved===i&&(0,I.jsx)(T9,{})]}),(0,I.jsx)(`span`,{className:`truncate text-xs text-text-tertiary`,title:e.description,children:e.description})]}),(0,I.jsxs)(CY,{value:e.value??``,onValueChange:e=>r.save(i,i,e===``?null:e),children:[(0,I.jsx)(OY,{"aria-label":`Model for ${e.label}`,className:q(TY,`w-full`,!a&&`text-text-tertiary`),children:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 [&>span:last-child]:truncate`,children:[(0,I.jsx)(M9,{runtime:e.effectiveRuntime}),(0,I.jsx)(kY,{})]})}),(0,I.jsxs)(AY,{children:[(0,I.jsxs)(PY,{value:``,children:[`Default (`,n,`)`]}),(0,I.jsx)(N9,{groups:t})]})]}),a?(0,I.jsx)(Y,{label:`Reset ${e.label} to default`,size:`sm`,icon:(0,I.jsx)(Hy,{}),onClick:()=>r.save(i,i,null),className:A9}):(0,I.jsx)(`span`,{})]}),(0,I.jsx)(j9,{writes:r,cell:i,className:`px-2 pb-2.5`})]})}var xie=1400,F9=`model`;function Sie(){let e=R.useUtils(),[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(null),a=(0,F.useRef)([]),o=(0,F.useRef)(null),s=(0,F.useRef)(void 0);(0,F.useEffect)(()=>()=>clearTimeout(s.current),[]);let c=()=>{let e=a.current.shift();if(!e){o.current=null;return}o.current=e.cell,l.mutate({key:e.key,value:e.value})},l=R.settings.update.useMutation({onSuccess:()=>{n(o.current),clearTimeout(s.current),s.current=setTimeout(()=>n(null),xie),e.settings.get.invalidate(),c()},onError:e=>{let t=o.current;t&&i({cell:t,message:e.message}),a.current=[],o.current=null}}),u=e=>i(t=>t&&t.cell===e?null:t);return{saved:t,error:r,save:(e,t,n)=>{u(e),a.current.push({cell:e,key:t,value:n}),o.current===null&&c()},refuse:(e,t)=>i({cell:e,message:t})}}var Cie=[[`w-28`],[`w-32`,`w-24`,`w-28`],[`w-20`,`w-28`,`w-24`]];function wie({globals:e,scoped:t,filter:n,highlightField:r}){let i=Sie();if(e.isLoading)return(0,I.jsx)(S9,{groups:Cie});if(e.error)return(0,I.jsxs)(YN,{children:[`Could not load settings: `,e.error.message]});if(!e.data)return null;let a=e.data,o=bh(a),s=wh(a),c=Wm(Um(a)),l=gh(a),u=new Map(s.map(e=>[e.step,e.label]));return(0,I.jsxs)(I.Fragment,{children:[b9(n,`model`)&&(0,I.jsx)(`div`,{className:`-mt-3.5`,children:(0,I.jsx)(Die,{value:l,groups:c,writes:i,highlight:r===`model`})}),o.some(e=>b9(n,e.id))&&(0,I.jsxs)(C9,{title:`Roster`,action:(0,I.jsx)(Eie,{}),description:(0,I.jsxs)(I.Fragment,{children:[`A model with a `,(0,I.jsx)(`span`,{className:`text-text-secondary`,children:`use-case note`}),` is offered to the tickets agent, which may pick it per ticket; models without a note are never picked automatically.`]}),children:[(0,I.jsx)(Tie,{view:a}),(0,I.jsx)(pie,{rows:o,stepLabels:u,customModels:Hm(a),filter:n,writes:i})]}),s.some(e=>b9(n,Zm(e.step)))&&(0,I.jsx)(C9,{title:`Per step`,description:`Every step runs the default unless it names a model of its own.`,children:(0,I.jsx)(yie,{rows:s,groups:c,defaultModel:l,projectModel:Th(t.data),filter:n,writes:i})})]})}function Tie({view:e}){return(0,I.jsx)(`ul`,{"aria-label":`Model discovery`,className:`m-0 mt-1.5 flex list-none flex-wrap gap-x-5 gap-y-1 p-0 text-xs`,children:Ch(e).map(e=>(0,I.jsxs)(`li`,{className:q(`inline-flex items-center gap-1.5`,e.failed?`text-warning-text`:`text-text-tertiary`),children:[(0,I.jsx)(M9,{runtime:e.runtime}),e.text]},e.runtime))})}function Eie(){let e=R.useUtils(),t=R.settings.refreshModels.useMutation({onSuccess:()=>void e.settings.get.invalidate()});return(0,I.jsxs)(I.Fragment,{children:[t.error&&(0,I.jsxs)(`span`,{role:`alert`,className:`text-xs text-danger-text`,children:[`Refresh failed: `,t.error.message]}),(0,I.jsx)(J,{variant:`ghost`,size:`sm`,icon:(0,I.jsx)(Db,{}),loading:t.isPending,onClick:()=>t.mutate(),children:t.isPending?`Refreshing…`:`Refresh`})]})}function Die({value:e,groups:t,writes:n,highlight:r}){let{ref:i,flash:a}=y9(r);return(0,I.jsx)(w9,{rowRef:i,flash:a,label:`Default model`,htmlFor:`settings-default-model`,description:`Runs every step that has no model of its own below — and every project that has not set one.`,aside:n.saved===F9&&(0,I.jsx)(T9,{}),control:(0,I.jsxs)(CY,{value:e,onValueChange:e=>n.save(F9,`model`,e),children:[(0,I.jsx)(OY,{id:`settings-default-model`,className:q(TY,`w-full`),children:(0,I.jsx)(kY,{})}),(0,I.jsx)(AY,{children:(0,I.jsx)(N9,{groups:t})})]}),below:(0,I.jsx)(j9,{writes:n,cell:F9,className:``})})}function I9({projectId:e,filter:t,highlightField:n,onDismiss:r}){let i=R.useUtils(),a=R.setup.doctor.useQuery(e?{projectId:e}:void 0,{refetchOnWindowFocus:!1}),o=a.data,s=e=>o?.results.find(t=>t.id===e),c=s(`container-runtime`),l=s(`sandcastle-image`),u=Ire(o?.results??[]),[d,f]=(0,F.useState)(0),p=()=>{f(e=>e+1),i.setup.doctor.cancel().then(()=>a.refetch())},m=jie(a.isLoading,d),h=e=>!t||b9(t,e),g=m?kie:`checking prerequisites…`,_=a.error?.message??(m?Aie:null),v=Rre([...c?[{field:`container-runtime`,ok:c.status===`ok`}]:[],...l?[{field:`sandcastle-image`,ok:L9(l)}]:[],...u.map(e=>({field:o9(e.runtime),ok:e.probe.status===`ok`}))].map(({field:e,ok:t})=>({ok:t,reason:R9[e].reason??R9[e].label}))),y=e=>({field:e,label:R9[e].label,visible:h(e),highlight:n===e}),b=o!==void 0&&v.count===null;return(0,I.jsxs)(`section`,{"aria-label":`Unattended worker prerequisites`,className:`flex flex-col`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3 pb-3`,children:[(0,I.jsx)(`span`,{"aria-hidden":!0,className:q(`mt-0.5 inline-flex size-7 shrink-0 items-center justify-center [&>svg]:size-4`,b?`text-success`:`text-icon`),children:b?(0,I.jsx)(zy,{}):(0,I.jsx)(eb,{})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`flex min-h-7 items-center gap-2 text-sm font-medium text-text`,children:a.isLoading?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(UE,{}),(0,I.jsx)(`span`,{className:`font-normal text-text-secondary`,children:g})]}):a.error?`Could not run the checks`:(0,I.jsxs)(`span`,{className:`min-w-0`,children:[v.count&&(0,I.jsxs)(`span`,{className:`tabular-nums`,children:[v.count,` `]}),v.text]})}),!r&&(0,I.jsx)(`p`,{className:`m-0 text-xs text-pretty text-text-tertiary`,children:`Workers run a round’s tickets in containers while you are away, so they need what an interactive session never does. Fix any of these now, or leave them for later.`})]}),r&&(0,I.jsx)(J,{variant:`ghost`,className:`shrink-0`,onClick:r,children:`Set up later`})]}),_&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5 py-2 pl-10`,children:[(0,I.jsx)(RA,{tone:`warning`}),(0,I.jsx)(`span`,{className:`min-w-0 grow text-xs text-text-secondary`,children:_}),(0,I.jsx)(J,{variant:`ghost`,size:`sm`,icon:(0,I.jsx)(Db,{}),onClick:p,children:`Retry`})]}),o&&(0,I.jsxs)(B9,{children:[(0,I.jsx)(Mie,{...y(`container-runtime`),probe:c,onRecheck:p}),(0,I.jsx)(Nie,{...y(`sandcastle-image`),probe:l,runtimeOk:c?.status===`ok`,projectId:e,onDone:p}),u.map(e=>e.kind===`token`?(0,I.jsx)(zie,{...y(o9(e.runtime)),probe:e.probe,onDone:p},e.runtime):(0,I.jsx)(Bie,{...y(o9(e.runtime)),row:e,onDone:p},e.runtime)),e&&(0,I.jsx)(Lie,{...y(`burn-cache`),projectId:e})]})]})}function L9(e){return e.status===`ok`||e.severity===`info`}var Oie=1e4,kie=`still checking — this is taking longer than usual`,Aie=`The container runtime has not answered yet. A runtime that is starting up — or wedged — can leave the checks outstanding for minutes.`;function jie(e,t){let[n,r]=(0,F.useState)(!1);return(0,F.useEffect)(()=>{if(r(!1),!e)return;let t=setTimeout(()=>r(!0),Oie);return()=>clearTimeout(t)},[e,t]),n}var R9=Object.fromEntries(s9.map(e=>[e.field,e]));function z9({field:e,label:t,visible:n=!0,highlight:r=!1,detail:i,ok:a,status:o,children:s,below:c}){let{ref:l,flash:u}=y9(r);return n?(0,I.jsxs)(`li`,{ref:l,...e?{"data-field":e}:{},className:q(`grid grid-cols-[28px_minmax(0,1fr)_auto] items-start gap-x-3 gap-y-2.5 py-3 [counter-increment:checklist]`,`border-t border-border-subtle first:border-t-0`,u&&`rounded-md outline-2 outline-offset-4 outline-accent`),children:[(0,I.jsx)(`span`,{"aria-hidden":!0,className:`flex h-5 items-center justify-center text-xs text-text-tertiary tabular-nums before:content-[counter(checklist)]`}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-5 flex-wrap items-center gap-x-3 gap-y-0.5`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-text`,children:t}),a?(0,I.jsx)(BA,{tone:`success`,icon:(0,I.jsx)(zy,{}),children:o??`Ready`}):(0,I.jsx)(BA,{tone:`warning`,children:o??`Needed`})]}),(0,I.jsx)(`div`,{className:`mt-0.5 font-mono text-xs break-words text-text-tertiary`,title:i,children:i})]}),(0,I.jsx)(`div`,{className:`flex max-w-96 flex-wrap items-center justify-end gap-2`,children:s}),c]}):null}function B9({children:e}){return(0,I.jsx)(`ol`,{className:`m-0 list-none border-t border-border-subtle p-0 [counter-reset:checklist]`,children:e})}function V9({sessionId:e,label:t,onDone:n,onEnded:r}){return(0,I.jsxs)(`div`,{className:`col-span-full flex flex-col gap-2`,children:[(0,I.jsx)(`div`,{className:`h-70 overflow-hidden rounded-md border border-border bg-surface-inset animate-rise-in`,children:(0,I.jsx)(oq,{label:t,children:(0,I.jsx)(c6,{sessionId:e,onEnded:r})})}),n&&(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsx)(J,{variant:`ghost`,size:`sm`,icon:(0,I.jsx)(Db,{}),onClick:n,children:`Done — re-check`})})]})}function Mie({probe:e,onRecheck:t,...n}){let r=R.setup.runtimeGuide.useQuery(void 0,{enabled:e?.status===`missing`,refetchOnWindowFocus:!1}),i=rx();if(!e)return null;let a=e.status===`missing`?r.data:void 0,o=a?.command??e.fix??``,s=e.status===`ok`;return(0,I.jsxs)(z9,{...n,detail:e.detail,ok:s,children:[!s&&o&&(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(H9,{command:o,onCopy:()=>{navigator.clipboard?.writeText(o),i.push(`copied`,`info`)}})}),!s&&a?.note&&(0,I.jsx)(`span`,{className:`basis-full text-right text-xs text-text-tertiary`,children:a.note}),!s&&(0,I.jsx)(J,{variant:`ghost`,size:`sm`,icon:(0,I.jsx)(Db,{}),onClick:t,children:`Re-check`})]})}function Nie({probe:e,runtimeOk:t,projectId:n,onDone:r,...i}){let[a,o]=(0,F.useState)(null),s=rx(),c=R.setup.imageBuildTarget.useQuery(n?{projectId:n}:void 0),l=R.setup.startTerminal.useMutation({onSuccess:({sessionId:e,notices:t})=>{o(e);for(let e of t)s.push(e)},onError:e=>s.push(e.message)});return e?(0,I.jsx)(z9,{...i,detail:e.detail,ok:L9(e),below:a&&(0,I.jsx)(V9,{sessionId:a,label:`build-image`,onEnded:r,onDone:()=>{o(null),r()}}),children:!a&&(0,I.jsx)(Fie,{probe:e,target:Pie(c),runtimeOk:t,pending:l.isPending,onStart:()=>l.mutate({kind:`build-image`,...n?{projectId:n}:{}})})}):null}function Pie(e){let{data:t}=e;return t?t.kind===`refused`?{kind:`refused`,reason:t.reason}:{kind:`ready`,dockerfile:t.dockerfile,tag:t.tag}:e.error?{kind:`error`,message:e.error.message}:{kind:`loading`}}function Fie({probe:e,target:t,runtimeOk:n,pending:r,onStart:i}){if(e.status===`custom`)return(0,I.jsx)(`span`,{className:`basis-full text-right text-xs text-text-tertiary`,children:e.fix});if(t.kind===`refused`)return(0,I.jsx)(`span`,{className:`basis-full text-right text-xs text-text-tertiary`,children:t.reason});let a=e.status===`missing`||e.status===`not-built-yet`?`Build`:`Rebuild`,o=r?`Starting…`:t.kind===`ready`?`${a} image · ${t.tag}`:t.kind===`loading`?`${a} image · resolving…`:`${a} image`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(J,{variant:`secondary`,size:`sm`,icon:(0,I.jsx)($y,{}),"aria-label":`${a} image`,disabled:!n||r||t.kind!==`ready`,title:n?t.kind===`ready`?`Dockerfile: ${t.dockerfile}\nImage: ${t.tag}`:void 0:`Install a container runtime first`,onClick:i,children:o}),t.kind===`error`&&(0,I.jsx)(`span`,{className:`basis-full text-right text-xs text-warning-text`,children:t.message})]})}function Iie({status:e,pending:t,refusal:n,onClear:r,...i}){return e?.mode===`volume`?(0,I.jsxs)(z9,{field:R9[`burn-cache`].field,label:R9[`burn-cache`].label,...i,ok:!0,detail:`${e.volumeName} — ${e.sizeBytes===null?`empty`:mg(e.sizeBytes)}`,children:[(0,I.jsx)(J,{variant:`ghost`,size:`sm`,icon:(0,I.jsx)(Vy,{}),disabled:t,onClick:r,children:t?`Clearing…`:`Clear`}),n&&(0,I.jsx)(`span`,{className:`basis-full text-right text-xs text-warning-text`,children:n})]}):null}function Lie({projectId:e,...t}){let n=R.useUtils(),[r,i]=(0,F.useState)(null),a=R.system.burnCache.status.useQuery({projectId:e},{refetchOnWindowFocus:!1}),o=R.system.burnCache.clear.useMutation({onSuccess:()=>{i(null),n.system.burnCache.status.invalidate()},onError:e=>i(e.message)});return(0,I.jsx)(Iie,{...t,status:a.data,pending:o.isPending,refusal:r,onClear:()=>o.mutate({projectId:e})})}var Rie={"claude-code":{mint:{kind:`setup-token`,label:`Run claude setup-token`},placeholder:`paste sk-ant-oat01-…`}};function zie({probe:e,onDone:t,...n}){let[r,i]=(0,F.useState)(null),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(null),l=rx(),u=R.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>i(e),onError:e=>l.push(e.message)}),d=R.setup.afkToken.useMutation({onSuccess:e=>{c(e),e.valid&&t()},onError:e=>l.push(e.message)});if(!e?.runtime)return null;let f=e.runtime,p=Rie[f];return p?(0,I.jsxs)(z9,{...n,detail:e.detail,ok:e.status===`ok`,below:r&&(0,I.jsx)(V9,{sessionId:r,label:`setup-token`}),children:[p.mint&&!r&&(0,I.jsx)(J,{variant:`ghost`,size:`sm`,icon:(0,I.jsx)(Ky,{}),onClick:()=>p.mint&&u.mutate({kind:p.mint.kind}),disabled:u.isPending,children:u.isPending?`Starting…`:p.mint.label}),(0,I.jsx)(EN,{"aria-label":n.label,mono:!0,className:`w-52`,value:a,onChange:e=>o(e.target.value),placeholder:p.placeholder,spellCheck:!1,autoComplete:`off`}),(0,I.jsx)(J,{variant:`primary`,disabled:a.trim()===``||d.isPending,onClick:()=>d.mutate({token:a,runtime:f}),children:d.isPending?`Verifying…`:`Save & verify`}),s&&(0,I.jsxs)(`span`,{className:`basis-full text-right text-xs`,children:[(0,I.jsx)(BA,{tone:s.valid?`success`:`warning`,icon:s.valid?(0,I.jsx)(zy,{}):(0,I.jsx)(Sb,{}),children:s.detail}),s.fix&&(0,I.jsx)(`span`,{className:`mt-0.5 block text-text-tertiary`,children:s.fix})]})]}):null}function Bie({row:e,onDone:t,...n}){let[r,i]=(0,F.useState)(null),a=rx(),o=R.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>i(e),onError:e=>a.push(e.message)}),s=Ih[e.runtime],c=e.probe.status===`ok`;return(0,I.jsx)(z9,{...n,ok:c,status:c?`Signed in`:`Not signed in`,detail:e.probe.detail,below:r&&(0,I.jsx)(V9,{sessionId:r,label:s.kind,onDone:()=>{i(null),t()}}),children:!c&&!r&&(0,I.jsx)(J,{variant:`secondary`,size:`sm`,icon:(0,I.jsx)(Ob,{}),disabled:o.isPending,onClick:()=>o.mutate({kind:s.kind}),children:o.isPending?`Starting…`:`Sign in`})})}function H9({command:e,onCopy:t}){return(0,I.jsxs)(`span`,{className:`inline-flex max-w-full min-w-0 items-center gap-1 rounded-md bg-surface-inset py-0.5 pr-0.5 pl-2`,children:[(0,I.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-text-secondary`,title:e,children:e}),(0,I.jsx)(Y,{label:`Copy`,size:`sm`,icon:(0,I.jsx)(hb,{}),onClick:t})]})}var Vie=[[`w-32`,`w-28`,`w-36`],[`w-20`,`w-24`]];function Hie({globals:e,projectId:t,filter:n,highlightField:r}){return e.isLoading?(0,I.jsx)(S9,{groups:Vie}):e.error?(0,I.jsxs)(YN,{children:[`Could not load settings: `,e.error.message]}):e.data?(0,I.jsxs)(I.Fragment,{children:[s9.some(e=>b9(n,e.field))&&(0,I.jsx)(C9,{title:`Prerequisites for unattended workers`,children:(0,I.jsx)(I9,{projectId:t,filter:n,highlightField:r})}),(0,I.jsx)(x9,{title:`Width & retries`,rows:mh(e.data,`burns`),filter:n,highlightField:r})]}):null}var Uie={prep:`established by preparation`,session:`established in a conversation on this machine`,human:`set by you`,build:`built by runcastle from this repo's own Dockerfile`};function Wie({source:e,evidence:t,onClose:n}){let r=(0,F.useRef)(null);return(0,F.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),n())},t=e=>{let t=r.current?.parentElement;e.target instanceof Node&&t?.contains(e.target)||n()};return window.addEventListener(`keydown`,e,!0),window.addEventListener(`mousedown`,t),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`mousedown`,t)}},[n]),(0,I.jsxs)(`div`,{ref:r,className:`absolute top-7 left-0 z-10 max-h-72 w-105 overflow-auto rounded-lg bg-surface-raised px-3.5 py-3 shadow-popover animate-pop-in`,children:[(0,I.jsxs)(`h4`,{className:`m-0 mb-2 text-xs font-medium text-text-tertiary`,children:[`Evidence · `,Uie[e]]}),(0,I.jsx)(`pre`,{className:`m-0 font-mono text-xs leading-[18px] whitespace-pre-wrap text-text-secondary`,children:t})]})}var Gie=[{group:`model`,title:`Model & sandbox`},{group:`commands`,title:`Commands`},{group:`chat`,title:`Project chat`}],Kie=[[`w-24`,`w-32`],[`w-28`,`w-20`,`w-32`],[`w-24`]];function qie({scoped:e,projectId:t,filter:n,highlightField:r}){let i=R.project.prep.useQuery({projectId:t}),[a,o]=(0,F.useState)(null);if(e.isLoading)return(0,I.jsx)(S9,{groups:Kie});if(e.error)return(0,I.jsxs)(YN,{children:[`Could not load settings: `,e.error.message]});if(!e.data)return null;let s=i.data?.findings??[],c=new Map(s.map(e=>[e.key,e])),l=mh(e.data,`project`,s),u=e=>{let t=c.get(e.key);return a!==e.key||!t?.evidence?null:(0,I.jsx)(Wie,{source:t.source,evidence:t.evidence,onClose:()=>o(null)})};return(0,I.jsx)(I.Fragment,{children:Gie.map(({group:e,title:i})=>(0,I.jsx)(x9,{title:i,rows:l.filter(t=>t.group===e),projectId:t,filter:n,highlightField:r,onOpenEvidence:e=>o(t=>t===e?null:e),evidence:u},e))})}var Jie={general:`How runcastle looks, where its server listens, and how sessions are sandboxed.`,models:`The default model, the roster this machine offers, and which model runs each step.`,burns:`What workers need before a round can start, and how hard they try once it does.`,project:`Values this project sets for itself. Unset fields inherit the global value, shown as ghost text.`},Yie={general:lie,models:wie,burns:Hie,project:qie};function Xie({projectId:e,projectName:t,location:n,onClose:r}){let i=R.settings.get.useQuery(),a=R.settings.get.useQuery({projectId:e}),[o,s]=(0,F.useState)(n.page),[c,l]=(0,F.useState)(``),u=(0,F.useRef)(null),d=(0,F.useMemo)(()=>Oh(c,Qie(i.data,a.data)),[c,i.data,a.data]),f={query:c,...d},p=c.trim()!==``;(0,F.useEffect)(()=>{if(!p||d.counts[o]>0)return;let e=c9.find(e=>d.counts[e.page]>0);e&&s(e.page)},[p,d,o]);let m=e=>{!(e.metaKey||e.ctrlKey)||e.key.toLowerCase()!==`f`||(e.preventDefault(),u.current?.focus(),u.current?.select())},h=Yie[o],g=c9.find(e=>e.page===o)?.label??``,_=p&&d.matches.size===0;return(0,I.jsx)(aP,{open:!0,onClose:r,size:`xl`,label:`Settings`,className:`overflow-hidden`,children:(0,I.jsxs)(`div`,{className:`relative grid h-[min(720px,84vh)] grid-cols-[208px_minmax(0,1fr)]`,onKeyDown:m,children:[(0,I.jsx)(zre,{page:o,filter:f,filterRef:u,projectName:t,onFilter:l,onSelect:s}),(0,I.jsx)(`section`,{className:`grid min-h-0 min-w-0 grid-rows-[minmax(0,1fr)] bg-surface`,children:(0,I.jsx)(`div`,{className:`min-h-0 overflow-x-hidden overflow-y-auto px-8 pt-9 pb-12 [scrollbar-width:thin]`,children:(0,I.jsxs)(`div`,{className:`animate-rise-in`,children:[(0,I.jsxs)(`header`,{className:`mb-8`,children:[(0,I.jsx)(`h2`,{className:`m-0 text-lg font-semibold text-text`,children:g}),(0,I.jsx)(`p`,{className:`mt-1 mb-0 text-sm text-text-tertiary`,children:Jie[o]})]}),(0,I.jsx)(`div`,{children:(0,I.jsx)(h,{globals:i,scoped:a,projectId:e,filter:f,...o===n.page&&n.field?{highlightField:n.field}:{}})}),_&&(0,I.jsx)(XN,{compact:!0,icon:(0,I.jsx)(My,{}),title:`Nothing matches`,hint:`Try “model”, “verify” or “image”.`})]},o)})}),(0,I.jsx)(Y,{label:`Close`,kbd:`Esc`,size:`sm`,icon:(0,I.jsx)(By,{}),onClick:r,className:`absolute top-3 right-3`})]})})}var Zie={id:sie,page:`general`,terms:[`Theme`,`Appearance`,`Dark`,`Light`,`System`]};function Qie(e,t){let n=c9.flatMap(({page:n})=>{let r=n===`project`?t:e;return r?Dh(r,n):[]}),r=s9.map(e=>({id:e.field,page:`burns`,terms:[e.label,...e.terms]}));return[Zie,nie,...n,...r]}function U9({projectId:e,nav:t}){let n=q_(e),{selectedFeatureId:r,projectSelected:i,preparing:a,select:o,selectView:s,selectProject:c,showProject:l,openConversations:u,startPreparation:d,setCmdk:f}=n,[p,m]=(0,F.useState)(null),[h,g]=(0,F.useState)(0),[_,v]=(0,F.useState)(!1),[y,b]=(0,F.useState)(0),x=()=>{v(!0),b(e=>e+1)},[S,C]=(0,F.useState)(0),w=()=>{l(),C(e=>e+1)},T=()=>C(0),[E,D]=(0,F.useState)(0),O=()=>{l(),D(e=>e+1)},k=()=>D(0),ee=tI(),A=R.feature.list.useQuery({projectId:e},{refetchInterval:tg()}),j=ix(e),M=R.project.prep.useQuery({projectId:e}),N=M.data?.prepared??!0,te=M.data?.empty??!0,ne=R.feature.driveInfo.useQuery({projectId:e},{refetchInterval:tg()}).data,re=cx(ne,e)?ne:null,ie=p??(ne?.featureId?{featureId:ne.featureId,branch:ne.branch}:null),ae=A.data,P=(0,F.useCallback)((e,t)=>{if(!e)return o(null);o(e,t??U_(e,ae?.find(t=>t.id===e)))},[o,ae]),[oe,se]=(0,F.useState)(null),ce=zx(),le=(0,F.useCallback)((e,t)=>{se(null),P(e,t??(ce?`chat`:void 0))},[P,ce]),ue=n.featureView,de=(0,F.useCallback)(e=>{let t=r&&!i&&!a&&ae?.find(e=>e.id===r)?.status!==`draft`;o(e,mx(e,{featureId:t?r:null,view:ue}))},[o,r,i,a,ae,ue]),[fe,pe]=(0,F.useState)(!1),[me]=(0,F.useState)(()=>m_(__()));(0,F.useEffect)(()=>{if(fe||!ae)return;let t=h_(me,e);if(t?.kind===`chat`)c();else if(t?.kind===`conversations`)u();else if(t?.kind===`prepare`)d();else if(t){let e=ae.find(e=>e.slug===t.featureSlug);if(e)P(e.id,u_(t));else if(ce)o(null);else{let e=Bg(ae);se(e?.id??null),P(e?.id??null)}}else if(ce)o(null);else if(!r&&!i&&!a){let e=Bg(ae);e&&(se(e.id),P(e.id))}else r&&!i&&!a&&s(U_(r,ae.find(e=>e.id===r)));pe(!0)},[fe,ae,e,me,ce,o,r,i,a,P,s,c,u,d]);let he=ae?.find(e=>e.id===r),ge=he?.slug??null,_e=he?.status===`draft`?`work`:n.featureView;D_(fe&&!n.creating?g_({projectId:e,preparing:a,projectSelected:i,conversations:n.conversations,featureSlug:ge,featureView:_e}):null,t=>{if(!t||l_(t)!==e)return;let n=h_(t,e);if(!n)o(null);else if(n.kind===`chat`)c();else if(n.kind===`conversations`)u();else if(n.kind===`prepare`)d();else{let e=ae?.find(e=>e.slug===n.featureSlug);e?o(e.id,c_(n)):P(ce?null:Bg(ae??[])?.id??null)}});let ve=()=>{c(),g(e=>e+1)};(0,F.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`?(e.preventDefault(),f(!0)):ox(e)&&(e.preventDefault(),x())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[f]);let[ye,be]=(0,F.useState)(null),xe=(0,F.useCallback)(()=>be(null),[]),Se=Ty({...n,featureCount:ae?.length??0,prepared:N,empty:te}),Ce=()=>o(null),we=Se===`feature`?()=>n.selectView(_e===`details`?`chat`:`details`):void 0,Te=Se===`create`?(0,I.jsx)(`section`,{className:`relative flex min-h-0 min-w-0 flex-col`,children:(0,I.jsx)(xre,{projectId:e,onCancel:n.cancelCreate,onCreated:P})}):Se===`prepare`?(0,I.jsx)(Sre,{projectId:e,...n.preparing?{onClose:n.closePreparation}:{}}):Se===`project`?(0,I.jsx)(vre,{projectId:e,talk:j,newChatRequest:h,onConsumeNewChatRequest:()=>g(0),inboxRequest:S,onConsumeInboxRequest:T,empty:te,conversations:n.conversations,threadRequest:ye,onConsumeThreadRequest:xe,onOpenConversations:n.openConversations,onCloseConversations:n.selectProject,onOpenPreparation:n.startPreparation,driveRequest:E,onConsumeDriveRequest:k,onBackToList:Ce}):Se===`feature`&&r?(0,I.jsx)(oq,{label:`feature view`,fallback:e=>(0,I.jsx)(tre,{featureId:r,error:e}),children:(0,I.jsx)(rre,{featureId:r,view:_e,onViewChange:n.selectView,guidance:n.guidance,driving:ie,landedOn:oe===r,onDriveChange:m,onOpenThread:e=>{be(e),n.selectProject()},onDeleted:()=>{n.select(null),n.selectProject()},onBackToList:Ce})},`ws-${r}`):null,Ee=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(aI,{phoneShows:(fe?!n.creating&&!a&&!i&&!r:!h_(me,e))?`list`:`page`,sidebar:(0,I.jsx)(fte,{projectId:e,nav:t,view:Se,selectedFeatureId:n.selectedFeatureId,onSelect:le,onSelectProject:n.selectProject,onNewChat:ve,onDraft:n.startDraft,onOpenPreparation:n.startPreparation,onOpenNote:x,onOpenCmdk:()=>f(!0),onOpenSettings:()=>n.openSettings(),projectDriveBranch:re?.branch??null,onOpenProjectDrive:O,onOpenFeatureDrive:e=>P(e,`drive`),driving:ie,onDriveChange:m}),children:(0,I.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col [&>*]:min-h-0 [&>*]:flex-1`,children:(0,I.jsx)(w_.Provider,{value:fe,children:Te})})}),!ce&&(0,I.jsx)(jre,{open:n.cmdkOpen,onClose:()=>n.setCmdk(!1),features:ae??[],selectedFeatureId:n.selectedFeatureId,onSelect:le,onOpenSettings:()=>n.openSettings(),onOpenPreparation:n.startPreparation,onOpenProjectChat:n.selectProject,onOpenNote:x,onToggleSidebar:ee.toggleSidebar,onToggleDetails:we,nav:t}),(0,I.jsx)(Fre,{projectId:e,projectName:t.currentProject?.name??``,open:_,openRequest:y,onClose:()=>v(!1),onOpenInbox:w}),n.settings&&!ce&&(0,I.jsx)(Xie,{projectId:e,projectName:t.currentProject?.name??``,location:n.settings,onClose:n.closeSettings})]});return(0,I.jsx)(yte,{open:n.openSettings,children:(0,I.jsx)(px,{value:de,children:(0,I.jsx)(wx,{children:Ee})})})}var $ie=`${CN} h-7 w-full font-medium`,eae=`A run is in flight — it has to finish before this project can go.`;function tae({project:e,stats:t,loading:n,onOpen:r,index:i}){let a=rx(),o=R.useUtils(),s=zx(),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(e.name),m=R.project.rename.useMutation({onSuccess:async()=>{await o.project.list.invalidate(),l(!1)},onError:e=>a.push(e.message)}),h=R.project.close.useMutation({onSuccess:async()=>{await o.project.list.invalidate(),a.push(`removed ${e.name}`,`info`)},onError:e=>a.push(e.message)});(0,F.useEffect)(()=>{if(!u)return;let e=e=>{e.key===`Escape`&&d(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u]);let g=t.activeRuns>0,_=()=>{let t=f.trim();t&&t!==e.name?m.mutate({projectId:e.id,name:t}):l(!1)},v=c?(0,I.jsx)(`input`,{className:$ie,value:f,"aria-label":`Project name`,maxLength:80,autoFocus:!0,onChange:e=>p(e.target.value),onKeyDown:t=>{t.stopPropagation(),t.key===`Enter`&&_(),t.key===`Escape`&&(p(e.name),l(!1))},onBlur:_}):(0,I.jsx)(`span`,{className:`block truncate font-medium`,children:e.name});return u?(0,I.jsx)(JA,{className:`animate-fade-in`,wrap:!0,title:(0,I.jsxs)(`span`,{className:`text-text-secondary`,children:[`Remove `,(0,I.jsx)(`span`,{className:`font-medium text-text`,children:e.name}),`? The repo on disk is untouched.`,g&&(0,I.jsx)(`span`,{className:`block text-xs text-text-tertiary`,children:eae})]}),control:(0,I.jsxs)(`span`,{className:`flex shrink-0 gap-2 pr-3`,children:[(0,I.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>d(!1),children:`Cancel`}),(0,I.jsx)(J,{size:`sm`,variant:`danger`,icon:(0,I.jsx)(Vy,{}),disabled:g||h.isPending,onClick:()=>h.mutate({projectId:e.id}),children:h.isPending?`Removing…`:`Remove`})]})}):(0,I.jsx)(JA,{index:i,leading:(0,I.jsx)(Qy,{}),title:v,description:(0,I.jsx)(`span`,{className:`block truncate text-left font-mono`,dir:`rtl`,title:e.repoPath,children:(0,I.jsx)(`bdi`,{children:e.repoPath})}),meta:n?`Loading…`:(0,I.jsx)(ZA,{className:`flex-nowrap`,items:[t.needsYou>0&&{tone:`warning`,strong:t.needsYou,text:t.needsYou===1?`needs you`:`need you`},t.activeRuns>0&&{tone:`live`,strong:t.activeRuns,text:`running`},t.total===0?{text:`No features yet`}:{strong:t.total,text:t.total===1?`feature`:`features`}]}),onClick:c?void 0:r,tooltip:`Open ${e.name}`,actionsOverlay:!0,actions:!c&&!s&&(0,I.jsx)(DI,{label:`${e.name} actions`,actions:[{key:`rename`,label:`Rename`,onSelect:()=>{p(e.name),l(!0)}},{key:`remove`,label:`Remove from list`,danger:!0,onSelect:()=>d(!0)}]})})}function W9({nav:e}){let t=zx(),n=e.projects??[],r=tg(),i=R.useQueries(e=>n.map(t=>e.feature.list({projectId:t.id},{refetchInterval:r}))),a=n.map((e,t)=>cee(i[t]?.data??[])),o=a.reduce((e,t)=>e+t.activeRuns,0),s=a.reduce((e,t)=>e+t.needsYou,0),c=n.map((e,t)=>({project:e,stats:a[t],loading:i[t]?.data===void 0})),l=c.filter(e=>e.stats.needsYou>0||e.stats.activeRuns>0).sort((e,t)=>t.stats.needsYou-e.stats.needsYou||t.stats.activeRuns-e.stats.activeRuns),u=c.filter(e=>!l.includes(e)),d=(t,n)=>(0,I.jsx)(tae,{index:n,project:t.project,stats:t.stats,loading:t.loading,onOpen:()=>e.enterProject(t.project.id)},t.project.id),f=(0,I.jsxs)(`section`,{className:q(`flex min-h-0 min-w-0 flex-1 flex-col`,t&&`h-dvh`),children:[(0,I.jsx)(MN,{crumbs:[{label:`Projects`,icon:(0,I.jsx)(yb,{})}]}),(0,I.jsxs)(PN,{routeKey:`portfolio`,className:`relative isolate`,children:[(0,I.jsx)(ZI,{}),(0,I.jsx)(FN,{title:`Projects`,meta:[{strong:n.length,text:n.length===1?`project open`:`projects open`},o>0&&{tone:`live`,strong:o,text:`running`},s>0&&{tone:`warning`,strong:s,text:s===1?`needs you`:`need you`}],actions:!t&&(0,I.jsx)(J,{variant:`primary`,icon:(0,I.jsx)(Ry,{}),onClick:e.showOpen,children:`Open a project`})}),l.length>0&&(0,I.jsx)(YA,{divided:!0,label:`Live projects`,className:q(`card relative mt-8 rounded-lg p-1`,o>0&&`orbit-light`),children:l.map(d)}),u.length>0&&(0,I.jsx)(YA,{divided:!0,label:`Open projects`,className:l.length>0?`mt-4 px-1`:`mt-8`,children:u.map((e,t)=>d(e,t+l.length))})]})]});return t?f:(0,I.jsx)(aI,{sidebar:(0,I.jsx)(nae,{nav:e}),children:f})}function nae({nav:e}){let t=Qh(),n=uF();return(0,I.jsxs)(`nav`,{"aria-label":`Projects`,className:`relative isolate flex h-full min-h-0 flex-col p-2`,children:[(0,I.jsx)(ZI,{}),(0,I.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-0.5`,children:[(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1`,children:(0,I.jsx)(qF,{nav:e})}),(0,I.jsx)(nI,{})]}),(0,I.jsx)(`div`,{className:`mt-2 flex flex-col gap-px`,children:(0,I.jsx)(qA,{icon:(0,I.jsx)(yb,{}),label:`All projects`,meta:e.projects?.length,active:!0})}),(0,I.jsx)(`div`,{className:`flex-1`}),(0,I.jsx)(tL,{health:t===`live`?`ok`:t===`connecting`?`connecting`:`reconnecting`,origin:typeof window>`u`?`this machine`:window.location.origin,sandbox:AP,notify:null,theme:n.resolved,onToggleTheme:n.toggle})]})}var rae=4;function iae({crumbs:e,value:t,onNavigate:n,onEnterPath:r,placeholder:i}){let[a,o]=(0,F.useState)(null),s=a!==null,c=e.length>rae,l=c?e.slice(-3):e;return s?(0,I.jsx)(`input`,{className:`${CN} flex-1 font-mono text-xs`,"aria-label":`Path`,spellCheck:!1,autoComplete:`off`,autoFocus:!0,value:a,placeholder:i,onChange:e=>o(e.target.value),onBlur:()=>o(null),onKeyDown:e=>{e.key===`Enter`&&(r(a.trim()),o(null)),e.key===`Escape`&&(e.stopPropagation(),o(null))}}):(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 cursor-text items-center gap-0.5 truncate`,onClick:()=>o(t),role:`group`,"aria-label":`Current path`,children:[c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G9,{crumb:e[0],onNavigate:n}),(0,I.jsx)(Wy,{size:12,className:`shrink-0 text-text-disabled`}),(0,I.jsx)(`span`,{className:`shrink-0 px-1 text-sm text-text-tertiary`,title:e[e.length-1].path,children:`…`})]}),l.map((e,t)=>(0,I.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5`,children:[(t>0||c)&&(0,I.jsx)(Wy,{size:12,className:`shrink-0 text-text-disabled`}),(0,I.jsx)(G9,{crumb:e,onNavigate:n})]},e.path)),(0,I.jsx)(`button`,{type:`button`,className:`${WE} ml-1 inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-icon transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover hover:text-text`,"aria-label":`Edit path`,title:`Edit path`,onClick:()=>o(t),children:(0,I.jsx)(Yy,{size:14})})]})}function G9({crumb:e,onNavigate:t}){return(0,I.jsx)(`button`,{type:`button`,className:`${WE} shrink-0 rounded-sm px-1 py-0.5 cursor-pointer font-mono text-xs text-text-secondary transition-colors duration-(--dur-1) ease-app hover:bg-surface-hover hover:text-text`,onClick:n=>{n.stopPropagation(),t(e.path)},children:e.name})}function aae({initialPath:e,onPick:t,onCancel:n}){let r=e?.trim()||void 0,[i,a]=(0,F.useState)(r),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(r??null),[u,d]=(0,F.useState)(null),f=R.project.roots.useQuery(),p=R.project.browse.useQuery({dir:i,showHidden:o},{placeholderData:e=>e,retry:!1}),m=p.data,h=m?.dir??i,g=e=>{l(null),d(null),a(e)},_=e=>{l(e||null),d(null),a(e||void 0)},v=c!==null&&p.isError?dee(i,p.error.message):null,y=v!==null&&v.dir!==i,b=v?.dir,x=p.error?.message;(0,F.useEffect)(()=>{y&&(i===c&&x&&d(Kg(x)),a(b))},[y,b,i,c,x]);let S=e=>{if(![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;let t=[...e.currentTarget.querySelectorAll(`[data-dir-row] button`)];if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowDown`?Math.min(t.length-1,n+1):Math.max(0,n===-1?0:n-1)]?.focus()};return(0,I.jsxs)(aP,{open:!0,onClose:n,size:`lg`,labelledBy:`dir-picker-title`,className:`flex h-[min(620px,76vh)] flex-col overflow-hidden`,children:[(0,I.jsx)(oP,{id:`dir-picker-title`,title:`Choose a repository`,description:`Browse this machine for a git repository to open.`,onClose:n}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-y border-border-subtle px-3 py-2`,children:[(0,I.jsx)(Y,{label:`Up one level`,icon:(0,I.jsx)(Tb,{}),onClick:()=>m?.parent&&g(m.parent),disabled:!m?.parent}),(0,I.jsx)(iae,{crumbs:m?.crumbs??[],value:c??h??``,onNavigate:g,onEnterPath:_,placeholder:OP()}),(0,I.jsx)(HN,{label:`Hidden`,checked:o,onChange:s,className:`shrink-0 px-2`})]}),u&&(0,I.jsx)(`div`,{className:`shrink-0 border-b border-border-subtle px-4 py-3`,children:(0,I.jsx)(eP,{message:u.message,path:u.path,hint:`Showing the closest folder that could be listed. Edit the path to try again.`})}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex w-44 shrink-0 flex-col gap-0.5 overflow-y-auto border-r border-border-subtle p-2`,onKeyDown:S,children:[(0,I.jsx)(WA,{className:`px-2.5`,children:`Locations`}),(f.data??[]).map(e=>(0,I.jsx)(`div`,{"data-dir-row":``,children:(0,I.jsx)(qA,{label:(0,I.jsx)(`span`,{className:`font-mono text-xs`,children:e.label}),title:e.path,icon:e.label===`~`?(0,I.jsx)(yb,{}):(0,I.jsx)(Qy,{}),active:h===e.path,onClick:()=>g(e.path)})},e.path))]}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto p-2`,onKeyDown:S,children:[y||p.isLoading?(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-2 text-sm text-text-tertiary`,children:[(0,I.jsx)(UE,{}),` Loading…`]}):p.isError?(0,I.jsx)(`div`,{className:`p-2`,children:(0,I.jsx)(eP,{...Kg(p.error.message)})}):(m?.entries.length??0)===0?(0,I.jsx)(XN,{compact:!0,icon:(0,I.jsx)(Qy,{}),title:`No subfolders here`,hint:o?void 0:`Hidden folders, junctions and node_modules are filtered.`}):(0,I.jsx)(`div`,{className:`flex flex-col gap-0.5 animate-rise-in`,role:`list`,children:(m?.entries??[]).map(e=>(0,I.jsx)(`div`,{role:`listitem`,"data-dir-row":``,children:(0,I.jsx)(qA,{onDoubleClick:()=>e.isRepo&&t(e.path),label:e.name,title:e.path,icon:e.isRepo?(0,I.jsx)(Fy,{}):(0,I.jsx)(Qy,{}),onClick:()=>g(e.path),className:e.isRepo?`text-text`:void 0,meta:e.isRepo?(0,I.jsx)(`span`,{className:`text-text-secondary`,children:`git`}):e.isSymlink?`link`:void 0})},e.path))},h),m?.truncated&&(0,I.jsx)(`p`,{className:`m-0 px-2.5 py-2 text-xs text-text-tertiary`,children:`Listing truncated — this folder is very large.`})]})]}),(0,I.jsxs)(cP,{className:`border-t border-border-subtle pt-3 pb-3`,start:(0,I.jsx)(`div`,{className:`min-w-0 truncate text-left font-mono text-xs`,dir:`rtl`,title:h,children:(0,I.jsx)(`bdi`,{children:h??`—`})}),children:[(0,I.jsx)(J,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,I.jsx)(J,{variant:`primary`,icon:(0,I.jsx)(Qy,{}),onClick:()=>h&&t(h),disabled:!h||p.isError,children:`Open this folder`})]})]})}function K9({rail:e,stepKey:t,direction:n=`forward`,onKeyDown:r,children:i}){return(0,I.jsx)(`div`,{className:`min-h-full`,onKeyDown:r,children:(0,I.jsxs)(`div`,{className:q(`mx-auto grid w-full gap-12 px-8 pt-[14vh] pb-12`,e?`max-w-[860px] grid-cols-[176px_minmax(0,1fr)]`:`max-w-[560px]`),children:[e&&(0,I.jsx)(`div`,{className:`pt-1`,children:e}),(0,I.jsx)(`div`,{className:q(`min-w-0`,n===`forward`?`animate-slide-in-right`:`animate-rise-in`),children:i},t)]})})}function q9({title:e,children:t}){return(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`h1`,{className:`m-0 text-xl font-semibold tracking-tight text-pretty text-text`,children:e}),(0,I.jsx)(`p`,{className:`mt-2 mb-0 text-base text-pretty text-text-secondary`,children:t})]})}function J9({onBack:e,note:t,children:n}){return(0,I.jsxs)(`footer`,{className:`mt-10 border-t border-border-subtle pt-5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e&&(0,I.jsx)(J,{variant:`ghost`,icon:(0,I.jsx)(wb,{}),onClick:e,children:`Back`}),(0,I.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:n})]}),t&&(0,I.jsx)(`p`,{className:`mt-2 mb-0 text-right text-xs text-text-tertiary`,children:t})]})}function Y9({firstRun:e,rail:t,variant:n=`screen`,onOpened:r,onCancel:i}){let[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(!1),p=rx(),m=R.useUtils(),h=zx(),g=R.project.open.useMutation({onSuccess:async e=>{await m.project.list.invalidate(),p.push(`opened ${e.name}`,`info`),r(e.id)},onError:()=>void 0}),_=R.project.initRepo.useMutation({onSuccess:({repoPath:e})=>{u(e),g.mutate({repoPath:e})},onError:()=>void 0}),v=()=>{g.reset(),_.reset(),f(!1)},y=e=>{let t=(e??a).trim();if(t){if(v(),!kP(t)){f(!0);return}u(t),g.mutate({repoPath:t})}},b=()=>{v(),c(!0)},x=g.isPending||_.isPending,S=_.error??g.error,C=d?{message:`Enter an absolute path`,hint:`A path from the root of this machine, like ${OP()}.`,path:null}:S?mee(S.message,l):null,w=e=>{o(e),c(!1),y(e)},T=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:q(`flex items-center gap-2`,n===`screen`&&`mt-8`),children:[(0,I.jsx)(EN,{id:`open-repo-path`,size:`lg`,mono:!0,icon:(0,I.jsx)(Qy,{}),className:`flex-1`,value:a,onChange:e=>o(e.target.value),placeholder:OP(),"aria-label":`Repository path`,autoFocus:!0,spellCheck:!1,invalid:!!C,"aria-describedby":C?`open-repo-error`:`open-repo-hint`,onKeyDown:e=>{e.key===`Enter`&&y()}}),(0,I.jsx)(J,{size:`lg`,icon:(0,I.jsx)(My,{}),onClick:b,disabled:x,children:`Browse…`}),(0,I.jsx)(J,{variant:`primary`,size:`lg`,icon:(0,I.jsx)(nb,{}),loading:g.isPending,onClick:()=>y(),disabled:x||a.trim()===``,children:`Open`})]}),C?(0,I.jsx)(`div`,{className:`mt-3 animate-rise-in`,children:(0,I.jsx)(eP,{...C,id:`open-repo-error`,action:C.offer===`init-repo`?(0,I.jsx)(J,{size:`sm`,icon:(0,I.jsx)(Fy,{}),loading:_.isPending,onClick:()=>_.mutate({repoPath:l}),disabled:x,children:`Initialize repository`}):void 0})}):(0,I.jsx)(`p`,{id:`open-repo-hint`,className:`mt-2.5 mb-0 text-xs text-text-tertiary`,children:`Paste an absolute path, or browse for one. The default branch is detected when the project opens.`})]}),E=(0,I.jsx)(I.Fragment,{children:s&&(0,I.jsx)(aae,{initialPath:a,onPick:w,onCancel:()=>c(!1)})});return h?n===`dialog`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(oP,{title:`Open a project`,onClose:i}),(0,I.jsx)(sP,{children:(0,I.jsx)(t9,{})})]}):(0,I.jsx)(K9,{children:(0,I.jsx)(t9,{})}):n===`dialog`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(oP,{title:`Open a project`,description:`Point runcastle at a local git repository — every feature runs its pipeline against it.`,onClose:x?void 0:i}),(0,I.jsx)(sP,{className:`pt-1`,children:T}),E]}):(0,I.jsxs)(K9,{rail:t,stepKey:`project`,onKeyDown:t=>{t.key===`Escape`&&!e&&!s&&i()},children:[!t&&(0,I.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs text-text-tertiary`,children:[(0,I.jsx)(Xb,{size:14}),e?`Welcome to runcastle`:`Your projects`]}),(0,I.jsx)(q9,{title:e?`Open your first project`:`Open a project`,children:`Point runcastle at a local git repository — every feature runs its pipeline against it.`}),T,!e&&(0,I.jsx)(`footer`,{className:`mt-10 flex items-center border-t border-border-subtle pt-5`,children:(0,I.jsx)(J,{variant:`ghost`,icon:(0,I.jsx)(wb,{}),onClick:i,disabled:x,children:`Cancel`})}),E]})}function oae({onBack:e,onNext:t}){let[n,r]=(0,F.useState)(!1);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q9,{title:`Run workers unattended?`,children:FP}),n&&(0,I.jsx)(`div`,{className:`mt-8 animate-rise-in`,children:(0,I.jsx)(I9,{onDismiss:t})}),(0,I.jsx)(J9,{onBack:e,children:!n&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(J,{variant:`ghost`,icon:(0,I.jsx)(eb,{}),onClick:()=>r(!0),children:`Set up now`}),(0,I.jsx)(J,{variant:`primary`,icon:(0,I.jsx)(nb,{}),onClick:t,children:`Skip for now`})]})})]})}function sae({onBack:e,onNext:t}){let[n,r]=(0,F.useState)(``),[i,a]=(0,F.useState)(``),o=rx(),s=R.useUtils(),c=R.setup.gitIdentity.useMutation({onSuccess:async()=>{await s.setup.doctor.invalidate(),t()},onError:e=>o.push(e.message)}),l=n.trim()!==``&&i.includes(`@`),u=()=>l&&c.mutate({name:n.trim(),email:i.trim()}),d=e=>e.key===`Enter`&&u();return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(q9,{title:`Set your git identity`,children:[`runcastle commits documentation and merges on your behalf, so it needs a name and email. This writes to `,(0,I.jsx)(`code`,{className:`font-mono text-sm text-text`,children:`git config --global`}),`.`]}),(0,I.jsxs)(`div`,{className:`mt-8 flex max-w-sm flex-col gap-4`,children:[(0,I.jsx)(kN,{label:`Name`,children:(0,I.jsx)(EN,{id:`wiz-name`,size:`lg`,value:n,onChange:e=>r(e.target.value),placeholder:`Ada Lovelace`,autoFocus:!0,spellCheck:!1,onKeyDown:d})}),(0,I.jsx)(kN,{label:`Email`,children:(0,I.jsx)(EN,{id:`wiz-email`,size:`lg`,type:`email`,value:i,onChange:e=>a(e.target.value),placeholder:`ada@example.com`,spellCheck:!1,onKeyDown:d})})]}),(0,I.jsx)(J9,{onBack:e,children:(0,I.jsx)(J,{variant:`primary`,icon:(0,I.jsx)(nb,{}),loading:c.isPending,onClick:u,disabled:!l,children:`Continue`})})]})}function cae({onNext:e}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(XI,{large:!0,className:`mb-6`,children:(0,I.jsx)(Xb,{size:26})}),(0,I.jsx)(q9,{title:`Your coding agent, driven through a pipeline`,children:`Describe a feature and runcastle runs the agent sessions that carry it from idea to merged. You test-drive the result and decide when it ships.`}),(0,I.jsx)(`ol`,{className:`m-0 mt-8 flex list-none flex-col p-0`,children:Av.map((e,t)=>(0,I.jsxs)(`li`,{className:`grid grid-cols-[16px_96px_minmax(0,1fr)] items-center gap-3 border-b border-border-subtle py-2.5 text-sm last:border-b-0 animate-rise-in`,style:{animationDelay:`${120+t*40}ms`},children:[(0,I.jsx)(Kb,{phase:e,size:16,label:``}),(0,I.jsx)(`span`,{className:`font-medium text-text`,children:Ub[e]}),(0,I.jsx)(`span`,{className:`text-text-tertiary`,children:jv[e]})]},e))}),(0,I.jsx)(J9,{children:(0,I.jsx)(J,{variant:`primary`,icon:(0,I.jsx)(nb,{}),onClick:e,autoFocus:!0,children:`Set up runcastle`})})]})}function lae({runtimes:e,onBack:t,onNext:n}){let r=Rh(e);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q9,{title:`Connect a coding agent`,children:`runcastle drives whichever agent you have — sign in to one or both. The ones you connect here are the ones whose models you can pick later.`}),(0,I.jsx)(`div`,{className:`mt-8`,children:(0,I.jsx)(B9,{children:e.map(e=>(0,I.jsx)(uae,{runtime:e},e.runtime))})}),(0,I.jsx)(J9,{onBack:t,note:r.length===0&&`Connect at least one agent to continue — runcastle has nothing to run without one.`,children:(0,I.jsx)(J,{variant:`primary`,icon:(0,I.jsx)(nb,{}),onClick:n,disabled:r.length===0,children:`Continue`})})]})}function uae({runtime:e}){let[t,n]=(0,F.useState)(null),r=rx(),i=R.useUtils(),a=R.setup.startTerminal.useMutation({onSuccess:({sessionId:e})=>n(e),onError:e=>r.push(e.message)}),o=Ih[e.runtime],s=e.talkReady?`Ready`:e.installed?`Not signed in`:`Not installed`;return(0,I.jsxs)(z9,{label:e.label,status:s,detail:e.detail,ok:e.talkReady,below:t&&(0,I.jsx)(V9,{sessionId:t,label:o.kind,onDone:()=>{n(null),i.setup.doctor.invalidate()}}),children:[e.installFix&&(0,I.jsx)(H9,{command:e.installFix,onCopy:()=>{navigator.clipboard?.writeText(e.installFix??``),r.push(`copied`,`info`)}}),e.installed&&!e.talkReady&&!t&&(0,I.jsxs)(J,{size:`sm`,icon:(0,I.jsx)(Ky,{}),loading:a.isPending,onClick:()=>a.mutate({kind:o.kind}),children:[`Run `,o.command]}),e.talkReady&&!e.afkReady&&(0,I.jsxs)(`span`,{className:`basis-full text-right text-xs text-text-tertiary`,children:[`Signed in for sessions you watch. Unattended workers on `,e.label,` also need its key — the next step sets that up.`]})]})}var dae={passed:`shipped`,done:`shipped`,current:`review`,todo:`draft`},fae={passed:`text-text-secondary`,done:`text-text-secondary`,current:`card font-medium text-text`,todo:`text-text-tertiary`};function X9({steps:e}){return(0,I.jsxs)(`nav`,{"aria-label":`Setup`,className:`flex flex-col gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 text-sm font-medium text-text`,children:[(0,I.jsx)(Xb,{size:16}),`Set up runcastle`]}),(0,I.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-0.5 p-0`,"aria-label":`Setup progress`,children:e.map(e=>(0,I.jsxs)(`li`,{"data-state":e.state,"aria-current":e.state===`current`?`step`:void 0,className:q(`flex flex-col rounded-md px-2.5 py-1.5 text-sm transition-colors duration-(--dur-2) ease-app`,fae[e.state]),children:[(0,I.jsxs)(`span`,{className:`flex min-h-5 items-center gap-2`,children:[(0,I.jsx)(Kb,{phase:dae[e.state],size:14,label:``}),e.label]}),e.detected&&(0,I.jsx)(`span`,{className:`mt-0.5 pl-5.5 text-xs font-normal text-pretty text-text-tertiary`,children:e.detected})]},e.key))})]})}function pae({onOpened:e,onCancel:t}){let n=R.setup.doctor.useQuery(void 0,{refetchOnWindowFocus:!1}),r=n.data?.results.find(e=>e.id===`git-identity`),i=Lh(n.data?.results??[]),[a,o]=(0,F.useState)(`intro`),[s,c]=(0,F.useState)(`forward`),l=(e,t)=>{c(t),o(e)},u=R.setup.seedModelDefaults.useMutation(),d=zx(),f=()=>{u.mutate({runtimes:Rh(i)}),l(`project`,`forward`)};if(d)return(0,I.jsx)(K9,{children:(0,I.jsx)(t9,{})});if(n.isLoading)return(0,I.jsx)(K9,{children:(0,I.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-sm text-text-tertiary`,children:[(0,I.jsx)(UE,{}),` Preparing setup…`]})});if(a===`project`)return(0,I.jsx)(Y9,{firstRun:!0,rail:(0,I.jsx)(X9,{steps:Vh(`project`,r)}),onOpened:e,onCancel:t});if(a===`intro`)return(0,I.jsx)(K9,{stepKey:`intro`,direction:s,children:(0,I.jsx)(cae,{onNext:()=>l(Nh(r),`forward`)})});let p=()=>{let e=Ph(a);e===`project`||e===void 0?f():l(e,`forward`)},m=()=>l(Fh(a,r)??`intro`,`back`);return(0,I.jsxs)(K9,{rail:(0,I.jsx)(X9,{steps:Vh(a,r)}),stepKey:a,direction:s,children:[a===`identity`&&(0,I.jsx)(sae,{onBack:m,onNext:p}),a===`runtimes`&&(0,I.jsx)(lae,{runtimes:i,onBack:m,onNext:p}),a===`afk`&&(0,I.jsx)(oae,{onBack:m,onNext:p})]})}var Z9=`runcastle.update.dismissed`;function mae(e,t){return e.updateAvailable&&e.latest!==null&&e.latest!==t}function Q9({tone:e=`neutral`,icon:t,children:n,action:r,onDismiss:i,dismissLabel:a=`Dismiss`}){return(0,I.jsxs)(`div`,{role:`status`,className:q(`flex h-10 shrink-0 animate-fade-in items-center gap-2.5 overflow-hidden border-b border-border-subtle pr-2 pl-4 text-sm`,e===`danger`?`bg-danger-subtle`:`bg-surface`),children:[(0,I.jsx)(`span`,{className:q(`inline-flex shrink-0 [&>svg]:size-4`,e===`danger`?`text-danger`:`text-accent`),children:t}),(0,I.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2 truncate text-text-secondary`,children:n}),r,i&&(0,I.jsx)(Y,{size:`sm`,label:a,icon:(0,I.jsx)(By,{}),onClick:i})]})}function hae(){let e=rx(),t=R.system.checkUpdate.useQuery(void 0,{staleTime:1/0,refetchOnWindowFocus:!1,retry:!1}),[n,r]=(0,F.useState)(()=>{try{return localStorage.getItem(Z9)}catch{return null}}),i=t.data;return!i||!i.latest||!mae(i,n)?null:(0,I.jsxs)(Q9,{icon:(0,I.jsx)(nb,{}),onDismiss:()=>{try{localStorage.setItem(Z9,i.latest)}catch{}r(i.latest)},dismissLabel:`Dismiss update notice`,action:(0,I.jsx)(J,{size:`sm`,variant:`ghost`,icon:(0,I.jsx)(hb,{}),onClick:()=>navigator.clipboard.writeText(i.command).then(()=>e.push(`Update command copied`,`info`),()=>e.push(`Copy failed`)),children:`Copy command`}),children:[(0,I.jsxs)(`span`,{className:`shrink-0 text-text`,children:[`runcastle `,i.latest,` is available`]}),(0,I.jsxs)(`span`,{className:`shrink-0 text-text-tertiary`,children:[`you're on `,i.current]}),(0,I.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-text-tertiary select-all`,children:i.command})]})}function gae({error:e,onRecheck:t}){return e?(0,I.jsxs)(Q9,{tone:`danger`,icon:(0,I.jsx)(Sb,{}),action:(0,I.jsx)(J,{size:`sm`,variant:`ghost`,icon:(0,I.jsx)(Db,{}),onClick:t,children:`Re-run checks`}),children:[(0,I.jsx)(`span`,{className:`shrink-0 font-medium text-text`,children:`Setup checks could not run`}),(0,I.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-text-secondary`,title:e,children:e})]}):null}function _ae(){let e=P_(),t,n=null;return e.loading||e.projects===void 0?t=(0,I.jsx)(aI,{children:(0,I.jsx)(PN,{children:(0,I.jsx)(yae,{})})}):e.view===`setup`?t=(0,I.jsx)(aI,{children:(0,I.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:(0,I.jsx)(pae,{onOpened:e.enterProject,onCancel:e.cancelOpen})})}):e.view===`open`&&e.projects.length>0?(t=e.currentProjectId?(0,I.jsx)(U9,{projectId:e.currentProjectId,nav:e},e.currentProjectId):(0,I.jsx)(W9,{nav:e}),n=(0,I.jsx)(aP,{open:!0,onClose:e.cancelOpen,size:`md`,label:`Open a project`,children:(0,I.jsx)(Y9,{variant:`dialog`,firstRun:!1,onOpened:e.enterProject,onCancel:e.cancelOpen})})):t=e.view===`open`?(0,I.jsx)(aI,{children:(0,I.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:(0,I.jsx)(Y9,{firstRun:e.projects.length===0,onOpened:e.enterProject,onCancel:e.cancelOpen})})}):e.view===`project`&&e.currentProjectId?(0,I.jsx)(U9,{projectId:e.currentProjectId,nav:e},e.currentProjectId):(0,I.jsx)(W9,{nav:e}),(0,I.jsx)(eI,{notices:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(hae,{}),(0,I.jsx)(gae,{error:e.doctorError,onRecheck:e.recheckDoctor})]}),children:(0,I.jsxs)(`div`,{className:`h-full bg-canvas`,children:[t,n]})})}var vae=[{name:`w-40`,path:`w-56`},{name:`w-28`,path:`w-44`},{name:`w-48`,path:`w-64`}];function yae(){return(0,I.jsxs)(WN,{label:`Loading projects…`,children:[(0,I.jsx)(`div`,{className:`flex h-7 items-center`,"data-skeleton":`title`,children:(0,I.jsx)(GN,{className:`h-5 w-32`})}),(0,I.jsx)(`div`,{className:`mt-2 flex h-5 items-center`,children:(0,I.jsx)(GN,{className:`h-2.5 w-28`})}),(0,I.jsx)(`div`,{className:`mt-8 flex flex-col`,children:vae.map((e,t)=>(0,I.jsxs)(`div`,{className:`flex min-h-10 items-center gap-3 border-b border-border-subtle px-3 py-2 last:border-b-0`,"data-skeleton":`project-row`,children:[(0,I.jsx)(GN,{className:`mt-0.5 size-4 self-start`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(`div`,{className:`flex h-5 items-center`,children:(0,I.jsx)(GN,{className:q(`h-3`,e.name)})}),(0,I.jsx)(`div`,{className:`flex h-4 items-center`,"data-skeleton":`repo-path`,children:(0,I.jsx)(GN,{className:q(`h-2.5`,e.path)})})]}),(0,I.jsx)(GN,{className:`h-2.5 w-16`})]},t))})]})}function bae(){return sg(),(0,I.jsx)(_ae,{})}function xae(e){return e instanceof Error&&e.message?e.message:typeof e==`string`&&e!==``?e:`something went wrong`}function Sae(e,t){return typeof t.options.onError==`function`?null:xae(e)}aF(),mI();function Cae(){let[e]=(0,F.useState)(()=>new Ue({mutationCache:new Ie({onError:(e,t,n,r)=>{let i=Sae(e,r);i&&tx(i)}}),defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}}})),[t]=(0,F.useState)(()=>R.createClient({links:di(`/api/trpc`)}));return(0,I.jsx)(R.Provider,{client:t,queryClient:e,children:(0,I.jsx)(Xe,{client:e,children:(0,I.jsx)(DE,{children:(0,I.jsx)(nx,{children:(0,I.jsx)(bae,{})})})})})}var $9=document.getElementById(`root`);if(!$9)throw Error(`#root not found`);(0,Dt.createRoot)($9).render((0,I.jsx)(F.StrictMode,{children:(0,I.jsx)(Cae,{})}));
|