@krapht/ork 1.0.0-alpha.3 → 1.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{__build_info__-BwrKe6yz.mjs → __build_info__-Dl8yTEu-.mjs} +2 -2
- package/dist/bin.mjs +63 -225
- package/dist/{clean-hXSaN8BT.mjs → clean-DYVmLkd4.mjs} +1 -1
- package/dist/{completion-Cga01yQP.mjs → completion-BVx917Yr.mjs} +5 -5
- package/dist/{context-mCAwzFFM.mjs → context-CepHRoj9.mjs} +3 -3
- package/dist/{decide-BvZnKErW.mjs → decide-CK_-lI5V.mjs} +3 -3
- package/dist/{find-CbetS8I2.mjs → find-DWiDJ5Lc.mjs} +1 -1
- package/dist/{format-D87bY6Ud.mjs → format-yBEAXZhk.mjs} +223 -17
- package/dist/{in-a-run-Bs4Wv-Cz.mjs → in-a-run-CKFIeMpU.mjs} +1 -1
- package/dist/{limits-RzKQ_zPk.mjs → limits-CwzPe9wZ.mjs} +1 -1
- package/dist/{list-DX65Sbu7.mjs → list-BE02pCZ9.mjs} +1 -1
- package/dist/{mcp-DKrrxowo.mjs → mcp-DMuBbUHU.mjs} +6 -6
- package/dist/{output-Q3TZ-Ave.mjs → output-BhYkshYq.mjs} +9 -6
- package/dist/{pause-B5Z41lR3.mjs → pause-C_Q0W6iX.mjs} +4 -4
- package/dist/{relay-BLnjMdjT.mjs → relay-COCvG-0I.mjs} +2 -2
- package/dist/{remove-IbcZOemm.mjs → remove-RVcX1KqP.mjs} +3 -3
- package/dist/{send-CJKEhBL1.mjs → send-OVpRei_5.mjs} +3 -3
- package/dist/{src-LSxjnWDH.mjs → src-CxZr4Bp2.mjs} +16 -8
- package/dist/{src-DnETlJ1r.mjs → src-Do_MhwiV.mjs} +186 -30
- package/dist/{src-XDSRnAZV.mjs → src-HxtJOMRr.mjs} +172 -167
- package/dist/{src-BTDzibW3.mjs → src-QEycKJWk.mjs} +26 -12
- package/dist/ui/THIRD_PARTY_LICENSES.txt +594 -0
- package/dist/ui/assets/app-DzI77WV9.js +75 -0
- package/dist/ui/assets/app-pTYGrAbI.css +1 -0
- package/dist/ui/assets/{index-BkI68sr5.js → index-2G_6XIIv.js} +3 -3
- package/dist/ui/assets/theme-CdXvqTQ6.js +1 -0
- package/dist/ui/index.html +2 -2
- package/dist/{ui-fvrO7Gxd.mjs → ui-Dz_qfUOz.mjs} +4 -4
- package/dist/{usage-bNdcBcj9.mjs → usage-BcLUZ1xw.mjs} +5 -5
- package/dist/{watch-EhlO304A.mjs → watch-Buyn0Mhz.mjs} +6 -6
- package/dist/{workflows-C5hYAVcE.mjs → workflows-1sntXqSd.mjs} +3 -3
- package/dist/{worktrees-BQFcpYz1.mjs → worktrees-B_Go_A9w.mjs} +4 -4
- package/package.json +1 -1
- package/dist/ui/assets/app-BNElhp7Z.js +0 -67
- package/dist/ui/assets/app-BNT0SuIz.css +0 -1
- package/dist/ui/assets/theme-3xH5jxKs.js +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,T as b,U as x,V as S,W as C,X as w,Y as T,Z as E,_ as D,a as O,at as k,b as A,c as j,ct as M,d as N,et as P,f as F,g as I,h as L,i as R,j as ee,k as z,l as te,lt as ne,m as re,n as ie,nt as ae,o as oe,ot as se,p as ce,q as le,r as ue,rt as de,s as fe,st as pe,t as me,tt as he,u as ge,v as _e,w as ve,x as ye,y as be,z as B}from"./theme-CdXvqTQ6.js";function xe(){let e=this._zod;return e.message??=JSON.stringify(e.def,l,2),e.message}function Se(e){this._zod.message=e}var Ce={get:xe,set:Se,enumerable:!0,configurable:!0},we={value:void 0,enumerable:!1},Te=new WeakSet([Object.prototype,Error.prototype]),Ee=O(`$ZodError`,(e,t)=>{e.name=`$ZodError`,we.value=t,Object.defineProperty(e,"issues",we),we.value=void 0,Object.defineProperty(e,"message",Ce);let n=Object.getPrototypeOf(e);Te.has(n)||(Te.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function De(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Oe(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?De(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function ke(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],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Ae(e,t){return{callee:t?.callee??e,Err:t?.Err}}var je=e=>{let t=(n,r,i,o)=>{let s=i?{...i,async:!1}:{async:!1},c=n._zod.run({value:r,issues:[]},s);if(c instanceof Promise)throw new ue;if(c.issues.length){let n=new((o?.Err)??e)(c.issues.map(e=>a(e,s,oe())));throw L(n,o?.callee??t),n}return c.value};return t},Me=e=>{let t=async(n,r,i,o)=>{let s=i?{...i,async:!0}:{async:!0},c=n._zod.run({value:r,issues:[]},s);if(c instanceof Promise&&(c=await c),c.issues.length){let n=new((o?.Err)??e)(c.issues.map(e=>a(e,s,oe())));throw L(n,o?.callee??t),n}return c.value};return t},Ne=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 ue;return a.issues.length?Pe(e,a.issues,i):{success:!0,data:a.value}};function Pe(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>a(e,n,oe()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var Fe=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?Pe(e,a.issues,i):{success:!0,data:a.value}},Ie=Symbol.for(`zod.compile.invalid`),Le=Symbol.for(`zod.compile.fallback`),Re=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Ie)return!0;if(r.definite===!0&&n===void 0)return!1}return ze(e,t,n)});function ze(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Le]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new ue;return a.issues.length===0}var Be=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Ve=e=>{let t=je(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Ae(n,a))};return n},He=e=>{let t=je(e),n=(e,r,i,a)=>t(e,r,i,Ae(n,a));return n},Ue=e=>{let t=Me(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Ae(n,a))};return n},We=e=>{let t=Me(e),n=async(e,r,i,a)=>await t(e,r,i,Ae(n,a));return n},Ge=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ne(e)(t,n,i)},Ke=e=>(t,n,r)=>Ne(e)(t,n,r),qe=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Fe(e)(t,n,i)},Je=e=>async(t,n,r)=>Fe(e)(t,n,r),Ye=/^[cC][0-9a-z]{6,}$/,Xe=/^[0-9a-z]+$/,Ze=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Qe=/^[0-9a-vA-V]{20}$/,$e=/^[A-Za-z0-9]{27}$/,et=/^[a-zA-Z0-9_-]{21}$/;function tt(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var nt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,rt=/^([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})$/,it=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)$/,at=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ot=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function st(){return new RegExp(ot,`u`)}var ct=/^(?:(?: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])$/,lt=/^(([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}|:))$/,ut=/^((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])$/,dt=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ft=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,pt=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,mt=/^https?$/,ht=/^\+[1-9]\d{6,14}$/,gt=`(?:(?:\\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])))`;function _t(e){return RegExp(`^${e}$`)}var vt=_t(gt);function yt(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}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function bt(e){return RegExp(`^${yt(e)}$`)}function xt(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${yt({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${yt({precision:e.precision})}`:n;return RegExp(`^${gt}T(?:${r})$`)}var St=/^[\s\S]{0,}$/,Ct=/^-?\d+$/,wt=/^-?\d+(?:\.\d+)?$/,Tt=/^(?:true|false)$/i,Et=/^[^A-Z]*$/,Dt=/^[^a-z]*$/,Ot=O(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),kt=e=>{let t=e.value;return!n(t)&&t.length!==void 0},At={number:`number`,bigint:`bigint`,object:`date`},jt=O(`$ZodCheckLessThan`,(e,t)=>{Ot.init(e,t);let n=At[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:At[typeof r.value]??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})}}),Mt=O(`$ZodCheckGreaterThan`,(e,t)=>{Ot.init(e,t);let n=At[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:At[typeof r.value]??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})}}),Nt=O(`$ZodCheckMultipleOf`,(e,t)=>{Ot.init(e,t),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`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):i(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})}}),Pt=O(`$ZodCheckNumberFormat`,(e,t)=>{Ot.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=te[t.format];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})}}),Ft=O(`$ZodCheckMaxLength`,(e,t)=>{var n;Ot.init(e,t),(n=e._zod.def).when??(n.when=kt),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?_e(r):i)<=t.maximum)return;let a=z(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),It=O(`$ZodCheckMinLength`,(e,t)=>{var n;Ot.init(e,t),(n=e._zod.def).when??(n.when=kt),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?_e(r):i)>=t.minimum)return;let a=z(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Lt=O(`$ZodCheckLengthEquals`,(e,t)=>{var n;Ot.init(e,t),(n=e._zod.def).when??(n.when=kt),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?_e(r):i;if(a===t.length)return;let o=z(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Rt=O(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Ot.init(e,t),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=()=>{})}),zt=O(`$ZodCheckRegex`,(e,t)=>{Rt.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})}}),Bt=O(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Et,Rt.init(e,t)}),Vt=O(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Dt,Rt.init(e,t)}),Ht=O(`$ZodCheckIncludes`,(e,t)=>{Ot.init(e,t);let n=r(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),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})}}),Ut=O(`$ZodCheckStartsWith`,(e,t)=>{Ot.init(e,t);let n=RegExp(`^${r(t.prefix)}.*`);t.pattern??=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})}}),Wt=O(`$ZodCheckEndsWith`,(e,t)=>{Ot.init(e,t);let n=RegExp(`.*${r(t.suffix)}$`);t.pattern??=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})}}),Gt=O(`$ZodCheckOverwrite`,(e,t)=>{Ot.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Kt=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
2
|
+
`).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?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
3
|
+
`)}\n};`)(...Object.values(this.closed))}},qt={major:4,minor:6,patch:7},Jt=O(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=qt;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=ge(t),a;for(let o of n){if(o._zod.def.when){if(ve(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new ue;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(ce(t.issues,n,e),i||=ge(t,n))});else{if(t.issues.length===n)continue;ce(t.issues,n,e),i||=ge(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(ge(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new ue;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new ue;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return t(this,`~standard`,Zt(this))},set"~standard"(e){x(this,`~standard`,e)}}),Yt=(e,t)=>e.issues.length?{issues:e.issues.map(e=>a(e,t,oe()))}:{value:e.value};async function Xt(e,t){let n={async:!0};return Yt(await e._zod.run({value:t,issues:[]},n),n)}function Zt(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Yt(r,n)}catch{}return Xt(e,t)},vendor:`zod`,version:1}}var Qt=O(`$ZodString`,(e,t)=>{Jt.init(e,t),e._zod.pattern=t.pattern??St,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}}),$t=O(`$ZodStringFormat`,(e,t)=>{Rt.init(e,t),Qt.init(e,t)}),en=O(`$ZodGUID`,(e,t)=>{t.pattern??=rt,$t.init(e,t)}),tn=O(`$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??=it(e)}else t.pattern??=it();$t.init(e,t)}),nn=O(`$ZodEmail`,(e,t)=>{t.pattern??=at,$t.init(e,t)});function rn(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function an(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?rn(e)||2:on(e,t)}function on(e,t){if(!t.normalize&&t.protocol?.source===mt.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var sn=/[\t\n\r]/g;function cn(e){return e.replace(sn,``)}function ln(e,t){return t.lastIndex=0,t.test(e.hostname)}function un(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var dn=O(`$ZodURL`,(e,t)=>{$t.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=an(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=cn(r);return}t.hostname&&!ln(i,t.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&&!un(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:cn(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),fn=O(`$ZodEmoji`,(e,t)=>{t.pattern??=st(),$t.init(e,t)}),pn=O(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?et:tt(t.length),$t.init(e,t)}),mn=O(`$ZodCUID`,(e,t)=>{t.pattern??=Ye,$t.init(e,t)}),hn=O(`$ZodCUID2`,(e,t)=>{t.pattern??=Xe,$t.init(e,t)}),gn=O(`$ZodULID`,(e,t)=>{t.pattern??=Ze,$t.init(e,t)}),_n=O(`$ZodXID`,(e,t)=>{t.pattern??=Qe,$t.init(e,t)}),vn=O(`$ZodKSUID`,(e,t)=>{t.pattern??=$e,$t.init(e,t)}),yn=O(`$ZodISODateTime`,(e,t)=>{t.pattern??=xt(t),$t.init(e,t)}),bn=O(`$ZodISODate`,(e,t)=>{t.pattern??=vt,$t.init(e,t)}),xn=O(`$ZodISOTime`,(e,t)=>{t.pattern??=bt(t),$t.init(e,t)}),Sn=O(`$ZodISODuration`,(e,t)=>{t.pattern??=nt,$t.init(e,t)}),Cn=O(`$ZodIPv4`,(e,t)=>{t.pattern??=ct,$t.init(e,t)}),wn=/^[0-9a-fA-F:.]+$/;function Tn(e){return wn.test(e)?rn(`http://[${e}]`):!1}var En=O(`$ZodIPv6`,(e,t)=>{t.pattern??=lt,$t.init(e,t),e._zod.check=n=>{Tn(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Dn=O(`$ZodCIDRv4`,(e,t)=>{t.pattern??=ut,$t.init(e,t)});function On(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Tn(n)}var kn=O(`$ZodCIDRv6`,(e,t)=>{t.pattern??=dt,$t.init(e,t),e._zod.check=n=>{On(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function An(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var jn=/^[0-9a-zA-Z+/]*={0,2}$/,Mn=O(`$ZodBase64`,(e,t)=>{t.pattern??=jn,$t.init(e,t),e._zod.check=n=>{An(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Nn=/^[A-Za-z0-9_-]*$/;function Pn(e){if(!Nn.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return An(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Fn=O(`$ZodBase64URL`,(e,t)=>{t.pattern??=Nn,$t.init(e,t),e._zod.check=n=>{Pn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),In=O(`$ZodE164`,(e,t)=>{t.pattern??=ht,$t.init(e,t)});function Ln(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 Rn=O(`$ZodJWT`,(e,t)=>{$t.init(e,t),e._zod.check=n=>{Ln(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),zn=O(`$ZodNumber`,(e,t)=>{Jt.init(e,t),e._zod.pattern=wt,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:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Bn=O(`$ZodNumberFormat`,(e,t)=>{Pt.init(e,t),zn.init(e,t)}),Vn=O(`$ZodBoolean`,(e,t)=>{Jt.init(e,t),e._zod.pattern=Tt,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}}),Hn=O(`$ZodUnknown`,(e,t)=>{Jt.init(e,t),e._zod.parse=e=>e}),Un=O(`$ZodNever`,(e,t)=>{Jt.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Wn(t,n){let r=e(t._zod.def.checks);if(!r.length)return;let i=Math.min(...r.map(e=>e[0])),a=t._zod.parse;t._zod.parse=(r,o)=>{let s=n(r.value);if(s>i&&!o?.skipChecks&&o?.direction!==`backward`){for(let[n,i]of e(t._zod.def.checks))if(s>n&&i._zod.def.when(r)){let e=r.issues.length;return i._zod.check(r),r.issues[e].continue=!1,ce(r.issues,e,t),r}}return a(r,o)}}var Gn=e=>Array.isArray(e)?e.length:-1;function Kn(e,t,n){e.issues.length&&t.issues.push(...le(n,e.issues)),t.value[n]=e.value}var qn=O(`$ZodArray`,(e,t)=>{Jt.init(e,t);let n=fe.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Kn(t,r,e)));else if(Kn(c,r,e),s&&c.issues.length!==0&&ge(c))break}return o.length?Promise.all(o).then(()=>r):r},Wn(e,Gn)});function Jn(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...le(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var Yn=[];function Xn(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Yn,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=c(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Zn(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(ge(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Jn(e,n,i,t,d,f))):Jn(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Qn=O(`$ZodObject`,(e,t)=>{Jt.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=re(()=>Xn(t));A(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||F(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=p,o=t.catchall,s,c=fe.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(ge(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Jn(n,t,e,r,a,o))):Jn(s,t,e,r,a,o)}return o?Zn(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),$n=O(`$ZodObjectJIT`,(e,t)=>{Qn.init(e,t);let n=e._zod.parse,r=re(()=>Xn(t)),i=fe.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Kt([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
4
|
+
let ${e}_ab = false;
|
|
5
|
+
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
6
|
+
const iss = ${e}.issues[i];
|
|
7
|
+
iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
|
|
8
|
+
payload.issues.push(iss);
|
|
9
|
+
if (iss.continue !== true) ${e}_ab = true;
|
|
10
|
+
}
|
|
11
|
+
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
12
|
+
payload.value = newResult;
|
|
13
|
+
return payload;
|
|
14
|
+
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:y(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
15
|
+
const ${n}_present = ${i};
|
|
16
|
+
if (!${n}.issues.length || ${n}_present) {
|
|
17
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (${e}) {
|
|
21
|
+
newResult[${r}] = ${n}.value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
`)}else f?(o.write(`
|
|
26
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
27
|
+
}
|
|
28
|
+
`),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
|
|
29
|
+
if (${n}.value !== undefined || ${i}) {
|
|
30
|
+
newResult[${r}] = ${n}.value;
|
|
31
|
+
}
|
|
32
|
+
`)):o.write(`
|
|
33
|
+
const ${n}_present = ${i};
|
|
34
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
35
|
+
}
|
|
36
|
+
if (!${n}_present && !${n}.issues.length) {
|
|
37
|
+
payload.issues.push({
|
|
38
|
+
code: "invalid_type",
|
|
39
|
+
expected: "nonoptional",
|
|
40
|
+
input: undefined,
|
|
41
|
+
path: [${r}]
|
|
42
|
+
});
|
|
43
|
+
if (ctx && ctx.abortEarly) {
|
|
44
|
+
payload.value = newResult;
|
|
45
|
+
return payload;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (${n}_present) {
|
|
50
|
+
newResult[${r}] = ${n}.value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=p,c=!fe.jitless,l=c&&N.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Zn([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function er(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=>!ge(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=>a(e,r,oe())))}),t)}var tr=O(`$ZodUnion`,(e,t)=>{Jt.init(e,t),A(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),A(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),A(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),A(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>I(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=>er(t,r,e,i)):er(o,r,e,i)}}),nr=O(`$ZodIntersection`,(e,t)=>{Jt.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])=>ir(e,t,n)):ir(e,i,a)}});function rr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(m(e)&&m(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=rr(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=rr(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 ir(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=rr(t.value,n.value);if(!c.valid){if(ge(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var ar=O(`$ZodRecord`,(e,t)=>{Jt.init(e,t);let n=fe.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let o=r.value;if(!m(o))return r.issues.push({expected:`record`,code:`invalid_type`,input:o,inst:e}),r;let s=[],c=t.keyType._zod.values;if(c&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let l=new Set;for(let n of c)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(l.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let c=t.keyType._zod.run({value:n,issues:[]},i);if(c instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(c.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:c.issues.map(e=>a(e,i,oe())),input:n,path:[n],inst:e});continue}let u=c.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:o[n],issues:[]},i);d instanceof Promise?s.push(d.then(e=>{e.issues.length&&r.issues.push(...le(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...le(n,d.issues)),r.value[u]=d.value)}let u;for(let e in o)if(!l.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=o[e]}else u??=[],u.push(e)}u&&u.length>0&&r.issues.push({code:`unrecognized_keys`,input:o,inst:e,keys:u,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let l;for(let n of Reflect.ownKeys(o)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(o,n))continue;let u=t.keyType._zod.run({value:n,issues:[]},i);if(u instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&wt.test(n)&&u.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(u=e)}if(u.issues.length){t.mode===`loose`?r.value[n]=o[n]:c?(l??=[],l.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:u.issues.map(e=>a(e,i,oe())),input:n,path:[n],inst:e});continue}let d=u.value;if(d===`__proto__`)continue;let f=t.valueType._zod.run({value:o[n],issues:[]},i);f instanceof Promise?s.push(f.then(e=>{e.issues.length&&r.issues.push(...le(n,e.issues)),r.value[d]=e.value})):(f.issues.length&&r.issues.push(...le(n,f.issues)),r.value[d]=f.value)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:o,inst:e,keys:l,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}}),or=O(`$ZodEnum`,(e,t)=>{Jt.init(e,t);let n=h(t.entries),i=new Set(n);e._zod.values=i,A(e,`pattern`,e=>{let t=h(e.def.entries).filter(e=>u.has(typeof e));return RegExp(t.length?`^(${t.map(e=>r(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,r)=>{let a=t.value;return i.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),sr=O(`$ZodTransform`,(e,t)=>{Jt.init(e,t),e._zod.optin=`optional`,fe.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new R(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));if(i instanceof Promise)throw new ue;return n.value=i,n}});function cr(e,t){return e.value=t.issues.length?void 0:t.value,e}var lr=O(`$ZodOptional`,(e,t)=>{Jt.init(e,t),A(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,A(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),A(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${I(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>cr(e,t)):cr(e,r)}return t.innerType._zod.run(e,n)}}),ur=O(`$ZodExactOptional`,(e,t)=>{lr.init(e,t),A(e,`values`,e=>e.def.innerType._zod.values),A(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),dr=O(`$ZodNullable`,(e,t)=>{Jt.init(e,t),A(e,`optin`,e=>e.def.innerType._zod.optin),A(e,`optout`,e=>e.def.innerType._zod.optout),A(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${I(t.source)}|null)$`):void 0}),A(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),fr=O(`$ZodDefault`,(e,t)=>{Jt.init(e,t),e._zod.optin=`defaulted`,A(e,`values`,e=>e.def.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=>pr(e,t)):pr(r,t)}});function pr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var mr=O(`$ZodPrefault`,(e,t)=>{Jt.init(e,t),e._zod.optin=`defaulted`,A(e,`values`,e=>e.def.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))}),hr=O(`$ZodNonOptional`,(e,t)=>{Jt.init(e,t),A(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].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=>gr(t,e)):gr(i,e)}});function gr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function _r(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>a(e,r,oe()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var vr=O(`$ZodCatch`,(e,t)=>{Jt.init(e,t),A(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),A(e,`optout`,e=>e.def.innerType._zod.optout),A(e,`values`,e=>e.def.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({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>_r(e,r,t,n)):_r(e,r,t,n)}}),yr=O(`$ZodPipe`,(e,t)=>{Jt.init(e,t),A(e,`values`,e=>e.def.in._zod.values),A(e,`optin`,e=>e.def.in._zod.optin),A(e,`optout`,e=>e.def.out._zod.optout),A(e,`propValues`,e=>e.def.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=>br(e,t.in,n)):br(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>br(e,t.out,n)):br(r,t.out,n)}});function br(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var xr=O(`$ZodReadonly`,(e,t)=>{Jt.init(e,t),A(e,`propValues`,e=>e.def.innerType._zod.propValues),A(e,`values`,e=>e.def.innerType._zod.values),A(e,`optin`,e=>e.def.innerType?._zod?.optin),A(e,`optout`,e=>e.def.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(Sr):Sr(r)}});function Sr(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Cr=O(`$ZodCustom`,(e,t)=>{Ot.init(e,t),Jt.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=>wr(t,n,r,e));wr(i,n,r,e)}});function wr(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(g(e))}}var Tr=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Er=`~memo`,Dr=[];function Or(e){return typeof e==`object`&&!!e}function kr(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Ar=new WeakMap,jr=0,Mr=1,Nr=2;function Pr(e,t,n){let r=Ar.get(e);if(r!==void 0)return r?Nr:jr;if(t.has(e))return Nr;t.add(e);let i=jr,a=e=>{if(i!==Nr&&e?._zod){let r=Pr(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=jr;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?Mr:o.value?._zod?Pr(o.value,t,n):jr;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=T(c);s(e?o(e,!0):Mr),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Pr(r,t,!1):Mr);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Fr(e,i)}function Fr(e,t){return t!==Mr&&Ar.set(e,t===Nr),t}function Ir(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var Lr,Rr=[],zr={alloc(e,t,n){let r=Lr;if(!r)return n;Lr=void 0;let i={value:n,issues:null};return r.set(t.value,i),Rr.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Vr(n,e.value))throw new Tr;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Pr(e,new Set,!1);if(i===jr)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===Nr||r?n=!0:r=!0}let l=s.value;if(!Or(l))return t(s,c);let u=c[Er];u||(u={buckets:new WeakMap,backEdges:void 0},c[Er]=u);let d;i===c?d=a:(d=Ir(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...kr(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;Lr=d;let p=Rr.length,m=t(s,c);Lr=void 0;let h=Rr.length>p?Rr.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?kr(e.issues):Dr),e)):(h&&(h.issues=m.issues.length?kr(m.issues):Dr),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Br(){return zr}function Vr(e,t){let n=e[Er]?.backEdges;return n!==void 0&&Or(t)&&n.has(t)}var Hr=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(C(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${he(e.values[0])}`:`Invalid option: expected one of ${o(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${o(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Ur(){return{localeError:Hr()}}var Wr,Gr=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 Kr(){return new Gr}(Wr=globalThis).__zod_globalRegistry??(Wr.__zod_globalRegistry=Kr());var qr=globalThis.__zod_globalRegistry;function Jr(e){return e.checks&&=[...e.checks],e}function Yr(e,t){return new e(Jr({type:`string`,...B(t)}))}function Xr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...B(t)})}function Zr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...B(t)})}function Qr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...B(t)})}function $r(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...B(t)})}function ei(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...B(t)})}function ti(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...B(t)})}function ni(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...B(t)})}function ri(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...B(t)})}function ii(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...B(t)})}function ai(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...B(t)})}function oi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...B(t)})}function si(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...B(t)})}function ci(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...B(t)})}function li(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...B(t)})}function ui(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...B(t)})}function di(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...B(t)})}function fi(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...B(t)})}function pi(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...B(t)})}function mi(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...B(t)})}function hi(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...B(t)})}function gi(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...B(t)})}function _i(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...B(t)})}function vi(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...B(t)})}function yi(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...B(t)})}function bi(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...B(t)})}function xi(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...B(t)})}function Si(e,t){return new e(Jr({type:`number`,checks:[],...B(t)}))}function Ci(e,t){return new e(Jr({type:`number`,coerce:!0,checks:[],...B(t)}))}function wi(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...B(t)})}function Ti(e,t){return new e({type:`boolean`,...B(t)})}function Ei(e){return new e({type:`unknown`})}function Di(e,t){return new e({type:`never`,...B(t)})}function Oi(e,t){return new jt({check:`less_than`,...B(t),value:e,inclusive:!1})}function ki(e,t){return new jt({check:`less_than`,...B(t),value:e,inclusive:!0})}function Ai(e,t){return new Mt({check:`greater_than`,...B(t),value:e,inclusive:!1})}function ji(e,t){return new Mt({check:`greater_than`,...B(t),value:e,inclusive:!0})}function Mi(e,t){return new Nt({check:`multiple_of`,...B(t),value:e})}function Ni(e,t){return new Ft({check:`max_length`,...B(t),maximum:e})}function Pi(e,t){return new It({check:`min_length`,...B(t),minimum:e})}function Fi(e,t){return new Lt({check:`length_equals`,...B(t),length:e})}function Ii(e,t){return new zt({check:`string_format`,format:`regex`,...B(t),pattern:e})}function Li(e){return new Bt({check:`string_format`,format:`lowercase`,...B(e)})}function Ri(e){return new Vt({check:`string_format`,format:`uppercase`,...B(e)})}function zi(e,t){return new Ht({check:`string_format`,format:`includes`,...B(t),includes:e})}function Bi(e,t){return new Ut({check:`string_format`,format:`starts_with`,...B(t),prefix:e})}function Vi(e,t){return new Wt({check:`string_format`,format:`ends_with`,...B(t),suffix:e})}function Hi(e){return new Gt({check:`overwrite`,tx:e})}function Ui(e){return Hi(t=>t.normalize(e))}function Wi(){return Hi(e=>e.trim())}function Gi(){return Hi(e=>e.toLowerCase())}function Ki(){return Hi(e=>e.toUpperCase())}function qi(){return Hi(e=>P(e))}function Ji(e,t,n){return new e({type:`array`,element:t,...B(n)})}function Yi(e,t,n){let r=B(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function Xi(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...B(n)})}function Zi(e,t){let n=Qi(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(g(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(g(r))}},e(t.value,t)),t);return n}function Qi(e,t){let n=new Ot({check:`custom`,...B(t)});return n._zod.check=e,n}function $i(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&F(e,t,n[t]);return e}function ea(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??qr,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function ta(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function na(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),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;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,na(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&$i(o.schema,c),t.io===`input`&&fa(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 ra(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function ia(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;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}/${ra(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+ra(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>
|
|
54
|
+
|
|
55
|
+
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);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function aa(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;aa(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var oa=new Set([`type`,`properties`,`required`,`additionalProperties`]),sa=[`oneOf`,`anyOf`];function ca(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function la(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!oa.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??ca(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}let i=e.length===1?e[0]:la(e)??{allOf:e};F(n,r,i)}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=ca(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function ua(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of oa)if(t in e)return;let n=t.filter(e=>sa.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=la(t);else{let e=n[0],i=sa.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>la([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,$i(e,r))}function da(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)):$i(i,s),$i(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??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())aa(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])ua(e)}}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)}$i(i,n.defId?n.schema: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??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,F(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),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:ma(t,`input`,e.processors),output:ma(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function fa(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 fa(r.element,n);if(r.type===`set`)return fa(r.valueType,n);if(r.type===`lazy`)return fa(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`||r.type===`catch`)return fa(r.innerType,n);if(r.type===`intersection`)return fa(r.left,n)||fa(r.right,n);if(r.type===`record`||r.type===`map`)return fa(r.keyType,n)||fa(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:fa(r.in,n)||fa(r.out,n);if(r.type===`object`){for(let e in r.shape)if(fa(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(fa(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(fa(e,n))return!0;return!!(r.rest&&fa(r.rest,n))}return!1}var pa=(e,t={})=>n=>{let r=ea({...n,processors:t});return na(e,r),ia(r,e),da(r,e)},ma=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ea({...i??{},target:a,io:t,processors:n});return na(e,o),ia(o,e),da(o,e)},ha=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},ga=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},_a=(e,t)=>{ha(e,`minimum`,t),ga(e,`maximum`,t)},va=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},ya=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},ba=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},xa=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Sa=(e,t)=>ha(e,`minimum`,t.minimum),Ca=(e,t)=>ga(e,`maximum`,t.maximum),wa=e=>(t,n)=>{xa(t,n.format);let[r,i]=e[n.format];ha(t,`minimum`,r),ga(t,`maximum`,i)},Ta={greater_than:(e,t)=>ha(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>ga(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>va(e,t.value),number_format:wa(te),bigint_format:wa(j),min_length:Sa,max_length:Ca,length_equals:(e,t)=>_a(e,t.length),min_size:Sa,max_size:Ca,size_equals:(e,t)=>_a(e,t.size),string_format:(e,t)=>{xa(e,t.format),t.pattern&&ya(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>ba(e,t.mime)};function Ea(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Ta[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&ha(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&ha(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&ga(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&ga(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&va(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&ba(t,i.mime);for(let e of i.patterns??[])ya(t,e);return t}var Da={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Oa=new Map([[jn,ft],[Nn,pt]]),ka=e=>Oa.get(e)??e,Aa=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Ea(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Da[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(ka);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}))])}},ja=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Ea(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):ta(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Ma=(e,t,n,r)=>{n.type=`boolean`},Na=(e,t,n,r)=>{n.not={}},Pa=(e,t,n,r)=>{let i=e._zod.def,a=h(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Fa=(e,t,n,r)=>{ta(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Ia=(e,t,n,r)=>{ta(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},La=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Ea(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=na(a.element,t,{...r,path:[...r.path,`items`]})};function Ra(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Ra(t.out):t.type===`catch`?Ra(t.innerType):e._zod.optin}var za=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&ta(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)F(i.properties,e,na(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Ra(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=na(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ba=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>na(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Va=(e,t,n,r)=>{let i=e._zod.def,a=na(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=na(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Ha(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Ha(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Ha(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?wt:Ct).source)),p}var Ua=new WeakMap;function Wa(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of Ua.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Ha(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var Ga=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Ea(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=na(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)F(i.patternProperties,ka(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=na(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Ua.get(t);n||(n=[],Ua.set(t,n),t.deferred.push(()=>Wa(t))),n.push(e)}i.additionalProperties=na(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Ra(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},Ka=(e,t,n,r)=>{let i=e._zod.def,a=na(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`}]},qa=(e,t,n,r)=>{let i=e._zod.def;na(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ja=Symbol();function Ya(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(ta(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Ja):JSON.parse(o)}var Xa=(e,t,n,r)=>{let i=e._zod.def;na(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Ya(i.defaultValue,e,t,n,r);o!==Ja&&(n.default=o)},Za=(e,t,n,r)=>{let i=e._zod.def;na(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Ya(i.defaultValue,e,t,n,r);o!==Ja&&(n._prefault=o)},Qa=(e,t,n,r)=>{let i=e._zod.def;na(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{ta(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},$a=(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;na(o,t,r);let s=t.seen.get(e);s.ref=o},eo=(e,t,n,r)=>{let i=e._zod.def;na(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},to=(e,t,n,r)=>{let i=e._zod.def;na(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},no=new WeakSet([Object.prototype,Error.prototype]);function ro(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var io=O(`ZodError`,(e,t)=>{Ee.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);no.has(n)||(no.add(n),ro(n,`format`,e=>t=>ke(e,t)),ro(n,`flatten`,e=>t=>Oe(e,t)),ro(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,l,2)}),ro(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,l,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),ao=je(io),oo=Me(io),so=Ne(io),co=Fe(io),lo=Ve(io),uo=He(io),fo=Ue(io),po=We(io),mo=Ge(io),ho=Ke(io),go=qe(io),_o=Je(io);function vo(){fe.localeError||oe(Ur())}function yo(){fe.memoizer||oe({memoizer:Br()})}var bo=O(`ZodType`,(e,t)=>(vo(),Jt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(v(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 D(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Bs(e,t))},superRefine(e,t){return this.check(Vs(e,t))},overwrite(e){return this.check(Hi(e))},optional(){return xs(this)},exactOptional(){return Cs(this)},nullable(){return Ts(this)},nullish(){return xs(Ts(this))},nonoptional(e){return js(this,e)},array(){return as(this)},or(e){return ds([this,e])},and(e){return ps(this,e)},transform(e){return Fs(this,ys(e))},default(e){return Ds(this,e)},prefault(e){return ks(this,e)},catch(e){return Ns(this,e)},pipe(e){return Fs(this,e)},readonly(){return Ls(this)},describe(e){let t=this.clone();return qr.add(t,{description:e}),t},meta(...e){if(e.length===0)return qr.get(this);let t=this.clone();return qr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return t(this,`~standard`,{...Zt(this),jsonSchema:{input:ma(this,`input`),output:ma(this,`output`)}})},set"~standard"(e){x(this,`~standard`,e)},parse:function e(t,n){return ao(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await oo(this,t,n,{callee:e})},safeParse(e,t){return so(this,e,t)},async safeParseAsync(e,t){return co(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){x(this,`spa`,e)},validate(e,t){return Re(this,e,t)},validateAsync(e,t){return Be(this,e,t)},encode:function e(t,n){return lo(this,t,n,{callee:e})},decode:function e(t,n){return uo(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await fo(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await po(this,t,n,{callee:e})},safeEncode(e,t){return mo(this,e,t)},safeDecode(e,t){return ho(this,e,t)},async safeEncodeAsync(e,t){return go(this,e,t)},async safeDecodeAsync(e,t){return _o(this,e,t)},toJSONSchema(e){return pa(this,{})(e)},get description(){return qr.get(this)?.description},get _def(){return this._zod.def}}),xo=O(`_ZodString`,(e,t)=>{Qt.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Aa(e,t,n,r)},ye({format:e=>Ea(e).format??null,minLength:e=>Ea(e).minimum??null,maxLength:e=>Ea(e).maximum??null},{regex(...e){return this.check(Ii(...e))},includes(...e){return this.check(zi(...e))},startsWith(...e){return this.check(Bi(...e))},endsWith(...e){return this.check(Vi(...e))},min(...e){return this.check(Pi(...e))},max(...e){return this.check(Ni(...e))},length(...e){return this.check(Fi(...e))},nonempty(...e){return this.check(Pi(1,...e))},lowercase(e){return this.check(Li(e))},uppercase(e){return this.check(Ri(e))},trim(){return this.check(Wi())},normalize(...e){return this.check(Ui(...e))},toLowerCase(){return this.check(Gi())},toUpperCase(){return this.check(Ki())},slugify(){return this.check(qi())}})),So=O(`ZodString`,(e,t)=>{Qt.init(e,t),xo.init(e,t)},{email(e){return this.check(Xr(ko,e))},url(e){return this.check(ni(Mo,e))},jwt(e){return this.check(_i(qo,e))},emoji(e){return this.check(ri(No,e))},guid(e){return this.check(Zr(Ao,e))},uuid(e){return this.check(Qr(jo,e))},uuidv4(e){return this.check($r(jo,e))},uuidv6(e){return this.check(ei(jo,e))},uuidv7(e){return this.check(ti(jo,e))},nanoid(e){return this.check(ii(Po,e))},cuid(e){return this.check(ai(Fo,e))},cuid2(e){return this.check(oi(Io,e))},ulid(e){return this.check(si(Lo,e))},base64(e){return this.check(mi(Wo,e))},base64url(e){return this.check(hi(Go,e))},xid(e){return this.check(ci(Ro,e))},ksuid(e){return this.check(li(zo,e))},ipv4(e){return this.check(ui(Bo,e))},ipv6(e){return this.check(di(Vo,e))},cidrv4(e){return this.check(fi(Ho,e))},cidrv6(e){return this.check(pi(Uo,e))},e164(e){return this.check(gi(Ko,e))},datetime(e){return this.check(vi(To,e))},date(e){return this.check(yi(Eo,e))},time(e){return this.check(bi(Do,e))},duration(e){return this.check(xi(Oo,e))}});function Co(e){return Yr(So,e)}var wo=O(`ZodStringFormat`,(e,t)=>{$t.init(e,t),xo.init(e,t)}),To=O(`ZodISODateTime`,(e,t)=>{yn.init(e,t),wo.init(e,t)}),Eo=O(`ZodISODate`,(e,t)=>{bn.init(e,t),wo.init(e,t)}),Do=O(`ZodISOTime`,(e,t)=>{xn.init(e,t),wo.init(e,t)}),Oo=O(`ZodISODuration`,(e,t)=>{Sn.init(e,t),wo.init(e,t)}),ko=O(`ZodEmail`,(e,t)=>{nn.init(e,t),wo.init(e,t)}),Ao=O(`ZodGUID`,(e,t)=>{en.init(e,t),wo.init(e,t)}),jo=O(`ZodUUID`,(e,t)=>{tn.init(e,t),wo.init(e,t)}),Mo=O(`ZodURL`,(e,t)=>{dn.init(e,t),wo.init(e,t)}),No=O(`ZodEmoji`,(e,t)=>{fn.init(e,t),wo.init(e,t)}),Po=O(`ZodNanoID`,(e,t)=>{pn.init(e,t),wo.init(e,t)}),Fo=O(`ZodCUID`,(e,t)=>{mn.init(e,t),wo.init(e,t)}),Io=O(`ZodCUID2`,(e,t)=>{hn.init(e,t),wo.init(e,t)}),Lo=O(`ZodULID`,(e,t)=>{gn.init(e,t),wo.init(e,t)}),Ro=O(`ZodXID`,(e,t)=>{_n.init(e,t),wo.init(e,t)}),zo=O(`ZodKSUID`,(e,t)=>{vn.init(e,t),wo.init(e,t)}),Bo=O(`ZodIPv4`,(e,t)=>{Cn.init(e,t),wo.init(e,t)}),Vo=O(`ZodIPv6`,(e,t)=>{En.init(e,t),wo.init(e,t)}),Ho=O(`ZodCIDRv4`,(e,t)=>{Dn.init(e,t),wo.init(e,t)}),Uo=O(`ZodCIDRv6`,(e,t)=>{kn.init(e,t),wo.init(e,t)}),Wo=O(`ZodBase64`,(e,t)=>{Mn.init(e,t),wo.init(e,t)}),Go=O(`ZodBase64URL`,(e,t)=>{Fn.init(e,t),wo.init(e,t)}),Ko=O(`ZodE164`,(e,t)=>{In.init(e,t),wo.init(e,t)}),qo=O(`ZodJWT`,(e,t)=>{Rn.init(e,t),wo.init(e,t)}),Jo=O(`ZodNumber`,(e,t)=>{zn.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ja(e,t,n,r),e.isFinite=!0},ye({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Ea(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Ea(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Ea(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Ea(e).format??null},{gt(e,t){return this.check(Ai(e,t))},gte(e,t){return this.check(ji(e,t))},min(e,t){return this.check(ji(e,t))},lt(e,t){return this.check(Oi(e,t))},lte(e,t){return this.check(ki(e,t))},max(e,t){return this.check(ki(e,t))},int(e){return this.check(Zo(e))},safe(e){return this.check(Zo(e))},positive(e){return this.check(Ai(0,e))},nonnegative(e){return this.check(ji(0,e))},negative(e){return this.check(Oi(0,e))},nonpositive(e){return this.check(ki(0,e))},multipleOf(e,t){return this.check(Mi(e,t))},step(e,t){return this.check(Mi(e,t))},finite(){return this}}));function Yo(e){return Si(Jo,e)}var Xo=O(`ZodNumberFormat`,(e,t)=>{Bn.init(e,t),Jo.init(e,t)});function Zo(e){return wi(Xo,e)}var Qo=O(`ZodBoolean`,(e,t)=>{Vn.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ma(e,t,n,r)});function $o(e){return Ti(Qo,e)}var es=O(`ZodUnknown`,(e,t)=>{Hn.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ts(){return Ei(es)}var ns=O(`ZodNever`,(e,t)=>{Un.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Na(e,t,n,r)});function rs(e){return Di(ns,e)}var is=O(`ZodArray`,(e,t)=>{yo(),qn.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>La(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Pi(e,t))},nonempty(e){return this.check(Pi(1,e))},max(e,t){return this.check(Ni(e,t))},length(e,t){return this.check(Fi(e,t))},unwrap(){return this.element}});function as(e,t){return Ji(is,e,t)}var os=O(`ZodObject`,(e,t)=>{yo(),$n.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>za(e,t,n,r),ee(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return _s(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(v(this._zod.def,{catchall:e}))},passthrough(){return this.clone(v(this._zod.def,{catchall:ts()}))},loose(){return this.clone(v(this._zod.def,{catchall:ts()}))},strict(){return this.clone(v(this._zod.def,{catchall:rs()}))},strip(){return this.clone(v(this._zod.def,{catchall:void 0}))},extend(e){return b(this,e)},safeExtend(e){return E(this,e)},merge(e){return f(this,e)},pick(e){return d(this,e)},omit(e){return S(this,e)},partial(...e){return s(bs,this,e[0])},exactPartial(...e){return s(Ss,this,e[0],`exactPartial`)},required(...e){return w(As,this,e[0])}});function ss(e,t){return new os({type:`object`,shape:e??{},...B(t)})}function cs(e,t){return new os({type:`object`,shape:e,catchall:rs(),...B(t)})}function ls(e,t){return new os({type:`object`,shape:e,catchall:ts(),...B(t)})}var us=O(`ZodUnion`,(e,t)=>{tr.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ba(e,t,n,r),e.options=t.options});function ds(e,t){return new us({type:`union`,options:e,...B(t)})}var fs=O(`ZodIntersection`,(e,t)=>{nr.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Va(e,t,n,r)});function ps(e,t){return new fs({type:`intersection`,left:e,right:t})}var ms=O(`ZodRecord`,(e,t)=>{yo(),ar.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ga(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function hs(e,t,n){return!t||!t._zod?new ms({type:`record`,keyType:Co(),valueType:e,...B(t)}):new ms({type:`record`,keyType:e,valueType:t,...B(n)})}var gs=O(`ZodEnum`,(e,t)=>{or.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pa(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];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 gs({...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 gs({...t,checks:[],...B(r),entries:i})}});function _s(e,t){return new gs({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...B(t)})}var vs=O(`ZodTransform`,(e,t)=>{yo(),sr.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ia(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new R(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(g(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(g(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ys(e){return new vs({type:`transform`,transform:e})}var bs=O(`ZodOptional`,(e,t)=>{lr.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>to(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xs(e){return new bs({type:`optional`,innerType:e})}var Ss=O(`ZodExactOptional`,(e,t)=>{ur.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>to(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Cs(e){return new Ss({type:`optional`,innerType:e})}var ws=O(`ZodNullable`,(e,t)=>{dr.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ka(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ts(e){return new ws({type:`nullable`,innerType:e})}var Es=O(`ZodDefault`,(e,t)=>{fr.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ds(e,t){return new Es({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():_(t)}})}var Os=O(`ZodPrefault`,(e,t)=>{mr.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Za(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ks(e,t){return new Os({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():_(t)}})}var As=O(`ZodNonOptional`,(e,t)=>{hr.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function js(e,t){return new As({type:`nonoptional`,innerType:e,...B(t)})}var Ms=O(`ZodCatch`,(e,t)=>{vr.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ns(e,t){return new Ms({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:be(t)})}var Ps=O(`ZodPipe`,(e,t)=>{yr.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$a(e,t,n,r),e.in=t.in,e.out=t.out});function Fs(e,t){return new Ps({type:`pipe`,in:e,out:t})}var Is=O(`ZodReadonly`,(e,t)=>{xr.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ls(e){return new Is({type:`readonly`,innerType:e})}var Rs=O(`ZodCustom`,(e,t)=>{Cr.init(e,t),bo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fa(e,t,n,r)});function zs(e,t){return Yi(Rs,e??(()=>!0),t)}function Bs(e,t={}){return Xi(Rs,e,t)}function Vs(e,t){return Zi(e,t)}function Hs(e){return vi(To,e)}function Us(e){return Ci(Jo,e)}var V=ne(se(),1),Ws={};function Gs(e,t){let n=V.useRef(Ws);return n.current===Ws&&(n.current=e(t)),n}var Ks=[],qs=void 0;function Js(){return qs}function Ys(e){Ks.push(e)}function Xs(e){let t=(t,n)=>{let r=Gs(Qs).current,i;try{qs=r;for(let e of Ks)e.before(r);i=e(t,n);for(let e of Ks)e.after(r);r.didInitialize=!0}finally{qs=void 0}return i};return t.displayName=e.displayName||e.name,t}function Zs(e){return V.forwardRef(Xs(e))}function Qs(){return{didInitialize:!1}}function $s(){}var ec=Object.freeze([]),tc=Object.freeze({}),H=typeof document<`u`?V.useLayoutEffect:()=>{};function nc(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var rc=nc(`https://base-ui.com/production-error`,`Base UI`),ic=V.createContext(void 0);function ac(e){let t=V.useContext(ic);if(t===void 0&&!e)throw Error(rc(72));return t}function oc(e){V.useEffect(e,ec)}var sc=0,cc=class e{static create(){return new e}currentId=sc;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=sc,t()},e)}isStarted(){return this.currentId!==sc}clear=()=>{this.currentId!==sc&&(clearTimeout(this.currentId),this.currentId=sc)};disposeEffect=()=>this.clear};function lc(){let e=Gs(cc.create).current;return oc(e.disposeEffect),e}function uc(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:dc,platform:fc,maxTouchPoints:pc}=uc(),mc=dc.toLowerCase(),hc=fc.toLowerCase(),gc=/^i(os$|p)/.test(hc)||hc===`macintel`&&pc>1,_c=`android`,vc=hc===_c||mc.includes(_c),yc=!gc&&hc.startsWith(`mac`);hc.startsWith(`win`),!vc&&/^(linux|chrome os)/.test(hc);var bc=yc||gc,xc=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`),Sc=!xc&&mc.includes(`firefox`);!xc&&mc.includes(`chrom`);var Cc=bc,wc=/jsdom|happydom/.test(mc);function Tc(e){e.preventDefault(),e.stopPropagation()}function Ec(e){return`nativeEvent`in e}function Dc(e){return e.pointerType===``&&e.isTrusted?!0:vc&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function Oc(e){return wc?!1:!vc&&e.width===0&&e.height===0||e.type===`pointerdown`&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`&&(vc||e.buttons===0)||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function kc(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function Ac(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function jc(){return typeof window<`u`}function Mc(e){return Fc(e)?(e.nodeName||``).toLowerCase():`#document`}function Nc(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Pc(e){return((Fc(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Fc(e){return jc()?e instanceof Node||e instanceof Nc(e).Node:!1}function Ic(e){return jc()?e instanceof Element||e instanceof Nc(e).Element:!1}function Lc(e){return jc()?e instanceof HTMLElement||e instanceof Nc(e).HTMLElement:!1}function Rc(e){return!jc()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Nc(e).ShadowRoot}function zc(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Xc(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Bc(e){return/^(table|td|th)$/.test(Mc(e))}function Vc(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Hc=/transform|translate|scale|rotate|perspective|filter/,Uc=/paint|layout|strict|content/,Wc=e=>!!e&&e!==`none`,Gc;function Kc(e){let t=Ic(e)?Xc(e):e;return Wc(t.transform)||Wc(t.translate)||Wc(t.scale)||Wc(t.rotate)||Wc(t.perspective)||!Jc()&&(Wc(t.backdropFilter)||Wc(t.filter))||Hc.test(t.willChange||``)||Uc.test(t.contain||``)}function qc(e){let t=Qc(e);for(;Lc(t)&&!Yc(t);){if(Kc(t))return t;if(Vc(t))return null;t=Qc(t)}return null}function Jc(){return Gc??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Gc}function Yc(e){return/^(html|body|#document)$/.test(Mc(e))}function Xc(e){return Nc(e).getComputedStyle(e)}function Zc(e){return Ic(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Qc(e){if(Mc(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Rc(e)&&e.host||Pc(e);return Rc(t)?t.host:t}function $c(e){let t=Qc(e);return Yc(t)?(e.ownerDocument||e).body:Lc(t)&&zc(t)?t:$c(t)}function el(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=$c(e),i=r===e.ownerDocument?.body,a=Nc(r);if(i){let e=tl(a);return t.concat(a,a.visualViewport||[],zc(r)?r:[],e&&n?el(e):[])}return t.concat(r,el(r,[],n))}function tl(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function nl(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function U(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Rc(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function rl(e,t){let n=e;for(;n;){if(Ic(n)&&n.matches(t))return n;n=n.assignedSlot??n.parentNode??(Rc(n)?n.host:null)}return null}function il(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var al=`data-base-ui-focusable`,ol=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,sl=`ArrowLeft`,cl=`ArrowRight`,ll=`ArrowUp`,ul=`ArrowDown`,dl=`data-starting-style`,fl=`data-ending-style`,pl={[dl]:``},ml={[fl]:``},hl={transitionStatus(e){return e===`starting`?pl:e===`ending`?ml:null}},gl=`data-open`,_l=`data-closed`,vl=`data-anchor-hidden`,yl=`data-popup-open`,bl=`data-pressed`,xl={[yl]:``},Sl={[yl]:``,[bl]:``},Cl={[gl]:``},wl={[_l]:``},Tl={[vl]:``},El={open(e){return e?xl:null}},Dl={open(e){return e?Sl:null}},Ol={open(e){return e?Cl:wl},anchorHidden(e){return e?Tl:null}},kl={...Ol,...hl},Al=`data-trigger-disabled`;function jl(e,t){if(!Ic(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(Al);for(let[,e]of t.entries())if(U(e,n))return!e.hasAttribute(Al);return!1}function Ml(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function Nl(e){return e.matches(`html,body`)}function Pl(e){return Lc(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function Fl(e){return rl(e,`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${ol}`)!=null}function Il(e){return e?e.getAttribute(`role`)===`combobox`&&Pl(e):!1}function Ll(e){if(!e||wc)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function Rl(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function zl(e,t){return t!=null&&!kc(t)?0:typeof e==`function`?e():e}function Bl(e,t,n){let r=zl(e,n);return typeof r==`number`?r:r?.[t]}function Vl(e){return typeof e==`function`?e():e}function Hl(e,t){return t||e===`click`||e===`mousedown`}function Ul(e){return e?.includes(`mouse`)&&e!==`mousedown`}function W(e,t,n,r){let i=!1,a=!1,o=r??tc;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function Wl(e,t,n){let r=n??tc;return{reason:e,event:t??new Event(`base-ui`),...r}}var Gl=`none`,Kl=`trigger-press`,ql=`trigger-hover`,Jl=`trigger-focus`,Yl=`outside-press`,Xl=`item-press`,Zl=`close-press`,Ql=`input-change`,$l=`input-clear`,eu=`input-press`,tu=`focus-out`,nu=`escape-key`,ru=`list-navigation`,iu=`keyboard`,au=`pointer`,ou=`cancel-open`,su=`sibling-open`,cu=`disabled`,lu=`imperative-action`,uu=`window-resize`,G=de(),du=V.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new cc,currentIdRef:{current:null},currentContextRef:{current:null}});function fu(e,t){e.current=t.current}function pu(e){let{children:t,delay:n,timeoutMs:r=0}=e,i=V.useRef(n),a=V.useRef(n),o=V.useRef(null),s=V.useRef(null),c=lc();return H(()=>{a.current=n,o.current?i.current={open:Bl(i.current,`open`),close:Bl(n,`close`)}:i.current=n},[n,o,i,a]),(0,G.jsx)(du.Provider,{value:V.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:a,currentIdRef:o,timeoutMs:r,currentContextRef:s,timeout:c}),[r,c]),children:t})}function mu(e,t={open:!1}){let{open:n}=t,r=e.useState(`floatingId`),{currentIdRef:i,delayRef:a,timeoutMs:o,initialDelayRef:s,currentContextRef:c,hasProvider:l,timeout:u}=V.useContext(du),[d,f]=V.useState(!1),p=V.useRef(n);return H(()=>{p.current=n},[n]),H(()=>{function t(){c.current?.setIsInstantPhase(!1),i.current=null,c.current=null,a.current=s.current,u.clear()}if(i.current&&!n&&i.current===r){if(f(!1),o){let n=r;return u.start(o,()=>{e.select(`open`)||i.current&&i.current!==n||t()}),()=>{(p.current||i.current!==n)&&u.clear()}}t()}},[n,r,i,a,o,s,c,u,e]),H(()=>{if(!n)return;let t=c.current,o=i.current;u.clear(),c.current={onOpenChange:e.setOpen,setIsInstantPhase:f},i.current=r,a.current={open:0,close:Bl(s.current,`close`)},o!==null&&o!==r?(f(!0),t?.setIsInstantPhase(!0),t?.onOpenChange(!1,W(Gl))):(f(!1),t?.setIsInstantPhase(!1))},[n,r,e,i,a,s,c,u]),H(()=>()=>{if(i.current===r){if(c.current=null,!p.current)return;i.current=null,fu(a,s),u.clear()}},[c,i,a,r,s,u]),V.useMemo(()=>({activeIdRef:i,hasProvider:l,delayRef:a,isInstantPhase:d}),[i,l,a,d])}function hu(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function gu(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function _u(e,t,n,r){let i=Gs(yu).current;return bu(i,e,t,n,r)&&Su(i,[e,t,n,r]),i.callback}function vu(e){let t=Gs(yu).current;return xu(t,e)&&Su(t,e),t.callback}function yu(){return{callback:null,cleanup:null,refs:[]}}function bu(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function xu(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Su(e,t){e.refs=t,e.callback=t.every(e=>e==null)?null:n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}function Cu(e){let t=Gs(wu,e).current;return t.next=e,H(t.effect),t}function wu(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Tu={...V},Eu=Tu.useInsertionEffect,Du=Eu&&Eu!==Tu.useLayoutEffect?Eu:e=>e();function K(e){let t=Gs(Ou).current;return t.next=e,Du(t.effect),t.trampoline}function Ou(){let e={next:void 0,callback:ku,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function ku(){}var Au=null;globalThis.requestAnimationFrame;var ju=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},Mu=class e{static create(){return new e}static request(e){return ju.request(e)}static cancel(e){return ju.cancel(e)}currentId=Au;request(e){this.cancel(),this.currentId=ju.request(()=>{this.currentId=Au,e()})}cancel=()=>{this.currentId!==Au&&(ju.cancel(this.currentId),this.currentId=Au)};disposeEffect=()=>this.cancel};function Nu(){let e=Gs(Mu.create).current;return oc(e.disposeEffect),e}function Pu(e){return e?.ownerDocument||document}var Fu={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},Iu={...Fu,position:`fixed`,margin:0,top:0,left:0},Lu={...Fu,position:`absolute`},Ru=V.forwardRef(function(e,t){let[n,r]=V.useState();H(()=>{Cc&&xc&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,G.jsx)(`span`,{...e,ref:t,style:Iu,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),zu=Math.min,Bu=Math.max,Vu=Math.round,Hu=Math.floor,Uu=e=>({x:e,y:e}),Wu={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Gu(e,t,n){return Bu(e,zu(t,n))}function Ku(e,t){return typeof e==`function`?e(t):e}function qu(e){return e.split(`-`)[0]}function Ju(e){return e.split(`-`)[1]}function Yu(e){return e===`x`?`y`:`x`}function Xu(e){return e===`y`?`height`:`width`}function Zu(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Qu(e){return Yu(Zu(e))}function $u(e,t,n){n===void 0&&(n=!1);let r=Ju(e),i=Qu(e),a=Xu(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=cd(o)),[o,cd(o)]}function ed(e){let t=cd(e);return[td(e),t,td(t)]}function td(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var nd=[`left`,`right`],rd=[`right`,`left`],id=[`top`,`bottom`],ad=[`bottom`,`top`];function od(e,t,n){switch(e){case`top`:case`bottom`:return n?t?rd:nd:t?nd:rd;case`left`:case`right`:return t?id:ad;default:return[]}}function sd(e,t,n,r){let i=Ju(e),a=od(qu(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(td)))),a}function cd(e){let t=qu(e);return Wu[t]+e.slice(t.length)}function ld(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ud(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:ld(e)}function dd(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 fd(e,t,n){return Math.floor(e/t)!==n}function pd(e,t){return t<0||t>=e.length}function md(e,t){return _d(e.current,{disabledIndices:t})}function hd(e,t){return _d(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function gd(e,t,n){let{decrement:r,loopFocus:i,allowEscape:a,disabledIndices:o,minIndex:s,maxIndex:c}=n,l=()=>_d(e,{startingIndex:t,decrement:r,disabledIndices:o}),u,d=!1;if(!i)u=r?Math.max(s,l()):Math.min(c,l());else if(r?t<=s:t>=c){let n=r?-1:e.length;a&&t!==n?u=-1:(u=r?c:s,d=!0)}else u=l();return{index:pd(e,u)?-1:u,wrapped:d}}function _d(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&yd(e,a,r));return a}function vd(e,{event:t,orientation:n,loopFocus:r,onLoop:i,rtl:a,cols:o,disabledIndices:s,minIndex:c,maxIndex:l,prevIndex:u,stopEvent:d=!1}){let f=u,p;if(t.key===`ArrowUp`?p=`up`:t.key===`ArrowDown`&&(p=`down`),p){let n=[],a=[],m=!1,h=0;{let t=null,r=-1;e.forEach((e,i)=>{if(e==null)return;h+=1;let o=rl(e,`[role="row"]`);o&&(m=!0),(o!==t||r===-1)&&(t=o,r+=1,n[r]=[]),n[r].push(i),a[i]=r})}let g=!1,_=0;if(m)for(let e of n){let t=e.length;t>_&&(_=t),t!==o&&(g=!0)}let v=g&&h<e.length,y=_||o,b=o=>{if(!g||u===-1)return;let c=a[u];if(c==null)return;let l=n[c].indexOf(u),d=o===`up`?-1:1;for(let o=c+d,f=0;f<n.length;f+=1,o+=d){if(o<0||o>=n.length){if(!r||v)return;if(o=o<0?n.length-1:0,i){let e=Math.min(l,n[o].length-1),r=i(t,u,n[o][e]??n[o][0]);o=a[r]??o}}let c=n[o];for(let t=Math.min(l,c.length-1);t>=0;--t){let n=c[t];if(!yd(e,n,s))return n}}},x=t=>{if(!v||u===-1)return;let n=u%y,i=t===`up`?-y:y,a=l-l%y,o=Hu(l/y)+1;for(let t=u-n+i,c=0;c<o;c+=1,t+=i){if(t<0||t>l){if(!r)return;t=t<0?a:0}let i=Math.min(t+y-1,l);for(let r=Math.min(t+n,i);r>=t;--r)if(!yd(e,r,s))return r}};d&&Tc(t);let S=b(p)??x(p);if(S!==void 0)f=S;else if(u===-1)f=p===`up`?l:c;else if(f=_d(e,{startingIndex:u,amount:y,decrement:p===`up`,disabledIndices:s}),r){if(p===`up`&&(u-y<c||f<0)){let e=u%y,n=l%y,r=l-(n-e);f=n===e?l:n>e?r:r-y,i&&(f=i(t,u,f))}p===`down`&&u+y>l&&(f=_d(e,{startingIndex:u%y-y,amount:y,disabledIndices:s}),i&&(f=i(t,u,f)))}pd(e,f)&&(f=u)}if(n===`both`){let n=Hu(u/o);t.key===(a?`ArrowLeft`:`ArrowRight`)&&(d&&Tc(t),u%o===o-1?r&&(f=_d(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):(f=_d(e,{startingIndex:u,disabledIndices:s}),r&&fd(f,o,n)&&(f=_d(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f)))),fd(f,o,n)&&(f=u)),t.key===(a?`ArrowRight`:`ArrowLeft`)&&(d&&Tc(t),u%o===0?r&&(f=_d(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f))):(f=_d(e,{startingIndex:u,decrement:!0,disabledIndices:s}),r&&fd(f,o,n)&&(f=_d(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f)))),fd(f,o,n)&&(f=u));let c=Hu(l/o)===n;pd(e,f)&&(r&&c?(f=t.key===(a?`ArrowRight`:`ArrowLeft`)?l:_d(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):f=u)}return f}function yd(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!xd(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function bd(e){return e.visibility===`hidden`||e.visibility===`collapse`}function xd(e,t=e?Xc(e):null){return!e||!e.isConnected||!t||bd(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var Sd=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function Cd(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return Rc(n)?n.host:null}function wd(e){for(let t of Array.from(e.children))if(Mc(t)===`summary`)return t;return null}function Td(e,t){let n=wd(t);return!!n&&(e===n||U(n,e))}function Ed(e){let t=e?Mc(e):``;return e!=null&&e.matches(Sd)&&(t!==`summary`||e.parentElement!=null&&Mc(e.parentElement)===`details`&&wd(e.parentElement)===e)&&(t!==`details`||wd(e)==null)&&(t!==`input`||e.type!==`hidden`)}function Dd(e){if(!Ed(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=Cd(t)){let n=t!==e,r=Mc(t)===`slot`;if(t.hasAttribute(`inert`)||n&&Mc(t)===`details`&&!t.open&&!Td(e,t)||t.hasAttribute(`hidden`)||!r&&!Od(t,n))return!1}return!0}function Od(e,t){let n=Xc(e);return t?n.display!==`none`:xd(e,n)}function kd(e){let t=e.tabIndex;if(t<0){let t=Mc(e);if(t===`details`||t===`audio`||t===`video`||Lc(e)&&e.isContentEditable)return 0}return t}function Ad(e){if(Mc(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function jd(e,t){let n=Ad(e);if(!n)return!0;let r=t.find(e=>{let t=Ad(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=Ad(e);return t?.name===n.name&&t.form===n.form})===n}function Md(e){if(Lc(e)&&Mc(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return Lc(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function Nd(e,t){Md(e).forEach(e=>{Ed(e)&&t.push(e),Nd(e,t)})}function Pd(e,t,n){Md(e).forEach(e=>{Lc(e)&&e.matches(t)&&n.push(e),Pd(e,t,n)})}function Fd(e){return Dd(e)&&kd(e)>=0}function Id(e){let t=[];return Nd(e,t),t.filter(Dd)}function Ld(e){let t=Id(e);return t.filter(e=>kd(e)>=0&&jd(e,t))}function Rd(e,t){let n=Ld(e),r=n.length;if(r===0)return;let i=nl(Pu(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function zd(e){return Rd(Pu(e).body,1)||e}function Bd(e){return Rd(Pu(e).body,-1)||e}function Vd(e,t,n){if(!e)return null;let r=[];Nd(Pu(e).body,r);let i=r.indexOf(e);if(i===-1)return null;let a=r.filter(Dd);for(let e=1;e<r.length;e+=1){let o=r[(i+t*e+r.length)%r.length];if(!U(n,o)&&Fd(o)&&jd(o,a))return o}return r[i]}function Hd(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!U(n,r)}function Ud(e){Ld(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function Wd(e){let t=[];Pd(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function Gd(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...Gd(e,t.id,n)])}function Kd(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function qd(e){return`data-base-ui-${e}`}var Jd=0;function Yd(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(Jd);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),$s;let o=requestAnimationFrame(a);return Jd=o,()=>{Jd===o&&(cancelAnimationFrame(o),Jd=0)}}var Xd=`data-base-ui-inert`,Zd=new WeakMap,Qd=new WeakSet,$d=new WeakMap,ef=0;function tf(e){return e?Rc(e)?e.host:tf(e.parentNode):null}var nf=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=tf(t);return e.contains(n)?n:null}).filter(e=>e!=null),rf=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},af=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{Mc(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function of(e,t,n,{mark:r=!0}){let i=nf(t,e),a=r?af(t,rf(i),new Set(i)):[],o=[],s=[];if(n){let e=nf(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);af(t,rf(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(Zd.get(e)||0)+1;Zd.set(e,r),o.push(e),r===1&&n&&Qd.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=($d.get(e)||0)+1;$d.set(e,t),s.push(e),t===1&&e.setAttribute(Xd,``)}),ef+=1,()=>{o.forEach(e=>{let t=(Zd.get(e)||0)-1;Zd.set(e,t),t||(Qd.has(e)||e.removeAttribute(`aria-hidden`),Qd.delete(e))}),r&&s.forEach(e=>{let t=($d.get(e)||0)-1;$d.set(e,t),t||e.removeAttribute(Xd)}),--ef,ef||(Zd=new WeakMap,Qd=new WeakSet,$d=new WeakMap)}}function sf(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=Pu(e[0]).body;return of(e,i,n,{mark:r})}function cf(){let[,e]=V.useState({});return V.useCallback(()=>{e({})},[])}var lf=0;function uf(e,t=`mui`){let n=V.useRef(void 0),r=cf(),i=e??n.current;return V.useEffect(()=>{n.current??(lf+=1,n.current=`${t}-${lf}`,e??r())},[e,t,r]),i}var df=Tu.useId;function ff(e,t){if(df!==void 0){let n=df();return e??(t?`${t}-${n}`:n)}return uf(e,t)}var pf=19;function mf(e){return pf>=e}function hf(e){if(!V.isValidElement(e))return null;let t=e,n=t.props;return(mf(19)?n?.ref:t.ref)??null}function gf(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function _f(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e)}else i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function vf(e,t){return typeof e==`function`?e(t):e}function yf(e,t){return typeof e==`function`?e(t):e}var bf={};function xf(e,t,n,r,i){if(!n&&!r&&!i&&!e)return Cf(t);let a=Cf(e);return t&&(a=wf(a,t)),n&&(a=wf(a,n)),r&&(a=wf(a,r)),i&&(a=wf(a,i)),a}function Sf(e){if(e.length===0)return bf;if(e.length===1)return Cf(e[0]);let t=Cf(e[0]);for(let n=1;n<e.length;n+=1)t=wf(t,e[n]);return t}function Cf(e){return Of(e)?{...e(bf)}:Tf(e)}function wf(e,t){return Of(t)?t(e):Ef(e,t)}function Tf(e){let t={...e};for(let e in t){let n=t[e];Df(e,n)&&(t[e]=Af(n))}return t}function Ef(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=gf(e.style,r);break;case`className`:e[n]=Mf(e.className,r);break;default:e[n]=Df(n,r)?kf(e[n],r):r}}return e}function Df(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Of(e){return typeof e==`function`}function kf(e,t){return t?e?(...n)=>{let r=n[0];if(Nf(r)){let i=r;jf(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:Af(t):e}function Af(e){return e&&((...t)=>{let n=t[0];return Nf(n)&&jf(n),e(...t)})}function jf(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Mf(e,t){return t?e?t+` `+e:t:e}function Nf(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function Pf(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=Rf(r));let i=Ff(t,n,r);if(n.enabled===!1)return null;let a=n.state??tc;return zf(e,r,i,a)}function Ff(e,t,n){let{className:r,style:i}=e,{state:a=tc,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?vf(r,a):void 0,d=l?yf(i,a):void 0,f=l?_f(a,c):tc,p=l&&s?If(s):void 0,m=l?gf(f,p)??{}:tc;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?vu([m.ref,hf(n),...o]):_u(m.ref,hf(n),o):_u(null,null)),l?(u!==void 0&&(m.className=Mf(m.className,u)),d!==void 0&&(m.style=gf(m.style,d)),m):tc}function If(e){return Array.isArray(e)?Sf(e):xf(void 0,e)}var Lf=Symbol.for(`react.lazy`);function Rf(e){if(e?.$$typeof!==Lf)return e;let t=V.Children.toArray(e)[0];return V.isValidElement(t)?t:e}function zf(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=xf(n,t.props);return e.ref=n.ref,V.cloneElement(t,e)}return Bf(e,n)}function Bf(e,t){return e===`button`?(0,V.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,V.createElement)(`img`,{alt:``,...t,key:t.key}):V.createElement(e,t)}var Vf={style:{transition:`none`}},Hf=`data-base-ui-click-trigger`,Uf=`data-base-ui-swipe-ignore`,Wf=`data-swipe-ignore`,Gf=`[${Uf}]`,Kf=`[${Wf}]`,qf={fallbackAxisSide:`none`},Jf={fallbackAxisSide:`end`},Yf={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},Xf=ne(ae(),1),Zf=V.createContext(null),Qf=()=>V.useContext(Zf),$f=qd(`portal`);function ep(e={}){let{ref:t,container:n,componentProps:r=tc,elementProps:i}=e,a=ff(),o=Qf()?.portalNode,[s,c]=V.useState(null),[l,u]=V.useState(null),d=K(e=>{e!==null&&u(e)}),f=V.useRef(null);H(()=>{if(n===null){f.current&&(f.current=null,u(null),c(null));return}let e=(n&&(Fc(n)?n:n.current))??o??document.body;e==null?f.current&&(f.current=null,u(null),c(null)):f.current!==e&&(f.current=e,u(null),c(e))},[n,o]);let p=Pf(`div`,r,{ref:[t,d],props:[{id:a,[$f]:``},i]}),m=s&&p?Xf.createPortal(p,s):null;return{node:l,nodeId:V.isValidElement(p)?p.props.id:void 0,subtree:m}}var tp=V.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,portalOwnerRole:s,...c}=e,{node:l,nodeId:u,subtree:d}=ep({container:o,ref:t,componentProps:e,elementProps:c}),f=V.useRef(null),p=V.useRef(null),m=V.useRef(null),h=V.useRef(null),[g,_]=V.useState(null),v=V.useRef(!1),y=g?.modal,b=g?.open,x=!!g&&!g.modal&&g.open&&!!l;V.useEffect(()=>{if(!l||y)return;function e(e){l&&e.relatedTarget&&Hd(e)&&(e.type===`focusin`?v.current&&=(Wd(l),!1):(Ud(l),v.current=!0))}return gu(hu(l,`focusin`,e,!0),hu(l,`focusout`,e,!0))},[l,y]),H(()=>{l&&b===!0&&v.current&&(Wd(l),v.current=!1)},[b,l]);let S=V.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:h,portalNode:l,setFocusManagerState:_}),[l]);return(0,G.jsxs)(V.Fragment,{children:[d,(0,G.jsxs)(Zf.Provider,{value:S,children:[x&&l&&(0,G.jsx)(Ru,{"data-type":`outside`,ref:f,onFocus:e=>{Hd(e,l)?m.current?.focus():Bd(g?g.domReference:null)?.focus()}}),x&&l&&(0,G.jsx)(`span`,{role:s,"aria-owns":u,style:Yf}),l&&Xf.createPortal(a,l),x&&l&&(0,G.jsx)(Ru,{"data-type":`outside`,ref:p,onFocus:e=>{Hd(e,l)?h.current?.focus():(zd(g?g.domReference:null)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,W(`focus-out`,e.nativeEvent)))}})]})]})});function np(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var rp=class{nodesRef={current:[]};events=np();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},ip=V.createContext(null),ap=V.createContext(null),op=()=>V.useContext(ip)?.id||null,sp=e=>{let t=V.useContext(ap);return e??t};function cp(e){let t=ff(),n=sp(e),r=op();return H(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function lp(e){let{children:t,id:n}=e,r=op();return(0,G.jsx)(ip.Provider,{value:V.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function up(e){let{children:t,externalTree:n}=e,r=Gs(()=>n??new rp).current;return(0,G.jsx)(ap.Provider,{value:r,children:t})}function dp(e){return e==null?e:`current`in e?e.current:e}function fp(e,t){let n=Nc(il(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||(Dc(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var pp=20,mp=[];function hp(){mp=mp.filter(e=>e.deref()?.isConnected)}function gp(e){hp(),e&&Mc(e)!==`body`&&(mp.push(new WeakRef(e)),mp.length>pp&&(mp=mp.slice(-20)))}function _p(){return hp(),mp[mp.length-1]?.deref()}function vp(e){return e?Fd(e)?e:Ld(e)[0]||e:null}function yp(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=Id(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Fd(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function bp(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,explicitReturnFocus:o,restoreFocus:s=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:h}=e,g=t.useState(`open`),_=t.useState(`domReferenceElement`),v=t.useState(`floatingElement`),{events:y,dataRef:b}=t.context,x=K(()=>b.current.floatingContext?.nodeId),S=i===!1,C=Il(_)&&S,w=Cu(i),T=Cu(a),E=Cu(o),D=Cu(u),O=Cu(g),k=sp(m),A=Qf(),j=V.useRef(!1),M=V.useRef(!1),N=V.useRef(!1),P=V.useRef(null),F=V.useRef(``),I=V.useRef(``),L=V.useRef(null),R=V.useRef(null),ee=_u(L,p,A?.beforeInsideRef),z=_u(R,A?.afterInsideRef),te=lc(),ne=lc(),re=Nu(),ie=A!=null,ae=Rl(v),oe=K((e=ae)=>e?Ld(e):[]),se=K(()=>h?.().filter(e=>e!=null)??[]);V.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&U(ae,nl(Pu(ae)))&&oe().length===0&&!C&&Tc(e)}return hu(Pu(ae),`keydown`,e)},[r,ae,c,C,oe]),V.useEffect(()=>{if(r||!g)return;let e=Pu(ae);function t(){N.current=!1}function n(e){let t=il(e),n=se(),r=U(v,t)||U(_,t)||U(A?.portalNode,t)||n.some(e=>e===t||U(e,t));N.current=!r,I.current=e.pointerType||`keyboard`,rl(t,`[data-base-ui-click-trigger]`)&&(M.current=!0,ne.start(0,()=>{M.current=!1}))}function i(){I.current=`keyboard`}return gu(hu(e,`pointerdown`,n,!0),hu(e,`pointerup`,t,!0),hu(e,`pointercancel`,t,!0),hu(e,`keydown`,i,!0),t)},[r,v,_,ae,g,A,ne,se]),V.useEffect(()=>{if(r||!l)return;let e=Pu(ae);function n(){M.current=!0,ne.start(0,()=>{M.current=!1})}function i(e){let t=il(e);Fd(t)&&(P.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=il(n);c&&r==null&&a!=null&&U(v,a)&&gp(a),queueMicrotask(()=>{let o=x(),l=t.context.triggerElements,u=se(),p=r?.hasAttribute(qd(`focus-guard`))&&[L.current,R.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,dp(f),dp(d)].includes(r),m=!(U(_,r)||U(v,r)||U(r,v)||U(A?.portalNode,r)||u.some(e=>e===r||U(e,r))||l.hasMatchingElement(e=>U(e,r))||p||k&&(Gd(k.nodesRef.current,o).find(e=>U(e.context?.elements.floating,r)||U(e.context?.elements.domReference,r))||Kd(k.nodesRef.current,o).find(e=>[e.context?.elements.floating,Rl(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===_&&ae&&yp(ae),s&&i!==_&&!xd(a)&&nl(e)===e.body){if(Lc(ae)&&(ae.focus(),s===`popup`)){re.request(()=>{ae.focus()});return}let e=oe(),t=P.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||ae;Lc(n)&&n.focus()}b.current.insideReactTree?b.current.insideReactTree=!1:(C||!c)&&r&&m&&!M.current&&(C||r!==_p())&&(j.current=!0,t.setOpen(!1,W(tu,n)))})}function o(){N.current||(b.current.insideReactTree=!0,te.start(0,()=>{b.current.insideReactTree=!1}))}let u=Lc(_)?_:null;if(v||u)return gu(u&&hu(u,`focusout`,a),u&&hu(u,`pointerdown`,n),v&&hu(v,`focusin`,i),v&&hu(v,`focusout`,a),v&&A&&hu(v,`focusout`,o,!0))},[r,_,v,ae,c,k,A,t,l,s,oe,C,x,b,te,ne,re,d,f,se]),V.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${qd(`portal`)}]`)||[]),t=(k?Kd(k.nodesRef.current,x()):[]).find(e=>Il(e.context?.elements.domReference||null))?.context?.elements.domReference,n=sf([v,...e,L.current,R.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...se(),t,dp(f),dp(d),C?_:null].filter(e=>e!=null),{ariaHidden:c||C,mark:!1}),i=sf([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,c,A,C,k,x,d,f,se]),H(()=>{if(!g||r||!Lc(ae))return;F.current=``,I.current=``;let e=Pu(ae),t=nl(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(D.current||``):n;if(r===void 0||r===!1||U(ae,t))return;let i=null,a=()=>(i??=oe(ae),i[0]||ae),o;o=r===!0||r===null?a():dp(r),o||=a();let s=U(ae,nl(e)),c=b.current.openEvent,l=c?.type===`mousedown`&&Dc(c);Yd(o,{sync:l,preventScroll:o===ae,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=nl(e);return!(t!==o&&U(ae,t))}})})},[r,g,ae,oe,w,D,O,b]);let ce=V.useRef(null);H(()=>{if(r||!ae){ce.current=null;return}ce.current&&=(ce.current.cancelled=!0,null);let e=Pu(ae),t=nl(e),n=D.current==null;gp(t);function i(e){if(e.open||(F.current=fp(e.nativeEvent,I.current)),(e.reason===`focus-out`&&e.triggerElement?.hasAttribute(qd(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(Dc(e.nativeEvent)||Oc(e.nativeEvent))j.current=!1;else{let e=!1;Pu(ae).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&Mc(t)!==`body`?t:null,s=n?o||a:a||o;return s||=_p()||null,typeof i==`boolean`?s:dp(i)||s||null}return()=>{y.off(`openchange`,i);let t=nl(e),n=se(),r=U(v,t)||n.some(e=>e===t||U(e,t))||k&&Gd(k.nodesRef.current,x(),!1).some(e=>U(e.context?.elements.floating,t)),o=T.current,s=F.current,c=a(s),l={cancelled:!1};ce.current=l,queueMicrotask(()=>{ce.current===l&&(ce.current=null);let n=vp(c),i=E.current??typeof o!=`boolean`;if(!l.cancelled&&o&&!j.current&&Lc(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,v,ae,T,E,D,y,k,_,x,se]),H(()=>{if(!xc||g||!v)return;let e=nl(Pu(v));Lc(e)&&Pl(e)&&U(v,e)&&e.blur()},[g,v]),H(()=>{if(!r&&A)return A.setFocusManagerState({modal:c,closeOnFocusOut:l,open:g,onOpenChange:t.setOpen,domReference:_}),()=>{A.setFocusManagerState(null)}},[r,A,c,g,t,l,_]),H(()=>{if(!r&&ae)return yp(ae),()=>{queueMicrotask(hp)}},[r,ae]);let le=!r&&(!c||!C)&&(ie||c);return(0,G.jsxs)(V.Fragment,{children:[le&&(0,G.jsx)(Ru,{"data-type":`inside`,ref:ee,onFocus:e=>{if(c){let e=oe();Yd(e[e.length-1])}else A?.portalNode&&(j.current=!1,Hd(e,A.portalNode)?zd(_)?.focus():dp(f??A.beforeOutsideRef)?.focus())}}),n,le&&(0,G.jsx)(Ru,{"data-type":`inside`,ref:z,onFocus:e=>{c?Yd(oe()[0]):A?.portalNode&&(l&&(j.current=!0),Hd(e,A.portalNode)?Bd(_)?.focus():dp(d??A.afterOutsideRef)?.focus())}})]})}function xp(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=Kl}=t,l=e.context.dataRef,u=V.useRef(void 0),d=Nu(),f=lc(),p=V.useMemo(()=>{function t(t,n,r,i){let a=W(c,n,r);t&&i===`touch`&&s>0?f.start(s,()=>{e.setOpen(!0,a)}):e.setOpen(t,a)}function n(t,n,r){let a=l.current.openEvent,s=e.select(`domReferenceElement`)!==n;return t&&s||!t||!i?!0:a&&(typeof o==`function`?o():o)?!r(a.type):!1}return{onPointerDown(e){u.current=kc(e.pointerType,!0)&&Oc(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||kc(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=il(s),p=Pl(f);if(p||o===`virtual`){t(l,s,p?f:i.currentTarget,o);return}let m=i.currentTarget;d.request(()=>{t(l,s,m,o)})},onClick(i){if(r===`mousedown-only`)return;let o=u.current;r===`mousedown`&&o?u.current=void 0:kc(o,!0)&&a||t(n(e.select(`open`),i.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),i.nativeEvent,i.currentTarget,o)},onKeyDown(){u.current=void 0}}},[l,r,a,c,e,o,i,d,f,s]);return V.useMemo(()=>n?{reference:p}:tc,[n,p])}function Sp(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,(!i||c)&&(d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function Cp(e){return e!=null&&e.clientX!=null}function wp(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=e.useState(`open`),a=e.useState(`floatingElement`),o=e.useState(`domReferenceElement`),s=e.context.dataRef,c=V.useRef(!1),l=V.useRef(null),[u,d]=V.useState(),[f,p]=V.useState([]),m=K(t=>{e.set(`positionReference`,t)}),h=K((t,n,i)=>{c.current||(!s.current.openEvent||Cp(s.current.openEvent))&&e.set(`positionReference`,Sp(i??o,{x:t,y:n,axis:r,dataRef:s,pointerType:u}))}),g=K(e=>{i?l.current||(h(e.clientX,e.clientY,e.currentTarget),p([])):h(e.clientX,e.clientY,e.currentTarget)}),_=kc(u)?a:i;V.useEffect(()=>{if(!n){m(o);return}if(!_)return;function e(){l.current?.(),l.current=null}let t=Nc(a);function r(t){let n=il(t);U(a,n)?e():h(t.clientX,t.clientY)}return!s.current.openEvent||Cp(s.current.openEvent)?l.current=hu(t,`mousemove`,r):m(o),e},[_,n,a,s,o,e,h,m,f]),V.useEffect(()=>()=>{e.set(`positionReference`,null)},[e]),V.useEffect(()=>{n&&!a&&(c.current=!1)},[n,a]),V.useEffect(()=>{!n&&i&&(c.current=!0)},[n,i]);let v=V.useMemo(()=>{function e(e){d(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:g,onMouseEnter:g}},[g]);return V.useMemo(()=>n?{reference:v,trigger:v}:{},[n,v])}function Tp(){return!1}function Ep(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function Dp(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=Tp,bubbles:s,externalTree:c}=t,l=e.useState(`open`),u=e.useState(`floatingElement`),{dataRef:d,events:f}=e.context,p=sp(c),m=K(typeof i==`function`?i:()=>!1),h=typeof i==`function`?m:i,g=h!==!1,_=K(()=>a),{escapeKey:v,outsidePress:y}=Ep(s),b=V.useRef(!1),x=V.useRef(!1),S=V.useRef(!1),C=V.useRef(!1),w=V.useRef(!1),T=V.useRef(``),E=V.useRef(null),D=lc(),O=lc(),k=lc(),A=K(()=>{O.clear(),d.current.insideReactTree=!1}),j=K(e=>{let t=d.current.floatingContext?.nodeId;return(p?Gd(p.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=K(t=>Ml(t,e.select(`floatingElement`))||Ml(t,e.select(`domReferenceElement`))),N=K(t=>{o()&&e.setOpen(!1,W(Kl,t.nativeEvent))}),P=K(t=>{if(!l||!n||!r||t.key!==`Escape`)return;let i=Ec(t)?t.nativeEvent:t;if(w.current||i.isComposing||!v&&j(`__escapeKeyBubbles`))return;let a=W(nu,i);e.setOpen(!1,a),a.isCanceled||t.preventDefault(),!v&&!a.isPropagationAllowed&&t.stopPropagation()}),F=K(()=>{d.current.insideReactTree=!0,O.start(0,A)}),I=K(t=>{if(!l||!n||t.button!==0)return;let r=il(t.nativeEvent);U(e.select(`floatingElement`),r)&&(b.current||(b.current=!0,x.current=!1))}),L=K(e=>{l&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&b.current&&(x.current=!0)});V.useEffect(()=>{function e(e){e.open||(C.current=!1)}return f.on(`openchange`,e),()=>{f.off(`openchange`,e)}},[f]),V.useEffect(()=>A,[A]),V.useEffect(()=>{if(!l||!n)return l||(C.current=!1,w.current=!1,T.current=``,E.current=null),A;d.current.__escapeKeyBubbles=v,d.current.__outsidePressBubbles=y;let t=new cc,i=Pu(u);function a(){k.clear(),w.current=!0}function o(){w.current=!0,k.start(xc?5:0,()=>{w.current=!1})}function s(){S.current=!0,t.start(0,()=>{S.current=!1})}function c(){b.current=!1,x.current=!1}function f(){let e=T.current,t=e===`pen`||!e?`mouse`:e,n=_(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=f();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function O(e){let t=d.current.floatingContext?.nodeId,n=p&&Gd(p.nodesRef.current,t).some(t=>Ml(e,t.context?.elements.floating));return M(e)||n}function N(n){if(m(n)){n.type!==`click`&&!M(n)&&(t.clear(),S.current=!1),A();return}if(d.current.insideReactTree){A();return}let r=il(n),i=`[${qd(`inert`)}]`,a=Ic(r)?r.getRootNode():null,o=Array.from((Rc(a)?a:Pu(e.select(`floatingElement`))).querySelectorAll(i)),s=e.context.triggerElements;if(r&&(s.hasElement(r)||s.hasMatchingElement(e=>U(e,r))))return;let c=Ic(r)?r:null;for(;c&&!Yc(c);){let e=Qc(c);if(Yc(e)||!Ic(e))break;c=e}if(!(o.length&&Ic(r)&&!Nl(r)&&!U(r,e.select(`floatingElement`))&&o.every(e=>!U(c,e)))){if(Lc(r)&&!(`touches`in n)){let e=Yc(r),t=Xc(r),i=/auto|scroll/,a=e||i.test(t.overflowX),o=e||i.test(t.overflowY),s=a&&r.clientWidth>0&&r.scrollWidth>r.clientWidth,c=o&&r.clientHeight>0&&r.scrollHeight>r.clientHeight,l=t.direction===`rtl`,u=c&&(l?n.offsetX<=r.offsetWidth-r.clientWidth:n.offsetX>r.clientWidth),d=s&&n.offsetY>r.clientHeight;if(u||d)return}if(!O(n)){if(f()===`intentional`){if(n.detail!==0&&!Dc(n)&&!C.current)return;if(S.current){t.clear(),S.current=!1;return}}typeof h==`function`&&!h(n)||j(`__outsidePressBubbles`)||(e.setOpen(!1,W(Yl,n)),A())}}}function F(t){f()===`sloppy`&&t.pointerType!==`touch`&&e.select(`open`)&&n&&!M(t)&&N(t)}function I(t){if(f()!==`sloppy`||!e.select(`open`)||!n||M(t))return;let r=t.touches[0];r&&(E.current={startTime:Date.now(),startX:r.clientX,startY:r.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},D.start(1e3,()=>{E.current&&(E.current.dismissOnTouchEnd=!1,E.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=il(e);if(!n)return;let r=hu(n,e.type,()=>{t(e),r()})}function R(e){T.current=`touch`,L(e,I)}function ee(e){D.clear(),e.type===`pointerdown`&&(e.button===0&&(C.current=!0),T.current=e.pointerType),(e.type!==`mousedown`||!E.current||E.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?F(e):N(e)})}function z(e){if(e.type===`pointercancel`&&(C.current=!1),!b.current)return;let n=x.current;c(),f()===`intentional`&&(e.type===`pointercancel`?n&&s():O(e)||(n?s():(typeof h!=`function`||h(e))&&(t.clear(),S.current=!0,A())))}function te(e){if(f()!==`sloppy`||!E.current||M(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-E.current.startX),r=Math.abs(t.clientY-E.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(E.current.dismissOnTouchEnd=!0),i>10&&(N(e),D.clear(),E.current=null)}function ne(e){L(e,te)}function re(e){f()===`sloppy`&&E.current&&!M(e)&&(E.current.dismissOnTouchEnd&&N(e),D.clear(),E.current=null)}function ie(e){L(e,re)}let ae=gu(r&&gu(hu(i,`keydown`,P),hu(i,`compositionstart`,a),hu(i,`compositionend`,o)),g&&gu(hu(i,`click`,ee,!0),hu(i,`pointerdown`,ee,!0),hu(i,`pointerup`,z,!0),hu(i,`pointercancel`,z,!0),hu(i,`mousedown`,ee,!0),hu(i,`mouseup`,z,!0),hu(i,`touchstart`,R,{capture:!0,passive:!0}),hu(i,`touchmove`,ne,{capture:!0,passive:!0}),hu(i,`touchend`,ie,{capture:!0,passive:!0})));return()=>{ae(),t.clear(),c(),S.current=!1}},[d,u,r,g,h,l,n,v,y,P,A,_,j,M,p,e,D,k]);let R=V.useMemo(()=>({onKeyDown:P,onPointerDown:N,onClick:N}),[P,N]),ee=V.useMemo(()=>({onKeyDown:P,onPointerDown:L,onMouseDown:L,onClickCapture:F,onMouseDownCapture(e){F(),I(e)},onPointerDownCapture(e){F(),I(e)},onMouseUpCapture:F,onTouchEndCapture:F,onTouchMoveCapture:F}),[P,F,I,L]);return V.useMemo(()=>n?{reference:R,floating:ee,trigger:R}:{},[n,R,ee])}function Op(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=o;return t.useSyncedValue(`floatingId`,i),H(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};Ic(c)&&(e.domReferenceElement=c),r.state.positionReference===r.state.referenceElement&&(e.positionReference=c),r.update(e)},[s,i,c,l,r]),r.context.onOpenChange=u,r.context.nested=a,r}function kp(e,t=!1,n=!1,r=!1){let[i,a]=V.useState(e&&t?`idle`:void 0),[o,s]=V.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),H(()=>{if(!e&&o&&i!==`ending`&&n){let e=Mu.request(()=>{a(`ending`)});return()=>{Mu.cancel(e)}}},[e,o,i,n]),H(()=>{if(!e||t||i===void 0)return;let n=Mu.request(()=>{a(void 0)});return()=>{Mu.cancel(n)}},[t,e,i]),H(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=Mu.request(()=>{a(`idle`)});return()=>{Mu.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function Ap(e,t){return e.getAnimations(t).filter(e=>{let t=e.effect?.getTiming();return t?.duration!==1/0&&t?.iterations!==1/0})}var jp=null;function Mp(e){if(!jp){let e=[];jp=e,queueMicrotask(()=>{jp=null,Xf.flushSync(()=>{for(let t of e)t()})})}jp.push(e)}function Np(e,t=!1,n=!1){let r=Nu();return K((i,a=null)=>{r.cancel();let o=dp(e);if(o==null)return;let s=o,c=()=>{n?Mp(()=>{a?.aborted||i()}):Xf.flushSync(i)};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(Ap(s).map(e=>e.finished.then($s))).then(()=>{a?.aborted||c()},()=>{a?.aborted||(Ap(s).some(e=>e.pending||e.playState!==`finished`)?l():c())})}if(t){let e=dl;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0})}else r.request(l)})}function Pp(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=K(a),s=Np(r,n,i);V.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}function Fp(e){let{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:i,onUnmount:a,animateInitialOpen:o}=e,s=K(i),{mounted:c,setMounted:l,transitionStatus:u}=kp(t,!1,!1,o),d=!t&&r;H(()=>{t&&s(!1)},[t,s]);let f=V.useRef(c),p=V.useRef(!1),m=cf(),h=()=>{f.current=!1,l(!1),a()};H(()=>{f.current=c,p.current&&(p.current=!1,!t&&c&&h())});let g=K(()=>{f.current&&(t?(p.current=!0,m()):h())});return Pp({enabled:c&&!t&&!d,open:t,ref:n,onComplete(){t||g()}}),{mounted:c,transitionStatus:u,preventUnmountingOnClose:d,forceUnmount:g}}var Ip={tabIndex:-1,[al]:``};function Lp(e){return t=>t!==`touch`||e.current}function Rp(e,t=!1){let n=ff(),r=op()!=null,i=Gs(()=>e(n,r)).current;return Op({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function zp({handle:e,store:t}){return H(()=>e.attachStore(t),[e,t]),null}function Bp(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function Vp(e,t){let n=V.useRef(null);return K(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),Bp(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),Bp(t))})}function Hp(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s,openedWithoutTrigger:t?n==null:e.openedWithoutTrigger}}function Up(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Wp(e,t,n,r={}){let i=n.reason,a=i===ql,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=Up(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i=Hp(e.state,t,n.trigger,c()),l={...r.extraState,...i};o?l.instantType=`focus`:s?l.instantType=`dismiss`:a&&(l.instantType=void 0),e.update(l)};a?Xf.flushSync(l):l()}function Gp(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Vp(e,n),o=K(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e)}else if(a==null&&i&&!n.state.openedWithoutTrigger){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=K(e=>{a(e),e&&o(e)});return H(()=>(s(t.current),()=>s(null)),[s,t,n,e]),H(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Kp(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=V.useRef(null),i=e.useState(`open`);H(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0),e.state.openedWithoutTrigger&&e.set(`openedWithoutTrigger`,!1);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&!e.state.openedWithoutTrigger&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=W(Gl);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function qp(e,t,n,r){let{mounted:i,transitionStatus:a,forceUnmount:o}=Fp({open:e,ref:t.context.popupRef,preventUnmountOnClose:t.useState(`preventUnmountingOnClose`),setPreventUnmountOnClose:e=>t.set(`preventUnmountingOnClose`,e),animateInitialOpen:r,onUnmount(){t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}});return Gs(()=>(t.set(`mounted`,i),null)),t.useSyncedValues({mounted:i,transitionStatus:a}),{forceUnmount:o,transitionStatus:a}}function Jp(e,t){e.useSyncedValues(t),H(()=>()=>{e.update({activeTriggerProps:tc,inactiveTriggerProps:tc,popupProps:tc})},[e])}function Yp(e,t){H(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),H(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var Xp=class{idMap=new Map;add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}},Zp=pe((e=>{var t=se();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),Qp=pe(((e,t)=>{t.exports=Zp()})),$p=pe((e=>{var t=se(),n=Qp();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),em=pe(((e,t)=>{t.exports=$p()})),tm=Qp(),nm=em(),rm=mf(19)?om:sm;function im(e,t,n,r,i){return rm(e,t,n,r,i)}function am(e,t,n,r,i){let a=V.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,tm.useSyncExternalStore)(e.subscribe,a,a)}Ys({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,tm.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function om(e,t,n,r,i){let a=Js();if(!a)return am(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],s.store===e&&s.selector===t&&Object.is(s.a1,n)&&Object.is(s.a2,r)&&Object.is(s.a3,i)||(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function sm(e,t,n,r,i){return(0,nm.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var cm=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return im(this,e,t,n,r)}},lm=class extends cm{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){V.useDebugValue(e);let n=this;H(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;H(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;H(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){V.useDebugValue(e);let n=this,r=t!==void 0;H(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return V.useDebugValue(e),im(this,this.selectors[e],t,n,r)}useContextCallback(e,t){V.useDebugValue(e);let n=K(t??$s);this.context[e]=n}useStateSetter(e){let t=V.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},um={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},dm=class extends lm{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:np(),nested:n,triggerElements:i},um),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&Ac(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{this.syncOnly||this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function fm(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new dm({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,openedWithoutTrigger:!1,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:tc,inactiveTriggerProps:tc,popupProps:tc}}var pm=e=>e.triggerIdProp??e.activeTriggerId,mm=e=>e.openProp??e.open,hm=e=>(e.popupElement?.id??e.floatingId)||void 0;function gm(e,t){return t!==void 0&&mm(e)&&pm(e)===t}function _m(e,t){return gm(e,t)?!0:t!==void 0&&mm(e)&&pm(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var vm={open:mm,mounted:e=>e.mounted,transitionStatus:e=>mm(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:pm,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:hm,isTriggerActive:(e,t)=>t!==void 0&&pm(e)===t,isOpenedByTrigger:(e,t)=>gm(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&pm(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>_m(e,t)?hm(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function ym(e){let t=V.useCallback(t=>e===void 0?$s:e.subscribeStore(t),[e]),n=V.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,tm.useSyncExternalStore)(t,n,()=>e?.serverStore)}function bm(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=ff(),a=op()!=null,o=Gs(()=>new dm({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Xp,floatingId:i,syncOnly:!1,nested:a})).current;return H(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=Ic(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}var xm=yc&&xc;function Sm(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=V.useRef(!1),s=V.useRef(null),c=V.useRef(!0),l=lc();V.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=Nc(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&Lc(t)&&t===nl(Pu(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return gu(hu(r,`blur`,i),xm&&hu(r,`keydown`,a,!0),xm&&hu(r,`pointerdown`,l,!0))},[e,n]),V.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);Ic(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=V.useMemo(()=>{function t(){o.current=!1,s.current=null}return{onMouseLeave(){t()},onFocus(n){let i=n.currentTarget;if(o.current){if(s.current===i)return;t()}let a=il(n.nativeEvent);if(Ic(a)){if(xm&&!n.relatedTarget){if(!c.current&&!Pl(a))return}else if(!Ll(a))return}let u=jl(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;e.select(`open`)&&u||!r?e.setOpen(!0,W(Jl,d,f)):l.start(r,()=>{o.current||e.setOpen(!0,W(Jl,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=Ic(r)&&r.hasAttribute(qd(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=nl(Pu(t));!r&&n===t||U(a.current.floatingContext?.refs.floating.current,n)||U(t,n)||o||jl(r??n,e.context.triggerElements)||e.setOpen(!1,W(Jl,i))})}}},[a,r,e,l]);return V.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var Cm=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new cc;restTimeout=new cc;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},wm=new WeakMap;function Tm(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&wm.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),wm.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Em(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=wm.get(n);a&&a!==e&&Tm(a),Tm(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,wm.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function Dm(e){let t=e.context.dataRef.current,n=Gs(()=>t.hoverInteractionState??Cm.create()).current;return t.hoverInteractionState||=n,oc(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function Om(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=e.useState(`open`),o=e.useState(`floatingElement`),s=e.useState(`domReferenceElement`),{dataRef:c}=e.context,l=sp(),u=op(),d=Dm(e),f=lc(),p=K(()=>Hl(c.current.openEvent?.type,d.interactedInside)),m=K(()=>Ul(c.current.openEvent?.type)),h=K(()=>{Tm(d)});H(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,h())},[a,d,h]),V.useEffect(()=>h,[h]),H(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&m()&&Ic(s)&&o){let e=s,t=o,n=Pu(o),r=l?.nodesRef.current.find(e=>e.id===u)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=d.pointerEventsScopeElement===t?null:d.pointerEventsScopeElement,a=r===t?null:r,c=d.handleCloseOptions?.getScope?.()??i??a??rl(e,`[data-rootownerid]`)??n.body;return Em(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{h()}}},[n,a,s,o,d,m,l,u,h]),V.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&Gd(l.nodesRef.current,u).length>0)}function a(t){let n=Bl(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,W(ql,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=il(e);Fl(t)?d.interactedInside=rl(t,`[aria-haspopup]`)!=null:d.interactedInside=!1}function g(){d.openChangeTimeout.clear(),f.clear(),l?.events.off(`floating.closed`,v),h()}function _(n){if(t()&&l){l.events.on(`floating.closed`,v);return}if(jl(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;l&&r&&Ic(o)&&Gd(l.nodesRef.current,r,!1).some(e=>U(e.context?.elements.floating,o))||(d.handler?d.handler(n):(h(),m()&&!p()&&a(n)))}function v(n){l&&u&&!t()&&f.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,W(ql,n)),l.events.emit(`floating.closed`,n)})}let y=o;return gu(y&&hu(y,`mouseenter`,g),y&&hu(y,`mouseleave`,_),y&&hu(y,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,m,p,h,d,l,u,f])}var km={current:null};function Am(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=km,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,{dataRef:h,events:g}=e.context,_=sp(l),v=Dm(e),y=V.useRef(!1),b=Cu(i),x=Cu(r),S=Cu(o),C=Cu(n),w=Cu(p),T=Cu(f),E=K(()=>Hl(h.current.openEvent?.type,v.interactedInside)),D=K(()=>w.current?.()!==!1),O=K((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!U(t,n);if(!Ic(r))return!1;let a=r;return i.hasMatchingElement(e=>U(e,a))&&(!t||!U(t,a))}),k=K(()=>{v.handler&&=(Pu(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,v.handler),void 0)}),A=K(()=>{Tm(v)});return u&&(v.handleCloseOptions=i?.__options),V.useEffect(()=>k,[k]),V.useEffect(()=>{if(!n)return;function e(e){e.open?y.current=!1:(y.current=e.reason===ql,k(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return g.on(`openchange`,e),()=>{g.off(`openchange`,e)}},[n,g,v,k]),V.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=Bl(x.current,`close`,v.pointerType);r?v.openChangeTimeout.start(r,()=>{e.setOpen(!1,W(ql,t)),_?.events.emit(`floating.closed`,t)}):n&&(v.openChangeTimeout.clear(),e.setOpen(!1,W(ql,t)),_?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!Ic(r))return;function i(t){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,a&&!kc(v.pointerType))return;let n=Vl(S.current),r=Bl(x.current,`open`,v.pointerType),i=il(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(Ic(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(U(t,i)){c=t;break}}Ic(o)&&Ic(s)&&!e.context.triggerElements.hasElement(o)&&U(o,s)&&(c=s);let l=c!=null&&O(s,c,i),u=e.select(`open`),d=T.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&y.current,p=!l&&Ic(c)&&Ic(s)&&U(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;h?D()&&e.setOpen(!0,W(ql,t,c)):m||(r?v.openChangeTimeout.start(r,()=>{g&&D()&&e.setOpen(!0,W(ql,t,c))}):g&&D()&&e.setOpen(!0,W(ql,t,c)))}function o(n){if(E()){A();return}k();let r=Pu(e.select(`domReferenceElement`));v.restTimeout.clear(),v.restTimeoutPending=!1;let i=h.current.floatingContext??d?.();if(!jl(n.relatedTarget,e.context.triggerElements)){if(b.current&&i){e.select(`open`)||v.openChangeTimeout.clear();let a=c.current;v.handler=b.current({...i,tree:_,x:n.clientX,y:n.clientY,onClose(){A(),k(),C.current&&!E()&&a===e.select(`domReferenceElement`)&&t(n,!0)}}),r.addEventListener(`mousemove`,v.handler),v.handler(n)}else v.pointerType===`touch`&&U(e.select(`floatingElement`),n.relatedTarget)||t(n)}}function l(e){U(r,e.relatedTarget)||(v.openChangeTimeout.clear(),v.restTimeout.clear(),v.restTimeoutPending=!1)}let f=m?hu(r,`mouseout`,l):void 0;return s?gu(hu(r,`mousemove`,i,{once:!0}),hu(r,`mouseenter`,i),hu(r,`mouseleave`,o),f):gu(hu(r,`mouseenter`,i),hu(r,`mouseleave`,o),f)},[k,A,h,x,e,n,b,v,u,O,E,a,s,S,c,_,C,d,T,D,m]),V.useMemo(()=>{if(!n)return;function t(e){v.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){let{nativeEvent:n}=t,r=t.currentTarget,i=e.select(`domReferenceElement`),o=e.select(`open`),s=O(i,r,t.target);if(a&&!kc(v.pointerType))return;if(o&&s&&v.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=v.handleCloseOptions?.getScope?.()??r.ownerDocument.body;Em(v,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=Vl(S.current);if(o&&!s||c===0||!s&&v.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;v.restTimeout.clear();function l(){if(v.restTimeoutPending=!1,E())return;let t=e.select(`open`);!v.blockMouseMove&&(!t||s)&&D()&&e.setOpen(!0,W(ql,n,r))}v.pointerType===`touch`?Xf.flushSync(()=>{l()}):s&&o?l():(v.restTimeoutPending=!0,v.restTimeout.start(c,l))}}},[n,v,E,O,a,e,S,D])}function jm(e){return xc&&e.movementX===0&&e.movementY===0}function Mm(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function Nm(e,t){return Mm(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Pm(e,t,n){return Mm(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Fm(e,t,n){return Mm(t,n?e===sl:e===cl,e===ul)}function Im(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Mm(t,n?e===cl:e===sl,e===ll)}function Lm(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,triggerOrientation:_=g,parentOrientation:v,id:y,resetOnPointerLeave:b=!0,externalTree:x,nestedReturnFocusRef:S,grid:C}=t,w=C!=null,T=e.useState(`open`),E=e.useState(`floatingElement`),D=e.useState(`domReferenceElement`),O=e.context.dataRef,k=Rl(E),A=Il(D),j=Cu(k),M=op(),N=sp(x),P=V.useRef(f),F=V.useRef(o??-1),I=V.useRef(null),L=V.useRef(!0),R=K(e=>{i(F.current===-1?null:F.current,e)}),ee=V.useRef(!!E),z=V.useRef(T),te=V.useRef(!1),ne=V.useRef(!1),re=V.useRef(null),ie=Cu(h),ae=Cu(T),oe=Cu(o),se=Cu(b),ce=Nu(),le=Nu(),ue=K(()=>{ce.cancel();function e(e){d||(re.current=Yd(e,{sync:te.current,preventScroll:!0}))}let t=n.current[F.current],r=ne.current;t&&e(t),(te.current?e=>e():e=>ce.request(e))(()=>{let i=n.current[F.current]||t;i&&(t||e(i),ge&&(r||!L.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});H(()=>{O.current.orientation=g},[O,g]),H(()=>{T||(I.current=null),T&&f===`auto`||(P.current=f)},[T,f]),H(()=>{a&&(T&&E?(F.current=o??-1,P.current&&o!=null&&(ne.current=!0,R())):ee.current&&(F.current=-1,R()))},[a,T,E,o,R]),H(()=>{if(a){if(!T)te.current=!1;else if(E){if(r==null){if(te.current=!1,oe.current!=null)return;if(ee.current&&(F.current=-1,ue()),(!z.current||!ee.current)&&P.current&&(I.current!=null||P.current===!0&&I.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>le.request(e):queueMicrotask)(t),e+=1):(F.current=I.current==null||Pm(I.current,_,u)||l?md(n):hd(n),I.current=null,R())};t()}}else pd(n.current,r)||(F.current=r,ue(),ne.current=!1)}}},[a,T,E,r,oe,l,n,_,u,R,ue,le]),H(()=>{if(!a||E||!N||d||!ee.current)return;let e=N.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=nl(Pu(D??t??null)),r=e.some(e=>e.context&&U(e.context.elements.floating,n));t&&!r&&L.current&&t.focus({preventScroll:!0})},[a,E,D,N,M,d]),H(()=>{z.current=T,ee.current=!!E});let de=r!=null,fe=K(e=>{if(!ae.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(F.current!==t||r!==t)&&(F.current=t,R(e))}),pe=K(()=>v??N?.nodesRef.current.find(e=>e.id===M)?.context?.dataRef?.current.orientation),me=K(()=>md(n,ie.current)),he=K(t=>{if(L.current=!1,te.current=!0,t.which===229||!ae.current&&t.currentTarget===j.current)return;if(l&&Im(t.key,g,u,w)){Nm(t.key,pe())||Tc(t),e.setOpen(!1,W(ru,t.nativeEvent));let n=S?.current??D;Lc(n)&&n.focus();return}r!=null&&r!==F.current&&!pd(n.current,r)&&(F.current=r);let i=F.current,a=md(n,h),o=hd(n,h);if(A||(t.key===`Home`&&(Tc(t),F.current=a,R(t)),t.key===`End`&&(Tc(t),F.current=o,R(t))),C!=null){let e=C(t,F.current,n,g,c,u,h,a,o);if(e!=null&&e!==F.current&&(F.current=e,R(t)),g===`both`)return}if(Nm(t.key,g)){Tc(t);let e=nl(t.currentTarget.ownerDocument);if(T&&!d&&U(t.currentTarget,e)&&!n.current.some(t=>t!=null&&U(t,e))){F.current=Pm(t.key,g,u)?a:o,R(t),r===F.current&&ue();return}let{index:l,wrapped:f}=gd(n.current,i,{decrement:!Pm(t.key,g,u),loopFocus:c,allowEscape:s,disabledIndices:h,minIndex:a,maxIndex:o});f&&(te.current=!1),F.current=l,R(t)}}),ge=V.useMemo(()=>({onFocus(e){te.current=!0,fe(e)},onClick({currentTarget:e}){d||e.focus({preventScroll:!0})},onMouseMove(e){jm(e)||(te.current=!0,ne.current=!1,p&&fe(e))},onPointerLeave(e){if(!ae.current||!L.current||e.pointerType===`touch`)return;te.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&se.current&&(re.current?.(),re.current=null,F.current=-1,R(e),!d)){let e=j.current,t=nl(Pu(e));e&&U(e,t)&&e.focus({preventScroll:!0})}}}),[fe,ae,j,p,n,R,se,d]),_e=V.useMemo(()=>d&&T&&de&&{"aria-activedescendant":`${y}-${r}`},[d,T,de,y,r]),ve=V.useMemo(()=>({...A?{}:_e,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&T&&!d){let n=il(t.nativeEvent);if(n&&!U(j.current,n))return;Tc(t);let r=W(tu,t.nativeEvent);e.setOpen(!1,r);let i=S?.current??D;!r.isCanceled&&Lc(i)&&i.focus()}else he(t)},onPointerMove(e){jm(e)||(L.current=!0)}}),[_e,he,j,A,e,T,d,D,S]),ye=V.useMemo(()=>{function t(t){e.setOpen(!0,W(ru,t.nativeEvent,t.currentTarget))}function n(e){f===`auto`&&Dc(e.nativeEvent)&&(P.current=!d)}function r(e){P.current=f,f===`auto`&&Oc(e.nativeEvent)&&(P.current=!0)}return{onKeyDown(n){let r=e.select(`open`);L.current=!1;let i=n.key.startsWith(`Arrow`),a=Fm(n.key,pe(),u),o=Nm(n.key,r?g:_),s=(l?a:o)||n.key===`Enter`||n.key.trim()===``;if(d&&r&&(!l||Pl(n.currentTarget)))return he(n);if(r||m||!i){if(s){let e=Nm(n.key,pe());I.current=l&&e?null:n.key}l?a&&(Tc(n),r?(F.current=me(),R(n),d&&j.current?.focus()):t(n)):o&&(oe.current!=null&&(F.current=oe.current),Tc(n),!r&&m?t(n):he(n),r&&R(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!d&&(F.current=-1,R(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[he,f,me,l,R,e,m,g,_,pe,u,oe,d,j]),be=V.useMemo(()=>({..._e,...ye}),[_e,ye]);return V.useMemo(()=>a?{reference:be,floating:ve,item:ge,trigger:ye}:{},[a,be,ve,ye,ge])}function Rm(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=K(s),f=e.useState(`open`),p=lc(),m=V.useRef(``),h=V.useRef(u??i??-1),g=V.useRef(null),_=K(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!xd(n)||n?.matches(`:disabled`)?!1:o==null||!yd(ec,e,o)}function c(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&s(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(Tc(e),d?.(!0)),m.current.length>0&&m.current[0]!==` `&&c(_,m.current)===-1&&e.key!==` `&&d?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(Tc(e),d?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&s(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,d?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=c(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,d?.(!1)):(a?.(b,e),g.current=b)}),v=K(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);U(r,n)||U(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});H(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let y=V.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return V.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var zm=.1,Bm=zm*zm,Vm=.5;function Hm(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Um(e,t,n,r,i,a,o,s,c,l){let u=!1;return Hm(e,t,n,r,i,a)&&(u=!u),Hm(e,t,i,a,o,s)&&(u=!u),Hm(e,t,o,s,c,l)&&(u=!u),Hm(e,t,c,l,n,r)&&(u=!u),u}function Wm(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Gm(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function Km(e={}){let{blockPointerEvents:t=!1}=e,n=new cc,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*Bm;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=il(r),g=r.type===`mouseleave`,_=U(u,h),v=U(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Ic(r.relatedTarget)&&U(u,r.relatedTarget))return;function y(){return!!(s&&Gd(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=Gm(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=Gm(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=Gm(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=Gm(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Wm(d,f,x)||!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?Vm/2:Vm*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+Vm+1,o=C||T?S.bottom-Vm:S.top,s=C?T?S.bottom-Vm:S.top:S.bottom-Vm;M=Um(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?Vm/2:Vm*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-Vm,o=C||T?S.top+Vm:S.bottom,s=C?T?S.top+Vm:S.bottom:S.top+Vm;M=Um(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?Vm/2:Vm*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+Vm+1,o=w||E?S.right-Vm:S.left,s=w?E?S.right-Vm:S.left:S.right-Vm;M=Um(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?Vm/2:Vm*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-Vm,o=w||E?S.left+Vm:S.right,s=w?E?S.left+Vm:S.right:S.left+Vm;M=Um(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function qm(e,t,n){let{reference:r,floating:i}=e,a=Zu(t),o=Qu(t),s=Xu(o),c=qu(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=Ju(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Jm(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}=Ku(t,e),p=ud(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=dd(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=dd(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 Ym=50,Xm=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Jm},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=qm(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<Ym&&(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}=qm(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Zm=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}=Ku(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=qu(r),_=Zu(o),v=qu(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[cd(o)]:ed(o)),x=p!==`none`;!d&&x&&b.push(...sd(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=$u(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`||_===Zu(t)||T.every(e=>Zu(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=Zu(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}if(r!==n)return{reset:{placement:n}}}return{}}}},Qm=new Set([`left`,`top`]);async function $m(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=qu(n),s=Ju(n),c=Zu(n)===`y`,l=Qm.has(o)?-1:1,u=a&&c?-1:1,d=Ku(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 eh=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 $m(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}}}}},th=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}=Ku(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Zu(i),p=Yu(f),m=u[p],h=u[f],g=(e,t)=>Gu(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}}}}}},nh=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}=Ku(e,t),u={x:n,y:r},d=Zu(i),f=Yu(d),p=u[f],m=u[d],h=Ku(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=Qm.has(qu(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}}}},rh=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}=Ku(e,t),c=await i.detectOverflow(t,s),l=qu(n),u=Ju(n),d=Zu(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=zu(p-c[m],g),y=zu(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*Bu(c.left,c.right):S=p-2*Bu(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 ih(e){let t=Xc(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Lc(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Vu(n)!==a||Vu(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function ah(e){return Ic(e)?e:e.contextElement}function oh(e){let t=ah(e);if(!Lc(t))return Uu(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=ih(t),o=(a?Vu(n.width):n.width)/r,s=(a?Vu(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var sh=Uu(0);function ch(e){let t=Nc(e);return!Jc()||!t.visualViewport?sh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function lh(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Nc(e)}function uh(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=ah(e),o=Uu(1);t&&(r?Ic(r)&&(o=oh(r)):o=oh(e));let s=lh(a,n,r)?ch(a):Uu(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=Nc(a),t=Ic(r)?Nc(r):r,n=e,i=tl(n);for(;i&&t!==n;){let e=oh(i),t=i.getBoundingClientRect(),r=Xc(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=Nc(i),i=tl(n)}}return dd({width:u,height:d,x:c,y:l})}function dh(e,t){let n=Zc(e).scrollLeft;return t?t.left+n:uh(Pc(e)).left+n}function fh(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-dh(e,n),y:n.top+t.scrollTop}}function ph(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Pc(r),s=t?Vc(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Uu(1),u=Uu(0),d=Lc(r);if((d||!a)&&((Mc(r)!==`body`||zc(o))&&(c=Zc(r)),d)){let e=uh(r);l=oh(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?fh(o,c):Uu(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 mh(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function hh(e){let t=Zc(e),n=e.ownerDocument.body,r=Bu(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Bu(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+dh(e),o=-t.scrollTop;return Xc(n).direction===`rtl`&&(a+=Bu(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var gh=25;function _h(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Nc(e),a=Pc(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Jc()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(dh(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<=gh&&(s-=o)}return{width:s,height:c,x:l,y:u}}function vh(e,t){let n=uh(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=oh(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function yh(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=_h(e,n,t);else if(t===`document`)r=hh(Pc(e));else if(Ic(t))r=vh(t,n);else{let n=ch(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return dd(r)}function bh(e,t){let n=t.get(e);if(n)return n;let r=el(e,[],!1).filter(e=>Ic(e)&&Mc(e)!==`body`),i=null,a=Xc(e).position===`fixed`,o=a?Qc(e):e;for(;Ic(o)&&!Yc(o);){let e=Xc(o),t=Kc(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Qc(o)}return t.set(e,r),r}function xh(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Vc(t)?[]:bh(t,this._c):[].concat(n),r],o=yh(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=yh(t,a[e],i);s=Bu(n.top,s),c=zu(n.right,c),l=zu(n.bottom,l),u=Bu(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Sh(e){let{width:t,height:n}=ih(e);return{width:t,height:n}}function Ch(e,t,n){let r=Lc(t),i=Pc(t),a=n===`fixed`,o=uh(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Uu(0);if((r||!a)&&((Mc(t)!==`body`||zc(i))&&(s=Zc(t)),r)){let e=uh(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=dh(i));let l=i&&!r&&!a?fh(i,s):Uu(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 wh(e){return Xc(e).position===`static`}function Th(e,t){if(!Lc(e)||Xc(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Pc(e)===n&&(n=n.ownerDocument.body),n}function Eh(e,t){let n=Nc(e);if(Vc(e))return n;if(!Lc(e)){let t=Qc(e);for(;t&&!Yc(t);){if(Ic(t)&&!wh(t))return t;t=Qc(t)}return n}let r=Th(e,t);for(;r&&Bc(r)&&wh(r);)r=Th(r,t);return r&&Yc(r)&&wh(r)&&!Kc(r)?n:r||qc(e)||n}var Dh=async function(e){let t=this.getOffsetParent||Eh,n=this.getDimensions,r=await n(e.floating);return{reference:Ch(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Oh(e){return Xc(e).direction===`rtl`}var kh={convertOffsetParentRelativeRectToViewportRelativeRect:ph,getDocumentElement:Pc,getClippingRect:xh,getOffsetParent:Eh,getElementRects:Dh,getClientRects:mh,getDimensions:Sh,getScale:oh,isElement:Ic,isRTL:Oh};function Ah(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function jh(e,t,n){let r=null,i,a=Pc(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=Hu(d),h=Hu(a.clientWidth-(u+f)),g=Hu(a.clientHeight-(d+p)),_=Hu(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Bu(0,zu(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Ah(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=Nc(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Mh(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=ah(e),u=i||a?[...l?el(l):[],...t?el(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?jh(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?uh(e):null;c&&g();function g(){let t=uh(e);h&&!Ah(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 Nh=eh,Ph=th,Fh=Zm,Ih=rh,Lh=nh,Rh=(e,t,n)=>{let r=new Map,i=n??{},a={...kh,...i.platform,_c:r};return Xm(e,t,{...i,platform:a})},zh=typeof document<`u`?V.useLayoutEffect:function(){};function Bh(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(!Bh(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)&&!Bh(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Vh(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Hh(e,t){let n=Vh(e);return Math.round(t*n)/n}function Uh(e){let t=V.useRef(e);return zh(()=>{t.current=e}),t}function Wh(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]=V.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=V.useState(r);Bh(f,r)||p(r);let[m,h]=V.useState(null),[g,_]=V.useState(null),v=V.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=V.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=V.useRef(null),C=V.useRef(null),w=V.useRef(u),T=c!=null,E=Uh(c),D=Uh(i),O=Uh(l),k=V.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Rh(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Bh(w.current,t)&&(w.current=t,Xf.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);zh(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=V.useRef(!1);zh(()=>(A.current=!0,()=>{A.current=!1}),[]),zh(()=>{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 j=V.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=V.useMemo(()=>({reference:b,floating:x}),[b,x]),N=V.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=Hh(M.floating,u.x),r=Hh(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Vh(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return V.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var Gh=(e,t)=>{let n=Nh(e);return{name:n.name,fn:n.fn,options:[e,t]}},Kh=(e,t)=>{let n=Ph(e);return{name:n.name,fn:n.fn,options:[e,t]}},qh=(e,t)=>({fn:Lh(e).fn,options:[e,t]}),Jh=(e,t)=>{let n=Fh(e);return{name:n.name,fn:n.fn,options:[e,t]}},Yh=(e,t)=>{let n=Ih(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xh={...vm,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,appliedTriggerProps:(e,t)=>t?e.activeTriggerProps:void 0,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Zh=class extends lm{constructor(e,t,n){let r=new Xp;super(Qh(e,r,t,n),$h(r),Xh)}setOpen=(e,t)=>{Wp(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,W(Kl,e))}};function Qh(e,t,n,r=!1){return{...fm(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function $h(e){return{popupRef:V.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var eg=Xs(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=Rp((e,t)=>new Zh({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),h=!t&&m,g=p.useState(`activeTriggerId`),_=p.useState(`mounted`),v=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),Kp(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:y,transitionStatus:b}=qp(h,p),x=p.useState(`isInstantPhase`),S=p.useState(`instantType`),C=p.useState(`lastOpenChangeReason`),w=V.useRef(null);H(()=>{m&&t&&p.setOpen(!1,W(cu))},[m,t,p]),H(()=>{b===`ending`&&C===`none`||b!==`ending`&&x?(S!==`delay`&&(w.current=S),p.set(`instantType`,`delay`)):w.current!==null&&(p.set(`instantType`,w.current),w.current=null)},[b,x,C,S,p]),H(()=>{h&&(g??p.set(`payload`,void 0))},[p,g,h]),V.useImperativeHandle(o,()=>({unmount:y,close:()=>p.setOpen(!1,W(lu))}),[y,p]);let T=h||_||!t&&a!==`none`;return(0,G.jsxs)(ic.Provider,{value:p,children:[l&&(0,G.jsx)(zp,{handle:l,store:p}),T&&(0,G.jsx)(tg,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function tg({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=Dp(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=wp(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=V.useMemo(()=>xf(a.reference,i.reference),[a.reference,i.reference]);return Jp(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??tc}),null}function ng(e){return ff(e,`base-ui`)}var rg=V.createContext(void 0);function ig(){return V.useContext(rg)}var ag=`data-base-ui-tooltip-trigger`;function og(e){let t=il(e);return Ic(t)?t:null}var sg=Zs(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d,...f}=e,p=ac(!0),m=ym(a)??p;if(!m)throw Error(rc(82));let h=ng(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),y=V.useRef(null),b=u??0,{registerTrigger:x,isMountedByThisTrigger:S}=Gp(h,y,m,{payload:o,closeOnClick:l,closeDelay:b}),C=ig(),{activeIdRef:w,delayRef:T,isInstantPhase:E,hasProvider:D}=mu(v,{open:_}),O=Dm(v);m.useSyncedValue(`isInstantPhase`,E);let k=m.useState(`disabled`),A=s??k,j=Cu(A),M=m.useState(`trackCursorAxis`),N=m.useState(`disableHoverablePopup`),P=V.useRef(!1),F=lc(),I=V.useRef(void 0);function L(){return D&&w.current!=null?0:c??C??600}function R(e){let t=y.current;if(!t||!e)return!1;let n=rl(e,`[${ag}]`);return n!==null&&n!==t&&U(t,n)}function ee(e){let t=R(e);return P.current=t,t&&(O.openChangeTimeout.clear(),O.restTimeout.clear(),O.restTimeoutPending=!1,F.clear()),t}let z=Am(v,{enabled:!A,mouseOnly:!0,move:!1,handleClose:!N&&M!==`both`?Km():null,restMs:L,delay(){return u==null&&D?{close:Bl(T.current,`close`)}:{close:b}},triggerElementRef:y,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!P.current}}),te=Sm(v,{enabled:!A}).reference,ne=e=>{let t=P.current,n=og(e),r=ee(n),i=y.current,a=i&&n&&U(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`)m.setOpen(!1,W(ql,e));else if(t&&!r&&a&&!j.current&&!m.select(`open`)&&i&&kc(I.current)){let t=()=>{P.current||j.current||m.select(`open`)||m.setOpen(!0,W(ql,e,i))},n=L();n===0?(F.clear(),t()):F.start(n,t)}},re=m.useState(`appliedTriggerProps`,S||M!==`none`);return Pf(`button`,e,{state:{open:_},ref:[t,x,y],props:[z,te,re,{onMouseOver(e){ne(e.nativeEvent)},onFocus(e){R(og(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){P.current=!1,F.clear(),I.current=void 0},onPointerEnter(e){I.current=e.pointerType},onPointerDown(e){I.current=e.pointerType,m.set(`closeOnClick`,l),l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},id:h,[Al]:A?``:void 0,[ag]:A?void 0:``},f],stateAttributesMapping:El})}),cg=V.createContext(void 0);function lg(){let e=V.useContext(cg);if(e===void 0)throw Error(rc(70));return e}var ug=V.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:l}=ep({container:r,ref:t,componentProps:e,elementProps:s});return!l&&!c?null:(0,G.jsxs)(V.Fragment,{children:[l,c&&Xf.createPortal(n,c)]})}),dg=V.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return ac().useState(`mounted`)||n?(0,G.jsx)(cg.Provider,{value:n,children:(0,G.jsx)(ug,{ref:t,...r})}):null}),fg=V.createContext(void 0);function pg(){let e=V.useContext(fg);if(e===void 0)throw Error(rc(71));return e}function mg(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=V.useState(null),d=V.useRef(null),f=sp(n),p=V.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=Wh({...e,elements:{...p,...l&&{reference:l}}}),h=V.useCallback(e=>{let t=Ic(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=V.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=V.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=V.useMemo(()=>({...m,dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:g,elements:_,nodeId:t,rootStore:r}),[m,g,_,t,r,s,c]);return H(()=>{o&&(d.current=o)},[o]),H(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),V.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}var hg=V.createContext(void 0);function gg(){return V.useContext(hg)?.direction??`ltr`}var _g=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}=Ku(e,t)||{};if(l==null)return{};let d=ud(u),f={x:n,y:r},p=Qu(i),m=Xu(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=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),E=Math.min(d[v],w),D=T,O=S-h[m]-E,k=S/2-h[m]/2+C,A=Gu(D,k,O),j=!c.arrow&&Ju(i)!=null&&k!==A&&a.reference[m]/2-(k<D?T:E)-h[m]/2<0,M=j?k<D?k-D:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),vg=(e,t)=>{let{name:n,fn:r}=_g(e);return{name:n,fn:r,options:[e,t]}},yg={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},bg={sideX:`left`,sideY:`top`},xg=`--available-width`,Sg=`--available-height`,Cg=`--anchor-width`,wg=`--anchor-height`,Tg=`--transform-origin`,Eg=xg,Dg=Sg;function Og(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function kg(e,t,n){let{rects:r,placement:i}=e;return{side:Og(t,qu(i),n),align:Ju(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function Ag(e){return jg(e,mg)}function jg(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,C=_.side||`flip`,w=_.align||`flip`,T=_.fallbackAxisSide||`end`,E=v?.crossAxis??!1,D=v?.rootBoundary,O=typeof n==`function`?n:void 0,k=K(O),A=O?k:n,j=Cu(n),M=Cu(g),N=gg()===`rtl`,[P,F]=V.useState(null);!g&&P!==null&&F(null);let I=x===`placement`,L=P?qu(P):null,R=P&&I?Ju(P)||`center`:null,ee=L||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":N?`left`:`right`,"inline-start":N?`right`:`left`}[i],z=R||o,te=z===`center`?ee:`${ee}-${z}`,ne=l;typeof ne==`number`?ne={top:ne,right:ne,bottom:ne,left:ne}:ne&&={top:ne.top||0,right:ne.right||0,bottom:ne.bottom||0,left:ne.left||0};let re=+(i===`bottom`),ie=+(i===`top`),ae=+(i===`right`),oe=+(i===`left`),se={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:ne},ce=V.useRef(null),le=Cu(a),ue=Cu(s),de=typeof a==`function`?0:a,fe=typeof s==`function`?0:s,pe=[];p&&pe.push(p),pe.push(Gh(e=>{let t=kg(e,i,N),n=typeof le.current==`function`?le.current(t):le.current,r=typeof ue.current==`function`?ue.current(t):ue.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[de,fe,N,i]));let me=w===`none`&&C!==`shift`,he=!me&&(u||E||C===`shift`),ge=C===`none`?null:Jh({...se,padding:{top:ne.top+1+re,right:ne.right+1+oe,bottom:ne.bottom+1+ie,left:ne.left+1+ae},mainAxis:!E&&C===`flip`,crossAxis:w===`flip`&&`alignment`,fallbackAxisSideDirection:T}),_e=me?null:Kh({...se,rootBoundary:D,mainAxis:w!==`none`,crossAxis:he,limiter:u||E?void 0:qh(e=>{if(!ce.current)return{};let{width:t,height:n}=ce.current.getBoundingClientRect(),r=Zu(qu(e.placement)),i=r===`y`?t:n,a=r===`y`?ne.left+ne.right:ne.top+ne.bottom;return{offset:i/2+a/2}})},[se,u,E,D,ne,w]);C===`shift`||w===`shift`||z===`center`?pe.push(_e,ge):pe.push(ge,_e),pe.push(Yh({...se,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!M.current)return;let i=e.style;i.setProperty(Eg,`${t}px`),i.setProperty(Dg,`${n}px`);let a=Nc(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(Cg,`${u}px`),i.setProperty(wg,`${d}px`)}}),vg(e=>({element:ce.current||Pu(e.elements.floating).createElement(`div`),padding:ce.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=qu(r),u=Ju(r),d=Zu(l)===`y`,f=ce.current,p=typeof a==`function`?a(kg(e,i,N)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return he&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(Tg,d?`${m} ${h}`:`${h} ${m}`),{}}},yg,b),H(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let ve=V.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:ye,elements:be,x:B,y:xe,middlewareData:Se,update:Ce,placement:we,context:Te,isPositioned:Ee,floatingStyles:De}=t({rootContext:h,open:m?g:void 0,placement:te,middleware:pe,strategy:r,whileElementsMounted:m?void 0:(...e)=>Mh(...e,ve),nodeId:y,externalTree:S}),{sideX:Oe,sideY:ke}=Se.adaptiveOrigin||bg,Ae=Ee?r:`fixed`,je=V.useMemo(()=>{let e;return e=Ee?b?{position:Ae,[Oe]:B,[ke]:xe}:{...De,position:Ae}:{position:Ae,top:0,left:0},e[Eg]=`100vw`,e[Dg]=`100vh`,Ee||(e.opacity=0),e},[b,Ae,Oe,B,ke,xe,De,Ee]),Me=V.useRef(null);H(()=>{if(!g)return;let e=j.current,t=typeof e==`function`?e():e,n=(Mg(t)?t.current:t)||null;n!==Me.current&&(ye.setPositionReference(n),Me.current=n)},[g,ye,A,j]),V.useEffect(()=>{if(!g)return;let e=j.current;typeof e!=`function`&&Mg(e)&&e.current!==Me.current&&(ye.setPositionReference(e.current),Me.current=e.current)},[g,ye,A,j]),V.useEffect(()=>{if(m&&g&&be.reference&&be.floating)return Mh(be.reference,be.floating,Ce,ve)},[m,g,be,Ce,ve]);let Ne=qu(we),Pe=Og(i,Ne,N),Fe=Ju(we)||`center`,Ie=!!Se.hide?.referenceHidden;H(()=>{x&&g&&Ee&&(Ne!==ee||I&&Fe!==z)&&F(we)},[x,I,g,Ee,we,Ne,Fe,ee,z]);let Le=V.useMemo(()=>({position:`absolute`,top:Se.arrow?.y,left:Se.arrow?.x}),[Se.arrow]),Re=Se.arrow?.centerOffset!==0;return V.useMemo(()=>({positionerStyles:je,arrowStyles:Le,arrowRef:ce,arrowUncentered:Re,side:Pe,align:Fe,physicalSide:Ne,anchorHidden:Ie,refs:ye,context:Te,isPositioned:Ee,update:Ce}),[je,Le,ce,Re,Pe,Fe,Ne,Ie,ye,Te,Ee,Ce])}function Mg(e){return e!=null&&`current`in e}function Ng(e){return e===`starting`?Vf:tc}function Pg(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),Pf(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},Ng(r),i],stateAttributesMapping:Ol})}var Fg=V.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=Jf,style:g,..._}=e,v=ac(),y=lg(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=Ag({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:v.useState(`adaptiveOrigin`)}),O=Pg(e,V.useMemo(()=>({open:b,side:D.side,align:D.align,anchorHidden:D.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,D.side,D.align,D.anchorHidden,S,T]),{styles:D.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,G.jsx)(fg.Provider,{value:D,children:O})}),Ig=V.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=ac(),{side:s,align:c}=pg(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);Pp({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Om(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return Pf(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[Ip,f,Ng(d),a],stateAttributesMapping:kl})}),Lg=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=V.useMemo(()=>({open:t,close:n}),[t,n]);return(0,G.jsx)(rg.Provider,{value:t,children:(0,G.jsx)(pu,{delay:i,timeoutMs:r,children:e.children})})};function Rg(e){return mf(19)?e:e?`true`:void 0}function zg(e){let[t,n]=V.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}var Bg=/(?<!`)(`+)(?!`)(.+?)(?<!`)\1(?!`)/gu,Vg=e=>e.startsWith(` `)&&e.endsWith(` `)?e.slice(1,-1):e,Hg=e=>{let t=[],n=``,r=0;for(let i of e.matchAll(Bg)){let a=i[2]??``;a.trim()!==``&&(n+=e.slice(r,i.index),n!==``&&t.push({code:!1,text:n}),n=``,t.push({code:!0,text:Vg(a)}),r=i.index+i[0].length)}return n+=e.slice(r),n===``?t:[...t,{code:!1,text:n}]},Ug=e=>Hg(e).map(e=>e.text).join(``),Wg=({text:e})=>Hg(e).map(({code:e,text:t},n)=>e?(0,G.jsx)(`code`,{children:t},n):t),Gg={keys:`_keys_pj1z3_6`,key:`_key_pj1z3_6`,empty:`_empty_pj1z3_37`,emptyTitle:`_emptyTitle_pj1z3_47`,emptyBody:`_emptyBody_pj1z3_57`,emptyCommand:`_emptyCommand_pj1z3_63`},Kg=({keys:e})=>(0,G.jsx)(`span`,{className:Gg.keys,children:e.map(e=>(0,G.jsx)(`kbd`,{className:Gg.key,children:e},e))}),qg={positioner:`_positioner_9bvkc_6`,popup:`_popup_9bvkc_12`,panel:`_panel_9bvkc_45 _popup_9bvkc_12`,title:`_title_9bvkc_52`,description:`_description_9bvkc_62`,item:`_item_9bvkc_69`,itemDetail:`_itemDetail_9bvkc_112`,separator:`_separator_9bvkc_125`,tip:`_tip_9bvkc_136`,tipPositioner:`_tipPositioner_9bvkc_142`,tipCommand:`_tipCommand_9bvkc_181`},Jg=300,Yg=({children:e})=>(0,G.jsx)(Lg,{delay:Jg,children:e}),Xg=(e,t)=>{let n=[t,e===void 0?void 0:`CLI: ${e}`].filter(e=>e!==void 0);return n.length===0?{}:{"aria-description":n.join(`. `)}},Zg=({children:e,label:t,cli:n,keys:r})=>(0,G.jsxs)(eg,{children:[(0,G.jsx)(sg,{render:e}),(0,G.jsx)(dg,{children:(0,G.jsx)(Fg,{className:qg.tipPositioner,sideOffset:6,children:(0,G.jsxs)(Ig,{className:qg.tip,children:[t===void 0?null:(0,G.jsx)(`span`,{children:(0,G.jsx)(Wg,{text:t})}),n===void 0?null:(0,G.jsx)(`code`,{className:qg.tipCommand,children:n}),r===void 0?null:(0,G.jsx)(Kg,{keys:r})]})})})]}),Qg=V.createContext(void 0);function $g(){let e=V.useContext(Qg);if(!e)throw Error(rc(73));return e}var e_=0;function t_(e){return e_+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${e_}`}function n_(e,t){if(typeof e==`string`)return{description:e};if(typeof e==`function`){let n=e(t);return typeof n==`string`?{description:n}:n}return e}function r_(e){let t=new Map,n=0,r=0;return e.forEach((e,i)=>{let a=e.transitionStatus===`ending`;t.set(e.id,{value:e,domIndex:i,visibleIndex:a?-1:n,offsetY:r}),r+=e.height||0,a||(n+=1)}),t}function i_(e,t){let n=0;return e.map(e=>{if(e.transitionStatus===`ending`)return e;let r=n>=t;return n+=1,e.limited===r?e:{...e,limited:r}})}var a_={toasts:e=>e.toasts,isEmpty:e=>e.toasts.length===0,toast:(e,t)=>e.toastMetadata.get(t)?.value,toastIndex:(e,t)=>e.toastMetadata.get(t)?.domIndex??-1,toastOffsetY:(e,t)=>e.toastMetadata.get(t)?.offsetY??0,toastVisibleIndex:(e,t)=>e.toastMetadata.get(t)?.visibleIndex??-1,focused:e=>e.focused,expanded:e=>e.hovering||e.focused,expandedOrOutOfFocus:e=>e.hovering||e.focused||!e.isWindowFocused,prevFocusElement:e=>e.prevFocusElement},o_=class extends lm{timers=new Map;areTimersPaused=!1;constructor(e){super({...e,toastMetadata:r_(e.toasts)},{},a_)}setViewport=e=>{this.set(`viewport`,e)};syncProviderProps(e,t){let n=this.state.limit!==t;if(this.state.timeout===e&&!n)return;let r={timeout:e,limit:t};if(n){let e=i_(this.state.toasts,t);r.toasts=e,r.toastMetadata=r_(e)}this.update(r)}disposeEffect=()=>()=>{this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear()};removeToast(e,t=!1){let n=a_.toastIndex(this.state,e);if(n===-1)return;let r=this.state.toasts[n];t||r?.onRemove?.();let i=[...this.state.toasts];i.splice(n,1),this.setToasts(i)}addToast=e=>{let{timeout:t,limit:n}=this.state,r=e.id||t_(`toast`);if(e.id){let t=a_.toast(this.state,e.id);if(t){if(t.transitionStatus===`ending`)this.removeToast(e.id,!0);else{let{id:t,transitionStatus:n,...r}=e;return this.updateToastInternal(e.id,r,!0,!0),e.id}}}let i={...e,id:r,updateKey:0,transitionStatus:`starting`},a=[i,...this.state.toasts];this.setToasts(i_(a,n));let o=i.timeout??t;return i.type!==`loading`&&o>0&&this.scheduleTimer(r,o,()=>this.closeToast(r)),a_.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),r};updateToast=(e,t)=>{let n=a_.toast(this.state,e);n&&n.transitionStatus!==`ending`&&this.updateToastInternal(e,typeof t==`function`?t(n):t,!1,!0)};updateToastInternal=(e,t,n=!1,r=!1)=>{let{timeout:i,toasts:a}=this.state,o=a_.toast(this.state,e);if(!o||o.transitionStatus===`ending`)return;let s={...o,...t,...r&&{updateKey:o.updateKey+1}};this.setToasts(a.map(t=>t.id===e?s:t));let c=s.timeout??i,l=o.timeout??i,u=Object.hasOwn(t,`timeout`),d=s.transitionStatus!==`ending`&&s.type!==`loading`&&c>0,f=this.timers.has(e),p=l!==c,m=o.type===`loading`;!d&&f?this.clearTimer(e):d&&(!f||p||u||m||n)&&(this.clearTimer(e),this.scheduleTimer(e,c,()=>this.closeToast(e)),a_.expandedOrOutOfFocus(this.state)&&this.pauseTimers())};closeToast=e=>{let t=e===void 0,{limit:n,toasts:r}=this.state,i;if(t)i=r,this.clearTimers();else{let t=a_.toast(this.state,e);if(!t)return;i=[t],this.clearTimer(e)}let a=i_(r.map(n=>t||n.id===e?{...n,transitionStatus:`ending`,height:0}:n),n);this.setToasts(a,!a.some(e=>e.transitionStatus!==`ending`)),i.forEach(e=>{e.transitionStatus!==`ending`&&e.onClose?.()}),this.handleFocusManagement(e)};promiseToast=(e,t)=>{let n=n_(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=n_(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=n_(t.error,e);return this.updateToast(r,{...n,type:`error`,timeout:n.timeout}),Promise.reject(e)});return{}.hasOwnProperty.call(t,`setPromise`)&&t.setPromise(i),i};pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(e=>{e.timeout&&(e.timeout.clear(),e.remaining=Math.max(e.remaining-(Date.now()-e.start),0))}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((e,t)=>{e.remaining=e.remaining>0?e.remaining:e.delay,e.timeout??=cc.create(),e.timeout.start(e.remaining,()=>{this.handleTimerFired(t),e.callback()}),e.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}handleDocumentPointerDown=e=>{if(e.pointerType!==`touch`)return;let t=il(e);U(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=a_.expandedOrOutOfFocus(this.state)?void 0:cc.create();i?.start(t,()=>{this.handleTimerFired(e),n()}),this.timers.set(e,{timeout:i,start:r,delay:t,remaining:t,callback:n})}clearTimers(){this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear(),this.areTimersPaused=!1}clearTimer(e){this.timers.get(e)?.timeout?.clear(),this.timers.delete(e),this.resetPausedStateIfNoTimersRemain()}handleTimerFired(e){this.timers.delete(e),this.resetPausedStateIfNoTimersRemain()}resetPausedStateIfNoTimersRemain(){this.timers.size===0&&(this.areTimersPaused=!1)}setToasts(e,t=e.length===0){let n={toasts:e,toastMetadata:r_(e)};t&&(n.hovering=!1,n.focused=!1),this.update(n)}handleFocusManagement(e){let t=nl(Pu(this.state.viewport));if(!this.state.viewport||!U(this.state.viewport,t)||!Ll(t))return;if(e===void 0){this.restoreFocusToPrevElement();return}let n=a_.toasts(this.state),r=a_.toastIndex(this.state,e),i=(e,t)=>{for(let r=e;r>=0&&r<n.length;r+=t)if(n[r].transitionStatus!==`ending`)return n[r];return null},a=i(r+1,1)??i(r-1,-1);a?a.ref?.current?.focus():this.restoreFocusToPrevElement()}},s_=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=Gs(()=>new o_({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return oc(a.disposeEffect),V.useEffect(function(){if(i)return i[` subscribe`](({action:e,options:t})=>{let n=t.id;e===`promise`&&t.promise?a.promiseToast(t.promise,t):e===`update`&&n?a.updateToast(n,t.updates):e===`close`?a.closeToast(n):a.addToast(t)})},[a,i]),(0,G.jsxs)(Qg.Provider,{value:a,children:[(0,G.jsx)(c_,{store:a,timeout:n,limit:r}),t]})};function c_(e){let{store:t,timeout:n,limit:r}=e;return H(()=>{t.syncProviderProps(n,r)},[t,n,r]),null}var l_=`--toast-frontmost-height`,u_=V.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=$g(),c=lc(),l=V.useRef(!1),u=V.useRef(!1),d=V.useRef(!1),f=s.useState(`isEmpty`),p=s.useState(`toasts`),m=s.useState(`focused`),h=s.useState(`expanded`),g=s.useState(`prevFocusElement`),_=p[0]?.height,v=p.some(e=>e.transitionStatus===`ending`),y=p.filter(e=>e.priority===`high`);V.useEffect(()=>{let e=s.state.viewport;if(!e||f)return;let t=Nc(e),n=Pu(e);function r(t){t.key===`F6`&&il(t)!==e&&(t.preventDefault(),s.set(`prevFocusElement`,nl(n)),e?.focus({preventScroll:!0}),s.pauseTimers(),s.set(`focused`,!0))}function i(e){il(e)===t&&(s.set(`isWindowFocused`,!1),s.pauseTimers())}function a(n){if(n.relatedTarget)return;let r=il(n),i=nl(Pu(e));r!==t&&U(e,r)&&Ll(i)||s.resumeTimers(),c.start(0,()=>s.set(`isWindowFocused`,!0))}return gu(hu(t,`keydown`,r),hu(t,`blur`,i,!0),hu(t,`focus`,a,!0),hu(n,`pointerdown`,s.handleDocumentPointerDown,!0))},[s,c,f]);function b(e){l.current=!0;let t=e.relatedTarget===s.state.viewport?p.find(e=>e.transitionStatus!==`ending`&&!e.limited):void 0;t?t.ref?.current?.focus():s.restoreFocusToPrevElement()}function x(e){e.key===`Tab`&&e.shiftKey&&il(e.nativeEvent)===s.state.viewport&&(e.preventDefault(),s.restoreFocusToPrevElement())}function S(){s.state.toasts.some(e=>e.transitionStatus===`ending`)||d.current||!u.current||(s.set(`hovering`,!1),s.select(`expandedOrOutOfFocus`)||s.resumeTimers(),u.current=!1)}V.useEffect(S,[v,s]);function C(){s.pauseTimers(),s.set(`hovering`,!0),u.current=!1}function w(){u.current=!0,S()}function T(e){e.pointerType===`touch`&&(d.current=!0)}function E(e){e.pointerType===`touch`&&(d.current=!1,S())}function D(){l.current?l.current=!1:m||Ll(nl(Pu(s.state.viewport)))&&(s.set(`focused`,!0),s.pauseTimers())}function O(e){m&&!U(s.state.viewport,e.relatedTarget)&&(s.set(`focused`,!1),s.select(`expandedOrOutOfFocus`)||s.resumeTimers())}let k={tabIndex:-1,role:`region`,"aria-live":`polite`,"aria-atomic":!1,"aria-relevant":`additions text`,"aria-label":`Notifications`,onMouseEnter:C,onMouseMove:C,onMouseLeave:w,onFocus:D,onBlur:O,onKeyDown:x,onClick:D,onPointerDown:T,onPointerUp:E,onPointerCancel:E,style:{[l_]:_?`${_}px`:void 0}},A={expanded:h},j=!f&&g&&(0,G.jsx)(Ru,{onFocus:b}),M=Pf(`div`,e,{ref:[t,s.setViewport],state:A,props:[k,o,{children:(0,G.jsxs)(V.Fragment,{children:[j,a,j]})}]});return(0,G.jsxs)(V.Fragment,{children:[j,M,!m&&y.length>0&&(0,G.jsx)(`div`,{style:Iu,children:y.map(e=>(0,G.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,G.jsx)(`div`,{children:e.title}),(0,G.jsx)(`div`,{children:e.description})]},e.id))})]})}),d_=V.createContext(void 0);function f_(){let e=V.useContext(d_);if(!e)throw Error(rc(66));return e}function p_(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function m_(e,t=!1){let{overflowY:n}=Xc(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}function h_(e,t){let n=(t??Nc(e).getComputedStyle(e)).transform,r=0,i=0,a=1;if(n&&n!==`none`){let e=n.match(/matrix(?:3d)?\(([^)]+)\)/);if(e){let t=e[1].split(`, `).map(parseFloat);t.length===6?(r=t[4],i=t[5],a=Math.sqrt(t[0]*t[0]+t[1]*t[1])):t.length===16&&(r=t[12],i=t[13],a=t[0])}}return{x:r,y:i,scale:a}}function g_(e,t,n){switch(e){case`up`:return-n;case`down`:return n;case`left`:return-t;case`right`:return t;default:return 0}}var __=`--toast-index`,v_=`--toast-offset-y`,y_=`--toast-height`,b_=`--toast-swipe-movement-x`,x_=`--toast-swipe-movement-y`,S_=`data-swipe-direction`,C_={...hl,swipeDirection(e){return e?{[S_]:e}:null}},w_=40,T_=10,E_=.5,D_=1,O_=`${Gf},${Kf}`,k_=V.forwardRef(function(e,t){let{toast:n,render:r,className:i,swipeDirection:a=[`down`,`right`],style:o,...s}=e,c=n.positionerProps?.anchor!==void 0,l=[];c||(l=Array.isArray(a)?a:[a]);let u=l.length>0,d=$g(),[f,p]=V.useState(void 0),[m,h]=V.useState(!1),[g,_]=V.useState(!1),[v,y]=V.useState({x:0,y:0}),[b,x]=V.useState({x:0,y:0,scale:1}),[S,C]=V.useState(),[w,T]=V.useState(),[E,D]=V.useState(null),O=V.useRef(null),k=V.useRef(void 0),A=V.useRef({x:0,y:0}),j=V.useRef({x:0,y:0,scale:1}),M=V.useRef(void 0),N=V.useRef(0),P=V.useRef(!1),F=V.useRef({x:0,y:0}),I=V.useRef(!1),L=V.useRef({x:0,y:0}),R=V.useRef(null),ee=V.useRef(null),z=d.useState(`toastIndex`,n.id),te=d.useState(`toastVisibleIndex`,n.id),ne=d.useState(`toastOffsetY`,n.id),re=d.useState(`focused`),ie=d.useState(`expanded`);Pp({open:n.transitionStatus!==`ending`,ref:O,onComplete(){n.transitionStatus===`ending`&&d.removeToast(n.id)}});let ae=K((e=!1)=>{let t=O.current;if(!t)return;let r=t.style.height;t.style.height=`auto`;let i=t.offsetHeight;t.style.height=r;function a(){d.updateToastInternal(n.id,{ref:O,height:i,transitionStatus:void 0})}e?Xf.flushSync(a):a()});H(()=>{let e=k.current;(n.transitionStatus===`starting`||e!==n.id)&&(e!==void 0&&(p(void 0),x({x:0,y:0,scale:1}),oe({x:0,y:0})),k.current=n.id,ae())},[ae,n.id,n.transitionStatus]);function oe(e){L.current=e,y(e)}H(()=>()=>{ee.current?.abort()},[]);function se(e,t){let n=e=>e>0?e**E_:-(Math.abs(e)**E_),r=e>0&&!l.includes(`right`)||e<0&&!l.includes(`left`),i=t>0&&!l.includes(`down`)||t<0&&!l.includes(`up`);return{x:r?n(e):e,y:i?n(t):t}}let ce=K(e=>{if(e.pointerId!==R.current)return;R.current=null,ee.current?.abort(),ee.current=null,h(!1),_(!1),D(null);let t=j.current;if(e.type===`pointercancel`||P.current){oe({x:t.x,y:t.y}),p(void 0);return}let r=L.current,i=r.x-t.x,a=r.y-t.y,o;for(let e of l)if(g_(e,i,a)>w_){o=e;break}o?(p(o),d.closeToast(n.id)):(oe({x:t.x,y:t.y}),p(void 0))});function le(e){if(e.button!==0||(e.pointerType===`touch`&&d.pauseTimers(),rl(il(e.nativeEvent),`button,a,input,textarea,[role="button"],${O_}`)))return;P.current=!1,M.current=void 0,N.current=0,R.current=e.pointerId,A.current={x:e.clientX,y:e.clientY},F.current=A.current;let t=e.currentTarget,n=h_(t);j.current=n,x(n),oe({x:n.x,y:n.y}),d.set(`hovering`,!0),h(!0),_(!1),D(null),I.current=!0,ee.current?.abort();let r=new AbortController;ee.current=r;let i=Pu(t);i.addEventListener(`pointerup`,ce,{signal:r.signal}),i.addEventListener(`pointercancel`,ce,{signal:r.signal}),t.setPointerCapture?.(e.pointerId)}function ue(e){if(e.pointerId!==R.current)return;e.preventDefault(),I.current&&=(A.current={x:e.clientX,y:e.clientY},!1);let{clientY:t,clientX:n,movementX:r,movementY:i}=e;(i<0&&t>F.current.y||i>0&&t<F.current.y)&&(F.current={x:F.current.x,y:t}),(r<0&&n>F.current.x||r>0&&n<F.current.x)&&(F.current={x:n,y:F.current.y});let a=n-A.current.x,o=t-A.current.y,s=t-F.current.y,c=n-F.current.x,u=E;if(!g&&Math.sqrt(a*a+o*o)>=D_){_(!0);let e=l.includes(`left`)||l.includes(`right`),t=l.includes(`up`)||l.includes(`down`);e&&t&&(u=Math.abs(a)>Math.abs(o)?`horizontal`:`vertical`,D(u))}let d;if(!M.current)u===`vertical`?o>0?d=`down`:o<0&&(d=`up`):u===`horizontal`?a>0?d=`right`:a<0&&(d=`left`):d=Math.abs(a)>=Math.abs(o)?a>0?`right`:`left`:o>0?`down`:`up`,d&&l.includes(d)&&(M.current=d,N.current=g_(d,a,o),p(d));else{let e=M.current,t=g_(e,c,s);t>w_?(P.current=!1,p(e)):!(l.includes(`left`)&&l.includes(`right`))&&!(l.includes(`up`)&&l.includes(`down`))&&N.current-t>=T_&&(P.current=!0)}let f=se(a,o),m=j.current.x,h=j.current.y,v=l.includes(`left`)||l.includes(`right`),y=l.includes(`up`)||l.includes(`down`);u!==`vertical`&&v&&(m+=f.x),u!==`horizontal`&&y&&(h+=f.y),oe({x:m,y:h})}function de(e){if(e.key===`Escape`){if(!O.current||!U(O.current,nl(Pu(O.current))))return;d.closeToast(n.id)}}V.useEffect(()=>{let e=O.current;if(!u||!e)return;function t(t){R.current!==null&&U(e,il(t))&&t.preventDefault()}return hu(e,`touchmove`,t,{passive:!1})},[u]);function fe(){let e=v.x-b.x,t=v.y-b.y;return{transition:m?`none`:void 0,transform:m?`translateX(${v.x}px) translateY(${v.y}px) scale(${b.scale})`:void 0,[b_]:`${e}px`,[x_]:`${t}px`}}let pe=n.priority===`high`,me={role:pe?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":S,"aria-describedby":w,"aria-hidden":pe&&!re?!0:void 0,onPointerDown:u?le:void 0,onPointerMove:u?ue:void 0,onPointerUp:u?ce:void 0,onPointerCancel:u?ce:void 0,onKeyDown:de,inert:Rg(n.limited),style:{...fe(),[__]:n.transitionStatus===`ending`?z:te,[v_]:`${ne}px`,[y_]:n.height?`${n.height}px`:void 0}},he=V.useMemo(()=>({toast:n,setTitleId:C,setDescriptionId:T,recalculateHeight:ae,visibleIndex:te,expanded:ie}),[n,C,T,ae,te,ie]),ge={transitionStatus:n.transitionStatus,expanded:ie,limited:n.limited||!1,type:n.type,swiping:m,swipeDirection:f},_e=Pf(`div`,e,{ref:[t,O],state:ge,stateAttributesMapping:C_,props:[me,s]});return(0,G.jsx)(d_.Provider,{value:he,children:_e})}),A_=V.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{visibleIndex:o,expanded:s,recalculateHeight:c}=f_(),l=V.useRef(null);return H(()=>{c();let e=l.current;if(!e||typeof ResizeObserver!=`function`||typeof MutationObserver!=`function`)return;let t=new ResizeObserver(()=>c(!0)),n=new MutationObserver(()=>c(!0));return t.observe(e),n.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{t.disconnect(),n.disconnect()}},[c]),Pf(`div`,e,{ref:[t,l],state:{expanded:s,behind:o>0},props:a})});function j_(e){return e==null||typeof e==`boolean`||e===``?!1:!Array.isArray(e)||e.some(j_)}function M_(e){return V.isValidElement(e)&&j_(e.props.children)}function N_(e,t,n){let{toast:r,setTitleId:i,setDescriptionId:a}=f_(),o=n===`title`?i:a,s=t??(n===`title`?r.title:r.description);return{id:ff(e),children:s,type:r.type,setId:o}}function P_(e,t,n){let r=M_(e);return H(()=>{if(r)return n(t),()=>{n(e=>e===t?void 0:e)}},[r,t,n]),r?e:null}var F_=V.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,children:o,...s}=e,{id:c,children:l,type:u,setId:d}=N_(a,o,`description`);return P_(Pf(`p`,e,{ref:t,state:{type:u},props:{...s,id:c,children:l}}),c,d)}),I_=V.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,children:o,...s}=e,{id:c,children:l,type:u,setId:d}=N_(a,o,`title`);return P_(Pf(`h2`,e,{ref:t,state:{type:u},props:{...s,id:c,children:l}}),c,d)}),L_=V.createContext(void 0);function R_(e=!1){let t=V.useContext(L_);if(t===void 0&&!e)throw Error(rc(16));return t}function z_(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:V.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function B_(e,t,{detail:n=0,pointerType:r=``}={}){e.dispatchEvent(new(Nc(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,pointerType:r,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function V_(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=V.useRef(null),s=R_(!0),c=a??s!==void 0,{props:l}=z_({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=V.useCallback(()=>{let e=o.current;H_(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return H(u,[u]),{getButtonProps:V.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return xf({onClick(e){t?e.preventDefault():n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(jf(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=H_(r),s=!i&&U_(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),B_(r,e))}else!l||i||!d&&!u?n&&s&&d&&e.preventDefault():e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),B_(r,e)))},onKeyUp(e){t||(jf(e),a?.(e),e.target===e.currentTarget&&i&&c&&H_(e.currentTarget)&&e.key===` `?e.preventDefault():e.baseUIHandlerPrevented||e.target!==e.currentTarget||i||c||e.defaultPrevented||e.key!==` `||(e.preventBaseUIHandler(),B_(e.currentTarget,e)))},onPointerDown(e){t?e.preventDefault():s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:K(e=>{o.current=e,u()})}}function H_(e){return Lc(e)&&e.tagName===`BUTTON`}function U_(e){return Lc(e)&&e.tagName===`A`&&!!e.href}var W_=V.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a,nativeButton:o=!0,...s}=e,c=$g(),{toast:l,expanded:u}=f_(),[d,f]=V.useState(!1),{getButtonProps:p,buttonRef:m}=V_({disabled:a,native:o}),h={type:l.type};return Pf(`button`,e,{ref:[t,m],state:h,props:[{"aria-hidden":!u&&!d,onClick(){c.closeToast(l.id)},onFocus(){f(!0)},onBlur(){f(!1)}},s,p]})}),G_=V.forwardRef(function(e,t){return(0,G.jsx)(ug,{ref:t,...e})});function K_(){let e=$g(),t=e.useState(`toasts`);return V.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function q_(){let e=new Set;function t(t){e.forEach(e=>e(t))}return{" subscribe":function(t){return e.add(t),()=>{e.delete(t)}},add(e){let n=e.id||t_(`toast`);return t({action:`add`,options:{...e,id:n,transitionStatus:`starting`}}),n},close(e){t({action:`close`,options:{id:e}})},update(e,n){t({action:`update`,options:{id:e,updates:n}})},promise(e,n){let r=e;return t({action:`promise`,options:{...n,promise:e,setPromise(e){r=e}}}),r}}}var J_=`M21.1,12.5L22.5,13.91L15.97,20.5L12.5,17L13.9,15.59L15.97,17.67L21.1,12.5M11,4A4,4 0 0,1 15,8A4,4 0 0,1 11,12A4,4 0 0,1 7,8A4,4 0 0,1 11,4M11,6A2,2 0 0,0 9,8A2,2 0 0,0 11,10A2,2 0 0,0 13,8A2,2 0 0,0 11,6M11,13C11.68,13 12.5,13.09 13.41,13.26L11.74,14.93L11,14.9C8.03,14.9 4.9,16.36 4.9,17V18.1H11.1L13,20H3V17C3,14.34 8.33,13 11,13Z`,Y_=`M15,4A4,4 0 0,1 19,8A4,4 0 0,1 15,12A4,4 0 0,1 11,8A4,4 0 0,1 15,4M15,5.9A2.1,2.1 0 0,0 12.9,8A2.1,2.1 0 0,0 15,10.1C16.16,10.1 17.1,9.16 17.1,8C17.1,6.84 16.16,5.9 15,5.9M15,13C17.67,13 23,14.33 23,17V20H7V17C7,14.33 12.33,13 15,13M15,14.9C12,14.9 8.9,16.36 8.9,17V18.1H21.1V17C21.1,16.36 17.97,14.9 15,14.9M5,13.28L2.5,14.77L3.18,11.96L1,10.08L3.87,9.83L5,7.19L6.11,9.83L9,10.08L6.8,11.96L7.45,14.77L5,13.28Z`,X_=`M12,2L1,21H23M12,6L19.53,19H4.47M11,10V14H13V10M11,16V18H13V16`,Z_=`M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z`,Q_=`M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z`,$_=`M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z`,ev=`M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z`,tv=`M13,18H11V10L7.5,13.5L6.08,12.08L12,6.16L17.92,12.08L16.5,13.5L13,10V18M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4Z`,nv=`M7.64,10.38C7.64,10.63 7.66,10.83 7.71,11C7.76,11.12 7.83,11.28 7.92,11.46C7.96,11.5 7.97,11.56 7.97,11.61C7.97,11.68 7.93,11.74 7.84,11.81L7.42,12.09C7.36,12.13 7.3,12.15 7.25,12.15C7.18,12.15 7.12,12.11 7.05,12.05C6.96,11.95 6.88,11.85 6.81,11.74C6.75,11.63 6.68,11.5 6.61,11.35C6.09,11.96 5.44,12.27 4.65,12.27C4.09,12.27 3.65,12.11 3.32,11.79C3,11.47 2.83,11.04 2.83,10.5C2.83,9.95 3.03,9.5 3.43,9.14C3.84,8.8 4.38,8.62 5.06,8.62C5.29,8.62 5.5,8.64 5.77,8.68C6,8.71 6.27,8.76 6.53,8.82V8.34C6.53,7.83 6.43,7.5 6.22,7.27C6,7.06 5.65,6.97 5.14,6.97C4.9,6.97 4.66,7 4.42,7.05C4.17,7.11 3.93,7.18 3.7,7.28C3.59,7.32 3.5,7.35 3.47,7.36C3.42,7.38 3.39,7.38 3.36,7.38C3.27,7.38 3.22,7.32 3.22,7.18V6.85C3.22,6.75 3.23,6.67 3.27,6.62C3.3,6.57 3.36,6.53 3.45,6.5C3.69,6.36 3.96,6.26 4.29,6.18C4.62,6.09 4.96,6.05 5.33,6.05C6.12,6.05 6.7,6.23 7.07,6.59C7.44,6.95 7.62,7.5 7.62,8.23V10.38H7.64M4.94,11.4C5.16,11.4 5.38,11.36 5.62,11.28C5.86,11.2 6.07,11.05 6.25,10.85C6.36,10.72 6.44,10.58 6.5,10.42C6.5,10.26 6.55,10.07 6.55,9.84V9.57C6.35,9.5 6.15,9.5 5.93,9.45C5.72,9.43 5.5,9.41 5.31,9.41C4.86,9.41 4.54,9.5 4.32,9.68C4.1,9.86 4,10.11 4,10.44C4,10.76 4.07,11 4.24,11.15C4.4,11.32 4.63,11.4 4.94,11.4M10.28,12.11C10.16,12.11 10.08,12.09 10,12.05C9.97,12 9.92,11.91 9.88,11.79L8.32,6.65C8.28,6.5 8.26,6.43 8.26,6.38C8.26,6.27 8.31,6.21 8.42,6.21H9.07C9.2,6.21 9.29,6.23 9.33,6.28C9.39,6.32 9.43,6.41 9.47,6.54L10.58,10.94L11.62,6.54C11.65,6.41 11.69,6.32 11.75,6.28C11.8,6.24 11.89,6.21 12,6.21H12.55C12.67,6.21 12.76,6.23 12.81,6.28C12.86,6.32 12.91,6.41 12.94,6.54L14,11L15.14,6.54C15.18,6.41 15.23,6.32 15.27,6.28C15.33,6.24 15.41,6.21 15.53,6.21H16.15C16.26,6.21 16.32,6.27 16.32,6.38C16.32,6.41 16.31,6.45 16.3,6.5C16.3,6.5 16.28,6.58 16.26,6.65L14.65,11.79C14.61,11.93 14.57,12 14.5,12.05C14.46,12.09 14.37,12.12 14.26,12.12H13.69C13.56,12.12 13.5,12.1 13.42,12.05C13.37,12 13.32,11.92 13.3,11.79L12.27,7.5L11.24,11.78C11.21,11.91 11.17,12 11.12,12.05C11.06,12.09 10.97,12.11 10.85,12.11H10.28M18.83,12.29C18.5,12.29 18.13,12.25 17.8,12.17C17.47,12.09 17.21,12 17.04,11.91C16.93,11.85 16.86,11.78 16.83,11.72C16.8,11.66 16.79,11.6 16.79,11.54V11.2C16.79,11.06 16.84,11 16.94,11C17,11 17,11 17.06,11C17.1,11 17.16,11.05 17.23,11.08C17.45,11.18 17.7,11.26 17.96,11.31C18.23,11.36 18.5,11.39 18.75,11.39C19.17,11.39 19.5,11.32 19.72,11.17C19.95,11 20.07,10.81 20.07,10.54C20.07,10.35 20,10.2 19.89,10.07C19.77,9.95 19.54,9.83 19.22,9.73L18.25,9.43C17.77,9.27 17.41,9.05 17.19,8.75C16.97,8.46 16.86,8.13 16.86,7.78C16.86,7.5 16.92,7.26 17.04,7.05C17.16,6.83 17.32,6.65 17.5,6.5C17.72,6.35 17.94,6.24 18.21,6.16C18.47,6.08 18.75,6.04 19.05,6.04C19.19,6.04 19.34,6.05 19.5,6.07C19.64,6.09 19.78,6.12 19.92,6.14C20.06,6.18 20.18,6.21 20.3,6.25C20.42,6.29 20.5,6.33 20.58,6.37C20.67,6.42 20.74,6.47 20.78,6.53C20.82,6.59 20.84,6.66 20.84,6.75V7.07C20.84,7.21 20.79,7.28 20.69,7.28C20.64,7.28 20.55,7.25 20.43,7.2C20.06,7.03 19.63,6.94 19.16,6.94C18.78,6.94 18.5,7 18.27,7.13C18.07,7.25 17.96,7.45 17.96,7.72C17.96,7.91 18.03,8.07 18.16,8.19C18.29,8.32 18.54,8.44 18.89,8.56L19.84,8.86C20.32,9 20.66,9.22 20.87,9.5C21.07,9.77 21.17,10.08 21.17,10.43C21.17,10.71 21.11,10.97 21,11.2C20.88,11.42 20.72,11.62 20.5,11.78C20.31,11.95 20.06,12.07 19.78,12.16C19.5,12.25 19.16,12.29 18.83,12.29M20.08,15.53C17.89,17.14 14.71,18 12,18C8.15,18 4.7,16.58 2.09,14.23C1.88,14.04 2.07,13.79 2.32,13.94C5.14,15.57 8.61,16.56 12.21,16.56C14.64,16.56 17.31,16.06 19.76,15C20.13,14.85 20.44,15.26 20.08,15.53M21,14.5C20.71,14.13 19.14,14.32 18.43,14.4C18.22,14.43 18.19,14.24 18.38,14.1C19.63,13.23 21.69,13.5 21.92,13.77C22.16,14.07 21.86,16.13 20.69,17.11C20.5,17.26 20.33,17.18 20.41,17C20.68,16.32 21.27,14.84 21,14.5Z`,rv=`M10 21H14C14 22.1 13.1 23 12 23S10 22.1 10 21M21 19V20H3V19L5 17V11C5 7.9 7 5.2 10 4.3V4C10 2.9 10.9 2 12 2S14 2.9 14 4V4.3C17 5.2 19 7.9 19 11V17L21 19M17 11C17 8.2 14.8 6 12 6S7 8.2 7 11V18H17V11Z`,iv=`M17,20.41L18.41,19L15,15.59L13.59,17M7.5,8H11V13.59L5.59,19L7,20.41L13,14.41V8H16.5L12,3.5`,av=`M14,4L16.29,6.29L13.41,9.17L14.83,10.59L17.71,7.71L20,10V4M10,4H4V10L6.29,7.71L11,12.41V20H13V11.59L7.71,6.29`,ov=`M22,21H2V3H4V19H6V10H10V19H12V6H16V19H18V14H22V21Z`,sv=`M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z`,cv=`M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z`,lv=`M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z`,uv=`M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z`,dv=`M13,19V16H21V19H13M8.5,13L2.47,7H6.71L11.67,11.95C12.25,12.54 12.25,13.5 11.67,14.07L6.74,19H2.5L8.5,13Z`,fv=`M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z`,pv=`M20 4H4A2 2 0 0 0 2 6V18A2 2 0 0 0 4 20H20A2 2 0 0 0 22 18V6A2 2 0 0 0 20 4M20 13H4V6H20Z`,mv=`M18 18V20H4A2 2 0 0 1 2 18V8H4V18M22 6V14A2 2 0 0 1 20 16H8A2 2 0 0 1 6 14V6A2 2 0 0 1 8 4H20A2 2 0 0 1 22 6M20 6H8V14H20Z`,hv=`M12 13H7V18H12V20H5V10H7V11H12V13M8 4V6H4V4H8M10 2H2V8H10V2M20 11V13H16V11H20M22 9H14V15H22V9M20 18V20H16V18H20M22 16H14V22H22V16Z`,gv=`M17 4H20C21.1 4 22 4.9 22 6V8H20V6H17V4M4 8V6H7V4H4C2.9 4 2 4.9 2 6V8H4M20 16V18H17V20H20C21.1 20 22 19.1 22 18V16H20M7 18H4V16H2V18C2 19.1 2.9 20 4 20H7V18M16 10V14H8V10H16M18 8H6V16H18V8Z`,_v=`M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z`,vv=`M15,4V11H5.17L4,12.17V4H15M16,2H3A1,1 0 0,0 2,3V17L6,13H16A1,1 0 0,0 17,12V3A1,1 0 0,0 16,2M21,6H19V15H6V17A1,1 0 0,0 7,18H18L22,22V7A1,1 0 0,0 21,6Z`,yv=`M2.6,10.59L8.38,4.8L10.07,6.5C9.83,7.35 10.22,8.28 11,8.73V14.27C10.4,14.61 10,15.26 10,16A2,2 0 0,0 12,18A2,2 0 0,0 14,16C14,15.26 13.6,14.61 13,14.27V9.41L15.07,11.5C15,11.65 15,11.82 15,12A2,2 0 0,0 17,14A2,2 0 0,0 19,12A2,2 0 0,0 17,10C16.82,10 16.65,10 16.5,10.07L13.93,7.5C14.19,6.57 13.71,5.55 12.78,5.16C12.35,5 11.9,4.96 11.5,5.07L9.8,3.38L10.59,2.6C11.37,1.81 12.63,1.81 13.41,2.6L21.4,10.59C22.19,11.37 22.19,12.63 21.4,13.41L13.41,21.4C12.63,22.19 11.37,22.19 10.59,21.4L2.6,13.41C1.81,12.63 1.81,11.37 2.6,10.59Z`,bv=`M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z`,xv=`M19.5 17C19.36 17 19.24 17 19.11 17.04L17.5 13.8C17.95 13.35 18.25 12.71 18.25 12C18.25 10.62 17.13 9.5 15.75 9.5C15.61 9.5 15.5 9.5 15.35 9.54L13.74 6.3C14.21 5.84 14.5 5.21 14.5 4.5C14.5 3.12 13.38 2 12 2S9.5 3.12 9.5 4.5C9.5 5.2 9.79 5.84 10.26 6.29L8.65 9.54C8.5 9.5 8.39 9.5 8.25 9.5C6.87 9.5 5.75 10.62 5.75 12C5.75 12.71 6.04 13.34 6.5 13.79L4.89 17.04C4.76 17 4.64 17 4.5 17C3.12 17 2 18.12 2 19.5C2 20.88 3.12 22 4.5 22S7 20.88 7 19.5C7 18.8 6.71 18.16 6.24 17.71L7.86 14.46C8 14.5 8.12 14.5 8.25 14.5C8.38 14.5 8.5 14.5 8.63 14.46L10.26 17.71C9.79 18.16 9.5 18.8 9.5 19.5C9.5 20.88 10.62 22 12 22S14.5 20.88 14.5 19.5C14.5 18.12 13.38 17 12 17C11.87 17 11.74 17 11.61 17.04L10 13.8C10.45 13.35 10.75 12.71 10.75 12C10.75 11.3 10.46 10.67 10 10.21L11.61 6.96C11.74 7 11.87 7 12 7C12.13 7 12.26 7 12.39 6.96L14 10.21C13.54 10.66 13.25 11.3 13.25 12C13.25 13.38 14.37 14.5 15.75 14.5C15.88 14.5 16 14.5 16.13 14.46L17.76 17.71C17.29 18.16 17 18.8 17 19.5C17 20.88 18.12 22 19.5 22S22 20.88 22 19.5C22 18.12 20.88 17 19.5 17M4.5 20.5C3.95 20.5 3.5 20.05 3.5 19.5S3.95 18.5 4.5 18.5 5.5 18.95 5.5 19.5 5.05 20.5 4.5 20.5M13 19.5C13 20.05 12.55 20.5 12 20.5S11 20.05 11 19.5 11.45 18.5 12 18.5 13 18.95 13 19.5M7.25 12C7.25 11.45 7.7 11 8.25 11S9.25 11.45 9.25 12 8.8 13 8.25 13 7.25 12.55 7.25 12M11 4.5C11 3.95 11.45 3.5 12 3.5S13 3.95 13 4.5 12.55 5.5 12 5.5 11 5.05 11 4.5M14.75 12C14.75 11.45 15.2 11 15.75 11S16.75 11.45 16.75 12 16.3 13 15.75 13 14.75 12.55 14.75 12M19.5 20.5C18.95 20.5 18.5 20.05 18.5 19.5S18.95 18.5 19.5 18.5 20.5 18.95 20.5 19.5 20.05 20.5 19.5 20.5Z`,Sv=`M20 16V4H8V16H20M22 16C22 17.1 21.1 18 20 18H8C6.9 18 6 17.1 6 16V4C6 2.9 6.9 2 8 2H20C21.1 2 22 2.9 22 4V16M16 20V22H4C2.9 22 2 21.1 2 20V7H4V20H16M14.2 5C13.3 5 12.6 5.2 12.1 5.6C11.6 6 11.3 6.6 11.3 7.4H13.2C13.2 7.1 13.3 6.9 13.5 6.7C13.7 6.6 13.9 6.5 14.2 6.5C14.5 6.5 14.8 6.6 15 6.8C15.2 7 15.3 7.2 15.3 7.6C15.3 7.9 15.2 8.2 15.1 8.4C15 8.6 14.7 8.8 14.5 9C14 9.3 13.6 9.6 13.5 9.9C13.1 10.1 13 10.5 13 11H15C15 10.7 15 10.4 15.1 10.3C15.2 10.1 15.4 9.9 15.6 9.8C16 9.6 16.4 9.3 16.7 8.9C17 8.4 17.2 8 17.2 7.5C17.2 6.7 16.9 6.1 16.4 5.7C15.9 5.2 15.1 5 14.2 5M13 12V14H15V12H13Z`,Cv=`M4,5A2,2 0 0,0 2,7V17A2,2 0 0,0 4,19H20A2,2 0 0,0 22,17V7A2,2 0 0,0 20,5H4M4,7H20V17H4V7M5,8V10H7V8H5M8,8V10H10V8H8M11,8V10H13V8H11M14,8V10H16V8H14M17,8V10H19V8H17M5,11V13H7V11H5M8,11V13H10V11H8M11,11V13H13V11H11M14,11V13H16V11H14M17,11V13H19V11H17M8,14V16H16V14H8Z`,wv=`M12,18.54L19.37,12.8L21,14.07L12,21.07L3,14.07L4.62,12.81L12,18.54M12,16L3,9L12,2L21,9L12,16M12,4.53L6.26,9L12,13.47L17.74,9L12,4.53Z`,Tv=`M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z`,Ev=`M13,10H11V6H13V10M13,12H11V14H13V12M22,4V16A2,2 0 0,1 20,18H6L2,22V4A2,2 0 0,1 4,2H20A2,2 0 0,1 22,4M20,4H4V17.2L5.2,16H20V4Z`,Dv=`M19,13H5V11H19V13Z`,Ov=`M18.13 12L19.39 10.74C19.83 10.3 20.39 10.06 21 10V9L15 3H5C3.89 3 3 3.89 3 5V19C3 20.1 3.89 21 5 21H11V19.13L11.13 19H5V5H12V12H18.13M14 4.5L19.5 10H14V4.5M19.13 13.83L21.17 15.87L15.04 22H13V19.96L19.13 13.83M22.85 14.19L21.87 15.17L19.83 13.13L20.81 12.15C21 11.95 21.33 11.95 21.53 12.15L22.85 13.47C23.05 13.67 23.05 14 22.85 14.19Z`,kv=`M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z`,Av=`M14,19H18V5H14M6,19H10V5H6V19Z`,jv=`M3 17.25V21H6.75L17.81 9.93L14.06 6.18L3 17.25M22.61 18.36L18.36 22.61L13.16 17.41L14.93 15.64L15.93 16.64L18.4 14.16L19.82 15.58L18.36 17L19.42 18L20.84 16.6L22.61 18.36M6.61 10.83L1.39 5.64L5.64 1.39L7.4 3.16L4.93 5.64L6 6.7L8.46 4.22L9.88 5.64L8.46 7.05L9.46 8.05L6.61 10.83M20.71 7C21.1 6.61 21.1 6 20.71 5.59L18.37 3.29C18 2.9 17.35 2.9 16.96 3.29L15.12 5.12L18.87 8.87L20.71 7Z`,Mv=`M8,5.14V19.14L19,12.14L8,5.14Z`,Nv=`M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z`,Pv=`M12,4C14.1,4 16.1,4.8 17.6,6.3C20.7,9.4 20.7,14.5 17.6,17.6C15.8,19.5 13.3,20.2 10.9,19.9L11.4,17.9C13.1,18.1 14.9,17.5 16.2,16.2C18.5,13.9 18.5,10.1 16.2,7.7C15.1,6.6 13.5,6 12,6V10.6L7,5.6L12,0.6V4M6.3,17.6C3.7,15 3.3,11 5.1,7.9L6.6,9.4C5.5,11.6 5.9,14.4 7.8,16.2C8.3,16.7 8.9,17.1 9.6,17.4L9,19.4C8,19 7.1,18.4 6.3,17.6Z`,Fv=`M10.5 15.5C10.5 15.87 10.4 16.2 10.22 16.5C9.88 15.91 9.24 15.5 8.5 15.5S7.12 15.91 6.78 16.5C6.61 16.2 6.5 15.87 6.5 15.5C6.5 14.4 7.4 13.5 8.5 13.5S10.5 14.4 10.5 15.5M23 15V18C23 18.55 22.55 19 22 19H21V20C21 21.11 20.11 22 19 22H5C3.9 22 3 21.11 3 20V19H2C1.45 19 1 18.55 1 18V15C1 14.45 1.45 14 2 14H3C3 10.13 6.13 7 10 7H11V5.73C10.4 5.39 10 4.74 10 4C10 2.9 10.9 2 12 2S14 2.9 14 4C14 4.74 13.6 5.39 13 5.73V7H14C17.87 7 21 10.13 21 14H22C22.55 14 23 14.45 23 15M21 16H19V14C19 11.24 16.76 9 14 9H10C7.24 9 5 11.24 5 14V16H3V17H5V20H19V17H21V16M15.5 13.5C14.4 13.5 13.5 14.4 13.5 15.5C13.5 15.87 13.61 16.2 13.78 16.5C14.12 15.91 14.76 15.5 15.5 15.5S16.88 15.91 17.22 16.5C17.4 16.2 17.5 15.87 17.5 15.5C17.5 14.4 16.61 13.5 15.5 13.5Z`,Iv=`M17.5 15.5C17.5 16.61 16.61 17.5 15.5 17.5S13.5 16.61 13.5 15.5 14.4 13.5 15.5 13.5 17.5 14.4 17.5 15.5M8.5 13.5C7.4 13.5 6.5 14.4 6.5 15.5S7.4 17.5 8.5 17.5 10.5 16.61 10.5 15.5 9.61 13.5 8.5 13.5M23 15V18C23 18.55 22.55 19 22 19H21V20C21 21.11 20.11 22 19 22H5C3.9 22 3 21.11 3 20V19H2C1.45 19 1 18.55 1 18V15C1 14.45 1.45 14 2 14H3C3 10.13 6.13 7 10 7H11V5.73C10.4 5.39 10 4.74 10 4C10 2.9 10.9 2 12 2S14 2.9 14 4C14 4.74 13.6 5.39 13 5.73V7H14C17.87 7 21 10.13 21 14H22C22.55 14 23 14.45 23 15M21 16H19V14C19 11.24 16.76 9 14 9H10C7.24 9 5 11.24 5 14V16H3V17H5V20H19V17H21V16Z`,Lv=`M13,14C9.64,14 8.54,15.35 8.18,16.24C9.25,16.7 10,17.76 10,19A3,3 0 0,1 7,22A3,3 0 0,1 4,19C4,17.69 4.83,16.58 6,16.17V7.83C4.83,7.42 4,6.31 4,5A3,3 0 0,1 7,2A3,3 0 0,1 10,5C10,6.31 9.17,7.42 8,7.83V13.12C8.88,12.47 10.16,12 12,12C14.67,12 15.56,10.66 15.85,9.77C14.77,9.32 14,8.25 14,7A3,3 0 0,1 17,4A3,3 0 0,1 20,7C20,8.34 19.12,9.5 17.91,9.86C17.65,11.29 16.68,14 13,14M7,18A1,1 0 0,0 6,19A1,1 0 0,0 7,20A1,1 0 0,0 8,19A1,1 0 0,0 7,18M7,4A1,1 0 0,0 6,5A1,1 0 0,0 7,6A1,1 0 0,0 8,5A1,1 0 0,0 7,4M17,6A1,1 0 0,0 16,7A1,1 0 0,0 17,8A1,1 0 0,0 18,7A1,1 0 0,0 17,6Z`,Rv=`M8,0H20A2,2 0 0,1 22,2V18A2,2 0 0,1 20,20H8A2,2 0 0,1 6,18V2A2,2 0 0,1 8,0M14.75,11.5C17.5,11.5 18.24,9.47 18.43,8.4C19.34,8.11 20,7.26 20,6.25C20,5 19,4 17.75,4C16.5,4 15.5,5 15.5,6.25C15.5,7.19 16.07,8 16.89,8.33C16.67,9 16,10 14,10C12.62,10 11.66,10.35 11,10.84V6.87C11.87,6.56 12.5,5.73 12.5,4.75C12.5,3.5 11.5,2.5 10.25,2.5C9,2.5 8,3.5 8,4.75C8,5.73 8.63,6.56 9.5,6.87V13.13C8.63,13.44 8,14.27 8,15.25C8,16.5 9,17.5 10.25,17.5C11.5,17.5 12.5,16.5 12.5,15.25C12.5,14.32 11.94,13.5 11.13,13.18C11.41,12.5 12.23,11.5 14.75,11.5M10.25,14.5A0.75,0.75 0 0,1 11,15.25A0.75,0.75 0 0,1 10.25,16A0.75,0.75 0 0,1 9.5,15.25A0.75,0.75 0 0,1 10.25,14.5M10.25,4A0.75,0.75 0 0,1 11,4.75A0.75,0.75 0 0,1 10.25,5.5A0.75,0.75 0 0,1 9.5,4.75A0.75,0.75 0 0,1 10.25,4M17.75,5.5A0.75,0.75 0 0,1 18.5,6.25A0.75,0.75 0 0,1 17.75,7A0.75,0.75 0 0,1 17,6.25A0.75,0.75 0 0,1 17.75,5.5M16,22V24H4A2,2 0 0,1 2,22V6H4V22H16Z`,zv=`M18,18H6V6H18V18Z`,Bv=`M5,3C3.89,3 3,3.89 3,5V19C3,20.11 3.89,21 5,21H19C20.11,21 21,20.11 21,19V5C21,3.89 20.11,3 19,3H5M5,5H19V19H5V5M7,7V9H17V7H7M7,11V13H17V11H7M7,15V17H14V15H7Z`,Vv=`M4,4H20V20H4V4M6,8V18H18V8H6Z`,Hv=`M20,14H4V10H20`,Uv=`M4,8H8V4H20V16H16V20H4V8M16,8V14H18V6H10V8H16M6,12V18H14V12H6Z`,Wv=e=>()=>(0,G.jsx)(`svg`,{"aria-hidden":`true`,fill:`currentColor`,focusable:`false`,height:`1em`,viewBox:`0 0 24 24`,width:`1em`,children:(0,G.jsx)(`path`,{d:e})}),Gv=Wv(Mv),Kv=Wv(Av),qv=Wv(zv),Jv=Wv(uv),Yv=Wv(sv),Xv=Wv(cv),Zv=Wv(lv),Qv=Wv(Q_),$v=Wv($_),ey=Wv(ev),ty=Wv(Z_),ny=Wv(fv),ry=Wv(Tv),iy=Wv(dv),ay=Wv(Hv),oy=Wv(Vv),sy=Wv(Uv),cy=Wv(mv),ly=Wv(pv),uy=Wv(_v),dy=Wv(xv),fy=Wv(Bv),py=Wv(Sv),my=Wv(vv),hy=Wv(rv),gy=Wv(ov),_y=Wv(jv),vy=Wv(wv),yy=Wv(X_),by=Wv(Ev),xy=Wv(Ov),Sy=Wv(kv),Cy=Wv(Rv),wy=Wv(Y_),Ty=Wv(Iv),Ey=Wv(Fv),Dy=Wv(av),Oy=Wv(iv),ky=Wv(Lv),Ay=Wv(J_),jy=Wv(hv),My=Wv(bv),Ny=Wv(nv),Py=Wv(yv),Fy=Wv(Nv),Iy=Wv(Dv),Ly=Wv(gv),Ry=Wv(Cv),zy=Wv(tv),By=Wv(Pv),Vy={viewport:`_viewport_1wznh_6`,toast:`_toast_1wznh_25`,content:`_content_1wznh_62`,title:`_title_1wznh_66`,description:`_description_1wznh_75`,close:`_close_1wznh_82`},Hy=q_(),Uy=()=>{let{toasts:e}=K_();return e.map(e=>(0,G.jsxs)(k_,{className:Vy.toast,toast:e,children:[(0,G.jsxs)(A_,{className:Vy.content,children:[(0,G.jsx)(I_,{className:Vy.title,children:typeof e.title==`string`?(0,G.jsx)(Wg,{text:e.title}):e.title}),(0,G.jsx)(F_,{className:Vy.description,children:typeof e.description==`string`?(0,G.jsx)(Wg,{text:e.description}):e.description})]}),(0,G.jsx)(W_,{"aria-label":`Dismiss`,className:Vy.close,children:(0,G.jsx)(Jv,{})})]},e.id))},Wy=({children:e})=>(0,G.jsxs)(s_,{toastManager:Hy,children:[e,(0,G.jsx)(G_,{children:(0,G.jsx)(u_,{"aria-label":`Messages`,className:Vy.viewport,children:(0,G.jsx)(Uy,{})})})]}),Gy=(0,V.createContext)(null),Ky=Gy.Provider,qy=()=>{let e=(0,V.useContext)(Gy);if(e===null)throw Error(`No AppStateProvider above this.`);return e},Jy={DEFAULT:`default`,COMPUTED:`computed`},Yy=class e{_value;_subscribers;_initialValue;#e=[];#t=!1;static create(t){return new e(t)}constructor(e){let t=typeof e==`function`?e():e;this._initialValue=t,this._value=t,this._subscribers=new Set}getValue(){return this._value}getServerValue(){return this._value}setValue(e){let t=this._value;return this._value=e,new Promise(n=>{this.#e.push(()=>{let r=[...this._subscribers];n(this.#r(r,t,e))}),this.#n()})}#n(){if(!this.#t){this.#t=!0;for(let e of this.#e)e();this.#e.length=0,this.#t=!1}}async#r(e,t,n){let r=(await Promise.allSettled(e.map(e=>this.#i(e,t,n)))).flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(r.length>1)throw AggregateError(r,`Several subscribers failed.`);if(r.length===1)throw r[0]}async#i(e,t,n){if(!this._subscribers.has(e))return;if(e.type!==Jy.COMPUTED){Object.is(t,n)||await e.cb(n);return}let{computeValue:r,cb:i,isEqual:a}=e;if(a===void 0&&Object.is(t,n))return;let o=r(n),s=r(t);(a?.(s,o)??Object.is(o,s))||await i(o)}subscribe(e,t){let{signal:n}=t??{},r={type:Jy.DEFAULT,cb:e};this._subscribers.add(r);let i=()=>{this._subscribers.delete(r),n?.removeEventListener(`abort`,i)};return n?.addEventListener(`abort`,i),n?.aborted===!0&&i(),i}computedSubscribe(e,t,n){let{isEqual:r,signal:i}=n??{},a={type:Jy.COMPUTED,computeValue:e,cb:t,isEqual:r};this._subscribers.add(a);let o=()=>{this._subscribers.delete(a),i?.removeEventListener(`abort`,o)};return i?.addEventListener(`abort`,o),i?.aborted===!0&&o(),o}reset(){return this.setValue(this._initialValue)}},Xy=e=>typeof e==`object`&&!!e&&`timestamp`in e&&typeof e.timestamp==`number`,Zy=class extends Yy{#e;#t;#n;#r;#i;#a;constructor(e,t){super(e),this.#e=t.key,this.#t=t.storage,this.#n=t.ttl,this.#r=e=>t.serialize===void 0?e:t.serialize(e),this.#i=e=>t.deserialize===void 0?e:t.deserialize(e),this.#a=t.onError;let n=this.#o();n!==null&&(this._value=n.value)}getServerValue(){return this._initialValue}async setValue(e){this.#c(e),await super.setValue(e)}async reset(){this.#s(),await super.setValue(this._initialValue)}#o(){try{let e=this.#t.getItem(this.#e);if(e===null)return null;let t=JSON.parse(e);if(!Xy(t))throw TypeError(`Unexpected data in "${this.#e}".`);return this.#n!==void 0&&Date.now()-t.timestamp>this.#n?(this.#t.removeItem(this.#e),null):{...t,value:this.#i(t.value)}}catch(e){return this.#l(e),null}}#s(){try{this.#t.removeItem(this.#e)}catch(e){this.#l(e)}}#c(e){try{let t=this.#r(e);if(typeof t==`function`||typeof t==`symbol`)throw TypeError(`Cannot save a ${typeof t} as JSON.`);let n={value:t,timestamp:Date.now()};this.#t.setItem(this.#e,JSON.stringify(n))}catch(e){this.#l(e)}}#l(e){try{this.#a?.(e)}catch{}}},Qy=`ork.preferences.v1`,$y=ss({theme:_s([`system`,`dark`,`light`]).default(`system`),density:_s([`compact`,`comfortable`]).default(`compact`),desktopNotifications:$o().default(!1),updateDismissed:ss({version:Co(),at:Co()}).optional(),decisionFilter:ss({workflow:Co().optional(),run:Co().optional()}).default({})}),eb={theme:`system`,density:`compact`,desktopNotifications:!1,decisionFilter:{}},tb=e=>{let t=new Zy(eb,{key:Qy,storage:e}),n=$y.safeParse(t.getValue());return n.success?t.setValue(n.data):t.reset(),{value:t,update:e=>{t.setValue({...t.getValue(),...e})}}},nb=(e,t)=>{let{value:n}=t,r=e.document.documentElement,i=()=>{r.dataset.density=n.getValue().density};i();let a=ie(e,()=>n.getValue().theme),o=n.subscribe(()=>{i(),me(e,n.getValue().theme)});return()=>{a(),o()}},rb=e=>typeof e.getServerValue==`function`?e.getServerValue():e.getValue(),ib=(e,t,n)=>{let{subscribe:r,getServerSnapshot:i,getSnapshot:a}=(0,V.useMemo)(()=>({subscribe:e.subscribe.bind(e),getSnapshot:e.getValue.bind(e),getServerSnapshot:()=>rb(e)}),[e]);return(0,nm.useSyncExternalStoreWithSelector)(r,a,i,t,n)},ab=e=>{let{subscribe:t,getServerSnapshot:n,getSnapshot:r}=(0,V.useMemo)(()=>({subscribe:e.subscribe.bind(e),getSnapshot:e.getValue.bind(e),getServerSnapshot:()=>rb(e)}),[e]);return(0,tm.useSyncExternalStore)(t,r,n)},ob=V.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=V_({disabled:i,focusableWhenDisabled:a,native:o});return Pf(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})}),sb={button:`_button_bj0an_7`,icon:`_icon_bj0an_8`},q=({variant:e=`default`,cli:t,tip:n,...r})=>{let i=(0,G.jsx)(ob,{...r,...Xg(t),className:sb.button,"data-variant":e});return t===void 0&&n===void 0?i:(0,G.jsx)(Zg,{cli:t,label:n,children:i})},cb=({label:e,variant:t=`ghost`,cli:n,keys:r,...i})=>(0,G.jsx)(Zg,{cli:n,keys:r,label:e,children:(0,G.jsx)(ob,{...i,...Xg(n),"aria-label":e,className:sb.icon,"data-variant":t})});function lb({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=V.useRef(e!==void 0),[a,o]=V.useState(()=>t);return[i&&e!==void 0?e:a,V.useCallback(e=>{i||o(e)},[])]}function ub(e){let t=V.useRef(!0);t.current&&(t.current=!1,e())}function db(e,t,n,r,i,a,o,s,c,l=2){let u=vd(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return pd(n.current,u)?void 0:u}function fb(e){return e==null?Gl:e.type.startsWith(`key`)?iu:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?au:Gl}var pb=V.createContext(void 0),mb=V.createContext(void 0),hb=V.createContext(void 0),gb=V.createContext(!1),_b=V.createContext(``);function vb(){let e=V.useContext(pb);if(!e)throw Error(rc(22));return e}function yb(){let e=V.useContext(mb);if(!e)throw Error(rc(23));return e}function bb(){let e=V.useContext(hb);if(!e)throw Error(rc(24));return e}function xb(){return V.useContext(_b)}function Sb(){return V.useContext(gb)}function Cb(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var wb=(e,t)=>Object.is(e,t);function Tb(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Eb(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Cb(e,t,(e,t)=>Tb(e,t,n)):e!==t}function Db(e,t,n){return e?e.some(e=>e!==void 0&&Tb(t,e,n)):!1}function Ob(e,t,n){return e?e.findIndex(e=>e!==void 0&&Tb(e,t,n)):-1}function kb(e,t){if(t!==wb)return n=>Db(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function Ab(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(kb(t,n)):Ob(e,t,n);return i===-1?null:i}function jb(e,t,n,r,i,a){return Db(r,t,i)?a!=null&&e>a&&Db(r,n[a],i)?a:e:e===a?Ab(n,r,i,!0):a}function Mb(e,t,n){return e.filter(e=>!Tb(t,e,n))}function Nb(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function Pb(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function Fb(e){return Pb(e?.[0])}function Ib(e){return Fb(e)?e.flatMap(e=>e.items):e}function Lb(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(Fb(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function Rb(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return Nb(e)}function zb(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?Nb(e.value):Nb(e)}function Bb(e,t,n){function r(){return Rb(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=Ib(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function Vb(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,G.jsx)(V.Fragment,{children:Bb(r,t,n)},i)),e),[])}var Hb={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?Lb(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>Tb(t,e,n)):Tb(t,r,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight},Ub=`data-valid`,Wb=`data-invalid`,Gb={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Kb={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},qb={disabled:!1,...Kb},Jb={valid(e){return e===null?null:e?{[Ub]:``}:{[Wb]:``}}},Yb={invalid:void 0,name:void 0,validityData:{state:Gb,errors:[],error:``,value:``,initialValue:null},setValidityData:$s,disabled:void 0,setTouched:$s,setDirty:$s,setFilled:$s,setFocused:$s,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:qb,registerFieldControl:$s,validation:{getValidationProps:(e,t=tc)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:$s,getInputControl:()=>null,commit:async()=>{},change:$s}},Xb=V.createContext(Yb);function Zb(e=!0){let t=V.useContext(Xb);if(t.setValidityData===$s&&!e)throw Error(rc(28));return t}function Qb(e,t,n,r,i=!0,a){let{registerFieldControl:o}=Zb(),s=Gs(()=>Symbol());H(()=>{let c=s.current;i?o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}):o(c,void 0)},[e,i,r,t,a,o,s,n]),H(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var $b=V.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:$s,validationMode:`onSubmit`,submitCountRef:{current:0}});function ex(){return V.useContext($b)}var tx=V.createContext({controlId:void 0,registerControlId:$s,resetControlId:$s,labelId:void 0,setLabelId:$s,messageIds:[],setMessageIds:$s,getDescriptionProps:e=>e});function nx(){return V.useContext(tx)}function rx(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=nx(),o=ng(),s=Gs(()=>Symbol()),c=V.useRef(!1),l=V.useRef(!1),u=K(()=>{c.current&&i!==$s&&(c.current=!1,i(s.current,void 0))});return H(()=>{if(!n||i===$s){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}e===void 0?u():(c.current=!0,i(s.current,e))},[t,n,i,a,o,s,u]),H(()=>u,[u]),(n?r:void 0)??t??o}function ix(e){return e==null?void 0:`${e}-popup`}function ax(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}function ox(e){return Array.isArray(e)?e.map(e=>ox(e)).join(`,`):e==null?``:String(e)}var sx=new Map;function cx(e={}){let{locale:t,...n}=e,r={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...n},i=`${ox(t)}|${JSON.stringify(r)}`,a=sx.get(i);if(a)return a;let o=new Intl.Collator(t,r),s={contains(e,t,n){if(!t)return!0;let r=Rb(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(o.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=Rb(e,n);return o.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Rb(e,n),i=t.length;return r.length>=i&&o.compare(r.slice(r.length-i),t)===0}};return sx.set(i,s),s}var lx=cx;function ux(e){let t=V.useRef(``),n=V.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:V.useCallback(n=>{n.detail===0?e(n,`keyboard`):(`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``)},[e]),onPointerDown:n}}function dx(e,t){let n=V.useRef(e),r=K(t);H(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function fx(e,t){let{onClick:n,onPointerDown:r}=ux(K((n,r)=>{(typeof e==`function`?e():e)||t(r||(gc?`touch`:``))}));return V.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function px(e){let[t,n]=V.useState(null),r=fx(e,n);return dx(e,t=>{t&&!e&&n(null)}),V.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}var mx=Symbol(`none`),hx={value:mx,index:-1};function gx(e,t,n){let r=e.get(t);if(r!==void 0||n===wb)return r;for(let[r,i]of e)if(Tb(r,t,n))return i}function _x(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:o,inputValue:s,open:c,defaultOpen:l=!1,selectionMode:u,onItemHighlighted:d,name:f,form:p,disabled:m=!1,readOnly:h=!1,required:g=!1,inputRef:_,grid:v=!1,items:y,filteredItems:b,filter:x,filterQuery:S,openOnInputClick:C=!0,autoHighlight:w=!1,keepHighlight:T=!1,highlightItemOnHover:E=!0,loopFocus:D=!0,itemToStringLabel:O,itemToStringValue:k,isItemEqualToValue:A=wb,virtualized:j=!1,inline:M=!1,fillInputOnItemPress:N=!0,modal:P=!1,limit:F=-1,autoComplete:I=`list`,formAutoComplete:L,locale:R,submitOnItemClick:ee=!1}=e,{clearErrors:z}=ex(),{setDirty:te,validityData:ne,setFilled:re,name:ie,disabled:ae,setTouched:oe,setFocused:se,validationMode:ce,validation:le}=Zb(),ue=gg(),de=rx({id:t}),fe=lx({locale:R}),pe=Array.isArray(y)?null:y;if(pe&&typeof pe.label!=`function`)throw Error(rc(100));let me=pe?pe.data:y,he=pe?.value,ge=he?void 0:me,_e=V.useMemo(()=>{if(!b||!he)return;let e=Ib(b),t=e.map(he),n;return{values:t,findItem(r,i){if(!n){n=new Map;for(let r=0;r<t.length;r+=1)n.has(t[r])||n.set(t[r],e[r])}return gx(n,r,i)}}},[b,he]),ve=V.useMemo(()=>pe?e=>pe.label(e,A,e=>{let t=_e?.findItem(e,A);return t==null?Rb(e,O):pe.itemLabel(t)}):O,[pe,O,_e,A]),ye=V.useMemo(()=>pe?Object.assign(e=>pe.itemLabel(e),{selected:e=>Rb(e,ve)}):O,[pe,ve,O]);function be(e){return Rb(e,ve)}let[B,xe]=V.useState(!1),[Se,Ce]=V.useState(null),we=V.useRef(Se),Te=V.useRef([]),Ee=V.useRef([]),De=V.useRef(null),Oe=V.useRef(null),ke=V.useRef(null),Ae=V.useRef(null),je=V.useRef(null),Me=V.useRef(!1),Ne=V.useRef(null),Pe=V.useRef(null),Fe=V.useRef(null),Ie=V.useRef(hx),Le=V.useRef(null),Re=V.useRef([]),ze=V.useRef(null),Be=ae||m,Ve=ie??f,He=u===`multiple`,Ue=u===`single`,We=s!==void 0||o!==void 0,Ge=me!==void 0,Ke=b!==void 0,qe;qe=w===`always`?`always`:w?`input-change`:!1;let[Je,Ye]=lb({controlled:i,default:He?r??ec:r,name:`Combobox`,state:`selectedValue`}),Xe=V.useMemo(()=>x===null?()=>!0:x===void 0?ax(fe,ye):x,[x,fe,ye]),Ze=Gs(()=>We?o??``:Ue?be(Je):``).current,[Qe,$e]=lb({controlled:s,default:Ze,name:`Combobox`,state:`inputValue`}),[et,tt]=lb({controlled:c,default:l,name:`Combobox`,state:`open`}),nt=Fb(me),rt=!et&&Se!==null?Se:String(Qe).trim(),it=Ue?be(Je):``,at=Ue&&!B&&rt!==``&&it.length===rt.length&&fe.contains(it,rt),ot=at?``:S??rt,st=Ge&&Ke&&at&&(!pe||pe.hasValue(Je,A)),ct=V.useMemo(()=>me?Ib(me):ec,[me]),lt=V.useMemo(()=>{if(b&&!st)return b;if(!me)return ec;if(nt){let e=me,t=[],n=0;for(let r of e){if(F>-1&&n>=F)break;let e=F>-1?F-n:1/0,i=ot===``?r.items.slice(0,e):[];if(ot!==``)for(let t of r.items){if(i.length>=e)break;Xe(t,ot,ye)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(ot===``)return F>-1?ct.slice(0,F):ct;let e=[];for(let t of ct){if(F>-1&&e.length>=F)break;Xe(t,ot,ye)&&e.push(t)}return e},[b,st,me,nt,ot,F,Xe,ye,ct]),ut=V.useMemo(()=>{if(_e&<===b)return _e.values;let e=Ib(lt);return he?e.map(e=>he(e)):e},[lt,b,_e,he]),dt=Gs(()=>{let e=null;return M&&et&&Ge&&u!==`none`&&(e=Ab(ut,Je,A,He)),new lm({id:de,labelId:void 0,selectedValue:Je,open:et,items:ge,selectionMode:u,name:Ve,form:p,disabled:Be,readOnly:h,required:g,grid:v,virtualized:j,openOnInputClick:C,itemToStringLabel:ve,isItemEqualToValue:A,modal:P,autoHighlight:qe,submitOnItemClick:ee,hasInputValue:We,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:M,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemRoot:{props:tc,id:de,selectionMode:u,disabled:Be,readOnly:h,isItemEqualToValue:A},positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:u===`none`},{onOpenChangeComplete:$s,setOpen:$s,setInputValue:$s,setSelectedValue:$s,setIndices:$s,handleSelection:$s,forceMount:$s,requestSubmit:$s,listRef:Te,labelsRef:Ee,popupRef:De,emptyRef:je,inputRef:Oe,startDismissRef:ke,endDismissRef:Ae,chipsContainerRef:Ne,clearRef:Pe,valuesRef:Re,pointerDownItemRef:ze,selectionEventRef:Fe},Hb)}).current,ft=u===`none`?Qe:Je,pt=V.useMemo(()=>u===`none`?ft:Array.isArray(Je)?Je.map(e=>zb(e,k)):zb(Je,k),[ft,k,u,Je]),mt=K(d),ht=K(n),gt=dt.useState(`activeIndex`),_t=dt.useState(`selectedIndex`),vt=dt.useState(`positionerElement`),yt=dt.useState(`listElement`),bt=dt.useState(`triggerElement`),xt=dt.useState(`inputElement`),St=dt.useState(`inputGroupElement`),Ct=dt.useState(`inline`),wt=dt.useState(`inputInsidePopup`),Tt=dt.useState(`inputOwnsFormValue`),Et=Ue&&!wt&&Qe===it,Dt=Cu(bt),{openMethod:Ot,triggerProps:kt}=px(et),At=K(()=>pt);Qb(wt?Dt:Oe,de,ft,At,!Be,f);let jt=K(()=>{me?Ee.current=ut.map(be):dt.set(`forceMounted`,!0)}),Mt=K((e,t,n,r)=>{if(t===-1){if(Ie.current===hx)return;Ie.current=hx}else Ie.current={value:e,index:t};mt(e,Wl(n,r,{index:t}))}),Nt=K(e=>{let t={};e.activeIndex!==void 0&&(t.activeIndex=e.activeIndex),e.selectedIndex!==void 0&&(t.selectedIndex=e.selectedIndex),dt.update(t);let n=e.activeIndex;if(n===void 0)return;let r=e.type||`none`;n===null?Mt(void 0,-1,r,e.event):Mt(Re.current[n],n,r,e.event)}),Pt=K((t,n)=>{if(e.onInputValueChange?.(t,n),!n.isCanceled){if(Me.current=n.reason===$l,n.reason===`input-change`){et&&Se!==null&&Ce(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&xe(!0),Le.current={hasQuery:e};let n=dt.state.listElement;if(!dt.state.virtualized&&n){let e=De.current;for(let t of el(n.firstElementChild??n)){if(!Lc(t)||(e?!U(e,t):t.getAttribute(`role`)===`dialog`))break;if(m_(t)){t.scrollTop=0;break}}}e&&qe&&dt.state.activeIndex==null&&(et||Ct)&&dt.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&dt.state.inputInsidePopup&&(Le.current={hasQuery:!1,selection:!0});$e(t)}}),Ft=K(e=>{let t=!e&&wt&&!Ct&&Qe!==``&&(String(Qe).trim()===Se||Qe===it);!e&&(t||Qe===``||Et)&&xe(!1),Ce(null),t&&Pt(``,W($l))}),[It,Lt]=V.useState(!1),Rt=K((t,n)=>{if(et===t)return;n.reason===`escape-key`&&Ge&&ut.length===0&&!je.current&&n.allowPropagation();let r=n,i=Up(r);if(e.onOpenChange?.(t,r),Le.current?.hasQuery&&n.reason===`input-change`===n.isCanceled&&(Le.current=null),!n.isCanceled&&(t&&Se!==null&&Ft(n.reason===Ql),!t&&B&&(Ue?(Ct||Ce(rt),rt===``&&xe(!1)):He&&(Ct||Ce(rt),wt&&Nt({activeIndex:null}),(!wt||Ct)&&Pt(``,W($l,n.event,void 0,{isItemPress:n.reason===Xl})))),t||Lt(i()),tt(t),!t&&wt&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(oe(!0),se(!1),ce===`onBlur`))){let e=u===`none`?Qe:Je;le.commit(e)}}),zt=K((e,t)=>{a?.(e,t),!t.isCanceled&&(Ye(e),(u===`none`&&De.current&&N||Ue&&!dt.state.inputInsidePopup)&&Pt(be(e),W(t.reason,t.event)))}),Bt=K((e,t)=>{let n=il(e),r=Fe.current??e;Fe.current=null;let i=W(Xl,r),a=rl(n,`a`)?.getAttribute(`href`);if(a)a.startsWith(`#`)&&Rt(!1,i);else if(He){let e=Array.isArray(Je)?Je:[],n=Db(e,t,A),r=n?Mb(e,t,A):[...e,t];if(zt(r,i),i.isCanceled||!(Oe.current&&Oe.current.value.trim()!==``))return;if(dt.state.inputInsidePopup){Pt(``,W($l,i.event,void 0,{isItemPress:!0}));let e=Le.current;e&&!n&&(e.toggledValue=t)}else Rt(!1,i)}else{if(zt(t,i),i.isCanceled)return;Rt(!1,i)}}),Vt=K(()=>{let e=le.inputRef.current?.form??dt.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),Ht=K(()=>{if(ht?.(!1),xe(!1),Ce(null),Nt(u===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),He&&Oe.current&&Oe.current.value!==``&&!Me.current&&Pt(``,W($l)),Ue){if(dt.state.inputInsidePopup)Oe.current&&Oe.current.value!==``&&Pt(``,W($l));else{let e=be(Je);Oe.current&&Oe.current.value!==e&&Pt(e,W(e===``?$l:Gl))}}}),Ut=V.useMemo(()=>Ct&&vt?{current:rl(vt,`[role="dialog"]`)}:De,[Ct,vt]),{mounted:Wt,transitionStatus:Gt,forceUnmount:Kt}=Fp({open:et,ref:Ut,preventUnmountOnClose:It,setPreventUnmountOnClose:Lt,onUnmount:Ht});V.useImperativeHandle(e.actionsRef,()=>({unmount:Kt,close:()=>Rt(!1,W(lu))}),[Kt,Rt]),H(function(){let e=we.current!==null&&Se===null;if(we.current=Se,et&&(!e||!Ge)||(et||(ze.current=null),u===`none`))return;let t=Ge?ut:Re.current;Nt({selectedIndex:Ab(t,Je,A,He)})},[et,Se,Je,u,He,Ge,ut,A,Nt]),H(()=>{me&&(Re.current=ut,Te.current.length=ut.length)},[me,ut]),H(()=>{!et&&Le.current?.hasQuery&&(Le.current=null)},[et]),H(()=>{if(!et&&Ct&&Ut.current){Le.current=null;return}let e=Ge||Ke?ut:Re.current,t=Le.current;if(t){let n=et||Ct||dt.state.positionerElement?.hidden===!1;if(t.hasQuery){let t=Oe.current;!qe||String(Qe).trim()===``||Ct&&qe!==`always`&&(!t||nl(t.ownerDocument)!==t)?Le.current=null:n&&(e[0]!==void 0||!Ge&&!Ke)&&(dt.set(`activeIndex`,0),Le.current=null)}else if(String(Qe).trim()===``&&(Le.current=null,n)){let e=t.selection;qe===`always`&&!e&&dt.state.selectionMode===`none`&&dt.set(`activeIndex`,0),queueMicrotask(()=>{if(!dt.state.open&&(!dt.state.inline||Ut.current)||Oe.current&&Oe.current.value.trim()!==``)return;let n=dt.state.selectedValue,r=dt.state.selectionMode===`multiple`;if(r&&Array.isArray(n)?n.length>0:dt.state.selectionMode!==`none`&&n!=null){let e=Ge||Ke?ut:Re.current,i=Ob(e,t.toggledValue,dt.state.isItemEqualToValue);dt.set(`activeIndex`,i===-1?Ab(e,n,dt.state.isItemEqualToValue,r):i)}else e?dt.set(`activeIndex`,null):qe===`always`&&dt.set(`activeIndex`,0)})}}if(!et&&!Ct)return;let n=dt.state.activeIndex;if(n==null){if(qe===`always`&&e.length>0){dt.set(`activeIndex`,0);return}Mt(void 0,-1,Gl);return}if(n>=e.length){Mt(void 0,-1,Gl),dt.set(`activeIndex`,null);return}let r=e[n],i=Ie.current.value,a=i!==mx&&Tb(r,i,dt.state.isItemEqualToValue);Ie.current.index===n&&a||Mt(r,n,Gl)},[gt,qe,Mt,Ke,Ge,ut,Ct,et,Ut,dt,Qe]),H(()=>{re(u===`none`?String(Qe)!==``:He?Array.isArray(Je)&&Je.length>0:Je!=null)},[re,u,Qe,Je,He]),V.useEffect(()=>{Ge&&qe&&ut.length===0&&Nt({activeIndex:null})},[Ge,qe,ut.length,Nt]);function qt(){et&&rt!==``&&rt!==String(Ze)&&!Et&&xe(!0)}function Jt(){et&&Se!==null&&Ft(!1)}let Yt=!1;function Xt(){!Yt&&Qe!==it&&(Yt=!0,Pt(it,W(Gl)))}function Zt(){u!==`none`&&(z(Ve),te(Eb(Je,ne.initialValue,A)),le.change(Je),Ue&&!We&&!wt&&Xt())}function Qt(){Ue&&!We&&!wt&&!B&&Xt()}function $t(){u===`none`&&(z(Ve),te(Qe!==ne.initialValue),le.change(Qe))}dx(rt,qt),dx(et,Jt),dx(Je,Zt),dx(it,Qt),dx(me,Qt),dx(Qe,$t);let en=bm({open:Ct?!0:et,onOpenChange:Rt,elements:{reference:wt?bt:xt,floating:vt}}),tn=v?`grid`:`listbox`,nn=et||Ct,rn=nn?`true`:`false`,an=V.useMemo(()=>{let e=xt?.tagName===`INPUT`,t=xt==null||e,n=t||nn,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=rn,r[`aria-haspopup`]=tn,r[`aria-controls`]=nn?yt?.id:void 0,r[`aria-autocomplete`]=h?`none`:I),{reference:r,floating:{role:`presentation`}}},[xt,nn,rn,tn,yt?.id,I,h]),on=xp(en,{enabled:!Be&&C,event:`mousedown-only`,toggle:!1,touchOpenDelay:wt?0:100,reason:eu}),sn=Dp(en,{enabled:!Be&&!Ct,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:Ct?!0:void 0,outsidePress(e){let t=il(e);return!U(bt,t)&&!U(Pe.current,t)&&!U(Ne.current,t)&&!U(St,t)}}),cn=Lm(en,{enabled:!Be,id:de,listRef:Te,activeIndex:gt,selectedIndex:_t,virtual:!0,loopFocus:D,allowEscape:D&&!qe,focusItemOnOpen:B||u===`none`&&!qe?!1:`auto`,focusItemOnHover:E,resetOnPointerLeave:!T,orientation:v?`horizontal`:void 0,rtl:ue===`rtl`,disabledIndices:ec,grid:v?db:void 0,onNavigate(e,t){(t||et||Ct&&e===null)&&Gt!==`ending`&&Nt({activeIndex:e,type:fb(t),event:t?.nativeEvent})}}),ln=V.useMemo(()=>xf(cn.reference,{onKeyDown(e){v&&dt.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},sn.reference,on.reference,an.reference),[cn.reference,sn.reference,on.reference,an.reference,v,dt]),un=V.useMemo(()=>xf(Ip,sn.floating),[sn.floating]),dn=V.useMemo(()=>xf(cn.floating,an.floating),[cn.floating,an.floating]),fn=V.useMemo(()=>{let e=cn.item;return{props:e?{...e,onFocus:void 0}:tc,id:de,selectionMode:u,disabled:Be,readOnly:h,isItemEqualToValue:A}},[cn.item,de,u,Be,h,A]);dt.useContextCallback(`setOpen`,Rt),dt.useContextCallback(`setInputValue`,Pt),dt.useContextCallback(`setSelectedValue`,zt),dt.useContextCallback(`setIndices`,Nt),dt.useContextCallback(`handleSelection`,Bt),dt.useContextCallback(`forceMount`,jt),dt.useContextCallback(`requestSubmit`,Vt),dt.useContextCallback(`onOpenChangeComplete`,n),ub(()=>{dt.update({inline:M,popupProps:un,listProps:dn,inputProps:ln,triggerProps:kt,itemRoot:fn})});let pn={id:de,selectedValue:Je,open:et,mounted:Wt,transitionStatus:Gt,items:ge,inline:M,popupProps:un,listProps:dn,inputProps:ln,triggerProps:kt,itemRoot:fn,openMethod:Ot,selectionMode:u,name:Ve,form:p,disabled:Be,readOnly:h,required:g,grid:v,virtualized:j,openOnInputClick:C,itemToStringLabel:ve,modal:P,autoHighlight:qe,isItemEqualToValue:A,submitOnItemClick:ee,hasInputValue:We};H(()=>{dt.update({...pn,inputOwnsFormValue:u===`none`&&(M||!dt.state.inputInsidePopup)})},[dt,...Object.values(pn)]);let mn=_u(_,le.inputRef),hn=V.useMemo(()=>({query:rt,hasItems:Ge,filteredItems:lt,flatFilteredValues:ut}),[rt,Ge,lt,ut]),gn=V.useMemo(()=>Array.isArray(ft)?``:zb(ft,k),[ft,k]),_n=He&&Array.isArray(Je)&&Je.length>0,vn=He||u===`none`&&Tt?void 0:Ve,yn=V.useMemo(()=>!He||!Array.isArray(Je)||!Ve?null:Je.map(e=>{let t=zb(e,k);return(0,G.jsx)(`input`,{type:`hidden`,form:p,name:Ve,value:t,disabled:Be},t)}),[He,Je,p,Ve,k,Be]),bn=(0,G.jsxs)(V.Fragment,{children:[e.children,(0,G.jsx)(`input`,{...le.getValidationProps(Be,{onFocus(){wt?bt?.focus():(Oe.current||bt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||Be||h)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=W(Gl,e.nativeEvent),i=()=>Re.current.findIndex(e=>zb(e,k).toLowerCase()===n||be(e).toLowerCase()===n);function a(){if(He)return;if(u===`none`){Pt(t,r);return}let e=i();e===-1&&(e=Re.current.findIndex((e,t)=>{let r=Ee.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:Re.current[e];a!=null&&zt?.(a,r)}Ue&&(jt(),me&&i()===-1&&dt.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:de&&vn==null?`${de}-hidden-input`:void 0,form:p,name:vn,autoComplete:L,disabled:Be,required:g&&!_n,readOnly:h,value:gn,ref:mn,style:vn?Lu:Iu,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),yn]});return(0,G.jsx)(pb.Provider,{value:dt,children:(0,G.jsx)(mb.Provider,{value:en,children:(0,G.jsx)(gb.Provider,{value:Ge,children:(0,G.jsx)(hb.Provider,{value:hn,children:(0,G.jsx)(_b.Provider,{value:Qe,children:bn})})})})})}function vx(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return(0,G.jsx)(_x,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}function yx(e,t){let n=ng(e);return H(()=>(t(n),()=>{t(e=>e===n?void 0:e)}),[n,t]),n}function bx(e={}){let{id:t,fallbackControlId:n,native:r=!1,setLabelId:i,focusControl:a}=e,{controlId:o,setLabelId:s}=nx(),c=yx(t,K(e=>{s(e),i?.(e)})),l=o??n;function u(e){if(a){a(e,l);return}if(!l)return;let t=xx(e.currentTarget,l);Lc(t)&&Sx(t)}function d(e){rl(il(e.nativeEvent),`button,input,select,textarea`)||(!e.defaultPrevented&&e.detail>1&&e.preventDefault(),!r&&u(e))}return r?{id:c,htmlFor:l,onMouseDown:d}:{id:c,onClick:d,onPointerDown(e){e.preventDefault()}}}function xx(e,t){let n=e.getRootNode();for(;Rc(n);){let e=n.getElementById(t);if(e)return e;n=n.host.getRootNode()}return Pu(e).getElementById(t)}function Sx(e){e.focus({focusVisible:!0})}function Cx(e){return e==null?void 0:`${e}-label`}function wx(e,t){return e??t}var Tx=`data-popup-side`,Ex=`data-list-empty`,Dx={...Dl,...Jb,popupSide:e=>e?{[Tx]:e}:null,listEmpty:e=>e?{[Ex]:``}:null};function Ox(e,t,n){let{setFocused:r,focusOwnerRef:i}=Zb(),a=K(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return H(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}var kx=V.createContext(void 0);function Ax(){return V.useContext(kx)}var jx=V.createContext(void 0);function Mx(e){let t=V.useContext(jx);if(t===void 0&&!e)throw Error(rc(21));return t}var Nx=V.forwardRef(function(e,t){let n=vb(),{buttonRef:r,getButtonProps:i}=V_({native:!1}),a=_u(t,r);function o(e){n.context.setOpen(!1,W(Zl,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return(0,G.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:Lu})});function Px(e){let t=e.useState(`mounted`),n=e.useState(`popupSide`),r=e.useState(`positionerElement`);return t&&r?n:null}function Fx(){return bb().filteredItems.length===0}function Ix(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function Lx(e,t,n){let r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}var Rx=V.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:c,disabled:l,setTouched:u,validationMode:d,validation:f}=Zb(),{labelId:p}=nx(),m=Ax(),h=!!Mx(!0),g=vb(),_=xb(),v=gg(),y=g.useState(`required`),b=g.useState(`disabled`),x=g.useState(`readOnly`),S=g.useState(`name`),C=g.useState(`form`),w=g.useState(`selectionMode`),T=g.useState(`autoHighlight`),E=g.useState(`inputProps`),D=g.useState(`triggerProps`),O=g.useState(`open`),k=g.useState(`mounted`),A=g.useState(`selectedValue`),j=g.useState(`id`),M=g.useState(`inline`),N=g.useState(`modal`),P=!!T,F=Px(g),I=l||b||i,L=Fx(),R=Ox(I,g.context.inputRef),ee=h||M,z=!ee||N,te=ng(a??(ee?void 0:j)),ne=h?Kb:c,[re,ie]=V.useState(null),ae=V.useRef(!1),oe=V.useRef(null);H(()=>{O||(oe.current=null)},[O]);let se=w===`none`&&!h,ce=K(e=>{let t=h||g.state.inline;t&&!g.state.hasInputValue&&g.context.setInputValue(``,W(Gl)),g.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:se})}),le=h?s:f.getValidationProps(I,s);function ue(e){g.context.setIndices({activeIndex:null,selectedIndex:null,type:fb(e),event:e})}let de={...ne,open:O,disabled:I,readOnly:x,popupSide:F,listEmpty:L};function fe(e){if(!m)return;let t,n=m.chipsRef.current.length,[r]=Ix(v);return e.key===r&&(e.currentTarget.selectionStart??0)===0&&A.length>0&&(e.preventDefault(),t=n>0?n-1:void 0),t}let pe=Pf(`input`,e,{state:de,ref:[t,g.context.inputRef,ce],props:[E,D,{value:re??_,"aria-readonly":x||void 0,"aria-required":y||void 0,"aria-labelledby":p,disabled:I,readOnly:x,required:w===`none`?y:void 0,form:C,...se&&S&&{name:S},id:te,onFocus(){if(R(!0),!M)return;let e=oe.current;oe.current=null,e!=null&&Object.hasOwn(g.context.valuesRef.current,e)&&g.context.setIndices({activeIndex:e})},onBlur(){u(!0),R(!1);let e=g.state.activeIndex;if(M&&e!==null&&T!==`always`&&(oe.current=e,g.context.setIndices({activeIndex:null})),d===`onBlur`){let e=w===`none`?_:A;f.commit(e)}},onCompositionStart(e){vc||(ae.current=!0,ie(e.currentTarget.value))},onCompositionEnd(e){ae.current=!1;let t=e.currentTarget.value;ie(null),g.context.setInputValue(t,W(Ql,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=ae.current||!r;function a(e){!x&&!I&&e&&i&&(g.context.setOpen(!0,W(Ql,t)),P||ue(t))}if(ae.current){let n=e.currentTarget.value;ie(n),n===``&&!g.state.openOnInputClick&&!g.state.inputInsidePopup&&g.context.setOpen(!1,W($l,t));let r=n.trim(),i=P&&r!==``;a(r),O&&g.state.activeIndex!==null&&!i&&ue(t);return}let o=W(Ql,t);if(g.context.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=W($l,t);s&&!g.state.inputInsidePopup&&(w===`single`&&g.context.setSelectedValue(null,c),g.state.openOnInputClick||g.context.setOpen(!1,c)),a(e.currentTarget.value.trim()),O&&g.state.activeIndex!==null&&!P&&ue(t)},onKeyDown(e){if(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;if(I||x){x&&e.key===`Enter`&&O&&g.state.activeIndex!==null&&Tc(e);return}let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=v===`rtl`;if(e.key===`Home`){Tc(e);let n=Sc&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){Tc(e);let i=Sc&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!k&&e.key===`Escape`){let t=w===`multiple`&&Array.isArray(A)?A.length===0:A===null,n=W(nu,e.nativeEvent),r=w===`multiple`?[]:null;g.context.setInputValue(``,n),g.context.setSelectedValue(r,n),t||g.state.inline||n.isPropagationAllowed||e.stopPropagation();return}if(m&&e.key===`Backspace`&&t.value===``&&Array.isArray(A)&&A.length>0){let t=m.chipsRef.current.length,n=t>0?t-1:A.length-1,r=A.filter((e,t)=>t!==n);ue(e.nativeEvent),g.context.setSelectedValue(r,W(Gl,e.nativeEvent));return}let i=fe(e);if(i!==void 0&&m?.chipsRef.current[i]?.focus(),e.which!==229&&e.key===`Enter`&&O){let t=g.state.activeIndex,n=e.nativeEvent;if(t===null){if(M)return;g.context.setOpen(!1,W(Gl,n));return}Tc(e),Lx(g,t,n)}}},le],stateAttributesMapping:Dx}),me=h?(0,G.jsx)(Xb.Provider,{value:Yb,children:pe}):pe;return(0,G.jsxs)(V.Fragment,{children:[O&&z&&(0,G.jsx)(Nx,{ref:g.context.startDismissRef}),me]})});function zx(e,t,n,r){if(e.baseUIHandlerPrevented)return;let i=il(e.nativeEvent),a=Ic(i)?i:null;(a===e.currentTarget||!r?.(a)&&!Fl(a))&&(e.preventDefault(),!n&&(t.context.inputRef.current?.focus(),t.state.openOnInputClick&&t.context.setOpen(!0,W(eu,e.nativeEvent))))}var Bx=V.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{state:o}=Zb(),s=vb(),c=s.useState(`open`),l=s.useState(`disabled`),u=s.useState(`readOnly`),d=s.useState(`hasSelectedValue`),f=s.useState(`selectionMode`),p=Px(s),m=l,h=Fx(),g=f!==`none`&&!d,_={...o,open:c,disabled:m,readOnly:u,popupSide:p,listEmpty:h,placeholder:g};return Pf(`div`,e,{ref:[t,K(e=>{s.set(`inputGroupElement`,e)})],props:[{role:`group`,onMouseDown(e){zx(e,s,m,e=>U(s.context.chipsContainerRef.current,e))}},a],state:_,stateAttributesMapping:Dx})}),Vx=5;function Hx(e,t){let n=Ux(t);return e.clientX>=n.left-Vx&&e.clientX<=n.right+Vx&&e.clientY>=n.top-Vx&&e.clientY<=n.bottom+Vx}function Ux(e){let t=e.getBoundingClientRect(),n=Nc(e);if(wc)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}var Wx=V.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,style:s,...c}=e,{state:l,disabled:u,setTouched:d,validationMode:f,validation:p}=Zb(),{labelId:m}=nx(),h=vb(),g=h.useState(`selectionMode`),_=h.useState(`disabled`),v=h.useState(`readOnly`),y=h.useState(`required`),b=h.useState(`positionerElement`),x=h.useState(`listElement`),S=h.useState(`popupId`),C=h.useState(`triggerProps`),w=h.useState(`inputInsidePopup`),T=h.useState(`id`),E=h.useState(`labelId`),D=h.useState(`open`),O=h.useState(`selectedValue`),k=h.useState(`activeIndex`),A=h.useState(`selectedIndex`),j=h.useState(`hasSelectedValue`),M=yb(),N=xb(),P=lc(),F=u||_||a,I=Fx(),L=Px(h),R=V.useRef(null),ee=Ox(F,R);rx({id:w?o:void 0});let z=w?o??T:o,te=wx(m,E),ne;D&&w?ne=S??ix(T):D&&(ne=x?.id);let re=V.useRef(``);function ie(e){re.current=e.pointerType}let{reference:ae}=Rm(M,{enabled:!D&&!v&&!_&&g===`single`,listRef:h.context.labelsRef,activeIndex:k,selectedIndex:A,onMatch(e){let t=h.context.valuesRef.current[e];t!==void 0&&h.context.setSelectedValue(t,W(Gl))}}),{reference:oe}=xp(M,{enabled:!_,event:`mousedown`}),{buttonRef:se,getButtonProps:ce}=V_({native:i,disabled:F}),le={...l,readOnly:v,open:D,disabled:F,popupSide:L,listEmpty:I,placeholder:g!==`none`&&!j};return Pf(`button`,e,{ref:[t,se,R,K(e=>{h.set(`triggerElement`,e)})],state:le,props:[C,oe,ae,{id:z,tabIndex:w?0:-1,role:w?`combobox`:void 0,"aria-expanded":D,"aria-haspopup":w?`dialog`:`listbox`,"aria-controls":ne,"aria-required":w&&y||void 0,"aria-readonly":w&&v||void 0,"aria-labelledby":te,onPointerDown:ie,onPointerEnter:ie,onFocus(){ee(!0),!F&&P.start(0,h.context.forceMount)},onBlur(e){if(!U(b,e.relatedTarget)&&(d(!0),ee(!1),f===`onBlur`)){let e=g===`none`?N:O;p.commit(e)}},onMouseDown(e){if(F||(w||M.set(`domReferenceElement`,e.currentTarget),h.context.forceMount(),re.current!==`touch`&&(h.context.inputRef.current?.focus(),w||e.preventDefault()),D))return;let t=Pu(e.currentTarget);function n(e){let t=h.state.triggerElement;if(!t)return;let n=il(e),r=h.state.positionerElement,i=h.state.listElement;U(t,n)||U(r,n)||U(i,n)||Hx(e,t)||h.context.setOpen(!1,W(ou,e))}w&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(Tc(e),h.context.setOpen(!0,W(ru,e.nativeEvent)),h.context.inputRef.current?.focus())}},p.getValidationProps(F,c),ce],stateAttributesMapping:Dx})}),Gx=V.createContext(null);function Kx(){return V.useContext(Gx)}function qx(e){let{children:t,items:n}=e,r=V.useMemo(()=>({items:n}),[n]);return(0,G.jsx)(Gx.Provider,{value:r,children:t})}function Jx(e){let{children:t}=e,{filteredItems:n}=bb(),r=Kx(),i=r?r.items:n;return(0,G.jsx)(V.Fragment,{children:i.map(t)})}var Yx=V.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Xx(){return V.useContext(Yx)}function Zx(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=K(i),[,o]=V.useState(0),s=Gs($x).current,c=Gs(Qx).current,l=V.useRef(0),u=V.useRef(!0),d=V.useRef(null),f=V.useRef(null),p=K(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=K((e,t)=>{c.set(e,t),p()}),h=K(e=>{c.delete(e),p()}),g=K(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!nS(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&rS(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=tS(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=K(()=>{let[e,t]=eS(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});H(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),H(()=>{u.current&&v()}),H(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=K(e=>(s.add(e),()=>{s.delete(e)})),b=V.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,G.jsx)(Yx.Provider,{value:b,children:t})}function Qx(){return new Map}function $x(){return new Set}function eS(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>rS(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function tS(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function nS(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function rS(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var iS=V.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=vb(),l=yb(),u=!!Mx(!0),{filteredItems:d,hasItems:f}=bb(),p=c.useState(`selectionMode`),m=c.useState(`grid`),h=c.useState(`readOnly`),g=c.useState(`listProps`),_=c.useState(`virtualized`),v=c.useState(`forceMounted`),y=p===`multiple`,b=d.length===0,x=K(e=>{c.set(`positionerElement`,e)}),S=K(e=>{c.set(`listElement`,e)}),C=V.useMemo(()=>typeof o==`function`?n||=(0,G.jsx)(Jx,{children:o}):o,[o]),w={empty:b},T=l.useState(`floatingId`),E=Pf(`div`,e,{state:w,ref:[t,S,u?null:x],props:[g,{children:C,tabIndex:-1,id:T,role:m?`grid`:`listbox`,"aria-multiselectable":y?`true`:void 0,"aria-readonly":!m&&h?!0:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;Tc(e),Lx(c,t,e.nativeEvent)}}},s]});if(_)return E;let D=f&&!v?void 0:c.context.labelsRef;return(0,G.jsx)(Zx,{elementsRef:c.context.listRef,labelsRef:D,children:E})}),aS=``;function oS(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function sS(e=!0){let t=lc(),n=V.useRef(null);return V.useEffect(()=>{if(!e||gc)return;let r=n.current;if(r==null)return;let i=oS(r);if(i==null)return;let a=i.data,o=`${a}${aS}`;return i.nodeValue=o,t.start(200,()=>{i.nodeValue===o&&(i.nodeValue=a)}),()=>{t.clear(),i.nodeValue===o&&(i.nodeValue=a)}},[e,n,t]),n}var cS=V.createContext(void 0);function lS(){let e=V.useContext(cS);if(e===void 0)throw Error(rc(20));return e}var uS=V.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=vb(),a=i.useState(`mounted`),o=i.useState(`forceMounted`);return a||n||o?(0,G.jsx)(cS.Provider,{value:n,children:(0,G.jsx)(tp,{ref:t,...r})}):null}),dS=V.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,G.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),fS={},pS={},mS=``;function hS(e,t){return zc(e)?e:t}function gS(e,t,n){return/hidden|clip/.test(e.getComputedStyle(hS(t,n)).overflowY)}function _S(e){if(typeof document>`u`)return!1;let t=Pu(e);return Nc(t).innerWidth-t.documentElement.clientWidth>0}function vS(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=Pu(e),n=t.documentElement,r=t.body,i=hS(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function yS(e){let t=Pu(e),n=t.documentElement,r=t.body,i=hS(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function bS(e){let t=Pu(e),n=t.documentElement,r=t.body,i=Nc(n),a=0,o=0,s=!1,c=Mu.create();if(xc&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,fS={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},mS=n.style.scrollBehavior,pS={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=hS(n,r);s=vS(e),s?(n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`):(Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`)}function u(){Object.assign(n.style,fS),Object.assign(r.style,pS),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=mS)}function d(){u(),c.request(l)}l();let f=hu(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var xS=new class{lockCount=0;restore=null;timeoutLock=cc.create();timeoutUnlock=cc.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=Pu(e),n=t.documentElement,r=t.body,i=Nc(n);if(gS(i,n,r)){let t=new i.MutationObserver(()=>{gS(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=gc||!_S(e);this.restore=a?yS(e):bS(e)}};function SS(e=!0,t=null){H(()=>{if(e)return xS.acquire(t)},[e,t])}var CS=20;function wS(e,t,n,r){let[i,a]=V.useState(!1);H(()=>{if(!e||!t||n==null){a(!1);return}let r=Pu(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-CS)},[e,t,n]),SS(e&&(!t||i),r)}var TS=V.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m=!1,collisionAvoidance:h=qf,style:g,..._}=e,v=vb(),y=yb(),b=lS(),x=v.useState(`modal`),S=v.useState(`open`),C=v.useState(`mounted`),w=v.useState(`openMethod`),T=v.useState(`positionerElement`),E=v.useState(`triggerElement`),D=v.useState(`inputElement`),O=v.useState(`inputGroupElement`),k=v.useState(`inputInsidePopup`),A=v.useState(`transitionStatus`),j=Fx(),M=Ag({anchor:i??(k?E:O??D),floatingRootContext:y,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,lazyFlip:!0});wS(S&&x,w===`touch`,T,E);let N={open:S,side:M.side,align:M.align,anchorHidden:M.anchorHidden,empty:j};H(()=>{v.set(`popupSide`,M.side)},[v,M.side]);let P=K(e=>{v.set(`positionerElement`,e)}),F=Pg(e,N,{styles:M.positionerStyles,transitionStatus:A,props:_,refs:[t,P],hidden:!C,inert:!S});return(0,G.jsxs)(jx.Provider,{value:M,children:[C&&x&&(0,G.jsx)(dS,{inert:Rg(!S),cutout:O??D??E}),F]})}),ES={...Ol,...hl},DS=V.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=vb(),l=Mx(),u=yb(),d=c.useState(`mounted`),f=c.useState(`open`),p=c.useState(`openMethod`),m=c.useState(`popupProps`),h=c.useState(`transitionStatus`),g=c.useState(`inputInsidePopup`),_=c.useState(`inputElement`),v=c.useState(`modal`),y=c.useState(`id`),b=Fx(),x=s.id??(g?ix(y):void 0);H(()=>(c.set(`popupId`,c.context.popupRef.current?.id||x),()=>{c.set(`popupId`,void 0)}),[c,x]),Pp({open:f,ref:c.context.popupRef,onComplete(){f&&c.context.onOpenChangeComplete(!0)}});let S=Pf(`div`,e,{state:{open:f,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:b},ref:[t,c.context.popupRef],props:[m,{id:x,role:g?`dialog`:`presentation`,onFocus(e){let t=il(e.nativeEvent);p!==`touch`&&(U(c.state.listElement,t)||t===e.currentTarget)&&c.context.inputRef.current?.focus()}},Ng(h),s],stateAttributesMapping:ES}),C=a===void 0?g?e=>e===`touch`?c.context.popupRef.current:_:!1:a,w;w=o??(g?void 0:!1);let T=!g||v;return(0,G.jsx)(bp,{context:u,disabled:!d,modal:T,openInteractionType:p,initialFocus:C,returnFocus:w,getInsideElements:()=>[c.context.startDismissRef.current,c.context.endDismissRef.current],children:(0,G.jsxs)(V.Fragment,{children:[S,T&&(0,G.jsx)(Nx,{ref:c.context.endDismissRef})]})})}),OS=V.createContext(void 0);function kS(){let e=V.useContext(OS);if(e===void 0)throw Error(rc(18));return e}var AS=V.forwardRef(function(e,t){let{render:n,className:r,style:i,items:a,...o}=e,s=vb().useState(`grid`),[c,l]=V.useState(),u=V.useMemo(()=>({labelId:c,setLabelId:l,items:a}),[c,l,a]),d=Pf(`div`,e,{ref:t,props:[{role:s?`rowgroup`:`group`,"aria-labelledby":c},o]}),f=(0,G.jsx)(OS.Provider,{value:u,children:d});return a?(0,G.jsx)(qx,{items:a,children:f}):f}),jS=V.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{setLabelId:s}=kS(),c=ng(a);return H(()=>(s(c),()=>{s(e=>e===c?void 0:e)}),[c,s]),Pf(`div`,e,{ref:t,props:[{id:c,"aria-hidden":!0},o]})});function MS(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=Xx(),u=V.useRef(-1),[d,f]=V.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=V.useRef(null),h=V.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return H(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var NS=V.createContext(void 0);function PS(){let e=V.useContext(NS);if(!e)throw Error(rc(19));return e}var FS=V.createContext(!1);function IS(){return V.useContext(FS)}function LS(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:l,disabled:u=!1,nativeButton:d=!1,...f}=t,p=V.useRef(null),m=MS({guess:!0,index:l,textRef:p}),h=vb(),g=IS(),_=Sb(),{props:v,id:y,selectionMode:b,disabled:x,readOnly:S,isItemEqualToValue:C}=h.useState(`itemRoot`),w=x||u,T=b!==`none`,E=l??i??m.index,D=E!==-1,O=h.useState(`isActive`,E),k=h.useState(`isSelected`,c),A=V.useRef(null),j=y!=null&&D?`${y}-${E}`:void 0,M=k&&T;H(()=>{if(!D||!r&&l==null)return;let e=h.context.listRef.current;return e[E]=A.current,()=>{delete e[E]}},[D,r,E,l,h]),H(()=>{if(!D||_)return;let e=h.context.valuesRef.current;return e[E]=c,()=>{delete e[E]}},[D,_,E,c,h]),H(()=>{if(!D||_)return;let e=h.state.selectedValue,t=h.state.selectedIndex;h.state.selectionMode===`multiple`&&Array.isArray(e)?t=jb(E,c,h.context.valuesRef.current,e,C,t):Tb(c,e,C)&&(t=E),h.set(`selectedIndex`,t)},[D,_,h,E,c,C]);let{getButtonProps:N,buttonRef:P}=V_({disabled:w,focusableWhenDisabled:!0,native:d,composite:!0}),F={disabled:w,selected:M,highlighted:O};function I(e){function t(){h.context.handleSelection(e,c)}h.state.submitOnItemClick?(Xf.flushSync(t),h.context.requestSubmit()):t()}let L={id:j,role:g?`gridcell`:`option`,"aria-selected":T?M:void 0,tabIndex:void 0,onPointerDownCapture(e){e.isPrimary&&(h.context.pointerDownItemRef.current=e.currentTarget),e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){w||S||I(e.nativeEvent)},onMouseUp(e){let t=h.context.pointerDownItemRef.current===e.currentTarget;h.context.pointerDownItemRef.current=null,!(w||S||e.button!==0||t||!O)&&I(e.nativeEvent)}},R=Pf(`div`,t,{ref:[P,n,m.ref,A],state:F,props:[v,L,f,N]}),ee=V.useMemo(()=>({selected:M,textRef:p}),[M,p]);return(0,G.jsx)(NS.Provider,{value:ee,children:R})}function RS(e){let{componentProps:t,forwardedRef:n}=e,r=vb().useState(`isItemEqualToValue`),{flatFilteredValues:i}=bb(),a=Ob(i,t.value??null,r);return(0,G.jsx)(LS,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:a})}var zS=V.memo(V.forwardRef(function(e,t){let n=vb().useState(`virtualized`);return n&&e.index==null?(0,G.jsx)(RS,{componentProps:e,forwardedRef:t}):(0,G.jsx)(LS,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),BS=V.memo(V.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a,selected:o,...s}=e,c=V.useRef(null),{transitionStatus:l,setMounted:u}=kp(o),d=Pf(`span`,e,{ref:[t,c],state:{selected:o,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:hl});return Pp({batch:!0,enabled:!o,open:o,ref:c,onComplete(){o||u(!1)}}),d})),VS=V.forwardRef(function(e,t){let{selected:n}=PS();return e.keepMounted||n?(0,G.jsx)(BS,{...e,selected:n,ref:t}):null}),HS=V.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=bb(),c=vb(),l=sS(),u=s.length===0?a:null;return Pf(`div`,e,{ref:[t,c.context.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})}),US={field:`_field_15tny_7`,label:`_label_15tny_16`,control:`_control_15tny_28`,group:`_group_15tny_29`,input:`_input_15tny_77`,hint:`_hint_15tny_93`,inputButton:`_inputButton_15tny_114`,icon:`_icon_15tny_135`,empty:`_empty_15tny_145`,toggle:`_toggle_15tny_158`,box:`_box_15tny_169`,mark:`_mark_15tny_201`,switch:`_switch_15tny_211`,thumb:`_thumb_15tny_246`,visuallyHidden:`_visuallyHidden_15tny_288`},WS=e=>e.label,GS=(e,t)=>e.value===t.value,KS=({label:e,options:t,value:n,onChange:r,placeholder:i=``,empty:a,disabled:o=!1})=>{let s=(0,V.useId)();return(0,G.jsxs)(vx,{autoHighlight:!0,disabled:o,isItemEqualToValue:GS,itemToStringLabel:WS,items:t,onValueChange:e=>{r(e?.value??null)},value:t.find(e=>e.value===n)??null,children:[(0,G.jsxs)(`div`,{className:US.field,children:[(0,G.jsx)(`label`,{className:US.label,htmlFor:s,children:e}),(0,G.jsxs)(Bx,{className:US.group,children:[(0,G.jsx)(Rx,{"aria-label":e,className:US.input,id:s,placeholder:i}),(0,G.jsx)(Wx,{"aria-label":`Show ${e} list`,className:US.inputButton,children:(0,G.jsx)(Xv,{})})]})]}),(0,G.jsx)(uS,{children:(0,G.jsx)(TS,{align:`start`,className:qg.positioner,sideOffset:4,children:(0,G.jsxs)(DS,{className:qg.popup,children:[(0,G.jsx)(HS,{className:US.empty,children:a}),(0,G.jsx)(iS,{"aria-label":e,children:e=>(0,G.jsxs)(zS,{className:qg.item,value:e,children:[(0,G.jsx)(`span`,{children:e.label}),(0,G.jsx)(VS,{className:US.icon,children:(0,G.jsx)(Yv,{})})]},e.value)})]})})})]})},qS=({text:e,label:t,resultClass:n})=>{let[r,i]=(0,V.useState)({words:``,count:0}),a=e=>{i(({count:t})=>({words:e,count:t+1}))},o=async()=>{try{await navigator.clipboard.writeText(e),a(`Copied.`)}catch{a(`Copy failed: select the text instead.`)}};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`output`,{className:n,children:(0,G.jsx)(`span`,{children:r.words},r.count)}),(0,G.jsx)(cb,{label:t,onClick:()=>{o()},children:(0,G.jsx)(ny,{})})]})},JS={field:`_field_10412_10`,body:`_body_10412_32`,caption:`_caption_10412_39`,command:`_command_10412_53`,copy:`_copy_10412_69`,result:`_result_10412_78`},YS=({command:e,label:t,caption:n})=>(0,G.jsxs)(`div`,{className:JS.field,children:[(0,G.jsxs)(`div`,{className:JS.body,children:[n===void 0?null:(0,G.jsx)(`span`,{className:JS.caption,children:n}),(0,G.jsx)(`code`,{className:JS.command,children:e})]}),(0,G.jsx)(`span`,{className:JS.copy,children:(0,G.jsx)(qS,{label:t??`Copy ${e}`,resultClass:JS.result,text:e})})]});function XS({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`mounted`),a=e.useState(`disablePointerDismissal`),o=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=V.useState(0),[d,f]=V.useState(0),p=l===0,m=Dp(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=il(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||U(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return SS(r&&o===!0,s),e.useContextCallback(`onNestedDialogOpen`,(t,n)=>{(e.select(`open`)||e.select(`mounted`))&&(u(t),f(n))}),H(()=>{!r&&!i&&(u(0),f(0))},[r,i]),H(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(l+1,d+ +!!n),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),Jp(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var ZS=V.createContext(void 0);function QS(e){let t=V.useContext(ZS);if(!e&&t===void 0)throw Error(rc(27));return t}var $S={...vm,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},eC=class extends lm{constructor(e,t,n){let r=new Xp,i=tC(e,r,t,n);super(i,nC(r),$S)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(Hp(this.state,e,t.trigger)))}};function tC(e,t,n,r=!1){return{...fm(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function nC(e){return{popupRef:V.createRef(),backdropRef:V.createRef(),internalBackdropRef:V.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function rC(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=QS(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=Rp((e,t)=>new eC({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...y},e,t),!0);b.useControlledProp(`openProp`,r),b.useControlledProp(`triggerIdProp`,d),b.useSyncedValues(y),b.useContextCallback(`onOpenChange`,a),b.useContextCallback(`onOpenChangeComplete`,o);let x=b.useState(`open`),S=b.useState(`mounted`),C=b.useState(`payload`);Yp(b,x),Kp(b);let{forceUnmount:w}=qp(x,b);V.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,W(lu))}),[w,b]);let T=x||S||u!=null;return(0,G.jsxs)(ZS.Provider,{value:b,children:[u&&(0,G.jsx)(zp,{handle:u,store:b}),T&&(0,G.jsx)(XS,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}function iC(e){return rC(`alert-dialog`,e)}var aC=V.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=QS(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return Pf(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:kl,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),oC=V.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=QS(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=V_({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,W(Zl,e.nativeEvent))}return Pf(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),sC=V.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=QS(),c=ng(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),Pf(`p`,e,{ref:t,props:[{id:c},o]})}),cC=V.createContext(void 0);function lC(){let e=V.useContext(cC);if(e===void 0)throw Error(rc(26));return e}var uC=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),dC=`--nested-dialogs`,fC=`data-nested-dialog-open`,pC={...Ol,...hl,nestedDialogOpen(e){return e?{[fC]:``}:null}},mC=V.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=QS(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);lC(),Pp({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?Lp(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=Pf(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...Ip,hidden:!m,onKeyDown(e){uC.has(e.key)&&e.stopPropagation()},style:{[dC]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:pC});return(0,G.jsx)(bp,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),hC=V.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=QS(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,G.jsx)(cC.Provider,{value:n,children:(0,G.jsxs)(tp,{ref:t,...r,children:[a&&o===!0&&(0,G.jsx)(dS,{ref:i.context.internalBackdropRef,inert:Rg(!s)}),e.children]})}):null}),gC=V.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=QS(),c=ng(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),Pf(`h2`,e,{ref:t,props:[{id:c},o]})}),_C=Xs(function(e){return rC(`dialog`,e)}),vC={backdrop:`_backdrop_1kwjw_6`,dialog:`_dialog_1kwjw_25`,title:`_title_1kwjw_79`,description:`_description_1kwjw_90`,actions:`_actions_1kwjw_97`,refusal:`_refusal_1kwjw_111`},yC=()=>!0,bC=({open:e,onOpenChange:t,title:n,description:r,children:i,finalFocus:a=yC,initialFocus:o,size:s=`default`})=>(0,G.jsx)(_C,{onOpenChange:e=>{t(e)},open:e,children:(0,G.jsxs)(hC,{children:[(0,G.jsx)(aC,{className:vC.backdrop}),(0,G.jsxs)(mC,{"aria-modal":`true`,className:vC.dialog,"data-modal":``,"data-size":s,finalFocus:a,initialFocus:o??!0,children:[(0,G.jsx)(gC,{className:vC.title,children:(0,G.jsx)(Wg,{text:n})}),r===void 0?null:(0,G.jsx)(sC,{className:vC.description,children:(0,G.jsx)(Wg,{text:r})}),i]})]})}),xC=({children:e})=>(0,G.jsx)(`div`,{className:vC.actions,children:e}),SC=({open:e,onOpenChange:t,title:n,description:r,confirm:i,onConfirm:a,pending:o,variant:s=`danger`,cli:c,finalFocus:l=yC,children:u})=>{let[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(null),h=(0,V.useRef)(null),g=async()=>{let e=a();if(e===void 0){t(!1);return}f(!0),m(null);let n=await e;f(!1),m(n),n===null&&t(!1)};return(0,G.jsx)(iC,{onOpenChange:e=>{d||(e||m(null),t(e))},open:e,children:(0,G.jsxs)(hC,{children:[(0,G.jsx)(aC,{className:vC.backdrop}),(0,G.jsxs)(mC,{"aria-modal":`true`,className:vC.dialog,"data-modal":``,finalFocus:l,initialFocus:h,children:[(0,G.jsx)(gC,{className:vC.title,children:(0,G.jsx)(Wg,{text:n})}),(0,G.jsx)(sC,{className:vC.description,children:(0,G.jsx)(Wg,{text:r})}),u,c===void 0?null:(0,G.jsx)(YS,{command:c}),p===null?null:(0,G.jsx)(`p`,{className:vC.refusal,role:`alert`,children:(0,G.jsx)(Wg,{text:p})}),(0,G.jsxs)(`div`,{className:vC.actions,children:[(0,G.jsx)(oC,{disabled:d,ref:h,render:(0,G.jsx)(q,{focusableWhenDisabled:!0,children:`Cancel`})}),(0,G.jsx)(q,{disabled:d,focusableWhenDisabled:!0,onClick:()=>{g()},variant:s,children:d?o??i:i})]})]})]})})},CC=({title:e,children:t,cli:n,focusable:r=!1})=>(0,G.jsxs)(`div`,{className:Gg.empty,children:[(0,G.jsx)(`p`,{className:Gg.emptyTitle,"data-empty-title":r?``:void 0,tabIndex:r?-1:void 0,children:e}),(0,G.jsx)(`div`,{className:Gg.emptyBody,children:t}),n===void 0?null:(0,G.jsx)(`div`,{className:Gg.emptyCommand,children:(0,G.jsx)(YS,{command:n})})]});function wC(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}var TC=`data-checked`,EC=`data-unchecked`;function DC(e){return{checked(t){return e.indeterminate?{}:t?{[TC]:``}:{[EC]:``}},...Jb}}var OC=V.createContext({disabled:!1});function kC(){return V.useContext(OC)}function AC(e,t,n,r=!0,i,a){let[o,s]=V.useState(),c=ng(i?`${i}-label`:void 0),l=!!a?.trim(),u=e??(l?void 0:t)??o;return H(()=>{let i=e||t||l||!r?void 0:jC(n.current,c);o!==i&&s(i)}),u}function jC(e,t){let n=MC(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function MC(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}var NC=V.createContext(void 0);function PC(){return V.useContext(NC)}var FC=V.createContext(void 0);function IC(){let e=V.useContext(FC);if(e===void 0)throw Error(rc(14));return e}var LC=`data-parent`,RC=V.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":a,disabled:o=!1,form:s,id:c,indeterminate:l=!1,inputRef:u,name:d,onCheckedChange:f,parent:p=!1,readOnly:m=!1,render:h,required:g=!1,uncheckedValue:_,value:v,nativeButton:y=!1,style:b,...x}=e,{clearErrors:S}=ex(),{disabled:C,name:w,setDirty:T,setFilled:E,setTouched:D,state:O,validationMode:k,validityData:A,validation:j}=Zb(),M=kC(),{labelId:N,registerControlId:P,getDescriptionProps:F}=nx(),I=PC(),L=I?.allValues===void 0?void 0:I.parent,R=L!==void 0,ee=C||M.disabled||I?.disabled||o,z=w??d,te=v??z,ne=ng(),re=I?.registerControlId!==P,ie=rx({id:c||void 0,enabled:re}),ae=y?ie:ne,oe={};R&&(p?oe=L.getParentProps():te!==void 0&&(oe=L.getChildProps(te)));let{checked:se=n,indeterminate:ce=l,onCheckedChange:le,...ue}=oe,de=I?.value,fe=V.useRef(null),pe=Ox(ee,fe),{getButtonProps:me,buttonRef:he}=V_({disabled:ee,native:y}),ge=I?.validation??j,[_e,ve]=lb({controlled:te!==void 0&&de!==void 0&&!p?de.includes(te):se,default:i,name:`Checkbox`,state:`checked`}),ye=R?!!se:_e,be=R&&ce||l;Qb(fe,ne,_e,void 0,!I&&!ee,d);let B=L?.registerChildId,xe=V.useRef(null),Se=ge.registerInput,Ce=I?te:void 0,we=V.useCallback(e=>Se(e,{controlRef:fe,value:Ce}),[Se,Ce]),Te=_u(u,xe,p?void 0:we),Ee=AC(a,N,xe,!y,ie,x[`aria-label`]);H(()=>{xe.current&&(xe.current.indeterminate=be),I||E(_e)},[_e,be,I,E]),dx(_e,()=>{I||(S(z),T(_e!==A.initialValue),ge.change(_e))});let De=xf({checked:_e,disabled:ee,form:s,name:p?void 0:z,id:y?void 0:ie,required:g,ref:Te,style:z?Lu:Iu,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(m){e.preventDefault();return}let t=e.currentTarget.checked,n=W(Gl,e.nativeEvent);if(f?.(t,n),!n.isCanceled&&(le?.(t,n),!n.isCanceled&&(ve(t),te!==void 0&&I!==void 0&&!p&&!R))){let e=t?[...I.value,te]:I.value.filter(e=>e!==te);I.setValue(e,n)}},onClick(e){e.stopPropagation()},onFocus(){fe.current?.focus()}},v===void 0?tc:{value:(I?_e&&v:v)||``},F,e=>ge.getValidationProps(ee,e));V.useEffect(()=>{if(!L||te===void 0)return;let e=L.disabledStatesRef.current;return e.set(te,ee),()=>{e.delete(te)}},[L,ee,te]);let Oe=V.useMemo(()=>({...O,checked:ye,disabled:ee,readOnly:m,required:g,indeterminate:be}),[O,ye,ee,m,g,be]),ke=DC(Oe),Ae=Pf(`span`,e,{state:Oe,ref:[he,fe,t],props:[{id:ae,role:`checkbox`,"aria-checked":be?`mixed`:ye,"aria-readonly":m||void 0,"aria-required":g||void 0,"aria-labelledby":Ee,[LC]:p?``:void 0,onFocus(){pe(!0)},onBlur(){let e=xe.current;e&&(D(!0),pe(!1),k===`onBlur`&&ge.commit(I?de:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=xe.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),Nc(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||wC(t)?.click()})},onClick(e){if(m||ee)return;e.preventDefault();let t=xe.current;t&&B_(t,e)}},x,ue,me,F,e=>ge.getValidationProps(ee,e)],stateAttributesMapping:ke}),je=Ae.props.id;return H(()=>{if(B&&!p&&te!==void 0&&je!==void 0)return B(te,je)},[B,p,te,je]),(0,G.jsxs)(FC.Provider,{value:Oe,children:[Ae,!_e&&!I&&z&&!p&&_!==void 0&&(0,G.jsx)(`input`,{type:`hidden`,form:s,name:z,value:_,disabled:ee}),(0,G.jsx)(`input`,{...De,suppressHydrationWarning:!0})]})}),zC=V.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=IC(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=kp(c),f=V.useRef(null),p={...s,transitionStatus:u};Pp({batch:!0,enabled:!c,open:c,ref:f,onComplete(){c||d(!1)}});let m={...DC(s),...hl},h=a||l,g=Pf(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null}),BC=V.createContext(void 0);function VC(){let e=V.useContext(BC);if(e===void 0)throw Error(rc(63));return e}var HC=`data-checked`,UC=`data-unchecked`,WC={...Jb,checked(e){return e?{[HC]:``}:{[UC]:``}}},GC=V.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,"aria-labelledby":a,form:o,id:s,inputRef:c,name:l,nativeButton:u=!1,onCheckedChange:d,readOnly:f=!1,required:p=!1,disabled:m=!1,render:h,uncheckedValue:g,value:_,style:v,...y}=e,{clearErrors:b}=ex(),{state:x,setTouched:S,setDirty:C,validityData:w,setFilled:T,validationMode:E,disabled:D,name:O,validation:k}=Zb(),{labelId:A}=nx(),j=D||m,M=O??l,N=V.useRef(null),P=_u(N,c,k.inputRef),F=V.useRef(null),I=Ox(j,F),L=ng(),R=rx({id:s}),ee=u?void 0:R,[z,te]=lb({controlled:n,default:!!i,name:`Switch`,state:`checked`});Qb(F,L,z,void 0,!j,l),H(()=>{T(z)},[z,T]),dx(z,()=>{b(M),C(z!==w.initialValue),k.change(z)});let{getButtonProps:ne,buttonRef:re}=V_({disabled:j,native:u}),ie=AC(a,A,N,!u,ee,y[`aria-label`]),ae={id:u?R:L,role:`switch`,"aria-checked":z,"aria-readonly":f||void 0,"aria-required":p||void 0,"aria-labelledby":ie,onFocus(){I(!0)},onBlur(){let e=N.current;e&&!j&&(S(!0),I(!1),E===`onBlur`&&k.commit(e.checked))},onClick(e){if(f||j)return;e.preventDefault();let t=N.current;t&&B_(t,e)}},oe={...k.getValidationProps(j),checked:z,disabled:j,form:o,id:ee,name:M,required:p,style:M?Lu:Iu,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:P,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(f){e.preventDefault();return}let t=e.currentTarget.checked,n=W(Gl,e.nativeEvent);d?.(t,n),!n.isCanceled&&te(t)},onClick(e){e.stopPropagation()},onFocus(){F.current?.focus()},..._===void 0?tc:{value:_}},se=V.useMemo(()=>({...x,checked:z,disabled:j,readOnly:f,required:p}),[x,z,j,f,p]),ce=Pf(`span`,e,{state:se,ref:[t,F,re],props:[ae,y,ne,e=>k.getValidationProps(j,e)],stateAttributesMapping:WC});return(0,G.jsxs)(BC.Provider,{value:se,children:[ce,!z&&M&&g!==void 0&&(0,G.jsx)(`input`,{type:`hidden`,form:o,name:M,value:g,disabled:j}),(0,G.jsx)(`input`,{...oe,suppressHydrationWarning:!0})]})}),KC=V.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return Pf(`span`,e,{state:VC(),ref:t,stateAttributesMapping:WC,props:a})}),qC=({label:e,checked:t,onChange:n,disabled:r=!1,describedBy:i})=>(0,G.jsxs)(`label`,{className:US.toggle,children:[(0,G.jsx)(RC,{"aria-describedby":i,checked:t,className:US.box,disabled:r,onCheckedChange:e=>{n(e)},children:(0,G.jsx)(zC,{className:US.mark,children:(0,G.jsx)(Yv,{})})}),e]}),JC=({label:e,checked:t,onChange:n,disabled:r=!1})=>(0,G.jsxs)(`label`,{className:US.toggle,children:[(0,G.jsx)(GC,{checked:t,className:US.switch,disabled:r,onCheckedChange:e=>{n(e)},children:(0,G.jsx)(KC,{className:US.thumb})}),e]});function YC(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var XC=V.createContext(void 0),ZC=V.createContext(void 0);function QC(){let e=V.useContext(XC);if(e===void 0)throw Error(rc(60));return e}function $C(){let e=V.useContext(ZC);if(e===void 0)throw Error(rc(61));return e}var ew={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,multiple:e=>e.multiple,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,highlightItemOnHover:e=>e.highlightItemOnHover,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:zb(t,r)!==``},hasNullItemLabel:(e,t)=>t?Lb(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>Tb(t,e,n)):Tb(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function tw(e,t){return Math.max(0,e-t)}function nw(e,t){if(t<=0)return 0;let n=p_(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function rw(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:y=!1,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S=wb,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=ex(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=Zb(),F=rx({id:t}),I=M||d,L=j??c,[R,ee]=lb({controlled:n,default:y?r??ec:r,name:`Select`,state:`value`}),[z,te]=lb({controlled:a,default:o,name:`Select`,state:`open`}),ne=V.useRef([]),re=V.useRef([]),ie=V.useRef(null),ae=V.useRef(null),oe=V.useRef(0),se=V.useRef(null),ce=V.useRef([]),le=V.useRef(!1),ue=V.useRef(null),de=V.useRef(null),fe=V.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),pe=V.useRef(!1),me=V.useRef(R),{openMethod:he,triggerProps:ge}=px(z),_e=Gs(()=>new lm({id:F,labelId:void 0,modal:m,multiple:y,disabled:I,readOnly:f,required:p,highlightItemOnHover:C,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,value:R,open:z,mounted:z,transitionStatus:void 0,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:tc,triggerProps:tc,itemRoot:{props:tc,multiple:y,disabled:I,readOnly:f,isItemEqualToValue:S},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:$s,setOpen:$s,handleScrollArrowVisibility:$s,onOpenChangeComplete:$s,listRef:ne,popupRef:ie,scrollHandlerRef:ae,scrollArrowsMountedCountRef:oe,valueRef:se,valuesRef:ce,labelsRef:re,typingRef:le,selectionRef:fe,firstItemTextRef:ue,selectedItemTextRef:de,alignItemWithTriggerActiveRef:pe,initialValueRef:me},ew)).current,[ve,ye]=V.useState(!1),{mounted:be,transitionStatus:B,forceUnmount:xe}=Fp({open:z,ref:ie,preventUnmountOnClose:ve,setPreventUnmountOnClose:ye,onUnmount(){_e.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)}}),Se=_e.useState(`activeIndex`),Ce=_e.useState(`selectedIndex`),we=_e.useState(`triggerElement`),Te=_e.useState(`positionerElement`),Ee=zg(he),De=he??Ee,Oe=V.useMemo(()=>y?``:zb(R,x),[y,R,x]),ke=V.useMemo(()=>y&&Array.isArray(R)?R.map(e=>zb(e,x)):zb(R,x),[y,R,x]);Qb(Cu(we),F,R,K(()=>ke),!I,c);let Ae=y?Array.isArray(R)&&R.length>0:R!=null&&Oe!==``;H(()=>{A(Ae)},[Ae,A]),H(function(){let e=Ab(ce.current,R,S,y);e===null&&(de.current=null),!z&&_e.set(`selectedIndex`,e)},[y,z,R,S,_e]),dx(R,()=>{T(L),E(Eb(R,k.initialValue,S)),N.change(R)});let je=K((e,t)=>{let n=t,r=Up(n);s?.(e,n),!t.isCanceled&&(e||ye(r()),te(e),e||t.reason!==`focus-out`&&t.reason!==`outside-press`||(D(!0),O(!1),P===`onBlur`&&N.commit(R)))});V.useImperativeHandle(h,()=>({unmount:xe,close:()=>{_e.state.open&&je(!1,W(lu))}}),[xe,je,_e]);let Me=K((e,t)=>{i?.(e,t),!t.isCanceled&&ee(e)}),Ne=K(e=>{let t=tw(e.scrollHeight,e.clientHeight),n=nw(e.scrollTop,t),r=n>0,i=n<t;_e.set(`scrollUpArrowVisible`,r),_e.set(`scrollDownArrowVisible`,i)}),Pe=bm({open:z,onOpenChange:je,elements:{reference:we,floating:Te}}),Fe=xp(Pe,{enabled:!I,event:`mousedown`}),Ie=Dp(Pe),Le=Lm(Pe,{enabled:!I,listRef:ne,activeIndex:Se,selectedIndex:Ce,disabledIndices:ec,onNavigate(e){(e!==null||z)&&_e.set(`activeIndex`,e)},focusItemOnHover:C}),Re=Rm(Pe,{enabled:!I&&(z||!f&&!y),listRef:re,activeIndex:Se,selectedIndex:Ce,disabledIndices:e=>YC(ne.current[e]),onMatch(e){z?_e.set(`activeIndex`,e):Me(ce.current[e],W(Gl))},onTyping(e){le.current=e}}),ze=V.useMemo(()=>xf(Re.reference,Le.reference,Ie.reference,Fe.reference,ge),[Fe.reference,Re.reference,Le.reference,Ie.reference,ge]),Be=V.useMemo(()=>xf(Ip,Re.floating,Le.floating,Ie.floating),[Re.floating,Le.floating,Ie.floating]),Ve=Le.item??tc,He=V.useMemo(()=>({props:Ve,multiple:y,disabled:I,readOnly:f,isItemEqualToValue:S}),[Ve,y,I,f,S]);_e.useContextCallback(`setValue`,Me),_e.useContextCallback(`setOpen`,je),_e.useContextCallback(`handleScrollArrowVisibility`,Ne),_e.useContextCallback(`onOpenChangeComplete`,_),ub(()=>{_e.update({popupProps:Be,triggerProps:ze,itemRoot:He})}),_e.useSyncedValues({id:F,modal:m,multiple:y,disabled:I,readOnly:f,required:p,highlightItemOnHover:C,value:R,open:z,mounted:be,transitionStatus:B,popupProps:Be,triggerProps:ze,itemRoot:He,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:De});let Ue=_u(g,N.inputRef),We=y?void 0:L,Ge=V.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=zb(e,x);return(0,G.jsx)(`input`,{type:`hidden`,form:l,name:L,value:t,disabled:I},t)}),[y,R,l,L,x,I]);return(0,G.jsxs)(XC.Provider,{value:_e,children:[(0,G.jsx)(ZC.Provider,{value:Pe,children:w}),(0,G.jsx)(`input`,{...N.getValidationProps(I,{onFocus(){_e.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||I||f)return;let t=e.currentTarget.value,n=W(Gl,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=ce.current.findIndex(t=>zb(t,x).toLowerCase()===e||Rb(t,b).toLowerCase()===e);r===-1&&(r=ce.current.findIndex((t,n)=>{let r=re.current[n];return r!=null&&r.toLowerCase()===e}));let i=ce.current[r];i!=null&&Me(i,n)}_e.set(`forceMount`,!0),queueMicrotask(r)}}),id:F&&We==null?`${F}-hidden-input`:void 0,form:l,name:We,autoComplete:u,value:Oe,disabled:I,required:p&&!(y&&Ae),readOnly:f,ref:Ue,style:L?Lu:Iu,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ge]})}var iw=V.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=a;delete o.id;let s=Zb(),c=QC(),l=c.useState(`triggerElement`),u=c.useState(`id`),d=bx({id:Cx(u),fallbackControlId:l?.id??u,setLabelId(e){let t=typeof e==`function`?e(c.state.labelId):e;c.set(`labelId`,t)}});return Pf(`div`,e,{ref:t,state:s.state,props:[d,a],stateAttributesMapping:Jb})}),aw=`data-popup-side`,ow=400,sw={...Dl,...Jb,popupSide:e=>e?{[aw]:e}:null,value:()=>null},cw=V.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,validationMode:u,validation:d,state:f,disabled:p}=Zb(),{labelId:m}=nx(),h=QC(),g=h.useState(`readOnly`),_=h.useState(`required`),v=h.useState(`disabled`),y=p||v||a,b=h.useState(`open`),x=h.useState(`mounted`),S=h.useState(`value`),C=h.useState(`triggerProps`),w=h.useState(`positionerElement`),T=h.useState(`listElement`),E=h.useState(`popupSide`),D=h.useState(`id`),O=h.useState(`labelId`),k=h.useState(`hasSelectedValue`),A=x&&w?E:null,j=i??D,M=wx(m,O);rx({id:i});let N=Cu(w),P=V.useRef(null),F=Ox(y,P),{getButtonProps:I,buttonRef:L}=V_({disabled:y,native:o}),R=h.useStateSetter(`triggerElement`),ee=lc(),z=lc(),te=lc();V.useEffect(()=>{if(b)return te.start(ow,()=>{h.context.selectionRef.current.allowUnselectedMouseUp=!0,h.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{te.clear()};h.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},z.clear()},[b,h,z,te]);let ne=xf(C,{id:j,role:`combobox`,"aria-expanded":b,"aria-haspopup":`listbox`,"aria-controls":b?T?.id??Rl(w)?.id:void 0,"aria-labelledby":M,"aria-readonly":g||void 0,"aria-required":_||void 0,tabIndex:y?-1:0,onFocus(e){F(!0),b&&h.context.alignItemWithTriggerActiveRef.current&&h.context.setOpen(!1,W(Gl,e.nativeEvent)),ee.start(0,()=>{h.set(`forceMount`,!0)})},onBlur(e){U(w,e.relatedTarget)||(l(!0),F(!1),u===`onBlur`&&d.commit(S))},onMouseDown(e){if(b)return;let t=Pu(e.currentTarget);function n(e){if(!P.current)return;let t=e.target;U(P.current,t)||U(N.current,t)||Hx(e,P.current)||h.context.setOpen(!1,W(ou,e))}z.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,I),re=d.getValidationProps(y,ne);re.role=`combobox`;let ie={...f,open:b,disabled:y,value:S,readOnly:g,popupSide:A,placeholder:!k};return Pf(`button`,e,{ref:[t,P,L,R],state:ie,stateAttributesMapping:sw,props:re})}),lw={value:()=>null},uw=V.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=QC(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?Vb(l,u,d):Bb(l,u,d)),Pf(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:lw})}),dw=V.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return Pf(`span`,e,{state:{open:QC().useState(`open`)},ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:El})}),fw=V.forwardRef(function(e,t){let n=QC(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,G.jsx)(tp,{ref:t,...e}):null}),pw=V.createContext(void 0);function mw(){let e=V.useContext(pw);if(!e)throw Error(rc(59));return e}function hw(e,t){e&&Object.assign(e.style,t)}var gw={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},_w={position:`fixed`},vw=V.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=qf,style:_,...v}=e,y=QC(),b=$C(),x=y.useState(`open`),S=y.useState(`mounted`),C=y.useState(`modal`),w=y.useState(`value`),T=y.useState(`openMethod`),E=y.useState(`positionerElement`),D=y.useState(`triggerElement`),O=y.useState(`isItemEqualToValue`),k=y.useState(`transitionStatus`),A=V.useRef(null),j=V.useRef(null),[M,N]=V.useState(h),P=S&&M&&T!==`touch`;!S&&M!==h&&N(h),V.useImperativeHandle(y.context.alignItemWithTriggerActiveRef,()=>P),wS((P||C)&&x,T===`touch`,E,D);let F=Ag({anchor:n,floatingRootContext:b,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??P,collisionAvoidance:g,keepMounted:!0}),I=P?`none`:F.side,L=P?_w:F.positionerStyles,R={open:x,side:I,align:F.align,anchorHidden:F.anchorHidden};H(()=>{y.set(`popupSide`,F.side)},[y,F.side]);let ee=Pg(e,R,{styles:L,transitionStatus:k,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x}),z=V.useRef(0),te=K(e=>{if(y.context.valuesRef.current.length===0)return;let t=z.current;z.current=e.size;let n=W(Gl);if(t!==0&&!y.state.multiple&&w!==null&&Ob(y.context.valuesRef.current,w,O)===-1){let e=y.context.initialValueRef.current,t=e!=null&&Ob(y.context.valuesRef.current,e,O)!==-1?e:null;y.context.setValue(t,n),t===null&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null)}if(t!==0&&y.state.multiple&&Array.isArray(w)){let e=w.filter(e=>Ob(y.context.valuesRef.current,e,O)!==-1);e.length!==w.length&&(y.context.setValue(e,n),e.length===0&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null))}if(x&&P){y.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};hw(E,e),hw(y.context.popupRef.current,e)}}),ne=V.useMemo(()=>({...F,side:I,alignItemWithTriggerActive:P,setControlledAlignItemWithTrigger:N,scrollUpArrowRef:A,scrollDownArrowRef:j}),[F,I,P,N]);return(0,G.jsx)(Zx,{elementsRef:y.context.listRef,labelsRef:y.context.labelsRef,onMapChange:te,children:(0,G.jsxs)(pw.Provider,{value:ne,children:[S&&C&&(0,G.jsx)(dS,{inert:Rg(!x),cutout:D}),ee]})})}),yw=`base-ui-disable-scrollbar`,bw={className:yw,getElement(e){return(0,G.jsx)(`style`,{nonce:e,href:yw,precedence:`base-ui:low`,children:`.${yw}{scrollbar-width:none}.${yw}::-webkit-scrollbar{display:none}`})}},xw=V.createContext(void 0);function Sw(e){let t=V.useContext(xw);if(t===void 0&&!e)throw Error(rc(69));return t}var Cw=`--transform-origin`,ww={...Ol,...hl},Tw=V.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=QC(),c=s.useState(`multiple`),l=s.useState(`readOnly`),u=s.useState(`highlightItemOnHover`),d=$C(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=mw(),_=Sw(!0)!=null,v=gg(),{nonce:y,disableStyleElements:b}=k(),x=s.useState(`id`),S=s.useState(`open`),C=s.useState(`openMethod`),w=s.useState(`mounted`),T=s.useState(`popupProps`),E=s.useState(`transitionStatus`),D=s.useState(`triggerElement`),O=s.useState(`positionerElement`),A=s.useState(`listElement`),j=V.useRef(!1),M=V.useRef(!1),N=V.useRef({}),P=Nu(),F=K(e=>{if(!O||!s.context.popupRef.current||!M.current)return;let t=O.style.top===`0px`,n=O.style.bottom===`0px`;if(j.current||!m||!t&&!n){s.context.handleScrollArrowVisibility(e);return}let r=Ow(O),i=kw(O.getBoundingClientRect().height,`y`,r),a=Pu(O),o=Nc(O),c=o.getComputedStyle(O),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=Ew(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=Dw(e),g=null,_=e=>{O.style.height=`${e}px`},v=t?h-p:p,y=Math.min(i+v,f);if(v<=1){let n=p_(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?h:0,f-(i+n)<=1&&(j.current=!0),s.context.handleScrollArrowVisibility(e);return}f-y>1?g=t?1/0:0:n&&p<h&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=p_(g,0,Dw(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(j.current=!0),s.context.handleScrollArrowVisibility(e)});V.useImperativeHandle(s.context.scrollHandlerRef,()=>F,[F]),Pp({open:S,ref:s.context.popupRef,onComplete(){S&&s.context.onOpenChangeComplete(!0)}});let I={open:S,transitionStatus:E,side:f,align:p};H(()=>{O&&s.context.popupRef.current&&!Object.keys(N.current).length&&(N.current={top:O.style.top||`0`,left:O.style.left||`0`,right:O.style.right,height:O.style.height,bottom:O.style.bottom,minHeight:O.style.minHeight,maxHeight:O.style.maxHeight,marginTop:O.style.marginTop,marginBottom:O.style.marginBottom})},[s,O]),H(()=>{S||m||(M.current=!1,j.current=!1,hw(O,N.current))},[S,m,O]),H(()=>{let e=s.context.popupRef.current;if(!S||!D||!O||!e||m&&!h||s.state.transitionStatus===`ending`)return;if(M.current=!0,e.style.removeProperty(Cw),!m){P.request(()=>s.context.handleScrollArrowVisibility(A||e));return}let t=Mw(e);try{let t=s.context.selectedItemTextRef.current;t?.isConnected||(t=!s.select(`hasSelectedValue`)&&s.context.firstItemTextRef.current?.isConnected?s.context.firstItemTextRef.current:null);let n=s.context.valueRef.current,r=Nc(O),i=r.getComputedStyle(O),a=r.getComputedStyle(e),o=Pu(D),c=Ow(D),l=Aw(D.getBoundingClientRect(),c),d=Aw(O.getBoundingClientRect(),c),f=l.height,p=A||e,m=p.scrollHeight,h=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,b=parseFloat(i.minHeight)||100,x=Ew(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-l.bottom+f,T,E=v===`rtl`?l.right-d.width:l.left,k=0;if(t&&n){let e=Aw(n.getBoundingClientRect(),c);T=Aw(t.getBoundingClientRect(),c),E=d.left+(v===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-l.top+e.height/2;k=T.top-d.top+T.height/2-r}let M=w+k+y+h,P=Math.min(S,M),F=S-_-y,I=M-P,L=C-5;O.style.left=`${p_(E,5,L-d.width)}px`,O.style.height=`${P}px`,O.style.maxHeight=`none`,O.style.marginTop=`${_}px`,O.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=Dw(p),ee=I>=R-1;ee&&(P=Math.min(S,d.height)-(I-R));let z=l.top<20||l.bottom>S-20||Math.ceil(P)+1<Math.min(m,b),te=(r.visualViewport?.scale??1)!==1&&xc;if(z||te){hw(O,N.current),g(!1);return}let ne=Math.max(b,P);if(ee){let e=Math.max(0,S-M);O.style.top=d.height>=F?`0`:`${e}px`,O.style.height=`${P}px`,p.scrollTop=Dw(p)}else O.style.bottom=`0`,p.scrollTop=I;if(T){let t=d.top,n=d.height,r=T.top+T.height/2,i=p_(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(Cw,`50% ${i}%`)}(ne===S||P>=x)&&(j.current=!0),s.context.handleScrollArrowVisibility(p),u&&s.state.selectedIndex===null&&s.state.activeIndex===null&&s.context.listRef.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,S,O,D,m,g,P,A,u,v,h]),V.useEffect(()=>{if(!m||!O||!S)return;let e=Nc(O);function t(e){s.context.setOpen(!1,W(uu,e))}return hu(e,`resize`,t)},[s,m,O,S]);let L={...A?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":c||void 0,"aria-readonly":l||void 0,id:`${x}-list`},onKeyDown(e){_&&uC.has(e.key)&&e.stopPropagation()},onScroll(e){A||F(e.currentTarget)},...m&&{style:A?{height:`100%`}:gw},className:!A&&m?bw.className:void 0},R=Pf(`div`,e,{ref:[t,s.context.popupRef],state:I,stateAttributesMapping:ww,props:[T,L,Ng(E),o]});return(0,G.jsxs)(V.Fragment,{children:[!b&&bw.getElement(y),(0,G.jsx)(bp,{context:d,modal:!1,disabled:!w,openInteractionType:C,returnFocus:a,restoreFocus:!0,children:R})]})});function Ew(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function Dw(e){return tw(e.scrollHeight,e.clientHeight)}function Ow(e){return kh.getScale(e)}function kw(e,t,n){return e/n[t]}function Aw(e,t){return dd({x:kw(e.x,`x`,t),y:kw(e.y,`y`,t),width:kw(e.width,`x`,t),height:kw(e.height,`y`,t)})}var jw=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function Mw(e){let{style:t}=e,n={};for(let[e,r]of jw)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of jw){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var Nw=V.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=QC(),s=o.useState(`multiple`),c=o.useState(`readOnly`),{alignItemWithTriggerActive:l}=mw(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:gw},className:u&&d!==`touch`?bw.className:void 0};return Pf(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),Pw=V.createContext(void 0);function Fw(){let e=V.useContext(Pw);if(!e)throw Error(rc(57));return e}var Iw=V.memo(V.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=V.useRef(null),d=MS({guess:!0,label:o,textRef:u}),f=QC(),{props:p,multiple:m,disabled:h,readOnly:g,isItemEqualToValue:_}=f.useState(`itemRoot`),v=h||s,y=f.useState(`isActive`,d.index),b=f.useState(`open`),x=f.useState(`isSelected`,a),S=f.useState(`isSelectedByFocus`,d.index),C=d.index,w=V.useRef(null);H(()=>{let e=f.context.valuesRef.current;return e[C]=a,()=>{delete e[C]}},[C,a,f]),H(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=jb(C,a,f.context.valuesRef.current,e,_,t),r=n===C,C===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&Tb(a,e,_),r&&(n=C)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[C,m,_,f,a]);let T=V.useRef(`mouse`),E=V.useRef(!1),{getButtonProps:D,buttonRef:O}=V_({disabled:v,focusableWhenDisabled:!0,native:c,composite:!0}),k={disabled:v,selected:x,highlighted:y};function A(e){if(h||g)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=x?Mb(n,a,_):[...n,a];f.context.setValue(r,W(Xl,e))}else f.context.setValue(a,W(Xl,e)),f.context.setOpen(!1,W(Xl,e))}function j(){f.context.selectionRef.current.dragY=0}let M={role:`option`,"aria-selected":x,tabIndex:b&&y?0:-1,onKeyDown(e){f.set(`activeIndex`,C),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=T.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&Dc(e.nativeEvent)&&(n!==void 0||y),i=t&&!r&&!E.current;E.current=!1,!(v||i)&&A(e.nativeEvent)},onPointerEnter(e){T.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){T.current=e.pointerType,E.current=!0,j()},onMouseUp(){if(j(),v||T.current===`touch`||E.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&x,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!x;e||t||(E.current=!0,w.current?.click(),E.current=!1)}},N=Pf(`div`,e,{ref:[O,t,d.ref,w],state:k,props:[p,M,l,D]}),P=V.useMemo(()=>({selected:x,index:C,textRef:u,selectedByFocus:S}),[x,C,u,S]);return(0,G.jsx)(Pw.Provider,{value:P,children:N})})),Lw=V.forwardRef(function(e,t){let{selected:n}=Fw();return e.keepMounted||n?(0,G.jsx)(BS,{...e,selected:n,ref:t}):null}),Rw=V.memo(V.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=Fw(),a=QC(),{render:o,className:s,style:c,...l}=e;return Pf(`div`,e,{ref:[V.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]),t,r],props:l})})),zw=({children:e})=>(0,G.jsx)(`span`,{className:US.visuallyHidden,children:e}),Bw=({label:e,unseen:t,options:n,value:r,onChange:i,describedBy:a})=>(0,G.jsxs)(rw,{items:n,onValueChange:e=>{e!==null&&i(e)},value:r,children:[(0,G.jsxs)(`div`,{className:US.field,children:[(0,G.jsxs)(iw,{className:US.label,children:[e,t===void 0?null:(0,G.jsx)(zw,{children:t})]}),(0,G.jsxs)(cw,{"aria-describedby":a,className:US.control,children:[(0,G.jsx)(uw,{}),(0,G.jsx)(dw,{className:US.icon,children:(0,G.jsx)(Xv,{})})]})]}),(0,G.jsx)(fw,{children:(0,G.jsx)(vw,{align:`start`,alignItemWithTrigger:!1,className:qg.positioner,sideOffset:4,children:(0,G.jsx)(Tw,{className:qg.popup,children:(0,G.jsx)(Nw,{"aria-label":e,children:n.map(e=>(0,G.jsxs)(Iw,{className:qg.item,value:e.value,children:[(0,G.jsx)(Rw,{children:e.label}),(0,G.jsx)(Lw,{className:US.icon,children:(0,G.jsx)(Yv,{})})]},e.value))})})})})]}),Vw=V.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFilled:y,validationMode:b,validation:x}=Zb(),{clearErrors:S,elementRef:C,submitCountRef:w}=ex(),T=h||s,E=m??a,D={...p,disabled:T},{labelId:O}=nx(),k=rx({id:i}),A=o!==void 0,j=o==null?void 0:String(o),M=K(()=>x.inputRef.current?.value);Qb(x.inputRef,k,j,M,!T,a),H(()=>{let e=j??x.inputRef.current?.value;e!==void 0&&y(e!==``)},[j,l,x.inputRef,y]),dx(j,()=>{j!==void 0&&(S(E),_(j!==(v.initialValue??``)),x.change(j))});let N=V.useRef(null),P=Ox(T,N),F=lc();return Pf(`input`,e,{ref:[t,N],state:D,props:[{id:k,disabled:T,name:E,ref:x.inputRef,"aria-labelledby":O,autoFocus:u,...A?{value:o}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=W(Gl,e.nativeEvent);c?.(t,n),!A&&(_(t!==(v.initialValue??``)),y(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(S(E),x.change(t)))},onFocus(){P(!0)},onBlur(e){if(g(!0),P(!1),b===`onBlur`){let t=e.currentTarget.value;x.commit(t),A&&queueMicrotask(()=>{let e=x.inputRef.current?.value;e!==void 0&&e!==t&&e!==(v.initialValue??``)&&x.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){g(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===C.current&&!e.defaultPrevented){let t=e.currentTarget,n=w.current;F.start(0,()=>{w.current===n&&x.commit(t.value)})}else x.commit(t)}}},f,e=>x.getValidationProps(T,e)],stateAttributesMapping:Jb})}),Hw=V.forwardRef(function(e,t){return(0,G.jsx)(Vw,{ref:t,...e})}),Uw=({label:e,unseen:t,value:n,onChange:r,onCommit:i,multiline:a=!1,rows:o=4,description:s,required:c=!1,type:l=`text`})=>{let u=(0,V.useId)(),d=`${u}-description`;return(0,G.jsxs)(`div`,{className:US.field,children:[(0,G.jsxs)(`label`,{className:US.label,htmlFor:u,children:[e,t===void 0?null:(0,G.jsx)(zw,{children:t}),c?` (required)`:``]}),(0,G.jsx)(`div`,{className:US.group,children:(0,G.jsx)(Hw,{"aria-describedby":s===void 0?void 0:d,className:US.input,id:u,onBlur:i,onKeyDown:e=>{e.key===`Enter`&&!a&&i?.()},onValueChange:e=>{r(e)},render:a?(0,G.jsx)(`textarea`,{rows:o}):void 0,required:c,type:a?void 0:l,value:n})}),s===void 0?null:(0,G.jsx)(`p`,{className:US.hint,id:d,children:(0,G.jsx)(Wg,{text:s})})]})},Ww={panel:`_panel_1pbue_7`,tools:`_tools_1pbue_19`,main:`_main_1pbue_35`,list:`_list_1pbue_47`,row:`_row_1pbue_60`,rowTop:`_rowTop_1pbue_97`,rowMeta:`_rowMeta_1pbue_98`,workflow:`_workflow_1pbue_130`,note:`_note_1pbue_137`,form:`_form_1pbue_146`,group:`_group_1pbue_154`,legend:`_legend_1pbue_166`,reason:`_reason_1pbue_185`,error:`_error_1pbue_186`,triggers:`_triggers_1pbue_218`,triggersTitle:`_triggersTitle_1pbue_236`,triggerList:`_triggerList_1pbue_253`,triggerName:`_triggerName_1pbue_264`,triggerLine:`_triggerLine_1pbue_272`,triggerCommand:`_triggerCommand_1pbue_281`},Gw=[{value:``,label:`The workflow's, else the one ready`},{value:`sdk`,label:`sdk: API key or cloud provider`},{value:`cli`,label:`cli: your claude login`}],Kw=({workflow:e,values:t,onChange:n})=>(0,G.jsx)(G.Fragment,{children:Object.entries(e.inputs).map(([e,r])=>r.type===`boolean`?(0,G.jsx)(qC,{checked:t[e]===`true`,label:e,onChange:t=>{n(e,String(t))}},e):(0,G.jsx)(Uw,{description:r.description,label:e,onChange:t=>{n(e,t)},required:r.required===!0,type:r.type===`number`?`number`:`text`,value:t[e]??``},e))}),qw=({value:e,onChange:t})=>(0,G.jsx)(Bw,{label:`Driver`,onChange:e=>{let n=Gw.find(t=>t.value===e);n!==void 0&&t(n.value)},options:Gw,value:e}),Jw=({flags:e,onChange:t})=>(0,G.jsxs)(`fieldset`,{className:Ww.group,children:[(0,G.jsx)(`legend`,{className:Ww.legend,children:`Flags`}),(0,G.jsx)(qw,{onChange:e=>{t({driver:e})},value:e.driver}),(0,G.jsx)(qC,{checked:e.inPlace,label:`--in-place: run worktree nodes in this checkout`,onChange:e=>{t({inPlace:e})}}),(0,G.jsx)(qC,{checked:e.allowDirty,label:`--allow-dirty: run with uncommitted instructions or skills`,onChange:e=>{t({allowDirty:e})}}),(0,G.jsx)(Xw,{checked:e.machineClaude,onChange:e=>{t({machineClaude:e})}})]}),Yw=`Your MCP servers and Claude's memory`,Xw=({checked:e,onChange:t})=>{let n=(0,V.useId)();return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(qC,{checked:e,describedBy:n,label:`Use this machine's Claude setup`,onChange:t}),(0,G.jsx)(`p`,{className:US.hint,id:n,children:Yw})]})},Zw=()=>(0,G.jsx)(CC,{cli:`ork init`,title:`No projects yet.`,children:`Run this in a repository:`}),Qw=({error:e})=>(0,G.jsx)(`p`,{className:Ww.error,role:`alert`,children:(0,G.jsx)(Wg,{text:e})}),$w={driver:``,inPlace:!1,allowDirty:!1,machineClaude:!1},eT=({default:e,type:t})=>e===void 0?t===`boolean`?`false`:``:String(e),tT=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,eT(t)])),nT=(e,t,n)=>e===null?null:t.status===`failed`?`Cannot read the workflows of ${e}: ${t.error??`unknown error`}`:t.status===`ready`&&n===0?`${e} has no workflows. Add one to its .ork/workflows folder.`:null,rT=(e,t,n)=>e===null?`Choose a project first`:t?`Reading workflows…`:n===0?`No workflows here`:`Type to find a workflow`,iT=(e,t,n)=>{if(e===null)return`Pick a project.`;if(t===null)return`Pick a workflow.`;if(t.error!==void 0)return`This workflow does not parse: ${t.error}`;for(let[e,r]of Object.entries(t.inputs)){let t=n[e]??``;if(r.required===!0&&t===``)return`Fill in ${e}.`;if(r.type===`number`&&t!==``&&!Number.isFinite(Number(t)))return`${e} must be a number.`}return null},aT=(e,t)=>Object.fromEntries(Object.entries(e).flatMap(([e,n])=>{let r=t[e]??``;return r===``||r===eT(n)?[]:[[e,r]]})),oT=/^[\w./:=@%+,-]+$/u,sT=e=>oT.test(e)?e:`'${e.replaceAll(`'`,String.raw`'\''`)}'`,cT=(e,t,n)=>[`ork run`,sT(e.name),`--detach`,...Object.entries(aT(e.inputs,t)).map(([e,t])=>`--input ${sT(`${e}=${t}`)}`),...n.driver===``?[]:[`--driver ${n.driver}`],...n.inPlace?[`--in-place`]:[],...n.allowDirty?[`--allow-dirty`]:[],...n.machineClaude?[`--machine-claude`]:[]].join(` `),lT=[],uT=e=>{let t=qy(),n=ab(t.workflows.state);(0,V.useEffect)(()=>{e!==null&&t.workflows.load(e)},[t,e]);let r=n.status!==`idle`&&n.arg===e,i=r&&n.status===`ready`?n.data:lT;return{list:i,reading:!r||n.status===`loading`,problem:nT(e,r?n:{status:`idle`},i.length)}},dT=(e,t)=>[...document.querySelectorAll(`[${e}]`)].find(n=>n.getAttribute(e)===t)??null,fT=e=>dT(`data-run-heading`,e)??dT(`data-run-row`,e)??document.querySelector(`[data-run-workflow]`)??!0,pT=()=>{let e=(0,V.useRef)(null);return{onStarted:t=>{e.current=t},finalFocus:()=>{let t=e.current;return e.current=null,t===null||fT(t)}}},mT=(e,t)=>{let n=qy(),r=ab(n.projects.state),i=(0,V.useMemo)(()=>r.status===`ready`?r.data:[],[r]),[a]=(0,V.useState)(()=>n.runPreset.getValue()),[o,s]=(0,V.useState)(a?.project??null),[c,l]=(0,V.useState)(a?.workflow??null),[u,d]=(0,V.useState)({}),[f,p]=(0,V.useState)($w),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(!1),v=o??(i.length===1?i[0]?.id??null:null),{list:y,reading:b,problem:x}=uT(v),S=c??(y.length===1?y[0]?.name:null),C=y.find(({name:e})=>e===S)??null,w=(0,V.useMemo)(()=>({...tT(C?.inputs??{}),...u}),[C,u]),T=x??iT(v,C,w);return(0,V.useEffect)(()=>{n.projects.load()},[n]),{projectsRead:r,projects:i,project:v,workflows:y,readingWorkflows:b,workflow:C,values:w,flags:f,blocked:T,refusal:m,starting:g,start:async()=>{if(T!==null||g||v===null||C===null)return;_(!0),h(null);let r=await n.startRun({project:v,workflow:C.name,inputs:aT(C.inputs,w),...f.driver===``?{}:{driver:f.driver},...f.inPlace?{inPlace:!0}:{},...f.allowDirty?{allowDirty:!0}:{},...f.machineClaude?{machineClaude:!0}:{}});_(!1),r.ok?(n.arriveAt(r.data.runId),Hy.add({title:`Run ${r.data.runId} started`}),t(r.data.runId),e()):h(r.error)},setFlags:p,chooseProject:e=>{s(e),l(null),d({})},chooseWorkflow:e=>{l(e),d({})},setInput:(e,t)=>{d(n=>({...n,[e]:t}))}}},hT=({onDone:e,onStarted:t})=>{let n=mT(e,t),{projectsRead:r,projects:i,project:a,workflows:o,workflow:s}=n,{readingWorkflows:c}=n,{values:l,flags:u,blocked:d,refusal:f,starting:p}=n,m=(0,G.jsx)(xC,{children:(0,G.jsx)(q,{onClick:e,variant:`ghost`,children:`Close`})});return r.status===`failed`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Qw,{error:`Cannot read the projects: ${r.error}`}),m]}):r.status===`ready`&&i.length===0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Zw,{}),m]}):(0,G.jsxs)(`form`,{className:Ww.form,onSubmit:e=>{e.preventDefault(),n.start()},children:[(0,G.jsx)(KS,{empty:`No project matches.`,label:`Project`,onChange:n.chooseProject,options:i.map(({id:e})=>({value:e,label:e})),placeholder:`Type to find a project`,value:a}),(0,G.jsx)(KS,{disabled:a===null||o.length===0,empty:`No workflow matches.`,label:`Workflow`,onChange:n.chooseWorkflow,options:o.map(({name:e})=>({value:e,label:e})),placeholder:rT(a,c,o.length),value:s?.name??null}),s===null?null:(0,G.jsx)(Kw,{onChange:n.setInput,values:l,workflow:s}),(0,G.jsx)(Jw,{flags:u,onChange:e=>{n.setFlags(t=>({...t,...e}))}}),s===null?null:(0,G.jsx)(YS,{command:cT(s,l,u)}),(0,G.jsx)(`output`,{className:Ww.reason,children:d}),f===null?null:(0,G.jsx)(Qw,{error:f}),(0,G.jsxs)(xC,{children:[(0,G.jsx)(q,{onClick:e,type:`button`,variant:`ghost`,children:`Cancel`}),(0,G.jsx)(q,{disabled:d!==null||p,focusableWhenDisabled:!0,type:`submit`,variant:`primary`,children:p?`Starting…`:`Start run`})]})]})},gT=()=>{let{runDialog:e,runPreset:t}=qy(),n=ab(e),{finalFocus:r,onStarted:i}=pT();return(0,G.jsx)(bC,{description:`Starts in the background, from the project's root.`,finalFocus:r,onOpenChange:n=>{n||t.setValue(null),e.setValue(n)},open:n,title:`Run workflow`,children:(0,G.jsx)(hT,{onDone:()=>{t.setValue(null),e.setValue(!1)},onStarted:i})})},_T=e=>/mac|iphone|ipad/iu.test(e),vT=(e,t,n)=>{let r=t.mod===!0;return e.code===t.code&&e.altKey===(t.alt===!0)&&e.shiftKey===(t.shift===!0)&&e.metaKey===(r&&n)&&e.ctrlKey===(t.ctrl===!0||r&&!n)},yT=(e,t)=>{let n=e.glyph??e.key;return[...e.ctrl===!0?[t?`⌃`:`Ctrl`]:[],...e.mod===!0?[t?`⌘`:`Ctrl`]:[],...e.alt===!0?[t?`⌥`:`Alt`]:[],...e.shift===!0?[t?`⇧`:`Shift`]:[],n]},bT=(e,t)=>[...e.ctrl===!0?[`Control`]:[],...e.mod===!0?[t?`Meta`:`Control`]:[],...e.alt===!0?[`Alt`]:[],...e.shift===!0?[`Shift`]:[],e.key].join(`+`),xT=(e,t,n)=>({code:e,key:t,...n===void 0?{}:{glyph:n},alt:!0,shift:!0}),ST={left:[`ArrowLeft`,`←`],right:[`ArrowRight`,`→`],up:[`ArrowUp`,`↑`],down:[`ArrowDown`,`↓`]},CT={palette:{code:`KeyK`,key:`K`,mod:!0},minimize:xT(`KeyM`,`M`),maximize:xT(`KeyX`,`X`),float:xT(`KeyF`,`F`),close:xT(`KeyW`,`W`),nextGroup:xT(`BracketRight`,`]`),previousGroup:xT(`BracketLeft`,`[`),goTo:e=>xT(`Digit${String(e)}`,String(e)),resize:e=>{let[t,n]=ST[e];return xT(t,t,n)},move:e=>{let[t,n]=ST[e];return{...xT(t,t,n),ctrl:!0}}},wT=9,TT=e=>e<=wT?CT.goTo(e):void 0,ET=()=>_T(navigator.platform),DT=()=>document.querySelector(`[data-modal]`)!==null,OT=(e,t)=>{(0,V.useEffect)(()=>{let n=ET(),r=r=>{let i=e.palette.getValue();if(!i&&DT())return;if(vT(r,CT.palette,n)){r.preventDefault(),e.palette.setValue(!i);return}if(i)return;let a=t.find(({shortcut:e})=>e!==void 0&&vT(r,e,n));a!==void 0&&(r.preventDefault(),a.disabled===void 0?a.run():e.announce(a.disabled))};return window.addEventListener(`keydown`,r),()=>{window.removeEventListener(`keydown`,r)}},[e,t])},kT={shell:`_shell_aupfr_7`,bar:`_bar_aupfr_15`,name:`_name_aupfr_34`,logoOnDark:`_logoOnDark_aupfr_44`,logoOnLight:`_logoOnLight_aupfr_45`,spacer:`_spacer_aupfr_60`,status:`_status_aupfr_64`,middle:`_middle_aupfr_80`,dockArea:`_dockArea_aupfr_90`,rail:`_rail_aupfr_95`,stack:`_stack_aupfr_117`,stacked:`_stacked_aupfr_130`,stackedHeading:`_stackedHeading_aupfr_149`,stackedButton:`_stackedButton_aupfr_158`,stackedBody:`_stackedBody_aupfr_184`,visuallyHidden:`_visuallyHidden_aupfr_196`,count:`_count_aupfr_209`},AT=({workspace:e})=>{let{notifications:t}=qy(),n=ib(t.view,e=>e.unread);return(0,G.jsxs)(cb,{label:n===0?`Notifications`:`Notifications, ${String(n)} unread`,onClick:()=>{e.goTo(`notifications`)},children:[(0,G.jsx)(hy,{}),n===0?null:(0,G.jsx)(`span`,{className:kT.count,children:n>99?`99+`:n})]})},jT=V.createContext(void 0);function MT(e){let t=V.useContext(jT);if(t===void 0&&!e)throw Error(rc(33));return t}var NT=V.createContext(void 0);function PT(e){let t=V.useContext(NT);if(t===void 0&&!e)throw Error(rc(36));return t}var FT=V.createContext(void 0);function IT(e=!0){let t=V.useContext(FT);if(t===void 0&&!e)throw Error(rc(25));return t}var LT=V.createContext(null);function RT(e=`root`){let t=V.useContext(LT),n=V.useContext(NT);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var zT={visible:!0,ref:null};function BT(){return zT}function VT(e,t,n=`root`){let r=RT(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??BT)({label:e.label,children:e.children,render:e.render}),a=_u(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}function HT(e){e.preventDefault()}function UT(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=PT(),u=IT(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return V.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?HT:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:Xl})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!yc&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&B_(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var WT={type:`regular-item`};function GT(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=V.useRef(null),{getButtonProps:d,buttonRef:f}=V_({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=UT({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=V.useCallback(e=>xf(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=_u(u,f);return V.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var KT=V.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=PT(),f=MS({guess:!0,label:a}),p=ng(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=GT({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:WT});return Pf(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),qT=V.forwardRef(function(e,t){let n=VT(e,t);return n.visible?(0,G.jsx)(KT,{...e,ref:n.ref}):null}),JT=V.createContext(void 0);function YT(){return V.useContext(JT)}function XT(e,t){let n=Rf(e.render);if(V.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function ZT(e,t,n){let r=XT(e,t),i=r===t?void 0:r;return[r,V.useCallback(e=>n?.(e?i:void 0),[i,n])]}function QT(e,t,n){let r=Rf(e.render),i=V.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var $T=V.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=PT(),m=YT(),{side:h,align:g}=MT(),_=Sw(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),S=l.useState(`instantType`),C=l.useState(`activeTriggerElement`),w=l.useState(`parent`),T=l.useState(`lastOpenChangeReason`),E=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),k=l.useState(`closeDelay`),A=l.useState(`hoverEnabled`),j=l.useState(`disabled`),M=l.useState(`openMethod`),N=l.useState(`activeTriggerId`),P=l.useState(`listElement`),[F,I]=ZT(e,u,d),L=QT(e,C,N),R=w.type===`menu`?m:void 0,ee=w.type===`context-menu`,z=s??w.type!==`menu`;s===void 0&&P&&w.type!==`menu`&&(z=()=>l.state.activeIndex===null&&P),Pp({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),V.useEffect(()=>{function e(e){l.setOpen(!1,W(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),Om(D,{enabled:A&&!j&&!ee&&w.type!==`menubar`,closeDelay:k});let te=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:ne,handleFocus:re}=(V.useContext(LT)?.useParentHandoff??tE)(l,w,v,f),ie=Pf(`div`,e,{state:{transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},ref:[t,l.context.popupRef,te,I],stateAttributesMapping:kl,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&uC.has(e.key)&&e.stopPropagation()},onFocus:re},Ng(y),c,{"data-rootownerid":E}]}),ae=w.type===void 0||ee;(C||w.type===`menubar`&&T!==`outside-press`)&&(ae=!0);let oe=R?.getReturnElement??ne;return(0,G.jsx)(bp,{context:D,openInteractionType:M,modal:ee,disabled:!x,returnFocus:a??oe??ae,explicitReturnFocus:a===void 0&&oe?!1:void 0,initialFocus:z,restoreFocus:!0,getInsideElements:w.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:w.type===`menubar`?void 0:O,previousFocusableElement:C,nextFocusableElement:w.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:ie})}),eE={parentVirtualFocusRef:void 0,handleFocus:void 0};function tE(){return eE}var nE=V.forwardRef(function(e,t){let n=RT()?.Popup??$T;return(0,G.jsx)(n,{...e,ref:t})}),rE=V.createContext(void 0);function iE(){let e=V.useContext(rE);if(e===void 0)throw Error(rc(32));return e}var aE=V.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=PT();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,G.jsx)(rE.Provider,{value:n,children:(0,G.jsx)(tp,{ref:t,...r,portalOwnerRole:o})})});function oE(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=V.useRef(null),o=V.useRef(null),s=Np(r);H(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),H(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}var sE=V.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=qf,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=PT(),x=iE(),S=IT(!0),C=v.useState(`parent`),w=v.useState(`floatingRootContext`),T=v.useState(`floatingTreeRoot`),E=v.useState(`mounted`),D=v.useState(`open`),O=v.useState(`modal`),k=v.useState(`openMethod`),A=v.useState(`activeTriggerElement`),j=v.useState(`transitionStatus`),M=v.useState(`positionerElement`),N=v.useState(`instantType`),P=v.useState(`adaptiveOrigin`),F=v.useState(`lastOpenChangeReason`),I=v.useState(`floatingNodeId`),L=v.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),ee=n,z=c,te=l,ne=s,re=h;C.type===`context-menu`&&(ee=n??C.context?.anchor,ne??=`start`,!o&&ne!==`center`&&(te=e.alignOffset??2,z=e.sideOffset??-5));let ie=o,ae=ne;C.type===`menu`?(ie??=`inline-end`,ae??=`start`,re=e.collisionAvoidance??Jf):C.type===`menubar`&&(ie??=C.context.orientation===`vertical`?`inline-end`:`bottom`,ae??=`start`);let oe=C.type===`context-menu`,se=Ag({anchor:ee,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:ie,sideOffset:z,align:ae,alignOffset:te,arrowPadding:oe?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:re,shift:oe?{crossAxis:!(`side`in re&&re.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});V.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,W(su)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),V.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,W(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let ce=lc();V.useEffect(()=>{D||ce.clear()},[D,ce]),V.useEffect(()=>{function e(e){if(D&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&A&&A!==e.target){let e=v.select(`closeDelay`);e>0?ce.isStarted()||ce.start(e,()=>{v.setOpen(!1,W(su))}):v.setOpen(!1,W(su))}else ce.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,ce]),V.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),oE({store:v,domReference:R,positionerElement:M,open:D});let le={open:D,side:se.side,align:se.align,anchorHidden:se.anchorHidden,nested:C.type===`menu`,instant:N},ue=C.type===`menubar`&&C.context.modal;wS(D&&(ue||O&&F!==`trigger-hover`),k===`touch`,M,A);let de=Pg(e,le,{styles:se.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),fe=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),pe=null;return C.type===`menubar`?pe=C.context.contentElement:C.type===void 0&&(pe=A),(0,G.jsxs)(jT.Provider,{value:se,children:[fe&&(0,G.jsx)(dS,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:Rg(!D),cutout:pe}),(0,G.jsx)(lp,{id:I,children:(0,G.jsx)(Zx,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:de})})]})}),cE=V.createContext(null);function lE(e){let t=V.useContext(cE);if(t===null&&!e)throw Error(rc(5));return t}var uE={...vm,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=vm.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>xc&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!vm.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},dE=class extends lm{constructor(e,t,n=!1){let r=new Xp,i=pE(r,t,n,e);super(i,fE(r),uE),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function fE(e){return{positionerRef:V.createRef(),popupRef:V.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:V.createRef(),beforeTriggerFocusGuardRef:V.createRef(),beforeContentFocusGuardRef:V.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function pE(e,t,n=!1,r){return{...fm(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:tc,inputProps:tc,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new rp,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:tc,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var mE=V.createContext(null);function hE(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function gE(e,t){return e===`list-navigation`||hE(e,t)}var _E=Xs(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:y,allowEscape:b=!0,resetOnPointerLeave:x=!0}=e,S=IT(!0),C=PT(!0),w=lE(!0),T=C?.store,E=C?.virtualFocus??!1,D=V.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=ng(),k=ng(),[A,j]=V.useState(void 0),M=(A??k)||void 0,N=op(),P=D.type===`menu`?D.store:void 0,F=(n??o)&&P?.state.transitionStatus===`starting`,I=Gs(()=>F?P?.state.instantType:void 0).current,L=Gs(()=>{let e=new dE({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:I},M,N!=null);return e.context.virtualFocusRef=y,e}).current;L.useControlledProp(`openProp`,n),L.useControlledProp(`triggerIdProp`,m),L.useContextCallback(`onOpenChangeComplete`,i);let R=L.useState(`floatingTreeRoot`),ee=cp(R),z=L.useState(`open`),te=L.useState(`activeTriggerElement`),ne=L.useState(`positionerElement`),re=L.useState(`hoverEnabled`),ie=L.useState(`disabled`),ae=L.useState(`lastOpenChangeReason`),oe=L.useState(`parent`),se=L.useState(`activeIndex`),ce=L.useState(`keyboardOpen`),le=L.useState(`payload`),ue=L.useState(`floatingParentNodeId`),de=V.useRef(null),fe=V.useRef(oe.type!==`context-menu`),pe=lc(),me=V.useRef(!0),he=lc(),ge=ue!=null,{openMethod:_e,triggerProps:ve}=px(z);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:oe.type===void 0?c:void 0,openMethod:_e,rootId:O}),Kp(L);let{forceUnmount:ye,transitionStatus:be}=qp(z,L,()=>{L.set(`allowMouseEnter`,!1)},F),B=Np(L.context.popupRef);V.useEffect(()=>{if(I===void 0)return;let e=()=>{L.state.instantType===I&&L.set(`instantType`,void 0)};if(!z){e();return}if(be!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return B(e,t.signal),()=>{t.abort()}},[I,z,be,B,L]),H(()=>{S&&!C?L.update({parent:{type:`context-menu`,context:S},floatingNodeId:ee,floatingParentNodeId:N}):(C||!L.select(`activeTriggerElement`))&&L.update({floatingNodeId:ee,floatingParentNodeId:N})},[S,C,ee,N,te,L]),V.useEffect(()=>{z||(de.current=null),oe.type===`context-menu`&&(z?pe.start(500,()=>{fe.current=!0}):(pe.clear(),fe.current=!1))},[pe,z,oe.type]),H(()=>{!z&&!re&&L.set(`hoverEnabled`,!0)},[z,re,L]);let xe=K((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||z===e&&t.trigger===te&&ae===n)return;let i=Up(t);if(!e&&t.trigger==null&&(t.trigger=te??void 0),r?.(e,t),t.isCanceled)return;L.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!me.current)return;e&&n===`trigger-focus`?(me.current=!1,he.start(300,()=>{me.current=!0})):(me.current=!0,he.clear());let o=!e&&(n===`escape-key`||n==null);de.current=t.event;let s=Hp(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&gE(n,a),s.instantType=oe.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:hE(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),Se=Op({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:xe}),Ce=Se.context.events;H(()=>{let e=({open:e,eventDetails:t})=>xe(e,t);return Ce.on(`setOpen`,e),()=>{Ce?.off(`setOpen`,e)}},[Ce,xe]),H(()=>L.subscribeToParentMenu(),[L]);let we=V.useCallback(()=>{L.setOpen(!1,W(lu))},[L]);V.useImperativeHandle(d,()=>({unmount:ye,close:we}),[ye,we]);let Te;oe.type===`context-menu`&&(Te=oe.context),V.useImperativeHandle(Te?.positionerRef,()=>ne,[ne]),V.useImperativeHandle(Te?.actionsRef,()=>({setOpen:xe}),[xe]);let Ee=Dp(Se,{enabled:!ie,bubbles:{escapeKey:f&&oe.type===`menu`},outsidePress(){return oe.type!==`context-menu`||de.current?.type===`contextmenu`||fe.current},externalTree:ge?R:void 0}),De=gg(),Oe=Lm(Se,{enabled:!ie,listRef:L.context.itemDomElements,activeIndex:se,virtual:v,nested:oe.type===`menubar`||!v&&oe.type!==void 0,parentOrientation:oe.type===`menubar`?oe.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?ce:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:De===`rtl`,disabledIndices:ec,onNavigate(e,t){L.setActiveIndex(e,fb(t),t?.nativeEvent)},openOnArrowKeyDown:oe.type!==`context-menu`&&!(v&&_),externalTree:!v&&ge?R:void 0,nestedReturnFocusRef:P?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),ke=V.useCallback(e=>{L.context.typingRef.current=e},[L]),Ae=Rm(Se,{enabled:!ie&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:se,resetMs:500,onMatch:(e,t)=>{z&&e!==se&&L.setActiveIndex(e,iu,t.nativeEvent)},onTyping:ke}),je=K(a),Me=V.useRef(-1),Ne=K(()=>{let e=L.state.activeIndex,t=e===null?void 0:L.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Me.current===n&&L.context.reportedItem===t)return;Me.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=Gl,L.context.highlightEvent=void 0,a&&je(t,Wl(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});H(()=>{Ne()},[se,Ne]);let Pe=V.useMemo(()=>{if(!v)return Oe.reference;if(!Oe.trigger)return tc;let{onFocus:e,...t}=Oe.trigger;return t},[v,Oe.reference,Oe.trigger]);L.useSyncedValue(`inputProps`,v?Oe.reference??tc:tc);let Fe=V.useMemo(()=>{let e=xf(Ae.reference,Pe,Ee.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},ve);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=z,e},[L,Ae.reference,Pe,Ee.reference,ve,z]),Ie=V.useMemo(()=>{let e=xf(Oe.trigger,Ee.trigger,ve);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Oe.trigger,Ee.trigger,ve]);Gs(()=>(L.update({inactiveTriggerProps:Ie}),null)),Jp(L,{floatingRootContext:Se,activeTriggerProps:Fe,inactiveTriggerProps:Ie,popupProps:V.useMemo(()=>xf(Ip,{onMouseMove(){L.set(`allowMouseEnter`,!0),oe.type===`menu`&&L.set(`hoverEnabled`,!1)},onClick(){L.select(`hoverEnabled`)&&L.set(`hoverEnabled`,!1)},onKeyDown(e){let t=L.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Ae.floating,Oe.floating,Ee.floating),[oe.type,L,Ae.floating,Oe.floating,Ee.floating]),itemProps:Oe.item??tc});let Le=V.useMemo(()=>({store:L,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:Ne}),[L,D,u,l,b,k,v,E,Ne]),Re=typeof t==`function`?t({payload:le}):t,ze=(0,G.jsxs)(NT.Provider,{value:Le,children:[p&&(0,G.jsx)(zp,{handle:p,store:L}),Re]});return(oe.type===void 0||oe.type===`context-menu`)&&(ze=(0,G.jsx)(up,{externalTree:R,children:ze})),ze});function vE(e){let t=V.useContext(mE);if(t===null)return(0,G.jsx)(_E,{...e});let n=t.Root;return(0,G.jsx)(mE.Provider,{value:null,children:(0,G.jsx)(n,{...t.options,...e})})}function yE(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=R_(),{ref:i,index:a}=MS(e),o=n===a,s=V.useRef(null),c=_u(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function bE(e){let{render:t,className:n,style:r,state:i=tc,props:a=ec,refs:o=ec,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=yE({metadata:s});return Pf(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function xE(e){if(Lc(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Yc(e))return xE(Qc(e))}function SE(e,t){function n(n,r,i){let a=n.currentTarget;Xf.flushSync(()=>{e.setOpen(!1,W(tu,n.nativeEvent,a))}),Vd(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&Hd(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function CE(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=V.useRef(!1);return V.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Pu(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:tc,[t,n,r])}var wE=Zs(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=PT(!0),h=ym(d)??m?.store;if(!h)throw Error(rc(85));let g=ng(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=V.useRef(null),S=EE(),C=R_(!0),w=sp(),T=V.useMemo(()=>w??new rp,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=Gp(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:cp(T),floatingParentNodeId:op(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=V_({disabled:A,native:o});V.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=V.useRef(null),P=lc(),F=K(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;U(N.current,t)||U(h.select(`positionerElement`),t)||t===N.current||t!=null&&xE(t)===h.select(`rootId`)||Hx(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:ou})});V.useEffect(()=>{let e=Pu(N.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[y,F,h]);let I=O&&S.context.hasSubmenuOpen,L=Am(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:Km({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),R=TE(y,h.select(`lastOpenChangeReason`)),ee=xp(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),z=Sm(v,{enabled:!A&&I}),te=CE({open:y,enabled:O,mouseDownAction:`open`}),ne=V.useMemo(()=>xf(z.reference,ee.reference),[z.reference,ee.reference]),re=h.useState(`triggerProps`,D),ie=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:ae,handleFocusTargetFocus:oe}=SE(h,x),se={disabled:A,open:y},ce=[N,t,M,E,x],le=[ne,L??tc,re,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),Pu(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},ie,O?{role:`menuitem`}:{},te,p,j],ue=Pf(`button`,e,{enabled:!O,stateAttributesMapping:Dl,state:se,ref:ce,props:le});return O?(0,G.jsx)(bE,{tag:`button`,render:n,className:r,style:i,state:se,refs:ce,props:le,stateAttributesMapping:Dl}):y?(0,G.jsxs)(V.Fragment,{children:[(0,G.jsx)(Ru,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:ae},`${g}-pre-focus-guard`),(0,G.jsx)(V.Fragment,{children:ue},g),(0,G.jsx)(Ru,{ref:h.context.triggerFocusTargetRef,onFocus:oe},`${g}-post-focus-guard`)]}):(0,G.jsx)(V.Fragment,{children:ue},g)});function TE(e,t){let n=lc(),[r,i]=V.useState(!1);return H(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function EE(){let e=lE(!0);return V.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var DE=V.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Pf(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),OE=(e,t)=>e===`separator`?`separator-${String(t)}`:e.label,kE=({entry:e})=>e===`separator`?(0,G.jsx)(DE,{className:qg.separator}):(0,G.jsxs)(qT,{className:qg.item,"data-variant":e.danger===!0?`danger`:`default`,disabled:e.disabled??!1,onClick:e.onSelect,children:[(0,G.jsx)(`span`,{children:e.label}),e.detail===void 0?null:(0,G.jsx)(`span`,{className:qg.itemDetail,children:e.detail}),e.hint===void 0?null:(0,G.jsx)(`kbd`,{children:e.hint})]}),AE=({trigger:e,entries:t})=>(0,G.jsxs)(vE,{children:[(0,G.jsx)(wE,{render:e}),(0,G.jsx)(aE,{children:(0,G.jsx)(sE,{align:`start`,className:qg.positioner,sideOffset:4,children:(0,G.jsx)(nE,{className:qg.popup,children:t.map((e,t)=>(0,G.jsx)(kE,{entry:e},OE(e,t)))})})})]}),jE=(e,{label:t})=>t===void 0?e:`${e} if ${t}`,ME={flow:e=>({from:[`leads to`,jE(e.to,e)],to:[`after`,jE(e.from,e)]}),back:e=>({from:[`goes back to`,jE(e.to,e)],to:[`comes back from`,jE(e.from,e)]}),owner:e=>({from:[`owns`,e.to],to:[`owned by`,e.from]}),message:e=>({from:[`can message`,e.to],to:[`can message`,e.from]})},NE=e=>{let t=new Map,n=(e,[n,r])=>{let i=t.get(e)??new Map;i.set(n,[...i.get(n)??[],r]),t.set(e,i)};for(let t of e){let{from:e,to:r}=ME[t.kind](t);n(t.from,e),n(t.to,r)}return new Map([...t].map(([e,t])=>[e,[...t].map(([e,t])=>`${e} ${t.join(`, `)}`).join(`; `)]))},PE=12,FE=(e,t,n)=>{let r=Math.abs(t.x-e.x)+Math.abs(t.y-e.y),i=r===0?0:n/r;return{x:e.x+(t.x-e.x)*i,y:e.y+(t.y-e.y)*i}},IE=({x:e,y:t})=>`${String(e)} ${String(t)}`,LE=(e,t)=>Math.abs(e.x-t.x)+Math.abs(e.y-t.y),RE=e=>{let[t,...n]=e;if(t===void 0)return``;let r=[`M ${IE(t)}`];for(let[i,a]of n.entries()){let o=e[i]??t,s=n[i+1];if(s===void 0)r.push(`L ${IE(a)}`);else{let e=Math.min(PE,LE(o,a)/2,LE(a,s)/2);r.push(`L ${IE(FE(a,o,e))}`,`Q ${IE(a)} ${IE(FE(a,s,e))}`)}}return r.join(` `)},zE=({shape:e,points:t})=>{let[n,r,i,a]=t;return e===`curve`&&n!==void 0&&r!==void 0&&i!==void 0&&a!==void 0?`M ${IE(n)} C ${IE(r)} ${IE(i)} ${IE(a)}`:RE(t)},BE=e=>e.length<=28?e:`${e.slice(0,27)}…`,VE=6.6,HE={graph:`_graph_cuiyl_7`,canvas:`_canvas_cuiyl_15`,hint:`_hint_cuiyl_45`,layer:`_layer_cuiyl_58`,edges:`_edges_cuiyl_67`,edgeLine:`_edgeLine_cuiyl_82`,edgeHead:`_edgeHead_cuiyl_95`,packet:`_packet_cuiyl_136`,edgeLabel:`_edgeLabel_cuiyl_160`,edgeLabelBack:`_edgeLabelBack_cuiyl_174`,card:`_card_cuiyl_180`,cardHead:`_cardHead_cuiyl_258`,cardIcon:`_cardIcon_cuiyl_267`,cardId:`_cardId_cuiyl_278`,cardCost:`_cardCost_cuiyl_289`,controls:`_controls_cuiyl_300`,keyList:`_keyList_cuiyl_325`,keyRow:`_keyRow_cuiyl_336`,keyNames:`_keyNames_cuiyl_340`,keyDoes:`_keyDoes_cuiyl_349`},UE=6,WE=16,GE=(e,t)=>{if(!(t===void 0||e!==`flow`&&e!==`owner`))return t.status===`running`?`flowing`:t.status===`queued`||t.status===`skipped`?`pending`:`taken`},KE=e=>e.reduce((t,n,r)=>{let i=e[r-1];return i===void 0?t:t+Math.hypot(n.x-i.x,n.y-i.y)},0),qE=({path:e,length:t})=>{let n=6/t;return(0,G.jsx)(`path`,{className:HE.packet,d:e,"data-packet":``,pathLength:2,strokeDasharray:`${String(n)} ${String(1-n)}`})},JE=e=>{let t=e.at(-1),n=e.at(-2);if(t===void 0||n===void 0)return``;let r=Math.sign(t.x-n.x),i=Math.sign(t.y-n.y),a={x:t.x-r*UE,y:t.y-i*UE},o={x:-i*(UE/2),y:UE/2*r};return[t,{x:a.x+o.x,y:a.y+o.y},{x:a.x-o.x,y:a.y-o.y}].map(({x:e,y:t})=>`${String(e)},${String(t)}`).join(` `)},YE=({label:e,at:t})=>{let n=BE(e),r=n.length*VE+8;return(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`rect`,{className:HE.edgeLabelBack,height:WE,rx:2,width:r,x:t.x-r/2,y:t.y-WE/2}),(0,G.jsxs)(`text`,{className:HE.edgeLabel,x:t.x,y:t.y,children:[(0,G.jsx)(`title`,{children:e}),n]})]})},XE=(0,V.memo)(({edges:e,facts:t,quiet:n,width:r,height:i})=>(0,G.jsx)(`svg`,{"aria-hidden":`true`,className:HE.edges,"data-quiet":n?``:void 0,focusable:`false`,height:i,width:r,children:e.map(e=>{let n=GE(e.kind,t?.get(e.to)),r=zE(e);return(0,G.jsxs)(`g`,{"data-kind":e.kind,"data-state":n,children:[(0,G.jsx)(`path`,{className:HE.edgeLine,d:r}),e.kind===`message`?null:(0,G.jsx)(`polygon`,{className:HE.edgeHead,points:JE(e.points)}),n===`flowing`?(0,G.jsx)(qE,{length:KE(e.points),path:r}):null,e.label===void 0||e.labelAt===void 0?null:(0,G.jsx)(YE,{at:e.labelAt,label:e.label})]},`${e.from}\n${e.to}\n${e.kind}`)})}));XE.displayName=`EdgePaths`;var ZE=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),QE=(e,t,n)=>{let r=ZE(t),i=ZE(n);return e===`left`?i.x<r.x:e===`right`?i.x>r.x:e===`up`?i.y<r.y:i.y>r.y},$E=(e,t,n)=>{let r=ZE(t),i=e===`left`||e===`right`,a=e=>{let t=ZE(e);return Math.abs(i?t.x-r.x:t.y-r.y)+Math.abs(i?t.y-r.y:t.x-r.x)*2};return n.toSorted((e,t)=>a(e)-a(t))[0]},eD=(e,t,n)=>{let r=e.nodes.find(e=>e.id===t);if(r===void 0)return;let i=new Set(e.edges.flatMap(e=>e.from===t?[e.to]:e.to===t?[e.from]:[])),a=e.nodes.filter(e=>e.id!==t),o=a.filter(e=>i.has(e.id)&&QE(n,r,e));return($E(n,r,n===`left`||n===`right`?[]:a.filter(e=>e.x===r.x&&QE(n,r,e)))??$E(n,r,o))?.id},tD=5,nD=e=>e.flatMap((e,t)=>e.split(``).flatMap((e,n)=>e===`#`?[`M${String(n)} ${String(t)}h1v1h-1z`]:[])).join(``),rD=e=>()=>(0,G.jsx)(`svg`,{"aria-hidden":`true`,fill:`currentColor`,focusable:`false`,height:`1em`,shapeRendering:`crispEdges`,viewBox:`0 0 ${String(tD)} ${String(tD)}`,width:`1em`,children:(0,G.jsx)(`path`,{d:nD(e)})}),iD=rD([`.....`,`.###.`,`.###.`,`.###.`,`.....`]),aD=rD([`....#`,`...#.`,`#.#..`,`.#...`,`.....`]),oD=rD([`..#..`,`.#.#.`,`#...#`,`.#.#.`,`..#..`]),sD=rD([`.#.#.`,`.#.#.`,`.#.#.`,`.#.#.`,`.#.#.`]),cD=rD([`#...#`,`.#.#.`,`..#..`,`.#.#.`,`#...#`]),lD=rD([`#.#.#`,`.....`,`#...#`,`.....`,`#.#.#`]),uD=rD([`.....`,`.....`,`#####`,`.....`,`.....`]),dD=rD([`#####`,`#...#`,`#...#`,`#...#`,`#####`]),fD=rD([`..#..`,`..#..`,`#####`,`..#..`,`..#..`]),pD=rD([`#....`,`.#...`,`..#..`,`.#...`,`#....`]),mD=rD([`..#..`,`.###.`,`#.#.#`,`..#..`,`..#..`]),hD={badge:`_badge_1rvaq_8`,icon:`_icon_1rvaq_42`,blink:`_blink_1rvaq_1`},gD={running:{Icon:iD,word:`running`,tone:`running`},succeeded:{Icon:aD,word:`succeeded`,tone:`succeeded`},waiting:{Icon:oD,word:`waiting on you`,tone:`waiting`},paused:{Icon:sD,word:`paused`,tone:`paused`},failed:{Icon:cD,word:`failed`,tone:`failed`},crashed:{Icon:cD,word:`crashed`,tone:`failed`},queued:{Icon:lD,word:`queued`,tone:`queued`},skipped:{Icon:uD,word:`skipped`,tone:`skipped`},interrupted:{Icon:dD,word:`interrupted`,tone:`interrupted`},budget_exhausted:{Icon:dD,word:`budget exhausted`,tone:`interrupted`},quota_exhausted:{Icon:dD,word:`quota spent`,tone:`interrupted`},timed_out:{Icon:dD,word:`timed out`,tone:`interrupted`}},_D=e=>gD[e].word,vD=e=>gD[e].tone,yD=({look:e,pill:t})=>{let{Icon:n,word:r,tone:i}=e;return(0,G.jsxs)(`span`,{className:hD.badge,"data-look":t?`pill`:`bare`,"data-tone":i,children:[(0,G.jsx)(`span`,{className:hD.icon,children:(0,G.jsx)(n,{})}),r]})},bD=({status:e,word:t,pill:n=!1})=>{let r=gD[e];return(0,G.jsx)(yD,{look:{...r,word:t??r.word},pill:n})},xD={new:{Icon:fD,word:`new`,tone:`waiting`},triaged:{Icon:lD,word:`triaged`,tone:`queued`},accepted:{Icon:pD,word:`accepted`,tone:`queued`},resolved:{Icon:aD,word:`resolved`,tone:`succeeded`},published:{Icon:mD,word:`published`,tone:`succeeded`},dismissed:{Icon:uD,word:`dismissed`,tone:`skipped`}},SD=({status:e,pill:t=!1})=>(0,G.jsx)(yD,{look:xD[e],pill:t}),CD={merged:{Icon:aD,word:`merged`,tone:`succeeded`},unmerged:{Icon:pD,word:`not merged`,tone:`queued`},detached:{Icon:uD,word:`detached`,tone:`skipped`}},wD=({state:e})=>(0,G.jsx)(yD,{look:CD[e],pill:!1}),TD={"claude.leader":`leader`,"claude.worker":`worker`,"claude.subagent":`sub-agent`,"control.split":`split`,"control.join":`join`,"control.router":`router`,"human.gate":`gate`,"workflow.call":`workflow call`,"mcp.call":`MCP call`},ED=e=>TD[e]??(e.startsWith(`tool.`)?`${e.slice(5)} tool`:e),DD=5e-5,OD=(e,t=[e])=>{if(!Number.isFinite(e))return`–`;let n=Math.abs(e);if(n!==0&&n<DD)return e>0?`<$0.0001`:`$0.00`;let r=t.some(e=>{let t=Math.abs(Number(e.toFixed(4)));return t!==0&&t<10});return`${e<0?`-`:``}$${n.toFixed(r?4:2)}`},kD=e=>e<1e3?String(e):`${(e/1e3).toFixed(1)}k`,AD=e=>String(e).padStart(2,`0`),jD=e=>{let t=Math.max(Math.floor(e/1e3),0),n=Math.floor(t/60),r=`${AD(n%60)}:${AD(t%60)}`;return n<60?`${String(n)}:${AD(t%60)}`:`${String(Math.floor(n/60))}:${r}`},MD=(e,t,n)=>[e,n.word??_D(n.status),...n.costUsd===void 0?[]:[OD(n.costUsd)],...n.tokens===void 0?[]:[`${kD(n.tokens)} tokens`],...n.model===void 0?[]:[n.model],ED(t)].join(`, `),ND=new Map([[`claude.leader`,(0,G.jsx)(wy,{},`leader`)],[`claude.worker`,(0,G.jsx)(Ty,{},`worker`)],[`claude.subagent`,(0,G.jsx)(Ey,{},`subagent`)],[`control.split`,(0,G.jsx)(Dy,{},`split`)],[`control.join`,(0,G.jsx)(Oy,{},`join`)],[`control.router`,(0,G.jsx)(ky,{},`router`)],[`human.gate`,(0,G.jsx)(Ay,{},`gate`)],[`workflow.call`,(0,G.jsx)(jy,{},`call`)],[`mcp.call`,(0,G.jsx)(jy,{},`mcp`)],[`tool.gh`,(0,G.jsx)(My,{},`gh`)],[`tool.aws`,(0,G.jsx)(Ny,{},`aws`)],[`tool.git`,(0,G.jsx)(Py,{},`git`)]]),PD=({type:e})=>ND.get(e)??(0,G.jsx)(iy,{}),FD=(0,V.memo)(({node:e,facts:t,connections:n,selected:r,dimmed:i,tabbable:a,bind:o,onSelect:s,onFocused:c,onKey:l,onMenu:u,onHover:d})=>{let{id:f,type:p,x:m,y:h,width:g,height:_}=e,v=(0,G.jsxs)(`button`,{...Xg(t.cli,n),"aria-current":r?`true`:void 0,"aria-label":MD(f,p,t),className:HE.card,"data-graph-node":``,"data-dim":i?``:void 0,"data-selected":r?``:void 0,"data-tone":vD(t.status),onMouseEnter:()=>d?.(f),onMouseLeave:()=>d?.(null),onClick:()=>{s(f)},onContextMenu:u===void 0?void 0:e=>{e.preventDefault(),u(f)},onFocus:()=>{c(f)},onKeyDown:e=>{l(f,e)},ref:e=>{o(f,e)},style:{height:_,transform:`translate(${m}px, ${h}px)`,width:g},tabIndex:a?0:-1,type:`button`,children:[(0,G.jsxs)(`span`,{className:HE.cardHead,children:[(0,G.jsx)(`span`,{className:HE.cardIcon,children:(0,G.jsx)(PD,{type:p})}),(0,G.jsx)(`span`,{className:HE.cardId,children:f}),t.costUsd===void 0?null:(0,G.jsx)(`span`,{className:HE.cardCost,children:OD(t.costUsd)})]}),(0,G.jsx)(bD,{status:t.status,word:t.word})]});return t.cli===void 0?v:(0,G.jsx)(Zg,{cli:t.cli,children:v})});FD.displayName=`NodeCard`;var ID=(e,t)=>{let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},LD=(e,t)=>{let n=e=>{e.preventDefault(),e instanceof WheelEvent&&t(e)};return e.addEventListener(`wheel`,n,{passive:!1}),()=>{e.removeEventListener(`wheel`,n)}},RD=(e,t)=>{let n=e.current?.getBoundingClientRect(),r=t.current?.getBoundingClientRect();return n===void 0||r===void 0?void 0:{x:n.x-r.x,y:n.y-r.y,width:n.width,height:n.height}},zD=.2,BD=e=>Math.min(2,Math.max(zD,e)),VD=(e,t)=>{if(e.width<=0||e.height<=0)return{x:0,y:0,k:1};let n=BD(Math.min(1,t.width/e.width,t.height/e.height));return{x:(t.width-e.width*n)/2,y:(t.height-e.height*n)/2,k:n}},HD=(e,t,n)=>{let r=BD(e.k*t),i=r/e.k;return{k:r,x:n.x-(n.x-e.x)*i,y:n.y-(n.y-e.y)*i}},UD=(e,t,n)=>({...e,x:e.x+t,y:e.y+n}),WD=(e,t,n,r)=>{let i={x:t.x*e.k+e.x,y:t.y*e.k+e.y,width:t.width*e.k,height:t.height*e.k};if(!qD(i,n))return e;let a=n.y-r-(i.y+i.height);return i.y+a>=r?UD(e,0,a):UD(e,n.x-r-(i.x+i.width),0)},GD=(e,t,n,r,i=24)=>{let a=(e,t,n)=>{let r=e+t;return t+i*2>=n?(n-t)/2-e:e<i?i-e:r>n-i?n-i-r:0},o=a(t.x*e.k+e.x,t.width*e.k,n.width),s=a(t.y*e.k+e.y,t.height*e.k,n.height),c=o===0&&s===0?e:UD(e,o,s);return r===void 0?c:WD(c,t,r,i)},KD=(e,t,n=160)=>({x:(-n-e.x)/e.k,y:(-n-e.y)/e.k,width:(t.width+n*2)/e.k,height:(t.height+n*2)/e.k}),qD=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,JD=16,YD=12,XD=e=>{let t=JD*e;for(;t<YD;)t*=2;return t},ZD=e=>{let t=e.map(e=>e.x),n=e.map(e=>e.y),r=Math.min(...t),i=Math.min(...n);return{x:r,y:i,width:Math.max(...t)-r,height:Math.max(...n)-i}},QD=.01,$D=e=>({nodes:new Set(e.nodes.map(e=>e.id)),edges:new Set(e.edges.keys())}),eO=()=>{},tO=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),nO=e=>{let t=(0,V.useRef)(null),n=(0,V.useRef)(null),r=(0,V.useRef)(null),i=(0,V.useRef)({x:0,y:0,k:1}),a=(0,V.useRef)(!1),o=(0,V.useRef)(0),s=(0,V.useRef)(new Map),[c,l]=(0,V.useState)(()=>$D(e)),u=(0,V.useRef)(``),[d,f]=(0,V.useState)(e);e!==d&&(f(e),l($D(e)));let p=(0,V.useMemo)(()=>e.edges.map(e=>ZD(e.points)),[e]),m=(0,V.useCallback)(()=>{let e=t.current?.getBoundingClientRect();return{width:e?.width??0,height:e?.height??0}},[]),h=(0,V.useCallback)(()=>{o.current=0;let{x:r,y:a,k:s}=i.current,c=n.current;c!==null&&(c.style.transform=`translate(${String(r)}px, ${String(a)}px) scale(${String(s)})`);let d=t.current;if(d!==null){let e=`${String(XD(s))}px`;d.style.backgroundSize=`${e} ${e}`,d.style.backgroundPosition=`${String(r)}px ${String(a)}px`,d.style.setProperty(`--graph-zoom`,String(s))}let f=m();if(f.width===0||f.height===0)return;let h=KD(i.current,f),g=e.nodes.filter(e=>qD(h,e)).map(e=>e.id),_=[...p.keys()].filter(e=>{let t=p[e];return t!==void 0&&qD(h,t)}),v=`${g.join(`
|
|
56
|
+
`)}\n\n${_.join(`,`)}`;v!==u.current&&(u.current=v,l({nodes:new Set(g),edges:new Set(_)}))},[p,e,m]),g=(0,V.useCallback)(()=>{o.current===0&&(o.current=requestAnimationFrame(h))},[h]),_=(0,V.useCallback)(()=>{a.current=!1,i.current=VD(e,m()),g()},[e,g,m]),v=(0,V.useCallback)(e=>{a.current=!0,i.current=e,g()},[g]),y=(0,V.useCallback)(e=>{let{width:t,height:n}=m();v(HD(i.current,e,{x:t/2,y:n/2}))},[v,m]),b=(0,V.useCallback)((e,t)=>{v(UD(i.current,e,t))},[v]),x=(0,V.useCallback)(e=>{let n=m();if(n.width===0||n.height===0)return;let a=GD(i.current,e,n,RD(r,t));a!==i.current&&v(a)},[v,m]);return(0,V.useEffect)(()=>{u.current=``,a.current?g():_()},[_,g]),(0,V.useEffect)(()=>{let e=t.current;return e===null?eO:ID(e,()=>{a.current?g():_()})},[_,g]),(0,V.useEffect)(()=>()=>{cancelAnimationFrame(o.current),o.current=0},[]),(0,V.useEffect)(()=>{let e=t.current;return e===null?eO:LD(e,t=>{if(t.ctrlKey||t.metaKey){let n=e.getBoundingClientRect();v(HD(i.current,Math.exp(-t.deltaY*QD),{x:t.clientX-n.left,y:t.clientY-n.top}))}else v(UD(i.current,-t.deltaX,-t.deltaY))})},[v]),{canvasRef:t,layerRef:n,controlsRef:r,shown:c,fit:_,zoom:y,pan:b,show:x,pointer:(0,V.useMemo)(()=>{let e=e=>{let t=e.currentTarget.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},t=e=>{s.current.delete(e.pointerId)};return{onPointerDown:t=>{t.target instanceof Element&&t.target.closest(`button`)!==null||(t.currentTarget.setPointerCapture?.(t.pointerId),s.current.set(t.pointerId,e(t)))},onPointerMove:t=>{let n=s.current.get(t.pointerId);if(n===void 0)return;let r=e(t),a=[...s.current].find(([e])=>e!==t.pointerId)?.[1];if(a===void 0)v(UD(i.current,r.x-n.x,r.y-n.y));else{let e=tO(n,a);e>0&&v(HD(i.current,tO(r,a)/e,a))}s.current.set(t.pointerId,r)},onPointerUp:t,onPointerCancel:t}},[v])}},rO=V.createContext(void 0);function iO(e){let t=V.useContext(rO);if(t===void 0&&!e)throw Error(rc(47));return t}var aO={...vm,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!vm.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&vm.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>vm.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},oO=class extends lm{constructor(e,t,n){let r=new Xp;super(sO(e,r,t,n),cO(r),aO)}setOpen=(e,t)=>{let n=t.reason===ql,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=Up(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=Hp(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),Xf.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function sO(e,t,n,r=!1){let i={...fm(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function cO(e){return{popupRef:V.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:V.createRef(),beforeTriggerFocusGuardRef:V.createRef(),beforeContentFocusGuardRef:V.createRef(),stickIfOpenTimeout:new cc,stickIfOpen:!0,triggerElements:e}}var lO=Xs(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=dO(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),Yp(u,d),Kp(u);let{forceUnmount:m}=qp(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),V.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),V.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,W(lu))}),[m,u]);let h=d||f||s!=null;return(0,G.jsxs)(rO.Provider,{value:u,children:[s&&(0,G.jsx)(zp,{handle:s,store:u}),h&&(0,G.jsx)(fO,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function uO(e){return iO(!0)?(0,G.jsx)(lO,{props:e}):(0,G.jsx)(up,{children:(0,G.jsx)(lO,{props:e})})}function dO(e,t){let n=Rp((e,n)=>new oO(t,e,n));return V.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function fO({store:e,modal:t}){let n=Dp(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return Jp(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var pO=Zs(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=iO(!0),h=ym(s)??m;if(!h)throw Error(rc(74));let g=ng(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=V.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=Gp(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=Am(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:Km(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=xp(v,{stickIfOpen:K(()=>h.context.stickIfOpen)}),k=fx(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),A=h.useState(`triggerProps`,C),{getButtonProps:j,buttonRef:M}=V_({disabled:a,native:o}),N={open(e){return w?Dl.open(e):El.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:F}=SE(h,x),I=Pf(`button`,e,{state:{disabled:a,open:y},ref:[M,t,S,x],props:[O.reference,D,A,k,{[Hf]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,j],stateAttributesMapping:N}),L=(0,G.jsx)(V.Fragment,{children:I},g);return E?(0,G.jsxs)(V.Fragment,{children:[(0,G.jsx)(Ru,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),L,(0,G.jsx)(Ru,{ref:h.context.triggerFocusTargetRef,onFocus:F})]}):L}),mO=V.createContext(void 0);function hO(){let e=V.useContext(mO);if(e===void 0)throw Error(rc(45));return e}var gO=V.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return iO().useState(`mounted`)||n?(0,G.jsx)(mO.Provider,{value:n,children:(0,G.jsx)(tp,{ref:t,...r})}):null}),_O=V.createContext(void 0);function vO(){let e=V.useContext(_O);if(!e)throw Error(rc(46));return e}var yO=V.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=Jf,..._}=e,v=iO(),y=hO(),b=cp(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=Ag({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});oE({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let M=E===!0&&w!==`trigger-hover`;wS(C&&M,D===`touch`,O,T);let N=v.useStateSetter(`positionerElement`),P=Pg(e,{open:C,side:j.side,align:j.align,anchorHidden:j.anchorHidden,instant:k},{styles:j.positionerStyles,transitionStatus:A,props:_,refs:[t,N],hidden:!S,inert:!C});return(0,G.jsxs)(_O.Provider,{value:j,children:[S&&M&&(0,G.jsx)(dS,{inert:Rg(!C),cutout:T}),(0,G.jsx)(lp,{id:b,children:P})]})}),bO=V.createContext(void 0);function xO(){let[e,t]=V.useState(0),n=K(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:V.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var SO=V.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=iO(),l=vO(),u=Sw(!0)!=null,{context:d,hasClosePart:f}=xO(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);Pp({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),Om(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?Lp(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=Pf(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...Ip,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&uC.has(e.key)&&e.stopPropagation()}},Ng(g),s],stateAttributesMapping:kl});return(0,G.jsx)(bp,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:Lc(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,G.jsx)(bO.Provider,{value:d,children:M})})}),CO=V.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=iO(),s=ng(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),Pf(`h2`,e,{ref:t,props:[{id:s},a]})}),wO=({trigger:e,title:t,children:n})=>(0,G.jsxs)(uO,{children:[(0,G.jsx)(pO,{render:e}),(0,G.jsx)(gO,{children:(0,G.jsx)(yO,{className:qg.positioner,sideOffset:4,children:(0,G.jsxs)(SO,{className:qg.panel,children:[(0,G.jsx)(CO,{className:qg.title,children:t}),n]})})})]}),TO=1.25,EO=[{keys:[[`←`],[`→`],[`↑`],[`↓`]],does:`Move the view; on a node, follow its edges`},{keys:[[`Enter`],[`Space`]],does:`Select the node`},{keys:[[`Shift`,`F10`]],does:`The node's controls`},{keys:[[`Escape`]],does:`Back to the view`},{keys:[[`+`],[`-`]],does:`Zoom in or out`},{keys:[[`0`]],does:`Fit the graph`}],DO=()=>(0,G.jsx)(wO,{title:`Keys on the graph`,trigger:(0,G.jsx)(cb,{label:`Keys on the graph`,children:(0,G.jsx)(Ry,{})}),children:(0,G.jsx)(`dl`,{className:HE.keyList,children:EO.map(({keys:e,does:t})=>(0,G.jsxs)(`div`,{className:HE.keyRow,children:[(0,G.jsx)(`dt`,{className:HE.keyNames,children:e.map(e=>(0,G.jsx)(Kg,{keys:e},e.join(`+`)))}),(0,G.jsx)(`dd`,{className:HE.keyDoes,children:t})]},t))})}),OO=({controlsRef:e,zoom:t,fit:n,pan:r})=>(0,G.jsxs)(`div`,{className:HE.controls,ref:e,children:[(0,G.jsx)(cb,{keys:[`+`],label:`Zoom in`,onClick:()=>{t(TO)},children:(0,G.jsx)(Fy,{})}),(0,G.jsx)(cb,{keys:[`-`],label:`Zoom out`,onClick:()=>{t(1/TO)},children:(0,G.jsx)(Iy,{})}),(0,G.jsx)(cb,{keys:[`0`],label:`Fit the graph`,onClick:n,children:(0,G.jsx)(Ly,{})}),(0,G.jsx)(cb,{keys:[`←`],label:`Pan left`,onClick:()=>{r(48,0)},children:(0,G.jsx)(Qv,{})}),(0,G.jsx)(cb,{keys:[`→`],label:`Pan right`,onClick:()=>{r(-48,0)},children:(0,G.jsx)($v,{})}),(0,G.jsx)(cb,{keys:[`↑`],label:`Pan up`,onClick:()=>{r(0,48)},children:(0,G.jsx)(ey,{})}),(0,G.jsx)(cb,{keys:[`↓`],label:`Pan down`,onClick:()=>{r(0,-48)},children:(0,G.jsx)(ty,{})}),(0,G.jsx)(DO,{})]}),kO={status:`queued`},AO={ArrowLeft:`left`,ArrowRight:`right`,ArrowUp:`up`,ArrowDown:`down`},jO=()=>{},MO=(0,V.memo)(({layout:e,label:t,facts:n,selected:r,onSelect:i=jO,onNodeMenu:a,live:o=!1,hovered:s=null,onHover:c})=>{let l=(0,V.useId)(),{canvasRef:u,layerRef:d,controlsRef:f,shown:p,fit:m,zoom:h,pan:g,show:_,pointer:v}=nO(e),[y,b]=(0,V.useState)(r),[x,S]=(0,V.useState)(r);r!==x&&(S(r),r!==void 0&&b(r));let C=(0,V.useRef)(new Map),w=(0,V.useRef)(null),T=(0,V.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e])),[e]),E=(0,V.useMemo)(()=>NE(e.edges),[e]),D=T.has(y??``)?y:e.nodes[0]?.id,O=(0,V.useRef)(r);(0,V.useEffect)(()=>{if(r===O.current)return;O.current=r;let e=T.get(r??``);e!==void 0&&_(e)},[T,r,_]),(0,V.useEffect)(()=>{let e=w.current;if(e===null)return;let t=C.current.get(e);t!==void 0&&(w.current=null,t.focus({preventScroll:!0}))});let k=(0,V.useCallback)((e,t)=>{t===null?C.current.delete(e):C.current.set(e,t)},[]),A=(0,V.useCallback)(e=>{b(e);let t=T.get(e);t!==void 0&&_(t)},[T,_]),j=(0,V.useCallback)((t,n)=>{let r=AO[n.key];if(r!==void 0){n.preventDefault(),n.stopPropagation();let i=eD(e,t,r);if(i===void 0)return;let a=T.get(i);a!==void 0&&_(a),w.current=i,b(i)}else n.key===`Escape`?u.current?.focus({preventScroll:!0}):(n.key===`ContextMenu`||n.key===`F10`&&n.shiftKey)&&a!==void 0&&(n.preventDefault(),a(t))},[T,u,e,a,_]),M=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target===e.currentTarget,n={"+":()=>{h(TO)},"=":()=>{h(TO)},"-":()=>{h(1/TO)},0:m,...t?{ArrowLeft:()=>{g(48,0)},ArrowRight:()=>{g(-48,0)},ArrowUp:()=>{g(0,48)},ArrowDown:()=>{g(0,-48)}}:{}}[e.key];n!==void 0&&(e.preventDefault(),n())},N=e.nodes.filter(e=>p.nodes.has(e.id)||e.id===D),P=(0,V.useMemo)(()=>e.edges.filter((e,t)=>p.edges.has(t)),[e,p]);return(0,G.jsxs)(`div`,{className:HE.graph,children:[(0,G.jsxs)(`div`,{...v,"aria-describedby":l,"aria-label":t,"aria-roledescription":`graph`,className:HE.canvas,onKeyDown:M,ref:u,role:`application`,tabIndex:0,children:[(0,G.jsx)(`p`,{className:HE.hint,id:l,children:`Arrow keys move the view; on a node, they move along its edges, Enter selects it, Shift+F10 asks for its controls, and Escape goes back to the view. Plus and minus zoom, and 0 fits the graph.`}),(0,G.jsxs)(`div`,{className:HE.layer,ref:d,children:[(0,G.jsx)(XE,{edges:P,facts:o?n:void 0,height:e.height,quiet:s!==null,width:e.width}),N.map(e=>(0,G.jsx)(FD,{bind:k,connections:E.get(e.id),dimmed:s!==null&&s!==e.id,facts:n?.get(e.id)??kO,node:e,onFocused:A,onHover:c,onKey:j,onMenu:a,onSelect:i,selected:e.id===r,tabbable:e.id===D},e.id))]})]}),(0,G.jsx)(OO,{controlsRef:f,fit:m,pan:g,zoom:h})]})});MO.displayName=`GraphView`;var NO=8,PO=e=>new Map(e.map((e,t)=>[e,t])),FO=(e,t,n)=>{let r=PO(e),i=PO(t),a=n.flatMap(([e,t])=>{let n=r.get(e),a=i.get(t);return n===void 0||a===void 0?[]:[[n,a]]}),o=0;for(let[e,[t=0,n=0]=[]]of a.entries())for(let[r=0,i=0]of a.slice(e+1))(t-r)*(n-i)<0&&(o+=1);return o},IO=(e,t)=>e.slice(1).reduce((n,r,i)=>n+FO(e[i]??[],r,t),0),LO=(e,t,n)=>{let r=(e,r)=>{let i=(t.get(e)??[]).flatMap(e=>{let t=n.get(e);return t===void 0?[]:[t]});return i.length===0?r:i.reduce((e,t)=>e+t,0)/i.length};return e.map((e,t)=>({id:e,index:t,weight:r(e,t)})).toSorted((e,t)=>e.weight-t.weight||e.index-t.index).map(({id:e})=>e)},RO=(e,t)=>{let n=new Map,r=new Map;for(let[e,i]of t)n.set(i,[...n.get(i)??[],e]),r.set(e,[...r.get(e)??[],i]);let i=e.map(e=>[...e]),a=i,o=IO(i,t);for(let e=0;e<NO&&o>0;e+=1){let s=e%2==0,c=i.map(e=>[...e]),l=c.map((e,t)=>t);for(let e of s?l.slice(1):l.slice(0,-1).toReversed()){let t=PO(c[e+(s?-1:1)]??[]);c[e]=LO(c[e]??[],s?n:r,t)}i=c;let u=IO(i,t);u<o&&(o=u,a=i)}return a},zO=12,BO=(e,t)=>{let n=[],r=0;for(let[i]of e.entries())i>0&&(r+=t[i-1]??0),n.push(r);let i=[];for(let[t,r]of e.entries())for(i.push({sum:r-(n[t]??0),size:1});;){let e=i.at(-1),t=i.at(-2);if(e===void 0||t===void 0||t.sum/t.size<=e.sum/e.size)break;i.splice(-2,2,{sum:t.sum+e.sum,size:t.size+e.size})}return i.flatMap(({sum:e,size:t})=>Array.from({length:t},()=>e/t)).map((e,t)=>e+(n[t]??0))},VO=(e,t,n)=>{let r=new Map,i=new Map;for(let[e,n]of t)r.set(n,[...r.get(n)??[],e]),i.set(e,[...i.get(e)??[],n]);let a=new Map,o=(e,t)=>{let r=BO(t,e.slice(1).map((t,r)=>n(e[r]??``,t)));for(let[t,n]of e.entries())a.set(n,r[t]??0)};for(let t of e)o(t,t.map(()=>0));let s=(e,t)=>{let n=e.map(e=>{let n=t.flatMap(t=>t.get(e)??[]).map(e=>a.get(e)??0);return n.length===0?a.get(e)??0:n.reduce((e,t)=>e+t,0)/n.length});o(e,n)};for(let t=0;t<zO;t+=1){let n=t%2==0;for(let a of n?e:e.toReversed())s(a,t===11?[r,i]:[n?r:i])}return a},HO=e=>{let t=new Set(e.nodes.map(e=>e.id)),n=[],r=(e,t,r,i)=>{n.push({index:n.length,from:e,to:t,kind:r,label:i})},i=new Set;for(let{from:n,to:a,when:o,maxRounds:s}of e.edges)t.has(n)&&t.has(a)&&(i.add(`${n}\n${a}`),r(n,a,s!==void 0||n===a?`back`:`flow`,o));for(let{id:n,parent:a}of e.nodes)a!==void 0&&t.has(a)&&!i.has(`${a}\n${n}`)&&r(a,n,`owner`);for(let[n,i]of e.channels??[])t.has(n)&&t.has(i)&&n!==i&&r(n,i,`message`);return n},UO=(e,t)=>{let n=new Map;for(let e of t)n.set(e.from,[...n.get(e.from)??[],e]);let r=new Map,i=e=>{r.set(e,`open`);for(let t of n.get(e)??[]){let e=r.get(t.to);e===`open`?t.kind=`back`:e===void 0&&i(t.to)}r.set(e,`done`)};for(let t of e)r.has(t)||i(t)},WO=(e,t)=>{let n=new Set(t.filter(e=>e.kind===`flow`).map(e=>e.to)),r=t.filter(e=>e.kind===`flow`||e.kind===`owner`&&!n.has(e.to));UO(e,r);let i=r.filter(e=>e.kind!==`back`),a=new Map(e.map(e=>[e,0])),o=!0;for(let t=0;o&&t<=e.length;t+=1){o=!1;for(let{from:e,to:t}of i){let n=(a.get(e)??0)+1;n>(a.get(t)??0)&&(a.set(t,n),o=!0)}}return a},GO=12,KO=(e,t)=>{let n=new Map,r=(e,t,r)=>{n.set(e,[...n.get(e)??[],{top:t,bottom:r}])};for(let n of e.values())r(t(n.id),n.y-GO,n.y+n.height+GO);return(e,t)=>{let i=t=>e.every(e=>(n.get(e)??[]).every(({top:e,bottom:n})=>t<=e||t>=n)),a=e.flatMap(e=>(n.get(e)??[]).flatMap(({top:e,bottom:t})=>[e,t])),o=t[0]??0,s=t.find(e=>i(e))??a.filter(e=>i(e)).toSorted((e,t)=>Math.abs(e-o)-Math.abs(t-o)||e-t)[0]??o;for(let t of e)r(t,s-GO,s+GO);return s}},qO=30,JO=48,YO=36,XO=16,ZO={flow:0,owner:0,back:14,message:-14},QO=(e,t)=>e.y+e.height/2+ZO[t],$O=e=>e?.x??0,ek=e=>e?.y??0,tk=([e,t,n,r])=>({x:($O(e)+3*$O(t)+3*$O(n)+$O(r))/8,y:(ek(e)+3*ek(t)+3*ek(n)+ek(r))/8}),nk=(e,t)=>({from:e.from,to:e.to,kind:e.kind,shape:`curve`,points:t,...e.label===void 0?{}:{label:e.label,labelAt:tk(t)}}),rk=(e,t,n)=>{let r=Math.max(YO,Math.abs(n.x-t.x)/2),i=n.x>=t.x?1:-1;return nk(e,[t,{x:t.x+r*i,y:t.y},{x:n.x-r*i,y:n.y},n])},ik=(e,t)=>{let n=Math.max(e.y,t.y),r=Math.min(e.y+e.height,t.y+t.height);return r-n<XO?void 0:(n+r)/2},ak=(e,t)=>{let n=t.x+t.width*.3,r=t.x+t.width*.7,i=t.y-qO;return nk(e,[{x:r,y:t.y},{x:r,y:i},{x:n,y:i},{x:n,y:t.y}])},ok=(e,t,n)=>{let r={x:t.x+t.width,y:QO(t,e.kind)},i={x:n.x+n.width,y:QO(n,e.kind)};return nk(e,[r,{x:r.x+JO,y:r.y},{x:i.x+JO,y:i.y},i])},sk=e=>{let t=[];for(let n of e){let e=t.at(-1),r=t.at(-2);(e?.x!==n.x||e.y!==n.y)&&(e!==void 0&&r!==void 0&&(r.x===e.x&&e.x===n.x||r.y===e.y&&e.y===n.y)&&t.pop(),t.push(n))}return t},ck=e=>{let t=e[0]??{x:0,y:0},n=-1;for(let[r,i]of e.slice(1).entries()){let a=e[r]??i,o=Math.abs(i.x-a.x)+Math.abs(i.y-a.y);o>n&&(n=o,t={x:(a.x+i.x)/2,y:(a.y+i.y)/2})}return t},lk=(e,t)=>{let n=sk(t);return{from:e.from,to:e.to,kind:e.kind,shape:`lines`,points:n,...e.label===void 0?{}:{label:e.label,labelAt:ck(n)}}},uk=e=>{let{chains:t,nodes:n,stopY:r,rankOf:i,columnX:a,columnWidth:o,gapWidth:s}=e,c=e=>a(e)+o,l=KO(n,i),u=t.filter(({stops:e})=>e.length>2),d=new Map,f=new Map;for(let{edge:e,stops:t}of u){let a=n.get(e.from),o=n.get(e.to);if(a!==void 0&&o!==void 0){let n=QO(a,e.kind),s=QO(o,e.kind),c=l(t.slice(1,-1).map(e=>{let[,t=``]=e.split(`:`);return Number(t)}),[n,s,...t.slice(1,-1).map(e=>r.get(e)??n)]);d.set(e.index,c);let u=Math.min(i(e.from),i(e.to)),p=Math.max(i(e.from),i(e.to));for(let t of[u,p-1])f.set(t,[...f.get(t)??[],e.index])}}let p=(e,t)=>{let n=f.get(e)??[];return c(e)+s(e)*(n.indexOf(t)+1)/(n.length+1)};return t.flatMap(({edge:e})=>{let t=n.get(e.from),r=n.get(e.to);if(t===void 0||r===void 0)return[];if(e.from===e.to)return[ak(e,t)];let a=i(e.from),o=i(e.to);if(a===o)return[ok(e,t,r)];let s=o>a,c={x:s?t.x+t.width:t.x,y:QO(t,e.kind)},l={x:s?r.x:r.x+r.width,y:QO(r,e.kind)},u=d.get(e.index);if(u===void 0){let n=ik(t,r);return[n===void 0?rk(e,c,l):rk(e,{...c,y:n},{...l,y:n})]}let f=Math.min(a,o),m=Math.max(a,o),h=p(s?f:m-1,e.index),g=p(s?m-1:f,e.index);return[lk(e,[c,{x:h,y:c.y},{x:h,y:u},{x:g,y:u},{x:g,y:l.y},l])]})},dk=({layers:e,chains:t,centers:n,space:r,reach:i})=>{let a=e=>n.get(e)??0,o=(e,t,o,s)=>{let c=a(e),l=t.map(e=>a(e)).toSorted((e,t)=>Math.abs(e-c)-Math.abs(t-c))[0];l!==void 0&&Math.abs(l-c)<i&&(o===void 0||a(o)+r(o,e)<=l)&&(s===void 0||l<=a(s)-r(e,s))&&n.set(e,l)},s=new Map,c=new Map;for(let{edge:e,stops:n}of t)e.kind===`flow`&&n.length===2&&(s.set(e.to,[...s.get(e.to)??[],e.from]),c.set(e.from,[...c.get(e.from)??[],e.to]));for(let t of e)for(let[e,n]of t.entries())o(n,s.get(n)??[],t[e-1],t[e+1]);for(let t of e)for(let[e,n]of t.entries())s.has(n)||o(n,c.get(n)??[],t[e-1],t[e+1])},fk=14,pk=(e,t)=>`\0${String(e.index)}:${String(t)}`,mk=e=>e.startsWith(`\0`),hk=(e,t)=>{let n=e=>mk(e)?0:23,r=mk(e)||mk(t)?fk:20;return n(e)+n(t)+r},gk=(e,t)=>e.map(e=>{let n=t.get(e.from)??0,r=t.get(e.to)??0,i=r>n?1:-1,a=Array.from({length:Math.max(Math.abs(r-n)-1,0)},(t,r)=>pk(e,n+i*(r+1)));return{edge:e,stops:[e.from,...a,e.to]}}),_k=(e,t)=>e.flatMap(({stops:e})=>e.slice(1).flatMap((n,r)=>{let i=e[r]??n,a=t(i),o=t(n);return a===o?[]:a<o?[[i,n]]:[[n,i]]})),vk=(e,t)=>{let n=[...e.flatMap(e=>[e.x,e.x+e.width]),...t.flatMap(e=>e.points.map(e=>e.x))],r=[...e.flatMap(e=>[e.y,e.y+e.height]),...t.flatMap(e=>e.points.map(e=>e.y))];return{minX:Math.min(...n),minY:Math.min(...r),maxX:Math.max(...n),maxY:Math.max(...r)}},yk=(e,t)=>{let{minX:n,minY:r,maxX:i,maxY:a}=vk(e,t),o=16-n,s=16-r,c=({x:e,y:t})=>({x:e+o,y:t+s});return{nodes:e.map(e=>({...e,...c(e)})),edges:t.map(e=>({...e,points:e.points.map(c),...e.labelAt===void 0?{}:{labelAt:c(e.labelAt)}})),width:i-n+32,height:a-r+32}},bk=e=>{let t=e.nodes.map(e=>e.id),n=HO(e),r=WO(t,n),i=gk(n,r),a=new Map;for(let{edge:e,stops:t}of i){let n=r.get(e.from)??0,i=(r.get(e.to)??0)>n?1:-1;for(let[e,r]of t.slice(1,-1).entries())a.set(r,n+i*(e+1))}let o=e=>r.get(e)??a.get(e)??0,s=Math.max(0,...r.values()),c=Array.from({length:s+1},()=>[]);for(let e of[...t,...a.keys()])c[o(e)]?.push(e);let l=_k(i,o),u=RO(c,l),d=VO(u,l,hk);dk({layers:u,chains:i,centers:d,space:hk,reach:20});let f=new Map;for(let{edge:e,stops:t}of i)if(e.label!==void 0&&e.from!==e.to&&t.length===2&&o(e.from)!==o(e.to)){let t=Math.min(o(e.from),o(e.to)),n=BE(e.label).length*VE+32;f.set(t,Math.max(f.get(t)??48,n))}let p=e=>f.get(e)??48,m=[0];for(let e=0;e<s;e+=1)m.push((m[e]??0)+152+p(e));let h=e=>m[e]??0,g=new Map(e.nodes.map(({id:e,type:t})=>{let n=o(e);return[e,{id:e,type:t,x:h(n),y:(d.get(e)??0)-23,width:152,height:46,rank:n}]})),_=uk({chains:i,nodes:g,stopY:d,rankOf:o,columnX:h,columnWidth:152,gapWidth:p});return yk([...g.values()],_)},xk=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Sk=e=>Array.isArray(e)?e.filter(e=>xk(e)):[],Ck=e=>typeof e.description==`string`?e.description:void 0,wk=e=>e===!0?`On`:e===!1?`Off`:typeof e==`string`||typeof e==`number`?String(e):``,Tk=e=>(Array.isArray(e.enum)?e.enum:`const`in e?[e.const]:e.type===`boolean`?[!0,!1]:void 0)?.map(e=>({value:e,label:wk(e)})),Ek=e=>[...Sk(e.anyOf),...Sk(e.oneOf)],Dk=e=>{let t=Ek(e);if(t.length>0){let e=t.map(e=>Tk(e));if(e.every(e=>e!==void 0))return{kind:`choice`,options:e.flat()};let[n]=t;return t.length===1&&n!==void 0?Dk(n):{kind:`variants`,variants:t}}let n=Tk(e);if(n!==void 0)return{kind:`choice`,options:n};if(e.type===`string`)return{kind:`text`,pattern:typeof e.pattern==`string`?e.pattern:void 0};if(e.type===`number`||e.type===`integer`)return{kind:`number`,integer:e.type===`integer`};if(e.type===`array`){let t=Sk(e.prefixItems),[n]=t;return n===void 0?{kind:`list`,item:xk(e.items)?e.items:{}}:{kind:`list`,item:n,fixed:t.length}}if(e.type===`object`){if(xk(e.properties)){let t=Array.isArray(e.required)?e.required:[];return{kind:`object`,fields:Object.entries(e.properties).flatMap(([e,n])=>xk(n)?[{key:e,schema:n,required:t.includes(e)}]:[])}}return{kind:`record`,value:xk(e.additionalProperties)?e.additionalProperties:{}}}return{kind:`free`}},Ok=(e,t)=>{let n=Dk(e);switch(n.kind){case`text`:return typeof t==`string`;case`number`:return typeof t==`number`;case`choice`:return n.options.some(e=>e.value===t);case`list`:return Array.isArray(t);case`object`:case`record`:return xk(t);case`variants`:return n.variants.some(e=>Ok(e,t));case`free`:return!0;default:return!1}},kk=(e,t)=>{let n=e.findIndex(e=>Ok(e,t));return n===-1?0:n},Ak=[[`text`,`Text`],[`number`,`Number`],[`choice`,`Choice`],[`list`,`List`],[`object`,`Details`],[`record`,`Named values`],[`variants`,`Other`],[`free`,`Anything`]],jk=e=>{let{kind:t}=Dk(e);return Ak.find(([e])=>e===t)?.[1]??t},Mk=e=>{let t=Dk(e);switch(t.kind){case`number`:return 0;case`choice`:return t.options[0]?.value;case`list`:return[];case`object`:case`record`:return{};case`text`:case`variants`:case`free`:return``;default:return t}},Nk=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):``,Pk={budgetUsd:`Budget (USD)`,plainEnv:`Plain environment`,env:`Environment`,cwd:`Working folder`,maxRounds:`Max rounds`,maxTurns:`Max turns`,maxMessages:`Max messages`,dayUsd:`Per day (USD)`,weekUsd:`Per week (USD)`,monthUsd:`Per month (USD)`},Fk=e=>{let t=Pk[e];if(t!==void 0)return t;let n=e.replaceAll(/([a-z0-9])([A-Z])/gu,`$1 $2`).toLowerCase();return`${n.charAt(0).toUpperCase()}${n.slice(1)}`},Ik=new Set([`prompt`,`instructions`,`question`,`script`,`body`,`command`]),Lk=(e,t)=>Ik.has(e)||typeof t==`string`&&t.includes(`
|
|
57
|
+
`),Rk=e=>Number.isFinite(Number(e))&&String(Number(e))===e,zk=e=>{let t=e.trim();if(t!==``){if(t===`true`)return!0;if(t===`false`)return!1;if(t===`null`)return null;if(Rk(t))return Number(t);if(!/^[[{"]/u.test(t))return e;try{return JSON.parse(t)}catch{return e}}},Bk=e=>e===void 0?``:typeof e==`string`&&zk(e)===e?e:JSON.stringify(e),Vk=(e,t)=>{let n=xk(e.properties)?e.properties.nodes:void 0,r=xk(n)?n.additionalProperties:void 0;return xk(r)?Ek(r).find(e=>{let n=e.properties,r=xk(n)?n.type:void 0;return xk(r)&&r.const===t}):void 0},Hk=e=>{let t=xk(e.properties)?e.properties.nodes:void 0,n=xk(t)?t.additionalProperties:void 0;return xk(n)?Ek(n).flatMap(e=>{let t=e.properties,n=xk(t)?t.type:void 0;return xk(n)&&typeof n.const==`string`?[n.const]:[]}):[]},Uk=e=>{let[t,n]=e.path;return t===`nodes`&&typeof n==`string`?n:void 0},Wk=e=>{let t=e.path.at(-1);return e.message.endsWith(`received undefined`)&&typeof t==`string`?`${Fk(t)} is required.`:e.message},Gk=e=>{let t=new Map;for(let n of e){let e=Uk(n);e!==void 0&&t.set(e,[...t.get(e)??[],n])}return t},Kk=(e,t)=>`${String(e)} ${t}${e===1?``:`s`}`,qk=(e,t)=>{let n=Gk(t),r=!t.some(({code:e})=>/^(schema|yaml)\./u.test(e));return new Map(e.nodes.map(({id:e})=>{let t=n.get(e)??[],i=t.filter(e=>e.severity===`error`).length,a=t.length-i;return i>0?[e,{status:`failed`,word:Kk(i,`error`)}]:a>0?[e,{status:`waiting`,word:Kk(a,`warning`)}]:[e,{status:`queued`,word:r?`no problems`:`not checked yet`}]}))},Jk=(e,t)=>e.filter(e=>e.path.length===t.length&&e.path.every((e,n)=>e===t[n])),Yk=(e,t)=>{let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(typeof n==`object`&&n&&!Array.isArray(n))n=Object.entries(n).find(([t])=>t===e)?.[1];else return;return n},Xk=(e,t)=>e===t||e!==void 0&&t!==void 0&&JSON.stringify(e)===JSON.stringify(t),Zk=e=>e.filter(e=>e.severity===`error`).length,Qk=(e,t)=>{let n=(e.split(`.`).at(-1)??`node`).toLowerCase();if(!t.includes(n))return n;let r=2;for(;t.includes(`${n}-${String(r)}`);)r+=1;return`${n}-${String(r)}`},$k=new Set([`tool.gh`,`tool.aws`,`mcp.call`,`workflow.call`]),eA=e=>e.nodes.filter(({type:e})=>$k.has(e)).map(({id:e,type:t})=>`${e} (${t})`),tA=e=>e.nodes.filter(({type:e})=>e===`claude.leader`||e===`claude.worker`).map(({id:e})=>e),nA={panel:`_panel_16yrr_8`,tools:`_tools_16yrr_21`,chooser:`_chooser_16yrr_37`,create:`_create_16yrr_38`,actions:`_actions_16yrr_39`,connect:`_connect_16yrr_40`,notices:`_notices_16yrr_53`,status:`_status_16yrr_73`,error:`_error_16yrr_79`,empty:`_empty_16yrr_89`,body:`_body_16yrr_99`,palette:`_palette_16yrr_118`,inspector:`_inspector_16yrr_119`,middle:`_middle_16yrr_146`,canvas:`_canvas_16yrr_160`,problems:`_problems_16yrr_174`,clean:`_clean_16yrr_175`,problemsHead:`_problemsHead_16yrr_203`,walk:`_walk_16yrr_215`,problemList:`_problemList_16yrr_224`,types:`_types_16yrr_225`,edges:`_edges_16yrr_226`,problemLink:`_problemLink_16yrr_250`,heading:`_heading_16yrr_266`,subheading:`_subheading_16yrr_283`,type:`_type_16yrr_225`,fields:`_fields_16yrr_321`,edge:`_edge_16yrr_226`,testRow:`_testRow_16yrr_338`,field:`_field_16yrr_321`,choice:`_choice_16yrr_345`,problem:`_problem_16yrr_174`,problemIcon:`_problemIcon_16yrr_376`,problemWords:`_problemWords_16yrr_386`,hint:`_hint_16yrr_390`,group:`_group_16yrr_404`,summary:`_summary_16yrr_424`,row:`_row_16yrr_435`,rowName:`_rowName_16yrr_449`,edgeName:`_edgeName_16yrr_480`},rA=({builder:e})=>{let t=e.schema===null?[]:Hk(e.schema),n=e.view?.graph.nodes.map(({id:e})=>e)??[],r=async t=>{let r=Qk(t,n);await e.edit({op:`addNode`,id:r,node:{type:t}})&&e.select(r)};return(0,G.jsxs)(`nav`,{"aria-label":`Add a node`,className:nA.palette,children:[(0,G.jsx)(`h2`,{className:nA.heading,children:`Add a node`}),(0,G.jsx)(`ul`,{className:nA.types,children:t.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{className:nA.type,onClick:()=>{r(e)},type:`button`,children:[(0,G.jsx)(PD,{type:e}),ED(e)]})},e))})]})},iA=({problems:e,walk:t,onChoose:n})=>e.length===0?(0,G.jsxs)(`output`,{className:nA.clean,children:[`No problems found.`,t===null?``:` ${t}`]}):(0,G.jsxs)(`section`,{"aria-label":`Problems`,className:nA.problems,children:[(0,G.jsxs)(`div`,{className:nA.problemsHead,children:[(0,G.jsx)(`h2`,{className:nA.heading,children:Zk(e)>0?`Fix these before saving`:`Warnings`}),t===null?null:(0,G.jsx)(`p`,{className:nA.walk,children:t})]}),(0,G.jsx)(`ul`,{className:nA.problemList,children:e.map(e=>{let t=Uk(e),r=`${e.code} ${e.path.join(`.`)} ${e.message}`;return(0,G.jsx)(`li`,{children:t===void 0?(0,G.jsx)(`span`,{children:(0,G.jsx)(Wg,{text:Wk(e)})}):(0,G.jsxs)(`button`,{className:nA.problemLink,onClick:()=>{n(t)},type:`button`,children:[Wk(e).startsWith(`\`${t}\``)?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`code`,{children:t}),`:`,` `]}),(0,G.jsx)(Wg,{text:Wk(e)})]})},r)})})]}),aA=cs({name:Co().min(1)}),oA=cs({edits:as(zs()).min(1)}),sA=cs({text:Co(),baseHash:Co().nullable()}),cA=cs({force:$o().optional()}),lA={builderSchema:{method:`GET`,path:`/api/workflow-schema`},builderCatalog:{method:`GET`,path:`/api/projects/:id/catalog`},builderDrafts:{method:`GET`,path:`/api/projects/:id/builder`},builderView:{method:`GET`,path:`/api/projects/:id/builder/:name`},builderCreate:{method:`POST`,path:`/api/projects/:id/builder`,body:aA},builderEdit:{method:`POST`,path:`/api/projects/:id/builder/:name/edits`,body:oA},builderRestore:{method:`POST`,path:`/api/projects/:id/builder/:name/text`,body:sA},builderDiscard:{method:`POST`,path:`/api/projects/:id/builder/:name/discard`},builderSave:{method:`POST`,path:`/api/projects/:id/builder/:name/save`,body:cA}},uA={runContext:{method:`GET`,path:`/api/runs/:id/nodes/:node/context`},builderContext:{method:`GET`,path:`/api/projects/:id/builder/:name/nodes/:node/context`}},dA=cs({text:Co().min(1),node:Co().min(1).optional(),kind:Co().min(1).optional(),severity:Co().min(1).optional(),rating:Co().min(1).optional()}),fA=cs({status:_s([`dismissed`,`new`])}),pA=cs({lesson:$o(),text:Co().min(1).optional(),workflow:Co().min(1).optional()}),mA=cs({driver:_s([`sdk`,`cli`]).optional()}),hA=cs({hideNames:$o()}),gA=cs({hideNames:$o(),digest:Co().min(1)}),_A={note:{method:`POST`,path:`/api/runs/:id/notes`,body:dA},feedbackItems:{method:`GET`,path:`/api/feedback`},feedbackItem:{method:`GET`,path:`/api/feedback/:id`},feedbackStatus:{method:`POST`,path:`/api/feedback/:id/status`,body:fA},accept:{method:`POST`,path:`/api/feedback/:id/accept`,body:pA},apply:{method:`POST`,path:`/api/feedback/:id/apply`,body:mA},publishPreview:{method:`POST`,path:`/api/feedback/:id/publish/preview`,body:hA},publish:{method:`POST`,path:`/api/feedback/:id/publish`,body:gA},split:{method:`POST`,path:`/api/feedback/:id/split`}},vA=cs({a:Co().min(3),b:Co().min(3),maxMessages:Yo().int().positive().optional()}),yA=cs({a:Co().min(3),b:Co().min(3)}),bA={links:{method:`GET`,path:`/api/links`,query:cs({run:Co().min(1).optional()})},link:{method:`POST`,path:`/api/links`,body:vA},unlink:{method:`POST`,path:`/api/links/end`,body:yA}},xA={version:{method:`GET`,path:`/api/version`},upgradePlan:{method:`POST`,path:`/api/upgrade/plan`},upgrade:{method:`POST`,path:`/api/upgrade`,body:cs({planId:Co().min(1)})},restart:{method:`POST`,path:`/api/restart`}},SA=Co().min(1),CA=cs({project:SA.optional()}),wA=cs({project:SA,key:Co().min(1),deleteBranch:$o()}),TA=wA.extend({force:$o(),digest:Co().min(1)}),EA=cs({project:SA.optional(),branches:$o()}),DA=EA.extend({digest:Co().min(1)}),OA={worktrees:{method:`GET`,path:`/api/worktrees`,query:CA},worktreeRemovePlan:{method:`POST`,path:`/api/worktrees/remove/plan`,body:wA},worktreeRemove:{method:`POST`,path:`/api/worktrees/remove`,body:TA},worktreesCleanPlan:{method:`POST`,path:`/api/worktrees/clean/plan`,body:EA},worktreesClean:{method:`POST`,path:`/api/worktrees/clean`,body:DA}},kA=Us().int().positive(),AA=Us().int().nonnegative(),jA=_s([`sdk`,`cli`]),MA=cs({project:Co().min(1).optional(),limit:kA.optional()}),NA=cs({project:Co().min(1).optional(),workflow:Co().min(1).optional(),since:Hs().optional(),until:Hs().optional()}),PA=cs({after:AA.optional(),node:Co().min(1).optional(),limit:kA.optional(),last:kA.optional()}),FA=cs({run:Co().min(1).optional(),project:Co().min(1).optional(),workflow:Co().min(1).optional()}),IA=cs({choose:Co().min(1),note:Co().optional()}),LA={inputs:hs(Co(),Co()).optional(),driver:jA.optional(),inPlace:$o().optional(),allowDirty:$o().optional()},RA=cs({project:Co().min(1),workflow:Co().min(1),...LA,machineClaude:$o().optional()}),zA=cs(LA),BA=cs({node:Co().min(1),body:Co().min(1)}),VA=cs({node:Co().min(1).optional()}),HA={health:{method:`GET`,path:`/api/health`},...lA,...uA,..._A,...OA,...xA,projects:{method:`GET`,path:`/api/projects`},workflows:{method:`GET`,path:`/api/projects/:id/workflows`},runs:{method:`GET`,path:`/api/runs`,query:MA},run:{method:`GET`,path:`/api/runs/:id`},tree:{method:`GET`,path:`/api/runs/:id/tree`},graph:{method:`GET`,path:`/api/runs/:id/graph`},events:{method:`GET`,path:`/api/runs/:id/events`,query:PA},decisions:{method:`GET`,path:`/api/decisions`,query:FA},decision:{method:`GET`,path:`/api/decisions/:id`},answer:{method:`POST`,path:`/api/decisions/:id`,body:IA},start:{method:`POST`,path:`/api/runs`,body:RA},resume:{method:`POST`,path:`/api/runs/:id/resume`,body:zA},stop:{method:`POST`,path:`/api/runs/:id/stop`,body:VA},pause:{method:`POST`,path:`/api/runs/:id/pause`,body:VA},continue:{method:`POST`,path:`/api/runs/:id/continue`,body:VA},message:{method:`POST`,path:`/api/runs/:id/messages`,body:BA},usage:{method:`GET`,path:`/api/usage`,query:NA},triggers:{method:`GET`,path:`/api/triggers`},...bA},UA={run:`/api/runs/:id/stream`,overview:`/api/stream`,upgrade:`/api/upgrade/stream`},WA=(e,t)=>e.replaceAll(/:(\w+)/gu,(e,n)=>encodeURIComponent(t[n]??``)),GA=e=>typeof e==`object`&&e?Object.entries(e).flatMap(([e,t])=>typeof t==`string`||typeof t==`number`?[[e,String(t)]]:[]):[],KA=e=>{let t=new URLSearchParams;for(let[n,r]of GA(e))t.set(n,r);let n=t.toString();return n===``?``:`?${n}`},qA=(e,t)=>typeof e==`object`&&e&&`error`in e&&typeof e.error==`string`?e.error:`The server answered ${String(t)}.`,JA=(e={})=>{let t=(t,n)=>(e.fetch??globalThis.fetch)(t,n);return{call:async(n,...[r])=>{let i=HA[n],a=r??{},o=Object.fromEntries(GA(a.params)),s=`${e.base??``}${WA(i.path,o)}${KA(a.query)}`,c={accept:`application/json`};e.token!==void 0&&(c.authorization=`Bearer ${e.token}`);let l={method:i.method,headers:c};i.method===`POST`&&(c[`content-type`]=`application/json`,l.body=JSON.stringify(a.body??{}));let u;try{u=await t(s,l)}catch(e){return{ok:!1,status:0,error:`No answer: ${e instanceof Error?e.message:String(e)}`}}let d=await u.json().catch(()=>null);return u.ok?{ok:!0,status:u.status,data:d}:{ok:!1,status:u.status,error:qA(d,u.status)}}}},YA=e=>typeof e==`string`?`'${e.replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`)}'`:String(e??`''`),XA={is:`==`,isnt:`!=`,above:`>`,atLeast:`>=`,below:`<`,atMost:`<=`},ZA={anyIs:`any`,allAre:`all`,contains:`contains`},QA=({field:e,test:t,value:n})=>{if(t===`isTrue`)return e;if(t===`isFalse`)return`!${e}`;let r=ZA[t];return r===void 0?`${e} ${String(XA[t])} ${YA(n)}`:`${r}(${e}, ${YA(n)})`},$A=e=>{switch(e.mode){case`succeeds`:return;case`fails`:return`!ok`;case`otherwise`:return`true`;case`hand`:return e.text;case`test`:return e.rows.map(QA).join(e.join===`any`?` || `:` && `);default:return}},ej={is:`isnt`,isnt:`is`,above:`atMost`,atMost:`above`,below:`atLeast`,atLeast:`below`,isTrue:`isFalse`,isFalse:`isTrue`},tj=e=>{if(e.mode!==`succeeds`&&e.mode!==`otherwise`){if(e.mode===`fails`)return`ok`;if(e.mode===`test`&&e.rows.length===1){let[t]=e.rows,n=t===void 0?void 0:ej[t.test];if(t!==void 0&&n!==void 0)return QA({...t,test:n})}return`!(${String($A(e))})`}},nj={fields:[],canFail:!1,canDeclare:!1},rj=3,ij=(e,t)=>e.says?.[t]??nj,aj={is:`is`,isnt:`isn't`,above:`is above`,atLeast:`is at least`,below:`is below`,atMost:`is at most`,contains:`contains`,anyIs:`any is`,allAre:`all are`,isTrue:`is true`,isFalse:`is false`},oj={values:[`is`,`isnt`],statuses:[`anyIs`,`allAre`],number:[`above`,`atLeast`,`below`,`atMost`,`is`,`isnt`],boolean:[`isTrue`,`isFalse`],text:[`contains`,`is`,`isnt`]},sj=e=>oj[e.kind],cj=e=>e!==`isTrue`&&e!==`isFalse`,lj=(e,t)=>{let n=t.find(({field:t})=>t===e.field);return n===void 0||!sj(n).includes(e.test)?!1:n.values===void 0||e.value===void 0||n.values.includes(e.value)},uj=({condition:e,when:t},n)=>{let r=e??{mode:`succeeds`};return r.mode===`test`&&!r.rows.every(e=>lj(e,n.fields))?{mode:`hand`,text:t??``}:r},dj=(e,t)=>{let n=sj(e)[0]??`is`;if(!cj(n))return{field:e.field,test:n};let r=e.values?.[0]??(e.kind===`number`?0:``);return{field:e.field,test:n,value:t??r}},fj=(e,t)=>{let n=e.fields.find(({values:e})=>(e??[]).length>0)??e.fields[0];return n===void 0?void 0:dj(n,n.values?.includes(t??``)===!0?t:void 0)},pj=e=>e.fields.flatMap(({field:e,values:t})=>e===`choice`?(t??[]).map(String):[]),mj=({condition:e},t)=>e===void 0||e.mode===`succeeds`||e.mode===`test`&&e.rows.some(({test:e,value:n})=>e===`is`&&n===t),hj=(e,t)=>{let n=e.edges.filter(({from:e})=>e===t);return n.length===0?[]:pj(ij(e,t)).filter(e=>!n.some(t=>mj(t,e)))},gj=(e,t,n)=>{let r=new Set([t]),i=[t];for(let t of i)for(let n of e.edges)n.from===t&&!r.has(n.to)&&(r.add(n.to),i.push(n.to));return r.has(n)},_j=e=>e===void 0?void 0:$A({mode:`test`,join:`all`,rows:[e]}),vj=(e,t,n)=>{let r=ij(e,t);if(gj(e,n,t))return _j(fj(r,`changes_requested`));let i=e.edges.filter(e=>e.from===t),a=pj(r);if(a.length>0){let[n]=i.length===0?a:hj(e,t);return n===void 0?void 0:_j({field:`choice`,test:`is`,value:n})}let o=i.find(({maxRounds:e})=>e!==void 0);return o?.condition===void 0?e.nodes.find(({id:e})=>e===t)?.type===`control.router`?_j(fj(r))??`true`:void 0:tj(o.condition)},yj=(e,t,n)=>{let r=vj(e,t,n);return{op:`connect`,from:t,to:n,...r===void 0?{}:{when:r},...gj(e,n,t)?{maxRounds:rj}:{}}},bj=/^[A-Za-z_][A-Za-z0-9_-]*$/u,xj=e=>e.split(`,`).map(e=>e.trim()).filter(e=>e!==``).map(e=>e===`true`?!0:e===`false`?!1:Number.isFinite(Number(e))?Number(e):e),Sj=({to:e,onDeclare:t})=>{let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(``);if(!n)return(0,G.jsxs)(q,{onClick:()=>{r(!0)},children:[`Add a field`,(0,G.jsxs)(zw,{children:[`, to `,e]})]});let c=xj(o);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Uw,{description:`A field of the JSON this node gives, such as state.`,label:`New field`,unseen:`, to ${e}`,onChange:a,value:i}),(0,G.jsx)(Uw,{description:`Separated by commas. A run fails this node on anything else.`,label:`Its values`,unseen:`, to ${e}`,onChange:s,value:o}),(0,G.jsxs)(q,{disabled:!bj.test(i)||c.length===0,onClick:()=>{t(i,c),r(!1),a(``),s(``)},children:[`Add `,i===``?`field`:i]})]})},Cj=(e,t)=>{e.context.change(e.path,()=>t)},wj=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Tj=({label:e,unseen:t,shown:n,commit:r,description:i,required:a=!1,multiline:o=!1,number:s=!1})=>{let[c,l]=(0,V.useState)(n),[u,d]=(0,V.useState)(n),[f,p]=(0,V.useState)(null);return u!==n&&(d(n),p(null),n!==f&&l(n)),(0,G.jsx)(Uw,{description:i,label:e,unseen:t,multiline:o,onChange:l,onCommit:()=>{c!==n&&c!==f&&(p(c),r(c))},required:a,type:s?`number`:`text`,value:c})},Ej=`__not_set__`,Dj=({options:e,...t})=>{let{name:n,schema:r,value:i,required:a}=t,o=[...a&&i!==void 0?[]:[{value:Ej,label:a?`Choose one`:`Default`}],...e.map(e=>({value:Nk(e.value),label:e.label}))],s=Ck(r);return(0,G.jsxs)(`div`,{className:nA.choice,children:[(0,G.jsx)(Bw,{label:Fk(n),onChange:n=>{Cj(t,n===Ej?void 0:e.find(e=>Nk(e.value)===n)?.value)},options:o,value:i===void 0?o[0]?.value??``:Nk(i)}),s===void 0?null:(0,G.jsx)(`p`,{className:nA.hint,children:(0,G.jsx)(Wg,{text:s})})]})},Oj=({name:e,description:t,open:n,children:r})=>(0,G.jsxs)(`details`,{className:nA.group,open:n,children:[(0,G.jsx)(`summary`,{className:nA.summary,children:Fk(e)}),t===void 0?null:(0,G.jsx)(`p`,{className:nA.hint,children:(0,G.jsx)(Wg,{text:t})}),(0,G.jsx)(`div`,{className:nA.fields,children:r})]}),kj=(e,t)=>t&&e.trim()!==``&&Number.isFinite(Number(e))?Number(e):e,Aj=({row:e,fields:t,to:n,index:r,onChange:i})=>{let a=t.find(({field:t})=>t===e.field),o=`${r===0?``:`${String(r+1)} `}to ${n}`;if(a===void 0)return null;let s=a.values??[];return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Bw,{label:`Field`,unseen:`, ${o}`,onChange:e=>{let n=t.find(t=>t.field===e);n!==void 0&&i(dj(n))},options:t.map(({field:e})=>({value:e,label:e})),value:e.field}),(0,G.jsx)(Bw,{label:`Test`,unseen:`, ${o}`,onChange:t=>{let n=t,{value:r}=dj(a);i({field:e.field,test:n,...cj(n)?{value:e.value??r??``}:{}})},options:sj(a).map(e=>({value:e,label:aj[e]})),value:e.test}),cj(e.test)&&s.length>0?(0,G.jsx)(Bw,{label:`Value`,unseen:`, ${o}`,onChange:t=>{i({...e,value:s.find(e=>String(e)===t)??t})},options:s.map(e=>({value:String(e),label:String(e)})),value:String(e.value)}):null,cj(e.test)&&s.length===0?(0,G.jsx)(Tj,{commit:t=>{i({...e,value:kj(t,a.kind===`number`)})},label:`Value`,unseen:`, ${o}`,number:a.kind===`number`,shown:String(e.value??``)}):null]})},jj=e=>`row ${String(e)}`,Mj=({condition:e,says:t,to:n,onChange:r})=>{let{rows:i,join:a}=e,o=e=>{r({mode:`test`,join:a,rows:e})},s=fj(t);return(0,G.jsxs)(G.Fragment,{children:[i.length<2?null:(0,G.jsx)(Bw,{label:`Which tests`,unseen:`, to ${n}`,onChange:e=>{r({mode:`test`,join:e===`any`?`any`:`all`,rows:i})},options:[{value:`all`,label:`All of these`},{value:`any`,label:`Any of these`}],value:a}),i.map((e,r)=>(0,G.jsxs)(`div`,{className:nA.testRow,children:[(0,G.jsx)(Aj,{fields:t.fields,index:r,onChange:e=>{o(i.map((t,n)=>n===r?e:t))},row:e,to:n}),i.length<2?null:(0,G.jsxs)(q,{onClick:()=>{o(i.filter((e,t)=>t!==r))},children:[`Remove test `,String(r+1),(0,G.jsxs)(zw,{children:[`, to `,n]})]})]},jj(r))),s===void 0?null:(0,G.jsxs)(q,{onClick:()=>{o([...i,s])},children:[`Add a test`,(0,G.jsxs)(zw,{children:[`, to `,n]})]})]})},Nj=({to:e,says:t,condition:n,when:r,loop:i,gate:a,canBeOtherwise:o,onChange:s,onDeclare:c})=>{let[l,u]=(0,V.useState)(!1),d=fj(t),f=l?`hand`:n.mode,p=e=>{u(e===`hand`),e!==`hand`&&(e===`fails`?s(`!ok`):e===`otherwise`?s(`true`):e===`succeeds`?s():d!==void 0&&s($A({mode:`test`,join:`all`,rows:[d]})))},m=[{value:`succeeds`,label:i?`Every round`:a?`Whatever the answer`:`When it succeeds`},...t.canFail?[{value:`fails`,label:`When it fails`}]:[],...d===void 0?[]:[{value:`test`,label:`When a test holds`}],...o?[{value:`otherwise`,label:`Otherwise`}]:[],{value:`hand`,label:`Written by hand`}];return(0,G.jsxs)(`div`,{className:nA.fields,children:[(0,G.jsx)(Bw,{label:`Follow this edge`,unseen:`, to ${e}`,onChange:p,options:m,value:f}),f===`test`&&n.mode===`test`?(0,G.jsx)(Mj,{condition:n,onChange:e=>{s($A(e))},says:t,to:e}):null,f===`hand`?(0,G.jsx)(Tj,{commit:e=>{s(e===``?void 0:e)},description:`An expression, such as status == 'pass'. It's kept as you write it.`,label:`Condition`,unseen:`, to ${e}`,shown:r??``}):null,t.canDeclare?(0,G.jsx)(Sj,{onDeclare:c,to:e}):null]})},Pj=e=>e.when===void 0?{}:{whenWas:e.when},Fj=({edge:e,last:t,builder:n})=>{let{from:r,to:i}=e,a=n.view?.graph;if(a===void 0)return null;let o=a.nodes.find(({id:e})=>e===r)?.type,s=ij(a,r),c=e.maxRounds===void 0?{}:{maxRounds:e.maxRounds},l=t=>({op:`setEdge`,from:r,to:i,...t===void 0?{}:{when:t},...c,...Pj(e)}),u=e.maxRounds!==void 0;return(0,G.jsxs)(`li`,{className:nA.edge,children:[(0,G.jsxs)(`p`,{className:nA.edgeName,children:[`To `,i]}),(0,G.jsx)(Nj,{canBeOtherwise:o===`control.router`&&t,condition:uj(e,s),gate:o===`human.gate`,loop:u,onChange:e=>{n.edit(l(e))},onDeclare:(e,t)=>{let[i]=t;n.edit({op:`set`,path:[`nodes`,r,`output`,`schema`,e],value:t},l($A({mode:`test`,join:`all`,rows:[{field:`json.${e}`,test:`is`,...i===void 0?{}:{value:i}}]})))},says:s,to:i,when:e.when}),(0,G.jsx)(Tj,{commit:t=>{n.edit({op:`setEdge`,from:r,to:i,...e.when===void 0?{}:{when:e.when},...t===``?{}:{maxRounds:Number(t)},...Pj(e)})},description:`Needed on an edge that closes a loop.`,label:`Max rounds`,unseen:`, to ${i}`,number:!0,shown:e.maxRounds===void 0?``:String(e.maxRounds)}),(0,G.jsxs)(q,{onClick:()=>{n.edit({op:`disconnect`,from:r,to:i,...Pj(e)})},children:[`Remove edge`,(0,G.jsxs)(zw,{children:[` to `,i]})]})]})},Ij=({id:e,builder:t})=>{let n=t.view?.graph,[r,i]=(0,V.useState)(``);if(n===void 0)return null;let a=n.edges.filter(({from:t})=>t===e),o=n.edges.filter(({to:t})=>t===e),s=n.nodes.map(e=>e.id).filter(e=>!a.some(({to:t})=>t===e)).toSorted((t,n)=>Number(t===e)-Number(n===e)),c=s.includes(r)?r:s[0]??``,l=hj(n,e);return(0,G.jsxs)(`section`,{"aria-label":`Edges of ${e}`,className:nA.fields,children:[(0,G.jsx)(`h3`,{className:nA.subheading,children:`Edges`}),o.length===0?null:(0,G.jsxs)(`p`,{className:nA.hint,children:[`From `,o.map(({from:e})=>e).join(`, `)]}),a.length===0?(0,G.jsx)(`p`,{className:nA.hint,children:`Nothing follows this node yet.`}):(0,G.jsx)(`ul`,{className:nA.edges,children:a.map((e,n)=>(0,G.jsx)(Fj,{builder:t,edge:e,last:n===a.length-1},`${e.to} ${String(a.slice(0,n).filter(({to:t})=>t===e.to).length)}`))}),l.length===0?null:(0,G.jsxs)(`p`,{className:nA.hint,children:[`Answering `,l.join(` or `),` ends the run here.`]}),s.length===0?null:(0,G.jsxs)(`div`,{className:nA.connect,children:[(0,G.jsx)(Bw,{label:`Connect to`,onChange:i,options:s.map(e=>({value:e,label:e})),value:c}),(0,G.jsx)(q,{onClick:()=>{t.edit(yj(n,e,c))},children:`Connect`}),(0,G.jsx)(q,{"aria-pressed":t.connecting,onClick:()=>{t.setConnecting(!t.connecting)},children:t.connecting?`Cancel picking`:`Pick a card`})]})]})},Lj=()=>{},Rj=e=>Array.isArray(e)?e:[],zj=({name:e,path:t,schema:n,value:r,context:i,item:a,fixed:o,draw:s})=>{let c=Array.isArray(r)?r:[];return(0,G.jsxs)(Oj,{description:Ck(n),name:e,open:c.length>0,children:[c.map((n,r)=>(0,G.jsxs)(`div`,{className:nA.row,children:[s({context:i,name:`${e} ${String(r+1)}`,path:[...t,r],required:!0,schema:a,value:n}),o===void 0?(0,G.jsxs)(q,{onClick:()=>{i.change(t,e=>{let t=Rj(e).filter((e,t)=>t!==r);return t.length===0?void 0:t})},children:[`Remove `,Fk(e).toLowerCase(),` `,r+1]}):null]},r)),o!==void 0&&c.length>=o?null:(0,G.jsxs)(q,{onClick:()=>{i.change(t,e=>[...Rj(e),Mk(a)])},children:[`Add to `,Fk(e).toLowerCase()]})]})},Bj=({name:e,path:t,schema:n,value:r,context:i,valueSchema:a,draw:o})=>{let s=wj(r)?Object.entries(r):[],[c,l]=(0,V.useState)(``),u=c.trim(),d=s.some(([e])=>e===u);return(0,G.jsxs)(Oj,{description:Ck(n),name:e,open:s.length>0,children:[s.map(([e,n])=>(0,G.jsxs)(`div`,{className:nA.row,children:[o({context:i,name:e,path:[...t,e],required:!0,schema:a,value:n}),(0,G.jsxs)(q,{onClick:()=>{i.change([...t,e],Lj)},children:[`Remove `,e]})]},e)),(0,G.jsx)(Uw,{description:d?`${u} is already here.`:void 0,label:`New name in ${Fk(e).toLowerCase()}`,onChange:l,value:c}),(0,G.jsxs)(q,{disabled:u===``||d,focusableWhenDisabled:!0,onClick:()=>{i.change([...t,u],e=>e===void 0?Mk(a):e),l(``)},children:[`Add to `,Fk(e).toLowerCase()]})]})},Vj=e=>{let{name:t,value:n,variants:r,draw:i}=e,a=kk(r,n),o=r[a]??{};return(0,G.jsxs)(`div`,{className:nA.fields,children:[(0,G.jsx)(Bw,{label:`${Fk(t)} as`,onChange:t=>{Cj(e,Mk(r[Number(t)]??{}))},options:r.map((e,t)=>({value:String(t),label:jk(e)})),value:String(a)}),i({...e,schema:o})]})},Hj=e=>(0,G.jsx)(Gj,{...e}),Uj=({fields:e,value:t,path:n,context:r})=>{let i=wj(t)?t:{};return(0,G.jsx)(G.Fragment,{children:e.map(({key:e,schema:t,required:a})=>(0,G.jsx)(Gj,{context:r,name:e,path:[...n,e],required:a,schema:t,value:i[e]},e))})},Wj=e=>{let{name:t,path:n,schema:r,value:i,required:a,context:o}=e,s=Dk(r),c=Ck(r);switch(s.kind){case`text`:return(0,G.jsx)(Tj,{commit:t=>{Cj(e,t===``&&!a?void 0:t)},description:c,label:Fk(t),multiline:Lk(t,i),required:a,shown:typeof i==`string`?i:``});case`number`:return(0,G.jsx)(Tj,{commit:t=>{Cj(e,t===``?void 0:Number(t))},description:c,label:Fk(t),number:!0,required:a,shown:typeof i==`number`?String(i):``});case`choice`:return(0,G.jsx)(Dj,{...e,options:s.options});case`object`:return(0,G.jsx)(Oj,{description:c,name:t,open:wj(i)&&Object.keys(i).length>0,children:(0,G.jsx)(Uj,{context:o,fields:s.fields,path:n,value:i})});case`list`:return(0,G.jsx)(zj,{...e,draw:Hj,fixed:s.fixed,item:s.item});case`record`:return(0,G.jsx)(Bj,{...e,draw:Hj,valueSchema:s.value});case`variants`:return(0,G.jsx)(Vj,{...e,draw:Hj,variants:s.variants});case`free`:return(0,G.jsx)(Tj,{commit:t=>{Cj(e,zk(t))},description:c??`Text, or JSON for a number or a list. Quote text that looks like either, such as "5".`,label:Fk(t),multiline:typeof i==`string`&&i.includes(`
|
|
58
|
+
`),shown:Bk(i)});default:return s}},Gj=e=>{let{path:t,context:n}=e,r=n.problems(t);return(0,G.jsxs)(`div`,{className:nA.field,"data-problem":r.length>0?``:void 0,children:[n.custom?.(e)??Wj(e),r.map(e=>(0,G.jsxs)(`p`,{className:nA.problem,children:[(0,G.jsx)(`span`,{className:nA.problemIcon,children:(0,G.jsx)(cD,{})}),(0,G.jsx)(`span`,{className:nA.problemWords,children:(0,G.jsx)(Wg,{text:e})})]},e))]})},Kj=e=>Array.isArray(e)?e:[],qj=({field:e,catalog:t})=>{let n=Array.isArray(e.value)?e.value.filter(e=>typeof e==`string`):[],[r,i]=(0,V.useState)(``),a=t=>{e.context.change(e.path,e=>Kj(e).includes(t)?e:[...Kj(e),t])},o=t.skills.filter(({name:e})=>!n.includes(e));return(0,G.jsxs)(`div`,{className:nA.fields,children:[(0,G.jsx)(`h3`,{className:nA.subheading,children:`Skills`}),n.length===0?(0,G.jsx)(`p`,{className:nA.hint,children:`It gets what the workflow and the project give it.`}):(0,G.jsx)(`ul`,{className:nA.edges,children:n.map(t=>(0,G.jsxs)(`li`,{className:nA.row,children:[(0,G.jsx)(`span`,{className:nA.rowName,children:t}),(0,G.jsxs)(q,{onClick:()=>{e.context.change(e.path,e=>{let n=Kj(e).filter(e=>e!==t);return n.length===0?void 0:n})},children:[`Remove `,t]})]},t))}),(0,G.jsx)(KS,{empty:`No skill matches.`,label:`Add a skill`,onChange:e=>{e!==null&&a(e)},options:o.map(({name:e,layer:t})=>({value:e,label:`${e} (${t})`})),placeholder:o.length===0?`No skills found`:`Type to find a skill`,value:null}),(0,G.jsx)(Uw,{description:`Or a path to one, such as ./skills/checklist.`,label:`Skill by path`,onChange:i,onCommit:()=>{r.trim()!==``&&a(r.trim()),i(``)},value:r})]})},Jj=(e,t)=>Dk(t.schema).kind===`list`?(0,G.jsx)(qj,{catalog:e.catalog,field:t}):null,Yj=`stop looking`,Xj=({says:e,condition:t,until:n,onChange:r,onDeclare:i})=>{let[a,o]=(0,V.useState)(!1),s=uj({condition:t,when:n},e),c=fj(e),l=!a&&s.mode===`test`,u=n===void 0&&!a,d=u?`unset`:l?`test`:`hand`;return(0,G.jsxs)(`div`,{className:nA.fields,children:[(0,G.jsx)(Bw,{label:`Look until`,onChange:e=>{o(e===`hand`),e===`test`&&c!==void 0&&r($A({mode:`test`,join:`all`,rows:[c]}))},options:[...u?[{value:`unset`,label:`Choose one`}]:[],...c===void 0?[]:[{value:`test`,label:`A test holds`}],{value:`hand`,label:`Written by hand`}],value:d}),l?(0,G.jsx)(Mj,{condition:s,onChange:e=>{r($A(e))},says:e,to:Yj}):null,d===`hand`?(0,G.jsx)(Tj,{commit:e=>{r(e===``?void 0:e)},description:`An expression, such as json.state != 'pending'. It's kept as you write it.`,label:`Condition`,shown:n??``,unseen:`, to ${Yj}`}):null,e.canDeclare?(0,G.jsx)(Sj,{onDeclare:i,to:Yj}):null]})},Zj=({builder:e,id:t,field:n})=>{let r=e.view?.graph;return r===void 0?null:(0,G.jsx)(Xj,{condition:r.untils?.[t],onChange:e=>{Cj(n,e)},onDeclare:(n,r)=>{let[i]=r;e.edit({op:`set`,path:[`nodes`,t,`output`,`schema`,n],value:r},{op:`set`,path:[`nodes`,t,`watch`,`until`],value:`json.${n} == ${JSON.stringify(i)}`})},says:ij(r,t),until:typeof n.value==`string`?n.value:void 0})},Qj=`__none__`,$j=(e,t)=>{let{document:n}=e.view??{},r=wj(n)?n.inputs:void 0,i=wj(r)?r[String(t.path[1])]:void 0,a=wj(i)?i.type:void 0,o=typeof a==`string`?a:`string`;return t.value===void 0||typeof t.value===o?Wj({...t,schema:{...t.schema,type:o}}):null},eM=(e,t,n)=>{let r=e.view?.graph;if(r===void 0)return null;let i=n.path.at(-1),a=typeof n.value==`string`?n.value:void 0;if(i===`parent`&&t!==null){let e=r.nodes.map(e=>e.id).filter(e=>e!==t);return(0,G.jsx)(Bw,{label:`Owner`,onChange:e=>{Cj(n,e===Qj?void 0:e)},options:[...n.required?[]:[{value:Qj,label:`None`}],...e.map(e=>({value:e,label:e}))],value:a??Qj})}if(i===`n`&&t!==null&&n.path.length===3){let e=r.edges.filter(({to:e})=>e===t).length,i=typeof n.value==`number`?n.value:1,a=Array.from({length:Math.max(e,i,1)},(e,t)=>String(t+1));return(0,G.jsx)(Bw,{label:`How many inputs to wait for`,onChange:e=>{Cj(n,Number(e))},options:a.map(e=>({value:e,label:e})),value:String(i)})}if((i===`recommended`||i==="default")&&t!==null&&n.path.length===3){let e=ij(r,t).fields.find(({field:e})=>e===`choice`)?.values??[];if(e.length>0)return(0,G.jsx)(Bw,{label:i==="default"?`If it times out`:`Recommended`,onChange:e=>{Cj(n,e===Qj?void 0:e)},options:[{value:Qj,label:`None`},...e.map(e=>({value:String(e),label:String(e)}))],value:a??Qj})}return i===`until`&&t!==null&&n.path.includes(`watch`)?(0,G.jsx)(Zj,{builder:e,field:n,id:t}):i===`to`&&n.path.includes(`notify`)?(0,G.jsx)(Bw,{label:`To`,onChange:e=>{Cj(n,e)},options:tA(r).map(e=>({value:e,label:e})),value:a??``}):i===`agent`?(0,G.jsx)(KS,{empty:`No agent matches.`,label:`Agent`,onChange:e=>{Cj(n,e??void 0)},options:e.catalog.agents.map(({name:e,source:t})=>({value:e,label:`${e} (${t})`})),placeholder:`Type to find an agent`,value:a??null}):i==="default"&&n.path[0]===`inputs`?$j(e,n):i===`skills`?Jj(e,n):null},tM=(e,t,n)=>({custom:n=>eM(e,t,n),change:(t,n)=>{e.change(t,n)},problems:e=>Jk(n,e).map(e=>Wk(e))}),nM=({schema:e,value:t,path:n,hide:r,context:i})=>{let a=Dk(e);if(a.kind!==`object`)return null;let o=wj(t)?t:{};return(0,G.jsx)(G.Fragment,{children:a.fields.filter(({key:e})=>!r.includes(e)).map(e=>(0,G.jsx)(Gj,{context:i,name:e.key,path:[...n,e.key],required:e.required,schema:e.schema,value:o[e.key]},e.key))})},rM=e=>wj(e)&&typeof e.type==`string`?e.type:``,iM=({id:e,builder:t})=>{let{view:n,schema:r}=t,[i,a]=(0,V.useState)(e),o=(0,V.useRef)(e),s=n?.document,c=wj(s)?s.nodes:void 0,l=wj(c)?c[e]:void 0,u=rM(l),d=r===null?void 0:Vk(r,u),f=async()=>{i!==o.current&&(o.current=i,await t.edit({op:`renameNode`,from:e,to:i})?t.select(i):(o.current=e,a(e)))},p=async()=>{await t.edit({op:`removeNode`,id:e})&&t.select(null)};return(0,G.jsxs)(`div`,{className:nA.fields,children:[(0,G.jsx)(`h2`,{className:nA.heading,children:ED(u)}),(0,G.jsx)(Uw,{description:`Lowercase, and read by other nodes. A new name follows every reference.`,label:`Name`,onChange:a,onCommit:()=>{f()},value:i}),d===void 0?(0,G.jsx)(`p`,{className:nA.hint,children:`This node has no known type, so there are no fields to show.`}):(0,G.jsx)(nM,{context:tM(t,e,n?.diagnostics??[]),hide:[`type`],path:[`nodes`,e],schema:d,value:l}),(0,G.jsx)(Ij,{builder:t,id:e}),(0,G.jsxs)(q,{onClick:()=>{p()},children:[`Remove `,e]})]})},aM=({builder:e})=>{let{view:t,schema:n}=e;return n===null?null:(0,G.jsxs)(`div`,{className:nA.fields,children:[(0,G.jsx)(`h2`,{className:nA.heading,children:`Workflow`}),(0,G.jsx)(nM,{context:tM(e,null,t?.diagnostics??[]),hide:[`schemaVersion`,`nodes`,`edges`],path:[],schema:n,value:t?.document})]})},oM=({builder:e})=>{let{selected:t,view:n}=e,r=n?.graph.nodes.some(({id:e})=>e===t)===!0;return t!==null&&r?(0,G.jsx)(iM,{builder:e,id:t},t):(0,G.jsx)(aM,{builder:e})},sM=({builder:e})=>{let t=e.view?.graph,n=e.view?.diagnostics,r=(0,V.useMemo)(()=>t===void 0?null:bk(t),[t]),i=(0,V.useMemo)(()=>t===void 0||n===void 0?void 0:qk(t,n),[t,n]);if(t===void 0||r===null)return null;if(t.nodes.length===0)return(0,G.jsx)(CC,{title:`No nodes yet.`,children:`Add one from the list beside this.`});let{selected:a,connecting:o}=e;return(0,G.jsx)(MO,{facts:i,label:`Workflow ${e.opened?.name??``}`,layout:r,onSelect:n=>{o&&a!==null?(e.setConnecting(!1),e.edit(yj(t,a,n))):e.select(n)},selected:a??void 0})},cM=({builder:e})=>{let{view:t}=e;return t===null?(0,G.jsx)(`div`,{className:nA.empty,children:(0,G.jsxs)(CC,{title:`No workflow open.`,children:[`Choose one above, or name a new one. A workflow you make here is the same file you could write by hand, and works with every`,` `,(0,G.jsx)(`code`,{children:`ork`}),` command.`]})}):(0,G.jsxs)(`div`,{className:nA.body,children:[(0,G.jsx)(rA,{builder:e}),(0,G.jsxs)(`div`,{className:nA.middle,children:[(0,G.jsx)(`div`,{className:nA.canvas,children:(0,G.jsx)(sM,{builder:e})}),(0,G.jsx)(iA,{onChoose:e.select,problems:t.diagnostics,walk:t.walk})]}),(0,G.jsx)(`aside`,{"aria-label":`Inspector`,className:nA.inspector,children:(0,G.jsx)(oM,{builder:e})})]})},lM=({builder:e})=>{let t=qy(),n=ab(t.projects.state),r=ab(t.workflows.state),i=n.status===`ready`?n.data:[],a=ab(t.builder.project),[o,s]=(0,V.useState)(``),c=a??(i.length===1?i[0]?.id:null)??null,{chooseProject:l}=e;(0,V.useEffect)(()=>{t.projects.load()},[t]),(0,V.useEffect)(()=>{c!==null&&(t.workflows.load(c),l(c))},[t,c,l]);let u=r.status===`ready`&&r.arg===c?r.data.map(({name:e})=>e):[],d=[...new Set([...u,...e.drafts])].toSorted(),f=async()=>{c!==null&&o!==``&&await e.create(c,o)&&s(``)};return(0,G.jsxs)(`div`,{className:nA.chooser,children:[(0,G.jsx)(KS,{empty:`No project matches.`,label:`Project`,onChange:e=>{t.builder.project.setValue(e)},options:i.map(({id:e})=>({value:e,label:e})),placeholder:`Type to find a project`,value:c}),(0,G.jsx)(KS,{disabled:c===null||d.length===0,empty:`No workflow matches.`,label:`Workflow`,onChange:t=>{c!==null&&t!==null&&e.open(c,t)},options:d.map(t=>({value:t,label:e.drafts.includes(t)?`${t} (draft)`:t})),placeholder:d.length===0?`None yet`:`Type to find one`,value:e.opened?.name??null}),(0,G.jsxs)(`form`,{className:nA.create,onSubmit:e=>{e.preventDefault(),f()},children:[(0,G.jsx)(Uw,{label:`New workflow`,onChange:s,value:o}),(0,G.jsx)(q,{disabled:c===null||o===``,focusableWhenDisabled:!0,type:`submit`,children:`Create`})]})]})},uM={agents:[],skills:[]},dM=e=>typeof e==`object`&&!!e&&!Array.isArray(e),fM=e=>{let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(uM),[a,o]=(0,V.useState)([]),s=(0,V.useRef)(null);(0,V.useEffect)(()=>{(async()=>{let t=await e.call(`builderSchema`);t.ok&&dM(t.data)&&n(t.data)})()},[e]);let c=(0,V.useCallback)(async t=>{let n={id:t},[r,a]=await Promise.all([e.call(`builderDrafts`,{params:n}),e.call(`builderCatalog`,{params:n})]);s.current===t&&(r.ok&&o(r.data),a.ok&&i(a.data))},[e]);return{schema:t,catalog:r,drafts:a,setDrafts:o,forProject:(0,V.useCallback)(e=>{s.current!==e&&o([]),s.current=e,c(e)},[c]),refreshDrafts:(0,V.useCallback)(()=>{s.current!==null&&c(s.current)},[c])}},pM=({project:e,name:t})=>({id:e,name:t}),mM=()=>{let{client:e,builder:t}=qy(),{inTurn:n,history:r,view:i,opened:a}=t,o=ab(a),s=ab(i),c=ab(t.selected),l=ab(r).length>0,[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),[m,h]=(0,V.useState)(null),{schema:g,catalog:_,drafts:v,setDrafts:y,refreshDrafts:b,forProject:x}=fM(e),S=(0,V.useCallback)(e=>{r.setValue(e)},[r]),C=(0,V.useCallback)(e=>{let t=a.getValue();return t?.project===e.project&&t.name===e.name},[a]),w=(0,V.useCallback)((e,n)=>{t.show(e,n),d(!1),p(null),h(null)},[t]),T=(0,V.useCallback)(e=>{x(e);let t=a.getValue();t!==null&&t.project!==e&&w(null,null)},[x,a,w]),E=(0,V.useCallback)((e,n)=>C(e)?n.ok?(t.update(n.data),p(null),!0):(p(n.error),!1):n.ok,[C,t]),D=(0,V.useCallback)((t,r)=>n(async()=>{let n={project:t,name:r},i=await e.call(`builderView`,{params:pM(n)});i.ok?w(n,i.data):p(i.error)}),[e,n,w]),O=(0,V.useCallback)((t,r)=>n(async()=>{let n=await e.call(`builderCreate`,{params:{id:t},body:{name:r}});return n.ok?(w({project:t,name:r},n.data),y(e=>[...e,r]),!0):(p(n.error),!1)}),[e,n,y,w]),k=(0,V.useCallback)(async(t,n)=>{let i=await e.call(`builderEdit`,{params:pM(t),body:{edits:n}}),a=E(t,i);return i.ok&&C(t)&&i.data.text!==i.data.previous.text&&S([...r.getValue(),i.data.previous]),a},[e,r,C,E,S]);return{opened:o,view:s,selected:c,connecting:u,refusal:f,canUndo:l,replaceAsked:m,schema:g,catalog:_,drafts:v,chooseProject:T,open:D,create:O,edit:(0,V.useCallback)((...e)=>o===null?Promise.resolve(!1):n(()=>k(o,e)),[n,o,k]),change:(0,V.useCallback)((e,t)=>o===null?Promise.resolve(!1):n(()=>{if(!C(o))return Promise.resolve(!1);let n=Yk(i.getValue()?.document,e),r=t(n);if(Xk(n,r))return Promise.resolve(!0);let a=[...e];return k(o,[r===void 0?{op:`delete`,path:a}:{op:`set`,path:a,value:r}])}),[n,C,o,k,i]),undo:(0,V.useCallback)(()=>o===null?Promise.resolve():n(async()=>{let t=r.getValue().at(-1);if(t===void 0||!C(o))return;let n=await e.call(`builderRestore`,{params:pM(o),body:t});E(o,n)&&S(r.getValue().slice(0,-1))}),[e,r,n,C,o,E,S]),discard:(0,V.useCallback)(()=>o===null?Promise.resolve():n(async()=>{let t=await e.call(`builderDiscard`,{params:pM(o)});b(),C(o)&&(t.ok?`gone`in t.data?w(null,null):w(o,t.data):p(t.error))}),[e,n,C,o,b,w]),save:(0,V.useCallback)((t=!1)=>{if(o===null)return Promise.resolve(!1);let r=pM(o);return n(async()=>{let n=await e.call(`builderSave`,{params:r,body:t?{force:!0}:{}});return n.ok?n.data.saved?(p(null),b(),C(o)&&S([]),E(o,await e.call(`builderView`,{params:r})),Hy.add({title:`Saved ${o.name}`}),!0):(n.data.why===`changed`?h(n.data.message):p(n.data.message),!1):(p(n.error),!1)})},[e,n,C,o,b,E,S]),select:t.select,setConnecting:d,setReplaceAsked:h}},hM=()=>{let e=qy(),t=mM(),{view:n,opened:r,refusal:i,connecting:a,selected:o}=t,[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(!1),d=n===null?0:Zk(n.diagnostics),f=n===null?[]:eA(n.graph),p=async()=>{await t.save()&&c(!0)},m=()=>{r!==null&&(e.workflows.load(r.project),e.runPreset.setValue({project:r.project,workflow:r.name}),e.runDialog.setValue(!0))};return(0,G.jsxs)(`div`,{className:nA.panel,children:[(0,G.jsxs)(`header`,{className:nA.tools,children:[(0,G.jsx)(lM,{builder:t}),n===null?null:(0,G.jsxs)(`div`,{className:nA.actions,children:[(0,G.jsx)(q,{disabled:!t.canUndo,focusableWhenDisabled:!0,onClick:()=>{t.undo()},children:`Undo`}),(0,G.jsx)(q,{disabled:!n.draft,focusableWhenDisabled:!0,onClick:()=>{u(!0)},children:`Discard`}),(0,G.jsx)(q,{disabled:d>0||!n.draft,focusableWhenDisabled:!0,onClick:()=>{t.save()},variant:`primary`,children:`Save`}),(0,G.jsx)(q,{disabled:d>0,focusableWhenDisabled:!0,onClick:()=>{p()},children:`Run…`})]})]}),n===null?null:(0,G.jsxs)(`div`,{className:nA.notices,children:[i===null?null:(0,G.jsx)(`p`,{className:nA.error,role:`alert`,children:(0,G.jsx)(Wg,{text:i})}),(0,G.jsx)(`output`,{className:nA.status,children:a&&o!==null?`Choose the card ${o} leads to.`:n.changedOnDisk?`The file changed since this draft began. Saving will ask before replacing it.`:n.draft?`Unsaved changes are kept as a draft.`:``})]}),(0,G.jsx)(cM,{builder:t}),(0,G.jsx)(SC,{confirm:`Discard the draft`,description:`This throws away every unsaved change, and it can't be undone.`,onConfirm:()=>{u(!1),t.discard()},onOpenChange:u,open:l,title:`Discard the draft of ${r?.name??``}?`}),(0,G.jsx)(SC,{confirm:`Replace the file`,description:`${t.replaceAsked??``} Replacing it loses what changed there.`,onConfirm:()=>{t.setReplaceAsked(null),t.save(!0)},onOpenChange:e=>{e||t.setReplaceAsked(null)},open:t.replaceAsked!==null,title:`The file changed`}),(0,G.jsx)(SC,{confirm:`Choose how to run it`,description:`This starts a real run, which can spend money and commit work.${f.length===0?``:` These nodes act outside its worktree: ${f.join(`, `)}.`}`,onConfirm:()=>{c(!1),m()},onOpenChange:c,open:s,title:`Run ${r?.name??``}?`})]})},gM=new Set([`claude.leader`,`claude.worker`]),_M=e=>{let t=new Set;for(let{event:n}of e)if(n.type===`run.started`)for(let{id:e,type:r}of n.nodes)gM.has(r)&&t.add(e);else n.type===`node.started`&&gM.has(n.nodeType)&&t.add(n.id);return[...t]},vM={now:`delivered to its session`,queued:`waits for its next session`,resumed:`resumed its session`},yM=e=>e===void 0?{}:{note:e===`script`?`a script`:`a rule`},bM=/^mcp__ork__/u,xM=new Set([`StructuredOutput`]),SM=(e,t)=>e.type===`assistant.text`?{...t,kind:`node`,text:e.text}:e.type===`tool.called`?xM.has(e.name)?void 0:{...t,kind:`activity`,text:`Used ${e.name.replace(bM,``)}`}:e.type===`session.started`?{...t,kind:`activity`,text:`Session on ${e.model}`}:void 0,CM=({seq:e,at:t,event:n},r)=>{let i={seq:e,at:t},a=e=>({...i,kind:`activity`,text:e});if(n.type===`node.event`)return n.id===r?n.event.fork===!0?n.event.type===`session.started`?a(`A fork took a child's question`):void 0:SM(n.event,i):void 0;if(n.type===`node.finished`){if(n.id!==r)return;let{summary:e}=n.output;if(n.ok&&typeof e==`string`)return{...i,kind:`node`,text:e,note:`its report`};let t=n.error===void 0?``:`: ${n.error}`;return a(n.ok?`Finished.`:`Failed${t}`)}if(n.type===`message.sent`&&n.to===r)return{...i,kind:`peer`,from:n.node,text:n.body,...yM(n.via)};if(`node`in n&&n.node===r){if(n.type===`user.message`)return{...i,kind:`you`,text:n.body,note:vM[n.delivered]};if(n.type===`message.sent`)return a(n.via===`rule`?`A rule wrote to ${n.to}: ${n.body}`:`Wrote to ${n.to}: ${n.body}`);if(n.type===`message.received`)return{...i,kind:`peer`,from:n.from,text:n.body,...yM(n.via)};if(n.type===`decision.opened`)return a(`Asked you: ${n.question}`);if(n.type===`decision.answered`)return a(n.note===void 0?`You answered: ${n.answer}`:`You answered: ${n.answer}. You said: ${n.note}`)}},wM=(e,t)=>e.flatMap(e=>CM(e,t)??[]),TM=({live:e})=>e===`running`?null:e===`paused`?`The run is paused. Continue it to write to this node.`:`The run has ended (${e}). To resume this node's session, use:`,EM=(e,t)=>`ork chat ${e} ${t}`,DM={panel:`_panel_s0gbu_7`,tools:`_tools_s0gbu_23`,main:`_main_s0gbu_33`,thread:`_thread_s0gbu_46`,items:`_items_s0gbu_62`,message:`_message_s0gbu_73`,meta:`_meta_s0gbu_81`,speaker:`_speaker_s0gbu_91`,time:`_time_s0gbu_101`,note:`_note_s0gbu_102`,text:`_text_s0gbu_112`,activity:`_activity_s0gbu_118`,activityText:`_activityText_s0gbu_131`,composer:`_composer_s0gbu_136`,box:`_box_s0gbu_156`,labelRow:`_labelRow_s0gbu_179`,send:`_send_s0gbu_189`,hint:`_hint_s0gbu_197`,why:`_why_s0gbu_198`,refusal:`_refusal_s0gbu_207`},OM=({run:e,node:t})=>{let n=qy(),r=(0,V.useId)(),i=(0,V.useId)(),[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),d=TM(e),f=EM(e.id,t),p=(0,V.useRef)(!1),m=(0,V.useRef)(null);(0,V.useEffect)(()=>{d!==null&&p.current&&(p.current=!1,m.current?.focus())},[d]);let h=async()=>{if(s||a.trim()===``)return;c(!0),u(null);let r=await n.sendMessage(e.id,t,a);c(!1),r.ok?o(``):u(r.error)};return d===null?(0,G.jsxs)(`form`,{className:DM.composer,onSubmit:e=>{e.preventDefault(),h()},children:[(0,G.jsxs)(`div`,{className:DM.labelRow,children:[(0,G.jsxs)(`label`,{className:US.label,htmlFor:r,children:[`Message to `,t]}),(0,G.jsx)(`span`,{className:DM.hint,id:i,children:`Enter sends, Shift+Enter starts a new line.`})]}),(0,G.jsxs)(`div`,{className:DM.send,children:[(0,G.jsx)(`textarea`,{"aria-describedby":i,className:DM.box,id:r,onBlur:()=>{p.current=!1},onChange:e=>{o(e.target.value)},onFocus:()=>{p.current=!0},onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),h())},rows:1,value:a}),(0,G.jsx)(q,{cli:`${f} -m …`,disabled:s||a.trim()===``,focusableWhenDisabled:!0,type:`submit`,variant:`primary`,children:s?`Sending…`:`Send`})]}),l===null?null:(0,G.jsx)(`p`,{className:DM.refusal,role:`alert`,children:(0,G.jsx)(Wg,{text:l})})]}):(0,G.jsxs)(`div`,{"aria-describedby":r,"aria-label":`Message to ${t}`,className:DM.composer,ref:m,role:`group`,tabIndex:-1,children:[(0,G.jsx)(`p`,{className:DM.why,id:r,children:(0,G.jsx)(Wg,{text:d})}),e.live===`paused`?null:(0,G.jsx)(YS,{command:f})]})},kM=e=>`id`in e?e.id:`node`in e?e.node:`from`in e?e.from:void 0,AM=e=>e.replaceAll(/\s+/gu,` `).trim(),jM=e=>e===void 0?``:` (${e})`,MM=({event:e})=>{switch(e.type){case`session.started`:return`session on ${e.model}`;case`assistant.text`:return AM(e.text);case`tool.called`:return`${e.name} ${AM(JSON.stringify(e.input))}`;case`tool.result`:return e.isError?`tool failed`:`tool done`;case`plan.limit`:return e.status===`allowed`?``:`plan: ${e.window.replaceAll(`_`,` `)} limit ${e.status===`rejected`?`reached`:`is close`}`;case`session.finished`:return`session finished`;default:return``}},NM=e=>{let t=MM(e);return e.event.fork===!0&&t!==``?`fork: ${t}`:t},PM=({ok:e,error:t,round:n,output:r})=>{let{summary:i}=r,a=typeof i==`string`?`: ${AM(i)}`:``,o=e?`ok${a}`:`failed${t===void 0?``:`: ${AM(t)}`}`;return n>1?`round ${String(n)}: ${o}`:o},FM=e=>{switch(e.type){case`run.started`:return`${e.workflow}, ${String(e.nodes.length)} nodes`;case`run.resumed`:return`keeps ${String(e.kept.length)} nodes`;case`run.command`:return e.node===void 0?e.command:`${e.command} ${e.node}`;case`run.finished`:return e.result.status;case`node.started`:return e.round>1?`${e.nodeType}, round ${String(e.round)}`:e.nodeType;case`node.event`:return NM(e);case`node.finished`:return PM(e);case`edge.taken`:return`${e.from} -> ${e.to}`;case`loop.exhausted`:return`${e.from} -> ${e.to} after ${String(e.maxRounds)} rounds`;case`watch.started`:return`until ${e.until}, every ${e.every}`;case`watch.changed`:return`look ${String(e.looks)}: ${e.said}`;case`watch.ended`:return`${e.outcome} after ${String(e.looks)} looks`;case`worktree`:return`${e.action} ${e.branch??e.path}`;case`decision.opened`:return AM(e.question);case`decision.answered`:{let t=e.note===void 0?``:`; said: ${AM(e.note)}`;return`${e.answer}, by ${e.by}${t}`}case`message.sent`:return`to ${e.to}${jM(e.via)}: ${AM(e.body)}`;case`message.received`:return`from ${e.from}${jM(e.via)}: ${AM(e.body)}`;case`call.started`:return`${e.workflow} as ${e.run}`;case`link.notice`:return AM(e.text);case`owner.asked`:return`about ${e.about}: ${AM(e.text)}`;case`owner.answered`:return e.answer;case`user.message`:return`${e.delivered}: ${AM(e.body)}`;case`claim.taken`:return e.resource;case`claim.refused`:return`${e.resource}: ${e.holder} holds ${e.held}`;case`claim.released`:return`${e.resource}, ${e.reason}`;case`feedback.recorded`:return AM(e.feedback.title);case`message.read`:return`${String(e.ids.length)} messages`;case`decision.withdrawn`:case`node.held`:case`node.released`:case`node.skipped`:case`owner.unanswered`:return``;default:return``}},IM=new WeakMap,LM=e=>{let t=IM.get(e);if(t!==void 0)return t;let n=JSON.stringify(e.event).toLowerCase();return IM.set(e,n),n},RM=(e,{node:t,type:n,text:r})=>{let i=r.trim().toLowerCase();return t===null&&n===null&&i===``?e:e.filter(e=>(t===null||kM(e.event)===t)&&(n===null||e.event.type===n)&&(i===``||LM(e).includes(i)))},zM=e=>[...new Set(e)].toSorted((e,t)=>e.localeCompare(t)),BM=(e,t)=>zM([...e.flatMap(({event:e})=>kM(e)??[]),...t===null?[]:[t]]),VM=e=>zM(e.map(({event:e})=>e.type)),HM=(e,t,n)=>`${e===t?`${String(e)} events`:`${String(e)} of ${String(t)} loaded`}${n>t?`, ${String(n)} in the run`:``}`,UM=(e,t)=>`ork logs ${e}${t===null?``:` --node ${t}`} --follow`,WM=e=>new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),GM=32,KM=({kind:e,from:t},n)=>e===`you`?`You`:e===`node`?n:t??``,qM=(0,V.memo)(({item:e,node:t})=>e.kind===`activity`?(0,G.jsxs)(`li`,{className:DM.activity,children:[(0,G.jsx)(`span`,{className:DM.activityText,children:e.text}),(0,G.jsx)(`span`,{className:DM.time,children:WM(e.at)})]}):(0,G.jsxs)(`li`,{className:DM.message,"data-kind":e.kind,children:[(0,G.jsxs)(`p`,{className:DM.meta,children:[(0,G.jsx)(`span`,{className:DM.speaker,children:KM(e,t)}),(0,G.jsx)(`span`,{className:DM.time,children:WM(e.at)}),e.note===void 0?null:(0,G.jsx)(`span`,{className:DM.note,children:e.note})]}),(0,G.jsx)(`p`,{className:DM.text,children:e.text})]}));qM.displayName=`ThreadRow`;var JM=({items:e,node:t})=>{let n=(0,V.useRef)(null),r=(0,V.useRef)(!0);return(0,V.useLayoutEffect)(()=>{let e=n.current;e!==null&&r.current&&(e.scrollTop=e.scrollHeight)}),(0,V.useEffect)(()=>{let e=n.current,t=new ResizeObserver(()=>{e!==null&&r.current&&(e.scrollTop=e.scrollHeight)});return e!==null&&t.observe(e),()=>{t.disconnect()}},[]),(0,G.jsx)(`div`,{"aria-label":`Conversation with ${t}`,className:DM.thread,onScroll:e=>{let{scrollHeight:t,scrollTop:n,clientHeight:i}=e.currentTarget;r.current=t-n-i<GM},ref:n,role:`log`,tabIndex:0,children:(0,G.jsx)(`ol`,{className:DM.items,children:e.map(e=>(0,G.jsx)(qM,{item:e,node:t},e.seq))})})},YM=({run:e,selected:t})=>{let n=qy(),r=(0,V.useMemo)(()=>n.feedOf(e.id),[n,e.id]);(0,V.useEffect)(()=>n.retainRun(e.id),[n,e.id]);let{events:i,tail:a,following:o,link:s}=ab(r.state),c=o?i:a,l=(0,V.useMemo)(()=>_M(i),[i]),u=t!==null&&l.includes(t)?t:l[0]??null,d=(0,V.useMemo)(()=>u===null?[]:wM(c,u),[c,u]);return u===null?(0,G.jsx)(CC,{title:s===`loading`&&i.length===0?`Reading the run…`:`This run has no one to talk to.`,children:`Only leaders and workers have sessions.`}):(0,G.jsxs)(`div`,{className:DM.panel,children:[(0,G.jsx)(`div`,{className:DM.tools,children:(0,G.jsx)(KS,{empty:`No node matches.`,label:`Node`,onChange:n.selectNode,options:l.map(e=>({value:e,label:e})),value:u})}),(0,G.jsx)(`div`,{className:DM.main,children:d.length===0?(0,G.jsx)(CC,{title:`Nothing from ${u} yet.`,children:`What it says and what you write show here.`}):(0,G.jsx)(JM,{items:d,node:u},u)}),(0,G.jsx)(OM,{node:u,run:e},`${e.id}/${u}`)]})},XM=()=>{let e=qy(),{run:t,node:n}=ab(e.selection),r=ab(e.runs)?.find(({id:e})=>e===t);return r===void 0?(0,G.jsx)(CC,{cli:`ork chat <run> <node>`,title:`No run chosen.`,children:`Choose one in the Runs panel, or in a terminal:`}):(0,G.jsx)(YM,{run:r,selected:n},r.id)},ZM=(0,V.createContext)(null),QM=({id:e,label:t})=>t??e,$M=({id:e,runId:t},n,r=``)=>{let i=r.trim()===``?``:` --say ${sT(r.trim())}`;return`ork decide ${t} --id ${e} --choose ${n?.id??`<option>`}${i}`},eN={terminal:`in the run's terminal`,decide:"with `ork decide`",ui:"in `ork ui`",owner:`by its owner`},tN=({status:e,options:t,answer:n,answeredBy:r,owner:i})=>{if(e===`withdrawn`)return`Withdrawn: it no longer needs an answer.`;if(e===`open`)return`Its run ended before it was answered.`;let a=t.find(({id:e})=>e===n),o=a===void 0?n??``:QM(a);if(r===`owner`&&i!==void 0)return`Answered ${o} by \`${i}\`, its owner.`;let s=i===void 0?``:`, after \`${i}\` passed it on`;return r===void 0?`Answered ${o}${s}.`:`Answered ${o} ${eN[r]}${s}.`},nN=({note:e})=>e===void 0?void 0:`They said: ${e}`,rN=(e,t)=>/^[1-9]$/u.test(t)?e[Number(t)-1]:void 0,iN=e=>(t,n)=>`${n===1?`Copy code`:`Copy code block ${t} of ${n}`} (${e})`,aN=({runId:e,id:t})=>`ork decide ${e} --id ${t} --document`,oN=e=>e.startsWith(`{
|
|
59
|
+
`),sN={value:` all`,label:``},cN=(e,t,n,r)=>{let i=new Map;for(let n of e){let e=t(n);e!==void 0&&i.set(e,(i.get(e)??0)+1)}let a=[...i];return(r?a.toSorted(([e],[t])=>e.localeCompare(t)):a).map(([e,t])=>({value:e,label:n(e,t)}))},lN=(e,{workflow:t,run:n},r)=>({...e.some(({runId:e})=>r(e)===t)&&t!==void 0?{workflow:t}:{},...e.some(({runId:e})=>e===n)&&n!==void 0?{run:n}:{}}),uN=(e,t)=>t===void 0||e.some(({value:e})=>e===t)?e:[...e,{value:t,label:`${t} (0)`}],dN=(e,{workflow:t,run:n},r)=>{let i=e.filter(({runId:e})=>t===void 0||r(e)===t);return{workflows:[{...sN,label:`All (${e.length})`},...uN(cN(e,({runId:e})=>r(e),(e,t)=>`${e} (${t})`,!0),t)],runs:[{...sN,label:`All (${i.length})`},...uN(cN(i,({runId:e})=>e,(e,t)=>{let n=r(e);return`${e}${n===void 0?``:` · ${n}`} (${t})`},!1),n)],shown:i.filter(({runId:e})=>n===void 0||e===n),active:{...t===void 0?{}:{workflow:t},...n===void 0?{}:{run:n}}}},fN=(e,t)=>t===e?e===1?`1 open decision.`:`${e} open decisions.`:`${t} of ${e} open decisions shown; ${e-t} hidden by the filter.`,pN=({workflow:e,run:t})=>e!==void 0||t!==void 0,mN=({workflow:e,run:t})=>t===void 0?`ork decide --list${e===void 0?``:` --workflow ${e}`}`:`ork decide ${t} --list`,hN={panel:`_panel_10bhv_6`,list:`_list_10bhv_22`,card:`_card_10bhv_27`,fromText:`_fromText_10bhv_43`,from:`_from_10bhv_43`,read:`_read_10bhv_69`,length:`_length_10bhv_79`,document:`_document_10bhv_90`,filter:`_filter_10bhv_120`,filterFields:`_filterFields_10bhv_134`,counts:`_counts_10bhv_145`,options:`_options_10bhv_154`,option:`_option_10bhv_154`,optionText:`_optionText_10bhv_207`,optionMark:`_optionMark_10bhv_217`,optionLabel:`_optionLabel_10bhv_231`,optionDescription:`_optionDescription_10bhv_238`,refusal:`_refusal_10bhv_247`,settled:`_settled_10bhv_255`,settledTitle:`_settledTitle_10bhv_265`,settledList:`_settledList_10bhv_282`,settledQuestion:`_settledQuestion_10bhv_303`,settledEnding:`_settledEnding_10bhv_307`,settledNote:`_settledNote_10bhv_317`},gN=({decision:e,note:t,onNote:n,sending:r,onChoose:i})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Uw,{description:`It goes with the option you choose; a gate passes it on as its note.`,label:`Note for the run (optional)`,multiline:!0,onChange:n,rows:2,value:t}),t.trim()===``?null:(0,G.jsx)(YS,{command:$M(e,void 0,t)}),(0,G.jsx)(`ul`,{className:hN.options,children:e.options.map((n,a)=>{let o=n.id===e.recommended,s=$M(e,n,t),c=a<9?String(a+1):void 0;return(0,G.jsx)(`li`,{children:(0,G.jsx)(Zg,{cli:s,children:(0,G.jsxs)(`button`,{...Xg(s),"aria-disabled":r?`true`:void 0,"aria-keyshortcuts":c,className:hN.option,"data-option":``,"data-recommended":o?``:void 0,onClick:()=>{i(n)},type:`button`,children:[c===void 0?null:(0,G.jsx)(Kg,{keys:[c]}),(0,G.jsxs)(`span`,{className:hN.optionText,children:[(0,G.jsx)(`span`,{className:hN.optionLabel,children:QM(n)}),n.description===void 0?null:(0,G.jsx)(`span`,{className:hN.optionDescription,children:n.description})]}),o?(0,G.jsx)(`span`,{className:hN.optionMark,children:`recommended`}):null]})})},n.id)})})]}),_N={};function vN(e,t){let n=t||_N;return yN(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function yN(e,t,n){if(xN(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 bN(e.children,t,n)}return Array.isArray(e)?bN(e,t,n):``}function bN(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=yN(e[i],t,n);return r.join(``)}function xN(e){return!!(e&&typeof e==`object`)}var SN=document.createElement(`i`);function CN(e){let t=`&`+e+`;`;SN.innerHTML=t;let n=SN.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function wN(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 TN(e,t){return e.length>0?(wN(e,e.length,0,t),e):t}var EN={}.hasOwnProperty;function DN(e){let t={},n=-1;for(;++n<e.length;)ON(t,e[n]);return t}function ON(e,t){let n;for(n in t){let r=(EN.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){EN.call(r,a)||(r[a]=[]);let e=i[a];kN(r[a],Array.isArray(e)?e:e?[e]:[])}}}function kN(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);wN(e,0,0,r)}function AN(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 jN(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var MN=WN(/[A-Za-z]/),NN=WN(/[\dA-Za-z]/),PN=WN(/[#-'*+\--9=?A-Z^-~]/);function FN(e){return e!==null&&(e<32||e===127)}var IN=WN(/\d/),LN=WN(/[\dA-Fa-f]/),RN=WN(/[!-/:-@[-`{-~]/);function zN(e){return e!==null&&e<-2}function BN(e){return e!==null&&(e<0||e===32)}function VN(e){return e===-2||e===-1||e===32}var HN=WN(/\p{P}|\p{S}/u),UN=WN(/\s/);function WN(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function GN(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return VN(r)?(e.enter(n),s(r)):t(r)}function s(r){return VN(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function KN(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&VN(t)?(e.enter(r),c(t)):l(t)}function c(t){return VN(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var qN={tokenize:JN};function JN(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null)e.consume(n);else return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),GN(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);else return zN(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var YN=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){XN(this,e,t,n,!1)}addBefore(e,t,n){XN(this,e,t,n,!0)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function XN(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var ZN={tokenize:$N},QN={tokenize:eP};function $N(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++;let c=new YN;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),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(QN,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(QN,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);else 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);else return zN(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++;let l=new YN;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}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 eP(e,t,n){return GN(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function tP(e){if(e===null||BN(e)||UN(e))return 1;if(HN(e))return 2}function nP(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 rP={name:`attention`,resolveAll:iP,tokenize:aP};function iP(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};oP(o,-a),oP(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=TN(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=TN(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=TN(r,nP(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=TN(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=TN(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),wN(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function aP(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=tP(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=tP(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function oP(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var sP={name:`autolink`,tokenize:cP};function cP(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 MN(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||NN(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||NN(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||FN(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):PN(t)?(e.consume(t),l):n(t)}function u(e){return NN(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||NN(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var lP={partial:!0,tokenize:uP};function uP(e,t,n){return r;function r(t){return VN(t)?GN(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||zN(e)?t(e):n(e)}}var dP={continuation:{tokenize:pP},exit:mP,name:`blockQuote`,tokenize:fP};function fP(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 VN(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function pP(e,t,n){let r=this;return i;function i(t){return VN(t)?GN(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(dP,t,n)(r)}}function mP(e){e.exit(`blockQuote`)}var hP={name:`characterEscape`,tokenize:gP};function gP(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 RN(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var _P={name:`characterReference`,tokenize:vP};function vP(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=NN,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=LN,u):(e.enter(`characterReferenceValue`),a=7,o=IN,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===NN&&!CN(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 yP={partial:!0,tokenize:bP};function bP(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 xP={concrete:!0,name:`codeFenced`,tokenize:SP};function SP(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`),VN(t)?GN(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||zN(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(yP,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||zN(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):VN(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),GN(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||zN(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||zN(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&&VN(t)?GN(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||zN(t)?e.check(yP,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||zN(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`),VN(t)?GN(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`),VN(t)?GN(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||zN(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var CP={name:`codeIndented`,tokenize:TP},wP={partial:!0,tokenize:EP};function TP(e,t,n){return r;function r(t){return e.enter(`codeIndented`),KN(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):zN(t)?e.attempt(wP,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||zN(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function EP(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):zN(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):KN(e,t,a,`linePrefix`,4,4)(o)}function a(e){return zN(e)?i(e):n(e)}}var DP={name:`codeText`,previous:kP,resolve:OP,tokenize:AP};function OP(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 kP(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function AP(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)):zN(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||zN(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 jP=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&&MP(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),MP(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),MP(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);MP(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);MP(this.left,t.reverse())}}}};function MP(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 NP(e){let t={},n=-1,r,i,a,o,s,c,l,u=new jP(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,PP(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 wN(e,0,1/0,u.slice(0)),!l}function PP(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 FP={resolve:LP,tokenize:RP},IP={partial:!0,tokenize:zP};function LP(e){return NP(e),e}function RP(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):zN(t)?e.check(IP,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 zP(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),GN(e,a,`linePrefix`)}function a(i){if(i===null||zN(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 BP(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||FN(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||zN(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||BN(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||FN(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 VP(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):zN(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||zN(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!VN(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function HP(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):zN(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),GN(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||zN(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 UP(e,t){let n;return r;function r(i){return zN(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):VN(i)?GN(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var WP={name:`definition`,tokenize:KP},GP={partial:!0,tokenize:qP};function KP(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return VP.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=jN(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 BN(t)?UP(e,l)(t):l(t)}function l(t){return BP(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(GP,d,d)(t)}function d(t){return VN(t)?GN(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||zN(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function qP(e,t,n){return r;function r(t){return BN(t)?UP(e,i)(t):n(t)}function i(t){return HP(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return VN(t)?GN(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||zN(e)?t(e):n(e)}}var JP={name:`hardBreakEscape`,tokenize:YP};function YP(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return zN(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var XP={name:`headingAtx`,resolve:ZP,tokenize:QP};function ZP(e,t){let n=e.length-2,r=3;if(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){let 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`};wN(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function QP(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||BN(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||zN(n)?(e.exit(`atxHeading`),t(n)):VN(n)?GN(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||BN(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var $P=`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(`.`),eF=[`pre`,`script`,`style`,`textarea`],tF={concrete:!0,name:`htmlFlow`,resolveTo:rF,tokenize:iF},nF={partial:!0,tokenize:aF};function rF(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 iF(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:I):MN(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):MN(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):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 MN(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||BN(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&eF.includes(l)?(i=1,r.interrupt?t(s):O(s)):$P.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||NN(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 VN(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||MN(t)?(e.consume(t),b):VN(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||NN(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):VN(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):VN(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||zN(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||BN(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||VN(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||zN(t)?O(t):VN(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):zN(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(nF,R,k)(t)):t===null||zN(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(yP,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||zN(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return eF.includes(n)?(e.consume(t),L):O(t)}return MN(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||zN(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function aF(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(lP,t,n)}}var oF={name:`htmlText`,tokenize:sF};function sF(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):MN(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):MN(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):zN(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(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):zN(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):zN(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):zN(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return MN(t)?(e.consume(t),S):n(t)}function S(t){return t===45||NN(t)?(e.consume(t),S):C(t)}function C(t){return zN(t)?(o=C,N(t)):VN(t)?(e.consume(t),C):M(t)}function w(t){return t===45||NN(t)?(e.consume(t),w):t===47||t===62||BN(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||MN(t)?(e.consume(t),E):zN(t)?(o=T,N(t)):VN(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||NN(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):zN(t)?(o=D,N(t)):VN(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):zN(t)?(o=O,N(t)):VN(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):zN(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||BN(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||BN(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return VN(t)?GN(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var cF={name:`labelEnd`,resolveAll:fF,resolveTo:pF,tokenize:mF},lF={tokenize:hF},uF={tokenize:gF},dF={tokenize:_F};function fF(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&&wN(e,0,e.length,n),e}function pF(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=TN(o,e.slice(i+1,i+r+3)),o=TN(o,[[`enter`,l,t]]),o=TN(o,nP(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=TN(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=TN(o,e.slice(a+1)),o=TN(o,[[`exit`,s,t]]),wN(e,i,e.length,o),e}function mF(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(jN(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(lF,u,o?u:d)(t):t===91?e.attempt(uF,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(dF,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function hF(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 BN(t)?UP(e,a)(t):a(t)}function a(t){return t===41?u(t):BP(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return BN(t)?UP(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?HP(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return BN(t)?UP(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 gF(e,t,n){let r=this;return i;function i(t){return VP.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(jN(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function _F(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 vF={name:`labelStartImage`,resolveAll:cF.resolveAll,tokenize:yF};function yF(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var bF={name:`labelStartLink`,resolveAll:cF.resolveAll,tokenize:xF};function xF(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var SF={name:`lineEnding`,tokenize:CF};function CF(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),GN(e,t,`linePrefix`)}}var wF={name:`thematicBreak`,tokenize:TF};function TF(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||zN(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),VN(t)?GN(e,s,`whitespace`)(t):s(t))}}var EF={continuation:{tokenize:AF},exit:MF,name:`list`,tokenize:kF},DF={partial:!0,tokenize:NF},OF={partial:!0,tokenize:jF};function kF(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:IN(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(wF,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 IN(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(lP,r.interrupt?n:u,e.attempt(DF,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return VN(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 AF(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(lP,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,GN(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!VN(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(OF,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,GN(e,e.attempt(EF,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function jF(e,t,n){let r=this;return GN(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 MF(e){e.exit(this.containerState.type)}function NF(e,t,n){let r=this;return GN(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!VN(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var PF={name:`setextUnderline`,resolveTo:FF,tokenize:IF};function FF(e,t){let n=new YN,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function IF(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`),VN(t)?GN(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||zN(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var LF={tokenize:RF};function RF(e){let t=this,n=e.attempt(lP,r,e.attempt(this.parser.constructs.flowInitial,i,GN(e,e.attempt(this.parser.constructs.flow,i,e.attempt(FP,i)),`linePrefix`)));return n;function r(r){if(r===null)e.consume(r);else return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null)e.consume(r);else return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var zF={resolveAll:UF()},BF=HF(`string`),VF=HF(`text`);function HF(e){return{resolveAll:UF(e===`text`?WF: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);else 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 UF(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 WF(e,t){let n=new YN,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var GF=M({attentionMarkers:()=>$F,contentInitial:()=>qF,disable:()=>eI,document:()=>KF,flow:()=>YF,flowInitial:()=>JF,insideSpan:()=>QF,string:()=>XF,text:()=>ZF}),KF={42:EF,43:EF,45:EF,48:EF,49:EF,50:EF,51:EF,52:EF,53:EF,54:EF,55:EF,56:EF,57:EF,62:dP},qF={91:WP},JF={[-2]:CP,[-1]:CP,32:CP},YF={35:XP,42:wF,45:[PF,wF],60:tF,61:PF,95:wF,96:xP,126:xP},XF={38:_P,92:hP},ZF={[-5]:SF,[-4]:SF,[-3]:SF,33:vF,38:_P,42:rP,60:[sP,oF],91:bF,92:[JP,hP],93:cF,95:rP,96:DP},QF={null:[rP,zF]},$F={null:[42,95]},eI={null:[]};function tI(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=TN(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=nP(a,l.events,l),l.events):[]}function f(e,t){return rI(p(e),t)}function p(e){return nI(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(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){zN(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&&wN(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 nI(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 rI(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=`
|
|
60
|
+
`;break;case-3:o=`\r
|
|
61
|
+
`;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 iI(e){let t={constructs:DN([GF,...(e||{}).extensions||[]]),content:n(qN),defined:[],document:n(ZN),flow:n(LF),lazy:{},string:n(BF),text:n(VF)};return t;function n(e){return n;function n(n){return tI(t,e,n)}}}function aI(e){for(;!NP(e););return e}var oI=/[\0\t\n\r]/g;function sI(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&=(i.charCodeAt(0)===65279&&c++,void 0);c<i.length;){oI.lastIndex=c;let n=oI.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var cI=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function lI(e){return e.replace(cI,uI)}function uI(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return AN(n.slice(t?2:1),t?16:10)}return CN(n)||e}function dI(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?pI(e.position):`start`in e||`end`in e?pI(e):`line`in e||`column`in e?fI(e):``}function fI(e){return mI(e&&e.line)+`:`+mI(e&&e.column)}function pI(e){return fI(e&&e.start)+`-`+fI(e&&e.end)}function mI(e){return e&&typeof e==`number`?e:1}var hI={}.hasOwnProperty;function gI(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),_I(n)(aI(iI(n).document().write(sI()(e,t,!0))))}function _I(e){let t={afterExit:[],beforeEnter:[],transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:o(ge),autolinkProtocol:E,autolinkEmail:E,atxHeading:o(fe),blockQuote:o(se),characterEscape:E,characterReference:E,codeFenced:o(ce),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(ce,s),codeText:o(le,s),codeTextData:E,data:E,codeFlowValue:E,definition:o(ue),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(de),hardBreakEscape:o(pe),hardBreakTrailing:o(pe),htmlFlow:o(me,s),htmlFlowData:E,htmlText:o(me,s),htmlTextData:E,image:o(he),label:s,link:o(ge),listItem:o(ve),listItemValue:p,listOrdered:o(_e,f),listUnordered:o(_e),paragraph:o(ye),reference:z,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(fe),strong:o(be),thematicBreak:o(xe)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:oe,autolinkProtocol:ae,blockQuote:l(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:ne,characterReferenceMarkerNumeric:ne,characterReferenceValue:re,characterReference:ie,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:D,codeIndented:l(v),codeText:l(M),codeTextData:D,data:D,definition:l(),definitionDestinationString:x,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(k),hardBreakTrailing:l(k),htmlFlow:l(A),htmlFlowData:D,htmlText:l(j),htmlTextData:D,image:l(P),label:I,labelText:F,lineEnding:O,link:l(N),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:te,resourceDestinationString:L,resourceTitleString:R,resource:ee,setextHeading:l(T),setextHeadingLineSequence:w,setextHeadingText:C,strong:l(),thematicBreak:l()}};yI(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[],position:void 0},o={stack:[r],tokenStack:[],config:t,enter:c,exit:u,buffer:s,resume:d,data:n},l=[],f=[],p=-1;for(;++p<e.length;)f.push(e[p]),(e[p][1].type===`listOrdered`||e[p][1].type===`listUnordered`)&&(e[p][0]===`enter`?l.push(f.length-1):a(f,l.pop()));for(e=f,p=-1;++p<e.length;){let n=t[e[p][0]];e[p][0]===`enter`&&t.beforeEnter.length>0&&i(t.beforeEnter,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),hI.call(n,e[p][1].type)&&n[e[p][1].type].call({...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),e[p][0]===`exit`&&t.afterExit.length>0&&i(t.afterExit,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||xI).call(o,void 0,e[0])}for(r.position={start:vI(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:vI(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},p=-1;++p<t.transforms.length;)r=t.transforms[p](r)||r;return r}function i(e,t,n){let r=-1;for(;++r<e.length;)e[r].call(t,n)}function a(e,t){let n=e.length-1,r=t-1,i=-1,a=!1,o,s,c,l,u=[];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 n=r;for(s=void 0;n--;){let t=e[n];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=n}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),u.push({at:s||r,event:[`exit`,o,t[2]]})}if(t[1].type===`listItemPrefix`){let e={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=e,u.push({at:r,event:[`enter`,e,t[2]]}),c=void 0,l=!0}}}let d=e.splice(t),f=0;for(r=-1;++r<d.length;){for(;f<u.length&&u[f].at===t+r;)e.push(u[f++].event);e.push(d[r])}e[t][1]._spread=a}function o(e,t){return n;function n(n){c.call(this,e(n),n),t&&t.call(this,n)}}function s(){this.stack.push({type:`fragment`,children:[]})}function c(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:vI(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),u.call(this,t)}}function u(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw Error("Cannot close `"+e.type+"` ("+dI({start:e.start,end:e.end})+`): it’s not open`);r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||xI).call(this,e,r[0])),n.position.end=vI(e.end)}function d(){return vN(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(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 m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function h(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){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 v(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function y(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=jN(this.sliceSerialize(e)).toLowerCase()}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function x(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function S(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function C(){this.data.setextHeadingSlurpLineEnding=!0}function w(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function E(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&n.type===`text`||(n=B(),n.position={start:vI(e.start),end:void 0},t.push(n)),this.stack.push(n)}function D(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=vI(e.end)}function O(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=vI(e.end),this.data.atHardBreak=void 0}else!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(E.call(this,e),D.call(this,e))}function k(){this.data.atHardBreak=!0}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function N(){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 P(){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 F(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=lI(t),n.identifier=jN(t).toLowerCase()}function I(){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 L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function R(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ee(){this.data.inReference=void 0}function z(){this.data.referenceType=`collapsed`}function te(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=jN(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ne(e){this.data.characterReferenceType=e.type}function re(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=AN(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=CN(t);let i=this.stack[this.stack.length-1];i.value+=r}function ie(e){let t=this.stack.pop();t.position.end=vI(e.end)}function ae(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function oe(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function se(){return{type:`blockquote`,children:[],position:void 0}}function ce(){return{type:`code`,lang:null,meta:null,value:``,position:void 0}}function le(){return{type:`inlineCode`,value:``,position:void 0}}function ue(){return{type:`definition`,identifier:``,label:null,title:null,url:``,position:void 0}}function de(){return{type:`emphasis`,children:[],position:void 0}}function fe(){return{type:`heading`,depth:0,children:[],position:void 0}}function pe(){return{type:`break`,position:void 0}}function me(){return{type:`html`,value:``,position:void 0}}function he(){return{type:`image`,title:null,url:``,alt:null,position:void 0}}function ge(){return{type:`link`,title:null,url:``,children:[],position:void 0}}function _e(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[],position:void 0}}function ve(e){return{type:`listItem`,spread:e._spread,checked:null,children:[],position:void 0}}function ye(){return{type:`paragraph`,children:[],position:void 0}}function be(){return{type:`strong`,children:[],position:void 0}}function B(){return{type:`text`,value:``,position:void 0}}function xe(){return{type:`thematicBreak`,position:void 0}}}function vI(e){return{line:e.line,column:e.column,offset:e.offset}}function yI(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?yI(e,r):bI(e,r)}}function bI(e,t){let n;for(n in t)if(hI.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`afterExit`:case`beforeEnter`:{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 xI(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+dI({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+dI({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+dI({start:t.start,end:t.end})+`) is still open`)}var SI=new Set([`http:`,`https:`,`mailto:`]),CI=e=>{try{return SI.has(new URL(e).protocol)}catch{return!1}},wI=50,TI=e=>{let t=0,n=[{node:e,depth:0}];for(let e=n.pop();e!==void 0;e=n.pop())if(t=Math.max(t,e.depth),`children`in e.node)for(let t of e.node.children)n.push({node:t,depth:e.depth+1});return t},EI=e=>{let t=gI(e);if(TI(t)>wI)throw RangeError(`Nested too deep`);return t},DI=e=>e.type===`break`?`
|
|
62
|
+
`:e.type===`image`||e.type===`imageReference`?e.alt??``:`value`in e?e.value:`children`in e?e.children.map(DI).join(``):``,OI=[`root`,`blockquote`,`listItem`],kI=e=>`children`in e?e.children.reduce((t,n)=>t+(n.type===`code`||n.type===`html`&&OI.includes(e.type)?1:0)+kI(n),0):0,AI=(e,t=120)=>{let n=e=>{let n=e.trim();return n.length>t?`${n.slice(0,t-1)}…`:n};try{return n(DI(EI(e).children.find(e=>DI(e).trim()!==``)??{type:`text`,value:``}).split(`
|
|
63
|
+
`).find(e=>e.trim()!==``)??``)}catch{return n(e.split(`
|
|
64
|
+
`).find(e=>e.trim()!==``)??``)}},jI=e=>e===``?0:e.replace(/\n+$/u,``).split(`
|
|
65
|
+
`).length,MI={markdown:`_markdown_q1zph_9`,inline:`_inline_q1zph_94`,target:`_target_q1zph_103`,link:`_link_q1zph_108`,image:`_image_q1zph_113`,note:`_note_q1zph_117`,written:`_written_q1zph_122`},NI=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],PI=(e,t)=>t===1?`Copy code`:`Copy code block ${e} of ${t}`,FI=e=>String(e.position?.start.offset),II=(e,t)=>{let n=0;return e.split(`
|
|
66
|
+
`).flatMap((e,r)=>{let i=`${t}:${n}`;return n+=e.length+1,r===0?[e]:[(0,G.jsx)(`br`,{},i),e]})},LI=e=>e.map(e=>(0,G.jsx)(V.Fragment,{children:RI(e)},FI(e))),RI=e=>e.type===`text`?II(e.value,FI(e)):e.type===`emphasis`?(0,G.jsx)(`em`,{children:LI(e.children)}):e.type===`strong`?(0,G.jsx)(`strong`,{children:LI(e.children)}):e.type===`delete`||e.type===`linkReference`?LI(e.children):e.type===`inlineCode`?(0,G.jsx)(`code`,{className:MI.inline,children:e.value}):e.type===`break`?(0,G.jsx)(`br`,{}):e.type===`html`?e.value:e.type===`link`?zI(e.url,e.children):e.type===`image`||e.type===`imageReference`?(0,G.jsx)(`span`,{className:MI.image,children:e.alt===void 0||e.alt===null||e.alt===``?`image`:`image: ${e.alt}`}):null,zI=(e,t)=>{if(CI(e))return(0,G.jsxs)(`a`,{className:MI.link,href:e,rel:`noopener noreferrer`,target:`_blank`,children:[LI(t),(0,G.jsx)(zw,{children:` (opens in a new tab)`})]});let n=t.map(e=>DI(e)).join(``);return n===e||n===``?(0,G.jsx)(`code`,{className:MI.target,children:e}):(0,G.jsxs)(G.Fragment,{children:[LI(t),` (`,(0,G.jsx)(`code`,{className:MI.target,children:e}),`)`]})},BI=(e,t,n)=>{let r=FI(e);if(e.type===`paragraph`)return(0,G.jsx)(`p`,{children:LI(e.children)},r);if(e.type===`heading`){let t=NI[Math.min(6,n.startLevel+e.depth-1)-1]??`h6`;return(0,G.jsx)(t,{children:LI(e.children)},r)}if(e.type===`thematicBreak`)return(0,G.jsx)(`hr`,{},r);if(e.type===`blockquote`)return(0,G.jsx)(`blockquote`,{children:HI(e,n)},r);if(e.type===`list`){let t=e.children.map(e=>(0,G.jsx)(`li`,{children:HI(e,n)},FI(e)));return e.ordered===!0?(0,G.jsx)(`ol`,{start:e.start??1,children:t},r):(0,G.jsx)(`ul`,{children:t},r)}return e.type===`definition`?(0,G.jsxs)(`p`,{children:[`[`,e.label??e.identifier,`]:`,` `,(0,G.jsx)(`code`,{className:MI.target,children:e.url})]},r):e.type===`code`?VI(e.value,e.lang,n,r):e.type===`html`?OI.includes(t.type)?VI(e.value,void 0,n,r):(0,G.jsx)(V.Fragment,{children:e.value},r):null},VI=(e,t,n,r)=>(0,G.jsx)(YS,{caption:t??void 0,command:e,label:n.copyLabel(n.next(),n.blocks)},r),HI=(e,t)=>e.children.map(n=>BI(n,e,t)),UI=e=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:MI.note,children:`Could not render this as Markdown: showing the text as written.`}),(0,G.jsx)(`pre`,{className:MI.written,children:e})]}),WI=({text:e,startLevel:t,lead:n=!1,muted:r=!1,copyLabel:i=PI})=>{let a;try{let n=EI(e),r=0;a=HI(n,{startLevel:t,blocks:kI(n),next:()=>++r,copyLabel:i})}catch{a=UI(e)}return(0,G.jsx)(`div`,{className:MI.markdown,"data-lead":n?``:void 0,"data-muted":r?``:void 0,children:a})},GI=e=>{let t=jI(e);return t===1?`1 line`:`${t} lines`},KI=({decision:e,document:t})=>{let[n,r]=(0,V.useState)(!1),i=(0,V.useRef)(null),{id:a,node:o,runId:s}=e;return(0,G.jsxs)(`div`,{className:hN.read,children:[(0,G.jsx)(q,{cli:aN(e),onClick:()=>{r(!0)},variant:`ghost`,children:`Read document`}),(0,G.jsx)(`span`,{className:hN.length,children:GI(t)}),(0,G.jsxs)(bC,{description:`Document for run ${s}. Read-only.`,initialFocus:i,onOpenChange:r,open:n,size:`wide`,title:`\`${o}\` · \`${a}\``,children:[(0,G.jsx)(`div`,{"aria-label":`Document`,className:hN.document,ref:i,role:`region`,tabIndex:0,children:(0,G.jsx)(WI,{copyLabel:iN(`${o} document`),startLevel:3,text:t})}),(0,G.jsx)(xC,{children:(0,G.jsx)(q,{onClick:()=>{r(!1)},children:`Close`})})]})]})},qI={region:`_region_1w5dd_7`,more:`_more_1w5dd_23`},JI=e=>{let t=Number(getComputedStyle(e).lineHeight.replace(`px`,``));return e.scrollHeight>0&&t>0?Math.round(e.scrollHeight/t):null},YI=({source:e,children:t})=>{let n=(0,V.useRef)(null),r=(0,V.useId)(),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(()=>jI(e)),c=(0,V.useCallback)(()=>{let t=n.current;s((t===null?null:JI(t))??jI(e))},[e]);(0,V.useEffect)(()=>{c();let e=typeof ResizeObserver>`u`?null:new ResizeObserver(c);return n.current!==null&&e?.observe(n.current),()=>{e?.disconnect()}},[c]);let l=o>20;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:qI.region,"data-folded":l&&!i?``:void 0,id:r,onFocus:()=>{a(!0)},ref:n,children:t}),l?(0,G.jsx)(`div`,{className:qI.more,children:(0,G.jsx)(q,{"aria-controls":r,"aria-expanded":i,onClick:()=>{i&&n.current?.closest(`section`)?.scrollIntoView?.({block:`nearest`}),a(!i)},variant:`ghost`,children:i?`Show less`:`Show all (${o} lines)`})}):null]})},XI=({decision:{kind:e,node:t,question:n,context:r},nameId:i})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{hidden:!0,id:i,children:AI(n)}),(0,G.jsx)(YI,{source:n,children:(0,G.jsx)(WI,{copyLabel:iN(t),lead:!0,startLevel:4,text:n})}),r===void 0?null:e===`permission`?(0,G.jsx)(YS,{caption:oN(r)?`json`:void 0,command:r,label:`Copy command (${t})`}):(0,G.jsx)(YI,{source:r,children:(0,G.jsx)(WI,{copyLabel:iN(t),muted:!0,startLevel:4,text:r})})]}),ZI=e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLButtonElement&&!(`option`in e.dataset),QI=({decision:e,workflow:t,onAnswer:n,onOpenRun:r})=>{let{id:i,runId:a,node:o,document:s,options:c,recommended:l,owner:u}=e,d=(0,V.useId)(),f=(0,V.useId)(),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(``),y=async e=>{if(p)return;m(!0),g(null);let t=await n(i,e.id,_);m(!1),t.ok||g(t.error)};return(0,G.jsxs)(`section`,{"aria-labelledby":`${f} ${d}`,className:hN.card,"data-decision":i,onKeyDown:e=>{if(!(e.target instanceof Node)||!e.currentTarget.contains(e.target)||e.metaKey||e.ctrlKey||e.altKey||ZI(e.target))return;let t=e.target===e.currentTarget,n=e.key===`Enter`&&t?c.find(e=>e.id===l):rN(c,e.key);n!==void 0&&(e.preventDefault(),y(n))},tabIndex:0,children:[(0,G.jsxs)(`div`,{className:hN.from,children:[(0,G.jsxs)(`h3`,{className:hN.fromText,id:f,children:[t===void 0?``:`${t} · `,a,` · `,o,u===void 0?``:`, passed on by ${u}`]}),(0,G.jsx)(q,{onClick:()=>{r(a,o)},variant:`ghost`,children:`Open run`})]}),(0,G.jsx)(XI,{decision:e,nameId:d}),s===void 0?null:(0,G.jsx)(KI,{decision:e,document:s}),(0,G.jsx)(gN,{decision:e,note:_,onChoose:e=>{y(e)},onNote:v,sending:p}),h===null?null:(0,G.jsxs)(`p`,{className:hN.refusal,role:`alert`,children:[`Could not answer: `,(0,G.jsx)(Wg,{text:h})]})]})},$I=({view:e,open:t,onChange:n})=>{let{workflow:r,run:i}=e.active;return(0,G.jsxs)(`div`,{className:hN.filter,children:[(0,G.jsxs)(`div`,{className:hN.filterFields,children:[(0,G.jsx)(Bw,{label:`Workflow`,onChange:e=>{n(e===` all`?{}:{workflow:e})},options:e.workflows,value:r??` all`}),(0,G.jsx)(Bw,{label:`Run`,onChange:e=>{n({...r===void 0?{}:{workflow:r},...e===` all`?{}:{run:e}})},options:e.runs,value:i??` all`})]}),(0,G.jsxs)(`div`,{className:hN.counts,children:[(0,G.jsx)(`output`,{children:fN(t,e.shown.length)}),pN(e.active)?(0,G.jsx)(q,{onClick:()=>{n({})},variant:`ghost`,children:`Clear filter`}):null]})]})},eL=({filter:e,open:t,onClear:n})=>t===0?(0,G.jsx)(CC,{cli:`ork decide`,title:`No decisions waiting.`,children:`Questions from your runs land here. In a terminal:`}):(0,G.jsxs)(CC,{cli:mN(e),title:`No decisions match the filter.`,children:[(0,G.jsxs)(`p`,{children:[t===1?`1 open decision is`:`${t} open decisions are`,` `,`hidden by it. Clear the filter to see `,t===1?`it`:`them`,`.`]}),(0,G.jsx)(q,{onClick:n,variant:`ghost`,children:`Clear filter`})]}),tL=({settled:e})=>e.length===0?null:(0,G.jsxs)(`section`,{"aria-label":`Settled decisions`,className:hN.settled,children:[(0,G.jsx)(`h3`,{className:hN.settledTitle,children:`Settled`}),(0,G.jsx)(`ul`,{className:hN.settledList,children:e.map(e=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:hN.settledQuestion,children:e.question}),(0,G.jsxs)(`span`,{className:hN.settledEnding,children:[(0,G.jsx)(`code`,{children:e.runId}),` · `,(0,G.jsx)(`code`,{children:e.node}),`.`,` `,(0,G.jsx)(Wg,{text:tN(e)})]}),nN(e)===void 0?null:(0,G.jsx)(`span`,{className:hN.settledNote,children:nN(e)})]},e.id))})]}),nL=e=>e.tabIndex>=0?e:e.querySelector(`button`),rL=(e,t)=>{let n=(0,V.useRef)(null),r=(0,V.useRef)(null),i=(0,V.useRef)(e),a=(0,V.useRef)(null);return(0,V.useEffect)(()=>{if(e===i.current)return;i.current=e;let a=r.current;if(a===null||document.activeElement!==document.body)return;let o=n.current?.querySelectorAll(t),s=o?.[Math.min(a,(o.length||1)-1)];((s===void 0?null:nL(s))??n.current)?.focus()},[e,t]),(0,V.useEffect)(()=>{let e=a.current;e instanceof Node&&!e.isConnected&&(a.current=null,document.activeElement===document.body&&n.current?.focus())}),{panel:n,onFocus:e=>{let{target:n,currentTarget:i}=e;a.current=n;let o=n instanceof Element?n.closest(t):null;r.current=o===null?null:[...i.querySelectorAll(t)].indexOf(o)}}},iL=()=>{let e=qy(),t=(0,V.use)(ZM),n=ab(e.decisions),r=ab(e.settledDecisions),i=ab(e.runs),a=(0,V.useRef)(r[0]?.id),{value:o,update:s}=e.preferences,c=ab(o).decisionFilter,l=(0,V.useMemo)(()=>n??[],[n]),u=(0,V.useCallback)(e=>i?.find(({id:t})=>t===e)?.workflow,[i]),d=n!==null&&i!==null,[f,p]=(0,V.useState)(!1),m=dN(l,!d||f?c:lN(l,c,u),u),h=new Set(l.map(({runId:e})=>e)).size>1,{panel:g,onFocus:_}=rL(m.shown.map(({id:e})=>e).join(`
|
|
67
|
+
`),`[data-decision]`),v=e=>{s({decisionFilter:e})};return(0,V.useEffect)(()=>{if(f||!d)return;let e=lN(l,c,u);(e.workflow!==c.workflow||e.run!==c.run)&&s({decisionFilter:e}),p(!0)},[d,f,l,c,s,u]),(0,V.useEffect)(()=>{let e=r[0];e!==void 0&&e.id!==a.current&&(a.current=e.id,t?.announce(`${e.question} ${tN(e)}`))},[r,t]),(0,G.jsxs)(`div`,{"aria-label":`Decisions`,className:hN.panel,onFocus:_,ref:g,role:`group`,tabIndex:-1,children:[pN(m.active)||h?(0,G.jsx)($I,{onChange:v,open:l.length,view:m}):null,m.shown.length===0?(0,G.jsx)(eL,{filter:m.active,onClear:()=>{v({})},open:l.length}):(0,G.jsx)(`div`,{className:hN.list,children:m.shown.map(t=>(0,G.jsx)(QI,{decision:t,onAnswer:e.answerDecision,onOpenRun:(t,n)=>{e.selectRun(t),e.selectNode(n)},workflow:u(t.runId)},t.id))}),(0,G.jsx)(tL,{settled:r})]})},aL={panel:`_panel_1h85d_8`,tools:`_tools_1h85d_24`,main:`_main_1h85d_39`,status:`_status_1h85d_52`,counts:`_counts_1h85d_65`,error:`_error_1h85d_82`,list:`_list_1h85d_91`,item:`_item_1h85d_106`,row:`_row_1h85d_113`,time:`_time_1h85d_152`,type:`_type_1h85d_153`,node:`_node_1h85d_159`,line:`_line_1h85d_161`,detail:`_detail_1h85d_186`},oL=e=>e.map(e=>({value:e,label:e})),sL=({events:e,node:t,type:n,text:r,onNode:i,onType:a,onText:o})=>(0,G.jsxs)(`div`,{className:aL.tools,children:[(0,G.jsx)(KS,{empty:`No node matches.`,label:`Node`,onChange:i,options:oL(BM(e,t)),placeholder:`All nodes`,value:t}),(0,G.jsx)(KS,{empty:`No event type matches.`,label:`Event`,onChange:a,options:oL(VM(e)),placeholder:`All events`,value:n}),(0,G.jsx)(Uw,{label:`Text`,onChange:o,value:r})]}),cL=(0,V.memo)(({stored:e,open:t,tabbable:n,onToggle:r})=>{let{seq:i,at:a,event:o}=e;return(0,G.jsxs)(`li`,{className:aL.item,children:[(0,G.jsxs)(`button`,{"aria-expanded":t,className:aL.row,"data-log-row":i,onClick:()=>{r(i)},tabIndex:n?0:-1,type:`button`,children:[(0,G.jsx)(`span`,{className:aL.time,children:WM(a)}),(0,G.jsx)(`span`,{className:aL.node,children:kM(o)??`run`}),(0,G.jsx)(`span`,{className:aL.type,children:o.type}),(0,G.jsx)(`span`,{className:aL.line,children:FM(o)})]}),t?(0,G.jsx)(`pre`,{"aria-label":`Event ${String(i)} in full`,className:aL.detail,role:`group`,tabIndex:0,children:JSON.stringify(o,null,2)}):null]})});cL.displayName=`LogRow`;var lL=({shown:e,listRef:t,onScroll:n,label:r,reading:i})=>{let[a,o]=(0,V.useState)(new Set),[s,c]=(0,V.useState)(null),l=e.some(({seq:e})=>e===s)?s:e.at(-1)?.seq??null,u=(0,V.useCallback)(e=>{c(e),o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]);return e.length===0?(0,G.jsx)(CC,{title:i?`Reading the run…`:`No event matches.`,children:`Only loaded events are filtered. Load older ones to look further.`}):(0,G.jsx)(`ol`,{"aria-label":r,className:aL.list,onKeyDown:e=>{let t=[...e.currentTarget.querySelectorAll(`[data-log-row]`)],n=t.findIndex(t=>t===e.target);if(n===-1)return;let r={ArrowDown:t[n+1],ArrowUp:t[n-1],Home:t[0],End:t.at(-1)};if(!(e.key in r))return;e.preventDefault();let i=r[e.key];i!==void 0&&(c(Number(i.dataset.logRow)),i.focus())},onScroll:n,ref:t,children:e.map(e=>(0,G.jsx)(cL,{onToggle:u,open:a.has(e.seq),stored:e,tabbable:e.seq===l},e.seq))})},uL=2e3,dL={events:[],latest:0,following:!0},fL=e=>e.events[0]?.seq??1,pL=e=>e.events.at(-1)?.seq??0,mL=e=>fL(e)>1,hL=e=>pL(e)<e.latest,gL=e=>e.slice(-2e3),_L=(e,t)=>Math.max(e.latest,t.at(-1)?.seq??0),vL=(e,t)=>{let n=pL(e);return t.filter(e=>e.seq>n)},yL=(e,t)=>{let n=_L(e,t);return e.following&&!hL(e)?{...e,latest:n,events:gL([...e.events,...vL(e,t)])}:{...e,latest:n}},bL=(e,t)=>({events:gL(t),latest:_L(e,t),following:!0}),xL=(e,t)=>({...e,latest:_L(e,t),events:gL([...e.events,...vL(e,t)])}),SL=(e,t)=>{let n=fL(e),r=[...t.filter(e=>e.seq<n),...e.events].slice(0,uL),i={...e,events:r};return{...i,following:e.following&&!hL(i)}},CL=e=>{let t=fL(e)-1,n=Math.max(0,t-500);return{after:n,limit:t-n}},wL=({events:e,shown:t,feed:n,cli:r})=>{let i=e.events.length,a=e.latest-pL(e);return(0,G.jsxs)(`div`,{className:aL.status,children:[(0,G.jsx)(`span`,{className:aL.counts,children:HM(t,i,e.latest)}),(0,G.jsx)(q,{disabled:!mL(e)||e.paging,focusableWhenDisabled:!0,onClick:()=>{n.loadOlder()},variant:`ghost`,children:`Load older`}),(0,G.jsxs)(q,{"aria-pressed":e.following,cli:r,onClick:()=>{e.following?n.hold():n.follow()},variant:`ghost`,children:[e.following?(0,G.jsx)(Yv,{}):null,`Follow`,a>0?` (${String(a)} new)`:``]})]})},TL=({error:e})=>(0,G.jsx)(`p`,{className:aL.error,role:`alert`,children:(0,G.jsx)(Wg,{text:e})}),EL=32,DL=e=>e.scrollHeight-e.scrollTop-e.clientHeight<EL,OL=(e,t)=>{let n=(0,V.useRef)(null),{following:r}=t,i=t.events[0]?.seq,a=(0,V.useRef)({firstSeq:i,height:0});return(0,V.useLayoutEffect)(()=>{let e=n.current;e!==null&&(r?e.scrollTop=e.scrollHeight:a.current.firstSeq!==i&&a.current.height>0&&(e.scrollTop+=e.scrollHeight-a.current.height),a.current={firstSeq:i,height:e.scrollHeight})}),(0,V.useEffect)(()=>{let t=n.current,r=new ResizeObserver(()=>{t!==null&&e.state.getValue().following&&(t.scrollTop=t.scrollHeight)});return t!==null&&r.observe(t),()=>{r.disconnect()}}),{listRef:n,onScroll:()=>{let t=n.current;if(t===null)return;let r=DL(t),i=e.state.getValue();i.following&&!r?e.hold():!i.following&&r&&!hL(i)&&e.follow()}}},kL=500,AL=({runId:e,node:t})=>{let n=qy(),r=(0,V.useMemo)(()=>n.feedOf(e),[n,e]);(0,V.useEffect)(()=>n.retainRun(e),[n,e]);let i=ab(r.state),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(``),l=(0,V.useMemo)(()=>RM(i.events,{node:t,type:a,text:s}),[i.events,t,a,s]),{listRef:u,onScroll:d}=OL(r,i),f=(0,V.use)(ZM),p=JSON.stringify([t,a,s]),m=(0,V.useRef)(p),h=HM(l.length,i.events.length,i.latest);return(0,V.useEffect)(()=>{let e=setTimeout(()=>{p!==m.current&&(m.current=p,f?.announce(h))},kL);return()=>{clearTimeout(e)}},[p,h,f]),(0,G.jsxs)(`div`,{className:aL.panel,children:[(0,G.jsx)(sL,{events:i.events,node:t,onNode:n.selectNode,onText:c,onType:o,text:s,type:a}),(0,G.jsxs)(`div`,{className:aL.main,children:[(0,G.jsx)(wL,{cli:UM(e,t),events:i,feed:r,shown:l.length}),i.error===null?null:(0,G.jsx)(TL,{error:i.error}),(0,G.jsx)(lL,{label:`Events of run ${e}`,listRef:u,onScroll:d,reading:i.link===`loading`&&i.events.length===0,shown:l})]})]})},jL=()=>{let{run:e,node:t}=ab(qy().selection);return e===null?(0,G.jsx)(CC,{cli:`ork logs <run>`,title:`No run chosen.`,children:`Choose one in the Runs panel, or in a terminal:`}):(0,G.jsx)(AL,{node:t,runId:e},e)},ML=(e,t=new Set)=>{let n=(e,r,i)=>e.flatMap(e=>[{node:e,depth:r,parent:i},...t.has(e.id)?[]:n(e.children,r+1,e.id)]);return n(e,1)},NL={waiting:`queued`,running:`running`,ok:`succeeded`,failed:`failed`,skipped:`skipped`},PL={waiting:`skipped`,running:`interrupted`},FL=(e,t,n=!1)=>{let r=n?PL[e.state]:void 0;return r===void 0?e.held===!0?`paused`:t?`waiting`:NL[e.state]:r},IL=(e,t)=>new Set((e??[]).filter(e=>e.runId===t).map(e=>e.node)),LL=(e,t,n,r=!1)=>new Map(ML(e).map(({node:e})=>{let i=e.inputTokens+e.outputTokens;return[e.id,{status:FL(e,t.has(e.id),r),model:e.model,tokens:i===0?void 0:i,costUsd:e.costUsd===0?void 0:e.costUsd,cli:`ork logs ${n} --node ${e.id}`}]})),RL=(e,t)=>({run:e,nodes:new Map([...t].map(([e,{status:t}])=>[e,t]))}),zL=new Set([`failed`,`paused`]),BL=(e,t,n)=>[...n.run===t.run||n.run!==`running`?[]:[`Run ${e} ${_D(n.run)}.`],...[...n.nodes].filter(([e,r])=>r!==t.nodes.get(e)&&zL.has(r)&&(r!==`paused`||n.run!==`paused`)).map(([e,t])=>`${e} ${_D(t)}.`)],VL=({live:e},t)=>e===`running`&&t?`waiting`:e,HL=(e,t)=>{let n=new Set(e.nodes.map(e=>e.id)),r=ML(t).map(({node:e})=>e).filter(e=>!n.has(e.id)).map(({id:e,type:t,parent:n})=>({id:e,type:t,parent:n}));return{...e,nodes:[...e.nodes,...r]}},UL={enabled:!0},WL=e=>({enabled:!1,why:e}),GL=({live:e})=>e===`running`||e===`paused`,KL=e=>e.id.startsWith(`node-`)?WL(`it ran one node; run that node again instead`):UL,qL=e=>{if(!GL(e)){let t=`the run has ended (${e.live})`,n={pause:WL(t),proceed:WL(t),stop:WL(t)};return e.live===`succeeded`?n:{...n,resume:KL(e)}}let t=e.live===`paused`;return{pause:t?WL(`the run is paused`):UL,proceed:t?UL:WL(`the run is not paused`),stop:UL}},JL=(e,t)=>{if(!GL(e)){let t=`the run has ended (${e.live})`;return{pause:WL(t),proceed:WL(t),stop:WL(t)}}if(t.state!==`running`&&t.state!==`waiting`){let e=`${t.id} has finished`;return{pause:WL(e),proceed:WL(e),stop:WL(e)}}let n=t.held===!0||e.paused.nodes.includes(t.id),r=t.state===`running`?UL:WL(`${t.id} is not running`);if(e.live===`paused`){let e=`the whole run is paused; continue the run`;return{pause:WL(e),proceed:WL(e),stop:r}}return{pause:n?WL(`${t.id} is paused`):UL,proceed:n?UL:WL(`${t.id} is not paused`),stop:r}},YL=e=>e.state===`waiting`||e.state===`skipped`?WL(`it hasn't run`):UL,XL={reason:`_reason_sb9l9_7`},J={panel:`_panel_150du_9`,tools:`_tools_150du_28`,card:`_card_150du_29`,body:`_body_150du_58`,toolsEnd:`_toolsEnd_150du_74`,count:`_count_150du_85`,updating:`_updating_150du_86`,list:`_list_150du_96`,row:`_row_150du_107`,rowTop:`_rowTop_150du_148`,rowTitle:`_rowTitle_150du_158`,rowMeta:`_rowMeta_150du_172`,high:`_high_150du_189`,detail:`_detail_150du_197`,head:`_head_150du_206`,title:`_title_150du_215`,facts:`_facts_150du_228`,fact:`_fact_150du_228`,factName:`_factName_150du_245`,caption:`_caption_150du_246`,factValue:`_factValue_150du_263`,actions:`_actions_150du_278`,line:`_line_150du_279`,note:`_note_150du_288`,message:`_message_150du_289`,lineIcon:`_lineIcon_150du_299`,alert:`_alert_150du_308`,section:`_section_150du_326`,records:`_records_150du_339`,record:`_record_150du_339`,recordMeta:`_recordMeta_150du_362`,recordTitle:`_recordTitle_150du_380`,recordBody:`_recordBody_150du_390`,evidence:`_evidence_150du_399`,form:`_form_150du_409`,pair:`_pair_150du_417`,place:`_place_150du_425`,wellHead:`_wellHead_150du_435`,wellCopy:`_wellCopy_150du_444`,preview:`_preview_150du_452`,link:`_link_150du_499`,result:`_result_150du_510`,dialogFoot:`_dialogFoot_150du_519`},ZL=`Meta+Enter Control+Enter`,QL=({onSend:e,children:t})=>(0,G.jsx)(`form`,{className:J.form,onKeyDown:t=>{t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e())},onSubmit:t=>{t.preventDefault(),e()},children:t}),$L=({why:e,id:t})=>(0,G.jsx)(`output`,{className:XL.reason,id:t,children:(0,G.jsx)(Wg,{text:e??``})}),eR=({text:e})=>e===null?null:(0,G.jsx)(`p`,{className:J.alert,role:`alert`,children:(0,G.jsx)(Wg,{text:e})}),tR=[`friction`,`bug`,`context-gap`,`skill`,`workflow`,`idea`],nR=[`low`,`medium`,`high`],rR=[{value:``,label:`No rating`},{value:`good`,label:`good`},{value:`bad`,label:`bad`}],iR={text:``,rating:``,kind:`friction`,severity:null},aR=({rating:e,severity:t})=>t??(e===`bad`?`high`:`medium`),oR=e=>e.severity===null&&e.rating===`bad`,sR=e=>e.text.trim()===``?`Write the note first.`:null,cR=(e,t)=>({text:t.text,...e===void 0?{}:{node:e},kind:t.kind,severity:aR(t),...t.rating===``?{}:{rating:t.rating}}),lR=(e,t,n)=>{let r=aR({...n,severity:null}),i=aR(n);return[`ork feedback note`,e,...t===void 0?[]:[sT(t)],`-m`,n.text.trim()===``?`<text>`:sT(n.text),...n.kind===`friction`?[]:[`--kind ${n.kind}`],...i===r?[]:[`--severity ${i}`],...n.rating===``?[]:[`--rating ${n.rating}`]].join(` `)},uR=(e,t,n)=>({title:t===void 0?`Noted on run \`${e}\``:`Noted on \`${t}\``,description:`It joined item \`${n.slice(0,12)}\`.`}),dR=e=>e.map(e=>({value:e,label:e})),fR=({runId:e,node:t,onSend:n,onDone:r})=>{let[i,a]=(0,V.useState)(iR),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null),u=(0,V.useId)(),d=(0,V.useId)(),f=sR(i),p=e=>{a(t=>({...t,...e}))},m=async()=>{if(f!==null||o)return;s(!0),l(null);let e=await n(cR(t,i));s(!1),l(e),e===null&&r()};return(0,G.jsxs)(QL,{onSend:()=>{m()},children:[(0,G.jsx)(Uw,{description:`Its first line is the title.`,label:`Note`,multiline:!0,onChange:e=>{p({text:e})},required:!0,value:i.text}),(0,G.jsx)(Bw,{label:`Rating`,onChange:e=>{p({rating:e})},options:rR,value:i.rating}),(0,G.jsx)(Bw,{label:`Kind`,onChange:e=>{p({kind:e})},options:dR(tR),value:i.kind}),(0,G.jsx)(Bw,{label:`Severity`,onChange:e=>{p({severity:e})},describedBy:d,options:dR(nR),value:aR(i)}),(0,G.jsx)($L,{id:d,why:oR(i)?`Severity: high, from the bad rating.`:null}),(0,G.jsx)(YS,{command:lR(e,t,i)}),(0,G.jsx)($L,{id:u,why:f}),(0,G.jsx)(eR,{text:c}),(0,G.jsxs)(xC,{children:[(0,G.jsx)(q,{disabled:o,onClick:r,type:`button`,variant:`ghost`,children:`Cancel`}),(0,G.jsx)(q,{"aria-describedby":u,"aria-keyshortcuts":ZL,disabled:f!==null||o,focusableWhenDisabled:!0,type:`submit`,variant:`primary`,children:o?`Adding…`:`Add note`})]})]})},pR={enabled:!0},mR=({runId:e,node:t,check:n=pR,onSend:r})=>{let[i,a]=(0,V.useState)(!1),o=t??`run ${e}`,s=n.enabled?`Note on ${o}`:`Note on ${o}: ${n.why}`,c=`ork feedback note ${e}${t===void 0?``:` ${t}`} -m <text>`,l=()=>{a(!0)};return(0,G.jsxs)(G.Fragment,{children:[t===void 0?(0,G.jsx)(cb,{cli:c,label:s,onClick:l,children:(0,G.jsx)(xy,{})}):(0,G.jsxs)(q,{"aria-label":s,cli:c,disabled:!n.enabled,focusableWhenDisabled:!0,onClick:l,tip:n.enabled?void 0:s,children:[(0,G.jsx)(xy,{}),`Note…`]}),(0,G.jsx)(bC,{description:`It joins run ${e}'s feedback as yours, and groups into an item like any record.`,onOpenChange:a,open:i,title:t===void 0?`Note on run \`${e}\``:`Note on \`${t}\``,children:(0,G.jsx)(fR,{node:t,onDone:()=>{a(!1)},onSend:r,runId:e})})]})},hR={monitor:`_monitor_1rkzd_8`,header:`_header_1rkzd_25`,stats:`_stats_1rkzd_43`,stat:`_stat_1rkzd_43`,statName:`_statName_1rkzd_58`,statValue:`_statValue_1rkzd_74`,title:`_title_1rkzd_90`,runId:`_runId_1rkzd_101`,controls:`_controls_1rkzd_111`,error:`_error_1rkzd_119`,canvas:`_canvas_1rkzd_133`,table:`_table_1rkzd_144`,tableHead:`_tableHead_1rkzd_162`,tree:`_tree_1rkzd_185`,treeRow:`_treeRow_1rkzd_190`,treeNode:`_treeNode_1rkzd_233`,treeToggle:`_treeToggle_1rkzd_239`,treeId:`_treeId_1rkzd_259`,treeType:`_treeType_1rkzd_269`,treeStatus:`_treeStatus_1rkzd_285`,treeNow:`_treeNow_1rkzd_291`,treeTime:`_treeTime_1rkzd_301`,treeCost:`_treeCost_1rkzd_314`,sideTitle:`_sideTitle_1rkzd_337`,node:`_node_1rkzd_346`,nodeFacts:`_nodeFacts_1rkzd_362`,watching:`_watching_1rkzd_363`,links:`_links_1rkzd_415`,linkList:`_linkList_1rkzd_430`,link:`_link_1rkzd_415`,linkEnds:`_linkEnds_1rkzd_450`,linkCount:`_linkCount_1rkzd_461`},gR={enabled:!0},_R=(e,t,n)=>n.enabled?`${e} ${t}`:`${e} ${t}: ${n.why}`,vR=`It goes on in the background with the inputs and flags it started with. Nodes that finished keep their results and don't run again; the one that failed or was cut off runs again, and so does everything after it. It's a paid run, like any you start.`,yR=({runId:e,action:t})=>{let n=qy(),[r,i]=(0,V.useState)(!1),a=(0,V.useRef)(!1),o=`ork resume ${e} --detach`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(q,{"aria-label":_R(`Resume`,`run`,t),cli:o,disabled:!t.enabled,focusableWhenDisabled:!0,onClick:()=>{i(!0)},tip:t.enabled?void 0:t.why,variant:`ghost`,children:[(0,G.jsx)(By,{}),`Resume…`]}),(0,G.jsx)(SC,{cli:o,confirm:`Resume run`,description:vR,finalFocus:()=>{let t=a.current;return a.current=!1,(t?document.querySelector(`[data-run-heading="${e}"]`):null)??!0},onConfirm:async()=>{let t=await n.client.call(`resume`,{params:{id:e},body:{}});return a.current=t.ok,t.ok?null:`Could not resume the run: ${t.error}`},onOpenChange:i,open:r,pending:`Resuming…`,title:`Resume run ${e}?`,variant:`primary`})]})},bR=({runId:e,node:t,actions:n,note:r=gR})=>{let i=qy(),[a,o]=(0,V.useState)(!1),s=t??`run`,c=t===void 0?``:` --node ${t}`,l=n=>{i.control(n,e,t).then(e=>(e.ok||Hy.add({title:`Could not ${n} ${s}`,description:e.error}),e))},u=(0,G.jsx)(mR,{check:r,node:t,onSend:async n=>{let r=await i.client.call(`note`,{params:{id:e},body:n});return r.ok?(Hy.add(uR(e,t,r.data.item)),null):`Could not add the note: ${r.error}`},runId:e});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{"aria-label":t===void 0?`Run controls`:`Controls for ${t}`,className:hR.controls,role:`group`,children:[(0,G.jsx)(cb,{cli:`ork pause ${e}${c}`,disabled:!n.pause.enabled,focusableWhenDisabled:!0,label:_R(`Pause`,s,n.pause),onClick:()=>{l(`pause`)},children:(0,G.jsx)(Kv,{})}),(0,G.jsx)(cb,{cli:`ork continue ${e}${c}`,disabled:!n.proceed.enabled,focusableWhenDisabled:!0,label:_R(`Continue`,s,n.proceed),onClick:()=>{l(`continue`)},children:(0,G.jsx)(Gv,{})}),(0,G.jsx)(cb,{cli:`ork stop ${e}${c}`,disabled:!n.stop.enabled,focusableWhenDisabled:!0,label:_R(`Stop`,s,n.stop),onClick:()=>{o(!0)},children:(0,G.jsx)(qv,{})}),(0,G.jsx)(SC,{cli:`ork stop ${e}${c}`,confirm:t===void 0?`Stop run`:`Stop ${t}`,description:t===void 0?`Running nodes are interrupted, and runs it called stop too. It can be resumed later, from here or a terminal.`:`Its session is interrupted and \`${t}\` fails with \`stopped by the user\`. The workflow's failure rules then apply.`,onConfirm:()=>{o(!1),l(`stop`)},onOpenChange:o,open:a,title:t===void 0?`Stop run ${e}?`:`Stop ${t}?`}),n.resume===void 0?null:(0,G.jsx)(yR,{action:n.resume,runId:e}),t===void 0?u:null]}),t===void 0?null:u]})},xR={s:1e3,m:6e4,h:36e5},SR=e=>{let t=/^(\d+)([smh])$/u.exec(e);return Number(t?.[1]??0)*(xR[t?.[2]??`s`]??1e3)},CR=e=>{let t=Math.ceil(e/1e3);if(t<60)return`${String(t)} s`;let n=Math.ceil(t/60);return n<60?`${String(n)} min`:`${String(Math.ceil(n/60))} h`},wR=e=>e===`running`||e===`paused`,TR=(e,t)=>{let n=SR(e.every),r=Math.max(0,t-Date.parse(e.at)),i=n===0?0:Math.floor(r/n),a=e.looks+i;return{until:e.until,every:`every ${e.every}`,looks:`${i===0?``:`about `}${String(a)}`,next:`in about ${CR(n===0?0:n-r%n)}`,said:e.said}},ER=5e3,DR=({watching:e})=>{let[t,n]=(0,V.useState)(Date.now);(0,V.useEffect)(()=>{let e=setInterval(()=>{n(Date.now())},ER);return()=>{clearInterval(e)}},[]);let r=TR(e,t);return(0,G.jsxs)(`dl`,{className:hR.watching,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Waiting until`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(`code`,{children:r.until})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Looks`}),(0,G.jsxs)(`dd`,{children:[r.looks,`, `,r.every]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Next look`}),(0,G.jsx)(`dd`,{children:r.next})]}),r.said===void 0?null:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Last said`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(`code`,{children:r.said})})]})]})},OR=({run:e,node:t,sectionRef:n,onLeave:r,onOpenRun:i})=>{let{calledRun:a}=t;return(0,G.jsxs)(`section`,{"aria-label":`Node ${t.id}`,className:hR.node,onKeyDown:e=>{let t=document.querySelector(`[data-modal]`)!==null;e.key===`Escape`&&!t&&r()},ref:n,children:[(0,G.jsx)(`h3`,{className:hR.sideTitle,children:t.id}),(0,G.jsxs)(`dl`,{className:hR.nodeFacts,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Type`}),(0,G.jsx)(`dd`,{children:ED(t.type)})]}),t.model===void 0?null:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Model`}),(0,G.jsx)(`dd`,{children:t.model})]}),t.inputTokens+t.outputTokens===0?null:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Tokens`}),(0,G.jsxs)(`dd`,{children:[kD(t.inputTokens),` in ·`,` `,kD(t.outputTokens),` out`]})]})]}),(0,G.jsx)(bR,{actions:JL(e,t),node:t.id,note:YL(t),runId:e.id}),t.watching===void 0||!wR(e.status)?null:(0,G.jsx)(DR,{watching:t.watching}),a===void 0?null:(0,G.jsxs)(q,{onClick:()=>{i(a)},variant:`ghost`,children:[`Open run `,a]})]})},kR=({error:e})=>(0,G.jsx)(`p`,{className:hR.error,role:`alert`,children:(0,G.jsx)(Wg,{text:e})}),AR=new Set([`succeeded`,`failed`,`skipped`,`interrupted`]),jR=e=>e.length<2?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e.at(-1)??``}`,MR=(e,t,n)=>{let r=t.filter(({to:t,from:r})=>{let i=t===e?n(r):void 0;return t===e&&(i===void 0||!AR.has(i))}).map(({from:e})=>e);return r.length===0?``:`After ${jR([...new Set(r)])}`},NR=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`,PR=(e,t,n,r,i)=>{if(t===`queued`)return MR(e.id,n,r);if(e.watching!==void 0&&!AR.has(t)){let{looks:t,next:n}=TR(e.watching,i);return NR(`${t} ${t===`1`?`look`:`looks`}, next ${n}`)}return e.now??``},FR=({startedAt:e,finishedAt:t},n,r)=>{if(e===void 0)return`–`;let i=t??n;return jD((i===void 0?r:Date.parse(i))-Date.parse(e))},IR=e=>{let t=[...e];return`${String(t.filter(e=>AR.has(e)).length)} / ${String(t.length)}`},LR=({skipped:e=0,failuresHandled:t=0})=>{let n=[...e===0?[]:[`${String(e)} skipped`],...t===0?[]:[`${String(t)} ${t===1?`failure`:`failures`} handled`]];return n.length===0?null:n.join(` · `)},RR={status:`queued`},zR=({roots:e,facts:t,connections:n,selected:r,edges:i,hovered:a,now:o,runFinishedAt:s,onHover:c,onSelect:l,onNodeMenu:u})=>{let[d,f]=(0,V.useState)(new Set),[p,m]=(0,V.useState)(r),[h,g]=(0,V.useState)(r);r!==h&&(g(r),r!==null&&m(r));let _=(0,V.useMemo)(()=>ML(e,d),[e,d]),v=_.some(({node:e})=>e.id===p)?p:_[0]?.node.id??null,y=(e,t)=>{let n=new Set(d);t?n.delete(e):n.add(e),f(n)},b=(e,t)=>{m(t),[...e.currentTarget.parentElement?.querySelectorAll(`[data-tree-row]`)??[]].find(e=>e.dataset.treeRow===t)?.focus()},x=(e,t)=>{let n=_[t];if(n===void 0)return;let{node:r,parent:i}=n,a=r.children.length>0,o=a&&!d.has(r.id),s={ArrowDown:()=>{let n=_[t+1];n!==void 0&&b(e,n.node.id)},ArrowUp:()=>{let n=_[t-1];n!==void 0&&b(e,n.node.id)},ArrowRight:()=>{a&&(o?b(e,r.children[0]?.id??r.id):y(r.id,!0))},ArrowLeft:()=>{o?y(r.id,!1):i!==void 0&&b(e,i)},Home:()=>{b(e,_[0]?.node.id??r.id)},End:()=>{b(e,_.at(-1)?.node.id??r.id)},Enter:()=>{l(r.id)}," ":()=>{l(r.id)},ContextMenu:()=>{u(r.id)}}[e.key===`F10`&&e.shiftKey?`ContextMenu`:e.key];s!==void 0&&(e.preventDefault(),s())},S=e=>t.get(e)?.status,C=_.some(({node:e})=>e.children.length>0);return(0,G.jsxs)(`div`,{className:hR.table,children:[(0,G.jsxs)(`div`,{"aria-hidden":`true`,className:hR.tableHead,children:[(0,G.jsx)(`span`,{children:`Node`}),(0,G.jsx)(`span`,{className:hR.treeType,children:`Type`}),(0,G.jsx)(`span`,{children:`Status`}),(0,G.jsx)(`span`,{children:`Now`}),(0,G.jsx)(`span`,{className:hR.treeTime,children:`Time`}),(0,G.jsx)(`span`,{className:hR.treeCost,children:`Cost`})]}),(0,G.jsx)(`div`,{"aria-label":`Ownership tree`,className:hR.tree,role:`tree`,children:_.map(({node:e,depth:f},p)=>{let h=t.get(e.id)??RR,g=e.children.length>0,_=g&&!d.has(e.id),b=PR(e,h.status,i,S,o);return(0,V.createElement)(`div`,{...Xg(void 0,n.get(e.id)),"aria-expanded":g?_:void 0,"aria-label":[MD(e.id,e.type,h),...b===``?[]:[b]].join(`, `),"aria-level":f,"aria-selected":e.id===r,className:hR.treeRow,"data-dim":a!==null&&a!==e.id?``:void 0,"data-selected":e.id===r?``:void 0,"data-tree-row":e.id,key:e.id,onClick:()=>{m(e.id),l(e.id)},onContextMenu:t=>{t.preventDefault(),u(e.id)},onKeyDown:e=>{x(e,p)},onMouseEnter:()=>{c(e.id)},onMouseLeave:()=>{c(null)},role:`treeitem`,tabIndex:e.id===v?0:-1},(0,G.jsxs)(`span`,{className:hR.treeNode,style:{paddingInlineStart:`${String((f-1)*.75)}rem`},children:[C?(0,G.jsxs)(`span`,{"aria-hidden":`true`,className:hR.treeToggle,onClick:g?t=>{t.stopPropagation(),y(e.id,!_)}:void 0,children:[g&&_?(0,G.jsx)(Xv,{}):null,g&&!_?(0,G.jsx)(Zv,{}):null]}):null,(0,G.jsx)(`span`,{className:hR.treeId,children:e.id})]}),(0,G.jsx)(`span`,{className:hR.treeType,children:e.type}),(0,G.jsx)(`span`,{className:hR.treeStatus,children:(0,G.jsx)(bD,{status:h.status})}),(0,G.jsx)(`span`,{className:hR.treeNow,children:b}),(0,G.jsx)(`span`,{className:hR.treeTime,children:FR(e,s,o)}),(0,G.jsx)(`span`,{className:hR.treeCost,children:h.costUsd===void 0?`–`:OD(h.costUsd)}))})})]})},BR=new Map;function VR(e,t){let n=JSON.stringify({locale:ox(e),options:t}),r=BR.get(n);if(r)return r;let i=new Intl.NumberFormat(e,t);return BR.set(n,i),i}function HR(e,t,n){return e==null?``:VR(t,n).format(e)}var UR=V.createContext(void 0);function WR(){let e=V.useContext(UR);if(e===void 0)throw Error(rc(38));return e}function GR(e,t,n){return(e-t)*100/(n-t)}var KR=V.forwardRef(function(e,t){let{format:n,getAriaValueText:r,locale:i,max:a=100,min:o=0,value:s,render:c,className:l,children:u,style:d,...f}=e,[p,m]=V.useState(),h=GR(s,o,a),g=p_(Number.isNaN(h)?0:h,0,100),_=p_(Number.isNaN(s)?o:s,o,a),v=n?HR(_,i,n):HR(g/100,i,{style:`percent`}),y=v;r&&(y=r(v,s));let b={"aria-labelledby":p,"aria-valuemax":a,"aria-valuemin":o,"aria-valuenow":_,"aria-valuetext":y,role:`meter`,children:(0,G.jsxs)(V.Fragment,{children:[u,(0,G.jsx)(`span`,{role:`presentation`,style:Iu,children:`x`})]})},x=V.useMemo(()=>({formattedValue:v,percentageValue:g,setLabelId:m,value:s}),[v,g,m,s]),S=Pf(`div`,e,{ref:t,props:[b,f]});return(0,G.jsx)(UR.Provider,{value:x,children:S})}),qR=V.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{setLabelId:s}=WR();return Pf(`span`,e,{ref:t,props:[{id:yx(a,s),role:`presentation`},o]})}),JR={meter:`_meter_1pby1_6`,label:`_label_1pby1_15`,value:`_value_1pby1_31`,track:`_track_1pby1_39`,block:`_block_1pby1_47`},YR=.8,XR=20,ZR=(e,t,n=XR)=>e>=t?n:e<=0?0:Math.min(Math.max(Math.round(e/t*n),1),n-1),QR=(e,t)=>e>=t?`full`:e>=t*YR?`high`:`normal`,$R=({value:e,max:t,blocks:n=XR})=>{let r=ZR(e,t,n);return(0,G.jsx)(`span`,{"aria-hidden":`true`,className:JR.track,"data-level":QR(e,t),children:Array.from({length:n},(e,t)=>(0,G.jsx)(`span`,{className:JR.block,"data-on":t<r?``:void 0},t))})},ez=({label:e,value:t,max:n,text:r})=>(0,G.jsxs)(KR,{"aria-valuetext":r,className:JR.meter,"data-level":QR(t,n),max:n,value:Math.min(t,n),children:[(0,G.jsx)(qR,{className:JR.label,children:e}),(0,G.jsx)(`span`,{className:JR.value,children:r}),(0,G.jsx)($R,{max:n,value:t})]}),tz=16,nz=({run:e,facts:t,budgetUsd:n,now:r})=>{let i=LR(e);return(0,G.jsxs)(`dl`,{className:hR.stats,children:[(0,G.jsxs)(`div`,{className:hR.stat,children:[(0,G.jsxs)(`dt`,{className:hR.statName,children:[`Spent`,n===void 0?``:` · cap ${OD(n,[])}`]}),(0,G.jsxs)(`dd`,{className:hR.statValue,children:[OD(e.costUsd),n===void 0?null:(0,G.jsx)($R,{blocks:tz,max:n,value:e.costUsd})]})]}),(0,G.jsxs)(`div`,{className:hR.stat,children:[(0,G.jsx)(`dt`,{className:hR.statName,children:`Nodes`}),(0,G.jsxs)(`dd`,{className:hR.statValue,children:[IR([...t.values()].map(({status:e})=>e)),i===null?null:` · ${i}`]})]}),(0,G.jsxs)(`div`,{className:hR.stat,children:[(0,G.jsx)(`dt`,{className:hR.statName,children:`Elapsed`}),(0,G.jsx)(`dd`,{className:hR.statValue,children:jD((e.finishedAt===void 0?r:Date.parse(e.finishedAt))-Date.parse(e.startedAt))})]})]})},rz=({run:e,waiting:t})=>{let n=qy(),r=(0,V.use)(ZM),i=ab(n.decisions)?.filter(({runId:t})=>t===e.id).length;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(bD,{pill:!0,status:VL(e,t)}),i===void 0||i===0?null:(0,G.jsxs)(q,{cli:`ork decide ${e.id} --list`,onClick:()=>{n.preferences.update({decisionFilter:{run:e.id}}),r?.goTo(`decisions`)},tip:`Open Decisions, filtered to this run.`,variant:`ghost`,children:[(0,G.jsx)(yy,{}),i===1?`1 decision`:`${i} decisions`,` waiting`]})]})},iz=({run:e,waiting:t,facts:n,budgetUsd:r,now:i})=>{let a=qy(),o=(0,V.useRef)(null),{parent:s}=e;return(0,V.useEffect)(()=>{a.takeArrival(e.id)&&o.current?.focus()},[a,e.id]),(0,G.jsxs)(`header`,{className:hR.header,children:[(0,G.jsxs)(`div`,{className:hR.stat,children:[(0,G.jsx)(`span`,{className:hR.statName,children:`Run`}),(0,G.jsxs)(`span`,{className:hR.statValue,children:[(0,G.jsx)(`h2`,{className:hR.title,"data-run-heading":e.id,ref:o,tabIndex:-1,children:e.workflow}),(0,G.jsx)(`code`,{className:hR.runId,children:e.id})]})]}),(0,G.jsx)(nz,{budgetUsd:r,facts:n,now:i,run:e}),(0,G.jsx)(rz,{run:e,waiting:t}),s===void 0?null:(0,G.jsxs)(q,{onClick:()=>{a.arriveAt(s)},variant:`ghost`,children:[`Called by `,s]}),(0,G.jsx)(bR,{actions:qL(e),runId:e.id})]})},az=({links:e,runId:t,onOpen:n})=>e.length===0?null:(0,G.jsxs)(`section`,{"aria-label":`Links to other runs`,className:hR.links,children:[(0,G.jsx)(`h3`,{className:hR.sideTitle,children:`Links`}),(0,G.jsx)(`ul`,{className:hR.linkList,children:e.map(e=>{let[r,i]=e.a.run===t?[e.a,e.b]:[e.b,e.a];return(0,G.jsxs)(`li`,{className:hR.link,children:[(0,G.jsxs)(`span`,{className:hR.linkEnds,children:[r.node,` ↔ `,i.run,`/`,i.node]}),(0,G.jsxs)(`span`,{className:hR.linkCount,children:[e.messages,`/`,e.maxMessages,e.endedAt===void 0?``:` · ended`]}),(0,G.jsx)(q,{onClick:()=>{n(i.run)},variant:`ghost`,children:`Open`})]},e.id)})})]}),oz=1e3,sz=e=>{let[t,n]=(0,V.useState)(Date.now);return(0,V.useEffect)(()=>{let t=e?setInterval(()=>{n(Date.now())},oz):void 0;return()=>{clearInterval(t)}},[e]),t},cz=1e3,lz=(e,t)=>{let n=(0,V.use)(ZM),r=(0,V.useRef)(null),i=(0,V.useRef)([]),a=(0,V.useRef)(void 0),{id:o,live:s}=e;(0,V.useEffect)(()=>{if(t.size===0)return;let e=RL(s,t),c=r.current===null?[]:BL(o,r.current,e);r.current=e,i.current.push(...c),i.current.length!==0&&a.current===void 0&&(a.current=setTimeout(()=>{a.current=void 0,n?.announce(i.current.splice(0).join(` `))},cz))},[t,o,s,n]),(0,V.useEffect)(()=>()=>{clearTimeout(a.current)},[])},uz=e=>{let t=qy(),n=e.id,r=(0,V.useMemo)(()=>t.watchRun(n),[t,n]);(0,V.useEffect)(()=>{let e=t.retainRun(n),i=r.start();return()=>{i(),e()}},[t,r,n]);let{graph:i,tree:a,links:o,error:s}=ab(r.state),c=ab(t.decisions),{node:l}=ab(t.selection),u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useMemo)(()=>a??[],[a]),p=e.live!==`running`&&e.live!==`paused`,m=(0,V.useMemo)(()=>IL(c,n),[c,n]),h=(0,V.useMemo)(()=>LL(f,m,n,p),[f,m,n,p]),g=ML(f).map(({node:e})=>e.id).join(`
|
|
68
|
+
`),_=(0,V.useMemo)(()=>i===null?null:bk(HL(i,f)),[i,g]),v=(0,V.useMemo)(()=>NE(_?.edges??[]),[_]),y=ML(f).find(({node:e})=>e.id===l)?.node;lz(e,h);let b=(0,V.useCallback)(e=>{let{activeElement:n}=document;d.current=n instanceof HTMLElement?n:null,t.selectNode(e),requestAnimationFrame(()=>{u.current?.querySelector(`button`)?.focus()})},[t]),x=(0,V.useCallback)(()=>{d.current?.focus({preventScroll:!0}),d.current=null},[]);return{state:t,graph:i,layout:_,facts:h,waiting:m.size>0,connections:v,roots:f,links:o,error:s,selected:l,chosen:y,nodeControls:u,openControls:b,closeControls:x}},dz=({run:e})=>{let{state:t,graph:n,layout:r,facts:i,waiting:a,connections:o,roots:s,links:c,error:l,selected:u,chosen:d,nodeControls:f,openControls:p,closeControls:m}=uz(e),[h,g]=(0,V.useState)(null),_=sz(e.live===`running`||e.live===`paused`);return(0,G.jsxs)(`div`,{className:hR.monitor,children:[(0,G.jsx)(iz,{budgetUsd:n?.budgetUsd,facts:i,now:_,run:e,waiting:a}),l===null?null:(0,G.jsx)(kR,{error:l}),(0,G.jsx)(`div`,{className:hR.canvas,children:r===null?(0,G.jsx)(CC,{cli:`ork tree ${e.id}`,title:`Reading the run…`,children:`For now:`}):(0,G.jsx)(MO,{facts:i,hovered:h,label:`Graph of run ${e.id}, ${e.workflow}`,layout:r,live:!0,onHover:g,onNodeMenu:p,onSelect:t.selectNode,selected:u??void 0})}),(0,G.jsx)(zR,{connections:o,edges:n?.edges??[],facts:i,hovered:h,now:_,onHover:g,onNodeMenu:p,onSelect:t.selectNode,roots:s,runFinishedAt:e.finishedAt,selected:u}),d===void 0?null:(0,G.jsx)(OR,{node:d,onLeave:m,onOpenRun:t.arriveAt,run:e,sectionRef:f}),(0,G.jsx)(az,{links:c,onOpen:t.arriveAt,runId:e.id})]})},fz=()=>{let e=qy(),{run:t}=ab(e.selection),n=ab(e.runs)?.find(({id:e})=>e===t);return n===void 0?(0,G.jsx)(CC,{cli:`ork tree <run>`,title:`No run chosen.`,children:`Choose one in the Runs panel, or in a terminal:`}):(0,G.jsx)(dz,{run:n},n.id)},pz=()=>`Notification`in globalThis,mz=async()=>pz()?await Notification.requestPermission()===`granted`?`granted`:`denied`:`unsupported`,hz=(e,t,n)=>{if(!pz()||Notification.permission!==`granted`||document.visibilityState===`visible`)return;let r=new Notification(`Ork`,{body:e,tag:t});r.addEventListener(`click`,()=>{window.focus(),n(),r.close()})},gz=(e,t)=>e.live===`running`&&t?`waiting`:e.live,_z=e=>{let t=new Date(e),n=t.toDateString()===new Date().toDateString();return t.toLocaleString(void 0,n?{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}:{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})},vz=({paused:e,live:t})=>{let n=e.nodes.length;return t!==`running`||n===0?null:n===1?`1 node paused`:`${String(n)} nodes paused`},yz=(0,V.memo)(({run:e,selected:t,tabStop:n,waiting:r,onSelect:i})=>{let a=vz(e);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{"aria-current":t?`true`:void 0,className:Ww.row,"data-run-row":e.id,onClick:()=>{i(e.id)},tabIndex:n?0:-1,type:`button`,children:[(0,G.jsxs)(`span`,{className:Ww.rowTop,children:[(0,G.jsx)(`span`,{className:Ww.workflow,children:e.workflow}),(0,G.jsx)(bD,{status:gz(e,r)})]}),(0,G.jsxs)(`span`,{className:Ww.rowMeta,children:[(0,G.jsx)(`span`,{children:e.id}),(0,G.jsx)(`time`,{dateTime:e.startedAt,children:_z(e.startedAt)}),(0,G.jsx)(`span`,{children:OD(e.costUsd)}),a===null?null:(0,G.jsx)(`span`,{children:a})]})]})})});yz.displayName=`RunRow`;var bz=({onClick:e})=>(0,G.jsxs)(q,{cli:`ork run <workflow>`,"data-run-workflow":``,onClick:e,variant:`primary`,children:[(0,G.jsx)(Gv,{}),`Run workflow`]}),xz=({filtered:e})=>e?(0,G.jsx)(CC,{cli:`ork ps`,title:`No runs in this project.`,children:`Among the newest 50. For older ones:`}):(0,G.jsx)(CC,{cli:`ork run <workflow>`,title:`No runs yet.`,children:`Start one with Run workflow, or in a terminal:`}),Sz={panel:`_panel_1mlu0_7`,tools:`_tools_1mlu0_22`,main:`_main_1mlu0_38`,refused:`_refused_1mlu0_50`,list:`_list_1mlu0_60`,item:`_item_1mlu0_66`,title:`_title_1mlu0_90`,meta:`_meta_1mlu0_103`,unread:`_unread_1mlu0_121`,actions:`_actions_1mlu0_127`},Cz=({item:e})=>{let t=qy(),n=(0,V.use)(ZM);return(0,G.jsxs)(`li`,{className:Sz.item,"data-notification":e.id,"data-unread":e.unread?``:void 0,children:[(0,G.jsx)(`p`,{className:Sz.title,children:e.title}),(0,G.jsxs)(`p`,{className:Sz.meta,children:[(0,G.jsx)(bD,{status:e.status}),(0,G.jsx)(`span`,{children:_z(e.at)}),e.unread?(0,G.jsx)(`span`,{className:Sz.unread,children:`unread`}):null]}),(0,G.jsxs)(`p`,{className:Sz.actions,children:[(0,G.jsx)(q,{"aria-label":`Open: ${e.title}`,onClick:()=>{t.notifications.markRead(e.id),t.selectRun(e.runId),e.node!==void 0&&t.selectNode(e.node),n?.goTo(e.kind===`decision`?`decisions`:`monitor`)},variant:`ghost`,children:`Open`}),(0,G.jsx)(q,{"aria-label":`Mark read: ${e.title}`,disabled:!e.unread,focusableWhenDisabled:!0,onClick:()=>{t.notifications.markRead(e.id)},variant:`ghost`,children:`Mark read`})]})]})},wz={denied:`The browser refused. Allow notifications for this page in its settings.`,unsupported:`This browser has no desktop notifications.`},Tz=()=>{let{notifications:e,preferences:t}=qy(),{items:n,unread:r}=ab(e.view),{desktopNotifications:i}=ab(t.value),[a,o]=(0,V.useState)(null),{panel:s,onFocus:c}=rL(n.map(({id:e})=>e).join(`
|
|
69
|
+
`),`[data-notification]`),l=async e=>{if(o(null),!e){t.update({desktopNotifications:!1});return}let n=await mz();n===`granted`?t.update({desktopNotifications:!0}):o(wz[n])};return(0,G.jsxs)(`div`,{"aria-label":`Notifications`,className:Sz.panel,onFocus:c,ref:s,role:`group`,tabIndex:-1,children:[(0,G.jsxs)(`div`,{className:Sz.tools,children:[(0,G.jsx)(JC,{checked:i,label:`Desktop notifications`,onChange:e=>{l(e)}}),(0,G.jsx)(q,{disabled:r===0,focusableWhenDisabled:!0,onClick:e.markAllRead,variant:`ghost`,children:`Mark all read`})]}),(0,G.jsxs)(`div`,{className:Sz.main,children:[a===null?null:(0,G.jsx)(`p`,{className:Sz.refused,role:`alert`,children:a}),n.length===0?(0,G.jsx)(CC,{title:`Nothing yet.`,children:`Decisions, and runs that end, crash or pause, land here.`}):(0,G.jsx)(`ul`,{className:Sz.list,children:n.map(e=>(0,G.jsx)(Cz,{item:e},e.id))})]})]})},Ez=e=>e.split(`/`).at(-1)??e,Dz=e=>e.split(`/`).slice(-2).join(`/`),Oz=(e,t)=>{let n=new Map(e.map(({root:e,id:t})=>[e,t]));for(let{project:e}of t)n.has(e)||n.set(e,Ez(e));let r=[...n.values()],i=e=>r.indexOf(e)!==r.lastIndexOf(e);return[{value:`all`,label:`All projects`},...[...n].map(([e,t])=>({value:e,label:i(t)?Dz(e):t})).toSorted((e,t)=>e.label.localeCompare(t.label))]},kz=e=>e.status===`ready`?{data:e.data,arg:e.arg}:e.status===`idle`?void 0:e.shown,Az=e=>{let t=Yy.create({status:`idle`}),n=0;return{state:t,load:async r=>{n+=1;let i=n,a=kz(t.getValue());t.setValue({status:`loading`,arg:r,...a===void 0?{}:{shown:a}});let o=await e(r);i===n&&t.setValue(o.ok?{status:`ready`,arg:r,data:o.data}:{status:`failed`,arg:r,error:o.error,...a===void 0?{}:{shown:a}})}}},jz=3e4,Mz={live:`Live`,new:`Off: new, not accepted yet`,changed:`Off: changed since it was accepted`,invalid:`Off: it has an error`},Nz={new:`ork watch --accept`,changed:`ork watch --accept`,invalid:`ork validate`},Pz=e=>new Date(e).toLocaleTimeString(void 0,{timeStyle:`short`}),Fz=e=>[Mz[e.standing],...e.lookedAt===void 0?[]:[`Last looked ${Pz(e.lookedAt)}`],...e.error===void 0?[]:[`Last look failed: ${e.error}`],...e.held===void 0?[]:[`Waiting: ${e.held}`]],Iz=()=>{let{triggers:e}=qy(),t=ab(e.state);(0,V.useEffect)(()=>{e.load();let t=setInterval(()=>{e.load()},jz);return()=>{clearInterval(t)}},[e]);let n=kz(t)?.data;return n===void 0||n.triggers.length===0?null:(0,G.jsxs)(`section`,{"aria-label":`Triggers`,className:Ww.triggers,children:[(0,G.jsx)(`h3`,{className:Ww.triggersTitle,children:`Triggers`}),n.pid===void 0?(0,G.jsxs)(`p`,{className:Ww.note,children:[(0,G.jsx)(`code`,{children:`ork watch`}),` isn't running, so nothing is looking.`]}):null,(0,G.jsx)(`ul`,{className:Ww.triggerList,children:n.triggers.map(e=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:Ww.triggerName,children:e.trigger}),` starts `,(0,G.jsx)(`code`,{children:e.run}),`, every ${e.every}`,Fz(e).map(e=>(0,G.jsx)(`span`,{className:Ww.triggerLine,children:(0,G.jsx)(Wg,{text:e})},e)),Nz[e.standing]===void 0?null:(0,G.jsx)(`span`,{className:Ww.triggerCommand,children:(0,G.jsx)(YS,{command:Nz[e.standing]??``})})]},`${e.project}/${e.trigger}`))})]})},Lz=e=>ib(e.decisions,e=>new Set((e??[]).map(({runId:e})=>e))),Rz=e=>{let t=ab(e.projects.state);return(0,V.useEffect)(()=>{e.projects.load()},[e]),t.status===`ready`?t.data:[]},zz=e=>{let t=[...e.currentTarget.querySelectorAll(`button`)],n=t.findIndex(e=>e===document.activeElement),r=t.length-1,i={ArrowDown:Math.min(n+1,r),ArrowUp:Math.max(n-1,0),Home:0,End:r}[e.key];i!==void 0&&(e.preventDefault(),t[i]?.focus())},Bz=()=>{let e=qy(),t=ab(e.runs),n=ab(e.runFilter),r=ib(e.selection,({run:e})=>e),i=Lz(e),a=Rz(e),o=(0,V.useMemo)(()=>t??[],[t]),s=(0,V.useMemo)(()=>Oz(a,o),[a,o]),c=(0,V.useMemo)(()=>n===`all`?o:o.filter(e=>e.project===n),[o,n]),l=c.some(({id:e})=>e===r)?r:c[0]?.id;return(0,G.jsxs)(`div`,{className:Ww.panel,children:[(0,G.jsxs)(`div`,{className:Ww.tools,children:[(0,G.jsx)(Bw,{label:`Project`,onChange:t=>{e.runFilter.setValue(t)},options:s,value:n}),(0,G.jsx)(bz,{onClick:()=>{e.runDialog.setValue(!0)}})]}),(0,G.jsx)(`div`,{className:Ww.main,children:t===null?(0,G.jsx)(`p`,{className:Ww.note,children:`Reading runs…`}):c.length===0?(0,G.jsx)(xz,{filtered:n!==`all`}):(0,G.jsx)(`ul`,{"aria-label":`Runs`,className:Ww.list,onKeyDown:zz,children:c.map(t=>(0,G.jsx)(yz,{onSelect:e.selectRun,run:t,selected:t.id===r,tabStop:t.id===l,waiting:i.has(t.id)},t.id))})}),(0,G.jsx)(Iz,{})]})},Vz=e=>e.toLocaleString(`en`),Hz=e=>`≈${Vz(e)}`,Uz=e=>{let t=e.trim(),n=/^[a-z]+\s/u.test(t)?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:t;return n===``||/[.!?…]$/u.test(n)?n:`${n}.`},Wz=e=>e.reduce((e,t)=>e+(t.tokens??0),0),Gz=e=>{let t=e.filter(e=>e.state===`live`).length,n=e.length-t;return n===0?`${Vz(t)} live`:`${Vz(t)} live, ${Vz(n)} off`},Kz=(e,t,n=0)=>{let r=`${t(e.length)} · ${Hz(Wz(e))}`;return n===0?r:`${r}, ${Vz(n)} off`},qz=e=>`${Vz(e)} ${e===1?`file`:`files`}`,Jz=e=>`${Vz(e)} live`,Yz=e=>{let t=e.agent===void 0?[]:[{key:`agent/${e.agent.name}`,name:e.agent.name,source:e.agent.where,tokens:e.agent.tokens,text:e.agent.text??``,place:e.agent.where}],n=(e.instructionFiles??[]).map(e=>({key:`instructions/${e.name}`,name:e.name,tokens:e.tokens,text:e.text,place:e.name})),r=e.skills.map(e=>({key:`skill/${e.layer}/${e.name}`,name:e.name,state:e.state,layer:e.layer,source:e.source,tokens:e.tokens,...e.why===void 0?{}:{why:e.why},text:e.text??``,place:e.source===`built-in`?`built-in`:`${e.source}/SKILL.md`})),i=e.files.map((e,t)=>({key:`file/${e.layer}/${e.name}/${String(t)}`,name:e.name,layer:e.layer,tokens:e.tokens,text:e.text??``,place:e.name,...e.cutFrom===void 0?{}:{why:`cut at the lessons cap a session loads; the whole file is about ${Vz(e.cutFrom)} tokens`}})),a=[...e.practices.map(e=>({key:`practice/${e.name}`,name:e.name,state:`live`,tokens:e.tokens,text:e.text??``,place:`practice: ${e.name}`})),...e.skippedPractices.map(e=>({key:`practice/${e}`,name:e,state:`off`,why:`The project's own skill wins.`}))];return[{id:`agent`,title:`Agent`,meta:Hz(Wz(t)),empty:`No agent fills this node.`,pieces:t},{id:`instructions`,title:`Project instructions`,meta:Hz(Wz(n)),description:`Claude Code reads these itself; they aren't appended.`,empty:Uz(e.instructions),pieces:n},{id:`skills`,title:`Skills`,meta:r.length===0?`none`:Gz(r),description:`A skill's SKILL.md loads only when the session uses it.`,empty:`No skills.`,pieces:r},{id:`files`,title:`Context files`,meta:Kz(i,qz),empty:`No context files.`,pieces:i},{id:`practices`,title:`Practices`,meta:Kz(a.filter(e=>e.state===`live`),Jz,e.skippedPractices.length),empty:`No practices.`,pieces:a},{id:`appended`,title:`Appended system prompt`,meta:Hz(e.appendedTokens),description:"Everything Ork adds to Claude Code's system prompt, in the order the session reads it: the agent's role, the context files and practices above, Ork's own instructions to the node, and the node's `instructions`.",empty:`Nothing is appended.`,pieces:[{key:`appended`,name:`The whole prompt`,tokens:e.appendedTokens,text:e.appended??``,place:`system prompt, appended`}]}]},Xz=(e,t)=>t?`Couldn't update: ${Uz(e)} This is the answer from before.`:`Couldn't read the context: ${Uz(e)}`,Zz=e=>e===``?0:e.replace(/\n$/u,``).split(`
|
|
70
|
+
`).length,Qz=(e,t)=>{let n=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(n)?e.slice(n.length):e},$z=(e,t)=>`ork context explain ${e} ${t}`,eB={host:`_host_tnhom_9`,panel:`_panel_tnhom_17`,header:`_header_tnhom_36`,card:`_card_tnhom_37`,foot:`_foot_tnhom_38`,facts:`_facts_tnhom_54`,fact:`_fact_tnhom_54`,factName:`_factName_tnhom_71`,factValue:`_factValue_tnhom_85`,title:`_title_tnhom_95`,plannedLine:`_plannedLine_tnhom_107`,planned:`_planned_tnhom_107`,description:`_description_tnhom_117`,why:`_why_tnhom_118`,emptyText:`_emptyText_tnhom_119`,updating:`_updating_tnhom_132`,cardTitle:`_cardTitle_tnhom_142`,notice:`_notice_tnhom_151`,noticeIcon:`_noticeIcon_tnhom_174`,noticeWords:`_noticeWords_tnhom_190`,stack:`_stack_tnhom_194`,section:`_section_tnhom_203`,sectionHead:`_sectionHead_tnhom_219`,sectionNote:`_sectionNote_tnhom_230`,heading:`_heading_tnhom_241`,meta:`_meta_tnhom_251`,layer:`_layer_tnhom_252`,source:`_source_tnhom_253`,tokens:`_tokens_tnhom_254`,state:`_state_tnhom_255`,list:`_list_tnhom_266`,item:`_item_tnhom_272`,row:`_row_tnhom_281`,details:`_details_tnhom_318`,toggle:`_toggle_tnhom_341`,mark:`_mark_tnhom_342`,name:`_name_tnhom_365`,visuallyHidden:`_visuallyHidden_tnhom_426`,well:`_well_tnhom_437`,wellBar:`_wellBar_tnhom_449`,wellPlace:`_wellPlace_tnhom_466`,wellCopy:`_wellCopy_tnhom_473`,copied:`_copied_tnhom_482`,text:`_text_tnhom_488`},tB=({text:e})=>e.split(`≈`).map((e,t)=>t===0?e:(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`≈`}),(0,G.jsx)(`span`,{className:eB.visuallyHidden,children:`about `}),e]},t)),nB=({name:e,value:t})=>(0,G.jsxs)(`div`,{className:eB.fact,children:[(0,G.jsx)(`dt`,{className:eB.factName,children:e}),(0,G.jsx)(`dd`,{className:eB.factValue,children:(0,G.jsx)(tB,{text:t})})]}),rB=({node:e,type:t,from:n,appendedTokens:r,planned:i,reload:a,updating:o,cli:s,onReload:c,titleRef:l,children:u})=>(0,G.jsxs)(`header`,{className:eB.header,children:[(0,G.jsxs)(`dl`,{className:eB.facts,children:[(0,G.jsxs)(`div`,{className:eB.fact,children:[(0,G.jsx)(`dt`,{className:eB.factName,children:`Node`}),(0,G.jsx)(`dd`,{className:eB.factValue,children:(0,G.jsx)(`h2`,{className:eB.title,ref:l,tabIndex:-1,children:e})})]}),t===void 0?null:(0,G.jsx)(nB,{name:`Type`,value:t}),(0,G.jsx)(nB,{name:`From`,value:n}),r===void 0?null:(0,G.jsx)(nB,{name:`Appended`,value:`${Hz(r)} tokens`})]}),(0,G.jsxs)(`div`,{className:eB.plannedLine,children:[i===null?null:(0,G.jsx)(`p`,{className:eB.planned,children:i}),o?(0,G.jsx)(`span`,{className:eB.updating,children:`Updating…`}):null,(0,G.jsx)(q,{cli:s,onClick:c,variant:`ghost`,children:a})]}),u]}),iB=e=>`Changed after this run started: ${e.map(e=>`\`${e}\``).join(`, `)}. The run may have read ${e.length===1?`an older version`:`older versions`}.`,aB=({answer:e,error:t})=>{let n=e?.changedSinceStart??[],r=e?.planned===!0?e.explanation:null;return(0,G.jsxs)(G.Fragment,{children:[n.length===0?null:(0,G.jsxs)(`p`,{className:eB.notice,"data-note":`changed`,children:[(0,G.jsx)(`span`,{className:eB.noticeIcon,children:(0,G.jsx)(yy,{})}),(0,G.jsx)(`span`,{className:eB.noticeWords,children:(0,G.jsx)(Wg,{text:iB(n)})})]}),r?.template===void 0?null:(0,G.jsx)(`p`,{className:eB.notice,"data-note":`spawned`,children:(0,G.jsx)(`span`,{className:eB.noticeWords,children:(0,G.jsx)(Wg,{text:`\`${r.node}\` was spawned during the run, so it's planned as \`${r.template}\`, the node it was spawned from.`})})}),t===null?null:(0,G.jsxs)(`p`,{className:eB.notice,"data-note":`failed`,children:[(0,G.jsx)(`span`,{className:eB.noticeIcon,children:(0,G.jsx)(cD,{})}),(0,G.jsx)(`span`,{className:eB.noticeWords,children:(0,G.jsx)(Wg,{text:Xz(t,e!==null)})})]})]})},oB=({why:e})=>(0,G.jsxs)(`div`,{className:eB.card,children:[(0,G.jsx)(`p`,{className:eB.cardTitle,children:`No context to show.`}),(0,G.jsx)(`p`,{className:eB.description,children:(0,G.jsx)(Wg,{text:Uz(e)})})]}),sB=({cli:e,draft:t,sized:n})=>(0,G.jsxs)(`footer`,{className:eB.foot,children:[t?(0,G.jsx)(`p`,{className:eB.description,children:`The CLI reads the saved file, not the draft.`}):null,(0,G.jsx)(YS,{command:e}),n?(0,G.jsx)(`p`,{className:eB.description,children:`Tokens are estimates, about four characters each.`}):null]}),cB=({target:e})=>e?.kind===`run`?(0,G.jsx)(CC,{title:`No node chosen in this run.`,children:`Choose one in the Monitor, Logs or Chats.`}):e?.kind===`builder`?(0,G.jsx)(CC,{title:`No node selected in the Builder.`,children:`Select a card to see what its session loads.`}):(0,G.jsx)(CC,{cli:`ork context explain <workflow> <node>`,title:`No node chosen.`,children:`Choose one in the Monitor or the Builder, or in a terminal:`}),lB=({words:e,more:t})=>{let n=`${e}${t?`, `:``}`;return n===``?null:(0,G.jsx)(`span`,{className:eB.visuallyHidden,children:n})},uB=({piece:e})=>{let t=[e.state,e.layer,e.source,e.tokens],n=e=>t.slice(e).some(e=>e!==void 0),r=e.state!==void 0||e.layer!==void 0||e.source!==void 0;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:eB.mark,"data-state":e.state,children:e.state===void 0?null:e.state===`live`?(0,G.jsx)(Yv,{}):(0,G.jsx)(Iy,{})}),(0,G.jsxs)(`span`,{className:eB.name,children:[e.name,(0,G.jsx)(lB,{more:n(0),words:``})]}),r?(0,G.jsxs)(`span`,{className:eB.details,children:[e.state===void 0?null:(0,G.jsxs)(`span`,{className:eB.state,children:[e.state,(0,G.jsx)(lB,{more:n(1),words:``})]}),e.layer===void 0?null:(0,G.jsxs)(`span`,{className:eB.layer,children:[e.layer,(0,G.jsx)(lB,{more:n(2),words:` layer`})]}),e.source===void 0?null:(0,G.jsxs)(`span`,{className:eB.source,children:[e.source,(0,G.jsx)(lB,{more:n(3),words:``})]})]}):null,e.tokens===void 0?null:(0,G.jsxs)(`span`,{className:eB.tokens,children:[(0,G.jsx)(tB,{text:Hz(e.tokens)}),(0,G.jsx)(lB,{more:!1,words:` tokens`})]})]})},dB=({piece:e,id:t})=>{let n=e.text??``,r=Zz(n);return(0,G.jsxs)(`div`,{className:eB.well,id:t,children:[(0,G.jsxs)(`div`,{className:eB.wellBar,children:[(0,G.jsx)(`span`,{className:eB.wellPlace,children:e.place}),(0,G.jsx)(`span`,{children:(0,G.jsx)(tB,{text:`${r.toLocaleString(`en`)} ${r===1?`line`:`lines`}${e.tokens===void 0?``:` · ${Hz(e.tokens)} tokens`}`})}),(0,G.jsx)(`span`,{className:eB.wellCopy,children:(0,G.jsx)(qS,{label:`Copy the text of ${e.name}`,resultClass:eB.copied,text:n})})]}),n===``?(0,G.jsx)(`p`,{className:eB.emptyText,children:e.key===`appended`?`Nothing is appended.`:`This file is empty.`}):(0,G.jsx)(`pre`,{className:eB.text,children:n})]})},fB=({piece:e,open:t,onToggle:n})=>{let r=(0,V.useId)(),i=`${r}-why`,a=`${r}-text`,o=e.state??`live`,s=e.why===void 0?null:(0,G.jsx)(`p`,{className:eB.why,id:i,children:(0,G.jsx)(Wg,{text:Uz(e.why)})});return e.text===void 0?(0,G.jsxs)(`li`,{className:eB.item,children:[(0,G.jsxs)(`div`,{className:eB.row,"data-state":o,children:[(0,G.jsx)(`span`,{className:eB.toggle}),(0,G.jsx)(uB,{piece:e})]}),s]}):(0,G.jsxs)(`li`,{className:eB.item,children:[(0,G.jsxs)(`button`,{"aria-controls":t?a:void 0,"aria-describedby":e.why===void 0?void 0:i,"aria-expanded":t,className:eB.row,"data-piece":e.key,"data-state":o,onClick:()=>{n(e.key)},type:`button`,children:[(0,G.jsx)(`span`,{className:eB.toggle,children:t?(0,G.jsx)(Xv,{}):(0,G.jsx)(Zv,{})}),(0,G.jsx)(uB,{piece:e})]}),s,t?(0,G.jsx)(dB,{id:a,piece:e}):null]})},pB=({sections:e,opened:t,onToggle:n,busy:r})=>(0,G.jsx)(`div`,{"aria-busy":r,className:eB.stack,children:e.map(e=>(0,G.jsxs)(`section`,{className:eB.section,children:[(0,G.jsxs)(`div`,{className:eB.sectionHead,children:[(0,G.jsx)(`h3`,{className:eB.heading,children:e.title}),(0,G.jsx)(`span`,{className:eB.meta,children:(0,G.jsx)(tB,{text:e.meta})})]}),e.description===void 0?null:(0,G.jsx)(`p`,{className:eB.sectionNote,children:(0,G.jsx)(Wg,{text:e.description})}),e.pieces.length===0?(0,G.jsx)(`p`,{className:eB.sectionNote,children:(0,G.jsx)(Wg,{text:e.empty})}):(0,G.jsx)(`ul`,{className:eB.list,children:e.pieces.map(e=>(0,G.jsx)(fB,{onToggle:n,open:t.has(e.key),piece:e},e.key))})]},e.id))}),mB=e=>e.kind===`run`?`run/${e.run}/${e.node}`:`builder/${e.project}/${e.workflow}/${e.node}`,hB={answer:null,error:null,loading:!0},gB=e=>{let{client:t}=qy(),n=(0,V.use)(ZM),[r,i]=(0,V.useState)(hB),a=(0,V.useRef)(!1);a.current=r.answer!==null;let[o,s]=(0,V.useState)(0),c=e.kind===`builder`?e.revision:0,l=mB(e);(0,V.useEffect)(()=>{let r=!0;i(e=>({...e,loading:!0}));let o=e.kind===`run`?t.call(`runContext`,{params:{id:e.run,node:e.node}}):t.call(`builderContext`,{params:{id:e.project,name:e.workflow,node:e.node}});return(async()=>{let e=await o;r&&(e.ok||n?.announce(Xz(e.error,a.current)),i(t=>e.ok?{answer:e.data,error:null,loading:!1}:{answer:t.answer,error:e.error,loading:!1}))})(),()=>{r=!1}},[t,n,l,c,o]);let u=(0,V.useCallback)(()=>{s(e=>e+1)},[]);return{...r,reload:u}},_B=e=>{let t=ab(qy().runs);if(e.kind===`builder`)return{from:`Builder · ${e.workflow}${e.draft?` · draft`:``}`,cli:$z(e.workflow,e.node),planned:e.draft?`Planned from the unsaved draft. It updates after each edit.`:`Planned from the saved file.`};let n=t?.find(({id:t})=>t===e.run);return{from:n===void 0?e.run:`${n.workflow} · ${e.run}`,cli:$z(n===void 0?`<workflow>`:Qz(n.file,n.project),e.node),planned:`Planned from the project's files as they are now.`}},vB=({target:e,hadFocus:t})=>{let{answer:n,error:r,loading:i,reload:a}=gB(e),o=_B(e),[s,c]=(0,V.useState)(new Set),l=(0,V.useRef)(null),u=(0,V.useRef)(null),d=(0,V.useCallback)(e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),f=n?.planned===!0?n.explanation:null,p=(0,V.useMemo)(()=>f===null?[]:Yz(f),[f]),m=n===null?r===null?`loading`:`failed`:`shown`,h=(0,V.useRef)(null);return(0,V.useEffect)(()=>{let e=document.activeElement,n=e!==null&&l.current?.contains(e)===!0,r=(e===null||e===document.body)&&t.current,i=h.current!==m;h.current=m,(r||i&&n)&&u.current?.focus()},[m,n]),(0,G.jsxs)(`div`,{className:eB.panel,ref:l,children:[(0,G.jsx)(rB,{appendedTokens:f?.appendedTokens,cli:o.cli,from:o.from,node:e.node,onReload:a,planned:n?.planned===!1?null:o.planned,reload:r===null?`Reload`:`Try again`,titleRef:u,type:f?.type,updating:i&&n!==null,children:(0,G.jsx)(aB,{answer:n,error:r})}),n?.planned===!1?(0,G.jsx)(oB,{why:n.why}):null,f===null?null:(0,G.jsx)(pB,{busy:i,onToggle:d,opened:s,sections:p}),n===null&&r===null?(0,G.jsx)(`p`,{"aria-busy":`true`,className:eB.card,children:(0,G.jsx)(`span`,{className:eB.description,children:`Planning ${e.node}…`})}):null,m===`loading`?null:(0,G.jsx)(sB,{cli:o.cli,draft:e.kind===`builder`&&e.draft,sized:f!==null})]})},yB=({target:e,hadFocus:t})=>{let n=(0,V.useRef)(null);return(0,V.useEffect)(()=>{let e=document.activeElement;(e===null||e===document.body)&&t.current&&n.current?.focus()},[t]),(0,G.jsx)(`div`,{ref:n,tabIndex:-1,children:(0,G.jsx)(cB,{target:e})})},bB=({target:e,hadFocus:t})=>{if(e===null||e.node===null)return(0,G.jsx)(yB,{hadFocus:t,target:e});let n={...e,node:e.node};return(0,G.jsx)(vB,{hadFocus:t,target:n},mB(n))},xB=()=>{let e=ab(qy().contextTarget),t=(0,V.useRef)(!1);return(0,G.jsx)(`div`,{className:eB.host,onBlur:e=>{let n=e.relatedTarget;(n instanceof Node?!e.currentTarget.contains(n):e.target.isConnected)&&(t.current=!1)},onFocus:()=>{t.current=!0},children:(0,G.jsx)(bB,{hadFocus:t,target:e})})},SB=e=>e.slice(0,12),CB=[[`open`,`Not dismissed`],[`all`,`All`],[`new`,`New`],[`triaged`,`Triaged`],[`accepted`,`Accepted`],[`resolved`,`Resolved`],[`published`,`Published`],[`dismissed`,`Dismissed`]],wB=[{value:`all`,label:`All`},{value:`ork`,label:`ork`},{value:`workflow`,label:`workflow`},{value:`project`,label:`project`}],TB=(e,t)=>t===`all`?!0:t===`open`?e.status!==`dismissed`:e.status===t,EB=e=>CB.map(([t,n])=>({value:t,label:`${n} · ${String(e.filter(e=>TB(e,t)).length)}`})),DB=(e,{status:t,about:n})=>e.filter(e=>TB(e,t)&&(n===`all`||e.target===n)),OB=(e,t,n)=>e===1?`1 ${t}`:`${e.toLocaleString(`en`)} ${n}`,kB=e=>OB(e,`item`,`items`),AB=e=>OB(e,`time`,`times`),jB=e=>OB(e,`run`,`runs`),MB={open:`No items`,all:`No items`,new:`No new items`,triaged:`No triaged items`,accepted:`No accepted items`,resolved:`Nothing resolved`,published:`Nothing published`,dismissed:`Nothing dismissed`},NB=({status:e,about:t})=>{let n=MB[e]??`No items`,r=e===`open`&&t===`all`?`Every item is dismissed.`:`${n}${t===`all`?``:` about ${t}`}.`,i=[e===`all`?[]:[`Status: All`],t===`all`?[]:[`About: All`]].flat();return{title:r,body:`${i.join(` and `)} ${i.length>1?`show`:`shows`} every item.`}},PB=(e,t,n)=>{let r=e.findIndex(({id:e})=>e===n),i=t.filter(({id:e})=>e!==n);return i[Math.min(Math.max(r,0),i.length-1)]},FB=(e,t)=>e.find(e=>e.merged.includes(t)),IB={ok:!1,why:`reading what it allows`},LB=(e,...t)=>{if(!e.ok)return{ok:!1,why:e.why};let n=t.find(e=>e!==void 0);return n===void 0?{ok:!0}:{ok:!1,why:n}},RB=e=>{let t=e.lessons,[n]=t;return t.every(e=>!e.ok)&&n!==void 0&&!n.ok?n.error:void 0},zB=(e,t)=>{let n=SB(e.id),r=e=>{if(t===null)return IB;let{actions:n,project:r}=t;return e===`lesson`?LB(n.lesson,RB(t)):e===`apply`?LB(n.apply,r.ok?void 0:r.error):LB(n[e])},i={key:`accept`,word:`Accept`,cli:`ork feedback accept ${n}`,variant:`default`,check:r(`accept`)};return e.target===`ork`?[i,{key:`publish`,word:`Publish…`,cli:`ork feedback publish ${n}`,variant:`primary`,check:r(`publish`)}]:[i,{key:`lesson`,word:`Add lesson…`,cli:`ork feedback accept ${n} --lesson`,variant:`default`,check:r(`lesson`)},{key:`apply`,word:`Propose fix…`,cli:`ork feedback apply ${n}`,variant:`primary`,check:r(`apply`)}]},BB=(e,t)=>t.ok?e:`${e}: ${t.why}`,VB=e=>`Starts a run of \`ork:feedback-apply\` in \`${e}\`. It's a paid run, like any you start. A worker reads this item and that project's records of it, and Ork commits the smallest change that would stop it on a branch of its own, in a worktree. The worker reads and edits files and runs no commands. Then you're asked to keep or discard the branch, in Decisions.`,HB=({item:e,id:t,root:n,acts:r,open:i,onOpenChange:a})=>{let[o,s]=(0,V.useState)(``),c=(0,V.useRef)(!1);return(0,G.jsx)(SC,{cli:`ork feedback apply ${t}${o===``?``:` --driver ${o}`}`,confirm:`Start run`,description:VB(n??`its project`),finalFocus:()=>{let e=c.current;return c.current=!1,!e},onConfirm:async()=>{let t=await r.apply(e,o);return c.current=t===null,t},onOpenChange:a,open:i,pending:`Starting…`,title:`Propose a fix for ${t}?`,variant:`primary`,children:(0,G.jsx)(qw,{onChange:s,value:o})})},UB=(e,t)=>`about ${e.toLocaleString(`en`)} of ${t.toLocaleString(`en`)} tokens`,WB=(e,t,n)=>[`ork feedback accept ${SB(e.id)} --lesson`,...t===null||e.workflows.length<2?[]:[`--workflow ${sT(t)}`],...n===e.title||n.trim()===``?[]:[`-m ${sT(n)}`]].join(` `),GB=(e,t,n)=>e===null?`Choose a workflow.`:t.trim()===``?`Write the lesson first.`:n!==void 0&&!n.ok?n.error:null,KB=({place:e,cap:t})=>e.ok?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:J.place,children:[(0,G.jsx)(`span`,{className:J.caption,children:`Goes to `}),(0,G.jsx)(Wg,{text:`\`${e.file}\` in \`${e.root}\``})]}),(0,G.jsx)(ez,{label:`Now`,max:t,text:e.exists?UB(e.tokens,t):`no lessons file yet; this starts it`,value:e.tokens})]}):(0,G.jsx)(`p`,{className:J.note,children:(0,G.jsx)(Wg,{text:e.error})}),qB=({open:e,onOpenChange:t,item:n,detail:r,onAdd:i})=>{let a=n.workflows.length>1,[o,s]=(0,V.useState)(a?null:n.workflows[0]??null),[c,l]=(0,V.useState)(n.title),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),m=(0,V.useId)(),h=r.lessons.find(e=>e.workflow===o),g=GB(o,c,h),_=async()=>{if(g!==null||u)return;d(!0),p(null);let e=await i({lesson:!0,...c===n.title?{}:{text:c},...a&&o!==null?{workflow:o}:{}});d(!1),p(e),e===null&&t(!1)};return(0,G.jsx)(bC,{description:o===null?`Every later session of the workflow you choose reads it, in the workflow layer of its context.`:`Every later session of \`${o}\` reads it, in the workflow layer of its context.`,onOpenChange:e=>{u||t(e)},open:e,title:o===null?`Add a lesson`:`Add a lesson for \`${o}\``,children:(0,G.jsxs)(QL,{onSend:()=>{_()},children:[a?(0,G.jsx)(Bw,{label:`Workflow (required)`,onChange:e=>{s(e===``?null:e)},options:[{value:``,label:`Choose one`},...n.workflows.map(e=>({value:e,label:e}))],value:o??``}):null,(0,G.jsx)(Uw,{description:`Its first line is the entry; later lines sit under it.`,label:`Lesson`,multiline:!0,onChange:l,required:!0,value:c}),h===void 0?null:(0,G.jsx)(KB,{cap:r.lessonCap,place:h}),(0,G.jsx)(YS,{command:WB(n,o,c)}),(0,G.jsx)($L,{id:m,why:g}),(0,G.jsx)(eR,{text:f}),(0,G.jsxs)(xC,{children:[(0,G.jsx)(q,{disabled:u,onClick:()=>{t(!1)},type:`button`,variant:`ghost`,children:`Cancel`}),(0,G.jsx)(q,{"aria-describedby":m,"aria-keyshortcuts":ZL,disabled:g!==null||u,focusableWhenDisabled:!0,type:`submit`,variant:`primary`,children:u?`Adding…`:`Add lesson`})]})]})})},JB={slot:`_slot_17gek_6`,alert:`_alert_17gek_17`},YB=({id:e,words:t,takeFocus:n,onTryAgain:r})=>{let i=(0,V.useRef)(null);return(0,V.useEffect)(()=>{if(t===null)return;let e=document.activeElement,r=e===null||e===document.body||e.getAttribute(`aria-disabled`)===`true`;(n===`always`||r)&&i.current?.querySelector(`button`)?.focus()},[t,n]),(0,G.jsxs)(`div`,{className:JB.slot,ref:i,children:[(0,G.jsx)(`p`,{className:JB.alert,id:e,role:`alert`,children:t===null?null:(0,G.jsx)(Wg,{text:t})}),t===null||r===void 0?null:(0,G.jsx)(q,{onClick:r,variant:`ghost`,children:`Try again`})]})},XB=({url:e})=>(0,G.jsxs)(`a`,{className:J.link,href:e,rel:`noreferrer`,target:`_blank`,children:[e,(0,G.jsx)(Sy,{}),(0,G.jsx)(zw,{children:` (opens in a new tab)`})]}),ZB=({preview:e})=>e.plan.kind===`create`?(0,G.jsx)(`p`,{className:J.message,children:(0,G.jsx)(Wg,{text:`A new thread in the Agent feedback category of \`${e.repo}\`.`})}):(0,G.jsxs)(`p`,{className:J.message,children:[`A thread for this exists, so this goes on it as a +1 comment:`,` `,(0,G.jsx)(XB,{url:e.plan.url})]}),QB="Reading Ork's Discussions with your `gh`…",$B=`Nothing to show: the preview couldn't be read.`,eV=({id:e})=>(0,G.jsx)(`span`,{className:J.note,id:e,children:`From the last read`}),tV=({preview:e,reading:t,region:n,stale:r,staleId:i})=>{let a=e?.plan.kind!==`comment`,o=e===void 0?``:a?e.post.body:e.post.comment,s=a?`Body`:`Comment`,c=r&&e!==void 0;return(0,G.jsxs)(G.Fragment,{children:[e===void 0||!a?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:J.line,children:[(0,G.jsx)(`p`,{className:J.caption,children:`Title`}),c?(0,G.jsx)(eV,{}):null]}),(0,G.jsx)(`p`,{className:J.preview,"data-stale":r?``:void 0,children:e.post.title})]}),(0,G.jsxs)(`div`,{className:J.wellHead,children:[(0,G.jsxs)(`div`,{className:J.line,children:[(0,G.jsx)(`p`,{className:J.caption,children:s}),c?(0,G.jsx)(eV,{id:i}):null]}),o===``?null:(0,G.jsx)(`span`,{className:J.wellCopy,children:(0,G.jsx)(qS,{label:`Copy the ${s.toLowerCase()}`,text:o})})]}),(0,G.jsx)(`section`,{"aria-busy":t,"aria-describedby":c?i:void 0,"aria-label":`Text to post`,className:J.preview,"data-scrolls":``,"data-stale":r?``:void 0,ref:n,tabIndex:0,children:o===``?(0,G.jsx)(Wg,{text:t?QB:$B}):o}),(0,G.jsx)(`p`,{className:J.note,children:`This is the Markdown that is sent, as it is. Secrets, your projects' paths, your home folder, emails, host names and IP addresses are taken out.`})]})},nV=({children:e})=>(0,G.jsxs)(`div`,{className:J.dialogFoot,children:[(0,G.jsx)(`p`,{className:J.note,children:(0,G.jsx)(Wg,{text:"It posts with your own `gh` login."})}),(0,G.jsx)(`div`,{className:J.actions,children:e})]}),rV=({id:e})=>(0,G.jsx)(`p`,{className:J.note,id:e,children:(0,G.jsx)(Wg,{text:"Your workflows' and projects' folders' names become `<name>`."})}),iV=({id:e,url:t,kind:n,onClose:r})=>{let i=(0,V.useRef)(null);return(0,V.useEffect)(()=>{i.current?.focus()},[]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:J.result,ref:i,tabIndex:-1,children:n===`created`?`Posted`:`Added a +1`}),(0,G.jsx)(`p`,{className:J.message,children:(0,G.jsx)(XB,{url:t})}),(0,G.jsx)(`p`,{className:J.message,children:`${e} is published.`}),(0,G.jsx)(`div`,{className:J.actions,children:(0,G.jsx)(q,{onClick:r,children:`Close`})})]})},aV=e=>e.step===`reading`||e.step===`readFailed`?e.shown:`preview`in e?e.preview:void 0,oV=e=>e.step===`reading`||e.step===`readFailed`,sV=e=>/[.!?]$/u.test(e.trim())?e.trim():`${e.trim()}.`,cV=(e,t,n)=>{let[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)({step:`reading`}),s=(0,V.useRef)(0),c=(0,V.useCallback)(async n=>{s.current+=1;let r=s.current,i=await e.call(`publishPreview`,{params:{id:t},body:{hideNames:n}});r===s.current&&o(e=>{if(i.ok)return{step:`preview`,preview:i.data,changed:!1};let t=aV(e);return t===void 0?{step:`readFailed`,error:i.error}:{step:`readFailed`,error:i.error,shown:t}})},[e,t]);(0,V.useEffect)(()=>{c(!1)},[c]);let l=(e,t)=>{o(t===void 0?{step:`reading`}:{step:`reading`,shown:t}),c(e)},u=async i=>{o({step:`posting`,preview:i});let a=await e.call(`publish`,{params:{id:t},body:{hideNames:r,digest:i.digest}});if(a.ok){o({step:`posted`,url:a.data.url,kind:a.data.kind}),n();return}if(a.status!==409){o({step:`postFailed`,preview:i,error:a.error});return}let s=await e.call(`publishPreview`,{params:{id:t},body:{hideNames:r}});s.ok?s.data.digest===i.digest?o({step:`postFailed`,preview:i,error:a.error}):o({step:`preview`,preview:s.data,changed:!0}):o({step:`readFailed`,error:s.error,shown:i})};return{step:a,hideNames:r,setHideNames:e=>{i(e),l(e,aV(a))},tryAgain:()=>{a.step===`postFailed`?u(a.preview):l(r)},post:()=>{a.step===`preview`&&u(a.preview)}}},lV=`The text to post changed since you read it. Read it again before posting.`,uV=e=>e.step===`readFailed`?`Could not read Ork's Discussions: ${sV(e.error)} Nothing was sent.`:e.step===`postFailed`?`Could not post: ${sV(e.error)}`:null,dV=()=>{let e=document.activeElement;return e===null||e===document.body||e.getAttribute(`role`)===`dialog`},fV=e=>e.step===`reading`?`Reading the preview…`:null,pV=({client:e,item:t,id:n,region:r,onStep:i,onClose:a,onPosted:o})=>{let s=cV(e,t,o),{step:c,hideNames:l}=s,u=(0,V.useId)(),d=(0,V.useId)(),f=(0,V.useId)(),p=(0,V.useId)();if((0,V.useEffect)(()=>{i(c),c.step!==`posted`&&dV()&&r.current?.focus()},[c,i,r]),c.step===`posted`)return(0,G.jsx)(iV,{id:n,kind:c.kind,onClose:a,url:c.url});let m=aV(c),h=c.step===`posting`,g=m?.plan.kind===`comment`;return(0,G.jsxs)(G.Fragment,{children:[c.step===`preview`&&c.changed?(0,G.jsx)(`p`,{role:`alert`,children:lV}):null,m===void 0?null:(0,G.jsx)(ZB,{preview:m}),(0,G.jsx)(tV,{preview:m,reading:c.step===`reading`,region:r,stale:oV(c),staleId:p}),(0,G.jsx)(qC,{checked:l,describedBy:u,disabled:h,label:`Hide repository and workflow names`,onChange:s.setHideNames}),(0,G.jsx)(rV,{id:u}),(0,G.jsx)(YS,{command:`ork feedback publish ${n}${l?` --hide-names`:``}`}),(0,G.jsx)(YB,{id:f,onTryAgain:s.tryAgain,takeFocus:c.step===`postFailed`?`always`:`ifLost`,words:uV(c)}),(0,G.jsx)($L,{id:d,why:fV(c)}),(0,G.jsxs)(nV,{children:[(0,G.jsx)(q,{disabled:h,focusableWhenDisabled:!0,onClick:a,variant:`ghost`,children:`Cancel`}),(0,G.jsx)(q,{"aria-describedby":`${d} ${f}`,disabled:c.step!==`preview`,focusableWhenDisabled:!0,onClick:s.post,type:`button`,variant:`primary`,children:h?`Posting…`:g?`Post +1 comment`:`Post thread`})]})]})},mV=({open:e,onOpenChange:t,client:n,item:r,id:i,onPosted:a,onCancelled:o})=>{let s=(0,V.useRef)(null),c=(0,V.useRef)({busy:!1,tried:!1}),l=(0,V.useCallback)(e=>{let t=e.step===`posting`;c.current={busy:t,tried:c.current.tried||t||e.step===`posted`}},[]),u=()=>{c.current.busy||(c.current.tried||o(),c.current={busy:!1,tried:!1},t(!1))};return(0,G.jsx)(bC,{initialFocus:s,onOpenChange:e=>{e?t(!0):u()},open:e,size:`wide`,title:`Publish ${i} to Ork's Discussions`,children:(0,G.jsx)(pV,{client:n,id:i,item:r,onClose:u,onPosted:a,onStep:l,region:s})})},hV=({item:e,detail:t,acts:n})=>{let r=qy(),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(0),c=SB(e.id),l=e.status===`dismissed`,u=e=>{s(e=>e+1),a(e)},d=e=>{e||a(null)},f=t=>{t===`accept`?n.accept(e):u(t===`lesson`?`lesson`:t===`apply`?`apply`:`publish`)};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{"aria-label":`Actions on ${c}`,className:J.actions,role:`group`,children:[zB(e,t).map(({key:e,word:t,cli:n,variant:r,check:i})=>(0,G.jsx)(q,{"aria-label":BB(t,i),cli:n,disabled:!i.ok,focusableWhenDisabled:!0,onClick:()=>{f(e)},tip:i.ok?void 0:i.why,variant:r,children:t},e)),(0,G.jsx)(q,{cli:`ork feedback ${l?`restore`:`dismiss`} ${c}`,onClick:()=>{n.setStatus(e,l?`new`:`dismissed`)},variant:`ghost`,children:l?`Restore`:`Dismiss`},`status`)]}),e.target===`ork`?(0,G.jsx)(`p`,{className:J.note,children:`About Ork itself: it has no lesson or fix in your projects. Publish shares it with Ork's maintainers.`}):null,t===null?null:(0,G.jsx)(qB,{detail:t,item:e,onAdd:r=>n.addLesson(e,r,t.lessonCap),onOpenChange:d,open:i===`lesson`},`lesson-${String(o)}`),(0,G.jsx)(HB,{acts:n,id:c,item:e,onOpenChange:d,open:i===`apply`,root:t?.project.ok===!0?t.project.root:null},`fix-${String(o)}`),e.target===`ork`?(0,G.jsx)(mV,{client:r.client,id:c,item:e.id,onCancelled:()=>{n.announce(`Nothing was sent.`)},onOpenChange:d,onPosted:()=>{n.reloadAll()},open:i===`publish`},`publish-${String(o)}`):null]})},gV=({name:e,children:t})=>(0,G.jsxs)(`div`,{className:J.fact,children:[(0,G.jsx)(`dt`,{className:J.factName,children:e}),(0,G.jsx)(`dd`,{className:J.factValue,children:t})]}),_V=({name:e,values:t})=>t.length===0?null:(0,G.jsx)(gV,{name:e,children:t.join(`, `)}),vV=({item:e,onSplit:t})=>{let n=SB(e.id);return(0,G.jsxs)(`dl`,{className:J.facts,children:[(0,G.jsx)(gV,{name:`Item`,children:n}),(0,G.jsx)(gV,{name:`About`,children:e.target}),(0,G.jsx)(gV,{name:`Kind`,children:e.kind}),(0,G.jsx)(gV,{name:`Severity`,children:e.severity}),(0,G.jsx)(gV,{name:`Seen`,children:(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`${String(e.count)}×`}),(0,G.jsx)(zw,{children:AB(e.count)}),` in ${jB(e.runs.length)}`]})}),(0,G.jsx)(gV,{name:`First seen`,children:(0,G.jsx)(`time`,{dateTime:e.firstSeen,children:_z(e.firstSeen)})}),(0,G.jsx)(gV,{name:`Last seen`,children:(0,G.jsx)(`time`,{dateTime:e.lastSeen,children:_z(e.lastSeen)})}),(0,G.jsx)(_V,{name:`Workflows`,values:e.workflows}),(0,G.jsx)(_V,{name:`Models`,values:e.models}),(0,G.jsx)(_V,{name:`Sources`,values:e.sources}),e.merged.length===0?null:(0,G.jsxs)(gV,{name:`Merged`,children:[e.merged.map(SB).join(`, `),(0,G.jsx)(q,{cli:`ork feedback split ${n}`,onClick:t,variant:`ghost`,children:`Split`})]})]})},yV=({onBack:e})=>(0,G.jsxs)(q,{onClick:e,variant:`ghost`,children:[(0,G.jsx)(Qv,{}),`Back to items`]}),bV=({run:e,onOpen:t})=>(0,G.jsxs)(`p`,{className:J.line,children:[(0,G.jsx)(`span`,{className:J.lineIcon,children:(0,G.jsx)(Gv,{})}),(0,G.jsxs)(`span`,{className:J.message,children:[`Run `,(0,G.jsx)(`code`,{children:e}),` is proposing a fix.`]}),(0,G.jsx)(q,{"aria-label":`Open run ${e}`,onClick:()=>{t(e)},variant:`ghost`,children:`Open run`})]}),xV=e=>[_z(e.at),e.feedback.source,...e.feedback.code===void 0?[]:[e.feedback.code],`run ${e.runId}`,...e.node===void 0?[]:[e.node]].join(` · `),SV=({record:e,title:t,onOpenRun:n})=>{let{feedback:r,runId:i,node:a}=e;return(0,G.jsxs)(`li`,{className:J.record,children:[(0,G.jsxs)(`p`,{className:J.recordMeta,children:[(0,G.jsx)(`span`,{children:xV(e)}),(0,G.jsxs)(q,{onClick:()=>{n(i,a)},variant:`ghost`,children:[`Open run`,(0,G.jsx)(zw,{children:` ${i}${a===void 0?``:` at ${a}`}, ${_z(e.at)}`})]})]}),r.title===t?null:(0,G.jsx)(`h4`,{className:J.recordTitle,children:r.title}),r.body===``?null:(0,G.jsx)(`p`,{className:J.recordBody,children:r.body}),r.evidence.length===0?null:(0,G.jsxs)(`p`,{className:J.evidence,children:[(0,G.jsx)(`span`,{className:J.caption,children:`Evidence `}),r.evidence.join(`, `)]})]})},CV=({item:e,read:t,onOpenRun:n})=>{let r=SB(e.id),i=t.detail?.records;return(0,G.jsxs)(`div`,{className:J.section,children:[(0,G.jsx)(`h3`,{className:J.caption,children:i===void 0?`Records`:`Records · ${String(i.length)}, newest first`}),i===void 0&&t.error!==null?(0,G.jsxs)(`div`,{className:J.line,children:[(0,G.jsx)(`p`,{className:J.alert,role:`alert`,children:(0,G.jsx)(`span`,{children:(0,G.jsx)(Wg,{text:`Could not read the records: ${t.error}`})})}),(0,G.jsx)(q,{onClick:t.reload,variant:`ghost`,children:`Try again`})]}):null,i===void 0&&t.error===null?(0,G.jsx)(`p`,{"aria-busy":`true`,className:J.message,children:`Reading records…`}):null,i===void 0?null:(0,G.jsx)(`ol`,{"aria-label":`Records of ${r}, newest first`,className:J.records,role:`list`,children:i.toReversed().map(t=>(0,G.jsx)(SV,{onOpenRun:n,record:t,title:e.title},t.id))})]})},wV=({item:e,read:t,acts:n,narrow:r,onBack:i,onLeave:a})=>{let o=(0,V.useId)(),s=t.detail?.fixRun;return(0,G.jsxs)(`section`,{"aria-labelledby":o,className:J.detail,onKeyDown:e=>{let t=document.querySelector(`[data-modal]`)!==null;e.key===`Escape`&&!t&&a()},children:[r?(0,G.jsx)(yV,{onBack:i}):null,(0,G.jsxs)(`div`,{className:J.head,children:[(0,G.jsx)(`h2`,{className:J.title,"data-feedback-heading":``,id:o,tabIndex:-1,children:e.title}),(0,G.jsx)(SD,{pill:!0,status:e.status})]}),(0,G.jsx)(vV,{item:e,onSplit:()=>{n.split(e)}}),s===void 0?null:(0,G.jsx)(bV,{onOpen:n.openRun,run:s}),(0,G.jsx)(hV,{acts:n,detail:t.detail,item:e}),(0,G.jsx)(CV,{item:e,onOpenRun:n.openRun,read:t}),(0,G.jsx)(YS,{command:`ork feedback show ${e.id.slice(0,12)}`})]})},TV=e=>{let t=[...e.currentTarget.querySelectorAll(`button`)],n=t.findIndex(e=>e===document.activeElement),r=t.length-1,i={ArrowDown:Math.min(n+1,r),ArrowUp:Math.max(n-1,0),Home:0,End:r}[e.key];i!==void 0&&(e.preventDefault(),t[i]?.focus())},EV=()=>(0,G.jsx)(zw,{children:`, `}),DV=(0,V.memo)(({item:e,chosen:t,tabStop:n,onChoose:r})=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{"aria-current":t?`true`:void 0,className:J.row,"data-item":e.id,onClick:()=>{r(e.id)},tabIndex:n?0:-1,type:`button`,children:[(0,G.jsxs)(`span`,{className:J.rowTop,children:[(0,G.jsx)(`span`,{className:J.rowTitle,children:e.title}),(0,G.jsx)(EV,{}),(0,G.jsx)(SD,{status:e.status})]}),(0,G.jsx)(EV,{}),(0,G.jsxs)(`span`,{className:J.rowMeta,children:[(0,G.jsx)(`span`,{children:SB(e.id)}),(0,G.jsx)(EV,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`${String(e.count)}×`}),(0,G.jsx)(zw,{children:AB(e.count)})]}),(0,G.jsx)(EV,{}),(0,G.jsx)(`span`,{children:`${e.target} · ${e.kind}`}),e.severity===`high`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(EV,{}),(0,G.jsx)(`span`,{className:J.high,children:`high`})]}):null,e.merged.length===0?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(EV,{}),(0,G.jsx)(`span`,{children:`+${String(e.merged.length)} merged`})]}),(0,G.jsx)(EV,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(zw,{children:`last seen `}),(0,G.jsx)(`time`,{dateTime:e.lastSeen,children:_z(e.lastSeen)})]})]})]})}));DV.displayName=`FeedbackRow`;var OV=({items:e,chosen:t,onChoose:n})=>{let r=e.some(({id:e})=>e===t)?t:e[0]?.id;return(0,G.jsx)(`ul`,{"aria-label":`Feedback items`,className:J.list,onKeyDown:TV,role:`list`,children:e.map(e=>(0,G.jsx)(DV,{chosen:e.id===t,item:e,onChoose:n,tabStop:e.id===r},e.id))})},kV=({filter:e,items:t,count:n,updating:r,failed:i,onFilter:a,onReload:o})=>(0,G.jsxs)(`div`,{className:J.tools,children:[(0,G.jsx)(Bw,{label:`Status`,onChange:t=>{a({...e,status:t})},options:EB(t??[]),value:e.status}),(0,G.jsx)(Bw,{label:`About`,onChange:t=>{a({...e,about:t})},options:wB,value:e.about}),(0,G.jsxs)(`div`,{className:J.toolsEnd,children:[t===null?null:(0,G.jsx)(`span`,{className:J.count,children:kB(n)}),r?(0,G.jsx)(`span`,{className:J.updating,children:`Updating…`}):null,(0,G.jsx)(q,{cli:e.status===`all`||e.status===`dismissed`?`ork feedback list --all`:`ork feedback list`,onClick:o,variant:`ghost`,children:i?`Try again`:`Reload`})]})]}),AV=({error:e})=>(0,G.jsxs)(`p`,{className:J.alert,"data-tone":`failed`,role:`alert`,children:[(0,G.jsx)(`span`,{className:J.lineIcon,children:(0,G.jsx)(yy,{})}),(0,G.jsx)(`span`,{children:(0,G.jsx)(Wg,{text:`Could not read feedback: ${e}`})})]}),jV=({anything:e,filter:t})=>{if(!e)return(0,G.jsx)(CC,{cli:`ork feedback list`,title:`No feedback yet.`,children:`What gets in your runs' way lands here: Ork's own signals, the agents' reports and your notes. In a terminal:`});let{title:n,body:r}=NB(t);return(0,G.jsx)(CC,{title:n,children:r})},MV=(e,t,n,r)=>{e.arriveAt(n),r!==void 0&&e.selectNode(r),t?.goTo(`monitor`),requestAnimationFrame(()=>{let t=document.querySelector(`[data-run-heading="${n}"]`);t!==null&&(e.takeArrival(n),t.focus())})},NV=e=>{let{state:t,workspace:n,filter:r,narrow:i,choose:a,focus:o}=e,s=(0,V.useRef)(!1),c=()=>kz(t.feedback.state.getValue())?.data??[],l=(e,r)=>{MV(t,n,e,r)},u=async()=>{await t.feedback.load(),e.reloadDetail()};return{moving:s,setStatus:async(e,l)=>{let d=SB(e.id),f=DB(c(),r),p=await t.client.call(`feedbackStatus`,{params:{id:e.id},body:{status:l}});if(!p.ok){let e=l===`new`?`restore`:`dismiss`;Hy.add({title:`Could not ${e} ${d}`,description:p.error});return}s.current=!0,await u();let m=DB(c(),r);if(!m.some(({id:t})=>t===e.id)){let t=PB(f,m,e.id);a(t?.id??null),o(t===void 0?`list`:i?`heading`:{row:t.id})}s.current=!1,n?.announce(l===`dismissed`?`Dismissed ${d}. It's listed under All and Dismissed.`:`Restored ${d} as new.`)},accept:async e=>{let r=SB(e.id),i=await t.client.call(`accept`,{params:{id:e.id},body:{lesson:!1}});i.ok?(n?.announce(`Accepted ${r}.`),await u()):Hy.add({title:`Could not accept ${r}`,description:i.error})},addLesson:async(e,n,r)=>{let i=await t.client.call(`accept`,{params:{id:e.id},body:n});if(!i.ok)return`Could not add the lesson: ${i.error}`;let{lesson:a}=i.data;return Hy.add({title:`Lesson added`,description:a===void 0?`${SB(e.id)} is accepted.`:`\`${a.file}\` in \`${a.root}\`, ${UB(a.tokens,r)}. Every session of \`${a.workflow}\` reads it from now on.`}),u(),null},apply:async(e,n=``)=>{let r=await t.client.call(`apply`,{params:{id:e.id},body:n===``?{}:{driver:n}});if(!r.ok)return`Could not start the run: ${r.error}`;let{runId:i}=r.data;return Hy.add({title:`Run ${i} started`,description:`\`ork:feedback-apply\` is proposing a fix for ${SB(e.id)}. Its question comes to Decisions.`}),l(i),u(),null},split:async e=>{let r=SB(e.id),i=await t.client.call(`split`,{params:{id:e.id}});i.ok?(o(`heading`),n?.announce(`Split ${kB(i.data.moved)} back out of ${r}.`),await u()):Hy.add({title:`Could not split ${r}`,description:i.error})},openRun:(e,t)=>{l(e,t)},reloadAll:u,announce:e=>{n?.announce(e)}}},PV=5e3,FV=48,IV=16,LV=e=>{let t=ab(e.feedback.state),n=ab(e.runs),r=(0,V.useRef)(0),i=(0,V.useRef)(null),a=(0,V.useRef)(n),o=(0,V.useCallback)(async()=>{r.current=Date.now(),await e.feedback.load()},[e]);return(0,V.useEffect)(()=>(o(),()=>{i.current!==null&&clearTimeout(i.current),i.current=null}),[o]),(0,V.useEffect)(()=>{if(a.current===n||(a.current=n,i.current!==null))return;let e=Math.max(0,r.current+PV-Date.now());i.current=setTimeout(()=>{i.current=null,o()},e)},[n,o]),{read:t,load:o}},RV=(e,t,n)=>{let[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(``),[l,u]=(0,V.useState)(0),d=`${t??``}|${n}|${String(l)}`;(0,V.useEffect)(()=>{if(t===null)return()=>{};let n=!0;return e.call(`feedbackItem`,{params:{id:t}}).then(e=>(n&&(c(d),e.ok?(i({id:t,value:e.data}),o(null)):o({id:t,value:e.error})),e)),()=>{n=!1}},[e,t,d]);let f=(0,V.useCallback)(()=>{u(e=>e+1)},[]);return{detail:r?.id===t?r.value:null,error:a?.id===t?a.value:null,loading:t!==null&&s!==d,reload:f}},zV=e=>{let[t,n]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{let t=e.current;if(t===null)return()=>{};let r=new ResizeObserver(([e])=>{let t=e?.contentRect.width??0;if(t===0)return;let r=getComputedStyle(document.documentElement).fontSize,i=Number(r.replace(`px`,``))||IV;n(t<FV*i)});return r.observe(t),()=>{r.disconnect()}},[e]),t},BV=e=>e===void 0?``:[e.status,e.count,e.lastSeen,...e.merged].join(`|`),VV={heading:`[data-feedback-heading]`,list:`[data-feedback-list]`},HV=(e,t)=>e?.querySelector(typeof t==`string`?VV[t]:`[data-item="${t.row}"]`)??null,UV=e=>{let t=(0,V.useRef)(null),[,n]=(0,V.useState)(0);return(0,V.useEffect)(()=>{let n=t.current;if(n===null)return;let r=HV(e.current,n);r!==null&&(t.current=null,r.focus())}),(0,V.useCallback)(e=>{t.current=e,n(e=>e+1)},[])},WV=()=>{let e=(0,V.useRef)(!1);return{had:e,onFocus:()=>{e.current=!0},onBlur:t=>{let n=t.relatedTarget;(n instanceof Node?!t.currentTarget.contains(n):t.target.isConnected)&&(e.current=!1)}}},GV=()=>{let e=qy(),t=(0,V.use)(ZM),n=ab(e.feedbackFilter),{read:r,load:i}=LV(e),a=(0,V.useRef)(null),o=zV(a),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(`list`),d=kz(r)?.data??null,f=(0,V.useMemo)(()=>d??[],[d]),p=(0,V.useMemo)(()=>DB(f,n),[f,n]),m=p.find(({id:e})=>e===s),h=RV(e.client,m?.id??null,BV(m)),g=UV(a),_=WV(),v=(0,V.useCallback)(e=>{c(e),u(e===null?`list`:`detail`)},[]),y=NV({state:e,workspace:t,filter:n,narrow:o,choose:v,focus:g,reloadDetail:h.reload}),{moving:b}=y;return(0,V.useEffect)(()=>{if(s===null||d===null||b.current||p.some(({id:e})=>e===s))return;let e=FB(f,s);e!==void 0&&p.some(({id:t})=>t===e.id)?(c(e.id),t?.announce(`${SB(s)} was merged into ${SB(e.id)}.`)):o||(c(null),document.activeElement===document.body&&_.had.current&&g(`list`))},[s,d,f,p,o,t,g,b]),{root:a,narrow:o,read:r,all:d,items:f,shown:p,filter:n,chosen:s,item:m,detail:h,acts:y,focusWatch:_,showing:o?l:`both`,back:()=>{u(`list`);let e=s!==null&&p.some(({id:e})=>e===s);g(e?{row:s}:`list`)},choose:e=>{v(e),o&&g(`heading`)},setFilter:n=>{e.feedbackFilter.setValue(n),t?.announce(`${kB(DB(f,n).length)}.`)},reload:()=>{i(),h.reload()}}},KV=({view:e})=>{let{read:t,all:n,items:r,shown:i,filter:a,chosen:o}=e;return(0,G.jsxs)(`div`,{"aria-label":`Items`,className:J.card,"data-feedback-list":``,role:`group`,tabIndex:-1,children:[t.status===`failed`?(0,G.jsx)(AV,{error:t.error}):null,n===null&&t.status!==`failed`?(0,G.jsx)(`p`,{className:J.message,children:`Reading feedback…`}):null,n!==null&&i.length===0?(0,G.jsx)(jV,{anything:r.length>0,filter:a}):null,i.length===0?null:(0,G.jsx)(OV,{chosen:o,items:i,onChoose:e.choose})]})},qV=({view:e})=>{let{item:t,chosen:n,narrow:r}=e;return(0,G.jsxs)(`div`,{className:J.card,"data-feedback-detail":``,children:[t===void 0?null:(0,G.jsx)(wV,{acts:e.acts,item:t,narrow:r,onBack:e.back,onLeave:e.back,read:e.detail}),t===void 0&&r&&n!==null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yV,{onBack:e.back}),(0,G.jsx)(`p`,{className:J.message,children:`${SB(n)} isn't in this list any more.`})]}):null,t===void 0&&!r?(0,G.jsx)(`p`,{className:J.message,children:`Choose an item to read its records.`}):null]})},JV=()=>{let e=GV(),{read:t,all:n,filter:r,shown:i,showing:a,focusWatch:o,root:s}=e;return(0,G.jsxs)(`div`,{"aria-label":`Feedback`,className:J.panel,"data-layout":e.narrow?`narrow`:`wide`,onBlur:o.onBlur,onFocus:o.onFocus,ref:s,role:`group`,tabIndex:-1,children:[(0,G.jsx)(kV,{count:i.length,failed:t.status===`failed`,filter:r,items:n,onFilter:e.setFilter,onReload:e.reload,updating:t.status===`loading`&&n!==null}),(0,G.jsxs)(`div`,{className:J.body,children:[a===`detail`?null:(0,G.jsx)(KV,{view:e}),a===`list`?null:(0,G.jsx)(qV,{view:e})]})]})},YV=`all`,XV=[{value:`7`,label:`Last 7 days`},{value:`30`,label:`Last 30 days`},{value:`90`,label:`Last 90 days`},{value:YV,label:`All time`}],ZV=e=>e===YV,QV=(e,t)=>{if(ZV(e))return;let n=new Date(t);return new Date(n.getFullYear(),n.getMonth(),n.getDate()-(Number(e)-1)).toISOString()},$V=(e,t,n)=>[`ork usage`,...e?[`--all`]:[],`--since ${ZV(t)?`all`:`${t}d`}`,...n===void 0?[]:[`--by ${n}`]].join(` `),eH=92,tH=e=>String(e).padStart(2,`0`),nH=e=>`${String(e.getFullYear())}-${tH(e.getMonth()+1)}-${tH(e.getDate())}`,rH=e=>{let[t=0,n=1,r=1]=e.split(`-`).map(Number);return new Date(t,n-1,r)},iH=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()-(e.getDay()+6)%7),aH=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),oH=(e,t,n,r)=>{let i=new Map(e.map(e=>[e.key,e])),a=[];for(let e=n;e<=r;e=new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)){let t=nH(e);a.push(i.get(t)??{key:t,costUsd:0,sessions:0})}return a},sH=(e,t,n)=>{let r=e.groups.day,i=t===void 0?r[0]?.key:void 0;if(t===void 0&&i===void 0)return{unit:`day`,bars:[],maxUsd:0};let a=t===void 0?rH(i??``):aH(new Date(t)),o=aH(new Date(n)),s=oH(r,1,a,o),c=s.length>eH?`week`:`day`,l=c===`day`?s:oH(e.groups.week,7,iH(a),o);return{unit:c,bars:l,maxUsd:Math.max(0,...l.map(e=>e.costUsd))}},cH=e=>OD(e),lH=e=>{let t=[...e];return e=>OD(e,t)},uH=e=>e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(1)}M`,dH=e=>`${String(Math.round(e*100))}%`,fH={panel:`_panel_18mjp_9`,tools:`_tools_18mjp_35`,projectFilter:`_projectFilter_18mjp_51`,body:`_body_18mjp_58`,overview:`_overview_18mjp_81`,breakdowns:`_breakdowns_18mjp_94`,totals:`_totals_18mjp_108`,total:`_total_18mjp_108`,section:`_section_18mjp_147`,heading:`_heading_18mjp_156`,hintsSection:`_hintsSection_18mjp_165`,chartArea:`_chartArea_18mjp_174`,hints:`_hints_18mjp_165`,chartHead:`_chartHead_18mjp_190`,readout:`_readout_18mjp_202`,chart:`_chart_18mjp_174`,column:`_column_18mjp_229`,bar:`_bar_18mjp_244`,axis:`_axis_18mjp_273`,axisEvery:`_axisEvery_18mjp_274`,details:`_details_18mjp_315`,table:`_table_18mjp_323`,number:`_number_18mjp_369`,name:`_name_18mjp_381`,path:`_path_18mjp_396`,retry:`_retry_18mjp_406`,note:`_note_18mjp_410`,refused:`_refused_18mjp_417`,limits:`_limits_18mjp_484`},pH=e=>e.toSorted((e,t)=>t.costUsd-e.costUsd)[0],mH=e=>`${String(e)} session${e===1?``:`s`}`,hH=2,gH=6,_H=14,vH=e=>e<=gH?`always`:e<=_H?`wide`:`never`,yH=({bars:e})=>{let t=vH(e.length);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{"aria-hidden":!0,className:fH.axis,"data-labelled":t,children:[(0,G.jsx)(`span`,{children:e[0]?.key}),(0,G.jsx)(`span`,{children:e.at(-1)?.key})]}),(0,G.jsx)(`div`,{"aria-hidden":!0,className:fH.axisEvery,"data-labelled":t,children:e.map(e=>(0,G.jsx)(`span`,{children:e.key.slice(5)},e.key))})]})},bH=({series:e})=>{let{bars:t,unit:n}=e,r=t.filter(e=>e.costUsd>0||e.sessions>0).toReversed(),i=t.length-r.length,a=lH(r.map(e=>e.costUsd));return(0,G.jsxs)(`details`,{className:fH.details,children:[(0,G.jsx)(`summary`,{children:`Show as a table`}),(0,G.jsxs)(`table`,{className:fH.table,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`col`,children:n===`day`?`Day`:`Week of`}),(0,G.jsx)(`th`,{className:fH.number,scope:`col`,children:`Cost`}),(0,G.jsx)(`th`,{className:fH.number,scope:`col`,children:`Sessions`})]})}),(0,G.jsx)(`tbody`,{children:r.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:fH.name,scope:`row`,children:e.key}),(0,G.jsx)(`td`,{className:fH.number,children:a(e.costUsd)}),(0,G.jsx)(`td`,{className:fH.number,children:e.sessions})]},e.key))})]}),i===0?null:(0,G.jsxs)(`p`,{className:fH.note,children:[String(i),` `,n,i===1?``:`s`,` with no spend.`]})]})},xH=({series:e})=>{let[t,n]=(0,V.useState)(null),{bars:r,maxUsd:i,unit:a}=e,o=r.find(e=>e.key===t)??null,s=pH(r),c=o??s,l=r.at(-1)?.key,u=a===`day`?`Spend per day`:`Spend per week`,d=a===`day`?``:`week of `,f=s===void 0?u:`${u}, ${String(r.length)} ${a}s. The peak was ${cH(s.costUsd)} ${a===`day`?`on`:`in the week of`} ${s.key}.`;return(0,G.jsxs)(`section`,{"aria-label":u,className:fH.section,children:[(0,G.jsxs)(`div`,{className:fH.chartHead,children:[(0,G.jsx)(`h3`,{className:fH.heading,children:u}),c===void 0?null:(0,G.jsxs)(`p`,{className:fH.readout,children:[o===null?`Peak: `:``,d,c.key,c.key===l?` so far`:``,` · `,cH(c.costUsd),` ·`,` `,mH(c.sessions)]})]}),(0,G.jsx)(`div`,{"aria-label":f,className:fH.chart,onPointerLeave:()=>{n(null)},role:`img`,children:r.map(e=>(0,G.jsx)(`div`,{className:fH.column,"data-partial":e.key===l?``:void 0,"data-pointed":e.key===o?.key?``:void 0,onPointerEnter:()=>{n(e.key)},children:e.costUsd===0?null:(0,G.jsx)(`div`,{className:fH.bar,style:{height:`${String(Math.max(hH,e.costUsd/i*100))}%`}})},e.key))}),(0,G.jsx)(yH,{bars:r}),(0,G.jsx)(bH,{series:e})]})},SH=e=>e===void 0?`All projects`:`This project`,CH=e=>`$${e.toFixed(2)}`,wH=e=>new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}),TH=({limits:e})=>e.problems.length===0&&e.caps.length===0&&e.plan.length===0?null:(0,G.jsxs)(`section`,{"aria-label":`Limits`,className:fH.limits,children:[e.problems.map(e=>(0,G.jsx)(`p`,{className:fH.note,children:(0,G.jsx)(Wg,{text:e})},e)),e.caps.map(e=>(0,G.jsx)(ez,{label:`${SH(e.project)}, this ${e.window}`,max:e.capUsd,text:`${CH(e.spentUsd)} of ${CH(e.capUsd)}, resets ${wH(e.resetsAt)}`,value:Math.min(e.spentUsd,e.capUsd)},`${e.project??`all`}-${e.window}`)),e.plan.map(e=>(0,G.jsx)(`p`,{className:fH.note,children:`Your Claude plan's ${e.window.replaceAll(`_`,` `)} limit ${e.status===`rejected`?`was reached`:`is close`}${e.resetsAt===void 0?``:`; it resets ${wH(e.resetsAt)}`}.`},e.window))]}),EH=10,DH=({title:e,label:t,groups:n,total:r,nameOf:i,moreCommand:a})=>{let o=n.length-EH,s=n.slice(0,EH),c=lH(s.map(e=>e.costUsd));return(0,G.jsxs)(`section`,{"aria-label":e,className:fH.section,children:[(0,G.jsx)(`h3`,{className:fH.heading,children:e}),(0,G.jsxs)(`table`,{className:fH.table,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`col`,children:t}),(0,G.jsx)(`th`,{className:fH.number,scope:`col`,children:`Cost`}),(0,G.jsx)(`th`,{className:fH.number,scope:`col`,children:`Share`}),(0,G.jsx)(`th`,{className:fH.number,scope:`col`,children:`Sessions`}),(0,G.jsx)(`th`,{className:fH.number,scope:`col`,children:`From cache`})]})}),(0,G.jsx)(`tbody`,{children:s.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsxs)(`th`,{className:fH.name,scope:`row`,title:e.key,children:[i?.(e.key)??e.key,i===void 0?null:(0,G.jsx)(`span`,{className:fH.path,children:e.key})]}),(0,G.jsx)(`td`,{className:fH.number,children:c(e.costUsd)}),(0,G.jsx)(`td`,{className:fH.number,children:dH(r===0?0:e.costUsd/r)}),(0,G.jsx)(`td`,{className:fH.number,children:e.sessions}),(0,G.jsx)(`td`,{className:fH.number,children:dH(e.cacheHitRate)})]},e.key))})]}),o>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:fH.note,children:[`And `,o,` more that cost less. This lists them all:`]}),(0,G.jsx)(YS,{command:a})]}):null]})},OH=({error:e,command:t,retry:n})=>(0,G.jsxs)(`div`,{className:fH.section,children:[(0,G.jsxs)(`p`,{className:fH.refused,role:`alert`,children:[`Cannot read usage: `,(0,G.jsx)(Wg,{text:e})]}),(0,G.jsx)(`div`,{className:fH.retry,children:(0,G.jsx)(q,{onClick:n,children:`Try again`})}),(0,G.jsx)(`p`,{className:fH.note,children:`On a terminal, the same report:`}),(0,G.jsx)(YS,{command:t})]}),kH=({period:e,limits:t})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(TH,{limits:t}),(0,G.jsx)(CC,{cli:`ork run <workflow>`,title:ZV(e)?`Nothing spent yet.`:`Nothing spent in this period.`,children:`Claude sessions show here once they finish. Start one with Run workflow, or in a terminal:`})]}),AH=({report:e})=>{let{totals:t}=e,n=t.inputTokens+t.cacheReadTokens+t.cacheWriteTokens,r=[[`Spend`,cH(t.costUsd)],[`Runs with sessions`,String(t.runs)],[`Sessions`,String(t.sessions)],[`Tokens in`,uH(n)],[`Tokens out`,uH(t.outputTokens)],[`From cache`,dH(t.cacheHitRate)]];return(0,G.jsx)(`dl`,{className:fH.totals,children:r.map(([e,t])=>(0,G.jsxs)(`div`,{className:fH.total,children:[(0,G.jsx)(`dt`,{children:e}),(0,G.jsx)(`dd`,{children:t})]},e))})},jH=({report:e,since:t,now:n,period:r,everyProject:i,projectName:a})=>{let o=(0,V.useMemo)(()=>sH(e,t,n),[e,t,n]),s=e.totals.costUsd,c=e=>$V(i,r,e);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(TH,{limits:e.limits}),(0,G.jsxs)(`div`,{className:fH.overview,children:[(0,G.jsx)(AH,{report:e}),e.hints.length===0?null:(0,G.jsxs)(`section`,{"aria-label":`Worth a look`,className:fH.hintsSection,children:[(0,G.jsx)(`h3`,{className:fH.heading,children:`Worth a look`}),(0,G.jsx)(`ul`,{className:fH.hints,children:e.hints.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(Wg,{text:e.message})},e.code))})]}),(0,G.jsx)(`div`,{className:fH.chartArea,children:(0,G.jsx)(xH,{series:o})})]}),(0,G.jsxs)(`div`,{className:fH.breakdowns,children:[i?(0,G.jsx)(DH,{groups:e.groups.project,label:`Project`,moreCommand:c(`project`),nameOf:a,title:`By project`,total:s}):null,(0,G.jsx)(DH,{groups:e.groups.workflow,label:`Workflow`,moreCommand:c(`workflow`),title:`By workflow`,total:s}),(0,G.jsx)(DH,{groups:e.groups.model,label:`Model`,moreCommand:c(`model`),title:`By model`,total:s}),(0,G.jsx)(DH,{groups:e.groups.node,label:`Node`,moreCommand:c(`node`),title:`Costliest nodes`,total:s})]}),(0,G.jsx)(`p`,{className:fH.note,children:`Costs are Claude Code's own estimates. On a subscription they are not what you are billed. On a terminal:`}),(0,G.jsx)(YS,{command:c()})]})},MH=()=>{let e=qy(),t=ab(e.usage.state),n=ab(e.runs),r=ab(e.projects.state),i=ab(e.usageFilter),{project:a,period:o}=i,[s,c]=(0,V.useState)(0),l=kz(t),u=(0,V.useRef)(null),d=ib(e.runs,e=>e?.filter(e=>e.live!==`running`&&e.live!==`paused`).length??0);(0,V.useEffect)(()=>{e.projects.load()},[e]),(0,V.useEffect)(()=>{let t=Date.now(),n=QV(o,t);e.usage.load({now:t,period:o,query:{...a===`all`?{}:{project:a},...n===void 0?{}:{since:n}}})},[e,a,o,d,s]);let f=(0,V.useMemo)(()=>Oz(r.status===`ready`?r.data:[],n??[]),[r,n]),p=a===`all`;return(0,G.jsxs)(`div`,{className:fH.panel,children:[(0,G.jsxs)(`div`,{className:fH.tools,children:[(0,G.jsx)(`div`,{className:fH.projectFilter,children:(0,G.jsx)(Bw,{label:`Project`,onChange:t=>{e.usageFilter.setValue({...i,project:t})},options:f,value:a})}),(0,G.jsx)(Bw,{label:`Period`,onChange:t=>{e.usageFilter.setValue({...i,period:t})},options:XV,value:o})]}),(0,G.jsxs)(`section`,{"aria-busy":t.status===`loading`,"aria-label":`Usage report`,className:fH.body,ref:u,tabIndex:0,children:[t.status===`failed`?(0,G.jsx)(OH,{command:$V(p,o),error:t.error,retry:()=>{u.current?.focus(),c(s+1)}}):null,l===void 0?t.status===`failed`?null:(0,G.jsx)(`p`,{className:fH.note,children:`Reading usage…`}):l.data.totals.sessions===0?(0,G.jsx)(kH,{limits:l.data.limits,period:l.arg.period}):(0,G.jsx)(jH,{everyProject:l.arg.query.project===void 0,now:l.arg.now,period:l.arg.period,projectName:e=>f.find(t=>t.value===e)?.label??Ez(e),report:l.data,since:l.arg.query.since})]})]})},NH=(e,t)=>`${String(e)} ${t}${e===1?``:t.endsWith(`h`)?`es`:`s`}`,PH=e=>({worktrees:e.filter(e=>e.path!==null).length,branches:e.filter(e=>e.path===null).length}),FH=e=>{let{worktrees:t,branches:n}=PH(e);return[...t>0||n===0?[NH(t,`worktree`)]:[],...n>0?[NH(n,`branch`)]:[]].join(` · `)},IH=(e,t)=>{let n=e.flatMap(e=>e.items),{worktrees:r,branches:i}=PH(n),a=t??NH(e.filter(e=>e.items.length>0).length,`project`);return n.length===0?`No Ork worktrees or branches in ${a}.`:`${[...r>0?[NH(r,`worktree`)]:[],...i>0?[NH(i,`branch`)]:[]].join(` and `)} in ${a}.`},LH=(e,t,n)=>e===null?n?`the worktrees couldn't be read`:`reading worktrees`:e.some(e=>e.items.some(e=>e.state===`merged`))?null:t?`nothing merged into the current branch`:`nothing merged in these projects`,RH=e=>[e.root,...e.error===void 0?[e.head===null?`detached HEAD`:`current branch ${e.head}`]:[],...e.items.length===0?[]:[FH(e.items)]],zH=e=>[{text:`run ${e.runId}`,risk:!1},{text:e.nodeId,risk:!1},...e.path===null?[]:[{text:e.path,risk:!1}],...e.parts,...e.cleanKeeps===void 0?[]:[{text:`clean keeps it: ${e.cleanKeeps}`,risk:!1}]],BH=e=>e.run.known?`Open run ${e.runId} at ${e.nodeId}`:`Open run ${e.runId}: it isn't in Ork's records`,VH=e=>{let t=`${e.remove.label.replace(`…`,``)} ${e.label}…`;return e.remove.refusal===void 0?t:`${t}: ${e.remove.refusal}`},HH=(e,t,n,r)=>`cd ${sT(e)} && ork worktrees remove ${sT(t)}${n?` --branch`:``}${r?` --force`:``}`,UH=e=>e.path===null?`branch`:e.state===`detached`||e.branch===void 0?`detached`:`worktree`,WH=e=>({branch:`Delete branch \`${e.label}\``,detached:`Remove the worktree of \`${e.label}\``,worktree:`Remove \`${e.label}\``})[UH(e)],GH=(e,t)=>{let n=UH(e),r=n===`branch`?`It has no worktree. Deletes the branch from \`${t}\`.`:n===`detached`?`Removes the detached worktree. It has no branch of Ork's.`:e.missing?`Its folder is gone. Removing it drops git's record of the worktree. The branch stays unless you delete it too.`:`Removes its worktree. The branch stays unless you delete it too.`;return e.checkedOut===void 0?r:`${r} It's on \`${e.checkedOut}\`, the workflow's own branch, which Ork never deletes; removing the worktree loses nothing committed.`},KH=(e,t)=>e.merged?`It's merged into \`${t}\`.`:`It has ${NH(e.ahead,`commit`)} not merged into \`${t}\`; deleting it loses them.`,qH=e=>e.force?`Continue…`:e.removeWorktree&&e.deleteBranch?`Remove worktree and branch`:e.deleteBranch?`Delete branch`:e.prunes?`Prune`:`Remove worktree`,JH=e=>{if(!e.force)return null;let{losing:t}=e;if(t.changes.length>0)return`It has uncommitted changes; the next step shows what's lost.`;let n=NH(t.commits.length+t.more.commits,`commit`);return t.commitsOn===`no branch`?`It holds ${n} on no branch; the next step shows them.`:`Deleting the branch loses ${n}; the next step shows them.`},YH=(e,t)=>t.removeWorktree&&t.deleteBranch?`Removed ${e.label}'s worktree and deleted its branch.`:t.deleteBranch?`Deleted branch ${e.label}.`:t.prunes?`Pruned ${e.label}'s missing worktree.`:`Removed ${e.label}'s worktree.`,XH=e=>[...e.losing.changes.length>0?[`Uncommitted changes can't be recovered.`]:[],...e.losing.commits.length>0?[`Deleted commits stay only in git's reflog, until it expires.`]:[]].join(` `),ZH=(e,t)=>`cd ${sT(e)} && ork worktrees clean${t?` --branches`:``}`,QH=`[data-worktree-row]`,$H=(e,t)=>[...e?.querySelectorAll(QH)??[]].findIndex(e=>e.dataset.worktreeRow===t),eU=(e,t)=>{let n=qy(),r=(0,V.use)(ZM),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(new Set),u=(0,V.useRef)(`back`),d=(0,V.useRef)(null),f=(0,V.useRef)(0),p=(0,V.useMemo)(()=>({openRun:e=>{MV(n,r,e.runId,e.nodeId)},remove:(t,n)=>{u.current=`back`,a({kind:`remove`,row:t,project:n,target:{project:n.root,key:t.key},index:$H(e.current,t.key),id:f.current+1}),f.current+=1,s(!0)}}),[n,r,e]),m=t=>{let n=e.current?.querySelectorAll(QH)??[];return n[Math.min(t,n.length-1)]?.querySelector(`[data-act="remove"]`)??e.current?.querySelector(`[data-empty-title]`)??e.current??!1};return{opened:i,open:o,gone:c,rowActs:p,cleanButton:d,openClean:()=>{f.current+=1,a({kind:`clean`,id:f.current}),s(!0)},close:()=>{s(!1)},removed:(e,n,i,a)=>{r?.announce(YH(e,i)),u.current=a,l(t=>new Set([...t,`${n.root}|${e.key}`])),s(!1),t().finally(()=>{l(new Set)})},removeFocus:()=>typeof u.current==`number`?m(u.current):u.current===`back`,cleanClosed:e=>{e||r?.announce(`Nothing was removed.`),s(!1)},cleanFocus:()=>d.current??!0,openRemovedRun:e=>{u.current=`run`,s(!1),MV(n,r,e.runId,e.nodeId)}}},tU=(e,t)=>t===`all`?[...e]:e.filter(e=>e.root===t),nU=(e,t)=>({...e,name:t}),rU=()=>{let e=qy(),t=(0,V.use)(ZM),n=ab(e.worktrees.state),r=ab(e.worktreesFilter),i=ab(e.runs),a=ab(e.projects.state),o=(0,V.useRef)(0),s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=(0,V.useRef)(i),u=(0,V.useCallback)(()=>{if(s.current!==null)return s.current;o.current=Date.now();let t=e.worktrees.load().finally(()=>{s.current=null});return s.current=t,t},[e]);(0,V.useEffect)(()=>(u(),e.projects.state.getValue().status===`idle`&&e.projects.load(),()=>{c.current!==null&&clearTimeout(c.current),c.current=null}),[u,e]),(0,V.useEffect)(()=>{if(l.current===i||(l.current=i,c.current!==null))return;let e=Math.max(0,o.current+PV-Date.now());c.current=setTimeout(()=>{c.current=null,u()},e)},[i,u]);let d=kz(n)?.data.projects??null,f=Oz(kz(a)?.data??[],[...i??[],...(d??[]).map(e=>({project:e.root}))]),p=e=>f.find(t=>t.value===e)?.label??e,m=(d??[]).map(e=>nU(e,p(e.root))),h=f.flatMap(e=>m.filter(t=>t.root===e.value)),g=d===null?null:tU(h,r);return{read:n,all:d===null?null:h,shown:g,filter:r,options:f,load:u,setFilter:n=>{e.worktreesFilter.setValue(n);let r=n===`all`?null:p(n);t?.announce(IH(tU(h,n),r))}}},iU={panel:`_panel_jg5qy_10`,tools:`_tools_jg5qy_31`,card:`_card_jg5qy_32`,toolsEnd:`_toolsEnd_jg5qy_56`,count:`_count_jg5qy_66`,head:`_head_jg5qy_76`,name:`_name_jg5qy_85`,headMeta:`_headMeta_jg5qy_94`,list:`_list_jg5qy_106`,row:`_row_jg5qy_112`,rowName:`_rowName_jg5qy_143`,badge:`_badge_jg5qy_155`,meta:`_meta_jg5qy_159`,risk:`_risk_jg5qy_177`,actions:`_actions_jg5qy_185`,note:`_note_jg5qy_195`,message:`_message_jg5qy_196`,alert:`_alert_jg5qy_205`,alertIcon:`_alertIcon_jg5qy_218`,facts:`_facts_jg5qy_225`,factName:`_factName_jg5qy_239`,caption:`_caption_jg5qy_240`,factValue:`_factValue_jg5qy_261`,step:`_step_jg5qy_277`,reason:`_reason_jg5qy_287`,section:`_section_jg5qy_293`,title:`_title_jg5qy_303`,result:`_result_jg5qy_312`,resultLine:`_resultLine_jg5qy_323`,foot:`_foot_jg5qy_335`},aU={ArrowDown:e=>e+1,ArrowUp:e=>e-1,Home:()=>0,End:(e,t)=>t},oU=e=>{let t=aU[e.key],{target:n}=e;if(t===void 0||!(n instanceof HTMLElement))return;let r=n.dataset.act;if(r===void 0)return;let i=[...e.currentTarget.querySelectorAll(`[data-worktree-row] [data-act="${r}"]`)],a=i.length-1,o=i[Math.max(0,Math.min(a,t(i.indexOf(n),a)))];o!==void 0&&(e.preventDefault(),o.focus())},sU=(0,V.memo)(({row:e,project:t,acts:n})=>{let r=(0,V.useId)(),i=(0,V.useId)(),a=HH(t.root,e.key,e.path===null,!1),o=zH(e),{refusal:s}=e.remove;return(0,G.jsxs)(`li`,{className:iU.row,"data-worktree-row":e.key,children:[(0,G.jsxs)(`p`,{className:iU.rowName,children:[e.label,(0,G.jsx)(zw,{children:`, `})]}),(0,G.jsx)(`span`,{className:iU.badge,children:(0,G.jsx)(wD,{state:e.state})}),(0,G.jsx)(`p`,{className:iU.meta,id:r,children:o.map((e,t)=>(0,G.jsxs)(`span`,{className:e.risk?iU.risk:void 0,children:[e.text,t<o.length-1?` ·`:``]},t))}),(0,G.jsx)(`span`,{hidden:!0,id:i,children:`CLI: ${a}`}),(0,G.jsxs)(`div`,{className:iU.actions,children:[(0,G.jsx)(q,{"aria-label":BH(e),"data-act":`open`,disabled:!e.run.known,focusableWhenDisabled:!0,onClick:()=>{n.openRun(e)},tip:e.run.known?void 0:`It isn't in Ork's records.`,variant:`ghost`,children:`Open run`}),(0,G.jsx)(q,{"aria-describedby":`${r} ${i}`,"aria-label":VH(e),cli:a,"data-act":`remove`,disabled:s!==void 0,focusableWhenDisabled:!0,onClick:()=>{n.remove(e,t)},tip:s===void 0?void 0:`${s[0]?.toUpperCase()??``}${s.slice(1)}.`,children:e.remove.label})]})]})},(e,t)=>e.acts===t.acts&&e.project.root===t.project.root&&e.project.head===t.project.head&&JSON.stringify(e.row)===JSON.stringify(t.row)),cU=({project:e,acts:t})=>{let n=(0,V.useId)();return(0,G.jsxs)(`section`,{"aria-labelledby":n,className:iU.card,children:[(0,G.jsxs)(`div`,{className:iU.head,children:[(0,G.jsx)(`h3`,{className:iU.name,id:n,children:e.name}),(0,G.jsx)(`p`,{className:iU.headMeta,children:RH(e).join(` · `)})]}),e.error===void 0?(0,G.jsx)(`ul`,{"aria-label":`Worktrees in ${e.name}`,className:iU.list,children:e.items.map(n=>(0,G.jsx)(sU,{acts:t,project:e,row:n},n.key))}):(0,G.jsxs)(`p`,{className:iU.alert,children:[(0,G.jsx)(`span`,{className:iU.alertIcon,children:(0,G.jsx)(cD,{})}),(0,G.jsx)(`span`,{children:(0,G.jsx)(Wg,{text:`Could not read ${e.name}'s worktrees: ${e.error}`})})]}),e.fix===void 0?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:iU.note,children:`If it moved, this points Ork at its new place:`}),(0,G.jsx)(YS,{command:e.fix})]})]})},lU=e=>e.filter(e=>e.steps.length>0),uU=e=>({worktrees:e.filter(e=>e.removeWorktree||e.prunes).length,branches:e.filter(e=>e.deleteBranch).length}),dU=e=>e.removeWorktree||e.deleteBranch||e.prunes,fU=e=>e.skip??`no worktree, branch kept`,pU=e=>{let[t]=e;return e.length===1&&t!==void 0?`Clean merged worktrees in ${t.name}`:`Clean merged worktrees in ${NH(e.length,`project`)}`},mU=e=>`Removes the worktrees of branches merged into ${e?`the project's current branch`:`each project's current branch`}, as the command below does. One with uncommitted changes, or checked out in the main checkout, is kept. Nothing is forced.`,hU=e=>{let{worktrees:t,branches:n}=uU(e),r=[...t>0?[`removes ${NH(t,`worktree`)}`]:[],...n>0?[`deletes ${NH(n,`branch`)}`]:[]].join(` and `),i=e.filter(e=>!dU(e)||e.skip!==void 0),a=new Map;for(let e of i)a.set(fU(e),(a.get(fU(e))??0)+1);let o=i.length===0?``:`Keeps ${String(i.length)}: ${[...a].map(([e,t])=>`${e} (${String(t)})`).join(`; `)}.`;return[r===``?`Nothing to clean.`:`${r.charAt(0).toUpperCase()}${r.slice(1)}.`,o].filter(e=>e!==``).join(` `)},gU=e=>{let{worktrees:t,branches:n}=uU(e.flatMap(e=>e.steps));return t===0&&n===0?null:t===0?`Delete ${NH(n,`branch`)}`:n===0?`Remove ${NH(t,`worktree`)}`:`Remove ${NH(t,`worktree`)} and ${NH(n,`branch`)}`},_U=e=>e.some(e=>e.error!==void 0)?`Cleaned in part`:`Cleaned`,vU={well:`_well_18f8h_7`},yU=({label:e,reading:t,describedBy:n,ref:r,steady:i=!1,short:a=!1,children:o})=>(0,G.jsx)(`section`,{"aria-busy":t!==void 0,"aria-describedby":n,"aria-label":e,className:vU.well,"data-short":a?``:void 0,"data-steady":i?``:void 0,ref:r,tabIndex:0,children:t===void 0?o:(0,G.jsx)(Wg,{text:t})}),bU=`Reading the plan…`,xU=`Nothing to show: the plan couldn't be read.`,SU=({reading:e,failed:t,well:n})=>(0,G.jsx)(yU,{label:`Plan`,reading:e?bU:void 0,ref:n,steady:!0,children:t?xU:`Nothing to clean.`}),CU=({checked:e,disabled:t,onChange:n})=>{let r=(0,V.useId)();return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(qC,{checked:e,describedBy:r,disabled:t,label:`Also delete the merged branches`,onChange:n}),(0,G.jsx)(`p`,{className:iU.note,id:r,children:`Only branches merged into the current branch, which git deletes without losing a commit.`})]})},wU=({project:e,branches:t,reading:n,failed:r,well:i})=>{let a=(0,V.useId)(),o=e.head??`its detached HEAD`;return(0,G.jsxs)(`section`,{"aria-label":e.name,className:iU.section,children:[(0,G.jsx)(`h3`,{className:iU.name,children:e.name}),(0,G.jsx)(`p`,{className:iU.headMeta,children:(0,G.jsx)(Wg,{text:`\`${e.root}\` · into \`${o}\``})}),(0,G.jsx)(`p`,{className:iU.message,id:a,children:n||r?``:hU(e.steps)}),(0,G.jsx)(`p`,{className:iU.caption,children:`Plan`}),(0,G.jsxs)(yU,{describedBy:a,label:`Plan for ${e.name}`,reading:n?bU:void 0,ref:i,steady:!0,children:[r?xU:null,e.steps.map(e=>(0,G.jsxs)(`span`,{children:[e.line.text,e.line.reason===void 0?null:(0,G.jsx)(`span`,{className:iU.reason,children:` (${e.line.reason})`}),`
|
|
71
|
+
`]},e.key))]}),(0,G.jsx)(`p`,{className:iU.note,children:(0,G.jsx)(Wg,{text:`In \`${e.root}\`:`})}),(0,G.jsx)(YS,{command:ZH(e.root,t)})]})},TU=({lines:e})=>(0,G.jsx)(`ul`,{className:iU.result,children:e.map(e=>(0,G.jsxs)(`li`,{className:iU.resultLine,children:[(0,G.jsx)(aD,{}),e]},e))}),EU=({results:e})=>{let t=(0,V.useRef)(null);return(0,V.useEffect)(()=>{t.current?.focus()},[]),(0,G.jsxs)(`div`,{className:iU.step,children:[(0,G.jsx)(`h3`,{className:iU.title,ref:t,tabIndex:-1,children:_U(e)}),e.filter(e=>e.done.length>0||e.error!==void 0).map(e=>(0,G.jsxs)(`section`,{"aria-label":e.name,className:iU.section,children:[(0,G.jsx)(`h4`,{className:iU.name,children:e.name}),e.error===void 0?null:(0,G.jsxs)(`p`,{className:iU.alert,children:[(0,G.jsx)(`span`,{className:iU.alertIcon,children:(0,G.jsx)(cD,{})}),(0,G.jsx)(`span`,{children:(0,G.jsx)(Wg,{text:`Stopped in ${e.name}: ${e.error}`})})]}),e.error===void 0||e.done.length===0?null:(0,G.jsx)(`p`,{className:iU.note,children:`Done before it stopped:`}),(0,G.jsx)(TU,{lines:e.done})]},e.root))]})},DU=e=>{if(e.step!==`done`)return`plan`in e?e.plan:e.shown},OU=(e,t,n)=>{let[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)({step:`reading`}),s=(0,V.useRef)(0),c=(0,V.useCallback)(async n=>{s.current+=1;let r=s.current,i=await e.call(`worktreesCleanPlan`,{body:{...t===void 0?{}:{project:t},branches:n}});return r===s.current?i:null},[e,t]),l=(0,V.useCallback)(async(n,r)=>{s.current+=1;let i=s.current,a=await e.call(`worktreesCleanPlan`,{body:{...t===void 0?{}:{project:t},branches:n}});i===s.current&&o(a.ok?{step:`plan`,plan:a.data,changed:!1}:{step:`readFailed`,error:a.error,...r===void 0?{}:{shown:r}})},[e,t]);(0,V.useEffect)(()=>{l(!1)},[l]);let u=(e,t)=>{o(t===void 0?{step:`reading`}:{step:`reading`,shown:t}),l(e,t)},d=async i=>{o({step:`cleaning`,plan:i});let a=await e.call(`worktreesClean`,{body:{...t===void 0?{}:{project:t},branches:r,digest:i.digest}});if(a.ok){o({step:`done`,results:a.data.projects}),n();return}if(a.status!==409){o({step:`cleanFailed`,plan:i,error:a.error});return}let s=await c(r);s!==null&&(s.ok&&s.data.digest!==i.digest?o({step:`plan`,plan:s.data,changed:!0}):o({step:`cleanFailed`,plan:i,error:a.error}))};return{step:a,branches:r,setBranches:e=>{i(e),u(e,DU(a))},clean:()=>{a.step===`plan`&&d(a.plan)},tryAgain:()=>{a.step===`cleanFailed`?d(a.plan):u(r,DU(a))}}},kU=e=>e.step===`readFailed`?`Could not read the plan: ${e.error}`:e.step===`cleanFailed`?`Could not clean: ${e.error}`:null,AU=e=>e.step===`reading`?`Reading the plan…`:e.step===`readFailed`?`The plan couldn't be read; Try again reads it.`:null,jU=e=>{let t=OU(e.client,e.project,e.onCleaned),{step:n}=t,r=(0,V.useRef)(null),i=(0,V.useId)(),a=(0,V.useId)(),o=n.step===`cleaning`,s=n.step===`reading`,c=DU(n),l=c===void 0?e.scope:lU(c.projects),u=gU(l),d=n.step===`plan`&&n.changed,f=c!==void 0&&!s&&u===null,p=n.step===`readFailed`&&c===void 0;(0,V.useEffect)(()=>{d&&r.current?.focus()},[d]),(0,V.useEffect)(()=>{if(s)return;let e=document.activeElement;(e===null||e===document.body||e.getAttribute(`role`)===`dialog`)&&r.current?.focus()},[s]);let m=()=>{o||e.onClose(n.step===`done`)};return(0,G.jsx)(bC,{description:mU(e.project!==void 0),finalFocus:e.finalFocus,initialFocus:r,onOpenChange:e=>{e||m()},open:e.open,size:`wide`,title:pU(l.length===0?e.scope:l),children:n.step===`done`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(EU,{results:n.results}),(0,G.jsx)(xC,{children:(0,G.jsx)(q,{onClick:m,children:`Close`})})]}):(0,G.jsxs)(G.Fragment,{children:[d?(0,G.jsx)(`p`,{role:`alert`,children:`The plan changed since you read it. Read it again before cleaning.`}):null,l.length===0?(0,G.jsx)(SU,{failed:p,reading:s,well:r}):null,l.map((e,n)=>(0,G.jsx)(wU,{branches:t.branches,failed:p,project:e,reading:s,well:n===0?r:void 0},e.root)),(0,G.jsx)(CU,{checked:t.branches,disabled:o,onChange:t.setBranches}),(0,G.jsx)(YB,{id:a,onTryAgain:t.tryAgain,takeFocus:n.step===`cleanFailed`?`always`:`ifLost`,words:kU(n)}),(0,G.jsx)($L,{id:i,why:AU(n)}),(0,G.jsxs)(xC,{children:[(0,G.jsx)(q,{disabled:o,focusableWhenDisabled:!0,onClick:m,variant:`ghost`,children:f?`Close`:`Cancel`}),f?null:(0,G.jsx)(q,{"aria-describedby":`${i} ${a}`,disabled:n.step!==`plan`,focusableWhenDisabled:!0,onClick:t.clean,variant:`primary`,children:o?`Removing…`:u??`Remove worktrees`})]})]})})},MU=(e,t,n)=>{let r=t?.parts.map(e=>e.text)??e.parts.map(e=>e.text.replace(/ not merged$/u,` not merged into ${n}`)),i=t?.merged??e.merged;return r.join(` · `)||(i?`merged into ${n}`:``)},NU=`Nothing to show: its state couldn't be read.`,PU=({name:e,children:t})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dt`,{className:iU.factName,children:e}),(0,G.jsx)(`dd`,{className:iU.factValue,children:t})]}),FU=({plan:e,label:t,reading:n})=>(0,G.jsx)(yU,{label:t,reading:n,steady:!0,children:e===void 0?NU:(0,G.jsxs)(G.Fragment,{children:[e.line.text,e.line.reason===void 0?null:(0,G.jsx)(`span`,{className:iU.reason,children:` (${e.line.reason})`})]})}),IU=e=>{let{row:t,project:n,plan:r}=e,i=(0,V.useId)(),a=n.head??`the current branch`;return(0,G.jsxs)(`div`,{className:iU.step,children:[(0,G.jsxs)(`dl`,{className:iU.facts,children:[(0,G.jsx)(PU,{name:`Project`,children:`${n.name} ${n.root}`}),(0,G.jsxs)(PU,{name:`Run`,children:[`${t.runId} · ${t.nodeId}`,(0,G.jsx)(q,{"aria-label":BH(t),disabled:!t.run.known||e.busy,focusableWhenDisabled:!0,onClick:e.onOpenRun,tip:t.run.known?void 0:`It isn't in Ork's records.`,variant:`ghost`,children:`Open run`})]}),t.path===null?null:(0,G.jsx)(PU,{name:`Path`,children:t.path}),(0,G.jsx)(PU,{name:`State`,children:MU(t,r,a)})]}),UH(t)===`worktree`&&t.branch!==void 0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(qC,{checked:e.deleteBranch,describedBy:i,disabled:e.busy,label:`Also delete the branch ${t.branch}`,onChange:e.onDeleteBranch}),(0,G.jsx)(`p`,{className:iU.note,id:i,children:(0,G.jsx)(Wg,{text:KH(r??t,a)})})]}):null,(0,G.jsx)(`p`,{className:iU.caption,children:`Plan`}),(0,G.jsx)(FU,{label:`Plan`,plan:r,reading:e.reading?`Reading its state…`:void 0}),(0,G.jsx)(YS,{command:HH(n.root,t.key,r?.deleteBranch??e.deleteBranch,r?.force??!1)})]})},LU=({title:e,label:t,lines:n,more:r})=>(0,G.jsxs)(`div`,{className:iU.section,children:[(0,G.jsx)(`p`,{className:iU.caption,children:(0,G.jsx)(Wg,{text:`${e} · ${String(n.length+r)}`})}),(0,G.jsx)(yU,{label:t,short:!0,children:n.join(`
|
|
72
|
+
`)}),r>0?(0,G.jsx)(`p`,{className:iU.note,children:`and ${String(r)} more`}):null]}),RU=({row:e,plan:t,head:n,root:r})=>{let i=(0,V.useRef)(null);(0,V.useEffect)(()=>{i.current?.focus()},[]);let{losing:a}=t,o=`Commits not merged into ${n}`;return(0,G.jsxs)(`div`,{className:iU.step,children:[(0,G.jsx)(`h3`,{className:iU.title,ref:i,tabIndex:-1,children:`What's lost`}),a.changes.length===0?null:(0,G.jsx)(LU,{label:`Uncommitted changes`,lines:a.changes,more:a.more.changes,title:`Uncommitted changes`}),a.commits.length===0?null:(0,G.jsx)(LU,{label:a.commitsOn===`no branch`?`Commits on no branch`:o,lines:a.commits,more:a.more.commits,title:a.commitsOn===`no branch`?`Commits on no branch`:`Commits not merged into \`${n}\``}),(0,G.jsx)(`p`,{className:iU.note,children:XH(t)}),(0,G.jsx)(YS,{command:HH(r,e.key,t.deleteBranch,!0)})]})},zU=e=>`plan`in e?e.plan:e.shown,BU=e=>e.step===`lost`||(e.step===`removing`||e.step===`removeFailed`)&&e.from===`lost`,VU=(e,t,n)=>{let[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)({step:`reading`}),s=(0,V.useRef)(0),c=(0,V.useCallback)(async n=>{s.current+=1;let r=s.current,i=await e.call(`worktreeRemovePlan`,{body:{...t,deleteBranch:n}});return r===s.current?i:null},[e,t]),l=(0,V.useCallback)(async(n,r)=>{s.current+=1;let i=s.current,a=await e.call(`worktreeRemovePlan`,{body:{...t,deleteBranch:n}});i===s.current&&o(a.ok?{step:`choice`,plan:a.data,changed:!1}:{step:`readFailed`,error:a.error,...r===void 0?{}:{shown:r}})},[e,t]);(0,V.useEffect)(()=>{l(!1)},[l]);let u=(e,t)=>{o(t===void 0?{step:`reading`}:{step:`reading`,shown:t}),l(e,t)},d=async(i,a)=>{o({step:`removing`,plan:i,from:a});let s=await e.call(`worktreeRemove`,{body:{...t,deleteBranch:r,force:i.force,digest:i.digest}});if(s.ok){n(i);return}if(s.status!==409){o({step:`removeFailed`,plan:i,from:a,error:s.error});return}let l=await c(r);l!==null&&(l.ok&&l.data.digest!==i.digest?o({step:`choice`,plan:l.data,changed:!0}):o({step:`removeFailed`,plan:i,from:a,error:s.error}))};return{step:a,deleteBranch:r,setDeleteBranch:e=>{i(e),u(e,zU(a))},goOn:()=>{a.step===`choice`&&a.plan.force?o({step:`lost`,plan:a.plan}):a.step===`choice`&&d(a.plan,`choice`)},back:()=>{a.step===`lost`&&o({step:`choice`,plan:a.plan,changed:!1})},loseIt:()=>{a.step===`lost`&&d(a.plan,`lost`)},tryAgain:()=>{a.step===`removeFailed`?d(a.plan,a.from):u(r,zU(a))}}},HU=`It changed since you read it. Read it again before removing.`,UU=(e,t)=>e.step===`readFailed`?`Could not read its state: ${e.error}`:e.step===`removeFailed`?`Could not remove ${t}: ${e.error}`:e.step===`choice`&&e.changed?HU:null,WU=e=>e.step===`reading`?`Reading its state…`:e.step===`readFailed`?`Its state couldn't be read; Try again reads it.`:e.step===`choice`?JH(e.plan):null,GU=({client:e,row:t,project:n,target:r,cancel:i,onBusy:a,onRemoved:o,onOpenRun:s,onClose:c})=>{let l=VU(e,r,o),{step:u}=l,d=(0,V.useId)(),f=(0,V.useId)(),p=(0,V.useRef)(null),m=u.step===`removing`,h=zU(u),g=BU(u),_=u.step===`choice`&&u.changed;(0,V.useEffect)(()=>{a(m)},[m,a]);let v=(0,V.useRef)(!1);(0,V.useEffect)(()=>{let e=v.current&&!g;v.current=g,(_||e)&&p.current?.focus()},[_,g]);let y=UU(u,t.label);return(0,G.jsxs)(G.Fragment,{children:[g&&h!==void 0?(0,G.jsx)(RU,{head:n.head??`the current branch`,plan:h,root:n.root,row:t}):(0,G.jsx)(IU,{busy:m,deleteBranch:l.deleteBranch,onDeleteBranch:l.setDeleteBranch,onOpenRun:s,plan:h,project:n,reading:u.step===`reading`,row:t}),(0,G.jsx)(YB,{id:f,onTryAgain:_?void 0:l.tryAgain,takeFocus:u.step===`removeFailed`?`always`:`ifLost`,words:y}),(0,G.jsx)($L,{id:d,why:WU(u)}),(0,G.jsxs)(`div`,{className:iU.foot,children:[g?(0,G.jsx)(q,{disabled:m,focusableWhenDisabled:!0,onClick:l.back,variant:`ghost`,children:`Back`}):null,(0,G.jsx)(q,{disabled:m,focusableWhenDisabled:!0,onClick:c,ref:i,variant:`ghost`,children:`Cancel`}),g?(0,G.jsx)(q,{"aria-describedby":f,disabled:u.step!==`lost`,focusableWhenDisabled:!0,onClick:l.loseIt,variant:`danger`,children:m?`Removing…`:`Remove and lose this work`}):(0,G.jsx)(q,{"aria-describedby":`${d} ${f}`,disabled:u.step!==`choice`,focusableWhenDisabled:!0,onClick:l.goOn,ref:p,variant:h?.force===!0?`default`:`primary`,children:m?`Removing…`:h===void 0?`Remove worktree`:qH(h)})]})]})},KU=({open:e,client:t,row:n,project:r,target:i,finalFocus:a,onRemoved:o,onOpenRun:s,onClose:c})=>{let l=(0,V.useRef)(null),u=(0,V.useRef)(!1),d=()=>{u.current||c()};return(0,G.jsx)(bC,{description:GH(n,r.root),finalFocus:a,initialFocus:l,onOpenChange:e=>{e||d()},open:e,size:`wide`,title:WH(n),children:(0,G.jsx)(GU,{cancel:l,client:t,onBusy:e=>{u.current=e},onClose:d,onOpenRun:s,onRemoved:o,project:r,row:n,target:i})})},qU=({acts:e,project:t,merged:n,load:r})=>{let{client:i}=qy(),{opened:a,open:o}=e;return a?.kind===`remove`?(0,G.jsx)(KU,{client:i,finalFocus:e.removeFocus,onClose:e.close,onOpenRun:()=>{e.openRemovedRun(a.row)},onRemoved:t=>{e.removed(a.row,a.project,t,a.index)},open:o,project:a.project,row:a.row,target:a.target},a.id):a?.kind===`clean`?(0,G.jsx)(jU,{client:i,finalFocus:e.cleanFocus,onCleaned:()=>void r(),onClose:e.cleanClosed,open:o,project:t,scope:n.map(({root:e,name:t,head:n})=>({root:e,name:t,head:n,steps:[]}))},a.id):null},JU=({filter:e,options:t,items:n,updating:r,cleanBlocked:i,cleanButton:a,onFilter:o,onClean:s,onReload:c})=>(0,G.jsxs)(`div`,{className:iU.tools,children:[(0,G.jsx)(Bw,{label:`Project`,onChange:o,options:t,value:e}),(0,G.jsxs)(`div`,{className:iU.toolsEnd,children:[n===null?null:(0,G.jsx)(`span`,{className:iU.count,children:FH(n)}),(0,G.jsx)(`output`,{className:iU.count,children:r?`Updating…`:``}),(0,G.jsx)(q,{"aria-label":i===null?void 0:`Clean merged…: ${i}`,cli:`ork worktrees clean`,disabled:i!==null,focusableWhenDisabled:!0,onClick:s,ref:a,tip:i===null?void 0:`Clean merged…: ${i}`,children:`Clean merged…`}),(0,G.jsx)(q,{cli:`ork worktrees`,onClick:c,tip:`In the project's folder.`,variant:`ghost`,children:`Reload`})]})]}),YU=({error:e})=>(0,G.jsxs)(`p`,{className:iU.alert,role:`alert`,children:[(0,G.jsx)(`span`,{className:iU.alertIcon,children:(0,G.jsx)(yy,{})}),(0,G.jsx)(`span`,{children:(0,G.jsx)(Wg,{text:`Could not read worktrees: ${e}`})})]}),XU=({projects:e,one:t})=>e===0?(0,G.jsxs)(CC,{cli:`ork register <path>`,focusable:!0,title:`No projects registered yet.`,children:[(0,G.jsx)(`p`,{children:`In a repository:`}),(0,G.jsx)(YS,{command:`ork init`}),(0,G.jsx)(`p`,{children:`Or from outside it:`})]}):t===null?(0,G.jsx)(CC,{cli:`ork worktrees`,focusable:!0,title:`No Ork worktrees or branches.`,children:(0,G.jsx)(Wg,{text:"A run with `worktree` nodes leaves a worktree and an `ork/` branch for each; they wait here until you remove them. In a terminal, in a project's folder:"})}):(0,G.jsx)(CC,{focusable:!0,title:`No Ork worktrees or branches in ${t}.`,children:`Project: All projects shows every project's.`}),ZU=(e,t)=>({...e,items:e.items.filter(n=>!t.has(`${e.root}|${n.key}`))}),QU={usage:{title:`Usage`,Icon:gy,Body:MH},context:{title:`Context`,Icon:vy,Body:xB},feedback:{title:`Feedback`,Icon:by,Body:JV},worktrees:{title:`Worktrees`,Icon:Cy,Body:()=>{let e=rU(),{read:t,shown:n,filter:r}=e,i=r===`all`?null:r,{panel:a,onFocus:o}=rL((n??[]).flatMap(e=>e.items.map(t=>`${e.root}|${t.key}`)).join(`
|
|
73
|
+
`),`[data-worktree-row]`),s=eU(a,e.load),c=(n??[]).map(e=>ZU(e,s.gone)),l=c.filter(e=>e.items.length>0||e.error!==void 0),u=c.length-l.length,d=c.filter(e=>e.items.some(e=>e.state===`merged`));return(0,G.jsxs)(`div`,{"aria-label":`Worktrees`,className:iU.panel,onFocus:o,onKeyDown:oU,ref:a,role:`group`,tabIndex:-1,children:[(0,G.jsx)(JU,{cleanBlocked:LH(n===null?null:c,i!==null,t.status===`failed`),cleanButton:s.cleanButton,filter:r,items:n===null?null:c.flatMap(e=>e.items),onClean:s.openClean,onFilter:e.setFilter,onReload:()=>void e.load(),options:e.options,updating:t.status===`loading`&&n!==null}),t.status===`failed`?(0,G.jsx)(YU,{error:t.error}):null,n===null&&t.status!==`failed`?(0,G.jsx)(`p`,{className:iU.message,children:`Reading worktrees…`}):null,n!==null&&l.length===0?(0,G.jsx)(XU,{one:i===null?null:c[0]?.name??i,projects:e.all?.length??0}):null,l.map(e=>(0,G.jsx)(cU,{acts:s.rowActs,project:e},e.root)),i===null&&l.length>0&&u>0?(0,G.jsx)(`p`,{className:iU.note,children:`Nothing left in ${NH(u,`other project`)}.`}):null,(0,G.jsx)(qU,{acts:s,load:e.load,merged:d,project:i??void 0})]})}}},$U={runs:{id:`runs`,title:`Runs`,Icon:uy,Body:Bz},monitor:{id:`monitor`,title:`Monitor`,Icon:dy,Body:fz},logs:{id:`logs`,title:`Logs`,Icon:fy,Body:jL},decisions:{id:`decisions`,title:`Decisions`,Icon:py,Body:iL},chats:{id:`chats`,title:`Chats`,Icon:my,Body:XM},notifications:{id:`notifications`,title:`Notifications`,Icon:hy,Body:Tz},usage:{id:`usage`,...QU.usage},builder:{id:`builder`,title:`Builder`,Icon:_y,Body:hM},context:{id:`context`,...QU.context},feedback:{id:`feedback`,...QU.feedback},worktrees:{id:`worktrees`,...QU.worktrees}},eW=Object.values($U),tW=e=>e in $U,nW=e=>$U[e],rW=(e,t)=>e===void 0?void 0:yT(e,t).join(t?``:`+`),iW=(e,t)=>{if(e.wide&&!e.open.includes(t))return e.minimized.includes(t)?`minimized`:`closed`},aW=({workspace:e})=>{let t=ab(e.view),n=ET(),r=[...eW.map(({id:r,title:i},a)=>({label:i,detail:iW(t,r),hint:rW(TT(a+1),n),onSelect:()=>{e.goTo(r)}})),`separator`,{label:`Reset layout`,onSelect:()=>{e.resetLayout()}}];return(0,G.jsx)(AE,{entries:r,trigger:(0,G.jsxs)(q,{variant:`ghost`,children:[`Window`,(0,G.jsx)(Xv,{})]})})},oW=({workspace:e})=>(0,G.jsxs)(`header`,{className:kT.bar,children:[(0,G.jsxs)(`h1`,{className:kT.name,children:[(0,G.jsx)(`img`,{alt:`Ork`,className:kT.logoOnDark,src:`/ork-wordmark-small.svg`}),(0,G.jsx)(`img`,{alt:`Ork`,className:kT.logoOnLight,src:`/ork-wordmark-small-on-light.svg`})]}),(0,G.jsx)(aW,{workspace:e}),(0,G.jsx)(`div`,{className:kT.spacer}),(0,G.jsx)(AT,{workspace:e}),(0,G.jsxs)(q,{onClick:()=>{e.palette.setValue(!0)},variant:`ghost`,children:[(0,G.jsx)(ry,{}),`Commands`,(0,G.jsx)(Kg,{keys:yT(CT.palette,ET())})]})]}),sW,cW=class{constructor(){}},lW=class extends cW{constructor(e,t,n,r){super(),this.viewId=e,this.groupId=t,this.panelId=n,this.tabGroupId=r}},uW=class extends cW{constructor(e,t){super(),this.viewId=e,this.paneId=t}},dW=class e{constructor(){}static getInstance(){return e.INSTANCE}hasData(e){return e&&e===this.proto}clearData(e){this.hasData(e)&&(this.proto=void 0,this.data=void 0)}getData(e){if(this.hasData(e))return this.data}setData(e,t){t&&(this.data=e,this.proto=t)}};sW=dW,dW.INSTANCE=new sW;function fW(){let e=dW.getInstance();if(e.hasData(lW.prototype))return e.getData(lW.prototype)[0]}function pW(){let e=dW.getInstance();if(e.hasData(uW.prototype))return e.getData(uW.prototype)[0]}var mW;(function(e){e.NONE={dispose:()=>{}};function t(e){return{dispose:()=>{e()}}}e.from=t})(mW||={});var Y=class{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=new Set(e)}addDisposables(...e){e.forEach(e=>this._disposables.add(e))}removeDisposable(e){this._disposables.delete(e)}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposables.forEach(e=>e.dispose()),this._disposables.clear())}},hW=class{constructor(){this._disposable=mW.NONE}get value(){return this._disposable===mW.NONE?void 0:this._disposable}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&=(this._disposable.dispose(),mW.NONE)}},gW;(function(e){e.map=(e,t)=>n=>e(e=>n(t(e))),e.any=(...e)=>t=>{let n=e.map(e=>e(t));return{dispose:()=>{n.forEach(e=>{e.dispose()})}}}})(gW||={});var _W=class{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}},vW=class{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}},yW=class{constructor(){this.events=new Map}get size(){return this.events.size}add(e,t){this.events.set(e,t)}delete(e){this.events.delete(e)}clear(){this.events.clear()}},bW=class e{static create(){return new e(Error(`listener stacktrace`).stack??``)}constructor(e){this.value=e}print(){console.warn(`dockview: stacktrace`,this.value)}},xW=class{constructor(e,t){this.callback=e,this.stacktrace=t}},X=class e{static setLeakageMonitorEnabled(t){t!==e.ENABLE_TRACKING&&e.MEMORY_LEAK_WATCHER.clear(),e.ENABLE_TRACKING=t}get value(){return this._last}constructor(e){this.options=e,this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=t=>{this.options?.replay&&this._last!==void 0&&t(this._last);let n=new xW(t,e.ENABLE_TRACKING?bW.create():void 0);return this._listeners.push(n),{dispose:()=>{let t=this._listeners.indexOf(n);t>-1?this._listeners.splice(t,1):e.ENABLE_TRACKING}}},e.ENABLE_TRACKING&&e.MEMORY_LEAK_WATCHER.add(this._event,bW.create())),this._event}fire(e){if(this._pauseTokens!==void 0&&this._pauseTokens.size>0)return;this.options?.replay&&(this._last=e);let t=this._listeners,n=t.length;if(n!==0){if(n===1)t[0].callback(e);else for(let n of t.slice())n.callback(e)}}pause(){let e={};return this._pauseTokens??=new Set,this._pauseTokens.add(e),mW.from(()=>this._pauseTokens?.delete(e))}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(e.ENABLE_TRACKING?queueMicrotask(()=>{for(let e of this._listeners)console.warn(`dockview: stacktrace`,e.stacktrace?.print());this._listeners=[]}):this._listeners=[]),e.ENABLE_TRACKING&&this._event&&e.MEMORY_LEAK_WATCHER.delete(this._event))}};X.ENABLE_TRACKING=!1,X.MEMORY_LEAK_WATCHER=new yW;function Z(e,t,n,r){return e.addEventListener(t,n,r),{dispose:()=>{e.removeEventListener(t,n,r)}}}var SW=class{constructor(){this._onFired=new X,this._currentFireCount=0,this._pending=new Set,this._queued=!1,this.onEvent=e=>{let t=this._currentFireCount;return this._onFired.event(n=>{this._currentFireCount>t&&e(n)})}}fire(e){this._currentFireCount++,this._pending.add(e),!this._queued&&(this._queued=!0,queueMicrotask(()=>{this._queued=!1;let e=this._pending;this._pending=new Set,this._onFired.fire(e)}))}dispose(){this._onFired.dispose()}},CW=class extends Y{constructor(e){super(),this._onDidChange=new X,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,wW(e,e=>{let t=e.target.scrollWidth>e.target.clientWidth,n=e.target.scrollHeight>e.target.clientHeight;this._value={hasScrollX:t,hasScrollY:n},this._onDidChange.fire(this._value)}))}};function wW(e,t){let n=new Set,r=new ResizeObserver(e=>{let r=!1,i;i=requestAnimationFrame(()=>{r=!0,i!==void 0&&n.delete(i);let a=e[0];t(a)}),r||n.add(i)});return r.observe(e),{dispose:()=>{r.unobserve(e),r.disconnect();for(let e of n)cancelAnimationFrame(e);n.clear()}}}var TW=(e,...t)=>{for(let n of t)e.classList.contains(n)&&e.classList.remove(n)},EW=(e,...t)=>{for(let n of t)e.classList.contains(n)||e.classList.add(n)},Q=(e,t,n)=>{let r=e.classList.contains(t);n&&!r&&e.classList.add(t),!n&&r&&e.classList.remove(t)};function DW(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function OW(e){return new kW(e)}var kW=class extends Y{constructor(e){super(),this._onDidFocus=new X,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new X,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=DW($W(e),e),n=!1,r=()=>{n=!1,t||(t=!0,this._onDidFocus.fire())},i=()=>{t&&(n=!0,globalThis.setTimeout(()=>{n&&(n=!1,t=!1,this._onDidBlur.fire())},0))};this._refreshStateHandler=()=>{DW($W(e),e)!==t&&(t?i():r())},this.addDisposables(Z(e,`focus`,r,!0)),this.addDisposables(Z(e,`blur`,i,!0))}refreshState(){this._refreshStateHandler()}},AW=`dv-quasiPreventDefault`;function jW(e){e[AW]=!0}function MW(e){return e[AW]}function NW(e,t){let n=e.composedPath?.call(e)??[];if(n.length>0)return t.some(e=>n.includes(e));let r=e.target;return r instanceof Node&&t.some(e=>e.contains(r))}function PW(e){let t=[],n=e.getRootNode();for(;zW(n);)t.push(n),n=n.host.getRootNode();return t}function FW(e,t){let n=t?.getRootNode(),r=e,i=r.getRootNode();for(;i!==n&&zW(i);)r=i.host,i=r.getRootNode();return r}function IW(e,t,n={}){let r=Array.from(t),{nonce:i}=n,a=typeof i==`function`?i(e):i;for(let t of r){if(t.href){let n=e.createElement(`link`);n.href=t.href,n.type=t.type,n.rel=`stylesheet`,a&&n.setAttribute(`nonce`,a),e.head.appendChild(n);continue}let n=[];try{t.cssRules&&(n=Array.from(t.cssRules).map(e=>e.cssText))}catch(e){console.warn(`dockview: failed to access stylesheet rules due to security restrictions`,e)}let r=e.createDocumentFragment();for(let t of n){let n=e.createElement(`style`);a&&n.setAttribute(`nonce`,a),n.appendChild(e.createTextNode(t)),r.appendChild(n)}e.head.appendChild(r)}}function LW(e){let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t+window.scrollX,top:n+window.scrollY,width:r,height:i}}function RW(e){let t=e;for(;t?.parentNode;)if(t.parentNode===document)return!0;else t=t.parentNode instanceof DocumentFragment?t.parentNode.host:t.parentNode;return!1}function zW(e){return!!e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&`host`in e&&!!e.host}function BW(e){let t=e.getRootNode();return t!==e&&typeof t.elementsFromPoint==`function`?t:e.ownerDocument??document}function VW(e,t){e.dataset.testid=t}function HW(e,t){let n=[];function r(t){if(t.nodeType===Node.ELEMENT_NODE){e.includes(t.tagName)&&n.push(t),t.shadowRoot&&r(t.shadowRoot);for(let e of t.children)r(e)}}return r(t instanceof Document?t.documentElement:t),n}function UW(e=document){let t=HW([`IFRAME`,`WEBVIEW`],e),n=new WeakMap;for(let e of t)n.set(e,e.style.pointerEvents),e.style.pointerEvents=`none`;return{release:()=>{for(let e of t)e.style.pointerEvents=n.get(e)??`auto`;t.splice(0,t.length)}}}function WW(e=document){let t=e instanceof Document?e:e.ownerDocument,n=t?.documentElement;if(!t||!n)return{release:()=>void 0};let r=[`user-select`,`-webkit-user-select`],i=r.map(e=>[e,n.style.getPropertyValue(e)]);for(let e of r)n.style.setProperty(e,`none`);let a=e=>e.preventDefault();return t.addEventListener(`selectstart`,a),{release:()=>{t.removeEventListener(`selectstart`,a);for(let[e,t]of i)t?n.style.setProperty(e,t):n.style.removeProperty(e)}}}function GW(e){function t(e){let t=[];for(let n=0;n<e.classList.length;n++)t.push(e.classList.item(n));return t}let n,r=e;for(;r!==null&&(n=t(r).find(e=>e.startsWith(`dockview-theme-`)),typeof n!=`string`);)if(r.parentElement===null){let e=r.getRootNode();r=zW(e)?e.host:null}else r=r.parentElement;return n}var KW=class{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(let e of this._classNames)Q(this.element,e,!1);this._classNames=e.split(` `).filter(e=>e.trim().length>0);for(let e of this._classNames)Q(this.element,e,!0)}},qW=100;function JW(e,t){let n=LW(e),r=LW(t);return!(n.left<r.left||n.left+n.width>r.left+r.width||n.top<r.top||n.top+n.height>r.top+r.height)}function YW(e){let t=new X,n=e.screenX,r=e.screenY,i,a=0,o=!1,s=()=>{if(o||e.closed)return;let c=e.screenX,l=e.screenY;(c!==n||l!==r)&&(clearTimeout(i),i=setTimeout(()=>{t.fire()},qW),n=c,r=l),a=requestAnimationFrame(s)};s();let c=t.dispose.bind(t);return t.dispose=()=>{o||(o=!0,cancelAnimationFrame(a),clearTimeout(i)),c()},t}function XW(e,t){let n;return new Y(Z(e,`resize`,()=>{clearTimeout(n),n=setTimeout(()=>{t()},qW)}),mW.from(()=>clearTimeout(n)))}function ZW(e,t,n){let r=n?.buffer??10,i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=0,s=0,c=i.left-a.left,l=i.top-a.top,u=i.bottom-a.bottom,d=i.right-a.right;c<r?o=r-c:d>r&&(o=-r-d),l<r?s=r-l:u>r&&(s=-u-r),(o!==0||s!==0)&&(e.style.transform=`translate(${o}px, ${s}px)`)}function QW(e){let t=e;for(;t&&(t.style.zIndex===`auto`||t.style.zIndex===``);)t=t.parentElement;return t}function $W(e){let t=e.getRootNode(),n=t.nodeType===Node.DOCUMENT_NODE?t:e.ownerDocument;return n&&typeof n.hasFocus==`function`&&!n.hasFocus()?null:t.activeElement??null}function eG(e){let t=e.getRootNode();return zW(t)?t:(e.ownerDocument??document).body}function tG(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function nG(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){tG(a,r,i,o,s,`next`,e)}function s(e){tG(a,r,i,o,s,`throw`,e)}o(void 0)})}}function rG(e){let t=oG(e);if(t)throw t}var iG=new Set([`javascript:`,`data:`,`blob:`,`vbscript:`,`file:`]),aG=250;function oG(e,t=globalThis.location){let n;try{n=new URL(e,t.href)}catch{return Error(`dockview: invalid popout URL: ${e}`)}if(iG.has(n.protocol))return Error(`dockview: popout URL must not use the "${n.protocol}" protocol, which would run in the opener's context; got: ${e}`);if(n.protocol!==t.protocol||n.host!==t.host)return Error(`dockview: popout URL must be same-origin with the page (${t.protocol}//${t.host}); got: ${e}`)}var sG=class extends Y{get window(){return this._window?.value??null}get failure(){return this._failure}constructor(e,t,n){super(),this.target=e,this.className=t,this.options=n,this._onWillClose=new X,this.onWillClose=this._onWillClose.event,this._onDidClose=new X,this.onDidClose=this._onDidClose.event,this._window=null,this.addDisposables(this._onWillClose,this._onDidClose)}dispose(){this.close(),super.dispose()}dimensions(){if(!this._window)return null;let e=this._window.value.screenX;return{top:this._window.value.screenY,left:e,width:this._window.value.innerWidth,height:this._window.value.innerHeight}}close(){var e,t;let n=this._window;n&&(this._window=null,this._onWillClose.fire(),(e=(t=this.options).onWillClose)==null||e.call(t,{id:this.target,window:n.value}),n.disposable.dispose(),this._onDidClose.fire())}open(){var e=this;return nG(function*(){var t,n;if(e._window)throw Error(`instance of popout window is already open`);let r=`${e.options.url}`;rG(r);let i=Object.entries({top:e.options.top,left:e.options.left,width:e.options.width,height:e.options.height}).map(([e,t])=>`${e}=${t}`).join(`,`),a=window.open(r,e.target,i);if(!a)return e._failure={reason:`blocked`},null;let o=new Y;e._window={value:a,disposable:o},o.addDisposables(mW.from(()=>{a.close()}),e.watchForClose(a),Z(globalThis.window,`beforeunload`,()=>{e.close()}));let s=e.createPopoutWindowContainer();return e.className&&s.classList.add(e.className),(t=(n=e.options).onDidOpen)==null||t.call(n,{id:e.target,window:a}),new Promise(t=>{let n=n=>{e._failure={reason:`unscriptable`,error:n instanceof Error?n:Error(String(n))},e.close(),t(null)};try{a.addEventListener(`unload`,()=>{})}catch(e){n(e);return}o.addDisposables(e.onWillClose(()=>{e._failure??={reason:`closed`},t(null)})),a.addEventListener(`load`,()=>{try{var r;let n=a.document;n.title=document.title,n.body.appendChild(s),IW(n,[...Array.from(globalThis.document.styleSheets),...globalThis.document.adoptedStyleSheets??[]],{nonce:e.options.nonce});let i=[];for(let t=(r=e.options).styleRoot?.call(r);zW(t);t=t.host.getRootNode())i.push(...Array.from(t.styleSheets??[]),...t.adoptedStyleSheets??[]);i.length>0&&IW(n,i,{nonce:e.options.nonce}),Z(a,`beforeunload`,()=>{e.close()}),t(s)}catch(e){n(e)}})})})()}watchForClose(e){if(typeof e.closed!=`boolean`)return mW.NONE;let t=setInterval(()=>{e.closed&&this.close()},aG);return mW.from(()=>{clearInterval(t)})}createPopoutWindowContainer(){let e=document.createElement(`div`);return e.classList.add(`dv-popout-window`),e.id=`dv-popout-window`,e.style.position=`absolute`,e.style.width=`100%`,e.style.height=`100%`,e.style.top=`0px`,e.style.left=`0px`,e}};function cG(e){if(e.length===0)throw Error(`Invalid tail call`);return[e.slice(0,e.length-1),e[e.length-1]]}function lG(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function uG(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.unshift(t))}function dG(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.push(t))}function fG(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(t(r))return n}return-1}function pG(e,t){let n=e.indexOf(t);return n>-1&&(e.splice(n,1),!0)}var mG=(e,t,n)=>t>n?t:Math.min(n,Math.max(e,t)),hG=()=>{let e=1;return{next:()=>(e++).toString()}},gG=(e,t)=>{let n=[];if(typeof t!=`number`&&(t=e,e=0),e<=t)for(let r=e;r<t;r++)n.push(r);else for(let r=e;r>t;r--)n.push(r);return n},_G=class{set size(e){this._size=e}setContainerGeometry(e,t){this._appliedStyles[e]!==t&&(this._appliedStyles[e]=t,this.container.style[e]=t)}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return this._cachedVisibleSize===void 0}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?``:`none`}constructor(e,t,n,r){this.container=e,this.view=t,this.disposable=r,this._cachedVisibleSize=void 0,this._appliedStyles={},typeof n==`number`?(this._size=n,this._cachedVisibleSize=void 0,e.classList.add(`visible`)):(this._size=0,this._cachedVisibleSize=n.cachedVisibleSize)}setVisible(e,t){if(e!==this.visible){if(e){let e=this._cachedVisibleSize??0;this._cachedVisibleSize=void 0,this.size=mG(e,this.viewMinimumSize,this.viewMaximumSize)}else this._cachedVisibleSize=typeof t==`number`?t:this.size,this.size=0;this.container.classList.toggle(`visible`,e),this.view.setVisible&&this.view.setVisible(e)}}scale(e){this._cachedVisibleSize===void 0?this.size=mG(Math.round(this.size*e),this.minimumSize,this.maximumSize):this._cachedVisibleSize=Math.round(this._cachedVisibleSize*e)}dispose(){return this.disposable.dispose(),this.view}},vG=function(e){return e.HORIZONTAL=`HORIZONTAL`,e.VERTICAL=`VERTICAL`,e}({});function yG(e,t,n){e.appliedLeft!==t&&(e.appliedLeft=t,e.container.style.left=t),e.appliedTop!==n&&(e.appliedTop=n,e.container.style.top=n)}var bG;(function(e){e.Distribute={type:`distribute`};function t(e){return{type:`split`,index:e}}e.Split=t;function n(e){return{type:`invisible`,cachedVisibleSize:e}}e.Invisible=n})(bG||={});var xG=class{get contentSize(){return this._contentSize}get size(){return this._size}set size(e){this._size=e}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get length(){return this.viewItems.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get proportionalLayout(){return this._proportionalLayout}set proportionalLayout(e){this._proportionalLayout!==e&&(this._proportionalLayout=e,e?this.saveProportions():this._proportions=void 0)}get orientation(){return this._orientation}set orientation(e){if(this._orientation===e)return;this._orientation=e;let t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,this.rescaleViews(this.size),TW(this.element,`dv-horizontal`,`dv-vertical`),this.element.classList.add(this.orientation==`HORIZONTAL`?`dv-horizontal`:`dv-vertical`)}get minimumSize(){return this.viewItems.reduce((e,t)=>e+t.minimumSize,0)}get maximumSize(){return this.length===0?1/0:this.viewItems.reduce((e,t)=>e+t.maximumSize,0)}get startSnappingEnabled(){return this._startSnappingEnabled}set startSnappingEnabled(e){this._startSnappingEnabled!==e&&(this._startSnappingEnabled=e,this.updateSashEnablement())}get endSnappingEnabled(){return this._endSnappingEnabled}set endSnappingEnabled(e){this._endSnappingEnabled!==e&&(this._endSnappingEnabled=e,this.updateSashEnablement())}get disabled(){return this._disabled}set disabled(e){this._disabled=e,Q(this.element,`dv-splitview-disabled`,e)}get margin(){return this._margin}get marginShare(){let e=0;for(let t of this.viewItems)t.visible&&e++;return this.marginShareFor(e)}set margin(e){this._margin=e,Q(this.element,`dv-splitview-has-margin`,e!==0)}constructor(e,t){this.container=e,this.viewItems=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this._contentSize=0,this._proportions=void 0,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this._disabled=!1,this._margin=0,this._onDidSashEnd=new X,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new X,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new X,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(e,t,n=this.viewItems.map(e=>e.size),r,i,a=-1/0,o=1/0,s,c)=>{if(e<0||e>this.viewItems.length)return 0;let l=gG(e,-1),u=gG(e+1,this.viewItems.length);if(i)for(let e of i)uG(l,e),uG(u,e);if(r)for(let e of r)dG(l,e),dG(u,e);let d=l.reduce((e,t)=>e+this.viewItems[t].minimumSize-n[t],0),f=l.reduce((e,t)=>e+this.viewItems[t].maximumSize-n[t],0),p=u.length===0?1/0:u.reduce((e,t)=>e+n[t]-this.viewItems[t].minimumSize,0),m=u.length===0?-1/0:u.reduce((e,t)=>e+n[t]-this.viewItems[t].maximumSize,0),h=Math.max(d,m),g=Math.min(p,f),_=!1;if(s){let e=this.viewItems[s.index],n=t>=s.limitDelta;_=n!==e.visible,e.setVisible(n,s.size)}if(!_&&c){let e=this.viewItems[c.index],n=t<c.limitDelta;_=n!==e.visible,e.setVisible(n,c.size)}if(_)return this.resize(e,t,n,r,i,a,o);let v=mG(t,h,g),y=0,b=v;for(let e of l){let t=this.viewItems[e],r=n[e],i=mG(r+b,t.minimumSize,t.maximumSize),a=i-r;y+=a,b-=a,t.size=i}let x=y;for(let e of u){let t=this.viewItems[e],r=n[e],i=mG(r-x,t.minimumSize,t.maximumSize),a=i-r;x+=a,t.size=i}return t},this._orientation=t.orientation??`VERTICAL`,this.element=this.createContainer(),this.margin=t.margin??0,this._proportionalLayout=t.proportionalLayout===void 0||!!t.proportionalLayout,this.viewContainer=this.createViewContainer(),this.sashContainer=this.createSashContainer(),this.element.appendChild(this.sashContainer),this.element.appendChild(this.viewContainer),this.container.appendChild(this.element),this.style(t.styles),t.descriptor&&(this._size=t.descriptor.size,t.descriptor.views.forEach((e,t)=>{let n=e.visible===void 0||e.visible?e.size:{type:`invisible`,cachedVisibleSize:e.size},r=e.view;this.addView(r,n,t,!0)}),this._contentSize=this.viewItems.reduce((e,t)=>e+t.size,0),this.saveProportions())}style(e){e?.separatorBorder===`transparent`?(TW(this.element,`dv-separator-border`),this.element.style.removeProperty(`--dv-separator-border`)):(EW(this.element,`dv-separator-border`),e?.separatorBorder&&this.element.style.setProperty(`--dv-separator-border`,e.separatorBorder))}isViewVisible(e){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);return this.viewItems[e].visible}setViewVisible(e,t){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);let n=this.viewItems[e];n.setVisible(t,n.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.viewItems.length?-1:this.viewItems[e].size}resizeView(e,t){if(e<0||e>=this.viewItems.length)return;let n=gG(this.viewItems.length).filter(t=>t!==e),r=[...n.filter(e=>this.viewItems[e].priority===`low`),e],i=n.filter(e=>this.viewItems[e].priority===`high`),a=this.viewItems[e];t=Math.round(t),t=mG(t,a.minimumSize,Math.min(a.maximumSize,this._size)),a.size=t,this.relayout(r,i)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(e,t){let n=this.viewItems.indexOf(e);if(n<0||n>=this.viewItems.length)return;t=typeof t==`number`?t:e.size,t=mG(t,e.minimumSize,e.maximumSize),e.size=t;let r=gG(this.viewItems.length).filter(e=>e!==n),i=[...r.filter(e=>this.viewItems[e].priority===`low`),n],a=r.filter(e=>this.viewItems[e].priority===`high`);this.relayout([...i,n],a)}addView(e,t=bG.Distribute,n=this.viewItems.length,r){let i=document.createElement(`div`);i.className=`dv-view`,i.appendChild(e.element);let a;if(typeof t==`number`)a=t;else if(t.type===`split`){let e=this.viewItems[t.index];if(e){let t=Math.floor(e.size/2);a=e.size-t,e.size=t}else a=this.getViewSize(t.index)/2}else a=t.type===`invisible`?{cachedVisibleSize:t.cachedVisibleSize}:e.minimumSize;let o=e.onDidChange(e=>this.onDidChange(s,e.size)),s=new _G(i,e,a,{dispose:()=>{o.dispose(),i.remove()}});if(n===this.viewItems.length?this.viewContainer.appendChild(i):this.viewContainer.insertBefore(i,this.viewContainer.children.item(n)),this.viewItems.splice(n,0,s),this.viewItems.length>1){let e=document.createElement(`div`);e.className=`dv-sash`;let t=t=>{for(let e of this.viewItems)e.enabled=!1;let n=e.ownerDocument??document,r=UW(n),i=this._orientation===`HORIZONTAL`?t.clientX:t.clientY,a=fG(this.sashes,t=>t.container===e),o=this.viewItems.map(e=>e.size),s,c,l=gG(a,-1),u=gG(a+1,this.viewItems.length),d=l.reduce((e,t)=>e+(this.viewItems[t].minimumSize-o[t]),0),f=l.reduce((e,t)=>e+(this.viewItems[t].viewMaximumSize-o[t]),0),p=u.length===0?1/0:u.reduce((e,t)=>e+(o[t]-this.viewItems[t].minimumSize),0),m=u.length===0?-1/0:u.reduce((e,t)=>e+(o[t]-this.viewItems[t].viewMaximumSize),0),h=Math.max(d,m),g=Math.min(p,f),_=this.findFirstSnapIndex(l),v=this.findFirstSnapIndex(u);if(typeof _==`number`){let e=this.viewItems[_],t=Math.floor(e.viewMinimumSize/2);s={index:_,limitDelta:e.visible?h-t:h+t,size:e.size}}if(typeof v==`number`){let e=this.viewItems[v],t=Math.floor(e.viewMinimumSize/2);c={index:v,limitDelta:e.visible?g+t:g-t,size:e.size}}let y=e=>{let t=(this._orientation===`HORIZONTAL`?e.clientX:e.clientY)-i;this.resize(a,t,o,void 0,void 0,h,g,s,c),this.distributeEmptySpace(),this.layoutViews()},b=()=>{for(let e of this.viewItems)e.enabled=!0;r.release(),this.saveProportions(),n.removeEventListener(`pointermove`,y),n.removeEventListener(`pointerup`,b),n.removeEventListener(`pointercancel`,b),n.removeEventListener(`contextmenu`,b),this._onDidSashEnd.fire(void 0)};n.addEventListener(`pointermove`,y),n.addEventListener(`pointerup`,b),n.addEventListener(`pointercancel`,b),n.addEventListener(`contextmenu`,b)};e.addEventListener(`pointerdown`,t);let n={container:e,disposable:()=>{e.removeEventListener(`pointerdown`,t),e.remove()}};this.sashContainer.appendChild(e),this.sashes.push(n)}r||this.relayout([n]),!r&&typeof t!=`number`&&t.type===`distribute`&&this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){let e=[],t=0;for(let n of this.viewItems)n.maximumSize-n.minimumSize>0&&(e.push(n),t+=n.size);let n=Math.floor(t/e.length);for(let t of e)t.size=mG(n,t.minimumSize,t.maximumSize);let r=gG(this.viewItems.length),i=r.filter(e=>this.viewItems[e].priority===`low`),a=r.filter(e=>this.viewItems[e].priority===`high`);this.relayout(i,a)}removeView(e,t,n=!1){let r=this.viewItems.splice(e,1)[0];if(r.dispose(),this.viewItems.length>=1){let t=Math.max(e-1,0);this.sashes.splice(t,1)[0].disposable()}return n||this.relayout(),t?.type===`distribute`&&this.distributeViewSizes(),this._onDidRemoveView.fire(r.view),r.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);return this.viewItems[e].cachedVisibleSize}moveView(e,t){let n=this.getViewCachedVisibleSize(e),r=n===void 0?this.getViewSize(e):bG.Invisible(n),i=this.removeView(e,void 0,!0);this.addView(i,r,t)}layout(e,t){let n=Math.max(this.size,this._contentSize);if(this.size=e,this.orthogonalSize=t,this._proportions||this.saveProportions(),this.proportions){let t=0;for(let n=0;n<this.viewItems.length;n++){let r=this.viewItems[n],i=this.proportions[n];typeof i==`number`?t+=i:e-=r.size}for(let n=0;n<this.viewItems.length;n++){let r=this.viewItems[n],i=this.proportions[n];typeof i==`number`&&t>0&&(r.size=mG(Math.round(i*e/t),r.minimumSize,r.maximumSize))}}else{let t=gG(this.viewItems.length),r=t.filter(e=>this.viewItems[e].priority===`low`),i=t.filter(e=>this.viewItems[e].priority===`high`);this.resize(this.viewItems.length-1,e-n,void 0,r,i)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){let n=this.viewItems.reduce((e,t)=>e+t.size,0);this.resize(this.viewItems.length-1,this._size-n,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(e){let t=0;for(let e of this.viewItems)t+=e.size;let n=this.size-t;if(n===0)return;let r=gG(this.viewItems.length-1,-1),i=!1;for(let e of this.viewItems)if(e.priority===`low`||e.priority===`high`){i=!0;break}if(i){let e=r.filter(e=>this.viewItems[e].priority===`low`),t=r.filter(e=>this.viewItems[e].priority===`high`);for(let e of t)uG(r,e);for(let t of e)dG(r,t)}typeof e==`number`&&dG(r,e);for(let e=0;n!==0&&e<r.length;e++){let t=this.viewItems[r[e]],i=mG(t.size+n,t.minimumSize,t.maximumSize),a=i-t.size;n-=a,t.size=i}}rescaleViews(e){let t=0;for(let e of this.viewItems)t+=e.size;if(e<=0||t<=0)return;let n=e/t,r=0;for(let e of this.viewItems)e.scale(n),r+=e.size;this._contentSize=r}saveProportions(){if(!this.proportionalLayout)return;let e=0;for(let t of this.viewItems)e+=t.size;e>0&&(this._proportions=this.viewItems.map(t=>t.visible?t.size/e:void 0))}layoutViews(){let e=0,t=0;for(let n of this.viewItems)e+=n.size,n.visible&&t++;if(this._contentSize=e,this.updateSashEnablement(),this.viewItems.length===0)return;let n=Math.max(0,t-1),r=this.marginShareFor(t),i=0,a=[],o=0;this.viewItems.forEach((e,t)=>{i+=this.viewItems[t].size,a.push(i),o+=+!!e.visible;let s=e.visible?e.size-r:0,c=Math.max(0,o-1),l=t===0||c===0?0:a[t-1]+c/n*r;if(t<this.viewItems.length-1){let n=e.visible?l+s-2+this.margin/2:l,r=this.sashes[t];this._orientation===`HORIZONTAL`&&yG(r,`${n}px`,`0px`),this._orientation===`VERTICAL`&&yG(r,`0px`,`${n}px`)}this._orientation===`HORIZONTAL`&&(e.setContainerGeometry(`width`,`${s}px`),e.setContainerGeometry(`left`,`${l}px`),e.setContainerGeometry(`top`,``),e.setContainerGeometry(`height`,``)),this._orientation===`VERTICAL`&&(e.setContainerGeometry(`height`,`${s}px`),e.setContainerGeometry(`top`,`${l}px`),e.setContainerGeometry(`width`,``),e.setContainerGeometry(`left`,``)),e.view.layout(s,this._orthogonalSize)})}marginShareFor(e){let t=Math.max(0,e-1);return this._margin*t/Math.max(1,e)}findFirstSnapIndex(e){for(let t of e){let e=this.viewItems[t];if(e.visible&&e.snap)return t}for(let t of e){let e=this.viewItems[t];if(e.visible&&e.maximumSize-e.minimumSize>0)return;if(!e.visible&&e.snap)return t}}updateSashEnablement(){if(this.sashes.length===0)return;let e=!1,t=this.viewItems.map(t=>e=t.size-t.minimumSize>0||e);e=!1;let n=this.viewItems.map(t=>e=t.maximumSize-t.size>0||e),r=[...this.viewItems].reverse();e=!1;let i=r.map(t=>e=t.size-t.minimumSize>0||e).reverse();e=!1;let a=r.map(t=>e=t.maximumSize-t.size>0||e).reverse(),o=0;for(let e=0;e<this.sashes.length;e++){let r=this.sashes[e],s=this.viewItems[e];o+=s.size;let c=!(t[e]&&a[e+1]),l=!(n[e]&&i[e+1]);if(c&&l){let n=gG(e,-1),a=gG(e+1,this.viewItems.length),s=this.findFirstSnapIndex(n),c=this.findFirstSnapIndex(a),l=typeof s==`number`&&!this.viewItems[s].visible,u=typeof c==`number`&&!this.viewItems[c].visible;l&&i[e]&&(o>0||this.startSnappingEnabled)?this.updateSash(r,1):u&&t[e]&&(o<this._contentSize||this.endSnappingEnabled)?this.updateSash(r,0):this.updateSash(r,2)}else c&&!l?this.updateSash(r,1):!c&&l?this.updateSash(r,0):this.updateSash(r,3)}}updateSash(e,t){Q(e.container,`dv-disabled`,t===2),Q(e.container,`dv-enabled`,t===3),Q(e.container,`dv-maximum`,t===0),Q(e.container,`dv-minimum`,t===1)}createViewContainer(){let e=document.createElement(`div`);return e.className=`dv-view-container`,e}createSashContainer(){let e=document.createElement(`div`);return e.className=`dv-sash-container`,e}createContainer(){let e=document.createElement(`div`);return e.className=`dv-split-view-container ${this._orientation===`HORIZONTAL`?`dv-horizontal`:`dv-vertical`}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.remove();break}for(let e of this.viewItems)e.dispose();this.element.remove()}},SG=Object.keys({orientation:void 0,descriptor:void 0,proportionalLayout:void 0,styles:void 0,margin:void 0,disableAutoResizing:void 0,className:void 0}),CG=class extends Y{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new X,this.onDidChange=this._onDidChange.event,this._orientation=t.orientation??`VERTICAL`,this.element=document.createElement(`div`),this.element.className=`dv-pane-container`,e.appendChild(this.element),this.splitview=new xG(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach(e=>{let t=new Y(e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),n={pane:e,disposable:{dispose:()=>{t.dispose()}}};this.paneItems.push(n),e.orthogonalSize=this.splitview.orthogonalSize}),this.addDisposables(this._onDidChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire(void 0)}),this.splitview.onDidAddView(()=>{this._onDidChange.fire()}),this.splitview.onDidRemoveView(()=>{this._onDidChange.fire()}))}setViewVisible(e,t){this.splitview.setViewVisible(e,t)}addPane(e,t,n=this.splitview.length,r=!1){let i=e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}),a={pane:e,disposable:{dispose:()=>{i.dispose()}}};this.paneItems.splice(n,0,a),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,n,r)}getViewSize(e){return this.splitview.getViewSize(e)}getViewCachedVisibleSize(e){return this.splitview.getViewCachedVisibleSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t){if(e<0||e>=this.paneItems.length)throw Error(`Index out of bounds`);let n=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t?.skipDispose||(n.disposable.dispose(),n.pane.dispose()),n}moveView(e,t){if(e===t)return;let n=this.getViewCachedVisibleSize(e),r=this.removePane(e,{skipDispose:!0}),i=n===void 0?r.pane.size:bG.Invisible(n);r.disposable.dispose(),this.skipAnimation=!0;try{this.addPane(r.pane,i,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&=(clearTimeout(this.animationTimer),void 0),EW(this.element,`dv-animated`),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,TW(this.element,`dv-animated`)},200))}dispose(){super.dispose(),this.animationTimer&&=(clearTimeout(this.animationTimer),void 0),this.paneItems.forEach(e=>{e.disposable.dispose(),e.pane.dispose()}),this.paneItems=[],this.splitview.dispose(),this.element.remove()}},wG=class{get minimumWidth(){return this.view.minimumWidth}get maximumWidth(){return this.view.maximumWidth}get minimumHeight(){return this.view.minimumHeight}get maximumHeight(){return this.view.maximumHeight}get priority(){return this.view.priority}get snap(){return this.view.snap}get minimumSize(){return this.orientation===`HORIZONTAL`?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===`HORIZONTAL`?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===`HORIZONTAL`?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===`HORIZONTAL`?this.maximumWidth:this.maximumHeight}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get element(){return this.view.element}get width(){return this.orientation===`HORIZONTAL`?this.orthogonalSize:this.size}get height(){return this.orientation===`HORIZONTAL`?this.size:this.orthogonalSize}constructor(e,t,n,r=0){this.view=e,this.orientation=t,this._onDidChange=new X,this.onDidChange=this._onDidChange.event,this._orthogonalSize=n,this._size=r,this._disposable=this.view.onDidChange(e=>{e?this._onDidChange.fire({size:this.orientation===`VERTICAL`?e.width:e.height,orthogonalSize:this.orientation===`VERTICAL`?e.height:e.width}):this._onDidChange.fire({})})}setVisible(e){this.view.setVisible&&this.view.setVisible(e)}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}},TG=class e extends Y{get width(){return this.orientation===`HORIZONTAL`?this.size:this.orthogonalSize}get height(){return this.orientation===`HORIZONTAL`?this.orthogonalSize:this.size}get minimumSize(){if(this._cachedMinimumSize===void 0){let e=0;for(let t=0;t<this.children.length;t++)this.splitview.isViewVisible(t)&&(e=Math.max(e,this.children[t].minimumOrthogonalSize));this._cachedMinimumSize=e}return this._cachedMinimumSize}get maximumSize(){if(this._cachedMaximumSize===void 0){let e=1/0;for(let t=0;t<this.children.length;t++)this.splitview.isViewVisible(t)&&(e=Math.min(e,this.children[t].maximumOrthogonalSize));this._cachedMaximumSize=e}return this._cachedMaximumSize}get minimumOrthogonalSize(){return this.splitview.minimumSize}get maximumOrthogonalSize(){return this.splitview.maximumSize}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get minimumWidth(){return this.orientation===`HORIZONTAL`?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===`HORIZONTAL`?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===`HORIZONTAL`?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===`HORIZONTAL`?this.maximumSize:this.maximumOrthogonalSize}get priority(){return this._cachedPriority??=this.computePriority(),this._cachedPriority}computePriority(){if(this.children.length===0)return`normal`;let e=!1,t=!1;for(let n of this.children){let r=n.priority??`normal`;r===`high`?e=!0:r===`low`&&(t=!0)}return e?`high`:t?`low`:`normal`}invalidateCachedSizes(){this._cachedMinimumSize=void 0,this._cachedMaximumSize=void 0,this._cachedPriority=void 0,this._onDidInvalidateSizes.fire()}get disabled(){return this.splitview.disabled}set disabled(e){this.splitview.disabled=e}get margin(){return this.splitview.margin}set margin(t){this.splitview.margin=t,this.children.forEach(n=>{n instanceof e&&(n.margin=t)})}get proportionalLayout(){return this.splitview.proportionalLayout}set proportionalLayout(t){this.splitview.proportionalLayout=t,this.children.forEach(n=>{n instanceof e&&(n.proportionalLayout=t)})}constructor(e,t,n,r,i,a,o,s){if(super(),this.orientation=e,this.styles=n,this._childrenDisposable=mW.NONE,this.children=[],this._onDidChange=new X,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new X,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onDidInvalidateSizes=new X,this.onDidInvalidateSizes=this._onDidInvalidateSizes.event,this._orthogonalSize=i,this._size=r,this.element=document.createElement(`div`),this.element.className=`dv-branch-node`,s){let e={views:s.map(e=>({view:e.node,size:e.node.size,visible:e.visible??!0})),size:this.orthogonalSize};this.children=s.map(e=>e.node),this.splitview=new xG(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t,styles:n,margin:o})}else this.splitview=new xG(this.element,{orientation:this.orientation,proportionalLayout:t,styles:n,margin:o}),this.splitview.layout(this.size,this.orthogonalSize);this.disabled=a,this.addDisposables(this._onDidChange,this._onDidVisibilityChange,this._onDidInvalidateSizes,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire({})})),this.setupChildrenEvents()}setVisible(e){}isChildVisible(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.isViewVisible(e)}setChildVisible(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);if(this.splitview.isViewVisible(e)===t)return;let n=this.splitview.contentSize===0;this.splitview.setViewVisible(e,t),this.invalidateCachedSizes();let r=this.splitview.contentSize===0;(t&&n||!t&&r)&&this._onDidVisibilityChange.fire({visible:t})}moveChild(e,t){if(e===t)return;if(e<0||e>=this.children.length)throw Error(`Invalid from index`);e<t&&t--,this.splitview.moveView(e,t);let n=this._removeChild(e);this._addChild(n,t)}getChildSize(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.getViewSize(e)}resizeChild(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);this.splitview.resizeView(e,t)}layout(e,t){this._size=t,this._orthogonalSize=e,this.splitview.layout(t,e)}addChild(e,t,n,r){if(n<0||n>this.children.length)throw Error(`Invalid index`);this.splitview.addView(e,t,n,r),this._addChild(e,n)}getChildCachedVisibleSize(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.getViewCachedVisibleSize(e)}removeChild(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.removeView(e,t),this._removeChild(e)}_addChild(e,t){this.children.splice(t,0,e),this.setupChildrenEvents()}_removeChild(e){let[t]=this.children.splice(e,1);return this.setupChildrenEvents(),t}setupChildrenEvents(){this.invalidateCachedSizes(),this._childrenDisposable.dispose(),this._childrenDisposable=new Y(gW.any(...this.children.map(e=>e.onDidChange))(e=>{this.invalidateCachedSizes(),this._onDidChange.fire({size:e.orthogonalSize})}),...this.children.map((t,n)=>t instanceof e?new Y(t.onDidVisibilityChange(({visible:e})=>{this.setChildVisible(n,e)}),t.onDidInvalidateSizes(()=>{this.invalidateCachedSizes()})):mW.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(e=>e.dispose()),super.dispose()}};function EG(e,t){if(e instanceof wG)return e;if(e instanceof TG)return EG(e.children[t?e.children.length-1:0],t);throw Error(`invalid node`)}function DG(e,t,n,r=1){let i=e.getChildCachedVisibleSize(t);return i===void 0?n:bG.Invisible(Math.round(i*r))}function OG(e,t,n){if(e instanceof TG){let r=new TG(e.orientation,e.proportionalLayout,e.styles,t,n,e.disabled,e.margin);for(let t=e.children.length-1;t>=0;t--){let n=e.children[t],i=n instanceof TG?n.orthogonalSize:n.size;r.addChild(OG(n,n.size,n.orthogonalSize),DG(e,t,i),0,!0)}return r}return new wG(e.view,e.orientation,n)}function kG(e,t,n){if(e instanceof TG){let r=new TG(FG(e.orientation),e.proportionalLayout,e.styles,t,n,e.disabled,e.margin),i=0,a=e.size===0?1:t/e.size;for(let o=e.children.length-1;o>=0;o--){let s=e.children[o],c=s instanceof TG?s.orthogonalSize:s.size,l=e.size===0?0:Math.round(t*c/e.size);i+=l,o===0&&(l+=t-i),r.addChild(kG(s,n,l),DG(e,o,l,a),0,!0)}return r}return new wG(e.view,FG(e.orientation),n)}function AG(e){let t=e.parentElement;if(!t)throw Error(`Invalid grid element`);let n=t.firstElementChild,r=0;for(;n!==e&&n!==t.lastElementChild&&n;)n=n.nextElementSibling,r++;return r}function jG(e){let t=e.parentElement;if(!t)throw Error(`Invalid grid element`);if(/\bdv-grid-view\b/.test(t.className))return[];let n=AG(t),r=t.parentElement.parentElement.parentElement;return[...jG(r),n]}function MG(e,t,n){if(PG(e,t)===NG(n)){let[e,r]=cG(t),i=r;return(n===`right`||n===`bottom`)&&(i+=1),[...e,i]}{let e=+(n===`right`||n===`bottom`);return[...t,e]}}function NG(e){return e===`top`||e===`bottom`?`VERTICAL`:`HORIZONTAL`}function PG(e,t){return t.length%2==0?FG(e):e}var FG=e=>e===`HORIZONTAL`?`VERTICAL`:`HORIZONTAL`;function IG(e){return!!e.children}var LG=(e,t)=>{let n=t===`VERTICAL`?e.box.width:e.box.height;if(!IG(e))return typeof e.cachedVisibleSize==`number`?{type:`leaf`,data:e.view.toJSON(),size:e.cachedVisibleSize,visible:!1}:{type:`leaf`,data:e.view.toJSON(),size:n};let r=e.children.map(e=>LG(e,FG(t)));return typeof e.cachedVisibleSize==`number`?{type:`branch`,data:r,size:e.cachedVisibleSize,visible:!1}:{type:`branch`,data:r,size:n}},RG=class{get length(){return this._root?this._root.children.length:0}get orientation(){return this.root.orientation}set orientation(e){if(this.root.orientation===e)return;let{size:t,orthogonalSize:n}=this.root;this.root=kG(this.root,n,t),this.root.layout(t,n)}get width(){return this.root.width}get height(){return this.root.height}get minimumWidth(){return this.root.minimumWidth}get minimumHeight(){return this.root.minimumHeight}get maximumWidth(){return this.root.maximumWidth}get maximumHeight(){return this.root.maximumHeight}get locked(){return this._locked}set locked(e){this._locked=e;let t=[this.root];for(;t.length>0;){let n=t.pop();n instanceof TG&&(n.disabled=e,t.push(...n.children))}}get margin(){return this._margin}set margin(e){this._margin=e,this.root.margin=e}maximizedView(){return this._maximizedNode?.leaf.view}hasMaximizedView(){return this._maximizedNode!==void 0}maximizeView(e){let t=jG(e.element),[n,r]=this.getNode(t);if(!(r instanceof wG)||this._maximizedNode?.leaf===r)return;this.hasMaximizedView()&&this.exitMaximizedView(),LG(this.getView(),this.orientation);let i=[];function a(e,t){for(let n=0;n<e.children.length;n++){let r=e.children[n];r instanceof wG?r!==t&&(e.isChildVisible(n)?e.setChildVisible(n,!1):i.push(r)):a(r,t)}}a(this.root,r),this._maximizedNode={leaf:r,hiddenOnMaximize:i},this._onDidMaximizedNodeChange.fire({view:r.view,isMaximized:!0})}exitMaximizedView(){if(!this._maximizedNode)return;let e=this._maximizedNode.hiddenOnMaximize;function t(n){for(let r=n.children.length-1;r>=0;r--){let i=n.children[r];i instanceof wG?e.includes(i)||n.setChildVisible(r,!0):t(i)}}t(this.root);let n=this._maximizedNode.leaf;this._maximizedNode=void 0,this._onDidMaximizedNodeChange.fire({view:n.view,isMaximized:!1})}serialize(){let e=this.maximizedView(),t;e&&(t=jG(e.element));let n=this._onDidMaximizedNodeChange.pause();try{this.hasMaximizedView()&&this.exitMaximizedView();let n={root:LG(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(n.maximizedNode={location:t}),e&&this.maximizeView(e),n}finally{n.dispose()}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this._onDidMaximizedNodeChange.dispose(),this._onDidViewVisibilityChange.dispose(),this.root.dispose(),this._maximizedNode=void 0,this.element.remove()}clear(){let e=this.root.orientation;this.root=new TG(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(e,t){let n=e.orientation,r=n===`VERTICAL`?e.height:e.width;if(this._deserialize(e.root,n,t,r),this.layout(e.width,e.height),e.maximizedNode){let t=e.maximizedNode.location,[n,r]=this.getNode(t);if(!(r instanceof wG))return;this.maximizeView(r.view)}}_deserialize(e,t,n,r){this.root=this._deserializeNode(e,t,n,r)}_deserializeNode(e,t,n,r){let i;if(e.type===`branch`){let a=e.data.map(r=>({node:this._deserializeNode(r,FG(t),n,e.size),visible:r.visible}));i=new TG(t,this.proportionalLayout,this.styles,e.size,r,this.locked,this.margin,a)}else{let o=n.fromJSON(e);if(typeof e.visible==`boolean`){var a;(a=o.setVisible)==null||a.call(o,e.visible)}i=new wG(o,t,r,e.size)}return i}get root(){return this._root}set root(e){let t=this._root;t&&(t.dispose(),this._maximizedNode=void 0,t.element.remove()),this._root=e,this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}normalize(){if(!this._root||this._root.children.length!==1)return;let e=this.root,t=e.children[0];if(t instanceof wG)return;e.element.remove();let n=e.removeChild(0);e.dispose(),n.dispose(),this._root=OG(t,t.size,t.orthogonalSize),this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;let e=this.root;if(e.element.remove(),this._root=new TG(FG(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),e.children.length!==0){if(e.children.length===1){let t=e.children[0];e.removeChild(0).dispose(),e.dispose(),this._root.addChild(kG(t,t.orthogonalSize,t.size),bG.Distribute,0)}else this._root.addChild(e,bG.Distribute,0)}this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){let t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,n){let r={height:e.height,width:e.width};if(e instanceof wG)return{box:r,view:e.view,cachedVisibleSize:n};let i=[];for(let n=0;n<e.children.length;n++){let r=e.children[n],a=e.getChildCachedVisibleSize(n);i.push(this._getViews(r,FG(t),a))}return{box:r,children:i,cachedVisibleSize:n}}progmaticSelect(e,t=!1){let[n,r]=this.getNode(e);if(!(r instanceof wG))throw TypeError(`invalid location`);for(let r=n.length-1;r>-1;r--){let i=n[r],a=e[r]||0;if(t?a-1>-1:a+1<i.children.length)return EG(i.children[t?a-1:a+1],t)}return EG(this.root,t)}get proportionalLayout(){return this.root.proportionalLayout}set proportionalLayout(e){this.root.proportionalLayout=e}constructor(e,t,n,r,i){this.styles=t,this._locked=!1,this._margin=0,this._maximizedNode=void 0,this.disposable=new hW,this._onDidChange=new X,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new X,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new X,this.onDidMaximizedNodeChange=this._onDidMaximizedNodeChange.event,this.element=document.createElement(`div`),this.element.className=`dv-grid-view`,this._locked=r??!1,this._margin=i??0,this.root=new TG(n,e,t,0,0,this.locked,this.margin)}isViewVisible(e){let[t,n]=cG(e),[,r]=this.getNode(t);if(!(r instanceof TG))throw TypeError(`Invalid from location`);return r.isChildVisible(n)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();let[n,r]=cG(e),[,i]=this.getNode(n);if(!(i instanceof TG))throw TypeError(`Invalid from location`);this._onDidViewVisibilityChange.fire(),i.setChildVisible(r,t)}moveView(e,t,n){this.hasMaximizedView()&&this.exitMaximizedView();let[,r]=this.getNode(e);if(!(r instanceof TG))throw TypeError(`Invalid location`);r.moveChild(t,n)}addView(e,t,n){this.hasMaximizedView()&&this.exitMaximizedView();let[r,i]=cG(n),[a,o]=this.getNode(r);if(o instanceof TG){let n=new wG(e,FG(o.orientation),o.orthogonalSize);o.addChild(n,t,i)}else{let[n,...s]=[...a].reverse(),[c,...l]=[...r].reverse(),u=0,d=n.getChildCachedVisibleSize(c);typeof d==`number`&&(u=bG.Invisible(d)),n.removeChild(c).dispose();let f=new TG(o.orientation,this.proportionalLayout,this.styles,o.size,o.orthogonalSize,this.locked,this.margin);n.addChild(f,o.size,c);let p=new wG(o.view,n.orientation,o.size);f.addChild(p,u,0),typeof t!=`number`&&t.type===`split`&&(t={type:`split`,index:0});let m=new wG(e,n.orientation,o.size);f.addChild(m,t,i)}}remove(e,t){let n=jG(e.element);return this.removeView(n,t)}removeView(e,t){this.hasMaximizedView()&&this.exitMaximizedView();let[n,r]=cG(e),[i,a]=this.getNode(n);if(!(a instanceof TG))throw TypeError(`Invalid location`);let o=a.children[r];if(!(o instanceof wG))throw TypeError(`Invalid location`);if(a.removeChild(r,t),o.dispose(),a.children.length!==1)return o.view;let s=a.children[0];if(i.length===0)return s instanceof wG||(a.removeChild(0,t),this.root=s),o.view;let[c,...l]=[...i].reverse(),[u,...d]=[...n].reverse(),f=a.isChildVisible(0);a.removeChild(0,t);let p=c.children.map((e,t)=>c.getChildSize(t));if(c.removeChild(u,t).dispose(),s instanceof TG){let e=s.children.map(e=>e instanceof TG?e.orthogonalSize:e.size);p.splice(u,1,...e);for(let t=0;t<s.children.length;t++){let n=s.children[t],r=DG(s,t,e[t]);c.addChild(n,!f&&typeof r==`number`?bG.Invisible(r):r,u+t)}for(;s.children.length>0;)s.removeChild(0)}else{let e=new wG(s.view,FG(s.orientation),s.size),t=f?s.orthogonalSize:bG.Invisible(s.orthogonalSize);c.addChild(e,t,u)}s.dispose();for(let e=0;e<p.length;e++)c.resizeChild(e,p[e]);return o.view}layout(e,t){let[n,r]=this.root.orientation===`HORIZONTAL`?[t,e]:[e,t];this.root.layout(n,r)}getNode(e,t=this.root,n=[]){if(e.length===0)return[n,t];if(!(t instanceof TG))throw TypeError(`Invalid location`);let[r,...i]=e;if(r<0||r>=t.children.length)throw Error(`Invalid location`);let a=t.children[r];return n.push(t),this.getNode(i,a,n)}},zG=Object.keys({disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0}),BG=class extends Y{get element(){return this._element}get disableResizing(){return this._disableResizing}set disableResizing(e){this._disableResizing=e}constructor(e,t=!1){super(),this._lastWidth=-1,this._lastHeight=-1,this._disableResizing=t,this._element=e,this.addDisposables(wW(this._element,e=>{if(this.isDisposed||this.disableResizing||!this._element.offsetParent||!RW(this._element))return;let t=Math.round(e.contentRect.width),n=Math.round(e.contentRect.height);(t!==this._lastWidth||n!==this._lastHeight)&&(this._lastWidth=t,this._lastHeight=n,this.layout(t,n))}))}layoutFromElement(){if(this.disableResizing||!this._element.offsetParent||!RW(this._element))return;let e=Math.round(this._element.clientWidth),t=Math.round(this._element.clientHeight);e!==0&&t!==0&&this.layout(e,t)}},VG=hG();function HG(e){switch(e){case`left`:return`left`;case`right`:return`right`;case`above`:return`top`;case`below`:return`bottom`;default:return`center`}}var UG=class extends BG{get id(){return this._id}get size(){return this._groups.size}get groups(){return Array.from(this._groups.values()).map(e=>e.value)}get width(){return this.gridview.width}get height(){return this.gridview.height}get minimumHeight(){return this.gridview.minimumHeight}get maximumHeight(){return this.gridview.maximumHeight}get minimumWidth(){return this.gridview.minimumWidth}get maximumWidth(){return this.gridview.maximumWidth}get activeGroup(){return this._activeGroup}get locked(){return this.gridview.locked}set locked(e){this.gridview.locked=e}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._id=VG.next(),this._groups=new Map,this._onDidRemove=new X,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new X,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new X,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new X,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new SW,this.onDidLayoutChange=gW.map(this._bufferOnDidLayoutChange.onEvent,e=>({reasons:e})),this._onDidViewVisibilityChangeMicroTaskQueue=new SW,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height=`100%`,this.element.style.width=`100%`,this._classNames=new KW(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this.gridview=new RG(!!t.proportionalLayout,t.styles,t.orientation,t.locked,t.margin),this.gridview.locked=!!t.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(e=>{this._onDidMaximizedChange.fire({panel:e.view,isMaximized:e.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.forceRelayout()}),mW.from(()=>{this.element.remove()}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire(`geometry`)}),gW.any(this.onDidAdd,this.onDidRemove)(()=>{this._bufferOnDidLayoutChange.fire(`structure`)}),this.onDidActiveChange(()=>{this._bufferOnDidLayoutChange.fire(`activePanel`)}),this.onDidMaximizedChange(()=>{this._bufferOnDidLayoutChange.fire(`geometry`)}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(jG(e.element),t),this._bufferOnDidLayoutChange.fire(`geometry`)}isVisible(e){return this.gridview.isViewVisible(jG(e.element))}updateOptions(e){`proportionalLayout`in e&&(this.gridview.proportionalLayout=e.proportionalLayout??!0),e.orientation&&(this.gridview.orientation=e.orientation),`styles`in e,`disableAutoResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),`locked`in e&&(this.locked=e.locked??!1),`margin`in e&&(this.gridview.margin=e.margin??0),`className`in e&&this._classNames.setClassNames(e.className??``)}maximizeGroup(e){this.gridview.maximizeView(e),this.doSetGroupActive(e)}isMaximizedGroup(e){return this.gridview.maximizedView()===e}exitMaximizedGroup(){this.gridview.exitMaximizedView()}hasMaximizedGroup(){return this.gridview.hasMaximizedView()}doAddGroup(e,t=[0],n,r=this.gridview){r.addView(e,n??bG.Distribute,t),this._onDidAdd.fire(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw Error(`invalid operation`);let n=this._groups.get(e.id),r=this.gridview.remove(e,bG.Distribute);if(n&&!t?.skipDispose&&(n.disposable.dispose(),n.value.dispose(),this._groups.delete(e.id),this._onDidRemove.fire(e)),!t?.skipActive&&this._activeGroup===e){let e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return r}getPanel(e){return this._groups.get(e)?.value}doSetGroupActive(e){this._activeGroup!==e&&(this._activeGroup&&this._activeGroup.setActive(!1),e&&e.setActive(!0),this._activeGroup=e,this._onDidActiveChange.fire(e))}removeGroup(e){this.doRemoveGroup(e)}activateNext(e){if(e??={},!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}let t=jG(e.group.element),n=this.gridview.next(t)?.view;this.doSetGroupActive(n)}activatePrevious(e){if(e??={},!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}let t=jG(e.group.element),n=this.gridview.previous(t)?.view;this.doSetGroupActive(n)}forceRelayout(){this.layout(this.width,this.height,!0)}layout(e,t,n){(n||e!==this.width||t!==this.height)&&(this.gridview.element.style.height=`${t}px`,this.gridview.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){this._onDidActiveChange.dispose(),this._onDidAdd.dispose(),this._onDidRemove.dispose();for(let e of this.groups)e.dispose();this.gridview.dispose(),super.dispose()}};function WG(e){"@babel/helpers - typeof";return WG=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},WG(e)}function GG(e,t){if(WG(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(WG(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function KG(e){var t=GG(e,`string`);return WG(t)==`symbol`?t:t+``}function qG(e,t,n){return(t=KG(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function JG(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 $(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?JG(Object(n),!0).forEach(function(t){qG(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):JG(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function YG(e,t){return e===`center`?`Tab into ${t}`:`Split ${e} of ${t}`}function XG(e,t){return e===`center`?`docked into ${t}`:`split ${e} of ${t}`}var ZG={panelOpened:e=>`${e} opened`,panelClosed:e=>`${e} closed`,groupMaximized:e=>`${e} maximized`,groupRestored:e=>`${e} restored`,groupFloated:e=>`${e} floated`,groupDocked:e=>`${e} docked`,groupPoppedOut:e=>`${e} opened in a new window`,closeTab:e=>`Close ${e}`,closeTabPlain:()=>`Close`,movePickTarget:(e,t,n,r)=>`Moving ${e}. Target ${t}, ${n} of ${r}. Enter to choose where, Escape to cancel.`,movePickEdge:(e,t)=>`${YG(e,t)}. Arrows to change, Enter to confirm, Escape to go back.`,moveCommitted:(e,t,n)=>`${e} ${XG(n,t)}.`,moveCancelled:()=>`Move cancelled.`,moveNotAllowed:()=>`That move is not allowed.`,moveFloated:e=>`${e} floated.`};function QG(e){return e?$($({},ZG),e):ZG}var $G=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get length(){return this.component.length}get orientation(){return this.component.orientation}get panels(){return this.component.panels}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}constructor(e){this.component=e}removePanel(e,t){this.component.removePanel(e,t)}focus(){this.component.focus()}getPanel(e){return this.component.getPanel(e)}layout(e,t){return this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},eK=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get panels(){return this.component.panels}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}get onDidDrop(){return this.component.onDidDrop}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}constructor(e){this.component=e}removePanel(e){this.component.removePanel(e)}getPanel(e){return this.component.getPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}focus(){this.component.focus()}layout(e,t){this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},tK=class{get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddPanel(){return this.component.onDidAddGroup}get onDidRemovePanel(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActiveGroupChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get panels(){return this.component.groups}get orientation(){return this.component.orientation}set orientation(e){this.component.updateOptions({orientation:e})}constructor(e){this.component=e}focus(){this.component.focus()}layout(e,t,n=!1){this.component.layout(e,t,n)}addPanel(e){return this.component.addPanel(e)}removePanel(e,t){this.component.removePanel(e,t)}movePanel(e,t){this.component.movePanel(e,t)}getPanel(e){return this.component.getPanel(e)}fromJSON(e){return this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},nK=class{get id(){return this.component.id}get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get size(){return this.component.size}get tabGroupColors(){return this.component.tabGroupColorPalette.entries()}get totalPanels(){return this.component.totalPanels}get onDidActiveGroupChange(){return this.component.onDidActiveGroupChange}get onDidAddGroup(){return this.component.onDidAddGroup}get onDidRemoveGroup(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActivePanelChange}get onDidPanelPinnedChange(){return this.component.onDidPanelPinnedChange}get onDidAddPanel(){return this.component.onDidAddPanel}get onDidRemovePanel(){return this.component.onDidRemovePanel}get onDidMovePanel(){return this.component.onDidMovePanel}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}get onWillDrop(){return this.component.onWillDrop}get onWillMutateLayout(){return this.component.onWillMutateLayout}get onDidMutateLayout(){return this.component.onDidMutateLayout}get onWillShowOverlay(){return this.component.onWillShowOverlay}get onWillDragGroup(){return this.component.onWillDragGroup}get onWillDragPanel(){return this.component.onWillDragPanel}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}get dndCapabilities(){return this.component.dndCapabilities}get onDidPopoutGroupSizeChange(){return this.component.onDidPopoutGroupSizeChange}get onDidPopoutGroupPositionChange(){return this.component.onDidPopoutGroupPositionChange}get onDidAddPopoutGroup(){return this.component.onDidAddPopoutGroup}get onDidRemovePopoutGroup(){return this.component.onDidRemovePopoutGroup}get onDidOpenPopoutWindowFail(){return this.component.onDidOpenPopoutWindowFail}get onWillClosePopoutWindow(){return this.component.onWillClosePopoutWindow}getPopouts(){return this.component.getPopouts()}get onDidCreateTabGroup(){return this.component.onDidCreateTabGroup}get onDidDestroyTabGroup(){return this.component.onDidDestroyTabGroup}get onDidAddPanelToTabGroup(){return this.component.onDidAddPanelToTabGroup}get onDidRemovePanelFromTabGroup(){return this.component.onDidRemovePanelFromTabGroup}get onDidTabGroupChange(){return this.component.onDidTabGroupChange}get onDidTabGroupCollapsedChange(){return this.component.onDidTabGroupCollapsedChange}get panels(){return this.component.panels}get groups(){return this.component.groups}adjacentGroupInDirection(e,t){return this.component.adjacentGroupInDirection(e,t)}get activePanel(){return this.component.activePanel}get activeGroup(){return this.component.activeGroup}get messages(){return QG(this.component.options.messages)}constructor(e){this.component=e}focus(){this.component.focus()}getPanel(e){return this.component.getGroupPanel(e)}layout(e,t,n=!1){this.component.layout(e,t,n)}addPanel(e){return this.component.withOrigin(`api`,()=>this.component.addPanel(e))}removePanel(e,t){this.component.withOrigin(`api`,()=>this.component.removePanel(e,t))}addGroup(e){return this.component.withOrigin(`api`,()=>this.component.addGroup(e))}serializeGroup(e){return this.component.serializeGroup(e)}addGroupFromJSON(e,t){return this.component.withOrigin(`api`,()=>this.component.addGroupFromJSON(e,t))}addPanelFromJSON(e,t){return this.component.withOrigin(`api`,()=>this.component.addPanelFromJSON(e,t))}closeAllGroups(){return this.component.withOrigin(`api`,()=>this.component.closeAllGroups())}removeGroup(e){this.component.withOrigin(`api`,()=>this.component.removeGroup(e))}getGroup(e){return this.component.getPanel(e)}addFloatingGroup(e,t){return this.component.withOrigin(`api`,()=>this.component.addFloatingGroup(e,t))}fromJSON(e,t){this.component.withOrigin(`api`,()=>this.component.fromJSON(e,t))}toJSON(){return this.component.toJSON()}clear(){this.component.withOrigin(`api`,()=>this.component.clear())}undo(){this.component.undo()}redo(){this.component.redo()}get canUndo(){return this.component.canUndo}get canRedo(){return this.component.canRedo}clearHistory(){this.component.clearHistory()}get onDidChangeHistory(){return this.component.onDidChangeHistory}get smartGuidesEnabled(){return this.component.smartGuidesEnabled}setSmartGuidesEnabled(e){this.component.setSmartGuidesEnabled(e)}updateSmartGuidesOptions(e){this.component.updateSmartGuidesOptions(e)}get onDidSnapFloat(){return this.component.onDidSnapFloat}get onDidSnapTogether(){return this.component.onDidSnapTogether}get popoutRestorationPromise(){return this.component.popoutRestorationPromise}activateNext(e){this.component.activateNext(e)}activatePrevious(e){this.component.activatePrevious(e)}moveToNext(e){this.activateNext(e)}moveToPrevious(e){this.activatePrevious(e)}maximizeGroup(e){this.component.withOrigin(`api`,()=>this.component.maximizeGroup(e.group))}hasMaximizedGroup(){return this.component.hasMaximizedGroup()}exitMaximizedGroup(){this.component.withOrigin(`api`,()=>this.component.exitMaximizedGroup())}get onDidMaximizedGroupChange(){return this.component.onDidMaximizedGroupChange}addPopoutGroup(e,t){return this.component.withOrigin(`api`,()=>this.component.addPopoutGroup(e,t))}addEdgeGroup(e,t){return this.component.addEdgeGroup(e,t)}revealEdgeGroupWithData(e,t,n){this.component.revealEdgeGroupWithData(e,t,n)}getEdgeGroup(e){return this.component.getEdgeGroup(e)}setEdgeGroupVisible(e,t){this.component.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this.component.isEdgeGroupVisible(e)}removeEdgeGroup(e){this.component.removeEdgeGroup(e)}pinEdgeGroup(e){this.component.pinEdgeGroup(e)}autoHideEdgeGroup(e){this.component.autoHideEdgeGroup(e)}peekEdgeGroup(e,t){this.component.peekEdgeGroup(e,t)}updateOptions(e){this.component.updateOptions(e)}_getGroupModel(e){let t=this.component.getPanel(e);if(!t)throw Error(`dockview: group '${e}' not found`);return t.model}createTabGroup(e){let t=this._getGroupModel(e.groupId);return this.component.withOrigin(`api`,()=>t.createTabGroup({label:e.label,color:e.color,componentParams:e.componentParams}))}dissolveTabGroup(e){let t=this._getGroupModel(e.groupId);this.component.withOrigin(`api`,()=>t.dissolveTabGroup(e.tabGroupId))}addPanelToTabGroup(e){let t=this._getGroupModel(e.groupId);this.component.withOrigin(`api`,()=>t.addPanelToTabGroup(e.tabGroupId,e.panelId,e.index))}removePanelFromTabGroup(e){let t=this._getGroupModel(e.groupId);this.component.withOrigin(`api`,()=>t.removePanelFromTabGroup(e.panelId))}getTabGroups(e){return this._getGroupModel(e.groupId).getTabGroups()}getTabGroupForPanel(e){return this._getGroupModel(e.groupId).getTabGroupForPanel(e.panelId)}moveTabGroup(e){this._getGroupModel(e.groupId).moveTabGroup(e.tabGroupId,e.index)}dispose(){this.component.dispose()}},rK=class extends Y{constructor(e,t){super(),this.element=e,this.callbacks=t,this.target=null,this.registerListeners()}onDragEnter(e){this.target=e.target,this.callbacks.onDragEnter(e)}onDragOver(e){e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}onDragLeave(e){this.target===e.target&&(this.target=null,this.callbacks.onDragLeave(e))}onDragEnd(e){this.target=null,this.callbacks.onDragEnd(e)}onDrop(e){this.callbacks.onDrop(e)}registerListeners(){this.addDisposables(Z(this.element,`dragenter`,e=>{this.onDragEnter(e)},!0)),this.addDisposables(Z(this.element,`dragover`,e=>{this.onDragOver(e)},!0)),this.addDisposables(Z(this.element,`dragleave`,e=>{this.onDragLeave(e)})),this.addDisposables(Z(this.element,`dragend`,e=>{this.onDragEnd(e)})),this.addDisposables(Z(this.element,`drop`,e=>{this.onDrop(e)}))}},iK={value:50,type:`percentage`},aK=100,oK=100;function sK(){let e=document.createElement(`div`);e.className=`dv-drop-target-dropzone`;let t=document.createElement(`div`);return t.className=`dv-drop-target-selection`,e.appendChild(t),{dropzone:e,selection:t}}function cK(e,t,n,r){let i=r?.smallWidthBoundary??aK,a=r?.smallHeightBoundary??oK,o=t<i,s=n<a,c=e===`left`,l=e===`right`,u=e===`top`,d=e===`bottom`,f=!o&&l,p=!o&&c,m=!s&&u,h=!s&&d,g=1,_=r?.size??iK;return _.type===`percentage`?g=mG(_.value,0,100)/100:((f||p)&&(g=mG(_.value,0,t)/t),(m||h)&&(g=mG(_.value,0,n)/n)),{isSmallX:o,isSmallY:s,isLeft:c,isRight:l,isTop:u,isBottom:d,rightClass:f,leftClass:p,topClass:m,bottomClass:h,size:g}}function lK(e,t,n,r,i){let a=cK(t,n,r,i),{rightClass:o,leftClass:s,topClass:c,bottomClass:l,size:u}=a,d={top:`0px`,left:`0px`,width:`100%`,height:`100%`};o?(d.left=`${100*(1-u)}%`,d.width=`${100*u}%`):s?d.width=`${100*u}%`:c?d.height=`${100*u}%`:l&&(d.top=`${100*(1-u)}%`,d.height=`${100*u}%`),a.isSmallX&&a.isLeft&&(d.width=`4px`),a.isSmallX&&a.isRight&&(d.left=`${n-4}px`,d.width=`4px`),a.isSmallY&&a.isTop&&(d.height=`4px`),a.isSmallY&&a.isBottom&&(d.top=`${r-4}px`,d.height=`4px`),e.style.top=d.top,e.style.left=d.left,e.style.width=d.width,e.style.height=d.height,e.style.visibility=`visible`,e.style.transform&&e.style.transform!==``||(e.style.transform=`translate3d(0, 0, 0)`);let f=a.isSmallX&&(a.isLeft||a.isRight)||a.isSmallY&&(a.isTop||a.isBottom);Q(e,`dv-drop-target-small-vertical`,a.isSmallY),Q(e,`dv-drop-target-small-horizontal`,a.isSmallX),Q(e,`dv-drop-target-selection-line`,f),Q(e,`dv-drop-target-left`,a.isLeft),Q(e,`dv-drop-target-right`,a.isRight),Q(e,`dv-drop-target-top`,a.isTop),Q(e,`dv-drop-target-bottom`,a.isBottom),Q(e,`dv-drop-target-center`,t===`center`)}function uK(e,t){let n=`${Math.round(t.top)}px`,r=`${Math.round(t.left)}px`,i=`${Math.round(t.width)}px`,a=`${Math.round(t.height)}px`;return e.style.top!==n||e.style.left!==r||e.style.width!==i||e.style.height!==a}function dK(e,t){e.style.top=`${Math.round(t.top)}px`,e.style.left=`${Math.round(t.left)}px`,e.style.width=`${Math.round(t.width)}px`,e.style.height=`${Math.round(t.height)}px`,e.style.visibility=`visible`,e.style.transform&&e.style.transform!==``||(e.style.transform=`translate3d(0, 0, 0)`)}function fK(e){let t=cK(e.quadrant,e.width,e.height,e.overlayModel),{rightClass:n,leftClass:r,topClass:i,bottomClass:a,size:o}=t,s=e.outlineElement.getBoundingClientRect(),c=e.targetModel.getElements(void 0,e.outlineElement),l=c.root,u=c.overlay,d=l.getBoundingClientRect(),f=s.top-d.top,p=s.left-d.left,m={top:f,left:p,width:e.width,height:e.height};return n?(m.left=p+e.width*(1-o),m.width=e.width*o):r?m.width=e.width*o:i?m.height=e.height*o:a&&(m.top=f+e.height*(1-o),m.height=e.height*o),t.isSmallX&&t.isLeft&&(m.width=4),t.isSmallX&&t.isRight&&(m.left=p+e.width-4,m.width=4),t.isSmallY&&t.isTop&&(m.height=4),t.isSmallY&&t.isBottom&&(m.top=f+e.height-4,m.height=4),uK(u,m)?(dK(u,m),u.className=`dv-drop-target-anchor${e.className?` ${e.className}`:``}`,Q(u,`dv-drop-target-left`,t.isLeft),Q(u,`dv-drop-target-right`,t.isRight),Q(u,`dv-drop-target-top`,t.isTop),Q(u,`dv-drop-target-bottom`,t.isBottom),Q(u,`dv-drop-target-anchor-line`,t.isSmallX&&(t.isLeft||t.isRight)||t.isSmallY&&(t.isTop||t.isBottom)),Q(u,`dv-drop-target-center`,e.quadrant===`center`),c.changed&&(Q(u,`dv-drop-target-anchor-container-changed`,!0),setTimeout(()=>{Q(u,`dv-drop-target-anchor-container-changed`,!1)},10)),{boundsChanged:!0,targetChanged:c.changed}):{boundsChanged:!1,targetChanged:c.changed}}var pK=class extends _W{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get edge(){return!!this.options.edge}get edgeGroup(){return!!this.options.edgeGroup}constructor(e){super(),this.options=e}};function mK(e){switch(e){case`above`:return`top`;case`below`:return`bottom`;case`left`:return`left`;case`right`:return`right`;case`within`:return`center`;default:throw Error(`invalid direction '${e}'`)}}function hK(e){switch(e){case`top`:return`above`;case`bottom`:return`below`;case`left`:return`left`;case`right`:return`right`;case`center`:return`within`;default:throw Error(`invalid position '${e}'`)}}var gK={value:20,type:`percentage`},_K=class e extends Y{get disabled(){return this._disabled}set disabled(e){this._disabled=e}get state(){return this._state}constructor(t,n){super(),this.element=t,this.options=n,this._edge=!1,this._onDrop=new X,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new X,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new rK(this.element,{onDragEnter:()=>{var e,t;(e=(t=this.options).getOverrideTarget)==null||(e=e.call(t))==null||e.getElements()},onDragOver:t=>{var n,r;if(this._disabled){this.clearOwnOverlay();return}e.ACTUAL_TARGET=this;let i=(n=this.options).getOverrideTarget?.call(n);if(this._acceptedTargetZonesSet.size===0){this.clearOwnOverlay();return}let a=(r=this.options).getOverlayOutline?.call(r)??this.element,o=a.offsetWidth,s=a.offsetHeight;if(o===0||s===0)return;let c=a.getBoundingClientRect(),l=(t.clientX??0)-c.left,u=(t.clientY??0)-c.top,d=this.resolvePosition(l,u,o,s,t);if(this.isAlreadyUsed(t)){this.removeDropTarget();return}if(d===null){this.clearOwnOverlay();return}let f=d.position;if(!this.options.canDisplayOverlay(t,f)){this.clearOwnOverlay();return}let p=new pK({nativeEvent:t,position:f,edge:d.edge,edgeGroup:d.edgeGroup});if(this._onWillShowOverlay.fire(p),p.defaultPrevented)this.clearOwnOverlay();else if(this.markAsUsed(t),d.edge)this.clearOwnOverlay(),this._state=f,this._edge=!0;else{if(this._edge=!1,!i&&!this.targetElement){let e=sK();this.targetElement=e.dropzone,this.overlayElement=e.selection,this._state=`center`,a.classList.add(`dv-drop-target`),a.append(this.targetElement)}this.toggleClasses(f,o,s),this._state=f}},onDragLeave:()=>{var e;let t=(e=this.options).getOverrideTarget?.call(e);if(t){var n;this._state=void 0,this._edge=!1,(n=t.scheduleClear)==null||n.call(t)}else this.removeDropTarget()},onDragEnd:t=>{var n;let r=(n=this.options).getOverrideTarget?.call(n);r&&e.ACTUAL_TARGET===this&&this._state&&(t.stopPropagation(),this._onDrop.fire({position:this._state,nativeEvent:t,edge:this._edge})),this.removeDropTarget(),r?.clear()},onDrop:e=>{var t,n;e.preventDefault();let r=this._state,i=this._edge;this.removeDropTarget(),(t=(n=this.options).getOverrideTarget)==null||(t=t.call(n))==null||t.clear(),r&&(e.stopPropagation(),this._onDrop.fire({position:r,nativeEvent:e,edge:i}))}}),this.addDisposables(this._onDrop,this._onWillShowOverlay,this.dnd)}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this.removeDropTarget(),super.dispose()}markAsUsed(t){t[e.USED_EVENT_ID]=!0}isAlreadyUsed(t){let n=t[e.USED_EVENT_ID];return typeof n==`boolean`&&n}toggleClasses(e,t,n){var r;let i=(r=this.options).getOverrideTarget?.call(r);if(i){var a;fK({outlineElement:(a=this.options).getOverlayOutline?.call(a)??this.element,targetModel:i,quadrant:e,width:t,height:n,overlayModel:this.options.overlayModel,className:this.options.className})}else this.overlayElement&&lK(this.overlayElement,e,t,n,this.options.overlayModel)}resolvePosition(e,t,n,r,i){var a;let o=(a=this.options).getPositionResolver?.call(a);if(o){let a=o.resolve({x:e,y:t,width:n,height:r,zones:this._acceptedTargetZonesSet,event:i});return a?{position:a.position,edge:!!a.edge,edgeGroup:!!a.edgeGroup}:null}let s=this.calculateQuadrant(this._acceptedTargetZonesSet,e,t,n,r);return s?{position:s,edge:!1,edgeGroup:!1}:null}calculateQuadrant(e,t,n,r,i){let a=this.options.overlayModel?.activationSize??gK;return a.type===`percentage`?vK(e,t,n,r,i,a.value):yK(e,t,n,r,i,a.value)}clearOwnOverlay(){let e=this._state!==void 0;if(this.removeDropTarget(),e){var t,n;(t=(n=this.options).getOverrideTarget)==null||(t=t.call(n))==null||t.clear()}}removeDropTarget(){if(this._state=void 0,this._edge=!1,this.targetElement){var e;(e=this.targetElement.parentElement)==null||e.classList.remove(`dv-drop-target`),this.targetElement.remove(),this.targetElement=void 0,this.overlayElement=void 0}}showOverlay(e){var t,n;let r=(t=this.options).getOverrideTarget?.call(t),i=(n=this.options).getOverlayOutline?.call(n)??this.element,a=i.offsetWidth,o=i.offsetHeight;if(!r&&!this.targetElement){let e=sK();this.targetElement=e.dropzone,this.overlayElement=e.selection,i.classList.add(`dv-drop-target`),i.append(this.targetElement)}this.toggleClasses(e,a,o),this._state=e}clearOverlay(){var e,t;this.removeDropTarget(),(e=(t=this.options).getOverrideTarget)==null||(e=e.call(t))==null||e.clear(),this._state=void 0}};_K.USED_EVENT_ID=`__dockview_droptarget_event_is_used__`;function vK(e,t,n,r,i,a){let o=100*t/r,s=100*n/i;return e.has(`left`)&&o<a?`left`:e.has(`right`)&&o>100-a?`right`:e.has(`top`)&&s<a?`top`:e.has(`bottom`)&&s>100-a?`bottom`:e.has(`center`)?`center`:null}function yK(e,t,n,r,i,a){return e.has(`left`)&&t<a?`left`:e.has(`right`)&&t>r-a?`right`:e.has(`top`)&&n<a?`top`:e.has(`bottom`)&&n>i-a?`bottom`:e.has(`center`)?`center`:null}function bK(e,t,n){EW(t,`dv-dragged`),t.style.top=`-9999px`,t.style.position=`absolute`,(n?.owner?eG(n.owner):(n?.ownerDocument??document).body).appendChild(t),e.setDragImage(t,n?.x??0,n?.y??0),setTimeout(()=>{TW(t,`dv-dragged`),t.remove()},0)}var xK=class e extends Y{static getInstance(){return e._instance??=new e,e._instance}constructor(){super(),this._targets=new Set,this._targetByElement=new Map,this._onDragStart=new X,this.onDragStart=this._onDragStart.event,this._onDragMove=new X,this.onDragMove=this._onDragMove.event,this._onDragEnd=new X,this.onDragEnd=this._onDragEnd.event,this.addDisposables(this._onDragStart,this._onDragMove,this._onDragEnd)}get active(){return this._active}registerTarget(e){return this._targets.add(e),this._targetByElement.set(e.element,e),{dispose:()=>{this._targets.delete(e),this._targetByElement.get(e.element)===e&&this._targetByElement.delete(e.element),this._currentTarget===e&&(this._currentTarget=void 0)}}}beginDrag(e){this._active&&this.cancel();let{pointerEvent:t,source:n}=e,r=e.getData();this._active={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,source:n},this._lastPointerEvent=t,this._onDragMoveCallback=e.onDragMove,this._onDragEndCallback=e.onDragEnd,this._dataDisposable=r,this._ghost=e.ghost,this._iframeShield=UW(n.ownerDocument??document),this._selectionShield=WW(n.ownerDocument??document);let i={clientX:t.clientX,clientY:t.clientY,pointerEvent:t};this._onDragStart.fire(i);let a=n.ownerDocument?.defaultView??globalThis.window;this._moveListener=Z(a,`pointermove`,e=>{e.pointerId===this._active?.pointerId&&this._handleMove(e)}),this._upListener=Z(a,`pointerup`,e=>{e.pointerId===this._active?.pointerId&&this._handleEnd(e,!0)}),this._cancelListener=Z(a,`pointercancel`,e=>{e.pointerId===this._active?.pointerId&&this._handleEnd(e,!1)})}cancel(){var e,t;if(!this._active)return;let n=this._onDragEndCallback,r=this._lastPointerEvent;if((e=this._currentTarget)==null||e.handleDragLeave(),this._teardown(),(t=this._dataDisposable)==null||t.dispose(),this._dataDisposable=void 0,r){let e={clientX:r.clientX,clientY:r.clientY,pointerEvent:r};n?.(e,!1),this._onDragEnd.fire(e)}}_findTargetUnder(e,t){let n=(this._active?BW(this._active.source):document).elementsFromPoint(e,t);for(let e of n){let t=e;for(;t;){let e=this._targetByElement.get(t);if(e&&!e.isHitTestTransparent?.call(e))return e;t=t.parentElement}}}_handleMove(e){var t,n;this._lastPointerEvent=e,(t=this._ghost)==null||t.update(e.clientX,e.clientY);let r={clientX:e.clientX,clientY:e.clientY,pointerEvent:e},i=this._findTargetUnder(e.clientX,e.clientY);if(i!==this._currentTarget){var a;(a=this._currentTarget)==null||a.handleDragLeave(),this._currentTarget=i}i&&i.handleDragOver(r),(n=this._onDragMoveCallback)==null||n.call(this,r),this._onDragMove.fire(r)}_handleEnd(e,t){let n={clientX:e.clientX,clientY:e.clientY,pointerEvent:e};try{if(t&&this._currentTarget)this._currentTarget.handleDrop(n);else{var r;(r=this._currentTarget)==null||r.handleDragLeave()}}finally{let e=this._onDragEndCallback,r=this._dataDisposable;this._teardown(),this._dataDisposable=void 0,setTimeout(()=>r?.dispose(),0),e?.(n,t),this._onDragEnd.fire(n)}}_teardown(){var e,t,n,r,i,a;this._currentTarget=void 0,this._active=void 0,this._lastPointerEvent=void 0,this._onDragMoveCallback=void 0,this._onDragEndCallback=void 0,(e=this._ghost)==null||e.dispose(),this._ghost=void 0,(t=this._iframeShield)==null||t.release(),this._iframeShield=void 0,(n=this._selectionShield)==null||n.release(),this._selectionShield=void 0,(r=this._moveListener)==null||r.dispose(),(i=this._upListener)==null||i.dispose(),(a=this._cancelListener)==null||a.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}},SK={value:20,type:`percentage`},CK=class extends Y{get disabled(){return this._disabled}set disabled(e){this._disabled=e,e&&this._removeOverlay()}get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._edge=!1,this._onDrop=new X,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new X,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(t.acceptedTargetZones);let n={element:this.element,handleDragOver:e=>this._onDragOver(e),handleDragLeave:()=>this._onDragLeave(),handleDrop:e=>this._onDropEvent(e),isHitTestTransparent:t.isHitTestTransparent};this.addDisposables(this._onDrop,this._onWillShowOverlay,xK.getInstance().registerTarget(n))}clearOverlay(){this._clearOwnOverlay()}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this._removeOverlay(),super.dispose()}_onDragOver(e){var t,n;if(this._disabled){this._clearOwnOverlay();return}let r=(t=this.options).getOverrideTarget?.call(t);if(this._acceptedTargetZonesSet.size===0){this._clearOwnOverlay();return}let i=(n=this.options).getOverlayOutline?.call(n)??this.element,a=i.offsetWidth,o=i.offsetHeight;if(a===0||o===0)return;let s=i.getBoundingClientRect(),c=e.clientX-s.left,l=e.clientY-s.top,u=this._resolvePosition(c,l,a,o,e.pointerEvent);if(u===null){this._clearOwnOverlay();return}let d=u.position;if(!this.options.canDisplayOverlay(e.pointerEvent,d)){this._clearOwnOverlay();return}let f=new pK({nativeEvent:e.pointerEvent,position:d,edge:u.edge,edgeGroup:u.edgeGroup});if(this._onWillShowOverlay.fire(f),f.defaultPrevented)this._clearOwnOverlay();else if(u.edge)this._clearOwnOverlay(),this._state=d,this._edge=!0;else if(this._edge=!1,r)fK({outlineElement:i,targetModel:r,quadrant:d,width:a,height:o,overlayModel:this.options.overlayModel,className:this.options.className}),this._state=d;else{if(!this._targetElement){let e=sK();this._targetElement=e.dropzone,this._overlayElement=e.selection,this._state=`center`,this.element.classList.add(`dv-drop-target`),this.element.append(this._targetElement)}this._overlayElement&&lK(this._overlayElement,d,a,o,this.options.overlayModel),this._state=d}}_onDragLeave(){var e;let t=(e=this.options).getOverrideTarget?.call(e);t?(this._state=void 0,t.clear()):this._removeOverlay()}_onDropEvent(e){var t;let n=this._state,r=this._edge,i=(t=this.options).getOverrideTarget?.call(t);this._removeOverlay(),i?.clear(),n&&this._onDrop.fire({position:n,nativeEvent:e.pointerEvent,edge:r})}_resolvePosition(e,t,n,r,i){var a;let o=(a=this.options).getPositionResolver?.call(a);if(o){let a=o.resolve({x:e,y:t,width:n,height:r,zones:this._acceptedTargetZonesSet,event:i});return a?{position:a.position,edge:!!a.edge,edgeGroup:!!a.edgeGroup}:null}let s=this._calculateQuadrant(e,t,n,r);return s?{position:s,edge:!1,edgeGroup:!1}:null}_calculateQuadrant(e,t,n,r){let i=this.options.overlayModel?.activationSize??SK;return i.type===`percentage`?vK(this._acceptedTargetZonesSet,e,t,n,r,i.value):yK(this._acceptedTargetZonesSet,e,t,n,r,i.value)}_clearOwnOverlay(){let e=this._state!==void 0;if(this._removeOverlay(),e){var t,n;(t=(n=this.options).getOverrideTarget)==null||(t=t.call(n))==null||t.clear()}}_removeOverlay(){if(this._edge=!1,this._targetElement){var e;this._state=void 0,(e=this._targetElement.parentElement)==null||e.classList.remove(`dv-drop-target`),this._targetElement.remove(),this._targetElement=void 0,this._overlayElement=void 0}else this._state=void 0}},wK=5,TK=250,EK=8,DK=class extends Y{constructor(e,t){super(),this.element=e,this.options=t,this._disabled=!1,this._armed=!1,this._startX=0,this._startY=0,this._touchOnly=t.touchOnly??!0,this.addDisposables(Z(this.element,`pointerdown`,e=>{this._onPointerDown(e)}))}setDisabled(e){this._disabled=e,e&&this._cancelPending()}setTouchOnly(e){this._touchOnly!==e&&(this._touchOnly=e,e&&this._cancelPending())}_shouldHandle(e){var t;return!(this._disabled||this._touchOnly&&e.pointerType!==`touch`&&e.pointerType!==`pen`||e.pointerType===`mouse`&&e.button!==0||(t=this.options).isCancelled?.call(t,e))}_onPointerDown(e){if(!this._shouldHandle(e))return;this._cancelPending(),this._selectionShield=WW(this.element.ownerDocument??document),this._pendingPointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY,this._startEvent=e;let t=e.pointerType===`touch`||e.pointerType===`pen`,n=this.options.touchInitiationDelay,r=(typeof n==`function`?n():n)??TK;this._armed=!t||r<=0,t&&r>0&&Number.isFinite(r)&&(this._armTimer=setTimeout(()=>{this._armTimer=void 0,this._armed=!0},r));let i=this.options.threshold??wK,a=this.options.pressTolerance,o=(typeof a==`function`?a():a)??EK,s=this.element.ownerDocument?.defaultView??globalThis.window;this._pendingMoveListener=Z(s,`pointermove`,e=>{if(e.pointerId!==this._pendingPointerId)return;let t=e.clientX-this._startX,n=e.clientY-this._startY,r=Math.hypot(t,n);this._armed?r>=i&&this._beginDrag(e):r>o&&this._beginDrag(e)}),this._pendingUpListener=Z(s,`pointerup`,e=>{e.pointerId===this._pendingPointerId&&this._cancelPending()}),this._pendingCancelListener=Z(s,`pointercancel`,e=>{e.pointerId===this._pendingPointerId&&this._cancelPending()})}cancelPending(){this._cancelPending()}_cancelPending(){var e,t,n,r;(e=this._selectionShield)==null||e.release(),this._selectionShield=void 0,this._pendingPointerId=void 0,this._armTimer!==void 0&&(clearTimeout(this._armTimer),this._armTimer=void 0),this._armed=!1,(t=this._pendingMoveListener)==null||t.dispose(),(n=this._pendingUpListener)==null||n.dispose(),(r=this._pendingCancelListener)==null||r.dispose(),this._pendingMoveListener=void 0,this._pendingUpListener=void 0,this._pendingCancelListener=void 0,this._startEvent=void 0}_beginDrag(e){var t,n,r;let i=this._startEvent??e;this._cancelPending();let a=i.defaultPrevented;if((t=(n=this.options).onDragStart)==null||t.call(n,i),i.defaultPrevented&&!a)return;let o=(r=this.options).createGhost?.call(r,i);xK.getInstance().beginDrag({pointerEvent:e,source:this.element,getData:()=>this.options.getData(i),ghost:o,onDragMove:this.options.onDragMove,onDragEnd:this.options.onDragEnd})}dispose(){this._cancelPending(),super.dispose()}},OK=class{constructor(e){this._disposed=!1,this.element=e.element,this.offsetX=e.offsetX??0,this.offsetY=e.offsetY??0;let t=e.owner?eG(e.owner):document.body,n;zW(t)&&typeof this.element.showPopover==`function`&&(n=this.element.ownerDocument.createElement(`div`),n.popover=`manual`,Object.assign(n.style,{inset:`auto`,margin:`0`,padding:`0`,border:`0`,background:`transparent`,color:`inherit`,overflow:`visible`}),n.appendChild(this.element),this.element.style.pointerEvents=`none`,this.element.style.transform=`none`),this.container=n??this.element;let r=this.container.style;r.position=`fixed`,r.left=`0px`,r.top=`0px`,r.pointerEvents=`none`,r.zIndex=`99999`,r.opacity=String(e.opacity??.8),r.willChange=`transform`,r.transform=`translate3d(${e.initialX-this.offsetX}px, ${e.initialY-this.offsetY}px, 0)`,t.appendChild(this.container),n?.showPopover()}update(e,t){this._disposed||(this.container.style.transform=`translate3d(${e-this.offsetX}px, ${t-this.offsetY}px, 0)`)}dispose(){this._disposed||(this._disposed=!0,this.element.remove(),this.container!==this.element&&this.container.remove())}},kK=class extends Y{constructor(e,t){super(),this.el=e,this.opts=t,this._dataDisposable=new hW,this._pointerEventsDisposable=new hW,this._disabled=!!t.disabled,this.addDisposables(this._dataDisposable,this._pointerEventsDisposable,Z(this.el,`dragstart`,e=>{var t,n,r,i;if(e.defaultPrevented||this._disabled||(t=this.opts).isCancelled?.call(t,e)){e.preventDefault();return}if((n=(r=this.opts).onDragStart)==null||n.call(r,e),e.defaultPrevented)return;let a=UW(this.el.ownerDocument??document);this._pointerEventsDisposable.value={dispose:()=>a.release()},this.el.classList.add(`dv-dragged`),setTimeout(()=>this.el.classList.remove(`dv-dragged`),0),this._dataDisposable.value=this.opts.getData(e);let o=(i=this.opts).createGhost?.call(i,e);if(o&&e.dataTransfer&&(bK(e.dataTransfer,o.element,{x:o.offsetX??0,y:o.offsetY??0,ownerDocument:this.el.ownerDocument??void 0,owner:this.el}),o.dispose)){let e=o.dispose;setTimeout(()=>e(),0)}e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.items.length===0&&e.dataTransfer.setData(`text/plain`,``))}),Z(this.el,`dragend`,e=>{var t,n;this._pointerEventsDisposable.dispose(),setTimeout(()=>this._dataDisposable.dispose(),0),(t=(n=this.opts).onDragEnd)==null||t.call(n,e)}))}setDisabled(e){this._disabled=e}setTouchOnly(e){}cancelPending(){}},AK=class{constructor(){this.kind=`html5`}createDropTarget(e,t){return new _K(e,t)}createDragSource(e,t){return new kK(e,t)}},jK=class{constructor(){this.kind=`pointer`}createDropTarget(e,t){return new CK(e,t)}createDragSource(e,t){let n=t.createGhost?n=>{let r=t.createGhost(n);if(!r)return;let i=new OK({element:r.element,initialX:n.clientX,initialY:n.clientY,offsetX:r.offsetX,offsetY:r.offsetY,owner:e});if(r.dispose){let e=i.dispose.bind(i),t=r.dispose;i.dispose=()=>{e(),t()}}return i}:void 0,r=new DK(e,{getData:t.getData,isCancelled:t.isCancelled,onDragStart:t.onDragStart,onDragEnd:t.onDragEnd?e=>t.onDragEnd(e.pointerEvent):void 0,createGhost:n,touchOnly:t.touchOnly,touchInitiationDelay:t.touchInitiationDelay,pressTolerance:t.pressTolerance,threshold:t.threshold});return t.disabled&&r.setDisabled(!0),r}},MK=new AK,NK=new jK,PK=Object.keys({disableAutoResizing:void 0,disableDnd:void 0,className:void 0}),FK=class extends vW{constructor(e,t,n,r){super(),this.nativeEvent=e,this.position=t,this.getData=n,this.panel=r}},IK=class extends _W{constructor(){super()}},LK=class extends Y{get isFocused(){return this._isFocused}get isActive(){return this._isActive}get isVisible(){return this._isVisible}get width(){return this._width}get height(){return this._height}constructor(e,t){super(),this.id=e,this.component=t,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this._parameters={},this.panelUpdatesDisposable=new hW,this._onDidDimensionChange=new X,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new X,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new X,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new X,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new X,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new X,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new X,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new X,this.onDidParametersChange=this._onDidParametersChange.event,this.addDisposables(this.onDidFocusChange(e=>{this._isFocused=e.isFocused}),this.onDidActiveChange(e=>{this._isActive=e.isActive}),this.onDidVisibilityChange(e=>{this._isVisible=e.isVisible}),this.onDidDimensionsChange(e=>{this._width=e.width,this._height=e.height}),this.panelUpdatesDisposable,this._onDidDimensionChange,this._onDidChangeFocus,this._onDidVisibilityChange,this._onDidActiveChange,this._onWillFocus,this._onActiveChange,this._onWillFocus,this._onWillVisibilityChange,this._onDidParametersChange)}getParameters(){return this._parameters}initialize(e){this.panelUpdatesDisposable.value=this._onDidParametersChange.event(t=>{this._parameters=t,e.update({params:t})})}setVisible(e){this._onWillVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}updateParameters(e){this._onDidParametersChange.fire(e)}},RK=class extends LK{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new X,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new X({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new X,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},zK=class extends RK{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new X({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new X({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new X({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}setExpanded(e){var t;(t=this._pane)==null||t.setExpanded(e)}get isExpanded(){return!!this._pane?.isExpanded()}},BK=class extends Y{get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){return this._params?.params}constructor(e,t,n){super(),this.id=e,this.component=t,this.api=n,this._height=0,this._width=0,this._element=document.createElement(`div`),this._element.tabIndex=-1,this._element.style.outline=`none`,this._element.style.height=`100%`,this._element.style.width=`100%`,this._element.style.overflow=`hidden`;let r=OW(this._element);this.addDisposables(this.api,r.onDidFocus(()=>{this.api._onDidChangeFocus.fire({isFocused:!0})}),r.onDidBlur(()=>{this.api._onDidChangeFocus.fire({isFocused:!1})}),r)}focus(){let e=new IK;this.api._onWillFocus.fire(e),!e.defaultPrevented&&this._element.focus()}layout(e,t){this._width=e,this._height=t,this.api._onDidDimensionChange.fire({width:e,height:t}),this.part&&this._params&&this.part.update({params:this._params.params})}init(e){this._params=e,this.part=this.getComponent()}update(e){var t;this._params=$($({},this._params),{},{params:$($({},this._params?.params),e.params)});for(let t of Object.keys(e.params))e.params[t]===void 0&&delete this._params.params[t];(t=this.part)==null||t.update({params:this._params.params})}toJSON(){let e=this._params?.params??{};return{id:this.id,component:this.component,params:Object.keys(e).length>0?e:void 0}}dispose(){var e;this.api.dispose(),(e=this.part)==null||e.dispose(),super.dispose()}},VK=class extends BK{set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){return this.headerSize+(this.isExpanded()?this._minimumBodySize:0)}get maximumSize(){return this.headerSize+(this.isExpanded()?this._maximumBodySize:0)}get size(){return this._size}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get minimumBodySize(){return this._minimumBodySize}set minimumBodySize(e){this._minimumBodySize=typeof e==`number`?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize=typeof e==`number`?e:1/0}get headerVisible(){return this._headerVisible}set headerVisible(e){this._headerVisible=e,this.header.style.display=e?``:`none`}constructor(e){super(e.id,e.component,new zK(e.id,e.component)),this._onDidChangeExpansionState=new X({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new X,this.onDidChange=this._onDidChange.event,this._orthogonalSize=0,this._size=0,this._isExpanded=!1,this.api.pane=this,this.api.initialize(this),this.headerSize=e.headerSize,this.headerComponent=e.headerComponent,this._minimumBodySize=e.minimumBodySize,this._maximumBodySize=e.maximumBodySize,this._isExpanded=e.isExpanded,this._headerVisible=e.isHeaderVisible,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=e.orientation,this.element.classList.add(`dv-pane`),this.addDisposables(this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}),Z(this.element,`mouseenter`,e=>{this.api._onMouseEnter.fire(e)}),Z(this.element,`mouseleave`,e=>{this.api._onMouseLeave.fire(e)})),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState(e=>{this.api._onDidExpansionChange.fire({isExpanded:e})}),this.api.onDidFocusChange(e=>{this.header&&(e.isFocused?EW(this.header,`focused`):TW(this.header,`focused`))})),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):(this._expandedSize=this._size,this.animationTimer=setTimeout(()=>{var e;(e=this.body)==null||e.remove()},200)),this._onDidChange.fire(e?{size:this._expandedSize??this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(e,t){this._size=e,this._orthogonalSize=t;let[n,r]=this.orientation===`HORIZONTAL`?[e,t]:[t,e];super.layout(n,r)}init(e){var t,n;super.init(e),typeof e.minimumBodySize==`number`&&(this.minimumBodySize=e.minimumBodySize),typeof e.maximumBodySize==`number`&&(this.maximumBodySize=e.maximumBodySize),this.bodyPart=this.getBodyComponent(),this.headerPart=this.getHeaderComponent(),this.bodyPart.init($($({},e),{},{api:this.api})),this.headerPart.init($($({},e),{},{api:this.api})),(t=this.body)==null||t.append(this.bodyPart.element),(n=this.header)==null||n.append(this.headerPart.element),typeof e.isExpanded==`boolean`&&this.setExpanded(e.isExpanded)}toJSON(){let e=this._params;return $($({},super.toJSON()),{},{headerComponent:this.headerComponent,title:e.title})}renderOnce(){this.header=document.createElement(`div`),this.header.tabIndex=0,this.header.className=`dv-pane-header`,this.header.style.height=`${this.headerSize}px`,this.header.style.lineHeight=`${this.headerSize}px`,this.header.style.minHeight=`${this.headerSize}px`,this.header.style.maxHeight=`${this.headerSize}px`,this.element.appendChild(this.header),this.body=document.createElement(`div`),this.body.className=`dv-pane-body`,this.element.appendChild(this.body)}getComponent(){return{update:e=>{var t,n;(t=this.bodyPart)==null||t.update(e),(n=this.headerPart)==null||n.update(e)},dispose:()=>{var e,t;(e=this.bodyPart)==null||e.dispose(),(t=this.headerPart)==null||t.dispose()}}}},HK=class extends VK{constructor(e){super({id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,isHeaderVisible:!0,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this._onDidDrop=new X,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOver=new X,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.accessor=e.accessor,this.addDisposables(this._onDidDrop,this._onUnhandledDragOver),e.disableDnd||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;let e=this.id,t=this.accessor.id;this.header.draggable=!0;let n={getData:()=>(dW.getInstance().setData([new uW(t,e)],uW.prototype),{dispose:()=>{dW.getInstance().clearData(uW.prototype)}})};this.html5DragSource=MK.createDragSource(this.header,n),this.pointerDragSource=NK.createDragSource(this.header,n);let r={acceptedTargetZones:[`top`,`bottom`],overlayModel:{activationSize:{type:`percentage`,value:50}},canDisplayOverlay:(e,t)=>{let n=pW();if(n&&n.paneId!==this.id&&n.viewId===this.accessor.id)return!0;let r=new FK(e,t,pW,this);return this._onUnhandledDragOver.fire(r),r.isAccepted}};this.target=MK.createDropTarget(this.element,r),this.pointerTarget=NK.createDropTarget(this.element,r),this.addDisposables(this._onDidDrop,this.html5DragSource,this.pointerDragSource,this.target,this.pointerTarget,this.target.onDrop(e=>{this.onDrop(e)}),this.pointerTarget.onDrop(e=>{this.onDrop(e)}))}onDrop(e){let t=pW();if(t?.viewId!==this.accessor.id){this._onDidDrop.fire($($({},e),{},{panel:this,api:new eK(this.accessor),getData:pW}));return}let n=this._params.containerApi,r=t.paneId,i=n.getPanel(r);if(!i){this._onDidDrop.fire($($({},e),{},{panel:this,getData:pW,api:new eK(this.accessor)}));return}let a=n.panels,o=a.indexOf(i),s=n.panels.indexOf(this);(e.position===`left`||e.position===`top`)&&o<s&&s--,(e.position===`right`||e.position===`bottom`)&&(o>s&&s++,s=Math.min(a.length-1,s)),n.movePanel(o,s)}},UK=0,WK=()=>`dv-tabpanel-${UK++}`,GK=class extends Y{get element(){return this._element}get dimensions(){return this._dimensions}constructor(e,t){var n,r,i;super(),this.accessor=e,this.group=t,this.disposable=new hW,this._onDidFocus=new X,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new X,this.onDidBlur=this._onDidBlur.event,this._onDidDimensionsChange=new X,this.onDidDimensionsChange=this._onDidDimensionsChange.event,this._element=document.createElement(`div`),this._element.className=`dv-content-container`,this._element.tabIndex=-1,this._element.id=WK(),this._element.setAttribute(`role`,`tabpanel`),this.addDisposables(this._onDidFocus,this._onDidBlur,this._onDidDimensionsChange);let a=()=>t.dropTargetContainer?.model,o=(e,t)=>this.group.canDisplayContentOverlay(e,t);this.dropTarget=new _K(this.element,{getOverlayOutline:()=>e.options.theme?.dndPanelOverlay===`group`?this.element.parentElement:null,className:`dv-drop-target-content`,acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],canDisplayOverlay:o,getOverrideTarget:a,overlayModel:(n=this.accessor).resolveDropOverlayModel?.call(n,`content`),getPositionResolver:()=>e.getDropPositionResolver?.call(e)}),this.pointerDropTarget=NK.createDropTarget(this.element,{acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],canDisplayOverlay:o,getOverlayOutline:()=>e.options.theme?.dndPanelOverlay===`group`?this.element.parentElement:null,className:`dv-drop-target-content`,getOverrideTarget:a,overlayModel:(r=this.accessor).resolveDropOverlayModel?.call(r,`content`),getPositionResolver:()=>e.getDropPositionResolver?.call(e)}),this.addDisposables(this.dropTarget,this.pointerDropTarget,(i=this.accessor).onDidOptionsChange?.call(i,()=>{var e;let t=(e=this.accessor).resolveDropOverlayModel?.call(e,`content`)??{};this.dropTarget.setOverlayModel(t),this.pointerDropTarget.setOverlayModel(t)})??mW.NONE)}show(){this.element.style.display=``}hide(){this.element.style.display=`none`}setLabelledBy(e){e?this._element.setAttribute(`aria-labelledby`,e):this._element.removeAttribute(`aria-labelledby`)}renderPanel(e,t){let n=(t?.asActive??!0)||this.group.isPanelActive(e);if(n||this.panel===e){if(this.panel?.view.content.element.parentElement===this._element){var r,i;this.panel.view.content.element.remove(),(r=(i=this.panel.view.content).onHide)==null||r.call(i)}this.panel=e}let a;switch(e.api.renderer){case`onlyWhenVisible`:if(this.group.renderContainer.detatch(e),n){var o,s;this._element.appendChild(e.view.content.element),(o=(s=e.view.content).onShow)==null||o.call(s)}a=this._element;break;case`always`:e.view.content.element.parentElement===this._element&&e.view.content.element.remove(),a=this.group.renderContainer.attach({panel:e,referenceContainer:this});break;default:throw Error(`dockview: invalid renderer type '${e.api.renderer}'`)}if(n){let e=OW(a);this.focusTracker=e;let t=new Y;t.addDisposables(e,e.onDidFocus(()=>this._onDidFocus.fire()),e.onDidBlur(()=>this._onDidBlur.fire())),this.disposable.value=t}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){(this._dimensions?.width!==e||this._dimensions.height!==t)&&(this._dimensions={width:e,height:t},this._onDidDimensionsChange.fire(this._dimensions))}closePanel(){if(this.panel&&this.panel.api.renderer===`onlyWhenVisible`){var e,t;this.panel.view.content.element.remove(),(e=(t=this.panel.view.content).onHide)==null||e.call(t)}this.panel=void 0}dispose(){this.disposable.dispose(),super.dispose()}refreshFocusState(){this.focusTracker?.refreshState&&this.focusTracker.refreshState()}},KK=e=>{let t=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);t.setAttributeNS(null,`height`,e.height),t.setAttributeNS(null,`width`,e.width),t.setAttributeNS(null,`viewBox`,e.viewbox),t.setAttributeNS(null,`aria-hidden`,`false`),t.setAttributeNS(null,`focusable`,`false`),t.classList.add(`dv-svg`);let n=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return n.setAttributeNS(null,`d`,e.path),t.appendChild(n),t},qK=()=>KK({width:`11`,height:`11`,viewbox:`0 0 28 28`,path:`M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z`}),JK=()=>KK({width:`11`,height:`11`,viewbox:`0 0 24 24`,path:`M16 9V4h1c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3z`}),YK=()=>KK({width:`11`,height:`11`,viewbox:`0 0 24 15`,path:`M12 14.15L0 2.15L2.15 0L12 9.9L21.85 0.0499992L24 2.2L12 14.15Z`}),XK=()=>KK({width:`11`,height:`11`,viewbox:`0 0 15 25`,path:`M2.15 24.1L0 21.95L9.9 12.05L0 2.15L2.15 0L14.2 12.05L2.15 24.1Z`}),ZK=500,QK=8,$K=class extends Y{constructor(e,t){super(),this.element=e,this.options=t,this._startX=0,this._startY=0,this.addDisposables(Z(this.element,`pointerdown`,e=>{this._onPointerDown(e)}))}_onPointerDown(e){if((this.options.touchOnly??!0)&&e.pointerType!==`touch`&&e.pointerType!==`pen`)return;this._cancelPending(),this._pointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY;let t=this.options.delay??ZK,n=this.options.tolerance??QK,r=this.element.ownerDocument?.defaultView??globalThis.window;this._timer=setTimeout(()=>{this._timer=void 0,this._cancelPending(),this._installContextMenuGuard(r),this._installClickGuard(r),this.options.onLongPress(e)},t),this._moveListener=Z(r,`pointermove`,e=>{if(e.pointerId!==this._pointerId)return;let t=e.clientX-this._startX,r=e.clientY-this._startY;Math.hypot(t,r)>n&&this._cancelPending()}),this._upListener=Z(r,`pointerup`,e=>{e.pointerId===this._pointerId&&this._cancelPending()}),this._cancelListener=Z(r,`pointercancel`,e=>{e.pointerId===this._pointerId&&this._cancelPending()})}_installContextMenuGuard(e){let t,n=setTimeout(()=>t?.dispose(),500);t=Z(e,`contextmenu`,e=>{e.preventDefault(),clearTimeout(n),t?.dispose()},{capture:!0})}_installClickGuard(e){let t,n=setTimeout(()=>t?.dispose(),500);t=Z(e,`click`,e=>{NW(e,[this.element])&&(e.preventDefault(),e.stopPropagation()),clearTimeout(n),t?.dispose()},{capture:!0})}_cancelPending(){var e,t,n;this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0),this._pointerId=void 0,(e=this._moveListener)==null||e.dispose(),(t=this._upListener)==null||t.dispose(),(n=this._cancelListener)==null||n.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}dispose(){this._cancelPending(),super.dispose()}};function eq(e){if(e.disableDnd)return{html5:!1,pointer:!1,pointerHandlesMouse:!1};switch(e.dndStrategy){case`pointer`:return{html5:!1,pointer:!0,pointerHandlesMouse:!0};case`html5`:return{html5:!0,pointer:!1,pointerHandlesMouse:!1};case`auto`:case void 0:default:return tq()?{html5:!1,pointer:!0,pointerHandlesMouse:!0}:{html5:!0,pointer:!0,pointerHandlesMouse:!1}}}function tq(){if(globalThis.window===void 0||!globalThis.matchMedia)return!1;let e=globalThis.matchMedia(`(pointer: coarse)`).matches,t=globalThis.matchMedia(`(pointer: fine)`).matches;return e&&!t}var nq=0,rq=()=>`dv-tab-${nq++}`,iq=class extends Y{get element(){return this._element}constructor(e,t,n){var r,i,a,o,s;super(),this.panel=e,this.accessor=t,this.group=n,this.content=void 0,this.panelTransfer=dW.getInstance(),this._direction=`horizontal`,this._pinIndicator=void 0,this._onPointDown=new X,this.onPointerDown=this._onPointDown.event,this._onTabClick=new X,this.onTabClick=this._onTabClick.event,this._onDropped=new X,this.onDrop=this._onDropped.event,this._onDragStart=new X,this.onDragStart=this._onDragStart.event,this._onDragEnd=new X,this.onDragEnd=this._onDragEnd.event;let c=eq(this.accessor.options);this._element=document.createElement(`div`),this._element.className=`dv-tab`,this._element.tabIndex=-1,this._element.draggable=c.html5,this._element.id=rq(),this._element.setAttribute(`role`,`tab`),this._element.setAttribute(`aria-selected`,`false`),this._element.setAttribute(`aria-label`,this.panel.title??this.panel.id),this._element.dataset.tabPanelId=this.panel.id;let l=(r=this.group)==null||(r=r.model)==null?void 0:r.contentContainerId;l&&this._element.setAttribute(`aria-controls`,l),Q(this.element,`dv-inactive-tab`,!0),this._updatePinnedClasses();let u=(e,t)=>{if(this.group.locked)return!1;let n=fW();return this.accessor.id===n?.viewId?!(this.accessor.options.theme?.tabAnimation===`smooth`||n.tabGroupId&&n.groupId===this.group.id&&this.group.model.getTabGroupForPanel(this.panel.id)):this.group.model.canDisplayOverlay(e,t,`tab`)};this.dropTarget=MK.createDropTarget(this._element,{acceptedTargetZones:[`left`,`right`],overlayModel:this._buildOverlayModel(),canDisplayOverlay:u,getOverrideTarget:()=>n.model.dropTargetContainer?.model}),this.pointerDropTarget=NK.createDropTarget(this._element,{acceptedTargetZones:[`left`,`right`],overlayModel:this._buildOverlayModel(),canDisplayOverlay:u,getOverrideTarget:()=>n.model.dropTargetContainer?.model});let d={getData:()=>(this.panelTransfer.setData([new lW(this.accessor.id,this.group.id,this.panel.id)],lW.prototype),{dispose:()=>{this.panelTransfer.clearData(lW.prototype)}}),createGhost:()=>({element:this._buildGhostElement(),offsetX:30,offsetY:-10}),onDragStart:e=>{this._onDragStart.fire(e),!e.defaultPrevented&&!(e instanceof PointerEvent)&&this.accessor.options.theme?.tabAnimation===`smooth`&&requestAnimationFrame(()=>{Q(this.element,`dv-tab--dragging`,!0)})},onDragEnd:e=>{this._onDragEnd.fire(e)}};this.html5DragSource=MK.createDragSource(this._element,$($({},d),{},{disabled:!c.html5})),this.pointerDragSource=NK.createDragSource(this._element,$($({},d),{},{disabled:!c.pointer,touchOnly:!c.pointerHandlesMouse,isCancelled:()=>!eq(this.accessor.options).pointer})),this.onWillShowOverlay=gW.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this._onPointDown,this._onTabClick,this._onDropped,this._onDragStart,this._onDragEnd,this.accessor.onDidOptionsChange(()=>{let e=this._buildOverlayModel();this.dropTarget.setOverlayModel(e),this.pointerDropTarget.setOverlayModel(e),this._updatePinnedClasses()}),((i=this.panel.api)==null||(a=i.onDidChangePinned)==null?void 0:a.call(i,()=>{this._updatePinnedClasses()}))??{dispose:()=>{}},((o=this.panel.api)==null||(s=o.onDidTitleChange)==null?void 0:s.call(o,e=>{this._element.setAttribute(`aria-label`,e.title??this.panel.id)}))??{dispose:()=>{}},Z(this._element,`dragend`,()=>{Q(this.element,`dv-tab--dragging`,!1)}),this.html5DragSource,Z(this._element,`pointerdown`,e=>{this._onPointDown.fire(e)}),Z(this._element,`click`,e=>{this._onTabClick.fire(e)}),Z(this._element,`contextmenu`,e=>{var t;(t=this.accessor.contextMenuService)==null||t.show(this.panel,this.group,e)}),new $K(this._element,{onLongPress:e=>{var t;this.pointerDragSource.cancelPending(),(t=this.accessor.contextMenuService)==null||t.show(this.panel,this.group,e)}}),this.dropTarget.onDrop(e=>{this._onDropped.fire(e)}),this.pointerDropTarget.onDrop(e=>{this._onDropped.fire(e)}),this.dropTarget,this.pointerDropTarget,this.pointerDragSource)}_updatePinnedClasses(){let e=this.panel.api?.isPinned??!1,t=e&&this.accessor.options.pinnedTabs?.compact===!0;Q(this.element,`dv-tab--pinned`,e),Q(this.element,`dv-tab--pinned-compact`,t);let n=e&&!this.panel.api?.tabComponent;if(n&&!this._pinIndicator){let e=document.createElement(`div`);e.className=`dv-tab-pin`,e.appendChild(JK()),this._element.insertBefore(e,this._element.firstChild),this._pinIndicator=e}else!n&&this._pinIndicator&&(this._pinIndicator.remove(),this._pinIndicator=void 0)}setActive(e){Q(this.element,`dv-active-tab`,e),Q(this.element,`dv-inactive-tab`,!e),this._element.setAttribute(`aria-selected`,e?`true`:`false`),this._element.tabIndex=e?0:-1}setContent(e){this.content&&this.content.element.remove(),this.content=e,this._element.appendChild(this.content.element)}_buildOverlayModel(){var e;let t=(e=this.accessor).resolveDropOverlayModel?.call(e,`tab`,this.group);if(t)return t;let n=this.accessor.options.theme?.dndTabIndicator===`line`?1/0:0;return{activationSize:{value:50,type:`percentage`},smallWidthBoundary:n,smallHeightBoundary:n}}setDirection(e){this._direction=e;let t=e===`vertical`?[`top`,`bottom`]:[`left`,`right`];this.dropTarget.setTargetZones(t),this.pointerDropTarget.setTargetZones(t)}updateDragAndDropState(){let e=eq(this.accessor.options);this._element.draggable=e.html5,this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}_buildGhostElement(){let e=getComputedStyle(this.element),t=this.element.cloneNode(!0),n=this._direction===`vertical`,r=new Set([`writing-mode`,`inline-size`,`block-size`,`min-inline-size`,`min-block-size`,`max-inline-size`,`max-block-size`,`margin-inline`,`margin-inline-start`,`margin-inline-end`,`margin-block`,`margin-block-start`,`margin-block-end`,`padding-inline`,`padding-inline-start`,`padding-inline-end`,`padding-block`,`padding-block-start`,`padding-block-end`]);return Array.from(e).forEach(i=>{n&&r.has(i)||t.style.setProperty(i,e.getPropertyValue(i),e.getPropertyPriority(i))}),n&&(t.style.setProperty(`writing-mode`,`horizontal-tb`),t.style.setProperty(`width`,e.height),t.style.setProperty(`height`,e.width)),t.style.position=`absolute`,t.classList.add(`dv-tab-ghost-drag`),t}},aq=class{get kind(){return this.options.kind}get nativeEvent(){return this.event.nativeEvent}get position(){return this.event.position}get edge(){return this.event.edge}get edgeGroup(){return this.event.edgeGroup}get defaultPrevented(){return this.event.defaultPrevented}get panel(){return this.options.panel}get api(){return this.options.api}get group(){return this.options.group}preventDefault(){this.event.preventDefault()}getData(){return this.options.getData()}constructor(e,t){this.event=e,this.options=t}},oq=class extends Y{get group(){return this.groupAccessor()}constructor(e){var t;super(),this.panelTransfer=dW.getInstance(),this._onDragStart=new X,this.onDragStart=this._onDragStart.event,this._element=e.element,this.accessor=e.accessor;let n=e.group;this.groupAccessor=typeof n==`function`?n:()=>n,this.isFloatingMoveHandle=e.isFloatingMoveHandle??(()=>!0);let r=eq(this.accessor.options);this._element.draggable=r.html5,Q(this._element,`dv-draggable`,r.html5||r.pointer),this.addDisposables(this._onDragStart);let i=()=>{let e=document.createElement(`div`),t=globalThis.getComputedStyle(this._element),n=t.getPropertyValue(`--dv-activegroup-visiblepanel-tab-background-color`),r=t.getPropertyValue(`--dv-activegroup-visiblepanel-tab-color`);return e.style.backgroundColor=n,e.style.color=r,e.style.padding=`2px 8px`,e.style.height=`24px`,e.style.fontSize=`11px`,e.style.lineHeight=`20px`,e.style.borderRadius=`12px`,e.style.whiteSpace=`nowrap`,e.style.boxSizing=`border-box`,e.style.display=`inline-block`,e.textContent=`Multiple Panels (${this.group.size})`,e},a={getData:()=>(this.panelTransfer.setData([new lW(this.accessor.id,this.group.id,null)],lW.prototype),{dispose:()=>{this.panelTransfer.clearData(lW.prototype)}}),createGhost:()=>{var e;return(e=this.accessor).buildGroupDragGhost?.call(e,this.group)||{element:i(),offsetX:30,offsetY:-10}},onDragStart:e=>{this._onDragStart.fire(e)}};this.html5DragSource=MK.createDragSource(this._element,$($({},a),{},{disabled:!r.html5,isCancelled:e=>!!(this.group.api.location.type===`floating`&&this.isFloatingMoveHandle()&&!e.shiftKey||this.group.api.location.type===`edge`&&this.group.size===0)}));let o=()=>{var e;return((e=this.group)==null||(e=e.api)==null||(e=e.location)==null?void 0:e.type)===`floating`&&this.isFloatingMoveHandle()};this.pointerDragSource=NK.createDragSource(this._element,$($({},a),{},{disabled:!r.pointer,touchOnly:!r.pointerHandlesMouse,touchInitiationDelay:()=>o()?500:250,pressTolerance:()=>o()?1/0:8,isCancelled:()=>!eq(this.accessor.options).pointer||this.group.api.location.type===`edge`&&this.group.size===0,onDragStart:e=>{var t;let n=e.defaultPrevented;this._onDragStart.fire(e),e.defaultPrevented&&!n||(t=this.getFloatingOverlay())==null||t.cancelPendingDrag()}}));let s=new hW,c=()=>{let e=this.getFloatingOverlay();s.value=e?e.onDidStartMoving(()=>{this.pointerDragSource.cancelPending()}):mW.NONE};c(),this.addDisposables(s);let l=(t=this.group)==null||(t=t.api)==null?void 0:t.onDidLocationChange;l&&this.addDisposables(l(c)),this.addDisposables(this.html5DragSource,this.pointerDragSource)}updateDragAndDropState(){let e=eq(this.accessor.options);this._element.draggable=e.html5,Q(this._element,`dv-draggable`,e.html5||e.pointer),this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}getFloatingOverlay(){var e;if(this.group)return(e=this.accessor.floatingGroups)==null||(e=e.find(e=>e.group===this.group))==null?void 0:e.overlay}},sq=class extends Y{get element(){return this._element}constructor(e,t){var n,r,i;super(),this.accessor=e,this.group=t,this._onDrop=new X,this.onDrop=this._onDrop.event,this._onDragStart=new X,this.onDragStart=this._onDragStart.event,this._element=document.createElement(`div`),this._element.className=`dv-void-container`,this.addDisposables(this._onDrop,this._onDragStart,Z(this._element,`pointerdown`,()=>{this.accessor.doSetGroupActive(this.group)}),Z(this._element,`pointerdown`,e=>{e.shiftKey&&jW(e)},!0)),this.dragSource=new oq({element:this._element,accessor:this.accessor,group:this.group,isFloatingMoveHandle:()=>!this._element.closest(`.dv-resize-container-with-titlebar`)});let a=(e,n)=>{if(this.group.api.locked)return!1;let r=fW();return this.accessor.id===r?.viewId||t.model.canDisplayOverlay(e,n,`header_space`)};this.dropTarget=MK.createDropTarget(this._element,{acceptedTargetZones:[`center`],canDisplayOverlay:a,getOverrideTarget:()=>t.model.dropTargetContainer?.model,overlayModel:(n=this.accessor).resolveDropOverlayModel?.call(n,`header_space`,this.group)}),this.pointerDropTarget=NK.createDropTarget(this._element,{acceptedTargetZones:[`center`],canDisplayOverlay:a,getOverrideTarget:()=>t.model.dropTargetContainer?.model,overlayModel:(r=this.accessor).resolveDropOverlayModel?.call(r,`header_space`,this.group)}),this.onWillShowOverlay=gW.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this.dragSource,this.dragSource.onDragStart(e=>{this._onDragStart.fire(e)}),this.dropTarget.onDrop(e=>{this._onDrop.fire(e)}),this.pointerDropTarget.onDrop(e=>{this._onDrop.fire(e)}),this.dropTarget,this.pointerDropTarget,(i=this.accessor).onDidOptionsChange?.call(i,()=>{var e;let t=(e=this.accessor).resolveDropOverlayModel?.call(e,`header_space`,this.group)??{};this.dropTarget.setOverlayModel(t),this.pointerDropTarget.setOverlayModel(t)})??mW.NONE)}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}},cq=class e extends Y{get element(){return this._element}get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._scrollOffset=0,this._orientation=e,TW(this._scrollbar,`dv-scrollbar-vertical`,`dv-scrollbar-horizontal`),e===`vertical`?EW(this._scrollbar,`dv-scrollbar-vertical`):EW(this._scrollbar,`dv-scrollbar-horizontal`))}constructor(t){super(),this.scrollableElement=t,this._scrollOffset=0,this._orientation=`horizontal`,this._element=document.createElement(`div`),this._element.className=`dv-scrollable`,this._scrollbar=document.createElement(`div`),this._scrollbar.className=`dv-scrollbar dv-scrollbar-horizontal`,this.element.appendChild(t),this.element.appendChild(this._scrollbar),this.addDisposables(Z(this.element,`wheel`,t=>{this._scrollOffset+=t.deltaY*e.MouseWheelSpeed,this.scheduleStyleUpdate()}),Z(this._scrollbar,`pointerdown`,e=>{e.preventDefault();let t=this._scrollbar.ownerDocument??document;Q(this.element,`dv-scrollable-scrolling`,!0);let n=this._orientation===`horizontal`?e.clientX:e.clientY,r=this._scrollOffset,i=e=>{let t=this._orientation===`horizontal`?e.clientX-n:e.clientY-n,i=(this._orientation===`horizontal`?this.element.clientWidth:this.element.clientHeight)/(this._orientation===`horizontal`?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight);this._scrollOffset=r+t/i,this.scheduleStyleUpdate()},a=()=>{Q(this.element,`dv-scrollable-scrolling`,!1),t.removeEventListener(`pointermove`,i),t.removeEventListener(`pointerup`,a),t.removeEventListener(`pointercancel`,a)};t.addEventListener(`pointermove`,i),t.addEventListener(`pointerup`,a),t.addEventListener(`pointercancel`,a)}),Z(this.element,`scroll`,()=>{this.scheduleStyleUpdate()}),Z(this.scrollableElement,`scroll`,()=>{this._scrollOffset=this._orientation===`horizontal`?this.scrollableElement.scrollLeft:this.scrollableElement.scrollTop,this.scheduleStyleUpdate()}),wW(this.element,()=>{Q(this.element,`dv-scrollable-resizing`,!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),Q(this.element,`dv-scrollable-resizing`,!1)},500),this.scheduleStyleUpdate()}),mW.from(()=>{this._pendingStyleFrame!==void 0&&(cancelAnimationFrame(this._pendingStyleFrame),this._pendingStyleFrame=void 0)}))}scheduleStyleUpdate(){this._pendingStyleFrame===void 0&&(this._pendingStyleFrame=requestAnimationFrame(()=>{this._pendingStyleFrame=void 0,this.calculateScrollbarStyles()}))}calculateScrollbarStyles(){let e=this._orientation===`horizontal`?this.element.clientWidth:this.element.clientHeight,t=this._orientation===`horizontal`?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight;if(t>e){let n=e/t*e;this._orientation===`horizontal`?(this._scrollbar.style.width=`${n}px`,this._scrollbar.style.height=``):(this._scrollbar.style.height=`${n}px`,this._scrollbar.style.width=``),this._scrollOffset=mG(this._scrollOffset,0,t-e),this._orientation===`horizontal`?this.scrollableElement.scrollLeft=this._scrollOffset:this.scrollableElement.scrollTop=this._scrollOffset;let r=this._scrollOffset/(t-e);this._orientation===`horizontal`?(this._scrollbar.style.left=`${(e-n)*r}px`,this._scrollbar.style.top=``):(this._scrollbar.style.top=`${(e-n)*r}px`,this._scrollbar.style.left=``)}else this._orientation===`horizontal`?(this._scrollbar.style.width=`0px`,this._scrollbar.style.left=`0px`):(this._scrollbar.style.height=`0px`,this._scrollbar.style.top=`0px`),this._scrollOffset=0}};cq.MouseWheelSpeed=1;var lq=`dv-tabs-container--wrap`;function uq(e,t){return typeof e==`boolean`?e:!!e?.[t]}function dq(e){return typeof e==`boolean`?e:e?Object.values(e).some(Boolean):!1}var fq=class extends vW{constructor(e,t,n,r,i){super(),this.nativeEvent=e,this.target=t,this.position=n,this.getData=r,this.group=i}},pq=Object.keys({disableAutoResizing:void 0,proportionalLayout:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,transformFloatingGroupDrag:void 0,smartGuides:void 0,floatingGroupDragHandle:void 0,popoutUrl:void 0,nonce:void 0,defaultRenderer:void 0,defaultHeaderPosition:void 0,debug:void 0,locked:void 0,disableDnd:void 0,dndStrategy:void 0,className:void 0,noPanelsOverlay:void 0,closeEmptyGroups:void 0,groupIdGenerator:void 0,dndEdges:void 0,dropPositionResolver:void 0,dndCompass:void 0,dropSizing:void 0,theme:void 0,disableTabsOverflowList:void 0,overflow:void 0,scrollbars:void 0,getTabContextMenuItems:void 0,getTabGroupChipContextMenuItems:void 0,createTabGroupChipComponent:void 0,createGroupDragGhostComponent:void 0,dropOverlayModel:void 0,announcements:void 0,getAnnouncement:void 0,announcer:void 0,messages:void 0,keyboardNavigation:void 0,layoutHistory:void 0,autoHideEdgeGroups:void 0,dockToEdgeGroups:void 0,edgeGroupPeek:void 0,tabGroupColors:void 0,tabGroupAccent:void 0,pinnedTabs:void 0});function mq(e){return!!e.referencePanel}function hq(e){return!!e.referenceGroup}function gq(e){return!!e.referencePanel}function _q(e){return!!e.referenceGroup}var vq=[{id:`grey`,value:`var(--dv-tab-group-color-grey)`,label:`Grey`},{id:`blue`,value:`var(--dv-tab-group-color-blue)`,label:`Blue`},{id:`red`,value:`var(--dv-tab-group-color-red)`,label:`Red`},{id:`yellow`,value:`var(--dv-tab-group-color-yellow)`,label:`Yellow`},{id:`green`,value:`var(--dv-tab-group-color-green)`,label:`Green`},{id:`pink`,value:`var(--dv-tab-group-color-pink)`,label:`Pink`},{id:`purple`,value:`var(--dv-tab-group-color-purple)`,label:`Purple`},{id:`cyan`,value:`var(--dv-tab-group-color-cyan)`,label:`Cyan`},{id:`orange`,value:`var(--dv-tab-group-color-orange)`,label:`Orange`}],yq=class{constructor(e,t=!0){this._entries=e.slice(),this._byId=new Map(e.map(e=>[e.id,e])),this._enabled=t}get enabled(){return this._enabled}set enabled(e){this._enabled=e}setEntries(e){this._entries=e.slice(),this._byId=new Map(e.map(e=>[e.id,e]))}entries(){return this._entries}has(e){return this._byId.has(e)}get(e){return this._byId.get(e)}defaultId(){return this._entries[0]?.id}resolveValue(e){if(!this._enabled||!e)return;let t=this._byId.get(e);return t?t.value:e}},bq;function xq(){return bq??=new yq(vq,!0),bq}function Sq(e,t,n){let r=(n??xq()).resolveValue(t);r===void 0?e.style.removeProperty(`--dv-tab-group-color`):e.style.setProperty(`--dv-tab-group-color`,r)}function Cq(e,t){return(t??xq()).resolveValue(e)}var wq=class extends Y{get element(){return this._element}constructor(e){super(),this._palette=e,this._onClick=new X,this.onClick=this._onClick.event,this._onContextMenu=new X,this.onContextMenu=this._onContextMenu.event,this._element=document.createElement(`div`),this._element.className=`dv-tab-group-chip`,this._element.tabIndex=0,this._label=document.createElement(`span`),this._label.className=`dv-tab-group-chip-label`,this._element.appendChild(this._label),this.addDisposables(this._onClick,this._onContextMenu,new $K(this._element,{onLongPress:e=>{this._onContextMenu.fire(e)}}),Z(this._element,`click`,e=>{this._onClick.fire(e)}),Z(this._element,`contextmenu`,e=>{this._onContextMenu.fire(e)}))}init(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed),this.addDisposables(e.tabGroup.onDidChange(()=>{this._tabGroup&&(this.updateColor(this._tabGroup.color),this.updateLabel(this._tabGroup.label))}),e.tabGroup.onDidCollapseChange(e=>{this.updateCollapsed(e)}),this._onClick.event(()=>{var e;(e=this._tabGroup)==null||e.toggle()}))}update(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed)}updateColor(e){Sq(this._element,e,this._palette),Q(this._element,`dv-tab-group-chip--accent-off`,this._palette?.enabled===!1)}updateLabel(e){this._label.textContent=e,Q(this._label,`dv-tab-group-chip-label--empty`,!e)}updateCollapsed(e){Q(this._element,`dv-tab-group-chip--collapsed`,e)}},Tq=`dv-tab-group-chip-continuation`,Eq=8,Dq=class{get underlines(){return this._underlines}constructor(e){this._ctx=e,this._underlines=new Map,this._continuationMarkers=new Map,this._rafId=null}positionUnderlines(){requestAnimationFrame(()=>{this._positionUnderlinesSync()})}trackUnderlines(){this._rafId!==null&&cancelAnimationFrame(this._rafId);let e=performance.now(),t=()=>{this._positionUnderlinesSync(),this._rafId=performance.now()-e<250?requestAnimationFrame(t):null};this._rafId=requestAnimationFrame(t)}syncUnderlineElements(e){for(let t of e)if(!this._underlines.has(t)){let e=document.createElement(`div`);e.className=`dv-tab-group-underline`,this._ctx.tabsList.appendChild(e),this._underlines.set(t,e)}for(let[t,n]of this._underlines)e.has(t)||(n.remove(),this._underlines.delete(t),this._clearContinuationMarkers(t))}getUnderline(e){return this._underlines.get(e)}dispose(){this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null);for(let[,e]of this._underlines)e.remove();this._underlines.clear(),this._clearContinuationMarkers()}_syncContinuationMarkers(e,t){let n=this._continuationMarkers.get(e);for(n||(n=[],this._continuationMarkers.set(e,n));n.length<t;){let e=document.createElement(`div`);e.className=Tq,this._ctx.tabsList.appendChild(e),n.push(e)}for(;n.length>t;)n.pop()?.remove();return n}_clearContinuationMarkers(e){if(e===void 0){for(let[,e]of this._continuationMarkers)for(let t of e)t.remove();this._continuationMarkers.clear();return}let t=this._continuationMarkers.get(e);if(t){for(let e of t)e.remove();this._continuationMarkers.delete(e)}}_positionUnderlinesSync(){let e=this._ctx.tabsList.getBoundingClientRect(),t=this._ctx.getTabGroups(),n=this._ctx.getDirection()===`vertical`,r=this._ctx.tabsList.classList.contains(lq);r||this._clearContinuationMarkers();let i=n?e.width:e.height,a=this._ctx.getActivePanelId(),o=this._ctx.getTabMap();for(let s of t){let t=this._underlines.get(s.id);if(!t)continue;let c=s.panelIds;if(c.length===0){t.style.display=`none`;continue}if(t.style.display=``,r){this._positionWrappedUnderline(t,s,e,o,n);continue}let l=this._ctx.getChipElement(s.id),u;if(l){let t=l.getBoundingClientRect(),r=getComputedStyle(l),i=n?Number.parseFloat(r.marginTop)||0:Number.parseFloat(r.marginLeft)||0;u=n?t.top-e.top-i:t.left-e.left-i}else{let t=c[0],r=o.get(t);if(r){let t=r.value.element.getBoundingClientRect();u=n?t.top-e.top:t.left-e.left}else u=0}let d=c[c.length-1],f=o.get(d);if(!f){n?(t.style.top=`${u}px`,t.style.height=`0px`,t.style.left=``,t.style.width=``):(t.style.left=`${u}px`,t.style.width=`0px`,t.style.top=``,t.style.height=``);continue}let p=f.value.element.getBoundingClientRect(),m=n?p.bottom-e.top:p.right-e.left,h=m-u;if((s.collapsed||s.panelIds.some(e=>o.get(e)?.value.element.classList.contains(`dv-tab--group-expanding`)))&&l){let t=l.getBoundingClientRect(),r=n?t.top+t.height/2-e.top:t.left+t.width/2-e.left,i=0,a=0;for(let e of s.panelIds){let t=o.get(e);if(!t)continue;let r=t.value.element;n?(i+=r.getBoundingClientRect().height,a+=r.scrollHeight):(i+=r.getBoundingClientRect().width,a+=r.scrollWidth)}let c=a>0?Math.min(1,i/a):0;u=r+(u-r)*c,m=r+(m-r)*c,h=Math.max(0,m-u)}n?(t.style.top=`${u}px`,t.style.height=`${Math.max(0,h)}px`,t.style.left=``,t.style.width=``,t.style.bottom=``):(t.style.left=`${u}px`,t.style.width=`${Math.max(0,h)}px`,t.style.top=``,t.style.height=``,t.style.bottom=``),this.applyShape(t,s,u,h,i,a,e,n)}}_positionWrappedUnderline(e,t,n,r,i){let a=Cq(t.color,this._ctx.getColorPalette());if(a===void 0){e.style.display=`none`,this._clearContinuationMarkers(t.id);return}let{runs:o,firstRun:s}=this._computeWrappedRuns(t,n,r,i);if(o.length===0){e.style.display=`none`,this._clearContinuationMarkers(t.id);return}this._positionContinuationMarkers(t.id,o,s,a,i);let c=Math.min(...o.map(e=>e.left)),l=Math.max(...o.map(e=>e.right)),u=Math.min(...o.map(e=>e.top)),d=Math.max(...o.map(e=>e.bottom)),f=i?Math.max(0,l-c):n.width,p=i?n.height:Math.max(0,d-u);e.style.left=i?`${c}px`:`0px`,e.style.top=i?`0px`:`${u}px`,e.style.bottom=`auto`,e.style.width=`${f}px`,e.style.height=`${p}px`,e.style.backgroundColor=``;let{svg:m,path:h}=this.ensureSvgPath(e);m.setAttribute(`width`,String(f)),m.setAttribute(`height`,String(p)),h.setAttribute(`stroke`,a),h.setAttribute(`stroke-width`,`2`);let g=this._ctx.getHeaderPosition(),_=i?g===`right`:g===`bottom`;h.setAttribute(`d`,this._wrappedPathData(o,i,_,c,u,2))}_computeWrappedRuns(e,t,n,r){let i=[],a;for(let o of e.panelIds){let e=n.get(o);if(!e)continue;let s=e.value.element.getBoundingClientRect();if(s.width===0&&s.height===0)continue;let c=s.top-t.top,l=s.bottom-t.top,u=s.left-t.left,d=s.right-t.left,f=r?u:c,p=i.find(e=>Math.abs((r?e.left:e.top)-f)<=2);p?(p.top=Math.min(p.top,c),p.bottom=Math.max(p.bottom,l),p.left=Math.min(p.left,u),p.right=Math.max(p.right,d)):(p={top:c,bottom:l,left:u,right:d},i.push(p)),a??=p}return{runs:i,firstRun:a}}_wrappedPathData(e,t,n,r,i,a){let o=``;for(let s of e)if(t){let e=n?s.right-r-a/2:s.left-r+a/2;o+=`M ${e},${s.top} L ${e},${s.bottom} `}else{let e=n?s.top-i+a/2:s.bottom-i-a/2;o+=`M ${s.left},${e} L ${s.right},${e} `}return o.trim()}_positionContinuationMarkers(e,t,n,r,i){let a=t.filter(e=>e!==n),o=this._syncContinuationMarkers(e,a.length);a.forEach((e,t)=>{let n=o[t];if(n.style.backgroundColor=r,i){let t=(e.left+e.right)/2;n.style.left=`${t-Eq/2}px`,n.style.top=`${e.top}px`}else{let t=(e.top+e.bottom)/2;n.style.left=`${e.left}px`,n.style.top=`${t-Eq/2}px`}})}ensureSvgPath(e){let t=e.firstElementChild;if(t?.tagName===`svg`)return{svg:t,path:t.firstElementChild};e.replaceChildren();let n=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);n.style.display=`block`;let r=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return r.setAttribute(`fill`,`none`),n.appendChild(r),e.appendChild(n),{svg:n,path:r}}},Oq=class extends Dq{_applyStraightLine(e,t,n,r,i,a,o){let s=o?i:r,c=o?r:i;e.setAttribute(`width`,String(s)),e.setAttribute(`height`,String(c)),n.style.width=`${s}px`,n.style.height=`${c}px`,t.setAttribute(`d`,o?`M ${a},0 L ${a},${r}`:`M 0,${a} L ${r},${a}`)}applyShape(e,t,n,r,i,a,o,s){let c=i,l=r,u=Cq(t.color,this._ctx.getColorPalette());if(l<=0||c<=0||u===void 0){e.style.display=`none`;return}e.style.display=``;let d;a&&t.panelIds.includes(a)&&(d=this._ctx.getTabMap().get(a));let{svg:f,path:p}=this.ensureSvgPath(e);p.setAttribute(`stroke`,u),p.setAttribute(`stroke-width`,`2`);let m=this._ctx.getHeaderPosition(),h=!s&&m===`bottom`,g=s&&m===`right`,_,v;if(s?(_=g?c-2:2,v=g?2:c-2):(_=h?2:c-2,v=h?c-2:2),!d){this._applyStraightLine(f,p,e,l,c,_,s);return}let y=d.value.element.getBoundingClientRect(),b,x;if(s?(b=Math.max(0,y.top-o.top-n),x=Math.min(l,y.bottom-o.top-n)):(b=Math.max(0,y.left-o.left-n),x=Math.min(l,y.right-o.left-n)),x<=b){this._applyStraightLine(f,p,e,l,c,_,s);return}let S=v>_?1:-1;if(s){let t=c,n=l;f.setAttribute(`width`,String(t)),f.setAttribute(`height`,String(n)),e.style.width=`${t}px`,e.style.height=`${n}px`;let r=[`M ${_},0`,`L ${_},${b-6}`,`Q ${_},${b} ${_+S*6},${b}`,`L ${v-S*6},${b}`,`Q ${v},${b} ${v},${b+6}`,`L ${v},${x-6}`,`Q ${v},${x} ${v-S*6},${x}`,`L ${_+S*6},${x}`,`Q ${_},${x} ${_},${x+6}`,`L ${_},${n}`].join(` `);p.setAttribute(`d`,r)}else{let t=l,n=c;f.setAttribute(`width`,String(t)),f.setAttribute(`height`,String(n)),e.style.width=`${t}px`,e.style.height=`${n}px`;let r=[`M 0,${_}`,`L ${b-6},${_}`,`Q ${b},${_} ${b},${_+S*6}`,`L ${b},${v-S*6}`,`Q ${b},${v} ${b+6},${v}`,`L ${x-6},${v}`,`Q ${x},${v} ${x},${v-S*6}`,`L ${x},${_+S*6}`,`Q ${x},${_} ${x+6},${_}`,`L ${t},${_}`].join(` `);p.setAttribute(`d`,r)}}},kq=class extends Dq{applyShape(e,t,n,r,i,a,o,s){let c=Cq(t.color,this._ctx.getColorPalette());r<=0||c===void 0?e.style.display=`none`:(e.style.display=``,e.firstElementChild&&e.replaceChildren(),e.style.backgroundColor=c,s?(e.style.width=`2px`,e.style.height=`${r}px`):(e.style.width=`${r}px`,e.style.height=`2px`))}},Aq=new Map,jq=class{get chipRenderers(){return this._chipRenderers}get groupUnderlines(){return this._indicator?.underlines??Aq}get skipNextCollapseAnimation(){return this._skipNextCollapseAnimation}set skipNextCollapseAnimation(e){this._skipNextCollapseAnimation=e}constructor(e,t){this._ctx=e,this._callbacks=t,this._chipRenderers=new Map,this._indicator=null,this._skipNextCollapseAnimation=!1,this._pendingTransitionCleanups=new Map}update(){let e=this._ctx.group.model.getTabGroups(),t=new Set;for(let n of e)t.add(n.id),this._ensureChipForGroup(n),this._positionChipForGroup(n);for(let[e,r]of this._chipRenderers)if(!t.has(e)){var n;r.chip.element.remove(),r.chip.dispose(),(n=r.dragSourcesDisposable)==null||n.dispose(),r.disposable.dispose(),this._chipRenderers.delete(e)}this._updateTabGroupClasses()}refreshAccents(){for(let n of this._ctx.group.model.getTabGroups()){var e,t;let r=this._chipRenderers.get(n.id);r==null||(t=(e=r.chip).update)==null||t.call(e,{tabGroup:n})}this._updateTabGroupClasses()}positionAllChips(){if(this._chipRenderers.size!==0)for(let e of this._ctx.group.model.getTabGroups())this._positionChipForGroup(e)}updateDirection(){let e=this._ctx.getDirection()===`vertical`;for(let[,t]of this._chipRenderers){let n=e?[`top`]:[`left`];t.dropTarget.setTargetZones(n),t.pointerDropTarget.setTargetZones(n)}}clearChipDropOverlays(){for(let[,n]of this._chipRenderers){var e,t;(e=n.dropTarget)==null||e.clearOverlay(),(t=n.pointerDropTarget)==null||t.clearOverlay()}}snapshotChipSizes(){let e=this._ctx.getDirection()===`vertical`,t=new Map;for(let[n,r]of this._chipRenderers){let i=r.chip.element.getBoundingClientRect();t.set(n,e?i.height:i.width)}return t}positionUnderlines(){var e;(e=this._indicator)==null||e.positionUnderlines()}trackUnderlines(){var e;(e=this._indicator)==null||e.trackUnderlines()}setGroupDragImage(e,t,n){if(!e.dataTransfer)return;let r=this._ctx.getDirection()===`vertical`,i=this._ctx.tabsList.cloneNode(!0);r?(i.classList.remove(`dv-tabs-container-vertical`,`dv-vertical`),i.classList.add(`dv-horizontal`),i.style.writingMode=`horizontal-tb`,i.style.height=`${this._ctx.tabsList.offsetWidth}px`):i.style.height=`${this._ctx.tabsList.offsetHeight}px`,i.style.width=`auto`,i.style.overflow=`visible`,i.style.pointerEvents=`none`;let a=Array.from(i.children),o=Array.from(this._ctx.tabsList.children);for(let e=a.length-1;e>=0;e--)o[e]!==n&&a[e].remove();let s=document.createElement(`div`);s.className=`dv-groupview dv-active-group`,s.style.position=`fixed`,s.style.top=`-10000px`,s.style.left=`0px`,s.style.height=`auto`,s.style.width=`auto`,s.style.pointerEvents=`none`;let c=document.createElement(`div`);c.className=`dv-tabs-and-actions-container`,c.style.height=`auto`,c.style.width=`auto`,s.appendChild(c),c.appendChild(i),this._ctx.accessor.element.appendChild(s);let l=i.querySelector(`.dv-tab-group-chip`),u=n.getBoundingClientRect(),d=e.clientX-u.left,f=e.clientY-u.top;if(l){let t=l.getBoundingClientRect(),n=s.getBoundingClientRect(),r=t.left-n.left+d,i=t.top-n.top+f;e.dataTransfer.setDragImage(s,r,i)}else e.dataTransfer.setDragImage(s,d,f);requestAnimationFrame(()=>{s.remove()})}cleanupTransition(e){var t;(t=this._pendingTransitionCleanups.get(e))==null||t(),this._pendingTransitionCleanups.delete(e)}updateDragAndDropState(){let e=eq(this._ctx.accessor.options);for(let i of this._chipRenderers.values()){var t,n,r;i.chip.element.draggable=e.html5,(t=i.html5DragSource)==null||t.setDisabled(!e.html5),(n=i.pointerDragSource)==null||n.setDisabled(!e.pointer),(r=i.pointerDragSource)==null||r.setTouchOnly(!e.pointerHandlesMouse)}}disposeChipDrag(e){var t;let n=this._chipRenderers.get(e);n&&((t=n.dragSourcesDisposable)==null||t.dispose(),n.html5DragSource=void 0,n.pointerDragSource=void 0,n.dragSourcesDisposable=void 0)}_buildChipGhostElement(e){let t=getComputedStyle(e),n=e.cloneNode(!0);return Array.from(t).forEach(e=>{n.style.setProperty(e,t.getPropertyValue(e),t.getPropertyPriority(e))}),n.style.position=`absolute`,n}disposeAll(){var e;(e=this._indicator)==null||e.dispose(),this._indicator=null;for(let[,e]of this._pendingTransitionCleanups)e();this._pendingTransitionCleanups.clear();for(let[,e]of this._chipRenderers){var t;e.chip.element.remove(),e.chip.dispose(),(t=e.dragSourcesDisposable)==null||t.dispose(),e.disposable.dispose()}this._chipRenderers.clear()}_ensureIndicator(){let e=(this._ctx.accessor.options.theme?.tabGroupIndicator??`wrap`)===`none`?kq:Oq;this._indicator&&!(this._indicator instanceof e)&&(this._indicator.dispose(),this._indicator=null),this._indicator??=new e({tabsList:this._ctx.tabsList,getTabGroups:()=>this._ctx.group.model.getTabGroups(),getActivePanelId:()=>this._ctx.group.activePanel?.id,getTabMap:()=>this._ctx.getTabMap(),getChipElement:e=>this._chipRenderers.get(e)?.chip.element,getDirection:()=>this._ctx.getDirection(),getHeaderPosition:()=>this._ctx.group.model.headerPosition,getColorPalette:()=>this._ctx.accessor.tabGroupColorPalette})}_createChipDragSources(e,t){let n=eq(this._ctx.accessor.options);e.element.draggable=n.html5;let r=dW.getInstance(),i=()=>(r.setData([new lW(this._ctx.accessor.id,this._ctx.group.id,null,t.id)],lW.prototype),{dispose:()=>{r.clearData(lW.prototype)}}),a=MK.createDragSource(e.element,{getData:i,disabled:!n.html5,isCancelled:()=>!eq(this._ctx.accessor.options).html5,onDragStart:n=>{`dataTransfer`in n&&n.dataTransfer&&this.setGroupDragImage(n,t,e.element),this._callbacks.onChipDragStart(t,e,n)},onDragEnd:n=>{var r,i;(r=(i=this._callbacks).onChipDragEnd)==null||r.call(i,t,e,n)}}),o=()=>{r.clearData(lW.prototype)};e.element.addEventListener(`dragend`,o,{once:!0});let s=NK.createDragSource(e.element,{getData:i,disabled:!n.pointer,touchOnly:!n.pointerHandlesMouse,isCancelled:()=>!eq(this._ctx.accessor.options).pointer,createGhost:()=>({element:this._buildChipGhostElement(e.element),offsetX:8,offsetY:8}),onDragStart:n=>{this._callbacks.onChipDragStart(t,e,n)}});return{html5DragSource:a,pointerDragSource:s,disposable:{dispose:()=>{a.dispose(),s.dispose(),e.element.removeEventListener(`dragend`,o)}}}}_ensureChipForGroup(e){let t=this._chipRenderers.get(e.id);if(t){if(!t.html5DragSource){let n=this._createChipDragSources(t.chip,e);t.html5DragSource=n.html5DragSource,t.pointerDragSource=n.pointerDragSource,t.dragSourcesDisposable=n.disposable}return}let n=this._ctx.accessor.options.createTabGroupChipComponent,r=n?n(e):new wq(this._ctx.accessor.tabGroupColorPalette);r.init({tabGroup:e,api:this._ctx.accessor.api});let i=this._createChipDragSources(r,e),a=[e.onDidChange(()=>{var t;(t=r.update)==null||t.call(r,{tabGroup:e}),this._updateTabGroupClasses()}),e.onDidPanelChange(()=>{this._positionChipForGroup(e),this._updateTabGroupClasses()}),e.onDidCollapseChange(()=>{this._updateTabGroupClasses()})],o=t=>{var n;(n=this._chipRenderers.get(e.id))==null||(n=n.pointerDragSource)==null||n.cancelPending(),this._callbacks.onChipContextMenu(e,t)};r instanceof wq?a.push(r.onContextMenu(o)):a.push(new $K(r.element,{onLongPress:o}),Z(r.element,`contextmenu`,o));let s={acceptedTargetZones:this._ctx.getDirection()===`vertical`?[`top`]:[`left`],overlayModel:{activationSize:{value:100,type:`percentage`}},canDisplayOverlay:(e,t)=>{if(this._ctx.group.locked||this._ctx.accessor.options.disableDnd)return!1;let n=fW();return this._ctx.accessor.id===n?.viewId?!(this._ctx.accessor.options.theme?.tabAnimation===`smooth`&&!n.tabGroupId):this._ctx.group.model.canDisplayOverlay(e,t,`tab`)}},c=MK.createDropTarget(r.element,s),l=NK.createDropTarget(r.element,s),u=t=>{this._callbacks.onChipDrop(e,t)};a.push(c,c.onDrop(u),l,l.onDrop(u));let d=new Y(...a);this._chipRenderers.set(e.id,{chip:r,html5DragSource:i.html5DragSource,pointerDragSource:i.pointerDragSource,dragSourcesDisposable:i.disposable,disposable:d,dropTarget:c,pointerDropTarget:l}),e.collapsed&&(this._skipNextCollapseAnimation=!0)}_positionChipForGroup(e){let t=this._chipRenderers.get(e.id);if(!t)return;let n=t.chip.element,r=e.panelIds;if(r.length===0){n.remove();return}let i=r[0],a=this._ctx.getTabMap().get(i);if(!a){n.remove();return}let o=a.value.element;n.nextSibling!==o&&this._ctx.tabsList.insertBefore(n,o)}_updateTabGroupClasses(){let e=this._ctx.group.model.getTabGroups(),t=this._ctx.getTabs(),n=this._ctx.getTabMap(),r=!1,i=new Map;for(let t of e)for(let e of t.panelIds)i.set(e,t);for(let e of t){let t=e.value,n=t.panel.id,o=i.get(n),s=!!o;if(Q(t.element,`dv-tab--grouped`,s),o){let e=o.panelIds,i=e[0]===n,s=e[e.length-1]===n;Q(t.element,`dv-tab--group-first`,i),Q(t.element,`dv-tab--group-last`,s),Sq(t.element,o.color,this._ctx.accessor.tabGroupColorPalette);let c=t.element.classList.contains(`dv-tab--group-collapsed`);if(!o.collapsed&&c){var a;r=!0,t.element.classList.remove(`dv-tab--group-collapsed`),t.element.classList.add(`dv-tab--group-expanding`),(a=this._pendingTransitionCleanups.get(n))==null||a();let e=()=>{t.element.classList.remove(`dv-tab--group-expanding`),t.element.style.removeProperty(`width`),t.element.removeEventListener(`transitionend`,e),clearTimeout(i),this._pendingTransitionCleanups.delete(n)},i=setTimeout(e,300);this._pendingTransitionCleanups.set(n,e),t.element.addEventListener(`transitionend`,e)}}else Q(t.element,`dv-tab--group-first`,!1),Q(t.element,`dv-tab--group-last`,!1),t.element.classList.remove(`dv-tab--group-collapsed`,`dv-tab--group-expanding`),t.element.style.removeProperty(`width`),t.element.style.removeProperty(`--dv-tab-group-color`)}let o=new Set;for(let t of e)if(o.add(t.id),t.collapsed&&t.panelIds.some(e=>{let t=n.get(e);return t&&!t.value.element.classList.contains(`dv-tab--group-collapsed`)})){if(this._skipNextCollapseAnimation){let e=[];for(let r of t.panelIds){let t=n.get(r);t&&(t.value.element.style.transition=`none`,t.value.element.classList.add(`dv-tab--group-collapsed`),e.push(t.value.element))}if(e.length>0){e[0].offsetHeight;for(let t of e)t.style.removeProperty(`transition`)}}else{r=!0;let e=this._ctx.getDirection()===`vertical`;for(let r of t.panelIds){let t=n.get(r);if(t&&!t.value.element.classList.contains(`dv-tab--group-collapsed`)){let n=t.value.element.getBoundingClientRect();e?t.value.element.style.height=`${n.height}px`:t.value.element.style.width=`${n.width}px`,t.value.element.offsetHeight,t.value.element.classList.add(`dv-tab--group-collapsed`)}}}}this._skipNextCollapseAnimation=!1,this._ensureIndicator(),this._indicator&&(this._indicator.syncUnderlineElements(o),r?this._indicator.trackUnderlines():this._indicator.positionUnderlines())}};function Mq(e,t){return t===`vertical`?e.height:e.width}function Nq(e,t){return t===`vertical`?e.top:e.left}function Pq(e,t){return t===`vertical`?e.clientY:e.clientX}var Fq=class extends Y{get _tabs(){return this.host.tabItems}get _tabMap(){return this.host.tabMap}get _tabsList(){return this.host.tabsList}get _direction(){return this.host.direction}get group(){return this.host.groupPanel}get accessor(){return this.host.component}get _tabGroupManager(){return this.host.tabGroupManager}get _wrapMode(){return this._tabsList.classList.contains(lq)}get animState(){return this._animState}set animState(e){this._animState=e}get pendingCollapse(){return this._pendingCollapse}set pendingCollapse(e){this._pendingCollapse=e}set voidContainerElement(e){this._voidContainer=e}constructor(e){super(),this.host=e,this._animState=null,this._pendingMarginCleanups=new Map,this._pendingCollapse=!1,this._flipTransitionCleanup=null,this._voidContainer=null,this._extendedDropZone=null,this._pointerInsideTabsList=!1,this._wrapIndicatorEl=null,this.addDisposables({dispose:()=>{var e;(e=this._flipTransitionCleanup)==null||e.call(this)}})}setExtendedDropZone(e){this._extendedDropZone=e}setExternalInsertionIndex(e){this._animState&&e!==this._animState.currentInsertionIndex&&(this._animState.currentInsertionIndex=e,this.applyDragOverTransforms())}clearExternalAnimState(){this._animState&&(this.resetTabTransforms(),this._animState.sourceIndex===-1?this._animState=null:this._animState.currentInsertionIndex=null)}snapshotTabPositions(){let e=new Map;for(let t of this._tabs)e.set(t.value.panel.id,t.value.element.getBoundingClientRect());return e}_mainAxisSize(e){return Mq(e,this._direction)}_mainAxisStart(e){return Nq(e,this._direction)}_mainAxisCoord(e,t){return Pq({clientX:e,clientY:t},this._direction)}get _gapMarginProperty(){return this._direction===`vertical`?`margin-top`:`margin-left`}getAverageTabSize(){if(this._tabs.length===0)return 0;let e=0;for(let t of this._tabs)e+=this._mainAxisSize(t.value.element.getBoundingClientRect());return e/this._tabs.length}handlePointerDragMove(e,t){let n=BW(this._tabsList).elementFromPoint(e,t);n&&(this._tabsList.contains(n)||this._extendedDropZone&&this._extendedDropZone.contains(n))?(this._pointerInsideTabsList=!0,this.processDragOver(e,t)):this._pointerInsideTabsList&&(this._pointerInsideTabsList=!1,this.processDragLeave(n))}handlePointerDragEnd(e){if(e&&this._animState&&this._animState.sourceIndex!==-1&&this._animState.currentInsertionIndex!==null&&this.isPointInsideTabsList(e.clientX,e.clientY)){let t=this._animState.sourceTabGroupId;if(t){let e=this._animState.currentInsertionIndex;this._animState=null,this.commitGroupMove(t,e)}else this.commitPointerReorder(e.pointerEvent)}this._pointerInsideTabsList=!1,this.resetDragAnimation()}isPointInsideTabsList(e,t){let n=BW(this._tabsList).elementFromPoint(e,t);return!!n&&this._tabsList.contains(n)}resolveTabDrop(e){let t=e.currentInsertionIndex;if(t===null)return null;let{sourceIndex:n,targetTabGroupId:r}=e,i=t-+(n!==-1&&n<t);return i===n&&r===(this.group.model.getTabGroupForPanel(e.sourceTabId)?.id??null)?null:{index:i,targetTabGroupId:r}}commitPointerReorder(e){let t=this._animState;if(t?.currentInsertionIndex==null)return;let n=this.resolveTabDrop(t);this._animState=null,this.clearWrapDropIndicator(),this.uncollapseSourceTab(t.sourceTabId),n&&this.host.fireDrop($({event:e},n))}processDragOver(e,t){if(this.accessor.options.disableDnd||(this._dropStaleAnimState(),!this._animState&&!this._initAnimStateForExternalDrag()))return!1;if(this._animState.sourceIndex!==-1){var n;(n=this.group.model.dropTargetContainer)==null||(n=n.model)==null||n.clear()}return this.handleDragOver({clientX:e,clientY:t}),!0}_dropStaleAnimState(){if(!this._animState)return;let e=fW();e?.tabGroupId&&e.groupId!==this.group.id&&this._animState.sourceTabGroupId!==e.tabGroupId&&(this._animState=null)}_initAnimStateForExternalDrag(){let e=fW();if(this.accessor.options.theme?.tabAnimation==="default"&&!e?.tabGroupId||!e||!(e.panelId||e.tabGroupId)||e.groupId===this.group.id)return!1;let t=this.getAverageTabSize();return this._animState=e.tabGroupId?this._makeGroupDragAnimState(e,t):this._makeTabDragAnimState(e,t),!0}_makeGroupDragAnimState(e,t){let n=this.accessor.getPanel(e.groupId)?.model.getTabGroups().find(t=>t.id===e.tabGroupId),r=t*(n?.panelIds.length??1)+t;return{sourceTabId:``,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipSizes:this._tabGroupManager.snapshotChipSizes(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.tabGroupId,sourceGroupPanelIds:n?new Set(n.panelIds):new Set,sourceChipSize:t,cursorOffsetFromDragStart:r/2,sourceGapSize:r,containerStart:this._mainAxisStart(this._tabsList.getBoundingClientRect())}}_makeTabDragAnimState(e,t){return{sourceTabId:e.panelId,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipSizes:this._tabGroupManager.snapshotChipSizes(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipSize:0,cursorOffsetFromDragStart:t/2,sourceGapSize:t,containerStart:this._mainAxisStart(this._tabsList.getBoundingClientRect())}}processDragLeave(e){this._animState&&(e&&this._tabsList.contains(e)||(e&&this._extendedDropZone?.contains(e)?(this.resetTabTransforms(),this._animState.currentInsertionIndex=null):this._voidContainer&&e&&(e===this._voidContainer||this._voidContainer.contains(e))||(this.resetTabTransforms(),this._animState.sourceIndex===-1?(this.clearHeaderAnchorOverlay(),this._animState=null):this._animState.currentInsertionIndex=null)))}clearHeaderAnchorOverlay(){var e;let t=this.group.model.dropTargetContainer,n=t?.renderedOutline;n&&![this._tabsList,this._voidContainer,this._extendedDropZone].some(e=>e?.contains(n))||t==null||(e=t.model)==null||e.clear()}handleDragOver(e){if(!this._animState)return;if(this._wrapMode&&!this._animState.sourceTabGroupId){this.handleWrappedDragOver(e.clientX,e.clientY??0);return}let t=this._mainAxisCoord(e.clientX,e.clientY??0),n=this._buildFirstPanelToGroupMap(),r=this._computeDragOverInsertionIndex(t,n),i=null;if(r!==null&&this._tabGroupManager.chipRenderers.size>0){let e=this._resolveInsertionAgainstTabGroups(t,r,n);r=e.insertionIndex,i=e.targetTabGroupId}(r!==this._animState.currentInsertionIndex||i!==this._animState.targetTabGroupId)&&(this._animState.currentInsertionIndex=r,this._animState.targetTabGroupId=i,this.accessor.options.theme?.tabAnimation===`smooth`&&this.applyDragOverTransforms())}_buildFirstPanelToGroupMap(){let e=new Map;if(this._tabGroupManager.chipRenderers.size===0)return e;for(let t of this.group.model.getTabGroups())t.id!==this._animState.sourceTabGroupId&&t.panelIds.length>0&&e.set(t.panelIds[0],t.id);return e}_computeDragOverInsertionIndex(e,t){let n=this._animState,r=n.sourceGroupPanelIds,i=e-n.cursorOffsetFromDragStart-n.containerStart,a=0,o=null;for(let e=0;e<this._tabs.length;e++){let s=this._tabs[e].value;if(s.panel.id===n.sourceTabId||r?.has(s.panel.id))continue;let c=t.get(s.panel.id);if(c){let t=n.chipSizes.get(c)??0;if(a+t>i){o??=e;break}a+=t}let l=n.tabPositions.get(s.panel.id),u=this._mainAxisSize(l??s.element.getBoundingClientRect());if(a+u/2<=i)a+=u,o=e+1;else{o??=e;break}}return o}_accumulatedSizeUpTo(e,t){let n=this._animState,r=n.sourceGroupPanelIds,i=0;for(let a=0;a<this._tabs.length;a++){let o=this._tabs[a].value;if(o.panel.id===n.sourceTabId||r?.has(o.panel.id))continue;if(a>=e)break;let s=t.get(o.panel.id);s&&(i+=n.chipSizes.get(s)??0);let c=n.tabPositions.get(o.panel.id);i+=this._mainAxisSize(c??o.element.getBoundingClientRect())}return i}_resolveInsertionAgainstTabGroups(e,t,n){let r=!!this._animState.sourceTabGroupId,i=this._accumulatedSizeUpTo(t,n);for(let n of this.group.model.getTabGroups()){let a=this._evaluateTabGroupForInsertion(n,e,t,i,r);if(a)return a.targetTabGroupId?a:this._keepSourceGroupAtOwnSlot(e,a.insertionIndex,i)??a}return this._keepSourceGroupAtOwnSlot(e,t,i)??{insertionIndex:t,targetTabGroupId:null}}_keepSourceGroupAtOwnSlot(e,t,n){let r=this._animState,i=r.sourceIndex;if(r.sourceGroupPanelIds||i===-1||t!==i&&t!==i+1)return null;let a=this.group.model.getTabGroups().find(e=>e.panelIds.includes(r.sourceTabId));if(!a)return null;if(a.panelIds[0]===r.sourceTabId){let t=r.chipSizes.get(a.id)??0;if(e<r.containerStart+n+t)return null}return{insertionIndex:t,targetTabGroupId:a.id}}_evaluateTabGroupForInsertion(e,t,n,r,i){let a=this._resolveGroupRange(e);if(!a)return null;let{firstIdx:o,lastIdx:s}=a,c=n>=o&&n<=s,l=!c&&n===o-1;return!c&&!l?null:i?this._resolveGroupDragTarget(n,o,s,c):this._resolveTabDragTarget(e,t,n,r,o,l)}_resolveGroupRange(e){let t=this._animState,n=t.sourceGroupPanelIds,r=e.panelIds.filter(e=>e!==t.sourceTabId&&!n?.has(e));if(r.length===0)return null;let i=this._tabs.findIndex(e=>e.value.panel.id===r[0]),a=this._tabs.findIndex(e=>e.value.panel.id===r[r.length-1]);return i===-1||a===-1?null:{firstIdx:i,lastIdx:a}}_resolveGroupDragTarget(e,t,n,r){return r?{insertionIndex:e<(t+n+1)/2?t:n+1,targetTabGroupId:null}:{insertionIndex:e,targetTabGroupId:null}}_resolveTabDragTarget(e,t,n,r,i,a){let o=this._animState,s=o.chipSizes.get(e.id)??0;if(a)return this._onlySourceBetween(n,i)?t>=(e.collapsed?o.containerStart+r+s/2:o.containerStart+r+s)?{insertionIndex:i,targetTabGroupId:e.id}:{insertionIndex:n,targetTabGroupId:null}:null;let c=o.containerStart+r+s;return n===i?{insertionIndex:n,targetTabGroupId:t>=c?e.id:null}:{insertionIndex:n,targetTabGroupId:e.id}}_onlySourceBetween(e,t){let n=this._animState;for(let r=e;r<t;r++){let e=this._tabs[r].value.panel.id;if(e!==n.sourceTabId&&!n.sourceGroupPanelIds?.has(e))return!1}return!0}handleWrappedDragOver(e,t){if(!this._animState)return;let n=this.computeWrappedInsertionIndex(e,t);(n!==this._animState.currentInsertionIndex||this._animState.targetTabGroupId!==null)&&(this._animState.currentInsertionIndex=n,this._animState.targetTabGroupId=null,this.updateWrapDropIndicator(n))}computeWrappedInsertionIndex(e,t){let n=this._direction===`vertical`,r=this._wrappedDragEntries();if(r.length===0)return this._tabs.length;let i=n?e:t,a=n?t:e,o=e=>n?e.left:e.top,s=e=>n?e.right:e.bottom,c=e=>n?e.top:e.left,l=e=>n?e.height:e.width,u=this._bucketWrappedLines(r,o,s),d=[...(u.find(e=>i>=e.start&&i<=e.end)??this._nearestWrappedLine(u,i)).items].sort((e,t)=>c(e.rect)-c(t.rect));for(let e of d)if(a<c(e.rect)+l(e.rect)/2)return e.index;return d[d.length-1].index+1}_wrappedDragEntries(){let e=this._animState?.sourceTabId,t=this._animState?.sourceGroupPanelIds,n=[];for(let r=0;r<this._tabs.length;r++){let i=this._tabs[r].value;i.panel.id!==e&&(t?.has(i.panel.id)||n.push({index:r,rect:i.element.getBoundingClientRect()}))}return n}_bucketWrappedLines(e,t,n){let r=[];for(let i of e){let e=t(i.rect),a=r.find(t=>Math.abs(t.start-e)<=2);a?(a.items.push(i),a.end=Math.max(a.end,n(i.rect))):r.push({start:e,end:n(i.rect),items:[i]})}return r.sort((e,t)=>e.start-t.start),r}_nearestWrappedLine(e,t){let n=e=>t<e.start?e.start-t:t-e.end;return e.reduce((e,t)=>n(t)<n(e)?t:e,e[0])}updateWrapDropIndicator(e){this.clearWrapDropIndicator();let t=this._tabs.length;if(t===0)return;let n=this._animState?.sourceTabId;if(e<t){let t=this._tabs[e].value.element;if(this._tabs[e].value.panel.id===n)return;t.classList.add(`dv-tab--reorder-before`),this._wrapIndicatorEl=t}else{let e=this._tabs[t-1].value.element;e.classList.add(`dv-tab--reorder-after`),this._wrapIndicatorEl=e}}clearWrapDropIndicator(){var e;(e=this._wrapIndicatorEl)==null||e.classList.remove(`dv-tab--reorder-before`,`dv-tab--reorder-after`),this._wrapIndicatorEl=null}_removeClassInstantlyBatch(e,t){let n=[];for(let r of e)r.classList.contains(t)&&(r.style.transition=`none`,Q(r,t,!1),n.push(r));if(n.length>0){n[0].getBoundingClientRect();for(let e of n)e.style.removeProperty(`transition`)}}uncollapseSourceTab(e){let t=this._tabMap.get(e);t&&this._removeClassInstantlyBatch([t.value.element],`dv-tab--dragging`)}applyDragOverTransforms(e=!1){if(this._wrapMode)return;if(this._animState?.currentInsertionIndex==null){this.resetTabTransforms();return}if(this._pendingCollapse)return;let t=this._animState.currentInsertionIndex,n=this._computeGapSize(),r=this._computeChipToShift(t);this._applyGapMargins(t,n,r,e)}_computeGapSize(){let e=this._animState;if(e.sourceTabGroupId&&e.sourceGroupPanelIds)return e.sourceGapSize;let t=e.tabPositions.get(e.sourceTabId);return t?this._mainAxisSize(t):this.getAverageTabSize()}_computeChipToShift(e){if(this._tabGroupManager.chipRenderers.size===0)return null;for(let t of this.group.model.getTabGroups()){let n=this._chipToShiftForGroup(t,e);if(n!==void 0)return n}return null}_chipToShiftForGroup(e,t){let n=this._animState;if(e.id===n.sourceTabGroupId||e.panelIds.includes(n.sourceTabId))return;let r=e.panelIds.filter(e=>e!==n.sourceTabId&&!n.sourceGroupPanelIds?.has(e));if(r.length===0)return;let i=this._tabs.findIndex(e=>e.value.panel.id===r[0]);if((!n.targetTabGroupId||n.targetTabGroupId===e.id&&e.collapsed)&&!(i<t)){if(this._onlySourceBetween(t,i)){let t=this._tabGroupManager.chipRenderers.get(e.id);if(t)return t.chip.element}return null}}_applyGapMargins(e,t,n,r){let i=this._animState,a=i.sourceGroupPanelIds,o=!1;for(let[e,t]of this._tabGroupManager.chipRenderers)e!==i.sourceTabGroupId&&this._clearMargin(t.chip.element,r);n&&(this._setMargin(n,`${t}px`,r),o=!0);for(let n=0;n<this._tabs.length;n++){let s=this._tabs[n].value;s.panel.id!==i.sourceTabId&&(a?.has(s.panel.id)||(!o&&n>=e?(this._setMargin(s.element,`${t}px`,r),o=!0):this._clearMargin(s.element,r)))}this._tabGroupManager.trackUnderlines()}_shiftingClass(e){return e.classList.contains(`dv-tab-group-chip`)?`dv-tab-group-chip--shifting`:`dv-tab--shifting`}_setMargin(e,t,n){let r=this._gapMarginProperty;n?(e.style.transition=`none`,e.style.setProperty(r,t),e.getBoundingClientRect(),e.style.removeProperty(`transition`)):e.style.setProperty(r,t),Q(e,this._shiftingClass(e),!0)}_clearMargin(e,t){let n=this._shiftingClass(e),r=this._gapMarginProperty,i=this._pendingMarginCleanups.get(e);if(i&&i(),t||!e.style.getPropertyValue(r))e.style.removeProperty(r),Q(e,n,!1);else{e.style.setProperty(r,`0px`),Q(e,n,!0);let t=()=>{e.style.removeProperty(r),Q(e,n,!1),e.removeEventListener(`transitionend`,t),clearTimeout(i),this._pendingMarginCleanups.delete(e)},i=setTimeout(t,300);this._pendingMarginCleanups.set(e,t),e.addEventListener(`transitionend`,t)}}resetTabTransforms(){this.clearWrapDropIndicator();for(let[,e]of this._pendingMarginCleanups)e();this._pendingMarginCleanups.clear();for(let e of this._tabs)e.value.element.style.removeProperty(`margin-left`),e.value.element.style.removeProperty(`margin-right`),e.value.element.style.removeProperty(`margin-top`),e.value.element.style.removeProperty(`margin-bottom`),e.value.element.style.removeProperty(`transform`),Q(e.value.element,`dv-tab--shifting`,!1);for(let[,e]of this._tabGroupManager.chipRenderers)e.chip.element.style.removeProperty(`margin-left`),e.chip.element.style.removeProperty(`margin-top`),Q(e.chip.element,`dv-tab-group-chip--shifting`,!1);this._tabGroupManager.positionUnderlines()}commitGroupMove(e,t){let n=fW();if(this._tabGroupManager.disposeChipDrag(e),this._tabGroupManager.clearChipDropOverlays(),this.group.model.getTabGroups().some(t=>t.id===e)){if(this.accessor.options.theme?.tabAnimation===`smooth`){this._clearGroupDragClasses(e);let n=this.snapshotTabPositions();this.resetTabTransforms(),this.group.model.moveTabGroup(e,t),this.runFlipAnimation(n,``,!1)}else this._tabGroupManager.skipNextCollapseAnimation=!0,this.group.model.moveTabGroup(e,t)}else n&&(this.resetTabTransforms(),this.accessor.moveGroupOrPanel({from:{groupId:n.groupId,tabGroupId:n.tabGroupId??e},to:{group:this.group,position:`center`,index:t}}))}_clearGroupDragClasses(e){let t=this._tabGroupManager.chipRenderers.get(e);t&&this._removeClassInstantlyBatch([t.chip.element],`dv-tab-group-chip--dragging`),this._removeClassInstantlyBatch(this._tabs.map(e=>e.value.element),`dv-tab--dragging`);let n=this._tabGroupManager.groupUnderlines.get(e);n&&n.style.removeProperty(`display`),this._tabGroupManager.skipNextCollapseAnimation=!0}resetDragAnimation(){if(this._pendingCollapse=!1,this._animState){this.resetTabTransforms(),this._animState.sourceTabGroupId?this._clearGroupDragClasses(this._animState.sourceTabGroupId):this._removeClassInstantlyBatch(this._tabs.map(e=>e.value.element),`dv-tab--dragging`),this._animState=null;for(let[,e]of this._tabGroupManager.groupUnderlines)e.style.removeProperty(`display`)}}runFlipAnimation(e,t,n=!1,r){if(this._wrapMode)return;let i=!1;for(let a=0;a<this._tabs.length;a++)this._applyFlipTransform(this._tabs[a],a,t,n,e,r)&&(i=!0);i&&this._scheduleFlipReset()}_applyFlipTransform(e,t,n,r,i,a){let o=this._direction===`vertical`,s=e.value.panel.id;if(s===n){if(!r)return!1;let t=e.value.element.getBoundingClientRect();return e.value.element.style.transform=o?`translateY(${t.height}px)`:`translateX(${t.width}px)`,Q(e.value.element,`dv-tab--shifting`,!0),!0}if(a!==void 0&&(t<a.from||t>a.to))return!1;let c=i.get(s);if(!c)return!1;let l=e.value.element.getBoundingClientRect(),u=o?c.top-l.top:c.left-l.left;return Math.abs(u)<1?!1:(e.value.element.style.transform=o?`translateY(${u}px)`:`translateX(${u}px)`,Q(e.value.element,`dv-tab--shifting`,!0),!0)}_scheduleFlipReset(){requestAnimationFrame(()=>{var e;for(let e of this._tabs)e.value.element.style.transform&&(e.value.element.style.transform=``);this._tabGroupManager.trackUnderlines(),(e=this._flipTransitionCleanup)==null||e.call(this);let t=e=>{if(e.propertyName===`transform`){n();for(let e of this._tabs)Q(e.value.element,`dv-tab--shifting`,!1);this._tabGroupManager.positionUnderlines()}},n=()=>{this._tabsList.removeEventListener(`transitionend`,t),this._flipTransitionCleanup=null};this._flipTransitionCleanup=n,this._tabsList.addEventListener(`transitionend`,t)})}},Iq=class extends Y{get _animState(){return this._reorder.animState}set _animState(e){this._reorder.animState=e}get _pendingCollapse(){return this._reorder.pendingCollapse}set _pendingCollapse(e){this._reorder.pendingCollapse=e}get tabItems(){return this._tabs}get tabMap(){return this._tabMap}get tabsList(){return this._tabsList}get groupPanel(){return this.group}get component(){return this.accessor}get tabGroupManager(){return this._tabGroupManager}fireDrop(e){this._onDrop.fire(e)}setOverflowExclude(e){this._overflowExclude=e,this.refreshOverflow()}setForcedOverflow(e){this._forcedOverflow=e,this.refreshOverflow()}refreshOverflow(){this._showTabsOverflowControl&&this.toggleDropdown({reset:!1}),this._applyPinnedSticky()}setPinnedSticky(e){this._pinnedSticky!==e&&(this._pinnedSticky=e,this._applyPinnedSticky())}_applyPinnedSticky(){let e=this._pinnedSticky?this._tabs.filter(e=>this._overflowExclude(e.value.panel.id)):[];if(e.length===0&&!this._hasPinnedStickyStyling)return;for(let e of this._tabs){let t=e.value.element;t.classList.contains(`dv-tab--pinned-sticky`)&&(t.classList.remove(`dv-tab--pinned-sticky`),t.style.removeProperty(`--dv-pinned-sticky-left`))}if(e.length===0){this._hasPinnedStickyStyling=!1;return}let t=e.map(e=>e.value.element.offsetLeft);e.forEach((e,n)=>{let r=e.value.element;r.classList.add(`dv-tab--pinned-sticky`),r.style.setProperty(`--dv-pinned-sticky-left`,`${t[n]}px`)}),this._hasPinnedStickyStyling=!0}get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e){if(this._showTabsOverflowControl=e,e){let e=new CW(this._tabsList);this._observerDisposable.value=new Y(e,e.onDidChange(e=>{let t=e.hasScrollX||e.hasScrollY;this.toggleDropdown({reset:!t}),this._applyPinnedSticky(),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}),Z(this._tabsList,`scroll`,()=>{this.toggleDropdown({reset:!1}),this._applyPinnedSticky(),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}))}else this._observerDisposable.value=mW.NONE}}get element(){return this._element}get tabsListElement(){return this._tabsList}set voidContainer(e){var t;(t=this._voidContainerListeners)==null||t.dispose(),this._voidContainerListeners=null,this._reorder.voidContainerElement=e,e&&(this._voidContainerListeners=new Y(Z(e,`dragover`,e=>{this._animState&&e.preventDefault()}),Z(e,`drop`,e=>{this._animState?.sourceTabGroupId&&this._animState.currentInsertionIndex!==null&&(e.preventDefault(),e.stopPropagation(),this.handleVoidDrop())})))}handleVoidDrop(){if(!this._animState?.sourceTabGroupId)return!1;let e=this._animState.sourceTabGroupId,t=this._animState.currentInsertionIndex??this._tabs.length;return this._animState=null,this._commitGroupMove(e,t),!0}get panels(){return this._tabs.map(e=>e.value.panel.id)}get size(){return this._tabs.length}get tabs(){return this._tabs.map(e=>e.value)}get direction(){return this._direction}set direction(e){if(this._direction!==e){this._direction=e,this._tabsList.setAttribute(`aria-orientation`,e===`vertical`?`vertical`:`horizontal`),this._scrollbar&&(this._scrollbar.orientation=e),TW(this._tabsList,`dv-horizontal`,`dv-vertical`),e===`vertical`?EW(this._tabsList,`dv-tabs-container-vertical`,`dv-vertical`):(TW(this._tabsList,`dv-tabs-container-vertical`),EW(this._tabsList,`dv-horizontal`));for(let t of this._tabs)t.value.setDirection(e);this._tabGroupManager.updateDirection()}}constructor(e,t,n){super(),this.group=e,this.accessor=t,this._observerDisposable=new hW,this._pointerActivation=new hW,this._scrollbar=null,this._tabs=[],this._overflowRefreshPending=!1,this._tabMap=new Map,this.selectedIndex=-1,this._showTabsOverflowControl=!1,this._overflowExclude=()=>!1,this._forcedOverflow=()=>!1,this._pinnedSticky=!1,this._hasPinnedStickyStyling=!1,this._direction=`horizontal`,this._voidContainerListeners=null,this._onTabDragStart=new X,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new X,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new X,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new X,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement(`div`),this._tabsList.className=`dv-tabs-container`,this._tabsList.setAttribute(`role`,`tablist`),this._tabsList.setAttribute(`aria-orientation`,this._direction===`vertical`?`vertical`:`horizontal`),this.showTabsOverflowControl=n.showTabsOverflowControl,t.options.scrollbars===`native`?this._element=this._tabsList:(this._scrollbar=new cq(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new jq({group:this.group,accessor:this.accessor,tabsList:this._tabsList,getTabs:()=>this._tabs,getTabMap:()=>this._tabMap,getDirection:()=>this._direction},{onChipContextMenu:(e,t)=>{var n;(n=this.accessor.contextMenuService)==null||n.showForChip(e,this.group,t)},onChipDragStart:(e,t,n)=>{this._handleChipDragStart(e,t,n)},onChipDragEnd:()=>{this._reorder.resetDragAnimation()},onChipDrop:(e,t)=>{this._handleChipDrop(e,t)}}),this._reorder=new Fq(this);let r=NK.createDropTarget(this._tabsList,{acceptedTargetZones:[`center`],canDisplayOverlay:()=>!1,isHitTestTransparent:()=>{let e=fW();return e?.viewId!==this.accessor.id||e.groupId!==this.group.id||e.panelId===null&&!e.tabGroupId}});this.addDisposables(r,this._onOverflowTabsChange,this._observerDisposable,this._pointerActivation,this._onWillShowOverlay,this._onDrop,this._onTabDragStart,this._reorder,xK.getInstance().onDragEnd(e=>{this._reorder.handlePointerDragEnd(e)}),xK.getInstance().onDragMove(e=>{this._reorder.handlePointerDragMove(e.clientX,e.clientY)}),Z(this.element,`pointerdown`,e=>{e.defaultPrevented||e.button===0&&this.accessor.doSetGroupActive(this.group)}),Z(this._tabsList,`wheel`,e=>{let t=this._direction===`vertical`,n=t?e.deltaY||e.deltaX:e.deltaX||e.deltaY;if(n===0)return;let r=t?this._tabsList.scrollHeight-this._tabsList.clientHeight:this._tabsList.scrollWidth-this._tabsList.clientWidth;if(r<=0)return;let i=t?this._tabsList.scrollTop:this._tabsList.scrollLeft;n<0&&i<=0||n>0&&i>=r||(e.preventDefault(),e.stopPropagation(),t?this._tabsList.scrollTop=i+n:this._tabsList.scrollLeft=i+n)},{passive:!1}),Z(this._tabsList,`keydown`,e=>{this._onKeyDown(e)}),Z(this._tabsList,`dragover`,e=>{this._reorder.processDragOver(e.clientX,e.clientY)&&e.preventDefault()},!0),Z(this._tabsList,`dragleave`,e=>{this._reorder.processDragLeave(e.relatedTarget)},!0),Z(this._tabsList,`dragend`,()=>{this._reorder.resetDragAnimation()}),Z(this._tabsList,`drop`,e=>{var t;if(this._animState?.currentInsertionIndex==null||this.accessor.options.theme?.tabAnimation!==`smooth`&&!this._animState.sourceTabGroupId)return;e.stopPropagation(),e.preventDefault(),(t=this.group.model.dropTargetContainer)==null||(t=t.model)==null||t.clear();let n=this._animState;if(this._animState=null,this._pendingCollapse=!1,n.sourceTabGroupId){this._commitGroupMove(n.sourceTabGroupId,n.currentInsertionIndex);return}let r=this._reorder.resolveTabDrop(n);if(this._reorder.uncollapseSourceTab(n.sourceTabId),!r){this.resetTabTransforms();return}let i=n.sourceIndex,a=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire($({event:e},r)),this.runFlipAnimation(a,n.sourceTabId,i===-1,{from:Math.min(i,r.index),to:Math.max(i,r.index)})},!0),mW.from(()=>{var e;(e=this._voidContainerListeners)==null||e.dispose(),this._reorder.resetDragAnimation(),this._tabGroupManager.disposeAll();for(let{value:e,disposable:t}of this._tabs)t.dispose(),e.dispose();this._tabs=[],this._tabMap.clear()}))}indexOf(e){return this._tabs.findIndex(t=>t.value.panel.id===e)}getTabId(e){return this._tabMap.get(e)?.value.element.id}getPanelForTab(e){for(let{value:t}of this._tabs)if(t.element===e||t.element.contains(e))return t.panel}isActive(e){return this.selectedIndex>-1&&this._tabs[this.selectedIndex].value===e}_onKeyDown(e){let t=this._tabs.findIndex(t=>t.value.element===e.target);if(t===-1)return;let n=this._direction===`vertical`,r=n?`ArrowDown`:`ArrowRight`,i=n?`ArrowUp`:`ArrowLeft`,a=this._tabs.length-1;switch(e.key){case r:e.preventDefault(),this._focusTab(Math.min(t+1,a));break;case i:e.preventDefault(),this._focusTab(Math.max(t-1,0));break;case`Home`:e.preventDefault(),this._focusTab(0);break;case`End`:e.preventDefault(),this._focusTab(a);break;case`Enter`:case` `:e.preventDefault(),this.accessor.withOrigin(`user`,()=>this._tabs[t].value.panel.api.setActive());break;case`Delete`:case`Backspace`:e.preventDefault(),this._closeTab(t)}}_closeTab(e){let t=this._tabs[e]?.value;if(!t)return;let n=(this._tabs[e+1]?.value??this._tabs[e-1]?.value)?.panel.id;if(t.panel.api.close(),n!==void 0){let e=this._tabs.findIndex(e=>e.value.panel.id===n);e>-1&&this._focusTab(e)}}_focusTab(e){for(let t=0;t<this._tabs.length;t++)this._tabs[t].value.element.tabIndex=t===e?0:-1;this._tabs[e].value.element.focus()}focusActiveTab(){if(this._tabs.length===0)return;let e=this.group.activePanel?.id,t=e?this._tabs.findIndex(t=>t.value.panel.id===e):-1;this._focusTab(t>-1?t:0)}setActivePanel(e){let t=this._direction===`vertical`;for(let n of this._tabs){let r=e.id===n.value.panel.id;n.value.setActive(r),r&&this._scrollTabIntoView(n.value.element,t)}this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}_scrollTabIntoView(e,t){let n=e.parentElement;if(!n)return;let r=t?e.offsetTop:e.offsetLeft,i=t?e.offsetHeight:e.offsetWidth,a=t?n.scrollTop:n.scrollLeft,o=t?n.clientHeight:n.clientWidth;(r<a||r+i>a+o)&&(t?n.scrollTop=r:n.scrollLeft=r)}_activateOnPointerDown(e){if(!eq(this.accessor.options).html5){this.group.model.openPanel(e);return}let t=requestAnimationFrame(()=>{this._tabMap.has(e.id)&&this.group.model.openPanel(e)});this._pointerActivation.value={dispose:()=>cancelAnimationFrame(t)}}openPanel(e,t=this._tabs.length){if(this._tabMap.has(e.id))return;let n=new iq(e,this.accessor,this.group);n.setContent(e.view.tab),this._direction!==`horizontal`&&n.setDirection(this._direction);let r={value:n,disposable:new Y(n.onDragStart(t=>{let r=t.defaultPrevented;if(this._onTabDragStart.fire({nativeEvent:t,panel:e}),(!t.defaultPrevented||r)&&this.accessor.options.theme?.tabAnimation===`smooth`){let t=Mq(n.element.getBoundingClientRect(),this._direction),r=this._tabs.findIndex(e=>e.value===n);this._animState={sourceTabId:e.id,sourceIndex:r,tabPositions:this.snapshotTabPositions(),chipSizes:this._tabGroupManager.snapshotChipSizes(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipSize:0,cursorOffsetFromDragStart:t/2,sourceGapSize:t,containerStart:Nq(this._tabsList.getBoundingClientRect(),this._direction)},this._pendingCollapse=!0,requestAnimationFrame(()=>{var e;this._pendingCollapse=!1,this._animState&&(this._tabsList.classList.contains(`dv-tabs-container--wrap`)||(n.element.style.transition=`none`,Q(n.element,`dv-tab--dragging`,!0),n.element.offsetHeight),(e=this._animState).currentInsertionIndex??(e.currentInsertionIndex=r),this.applyDragOverTransforms(!0),n.element.style.removeProperty(`transition`))})}}),n.onTabClick(t=>{t.defaultPrevented||this.group.api.location.type===`edge`&&(this.group.activePanel===e?this.group.api.isCollapsed()?this.group.api.expand():this.group.api.collapse():(this.group.model.openPanel(e),this.group.api.isCollapsed()&&this.group.api.expand()))}),n.onPointerDown(t=>{if(t.defaultPrevented)return;let r=!this.accessor.options.disableFloatingGroups,i=this.group.api.location.type===`floating`&&this.size===1;if(r&&!i&&t.shiftKey){t.preventDefault();let e=this.accessor.getGroupPanel(n.panel.id),{top:r,left:i}=n.element.getBoundingClientRect(),{top:a,left:o}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(e,{x:i-o,y:r-a,inDragMode:!0})}else t.button===0&&this.group.api.location.type!==`edge`&&this.group.activePanel!==e&&this._activateOnPointerDown(e)}),n.onDrop(e=>{let t=this._animState;this._animState=null,this._pendingCollapse=!1;let r=this._tabs.findIndex(e=>e.value===n);if(t){let n=e.position===`right`?r+1:r;if(t.sourceTabGroupId){this._commitGroupMove(t.sourceTabGroupId,t.currentInsertionIndex??n);return}this._reorder.uncollapseSourceTab(t.sourceTabId);let i=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:e.nativeEvent,index:n,targetTabGroupId:t.targetTabGroupId}),this.accessor.options.theme?.tabAnimation===`smooth`&&this.runFlipAnimation(i,t.sourceTabId,t.sourceIndex===-1,t.sourceIndex===-1?void 0:{from:Math.min(t.sourceIndex,n),to:Math.max(t.sourceIndex,n)})}else{let t=this._direction===`vertical`?`bottom`:`right`,i=e.position===t?r+1:r,a=fW(),o=a?this._tabs.findIndex(e=>e.value.panel.id===a.panelId):-1,s=i-+(o!==-1&&o<i),c=this.group.model.getTabGroupForPanel(n.panel.id)?.id??null;this._onDrop.fire({event:e.nativeEvent,index:s,targetTabGroupId:c})}}),n.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new aq(e,{kind:`tab`,panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:fW}))}))};this.addTab(r,t),this._scheduleOverflowRefresh(),this._tabGroupManager.positionAllChips(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipSizes=this._tabGroupManager.snapshotChipSizes(),this.applyDragOverTransforms())}delete(e){let t=this.indexOf(e);if(t===-1)return;this._animState?.sourceTabId===e&&(this.resetTabTransforms(),this._animState=null),this._tabGroupManager.cleanupTransition(e);let{value:n,disposable:r}=this._tabs.splice(t,1)[0];this._tabMap.delete(e),r.dispose(),n.dispose(),n.element.remove(),this._scheduleOverflowRefresh(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipSizes=this._tabGroupManager.snapshotChipSizes(),this.applyDragOverTransforms())}addTab(e,t=this._tabs.length){if(t<0||t>this._tabs.length)throw Error(`invalid location`);let n=t<this._tabs.length?this._tabs[t].value.element:null;this._tabsList.insertBefore(e.value.element,n),this._tabs=[...this._tabs.slice(0,t),e,...this._tabs.slice(t)],this._tabMap.set(e.value.panel.id,e),this.selectedIndex<0&&(this.selectedIndex=t)}_scheduleOverflowRefresh(){!this._overflowRefreshPending&&this._showTabsOverflowControl&&(this._overflowRefreshPending=!0,queueMicrotask(()=>{if(this._overflowRefreshPending=!1,this.isDisposed||!this._showTabsOverflowControl)return;let e=this._tabsList,t=e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight;this.toggleDropdown({reset:!t})}))}toggleDropdown(e){let t=this._tabs.some(e=>!this._overflowExclude(e.value.panel.id)&&this._forcedOverflow(e.value.panel.id));if(e.reset&&!t){this._onOverflowTabsChange.fire({tabs:[],tabGroups:[],pinnedTabs:[],reset:!0});return}let n=this._tabs.filter(t=>!this._overflowExclude(t.value.panel.id)&&(this._forcedOverflow(t.value.panel.id)||!e.reset&&!JW(t.value.element,this._tabsList))).map(e=>e.value.panel.id),r=e.reset?[]:this._tabs.filter(e=>this._overflowExclude(e.value.panel.id)&&e.value.element.getBoundingClientRect().width>0&&!JW(e.value.element,this._tabsList)).map(e=>e.value.panel.id),i=new Set(n),a=[];for(let e of this.group.model.getTabGroups()){let t=this._tabGroupManager.chipRenderers.get(e.id),r=t&&!JW(t.chip.element,this._tabsList),o=e.panelIds.length>0&&e.panelIds.every(e=>i.has(e));if((r||o)&&(a.push(e.id),e.collapsed))for(let t of e.panelIds)i.has(t)||(i.add(t),n.push(t))}this._onOverflowTabsChange.fire({tabs:n,tabGroups:a,pinnedTabs:r,reset:!1})}updateDragAndDropState(){for(let e of this._tabs)e.value.updateDragAndDropState();this._tabGroupManager.updateDragAndDropState()}updateTabGroups(){this._tabGroupManager.update()}refreshTabGroupAccent(){this._tabGroupManager.refreshAccents()}_handleChipDragStart(e,t,n){let r=e.panelIds[0],i=r?this._tabs.findIndex(e=>e.value.panel.id===r):-1,a=t.element.getBoundingClientRect(),o=Mq(a,this._direction);for(let t of e.panelIds){let e=this._tabMap.get(t);e&&(o+=Mq(e.value.element.getBoundingClientRect(),this._direction))}if(this._animState={sourceTabId:``,sourceIndex:i,tabPositions:this.snapshotTabPositions(),chipSizes:this._tabGroupManager.snapshotChipSizes(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.id,sourceGroupPanelIds:new Set(e.panelIds),sourceChipSize:Mq(a,this._direction),cursorOffsetFromDragStart:Pq(n,this._direction)-Nq(a,this._direction),sourceGapSize:o,containerStart:Nq(this._tabsList.getBoundingClientRect(),this._direction)},this.accessor.options.theme?.tabAnimation!==`smooth`)return;let s=new Set(e.panelIds);this._pendingCollapse=!0,requestAnimationFrame(()=>{var t;if(this._pendingCollapse=!1,!this._animState)return;for(let e of this._tabs)s.has(e.value.panel.id)&&(e.value.element.style.transition=`none`,Q(e.value.element,`dv-tab--dragging`,!0));let n=this._tabGroupManager.chipRenderers.get(e.id);n&&(n.chip.element.style.transition=`none`,Q(n.chip.element,`dv-tab-group-chip--dragging`,!0)),this._tabsList.offsetHeight;let r=this._tabGroupManager.groupUnderlines.get(e.id);r&&(r.style.display=`none`),(t=this._animState).currentInsertionIndex??(t.currentInsertionIndex=i),this.applyDragOverTransforms(!0);for(let e of this._tabs)s.has(e.value.panel.id)&&e.value.element.style.removeProperty(`transition`);n&&n.chip.element.style.removeProperty(`transition`)})}_handleChipDrop(e,t){let n=e.panelIds[0];if(!n)return;let r=this._tabs.findIndex(e=>e.value.panel.id===n);if(r===-1)return;let i=fW();if(i?.tabGroupId){let e=this._animState;this._animState=null,this._pendingCollapse=!1,this._commitGroupMove(i.tabGroupId,e?.currentInsertionIndex??r);return}let a=i?.groupId===this.group.id&&i?.panelId?this._tabs.findIndex(e=>e.value.panel.id===i.panelId):-1,o=r-+(a!==-1&&a<r);this._onDrop.fire({event:t.nativeEvent,index:o,targetTabGroupId:null})}setExtendedDropZone(e){this._reorder.setExtendedDropZone(e)}setExternalInsertionIndex(e){this._reorder.setExternalInsertionIndex(e)}clearExternalAnimState(){this._reorder.clearExternalAnimState()}snapshotTabPositions(){return this._reorder.snapshotTabPositions()}handleDragOver(e){this._reorder.handleDragOver(e)}applyDragOverTransforms(e=!1){this._reorder.applyDragOverTransforms(e)}resetTabTransforms(){this._reorder.resetTabTransforms()}_commitGroupMove(e,t){this._reorder.commitGroupMove(e,t)}runFlipAnimation(e,t,n=!1,r){this._reorder.runFlipAnimation(e,t,n,r)}};function Lq(){let e=document.createElement(`div`);e.className=`dv-tabs-overflow-dropdown-default`;let t=document.createElement(`span`);t.textContent=``;let n=XK();return e.appendChild(n),e.appendChild(t),{element:e,update:e=>{t.textContent=`${e.tabs}`}}}var Rq=class extends Y{get onTabDragStart(){return this.tabs.onTabDragStart}get panels(){return this.tabs.panels}get size(){return this.tabs.size}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?`none`:``}get direction(){return this._direction}set direction(e){this._direction=e,e===`vertical`?(EW(this._element,`dv-groupview-header-vertical`),EW(this.rightActionsContainer,`dv-right-actions-container-vertical`),this.tabs.direction=e):(TW(this._element,`dv-groupview-header-vertical`),TW(this.rightActionsContainer,`dv-right-actions-container-vertical`),this.tabs.direction=e)}get element(){return this._element}get tabsListElement(){return this.tabs.tabsListElement}constructor(e,t){super(),this.accessor=e,this.group=t,this._hidden=!1,this._direction=`horizontal`,this._dropIndexResolver=(e,t)=>t,this._pinnedRow=void 0,this.dropdownPart=null,this._overflowTabs=[],this._overflowTabGroups=[],this._overflowPinnedTabs=[],this._dropdownDisposable=new hW,this._onDrop=new X,this.onDrop=this._onDrop.event,this._onGroupDragStart=new X,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new X,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement(`div`),this._element.className=`dv-tabs-and-actions-container`,Q(this._element,`dv-full-width-single-tab`,this.accessor.options.singleTabMode===`fullwidth`),this.rightActionsContainer=document.createElement(`div`),this.rightActionsContainer.className=`dv-right-actions-container`,this.leftActionsContainer=document.createElement(`div`),this.leftActionsContainer.className=`dv-left-actions-container`,this.preActionsContainer=document.createElement(`div`),this.preActionsContainer.className=`dv-pre-actions-container`,this.tabs=new Iq(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new sq(this.accessor,this.group),this.tabs.voidContainer=this.voidContainer.element,this._element.appendChild(this.preActionsContainer),this._element.appendChild(this.tabs.element),this._element.appendChild(this.leftActionsContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.rightActionsContainer),this.tabs.setExtendedDropZone(this._element),this.addDisposables(this.tabs.onDrop(e=>this._onDrop.fire(e)),this.tabs.onWillShowOverlay(e=>this._onWillShowOverlay.fire(e)),e.onDidOptionsChange(()=>{this.tabs.showTabsOverflowControl=!e.options.disableTabsOverflowList}),this.tabs.onOverflowTabsChange(e=>{this.toggleDropdown(e)}),this.tabs,this._onWillShowOverlay,this._onDrop,this._onGroupDragStart,this.voidContainer,this.voidContainer.onDragStart(e=>{this._onGroupDragStart.fire({nativeEvent:e,group:this.group})}),this.voidContainer.onDrop(e=>{this.tabs.handleVoidDrop()||this._onDrop.fire({event:e.nativeEvent,index:this.tabs.size})}),this.voidContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new aq(e,{kind:`header_space`,panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:fW}))}),Z(this.leftActionsContainer,`dragleave`,e=>{let t=e.relatedTarget;!this.leftActionsContainer.contains(t)&&!this._element.contains(t)&&this.tabs.clearExternalAnimState()}),Z(this.voidContainer.element,`dragleave`,e=>{let t=e.relatedTarget;this.voidContainer.element.contains(t)||(this._element.contains(t)?this.tabs.setExternalInsertionIndex(null):this.tabs.clearExternalAnimState())}),Z(this.voidContainer.element,`pointerdown`,e=>{if(!e.defaultPrevented&&!this.accessor.options.disableFloatingGroups&&e.shiftKey&&this.group.api.location.type!==`floating`&&this.group.api.location.type!==`edge`){e.preventDefault();let{top:t,left:n}=this.element.getBoundingClientRect(),{top:r,left:i}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:n-i+20,y:t-r+20,inDragMode:!0})}}))}show(){this.hidden||(this.element.style.display=``)}hide(){this._element.style.display=`none`}setRightActionsElement(e){this.rightActions!==e&&(this.rightActions&&=(this.rightActions.remove(),void 0),e&&(this.rightActionsContainer.appendChild(e),this.rightActions=e))}setLeftActionsElement(e){this.leftActions!==e&&(this.leftActions&&=(this.leftActions.remove(),void 0),e&&(this.leftActionsContainer.appendChild(e),this.leftActions=e))}setPrefixActionsElement(e){this.preActions!==e&&(this.preActions&&=(this.preActions.remove(),void 0),e&&(this.preActionsContainer.appendChild(e),this.preActions=e))}isActive(e){return this.tabs.isActive(e)}indexOf(e){return this.tabs.indexOf(e)}getTabId(e){return this.tabs.getTabId(e)}getPanelForTab(e){return this.tabs.getPanelForTab(e)}setActive(e){}delete(e){this.tabs.delete(e),this.updateClassnames()}setActivePanel(e){this.tabs.setActivePanel(e)}focusActiveTab(){this.tabs.focusActiveTab()}openPanel(e,t=this.tabs.size){this.tabs.openPanel(e,t),this.updateClassnames()}closePanel(e){this.delete(e.id)}setOverflowExclude(e){this.tabs.setOverflowExclude(e)}setForcedOverflow(e){this.tabs.setForcedOverflow(e)}setPinnedSticky(e){this.tabs.setPinnedSticky(e)}refreshOverflow(){this.tabs.refreshOverflow()}setPinnedRow(e){this._pinnedRow!==e&&(this._pinnedRow&&this._pinnedRow.remove(),this._pinnedRow=e,e&&(e.classList.add(`dv-pinned-row`),this._element.insertBefore(e,this._element.firstChild)),Q(this._element,`dv-tabs-and-actions-container--pinned-row`,!!e))}setDropIndexResolver(e){this._dropIndexResolver=e}resolveDropIndex(e,t){return this._dropIndexResolver(e,t)}updateClassnames(){Q(this._element,`dv-single-tab`,this.size===1)}toggleDropdown(e){let t=e.reset?[]:e.tabs,n=e.reset?[]:e.tabGroups,r=e.reset?[]:e.pinnedTabs;this._overflowTabs=t,this._overflowTabGroups=n,this._overflowPinnedTabs=r;let i=this._overflowTabs.length+this._overflowPinnedTabs.length;if(i>0&&this.dropdownPart){this.dropdownPart.update({tabs:i});return}if(i===0){this._dropdownDisposable.dispose();return}let a=document.createElement(`div`);a.className=`dv-tabs-overflow-dropdown-root`;let o=Lq();o.update({tabs:i}),this.dropdownPart=o,a.appendChild(o.element),this.rightActionsContainer.prepend(a),this._dropdownDisposable.value=new Y(mW.from(()=>{var e,t;a.remove(),(e=this.dropdownPart)==null||(t=e.dispose)==null||t.call(e),this.dropdownPart=null}),Z(a,`pointerdown`,e=>{e.preventDefault()},{capture:!0}),Z(a,`click`,e=>{let t=QW(a),n={x:e.clientX,y:e.clientY,zIndex:t?.style.zIndex?`calc(${t.style.zIndex} * 2)`:void 0},{context:r,rowRenderers:i}=this.createOverflowRenderContext(a,n),o=this.accessor.advancedOverflowService;try{o?o.renderOverflow({group:this.group,overflowTabs:[...this._overflowTabs],overflowTabGroups:[...this._overflowTabGroups],pinnedOverflowTabs:[...this._overflowPinnedTabs],context:r}):r.open(this.renderFreeOverflowList(r))}catch(e){throw i.dispose(),e}}))}createOverflowRenderContext(e,t){let n=new Set(this._overflowTabGroups),r=this.group.model.getTabGroups(),i=new Map,a=new Map;for(let e of r)if(a.set(e.id,e),n.has(e.id))for(let t of e.panelIds)i.set(t,e);let o=()=>this.accessor.getPopupServiceForGroup(this.group),s=new Y,c=e=>{let t=document.createElement(`div`);t.className=`dv-tabs-overflow-group-header`;let n=document.createElement(`span`);n.className=`dv-tabs-overflow-group-color`,Sq(n,e.color,this.accessor.tabGroupColorPalette),t.appendChild(n);let r=document.createElement(`span`);if(r.className=`dv-tabs-overflow-group-label`,r.textContent=e.label||e.id,t.appendChild(r),e.collapsed){let n=document.createElement(`span`);n.className=`dv-tabs-overflow-group-collapsed-badge`,n.textContent=`${e.panelIds.length}`,t.appendChild(n)}return t.addEventListener(`click`,()=>{o().close(),e.collapsed&&e.expand();let t=e.panelIds[0];if(t){let e=this.group.panels.find(e=>e.id===t);this.accessor.withOrigin(`user`,()=>e?.api.setActive())}}),t};return{context:{overflowGroupIdForPanel:e=>i.get(e)?.id,buildGroupHeader:e=>{let t=a.get(e);if(t&&n.has(t.id))return c(t)},buildPinnedHeader:()=>{let e=document.createElement(`div`);e.className=`dv-tabs-overflow-group-header dv-tabs-overflow-pinned-header`;let t=JK();t.classList.add(`dv-tabs-overflow-pinned-icon`),e.appendChild(t);let n=document.createElement(`span`);return n.className=`dv-tabs-overflow-group-label`,n.textContent=`Pinned`,e.appendChild(n),e},buildRow:e=>{let t=this.group.panels.find(t=>t.id===e);if(!t)return;let n=this.tabs.tabs.find(t=>t.panel.id===e),r=i.get(e),a=t.view.createTabRenderer(`headerOverflow`),c=!1,l=mW.from(()=>{if(!c){var e;c=!0,(e=a.dispose)==null||e.call(a)}});s.isDisposed?l.dispose():s.addDisposables(l);let u=a.element,d=document.createElement(`div`);Q(d,`dv-tab`,!0),Q(d,`dv-active-tab`,t.api.isActive),Q(d,`dv-inactive-tab`,!t.api.isActive),r&&Q(d,`dv-tab--grouped`,!0);let f=()=>{r?.collapsed&&r.expand(),n?.element.scrollIntoView({block:`nearest`,inline:`nearest`}),this.accessor.withOrigin(`user`,()=>t.api.setActive())};return d.addEventListener(`click`,e=>{o().close(),!e.defaultPrevented&&f()}),d.appendChild(u),{element:d,panel:t,activate:()=>{o().close(),f()},dispose:()=>{s.removeDisposable(l),l.dispose()}}},open:e=>{o().openPopover(e,t,{onClose:()=>s.dispose()})},close:()=>o().close(),focusTrigger:()=>{e.tabIndex=-1,e.focus()}},rowRenderers:s}}renderFreeOverflowList(e){let t=document.createElement(`div`);t.style.overflow=`auto`,t.className=`dv-tabs-overflow-container`;let n=this._overflowPinnedTabs.map(t=>e.buildRow(t)).filter(e=>e!=null);if(n.length>0){t.appendChild(e.buildPinnedHeader());for(let e of n)t.appendChild(e.element)}let r=new Set;for(let n of this.tabs.tabs.filter(e=>this._overflowTabs.includes(e.panel.id))){let i=e.overflowGroupIdForPanel(n.panel.id);if(i&&!r.has(i)){r.add(i);let n=e.buildGroupHeader(i);n&&t.appendChild(n)}let a=e.buildRow(n.panel.id);a&&t.appendChild(a.element)}return t}updateDragAndDropState(){this.tabs.updateDragAndDropState(),this.voidContainer.updateDragAndDropState()}updateTabGroups(){this.tabs.updateTabGroups()}refreshTabGroupAccent(){this.tabs.refreshTabGroupAccent()}},zq=class extends Y{get label(){return this._label}get color(){return this._color}get componentParams(){return this._componentParams}setLabel(e){this.isDisposed||this._label===e||(this._label=e,this._onDidChange.fire())}setColor(e){if(this.isDisposed)return;let t=e===``?void 0:e;this._color!==t&&(this._color=t,this._onDidChange.fire())}setComponentParams(e){this.isDisposed||(this._componentParams=e,this._onDidChange.fire())}get collapsed(){return this._collapsed}get panelIds(){return this._panelIds}get size(){return this._panelIds.length}get isEmpty(){return this._panelIds.length===0}constructor(e,t){super(),this.id=e,this._collapsed=!1,this._panelIds=[],this._onDidChange=new X,this.onDidChange=this._onDidChange.event,this._onDidPanelChange=new X,this.onDidPanelChange=this._onDidPanelChange.event,this._onDidCollapseChange=new X,this.onDidCollapseChange=this._onDidCollapseChange.event,this._onDidDestroy=new X,this.onDidDestroy=this._onDidDestroy.event,this._label=t?.label??``,this._color=t?.color===``?void 0:t?.color,this._collapsed=t?.collapsed??!1,this._componentParams=t?.componentParams,this.addDisposables(this._onDidChange,this._onDidPanelChange,this._onDidCollapseChange,this._onDidDestroy)}addPanel(e,t){if(this.isDisposed||this._panelIds.includes(e))return;let n=t===void 0?this._panelIds.length:Math.max(0,Math.min(t,this._panelIds.length));this._panelIds.splice(n,0,e),this._onDidPanelChange.fire({panelId:e,type:`add`})}removePanel(e){if(this.isDisposed)return!1;let t=this._panelIds.indexOf(e);return t!==-1&&(this._panelIds.splice(t,1),this._onDidPanelChange.fire({panelId:e,type:`remove`}),!0)}indexOfPanel(e){return this._panelIds.indexOf(e)}containsPanel(e){return this._panelIds.includes(e)}collapse(){this.isDisposed||this._collapsed||(this._collapsed=!0,this._onDidCollapseChange.fire(!0))}expand(){!this.isDisposed&&this._collapsed&&(this._collapsed=!1,this._onDidCollapseChange.fire(!1))}toggle(){this._collapsed?this.expand():this.collapse()}toJSON(){let e={id:this.id,collapsed:this._collapsed,panelIds:[...this._panelIds]};return this._label&&(e.label=this._label),this._color!==void 0&&(e.color=this._color),this._componentParams!==void 0&&(e.componentParams=this._componentParams),e}dispose(){this._onDidDestroy.fire(),super.dispose()}},Bq=class extends _W{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get panel(){return this.options.panel}get index(){return this.options.index}get group(){return this.options.group}get api(){return this.options.api}constructor(e){super(),this.options=e}getData(){return this.options.getData()}},Vq=class extends Bq{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}},Hq=class extends Y{get tabGroups(){return this._tabGroups}get element(){throw Error(`dockview: not supported`)}get activePanel(){return this._activePanel}get contentContainerId(){return this.contentContainer.element.id}get contentDropTarget(){return this.contentContainer.dropTarget}get locked(){return this._locked}set locked(e){this._locked=e,Q(this.container,`dv-locked-groupview`,e===`no-drop-target`||e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return this._panels.length===0}get hasWatermark(){return!!(this.watermark&&this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get tabsListElement(){return this.tabsContainer.tabsListElement}getPanelForTab(e){return this.tabsContainer.getPanelForTab(e)}get isContentFocused(){let e=this.contentContainer.element,t=$W(e);return t?DW(t,e):!1}get headerPosition(){return this._headerPosition??`top`}set headerPosition(e){this._headerPosition=e,this.invalidateHeaderSize(),TW(this.container,`dv-groupview-header-top`,`dv-groupview-header-bottom`,`dv-groupview-header-left`,`dv-groupview-header-right`),EW(this.container,`dv-groupview-header-${e}`);let t=e===`top`||e===`bottom`?`horizontal`:`vertical`,n=this._headerDirection;if(this._headerDirection=t,this.tabsContainer.direction=t,this.header.direction=t,this.panels.length>0&&this.layoutContent(),this.updateHeaderActions(),n!==void 0&&n!==t){var r;(r=this.groupPanel)==null||r.api._onDidHeaderDirectionChange.fire({direction:t,position:e})}}get location(){return this._location}set location(e){this._location=e,Q(this.container,`dv-groupview-floating`,!1),Q(this.container,`dv-groupview-popout`,!1),Q(this.container,`dv-groupview-edge`,!1);let t=e=>{this.contentContainer.dropTarget.setTargetZones(e),this.contentContainer.pointerDropTarget.setTargetZones(e)};switch(e.type){case`grid`:t([`top`,`bottom`,`left`,`right`,`center`]);break;case`floating`:t([`top`,`bottom`,`left`,`right`,`center`]),Q(this.container,`dv-groupview-floating`,!0);break;case`popout`:t([`top`,`bottom`,`left`,`right`,`center`]),Q(this.container,`dv-groupview-popout`,!0);break;case`edge`:t([`center`]),Q(this.container,`dv-groupview-edge`,!0)}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,n,r,i){super(),this.container=e,this.accessor=t,this.id=n,this.options=r,this.groupPanel=i,this._isGroupActive=!1,this._locked=!1,this._location={type:`grid`},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new X,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._panelDisposables=new Map,this._tabGroupDisposables=new Map,this._pendingMicrotaskDisposables=new Set,this._onMove=new X,this.onMove=this._onMove.event,this._onDidDrop=new X,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new X,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new X,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new X,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new X,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new X,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new X,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new X,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new X,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new X,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOver=new X,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._tabGroups=[],this._tabGroupMap=new Map,this._panelToTabGroup=new Map,this._tabGroupIdCounter=0,this._pendingTabGroupUpdate=!1,this._onDidCreateTabGroup=new X,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new X,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new X,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new X,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new X,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new X,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,Q(this.container,`dv-groupview`,!0),this.container.setAttribute(`role`,`region`),this._api=new nK(this.accessor),this.tabsContainer=new Rq(this.accessor,this.groupPanel),this.contentContainer=new GK(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!r.hideHeader,this.locked=r.locked??!1,this.headerPosition=r.headerPosition??t.defaultHeaderPosition,this.addDisposables(wW(this.tabsContainer.element,()=>{if(this.isDisposed)return;let e=this.measureHeaderSize();e!==this._cachedHeaderSize&&(this._cachedHeaderSize=e,this.layout(this._width,this._height))}),this._onDidPanelTitleChange.event(()=>this.updateAccessibleLabel()),this._onTabDragStart,this._onGroupDragStart,this._onWillShowOverlay,this.tabsContainer.onTabDragStart(e=>{this._onTabDragStart.fire(e)}),this.tabsContainer.onGroupDragStart(e=>{this._onGroupDragStart.fire(e)}),this.tabsContainer.onDrop(e=>{let t=fW()?.panelId??null,n=t?this.tabsContainer.resolveDropIndex(t,e.index):e.index;if(this.handleDropEvent(`header`,e.event,`center`,n),t&&e.targetTabGroupId){let n=this._tabGroupMap.get(e.targetTabGroupId),r;if(n){let e=this._panels.findIndex(e=>e.id===t);if(e!==-1){r=0;for(let t of n.panelIds)this._panels.findIndex(e=>e.id===t)<e&&r++}}this.addPanelToTabGroup(e.targetTabGroupId,t,r)}else t&&e.targetTabGroupId===null&&this.removePanelFromTabGroup(t)}),this.contentContainer.onDidFocus(()=>{this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.onDidBlur(()=>{}),this.contentContainer.dropTarget.onDrop(e=>{this.handleDropEvent(`content`,e.nativeEvent,e.position,void 0,e.edge)}),this.contentContainer.pointerDropTarget.onDrop(e=>{this.handleDropEvent(`content`,e.nativeEvent,e.position,void 0,e.edge)}),this.tabsContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(e)}),this.contentContainer.dropTarget.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new aq(e,{kind:`content`,panel:this.activePanel,api:this._api,group:this.groupPanel,getData:fW}))}),this.contentContainer.pointerDropTarget.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new aq(e,{kind:`content`,panel:this.activePanel,api:this._api,group:this.groupPanel,getData:fW}))}),this._onMove,this._onDidChange,this._onDidDrop,this._onWillDrop,this._onDidAddPanel,this._onDidRemovePanel,this._onDidActivePanelChange,this._onUnhandledDragOver,this._onDidPanelTitleChange,this._onDidPanelParametersChange,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,this._onDidCreateTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidDestroyTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidAddPanelToTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidRemovePanelFromTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupChange.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupCollapsedChange.event(()=>{this._scheduleTabGroupUpdate()}))}_scheduleTabGroupUpdate(){this._pendingTabGroupUpdate||(this._pendingTabGroupUpdate=!0,queueMicrotask(()=>{this._pendingTabGroupUpdate=!1,this.isDisposed||this.tabsContainer.updateTabGroups()}))}_bracketTabGroupMutation(e){return this.accessor.mutation?this.accessor.mutation(`tab-group`,e):e()}createTabGroup(e){return this._bracketTabGroupMutation(()=>this._doCreateTabGroup(e))}_doCreateTabGroup(e){let t=e?.id??`tg-${this.id}-${this._tabGroupIdCounter++}`,n=new zq(t,{label:e?.label,color:e?.color,collapsed:e?.collapsed,componentParams:e?.componentParams});return this._tabGroups.push(n),this._tabGroupMap.set(t,n),this._tabGroupDisposables.set(t,new Y(n.onDidChange(()=>{this._onDidTabGroupChange.fire({tabGroup:n})}),n.onDidCollapseChange(e=>{e?this._handleGroupCollapse(n):this._handleGroupExpand(n),this._onDidTabGroupCollapsedChange.fire({tabGroup:n})}),n.onDidDestroy(()=>{this._removeTabGroupInternal(n)}))),this._onDidCreateTabGroup.fire({tabGroup:n}),n}dissolveTabGroup(e){let t=this._tabGroupMap.get(e);t&&this._bracketTabGroupMutation(()=>{let e=[...t.panelIds];for(let n of e)t.removePanel(n),this._panelToTabGroup.delete(n),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:n});t.dispose()})}addPanelToTabGroup(e,t,n){let r=this._tabGroupMap.get(e);if(!r||!this._panels.some(e=>e.id===t))return;let i=this.getTabGroupForPanel(t);i?.id!==e&&this._bracketTabGroupMutation(()=>{i&&this.removePanelFromTabGroup(t),r.addPanel(t,n),this._panelToTabGroup.set(t,r),this._enforceContiguity(r,t),this._onDidAddPanelToTabGroup.fire({tabGroup:r,panelId:t})})}movePanelWithinGroup(e,t,n){let r=this._tabGroupMap.get(e);r?.containsPanel(t)&&(r.removePanel(t),r.addPanel(t,n),this._enforceContiguity(r,t),this.tabsContainer.updateTabGroups())}movePanelBetweenGroups(e,t,n){let r=this._findTabGroupForPanel(e),i=this._tabGroupMap.get(t);i&&(r&&(r.removePanel(e),this._panelToTabGroup.delete(e),this._moveOutOfGroupSpan(r,e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:r,panelId:e}),r.isEmpty&&r.dispose()),i.addPanel(e,n),this._panelToTabGroup.set(e,i),this._enforceContiguity(i,e),this._onDidAddPanelToTabGroup.fire({tabGroup:i,panelId:e}))}moveTabGroup(e,t){let n=this._tabGroupMap.get(e);if(!n||n.panelIds.length===0)return;let r=new Set(n.panelIds),i=n.panelIds.map(e=>this._panels.find(t=>t.id===e)).filter(e=>e!==void 0);if(i.length===0)return;let a=0;for(let e=0;e<Math.min(t,this._panels.length);e++)r.has(this._panels[e].id)&&a++;for(let e of i){let t=this._panels.indexOf(e);t!==-1&&this._panels.splice(t,1)}let o=t-a,s=Math.max(0,Math.min(o,this._panels.length));this._panels.splice(s,0,...i);for(let e of this._panels)this.tabsContainer.delete(e.id);for(let e=0;e<this._panels.length;e++)this.tabsContainer.openPanel(this._panels[e],e);this._syncActiveTab(),this.tabsContainer.updateTabGroups()}_enforceContiguity(e,t){let n=this._panels.find(e=>e.id===t);if(!n)return;let r=e.indexOfPanel(t),i=this._computeGlobalIndex(e,r),a=this._panels.indexOf(n);if(a===i)return;this._panels.splice(a,1);let o=i>a?i-1:i;this._panels.splice(o,0,n),this._reinsertTab(n,o)}_reinsertTab(e,t){this.tabsContainer.delete(e.id),this.tabsContainer.openPanel(e,t),e===this._activePanel&&this._syncActiveTab()}_syncActiveTab(){this._activePanel&&(this.tabsContainer.setActivePanel(this._activePanel),this.contentContainer.setLabelledBy(this.tabsContainer.getTabId(this._activePanel.id)))}_computeGlobalIndex(e,t){let n=e.panelIds;if(n.length<=1){let e=this._panels.find(e=>e.id===n[0]);return e?this._panels.indexOf(e):this._panels.length}for(let e=0;e<n.length;e++){if(e===t)continue;let r=this._panels.find(t=>t.id===n[e]);if(r){let n=this._panels.indexOf(r);return Math.max(0,n+(t-e))}}return this._panels.length}removePanelFromTabGroup(e){let t=this._findTabGroupForPanel(e);t&&this._bracketTabGroupMutation(()=>{t.removePanel(e),this._panelToTabGroup.delete(e),this._moveOutOfGroupSpan(t,e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:e}),t.isEmpty&&t.dispose()})}_moveOutOfGroupSpan(e,t){let n=this._panels.findIndex(e=>e.id===t);if(n===-1||e.isEmpty)return;let r=e.panelIds,i=this._panels.findIndex(e=>e.id===r[0]),a=this._panels.findIndex(e=>e.id===r[r.length-1]);if(i===-1||a===-1||n<i||n>a)return;let[o]=this._panels.splice(n,1);this._panels.splice(a,0,o),this._reinsertTab(o,a)}getTabGroups(){return this._tabGroups}updateTabGroups(){this.tabsContainer.updateTabGroups()}refreshTabGroupAccent(){this.tabsContainer.refreshTabGroupAccent()}refreshWatermark(){if(this.watermark){var e,t;this.watermark.element.remove(),(e=(t=this.watermark).dispose)==null||e.call(t),this.watermark=void 0}this.updateContainer()}getTabGroupForPanel(e){return this._findTabGroupForPanel(e)}_findTabGroupForPanel(e){return this._panelToTabGroup.get(e)}_removeTabGroupInternal(e){let t=this._tabGroups.indexOf(e);if(t!==-1){this._tabGroups.splice(t,1),this._tabGroupMap.delete(e.id);for(let t of e.panelIds)this._panelToTabGroup.delete(t);this._onDidDestroyTabGroup.fire({tabGroup:e});let n=this._tabGroupDisposables.get(e.id);this._tabGroupDisposables.delete(e.id),n&&(this._pendingMicrotaskDisposables.add(n),queueMicrotask(()=>{this._pendingMicrotaskDisposables.delete(n),n.dispose()}))}}_handleGroupCollapse(e){if(!this._activePanel||!e.containsPanel(this._activePanel.id))return;let t=this._panels.indexOf(this._activePanel);for(let e=t+1;e<this._panels.length;e++){let t=this._panels[e];if(!this._findTabGroupForPanel(t.id)?.collapsed){this.doSetActivePanel(t),this.updateContainer();return}}for(let e=t-1;e>=0;e--){let t=this._panels[e];if(!this._findTabGroupForPanel(t.id)?.collapsed){this.doSetActivePanel(t),this.updateContainer();return}}this.contentContainer.closePanel(),this.doSetActivePanel(void 0),this.updateContainer()}_handleGroupExpand(e){if(this._activePanel)return;let t=e.panelIds[0];if(t){let e=this._panels.find(e=>e.id===t);e&&(this.doSetActivePanel(e),this.updateContainer())}}restoreTabGroups(e){for(let t of e){let e=/-(\d+)$/.exec(t.id);if(e){let t=Number.parseInt(e[1],10)+1;t>this._tabGroupIdCounter&&(this._tabGroupIdCounter=t)}}for(let t of e){let e=this.createTabGroup({id:t.id,label:t.label,color:t.color,componentParams:t.componentParams}),n=this._tabGroupMap.get(e.id);for(let r of t.panelIds)this._panels.some(e=>e.id===r)&&(e.addPanel(r),this._panelToTabGroup.set(r,n),this._enforceContiguity(n,r));t.collapsed&&e.collapse(),e.isEmpty&&e.dispose()}}focusContent(){this.contentContainer.element.focus()}focusActiveTab(){this.tabsContainer.focusActiveTab()}set renderContainer(e){this.panels.forEach(e=>{this.renderContainer.detatch(e)}),this._overwriteRenderContainer=e,this.panels.forEach(e=>{this.rerender(e)}),this.panels.length>0&&this.layoutContent()}get renderContainer(){return this._overwriteRenderContainer??this.accessor.overlayRenderContainer}set dropTargetContainer(e){this._overwriteDropTargetContainer=e}get dropTargetContainer(){return this._location.type===`floating`&&this.accessor.rootDropTargetContainer.disabled?this.accessor.floatingDropTargetContainer:this._overwriteDropTargetContainer??this.accessor.rootDropTargetContainer}initialize(){this.options.panels&&this.options.panels.forEach(e=>{this.doAddPanel(e)}),this.options.activePanel&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0),this.updateContainer(),this.updateHeaderActions()}updateHeaderActions(){var e;(e=this.accessor.headerActionsService)==null||e.refresh(this.groupPanel)}attachHeaderAction(e,t){switch(e){case`left`:this.tabsContainer.setLeftActionsElement(t);break;case`right`:this.tabsContainer.setRightActionsElement(t);break;case`prefix`:this.tabsContainer.setPrefixActionsElement(t)}}rerender(e){this.contentContainer.renderPanel(e,{asActive:!1})}indexOf(e){return this.tabsContainer.indexOf(e.id)}toJSON(){let e={views:this.tabsContainer.panels,activeView:this._activePanel?.id,id:this.id};return this.locked!==!1&&(e.locked=this.locked),this.header.hidden&&(e.hideHeader=!0),this.headerPosition!==`top`&&(e.headerPosition=this.headerPosition),this._tabGroups.length>0&&(e.tabGroups=this._tabGroups.map(e=>e.toJSON())),e}moveToNext(e){var t;e??={},(t=e).panel??(t.panel=this.activePanel);let n=e.panel?this.panels.indexOf(e.panel):-1,r;if(n<this.panels.length-1)r=n+1;else if(e.suppressRoll)return;else r=0;this.openPanel(this.panels[r])}moveToPrevious(e){var t;if(e??={},(t=e).panel??(t.panel=this.activePanel),!e.panel)return;let n=this.panels.indexOf(e.panel),r;if(n>0)r=n-1;else if(e.suppressRoll)return;else r=this.panels.length-1;this.openPanel(this.panels[r])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;(e=this._activePanel)==null||e.focus()}openPanel(e,t={}){typeof t.index!=`number`||t.index>this.panels.length?t.index=this.panels.length:t.index<0&&(t.index=0);let n=!!t.skipSetActive;e.updateParentGroup(this.groupPanel,{skipSetActive:t.skipSetActive}),this.doAddPanel(e,t.index,{skipSetActive:n}),this.invalidateHeaderSize(),this._activePanel===e?this.contentContainer.openPanel(e):(n||this.doSetActivePanel(e),t.skipSetGroupActive||this.accessor.doSetGroupActive(this.groupPanel),t.skipSetActive?e.runEvents():this.updateContainer())}removePanel(e,t){let n=typeof e==`string`?e:e.id,r=this._panels.find(e=>e.id===n);if(!r)throw Error(`invalid operation`);return this._removePanel(r,t)}closeAllPanels(){if(this.panels.length>0){let e=[...this.panels];for(let t of e)this.doClose(t)}else this.accessor.removeGroup(this.groupPanel)}closePanel(e){this.doClose(e)}doClose(e){let t=this.panels.length===1&&this.accessor.isLastGridGroup(this.groupPanel);this.accessor.removePanel(e,t&&this.accessor.options.noPanelsOverlay===`emptyGroup`?{removeEmptyGroup:!1}:void 0)}isPanelActive(e){return this._activePanel===e}updateActions(e){this.tabsContainer.setRightActionsElement(e)}setActive(e,t=!1){if(!this.isDisposed&&(t||this.isActive!==e)){if(this._isGroupActive=e,Q(this.container,`dv-active-group`,e),Q(this.container,`dv-inactive-group`,!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0){let e=this._panels.find(e=>!this._findTabGroupForPanel(e.id)?.collapsed);e&&this.doSetActivePanel(e)}this.updateContainer()}}layout(e,t){this._width=e,this._height=t,this.layoutContent()}layoutContent(){let{width:e,height:t}=this.contentDimensions();this.contentContainer.layout(e,t),this._activePanel?.layout&&this._activePanel.layout(e,t)}relayout(){this.invalidateHeaderSize(),this.layout(this._width,this._height)}measureHeaderSize(){let e=this.tabsContainer.element;return this.headerPosition===`top`||this.headerPosition===`bottom`?e.offsetHeight:e.offsetWidth}invalidateHeaderSize(){this._cachedHeaderSize=void 0}contentDimensions(){let e=this.headerPosition===`top`||this.headerPosition===`bottom`,t=this._cachedHeaderSize??=this.measureHeaderSize();return{width:e?this._width:Math.max(0,this._width-t),height:e?Math.max(0,this._height-t):this._height}}_removePanel(e,t){let n=this._activePanel===e;if(this.doRemovePanel(e),this.invalidateHeaderSize(),n&&this.panels.length>0){let e=this.mostRecentlyUsed[0];this.openPanel(e,{skipSetActive:t?.skipSetActive,skipSetGroupActive:t?.skipSetActiveGroup})}return this._activePanel&&this.panels.length===0&&this.doSetActivePanel(void 0),t?.skipSetActive||this.updateContainer(),e}doRemovePanel(e){let t=this.panels.indexOf(e);if(this._activePanel===e&&this.contentContainer.closePanel(),this.tabsContainer.delete(e.id),this._panels.splice(t,1),this.mostRecentlyUsed.includes(e)){let t=this.mostRecentlyUsed.indexOf(e);this.mostRecentlyUsed.splice(t,1)}let n=this._panelDisposables.get(e.id);n&&(n.dispose(),this._panelDisposables.delete(e.id)),this.removePanelFromTabGroup(e.id),this._onDidRemovePanel.fire({panel:e})}doAddPanel(e,t=this.panels.length,n){let r=this._panels.indexOf(e)>-1;this.tabsContainer.show(),this.contentContainer.show(),this.tabsContainer.openPanel(e,t),n?.skipSetActive?e.api.renderer===`always`&&this.contentContainer.renderPanel(e,{asActive:!1}):this.contentContainer.openPanel(e),!r&&(this.updateMru(e),this.panels.splice(t,0,e),this._panelDisposables.set(e.id,new Y(e.api.onDidTitleChange(e=>this._onDidPanelTitleChange.fire(e)),e.api.onDidParametersChange(e=>this._onDidPanelParametersChange.fire(e)))),this._onDidAddPanel.fire({panel:e}))}doSetActivePanel(e){if(this._activePanel!==e){if(this._activePanel=e,e){var t;this._syncActiveTab(),this.contentContainer.openPanel(e),this.layoutContent(),this.updateMru(e),this.contentContainer.refreshFocusState(),this._onDidActivePanelChange.fire({panel:e,origin:(t=this.accessor).currentOrigin?.call(t)??`user`})}this.updateAccessibleLabel()}}updateAccessibleLabel(){let e=this._activePanel?.title;e?this.container.setAttribute(`aria-label`,e):this.container.removeAttribute(`aria-label`)}updateMru(e){this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this.mostRecentlyUsed=[e,...this.mostRecentlyUsed]}updateContainer(){this.panels.forEach(e=>e.runEvents());let e=this.isEmpty||!this._activePanel;if(e&&!this.watermark){let e=this.accessor.createWatermarkComponent();e.init({containerApi:this._api,group:this.groupPanel}),this.watermark=e,Z(this.watermark.element,`pointerdown`,()=>{this.isActive||this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.element.appendChild(this.watermark.element)}if(!e&&this.watermark){var t,n;this.watermark.element.remove(),(t=(n=this.watermark).dispose)==null||t.call(n),this.watermark=void 0}}canDisplayOverlay(e,t,n){let r=new fq(e,n,t,fW,this.accessor.getPanel(this.id));return this._onUnhandledDragOver.fire(r),r.isAccepted}canDisplayContentOverlay(e,t){if(this.locked===`no-drop-target`||this.locked&&t===`center`)return!1;let n=fW();return!n&&e.shiftKey&&this.location.type!==`floating`?!1:n?.viewId===this.accessor.id||this.canDisplayOverlay(e,t,`content`)}handleDropEvent(e,t,n,r,i){if(this.locked===`no-drop-target`)return;if(e===`content`&&i){this.accessor.dockToLayoutEdge(t,n);return}function a(){switch(e){case`header`:return typeof r==`number`?`tab`:`header_space`;case`content`:return`content`}}let o=typeof r==`number`?this.panels[r]:void 0,s=new Vq({nativeEvent:t,position:n,panel:o,index:r,getData:()=>fW(),kind:a(),group:this.groupPanel,api:this._api});if(this._onWillDrop.fire(s),s.defaultPrevented)return;let c=fW();if(c?.viewId===this.accessor.id){if(e===`content`&&c.groupId===this.id&&(n===`center`||c.panelId===null&&!c.tabGroupId)||e===`header`&&c.groupId===this.id&&c.panelId===null&&!c.tabGroupId)return;if(c.panelId===null){let{groupId:e}=c;this._onMove.fire({target:n,groupId:e,index:r,tabGroupId:c.tabGroupId});return}if(this.tabsContainer.indexOf(c.panelId)!==-1&&this.tabsContainer.size===1&&this.accessor.options.closeEmptyGroups!==!1)return;let{groupId:t,panelId:i}=c;if(this.id===t&&!n&&this.tabsContainer.indexOf(i)===r)return;this._onMove.fire({target:n,groupId:c.groupId,itemId:c.panelId,index:r})}else this._onDidDrop.fire(new Bq({nativeEvent:t,position:n,panel:o,index:r,getData:()=>fW(),group:this.groupPanel,api:this._api}))}updateDragAndDropState(){this.tabsContainer.updateDragAndDropState()}dispose(){var e,t,n;super.dispose(),(e=this.watermark)==null||e.element.remove(),(t=this.watermark)==null||(n=t.dispose)==null||n.call(t),this.watermark=void 0;for(let e of[...this._tabGroups])e.dispose();for(let e of this._tabGroupDisposables.values())e.dispose();this._tabGroupDisposables.clear();for(let e of this._pendingMicrotaskDisposables)e.dispose();this._pendingMicrotaskDisposables.clear();for(let e of this.panels)e.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}},Uq=class extends LK{constructor(e,t,n){super(e,t),this._onDidConstraintsChangeInternal=new X,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new X,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new X,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange),n&&this.initialize(n)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},Wq=class extends BK{get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){return this.__minimumWidth()}get minimumHeight(){return this.__minimumHeight()}get maximumHeight(){return this.__maximumHeight()}get maximumWidth(){return this.__maximumWidth()}__minimumWidth(){let e=typeof this._minimumWidth==`function`?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}__maximumWidth(){let e=typeof this._maximumWidth==`function`?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}__minimumHeight(){let e=typeof this._minimumHeight==`function`?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}__maximumHeight(){let e=typeof this._maximumHeight==`function`?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}get isVisible(){return this.api.isVisible}constructor(e,t,n,r){super(e,t,r??new Uq(e,t)),this._evaluatedMinimumWidth=0,this._evaluatedMaximumWidth=2**53-1,this._evaluatedMinimumHeight=0,this._evaluatedMaximumHeight=2**53-1,this._minimumWidth=0,this._minimumHeight=0,this._maximumWidth=2**53-1,this._maximumHeight=2**53-1,this._snap=!1,this._onDidChange=new X,this.onDidChange=this._onDidChange.event,typeof n?.minimumWidth==`number`&&(this._minimumWidth=n.minimumWidth),typeof n?.maximumWidth==`number`&&(this._maximumWidth=n.maximumWidth),typeof n?.minimumHeight==`number`&&(this._minimumHeight=n.minimumHeight),typeof n?.maximumHeight==`number`&&(this._maximumHeight=n.maximumHeight),this.api.initialize(this),this.addDisposables(this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onActiveChange(()=>{let{accessor:e}=this._params;e.doSetGroupActive(this)}),this.api.onDidConstraintsChangeInternal(e=>this.applyConstraints(e)),this.api.onDidSizeChange(e=>{this._onDidChange.fire({height:e.height,width:e.width})}),this._onDidChange)}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}init(e){e.maximumHeight&&(this._maximumHeight=e.maximumHeight),e.minimumHeight&&(this._minimumHeight=e.minimumHeight),e.maximumWidth&&(this._maximumWidth=e.maximumWidth),e.minimumWidth&&(this._minimumWidth=e.minimumWidth),this._priority=e.priority,this._snap=!!e.snap,super.init(e),typeof e.isVisible==`boolean`&&this.setVisible(e.isVisible)}applyConstraints(e){(typeof e.minimumWidth==`number`||typeof e.minimumWidth==`function`)&&(this._minimumWidth=e.minimumWidth),(typeof e.minimumHeight==`number`||typeof e.minimumHeight==`function`)&&(this._minimumHeight=e.minimumHeight),(typeof e.maximumWidth==`number`||typeof e.maximumWidth==`function`)&&(this._maximumWidth=e.maximumWidth),(typeof e.maximumHeight==`number`||typeof e.maximumHeight==`function`)&&(this._maximumHeight=e.maximumHeight),this.notifyConstraintsChanged()}notifyConstraintsChanged(){this._onDidChange.fire(void 0)}updateConstraints(){this.api._onDidConstraintsChange.fire({minimumWidth:this._evaluatedMinimumWidth,maximumWidth:this._evaluatedMaximumWidth,minimumHeight:this._evaluatedMinimumHeight,maximumHeight:this._evaluatedMaximumHeight})}toJSON(){let e=super.toJSON(),t=e=>e===2**53-1?void 0:e,n=e=>e<=0?void 0:e;return $($({},e),{},{minimumHeight:n(this.minimumHeight),maximumHeight:t(this.maximumHeight),minimumWidth:n(this.minimumWidth),maximumWidth:t(this.maximumWidth),snap:this.snap,priority:this.priority})}},Gq=`dockview: DockviewGroupPanelApiImpl not initialized`,Kq=class extends Uq{get location(){if(!this._group)throw Error(Gq);return this._group.model.location}get boundingBox(){if(!this._group||this._group.model.location.type===`popout`)return;let e=this.accessor.element.getBoundingClientRect(),t=this._group.element.getBoundingClientRect();return{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}}get locked(){if(!this._group)throw Error(Gq);return this._group.locked}set locked(e){if(!this._group)throw Error(Gq);this._group.locked=e}constructor(e,t){super(e,`__dockviewgroup__`),this.accessor=t,this._isApplyingSize=!1,this._onDidLocationChange=new X,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new X,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidCollapsedChange=new X,this.onDidCollapsedChange=this._onDidCollapsedChange.event,this._onDidPeekChange=new X,this.onDidPeekChange=this._onDidPeekChange.event,this._onDidHeaderDirectionChange=new X,this.onDidHeaderDirectionChange=this._onDidHeaderDirectionChange.event,this.addDisposables(this._onDidLocationChange,this._onDidActivePanelChange,this._onDidCollapsedChange,this._onDidPeekChange,this._onDidHeaderDirectionChange,this._onDidVisibilityChange.event(e=>{if(e.isVisible&&this._pendingSize){let e=this._pendingSize;this._pendingSize=void 0,super.setSize(e)}}),this.onDidDimensionsChange(e=>{let t=e.width!==this._reportedSize?.width||e.height!==this._reportedSize?.height;this._reportedSize={width:e.width,height:e.height},t&&this.isVisible&&!this._isApplyingSize&&(this._pendingSize=void 0)}))}setSize(e){(typeof e.width==`number`||typeof e.height==`number`)&&(this._pendingSize=$({},e));let t=this._isApplyingSize;this._isApplyingSize=!0;try{super.setSize(e)}finally{this._isApplyingSize=t}}close(){if(this._group)return this.accessor.removeGroup(this._group)}getWindow(){return this.location.type===`popout`?this.location.getWindow():globalThis.window}setHeaderPosition(e){if(!this._group)throw Error(Gq);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw Error(Gq);return this._group.model.headerPosition}moveTo(e){if(!this._group)throw Error(Gq);this.accessor.withOrigin(`api`,()=>{let t=e.group??this.accessor.addGroup({direction:hK(e.position??`right`),skipSetActive:e.skipSetActive??!1});this.accessor.moveGroupOrPanel({from:{groupId:this._group.id},to:{group:t,position:e.group?e.position??`center`:`center`,index:e.index},skipSetActive:e.skipSetActive})})}maximize(){if(!this._group)throw Error(Gq);this.location.type===`grid`&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw Error(Gq);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw Error(Gq);this.isMaximized()&&this.accessor.exitMaximizedGroup()}collapse(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!0)}expand(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!1)}isCollapsed(){return this._group?this.accessor.isEdgeGroupCollapsed(this._group):!1}isPeeking(){return this._group?this.accessor.isEdgeGroupPeeking(this._group):!1}setAutoHide(e){this._group&&this.accessor.setEdgeGroupAutoHide(this._group,e)}isAutoHide(){return this._group?this.accessor.isEdgeGroupAutoHide(this._group):!1}initialize(e){this._group=e}},qq=100,Jq=100,Yq=class extends Wq{get minimumWidth(){if(typeof this._explicitConstraints.minimumWidth==`number`)return this._explicitConstraints.minimumWidth;let e=this.activePanel?.minimumWidth;return typeof e==`number`?e:super.__minimumWidth()}get minimumHeight(){if(typeof this._explicitConstraints.minimumHeight==`number`)return this._explicitConstraints.minimumHeight;let e=this.activePanel?.minimumHeight;return typeof e==`number`?e:super.__minimumHeight()}get maximumWidth(){if(typeof this._explicitConstraints.maximumWidth==`number`)return this._explicitConstraints.maximumWidth;let e=this.activePanel?.maximumWidth;return typeof e==`number`?e:super.__maximumWidth()}get maximumHeight(){if(typeof this._explicitConstraints.maximumHeight==`number`)return this._explicitConstraints.maximumHeight;let e=this.activePanel?.maximumHeight;return typeof e==`number`?e:super.__maximumHeight()}get panels(){return this._model.panels}get activePanel(){return this._model.activePanel}get size(){return this._model.size}get model(){return this._model}get locked(){return this._model.locked}set locked(e){this._model.locked=e}get header(){return this._model.header}constructor(e,t,n){super(t,`groupview_default`,{minimumHeight:n.constraints?.minimumHeight??Jq,minimumWidth:n.constraints?.minimumWidth??qq,maximumHeight:n.constraints?.maximumHeight,maximumWidth:n.constraints?.maximumWidth},new Kq(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new Hq(this.element,e,t,n,this),this._lastConstraints=this.currentConstraints(),this.addDisposables(this.model.onDidActivePanelChange(e=>{this.api._onDidActivePanelChange.fire(e),this.notifyIfConstraintsChanged()}))}applyConstraints(e){e.minimumWidth!==void 0&&(this._explicitConstraints.minimumWidth=typeof e.minimumWidth==`function`?e.minimumWidth():e.minimumWidth),e.minimumHeight!==void 0&&(this._explicitConstraints.minimumHeight=typeof e.minimumHeight==`function`?e.minimumHeight():e.minimumHeight),e.maximumWidth!==void 0&&(this._explicitConstraints.maximumWidth=typeof e.maximumWidth==`function`?e.maximumWidth():e.maximumWidth),e.maximumHeight!==void 0&&(this._explicitConstraints.maximumHeight=typeof e.maximumHeight==`function`?e.maximumHeight():e.maximumHeight),super.applyConstraints(e),this._lastConstraints=this.currentConstraints()}currentConstraints(){return{minimumWidth:this.minimumWidth,maximumWidth:this.maximumWidth,minimumHeight:this.minimumHeight,maximumHeight:this.maximumHeight}}notifyIfConstraintsChanged(){let e=this._lastConstraints,t=this.currentConstraints();(e.minimumWidth!==t.minimumWidth||e.maximumWidth!==t.maximumWidth||e.minimumHeight!==t.minimumHeight||e.maximumHeight!==t.maximumHeight)&&(this._lastConstraints=t,this.notifyConstraintsChanged())}focus(){this.api.isActive||this.api.setActive(),super.focus()}initialize(){this._model.initialize()}setActive(e){super.setActive(e),this.model.setActive(e)}layout(e,t){super.layout(e,t),this.model.layout(e,t)}relayout(){this.model.relayout()}getComponent(){return this._model}toJSON(){return this.model.toJSON()}},Xq={name:`abyss`,className:`dockview-theme-abyss`,colorScheme:`dark`,tabGroupIndicator:`none`},Zq=class extends Uq{get location(){return this.group.api.location}get title(){return this.panel.title}get isPinned(){return this.panel.isPinned}get isGroupActive(){return this.group.isActive}get renderer(){return this.panel.renderer}set group(e){if(this._group!==e){let t=this._group.isActive;this._group=e,this._onDidGroupChange.fire({}),this.setupGroupEventListeners(),t!==this.isGroupActive&&this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}),this.fireLocationChange()}}get group(){return this._group}get tabComponent(){return this._tabComponent}constructor(e,t,n,r,i){super(e.id,r),this.panel=e,this.accessor=n,this._onDidTitleChange=new X,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidChangePinned=new X,this.onDidChangePinned=this._onDidChangePinned.event,this._onDidActiveGroupChange=new X,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new X,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new X,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new X,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new hW,this._tabComponent=i,this.initialize(e),this._group=t,this.setupGroupEventListeners(),this.addDisposables(this.groupEventsDisposable,this._onDidRendererChange,this._onDidTitleChange,this._onDidChangePinned,this._onDidGroupChange,this._onDidActiveGroupChange,this._onDidLocationChange)}getWindow(){return this.group.api.getWindow()}setActive(){this.accessor.withOrigin(`api`,()=>super.setActive())}moveTo(e){this.accessor.withOrigin(`api`,()=>this.accessor.moveGroupOrPanel({from:{groupId:this._group.id,panelId:this.panel.id},to:{group:e.group??this._group,position:e.group?e.position??`center`:`center`,index:e.index},skipSetActive:e.skipSetActive}))}setTitle(e){this.panel.setTitle(e)}setPinned(e){this.accessor.setPanelPinned(this.panel,e)}setRenderer(e){this.panel.setRenderer(e)}close(){this.group.model.closePanel(this.panel)}maximize(){this.group.api.maximize()}isMaximized(){return this.group.api.isMaximized()}exitMaximized(){this.group.api.exitMaximized()}fireLocationChange(){this.accessor.deferLocationChange(this,()=>{this.isDisposed||this._onDidLocationChange.fire({location:this.location})})}setupGroupEventListeners(){let e=this.isGroupActive;this.groupEventsDisposable.value=new Y(this.group.api.onDidVisibilityChange(e=>{let t=!e.isVisible&&this.isVisible,n=e.isVisible&&!this.isVisible,r=this.group.model.isPanelActive(this.panel);(t||n&&r)&&this._onDidVisibilityChange.fire(e)}),this.group.api.onDidLocationChange(()=>{this.group===this.panel.group&&this.fireLocationChange()}),this.group.api.onDidActiveChange(()=>{this.group===this.panel.group&&e!==this.isGroupActive&&(e=this.isGroupActive,this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}))}))}},Qq=class extends Y{get params(){return this._params}get title(){return this._title}get isPinned(){return this._pinned}get group(){return this._group}get renderer(){return this._renderer??this.accessor.renderer}get minimumWidth(){return this._minimumWidth}get minimumHeight(){return this._minimumHeight}get maximumWidth(){return this._maximumWidth}get maximumHeight(){return this._maximumHeight}constructor(e,t,n,r,i,a,o,s){super(),this.id=e,this.accessor=r,this.containerApi=i,this.view=o,this._pinned=!1,this._renderer=s.renderer,this._group=a,this._minimumWidth=s.minimumWidth,this._minimumHeight=s.minimumHeight,this._maximumWidth=s.maximumWidth,this._maximumHeight=s.maximumHeight,this.api=new Zq(this,this._group,r,t,n),this.addDisposables(this.api.onActiveChange(()=>{r.setActivePanel(this)}),this.api.onDidSizeChange(e=>{this.group.api.setSize(e)}),this.api.onDidRendererChange(()=>{this.group.model.rerender(this)}))}init(e){this._params=e.params,this.view.init($($({},e),{},{api:this.api,containerApi:this.containerApi})),this.setTitle(e.title)}focus(){let e=new IK;this.api._onWillFocus.fire(e),e.defaultPrevented||this.api.isActive||this.api.setActive()}toJSON(){return{id:this.id,contentComponent:this.view.contentComponent,tabComponent:this.view.tabComponent,params:Object.keys(this._params||{}).length>0?this._params:void 0,title:this.title,renderer:this._renderer,minimumHeight:this._minimumHeight,maximumHeight:this._maximumHeight,minimumWidth:this._minimumWidth,maximumWidth:this._maximumWidth,pinned:this._pinned?!0:void 0}}setTitle(e){e!==this.title&&(this._title=e,this.view.setTitle(e),this.api._onDidTitleChange.fire({title:e}))}setPinned(e){this._pinned!==e&&(this._pinned=e,this.api._onDidChangePinned.fire({isPinned:e}))}setRenderer(e){e!==this.renderer&&(this._renderer=e,this.api._onDidRendererChange.fire({renderer:e}))}update(e){this._params=$($({},this._params),e.params);for(let t of Object.keys(e.params))e.params[t]===void 0&&delete this._params[t];this.view.update({params:this._params})}updateFromStateModel(e){this._maximumHeight=e.maximumHeight,this._minimumHeight=e.minimumHeight,this._maximumWidth=e.maximumWidth,this._minimumWidth=e.minimumWidth,this._params=e.params??{},this.view.update({params:this._params}),this.setTitle(e.title??this.id),this.setRenderer(e.renderer??this.accessor.renderer),this.setPinned((e.pinned??!1)&&!!this.accessor.options.pinnedTabs?.enabled)}updateParentGroup(e,t){this._group=e,this.api.group=this._group;let n=this._group.model.isPanelActive(this),r=this.group.api.isActive&&n;t?.skipSetActive||this.api.isActive!==r&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&n}),this.api.isVisible!==n&&this.api._onDidVisibilityChange.fire({isVisible:n})}runEvents(){let e=this._group.model.isPanelActive(this),t=this.group.api.isActive&&e;this.api.isActive!==t&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&e}),this.api.isVisible!==e&&this.api._onDidVisibilityChange.fire({isVisible:e})}layout(e,t){this.api._onDidDimensionChange.fire({width:e,height:t}),this.view.layout(e,t)}dispose(){this.api.dispose(),this.view.dispose()}},$q=class extends Y{get element(){return this._element}constructor(){super(),this._messages=ZG,this._element=document.createElement(`div`),this._element.className=`dv-default-tab`,this._content=document.createElement(`div`),this._content.className=`dv-default-tab-content`,this.action=document.createElement(`div`),this.action.className=`dv-default-tab-action`,this.action.setAttribute(`role`,`button`),this.action.setAttribute(`tabindex`,`-1`);let e=qK();e.setAttribute(`aria-hidden`,`true`),this.action.appendChild(e),this._element.appendChild(this._content),this._element.appendChild(this.action),this.render()}init(e){this._title=e.title,this._messages=e.containerApi.messages??ZG,this.addDisposables(e.api.onDidTitleChange(e=>{this._title=e.title,this.render()}),Z(this.action,`pointerdown`,e=>{e.preventDefault()}),Z(this.action,`click`,t=>{t.defaultPrevented||(t.preventDefault(),e.api.close())})),this.render()}render(){this._content.textContent!==this._title&&(this._content.textContent=this._title??``),this.action.setAttribute(`aria-label`,this._title?this._messages.closeTab(this._title):this._messages.closeTabPlain())}},eJ=class{get content(){return this._content}get tab(){return this._tab}constructor(e,t,n,r){this.accessor=e,this.id=t,this.contentComponent=n,this.tabComponent=r,this._content=this.createContentComponent(this.id,n),this._tab=this.createTabComponent(this.id,r)}createTabRenderer(e){let t=this.createTabComponent(this.id,this.tabComponent);if(this._params&&t.init($($({},this._params),{},{tabLocation:e})),this._updateEvent){var n;(n=t.update)==null||n.call(t,this._updateEvent)}return t}init(e){this._params=e,this.content.init(e),this.tab.init($($({},e),{},{tabLocation:`header`}))}setTitle(e){this._params&&(this._params.title=e)}layout(e,t){var n,r;(n=(r=this.content).layout)==null||n.call(r,e,t)}update(e){var t,n,r,i;this._updateEvent=e,(t=(n=this.content).update)==null||t.call(n,e),(r=(i=this.tab).update)==null||r.call(i,e)}dispose(){var e,t,n,r;(e=(t=this.content).dispose)==null||e.call(t),(n=(r=this.tab).dispose)==null||n.call(r)}createContentComponent(e,t){return this.accessor.options.createComponent({id:e,name:t})}createTabComponent(e,t){let n=t??this.accessor.options.defaultTabComponent;if(n){if(this.accessor.options.createTabComponent)return this.accessor.options.createTabComponent({id:e,name:n})||new $q;console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new $q}},tJ=class{constructor(e){this.accessor=e}fromJSON(e,t){let n=e.id,r=e.params,i=e.title,a=e.view,o=a?a.content.id:e.contentComponent??`unknown`,s=a?a.tab?.id:e.tabComponent,c=new eJ(this.accessor,n,o,s),l=new Qq(n,o,s,this.accessor,new nK(this.accessor),t,c,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return l.init({title:i??n,params:r??{}}),e.pinned&&this.accessor.options.pinnedTabs?.enabled&&l.setPinned(!0),l}},nJ=class extends Y{get element(){return this._element}constructor(){super(),this._element=document.createElement(`div`),this._element.className=`dv-watermark`}init(e){}},rJ=new class{constructor(){this._orderedList=[]}push(e){this._orderedList=[...this._orderedList.filter(t=>t!==e),e],this.update()}destroy(e){this._orderedList=this._orderedList.filter(t=>t!==e),this.update()}update(){for(let e=0;e<this._orderedList.length;e++)this._orderedList[e].setAttribute(`aria-level`,`${e}`),this._orderedList[e].style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2})`}};function iJ(e){return e.width>0&&e.height>0}var aJ=class e extends Y{set minimumInViewportWidth(e){this.options.minimumInViewportWidth=e}set minimumInViewportHeight(e){this.options.minimumInViewportHeight=e}get element(){return this._element}get isVisible(){return this._isVisible}get headerHeight(){return this.options.header?.offsetHeight??0}constructor(e){super(),this.options=e,this._element=document.createElement(`div`),this._onDidChange=new X,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new X,this.onDidChangeEnd=this._onDidChangeEnd.event,this._onDidStartMoving=new X,this.onDidStartMoving=this._onDidStartMoving.event,this._dragMove=new hW,this._dragCancelled=!1,this.addDisposables(this._onDidChange,this._onDidChangeEnd,this._onDidStartMoving,this._dragMove),this._element.className=`dv-resize-container`,this._element.setAttribute(`role`,`dialog`),this._element.setAttribute(`aria-modal`,`false`),this._isVisible=!0,this.setupResize(`top`),this.setupResize(`bottom`),this.setupResize(`left`),this.setupResize(`right`),this.setupResize(`topleft`),this.setupResize(`topright`),this.setupResize(`bottomleft`),this.setupResize(`bottomright`),this.options.header&&(Q(this._element,`dv-resize-container-with-titlebar`,!0),this._element.appendChild(this.options.header)),this._element.appendChild(this.options.content),this.options.container.appendChild(this._element),this.setBounds($($($($({height:this.options.height,width:this.options.width},`top`in this.options&&{top:this.options.top}),`bottom`in this.options&&{bottom:this.options.bottom}),`left`in this.options&&{left:this.options.left}),`right`in this.options&&{right:this.options.right})),rJ.push(this._element)}setVisible(e){e!==this.isVisible&&(this._isVisible=e,Q(this.element,`dv-hidden`,!this.isVisible))}bringToFront(){rJ.push(this._element)}setBounds(e={}){typeof e.height==`number`&&(this._element.style.height=`${e.height}px`),typeof e.width==`number`&&(this._element.style.width=`${e.width}px`),`top`in e&&typeof e.top==`number`&&(this._element.style.top=`${e.top}px`,this._element.style.bottom=`auto`,this.verticalAlignment=`top`),`bottom`in e&&typeof e.bottom==`number`&&(this._element.style.bottom=`${e.bottom}px`,this._element.style.top=`auto`,this.verticalAlignment=`bottom`),`left`in e&&typeof e.left==`number`&&(this._element.style.left=`${e.left}px`,this._element.style.right=`auto`,this.horiziontalAlignment=`left`),`right`in e&&typeof e.right==`number`&&(this._element.style.right=`${e.right}px`,this._element.style.left=`auto`,this.horiziontalAlignment=`right`);let t=this.options.container.getBoundingClientRect(),n=this._element.getBoundingClientRect();if(!iJ(t)||!iJ(n)){this._onDidChange.fire();return}let r=Math.max(0,this.getMinimumWidth(n.width)),i=Math.max(0,this.getMinimumHeight(n.height));if(this.verticalAlignment===`top`){let e=mG(n.top-t.top,-i,Math.max(0,t.height-n.height+i));this._element.style.top=`${e}px`,this._element.style.bottom=`auto`}if(this.verticalAlignment===`bottom`){let e=mG(t.bottom-n.bottom,-i,Math.max(0,t.height-n.height+i));this._element.style.bottom=`${e}px`,this._element.style.top=`auto`}if(this.horiziontalAlignment===`left`){let e=mG(n.left-t.left,-r,Math.max(0,t.width-n.width+r));this._element.style.left=`${e}px`,this._element.style.right=`auto`}if(this.horiziontalAlignment===`right`){let e=mG(t.right-n.right,-r,Math.max(0,t.width-n.width+r));this._element.style.right=`${e}px`,this._element.style.left=`auto`}this._onDidChange.fire()}toJSON(){let e=this.options.container.getBoundingClientRect(),t=this._element.getBoundingClientRect(),n={};return this.verticalAlignment===`top`?n.top=Number.parseFloat(this._element.style.top):this.verticalAlignment===`bottom`?n.bottom=Number.parseFloat(this._element.style.bottom):n.top=t.top-e.top,this.horiziontalAlignment===`left`?n.left=Number.parseFloat(this._element.style.left):this.horiziontalAlignment===`right`?n.right=Number.parseFloat(this._element.style.right):n.left=t.left-e.left,iJ(t)?(n.width=t.width,n.height=t.height):(n.width=Number.parseFloat(this._element.style.width)||0,n.height=Number.parseFloat(this._element.style.height)||0),n}cancelPendingDrag(){this._dragMove.value&&(this._dragCancelled=!0,Q(this._element,`dv-resize-container-dragging`,!1),this._dragMove.value=mW.NONE)}setupDrag(e,t){let n=(e,t)=>{var n;let r=null,i=!1;this._dragCancelled=!1;let a=this.options.transformDragPosition?(n=this.options).getSiblingBoxes?.call(n)??[]:[],o=UW();if(e&&typeof t==`number`&&typeof e.setPointerCapture==`function`)try{e.setPointerCapture(t)}catch{}let s=()=>{Q(this._element,`dv-resize-container-dragging`,!1),this._dragMove.value=mW.NONE,this._onDidChangeEnd.fire()};this._dragMove.value=new Y({dispose:()=>{if(o.release(),e&&typeof t==`number`&&typeof e.releasePointerCapture==`function`)try{e.releasePointerCapture(t)}catch{}}},Z(globalThis.window,`pointermove`,e=>{if(this._dragCancelled)return;let t=this.options.container.getBoundingClientRect(),n=e.clientX-t.left,o=e.clientY-t.top;Q(this._element,`dv-resize-container-dragging`,!0);let s=this._element.getBoundingClientRect();r??={x:e.clientX-s.left,y:e.clientY-s.top};let c=Math.max(0,this.getMinimumWidth(s.width)),l=Math.max(0,this.getMinimumHeight(s.height)),u=o-r.y,d=n-r.x;if(this.options.transformDragPosition){let n=this.options.transformDragPosition({proposed:{top:u,left:d,width:s.width,height:s.height},container:{width:t.width,height:t.height},others:a,modifiers:{altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey}});n&&(u=n.top,d=n.left)}let f=Math.max(0,t.height-s.height+l),p=Math.max(0,t.width-s.width+c),m=mG(u,-l,f),h=mG(t.height-s.height-u,-l,f),g=mG(d,-c,p),_=mG(t.width-s.width-d,-c,p),v={};m<=h?v.top=m:v.bottom=h,g<=_?v.left=g:v.right=_,this.setBounds(v),i||(i=!0,this._onDidStartMoving.fire())}),Z(globalThis.window,`pointerup`,s),Z(globalThis.window,`pointercancel`,s))};this.addDisposables(Z(e,`pointerdown`,t=>{t.defaultPrevented?t.preventDefault():MW(t)||n(e,t.pointerId)}),Z(this.options.content,`pointerdown`,e=>{e.defaultPrevented||MW(e)||e.shiftKey&&n(this.options.content,e.pointerId)}),Z(this.options.content,`pointerdown`,()=>{rJ.push(this._element)},!0)),t?.inDragMode&&n()}setupResize(t){let n=document.createElement(`div`);n.className=`dv-resize-handle-${t}`,this._element.appendChild(n);let r=new hW;this.addDisposables(r,Z(n,`pointerdown`,i=>{i.preventDefault();let a=null,o=UW(),s=i.pointerId;if(typeof n.setPointerCapture==`function`)try{n.setPointerCapture(s)}catch{}let c=()=>{r.dispose(),this._onDidChangeEnd.fire()};r.value=new Y(Z(globalThis.window,`pointermove`,n=>{let r=this.options.container.getBoundingClientRect(),i=this._element.getBoundingClientRect(),o=n.clientY-r.top,s=n.clientX-r.left;a??={originalY:o,originalHeight:i.height,originalX:s,originalWidth:i.width};let c,l,u,d,f,p,m=()=>{let t=a.originalY+a.originalHeight>r.height?Math.max(0,r.height-e.MINIMUM_HEIGHT):Math.max(0,a.originalY+a.originalHeight-e.MINIMUM_HEIGHT);c=mG(o,0,t),u=a.originalY+a.originalHeight-c,l=r.height-c-u},h=()=>{c=a.originalY-a.originalHeight;let t=c<0&&typeof this.options.minimumInViewportHeight==`number`?-c+this.options.minimumInViewportHeight:e.MINIMUM_HEIGHT,n=r.height-Math.max(0,c);u=mG(o-c,t,n),l=r.height-c-u},g=()=>{let t=a.originalX+a.originalWidth>r.width?Math.max(0,r.width-e.MINIMUM_WIDTH):Math.max(0,a.originalX+a.originalWidth-e.MINIMUM_WIDTH);d=mG(s,0,t),p=a.originalX+a.originalWidth-d,f=r.width-d-p},_=()=>{d=a.originalX-a.originalWidth;let t=d<0&&typeof this.options.minimumInViewportWidth==`number`?-d+this.options.minimumInViewportWidth:e.MINIMUM_WIDTH,n=r.width-Math.max(0,d);p=mG(s-d,t,n),f=r.width-d-p};switch(t){case`top`:m();break;case`bottom`:h();break;case`left`:g();break;case`right`:_();break;case`topleft`:m(),g();break;case`topright`:m(),_();break;case`bottomleft`:h(),g();break;case`bottomright`:h(),_()}let v={};c<=l?v.top=c:v.bottom=l,d<=f?v.left=d:v.right=f,v.height=u,v.width=p,this.setBounds(v)}),{dispose:()=>{if(o.release(),typeof n.releasePointerCapture==`function`)try{n.releasePointerCapture(s)}catch{}}},Z(globalThis.window,`pointerup`,c),Z(globalThis.window,`pointercancel`,c))}))}getMinimumWidth(e){return typeof this.options.minimumInViewportWidth==`number`?e-this.options.minimumInViewportWidth:0}getMinimumHeight(e){return typeof this.options.minimumInViewportHeight==`number`?e-this.options.minimumInViewportHeight:0}dispose(){rJ.destroy(this._element),this._element.remove(),super.dispose()}};aJ.MINIMUM_HEIGHT=20,aJ.MINIMUM_WIDTH=20;var oJ=class extends Y{get element(){return this._element}get group(){return this._group}setGroup(e){this._group=e}constructor(e,t){super(),this.accessor=e,this._onDragStart=new X,this.onDragStart=this._onDragStart.event,this._group=t,this._element=document.createElement(`div`),this._element.className=`dv-floating-titlebar`,this.addDisposables(this._onDragStart,Z(this._element,`pointerdown`,()=>{this.accessor.doSetGroupActive(this._group)}),Z(this._element,`pointerdown`,e=>{e.shiftKey&&jW(e)},!0)),this.dragSource=new oq({element:this._element,accessor:this.accessor,group:()=>this._group}),this.addDisposables(this.dragSource,this.dragSource.onDragStart(e=>{this._onDragStart.fire(e)}))}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}};function sJ(e){return{moduleName:e.name,options:e.options,services:{[e.serviceKey]:e.create},init:e.init?(t,n)=>e.init(t,n[e.serviceKey]):void 0,dependsOn:e.dependsOn}}var cJ=new Set([`AdvancedOverflow`,`AutoEdgeGroup`,`AutoHideEdgeGroup`,`DndCompass`,`KeyboardDocking`,`KeyboardNavigation`,`LayoutHistory`,`License`,`MultiRowTabs`,`PinnedTabs`,`SmartGuides`]),lJ=new Set;function uJ(e,t){let n=t===void 0?[]:[].concat(t),r=n.map(e=>`\`${e}\``).join(`, `),i=n.length>1?`require`:`requires`,a=n.length?`${r} ${i} the "${e}" module`:`The "${e}" module is required`;return cJ.has(e)?`dockview: ${a}, which ships in dockview-enterprise.\n\n npm install dockview-enterprise\n import 'dockview-enterprise'; // self-registers every enterprise module\n`:`dockview: ${a}, but it is not registered.`}function dJ(e,t){let n=`${e}|${(t===void 0?[]:[].concat(t)).join(`|`)}`;lJ.has(n)||(lJ.add(n),console.error(uJ(e,t)))}function fJ(e,t,n){if(e!==void 0)return e;dJ(t,n)}var pJ=class{constructor(){this._modules=new Map,this._services={},this._initDisposables=[]}get services(){return this._services}register(e){if(!this._modules.has(e.moduleName)){if(e.dependsOn)for(let t of e.dependsOn)this.register(t);this._modules.set(e.moduleName,e)}}initialize(e){for(let t of this._modules.values())if(t.services)for(let[n,r]of Object.entries(t.services))this._services[n]=r(e)}postConstruct(e){for(let t of this._modules.values())t.init&&this._initDisposables.push(t.init(e,this._services))}has(e){return this._modules.has(e)}dispose(){for(let e of this._initDisposables)e.dispose();this._initDisposables.length=0;for(let e of Object.values(this._services))e!==void 0&&typeof e.dispose==`function`&&e.dispose()}},mJ=[];function hJ(){return[...mJ]}var gJ=[{optionKey:`smartGuides`,reason:`smartGuides`,moduleName:`SmartGuides`,when:e=>!!e.smartGuides&&e.smartGuides.enabled!==!1},{optionKey:`layoutHistory`,reason:`layoutHistory.enabled: true`,moduleName:`LayoutHistory`,when:e=>e.layoutHistory?.enabled===!0},{optionKey:`pinnedTabs`,reason:`pinnedTabs.enabled: true`,moduleName:`PinnedTabs`,when:e=>e.pinnedTabs?.enabled===!0},{optionKey:`overflow`,reason:`overflow.mode: 'wrap'`,moduleName:`MultiRowTabs`,when:e=>e.overflow?.mode===`wrap`},{optionKey:`overflow`,reason:`overflow.maxRows`,moduleName:`MultiRowTabs`,when:e=>e.overflow?.maxRows!=null},{optionKey:`overflow`,reason:`overflow.search`,moduleName:`AdvancedOverflow`,when:e=>!!e.overflow?.search},{optionKey:`overflow`,reason:`overflow.mru`,moduleName:`AdvancedOverflow`,when:e=>!!e.overflow?.mru},{optionKey:`autoHideEdgeGroups`,reason:`autoHideEdgeGroups`,moduleName:`AutoHideEdgeGroup`,when:e=>dq(e.autoHideEdgeGroups)},{optionKey:`dockToEdgeGroups`,reason:`dockToEdgeGroups`,moduleName:`AutoEdgeGroup`,when:e=>dq(e.dockToEdgeGroups)},{optionKey:`dndCompass`,reason:`dndCompass`,moduleName:`DndCompass`,when:e=>!!e.dndCompass},{optionKey:`keyboardNavigation`,reason:`keyboardNavigation`,moduleName:`KeyboardNavigation`,when:e=>!!e.keyboardNavigation}];function _J(e,t){let n=new Map;for(let r of gJ){if(!r.when(e)||t(r.moduleName))continue;let i=n.get(r.moduleName);i?i.push(r.reason):n.set(r.moduleName,[r.reason])}for(let[e,t]of n)dJ(e,t)}var vJ={left:100,top:100,width:300,height:300},yJ=class extends Y{get group(){return this._group}setTitleBar(e){this._titleBar=e}setAnchorGroup(e){var t;this._group=e,(t=this._titleBar)==null||t.setGroup(e),this._onDidChangeAnchorGroup.fire(e)}constructor(e,t,n){super(),this.overlay=t,this.gridview=n,this._onDidChangeAnchorGroup=new X,this.onDidChangeAnchorGroup=this._onDidChangeAnchorGroup.event,this._group=e,this.addDisposables(this._onDidChangeAnchorGroup,t,{dispose:()=>this.gridview.dispose()})}position(e){this.overlay.setBounds(e)}},bJ=class{get floatingGroups(){return this._floatingGroups}constructor(e){this._floatingGroups=[],this._host=e}add(e,t,n){let r=new yJ(e,t,n),i=new Y((()=>{let e=-1,t=-1;return wW(n.element,r=>{let i=Math.round(r.contentRect.width),a=Math.round(r.contentRect.height);(i!==e||a!==t)&&(e=i,t=a,n.layout(i,a))})})()),a=e=>{let n=e.activePanel?.title;n?t.element.setAttribute(`aria-label`,n):t.element.removeAttribute(`aria-label`)},o=new hW,s=e=>{a(e),o.value=new Y(e.api.onDidActiveChange(e=>{e.isActive&&t.bringToFront()}),e.api.onDidActivePanelChange(()=>a(e)),e.onDidChange(e=>{t.setBounds({height:typeof e?.height==`number`?e.height+t.headerHeight:e?.height,width:e?.width})}))};return s(e),r.addDisposables(o,r.onDidChangeAnchorGroup(e=>s(e)),t.onDidChange(()=>{n.layout(n.width,n.height)}),t.onDidChangeEnd(()=>{this._host.fireLayoutChange(`geometry`)}),{dispose:()=>{i.dispose(),pG(this._floatingGroups,r),e.model.location={type:`grid`}}}),this._floatingGroups.push(r),r}findByGroup(e){return this._floatingGroups.find(t=>t.group===e||t.gridview.element.contains(e.element))}serialize(){return this._floatingGroups.map(e=>{let t=e.gridview.serialize(),n=e.overlay.toJSON(),r=t.root;return r.type===`branch`&&r.data.length===1&&r.data[0].type===`leaf`?{data:r.data[0].data,position:n}:{grid:t,position:n}})}constrainBounds(){for(let e of this._floatingGroups)e.overlay.setBounds()}updateBounds(e){if(`floatingGroupBounds`in e)for(let t of this._floatingGroups){switch(e.floatingGroupBounds){case`boundedWithinViewport`:t.overlay.minimumInViewportHeight=void 0,t.overlay.minimumInViewportWidth=void 0;break;case void 0:t.overlay.minimumInViewportHeight=100,t.overlay.minimumInViewportWidth=100;break;default:t.overlay.minimumInViewportHeight=e.floatingGroupBounds?.minimumHeightWithinViewport,t.overlay.minimumInViewportWidth=e.floatingGroupBounds?.minimumWidthWithinViewport}t.overlay.setBounds()}}disposeAll(){for(let e of[...this._floatingGroups])e.dispose()}dispose(){this.disposeAll()}},xJ=sJ({name:`FloatingGroup`,serviceKey:`floatingGroupService`,create:e=>new bJ(e)}),SJ=class{constructor(e){this._entries=[],this._restorationCleanups=new Set,this._restorationPromise=Promise.resolve(),this._onDidRemove=new X,this.onDidRemove=this._onDidRemove.event,this._host=e}get entries(){return this._entries}get restorationPromise(){return this._restorationPromise}add(e){this._entries.push(e)}remove(e){pG(this._entries,e)&&!this._host.isDisposed&&this._onDidRemove.fire(e)}findByGroup(e){return this._entries.find(t=>t.popoutGroup===e||t.gridview.element.contains(e.element))}findReferenceGroupId(e){return this._entries.find(t=>t.popoutGroup===e)?.referenceGroup}observeGridviewSize(e,t,n){let r=e.window?.ResizeObserver;if(!r)return;let i=-1,a=-1,o=()=>{let r=e.window;if(this._host.isDisposed||!r||r.closed)return;let o=Math.round(t.element.clientWidth),s=Math.round(t.element.clientHeight);(o!==i||s!==a)&&(i=o,a=s,o>0&&s>0&&t.layout(o,s),n.updateAllPositions())},s=new r(()=>{let t=e.window?.requestAnimationFrame;t?t.call(e.window,o):o()});return s.observe(t.element),{dispose:()=>s.disconnect()}}scheduleRestoration(e,t,n){return new Promise(r=>{let i=()=>{this._restorationCleanups.delete(i),clearTimeout(a),n?.(),r()},a=setTimeout(()=>{this._restorationCleanups.delete(i),this._host.isDisposed?r():Promise.resolve(t()).then(()=>r(),()=>r())},e);this._restorationCleanups.add(i)})}finishRestoration(e){this._restorationPromise=Promise.all(e).then(()=>void 0)}cancelPendingRestorations(){for(let e of[...this._restorationCleanups])e();this._restorationCleanups.clear()}serialize(){return this._entries.map(e=>{let t=e.gridview.serialize(),n=t.root,r=e.popoutGroup.api.location.type===`popout`?e.popoutGroup.api.location.popoutUrl:void 0,i={gridReferenceGroup:e.referenceGroup,position:e.window.dimensions(),url:r};return n.type===`branch`&&n.data.length===1&&n.data[0].type===`leaf`?$($({},i),{},{data:n.data[0].data}):$($({},i),{},{grid:t})})}disposeAll(){for(let e of[...this._entries])e.disposable.dispose()}dispose(){this.cancelPendingRestorations(),this.disposeAll(),this._onDidRemove.dispose()}},CJ=sJ({name:`PopoutWindow`,serviceKey:`popoutWindowService`,create:e=>new SJ(e)}),wJ=class{constructor(e){this._watermark=null,this._host=e}update(){if(this._host.hasVisibleGridGroup()){this._unmount();return}if(this._watermark)return;this._watermark=this._host.createWatermarkComponent(),this._watermark.init({containerApi:this._host.api});let e=document.createElement(`div`);e.className=`dv-watermark-container`,VW(e,`watermark-component`),e.appendChild(this._watermark.element),this._host.mountElement.appendChild(e)}refresh(){this._unmount(),this.update()}_unmount(){var e,t;this._watermark&&=(this._watermark.element.parentElement.remove(),(e=(t=this._watermark).dispose)==null||e.call(t),null)}dispose(){this._unmount()}},TJ=sJ({name:`Watermark`,serviceKey:`watermarkService`,create:e=>new wJ(e),init:(e,t)=>(t.update(),new Y(gW.any(e.onDidAdd,e.onDidRemove)(()=>{t.update()}),e.onDidViewVisibilityChangeMicroTaskQueue(()=>{t.update()})))}),EJ=class{constructor(){this._edgeGroups=new Map,this._edgeGroupDisposables=new Map,this._autoHide=new WeakMap,this._autoReveal=new WeakMap}add(e,t,n){this._edgeGroups.set(e,t),this._edgeGroupDisposables.set(e,n)}remove(e){var t;(t=this._edgeGroupDisposables.get(e))==null||t.dispose(),this._edgeGroupDisposables.delete(e),this._edgeGroups.delete(e)}get(e){return this._edgeGroups.get(e)}has(e){return this._edgeGroups.has(e)}hasAny(){return this._edgeGroups.size>0}entries(){return this._edgeGroups.entries()}includes(e){for(let t of this._edgeGroups.values())if(t===e)return!0;return!1}findPositionOf(e){for(let[t,n]of this._edgeGroups)if(n===e)return t}setAutoHide(e,t){t===void 0?this._autoHide.delete(e):this._autoHide.set(e,t)}isAutoHide(e){return this._autoHide.get(e)}setAutoReveal(e,t){this._autoReveal.set(e,t)}isAutoReveal(e){return this._autoReveal.get(e)??!1}disposeAll(){for(let e of this._edgeGroupDisposables.values())e.dispose();this._edgeGroupDisposables.clear(),this._edgeGroups.clear()}dispose(){this.disposeAll()}},DJ=sJ({name:`EdgeGroup`,serviceKey:`edgeGroupService`,create:()=>new EJ}),OJ={activationSize:{type:`pixels`,value:10},size:{type:`pixels`,value:20}},kJ={activationSize:{type:`pixels`,value:32},size:{type:`pixels`,value:20}};function AJ(e,t){return typeof e.dndEdges==`object`&&e.dndEdges!==null?e.dndEdges:t&&dq(e.dockToEdgeGroups)?kJ:OJ}var jJ=class{constructor(e){this._host=e;let t=(t,n)=>{let r=fW();return r?r.viewId===e.id?n!==`center`||e.isGridEmpty():!1:n===`center`&&!e.isGridEmpty()?!1:e.dispatchUnhandledDragOver(t,n)},n=AJ(e.options,!1);this._html5Target=MK.createDropTarget(e.element,{className:`dv-drop-target-edge`,canDisplayOverlay:t,acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],overlayModel:n,getOverrideTarget:()=>e.rootDropTargetOverrideTarget(),getPositionResolver:()=>e.options.dropPositionResolver}),this._pointerTarget=NK.createDropTarget(e.element,{className:`dv-drop-target-edge`,canDisplayOverlay:t,acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],overlayModel:n,getOverrideTarget:()=>e.rootDropTargetOverrideTarget(),getPositionResolver:()=>e.options.dropPositionResolver}),this.onWillShowOverlay=gW.any(this._html5Target.onWillShowOverlay,this._pointerTarget.onWillShowOverlay),this.onDrop=gW.any(this._html5Target.onDrop,this._pointerTarget.onDrop),this.setOptions(e.options)}setOptions(e){if(`dndEdges`in e){let t=typeof e.dndEdges==`boolean`&&e.dndEdges===!1;this._html5Target.disabled=t,this._pointerTarget.disabled=t}if(`dndEdges`in e||`dockToEdgeGroups`in e){let t=AJ({dndEdges:`dndEdges`in e?e.dndEdges:this._host.options.dndEdges,dockToEdgeGroups:`dockToEdgeGroups`in e?e.dockToEdgeGroups:this._host.options.dockToEdgeGroups},this._host.hasEdgeDragReveal);this._html5Target.setOverlayModel(t),this._pointerTarget.setOverlayModel(t)}}dispose(){this._html5Target.dispose(),this._pointerTarget.dispose()}},MJ=sJ({name:`RootDropTarget`,serviceKey:`rootDropTargetService`,create:e=>new jJ(e),init:(e,t)=>(t.setOptions(e.options),mW.NONE)}),NJ={left:`createLeftHeaderActionComponent`,right:`createRightHeaderActionComponent`,prefix:`createPrefixHeaderActionComponent`},PJ=class{constructor(e){this._perGroup=new Map,this._host=e}refresh(e){if(!e?.model)return;let t=this._ensureState(e);this._refreshSlot(`left`,e,t.left),this._refreshSlot(`right`,e,t.right),this._refreshSlot(`prefix`,e,t.prefix)}refreshAll(){for(let e of this._host.groups)this.refresh(e)}disposeGroup(e){let t=this._perGroup.get(e);t&&(t.left.dispose(),t.right.dispose(),t.prefix.dispose(),this._perGroup.delete(e))}dispose(){for(let e of[...this._perGroup.keys()])this.disposeGroup(e)}_ensureState(e){let t=this._perGroup.get(e);return t||(t={left:new hW,right:new hW,prefix:new hW},this._perGroup.set(e,t)),t}_refreshSlot(e,t,n){let r=this._host.options[NJ[e]];if(r){let i=r(t);n.value=i,i.init({containerApi:this._host.api,api:t.api,group:t}),t.model.attachHeaderAction(e,i.element)}else n.dispose(),t.model.attachHeaderAction(e,void 0)}},FJ=sJ({name:`HeaderActions`,serviceKey:`headerActionsService`,create:e=>new PJ(e),init:(e,t)=>new Y(e.onDidRemoveGroup(e=>{t.disposeGroup(e)}))}),IJ=e=>e===`load`||e===`clear`;function LJ(e,t){let n=e.createElement(`div`);return n.className=t===`assertive`?`dv-live-region-assertive`:`dv-live-region`,n.setAttribute(`role`,t===`assertive`?`alert`:`status`),n.setAttribute(`aria-live`,t),n.setAttribute(`aria-atomic`,`true`),Object.assign(n.style,{position:`absolute`,width:`1px`,height:`1px`,margin:`-1px`,padding:`0`,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(50%)`,whiteSpace:`nowrap`,border:`0`}),n}var RJ=class extends Y{constructor(e){super(),this._regions=new Map,this._suppressDepth=0,this._locationSubs=new Map,this._host=e;let t=e.element.ownerDocument;this._mainWindow=t.defaultView??window;let n={polite:LJ(t,`polite`),assertive:LJ(t,`assertive`)};e.element.appendChild(n.polite),e.element.appendChild(n.assertive),this._regions.set(this._mainWindow,n),this._syncPopoutRegions(),this.addDisposables({dispose:()=>this._disposeRegions()},e.onDidChangePopouts(()=>this._syncPopoutRegions()),e.onDidAddPanel(e=>this._announce(e,`open`)),e.onDidRemovePanel(e=>this._announce(e,`close`)),e.onWillMutateLayout(e=>{IJ(e.kind)&&this._suppressDepth++}),e.onDidMutateLayout(e=>{IJ(e.kind)&&(this._suppressDepth=Math.max(0,this._suppressDepth-1))}),e.onDidMaximizedGroupChange(e=>{let t=e.group.activePanel;t&&this._announce(t,e.isMaximized?`maximize`:`restore`)}),e.onDidAddGroup(e=>this._trackLocation(e)),e.onDidRemoveGroup(e=>{var t;(t=this._locationSubs.get(e.id))==null||t.dispose(),this._locationSubs.delete(e.id)}),{dispose:()=>{this._locationSubs.forEach(e=>e.dispose()),this._locationSubs.clear()}})}_syncPopoutRegions(){let e=this._host.element.ownerDocument,t=new Set([this._mainWindow]);for(let n of this._host.getPopoutWindows()){if(n.document===e||(t.add(n),this._regions.has(n)))continue;let r=n.document,i=r.body??r.documentElement,a={polite:LJ(r,`polite`),assertive:LJ(r,`assertive`)};i.appendChild(a.polite),i.appendChild(a.assertive),this._regions.set(n,a)}for(let[e,n]of this._regions)t.has(e)||(n.polite.remove(),n.assertive.remove(),this._regions.delete(e))}_disposeRegions(){for(let e of this._regions.values())e.polite.remove(),e.assertive.remove();this._regions.clear()}_focusedRegions(){for(let[e,t]of this._regions)if(e!==this._mainWindow)try{if(e.document.hasFocus())return t}catch{}return this._regions.get(this._mainWindow)}_trackLocation(e){let t=e.api.location.type,n=e.api.onDidLocationChange(n=>{let r=n.location.type;if(r===t)return;t=r;let i=e.activePanel;if(!i)return;let a;switch(r){case`floating`:a=`float`;break;case`popout`:a=`popout`;break;default:a=`dock`}this._announce(i,a)});this._locationSubs.set(e.id,n)}announce(e,t=`polite`){if(this._host.options.announcements===!1||this._suppressDepth>0||!e)return;let n=this._host.options.announcer;if(n){n({message:e,politeness:t});return}let r=this._focusedRegions(),i=t===`assertive`?r.assertive:r.polite;i.textContent=``,i.textContent=e}_announce(e,t){var n;let r=(n=this._host.options).getAnnouncement?.call(n,{kind:t,panel:e});r!==null&&r!==``&&this.announce(r??this._defaultMessage(e,t))}_defaultMessage(e,t){let n=QG(this._host.options.messages),r=e.title??e.id;switch(t){case`open`:return n.panelOpened(r);case`close`:return n.panelClosed(r);case`maximize`:return n.groupMaximized(r);case`restore`:return n.groupRestored(r);case`float`:return n.groupFloated(r);case`dock`:return n.groupDocked(r);case`popout`:return n.groupPoppedOut(r)}}},zJ=sJ({name:`LiveRegion`,serviceKey:`liveRegionService`,create:e=>new RJ(e)}),BJ=30,VJ=-10,HJ=class{constructor(e){this.host=e}dispatchWillDragPanel(e){this.host.fireWillDragPanel(e)}dispatchWillDragGroup(e){this.host.fireWillDragGroup(e)}dispatchWillDrop(e){this.host.fireWillDrop(e)}dispatchWillShowOverlay(e){this.host.fireWillShowOverlay(e)}buildGroupDragGhost(e){let t=this.host.options.createGroupDragGhostComponent;if(!t)return;let n=t(e);return n.init({group:e,api:this.host.api}),{element:n.element,offsetX:BJ,offsetY:VJ,dispose:n.dispose?()=>n.dispose?.call(n):void 0}}resolveOverlayModel(e,t){var n;return(n=this.host.options).dropOverlayModel?.call(n,{location:e,group:t})}showPreviewOverlay(e,t){let n=e.model.contentDropTarget;return n.showOverlay(t),mW.from(()=>n.clearOverlay())}dispose(){}},UJ=sJ({name:`AdvancedDnD`,serviceKey:`advancedDnDService`,create:e=>new HJ(e)}),WJ=class{constructor(e){this._host=e}attachToGroup(e){return new Y(e.model.onDidCreateTabGroup(e=>{this._host.fireDidCreateTabGroup(e)}),e.model.onDidDestroyTabGroup(e=>{this._host.fireDidDestroyTabGroup(e)}),e.model.onDidAddPanelToTabGroup(e=>{this._host.fireDidAddPanelToTabGroup(e)}),e.model.onDidRemovePanelFromTabGroup(e=>{this._host.fireDidRemovePanelFromTabGroup(e)}),e.model.onDidTabGroupChange(e=>{this._host.fireDidTabGroupChange(e)}),e.model.onDidTabGroupCollapsedChange(e=>{this._host.fireDidTabGroupCollapsedChange(e)}))}dispose(){}},GJ=sJ({name:`TabGroupChips`,serviceKey:`tabGroupChipsService`,create:e=>new WJ(e),init:(e,t)=>{let n=new Map;return new Y(e.onDidAddGroup(e=>{n.set(e,t.attachToGroup(e))}),e.onDidRemoveGroup(e=>{var t;(t=n.get(e))==null||t.dispose(),n.delete(e)}),{dispose:()=>{for(let e of n.values())e.dispose();n.clear()}})}});function KJ(e,t){var n,r;if((n=t.api)!=null&&(r=n.isPeeking)!=null&&r.call(n))return`calc(var(--dv-overlay-z-index, 999) + 100)`;if(!(e instanceof HTMLElement))return;let i=QW(e);return i?.style.zIndex?`calc(${i.style.zIndex} * 2)`:void 0}var qJ=0,JJ=()=>`dv-ctx-menu-item-${qJ++}`;function YJ(e){return typeof e==`object`}function XJ(e,t,n,r){let i=document.createElement(`div`);return i.className=`dv-context-menu-item`,i.setAttribute(`role`,`menuitem`),r&&(i.classList.add(`dv-context-menu-item--disabled`),i.setAttribute(`aria-disabled`,`true`)),i.textContent=e,r||i.addEventListener(`click`,()=>{n(),t()}),i}function ZJ(){let e=document.createElement(`div`);return e.className=`dv-context-menu-separator`,e.setAttribute(`role`,`separator`),e}function QJ(){if(globalThis.window===void 0||!globalThis.matchMedia)return!1;let e=globalThis.matchMedia(`(pointer: coarse)`).matches,t=globalThis.matchMedia(`(pointer: fine)`).matches;return e&&!t}function $J(e){let t=document.createElement(`div`);t.className=`dv-context-menu-rename`;let n=document.createElement(`input`);return n.className=`dv-context-menu-rename-input`,n.type=`text`,n.placeholder=`Name This Group`,n.value=e.label,n.addEventListener(`input`,()=>{e.setLabel(n.value)}),n.addEventListener(`keydown`,e=>{e.key!==`Escape`&&e.key!==`Enter`&&e.stopPropagation()}),n.addEventListener(`click`,e=>{e.stopPropagation()}),t.appendChild(n),QJ()||requestAnimationFrame(()=>{n.focus(),n.select()}),t}function eY(e,t){let n=document.createElement(`div`);if(n.className=`dv-context-menu-color-picker`,!t.enabled)return n;for(let r of t.entries()){let t=document.createElement(`div`);t.className=`dv-context-menu-color-swatch`,t.style.setProperty(`--dv-tab-group-color`,r.value),r.label&&(t.title=r.label),e.color===r.id&&t.classList.add(`dv-context-menu-color-swatch--selected`),t.addEventListener(`click`,()=>{e.setColor(r.id)}),n.appendChild(t)}return n}var tY=class{constructor(e){this.accessor=e}buildMaximizeItem(e,t){let n=e.api.isMaximized();return XJ(n?`Restore`:`Maximize`,t,n?()=>e.api.exitMaximized():()=>e.api.maximize(),!n&&e.api.location.type!==`grid`)}buildCollapseItem(e,t){return XJ(e.collapsed?`Expand`:`Collapse`,t,()=>e.toggle())}_shouldInjectPin(){let e=this.accessor.options.pinnedTabs;return!!this.accessor.pinnedTabsService&&!!e?.enabled&&e.contextMenuItem!==!1}_resolveTabItems(e,t,n){var r;let i=(r=this.accessor.options).getTabContextMenuItems?.call(r,{panel:e,group:t,api:this.accessor.api,event:n})??[];return this._shouldInjectPin()?[`pin`,...i]:i}appendComponentItem(e,t,n,r,i,a){var o;let s=(o=this.accessor.options).createContextMenuItemComponent?.call(o,{id:JJ(),component:t.component});s&&(a.addDisposables(s),s.init($($({},n),{},{group:r,api:this.accessor.api,close:i,componentProps:t.componentProps})),e.appendChild(s.element))}buildBuiltInTabItem(e,t,n,r){switch(e){case`separator`:return ZJ();case`close`:return XJ(`Close`,r,()=>t.api.close());case`closeOthers`:return XJ(`Close Others`,r,()=>{n.panels.filter(e=>e!==t).forEach(e=>e.api.close())});case`closeAll`:return XJ(`Close All`,r,()=>{[...n.panels].forEach(e=>e.api.close())});case`closeLeft`:{let e=n.panels.indexOf(t);return XJ(`Close to the Left`,r,()=>{n.panels.filter((t,n)=>n<e).forEach(e=>e.api.close())},e<=0)}case`closeRight`:{let e=n.panels.indexOf(t);return XJ(`Close to the Right`,r,()=>{n.panels.filter((t,n)=>n>e).forEach(e=>e.api.close())},e===-1||e>=n.panels.length-1)}case`maximize`:return this.buildMaximizeItem(t,r);case`float`:return XJ(`Float`,r,()=>this.accessor.api.addFloatingGroup(t),t.api.location.type===`floating`);case`popout`:return XJ(`Open in New Window`,r,()=>{this.accessor.api.addPopoutGroup(t)},t.api.location.type===`popout`);case`pin`:return XJ(t.api.isPinned?`Unpin tab`:`Pin tab`,r,()=>t.api.setPinned(!t.api.isPinned));default:return}}appendConfigItem(e,t,n,r,i,a){t.element?e.appendChild(t.element):t.component?this.appendComponentItem(e,t,n,r,i,a):t.label&&e.appendChild(XJ(t.label,i,()=>t.action?.call(t),t.disabled))}show(e,t,n){let r=this._resolveTabItems(e,t,n);if(r.length===0)return;n.preventDefault();let i=this.accessor.getPopupServiceForGroup(t),a=()=>i.close(),o=new Y,s=document.createElement(`div`);s.className=`dv-context-menu`,s.setAttribute(`role`,`menu`);try{for(let n of r){if(YJ(n)){this.appendConfigItem(s,n,{panel:e},t,a,o);continue}let r=this.buildBuiltInTabItem(n,e,t,a);r&&s.appendChild(r)}}catch(e){throw o.dispose(),e}i.openPopover(s,{x:n.clientX,y:n.clientY,zIndex:KJ(n.target,t)},{onClose:()=>o.dispose()})}showForChip(e,t,n){if(!this.accessor.options.getTabGroupChipContextMenuItems)return;let r=this.accessor.options.getTabGroupChipContextMenuItems({tabGroup:e,group:t,api:this.accessor.api,event:n});if(r.length===0)return;n.preventDefault();let i=this.accessor.getPopupServiceForGroup(t),a=()=>i.close(),o=new Y,s=document.createElement(`div`);s.className=`dv-context-menu`,s.setAttribute(`role`,`menu`);try{for(let n of r)n===`separator`?s.appendChild(ZJ()):n===`rename`?s.appendChild($J(e)):n===`colorPicker`?s.appendChild(eY(e,this.accessor.tabGroupColorPalette)):n===`collapse`?s.appendChild(this.buildCollapseItem(e,a)):n===`close`?s.appendChild(XJ(`Close All`,a,()=>{t.panels.filter(t=>e.containsPanel(t.id)).forEach(e=>e.api.close())})):YJ(n)&&this.appendConfigItem(s,n,{tabGroup:e},t,a,o)}catch(e){throw o.dispose(),e}i.openPopover(s,{x:n.clientX,y:n.clientY,zIndex:KJ(n.target,t)},{onClose:()=>o.dispose()})}},nY=[xJ,CJ,TJ,DJ,MJ,FJ,zJ,UJ,GJ,sJ({name:`ContextMenu`,serviceKey:`contextMenuService`,create:e=>new tY(e)})],rY=class{constructor(){this.cache=new WeakMap,this.currentFrameId=0,this.rafId=null}getPosition(e){let t=this.cache.get(e);if(t?.frameId===this.currentFrameId)return t.rect;this.scheduleFrameUpdate();let n=LW(e);return this.cache.set(e,{rect:n,frameId:this.currentFrameId}),n}invalidate(){this.currentFrameId++}scheduleFrameUpdate(){this.rafId||=requestAnimationFrame(()=>{this.currentFrameId++,this.rafId=null})}},iY=-1;function aY(e){let t=e.group.api;return t.location.type===`edge`&&t.isCollapsed()}function oY(){let e=document.createElement(`div`);return e.tabIndex=-1,e}function sY(e,t,n){let r=`${n}px`;e[t]!==r&&(e[t]=r)}var cY=class extends Y{constructor(e,t){super(),this.element=e,this.accessor=t,this.map={},this._disposed=!1,this._generation=0,this.positionCache=new rY,this.addDisposables(mW.from(()=>{for(let e of Object.values(this.map))e.disposable.dispose(),e.destroy.dispose(),this.cancelPendingUpdate(e);this._disposed=!0}))}updateAllPositions(){if(!this._disposed){this.positionCache.invalidate();for(let e of Object.values(this.map))e.panel.api.isVisible&&e.resize&&e.resize()}}repositionPanelOverlay(e,t=!1,n){var r;if(this._disposed)return;let i=this.map[e];i&&(i.forceVisible=t,i.clip=n,this.positionCache.invalidate(),(r=i.resize)==null||r.call(i))}cancelPendingUpdate(e){e.pendingUpdate!==void 0&&(cancelAnimationFrame(e.pendingUpdate),e.pendingUpdate=void 0)}detatch(e){if(this.map[e.api.id]){let t=this.map[e.api.id];return t.disposable.dispose(),t.destroy.dispose(),this.cancelPendingUpdate(t),delete this.map[e.api.id],!0}return!1}attach(e){var t;let{panel:n,referenceContainer:r}=e;if(!this.map[n.api.id]){let e=oY();e.className=`dv-render-overlay`,e.style.visibility=`hidden`,this.map[n.api.id]={panel:n,disposable:mW.NONE,destroy:mW.NONE,element:e,retainPreviousGeometry:!1,positioned:!1,generation:++this._generation}}let i=this.map[n.api.id];if(i.referenceContainer!==r){i.generation=++this._generation,this.cancelPendingUpdate(i),i.referenceContainer=r;let e=aY(n);i.retainPreviousGeometry=i.positioned&&!e,e&&!i.forceVisible&&(i.element.style.visibility=`hidden`,i.element.style.pointerEvents=`none`)}let a=i.generation,o=i.element,s=n.view.content.element,c=e=>{if(!e||e.width<=0||e.height<=0)return;let t=this.map[n.api.id];!t||t.forceVisible||t.positioned&&n.api.isVisible||(sY(o.style,`width`,e.width),sY(o.style,`height`,e.height))};c(r.dimensions),s.parentElement!==o&&o.appendChild(s),o.parentElement!==this.element&&this.element.appendChild(o);let l=()=>{let e=n.api.id,t=this.map[e];if(t?.generation!==a||t.pendingUpdate!==void 0)return;t.pendingUpdate=iY;let i=requestAnimationFrame(()=>{let t=this.map[e];if(t&&(t.pendingUpdate=void 0),this.isDisposed||t?.generation!==a)return;let i=t.forceVisible??!1,s=t.clip,c=aY(n),l=!i&&(!n.api.isVisible||c),u=this.positionCache.getPosition(r.element),d=this.positionCache.getPosition(this.element),f=u.left-d.left,p=u.top-d.top,m=u.width,h=u.height;if(m===0||h===0){if(c&&!i){t.retainPreviousGeometry=!1,o.style.visibility=`hidden`,o.style.pointerEvents=`none`,o.style.clipPath=``,o.style.zIndex=``;return}if(t.retainPreviousGeometry){l&&(o.style.visibility=`hidden`,o.style.pointerEvents=`none`);return}}if(t.retainPreviousGeometry=!1,t.positioned=!0,sY(o.style,`left`,f),sY(o.style,`top`,p),sY(o.style,`width`,m),sY(o.style,`height`,h),l?(o.style.visibility=`hidden`,o.style.pointerEvents=`none`):(o.style.visibility=``,o.style.pointerEvents=``),i?o.style.zIndex=`1000`:n.api.location.type!==`floating`&&(o.style.zIndex=``),s){let e=this.element.ownerDocument.defaultView,t=e?.scrollX??0,n=e?.scrollY??0,r=s.top+n,i=s.left+t,a=Math.max(0,r-u.top),c=Math.max(0,i-u.left),l=Math.max(0,u.left+m-(s.right+t)),d=Math.max(0,u.top+h-(s.bottom+n));o.style.clipPath=`inset(${a}px ${l}px ${d}px ${c}px)`}else o.style.clipPath=``;Q(o,`dv-render-overlay-float`,n.group.api.location.type===`floating`)});t.pendingUpdate===iY&&(t.pendingUpdate=i)},u=()=>{let e=!this.map[n.api.id]?.forceVisible&&aY(n);n.api.isVisible&&!e?(this.positionCache.invalidate(),l(),this.map[n.api.id]?.retainPreviousGeometry&&(o.style.visibility=``),o.style.pointerEvents=``):(o.style.visibility=`hidden`,o.style.pointerEvents=`none`)},d=new hW,f=()=>{n.api.location.type===`floating`?queueMicrotask(()=>{if(p.isDisposed)return;let e=this.accessor.getFloatingWindowForGroup(n.api.group);if(!e)return;let t=e.overlay.element,r=()=>{let e=Number(t.getAttribute(`aria-level`));o.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2+1})`},i=new MutationObserver(()=>{r()});d.value=mW.from(()=>i.disconnect()),i.observe(t,{attributeFilter:[`aria-level`],attributes:!0}),r()}):o.style.zIndex=``},p=new Y(d,new rK(o,{onDragEnd:e=>{r.dropTarget.dnd.onDragEnd(e)},onDragEnter:e=>{r.dropTarget.dnd.onDragEnter(e)},onDragLeave:e=>{r.dropTarget.dnd.onDragLeave(e)},onDrop:e=>{r.dropTarget.dnd.onDrop(e)},onDragOver:e=>{r.dropTarget.dnd.onDragOver(e)}}),n.api.onDidVisibilityChange(()=>{u()}),n.api.onDidDimensionsChange(()=>{n.api.isVisible&&l()}),(t=n.group.api).onDidCollapsedChange?.call(t,()=>{this.positionCache.invalidate(),l()})??mW.NONE,r.onDidDimensionsChange(e=>{c(e)}),n.api.onDidLocationChange(()=>{f()}));return this.map[n.api.id].destroy=mW.from(()=>{s.parentElement===o&&s.remove(),o.remove()}),f(),queueMicrotask(()=>{this.isDisposed||u()}),this.map[n.api.id].disposable.dispose(),this.map[n.api.id].disposable=p,this.map[n.api.id].resize=l,o}},lY=class extends Y{constructor(e){super(),this.accessor=e,this.init()}init(){let e=new Set,t=new Set;this.addDisposables(this.accessor.onDidAddPanel(t=>{if(e.has(t.api.id))throw Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${t.api.id} but panel already exists`);e.add(t.api.id)}),this.accessor.onDidRemovePanel(t=>{if(e.has(t.api.id))e.delete(t.api.id);else throw Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${t.api.id} but panel does not exists`)}),this.accessor.onDidAddGroup(e=>{if(t.has(e.api.id))throw Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${e.api.id} but group already exists`);t.add(e.api.id)}),this.accessor.onDidRemoveGroup(e=>{if(t.has(e.api.id))t.delete(e.api.id);else throw Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${e.api.id} but group does not exists`)}))}};function uY(e){if(!e.matchMedia)return!1;let t=e.matchMedia(`(pointer: coarse)`).matches,n=e.matchMedia(`(pointer: fine)`).matches;return t&&!n}function dY(e){let t=e.window??window,n=e.capture??!1,r=e.escape??!0,i=e.keys??[],a=e.outsidePointerDown??!0,o=e.pointerDownGraceMs??0,s=e.now??Date.now,c=s(),l=new Y,u=t=>e.isInside?e.isInside(t):NW(t,e.elements?.call(e)??[]);if((r||i.length>0)&&l.addDisposables(Z(t,`keydown`,t=>{(r&&t.key===`Escape`||i.includes(t.key))&&e.onDismiss()},n)),(a||e.onInsidePointerDown)&&l.addDisposables(Z(t,`pointerdown`,t=>{if(u(t)){var n;(n=e.onInsidePointerDown)==null||n.call(e,t)}else!a||s()-c<o||e.onDismiss()},n)),e.resize&&l.addDisposables(Z(t,`resize`,()=>{uY(t)||e.onDismiss()})),e.focusOut){let r=()=>e.anchor?.call(e)??e.elements?.call(e)[0],i=new WeakSet,a=t=>{if(i.has(t))return;i.add(t);let n=t.target;n instanceof Element&&((e.isFocusInside?e.isFocusInside(FW(n,r())):NW(t,e.elements?.call(e)??[]))||e.onDismiss())},o=new Map,s=()=>{let t=new Set,r=e.anchor?.call(e),i=[...e.elements?.call(e)??[],...r?[r]:[]];for(let e of i)for(let n of PW(e))t.add(n);for(let[e,n]of o)t.has(e)||(n.dispose(),o.delete(e));for(let e of t)o.has(e)||o.set(e,Z(e,`focusin`,a,n))};l.addDisposables(Z(t,`focusin`,e=>{s(),a(e)},n),{dispose:()=>{for(let[,e]of o)e.dispose();o.clear()}}),s()}return l}var fY=class extends Y{constructor(e,t=globalThis.window){super(),this._active=null,this._activeDisposable=new hW,this._root=e,this._window=t,this._element=t.document.createElement(`div`),this._element.className=`dv-popover-anchor`,this._element.style.position=`relative`,this._root.prepend(this._element),this.addDisposables(mW.from(()=>{this.close()}),this._activeDisposable)}updateRoot(e){e.prepend(this._element),this._root=e}openPopover(e,t,n){this.close();let r=this._window.document.createElement(`div`);r.style.position=`absolute`,r.style.zIndex=t.zIndex??`var(--dv-overlay-z-index)`,r.appendChild(e);let i=this._element.getBoundingClientRect(),a=i.left,o=i.top;r.style.top=`${t.y-o}px`,r.style.left=`${t.x-a}px`,this._element.appendChild(r),this._active=r,this._activeDisposable.value=new Y(dY({window:this._window,onDismiss:()=>this.close(),elements:()=>this._active?[this._active]:[],keys:[`Enter`],pointerDownGraceMs:200,resize:!0}),n?.onClose?mW.from(n.onClose):mW.NONE),this._window.requestAnimationFrame(()=>{ZW(r,this._root)})}close(){this._active&&=(this._active.remove(),this._activeDisposable.dispose(),null)}},pY=class extends Y{get renderedOutline(){return this._model?this._outline:void 0}get disabled(){return this._disabled}set disabled(e){this.disabled!==e&&(this._disabled=e,e&&this._clearNow())}_cancelPendingClear(){this._pendingClear!==void 0&&(clearTimeout(this._pendingClear),this._pendingClear=void 0)}_clearNow(){this._cancelPendingClear(),this._model&&this._model.root.remove(),this._model=void 0}get model(){if(!this.disabled)return{clear:()=>{this._clearNow()},scheduleClear:()=>{this._pendingClear===void 0&&this._model&&(this._pendingClear=setTimeout(()=>{this._pendingClear=void 0,this._clearNow()},0))},exists:()=>!!this._model,getElements:(e,t)=>{this._cancelPendingClear();let n=this._outline!==t;if(this._outline=t,this._model)return this._model.changed=n,this._model;let r=this.createContainer(),i=this.createAnchor();if(this._model={root:r,overlay:i,changed:n},r.appendChild(i),this.element.appendChild(r),e?.target instanceof HTMLElement){let t=e.target.getBoundingClientRect(),n=this.element.getBoundingClientRect();i.style.left=`${t.left-n.left}px`,i.style.top=`${t.top-n.top}px`}return this._model}}}constructor(e,t){super(),this.element=e,this._disabled=!1,this._disabled=t.disabled,this.addDisposables(mW.from(()=>{var e;(e=this.model)==null||e.clear()}))}createContainer(){let e=document.createElement(`div`);return e.className=`dv-drop-target-container`,e}createAnchor(){let e=document.createElement(`div`);return e.className=`dv-drop-target-anchor`,e.style.visibility=`hidden`,e}},mY=[`left`,`right`,`top`,`bottom`];function hY(e){return e===`left`||e===`right`}var gY={marginShare:0,size:1/0},_Y=class{get _effectiveBaseCollapsed(){return this._measuredTabSize??this._baseCollapsedSize}get minimumSize(){return this._isCollapsed?this.collapsedSize:this._baseMinimumSize===void 0?this._effectiveBaseCollapsed+50+this._axis.marginShare:this._baseMinimumSize+this._axis.marginShare}get maximumSize(){return this._isCollapsed?this.collapsedSize:this._expandedMaximumSize}get element(){return this._group.element}get isCollapsed(){return this._isCollapsed}get lastExpandedSize(){return this._lastExpandedSize}get lastExpandedContentSize(){return this._lastExpandedSize-this._axis.marginShare}get collapsedSize(){return this._effectiveBaseCollapsed+this._axis.marginShare}get configuredMinimumSize(){return this._baseMinimumSize}get configuredMaximumSize(){return this._expandedMaximumSize}get configuredCollapsedSize(){return this._baseCollapsedSize}constructor(e,t,n,r=gY){this._onDidChange=new X,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority=`low`,this._isCollapsed=!1,this._isVisible=!0,this._tabSizeDisposables=new Y,this._group=t,this._orientation=n,t.element.classList.add(`dv-edge-group`),t.element.dataset.testid=`dv-edge-group-${e.id}`,this._baseCollapsedSize=e.collapsedSize??35,this._baseMinimumSize=e.minimumSize,this._axis=r,this._expandedMaximumSize=e.maximumSize??1/0,this._lastExpandedSize=e.initialSize??200,e.collapsed&&(this._isCollapsed=!0,t.element.classList.add(`dv-edge-collapsed`)),this._observeTabStrip()}_observeTabStrip(){let e=this._group.element.querySelector(`.dv-tabs-and-actions-container`);e&&this._tabSizeDisposables.addDisposables(wW(e,()=>{let{headerPosition:t}=this._group;(t===`left`||t===`right`)==(this._orientation===`horizontal`)&&this._applyMeasuredTabSize(this._orientation===`vertical`?e.offsetHeight:e.offsetWidth)}))}_applyMeasuredTabSize(e){e<=0||e===this._measuredTabSize||(this._measuredTabSize=e,this._isCollapsed&&this._onDidChange.fire({size:this.collapsedSize}))}layout(e,t){!this._isCollapsed&&this._isVisible&&this._axis.size>0&&(this._lastExpandedSize=e+this._axis.marginShare),this._orientation===`horizontal`?this._group.layout(e,t):this._group.layout(t,e)}setCollapsed(e){this._isCollapsed!==e&&(this._isCollapsed=e,this._group.element.classList.toggle(`dv-edge-collapsed`,e))}setVisible(e){this._isVisible=e}restoreExpandedSize(e){this._lastExpandedSize=e}updateSizing(e,t){this._baseCollapsedSize=e,this._baseMinimumSize=t}dispose(){this._tabSizeDisposables.dispose(),this._onDidChange.dispose()}},vY=class{get element(){return this._dockviewElement}constructor(e,t){this._dockviewElement=e,this._layoutDockview=t,this.priority=`high`,this.minimumSize=100,this.maximumSize=1/0,this._onDidChange=new X,this.onDidChange=this._onDidChange.event}layout(e,t){this._layoutDockview(t,e)}setVisible(e){}dispose(){this._onDidChange.dispose()}},yY=class{get element(){return this._element}constructor(e,t=0){this._onDidChange=new X,this.onDidChange=this._onDidChange.event,this.minimumSize=100,this.maximumSize=1/0,this.priority=`high`,this._element=document.createElement(`div`),this._element.className=`dv-shell-middle-column`,this._element.style.height=`100%`,this._element.style.width=`100%`,this._splitview=new xG(this._element,{orientation:`VERTICAL`,proportionalLayout:!1,margin:t}),this._centerIndex=0,this._splitview.addView(e,{type:`distribute`},0)}addTopView(e,t){this._splitview.addView(e,t,0),this._topIndex=0,this._centerIndex+=1,this._bottomIndex!==void 0&&(this._bottomIndex+=1)}addBottomView(e,t){let n=this._splitview.length;this._splitview.addView(e,t,n),this._bottomIndex=n}removeView(e){let t=e===`top`?this._topIndex:this._bottomIndex;t!==void 0&&(this._splitview.removeView(t),e===`top`?(this._topIndex=void 0,--this._centerIndex,this._bottomIndex!==void 0&&--this._bottomIndex):this._bottomIndex=void 0)}layout(e,t){this._splitview.layout(t,e)}setVisible(e){}setViewVisible(e,t){let n=e===`top`?this._topIndex:this._bottomIndex;n!==void 0&&this._splitview.setViewVisible(n,t)}isViewVisible(e){let t=e===`top`?this._topIndex:this._bottomIndex;return t!==void 0&&this._splitview.isViewVisible(t)}getViewSize(e){let t=e===`top`?this._topIndex:this._bottomIndex;return t===void 0?0:this._splitview.getViewSize(t)}getViewCachedVisibleSize(e){let t=e===`top`?this._topIndex:this._bottomIndex;if(t!==void 0)return this._splitview.getViewCachedVisibleSize(t)}resizeView(e,t){let n=e===`top`?this._topIndex:this._bottomIndex;n!==void 0&&this._splitview.resizeView(n,t)}get axis(){return this._splitview}updateMargin(e){this._splitview.margin=e}get disabled(){return this._splitview.disabled}set disabled(e){this._splitview.disabled=e}dispose(){this._onDidChange.dispose(),this._splitview.dispose()}},bY=class{constructor(e,t,n,r=0,i=35){this._disposables=new Y,this._viewConfigs=new Map,this._pendingSizes=new Map,this._currentWidth=0,this._currentHeight=0,this._gap=r,this._defaultCollapsedSize=i,this._shellElement=document.createElement(`div`),this._shellElement.className=`dv-shell`,this._shellElement.style.height=`100%`,this._shellElement.style.width=`100%`,this._shellElement.style.position=`relative`,e.appendChild(this._shellElement);let a=new vY(t,n);this._middleColumn=new yY(a,r),this._outerSplitview=new xG(this._shellElement,{orientation:`HORIZONTAL`,proportionalLayout:!1,margin:r}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:`distribute`},0),this._disposables.addDisposables(wW(this._shellElement,e=>{if(!this._shellElement.offsetParent||!RW(this._shellElement))return;let t=Math.round(e.contentRect.width),n=Math.round(e.contentRect.height);(t!==this._currentWidth||n!==this._currentHeight)&&this.layout(t,n)}),this._outerSplitview,this._middleColumn,a)}get element(){return this._shellElement}get locked(){return this._outerSplitview.disabled}set locked(e){this._outerSplitview.disabled=e,this._middleColumn.disabled=e}addEdgeView(e,t,n){if(this.hasEdgeGroup(e))throw Error(`dockview: edge group already registered at position '${e}'`);this._viewConfigs.set(e,t);let r=new _Y($($({},t),{},{collapsedSize:t.collapsedSize??this._defaultCollapsedSize}),n,hY(e)?`horizontal`:`vertical`,this._axisFor(e)),i=r.isCollapsed?r.collapsedSize:r.lastExpandedSize;switch(e){case`left`:this._outerSplitview.addView(r,i,0),this._leftIndex=0,this._middleIndex+=1,this._rightIndex!==void 0&&(this._rightIndex+=1),this._leftView=r;break;case`right`:{let e=this._outerSplitview.length;this._outerSplitview.addView(r,i,e),this._rightIndex=e,this._rightView=r}break;case`top`:this._middleColumn.addTopView(r,i),this._topView=r;break;case`bottom`:this._middleColumn.addBottomView(r,i),this._bottomView=r}return this._disposables.addDisposables(r),!r.isCollapsed&&!this._canResize(e)&&this._pendingSizes.set(e,i),this._relayout(),r}layoutFromElement(){if(!this._shellElement.offsetParent||!RW(this._shellElement))return;let e=Math.round(this._shellElement.clientWidth),t=Math.round(this._shellElement.clientHeight);e!==0&&t!==0&&this.layout(e,t)}layout(e,t){this._currentWidth=e,this._currentHeight=t,this._outerSplitview.layout(e,t),this._flushPendingSizes()}updateTheme(e,t){this._gap=e,this._defaultCollapsedSize=t,this._outerSplitview.margin=e,this._middleColumn.updateMargin(e),this._applyThemeSizing(),this._relayout()}_hasSiblingOn(e){return hY(e)?this._leftView!==void 0&&this._rightView!==void 0:this._topView!==void 0&&this._bottomView!==void 0}_axisFor(e){return hY(e)?this._outerSplitview:this._middleColumn.axis}_applyThemeSizing(){for(let e of mY){let t=this._getView(e),n=this._viewConfigs.get(e);t&&n&&t.updateSizing(n.collapsedSize??this._defaultCollapsedSize,n.minimumSize)}}_relayout(){this._currentWidth>0&&this._currentHeight>0&&this.layout(this._currentWidth,this._currentHeight)}_slotSize(e){switch(e){case`left`:return this._leftIndex===void 0?0:this._outerSplitview.getViewSize(this._leftIndex);case`right`:return this._rightIndex===void 0?0:this._outerSplitview.getViewSize(this._rightIndex);case`top`:case`bottom`:return this._middleColumn.getViewSize(e)}}removeEdgeView(e){let t=this._getView(e);if(t){switch(e){case`left`:this._outerSplitview.removeView(this._leftIndex),this._leftIndex=void 0,this._leftView=void 0,--this._middleIndex,this._rightIndex!==void 0&&--this._rightIndex;break;case`right`:this._outerSplitview.removeView(this._rightIndex),this._rightIndex=void 0,this._rightView=void 0;break;case`top`:this._middleColumn.removeView(`top`),this._topView=void 0;break;case`bottom`:this._middleColumn.removeView(`bottom`),this._bottomView=void 0}this._disposables.removeDisposable(t),t.dispose(),this._viewConfigs.delete(e),this._pendingSizes.delete(e),this._relayout()}}hasEdgeGroup(e){switch(e){case`top`:return this._topView!==void 0;case`bottom`:return this._bottomView!==void 0;case`left`:return this._leftView!==void 0;case`right`:return this._rightView!==void 0}}setEdgeGroupVisible(e,t){let n=this._getView(e)!==void 0&&t!==this.isEdgeGroupVisible(e);switch(e){case`left`:this._leftIndex!==void 0&&this._outerSplitview.setViewVisible(this._leftIndex,t);break;case`right`:this._rightIndex!==void 0&&this._outerSplitview.setViewVisible(this._rightIndex,t);break;case`top`:case`bottom`:this._middleColumn.setViewVisible(e,t)}n&&this._gap>0&&this._hasSiblingOn(e)&&this._relayout(),t&&this._flushPendingSizes()}isEdgeGroupVisible(e){switch(e){case`left`:return this._leftIndex!==void 0&&this._outerSplitview.isViewVisible(this._leftIndex);case`right`:return this._rightIndex!==void 0&&this._outerSplitview.isViewVisible(this._rightIndex);case`top`:case`bottom`:return this._middleColumn.isViewVisible(e)}}setEdgeGroupCollapsed(e,t){let n=this._getView(e);n&&(n.setCollapsed(t),t?(this._pendingSizes.delete(e),this._resizeView(e,n.collapsedSize)):this.resizeEdgeGroup(e,n.lastExpandedSize))}resizeEdgeGroup(e,t){let n=this._getView(e);if(!n||!Number.isFinite(t))return;let r=Math.round(t);r<=0||(n.restoreExpandedSize(r),n.isCollapsed?this._pendingSizes.delete(e):this._canResize(e)?(this._pendingSizes.delete(e),this._resizeView(e,r)):this._pendingSizes.set(e,r))}_canResize(e){return this.isEdgeGroupVisible(e)&&this._axisFor(e).size>0}_resizeView(e,t){switch(e){case`left`:this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,t);break;case`right`:this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,t);break;case`top`:case`bottom`:this._middleColumn.resizeView(e,t)}}_flushPendingSizes(){if(this._pendingSizes.size!==0)for(let[e,t]of this._pendingSizes){let n=this._getView(e);n&&!n.isCollapsed&&this._canResize(e)&&(this._pendingSizes.delete(e),this._resizeView(e,t))}}isEdgeGroupCollapsed(e){return this._getView(e)?.isCollapsed??!1}getEdgeGroupExpandedSize(e){return this._getView(e)?.lastExpandedContentSize??0}_getView(e){switch(e){case`top`:return this._topView;case`bottom`:return this._bottomView;case`left`:return this._leftView;case`right`:return this._rightView}}toJSON(){let e={};for(let t of mY){let n=this._getView(t);if(!n)continue;let r=this.isEdgeGroupVisible(t);e[t]={size:this._expandedSize(n,t,r),visible:r,collapsed:n.isCollapsed||void 0,minimumSize:n.configuredMinimumSize,maximumSize:Number.isFinite(n.configuredMaximumSize)?n.configuredMaximumSize:void 0,collapsedSize:n.configuredCollapsedSize}}return e}_expandedSize(e,t,n){if(e.isCollapsed)return e.lastExpandedSize;let r=this._pendingSizes.get(t);return r===void 0?n?this._slotSize(t):this._cachedVisibleSize(t)??e.lastExpandedSize:r}_cachedVisibleSize(e){switch(e){case`left`:return this._leftIndex===void 0?void 0:this._outerSplitview.getViewCachedVisibleSize(this._leftIndex);case`right`:return this._rightIndex===void 0?void 0:this._outerSplitview.getViewCachedVisibleSize(this._rightIndex);case`top`:case`bottom`:return this._middleColumn.getViewCachedVisibleSize(e)}}fromJSON(e){for(let t of mY){let n=e[t],r=this._getView(t);n&&r&&(r.restoreExpandedSize(n.size),r.setCollapsed(n.collapsed??!1),n.collapsed?(this._pendingSizes.delete(t),this._resizeView(t,r.collapsedSize)):this.resizeEdgeGroup(t,n.size),this.setEdgeGroupVisible(t,!!n.visible))}}dispose(){this._disposables.dispose(),this._shellElement.remove()}};function xY(e){e.error?console.error(`dockview: failed to create popout.`,e.error):e.reason===`blocked`?console.error(`dockview: failed to create popout. perhaps you need to allow pop-ups for this website`):console.error(`dockview: failed to create popout (${e.reason}).`)}function SY(e){return new yq(e.tabGroupColors??vq,e.tabGroupAccent!==`off`)}function CY(e){let t=e.from.activePanel;[...e.from.panels].map(t=>{let n=e.from.model.removePanel(t);return e.from.model.renderContainer.detatch(t),n}).forEach(n=>{e.to.model.openPanel(n,{skipSetActive:t!==n,skipSetGroupActive:!0})})}var wY=()=>({dispose:()=>{}}),TY=wY,EY=100,DY=class extends UG{fireDidCreateTabGroup(e){this._onDidCreateTabGroup.fire(e)}fireDidDestroyTabGroup(e){this._onDidDestroyTabGroup.fire(e)}fireDidAddPanelToTabGroup(e){this._onDidAddPanelToTabGroup.fire(e)}fireDidRemovePanelFromTabGroup(e){this._onDidRemovePanelFromTabGroup.fire(e)}fireDidTabGroupChange(e){this._onDidTabGroupChange.fire(e)}fireDidTabGroupCollapsedChange(e){this._onDidTabGroupCollapsedChange.fire(e)}get orientation(){return this.gridview.orientation}get totalPanels(){return this.panels.length}get panels(){return this.groups.flatMap(e=>e.panels)}get dndCapabilities(){return eq(this.options)}get options(){return this._options}get tabGroupColorPalette(){return this._tabGroupColorPalette}get activePanel(){let e=this.activeGroup;if(e)return e.activePanel}get renderer(){return this.options.defaultRenderer??`onlyWhenVisible`}get defaultHeaderPosition(){return this.options.defaultHeaderPosition??`top`}get api(){return this._api}get floatingGroups(){var e;return((e=this._moduleRegistry)==null||(e=e.services.floatingGroupService)==null?void 0:e.floatingGroups)??[]}getFloatingWindowForGroup(e){return this._floatingGroupService?.findByGroup(e)}_gatherFloatingGroupBoxes(e){return this.getFloatingGroupSnapshots(e).map(e=>e.box)}getFloatingContainer(){return this._floatingOverlayHost??this.gridview.element}getFloatingGroupSnapshots(e){let t=this.getFloatingContainer().getBoundingClientRect();return this.floatingGroups.filter(t=>t.group!==e).map(e=>{let n=e.overlay.element.getBoundingClientRect();return{group:e.group,box:{left:n.left-t.left,top:n.top-t.top,width:n.width,height:n.height}}})}mergeFloatInto(e,t,n){e!==t&&this.getPanel(t.id)&&this.moveGroupOrPanel({from:{groupId:e.id},to:{group:t,position:n}})}getGridSplitterRects(){let e=this.getFloatingContainer().getBoundingClientRect(),t=[];return this.gridview.element.querySelectorAll(`.dv-sash`).forEach(n=>{let r=n.getBoundingClientRect();t.push({left:r.left-e.left,top:r.top-e.top,width:r.width,height:r.height})}),t}get _smartGuidesService(){return this._moduleRegistry.services.smartGuidesService}get smartGuidesEnabled(){return this._smartGuidesService?.enabled??!1}setSmartGuidesEnabled(e){var t;(t=fJ(this._smartGuidesService,`SmartGuides`,`api.setSmartGuidesEnabled`))==null||t.setEnabled(e)}updateSmartGuidesOptions(e){var t;(t=fJ(this._smartGuidesService,`SmartGuides`,`api.updateSmartGuidesOptions`))==null||t.updateOptions(e)}get onDidSnapFloat(){return this._smartGuidesService?.onDidSnapFloat??wY}get onDidSnapTogether(){return this._smartGuidesService?.onDidSnapTogether??wY}_buildFloatingDragTransform(e,t){let n=this.options.transformFloatingGroupDrag,r=!t;if(n||r&&this._smartGuidesService)return t=>{let i=n?.({group:e,proposed:t.proposed,container:t.container,others:t.others,modifiers:t.modifiers}),a=i?$($({},t.proposed),i):t.proposed;return(r?this._smartGuidesService?.transformFloatingGroupDrag({group:e,proposed:a,container:t.container,others:t.others,modifiers:t.modifiers}):void 0)??i??void 0}}get _floatingGroupService(){return this._moduleRegistry.services.floatingGroupService}get _popoutWindowService(){return this._moduleRegistry.services.popoutWindowService}get _watermarkService(){return this._moduleRegistry.services.watermarkService}get _edgeGroupService(){return this._moduleRegistry.services.edgeGroupService}get _rootDropTargetService(){return this._moduleRegistry.services.rootDropTargetService}get _advancedDnDService(){return this._moduleRegistry.services.advancedDnDService}get _dndCompassService(){return this._moduleRegistry.services.dndCompassService}canDropOnGroup(e,t,n){return e.model.canDisplayContentOverlay(n,t)}getDropOverlayElement(e){let t=e.element.querySelector(`.dv-content-container`);if(t)return this.options.theme?.dndPanelOverlay===`group`?t.parentElement??t:t}getTabsListElement(e){return e.model.header.hidden?void 0:e.model.tabsListElement}relayoutGroup(e){e.relayout()}setForcedOverflow(e,t){e.model.header.setForcedOverflow(t)}getLayoutElement(){return this.gridview.element}getDropPositionResolver(){if(this.options.dropPositionResolver)return this.options.dropPositionResolver;let e=this._dndCompassService?.resolver,t=this._moduleRegistry.services.autoEdgeGroupService;return e&&t?{resolve:n=>t.resolveEdge(n)??e.resolve(n)}:e??t?.resolver}dockToLayoutEdge(e,t){let n=new Vq({nativeEvent:e,position:t,panel:void 0,api:this._api,group:void 0,getData:fW,kind:`edge`});if(this._onWillDrop.fire(n),n.defaultPrevented)return;let r=fW();r?this.moveGroupOrPanel({from:{groupId:r.groupId,panelId:r.panelId??void 0},to:{group:this.orthogonalize(t),position:`center`}}):this._onDidDrop.fire(new Bq({nativeEvent:e,position:t,panel:void 0,api:this._api,group:void 0,getData:fW}))}get headerActionsService(){return this._moduleRegistry.services.headerActionsService}get _layoutHistoryService(){return this._moduleRegistry.services.layoutHistoryService}undo(){var e;(e=fJ(this._layoutHistoryService,`LayoutHistory`,`api.undo`))==null||e.undo()}redo(){var e;(e=fJ(this._layoutHistoryService,`LayoutHistory`,`api.redo`))==null||e.redo()}get canUndo(){return this._layoutHistoryService?.canUndo??!1}get canRedo(){return this._layoutHistoryService?.canRedo??!1}clearHistory(){var e;(e=this._layoutHistoryService)==null||e.clear()}get onDidChangeHistory(){return this._layoutHistoryService?.onDidChangeHistory??TY}get hasEdgeDragReveal(){return!!this._moduleRegistry.services.autoEdgeGroupService}isGridEmpty(){return this.gridview.length===0}rootDropTargetOverrideTarget(){return this.rootDropTargetContainer?.model}dispatchUnhandledDragOver(e,t){let n=new fq(e,`edge`,t,fW);return this._onUnhandledDragOver.fire(n),n.isAccepted}fireWillDragPanel(e){this._onWillDragPanel.fire(e)}fireWillDragGroup(e){this._onWillDragGroup.fire(e)}fireWillDrop(e){this._onWillDrop.fire(e)}fireWillShowOverlay(e){this._onWillShowOverlay.fire(e)}buildGroupDragGhost(e){return this._advancedDnDService?.buildGroupDragGhost(e)}resolveDropOverlayModel(e,t){return this._advancedDnDService?.resolveOverlayModel(e,t)}get rootElement(){return this._shellManager?.element??this.element}ownsElement(e){if(this.rootElement.contains(e))return!0;let t=this.rootElement.ownerDocument,n=e.ownerDocument;return!n||n===t?!1:this.getPopoutWindows().some(e=>e.document===n)}adjacentGroup(e,t){let n=this.getGridviewForGroup(e);if(!n.element.contains(e.element))return;let r=jG(e.element),i=(t?n.previous(r):n.next(r)).view;if(n===this.gridview||i!==e)return i}adjacentGroupInDirection(e,t){if(e.api.location.type!==`grid`)return;let n=e.element.getBoundingClientRect(),r=n.left+n.width/2,i=n.top+n.height/2,a,o=1/0;for(let n of this.groups){if(n===e||n.api.location.type!==`grid`)continue;let s=n.element.getBoundingClientRect(),c=s.left+s.width/2-r,l=s.top+s.height/2-i,u;switch(t){case`left`:u=c<0&&Math.abs(c)>=Math.abs(l);break;case`right`:u=c>0&&Math.abs(c)>=Math.abs(l);break;case`up`:u=l<0&&Math.abs(l)>=Math.abs(c);break;default:u=l>0&&Math.abs(l)>=Math.abs(c)}if(!u)continue;let d=c*c+l*l;d<o&&(o=d,a=n)}return a}showDropPreview(e,t){return this._advancedDnDService?.showPreviewOverlay(e,t)??mW.NONE}announce(e){var t;(t=this._moduleRegistry.services.liveRegionService)==null||t.announce(e)}dockPanel(e,t,n){this.moveGroupOrPanel({from:{groupId:e.group.id,panelId:e.id},to:{group:t,position:n}})}floatPanel(e){this.addFloatingGroup(e)}get contextMenuService(){return this._moduleRegistry.services.contextMenuService}get pinnedTabsService(){return this._moduleRegistry.services.pinnedTabsService}get advancedOverflowService(){return this._moduleRegistry.services.advancedOverflowService}setPanelPinned(e,t){e.isPinned!==t&&this.options.pinnedTabs?.enabled&&this.pinnedTabsService&&(e.setPinned(t),this._onDidPanelPinnedChange.fire({panel:e,isPinned:t}))}get mountElement(){return this.gridview.element}hasVisibleGridGroup(){return this.groups.some(e=>e.api.location.type===`grid`&&e.api.isVisible)}isLastGridGroup(e){return e.api.location.type===`grid`&&!this.groups.some(t=>t!==e&&t.api.location.type===`grid`)}fireLayoutChange(e){this._bufferOnDidLayoutChange.fire(e)}get popoutRestorationPromise(){return this._popoutWindowService?.restorationPromise??Promise.resolve()}constructor(e,t){super(e,{proportionalLayout:t.proportionalLayout??!0,orientation:`HORIZONTAL`,styles:t.hideBorders?{separatorBorder:`transparent`}:void 0,disableAutoResizing:t.disableAutoResizing,locked:t.locked,margin:t.theme?.gap??0,className:t.className}),this.nextGroupId=hG(),this._deserializer=new tJ(this),this._moduleRegistry=new pJ,this._onWillDragPanel=new X,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new X,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new X,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new X,this.onWillDrop=this._onWillDrop.event,this._mutationDepth=0,this._syncMutationDepth=0,this._pendingLocationChanges=new Map,this._openingPopoutWindows=new Set,this._origin=`user`,this._originDepth=0,this._onWillMutateLayout=new X,this.onWillMutateLayout=this._onWillMutateLayout.event,this._onDidMutateLayout=new X,this.onDidMutateLayout=this._onDidMutateLayout.event,this._onWillShowOverlay=new X,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOver=new X,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._onDidRemovePanel=new X,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new X,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new X,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new X,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidAddPopoutGroup=new X,this.onDidAddPopoutGroup=this._onDidAddPopoutGroup.event,this._onDidRemovePopoutGroup=new X,this.onDidRemovePopoutGroup=this._onDidRemovePopoutGroup.event,this._onDidChangePopouts=new X,this.onDidChangePopouts=this._onDidChangePopouts.event,this._onDidOpenPopoutWindowFail=new X,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onWillClosePopoutWindow=new X,this.onWillClosePopoutWindow=this._onWillClosePopoutWindow.event,this._onDidStartFloatingGroupDrag=new X,this.onDidStartFloatingGroupDrag=this._onDidStartFloatingGroupDrag.event,this._onDidEndFloatingGroupDrag=new X,this.onDidEndFloatingGroupDrag=this._onDidEndFloatingGroupDrag.event,this._onDidLayoutFromJSON=new X,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new X({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidPanelPinnedChange=new X,this.onDidPanelPinnedChange=this._onDidPanelPinnedChange.event,this._onDidMovePanel=new X,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidCreateTabGroup=new X,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new X,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new X,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new X,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new X,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new X,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,this._onDidMaximizedGroupChange=new X,this.onDidMaximizedGroupChange=this._onDidMaximizedGroupChange.event,this._inShellLayout=!1,this._onDidRemoveGroup=new X,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidEdgeGroupAutoHideChange=new X,this.onDidEdgeGroupAutoHideChange=this._onDidEdgeGroupAutoHideChange.event,this._onDidAddGroup=new X,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new X,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new X,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._peekingGroups=new Set,this._moving=!1,this._options=t,this._tabGroupColorPalette=SY(t);let n=t.modules??[...nY,...hJ()];for(let e of n)this._moduleRegistry.register(e);this._moduleRegistry.initialize(this),this.reportMissingOptionModules(t);let r=this._popoutWindowService;r&&this.addDisposables(r.onDidRemove(e=>{this._onDidRemovePopoutGroup.fire({id:e.popoutGroup.id,group:e.popoutGroup,window:e.getWindow()})})),this.popupService=new fY(this.element),this.addDisposables(this.popupService,mW.from(()=>{for(let e of this._openingPopoutWindows)e.dispose();this._openingPopoutWindows.clear()})),this._api=new nK(this),this.disableResizing=!0,this.element.remove(),this._shellManager=new bY(e,this.element,(e,t)=>this._layoutFromShell(e,t),t.theme?.gap??0,t.theme?.edgeGroupCollapsedSize),this._shellManager.locked=!!t.locked,this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new KW(this._shellManager.element),this.rootDropTargetContainer=new pY(this._shellManager.element,{disabled:!0}),this.floatingDropTargetContainer=new pY(this._shellManager.element,{disabled:!1}),this.overlayRenderContainer=new cY(this._shellManager.element,this),this._floatingOverlayHost=document.createElement(`div`),this._floatingOverlayHost.className=`dv-floating-overlay-host`,this._shellManager.element.appendChild(this._floatingOverlayHost),Q(this.gridview.element,`dv-dockview`,!0),Q(this.element,`dv-debug`,!!t.debug),this.updateTheme(),t.debug&&this.addDisposables(new lY(this)),this.addDisposables(mW.from(()=>this._pendingLocationChanges.clear()),this.rootDropTargetContainer,this.floatingDropTargetContainer,Z(this._shellManager.element,`dragend`,()=>{var e,t;(e=this.rootDropTargetContainer.model)==null||e.clear(),(t=this.floatingDropTargetContainer.model)==null||t.clear()},!0),this.overlayRenderContainer,this._onWillDragPanel,this._onWillDragGroup,this._onWillShowOverlay,this._onDidActivePanelChange,this._onDidPanelPinnedChange,this._onDidAddPanel,this._onDidRemovePanel,this._onDidLayoutFromJSON,this._onDidDrop,this._onWillDrop,this._onWillMutateLayout,this._onDidMutateLayout,this._onDidMovePanel,this._onDidMovePanel.event(()=>{this.debouncedUpdateAllPositions()}),this._onDidAddGroup,this._onDidRemoveGroup,this._onDidEdgeGroupAutoHideChange,this._onDidActiveGroupChange,this._onUnhandledDragOver,this._onDidMaximizedGroupChange,this._onDidPopoutGroupSizeChange,this._onDidPopoutGroupPositionChange,this._onDidAddPopoutGroup,this._onDidRemovePopoutGroup,this._onDidChangePopouts,this._onDidAddPopoutGroup.event(()=>this._onDidChangePopouts.fire()),this._onDidRemovePopoutGroup.event(()=>this._onDidChangePopouts.fire()),this._onDidOpenPopoutWindowFail,this._onDidStartFloatingGroupDrag,this._onDidEndFloatingGroupDrag,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,gW.any(this.onDidPopoutGroupSizeChange,this.onDidPopoutGroupPositionChange)(()=>{this.fireLayoutChange(`geometry`)}),gW.any(this.onDidCreateTabGroup,this.onDidDestroyTabGroup,this.onDidAddPanelToTabGroup,this.onDidRemovePanelFromTabGroup,this.onDidTabGroupChange,this.onDidTabGroupCollapsedChange)(()=>{this.fireLayoutChange(`structure`)}),this._onDidOptionsChange,this.onDidAdd(e=>{this._moving||this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._moving||this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._moving||this._onDidActiveGroupChange.fire(e)}),this.onDidMaximizedChange(e=>{this._onDidMaximizedGroupChange.fire({group:e.panel,isMaximized:e.isMaximized})}),gW.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidAddGroup,this.onDidRemove,this.onDidRemoveGroup,this.onDidMovePanel)(()=>{this._bufferOnDidLayoutChange.fire(`structure`)}),this.onDidActivePanelChange(()=>{this._bufferOnDidLayoutChange.fire(`activePanel`)}),mW.from(()=>{var e;this._moduleRegistry.dispose(),(e=this._shellManager)==null||e.dispose()}),this._onWillClosePopoutWindow);let i=this._rootDropTargetService;i&&this.addDisposables(i.onWillShowOverlay(e=>{this.gridview.length>0&&e.position===`center`||this._onWillShowOverlay.fire(new aq(e,{kind:`edge`,panel:void 0,api:this._api,group:void 0,getData:fW}))}),i.onDrop(e=>this.dockToLayoutEdge(e.nativeEvent,e.position))),this._moduleRegistry.postConstruct(this),this._shellManager.layoutFromElement()}setVisible(e,t){switch(e.api.location.type){case`grid`:super.setVisible(e,t);break;case`floating`:{let n=this.floatingGroups.find(t=>t.group===e);n&&(n.overlay.setVisible(t),e.api._onDidVisibilityChange.fire({isVisible:t}));break}case`popout`:console.warn(`dockview: You cannot hide a group that is in a popout window`)}}getPopupServiceForGroup(e){var t;return((t=this._popoutWindowService)==null||(t=t.findByGroup(e))==null?void 0:t.popupService)??this.popupService}addPopoutGroup(e,t){return this.mutationAsync(`popout`,()=>this._doAddPopoutGroup(e,t))}getPopouts(){return this._popoutWindowService?.entries.map(e=>({id:e.popoutGroup.id,group:e.popoutGroup,window:e.getWindow()}))??[]}getPopoutWindows(){return this.getPopouts().map(e=>e.window)}_doAddPopoutGroup(e,t){var n;let r=fJ(this._popoutWindowService,`PopoutWindow`,`api.addPopoutGroup`);if(!r||e instanceof Yq&&e.model.location.type===`edge`)return Promise.resolve(!1);if(e instanceof Qq&&e.group.size===1&&this.closeEmptyGroups)return this.addPopoutGroup(e.group,t);let i=GW(this.gridview.element),a=this.element;function o(){if(t?.position)return t.position;let n=(e instanceof Yq?e.element:e.group?.element??a).getBoundingClientRect();return{left:window.screenX+n.left,top:window.screenY+n.top,width:n.width,height:n.height}}let s=o(),c=(t==null||(n=t.overridePopoutGroup)==null?void 0:n.id)??this.getNextGroupId(),l=t?.popoutUrl??this.options?.popoutUrl,u=l??`/popout.html`,d=new sG(`${this.id}-${c}`,i??``,{url:u,left:s.left,top:s.top,width:s.width,height:s.height,onDidOpen:t?.onDidOpen,onWillClose:e=>{var n;t==null||(n=t.onWillClose)==null||n.call(t,e),this._onWillClosePopoutWindow.fire(e)},nonce:this.options?.nonce,styleRoot:()=>this.element.getRootNode()}),f=new Y(d,d.onDidClose(()=>{f.dispose()}));this._openingPopoutWindows.add(f);let p=oG(u);return(p?Promise.resolve(null):d.open()).then(n=>{if(this._openingPopoutWindows.delete(f),this.isDisposed)return f.dispose(),!1;if(d.isDisposed){let e=d.failure;return e&&!this.isDisposed&&(xY(e),this._onDidOpenPopoutWindowFail.fire(e)),!1}let i=t?.referenceGroup??(e instanceof Qq?e.group:e),a=e.api.location.type,o=i.element.parentElement!==null,s;if(t?.overridePopoutGridview?s=t.overridePopoutGroup??i:o?t?.overridePopoutGroup?s=t.overridePopoutGroup:(s=this.createGroup({id:c}),n&&this._onDidAddGroup.fire(s)):s=i,n===null)return this.handleBlockedPopout({group:s,referenceGroup:i,options:t,popoutWindowDisposable:f,failure:p?{reason:`url-refused`,error:p}:d.failure??{reason:`blocked`}}),!1;let u=document.createElement(`div`);u.className=`dv-overlay-render-container`;let m=new cY(u,this);s.model.renderContainer=m;let h=t?.overridePopoutGridview??this.createNestedGridview();t?.overridePopoutGridview?h.locked=this.gridview.locked:h.addView(s,bG.Distribute,[0]),h.element.style.width=`100%`,h.element.style.height=`100%`,h.layout(d.window.innerWidth,d.window.innerHeight);let g=!1,_=()=>{g||(g=!0,h.dispose())},v,y=[];if(!t?.overridePopoutGroup&&!t?.overridePopoutGridview&&o){if(e instanceof Qq){let t=e.group;this.movingLock(()=>{let t=i.model.removePanel(e);s.model.openPanel(t)}),y=[{panel:e,from:t}]}else switch(this.movingLock(()=>CY({from:i,to:s})),y=s.panels.map(e=>({panel:e,from:i})),a){case`grid`:i.api.setVisible(!1);break;case`floating`:case`popout`:v=this.floatingGroups.find(t=>t.group.api.id===e.api.id)?.overlay.toJSON(),this.removeGroup(i)}}n.classList.add(`dv-dockview`),n.style.overflow=`hidden`,n.appendChild(u),n.appendChild(h.element);let b=document.createElement(`div`),x=new pY(b,{disabled:this.rootDropTargetContainer.disabled});n.appendChild(b),s.model.dropTargetContainer=x;let S=new fY(n,d.window);if(f.addDisposables(S),s.model.location={type:`popout`,getWindow:()=>d.window,popoutUrl:l},t?.overridePopoutGridview){let e=this.groups.filter(e=>h.element.contains(e.element));for(let t of e)t.model.renderContainer=m,t.model.dropTargetContainer=x,t.model.location={type:`popout`,getWindow:()=>d.window,popoutUrl:l}}o&&e.api.location.type===`grid`&&e.api.setVisible(!1),this.doSetGroupAndPanelActive(s);let C=r.observeGridviewSize(d,h,m);C&&f.addDisposables(C);let w=new hW;f.addDisposables(w);let T=e=>{w.value=new Y(e.api.onDidActiveChange(e=>{if(e.isActive){var t;(t=d.window)==null||t.focus()}}),e.api.onWillFocus(()=>{var e;(e=d.window)==null||e.focus()}))};T(s);let E={},D=o&&i&&this.getPanel(i.id),O={window:d,popoutGroup:s,gridview:h,overlayRenderContainer:m,dropTargetContainer:x,getWindow:()=>d.window,popoutUrl:l,referenceGroup:D?i.id:void 0,popupService:S,setAnchorGroup:e=>{O.popoutGroup=e,T(e)},disposable:{dispose:()=>(f.dispose(),E.returnedGroup)}},k=YW(d.window);f.addDisposables(k,XW(d.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:d.window.innerWidth,height:d.window.innerHeight,group:O.popoutGroup})}),k.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:d.window.screenX,screenY:d.window.screenY,group:O.popoutGroup})}),Z(d.window,`resize`,()=>{h.layout(d.window.innerWidth,d.window.innerHeight)}),m,mW.from(()=>this.disposePopoutWindow({group:s,referenceGroup:i,popoutGridview:h,isGroupAddedToDom:o,floatingBox:v,disposePopoutGridview:_,closeResult:E}))),r.add(O),this._onDidAddPopoutGroup.fire({id:O.popoutGroup.id,group:O.popoutGroup,window:O.getWindow()});for(let{panel:e,from:t}of y)this.fireDidMovePanel(e,t);return!0}).catch(e=>(this._openingPopoutWindows.delete(f),console.error(`dockview: failed to create popout.`,e),!1))}handleBlockedPopout(e){let{group:t,referenceGroup:n,options:r,popoutWindowDisposable:i,failure:a}=e;if(xY(a),i.dispose(),this._onDidOpenPopoutWindowFail.fire(a),r?.overridePopoutGridview){let e=r.overridePopoutGridview,t=this.groups.filter(t=>e.element.contains(t.element));for(let n of t)this.movingLock(()=>{e.remove(n),this.redockGroupToMainGrid(n)});e.dispose(),n&&!n.api.isVisible&&n.api.setVisible(!0)}else t===n?this.gridview.element.contains(t.element)||(this.movingLock(()=>this.doAddGroup(t,[0])),t.model.location={type:`grid`}):(this.movingLock(()=>CY({from:t,to:n})),t.model.size===0&&this._groups.has(t.id)&&(t.dispose(),this._groups.delete(t.id),this._onDidRemoveGroup.fire(t))),n.api.isVisible||n.api.setVisible(!0)}redockGroupToMainGrid(e){e.model.renderContainer=this.overlayRenderContainer,e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location={type:`grid`},this.doAddGroup(e,[0])}disposePopoutWindow(e){let{group:t,referenceGroup:n,popoutGridview:r,isGroupAddedToDom:i,floatingBox:a,disposePopoutGridview:o,closeResult:s}=e;if(this.isDisposed){o();return}let c=!!this._popoutWindowService?.entries.find(e=>e.gridview===r),l=this.groups.filter(e=>r.element.contains(e.element)),u=l.includes(t),d=u&&l.length===1;if(!c){u&&this.getPanel(t.id)&&(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,s.returnedGroup=t),o();return}let f=[];for(let e of l)if(e!==t){this.movingLock(()=>{this.doRemoveGroup(e,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),this.redockGroupToMainGrid(e)});for(let t of e.panels)f.push({panel:t,from:e})}if(u&&i&&this.getPanel(n.id)){let e=[...t.panels];this.movingLock(()=>CY({from:t,to:n}));for(let n of e)f.push({panel:n,from:t});n.api.isVisible||n.api.setVisible(!0),this.getPanel(t.id)&&this.doRemoveGroup(t,{skipPopoutAssociated:!0})}else if(u&&this.getPanel(t.id)){if(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,s.returnedGroup=t,a&&d)this.addFloatingGroup(t,{height:a.height,width:a.width,position:a});else{this.doRemoveGroup(t,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),t.model.location={type:`grid`},this.movingLock(()=>{this.doAddGroup(t,[0])});for(let e of t.panels)f.push({panel:e,from:t})}this.doSetGroupAndPanelActive(t)}o();for(let{panel:e,from:t}of f)this.fireDidMovePanel(e,t)}addFloatingGroup(e,t){this.mutation(`float`,()=>this._doAddFloatingGroup(e,t))}_doAddFloatingGroup(e,t){if(!fJ(this._floatingGroupService,`FloatingGroup`,`api.addFloatingGroup`)||e instanceof Yq&&e.model.location.type===`edge`)return;let n,r=[];if(e instanceof Qq){let t=e.group;n=this.createGroup(),this._onDidAddGroup.fire(n),this.movingLock(()=>this.removePanel(e,{removeEmptyGroup:!1,skipDispose:!0,skipSetActiveGroup:!0})),this.removeGroupIfEmpty(t),this.movingLock(()=>n.model.openPanel(e,{skipSetGroupActive:!0})),r=[{panel:e,from:t}]}else{n=e;let i=this._popoutWindowService?.findReferenceGroupId(n),a=i?this.getPanel(i):void 0;typeof t?.skipRemoveGroup==`boolean`&&t.skipRemoveGroup||(a?(this.movingLock(()=>CY({from:e,to:a})),this.doRemoveGroup(e,{skipPopoutReturn:!0,skipPopoutAssociated:!0}),this.doRemoveGroup(a,{skipDispose:!0}),n=a,r=n.panels.map(t=>({panel:t,from:e}))):(this.doRemoveGroup(e,{skipDispose:!0,skipPopoutReturn:!0,skipPopoutAssociated:!1}),r=n.panels.map(e=>({panel:e,from:n}))))}function i(){if(t?.position){let e={};return`left`in t.position?e.left=Math.max(t.position.left,0):`right`in t.position?e.right=Math.max(t.position.right,0):e.left=vJ.left,`top`in t.position?e.top=Math.max(t.position.top,0):`bottom`in t.position?e.bottom=Math.max(t.position.bottom,0):e.top=vJ.top,e.width=typeof t.width==`number`?Math.max(t.width,0):vJ.width,e.height=typeof t.height==`number`?Math.max(t.height,0):vJ.height,e}return{left:typeof t?.x==`number`?Math.max(t.x,0):vJ.left,top:typeof t?.y==`number`?Math.max(t.y,0):vJ.top,width:typeof t?.width==`number`?Math.max(t.width,0):vJ.width,height:typeof t?.height==`number`?Math.max(t.height,0):vJ.height}}let a=i(),o=this.createNestedGridview();o.addView(n,bG.Distribute,[0]),this.mountFloatingWindow(o,n,[n],a,{dragHandle:t?.dragHandle,inDragMode:t?.inDragMode,skipActiveGroup:t?.skipActiveGroup,disableSmartGuides:t?.disableSmartGuides});for(let{panel:e,from:t}of r)this.fireDidMovePanel(e,t)}get closeEmptyGroups(){return this.options.closeEmptyGroups!==!1}keepEmptyGroups(e){return e.keepEmptyGroups??!this.closeEmptyGroups}removeGroupIfEmpty(e){e.model.size===0&&this.closeEmptyGroups&&this.doRemoveGroup(e,{skipActive:!0})}get locked(){return this.gridview.locked}set locked(e){this.gridview.locked=e,this._shellManager&&(this._shellManager.locked=e);for(let t of this.nestedGridviews())t.locked=e}nestedGridviews(){return[...this.floatingGroups.map(e=>e.gridview),...(this._popoutWindowService?.entries??[]).map(e=>e.gridview)]}createNestedGridview(e=`HORIZONTAL`){return new RG(this.gridview.proportionalLayout,this.options.hideBorders?{separatorBorder:`transparent`}:void 0,e,this.gridview.locked,this.options.theme?.gap??0)}mountFloatingWindow(e,t,n,r,i){let a=fJ(this._floatingGroupService,`FloatingGroup`,`api.addFloatingGroup`);if(!a)return;let o=(i?.dragHandle??this.options.floatingGroupDragHandle??`titlebar`)===`titlebar`?new oJ(this,t):void 0,s=new aJ($($({container:this._floatingOverlayHost??this.gridview.element,content:e.element,header:o?.element},r),{},{minimumInViewportWidth:this.options.floatingGroupBounds===`boundedWithinViewport`?void 0:this.options.floatingGroupBounds?.minimumWidthWithinViewport??100,minimumInViewportHeight:this.options.floatingGroupBounds===`boundedWithinViewport`?void 0:this.options.floatingGroupBounds?.minimumHeightWithinViewport??100,transformDragPosition:this._buildFloatingDragTransform(t,i?.disableSmartGuides??!1),getSiblingBoxes:()=>this._gatherFloatingGroupBoxes(t)})),c=o?.element??t.element.querySelector(`.dv-void-container`);if(!c)throw Error(`dockview: failed to find drag handle`);s.setupDrag(c,{inDragMode:typeof i?.inDragMode==`boolean`&&i.inDragMode});let l=a.add(t,s,e);l.addDisposables(s.onDidStartMoving(()=>this._onDidStartFloatingGroupDrag.fire(t)),s.onDidChangeEnd(()=>this._onDidEndFloatingGroupDrag.fire(t))),o&&(l.setTitleBar(o),l.addDisposables(o,mW.from(()=>l.setTitleBar(void 0)),o.onDragStart(e=>{this._onWillDragGroup.fire({nativeEvent:e,group:l.group})})));for(let e of n)e.model.location={type:`floating`};i?.skipActiveGroup||this.doSetGroupAndPanelActive(t)}orthogonalize(e,t){switch(this.gridview.normalize(),e){case`top`:case`bottom`:this.gridview.orientation===`HORIZONTAL`&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case`left`:case`right`:this.gridview.orientation===`VERTICAL`&&this.gridview.insertOrthogonalSplitviewAtRoot()}switch(e){case`top`:case`left`:case`center`:return this.createGroupAtLocation([0],void 0,t);case`bottom`:case`right`:return this.createGroupAtLocation([this.gridview.length],void 0,t);default:throw Error(`dockview: unsupported position ${e}`)}}updateOptions(e){var t,n;super.updateOptions(e),this.reportMissingOptionModules(e),(t=this._floatingGroupService)==null||t.updateBounds(e),(n=this._rootDropTargetService)==null||n.setOptions(e);let r=this.options.disableDnd,i=this.options.dndStrategy;this._options=$($({},this.options),e);let a=this.options.disableDnd,o=this.options.dndStrategy;if((r!==a||i!==o)&&this.updateDragAndDropState(),`proportionalLayout`in e){let e=this.gridview.proportionalLayout;for(let t of this.nestedGridviews())t.proportionalLayout=e}if(`theme`in e&&this.updateTheme(),`createRightHeaderActionComponent`in e||`createLeftHeaderActionComponent`in e||`createPrefixHeaderActionComponent`in e){var s;(s=this.headerActionsService)==null||s.refreshAll()}if(`createWatermarkComponent`in e){var c;(c=this._watermarkService)==null||c.refresh();for(let e of this.groups)e.model.refreshWatermark()}if(`tabGroupColors`in e||`tabGroupAccent`in e){this._tabGroupColorPalette.setEntries(this._options.tabGroupColors??vq),this._tabGroupColorPalette.enabled=this._options.tabGroupAccent!==`off`;for(let e of this.groups)e.model.refreshTabGroupAccent()}this._onDidOptionsChange.fire(),this._layoutFromShell(this.gridview.width,this.gridview.height)}reportMissingOptionModules(e){_J(e,e=>this._moduleRegistry.has(e))}layout(e,t,n){var r;this._shellManager&&!this._inShellLayout?this._shellManager.layout(e,t):super.layout(e,t,n),this._syncFloatingOverlayHost(),(r=this._moduleRegistry)==null||(r=r.services.floatingGroupService)==null||r.constrainBounds()}_syncFloatingOverlayHost(){if(!this._floatingOverlayHost||!this._shellManager)return;let e=this._shellManager.element.getBoundingClientRect(),t=this.element.getBoundingClientRect(),n=this._floatingOverlayHost;n.style.left=`${t.left-e.left}px`,n.style.top=`${t.top-e.top}px`,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`}_layoutFromShell(e,t){this._inShellLayout=!0,this.layout(e,t,!0),this._inShellLayout=!1}forceRelayout(){this._shellManager?this._layoutFromShell(this.width,this.height):super.forceRelayout()}addEdgeGroup(e,t){let n=this._edgeGroupService;if(!n)throw Error(uJ(`EdgeGroup`,`api.addEdgeGroup`));if(n.has(e))throw Error(`dockview: edge group already exists at position '${e}'`);return this.mutation(`add`,()=>{let r=this.createGroup({id:t.id});r.model.location={type:`edge`,position:e},r.model.headerPosition=e;let i=r.onDidChange(t=>{var n;if(!t)return;let r=hY(e)?t.width:t.height;typeof r==`number`&&((n=this._shellManager)==null||n.resizeEdgeGroup(e,r))}),a=r.model.onDidRemovePanel(()=>{r.model.isEmpty&&(n.isAutoReveal(r)?queueMicrotask(()=>{r.model.isEmpty&&this._edgeGroupService?.includes(r)&&this.removeEdgeGroup(e)}):this.setEdgeGroupCollapsed(r,!0))});n.add(e,r,new Y(a,i)),t.autoHide!==void 0&&n.setAutoHide(r,t.autoHide),t.autoReveal!==void 0&&n.setAutoReveal(r,t.autoReveal),this._onDidAddGroup.fire(r);let o={element:r.element,get headerPosition(){return r.model.headerPosition},layout:(e,t)=>r.layout(e,t)};return this._shellManager.addEdgeView(e,t,o),r.api})}revealEdgeGroupWithData(e,t,n){let r=this._edgeGroupService;r&&this.mutation(`add`,()=>{let i=r.get(e);i||=(this.addEdgeGroup(e,{id:this.getNextGroupId(),autoReveal:!0,autoHide:n?.autoHide,collapsed:!0}),r.get(e)),i&&this.moveGroupOrPanel({from:{groupId:t.groupId,panelId:t.panelId??void 0},to:{group:i,position:`center`}})})}getEdgeGroup(e){var t;return(t=this._edgeGroupService)==null||(t=t.get(e))==null?void 0:t.api}getEdgeGroupPanel(e){return this._edgeGroupService?.get(e)}pinEdgeGroup(e){var t;(t=fJ(this._moduleRegistry.services.autoHideEdgeGroupService,`AutoHideEdgeGroup`,`api.pinEdgeGroup`))==null||t.pin(e)}autoHideEdgeGroup(e){var t;(t=fJ(this._moduleRegistry.services.autoHideEdgeGroupService,`AutoHideEdgeGroup`,`api.autoHideEdgeGroup`))==null||t.autoHide(e)}peekEdgeGroup(e,t){var n;(n=fJ(this._moduleRegistry.services.autoHideEdgeGroupService,`AutoHideEdgeGroup`,`api.peekEdgeGroup`))==null||n.peek(e,t)}get overlayRoot(){return this.rootElement}getDropZoneRect(){return this.element.getBoundingClientRect()}getEdgeGroupExpandedSize(e){return this._shellManager?.getEdgeGroupExpandedSize(e)??0}repositionPanelOverlay(e,t,n){this.overlayRenderContainer.repositionPanelOverlay(e.api.id,t,n)}setEdgeGroupVisible(e,t){this._shellManager.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this._shellManager.isEdgeGroupVisible(e)}removeEdgeGroup(e){let t=fJ(this._edgeGroupService,`EdgeGroup`,`api.removeEdgeGroup`);if(!t)return;let n=t.get(e);if(!n)throw Error(`dockview: no edge group exists at position '${e}'`);this.mutation(`remove`,()=>{for(let e of[...n.panels])this.removePanel(e,{removeEmptyGroup:!1,skipDispose:!1});this._shellManager.removeEdgeView(e),t.remove(e),n.dispose(),this._groups.delete(n.id),this._onDidRemoveGroup.fire(n),this.activateFallbackGroupIfRemoved(n)})}setEdgeGroupCollapsed(e,t){let n=this._edgeGroupService?.findPositionOf(e);n&&this._shellManager.isEdgeGroupCollapsed(n)!==t&&(this._shellManager.setEdgeGroupCollapsed(n,t),e.api._onDidCollapsedChange.fire({isCollapsed:t}))}isEdgeGroupCollapsed(e){let t=this._edgeGroupService?.findPositionOf(e);return t?this._shellManager.isEdgeGroupCollapsed(t):!1}isEdgeGroupPeeking(e){return this._peekingGroups.has(e)}setEdgeGroupPeeking(e,t){this._peekingGroups.has(e)!==t&&(t?this._peekingGroups.add(e):this._peekingGroups.delete(e),e.api._onDidPeekChange.fire({isPeeking:t}))}isEdgeGroupAutoHide(e){let t=this._edgeGroupService?.isAutoHide(e);if(t!==void 0)return t;let n=this._edgeGroupService?.findPositionOf(e);return n!==void 0&&uq(this.options.autoHideEdgeGroups,n)}setEdgeGroupAutoHide(e,t){let n=this._edgeGroupService;n?.includes(e)&&(n.setAutoHide(e,t),this._onDidEdgeGroupAutoHideChange.fire(e))}updateDragAndDropState(){for(let e of this.groups)e.model.updateDragAndDropState()}focus(){var e;(e=this.activeGroup)==null||e.focus()}getGroupPanel(e){return this.panels.find(t=>t.id===e)}setActivePanel(e){e.group.model.openPanel(e),this.doSetGroupAndPanelActive(e.group)}activateNext(e={}){if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[e.group.panels.length-1]){e.group.model.moveToNext({suppressRoll:!0});return}let t=this.activationTarget(e.group,!1);t&&this.doSetGroupAndPanelActive(t)}activatePrevious(e={}){if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[0]){e.group.model.moveToPrevious({suppressRoll:!0});return}let t=this.activationTarget(e.group,!0);t&&this.doSetGroupAndPanelActive(t)}activationTarget(e,t){let n=this.getGridviewForGroup(e);if(n.element.contains(e.element)){let r=jG(e.element),i=(t?n.previous(r):n.next(r)).view;if(n===this.gridview||i!==e)return i}let r=[],i=e=>{IG(e)?e.children.forEach(i):r.push(e.view)};i(this.gridview.getView());let a=r.filter(e=>e.api.isVisible);return a[t?a.length-1:0]}toJSON(){let e=this.gridview.serialize(),t=this.panels.reduce((e,t)=>(e[t.id]=t.toJSON(),e),{}),n=this._floatingGroupService?.serialize()??[],r=this._popoutWindowService?.serialize()??[],i={grid:e,panels:t,activeGroup:this.activeGroup?.id};n.length>0&&(i.floatingGroups=n),r.length>0&&(i.popoutGroups=r);let a=this._serializeEdgeGroups();return a&&(i.edgeGroups=a),i}_serializeEdgeGroups(){if(!this._edgeGroupService?.hasAny())return;let e=this._shellManager.toJSON();for(let[t,n]of this._edgeGroupService.entries()){let r=e[t];if(!r)continue;if(this._edgeGroupService.isAutoReveal(n)&&n.model.isEmpty){delete e[t];continue}r.group=n.toJSON(),this._edgeGroupService.isAutoReveal(n)&&(r.autoReveal=!0);let i=this._edgeGroupService.isAutoHide(n);i!==void 0&&(r.autoHide=i)}return e}fromJSON(e,t){this.mutation(`load`,()=>this._doFromJSON(e,t))}_doFromJSON(e,t){var n;if((n=this._popoutWindowService)==null||n.cancelPendingRestorations(),typeof e!=`object`||!e)throw Error(`dockview: serialized layout must be a non-null object`);if(!e.grid||e.grid.root?.type!==`branch`||!Array.isArray(e.grid.root.data))throw Error(`dockview: root must be of type branch`);let r=new Map,i=new Map,a=[],o=[],s=()=>{for(let e of o)try{e.dispose()}catch(e){console.error(`dockview: failed to dispose a temporary group created for reuseExistingPanels`,e)}o.length=0};if(t?.reuseExistingPanels){let t=Object.keys(e.panels),n,c=()=>{let e=this.createGroup(),t=this._groups.get(e.api.id);return this._groups.delete(e.api.id),o.push(mW.from(()=>{var n;this.movingLock(()=>{for(let t of e.panels.slice())e.model.removePanel(t)}),t?.disposable.dispose(),(n=this.headerActionsService)==null||n.disposeGroup(e),e.dispose()})),e};try{for(let e of this.panels)if(t.includes(e.api.id)){r.set(e.api.id,e);let t;e.api.renderer===`always`&&e.api.isVisible?t=c():(n??=c(),t=n),i.set(e.api.id,t),a.push({panel:e,temporaryGroup:t})}this.movingLock(()=>{a.forEach(({panel:e,temporaryGroup:t})=>{this.moveGroupOrPanel({from:{groupId:e.api.group.api.id,panelId:e.api.id},to:{group:t,position:`center`},keepEmptyGroups:!0})})}),this.clear()}catch(e){throw s(),e}}else this.clear();let{grid:c,panels:l,activeGroup:u}=e;try{var d,f,p;let t=this.width,n=this.height,a=e=>{let{id:t,locked:n,hideHeader:a,headerPosition:o,views:s,activeView:c}=e;if(typeof t!=`string`)throw TypeError(`dockview: group id must be of type string`);let u=this.createGroup({id:t,locked:n??!1,hideHeader:!!a,headerPosition:o});this._onDidAddGroup.fire(u);let d=[],f=s.filter(e=>l[e]);for(let e of f){let t=r.get(e),n=i.get(e);if(n&&t)this.movingLock(()=>{n.model.removePanel(t)}),d.push(t),t.updateFromStateModel(l[e]);else{let t=this._deserializer.fromJSON(l[e],u);d.push(t)}}for(let e of d){let t=typeof c==`string`&&c===e.id;r.has(e.api.id)?this.movingLock(()=>{u.model.openPanel(e,{skipSetActive:!t,skipSetGroupActive:!0})}):u.model.openPanel(e,{skipSetActive:!t,skipSetGroupActive:!0})}return e.tabGroups&&e.tabGroups.length>0&&u.model.restoreTabGroups(e.tabGroups),!u.activePanel&&u.panels.length>0&&u.model.openPanel(u.panels[u.panels.length-1],{skipSetGroupActive:!0}),u};this.gridview.deserialize(c,{fromJSON:e=>a(e.data)}),this._layoutFromShell(t,n),e.edgeGroups&&this.deserializeEdgeGroups(e.edgeGroups,l,r,i),this.deserializeFloatingWindows(e.floatingGroups??[],a);let o=this.deserializePopoutWindows(e.popoutGroups??[],a);if((d=this._popoutWindowService)==null||d.finishRestoration(o),(f=this._floatingGroupService)==null||f.constrainBounds(),typeof u==`string`){let e=this.getPanel(u);e&&this.doSetGroupAndPanelActive(e)}(p=this._watermarkService)==null||p.update()}catch(e){var m;console.error(`dockview: failed to deserialize layout. Reverting changes`,e);for(let e of this.groups)for(let t of e.panels.slice())this.removePanel(t,{removeEmptyGroup:!1,skipDispose:!1});for(let e of this.groups)this._edgeGroupService?.includes(e)||(e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e));throw(m=this._floatingGroupService)==null||m.disposeAll(),this.clear(),e}finally{s()}this.debouncedUpdateAllPositions(),this._onDidLayoutFromJSON.fire()}deserializeNestedGridview(e,t){let n=this.createNestedGridview(e.orientation),r=[];return n.deserialize(e,{fromJSON:e=>{let n=t(e.data);return r.push(n),n}}),{gridview:n,members:r}}deserializeEdgeGroups(e,t,n,r){let i=fJ(this._edgeGroupService,`EdgeGroup`,`fromJSON edge restoration`);if(i){for(let t of[`top`,`bottom`,`left`,`right`]){let n=e[t];if(n&&!i.has(t)){let e=n.group?.id??`${t}-group`;this.addEdgeGroup(t,{id:e,autoReveal:n.autoReveal,autoHide:n.autoHide,minimumSize:n.minimumSize,maximumSize:n.maximumSize,collapsedSize:n.collapsedSize})}}for(let[a,o]of i.entries()){let i=e[a]?.group;if(i){let{views:e,activeView:a,locked:s,hideHeader:c}=i;o.locked=s??!1,o.header.hidden=!!c;let l=[];for(let i of e){if(!t[i])continue;let e=n.get(i),a=r.get(i);if(a&&e)this.movingLock(()=>{a.model.removePanel(e)}),l.push(e),e.updateFromStateModel(t[i]);else{let e=this._deserializer.fromJSON(t[i],o);l.push(e)}}for(let e of l){let t=a===e.id;n.has(e.api.id)?this.movingLock(()=>{o.model.openPanel(e,{skipSetActive:!t,skipSetGroupActive:!0})}):o.model.openPanel(e,{skipSetActive:!t,skipSetGroupActive:!0})}i.tabGroups&&i.tabGroups.length>0&&o.model.restoreTabGroups(i.tabGroups),!o.activePanel&&o.panels.length>0&&o.model.openPanel(o.panels[o.panels.length-1],{skipSetGroupActive:!0})}}this._shellManager.fromJSON(e)}}deserializeFloatingWindows(e,t){for(let n of e){let{data:e,grid:r,position:i}=n;if(r){let{gridview:e,members:n}=this.deserializeNestedGridview(r,t);if(n.length===0)continue;this.mountFloatingWindow(e,n[0],n,i,{inDragMode:!1})}else if(e){let n=t(e);this.addFloatingGroup(n,{position:i,width:i.width,height:i.height,skipRemoveGroup:!0,inDragMode:!1})}}}deserializePopoutWindows(e,t){let n=e.length>0?fJ(this._popoutWindowService,`PopoutWindow`,`fromJSON popout restoration`):this._popoutWindowService;return n?e.flatMap((e,r)=>{let{data:i,grid:a,position:o,gridReferenceGroup:s,url:c}=e,l,u=[];if(a){let e=this.deserializeNestedGridview(a,t);if(l=e.gridview,u=e.members,u.length===0)return l.dispose(),[]}let d=a?u[0]:t(i);return n.scheduleRestoration(r*100,()=>this.addPopoutGroup(d,{position:o??void 0,overridePopoutGroup:s?d:void 0,overridePopoutGridview:l,referenceGroup:s?this.getPanel(s):void 0,popoutUrl:c}),()=>{for(let e of u.length>0?u:[d])if(!this.isDisposed&&this._groups.has(e.id)&&e.element.parentElement===null){for(let t of[...e.panels])this.removePanel(t,{removeEmptyGroup:!1});e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}})}):[]}clear(){this.mutation(`clear`,()=>this._doClear())}_doClear(){let e=Array.from(this._groups.values()).map(e=>e.value),t=!!this.activeGroup;for(let t of e)if(this._edgeGroupService?.includes(t)){let e=[...t.panels];for(let t of e)this.removePanel(t,{removeEmptyGroup:!1})}else this.removeGroup(t,{skipActive:!0});t&&this.doSetGroupAndPanelActive(void 0),this.gridview.clear()}closeAllGroups(){this.mutation(`remove`,()=>{let e=Array.from(this._groups.values()).map(e=>e.value);for(let t of e){if(!this._groups.has(t.id))continue;t.model.closeAllPanels();let e=this.options.noPanelsOverlay===`emptyGroup`&&this.isLastGridGroup(t);!this.closeEmptyGroups&&!e&&this._groups.has(t.id)&&t.model.size===0&&this.removeGroup(t,{skipActive:!0})}})}addPanel(e){return this.mutation(`add`,()=>this._doAddPanel(e))}addPanelFromJSON(e,t){if(!e.contentComponent)throw Error(`dockview: serialized panel ${e.id} has no contentComponent`);return this.mutation(`add`,()=>{let n=this._doAddPanel($($({},t),{},{id:e.id,component:e.contentComponent,tabComponent:e.tabComponent,title:e.title,renderer:e.renderer,params:e.params,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight}));return e.pinned&&this.setPanelPinned(n,!0),n})}_doAddPanel(e){if(this.panels.some(t=>t.id===e.id))throw Error(`dockview: panel with id ${e.id} already exists`);let t;if(e.position&&e.floating)throw Error(`dockview: you can only provide one of: position, floating as arguments to .addPanel(...)`);let n={width:e.initialWidth,height:e.initialHeight},r,i=t=>!!e.inactive&&t.model.size>0;if(e.position){if(mq(e.position)){let n=typeof e.position.referencePanel==`string`?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(r=e.position.index,!n){let t=typeof e.position.referencePanel==`string`?e.position.referencePanel:e.position.referencePanel?.id;throw Error(`dockview: referencePanel '${t}' does not exist`)}t=this.findGroup(n)}else if(hq(e.position)){if(t=typeof e.position.referenceGroup==`string`?this._groups.get(e.position.referenceGroup)?.value:e.position.referenceGroup,r=e.position.index,!t){let t=typeof e.position.referenceGroup==`string`?e.position.referenceGroup:e.position.referenceGroup?.id;throw Error(`dockview: referenceGroup '${t}' does not exist`)}}else{let t=this.orthogonalize(mK(e.position.direction)),a=this.createPanel(e,t);return t.model.openPanel(a,{skipSetActive:i(t),skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(t),t.api.setSize({height:n?.height,width:n?.width}),a}}else t=this.activeGroup;let a;if(t){let o=HG(e.position?.direction||`within`);if(e.floating){let t=this.createGroup();this._onDidAddGroup.fire(t);let n=typeof e.floating==`object`&&e.floating!==null?e.floating:{};this.addFloatingGroup(t,$($({},n),{},{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),a=this.createPanel(e,t),t.model.openPanel(a,{skipSetActive:i(t),skipSetGroupActive:e.inactive,index:r})}else if(t.api.location.type===`edge`||o===`center`)a=this.createPanel(e,t),t.model.openPanel(a,{skipSetActive:i(t),skipSetGroupActive:e.inactive,index:r}),t.api.setSize({width:n?.width,height:n?.height}),e.inactive||this.doSetGroupAndPanelActive(t);else{let s=this.getGridviewForGroup(t),c=jG(t.element),l=MG(s.orientation,c,o),u=this.createGroupAtLocation(l,this.orientationAtLocation(l,s)===`VERTICAL`?n?.height:n?.width,void 0,s);a=this.createPanel(e,u),u.model.openPanel(a,{skipSetActive:i(u),skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(u)}}else if(e.floating){let t=this.createGroup();this._onDidAddGroup.fire(t);let n=typeof e.floating==`object`&&e.floating!==null?e.floating:{};this.addFloatingGroup(t,$($({},n),{},{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),a=this.createPanel(e,t),t.model.openPanel(a,{skipSetActive:i(t),skipSetGroupActive:e.inactive,index:r})}else{let t=this.createGroupAtLocation([0],this.gridview.orientation===`VERTICAL`?n?.height:n?.width);a=this.createPanel(e,t),t.model.openPanel(a,{skipSetActive:i(t),skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(t)}return a}removePanel(e,t){this.mutation(`remove`,()=>this._doRemovePanel(e,{removeEmptyGroup:t?.removeEmptyGroup??this.closeEmptyGroups,skipDispose:t?.skipDispose,skipSetActiveGroup:t?.skipSetActiveGroup}))}_doRemovePanel(e,t){let n=e.group;if(!n)throw Error(`dockview: cannot remove panel ${e.id}. it's missing a group.`);n.model.removePanel(e,{skipSetActiveGroup:t.skipSetActiveGroup}),t.skipDispose||(e.group.model.renderContainer.detatch(e),e.dispose()),n.size===0&&t.removeEmptyGroup&&this.removeGroup(n,{skipActive:t.skipSetActiveGroup})}createWatermarkComponent(){return this.options.createWatermarkComponent?this.options.createWatermarkComponent():new nJ}addGroup(e){return this.mutation(`add`,()=>this._doAddGroup(e))}serializeGroup(e){let t={};for(let n of e.panels)t[n.id]=n.toJSON();return{group:e.model.toJSON(),panels:t}}addGroupFromJSON(e,t){return this.validateSerializedGroup(e),this.mutation(`add`,()=>this._doAddGroupFromJSON(e,t))}validateSerializedGroup(e){let t=e?.group;if(typeof t?.id!=`string`)throw TypeError(`dockview: group id must be of type string`);if(!Array.isArray(t.views))throw TypeError(`dockview: serialized group ${t.id} has no views`);for(let n of t.views){if(!e.panels?.[n])throw Error(`dockview: serialized group ${t.id} is missing panel state for ${n}`);if(this.panels.some(e=>e.id===n))throw Error(`dockview: panel with id ${n} already exists`)}}_doAddGroupFromJSON(e,t){let{id:n,locked:r,hideHeader:i,headerPosition:a,constraints:o,activeView:s,tabGroups:c}=e.group;if(t&&(t.direction??`within`)===`within`){let n=this.resolveReferenceGroup(t);if(n)return this.mergeGroupFromJSON(e,n,t)}let l={id:n,locked:r??!1,hideHeader:!!i,headerPosition:a,constraints:o,initialWidth:t?.initialWidth,initialHeight:t?.initialHeight,skipSetActive:!0},u=this.addEmptyGroupAt(l,t),d;try{d=this.deserializePanels(e,u)}catch(e){throw this.doRemoveGroup(u,{skipActive:!0}),e}for(let e of d)u.model.openPanel(e,{skipSetActive:e.id!==s,skipSetGroupActive:!0});return c&&c.length>0&&u.model.restoreTabGroups(c),!u.activePanel&&u.panels.length>0&&u.model.openPanel(u.panels[u.panels.length-1],{skipSetGroupActive:!0}),t?.skipSetActive||this.doSetGroupAndPanelActive(u),u}addEmptyGroupAt(e,t){if(t!==void 0&&(gq(t)||_q(t)||typeof t.direction==`string`))return this._doAddGroup($($({},t),e));let n=this.createGroup(e);return this.doAddGroup(n),n}deserializePanels(e,t){let n=[];try{for(let r of e.group.views)n.push(this._deserializer.fromJSON(e.panels[r],t))}catch(e){for(let e of n)e.dispose();throw e}return n}resolveReferenceGroup(e){if(gq(e)){let t=typeof e.referencePanel==`string`?e.referencePanel:e.referencePanel.id,n=this.getGroupPanel(t);if(!n)throw Error(`dockview: reference panel ${t} does not exist`);return n.group}if(_q(e)){let t=typeof e.referenceGroup==`string`?e.referenceGroup:e.referenceGroup.id,n=this.getPanel(t);if(!n)throw Error(`dockview: reference group ${t} does not exist`);return n}}mergeGroupFromJSON(e,t,n){let{activeView:r}=e.group,i=n.index;return this.deserializePanels(e,t).forEach((e,n)=>{t.model.openPanel(e,{index:i===void 0?void 0:i+n,skipSetActive:e.id!==r,skipSetGroupActive:!0})}),n.skipSetActive||this.doSetGroupAndPanelActive(t),t}_doAddGroup(e){if(e){let t;if(gq(e)){let n=typeof e.referencePanel==`string`?this.panels.find(t=>t.id===e.referencePanel):e.referencePanel,r=typeof e.referencePanel==`string`?e.referencePanel:e.referencePanel?.id;if(!n)throw Error(`dockview: reference panel ${r} does not exist`);if(t=this.findGroup(n),!t)throw Error(`dockview: reference group for reference panel ${r} does not exist`)}else if(_q(e)){if(t=typeof e.referenceGroup==`string`?this._groups.get(e.referenceGroup)?.value:e.referenceGroup,!t){let t=typeof e.referenceGroup==`string`?e.referenceGroup:e.referenceGroup?.id;throw Error(`dockview: reference group ${t} does not exist`)}}else{let t=this.orthogonalize(mK(e.direction),e);return e.skipSetActive||this.doSetGroupAndPanelActive(t),t}let n=HG(e.direction||`within`),r=this.getGridviewForGroup(t),i=jG(t.element),a=MG(r.orientation,i,n),o=this.orientationAtLocation(a,r)===`VERTICAL`?e.initialHeight:e.initialWidth,s=this.createGroupAtLocation(a,o,e,r);return e.skipSetActive||this.doSetGroupAndPanelActive(s),s}{let t=this.createGroup(e);return this.doAddGroup(t),this.doSetGroupAndPanelActive(t),t}}removeGroup(e,t){this.mutation(`remove`,()=>this.doRemoveGroup(e,t))}detachFromNestedWindow(e){let t=this._floatingGroupService?.findByGroup(e);if(t){let n=this.nestedWindowMembers(e);return n.length<=1?!1:(t.gridview.remove(e),t.group===e&&t.setAnchorGroup(n.find(t=>t!==e)),!0)}let n=this._popoutWindowService?.findByGroup(e);if(n){let t=this.nestedWindowMembers(e);return t.length<=1?!1:(n.gridview.remove(e),n.popoutGroup===e&&n.setAnchorGroup(t.find(t=>t!==e)),!0)}return!1}disposeGroupRecord(e){e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}activateFallbackGroupIfRemoved(e,t){if(!t&&this._activeGroup===e){let e=Array.from(this._groups.values());this.doSetGroupAndPanelActive(e.length>0?e[0].value:void 0)}}doRemoveGroup(e,t){if(this._edgeGroupService?.includes(e))return e;let n=[...e.panels];if(!t?.skipDispose)for(let e of n)this.removePanel(e,{removeEmptyGroup:!1,skipDispose:t?.skipDispose??!1});let r=this.activePanel;if(e.api.location.type===`floating`){let n=this._floatingGroupService?.findByGroup(e);if(!n)throw Error(`dockview: failed to find floating group`);return this.detachFromNestedWindow(e)?(t?.skipDispose?e.model.location={type:`grid`}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e):(t?.skipDispose||this.disposeGroupRecord(e),n.dispose(),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e)}if(e.api.location.type===`popout`){var i;let n=this._popoutWindowService?.findByGroup(e);if(!n)throw Error(`dockview: failed to find popout group`);if(this.detachFromNestedWindow(e))return t?.skipDispose?e.model.location={type:`grid`}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e;if(!t?.skipDispose){if(!t?.skipPopoutAssociated){let e=n.referenceGroup?this.getPanel(n.referenceGroup):void 0;e?.panels.length===0&&(this.closeEmptyGroups||!e.api.isVisible)&&this.removeGroup(e)}n.popoutGroup.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}(i=this._popoutWindowService)==null||i.remove(n);let r=n.disposable.dispose();return!t?.skipPopoutReturn&&r&&(this.doAddGroup(r,[0]),this.doSetGroupAndPanelActive(r)),this.activateFallbackGroupIfRemoved(e,t?.skipActive),n.popoutGroup}if(!this.gridview.element.contains(e.element))return t?.skipDispose||(this._groups.get(e.id)?.disposable.dispose(),this.disposeGroupRecord(e)),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e;let a=super.doRemoveGroup(e,t);return t?.skipActive||this.activePanel!==r&&this.fireActivePanelChange(this.activePanel),a}debouncedUpdateAllPositions(){this._updatePositionsFrameId!==void 0&&cancelAnimationFrame(this._updatePositionsFrameId),this._updatePositionsFrameId=requestAnimationFrame(()=>{this._updatePositionsFrameId=void 0,this.overlayRenderContainer.updateAllPositions();for(let e of this._popoutWindowService?.entries??[])e.overlayRenderContainer.updateAllPositions()})}movingLock(e){let t=this._moving;try{return this._moving=!0,e()}finally{this._moving=t}}mutation(e,t){let n=this.openMutation(e);this._syncMutationDepth++;try{return t()}finally{this._syncMutationDepth--,this._syncMutationDepth===0&&this.releaseDisposedActiveGroup(),n()}}mutationAsync(e,t){var n=this;return nG(function*(){let r=n.openMutation(e);try{return yield t()}finally{r()}})()}openMutation(e){let t=this._origin;return this._mutationDepth===0&&this._onWillMutateLayout.fire({kind:e,origin:t}),this._mutationDepth++,()=>{this._mutationDepth--,this._mutationDepth===0&&(this.releaseDisposedActiveGroup(),this.flushLocationChanges(),this._onDidMutateLayout.fire({kind:e,origin:t}))}}releaseDisposedActiveGroup(){!this.isDisposed&&this._activeGroup?.model.isDisposed&&this.activateFallbackGroupIfRemoved(this._activeGroup)}deferLocationChange(e,t){this._mutationDepth===0?t():this._pendingLocationChanges.set(e,t)}flushLocationChanges(){if(this._pendingLocationChanges.size===0)return;let e=Array.from(this._pendingLocationChanges.values());this._pendingLocationChanges.clear();for(let t of e)t()}currentOrigin(){return this._origin}withOrigin(e,t){if(this._originDepth>0||this._mutationDepth>0)return t();let n=this._origin;this._origin=e,this._originDepth++;try{return t()}finally{this._originDepth--,this._origin=n}}fireActivePanelChange(e){this._onDidActivePanelChange.fire({panel:e,origin:this._origin})}fireDidMovePanel(e,t){this._onDidMovePanel.fire({panel:e,from:t,to:e.group})}moveGroupOrPanel(e){this.mutation(`move`,()=>this._doMoveGroupOrPanel(e))}_doMoveGroupOrPanel(e){let t=e.to.group,n=e.from.groupId,r=e.from.panelId,i=e.to.position,a=e.to.index,o=n?this._groups.get(n)?.value:void 0;if(!o)throw Error(`dockview: Failed to find group id ${n}`);if(r===void 0)e.from.tabGroupId?this.moveTabGroupToGroup({sourceGroup:o,tabGroupId:e.from.tabGroupId,destinationGroup:t,destinationTarget:i,destinationIndex:a,skipSetActive:e.skipSetActive,keepEmptyGroups:e.keepEmptyGroups}):this.moveGroup({from:{group:o},to:{group:t,position:i},skipSetActive:e.skipSetActive});else if(!i||i===`center`){let n=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!n)throw Error(`dockview: No panel with id ${r}`);!this.keepEmptyGroups(e)&&o.model.size===0&&o!==t&&this.doRemoveGroup(o,{skipActive:!0});let i=t.model.size===0;this.movingLock(()=>t.model.openPanel(n,{index:a,skipSetActive:(e.skipSetActive??!1)&&!i,skipSetGroupActive:!0})),e.skipSetActive||this.doSetGroupAndPanelActive(t),this.fireDidMovePanel(n,o)}else{let n=this.getGridviewForGroup(t),a=jG(t.element),s=MG(n.orientation,a,i);if(o.size<2&&!this.keepEmptyGroups(e)){if(o===t)return;let[e,c]=cG(s);if(o.api.location.type===`grid`&&n===this.gridview){let[n,i]=cG(jG(o.element));if((this.options.dropSizing!==`distribute`||o===t)&&lG(n,e)){this.gridview.moveView(n,i,c),this.fireDidMovePanel(this.getGroupPanel(r),o);return}}if(o.api.location.type===`popout`&&this.nestedWindowMembers(o).length<=1){let e=this._popoutWindowService?.findByGroup(o);if(!e)return;let a=this.movingLock(()=>e.popoutGroup.model.removePanel(e.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(o,{skipActive:!0});let s=MG(n.orientation,jG(t.element),i),c=this.createGroupAtLocation(s,this.sizingForDrop(jG(t.element)),void 0,n);this.movingLock(()=>c.model.openPanel(a,{skipSetActive:!0})),this.doSetGroupAndPanelActive(c),this.fireDidMovePanel(this.getGroupPanel(r),o);return}if(o.api.location.type===`edge`){let e=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!e)throw Error(`dockview: No panel with id ${r}`);let t=this.createGroupAtLocation(s,this.sizingForDrop(a),void 0,n);this.movingLock(()=>t.model.openPanel(e,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(t),this.fireDidMovePanel(e,o);return}let l=this.movingLock(()=>this.doRemoveGroup(o,{skipActive:!0,skipDispose:!0})),u=jG(t.element),d=MG(n.orientation,u,i);this.movingLock(()=>this.doAddGroup(l,d,this.sizingForDrop(u),n)),this.setGroupLocationForRoot(l,n),this.doSetGroupAndPanelActive(l),this.fireDidMovePanel(this.getGroupPanel(r),o)}else{let e=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!e)throw Error(`dockview: No panel with id ${r}`);let t=MG(n.orientation,a,i),s=this.createGroupAtLocation(t,this.sizingForDrop(a),void 0,n);this.movingLock(()=>s.model.openPanel(e,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(s),this.fireDidMovePanel(e,o)}}}moveTabGroupToGroup(e){let{sourceGroup:t,tabGroupId:n,destinationGroup:r,destinationTarget:i,destinationIndex:a}=e,o=t.model.getTabGroups().find(e=>e.id===n);if(!o||o.panelIds.length===0)return;let s=o.label,c=o.color,l=o.collapsed,u=o.componentParams,d=[...o.panelIds],f=i&&i!==`center`?jG(r.element):void 0,p=this.movingLock(()=>d.map(e=>t.model.removePanel(e,{skipSetActive:!1,skipSetActiveGroup:!0})).filter(e=>e!==void 0));if(p.length===0)return;let m=n=>{this.movingLock(()=>{for(let e of p)n.model.openPanel(e,{index:a,skipSetActive:!0,skipSetGroupActive:!0})});let r=n.model.createTabGroup({label:s,color:c,collapsed:l,componentParams:u});for(let e of p)n.model.addPanelToTabGroup(r.id,e.id);e.skipSetActive||this.doSetGroupAndPanelActive(n);for(let e of p)this.fireDidMovePanel(e,t)},h;if(!i||i===`center`||!f)h=r;else{let e=this.getGridviewForGroup(r),t=MG(e.orientation,f,i);h=this.createGroupAtLocation(t,this.sizingForDrop(f),void 0,e)}!this.keepEmptyGroups(e)&&t.model.size===0&&t!==h&&this.doRemoveGroup(t,{skipActive:!0}),m(h)}moveGroup(e){this.mutation(`move`,()=>this._doMoveGroup(e))}maximizeGroup(e){this.mutation(`maximize`,()=>super.maximizeGroup(e))}exitMaximizedGroup(){this.mutation(`maximize`,()=>super.exitMaximizedGroup())}_doMoveGroup(e){let t=e.from.group,n=e.to.group,r=e.to.position;if(r===`center`&&t===n)return;let i=t,a;if(r===`center`){let r=t.activePanel,i=t.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),o=this.movingLock(()=>[...t.panels].map(e=>t.model.removePanel(e.id,{skipSetActive:!0})));t?.model.size===0&&this.doRemoveGroup(t,{skipActive:!0}),this.movingLock(()=>{for(let e of o)n.model.openPanel(e,{skipSetActive:e!==r,skipSetGroupActive:!0})}),a=o;for(let e of i){let t=n.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(let r of e.panelIds)n.model.addPanelToTabGroup(t.id,r)}e.skipSetActive===!0&&this.activePanel||this.doSetGroupAndPanelActive(n)}else{let e=(()=>{if(t.api.location.type===`edge`||n.api.location.type===`edge`)return!1;let e=this.getGridviewForGroup(t);if(e!==this.getGridviewForGroup(n))return!1;let i,a;try{i=jG(t.element),a=jG(n.element)}catch{return!1}return i.length===0||a.length===0?!1:lG(cG(i)[0],cG(a)[0])&&PG(e.orientation,a)===NG(r)})();if(t.api.location.type===`edge`){let e=t.activePanel,n=t.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),r=this.movingLock(()=>[...t.panels].map(e=>t.model.removePanel(e.id,{skipSetActive:!0})));i=this.createGroup(),this._onDidAddGroup.fire(i),this.movingLock(()=>{for(let t of r)i.model.openPanel(t,{skipSetActive:t!==e,skipSetGroupActive:!0})});for(let e of n){let t=i.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(let n of e.panelIds)i.model.addPanelToTabGroup(t.id,n)}}else switch(t.api.location.type){case`grid`:this.gridview.removeView(jG(t.element));break;case`floating`:{let e=this._floatingGroupService?.findByGroup(t);if(!e)throw Error(`dockview: failed to find floating group`);this.detachFromNestedWindow(t)||e.dispose();break}case`popout`:{var o;let e=this._popoutWindowService?.findByGroup(t);if(!e)throw Error(`dockview: failed to find popout group`);if(this.detachFromNestedWindow(t))break;if((o=this._popoutWindowService)==null||o.remove(e),e.referenceGroup){let t=this.getPanel(e.referenceGroup);t&&!t.api.isVisible&&this.doRemoveGroup(t,{skipActive:!0})}e.window.dispose();break}}if(n.api.location.type===`grid`||n.api.location.type===`floating`||n.api.location.type===`popout`){let a=this.getGridviewForGroup(n),o=jG(n.element),s=MG(a.orientation,o,r),c;c=e&&this.options.dropSizing!==`distribute`?NG(r)===`HORIZONTAL`?t.api.width:t.api.height:this.sizingForDrop(o),a.addView(i,c,s),this.setGroupLocationForRoot(i,a)}}if((a??i.panels).forEach(e=>{this.fireDidMovePanel(e,t)}),this.debouncedUpdateAllPositions(),e.skipSetActive===!1){let e=n??t;this.doSetGroupAndPanelActive(e)}else i!==t&&e.skipSetActive!==!0&&this.doSetGroupAndPanelActive(i)}doSetGroupActive(e){super.doSetGroupActive(e);let t=this.activePanel;!this._moving&&t!==this._onDidActivePanelChange.value?.panel&&this.fireActivePanelChange(t)}doSetGroupAndPanelActive(e){super.doSetGroupActive(e);let t=this.activePanel;e&&this.hasMaximizedGroup()&&!this.isMaximizedGroup(e)&&this.exitMaximizedGroup(),!this._moving&&t!==this._onDidActivePanelChange.value?.panel&&this.fireActivePanelChange(t)}getNextGroupId(){let e=this.options.groupIdGenerator;if(!e){let e=this.nextGroupId.next();for(;this._groups.has(e);)e=this.nextGroupId.next();return e}for(let t=0;t<EY;t++){let t=e();if(typeof t!=`string`||t.length===0)throw TypeError(`dockview: groupIdGenerator must return a non-empty string`);if(!this._groups.has(t))return t}throw Error(`dockview: groupIdGenerator returned an id already in use ${EY} times in a row`)}createGroup(e){e??={};let t=e?.id;t&&this._groups.has(e.id)&&(console.warn(`dockview: Duplicate group id ${e?.id}. reassigning group id to avoid errors`),t=void 0),t||=this.getNextGroupId();let n=new Yq(this,t,e);if(n.init({params:{},accessor:this}),!this._groups.has(n.id)){let e=new Y(n.model.onTabDragStart(e=>{var t;(t=this._advancedDnDService)==null||t.dispatchWillDragPanel(e)}),n.model.onGroupDragStart(e=>{var t;(t=this._advancedDnDService)==null||t.dispatchWillDragGroup(e)}),n.model.onMove(e=>{let{groupId:t,itemId:r,target:i,index:a,tabGroupId:o}=e;this.moveGroupOrPanel({from:{groupId:t,panelId:r,tabGroupId:o},to:{group:n,position:i,index:a}})}),n.model.onDidDrop(e=>{this._onDidDrop.fire(e)}),n.model.onWillDrop(e=>{var t;(t=this._advancedDnDService)==null||t.dispatchWillDrop(e)}),n.model.onWillShowOverlay(e=>{var t;this.options.disableDnd?e.preventDefault():(t=this._advancedDnDService)==null||t.dispatchWillShowOverlay(e)}),n.model.onUnhandledDragOver(e=>{this._onUnhandledDragOver.fire(e)}),n.model.onDidAddPanel(e=>{this._moving||this._onDidAddPanel.fire(e.panel)}),n.model.onDidRemovePanel(e=>{this._moving||this._onDidRemovePanel.fire(e.panel)}),n.model.onDidActivePanelChange(e=>{this._moving||e.panel===this.activePanel&&this._onDidActivePanelChange.value?.panel!==e.panel&&this.fireActivePanelChange(e.panel)}),n.model.onDidPanelTitleChange(()=>{this._bufferOnDidLayoutChange.fire(`panelTitle`)}),n.model.onDidPanelParametersChange(()=>{this._bufferOnDidLayoutChange.fire(`panelParameters`)}));this._groups.set(n.id,{value:n,disposable:e})}return n.initialize(),n}createPanel(e,t){let n=e.component,r=e.tabComponent??this.options.defaultTabComponent,i=new eJ(this,e.id,n,r),a=new Qq(e.id,n,r,this,this._api,t,i,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return a.init({title:e.title??e.id,params:e?.params??{}}),a}sizingForDrop(e){return this.options.dropSizing===`distribute`?bG.Distribute:bG.Split(e.length===0?0:e[e.length-1])}createGroupAtLocation(e,t,n,r=this.gridview){let i=this.createGroup(n);return this.doAddGroup(i,e,t,r),this.setGroupLocationForRoot(i,r),i}setGroupLocationForRoot(e,t){let n=this._popoutWindowService?.entries.find(e=>e.gridview===t);n?(e.model.renderContainer!==n.overlayRenderContainer&&(e.model.renderContainer=n.overlayRenderContainer),e.model.dropTargetContainer=n.dropTargetContainer,e.model.location={type:`popout`,getWindow:n.getWindow,popoutUrl:n.popoutUrl}):(e.model.renderContainer!==this.overlayRenderContainer&&(e.model.renderContainer=this.overlayRenderContainer),e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location=t===this.gridview?{type:`grid`}:{type:`floating`})}getGridviewForGroup(e){let t=this._floatingGroupService?.findByGroup(e);if(t)return t.gridview;let n=this._popoutWindowService?.findByGroup(e);return n?n.gridview:this.gridview}nestedWindowMembers(e){let t=this.getGridviewForGroup(e);return t===this.gridview?[]:this.groups.filter(e=>t.element.contains(e.element))}findGroup(e){return Array.from(this._groups.values()).find(t=>t.value.model.containsPanel(e))?.value}orientationAtLocation(e,t=this.gridview){let n=t.orientation;return e.length%2==1?n:FG(n)}updateTheme(){var e,t;let n=this._options.theme??Xq;(e=this._shellThemeClassnames)==null||e.setClassNames(n.className);let r=n.gap??0;this.gridview.margin=r;for(let e of this.nestedGridviews())e.margin=r;if((t=this._shellManager)==null||t.updateTheme(r,n.edgeGroupCollapsedSize??35),n.dndOverlayBorder===void 0){var i;this.element.style.removeProperty(`--dv-drag-over-border`),(i=this._shellManager)==null||i.element.style.removeProperty(`--dv-drag-over-border`)}else{var a;this.element.style.setProperty(`--dv-drag-over-border`,n.dndOverlayBorder),(a=this._shellManager)==null||a.element.style.setProperty(`--dv-drag-over-border`,n.dndOverlayBorder)}switch(n.dndOverlayMounting){case`absolute`:this.rootDropTargetContainer.disabled=!1;break;default:this.rootDropTargetContainer.disabled=!0}let o=(n.tabGroupIndicator??`wrap`)===`none`;Q(this.element,`dv-tab-group-indicator-none`,o),this._shellManager&&Q(this._shellManager.element,`dv-tab-group-indicator-none`,o);for(let e of this.groups)e.model.updateTabGroups()}},OY=class extends UG{get orientation(){return this.gridview.orientation}set orientation(e){this.gridview.orientation=e}get options(){return this._options}get deserializer(){return this._deserializer}set deserializer(e){this._deserializer=e}constructor(e,t){super(e,{proportionalLayout:t.proportionalLayout??!0,orientation:t.orientation,styles:t.hideBorders?{separatorBorder:`transparent`}:void 0,disableAutoResizing:t.disableAutoResizing,className:t.className}),this._onDidLayoutfromJSON=new X,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new X,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new X,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new X,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._options=t,this.addDisposables(this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this.onDidAdd(e=>{this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._onDidActiveGroupChange.fire(e)})),this.layoutFromElement()}updateOptions(e){super.updateOptions(e);let t=typeof e.orientation==`string`&&this.gridview.orientation!==e.orientation;this._options=$($({},this.options),e),t&&(this.gridview.orientation=e.orientation),this.layout(this.gridview.width,this.gridview.height,!0)}removePanel(e){this.removeGroup(e)}toJSON(){return{grid:this.gridview.serialize(),activePanel:this.activeGroup?.id}}setVisible(e,t){this.gridview.setViewVisible(jG(e.element),t)}setActive(e){this._groups.forEach((t,n)=>{t.value.setActive(e===t.value)})}focus(){var e;(e=this.activeGroup)==null||e.focus()}fromJSON(e){this.clear();let{grid:t,activePanel:n}=e;try{let e=[],r=this.width,i=this.height;if(this.gridview.deserialize(t,{fromJSON:t=>{let{data:n}=t,r=this.options.createComponent({id:n.id,name:n.component});return e.push(()=>r.init({params:n.params,minimumWidth:n.minimumWidth,maximumWidth:n.maximumWidth,minimumHeight:n.minimumHeight,maximumHeight:n.maximumHeight,priority:n.priority,snap:!!n.snap,accessor:this,isVisible:t.visible})),this._onDidAddGroup.fire(r),this.registerPanel(r),r}}),this.layout(r,i,!0),e.forEach(e=>e()),typeof n==`string`){let e=this.getPanel(n);e&&this.doSetGroupActive(e)}}catch(e){for(let e of this.groups)e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e);throw this.clear(),e}this._onDidLayoutfromJSON.fire()}clear(){let e=this.activeGroup,t=Array.from(this._groups.values());for(let e of t)e.disposable.dispose(),this.doRemoveGroup(e.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){let n=this._groups.get(t.reference)?.value;if(!n)throw Error(`reference group ${t.reference} does not exist`);let r=HG(t.direction);if(r===`center`)throw Error(`${r} not supported as an option`);let i=jG(n.element),a=MG(this.gridview.orientation,i,r),o=this.gridview.remove(e);this.doAddGroup(o,a,t.size)}addPanel(e){let t=e.location??[0];if(e.position?.referencePanel){let n=this._groups.get(e.position.referencePanel)?.value;if(!n)throw Error(`reference group ${e.position.referencePanel} does not exist`);let r=HG(e.position.direction);if(r===`center`)throw Error(`${r} not supported as an option`);{let e=jG(n.element);t=MG(this.gridview.orientation,e,r)}}let n=this.options.createComponent({id:e.id,name:e.component});return n.init({params:e.params??{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.doAddGroup(n,t,e.size),this.registerPanel(n),this.doSetGroupActive(n),n}registerPanel(e){let t=new Y(e.api.onDidFocusChange(t=>{t.isFocused&&this._groups.forEach(t=>{let n=t.value;n.setActive(n===e)})}));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,n){let r=this.getPanel(t);if(!r)throw Error(`invalid operation`);let i=jG(e.element),[a,o]=cG(MG(this.gridview.orientation,i,n)),[s,c]=cG(jG(r.element));if(lG(s,a)){this.gridview.moveView(s,c,o);return}let l=this.doRemoveGroup(r,{skipActive:!0,skipDispose:!0}),u=jG(e.element),d=MG(this.gridview.orientation,u,n);this.doAddGroup(l,d)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}},kY=class extends BG{get panels(){return this.splitview.getViews()}get options(){return this._options}get length(){return this._panels.size}get orientation(){return this.splitview.orientation}get splitview(){return this._splitview}set splitview(e){this._splitview&&this._splitview.dispose(),this._splitview=e,this._splitviewChangeDisposable.value=new Y(this._splitview.onDidSashEnd(()=>{this._onDidLayoutChange.fire({reasons:new Set([`geometry`])})}),this._splitview.onDidAddView(e=>this._onDidAddView.fire(e)),this._splitview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===`HORIZONTAL`?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===`HORIZONTAL`?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._splitviewChangeDisposable=new hW,this._panels=new Map,this._onDidLayoutfromJSON=new X,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new X,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new X,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new X,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height=`100%`,this.element.style.width=`100%`,this._classNames=new KW(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this._options=t,this.splitview=new xG(this.element,t),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange),this.layoutFromElement()}updateOptions(e){if(`className`in e&&this._classNames.setClassNames(e.className??``),`disableAutoResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),typeof e.orientation==`string`&&e.orientation!==this.splitview.orientation){this.splitview.orientation=e.orientation;for(let t of this.panels)t.orientation=e.orientation}this._options=$($({},this.options),e),this.splitview.layout(this.splitview.size,this.splitview.orthogonalSize)}focus(){var e;(e=this._activePanel)==null||e.focus()}movePanel(e,t){this.splitview.moveView(e,t)}setVisible(e,t){let n=this.panels.indexOf(e);this.splitview.setViewVisible(n,t)}setActive(e,t){this._activePanel=e,this.panels.filter(t=>t!==e).forEach(e=>{e.api._onDidActiveChange.fire({isActive:!1}),t||e.focus()}),e.api._onDidActiveChange.fire({isActive:!0}),t||e.focus()}removePanel(e,t){let n=this._panels.get(e.id);if(!n)throw Error(`unknown splitview panel ${e.id}`);n.dispose(),this._panels.delete(e.id);let r=this.panels.indexOf(e);this.splitview.removeView(r,t).dispose();let i=this.panels;i.length>0&&this.setActive(i[i.length-1])}getPanel(e){return this.panels.find(t=>t.id===e)}addPanel(e){if(this._panels.has(e.id))throw Error(`panel ${e.id} already exists`);let t=this.options.createComponent({id:e.id,name:e.component});t.orientation=this.splitview.orientation,t.init({params:e.params??{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});let n=typeof e.size==`number`?e.size:bG.Distribute,r=typeof e.index==`number`?e.index:void 0;return this.splitview.addView(t,n,r),this.doAddView(t),this.setActive(t),t}layout(e,t){let[n,r]=this.splitview.orientation===`HORIZONTAL`?[e,t]:[t,e];this.splitview.layout(n,r)}doAddView(e){let t=e.api.onDidFocusChange(t=>{t.isFocused&&this.setActive(e,!0)});this._panels.set(e.id,t)}toJSON(){return{views:this.splitview.getViews().map((e,t)=>{let n=this.splitview.getViewCachedVisibleSize(t),r=typeof n==`number`;return $({size:r?n:this.splitview.getViewSize(t),data:e.toJSON(),snap:!!e.snap,priority:e.priority},r?{visible:!1}:{})}),activeView:this._activePanel?.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();let{views:t,orientation:n,size:r,activeView:i}=e,a=[],o=this.width,s=this.height;if(this.splitview=new xG(this.element,{orientation:n,proportionalLayout:this.options.proportionalLayout,descriptor:{size:r,views:t.map(e=>{let t=e.data;if(this._panels.has(t.id))throw Error(`panel ${t.id} already exists`);let r=this.options.createComponent({id:t.id,name:t.component});return a.push(()=>{r.init({params:t.params??{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:e.snap,priority:e.priority,accessor:this}),e.visible===!1&&r.setVisible(!1)}),r.orientation=n,this.doAddView(r),setTimeout(()=>{this._onDidAddView.fire(r)},0),{size:e.size,view:r,visible:e.visible}})}}),this.layout(o,s),a.forEach(e=>e()),typeof i==`string`){let e=this.getPanel(i);e&&this.setActive(e)}this._onDidLayoutfromJSON.fire()}clear(){for(let e of this._panels.values())e.dispose();for(this._panels.clear();this.splitview.length>0;)this.splitview.removeView(0,bG.Distribute,!0).dispose()}dispose(){for(let e of this._panels.values())e.dispose();this._panels.clear();let e=this.splitview.getViews();this._splitviewChangeDisposable.dispose(),this.splitview.dispose();for(let t of e)t.dispose();this.element.remove(),super.dispose()}},AY=class extends Y{get element(){return this._element}constructor(){super(),this._expandedIcon=YK(),this._collapsedIcon=XK(),this.disposable=new hW,this.apiRef={api:null},this._element=document.createElement(`div`),this.element.className=`dv-default-header`,this._content=document.createElement(`span`),this._expander=document.createElement(`div`),this._expander.className=`dv-pane-header-icon`,this.element.appendChild(this._expander),this.element.appendChild(this._content),this.addDisposables(Z(this._element,`click`,()=>{var e;(e=this.apiRef.api)==null||e.setExpanded(!this.apiRef.api.isExpanded)}))}init(e){this.apiRef.api=e.api,this._content.textContent=e.title,this.updateIcon(),this.disposable.value=e.api.onDidExpansionChange(()=>{this.updateIcon()})}updateIcon(){let e=!!this.apiRef.api?.isExpanded;Q(this._expander,`collapsed`,!e),e?(this._expander.contains(this._collapsedIcon)&&this._collapsedIcon.remove(),this._expander.contains(this._expandedIcon)||this._expander.appendChild(this._expandedIcon)):(this._expander.contains(this._expandedIcon)&&this._expandedIcon.remove(),this._expander.contains(this._collapsedIcon)||this._expander.appendChild(this._collapsedIcon))}update(e){}dispose(){this.disposable.dispose(),super.dispose()}},jY=hG(),MY=22,NY=0,PY=2**53-1,FY=class extends HK{constructor(e){super({accessor:e.accessor,id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,disableDnd:e.disableDnd,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}},IY=class extends BG{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new Y(this._paneview.onDidChange(()=>{this._onDidLayoutChange.fire({reasons:new Set([`geometry`])})}),this._paneview.onDidAddView(e=>this._onDidAddView.fire(e)),this._paneview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===`HORIZONTAL`?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===`HORIZONTAL`?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._id=jY.next(),this._disposable=new hW,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new X,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new X,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new X,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new X,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new X,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOver=new X,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.element.style.height=`100%`,this.element.style.width=`100%`,this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView,this._onUnhandledDragOver),this._classNames=new KW(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this._options=t,this.paneview=new CG(this.element,{orientation:`VERTICAL`}),this.addDisposables(this._disposable)}setVisible(e,t){let n=this.panels.indexOf(e);this.paneview.setViewVisible(n,t)}focus(){}updateOptions(e){`className`in e&&this._classNames.setClassNames(e.className??``),`disableAutoResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),this._options=$($({},this.options),e)}addPanel(e){let t=this.options.createComponent({id:e.id,name:e.component}),n;e.headerComponent&&this.options.createHeaderComponent&&(n=this.options.createHeaderComponent({id:e.id,name:e.headerComponent})),n??=new AY;let r=new FY({id:e.id,component:e.component,headerComponent:e.headerComponent,header:n,body:t,orientation:`VERTICAL`,isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:e.headerSize??MY,minimumBodySize:NY,maximumBodySize:PY});this.doAddPanel(r);let i=typeof e.size==`number`?e.size:bG.Distribute,a=typeof e.index==`number`?e.index:void 0;return r.init({params:e.params??{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new eK(this),accessor:this}),this.paneview.addPane(r,i,a),r.orientation=this.paneview.orientation,r}removePanel(e){let t=this.panels.indexOf(e);if(t<0)throw Error(`unknown paneview panel ${e.id}`);this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find(t=>t.id===e)}layout(e,t){let[n,r]=this.paneview.orientation===`HORIZONTAL`?[e,t]:[t,e];this.paneview.layout(n,r)}toJSON(){let e=e=>e===2**53-1||e===1/0?void 0:e,t=e=>e<=0?void 0:e;return{views:this.paneview.getPanes().map((n,r)=>{let i=this.paneview.getViewCachedVisibleSize(r),a=typeof i==`number`;return $({size:a?i:this.paneview.getViewSize(r),data:n.toJSON(),minimumSize:t(n.minimumBodySize),maximumSize:e(n.maximumBodySize),headerSize:n.headerSize,expanded:n.isExpanded()},a?{visible:!1}:{})}),size:this.paneview.size}}fromJSON(e){this.clear();let{views:t,size:n}=e,r=[],i=this.width,a=this.height;this.paneview.dispose(),this.paneview=new CG(this.element,{orientation:`VERTICAL`,descriptor:{size:n,views:t.map(e=>{let t=e.data,n=this.options.createComponent({id:t.id,name:t.component}),i;t.headerComponent&&this.options.createHeaderComponent&&(i=this.options.createHeaderComponent({id:t.id,name:t.headerComponent})),i??=new AY;let a=new FY({id:t.id,component:t.component,headerComponent:t.headerComponent,header:i,body:n,orientation:`VERTICAL`,isExpanded:!!e.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:e.headerSize??MY,minimumBodySize:e.minimumSize??NY,maximumBodySize:e.maximumSize??PY});return this.doAddPanel(a),r.push(()=>{a.init({params:t.params??{},minimumBodySize:e.minimumSize,maximumBodySize:e.maximumSize,title:t.title,isExpanded:!!e.expanded,containerApi:new eK(this),accessor:this}),a.orientation=this.paneview.orientation,e.visible===!1&&a.setVisible(!1)}),setTimeout(()=>{this._onDidAddView.fire(a)},0),{size:e.size,view:a,visible:e.visible}})}}),this.layout(i,a),r.forEach(e=>e()),this._onDidLayoutfromJSON.fire()}clear(){for(let[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear();let e=this.width,t=this.height;this.paneview.dispose(),this.paneview=new CG(this.element,{orientation:`VERTICAL`}),this.layout(e,t)}doAddPanel(e){let t=new Y(e.onDidDrop(e=>{this._onDidDrop.fire(e)}),e.onUnhandledDragOver(e=>{this._onUnhandledDragOver.fire(e)}));this._viewDisposables.set(e.id,t)}doRemovePanel(e){let t=this._viewDisposables.get(e.id);t&&(t.dispose(),this._viewDisposables.delete(e.id))}dispose(){super.dispose();for(let[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.element.remove(),this.paneview.dispose()}},LY=class extends BK{get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){let e=typeof this._minimumSize==`function`?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){let e=typeof this._maximumSize==`function`?this._maximumSize():this._maximumSize;return e!==this._evaluatedMaximumSize&&(this._evaluatedMaximumSize=e,this.updateConstraints()),e}get snap(){return this._snap}constructor(e,t){super(e,t,new RK(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=1/0,this._minimumSize=0,this._maximumSize=1/0,this._snap=!1,this._onDidChange=new X,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onActiveChange(()=>{let{accessor:e}=this._params;e.setActive(this)}),this.api.onDidConstraintsChangeInternal(e=>{(typeof e.minimumSize==`number`||typeof e.minimumSize==`function`)&&(this._minimumSize=e.minimumSize),(typeof e.maximumSize==`number`||typeof e.maximumSize==`function`)&&(this._maximumSize=e.maximumSize),this.updateConstraints()}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(e,t){let[n,r]=this.orientation===`HORIZONTAL`?[e,t]:[t,e];super.layout(n,r)}init(e){super.init(e),this._priority=e.priority,e.minimumSize&&(this._minimumSize=e.minimumSize),e.maximumSize&&(this._maximumSize=e.maximumSize),e.snap&&(this._snap=e.snap)}toJSON(){return $($({},super.toJSON()),{},{minimumSize:(e=>e<=0?void 0:e)(this.minimumSize),maximumSize:(e=>e===2**53-1||e===1/0?void 0:e)(this.maximumSize)})}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}};function RY(e,t){return new DY(e,t).api}function zY(e,t){return new $G(new kY(e,t))}function BY(e,t){return new tK(new OY(e,t))}function VY(e,t){return new eK(new IY(e,t))}function HY(e){"@babel/helpers - typeof";return HY=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},HY(e)}function UY(e,t){if(HY(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(HY(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function WY(e){var t=UY(e,`string`);return HY(t)==`symbol`?t:t+``}function GY(e,t,n){return(t=WY(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function KY(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 qY(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?KY(Object(n),!0).forEach(function(t){GY(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):KY(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var JY=(e,t)=>{let[,n]=V.useState(0),r=V.useRef(e.componentProps);return V.useImperativeHandle(t,()=>({update:e=>{r.current=qY(qY({},r.current),e),n(e=>e+1)}}),[]),V.createElement(e.component,r.current)};JY.displayName=`DockviewReactJsBridge`;var YY=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),XY=V.createContext({}),ZY=class{constructor(e,t,n,r,i){this.parent=e,this.portalStore=t,this.component=n,this.parameters=r,this.context=i,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw Error(`invalid operation: resource is already disposed`);this.componentInstance?this.componentInstance.update(e):this._initialProps=qY(qY({},this._initialProps),e)}createPortal(){if(this.disposed)throw Error(`invalid operation: resource is already disposed`);if(!$Y(this.component))throw Error(`Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components`);let e=V.createElement(V.forwardRef(JY),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?V.createElement(XY.Provider,{value:this.context},e):e,n=Xf.createPortal(t,this.parent,YY.next());this.ref={portal:n,disposable:this.portalStore.addPortal(n)}}dispose(){var e;(e=this.ref)==null||e.disposable.dispose(),this.disposed=!0}},QY=()=>{let[e,t]=V.useState([]);return V.useDebugValue(`Portal count: ${e.length}`),[e,V.useCallback(e=>{t(t=>[...t,e]);let n=!1;return mW.from(()=>{if(n)throw Error(`invalid operation: resource already disposed`);n=!0,t(t=>t.filter(t=>t!==e))})},[])]};function $Y(e){return typeof e==`function`||!!e?.$$typeof}function eX(e,t){let n=e=>e instanceof ShadowRoot?e.host:e.parentNode,r=new Set,i=new MutationObserver(n=>{if(!e.isConnected)i.disconnect(),t();else for(let e of n)for(let t of e.removedNodes)if(r.has(t)){a();return}}),a=()=>{i.disconnect(),r.clear();for(let t=n(e);t;t=n(t))r.add(t),i.observe(t,{childList:!0})};return a(),mW.from(()=>i.disconnect())}var tX=Number.parseInt(`19.3.1`,10)>=18;function nX(e,t,n){let r=V.useRef(void 0);V.useEffect(()=>{var i;let a=e.current;if(!a)return;(i=r.current)==null||i.dispose(),r.current=void 0;let o=t.current??n(a);return t.current=o,()=>{let e=()=>{r.current=void 0,t.current=void 0,o.dispose()};tX&&a.isConnected&&typeof MutationObserver<`u`?r.current=eX(a,e):e()}},[])}function rX(e){let t=V.useRef({instance:void 0,values:new Map});return V.useCallback(n=>{t.current.instance!==e.current&&(t.current={instance:e.current,values:new Map});let r=t.current.values,i=!0;for(let[e,t]of Object.entries(n))r.has(e)&&r.get(e)!==t&&(i=!1),r.set(e,t);return i},[e])}var iX=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._onDidFocus=new X,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new X,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}focus(){}init(e){this.part=new ZY(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;(t=this.part)==null||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),(e=this.part)==null||e.dispose()}},aX=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}focus(){}init(e){this.part=new ZY(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;(t=this.part)==null||t.update({params:e.params})}layout(e,t){}dispose(){var e;(e=this.part)==null||e.dispose()}},oX=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new ZY(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t;this.parameters&&(this.parameters.params=e.params),(t=this.part)==null||t.update({params:this.parameters?.params??{}})}layout(e,t){}dispose(){var e;(e=this.part)==null||e.dispose()}},sX=class{get element(){return this._element}get part(){return this._part}constructor(e,t,n){this.component=e,this.reactPortalStore=t,this._group=n,this.mutableDisposable=new hW,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.mutableDisposable.value=new Y(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),e.api.onDidActiveChange(()=>{this.updateGroupActive()}),e.api.onDidLocationChange(e=>{this.updateLocation(e.location)})),this._part=new ZY(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:e.api.location})}dispose(){var e;this.mutableDisposable.dispose(),(e=this._part)==null||e.dispose()}update(e){var t;(t=this._part)==null||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}},cX=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new ZY(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;(e=this.part)==null||e.dispose()}},lX=class{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.display=`inline-flex`}init(e){this.part=new ZY(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;(t=this.part)==null||t.update({tabGroup:e.tabGroup})}dispose(){var e;(e=this.part)==null||e.dispose()}},uX=class{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.display=`inline-flex`}init(e){this.part=new ZY(this._element,this.reactPortalStore,this.component,{group:e.group,api:e.api})}dispose(){var e;(e=this.part)==null||e.dispose()}};function dX(e,t){return e?n=>new sX(e,t,n):void 0}var fX=`props.defaultTabComponent`;function pX(e){return pq.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var mX=V.forwardRef((e,t)=>{let n=V.useRef(null),r=V.useRef(void 0),[i,a]=QY(),o=rX(r);V.useImperativeHandle(t,()=>n.current,[]);let s=V.useRef({});return V.useEffect(()=>{let t={};pq.forEach(n=>{let r=n,i=e[r];r in e&&i!==s.current[r]&&(t[r]=i)}),r.current&&Object.keys(t).length>0&&r.current.updateOptions(t),s.current=e},pq.map(t=>e[t])),nX(n,r,t=>{let n=qY({},e.tabComponents);e.defaultTabComponent&&(n[fX]=e.defaultTabComponent);let r={createLeftHeaderActionComponent:dX(e.leftHeaderActionsComponent,{addPortal:a}),createRightHeaderActionComponent:dX(e.rightHeaderActionsComponent,{addPortal:a}),createPrefixHeaderActionComponent:dX(e.prefixHeaderActionsComponent,{addPortal:a}),createComponent:t=>new iX(t.id,e.components[t.name],{addPortal:a}),createTabComponent(e){return new aX(e.id,n[e.name],{addPortal:a})},createWatermarkComponent:e.watermarkComponent?()=>new oX(`watermark`,e.watermarkComponent,{addPortal:a}):void 0,defaultTabComponent:e.defaultTabComponent?fX:void 0,createContextMenuItemComponent:e=>{if(e.component)return new cX(e.id,e.component,{addPortal:a})}},i=pX(e);if(e.tabGroupChipComponent){let t=e.tabGroupChipComponent;i.createTabGroupChipComponent=()=>new lX(t,{addPortal:a})}if(e.groupDragGhostComponent){let t=e.groupDragGhostComponent;i.createGroupDragGhostComponent=()=>new uX(t,{addPortal:a})}let o=RY(t,qY(qY({},i),r)),{clientWidth:s,clientHeight:c}=t;return o.layout(s,c),e.onReady&&e.onReady({api:o}),o}),V.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),V.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onWillDrop(t=>{e.onWillDrop&&e.onWillDrop(t)});return()=>{t.dispose()}},[e.onWillDrop]),V.useEffect(()=>{r.current&&!o({tabGroupChipComponent:e.tabGroupChipComponent})&&r.current.updateOptions({createTabGroupChipComponent:e.tabGroupChipComponent?()=>new lX(e.tabGroupChipComponent,{addPortal:a}):void 0})},[e.tabGroupChipComponent]),V.useEffect(()=>{r.current&&!o({groupDragGhostComponent:e.groupDragGhostComponent})&&r.current.updateOptions({createGroupDragGhostComponent:e.groupDragGhostComponent?()=>new uX(e.groupDragGhostComponent,{addPortal:a}):void 0})},[e.groupDragGhostComponent]),V.useEffect(()=>{r.current&&!o({components:e.components})&&r.current.updateOptions({createComponent:t=>new iX(t.id,e.components[t.name],{addPortal:a})})},[e.components]),V.useEffect(()=>{if(!r.current||o({tabComponents:e.tabComponents,defaultTabComponent:e.defaultTabComponent}))return;let t=qY({},e.tabComponents);e.defaultTabComponent&&(t[fX]=e.defaultTabComponent),r.current.updateOptions({defaultTabComponent:e.defaultTabComponent?fX:void 0,createTabComponent(e){return new aX(e.id,t[e.name],{addPortal:a})}})},[e.tabComponents,e.defaultTabComponent]),V.useEffect(()=>{r.current&&!o({watermarkComponent:e.watermarkComponent})&&r.current.updateOptions({createWatermarkComponent:e.watermarkComponent?()=>new oX(`watermark`,e.watermarkComponent,{addPortal:a}):void 0})},[e.watermarkComponent]),V.useEffect(()=>{r.current&&!o({rightHeaderActionsComponent:e.rightHeaderActionsComponent})&&r.current.updateOptions({createRightHeaderActionComponent:dX(e.rightHeaderActionsComponent,{addPortal:a})})},[e.rightHeaderActionsComponent]),V.useEffect(()=>{r.current&&!o({leftHeaderActionsComponent:e.leftHeaderActionsComponent})&&r.current.updateOptions({createLeftHeaderActionComponent:dX(e.leftHeaderActionsComponent,{addPortal:a})})},[e.leftHeaderActionsComponent]),V.useEffect(()=>{r.current&&!o({prefixHeaderActionsComponent:e.prefixHeaderActionsComponent})&&r.current.updateOptions({createPrefixHeaderActionComponent:dX(e.prefixHeaderActionsComponent,{addPortal:a})})},[e.prefixHeaderActionsComponent]),V.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});mX.displayName=`DockviewComponent`;var hX=class extends LY{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){return new ZY(this.element,this.reactPortalStore,this.reactComponent,{params:this._params?.params??{},api:this.api,containerApi:new $G(this._params.accessor)})}};function gX(e){return SG.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var _X=V.forwardRef((e,t)=>{let n=V.useRef(null),r=V.useRef(void 0),[i,a]=QY(),o=rX(r);V.useImperativeHandle(t,()=>n.current,[]);let s=V.useRef({});return V.useEffect(()=>{let t={};SG.forEach(n=>{let r=n,i=e[r];r in e&&i!==s.current[r]&&(t[r]=i)}),r.current&&Object.keys(t).length>0&&r.current.updateOptions(t),s.current=e},SG.map(t=>e[t])),nX(n,r,t=>{let n=zY(t,qY(qY({},gX(e)),{createComponent:t=>new hX(t.id,t.name,e.components[t.name],{addPortal:a})})),{clientWidth:r,clientHeight:i}=t;return n.layout(r,i),e.onReady&&e.onReady({api:n}),n}),V.useEffect(()=>{r.current&&!o({components:e.components})&&r.current.updateOptions({createComponent:t=>new hX(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),V.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});_X.displayName=`SplitviewComponent`;var vX=class extends Wq{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){return new ZY(this.element,this.reactPortalStore,this.reactComponent,{params:this._params?.params??{},api:this.api,containerApi:new tK(this._params.accessor)})}};function yX(e){return zG.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var bX=V.forwardRef((e,t)=>{let n=V.useRef(null),r=V.useRef(void 0),[i,a]=QY(),o=rX(r);V.useImperativeHandle(t,()=>n.current,[]);let s=V.useRef({});return V.useEffect(()=>{let t={};zG.forEach(n=>{let r=n,i=e[r];r in e&&i!==s.current[r]&&(t[r]=i)}),r.current&&Object.keys(t).length>0&&r.current.updateOptions(t),s.current=e},zG.map(t=>e[t])),nX(n,r,t=>{let n=BY(t,qY(qY({},yX(e)),{createComponent:t=>new vX(t.id,t.name,e.components[t.name],{addPortal:a})})),{clientWidth:r,clientHeight:i}=t;return n.layout(r,i),e.onReady&&e.onReady({api:n}),n}),V.useEffect(()=>{r.current&&!o({components:e.components})&&r.current.updateOptions({createComponent:t=>new vX(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),V.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});bX.displayName=`GridviewComponent`;var xX=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new ZY(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;(t=this.part)==null||t.update({params:e.params})}dispose(){var e;(e=this.part)==null||e.dispose()}};function SX(e){return PK.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var CX=V.forwardRef((e,t)=>{let n=V.useRef(null),r=V.useRef(void 0),[i,a]=QY(),o=rX(r);V.useImperativeHandle(t,()=>n.current,[]);let s=V.useRef({});return V.useEffect(()=>{let t={};PK.forEach(n=>{let r=n,i=e[r];r in e&&i!==s.current[r]&&(t[r]=i)}),r.current&&Object.keys(t).length>0&&r.current.updateOptions(t),s.current=e},PK.map(t=>e[t])),nX(n,r,t=>{let n=e.headerComponents??{},r=VY(t,qY(qY({},SX(e)),{createComponent:t=>new xX(t.id,e.components[t.name],{addPortal:a}),createHeaderComponent:e=>new xX(e.id,n[e.name],{addPortal:a})})),{clientWidth:i,clientHeight:o}=t;return r.layout(i,o),e.onReady&&e.onReady({api:r}),r}),V.useEffect(()=>{r.current&&!o({components:e.components})&&r.current.updateOptions({createComponent:t=>new xX(t.id,e.components[t.name],{addPortal:a})})},[e.components]),V.useEffect(()=>{if(!r.current||o({headerComponents:e.headerComponents}))return;let t=e.headerComponents??{};r.current.updateOptions({createHeaderComponent:e=>new xX(e.id,t[e.name],{addPortal:a})})},[e.headerComponents]),V.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),V.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});CX.displayName=`PaneviewComponent`;var wX={dock:`_dock_psx21_10`,tab:`_tab_psx21_155`,buttons:`_buttons_psx21_178`,body:`_body_psx21_189`,heading:`_heading_psx21_197`,none:`_none_psx21_209`},TX=({label:e,shortcut:t,onClick:n,children:r})=>{let i=ET();return(0,G.jsx)(cb,{"aria-keyshortcuts":bT(t,i),keys:yT(t,i),label:e,onClick:n,children:r})},EX=({group:e,activePanel:t,workspace:n})=>{ab(n.view);let r=t?.title??`panel`,i=t!==void 0&&tW(t.id)?t.id:void 0,a=e.api.location.type===`floating`,o=e.api.isMaximized();return(0,G.jsxs)(`div`,{className:wX.buttons,children:[(0,G.jsx)(TX,{label:`Minimize ${r}`,onClick:()=>{n.minimize(i)},shortcut:CT.minimize,children:(0,G.jsx)(ay,{})}),a?null:(0,G.jsx)(TX,{label:o?`Restore ${r}`:`Maximize ${r}`,onClick:()=>{n.toggleMaximize(e)},shortcut:CT.maximize,children:o?(0,G.jsx)(sy,{}):(0,G.jsx)(oy,{})}),(0,G.jsx)(TX,{label:a?`Dock ${r}`:`Float ${r}`,onClick:()=>{n.toggleFloat(e)},shortcut:CT.float,children:a?(0,G.jsx)(ly,{}):(0,G.jsx)(cy,{})}),(0,G.jsx)(TX,{label:`Close ${r}`,onClick:()=>{n.close(i)},shortcut:CT.close,children:(0,G.jsx)(Jv,{})})]})},DX=e=>{let t=(0,V.use)(ZM);return t===null?null:(0,G.jsx)(EX,{...e,workspace:t})},OX=6,kX=({api:e})=>{let t=tW(e.id)?nW(e.id).Icon:null;return(0,G.jsxs)(`span`,{className:wX.tab,children:[t===null?null:(0,G.jsx)(t,{}),e.title]})},AX=()=>(0,G.jsx)(`div`,{className:wX.none,children:(0,G.jsx)(CC,{title:`No panels open.`,children:`Reopen one from Window, or press the command palette's keys.`})}),jX=Object.fromEntries(eW.map(({id:e,title:t,Body:n})=>[e,()=>(0,G.jsxs)(`div`,{className:wX.body,children:[(0,G.jsx)(`h2`,{className:wX.heading,children:t}),(0,G.jsx)(n,{})]})])),MX={name:`ork`,className:wX.dock??``,gap:OX,dndOverlayMounting:`relative`,dndPanelOverlay:`group`,dndTabIndicator:`line`},NX=({workspace:e})=>{let t=(0,V.useCallback)(({api:t})=>{e.attach(t)},[e]);return(0,V.useEffect)(()=>()=>{e.detach()},[e]),(0,G.jsx)(mX,{announcer:({message:t})=>{e.announceFromDock(t)},components:jX,defaultTabComponent:kX,disableTabsOverflowList:!0,onReady:t,rightHeaderActionsComponent:DX,theme:MX,watermarkComponent:AX})},PX=`(min-width: 64rem)`,FX=(e,t,n)=>{let r=e?.panels??[],i=e?.activePanel?.id;return{wide:n,open:eW.map(e=>e.id).filter(e=>r.some(t=>t.id===e)),minimized:t.minimized.map(e=>e.id),folded:t.folded,active:i!==void 0&&tW(i)?i:null,floating:e?.activePanel?.group.api.location.type===`floating`,maximized:e?.hasMaximizedGroup()??!1}},IX=(e,t)=>JSON.stringify(e)===JSON.stringify(t),LX=e=>`stack-${e}`,RX=e=>`rail-${e}`,zX=e=>{document.querySelector(`#${e}`)?.focus()},BX=({workspace:e})=>{let{minimized:t}=ab(e.view);return t.length===0?null:(0,G.jsx)(`nav`,{"aria-label":`Minimized panels`,className:kT.rail,children:t.map(t=>{let{title:n,Icon:r}=nW(t);return(0,G.jsx)(cb,{id:RX(t),label:`Restore ${n}`,onClick:()=>{e.restore(t)},children:(0,G.jsx)(r,{})},t)})})},VX=({workspace:e})=>{let{folded:t}=ab(e.view);return(0,G.jsx)(`div`,{className:kT.stack,children:eW.map(({id:n,title:r,Icon:i,Body:a})=>{let o=!t.includes(n),s=`${LX(n)}-body`;return(0,G.jsxs)(`section`,{"aria-labelledby":LX(n),className:kT.stacked,children:[(0,G.jsx)(`h2`,{className:kT.stackedHeading,children:(0,G.jsxs)(`button`,{"aria-controls":o?s:void 0,"aria-expanded":o,className:kT.stackedButton,id:LX(n),onClick:()=>{e.toggleFold(n)},type:`button`,children:[o?(0,G.jsx)(Xv,{}):(0,G.jsx)(Zv,{}),(0,G.jsx)(i,{}),r]})}),o?(0,G.jsx)(`div`,{className:kT.stackedBody,id:s,children:(0,G.jsx)(a,{})}):null]},n)})})},HX=e=>{(0,V.useEffect)(()=>{let t=window.matchMedia(PX),n=()=>{e.setWide(t.matches)};return n(),t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}},[e])},UX=({workspace:e})=>{let{wide:t}=ab(e.view);return HX(e),(0,G.jsx)(`main`,{className:kT.middle,children:t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(BX,{workspace:e}),(0,G.jsx)(`div`,{className:kT.dockArea,children:(0,G.jsx)(NX,{workspace:e})})]}):(0,G.jsx)(VX,{workspace:e})})},WX=`ork-new-version-action`,GX=(e,t,n)=>e?.version===t&&n-Date.parse(e.at)<864e5,KX=(e,t,n)=>{let{job:r}=e;if(r!==null)return r.state===`running`?{kind:`running`,latest:r.latest}:GX(t,r.latest,n)?null:r.state===`succeeded`?{kind:`installed`,latest:r.latest,current:e.current}:{kind:`failed`,latest:r.latest,code:r.code??1}},qX=({info:e,connection:t,pageVersion:n,dismissed:r,now:i})=>{let{server:a}=t;if(t.link!==`open`||a===null||`error`in a)return null;if(n!==null&&a.version!==n)return{kind:`pageOlder`,page:n,server:a.version};if(e===null)return null;let o=KX(e,r,i);if(o!==void 0)return o;let{newer:s,releaseNotes:c}=e;return s===null||c===null||GX(r,s,i)?null:{kind:`newer`,newer:s,current:e.current,releaseNotes:c}},JX=e=>e===null?`none`:`${e.kind}:${`newer`in e?e.newer:`latest`in e?e.latest:e.server}`,YX=e=>e?.kind===`newer`?`Ork ${e.newer} is out. Upgrade… is above the panels.`:e?.kind===`installed`?`Ork ${e.latest} is installed; restart \`ork ui\` to use it.`:e?.kind===`pageOlder`?`This page is from an older Ork. Reload to use ${e.server}.`:null,XX=e=>e.kind===`newer`?e.newer:e.kind===`installed`||e.kind===`failed`?e.latest:null,ZX={slot:`_slot_s34lg_8`,banner:`_banner_s34lg_14`,icon:`_icon_s34lg_43`,line:`_line_s34lg_52`,version:`_version_s34lg_59`,link:`_link_s34lg_71`,spacer:`_spacer_s34lg_82`,facts:`_facts_s34lg_86`,factName:`_factName_s34lg_99`,factValue:`_factValue_s34lg_114`,adviceWords:`_adviceWords_s34lg_125`,note:`_note_s34lg_131`,message:`_message_s34lg_142`,alert:`_alert_s34lg_149`,alertIcon:`_alertIcon_s34lg_168`,heading:`_heading_s34lg_175`,glyph:`_glyph_s34lg_189`,clock:`_clock_s34lg_200`,foot:`_foot_s34lg_210`,actions:`_actions_s34lg_220`},QX=({latest:e,current:t})=>(0,G.jsxs)(`p`,{className:ZX.line,children:[`Ork`,` `,(0,G.jsx)(`span`,{className:ZX.version,"data-new":``,children:e}),` `,`is out (you have `,(0,G.jsx)(`span`,{className:ZX.version,children:t}),`).`]}),$X=({url:e,version:t,children:n})=>(0,G.jsxs)(`a`,{className:ZX.link,href:e,rel:`noreferrer`,target:`_blank`,children:[n,t===void 0?null:(0,G.jsx)(zw,{children:` in ${t}`}),(0,G.jsx)(Sy,{}),(0,G.jsx)(zw,{children:` (opens in a new tab)`})]}),eZ=8,tZ=({ids:e})=>{if(e.length===0)return null;let t=e.slice(0,eZ).map(e=>`\`${e.slice(0,8)}\``),n=e.length-eZ,r=n>0?`${t.join(`, `)} and ${String(n)} more`:t.join(`, `);return(0,G.jsxs)(`p`,{className:ZX.alert,"data-tone":`note`,children:[(0,G.jsx)(`span`,{className:ZX.alertIcon,children:(0,G.jsx)(yy,{})}),(0,G.jsx)(`span`,{children:(0,G.jsx)(Wg,{text:`Running now: ${r}. Their next sessions would start from the new install; upgrading after they finish is safer.`})})]})},nZ=()=>{let e=document.activeElement;return e===null||e===document.body||e.getAttribute(`role`)===`dialog`},rZ=({tone:e,text:t,ref:n})=>{let r=(0,V.useRef)(null),i=n??r;return(0,V.useLayoutEffect)(()=>{i.current?.focus()},[i]),(0,V.useEffect)(()=>{let e=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>{nZ()&&i.current?.focus()})});return()=>{cancelAnimationFrame(e)}},[i]),(0,G.jsxs)(`h3`,{className:ZX.heading,ref:i,tabIndex:-1,children:[e===void 0?null:(0,G.jsx)(`span`,{className:ZX.glyph,"data-tone":e,children:e===`succeeded`?(0,G.jsx)(aD,{}):(0,G.jsx)(cD,{})}),(0,G.jsx)(`span`,{children:(0,G.jsx)(Wg,{text:t})})]})},iZ=({since:e})=>{let t=sz(!0),n=Math.max(0,Math.floor((t-e)/1e3));return(0,G.jsx)(`span`,{"aria-hidden":`true`,className:ZX.clock,children:`${String(n)} s`})},aZ=({text:e,icon:t=!1})=>e===null?null:(0,G.jsxs)(`p`,{className:ZX.alert,role:`alert`,children:[t?(0,G.jsx)(yy,{}):null,(0,G.jsx)(`span`,{children:(0,G.jsx)(Wg,{text:e})})]}),oZ=({why:e,id:t})=>(0,G.jsx)(`output`,{className:ZX.note,id:t,children:(0,G.jsx)(Wg,{text:e??``})}),sZ=({note:e,children:t})=>(0,G.jsxs)(`div`,{className:ZX.foot,children:[e===void 0?null:(0,G.jsx)(`p`,{className:ZX.note,children:(0,G.jsx)(Wg,{text:e})}),(0,G.jsx)(`div`,{className:ZX.actions,children:t})]}),cZ=`Dismissed for a day. Upgrade Ork… is in Commands.`,lZ=(e,t,n,r)=>{let i=(0,V.useRef)(null),a=JX(e);(0,V.useEffect)(()=>{if(!t)return;let o=i.current;if(i.current=a,o===null||o===a||n)return;let s=YX(e);s!==null&&r.announce(s)},[e,a,t,n,r])},uZ=()=>{let[e,t]=(0,V.useState)(Date.now);return(0,V.useEffect)(()=>{let e=setInterval(()=>{t(Date.now())},6e4);return()=>{clearInterval(e)}},[]),e},dZ=()=>{window.location.reload()},fZ={newer:{label:`Upgrade…`,primary:!0,opens:`ask`},running:{label:`Show output`,primary:!1,opens:`job`},failed:{label:`Show output`,primary:!1,opens:`job`},installed:{label:`Restart…`,primary:!0,opens:`job`},pageOlder:{label:`Reload`,primary:!0,opens:null}},pZ=e=>e.kind===`running`?`Upgrading Ork to ${e.latest}…`:e.kind===`failed`?`The upgrade to ${e.latest} did not finish: exit ${String(e.code)}.`:e.kind===`installed`?`Ork ${e.latest} is installed. \`ork ui\` still runs ${e.current} until it restarts.`:`This page is from Ork ${e.page}; \`ork ui\` now runs ${e.server}.`,mZ=({banner:e,onOpen:t})=>{let n=fZ[e.kind];return(0,G.jsxs)(G.Fragment,{children:[e.kind===`newer`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(QX,{current:e.current,latest:e.newer}),(0,G.jsx)($X,{url:e.releaseNotes,version:e.newer,children:`What changed`})]}):(0,G.jsx)(`p`,{className:ZX.line,children:(0,G.jsx)(Wg,{text:pZ(e)})}),(0,G.jsx)(`span`,{className:ZX.spacer}),(0,G.jsx)(q,{cli:e.kind===`newer`?`ork upgrade`:void 0,id:WX,onClick:()=>{n.opens===null?dZ():t(n.opens)},variant:n.primary?`primary`:`default`,children:n.label})]})},hZ=({workspace:e})=>{let{version:t,connection:n,preferences:r}=qy(),i=ab(t.info),a=ab(n),o=ab(r.value),s=ab(t.dialog),c=uZ(),l=qX({info:i,connection:a,pageVersion:t.pageVersion,dismissed:o.updateDismissed,now:c});lZ(l,i!==null&&a.server!==null,s!==null,e);let u=l===null?null:XX(l);return(0,G.jsx)(`div`,{className:ZX.slot,children:l===null?null:(0,G.jsxs)(`section`,{"aria-label":`New version`,className:ZX.banner,children:[(0,G.jsx)(`span`,{className:ZX.icon,children:(0,G.jsx)(zy,{})}),(0,G.jsx)(mZ,{banner:l,onOpen:t.openDialog}),u===null?null:(0,G.jsx)(cb,{label:`Dismiss for a day`,onClick:()=>{r.update({updateDismissed:{version:u,at:new Date().toISOString()}}),e.announce(cZ),e.focusPanels()},children:(0,G.jsx)(Jv,{})})]})})},gZ=e=>e===null?`Asking the npm registry for the latest version…`:`Asking the registry at \`${e}\` for the latest version…`,_Z=({plan:e})=>(0,G.jsxs)(`dl`,{className:ZX.facts,children:[(0,G.jsx)(`dt`,{className:ZX.factName,children:`Installed with`}),(0,G.jsx)(`dd`,{className:ZX.factValue,children:e.installer?.label??`Ork couldn't tell`}),e.kind===`command`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dt`,{className:ZX.factName,children:`Command`}),(0,G.jsx)(`dd`,{className:ZX.factValue,children:(0,G.jsx)(`section`,{"aria-label":`Command to run`,children:(0,G.jsx)(YS,{command:e.command.join(` `)})})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dt`,{className:ZX.factName,children:`What to do`}),(0,G.jsxs)(`dd`,{className:ZX.factValue,children:[(0,G.jsx)(`p`,{className:ZX.adviceWords,children:(0,G.jsx)(Wg,{text:e.words})}),e.commands.map(e=>(0,G.jsx)(YS,{command:e},e))]})]})]}),vZ=({plan:e})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(QX,{current:e.current,latest:e.latest}),(0,G.jsxs)(`p`,{className:ZX.message,children:[`What changed:`,` `,(0,G.jsx)($X,{url:e.releaseNotes,children:e.releaseNotes})]}),(0,G.jsx)(_Z,{plan:e}),e.kind===`advice`?(0,G.jsx)(`p`,{className:ZX.note,children:`Ork runs only a package manager's own command from here; this one is yours to run.`}):null,(0,G.jsx)(tZ,{ids:e.running}),(0,G.jsx)(`p`,{className:ZX.note,children:`The same, in a terminal:`}),(0,G.jsx)(YS,{command:`ork upgrade`})]}),yZ=({step:e,registry:t})=>e.step===`plan`?(0,G.jsx)(vZ,{plan:e.plan}):e.step===`latest`?(0,G.jsx)(rZ,{text:`Ork ${e.current} is the latest version.`,tone:`succeeded`}):e.step===`unreachable`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(aZ,{icon:!0,text:e.words}),(0,G.jsx)(`p`,{className:ZX.message,children:`Nothing was changed.`})]}):(0,G.jsx)(`section`,{"aria-busy":`true`,"aria-label":`Asking`,className:ZX.message,children:(0,G.jsx)(Wg,{text:gZ(t)})}),bZ=({step:e,registry:t,first:n,onClose:r,onAsk:i,onUpgrade:a})=>{let o=(0,V.useId)();(0,V.useEffect)(()=>{nZ()&&n.current?.focus()},[n]);let s=e.step===`plan`&&e.plan.kind===`command`,c=e.step===`checking`||s,l=e.step===`plan`&&e.starting;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yZ,{registry:t,step:e}),(0,G.jsx)(aZ,{text:e.step===`plan`?e.refusal:null}),(0,G.jsx)(oZ,{id:o,why:e.step===`checking`?`Asking the registry…`:null}),(0,G.jsxs)(sZ,{note:c?`It runs on this machine as you.`:void 0,children:[e.step===`unreachable`?(0,G.jsx)(q,{onClick:()=>{n.current?.focus(),i()},variant:`ghost`,children:`Try again`},`again`):null,(0,G.jsx)(q,{disabled:l,focusableWhenDisabled:!0,onClick:r,ref:n,variant:c?`ghost`:`default`,children:c?`Cancel`:`Close`},`close`),c?(0,G.jsx)(q,{"aria-describedby":o,disabled:!s||l,focusableWhenDisabled:!0,onClick:a,variant:`primary`,children:e.step===`plan`?`Upgrade to ${e.plan.latest}`:`Upgrade`},`upgrade`):null]})]})},xZ=({step:e,port:t})=>{let n=(0,V.useId)();return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(rZ,{text:"Restarting `ork ui`…"}),(0,G.jsx)(`p`,{className:ZX.message,children:e.step===`back`?`Ork ${e.version} is up. Reloading…`:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Wg,{text:`Waiting for \`ork ui\` to come back on port ${t}. Runs keep running.`}),` `,(0,G.jsx)(iZ,{since:e.since})]})}),(0,G.jsx)(oZ,{id:n,why:"It closes once `ork ui` is back."}),(0,G.jsx)(sZ,{children:(0,G.jsx)(q,{"aria-describedby":n,disabled:!0,focusableWhenDisabled:!0,children:`Close`})})]})},SZ=({step:e,port:t,onClose:n,onKeepWaiting:r,onReload:i})=>{if(e.step===`restarting`||e.step===`back`)return(0,G.jsx)(xZ,{port:t,step:e});let a=CZ(e,t);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(rZ,{text:a.heading,tone:`failed`}),(0,G.jsx)(aZ,{text:a.words}),(0,G.jsx)(YS,{command:a.command}),(0,G.jsxs)(sZ,{children:[e.step===`gaveUp`?(0,G.jsx)(q,{onClick:r,children:`Keep waiting`}):(0,G.jsx)(q,{onClick:n,children:`Close`}),e.step===`signedOut`?null:(0,G.jsx)(q,{onClick:i,variant:`primary`,children:`Reload`})]})]})},CZ=(e,t)=>e.step===`gaveUp`?{heading:"`ork ui` didn't come back",words:`It wasn't back on port ${t} after 60 seconds. Its terminal says why. Start it again there:`,command:`ork ui --port ${t}`}:e.step===`oldVersion`?{heading:`\`ork ui\` is back on ${e.version}`,words:`\`ork ui\` is back, but it runs ${e.version}: the \`ork\` it started is not the one that was upgraded. Another \`ork\` may come first on your PATH.`,command:`ork upgrade`}:{heading:`This page isn't signed in`,words:"`ork ui` is back, but this page isn't signed in to it. Open it again from a terminal:",command:`ork ui`},wZ={well:`_well_14iu2_8`},TZ=32,EZ=({label:e,text:t,ref:n})=>{let r=(0,V.useRef)(null),i=n??r,a=(0,V.useRef)(!0);return(0,V.useLayoutEffect)(()=>{let e=i.current;e!==null&&a.current&&(e.scrollTop=e.scrollHeight)}),(0,G.jsx)(`section`,{"aria-label":e,className:wZ.well,onScroll:()=>{let e=i.current;e!==null&&(a.current=e.scrollHeight-e.scrollTop-e.clientHeight<TZ)},ref:i,tabIndex:0,children:t})},DZ="Lost the output from `ork ui`. The command may still be running; reconnecting…",OZ=e=>e.command[0]??`it`,kZ=(e,t)=>{let n=t.split(`
|
|
74
|
+
`).findLast(e=>e.startsWith(`Could not run`));return e.code===127&&n!==void 0?n:`\`${OZ(e)}\` failed (exit ${String(e.code??1)}); the upgrade did not finish.`},AZ=({job:e,lost:t,output:n})=>{let r=(0,V.useId)();(0,V.useEffect)(()=>{n.current?.focus()},[n]);let i=OZ(e);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:ZX.message,children:[(0,G.jsx)(Wg,{text:`Running \`${i}\`…`}),` `,(0,G.jsx)(iZ,{since:Date.parse(e.startedAt)})]}),(0,G.jsx)(YS,{command:e.command.join(` `)}),t?(0,G.jsx)(aZ,{text:DZ}):null,(0,G.jsx)(oZ,{id:r,why:`It closes when ${i} ends; closing now would hide how it ended.`}),(0,G.jsx)(sZ,{children:(0,G.jsx)(q,{"aria-describedby":r,disabled:!0,focusableWhenDisabled:!0,children:`Close`})})]})},jZ=({step:e,text:t,lost:n,current:r,port:i,output:a,heading:o,onClose:s,onAsk:c,onRestart:l})=>{let{job:u}=e,d=`Output of ${OZ(u)}`;if(e.step===`running`)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(EZ,{label:d,ref:a,text:t}),(0,G.jsx)(AZ,{job:u,lost:n,output:a})]});let f=(0,G.jsx)(EZ,{label:d,text:t});return e.step===`failed`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(rZ,{ref:o,text:`The upgrade did not finish`,tone:`failed`}),(0,G.jsx)(aZ,{text:`${kZ(u,t)} Nothing was restarted; \`ork ui\` still runs ${r}.`}),f,(0,G.jsx)(`p`,{className:ZX.note,children:`To run it in a terminal yourself:`}),(0,G.jsx)(YS,{command:u.command.join(` `)}),(0,G.jsxs)(sZ,{children:[(0,G.jsx)(q,{onClick:s,children:`Close`}),(0,G.jsx)(q,{onClick:c,variant:`ghost`,children:`Try again`})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(rZ,{ref:o,text:`Upgraded to ${u.latest}`,tone:`succeeded`}),(0,G.jsx)(`p`,{className:ZX.message,children:(0,G.jsx)(Wg,{text:`Ork ${u.latest} is installed. This page and \`ork ui\` still run ${r} until \`ork ui\` restarts. Restart stops it and starts it again on port ${i} with the same options; runs keep running, and the page reloads itself when it's back.`})}),f,(0,G.jsx)(aZ,{text:e.refusal}),(0,G.jsxs)(sZ,{children:[(0,G.jsx)(q,{onClick:s,variant:`ghost`,children:`Later`}),(0,G.jsxs)(q,{cli:`ork ui --port ${i}`,disabled:e.asking,focusableWhenDisabled:!0,onClick:l,tip:"Stops `ork ui` and starts the new one",variant:`primary`,children:[(0,G.jsx)(By,{}),`Restart`]})]})]})},MZ={pollMs:1e3,waitMs:6e4,reloadMs:1500},NZ=async(e,t,n)=>{let{job:r,port:i,pid:a,since:o}=t,s=await e.call(`health`);if(s.ok&&s.data.pid!==a){let{version:e}=s.data;return e===r.latest?{step:`back`,version:e}:{step:`oldVersion`,job:r,version:e}}return!s.ok&&s.status===401?{step:`signedOut`}:Date.now()-o>=n?{step:`gaveUp`,job:r,port:i,pid:a}:null},PZ=({client:e,step:t,setStep:n,announce:r,reload:i,timing:a})=>{let o=(0,V.useRef)({announce:r,reload:i});(0,V.useEffect)(()=>{o.current={announce:r,reload:i}}),(0,V.useEffect)(()=>{let r=t.step===`restarting`?t:null,i=!1,s=async t=>{let r=await NZ(e,t,a.waitMs);i||r===null||(i=!0,n(r),r.step===`gaveUp`&&o.current.announce("`ork ui` didn't come back."),r.step===`back`&&(o.current.announce(`Ork ${r.version} is up. Reloading…`),setTimeout(()=>{o.current.reload()},a.reloadMs)))},c=r===null?void 0:setInterval(()=>{s(r)},a.pollMs);return()=>{i=!0,clearInterval(c)}},[e,t,n,a])},FZ=e=>new EventSource(e),IZ=2,LZ=1e3,RZ=15e3,zZ=e=>{try{return JSON.parse(e)}catch{return}},BZ=({url:e,open:t,on:n,onStatus:r,onFailure:i})=>{let a=null,o=null,s=LZ,c=null,l=e=>{e!==c&&(c=e,r(e))},u=()=>{let r=t(e());a=r,r.addEventListener(`open`,()=>{s=LZ,l(`open`)}),r.addEventListener(`error`,()=>{l(`lost`),i?.(),r.readyState===IZ&&(r.close(),o=setTimeout(u,s),s=Math.min(s*2,RZ))});let c=Object.entries(n);for(let[e,t]of c)r.addEventListener(e,e=>{let n=zZ(e.data);n!==void 0&&t(n)})};return l(`connecting`),u(),{close:()=>{o!==null&&clearTimeout(o),o=null,a?.close(),a=null}}},VZ=e=>e===null?`Could not reach the npm registry to look for a new version.`:`Could not reach the registry at \`${e}\` to look for a new version.`,HZ=(e,t)=>e.kind===`unreachable`?{step:`unreachable`,words:VZ(t)}:e.kind===`latest`?{step:`latest`,current:e.current}:{step:`plan`,plan:e,refusal:null,starting:!1},UZ=e=>e.kind===`command`?`Ork ${e.latest} is out. The plan is below.`:`Ork ${e.latest} is out. Ork can't run this upgrade from here; what to do is below.`,WZ=e=>e.state===`running`?{step:`running`,job:e}:e.state===`succeeded`?{step:`done`,job:e,refusal:null,asking:!1}:{step:`failed`,job:e},GZ=({client:e,open:t,job:n,registry:r,announce:i,onAsked:a})=>{let[o,s]=(0,V.useState)(()=>n===null?{step:`checking`}:WZ(n)),[c,l]=(0,V.useState)([]),[u,d]=(0,V.useState)(!1),f=(0,V.useRef)(null),p=(0,V.useRef)(0),m=(0,V.useRef)({announce:i,onAsked:a,registry:r});(0,V.useEffect)(()=>{m.current={announce:i,onAsked:a,registry:r}});let h=(0,V.useCallback)(e=>{f.current?.close(),p.current=0,l([]);let n=BZ({url:()=>`${UA.upgrade}?after=${String(p.current)}`,open:t,on:{output:e=>{e.seq<=p.current||(p.current=e.seq,l(t=>[...t,e]))},end:t=>{n.close(),d(!1),s(WZ({...e,state:t.state,code:t.code})),t.state===`succeeded`&&m.current.announce(`Upgraded to ${e.latest}.`)}},onStatus:e=>{d(e===`lost`)}});f.current=n},[t]),g=(0,V.useCallback)(async()=>{s({step:`checking`});let t=await e.call(`upgradePlan`);m.current.onAsked();let n=t.ok?HZ(t.data,m.current.registry):{step:`unreachable`,words:t.error};s(n),n.step===`plan`&&m.current.announce(UZ(n.plan))},[e]),_=(0,V.useRef)(n);(0,V.useEffect)(()=>{let e=_.current;return e===null?g():h(e),()=>{f.current?.close()}},[g,h]);let v=async(t,n)=>{let r=await e.call(`version`),i=r.ok?r.data.job:null;if(i?.state===`running`){m.current.announce(n),s({step:`running`,job:i}),h(i);return}let a=await e.call(`upgradePlan`);if(m.current.onAsked(),!a.ok){s({step:`plan`,plan:t,refusal:n,starting:!1});return}let o=HZ(a.data,m.current.registry);s(o.step===`plan`?{...o,refusal:n}:o)},y=async t=>{s({step:`plan`,plan:t,refusal:null,starting:!0});let n=await e.call(`upgrade`,{body:{planId:t.planId}});n.ok?(m.current.announce(`Upgrading Ork to ${t.latest}.`),s({step:`running`,job:n.data.job}),h(n.data.job)):n.status===409?await v(t,n.error):s({step:`plan`,plan:t,refusal:n.error,starting:!1})},b=async t=>{s({step:`done`,job:t,refusal:null,asking:!0});let n=await e.call(`restart`);s(n.ok?{step:`restarting`,job:t,port:n.data.port,pid:n.data.pid,since:Date.now()}:{step:`done`,job:t,refusal:n.error,asking:!1})};return{step:o,setStep:s,text:c.map(e=>e.text).join(`
|
|
75
|
+
`),lost:u,ask:()=>{g()},upgrade:()=>{o.step===`plan`&&o.plan.kind===`command`&&y(o.plan)},restart:()=>{o.step===`done`&&b(o.job)},keepWaiting:()=>{o.step===`gaveUp`&&s({...o,step:`restarting`,since:Date.now()})}}},KZ=e=>[`checking`,`unreachable`,`latest`,`plan`].includes(e.step),qZ=e=>[`running`,`done`,`failed`].includes(e.step),JZ=e=>!KZ(e)&&!qZ(e),YZ=({starts:e,timing:t,reload:n,onStep:r,onClose:i})=>{let{version:a,client:o}=qy(),s=(0,V.use)(ZM),c=ab(a.info),l=ab(a.dialog),u=(0,V.useCallback)(e=>s?.announce(e),[s]),d=GZ({client:o,open:a.open,job:l===`job`?c?.job??null:null,registry:c?.registry??null,announce:u,onAsked:()=>void a.refresh()}),{step:f,setStep:p}=d;PZ({client:o,step:f,setStep:p,announce:u,reload:n,timing:t}),(0,V.useEffect)(()=>{r(f)},[f,r]);let m=f.step===`restarting`||f.step===`back`;(0,V.useEffect)(()=>(a.restarting.setValue(m),()=>{a.restarting.setValue(!1)}),[a,m]);let h=window.location.port;return KZ(f)?(0,G.jsx)(bZ,{first:e.first,onAsk:d.ask,onClose:i,onUpgrade:d.upgrade,registry:c?.registry??null,step:f}):qZ(f)?(0,G.jsx)(jZ,{current:c?.current??``,heading:e.heading,lost:d.lost,onAsk:d.ask,onClose:i,onRestart:d.restart,output:e.output,port:h,step:f,text:d.text}):JZ(f)?(0,G.jsx)(SZ,{onClose:i,onKeepWaiting:d.keepWaiting,onReload:n,port:h,step:f}):null},XZ=()=>{window.location.reload()},ZZ=e=>![`running`,`restarting`,`back`].includes(e.step)&&!(e.step===`plan`&&e.starting)&&!(e.step===`done`&&e.asking),QZ=`Upgrade Ork`,$Z=({timing:e=MZ,reload:t=XZ})=>{let{version:n}=qy(),r=(0,V.use)(ZM),i=ab(n.dialog),a=ab(n.info),o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.useRef)(null),l=i===`job`&&a?.job?.state!==`running`,u=i===`job`?l?c:s:o,[d,f]=(0,V.useState)(QZ),p=(0,V.useRef)({closable:!0,ran:!1}),m=(0,V.useCallback)(e=>{p.current={closable:ZZ(e),ran:p.current.ran||`job`in e},f(t=>KZ(e)?QZ:`job`in e?`Upgrading Ork to ${e.job.latest}`:t)},[]),h=()=>{p.current.closable&&(p.current.ran||r?.announce(`Nothing was changed.`),p.current={closable:!0,ran:!1},f(QZ),n.closeDialog())};return(0,G.jsx)(bC,{finalFocus:()=>{let e=document.querySelector(`#${WX}`);return e===null?(r?.focusPanels(),!1):e},initialFocus:u,onOpenChange:e=>{e||h()},open:i!==null,size:`wide`,title:d,children:(0,G.jsx)(YZ,{onClose:h,onStep:m,reload:t,starts:{first:o,output:s,heading:c},timing:e})})},eQ=({workspace:e})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(hZ,{workspace:e}),(0,G.jsx)($Z,{})]});function tQ(e){let{openOnInputClick:t=!1,value:n,defaultValue:r,onValueChange:i,mode:a=`list`,itemToStringValue:o,...s}=e,c=(a===`inline`||a===`both`)&&!e.readOnly,l=a===`inline`||a===`none`,u=n!==void 0,[d,f]=V.useState(r??``),[p,m]=V.useState(``);V.useEffect(()=>{(u||!c)&&m(``)},[n,u,c]);let h;h=c&&p!==``?p:u?n??``:d;let g=lx({locale:s.locale}),_=String((u?n:d)??``).trim(),v=l||s.filter===null?null:s.filter??g.contains;function y(e,t){m(``),u||f(e),i?.(e,t)}function b(t,n){e.onItemHighlighted?.(t,n),n.reason!==`pointer`&&m(c&&t!=null?Rb(t,o):``)}return(0,G.jsx)(_x,{...s,itemToStringLabel:o,openOnInputClick:t,selectionMode:`none`,fillInputOnItemPress:!0,filter:v,filterQuery:a===`both`?_:void 0,autoComplete:a,inputValue:h,defaultInputValue:r,onInputValueChange:y,onItemHighlighted:b})}var nQ=zS,rQ=[`Panels`,`Runs`,`Window`,`Layout`,`View`,`Ork`],iQ=`Needs a wider window.`,aQ=`No panel is active.`,oQ=[`left`,`right`,`up`,`down`],sQ={left:`narrower`,right:`wider`,up:`shorter`,down:`taller`},cQ=e=>e.wide?e.active===null?aQ:void 0:iQ,lQ=e=>eW.map((t,n)=>{let r={id:`go-${t.id}`,title:`Go to ${t.title}`,group:`Panels`,run:()=>{e.goTo(t.id)}},i=TT(n+1);return i!==void 0&&(r.shortcut=i),r}),uQ=e=>[{id:`run-workflow`,title:`Run workflow…`,group:`Runs`,run:()=>{e.runDialog.setValue(!0)}}],dQ=(e,t)=>{let n=cQ(t),r=t.active===null?`panel`:nW(t.active).title,i=n??(t.floating?`A floating panel cannot be maximized.`:void 0),a=n??(t.maximized?`Restore the panel first.`:void 0);return[{id:`minimize`,title:`Minimize ${r}`,group:`Window`,shortcut:CT.minimize,run:()=>{e.minimize()},disabled:n},{id:`maximize`,title:t.maximized?`Restore ${r}`:`Maximize ${r}`,group:`Window`,shortcut:CT.maximize,run:()=>{e.toggleMaximize()},disabled:i},{id:`float`,title:t.floating?`Dock ${r}`:`Float ${r}`,group:`Window`,shortcut:CT.float,run:()=>{e.toggleFloat()},disabled:n},{id:`close`,title:`Close ${r}`,group:`Window`,shortcut:CT.close,run:()=>{e.close()},disabled:n},...oQ.map(t=>({id:`resize-${t}`,title:`Make ${r} ${sQ[t]}`,group:`Window`,shortcut:CT.resize(t),run:()=>{e.resize(t)},disabled:a})),...oQ.map(t=>({id:`move-${t}`,title:`Move ${r} ${t}`,group:`Window`,shortcut:CT.move(t),run:()=>{e.move(t)},disabled:n}))]},fQ=(e,t)=>{let n=t.wide?void 0:iQ;return[{id:`next-group`,title:`Focus next panel group`,group:`Layout`,shortcut:CT.nextGroup,run:()=>{e.cycleGroup(1)},disabled:n},{id:`previous-group`,title:`Focus previous panel group`,group:`Layout`,shortcut:CT.previousGroup,run:()=>{e.cycleGroup(-1)},disabled:n},{id:`reset-layout`,title:`Reset layout`,group:`Layout`,run:()=>{e.resetLayout()}}]},pQ=[{theme:`system`,title:`Follow the system`},{theme:`dark`,title:`Dark`},{theme:`light`,title:`Light`}],mQ=[{density:`compact`,title:`Compact`},{density:`comfortable`,title:`Comfortable`}],hQ=(e,t,n)=>[...pQ.map(({theme:r,title:i})=>({id:`theme-${r}`,title:`Theme: ${i}`,group:`View`,run:()=>{t.update({theme:r}),e.announce(`Theme: ${i}.`)},disabled:n.theme===r?`This is the theme now.`:void 0})),...mQ.map(({density:r,title:i})=>({id:`density-${r}`,title:`Density: ${i}`,group:`View`,run:()=>{t.update({density:r}),e.announce(`Density: ${i}.`)},disabled:n.density===r?`This is the density now.`:void 0}))],gQ=e=>[{id:`upgrade-ork`,title:`Upgrade Ork…`,group:`Ork`,detail:`Asks the registry for a new version now.`,run:()=>{e.version.openDialog(`ask`)}}],_Q=(e,t,n,r)=>[...lQ(e),...uQ(n),...dQ(e,t),...fQ(e,t),...hQ(e,n.preferences,r),...gQ(n)],vQ={palette:`_palette_p3ocp_6`,input:`_input_p3ocp_45`,list:`_list_p3ocp_78`,group:`_group_p3ocp_88`,empty:`_empty_p3ocp_106`},yQ=e=>rQ.map(t=>({value:t,items:e.filter(e=>e.group===t).map(e=>({label:e.title,command:e}))})),bQ=({commands:e,onChoose:t})=>{let n=(0,V.useMemo)(()=>yQ(e),[e]),r=ET();return(0,G.jsxs)(tQ,{autoHighlight:`always`,inline:!0,items:n,keepHighlight:!0,open:!0,children:[(0,G.jsx)(Rx,{"aria-label":`Search commands`,className:vQ.input,placeholder:`Type a command`}),(0,G.jsx)(HS,{children:(0,G.jsx)(`p`,{className:vQ.empty,children:`No command matches.`})}),(0,G.jsx)(iS,{className:vQ.list,children:e=>(0,G.jsxs)(AS,{items:e.items,children:[(0,G.jsx)(jS,{className:vQ.group,children:e.value}),(0,G.jsx)(Jx,{children:e=>(0,G.jsxs)(nQ,{className:qg.item,disabled:e.command.disabled!==void 0,onClick:()=>{t(e.command)},value:e,children:[(0,G.jsx)(`span`,{children:e.label}),(e.command.disabled??e.command.detail)===void 0?null:(0,G.jsx)(`span`,{className:qg.itemDetail,children:e.command.disabled??e.command.detail}),e.command.shortcut===void 0?null:(0,G.jsx)(Kg,{keys:yT(e.command.shortcut,r)})]},e.command.id)})]},e.value)})]})},xQ=()=>(document.activeElement===null||document.activeElement===document.body)&&document.querySelector(`[data-modal]`)===null,SQ=e=>{requestAnimationFrame(()=>{requestAnimationFrame(e)})},CQ=({workspace:e,commands:t})=>{let n=ab(e.palette),r=(0,V.useRef)(null),i=(0,V.useRef)(!1),a=(0,V.useRef)(null);(0,V.useLayoutEffect)(()=>{n&&(i.current=!1,a.current=document.activeElement)},[n]);let o=t=>{e.palette.setValue(t)},s=()=>{if(!xQ())return;let t=a.current;t instanceof HTMLElement&&t.isConnected?t.focus():e.focusPanels()};return(0,G.jsx)(_C,{onOpenChange:o,onOpenChangeComplete:e=>{if(e)return;let t=r.current;r.current=null,t!==null&&(t.run(),SQ(s))},open:n,children:(0,G.jsxs)(hC,{children:[(0,G.jsx)(aC,{className:vC.backdrop}),(0,G.jsx)(mC,{"aria-label":`Command palette`,"aria-modal":`true`,className:vQ.palette,finalFocus:()=>!i.current,children:(0,G.jsx)(bQ,{commands:t,onChoose:e=>{r.current=e,i.current=!0,o(!1)}})})]})})},wQ=e=>{let t=Yy.create(null),n=Yy.create(null),r=Yy.create(null),i=Yy.create(null),a=Yy.create([]),o=Promise.resolve(),s=(t,n)=>{e.chooseBuilder({project:t.project,workflow:t.name,node:n,draft:r.getValue()?.draft??!1})};return{project:t,opened:n,view:r,selected:i,history:a,inTurn:e=>{let t=o.then(e,e);return o=t.catch(()=>null),t},show:(t,o)=>{let c=n.getValue();n.setValue(t),r.setValue(o),i.setValue(null),a.setValue([]),t===null?e.builderClosed():(t!==c&&s(t,null),o!==null&&e.builderChanged(t.project,t.name,o.draft))},update:t=>{r.setValue(t);let i=n.getValue();i!==null&&e.builderChanged(i.project,i.name,t.draft)},select:e=>{i.setValue(e);let t=n.getValue();t!==null&&s(t,e)}}},TQ=(e,t,n)=>e?.kind===`builder`&&e.project===t&&e.workflow===n,EQ=()=>{let e=Yy.create(null),t=t=>{e.setValue(t)},n=n=>{let r=e.getValue();t({kind:`builder`,...n,revision:TQ(r,n.project,n.workflow)?r.revision:0})},r=(n,r,i)=>{let a=e.getValue();TQ(a,n,r)&&t({...a,draft:i,revision:a.revision+1})},i=()=>{e.getValue()?.kind===`builder`&&t(null)};return{target:e,chooseBuilder:n,builderChanged:r,builderClosed:i,builder:wQ({chooseBuilder:n,builderChanged:r,builderClosed:i}),chooseRun:(e,n)=>{t(e===null?null:{kind:`run`,run:e,node:n})}}},DQ=e=>{let t=Yy.create([]),n=new Map,r=async n=>{let r=await e.call(`decision`,{params:{id:n.id}}),i=r.ok?r.data:n;t.setValue([i,...t.getValue()].slice(0,20))};return{settled:t,saw:e=>{let t=new Map((e??[]).map(e=>[e.id,e]));for(let[e,i]of n)t.has(e)||r(i);n=t}}},OQ=1e3,kQ=({runId:e,client:t,open:n})=>{let r=Yy.create({...dL,tail:[],link:`idle`,ended:null,paging:!1,error:null}),i=null,a=!1,o=!1,s=0,c=[],l=null,u=null,d=e=>{r.setValue({...r.getValue(),...e})},f=()=>c.at(-1)?.seq??r.getValue().latest,p=async(n,i)=>{d({paging:!0});let a=await t.call(`events`,{params:{id:e},query:n});return a.ok?(d({...i(r.getValue(),a.data),...n.last===void 0?{}:{tail:a.data},paging:!1,error:null}),!0):(d({paging:!1,error:a.error}),!1)},m=async()=>{let e=r.getValue();e.following&&hL(e)&&!e.paging&&await p({after:pL(e),limit:500},xL)&&await m()},h=()=>{if(l!==null&&clearTimeout(l),l=null,c.length===0)return;let e=c;c=[];let t=r.getValue(),n=t.tail.at(-1)?.seq??0;d({...yL(t,e),tail:[...t.tail,...e.filter(e=>e.seq>n)].slice(-500)}),m()},g=()=>{i?.close(),i=null},_=()=>{i=BZ({url:()=>`${WA(UA.run,{id:e})}?after=${String(f())}`,open:n,on:{"run-event":e=>{e.seq<=f()||(c.push(e),l??=setTimeout(h,50))},end:({reason:e})=>{h(),g(),o=!1,d({link:`ended`,ended:e})}},onStatus:e=>{d({link:e===`open`?`live`:e===`lost`?`lost`:`loading`})}})},v=async()=>{let e=s;d({link:`loading`});let t=await p({last:500},bL);e===s&&(t?(a=!0,_()):(d({link:`lost`}),u=setTimeout(()=>void v(),OQ)))};return{state:r,start:()=>{o||(o=!0,s+=1,d({ended:null}),a?_():v())},stop:()=>{o=!1,s+=1,u!==null&&clearTimeout(u),u=null,h(),g(),r.getValue().link!==`ended`&&d({link:`idle`})},loadOlder:async()=>{let e=r.getValue();mL(e)&&!e.paging&&await p(CL(e),SL)},loadNewer:async()=>{let e=r.getValue();hL(e)&&!e.paging&&await p({after:pL(e),limit:500},xL)},hold:()=>{d({following:!1})},follow:async()=>{let e=r.getValue();e.paging||(hL(e)?await p({last:500},bL):d({following:!0}),await m())}}},AQ=({runId:e,client:t,feed:n})=>{let r=Yy.create({graph:null,tree:null,links:[],error:null}),i=e=>{r.setValue({...r.getValue(),...e})},a=0,o=async()=>{a+=1;let n=a,[o,s]=await Promise.all([t.call(`tree`,{params:{id:e}}),t.call(`links`,{query:{run:e}})]);n===a&&(o.ok?i({tree:o.data,links:s.ok?s.data:r.getValue().links,error:null}):i({error:o.error}))},s=async()=>{let n=await t.call(`graph`,{params:{id:e}});n.ok?i({graph:n.data}):i({error:n.error})};return{state:r,start:()=>{let e=null,t=n.state.getValue().latest;s(),o();let r=n.state.subscribe(({latest:n})=>{n!==t&&(t=n,e??=setTimeout(()=>{e=null,o()},250))});return()=>{r(),e!==null&&clearTimeout(e),a+=1}}}},jQ=e=>e.live===`running`||e.live===`paused`,MQ=({client:e,open:t})=>{let n=new Map,r=r=>{let i=n.get(r)??{feed:kQ({runId:r,client:e,open:t}),retained:0};return n.set(r,i),i},i=()=>{let e=[...n].filter(([,e])=>e.retained===0);for(let[t]of e.slice(0,-4))n.delete(t)};return{reopenResumed:e=>{for(let t of e??[]){let e=n.get(t.id);e!==void 0&&e.retained>0&&jQ(t)&&e.feed.state.getValue().link===`ended`&&e.feed.start()}},feedOf:e=>r(e).feed,retainRun:e=>{let t=r(e);return t.retained+=1,t.feed.start(),()=>{--t.retained,t.retained===0&&(t.feed.stop(),n.delete(e),n.set(e,t),i())}},watchRun:t=>AQ({runId:t,client:e,feed:r(t).feed})}},NQ=`ork.notifications.read`,PQ=ss({before:Co().nullable(),ids:as(Co())}),FQ=e=>{if(e.live===`running`)return null;let t=e.live===`paused`||e.live===`crashed`;return{id:`run:${e.id}:${e.live}`,kind:`run`,runId:e.id,status:e.live,title:`Run ${e.id} of ${e.workflow} ${_D(e.live)}.`,at:e.finishedAt??e.startedAt,pending:t}},IQ=e=>({id:`decision:${e.id}`,kind:`decision`,runId:e.runId,node:e.node,status:`waiting`,title:`${e.node} in run ${e.runId} asks: ${e.question}`,at:e.openedAt,pending:!0}),LQ=(e,t)=>[...t.map(e=>IQ(e)),...e.flatMap(e=>FQ(e)??[])].toSorted((e,t)=>t.at.localeCompare(e.at)),RQ=(e,t)=>t.ids.includes(e.id)||!e.pending&&t.before!==null&&e.at<=t.before,zQ=({runs:e,decisions:t,storage:n,now:r=()=>new Date().toISOString()})=>{let i=new Zy({before:null,ids:[]},{key:NQ,storage:n});PQ.safeParse(i.getValue()).success||i.reset();let a=Yy.create({items:[],unread:0}),o=null,s=new Set,c=[],l=()=>{let e=i.getValue(),t=c.map(t=>({...t,unread:!RQ(t,e)}));a.setValue({items:t,unread:t.filter(({unread:e})=>e).length})},u=()=>{let n=e.getValue(),a=t.getValue();if(n===null||a===null)return;c=LQ(n,a),i.getValue().before===null&&i.setValue({...i.getValue(),before:r()});let u=o,d=u===null?[]:c.filter(({id:e})=>!u.has(e));if(o=new Set(c.map(({id:e})=>e)),l(),d.length>0)for(let e of s)e(d)};return{view:a,start:()=>{let n=e.subscribe(u),r=t.subscribe(u);return u(),()=>{n(),r()}},onNew:e=>(s.add(e),()=>{s.delete(e)}),markRead:e=>{let t=i.getValue();i.setValue({...t,ids:[...t.ids,e].slice(-200)}),l()},markAllRead:()=>{i.setValue({before:r(),ids:c.filter(({pending:e})=>e).map(({id:e})=>e).slice(-200)}),l()}}},BQ=(e,t)=>JSON.stringify(e)===JSON.stringify(t),VQ=(e,t)=>{if(e===null)return t;let n=new Map(e.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.id);return t!==void 0&&BQ(t,e)?t:e});return r.length===e.length&&r.every((t,n)=>t===e[n])?e:r},HQ=({client:e,open:t,pageVersion:n})=>{let r=Yy.create(null),i=Yy.create(null);return{info:r,open:t,pageVersion:n,dialog:i,restarting:Yy.create(!1),receive:e=>{r.setValue(e)},refresh:async()=>{let t=await e.call(`version`);t.ok&&r.setValue(t.data)},openDialog:e=>{i.setValue(e)},closeDialog:()=>{i.setValue(null)}}},UQ=({client:e,open:t,pageVersion:n,runs:r,decisions:i})=>{let a=HQ({client:e,open:t,pageVersion:n});return{version:a,follow:e=>BZ({url:()=>UA.overview,open:t,on:{runs:e=>{r.setValue(VQ(r.getValue(),e))},decisions:e=>{i.setValue(VQ(i.getValue(),e))},version:a.receive},...e})}},WQ=({link:e,server:t})=>t!==null&&`error`in t?`Cannot reach \`ork ui\`: ${t.error}`:e===`lost`?"Lost the stream from `ork ui`. Retrying…":e===`open`&&t!==null?`Ork ${t.version}`:"Connecting to `ork ui`…",GQ=e=>e===null?null:e.filter(e=>jQ(e)).length,KQ=({client:e,open:t,storage:n,pageVersion:r=null})=>{let i=Yy.create(null),a=Yy.create(null),o=Yy.create({link:`connecting`,server:null}),s=Yy.create({run:null,node:null}),c=EQ(),l=null,u=e=>{e.run!==l&&(l=null),s.setValue(e),c.chooseRun(e.run,e.node)},d=tb(n),f=Yy.create(`all`),p=Yy.create(!1),m=Yy.create(null),h=Az(()=>e.call(`projects`)),g=Az(()=>e.call(`triggers`)),_=Az(t=>e.call(`workflows`,{params:{id:t}})),v=Yy.create({project:`all`,period:`30`}),y=Az(({query:t})=>e.call(`usage`,{query:t})),b=Yy.create({status:`open`,about:`all`}),x=Az(()=>e.call(`feedbackItems`)),S=Yy.create(`all`),C=Az(()=>e.call(`worktrees`)),w=MQ({client:e,open:t}),T=DQ(e),E=zQ({runs:i,decisions:a,storage:n}),D=UQ({client:e,open:t,pageVersion:r,runs:i,decisions:a}),{version:O}=D,k=async()=>{let t=await e.call(`health`);o.setValue({...o.getValue(),server:t.ok?t.data:{error:t.error}})};return{runs:i,decisions:a,connection:o,selection:s,contextTarget:c.target,builder:c.builder,preferences:d,runFilter:f,runDialog:p,runPreset:m,client:e,settledDecisions:T.settled,notifications:E,projects:h,workflows:_,usage:y,usageFilter:v,feedback:x,feedbackFilter:b,worktrees:C,worktreesFilter:S,triggers:g,version:O,startRun:t=>e.call(`start`,{body:t}),start:()=>{let e=i.subscribe(w.reopenResumed),t=a.subscribe(T.saw),n=E.start(),r=D.follow({onStatus:e=>{o.setValue({...o.getValue(),link:e}),e!==`lost`&&k()},onFailure:()=>void k()});return()=>{e(),t(),n(),r.close()}},feedOf:w.feedOf,retainRun:w.retainRun,control:(t,n,r)=>e.call(t,{params:{id:n},body:r===void 0?{}:{node:r}}),sendMessage:(t,n,r)=>e.call(`message`,{params:{id:t},body:{node:n,body:r}}),answerDecision:(t,n,r=``)=>e.call(`answer`,{params:{id:t},body:r.trim()===``?{choose:n}:{choose:n,note:r}}),watchRun:w.watchRun,selectRun:e=>{l=null,u({run:e,node:null})},arriveAt:e=>{l=e,u({run:e,node:null})},takeArrival:e=>{let t=l===e;return t&&(l=null),t},selectNode:e=>{u({...s.getValue(),node:e})}}},qQ=(e,t,n)=>`${String(e)} ${e===1?t:n}`,JQ=()=>{let{runs:e,decisions:t,connection:n}=qy(),r=ib(e,GQ),i=ib(t,e=>e?.length??null);return ib(n,({link:e})=>e===`open`)&&r!==null&&i!==null?(0,G.jsxs)(`span`,{className:kT.status,children:[qQ(r,`run live`,`runs live`),`,`,` `,qQ(i,`decision open`,`decisions open`)]}):null},YQ=({workspace:e})=>{let t=ab(e.announcement),{connection:n,version:r}=qy(),i=ib(n,WQ),a=ab(r.restarting);return(0,G.jsxs)(`footer`,{className:kT.bar,children:[(0,G.jsx)(`output`,{"aria-live":a?`off`:void 0,className:kT.status,children:(0,G.jsx)(Wg,{text:i})}),(0,G.jsx)(JQ,{}),(0,G.jsx)(`output`,{"aria-atomic":`true`,"aria-live":`polite`,className:kT.visuallyHidden,children:t})]})},XQ=e=>{let t=qy(),{preferences:n}=t,r=ab(e.view),i=ab(n.value),a=(0,V.useMemo)(()=>_Q(e,r,t,i),[e,r,t,i]);return OT(e,a),a},ZQ=e=>{let t=qy();(0,V.useEffect)(()=>t.notifications.onNew(n=>{if(e.announce(n.map(({title:e})=>e).join(` `)),t.preferences.value.getValue().desktopNotifications)for(let r of n)hz(r.title,r.id,()=>{t.selectRun(r.runId),e.goTo(`notifications`)})}),[t,e])},QQ=({workspace:e})=>{let t=XQ(e);return ZQ(e),(0,G.jsx)(ZM,{value:e,children:(0,G.jsxs)(`div`,{className:kT.shell,children:[(0,G.jsx)(oW,{workspace:e}),(0,G.jsx)(eQ,{workspace:e}),(0,G.jsx)(UX,{workspace:e}),(0,G.jsx)(YQ,{workspace:e}),(0,G.jsx)(CQ,{commands:t,workspace:e}),(0,G.jsx)(gT,{})]})})},$Q=()=>{let e=new Map;return{get length(){return e.size},clear:()=>{e.clear()},getItem:t=>e.get(t)??null,key:t=>[...e.keys()][t]??null,removeItem:t=>{e.delete(t)},setItem:(t,n)=>{e.set(t,n)}}},e$=()=>{try{return window.localStorage}catch{return $Q()}},t$=1e3,n$=e=>{let t=[],n=!1,r=i=>{n=!0,e.setValue(``),setTimeout(()=>{e.setValue(i)},0),setTimeout(()=>{n=!1,t.length>0&&r(t.splice(0).join(` `))},t$)};return e=>{let i=Ug(e);n?t.push(i):r(i)}},r$=280,i$=340,a$=240,o$={minimumWidth:240,minimumHeight:120},s$=e=>{e.api.setConstraints(o$)},c$=(e,t,n)=>[e.onDidAddGroup(s$),e.onDidLayoutChange(()=>{n(),t()}),e.onDidAddPanel(t),e.onDidRemovePanel(t),e.onDidActivePanelChange(t),e.onDidMaximizedGroupChange(t)],l$=(e,t)=>{try{return e.fromJSON(t),!0}catch{return e.clear(),!1}},u$=(e,t,n)=>e.addPanel({id:t,component:t,title:nW(t).title,...n}),d$=e=>{let t=u$(e,`monitor`,{});u$(e,`builder`,{position:{referencePanel:`monitor`,direction:`within`},inactive:!0}),u$(e,`runs`,{position:{referencePanel:`monitor`,direction:`left`},initialWidth:r$,inactive:!0}),u$(e,`decisions`,{position:{referencePanel:`monitor`,direction:`right`},initialWidth:i$,inactive:!0}),u$(e,`notifications`,{position:{referencePanel:`decisions`,direction:`within`},inactive:!0}),u$(e,`context`,{position:{referencePanel:`decisions`,direction:`below`}}),u$(e,`logs`,{position:{referencePanel:`monitor`,direction:`below`},initialHeight:a$,inactive:!0}),u$(e,`chats`,{position:{referencePanel:`logs`,direction:`within`},inactive:!0}),u$(e,`usage`,{position:{referencePanel:`logs`,direction:`within`},inactive:!0}),u$(e,`feedback`,{position:{referencePanel:`usage`,direction:`within`},inactive:!0}),u$(e,`worktrees`,{position:{referencePanel:`feedback`,direction:`within`},inactive:!0}),t.api.setActive()},f$=(e,t,n)=>{if(!Array.isArray(e.data))return;let r=e.data,i=r.findIndex(e=>!Array.isArray(e.data)&&e.data.id===t);if(i!==-1)return{siblings:r,index:i,along:n};for(let e of r){let r=f$(e,t,!n);if(r!==void 0)return r}},p$={horizontal:`left`,vertical:`above`},m$={horizontal:`right`,vertical:`below`},h$=(e,t)=>{let{root:n,orientation:r}=e.toJSON().grid,i=r===vG.HORIZONTAL,a=f$(n,t.id,!0);if(a===void 0)return;let{siblings:o,index:s,along:c}=a,l=c===i?`horizontal`:`vertical`,u=o[s+1],d=u??o[s-1];if(d===void 0)return;let f={width:t.api.width,height:t.api.height},p=u===void 0?m$[l]:p$[l];return Array.isArray(d.data)?c?{group:null,direction:p,...f}:void 0:{group:d.data.id,direction:p,...f}},g$=(e,t)=>{if(t.api.location.type!==`floating`)return;let n=e.toJSON().floatingGroups?.find(e=>e.data?.id===t.id);if(n===void 0)return;let{position:r}=n,{width:i,height:a}=r;return{left:`left`in r?r.left:e.width-r.right-i,top:`top`in r?r.top:e.height-r.bottom-a,width:i,height:a}},_$=(e,t)=>{let{group:n}=t,r=g$(e,n),i=h$(e,n);return{group:n.id,index:n.panels.indexOf(t),...r===void 0?{}:{floating:r},...i===void 0?{}:{beside:i}}},v$=(e,t)=>{if(t!==void 0){if(e.getGroup(t.group)!==void 0)return{position:{referenceGroup:t.group,direction:`within`,index:t.index}};if(t.floating!==void 0){let{left:e,top:n,width:r,height:i}=t.floating;return{floating:{x:e,y:n,width:r,height:i}}}if(t.beside!==void 0){let{group:n,direction:r,width:i,height:a}=t.beside,o=r===`left`||r===`right`?{initialWidth:i}:{initialHeight:a};if(n===null)return{position:{direction:r},...o};if(e.getGroup(n)!==void 0)return{position:{referenceGroup:n,direction:r},...o}}}let n=e.activeGroup;return n===void 0?{}:{position:{referenceGroup:n.id,direction:`within`}}},y$=(e,t,n)=>u$(e,t,v$(e,n)),b$=(e,t)=>e.groups.find(e=>e.id===t),x$=e=>{let t=e.element.querySelector(`[role="tab"][aria-selected="true"]`);return t?.focus(),t!==null},S$=e=>{e.api.setActive(),requestAnimationFrame(()=>{x$(e.group)})},C$=e=>e.map(e=>({group:e,box:e.element.getBoundingClientRect()})).toSorted((e,t)=>e.box.left-t.box.left||e.box.top-t.box.top).map(({group:e})=>e),w$=(e,t)=>{let n=C$(e.groups),{activeGroup:r}=e;if(n.length===0)return;let i=n[((r===void 0?0:n.indexOf(r))+t+n.length)%n.length];i!==void 0&&(i.activePanel?.api.setActive(),x$(i))},T$=e=>{e.api.location.type===`grid`&&(e.api.isMaximized()?e.api.exitMaximized():e.api.maximize(),x$(e))},E$={right:{axis:`width`,delta:32},left:{axis:`width`,delta:-32},down:{axis:`height`,delta:32},up:{axis:`height`,delta:-32}},D$=(e,t)=>{let{axis:n,delta:r}=E$[t];e.api.setSize({[n]:e.api[n]+r})},O$=e=>{let t=String(Math.round(e.group.api.width)),n=String(Math.round(e.group.api.height));return`${e.title??e.id}: ${t} by ${n}.`},k$={right:{x:32,y:0},left:{x:-32,y:0},down:{x:0,y:32},up:{x:0,y:-32}},A$={left:`left`,right:`right`,up:`above`,down:`below`},j$=(e,t,n)=>{let{group:r}=t,i=g$(e,r);if(i!==void 0){let{x:t,y:a}=k$[n];e.addFloatingGroup(r,{x:Math.max(0,i.left+t),y:Math.max(0,i.top+a),width:i.width,height:i.height});return}let a=e.adjacentGroupInDirection(r,n),o=a===void 0?void 0:b$(e,a.id);o===void 0?(r.panels.length!==1||e.groups.length!==1)&&t.api.moveTo({group:e.addGroup({direction:A$[n]}),position:`center`}):t.api.moveTo({group:o,position:`center`})},M$={left:`left`,right:`right`,above:`top`,below:`bottom`},N$=(e,t,n)=>{let r=t.activePanel;if(r===void 0)return;if(t.api.location.type!==`floating`){let{beside:i}=_$(e,r);e.addFloatingGroup(t);let a=e.getPanel(r.id)?.group;a!==void 0&&i!==void 0&&n.set(a.id,i);return}let i=n.get(t.id);n.delete(t.id);let a=i?.group===void 0||i.group===null?void 0:b$(e,i.group),o=i?.direction??`right`;t.api.moveTo(a===void 0?{position:M$[o]}:{group:a,position:M$[o]}),i!==void 0&&t.api.setSize(o===`left`||o===`right`?{width:i.width}:{height:i.height})},P$=`ork.layout.v1`,F$=zs(e=>typeof e==`string`&&tW(e)),I$=ss({left:Yo(),top:Yo(),width:Yo(),height:Yo()}),L$=ss({id:F$,anchor:ss({group:Co(),index:Yo(),floating:I$.optional(),beside:ss({group:Co().nullable(),direction:_s([`left`,`right`,`above`,`below`]),width:Yo(),height:Yo()}).optional()})}),R$=ls({grid:ls({root:ls({})}),panels:hs(Co(),ls({contentComponent:F$}))}),z$=ss({dock:ts(),minimized:as(L$),folded:as(F$)}),B$=(e,t,n)=>[...e.filter(e=>e!==t),...n?[t]:[]],V$={dock:null,minimized:[],folded:[]},H$=e=>R$.safeParse(e).success,U$=e=>{let t=z$.safeParse(e);if(!t.success)return null;let{dock:n,minimized:r,folded:i}=t.data;if(n==null)return{dock:null,minimized:[],folded:i};if(!H$(n))return null;let a=new Set(Object.values(n.panels).map(e=>e.contentComponent));return{dock:n,minimized:r.filter(e=>!a.has(e.id)),folded:i}},W$=e=>new Zy(V$,{key:P$,storage:e}),G$=({dock:e,targetPanel:t,commit:n,refocus:r,announce:i,quietly:a})=>{let o=new Map,s=()=>{let t=e();t?.hasMaximizedGroup()===!0&&t.exitMaximizedGroup()};return{close:e=>{let i=t(e);i!==void 0&&(s(),i.api.close(),n(),r())},toggleMaximize:t=>{let r=t??e()?.activeGroup;r!==void 0&&T$(r),n()},toggleFloat:t=>{let i=e(),a=t??i?.activeGroup;i!==null&&a!==void 0&&(s(),N$(i,a,o),n(),r())},resize:t=>{let n=e(),r=n?.activeGroup,a=n?.activePanel;r!==void 0&&a!==void 0&&n?.hasMaximizedGroup()!==!0&&(D$(r,t),i(O$(a)))},move:t=>{let o=e(),c=o?.activePanel;o!==null&&c!==void 0&&(a(()=>{s(),j$(o,c,t)}),n(),r(),i(`${c.title??c.id} moved ${t}.`))},cycleGroup:t=>{let n=e();n!==null&&w$(n,t)}}},K$=({storage:e,wide:t,onLayoutDropped:n})=>{let r=W$(e),i=U$(r.getValue()),a=i===null;a&&r.reset();let o=Yy.create(FX(null,i??V$,t)),s=Yy.create(!1),c=Yy.create(``),l=null,u=!1,d=[],f=n$(c),p=e=>{u||f(e)},m=e=>{u=!0,e(),u=!1},h=()=>{let e=o.getValue(),t=FX(l,r.getValue(),e.wide);IX(e,t)||o.setValue(t)},g=()=>{l!==null&&r.setValue({...r.getValue(),dock:l.toJSON()})},_=()=>{g(),h()},v=()=>{for(let e of d)e.dispose();d=[],l=null,h()},y=e=>{v(),u=!0,l=e;let{dock:t,folded:i}=r.getValue();t!==null&&l$(e,t)||(a||=t!==null,r.setValue({...V$,folded:i}),d$(e)),a&&n?.(),a=!1,e.groups.forEach(s$),d=c$(e,h,g),h(),u=!1},b=e=>e===void 0?l?.activePanel:l?.getPanel(e),x=()=>{l?.hasMaximizedGroup()===!0&&l.exitMaximizedGroup()},S=e=>{let t=r.getValue();r.setValue({...t,minimized:e(t.minimized)})},C=e=>{requestAnimationFrame(()=>{let t=l?.activeGroup;!(t!==void 0&&x$(t))&&e!==void 0&&zX(RX(e))})},w=()=>{let[e]=eW;o.getValue().wide?C():e!==void 0&&zX(LX(e.id))},T=e=>{let t=b(e);if(l===null||t===void 0)return;let n=t.id;if(!tW(n))return;m(x);let r=_$(l,t);S(e=>[...e,{id:n,anchor:r}]),m(()=>{t.api.close()}),f(`${nW(n).title} minimized.`),_(),C(n)},E=e=>{if(l===null)return;let t=r.getValue().minimized.find(t=>t.id===e);S(t=>t.filter(t=>t.id!==e));let n=l;m(()=>{x(),S$(y$(n,e,t?.anchor))}),f(`${nW(e).title} restored.`),_()},D=(e,t)=>{let n=r.getValue();r.setValue({...n,folded:B$(n.folded,e,t)}),_()},O=e=>{D(e,!r.getValue().folded.includes(e))},k=e=>{if(!o.getValue().wide){D(e,!1),zX(LX(e));return}if(l===null)return;let t=l.getPanel(e);if(t!==void 0)t.api.isMaximized()||x(),S$(t);else if(o.getValue().minimized.includes(e))E(e);else{let t=l;m(()=>{x(),S$(y$(t,e))}),f(`${nW(e).title} opened.`)}},A=G$({dock:()=>l,targetPanel:b,commit:_,refocus:C,announce:f,quietly:m}),j=()=>{if(r.setValue(V$),l!==null){let e=l;m(()=>{e.clear(),d$(e)}),l.groups.forEach(s$),g(),C()}_(),f(`Layout reset.`)},M=e=>{let t=o.getValue();t.wide!==e&&o.setValue({...t,wide:e})};return{view:o,layout:r,palette:s,announcement:c,announce:f,announceFromDock:p,attach:y,detach:v,goTo:k,minimize:T,restore:E,toggleFold:O,resetLayout:j,focusPanels:w,...A,setWide:M}},q$=JA(),J$=`1.0.0-alpha.5`,Y$=()=>KQ({client:q$,open:FZ,storage:e$(),pageVersion:J$}),X$=()=>K$({storage:e$(),wide:window.matchMedia(PX).matches,onLayoutDropped:()=>{Hy.add({title:`Layout reset`,description:`The saved layout could not be read.`})}}),Z$=()=>{let[e]=(0,V.useState)(Y$),[t]=(0,V.useState)(X$);return(0,V.useLayoutEffect)(()=>nb(window,e.preferences),[e]),(0,V.useEffect)(()=>e.start(),[e]),(0,G.jsx)(Ky,{value:e,children:(0,G.jsx)(Yg,{children:(0,G.jsx)(Wy,{children:(0,G.jsx)(QQ,{workspace:t})})})})};export{Z$ as App};
|